deeptwins-cesium-engine 0.0.3 → 0.0.4
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/Build/Workers/chunk-25U3LB43.js +139 -0
- package/Build/Workers/chunk-2GSMCVKA.js +837 -0
- package/Build/Workers/chunk-3G3JCTFQ.js +101 -0
- package/Build/Workers/chunk-3GRIO7U2.js +162 -0
- package/Build/Workers/chunk-3ZQ33WD3.js +455 -0
- package/Build/Workers/chunk-4U7LLSJ4.js +288 -0
- package/Build/Workers/chunk-4ZMC542T.js +55 -0
- package/Build/Workers/chunk-57TENMAK.js +37 -0
- package/Build/Workers/chunk-5JCUBAVN.js +387 -0
- package/Build/Workers/chunk-5MAQRQUK.js +102 -0
- package/Build/Workers/chunk-5XRGC6C7.js +299 -0
- package/Build/Workers/chunk-63UAUZT6.js +414 -0
- package/Build/Workers/chunk-6BUOGRYV.js +2058 -0
- package/Build/Workers/chunk-7D5ZXLGY.js +163 -0
- package/Build/Workers/chunk-7N66TCUJ.js +1800 -0
- package/Build/Workers/chunk-AG6ARNCB.js +682 -0
- package/Build/Workers/chunk-ARXSS5JC.js +788 -0
- package/Build/Workers/chunk-BDVACEHF.js +778 -0
- package/Build/Workers/chunk-BU67FVEG.js +97 -0
- package/Build/Workers/chunk-BYC4YR4M.js +352 -0
- package/Build/Workers/chunk-CH66JW7J.js +629 -0
- package/Build/Workers/chunk-CV2CR5WA.js +114 -0
- package/Build/Workers/chunk-DGMXFRAL.js +1443 -0
- package/Build/Workers/chunk-EDP33VH5.js +1054 -0
- package/Build/Workers/chunk-F7AOI3UD.js +73 -0
- package/Build/Workers/chunk-FKKSB7ZT.js +8366 -0
- package/Build/Workers/chunk-FTK6K2HA.js +1483 -0
- package/Build/Workers/chunk-IUPJ4QGV.js +476 -0
- package/Build/Workers/chunk-K7Z6W3PJ.js +368 -0
- package/Build/Workers/chunk-KBCQ5JGP.js +57 -0
- package/Build/Workers/chunk-KKTCNH5B.js +398 -0
- package/Build/Workers/chunk-LCSOUDEK.js +58 -0
- package/Build/Workers/chunk-LE5B7M4M.js +642 -0
- package/Build/Workers/chunk-LPPTJ7CE.js +511 -0
- package/Build/Workers/chunk-M3CFFEB7.js +280 -0
- package/Build/Workers/chunk-NN52QO5J.js +497 -0
- package/Build/Workers/chunk-NO3BDHBF.js +241 -0
- package/Build/Workers/chunk-O2H3UW6F.js +256 -0
- package/Build/Workers/chunk-OLJ7MBC7.js +439 -0
- package/Build/Workers/chunk-OZMVAGFQ.js +2719 -0
- package/Build/Workers/chunk-P3S5BWX6.js +219 -0
- package/Build/Workers/chunk-PLQPDE4E.js +171 -0
- package/Build/Workers/chunk-PYMMZCF6.js +3514 -0
- package/Build/Workers/chunk-QIK67M72.js +692 -0
- package/Build/Workers/chunk-RDQU66WA.js +124 -0
- package/Build/Workers/chunk-S6YC56IM.js +940 -0
- package/Build/Workers/chunk-S7CL5IXE.js +138 -0
- package/Build/Workers/chunk-SCVFHATG.js +1317 -0
- package/Build/Workers/chunk-V3IFABPY.js +44 -0
- package/Build/Workers/chunk-VKRSYA3C.js +1067 -0
- package/Build/Workers/chunk-VXIA6U3E.js +75 -0
- package/Build/Workers/chunk-WKTTAMO3.js +305 -0
- package/Build/Workers/chunk-WMMHNRGJ.js +198 -0
- package/Build/Workers/chunk-WY6ZUQRU.js +55 -0
- package/Build/Workers/chunk-X33W4QLH.js +958 -0
- package/Build/Workers/chunk-ZB5XJVWP.js +1460 -0
- package/Build/Workers/chunk-ZNQU6MNK.js +352 -0
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/README.md +1 -1
- package/Source/Scene/DerivedCommand.js +1 -1
- package/Source/Scene/VoxelContent.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +9 -9
- package/package.json +7 -11
|
@@ -0,0 +1,1443 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Cesium - https://github.com/CesiumGS/cesium
|
|
4
|
+
* Version 0.0.29
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2011-2022 Cesium Contributors
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*
|
|
20
|
+
* Columbus View (Pat. Pend.)
|
|
21
|
+
*
|
|
22
|
+
* Portions licensed separately.
|
|
23
|
+
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
Math_default
|
|
28
|
+
} from "./chunk-NN52QO5J.js";
|
|
29
|
+
import {
|
|
30
|
+
Check_default,
|
|
31
|
+
DeveloperError_default
|
|
32
|
+
} from "./chunk-7D5ZXLGY.js";
|
|
33
|
+
import {
|
|
34
|
+
defined_default
|
|
35
|
+
} from "./chunk-VXIA6U3E.js";
|
|
36
|
+
|
|
37
|
+
// packages/engine/Source/Core/Cartesian3.js
|
|
38
|
+
function Cartesian3(x, y, z) {
|
|
39
|
+
this.x = x ?? 0;
|
|
40
|
+
this.y = y ?? 0;
|
|
41
|
+
this.z = z ?? 0;
|
|
42
|
+
}
|
|
43
|
+
Cartesian3.fromSpherical = function(spherical, result) {
|
|
44
|
+
Check_default.typeOf.object("spherical", spherical);
|
|
45
|
+
if (!defined_default(result)) {
|
|
46
|
+
result = new Cartesian3();
|
|
47
|
+
}
|
|
48
|
+
const clock = spherical.clock;
|
|
49
|
+
const cone = spherical.cone;
|
|
50
|
+
const magnitude = spherical.magnitude ?? 1;
|
|
51
|
+
const radial = magnitude * Math.sin(cone);
|
|
52
|
+
result.x = radial * Math.cos(clock);
|
|
53
|
+
result.y = radial * Math.sin(clock);
|
|
54
|
+
result.z = magnitude * Math.cos(cone);
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
Cartesian3.fromElements = function(x, y, z, result) {
|
|
58
|
+
if (!defined_default(result)) {
|
|
59
|
+
return new Cartesian3(x, y, z);
|
|
60
|
+
}
|
|
61
|
+
result.x = x;
|
|
62
|
+
result.y = y;
|
|
63
|
+
result.z = z;
|
|
64
|
+
return result;
|
|
65
|
+
};
|
|
66
|
+
Cartesian3.clone = function(cartesian, result) {
|
|
67
|
+
if (!defined_default(cartesian)) {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
if (!defined_default(result)) {
|
|
71
|
+
return new Cartesian3(cartesian.x, cartesian.y, cartesian.z);
|
|
72
|
+
}
|
|
73
|
+
result.x = cartesian.x;
|
|
74
|
+
result.y = cartesian.y;
|
|
75
|
+
result.z = cartesian.z;
|
|
76
|
+
return result;
|
|
77
|
+
};
|
|
78
|
+
Cartesian3.fromCartesian4 = Cartesian3.clone;
|
|
79
|
+
Cartesian3.packedLength = 3;
|
|
80
|
+
Cartesian3.pack = function(value, array, startingIndex) {
|
|
81
|
+
Check_default.typeOf.object("value", value);
|
|
82
|
+
Check_default.defined("array", array);
|
|
83
|
+
startingIndex = startingIndex ?? 0;
|
|
84
|
+
array[startingIndex++] = value.x;
|
|
85
|
+
array[startingIndex++] = value.y;
|
|
86
|
+
array[startingIndex] = value.z;
|
|
87
|
+
return array;
|
|
88
|
+
};
|
|
89
|
+
Cartesian3.unpack = function(array, startingIndex, result) {
|
|
90
|
+
Check_default.defined("array", array);
|
|
91
|
+
startingIndex = startingIndex ?? 0;
|
|
92
|
+
if (!defined_default(result)) {
|
|
93
|
+
result = new Cartesian3();
|
|
94
|
+
}
|
|
95
|
+
result.x = array[startingIndex++];
|
|
96
|
+
result.y = array[startingIndex++];
|
|
97
|
+
result.z = array[startingIndex];
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
Cartesian3.packArray = function(array, result) {
|
|
101
|
+
Check_default.defined("array", array);
|
|
102
|
+
const length = array.length;
|
|
103
|
+
const resultLength = length * 3;
|
|
104
|
+
if (!defined_default(result)) {
|
|
105
|
+
result = new Array(resultLength);
|
|
106
|
+
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
107
|
+
throw new DeveloperError_default(
|
|
108
|
+
"If result is a typed array, it must have exactly array.length * 3 elements"
|
|
109
|
+
);
|
|
110
|
+
} else if (result.length !== resultLength) {
|
|
111
|
+
result.length = resultLength;
|
|
112
|
+
}
|
|
113
|
+
for (let i = 0; i < length; ++i) {
|
|
114
|
+
Cartesian3.pack(array[i], result, i * 3);
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
};
|
|
118
|
+
Cartesian3.unpackArray = function(array, result) {
|
|
119
|
+
Check_default.defined("array", array);
|
|
120
|
+
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 3);
|
|
121
|
+
if (array.length % 3 !== 0) {
|
|
122
|
+
throw new DeveloperError_default("array length must be a multiple of 3.");
|
|
123
|
+
}
|
|
124
|
+
const length = array.length;
|
|
125
|
+
if (!defined_default(result)) {
|
|
126
|
+
result = new Array(length / 3);
|
|
127
|
+
} else {
|
|
128
|
+
result.length = length / 3;
|
|
129
|
+
}
|
|
130
|
+
for (let i = 0; i < length; i += 3) {
|
|
131
|
+
const index = i / 3;
|
|
132
|
+
result[index] = Cartesian3.unpack(array, i, result[index]);
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
};
|
|
136
|
+
Cartesian3.fromArray = Cartesian3.unpack;
|
|
137
|
+
Cartesian3.maximumComponent = function(cartesian) {
|
|
138
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
139
|
+
return Math.max(cartesian.x, cartesian.y, cartesian.z);
|
|
140
|
+
};
|
|
141
|
+
Cartesian3.minimumComponent = function(cartesian) {
|
|
142
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
143
|
+
return Math.min(cartesian.x, cartesian.y, cartesian.z);
|
|
144
|
+
};
|
|
145
|
+
Cartesian3.minimumByComponent = function(first, second, result) {
|
|
146
|
+
Check_default.typeOf.object("first", first);
|
|
147
|
+
Check_default.typeOf.object("second", second);
|
|
148
|
+
Check_default.typeOf.object("result", result);
|
|
149
|
+
result.x = Math.min(first.x, second.x);
|
|
150
|
+
result.y = Math.min(first.y, second.y);
|
|
151
|
+
result.z = Math.min(first.z, second.z);
|
|
152
|
+
return result;
|
|
153
|
+
};
|
|
154
|
+
Cartesian3.maximumByComponent = function(first, second, result) {
|
|
155
|
+
Check_default.typeOf.object("first", first);
|
|
156
|
+
Check_default.typeOf.object("second", second);
|
|
157
|
+
Check_default.typeOf.object("result", result);
|
|
158
|
+
result.x = Math.max(first.x, second.x);
|
|
159
|
+
result.y = Math.max(first.y, second.y);
|
|
160
|
+
result.z = Math.max(first.z, second.z);
|
|
161
|
+
return result;
|
|
162
|
+
};
|
|
163
|
+
Cartesian3.clamp = function(value, min, max, result) {
|
|
164
|
+
Check_default.typeOf.object("value", value);
|
|
165
|
+
Check_default.typeOf.object("min", min);
|
|
166
|
+
Check_default.typeOf.object("max", max);
|
|
167
|
+
Check_default.typeOf.object("result", result);
|
|
168
|
+
const x = Math_default.clamp(value.x, min.x, max.x);
|
|
169
|
+
const y = Math_default.clamp(value.y, min.y, max.y);
|
|
170
|
+
const z = Math_default.clamp(value.z, min.z, max.z);
|
|
171
|
+
result.x = x;
|
|
172
|
+
result.y = y;
|
|
173
|
+
result.z = z;
|
|
174
|
+
return result;
|
|
175
|
+
};
|
|
176
|
+
Cartesian3.magnitudeSquared = function(cartesian) {
|
|
177
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
178
|
+
return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z;
|
|
179
|
+
};
|
|
180
|
+
Cartesian3.magnitude = function(cartesian) {
|
|
181
|
+
return Math.sqrt(Cartesian3.magnitudeSquared(cartesian));
|
|
182
|
+
};
|
|
183
|
+
var distanceScratch = new Cartesian3();
|
|
184
|
+
Cartesian3.distance = function(left, right) {
|
|
185
|
+
Check_default.typeOf.object("left", left);
|
|
186
|
+
Check_default.typeOf.object("right", right);
|
|
187
|
+
Cartesian3.subtract(left, right, distanceScratch);
|
|
188
|
+
return Cartesian3.magnitude(distanceScratch);
|
|
189
|
+
};
|
|
190
|
+
Cartesian3.distanceSquared = function(left, right) {
|
|
191
|
+
Check_default.typeOf.object("left", left);
|
|
192
|
+
Check_default.typeOf.object("right", right);
|
|
193
|
+
Cartesian3.subtract(left, right, distanceScratch);
|
|
194
|
+
return Cartesian3.magnitudeSquared(distanceScratch);
|
|
195
|
+
};
|
|
196
|
+
Cartesian3.normalize = function(cartesian, result) {
|
|
197
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
198
|
+
Check_default.typeOf.object("result", result);
|
|
199
|
+
const magnitude = Cartesian3.magnitude(cartesian);
|
|
200
|
+
result.x = cartesian.x / magnitude;
|
|
201
|
+
result.y = cartesian.y / magnitude;
|
|
202
|
+
result.z = cartesian.z / magnitude;
|
|
203
|
+
if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z)) {
|
|
204
|
+
throw new DeveloperError_default("normalized result is not a number");
|
|
205
|
+
}
|
|
206
|
+
return result;
|
|
207
|
+
};
|
|
208
|
+
Cartesian3.dot = function(left, right) {
|
|
209
|
+
Check_default.typeOf.object("left", left);
|
|
210
|
+
Check_default.typeOf.object("right", right);
|
|
211
|
+
return left.x * right.x + left.y * right.y + left.z * right.z;
|
|
212
|
+
};
|
|
213
|
+
Cartesian3.multiplyComponents = function(left, right, result) {
|
|
214
|
+
Check_default.typeOf.object("left", left);
|
|
215
|
+
Check_default.typeOf.object("right", right);
|
|
216
|
+
Check_default.typeOf.object("result", result);
|
|
217
|
+
result.x = left.x * right.x;
|
|
218
|
+
result.y = left.y * right.y;
|
|
219
|
+
result.z = left.z * right.z;
|
|
220
|
+
return result;
|
|
221
|
+
};
|
|
222
|
+
Cartesian3.divideComponents = function(left, right, result) {
|
|
223
|
+
Check_default.typeOf.object("left", left);
|
|
224
|
+
Check_default.typeOf.object("right", right);
|
|
225
|
+
Check_default.typeOf.object("result", result);
|
|
226
|
+
result.x = left.x / right.x;
|
|
227
|
+
result.y = left.y / right.y;
|
|
228
|
+
result.z = left.z / right.z;
|
|
229
|
+
return result;
|
|
230
|
+
};
|
|
231
|
+
Cartesian3.add = function(left, right, result) {
|
|
232
|
+
Check_default.typeOf.object("left", left);
|
|
233
|
+
Check_default.typeOf.object("right", right);
|
|
234
|
+
Check_default.typeOf.object("result", result);
|
|
235
|
+
result.x = left.x + right.x;
|
|
236
|
+
result.y = left.y + right.y;
|
|
237
|
+
result.z = left.z + right.z;
|
|
238
|
+
return result;
|
|
239
|
+
};
|
|
240
|
+
Cartesian3.subtract = function(left, right, result) {
|
|
241
|
+
Check_default.typeOf.object("left", left);
|
|
242
|
+
Check_default.typeOf.object("right", right);
|
|
243
|
+
Check_default.typeOf.object("result", result);
|
|
244
|
+
result.x = left.x - right.x;
|
|
245
|
+
result.y = left.y - right.y;
|
|
246
|
+
result.z = left.z - right.z;
|
|
247
|
+
return result;
|
|
248
|
+
};
|
|
249
|
+
Cartesian3.multiplyByScalar = function(cartesian, scalar, result) {
|
|
250
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
251
|
+
Check_default.typeOf.number("scalar", scalar);
|
|
252
|
+
Check_default.typeOf.object("result", result);
|
|
253
|
+
result.x = cartesian.x * scalar;
|
|
254
|
+
result.y = cartesian.y * scalar;
|
|
255
|
+
result.z = cartesian.z * scalar;
|
|
256
|
+
return result;
|
|
257
|
+
};
|
|
258
|
+
Cartesian3.divideByScalar = function(cartesian, scalar, result) {
|
|
259
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
260
|
+
Check_default.typeOf.number("scalar", scalar);
|
|
261
|
+
Check_default.typeOf.object("result", result);
|
|
262
|
+
result.x = cartesian.x / scalar;
|
|
263
|
+
result.y = cartesian.y / scalar;
|
|
264
|
+
result.z = cartesian.z / scalar;
|
|
265
|
+
return result;
|
|
266
|
+
};
|
|
267
|
+
Cartesian3.negate = function(cartesian, result) {
|
|
268
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
269
|
+
Check_default.typeOf.object("result", result);
|
|
270
|
+
result.x = -cartesian.x;
|
|
271
|
+
result.y = -cartesian.y;
|
|
272
|
+
result.z = -cartesian.z;
|
|
273
|
+
return result;
|
|
274
|
+
};
|
|
275
|
+
Cartesian3.abs = function(cartesian, result) {
|
|
276
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
277
|
+
Check_default.typeOf.object("result", result);
|
|
278
|
+
result.x = Math.abs(cartesian.x);
|
|
279
|
+
result.y = Math.abs(cartesian.y);
|
|
280
|
+
result.z = Math.abs(cartesian.z);
|
|
281
|
+
return result;
|
|
282
|
+
};
|
|
283
|
+
var lerpScratch = new Cartesian3();
|
|
284
|
+
Cartesian3.lerp = function(start, end, t, result) {
|
|
285
|
+
Check_default.typeOf.object("start", start);
|
|
286
|
+
Check_default.typeOf.object("end", end);
|
|
287
|
+
Check_default.typeOf.number("t", t);
|
|
288
|
+
Check_default.typeOf.object("result", result);
|
|
289
|
+
Cartesian3.multiplyByScalar(end, t, lerpScratch);
|
|
290
|
+
result = Cartesian3.multiplyByScalar(start, 1 - t, result);
|
|
291
|
+
return Cartesian3.add(lerpScratch, result, result);
|
|
292
|
+
};
|
|
293
|
+
var angleBetweenScratch = new Cartesian3();
|
|
294
|
+
var angleBetweenScratch2 = new Cartesian3();
|
|
295
|
+
Cartesian3.angleBetween = function(left, right) {
|
|
296
|
+
Check_default.typeOf.object("left", left);
|
|
297
|
+
Check_default.typeOf.object("right", right);
|
|
298
|
+
Cartesian3.normalize(left, angleBetweenScratch);
|
|
299
|
+
Cartesian3.normalize(right, angleBetweenScratch2);
|
|
300
|
+
const cosine = Cartesian3.dot(angleBetweenScratch, angleBetweenScratch2);
|
|
301
|
+
const sine = Cartesian3.magnitude(
|
|
302
|
+
Cartesian3.cross(
|
|
303
|
+
angleBetweenScratch,
|
|
304
|
+
angleBetweenScratch2,
|
|
305
|
+
angleBetweenScratch
|
|
306
|
+
)
|
|
307
|
+
);
|
|
308
|
+
return Math.atan2(sine, cosine);
|
|
309
|
+
};
|
|
310
|
+
var mostOrthogonalAxisScratch = new Cartesian3();
|
|
311
|
+
Cartesian3.mostOrthogonalAxis = function(cartesian, result) {
|
|
312
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
313
|
+
Check_default.typeOf.object("result", result);
|
|
314
|
+
const f = Cartesian3.normalize(cartesian, mostOrthogonalAxisScratch);
|
|
315
|
+
Cartesian3.abs(f, f);
|
|
316
|
+
if (f.x <= f.y) {
|
|
317
|
+
if (f.x <= f.z) {
|
|
318
|
+
result = Cartesian3.clone(Cartesian3.UNIT_X, result);
|
|
319
|
+
} else {
|
|
320
|
+
result = Cartesian3.clone(Cartesian3.UNIT_Z, result);
|
|
321
|
+
}
|
|
322
|
+
} else if (f.y <= f.z) {
|
|
323
|
+
result = Cartesian3.clone(Cartesian3.UNIT_Y, result);
|
|
324
|
+
} else {
|
|
325
|
+
result = Cartesian3.clone(Cartesian3.UNIT_Z, result);
|
|
326
|
+
}
|
|
327
|
+
return result;
|
|
328
|
+
};
|
|
329
|
+
Cartesian3.projectVector = function(a, b, result) {
|
|
330
|
+
Check_default.defined("a", a);
|
|
331
|
+
Check_default.defined("b", b);
|
|
332
|
+
Check_default.defined("result", result);
|
|
333
|
+
const scalar = Cartesian3.dot(a, b) / Cartesian3.dot(b, b);
|
|
334
|
+
return Cartesian3.multiplyByScalar(b, scalar, result);
|
|
335
|
+
};
|
|
336
|
+
Cartesian3.equals = function(left, right) {
|
|
337
|
+
return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y && left.z === right.z;
|
|
338
|
+
};
|
|
339
|
+
Cartesian3.equalsArray = function(cartesian, array, offset) {
|
|
340
|
+
return cartesian.x === array[offset] && cartesian.y === array[offset + 1] && cartesian.z === array[offset + 2];
|
|
341
|
+
};
|
|
342
|
+
Cartesian3.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
|
|
343
|
+
return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
|
|
344
|
+
left.x,
|
|
345
|
+
right.x,
|
|
346
|
+
relativeEpsilon,
|
|
347
|
+
absoluteEpsilon
|
|
348
|
+
) && Math_default.equalsEpsilon(
|
|
349
|
+
left.y,
|
|
350
|
+
right.y,
|
|
351
|
+
relativeEpsilon,
|
|
352
|
+
absoluteEpsilon
|
|
353
|
+
) && Math_default.equalsEpsilon(
|
|
354
|
+
left.z,
|
|
355
|
+
right.z,
|
|
356
|
+
relativeEpsilon,
|
|
357
|
+
absoluteEpsilon
|
|
358
|
+
);
|
|
359
|
+
};
|
|
360
|
+
Cartesian3.cross = function(left, right, result) {
|
|
361
|
+
Check_default.typeOf.object("left", left);
|
|
362
|
+
Check_default.typeOf.object("right", right);
|
|
363
|
+
Check_default.typeOf.object("result", result);
|
|
364
|
+
const leftX = left.x;
|
|
365
|
+
const leftY = left.y;
|
|
366
|
+
const leftZ = left.z;
|
|
367
|
+
const rightX = right.x;
|
|
368
|
+
const rightY = right.y;
|
|
369
|
+
const rightZ = right.z;
|
|
370
|
+
const x = leftY * rightZ - leftZ * rightY;
|
|
371
|
+
const y = leftZ * rightX - leftX * rightZ;
|
|
372
|
+
const z = leftX * rightY - leftY * rightX;
|
|
373
|
+
result.x = x;
|
|
374
|
+
result.y = y;
|
|
375
|
+
result.z = z;
|
|
376
|
+
return result;
|
|
377
|
+
};
|
|
378
|
+
Cartesian3.midpoint = function(left, right, result) {
|
|
379
|
+
Check_default.typeOf.object("left", left);
|
|
380
|
+
Check_default.typeOf.object("right", right);
|
|
381
|
+
Check_default.typeOf.object("result", result);
|
|
382
|
+
result.x = (left.x + right.x) * 0.5;
|
|
383
|
+
result.y = (left.y + right.y) * 0.5;
|
|
384
|
+
result.z = (left.z + right.z) * 0.5;
|
|
385
|
+
return result;
|
|
386
|
+
};
|
|
387
|
+
Cartesian3.fromDegrees = function(longitude, latitude, height, ellipsoid, result) {
|
|
388
|
+
Check_default.typeOf.number("longitude", longitude);
|
|
389
|
+
Check_default.typeOf.number("latitude", latitude);
|
|
390
|
+
longitude = Math_default.toRadians(longitude);
|
|
391
|
+
latitude = Math_default.toRadians(latitude);
|
|
392
|
+
return Cartesian3.fromRadians(longitude, latitude, height, ellipsoid, result);
|
|
393
|
+
};
|
|
394
|
+
var scratchN = new Cartesian3();
|
|
395
|
+
var scratchK = new Cartesian3();
|
|
396
|
+
Cartesian3._ellipsoidRadiiSquared = new Cartesian3(
|
|
397
|
+
6378137 * 6378137,
|
|
398
|
+
6378137 * 6378137,
|
|
399
|
+
6356752314245179e-9 * 6356752314245179e-9
|
|
400
|
+
);
|
|
401
|
+
Cartesian3.fromRadians = function(longitude, latitude, height, ellipsoid, result) {
|
|
402
|
+
Check_default.typeOf.number("longitude", longitude);
|
|
403
|
+
Check_default.typeOf.number("latitude", latitude);
|
|
404
|
+
height = height ?? 0;
|
|
405
|
+
const radiiSquared = !defined_default(ellipsoid) ? Cartesian3._ellipsoidRadiiSquared : ellipsoid.radiiSquared;
|
|
406
|
+
const cosLatitude = Math.cos(latitude);
|
|
407
|
+
scratchN.x = cosLatitude * Math.cos(longitude);
|
|
408
|
+
scratchN.y = cosLatitude * Math.sin(longitude);
|
|
409
|
+
scratchN.z = Math.sin(latitude);
|
|
410
|
+
scratchN = Cartesian3.normalize(scratchN, scratchN);
|
|
411
|
+
Cartesian3.multiplyComponents(radiiSquared, scratchN, scratchK);
|
|
412
|
+
const gamma = Math.sqrt(Cartesian3.dot(scratchN, scratchK));
|
|
413
|
+
scratchK = Cartesian3.divideByScalar(scratchK, gamma, scratchK);
|
|
414
|
+
scratchN = Cartesian3.multiplyByScalar(scratchN, height, scratchN);
|
|
415
|
+
if (!defined_default(result)) {
|
|
416
|
+
result = new Cartesian3();
|
|
417
|
+
}
|
|
418
|
+
return Cartesian3.add(scratchK, scratchN, result);
|
|
419
|
+
};
|
|
420
|
+
Cartesian3.fromDegreesArray = function(coordinates, ellipsoid, result) {
|
|
421
|
+
Check_default.defined("coordinates", coordinates);
|
|
422
|
+
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
|
|
423
|
+
throw new DeveloperError_default(
|
|
424
|
+
"the number of coordinates must be a multiple of 2 and at least 2"
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
const length = coordinates.length;
|
|
428
|
+
if (!defined_default(result)) {
|
|
429
|
+
result = new Array(length / 2);
|
|
430
|
+
} else {
|
|
431
|
+
result.length = length / 2;
|
|
432
|
+
}
|
|
433
|
+
for (let i = 0; i < length; i += 2) {
|
|
434
|
+
const longitude = coordinates[i];
|
|
435
|
+
const latitude = coordinates[i + 1];
|
|
436
|
+
const index = i / 2;
|
|
437
|
+
result[index] = Cartesian3.fromDegrees(
|
|
438
|
+
longitude,
|
|
439
|
+
latitude,
|
|
440
|
+
0,
|
|
441
|
+
ellipsoid,
|
|
442
|
+
result[index]
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
return result;
|
|
446
|
+
};
|
|
447
|
+
Cartesian3.fromRadiansArray = function(coordinates, ellipsoid, result) {
|
|
448
|
+
Check_default.defined("coordinates", coordinates);
|
|
449
|
+
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
|
|
450
|
+
throw new DeveloperError_default(
|
|
451
|
+
"the number of coordinates must be a multiple of 2 and at least 2"
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
const length = coordinates.length;
|
|
455
|
+
if (!defined_default(result)) {
|
|
456
|
+
result = new Array(length / 2);
|
|
457
|
+
} else {
|
|
458
|
+
result.length = length / 2;
|
|
459
|
+
}
|
|
460
|
+
for (let i = 0; i < length; i += 2) {
|
|
461
|
+
const longitude = coordinates[i];
|
|
462
|
+
const latitude = coordinates[i + 1];
|
|
463
|
+
const index = i / 2;
|
|
464
|
+
result[index] = Cartesian3.fromRadians(
|
|
465
|
+
longitude,
|
|
466
|
+
latitude,
|
|
467
|
+
0,
|
|
468
|
+
ellipsoid,
|
|
469
|
+
result[index]
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
return result;
|
|
473
|
+
};
|
|
474
|
+
Cartesian3.fromDegreesArrayHeights = function(coordinates, ellipsoid, result) {
|
|
475
|
+
Check_default.defined("coordinates", coordinates);
|
|
476
|
+
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
|
|
477
|
+
throw new DeveloperError_default(
|
|
478
|
+
"the number of coordinates must be a multiple of 3 and at least 3"
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
const length = coordinates.length;
|
|
482
|
+
if (!defined_default(result)) {
|
|
483
|
+
result = new Array(length / 3);
|
|
484
|
+
} else {
|
|
485
|
+
result.length = length / 3;
|
|
486
|
+
}
|
|
487
|
+
for (let i = 0; i < length; i += 3) {
|
|
488
|
+
const longitude = coordinates[i];
|
|
489
|
+
const latitude = coordinates[i + 1];
|
|
490
|
+
const height = coordinates[i + 2];
|
|
491
|
+
const index = i / 3;
|
|
492
|
+
result[index] = Cartesian3.fromDegrees(
|
|
493
|
+
longitude,
|
|
494
|
+
latitude,
|
|
495
|
+
height,
|
|
496
|
+
ellipsoid,
|
|
497
|
+
result[index]
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
return result;
|
|
501
|
+
};
|
|
502
|
+
Cartesian3.fromRadiansArrayHeights = function(coordinates, ellipsoid, result) {
|
|
503
|
+
Check_default.defined("coordinates", coordinates);
|
|
504
|
+
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
|
|
505
|
+
throw new DeveloperError_default(
|
|
506
|
+
"the number of coordinates must be a multiple of 3 and at least 3"
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
const length = coordinates.length;
|
|
510
|
+
if (!defined_default(result)) {
|
|
511
|
+
result = new Array(length / 3);
|
|
512
|
+
} else {
|
|
513
|
+
result.length = length / 3;
|
|
514
|
+
}
|
|
515
|
+
for (let i = 0; i < length; i += 3) {
|
|
516
|
+
const longitude = coordinates[i];
|
|
517
|
+
const latitude = coordinates[i + 1];
|
|
518
|
+
const height = coordinates[i + 2];
|
|
519
|
+
const index = i / 3;
|
|
520
|
+
result[index] = Cartesian3.fromRadians(
|
|
521
|
+
longitude,
|
|
522
|
+
latitude,
|
|
523
|
+
height,
|
|
524
|
+
ellipsoid,
|
|
525
|
+
result[index]
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
return result;
|
|
529
|
+
};
|
|
530
|
+
Cartesian3.ZERO = Object.freeze(new Cartesian3(0, 0, 0));
|
|
531
|
+
Cartesian3.ONE = Object.freeze(new Cartesian3(1, 1, 1));
|
|
532
|
+
Cartesian3.UNIT_X = Object.freeze(new Cartesian3(1, 0, 0));
|
|
533
|
+
Cartesian3.UNIT_Y = Object.freeze(new Cartesian3(0, 1, 0));
|
|
534
|
+
Cartesian3.UNIT_Z = Object.freeze(new Cartesian3(0, 0, 1));
|
|
535
|
+
Cartesian3.prototype.clone = function(result) {
|
|
536
|
+
return Cartesian3.clone(this, result);
|
|
537
|
+
};
|
|
538
|
+
Cartesian3.prototype.equals = function(right) {
|
|
539
|
+
return Cartesian3.equals(this, right);
|
|
540
|
+
};
|
|
541
|
+
Cartesian3.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
|
|
542
|
+
return Cartesian3.equalsEpsilon(
|
|
543
|
+
this,
|
|
544
|
+
right,
|
|
545
|
+
relativeEpsilon,
|
|
546
|
+
absoluteEpsilon
|
|
547
|
+
);
|
|
548
|
+
};
|
|
549
|
+
Cartesian3.prototype.toString = function() {
|
|
550
|
+
return `(${this.x}, ${this.y}, ${this.z})`;
|
|
551
|
+
};
|
|
552
|
+
var Cartesian3_default = Cartesian3;
|
|
553
|
+
|
|
554
|
+
// packages/engine/Source/Core/Matrix3.js
|
|
555
|
+
function Matrix3(column0Row0, column1Row0, column2Row0, column0Row1, column1Row1, column2Row1, column0Row2, column1Row2, column2Row2) {
|
|
556
|
+
this[0] = column0Row0 ?? 0;
|
|
557
|
+
this[1] = column0Row1 ?? 0;
|
|
558
|
+
this[2] = column0Row2 ?? 0;
|
|
559
|
+
this[3] = column1Row0 ?? 0;
|
|
560
|
+
this[4] = column1Row1 ?? 0;
|
|
561
|
+
this[5] = column1Row2 ?? 0;
|
|
562
|
+
this[6] = column2Row0 ?? 0;
|
|
563
|
+
this[7] = column2Row1 ?? 0;
|
|
564
|
+
this[8] = column2Row2 ?? 0;
|
|
565
|
+
}
|
|
566
|
+
Matrix3.packedLength = 9;
|
|
567
|
+
Matrix3.pack = function(value, array, startingIndex) {
|
|
568
|
+
Check_default.typeOf.object("value", value);
|
|
569
|
+
Check_default.defined("array", array);
|
|
570
|
+
startingIndex = startingIndex ?? 0;
|
|
571
|
+
array[startingIndex++] = value[0];
|
|
572
|
+
array[startingIndex++] = value[1];
|
|
573
|
+
array[startingIndex++] = value[2];
|
|
574
|
+
array[startingIndex++] = value[3];
|
|
575
|
+
array[startingIndex++] = value[4];
|
|
576
|
+
array[startingIndex++] = value[5];
|
|
577
|
+
array[startingIndex++] = value[6];
|
|
578
|
+
array[startingIndex++] = value[7];
|
|
579
|
+
array[startingIndex++] = value[8];
|
|
580
|
+
return array;
|
|
581
|
+
};
|
|
582
|
+
Matrix3.unpack = function(array, startingIndex, result) {
|
|
583
|
+
Check_default.defined("array", array);
|
|
584
|
+
startingIndex = startingIndex ?? 0;
|
|
585
|
+
if (!defined_default(result)) {
|
|
586
|
+
result = new Matrix3();
|
|
587
|
+
}
|
|
588
|
+
result[0] = array[startingIndex++];
|
|
589
|
+
result[1] = array[startingIndex++];
|
|
590
|
+
result[2] = array[startingIndex++];
|
|
591
|
+
result[3] = array[startingIndex++];
|
|
592
|
+
result[4] = array[startingIndex++];
|
|
593
|
+
result[5] = array[startingIndex++];
|
|
594
|
+
result[6] = array[startingIndex++];
|
|
595
|
+
result[7] = array[startingIndex++];
|
|
596
|
+
result[8] = array[startingIndex++];
|
|
597
|
+
return result;
|
|
598
|
+
};
|
|
599
|
+
Matrix3.packArray = function(array, result) {
|
|
600
|
+
Check_default.defined("array", array);
|
|
601
|
+
const length = array.length;
|
|
602
|
+
const resultLength = length * 9;
|
|
603
|
+
if (!defined_default(result)) {
|
|
604
|
+
result = new Array(resultLength);
|
|
605
|
+
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
606
|
+
throw new DeveloperError_default(
|
|
607
|
+
"If result is a typed array, it must have exactly array.length * 9 elements"
|
|
608
|
+
);
|
|
609
|
+
} else if (result.length !== resultLength) {
|
|
610
|
+
result.length = resultLength;
|
|
611
|
+
}
|
|
612
|
+
for (let i = 0; i < length; ++i) {
|
|
613
|
+
Matrix3.pack(array[i], result, i * 9);
|
|
614
|
+
}
|
|
615
|
+
return result;
|
|
616
|
+
};
|
|
617
|
+
Matrix3.unpackArray = function(array, result) {
|
|
618
|
+
Check_default.defined("array", array);
|
|
619
|
+
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 9);
|
|
620
|
+
if (array.length % 9 !== 0) {
|
|
621
|
+
throw new DeveloperError_default("array length must be a multiple of 9.");
|
|
622
|
+
}
|
|
623
|
+
const length = array.length;
|
|
624
|
+
if (!defined_default(result)) {
|
|
625
|
+
result = new Array(length / 9);
|
|
626
|
+
} else {
|
|
627
|
+
result.length = length / 9;
|
|
628
|
+
}
|
|
629
|
+
for (let i = 0; i < length; i += 9) {
|
|
630
|
+
const index = i / 9;
|
|
631
|
+
result[index] = Matrix3.unpack(array, i, result[index]);
|
|
632
|
+
}
|
|
633
|
+
return result;
|
|
634
|
+
};
|
|
635
|
+
Matrix3.clone = function(matrix, result) {
|
|
636
|
+
if (!defined_default(matrix)) {
|
|
637
|
+
return void 0;
|
|
638
|
+
}
|
|
639
|
+
if (!defined_default(result)) {
|
|
640
|
+
return new Matrix3(
|
|
641
|
+
matrix[0],
|
|
642
|
+
matrix[3],
|
|
643
|
+
matrix[6],
|
|
644
|
+
matrix[1],
|
|
645
|
+
matrix[4],
|
|
646
|
+
matrix[7],
|
|
647
|
+
matrix[2],
|
|
648
|
+
matrix[5],
|
|
649
|
+
matrix[8]
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
result[0] = matrix[0];
|
|
653
|
+
result[1] = matrix[1];
|
|
654
|
+
result[2] = matrix[2];
|
|
655
|
+
result[3] = matrix[3];
|
|
656
|
+
result[4] = matrix[4];
|
|
657
|
+
result[5] = matrix[5];
|
|
658
|
+
result[6] = matrix[6];
|
|
659
|
+
result[7] = matrix[7];
|
|
660
|
+
result[8] = matrix[8];
|
|
661
|
+
return result;
|
|
662
|
+
};
|
|
663
|
+
Matrix3.fromArray = Matrix3.unpack;
|
|
664
|
+
Matrix3.fromColumnMajorArray = function(values, result) {
|
|
665
|
+
Check_default.defined("values", values);
|
|
666
|
+
return Matrix3.clone(values, result);
|
|
667
|
+
};
|
|
668
|
+
Matrix3.fromRowMajorArray = function(values, result) {
|
|
669
|
+
Check_default.defined("values", values);
|
|
670
|
+
if (!defined_default(result)) {
|
|
671
|
+
return new Matrix3(
|
|
672
|
+
values[0],
|
|
673
|
+
values[1],
|
|
674
|
+
values[2],
|
|
675
|
+
values[3],
|
|
676
|
+
values[4],
|
|
677
|
+
values[5],
|
|
678
|
+
values[6],
|
|
679
|
+
values[7],
|
|
680
|
+
values[8]
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
result[0] = values[0];
|
|
684
|
+
result[1] = values[3];
|
|
685
|
+
result[2] = values[6];
|
|
686
|
+
result[3] = values[1];
|
|
687
|
+
result[4] = values[4];
|
|
688
|
+
result[5] = values[7];
|
|
689
|
+
result[6] = values[2];
|
|
690
|
+
result[7] = values[5];
|
|
691
|
+
result[8] = values[8];
|
|
692
|
+
return result;
|
|
693
|
+
};
|
|
694
|
+
Matrix3.fromQuaternion = function(quaternion, result) {
|
|
695
|
+
Check_default.typeOf.object("quaternion", quaternion);
|
|
696
|
+
const x2 = quaternion.x * quaternion.x;
|
|
697
|
+
const xy = quaternion.x * quaternion.y;
|
|
698
|
+
const xz = quaternion.x * quaternion.z;
|
|
699
|
+
const xw = quaternion.x * quaternion.w;
|
|
700
|
+
const y2 = quaternion.y * quaternion.y;
|
|
701
|
+
const yz = quaternion.y * quaternion.z;
|
|
702
|
+
const yw = quaternion.y * quaternion.w;
|
|
703
|
+
const z2 = quaternion.z * quaternion.z;
|
|
704
|
+
const zw = quaternion.z * quaternion.w;
|
|
705
|
+
const w2 = quaternion.w * quaternion.w;
|
|
706
|
+
const m00 = x2 - y2 - z2 + w2;
|
|
707
|
+
const m01 = 2 * (xy - zw);
|
|
708
|
+
const m02 = 2 * (xz + yw);
|
|
709
|
+
const m10 = 2 * (xy + zw);
|
|
710
|
+
const m11 = -x2 + y2 - z2 + w2;
|
|
711
|
+
const m12 = 2 * (yz - xw);
|
|
712
|
+
const m20 = 2 * (xz - yw);
|
|
713
|
+
const m21 = 2 * (yz + xw);
|
|
714
|
+
const m22 = -x2 - y2 + z2 + w2;
|
|
715
|
+
if (!defined_default(result)) {
|
|
716
|
+
return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
|
|
717
|
+
}
|
|
718
|
+
result[0] = m00;
|
|
719
|
+
result[1] = m10;
|
|
720
|
+
result[2] = m20;
|
|
721
|
+
result[3] = m01;
|
|
722
|
+
result[4] = m11;
|
|
723
|
+
result[5] = m21;
|
|
724
|
+
result[6] = m02;
|
|
725
|
+
result[7] = m12;
|
|
726
|
+
result[8] = m22;
|
|
727
|
+
return result;
|
|
728
|
+
};
|
|
729
|
+
Matrix3.fromHeadingPitchRoll = function(headingPitchRoll, result) {
|
|
730
|
+
Check_default.typeOf.object("headingPitchRoll", headingPitchRoll);
|
|
731
|
+
const cosTheta = Math.cos(-headingPitchRoll.pitch);
|
|
732
|
+
const cosPsi = Math.cos(-headingPitchRoll.heading);
|
|
733
|
+
const cosPhi = Math.cos(headingPitchRoll.roll);
|
|
734
|
+
const sinTheta = Math.sin(-headingPitchRoll.pitch);
|
|
735
|
+
const sinPsi = Math.sin(-headingPitchRoll.heading);
|
|
736
|
+
const sinPhi = Math.sin(headingPitchRoll.roll);
|
|
737
|
+
const m00 = cosTheta * cosPsi;
|
|
738
|
+
const m01 = -cosPhi * sinPsi + sinPhi * sinTheta * cosPsi;
|
|
739
|
+
const m02 = sinPhi * sinPsi + cosPhi * sinTheta * cosPsi;
|
|
740
|
+
const m10 = cosTheta * sinPsi;
|
|
741
|
+
const m11 = cosPhi * cosPsi + sinPhi * sinTheta * sinPsi;
|
|
742
|
+
const m12 = -sinPhi * cosPsi + cosPhi * sinTheta * sinPsi;
|
|
743
|
+
const m20 = -sinTheta;
|
|
744
|
+
const m21 = sinPhi * cosTheta;
|
|
745
|
+
const m22 = cosPhi * cosTheta;
|
|
746
|
+
if (!defined_default(result)) {
|
|
747
|
+
return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
|
|
748
|
+
}
|
|
749
|
+
result[0] = m00;
|
|
750
|
+
result[1] = m10;
|
|
751
|
+
result[2] = m20;
|
|
752
|
+
result[3] = m01;
|
|
753
|
+
result[4] = m11;
|
|
754
|
+
result[5] = m21;
|
|
755
|
+
result[6] = m02;
|
|
756
|
+
result[7] = m12;
|
|
757
|
+
result[8] = m22;
|
|
758
|
+
return result;
|
|
759
|
+
};
|
|
760
|
+
Matrix3.fromScale = function(scale, result) {
|
|
761
|
+
Check_default.typeOf.object("scale", scale);
|
|
762
|
+
if (!defined_default(result)) {
|
|
763
|
+
return new Matrix3(scale.x, 0, 0, 0, scale.y, 0, 0, 0, scale.z);
|
|
764
|
+
}
|
|
765
|
+
result[0] = scale.x;
|
|
766
|
+
result[1] = 0;
|
|
767
|
+
result[2] = 0;
|
|
768
|
+
result[3] = 0;
|
|
769
|
+
result[4] = scale.y;
|
|
770
|
+
result[5] = 0;
|
|
771
|
+
result[6] = 0;
|
|
772
|
+
result[7] = 0;
|
|
773
|
+
result[8] = scale.z;
|
|
774
|
+
return result;
|
|
775
|
+
};
|
|
776
|
+
Matrix3.fromUniformScale = function(scale, result) {
|
|
777
|
+
Check_default.typeOf.number("scale", scale);
|
|
778
|
+
if (!defined_default(result)) {
|
|
779
|
+
return new Matrix3(scale, 0, 0, 0, scale, 0, 0, 0, scale);
|
|
780
|
+
}
|
|
781
|
+
result[0] = scale;
|
|
782
|
+
result[1] = 0;
|
|
783
|
+
result[2] = 0;
|
|
784
|
+
result[3] = 0;
|
|
785
|
+
result[4] = scale;
|
|
786
|
+
result[5] = 0;
|
|
787
|
+
result[6] = 0;
|
|
788
|
+
result[7] = 0;
|
|
789
|
+
result[8] = scale;
|
|
790
|
+
return result;
|
|
791
|
+
};
|
|
792
|
+
Matrix3.fromCrossProduct = function(vector, result) {
|
|
793
|
+
Check_default.typeOf.object("vector", vector);
|
|
794
|
+
if (!defined_default(result)) {
|
|
795
|
+
return new Matrix3(
|
|
796
|
+
0,
|
|
797
|
+
-vector.z,
|
|
798
|
+
vector.y,
|
|
799
|
+
vector.z,
|
|
800
|
+
0,
|
|
801
|
+
-vector.x,
|
|
802
|
+
-vector.y,
|
|
803
|
+
vector.x,
|
|
804
|
+
0
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
result[0] = 0;
|
|
808
|
+
result[1] = vector.z;
|
|
809
|
+
result[2] = -vector.y;
|
|
810
|
+
result[3] = -vector.z;
|
|
811
|
+
result[4] = 0;
|
|
812
|
+
result[5] = vector.x;
|
|
813
|
+
result[6] = vector.y;
|
|
814
|
+
result[7] = -vector.x;
|
|
815
|
+
result[8] = 0;
|
|
816
|
+
return result;
|
|
817
|
+
};
|
|
818
|
+
Matrix3.fromRotationX = function(angle, result) {
|
|
819
|
+
Check_default.typeOf.number("angle", angle);
|
|
820
|
+
const cosAngle = Math.cos(angle);
|
|
821
|
+
const sinAngle = Math.sin(angle);
|
|
822
|
+
if (!defined_default(result)) {
|
|
823
|
+
return new Matrix3(
|
|
824
|
+
1,
|
|
825
|
+
0,
|
|
826
|
+
0,
|
|
827
|
+
0,
|
|
828
|
+
cosAngle,
|
|
829
|
+
-sinAngle,
|
|
830
|
+
0,
|
|
831
|
+
sinAngle,
|
|
832
|
+
cosAngle
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
result[0] = 1;
|
|
836
|
+
result[1] = 0;
|
|
837
|
+
result[2] = 0;
|
|
838
|
+
result[3] = 0;
|
|
839
|
+
result[4] = cosAngle;
|
|
840
|
+
result[5] = sinAngle;
|
|
841
|
+
result[6] = 0;
|
|
842
|
+
result[7] = -sinAngle;
|
|
843
|
+
result[8] = cosAngle;
|
|
844
|
+
return result;
|
|
845
|
+
};
|
|
846
|
+
Matrix3.fromRotationY = function(angle, result) {
|
|
847
|
+
Check_default.typeOf.number("angle", angle);
|
|
848
|
+
const cosAngle = Math.cos(angle);
|
|
849
|
+
const sinAngle = Math.sin(angle);
|
|
850
|
+
if (!defined_default(result)) {
|
|
851
|
+
return new Matrix3(
|
|
852
|
+
cosAngle,
|
|
853
|
+
0,
|
|
854
|
+
sinAngle,
|
|
855
|
+
0,
|
|
856
|
+
1,
|
|
857
|
+
0,
|
|
858
|
+
-sinAngle,
|
|
859
|
+
0,
|
|
860
|
+
cosAngle
|
|
861
|
+
);
|
|
862
|
+
}
|
|
863
|
+
result[0] = cosAngle;
|
|
864
|
+
result[1] = 0;
|
|
865
|
+
result[2] = -sinAngle;
|
|
866
|
+
result[3] = 0;
|
|
867
|
+
result[4] = 1;
|
|
868
|
+
result[5] = 0;
|
|
869
|
+
result[6] = sinAngle;
|
|
870
|
+
result[7] = 0;
|
|
871
|
+
result[8] = cosAngle;
|
|
872
|
+
return result;
|
|
873
|
+
};
|
|
874
|
+
Matrix3.fromRotationZ = function(angle, result) {
|
|
875
|
+
Check_default.typeOf.number("angle", angle);
|
|
876
|
+
const cosAngle = Math.cos(angle);
|
|
877
|
+
const sinAngle = Math.sin(angle);
|
|
878
|
+
if (!defined_default(result)) {
|
|
879
|
+
return new Matrix3(
|
|
880
|
+
cosAngle,
|
|
881
|
+
-sinAngle,
|
|
882
|
+
0,
|
|
883
|
+
sinAngle,
|
|
884
|
+
cosAngle,
|
|
885
|
+
0,
|
|
886
|
+
0,
|
|
887
|
+
0,
|
|
888
|
+
1
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
result[0] = cosAngle;
|
|
892
|
+
result[1] = sinAngle;
|
|
893
|
+
result[2] = 0;
|
|
894
|
+
result[3] = -sinAngle;
|
|
895
|
+
result[4] = cosAngle;
|
|
896
|
+
result[5] = 0;
|
|
897
|
+
result[6] = 0;
|
|
898
|
+
result[7] = 0;
|
|
899
|
+
result[8] = 1;
|
|
900
|
+
return result;
|
|
901
|
+
};
|
|
902
|
+
Matrix3.toArray = function(matrix, result) {
|
|
903
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
904
|
+
if (!defined_default(result)) {
|
|
905
|
+
return [
|
|
906
|
+
matrix[0],
|
|
907
|
+
matrix[1],
|
|
908
|
+
matrix[2],
|
|
909
|
+
matrix[3],
|
|
910
|
+
matrix[4],
|
|
911
|
+
matrix[5],
|
|
912
|
+
matrix[6],
|
|
913
|
+
matrix[7],
|
|
914
|
+
matrix[8]
|
|
915
|
+
];
|
|
916
|
+
}
|
|
917
|
+
result[0] = matrix[0];
|
|
918
|
+
result[1] = matrix[1];
|
|
919
|
+
result[2] = matrix[2];
|
|
920
|
+
result[3] = matrix[3];
|
|
921
|
+
result[4] = matrix[4];
|
|
922
|
+
result[5] = matrix[5];
|
|
923
|
+
result[6] = matrix[6];
|
|
924
|
+
result[7] = matrix[7];
|
|
925
|
+
result[8] = matrix[8];
|
|
926
|
+
return result;
|
|
927
|
+
};
|
|
928
|
+
Matrix3.getElementIndex = function(column, row) {
|
|
929
|
+
Check_default.typeOf.number.greaterThanOrEquals("row", row, 0);
|
|
930
|
+
Check_default.typeOf.number.lessThanOrEquals("row", row, 2);
|
|
931
|
+
Check_default.typeOf.number.greaterThanOrEquals("column", column, 0);
|
|
932
|
+
Check_default.typeOf.number.lessThanOrEquals("column", column, 2);
|
|
933
|
+
return column * 3 + row;
|
|
934
|
+
};
|
|
935
|
+
Matrix3.getColumn = function(matrix, index, result) {
|
|
936
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
937
|
+
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
938
|
+
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
939
|
+
Check_default.typeOf.object("result", result);
|
|
940
|
+
const startIndex = index * 3;
|
|
941
|
+
const x = matrix[startIndex];
|
|
942
|
+
const y = matrix[startIndex + 1];
|
|
943
|
+
const z = matrix[startIndex + 2];
|
|
944
|
+
result.x = x;
|
|
945
|
+
result.y = y;
|
|
946
|
+
result.z = z;
|
|
947
|
+
return result;
|
|
948
|
+
};
|
|
949
|
+
Matrix3.setColumn = function(matrix, index, cartesian, result) {
|
|
950
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
951
|
+
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
952
|
+
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
953
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
954
|
+
Check_default.typeOf.object("result", result);
|
|
955
|
+
result = Matrix3.clone(matrix, result);
|
|
956
|
+
const startIndex = index * 3;
|
|
957
|
+
result[startIndex] = cartesian.x;
|
|
958
|
+
result[startIndex + 1] = cartesian.y;
|
|
959
|
+
result[startIndex + 2] = cartesian.z;
|
|
960
|
+
return result;
|
|
961
|
+
};
|
|
962
|
+
Matrix3.getRow = function(matrix, index, result) {
|
|
963
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
964
|
+
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
965
|
+
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
966
|
+
Check_default.typeOf.object("result", result);
|
|
967
|
+
const x = matrix[index];
|
|
968
|
+
const y = matrix[index + 3];
|
|
969
|
+
const z = matrix[index + 6];
|
|
970
|
+
result.x = x;
|
|
971
|
+
result.y = y;
|
|
972
|
+
result.z = z;
|
|
973
|
+
return result;
|
|
974
|
+
};
|
|
975
|
+
Matrix3.setRow = function(matrix, index, cartesian, result) {
|
|
976
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
977
|
+
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
978
|
+
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
979
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
980
|
+
Check_default.typeOf.object("result", result);
|
|
981
|
+
result = Matrix3.clone(matrix, result);
|
|
982
|
+
result[index] = cartesian.x;
|
|
983
|
+
result[index + 3] = cartesian.y;
|
|
984
|
+
result[index + 6] = cartesian.z;
|
|
985
|
+
return result;
|
|
986
|
+
};
|
|
987
|
+
var scaleScratch1 = new Cartesian3_default();
|
|
988
|
+
Matrix3.setScale = function(matrix, scale, result) {
|
|
989
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
990
|
+
Check_default.typeOf.object("scale", scale);
|
|
991
|
+
Check_default.typeOf.object("result", result);
|
|
992
|
+
const existingScale = Matrix3.getScale(matrix, scaleScratch1);
|
|
993
|
+
const scaleRatioX = scale.x / existingScale.x;
|
|
994
|
+
const scaleRatioY = scale.y / existingScale.y;
|
|
995
|
+
const scaleRatioZ = scale.z / existingScale.z;
|
|
996
|
+
result[0] = matrix[0] * scaleRatioX;
|
|
997
|
+
result[1] = matrix[1] * scaleRatioX;
|
|
998
|
+
result[2] = matrix[2] * scaleRatioX;
|
|
999
|
+
result[3] = matrix[3] * scaleRatioY;
|
|
1000
|
+
result[4] = matrix[4] * scaleRatioY;
|
|
1001
|
+
result[5] = matrix[5] * scaleRatioY;
|
|
1002
|
+
result[6] = matrix[6] * scaleRatioZ;
|
|
1003
|
+
result[7] = matrix[7] * scaleRatioZ;
|
|
1004
|
+
result[8] = matrix[8] * scaleRatioZ;
|
|
1005
|
+
return result;
|
|
1006
|
+
};
|
|
1007
|
+
var scaleScratch2 = new Cartesian3_default();
|
|
1008
|
+
Matrix3.setUniformScale = function(matrix, scale, result) {
|
|
1009
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1010
|
+
Check_default.typeOf.number("scale", scale);
|
|
1011
|
+
Check_default.typeOf.object("result", result);
|
|
1012
|
+
const existingScale = Matrix3.getScale(matrix, scaleScratch2);
|
|
1013
|
+
const scaleRatioX = scale / existingScale.x;
|
|
1014
|
+
const scaleRatioY = scale / existingScale.y;
|
|
1015
|
+
const scaleRatioZ = scale / existingScale.z;
|
|
1016
|
+
result[0] = matrix[0] * scaleRatioX;
|
|
1017
|
+
result[1] = matrix[1] * scaleRatioX;
|
|
1018
|
+
result[2] = matrix[2] * scaleRatioX;
|
|
1019
|
+
result[3] = matrix[3] * scaleRatioY;
|
|
1020
|
+
result[4] = matrix[4] * scaleRatioY;
|
|
1021
|
+
result[5] = matrix[5] * scaleRatioY;
|
|
1022
|
+
result[6] = matrix[6] * scaleRatioZ;
|
|
1023
|
+
result[7] = matrix[7] * scaleRatioZ;
|
|
1024
|
+
result[8] = matrix[8] * scaleRatioZ;
|
|
1025
|
+
return result;
|
|
1026
|
+
};
|
|
1027
|
+
var scratchColumn = new Cartesian3_default();
|
|
1028
|
+
Matrix3.getScale = function(matrix, result) {
|
|
1029
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1030
|
+
Check_default.typeOf.object("result", result);
|
|
1031
|
+
result.x = Cartesian3_default.magnitude(
|
|
1032
|
+
Cartesian3_default.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn)
|
|
1033
|
+
);
|
|
1034
|
+
result.y = Cartesian3_default.magnitude(
|
|
1035
|
+
Cartesian3_default.fromElements(matrix[3], matrix[4], matrix[5], scratchColumn)
|
|
1036
|
+
);
|
|
1037
|
+
result.z = Cartesian3_default.magnitude(
|
|
1038
|
+
Cartesian3_default.fromElements(matrix[6], matrix[7], matrix[8], scratchColumn)
|
|
1039
|
+
);
|
|
1040
|
+
return result;
|
|
1041
|
+
};
|
|
1042
|
+
var scaleScratch3 = new Cartesian3_default();
|
|
1043
|
+
Matrix3.getMaximumScale = function(matrix) {
|
|
1044
|
+
Matrix3.getScale(matrix, scaleScratch3);
|
|
1045
|
+
return Cartesian3_default.maximumComponent(scaleScratch3);
|
|
1046
|
+
};
|
|
1047
|
+
var scaleScratch4 = new Cartesian3_default();
|
|
1048
|
+
Matrix3.setRotation = function(matrix, rotation, result) {
|
|
1049
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1050
|
+
Check_default.typeOf.object("result", result);
|
|
1051
|
+
const scale = Matrix3.getScale(matrix, scaleScratch4);
|
|
1052
|
+
result[0] = rotation[0] * scale.x;
|
|
1053
|
+
result[1] = rotation[1] * scale.x;
|
|
1054
|
+
result[2] = rotation[2] * scale.x;
|
|
1055
|
+
result[3] = rotation[3] * scale.y;
|
|
1056
|
+
result[4] = rotation[4] * scale.y;
|
|
1057
|
+
result[5] = rotation[5] * scale.y;
|
|
1058
|
+
result[6] = rotation[6] * scale.z;
|
|
1059
|
+
result[7] = rotation[7] * scale.z;
|
|
1060
|
+
result[8] = rotation[8] * scale.z;
|
|
1061
|
+
return result;
|
|
1062
|
+
};
|
|
1063
|
+
var scaleScratch5 = new Cartesian3_default();
|
|
1064
|
+
Matrix3.getRotation = function(matrix, result) {
|
|
1065
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1066
|
+
Check_default.typeOf.object("result", result);
|
|
1067
|
+
const scale = Matrix3.getScale(matrix, scaleScratch5);
|
|
1068
|
+
result[0] = matrix[0] / scale.x;
|
|
1069
|
+
result[1] = matrix[1] / scale.x;
|
|
1070
|
+
result[2] = matrix[2] / scale.x;
|
|
1071
|
+
result[3] = matrix[3] / scale.y;
|
|
1072
|
+
result[4] = matrix[4] / scale.y;
|
|
1073
|
+
result[5] = matrix[5] / scale.y;
|
|
1074
|
+
result[6] = matrix[6] / scale.z;
|
|
1075
|
+
result[7] = matrix[7] / scale.z;
|
|
1076
|
+
result[8] = matrix[8] / scale.z;
|
|
1077
|
+
return result;
|
|
1078
|
+
};
|
|
1079
|
+
Matrix3.multiply = function(left, right, result) {
|
|
1080
|
+
Check_default.typeOf.object("left", left);
|
|
1081
|
+
Check_default.typeOf.object("right", right);
|
|
1082
|
+
Check_default.typeOf.object("result", result);
|
|
1083
|
+
const column0Row0 = left[0] * right[0] + left[3] * right[1] + left[6] * right[2];
|
|
1084
|
+
const column0Row1 = left[1] * right[0] + left[4] * right[1] + left[7] * right[2];
|
|
1085
|
+
const column0Row2 = left[2] * right[0] + left[5] * right[1] + left[8] * right[2];
|
|
1086
|
+
const column1Row0 = left[0] * right[3] + left[3] * right[4] + left[6] * right[5];
|
|
1087
|
+
const column1Row1 = left[1] * right[3] + left[4] * right[4] + left[7] * right[5];
|
|
1088
|
+
const column1Row2 = left[2] * right[3] + left[5] * right[4] + left[8] * right[5];
|
|
1089
|
+
const column2Row0 = left[0] * right[6] + left[3] * right[7] + left[6] * right[8];
|
|
1090
|
+
const column2Row1 = left[1] * right[6] + left[4] * right[7] + left[7] * right[8];
|
|
1091
|
+
const column2Row2 = left[2] * right[6] + left[5] * right[7] + left[8] * right[8];
|
|
1092
|
+
result[0] = column0Row0;
|
|
1093
|
+
result[1] = column0Row1;
|
|
1094
|
+
result[2] = column0Row2;
|
|
1095
|
+
result[3] = column1Row0;
|
|
1096
|
+
result[4] = column1Row1;
|
|
1097
|
+
result[5] = column1Row2;
|
|
1098
|
+
result[6] = column2Row0;
|
|
1099
|
+
result[7] = column2Row1;
|
|
1100
|
+
result[8] = column2Row2;
|
|
1101
|
+
return result;
|
|
1102
|
+
};
|
|
1103
|
+
Matrix3.add = function(left, right, result) {
|
|
1104
|
+
Check_default.typeOf.object("left", left);
|
|
1105
|
+
Check_default.typeOf.object("right", right);
|
|
1106
|
+
Check_default.typeOf.object("result", result);
|
|
1107
|
+
result[0] = left[0] + right[0];
|
|
1108
|
+
result[1] = left[1] + right[1];
|
|
1109
|
+
result[2] = left[2] + right[2];
|
|
1110
|
+
result[3] = left[3] + right[3];
|
|
1111
|
+
result[4] = left[4] + right[4];
|
|
1112
|
+
result[5] = left[5] + right[5];
|
|
1113
|
+
result[6] = left[6] + right[6];
|
|
1114
|
+
result[7] = left[7] + right[7];
|
|
1115
|
+
result[8] = left[8] + right[8];
|
|
1116
|
+
return result;
|
|
1117
|
+
};
|
|
1118
|
+
Matrix3.subtract = function(left, right, result) {
|
|
1119
|
+
Check_default.typeOf.object("left", left);
|
|
1120
|
+
Check_default.typeOf.object("right", right);
|
|
1121
|
+
Check_default.typeOf.object("result", result);
|
|
1122
|
+
result[0] = left[0] - right[0];
|
|
1123
|
+
result[1] = left[1] - right[1];
|
|
1124
|
+
result[2] = left[2] - right[2];
|
|
1125
|
+
result[3] = left[3] - right[3];
|
|
1126
|
+
result[4] = left[4] - right[4];
|
|
1127
|
+
result[5] = left[5] - right[5];
|
|
1128
|
+
result[6] = left[6] - right[6];
|
|
1129
|
+
result[7] = left[7] - right[7];
|
|
1130
|
+
result[8] = left[8] - right[8];
|
|
1131
|
+
return result;
|
|
1132
|
+
};
|
|
1133
|
+
Matrix3.multiplyByVector = function(matrix, cartesian, result) {
|
|
1134
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1135
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
1136
|
+
Check_default.typeOf.object("result", result);
|
|
1137
|
+
const vX = cartesian.x;
|
|
1138
|
+
const vY = cartesian.y;
|
|
1139
|
+
const vZ = cartesian.z;
|
|
1140
|
+
const x = matrix[0] * vX + matrix[3] * vY + matrix[6] * vZ;
|
|
1141
|
+
const y = matrix[1] * vX + matrix[4] * vY + matrix[7] * vZ;
|
|
1142
|
+
const z = matrix[2] * vX + matrix[5] * vY + matrix[8] * vZ;
|
|
1143
|
+
result.x = x;
|
|
1144
|
+
result.y = y;
|
|
1145
|
+
result.z = z;
|
|
1146
|
+
return result;
|
|
1147
|
+
};
|
|
1148
|
+
Matrix3.multiplyByScalar = function(matrix, scalar, result) {
|
|
1149
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1150
|
+
Check_default.typeOf.number("scalar", scalar);
|
|
1151
|
+
Check_default.typeOf.object("result", result);
|
|
1152
|
+
result[0] = matrix[0] * scalar;
|
|
1153
|
+
result[1] = matrix[1] * scalar;
|
|
1154
|
+
result[2] = matrix[2] * scalar;
|
|
1155
|
+
result[3] = matrix[3] * scalar;
|
|
1156
|
+
result[4] = matrix[4] * scalar;
|
|
1157
|
+
result[5] = matrix[5] * scalar;
|
|
1158
|
+
result[6] = matrix[6] * scalar;
|
|
1159
|
+
result[7] = matrix[7] * scalar;
|
|
1160
|
+
result[8] = matrix[8] * scalar;
|
|
1161
|
+
return result;
|
|
1162
|
+
};
|
|
1163
|
+
Matrix3.multiplyByScale = function(matrix, scale, result) {
|
|
1164
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1165
|
+
Check_default.typeOf.object("scale", scale);
|
|
1166
|
+
Check_default.typeOf.object("result", result);
|
|
1167
|
+
result[0] = matrix[0] * scale.x;
|
|
1168
|
+
result[1] = matrix[1] * scale.x;
|
|
1169
|
+
result[2] = matrix[2] * scale.x;
|
|
1170
|
+
result[3] = matrix[3] * scale.y;
|
|
1171
|
+
result[4] = matrix[4] * scale.y;
|
|
1172
|
+
result[5] = matrix[5] * scale.y;
|
|
1173
|
+
result[6] = matrix[6] * scale.z;
|
|
1174
|
+
result[7] = matrix[7] * scale.z;
|
|
1175
|
+
result[8] = matrix[8] * scale.z;
|
|
1176
|
+
return result;
|
|
1177
|
+
};
|
|
1178
|
+
Matrix3.multiplyByUniformScale = function(matrix, scale, result) {
|
|
1179
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1180
|
+
Check_default.typeOf.number("scale", scale);
|
|
1181
|
+
Check_default.typeOf.object("result", result);
|
|
1182
|
+
result[0] = matrix[0] * scale;
|
|
1183
|
+
result[1] = matrix[1] * scale;
|
|
1184
|
+
result[2] = matrix[2] * scale;
|
|
1185
|
+
result[3] = matrix[3] * scale;
|
|
1186
|
+
result[4] = matrix[4] * scale;
|
|
1187
|
+
result[5] = matrix[5] * scale;
|
|
1188
|
+
result[6] = matrix[6] * scale;
|
|
1189
|
+
result[7] = matrix[7] * scale;
|
|
1190
|
+
result[8] = matrix[8] * scale;
|
|
1191
|
+
return result;
|
|
1192
|
+
};
|
|
1193
|
+
Matrix3.negate = function(matrix, result) {
|
|
1194
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1195
|
+
Check_default.typeOf.object("result", result);
|
|
1196
|
+
result[0] = -matrix[0];
|
|
1197
|
+
result[1] = -matrix[1];
|
|
1198
|
+
result[2] = -matrix[2];
|
|
1199
|
+
result[3] = -matrix[3];
|
|
1200
|
+
result[4] = -matrix[4];
|
|
1201
|
+
result[5] = -matrix[5];
|
|
1202
|
+
result[6] = -matrix[6];
|
|
1203
|
+
result[7] = -matrix[7];
|
|
1204
|
+
result[8] = -matrix[8];
|
|
1205
|
+
return result;
|
|
1206
|
+
};
|
|
1207
|
+
Matrix3.transpose = function(matrix, result) {
|
|
1208
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1209
|
+
Check_default.typeOf.object("result", result);
|
|
1210
|
+
const column0Row0 = matrix[0];
|
|
1211
|
+
const column0Row1 = matrix[3];
|
|
1212
|
+
const column0Row2 = matrix[6];
|
|
1213
|
+
const column1Row0 = matrix[1];
|
|
1214
|
+
const column1Row1 = matrix[4];
|
|
1215
|
+
const column1Row2 = matrix[7];
|
|
1216
|
+
const column2Row0 = matrix[2];
|
|
1217
|
+
const column2Row1 = matrix[5];
|
|
1218
|
+
const column2Row2 = matrix[8];
|
|
1219
|
+
result[0] = column0Row0;
|
|
1220
|
+
result[1] = column0Row1;
|
|
1221
|
+
result[2] = column0Row2;
|
|
1222
|
+
result[3] = column1Row0;
|
|
1223
|
+
result[4] = column1Row1;
|
|
1224
|
+
result[5] = column1Row2;
|
|
1225
|
+
result[6] = column2Row0;
|
|
1226
|
+
result[7] = column2Row1;
|
|
1227
|
+
result[8] = column2Row2;
|
|
1228
|
+
return result;
|
|
1229
|
+
};
|
|
1230
|
+
function computeFrobeniusNorm(matrix) {
|
|
1231
|
+
let norm = 0;
|
|
1232
|
+
for (let i = 0; i < 9; ++i) {
|
|
1233
|
+
const temp = matrix[i];
|
|
1234
|
+
norm += temp * temp;
|
|
1235
|
+
}
|
|
1236
|
+
return Math.sqrt(norm);
|
|
1237
|
+
}
|
|
1238
|
+
var rowVal = [1, 0, 0];
|
|
1239
|
+
var colVal = [2, 2, 1];
|
|
1240
|
+
function offDiagonalFrobeniusNorm(matrix) {
|
|
1241
|
+
let norm = 0;
|
|
1242
|
+
for (let i = 0; i < 3; ++i) {
|
|
1243
|
+
const temp = matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])];
|
|
1244
|
+
norm += 2 * temp * temp;
|
|
1245
|
+
}
|
|
1246
|
+
return Math.sqrt(norm);
|
|
1247
|
+
}
|
|
1248
|
+
function shurDecomposition(matrix, result) {
|
|
1249
|
+
const tolerance = Math_default.EPSILON15;
|
|
1250
|
+
let maxDiagonal = 0;
|
|
1251
|
+
let rotAxis = 1;
|
|
1252
|
+
for (let i = 0; i < 3; ++i) {
|
|
1253
|
+
const temp = Math.abs(
|
|
1254
|
+
matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])]
|
|
1255
|
+
);
|
|
1256
|
+
if (temp > maxDiagonal) {
|
|
1257
|
+
rotAxis = i;
|
|
1258
|
+
maxDiagonal = temp;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
let c = 1;
|
|
1262
|
+
let s = 0;
|
|
1263
|
+
const p = rowVal[rotAxis];
|
|
1264
|
+
const q = colVal[rotAxis];
|
|
1265
|
+
if (Math.abs(matrix[Matrix3.getElementIndex(q, p)]) > tolerance) {
|
|
1266
|
+
const qq = matrix[Matrix3.getElementIndex(q, q)];
|
|
1267
|
+
const pp = matrix[Matrix3.getElementIndex(p, p)];
|
|
1268
|
+
const qp = matrix[Matrix3.getElementIndex(q, p)];
|
|
1269
|
+
const tau = (qq - pp) / 2 / qp;
|
|
1270
|
+
let t;
|
|
1271
|
+
if (tau < 0) {
|
|
1272
|
+
t = -1 / (-tau + Math.sqrt(1 + tau * tau));
|
|
1273
|
+
} else {
|
|
1274
|
+
t = 1 / (tau + Math.sqrt(1 + tau * tau));
|
|
1275
|
+
}
|
|
1276
|
+
c = 1 / Math.sqrt(1 + t * t);
|
|
1277
|
+
s = t * c;
|
|
1278
|
+
}
|
|
1279
|
+
result = Matrix3.clone(Matrix3.IDENTITY, result);
|
|
1280
|
+
result[Matrix3.getElementIndex(p, p)] = result[Matrix3.getElementIndex(q, q)] = c;
|
|
1281
|
+
result[Matrix3.getElementIndex(q, p)] = s;
|
|
1282
|
+
result[Matrix3.getElementIndex(p, q)] = -s;
|
|
1283
|
+
return result;
|
|
1284
|
+
}
|
|
1285
|
+
var jMatrix = new Matrix3();
|
|
1286
|
+
var jMatrixTranspose = new Matrix3();
|
|
1287
|
+
Matrix3.computeEigenDecomposition = function(matrix, result) {
|
|
1288
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1289
|
+
const tolerance = Math_default.EPSILON20;
|
|
1290
|
+
const maxSweeps = 10;
|
|
1291
|
+
let count = 0;
|
|
1292
|
+
let sweep = 0;
|
|
1293
|
+
if (!defined_default(result)) {
|
|
1294
|
+
result = {};
|
|
1295
|
+
}
|
|
1296
|
+
const unitaryMatrix = result.unitary = Matrix3.clone(
|
|
1297
|
+
Matrix3.IDENTITY,
|
|
1298
|
+
result.unitary
|
|
1299
|
+
);
|
|
1300
|
+
const diagMatrix = result.diagonal = Matrix3.clone(matrix, result.diagonal);
|
|
1301
|
+
const epsilon = tolerance * computeFrobeniusNorm(diagMatrix);
|
|
1302
|
+
while (sweep < maxSweeps && offDiagonalFrobeniusNorm(diagMatrix) > epsilon) {
|
|
1303
|
+
shurDecomposition(diagMatrix, jMatrix);
|
|
1304
|
+
Matrix3.transpose(jMatrix, jMatrixTranspose);
|
|
1305
|
+
Matrix3.multiply(diagMatrix, jMatrix, diagMatrix);
|
|
1306
|
+
Matrix3.multiply(jMatrixTranspose, diagMatrix, diagMatrix);
|
|
1307
|
+
Matrix3.multiply(unitaryMatrix, jMatrix, unitaryMatrix);
|
|
1308
|
+
if (++count > 2) {
|
|
1309
|
+
++sweep;
|
|
1310
|
+
count = 0;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
return result;
|
|
1314
|
+
};
|
|
1315
|
+
Matrix3.abs = function(matrix, result) {
|
|
1316
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1317
|
+
Check_default.typeOf.object("result", result);
|
|
1318
|
+
result[0] = Math.abs(matrix[0]);
|
|
1319
|
+
result[1] = Math.abs(matrix[1]);
|
|
1320
|
+
result[2] = Math.abs(matrix[2]);
|
|
1321
|
+
result[3] = Math.abs(matrix[3]);
|
|
1322
|
+
result[4] = Math.abs(matrix[4]);
|
|
1323
|
+
result[5] = Math.abs(matrix[5]);
|
|
1324
|
+
result[6] = Math.abs(matrix[6]);
|
|
1325
|
+
result[7] = Math.abs(matrix[7]);
|
|
1326
|
+
result[8] = Math.abs(matrix[8]);
|
|
1327
|
+
return result;
|
|
1328
|
+
};
|
|
1329
|
+
Matrix3.determinant = function(matrix) {
|
|
1330
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1331
|
+
const m11 = matrix[0];
|
|
1332
|
+
const m21 = matrix[3];
|
|
1333
|
+
const m31 = matrix[6];
|
|
1334
|
+
const m12 = matrix[1];
|
|
1335
|
+
const m22 = matrix[4];
|
|
1336
|
+
const m32 = matrix[7];
|
|
1337
|
+
const m13 = matrix[2];
|
|
1338
|
+
const m23 = matrix[5];
|
|
1339
|
+
const m33 = matrix[8];
|
|
1340
|
+
return m11 * (m22 * m33 - m23 * m32) + m12 * (m23 * m31 - m21 * m33) + m13 * (m21 * m32 - m22 * m31);
|
|
1341
|
+
};
|
|
1342
|
+
Matrix3.inverse = function(matrix, result) {
|
|
1343
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1344
|
+
Check_default.typeOf.object("result", result);
|
|
1345
|
+
const m11 = matrix[0];
|
|
1346
|
+
const m21 = matrix[1];
|
|
1347
|
+
const m31 = matrix[2];
|
|
1348
|
+
const m12 = matrix[3];
|
|
1349
|
+
const m22 = matrix[4];
|
|
1350
|
+
const m32 = matrix[5];
|
|
1351
|
+
const m13 = matrix[6];
|
|
1352
|
+
const m23 = matrix[7];
|
|
1353
|
+
const m33 = matrix[8];
|
|
1354
|
+
const determinant = Matrix3.determinant(matrix);
|
|
1355
|
+
if (Math.abs(determinant) <= Math_default.EPSILON15) {
|
|
1356
|
+
throw new DeveloperError_default("matrix is not invertible");
|
|
1357
|
+
}
|
|
1358
|
+
result[0] = m22 * m33 - m23 * m32;
|
|
1359
|
+
result[1] = m23 * m31 - m21 * m33;
|
|
1360
|
+
result[2] = m21 * m32 - m22 * m31;
|
|
1361
|
+
result[3] = m13 * m32 - m12 * m33;
|
|
1362
|
+
result[4] = m11 * m33 - m13 * m31;
|
|
1363
|
+
result[5] = m12 * m31 - m11 * m32;
|
|
1364
|
+
result[6] = m12 * m23 - m13 * m22;
|
|
1365
|
+
result[7] = m13 * m21 - m11 * m23;
|
|
1366
|
+
result[8] = m11 * m22 - m12 * m21;
|
|
1367
|
+
const scale = 1 / determinant;
|
|
1368
|
+
return Matrix3.multiplyByScalar(result, scale, result);
|
|
1369
|
+
};
|
|
1370
|
+
var scratchTransposeMatrix = new Matrix3();
|
|
1371
|
+
Matrix3.inverseTranspose = function(matrix, result) {
|
|
1372
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1373
|
+
Check_default.typeOf.object("result", result);
|
|
1374
|
+
return Matrix3.inverse(
|
|
1375
|
+
Matrix3.transpose(matrix, scratchTransposeMatrix),
|
|
1376
|
+
result
|
|
1377
|
+
);
|
|
1378
|
+
};
|
|
1379
|
+
Matrix3.equals = function(left, right) {
|
|
1380
|
+
return left === right || defined_default(left) && defined_default(right) && left[0] === right[0] && left[1] === right[1] && left[2] === right[2] && left[3] === right[3] && left[4] === right[4] && left[5] === right[5] && left[6] === right[6] && left[7] === right[7] && left[8] === right[8];
|
|
1381
|
+
};
|
|
1382
|
+
Matrix3.equalsEpsilon = function(left, right, epsilon) {
|
|
1383
|
+
epsilon = epsilon ?? 0;
|
|
1384
|
+
return left === right || defined_default(left) && defined_default(right) && Math.abs(left[0] - right[0]) <= epsilon && Math.abs(left[1] - right[1]) <= epsilon && Math.abs(left[2] - right[2]) <= epsilon && Math.abs(left[3] - right[3]) <= epsilon && Math.abs(left[4] - right[4]) <= epsilon && Math.abs(left[5] - right[5]) <= epsilon && Math.abs(left[6] - right[6]) <= epsilon && Math.abs(left[7] - right[7]) <= epsilon && Math.abs(left[8] - right[8]) <= epsilon;
|
|
1385
|
+
};
|
|
1386
|
+
Matrix3.IDENTITY = Object.freeze(
|
|
1387
|
+
new Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1)
|
|
1388
|
+
);
|
|
1389
|
+
Matrix3.ZERO = Object.freeze(
|
|
1390
|
+
new Matrix3(0, 0, 0, 0, 0, 0, 0, 0, 0)
|
|
1391
|
+
);
|
|
1392
|
+
Matrix3.COLUMN0ROW0 = 0;
|
|
1393
|
+
Matrix3.COLUMN0ROW1 = 1;
|
|
1394
|
+
Matrix3.COLUMN0ROW2 = 2;
|
|
1395
|
+
Matrix3.COLUMN1ROW0 = 3;
|
|
1396
|
+
Matrix3.COLUMN1ROW1 = 4;
|
|
1397
|
+
Matrix3.COLUMN1ROW2 = 5;
|
|
1398
|
+
Matrix3.COLUMN2ROW0 = 6;
|
|
1399
|
+
Matrix3.COLUMN2ROW1 = 7;
|
|
1400
|
+
Matrix3.COLUMN2ROW2 = 8;
|
|
1401
|
+
Object.defineProperties(Matrix3.prototype, {
|
|
1402
|
+
/**
|
|
1403
|
+
* Gets the number of items in the collection.
|
|
1404
|
+
* @memberof Matrix3.prototype
|
|
1405
|
+
*
|
|
1406
|
+
* @type {number}
|
|
1407
|
+
*/
|
|
1408
|
+
length: {
|
|
1409
|
+
get: function() {
|
|
1410
|
+
return Matrix3.packedLength;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
Matrix3.prototype.clone = function(result) {
|
|
1415
|
+
return Matrix3.clone(this, result);
|
|
1416
|
+
};
|
|
1417
|
+
Matrix3.prototype.equals = function(right) {
|
|
1418
|
+
return Matrix3.equals(this, right);
|
|
1419
|
+
};
|
|
1420
|
+
Matrix3.equalsArray = function(matrix, array, offset) {
|
|
1421
|
+
return matrix[0] === array[offset] && matrix[1] === array[offset + 1] && matrix[2] === array[offset + 2] && matrix[3] === array[offset + 3] && matrix[4] === array[offset + 4] && matrix[5] === array[offset + 5] && matrix[6] === array[offset + 6] && matrix[7] === array[offset + 7] && matrix[8] === array[offset + 8];
|
|
1422
|
+
};
|
|
1423
|
+
Matrix3.prototype.equalsEpsilon = function(right, epsilon) {
|
|
1424
|
+
return Matrix3.equalsEpsilon(this, right, epsilon);
|
|
1425
|
+
};
|
|
1426
|
+
Matrix3.prototype.toString = function() {
|
|
1427
|
+
return `(${this[0]}, ${this[3]}, ${this[6]})
|
|
1428
|
+
(${this[1]}, ${this[4]}, ${this[7]})
|
|
1429
|
+
(${this[2]}, ${this[5]}, ${this[8]})`;
|
|
1430
|
+
};
|
|
1431
|
+
var Matrix3_default = Matrix3;
|
|
1432
|
+
|
|
1433
|
+
// packages/engine/Source/Core/Frozen.js
|
|
1434
|
+
var Frozen = {};
|
|
1435
|
+
Frozen.EMPTY_OBJECT = Object.freeze({});
|
|
1436
|
+
Frozen.EMPTY_ARRAY = Object.freeze([]);
|
|
1437
|
+
var Frozen_default = Frozen;
|
|
1438
|
+
|
|
1439
|
+
export {
|
|
1440
|
+
Cartesian3_default,
|
|
1441
|
+
Matrix3_default,
|
|
1442
|
+
Frozen_default
|
|
1443
|
+
};
|