@openglobus/og 0.14.4 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/og.css +377 -274
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +18 -17
- package/src/og/Clock.js +218 -194
- package/src/og/Globe.js +1 -3
- package/src/og/Object3d.js +104 -145
- package/src/og/camera/Camera.js +23 -19
- package/src/og/cons.js +107 -107
- package/src/og/control/Atmosphere.js +396 -0
- package/src/og/control/CompassButton.js +11 -18
- package/src/og/control/Control.js +187 -188
- package/src/og/control/GeoImageDragControl.js +84 -66
- package/src/og/control/LayerSwitcher.js +46 -145
- package/src/og/control/Lighting.js +314 -186
- package/src/og/control/RulerSwitcher.js +24 -19
- package/src/og/control/SimpleSkyBackground.js +38 -12
- package/src/og/control/Sun.js +2 -0
- package/src/og/control/ZoomControl.js +30 -42
- package/src/og/control/ruler/RulerScene.js +5 -23
- package/src/og/control/selection/Selection.js +21 -50
- package/src/og/control/selection/SelectionScene.js +15 -29
- package/src/og/control/timeline/TimelineControl.js +99 -0
- package/src/og/control/timeline/TimelineModel.js +133 -0
- package/src/og/control/timeline/TimelineView.js +449 -0
- package/src/og/control/timeline/timelineUtils.js +132 -0
- package/src/og/entity/Entity.js +30 -3
- package/src/og/entity/EntityCollection.js +0 -2
- package/src/og/entity/GeoObject.js +72 -56
- package/src/og/entity/GeoObjectHandler.js +487 -656
- package/src/og/input/input.js +3 -1
- package/src/og/layer/CanvasTiles.js +39 -34
- package/src/og/layer/Layer.js +2 -0
- package/src/og/layer/Material.js +1 -8
- package/src/og/light/LightSource.js +2 -0
- package/src/og/quadTree/Node.js +2 -1
- package/src/og/renderer/Renderer.js +26 -42
- package/src/og/renderer/RendererEvents.js +4 -4
- package/src/og/scene/Planet.js +276 -59
- package/src/og/scene/RenderNode.js +27 -12
- package/src/og/segment/Segment.js +0 -5
- package/src/og/shaders/atmos.js +332 -0
- package/src/og/shaders/drawnode.js +475 -109
- package/src/og/shaders/geoObject.js +96 -51
- package/src/og/shaders/polyline.js +212 -17
- package/src/og/shaders/utils.js +88 -0
- package/src/og/terrain/GlobusTerrain.js +2 -2
- package/src/og/ui/Button.js +106 -0
- package/src/og/ui/ButtonGroup.js +57 -0
- package/src/og/ui/Dialog.js +242 -0
- package/src/og/ui/Slider.js +144 -0
- package/src/og/ui/ToggleButton.js +51 -0
- package/src/og/ui/View.js +190 -0
- package/src/og/utils/shared.js +51 -33
- package/src/og/webgl/Framebuffer.js +308 -387
- package/src/og/webgl/Handler.js +68 -21
- package/src/og/webgl/Multisample.js +8 -0
- package/types/Clock.d.ts +7 -2
- package/types/Object3d.d.ts +14 -3
- package/types/camera/Camera.d.ts +15 -14
- package/types/control/Atmosphere.d.ts +15 -0
- package/types/control/CompassButton.d.ts +1 -2
- package/types/control/GeoImageDragControl.d.ts +7 -1
- package/types/control/LayerSwitcher.d.ts +4 -5
- package/types/control/Lighting.d.ts +32 -7
- package/types/control/SimpleSkyBackground.d.ts +4 -0
- package/types/control/ZoomControl.d.ts +0 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/Selection.d.ts +2 -4
- package/types/control/selection/SelectionScene.d.ts +0 -1
- package/types/entity/Entity.d.ts +8 -0
- package/types/entity/GeoObject.d.ts +28 -22
- package/types/entity/GeoObjectHandler.d.ts +16 -56
- package/types/input/input.d.ts +2 -0
- package/types/layer/CanvasTiles.d.ts +1 -0
- package/types/layer/Layer.d.ts +1 -0
- package/types/math/Plane.d.ts +1 -1
- package/types/renderer/Renderer.d.ts +7 -1
- package/types/scene/Planet.d.ts +20 -2
- package/types/scene/RenderNode.d.ts +2 -1
- package/types/segment/Segment.d.ts +1 -1
- package/types/shaders/atmos.d.ts +4 -0
- package/types/shaders/drawnode.d.ts +3 -2
- package/types/shaders/utils.d.ts +1 -0
- package/types/terrain/GlobusTerrain.d.ts +1 -1
- package/types/ui/Button.d.ts +21 -0
- package/types/ui/Dialog.d.ts +41 -0
- package/types/ui/Slider.d.ts +30 -0
- package/types/ui/ToggleButton.d.ts +10 -0
- package/types/ui/View.d.ts +32 -0
- package/types/utils/shared.d.ts +16 -14
- package/types/webgl/Framebuffer.d.ts +2 -5
- package/types/webgl/Handler.d.ts +11 -9
- package/types/webgl/Multisample.d.ts +2 -0
- package/src/og/ajax.js +0 -204
- package/src/og/entity/Object3d.js +0 -504
- package/types/ajax.d.ts +0 -24
- /package/src/og/{control → ui}/UIhelpers.js +0 -0
- /package/types/{control → ui}/UIhelpers.d.ts +0 -0
package/src/og/Object3d.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { htmlColorToFloat32Array } from './utils/shared.js';
|
|
5
5
|
import { Vec3 } from './math/Vec3.js';
|
|
6
|
+
import { MIN, MAX } from './math.js';
|
|
6
7
|
|
|
7
8
|
function getColor(color) {
|
|
8
9
|
if (color instanceof Array) {
|
|
@@ -18,7 +19,19 @@ class Object3d {
|
|
|
18
19
|
|
|
19
20
|
this._name = data.name || "noname";
|
|
20
21
|
this._vertices = data.vertices || [];
|
|
21
|
-
this.
|
|
22
|
+
this._numVertices = this._vertices.length / 3;
|
|
23
|
+
this._texCoords = data.texCoords || new Array(2 * this._numVertices);
|
|
24
|
+
|
|
25
|
+
if (data.center) {
|
|
26
|
+
Object3d.centering(this._vertices);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Image src.
|
|
31
|
+
* @protected
|
|
32
|
+
* @type {string}
|
|
33
|
+
*/
|
|
34
|
+
this._src = data.src || null;
|
|
22
35
|
|
|
23
36
|
this.color = getColor(data.color);
|
|
24
37
|
|
|
@@ -26,18 +39,45 @@ class Object3d {
|
|
|
26
39
|
Object3d.scale(this._vertices, data.scale);
|
|
27
40
|
}
|
|
28
41
|
|
|
29
|
-
if (data.
|
|
30
|
-
this.
|
|
42
|
+
if (data.indices) {
|
|
43
|
+
this._indices = data.indices || [];
|
|
31
44
|
this._normals = data.normals || [];
|
|
32
45
|
} else {
|
|
33
46
|
this._normals = Object3d.getNormals(this._vertices);
|
|
34
|
-
this.
|
|
35
|
-
for (let i = 0, len = this.
|
|
36
|
-
this.
|
|
47
|
+
this._indices = new Array(this._vertices.length);
|
|
48
|
+
for (let i = 0, len = this._indices.length; i < len; i++) {
|
|
49
|
+
this._indices[i] = i;
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
52
|
}
|
|
40
53
|
|
|
54
|
+
static centering(verts) {
|
|
55
|
+
let min_x = MAX, min_y = MAX, min_z = MAX, max_x = MIN, max_y = MIN, max_z = MIN;
|
|
56
|
+
for (let i = 0, len = verts.length; i < len; i += 3) {
|
|
57
|
+
let x = verts[i], y = verts[i + 1], z = verts[i + 2];
|
|
58
|
+
if (x < min_x) min_x = x;
|
|
59
|
+
if (y < min_y) min_y = y;
|
|
60
|
+
if (z < min_z) min_z = z;
|
|
61
|
+
if (x > max_x) max_x = x;
|
|
62
|
+
if (y > max_y) max_y = y;
|
|
63
|
+
if (z > max_z) max_z = z;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let c_x = min_x + (max_x - min_x) * 0.5;
|
|
67
|
+
let c_y = min_y + (max_y - min_y) * 0.5;
|
|
68
|
+
let c_z = min_z + (max_z - min_z) * 0.5;
|
|
69
|
+
|
|
70
|
+
for (let i = 0, len = verts.length; i < len; i += 3) {
|
|
71
|
+
verts[i] -= c_x;
|
|
72
|
+
verts[i + 1] -= c_y;
|
|
73
|
+
verts[i + 2] -= c_z;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get src() {
|
|
78
|
+
return this._src;
|
|
79
|
+
}
|
|
80
|
+
|
|
41
81
|
get name() {
|
|
42
82
|
return this._name;
|
|
43
83
|
}
|
|
@@ -50,8 +90,16 @@ class Object3d {
|
|
|
50
90
|
return this._normals;
|
|
51
91
|
}
|
|
52
92
|
|
|
53
|
-
get
|
|
54
|
-
return this.
|
|
93
|
+
get indices() {
|
|
94
|
+
return this._indices;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get texCoords() {
|
|
98
|
+
return this._texCoords;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get numVertices() {
|
|
102
|
+
return this._numVertices;
|
|
55
103
|
}
|
|
56
104
|
|
|
57
105
|
static scale(vertices, s) {
|
|
@@ -61,13 +109,10 @@ class Object3d {
|
|
|
61
109
|
}
|
|
62
110
|
|
|
63
111
|
static centroid(vertices) {
|
|
64
|
-
let minX = 1000.0, minY = 1000.0, minZ = 1000.0,
|
|
65
|
-
maxX = -1000.0, maxY = -1000.0, maxZ = -1000.0;
|
|
112
|
+
let minX = 1000.0, minY = 1000.0, minZ = 1000.0, maxX = -1000.0, maxY = -1000.0, maxZ = -1000.0;
|
|
66
113
|
|
|
67
114
|
for (let i = 0; i < vertices.length; i += 3) {
|
|
68
|
-
let x = vertices[i],
|
|
69
|
-
y = vertices[i + 1],
|
|
70
|
-
z = vertices[i + 2];
|
|
115
|
+
let x = vertices[i], y = vertices[i + 1], z = vertices[i + 2];
|
|
71
116
|
if (x < minX) minX = x;
|
|
72
117
|
if (y < minY) minY = y;
|
|
73
118
|
if (z < minZ) minZ = z;
|
|
@@ -76,11 +121,7 @@ class Object3d {
|
|
|
76
121
|
if (z > maxZ) maxZ = z;
|
|
77
122
|
}
|
|
78
123
|
|
|
79
|
-
return [
|
|
80
|
-
minX + (maxX - minX) * 0.5,
|
|
81
|
-
minY + (maxY - minY) * 0.5,
|
|
82
|
-
minZ + (maxZ - minZ) * 0.5
|
|
83
|
-
];
|
|
124
|
+
return [minX + (maxX - minX) * 0.5, minY + (maxY - minY) * 0.5, minZ + (maxZ - minZ) * 0.5];
|
|
84
125
|
}
|
|
85
126
|
|
|
86
127
|
static translate(vertices, v) {
|
|
@@ -96,26 +137,11 @@ class Object3d {
|
|
|
96
137
|
|
|
97
138
|
for (var i = 0; i < vertices.length; i += 9) {
|
|
98
139
|
|
|
99
|
-
let t03 = i,
|
|
100
|
-
t13 =
|
|
101
|
-
t23 =
|
|
102
|
-
v0_x =
|
|
103
|
-
|
|
104
|
-
v0_z = vertices[t03 + 2],
|
|
105
|
-
v1_x = vertices[t13],
|
|
106
|
-
v1_y = vertices[t13 + 1],
|
|
107
|
-
v1_z = vertices[t13 + 2],
|
|
108
|
-
v2_x = vertices[t23],
|
|
109
|
-
v2_y = vertices[t23 + 1],
|
|
110
|
-
v2_z = vertices[t23 + 2],
|
|
111
|
-
vv0_x = v1_x - v0_x,
|
|
112
|
-
vv0_y = v1_y - v0_y,
|
|
113
|
-
vv0_z = v1_z - v0_z,
|
|
114
|
-
vv1_x = v2_x - v0_x,
|
|
115
|
-
vv1_y = v2_y - v0_y,
|
|
116
|
-
vv1_z = v2_z - v0_z,
|
|
117
|
-
n_x = vv0_y * vv1_z - vv0_z * vv1_y,
|
|
118
|
-
n_y = vv0_z * vv1_x - vv0_x * vv1_z,
|
|
140
|
+
let t03 = i, t13 = i + 3, t23 = i + 6, v0_x = vertices[t03], v0_y = vertices[t03 + 1],
|
|
141
|
+
v0_z = vertices[t03 + 2], v1_x = vertices[t13], v1_y = vertices[t13 + 1], v1_z = vertices[t13 + 2],
|
|
142
|
+
v2_x = vertices[t23], v2_y = vertices[t23 + 1], v2_z = vertices[t23 + 2], vv0_x = v1_x - v0_x,
|
|
143
|
+
vv0_y = v1_y - v0_y, vv0_z = v1_z - v0_z, vv1_x = v2_x - v0_x, vv1_y = v2_y - v0_y, vv1_z = v2_z - v0_z,
|
|
144
|
+
n_x = vv0_y * vv1_z - vv0_z * vv1_y, n_y = vv0_z * vv1_x - vv0_x * vv1_z,
|
|
119
145
|
n_z = vv0_x * vv1_y - vv0_y * vv1_x;
|
|
120
146
|
|
|
121
147
|
let l = Math.sqrt(n_x * n_x + n_y * n_y + n_z * n_z);
|
|
@@ -142,9 +168,7 @@ class Object3d {
|
|
|
142
168
|
|
|
143
169
|
static createSphere(lonBands = 16, latBands = 16, radius = 1.0, offsetX = 0, offsetY = 0, offsetZ = 0) {
|
|
144
170
|
|
|
145
|
-
let vertices = [],
|
|
146
|
-
indexes = [],
|
|
147
|
-
normals = [];
|
|
171
|
+
let vertices = [], indices = [], normals = [];
|
|
148
172
|
|
|
149
173
|
for (let latNumber = 0; latNumber <= latBands; latNumber++) {
|
|
150
174
|
var theta = latNumber * Math.PI / latBands;
|
|
@@ -176,31 +200,26 @@ class Object3d {
|
|
|
176
200
|
var first = (latNumber * (lonBands + 1)) + longNumber;
|
|
177
201
|
var second = first + lonBands + 1;
|
|
178
202
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
203
|
+
indices.push(first);
|
|
204
|
+
indices.push(first + 1);
|
|
205
|
+
indices.push(second);
|
|
182
206
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
207
|
+
indices.push(second);
|
|
208
|
+
indices.push(first + 1);
|
|
209
|
+
indices.push(second + 1);
|
|
186
210
|
}
|
|
187
211
|
}
|
|
188
212
|
|
|
189
213
|
return new Object3d({
|
|
190
|
-
'vertices': vertices,
|
|
191
|
-
'normals': normals,
|
|
192
|
-
'indexes': indexes
|
|
214
|
+
'vertices': vertices, 'normals': normals, 'indices': indices
|
|
193
215
|
});
|
|
194
216
|
}
|
|
195
217
|
|
|
196
218
|
static createDisc(radius = 1.0, height = 0.0, radialSegments = 8, isTop = true, startIndex = 0, offsetX = 0, offsetY, offsetZ = 0) {
|
|
197
219
|
|
|
198
|
-
let vertices = [],
|
|
199
|
-
indexes = [],
|
|
200
|
-
normals = [];
|
|
220
|
+
let vertices = [], indices = [], normals = [];
|
|
201
221
|
|
|
202
|
-
let thetaStart = 0.0,
|
|
203
|
-
thetaLength = Math.PI * 2;
|
|
222
|
+
let thetaStart = 0.0, thetaLength = Math.PI * 2;
|
|
204
223
|
|
|
205
224
|
let sign = (isTop === true) ? 1.0 : -1.0;
|
|
206
225
|
|
|
@@ -231,30 +250,24 @@ class Object3d {
|
|
|
231
250
|
}
|
|
232
251
|
|
|
233
252
|
for (let x = 0; x < radialSegments; x++) {
|
|
234
|
-
let c = centerIndexStart + x,
|
|
235
|
-
i = centerIndexEnd + x;
|
|
253
|
+
let c = centerIndexStart + x, i = centerIndexEnd + x;
|
|
236
254
|
if (isTop === true) {
|
|
237
|
-
|
|
255
|
+
indices.push(i, i + 1, c);
|
|
238
256
|
} else {
|
|
239
|
-
|
|
257
|
+
indices.push(i + 1, i, c);
|
|
240
258
|
}
|
|
241
259
|
}
|
|
242
260
|
|
|
243
261
|
return new Object3d({
|
|
244
|
-
'vertices': vertices,
|
|
245
|
-
'normals': normals,
|
|
246
|
-
'indexes': indexes
|
|
262
|
+
'vertices': vertices, 'normals': normals, 'indices': indices
|
|
247
263
|
});
|
|
248
264
|
}
|
|
249
265
|
|
|
250
266
|
static createCylinder(radiusTop = 1.0, radiusBottom = 1.0, height = 1.0, radialSegments = 32, heightSegments = 1.0, isTop = true, isBottom = true, offsetX = 0, offsetY = 0, offsetZ = 0) {
|
|
251
267
|
|
|
252
|
-
let vertices = [],
|
|
253
|
-
indexes = [],
|
|
254
|
-
normals = [];
|
|
268
|
+
let vertices = [], indices = [], normals = [];
|
|
255
269
|
|
|
256
|
-
let thetaStart = 0.0,
|
|
257
|
-
thetaLength = Math.PI * 2;
|
|
270
|
+
let thetaStart = 0.0, thetaLength = Math.PI * 2;
|
|
258
271
|
|
|
259
272
|
let index = 0;
|
|
260
273
|
let indexArray = [];
|
|
@@ -277,8 +290,7 @@ class Object3d {
|
|
|
277
290
|
|
|
278
291
|
let theta = u * thetaLength + thetaStart;
|
|
279
292
|
|
|
280
|
-
let sinTheta = Math.sin(theta),
|
|
281
|
-
cosTheta = Math.cos(theta);
|
|
293
|
+
let sinTheta = Math.sin(theta), cosTheta = Math.cos(theta);
|
|
282
294
|
|
|
283
295
|
vertices.push(radius * sinTheta + offsetX, -v * height + height + offsetY, radius * cosTheta + offsetZ);
|
|
284
296
|
|
|
@@ -295,13 +307,11 @@ class Object3d {
|
|
|
295
307
|
for (let x = 0; x < radialSegments; x++) {
|
|
296
308
|
for (let y = 0; y < heightSegments; y++) {
|
|
297
309
|
|
|
298
|
-
let a = indexArray[y][x],
|
|
299
|
-
b = indexArray[y + 1][x],
|
|
300
|
-
c = indexArray[y + 1][x + 1],
|
|
310
|
+
let a = indexArray[y][x], b = indexArray[y + 1][x], c = indexArray[y + 1][x + 1],
|
|
301
311
|
d = indexArray[y][x + 1];
|
|
302
312
|
|
|
303
|
-
|
|
304
|
-
|
|
313
|
+
indices.push(a, b, d);
|
|
314
|
+
indices.push(b, c, d);
|
|
305
315
|
}
|
|
306
316
|
}
|
|
307
317
|
|
|
@@ -309,107 +319,56 @@ class Object3d {
|
|
|
309
319
|
let cap = Object3d.createDisc(radiusTop, height, radialSegments, true, index, offsetX, offsetY, offsetZ);
|
|
310
320
|
vertices.push(...cap.vertices);
|
|
311
321
|
normals.push(...cap.normals);
|
|
312
|
-
|
|
322
|
+
indices.push(...cap.indices);
|
|
313
323
|
}
|
|
314
324
|
|
|
315
325
|
if (radiusBottom !== 0.0 && isBottom) {
|
|
316
326
|
let cap = Object3d.createDisc(radiusBottom, 0, radialSegments, false, index + (isTop ? (1 + 2 * radialSegments) : 0), offsetX, offsetY, offsetZ);
|
|
317
327
|
vertices.push(...cap.vertices);
|
|
318
328
|
normals.push(...cap.normals);
|
|
319
|
-
|
|
329
|
+
indices.push(...cap.indices);
|
|
320
330
|
}
|
|
321
331
|
|
|
322
332
|
return new Object3d({
|
|
323
|
-
'vertices': vertices,
|
|
324
|
-
'normals': normals,
|
|
325
|
-
'indexes': indexes
|
|
333
|
+
'vertices': vertices, 'normals': normals, 'indices': indices
|
|
326
334
|
});
|
|
327
335
|
}
|
|
328
336
|
|
|
329
337
|
static createCube(length = 1, height = 1, depth = 1, xOffset = 0, yOffset = 0, zOffset = 0) {
|
|
330
|
-
let l = length * 0.5 + xOffset,
|
|
331
|
-
h = height * 0.5 + yOffset,
|
|
332
|
-
d = depth * 0.5 + zOffset;
|
|
338
|
+
let l = length * 0.5 + xOffset, h = height * 0.5 + yOffset, d = depth * 0.5 + zOffset;
|
|
333
339
|
|
|
334
340
|
return new Object3d({
|
|
335
|
-
vertices: [
|
|
336
|
-
|
|
337
|
-
-l, -h, d,
|
|
338
|
-
l, -h, -d,
|
|
339
|
-
l, -h, d,
|
|
340
|
-
-l, -h, d,
|
|
341
|
-
-l, -h, -d,
|
|
342
|
-
l, -h, -d,
|
|
341
|
+
vertices: [//bottom
|
|
342
|
+
-l, -h, d, l, -h, -d, l, -h, d, -l, -h, d, -l, -h, -d, l, -h, -d,
|
|
343
343
|
|
|
344
344
|
//top
|
|
345
|
-
-l, h, d,
|
|
346
|
-
l, h, d,
|
|
347
|
-
l, h, -d,
|
|
348
|
-
-l, h, d,
|
|
349
|
-
l, h, -d,
|
|
350
|
-
-l, h, -d,
|
|
345
|
+
-l, h, d, l, h, d, l, h, -d, -l, h, d, l, h, -d, -l, h, -d,
|
|
351
346
|
|
|
352
347
|
//front
|
|
353
|
-
-l, -h, d,
|
|
354
|
-
l, -h, d,
|
|
355
|
-
-l, h, d,
|
|
356
|
-
-l, h, d,
|
|
357
|
-
l, -h, d,
|
|
358
|
-
l, h, d,
|
|
348
|
+
-l, -h, d, l, -h, d, -l, h, d, -l, h, d, l, -h, d, l, h, d,
|
|
359
349
|
|
|
360
350
|
//back
|
|
361
|
-
-l, -h, -d,
|
|
362
|
-
-l, h, -d,
|
|
363
|
-
l, -h, -d,
|
|
364
|
-
-l, h, -d,
|
|
365
|
-
l, h, -d,
|
|
366
|
-
l, -h, -d,
|
|
351
|
+
-l, -h, -d, -l, h, -d, l, -h, -d, -l, h, -d, l, h, -d, l, -h, -d,
|
|
367
352
|
|
|
368
353
|
//left
|
|
369
|
-
l, -h, d,
|
|
370
|
-
l, -h, -d,
|
|
371
|
-
l, h, d,
|
|
372
|
-
l, h, d,
|
|
373
|
-
l, -h, -d,
|
|
374
|
-
l, h, -d,
|
|
354
|
+
l, -h, d, l, -h, -d, l, h, d, l, h, d, l, -h, -d, l, h, -d,
|
|
375
355
|
|
|
376
356
|
//right
|
|
377
|
-
-l, -h, d,
|
|
378
|
-
-l, h, d,
|
|
379
|
-
-l, -h, -d,
|
|
380
|
-
-l, h, d,
|
|
381
|
-
-l, h, -d,
|
|
382
|
-
-l, -h, -d
|
|
383
|
-
]
|
|
357
|
+
-l, -h, d, -l, h, d, -l, -h, -d, -l, h, d, -l, h, -d, -l, -h, -d]
|
|
384
358
|
});
|
|
385
359
|
}
|
|
386
360
|
|
|
387
361
|
static createArrow(back = 0.0, height = 2.1, front = -15) {
|
|
388
362
|
return new Object3d({
|
|
389
|
-
vertices: [
|
|
390
|
-
|
|
391
|
-
7, 0, 6,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
7, 0, 6,
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
-7, 0, 6,
|
|
399
|
-
0, 0, back,
|
|
400
|
-
0, height, 0,
|
|
401
|
-
|
|
402
|
-
-7, 0, 6,
|
|
403
|
-
0, height, 0,
|
|
404
|
-
0, 0, front,
|
|
405
|
-
|
|
406
|
-
-7, 0, 6,
|
|
407
|
-
0, 0, front,
|
|
408
|
-
0, 0, back,
|
|
409
|
-
0, 0, back,
|
|
410
|
-
0, 0, front,
|
|
411
|
-
7, 0, 6
|
|
412
|
-
]
|
|
363
|
+
vertices: [0, height, 0, 7, 0, 6, 0, 0, front,
|
|
364
|
+
|
|
365
|
+
0, 0, back, 7, 0, 6, 0, height, 0,
|
|
366
|
+
|
|
367
|
+
-7, 0, 6, 0, 0, back, 0, height, 0,
|
|
368
|
+
|
|
369
|
+
-7, 0, 6, 0, height, 0, 0, 0, front,
|
|
370
|
+
|
|
371
|
+
-7, 0, 6, 0, 0, front, 0, 0, back, 0, 0, back, 0, 0, front, 7, 0, 6]
|
|
413
372
|
});
|
|
414
373
|
}
|
|
415
374
|
}
|
package/src/og/camera/Camera.js
CHANGED
|
@@ -80,18 +80,18 @@ class Camera {
|
|
|
80
80
|
this._viewAngle = options.viewAngle || 47.0;
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* Camera
|
|
83
|
+
* Camera view matrix.
|
|
84
84
|
* @protected
|
|
85
|
-
* @type {
|
|
85
|
+
* @type {Mat4}
|
|
86
86
|
*/
|
|
87
|
-
this.
|
|
87
|
+
this._viewMatrix = new Mat4();
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* Camera
|
|
90
|
+
* Camera normal matrix.
|
|
91
91
|
* @protected
|
|
92
|
-
* @type {
|
|
92
|
+
* @type {Mat3}
|
|
93
93
|
*/
|
|
94
|
-
this.
|
|
94
|
+
this._normalMatrix = new Mat3();
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* Camera right vector.
|
|
@@ -167,7 +167,9 @@ class Camera {
|
|
|
167
167
|
|
|
168
168
|
this.FARTHEST_FRUSTUM_INDEX = this.frustums.length - 1;
|
|
169
169
|
|
|
170
|
-
this.
|
|
170
|
+
this.currentFrustumIndex = 0;
|
|
171
|
+
|
|
172
|
+
this.isFirstPass = false;
|
|
171
173
|
|
|
172
174
|
renderer && this._init(options);
|
|
173
175
|
}
|
|
@@ -271,7 +273,8 @@ class Camera {
|
|
|
271
273
|
1.0
|
|
272
274
|
]);
|
|
273
275
|
|
|
274
|
-
|
|
276
|
+
// do not cleanup, someday it will be using
|
|
277
|
+
//this._normalMatrix = this._viewMatrix.toMatrix3(); // this._viewMatrix.toInverseMatrix3().transposeTo();
|
|
275
278
|
|
|
276
279
|
for (let i = 0, len = this.frustums.length; i < len; i++) {
|
|
277
280
|
this.frustums[i].setViewMatrix(this._viewMatrix);
|
|
@@ -557,33 +560,34 @@ class Camera {
|
|
|
557
560
|
}
|
|
558
561
|
|
|
559
562
|
/**
|
|
560
|
-
* Returns
|
|
563
|
+
* Returns model matrix.
|
|
561
564
|
* @public
|
|
562
|
-
* @returns {
|
|
565
|
+
* @returns {Mat4} - View matrix.
|
|
563
566
|
*/
|
|
564
|
-
|
|
565
|
-
return this.
|
|
567
|
+
getViewMatrix() {
|
|
568
|
+
return this._viewMatrix._m;
|
|
566
569
|
}
|
|
567
570
|
|
|
568
571
|
/**
|
|
569
|
-
* Returns
|
|
572
|
+
* Returns normal matrix.
|
|
570
573
|
* @public
|
|
571
|
-
* @returns {
|
|
574
|
+
* @returns {Mat3} - Normal matrix.
|
|
572
575
|
*/
|
|
573
|
-
|
|
574
|
-
return this.
|
|
576
|
+
getNormalMatrix() {
|
|
577
|
+
return this._normalMatrix._m;
|
|
575
578
|
}
|
|
576
579
|
|
|
577
580
|
setCurrentFrustum(k) {
|
|
578
|
-
this.
|
|
581
|
+
this.currentFrustumIndex = k;
|
|
582
|
+
this.isFirstPass = k === this.FARTHEST_FRUSTUM_INDEX;
|
|
579
583
|
}
|
|
580
584
|
|
|
581
585
|
getCurrentFrustum() {
|
|
582
|
-
return this.
|
|
586
|
+
return this.currentFrustumIndex;
|
|
583
587
|
}
|
|
584
588
|
|
|
585
589
|
get frustum() {
|
|
586
|
-
return this.frustums[this.
|
|
590
|
+
return this.frustums[this.currentFrustumIndex];
|
|
587
591
|
}
|
|
588
592
|
|
|
589
593
|
/**
|