-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
94 lines (76 loc) · 2.91 KB
/
index.html
File metadata and controls
94 lines (76 loc) · 2.91 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Babylon.js sample code</title>
<!-- Babylon.js -->
<script src="http://www.babylonjs.com/hand.minified-1.2.js"></script>
<script src="js/cannon.js"></script>
<script src="js/oimo.js"></script>
<script src="js/babylon.js"></script>
<style>
html, body {
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#renderCanvas {
width: 100%;
height: 100%;
touch-action: none;
}
</style>
</head>
<body>
<canvas id="renderCanvas"></canvas>
<script>
var canvas = document.getElementById("renderCanvas");
var engine = new BABYLON.Engine(canvas, true);
var createScene = function () {
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI, Math.PI / 8, 150, BABYLON.Vector3.Zero(), scene);
camera.attachControl(canvas, true);
var light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), scene);
//Creation of 3 boxes and 2 spheres
var box1 = BABYLON.Mesh.CreateBox("Box1", 6.0, scene);
var box2 = BABYLON.Mesh.CreateBox("Box2", 6.0, scene);
var box3 = BABYLON.Mesh.CreateBox("Box3", 6.0, scene);
var box4 = BABYLON.Mesh.CreateBox("Box4", 6.0, scene);
var box5 = BABYLON.Mesh.CreateBox("Box5", 6.0, scene);
var box6 = BABYLON.Mesh.CreateBox("Box6", 6.0, scene);
var box7 = BABYLON.Mesh.CreateBox("Box7", 6.0, scene);
//Moving boxes on the x axis
box1.position.x = -20;
box2.position.x = -10;
box3.position.x = 0;
box4.position.x = 15;
box5.position.x = 30;
box6.position.x = 45;
//Rotate box around the x axis
box1.rotation.x = Math.PI / 6;
//Rotate box around the y axis
box2.rotation.y = Math.PI / 3;
//Scaling on the x axis
box4.scaling.x = 2;
//Scaling on the y axis
box5.scaling.y = 2;
//Scaling on the z axis
box6.scaling.z = 2;
//Moving box7 relatively to box1
box7.parent = box1;
box7.position.z = -10;
return scene;
}
var scene = createScene();
engine.runRenderLoop(function () {
scene.render();
});
// Resize
window.addEventListener("resize", function () {
engine.resize();
});
</script>
</body>
</html>