I'm toggling visibility in my Three.js scene by using the .visible
property on objects.
Initially, certain objects (rooms) have their .visible
property set to false
. Once the camera enters a specific mesh (the room bounding box), the .visible
property is turned to true
and the room becomes visible.
However, there seems to be a slight delay (a few seconds or less) between setting the .visible
property to true
and the room actually appearing. This delay is reduced after entering the rooms multiple times.
What could be causing this delay? Is there a way to determine when the room is fully prepared for rendering? It appears that update events are not triggered after setting .visible
to true
, so listening for those events may not provide a solution.
Any assistance would be greatly appreciated,
Thanks!
UPDATE
Since I encountered issues with using ColladaLoader2.js
, I opted to manually traverse the models loaded using ColladaLoader.js
and replace all geometry properties with a copy of BufferGeometry
created from the existing Geometry
object. I discovered that setting the .dynamic
property of an existing Geometry
object to false has a similar effect.
dae.traverse(function (obj) {
if (obj.hasOwnProperty('geometry')) {
obj.dynamic = false;
//obj.geometry = new THREE.BufferGeometry().fromGeometry(obj.geometry);
}
});
Now, when I change the .visible
property of an object to true
, the engine momentarily freezes instead of experiencing the previous delay before the object becomes visible. I now need to decide where I can tolerate this brief freeze, as it may not be feasible for all objects to be visible concurrently for performance considerations.
Having more control and insight into whether an object and its geometry are loaded and ready for display, or if they need to be reloaded into memory, would be helpful. Currently, it is unclear whether a BufferGeometry
will render immediately upon setting .visible
to true
, or if a brief freeze will occur.