Hide Objects on Camera Movement

Introduction

We can split the structured object into two groups - visible and hidden. Then, we can hide a group of objects during a camera move - i.e. pan, tilt, orbit, zoom.

The image above shows an extreme situation, were most objects are hidden. This will only reveal a skelekton. The perforance is super smooth - but the user experience might suffer.

Group Objects

There are many ways achieve this. Here's my simple take.

An Array with Hidden Objects

I have created an array with all the IFC objects that I want to disappear during a camera move. These are called hidden objects.

Tweak this array to your own needs.

Perform the Grouping

We can use the aforementioned array to group each object into a visible or hidden group. Three.js has a very nice way to deal with groupsarrow-up-right.

Notice that we use the children parmameter of the Three.Object3D()arrow-up-right.

Add Groups to Scene

Let's add the two groupsarrow-up-right to the scenearrow-up-right. This is very straigh forward and easy to do.

Hide on Camera Movement

The next step is to actually hide the hiddenGroup during a camera movement. A simple (!) way to do this is to place an event listener during a mouse press.

Then, all you do is change the visible property.

Please not that the EventListenermight intefere with other parts of the Three.js scene.

Last updated