@openglobus/og 0.15.4 → 0.16.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/README.md +4 -8
- package/css/og.css +1 -1
- 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 +13 -14
- package/src/og/Globe.js +5 -2
- package/src/og/LonLat.js +224 -193
- package/src/og/Object3d.js +21 -2
- package/src/og/bv/index.js +2 -2
- package/src/og/camera/Camera.js +4 -16
- package/src/og/camera/PlanetCamera.js +15 -15
- package/src/og/control/KeyboardNavigation.js +153 -169
- package/src/og/control/MouseNavigation.js +0 -20
- package/src/og/control/RulerSwitcher.js +2 -2
- package/src/og/control/SimpleNavigation.js +10 -10
- package/src/og/control/ZoomControl.js +2 -2
- package/src/og/control/heightRuler/HeightRulerScene.js +6 -2
- package/src/og/control/index.js +5 -2
- package/src/og/control/ruler/RulerScene.js +11 -8
- package/src/og/control/timeline/TimelineControl.js +5 -3
- package/src/og/control/timeline/TimelineModel.js +4 -0
- package/src/og/control/timeline/TimelineView.js +10 -3
- package/src/og/control/visibleExtent/Segment.js +36 -42
- package/src/og/ellipsoid/Ellipsoid.js +41 -11
- package/src/og/entity/Entity.js +3 -3
- package/src/og/entity/EntityCollection.js +2 -2
- package/src/og/entity/Label.js +1 -1
- package/src/og/entity/Polyline.js +4 -2
- package/src/og/index.js +4 -7
- package/src/og/layer/CanvasTiles.js +70 -23
- package/src/og/layer/GeoImage.js +40 -18
- package/src/og/layer/Vector.js +21 -17
- package/src/og/layer/WMS.js +2 -2
- package/src/og/layer/XYZ.js +2 -2
- package/src/og/math.js +2 -1
- package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +26 -0
- package/src/og/quadTree/EntityCollectionNode.js +8 -2
- package/src/og/quadTree/Node.js +44 -50
- package/src/og/quadTree/index.js +2 -0
- package/src/og/renderer/Renderer.js +14 -1
- package/src/og/scene/Planet.js +12 -8
- package/src/og/scene/index.js +3 -3
- package/src/og/segment/Segment.js +125 -120
- package/src/og/terrain/EmptyTerrain.js +19 -7
- package/src/og/terrain/GlobusTerrain.js +23 -18
- package/src/og/terrain/MapboxTerrain.js +7 -8
- package/src/og/terrain/index.js +4 -4
- package/src/og/utils/objParser.js +227 -0
- package/src/og/utils/shared.js +9 -0
- package/src/og/webgl/Handler.js +1 -3
- package/types/Globe.d.ts +2 -0
- package/types/LonLat.d.ts +20 -1
- package/types/Object3d.d.ts +2 -0
- package/types/Popup.d.ts +1 -1
- package/types/bv/index.d.ts +2 -2
- package/types/camera/PlanetCamera.d.ts +1 -8
- package/types/camera/index.d.ts +2 -2
- package/types/control/GeoImageDragControl.d.ts +1 -1
- package/types/control/LayerAnimation.d.ts +1 -1
- package/types/control/Lighting.d.ts +2 -2
- package/types/control/heightRuler/HeightRulerScene.d.ts +1 -1
- package/types/control/index.d.ts +3 -2
- package/types/control/ruler/RulerScene.d.ts +5 -4
- package/types/control/selection/SelectionScene.d.ts +3 -3
- package/types/control/timeline/TimelineControl.d.ts +10 -0
- package/types/control/timeline/TimelineModel.d.ts +33 -0
- package/types/control/timeline/TimelineView.d.ts +57 -0
- package/types/control/timeline/timelineUtils.d.ts +9 -0
- package/types/ellipsoid/Ellipsoid.d.ts +27 -8
- package/types/ellipsoid/index.d.ts +2 -2
- package/types/entity/Entity.d.ts +3 -3
- package/types/entity/EntityCollection.d.ts +2 -2
- package/types/entity/Label.d.ts +1 -1
- package/types/entity/Polyline.d.ts +1 -0
- package/types/index.d.ts +45 -46
- package/types/layer/CanvasTiles.d.ts +2 -1
- package/types/layer/GeoImage.d.ts +7 -1
- package/types/layer/GeoTexture2d.d.ts +1 -1
- package/types/layer/Vector.d.ts +3 -3
- package/types/layer/XYZ.d.ts +1 -1
- package/types/layer/index.d.ts +9 -9
- package/types/math/Line2.d.ts +1 -1
- package/types/math/Line3.d.ts +1 -1
- package/types/math/index.d.ts +10 -10
- package/types/mercator.d.ts +1 -1
- package/types/quadTree/EPSG4326QuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/EntityCollectionNode.d.ts +1 -1
- package/types/quadTree/index.d.ts +2 -0
- package/types/renderer/Renderer.d.ts +2 -2
- package/types/scene/Axes.d.ts +1 -1
- package/types/scene/SkyBox.d.ts +1 -1
- package/types/scene/index.d.ts +3 -3
- package/types/segment/Segment.d.ts +11 -14
- package/types/shaders/atmos.d.ts +1 -1
- package/types/shaders/billboard.d.ts +1 -1
- package/types/shaders/depth.d.ts +1 -1
- package/types/shaders/label.d.ts +1 -1
- package/types/shaders/pickingMask.d.ts +1 -1
- package/types/shaders/pointCloud.d.ts +1 -1
- package/types/shaders/polyline.d.ts +1 -1
- package/types/shaders/ray.d.ts +1 -1
- package/types/shaders/screenFrame.d.ts +1 -1
- package/types/shaders/skybox.d.ts +1 -1
- package/types/shaders/toneMapping.d.ts +1 -1
- package/types/terrain/BilTerrain.d.ts +1 -0
- package/types/terrain/EmptyTerrain.d.ts +13 -2
- package/types/terrain/GlobusTerrain.d.ts +2 -1
- package/types/terrain/MapboxTerrain.d.ts +1 -3
- package/types/terrain/index.d.ts +4 -4
- package/types/ui/Button.d.ts +1 -1
- package/types/ui/ButtonGroup.d.ts +12 -0
- package/types/ui/Dialog.d.ts +2 -2
- package/types/ui/Slider.d.ts +1 -1
- package/types/ui/ToggleButton.d.ts +1 -1
- package/types/ui/View.d.ts +1 -1
- package/types/utils/GeoImageCreator.d.ts +2 -2
- package/types/utils/ImagesCacheManager.d.ts +1 -1
- package/types/utils/Loader.d.ts +1 -1
- package/types/utils/VectorTileCreator.d.ts +1 -1
- package/types/utils/objParser.d.ts +8 -0
- package/types/utils/shared.d.ts +6 -0
- package/types/webgl/Handler.d.ts +2 -2
- package/src/og/index.core.js +0 -116
- package/src/og/index.webgl.js +0 -17
- package/types/index.core.d.ts +0 -65
- package/types/index.webgl.d.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "[OpenGlobus](https://www.openglobus.org/) is a javascript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers and 3d objects. It uses the WebGL technology, open source and completely free.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"example": "./sandbox"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"style": "./css/og.css",
|
|
10
10
|
"types": "./types/index.d.ts",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"
|
|
12
|
+
"docs": "jsdoc -r ./src/ -c ./jsdoc.conf.json -d ./docs",
|
|
13
13
|
"serve": "ws",
|
|
14
14
|
"build": "rollup -c --bundleConfigAsCjs",
|
|
15
15
|
"webgl": "rollup -c --environment entry:webgl",
|
|
@@ -44,25 +44,24 @@
|
|
|
44
44
|
"./css/og.css": "./css/og.css"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/preset-env": "^7.
|
|
47
|
+
"@babel/preset-env": "^7.21.5",
|
|
48
48
|
"@rollup/plugin-json": "^6.0.0",
|
|
49
|
-
"@rollup/plugin-terser": "^0.4.
|
|
50
|
-
"@types/jest": "^29.
|
|
51
|
-
"
|
|
52
|
-
"
|
|
49
|
+
"@rollup/plugin-terser": "^0.4.1",
|
|
50
|
+
"@types/jest": "^29.5.1",
|
|
51
|
+
"clean-jsdoc-theme": "^4.2.7",
|
|
52
|
+
"eslint": "^8.39.0",
|
|
53
53
|
"jest": "^29.5.0",
|
|
54
|
-
"jest-canvas-mock": "^2.
|
|
54
|
+
"jest-canvas-mock": "^2.5.0",
|
|
55
55
|
"jest-environment-jsdom": "^29.5.0",
|
|
56
56
|
"jest-webgl-canvas-mock": "^0.2.3",
|
|
57
57
|
"jsdoc": "^4.0.2",
|
|
58
|
-
"lint-staged": "^13.
|
|
58
|
+
"lint-staged": "^13.2.2",
|
|
59
59
|
"local-web-server": "^5.3.0",
|
|
60
|
-
"postcss": "^8.4.
|
|
61
|
-
"prettier": "^2.8.
|
|
62
|
-
"rollup": "^3.
|
|
60
|
+
"postcss": "^8.4.23",
|
|
61
|
+
"prettier": "^2.8.8",
|
|
62
|
+
"rollup": "^3.21.3",
|
|
63
63
|
"rollup-plugin-postcss": "^4.0.2",
|
|
64
|
-
"
|
|
65
|
-
"typescript": "^4.9.5"
|
|
64
|
+
"typescript": "^5.0.4"
|
|
66
65
|
},
|
|
67
66
|
"lint-staged": {
|
|
68
67
|
"*.{js,ts}": [
|
package/src/og/Globe.js
CHANGED
|
@@ -71,6 +71,8 @@ const PLANET_NAME_PREFIX = "globus_planet_";
|
|
|
71
71
|
* @param {Number} [options.minEqualZoomCameraSlope=0.8] - Minimal camera slope above te globe where segments on the screen bacame the same zoom level
|
|
72
72
|
* @param {Number} [options.loadingBatchSize=12] -
|
|
73
73
|
* @param {Number} [options.quadTreeStrategyPrototype] - Prototype of quadTree. QuadTreeStrategy for Earth is default.
|
|
74
|
+
* @param {Number} [options.msaa] - MSAA antialiasing parameter: 2,4,8,16. Default is 4.
|
|
75
|
+
* @param {Number} [options.dpi] - Device pixel ratio. Default is current screen DPI.
|
|
74
76
|
*/
|
|
75
77
|
|
|
76
78
|
class Globe {
|
|
@@ -127,7 +129,7 @@ class Globe {
|
|
|
127
129
|
*/
|
|
128
130
|
this.renderer = new Renderer(
|
|
129
131
|
new Handler(_canvasId, {
|
|
130
|
-
pixelRatio: window.devicePixelRatio + 0.15,
|
|
132
|
+
pixelRatio: options.dpi || (window.devicePixelRatio + 0.15),
|
|
131
133
|
context: {
|
|
132
134
|
alpha: false,
|
|
133
135
|
antialias: false,
|
|
@@ -135,7 +137,8 @@ class Globe {
|
|
|
135
137
|
}
|
|
136
138
|
}), {
|
|
137
139
|
autoActivate: false,
|
|
138
|
-
backgroundColor: createColorRGB(options.backgroundColor, new Vec3(115 / 255, 203 / 255, 249 / 255))
|
|
140
|
+
backgroundColor: createColorRGB(options.backgroundColor, new Vec3(115 / 255, 203 / 255, 249 / 255)),
|
|
141
|
+
msaa: options.msaa
|
|
139
142
|
}
|
|
140
143
|
);
|
|
141
144
|
this.renderer.initialize();
|
package/src/og/LonLat.js
CHANGED
|
@@ -1,193 +1,224 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/LonLat
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import * as mercator from "./mercator.js";
|
|
8
|
-
|
|
9
|
-
const HALF_PI = Math.PI * 0.5;
|
|
10
|
-
const INV_PI_BY_180 = 180.0 / Math.PI;
|
|
11
|
-
const INV_PI_BY_360 = INV_PI_BY_180 * 2.0;
|
|
12
|
-
const PI_BY_360 = Math.PI / 360.0;
|
|
13
|
-
const INV_PI_BY_180_HALF_PI = INV_PI_BY_180 * HALF_PI;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Represents a geographical point with a certain latitude, longitude and height.
|
|
17
|
-
* @class
|
|
18
|
-
* @param {number} [lon] - Longitude.
|
|
19
|
-
* @param {number} [lat] - Latitude.
|
|
20
|
-
* @param {number} [height] - Height over the surface.
|
|
21
|
-
*/
|
|
22
|
-
export class LonLat {
|
|
23
|
-
/**
|
|
24
|
-
* @param {number} [lon] - Longitude.
|
|
25
|
-
* @param {number} [lat] - Latitude.
|
|
26
|
-
* @param {number} [height] - Height over the surface.
|
|
27
|
-
*/
|
|
28
|
-
constructor(lon = 0
|
|
29
|
-
/**
|
|
30
|
-
* Longitude.
|
|
31
|
-
* @public
|
|
32
|
-
* @type {number}
|
|
33
|
-
*/
|
|
34
|
-
this.lon = lon;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Latitude.
|
|
38
|
-
* @public
|
|
39
|
-
* @type {number}
|
|
40
|
-
*/
|
|
41
|
-
this.lat = lat;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Height.
|
|
45
|
-
* @public
|
|
46
|
-
* @type {number}
|
|
47
|
-
*/
|
|
48
|
-
this.height = height;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
isZero() {
|
|
52
|
-
return this.lon === 0.0 && this.lat === 0.0 && this.height === 0.0;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Creates coordinates array.
|
|
57
|
-
* @static
|
|
58
|
-
* @param{Array.<Array<number>>} arr - Coordinates array data. (exactly 3 entries)
|
|
59
|
-
* @return{Array.<LonLat>} the same coordinates array but each element is LonLat instance.
|
|
60
|
-
*/
|
|
61
|
-
static join(arr) {
|
|
62
|
-
var res = [];
|
|
63
|
-
for (var i = 0; i < arr.length; i++) {
|
|
64
|
-
var ai = arr[i];
|
|
65
|
-
res[i] = new LonLat(ai[0], ai[1], ai[2]);
|
|
66
|
-
}
|
|
67
|
-
return res;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Creates an object by coordinate array.
|
|
72
|
-
* @static
|
|
73
|
-
* @param {Array.<number>} arr - Coordiante array, where first is longitude, second is latitude and third is a height. (exactly 3 entries)
|
|
74
|
-
* @returns {LonLat} -
|
|
75
|
-
*/
|
|
76
|
-
static createFromArray(arr) {
|
|
77
|
-
return new LonLat(arr[0], arr[1], arr[2]);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* @
|
|
83
|
-
* @
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
* @
|
|
100
|
-
* @param {number}
|
|
101
|
-
* @param {number}
|
|
102
|
-
* @
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*
|
|
115
|
-
* @
|
|
116
|
-
* @param {
|
|
117
|
-
* @param {
|
|
118
|
-
* @returns {LonLat} -
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
* @
|
|
130
|
-
* @param {
|
|
131
|
-
* @
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
*
|
|
173
|
-
* @public
|
|
174
|
-
* @returns {LonLat} -
|
|
175
|
-
*/
|
|
176
|
-
|
|
177
|
-
return LonLat
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
*
|
|
182
|
-
* @public
|
|
183
|
-
* @
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @module og/LonLat
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import * as mercator from "./mercator.js";
|
|
8
|
+
|
|
9
|
+
const HALF_PI = Math.PI * 0.5;
|
|
10
|
+
const INV_PI_BY_180 = 180.0 / Math.PI;
|
|
11
|
+
const INV_PI_BY_360 = INV_PI_BY_180 * 2.0;
|
|
12
|
+
const PI_BY_360 = Math.PI / 360.0;
|
|
13
|
+
const INV_PI_BY_180_HALF_PI = INV_PI_BY_180 * HALF_PI;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents a geographical point with a certain latitude, longitude and height.
|
|
17
|
+
* @class
|
|
18
|
+
* @param {number} [lon] - Longitude.
|
|
19
|
+
* @param {number} [lat] - Latitude.
|
|
20
|
+
* @param {number} [height] - Height over the surface.
|
|
21
|
+
*/
|
|
22
|
+
export class LonLat {
|
|
23
|
+
/**
|
|
24
|
+
* @param {number} [lon] - Longitude.
|
|
25
|
+
* @param {number} [lat] - Latitude.
|
|
26
|
+
* @param {number} [height] - Height over the surface.
|
|
27
|
+
*/
|
|
28
|
+
constructor(lon = 0, lat = 0, height = 0) {
|
|
29
|
+
/**
|
|
30
|
+
* Longitude.
|
|
31
|
+
* @public
|
|
32
|
+
* @type {number}
|
|
33
|
+
*/
|
|
34
|
+
this.lon = lon;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Latitude.
|
|
38
|
+
* @public
|
|
39
|
+
* @type {number}
|
|
40
|
+
*/
|
|
41
|
+
this.lat = lat;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Height.
|
|
45
|
+
* @public
|
|
46
|
+
* @type {number}
|
|
47
|
+
*/
|
|
48
|
+
this.height = height;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
isZero() {
|
|
52
|
+
return this.lon === 0.0 && this.lat === 0.0 && this.height === 0.0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Creates coordinates array.
|
|
57
|
+
* @static
|
|
58
|
+
* @param{Array.<Array<number>>} arr - Coordinates array data. (exactly 3 entries)
|
|
59
|
+
* @return{Array.<LonLat>} the same coordinates array but each element is LonLat instance.
|
|
60
|
+
*/
|
|
61
|
+
static join(arr) {
|
|
62
|
+
var res = [];
|
|
63
|
+
for (var i = 0; i < arr.length; i++) {
|
|
64
|
+
var ai = arr[i];
|
|
65
|
+
res[i] = new LonLat(ai[0], ai[1], ai[2]);
|
|
66
|
+
}
|
|
67
|
+
return res;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Creates an object by coordinate array.
|
|
72
|
+
* @static
|
|
73
|
+
* @param {Array.<number>} arr - Coordiante array, where first is longitude, second is latitude and third is a height. (exactly 3 entries)
|
|
74
|
+
* @returns {LonLat} -
|
|
75
|
+
*/
|
|
76
|
+
static createFromArray(arr) {
|
|
77
|
+
return new LonLat(arr[0], arr[1], arr[2]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Create array from lonlat
|
|
82
|
+
* @param lonLat
|
|
83
|
+
* @returns {number[]}
|
|
84
|
+
*/
|
|
85
|
+
static toArray(lonLat) {
|
|
86
|
+
return [lonLat.lon, lonLat.lat, lonLat.height]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Create array from lonlat
|
|
91
|
+
* @returns {number[]}
|
|
92
|
+
*/
|
|
93
|
+
toArray() {
|
|
94
|
+
return LonLat.toArray(this)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Converts degrees to mercator coordinates.
|
|
99
|
+
* @static
|
|
100
|
+
* @param {number} lon - Degrees longitude.
|
|
101
|
+
* @param {number} lat - Degrees latitude.
|
|
102
|
+
* @param {number} [height] - Height.
|
|
103
|
+
* @returns {LonLat} -
|
|
104
|
+
*/
|
|
105
|
+
static forwardMercator(lon, lat, height) {
|
|
106
|
+
return new LonLat(
|
|
107
|
+
lon * mercator.POLE_BY_180,
|
|
108
|
+
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI,
|
|
109
|
+
height
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Converts degrees to mercator coordinates.
|
|
115
|
+
* @static
|
|
116
|
+
* @param {LonLat} lonLat - Input geodetic degree coordinates
|
|
117
|
+
* @param {LonLat} res - Output mercator coordinates
|
|
118
|
+
* @returns {LonLat} - Output mercator coordinates
|
|
119
|
+
*/
|
|
120
|
+
static forwardMercatorRes(lonLat, res) {
|
|
121
|
+
res.lon = lonLat.lon * mercator.POLE_BY_180;
|
|
122
|
+
res.lat = Math.log(Math.tan((90.0 + lonLat.lat) * PI_BY_360)) * mercator.POLE_BY_PI,
|
|
123
|
+
res.height = lonLat.height;
|
|
124
|
+
return res;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Converts mercator to degrees coordinates.
|
|
129
|
+
* @static
|
|
130
|
+
* @param {number} x - Mercator longitude.
|
|
131
|
+
* @param {number} y - Mercator latitude.
|
|
132
|
+
* @param {number} [height] - Height.
|
|
133
|
+
* @returns {LonLat} -
|
|
134
|
+
*/
|
|
135
|
+
static inverseMercator(x, y, height = 0) {
|
|
136
|
+
return new LonLat(
|
|
137
|
+
x * mercator.INV_POLE_BY_180,
|
|
138
|
+
INV_PI_BY_360 * Math.atan(Math.exp(y * mercator.PI_BY_POLE)) - INV_PI_BY_180_HALF_PI,
|
|
139
|
+
height
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Sets coordinates.
|
|
145
|
+
* @public
|
|
146
|
+
* @param {number} [lon] - Longitude.
|
|
147
|
+
* @param {number} [lat] - Latitude.
|
|
148
|
+
* @param {number} [height] - Height.
|
|
149
|
+
* @returns {LonLat} -
|
|
150
|
+
*/
|
|
151
|
+
set(lon = 0, lat = 0, height = 0) {
|
|
152
|
+
this.lon = lon;
|
|
153
|
+
this.lat = lat;
|
|
154
|
+
this.height = height;
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Copy coordinates.
|
|
160
|
+
* @public
|
|
161
|
+
* @param {LonLat} [lonLat] - Coordinates to copy.
|
|
162
|
+
* @returns {LonLat} -
|
|
163
|
+
*/
|
|
164
|
+
copy(lonLat) {
|
|
165
|
+
this.lon = lonLat.lon;
|
|
166
|
+
this.lat = lonLat.lat;
|
|
167
|
+
this.height = lonLat.height;
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Clone the coordinates.
|
|
173
|
+
* @public
|
|
174
|
+
* @returns {LonLat} -
|
|
175
|
+
*/
|
|
176
|
+
clone() {
|
|
177
|
+
return new LonLat(this.lon, this.lat, this.height);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Converts to mercator coordinates.
|
|
182
|
+
* @public
|
|
183
|
+
* @returns {LonLat} -
|
|
184
|
+
*/
|
|
185
|
+
forwardMercator() {
|
|
186
|
+
return LonLat.forwardMercator(this.lon, this.lat, this.height);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
forwardMercatorEPS01() {
|
|
190
|
+
var lat = this.lat;
|
|
191
|
+
if (lat > 89.9) {
|
|
192
|
+
lat = 89.9;
|
|
193
|
+
} else if (lat < -89.9) {
|
|
194
|
+
lat = -89.9;
|
|
195
|
+
}
|
|
196
|
+
return new LonLat(
|
|
197
|
+
this.lon * mercator.POLE_BY_180,
|
|
198
|
+
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Converts from mercator coordinates.
|
|
204
|
+
* @public
|
|
205
|
+
* @returns {LonLat} -
|
|
206
|
+
*/
|
|
207
|
+
inverseMercator() {
|
|
208
|
+
return LonLat.inverseMercator(this.lon, this.lat, this.height);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Compares coordinates.
|
|
213
|
+
* @public
|
|
214
|
+
* @param {LonLat} b - Coordinate to compare with.
|
|
215
|
+
* @returns {boolean} -
|
|
216
|
+
*/
|
|
217
|
+
equal(b) {
|
|
218
|
+
if (b.height) {
|
|
219
|
+
return this.lon === b.lon && this.lat === b.lat && this.height === b.height;
|
|
220
|
+
} else {
|
|
221
|
+
return this.lon === b.lon && this.lat === b.lat;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
package/src/og/Object3d.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import { htmlColorToFloat32Array } from './utils/shared.js';
|
|
5
5
|
import { Vec3 } from './math/Vec3.js';
|
|
6
|
-
import {
|
|
6
|
+
import { MAX, MIN } from './math.js';
|
|
7
|
+
import { transformLeftToRightCoordinateSystem, objParser } from "./utils/objParser.js";
|
|
7
8
|
|
|
8
9
|
function getColor(color) {
|
|
9
10
|
if (color instanceof Array) {
|
|
@@ -44,7 +45,7 @@ class Object3d {
|
|
|
44
45
|
this._normals = data.normals || [];
|
|
45
46
|
} else {
|
|
46
47
|
this._normals = Object3d.getNormals(this._vertices);
|
|
47
|
-
this._indices = new Array(this._vertices.length/ 3);
|
|
48
|
+
this._indices = new Array(this._vertices.length / 3);
|
|
48
49
|
for (let i = 0, len = this._indices.length; i < len; i++) {
|
|
49
50
|
this._indices[i] = i;
|
|
50
51
|
}
|
|
@@ -78,6 +79,10 @@ class Object3d {
|
|
|
78
79
|
return this._src;
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
set src(src) {
|
|
83
|
+
this._src = src;
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
get name() {
|
|
82
87
|
return this._name;
|
|
83
88
|
}
|
|
@@ -371,6 +376,20 @@ class Object3d {
|
|
|
371
376
|
-7, 0, 6, 0, 0, front, 0, 0, back, 0, 0, back, 0, 0, front, 7, 0, 6]
|
|
372
377
|
});
|
|
373
378
|
}
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
static async loadObj(src) {
|
|
382
|
+
const obj = await fetch(src)
|
|
383
|
+
.then((response) => response.text())
|
|
384
|
+
.then((data) => transformLeftToRightCoordinateSystem(objParser(data)))
|
|
385
|
+
.catch(() => []);
|
|
386
|
+
|
|
387
|
+
return obj.geometries.map(({ data: { vertices, normals, textures } }) => new Object3d({
|
|
388
|
+
vertices,
|
|
389
|
+
normals,
|
|
390
|
+
texCoords: textures
|
|
391
|
+
}));
|
|
392
|
+
}
|
|
374
393
|
}
|
|
375
394
|
|
|
376
395
|
export { Object3d };
|
package/src/og/bv/index.js
CHANGED
package/src/og/camera/Camera.js
CHANGED
|
@@ -255,22 +255,10 @@ class Camera {
|
|
|
255
255
|
Vec3.doubleToTwoFloat32Array(eye, this.eyeHigh, this.eyeLow);
|
|
256
256
|
|
|
257
257
|
this._viewMatrix.set([
|
|
258
|
-
u.x,
|
|
259
|
-
v.
|
|
260
|
-
n.
|
|
261
|
-
|
|
262
|
-
u.y,
|
|
263
|
-
v.y,
|
|
264
|
-
n.y,
|
|
265
|
-
0.0,
|
|
266
|
-
u.z,
|
|
267
|
-
v.z,
|
|
268
|
-
n.z,
|
|
269
|
-
0.0,
|
|
270
|
-
-eye.dot(u),
|
|
271
|
-
-eye.dot(v),
|
|
272
|
-
-eye.dot(n),
|
|
273
|
-
1.0
|
|
258
|
+
u.x, v.x, n.x, 0.0,
|
|
259
|
+
u.y, v.y, n.y, 0.0,
|
|
260
|
+
u.z, v.z, n.z, 0.0,
|
|
261
|
+
-eye.dot(u), -eye.dot(v), -eye.dot(n), 1.0
|
|
274
262
|
]);
|
|
275
263
|
|
|
276
264
|
// do not cleanup, someday it will be using
|