Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Fix building positioning examples #1379 #1453

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading