t3d-3dtiles 0.1.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/LICENSE +28 -0
- package/README.md +41 -0
- package/build/t3d.3dtiles.js +5418 -0
- package/build/t3d.3dtiles.min.js +2 -0
- package/build/t3d.3dtiles.module.js +6183 -0
- package/examples/jsm/CesiumIon.js +30 -0
- package/examples/jsm/Tiles3DDebugger.js +219 -0
- package/examples/jsm/Tiles3DUtils.js +32 -0
- package/examples/jsm/helpers/LineSegmentHelper.js +74 -0
- package/examples/jsm/helpers/OBBHelper.js +48 -0
- package/examples/jsm/helpers/Tiles3DHelper.js +135 -0
- package/examples/jsm/math/Intersects.js +100 -0
- package/examples/jsm/math/LineSegment.js +234 -0
- package/package.json +57 -0
- package/src/Tiles3D.js +402 -0
- package/src/libs/ImageBitmapLoader.js +56 -0
- package/src/libs/glTF/Constants.js +85 -0
- package/src/libs/glTF/GLTFLoader.js +169 -0
- package/src/libs/glTF/GLTFResource.js +28 -0
- package/src/libs/glTF/GLTFUtils.js +131 -0
- package/src/libs/glTF/extensions/EXT_meshopt_compression.js +35 -0
- package/src/libs/glTF/extensions/KHR_draco_mesh_compression.js +54 -0
- package/src/libs/glTF/extensions/KHR_lights_punctual.js +53 -0
- package/src/libs/glTF/extensions/KHR_materials_clearcoat.js +42 -0
- package/src/libs/glTF/extensions/KHR_materials_pbrSpecularGlossiness.js +53 -0
- package/src/libs/glTF/extensions/KHR_materials_unlit.js +13 -0
- package/src/libs/glTF/extensions/KHR_texture_basisu.js +14 -0
- package/src/libs/glTF/extensions/KHR_texture_transform.js +31 -0
- package/src/libs/glTF/parsers/AccessorParser.js +99 -0
- package/src/libs/glTF/parsers/AnimationParser.js +118 -0
- package/src/libs/glTF/parsers/BufferParser.js +35 -0
- package/src/libs/glTF/parsers/BufferViewParser.js +27 -0
- package/src/libs/glTF/parsers/ImageParser.js +97 -0
- package/src/libs/glTF/parsers/IndexParser.js +22 -0
- package/src/libs/glTF/parsers/MaterialParser.js +146 -0
- package/src/libs/glTF/parsers/NodeParser.js +145 -0
- package/src/libs/glTF/parsers/PrimitiveParser.js +289 -0
- package/src/libs/glTF/parsers/ReferenceParser.js +67 -0
- package/src/libs/glTF/parsers/SceneParser.js +41 -0
- package/src/libs/glTF/parsers/SkinParser.js +53 -0
- package/src/libs/glTF/parsers/TextureParser.js +71 -0
- package/src/libs/glTF/parsers/Validator.js +16 -0
- package/src/loaders/B3DMLoader.js +49 -0
- package/src/loaders/CMPTLoader.js +48 -0
- package/src/loaders/I3DMLoader.js +49 -0
- package/src/loaders/PNTSLoader.js +20 -0
- package/src/loaders/TileGLTFLoader.js +17 -0
- package/src/loaders/parsers/HeaderParser.js +104 -0
- package/src/loaders/parsers/LoadParser.js +22 -0
- package/src/loaders/parsers/TableParser.js +66 -0
- package/src/loaders/parsers/b3dm/B3DMParser.js +18 -0
- package/src/loaders/parsers/b3dm/B3DMRootParser.js +22 -0
- package/src/loaders/parsers/b3dm/MaterialParser.js +156 -0
- package/src/loaders/parsers/cmpt/CMPTParser.js +37 -0
- package/src/loaders/parsers/cmpt/CMPTRootParser.js +44 -0
- package/src/loaders/parsers/gltf/IndexParser.js +24 -0
- package/src/loaders/parsers/i3dm/I3DMParser.js +28 -0
- package/src/loaders/parsers/i3dm/I3DMRootParser.js +123 -0
- package/src/loaders/parsers/i3dm/MaterialParser.js +152 -0
- package/src/loaders/parsers/i3dm/PrimitiveParser.js +291 -0
- package/src/loaders/parsers/pnts/PNTSRootParser.js +69 -0
- package/src/main.js +14 -0
- package/src/materials/InstancedBasicMaterial.js +32 -0
- package/src/materials/InstancedPBRMaterial.js +32 -0
- package/src/materials/InstancedShaderChunks.js +23 -0
- package/src/math/Ellipsoid.js +41 -0
- package/src/math/EllipsoidRegion.js +160 -0
- package/src/math/FastFrustum.js +49 -0
- package/src/math/GeoUtils.js +31 -0
- package/src/math/OBB.js +395 -0
- package/src/math/TileBoundingVolume.js +172 -0
- package/src/math/TileOBB.js +103 -0
- package/src/utils/BatchTable.js +14 -0
- package/src/utils/CameraList.js +131 -0
- package/src/utils/FeatureTable.js +107 -0
- package/src/utils/IntersectionUtils.js +136 -0
- package/src/utils/LRUCache.js +159 -0
- package/src/utils/ModelLoader.js +150 -0
- package/src/utils/PriorityQueue.js +102 -0
- package/src/utils/RequestState.js +17 -0
- package/src/utils/TilesLoader.js +386 -0
- package/src/utils/TilesScheduler.js +375 -0
- package/src/utils/Utils.js +43 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BasicMaterial, ShaderLib, MATERIAL_TYPE } from 't3d';
|
|
2
|
+
import { instancingParsVert, instancingPositionVert, instancingNormalVert } from './InstancedShaderChunks.js';
|
|
3
|
+
|
|
4
|
+
export class InstancedBasicMaterial extends BasicMaterial {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.type = MATERIAL_TYPE.SHADER;
|
|
9
|
+
this.shaderName = 'TILE_I_BASIC';
|
|
10
|
+
this.vertexShader = vertexShader;
|
|
11
|
+
this.fragmentShader = ShaderLib.basic_frag;
|
|
12
|
+
this.defines.USE_INSTANCING = true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
InstancedBasicMaterial.prototype.isInstancedBasicMaterial = true;
|
|
18
|
+
|
|
19
|
+
let vertexShader = ShaderLib.basic_vert;
|
|
20
|
+
|
|
21
|
+
vertexShader = vertexShader.replace('#include <logdepthbuf_pars_vert>', `
|
|
22
|
+
#include <logdepthbuf_pars_vert>
|
|
23
|
+
${instancingParsVert}
|
|
24
|
+
`);
|
|
25
|
+
vertexShader = vertexShader.replace('#include <pvm_vert>', `
|
|
26
|
+
${instancingPositionVert}
|
|
27
|
+
#include <pvm_vert>
|
|
28
|
+
`);
|
|
29
|
+
vertexShader = vertexShader.replace('#include <normal_vert>', `
|
|
30
|
+
${instancingNormalVert}
|
|
31
|
+
#include <normal_vert>
|
|
32
|
+
`);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PBRMaterial, ShaderLib, MATERIAL_TYPE } from 't3d';
|
|
2
|
+
import { instancingParsVert, instancingPositionVert, instancingNormalVert } from './InstancedShaderChunks.js';
|
|
3
|
+
|
|
4
|
+
export class InstancedPBRMaterial extends PBRMaterial {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.type = MATERIAL_TYPE.SHADER;
|
|
9
|
+
this.shaderName = 'TILE_I_PBR';
|
|
10
|
+
this.vertexShader = vertexShader;
|
|
11
|
+
this.fragmentShader = ShaderLib.pbr_frag;
|
|
12
|
+
this.defines.USE_INSTANCING = true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
InstancedPBRMaterial.prototype.isInstancedPBRMaterial = true;
|
|
18
|
+
|
|
19
|
+
let vertexShader = ShaderLib.pbr_vert;
|
|
20
|
+
|
|
21
|
+
vertexShader = vertexShader.replace('#include <logdepthbuf_pars_vert>', `
|
|
22
|
+
#include <logdepthbuf_pars_vert>
|
|
23
|
+
${instancingParsVert}
|
|
24
|
+
`);
|
|
25
|
+
vertexShader = vertexShader.replace('#include <pvm_vert>', `
|
|
26
|
+
${instancingPositionVert}
|
|
27
|
+
#include <pvm_vert>
|
|
28
|
+
`);
|
|
29
|
+
vertexShader = vertexShader.replace('#include <normal_vert>', `
|
|
30
|
+
${instancingNormalVert}
|
|
31
|
+
#include <normal_vert>
|
|
32
|
+
`);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const instancingParsVert = `
|
|
2
|
+
#ifdef USE_INSTANCING
|
|
3
|
+
attribute mat4 instanceMatrix;
|
|
4
|
+
#endif
|
|
5
|
+
`;
|
|
6
|
+
|
|
7
|
+
export const instancingPositionVert = `
|
|
8
|
+
#ifdef USE_INSTANCING
|
|
9
|
+
transformed = (instanceMatrix * vec4(transformed, 1.0)).xyz;
|
|
10
|
+
#endif
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const instancingNormalVert = `
|
|
14
|
+
#ifdef USE_INSTANCING
|
|
15
|
+
#ifdef USE_INSTANCING
|
|
16
|
+
objectNormal = (transposeMat4(inverseMat4(instanceMatrix)) * vec4(objectNormal, 0.0)).xyz;
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
#ifdef USE_TANGENT
|
|
20
|
+
objectTangent = (transposeMat4(inverseMat4(instanceMatrix)) * vec4(objectTangent, 0.0)).xyz;
|
|
21
|
+
#endif
|
|
22
|
+
#endif
|
|
23
|
+
`;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Spherical, Vector3 } from 't3d';
|
|
2
|
+
import { swapToGeoFrame, latitudeToSphericalPhi } from './GeoUtils.js';
|
|
3
|
+
|
|
4
|
+
export class Ellipsoid {
|
|
5
|
+
|
|
6
|
+
constructor(radius = new Vector3(1, 1, 1)) {
|
|
7
|
+
this.radius = radius;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getCartographicToPosition(lat, lon, height, target) {
|
|
11
|
+
// From Cesium function Ellipsoid.cartographicToCartesian
|
|
12
|
+
// https://github.com/CesiumGS/cesium/blob/665ec32e813d5d6fe906ec3e87187f6c38ed5e49/packages/engine/Source/Core/Ellipsoid.js#L396
|
|
13
|
+
this.getCartographicToNormal(lat, lon, _norm);
|
|
14
|
+
|
|
15
|
+
const radius = this.radius;
|
|
16
|
+
_vec3_1.copy(_norm);
|
|
17
|
+
_vec3_1.x *= radius.x ** 2;
|
|
18
|
+
_vec3_1.y *= radius.y ** 2;
|
|
19
|
+
_vec3_1.z *= radius.z ** 2;
|
|
20
|
+
|
|
21
|
+
const gamma = Math.sqrt(_norm.dot(_vec3_1));
|
|
22
|
+
_vec3_1.multiplyScalar(1 / gamma);
|
|
23
|
+
|
|
24
|
+
return target.copy(_vec3_1).addScaledVector(_norm, height);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getCartographicToNormal(lat, lon, target) {
|
|
28
|
+
_spherical.set(1, latitudeToSphericalPhi(lat), lon);
|
|
29
|
+
target.setFromSpherical(_spherical).normalize();
|
|
30
|
+
|
|
31
|
+
// swap frame from the t3d.js frame to the geo coord frame
|
|
32
|
+
swapToGeoFrame(target);
|
|
33
|
+
return target;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const _norm = new Vector3();
|
|
39
|
+
const _spherical = new Spherical();
|
|
40
|
+
|
|
41
|
+
const _vec3_1 = new Vector3();
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Matrix4, Vector2, Vector3 } from 't3d';
|
|
2
|
+
import { Ellipsoid } from './Ellipsoid.js';
|
|
3
|
+
|
|
4
|
+
export class EllipsoidRegion extends Ellipsoid {
|
|
5
|
+
|
|
6
|
+
constructor(
|
|
7
|
+
radius = new Vector3(1, 1, 1),
|
|
8
|
+
latRange = new Vector2(-HALF_PI, HALF_PI),
|
|
9
|
+
lonRange = new Vector2(0, 2 * PI),
|
|
10
|
+
heightRange = new Vector2(0, 1)
|
|
11
|
+
) {
|
|
12
|
+
super(radius);
|
|
13
|
+
|
|
14
|
+
this.latRange = latRange;
|
|
15
|
+
this.lonRange = lonRange;
|
|
16
|
+
this.heightRange = heightRange;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// refer to https://github.com/CesiumGS/cesium/blob/1.119/packages/engine/Source/Core/OrientedBoundingBox.js#L343
|
|
20
|
+
// refer to https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/c46d59c674e9ac1e652b9e9b65849bf02a645a6a/src/three/math/EllipsoidRegion.js#L120
|
|
21
|
+
getOrientedBoundingBox(target) {
|
|
22
|
+
resetPool();
|
|
23
|
+
|
|
24
|
+
const { latRange, lonRange } = this;
|
|
25
|
+
|
|
26
|
+
const latRangeValue = latRange.y - latRange.x;
|
|
27
|
+
|
|
28
|
+
if (latRangeValue < PI / 2) {
|
|
29
|
+
// get the midway point for the region
|
|
30
|
+
const midLat = mapLinear(0.5, 0, 1, latRange.x, latRange.y);
|
|
31
|
+
const midLon = mapLinear(0.5, 0, 1, lonRange.x, lonRange.y);
|
|
32
|
+
|
|
33
|
+
// get the frame matrix for the box - works well for smaller regions
|
|
34
|
+
this.getCartographicToNormal(midLat, midLon, _orthoZ);
|
|
35
|
+
_orthoY.set(0, 0, 1);
|
|
36
|
+
_orthoX.crossVectors(_orthoY, _orthoZ);
|
|
37
|
+
_orthoY.crossVectors(_orthoX, _orthoZ);
|
|
38
|
+
} else {
|
|
39
|
+
_orthoX.set(1, 0, 0);
|
|
40
|
+
_orthoY.set(0, 1, 0);
|
|
41
|
+
_orthoZ.set(0, 0, 1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
target.rotation.set(
|
|
45
|
+
_orthoX.x, _orthoY.x, _orthoZ.x,
|
|
46
|
+
_orthoX.y, _orthoY.y, _orthoZ.y,
|
|
47
|
+
_orthoX.z, _orthoY.z, _orthoZ.z
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// transform the points into the local frame
|
|
51
|
+
_invMatrix.setFromMatrix3(target.rotation).inverse();
|
|
52
|
+
|
|
53
|
+
const points = this._getPoints(true);
|
|
54
|
+
|
|
55
|
+
// get the center of the region
|
|
56
|
+
_center.set(0, 0, 0);
|
|
57
|
+
for (let i = 0, l = points.length; i < l; i++) {
|
|
58
|
+
_center.add(points[i]);
|
|
59
|
+
}
|
|
60
|
+
_center.multiplyScalar(1 / points.length);
|
|
61
|
+
|
|
62
|
+
for (let i = 0, l = points.length; i < l; i++) {
|
|
63
|
+
points[i].sub(_center).applyMatrix4(_invMatrix).add(_center);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
target.box.makeEmpty();
|
|
67
|
+
target.box.setFromPoints(points);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getBoundingSphere(target) {
|
|
71
|
+
resetPool();
|
|
72
|
+
|
|
73
|
+
const points = this._getPoints(true);
|
|
74
|
+
target.makeEmpty();
|
|
75
|
+
target.setFromPoints(points);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_getPoints(usePool = false) {
|
|
79
|
+
const { latRange, lonRange, heightRange } = this;
|
|
80
|
+
|
|
81
|
+
const midLat = mapLinear(0.5, 0, 1, latRange.x, latRange.y);
|
|
82
|
+
const midLon = mapLinear(0.5, 0, 1, lonRange.x, lonRange.y);
|
|
83
|
+
|
|
84
|
+
const lonOffset = Math.floor(lonRange.x / HALF_PI) * HALF_PI;
|
|
85
|
+
|
|
86
|
+
const latlon = [
|
|
87
|
+
[-PI / 2, 0],
|
|
88
|
+
[PI / 2, 0],
|
|
89
|
+
[0, lonOffset],
|
|
90
|
+
[0, lonOffset + PI / 2],
|
|
91
|
+
[0, lonOffset + PI],
|
|
92
|
+
[0, lonOffset + 3 * PI / 2],
|
|
93
|
+
|
|
94
|
+
[latRange.x, lonRange.y],
|
|
95
|
+
[latRange.y, lonRange.y],
|
|
96
|
+
[latRange.x, lonRange.x],
|
|
97
|
+
[latRange.y, lonRange.x],
|
|
98
|
+
|
|
99
|
+
[0, lonRange.x],
|
|
100
|
+
[0, lonRange.y],
|
|
101
|
+
|
|
102
|
+
[midLat, midLon],
|
|
103
|
+
[latRange.x, midLon],
|
|
104
|
+
[latRange.y, midLon],
|
|
105
|
+
[midLat, lonRange.x],
|
|
106
|
+
[midLat, lonRange.y]
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
const target = [];
|
|
110
|
+
const total = latlon.length;
|
|
111
|
+
|
|
112
|
+
for (let z = 0; z <= 1; z++) {
|
|
113
|
+
const height = mapLinear(z, 0, 1, heightRange.x, heightRange.y);
|
|
114
|
+
for (let i = 0, l = total; i < l; i++) {
|
|
115
|
+
const [lat, lon] = latlon[i];
|
|
116
|
+
if (lat >= latRange.x && lat <= latRange.y && lon >= lonRange.x && lon <= lonRange.y) {
|
|
117
|
+
const v = getVector(usePool);
|
|
118
|
+
target.push(v);
|
|
119
|
+
this.getCartographicToPosition(lat, lon, height, v);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return target;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const _orthoX = new Vector3();
|
|
130
|
+
const _orthoY = new Vector3();
|
|
131
|
+
const _orthoZ = new Vector3();
|
|
132
|
+
const _center = new Vector3();
|
|
133
|
+
const _invMatrix = new Matrix4();
|
|
134
|
+
|
|
135
|
+
const PI = Math.PI;
|
|
136
|
+
const HALF_PI = PI / 2;
|
|
137
|
+
|
|
138
|
+
// Linear mapping from range <a1, a2> to range <b1, b2>
|
|
139
|
+
function mapLinear(x, a1, a2, b1, b2) {
|
|
140
|
+
return b1 + (x - a1) * (b2 - b1) / (a2 - a1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let _poolIndex = 0;
|
|
144
|
+
const _pointsPool = [];
|
|
145
|
+
function getVector(usePool = false) {
|
|
146
|
+
if (!usePool) {
|
|
147
|
+
return new Vector3();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!_pointsPool[_poolIndex]) {
|
|
151
|
+
_pointsPool[_poolIndex] = new Vector3();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_poolIndex++;
|
|
155
|
+
return _pointsPool[_poolIndex - 1];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function resetPool() {
|
|
159
|
+
_poolIndex = 0;
|
|
160
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Frustum, Matrix3, Vector3 } from 't3d';
|
|
2
|
+
|
|
3
|
+
export class FastFrustum extends Frustum {
|
|
4
|
+
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.points = new Array(8).fill().map(() => new Vector3());
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
updateCache() {
|
|
12
|
+
const { planes, points } = this;
|
|
13
|
+
const planeIntersections = [
|
|
14
|
+
[planes[0], planes[3], planes[4]], // Near top left
|
|
15
|
+
[planes[1], planes[3], planes[4]], // Near top right
|
|
16
|
+
[planes[0], planes[2], planes[4]], // Near bottom left
|
|
17
|
+
[planes[1], planes[2], planes[4]], // Near bottom right
|
|
18
|
+
[planes[0], planes[3], planes[5]], // Far top left
|
|
19
|
+
[planes[1], planes[3], planes[5]], // Far top right
|
|
20
|
+
[planes[0], planes[2], planes[5]], // Far bottom left
|
|
21
|
+
[planes[1], planes[2], planes[5]] // Far bottom right
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
planeIntersections.forEach((planes, index) => {
|
|
25
|
+
findIntersectionPoint(planes[0], planes[1], planes[2], points[index]);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const _mat3_1 = new Matrix3();
|
|
32
|
+
|
|
33
|
+
// Solve a system of equations to find the point where the three planes intersect
|
|
34
|
+
function findIntersectionPoint(plane1, plane2, plane3, target) {
|
|
35
|
+
// Create the matrix A using the normals of the planes as rows
|
|
36
|
+
const A = _mat3_1.set(
|
|
37
|
+
plane1.normal.x, plane1.normal.y, plane1.normal.z,
|
|
38
|
+
plane2.normal.x, plane2.normal.y, plane2.normal.z,
|
|
39
|
+
plane3.normal.x, plane3.normal.y, plane3.normal.z
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Create the vector B using the constants of the planes
|
|
43
|
+
target.set(-plane1.constant, -plane2.constant, -plane3.constant);
|
|
44
|
+
|
|
45
|
+
// Solve for X by applying the inverse matrix to B
|
|
46
|
+
target.applyMatrix3(A.inverse());
|
|
47
|
+
|
|
48
|
+
return target;
|
|
49
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Cesium / 3D tiles Spheroid:
|
|
2
|
+
// - Up is Z at 90 degrees latitude
|
|
3
|
+
// - 0, 0 latitude, longitude is X axis
|
|
4
|
+
// Z
|
|
5
|
+
// |
|
|
6
|
+
// |
|
|
7
|
+
// .----- Y
|
|
8
|
+
// /
|
|
9
|
+
// X
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// t3d.js Spherical Coordinates
|
|
13
|
+
// - Up is Y at 90 degrees latitude
|
|
14
|
+
// - 0, 0 latitude, longitude is Z
|
|
15
|
+
// Y
|
|
16
|
+
// |
|
|
17
|
+
// |
|
|
18
|
+
// .----- X
|
|
19
|
+
// /
|
|
20
|
+
// Z
|
|
21
|
+
|
|
22
|
+
export function swapToGeoFrame(target) {
|
|
23
|
+
const { x, y, z } = target;
|
|
24
|
+
target.x = z;
|
|
25
|
+
target.y = x;
|
|
26
|
+
target.z = y;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function latitudeToSphericalPhi(latitude) {
|
|
30
|
+
return -latitude + Math.PI / 2;
|
|
31
|
+
}
|