How to handle controls after removing all object from scene


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.

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)

thanks in advance.

I don’t want to be mean to you but I’m afraid you won’t get any feedback to this issue unless you demonstrate the issue with a live example (as mentioned in your other topic: How to remove any loaded Object like 3D Model using OBJLoader and MTLLoader and text)

Yeah, That’s true. But I am working on large project and I don’t know How can i demonstrate as live example.

Hi @Mugen87

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 appreciate your effort but unfortunately nobody can debug your code with a screenshot.

1 Like

then I don’t think so I have any other way to demonstrate you.

Hi all!

I’ve encountered the same issue.
Here’s the fiddle:

1 Like

Call controls.detach(); before removing mesh

1 Like

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:

controls.attach( mesh );
scene.add( mesh );

So a check might be confusing in this method.

Thank you for your reply @Mugen87 !

Yes, please, do so!

I agree.

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.


1 Like

FYI: The docs and the error handling in TransfromControls should be improved with the next release R114:

@Mugen87 Thanks for the info!
I’ll gladly update my node packages :slight_smile:
@Mugen87 @mrdoob Thank you for all of the support!