@openglobus/og 0.22.2 → 0.24.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 +137 -1
- package/lib/@openglobus/js/Globe.d.ts +0 -1
- package/lib/@openglobus/js/Object3d.d.ts +20 -10
- package/lib/@openglobus/js/camera/Camera.d.ts +57 -15
- package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
- package/lib/@openglobus/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/@openglobus/js/control/CameraLock.d.ts +38 -0
- package/lib/@openglobus/js/control/MouseNavigation.d.ts +62 -51
- package/lib/@openglobus/js/control/OldMouseNavigation.d.ts +64 -0
- package/lib/@openglobus/js/control/SimpleNavigation.d.ts +27 -10
- package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/@openglobus/js/control/index.d.ts +3 -2
- package/lib/@openglobus/js/entity/Entity.d.ts +282 -19
- package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
- package/lib/@openglobus/js/entity/GeoObject.d.ts +135 -39
- package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
- package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
- package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/@openglobus/js/index.d.ts +2 -1
- package/lib/@openglobus/js/input/MouseHandler.d.ts +1 -0
- package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
- package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
- package/lib/@openglobus/js/math/Mat3.d.ts +1 -1
- package/lib/@openglobus/js/math/Mat4.d.ts +10 -1
- package/lib/@openglobus/js/math/Plane.d.ts +3 -1
- package/lib/@openglobus/js/math/Quat.d.ts +47 -33
- package/lib/@openglobus/js/math/Ray.d.ts +10 -14
- package/lib/@openglobus/js/math/Vec2.d.ts +22 -0
- package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
- package/lib/@openglobus/js/math.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/renderer/Renderer.d.ts +63 -44
- package/lib/@openglobus/js/renderer/RendererEvents.d.ts +2 -0
- package/lib/@openglobus/js/scene/Planet.d.ts +15 -7
- package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
- package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
- package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
- package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
- package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
- package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
- package/lib/@openglobus/js/ui/Input.d.ts +32 -0
- package/lib/@openglobus/js/ui/View.d.ts +3 -1
- package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
- package/lib/@openglobus/js/utils/shared.d.ts +22 -0
- package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/@openglobus/js/webgl/Handler.d.ts +22 -12
- package/lib/@openglobus/og.css +1 -1
- package/lib/@openglobus/og.esm.js +1 -1
- package/lib/@openglobus/og.esm.js.map +1 -1
- package/lib/@openglobus/og.umd.js +1 -1
- package/lib/@openglobus/og.umd.js.map +1 -1
- package/lib/js/Globe.d.ts +0 -1
- package/lib/js/Globe.js +4 -2
- package/lib/js/Object3d.d.ts +20 -10
- package/lib/js/Object3d.js +124 -48
- package/lib/js/Popup.js +1 -1
- package/lib/js/camera/Camera.d.ts +57 -15
- package/lib/js/camera/Camera.js +109 -29
- package/lib/js/camera/Frustum.d.ts +3 -0
- package/lib/js/camera/Frustum.js +7 -0
- package/lib/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/js/camera/PlanetCamera.js +52 -5
- package/lib/js/control/Atmosphere.js +10 -6
- package/lib/js/control/CameraLock.d.ts +38 -0
- package/lib/js/control/CameraLock.js +216 -0
- package/lib/js/control/Control.js +1 -1
- package/lib/js/control/DebugInfo.js +38 -8
- package/lib/js/control/KeyboardNavigation.js +9 -9
- package/lib/js/control/MouseNavigation.d.ts +62 -51
- package/lib/js/control/MouseNavigation.js +361 -305
- package/lib/js/control/MouseWheelZoomControl.d.ts +0 -44
- package/lib/js/control/MouseWheelZoomControl.js +270 -181
- package/lib/js/control/OldMouseNavigation.d.ts +64 -0
- package/lib/js/control/OldMouseNavigation.js +368 -0
- package/lib/js/control/ScaleControl.js +11 -5
- package/lib/js/control/SimpleNavigation.d.ts +27 -10
- package/lib/js/control/SimpleNavigation.js +149 -49
- package/lib/js/control/Sun.js +6 -6
- package/lib/js/control/TouchNavigation.js +11 -8
- package/lib/js/control/elevationProfile/ElevationProfileScene.js +6 -5
- package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +488 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +107 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +31 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
- package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/js/control/geoObjectEditor/colors.js +8 -0
- package/lib/js/control/index.d.ts +3 -2
- package/lib/js/control/index.js +3 -2
- package/lib/js/control/timeline/TimelineControl.js +2 -0
- package/lib/js/control/visibleExtent/Segment.js +4 -4
- package/lib/js/entity/Entity.d.ts +282 -19
- package/lib/js/entity/Entity.js +497 -62
- package/lib/js/entity/EntityCollection.d.ts +8 -9
- package/lib/js/entity/EntityCollection.js +48 -45
- package/lib/js/entity/GeoObject.d.ts +135 -39
- package/lib/js/entity/GeoObject.js +150 -90
- package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/js/entity/GeoObjectHandler.js +198 -295
- package/lib/js/entity/InstanceData.d.ts +76 -0
- package/lib/js/entity/InstanceData.js +347 -0
- package/lib/js/entity/Polyline.d.ts +19 -6
- package/lib/js/entity/Polyline.js +76 -36
- package/lib/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/js/entity/PolylineHandler.js +26 -1
- package/lib/js/index.d.ts +2 -1
- package/lib/js/index.js +2 -1
- package/lib/js/input/MouseHandler.d.ts +1 -0
- package/lib/js/input/MouseHandler.js +12 -1
- package/lib/js/layer/Bing.js +2 -2
- package/lib/js/layer/Vector.d.ts +4 -0
- package/lib/js/layer/Vector.js +16 -0
- package/lib/js/light/LightSource.d.ts +1 -139
- package/lib/js/light/LightSource.js +21 -227
- package/lib/js/math/Mat3.d.ts +1 -1
- package/lib/js/math/Mat3.js +1 -1
- package/lib/js/math/Mat4.d.ts +10 -1
- package/lib/js/math/Mat4.js +17 -1
- package/lib/js/math/Plane.d.ts +3 -1
- package/lib/js/math/Plane.js +11 -1
- package/lib/js/math/Quat.d.ts +47 -33
- package/lib/js/math/Quat.js +92 -90
- package/lib/js/math/Ray.d.ts +10 -14
- package/lib/js/math/Ray.js +56 -33
- package/lib/js/math/Vec2.d.ts +22 -0
- package/lib/js/math/Vec2.js +32 -0
- package/lib/js/math/Vec3.d.ts +15 -0
- package/lib/js/math/Vec3.js +30 -1
- package/lib/js/math.d.ts +2 -2
- package/lib/js/math.js +3 -3
- package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/js/quadTree/EntityCollectionNode.js +8 -8
- package/lib/js/quadTree/Node.d.ts +1 -1
- package/lib/js/quadTree/Node.js +2 -2
- package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/renderer/Renderer.d.ts +63 -44
- package/lib/js/renderer/Renderer.js +267 -266
- package/lib/js/renderer/RendererEvents.d.ts +2 -0
- package/lib/js/renderer/RendererEvents.js +5 -2
- package/lib/js/scene/Planet.d.ts +15 -7
- package/lib/js/scene/Planet.js +133 -90
- package/lib/js/scene/RenderNode.d.ts +10 -25
- package/lib/js/scene/RenderNode.js +70 -58
- package/lib/js/segment/Segment.js +4 -4
- package/lib/js/shaders/depth.js +2 -5
- package/lib/js/shaders/drawnode.d.ts +1 -0
- package/lib/js/shaders/drawnode.js +51 -52
- package/lib/js/shaders/geoObject.d.ts +1 -0
- package/lib/js/shaders/geoObject.js +154 -91
- package/lib/js/shaders/polyline.js +68 -51
- package/lib/js/shaders/utils.d.ts +1 -1
- package/lib/js/shaders/utils.js +11 -0
- package/lib/js/terrain/GlobusTerrain.js +2 -2
- package/lib/js/ui/Checkbox.d.ts +31 -0
- package/lib/js/ui/Checkbox.js +110 -0
- package/lib/js/ui/Color.js +2 -1
- package/lib/js/ui/Dialog.d.ts +3 -0
- package/lib/js/ui/Dialog.js +20 -0
- package/lib/js/ui/Input.d.ts +32 -0
- package/lib/js/ui/Input.js +107 -0
- package/lib/js/ui/View.d.ts +3 -1
- package/lib/js/ui/View.js +6 -0
- package/lib/js/utils/objParser.d.ts +44 -12
- package/lib/js/utils/objParser.js +241 -149
- package/lib/js/utils/shared.d.ts +22 -0
- package/lib/js/utils/shared.js +34 -0
- package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/js/webgl/Framebuffer.js +136 -29
- package/lib/js/webgl/Handler.d.ts +22 -12
- package/lib/js/webgl/Handler.js +53 -34
- package/lib/js/webgl/Program.js +0 -8
- package/package.json +5 -3
- package/lib/@openglobus/js/control/EarthNavigation.d.ts +0 -50
- package/lib/@openglobus/js/control/MouseWheelZoomControl.d.ts +0 -44
- package/lib/js/control/EarthNavigation.d.ts +0 -50
- package/lib/js/control/EarthNavigation.js +0 -202
package/lib/js/camera/Camera.js
CHANGED
|
@@ -6,6 +6,8 @@ import { Mat4 } from "../math/Mat4";
|
|
|
6
6
|
import { Vec2 } from "../math/Vec2";
|
|
7
7
|
import { Vec3 } from "../math/Vec3";
|
|
8
8
|
import { Vec4 } from "../math/Vec4";
|
|
9
|
+
import { Quat } from "../math/Quat";
|
|
10
|
+
import { RADIANS } from "../math";
|
|
9
11
|
const EVENT_NAMES = [
|
|
10
12
|
/**
|
|
11
13
|
* When camera has been updated.
|
|
@@ -44,10 +46,12 @@ class Camera {
|
|
|
44
46
|
this._aspect = options.aspect || 1.0;
|
|
45
47
|
this._viewAngle = options.viewAngle || 47.0;
|
|
46
48
|
this._viewMatrix = new Mat4();
|
|
49
|
+
this._viewMatrixRTE = new Mat4();
|
|
47
50
|
this._normalMatrix = new Mat3();
|
|
48
51
|
this._r = new Vec3(1.0, 0.0, 0.0);
|
|
49
52
|
this._u = new Vec3(0.0, 1.0, 0.0);
|
|
50
53
|
this._b = new Vec3(0.0, 0.0, 1.0);
|
|
54
|
+
this._f = this._b.negateTo();
|
|
51
55
|
// Previous frame values
|
|
52
56
|
this._pr = this._r.clone();
|
|
53
57
|
this._pu = this._u.clone();
|
|
@@ -74,7 +78,7 @@ class Camera {
|
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
else {
|
|
77
|
-
let near = 1
|
|
81
|
+
let near = 0.1, far = 1000.0;
|
|
78
82
|
let fr = new Frustum({
|
|
79
83
|
fov: this._viewAngle,
|
|
80
84
|
aspect: this._aspect,
|
|
@@ -88,6 +92,7 @@ class Camera {
|
|
|
88
92
|
}
|
|
89
93
|
this.FARTHEST_FRUSTUM_INDEX = this.frustums.length - 1;
|
|
90
94
|
this.currentFrustumIndex = 0;
|
|
95
|
+
this.frustumColorIndex = 0;
|
|
91
96
|
this.isFirstPass = false;
|
|
92
97
|
this._projSizeConst = 0;
|
|
93
98
|
this.set(options.eye || new Vec3(0.0, 0.0, 1.0), options.look || new Vec3(), options.up || new Vec3(0.0, 1.0, 0.0));
|
|
@@ -144,7 +149,7 @@ class Camera {
|
|
|
144
149
|
return this._r.negateTo();
|
|
145
150
|
}
|
|
146
151
|
getForward() {
|
|
147
|
-
return this.
|
|
152
|
+
return this._f.clone();
|
|
148
153
|
}
|
|
149
154
|
getBackward() {
|
|
150
155
|
return this._b.clone();
|
|
@@ -163,10 +168,17 @@ class Camera {
|
|
|
163
168
|
u.z, v.z, n.z, 0.0,
|
|
164
169
|
-eye.dot(u), -eye.dot(v), -eye.dot(n), 1.0
|
|
165
170
|
]);
|
|
171
|
+
this._viewMatrixRTE.set([
|
|
172
|
+
u.x, v.x, n.x, 0.0,
|
|
173
|
+
u.y, v.y, n.y, 0.0,
|
|
174
|
+
u.z, v.z, n.z, 0.0,
|
|
175
|
+
0, 0, 0, 1.0
|
|
176
|
+
]);
|
|
166
177
|
// do not clean up, someday it will be using
|
|
167
178
|
//this._normalMatrix = this._viewMatrix.toMatrix3(); // this._viewMatrix.toInverseMatrix3().transposeTo();
|
|
168
179
|
for (let i = 0, len = this.frustums.length; i < len; i++) {
|
|
169
180
|
this.frustums[i].setViewMatrix(this._viewMatrix);
|
|
181
|
+
this.frustums[i].setProjectionViewRTEMatrix(this._viewMatrixRTE);
|
|
170
182
|
}
|
|
171
183
|
this.events.dispatch(this.events.viewchange, this);
|
|
172
184
|
}
|
|
@@ -208,7 +220,7 @@ class Camera {
|
|
|
208
220
|
this._tanViewAngle_hradOneByHeight =
|
|
209
221
|
this._tanViewAngle_hrad * this.renderer.handler._oneByHeight;
|
|
210
222
|
let c = this.renderer.handler.canvas;
|
|
211
|
-
this._projSizeConst = Math.min(c.clientWidth < 512 ? 512 : c.clientWidth, c.clientHeight < 512 ? 512 : c.clientHeight) / (angle *
|
|
223
|
+
this._projSizeConst = Math.min(c.clientWidth < 512 ? 512 : c.clientWidth, c.clientHeight < 512 ? 512 : c.clientHeight) / (angle * RADIANS);
|
|
212
224
|
for (let i = 0, len = this.frustums.length; i < len; i++) {
|
|
213
225
|
this.frustums[i].setProjectionMatrix(angle, aspect, this.frustums[i].near, this.frustums[i].far);
|
|
214
226
|
}
|
|
@@ -254,6 +266,7 @@ class Camera {
|
|
|
254
266
|
this._b.normalize();
|
|
255
267
|
this._r.normalize();
|
|
256
268
|
this._u.copy(this._b.cross(this._r));
|
|
269
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
257
270
|
return this;
|
|
258
271
|
}
|
|
259
272
|
/**
|
|
@@ -266,6 +279,7 @@ class Camera {
|
|
|
266
279
|
this._b.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z);
|
|
267
280
|
this._r.copy((up || this._u).cross(this._b));
|
|
268
281
|
this._b.normalize();
|
|
282
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
269
283
|
this._r.normalize();
|
|
270
284
|
this._u.copy(this._b.cross(this._r));
|
|
271
285
|
}
|
|
@@ -282,41 +296,82 @@ class Camera {
|
|
|
282
296
|
this.eye.z += du * this._r.z + dv * this._u.z + dn * this._b.z;
|
|
283
297
|
}
|
|
284
298
|
/**
|
|
285
|
-
* Roll the camera to the angle in
|
|
299
|
+
* Roll the camera to the angle in radians
|
|
286
300
|
* @public
|
|
287
|
-
* @param {number} angle - Delta roll angle in
|
|
301
|
+
* @param {number} angle - Delta roll angle in radians
|
|
288
302
|
*/
|
|
289
|
-
|
|
290
|
-
let cs = Math.cos(
|
|
291
|
-
let sn = Math.sin(
|
|
303
|
+
setRoll(angle) {
|
|
304
|
+
let cs = Math.cos(angle);
|
|
305
|
+
let sn = Math.sin(angle);
|
|
292
306
|
let t = this._r.clone();
|
|
293
307
|
this._r.set(cs * t.x - sn * this._u.x, cs * t.y - sn * this._u.y, cs * t.z - sn * this._u.z);
|
|
294
308
|
this._u.set(sn * t.x + cs * this._u.x, sn * t.y + cs * this._u.y, sn * t.z + cs * this._u.z);
|
|
295
309
|
}
|
|
296
310
|
/**
|
|
297
|
-
* Pitch the camera to the angle in
|
|
311
|
+
* Pitch the camera to the angle in radians
|
|
298
312
|
* @public
|
|
299
|
-
* @param {number} angle - Delta pitch angle in
|
|
313
|
+
* @param {number} angle - Delta pitch angle in radians
|
|
300
314
|
*/
|
|
301
|
-
|
|
302
|
-
let cs = Math.cos(
|
|
303
|
-
let sn = Math.sin(
|
|
304
|
-
let t = this._b
|
|
315
|
+
setPitch(angle) {
|
|
316
|
+
let cs = Math.cos(angle);
|
|
317
|
+
let sn = Math.sin(angle);
|
|
318
|
+
let t = this._b;
|
|
305
319
|
this._b.set(cs * t.x - sn * this._u.x, cs * t.y - sn * this._u.y, cs * t.z - sn * this._u.z);
|
|
306
320
|
this._u.set(sn * t.x + cs * this._u.x, sn * t.y + cs * this._u.y, sn * t.z + cs * this._u.z);
|
|
307
321
|
}
|
|
308
322
|
/**
|
|
309
|
-
* Yaw the camera to the angle in
|
|
323
|
+
* Yaw the camera to the angle in radians
|
|
310
324
|
* @public
|
|
311
|
-
* @param {number} angle - Delta yaw angle in
|
|
325
|
+
* @param {number} angle - Delta yaw angle in radians
|
|
312
326
|
*/
|
|
313
|
-
|
|
314
|
-
let cs = Math.cos(
|
|
315
|
-
let sn = Math.sin(
|
|
316
|
-
let t = this._r
|
|
327
|
+
setYaw(angle) {
|
|
328
|
+
let cs = Math.cos(angle);
|
|
329
|
+
let sn = Math.sin(angle);
|
|
330
|
+
let t = this._r;
|
|
317
331
|
this._r.set(cs * t.x - sn * this._b.x, cs * t.y - sn * this._b.y, cs * t.z - sn * this._b.z);
|
|
318
332
|
this._b.set(sn * t.x + cs * this._b.x, sn * t.y + cs * this._b.y, sn * t.z + cs * this._b.z);
|
|
319
333
|
}
|
|
334
|
+
setPitchYawRoll(pitch, yaw, roll) {
|
|
335
|
+
let qRot = new Quat();
|
|
336
|
+
qRot.setPitchYawRoll(pitch, yaw, roll);
|
|
337
|
+
this.setRotation(qRot);
|
|
338
|
+
}
|
|
339
|
+
getPitch() {
|
|
340
|
+
return this.getRotation().getPitch();
|
|
341
|
+
}
|
|
342
|
+
getYaw() {
|
|
343
|
+
return this.getRotation().getYaw();
|
|
344
|
+
}
|
|
345
|
+
getRoll() {
|
|
346
|
+
return this.getRotation().getRoll();
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Returns camera quaternion
|
|
350
|
+
*/
|
|
351
|
+
getRotation() {
|
|
352
|
+
return Quat.getLookRotation(this._f, this._u).conjugate();
|
|
353
|
+
}
|
|
354
|
+
setRotation(rot, up, right, back) {
|
|
355
|
+
rot.mulVec3Res(up || new Vec3(0, 1, 0), this._u);
|
|
356
|
+
rot.mulVec3Res(right || new Vec3(1, 0, 0), this._r);
|
|
357
|
+
rot.mulVec3Res(back || new Vec3(0, 0, 1), this._b);
|
|
358
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
359
|
+
}
|
|
360
|
+
rotate(rot) {
|
|
361
|
+
rot.mulVec3Res(this._u, this._u);
|
|
362
|
+
rot.mulVec3Res(this._r, this._r);
|
|
363
|
+
rot.mulVec3Res(this._b, this._b);
|
|
364
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Returns normal vector direction to the unprojected screen point from camera eye
|
|
368
|
+
* @public
|
|
369
|
+
* @param {Vec2} pos - Screen X coordinate
|
|
370
|
+
* @returns {Vec3} - Direction vector
|
|
371
|
+
*/
|
|
372
|
+
unproject2v(pos) {
|
|
373
|
+
return this.unproject(pos.x, pos.y);
|
|
374
|
+
}
|
|
320
375
|
/**
|
|
321
376
|
* Returns normal vector direction to the unprojected screen point from camera eye
|
|
322
377
|
* @public
|
|
@@ -336,8 +391,19 @@ class Camera {
|
|
|
336
391
|
* @param {Vec3} v - Cartesian 3d coordinates
|
|
337
392
|
* @returns {Vec2} - Screen point coordinates
|
|
338
393
|
*/
|
|
339
|
-
|
|
340
|
-
|
|
394
|
+
project3v(v) {
|
|
395
|
+
return this.project(v.x, v.y, v.z);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Gets projected 3d point to the 2d screen coordinates
|
|
399
|
+
* @public
|
|
400
|
+
* @param {number} x - X coordinate
|
|
401
|
+
* @param {number} y - Y coordinate
|
|
402
|
+
* @param {number} z - Z coordinate
|
|
403
|
+
* @returns {Vec2} - Screen point coordinates
|
|
404
|
+
*/
|
|
405
|
+
project(x, y, z) {
|
|
406
|
+
let r = this.frustums[0].projectionViewMatrix.mulVec4(new Vec4(x, y, z, 1.0)), c = this.renderer.handler.canvas;
|
|
341
407
|
return new Vec2((1 + r.x / r.w) * c.width * 0.5, (1 - r.y / r.w) * c.height * 0.5);
|
|
342
408
|
}
|
|
343
409
|
/**
|
|
@@ -349,17 +415,15 @@ class Camera {
|
|
|
349
415
|
* @param {Vec3} [center] - Point that the camera rotates around
|
|
350
416
|
* @param {Vec3} [up] - Camera up vector
|
|
351
417
|
*/
|
|
352
|
-
rotateAround(angle, isArc, center, up) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
let
|
|
356
|
-
let tr = new Mat4().setIdentity().translate(center);
|
|
357
|
-
let ntr = new Mat4().setIdentity().translate(center.negateTo());
|
|
358
|
-
let trm = tr.mul(rot).mul(ntr);
|
|
418
|
+
rotateAround(angle, isArc = false, center = Vec3.ZERO, up = Vec3.UP) {
|
|
419
|
+
up = isArc ? this._u : up;
|
|
420
|
+
let rot = Mat4.getRotation(angle, up);
|
|
421
|
+
let trm = Mat4.getRotationAroundPoint(angle, center, up);
|
|
359
422
|
this.eye = trm.mulVec3(this.eye);
|
|
360
423
|
this._u = rot.mulVec3(this._u).normalize();
|
|
361
424
|
this._r = rot.mulVec3(this._r).normalize();
|
|
362
425
|
this._b = rot.mulVec3(this._b).normalize();
|
|
426
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
363
427
|
}
|
|
364
428
|
/**
|
|
365
429
|
* Rotates camera around center point by horizontal.
|
|
@@ -409,6 +473,7 @@ class Camera {
|
|
|
409
473
|
}
|
|
410
474
|
setCurrentFrustum(k) {
|
|
411
475
|
this.currentFrustumIndex = k;
|
|
476
|
+
this.frustumColorIndex = (k + 1) * 10.0 / 255.0;
|
|
412
477
|
this.isFirstPass = k === this.FARTHEST_FRUSTUM_INDEX;
|
|
413
478
|
}
|
|
414
479
|
getCurrentFrustum() {
|
|
@@ -441,6 +506,14 @@ class Camera {
|
|
|
441
506
|
getProjectionViewMatrix() {
|
|
442
507
|
return this.frustum.projectionViewMatrix._m;
|
|
443
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Returns projection and model RTE matrix product.
|
|
511
|
+
* @public
|
|
512
|
+
* @return {Mat4} - Projection-view matrix.
|
|
513
|
+
*/
|
|
514
|
+
getProjectionViewRTEMatrix() {
|
|
515
|
+
return this.frustum.projectionViewRTEMatrix._m;
|
|
516
|
+
}
|
|
444
517
|
/**
|
|
445
518
|
* Returns inverse projection and model matrix product.
|
|
446
519
|
* @public
|
|
@@ -457,5 +530,12 @@ class Camera {
|
|
|
457
530
|
getInverseProjectionMatrix() {
|
|
458
531
|
return this.frustum.inverseProjectionMatrix._m;
|
|
459
532
|
}
|
|
533
|
+
viewDistance(cartesian, distance = 10000.0) {
|
|
534
|
+
let p0 = this.eye.add(this.getForward().scaleTo(distance));
|
|
535
|
+
let _rot = Quat.getRotationBetweenVectors(p0.getNormal(), cartesian.getNormal());
|
|
536
|
+
let newPos = cartesian.add(this.getBackward().scaleTo(distance));
|
|
537
|
+
this.set(newPos, cartesian);
|
|
538
|
+
this.update();
|
|
539
|
+
}
|
|
460
540
|
}
|
|
461
541
|
export { Camera };
|
|
@@ -35,6 +35,7 @@ declare class Frustum {
|
|
|
35
35
|
* @type {Mat4}
|
|
36
36
|
*/
|
|
37
37
|
projectionViewMatrix: Mat4;
|
|
38
|
+
projectionViewRTEMatrix: Mat4;
|
|
38
39
|
/**
|
|
39
40
|
* Inverse projectionView Matrix.
|
|
40
41
|
* @protected
|
|
@@ -81,6 +82,7 @@ declare class Frustum {
|
|
|
81
82
|
getBackwardPlane(): NumberArray4;
|
|
82
83
|
getForwardPlane(): NumberArray4;
|
|
83
84
|
getProjectionViewMatrix(): NumberArray16;
|
|
85
|
+
getProjectionViewRTEMatrix(): NumberArray16;
|
|
84
86
|
getProjectionMatrix(): NumberArray16;
|
|
85
87
|
getInverseProjectionMatrix(): NumberArray16;
|
|
86
88
|
/**
|
|
@@ -92,6 +94,7 @@ declare class Frustum {
|
|
|
92
94
|
* @param {number} far - Far camera distance.
|
|
93
95
|
*/
|
|
94
96
|
setProjectionMatrix(angle: number, aspect: number, near: number, far: number): void;
|
|
97
|
+
setProjectionViewRTEMatrix(viewRTEMatrix: Mat4): void;
|
|
95
98
|
/**
|
|
96
99
|
* Camera's projection matrix values.
|
|
97
100
|
* @public
|
package/lib/js/camera/Frustum.js
CHANGED
|
@@ -19,6 +19,7 @@ class Frustum {
|
|
|
19
19
|
this.projectionMatrix = new Mat4();
|
|
20
20
|
this.inverseProjectionMatrix = new Mat4();
|
|
21
21
|
this.projectionViewMatrix = new Mat4();
|
|
22
|
+
this.projectionViewRTEMatrix = new Mat4();
|
|
22
23
|
this.inverseProjectionViewMatrix = new Mat4();
|
|
23
24
|
this.left = 0.0;
|
|
24
25
|
this.right = 0.0;
|
|
@@ -50,6 +51,9 @@ class Frustum {
|
|
|
50
51
|
getProjectionViewMatrix() {
|
|
51
52
|
return this.projectionViewMatrix._m;
|
|
52
53
|
}
|
|
54
|
+
getProjectionViewRTEMatrix() {
|
|
55
|
+
return this.projectionViewRTEMatrix._m;
|
|
56
|
+
}
|
|
53
57
|
getProjectionMatrix() {
|
|
54
58
|
return this.projectionMatrix._m;
|
|
55
59
|
}
|
|
@@ -74,6 +78,9 @@ class Frustum {
|
|
|
74
78
|
this.projectionMatrix.setPerspective(this.left, this.right, this.bottom, this.top, near, far);
|
|
75
79
|
this.projectionMatrix.inverseTo(this.inverseProjectionMatrix);
|
|
76
80
|
}
|
|
81
|
+
setProjectionViewRTEMatrix(viewRTEMatrix) {
|
|
82
|
+
this.projectionViewRTEMatrix = this.projectionMatrix.mul(viewRTEMatrix);
|
|
83
|
+
}
|
|
77
84
|
/**
|
|
78
85
|
* Camera's projection matrix values.
|
|
79
86
|
* @public
|
|
@@ -228,7 +228,20 @@ declare class PlanetCamera extends Camera {
|
|
|
228
228
|
checkFly(): void;
|
|
229
229
|
checkTerrainCollision(): Vec3 | undefined;
|
|
230
230
|
getSurfaceVisibleDistance(d: number): number;
|
|
231
|
+
/**
|
|
232
|
+
* should be yje same as getYaw
|
|
233
|
+
*/
|
|
231
234
|
getHeading(): number;
|
|
232
235
|
isVisible(poi: Vec3): boolean;
|
|
236
|
+
getPitch(): number;
|
|
237
|
+
/**
|
|
238
|
+
* should be the same as getHeading
|
|
239
|
+
*/
|
|
240
|
+
getYaw(): number;
|
|
241
|
+
getRoll(): number;
|
|
242
|
+
setPitch(a: number): void;
|
|
243
|
+
setYaw(a: number): void;
|
|
244
|
+
setRoll(a: number): void;
|
|
245
|
+
setPitchYawRoll(pitch: number, yaw: number, roll: number): void;
|
|
233
246
|
}
|
|
234
247
|
export { PlanetCamera };
|
|
@@ -7,6 +7,7 @@ import { Mat4 } from "../math/Mat4";
|
|
|
7
7
|
import { Quat } from "../math/Quat";
|
|
8
8
|
import { Ray } from "../math/Ray";
|
|
9
9
|
import { Vec3 } from "../math/Vec3";
|
|
10
|
+
import { RADIANS } from "../math";
|
|
10
11
|
/**
|
|
11
12
|
* Planet camera.
|
|
12
13
|
* @class
|
|
@@ -167,7 +168,7 @@ class PlanetCamera extends Camera {
|
|
|
167
168
|
let up = right.cross(direction).normalize();
|
|
168
169
|
let _h = Math.max(Math.abs(up.dot(northWest)), Math.abs(up.dot(southEast)), Math.abs(up.dot(northEast)), Math.abs(up.dot(southWest)));
|
|
169
170
|
let _w = Math.max(Math.abs(right.dot(northWest)), Math.abs(right.dot(southEast)), Math.abs(right.dot(northEast)), Math.abs(right.dot(southWest)));
|
|
170
|
-
let tanPhi = Math.tan(this._viewAngle *
|
|
171
|
+
let tanPhi = Math.tan(this._viewAngle * RADIANS * 0.5);
|
|
171
172
|
let tanTheta = this._aspect * tanPhi;
|
|
172
173
|
let d = Math.max(_w / tanTheta, _h / tanPhi);
|
|
173
174
|
center.normalize();
|
|
@@ -329,6 +330,7 @@ class PlanetCamera extends Camera {
|
|
|
329
330
|
this._framesArr = [];
|
|
330
331
|
this._framesCounter = -1;
|
|
331
332
|
this._frameCallback = null;
|
|
333
|
+
this.planet.stopDragging();
|
|
332
334
|
}
|
|
333
335
|
/**
|
|
334
336
|
* Returns camera is flying.
|
|
@@ -345,7 +347,7 @@ class PlanetCamera extends Camera {
|
|
|
345
347
|
* @param {boolean} [spin] - If its true rotates around globe spin.
|
|
346
348
|
*/
|
|
347
349
|
rotateLeft(angle, spin) {
|
|
348
|
-
this.rotateHorizontal(angle
|
|
350
|
+
this.rotateHorizontal(angle, spin !== true, Vec3.ZERO);
|
|
349
351
|
this.update();
|
|
350
352
|
}
|
|
351
353
|
/**
|
|
@@ -355,7 +357,7 @@ class PlanetCamera extends Camera {
|
|
|
355
357
|
* @param {boolean} [spin] - If its true rotates around globe spin.
|
|
356
358
|
*/
|
|
357
359
|
rotateRight(angle, spin) {
|
|
358
|
-
this.rotateHorizontal(-angle
|
|
360
|
+
this.rotateHorizontal(-angle, spin !== true, Vec3.ZERO);
|
|
359
361
|
this.update();
|
|
360
362
|
}
|
|
361
363
|
/**
|
|
@@ -364,7 +366,7 @@ class PlanetCamera extends Camera {
|
|
|
364
366
|
* @param {number} angle - Rotation angle.
|
|
365
367
|
*/
|
|
366
368
|
rotateUp(angle) {
|
|
367
|
-
this.rotateVertical(angle
|
|
369
|
+
this.rotateVertical(angle, Vec3.ZERO);
|
|
368
370
|
this.update();
|
|
369
371
|
}
|
|
370
372
|
/**
|
|
@@ -373,7 +375,7 @@ class PlanetCamera extends Camera {
|
|
|
373
375
|
* @param {number} angle - Rotation angle.
|
|
374
376
|
*/
|
|
375
377
|
rotateDown(angle) {
|
|
376
|
-
this.rotateVertical(-angle
|
|
378
|
+
this.rotateVertical(-angle, Vec3.ZERO);
|
|
377
379
|
this.update();
|
|
378
380
|
}
|
|
379
381
|
rotateVertical(angle, center, minSlope = 0) {
|
|
@@ -398,6 +400,7 @@ class PlanetCamera extends Camera {
|
|
|
398
400
|
this._u = u;
|
|
399
401
|
this._r = r;
|
|
400
402
|
this._b = b;
|
|
403
|
+
this._f.set(-b.x, -b.y, -b.z);
|
|
401
404
|
}
|
|
402
405
|
}
|
|
403
406
|
else {
|
|
@@ -405,6 +408,7 @@ class PlanetCamera extends Camera {
|
|
|
405
408
|
this._u = u;
|
|
406
409
|
this._r = r;
|
|
407
410
|
this._b = b;
|
|
411
|
+
this._f.set(-b.x, -b.y, -b.z);
|
|
408
412
|
}
|
|
409
413
|
}
|
|
410
414
|
/**
|
|
@@ -421,6 +425,7 @@ class PlanetCamera extends Camera {
|
|
|
421
425
|
this._r = this._framesArr[c].u;
|
|
422
426
|
this._u = this._framesArr[c].v;
|
|
423
427
|
this._b = this._framesArr[c].n;
|
|
428
|
+
this._f.set(-this._b.x, -this._b.y, -this._b.z);
|
|
424
429
|
if (this._frameCallback) {
|
|
425
430
|
this._frameCallback();
|
|
426
431
|
}
|
|
@@ -449,6 +454,9 @@ class PlanetCamera extends Camera {
|
|
|
449
454
|
let R = this.planet.ellipsoid.equatorialSize;
|
|
450
455
|
return R * Math.acos(R / (R + this._lonLat.height + d));
|
|
451
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* should be yje same as getYaw
|
|
459
|
+
*/
|
|
452
460
|
getHeading() {
|
|
453
461
|
let u = this.eye.getNormal();
|
|
454
462
|
let f = Vec3.proj_b_to_plane(this.slope >= 0.97 ? this.getUp() : this.getForward(), u).normalize(), n = Vec3.proj_b_to_plane(Vec3.NORTH, u).normalize();
|
|
@@ -462,5 +470,44 @@ class PlanetCamera extends Camera {
|
|
|
462
470
|
let e = this.eye.length();
|
|
463
471
|
return this.eye.distance(poi) < Math.sqrt(e * e - this.planet.ellipsoid.equatorialSizeSqr);
|
|
464
472
|
}
|
|
473
|
+
getPitch() {
|
|
474
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
475
|
+
return qFrame.conjugate().inverse().mul(this.getRotation()).getPitch();
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* should be the same as getHeading
|
|
479
|
+
*/
|
|
480
|
+
getYaw() {
|
|
481
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
482
|
+
return qFrame.conjugate().inverse().mul(this.getRotation()).getYaw();
|
|
483
|
+
}
|
|
484
|
+
getRoll() {
|
|
485
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
486
|
+
return qFrame.conjugate().inverse().mul(this.getRotation()).getRoll();
|
|
487
|
+
}
|
|
488
|
+
setPitch(a) {
|
|
489
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
490
|
+
let qRot = new Quat();
|
|
491
|
+
qRot.setPitchYawRoll(a, this.getYaw(), this.getRoll(), qFrame);
|
|
492
|
+
this.setRotation(qRot);
|
|
493
|
+
}
|
|
494
|
+
setYaw(a) {
|
|
495
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
496
|
+
let qRot = new Quat();
|
|
497
|
+
qRot.setPitchYawRoll(this.getYaw(), a, this.getRoll(), qFrame);
|
|
498
|
+
this.setRotation(qRot);
|
|
499
|
+
}
|
|
500
|
+
setRoll(a) {
|
|
501
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
502
|
+
let qRot = new Quat();
|
|
503
|
+
qRot.setPitchYawRoll(this.getPitch(), this.getYaw(), a, qFrame);
|
|
504
|
+
this.setRotation(qRot);
|
|
505
|
+
}
|
|
506
|
+
setPitchYawRoll(pitch, yaw, roll) {
|
|
507
|
+
let qFrame = this.planet.getFrameRotation(this.eye);
|
|
508
|
+
let qRot = new Quat();
|
|
509
|
+
qRot.setPitchYawRoll(pitch, yaw, roll, qFrame).conjugate();
|
|
510
|
+
this.setRotation(qRot);
|
|
511
|
+
}
|
|
465
512
|
}
|
|
466
513
|
export { PlanetCamera };
|
|
@@ -94,18 +94,22 @@ export class Atmosphere extends Control {
|
|
|
94
94
|
width: width,
|
|
95
95
|
height: height,
|
|
96
96
|
useDepth: false,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
targets: [{
|
|
98
|
+
filter: "LINEAR",
|
|
99
|
+
type: "FLOAT",
|
|
100
|
+
internalFormat: "RGBA16F"
|
|
101
|
+
}]
|
|
100
102
|
});
|
|
101
103
|
this._transmittanceBuffer.init();
|
|
102
104
|
this._scatteringBuffer = new Framebuffer(this.renderer.handler, {
|
|
103
105
|
width: width,
|
|
104
106
|
height: height,
|
|
105
107
|
useDepth: false,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
targets: [{
|
|
109
|
+
filter: "LINEAR",
|
|
110
|
+
type: "FLOAT",
|
|
111
|
+
internalFormat: "RGBA16F"
|
|
112
|
+
}]
|
|
109
113
|
});
|
|
110
114
|
this._scatteringBuffer.init();
|
|
111
115
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Control, IControlParams } from "./Control";
|
|
2
|
+
import { LonLat } from "../LonLat";
|
|
3
|
+
import { Vec3 } from "../math/Vec3";
|
|
4
|
+
import { EventsHandler } from "../Events";
|
|
5
|
+
import { Entity } from "../entity/Entity";
|
|
6
|
+
import { IMouseState } from "../renderer/RendererEvents";
|
|
7
|
+
import { Planet } from "../scene/Planet";
|
|
8
|
+
type CameraLockEventsList = ["lockview", "unlockview"];
|
|
9
|
+
interface ICameraLockParams extends IControlParams {
|
|
10
|
+
planet?: Planet | null;
|
|
11
|
+
}
|
|
12
|
+
export declare class CameraLock extends Control {
|
|
13
|
+
events: EventsHandler<CameraLockEventsList>;
|
|
14
|
+
protected _lockDistance: number;
|
|
15
|
+
protected _isFromTheBack: boolean;
|
|
16
|
+
protected _lockEntity: Entity | null;
|
|
17
|
+
protected _viewDir: Vec3;
|
|
18
|
+
constructor(options?: ICameraLockParams);
|
|
19
|
+
onactivate(): void;
|
|
20
|
+
ondeactivate(): void;
|
|
21
|
+
oninit(): void;
|
|
22
|
+
flyCartesian(cartesian: Vec3, dist?: number): void;
|
|
23
|
+
lockView(entity: Entity, fromTheBack?: boolean): void;
|
|
24
|
+
protected _activateNav(): void;
|
|
25
|
+
protected _deactivateNav(): void;
|
|
26
|
+
unlockView(): void;
|
|
27
|
+
private _getCenterDist;
|
|
28
|
+
protected _getDistance(entity: Entity, prevEntity?: Entity | null): number;
|
|
29
|
+
isVisibleDistance(cart: Vec3, C?: number): boolean;
|
|
30
|
+
get lockEntity(): Entity | null;
|
|
31
|
+
flyLonLat(lonLat: LonLat, dist?: number): void;
|
|
32
|
+
protected _activateLockViewEvents(): void;
|
|
33
|
+
protected _deactivateLockViewEvents(): void;
|
|
34
|
+
private _onLockViewDraw;
|
|
35
|
+
protected _onMouseWheel: (e: IMouseState) => void;
|
|
36
|
+
protected _onMouseMove: (ms: IMouseState) => void;
|
|
37
|
+
}
|
|
38
|
+
export {};
|