deeptwins-cesium-engine 0.0.4 → 0.0.6
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/ThirdParty/Workers/pako_deflate.min.js +503 -0
- package/Build/ThirdParty/Workers/pako_inflate.min.js +698 -0
- package/Build/Workers/chunk-2QYBZCFQ.js +163 -0
- package/Build/Workers/chunk-3D5MMPR6.js +497 -0
- package/Build/Workers/chunk-3FVCV7Y6.js +1483 -0
- package/Build/Workers/chunk-3GWSOCSN.js +1054 -0
- package/Build/Workers/chunk-46AZ4DAY.js +97 -0
- package/Build/Workers/chunk-4QX3NLRI.js +352 -0
- package/Build/Workers/chunk-5WQ6G3V5.js +114 -0
- package/Build/Workers/chunk-6H24F2MX.js +101 -0
- package/Build/Workers/chunk-ADSMQMR3.js +75 -0
- package/Build/Workers/chunk-ATP2KQO2.js +138 -0
- package/Build/Workers/chunk-AXYTFE2Q.js +642 -0
- package/Build/Workers/chunk-BA5B3QSO.js +1067 -0
- package/Build/Workers/chunk-BENDB2TP.js +44 -0
- package/Build/Workers/chunk-BSC7UFN5.js +73 -0
- package/Build/Workers/chunk-CDKPSKFL.js +37 -0
- package/Build/Workers/chunk-D6MRUQSS.js +256 -0
- package/Build/Workers/chunk-DBMJUNPI.js +305 -0
- package/Build/Workers/chunk-DE3L2T6Q.js +455 -0
- package/Build/Workers/chunk-DHY454TR.js +476 -0
- package/Build/Workers/chunk-EBV6YMT4.js +55 -0
- package/Build/Workers/chunk-ERWGQECA.js +55 -0
- package/Build/Workers/chunk-ESZKPTFQ.js +352 -0
- package/Build/Workers/chunk-F3HD4EGB.js +837 -0
- package/Build/Workers/chunk-GBN24WJI.js +198 -0
- package/Build/Workers/chunk-GLEP7WAP.js +692 -0
- package/Build/Workers/chunk-JEMRORA4.js +299 -0
- package/Build/Workers/chunk-JME6YHTN.js +682 -0
- package/Build/Workers/chunk-JPACOFW4.js +1443 -0
- package/Build/Workers/chunk-KTCUNCP6.js +139 -0
- package/Build/Workers/chunk-KUWX2S7J.js +2715 -0
- package/Build/Workers/chunk-KZJGDCOL.js +969 -0
- package/Build/Workers/chunk-LFQCF6XE.js +162 -0
- package/Build/Workers/chunk-MPKHH7V5.js +778 -0
- package/Build/Workers/chunk-N2B6WRSU.js +511 -0
- package/Build/Workers/chunk-N4VDVDGG.js +1317 -0
- package/Build/Workers/chunk-NGDTSO5G.js +2719 -0
- package/Build/Workers/chunk-NM2CSNDO.js +439 -0
- package/Build/Workers/chunk-O2MJVOWI.js +368 -0
- package/Build/Workers/chunk-O57JMXRV.js +788 -0
- package/Build/Workers/chunk-P2Q5LZL7.js +1800 -0
- package/Build/Workers/chunk-PTGWOENQ.js +102 -0
- package/Build/Workers/chunk-PTJNNSFD.js +629 -0
- package/Build/Workers/chunk-QCWI6UJJ.js +280 -0
- package/Build/Workers/chunk-QLEDW2RP.js +241 -0
- package/Build/Workers/chunk-QRQFI7TC.js +124 -0
- package/Build/Workers/chunk-R73G3H3Q.js +171 -0
- package/Build/Workers/chunk-RG7FJROK.js +414 -0
- package/Build/Workers/chunk-RSA5TPUO.js +398 -0
- package/Build/Workers/chunk-S5HDPNWJ.js +940 -0
- package/Build/Workers/chunk-SAA7QZDG.js +387 -0
- package/Build/Workers/chunk-T46NAKWG.js +58 -0
- package/Build/Workers/chunk-UMONYDWP.js +2058 -0
- package/Build/Workers/chunk-VGSPLVTX.js +1460 -0
- package/Build/Workers/chunk-WOTYILS4.js +219 -0
- package/Build/Workers/chunk-YA37IWET.js +57 -0
- package/Build/Workers/chunk-YCEZX7OI.js +8366 -0
- package/Build/Workers/chunk-ZWANDE2Q.js +288 -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 +47 -55
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Scene/TextureAtlasRegress.js +558 -0
- package/Source/ThirdParty/Workers/pako_deflate.min.js +2 -0
- package/Source/ThirdParty/Workers/pako_inflate.min.js +2 -0
- package/index.js +90 -89
- package/package.json +1 -1
|
@@ -0,0 +1,2058 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Cesium - https://github.com/CesiumGS/cesium
|
|
4
|
+
* Version 0.0.31
|
|
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
|
+
RuntimeError_default
|
|
28
|
+
} from "./chunk-T46NAKWG.js";
|
|
29
|
+
import {
|
|
30
|
+
Cartesian3_default,
|
|
31
|
+
Frozen_default,
|
|
32
|
+
Matrix3_default
|
|
33
|
+
} from "./chunk-JPACOFW4.js";
|
|
34
|
+
import {
|
|
35
|
+
Math_default
|
|
36
|
+
} from "./chunk-3D5MMPR6.js";
|
|
37
|
+
import {
|
|
38
|
+
Check_default,
|
|
39
|
+
DeveloperError_default
|
|
40
|
+
} from "./chunk-2QYBZCFQ.js";
|
|
41
|
+
import {
|
|
42
|
+
defined_default
|
|
43
|
+
} from "./chunk-ADSMQMR3.js";
|
|
44
|
+
|
|
45
|
+
// packages/engine/Source/Core/Cartesian4.js
|
|
46
|
+
function Cartesian4(x, y, z, w) {
|
|
47
|
+
this.x = x ?? 0;
|
|
48
|
+
this.y = y ?? 0;
|
|
49
|
+
this.z = z ?? 0;
|
|
50
|
+
this.w = w ?? 0;
|
|
51
|
+
}
|
|
52
|
+
Cartesian4.fromElements = function(x, y, z, w, result) {
|
|
53
|
+
if (!defined_default(result)) {
|
|
54
|
+
return new Cartesian4(x, y, z, w);
|
|
55
|
+
}
|
|
56
|
+
result.x = x;
|
|
57
|
+
result.y = y;
|
|
58
|
+
result.z = z;
|
|
59
|
+
result.w = w;
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
Cartesian4.fromColor = function(color, result) {
|
|
63
|
+
Check_default.typeOf.object("color", color);
|
|
64
|
+
if (!defined_default(result)) {
|
|
65
|
+
return new Cartesian4(color.red, color.green, color.blue, color.alpha);
|
|
66
|
+
}
|
|
67
|
+
result.x = color.red;
|
|
68
|
+
result.y = color.green;
|
|
69
|
+
result.z = color.blue;
|
|
70
|
+
result.w = color.alpha;
|
|
71
|
+
return result;
|
|
72
|
+
};
|
|
73
|
+
Cartesian4.clone = function(cartesian, result) {
|
|
74
|
+
if (!defined_default(cartesian)) {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
if (!defined_default(result)) {
|
|
78
|
+
return new Cartesian4(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
|
|
79
|
+
}
|
|
80
|
+
result.x = cartesian.x;
|
|
81
|
+
result.y = cartesian.y;
|
|
82
|
+
result.z = cartesian.z;
|
|
83
|
+
result.w = cartesian.w;
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
Cartesian4.packedLength = 4;
|
|
87
|
+
Cartesian4.pack = function(value, array, startingIndex) {
|
|
88
|
+
Check_default.typeOf.object("value", value);
|
|
89
|
+
Check_default.defined("array", array);
|
|
90
|
+
startingIndex = startingIndex ?? 0;
|
|
91
|
+
array[startingIndex++] = value.x;
|
|
92
|
+
array[startingIndex++] = value.y;
|
|
93
|
+
array[startingIndex++] = value.z;
|
|
94
|
+
array[startingIndex] = value.w;
|
|
95
|
+
return array;
|
|
96
|
+
};
|
|
97
|
+
Cartesian4.unpack = function(array, startingIndex, result) {
|
|
98
|
+
Check_default.defined("array", array);
|
|
99
|
+
startingIndex = startingIndex ?? 0;
|
|
100
|
+
if (!defined_default(result)) {
|
|
101
|
+
result = new Cartesian4();
|
|
102
|
+
}
|
|
103
|
+
result.x = array[startingIndex++];
|
|
104
|
+
result.y = array[startingIndex++];
|
|
105
|
+
result.z = array[startingIndex++];
|
|
106
|
+
result.w = array[startingIndex];
|
|
107
|
+
return result;
|
|
108
|
+
};
|
|
109
|
+
Cartesian4.packArray = function(array, result) {
|
|
110
|
+
Check_default.defined("array", array);
|
|
111
|
+
const length = array.length;
|
|
112
|
+
const resultLength = length * 4;
|
|
113
|
+
if (!defined_default(result)) {
|
|
114
|
+
result = new Array(resultLength);
|
|
115
|
+
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
116
|
+
throw new DeveloperError_default(
|
|
117
|
+
"If result is a typed array, it must have exactly array.length * 4 elements"
|
|
118
|
+
);
|
|
119
|
+
} else if (result.length !== resultLength) {
|
|
120
|
+
result.length = resultLength;
|
|
121
|
+
}
|
|
122
|
+
for (let i = 0; i < length; ++i) {
|
|
123
|
+
Cartesian4.pack(array[i], result, i * 4);
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
};
|
|
127
|
+
Cartesian4.unpackArray = function(array, result) {
|
|
128
|
+
Check_default.defined("array", array);
|
|
129
|
+
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
|
|
130
|
+
if (array.length % 4 !== 0) {
|
|
131
|
+
throw new DeveloperError_default("array length must be a multiple of 4.");
|
|
132
|
+
}
|
|
133
|
+
const length = array.length;
|
|
134
|
+
if (!defined_default(result)) {
|
|
135
|
+
result = new Array(length / 4);
|
|
136
|
+
} else {
|
|
137
|
+
result.length = length / 4;
|
|
138
|
+
}
|
|
139
|
+
for (let i = 0; i < length; i += 4) {
|
|
140
|
+
const index = i / 4;
|
|
141
|
+
result[index] = Cartesian4.unpack(array, i, result[index]);
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
};
|
|
145
|
+
Cartesian4.fromArray = Cartesian4.unpack;
|
|
146
|
+
Cartesian4.maximumComponent = function(cartesian) {
|
|
147
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
148
|
+
return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
|
|
149
|
+
};
|
|
150
|
+
Cartesian4.minimumComponent = function(cartesian) {
|
|
151
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
152
|
+
return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
|
|
153
|
+
};
|
|
154
|
+
Cartesian4.minimumByComponent = 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.min(first.x, second.x);
|
|
159
|
+
result.y = Math.min(first.y, second.y);
|
|
160
|
+
result.z = Math.min(first.z, second.z);
|
|
161
|
+
result.w = Math.min(first.w, second.w);
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
Cartesian4.maximumByComponent = function(first, second, result) {
|
|
165
|
+
Check_default.typeOf.object("first", first);
|
|
166
|
+
Check_default.typeOf.object("second", second);
|
|
167
|
+
Check_default.typeOf.object("result", result);
|
|
168
|
+
result.x = Math.max(first.x, second.x);
|
|
169
|
+
result.y = Math.max(first.y, second.y);
|
|
170
|
+
result.z = Math.max(first.z, second.z);
|
|
171
|
+
result.w = Math.max(first.w, second.w);
|
|
172
|
+
return result;
|
|
173
|
+
};
|
|
174
|
+
Cartesian4.clamp = function(value, min, max, result) {
|
|
175
|
+
Check_default.typeOf.object("value", value);
|
|
176
|
+
Check_default.typeOf.object("min", min);
|
|
177
|
+
Check_default.typeOf.object("max", max);
|
|
178
|
+
Check_default.typeOf.object("result", result);
|
|
179
|
+
const x = Math_default.clamp(value.x, min.x, max.x);
|
|
180
|
+
const y = Math_default.clamp(value.y, min.y, max.y);
|
|
181
|
+
const z = Math_default.clamp(value.z, min.z, max.z);
|
|
182
|
+
const w = Math_default.clamp(value.w, min.w, max.w);
|
|
183
|
+
result.x = x;
|
|
184
|
+
result.y = y;
|
|
185
|
+
result.z = z;
|
|
186
|
+
result.w = w;
|
|
187
|
+
return result;
|
|
188
|
+
};
|
|
189
|
+
Cartesian4.magnitudeSquared = function(cartesian) {
|
|
190
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
191
|
+
return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z + cartesian.w * cartesian.w;
|
|
192
|
+
};
|
|
193
|
+
Cartesian4.magnitude = function(cartesian) {
|
|
194
|
+
return Math.sqrt(Cartesian4.magnitudeSquared(cartesian));
|
|
195
|
+
};
|
|
196
|
+
var distanceScratch = new Cartesian4();
|
|
197
|
+
Cartesian4.distance = function(left, right) {
|
|
198
|
+
Check_default.typeOf.object("left", left);
|
|
199
|
+
Check_default.typeOf.object("right", right);
|
|
200
|
+
Cartesian4.subtract(left, right, distanceScratch);
|
|
201
|
+
return Cartesian4.magnitude(distanceScratch);
|
|
202
|
+
};
|
|
203
|
+
Cartesian4.distanceSquared = function(left, right) {
|
|
204
|
+
Check_default.typeOf.object("left", left);
|
|
205
|
+
Check_default.typeOf.object("right", right);
|
|
206
|
+
Cartesian4.subtract(left, right, distanceScratch);
|
|
207
|
+
return Cartesian4.magnitudeSquared(distanceScratch);
|
|
208
|
+
};
|
|
209
|
+
Cartesian4.normalize = function(cartesian, result) {
|
|
210
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
211
|
+
Check_default.typeOf.object("result", result);
|
|
212
|
+
const magnitude = Cartesian4.magnitude(cartesian);
|
|
213
|
+
result.x = cartesian.x / magnitude;
|
|
214
|
+
result.y = cartesian.y / magnitude;
|
|
215
|
+
result.z = cartesian.z / magnitude;
|
|
216
|
+
result.w = cartesian.w / magnitude;
|
|
217
|
+
if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z) || isNaN(result.w)) {
|
|
218
|
+
throw new DeveloperError_default("normalized result is not a number");
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
};
|
|
222
|
+
Cartesian4.dot = function(left, right) {
|
|
223
|
+
Check_default.typeOf.object("left", left);
|
|
224
|
+
Check_default.typeOf.object("right", right);
|
|
225
|
+
return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
|
|
226
|
+
};
|
|
227
|
+
Cartesian4.multiplyComponents = function(left, right, result) {
|
|
228
|
+
Check_default.typeOf.object("left", left);
|
|
229
|
+
Check_default.typeOf.object("right", right);
|
|
230
|
+
Check_default.typeOf.object("result", result);
|
|
231
|
+
result.x = left.x * right.x;
|
|
232
|
+
result.y = left.y * right.y;
|
|
233
|
+
result.z = left.z * right.z;
|
|
234
|
+
result.w = left.w * right.w;
|
|
235
|
+
return result;
|
|
236
|
+
};
|
|
237
|
+
Cartesian4.divideComponents = function(left, right, result) {
|
|
238
|
+
Check_default.typeOf.object("left", left);
|
|
239
|
+
Check_default.typeOf.object("right", right);
|
|
240
|
+
Check_default.typeOf.object("result", result);
|
|
241
|
+
result.x = left.x / right.x;
|
|
242
|
+
result.y = left.y / right.y;
|
|
243
|
+
result.z = left.z / right.z;
|
|
244
|
+
result.w = left.w / right.w;
|
|
245
|
+
return result;
|
|
246
|
+
};
|
|
247
|
+
Cartesian4.add = function(left, right, result) {
|
|
248
|
+
Check_default.typeOf.object("left", left);
|
|
249
|
+
Check_default.typeOf.object("right", right);
|
|
250
|
+
Check_default.typeOf.object("result", result);
|
|
251
|
+
result.x = left.x + right.x;
|
|
252
|
+
result.y = left.y + right.y;
|
|
253
|
+
result.z = left.z + right.z;
|
|
254
|
+
result.w = left.w + right.w;
|
|
255
|
+
return result;
|
|
256
|
+
};
|
|
257
|
+
Cartesian4.subtract = function(left, right, result) {
|
|
258
|
+
Check_default.typeOf.object("left", left);
|
|
259
|
+
Check_default.typeOf.object("right", right);
|
|
260
|
+
Check_default.typeOf.object("result", result);
|
|
261
|
+
result.x = left.x - right.x;
|
|
262
|
+
result.y = left.y - right.y;
|
|
263
|
+
result.z = left.z - right.z;
|
|
264
|
+
result.w = left.w - right.w;
|
|
265
|
+
return result;
|
|
266
|
+
};
|
|
267
|
+
Cartesian4.multiplyByScalar = function(cartesian, scalar, result) {
|
|
268
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
269
|
+
Check_default.typeOf.number("scalar", scalar);
|
|
270
|
+
Check_default.typeOf.object("result", result);
|
|
271
|
+
result.x = cartesian.x * scalar;
|
|
272
|
+
result.y = cartesian.y * scalar;
|
|
273
|
+
result.z = cartesian.z * scalar;
|
|
274
|
+
result.w = cartesian.w * scalar;
|
|
275
|
+
return result;
|
|
276
|
+
};
|
|
277
|
+
Cartesian4.divideByScalar = function(cartesian, scalar, result) {
|
|
278
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
279
|
+
Check_default.typeOf.number("scalar", scalar);
|
|
280
|
+
Check_default.typeOf.object("result", result);
|
|
281
|
+
result.x = cartesian.x / scalar;
|
|
282
|
+
result.y = cartesian.y / scalar;
|
|
283
|
+
result.z = cartesian.z / scalar;
|
|
284
|
+
result.w = cartesian.w / scalar;
|
|
285
|
+
return result;
|
|
286
|
+
};
|
|
287
|
+
Cartesian4.negate = function(cartesian, result) {
|
|
288
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
289
|
+
Check_default.typeOf.object("result", result);
|
|
290
|
+
result.x = -cartesian.x;
|
|
291
|
+
result.y = -cartesian.y;
|
|
292
|
+
result.z = -cartesian.z;
|
|
293
|
+
result.w = -cartesian.w;
|
|
294
|
+
return result;
|
|
295
|
+
};
|
|
296
|
+
Cartesian4.abs = function(cartesian, result) {
|
|
297
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
298
|
+
Check_default.typeOf.object("result", result);
|
|
299
|
+
result.x = Math.abs(cartesian.x);
|
|
300
|
+
result.y = Math.abs(cartesian.y);
|
|
301
|
+
result.z = Math.abs(cartesian.z);
|
|
302
|
+
result.w = Math.abs(cartesian.w);
|
|
303
|
+
return result;
|
|
304
|
+
};
|
|
305
|
+
var lerpScratch = new Cartesian4();
|
|
306
|
+
Cartesian4.lerp = function(start, end, t, result) {
|
|
307
|
+
Check_default.typeOf.object("start", start);
|
|
308
|
+
Check_default.typeOf.object("end", end);
|
|
309
|
+
Check_default.typeOf.number("t", t);
|
|
310
|
+
Check_default.typeOf.object("result", result);
|
|
311
|
+
Cartesian4.multiplyByScalar(end, t, lerpScratch);
|
|
312
|
+
result = Cartesian4.multiplyByScalar(start, 1 - t, result);
|
|
313
|
+
return Cartesian4.add(lerpScratch, result, result);
|
|
314
|
+
};
|
|
315
|
+
var mostOrthogonalAxisScratch = new Cartesian4();
|
|
316
|
+
Cartesian4.mostOrthogonalAxis = function(cartesian, result) {
|
|
317
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
318
|
+
Check_default.typeOf.object("result", result);
|
|
319
|
+
const f = Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);
|
|
320
|
+
Cartesian4.abs(f, f);
|
|
321
|
+
if (f.x <= f.y) {
|
|
322
|
+
if (f.x <= f.z) {
|
|
323
|
+
if (f.x <= f.w) {
|
|
324
|
+
result = Cartesian4.clone(Cartesian4.UNIT_X, result);
|
|
325
|
+
} else {
|
|
326
|
+
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
|
|
327
|
+
}
|
|
328
|
+
} else if (f.z <= f.w) {
|
|
329
|
+
result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
|
|
330
|
+
} else {
|
|
331
|
+
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
|
|
332
|
+
}
|
|
333
|
+
} else if (f.y <= f.z) {
|
|
334
|
+
if (f.y <= f.w) {
|
|
335
|
+
result = Cartesian4.clone(Cartesian4.UNIT_Y, result);
|
|
336
|
+
} else {
|
|
337
|
+
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
|
|
338
|
+
}
|
|
339
|
+
} else if (f.z <= f.w) {
|
|
340
|
+
result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
|
|
341
|
+
} else {
|
|
342
|
+
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
|
|
343
|
+
}
|
|
344
|
+
return result;
|
|
345
|
+
};
|
|
346
|
+
Cartesian4.equals = function(left, right) {
|
|
347
|
+
return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y && left.z === right.z && left.w === right.w;
|
|
348
|
+
};
|
|
349
|
+
Cartesian4.equalsArray = function(cartesian, array, offset) {
|
|
350
|
+
return cartesian.x === array[offset] && cartesian.y === array[offset + 1] && cartesian.z === array[offset + 2] && cartesian.w === array[offset + 3];
|
|
351
|
+
};
|
|
352
|
+
Cartesian4.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
|
|
353
|
+
return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
|
|
354
|
+
left.x,
|
|
355
|
+
right.x,
|
|
356
|
+
relativeEpsilon,
|
|
357
|
+
absoluteEpsilon
|
|
358
|
+
) && Math_default.equalsEpsilon(
|
|
359
|
+
left.y,
|
|
360
|
+
right.y,
|
|
361
|
+
relativeEpsilon,
|
|
362
|
+
absoluteEpsilon
|
|
363
|
+
) && Math_default.equalsEpsilon(
|
|
364
|
+
left.z,
|
|
365
|
+
right.z,
|
|
366
|
+
relativeEpsilon,
|
|
367
|
+
absoluteEpsilon
|
|
368
|
+
) && Math_default.equalsEpsilon(
|
|
369
|
+
left.w,
|
|
370
|
+
right.w,
|
|
371
|
+
relativeEpsilon,
|
|
372
|
+
absoluteEpsilon
|
|
373
|
+
);
|
|
374
|
+
};
|
|
375
|
+
Cartesian4.ZERO = Object.freeze(new Cartesian4(0, 0, 0, 0));
|
|
376
|
+
Cartesian4.ONE = Object.freeze(new Cartesian4(1, 1, 1, 1));
|
|
377
|
+
Cartesian4.UNIT_X = Object.freeze(new Cartesian4(1, 0, 0, 0));
|
|
378
|
+
Cartesian4.UNIT_Y = Object.freeze(new Cartesian4(0, 1, 0, 0));
|
|
379
|
+
Cartesian4.UNIT_Z = Object.freeze(new Cartesian4(0, 0, 1, 0));
|
|
380
|
+
Cartesian4.UNIT_W = Object.freeze(new Cartesian4(0, 0, 0, 1));
|
|
381
|
+
Cartesian4.prototype.clone = function(result) {
|
|
382
|
+
return Cartesian4.clone(this, result);
|
|
383
|
+
};
|
|
384
|
+
Cartesian4.prototype.equals = function(right) {
|
|
385
|
+
return Cartesian4.equals(this, right);
|
|
386
|
+
};
|
|
387
|
+
Cartesian4.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
|
|
388
|
+
return Cartesian4.equalsEpsilon(
|
|
389
|
+
this,
|
|
390
|
+
right,
|
|
391
|
+
relativeEpsilon,
|
|
392
|
+
absoluteEpsilon
|
|
393
|
+
);
|
|
394
|
+
};
|
|
395
|
+
Cartesian4.prototype.toString = function() {
|
|
396
|
+
return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
|
|
397
|
+
};
|
|
398
|
+
var scratchF32Array = new Float32Array(1);
|
|
399
|
+
var scratchU8Array = new Uint8Array(scratchF32Array.buffer);
|
|
400
|
+
var testU32 = new Uint32Array([287454020]);
|
|
401
|
+
var testU8 = new Uint8Array(testU32.buffer);
|
|
402
|
+
var littleEndian = testU8[0] === 68;
|
|
403
|
+
Cartesian4.packFloat = function(value, result) {
|
|
404
|
+
Check_default.typeOf.number("value", value);
|
|
405
|
+
if (!defined_default(result)) {
|
|
406
|
+
result = new Cartesian4();
|
|
407
|
+
}
|
|
408
|
+
scratchF32Array[0] = value;
|
|
409
|
+
if (littleEndian) {
|
|
410
|
+
result.x = scratchU8Array[0];
|
|
411
|
+
result.y = scratchU8Array[1];
|
|
412
|
+
result.z = scratchU8Array[2];
|
|
413
|
+
result.w = scratchU8Array[3];
|
|
414
|
+
} else {
|
|
415
|
+
result.x = scratchU8Array[3];
|
|
416
|
+
result.y = scratchU8Array[2];
|
|
417
|
+
result.z = scratchU8Array[1];
|
|
418
|
+
result.w = scratchU8Array[0];
|
|
419
|
+
}
|
|
420
|
+
return result;
|
|
421
|
+
};
|
|
422
|
+
Cartesian4.unpackFloat = function(packedFloat) {
|
|
423
|
+
Check_default.typeOf.object("packedFloat", packedFloat);
|
|
424
|
+
if (littleEndian) {
|
|
425
|
+
scratchU8Array[0] = packedFloat.x;
|
|
426
|
+
scratchU8Array[1] = packedFloat.y;
|
|
427
|
+
scratchU8Array[2] = packedFloat.z;
|
|
428
|
+
scratchU8Array[3] = packedFloat.w;
|
|
429
|
+
} else {
|
|
430
|
+
scratchU8Array[0] = packedFloat.w;
|
|
431
|
+
scratchU8Array[1] = packedFloat.z;
|
|
432
|
+
scratchU8Array[2] = packedFloat.y;
|
|
433
|
+
scratchU8Array[3] = packedFloat.x;
|
|
434
|
+
}
|
|
435
|
+
return scratchF32Array[0];
|
|
436
|
+
};
|
|
437
|
+
var Cartesian4_default = Cartesian4;
|
|
438
|
+
|
|
439
|
+
// packages/engine/Source/Core/Matrix4.js
|
|
440
|
+
function Matrix4(column0Row0, column1Row0, column2Row0, column3Row0, column0Row1, column1Row1, column2Row1, column3Row1, column0Row2, column1Row2, column2Row2, column3Row2, column0Row3, column1Row3, column2Row3, column3Row3) {
|
|
441
|
+
this[0] = column0Row0 ?? 0;
|
|
442
|
+
this[1] = column0Row1 ?? 0;
|
|
443
|
+
this[2] = column0Row2 ?? 0;
|
|
444
|
+
this[3] = column0Row3 ?? 0;
|
|
445
|
+
this[4] = column1Row0 ?? 0;
|
|
446
|
+
this[5] = column1Row1 ?? 0;
|
|
447
|
+
this[6] = column1Row2 ?? 0;
|
|
448
|
+
this[7] = column1Row3 ?? 0;
|
|
449
|
+
this[8] = column2Row0 ?? 0;
|
|
450
|
+
this[9] = column2Row1 ?? 0;
|
|
451
|
+
this[10] = column2Row2 ?? 0;
|
|
452
|
+
this[11] = column2Row3 ?? 0;
|
|
453
|
+
this[12] = column3Row0 ?? 0;
|
|
454
|
+
this[13] = column3Row1 ?? 0;
|
|
455
|
+
this[14] = column3Row2 ?? 0;
|
|
456
|
+
this[15] = column3Row3 ?? 0;
|
|
457
|
+
}
|
|
458
|
+
Matrix4.packedLength = 16;
|
|
459
|
+
Matrix4.pack = function(value, array, startingIndex) {
|
|
460
|
+
Check_default.typeOf.object("value", value);
|
|
461
|
+
Check_default.defined("array", array);
|
|
462
|
+
startingIndex = startingIndex ?? 0;
|
|
463
|
+
array[startingIndex++] = value[0];
|
|
464
|
+
array[startingIndex++] = value[1];
|
|
465
|
+
array[startingIndex++] = value[2];
|
|
466
|
+
array[startingIndex++] = value[3];
|
|
467
|
+
array[startingIndex++] = value[4];
|
|
468
|
+
array[startingIndex++] = value[5];
|
|
469
|
+
array[startingIndex++] = value[6];
|
|
470
|
+
array[startingIndex++] = value[7];
|
|
471
|
+
array[startingIndex++] = value[8];
|
|
472
|
+
array[startingIndex++] = value[9];
|
|
473
|
+
array[startingIndex++] = value[10];
|
|
474
|
+
array[startingIndex++] = value[11];
|
|
475
|
+
array[startingIndex++] = value[12];
|
|
476
|
+
array[startingIndex++] = value[13];
|
|
477
|
+
array[startingIndex++] = value[14];
|
|
478
|
+
array[startingIndex] = value[15];
|
|
479
|
+
return array;
|
|
480
|
+
};
|
|
481
|
+
Matrix4.unpack = function(array, startingIndex, result) {
|
|
482
|
+
Check_default.defined("array", array);
|
|
483
|
+
startingIndex = startingIndex ?? 0;
|
|
484
|
+
if (!defined_default(result)) {
|
|
485
|
+
result = new Matrix4();
|
|
486
|
+
}
|
|
487
|
+
result[0] = array[startingIndex++];
|
|
488
|
+
result[1] = array[startingIndex++];
|
|
489
|
+
result[2] = array[startingIndex++];
|
|
490
|
+
result[3] = array[startingIndex++];
|
|
491
|
+
result[4] = array[startingIndex++];
|
|
492
|
+
result[5] = array[startingIndex++];
|
|
493
|
+
result[6] = array[startingIndex++];
|
|
494
|
+
result[7] = array[startingIndex++];
|
|
495
|
+
result[8] = array[startingIndex++];
|
|
496
|
+
result[9] = array[startingIndex++];
|
|
497
|
+
result[10] = array[startingIndex++];
|
|
498
|
+
result[11] = array[startingIndex++];
|
|
499
|
+
result[12] = array[startingIndex++];
|
|
500
|
+
result[13] = array[startingIndex++];
|
|
501
|
+
result[14] = array[startingIndex++];
|
|
502
|
+
result[15] = array[startingIndex];
|
|
503
|
+
return result;
|
|
504
|
+
};
|
|
505
|
+
Matrix4.packArray = function(array, result) {
|
|
506
|
+
Check_default.defined("array", array);
|
|
507
|
+
const length = array.length;
|
|
508
|
+
const resultLength = length * 16;
|
|
509
|
+
if (!defined_default(result)) {
|
|
510
|
+
result = new Array(resultLength);
|
|
511
|
+
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
512
|
+
throw new DeveloperError_default(
|
|
513
|
+
"If result is a typed array, it must have exactly array.length * 16 elements"
|
|
514
|
+
);
|
|
515
|
+
} else if (result.length !== resultLength) {
|
|
516
|
+
result.length = resultLength;
|
|
517
|
+
}
|
|
518
|
+
for (let i = 0; i < length; ++i) {
|
|
519
|
+
Matrix4.pack(array[i], result, i * 16);
|
|
520
|
+
}
|
|
521
|
+
return result;
|
|
522
|
+
};
|
|
523
|
+
Matrix4.unpackArray = function(array, result) {
|
|
524
|
+
Check_default.defined("array", array);
|
|
525
|
+
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 16);
|
|
526
|
+
if (array.length % 16 !== 0) {
|
|
527
|
+
throw new DeveloperError_default("array length must be a multiple of 16.");
|
|
528
|
+
}
|
|
529
|
+
const length = array.length;
|
|
530
|
+
if (!defined_default(result)) {
|
|
531
|
+
result = new Array(length / 16);
|
|
532
|
+
} else {
|
|
533
|
+
result.length = length / 16;
|
|
534
|
+
}
|
|
535
|
+
for (let i = 0; i < length; i += 16) {
|
|
536
|
+
const index = i / 16;
|
|
537
|
+
result[index] = Matrix4.unpack(array, i, result[index]);
|
|
538
|
+
}
|
|
539
|
+
return result;
|
|
540
|
+
};
|
|
541
|
+
Matrix4.clone = function(matrix, result) {
|
|
542
|
+
if (!defined_default(matrix)) {
|
|
543
|
+
return void 0;
|
|
544
|
+
}
|
|
545
|
+
if (!defined_default(result)) {
|
|
546
|
+
return new Matrix4(
|
|
547
|
+
matrix[0],
|
|
548
|
+
matrix[4],
|
|
549
|
+
matrix[8],
|
|
550
|
+
matrix[12],
|
|
551
|
+
matrix[1],
|
|
552
|
+
matrix[5],
|
|
553
|
+
matrix[9],
|
|
554
|
+
matrix[13],
|
|
555
|
+
matrix[2],
|
|
556
|
+
matrix[6],
|
|
557
|
+
matrix[10],
|
|
558
|
+
matrix[14],
|
|
559
|
+
matrix[3],
|
|
560
|
+
matrix[7],
|
|
561
|
+
matrix[11],
|
|
562
|
+
matrix[15]
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
result[0] = matrix[0];
|
|
566
|
+
result[1] = matrix[1];
|
|
567
|
+
result[2] = matrix[2];
|
|
568
|
+
result[3] = matrix[3];
|
|
569
|
+
result[4] = matrix[4];
|
|
570
|
+
result[5] = matrix[5];
|
|
571
|
+
result[6] = matrix[6];
|
|
572
|
+
result[7] = matrix[7];
|
|
573
|
+
result[8] = matrix[8];
|
|
574
|
+
result[9] = matrix[9];
|
|
575
|
+
result[10] = matrix[10];
|
|
576
|
+
result[11] = matrix[11];
|
|
577
|
+
result[12] = matrix[12];
|
|
578
|
+
result[13] = matrix[13];
|
|
579
|
+
result[14] = matrix[14];
|
|
580
|
+
result[15] = matrix[15];
|
|
581
|
+
return result;
|
|
582
|
+
};
|
|
583
|
+
Matrix4.fromArray = Matrix4.unpack;
|
|
584
|
+
Matrix4.fromColumnMajorArray = function(values, result) {
|
|
585
|
+
Check_default.defined("values", values);
|
|
586
|
+
return Matrix4.clone(values, result);
|
|
587
|
+
};
|
|
588
|
+
Matrix4.fromRowMajorArray = function(values, result) {
|
|
589
|
+
Check_default.defined("values", values);
|
|
590
|
+
if (!defined_default(result)) {
|
|
591
|
+
return new Matrix4(
|
|
592
|
+
values[0],
|
|
593
|
+
values[1],
|
|
594
|
+
values[2],
|
|
595
|
+
values[3],
|
|
596
|
+
values[4],
|
|
597
|
+
values[5],
|
|
598
|
+
values[6],
|
|
599
|
+
values[7],
|
|
600
|
+
values[8],
|
|
601
|
+
values[9],
|
|
602
|
+
values[10],
|
|
603
|
+
values[11],
|
|
604
|
+
values[12],
|
|
605
|
+
values[13],
|
|
606
|
+
values[14],
|
|
607
|
+
values[15]
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
result[0] = values[0];
|
|
611
|
+
result[1] = values[4];
|
|
612
|
+
result[2] = values[8];
|
|
613
|
+
result[3] = values[12];
|
|
614
|
+
result[4] = values[1];
|
|
615
|
+
result[5] = values[5];
|
|
616
|
+
result[6] = values[9];
|
|
617
|
+
result[7] = values[13];
|
|
618
|
+
result[8] = values[2];
|
|
619
|
+
result[9] = values[6];
|
|
620
|
+
result[10] = values[10];
|
|
621
|
+
result[11] = values[14];
|
|
622
|
+
result[12] = values[3];
|
|
623
|
+
result[13] = values[7];
|
|
624
|
+
result[14] = values[11];
|
|
625
|
+
result[15] = values[15];
|
|
626
|
+
return result;
|
|
627
|
+
};
|
|
628
|
+
Matrix4.fromRotationTranslation = function(rotation, translation, result) {
|
|
629
|
+
Check_default.typeOf.object("rotation", rotation);
|
|
630
|
+
translation = translation ?? Cartesian3_default.ZERO;
|
|
631
|
+
if (!defined_default(result)) {
|
|
632
|
+
return new Matrix4(
|
|
633
|
+
rotation[0],
|
|
634
|
+
rotation[3],
|
|
635
|
+
rotation[6],
|
|
636
|
+
translation.x,
|
|
637
|
+
rotation[1],
|
|
638
|
+
rotation[4],
|
|
639
|
+
rotation[7],
|
|
640
|
+
translation.y,
|
|
641
|
+
rotation[2],
|
|
642
|
+
rotation[5],
|
|
643
|
+
rotation[8],
|
|
644
|
+
translation.z,
|
|
645
|
+
0,
|
|
646
|
+
0,
|
|
647
|
+
0,
|
|
648
|
+
1
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
result[0] = rotation[0];
|
|
652
|
+
result[1] = rotation[1];
|
|
653
|
+
result[2] = rotation[2];
|
|
654
|
+
result[3] = 0;
|
|
655
|
+
result[4] = rotation[3];
|
|
656
|
+
result[5] = rotation[4];
|
|
657
|
+
result[6] = rotation[5];
|
|
658
|
+
result[7] = 0;
|
|
659
|
+
result[8] = rotation[6];
|
|
660
|
+
result[9] = rotation[7];
|
|
661
|
+
result[10] = rotation[8];
|
|
662
|
+
result[11] = 0;
|
|
663
|
+
result[12] = translation.x;
|
|
664
|
+
result[13] = translation.y;
|
|
665
|
+
result[14] = translation.z;
|
|
666
|
+
result[15] = 1;
|
|
667
|
+
return result;
|
|
668
|
+
};
|
|
669
|
+
Matrix4.fromTranslationQuaternionRotationScale = function(translation, rotation, scale, result) {
|
|
670
|
+
Check_default.typeOf.object("translation", translation);
|
|
671
|
+
Check_default.typeOf.object("rotation", rotation);
|
|
672
|
+
Check_default.typeOf.object("scale", scale);
|
|
673
|
+
if (!defined_default(result)) {
|
|
674
|
+
result = new Matrix4();
|
|
675
|
+
}
|
|
676
|
+
const scaleX = scale.x;
|
|
677
|
+
const scaleY = scale.y;
|
|
678
|
+
const scaleZ = scale.z;
|
|
679
|
+
const x2 = rotation.x * rotation.x;
|
|
680
|
+
const xy = rotation.x * rotation.y;
|
|
681
|
+
const xz = rotation.x * rotation.z;
|
|
682
|
+
const xw = rotation.x * rotation.w;
|
|
683
|
+
const y2 = rotation.y * rotation.y;
|
|
684
|
+
const yz = rotation.y * rotation.z;
|
|
685
|
+
const yw = rotation.y * rotation.w;
|
|
686
|
+
const z2 = rotation.z * rotation.z;
|
|
687
|
+
const zw = rotation.z * rotation.w;
|
|
688
|
+
const w2 = rotation.w * rotation.w;
|
|
689
|
+
const m00 = x2 - y2 - z2 + w2;
|
|
690
|
+
const m01 = 2 * (xy - zw);
|
|
691
|
+
const m02 = 2 * (xz + yw);
|
|
692
|
+
const m10 = 2 * (xy + zw);
|
|
693
|
+
const m11 = -x2 + y2 - z2 + w2;
|
|
694
|
+
const m12 = 2 * (yz - xw);
|
|
695
|
+
const m20 = 2 * (xz - yw);
|
|
696
|
+
const m21 = 2 * (yz + xw);
|
|
697
|
+
const m22 = -x2 - y2 + z2 + w2;
|
|
698
|
+
result[0] = m00 * scaleX;
|
|
699
|
+
result[1] = m10 * scaleX;
|
|
700
|
+
result[2] = m20 * scaleX;
|
|
701
|
+
result[3] = 0;
|
|
702
|
+
result[4] = m01 * scaleY;
|
|
703
|
+
result[5] = m11 * scaleY;
|
|
704
|
+
result[6] = m21 * scaleY;
|
|
705
|
+
result[7] = 0;
|
|
706
|
+
result[8] = m02 * scaleZ;
|
|
707
|
+
result[9] = m12 * scaleZ;
|
|
708
|
+
result[10] = m22 * scaleZ;
|
|
709
|
+
result[11] = 0;
|
|
710
|
+
result[12] = translation.x;
|
|
711
|
+
result[13] = translation.y;
|
|
712
|
+
result[14] = translation.z;
|
|
713
|
+
result[15] = 1;
|
|
714
|
+
return result;
|
|
715
|
+
};
|
|
716
|
+
Matrix4.fromTranslationRotationScale = function(translationRotationScale, result) {
|
|
717
|
+
Check_default.typeOf.object("translationRotationScale", translationRotationScale);
|
|
718
|
+
return Matrix4.fromTranslationQuaternionRotationScale(
|
|
719
|
+
translationRotationScale.translation,
|
|
720
|
+
translationRotationScale.rotation,
|
|
721
|
+
translationRotationScale.scale,
|
|
722
|
+
result
|
|
723
|
+
);
|
|
724
|
+
};
|
|
725
|
+
Matrix4.fromTranslation = function(translation, result) {
|
|
726
|
+
Check_default.typeOf.object("translation", translation);
|
|
727
|
+
return Matrix4.fromRotationTranslation(Matrix3_default.IDENTITY, translation, result);
|
|
728
|
+
};
|
|
729
|
+
Matrix4.fromScale = function(scale, result) {
|
|
730
|
+
Check_default.typeOf.object("scale", scale);
|
|
731
|
+
if (!defined_default(result)) {
|
|
732
|
+
return new Matrix4(
|
|
733
|
+
scale.x,
|
|
734
|
+
0,
|
|
735
|
+
0,
|
|
736
|
+
0,
|
|
737
|
+
0,
|
|
738
|
+
scale.y,
|
|
739
|
+
0,
|
|
740
|
+
0,
|
|
741
|
+
0,
|
|
742
|
+
0,
|
|
743
|
+
scale.z,
|
|
744
|
+
0,
|
|
745
|
+
0,
|
|
746
|
+
0,
|
|
747
|
+
0,
|
|
748
|
+
1
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
result[0] = scale.x;
|
|
752
|
+
result[1] = 0;
|
|
753
|
+
result[2] = 0;
|
|
754
|
+
result[3] = 0;
|
|
755
|
+
result[4] = 0;
|
|
756
|
+
result[5] = scale.y;
|
|
757
|
+
result[6] = 0;
|
|
758
|
+
result[7] = 0;
|
|
759
|
+
result[8] = 0;
|
|
760
|
+
result[9] = 0;
|
|
761
|
+
result[10] = scale.z;
|
|
762
|
+
result[11] = 0;
|
|
763
|
+
result[12] = 0;
|
|
764
|
+
result[13] = 0;
|
|
765
|
+
result[14] = 0;
|
|
766
|
+
result[15] = 1;
|
|
767
|
+
return result;
|
|
768
|
+
};
|
|
769
|
+
Matrix4.fromUniformScale = function(scale, result) {
|
|
770
|
+
Check_default.typeOf.number("scale", scale);
|
|
771
|
+
if (!defined_default(result)) {
|
|
772
|
+
return new Matrix4(
|
|
773
|
+
scale,
|
|
774
|
+
0,
|
|
775
|
+
0,
|
|
776
|
+
0,
|
|
777
|
+
0,
|
|
778
|
+
scale,
|
|
779
|
+
0,
|
|
780
|
+
0,
|
|
781
|
+
0,
|
|
782
|
+
0,
|
|
783
|
+
scale,
|
|
784
|
+
0,
|
|
785
|
+
0,
|
|
786
|
+
0,
|
|
787
|
+
0,
|
|
788
|
+
1
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
result[0] = scale;
|
|
792
|
+
result[1] = 0;
|
|
793
|
+
result[2] = 0;
|
|
794
|
+
result[3] = 0;
|
|
795
|
+
result[4] = 0;
|
|
796
|
+
result[5] = scale;
|
|
797
|
+
result[6] = 0;
|
|
798
|
+
result[7] = 0;
|
|
799
|
+
result[8] = 0;
|
|
800
|
+
result[9] = 0;
|
|
801
|
+
result[10] = scale;
|
|
802
|
+
result[11] = 0;
|
|
803
|
+
result[12] = 0;
|
|
804
|
+
result[13] = 0;
|
|
805
|
+
result[14] = 0;
|
|
806
|
+
result[15] = 1;
|
|
807
|
+
return result;
|
|
808
|
+
};
|
|
809
|
+
Matrix4.fromRotation = function(rotation, result) {
|
|
810
|
+
Check_default.typeOf.object("rotation", rotation);
|
|
811
|
+
if (!defined_default(result)) {
|
|
812
|
+
result = new Matrix4();
|
|
813
|
+
}
|
|
814
|
+
result[0] = rotation[0];
|
|
815
|
+
result[1] = rotation[1];
|
|
816
|
+
result[2] = rotation[2];
|
|
817
|
+
result[3] = 0;
|
|
818
|
+
result[4] = rotation[3];
|
|
819
|
+
result[5] = rotation[4];
|
|
820
|
+
result[6] = rotation[5];
|
|
821
|
+
result[7] = 0;
|
|
822
|
+
result[8] = rotation[6];
|
|
823
|
+
result[9] = rotation[7];
|
|
824
|
+
result[10] = rotation[8];
|
|
825
|
+
result[11] = 0;
|
|
826
|
+
result[12] = 0;
|
|
827
|
+
result[13] = 0;
|
|
828
|
+
result[14] = 0;
|
|
829
|
+
result[15] = 1;
|
|
830
|
+
return result;
|
|
831
|
+
};
|
|
832
|
+
var fromCameraF = new Cartesian3_default();
|
|
833
|
+
var fromCameraR = new Cartesian3_default();
|
|
834
|
+
var fromCameraU = new Cartesian3_default();
|
|
835
|
+
Matrix4.fromCamera = function(camera, result) {
|
|
836
|
+
Check_default.typeOf.object("camera", camera);
|
|
837
|
+
const position = camera.position;
|
|
838
|
+
const direction = camera.direction;
|
|
839
|
+
const up = camera.up;
|
|
840
|
+
Check_default.typeOf.object("camera.position", position);
|
|
841
|
+
Check_default.typeOf.object("camera.direction", direction);
|
|
842
|
+
Check_default.typeOf.object("camera.up", up);
|
|
843
|
+
Cartesian3_default.normalize(direction, fromCameraF);
|
|
844
|
+
Cartesian3_default.normalize(
|
|
845
|
+
Cartesian3_default.cross(fromCameraF, up, fromCameraR),
|
|
846
|
+
fromCameraR
|
|
847
|
+
);
|
|
848
|
+
Cartesian3_default.normalize(
|
|
849
|
+
Cartesian3_default.cross(fromCameraR, fromCameraF, fromCameraU),
|
|
850
|
+
fromCameraU
|
|
851
|
+
);
|
|
852
|
+
const sX = fromCameraR.x;
|
|
853
|
+
const sY = fromCameraR.y;
|
|
854
|
+
const sZ = fromCameraR.z;
|
|
855
|
+
const fX = fromCameraF.x;
|
|
856
|
+
const fY = fromCameraF.y;
|
|
857
|
+
const fZ = fromCameraF.z;
|
|
858
|
+
const uX = fromCameraU.x;
|
|
859
|
+
const uY = fromCameraU.y;
|
|
860
|
+
const uZ = fromCameraU.z;
|
|
861
|
+
const positionX = position.x;
|
|
862
|
+
const positionY = position.y;
|
|
863
|
+
const positionZ = position.z;
|
|
864
|
+
const t0 = sX * -positionX + sY * -positionY + sZ * -positionZ;
|
|
865
|
+
const t1 = uX * -positionX + uY * -positionY + uZ * -positionZ;
|
|
866
|
+
const t2 = fX * positionX + fY * positionY + fZ * positionZ;
|
|
867
|
+
if (!defined_default(result)) {
|
|
868
|
+
return new Matrix4(
|
|
869
|
+
sX,
|
|
870
|
+
sY,
|
|
871
|
+
sZ,
|
|
872
|
+
t0,
|
|
873
|
+
uX,
|
|
874
|
+
uY,
|
|
875
|
+
uZ,
|
|
876
|
+
t1,
|
|
877
|
+
-fX,
|
|
878
|
+
-fY,
|
|
879
|
+
-fZ,
|
|
880
|
+
t2,
|
|
881
|
+
0,
|
|
882
|
+
0,
|
|
883
|
+
0,
|
|
884
|
+
1
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
result[0] = sX;
|
|
888
|
+
result[1] = uX;
|
|
889
|
+
result[2] = -fX;
|
|
890
|
+
result[3] = 0;
|
|
891
|
+
result[4] = sY;
|
|
892
|
+
result[5] = uY;
|
|
893
|
+
result[6] = -fY;
|
|
894
|
+
result[7] = 0;
|
|
895
|
+
result[8] = sZ;
|
|
896
|
+
result[9] = uZ;
|
|
897
|
+
result[10] = -fZ;
|
|
898
|
+
result[11] = 0;
|
|
899
|
+
result[12] = t0;
|
|
900
|
+
result[13] = t1;
|
|
901
|
+
result[14] = t2;
|
|
902
|
+
result[15] = 1;
|
|
903
|
+
return result;
|
|
904
|
+
};
|
|
905
|
+
Matrix4.computePerspectiveFieldOfView = function(fovY, aspectRatio, near, far, result) {
|
|
906
|
+
Check_default.typeOf.number.greaterThan("fovY", fovY, 0);
|
|
907
|
+
Check_default.typeOf.number.lessThan("fovY", fovY, Math.PI);
|
|
908
|
+
Check_default.typeOf.number.greaterThan("near", near, 0);
|
|
909
|
+
Check_default.typeOf.number.greaterThan("far", far, 0);
|
|
910
|
+
Check_default.typeOf.object("result", result);
|
|
911
|
+
const bottom = Math.tan(fovY * 0.5);
|
|
912
|
+
const column1Row1 = 1 / bottom;
|
|
913
|
+
const column0Row0 = column1Row1 / aspectRatio;
|
|
914
|
+
const column2Row2 = (far + near) / (near - far);
|
|
915
|
+
const column3Row2 = 2 * far * near / (near - far);
|
|
916
|
+
result[0] = column0Row0;
|
|
917
|
+
result[1] = 0;
|
|
918
|
+
result[2] = 0;
|
|
919
|
+
result[3] = 0;
|
|
920
|
+
result[4] = 0;
|
|
921
|
+
result[5] = column1Row1;
|
|
922
|
+
result[6] = 0;
|
|
923
|
+
result[7] = 0;
|
|
924
|
+
result[8] = 0;
|
|
925
|
+
result[9] = 0;
|
|
926
|
+
result[10] = column2Row2;
|
|
927
|
+
result[11] = -1;
|
|
928
|
+
result[12] = 0;
|
|
929
|
+
result[13] = 0;
|
|
930
|
+
result[14] = column3Row2;
|
|
931
|
+
result[15] = 0;
|
|
932
|
+
return result;
|
|
933
|
+
};
|
|
934
|
+
Matrix4.computeOrthographicOffCenter = function(left, right, bottom, top, near, far, result) {
|
|
935
|
+
Check_default.typeOf.number("left", left);
|
|
936
|
+
Check_default.typeOf.number("right", right);
|
|
937
|
+
Check_default.typeOf.number("bottom", bottom);
|
|
938
|
+
Check_default.typeOf.number("top", top);
|
|
939
|
+
Check_default.typeOf.number("near", near);
|
|
940
|
+
Check_default.typeOf.number("far", far);
|
|
941
|
+
Check_default.typeOf.object("result", result);
|
|
942
|
+
let a = 1 / (right - left);
|
|
943
|
+
let b = 1 / (top - bottom);
|
|
944
|
+
let c = 1 / (far - near);
|
|
945
|
+
const tx = -(right + left) * a;
|
|
946
|
+
const ty = -(top + bottom) * b;
|
|
947
|
+
const tz = -(far + near) * c;
|
|
948
|
+
a *= 2;
|
|
949
|
+
b *= 2;
|
|
950
|
+
c *= -2;
|
|
951
|
+
result[0] = a;
|
|
952
|
+
result[1] = 0;
|
|
953
|
+
result[2] = 0;
|
|
954
|
+
result[3] = 0;
|
|
955
|
+
result[4] = 0;
|
|
956
|
+
result[5] = b;
|
|
957
|
+
result[6] = 0;
|
|
958
|
+
result[7] = 0;
|
|
959
|
+
result[8] = 0;
|
|
960
|
+
result[9] = 0;
|
|
961
|
+
result[10] = c;
|
|
962
|
+
result[11] = 0;
|
|
963
|
+
result[12] = tx;
|
|
964
|
+
result[13] = ty;
|
|
965
|
+
result[14] = tz;
|
|
966
|
+
result[15] = 1;
|
|
967
|
+
return result;
|
|
968
|
+
};
|
|
969
|
+
Matrix4.computePerspectiveOffCenter = function(left, right, bottom, top, near, far, result) {
|
|
970
|
+
Check_default.typeOf.number("left", left);
|
|
971
|
+
Check_default.typeOf.number("right", right);
|
|
972
|
+
Check_default.typeOf.number("bottom", bottom);
|
|
973
|
+
Check_default.typeOf.number("top", top);
|
|
974
|
+
Check_default.typeOf.number("near", near);
|
|
975
|
+
Check_default.typeOf.number("far", far);
|
|
976
|
+
Check_default.typeOf.object("result", result);
|
|
977
|
+
const column0Row0 = 2 * near / (right - left);
|
|
978
|
+
const column1Row1 = 2 * near / (top - bottom);
|
|
979
|
+
const column2Row0 = (right + left) / (right - left);
|
|
980
|
+
const column2Row1 = (top + bottom) / (top - bottom);
|
|
981
|
+
const column2Row2 = -(far + near) / (far - near);
|
|
982
|
+
const column2Row3 = -1;
|
|
983
|
+
const column3Row2 = -2 * far * near / (far - near);
|
|
984
|
+
result[0] = column0Row0;
|
|
985
|
+
result[1] = 0;
|
|
986
|
+
result[2] = 0;
|
|
987
|
+
result[3] = 0;
|
|
988
|
+
result[4] = 0;
|
|
989
|
+
result[5] = column1Row1;
|
|
990
|
+
result[6] = 0;
|
|
991
|
+
result[7] = 0;
|
|
992
|
+
result[8] = column2Row0;
|
|
993
|
+
result[9] = column2Row1;
|
|
994
|
+
result[10] = column2Row2;
|
|
995
|
+
result[11] = column2Row3;
|
|
996
|
+
result[12] = 0;
|
|
997
|
+
result[13] = 0;
|
|
998
|
+
result[14] = column3Row2;
|
|
999
|
+
result[15] = 0;
|
|
1000
|
+
return result;
|
|
1001
|
+
};
|
|
1002
|
+
Matrix4.computeInfinitePerspectiveOffCenter = function(left, right, bottom, top, near, result) {
|
|
1003
|
+
Check_default.typeOf.number("left", left);
|
|
1004
|
+
Check_default.typeOf.number("right", right);
|
|
1005
|
+
Check_default.typeOf.number("bottom", bottom);
|
|
1006
|
+
Check_default.typeOf.number("top", top);
|
|
1007
|
+
Check_default.typeOf.number("near", near);
|
|
1008
|
+
Check_default.typeOf.object("result", result);
|
|
1009
|
+
const column0Row0 = 2 * near / (right - left);
|
|
1010
|
+
const column1Row1 = 2 * near / (top - bottom);
|
|
1011
|
+
const column2Row0 = (right + left) / (right - left);
|
|
1012
|
+
const column2Row1 = (top + bottom) / (top - bottom);
|
|
1013
|
+
const column2Row2 = -1;
|
|
1014
|
+
const column2Row3 = -1;
|
|
1015
|
+
const column3Row2 = -2 * near;
|
|
1016
|
+
result[0] = column0Row0;
|
|
1017
|
+
result[1] = 0;
|
|
1018
|
+
result[2] = 0;
|
|
1019
|
+
result[3] = 0;
|
|
1020
|
+
result[4] = 0;
|
|
1021
|
+
result[5] = column1Row1;
|
|
1022
|
+
result[6] = 0;
|
|
1023
|
+
result[7] = 0;
|
|
1024
|
+
result[8] = column2Row0;
|
|
1025
|
+
result[9] = column2Row1;
|
|
1026
|
+
result[10] = column2Row2;
|
|
1027
|
+
result[11] = column2Row3;
|
|
1028
|
+
result[12] = 0;
|
|
1029
|
+
result[13] = 0;
|
|
1030
|
+
result[14] = column3Row2;
|
|
1031
|
+
result[15] = 0;
|
|
1032
|
+
return result;
|
|
1033
|
+
};
|
|
1034
|
+
Matrix4.computeViewportTransformation = function(viewport, nearDepthRange, farDepthRange, result) {
|
|
1035
|
+
if (!defined_default(result)) {
|
|
1036
|
+
result = new Matrix4();
|
|
1037
|
+
}
|
|
1038
|
+
viewport = viewport ?? Frozen_default.EMPTY_OBJECT;
|
|
1039
|
+
const x = viewport.x ?? 0;
|
|
1040
|
+
const y = viewport.y ?? 0;
|
|
1041
|
+
const width = viewport.width ?? 0;
|
|
1042
|
+
const height = viewport.height ?? 0;
|
|
1043
|
+
nearDepthRange = nearDepthRange ?? 0;
|
|
1044
|
+
farDepthRange = farDepthRange ?? 1;
|
|
1045
|
+
const halfWidth = width * 0.5;
|
|
1046
|
+
const halfHeight = height * 0.5;
|
|
1047
|
+
const halfDepth = (farDepthRange - nearDepthRange) * 0.5;
|
|
1048
|
+
const column0Row0 = halfWidth;
|
|
1049
|
+
const column1Row1 = halfHeight;
|
|
1050
|
+
const column2Row2 = halfDepth;
|
|
1051
|
+
const column3Row0 = x + halfWidth;
|
|
1052
|
+
const column3Row1 = y + halfHeight;
|
|
1053
|
+
const column3Row2 = nearDepthRange + halfDepth;
|
|
1054
|
+
const column3Row3 = 1;
|
|
1055
|
+
result[0] = column0Row0;
|
|
1056
|
+
result[1] = 0;
|
|
1057
|
+
result[2] = 0;
|
|
1058
|
+
result[3] = 0;
|
|
1059
|
+
result[4] = 0;
|
|
1060
|
+
result[5] = column1Row1;
|
|
1061
|
+
result[6] = 0;
|
|
1062
|
+
result[7] = 0;
|
|
1063
|
+
result[8] = 0;
|
|
1064
|
+
result[9] = 0;
|
|
1065
|
+
result[10] = column2Row2;
|
|
1066
|
+
result[11] = 0;
|
|
1067
|
+
result[12] = column3Row0;
|
|
1068
|
+
result[13] = column3Row1;
|
|
1069
|
+
result[14] = column3Row2;
|
|
1070
|
+
result[15] = column3Row3;
|
|
1071
|
+
return result;
|
|
1072
|
+
};
|
|
1073
|
+
Matrix4.computeView = function(position, direction, up, right, result) {
|
|
1074
|
+
Check_default.typeOf.object("position", position);
|
|
1075
|
+
Check_default.typeOf.object("direction", direction);
|
|
1076
|
+
Check_default.typeOf.object("up", up);
|
|
1077
|
+
Check_default.typeOf.object("right", right);
|
|
1078
|
+
Check_default.typeOf.object("result", result);
|
|
1079
|
+
result[0] = right.x;
|
|
1080
|
+
result[1] = up.x;
|
|
1081
|
+
result[2] = -direction.x;
|
|
1082
|
+
result[3] = 0;
|
|
1083
|
+
result[4] = right.y;
|
|
1084
|
+
result[5] = up.y;
|
|
1085
|
+
result[6] = -direction.y;
|
|
1086
|
+
result[7] = 0;
|
|
1087
|
+
result[8] = right.z;
|
|
1088
|
+
result[9] = up.z;
|
|
1089
|
+
result[10] = -direction.z;
|
|
1090
|
+
result[11] = 0;
|
|
1091
|
+
result[12] = -Cartesian3_default.dot(right, position);
|
|
1092
|
+
result[13] = -Cartesian3_default.dot(up, position);
|
|
1093
|
+
result[14] = Cartesian3_default.dot(direction, position);
|
|
1094
|
+
result[15] = 1;
|
|
1095
|
+
return result;
|
|
1096
|
+
};
|
|
1097
|
+
Matrix4.toArray = function(matrix, result) {
|
|
1098
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1099
|
+
if (!defined_default(result)) {
|
|
1100
|
+
return [
|
|
1101
|
+
matrix[0],
|
|
1102
|
+
matrix[1],
|
|
1103
|
+
matrix[2],
|
|
1104
|
+
matrix[3],
|
|
1105
|
+
matrix[4],
|
|
1106
|
+
matrix[5],
|
|
1107
|
+
matrix[6],
|
|
1108
|
+
matrix[7],
|
|
1109
|
+
matrix[8],
|
|
1110
|
+
matrix[9],
|
|
1111
|
+
matrix[10],
|
|
1112
|
+
matrix[11],
|
|
1113
|
+
matrix[12],
|
|
1114
|
+
matrix[13],
|
|
1115
|
+
matrix[14],
|
|
1116
|
+
matrix[15]
|
|
1117
|
+
];
|
|
1118
|
+
}
|
|
1119
|
+
result[0] = matrix[0];
|
|
1120
|
+
result[1] = matrix[1];
|
|
1121
|
+
result[2] = matrix[2];
|
|
1122
|
+
result[3] = matrix[3];
|
|
1123
|
+
result[4] = matrix[4];
|
|
1124
|
+
result[5] = matrix[5];
|
|
1125
|
+
result[6] = matrix[6];
|
|
1126
|
+
result[7] = matrix[7];
|
|
1127
|
+
result[8] = matrix[8];
|
|
1128
|
+
result[9] = matrix[9];
|
|
1129
|
+
result[10] = matrix[10];
|
|
1130
|
+
result[11] = matrix[11];
|
|
1131
|
+
result[12] = matrix[12];
|
|
1132
|
+
result[13] = matrix[13];
|
|
1133
|
+
result[14] = matrix[14];
|
|
1134
|
+
result[15] = matrix[15];
|
|
1135
|
+
return result;
|
|
1136
|
+
};
|
|
1137
|
+
Matrix4.getElementIndex = function(column, row) {
|
|
1138
|
+
Check_default.typeOf.number.greaterThanOrEquals("row", row, 0);
|
|
1139
|
+
Check_default.typeOf.number.lessThanOrEquals("row", row, 3);
|
|
1140
|
+
Check_default.typeOf.number.greaterThanOrEquals("column", column, 0);
|
|
1141
|
+
Check_default.typeOf.number.lessThanOrEquals("column", column, 3);
|
|
1142
|
+
return column * 4 + row;
|
|
1143
|
+
};
|
|
1144
|
+
Matrix4.getColumn = function(matrix, index, result) {
|
|
1145
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1146
|
+
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
1147
|
+
Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
|
|
1148
|
+
Check_default.typeOf.object("result", result);
|
|
1149
|
+
const startIndex = index * 4;
|
|
1150
|
+
const x = matrix[startIndex];
|
|
1151
|
+
const y = matrix[startIndex + 1];
|
|
1152
|
+
const z = matrix[startIndex + 2];
|
|
1153
|
+
const w = matrix[startIndex + 3];
|
|
1154
|
+
result.x = x;
|
|
1155
|
+
result.y = y;
|
|
1156
|
+
result.z = z;
|
|
1157
|
+
result.w = w;
|
|
1158
|
+
return result;
|
|
1159
|
+
};
|
|
1160
|
+
Matrix4.setColumn = function(matrix, index, cartesian, result) {
|
|
1161
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1162
|
+
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
1163
|
+
Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
|
|
1164
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
1165
|
+
Check_default.typeOf.object("result", result);
|
|
1166
|
+
result = Matrix4.clone(matrix, result);
|
|
1167
|
+
const startIndex = index * 4;
|
|
1168
|
+
result[startIndex] = cartesian.x;
|
|
1169
|
+
result[startIndex + 1] = cartesian.y;
|
|
1170
|
+
result[startIndex + 2] = cartesian.z;
|
|
1171
|
+
result[startIndex + 3] = cartesian.w;
|
|
1172
|
+
return result;
|
|
1173
|
+
};
|
|
1174
|
+
Matrix4.getRow = function(matrix, index, result) {
|
|
1175
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1176
|
+
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
1177
|
+
Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
|
|
1178
|
+
Check_default.typeOf.object("result", result);
|
|
1179
|
+
const x = matrix[index];
|
|
1180
|
+
const y = matrix[index + 4];
|
|
1181
|
+
const z = matrix[index + 8];
|
|
1182
|
+
const w = matrix[index + 12];
|
|
1183
|
+
result.x = x;
|
|
1184
|
+
result.y = y;
|
|
1185
|
+
result.z = z;
|
|
1186
|
+
result.w = w;
|
|
1187
|
+
return result;
|
|
1188
|
+
};
|
|
1189
|
+
Matrix4.setRow = function(matrix, index, cartesian, result) {
|
|
1190
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1191
|
+
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
1192
|
+
Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
|
|
1193
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
1194
|
+
Check_default.typeOf.object("result", result);
|
|
1195
|
+
result = Matrix4.clone(matrix, result);
|
|
1196
|
+
result[index] = cartesian.x;
|
|
1197
|
+
result[index + 4] = cartesian.y;
|
|
1198
|
+
result[index + 8] = cartesian.z;
|
|
1199
|
+
result[index + 12] = cartesian.w;
|
|
1200
|
+
return result;
|
|
1201
|
+
};
|
|
1202
|
+
Matrix4.setTranslation = function(matrix, translation, result) {
|
|
1203
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1204
|
+
Check_default.typeOf.object("translation", translation);
|
|
1205
|
+
Check_default.typeOf.object("result", result);
|
|
1206
|
+
result[0] = matrix[0];
|
|
1207
|
+
result[1] = matrix[1];
|
|
1208
|
+
result[2] = matrix[2];
|
|
1209
|
+
result[3] = matrix[3];
|
|
1210
|
+
result[4] = matrix[4];
|
|
1211
|
+
result[5] = matrix[5];
|
|
1212
|
+
result[6] = matrix[6];
|
|
1213
|
+
result[7] = matrix[7];
|
|
1214
|
+
result[8] = matrix[8];
|
|
1215
|
+
result[9] = matrix[9];
|
|
1216
|
+
result[10] = matrix[10];
|
|
1217
|
+
result[11] = matrix[11];
|
|
1218
|
+
result[12] = translation.x;
|
|
1219
|
+
result[13] = translation.y;
|
|
1220
|
+
result[14] = translation.z;
|
|
1221
|
+
result[15] = matrix[15];
|
|
1222
|
+
return result;
|
|
1223
|
+
};
|
|
1224
|
+
var scaleScratch1 = new Cartesian3_default();
|
|
1225
|
+
Matrix4.setScale = function(matrix, scale, result) {
|
|
1226
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1227
|
+
Check_default.typeOf.object("scale", scale);
|
|
1228
|
+
Check_default.typeOf.object("result", result);
|
|
1229
|
+
const existingScale = Matrix4.getScale(matrix, scaleScratch1);
|
|
1230
|
+
const scaleRatioX = scale.x / existingScale.x;
|
|
1231
|
+
const scaleRatioY = scale.y / existingScale.y;
|
|
1232
|
+
const scaleRatioZ = scale.z / existingScale.z;
|
|
1233
|
+
result[0] = matrix[0] * scaleRatioX;
|
|
1234
|
+
result[1] = matrix[1] * scaleRatioX;
|
|
1235
|
+
result[2] = matrix[2] * scaleRatioX;
|
|
1236
|
+
result[3] = matrix[3];
|
|
1237
|
+
result[4] = matrix[4] * scaleRatioY;
|
|
1238
|
+
result[5] = matrix[5] * scaleRatioY;
|
|
1239
|
+
result[6] = matrix[6] * scaleRatioY;
|
|
1240
|
+
result[7] = matrix[7];
|
|
1241
|
+
result[8] = matrix[8] * scaleRatioZ;
|
|
1242
|
+
result[9] = matrix[9] * scaleRatioZ;
|
|
1243
|
+
result[10] = matrix[10] * scaleRatioZ;
|
|
1244
|
+
result[11] = matrix[11];
|
|
1245
|
+
result[12] = matrix[12];
|
|
1246
|
+
result[13] = matrix[13];
|
|
1247
|
+
result[14] = matrix[14];
|
|
1248
|
+
result[15] = matrix[15];
|
|
1249
|
+
return result;
|
|
1250
|
+
};
|
|
1251
|
+
var scaleScratch2 = new Cartesian3_default();
|
|
1252
|
+
Matrix4.setUniformScale = function(matrix, scale, result) {
|
|
1253
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1254
|
+
Check_default.typeOf.number("scale", scale);
|
|
1255
|
+
Check_default.typeOf.object("result", result);
|
|
1256
|
+
const existingScale = Matrix4.getScale(matrix, scaleScratch2);
|
|
1257
|
+
const scaleRatioX = scale / existingScale.x;
|
|
1258
|
+
const scaleRatioY = scale / existingScale.y;
|
|
1259
|
+
const scaleRatioZ = scale / existingScale.z;
|
|
1260
|
+
result[0] = matrix[0] * scaleRatioX;
|
|
1261
|
+
result[1] = matrix[1] * scaleRatioX;
|
|
1262
|
+
result[2] = matrix[2] * scaleRatioX;
|
|
1263
|
+
result[3] = matrix[3];
|
|
1264
|
+
result[4] = matrix[4] * scaleRatioY;
|
|
1265
|
+
result[5] = matrix[5] * scaleRatioY;
|
|
1266
|
+
result[6] = matrix[6] * scaleRatioY;
|
|
1267
|
+
result[7] = matrix[7];
|
|
1268
|
+
result[8] = matrix[8] * scaleRatioZ;
|
|
1269
|
+
result[9] = matrix[9] * scaleRatioZ;
|
|
1270
|
+
result[10] = matrix[10] * scaleRatioZ;
|
|
1271
|
+
result[11] = matrix[11];
|
|
1272
|
+
result[12] = matrix[12];
|
|
1273
|
+
result[13] = matrix[13];
|
|
1274
|
+
result[14] = matrix[14];
|
|
1275
|
+
result[15] = matrix[15];
|
|
1276
|
+
return result;
|
|
1277
|
+
};
|
|
1278
|
+
var scratchColumn = new Cartesian3_default();
|
|
1279
|
+
Matrix4.getScale = function(matrix, result) {
|
|
1280
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1281
|
+
Check_default.typeOf.object("result", result);
|
|
1282
|
+
result.x = Cartesian3_default.magnitude(
|
|
1283
|
+
Cartesian3_default.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn)
|
|
1284
|
+
);
|
|
1285
|
+
result.y = Cartesian3_default.magnitude(
|
|
1286
|
+
Cartesian3_default.fromElements(matrix[4], matrix[5], matrix[6], scratchColumn)
|
|
1287
|
+
);
|
|
1288
|
+
result.z = Cartesian3_default.magnitude(
|
|
1289
|
+
Cartesian3_default.fromElements(matrix[8], matrix[9], matrix[10], scratchColumn)
|
|
1290
|
+
);
|
|
1291
|
+
return result;
|
|
1292
|
+
};
|
|
1293
|
+
var scaleScratch3 = new Cartesian3_default();
|
|
1294
|
+
Matrix4.getMaximumScale = function(matrix) {
|
|
1295
|
+
Matrix4.getScale(matrix, scaleScratch3);
|
|
1296
|
+
return Cartesian3_default.maximumComponent(scaleScratch3);
|
|
1297
|
+
};
|
|
1298
|
+
var scaleScratch4 = new Cartesian3_default();
|
|
1299
|
+
Matrix4.setRotation = function(matrix, rotation, result) {
|
|
1300
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1301
|
+
Check_default.typeOf.object("result", result);
|
|
1302
|
+
const scale = Matrix4.getScale(matrix, scaleScratch4);
|
|
1303
|
+
result[0] = rotation[0] * scale.x;
|
|
1304
|
+
result[1] = rotation[1] * scale.x;
|
|
1305
|
+
result[2] = rotation[2] * scale.x;
|
|
1306
|
+
result[3] = matrix[3];
|
|
1307
|
+
result[4] = rotation[3] * scale.y;
|
|
1308
|
+
result[5] = rotation[4] * scale.y;
|
|
1309
|
+
result[6] = rotation[5] * scale.y;
|
|
1310
|
+
result[7] = matrix[7];
|
|
1311
|
+
result[8] = rotation[6] * scale.z;
|
|
1312
|
+
result[9] = rotation[7] * scale.z;
|
|
1313
|
+
result[10] = rotation[8] * scale.z;
|
|
1314
|
+
result[11] = matrix[11];
|
|
1315
|
+
result[12] = matrix[12];
|
|
1316
|
+
result[13] = matrix[13];
|
|
1317
|
+
result[14] = matrix[14];
|
|
1318
|
+
result[15] = matrix[15];
|
|
1319
|
+
return result;
|
|
1320
|
+
};
|
|
1321
|
+
var scaleScratch5 = new Cartesian3_default();
|
|
1322
|
+
Matrix4.getRotation = function(matrix, result) {
|
|
1323
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1324
|
+
Check_default.typeOf.object("result", result);
|
|
1325
|
+
const scale = Matrix4.getScale(matrix, scaleScratch5);
|
|
1326
|
+
result[0] = matrix[0] / scale.x;
|
|
1327
|
+
result[1] = matrix[1] / scale.x;
|
|
1328
|
+
result[2] = matrix[2] / scale.x;
|
|
1329
|
+
result[3] = matrix[4] / scale.y;
|
|
1330
|
+
result[4] = matrix[5] / scale.y;
|
|
1331
|
+
result[5] = matrix[6] / scale.y;
|
|
1332
|
+
result[6] = matrix[8] / scale.z;
|
|
1333
|
+
result[7] = matrix[9] / scale.z;
|
|
1334
|
+
result[8] = matrix[10] / scale.z;
|
|
1335
|
+
return result;
|
|
1336
|
+
};
|
|
1337
|
+
Matrix4.multiply = function(left, right, result) {
|
|
1338
|
+
Check_default.typeOf.object("left", left);
|
|
1339
|
+
Check_default.typeOf.object("right", right);
|
|
1340
|
+
Check_default.typeOf.object("result", result);
|
|
1341
|
+
const left0 = left[0];
|
|
1342
|
+
const left1 = left[1];
|
|
1343
|
+
const left2 = left[2];
|
|
1344
|
+
const left3 = left[3];
|
|
1345
|
+
const left4 = left[4];
|
|
1346
|
+
const left5 = left[5];
|
|
1347
|
+
const left6 = left[6];
|
|
1348
|
+
const left7 = left[7];
|
|
1349
|
+
const left8 = left[8];
|
|
1350
|
+
const left9 = left[9];
|
|
1351
|
+
const left10 = left[10];
|
|
1352
|
+
const left11 = left[11];
|
|
1353
|
+
const left12 = left[12];
|
|
1354
|
+
const left13 = left[13];
|
|
1355
|
+
const left14 = left[14];
|
|
1356
|
+
const left15 = left[15];
|
|
1357
|
+
const right0 = right[0];
|
|
1358
|
+
const right1 = right[1];
|
|
1359
|
+
const right2 = right[2];
|
|
1360
|
+
const right3 = right[3];
|
|
1361
|
+
const right4 = right[4];
|
|
1362
|
+
const right5 = right[5];
|
|
1363
|
+
const right6 = right[6];
|
|
1364
|
+
const right7 = right[7];
|
|
1365
|
+
const right8 = right[8];
|
|
1366
|
+
const right9 = right[9];
|
|
1367
|
+
const right10 = right[10];
|
|
1368
|
+
const right11 = right[11];
|
|
1369
|
+
const right12 = right[12];
|
|
1370
|
+
const right13 = right[13];
|
|
1371
|
+
const right14 = right[14];
|
|
1372
|
+
const right15 = right[15];
|
|
1373
|
+
const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2 + left12 * right3;
|
|
1374
|
+
const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2 + left13 * right3;
|
|
1375
|
+
const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2 + left14 * right3;
|
|
1376
|
+
const column0Row3 = left3 * right0 + left7 * right1 + left11 * right2 + left15 * right3;
|
|
1377
|
+
const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6 + left12 * right7;
|
|
1378
|
+
const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6 + left13 * right7;
|
|
1379
|
+
const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6 + left14 * right7;
|
|
1380
|
+
const column1Row3 = left3 * right4 + left7 * right5 + left11 * right6 + left15 * right7;
|
|
1381
|
+
const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10 + left12 * right11;
|
|
1382
|
+
const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10 + left13 * right11;
|
|
1383
|
+
const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10 + left14 * right11;
|
|
1384
|
+
const column2Row3 = left3 * right8 + left7 * right9 + left11 * right10 + left15 * right11;
|
|
1385
|
+
const column3Row0 = left0 * right12 + left4 * right13 + left8 * right14 + left12 * right15;
|
|
1386
|
+
const column3Row1 = left1 * right12 + left5 * right13 + left9 * right14 + left13 * right15;
|
|
1387
|
+
const column3Row2 = left2 * right12 + left6 * right13 + left10 * right14 + left14 * right15;
|
|
1388
|
+
const column3Row3 = left3 * right12 + left7 * right13 + left11 * right14 + left15 * right15;
|
|
1389
|
+
result[0] = column0Row0;
|
|
1390
|
+
result[1] = column0Row1;
|
|
1391
|
+
result[2] = column0Row2;
|
|
1392
|
+
result[3] = column0Row3;
|
|
1393
|
+
result[4] = column1Row0;
|
|
1394
|
+
result[5] = column1Row1;
|
|
1395
|
+
result[6] = column1Row2;
|
|
1396
|
+
result[7] = column1Row3;
|
|
1397
|
+
result[8] = column2Row0;
|
|
1398
|
+
result[9] = column2Row1;
|
|
1399
|
+
result[10] = column2Row2;
|
|
1400
|
+
result[11] = column2Row3;
|
|
1401
|
+
result[12] = column3Row0;
|
|
1402
|
+
result[13] = column3Row1;
|
|
1403
|
+
result[14] = column3Row2;
|
|
1404
|
+
result[15] = column3Row3;
|
|
1405
|
+
return result;
|
|
1406
|
+
};
|
|
1407
|
+
Matrix4.add = function(left, right, result) {
|
|
1408
|
+
Check_default.typeOf.object("left", left);
|
|
1409
|
+
Check_default.typeOf.object("right", right);
|
|
1410
|
+
Check_default.typeOf.object("result", result);
|
|
1411
|
+
result[0] = left[0] + right[0];
|
|
1412
|
+
result[1] = left[1] + right[1];
|
|
1413
|
+
result[2] = left[2] + right[2];
|
|
1414
|
+
result[3] = left[3] + right[3];
|
|
1415
|
+
result[4] = left[4] + right[4];
|
|
1416
|
+
result[5] = left[5] + right[5];
|
|
1417
|
+
result[6] = left[6] + right[6];
|
|
1418
|
+
result[7] = left[7] + right[7];
|
|
1419
|
+
result[8] = left[8] + right[8];
|
|
1420
|
+
result[9] = left[9] + right[9];
|
|
1421
|
+
result[10] = left[10] + right[10];
|
|
1422
|
+
result[11] = left[11] + right[11];
|
|
1423
|
+
result[12] = left[12] + right[12];
|
|
1424
|
+
result[13] = left[13] + right[13];
|
|
1425
|
+
result[14] = left[14] + right[14];
|
|
1426
|
+
result[15] = left[15] + right[15];
|
|
1427
|
+
return result;
|
|
1428
|
+
};
|
|
1429
|
+
Matrix4.subtract = function(left, right, result) {
|
|
1430
|
+
Check_default.typeOf.object("left", left);
|
|
1431
|
+
Check_default.typeOf.object("right", right);
|
|
1432
|
+
Check_default.typeOf.object("result", result);
|
|
1433
|
+
result[0] = left[0] - right[0];
|
|
1434
|
+
result[1] = left[1] - right[1];
|
|
1435
|
+
result[2] = left[2] - right[2];
|
|
1436
|
+
result[3] = left[3] - right[3];
|
|
1437
|
+
result[4] = left[4] - right[4];
|
|
1438
|
+
result[5] = left[5] - right[5];
|
|
1439
|
+
result[6] = left[6] - right[6];
|
|
1440
|
+
result[7] = left[7] - right[7];
|
|
1441
|
+
result[8] = left[8] - right[8];
|
|
1442
|
+
result[9] = left[9] - right[9];
|
|
1443
|
+
result[10] = left[10] - right[10];
|
|
1444
|
+
result[11] = left[11] - right[11];
|
|
1445
|
+
result[12] = left[12] - right[12];
|
|
1446
|
+
result[13] = left[13] - right[13];
|
|
1447
|
+
result[14] = left[14] - right[14];
|
|
1448
|
+
result[15] = left[15] - right[15];
|
|
1449
|
+
return result;
|
|
1450
|
+
};
|
|
1451
|
+
Matrix4.multiplyTransformation = function(left, right, result) {
|
|
1452
|
+
Check_default.typeOf.object("left", left);
|
|
1453
|
+
Check_default.typeOf.object("right", right);
|
|
1454
|
+
Check_default.typeOf.object("result", result);
|
|
1455
|
+
const left0 = left[0];
|
|
1456
|
+
const left1 = left[1];
|
|
1457
|
+
const left2 = left[2];
|
|
1458
|
+
const left4 = left[4];
|
|
1459
|
+
const left5 = left[5];
|
|
1460
|
+
const left6 = left[6];
|
|
1461
|
+
const left8 = left[8];
|
|
1462
|
+
const left9 = left[9];
|
|
1463
|
+
const left10 = left[10];
|
|
1464
|
+
const left12 = left[12];
|
|
1465
|
+
const left13 = left[13];
|
|
1466
|
+
const left14 = left[14];
|
|
1467
|
+
const right0 = right[0];
|
|
1468
|
+
const right1 = right[1];
|
|
1469
|
+
const right2 = right[2];
|
|
1470
|
+
const right4 = right[4];
|
|
1471
|
+
const right5 = right[5];
|
|
1472
|
+
const right6 = right[6];
|
|
1473
|
+
const right8 = right[8];
|
|
1474
|
+
const right9 = right[9];
|
|
1475
|
+
const right10 = right[10];
|
|
1476
|
+
const right12 = right[12];
|
|
1477
|
+
const right13 = right[13];
|
|
1478
|
+
const right14 = right[14];
|
|
1479
|
+
const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;
|
|
1480
|
+
const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;
|
|
1481
|
+
const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;
|
|
1482
|
+
const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;
|
|
1483
|
+
const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;
|
|
1484
|
+
const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;
|
|
1485
|
+
const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;
|
|
1486
|
+
const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;
|
|
1487
|
+
const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;
|
|
1488
|
+
const column3Row0 = left0 * right12 + left4 * right13 + left8 * right14 + left12;
|
|
1489
|
+
const column3Row1 = left1 * right12 + left5 * right13 + left9 * right14 + left13;
|
|
1490
|
+
const column3Row2 = left2 * right12 + left6 * right13 + left10 * right14 + left14;
|
|
1491
|
+
result[0] = column0Row0;
|
|
1492
|
+
result[1] = column0Row1;
|
|
1493
|
+
result[2] = column0Row2;
|
|
1494
|
+
result[3] = 0;
|
|
1495
|
+
result[4] = column1Row0;
|
|
1496
|
+
result[5] = column1Row1;
|
|
1497
|
+
result[6] = column1Row2;
|
|
1498
|
+
result[7] = 0;
|
|
1499
|
+
result[8] = column2Row0;
|
|
1500
|
+
result[9] = column2Row1;
|
|
1501
|
+
result[10] = column2Row2;
|
|
1502
|
+
result[11] = 0;
|
|
1503
|
+
result[12] = column3Row0;
|
|
1504
|
+
result[13] = column3Row1;
|
|
1505
|
+
result[14] = column3Row2;
|
|
1506
|
+
result[15] = 1;
|
|
1507
|
+
return result;
|
|
1508
|
+
};
|
|
1509
|
+
Matrix4.multiplyByMatrix3 = function(matrix, rotation, result) {
|
|
1510
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1511
|
+
Check_default.typeOf.object("rotation", rotation);
|
|
1512
|
+
Check_default.typeOf.object("result", result);
|
|
1513
|
+
const left0 = matrix[0];
|
|
1514
|
+
const left1 = matrix[1];
|
|
1515
|
+
const left2 = matrix[2];
|
|
1516
|
+
const left4 = matrix[4];
|
|
1517
|
+
const left5 = matrix[5];
|
|
1518
|
+
const left6 = matrix[6];
|
|
1519
|
+
const left8 = matrix[8];
|
|
1520
|
+
const left9 = matrix[9];
|
|
1521
|
+
const left10 = matrix[10];
|
|
1522
|
+
const right0 = rotation[0];
|
|
1523
|
+
const right1 = rotation[1];
|
|
1524
|
+
const right2 = rotation[2];
|
|
1525
|
+
const right4 = rotation[3];
|
|
1526
|
+
const right5 = rotation[4];
|
|
1527
|
+
const right6 = rotation[5];
|
|
1528
|
+
const right8 = rotation[6];
|
|
1529
|
+
const right9 = rotation[7];
|
|
1530
|
+
const right10 = rotation[8];
|
|
1531
|
+
const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;
|
|
1532
|
+
const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;
|
|
1533
|
+
const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;
|
|
1534
|
+
const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;
|
|
1535
|
+
const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;
|
|
1536
|
+
const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;
|
|
1537
|
+
const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;
|
|
1538
|
+
const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;
|
|
1539
|
+
const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;
|
|
1540
|
+
result[0] = column0Row0;
|
|
1541
|
+
result[1] = column0Row1;
|
|
1542
|
+
result[2] = column0Row2;
|
|
1543
|
+
result[3] = 0;
|
|
1544
|
+
result[4] = column1Row0;
|
|
1545
|
+
result[5] = column1Row1;
|
|
1546
|
+
result[6] = column1Row2;
|
|
1547
|
+
result[7] = 0;
|
|
1548
|
+
result[8] = column2Row0;
|
|
1549
|
+
result[9] = column2Row1;
|
|
1550
|
+
result[10] = column2Row2;
|
|
1551
|
+
result[11] = 0;
|
|
1552
|
+
result[12] = matrix[12];
|
|
1553
|
+
result[13] = matrix[13];
|
|
1554
|
+
result[14] = matrix[14];
|
|
1555
|
+
result[15] = matrix[15];
|
|
1556
|
+
return result;
|
|
1557
|
+
};
|
|
1558
|
+
Matrix4.multiplyByTranslation = function(matrix, translation, result) {
|
|
1559
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1560
|
+
Check_default.typeOf.object("translation", translation);
|
|
1561
|
+
Check_default.typeOf.object("result", result);
|
|
1562
|
+
const x = translation.x;
|
|
1563
|
+
const y = translation.y;
|
|
1564
|
+
const z = translation.z;
|
|
1565
|
+
const tx = x * matrix[0] + y * matrix[4] + z * matrix[8] + matrix[12];
|
|
1566
|
+
const ty = x * matrix[1] + y * matrix[5] + z * matrix[9] + matrix[13];
|
|
1567
|
+
const tz = x * matrix[2] + y * matrix[6] + z * matrix[10] + matrix[14];
|
|
1568
|
+
result[0] = matrix[0];
|
|
1569
|
+
result[1] = matrix[1];
|
|
1570
|
+
result[2] = matrix[2];
|
|
1571
|
+
result[3] = matrix[3];
|
|
1572
|
+
result[4] = matrix[4];
|
|
1573
|
+
result[5] = matrix[5];
|
|
1574
|
+
result[6] = matrix[6];
|
|
1575
|
+
result[7] = matrix[7];
|
|
1576
|
+
result[8] = matrix[8];
|
|
1577
|
+
result[9] = matrix[9];
|
|
1578
|
+
result[10] = matrix[10];
|
|
1579
|
+
result[11] = matrix[11];
|
|
1580
|
+
result[12] = tx;
|
|
1581
|
+
result[13] = ty;
|
|
1582
|
+
result[14] = tz;
|
|
1583
|
+
result[15] = matrix[15];
|
|
1584
|
+
return result;
|
|
1585
|
+
};
|
|
1586
|
+
Matrix4.multiplyByScale = function(matrix, scale, result) {
|
|
1587
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1588
|
+
Check_default.typeOf.object("scale", scale);
|
|
1589
|
+
Check_default.typeOf.object("result", result);
|
|
1590
|
+
const scaleX = scale.x;
|
|
1591
|
+
const scaleY = scale.y;
|
|
1592
|
+
const scaleZ = scale.z;
|
|
1593
|
+
if (scaleX === 1 && scaleY === 1 && scaleZ === 1) {
|
|
1594
|
+
return Matrix4.clone(matrix, result);
|
|
1595
|
+
}
|
|
1596
|
+
result[0] = scaleX * matrix[0];
|
|
1597
|
+
result[1] = scaleX * matrix[1];
|
|
1598
|
+
result[2] = scaleX * matrix[2];
|
|
1599
|
+
result[3] = matrix[3];
|
|
1600
|
+
result[4] = scaleY * matrix[4];
|
|
1601
|
+
result[5] = scaleY * matrix[5];
|
|
1602
|
+
result[6] = scaleY * matrix[6];
|
|
1603
|
+
result[7] = matrix[7];
|
|
1604
|
+
result[8] = scaleZ * matrix[8];
|
|
1605
|
+
result[9] = scaleZ * matrix[9];
|
|
1606
|
+
result[10] = scaleZ * matrix[10];
|
|
1607
|
+
result[11] = matrix[11];
|
|
1608
|
+
result[12] = matrix[12];
|
|
1609
|
+
result[13] = matrix[13];
|
|
1610
|
+
result[14] = matrix[14];
|
|
1611
|
+
result[15] = matrix[15];
|
|
1612
|
+
return result;
|
|
1613
|
+
};
|
|
1614
|
+
Matrix4.multiplyByUniformScale = function(matrix, scale, result) {
|
|
1615
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1616
|
+
Check_default.typeOf.number("scale", scale);
|
|
1617
|
+
Check_default.typeOf.object("result", result);
|
|
1618
|
+
result[0] = matrix[0] * scale;
|
|
1619
|
+
result[1] = matrix[1] * scale;
|
|
1620
|
+
result[2] = matrix[2] * scale;
|
|
1621
|
+
result[3] = matrix[3];
|
|
1622
|
+
result[4] = matrix[4] * scale;
|
|
1623
|
+
result[5] = matrix[5] * scale;
|
|
1624
|
+
result[6] = matrix[6] * scale;
|
|
1625
|
+
result[7] = matrix[7];
|
|
1626
|
+
result[8] = matrix[8] * scale;
|
|
1627
|
+
result[9] = matrix[9] * scale;
|
|
1628
|
+
result[10] = matrix[10] * scale;
|
|
1629
|
+
result[11] = matrix[11];
|
|
1630
|
+
result[12] = matrix[12];
|
|
1631
|
+
result[13] = matrix[13];
|
|
1632
|
+
result[14] = matrix[14];
|
|
1633
|
+
result[15] = matrix[15];
|
|
1634
|
+
return result;
|
|
1635
|
+
};
|
|
1636
|
+
Matrix4.multiplyByVector = function(matrix, cartesian, result) {
|
|
1637
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1638
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
1639
|
+
Check_default.typeOf.object("result", result);
|
|
1640
|
+
const vX = cartesian.x;
|
|
1641
|
+
const vY = cartesian.y;
|
|
1642
|
+
const vZ = cartesian.z;
|
|
1643
|
+
const vW = cartesian.w;
|
|
1644
|
+
const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12] * vW;
|
|
1645
|
+
const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13] * vW;
|
|
1646
|
+
const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14] * vW;
|
|
1647
|
+
const w = matrix[3] * vX + matrix[7] * vY + matrix[11] * vZ + matrix[15] * vW;
|
|
1648
|
+
result.x = x;
|
|
1649
|
+
result.y = y;
|
|
1650
|
+
result.z = z;
|
|
1651
|
+
result.w = w;
|
|
1652
|
+
return result;
|
|
1653
|
+
};
|
|
1654
|
+
Matrix4.multiplyByPointAsVector = function(matrix, cartesian, result) {
|
|
1655
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1656
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
1657
|
+
Check_default.typeOf.object("result", result);
|
|
1658
|
+
const vX = cartesian.x;
|
|
1659
|
+
const vY = cartesian.y;
|
|
1660
|
+
const vZ = cartesian.z;
|
|
1661
|
+
const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ;
|
|
1662
|
+
const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ;
|
|
1663
|
+
const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ;
|
|
1664
|
+
result.x = x;
|
|
1665
|
+
result.y = y;
|
|
1666
|
+
result.z = z;
|
|
1667
|
+
return result;
|
|
1668
|
+
};
|
|
1669
|
+
Matrix4.multiplyByPoint = function(matrix, cartesian, result) {
|
|
1670
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1671
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
1672
|
+
Check_default.typeOf.object("result", result);
|
|
1673
|
+
const vX = cartesian.x;
|
|
1674
|
+
const vY = cartesian.y;
|
|
1675
|
+
const vZ = cartesian.z;
|
|
1676
|
+
const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12];
|
|
1677
|
+
const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13];
|
|
1678
|
+
const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14];
|
|
1679
|
+
result.x = x;
|
|
1680
|
+
result.y = y;
|
|
1681
|
+
result.z = z;
|
|
1682
|
+
return result;
|
|
1683
|
+
};
|
|
1684
|
+
Matrix4.multiplyByScalar = function(matrix, scalar, result) {
|
|
1685
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1686
|
+
Check_default.typeOf.number("scalar", scalar);
|
|
1687
|
+
Check_default.typeOf.object("result", result);
|
|
1688
|
+
result[0] = matrix[0] * scalar;
|
|
1689
|
+
result[1] = matrix[1] * scalar;
|
|
1690
|
+
result[2] = matrix[2] * scalar;
|
|
1691
|
+
result[3] = matrix[3] * scalar;
|
|
1692
|
+
result[4] = matrix[4] * scalar;
|
|
1693
|
+
result[5] = matrix[5] * scalar;
|
|
1694
|
+
result[6] = matrix[6] * scalar;
|
|
1695
|
+
result[7] = matrix[7] * scalar;
|
|
1696
|
+
result[8] = matrix[8] * scalar;
|
|
1697
|
+
result[9] = matrix[9] * scalar;
|
|
1698
|
+
result[10] = matrix[10] * scalar;
|
|
1699
|
+
result[11] = matrix[11] * scalar;
|
|
1700
|
+
result[12] = matrix[12] * scalar;
|
|
1701
|
+
result[13] = matrix[13] * scalar;
|
|
1702
|
+
result[14] = matrix[14] * scalar;
|
|
1703
|
+
result[15] = matrix[15] * scalar;
|
|
1704
|
+
return result;
|
|
1705
|
+
};
|
|
1706
|
+
Matrix4.negate = function(matrix, result) {
|
|
1707
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1708
|
+
Check_default.typeOf.object("result", result);
|
|
1709
|
+
result[0] = -matrix[0];
|
|
1710
|
+
result[1] = -matrix[1];
|
|
1711
|
+
result[2] = -matrix[2];
|
|
1712
|
+
result[3] = -matrix[3];
|
|
1713
|
+
result[4] = -matrix[4];
|
|
1714
|
+
result[5] = -matrix[5];
|
|
1715
|
+
result[6] = -matrix[6];
|
|
1716
|
+
result[7] = -matrix[7];
|
|
1717
|
+
result[8] = -matrix[8];
|
|
1718
|
+
result[9] = -matrix[9];
|
|
1719
|
+
result[10] = -matrix[10];
|
|
1720
|
+
result[11] = -matrix[11];
|
|
1721
|
+
result[12] = -matrix[12];
|
|
1722
|
+
result[13] = -matrix[13];
|
|
1723
|
+
result[14] = -matrix[14];
|
|
1724
|
+
result[15] = -matrix[15];
|
|
1725
|
+
return result;
|
|
1726
|
+
};
|
|
1727
|
+
Matrix4.transpose = function(matrix, result) {
|
|
1728
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1729
|
+
Check_default.typeOf.object("result", result);
|
|
1730
|
+
const matrix1 = matrix[1];
|
|
1731
|
+
const matrix2 = matrix[2];
|
|
1732
|
+
const matrix3 = matrix[3];
|
|
1733
|
+
const matrix6 = matrix[6];
|
|
1734
|
+
const matrix7 = matrix[7];
|
|
1735
|
+
const matrix11 = matrix[11];
|
|
1736
|
+
result[0] = matrix[0];
|
|
1737
|
+
result[1] = matrix[4];
|
|
1738
|
+
result[2] = matrix[8];
|
|
1739
|
+
result[3] = matrix[12];
|
|
1740
|
+
result[4] = matrix1;
|
|
1741
|
+
result[5] = matrix[5];
|
|
1742
|
+
result[6] = matrix[9];
|
|
1743
|
+
result[7] = matrix[13];
|
|
1744
|
+
result[8] = matrix2;
|
|
1745
|
+
result[9] = matrix6;
|
|
1746
|
+
result[10] = matrix[10];
|
|
1747
|
+
result[11] = matrix[14];
|
|
1748
|
+
result[12] = matrix3;
|
|
1749
|
+
result[13] = matrix7;
|
|
1750
|
+
result[14] = matrix11;
|
|
1751
|
+
result[15] = matrix[15];
|
|
1752
|
+
return result;
|
|
1753
|
+
};
|
|
1754
|
+
Matrix4.abs = function(matrix, result) {
|
|
1755
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1756
|
+
Check_default.typeOf.object("result", result);
|
|
1757
|
+
result[0] = Math.abs(matrix[0]);
|
|
1758
|
+
result[1] = Math.abs(matrix[1]);
|
|
1759
|
+
result[2] = Math.abs(matrix[2]);
|
|
1760
|
+
result[3] = Math.abs(matrix[3]);
|
|
1761
|
+
result[4] = Math.abs(matrix[4]);
|
|
1762
|
+
result[5] = Math.abs(matrix[5]);
|
|
1763
|
+
result[6] = Math.abs(matrix[6]);
|
|
1764
|
+
result[7] = Math.abs(matrix[7]);
|
|
1765
|
+
result[8] = Math.abs(matrix[8]);
|
|
1766
|
+
result[9] = Math.abs(matrix[9]);
|
|
1767
|
+
result[10] = Math.abs(matrix[10]);
|
|
1768
|
+
result[11] = Math.abs(matrix[11]);
|
|
1769
|
+
result[12] = Math.abs(matrix[12]);
|
|
1770
|
+
result[13] = Math.abs(matrix[13]);
|
|
1771
|
+
result[14] = Math.abs(matrix[14]);
|
|
1772
|
+
result[15] = Math.abs(matrix[15]);
|
|
1773
|
+
return result;
|
|
1774
|
+
};
|
|
1775
|
+
Matrix4.equals = function(left, right) {
|
|
1776
|
+
return left === right || defined_default(left) && defined_default(right) && // Translation
|
|
1777
|
+
left[12] === right[12] && left[13] === right[13] && left[14] === right[14] && // Rotation/scale
|
|
1778
|
+
left[0] === right[0] && left[1] === right[1] && left[2] === right[2] && left[4] === right[4] && left[5] === right[5] && left[6] === right[6] && left[8] === right[8] && left[9] === right[9] && left[10] === right[10] && // Bottom row
|
|
1779
|
+
left[3] === right[3] && left[7] === right[7] && left[11] === right[11] && left[15] === right[15];
|
|
1780
|
+
};
|
|
1781
|
+
Matrix4.equalsEpsilon = function(left, right, epsilon) {
|
|
1782
|
+
epsilon = epsilon ?? 0;
|
|
1783
|
+
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 && Math.abs(left[9] - right[9]) <= epsilon && Math.abs(left[10] - right[10]) <= epsilon && Math.abs(left[11] - right[11]) <= epsilon && Math.abs(left[12] - right[12]) <= epsilon && Math.abs(left[13] - right[13]) <= epsilon && Math.abs(left[14] - right[14]) <= epsilon && Math.abs(left[15] - right[15]) <= epsilon;
|
|
1784
|
+
};
|
|
1785
|
+
Matrix4.getTranslation = function(matrix, result) {
|
|
1786
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1787
|
+
Check_default.typeOf.object("result", result);
|
|
1788
|
+
result.x = matrix[12];
|
|
1789
|
+
result.y = matrix[13];
|
|
1790
|
+
result.z = matrix[14];
|
|
1791
|
+
return result;
|
|
1792
|
+
};
|
|
1793
|
+
Matrix4.getMatrix3 = function(matrix, result) {
|
|
1794
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1795
|
+
Check_default.typeOf.object("result", result);
|
|
1796
|
+
result[0] = matrix[0];
|
|
1797
|
+
result[1] = matrix[1];
|
|
1798
|
+
result[2] = matrix[2];
|
|
1799
|
+
result[3] = matrix[4];
|
|
1800
|
+
result[4] = matrix[5];
|
|
1801
|
+
result[5] = matrix[6];
|
|
1802
|
+
result[6] = matrix[8];
|
|
1803
|
+
result[7] = matrix[9];
|
|
1804
|
+
result[8] = matrix[10];
|
|
1805
|
+
return result;
|
|
1806
|
+
};
|
|
1807
|
+
var scratchInverseRotation = new Matrix3_default();
|
|
1808
|
+
var scratchMatrix3Zero = new Matrix3_default();
|
|
1809
|
+
var scratchBottomRow = new Cartesian4_default();
|
|
1810
|
+
var scratchExpectedBottomRow = new Cartesian4_default(0, 0, 0, 1);
|
|
1811
|
+
Matrix4.inverse = function(matrix, result) {
|
|
1812
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1813
|
+
Check_default.typeOf.object("result", result);
|
|
1814
|
+
const src0 = matrix[0];
|
|
1815
|
+
const src1 = matrix[4];
|
|
1816
|
+
const src2 = matrix[8];
|
|
1817
|
+
const src3 = matrix[12];
|
|
1818
|
+
const src4 = matrix[1];
|
|
1819
|
+
const src5 = matrix[5];
|
|
1820
|
+
const src6 = matrix[9];
|
|
1821
|
+
const src7 = matrix[13];
|
|
1822
|
+
const src8 = matrix[2];
|
|
1823
|
+
const src9 = matrix[6];
|
|
1824
|
+
const src10 = matrix[10];
|
|
1825
|
+
const src11 = matrix[14];
|
|
1826
|
+
const src12 = matrix[3];
|
|
1827
|
+
const src13 = matrix[7];
|
|
1828
|
+
const src14 = matrix[11];
|
|
1829
|
+
const src15 = matrix[15];
|
|
1830
|
+
let tmp0 = src10 * src15;
|
|
1831
|
+
let tmp1 = src11 * src14;
|
|
1832
|
+
let tmp2 = src9 * src15;
|
|
1833
|
+
let tmp3 = src11 * src13;
|
|
1834
|
+
let tmp4 = src9 * src14;
|
|
1835
|
+
let tmp5 = src10 * src13;
|
|
1836
|
+
let tmp6 = src8 * src15;
|
|
1837
|
+
let tmp7 = src11 * src12;
|
|
1838
|
+
let tmp8 = src8 * src14;
|
|
1839
|
+
let tmp9 = src10 * src12;
|
|
1840
|
+
let tmp10 = src8 * src13;
|
|
1841
|
+
let tmp11 = src9 * src12;
|
|
1842
|
+
const dst0 = tmp0 * src5 + tmp3 * src6 + tmp4 * src7 - (tmp1 * src5 + tmp2 * src6 + tmp5 * src7);
|
|
1843
|
+
const dst1 = tmp1 * src4 + tmp6 * src6 + tmp9 * src7 - (tmp0 * src4 + tmp7 * src6 + tmp8 * src7);
|
|
1844
|
+
const dst2 = tmp2 * src4 + tmp7 * src5 + tmp10 * src7 - (tmp3 * src4 + tmp6 * src5 + tmp11 * src7);
|
|
1845
|
+
const dst3 = tmp5 * src4 + tmp8 * src5 + tmp11 * src6 - (tmp4 * src4 + tmp9 * src5 + tmp10 * src6);
|
|
1846
|
+
const dst4 = tmp1 * src1 + tmp2 * src2 + tmp5 * src3 - (tmp0 * src1 + tmp3 * src2 + tmp4 * src3);
|
|
1847
|
+
const dst5 = tmp0 * src0 + tmp7 * src2 + tmp8 * src3 - (tmp1 * src0 + tmp6 * src2 + tmp9 * src3);
|
|
1848
|
+
const dst6 = tmp3 * src0 + tmp6 * src1 + tmp11 * src3 - (tmp2 * src0 + tmp7 * src1 + tmp10 * src3);
|
|
1849
|
+
const dst7 = tmp4 * src0 + tmp9 * src1 + tmp10 * src2 - (tmp5 * src0 + tmp8 * src1 + tmp11 * src2);
|
|
1850
|
+
tmp0 = src2 * src7;
|
|
1851
|
+
tmp1 = src3 * src6;
|
|
1852
|
+
tmp2 = src1 * src7;
|
|
1853
|
+
tmp3 = src3 * src5;
|
|
1854
|
+
tmp4 = src1 * src6;
|
|
1855
|
+
tmp5 = src2 * src5;
|
|
1856
|
+
tmp6 = src0 * src7;
|
|
1857
|
+
tmp7 = src3 * src4;
|
|
1858
|
+
tmp8 = src0 * src6;
|
|
1859
|
+
tmp9 = src2 * src4;
|
|
1860
|
+
tmp10 = src0 * src5;
|
|
1861
|
+
tmp11 = src1 * src4;
|
|
1862
|
+
const dst8 = tmp0 * src13 + tmp3 * src14 + tmp4 * src15 - (tmp1 * src13 + tmp2 * src14 + tmp5 * src15);
|
|
1863
|
+
const dst9 = tmp1 * src12 + tmp6 * src14 + tmp9 * src15 - (tmp0 * src12 + tmp7 * src14 + tmp8 * src15);
|
|
1864
|
+
const dst10 = tmp2 * src12 + tmp7 * src13 + tmp10 * src15 - (tmp3 * src12 + tmp6 * src13 + tmp11 * src15);
|
|
1865
|
+
const dst11 = tmp5 * src12 + tmp8 * src13 + tmp11 * src14 - (tmp4 * src12 + tmp9 * src13 + tmp10 * src14);
|
|
1866
|
+
const dst12 = tmp2 * src10 + tmp5 * src11 + tmp1 * src9 - (tmp4 * src11 + tmp0 * src9 + tmp3 * src10);
|
|
1867
|
+
const dst13 = tmp8 * src11 + tmp0 * src8 + tmp7 * src10 - (tmp6 * src10 + tmp9 * src11 + tmp1 * src8);
|
|
1868
|
+
const dst14 = tmp6 * src9 + tmp11 * src11 + tmp3 * src8 - (tmp10 * src11 + tmp2 * src8 + tmp7 * src9);
|
|
1869
|
+
const dst15 = tmp10 * src10 + tmp4 * src8 + tmp9 * src9 - (tmp8 * src9 + tmp11 * src10 + tmp5 * src8);
|
|
1870
|
+
let det = src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3;
|
|
1871
|
+
if (Math.abs(det) < Math_default.EPSILON21) {
|
|
1872
|
+
if (Matrix3_default.equalsEpsilon(
|
|
1873
|
+
Matrix4.getMatrix3(matrix, scratchInverseRotation),
|
|
1874
|
+
scratchMatrix3Zero,
|
|
1875
|
+
Math_default.EPSILON7
|
|
1876
|
+
) && Cartesian4_default.equals(
|
|
1877
|
+
Matrix4.getRow(matrix, 3, scratchBottomRow),
|
|
1878
|
+
scratchExpectedBottomRow
|
|
1879
|
+
)) {
|
|
1880
|
+
result[0] = 0;
|
|
1881
|
+
result[1] = 0;
|
|
1882
|
+
result[2] = 0;
|
|
1883
|
+
result[3] = 0;
|
|
1884
|
+
result[4] = 0;
|
|
1885
|
+
result[5] = 0;
|
|
1886
|
+
result[6] = 0;
|
|
1887
|
+
result[7] = 0;
|
|
1888
|
+
result[8] = 0;
|
|
1889
|
+
result[9] = 0;
|
|
1890
|
+
result[10] = 0;
|
|
1891
|
+
result[11] = 0;
|
|
1892
|
+
result[12] = -matrix[12];
|
|
1893
|
+
result[13] = -matrix[13];
|
|
1894
|
+
result[14] = -matrix[14];
|
|
1895
|
+
result[15] = 1;
|
|
1896
|
+
return result;
|
|
1897
|
+
}
|
|
1898
|
+
throw new RuntimeError_default(
|
|
1899
|
+
"matrix is not invertible because its determinate is zero."
|
|
1900
|
+
);
|
|
1901
|
+
}
|
|
1902
|
+
det = 1 / det;
|
|
1903
|
+
result[0] = dst0 * det;
|
|
1904
|
+
result[1] = dst1 * det;
|
|
1905
|
+
result[2] = dst2 * det;
|
|
1906
|
+
result[3] = dst3 * det;
|
|
1907
|
+
result[4] = dst4 * det;
|
|
1908
|
+
result[5] = dst5 * det;
|
|
1909
|
+
result[6] = dst6 * det;
|
|
1910
|
+
result[7] = dst7 * det;
|
|
1911
|
+
result[8] = dst8 * det;
|
|
1912
|
+
result[9] = dst9 * det;
|
|
1913
|
+
result[10] = dst10 * det;
|
|
1914
|
+
result[11] = dst11 * det;
|
|
1915
|
+
result[12] = dst12 * det;
|
|
1916
|
+
result[13] = dst13 * det;
|
|
1917
|
+
result[14] = dst14 * det;
|
|
1918
|
+
result[15] = dst15 * det;
|
|
1919
|
+
return result;
|
|
1920
|
+
};
|
|
1921
|
+
Matrix4.inverseTransformation = function(matrix, result) {
|
|
1922
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1923
|
+
Check_default.typeOf.object("result", result);
|
|
1924
|
+
const matrix0 = matrix[0];
|
|
1925
|
+
const matrix1 = matrix[1];
|
|
1926
|
+
const matrix2 = matrix[2];
|
|
1927
|
+
const matrix4 = matrix[4];
|
|
1928
|
+
const matrix5 = matrix[5];
|
|
1929
|
+
const matrix6 = matrix[6];
|
|
1930
|
+
const matrix8 = matrix[8];
|
|
1931
|
+
const matrix9 = matrix[9];
|
|
1932
|
+
const matrix10 = matrix[10];
|
|
1933
|
+
const vX = matrix[12];
|
|
1934
|
+
const vY = matrix[13];
|
|
1935
|
+
const vZ = matrix[14];
|
|
1936
|
+
const x = -matrix0 * vX - matrix1 * vY - matrix2 * vZ;
|
|
1937
|
+
const y = -matrix4 * vX - matrix5 * vY - matrix6 * vZ;
|
|
1938
|
+
const z = -matrix8 * vX - matrix9 * vY - matrix10 * vZ;
|
|
1939
|
+
result[0] = matrix0;
|
|
1940
|
+
result[1] = matrix4;
|
|
1941
|
+
result[2] = matrix8;
|
|
1942
|
+
result[3] = 0;
|
|
1943
|
+
result[4] = matrix1;
|
|
1944
|
+
result[5] = matrix5;
|
|
1945
|
+
result[6] = matrix9;
|
|
1946
|
+
result[7] = 0;
|
|
1947
|
+
result[8] = matrix2;
|
|
1948
|
+
result[9] = matrix6;
|
|
1949
|
+
result[10] = matrix10;
|
|
1950
|
+
result[11] = 0;
|
|
1951
|
+
result[12] = x;
|
|
1952
|
+
result[13] = y;
|
|
1953
|
+
result[14] = z;
|
|
1954
|
+
result[15] = 1;
|
|
1955
|
+
return result;
|
|
1956
|
+
};
|
|
1957
|
+
var scratchTransposeMatrix = new Matrix4();
|
|
1958
|
+
Matrix4.inverseTranspose = function(matrix, result) {
|
|
1959
|
+
Check_default.typeOf.object("matrix", matrix);
|
|
1960
|
+
Check_default.typeOf.object("result", result);
|
|
1961
|
+
return Matrix4.inverse(
|
|
1962
|
+
Matrix4.transpose(matrix, scratchTransposeMatrix),
|
|
1963
|
+
result
|
|
1964
|
+
);
|
|
1965
|
+
};
|
|
1966
|
+
Matrix4.IDENTITY = Object.freeze(
|
|
1967
|
+
new Matrix4(
|
|
1968
|
+
1,
|
|
1969
|
+
0,
|
|
1970
|
+
0,
|
|
1971
|
+
0,
|
|
1972
|
+
0,
|
|
1973
|
+
1,
|
|
1974
|
+
0,
|
|
1975
|
+
0,
|
|
1976
|
+
0,
|
|
1977
|
+
0,
|
|
1978
|
+
1,
|
|
1979
|
+
0,
|
|
1980
|
+
0,
|
|
1981
|
+
0,
|
|
1982
|
+
0,
|
|
1983
|
+
1
|
|
1984
|
+
)
|
|
1985
|
+
);
|
|
1986
|
+
Matrix4.ZERO = Object.freeze(
|
|
1987
|
+
new Matrix4(
|
|
1988
|
+
0,
|
|
1989
|
+
0,
|
|
1990
|
+
0,
|
|
1991
|
+
0,
|
|
1992
|
+
0,
|
|
1993
|
+
0,
|
|
1994
|
+
0,
|
|
1995
|
+
0,
|
|
1996
|
+
0,
|
|
1997
|
+
0,
|
|
1998
|
+
0,
|
|
1999
|
+
0,
|
|
2000
|
+
0,
|
|
2001
|
+
0,
|
|
2002
|
+
0,
|
|
2003
|
+
0
|
|
2004
|
+
)
|
|
2005
|
+
);
|
|
2006
|
+
Matrix4.COLUMN0ROW0 = 0;
|
|
2007
|
+
Matrix4.COLUMN0ROW1 = 1;
|
|
2008
|
+
Matrix4.COLUMN0ROW2 = 2;
|
|
2009
|
+
Matrix4.COLUMN0ROW3 = 3;
|
|
2010
|
+
Matrix4.COLUMN1ROW0 = 4;
|
|
2011
|
+
Matrix4.COLUMN1ROW1 = 5;
|
|
2012
|
+
Matrix4.COLUMN1ROW2 = 6;
|
|
2013
|
+
Matrix4.COLUMN1ROW3 = 7;
|
|
2014
|
+
Matrix4.COLUMN2ROW0 = 8;
|
|
2015
|
+
Matrix4.COLUMN2ROW1 = 9;
|
|
2016
|
+
Matrix4.COLUMN2ROW2 = 10;
|
|
2017
|
+
Matrix4.COLUMN2ROW3 = 11;
|
|
2018
|
+
Matrix4.COLUMN3ROW0 = 12;
|
|
2019
|
+
Matrix4.COLUMN3ROW1 = 13;
|
|
2020
|
+
Matrix4.COLUMN3ROW2 = 14;
|
|
2021
|
+
Matrix4.COLUMN3ROW3 = 15;
|
|
2022
|
+
Object.defineProperties(Matrix4.prototype, {
|
|
2023
|
+
/**
|
|
2024
|
+
* Gets the number of items in the collection.
|
|
2025
|
+
* @memberof Matrix4.prototype
|
|
2026
|
+
*
|
|
2027
|
+
* @type {number}
|
|
2028
|
+
*/
|
|
2029
|
+
length: {
|
|
2030
|
+
get: function() {
|
|
2031
|
+
return Matrix4.packedLength;
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2035
|
+
Matrix4.prototype.clone = function(result) {
|
|
2036
|
+
return Matrix4.clone(this, result);
|
|
2037
|
+
};
|
|
2038
|
+
Matrix4.prototype.equals = function(right) {
|
|
2039
|
+
return Matrix4.equals(this, right);
|
|
2040
|
+
};
|
|
2041
|
+
Matrix4.equalsArray = function(matrix, array, offset) {
|
|
2042
|
+
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] && matrix[9] === array[offset + 9] && matrix[10] === array[offset + 10] && matrix[11] === array[offset + 11] && matrix[12] === array[offset + 12] && matrix[13] === array[offset + 13] && matrix[14] === array[offset + 14] && matrix[15] === array[offset + 15];
|
|
2043
|
+
};
|
|
2044
|
+
Matrix4.prototype.equalsEpsilon = function(right, epsilon) {
|
|
2045
|
+
return Matrix4.equalsEpsilon(this, right, epsilon);
|
|
2046
|
+
};
|
|
2047
|
+
Matrix4.prototype.toString = function() {
|
|
2048
|
+
return `(${this[0]}, ${this[4]}, ${this[8]}, ${this[12]})
|
|
2049
|
+
(${this[1]}, ${this[5]}, ${this[9]}, ${this[13]})
|
|
2050
|
+
(${this[2]}, ${this[6]}, ${this[10]}, ${this[14]})
|
|
2051
|
+
(${this[3]}, ${this[7]}, ${this[11]}, ${this[15]})`;
|
|
2052
|
+
};
|
|
2053
|
+
var Matrix4_default = Matrix4;
|
|
2054
|
+
|
|
2055
|
+
export {
|
|
2056
|
+
Cartesian4_default,
|
|
2057
|
+
Matrix4_default
|
|
2058
|
+
};
|