Open
Description
What happened?
I was testing a glTF model that contains no scene
or scenes
property. GltfLoader
is supposed to resolve this by picking the first node in the nodes
array. However, the code results in attempting to access an undefined
node.
I have narrowed it down to some weird behavior in loadScene
. The function getSceneNodeIds
is called before it, and it's supposed to substitutde the nodes
array if no scenes
exist. This is successfully chosen. It is the following line that results in an undefined
node being added to the scene:
scene.nodes = sceneNodeIds.map(function (sceneNodeId) {
return nodes[sceneNodeId];
});
Reproduction steps
This is most easily reproduced in locally-built CesiumJS.
- Open
Apps/SampleData/Models/BoxUnlit/BoxUnlit.gltf
in a text editor like VSCode. - Delete the
scene
andscenes
properties from the file. - Navigate to the "3D Models" sandcastle. Select "Unlit Box" from the dropdown. You'll get this error:
An error occurred while rendering. Rendering has stopped.
TypeError: Cannot read properties of undefined (reading 'matrix')
TypeError: Cannot read properties of undefined (reading 'matrix')
at ModelUtility.getNodeTransform (http://localhost:8080/Build/CesiumUnminified/index.js:72701:28)
at traverseAndCreateSceneGraph (http://localhost:8080/Build/CesiumUnminified/index.js:100266:43)
at initialize14 (http://localhost:8080/Build/CesiumUnminified/index.js:100182:27)
at new ModelSceneGraph (http://localhost:8080/Build/CesiumUnminified/index.js:100098:3)
at Model.update (http://localhost:8080/Build/CesiumUnminified/index.js:103316:24)
at PrimitiveCollection.update (http://localhost:8080/Build/CesiumUnminified/index.js:141598:19)
at updateAndRenderPrimitives (http://localhost:8080/Build/CesiumUnminified/index.js:241846:21)
at executeCommandsInViewport (http://localhost:8080/Build/CesiumUnminified/index.js:241697:3)
at Scene4.updateAndExecuteCommands (http://localhost:8080/Build/CesiumUnminified/index.js:241519:5)
at render (http://localhost:8080/Build/CesiumUnminified/index.js:242270:9)
Sandcastle example
http://localhost:8080/Apps/Sandcastle/index.html?src=3D%20Models.html
Environment
Browser: Google Chrome 131.0.6778.265
CesiumJS Version: 1.124
Operating System: Windows