2

I am trying to save a scalar signal value for future use as a texture with the Spark AR software.

Basically, using the camera texture on a material is scripted like this:

const texture = Textures.get('CameraTexture').signal;
const material = Materials.get('defaultMaterial0');
material.setTexture(texture, {textureSlotName: "diffuseTexture"})

It is not clear to me what class is the texture const, but I am guessing this is a ScalarSignal.

That means that it is a stream, not a value. How would I go about snapshotting that value? lastValue does not work, and when trying valueOf(), I get

JavaScript error: Exception in native code while calling a function: valueOf() called on a Signal. This probably means that you are trying to perform an arithmetic operation on a signal like +, -, *, etc. Use functions .add, .sub(), etc on the signal instead or .subscribeWithSnapshot() on an EventSource to get the signal's current value on a callback.

And subscribeWithSnapshot() is not a function..

If anyone has any idea how I could do this, or the specific reason why I can't, help would be appreciated!

Thanks!

4

1 回答 1

3

你不能。目前在 SparkAr 中不允许保存纹理。而且我认为数据类型应该是纹理缓冲区(最终......)

编辑:此外,相机纹理信号不是标量信号,而是 ShaderSignal。你可以检查这个:

Diagnostics.log(Textures.get('CameraTexture').signal);
于 2019-03-21T14:41:09.603 回答