4

I am trying to access a 2D text object with the findfirst function and it was working in the previous update (Version: 97), but in the new update (Version: 98.0.0.17.243 (248298637)) it throws the following error:

JavaScript error: Unexpeted SceneObject reference: 
{"identifier":"2_d_text_mode74846-11e77cda-9218-4c2f-871d- 
6f0d38749752", "name":"ApplyName1","materialIdentifier":"",
"className":"planarText","modelId":3715}
    
 no stack

I have updated the Spark AR just this morning so it was really strange that we got this error. We also looked at the documentation and implemented the example:

https://sparkar.facebook.com/ar-studio/learn/scripting/adding-physics-to-your-effects#The-script%5C

After implementing the example we found that this error only occurs when we are trying to find a 2d text object.

This is the script used in our game:

let text;
Promise.all([
    Scene.root.findFirst('2dText0')
]).then(function (objects) {
    text = objects[0];

}).catch((error) => Diagnostics.log(error));

Can someone help us, or does someone know the answer to this problem? We posted this question to the Spark AR forums as well to get an answer, but we're also reporting this to facebook a.k.a. the Spark AR bug report system.

Version: 98.0.0.17.243 (248298637) OS: Windows

Grisstusss
  • 76
  • 6

1 Answers1

1

EDIT: JUMP FROM V97 TO V100. They have fixed the problem with Scene.root.findFirst

OLD: I've the same problem in v98... "text" class is broken. I've reported this bug, please write in SparkARCommunity on fb:

(async ()=>{
const myText=await Promise.all([Scene.root.findFirst('2DText0')]);
myText.text='hello world';
})();

".text" in 4th line is the problem, it's broken.

Anyway the only solution is to "play" with: Patches.outputs.setString('varFromScript',value) / Patches.inputs.getString('toScript'). I'm awaiting a fix or some news from Spark AR team or I'll be forced to replace my hard code...

  • 1
    Thanks for the answer. But this is not what we are looking for, the problem arrises when we are trying to find "" the text object. Do you know how to fix it. – Grisstusss Oct 05 '20 at 10:14
  • The problem is the text object, please explain me your filter, we can solve this through fromScript/toScript – Michele Renzullo Oct 06 '20 at 11:41
  • 1
    What he's saying is is that the find/findfirst method doesn't work with 2Dtext. **He isn't getting the error because he's trying to edit the text! He's getting the error when trying to add the text to a value!** – Martijn Gelton Oct 13 '20 at 08:19
  • Solved with V100 I ve jumped from V97 to v100 – Michele Renzullo Oct 29 '20 at 11:39