forked from xeolabs/scenejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geometry_points.html
108 lines (88 loc) · 3.07 KB
/
geometry_points.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>SceneJS Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
margin: 0;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
}
</style>
<script src="../api/latest/scenejs.js"></script>
<link href="css/styles.css" rel="stylesheet"/>
<body>
<div id="infoDark">
<a href="http://scenejs.org">SceneJS</a> - points geometry
</div>
<script>
// Point SceneJS to the bundled plugins
SceneJS.setConfigs({
pluginPath:"../api/latest/plugins"
});
// Create scene
var scene = SceneJS.createScene({
nodes:[
// Mouse-orbited camera, implemented by plugin at
// http://scenejs.org/api/latest/plugins/node/cameras/orbit.js
{
type:"cameras/orbit",
yaw:30,
pitch:-30,
zoom:10,
zoomSensitivity:1.0,
nodes:[
{
type:"material",
color:{ r:1.0, g:0.6, b:0.4 },
emit:0.3,
nodes:[
// Geometry node which defines our point cloud
{
type:"geometry",
id:"points",
// The primitive type - allowed values are
// "points", "lines", "line-loop", "line-strip",
// "triangles", "triangle-strip" and "triangle-fan".
//
// See the OpenGL/WebGL specification docs for
// how the coordinate arrays are supposed to be laid out
// for them.
primitive:"points",
// The vertices - eight for our cube, each
// one spanning three array elements for X,Y and Z
positions:createPoints(6000),
pointSize:1
}
]
}
]
}
]
});
// Helper func to create random positions
function createPoints(n) {
var p = [];
for (var i = 0; i < n; i++) {
p.push(Math.random() * 2.0, Math.random() * 2.0, Math.random() * 2.0);
}
return p;
}
scene.getNode("points", function (points) {
var size = points.getPointSize();
var increment = 0.1;
scene.on("tick", function () {
size += increment;
points.setPointSize(size);
if (size > 10 || size < 1) {
size = Math.max(1, Math.min(size, 10));
increment *= -1;
}
});
});
</script>
</body>
</html>