What is wrong with this peace of code?

const vector = Vector3.Unproject(
            new Vector3(0, 0, 0),
            engine.getRenderWidth(),
            engine.getRenderHeight(),
            Matrix.Identity(),
            scene.getViewMatrix(),
            scene.getProjectionMatrix());

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'copyToArray')

1 Like

Hey there :slightly_smiling_face:. If the scene hasn’t been rendered yet, then you’ll need to call scene.updateTransformMatrix() first, otherwise scene.getViewMatrix() and scene.getProjectionMatrix() will return undefined.

scene.updateTransformMatrix();

Alternatively, you can call camera.getProjectionMatrix() and camera.getViewMatrix() directly, then scene.updateTransformMatrix() won’t be needed.

4 Likes

Hi there @trsh just checking in! Did Blake’s answer solve your problem :smiley: