Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GltfLoader fails for glTF with no scenes #12447

Open
j9liu opened this issue Jan 21, 2025 · 0 comments
Open

GltfLoader fails for glTF with no scenes #12447

j9liu opened this issue Jan 21, 2025 · 0 comments

Comments

@j9liu
Copy link
Contributor

j9liu commented Jan 21, 2025

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.

  1. Open Apps/SampleData/Models/BoxUnlit/BoxUnlit.gltf in a text editor like VSCode.
  2. Delete the scene and scenes properties from the file.
  3. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants