So I'm making a ball bounce in spark AR with cannon.js. Everything was working fine until I wanted to get the position of the forehead from the facetracker via the patch editor to a script.
Error:
Error:Exception in HostFunction: 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.
at ScalarSignal::valueOf (native)
{
"line": 4841,
"column": 19,
"sourceURL": "cannon.js"
}
My patches that send the vector3 of the forehead to the script.
this piece of code is giving the error:
var pos = Patches.getVectorValue('HeadPos');
groundBody.position.set(pos);
I sadly can't find anything online about sending a vector3 from the patches to a 'Working' value in the script, Does somebody know how to send a vector3 value ta a script and the use it as a value?
I've found a selution when working with cannon.js. cannon.js has a kind of update function so you can use .pinLastValue() because it does this every frame in order to update the physics.
My code:
This code gets the x, y and z values individually from the patches where I send these values individually as well. I could have done it as a Vector3 from both sides as well, but I thought this looked nicer and made it easier to edit the values individually through the patches instead of packing it as a Vector3 again.