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: Support InstancedMesh / 'EXT_mesh_gpu_instancing'

See original GitHub issue

It would be nice if GLTFLoader automatically created InstancedMeshes from a GLTF file including instanced meshes.

Here is an exemple file : instanced_cube.glb

Screenshot_1

Blender lets us reuse a mesh ( like other modeling softwares I’m sure ), here is the hierarchy in Blender :

Screenshot_2

I would like GLTFLoader to (optionaly?) create an InstancedMesh of this cube, instead of making several identical Meshes, because :

  • Manually removing the created Meshes to replace them with an InstancedMesh is tedious.
  • It takes memory for nothing. ( potentially a lot )

Some context :

A GLTF file can reuse meshes, this is what the GLTFLoader.parse get after reading the file above :

01

Issue Analytics

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

github_iconTop GitHub Comments

12reactions
takahiroxcommented, Mar 22, 2022

Sorry for slow progress because I have been a bit too busy…

Recently I have fixed some improtant problems in the plugin which I really wanted to resolve before moving it into GLTFLoader.

There is still lack of some supports, SkinnedMesh and better custom instance attributes handling, but they are advanced features. We may be able to start to consider to move the plugin into GLTFLoader as built-in plugin and can think of advanced feature supports later.

If it sounds good, I want to make a PR hopefully soon.

3reactions
takahiroxcommented, Jun 2, 2021

Some additional notes…

I already released the EXT_mesh_gpu_instancing glTF loader plugin at

https://github.com/takahirox/three-gltf-extensions/tree/main/loaders/EXT_mesh_gpu_instancing

You can use it now, but note that I didn’t test well yet. Some glTF or Three.js functions might not work (e.g. animation). Once I confirm the functionalities I would think of moving it into the Three.js glTF loader as built-in plugin.

As @donmccurdy explained, our work requires pre-processing. I don’t think of automatically converting the regular meshes to instanced mesh. If you still want to automatically do that, you may write your own plugin with the plugin API (Three.js glTF loader extensibility mechanism). We haven’t written the plugin API document yet, so please refer to the plugins in

https://github.com/takahirox/three-gltf-extensions/tree/main/loaders/

and the built-in plugins in the glTF loader for the API.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GLTFExporter support for EXT_mesh_gpu_instancing
Hi team, Can/will EXT_mesh_gpu_instancing extension be supported for GLTFExporter? It appears already supported by GLTFLoader Also appears ...
Read more >
InstancedMesh from GLTF doesn't work?! - three.js forum
Hi, InstancedMesh ([1] in code) doesn't work when geometry loaded from GLTF - is ... import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js"; ...
Read more >
InstancedMesh - glTF-Transform - Don McCurdy
Sets an instance attribute to an Accessor. All attributes must have the same instance count. Defined in packages/extensions/src/ext-mesh-gpu-instancing/ ...
Read more >
Tweets with replies by takahiro(John Smith ... - Twitter
the glTF loader plugin hardcodes to load _COLOR attribute as instance color ... attribute · Issue #7 · takahirox/glTF-Blender-IO-EXT-mesh-gpu-instancing.
Read more >
How do I get the THREE.JS InstancedMesh working?
JS InstancedMesh to make copies of an imported gltf file, but nothing shows up in the ... const loader = new GLTFLoader() loader.load(...
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