@twinmatrix/spatialverse-sdk-web 0.0.4 → 0.0.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.
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js +293 -0
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js.map +1 -0
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js +35 -0
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js.map +1 -0
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js +33 -0
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js.map +1 -0
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js +307 -0
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js.map +1 -0
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/focustree.json +121 -0
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/whatTaxonomies.json +170 -0
- package/lib/cjs/meta-atlas-sdk/combined_style.json +2313 -0
- package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js +166 -0
- package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js.map +1 -0
- package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js +229 -0
- package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js.map +1 -0
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js +286 -0
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js.map +1 -0
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js +27 -0
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js.map +1 -0
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js +27 -0
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js.map +1 -0
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js +305 -0
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js.map +1 -0
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/focustree.json +121 -0
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +2 -2
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/whatTaxonomies.json +170 -0
- package/lib/esm/meta-atlas-sdk/combined_style.json +2313 -0
- package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js +158 -0
- package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js.map +1 -0
- package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js +221 -0
- package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author peterqliu / https://github.com/peterqliu
|
|
3
|
+
* @author jscastro / https://github.com/jscastro76
|
|
4
|
+
*
|
|
5
|
+
* This code file is based on the CameraSync module from the ThreeBox project.
|
|
6
|
+
* Source: https://github.com/jscastro76/threebox/blob/master/src/camera/CameraSync.js
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Group, Matrix4, Vector3, OrthographicCamera, Quaternion } from "three";
|
|
10
|
+
import constants from './constants.js';
|
|
11
|
+
class CameraSync {
|
|
12
|
+
constructor(map, camera, world) {
|
|
13
|
+
this.map = map;
|
|
14
|
+
this.camera = camera;
|
|
15
|
+
this.active = true;
|
|
16
|
+
this.camera.matrixAutoUpdate = false; // We're in charge of the camera now!
|
|
17
|
+
|
|
18
|
+
// Postion and configure the world group so we can scale it appropriately when the camera zooms
|
|
19
|
+
this.world = world || new Group();
|
|
20
|
+
this.world.position.x = this.world.position.y = constants.WORLD_SIZE / 2;
|
|
21
|
+
this.world.matrixAutoUpdate = false;
|
|
22
|
+
|
|
23
|
+
// set up basic camera state
|
|
24
|
+
this.state = {
|
|
25
|
+
translateCenter: new Matrix4().makeTranslation(constants.WORLD_SIZE / 2, -constants.WORLD_SIZE / 2, 0),
|
|
26
|
+
worldSizeRatio: constants.TILE_SIZE / constants.WORLD_SIZE,
|
|
27
|
+
worldSize: constants.TILE_SIZE * this.map.transform.scale
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Listen for move events from the map and update the Three.js camera
|
|
31
|
+
let _this = this; // keep the function on _this
|
|
32
|
+
this.map.on('move', function () {
|
|
33
|
+
_this.updateCamera();
|
|
34
|
+
});
|
|
35
|
+
this.map.on('resize', function () {
|
|
36
|
+
_this.setupCamera();
|
|
37
|
+
});
|
|
38
|
+
this.setupCamera();
|
|
39
|
+
}
|
|
40
|
+
setupCamera() {
|
|
41
|
+
const t = this.map.transform;
|
|
42
|
+
this.camera.aspect = t.width / t.height; //bug fixed, if aspect is not reset raycast will fail on map resize
|
|
43
|
+
this.halfFov = t._fov / 2;
|
|
44
|
+
this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height;
|
|
45
|
+
const maxPitch = t._maxPitch * Math.PI / 180;
|
|
46
|
+
this.acuteAngle = Math.PI / 2 - maxPitch;
|
|
47
|
+
this.updateCamera();
|
|
48
|
+
}
|
|
49
|
+
updateCamera(ev) {
|
|
50
|
+
if (!this.camera) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const t = this.map.transform;
|
|
54
|
+
this.camera.aspect = t.width / t.height; //bug fixed, if aspect is not reset raycast will fail on map resize
|
|
55
|
+
const offset = t.centerOffset || new Vector3(); //{ x: t.width / 2, y: t.height / 2 };
|
|
56
|
+
let farZ = 0;
|
|
57
|
+
let furthestDistance = 0;
|
|
58
|
+
this.halfFov = t._fov / 2;
|
|
59
|
+
const groundAngle = Math.PI / 2 + t._pitch;
|
|
60
|
+
const pitchAngle = Math.cos(Math.PI / 2 - t._pitch); //pitch seems to influence heavily the depth calculation and cannot be more than 60 = PI/3 < v1 and 85 > v2
|
|
61
|
+
this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height;
|
|
62
|
+
// let pixelsPerMeter = 1;
|
|
63
|
+
const worldSize = this.worldSize();
|
|
64
|
+
|
|
65
|
+
// if (this.map.tb.mapboxVersion >= 2.0) {
|
|
66
|
+
// mapbox version >= 2.0
|
|
67
|
+
// pixelsPerMeter = this.mercatorZfromAltitude(1, t.center.lat) * worldSize;
|
|
68
|
+
// const fovAboveCenter = t._fov * (0.5 + t.centerOffset.y / t.height);
|
|
69
|
+
// // Adjust distance to MSL by the minimum possible elevation visible on screen,
|
|
70
|
+
// // this way the far plane is pushed further in the case of negative elevation.
|
|
71
|
+
// const minElevationInPixels = t.elevation ? t.elevation.getMinElevationBelowMSL() * pixelsPerMeter : 0;
|
|
72
|
+
// const cameraToSeaLevelDistance = ((t._camera.position[2] * worldSize) - minElevationInPixels) / Math.cos(t._pitch);
|
|
73
|
+
// const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * cameraToSeaLevelDistance / Math.sin(clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));
|
|
74
|
+
// // Calculate z distance of the farthest fragment that should be rendered.
|
|
75
|
+
// furthestDistance = pitchAngle * topHalfSurfaceDistance + cameraToSeaLevelDistance;
|
|
76
|
+
// // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`
|
|
77
|
+
// const horizonDistance = cameraToSeaLevelDistance * (1 / t._horizonShift);
|
|
78
|
+
// farZ = Math.min(furthestDistance * 1.01, horizonDistance);
|
|
79
|
+
// } else {
|
|
80
|
+
// // mapbox version < 2.0 or azure maps
|
|
81
|
+
// Furthest distance optimized by @jscastro76
|
|
82
|
+
const topHalfSurfaceDistance = Math.sin(this.halfFov) * this.cameraToCenterDistance / Math.sin(Math.PI - groundAngle - this.halfFov);
|
|
83
|
+
|
|
84
|
+
// Calculate z distance of the farthest fragment that should be rendered.
|
|
85
|
+
furthestDistance = pitchAngle * topHalfSurfaceDistance + this.cameraToCenterDistance;
|
|
86
|
+
|
|
87
|
+
// Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`
|
|
88
|
+
farZ = furthestDistance * 1.01;
|
|
89
|
+
// }
|
|
90
|
+
this.cameraTranslateZ = new Matrix4().makeTranslation(0, 0, this.cameraToCenterDistance);
|
|
91
|
+
|
|
92
|
+
// someday @ansis set further near plane to fix precision for deckgl,so we should fix it to use mapbox-gl v1.3+ correctly
|
|
93
|
+
// https://github.com/mapbox/mapbox-gl-js/commit/5cf6e5f523611bea61dae155db19a7cb19eb825c#diff-5dddfe9d7b5b4413ee54284bc1f7966d
|
|
94
|
+
const nz = t.height / 50; //min near z as coded by @ansis
|
|
95
|
+
const nearZ = Math.max(nz * pitchAngle, nz); //on changes in the pitch nz could be too low
|
|
96
|
+
|
|
97
|
+
const h = t.height;
|
|
98
|
+
const w = t.width;
|
|
99
|
+
if (this.camera instanceof OrthographicCamera) {
|
|
100
|
+
this.camera.projectionMatrix = makeOrthographicMatrix(w / -2, w / 2, h / 2, h / -2, nearZ, farZ);
|
|
101
|
+
} else {
|
|
102
|
+
this.camera.projectionMatrix = makePerspectiveMatrix(t._fov, w / h, nearZ, farZ);
|
|
103
|
+
}
|
|
104
|
+
this.camera.projectionMatrix.elements[8] = -offset.x * 2 / t.width;
|
|
105
|
+
this.camera.projectionMatrix.elements[9] = offset.y * 2 / t.height;
|
|
106
|
+
|
|
107
|
+
// Unlike the Mapbox GL JS camera, separate camera translation and rotation out into its world matrix
|
|
108
|
+
// If this is applied directly to the projection matrix, it will work OK but break raycasting
|
|
109
|
+
let cameraWorldMatrix = this.calcCameraMatrix(t._pitch, t.angle);
|
|
110
|
+
// When terrain layers are included, height of 3D layers must be modified from t_camera.z * worldSize
|
|
111
|
+
if (t.elevation) cameraWorldMatrix.elements[14] = t._camera.position[2] * worldSize;
|
|
112
|
+
//this.camera.matrixWorld.elements is equivalent to t._camera._transform
|
|
113
|
+
this.camera.matrixWorld.copy(cameraWorldMatrix);
|
|
114
|
+
let zoomPow = t.scale * this.state.worldSizeRatio;
|
|
115
|
+
// Handle scaling and translation of objects in the map in the world's matrix transform, not the camera
|
|
116
|
+
let scale = new Matrix4();
|
|
117
|
+
let translateMap = new Matrix4();
|
|
118
|
+
let rotateMap = new Matrix4();
|
|
119
|
+
scale.makeScale(zoomPow, zoomPow, zoomPow);
|
|
120
|
+
let x = t.x || t.point.x;
|
|
121
|
+
let y = t.y || t.point.y;
|
|
122
|
+
translateMap.makeTranslation(-x, y, 0);
|
|
123
|
+
rotateMap.makeRotationZ(Math.PI);
|
|
124
|
+
this.world.matrix = new Matrix4().premultiply(rotateMap).premultiply(this.state.translateCenter).premultiply(scale).premultiply(translateMap);
|
|
125
|
+
|
|
126
|
+
// utils.prettyPrintMatrix(this.camera.projectionMatrix.elements);
|
|
127
|
+
this.map.fire('CameraSynced', {
|
|
128
|
+
detail: {
|
|
129
|
+
nearZ: nearZ,
|
|
130
|
+
farZ: farZ,
|
|
131
|
+
pitch: t._pitch,
|
|
132
|
+
angle: t.angle,
|
|
133
|
+
furthestDistance: furthestDistance,
|
|
134
|
+
cameraToCenterDistance: this.cameraToCenterDistance,
|
|
135
|
+
t: this.map.transform,
|
|
136
|
+
tbProjMatrix: this.camera.projectionMatrix.elements,
|
|
137
|
+
tbWorldMatrix: this.world.matrix.elements,
|
|
138
|
+
cameraSyn: CameraSync
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
worldSize() {
|
|
143
|
+
let t = this.map.transform;
|
|
144
|
+
return t.tileSize * t.scale;
|
|
145
|
+
}
|
|
146
|
+
worldSizeFromZoom() {
|
|
147
|
+
let t = this.map.transform;
|
|
148
|
+
return Math.pow(2.0, t.zoom) * t.tileSize;
|
|
149
|
+
}
|
|
150
|
+
mercatorZfromAltitude(altitude, lat) {
|
|
151
|
+
return altitude / this.circumferenceAtLatitude(lat);
|
|
152
|
+
}
|
|
153
|
+
mercatorZfromZoom() {
|
|
154
|
+
return this.cameraToCenterDistance / this.worldSizeFromZoom();
|
|
155
|
+
}
|
|
156
|
+
circumferenceAtLatitude(latitude) {
|
|
157
|
+
return constants.EARTH_CIRCUMFERENCE * Math.cos(latitude * Math.PI / 180);
|
|
158
|
+
}
|
|
159
|
+
calcCameraMatrix(pitch, angle, trz) {
|
|
160
|
+
const t = this.map.transform;
|
|
161
|
+
const _pitch = pitch === undefined ? t._pitch : pitch;
|
|
162
|
+
const _angle = angle === undefined ? t.angle : angle;
|
|
163
|
+
const _trz = trz === undefined ? this.cameraTranslateZ : trz;
|
|
164
|
+
return new Matrix4().premultiply(_trz).premultiply(new Matrix4().makeRotationX(_pitch)).premultiply(new Matrix4().makeRotationZ(_angle));
|
|
165
|
+
}
|
|
166
|
+
updateCameraState() {
|
|
167
|
+
let t = this.map.transform;
|
|
168
|
+
if (!t.height) return;
|
|
169
|
+
|
|
170
|
+
// Set camera orientation and move it to a proper distance from the map
|
|
171
|
+
// t._camera.setPitchBearing(t._pitch, t.angle);
|
|
172
|
+
const dir = t._camera.forward();
|
|
173
|
+
const distance = t.cameraToCenterDistance;
|
|
174
|
+
const center = t.point;
|
|
175
|
+
|
|
176
|
+
// Use camera zoom (if terrain is enabled) to maintain constant altitude to sea level
|
|
177
|
+
const altitude = this.mercatorZfromZoom(t);
|
|
178
|
+
const height = altitude - this.mercatorZfromAltitude(t._centerAltitude, t.center.lat);
|
|
179
|
+
|
|
180
|
+
// simplified version of: this._worldSizeFromZoom(this._zoomFromMercatorZ(height))
|
|
181
|
+
const updatedWorldSize = t.cameraToCenterDistance / height;
|
|
182
|
+
return [center.x / this.worldSize() - dir[0] * distance / updatedWorldSize, center.y / this.worldSize() - dir[1] * distance / updatedWorldSize, this.mercatorZfromAltitude(t._centerAltitude, t._center.lat) + -dir[2] * distance / updatedWorldSize];
|
|
183
|
+
}
|
|
184
|
+
getWorldToCamera(worldSize, pixelsPerMeter) {
|
|
185
|
+
// transformation chain from world space to camera space:
|
|
186
|
+
// 1. Height value (z) of renderables is in meters. Scale z coordinate by pixelsPerMeter
|
|
187
|
+
// 2. Transform from pixel coordinates to camera space with cameraMatrix^-1
|
|
188
|
+
// 3. flip Y if required
|
|
189
|
+
// worldToCamera: flip * cam^-1 * zScale
|
|
190
|
+
// cameraToWorld: (flip * cam^-1 * zScale)^-1 => (zScale^-1 * cam * flip^-1)
|
|
191
|
+
let t = this.map.transform;
|
|
192
|
+
const matrix = new Matrix4();
|
|
193
|
+
const matrixT = new Matrix4();
|
|
194
|
+
|
|
195
|
+
// Compute inverse of camera matrix and post-multiply negated translation
|
|
196
|
+
const o = t._camera._orientation;
|
|
197
|
+
const p = t._camera.position;
|
|
198
|
+
const invPosition = new Vector3(p[0], p[1], p[2]);
|
|
199
|
+
const quat = new Quaternion();
|
|
200
|
+
quat.set(o[0], o[1], o[2], o[3]);
|
|
201
|
+
const invOrientation = quat.conjugate();
|
|
202
|
+
invPosition.multiplyScalar(-worldSize);
|
|
203
|
+
matrixT.makeTranslation(invPosition.x, invPosition.y, invPosition.z);
|
|
204
|
+
matrix.makeRotationFromQuaternion(invOrientation).premultiply(matrixT);
|
|
205
|
+
//this would make the matrix exact to getWorldToCamera but breaks
|
|
206
|
+
//this.translate(matrix.elements, matrix.elements, invPosition);
|
|
207
|
+
// Pre-multiply y (2nd row)
|
|
208
|
+
matrix.elements[1] *= -1.0;
|
|
209
|
+
matrix.elements[5] *= -1.0;
|
|
210
|
+
matrix.elements[9] *= -1.0;
|
|
211
|
+
matrix.elements[13] *= -1.0;
|
|
212
|
+
|
|
213
|
+
// Post-multiply z (3rd column)
|
|
214
|
+
matrix.elements[8] *= pixelsPerMeter;
|
|
215
|
+
matrix.elements[9] *= pixelsPerMeter;
|
|
216
|
+
matrix.elements[10] *= pixelsPerMeter;
|
|
217
|
+
matrix.elements[11] *= pixelsPerMeter;
|
|
218
|
+
return matrix;
|
|
219
|
+
}
|
|
220
|
+
translate(out, a, v) {
|
|
221
|
+
let x = v[0] || v.x,
|
|
222
|
+
y = v[1] || v.y,
|
|
223
|
+
z = v[2] || v.z;
|
|
224
|
+
let a00, a01, a02, a03;
|
|
225
|
+
let a10, a11, a12, a13;
|
|
226
|
+
let a20, a21, a22, a23;
|
|
227
|
+
if (a === out) {
|
|
228
|
+
out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
|
|
229
|
+
out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
|
|
230
|
+
out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
|
|
231
|
+
out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
|
|
232
|
+
} else {
|
|
233
|
+
a00 = a[0];
|
|
234
|
+
a01 = a[1];
|
|
235
|
+
a02 = a[2];
|
|
236
|
+
a03 = a[3];
|
|
237
|
+
a10 = a[4];
|
|
238
|
+
a11 = a[5];
|
|
239
|
+
a12 = a[6];
|
|
240
|
+
a13 = a[7];
|
|
241
|
+
a20 = a[8];
|
|
242
|
+
a21 = a[9];
|
|
243
|
+
a22 = a[10];
|
|
244
|
+
a23 = a[11];
|
|
245
|
+
out[0] = a00;
|
|
246
|
+
out[1] = a01;
|
|
247
|
+
out[2] = a02;
|
|
248
|
+
out[3] = a03;
|
|
249
|
+
out[4] = a10;
|
|
250
|
+
out[5] = a11;
|
|
251
|
+
out[6] = a12;
|
|
252
|
+
out[7] = a13;
|
|
253
|
+
out[8] = a20;
|
|
254
|
+
out[9] = a21;
|
|
255
|
+
out[10] = a22;
|
|
256
|
+
out[11] = a23;
|
|
257
|
+
out[12] = a00 * x + a10 * y + a20 * z + a[12];
|
|
258
|
+
out[13] = a01 * x + a11 * y + a21 * z + a[13];
|
|
259
|
+
out[14] = a02 * x + a12 * y + a22 * z + a[14];
|
|
260
|
+
out[15] = a03 * x + a13 * y + a23 * z + a[15];
|
|
261
|
+
}
|
|
262
|
+
return out;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function makeOrthographicMatrix(left, right, top, bottom, near, far) {
|
|
266
|
+
var out = new Matrix4();
|
|
267
|
+
const w = 1.0 / (right - left);
|
|
268
|
+
const h = 1.0 / (top - bottom);
|
|
269
|
+
const p = 1.0 / (far - near);
|
|
270
|
+
const x = (right + left) * w;
|
|
271
|
+
const y = (top + bottom) * h;
|
|
272
|
+
const z = near * p;
|
|
273
|
+
var newMatrix = [2 * w, 0, 0, 0, 0, 2 * h, 0, 0, 0, 0, -1 * p, 0, -x, -y, -z, 1];
|
|
274
|
+
out.elements = newMatrix;
|
|
275
|
+
return out;
|
|
276
|
+
}
|
|
277
|
+
function makePerspectiveMatrix(fovy, aspect, near, far) {
|
|
278
|
+
var out = new Matrix4();
|
|
279
|
+
var f = 1.0 / Math.tan(fovy / 2),
|
|
280
|
+
nf = 1 / (near - far);
|
|
281
|
+
var newMatrix = [f / aspect, 0, 0, 0, 0, f, 0, 0, 0, 0, (far + near) * nf, -1, 0, 0, 2 * far * near * nf, 0];
|
|
282
|
+
out.elements = newMatrix;
|
|
283
|
+
return out;
|
|
284
|
+
}
|
|
285
|
+
export default CameraSync;
|
|
286
|
+
//# sourceMappingURL=CameraSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraSync.js","names":["Group","Matrix4","Vector3","OrthographicCamera","Quaternion","constants","CameraSync","constructor","map","camera","world","active","matrixAutoUpdate","position","x","y","WORLD_SIZE","state","translateCenter","makeTranslation","worldSizeRatio","TILE_SIZE","worldSize","transform","scale","_this","on","updateCamera","setupCamera","t","aspect","width","height","halfFov","_fov","cameraToCenterDistance","Math","tan","maxPitch","_maxPitch","PI","acuteAngle","ev","offset","centerOffset","farZ","furthestDistance","groundAngle","_pitch","pitchAngle","cos","topHalfSurfaceDistance","sin","cameraTranslateZ","nz","nearZ","max","h","w","projectionMatrix","makeOrthographicMatrix","makePerspectiveMatrix","elements","cameraWorldMatrix","calcCameraMatrix","angle","elevation","_camera","matrixWorld","copy","zoomPow","translateMap","rotateMap","makeScale","point","makeRotationZ","matrix","premultiply","fire","detail","pitch","tbProjMatrix","tbWorldMatrix","cameraSyn","tileSize","worldSizeFromZoom","pow","zoom","mercatorZfromAltitude","altitude","lat","circumferenceAtLatitude","mercatorZfromZoom","latitude","EARTH_CIRCUMFERENCE","trz","undefined","_angle","_trz","makeRotationX","updateCameraState","dir","forward","distance","center","_centerAltitude","updatedWorldSize","_center","getWorldToCamera","pixelsPerMeter","matrixT","o","_orientation","p","invPosition","quat","set","invOrientation","conjugate","multiplyScalar","z","makeRotationFromQuaternion","translate","out","a","v","a00","a01","a02","a03","a10","a11","a12","a13","a20","a21","a22","a23","left","right","top","bottom","near","far","newMatrix","fovy","f","nf"],"sources":["../../../../../../src/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js"],"sourcesContent":["/**\n * @author peterqliu / https://github.com/peterqliu\n * @author jscastro / https://github.com/jscastro76\n * \n * This code file is based on the CameraSync module from the ThreeBox project.\n * Source: https://github.com/jscastro76/threebox/blob/master/src/camera/CameraSync.js\n */\n\nimport { Group, Matrix4, Vector3, OrthographicCamera, Quaternion } from \"three\";\nimport constants from './constants.js';\n\nclass CameraSync {\n constructor(map, camera, world) {\n this.map = map;\n this.camera = camera;\n this.active = true;\n\n this.camera.matrixAutoUpdate = false; // We're in charge of the camera now!\n\n\n // Postion and configure the world group so we can scale it appropriately when the camera zooms\n this.world = world || new Group();\n this.world.position.x = this.world.position.y = constants.WORLD_SIZE / 2;\n this.world.matrixAutoUpdate = false;\n\n // set up basic camera state\n this.state = {\n translateCenter: new Matrix4().makeTranslation(constants.WORLD_SIZE / 2, -constants.WORLD_SIZE / 2, 0),\n worldSizeRatio: constants.TILE_SIZE / constants.WORLD_SIZE,\n worldSize: constants.TILE_SIZE * this.map.transform.scale\n };\n\n\n\n // Listen for move events from the map and update the Three.js camera\n let _this = this; // keep the function on _this\n this.map\n .on('move', function () {\n _this.updateCamera();\n })\n this.map.on('resize', function () {\n _this.setupCamera();\n });\n this.setupCamera();\n }\n setupCamera() {\n const t = this.map.transform;\n this.camera.aspect = t.width / t.height; //bug fixed, if aspect is not reset raycast will fail on map resize\n this.halfFov = t._fov / 2;\n this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height;\n const maxPitch = t._maxPitch * Math.PI / 180;\n this.acuteAngle = Math.PI / 2 - maxPitch;\n this.updateCamera();\n }\n\n updateCamera(ev) {\n if (!this.camera) {\n return;\n }\n\n\n const t = this.map.transform;\n this.camera.aspect = t.width / t.height; //bug fixed, if aspect is not reset raycast will fail on map resize\n const offset = t.centerOffset || new Vector3(); //{ x: t.width / 2, y: t.height / 2 };\n let farZ = 0;\n let furthestDistance = 0;\n this.halfFov = t._fov / 2;\n const groundAngle = Math.PI / 2 + t._pitch;\n const pitchAngle = Math.cos((Math.PI / 2) - t._pitch); //pitch seems to influence heavily the depth calculation and cannot be more than 60 = PI/3 < v1 and 85 > v2\n this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height;\n // let pixelsPerMeter = 1;\n const worldSize = this.worldSize();\n\n // if (this.map.tb.mapboxVersion >= 2.0) {\n // mapbox version >= 2.0\n // pixelsPerMeter = this.mercatorZfromAltitude(1, t.center.lat) * worldSize;\n // const fovAboveCenter = t._fov * (0.5 + t.centerOffset.y / t.height);\n // // Adjust distance to MSL by the minimum possible elevation visible on screen,\n // // this way the far plane is pushed further in the case of negative elevation.\n // const minElevationInPixels = t.elevation ? t.elevation.getMinElevationBelowMSL() * pixelsPerMeter : 0;\n // const cameraToSeaLevelDistance = ((t._camera.position[2] * worldSize) - minElevationInPixels) / Math.cos(t._pitch);\n // const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * cameraToSeaLevelDistance / Math.sin(clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));\n // // Calculate z distance of the farthest fragment that should be rendered.\n // furthestDistance = pitchAngle * topHalfSurfaceDistance + cameraToSeaLevelDistance;\n // // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`\n // const horizonDistance = cameraToSeaLevelDistance * (1 / t._horizonShift);\n // farZ = Math.min(furthestDistance * 1.01, horizonDistance);\n // } else {\n // // mapbox version < 2.0 or azure maps\n // Furthest distance optimized by @jscastro76\n const topHalfSurfaceDistance = Math.sin(this.halfFov) * this.cameraToCenterDistance / Math.sin(Math.PI - groundAngle - this.halfFov);\n\n // Calculate z distance of the farthest fragment that should be rendered. \n furthestDistance = pitchAngle * topHalfSurfaceDistance + this.cameraToCenterDistance;\n\n // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`\n farZ = furthestDistance * 1.01;\n // }\n this.cameraTranslateZ = new Matrix4().makeTranslation(0, 0, this.cameraToCenterDistance);\n\n // someday @ansis set further near plane to fix precision for deckgl,so we should fix it to use mapbox-gl v1.3+ correctly\n // https://github.com/mapbox/mapbox-gl-js/commit/5cf6e5f523611bea61dae155db19a7cb19eb825c#diff-5dddfe9d7b5b4413ee54284bc1f7966d\n const nz = (t.height / 50); //min near z as coded by @ansis\n const nearZ = Math.max(nz * pitchAngle, nz); //on changes in the pitch nz could be too low\n\n const h = t.height;\n const w = t.width;\n if (this.camera instanceof OrthographicCamera) {\n this.camera.projectionMatrix = makeOrthographicMatrix(w / -2, w / 2, h / 2, h / -2, nearZ, farZ);\n } else {\n this.camera.projectionMatrix = makePerspectiveMatrix(t._fov, w / h, nearZ, farZ);\n }\n this.camera.projectionMatrix.elements[8] = -offset.x * 2 / t.width;\n this.camera.projectionMatrix.elements[9] = offset.y * 2 / t.height;\n\n // Unlike the Mapbox GL JS camera, separate camera translation and rotation out into its world matrix\n // If this is applied directly to the projection matrix, it will work OK but break raycasting\n let cameraWorldMatrix = this.calcCameraMatrix(t._pitch, t.angle);\n // When terrain layers are included, height of 3D layers must be modified from t_camera.z * worldSize\n if (t.elevation) cameraWorldMatrix.elements[14] = t._camera.position[2] * worldSize;\n //this.camera.matrixWorld.elements is equivalent to t._camera._transform\n this.camera.matrixWorld.copy(cameraWorldMatrix);\n\n let zoomPow = t.scale * this.state.worldSizeRatio;\n // Handle scaling and translation of objects in the map in the world's matrix transform, not the camera\n let scale = new Matrix4();\n let translateMap = new Matrix4();\n let rotateMap = new Matrix4();\n\n scale.makeScale(zoomPow, zoomPow, zoomPow);\n\n let x = t.x || t.point.x;\n let y = t.y || t.point.y;\n translateMap.makeTranslation(-x, y, 0);\n rotateMap.makeRotationZ(Math.PI);\n\n this.world.matrix = new Matrix4()\n .premultiply(rotateMap)\n .premultiply(this.state.translateCenter)\n .premultiply(scale)\n .premultiply(translateMap);\n\n // utils.prettyPrintMatrix(this.camera.projectionMatrix.elements);\n this.map.fire('CameraSynced', { detail: { nearZ: nearZ, farZ: farZ, pitch: t._pitch, angle: t.angle, furthestDistance: furthestDistance, cameraToCenterDistance: this.cameraToCenterDistance, t: this.map.transform, tbProjMatrix: this.camera.projectionMatrix.elements, tbWorldMatrix: this.world.matrix.elements, cameraSyn: CameraSync } });\n\n }\n worldSize() {\n let t = this.map.transform;\n return t.tileSize * t.scale;\n }\n\n worldSizeFromZoom() {\n let t = this.map.transform;\n return Math.pow(2.0, t.zoom) * t.tileSize;\n }\n\n mercatorZfromAltitude(altitude, lat) {\n return altitude / this.circumferenceAtLatitude(lat);\n }\n\n mercatorZfromZoom() {\n return this.cameraToCenterDistance / this.worldSizeFromZoom();\n }\n\n circumferenceAtLatitude(latitude) {\n return constants.EARTH_CIRCUMFERENCE * Math.cos(latitude * Math.PI / 180);\n }\n\n calcCameraMatrix(pitch, angle, trz) {\n const t = this.map.transform;\n const _pitch = (pitch === undefined) ? t._pitch : pitch;\n const _angle = (angle === undefined) ? t.angle : angle;\n const _trz = (trz === undefined) ? this.cameraTranslateZ : trz;\n\n return new Matrix4()\n .premultiply(_trz)\n .premultiply(new Matrix4().makeRotationX(_pitch))\n .premultiply(new Matrix4().makeRotationZ(_angle));\n }\n\n updateCameraState() {\n let t = this.map.transform;\n if (!t.height) return;\n\n // Set camera orientation and move it to a proper distance from the map\n // t._camera.setPitchBearing(t._pitch, t.angle);\n const dir = t._camera.forward();\n const distance = t.cameraToCenterDistance;\n const center = t.point;\n\n // Use camera zoom (if terrain is enabled) to maintain constant altitude to sea level\n const altitude = this.mercatorZfromZoom(t);\n const height = altitude - this.mercatorZfromAltitude(t._centerAltitude, t.center.lat);\n\n // simplified version of: this._worldSizeFromZoom(this._zoomFromMercatorZ(height))\n const updatedWorldSize = t.cameraToCenterDistance / height;\n return [\n center.x / this.worldSize() - (dir[0] * distance) / updatedWorldSize,\n center.y / this.worldSize() - (dir[1] * distance) / updatedWorldSize,\n this.mercatorZfromAltitude(t._centerAltitude, t._center.lat) + (-dir[2] * distance) / updatedWorldSize\n ];\n\n }\n\n getWorldToCamera(worldSize, pixelsPerMeter) {\n // transformation chain from world space to camera space:\n // 1. Height value (z) of renderables is in meters. Scale z coordinate by pixelsPerMeter\n // 2. Transform from pixel coordinates to camera space with cameraMatrix^-1\n // 3. flip Y if required\n // worldToCamera: flip * cam^-1 * zScale\n // cameraToWorld: (flip * cam^-1 * zScale)^-1 => (zScale^-1 * cam * flip^-1)\n let t = this.map.transform;\n const matrix = new Matrix4();\n const matrixT = new Matrix4();\n\n // Compute inverse of camera matrix and post-multiply negated translation\n const o = t._camera._orientation;\n const p = t._camera.position;\n const invPosition = new Vector3(p[0], p[1], p[2]);\n\n const quat = new Quaternion();\n quat.set(o[0], o[1], o[2], o[3]);\n const invOrientation = quat.conjugate();\n invPosition.multiplyScalar(-worldSize);\n\n matrixT.makeTranslation(invPosition.x, invPosition.y, invPosition.z);\n matrix\n .makeRotationFromQuaternion(invOrientation)\n .premultiply(matrixT);\n //this would make the matrix exact to getWorldToCamera but breaks\n //this.translate(matrix.elements, matrix.elements, invPosition);\n // Pre-multiply y (2nd row)\n matrix.elements[1] *= -1.0;\n matrix.elements[5] *= -1.0;\n matrix.elements[9] *= -1.0;\n matrix.elements[13] *= -1.0;\n\n // Post-multiply z (3rd column)\n matrix.elements[8] *= pixelsPerMeter;\n matrix.elements[9] *= pixelsPerMeter;\n matrix.elements[10] *= pixelsPerMeter;\n matrix.elements[11] *= pixelsPerMeter;\n\n return matrix;\n }\n\n translate(out, a, v) {\n let x = v[0] || v.x, y = v[1] || v.y, z = v[2] || v.z;\n let a00, a01, a02, a03;\n let a10, a11, a12, a13;\n let a20, a21, a22, a23;\n if (a === out) {\n out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\n out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\n out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\n out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\n } else {\n a00 = a[0];\n a01 = a[1];\n a02 = a[2];\n a03 = a[3];\n a10 = a[4];\n a11 = a[5];\n a12 = a[6];\n a13 = a[7];\n a20 = a[8];\n a21 = a[9];\n a22 = a[10];\n a23 = a[11];\n out[0] = a00;\n out[1] = a01;\n out[2] = a02;\n out[3] = a03;\n out[4] = a10;\n out[5] = a11;\n out[6] = a12;\n out[7] = a13;\n out[8] = a20;\n out[9] = a21;\n out[10] = a22;\n out[11] = a23;\n out[12] = a00 * x + a10 * y + a20 * z + a[12];\n out[13] = a01 * x + a11 * y + a21 * z + a[13];\n out[14] = a02 * x + a12 * y + a22 * z + a[14];\n out[15] = a03 * x + a13 * y + a23 * z + a[15];\n }\n return out;\n }\n}\n\nfunction makeOrthographicMatrix(left, right, top, bottom, near, far) {\n var out = new Matrix4();\n\n const w = 1.0 / (right - left);\n const h = 1.0 / (top - bottom);\n const p = 1.0 / (far - near);\n\n const x = (right + left) * w;\n const y = (top + bottom) * h;\n const z = near * p;\n\n var newMatrix = [\n 2 * w, 0, 0, 0,\n 0, 2 * h, 0, 0,\n 0, 0, - 1 * p, 0,\n - x, -y, -z, 1\n ]\n\n out.elements = newMatrix\n return out;\n}\n\nfunction makePerspectiveMatrix(fovy, aspect, near, far) {\n\n var out = new Matrix4();\n var f = 1.0 / Math.tan(fovy / 2),\n nf = 1 / (near - far);\n\n var newMatrix = [\n f / aspect, 0, 0, 0,\n 0, f, 0, 0,\n 0, 0, (far + near) * nf, -1,\n 0, 0, (2 * far * near) * nf, 0\n ]\n\n out.elements = newMatrix\n return out;\n}\n\nexport default CameraSync;"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAEC,kBAAkB,EAAEC,UAAU,QAAQ,OAAO;AAC/E,OAAOC,SAAS,MAAO,gBAAgB;AAEvC,MAAMC,UAAU,CAAC;EACbC,WAAWA,CAACC,GAAG,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAC5B,IAAI,CAACF,GAAG,GAAGA,GAAG;IACd,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,MAAM,GAAG,IAAI;IAElB,IAAI,CAACF,MAAM,CAACG,gBAAgB,GAAG,KAAK,CAAC,CAAC;;IAGtC;IACA,IAAI,CAACF,KAAK,GAAGA,KAAK,IAAI,IAAIV,KAAK,CAAC,CAAC;IACjC,IAAI,CAACU,KAAK,CAACG,QAAQ,CAACC,CAAC,GAAG,IAAI,CAACJ,KAAK,CAACG,QAAQ,CAACE,CAAC,GAAGV,SAAS,CAACW,UAAU,GAAG,CAAC;IACxE,IAAI,CAACN,KAAK,CAACE,gBAAgB,GAAG,KAAK;;IAEnC;IACA,IAAI,CAACK,KAAK,GAAG;MACTC,eAAe,EAAE,IAAIjB,OAAO,CAAC,CAAC,CAACkB,eAAe,CAACd,SAAS,CAACW,UAAU,GAAG,CAAC,EAAE,CAACX,SAAS,CAACW,UAAU,GAAG,CAAC,EAAE,CAAC,CAAC;MACtGI,cAAc,EAAEf,SAAS,CAACg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AE,CAACH,GAAG,GAAGD,IAAI,IAAIK,EAAE,EAAE,CAAC,CAAC,EAC3B,CAAC,EAAE,CAAC,EAAG,CAAC,GAAGJ,GAAG,GAAGD,IAAI,GAAIK,EAAE,EAAE,CAAC,CACjC;EAEDxB,GAAG,CAAC7D,QAAQ,GAAGkF,SAAS;EACxB,OAAOrB,GAAG;AACd;AAEA,eAAerH,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Matrix4 } from "three";
|
|
2
|
+
export function makePerspectiveMatrix(fovy, aspect, near, far) {
|
|
3
|
+
var out = new Matrix4();
|
|
4
|
+
var f = 1.0 / Math.tan(fovy / 2),
|
|
5
|
+
nf = 1 / (near - far);
|
|
6
|
+
var newMatrix = [f / aspect, 0, 0, 0, 0, f, 0, 0, 0, 0, (far + near) * nf, -1, 0, 0, 2 * far * near * nf, 0];
|
|
7
|
+
out.elements = newMatrix;
|
|
8
|
+
return out;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//[jscastro] new orthographic matrix calculations https://en.wikipedia.org/wiki/Orthographic_projection and validated with https://bit.ly/3rPvB9Y
|
|
12
|
+
export function makeOrthographicMatrix(left, right, top, bottom, near, far) {
|
|
13
|
+
var out = new Matrix4();
|
|
14
|
+
const w = 1.0 / (right - left);
|
|
15
|
+
const h = 1.0 / (top - bottom);
|
|
16
|
+
const p = 1.0 / (far - near);
|
|
17
|
+
const x = (right + left) * w;
|
|
18
|
+
const y = (top + bottom) * h;
|
|
19
|
+
const z = near * p;
|
|
20
|
+
var newMatrix = [2 * w, 0, 0, 0, 0, 2 * h, 0, 0, 0, 0, -1 * p, 0, -x, -y, -z, 1];
|
|
21
|
+
out.elements = newMatrix;
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
export function clamp(n, min, max) {
|
|
25
|
+
return Math.min(max, Math.max(min, n));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=CameraUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraUtils.js","names":["Matrix4","makePerspectiveMatrix","fovy","aspect","near","far","out","f","Math","tan","nf","newMatrix","elements","makeOrthographicMatrix","left","right","top","bottom","w","h","p","x","y","z","clamp","n","min","max"],"sources":["../../../../../../src/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js"],"sourcesContent":["import { Matrix4 } from \"three\";\n\n\nexport function makePerspectiveMatrix(fovy, aspect, near, far) {\n\n var out = new Matrix4();\n var f = 1.0 / Math.tan(fovy / 2),\n nf = 1 / (near - far);\n\n var newMatrix = [\n f / aspect, 0, 0, 0,\n 0, f, 0, 0,\n 0, 0, (far + near) * nf, -1,\n 0, 0, (2 * far * near) * nf, 0\n ]\n\n out.elements = newMatrix\n return out;\n}\n\n//[jscastro] new orthographic matrix calculations https://en.wikipedia.org/wiki/Orthographic_projection and validated with https://bit.ly/3rPvB9Y\nexport function makeOrthographicMatrix(left, right, top, bottom, near, far) {\n var out = new Matrix4();\n\n const w = 1.0 / (right - left);\n const h = 1.0 / (top - bottom);\n const p = 1.0 / (far - near);\n\n const x = (right + left) * w;\n const y = (top + bottom) * h;\n const z = near * p;\n\n var newMatrix = [\n 2 * w, 0, 0, 0,\n 0, 2 * h, 0, 0,\n 0, 0, - 1 * p, 0,\n - x, -y, -z, 1\n ]\n\n out.elements = newMatrix\n return out;\n}\n\nexport function clamp(n, min, max) {\n return Math.min(max, Math.max(min, n));\n}"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAG/B,OAAO,SAASC,qBAAqBA,CAACC,IAAI,EAAEC,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAE;EAE3D,IAAIC,GAAG,GAAG,IAAIN,OAAO,CAAC,CAAC;EACvB,IAAIO,CAAC,GAAG,GAAG,GAAGC,IAAI,CAACC,GAAG,CAACP,IAAI,GAAG,CAAC,CAAC;IAC5BQ,EAAE,GAAG,CAAC,IAAIN,IAAI,GAAGC,GAAG,CAAC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AACM,QAAQ,GAAGD,SAAS;EACxB,OAAOL,GAAG;AACd;AAEA,OAAO,SAASkB,KAAKA,CAACC,CAAC,EAAEC,GAAG,EAAEC,GAAG,EAAE;EAC/B,OAAOnB,IAAI,CAACkB,GAAG,CAACC,GAAG,EAAEnB,IAAI,CAACmB,GAAG,CAACD,GAAG,EAAED,CAAC,CAAC,CAAC;AAC1C","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const WORLD_SIZE = 1024000; //TILE_SIZE * 2000
|
|
2
|
+
const MERCATOR_A = 6378137.0; // 900913 projection property. (Deprecated) Replaced by EARTH_RADIUS
|
|
3
|
+
const FOV_ORTHO = 0.1 / 180 * Math.PI; //Mapbox doesn't accept 0 as FOV
|
|
4
|
+
const FOV = Math.atan(3 / 4); //from Mapbox https://github.com/mapbox/mapbox-gl-js/blob/main/src/geo/transform.js#L93
|
|
5
|
+
const EARTH_RADIUS = 6371008.8; //from Mapbox https://github.com/mapbox/mapbox-gl-js/blob/0063cbd10a97218fb6a0f64c99bf18609b918f4c/src/geo/lng_lat.js#L11
|
|
6
|
+
const EARTH_CIRCUMFERENCE_EQUATOR = 40075017; //from Mapbox https://github.com/mapbox/mapbox-gl-js/blob/0063cbd10a97218fb6a0f64c99bf18609b918f4c/src/geo/lng_lat.js#L117
|
|
7
|
+
|
|
8
|
+
const constants = {
|
|
9
|
+
WORLD_SIZE: WORLD_SIZE,
|
|
10
|
+
PROJECTION_WORLD_SIZE: WORLD_SIZE / (EARTH_RADIUS * Math.PI * 2),
|
|
11
|
+
MERCATOR_A: EARTH_RADIUS,
|
|
12
|
+
DEG2RAD: Math.PI / 180,
|
|
13
|
+
RAD2DEG: 180 / Math.PI,
|
|
14
|
+
EARTH_RADIUS: EARTH_RADIUS,
|
|
15
|
+
EARTH_CIRCUMFERENCE: 2 * Math.PI * EARTH_RADIUS,
|
|
16
|
+
//40075000, // In meters
|
|
17
|
+
EARTH_CIRCUMFERENCE_EQUATOR: EARTH_CIRCUMFERENCE_EQUATOR,
|
|
18
|
+
FOV_ORTHO: FOV_ORTHO,
|
|
19
|
+
// closest to 0
|
|
20
|
+
FOV: FOV,
|
|
21
|
+
// Math.atan(3/4) radians. If this value is changed, FOV_DEGREES must be calculated
|
|
22
|
+
FOV_DEGREES: FOV * 180 / Math.PI,
|
|
23
|
+
// Math.atan(3/4) in degrees
|
|
24
|
+
TILE_SIZE: 512
|
|
25
|
+
};
|
|
26
|
+
export default constants;
|
|
27
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":["WORLD_SIZE","MERCATOR_A","FOV_ORTHO","Math","PI","FOV","atan","EARTH_RADIUS","EARTH_CIRCUMFERENCE_EQUATOR","constants","PROJECTION_WORLD_SIZE","DEG2RAD","RAD2DEG","EARTH_CIRCUMFERENCE","FOV_DEGREES","TILE_SIZE"],"sources":["../../../../../../src/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js"],"sourcesContent":["const WORLD_SIZE = 1024000; //TILE_SIZE * 2000\nconst MERCATOR_A = 6378137.0; // 900913 projection property. (Deprecated) Replaced by EARTH_RADIUS\nconst FOV_ORTHO = 0.1 / 180 * Math.PI; //Mapbox doesn't accept 0 as FOV\nconst FOV = Math.atan(3 / 4); //from Mapbox https://github.com/mapbox/mapbox-gl-js/blob/main/src/geo/transform.js#L93\nconst EARTH_RADIUS = 6371008.8; //from Mapbox https://github.com/mapbox/mapbox-gl-js/blob/0063cbd10a97218fb6a0f64c99bf18609b918f4c/src/geo/lng_lat.js#L11\nconst EARTH_CIRCUMFERENCE_EQUATOR = 40075017 //from Mapbox https://github.com/mapbox/mapbox-gl-js/blob/0063cbd10a97218fb6a0f64c99bf18609b918f4c/src/geo/lng_lat.js#L117\n\nconst constants = {\n WORLD_SIZE: WORLD_SIZE,\n PROJECTION_WORLD_SIZE: WORLD_SIZE / (EARTH_RADIUS * Math.PI * 2),\n MERCATOR_A: EARTH_RADIUS,\n DEG2RAD: Math.PI / 180,\n RAD2DEG: 180 / Math.PI,\n EARTH_RADIUS: EARTH_RADIUS,\n EARTH_CIRCUMFERENCE: 2 * Math.PI * EARTH_RADIUS, //40075000, // In meters\n EARTH_CIRCUMFERENCE_EQUATOR: EARTH_CIRCUMFERENCE_EQUATOR,\n FOV_ORTHO: FOV_ORTHO, // closest to 0\n FOV: FOV, // Math.atan(3/4) radians. If this value is changed, FOV_DEGREES must be calculated\n FOV_DEGREES: FOV * 180 / Math.PI, // Math.atan(3/4) in degrees\n TILE_SIZE: 512\n}\n\nexport default constants;\n"],"mappings":"AAAA,MAAMA,UAAU,GAAG,OAAO,CAAC,CAAC;AAC5B,MAAMC,UAAU,GAAG,SAAS,CAAC,CAAC;AAC9B,MAAMC,SAAS,GAAG,GAAG,GAAG,GAAG,GAAGC,IAAI,CAACC,EAAE,CAAC,CAAC;AACvC,MAAMC,GAAG,GAAGF,IAAI,CAACG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC9B,MAAMC,YAAY,GAAG,SAAS,CAAC,CAAC;AAChC,MAAMC,2BAA2B,GAAG,QAAQ,EAAC;;AAE7C,MAAMC,SAAS,GAAG;EACdT,UAAU,EAAEA,UAAU;EACtBU,qBAAqB,EAAEV,UAAU,IAAIO,YAAY,GAAGJ,IAAI,CAACC,EAAE,GAAG,CAAC,CAAC;EAChEH,UAAU,EAAEM,YAAY;EACxBI,OAAO,EAAER,IAAI,CAACC,EAAE,GAAG,GAAG;EACtBQ,OAAO,EAAE,GAAG,GAAGT,IAAI,CAACC,EAAE;EACtBG,YAAY,EAAEA,YAAY;EAC1BM,mBAAmB,EAAE,CAAC,GAAGV,IAAI,CAACC,EAAE,GAAGG,YAAY;EAAE;EACjDC,2BAA2B,EAAEA,2BAA2B;EACxDN,SAAS,EAAEA,SAAS;EAAE;EACtBG,GAAG,EAAEA,GAAG;EAAE;EACVS,WAAW,EAAET,GAAG,GAAG,GAAG,GAAGF,IAAI,CAACC,EAAE;EAAE;EAClCW,SAAS,EAAE;AACf,CAAC;AAED,eAAeN,SAAS","ignoreList":[]}
|