-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1453 from xeokit/fix-building-positioning-examples
[FIX] Fix building positioning examples #1379
- Loading branch information
Showing
3 changed files
with
54 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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({ | ||
|