-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Description
Description
If you have a scene that includes a directional light without a target, the ObjectLoader defaults to the target to a new Object3D(). This means that on export, the target will be serialized as a brand new uuid.
Then when the scene is deserialized with parseAsync etc., bindLightTargets will not be able to find the target (as the target pointed to a new Object3D, and so will default to another new Object3D.
This means that every export-to-json & import-from-json for the exact same scene w/o edits will continue to alter the resulting text.
Reproduction steps
- Go to https://threejs.org/editor/
File > New > PongProject > PublishFile > New > PongProject > Publish
Compare the app.json of the 2 exports - the last child in the pong app is a DirectionalLight; the "target": <uuid>" values will differ.
Code
src/loaders/ObjectLoader.js:1212
bindLightTargets(object) {
object.traverse(function (child) {
if (child.isDirectionalLight || child.isSpotLight) {
const uuid = child.target;
const target = object.getObjectByProperty('uuid', uuid);
if (target !== undefined) {
child.target = target;
}
else {
child.target = new Object3D();
}
}
});
}if (target !== undefined) && child.target = new Object3D(); are the important parts
Live example
- jsfiddle-latest-release WebGLRenderer
- jsfiddle-dev WebGLRenderer
- jsfiddle-latest-release WebGPURenderer
- jsfiddle-dev WebGPURenderer
Screenshots
Version
0.174.0
Device
No response
Browser
No response
OS
No response
