@openglobus/og 0.13.5 → 0.13.8
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 +66 -25
- 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 +1 -1
- package/src/og/Events.js +188 -188
- package/src/og/Extent.js +1 -9
- package/src/og/Globe.js +1 -0
- package/src/og/Object3d.js +384 -0
- package/src/og/arial.js +1705 -1703
- package/src/og/camera/Camera.js +640 -640
- package/src/og/control/DebugInfo.js +15 -4
- package/src/og/control/EarthCoordinates.js +151 -160
- package/src/og/control/KeyboardNavigation.js +48 -2
- package/src/og/control/LayerAnimation.js +115 -0
- package/src/og/control/MouseNavigation.js +460 -460
- package/src/og/control/Sun.js +170 -170
- package/src/og/control/TouchNavigation.js +13 -13
- package/src/og/control/ZoomControl.js +1 -3
- package/src/og/control/index.js +3 -1
- package/src/og/control/ruler/Ruler.js +43 -0
- package/src/og/control/ruler/RulerScene.js +370 -0
- package/src/og/control/visibleExtent/Segment.js +1 -4
- package/src/og/ellipsoid/Ellipsoid.js +20 -1
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/GeoObject.js +1 -1
- package/src/og/entity/LabelHandler.js +3 -2
- package/src/og/input/input.js +7 -1
- package/src/og/layer/CanvasTiles.js +8 -8
- package/src/og/layer/KML.js +181 -12
- package/src/og/layer/Layer.js +27 -42
- package/src/og/layer/Vector.js +80 -14
- package/src/og/layer/XYZ.js +8 -2
- package/src/og/math/Vec3.js +1 -1
- package/src/og/math.js +4 -4
- package/src/og/quadTree/Node.js +2 -1
- package/src/og/renderer/Renderer.js +1 -2
- package/src/og/renderer/RendererEvents.js +17 -3
- package/src/og/res/images.js +0 -2
- package/src/og/scene/Planet.js +92 -32
- package/src/og/segment/Segment.js +1 -8
- package/src/og/shaders/label.js +30 -42
- package/src/og/terrain/EmptyTerrain.js +164 -146
- package/src/og/terrain/Geoid.js +246 -241
- package/src/og/terrain/GlobusTerrain.js +23 -24
- package/src/og/terrain/MapboxTerrain.js +292 -294
- package/src/og/utils/FontAtlas.js +1 -2
- package/src/og/utils/Loader.js +160 -112
- package/src/og/utils/PlainSegmentWorker.js +38 -26
- package/src/og/utils/VectorTileCreator.js +1 -1
- package/src/og/utils/units.js +78 -0
- package/src/og/webgl/ProgramController.js +143 -143
- package/types/Object3d.d.ts +21 -0
- package/types/arial.d.ts +1 -0
- package/types/control/EarthCoordinates.d.ts +27 -30
- package/types/control/KeyboardNavigation.d.ts +3 -0
- package/types/control/Sun.d.ts +1 -1
- package/types/control/index.d.ts +2 -1
- package/types/control/ruler/Ruler.d.ts +13 -0
- package/types/control/ruler/RulerScene.d.ts +48 -0
- package/types/ellipsoid/Ellipsoid.d.ts +8 -0
- package/types/input/input.d.ts +6 -0
- package/types/layer/KML.d.ts +26 -1
- package/types/layer/Layer.d.ts +23 -31
- package/types/layer/Vector.d.ts +2 -0
- package/types/layer/XYZ.d.ts +1 -0
- package/types/math.d.ts +1 -1
- package/types/renderer/RendererEvents.d.ts +2 -0
- package/types/res/images.d.ts +0 -1
- package/types/scene/Planet.d.ts +12 -3
- package/types/terrain/EmptyTerrain.d.ts +4 -1
- package/types/terrain/Geoid.d.ts +1 -10
- package/types/terrain/GlobusTerrain.d.ts +0 -2
- package/types/terrain/MapboxTerrain.d.ts +1 -1
- package/types/utils/Loader.d.ts +4 -0
- package/types/utils/units.d.ts +20 -0
package/src/og/control/Sun.js
CHANGED
|
@@ -1,170 +1,170 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/control/Sun
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import { Control } from "./Control.js";
|
|
8
|
-
import { getSunPosition } from "../astro/earth.js";
|
|
9
|
-
import { LightSource } from "../light/LightSource.js";
|
|
10
|
-
import { Quat } from "../math/Quat.js";
|
|
11
|
-
import { Vec3 } from "../math/Vec3.js";
|
|
12
|
-
|
|
13
|
-
const ACTIVATION_HEIGHT = 12079000.0;
|
|
14
|
-
/**
|
|
15
|
-
* Real Sun geocentric position control that place the Sun on the right place by the Earth.
|
|
16
|
-
* @class
|
|
17
|
-
* @extends {Control}
|
|
18
|
-
* @param {Object} [options] - Control options.
|
|
19
|
-
*/
|
|
20
|
-
class Sun extends Control {
|
|
21
|
-
constructor(options) {
|
|
22
|
-
super(options);
|
|
23
|
-
|
|
24
|
-
this._name = "sun";
|
|
25
|
-
|
|
26
|
-
options = options || {};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Earth planet node.
|
|
30
|
-
* @public
|
|
31
|
-
* @type {Planet}
|
|
32
|
-
*/
|
|
33
|
-
this.planet = null;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Sunlight position placed in the camera eye.
|
|
37
|
-
* @private
|
|
38
|
-
* @type {boolean}
|
|
39
|
-
*/
|
|
40
|
-
// this._isCameraSunlight = false;
|
|
41
|
-
|
|
42
|
-
this.offsetVertical = options.offsetVertical || -5000000;
|
|
43
|
-
|
|
44
|
-
this.offsetHorizontal = options.offsetHorizontal || 5000000;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Light source.
|
|
48
|
-
* @public
|
|
49
|
-
* @type {LightSource}
|
|
50
|
-
*/
|
|
51
|
-
this.sunlight = null;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Current frame handler clock date and time.
|
|
55
|
-
* @private
|
|
56
|
-
* @type {Number}
|
|
57
|
-
*/
|
|
58
|
-
this._currDate = 0;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Previous frame handler clock date and time.
|
|
62
|
-
* @private
|
|
63
|
-
* @type {Number}
|
|
64
|
-
*/
|
|
65
|
-
this._prevDate = 0;
|
|
66
|
-
|
|
67
|
-
this._clockPtr = null;
|
|
68
|
-
|
|
69
|
-
this._lightOn = false;
|
|
70
|
-
|
|
71
|
-
this._stopped = options.stopped || false;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
oninit() {
|
|
75
|
-
this.planet.lightEnabled = true;
|
|
76
|
-
|
|
77
|
-
// sunlight initialization
|
|
78
|
-
this.sunlight = new LightSource("Sun", {
|
|
79
|
-
ambient: new Vec3(0.15, 0.15, 0.25),
|
|
80
|
-
diffuse: new Vec3(0.9, 0.9, 0.8),
|
|
81
|
-
specular: new Vec3(0.1, 0.1, 0.06),
|
|
82
|
-
shininess: 110
|
|
83
|
-
});
|
|
84
|
-
this.sunlight.addTo(this.planet);
|
|
85
|
-
|
|
86
|
-
this.renderer.events.on("draw", this._draw, this);
|
|
87
|
-
|
|
88
|
-
if (!this._clockPtr) {
|
|
89
|
-
this._clockPtr = this.renderer.handler.defaultClock;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
stop() {
|
|
94
|
-
this._stopped = true;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
onactivate() {
|
|
98
|
-
this._stopped = false;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
bindClock(clock) {
|
|
102
|
-
this._clockPtr = clock;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_draw() {
|
|
106
|
-
this._currDate = this._clockPtr.currentDate;
|
|
107
|
-
if (!this._stopped) {
|
|
108
|
-
var cam = this.renderer.activeCamera;
|
|
109
|
-
if (cam.getHeight() < ACTIVATION_HEIGHT || !this._active) {
|
|
110
|
-
this._lightOn = true;
|
|
111
|
-
this._f = 1;
|
|
112
|
-
var n = cam.eye.normal(),
|
|
113
|
-
u = cam.getForward();
|
|
114
|
-
|
|
115
|
-
u.scale(Math.sign(cam._u.dot(n))); // up
|
|
116
|
-
|
|
117
|
-
if (cam.slope > 0.99) {
|
|
118
|
-
u = cam._u;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
var tu = Vec3.proj_b_to_plane(u, n, u).normalize().scale(this.offsetVertical);
|
|
122
|
-
var tr = Vec3.proj_b_to_plane(cam._r, n, cam._r)
|
|
123
|
-
.normalize()
|
|
124
|
-
.scale(this.offsetHorizontal); // right
|
|
125
|
-
var d = tu.add(tr);
|
|
126
|
-
var pos = cam.eye.add(d);
|
|
127
|
-
if (this._k > 0) {
|
|
128
|
-
this._k -= 0.01;
|
|
129
|
-
let rot = Quat.getRotationBetweenVectors(
|
|
130
|
-
this.sunlight._position.normal(),
|
|
131
|
-
pos.normal()
|
|
132
|
-
);
|
|
133
|
-
let r = rot.slerp(Quat.IDENTITY, this._k).normalize();
|
|
134
|
-
this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
|
|
135
|
-
} else {
|
|
136
|
-
this.sunlight.setPosition3v(pos);
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
this._k = 1;
|
|
140
|
-
if (this._f > 0) {
|
|
141
|
-
this._f -= 0.01;
|
|
142
|
-
let rot = Quat.getRotationBetweenVectors(
|
|
143
|
-
this.sunlight._position.normal(),
|
|
144
|
-
getSunPosition(this._currDate).normal()
|
|
145
|
-
);
|
|
146
|
-
let r = rot.slerp(Quat.IDENTITY, this._f).normalize();
|
|
147
|
-
this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
|
|
148
|
-
} else {
|
|
149
|
-
if (
|
|
150
|
-
(Math.abs(this._currDate - this._prevDate) > 0.00034 && this._active) ||
|
|
151
|
-
this._lightOn
|
|
152
|
-
) {
|
|
153
|
-
this._lightOn = false;
|
|
154
|
-
this._prevDate = this._currDate;
|
|
155
|
-
this.sunlight.setPosition3v(getSunPosition(this._currDate));
|
|
156
|
-
this._f = 0;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
this.sunlight.setPosition3v(getSunPosition(this._currDate));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export function sun(options) {
|
|
167
|
-
return Sun(options);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export { Sun };
|
|
1
|
+
/**
|
|
2
|
+
* @module og/control/Sun
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { Control } from "./Control.js";
|
|
8
|
+
import { getSunPosition } from "../astro/earth.js";
|
|
9
|
+
import { LightSource } from "../light/LightSource.js";
|
|
10
|
+
import { Quat } from "../math/Quat.js";
|
|
11
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
12
|
+
|
|
13
|
+
const ACTIVATION_HEIGHT = 12079000.0;
|
|
14
|
+
/**
|
|
15
|
+
* Real Sun geocentric position control that place the Sun on the right place by the Earth.
|
|
16
|
+
* @class
|
|
17
|
+
* @extends {Control}
|
|
18
|
+
* @param {Object} [options] - Control options.
|
|
19
|
+
*/
|
|
20
|
+
class Sun extends Control {
|
|
21
|
+
constructor(options) {
|
|
22
|
+
super(options);
|
|
23
|
+
|
|
24
|
+
this._name = "sun";
|
|
25
|
+
|
|
26
|
+
options = options || {};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Earth planet node.
|
|
30
|
+
* @public
|
|
31
|
+
* @type {Planet}
|
|
32
|
+
*/
|
|
33
|
+
this.planet = null;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sunlight position placed in the camera eye.
|
|
37
|
+
* @private
|
|
38
|
+
* @type {boolean}
|
|
39
|
+
*/
|
|
40
|
+
// this._isCameraSunlight = false;
|
|
41
|
+
|
|
42
|
+
this.offsetVertical = options.offsetVertical || -5000000;
|
|
43
|
+
|
|
44
|
+
this.offsetHorizontal = options.offsetHorizontal || 5000000;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Light source.
|
|
48
|
+
* @public
|
|
49
|
+
* @type {LightSource}
|
|
50
|
+
*/
|
|
51
|
+
this.sunlight = null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Current frame handler clock date and time.
|
|
55
|
+
* @private
|
|
56
|
+
* @type {Number}
|
|
57
|
+
*/
|
|
58
|
+
this._currDate = 0;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Previous frame handler clock date and time.
|
|
62
|
+
* @private
|
|
63
|
+
* @type {Number}
|
|
64
|
+
*/
|
|
65
|
+
this._prevDate = 0;
|
|
66
|
+
|
|
67
|
+
this._clockPtr = null;
|
|
68
|
+
|
|
69
|
+
this._lightOn = false;
|
|
70
|
+
|
|
71
|
+
this._stopped = options.stopped || false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
oninit() {
|
|
75
|
+
this.planet.lightEnabled = true;
|
|
76
|
+
|
|
77
|
+
// sunlight initialization
|
|
78
|
+
this.sunlight = new LightSource("Sun", {
|
|
79
|
+
ambient: new Vec3(0.15, 0.15, 0.25),
|
|
80
|
+
diffuse: new Vec3(0.9, 0.9, 0.8),
|
|
81
|
+
specular: new Vec3(0.1, 0.1, 0.06),
|
|
82
|
+
shininess: 110
|
|
83
|
+
});
|
|
84
|
+
this.sunlight.addTo(this.planet);
|
|
85
|
+
|
|
86
|
+
this.renderer.events.on("draw", this._draw, this);
|
|
87
|
+
|
|
88
|
+
if (!this._clockPtr) {
|
|
89
|
+
this._clockPtr = this.renderer.handler.defaultClock;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
stop() {
|
|
94
|
+
this._stopped = true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
onactivate() {
|
|
98
|
+
this._stopped = false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
bindClock(clock) {
|
|
102
|
+
this._clockPtr = clock;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_draw() {
|
|
106
|
+
this._currDate = this._clockPtr.currentDate;
|
|
107
|
+
if (!this._stopped) {
|
|
108
|
+
var cam = this.renderer.activeCamera;
|
|
109
|
+
if (cam.getHeight() < ACTIVATION_HEIGHT || !this._active) {
|
|
110
|
+
this._lightOn = true;
|
|
111
|
+
this._f = 1;
|
|
112
|
+
var n = cam.eye.normal(),
|
|
113
|
+
u = cam.getForward();
|
|
114
|
+
|
|
115
|
+
u.scale(Math.sign(cam._u.dot(n))); // up
|
|
116
|
+
|
|
117
|
+
if (cam.slope > 0.99) {
|
|
118
|
+
u = cam._u;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var tu = Vec3.proj_b_to_plane(u, n, u).normalize().scale(this.offsetVertical);
|
|
122
|
+
var tr = Vec3.proj_b_to_plane(cam._r, n, cam._r)
|
|
123
|
+
.normalize()
|
|
124
|
+
.scale(this.offsetHorizontal); // right
|
|
125
|
+
var d = tu.add(tr);
|
|
126
|
+
var pos = cam.eye.add(d);
|
|
127
|
+
if (this._k > 0) {
|
|
128
|
+
this._k -= 0.01;
|
|
129
|
+
let rot = Quat.getRotationBetweenVectors(
|
|
130
|
+
this.sunlight._position.normal(),
|
|
131
|
+
pos.normal()
|
|
132
|
+
);
|
|
133
|
+
let r = rot.slerp(Quat.IDENTITY, this._k).normalize();
|
|
134
|
+
this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
|
|
135
|
+
} else {
|
|
136
|
+
this.sunlight.setPosition3v(pos);
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
this._k = 1;
|
|
140
|
+
if (this._f > 0) {
|
|
141
|
+
this._f -= 0.01;
|
|
142
|
+
let rot = Quat.getRotationBetweenVectors(
|
|
143
|
+
this.sunlight._position.normal(),
|
|
144
|
+
getSunPosition(this._currDate).normal()
|
|
145
|
+
);
|
|
146
|
+
let r = rot.slerp(Quat.IDENTITY, this._f).normalize();
|
|
147
|
+
this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
|
|
148
|
+
} else {
|
|
149
|
+
if (
|
|
150
|
+
(Math.abs(this._currDate - this._prevDate) > 0.00034 && this._active) ||
|
|
151
|
+
this._lightOn
|
|
152
|
+
) {
|
|
153
|
+
this._lightOn = false;
|
|
154
|
+
this._prevDate = this._currDate;
|
|
155
|
+
this.sunlight.setPosition3v(getSunPosition(this._currDate));
|
|
156
|
+
this._f = 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
this.sunlight.setPosition3v(getSunPosition(this._currDate));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function sun(options) {
|
|
167
|
+
return new Sun(options);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { Sun };
|
|
@@ -83,13 +83,13 @@ class TouchNavigation extends Control {
|
|
|
83
83
|
t0.y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
|
|
84
84
|
t0.prev_x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
|
|
85
85
|
t0.prev_y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
|
|
86
|
-
t0.grabbedPoint = this.planet.getCartesianFromPixelTerrain(
|
|
86
|
+
t0.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
|
|
87
87
|
|
|
88
88
|
t1.x = e.sys.touches.item(1).clientX - e.sys.offsetLeft;
|
|
89
89
|
t1.y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
|
|
90
90
|
t1.prev_x = e.sys.touches.item(1).clientX - e.sys.offsetLeft;
|
|
91
91
|
t1.prev_y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
|
|
92
|
-
t1.grabbedPoint = this.planet.getCartesianFromPixelTerrain(
|
|
92
|
+
t1.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
|
|
93
93
|
|
|
94
94
|
// this.planet._viewChanged = true;
|
|
95
95
|
this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(
|
|
@@ -119,7 +119,7 @@ class TouchNavigation extends Control {
|
|
|
119
119
|
t.prev_x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
|
|
120
120
|
t.prev_y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
|
|
121
121
|
|
|
122
|
-
t.grabbedPoint = this.planet.getCartesianFromPixelTerrain(
|
|
122
|
+
t.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
|
|
123
123
|
this._eye0.copy(this.renderer.activeCamera.eye);
|
|
124
124
|
|
|
125
125
|
if (t.grabbedPoint) {
|
|
@@ -142,7 +142,8 @@ class TouchNavigation extends Control {
|
|
|
142
142
|
|
|
143
143
|
this.planet.stopFlying();
|
|
144
144
|
this.stopRotation();
|
|
145
|
-
|
|
145
|
+
|
|
146
|
+
var p = this.planet.getCartesianFromPixelTerrain(e);
|
|
146
147
|
if (p) {
|
|
147
148
|
var g = this.planet.ellipsoid.cartesianToLonLat(p);
|
|
148
149
|
this.planet.flyLonLat(
|
|
@@ -199,11 +200,6 @@ class TouchNavigation extends Control {
|
|
|
199
200
|
// distance < 0 --> zoomIn; distance > 0 --> zoomOut
|
|
200
201
|
var t0t1Distance = Math.abs(t0.prev_x - t1.prev_x) + Math.abs(t0.prev_y - t1.prev_y) - (Math.abs(t0.x - t1.x) + Math.abs(t0.y - t1.y))
|
|
201
202
|
var _move = 0
|
|
202
|
-
var _targetPoint = this.renderer.getCenter()
|
|
203
|
-
var d =
|
|
204
|
-
cam.eye.distance(
|
|
205
|
-
this.planet.getCartesianFromPixelTerrain(_targetPoint, true)
|
|
206
|
-
) * 0.075;
|
|
207
203
|
if (t0t1Distance < 0) {
|
|
208
204
|
_move = 1
|
|
209
205
|
}
|
|
@@ -211,9 +207,13 @@ class TouchNavigation extends Control {
|
|
|
211
207
|
_move = -1
|
|
212
208
|
}
|
|
213
209
|
if (_move !== 0) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
let pos = this.planet.getCartesianFromPixelTerrain(e);
|
|
211
|
+
if (pos) {
|
|
212
|
+
let d = cam.eye.distance(pos) * 0.075;
|
|
213
|
+
cam.eye.addA(cam.getForward().scale(_move * d));
|
|
214
|
+
cam.checkTerrainCollision();
|
|
215
|
+
cam.update();
|
|
216
|
+
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
if (
|
|
@@ -246,7 +246,7 @@ class TouchNavigation extends Control {
|
|
|
246
246
|
|
|
247
247
|
this.planet.stopFlying();
|
|
248
248
|
|
|
249
|
-
var direction =
|
|
249
|
+
var direction = e.direction
|
|
250
250
|
var targetPoint = new Ray(cam.eye, direction).hitSphere(t.grabbedSpheroid);
|
|
251
251
|
|
|
252
252
|
if (targetPoint) {
|
|
@@ -17,8 +17,6 @@ class ZoomControl extends Control {
|
|
|
17
17
|
constructor(options) {
|
|
18
18
|
super(options);
|
|
19
19
|
|
|
20
|
-
options = options || {};
|
|
21
|
-
|
|
22
20
|
this._keyLock = new Key();
|
|
23
21
|
|
|
24
22
|
this.planet = null;
|
|
@@ -114,7 +112,7 @@ class ZoomControl extends Control {
|
|
|
114
112
|
var cam = this.renderer.activeCamera;
|
|
115
113
|
|
|
116
114
|
if (this._move !== 0) {
|
|
117
|
-
let pos = this.planet.getCartesianFromPixelTerrain(
|
|
115
|
+
let pos = this.planet.getCartesianFromPixelTerrain(e);
|
|
118
116
|
if (pos) {
|
|
119
117
|
let d = cam.eye.distance(pos) * 0.035;
|
|
120
118
|
cam.eye.addA(cam.getForward().scale(this._move * d));
|
package/src/og/control/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { MouseNavigation } from "./MouseNavigation.js";
|
|
|
10
10
|
import { ToggleWireframe } from "./ToggleWireframe.js";
|
|
11
11
|
import { TouchNavigation } from "./TouchNavigation.js";
|
|
12
12
|
import { SimpleNavigation } from "./SimpleNavigation.js";
|
|
13
|
+
import { Ruler } from "./ruler/Ruler.js";
|
|
13
14
|
import { ShowFps } from "./ShowFps.js";
|
|
14
15
|
import { Sun } from "./Sun.js";
|
|
15
16
|
import { ZoomControl } from "./ZoomControl.js";
|
|
@@ -33,5 +34,6 @@ export {
|
|
|
33
34
|
Sun,
|
|
34
35
|
ZoomControl,
|
|
35
36
|
MouseWheelZoomControl,
|
|
36
|
-
Lighting
|
|
37
|
+
Lighting,
|
|
38
|
+
Ruler
|
|
37
39
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module og/control/Ruler
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { Control } from "../Control.js";
|
|
8
|
+
import { RulerScene } from "./RulerScene.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Activate ruler
|
|
12
|
+
* @class
|
|
13
|
+
* @extends {Control}
|
|
14
|
+
* @param {Object} [options] - Control options.
|
|
15
|
+
*/
|
|
16
|
+
class Ruler extends Control {
|
|
17
|
+
constructor(options = {}) {
|
|
18
|
+
super(options);
|
|
19
|
+
|
|
20
|
+
this._rulerScene = new RulerScene({
|
|
21
|
+
name: `rulerScene:${this._id}`,
|
|
22
|
+
ignoreTerrain: options.ignoreTerrain
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set ignoreTerrain(v) {
|
|
27
|
+
this._rulerScene.ignoreTerrain = v;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
oninit() {
|
|
31
|
+
this._rulerScene.bindPlanet(this.planet);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onactivate() {
|
|
35
|
+
this.renderer.addNode(this._rulerScene);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ondeactivate() {
|
|
39
|
+
this.renderer.removeNode(this._rulerScene);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Ruler };
|