|
| 1 | +<!doctype html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 7 | + <title>xeokit Example</title> |
| 8 | + <link href="../css/pageStyle.css" rel="stylesheet"/> |
| 9 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js"></script> |
| 10 | +</head> |
| 11 | +<body> |
| 12 | +<input type="checkbox" id="info-button"/> |
| 13 | +<label for="info-button" class="info-button"><i class="far fa-3x fa-question-circle"></i></label> |
| 14 | +<canvas id="myCanvas"></canvas> |
| 15 | +<div class="slideout-sidebar"> |
| 16 | + <img class="info-icon" src="../../assets/images/gltf_logo.png"/> |
| 17 | + <h1>GLTFLoaderPlugin</h1> |
| 18 | + <h2>Using an alternative loaders.gl version</h2> |
| 19 | + <p>In this example, we're using a <a |
| 20 | + href="../../docs/class/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js~GLTFLoaderPlugin.html" |
| 21 | + target="_other">GLTFLoaderPlugin</a> to load the <a |
| 22 | + href="https://sketchfab.com/bimcc" |
| 23 | + target="_other">House Plan</a> demo model from |
| 24 | + binary glTF (.glb).</p> |
| 25 | + <h3>Components used</h3> |
| 26 | + <ul> |
| 27 | + <li> |
| 28 | + <a href="../../docs/class/src/viewer/Viewer.js~Viewer.html" |
| 29 | + target="_other">Viewer</a> |
| 30 | + </li> |
| 31 | + <li> |
| 32 | + <a href="../../docs/class/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js~GLTFLoaderPlugin.html" |
| 33 | + target="_other">GLTFLoaderPlugin</a> |
| 34 | + </li> |
| 35 | + </ul> |
| 36 | + <h3>Assets</h3> |
| 37 | + <ul> |
| 38 | + <li> |
| 39 | + <a href="https://sketchfab.com/bimcc" target="_other">Model source</a> |
| 40 | + </li> |
| 41 | + </ul> |
| 42 | +</div> |
| 43 | +</body> |
| 44 | +<script type="module"> |
| 45 | + |
| 46 | + // User-provided loaders.gl |
| 47 | + import * as loadersGlCore from "https://cdn.jsdelivr.net/npm/@loaders.gl/core@4.4.1/+esm"; |
| 48 | + import * as loadersGlGltf from "https://cdn.jsdelivr.net/npm/@loaders.gl/gltf@4.4.1/+esm"; |
| 49 | + |
| 50 | + // Alternatively e.g. |
| 51 | + // import * as loadersGlCore from "https://esm.sh/@loaders.gl/core@4.4.1"; |
| 52 | + // import * as loadersGlGltf from "https://esm.sh/@loaders.gl/gltf@4.4.1"; |
| 53 | + |
| 54 | + import {Viewer, GLTFLoaderPlugin} from "../../src/index.js"; |
| 55 | + |
| 56 | + const viewer = new Viewer({ |
| 57 | + canvasId: "myCanvas", |
| 58 | + transparent: true, |
| 59 | + dtxEnabled: false |
| 60 | + }); |
| 61 | + |
| 62 | + viewer.camera.eye = [1394.38, 3.78, -247.05]; |
| 63 | + viewer.camera.look = [1391.46, 0.89, -244.24]; |
| 64 | + viewer.camera.up = [-0.41, 0.81, 0.40]; |
| 65 | + |
| 66 | + const gltfLoader = new GLTFLoaderPlugin(viewer); |
| 67 | + |
| 68 | + const sceneModel = gltfLoader.load({ |
| 69 | + id: "myHousePlan", |
| 70 | + src: "../../assets/models/gltf/HousePlan/glTF-Binary/HousePlan.glb", |
| 71 | + loadersGl: { core: loadersGlCore, gltf: loadersGlGltf } |
| 72 | + }); |
| 73 | + |
| 74 | + sceneModel.on("loaded", () => viewer.cameraFlight.jumpTo(sceneModel)); |
| 75 | + |
| 76 | + window.viewer = viewer; |
| 77 | +</script> |
| 78 | +</html> |
0 commit comments