I upload 3d models and created 2d text on marker. now can remove all content means this 3d models and 2d text from scene.
now how to handle this controls (transformContorl, dragControl and orbitControl) if there will be no content on marker ?
content will not display but still it will bind with controls after remove objects.
Error:
Uncaught TypeError: Cannot read property ‘matrixWorld’ of null
at TransformControls.updateMatrixWorld (TransformControls.js:223)
at Scene.updateMatrixWorld (three.module.js:8820)
at WebGLRenderer.render (three.module.js:23792)
at ImageAugmentationCreator.renderCanvas (imageAugmentationCreator.tsx:1356)
at ImageAugmentationCreator.animate (imageAugmentationCreator.tsx:1331)
this is screenshot of my project. first I uploaded 2d text and 3D model
then I delete that content and then I move my mouse on marker. then It will showing me this error.
I have no problem with detaching the mesh.
I’m only pointing out what causes the problem.
You can also cause it with attaching a loose Object3D which is not in the scene, or has no parent.
It would be nice to add a check to the source if [TransformControls].object is not only undefined, but also has no parent.
The .attach(object) method can be improved with the same check, also.
Thanks for this feedback! Your fiddle really help to clarify the issue.
How about just noting in the documentation 3D objects have to be part of the scene graph when using this class? It seems this is a fundamental (and logical) assumption of TransformControls.
It’s absolutely valid to attach an object first and then add it to the scene graph. Code example:
In my case, finding the culprit code took me a really long time, that’s because the error was pointing to the 'matrixWorld' of null. I had to go through the source code of TransformControls to figure out which objects show up as null. I couldn’t use debugger, because when you pause on error (breakepoint), the stack tree is only a huge list of a self reference to the render/requestAnimationFrame loop.
What I wish for is a different exception message, that would point me to a solution. It would be fabulous if you would like to consider adding a custom error message to the TransformControls.js:209 part of the code.