@openglobus/og 0.15.3 → 0.15.5

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.
Files changed (71) hide show
  1. package/README.md +3 -7
  2. package/css/og.css +24 -15
  3. package/dist/@openglobus/og.css +1 -1
  4. package/dist/@openglobus/og.esm.js +2 -2
  5. package/dist/@openglobus/og.esm.js.map +1 -1
  6. package/dist/@openglobus/og.umd.js +2 -2
  7. package/dist/@openglobus/og.umd.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/og/Globe.js +4 -0
  10. package/src/og/LonLat.js +207 -193
  11. package/src/og/Object3d.js +1 -1
  12. package/src/og/camera/Camera.js +4 -16
  13. package/src/og/camera/PlanetCamera.js +12 -6
  14. package/src/og/control/DebugInfo.js +263 -165
  15. package/src/og/control/KeyboardNavigation.js +153 -169
  16. package/src/og/control/MouseNavigation.js +0 -20
  17. package/src/og/control/RulerSwitcher.js +4 -1
  18. package/src/og/control/SimpleNavigation.js +123 -128
  19. package/src/og/control/heightRuler/HeightRuler.js +12 -0
  20. package/src/og/control/heightRuler/HeightRulerScene.js +224 -0
  21. package/src/og/control/heightRuler/HeightRulerSwitcher.js +15 -0
  22. package/src/og/control/index.js +2 -0
  23. package/src/og/control/ruler/RulerScene.js +106 -79
  24. package/src/og/ellipsoid/Ellipsoid.js +20 -3
  25. package/src/og/entity/Entity.js +6 -6
  26. package/src/og/entity/EntityCollection.js +4 -0
  27. package/src/og/entity/GeoObjectHandler.js +3 -0
  28. package/src/og/layer/BaseGeoImage.js +152 -16
  29. package/src/og/layer/GeoImage.js +0 -91
  30. package/src/og/layer/GeoTexture2d.js +54 -143
  31. package/src/og/layer/GeoVideo.js +6 -107
  32. package/src/og/layer/Material.js +1 -1
  33. package/src/og/layer/Vector.js +8 -6
  34. package/src/og/layer/XYZ.js +2 -2
  35. package/src/og/quadTree/EntityCollectionNode.js +8 -2
  36. package/src/og/renderer/Renderer.js +91 -94
  37. package/src/og/renderer/RendererEvents.js +39 -23
  38. package/src/og/scene/BaseNode.js +113 -113
  39. package/src/og/scene/Planet.js +20 -13
  40. package/src/og/scene/RenderNode.js +42 -9
  41. package/src/og/segment/Segment.js +38 -45
  42. package/src/og/shaders/geoObject.js +12 -10
  43. package/src/og/shaders/pickingMask.js +1 -1
  44. package/src/og/utils/GeoImageCreator.js +61 -21
  45. package/src/og/utils/VectorTileCreator.js +32 -49
  46. package/src/og/webgl/Framebuffer.js +5 -0
  47. package/types/LonLat.d.ts +8 -0
  48. package/types/camera/PlanetCamera.d.ts +1 -1
  49. package/types/control/DebugInfo.d.ts +4 -0
  50. package/types/control/SimpleNavigation.d.ts +1 -0
  51. package/types/control/heightRuler/HeightRuler.d.ts +6 -0
  52. package/types/control/heightRuler/HeightRulerScene.d.ts +23 -0
  53. package/types/control/index.d.ts +2 -1
  54. package/types/control/ruler/RulerScene.d.ts +8 -5
  55. package/types/control/selection/SelectionScene.d.ts +0 -1
  56. package/types/ellipsoid/Ellipsoid.d.ts +13 -1
  57. package/types/entity/EntityCollection.d.ts +1 -0
  58. package/types/layer/BaseGeoImage.d.ts +17 -3
  59. package/types/layer/GeoImage.d.ts +0 -8
  60. package/types/layer/GeoTexture2d.d.ts +0 -2
  61. package/types/layer/GeoVideo.d.ts +0 -8
  62. package/types/layer/XYZ.d.ts +1 -1
  63. package/types/renderer/Renderer.d.ts +12 -3
  64. package/types/scene/Axes.d.ts +1 -1
  65. package/types/scene/BaseNode.d.ts +2 -2
  66. package/types/scene/Planet.d.ts +0 -5
  67. package/types/scene/RenderNode.d.ts +16 -9
  68. package/types/scene/SkyBox.d.ts +1 -1
  69. package/types/segment/Segment.d.ts +2 -3
  70. package/types/utils/VectorTileCreator.d.ts +1 -3
  71. package/types/webgl/Framebuffer.d.ts +1 -0
@@ -1,169 +1,153 @@
1
- /**
2
- * @module og/control/KeyboardNavigation
3
- */
4
-
5
- "use strict";
6
-
7
- import { input } from "../input/input.js";
8
- import * as math from "../math.js";
9
- import { Vec3 } from "../math/Vec3.js";
10
- import { Control } from "./Control.js";
11
-
12
- /**
13
- * Planet camera keyboard navigation. Use W,S,A,D and left shift key for fly around a planet.
14
- * @class
15
- * @extends {Control}
16
- * @param {Object} [options] - Control options.
17
- */
18
-
19
- class KeyboardNavigation extends Control {
20
- constructor(options) {
21
- options = options || {};
22
- super(options);
23
- this.step = options.step || 250;
24
- }
25
-
26
- oninit() {
27
- this.renderer.events.on("keypress", input.KEY_PGUP, this.onCameraMoveForward, this);
28
- this.renderer.events.on("keypress", input.KEY_PGDN, this.onCameraMoveBackward, this);
29
- this.renderer.events.on("keypress", input.KEY_PLUS, this.onCameraMoveForward, this);
30
- this.renderer.events.on("keypress", input.KEY_EQUALS, this.onCameraMoveForward, this);
31
- this.renderer.events.on("keypress", input.KEY_MINUS, this.onCameraMoveBackward, this);
32
- this.renderer.events.on("keypress", input.KEY_W, this.onCameraMoveForward, this);
33
- this.renderer.events.on("keypress", input.KEY_S, this.onCameraMoveBackward, this);
34
- this.renderer.events.on("keypress", input.KEY_A, this.onCameraStrifeLeft, this);
35
- this.renderer.events.on("keypress", input.KEY_D, this.onCameraStrifeRight, this);
36
- this.renderer.events.on("keypress", input.KEY_UP, this.onCameraLookUp, this);
37
- this.renderer.events.on("keypress", input.KEY_DOWN, this.onCameraLookDown, this);
38
- this.renderer.events.on("keypress", input.KEY_LEFT, this.onCameraLookLeft, this);
39
- this.renderer.events.on("keypress", input.KEY_RIGHT, this.onCameraLookRight, this);
40
- this.renderer.events.on("keypress", input.KEY_Q, this.onCameraRollLeft, this);
41
- this.renderer.events.on("keypress", input.KEY_E, this.onCameraRollRight, this);
42
- this.renderer.events.on("keypress", input.KEY_N, this.onCameraRollNorth, this);
43
- }
44
-
45
- onCameraMoveForward(event) {
46
- var cam = this.renderer.activeCamera;
47
- cam.slide(0, 0, -cam._lonLat.height / this.step);
48
- cam.checkTerrainCollision();
49
- cam.update();
50
- }
51
-
52
- onCameraMoveBackward(event) {
53
- var cam = this.renderer.activeCamera;
54
- cam.slide(0, 0, cam._lonLat.height / this.step);
55
- cam.checkTerrainCollision();
56
- cam.update();
57
- }
58
-
59
- onCameraStrifeLeft(event) {
60
- var cam = this.renderer.activeCamera;
61
- cam.slide(-cam._lonLat.height / this.step, 0, 0);
62
- cam.checkTerrainCollision();
63
- cam.update();
64
- }
65
-
66
- onCameraStrifeRight(event) {
67
- var cam = this.renderer.activeCamera;
68
- cam.slide(cam._lonLat.height / this.step, 0, 0);
69
- cam.checkTerrainCollision();
70
- cam.update();
71
- }
72
-
73
- onCameraLookUp(event) {
74
- var cam = this.renderer.activeCamera;
75
- if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
76
- cam.pitch(15 / this.renderer.handler.deltaTime);
77
- } else {
78
- cam.rotateVertical((cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
79
- }
80
- cam.update();
81
- }
82
-
83
- onCameraLookDown(event) {
84
- var cam = this.renderer.activeCamera;
85
- if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
86
- cam.pitch(-15 / this.renderer.handler.deltaTime);
87
- } else {
88
- cam.rotateVertical((-cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
89
- }
90
- cam.update();
91
- }
92
-
93
- onCameraLookLeft(event) {
94
- var cam = this.renderer.activeCamera;
95
- if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
96
- cam.roll(15 / this.renderer.handler.deltaTime);
97
- } else {
98
- cam.rotateHorizontal((cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
99
- }
100
- cam.update();
101
- }
102
-
103
- onCameraLookRight(event) {
104
- var cam = this.renderer.activeCamera;
105
- if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
106
- cam.roll(-15 / this.renderer.handler.deltaTime);
107
- } else {
108
- cam.rotateHorizontal((-cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
109
- }
110
- cam.update();
111
- }
112
-
113
- onCameraTurnLeft(event) {
114
- var cam = this.renderer.activeCamera;
115
- if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
116
- cam.yaw(15 / this.renderer.handler.deltaTime);
117
- } else {
118
- cam.rotateHorizontal((cam._lonLat.height / 3000000) * math.RADIANS, false, Vec3.ZERO);
119
- }
120
- cam.update();
121
- }
122
-
123
- onCameraTurnRight(event) {
124
- var cam = this.renderer.activeCamera;
125
- if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
126
- cam.yaw(-15 / this.renderer.handler.deltaTime);
127
- } else {
128
- cam.rotateHorizontal((-cam._lonLat.height / 3000000) * math.RADIANS, false, Vec3.ZERO);
129
- }
130
- cam.update();
131
- }
132
-
133
- // from CompassButton._onClick()
134
- onCameraRollNorth(event) {
135
- let c = this.planet.getCartesianFromPixelTerrain(this.renderer.handler.getCenter());
136
- if (c) {
137
- this.planet.flyCartesian(
138
- c.normal().scaleTo(c.length() + c.distance(this.planet.camera.eye)),
139
- null,
140
- null,
141
- 0,
142
- null,
143
- null,
144
- () => {
145
- this.planet.camera.look(c);
146
- }
147
- );
148
- } else {
149
- this.planet.flyCartesian(this.planet.camera.eye);
150
- }
151
- }
152
-
153
- onCameraRollLeft(event) {
154
- this.renderer.activeCamera.roll(-15 / this.renderer.handler.deltaTime);
155
- this.renderer.activeCamera.update();
156
- }
157
-
158
- onCameraRollRight(event) {
159
- this.renderer.activeCamera.roll(15 / this.renderer.handler.deltaTime);
160
- this.renderer.activeCamera.update();
161
- }
162
- }
163
-
164
- export function keyboardNavigation(options) {
165
- return new KeyboardNavigation(options);
166
- }
167
-
168
- export { KeyboardNavigation };
169
-
1
+ /**
2
+ * @module og/control/KeyboardNavigation
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { input } from "../input/input.js";
8
+ import * as math from "../math.js";
9
+ import { Vec3 } from "../math/Vec3.js";
10
+ import { Control } from "./Control.js";
11
+
12
+ /**
13
+ * Planet camera keyboard navigation. Use W,S,A,D and left shift key for fly around a planet.
14
+ * @class
15
+ * @extends {Control}
16
+ * @param {Object} [options] - Control options.
17
+ */
18
+
19
+ class KeyboardNavigation extends Control {
20
+ constructor(options) {
21
+ options = options || {};
22
+ super(options);
23
+ this.step = options.step || 250;
24
+ }
25
+
26
+ oninit() {
27
+ this.renderer.events.on("keypress", input.KEY_PGUP, this.onCameraMoveForward, this);
28
+ this.renderer.events.on("keypress", input.KEY_PGDN, this.onCameraMoveBackward, this);
29
+ this.renderer.events.on("keypress", input.KEY_PLUS, this.onCameraMoveForward, this);
30
+ this.renderer.events.on("keypress", input.KEY_EQUALS, this.onCameraMoveForward, this);
31
+ this.renderer.events.on("keypress", input.KEY_MINUS, this.onCameraMoveBackward, this);
32
+ this.renderer.events.on("keypress", input.KEY_W, this.onCameraMoveForward, this);
33
+ this.renderer.events.on("keypress", input.KEY_S, this.onCameraMoveBackward, this);
34
+ this.renderer.events.on("keypress", input.KEY_A, this.onCameraStrifeLeft, this);
35
+ this.renderer.events.on("keypress", input.KEY_D, this.onCameraStrifeRight, this);
36
+ this.renderer.events.on("keypress", input.KEY_UP, this.onCameraLookUp, this);
37
+ this.renderer.events.on("keypress", input.KEY_DOWN, this.onCameraLookDown, this);
38
+ this.renderer.events.on("keypress", input.KEY_LEFT, this.onCameraLookLeft, this);
39
+ this.renderer.events.on("keypress", input.KEY_RIGHT, this.onCameraLookRight, this);
40
+ this.renderer.events.on("keypress", input.KEY_Q, this.onCameraRollLeft, this);
41
+ this.renderer.events.on("keypress", input.KEY_E, this.onCameraRollRight, this);
42
+ this.renderer.events.on("keypress", input.KEY_N, this.onCameraRollNorth, this);
43
+ }
44
+
45
+ onCameraMoveForward(event) {
46
+ var cam = this.renderer.activeCamera;
47
+ cam.slide(0, 0, -cam._lonLat.height / this.step);
48
+ }
49
+
50
+ onCameraMoveBackward(event) {
51
+ var cam = this.renderer.activeCamera;
52
+ cam.slide(0, 0, cam._lonLat.height / this.step);
53
+ }
54
+
55
+ onCameraStrifeLeft(event) {
56
+ var cam = this.renderer.activeCamera;
57
+ cam.slide(-cam._lonLat.height / this.step, 0, 0);
58
+ }
59
+
60
+ onCameraStrifeRight(event) {
61
+ var cam = this.renderer.activeCamera;
62
+ cam.slide(cam._lonLat.height / this.step, 0, 0);
63
+ }
64
+
65
+ onCameraLookUp(event) {
66
+ var cam = this.renderer.activeCamera;
67
+ if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
68
+ cam.pitch(15 / this.renderer.handler.deltaTime);
69
+ } else {
70
+ cam.rotateVertical((cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
71
+ }
72
+ }
73
+
74
+ onCameraLookDown(event) {
75
+ var cam = this.renderer.activeCamera;
76
+ if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
77
+ cam.pitch(-15 / this.renderer.handler.deltaTime);
78
+ } else {
79
+ cam.rotateVertical((-cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
80
+ }
81
+ }
82
+
83
+ onCameraLookLeft(event) {
84
+ var cam = this.renderer.activeCamera;
85
+ if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
86
+ cam.roll(15 / this.renderer.handler.deltaTime);
87
+ } else {
88
+ cam.rotateHorizontal((cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
89
+ }
90
+ }
91
+
92
+ onCameraLookRight(event) {
93
+ var cam = this.renderer.activeCamera;
94
+ if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
95
+ cam.roll(-15 / this.renderer.handler.deltaTime);
96
+ } else {
97
+ cam.rotateHorizontal((-cam._lonLat.height / 3000000) * math.RADIANS, Vec3.ZERO);
98
+ }
99
+ }
100
+
101
+ onCameraTurnLeft(event) {
102
+ var cam = this.renderer.activeCamera;
103
+ if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
104
+ cam.yaw(15 / this.renderer.handler.deltaTime);
105
+ } else {
106
+ cam.rotateHorizontal((cam._lonLat.height / 3000000) * math.RADIANS, false, Vec3.ZERO);
107
+ }
108
+ }
109
+
110
+ onCameraTurnRight(event) {
111
+ var cam = this.renderer.activeCamera;
112
+ if (this.renderer.events.isKeyPressed(input.KEY_SHIFT)) {
113
+ cam.yaw(-15 / this.renderer.handler.deltaTime);
114
+ } else {
115
+ cam.rotateHorizontal((-cam._lonLat.height / 3000000) * math.RADIANS, false, Vec3.ZERO);
116
+ }
117
+ }
118
+
119
+ // from CompassButton._onClick()
120
+ onCameraRollNorth(event) {
121
+ let c = this.planet.getCartesianFromPixelTerrain(this.renderer.handler.getCenter());
122
+ if (c) {
123
+ this.planet.flyCartesian(
124
+ c.normal().scaleTo(c.length() + c.distance(this.planet.camera.eye)),
125
+ null,
126
+ null,
127
+ 0,
128
+ null,
129
+ null,
130
+ () => {
131
+ this.planet.camera.look(c);
132
+ }
133
+ );
134
+ } else {
135
+ this.planet.flyCartesian(this.planet.camera.eye);
136
+ }
137
+ }
138
+
139
+ onCameraRollLeft(event) {
140
+ this.renderer.activeCamera.roll(-15 / this.renderer.handler.deltaTime);
141
+ }
142
+
143
+ onCameraRollRight(event) {
144
+ this.renderer.activeCamera.roll(15 / this.renderer.handler.deltaTime);
145
+ }
146
+ }
147
+
148
+ export function keyboardNavigation(options) {
149
+ return new KeyboardNavigation(options);
150
+ }
151
+
152
+ export { KeyboardNavigation };
153
+
@@ -319,10 +319,6 @@ class MouseNavigation extends Control {
319
319
  cam._u = rot.mulVec3(cam._u);
320
320
  cam._r = rot.mulVec3(cam._r);
321
321
  cam._b = rot.mulVec3(cam._b);
322
-
323
- cam.checkTerrainCollision();
324
-
325
- cam.update();
326
322
  }
327
323
  } else {
328
324
  var p0 = this.grabbedPoint,
@@ -332,10 +328,6 @@ class MouseNavigation extends Control {
332
328
  var px = new Vec3();
333
329
  if (new Ray(cam.eye, e.direction).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
334
330
  cam.eye = this._eye0.addA(px.subA(p0).negate());
335
-
336
- cam.checkTerrainCollision();
337
-
338
- cam.update();
339
331
  }
340
332
  }
341
333
  }
@@ -361,10 +353,6 @@ class MouseNavigation extends Control {
361
353
  cam.rotateHorizontal(l * (e.x - e.prev_x), false, this.pointOnEarth, this.earthUp);
362
354
 
363
355
  cam.rotateVertical(l * (e.y - e.prev_y), this.pointOnEarth, this.minSlope);
364
-
365
- cam.checkTerrainCollision();
366
-
367
- cam.update();
368
356
  }
369
357
  }
370
358
 
@@ -405,10 +393,6 @@ class MouseNavigation extends Control {
405
393
  cam._u = sf.v;
406
394
  cam._r = sf.u;
407
395
  cam._b = sf.n;
408
-
409
- cam.checkTerrainCollision();
410
-
411
- cam.update();
412
396
  } else {
413
397
  if (this._deactivate) {
414
398
  this._deactivate = false;
@@ -438,10 +422,6 @@ class MouseNavigation extends Control {
438
422
  cam._u = rot.mulVec3(cam._u);
439
423
  cam._r = rot.mulVec3(cam._r);
440
424
  cam._b = rot.mulVec3(cam._b);
441
-
442
- cam.checkTerrainCollision();
443
-
444
- cam.update();
445
425
  }
446
426
 
447
427
  if (cam.eye.distance(prevEye) / cam._terrainAltitude > 0.01) {
@@ -32,7 +32,10 @@ const ICON_BUTTON_SVG = `<?xml version="1.0" encoding="iso-8859-1"?>
32
32
  */
33
33
  class RulerSwitcher extends Control {
34
34
  constructor(options = {}) {
35
- super(options);
35
+ super({
36
+ name: "RulerSwitcher",
37
+ ...options
38
+ });
36
39
 
37
40
  this.ruler = new Ruler({
38
41
  ignoreTerrain: options.ignoreTerrain
@@ -1,128 +1,123 @@
1
- "use strict";
2
-
3
- import { input } from "../input/input.js";
4
- import { Control } from "./Control.js";
5
-
6
- /**
7
- * Simple keyboard camera navigation with W,S,A,D and shift keys to fly around the scene.
8
- * @class
9
- * @extends {Control}
10
- * @param {Object} [options] - Control options.
11
- */
12
- class SimpleNavigation extends Control {
13
- constructor(options) {
14
- options = options || {};
15
- super(options);
16
-
17
- this.camera = null;
18
- this.speed = options.speed || 1.0;
19
- }
20
-
21
- onactivate() {}
22
-
23
- ondeactivate() {}
24
-
25
- oninit() {
26
- this.camera = this.renderer.activeCamera;
27
- this.renderer.events.on("keypress", input.KEY_W, this.onCameraMoveForward, this);
28
- this.renderer.events.on("keypress", input.KEY_S, this.onCameraMoveBackward, this);
29
- this.renderer.events.on("keypress", input.KEY_A, this.onCameraStrifeLeft, this);
30
- this.renderer.events.on("keypress", input.KEY_D, this.onCameraStrifeRight, this);
31
- this.renderer.events.on("keypress", input.KEY_UP, this.onCameraLookUp, this);
32
- this.renderer.events.on("keypress", input.KEY_DOWN, this.onCameraLookDown, this);
33
- this.renderer.events.on("keypress", input.KEY_LEFT, this.onCameraTurnLeft, this);
34
- this.renderer.events.on("keypress", input.KEY_RIGHT, this.onCameraTurnRight, this);
35
- this.renderer.events.on("keypress", input.KEY_Q, this.onCameraRollLeft, this);
36
- this.renderer.events.on("keypress", input.KEY_E, this.onCameraRollRight, this);
37
- }
38
-
39
- onCameraMoveForward() {
40
- if (this._active) {
41
- var camera = this.camera;
42
- camera.slide(0, 0, -this.speed);
43
- camera.update();
44
- }
45
- }
46
-
47
- onCameraMoveBackward() {
48
- if (this._active) {
49
- var camera = this.camera;
50
- camera.slide(0, 0, this.speed);
51
- camera.update();
52
- }
53
- }
54
-
55
- onCameraStrifeLeft() {
56
- if (this._active) {
57
- var camera = this.camera;
58
- camera.slide(-this.speed, 0, 0);
59
- camera.update();
60
- }
61
- }
62
-
63
- onCameraStrifeRight() {
64
- if (this._active) {
65
- var camera = this.camera;
66
- camera.slide(this.speed, 0, 0);
67
- camera.update();
68
- }
69
- }
70
-
71
- onCameraLookUp() {
72
- if (this._active) {
73
- var cam = this.camera;
74
- cam.pitch(0.5);
75
- cam.update();
76
- }
77
- }
78
-
79
- onCameraLookDown() {
80
- if (this._active) {
81
- var cam = this.camera;
82
- cam.pitch(-0.5);
83
- cam.update();
84
- }
85
- }
86
-
87
- onCameraTurnLeft() {
88
- if (this._active) {
89
- var cam = this.camera;
90
- cam.yaw(0.5);
91
- cam.update();
92
- }
93
- }
94
-
95
- onCameraTurnRight() {
96
- if (this._active) {
97
- var cam = this.camera;
98
- cam.yaw(-0.5);
99
- cam.update();
100
- }
101
- }
102
-
103
- onCameraRollLeft() {
104
- if (this._active) {
105
- var cam = this.camera;
106
- cam.roll(-0.5);
107
- cam.update();
108
- }
109
- }
110
-
111
- onCameraRollRight() {
112
- if (this._active) {
113
- var cam = this.camera;
114
- cam.roll(0.5);
115
- cam.update();
116
- }
117
- }
118
- }
119
-
120
- /**
121
- * Creates simple navigation control instance.
122
- */
123
- export function simpleNavigation(options) {
124
- return new SimpleNavigation(options);
125
- }
126
-
127
- export { SimpleNavigation };
128
-
1
+ "use strict";
2
+
3
+ import { input } from "../input/input.js";
4
+ import { Control } from "./Control.js";
5
+
6
+ /**
7
+ * Simple keyboard camera navigation with W,S,A,D and shift keys to fly around the scene.
8
+ * @class
9
+ * @extends {Control}
10
+ * @param {Object} [options] - Control options.
11
+ */
12
+ class SimpleNavigation extends Control {
13
+ constructor(options = {}) {
14
+ super({ autoActivate: true, ...options });
15
+
16
+ this.camera = null;
17
+ this.speed = options.speed || 1.0;
18
+ }
19
+
20
+ oninit() {
21
+ this.camera = this.renderer.activeCamera;
22
+ this.renderer.events.on("keypress", input.KEY_W, this.onCameraMoveForward, this);
23
+ this.renderer.events.on("keypress", input.KEY_S, this.onCameraMoveBackward, this);
24
+ this.renderer.events.on("keypress", input.KEY_A, this.onCameraStrifeLeft, this);
25
+ this.renderer.events.on("keypress", input.KEY_D, this.onCameraStrifeRight, this);
26
+ this.renderer.events.on("keypress", input.KEY_UP, this.onCameraLookUp, this);
27
+ this.renderer.events.on("keypress", input.KEY_DOWN, this.onCameraLookDown, this);
28
+ this.renderer.events.on("keypress", input.KEY_LEFT, this.onCameraTurnLeft, this);
29
+ this.renderer.events.on("keypress", input.KEY_RIGHT, this.onCameraTurnRight, this);
30
+ this.renderer.events.on("keypress", input.KEY_Q, this.onCameraRollLeft, this);
31
+ this.renderer.events.on("keypress", input.KEY_E, this.onCameraRollRight, this);
32
+ }
33
+
34
+ onCameraMoveForward() {
35
+ if (this._active) {
36
+ var camera = this.camera;
37
+ camera.slide(0, 0, -this.speed);
38
+ //camera.update();
39
+ }
40
+ }
41
+
42
+ onCameraMoveBackward() {
43
+ if (this._active) {
44
+ var camera = this.camera;
45
+ camera.slide(0, 0, this.speed);
46
+ //camera.update();
47
+ }
48
+ }
49
+
50
+ onCameraStrifeLeft() {
51
+ if (this._active) {
52
+ var camera = this.camera;
53
+ camera.slide(-this.speed, 0, 0);
54
+ //camera.update();
55
+ }
56
+ }
57
+
58
+ onCameraStrifeRight() {
59
+ if (this._active) {
60
+ var camera = this.camera;
61
+ camera.slide(this.speed, 0, 0);
62
+ //camera.update();
63
+ }
64
+ }
65
+
66
+ onCameraLookUp() {
67
+ if (this._active) {
68
+ var cam = this.camera;
69
+ cam.pitch(0.5);
70
+ //cam.update();
71
+ }
72
+ }
73
+
74
+ onCameraLookDown() {
75
+ if (this._active) {
76
+ var cam = this.camera;
77
+ cam.pitch(-0.5);
78
+ //cam.update();
79
+ }
80
+ }
81
+
82
+ onCameraTurnLeft() {
83
+ if (this._active) {
84
+ var cam = this.camera;
85
+ cam.yaw(0.5);
86
+ //cam.update();
87
+ }
88
+ }
89
+
90
+ onCameraTurnRight() {
91
+ if (this._active) {
92
+ var cam = this.camera;
93
+ cam.yaw(-0.5);
94
+ //cam.update();
95
+ }
96
+ }
97
+
98
+ onCameraRollLeft() {
99
+ if (this._active) {
100
+ var cam = this.camera;
101
+ cam.roll(-0.5);
102
+ //cam.update();
103
+ }
104
+ }
105
+
106
+ onCameraRollRight() {
107
+ if (this._active) {
108
+ var cam = this.camera;
109
+ cam.roll(0.5);
110
+ //cam.update();
111
+ }
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Creates simple navigation control instance.
117
+ */
118
+ export function simpleNavigation(options) {
119
+ return new SimpleNavigation(options);
120
+ }
121
+
122
+ export { SimpleNavigation };
123
+
@@ -0,0 +1,12 @@
1
+ import { Ruler } from "../ruler/Ruler.js";
2
+ import { HeightRulerScene } from "./HeightRulerScene.js";
3
+
4
+ export class HeightRuler extends Ruler {
5
+ constructor(options) {
6
+ super({ ...options });
7
+ this._rulerScene = new HeightRulerScene({
8
+ name: `heightRulerScene:${this._id}`,
9
+ ignoreTerrain: false
10
+ });
11
+ }
12
+ }