- Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathexample.html
More file actions
Latest commit
80 lines (58 loc) · 2.35 KB
/
Copy pathexample.html
File metadata and controls
80 lines (58 loc) · 2.35 KB
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
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Babylon Template</title>
<style>
html,body {
overflow: hidden;
width:100%;
height:100%;
margin:0;
padding:0;
}
#renderCanvas {
width:100%;
height:100%;
touch-action: none;
}
</style>
<scriptsrc="babylon.js"></script>
<scriptsrc="babylon.gui.min.js"></script>
<scriptsrc="babylon.loaders.js"></script>
</head>
<body>
<canvasid="renderCanvas"></canvas>
<script>
constcanvas=document.getElementById("renderCanvas");// Get the canvas element
constengine=newBABYLON.Engine(canvas,true);// Generate the BABYLON 3D engine
constcreateScene=function(){
// This creates a basic Babylon Scene object (non-mesh)
constscene=newBABYLON.Scene(engine);
// This creates and positions a free camera (non-mesh)
constcamera=newBABYLON.FreeCamera("camera1",newBABYLON.Vector3(0,5,-10),scene);
// This targets the camera to scene origin
camera.setTarget(BABYLON.Vector3.Zero());
// This attaches the camera to the canvas
camera.attachControl(canvas,true);
// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
constlight=newBABYLON.HemisphericLight("light",newBABYLON.Vector3(0,1,0),scene);
// Default intensity is 1. Let's dim the light a small amount
light.intensity=0.7;
// Load meshes
BABYLON.SceneLoader.ImportMeshAsync("","/models/","scene.babylon");
returnscene;
};
constscene=createScene();//Call the createScene function
// Register a render loop to repeatedly render the scene
engine.runRenderLoop(function(){
scene.render();
});
// Watch for browser/canvas resize events
window.addEventListener("resize",function(){
engine.resize();
});
</script>
<scriptsrc="scripts/sliderGui.js"></script>
</body>
</html>