-
Notifications
You must be signed in to change notification settings - Fork 290
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 #1697 from xeokit/XEOK-50-adjust-overlay-example-f…
…or-tutorial XEOK-50 Adjust example code for an upcoming 2D Overlay tutorial
- Loading branch information
Showing
3 changed files
with
106 additions
and
89 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!doctype html> | ||
<html> | ||
<body style="overflow-y: hidden; overflow-x: hidden; margin: 0; width: 100%; height: 100%;"> | ||
<canvas id="myCanvas" style="position: absolute; width: 100%; height: 100%; background-image: linear-gradient(lightblue, white);"></canvas> | ||
</body> | ||
<script type="module"> | ||
|
||
import { SectionPlanesPlugin, Viewer, XKTLoaderPlugin } from "../../dist/xeokit-sdk.min.es.js"; | ||
|
||
const viewer = new Viewer({ canvasId: "myCanvas" }); | ||
|
||
viewer.camera.eye = [7, 30, -8]; | ||
viewer.camera.look = [7, 0, -10]; | ||
viewer.camera.up = [0, 1, 0]; | ||
|
||
new XKTLoaderPlugin(viewer).load({ src: "../../assets/models/xkt/v8/ifc/Schependomlaan.ifc.xkt" }); | ||
|
||
new SectionPlanesPlugin(viewer, { overviewVisible: false }).createSectionPlane({ pos: [0, 1, 0], dir: [0, -1, 0] }); | ||
|
||
import { buildPlaneGeometry, math, Mesh, PhongMaterial, ReadableGeometry, Texture } from "../../dist/xeokit-sdk.min.es.js"; | ||
|
||
const image = new Image(); | ||
image.src = "../../assets/images/schependomlaanPlanView.png"; | ||
image.onload = function() { | ||
// Create the floor plan Texture | ||
const scene = viewer.scene; | ||
const planTexture = new Texture(scene, { image: image }); | ||
|
||
// Create the floor plan Mesh | ||
const planMesh = new Mesh(scene, { | ||
pickable: false, | ||
geometry: new ReadableGeometry(scene, buildPlaneGeometry()), | ||
material: new PhongMaterial(scene, { | ||
alpha: 0.75, | ||
diffuse: [0, 0, 0], | ||
diffuseMap: planTexture, | ||
emissiveMap: planTexture, | ||
backfaces: true | ||
}) | ||
}); | ||
|
||
// Scale and position the Mesh | ||
const planHeight = 0.1 | ||
const planPosition = [ 10.946, planHeight, -10.343 ]; | ||
const planScale = 22.66; | ||
const t = math.translationMat4v(planPosition); | ||
// Preserve image's aspect ratio when scaling | ||
const s = math.scalingMat4v([planScale * image.width / image.height, 1, planScale]); | ||
planMesh.matrix = math.mulMat4(t, s, math.mat4()); | ||
}; | ||
|
||
</script> | ||
</html> |
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
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