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!
You can't. Currently in SparkAr is not allowed to save a texture. And I think the data type should be a texture buffer (eventually...)
EDIT: Also, the camera texture signal it's not a scalarSignal but a ShaderSignal. you can check this:
Diagnostics.log(Textures.get('CameraTexture').signal);