ReferenceError: THREE is not defined

I’m trying to manipulate the camera, using “Change the camera position on Z axis”. Then I get the error below.

I’m still exploring what I can do with GDevelop. I’m not sure what I should expect of the action if it works, but since I get this crash, I report it. I’m not using JavaScript in this case. The Action is triggered by moving a slider; then it crashes directly.

Googling for THREE suggests that there is a problem outside of GDevelop. For example, here: ReferenceError: THREE is not defined - Questions - three.js forum . But the problems reports that I see with Google are several years old. Are there any unit tests for this functionality in the GDevelop source code?

Here is the error log, copied from the running scene.

A crash or error happened in the game.
If you're using JavaScript, verify your code. Otherwise, this might be an issue with GDevelop - consider reporting a bug. Full error is: THREE is not defined

ReferenceError: THREE is not defined
    at Object.g.setCameraZ (file:///var/folders/3m/wpx62c0n0633x91vq_bxs9740000gn/T/GDTMP-501/preview/Extensions/3D/Scene3DTools.js:1:330)
    at Object.gdjs._214stersj_246nCode.eventsList11 (file:///var/folders/3m/wpx62c0n0633x91vq_bxs9740000gn/T/GDTMP-501/preview/code0.js:538:22)
    at Object.gdjs._214stersj_246nCode.eventsList12 (file:///var/folders/3m/wpx62c0n0633x91vq_bxs9740000gn/T/GDTMP-501/preview/code0.js:582:115)
    at c.gdjs._214stersj_246nCode.func [as _eventsFunction] (file:///var/folders/3m/wpx62c0n0633x91vq_bxs9740000gn/T/GDTMP-501/preview/code0.js:672:26)
    at c.renderAndStep (file:///var/folders/3m/wpx62c0n0633x91vq_bxs9740000gn/T/GDTMP-501/preview/runtimescene.js:1:5067)
    at r.step (file:///var/folders/3m/wpx62c0n0633x91vq_bxs9740000gn/T/GDTMP-501/preview/scenestack.js:1:465)
    at file:///var/folders/3m/wpx62c0n0633x91vq_bxs9740000gn/T/GDTMP-501/preview/runtimegame.js:1:7677
    at i (file:///var/folders/3m/wpx62c0n0633x91vq_bxs9740000gn/T/GDTMP-501/preview/pixi-renderers/runtimegame-pixi-renderer.js:1:9624)

Tested using GDevelop version 5.3.188 on Mac, and later version 5.3.189.

I’ve tried to share a simplified demonstration of the problem, here:

but apparently there is no crash online. On the other hand, nothing visible happens when the actions are executed.

1 Like

Just a random thought: Is this a problem that might be fixed by running npm install somewhere in the GDevelop installation? When I initially opened the source repository in IntelliJ, I had red markers in Scene3DTools.ts, on the word OrthographicCamera in THREE.OrthographicCamera at line 15. npm install helped.

This of course doesn’t help my runtime problems in GDevelop. I don’t use IntelliJ or the source files for that.

Thank you for reporting the issue and providing a project to reproduce. It should be fixed in the next release (5.3.191).

To workaround the issue with the current release, you can either use the camera zoom action or add a 3D object in the scene.


Thank you. The workaround works fine.

Outside the scope of the bug, I’m confused, because the camera Z position and the camera zoom level seem to do the same thing.

The camera Z action allow to zoom as if the camera were moving on the Z axis whereas the camera zoom action only does a ratio.

1 Like

With that explanation, I assume that moving in the z direction, and applying a ratio, would have the same kind of result, if the camera is an OrthographicCamera, but not if it’s a PerspectiveCamera. I don’t remember if that is a choice that can be made within GDevelop, but at least it exists in THREE.

Actually, with an orthographic camera, changing the camera distance doesn’t change the perceived object size. You would need to use the camera zoom action in this case.
You can find the camera setting in the layer properties.

1 Like