@luma.gl/engine 9.0.0-alpha.24 → 9.0.0-alpha.25
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/dist/animation/timeline.js.map +1 -1
- package/dist/animation-loop/animation-loop.js +7 -7
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/dist.dev.js +1534 -100
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometry/geometry.d.ts +1 -1
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +1 -1
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/index.cjs +305 -47
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/clip-space.js +1 -1
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model-utils.js.map +1 -1
- package/dist/model/model.js.map +1 -1
- package/dist/scenegraph/group-node.d.ts +21 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -0
- package/dist/scenegraph/group-node.js +95 -0
- package/dist/scenegraph/group-node.js.map +1 -0
- package/dist/scenegraph/model-node.d.ts +18 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -0
- package/dist/scenegraph/model-node.js +29 -0
- package/dist/scenegraph/model-node.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.d.ts +56 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-node.js +142 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -0
- package/dist/transform/transform.js +1 -1
- package/dist/transform/transform.js.map +1 -1
- package/dist.min.js +77 -76
- package/package.json +6 -6
- package/src/geometry/geometry.ts +1 -1
- package/src/index.ts +5 -0
- package/src/lib/clip-space.ts +1 -1
- package/src/scenegraph/group-node.ts +103 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/transform/transform.ts +1 -1
package/dist/dist.dev.js
CHANGED
|
@@ -39,11 +39,14 @@ var __exports__ = (() => {
|
|
|
39
39
|
CubeGeometry: () => CubeGeometry,
|
|
40
40
|
CylinderGeometry: () => CylinderGeometry,
|
|
41
41
|
Geometry: () => Geometry,
|
|
42
|
+
GroupNode: () => GroupNode,
|
|
42
43
|
IcoSphereGeometry: () => IcoSphereGeometry,
|
|
43
44
|
KeyFrames: () => KeyFrames,
|
|
44
45
|
Model: () => Model,
|
|
46
|
+
ModelNode: () => ModelNode,
|
|
45
47
|
PipelineFactory: () => PipelineFactory,
|
|
46
48
|
PlaneGeometry: () => PlaneGeometry,
|
|
49
|
+
ScenegraphNode: () => ScenegraphNode,
|
|
47
50
|
SphereGeometry: () => SphereGeometry,
|
|
48
51
|
Timeline: () => Timeline,
|
|
49
52
|
Transform: () => Transform,
|
|
@@ -294,52 +297,6 @@ var __exports__ = (() => {
|
|
|
294
297
|
return "Unknown";
|
|
295
298
|
}
|
|
296
299
|
|
|
297
|
-
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
298
|
-
function _typeof(obj) {
|
|
299
|
-
"@babel/helpers - typeof";
|
|
300
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
301
|
-
return typeof obj2;
|
|
302
|
-
} : function(obj2) {
|
|
303
|
-
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
304
|
-
}, _typeof(obj);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
308
|
-
function _toPrimitive(input, hint2) {
|
|
309
|
-
if (_typeof(input) !== "object" || input === null)
|
|
310
|
-
return input;
|
|
311
|
-
var prim = input[Symbol.toPrimitive];
|
|
312
|
-
if (prim !== void 0) {
|
|
313
|
-
var res = prim.call(input, hint2 || "default");
|
|
314
|
-
if (_typeof(res) !== "object")
|
|
315
|
-
return res;
|
|
316
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
317
|
-
}
|
|
318
|
-
return (hint2 === "string" ? String : Number)(input);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
322
|
-
function _toPropertyKey(arg) {
|
|
323
|
-
var key = _toPrimitive(arg, "string");
|
|
324
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
328
|
-
function _defineProperty(obj, key, value) {
|
|
329
|
-
key = _toPropertyKey(key);
|
|
330
|
-
if (key in obj) {
|
|
331
|
-
Object.defineProperty(obj, key, {
|
|
332
|
-
value,
|
|
333
|
-
enumerable: true,
|
|
334
|
-
configurable: true,
|
|
335
|
-
writable: true
|
|
336
|
-
});
|
|
337
|
-
} else {
|
|
338
|
-
obj[key] = value;
|
|
339
|
-
}
|
|
340
|
-
return obj;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
300
|
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
344
301
|
function getStorage(type) {
|
|
345
302
|
try {
|
|
@@ -355,9 +312,9 @@ var __exports__ = (() => {
|
|
|
355
312
|
var LocalStorage = class {
|
|
356
313
|
constructor(id, defaultConfig) {
|
|
357
314
|
let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
315
|
+
this.storage = void 0;
|
|
316
|
+
this.id = void 0;
|
|
317
|
+
this.config = void 0;
|
|
361
318
|
this.storage = getStorage(type);
|
|
362
319
|
this.id = id;
|
|
363
320
|
this.config = defaultConfig;
|
|
@@ -403,14 +360,14 @@ var __exports__ = (() => {
|
|
|
403
360
|
const padLength = Math.max(length - string.length, 0);
|
|
404
361
|
return "".concat(" ".repeat(padLength)).concat(string);
|
|
405
362
|
}
|
|
406
|
-
function formatImage(image, message2,
|
|
363
|
+
function formatImage(image, message2, scale2) {
|
|
407
364
|
let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
|
|
408
365
|
const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
|
|
409
366
|
if (image.width > maxWidth) {
|
|
410
|
-
|
|
367
|
+
scale2 = Math.min(scale2, maxWidth / image.width);
|
|
411
368
|
}
|
|
412
|
-
const width = image.width *
|
|
413
|
-
const height = image.height *
|
|
369
|
+
const width = image.width * scale2;
|
|
370
|
+
const height = image.height * scale2;
|
|
414
371
|
const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
|
|
415
372
|
return ["".concat(message2, " %c+"), style];
|
|
416
373
|
}
|
|
@@ -521,13 +478,13 @@ var __exports__ = (() => {
|
|
|
521
478
|
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
522
479
|
id: ""
|
|
523
480
|
};
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
481
|
+
this.id = void 0;
|
|
482
|
+
this.VERSION = VERSION;
|
|
483
|
+
this._startTs = getHiResTimestamp();
|
|
484
|
+
this._deltaTs = getHiResTimestamp();
|
|
485
|
+
this._storage = void 0;
|
|
486
|
+
this.userData = {};
|
|
487
|
+
this.LOG_THROTTLE_TIMEOUT = 0;
|
|
531
488
|
this.id = id;
|
|
532
489
|
this.userData = {};
|
|
533
490
|
this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
|
|
@@ -634,7 +591,7 @@ var __exports__ = (() => {
|
|
|
634
591
|
priority,
|
|
635
592
|
image,
|
|
636
593
|
message: message2 = "",
|
|
637
|
-
scale = 1
|
|
594
|
+
scale: scale2 = 1
|
|
638
595
|
} = _ref;
|
|
639
596
|
if (!this._shouldLog(logLevel || priority)) {
|
|
640
597
|
return noop;
|
|
@@ -642,11 +599,11 @@ var __exports__ = (() => {
|
|
|
642
599
|
return isBrowser() ? logImageInBrowser({
|
|
643
600
|
image,
|
|
644
601
|
message: message2,
|
|
645
|
-
scale
|
|
602
|
+
scale: scale2
|
|
646
603
|
}) : logImageInNode({
|
|
647
604
|
image,
|
|
648
605
|
message: message2,
|
|
649
|
-
scale
|
|
606
|
+
scale: scale2
|
|
650
607
|
});
|
|
651
608
|
}
|
|
652
609
|
time(logLevel, message2) {
|
|
@@ -725,7 +682,7 @@ var __exports__ = (() => {
|
|
|
725
682
|
return noop;
|
|
726
683
|
}
|
|
727
684
|
};
|
|
728
|
-
|
|
685
|
+
Log.VERSION = VERSION;
|
|
729
686
|
function normalizeLogLevel(logLevel) {
|
|
730
687
|
if (!logLevel) {
|
|
731
688
|
return 0;
|
|
@@ -787,7 +744,7 @@ var __exports__ = (() => {
|
|
|
787
744
|
let {
|
|
788
745
|
image,
|
|
789
746
|
message: message2 = "",
|
|
790
|
-
scale = 1
|
|
747
|
+
scale: scale2 = 1
|
|
791
748
|
} = _ref2;
|
|
792
749
|
console.warn("removed");
|
|
793
750
|
return noop;
|
|
@@ -796,12 +753,12 @@ var __exports__ = (() => {
|
|
|
796
753
|
let {
|
|
797
754
|
image,
|
|
798
755
|
message: message2 = "",
|
|
799
|
-
scale = 1
|
|
756
|
+
scale: scale2 = 1
|
|
800
757
|
} = _ref3;
|
|
801
758
|
if (typeof image === "string") {
|
|
802
759
|
const img = new Image();
|
|
803
760
|
img.onload = () => {
|
|
804
|
-
const args = formatImage(img, message2,
|
|
761
|
+
const args = formatImage(img, message2, scale2);
|
|
805
762
|
console.log(...args);
|
|
806
763
|
};
|
|
807
764
|
img.src = image;
|
|
@@ -809,12 +766,12 @@ var __exports__ = (() => {
|
|
|
809
766
|
}
|
|
810
767
|
const element = image.nodeName || "";
|
|
811
768
|
if (element.toLowerCase() === "img") {
|
|
812
|
-
console.log(...formatImage(image, message2,
|
|
769
|
+
console.log(...formatImage(image, message2, scale2));
|
|
813
770
|
return noop;
|
|
814
771
|
}
|
|
815
772
|
if (element.toLowerCase() === "canvas") {
|
|
816
773
|
const img = new Image();
|
|
817
|
-
img.onload = () => console.log(...formatImage(img, message2,
|
|
774
|
+
img.onload = () => console.log(...formatImage(img, message2, scale2));
|
|
818
775
|
img.src = image.toDataURL();
|
|
819
776
|
return noop;
|
|
820
777
|
}
|
|
@@ -856,20 +813,20 @@ var __exports__ = (() => {
|
|
|
856
813
|
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
857
814
|
var Stat = class {
|
|
858
815
|
constructor(name, type) {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
816
|
+
this.name = void 0;
|
|
817
|
+
this.type = void 0;
|
|
818
|
+
this.sampleSize = 1;
|
|
819
|
+
this.time = 0;
|
|
820
|
+
this.count = 0;
|
|
821
|
+
this.samples = 0;
|
|
822
|
+
this.lastTiming = 0;
|
|
823
|
+
this.lastSampleTime = 0;
|
|
824
|
+
this.lastSampleCount = 0;
|
|
825
|
+
this._count = 0;
|
|
826
|
+
this._time = 0;
|
|
827
|
+
this._samples = 0;
|
|
828
|
+
this._startTime = 0;
|
|
829
|
+
this._timerPending = false;
|
|
873
830
|
this.name = name;
|
|
874
831
|
this.type = type;
|
|
875
832
|
this.reset();
|
|
@@ -968,8 +925,8 @@ var __exports__ = (() => {
|
|
|
968
925
|
// ../../node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
969
926
|
var Stats = class {
|
|
970
927
|
constructor(options) {
|
|
971
|
-
|
|
972
|
-
|
|
928
|
+
this.id = void 0;
|
|
929
|
+
this.stats = {};
|
|
973
930
|
this.id = options.id;
|
|
974
931
|
this.stats = {};
|
|
975
932
|
this._initializeStats(options.stats);
|
|
@@ -3989,14 +3946,14 @@ void main() {
|
|
|
3989
3946
|
}
|
|
3990
3947
|
return this.check();
|
|
3991
3948
|
}
|
|
3992
|
-
scale(
|
|
3993
|
-
if (typeof
|
|
3949
|
+
scale(scale2) {
|
|
3950
|
+
if (typeof scale2 === "number") {
|
|
3994
3951
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
3995
|
-
this[i] *=
|
|
3952
|
+
this[i] *= scale2;
|
|
3996
3953
|
}
|
|
3997
3954
|
} else {
|
|
3998
|
-
for (let i = 0; i < this.ELEMENTS && i <
|
|
3999
|
-
this[i] *=
|
|
3955
|
+
for (let i = 0; i < this.ELEMENTS && i < scale2.length; ++i) {
|
|
3956
|
+
this[i] *= scale2[i];
|
|
4000
3957
|
}
|
|
4001
3958
|
}
|
|
4002
3959
|
return this.check();
|
|
@@ -4059,12 +4016,29 @@ void main() {
|
|
|
4059
4016
|
};
|
|
4060
4017
|
|
|
4061
4018
|
// ../../node_modules/@math.gl/core/dist/lib/validators.js
|
|
4019
|
+
function validateVector(v, length) {
|
|
4020
|
+
if (v.length !== length) {
|
|
4021
|
+
return false;
|
|
4022
|
+
}
|
|
4023
|
+
for (let i = 0; i < v.length; ++i) {
|
|
4024
|
+
if (!Number.isFinite(v[i])) {
|
|
4025
|
+
return false;
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
return true;
|
|
4029
|
+
}
|
|
4062
4030
|
function checkNumber(value) {
|
|
4063
4031
|
if (!Number.isFinite(value)) {
|
|
4064
4032
|
throw new Error("Invalid number ".concat(JSON.stringify(value)));
|
|
4065
4033
|
}
|
|
4066
4034
|
return value;
|
|
4067
4035
|
}
|
|
4036
|
+
function checkVector(v, length, callerName = "") {
|
|
4037
|
+
if (config.debug && !validateVector(v, length)) {
|
|
4038
|
+
throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
|
|
4039
|
+
}
|
|
4040
|
+
return v;
|
|
4041
|
+
}
|
|
4068
4042
|
|
|
4069
4043
|
// ../../node_modules/@math.gl/core/dist/lib/assert.js
|
|
4070
4044
|
function assert4(condition, message2) {
|
|
@@ -4179,10 +4153,62 @@ void main() {
|
|
|
4179
4153
|
};
|
|
4180
4154
|
|
|
4181
4155
|
// ../../node_modules/@math.gl/core/dist/gl-matrix/common.js
|
|
4156
|
+
var EPSILON = 1e-6;
|
|
4182
4157
|
var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
|
|
4183
4158
|
var degree = Math.PI / 180;
|
|
4184
4159
|
|
|
4160
|
+
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js
|
|
4161
|
+
function create() {
|
|
4162
|
+
const out = new ARRAY_TYPE(2);
|
|
4163
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
4164
|
+
out[0] = 0;
|
|
4165
|
+
out[1] = 0;
|
|
4166
|
+
}
|
|
4167
|
+
return out;
|
|
4168
|
+
}
|
|
4169
|
+
function transformMat4(out, a, m) {
|
|
4170
|
+
const x = a[0];
|
|
4171
|
+
const y = a[1];
|
|
4172
|
+
out[0] = m[0] * x + m[4] * y + m[12];
|
|
4173
|
+
out[1] = m[1] * x + m[5] * y + m[13];
|
|
4174
|
+
return out;
|
|
4175
|
+
}
|
|
4176
|
+
var forEach = function() {
|
|
4177
|
+
const vec = create();
|
|
4178
|
+
return function(a, stride, offset, count, fn, arg) {
|
|
4179
|
+
let i;
|
|
4180
|
+
let l;
|
|
4181
|
+
if (!stride) {
|
|
4182
|
+
stride = 2;
|
|
4183
|
+
}
|
|
4184
|
+
if (!offset) {
|
|
4185
|
+
offset = 0;
|
|
4186
|
+
}
|
|
4187
|
+
if (count) {
|
|
4188
|
+
l = Math.min(count * stride + offset, a.length);
|
|
4189
|
+
} else {
|
|
4190
|
+
l = a.length;
|
|
4191
|
+
}
|
|
4192
|
+
for (i = offset; i < l; i += stride) {
|
|
4193
|
+
vec[0] = a[i];
|
|
4194
|
+
vec[1] = a[i + 1];
|
|
4195
|
+
fn(vec, vec, arg);
|
|
4196
|
+
a[i] = vec[0];
|
|
4197
|
+
a[i + 1] = vec[1];
|
|
4198
|
+
}
|
|
4199
|
+
return a;
|
|
4200
|
+
};
|
|
4201
|
+
}();
|
|
4202
|
+
|
|
4185
4203
|
// ../../node_modules/@math.gl/core/dist/lib/gl-matrix-extras.js
|
|
4204
|
+
function vec2_transformMat4AsVector(out, a, m) {
|
|
4205
|
+
const x = a[0];
|
|
4206
|
+
const y = a[1];
|
|
4207
|
+
const w = m[3] * x + m[7] * y || 1;
|
|
4208
|
+
out[0] = (m[0] * x + m[4] * y) / w;
|
|
4209
|
+
out[1] = (m[1] * x + m[5] * y) / w;
|
|
4210
|
+
return out;
|
|
4211
|
+
}
|
|
4186
4212
|
function vec3_transformMat4AsVector(out, a, m) {
|
|
4187
4213
|
const x = a[0];
|
|
4188
4214
|
const y = a[1];
|
|
@@ -4203,7 +4229,7 @@ void main() {
|
|
|
4203
4229
|
}
|
|
4204
4230
|
|
|
4205
4231
|
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
|
|
4206
|
-
function
|
|
4232
|
+
function create2() {
|
|
4207
4233
|
const out = new ARRAY_TYPE(3);
|
|
4208
4234
|
if (ARRAY_TYPE != Float32Array) {
|
|
4209
4235
|
out[0] = 0;
|
|
@@ -4227,7 +4253,7 @@ void main() {
|
|
|
4227
4253
|
out[2] = ax * by - ay * bx;
|
|
4228
4254
|
return out;
|
|
4229
4255
|
}
|
|
4230
|
-
function
|
|
4256
|
+
function transformMat42(out, a, m) {
|
|
4231
4257
|
const x = a[0];
|
|
4232
4258
|
const y = a[1];
|
|
4233
4259
|
const z = a[2];
|
|
@@ -4326,8 +4352,8 @@ void main() {
|
|
|
4326
4352
|
const cosine = mag && dot(a, b) / mag;
|
|
4327
4353
|
return Math.acos(Math.min(Math.max(cosine, -1), 1));
|
|
4328
4354
|
}
|
|
4329
|
-
var
|
|
4330
|
-
const vec =
|
|
4355
|
+
var forEach2 = function() {
|
|
4356
|
+
const vec = create2();
|
|
4331
4357
|
return function(a, stride, offset, count, fn, arg) {
|
|
4332
4358
|
let i;
|
|
4333
4359
|
let l;
|
|
@@ -4451,7 +4477,7 @@ void main() {
|
|
|
4451
4477
|
return this.transformAsPoint(matrix4);
|
|
4452
4478
|
}
|
|
4453
4479
|
transformAsPoint(matrix4) {
|
|
4454
|
-
|
|
4480
|
+
transformMat42(this, this, matrix4);
|
|
4455
4481
|
return this.check();
|
|
4456
4482
|
}
|
|
4457
4483
|
transformAsVector(matrix4) {
|
|
@@ -4472,6 +4498,1139 @@ void main() {
|
|
|
4472
4498
|
}
|
|
4473
4499
|
};
|
|
4474
4500
|
|
|
4501
|
+
// ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
|
|
4502
|
+
var Matrix = class extends MathArray {
|
|
4503
|
+
toString() {
|
|
4504
|
+
let string = "[";
|
|
4505
|
+
if (config.printRowMajor) {
|
|
4506
|
+
string += "row-major:";
|
|
4507
|
+
for (let row = 0; row < this.RANK; ++row) {
|
|
4508
|
+
for (let col = 0; col < this.RANK; ++col) {
|
|
4509
|
+
string += " ".concat(this[col * this.RANK + row]);
|
|
4510
|
+
}
|
|
4511
|
+
}
|
|
4512
|
+
} else {
|
|
4513
|
+
string += "column-major:";
|
|
4514
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4515
|
+
string += " ".concat(this[i]);
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
string += "]";
|
|
4519
|
+
return string;
|
|
4520
|
+
}
|
|
4521
|
+
getElementIndex(row, col) {
|
|
4522
|
+
return col * this.RANK + row;
|
|
4523
|
+
}
|
|
4524
|
+
getElement(row, col) {
|
|
4525
|
+
return this[col * this.RANK + row];
|
|
4526
|
+
}
|
|
4527
|
+
setElement(row, col, value) {
|
|
4528
|
+
this[col * this.RANK + row] = checkNumber(value);
|
|
4529
|
+
return this;
|
|
4530
|
+
}
|
|
4531
|
+
getColumn(columnIndex, result = new Array(this.RANK).fill(-0)) {
|
|
4532
|
+
const firstIndex = columnIndex * this.RANK;
|
|
4533
|
+
for (let i = 0; i < this.RANK; ++i) {
|
|
4534
|
+
result[i] = this[firstIndex + i];
|
|
4535
|
+
}
|
|
4536
|
+
return result;
|
|
4537
|
+
}
|
|
4538
|
+
setColumn(columnIndex, columnVector) {
|
|
4539
|
+
const firstIndex = columnIndex * this.RANK;
|
|
4540
|
+
for (let i = 0; i < this.RANK; ++i) {
|
|
4541
|
+
this[firstIndex + i] = columnVector[i];
|
|
4542
|
+
}
|
|
4543
|
+
return this;
|
|
4544
|
+
}
|
|
4545
|
+
};
|
|
4546
|
+
|
|
4547
|
+
// ../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js
|
|
4548
|
+
function identity(out) {
|
|
4549
|
+
out[0] = 1;
|
|
4550
|
+
out[1] = 0;
|
|
4551
|
+
out[2] = 0;
|
|
4552
|
+
out[3] = 0;
|
|
4553
|
+
out[4] = 0;
|
|
4554
|
+
out[5] = 1;
|
|
4555
|
+
out[6] = 0;
|
|
4556
|
+
out[7] = 0;
|
|
4557
|
+
out[8] = 0;
|
|
4558
|
+
out[9] = 0;
|
|
4559
|
+
out[10] = 1;
|
|
4560
|
+
out[11] = 0;
|
|
4561
|
+
out[12] = 0;
|
|
4562
|
+
out[13] = 0;
|
|
4563
|
+
out[14] = 0;
|
|
4564
|
+
out[15] = 1;
|
|
4565
|
+
return out;
|
|
4566
|
+
}
|
|
4567
|
+
function transpose(out, a) {
|
|
4568
|
+
if (out === a) {
|
|
4569
|
+
const a01 = a[1];
|
|
4570
|
+
const a02 = a[2];
|
|
4571
|
+
const a03 = a[3];
|
|
4572
|
+
const a12 = a[6];
|
|
4573
|
+
const a13 = a[7];
|
|
4574
|
+
const a23 = a[11];
|
|
4575
|
+
out[1] = a[4];
|
|
4576
|
+
out[2] = a[8];
|
|
4577
|
+
out[3] = a[12];
|
|
4578
|
+
out[4] = a01;
|
|
4579
|
+
out[6] = a[9];
|
|
4580
|
+
out[7] = a[13];
|
|
4581
|
+
out[8] = a02;
|
|
4582
|
+
out[9] = a12;
|
|
4583
|
+
out[11] = a[14];
|
|
4584
|
+
out[12] = a03;
|
|
4585
|
+
out[13] = a13;
|
|
4586
|
+
out[14] = a23;
|
|
4587
|
+
} else {
|
|
4588
|
+
out[0] = a[0];
|
|
4589
|
+
out[1] = a[4];
|
|
4590
|
+
out[2] = a[8];
|
|
4591
|
+
out[3] = a[12];
|
|
4592
|
+
out[4] = a[1];
|
|
4593
|
+
out[5] = a[5];
|
|
4594
|
+
out[6] = a[9];
|
|
4595
|
+
out[7] = a[13];
|
|
4596
|
+
out[8] = a[2];
|
|
4597
|
+
out[9] = a[6];
|
|
4598
|
+
out[10] = a[10];
|
|
4599
|
+
out[11] = a[14];
|
|
4600
|
+
out[12] = a[3];
|
|
4601
|
+
out[13] = a[7];
|
|
4602
|
+
out[14] = a[11];
|
|
4603
|
+
out[15] = a[15];
|
|
4604
|
+
}
|
|
4605
|
+
return out;
|
|
4606
|
+
}
|
|
4607
|
+
function invert(out, a) {
|
|
4608
|
+
const a00 = a[0];
|
|
4609
|
+
const a01 = a[1];
|
|
4610
|
+
const a02 = a[2];
|
|
4611
|
+
const a03 = a[3];
|
|
4612
|
+
const a10 = a[4];
|
|
4613
|
+
const a11 = a[5];
|
|
4614
|
+
const a12 = a[6];
|
|
4615
|
+
const a13 = a[7];
|
|
4616
|
+
const a20 = a[8];
|
|
4617
|
+
const a21 = a[9];
|
|
4618
|
+
const a22 = a[10];
|
|
4619
|
+
const a23 = a[11];
|
|
4620
|
+
const a30 = a[12];
|
|
4621
|
+
const a31 = a[13];
|
|
4622
|
+
const a32 = a[14];
|
|
4623
|
+
const a33 = a[15];
|
|
4624
|
+
const b00 = a00 * a11 - a01 * a10;
|
|
4625
|
+
const b01 = a00 * a12 - a02 * a10;
|
|
4626
|
+
const b02 = a00 * a13 - a03 * a10;
|
|
4627
|
+
const b03 = a01 * a12 - a02 * a11;
|
|
4628
|
+
const b04 = a01 * a13 - a03 * a11;
|
|
4629
|
+
const b05 = a02 * a13 - a03 * a12;
|
|
4630
|
+
const b06 = a20 * a31 - a21 * a30;
|
|
4631
|
+
const b07 = a20 * a32 - a22 * a30;
|
|
4632
|
+
const b08 = a20 * a33 - a23 * a30;
|
|
4633
|
+
const b09 = a21 * a32 - a22 * a31;
|
|
4634
|
+
const b10 = a21 * a33 - a23 * a31;
|
|
4635
|
+
const b11 = a22 * a33 - a23 * a32;
|
|
4636
|
+
let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
4637
|
+
if (!det) {
|
|
4638
|
+
return null;
|
|
4639
|
+
}
|
|
4640
|
+
det = 1 / det;
|
|
4641
|
+
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
|
4642
|
+
out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
|
4643
|
+
out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
|
4644
|
+
out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
|
|
4645
|
+
out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
|
4646
|
+
out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
|
4647
|
+
out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
|
4648
|
+
out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
|
|
4649
|
+
out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
|
4650
|
+
out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
|
4651
|
+
out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
|
4652
|
+
out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
|
|
4653
|
+
out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
|
|
4654
|
+
out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
|
|
4655
|
+
out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
|
|
4656
|
+
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
|
|
4657
|
+
return out;
|
|
4658
|
+
}
|
|
4659
|
+
function determinant(a) {
|
|
4660
|
+
const a00 = a[0];
|
|
4661
|
+
const a01 = a[1];
|
|
4662
|
+
const a02 = a[2];
|
|
4663
|
+
const a03 = a[3];
|
|
4664
|
+
const a10 = a[4];
|
|
4665
|
+
const a11 = a[5];
|
|
4666
|
+
const a12 = a[6];
|
|
4667
|
+
const a13 = a[7];
|
|
4668
|
+
const a20 = a[8];
|
|
4669
|
+
const a21 = a[9];
|
|
4670
|
+
const a22 = a[10];
|
|
4671
|
+
const a23 = a[11];
|
|
4672
|
+
const a30 = a[12];
|
|
4673
|
+
const a31 = a[13];
|
|
4674
|
+
const a32 = a[14];
|
|
4675
|
+
const a33 = a[15];
|
|
4676
|
+
const b0 = a00 * a11 - a01 * a10;
|
|
4677
|
+
const b1 = a00 * a12 - a02 * a10;
|
|
4678
|
+
const b2 = a01 * a12 - a02 * a11;
|
|
4679
|
+
const b3 = a20 * a31 - a21 * a30;
|
|
4680
|
+
const b4 = a20 * a32 - a22 * a30;
|
|
4681
|
+
const b5 = a21 * a32 - a22 * a31;
|
|
4682
|
+
const b6 = a00 * b5 - a01 * b4 + a02 * b3;
|
|
4683
|
+
const b7 = a10 * b5 - a11 * b4 + a12 * b3;
|
|
4684
|
+
const b8 = a20 * b2 - a21 * b1 + a22 * b0;
|
|
4685
|
+
const b9 = a30 * b2 - a31 * b1 + a32 * b0;
|
|
4686
|
+
return a13 * b6 - a03 * b7 + a33 * b8 - a23 * b9;
|
|
4687
|
+
}
|
|
4688
|
+
function multiply(out, a, b) {
|
|
4689
|
+
const a00 = a[0];
|
|
4690
|
+
const a01 = a[1];
|
|
4691
|
+
const a02 = a[2];
|
|
4692
|
+
const a03 = a[3];
|
|
4693
|
+
const a10 = a[4];
|
|
4694
|
+
const a11 = a[5];
|
|
4695
|
+
const a12 = a[6];
|
|
4696
|
+
const a13 = a[7];
|
|
4697
|
+
const a20 = a[8];
|
|
4698
|
+
const a21 = a[9];
|
|
4699
|
+
const a22 = a[10];
|
|
4700
|
+
const a23 = a[11];
|
|
4701
|
+
const a30 = a[12];
|
|
4702
|
+
const a31 = a[13];
|
|
4703
|
+
const a32 = a[14];
|
|
4704
|
+
const a33 = a[15];
|
|
4705
|
+
let b0 = b[0];
|
|
4706
|
+
let b1 = b[1];
|
|
4707
|
+
let b2 = b[2];
|
|
4708
|
+
let b3 = b[3];
|
|
4709
|
+
out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
4710
|
+
out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
4711
|
+
out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
4712
|
+
out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
4713
|
+
b0 = b[4];
|
|
4714
|
+
b1 = b[5];
|
|
4715
|
+
b2 = b[6];
|
|
4716
|
+
b3 = b[7];
|
|
4717
|
+
out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
4718
|
+
out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
4719
|
+
out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
4720
|
+
out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
4721
|
+
b0 = b[8];
|
|
4722
|
+
b1 = b[9];
|
|
4723
|
+
b2 = b[10];
|
|
4724
|
+
b3 = b[11];
|
|
4725
|
+
out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
4726
|
+
out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
4727
|
+
out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
4728
|
+
out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
4729
|
+
b0 = b[12];
|
|
4730
|
+
b1 = b[13];
|
|
4731
|
+
b2 = b[14];
|
|
4732
|
+
b3 = b[15];
|
|
4733
|
+
out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
4734
|
+
out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
4735
|
+
out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
4736
|
+
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
4737
|
+
return out;
|
|
4738
|
+
}
|
|
4739
|
+
function translate(out, a, v) {
|
|
4740
|
+
const x = v[0];
|
|
4741
|
+
const y = v[1];
|
|
4742
|
+
const z = v[2];
|
|
4743
|
+
let a00;
|
|
4744
|
+
let a01;
|
|
4745
|
+
let a02;
|
|
4746
|
+
let a03;
|
|
4747
|
+
let a10;
|
|
4748
|
+
let a11;
|
|
4749
|
+
let a12;
|
|
4750
|
+
let a13;
|
|
4751
|
+
let a20;
|
|
4752
|
+
let a21;
|
|
4753
|
+
let a22;
|
|
4754
|
+
let a23;
|
|
4755
|
+
if (a === out) {
|
|
4756
|
+
out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
|
|
4757
|
+
out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
|
|
4758
|
+
out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
|
|
4759
|
+
out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
|
|
4760
|
+
} else {
|
|
4761
|
+
a00 = a[0];
|
|
4762
|
+
a01 = a[1];
|
|
4763
|
+
a02 = a[2];
|
|
4764
|
+
a03 = a[3];
|
|
4765
|
+
a10 = a[4];
|
|
4766
|
+
a11 = a[5];
|
|
4767
|
+
a12 = a[6];
|
|
4768
|
+
a13 = a[7];
|
|
4769
|
+
a20 = a[8];
|
|
4770
|
+
a21 = a[9];
|
|
4771
|
+
a22 = a[10];
|
|
4772
|
+
a23 = a[11];
|
|
4773
|
+
out[0] = a00;
|
|
4774
|
+
out[1] = a01;
|
|
4775
|
+
out[2] = a02;
|
|
4776
|
+
out[3] = a03;
|
|
4777
|
+
out[4] = a10;
|
|
4778
|
+
out[5] = a11;
|
|
4779
|
+
out[6] = a12;
|
|
4780
|
+
out[7] = a13;
|
|
4781
|
+
out[8] = a20;
|
|
4782
|
+
out[9] = a21;
|
|
4783
|
+
out[10] = a22;
|
|
4784
|
+
out[11] = a23;
|
|
4785
|
+
out[12] = a00 * x + a10 * y + a20 * z + a[12];
|
|
4786
|
+
out[13] = a01 * x + a11 * y + a21 * z + a[13];
|
|
4787
|
+
out[14] = a02 * x + a12 * y + a22 * z + a[14];
|
|
4788
|
+
out[15] = a03 * x + a13 * y + a23 * z + a[15];
|
|
4789
|
+
}
|
|
4790
|
+
return out;
|
|
4791
|
+
}
|
|
4792
|
+
function scale(out, a, v) {
|
|
4793
|
+
const x = v[0];
|
|
4794
|
+
const y = v[1];
|
|
4795
|
+
const z = v[2];
|
|
4796
|
+
out[0] = a[0] * x;
|
|
4797
|
+
out[1] = a[1] * x;
|
|
4798
|
+
out[2] = a[2] * x;
|
|
4799
|
+
out[3] = a[3] * x;
|
|
4800
|
+
out[4] = a[4] * y;
|
|
4801
|
+
out[5] = a[5] * y;
|
|
4802
|
+
out[6] = a[6] * y;
|
|
4803
|
+
out[7] = a[7] * y;
|
|
4804
|
+
out[8] = a[8] * z;
|
|
4805
|
+
out[9] = a[9] * z;
|
|
4806
|
+
out[10] = a[10] * z;
|
|
4807
|
+
out[11] = a[11] * z;
|
|
4808
|
+
out[12] = a[12];
|
|
4809
|
+
out[13] = a[13];
|
|
4810
|
+
out[14] = a[14];
|
|
4811
|
+
out[15] = a[15];
|
|
4812
|
+
return out;
|
|
4813
|
+
}
|
|
4814
|
+
function rotate(out, a, rad, axis) {
|
|
4815
|
+
let x = axis[0];
|
|
4816
|
+
let y = axis[1];
|
|
4817
|
+
let z = axis[2];
|
|
4818
|
+
let len = Math.sqrt(x * x + y * y + z * z);
|
|
4819
|
+
let c;
|
|
4820
|
+
let s;
|
|
4821
|
+
let t;
|
|
4822
|
+
let a00;
|
|
4823
|
+
let a01;
|
|
4824
|
+
let a02;
|
|
4825
|
+
let a03;
|
|
4826
|
+
let a10;
|
|
4827
|
+
let a11;
|
|
4828
|
+
let a12;
|
|
4829
|
+
let a13;
|
|
4830
|
+
let a20;
|
|
4831
|
+
let a21;
|
|
4832
|
+
let a22;
|
|
4833
|
+
let a23;
|
|
4834
|
+
let b00;
|
|
4835
|
+
let b01;
|
|
4836
|
+
let b02;
|
|
4837
|
+
let b10;
|
|
4838
|
+
let b11;
|
|
4839
|
+
let b12;
|
|
4840
|
+
let b20;
|
|
4841
|
+
let b21;
|
|
4842
|
+
let b22;
|
|
4843
|
+
if (len < EPSILON) {
|
|
4844
|
+
return null;
|
|
4845
|
+
}
|
|
4846
|
+
len = 1 / len;
|
|
4847
|
+
x *= len;
|
|
4848
|
+
y *= len;
|
|
4849
|
+
z *= len;
|
|
4850
|
+
s = Math.sin(rad);
|
|
4851
|
+
c = Math.cos(rad);
|
|
4852
|
+
t = 1 - c;
|
|
4853
|
+
a00 = a[0];
|
|
4854
|
+
a01 = a[1];
|
|
4855
|
+
a02 = a[2];
|
|
4856
|
+
a03 = a[3];
|
|
4857
|
+
a10 = a[4];
|
|
4858
|
+
a11 = a[5];
|
|
4859
|
+
a12 = a[6];
|
|
4860
|
+
a13 = a[7];
|
|
4861
|
+
a20 = a[8];
|
|
4862
|
+
a21 = a[9];
|
|
4863
|
+
a22 = a[10];
|
|
4864
|
+
a23 = a[11];
|
|
4865
|
+
b00 = x * x * t + c;
|
|
4866
|
+
b01 = y * x * t + z * s;
|
|
4867
|
+
b02 = z * x * t - y * s;
|
|
4868
|
+
b10 = x * y * t - z * s;
|
|
4869
|
+
b11 = y * y * t + c;
|
|
4870
|
+
b12 = z * y * t + x * s;
|
|
4871
|
+
b20 = x * z * t + y * s;
|
|
4872
|
+
b21 = y * z * t - x * s;
|
|
4873
|
+
b22 = z * z * t + c;
|
|
4874
|
+
out[0] = a00 * b00 + a10 * b01 + a20 * b02;
|
|
4875
|
+
out[1] = a01 * b00 + a11 * b01 + a21 * b02;
|
|
4876
|
+
out[2] = a02 * b00 + a12 * b01 + a22 * b02;
|
|
4877
|
+
out[3] = a03 * b00 + a13 * b01 + a23 * b02;
|
|
4878
|
+
out[4] = a00 * b10 + a10 * b11 + a20 * b12;
|
|
4879
|
+
out[5] = a01 * b10 + a11 * b11 + a21 * b12;
|
|
4880
|
+
out[6] = a02 * b10 + a12 * b11 + a22 * b12;
|
|
4881
|
+
out[7] = a03 * b10 + a13 * b11 + a23 * b12;
|
|
4882
|
+
out[8] = a00 * b20 + a10 * b21 + a20 * b22;
|
|
4883
|
+
out[9] = a01 * b20 + a11 * b21 + a21 * b22;
|
|
4884
|
+
out[10] = a02 * b20 + a12 * b21 + a22 * b22;
|
|
4885
|
+
out[11] = a03 * b20 + a13 * b21 + a23 * b22;
|
|
4886
|
+
if (a !== out) {
|
|
4887
|
+
out[12] = a[12];
|
|
4888
|
+
out[13] = a[13];
|
|
4889
|
+
out[14] = a[14];
|
|
4890
|
+
out[15] = a[15];
|
|
4891
|
+
}
|
|
4892
|
+
return out;
|
|
4893
|
+
}
|
|
4894
|
+
function rotateX2(out, a, rad) {
|
|
4895
|
+
const s = Math.sin(rad);
|
|
4896
|
+
const c = Math.cos(rad);
|
|
4897
|
+
const a10 = a[4];
|
|
4898
|
+
const a11 = a[5];
|
|
4899
|
+
const a12 = a[6];
|
|
4900
|
+
const a13 = a[7];
|
|
4901
|
+
const a20 = a[8];
|
|
4902
|
+
const a21 = a[9];
|
|
4903
|
+
const a22 = a[10];
|
|
4904
|
+
const a23 = a[11];
|
|
4905
|
+
if (a !== out) {
|
|
4906
|
+
out[0] = a[0];
|
|
4907
|
+
out[1] = a[1];
|
|
4908
|
+
out[2] = a[2];
|
|
4909
|
+
out[3] = a[3];
|
|
4910
|
+
out[12] = a[12];
|
|
4911
|
+
out[13] = a[13];
|
|
4912
|
+
out[14] = a[14];
|
|
4913
|
+
out[15] = a[15];
|
|
4914
|
+
}
|
|
4915
|
+
out[4] = a10 * c + a20 * s;
|
|
4916
|
+
out[5] = a11 * c + a21 * s;
|
|
4917
|
+
out[6] = a12 * c + a22 * s;
|
|
4918
|
+
out[7] = a13 * c + a23 * s;
|
|
4919
|
+
out[8] = a20 * c - a10 * s;
|
|
4920
|
+
out[9] = a21 * c - a11 * s;
|
|
4921
|
+
out[10] = a22 * c - a12 * s;
|
|
4922
|
+
out[11] = a23 * c - a13 * s;
|
|
4923
|
+
return out;
|
|
4924
|
+
}
|
|
4925
|
+
function rotateY2(out, a, rad) {
|
|
4926
|
+
const s = Math.sin(rad);
|
|
4927
|
+
const c = Math.cos(rad);
|
|
4928
|
+
const a00 = a[0];
|
|
4929
|
+
const a01 = a[1];
|
|
4930
|
+
const a02 = a[2];
|
|
4931
|
+
const a03 = a[3];
|
|
4932
|
+
const a20 = a[8];
|
|
4933
|
+
const a21 = a[9];
|
|
4934
|
+
const a22 = a[10];
|
|
4935
|
+
const a23 = a[11];
|
|
4936
|
+
if (a !== out) {
|
|
4937
|
+
out[4] = a[4];
|
|
4938
|
+
out[5] = a[5];
|
|
4939
|
+
out[6] = a[6];
|
|
4940
|
+
out[7] = a[7];
|
|
4941
|
+
out[12] = a[12];
|
|
4942
|
+
out[13] = a[13];
|
|
4943
|
+
out[14] = a[14];
|
|
4944
|
+
out[15] = a[15];
|
|
4945
|
+
}
|
|
4946
|
+
out[0] = a00 * c - a20 * s;
|
|
4947
|
+
out[1] = a01 * c - a21 * s;
|
|
4948
|
+
out[2] = a02 * c - a22 * s;
|
|
4949
|
+
out[3] = a03 * c - a23 * s;
|
|
4950
|
+
out[8] = a00 * s + a20 * c;
|
|
4951
|
+
out[9] = a01 * s + a21 * c;
|
|
4952
|
+
out[10] = a02 * s + a22 * c;
|
|
4953
|
+
out[11] = a03 * s + a23 * c;
|
|
4954
|
+
return out;
|
|
4955
|
+
}
|
|
4956
|
+
function rotateZ2(out, a, rad) {
|
|
4957
|
+
const s = Math.sin(rad);
|
|
4958
|
+
const c = Math.cos(rad);
|
|
4959
|
+
const a00 = a[0];
|
|
4960
|
+
const a01 = a[1];
|
|
4961
|
+
const a02 = a[2];
|
|
4962
|
+
const a03 = a[3];
|
|
4963
|
+
const a10 = a[4];
|
|
4964
|
+
const a11 = a[5];
|
|
4965
|
+
const a12 = a[6];
|
|
4966
|
+
const a13 = a[7];
|
|
4967
|
+
if (a !== out) {
|
|
4968
|
+
out[8] = a[8];
|
|
4969
|
+
out[9] = a[9];
|
|
4970
|
+
out[10] = a[10];
|
|
4971
|
+
out[11] = a[11];
|
|
4972
|
+
out[12] = a[12];
|
|
4973
|
+
out[13] = a[13];
|
|
4974
|
+
out[14] = a[14];
|
|
4975
|
+
out[15] = a[15];
|
|
4976
|
+
}
|
|
4977
|
+
out[0] = a00 * c + a10 * s;
|
|
4978
|
+
out[1] = a01 * c + a11 * s;
|
|
4979
|
+
out[2] = a02 * c + a12 * s;
|
|
4980
|
+
out[3] = a03 * c + a13 * s;
|
|
4981
|
+
out[4] = a10 * c - a00 * s;
|
|
4982
|
+
out[5] = a11 * c - a01 * s;
|
|
4983
|
+
out[6] = a12 * c - a02 * s;
|
|
4984
|
+
out[7] = a13 * c - a03 * s;
|
|
4985
|
+
return out;
|
|
4986
|
+
}
|
|
4987
|
+
function fromQuat(out, q) {
|
|
4988
|
+
const x = q[0];
|
|
4989
|
+
const y = q[1];
|
|
4990
|
+
const z = q[2];
|
|
4991
|
+
const w = q[3];
|
|
4992
|
+
const x2 = x + x;
|
|
4993
|
+
const y2 = y + y;
|
|
4994
|
+
const z2 = z + z;
|
|
4995
|
+
const xx = x * x2;
|
|
4996
|
+
const yx = y * x2;
|
|
4997
|
+
const yy = y * y2;
|
|
4998
|
+
const zx = z * x2;
|
|
4999
|
+
const zy = z * y2;
|
|
5000
|
+
const zz = z * z2;
|
|
5001
|
+
const wx = w * x2;
|
|
5002
|
+
const wy = w * y2;
|
|
5003
|
+
const wz = w * z2;
|
|
5004
|
+
out[0] = 1 - yy - zz;
|
|
5005
|
+
out[1] = yx + wz;
|
|
5006
|
+
out[2] = zx - wy;
|
|
5007
|
+
out[3] = 0;
|
|
5008
|
+
out[4] = yx - wz;
|
|
5009
|
+
out[5] = 1 - xx - zz;
|
|
5010
|
+
out[6] = zy + wx;
|
|
5011
|
+
out[7] = 0;
|
|
5012
|
+
out[8] = zx + wy;
|
|
5013
|
+
out[9] = zy - wx;
|
|
5014
|
+
out[10] = 1 - xx - yy;
|
|
5015
|
+
out[11] = 0;
|
|
5016
|
+
out[12] = 0;
|
|
5017
|
+
out[13] = 0;
|
|
5018
|
+
out[14] = 0;
|
|
5019
|
+
out[15] = 1;
|
|
5020
|
+
return out;
|
|
5021
|
+
}
|
|
5022
|
+
function frustum(out, left, right, bottom, top, near, far) {
|
|
5023
|
+
const rl = 1 / (right - left);
|
|
5024
|
+
const tb = 1 / (top - bottom);
|
|
5025
|
+
const nf = 1 / (near - far);
|
|
5026
|
+
out[0] = near * 2 * rl;
|
|
5027
|
+
out[1] = 0;
|
|
5028
|
+
out[2] = 0;
|
|
5029
|
+
out[3] = 0;
|
|
5030
|
+
out[4] = 0;
|
|
5031
|
+
out[5] = near * 2 * tb;
|
|
5032
|
+
out[6] = 0;
|
|
5033
|
+
out[7] = 0;
|
|
5034
|
+
out[8] = (right + left) * rl;
|
|
5035
|
+
out[9] = (top + bottom) * tb;
|
|
5036
|
+
out[10] = (far + near) * nf;
|
|
5037
|
+
out[11] = -1;
|
|
5038
|
+
out[12] = 0;
|
|
5039
|
+
out[13] = 0;
|
|
5040
|
+
out[14] = far * near * 2 * nf;
|
|
5041
|
+
out[15] = 0;
|
|
5042
|
+
return out;
|
|
5043
|
+
}
|
|
5044
|
+
function perspectiveNO(out, fovy, aspect, near, far) {
|
|
5045
|
+
const f = 1 / Math.tan(fovy / 2);
|
|
5046
|
+
out[0] = f / aspect;
|
|
5047
|
+
out[1] = 0;
|
|
5048
|
+
out[2] = 0;
|
|
5049
|
+
out[3] = 0;
|
|
5050
|
+
out[4] = 0;
|
|
5051
|
+
out[5] = f;
|
|
5052
|
+
out[6] = 0;
|
|
5053
|
+
out[7] = 0;
|
|
5054
|
+
out[8] = 0;
|
|
5055
|
+
out[9] = 0;
|
|
5056
|
+
out[11] = -1;
|
|
5057
|
+
out[12] = 0;
|
|
5058
|
+
out[13] = 0;
|
|
5059
|
+
out[15] = 0;
|
|
5060
|
+
if (far != null && far !== Infinity) {
|
|
5061
|
+
const nf = 1 / (near - far);
|
|
5062
|
+
out[10] = (far + near) * nf;
|
|
5063
|
+
out[14] = 2 * far * near * nf;
|
|
5064
|
+
} else {
|
|
5065
|
+
out[10] = -1;
|
|
5066
|
+
out[14] = -2 * near;
|
|
5067
|
+
}
|
|
5068
|
+
return out;
|
|
5069
|
+
}
|
|
5070
|
+
var perspective = perspectiveNO;
|
|
5071
|
+
function orthoNO(out, left, right, bottom, top, near, far) {
|
|
5072
|
+
const lr = 1 / (left - right);
|
|
5073
|
+
const bt = 1 / (bottom - top);
|
|
5074
|
+
const nf = 1 / (near - far);
|
|
5075
|
+
out[0] = -2 * lr;
|
|
5076
|
+
out[1] = 0;
|
|
5077
|
+
out[2] = 0;
|
|
5078
|
+
out[3] = 0;
|
|
5079
|
+
out[4] = 0;
|
|
5080
|
+
out[5] = -2 * bt;
|
|
5081
|
+
out[6] = 0;
|
|
5082
|
+
out[7] = 0;
|
|
5083
|
+
out[8] = 0;
|
|
5084
|
+
out[9] = 0;
|
|
5085
|
+
out[10] = 2 * nf;
|
|
5086
|
+
out[11] = 0;
|
|
5087
|
+
out[12] = (left + right) * lr;
|
|
5088
|
+
out[13] = (top + bottom) * bt;
|
|
5089
|
+
out[14] = (far + near) * nf;
|
|
5090
|
+
out[15] = 1;
|
|
5091
|
+
return out;
|
|
5092
|
+
}
|
|
5093
|
+
var ortho = orthoNO;
|
|
5094
|
+
function lookAt(out, eye, center, up) {
|
|
5095
|
+
let len;
|
|
5096
|
+
let x0;
|
|
5097
|
+
let x1;
|
|
5098
|
+
let x2;
|
|
5099
|
+
let y0;
|
|
5100
|
+
let y1;
|
|
5101
|
+
let y2;
|
|
5102
|
+
let z0;
|
|
5103
|
+
let z1;
|
|
5104
|
+
let z2;
|
|
5105
|
+
const eyex = eye[0];
|
|
5106
|
+
const eyey = eye[1];
|
|
5107
|
+
const eyez = eye[2];
|
|
5108
|
+
const upx = up[0];
|
|
5109
|
+
const upy = up[1];
|
|
5110
|
+
const upz = up[2];
|
|
5111
|
+
const centerx = center[0];
|
|
5112
|
+
const centery = center[1];
|
|
5113
|
+
const centerz = center[2];
|
|
5114
|
+
if (Math.abs(eyex - centerx) < EPSILON && Math.abs(eyey - centery) < EPSILON && Math.abs(eyez - centerz) < EPSILON) {
|
|
5115
|
+
return identity(out);
|
|
5116
|
+
}
|
|
5117
|
+
z0 = eyex - centerx;
|
|
5118
|
+
z1 = eyey - centery;
|
|
5119
|
+
z2 = eyez - centerz;
|
|
5120
|
+
len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
|
|
5121
|
+
z0 *= len;
|
|
5122
|
+
z1 *= len;
|
|
5123
|
+
z2 *= len;
|
|
5124
|
+
x0 = upy * z2 - upz * z1;
|
|
5125
|
+
x1 = upz * z0 - upx * z2;
|
|
5126
|
+
x2 = upx * z1 - upy * z0;
|
|
5127
|
+
len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
|
5128
|
+
if (!len) {
|
|
5129
|
+
x0 = 0;
|
|
5130
|
+
x1 = 0;
|
|
5131
|
+
x2 = 0;
|
|
5132
|
+
} else {
|
|
5133
|
+
len = 1 / len;
|
|
5134
|
+
x0 *= len;
|
|
5135
|
+
x1 *= len;
|
|
5136
|
+
x2 *= len;
|
|
5137
|
+
}
|
|
5138
|
+
y0 = z1 * x2 - z2 * x1;
|
|
5139
|
+
y1 = z2 * x0 - z0 * x2;
|
|
5140
|
+
y2 = z0 * x1 - z1 * x0;
|
|
5141
|
+
len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
|
|
5142
|
+
if (!len) {
|
|
5143
|
+
y0 = 0;
|
|
5144
|
+
y1 = 0;
|
|
5145
|
+
y2 = 0;
|
|
5146
|
+
} else {
|
|
5147
|
+
len = 1 / len;
|
|
5148
|
+
y0 *= len;
|
|
5149
|
+
y1 *= len;
|
|
5150
|
+
y2 *= len;
|
|
5151
|
+
}
|
|
5152
|
+
out[0] = x0;
|
|
5153
|
+
out[1] = y0;
|
|
5154
|
+
out[2] = z0;
|
|
5155
|
+
out[3] = 0;
|
|
5156
|
+
out[4] = x1;
|
|
5157
|
+
out[5] = y1;
|
|
5158
|
+
out[6] = z1;
|
|
5159
|
+
out[7] = 0;
|
|
5160
|
+
out[8] = x2;
|
|
5161
|
+
out[9] = y2;
|
|
5162
|
+
out[10] = z2;
|
|
5163
|
+
out[11] = 0;
|
|
5164
|
+
out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);
|
|
5165
|
+
out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);
|
|
5166
|
+
out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);
|
|
5167
|
+
out[15] = 1;
|
|
5168
|
+
return out;
|
|
5169
|
+
}
|
|
5170
|
+
|
|
5171
|
+
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js
|
|
5172
|
+
function create3() {
|
|
5173
|
+
const out = new ARRAY_TYPE(4);
|
|
5174
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
5175
|
+
out[0] = 0;
|
|
5176
|
+
out[1] = 0;
|
|
5177
|
+
out[2] = 0;
|
|
5178
|
+
out[3] = 0;
|
|
5179
|
+
}
|
|
5180
|
+
return out;
|
|
5181
|
+
}
|
|
5182
|
+
function transformMat43(out, a, m) {
|
|
5183
|
+
const x = a[0];
|
|
5184
|
+
const y = a[1];
|
|
5185
|
+
const z = a[2];
|
|
5186
|
+
const w = a[3];
|
|
5187
|
+
out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
|
|
5188
|
+
out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
|
|
5189
|
+
out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
|
|
5190
|
+
out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
|
|
5191
|
+
return out;
|
|
5192
|
+
}
|
|
5193
|
+
var forEach3 = function() {
|
|
5194
|
+
const vec = create3();
|
|
5195
|
+
return function(a, stride, offset, count, fn, arg) {
|
|
5196
|
+
let i;
|
|
5197
|
+
let l;
|
|
5198
|
+
if (!stride) {
|
|
5199
|
+
stride = 4;
|
|
5200
|
+
}
|
|
5201
|
+
if (!offset) {
|
|
5202
|
+
offset = 0;
|
|
5203
|
+
}
|
|
5204
|
+
if (count) {
|
|
5205
|
+
l = Math.min(count * stride + offset, a.length);
|
|
5206
|
+
} else {
|
|
5207
|
+
l = a.length;
|
|
5208
|
+
}
|
|
5209
|
+
for (i = offset; i < l; i += stride) {
|
|
5210
|
+
vec[0] = a[i];
|
|
5211
|
+
vec[1] = a[i + 1];
|
|
5212
|
+
vec[2] = a[i + 2];
|
|
5213
|
+
vec[3] = a[i + 3];
|
|
5214
|
+
fn(vec, vec, arg);
|
|
5215
|
+
a[i] = vec[0];
|
|
5216
|
+
a[i + 1] = vec[1];
|
|
5217
|
+
a[i + 2] = vec[2];
|
|
5218
|
+
a[i + 3] = vec[3];
|
|
5219
|
+
}
|
|
5220
|
+
return a;
|
|
5221
|
+
};
|
|
5222
|
+
}();
|
|
5223
|
+
|
|
5224
|
+
// ../../node_modules/@math.gl/core/dist/classes/matrix4.js
|
|
5225
|
+
var INDICES;
|
|
5226
|
+
(function(INDICES2) {
|
|
5227
|
+
INDICES2[INDICES2["COL0ROW0"] = 0] = "COL0ROW0";
|
|
5228
|
+
INDICES2[INDICES2["COL0ROW1"] = 1] = "COL0ROW1";
|
|
5229
|
+
INDICES2[INDICES2["COL0ROW2"] = 2] = "COL0ROW2";
|
|
5230
|
+
INDICES2[INDICES2["COL0ROW3"] = 3] = "COL0ROW3";
|
|
5231
|
+
INDICES2[INDICES2["COL1ROW0"] = 4] = "COL1ROW0";
|
|
5232
|
+
INDICES2[INDICES2["COL1ROW1"] = 5] = "COL1ROW1";
|
|
5233
|
+
INDICES2[INDICES2["COL1ROW2"] = 6] = "COL1ROW2";
|
|
5234
|
+
INDICES2[INDICES2["COL1ROW3"] = 7] = "COL1ROW3";
|
|
5235
|
+
INDICES2[INDICES2["COL2ROW0"] = 8] = "COL2ROW0";
|
|
5236
|
+
INDICES2[INDICES2["COL2ROW1"] = 9] = "COL2ROW1";
|
|
5237
|
+
INDICES2[INDICES2["COL2ROW2"] = 10] = "COL2ROW2";
|
|
5238
|
+
INDICES2[INDICES2["COL2ROW3"] = 11] = "COL2ROW3";
|
|
5239
|
+
INDICES2[INDICES2["COL3ROW0"] = 12] = "COL3ROW0";
|
|
5240
|
+
INDICES2[INDICES2["COL3ROW1"] = 13] = "COL3ROW1";
|
|
5241
|
+
INDICES2[INDICES2["COL3ROW2"] = 14] = "COL3ROW2";
|
|
5242
|
+
INDICES2[INDICES2["COL3ROW3"] = 15] = "COL3ROW3";
|
|
5243
|
+
})(INDICES || (INDICES = {}));
|
|
5244
|
+
var DEFAULT_FOVY = 45 * Math.PI / 180;
|
|
5245
|
+
var DEFAULT_ASPECT = 1;
|
|
5246
|
+
var DEFAULT_NEAR = 0.1;
|
|
5247
|
+
var DEFAULT_FAR = 500;
|
|
5248
|
+
var IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
5249
|
+
var Matrix4 = class extends Matrix {
|
|
5250
|
+
static get IDENTITY() {
|
|
5251
|
+
return getIdentityMatrix();
|
|
5252
|
+
}
|
|
5253
|
+
static get ZERO() {
|
|
5254
|
+
return getZeroMatrix();
|
|
5255
|
+
}
|
|
5256
|
+
get ELEMENTS() {
|
|
5257
|
+
return 16;
|
|
5258
|
+
}
|
|
5259
|
+
get RANK() {
|
|
5260
|
+
return 4;
|
|
5261
|
+
}
|
|
5262
|
+
get INDICES() {
|
|
5263
|
+
return INDICES;
|
|
5264
|
+
}
|
|
5265
|
+
constructor(array) {
|
|
5266
|
+
super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
|
|
5267
|
+
if (arguments.length === 1 && Array.isArray(array)) {
|
|
5268
|
+
this.copy(array);
|
|
5269
|
+
} else {
|
|
5270
|
+
this.identity();
|
|
5271
|
+
}
|
|
5272
|
+
}
|
|
5273
|
+
copy(array) {
|
|
5274
|
+
this[0] = array[0];
|
|
5275
|
+
this[1] = array[1];
|
|
5276
|
+
this[2] = array[2];
|
|
5277
|
+
this[3] = array[3];
|
|
5278
|
+
this[4] = array[4];
|
|
5279
|
+
this[5] = array[5];
|
|
5280
|
+
this[6] = array[6];
|
|
5281
|
+
this[7] = array[7];
|
|
5282
|
+
this[8] = array[8];
|
|
5283
|
+
this[9] = array[9];
|
|
5284
|
+
this[10] = array[10];
|
|
5285
|
+
this[11] = array[11];
|
|
5286
|
+
this[12] = array[12];
|
|
5287
|
+
this[13] = array[13];
|
|
5288
|
+
this[14] = array[14];
|
|
5289
|
+
this[15] = array[15];
|
|
5290
|
+
return this.check();
|
|
5291
|
+
}
|
|
5292
|
+
set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
|
|
5293
|
+
this[0] = m00;
|
|
5294
|
+
this[1] = m10;
|
|
5295
|
+
this[2] = m20;
|
|
5296
|
+
this[3] = m30;
|
|
5297
|
+
this[4] = m01;
|
|
5298
|
+
this[5] = m11;
|
|
5299
|
+
this[6] = m21;
|
|
5300
|
+
this[7] = m31;
|
|
5301
|
+
this[8] = m02;
|
|
5302
|
+
this[9] = m12;
|
|
5303
|
+
this[10] = m22;
|
|
5304
|
+
this[11] = m32;
|
|
5305
|
+
this[12] = m03;
|
|
5306
|
+
this[13] = m13;
|
|
5307
|
+
this[14] = m23;
|
|
5308
|
+
this[15] = m33;
|
|
5309
|
+
return this.check();
|
|
5310
|
+
}
|
|
5311
|
+
setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
5312
|
+
this[0] = m00;
|
|
5313
|
+
this[1] = m10;
|
|
5314
|
+
this[2] = m20;
|
|
5315
|
+
this[3] = m30;
|
|
5316
|
+
this[4] = m01;
|
|
5317
|
+
this[5] = m11;
|
|
5318
|
+
this[6] = m21;
|
|
5319
|
+
this[7] = m31;
|
|
5320
|
+
this[8] = m02;
|
|
5321
|
+
this[9] = m12;
|
|
5322
|
+
this[10] = m22;
|
|
5323
|
+
this[11] = m32;
|
|
5324
|
+
this[12] = m03;
|
|
5325
|
+
this[13] = m13;
|
|
5326
|
+
this[14] = m23;
|
|
5327
|
+
this[15] = m33;
|
|
5328
|
+
return this.check();
|
|
5329
|
+
}
|
|
5330
|
+
toRowMajor(result) {
|
|
5331
|
+
result[0] = this[0];
|
|
5332
|
+
result[1] = this[4];
|
|
5333
|
+
result[2] = this[8];
|
|
5334
|
+
result[3] = this[12];
|
|
5335
|
+
result[4] = this[1];
|
|
5336
|
+
result[5] = this[5];
|
|
5337
|
+
result[6] = this[9];
|
|
5338
|
+
result[7] = this[13];
|
|
5339
|
+
result[8] = this[2];
|
|
5340
|
+
result[9] = this[6];
|
|
5341
|
+
result[10] = this[10];
|
|
5342
|
+
result[11] = this[14];
|
|
5343
|
+
result[12] = this[3];
|
|
5344
|
+
result[13] = this[7];
|
|
5345
|
+
result[14] = this[11];
|
|
5346
|
+
result[15] = this[15];
|
|
5347
|
+
return result;
|
|
5348
|
+
}
|
|
5349
|
+
identity() {
|
|
5350
|
+
return this.copy(IDENTITY_MATRIX);
|
|
5351
|
+
}
|
|
5352
|
+
fromObject(object) {
|
|
5353
|
+
return this.check();
|
|
5354
|
+
}
|
|
5355
|
+
fromQuaternion(quaternion) {
|
|
5356
|
+
fromQuat(this, quaternion);
|
|
5357
|
+
return this.check();
|
|
5358
|
+
}
|
|
5359
|
+
frustum(view) {
|
|
5360
|
+
const {
|
|
5361
|
+
left,
|
|
5362
|
+
right,
|
|
5363
|
+
bottom,
|
|
5364
|
+
top,
|
|
5365
|
+
near = DEFAULT_NEAR,
|
|
5366
|
+
far = DEFAULT_FAR
|
|
5367
|
+
} = view;
|
|
5368
|
+
if (far === Infinity) {
|
|
5369
|
+
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
|
|
5370
|
+
} else {
|
|
5371
|
+
frustum(this, left, right, bottom, top, near, far);
|
|
5372
|
+
}
|
|
5373
|
+
return this.check();
|
|
5374
|
+
}
|
|
5375
|
+
lookAt(view) {
|
|
5376
|
+
const {
|
|
5377
|
+
eye,
|
|
5378
|
+
center = [0, 0, 0],
|
|
5379
|
+
up = [0, 1, 0]
|
|
5380
|
+
} = view;
|
|
5381
|
+
lookAt(this, eye, center, up);
|
|
5382
|
+
return this.check();
|
|
5383
|
+
}
|
|
5384
|
+
ortho(view) {
|
|
5385
|
+
const {
|
|
5386
|
+
left,
|
|
5387
|
+
right,
|
|
5388
|
+
bottom,
|
|
5389
|
+
top,
|
|
5390
|
+
near = DEFAULT_NEAR,
|
|
5391
|
+
far = DEFAULT_FAR
|
|
5392
|
+
} = view;
|
|
5393
|
+
ortho(this, left, right, bottom, top, near, far);
|
|
5394
|
+
return this.check();
|
|
5395
|
+
}
|
|
5396
|
+
orthographic(view) {
|
|
5397
|
+
const {
|
|
5398
|
+
fovy = DEFAULT_FOVY,
|
|
5399
|
+
aspect = DEFAULT_ASPECT,
|
|
5400
|
+
focalDistance = 1,
|
|
5401
|
+
near = DEFAULT_NEAR,
|
|
5402
|
+
far = DEFAULT_FAR
|
|
5403
|
+
} = view;
|
|
5404
|
+
checkRadians(fovy);
|
|
5405
|
+
const halfY = fovy / 2;
|
|
5406
|
+
const top = focalDistance * Math.tan(halfY);
|
|
5407
|
+
const right = top * aspect;
|
|
5408
|
+
return this.ortho({
|
|
5409
|
+
left: -right,
|
|
5410
|
+
right,
|
|
5411
|
+
bottom: -top,
|
|
5412
|
+
top,
|
|
5413
|
+
near,
|
|
5414
|
+
far
|
|
5415
|
+
});
|
|
5416
|
+
}
|
|
5417
|
+
perspective(view) {
|
|
5418
|
+
const {
|
|
5419
|
+
fovy = 45 * Math.PI / 180,
|
|
5420
|
+
aspect = 1,
|
|
5421
|
+
near = 0.1,
|
|
5422
|
+
far = 500
|
|
5423
|
+
} = view;
|
|
5424
|
+
checkRadians(fovy);
|
|
5425
|
+
perspective(this, fovy, aspect, near, far);
|
|
5426
|
+
return this.check();
|
|
5427
|
+
}
|
|
5428
|
+
determinant() {
|
|
5429
|
+
return determinant(this);
|
|
5430
|
+
}
|
|
5431
|
+
getScale(result = [-0, -0, -0]) {
|
|
5432
|
+
result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
|
|
5433
|
+
result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
|
|
5434
|
+
result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
|
|
5435
|
+
return result;
|
|
5436
|
+
}
|
|
5437
|
+
getTranslation(result = [-0, -0, -0]) {
|
|
5438
|
+
result[0] = this[12];
|
|
5439
|
+
result[1] = this[13];
|
|
5440
|
+
result[2] = this[14];
|
|
5441
|
+
return result;
|
|
5442
|
+
}
|
|
5443
|
+
getRotation(result, scaleResult) {
|
|
5444
|
+
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
5445
|
+
scaleResult = scaleResult || [-0, -0, -0];
|
|
5446
|
+
const scale2 = this.getScale(scaleResult);
|
|
5447
|
+
const inverseScale0 = 1 / scale2[0];
|
|
5448
|
+
const inverseScale1 = 1 / scale2[1];
|
|
5449
|
+
const inverseScale2 = 1 / scale2[2];
|
|
5450
|
+
result[0] = this[0] * inverseScale0;
|
|
5451
|
+
result[1] = this[1] * inverseScale1;
|
|
5452
|
+
result[2] = this[2] * inverseScale2;
|
|
5453
|
+
result[3] = 0;
|
|
5454
|
+
result[4] = this[4] * inverseScale0;
|
|
5455
|
+
result[5] = this[5] * inverseScale1;
|
|
5456
|
+
result[6] = this[6] * inverseScale2;
|
|
5457
|
+
result[7] = 0;
|
|
5458
|
+
result[8] = this[8] * inverseScale0;
|
|
5459
|
+
result[9] = this[9] * inverseScale1;
|
|
5460
|
+
result[10] = this[10] * inverseScale2;
|
|
5461
|
+
result[11] = 0;
|
|
5462
|
+
result[12] = 0;
|
|
5463
|
+
result[13] = 0;
|
|
5464
|
+
result[14] = 0;
|
|
5465
|
+
result[15] = 1;
|
|
5466
|
+
return result;
|
|
5467
|
+
}
|
|
5468
|
+
getRotationMatrix3(result, scaleResult) {
|
|
5469
|
+
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
5470
|
+
scaleResult = scaleResult || [-0, -0, -0];
|
|
5471
|
+
const scale2 = this.getScale(scaleResult);
|
|
5472
|
+
const inverseScale0 = 1 / scale2[0];
|
|
5473
|
+
const inverseScale1 = 1 / scale2[1];
|
|
5474
|
+
const inverseScale2 = 1 / scale2[2];
|
|
5475
|
+
result[0] = this[0] * inverseScale0;
|
|
5476
|
+
result[1] = this[1] * inverseScale1;
|
|
5477
|
+
result[2] = this[2] * inverseScale2;
|
|
5478
|
+
result[3] = this[4] * inverseScale0;
|
|
5479
|
+
result[4] = this[5] * inverseScale1;
|
|
5480
|
+
result[5] = this[6] * inverseScale2;
|
|
5481
|
+
result[6] = this[8] * inverseScale0;
|
|
5482
|
+
result[7] = this[9] * inverseScale1;
|
|
5483
|
+
result[8] = this[10] * inverseScale2;
|
|
5484
|
+
return result;
|
|
5485
|
+
}
|
|
5486
|
+
transpose() {
|
|
5487
|
+
transpose(this, this);
|
|
5488
|
+
return this.check();
|
|
5489
|
+
}
|
|
5490
|
+
invert() {
|
|
5491
|
+
invert(this, this);
|
|
5492
|
+
return this.check();
|
|
5493
|
+
}
|
|
5494
|
+
multiplyLeft(a) {
|
|
5495
|
+
multiply(this, a, this);
|
|
5496
|
+
return this.check();
|
|
5497
|
+
}
|
|
5498
|
+
multiplyRight(a) {
|
|
5499
|
+
multiply(this, this, a);
|
|
5500
|
+
return this.check();
|
|
5501
|
+
}
|
|
5502
|
+
rotateX(radians) {
|
|
5503
|
+
rotateX2(this, this, radians);
|
|
5504
|
+
return this.check();
|
|
5505
|
+
}
|
|
5506
|
+
rotateY(radians) {
|
|
5507
|
+
rotateY2(this, this, radians);
|
|
5508
|
+
return this.check();
|
|
5509
|
+
}
|
|
5510
|
+
rotateZ(radians) {
|
|
5511
|
+
rotateZ2(this, this, radians);
|
|
5512
|
+
return this.check();
|
|
5513
|
+
}
|
|
5514
|
+
rotateXYZ(angleXYZ) {
|
|
5515
|
+
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
|
|
5516
|
+
}
|
|
5517
|
+
rotateAxis(radians, axis) {
|
|
5518
|
+
rotate(this, this, radians, axis);
|
|
5519
|
+
return this.check();
|
|
5520
|
+
}
|
|
5521
|
+
scale(factor) {
|
|
5522
|
+
scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
|
|
5523
|
+
return this.check();
|
|
5524
|
+
}
|
|
5525
|
+
translate(vector) {
|
|
5526
|
+
translate(this, this, vector);
|
|
5527
|
+
return this.check();
|
|
5528
|
+
}
|
|
5529
|
+
transform(vector, result) {
|
|
5530
|
+
if (vector.length === 4) {
|
|
5531
|
+
result = transformMat43(result || [-0, -0, -0, -0], vector, this);
|
|
5532
|
+
checkVector(result, 4);
|
|
5533
|
+
return result;
|
|
5534
|
+
}
|
|
5535
|
+
return this.transformAsPoint(vector, result);
|
|
5536
|
+
}
|
|
5537
|
+
transformAsPoint(vector, result) {
|
|
5538
|
+
const {
|
|
5539
|
+
length
|
|
5540
|
+
} = vector;
|
|
5541
|
+
let out;
|
|
5542
|
+
switch (length) {
|
|
5543
|
+
case 2:
|
|
5544
|
+
out = transformMat4(result || [-0, -0], vector, this);
|
|
5545
|
+
break;
|
|
5546
|
+
case 3:
|
|
5547
|
+
out = transformMat42(result || [-0, -0, -0], vector, this);
|
|
5548
|
+
break;
|
|
5549
|
+
default:
|
|
5550
|
+
throw new Error("Illegal vector");
|
|
5551
|
+
}
|
|
5552
|
+
checkVector(out, vector.length);
|
|
5553
|
+
return out;
|
|
5554
|
+
}
|
|
5555
|
+
transformAsVector(vector, result) {
|
|
5556
|
+
let out;
|
|
5557
|
+
switch (vector.length) {
|
|
5558
|
+
case 2:
|
|
5559
|
+
out = vec2_transformMat4AsVector(result || [-0, -0], vector, this);
|
|
5560
|
+
break;
|
|
5561
|
+
case 3:
|
|
5562
|
+
out = vec3_transformMat4AsVector(result || [-0, -0, -0], vector, this);
|
|
5563
|
+
break;
|
|
5564
|
+
default:
|
|
5565
|
+
throw new Error("Illegal vector");
|
|
5566
|
+
}
|
|
5567
|
+
checkVector(out, vector.length);
|
|
5568
|
+
return out;
|
|
5569
|
+
}
|
|
5570
|
+
transformPoint(vector, result) {
|
|
5571
|
+
return this.transformAsPoint(vector, result);
|
|
5572
|
+
}
|
|
5573
|
+
transformVector(vector, result) {
|
|
5574
|
+
return this.transformAsPoint(vector, result);
|
|
5575
|
+
}
|
|
5576
|
+
transformDirection(vector, result) {
|
|
5577
|
+
return this.transformAsVector(vector, result);
|
|
5578
|
+
}
|
|
5579
|
+
makeRotationX(radians) {
|
|
5580
|
+
return this.identity().rotateX(radians);
|
|
5581
|
+
}
|
|
5582
|
+
makeTranslation(x, y, z) {
|
|
5583
|
+
return this.identity().translate([x, y, z]);
|
|
5584
|
+
}
|
|
5585
|
+
};
|
|
5586
|
+
var ZERO2;
|
|
5587
|
+
var IDENTITY;
|
|
5588
|
+
function getZeroMatrix() {
|
|
5589
|
+
if (!ZERO2) {
|
|
5590
|
+
ZERO2 = new Matrix4([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
5591
|
+
Object.freeze(ZERO2);
|
|
5592
|
+
}
|
|
5593
|
+
return ZERO2;
|
|
5594
|
+
}
|
|
5595
|
+
function getIdentityMatrix() {
|
|
5596
|
+
if (!IDENTITY) {
|
|
5597
|
+
IDENTITY = new Matrix4();
|
|
5598
|
+
Object.freeze(IDENTITY);
|
|
5599
|
+
}
|
|
5600
|
+
return IDENTITY;
|
|
5601
|
+
}
|
|
5602
|
+
function checkRadians(possiblyDegrees) {
|
|
5603
|
+
if (possiblyDegrees > Math.PI * 2) {
|
|
5604
|
+
throw Error("expected radians");
|
|
5605
|
+
}
|
|
5606
|
+
}
|
|
5607
|
+
function computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
|
|
5608
|
+
const column0Row0 = 2 * near / (right - left);
|
|
5609
|
+
const column1Row1 = 2 * near / (top - bottom);
|
|
5610
|
+
const column2Row0 = (right + left) / (right - left);
|
|
5611
|
+
const column2Row1 = (top + bottom) / (top - bottom);
|
|
5612
|
+
const column2Row2 = -1;
|
|
5613
|
+
const column2Row3 = -1;
|
|
5614
|
+
const column3Row2 = -2 * near;
|
|
5615
|
+
result[0] = column0Row0;
|
|
5616
|
+
result[1] = 0;
|
|
5617
|
+
result[2] = 0;
|
|
5618
|
+
result[3] = 0;
|
|
5619
|
+
result[4] = 0;
|
|
5620
|
+
result[5] = column1Row1;
|
|
5621
|
+
result[6] = 0;
|
|
5622
|
+
result[7] = 0;
|
|
5623
|
+
result[8] = column2Row0;
|
|
5624
|
+
result[9] = column2Row1;
|
|
5625
|
+
result[10] = column2Row2;
|
|
5626
|
+
result[11] = column2Row3;
|
|
5627
|
+
result[12] = 0;
|
|
5628
|
+
result[13] = 0;
|
|
5629
|
+
result[14] = column3Row2;
|
|
5630
|
+
result[15] = 0;
|
|
5631
|
+
return result;
|
|
5632
|
+
}
|
|
5633
|
+
|
|
4475
5634
|
// src/lib/pipeline-factory.ts
|
|
4476
5635
|
var DEFAULT_RENDER_PIPELINE_OPTIONS = {
|
|
4477
5636
|
vs: "",
|
|
@@ -6516,9 +7675,9 @@ void main() {
|
|
|
6516
7675
|
[GL.POLYGON_OFFSET_FACTOR]: factor,
|
|
6517
7676
|
[GL.POLYGON_OFFSET_UNITS]: units
|
|
6518
7677
|
}),
|
|
6519
|
-
sampleCoverage: (update, value,
|
|
7678
|
+
sampleCoverage: (update, value, invert2) => update({
|
|
6520
7679
|
[GL.SAMPLE_COVERAGE_VALUE]: value,
|
|
6521
|
-
[GL.SAMPLE_COVERAGE_INVERT]:
|
|
7680
|
+
[GL.SAMPLE_COVERAGE_INVERT]: invert2
|
|
6522
7681
|
}),
|
|
6523
7682
|
scissor: (update, x, y, width, height) => update({
|
|
6524
7683
|
[GL.SCISSOR_BOX]: new Int32Array([x, y, width, height])
|
|
@@ -10158,7 +11317,7 @@ void main(void) {}`;
|
|
|
10158
11317
|
}
|
|
10159
11318
|
};
|
|
10160
11319
|
|
|
10161
|
-
// ../webgl/src/classic/buffer.ts
|
|
11320
|
+
// ../webgl/src/classic/buffer-with-accessor.ts
|
|
10162
11321
|
var DEBUG_DATA_LENGTH2 = 10;
|
|
10163
11322
|
var DEPRECATED_PROPS = {
|
|
10164
11323
|
offset: "accessor.offset",
|
|
@@ -10202,7 +11361,7 @@ void main(void) {}`;
|
|
|
10202
11361
|
}
|
|
10203
11362
|
return bufferProps;
|
|
10204
11363
|
}
|
|
10205
|
-
var
|
|
11364
|
+
var BufferWithAccessor = class extends WEBGLBuffer {
|
|
10206
11365
|
constructor(device, props = {}) {
|
|
10207
11366
|
super(WebGLDevice.attach(device), getWEBGLBufferProps(props));
|
|
10208
11367
|
this.setAccessor(Object.assign({}, props, props.accessor));
|
|
@@ -12023,7 +13182,7 @@ ${formattedLog}`)();
|
|
|
12023
13182
|
}
|
|
12024
13183
|
createBuffer(props) {
|
|
12025
13184
|
const newProps = this._getBufferProps(props);
|
|
12026
|
-
return new
|
|
13185
|
+
return new BufferWithAccessor(this, newProps);
|
|
12027
13186
|
}
|
|
12028
13187
|
_createTexture(props) {
|
|
12029
13188
|
return new WEBGLTexture(this, props);
|
|
@@ -12421,6 +13580,281 @@ void main(void) {
|
|
|
12421
13580
|
}
|
|
12422
13581
|
};
|
|
12423
13582
|
|
|
13583
|
+
// src/scenegraph/scenegraph-node.ts
|
|
13584
|
+
var ScenegraphNode = class {
|
|
13585
|
+
matrix = new Matrix4();
|
|
13586
|
+
display = true;
|
|
13587
|
+
position = new Vector3();
|
|
13588
|
+
rotation = new Vector3();
|
|
13589
|
+
scale = new Vector3(1, 1, 1);
|
|
13590
|
+
userData = {};
|
|
13591
|
+
props = {};
|
|
13592
|
+
constructor(props = {}) {
|
|
13593
|
+
const {
|
|
13594
|
+
id
|
|
13595
|
+
} = props;
|
|
13596
|
+
this.id = id || uid(this.constructor.name);
|
|
13597
|
+
this._setScenegraphNodeProps(props);
|
|
13598
|
+
}
|
|
13599
|
+
getBounds() {
|
|
13600
|
+
return null;
|
|
13601
|
+
}
|
|
13602
|
+
destroy() {
|
|
13603
|
+
}
|
|
13604
|
+
/** @deprecated use .destroy() */
|
|
13605
|
+
delete() {
|
|
13606
|
+
this.destroy();
|
|
13607
|
+
}
|
|
13608
|
+
setProps(props) {
|
|
13609
|
+
this._setScenegraphNodeProps(props);
|
|
13610
|
+
return this;
|
|
13611
|
+
}
|
|
13612
|
+
toString() {
|
|
13613
|
+
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
13614
|
+
}
|
|
13615
|
+
setPosition(position) {
|
|
13616
|
+
assert2(position.length === 3, "setPosition requires vector argument");
|
|
13617
|
+
this.position = position;
|
|
13618
|
+
return this;
|
|
13619
|
+
}
|
|
13620
|
+
setRotation(rotation) {
|
|
13621
|
+
assert2(rotation.length === 3, "setRotation requires vector argument");
|
|
13622
|
+
this.rotation = rotation;
|
|
13623
|
+
return this;
|
|
13624
|
+
}
|
|
13625
|
+
setScale(scale2) {
|
|
13626
|
+
assert2(scale2.length === 3, "setScale requires vector argument");
|
|
13627
|
+
this.scale = scale2;
|
|
13628
|
+
return this;
|
|
13629
|
+
}
|
|
13630
|
+
setMatrix(matrix, copyMatrix = true) {
|
|
13631
|
+
if (copyMatrix) {
|
|
13632
|
+
this.matrix.copy(matrix);
|
|
13633
|
+
} else {
|
|
13634
|
+
this.matrix = matrix;
|
|
13635
|
+
}
|
|
13636
|
+
}
|
|
13637
|
+
setMatrixComponents(components) {
|
|
13638
|
+
const {
|
|
13639
|
+
position,
|
|
13640
|
+
rotation,
|
|
13641
|
+
scale: scale2,
|
|
13642
|
+
update = true
|
|
13643
|
+
} = components;
|
|
13644
|
+
if (position) {
|
|
13645
|
+
this.setPosition(position);
|
|
13646
|
+
}
|
|
13647
|
+
if (rotation) {
|
|
13648
|
+
this.setRotation(rotation);
|
|
13649
|
+
}
|
|
13650
|
+
if (scale2) {
|
|
13651
|
+
this.setScale(scale2);
|
|
13652
|
+
}
|
|
13653
|
+
if (update) {
|
|
13654
|
+
this.updateMatrix();
|
|
13655
|
+
}
|
|
13656
|
+
return this;
|
|
13657
|
+
}
|
|
13658
|
+
updateMatrix() {
|
|
13659
|
+
const pos = this.position;
|
|
13660
|
+
const rot = this.rotation;
|
|
13661
|
+
const scale2 = this.scale;
|
|
13662
|
+
this.matrix.identity();
|
|
13663
|
+
this.matrix.translate(pos);
|
|
13664
|
+
this.matrix.rotateXYZ(rot);
|
|
13665
|
+
this.matrix.scale(scale2);
|
|
13666
|
+
return this;
|
|
13667
|
+
}
|
|
13668
|
+
update(options = {}) {
|
|
13669
|
+
const {
|
|
13670
|
+
position,
|
|
13671
|
+
rotation,
|
|
13672
|
+
scale: scale2
|
|
13673
|
+
} = options;
|
|
13674
|
+
if (position) {
|
|
13675
|
+
this.setPosition(position);
|
|
13676
|
+
}
|
|
13677
|
+
if (rotation) {
|
|
13678
|
+
this.setRotation(rotation);
|
|
13679
|
+
}
|
|
13680
|
+
if (scale2) {
|
|
13681
|
+
this.setScale(scale2);
|
|
13682
|
+
}
|
|
13683
|
+
this.updateMatrix();
|
|
13684
|
+
return this;
|
|
13685
|
+
}
|
|
13686
|
+
getCoordinateUniforms(viewMatrix, modelMatrix) {
|
|
13687
|
+
assert2(viewMatrix);
|
|
13688
|
+
modelMatrix = modelMatrix || this.matrix;
|
|
13689
|
+
const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);
|
|
13690
|
+
const worldInverse = worldMatrix.invert();
|
|
13691
|
+
const worldInverseTranspose = worldInverse.transpose();
|
|
13692
|
+
return {
|
|
13693
|
+
viewMatrix,
|
|
13694
|
+
modelMatrix,
|
|
13695
|
+
objectMatrix: modelMatrix,
|
|
13696
|
+
worldMatrix,
|
|
13697
|
+
worldInverseMatrix: worldInverse,
|
|
13698
|
+
worldInverseTransposeMatrix: worldInverseTranspose
|
|
13699
|
+
};
|
|
13700
|
+
}
|
|
13701
|
+
// TODO - copied code, not yet vetted
|
|
13702
|
+
/*
|
|
13703
|
+
transform() {
|
|
13704
|
+
if (!this.parent) {
|
|
13705
|
+
this.endPosition.set(this.position);
|
|
13706
|
+
this.endRotation.set(this.rotation);
|
|
13707
|
+
this.endScale.set(this.scale);
|
|
13708
|
+
} else {
|
|
13709
|
+
const parent = this.parent;
|
|
13710
|
+
this.endPosition.set(this.position.add(parent.endPosition));
|
|
13711
|
+
this.endRotation.set(this.rotation.add(parent.endRotation));
|
|
13712
|
+
this.endScale.set(this.scale.add(parent.endScale));
|
|
13713
|
+
}
|
|
13714
|
+
const ch = this.children;
|
|
13715
|
+
for (let i = 0; i < ch.length; ++i) {
|
|
13716
|
+
ch[i].transform();
|
|
13717
|
+
}
|
|
13718
|
+
return this;
|
|
13719
|
+
}
|
|
13720
|
+
*/
|
|
13721
|
+
_setScenegraphNodeProps(props) {
|
|
13722
|
+
if ("display" in props) {
|
|
13723
|
+
this.display = props.display;
|
|
13724
|
+
}
|
|
13725
|
+
if ("position" in props) {
|
|
13726
|
+
this.setPosition(props.position);
|
|
13727
|
+
}
|
|
13728
|
+
if ("rotation" in props) {
|
|
13729
|
+
this.setRotation(props.rotation);
|
|
13730
|
+
}
|
|
13731
|
+
if ("scale" in props) {
|
|
13732
|
+
this.setScale(props.scale);
|
|
13733
|
+
}
|
|
13734
|
+
if ("matrix" in props) {
|
|
13735
|
+
this.setMatrix(props.matrix);
|
|
13736
|
+
}
|
|
13737
|
+
Object.assign(this.props, props);
|
|
13738
|
+
}
|
|
13739
|
+
};
|
|
13740
|
+
|
|
13741
|
+
// src/scenegraph/group-node.ts
|
|
13742
|
+
var GroupNode = class extends ScenegraphNode {
|
|
13743
|
+
constructor(props = {}) {
|
|
13744
|
+
props = Array.isArray(props) ? {
|
|
13745
|
+
children: props
|
|
13746
|
+
} : props;
|
|
13747
|
+
const {
|
|
13748
|
+
children = []
|
|
13749
|
+
} = props;
|
|
13750
|
+
log.assert(children.every((child) => child instanceof ScenegraphNode), "every child must an instance of ScenegraphNode");
|
|
13751
|
+
super(props);
|
|
13752
|
+
this.children = children;
|
|
13753
|
+
}
|
|
13754
|
+
getBounds() {
|
|
13755
|
+
const result = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];
|
|
13756
|
+
this.traverse((node, {
|
|
13757
|
+
worldMatrix
|
|
13758
|
+
}) => {
|
|
13759
|
+
const bounds = node.getBounds();
|
|
13760
|
+
if (!bounds) {
|
|
13761
|
+
return;
|
|
13762
|
+
}
|
|
13763
|
+
const [min, max] = bounds;
|
|
13764
|
+
const center = new Vector3(min).add(max).divide([2, 2, 2]);
|
|
13765
|
+
worldMatrix.transformAsPoint(center, center);
|
|
13766
|
+
const halfSize = new Vector3(max).subtract(min).divide([2, 2, 2]);
|
|
13767
|
+
worldMatrix.transformAsVector(halfSize, halfSize);
|
|
13768
|
+
for (let v = 0; v < 8; v++) {
|
|
13769
|
+
const position = new Vector3(v & 1 ? -1 : 1, v & 2 ? -1 : 1, v & 4 ? -1 : 1).multiply(halfSize).add(center);
|
|
13770
|
+
for (let i = 0; i < 3; i++) {
|
|
13771
|
+
result[0][i] = Math.min(result[0][i], position[i]);
|
|
13772
|
+
result[1][i] = Math.max(result[1][i], position[i]);
|
|
13773
|
+
}
|
|
13774
|
+
}
|
|
13775
|
+
});
|
|
13776
|
+
if (!Number.isFinite(result[0][0])) {
|
|
13777
|
+
return null;
|
|
13778
|
+
}
|
|
13779
|
+
return result;
|
|
13780
|
+
}
|
|
13781
|
+
destroy() {
|
|
13782
|
+
this.children.forEach((child) => child.destroy());
|
|
13783
|
+
this.removeAll();
|
|
13784
|
+
super.destroy();
|
|
13785
|
+
}
|
|
13786
|
+
// Unpacks arrays and nested arrays of children
|
|
13787
|
+
add(...children) {
|
|
13788
|
+
for (const child of children) {
|
|
13789
|
+
if (Array.isArray(child)) {
|
|
13790
|
+
this.add(...child);
|
|
13791
|
+
} else {
|
|
13792
|
+
this.children.push(child);
|
|
13793
|
+
}
|
|
13794
|
+
}
|
|
13795
|
+
return this;
|
|
13796
|
+
}
|
|
13797
|
+
remove(child) {
|
|
13798
|
+
const children = this.children;
|
|
13799
|
+
const indexOf = children.indexOf(child);
|
|
13800
|
+
if (indexOf > -1) {
|
|
13801
|
+
children.splice(indexOf, 1);
|
|
13802
|
+
}
|
|
13803
|
+
return this;
|
|
13804
|
+
}
|
|
13805
|
+
removeAll() {
|
|
13806
|
+
this.children = [];
|
|
13807
|
+
return this;
|
|
13808
|
+
}
|
|
13809
|
+
traverse(visitor, {
|
|
13810
|
+
worldMatrix = new Matrix4()
|
|
13811
|
+
} = {}) {
|
|
13812
|
+
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
13813
|
+
for (const child of this.children) {
|
|
13814
|
+
if (child instanceof GroupNode) {
|
|
13815
|
+
child.traverse(visitor, {
|
|
13816
|
+
worldMatrix: modelMatrix
|
|
13817
|
+
});
|
|
13818
|
+
} else {
|
|
13819
|
+
visitor(child, {
|
|
13820
|
+
worldMatrix: modelMatrix
|
|
13821
|
+
});
|
|
13822
|
+
}
|
|
13823
|
+
}
|
|
13824
|
+
}
|
|
13825
|
+
};
|
|
13826
|
+
|
|
13827
|
+
// src/scenegraph/model-node.ts
|
|
13828
|
+
var ModelNode = class extends ScenegraphNode {
|
|
13829
|
+
bounds = null;
|
|
13830
|
+
// TODO - is this used? override callbacks to make sure we call them with this
|
|
13831
|
+
// onBeforeRender = null;
|
|
13832
|
+
// onAfterRender = null;
|
|
13833
|
+
// AfterRender = null;
|
|
13834
|
+
constructor(props) {
|
|
13835
|
+
super(props);
|
|
13836
|
+
this.model = props.model;
|
|
13837
|
+
this.managedResources = props.managedResources || [];
|
|
13838
|
+
this.bounds = props.bounds || null;
|
|
13839
|
+
this.setProps(props);
|
|
13840
|
+
}
|
|
13841
|
+
getBounds() {
|
|
13842
|
+
return this.bounds;
|
|
13843
|
+
}
|
|
13844
|
+
destroy() {
|
|
13845
|
+
if (this.model) {
|
|
13846
|
+
this.model.destroy();
|
|
13847
|
+
this.model = null;
|
|
13848
|
+
}
|
|
13849
|
+
this.managedResources.forEach((resource) => resource.destroy());
|
|
13850
|
+
this.managedResources = [];
|
|
13851
|
+
}
|
|
13852
|
+
// Expose model methods
|
|
13853
|
+
draw(renderPass) {
|
|
13854
|
+
return this.model.draw(renderPass);
|
|
13855
|
+
}
|
|
13856
|
+
};
|
|
13857
|
+
|
|
12424
13858
|
// src/geometries/truncated-cone-geometry.ts
|
|
12425
13859
|
var INDEX_OFFSETS = {
|
|
12426
13860
|
x: [2, 0, 1],
|