I am trying to access a null object inside a plane tracker located in the Scene without success. I believe the issue is the hierarchy of the scene but, I need the plane tracker to be outside the Device (screenshot for reference). Any help is really appreciated.
Here's the scene setup: Screenshot
[Error] Warning: Possible Unhandled Promise Rejection: ReferenceError: Property 'obj0' doesn't exist
Code:
const Scene = require('Scene');
(async function () {
const allObjs = ([
obj0,
] = await Promise.all([
Scene.root.findFirst('obj0'),
]));
});
In your example you are retrieving obj0 asynchronously, meaning you cannot expect it to be available in the next line but only once the async call has finished.
To ensure obj0 is available, either use Promise.then as in
Scene.root.findFirst('obj0').then(obj0 => {
// obj0 is available here
});
or await it synchronously as in
const obj0 = await Scene.root.findFirst('obj0');
// obj0 is available