Camera gets detached after touch event + dispose() on mobile

Took me a while to track this one down. Here’s the sequence:

  1. Import GLB and add to scene
  2. Add Gizmo to mesh on pick
  3. On pointer double tap, dispose() of the mesh or bounding box

Voila, the camera is detached from canvas. Reattach and you’re good to go again. Behavior does not occur on desktop. And doesn’t occur on mobile if dispose() is run from the console. Only after a touch event.

Not a big deal, since I can just re-attach… but wanted to log it.

I am not able to repro in the playground, do you have a repro we could use ? so that we can fix it ASAP ?

Oh, looks like it’s repro-ing on desktop now too.


  1. Add an object using the UI (load mesh)
  2. Double click (or double tap) to delete it
  3. Camera is now detached

Delete runs boundingbox.dispose() - which is on line 184 of object_manager.js.

  • If I comment out that line, camera doesn’t detach.
  • If I run that line from console, camera doesn’t detach. To run from console line, do: g.objectManager.myObjs[0].handler_boundingbox.dispose();
  • If I reattach the camera with g.camManager.attachControl(), it works again.

Here’s how you add object (click add):

Unfortunately it is hard to debug in your app for us :frowning: would it be possible to repro in the playground instead ? This would be more efficient for us to be able to fix.

Was hoping you wouldn’t say that…
I’ll work on it…

OK, i repro’d it:

Double click the sphere to detach camera.
(sorry ugly code. working quick)

ps. Note that if you double click anywhere other than the sphere, camera does not detach. Which makes me think that it has something to do with running the pick event and attach gizmo process at the same time that the double-click event is doing a dispose().

Ohhhhhhh so the camera is not detached but it feels like it because you dispose the mesh without disposing the gizmo.

Demo pg works only if you click the mesh once and then double tap somewhere else.

You sure?
After deleting the sphere by double clicking on it, if you run
scene.cameras[0].attachControl(canvas, false)
In console, you get camera control back again…
(in my production code, i set the gizmo’s attachedMesh to null… just skipped that here)

As you kill the mesh during the pointer events, the dragbehavior which plays with the event to detach attach the camera to allow dragging, can not catch the final up event to reattach the camera.

It is why you need to kill it separately to force the reattach.

I ll see if I can include it automatically.