The 2D Floorplan (or simply “floorplan”) is a pre-built tool to aid navigation in BIM models by drawing the floorplan in an overlay. For more info on overlays, see the Overlays Programming Guide article and review the Overlay example code in the package located at applications/client/examples/.
By default, the floorplan will activate on walk in models that have IFC data, such as in the arboleda model that is included in the Communicator package, as pictured above. The avatar (a pink arrow by default) represents the current camera position and direction. The lines represent walls and other geometry on the current floor. A separate floorplan is generated for each floor in the model, and when moving between floors the overlay will display the floor that the camera is currently on. The floorplans are generated automatically from the IFC data when one is requested for the first time. As long as your model has IFC data, a floorplan can be generated.
The floorplan is controlled by the FloorplanManager, which is a member of the WebViewer. You can verify if the floorplan is currently active with: hwv.floorplanManager.isActive().
The following settings can be configured in the FloorplanConfig object:
- Overlay position
- Background color and opacity
- Avatar color and opacity
- Border color and opacity
- Avatar outline color
- Avatar scale
- Avatar mesh
- Scale and zoom
- Camera tracking
- Floorplan orientation
- Auto activation mode
Changing Background and Avatar Color
The following code snippet demonstrates a common workflow to update a floorplan's configuration by:
- Get the FloorplanConfig object
- Update configuration values
- Set the updated configuration with the FloorplanManager
Setting the floorplan to track the camera will cause the avatar to be centered in the overlay, and the floorplan will move around it as you move through the model. It is important to note that while not tracking the camera the floorplan will always fit the size of the overlay, zoom and scale will not be taken into account.
Setting north-up as the orientation will cause the floorplan to always point north, and the avatar rotates within it, while setting avatar-up as the orientation will cause the floorplan to rotate around the avatar.
Auto Activation Mode
The auto activation mode determines when the floorplan will be displayed. The following FloorplanAutoActivation options may be selected:
- BimWalk: Default. The floorplan will be displayed if a BIM model is loaded and the walk operator is active. The floorplan will be deactivated if the walk operator is deactivated.
- Bim: The floorplan will be activated if a BIM model is loaded
- Never: The floorplan will not be activated automatically.
If Never is set while the floorplan is already active, the floorplan will remain active. Use the FloorplanManager to activate or deactive a floorplan.
The avatar node can be replaced with custom geometry. The following snippet replaces the arrow with a blue square:
Find more information about mesh creation in our Mesh Programming Guide.
The Floorplan operator allows you to use the floorplan to navigate the model by clicking and dragging on the overlay. By default, you can click and drag the avatar to move the camera around the model to match where the avatar is located. You can change this behavior to simply clicking a point on the overlay and have the camera snap to it by calling restrictToAvatar(false); on the Floorplan operator.