@openglobus/og 0.13.7 → 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/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/Object3d.js +384 -0
- package/src/og/arial.js +1705 -1703
- package/src/og/camera/Camera.js +640 -640
- package/src/og/control/EarthCoordinates.js +1 -1
- 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/ZoomControl.js +0 -2
- 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 +19 -0
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/GeoObject.js +1 -1
- package/src/og/entity/LabelHandler.js +1 -0
- package/src/og/layer/Layer.js +23 -40
- package/src/og/layer/Vector.js +80 -14
- package/src/og/layer/XYZ.js +4 -0
- package/src/og/math/Vec3.js +1 -1
- package/src/og/math.js +4 -4
- package/src/og/quadTree/Node.js +1 -1
- package/src/og/renderer/Renderer.js +1 -2
- package/src/og/res/images.js +0 -2
- package/src/og/scene/Planet.js +3 -2
- package/src/og/segment/Segment.js +0 -8
- package/src/og/shaders/label.js +30 -42
- package/src/og/utils/FontAtlas.js +1 -2
- package/src/og/utils/Loader.js +160 -153
- package/src/og/utils/VectorTileCreator.js +1 -1
- 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/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/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/res/images.d.ts +0 -1
- package/types/scene/Planet.d.ts +2 -2
- package/types/utils/Loader.d.ts +1 -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 };
|
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 };
|