forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
119 lines (101 loc) · 3.14 KB
/
index.html
File metadata and controls
119 lines (101 loc) · 3.14 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!doctype html>
<html>
<head>
<script src="../../build/output/playcanvas-latest.js"></script>
<link href="../style.css" rel="stylesheet" />
<style>
#canvas-1 {
position: absolute;
width: 45%;
left: 0px;
margin: 0 0;
}
#canvas-2 {
position: absolute;
width: 45%;
right: 0px;
margin: 0 0;
}
</style>
</head>
<body>
<!-- The canvas element -->
<canvas id="canvas-1"></canvas>
<canvas id="canvas-2"></canvas>
<!-- The script -->
<script>
var canvas = document.getElementById("canvas-1");
// Create the app and start the update loop
var app1 = new pc.Application(canvas);
app1.start();
app1.setCanvasResolution(pc.RESOLUTION_AUTO);
var entity, light, camera;
// Create an Entity with a box component
entity = new pc.Entity(app1);
entity.setName("Box 1");
entity.addComponent("model", {
type: "box"
});
app1.root.addChild(entity);
// Create an Entity with a camera component
var camera = new pc.Entity(app1);
camera.addComponent("camera", {
clearColor: new pc.Color(0.4, 0.45, 0.5)
});
camera.translate(0, 0, 4);
app1.root.addChild(camera);
// Create an Entity with a point light component
var light = new pc.Entity(app1);
light.addComponent("light", {
type: "point",
color: new pc.Color(1, 1, 1),
range: 100
});
light.translate(5, 0, 15);
app1.root.addChild(light);
app1.on("update", function (dt) {
var entity = app1.root.findByName("Box 1");
if (entity) {
entity.rotate(0,10*dt,0);
}
});
</script>
<script>
var canvas = document.getElementById("canvas-2");
// Create the app and start the update loop
var app2 = new pc.Application(canvas);
app2.start();
app2.setCanvasResolution(pc.RESOLUTION_AUTO);
var entity, light, camera;
// Create an Entity with a box component
entity = new pc.Entity(app2);
entity.setName("Box 2")
entity.addComponent("model", {
type: "box"
});
app2.root.addChild(entity);
// Create an Entity with a camera component
var camera = new pc.Entity(app2);
camera.addComponent("camera", {
clearColor: new pc.Color(0.4, 0.45, 0.5)
});
camera.translate(0, 0, 4);
app2.root.addChild(camera);
// Create an Entity with a point light component
var light = new pc.Entity(app2);
light.addComponent("light", {
type: "point",
color: new pc.Color(1, 1, 1),
range: 100
});
light.translate(5, 0, 15);
app2.root.addChild(light);
app2.on("update", function (dt) {
// var entity = app2.root.findByName("Box 2");
if (entity) {
entity.rotate(0,10*dt,0);
}
});
</script>
</body>
</html>