@threepipe/plugin-blend-importer 0.0.6 → 0.0.8

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/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("threepipe"), require("three")) : typeof define === "function" && define.amd ? define(["exports", "threepipe", "three"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@threepipe/plugin-blend-importer"] = {}, global.threepipe, global.threepipe));
3
- })(this, function(exports2, threepipe, three) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("threepipe")) : typeof define === "function" && define.amd ? define(["exports", "threepipe"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@threepipe/plugin-blend-importer"] = {}, global.threepipe));
3
+ })(this, function(exports2, threepipe) {
4
4
  "use strict";/**
5
5
  * @license
6
- * @threepipe/plugin-blend-importer v0.0.6
6
+ * @threepipe/plugin-blend-importer v0.0.8
7
7
  * Copyright 2022-2025 repalash <palash@shaders.app>
8
8
  * Apache-2.0 License
9
9
  * See ./dependencies.txt for any bundled third-party dependencies and licenses.
@@ -414,6 +414,15 @@
414
414
  function toString(buffer, _in, _out) {
415
415
  return String.fromCharCode.apply(String, new Uint8Array(buffer, _in, _out - _in));
416
416
  }
417
+ function seekCheck(buffer, _in, str) {
418
+ const length = str.length;
419
+ for (let i = 0; i < length; i++) {
420
+ if (buffer.getUint8(_in + i) !== str.charCodeAt(i)) {
421
+ return false;
422
+ }
423
+ }
424
+ return true;
425
+ }
417
426
  function readFile() {
418
427
  let count = 0;
419
428
  let offset2 = 0;
@@ -464,14 +473,13 @@
464
473
  offset2++;
465
474
  curr_count++;
466
475
  }
467
- if (toString(_data, offset2, offset2 + 4) !== "TYPE") {
468
- for (let j = 0; j < 8; j++) {
469
- if (toString(_data, offset2, offset2 + 4) === "TYPE") break;
470
- offset2++;
471
- }
476
+ for (let j = 0; j < 8; j++) {
477
+ if (seekCheck(data, offset2, "TYPE")) break;
478
+ offset2++;
472
479
  }
473
- if (toString(_data, offset2, offset2 + 4) !== "TYPE") {
474
- debugger;
480
+ if (!seekCheck(data, offset2, "TYPE")) {
481
+ ERROR = "Unexpected alignment error in SDNA parsing";
482
+ break;
475
483
  }
476
484
  offset2 += 4;
477
485
  count = data.getUint32(offset2, true);
@@ -487,14 +495,13 @@
487
495
  offset2++;
488
496
  curr_count++;
489
497
  }
490
- if (toString(_data, offset2, offset2 + 4) !== "TLEN") {
491
- for (let j = 0; j < 8; j++) {
492
- if (toString(_data, offset2, offset2 + 4) === "TLEN") break;
493
- offset2++;
494
- }
498
+ for (let j = 0; j < 8; j++) {
499
+ if (seekCheck(data, offset2, "TLEN")) break;
500
+ offset2++;
495
501
  }
496
- if (toString(_data, offset2, offset2 + 4) !== "TLEN") {
497
- debugger;
502
+ if (!seekCheck(data, offset2, "TLEN")) {
503
+ ERROR = "Unexpected alignment error in SDNA parsing";
504
+ break;
498
505
  }
499
506
  offset2 += 4;
500
507
  curr_count = 0;
@@ -503,14 +510,13 @@
503
510
  offset2 += 2;
504
511
  curr_count++;
505
512
  }
506
- if (toString(_data, offset2, offset2 + 4) !== "STRC") {
507
- for (let j = 0; j < 8; j++) {
508
- if (toString(_data, offset2, offset2 + 4) === "STRC") break;
509
- offset2++;
510
- }
513
+ for (let j = 0; j < 8; j++) {
514
+ if (seekCheck(data, offset2, "STRC")) break;
515
+ offset2++;
511
516
  }
512
- if (toString(_data, offset2, offset2 + 4) !== "STRC") {
513
- debugger;
517
+ if (!seekCheck(data, offset2, "STRC")) {
518
+ ERROR = "Unexpected alignment error in SDNA parsing";
519
+ break;
514
520
  }
515
521
  offset2 += 4;
516
522
  const structure_count = data.getInt32(offset2, BIG_ENDIAN);
@@ -714,12 +720,13 @@
714
720
  return layers[i];
715
721
  }
716
722
  function createBufferGeometry(meshData, ctx) {
717
- var _a;
718
723
  if (meshData.mpoly) return createBufferGeometryOld(meshData, ctx);
719
724
  const geometry = new ctx.BufferGeometry();
720
725
  geometry.name = meshData.aname || "";
721
726
  let vertices;
727
+ let verticesData;
722
728
  let indices;
729
+ let indicesData;
723
730
  if (meshData.vdata && meshData.vdata.layers && meshData.vdata.totlayer > 0) {
724
731
  for (let i = 0; i < meshData.vdata.totlayer; i++) {
725
732
  const layer = getLayer(meshData.vdata.layers, i);
@@ -729,6 +736,7 @@
729
736
  continue;
730
737
  }
731
738
  vertices = layer;
739
+ verticesData = data;
732
740
  }
733
741
  }
734
742
  }
@@ -741,6 +749,7 @@
741
749
  continue;
742
750
  }
743
751
  indices = layer;
752
+ indicesData = data;
744
753
  }
745
754
  }
746
755
  }
@@ -748,26 +757,26 @@
748
757
  if (meshData.poly_offset_indices && meshData.totpoly > 0) {
749
758
  faceIndices = [...new Int32Array(meshData.poly_offset_indices.__blender_file__.AB, meshData.poly_offset_indices.__data_address__, meshData.totpoly + 1)];
750
759
  }
751
- if ((vertices == null ? void 0 : vertices.data) && vertices.data.length > 0) {
752
- const positions = new Float32Array(vertices.data.length * 3);
753
- for (let j = 0; j < vertices.data.length; j++) {
754
- const vertex = vertices.data[j];
755
- if (vertex.x !== void 0) {
756
- positions[j * 3] = vertex.x;
757
- positions[j * 3 + 1] = vertex.z;
758
- positions[j * 3 + 2] = -vertex.y;
759
- } else if (vertex.co !== void 0) {
760
- positions[j * 3] = vertex.co[0];
761
- positions[j * 3 + 1] = vertex.co[2];
762
- positions[j * 3 + 2] = -vertex.co[1];
760
+ if (verticesData && verticesData.length > 0) {
761
+ const positions = new Float32Array(verticesData.length * 3);
762
+ for (let j = 0; j < verticesData.length; j++) {
763
+ const { x, y, z, co } = verticesData[j] || {};
764
+ if (x !== void 0) {
765
+ positions[j * 3] = x;
766
+ positions[j * 3 + 1] = z;
767
+ positions[j * 3 + 2] = -y;
768
+ } else if (co !== void 0) {
769
+ positions[j * 3] = co[0];
770
+ positions[j * 3 + 1] = co[2];
771
+ positions[j * 3 + 2] = -co[1];
763
772
  } else {
764
- console.error("BlendLoader - unknown vertex", vertex);
773
+ console.error("BlendLoader - unknown vertex", verticesData[j]);
765
774
  break;
766
775
  }
767
776
  }
768
777
  geometry.setAttribute("position", new ctx.BufferAttribute(positions, 3));
769
778
  }
770
- if ((indices == null ? void 0 : indices.data) && indices.data.length > 0 && ((_a = vertices == null ? void 0 : vertices.data) == null ? void 0 : _a.length)) {
779
+ if (indicesData && indicesData.length > 0 && (verticesData == null ? void 0 : verticesData.length)) {
771
780
  const faceSize = meshData.totloop / meshData.totpoly;
772
781
  if (faceIndices.length > 0) {
773
782
  let totalTriangles = 0;
@@ -782,11 +791,11 @@
782
791
  const faceEnd = faceIndices[i + 1];
783
792
  const faceVertCount = faceEnd - faceStart;
784
793
  if (faceVertCount >= 3) {
785
- const firstVert = indices.data[faceStart].i;
794
+ const firstVert = indicesData[faceStart].i;
786
795
  for (let k = 1; k < faceVertCount - 1; k++) {
787
796
  indexes[t++] = firstVert;
788
- indexes[t++] = indices.data[faceStart + k].i;
789
- indexes[t++] = indices.data[faceStart + k + 1].i;
797
+ indexes[t++] = indicesData[faceStart + k].i;
798
+ indexes[t++] = indicesData[faceStart + k + 1].i;
790
799
  }
791
800
  }
792
801
  }
@@ -841,21 +850,24 @@
841
850
  if (indexi - 1 + l < len)
842
851
  index += indexi - 1 + l;
843
852
  const loop = loops[index];
844
- const vert = vertices[loop.v];
853
+ const { co, no } = vertices[loop.v] || {};
845
854
  indices[currentIndex] = currentIndex;
846
- positions[currentIndex * 3 + 0] = vert.co[0];
847
- positions[currentIndex * 3 + 1] = vert.co[2];
848
- positions[currentIndex * 3 + 2] = -vert.co[1];
849
- if (vert.no) {
850
- normals[currentIndex * 3 + 0] = vert.no[0];
851
- normals[currentIndex * 3 + 1] = vert.no[2];
852
- normals[currentIndex * 3 + 2] = -vert.no[1];
855
+ if (co) {
856
+ positions[currentIndex * 3 + 0] = co[0];
857
+ positions[currentIndex * 3 + 1] = co[2];
858
+ positions[currentIndex * 3 + 2] = -co[1];
859
+ }
860
+ if (no) {
861
+ normals[currentIndex * 3 + 0] = no[0];
862
+ normals[currentIndex * 3 + 1] = no[2];
863
+ normals[currentIndex * 3 + 2] = -no[1];
853
864
  } else {
854
865
  computeNormals = true;
855
866
  }
856
867
  if (uv) {
857
- uvs[currentIndex * 2 + 0] = uv[index].uv[0];
858
- uvs[currentIndex * 2 + 1] = uv[index].uv[1];
868
+ const uv1 = uv[index].uv;
869
+ uvs[currentIndex * 2 + 0] = uv1[0];
870
+ uvs[currentIndex * 2 + 1] = uv1[1];
859
871
  }
860
872
  currentIndex++;
861
873
  }
@@ -894,1765 +906,6 @@
894
906
  mesh.receiveShadow = true;
895
907
  return mesh;
896
908
  }
897
- function clamp(value, min, max) {
898
- return Math.max(min, Math.min(max, value));
899
- }
900
- class Quaternion {
901
- constructor(x = 0, y = 0, z = 0, w = 1) {
902
- this.isQuaternion = true;
903
- this._x = x;
904
- this._y = y;
905
- this._z = z;
906
- this._w = w;
907
- }
908
- static slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
909
- let x0 = src0[srcOffset0 + 0], y0 = src0[srcOffset0 + 1], z0 = src0[srcOffset0 + 2], w0 = src0[srcOffset0 + 3];
910
- const x1 = src1[srcOffset1 + 0], y1 = src1[srcOffset1 + 1], z1 = src1[srcOffset1 + 2], w1 = src1[srcOffset1 + 3];
911
- if (t === 0) {
912
- dst[dstOffset + 0] = x0;
913
- dst[dstOffset + 1] = y0;
914
- dst[dstOffset + 2] = z0;
915
- dst[dstOffset + 3] = w0;
916
- return;
917
- }
918
- if (t === 1) {
919
- dst[dstOffset + 0] = x1;
920
- dst[dstOffset + 1] = y1;
921
- dst[dstOffset + 2] = z1;
922
- dst[dstOffset + 3] = w1;
923
- return;
924
- }
925
- if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
926
- let s = 1 - t;
927
- const cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, dir = cos >= 0 ? 1 : -1, sqrSin = 1 - cos * cos;
928
- if (sqrSin > Number.EPSILON) {
929
- const sin = Math.sqrt(sqrSin), len = Math.atan2(sin, cos * dir);
930
- s = Math.sin(s * len) / sin;
931
- t = Math.sin(t * len) / sin;
932
- }
933
- const tDir = t * dir;
934
- x0 = x0 * s + x1 * tDir;
935
- y0 = y0 * s + y1 * tDir;
936
- z0 = z0 * s + z1 * tDir;
937
- w0 = w0 * s + w1 * tDir;
938
- if (s === 1 - t) {
939
- const f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
940
- x0 *= f;
941
- y0 *= f;
942
- z0 *= f;
943
- w0 *= f;
944
- }
945
- }
946
- dst[dstOffset] = x0;
947
- dst[dstOffset + 1] = y0;
948
- dst[dstOffset + 2] = z0;
949
- dst[dstOffset + 3] = w0;
950
- }
951
- static multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) {
952
- const x0 = src0[srcOffset0];
953
- const y0 = src0[srcOffset0 + 1];
954
- const z0 = src0[srcOffset0 + 2];
955
- const w0 = src0[srcOffset0 + 3];
956
- const x1 = src1[srcOffset1];
957
- const y1 = src1[srcOffset1 + 1];
958
- const z1 = src1[srcOffset1 + 2];
959
- const w1 = src1[srcOffset1 + 3];
960
- dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
961
- dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
962
- dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
963
- dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
964
- return dst;
965
- }
966
- get x() {
967
- return this._x;
968
- }
969
- set x(value) {
970
- this._x = value;
971
- this._onChangeCallback();
972
- }
973
- get y() {
974
- return this._y;
975
- }
976
- set y(value) {
977
- this._y = value;
978
- this._onChangeCallback();
979
- }
980
- get z() {
981
- return this._z;
982
- }
983
- set z(value) {
984
- this._z = value;
985
- this._onChangeCallback();
986
- }
987
- get w() {
988
- return this._w;
989
- }
990
- set w(value) {
991
- this._w = value;
992
- this._onChangeCallback();
993
- }
994
- set(x, y, z, w) {
995
- this._x = x;
996
- this._y = y;
997
- this._z = z;
998
- this._w = w;
999
- this._onChangeCallback();
1000
- return this;
1001
- }
1002
- clone() {
1003
- return new this.constructor(this._x, this._y, this._z, this._w);
1004
- }
1005
- copy(quaternion) {
1006
- this._x = quaternion.x;
1007
- this._y = quaternion.y;
1008
- this._z = quaternion.z;
1009
- this._w = quaternion.w;
1010
- this._onChangeCallback();
1011
- return this;
1012
- }
1013
- setFromEuler(euler, update = true) {
1014
- const x = euler._x, y = euler._y, z = euler._z, order = euler._order;
1015
- const cos = Math.cos;
1016
- const sin = Math.sin;
1017
- const c1 = cos(x / 2);
1018
- const c2 = cos(y / 2);
1019
- const c3 = cos(z / 2);
1020
- const s1 = sin(x / 2);
1021
- const s2 = sin(y / 2);
1022
- const s3 = sin(z / 2);
1023
- switch (order) {
1024
- case "XYZ":
1025
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
1026
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
1027
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
1028
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
1029
- break;
1030
- case "YXZ":
1031
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
1032
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
1033
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
1034
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
1035
- break;
1036
- case "ZXY":
1037
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
1038
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
1039
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
1040
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
1041
- break;
1042
- case "ZYX":
1043
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
1044
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
1045
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
1046
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
1047
- break;
1048
- case "YZX":
1049
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
1050
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
1051
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
1052
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
1053
- break;
1054
- case "XZY":
1055
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
1056
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
1057
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
1058
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
1059
- break;
1060
- default:
1061
- console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + order);
1062
- }
1063
- if (update === true) this._onChangeCallback();
1064
- return this;
1065
- }
1066
- setFromAxisAngle(axis, angle) {
1067
- const halfAngle = angle / 2, s = Math.sin(halfAngle);
1068
- this._x = axis.x * s;
1069
- this._y = axis.y * s;
1070
- this._z = axis.z * s;
1071
- this._w = Math.cos(halfAngle);
1072
- this._onChangeCallback();
1073
- return this;
1074
- }
1075
- setFromRotationMatrix(m) {
1076
- const te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10], trace = m11 + m22 + m33;
1077
- if (trace > 0) {
1078
- const s = 0.5 / Math.sqrt(trace + 1);
1079
- this._w = 0.25 / s;
1080
- this._x = (m32 - m23) * s;
1081
- this._y = (m13 - m31) * s;
1082
- this._z = (m21 - m12) * s;
1083
- } else if (m11 > m22 && m11 > m33) {
1084
- const s = 2 * Math.sqrt(1 + m11 - m22 - m33);
1085
- this._w = (m32 - m23) / s;
1086
- this._x = 0.25 * s;
1087
- this._y = (m12 + m21) / s;
1088
- this._z = (m13 + m31) / s;
1089
- } else if (m22 > m33) {
1090
- const s = 2 * Math.sqrt(1 + m22 - m11 - m33);
1091
- this._w = (m13 - m31) / s;
1092
- this._x = (m12 + m21) / s;
1093
- this._y = 0.25 * s;
1094
- this._z = (m23 + m32) / s;
1095
- } else {
1096
- const s = 2 * Math.sqrt(1 + m33 - m11 - m22);
1097
- this._w = (m21 - m12) / s;
1098
- this._x = (m13 + m31) / s;
1099
- this._y = (m23 + m32) / s;
1100
- this._z = 0.25 * s;
1101
- }
1102
- this._onChangeCallback();
1103
- return this;
1104
- }
1105
- setFromUnitVectors(vFrom, vTo) {
1106
- let r = vFrom.dot(vTo) + 1;
1107
- if (r < Number.EPSILON) {
1108
- r = 0;
1109
- if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
1110
- this._x = -vFrom.y;
1111
- this._y = vFrom.x;
1112
- this._z = 0;
1113
- this._w = r;
1114
- } else {
1115
- this._x = 0;
1116
- this._y = -vFrom.z;
1117
- this._z = vFrom.y;
1118
- this._w = r;
1119
- }
1120
- } else {
1121
- this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
1122
- this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
1123
- this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
1124
- this._w = r;
1125
- }
1126
- return this.normalize();
1127
- }
1128
- angleTo(q) {
1129
- return 2 * Math.acos(Math.abs(clamp(this.dot(q), -1, 1)));
1130
- }
1131
- rotateTowards(q, step) {
1132
- const angle = this.angleTo(q);
1133
- if (angle === 0) return this;
1134
- const t = Math.min(1, step / angle);
1135
- this.slerp(q, t);
1136
- return this;
1137
- }
1138
- identity() {
1139
- return this.set(0, 0, 0, 1);
1140
- }
1141
- invert() {
1142
- return this.conjugate();
1143
- }
1144
- conjugate() {
1145
- this._x *= -1;
1146
- this._y *= -1;
1147
- this._z *= -1;
1148
- this._onChangeCallback();
1149
- return this;
1150
- }
1151
- dot(v) {
1152
- return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
1153
- }
1154
- lengthSq() {
1155
- return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
1156
- }
1157
- length() {
1158
- return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
1159
- }
1160
- normalize() {
1161
- let l = this.length();
1162
- if (l === 0) {
1163
- this._x = 0;
1164
- this._y = 0;
1165
- this._z = 0;
1166
- this._w = 1;
1167
- } else {
1168
- l = 1 / l;
1169
- this._x = this._x * l;
1170
- this._y = this._y * l;
1171
- this._z = this._z * l;
1172
- this._w = this._w * l;
1173
- }
1174
- this._onChangeCallback();
1175
- return this;
1176
- }
1177
- multiply(q) {
1178
- return this.multiplyQuaternions(this, q);
1179
- }
1180
- premultiply(q) {
1181
- return this.multiplyQuaternions(q, this);
1182
- }
1183
- multiplyQuaternions(a, b) {
1184
- const qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
1185
- const qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
1186
- this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
1187
- this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
1188
- this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
1189
- this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
1190
- this._onChangeCallback();
1191
- return this;
1192
- }
1193
- slerp(qb, t) {
1194
- if (t === 0) return this;
1195
- if (t === 1) return this.copy(qb);
1196
- const x = this._x, y = this._y, z = this._z, w = this._w;
1197
- let cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
1198
- if (cosHalfTheta < 0) {
1199
- this._w = -qb._w;
1200
- this._x = -qb._x;
1201
- this._y = -qb._y;
1202
- this._z = -qb._z;
1203
- cosHalfTheta = -cosHalfTheta;
1204
- } else {
1205
- this.copy(qb);
1206
- }
1207
- if (cosHalfTheta >= 1) {
1208
- this._w = w;
1209
- this._x = x;
1210
- this._y = y;
1211
- this._z = z;
1212
- return this;
1213
- }
1214
- const sqrSinHalfTheta = 1 - cosHalfTheta * cosHalfTheta;
1215
- if (sqrSinHalfTheta <= Number.EPSILON) {
1216
- const s = 1 - t;
1217
- this._w = s * w + t * this._w;
1218
- this._x = s * x + t * this._x;
1219
- this._y = s * y + t * this._y;
1220
- this._z = s * z + t * this._z;
1221
- this.normalize();
1222
- return this;
1223
- }
1224
- const sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
1225
- const halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
1226
- const ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta, ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
1227
- this._w = w * ratioA + this._w * ratioB;
1228
- this._x = x * ratioA + this._x * ratioB;
1229
- this._y = y * ratioA + this._y * ratioB;
1230
- this._z = z * ratioA + this._z * ratioB;
1231
- this._onChangeCallback();
1232
- return this;
1233
- }
1234
- slerpQuaternions(qa, qb, t) {
1235
- return this.copy(qa).slerp(qb, t);
1236
- }
1237
- random() {
1238
- const u1 = Math.random();
1239
- const sqrt1u1 = Math.sqrt(1 - u1);
1240
- const sqrtu1 = Math.sqrt(u1);
1241
- const u2 = 2 * Math.PI * Math.random();
1242
- const u3 = 2 * Math.PI * Math.random();
1243
- return this.set(
1244
- sqrt1u1 * Math.cos(u2),
1245
- sqrtu1 * Math.sin(u3),
1246
- sqrtu1 * Math.cos(u3),
1247
- sqrt1u1 * Math.sin(u2)
1248
- );
1249
- }
1250
- equals(quaternion) {
1251
- return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;
1252
- }
1253
- fromArray(array, offset = 0) {
1254
- this._x = array[offset];
1255
- this._y = array[offset + 1];
1256
- this._z = array[offset + 2];
1257
- this._w = array[offset + 3];
1258
- this._onChangeCallback();
1259
- return this;
1260
- }
1261
- toArray(array = [], offset = 0) {
1262
- array[offset] = this._x;
1263
- array[offset + 1] = this._y;
1264
- array[offset + 2] = this._z;
1265
- array[offset + 3] = this._w;
1266
- return array;
1267
- }
1268
- fromBufferAttribute(attribute, index) {
1269
- this._x = attribute.getX(index);
1270
- this._y = attribute.getY(index);
1271
- this._z = attribute.getZ(index);
1272
- this._w = attribute.getW(index);
1273
- this._onChangeCallback();
1274
- return this;
1275
- }
1276
- toJSON() {
1277
- return this.toArray();
1278
- }
1279
- _onChange(callback) {
1280
- this._onChangeCallback = callback;
1281
- return this;
1282
- }
1283
- _onChangeCallback() {
1284
- }
1285
- *[Symbol.iterator]() {
1286
- yield this._x;
1287
- yield this._y;
1288
- yield this._z;
1289
- yield this._w;
1290
- }
1291
- }
1292
- const WebGLCoordinateSystem = 2e3;
1293
- const WebGPUCoordinateSystem = 2001;
1294
- class Vector3 {
1295
- constructor(x = 0, y = 0, z = 0) {
1296
- Vector3.prototype.isVector3 = true;
1297
- this.x = x;
1298
- this.y = y;
1299
- this.z = z;
1300
- }
1301
- set(x, y, z) {
1302
- if (z === void 0) z = this.z;
1303
- this.x = x;
1304
- this.y = y;
1305
- this.z = z;
1306
- return this;
1307
- }
1308
- setScalar(scalar) {
1309
- this.x = scalar;
1310
- this.y = scalar;
1311
- this.z = scalar;
1312
- return this;
1313
- }
1314
- setX(x) {
1315
- this.x = x;
1316
- return this;
1317
- }
1318
- setY(y) {
1319
- this.y = y;
1320
- return this;
1321
- }
1322
- setZ(z) {
1323
- this.z = z;
1324
- return this;
1325
- }
1326
- setComponent(index, value) {
1327
- switch (index) {
1328
- case 0:
1329
- this.x = value;
1330
- break;
1331
- case 1:
1332
- this.y = value;
1333
- break;
1334
- case 2:
1335
- this.z = value;
1336
- break;
1337
- default:
1338
- throw new Error("index is out of range: " + index);
1339
- }
1340
- return this;
1341
- }
1342
- getComponent(index) {
1343
- switch (index) {
1344
- case 0:
1345
- return this.x;
1346
- case 1:
1347
- return this.y;
1348
- case 2:
1349
- return this.z;
1350
- default:
1351
- throw new Error("index is out of range: " + index);
1352
- }
1353
- }
1354
- clone() {
1355
- return new this.constructor(this.x, this.y, this.z);
1356
- }
1357
- copy(v) {
1358
- this.x = v.x;
1359
- this.y = v.y;
1360
- this.z = v.z;
1361
- return this;
1362
- }
1363
- add(v) {
1364
- this.x += v.x;
1365
- this.y += v.y;
1366
- this.z += v.z;
1367
- return this;
1368
- }
1369
- addScalar(s) {
1370
- this.x += s;
1371
- this.y += s;
1372
- this.z += s;
1373
- return this;
1374
- }
1375
- addVectors(a, b) {
1376
- this.x = a.x + b.x;
1377
- this.y = a.y + b.y;
1378
- this.z = a.z + b.z;
1379
- return this;
1380
- }
1381
- addScaledVector(v, s) {
1382
- this.x += v.x * s;
1383
- this.y += v.y * s;
1384
- this.z += v.z * s;
1385
- return this;
1386
- }
1387
- sub(v) {
1388
- this.x -= v.x;
1389
- this.y -= v.y;
1390
- this.z -= v.z;
1391
- return this;
1392
- }
1393
- subScalar(s) {
1394
- this.x -= s;
1395
- this.y -= s;
1396
- this.z -= s;
1397
- return this;
1398
- }
1399
- subVectors(a, b) {
1400
- this.x = a.x - b.x;
1401
- this.y = a.y - b.y;
1402
- this.z = a.z - b.z;
1403
- return this;
1404
- }
1405
- multiply(v) {
1406
- this.x *= v.x;
1407
- this.y *= v.y;
1408
- this.z *= v.z;
1409
- return this;
1410
- }
1411
- multiplyScalar(scalar) {
1412
- this.x *= scalar;
1413
- this.y *= scalar;
1414
- this.z *= scalar;
1415
- return this;
1416
- }
1417
- multiplyVectors(a, b) {
1418
- this.x = a.x * b.x;
1419
- this.y = a.y * b.y;
1420
- this.z = a.z * b.z;
1421
- return this;
1422
- }
1423
- applyEuler(euler) {
1424
- return this.applyQuaternion(_quaternion$1.setFromEuler(euler));
1425
- }
1426
- applyAxisAngle(axis, angle) {
1427
- return this.applyQuaternion(_quaternion$1.setFromAxisAngle(axis, angle));
1428
- }
1429
- applyMatrix3(m) {
1430
- const x = this.x, y = this.y, z = this.z;
1431
- const e = m.elements;
1432
- this.x = e[0] * x + e[3] * y + e[6] * z;
1433
- this.y = e[1] * x + e[4] * y + e[7] * z;
1434
- this.z = e[2] * x + e[5] * y + e[8] * z;
1435
- return this;
1436
- }
1437
- applyNormalMatrix(m) {
1438
- return this.applyMatrix3(m).normalize();
1439
- }
1440
- applyMatrix4(m) {
1441
- const x = this.x, y = this.y, z = this.z;
1442
- const e = m.elements;
1443
- const w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
1444
- this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
1445
- this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
1446
- this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
1447
- return this;
1448
- }
1449
- applyQuaternion(q) {
1450
- const vx = this.x, vy = this.y, vz = this.z;
1451
- const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
1452
- const tx = 2 * (qy * vz - qz * vy);
1453
- const ty = 2 * (qz * vx - qx * vz);
1454
- const tz = 2 * (qx * vy - qy * vx);
1455
- this.x = vx + qw * tx + qy * tz - qz * ty;
1456
- this.y = vy + qw * ty + qz * tx - qx * tz;
1457
- this.z = vz + qw * tz + qx * ty - qy * tx;
1458
- return this;
1459
- }
1460
- project(camera) {
1461
- return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
1462
- }
1463
- unproject(camera) {
1464
- return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
1465
- }
1466
- transformDirection(m) {
1467
- const x = this.x, y = this.y, z = this.z;
1468
- const e = m.elements;
1469
- this.x = e[0] * x + e[4] * y + e[8] * z;
1470
- this.y = e[1] * x + e[5] * y + e[9] * z;
1471
- this.z = e[2] * x + e[6] * y + e[10] * z;
1472
- return this.normalize();
1473
- }
1474
- divide(v) {
1475
- this.x /= v.x;
1476
- this.y /= v.y;
1477
- this.z /= v.z;
1478
- return this;
1479
- }
1480
- divideScalar(scalar) {
1481
- return this.multiplyScalar(1 / scalar);
1482
- }
1483
- min(v) {
1484
- this.x = Math.min(this.x, v.x);
1485
- this.y = Math.min(this.y, v.y);
1486
- this.z = Math.min(this.z, v.z);
1487
- return this;
1488
- }
1489
- max(v) {
1490
- this.x = Math.max(this.x, v.x);
1491
- this.y = Math.max(this.y, v.y);
1492
- this.z = Math.max(this.z, v.z);
1493
- return this;
1494
- }
1495
- clamp(min, max) {
1496
- this.x = Math.max(min.x, Math.min(max.x, this.x));
1497
- this.y = Math.max(min.y, Math.min(max.y, this.y));
1498
- this.z = Math.max(min.z, Math.min(max.z, this.z));
1499
- return this;
1500
- }
1501
- clampScalar(minVal, maxVal) {
1502
- this.x = Math.max(minVal, Math.min(maxVal, this.x));
1503
- this.y = Math.max(minVal, Math.min(maxVal, this.y));
1504
- this.z = Math.max(minVal, Math.min(maxVal, this.z));
1505
- return this;
1506
- }
1507
- clampLength(min, max) {
1508
- const length = this.length();
1509
- return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
1510
- }
1511
- floor() {
1512
- this.x = Math.floor(this.x);
1513
- this.y = Math.floor(this.y);
1514
- this.z = Math.floor(this.z);
1515
- return this;
1516
- }
1517
- ceil() {
1518
- this.x = Math.ceil(this.x);
1519
- this.y = Math.ceil(this.y);
1520
- this.z = Math.ceil(this.z);
1521
- return this;
1522
- }
1523
- round() {
1524
- this.x = Math.round(this.x);
1525
- this.y = Math.round(this.y);
1526
- this.z = Math.round(this.z);
1527
- return this;
1528
- }
1529
- roundToZero() {
1530
- this.x = Math.trunc(this.x);
1531
- this.y = Math.trunc(this.y);
1532
- this.z = Math.trunc(this.z);
1533
- return this;
1534
- }
1535
- negate() {
1536
- this.x = -this.x;
1537
- this.y = -this.y;
1538
- this.z = -this.z;
1539
- return this;
1540
- }
1541
- dot(v) {
1542
- return this.x * v.x + this.y * v.y + this.z * v.z;
1543
- }
1544
- // TODO lengthSquared?
1545
- lengthSq() {
1546
- return this.x * this.x + this.y * this.y + this.z * this.z;
1547
- }
1548
- length() {
1549
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
1550
- }
1551
- manhattanLength() {
1552
- return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
1553
- }
1554
- normalize() {
1555
- return this.divideScalar(this.length() || 1);
1556
- }
1557
- setLength(length) {
1558
- return this.normalize().multiplyScalar(length);
1559
- }
1560
- lerp(v, alpha) {
1561
- this.x += (v.x - this.x) * alpha;
1562
- this.y += (v.y - this.y) * alpha;
1563
- this.z += (v.z - this.z) * alpha;
1564
- return this;
1565
- }
1566
- lerpVectors(v1, v2, alpha) {
1567
- this.x = v1.x + (v2.x - v1.x) * alpha;
1568
- this.y = v1.y + (v2.y - v1.y) * alpha;
1569
- this.z = v1.z + (v2.z - v1.z) * alpha;
1570
- return this;
1571
- }
1572
- cross(v) {
1573
- return this.crossVectors(this, v);
1574
- }
1575
- crossVectors(a, b) {
1576
- const ax = a.x, ay = a.y, az = a.z;
1577
- const bx = b.x, by = b.y, bz = b.z;
1578
- this.x = ay * bz - az * by;
1579
- this.y = az * bx - ax * bz;
1580
- this.z = ax * by - ay * bx;
1581
- return this;
1582
- }
1583
- projectOnVector(v) {
1584
- const denominator = v.lengthSq();
1585
- if (denominator === 0) return this.set(0, 0, 0);
1586
- const scalar = v.dot(this) / denominator;
1587
- return this.copy(v).multiplyScalar(scalar);
1588
- }
1589
- projectOnPlane(planeNormal) {
1590
- _vector.copy(this).projectOnVector(planeNormal);
1591
- return this.sub(_vector);
1592
- }
1593
- reflect(normal) {
1594
- return this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal)));
1595
- }
1596
- angleTo(v) {
1597
- const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
1598
- if (denominator === 0) return Math.PI / 2;
1599
- const theta = this.dot(v) / denominator;
1600
- return Math.acos(clamp(theta, -1, 1));
1601
- }
1602
- distanceTo(v) {
1603
- return Math.sqrt(this.distanceToSquared(v));
1604
- }
1605
- distanceToSquared(v) {
1606
- const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
1607
- return dx * dx + dy * dy + dz * dz;
1608
- }
1609
- manhattanDistanceTo(v) {
1610
- return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
1611
- }
1612
- setFromSpherical(s) {
1613
- return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
1614
- }
1615
- setFromSphericalCoords(radius, phi, theta) {
1616
- const sinPhiRadius = Math.sin(phi) * radius;
1617
- this.x = sinPhiRadius * Math.sin(theta);
1618
- this.y = Math.cos(phi) * radius;
1619
- this.z = sinPhiRadius * Math.cos(theta);
1620
- return this;
1621
- }
1622
- setFromCylindrical(c) {
1623
- return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
1624
- }
1625
- setFromCylindricalCoords(radius, theta, y) {
1626
- this.x = radius * Math.sin(theta);
1627
- this.y = y;
1628
- this.z = radius * Math.cos(theta);
1629
- return this;
1630
- }
1631
- setFromMatrixPosition(m) {
1632
- const e = m.elements;
1633
- this.x = e[12];
1634
- this.y = e[13];
1635
- this.z = e[14];
1636
- return this;
1637
- }
1638
- setFromMatrixScale(m) {
1639
- const sx = this.setFromMatrixColumn(m, 0).length();
1640
- const sy = this.setFromMatrixColumn(m, 1).length();
1641
- const sz = this.setFromMatrixColumn(m, 2).length();
1642
- this.x = sx;
1643
- this.y = sy;
1644
- this.z = sz;
1645
- return this;
1646
- }
1647
- setFromMatrixColumn(m, index) {
1648
- return this.fromArray(m.elements, index * 4);
1649
- }
1650
- setFromMatrix3Column(m, index) {
1651
- return this.fromArray(m.elements, index * 3);
1652
- }
1653
- setFromEuler(e) {
1654
- this.x = e._x;
1655
- this.y = e._y;
1656
- this.z = e._z;
1657
- return this;
1658
- }
1659
- setFromColor(c) {
1660
- this.x = c.r;
1661
- this.y = c.g;
1662
- this.z = c.b;
1663
- return this;
1664
- }
1665
- equals(v) {
1666
- return v.x === this.x && v.y === this.y && v.z === this.z;
1667
- }
1668
- fromArray(array, offset = 0) {
1669
- this.x = array[offset];
1670
- this.y = array[offset + 1];
1671
- this.z = array[offset + 2];
1672
- return this;
1673
- }
1674
- toArray(array = [], offset = 0) {
1675
- array[offset] = this.x;
1676
- array[offset + 1] = this.y;
1677
- array[offset + 2] = this.z;
1678
- return array;
1679
- }
1680
- fromBufferAttribute(attribute, index) {
1681
- this.x = attribute.getX(index);
1682
- this.y = attribute.getY(index);
1683
- this.z = attribute.getZ(index);
1684
- return this;
1685
- }
1686
- random() {
1687
- this.x = Math.random();
1688
- this.y = Math.random();
1689
- this.z = Math.random();
1690
- return this;
1691
- }
1692
- randomDirection() {
1693
- const u = (Math.random() - 0.5) * 2;
1694
- const t = Math.random() * Math.PI * 2;
1695
- const f = Math.sqrt(1 - u ** 2);
1696
- this.x = f * Math.cos(t);
1697
- this.y = f * Math.sin(t);
1698
- this.z = u;
1699
- return this;
1700
- }
1701
- *[Symbol.iterator]() {
1702
- yield this.x;
1703
- yield this.y;
1704
- yield this.z;
1705
- }
1706
- }
1707
- const _vector = /* @__PURE__ */ new Vector3();
1708
- const _quaternion$1 = /* @__PURE__ */ new Quaternion();
1709
- class Matrix4 {
1710
- constructor(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
1711
- Matrix4.prototype.isMatrix4 = true;
1712
- this.elements = [
1713
- 1,
1714
- 0,
1715
- 0,
1716
- 0,
1717
- 0,
1718
- 1,
1719
- 0,
1720
- 0,
1721
- 0,
1722
- 0,
1723
- 1,
1724
- 0,
1725
- 0,
1726
- 0,
1727
- 0,
1728
- 1
1729
- ];
1730
- if (n11 !== void 0) {
1731
- this.set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44);
1732
- }
1733
- }
1734
- set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
1735
- const te = this.elements;
1736
- te[0] = n11;
1737
- te[4] = n12;
1738
- te[8] = n13;
1739
- te[12] = n14;
1740
- te[1] = n21;
1741
- te[5] = n22;
1742
- te[9] = n23;
1743
- te[13] = n24;
1744
- te[2] = n31;
1745
- te[6] = n32;
1746
- te[10] = n33;
1747
- te[14] = n34;
1748
- te[3] = n41;
1749
- te[7] = n42;
1750
- te[11] = n43;
1751
- te[15] = n44;
1752
- return this;
1753
- }
1754
- identity() {
1755
- this.set(
1756
- 1,
1757
- 0,
1758
- 0,
1759
- 0,
1760
- 0,
1761
- 1,
1762
- 0,
1763
- 0,
1764
- 0,
1765
- 0,
1766
- 1,
1767
- 0,
1768
- 0,
1769
- 0,
1770
- 0,
1771
- 1
1772
- );
1773
- return this;
1774
- }
1775
- clone() {
1776
- return new Matrix4().fromArray(this.elements);
1777
- }
1778
- copy(m) {
1779
- const te = this.elements;
1780
- const me = m.elements;
1781
- te[0] = me[0];
1782
- te[1] = me[1];
1783
- te[2] = me[2];
1784
- te[3] = me[3];
1785
- te[4] = me[4];
1786
- te[5] = me[5];
1787
- te[6] = me[6];
1788
- te[7] = me[7];
1789
- te[8] = me[8];
1790
- te[9] = me[9];
1791
- te[10] = me[10];
1792
- te[11] = me[11];
1793
- te[12] = me[12];
1794
- te[13] = me[13];
1795
- te[14] = me[14];
1796
- te[15] = me[15];
1797
- return this;
1798
- }
1799
- copyPosition(m) {
1800
- const te = this.elements, me = m.elements;
1801
- te[12] = me[12];
1802
- te[13] = me[13];
1803
- te[14] = me[14];
1804
- return this;
1805
- }
1806
- setFromMatrix3(m) {
1807
- const me = m.elements;
1808
- this.set(
1809
- me[0],
1810
- me[3],
1811
- me[6],
1812
- 0,
1813
- me[1],
1814
- me[4],
1815
- me[7],
1816
- 0,
1817
- me[2],
1818
- me[5],
1819
- me[8],
1820
- 0,
1821
- 0,
1822
- 0,
1823
- 0,
1824
- 1
1825
- );
1826
- return this;
1827
- }
1828
- extractBasis(xAxis, yAxis, zAxis) {
1829
- xAxis.setFromMatrixColumn(this, 0);
1830
- yAxis.setFromMatrixColumn(this, 1);
1831
- zAxis.setFromMatrixColumn(this, 2);
1832
- return this;
1833
- }
1834
- makeBasis(xAxis, yAxis, zAxis) {
1835
- this.set(
1836
- xAxis.x,
1837
- yAxis.x,
1838
- zAxis.x,
1839
- 0,
1840
- xAxis.y,
1841
- yAxis.y,
1842
- zAxis.y,
1843
- 0,
1844
- xAxis.z,
1845
- yAxis.z,
1846
- zAxis.z,
1847
- 0,
1848
- 0,
1849
- 0,
1850
- 0,
1851
- 1
1852
- );
1853
- return this;
1854
- }
1855
- extractRotation(m) {
1856
- const te = this.elements;
1857
- const me = m.elements;
1858
- const scaleX = 1 / _v1.setFromMatrixColumn(m, 0).length();
1859
- const scaleY = 1 / _v1.setFromMatrixColumn(m, 1).length();
1860
- const scaleZ = 1 / _v1.setFromMatrixColumn(m, 2).length();
1861
- te[0] = me[0] * scaleX;
1862
- te[1] = me[1] * scaleX;
1863
- te[2] = me[2] * scaleX;
1864
- te[3] = 0;
1865
- te[4] = me[4] * scaleY;
1866
- te[5] = me[5] * scaleY;
1867
- te[6] = me[6] * scaleY;
1868
- te[7] = 0;
1869
- te[8] = me[8] * scaleZ;
1870
- te[9] = me[9] * scaleZ;
1871
- te[10] = me[10] * scaleZ;
1872
- te[11] = 0;
1873
- te[12] = 0;
1874
- te[13] = 0;
1875
- te[14] = 0;
1876
- te[15] = 1;
1877
- return this;
1878
- }
1879
- makeRotationFromEuler(euler) {
1880
- const te = this.elements;
1881
- const x = euler.x, y = euler.y, z = euler.z;
1882
- const a = Math.cos(x), b = Math.sin(x);
1883
- const c = Math.cos(y), d = Math.sin(y);
1884
- const e = Math.cos(z), f = Math.sin(z);
1885
- if (euler.order === "XYZ") {
1886
- const ae = a * e, af = a * f, be = b * e, bf = b * f;
1887
- te[0] = c * e;
1888
- te[4] = -c * f;
1889
- te[8] = d;
1890
- te[1] = af + be * d;
1891
- te[5] = ae - bf * d;
1892
- te[9] = -b * c;
1893
- te[2] = bf - ae * d;
1894
- te[6] = be + af * d;
1895
- te[10] = a * c;
1896
- } else if (euler.order === "YXZ") {
1897
- const ce = c * e, cf = c * f, de = d * e, df = d * f;
1898
- te[0] = ce + df * b;
1899
- te[4] = de * b - cf;
1900
- te[8] = a * d;
1901
- te[1] = a * f;
1902
- te[5] = a * e;
1903
- te[9] = -b;
1904
- te[2] = cf * b - de;
1905
- te[6] = df + ce * b;
1906
- te[10] = a * c;
1907
- } else if (euler.order === "ZXY") {
1908
- const ce = c * e, cf = c * f, de = d * e, df = d * f;
1909
- te[0] = ce - df * b;
1910
- te[4] = -a * f;
1911
- te[8] = de + cf * b;
1912
- te[1] = cf + de * b;
1913
- te[5] = a * e;
1914
- te[9] = df - ce * b;
1915
- te[2] = -a * d;
1916
- te[6] = b;
1917
- te[10] = a * c;
1918
- } else if (euler.order === "ZYX") {
1919
- const ae = a * e, af = a * f, be = b * e, bf = b * f;
1920
- te[0] = c * e;
1921
- te[4] = be * d - af;
1922
- te[8] = ae * d + bf;
1923
- te[1] = c * f;
1924
- te[5] = bf * d + ae;
1925
- te[9] = af * d - be;
1926
- te[2] = -d;
1927
- te[6] = b * c;
1928
- te[10] = a * c;
1929
- } else if (euler.order === "YZX") {
1930
- const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
1931
- te[0] = c * e;
1932
- te[4] = bd - ac * f;
1933
- te[8] = bc * f + ad;
1934
- te[1] = f;
1935
- te[5] = a * e;
1936
- te[9] = -b * e;
1937
- te[2] = -d * e;
1938
- te[6] = ad * f + bc;
1939
- te[10] = ac - bd * f;
1940
- } else if (euler.order === "XZY") {
1941
- const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
1942
- te[0] = c * e;
1943
- te[4] = -f;
1944
- te[8] = d * e;
1945
- te[1] = ac * f + bd;
1946
- te[5] = a * e;
1947
- te[9] = ad * f - bc;
1948
- te[2] = bc * f - ad;
1949
- te[6] = b * e;
1950
- te[10] = bd * f + ac;
1951
- }
1952
- te[3] = 0;
1953
- te[7] = 0;
1954
- te[11] = 0;
1955
- te[12] = 0;
1956
- te[13] = 0;
1957
- te[14] = 0;
1958
- te[15] = 1;
1959
- return this;
1960
- }
1961
- makeRotationFromQuaternion(q) {
1962
- return this.compose(_zero, q, _one);
1963
- }
1964
- lookAt(eye, target, up) {
1965
- const te = this.elements;
1966
- _z.subVectors(eye, target);
1967
- if (_z.lengthSq() === 0) {
1968
- _z.z = 1;
1969
- }
1970
- _z.normalize();
1971
- _x.crossVectors(up, _z);
1972
- if (_x.lengthSq() === 0) {
1973
- if (Math.abs(up.z) === 1) {
1974
- _z.x += 1e-4;
1975
- } else {
1976
- _z.z += 1e-4;
1977
- }
1978
- _z.normalize();
1979
- _x.crossVectors(up, _z);
1980
- }
1981
- _x.normalize();
1982
- _y.crossVectors(_z, _x);
1983
- te[0] = _x.x;
1984
- te[4] = _y.x;
1985
- te[8] = _z.x;
1986
- te[1] = _x.y;
1987
- te[5] = _y.y;
1988
- te[9] = _z.y;
1989
- te[2] = _x.z;
1990
- te[6] = _y.z;
1991
- te[10] = _z.z;
1992
- return this;
1993
- }
1994
- multiply(m) {
1995
- return this.multiplyMatrices(this, m);
1996
- }
1997
- premultiply(m) {
1998
- return this.multiplyMatrices(m, this);
1999
- }
2000
- multiplyMatrices(a, b) {
2001
- const ae = a.elements;
2002
- const be = b.elements;
2003
- const te = this.elements;
2004
- const a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
2005
- const a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
2006
- const a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
2007
- const a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
2008
- const b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
2009
- const b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
2010
- const b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
2011
- const b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
2012
- te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
2013
- te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
2014
- te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
2015
- te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
2016
- te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
2017
- te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
2018
- te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
2019
- te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
2020
- te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
2021
- te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
2022
- te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
2023
- te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
2024
- te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
2025
- te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
2026
- te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
2027
- te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
2028
- return this;
2029
- }
2030
- multiplyScalar(s) {
2031
- const te = this.elements;
2032
- te[0] *= s;
2033
- te[4] *= s;
2034
- te[8] *= s;
2035
- te[12] *= s;
2036
- te[1] *= s;
2037
- te[5] *= s;
2038
- te[9] *= s;
2039
- te[13] *= s;
2040
- te[2] *= s;
2041
- te[6] *= s;
2042
- te[10] *= s;
2043
- te[14] *= s;
2044
- te[3] *= s;
2045
- te[7] *= s;
2046
- te[11] *= s;
2047
- te[15] *= s;
2048
- return this;
2049
- }
2050
- determinant() {
2051
- const te = this.elements;
2052
- const n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
2053
- const n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
2054
- const n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
2055
- const n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
2056
- return n41 * (+n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34) + n42 * (+n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 - n13 * n21 * n34 + n13 * n24 * n31 - n14 * n23 * n31) + n43 * (+n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 + n12 * n21 * n34 + n14 * n22 * n31 - n12 * n24 * n31) + n44 * (-n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 + n13 * n21 * n32 - n12 * n21 * n33 + n12 * n23 * n31);
2057
- }
2058
- transpose() {
2059
- const te = this.elements;
2060
- let tmp;
2061
- tmp = te[1];
2062
- te[1] = te[4];
2063
- te[4] = tmp;
2064
- tmp = te[2];
2065
- te[2] = te[8];
2066
- te[8] = tmp;
2067
- tmp = te[6];
2068
- te[6] = te[9];
2069
- te[9] = tmp;
2070
- tmp = te[3];
2071
- te[3] = te[12];
2072
- te[12] = tmp;
2073
- tmp = te[7];
2074
- te[7] = te[13];
2075
- te[13] = tmp;
2076
- tmp = te[11];
2077
- te[11] = te[14];
2078
- te[14] = tmp;
2079
- return this;
2080
- }
2081
- setPosition(x, y, z) {
2082
- const te = this.elements;
2083
- if (x.isVector3) {
2084
- te[12] = x.x;
2085
- te[13] = x.y;
2086
- te[14] = x.z;
2087
- } else {
2088
- te[12] = x;
2089
- te[13] = y;
2090
- te[14] = z;
2091
- }
2092
- return this;
2093
- }
2094
- invert() {
2095
- const te = this.elements, n11 = te[0], n21 = te[1], n31 = te[2], n41 = te[3], n12 = te[4], n22 = te[5], n32 = te[6], n42 = te[7], n13 = te[8], n23 = te[9], n33 = te[10], n43 = te[11], n14 = te[12], n24 = te[13], n34 = te[14], n44 = te[15], t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44, t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44, t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44, t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
2096
- const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
2097
- if (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
2098
- const detInv = 1 / det;
2099
- te[0] = t11 * detInv;
2100
- te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
2101
- te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
2102
- te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
2103
- te[4] = t12 * detInv;
2104
- te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
2105
- te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
2106
- te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
2107
- te[8] = t13 * detInv;
2108
- te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
2109
- te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
2110
- te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
2111
- te[12] = t14 * detInv;
2112
- te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
2113
- te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
2114
- te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
2115
- return this;
2116
- }
2117
- scale(v) {
2118
- const te = this.elements;
2119
- const x = v.x, y = v.y, z = v.z;
2120
- te[0] *= x;
2121
- te[4] *= y;
2122
- te[8] *= z;
2123
- te[1] *= x;
2124
- te[5] *= y;
2125
- te[9] *= z;
2126
- te[2] *= x;
2127
- te[6] *= y;
2128
- te[10] *= z;
2129
- te[3] *= x;
2130
- te[7] *= y;
2131
- te[11] *= z;
2132
- return this;
2133
- }
2134
- getMaxScaleOnAxis() {
2135
- const te = this.elements;
2136
- const scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
2137
- const scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
2138
- const scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
2139
- return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
2140
- }
2141
- makeTranslation(x, y, z) {
2142
- if (x.isVector3) {
2143
- this.set(
2144
- 1,
2145
- 0,
2146
- 0,
2147
- x.x,
2148
- 0,
2149
- 1,
2150
- 0,
2151
- x.y,
2152
- 0,
2153
- 0,
2154
- 1,
2155
- x.z,
2156
- 0,
2157
- 0,
2158
- 0,
2159
- 1
2160
- );
2161
- } else {
2162
- this.set(
2163
- 1,
2164
- 0,
2165
- 0,
2166
- x,
2167
- 0,
2168
- 1,
2169
- 0,
2170
- y,
2171
- 0,
2172
- 0,
2173
- 1,
2174
- z,
2175
- 0,
2176
- 0,
2177
- 0,
2178
- 1
2179
- );
2180
- }
2181
- return this;
2182
- }
2183
- makeRotationX(theta) {
2184
- const c = Math.cos(theta), s = Math.sin(theta);
2185
- this.set(
2186
- 1,
2187
- 0,
2188
- 0,
2189
- 0,
2190
- 0,
2191
- c,
2192
- -s,
2193
- 0,
2194
- 0,
2195
- s,
2196
- c,
2197
- 0,
2198
- 0,
2199
- 0,
2200
- 0,
2201
- 1
2202
- );
2203
- return this;
2204
- }
2205
- makeRotationY(theta) {
2206
- const c = Math.cos(theta), s = Math.sin(theta);
2207
- this.set(
2208
- c,
2209
- 0,
2210
- s,
2211
- 0,
2212
- 0,
2213
- 1,
2214
- 0,
2215
- 0,
2216
- -s,
2217
- 0,
2218
- c,
2219
- 0,
2220
- 0,
2221
- 0,
2222
- 0,
2223
- 1
2224
- );
2225
- return this;
2226
- }
2227
- makeRotationZ(theta) {
2228
- const c = Math.cos(theta), s = Math.sin(theta);
2229
- this.set(
2230
- c,
2231
- -s,
2232
- 0,
2233
- 0,
2234
- s,
2235
- c,
2236
- 0,
2237
- 0,
2238
- 0,
2239
- 0,
2240
- 1,
2241
- 0,
2242
- 0,
2243
- 0,
2244
- 0,
2245
- 1
2246
- );
2247
- return this;
2248
- }
2249
- makeRotationAxis(axis, angle) {
2250
- const c = Math.cos(angle);
2251
- const s = Math.sin(angle);
2252
- const t = 1 - c;
2253
- const x = axis.x, y = axis.y, z = axis.z;
2254
- const tx = t * x, ty = t * y;
2255
- this.set(
2256
- tx * x + c,
2257
- tx * y - s * z,
2258
- tx * z + s * y,
2259
- 0,
2260
- tx * y + s * z,
2261
- ty * y + c,
2262
- ty * z - s * x,
2263
- 0,
2264
- tx * z - s * y,
2265
- ty * z + s * x,
2266
- t * z * z + c,
2267
- 0,
2268
- 0,
2269
- 0,
2270
- 0,
2271
- 1
2272
- );
2273
- return this;
2274
- }
2275
- makeScale(x, y, z) {
2276
- this.set(
2277
- x,
2278
- 0,
2279
- 0,
2280
- 0,
2281
- 0,
2282
- y,
2283
- 0,
2284
- 0,
2285
- 0,
2286
- 0,
2287
- z,
2288
- 0,
2289
- 0,
2290
- 0,
2291
- 0,
2292
- 1
2293
- );
2294
- return this;
2295
- }
2296
- makeShear(xy, xz, yx, yz, zx, zy) {
2297
- this.set(
2298
- 1,
2299
- yx,
2300
- zx,
2301
- 0,
2302
- xy,
2303
- 1,
2304
- zy,
2305
- 0,
2306
- xz,
2307
- yz,
2308
- 1,
2309
- 0,
2310
- 0,
2311
- 0,
2312
- 0,
2313
- 1
2314
- );
2315
- return this;
2316
- }
2317
- compose(position, quaternion, scale) {
2318
- const te = this.elements;
2319
- const x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
2320
- const x2 = x + x, y2 = y + y, z2 = z + z;
2321
- const xx = x * x2, xy = x * y2, xz = x * z2;
2322
- const yy = y * y2, yz = y * z2, zz = z * z2;
2323
- const wx = w * x2, wy = w * y2, wz = w * z2;
2324
- const sx = scale.x, sy = scale.y, sz = scale.z;
2325
- te[0] = (1 - (yy + zz)) * sx;
2326
- te[1] = (xy + wz) * sx;
2327
- te[2] = (xz - wy) * sx;
2328
- te[3] = 0;
2329
- te[4] = (xy - wz) * sy;
2330
- te[5] = (1 - (xx + zz)) * sy;
2331
- te[6] = (yz + wx) * sy;
2332
- te[7] = 0;
2333
- te[8] = (xz + wy) * sz;
2334
- te[9] = (yz - wx) * sz;
2335
- te[10] = (1 - (xx + yy)) * sz;
2336
- te[11] = 0;
2337
- te[12] = position.x;
2338
- te[13] = position.y;
2339
- te[14] = position.z;
2340
- te[15] = 1;
2341
- return this;
2342
- }
2343
- decompose(position, quaternion, scale) {
2344
- const te = this.elements;
2345
- let sx = _v1.set(te[0], te[1], te[2]).length();
2346
- const sy = _v1.set(te[4], te[5], te[6]).length();
2347
- const sz = _v1.set(te[8], te[9], te[10]).length();
2348
- const det = this.determinant();
2349
- if (det < 0) sx = -sx;
2350
- position.x = te[12];
2351
- position.y = te[13];
2352
- position.z = te[14];
2353
- _m1.copy(this);
2354
- const invSX = 1 / sx;
2355
- const invSY = 1 / sy;
2356
- const invSZ = 1 / sz;
2357
- _m1.elements[0] *= invSX;
2358
- _m1.elements[1] *= invSX;
2359
- _m1.elements[2] *= invSX;
2360
- _m1.elements[4] *= invSY;
2361
- _m1.elements[5] *= invSY;
2362
- _m1.elements[6] *= invSY;
2363
- _m1.elements[8] *= invSZ;
2364
- _m1.elements[9] *= invSZ;
2365
- _m1.elements[10] *= invSZ;
2366
- quaternion.setFromRotationMatrix(_m1);
2367
- scale.x = sx;
2368
- scale.y = sy;
2369
- scale.z = sz;
2370
- return this;
2371
- }
2372
- makePerspective(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem) {
2373
- const te = this.elements;
2374
- const x = 2 * near / (right - left);
2375
- const y = 2 * near / (top - bottom);
2376
- const a = (right + left) / (right - left);
2377
- const b = (top + bottom) / (top - bottom);
2378
- let c, d;
2379
- if (coordinateSystem === WebGLCoordinateSystem) {
2380
- c = -(far + near) / (far - near);
2381
- d = -2 * far * near / (far - near);
2382
- } else if (coordinateSystem === WebGPUCoordinateSystem) {
2383
- c = -far / (far - near);
2384
- d = -far * near / (far - near);
2385
- } else {
2386
- throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + coordinateSystem);
2387
- }
2388
- te[0] = x;
2389
- te[4] = 0;
2390
- te[8] = a;
2391
- te[12] = 0;
2392
- te[1] = 0;
2393
- te[5] = y;
2394
- te[9] = b;
2395
- te[13] = 0;
2396
- te[2] = 0;
2397
- te[6] = 0;
2398
- te[10] = c;
2399
- te[14] = d;
2400
- te[3] = 0;
2401
- te[7] = 0;
2402
- te[11] = -1;
2403
- te[15] = 0;
2404
- return this;
2405
- }
2406
- makeOrthographic(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem) {
2407
- const te = this.elements;
2408
- const w = 1 / (right - left);
2409
- const h = 1 / (top - bottom);
2410
- const p = 1 / (far - near);
2411
- const x = (right + left) * w;
2412
- const y = (top + bottom) * h;
2413
- let z, zInv;
2414
- if (coordinateSystem === WebGLCoordinateSystem) {
2415
- z = (far + near) * p;
2416
- zInv = -2 * p;
2417
- } else if (coordinateSystem === WebGPUCoordinateSystem) {
2418
- z = near * p;
2419
- zInv = -1 * p;
2420
- } else {
2421
- throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + coordinateSystem);
2422
- }
2423
- te[0] = 2 * w;
2424
- te[4] = 0;
2425
- te[8] = 0;
2426
- te[12] = -x;
2427
- te[1] = 0;
2428
- te[5] = 2 * h;
2429
- te[9] = 0;
2430
- te[13] = -y;
2431
- te[2] = 0;
2432
- te[6] = 0;
2433
- te[10] = zInv;
2434
- te[14] = -z;
2435
- te[3] = 0;
2436
- te[7] = 0;
2437
- te[11] = 0;
2438
- te[15] = 1;
2439
- return this;
2440
- }
2441
- equals(matrix) {
2442
- const te = this.elements;
2443
- const me = matrix.elements;
2444
- for (let i = 0; i < 16; i++) {
2445
- if (te[i] !== me[i]) return false;
2446
- }
2447
- return true;
2448
- }
2449
- fromArray(array, offset = 0) {
2450
- for (let i = 0; i < 16; i++) {
2451
- this.elements[i] = array[i + offset];
2452
- }
2453
- return this;
2454
- }
2455
- toArray(array = [], offset = 0) {
2456
- const te = this.elements;
2457
- array[offset] = te[0];
2458
- array[offset + 1] = te[1];
2459
- array[offset + 2] = te[2];
2460
- array[offset + 3] = te[3];
2461
- array[offset + 4] = te[4];
2462
- array[offset + 5] = te[5];
2463
- array[offset + 6] = te[6];
2464
- array[offset + 7] = te[7];
2465
- array[offset + 8] = te[8];
2466
- array[offset + 9] = te[9];
2467
- array[offset + 10] = te[10];
2468
- array[offset + 11] = te[11];
2469
- array[offset + 12] = te[12];
2470
- array[offset + 13] = te[13];
2471
- array[offset + 14] = te[14];
2472
- array[offset + 15] = te[15];
2473
- return array;
2474
- }
2475
- }
2476
- const _v1 = /* @__PURE__ */ new Vector3();
2477
- const _m1 = /* @__PURE__ */ new Matrix4();
2478
- const _zero = /* @__PURE__ */ new Vector3(0, 0, 0);
2479
- const _one = /* @__PURE__ */ new Vector3(1, 1, 1);
2480
- const _x = /* @__PURE__ */ new Vector3();
2481
- const _y = /* @__PURE__ */ new Vector3();
2482
- const _z = /* @__PURE__ */ new Vector3();
2483
- const _matrix = /* @__PURE__ */ new Matrix4();
2484
- const _quaternion = /* @__PURE__ */ new Quaternion();
2485
- class Euler {
2486
- constructor(x = 0, y = 0, z = 0, order = Euler.DEFAULT_ORDER) {
2487
- this.isEuler = true;
2488
- this._x = x;
2489
- this._y = y;
2490
- this._z = z;
2491
- this._order = order;
2492
- }
2493
- get x() {
2494
- return this._x;
2495
- }
2496
- set x(value) {
2497
- this._x = value;
2498
- this._onChangeCallback();
2499
- }
2500
- get y() {
2501
- return this._y;
2502
- }
2503
- set y(value) {
2504
- this._y = value;
2505
- this._onChangeCallback();
2506
- }
2507
- get z() {
2508
- return this._z;
2509
- }
2510
- set z(value) {
2511
- this._z = value;
2512
- this._onChangeCallback();
2513
- }
2514
- get order() {
2515
- return this._order;
2516
- }
2517
- set order(value) {
2518
- this._order = value;
2519
- this._onChangeCallback();
2520
- }
2521
- set(x, y, z, order = this._order) {
2522
- this._x = x;
2523
- this._y = y;
2524
- this._z = z;
2525
- this._order = order;
2526
- this._onChangeCallback();
2527
- return this;
2528
- }
2529
- clone() {
2530
- return new this.constructor(this._x, this._y, this._z, this._order);
2531
- }
2532
- copy(euler) {
2533
- this._x = euler._x;
2534
- this._y = euler._y;
2535
- this._z = euler._z;
2536
- this._order = euler._order;
2537
- this._onChangeCallback();
2538
- return this;
2539
- }
2540
- setFromRotationMatrix(m, order = this._order, update = true) {
2541
- const te = m.elements;
2542
- const m11 = te[0], m12 = te[4], m13 = te[8];
2543
- const m21 = te[1], m22 = te[5], m23 = te[9];
2544
- const m31 = te[2], m32 = te[6], m33 = te[10];
2545
- switch (order) {
2546
- case "XYZ":
2547
- this._y = Math.asin(clamp(m13, -1, 1));
2548
- if (Math.abs(m13) < 0.9999999) {
2549
- this._x = Math.atan2(-m23, m33);
2550
- this._z = Math.atan2(-m12, m11);
2551
- } else {
2552
- this._x = Math.atan2(m32, m22);
2553
- this._z = 0;
2554
- }
2555
- break;
2556
- case "YXZ":
2557
- this._x = Math.asin(-clamp(m23, -1, 1));
2558
- if (Math.abs(m23) < 0.9999999) {
2559
- this._y = Math.atan2(m13, m33);
2560
- this._z = Math.atan2(m21, m22);
2561
- } else {
2562
- this._y = Math.atan2(-m31, m11);
2563
- this._z = 0;
2564
- }
2565
- break;
2566
- case "ZXY":
2567
- this._x = Math.asin(clamp(m32, -1, 1));
2568
- if (Math.abs(m32) < 0.9999999) {
2569
- this._y = Math.atan2(-m31, m33);
2570
- this._z = Math.atan2(-m12, m22);
2571
- } else {
2572
- this._y = 0;
2573
- this._z = Math.atan2(m21, m11);
2574
- }
2575
- break;
2576
- case "ZYX":
2577
- this._y = Math.asin(-clamp(m31, -1, 1));
2578
- if (Math.abs(m31) < 0.9999999) {
2579
- this._x = Math.atan2(m32, m33);
2580
- this._z = Math.atan2(m21, m11);
2581
- } else {
2582
- this._x = 0;
2583
- this._z = Math.atan2(-m12, m22);
2584
- }
2585
- break;
2586
- case "YZX":
2587
- this._z = Math.asin(clamp(m21, -1, 1));
2588
- if (Math.abs(m21) < 0.9999999) {
2589
- this._x = Math.atan2(-m23, m22);
2590
- this._y = Math.atan2(-m31, m11);
2591
- } else {
2592
- this._x = 0;
2593
- this._y = Math.atan2(m13, m33);
2594
- }
2595
- break;
2596
- case "XZY":
2597
- this._z = Math.asin(-clamp(m12, -1, 1));
2598
- if (Math.abs(m12) < 0.9999999) {
2599
- this._x = Math.atan2(m32, m22);
2600
- this._y = Math.atan2(m13, m11);
2601
- } else {
2602
- this._x = Math.atan2(-m23, m33);
2603
- this._y = 0;
2604
- }
2605
- break;
2606
- default:
2607
- console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + order);
2608
- }
2609
- this._order = order;
2610
- if (update === true) this._onChangeCallback();
2611
- return this;
2612
- }
2613
- setFromQuaternion(q, order, update) {
2614
- _matrix.makeRotationFromQuaternion(q);
2615
- return this.setFromRotationMatrix(_matrix, order, update);
2616
- }
2617
- setFromVector3(v, order = this._order) {
2618
- return this.set(v.x, v.y, v.z, order);
2619
- }
2620
- reorder(newOrder) {
2621
- _quaternion.setFromEuler(this);
2622
- return this.setFromQuaternion(_quaternion, newOrder);
2623
- }
2624
- equals(euler) {
2625
- return euler._x === this._x && euler._y === this._y && euler._z === this._z && euler._order === this._order;
2626
- }
2627
- fromArray(array) {
2628
- this._x = array[0];
2629
- this._y = array[1];
2630
- this._z = array[2];
2631
- if (array[3] !== void 0) this._order = array[3];
2632
- this._onChangeCallback();
2633
- return this;
2634
- }
2635
- toArray(array = [], offset = 0) {
2636
- array[offset] = this._x;
2637
- array[offset + 1] = this._y;
2638
- array[offset + 2] = this._z;
2639
- array[offset + 3] = this._order;
2640
- return array;
2641
- }
2642
- _onChange(callback) {
2643
- this._onChangeCallback = callback;
2644
- return this;
2645
- }
2646
- _onChangeCallback() {
2647
- }
2648
- *[Symbol.iterator]() {
2649
- yield this._x;
2650
- yield this._y;
2651
- yield this._z;
2652
- yield this._order;
2653
- }
2654
- }
2655
- Euler.DEFAULT_ORDER = "XYZ";
2656
909
  const blenderObjectTypes = {
2657
910
  empty: 0,
2658
911
  mesh: 1,
@@ -2739,11 +992,11 @@
2739
992
  obj.quaternion.set(object.quat[1], object.quat[3], -object.quat[2], object.quat[0]);
2740
993
  } else {
2741
994
  const order = eulerModes[object.rotmode] ?? "XYZ";
2742
- const quat = new three.Quaternion().setFromEuler(new Euler(object.rot[0], object.rot[1], object.rot[2], order.split("").reverse().join("")));
995
+ const quat = new threepipe.Quaternion().setFromEuler(new threepipe.Euler(object.rot[0], object.rot[1], object.rot[2], order.split("").reverse().join("")));
2743
996
  obj.quaternion.set(quat.x, quat.z, -quat.y, quat.w);
2744
997
  }
2745
998
  if (object.type === blenderObjectTypes.camera)
2746
- obj.quaternion.multiply(new three.Quaternion().setFromAxisAngle(new three.Vector3(1, 0, 0), -Math.PI / 2));
999
+ obj.quaternion.multiply(new threepipe.Quaternion().setFromAxisAngle(new threepipe.Vector3(1, 0, 0), -Math.PI / 2));
2747
1000
  obj.updateMatrix();
2748
1001
  if (obj.setDirty) obj.setDirty();
2749
1002
  }
@@ -2768,8 +1021,6 @@
2768
1021
  const objects = await createObjects(blend, ctx);
2769
1022
  const root = new threepipe.Object3D();
2770
1023
  root.add(...objects);
2771
- root.userData.autoScaled = true;
2772
- root.userData.autoCentered = true;
2773
1024
  blend.scene = root;
2774
1025
  return blend;
2775
1026
  }