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