is there a best practice for adding and removing a highlight with an interaction?
//
within my “draw loop”/“request animation frame”/“update” whatever, I have this code:
//console.log(hl);
if (guardianOne.flashing == true && POV == false) {
redSphere.seek(playerSphere);
redSphere.animate("blend");
console.log("hi");
console.log(hl);
hl.addMesh(guardianOne, BABYLON.Color3.Green());
} else {
//guardianOne
redSphere.wander({ weight: 10 }).seek(greenTarget);
redSphere.animate("blend");
hl.removeMesh(guardianOne);
}
for some reason, even though the console log shows me the highlight layer object, I can’t add the guardian on the next line. I get this error:
VM89:1284 TypeError: Cannot read property ‘add’ of undefined
at t.addMesh (babylon.js:16)
at (index):3299
at t._renderFrame (babylon.js:16)
at t._renderLoop (babylon.js:16)
at Object.renderFunction [as callback] (babylon.js:16)
at XRSession$1..onDeviceFrame (:1281:42)
How can it be undefined when I literally just console logged it the line before?