question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GLTFLoader: Objects not found under original name, regression from r119 -> r123

See original GitHub issue

Describe the bug After upgrading three to r123 on a working project, that was before using r119, three cannot find some Camera’s anymore. Strangely enough it can find some cameras, but not others. It doesn’t seem to be related to ortographic vs perspective. It looks like the problem arrises only with nested camera’s, so cameras within other 3D objects. But I’m not completely sure yet.

I’ve read all migration guides from r119 -> r120 up to the last one, but cannot find anything in there that should cause this IMO.

I’m still debuging, but so far this seems to be the issue: getObjectByName() can find some camera’s, but others return undefined so cannot be found in the scene loaded by gltf. Before this was working fine, the only thing I needed to do before was traverse this object, because for some reason camera’s are wrapped inside some object in gltf. But now even the wrapper object cannot be found. It is still in the gltf or glb though, nothing changed to the data.

const cameraWrap = scene.getObjectByName(camName);

I keep you informed if I know more when exactly this happens. But for now please let me know if something has changed that could cause this that I should be aware of! Thanks

To Reproduce

Steps to reproduce the behavior:

  1. Create a scene with objects and camera’s in blender (probably the problem occurs when cameras are nested (and nested) within 3D objects, but not sure yet)
  2. Use the blender gltf or glb export to export to gltf or glb
  3. Import the gltf or glb in three to get the scene
  4. Try to get the cameras by using scene.getObjectByName(camName)

Code

scene.getObjectByName(camName)

Expected behavior

Nothing changed in three version according to the migration guide around cameras or objects AFAIK, so I would expect this to still work in r123.

Platform:

  • Device: Desktop/Mobile
  • OS: Windows
  • Browser: Edge Chromium
  • Three.js version: r123

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
donmccurdycommented, Apr 2, 2021

An opt-out method is proposed in https://github.com/mrdoob/three.js/pull/16639#issuecomment-797653487, if someone would like to open a PR and confirm it fixes this issue.

it would be better to never rename and just throw an error message to the user … it’s better to think of a developer as a mature developer, not as a beginner…

I’m afraid even experienced developers will disagree on whether duplicate names are “errors.” The glTF specification does not require unique names, so the file is 100% valid and will play animation in other glTF viewers. three.js does require unique names for animation to work, and so GLTFLoader has the responsibility of turning a valid glTF file into valid three.js objects. No single perfect solution here, so I think the opt-out method is a reasonable choice.

0reactions
donmccurdycommented, Oct 14, 2022

We’re still open to accepting a PR for an opt-out method, to prevent GLTFLoader from de-duplicating names. But I think someone who has a use case for the feature will need to implement and test it, this is not otherwise on the roadmap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

THREE.JS : GLTFLoader 404 Not Found problem
Finally I have a Cross Origin Error when I type the entire url in the code (will it be a problem when uploading...
Read more >
GLTFLoader – three.js docs
A loader for glTF 2.0 resources. glTF (GL Transmission Format) is an open format specification for efficient delivery and loading of 3D content....
Read more >
Three.js Loading a .GLTF File
Checking the hierarchy in Blender I found out that the artist had scaled the node all the cars are parented to. Scaling is...
Read more >
Extending the glTF Loader in Babylon.js - Medium
The loader extensions also have access to the base loader so that they can invoke the default behaviors. Once a loader extension has...
Read more >
Load 3D Models in glTF Format - Discover three.js!
The original glTF Version 1 never found widespread use and is no longer ... You can find the loader in examples/jsm/loaders/GLTFLoader.js on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found