Skip to content

Commit

Permalink
Merge pull request #1453 from xeokit/fix-building-positioning-examples
Browse files Browse the repository at this point in the history
[FIX] Fix building positioning examples #1379
  • Loading branch information
xeolabs committed Apr 21, 2024
2 parents a1ccc0e + 209a0aa commit 65380f1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 37 deletions.
37 changes: 23 additions & 14 deletions examples/buildings/positioning_cartesianCoordinates.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,42 @@ <h3>Assets</h3>
<script type="module">

import {Viewer, WebIFCLoaderPlugin} from "../../dist/xeokit-sdk.min.es.js";
import * as WebIFC from "https://cdn.jsdelivr.net/npm/[email protected]/web-ifc-api.js";

const viewer = new Viewer({
canvasId: "myCanvas",
transparent: true
});

const webIFCLoader = new WebIFCLoaderPlugin(viewer, {
wasmPath: "https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/"
});
const IfcAPI = new WebIFC.IfcAPI();

const sceneModel = webIFCLoader.load({
id: "myModel",
src: "../../assets/models/ifc/Duplex.ifc",
origin: [18201100000000.79, 9.91, -51729900000000.84]
});
IfcAPI.SetWasmPath("https://cdn.jsdelivr.net/npm/[email protected]/");

IfcAPI.Init().then(() => {

const webIFCLoader = new WebIFCLoaderPlugin(viewer, {
WebIFC,
IfcAPI
});

const sceneModel = webIFCLoader.load({
id: "myModel",
src: "../../assets/models/ifc/Duplex.ifc",
position: [18201100000000.79, 9.91, -51729900000000.84]
});

const t0 = performance.now();
const t0 = performance.now();

document.getElementById("time").innerHTML = "Loading model...";
document.getElementById("time").innerHTML = "Loading model...";

sceneModel.on("loaded", () => {
sceneModel.on("loaded", () => {

const t1 = performance.now();
const t1 = performance.now();

document.getElementById("time").innerHTML = `Model loaded in ${Math.floor(t1 - t0) / 1000.0} seconds<br>Objects: ${sceneModel.numEntities}`;
document.getElementById("time").innerHTML = `Model loaded in ${Math.floor(t1 - t0) / 1000.0} seconds<br>Objects: ${sceneModel.numEntities}`;

viewer.cameraFlight.jumpTo(sceneModel);
viewer.cameraFlight.jumpTo(sceneModel);
});
});

window.viewer = viewer;
Expand Down
52 changes: 30 additions & 22 deletions examples/buildings/positioning_geodesicCoordinates.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ <h3>Assets</h3>
<script type="module">

import {Viewer, WebIFCLoaderPlugin, math} from "../../dist/xeokit-sdk.min.es.js";
import * as WebIFC from "https://cdn.jsdelivr.net/npm/[email protected]/web-ifc-api.js";

const viewer = new Viewer({
canvasId: "myCanvas",
Expand All @@ -76,28 +77,35 @@ <h3>Assets</h3>
// Make sure we don't clip our model
viewer.camera.project.far = 10000.0;

// Install plugin to load models from IFC files
const webIFCLoader = new WebIFCLoaderPlugin(viewer, {
wasmPath: "https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/"
});

// Load a model, positioning it at the specified geodesic coordinates, which we'll first project to mercator
const sceneModel = webIFCLoader.load({
id: "myModel",
src: "../../assets/models/ifc/Duplex.ifc",
loadMetadata: false,
edges: true,
origin: projectLongLatToMercator(48.981900, 35.398470, 0.0),
rotation: [90, 0, 0]
});

// Fit model to view once loaded
const t0 = performance.now();
document.getElementById("time").innerHTML = "Loading model...";
sceneModel.on("loaded", () => {
const t1 = performance.now();
document.getElementById("time").innerHTML = `Model loaded in ${Math.floor(t1 - t0) / 1000.0} seconds<br>Objects: ${sceneModel.numEntities}`;
viewer.cameraFlight.jumpTo(viewer.scene);
const IfcAPI = new WebIFC.IfcAPI();

IfcAPI.SetWasmPath("https://cdn.jsdelivr.net/npm/[email protected]/");

IfcAPI.Init().then(() => {

const webIFCLoader = new WebIFCLoaderPlugin(viewer, {
WebIFC,
IfcAPI
});

// Load a model, positioning it at the specified geodesic coordinates, which we'll first project to mercator
const sceneModel = webIFCLoader.load({
id: "myModel",
src: "../../assets/models/ifc/Duplex.ifc",
loadMetadata: false,
edges: true,
position: projectLongLatToMercator(48.981900, 35.398470, 0.0),
rotation: [90, 0, 0]
});

// Fit model to view once loaded
const t0 = performance.now();
document.getElementById("time").innerHTML = "Loading model...";
sceneModel.on("loaded", () => {
const t1 = performance.now();
document.getElementById("time").innerHTML = `Model loaded in ${Math.floor(t1 - t0) / 1000.0} seconds<br>Objects: ${sceneModel.numEntities}`;
viewer.cameraFlight.jumpTo(viewer.scene);
});
});

// Projects geodesic longitude and latitude coordinates into our mercator coordinate system.
Expand Down
2 changes: 1 addition & 1 deletion examples/buildings/web-ifc_dtx_MAPGroundFloor.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h3>Assets</h3>

<script type="module">

import {Viewer, WebIFCLoaderPlugin, NavCubePlugin, TreeViewPlugin, FastNavPlugin} from "../../dist/xeokit-sdk.min.es.js";
import {Viewer, WebIFCLoaderPlugin, NavCubePlugin, FastNavPlugin} from "../../dist/xeokit-sdk.min.es.js";
import * as WebIFC from "https://cdn.jsdelivr.net/npm/[email protected]/web-ifc-api.js";

const viewer = new Viewer({
Expand Down

0 comments on commit 65380f1

Please sign in to comment.