takahirox / three-gltf-extensions

Unofficial Three.js glTF loader/exporter plugins
MIT License
123 stars 20 forks source link

MSFT_LOD onUpdate values inconsistent #62

Open arthurmougin opened 2 years ago

arthurmougin commented 2 years ago

When loading the torus asset (https://github.com/takahirox/three-gltf-extensions/tree/main/examples/assets/gltf/Torus/glTF-lod), the update does not return the good mesh :

Using this function as OnUpdate : (e,f) =>{console.log(e,f)}

return

11:50:36.923 
MSFT_LOD_Loader.js:64 LOD {uuid: '19A64444-FB39-4DDD-8C74-B1FFE2AC9253', name: '', type: 'LOD', parent: null, children: Array(1), …} 
Mesh {uuid: 'F2B479C3-3FA3-47D4-9EAD-96B88856A828', name: 'Torus_Low_LOD', type: 'Mesh', parent: LOD, children: Array(0), …}

11:50:36.924 
MSFT_LOD_Loader.js:64 LOD {uuid: '19A64444-FB39-4DDD-8C74-B1FFE2AC9253', name: '', type: 'LOD', parent: null, children: Array(2), …} 
Mesh {uuid: '520EB3BF-00F1-4F39-9157-D76FB020EC0E', name: 'Torus_Middle_LOD', type: 'Mesh', parent: LOD, children: Array(0), …}

11:50:36.924 
MSFT_LOD_Loader.js:64 LOD {uuid: '19A64444-FB39-4DDD-8C74-B1FFE2AC9253', name: '', type: 'LOD', parent: null, children: Array(3), …} 
Mesh {uuid: '1BDD1ED5-AB57-4CE1-8A4F-7591813F2FB0', name: 'Torus', type: 'Mesh', parent: LOD, children: Array(0), …}

11:50:36.924 
MSFT_LOD_Loader.js:64 LOD {uuid: 'FBFC4D70-915F-47F6-8068-4AC6B92ED06D', name: '', type: 'LOD', parent: null, children: Array(1), …} 
Mesh {uuid: '6AE523EF-F985-4B3B-BD3A-74CBBC2EC5AE', name: 'Torus_High_LOD', type: 'Mesh', parent: LOD, children: Array(0), …}

11:50:36.924 
MSFT_LOD_Loader.js:64 LOD {uuid: 'FBFC4D70-915F-47F6-8068-4AC6B92ED06D', name: '', type: 'LOD', parent: null, children: Array(2), …}
Mesh {uuid: 'C6767CBC-08CA-4170-AA51-0939FE8D33B6', name: 'Torus_High_LOD', type: 'Mesh', parent: LOD, children: Array(0), …}

11:50:36.925 
MSFT_LOD_Loader.js:64 LOD {uuid: 'FBFC4D70-915F-47F6-8068-4AC6B92ED06D', name: '', type: 'LOD', parent: null, children: Array(3), …} Mesh {uuid: '1DD73E77-3CFD-428E-A912-448D3BE1CF9D', name: 'Torus_High_LOD', type: 'Mesh', parent: LOD, children: Array(0), …}

which translate to:

Expected behavior :

Is this a naming mistake in the 3D model or a bug ? cannot tell :/

takahirox commented 2 years ago

Thanks for the report. But it's intentional. Donut 2 has LOD only in materials. In your example, Donut 2 meshes have the same name but you will notice that their uuids are different depending on the distance. Different uuids mean they are different meshes. I think they refer to the same high-poly geometry but refer to different materials. Further mesh should refer to lower quality material.

I think we should let them have clear name and better to put clearer explanation in the example. I will close this issue when we do them.