-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (59 loc) · 2.04 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Babylon.js GLTF Model Viewer</title>
<style>
html, body {
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#renderCanvas {
width: 100%;
height: 100%;
touch-action: none;
}
</style>
<script src="https://cdn.babylonjs.com/babylon.js"></script>
<script src="https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>
</head>
<body>
<canvas id="renderCanvas"></canvas>
<script>
const canvas = document.getElementById("renderCanvas");
const engine = new BABYLON.Engine(canvas, true);
const createScene = async function() {
const scene = new BABYLON.Scene(engine);
// Modify the camera setup
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.5, 50, new BABYLON.Vector3(0, 0, 0), scene);
camera.attachControl(canvas, true);
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);
// Log the model path
console.log("Model path: ./model.gltf");
const result = await BABYLON.SceneLoader.ImportMeshAsync("", "./", "model.gltf", scene);
// Log texture paths
console.log("Texture paths:");
scene.textures.forEach(texture => {
if (texture.name) {
console.log(texture.name);
}
});
// Adjust the camera to fit the loaded model
scene.createDefaultCameraOrLight(true, true, true);
scene.activeCamera.attachControl(canvas, true);
return scene;
};
createScene().then((scene) => {
engine.runRenderLoop(() => {
scene.render();
});
});
window.addEventListener("resize", () => {
engine.resize();
});
</script>
</body>
</html>