viral-viewer-2 2.2.2 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,22 +82,30 @@ function workerFunction() {
82
82
  case 1:
83
83
  console.log('receive structural');
84
84
  progressStructuralGeometries(event.data.materials, event.data.data, (buffer, colorString, opacity) => {
85
+ const geometry = new BufferGeometry();
86
+ geometry.setAttribute("position", new BufferAttribute(buffer, 3));
87
+ geometry.computeVertexNormals();
85
88
  self.postMessage({
86
89
  type: 1,
87
90
  buffer: buffer,
88
91
  materialColorString: colorString,
89
92
  materialOpacity: opacity,
93
+ geometry: geometry
90
94
  });
91
95
  });
92
96
  break;
93
97
  case 2:
94
98
  console.log('receive none structural');
95
99
  progressNoneStructuralGeometries(event.data.materials, event.data.data, (buffer, colorString, opacity) => {
100
+ const geometry = new BufferGeometry();
101
+ geometry.setAttribute("position", new BufferAttribute(buffer, 3));
102
+ geometry.computeVertexNormals();
96
103
  self.postMessage({
97
104
  type: 1,
98
105
  buffer: buffer,
99
106
  materialColorString: colorString,
100
107
  materialOpacity: opacity,
108
+ geometry: geometry
101
109
  });
102
110
  });
103
111
  break;
@@ -106,166 +114,7 @@ function workerFunction() {
106
114
  }
107
115
  }, false);
108
116
  //#region Threejs Types
109
- const REVISION = '135';
110
- const CullFaceNone = 0;
111
- const CullFaceBack = 1;
112
- const CullFaceFront = 2;
113
- const PCFShadowMap = 1;
114
- const PCFSoftShadowMap = 2;
115
- const VSMShadowMap = 3;
116
- const FrontSide = 0;
117
- const BackSide = 1;
118
- const DoubleSide = 2;
119
- const FlatShading = 1;
120
- const NoBlending = 0;
121
- const NormalBlending = 1;
122
- const AdditiveBlending = 2;
123
- const SubtractiveBlending = 3;
124
- const MultiplyBlending = 4;
125
- const CustomBlending = 5;
126
- const AddEquation = 100;
127
- const SubtractEquation = 101;
128
- const ReverseSubtractEquation = 102;
129
- const MinEquation = 103;
130
- const MaxEquation = 104;
131
- const ZeroFactor = 200;
132
- const OneFactor = 201;
133
- const SrcColorFactor = 202;
134
- const OneMinusSrcColorFactor = 203;
135
- const SrcAlphaFactor = 204;
136
- const OneMinusSrcAlphaFactor = 205;
137
- const DstAlphaFactor = 206;
138
- const OneMinusDstAlphaFactor = 207;
139
- const DstColorFactor = 208;
140
- const OneMinusDstColorFactor = 209;
141
- const SrcAlphaSaturateFactor = 210;
142
- const NeverDepth = 0;
143
- const AlwaysDepth = 1;
144
- const LessDepth = 2;
145
- const LessEqualDepth = 3;
146
- const EqualDepth = 4;
147
- const GreaterEqualDepth = 5;
148
- const GreaterDepth = 6;
149
- const NotEqualDepth = 7;
150
- const MultiplyOperation = 0;
151
- const MixOperation = 1;
152
- const AddOperation = 2;
153
- const NoToneMapping = 0;
154
- const LinearToneMapping = 1;
155
- const ReinhardToneMapping = 2;
156
- const CineonToneMapping = 3;
157
- const ACESFilmicToneMapping = 4;
158
- const CustomToneMapping = 5;
159
- const UVMapping = 300;
160
- const CubeReflectionMapping = 301;
161
- const CubeRefractionMapping = 302;
162
- const EquirectangularReflectionMapping = 303;
163
- const EquirectangularRefractionMapping = 304;
164
- const CubeUVReflectionMapping = 306;
165
- const CubeUVRefractionMapping = 307;
166
- const RepeatWrapping = 1000;
167
- const ClampToEdgeWrapping = 1001;
168
- const MirroredRepeatWrapping = 1002;
169
- const NearestFilter = 1003;
170
- const NearestMipmapNearestFilter = 1004;
171
- const NearestMipmapLinearFilter = 1005;
172
- const LinearFilter = 1006;
173
- const LinearMipmapNearestFilter = 1007;
174
- const LinearMipmapLinearFilter = 1008;
175
- const UnsignedByteType = 1009;
176
- const ByteType = 1010;
177
- const ShortType = 1011;
178
- const UnsignedShortType = 1012;
179
- const IntType = 1013;
180
- const UnsignedIntType = 1014;
181
- const FloatType = 1015;
182
- const HalfFloatType = 1016;
183
- const UnsignedShort4444Type = 1017;
184
- const UnsignedShort5551Type = 1018;
185
- const UnsignedShort565Type = 1019;
186
- const UnsignedInt248Type = 1020;
187
- const AlphaFormat = 1021;
188
- const RGBFormat = 1022;
189
- const RGBAFormat = 1023;
190
- const LuminanceFormat = 1024;
191
- const LuminanceAlphaFormat = 1025;
192
- const RGBEFormat = RGBAFormat;
193
- const DepthFormat = 1026;
194
- const DepthStencilFormat = 1027;
195
- const RedFormat = 1028;
196
- const RedIntegerFormat = 1029;
197
- const RGFormat = 1030;
198
- const RGIntegerFormat = 1031;
199
- const RGBIntegerFormat = 1032;
200
- const RGBAIntegerFormat = 1033;
201
- const RGB_S3TC_DXT1_Format = 33776;
202
- const RGBA_S3TC_DXT1_Format = 33777;
203
- const RGBA_S3TC_DXT3_Format = 33778;
204
- const RGBA_S3TC_DXT5_Format = 33779;
205
- const RGB_PVRTC_4BPPV1_Format = 35840;
206
- const RGB_PVRTC_2BPPV1_Format = 35841;
207
- const RGBA_PVRTC_4BPPV1_Format = 35842;
208
- const RGBA_PVRTC_2BPPV1_Format = 35843;
209
- const RGB_ETC1_Format = 36196;
210
- const RGB_ETC2_Format = 37492;
211
- const RGBA_ETC2_EAC_Format = 37496;
212
- const RGBA_ASTC_4x4_Format = 37808;
213
- const RGBA_ASTC_5x4_Format = 37809;
214
- const RGBA_ASTC_5x5_Format = 37810;
215
- const RGBA_ASTC_6x5_Format = 37811;
216
- const RGBA_ASTC_6x6_Format = 37812;
217
- const RGBA_ASTC_8x5_Format = 37813;
218
- const RGBA_ASTC_8x6_Format = 37814;
219
- const RGBA_ASTC_8x8_Format = 37815;
220
- const RGBA_ASTC_10x5_Format = 37816;
221
- const RGBA_ASTC_10x6_Format = 37817;
222
- const RGBA_ASTC_10x8_Format = 37818;
223
- const RGBA_ASTC_10x10_Format = 37819;
224
- const RGBA_ASTC_12x10_Format = 37820;
225
- const RGBA_ASTC_12x12_Format = 37821;
226
- const RGBA_BPTC_Format = 36492;
227
- const SRGB8_ALPHA8_ASTC_4x4_Format = 37840;
228
- const SRGB8_ALPHA8_ASTC_5x4_Format = 37841;
229
- const SRGB8_ALPHA8_ASTC_5x5_Format = 37842;
230
- const SRGB8_ALPHA8_ASTC_6x5_Format = 37843;
231
- const SRGB8_ALPHA8_ASTC_6x6_Format = 37844;
232
- const SRGB8_ALPHA8_ASTC_8x5_Format = 37845;
233
- const SRGB8_ALPHA8_ASTC_8x6_Format = 37846;
234
- const SRGB8_ALPHA8_ASTC_8x8_Format = 37847;
235
- const SRGB8_ALPHA8_ASTC_10x5_Format = 37848;
236
- const SRGB8_ALPHA8_ASTC_10x6_Format = 37849;
237
- const SRGB8_ALPHA8_ASTC_10x8_Format = 37850;
238
- const SRGB8_ALPHA8_ASTC_10x10_Format = 37851;
239
- const SRGB8_ALPHA8_ASTC_12x10_Format = 37852;
240
- const SRGB8_ALPHA8_ASTC_12x12_Format = 37853;
241
- const LoopOnce = 2200;
242
- const LoopRepeat = 2201;
243
- const LoopPingPong = 2202;
244
- const InterpolateDiscrete = 2300;
245
- const InterpolateLinear = 2301;
246
- const InterpolateSmooth = 2302;
247
- const ZeroCurvatureEnding = 2400;
248
- const ZeroSlopeEnding = 2401;
249
- const WrapAroundEnding = 2402;
250
- const NormalAnimationBlendMode = 2500;
251
- const AdditiveAnimationBlendMode = 2501;
252
- const TrianglesDrawMode = 0;
253
- const LinearEncoding = 3000;
254
- const sRGBEncoding = 3001;
255
- const GammaEncoding = 3007;
256
- const RGBEEncoding = 3002;
257
- const RGBM7Encoding = 3004;
258
- const RGBM16Encoding = 3005;
259
- const RGBDEncoding = 3006;
260
- const BasicDepthPacking = 3200;
261
- const RGBADepthPacking = 3201;
262
- const TangentSpaceNormalMap = 0;
263
- const ObjectSpaceNormalMap = 1;
264
- const KeepStencilOp = 7680;
265
- const AlwaysStencilFunc = 519;
266
117
  const StaticDrawUsage = 35044;
267
- const DynamicDrawUsage = 35048;
268
- const GLSL3 = '300 es';
269
118
  class EventDispatcher {
270
119
  constructor() {
271
120
  this._listeners = {};
@@ -726,17 +575,6 @@ function workerFunction() {
726
575
  }
727
576
  //#endregion
728
577
  //#region Base Unit
729
- class Matrix4 {
730
- constructor() {
731
- this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
732
- }
733
- fromArray(array, offset = 0) {
734
- for (let i = 0; i < 16; i++) {
735
- this.elements[i] = array[i + offset];
736
- }
737
- return this;
738
- }
739
- }
740
578
  class Vector2 {
741
579
  constructor(x = 0, y = 0) {
742
580
  this.x = x;
@@ -1212,6 +1050,62 @@ function workerFunction() {
1212
1050
  this.z = e[2] * x + e[6] * y + e[10] * z;
1213
1051
  return this.normalize();
1214
1052
  }
1053
+ min(v) {
1054
+ this.x = Math.min(this.x, v.x);
1055
+ this.y = Math.min(this.y, v.y);
1056
+ this.z = Math.min(this.z, v.z);
1057
+ return this;
1058
+ }
1059
+ max(v) {
1060
+ this.x = Math.max(this.x, v.x);
1061
+ this.y = Math.max(this.y, v.y);
1062
+ this.z = Math.max(this.z, v.z);
1063
+ return this;
1064
+ }
1065
+ dot(v) {
1066
+ return this.x * v.x + this.y * v.y + this.z * v.z;
1067
+ }
1068
+ distanceToSquared(v) {
1069
+ const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
1070
+ return dx * dx + dy * dy + dz * dz;
1071
+ }
1072
+ distanceTo(v) {
1073
+ return Math.sqrt(this.distanceToSquared(v));
1074
+ }
1075
+ lengthSq() {
1076
+ return this.x * this.x + this.y * this.y + this.z * this.z;
1077
+ }
1078
+ equals(v) {
1079
+ return ((v.x === this.x) && (v.y === this.y) && (v.z === this.z));
1080
+ }
1081
+ negate() {
1082
+ this.x = -this.x;
1083
+ this.y = -this.y;
1084
+ this.z = -this.z;
1085
+ return this;
1086
+ }
1087
+ cross(v, w) {
1088
+ if (w !== undefined) {
1089
+ console.warn('THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.');
1090
+ return this.crossVectors(v, w);
1091
+ }
1092
+ return this.crossVectors(this, v);
1093
+ }
1094
+ crossVectors(a, b) {
1095
+ const ax = a.x, ay = a.y, az = a.z;
1096
+ const bx = b.x, by = b.y, bz = b.z;
1097
+ this.x = ay * bz - az * by;
1098
+ this.y = az * bx - ax * bz;
1099
+ this.z = ax * by - ay * bx;
1100
+ return this;
1101
+ }
1102
+ clamp(min, max) {
1103
+ // assumes min < max, componentwise
1104
+ this.x = Math.max(min.x, Math.min(max.x, this.x));
1105
+ this.y = Math.max(min.y, Math.min(max.y, this.y));
1106
+ this.z = Math.max(min.z, Math.min(max.z, this.z));
1107
+ return this;
1108
+ }
1215
1109
  }
1216
1110
  class Vector4 {
1217
1111
  constructor(x = 0, y = 0, z = 0, w = 1) {
@@ -1791,11 +1685,738 @@ function workerFunction() {
1791
1685
  return new Matrix3().fromArray(this.elements);
1792
1686
  }
1793
1687
  }
1688
+ class Matrix4 {
1689
+ constructor() {
1690
+ this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
1691
+ }
1692
+ fromArray(array, offset = 0) {
1693
+ for (let i = 0; i < 16; i++) {
1694
+ this.elements[i] = array[i + offset];
1695
+ }
1696
+ return this;
1697
+ }
1698
+ getMaxScaleOnAxis() {
1699
+ const te = this.elements;
1700
+ const scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
1701
+ const scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
1702
+ const scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
1703
+ return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
1704
+ }
1705
+ }
1706
+ class Box3 {
1707
+ constructor(min = new Vector3(+Infinity, +Infinity, +Infinity), max = new Vector3(-Infinity, -Infinity, -Infinity)) {
1708
+ this.min = min;
1709
+ this.max = max;
1710
+ }
1711
+ set(min, max) {
1712
+ this.min.copy(min);
1713
+ this.max.copy(max);
1714
+ return this;
1715
+ }
1716
+ setFromArray(array) {
1717
+ let minX = +Infinity;
1718
+ let minY = +Infinity;
1719
+ let minZ = +Infinity;
1720
+ let maxX = -Infinity;
1721
+ let maxY = -Infinity;
1722
+ let maxZ = -Infinity;
1723
+ for (let i = 0, l = array.length; i < l; i += 3) {
1724
+ const x = array[i];
1725
+ const y = array[i + 1];
1726
+ const z = array[i + 2];
1727
+ if (x < minX)
1728
+ minX = x;
1729
+ if (y < minY)
1730
+ minY = y;
1731
+ if (z < minZ)
1732
+ minZ = z;
1733
+ if (x > maxX)
1734
+ maxX = x;
1735
+ if (y > maxY)
1736
+ maxY = y;
1737
+ if (z > maxZ)
1738
+ maxZ = z;
1739
+ }
1740
+ this.min.set(minX, minY, minZ);
1741
+ this.max.set(maxX, maxY, maxZ);
1742
+ return this;
1743
+ }
1744
+ setFromBufferAttribute(attribute) {
1745
+ let minX = +Infinity;
1746
+ let minY = +Infinity;
1747
+ let minZ = +Infinity;
1748
+ let maxX = -Infinity;
1749
+ let maxY = -Infinity;
1750
+ let maxZ = -Infinity;
1751
+ for (let i = 0, l = attribute.count; i < l; i++) {
1752
+ const x = attribute.getX(i);
1753
+ const y = attribute.getY(i);
1754
+ const z = attribute.getZ(i);
1755
+ if (x < minX)
1756
+ minX = x;
1757
+ if (y < minY)
1758
+ minY = y;
1759
+ if (z < minZ)
1760
+ minZ = z;
1761
+ if (x > maxX)
1762
+ maxX = x;
1763
+ if (y > maxY)
1764
+ maxY = y;
1765
+ if (z > maxZ)
1766
+ maxZ = z;
1767
+ }
1768
+ this.min.set(minX, minY, minZ);
1769
+ this.max.set(maxX, maxY, maxZ);
1770
+ return this;
1771
+ }
1772
+ setFromPoints(points) {
1773
+ this.makeEmpty();
1774
+ for (let i = 0, il = points.length; i < il; i++) {
1775
+ this.expandByPoint(points[i]);
1776
+ }
1777
+ return this;
1778
+ }
1779
+ setFromCenterAndSize(center, size) {
1780
+ const halfSize = new Vector3().copy(size).multiplyScalar(0.5);
1781
+ this.min.copy(center).sub(halfSize);
1782
+ this.max.copy(center).add(halfSize);
1783
+ return this;
1784
+ }
1785
+ setFromObject(object) {
1786
+ this.makeEmpty();
1787
+ return this.expandByObject(object);
1788
+ }
1789
+ clone() {
1790
+ return new Box3().copy(this);
1791
+ }
1792
+ copy(box) {
1793
+ this.min.copy(box.min);
1794
+ this.max.copy(box.max);
1795
+ return this;
1796
+ }
1797
+ makeEmpty() {
1798
+ this.min.x = this.min.y = this.min.z = +Infinity;
1799
+ this.max.x = this.max.y = this.max.z = -Infinity;
1800
+ return this;
1801
+ }
1802
+ isEmpty() {
1803
+ return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
1804
+ }
1805
+ getCenter(target) {
1806
+ return this.isEmpty() ? target.set(0, 0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);
1807
+ }
1808
+ getSize(target) {
1809
+ return this.isEmpty() ? target.set(0, 0, 0) : target.subVectors(this.max, this.min);
1810
+ }
1811
+ expandByPoint(point) {
1812
+ this.min.min(point);
1813
+ this.max.max(point);
1814
+ return this;
1815
+ }
1816
+ expandByVector(vector) {
1817
+ this.min.sub(vector);
1818
+ this.max.add(vector);
1819
+ return this;
1820
+ }
1821
+ expandByScalar(scalar) {
1822
+ this.min.addScalar(-scalar);
1823
+ this.max.addScalar(scalar);
1824
+ return this;
1825
+ }
1826
+ expandByObject(object) {
1827
+ object.updateWorldMatrix(false, false);
1828
+ const geometry = object.geometry;
1829
+ if (geometry !== undefined) {
1830
+ if (geometry.boundingBox === null) {
1831
+ geometry.computeBoundingBox();
1832
+ }
1833
+ const box = new Box3().copy(geometry.boundingBox);
1834
+ box.applyMatrix4(object.matrixWorld);
1835
+ this.union(box);
1836
+ }
1837
+ const children = object.children;
1838
+ for (let i = 0, l = children.length; i < l; i++) {
1839
+ this.expandByObject(children[i]);
1840
+ }
1841
+ return this;
1842
+ }
1843
+ containsPoint(point) {
1844
+ return point.x < this.min.x || point.x > this.max.x ||
1845
+ point.y < this.min.y || point.y > this.max.y ||
1846
+ point.z < this.min.z || point.z > this.max.z ? false : true;
1847
+ }
1848
+ containsBox(box) {
1849
+ return this.min.x <= box.min.x && box.max.x <= this.max.x &&
1850
+ this.min.y <= box.min.y && box.max.y <= this.max.y &&
1851
+ this.min.z <= box.min.z && box.max.z <= this.max.z;
1852
+ }
1853
+ getParameter(point, target) {
1854
+ return target.set((point.x - this.min.x) / (this.max.x - this.min.x), (point.y - this.min.y) / (this.max.y - this.min.y), (point.z - this.min.z) / (this.max.z - this.min.z));
1855
+ }
1856
+ intersectsBox(box) {
1857
+ return box.max.x < this.min.x || box.min.x > this.max.x ||
1858
+ box.max.y < this.min.y || box.min.y > this.max.y ||
1859
+ box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
1860
+ }
1861
+ intersectsSphere(sphere) {
1862
+ this.clampPoint(sphere.center, _vector$b);
1863
+ return _vector$b.distanceToSquared(sphere.center) <= (sphere.radius * sphere.radius);
1864
+ }
1865
+ intersectsPlane(plane) {
1866
+ let min, max;
1867
+ if (plane.normal.x > 0) {
1868
+ min = plane.normal.x * this.min.x;
1869
+ max = plane.normal.x * this.max.x;
1870
+ }
1871
+ else {
1872
+ min = plane.normal.x * this.max.x;
1873
+ max = plane.normal.x * this.min.x;
1874
+ }
1875
+ if (plane.normal.y > 0) {
1876
+ min += plane.normal.y * this.min.y;
1877
+ max += plane.normal.y * this.max.y;
1878
+ }
1879
+ else {
1880
+ min += plane.normal.y * this.max.y;
1881
+ max += plane.normal.y * this.min.y;
1882
+ }
1883
+ if (plane.normal.z > 0) {
1884
+ min += plane.normal.z * this.min.z;
1885
+ max += plane.normal.z * this.max.z;
1886
+ }
1887
+ else {
1888
+ min += plane.normal.z * this.max.z;
1889
+ max += plane.normal.z * this.min.z;
1890
+ }
1891
+ return (min <= -plane.constant && max >= -plane.constant);
1892
+ }
1893
+ intersectsTriangle(triangle) {
1894
+ if (this.isEmpty()) {
1895
+ return false;
1896
+ }
1897
+ this.getCenter(_center);
1898
+ _extents.subVectors(this.max, _center);
1899
+ _v0$2.subVectors(triangle.a, _center);
1900
+ _v1$7.subVectors(triangle.b, _center);
1901
+ _v2$3.subVectors(triangle.c, _center);
1902
+ _f0.subVectors(_v1$7, _v0$2);
1903
+ _f1.subVectors(_v2$3, _v1$7);
1904
+ _f2.subVectors(_v0$2, _v2$3);
1905
+ let axes = [
1906
+ 0, -_f0.z, _f0.y,
1907
+ 0, -_f1.z, _f1.y,
1908
+ 0, -_f2.z, _f2.y,
1909
+ _f0.z, 0, -_f0.x,
1910
+ _f1.z, 0, -_f1.x,
1911
+ _f2.z, 0, -_f2.x,
1912
+ -_f0.y, _f0.x, 0,
1913
+ -_f1.y, _f1.x, 0,
1914
+ -_f2.y, _f2.x, 0
1915
+ ];
1916
+ if (!satForAxes(axes, _v0$2, _v1$7, _v2$3, _extents)) {
1917
+ return false;
1918
+ }
1919
+ axes = [1, 0, 0, 0, 1, 0, 0, 0, 1];
1920
+ if (!satForAxes(axes, _v0$2, _v1$7, _v2$3, _extents)) {
1921
+ return false;
1922
+ }
1923
+ _triangleNormal.crossVectors(_f0, _f1);
1924
+ axes = [_triangleNormal.x, _triangleNormal.y, _triangleNormal.z];
1925
+ return satForAxes(axes, _v0$2, _v1$7, _v2$3, _extents);
1926
+ }
1927
+ clampPoint(point, target) {
1928
+ return target.copy(point).clamp(this.min, this.max);
1929
+ }
1930
+ distanceToPoint(point) {
1931
+ const clampedPoint = _vector$b.copy(point).clamp(this.min, this.max);
1932
+ return clampedPoint.sub(point).length();
1933
+ }
1934
+ getBoundingSphere(target) {
1935
+ this.getCenter(target.center);
1936
+ target.radius = this.getSize(_vector$b).length() * 0.5;
1937
+ return target;
1938
+ }
1939
+ intersect(box) {
1940
+ this.min.max(box.min);
1941
+ this.max.min(box.max);
1942
+ if (this.isEmpty()) {
1943
+ this.makeEmpty();
1944
+ }
1945
+ return this;
1946
+ }
1947
+ union(box) {
1948
+ this.min.min(box.min);
1949
+ this.max.max(box.max);
1950
+ return this;
1951
+ }
1952
+ applyMatrix4(matrix) {
1953
+ if (this.isEmpty()) {
1954
+ return this;
1955
+ }
1956
+ _points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(matrix); // 000
1957
+ _points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(matrix); // 001
1958
+ _points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(matrix); // 010
1959
+ _points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(matrix); // 011
1960
+ _points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(matrix); // 100
1961
+ _points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(matrix); // 101
1962
+ _points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(matrix); // 110
1963
+ _points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(matrix); // 111
1964
+ this.setFromPoints(_points);
1965
+ return this;
1966
+ }
1967
+ translate(offset) {
1968
+ this.min.add(offset);
1969
+ this.max.add(offset);
1970
+ return this;
1971
+ }
1972
+ equals(box) {
1973
+ return box.min.equals(this.min) && box.max.equals(this.max);
1974
+ }
1975
+ }
1976
+ const _points = [
1977
+ /*@__PURE__*/ new Vector3(),
1978
+ /*@__PURE__*/ new Vector3(),
1979
+ /*@__PURE__*/ new Vector3(),
1980
+ /*@__PURE__*/ new Vector3(),
1981
+ /*@__PURE__*/ new Vector3(),
1982
+ /*@__PURE__*/ new Vector3(),
1983
+ /*@__PURE__*/ new Vector3(),
1984
+ /*@__PURE__*/ new Vector3()
1985
+ ];
1986
+ const _vector$b = /*@__PURE__*/ new Vector3();
1987
+ const _box$3 = /*@__PURE__*/ new Box3();
1988
+ // triangle centered vertices
1989
+ const _v0$2 = /*@__PURE__*/ new Vector3();
1990
+ const _v1$7 = /*@__PURE__*/ new Vector3();
1991
+ const _v2$3 = /*@__PURE__*/ new Vector3();
1992
+ // triangle edge vectors
1993
+ const _f0 = /*@__PURE__*/ new Vector3();
1994
+ const _f1 = /*@__PURE__*/ new Vector3();
1995
+ const _f2 = /*@__PURE__*/ new Vector3();
1996
+ const _center = /*@__PURE__*/ new Vector3();
1997
+ const _extents = /*@__PURE__*/ new Vector3();
1998
+ const _triangleNormal = /*@__PURE__*/ new Vector3();
1999
+ const _testAxis = /*@__PURE__*/ new Vector3();
2000
+ function satForAxes(axes, v0, v1, v2, extents) {
2001
+ for (let i = 0, j = axes.length - 3; i <= j; i += 3) {
2002
+ const _testAxis = new Vector3().fromArray(axes, i);
2003
+ // Project the AABB onto the separating axis
2004
+ const r = extents.x * Math.abs(_testAxis.x) + extents.y * Math.abs(_testAxis.y) + extents.z * Math.abs(_testAxis.z);
2005
+ // Project all 3 vertices of the triangle onto the separating axis
2006
+ const p0 = v0.dot(_testAxis);
2007
+ const p1 = v1.dot(_testAxis);
2008
+ const p2 = v2.dot(_testAxis);
2009
+ // Actual test, basically see if either of the most extreme of the triangle points intersects r
2010
+ if (Math.max(-Math.max(p0, p1, p2), Math.min(p0, p1, p2)) > r) {
2011
+ // Points of the projected triangle are outside the projected half-length of the AABB
2012
+ // The axis is separating, and we can exit
2013
+ return false;
2014
+ }
2015
+ }
2016
+ return true;
2017
+ }
2018
+ const _box$2 = /*@__PURE__*/ new Box3();
2019
+ const _v1$6 = /*@__PURE__*/ new Vector3();
2020
+ const _toFarthestPoint = /*@__PURE__*/ new Vector3();
2021
+ const _toPoint = /*@__PURE__*/ new Vector3();
2022
+ class Sphere {
2023
+ constructor(center = new Vector3(), radius = -1) {
2024
+ this.center = center;
2025
+ this.radius = radius;
2026
+ }
2027
+ set(center, radius) {
2028
+ this.center.copy(center);
2029
+ this.radius = radius;
2030
+ return this;
2031
+ }
2032
+ setFromPoints(points, optionalCenter) {
2033
+ const center = this.center;
2034
+ if (optionalCenter !== undefined) {
2035
+ center.copy(optionalCenter);
2036
+ }
2037
+ else {
2038
+ const box = new Box3();
2039
+ box.setFromPoints(points);
2040
+ box.getCenter(center);
2041
+ }
2042
+ let maxRadiusSq = 0;
2043
+ for (let i = 0, il = points.length; i < il; i++) {
2044
+ maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(points[i]));
2045
+ }
2046
+ this.radius = Math.sqrt(maxRadiusSq);
2047
+ return this;
2048
+ }
2049
+ copy(sphere) {
2050
+ this.center.copy(sphere.center);
2051
+ this.radius = sphere.radius;
2052
+ return this;
2053
+ }
2054
+ isEmpty() {
2055
+ return this.radius < 0;
2056
+ }
2057
+ makeEmpty() {
2058
+ this.center.set(0, 0, 0);
2059
+ this.radius = -1;
2060
+ return this;
2061
+ }
2062
+ containsPoint(point) {
2063
+ return point.distanceToSquared(this.center) <= this.radius * this.radius;
2064
+ }
2065
+ distanceToPoint(point) {
2066
+ return point.distanceTo(this.center) - this.radius;
2067
+ }
2068
+ intersectsSphere(sphere) {
2069
+ const radiusSum = this.radius + sphere.radius;
2070
+ return sphere.center.distanceToSquared(this.center) <= radiusSum * radiusSum;
2071
+ }
2072
+ intersectsBox(box) {
2073
+ return box.intersectsSphere(this);
2074
+ }
2075
+ intersectsPlane(plane) {
2076
+ return Math.abs(plane.distanceToPoint(this.center)) <= this.radius;
2077
+ }
2078
+ clampPoint(point, target) {
2079
+ const deltaLengthSq = this.center.distanceToSquared(point);
2080
+ target.copy(point);
2081
+ if (deltaLengthSq > this.radius * this.radius) {
2082
+ target.sub(this.center).normalize().multiplyScalar(this.radius).add(this.center);
2083
+ }
2084
+ return target;
2085
+ }
2086
+ getBoundingBox(target) {
2087
+ if (this.isEmpty()) {
2088
+ target.makeEmpty();
2089
+ return target;
2090
+ }
2091
+ target.set(this.center, this.center);
2092
+ target.expandByScalar(this.radius);
2093
+ return target;
2094
+ }
2095
+ applyMatrix4(matrix) {
2096
+ this.center.applyMatrix4(matrix);
2097
+ this.radius *= matrix.getMaxScaleOnAxis();
2098
+ return this;
2099
+ }
2100
+ translate(offset) {
2101
+ this.center.add(offset);
2102
+ return this;
2103
+ }
2104
+ expandByPoint(point) {
2105
+ _toPoint.subVectors(point, this.center);
2106
+ const lengthSq = _toPoint.lengthSq();
2107
+ if (lengthSq > this.radius * this.radius) {
2108
+ const length = Math.sqrt(lengthSq);
2109
+ const missingRadiusHalf = (length - this.radius) * 0.5;
2110
+ this.center.add(_toPoint.multiplyScalar(missingRadiusHalf / length));
2111
+ this.radius += missingRadiusHalf;
2112
+ }
2113
+ return this;
2114
+ }
2115
+ union(sphere) {
2116
+ _toFarthestPoint.subVectors(sphere.center, this.center).normalize().multiplyScalar(sphere.radius);
2117
+ this.expandByPoint(_v1$6.copy(sphere.center).add(_toFarthestPoint));
2118
+ this.expandByPoint(_v1$6.copy(sphere.center).sub(_toFarthestPoint));
2119
+ return this;
2120
+ }
2121
+ equals(sphere) {
2122
+ return sphere.center.equals(this.center) && sphere.radius === this.radius;
2123
+ }
2124
+ clone() {
2125
+ return new Sphere().copy(this);
2126
+ }
2127
+ }
2128
+ class Plane {
2129
+ constructor(normal = new Vector3(1, 0, 0), constant = 0) {
2130
+ // normal is assumed to be normalized
2131
+ this.normal = normal;
2132
+ this.constant = constant;
2133
+ }
2134
+ set(normal, constant) {
2135
+ this.normal.copy(normal);
2136
+ this.constant = constant;
2137
+ return this;
2138
+ }
2139
+ setComponents(x, y, z, w) {
2140
+ this.normal.set(x, y, z);
2141
+ this.constant = w;
2142
+ return this;
2143
+ }
2144
+ setFromNormalAndCoplanarPoint(normal, point) {
2145
+ this.normal.copy(normal);
2146
+ this.constant = -point.dot(this.normal);
2147
+ return this;
2148
+ }
2149
+ setFromCoplanarPoints(a, b, c) {
2150
+ const normal = new Vector3().subVectors(c, b).cross(new Vector3().subVectors(a, b)).normalize();
2151
+ this.setFromNormalAndCoplanarPoint(normal, a);
2152
+ return this;
2153
+ }
2154
+ copy(plane) {
2155
+ this.normal.copy(plane.normal);
2156
+ this.constant = plane.constant;
2157
+ return this;
2158
+ }
2159
+ normalize() {
2160
+ // Note: will lead to a divide by zero if the plane is invalid.
2161
+ const inverseNormalLength = 1.0 / this.normal.length();
2162
+ this.normal.multiplyScalar(inverseNormalLength);
2163
+ this.constant *= inverseNormalLength;
2164
+ return this;
2165
+ }
2166
+ negate() {
2167
+ this.constant *= -1;
2168
+ this.normal.negate();
2169
+ return this;
2170
+ }
2171
+ distanceToPoint(point) {
2172
+ return this.normal.dot(point) + this.constant;
2173
+ }
2174
+ distanceToSphere(sphere) {
2175
+ return this.distanceToPoint(sphere.center) - sphere.radius;
2176
+ }
2177
+ projectPoint(point, target) {
2178
+ return target.copy(this.normal).multiplyScalar(-this.distanceToPoint(point)).add(point);
2179
+ }
2180
+ intersectLine(line, target) {
2181
+ const direction = line.delta(new Vector3());
2182
+ const denominator = this.normal.dot(direction);
2183
+ if (denominator === 0) {
2184
+ // Line is coplanar, return origin
2185
+ if (this.distanceToPoint(line.start) === 0) {
2186
+ return target.copy(line.start);
2187
+ }
2188
+ // Unsure if this is the correct method to handle this case.
2189
+ return null;
2190
+ }
2191
+ const t = -(line.start.dot(this.normal) + this.constant) / denominator;
2192
+ if (t < 0 || t > 1) {
2193
+ return null;
2194
+ }
2195
+ return target.copy(direction).multiplyScalar(t).add(line.start);
2196
+ }
2197
+ intersectsLine(line) {
2198
+ // Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.
2199
+ const startSign = this.distanceToPoint(line.start);
2200
+ const endSign = this.distanceToPoint(line.end);
2201
+ return (startSign < 0 && endSign > 0) || (endSign < 0 && startSign > 0);
2202
+ }
2203
+ intersectsBox(box) {
2204
+ return box.intersectsPlane(this);
2205
+ }
2206
+ intersectsSphere(sphere) {
2207
+ return sphere.intersectsPlane(this);
2208
+ }
2209
+ coplanarPoint(target) {
2210
+ return target.copy(this.normal).multiplyScalar(-this.constant);
2211
+ }
2212
+ applyMatrix4(matrix, optionalNormalMatrix) {
2213
+ const normalMatrix = optionalNormalMatrix || new Matrix3().getNormalMatrix(matrix);
2214
+ const referencePoint = this.coplanarPoint(new Vector3()).applyMatrix4(matrix);
2215
+ const normal = this.normal.applyMatrix3(normalMatrix).normalize();
2216
+ this.constant = -referencePoint.dot(normal);
2217
+ return this;
2218
+ }
2219
+ translate(offset) {
2220
+ this.constant -= offset.dot(this.normal);
2221
+ return this;
2222
+ }
2223
+ equals(plane) {
2224
+ return plane.normal.equals(this.normal) && plane.constant === this.constant;
2225
+ }
2226
+ clone() {
2227
+ return new Plane().copy(this);
2228
+ }
2229
+ }
2230
+ const _v0$1 = /*@__PURE__*/ new Vector3();
2231
+ const _v1$3 = /*@__PURE__*/ new Vector3();
2232
+ const _v2$2 = /*@__PURE__*/ new Vector3();
2233
+ const _v3$1 = /*@__PURE__*/ new Vector3();
2234
+ const _vab = /*@__PURE__*/ new Vector3();
2235
+ const _vac = /*@__PURE__*/ new Vector3();
2236
+ const _vbc = /*@__PURE__*/ new Vector3();
2237
+ const _vap = /*@__PURE__*/ new Vector3();
2238
+ const _vbp = /*@__PURE__*/ new Vector3();
2239
+ const _vcp = /*@__PURE__*/ new Vector3();
2240
+ class Triangle {
2241
+ constructor(a = new Vector3(), b = new Vector3(), c = new Vector3()) {
2242
+ this.a = a;
2243
+ this.b = b;
2244
+ this.c = c;
2245
+ }
2246
+ static getNormal(a, b, c, target) {
2247
+ target.subVectors(c, b);
2248
+ _v0$1.subVectors(a, b);
2249
+ target.cross(_v0$1);
2250
+ const targetLengthSq = target.lengthSq();
2251
+ if (targetLengthSq > 0) {
2252
+ return target.multiplyScalar(1 / Math.sqrt(targetLengthSq));
2253
+ }
2254
+ return target.set(0, 0, 0);
2255
+ }
2256
+ // static/instance method to calculate barycentric coordinates
2257
+ // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
2258
+ static getBarycoord(point, a, b, c, target) {
2259
+ _v0$1.subVectors(c, a);
2260
+ _v1$3.subVectors(b, a);
2261
+ _v2$2.subVectors(point, a);
2262
+ const dot00 = _v0$1.dot(_v0$1);
2263
+ const dot01 = _v0$1.dot(_v1$3);
2264
+ const dot02 = _v0$1.dot(_v2$2);
2265
+ const dot11 = _v1$3.dot(_v1$3);
2266
+ const dot12 = _v1$3.dot(_v2$2);
2267
+ const denom = (dot00 * dot11 - dot01 * dot01);
2268
+ // collinear or singular triangle
2269
+ if (denom === 0) {
2270
+ // arbitrary location outside of triangle?
2271
+ // not sure if this is the best idea, maybe should be returning undefined
2272
+ return target.set(-2, -1, -1);
2273
+ }
2274
+ const invDenom = 1 / denom;
2275
+ const u = (dot11 * dot02 - dot01 * dot12) * invDenom;
2276
+ const v = (dot00 * dot12 - dot01 * dot02) * invDenom;
2277
+ // barycentric coordinates must always sum to 1
2278
+ return target.set(1 - u - v, v, u);
2279
+ }
2280
+ static containsPoint(point, a, b, c) {
2281
+ this.getBarycoord(point, a, b, c, _v3$1);
2282
+ return (_v3$1.x >= 0) && (_v3$1.y >= 0) && ((_v3$1.x + _v3$1.y) <= 1);
2283
+ }
2284
+ static getUV(point, p1, p2, p3, uv1, uv2, uv3, target) {
2285
+ this.getBarycoord(point, p1, p2, p3, _v3$1);
2286
+ target.set(0, 0, undefined);
2287
+ target.addScaledVector(uv1, _v3$1.x);
2288
+ target.addScaledVector(uv2, _v3$1.y);
2289
+ target.addScaledVector(uv3, _v3$1.z);
2290
+ return target;
2291
+ }
2292
+ static isFrontFacing(a, b, c, direction) {
2293
+ _v0$1.subVectors(c, b);
2294
+ _v1$3.subVectors(a, b);
2295
+ // strictly front facing
2296
+ return (_v0$1.cross(_v1$3).dot(direction) < 0) ? true : false;
2297
+ }
2298
+ set(a, b, c) {
2299
+ this.a.copy(a);
2300
+ this.b.copy(b);
2301
+ this.c.copy(c);
2302
+ return this;
2303
+ }
2304
+ setFromPointsAndIndices(points, i0, i1, i2) {
2305
+ this.a.copy(points[i0]);
2306
+ this.b.copy(points[i1]);
2307
+ this.c.copy(points[i2]);
2308
+ return this;
2309
+ }
2310
+ setFromAttributeAndIndices(attribute, i0, i1, i2) {
2311
+ this.a.fromBufferAttribute(attribute, i0);
2312
+ this.b.fromBufferAttribute(attribute, i1);
2313
+ this.c.fromBufferAttribute(attribute, i2);
2314
+ return this;
2315
+ }
2316
+ clone() {
2317
+ return new Triangle().copy(this);
2318
+ }
2319
+ copy(triangle) {
2320
+ this.a.copy(triangle.a);
2321
+ this.b.copy(triangle.b);
2322
+ this.c.copy(triangle.c);
2323
+ return this;
2324
+ }
2325
+ getArea() {
2326
+ _v0$1.subVectors(this.c, this.b);
2327
+ _v1$3.subVectors(this.a, this.b);
2328
+ return _v0$1.cross(_v1$3).length() * 0.5;
2329
+ }
2330
+ getMidpoint(target) {
2331
+ return target.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
2332
+ }
2333
+ getNormal(target) {
2334
+ return Triangle.getNormal(this.a, this.b, this.c, target);
2335
+ }
2336
+ getPlane(target) {
2337
+ return target.setFromCoplanarPoints(this.a, this.b, this.c);
2338
+ }
2339
+ getBarycoord(point, target) {
2340
+ return Triangle.getBarycoord(point, this.a, this.b, this.c, target);
2341
+ }
2342
+ getUV(point, uv1, uv2, uv3, target) {
2343
+ return Triangle.getUV(point, this.a, this.b, this.c, uv1, uv2, uv3, target);
2344
+ }
2345
+ containsPoint(point) {
2346
+ return Triangle.containsPoint(point, this.a, this.b, this.c);
2347
+ }
2348
+ isFrontFacing(direction) {
2349
+ return Triangle.isFrontFacing(this.a, this.b, this.c, direction);
2350
+ }
2351
+ intersectsBox(box) {
2352
+ return box.intersectsTriangle(this);
2353
+ }
2354
+ closestPointToPoint(p, target) {
2355
+ const a = this.a, b = this.b, c = this.c;
2356
+ let v, w;
2357
+ // algorithm thanks to Real-Time Collision Detection by Christer Ericson,
2358
+ // published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,
2359
+ // under the accompanying license; see chapter 5.1.5 for detailed explanation.
2360
+ // basically, we're distinguishing which of the voronoi regions of the triangle
2361
+ // the point lies in with the minimum amount of redundant computation.
2362
+ _vab.subVectors(b, a);
2363
+ _vac.subVectors(c, a);
2364
+ _vap.subVectors(p, a);
2365
+ const d1 = _vab.dot(_vap);
2366
+ const d2 = _vac.dot(_vap);
2367
+ if (d1 <= 0 && d2 <= 0) {
2368
+ // vertex region of A; barycentric coords (1, 0, 0)
2369
+ return target.copy(a);
2370
+ }
2371
+ _vbp.subVectors(p, b);
2372
+ const d3 = _vab.dot(_vbp);
2373
+ const d4 = _vac.dot(_vbp);
2374
+ if (d3 >= 0 && d4 <= d3) {
2375
+ // vertex region of B; barycentric coords (0, 1, 0)
2376
+ return target.copy(b);
2377
+ }
2378
+ const vc = d1 * d4 - d3 * d2;
2379
+ if (vc <= 0 && d1 >= 0 && d3 <= 0) {
2380
+ v = d1 / (d1 - d3);
2381
+ // edge region of AB; barycentric coords (1-v, v, 0)
2382
+ return target.copy(a).addScaledVector(_vab, v);
2383
+ }
2384
+ _vcp.subVectors(p, c);
2385
+ const d5 = _vab.dot(_vcp);
2386
+ const d6 = _vac.dot(_vcp);
2387
+ if (d6 >= 0 && d5 <= d6) {
2388
+ // vertex region of C; barycentric coords (0, 0, 1)
2389
+ return target.copy(c);
2390
+ }
2391
+ const vb = d5 * d2 - d1 * d6;
2392
+ if (vb <= 0 && d2 >= 0 && d6 <= 0) {
2393
+ w = d2 / (d2 - d6);
2394
+ // edge region of AC; barycentric coords (1-w, 0, w)
2395
+ return target.copy(a).addScaledVector(_vac, w);
2396
+ }
2397
+ const va = d3 * d6 - d5 * d4;
2398
+ if (va <= 0 && (d4 - d3) >= 0 && (d5 - d6) >= 0) {
2399
+ _vbc.subVectors(c, b);
2400
+ w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
2401
+ // edge region of BC; barycentric coords (0, 1-w, w)
2402
+ return target.copy(b).addScaledVector(_vbc, w); // edge region of BC
2403
+ }
2404
+ // face region
2405
+ const denom = 1 / (va + vb + vc);
2406
+ // u = va * denom
2407
+ v = vb * denom;
2408
+ w = vc * denom;
2409
+ return target.copy(a).addScaledVector(_vab, v).addScaledVector(_vac, w);
2410
+ }
2411
+ equals(triangle) {
2412
+ return triangle.a.equals(this.a) && triangle.b.equals(this.b) && triangle.c.equals(this.c);
2413
+ }
2414
+ }
1794
2415
  //#endregion
1795
2416
  const _vector$9 = /*@__PURE__*/ new Vector3(0, 0, 0);
1796
2417
  const _vector2$1 = /*@__PURE__*/ new Vector2();
1797
2418
  class BufferAttribute {
1798
- constructor(array, itemSize, normalized) {
2419
+ constructor(array, itemSize, normalized = true) {
1799
2420
  this.name = '';
1800
2421
  if (Array.isArray(array)) {
1801
2422
  throw new TypeError('THREE.BufferAttribute: array should be a Typed Array.');
@@ -2027,436 +2648,103 @@ function workerFunction() {
2027
2648
  return data;
2028
2649
  }
2029
2650
  }
2030
- // class BufferGeometry extends EventDispatcher {
2031
- // uuid: string;
2032
- // name: string;
2033
- // type: string;
2034
- // index: BufferAttribute | null;
2035
- // attributes: { [name: string]: BufferAttribute };
2036
- // morphAttributes: { [name: string]: BufferAttribute[] };
2037
- // morphTargetsRelative: boolean;
2038
- // groups: { start: number; count: number; materialIndex: number }[];
2039
- // boundingBox: Box3 | null;
2040
- // boundingSphere: Sphere | null;
2041
- // drawRange: { start: number; count: number };
2042
- // userData: { [key: string]: any };
2043
- // constructor() {
2044
- // super();
2045
- // Object.defineProperty(this, 'id', { value: _id++ });
2046
- // this.uuid = generateUUID();
2047
- // this.name = '';
2048
- // this.type = 'BufferGeometry';
2049
- // this.index = null;
2050
- // this.attributes = {};
2051
- // this.morphAttributes = {};
2052
- // this.morphTargetsRelative = false;
2053
- // this.groups = [];
2054
- // this.boundingBox = null;
2055
- // this.boundingSphere = null;
2056
- // this.drawRange = { start: 0, count: Infinity };
2057
- // this.userData = {};
2058
- // }
2059
- // getIndex(): BufferAttribute | null {
2060
- // return this.index;
2061
- // }
2062
- // setIndex(index: BufferAttribute | number[]): this {
2063
- // if (Array.isArray(index)) {
2064
- // this.index = new (arrayMax(index) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(
2065
- // index,
2066
- // 1
2067
- // );
2068
- // } else {
2069
- // this.index = index;
2070
- // }
2071
- // return this;
2072
- // }
2073
- // getAttribute(name: string): BufferAttribute | undefined {
2074
- // return this.attributes[name];
2075
- // }
2076
- // setAttribute(name: string, attribute: BufferAttribute): this {
2077
- // this.attributes[name] = attribute;
2078
- // return this;
2079
- // }
2080
- // deleteAttribute(name: string): this {
2081
- // delete this.attributes[name];
2082
- // return this;
2083
- // }
2084
- // hasAttribute(name: string): boolean {
2085
- // return this.attributes[name] !== undefined;
2086
- // }
2087
- // addGroup(start: number, count: number, materialIndex: number = 0): void {
2088
- // this.groups.push({
2089
- // start,
2090
- // count,
2091
- // materialIndex,
2092
- // });
2093
- // }
2094
- // clearGroups(): void {
2095
- // this.groups = [];
2096
- // }
2097
- // setDrawRange(start: number, count: number): void {
2098
- // this.drawRange.start = start;
2099
- // this.drawRange.count = count;
2100
- // }
2101
- // applyMatrix4(matrix: Matrix4): this {
2102
- // const position = this.attributes.position;
2103
- // if (position !== undefined) {
2104
- // position.applyMatrix4(matrix);
2105
- // position.needsUpdate = true;
2106
- // }
2107
- // const normal = this.attributes.normal;
2108
- // if (normal !== undefined) {
2109
- // const normalMatrix = new Matrix3().getNormalMatrix(matrix);
2110
- // normal.applyNormalMatrix(normalMatrix);
2111
- // normal.needsUpdate = true;
2112
- // }
2113
- // const tangent = this.attributes.tangent;
2114
- // if (tangent !== undefined) {
2115
- // tangent.transformDirection(matrix);
2116
- // tangent.needsUpdate = true;
2117
- // }
2118
- // if (this.boundingBox !== null) {
2119
- // this.computeBoundingBox();
2120
- // }
2121
- // if (this.boundingSphere !== null) {
2122
- // this.computeBoundingSphere();
2123
- // }
2124
- // return this;
2125
- // }
2126
- // applyQuaternion(q: Quaternion): this {
2127
- // _m1.makeRotationFromQuaternion(q);
2128
- // this.applyMatrix4(_m1);
2129
- // return this;
2130
- // }
2131
- // rotateX(angle: number): this {
2132
- // _m1.makeRotationX(angle);
2133
- // this.applyMatrix4(_m1);
2134
- // return this;
2135
- // }
2136
- // rotateY(angle: number): this {
2137
- // _m1.makeRotationY(angle);
2138
- // this.applyMatrix4(_m1);
2139
- // return this;
2140
- // }
2141
- // rotateZ(angle: number): this {
2142
- // _m1.makeRotationZ(angle);
2143
- // this.applyMatrix4(_m1);
2144
- // return this;
2145
- // }
2146
- // translate(x: number, y: number, z: number): this {
2147
- // _m1.makeTranslation(x, y, z);
2148
- // this.applyMatrix4(_m1);
2149
- // return this;
2150
- // }
2151
- // scale(x: number, y: number, z: number): this {
2152
- // _m1.makeScale(x, y, z);
2153
- // this.applyMatrix4(_m1);
2154
- // return this;
2155
- // }
2156
- // lookAt(vector: Vector3): this {
2157
- // _obj.lookAt(vector);
2158
- // _obj.updateMatrix();
2159
- // this.applyMatrix4(_obj.matrix);
2160
- // return this;
2161
- // }
2162
- // center(): this {
2163
- // this.computeBoundingBox();
2164
- // this.boundingBox.getCenter(_offset).negate();
2165
- // this.translate(_offset.x, _offset.y, _offset.z);
2166
- // return this;
2167
- // }
2168
- // setFromPoints(points: Vector3[]): this {
2169
- // const position: number[] = [];
2170
- // for (let i = 0, l = points.length; i < l; i++) {
2171
- // const point = points[i];
2172
- // position.push(point.x, point.y, point.z || 0);
2173
- // }
2174
- // this.setAttribute('position', new Float32BufferAttribute(position, 3));
2175
- // return this;
2176
- // }
2177
- // computeBoundingBox(): void {
2178
- // if (this.boundingBox === null) {
2179
- // this.boundingBox = new Box3();
2180
- // }
2181
- // const position = this.attributes.position;
2182
- // const morphAttributesPosition = this.morphAttributes.position;
2183
- // if (position && position.isGLBufferAttribute) {
2184
- // console.error(
2185
- // 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',
2186
- // this
2187
- // );
2188
- // this.boundingBox.set(
2189
- // new Vector3(-Infinity, -Infinity, -Infinity),
2190
- // new Vector3(+Infinity, +Infinity, +Infinity)
2191
- // );
2192
- // return;
2193
- // }
2194
- // if (position !== undefined) {
2195
- // this.boundingBox.setFromBufferAttribute(position);
2196
- // // process morph attributes if present
2197
- // if (morphAttributesPosition) {
2198
- // for (let i = 0, il = morphAttributesPosition.length; i < il; i++) {
2199
- // const morphAttribute = morphAttributesPosition[i];
2200
- // _box.fromBufferAttribute(morphAttribute);
2201
- // _box.min.add(this.boundingBox.min);
2202
- // _box.max.add(this.boundingBox.max);
2203
- // this.boundingBox.union(_box);
2204
- // }
2205
- // }
2206
- // }
2207
- // }
2208
- // computeBoundingSphere(): void {
2209
- // if (this.boundingSphere === null) {
2210
- // this.boundingSphere = new Sphere();
2211
- // }
2212
- // const position = this.attributes.position;
2213
- // const morphAttributesPosition = this.morphAttributes.position;
2214
- // if (position && position.isGLBufferAttribute) {
2215
- // console.error(
2216
- // 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',
2217
- // this
2218
- // );
2219
- // this.boundingSphere.set(
2220
- // new Vector3(),
2221
- // Infinity
2222
- // );
2223
- // return;
2224
- // }
2225
- // if (position) {
2226
- // const center = this.boundingSphere.center;
2227
- // this.boundingSphere.radius = position.isInterleavedBufferAttribute
2228
- // ? position.data.stride <= 0 ? 0 : position.data.stride / 4
2229
- // : 0;
2230
- // // process morph attributes if present
2231
- // if (morphAttributesPosition) {
2232
- // for (let i = 0, il = morphAttributesPosition.length; i < il; i++) {
2233
- // const morphAttribute = morphAttributesPosition[i];
2234
- // const morphRadius = 0;
2235
- // if (morphAttribute.isInterleavedBufferAttribute) {
2236
- // console.error(
2237
- // 'THREE.BufferGeometry.computeBoundingSphere(): morphAttribute isInterleavedBufferAttribute is not supported. Please use regular BufferAttribute.'
2238
- // );
2239
- // continue;
2240
- // }
2241
- // for (let i = 0, il = morphAttribute.count; i < il; i++) {
2242
- // _v1.x = morphAttribute.getX(i);
2243
- // _v1.y = morphAttribute.getY(i);
2244
- // _v1.z = morphAttribute.getZ(i);
2245
- // morphRadius = Math.max(morphRadius, center.distanceToSquared(_v1));
2246
- // }
2247
- // this.boundingSphere.radius = Math.max(this.boundingSphere.radius, Math.sqrt(morphRadius));
2248
- // }
2249
- // }
2250
- // // process regular attributes
2251
- // for (let i = 0, il = position.count; i < il; i++) {
2252
- // _v1.x = position.getX(i);
2253
- // _v1.y = position.getY(i);
2254
- // _v1.z = position.getZ(i);
2255
- // this.boundingSphere.radius = Math.max(this.boundingSphere.radius, center.distanceToSquared(_v1));
2256
- // }
2257
- // this.boundingSphere.radius = Math.sqrt(this.boundingSphere.radius);
2258
- // }
2259
- // }
2260
- // computeTangents(): this {
2261
- // console.warn(
2262
- // 'THREE.BufferGeometry: .computeTangents() has been removed. Please use the TangentSpaceNormalMap shader or THREE.TangentSpaceUtils.computeTangents() instead.'
2263
- // );
2264
- // return this;
2265
- // }
2266
- // computeVertexNormals(): this {
2267
- // console.error(
2268
- // 'THREE.BufferGeometry: .computeVertexNormals() has been removed. Use THREE.BufferGeometryUtils.computeNormals() instead.'
2269
- // );
2270
- // return this;
2271
- // }
2272
- // computeFaceNormals(): this {
2273
- // const cb = new Vector3(), ab = new Vector3();
2274
- // if (this.index !== null) {
2275
- // // indexed BufferGeometry
2276
- // const indices = this.index.array;
2277
- // const positions = this.attributes.position.array;
2278
- // const normals = this.attributes.normal !== undefined ? this.attributes.normal.array : null;
2279
- // for (let i = 0, il = indices.length; i < il; i += 3) {
2280
- // const a = indices[i + 0];
2281
- // const b = indices[i + 1];
2282
- // const c = indices[i + 2];
2283
- // if (normals !== null) {
2284
- // const x = normals[a * 3 + 0] + normals[b * 3 + 0] + normals[c * 3 + 0];
2285
- // const y = normals[a * 3 + 1] + normals[b * 3 + 1] + normals[c * 3 + 1];
2286
- // const z = normals[a * 3 + 2] + normals[b * 3 + 2] + normals[c * 3 + 2];
2287
- // _cb.set(x, y, z).normalize();
2288
- // } else {
2289
- // // flat normals
2290
- // const x = positions[a * 3 + 0] - positions[b * 3 + 0];
2291
- // const y = positions[a * 3 + 1] - positions[b * 3 + 1];
2292
- // const z = positions[a * 3 + 2] - positions[b * 3 + 2];
2293
- // _cb.set(x, y, z).normalize();
2294
- // }
2295
- // _ab.set(positions[a * 3 + 0] - positions[c * 3 + 0], positions[a * 3 + 1] - positions[c * 3 + 1], positions[a * 3 + 2] - positions[c * 3 + 2]);
2296
- // _cb.cross(_ab).normalize();
2297
- // normals[a * 3 + 0] += _cb.x;
2298
- // normals[a * 3 + 1] += _cb.y;
2299
- // normals[a * 3 + 2] += _cb.z;
2300
- // normals[b * 3 + 0] += _cb.x;
2301
- // normals[b * 3 + 1] += _cb.y;
2302
- // normals[b * 3 + 2] += _cb.z;
2303
- // normals[c * 3 + 0] += _cb.x;
2304
- // normals[c * 3 + 1] += _cb.y;
2305
- // normals[c * 3 + 2] += _cb.z;
2306
- // }
2307
- // this.normalizeNormals();
2308
- // this.attributes.normal.needsUpdate = true;
2309
- // } else {
2310
- // // non-indexed BufferGeometry
2311
- // const positions = this.attributes.position.array;
2312
- // const normals = this.attributes.normal !== undefined ? this.attributes.normal.array : null;
2313
- // for (let i = 0, il = positions.length; i < il; i += 9) {
2314
- // // flat normals
2315
- // const x = positions[i + 0] - positions[i + 3];
2316
- // const y = positions[i + 1] - positions[i + 4];
2317
- // const z = positions[i + 2] - positions[i + 5];
2318
- // _cb.set(x, y, z).normalize();
2319
- // const a = x;
2320
- // const b = y;
2321
- // const c = z;
2322
- // x = positions[i + 0] - positions[i + 6];
2323
- // y = positions[i + 1] - positions[i + 7];
2324
- // z = positions[i + 2] - positions[i + 8];
2325
- // _ab.set(x, y, z).normalize();
2326
- // x = positions[i + 3] - positions[i + 6];
2327
- // y = positions[i + 4] - positions[i + 7];
2328
- // z = positions[i + 5] - positions[i + 8];
2329
- // _ab.set(x, y, z).normalize();
2330
- // _cb.cross(_ab).normalize();
2331
- // if (normals !== null) {
2332
- // normals[i + 0] = normals[i + 3] = normals[i + 6] = _cb.x;
2333
- // normals[i + 1] = normals[i + 4] = normals[i + 7] = _cb.y;
2334
- // normals[i + 2] = normals[i + 5] = normals[i + 8] = _cb.z;
2335
- // }
2336
- // }
2337
- // this.normalizeNormals();
2338
- // if (normals !== null) this.attributes.normal.needsUpdate = true;
2339
- // }
2340
- // return this;
2341
- // }
2342
- // computeMorphNormals(): this {
2343
- // const normal = new Vector3();
2344
- // return function computeMorphNormals() {
2345
- // const morphNormals = this.morphAttributes.normal;
2346
- // const normalAttribute = this.attributes.normal;
2347
- // if (morphNormals && normalAttribute) {
2348
- // const numMorphTargets = morphNormals.length;
2349
- // const numNormals = normalAttribute.count;
2350
- // for (let i = 0; i < numNormals; i++) {
2351
- // normal.set(0, 0, 0);
2352
- // for (let j = 0; j < numMorphTargets; j++) {
2353
- // const morphAttribute = morphNormals[j];
2354
- // // computing the tangent space for true normals is expensive
2355
- // // don't use for morphNormals if normal is null
2356
- // if (normalAttribute) {
2357
- // _normal.fromBufferAttribute(normalAttribute, i);
2358
- // _morphedNormal.fromBufferAttribute(morphAttribute, i);
2359
- // // compute normals
2360
- // _normal.applyQuaternion(this._rotationMatrix);
2361
- // _morphedNormal.applyQuaternion(this._rotationMatrix);
2362
- // // compute morph normal
2363
- // _morphedNormal.sub(_normal).multiplyScalar(this.morphTargetInfluences[j]);
2364
- // normal.add(_morphedNormal);
2365
- // }
2366
- // }
2367
- // normal.normalize();
2368
- // normalAttribute.setXYZ(i, normal.x, normal.y, normal.z);
2369
- // }
2370
- // normalAttribute.needsUpdate = true;
2371
- // }
2372
- // };
2373
- // }
2374
- // computeMorphTangents(): this {
2375
- // const normal = new Vector3();
2376
- // return function computeMorphTangents() {
2377
- // const morphNormals = this.morphAttributes.normal;
2378
- // const morphTangents = this.morphAttributes.tangent;
2379
- // const normalAttribute = this.attributes.normal;
2380
- // const tangentAttribute = this.attributes.tangent;
2381
- // if (morphTangents && morphNormals && normalAttribute && tangentAttribute) {
2382
- // const numMorphTargets = morphNormals.length;
2383
- // const numTangents = tangentAttribute.count;
2384
- // for (let i = 0; i < numTangents; i++) {
2385
- // normal.set(0, 0, 0);
2386
- // for (let j = 0; j < numMorphTargets; j++) {
2387
- // const morphAttribute = morphNormals[j];
2388
- // const morphTangent = morphTangents[j];
2389
- // // computing the tangent space for true normals is expensive
2390
- // // don't use for morphNormals if normal is null
2391
- // if (normalAttribute) {
2392
- // _normal.fromBufferAttribute(normalAttribute, i);
2393
- // _morphedNormal.fromBufferAttribute(morphAttribute, i);
2394
- // // compute normals
2395
- // _normal.applyQuaternion(this._rotationMatrix);
2396
- // _morphedNormal.applyQuaternion(this._rotationMatrix);
2397
- // // compute morph normal
2398
- // _morphedNormal.sub(_normal).multiplyScalar(this.morphTargetInfluences[j]);
2399
- // normal.add(_morphedNormal);
2400
- // // compute morph tangent
2401
- // if (morphTangent) {
2402
- // _tangent.fromBufferAttribute(morphTangent, i);
2403
- // _morphedTangent.fromBufferAttribute(morphTangent, i);
2404
- // _tangent.applyQuaternion(this._rotationMatrix);
2405
- // _morphedTangent.applyQuaternion(this._rotationMatrix);
2406
- // _morphedTangent.sub(_tangent).multiplyScalar(this.morphTargetInfluences[j]);
2407
- // normal.add(_morphedTangent);
2408
- // }
2409
- // }
2410
- // }
2411
- // normal.normalize();
2412
- // tangentAttribute.setXYZ(i, normal.x, normal.y, normal.z);
2413
- // }
2414
- // tangentAttribute.needsUpdate = true;
2415
- // }
2416
- // };
2417
- // }
2418
- // clearGroups(): void {
2419
- // this.groups.length = 0;
2420
- // this.drawRange.start = 0;
2421
- // this.drawRange.count = Infinity;
2422
- // }
2423
- // setDrawRange(start: number, count: number): void {
2424
- // this.drawRange.start = start;
2425
- // this.drawRange.count = count;
2426
- // }
2427
- // updateFromObject(object: Object3D): void {
2428
- // if (object.geometry === this) {
2429
- // console.error(
2430
- // 'THREE.BufferGeometry.updateFromObject(): The object and its geometry are already linked.'
2431
- // );
2432
- // return;
2433
- // }
2434
- // const geometry2 = object.geometry;
2435
- // if (object.isPoints || object.isLine) {
2436
- // const attributes = this.attributes;
2437
- // if (geometry2.isBufferGeometry) {
2438
- // attributes.position.updateRange = { offset: 0, count: geometry2.attributes.position.count };
2439
- // const array = geometry2.attributes.position.array;
2440
- // for (let i = 0; i < array.length; i++) {
2441
- // attributes.position.array[i] = array[i];
2442
- // }
2443
- // attributes.position.needsUpdate = true;
2444
- // }
2445
- // } else if (object.isMesh) {
2446
- // const newGeometry = geometry2.clone();
2447
- // this.fromGeometry(newGeometry);
2448
- // }
2449
- // }
2450
- // /**
2451
- // * @deprecated Use {@link BufferGeometry#toJSON .toJSON()} instead.
2452
- // */
2453
- // toJSON(): any {
2454
- // return this.toBufferGeometry().toJSON();
2455
- // }
2456
- // dispose(): void {
2457
- // this.dispatchEvent({ type: 'dispose' });
2458
- // }
2459
- // }
2651
+ let _id = 0;
2652
+ const _vector$8 = /*@__PURE__*/ new Vector3();
2653
+ class BufferGeometry extends EventDispatcher {
2654
+ constructor() {
2655
+ super();
2656
+ Object.defineProperty(this, 'id', { value: _id++ });
2657
+ this.uuid = generateUUID();
2658
+ this.name = '';
2659
+ this.type = 'BufferGeometry';
2660
+ this.index = null;
2661
+ this.attributes = {};
2662
+ this.morphAttributes = {};
2663
+ this.morphTargetsRelative = false;
2664
+ this.groups = [];
2665
+ this.boundingBox = null;
2666
+ this.boundingSphere = null;
2667
+ this.drawRange = { start: 0, count: Infinity };
2668
+ this.userData = {};
2669
+ }
2670
+ getIndex() {
2671
+ return this.index;
2672
+ }
2673
+ setAttribute(name, attribute) {
2674
+ this.attributes[name] = attribute;
2675
+ return this;
2676
+ }
2677
+ getAttribute(name) {
2678
+ return this.attributes[name];
2679
+ }
2680
+ computeVertexNormals() {
2681
+ const index = this.index;
2682
+ const positionAttribute = this.getAttribute('position');
2683
+ if (positionAttribute !== undefined) {
2684
+ let normalAttribute = this.getAttribute('normal');
2685
+ if (normalAttribute === undefined) {
2686
+ normalAttribute = new BufferAttribute(new Float32Array(positionAttribute.count * 3), 3);
2687
+ this.setAttribute('normal', normalAttribute);
2688
+ }
2689
+ else {
2690
+ // reset existing normals to zero
2691
+ for (let i = 0, il = normalAttribute.count; i < il; i++) {
2692
+ normalAttribute.setXYZ(i, 0, 0, 0);
2693
+ }
2694
+ }
2695
+ const pA = new Vector3(), pB = new Vector3(), pC = new Vector3();
2696
+ const nA = new Vector3(), nB = new Vector3(), nC = new Vector3();
2697
+ const cb = new Vector3(), ab = new Vector3();
2698
+ // indexed elements
2699
+ if (index) {
2700
+ for (let i = 0, il = index.count; i < il; i += 3) {
2701
+ const vA = index.getX(i + 0);
2702
+ const vB = index.getX(i + 1);
2703
+ const vC = index.getX(i + 2);
2704
+ pA.fromBufferAttribute(positionAttribute, vA);
2705
+ pB.fromBufferAttribute(positionAttribute, vB);
2706
+ pC.fromBufferAttribute(positionAttribute, vC);
2707
+ cb.subVectors(pC, pB);
2708
+ ab.subVectors(pA, pB);
2709
+ cb.cross(ab);
2710
+ nA.fromBufferAttribute(normalAttribute, vA);
2711
+ nB.fromBufferAttribute(normalAttribute, vB);
2712
+ nC.fromBufferAttribute(normalAttribute, vC);
2713
+ nA.add(cb);
2714
+ nB.add(cb);
2715
+ nC.add(cb);
2716
+ normalAttribute.setXYZ(vA, nA.x, nA.y, nA.z);
2717
+ normalAttribute.setXYZ(vB, nB.x, nB.y, nB.z);
2718
+ normalAttribute.setXYZ(vC, nC.x, nC.y, nC.z);
2719
+ }
2720
+ }
2721
+ else {
2722
+ // non-indexed elements (unconnected triangle soup)
2723
+ for (let i = 0, il = positionAttribute.count; i < il; i += 3) {
2724
+ pA.fromBufferAttribute(positionAttribute, i + 0);
2725
+ pB.fromBufferAttribute(positionAttribute, i + 1);
2726
+ pC.fromBufferAttribute(positionAttribute, i + 2);
2727
+ cb.subVectors(pC, pB);
2728
+ ab.subVectors(pA, pB);
2729
+ cb.cross(ab);
2730
+ normalAttribute.setXYZ(i + 0, cb.x, cb.y, cb.z);
2731
+ normalAttribute.setXYZ(i + 1, cb.x, cb.y, cb.z);
2732
+ normalAttribute.setXYZ(i + 2, cb.x, cb.y, cb.z);
2733
+ }
2734
+ }
2735
+ this.normalizeNormals();
2736
+ normalAttribute.needsUpdate = true;
2737
+ }
2738
+ }
2739
+ normalizeNormals() {
2740
+ const normals = this.attributes.normal;
2741
+ for (let i = 0, il = normals.count; i < il; i++) {
2742
+ _vector$8.fromBufferAttribute(normals, i);
2743
+ _vector$8.normalize();
2744
+ normals.setXYZ(i, _vector$8.x, _vector$8.y, _vector$8.z);
2745
+ }
2746
+ }
2747
+ }
2460
2748
  //#endregion
2461
2749
  }
2462
2750
  exports.workerCode = workerFunction;