I am trying to create a building scene using threejs, I am attaching the code below. Not adding full code… used ambient light, cubemap as environment and background.
here, I am loading GLB file which is 461 kb in size consisting main two parent meshes, first one is flor and second one is corridor, I am using flor to create first floor and adding them into group after that I am using for loop to create clone for that gp group. code work perfectly but the problem is, I am having only 23 or 20 fps. Is there any efficient way to create this ??? I am new to threejs so pls let me know. Thank you
On the topic of efficiency - you’re currently rendering 11x quite detailed meshes of floors / walls / doors / windows. That makes sense for the top-most floor, but rendering aaaaall of that for the occluded floors below is rather definitely not super efficient.
Consider adding some basic raycast-based occlusion testing that’d would help determine which floors the user can look into, and which aren’t visible at all.
The problem is, I dont know how, I have tried using createInstancedMesh and it will only instance mesh object(first object like flor and corridor) , my gltf have empty as parents,
I dont know how to instance those, and i have used group, in which I add clone and after that I clone that group…
I have tried to do instance in blender and export it but its also have performance issue,
I think I had a similar problem that the guys in this forum helped me a lot with. Please see this post, it got actually solved and still runs like a charm.
The basic idea I hade to face was to figure out which objects use the same material. And all those meshes with the same material-properties (except color, wich can be set individually) get merged together into one object. Therefore I only have 1 draw-call for each object and just about 5-10 objects left and that works so good.
Another idea ist to put objects into group and then raycast only these groups. Each none raycasted group can be switched to invisible. That way you can probably reduce the amount of objects to be rendered. Though I have to admit, I also have never done this before.
I tried to implement the instances as you mentioned and it worked, I remodeled my building such way that any objects have only and only one material, cause I cant find solution for multiple material, but one more problem has raised, when I use scale negative its somehow affect the shading.
Bro Thank you for answering, but truly speaking I dont have this much experience with Threejs so that I can understand it. even though Ill try, but right now, i have tried using instancing the mesh, and It kinda worked, I am getting 60 fps, to do that I have join the geometry in blender which have same material and separate geometry witch have more that one material and remodeled my building such way that any objects have only and only one material, cause I cant find solution for multiple material. now its creating shading issue , you can check code and shading problem in my previous reply
Thank you
Negative scaling is not officially supported. Zero scaling on an axis is also not officially supported. They may “work” but can lead to lighting issues.
Are you scaling the geometry? or the mesh.scale? if mesh.scale, you could try scaling the geometry itself instead.