GLTFLoader: primitive type .extras
See original GitHub issueDescription of the problem
From #14315
Currently GLTFLoader
just sets .extras
property to Three.js object’s .userData
.
if ( nodeDef.extras ) node.userData = nodeDef.extras;
But .extras
type in glTF is any
while .userData
type in Three.js is object
. If .extras
have primitive type value, like integer or strings, .userData
will have invalid type value in Three.js.
I’m thinking of .userData.glTF
(or .userData.extras
) instead of .userData
to set .extras
to.
if ( nodeDef.extras ) node.userData.glTF = nodeDef.extras;
Another option is to set like { value: *.extras }
to .userData
if .extras
is non-object.
if ( nodeDef.extras ) {
node.userData = ( typeof nodeDef.extras === 'object' )
? nodeDef.extras
: { value: nodeDef.extras };
}
Any thoughts?
/cc @donmccurdy @wlinna
(BTW, we should replace if ( *.extras )
with if ( *.extras !== undefined )
because .extras
can be 0, false, or empty strings ‘’.)
Three.js version
- Dev
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Hardware Requirements (graphics card, VR Device, …)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Top Results From Across the Web
GLTFLoader – three.js docs
GLTFLoader. A loader for glTF 2.0 resources. glTF (GL Transmission Format) is an open format specification for efficient delivery and loading of 3D...
Read more >Three.js Loading a .GLTF File
The gLTF format is actually a format designed from the ground up for be used for displaying graphics. 3D formats can be divided...
Read more >Load 3D Models in glTF Format - Discover three.js!
You can use three.js to build any kind of 3D application, however, ... To load glTF files, first, you need to add the...
Read more >three.js 加载gltf模型的简化demo - CSDN博客
GLTFLoader : Ignoring primitive type .extras, ' + gltfDef.extras ); } } } /** * ...
Read more >GLTF Format — x-visual 0.4 documentation
Three.js GLTFLoader will create then use a cache for meshes' material: GLTFParser.prototype.assignFinalMaterial = function ( mesh ) { if ( ! cachedMaterial )...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1. While technically allowed, no tools are doing this. Better to establish clear best practice that it be an object, and perhaps even disallow primitive
extras
types in a future version of glTF. Ifextras
is a primitive type, we could log a warning and ignore it, but until/unless it causes a real issue I’d vote to avoid adding specific code for the case at all.Yeah, I prefer
.userData.glTF
too but one concern. How we should export.userData
.If we import
.extras
as.userData.glTF
and export.userData
as.extras
, we’ll get.userData.glTF.glTF.glTF...
if we repeatedly import and export.