For some reason, the camera in this Playground example is locked (detached?) until you click on the first mesh. After that, the camera moves freely with mouse commands (attached to the canvas?), and you can continue to move the meshes around.
I’ve been using this line to start a scene with a freely moving camera:
camera.attachControl(canvas, true);
But adding it returns this error:
Line 16 : 981438 - Cannot read property ‘addEventListener’ of undefined
Thanks! It works perfectly now In the interest of understanding why it works, is getRenderingCanvas a way to tell the program to look for what’s happening in any particular moment in time in the scene?
So basically **engine.getRenderingCanvas()**method, gets an instance of that canvas provided to the engine and stores it into variable.
With that said, the reason why you need to put canvas.attachControl() method after is because canvas variable is not yet defined (undefined).
attachControl() -> to gain control over the scene with your mouse (or any other input) you need to attach event listeners to the canvas element, which this method does behind the scenes.
So if you try to attachControl() before you defined canvas you get that error
Cannot read property ‘addEventListener’ of undefined