Skip to content

Preserve unknown gltf mesh extensions in GLTFLoader#25948

Merged
donmccurdy merged 2 commits intomrdoob:devfrom
cstegel:mesh-extensions
May 5, 2023
Merged

Preserve unknown gltf mesh extensions in GLTFLoader#25948
donmccurdy merged 2 commits intomrdoob:devfrom
cstegel:mesh-extensions

Conversation

@cstegel
Copy link
Contributor

@cstegel cstegel commented Apr 27, 2023

Description

This is needed for custom glTF extensions which handle extension data under each mesh entry in the glTF json.

Previously, only unknown extensions in the glTF json's meshes[].primitives[].extensions field were added to the populated mesh's userData.gltfExtensions field. It is also valid to add data under glTF json meshes[].extensions so those should be added to the resulting mesh, too.

Previously, only unknown extensions in the gltf's
"meshes[].primitives[].extensions" field were added to the populated mesh's
userData.gltfExtensions field. It is also valid to add data under
"meshes[].extensions" so those should be added to the resulting mesh, too.
@donmccurdy
Copy link
Collaborator

Thanks @cstegel! When a glTF mesh has multiple primitives, I'm not sure we should be duplicating the extensions across all of the resulting THREE.Mesh instances. How about something like this, later in the affected function?

if ( meshes.length === 1 ) {

	if ( meshDef.extensions ) addUnknownExtensionsToUserData( extensions, meshes[ 0 ], meshDef );

	return meshes[ 0 ];

}

const group = new Group();

if ( meshDef.extensions ) addUnknownExtensionsToUserData( extensions, group, meshDef );

...

@mrdoob mrdoob added this to the r153 milestone May 4, 2023
@cstegel
Copy link
Contributor Author

cstegel commented May 4, 2023

@donmccurdy sounds good! I didn't notice that multiple primitives would get put together in their own Group. Adding it to the Group seems fine to me. I've applied those changes now.

@donmccurdy
Copy link
Collaborator

Thanks @cstegel!

@donmccurdy donmccurdy merged commit 7fdb969 into mrdoob:dev May 5, 2023
@cstegel cstegel deleted the mesh-extensions branch May 5, 2023 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants