CivilNavigators
Copying and pasting? We've got you covered! You can find the full source code of this tutorial here.
🛣️ Navigating 3D infrastructures
Infra models are awesome, but they are usually very, very long and thin. This makes it a bit hard to navigate through them. Luckily for you, the alignment data that comes in IFC models is processed by our libraries and generated in 3D, so you can use it for navigation!
The alignment data in IFC usually comes in 2D (floor plan and elevation). We use that data to regenerate the 3D curve from those 2D representations. You'll see the result in just a moment!
In this tutorial, we will import:
threeto create some 3D items.@thatopen/componentsto set up the barebone of our app.@thatopen/components-frontto use some frontend-oriented components.Stats.js(optional) to measure the performance of our app.
import * as THREE from "three";
import * as OBC from "@thatopen/components";
import * as CUI from "@thatopen/ui-obc";
import Stats from "stats.js";
import * as BUI from "@thatopen/ui";
// You have to import * as OBF from "@thatopen/components-front"
import * as OBF from "../..";
🌎 Setting up a simple scene
We will start by creating a simple scene with a camera and a renderer. If you don't know how to set up a scene, you can check the Worlds tutorial.
const container = document.getElementById("container")!;
const components = new OBC.Components();
const worlds = components.get(OBC.Worlds);
const world = worlds.create<
OBC.SimpleScene,
OBC.SimpleCamera,
OBF.RendererWith2D
>();
world.scene = new OBC.SimpleScene(components);
world.renderer = new OBF.RendererWith2D(components, container);
world.camera = new OBC.SimpleCamera(components);
components.init();
BUI.Manager.init();
CUI.Manager.init();
world.scene.setup();
world.camera.controls.setLookAt(5, 5, 5, 0, 0, 0);
container.appendChild(world.renderer.three2D.domElement);
const grids = components.get(OBC.Grids);
grids.create(world);
world.camera.three.far = 10000;
world.camera.three.updateProjectionMatrix();
We'll make the background of the scene transparent so that it looks good in our docs page, but you don't have to do that in your app!
world.scene.three.background = null;