Hi.
I have been fighting setDrawRange and I can confirm that it doesnβt work as expected.
M2815049900600-FLX02_B.glb (28.6 KB)
I attach this model which is composed of 28 meshes ordered by size.
The order can be get by the name of the mesh.
I have tried to merge these meshes taking their geometries in a ordered array and then I merged them using BufferGeometryUtils.mergeBufferGeometries and it doesnβt work:
Here the scne opened in threejs.editor:
1. 0: Mesh {uuid: β3A9D7170-FD5E-4FB1-9C2A-52EF9DC3EC91β, name: β003β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
2. 1: Mesh {uuid: βE1F1868F-DF86-4971-87AF-DA3D3D9BAAD2β, name: β008β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
3. 2: Mesh {uuid: β06AEF7EC-476D-4F9A-BAF0-9C2BB31288EBβ, name: β009β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
4. 3: Mesh {uuid: βD410DCAA-D41D-4BAB-B3E9-F9D8B71BFBA8β, name: β013β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
5. 4: Mesh {uuid: βF0904008-9D03-4C6E-B3FE-DB5FEB103344β, name: β014β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
6. 5: Mesh {uuid: βDBF5D1F5-FB9E-47CF-9EB0-1315CD25EE3Dβ, name: β018β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
7. 6: Mesh {uuid: β6C5D9B9E-FE37-475C-B0DB-E31A46B27865β, name: β004β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
8. 7: Mesh {uuid: βA0251AAF-9607-4B01-A8D0-A2DA4B1BCB7Dβ, name: β023β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
9. 8: Mesh {uuid: βE6BCF7D4-8A41-4F6C-9089-6D509AF65A71β, name: β024β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
10. 9: Mesh {uuid: β0E0AB326-0169-46D7-8B35-977741AC8E81β, name: β007β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
11. 10: Mesh {uuid: βA721F225-864C-44E7-9553-B4080202E3EEβ, name: β012β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
12. 11: Mesh {uuid: β781622DA-C619-4ED7-9D6C-9B03DD26C1BBβ, name: β017β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
13. 12: Mesh {uuid: β5A5EFA95-EBBA-4C5B-AD6E-34F97609A219β, name: β021β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
14. 13: Mesh {uuid: β6CA20DD6-43FF-496D-9743-BB775E59CBB5β, name: β027β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
15. 14: Mesh {uuid: β54299DA7-AE5D-4631-BCA9-592857A9B9B5β, name: β000β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
16. 15: Mesh {uuid: β7BC239A0-B8B6-4A49-B985-D27427A916A9β, name: β006β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
17. 16: Mesh {uuid: β5720AFF1-BEE3-4E87-9F3F-5DC64B11D9E7β, name: β011β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
18. 17: Mesh {uuid: βC243E2C0-D311-42CD-B78E-F631DB0C2191β, name: β016β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
19. 18: Mesh {uuid: βD2FF9549-C4F0-48BA-A595-6F216C62ECADβ, name: β020β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
20. 19: Mesh {uuid: β9EFC4BC3-E9B5-4B9A-92F4-B1504B31526Fβ, name: β025β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
21. 20: Mesh {uuid: β0274B73E-6395-4BE3-BC93-3043366D9E3Bβ, name: β026β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
22. 21: Mesh {uuid: βDF3C6F17-8C80-4F6A-97E3-84D1855BC779β, name: β001β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
23. 22: Mesh {uuid: β26BB373B-E1B1-4AB3-A89E-51FC03A156CEβ, name: β002β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
24. 23: Mesh {uuid: βCD7D21D5-C99C-4C7F-A7E0-A2DEE54BF353β, name: β005β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
25. 24: Mesh {uuid: β641B383F-F28E-4E15-87A5-7BCED99BD237β, name: β010β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
26. 25: Mesh {uuid: βB9DB6A25-349B-4D88-92AB-21045F3205BCβ, name: β015β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
27. 26: Mesh {uuid: βF399DF41-11E5-4374-A2AC-7E441F1774BFβ, name: β019β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
28. 27: Mesh {uuid: β7EDD7944-7C2C-43C5-9D79-B90FDE0D9F25β, name: β022β, type: βMeshβ, parent: Object3D, children: Array(0), β¦}
You can easily order the meshes, merge them an play with mergedGeometry.setDrawRange (start, Infinity)
My idea was to use a distanceFactor from camera to boundingBox of the geometry and set start value on setDrawRange accordingly.
The meshes are ordered from smalest to biggest
To be honest I am fully lost.
Here I attach the same scene having merged geometries in order:
M2815049900600-FLX02_B.glb (4.2 KB)
Maybe the problem is on GLTFExporter or GLTFLoader()?
I have realized that thew order of my meshes is not the same as the order when I exported to glb using GLTFExporter, maybe it does something with indices?
Best regards