@woosh/meep-engine 2.135.0 → 2.138.0

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.
Files changed (238) hide show
  1. package/package.json +1 -1
  2. package/src/core/geom/2d/aabb/aabb2_intersects_ray.d.ts.map +1 -1
  3. package/src/core/geom/2d/aabb/aabb2_intersects_ray.js +5 -7
  4. package/src/core/geom/2d/hash-grid/shg_query_elements_circle.d.ts.map +1 -1
  5. package/src/core/geom/2d/hash-grid/shg_query_elements_circle.js +2 -3
  6. package/src/core/geom/3d/aabb/aabb3_intersects_line_segment.d.ts.map +1 -1
  7. package/src/core/geom/3d/aabb/aabb3_intersects_line_segment.js +9 -11
  8. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -1
  9. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js +6 -4
  10. package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.d.ts.map +1 -1
  11. package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.js +1 -2
  12. package/src/core/geom/Quaternion.d.ts +26 -39
  13. package/src/core/geom/Quaternion.d.ts.map +1 -1
  14. package/src/core/geom/Quaternion.js +124 -136
  15. package/src/core/geom/Vector2.d.ts +28 -14
  16. package/src/core/geom/Vector2.d.ts.map +1 -1
  17. package/src/core/geom/Vector2.js +114 -97
  18. package/src/core/geom/Vector3.d.ts +21 -34
  19. package/src/core/geom/Vector3.d.ts.map +1 -1
  20. package/src/core/geom/Vector3.js +131 -142
  21. package/src/core/geom/Vector4.d.ts +21 -30
  22. package/src/core/geom/Vector4.d.ts.map +1 -1
  23. package/src/core/geom/Vector4.js +80 -93
  24. package/src/core/geom/packing/computeBoundingSphereOfSpheres.d.ts.map +1 -1
  25. package/src/core/geom/packing/computeBoundingSphereOfSpheres.js +23 -6
  26. package/src/core/geom/packing/miniball/Miniball.d.ts.map +1 -1
  27. package/src/core/geom/packing/miniball/Miniball.js +4 -11
  28. package/src/core/geom/packing/miniball/Subspan.d.ts +14 -39
  29. package/src/core/geom/packing/miniball/Subspan.d.ts.map +1 -1
  30. package/src/core/geom/packing/miniball/Subspan.js +105 -158
  31. package/src/core/geom/packing/miniball/miniball_compute_quality.d.ts.map +1 -1
  32. package/src/core/geom/packing/miniball/miniball_compute_quality.js +2 -6
  33. package/src/core/geom/vec/vector_axpy.d.ts +12 -0
  34. package/src/core/geom/vec/vector_axpy.d.ts.map +1 -0
  35. package/src/core/geom/vec/vector_axpy.js +15 -0
  36. package/src/core/geom/vec/vector_axpy_offset.d.ts +17 -0
  37. package/src/core/geom/vec/vector_axpy_offset.d.ts.map +1 -0
  38. package/src/core/geom/vec/vector_axpy_offset.js +20 -0
  39. package/src/core/geom/vec/vector_dot_offset.d.ts +18 -0
  40. package/src/core/geom/vec/vector_dot_offset.d.ts.map +1 -0
  41. package/src/core/geom/vec/vector_dot_offset.js +25 -0
  42. package/src/core/math/complex/complex_horner_eval.d.ts +16 -0
  43. package/src/core/math/complex/complex_horner_eval.d.ts.map +1 -0
  44. package/src/core/math/complex/complex_horner_eval.js +31 -0
  45. package/src/core/math/fabsf.d.ts +2 -3
  46. package/src/core/math/fabsf.d.ts.map +1 -1
  47. package/src/core/math/fabsf.js +3 -5
  48. package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.d.ts +26 -0
  49. package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.d.ts.map +1 -0
  50. package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.js +43 -0
  51. package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts +2 -1
  52. package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts.map +1 -1
  53. package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.js +2 -1
  54. package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts +10 -4
  55. package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts.map +1 -1
  56. package/src/core/math/linalg/eigen/matrix_householder_in_place.js +122 -98
  57. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +2 -2
  58. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -1
  59. package/src/core/math/linalg/eigen/matrix_qr_in_place.js +144 -124
  60. package/src/core/math/linalg/givens/givens_apply_rows.d.ts +22 -0
  61. package/src/core/math/linalg/givens/givens_apply_rows.d.ts.map +1 -0
  62. package/src/core/math/linalg/givens/givens_apply_rows.js +28 -0
  63. package/src/core/math/linalg/givens/givens_apply_rows_offset.d.ts +24 -0
  64. package/src/core/math/linalg/givens/givens_apply_rows_offset.d.ts.map +1 -0
  65. package/src/core/math/linalg/givens/givens_apply_rows_offset.js +30 -0
  66. package/src/core/math/linalg/givens/givens_rotation_coefficients.d.ts +25 -0
  67. package/src/core/math/linalg/givens/givens_rotation_coefficients.d.ts.map +1 -0
  68. package/src/core/math/linalg/givens/givens_rotation_coefficients.js +39 -0
  69. package/src/core/math/linalg/lu_factor_linear_system.d.ts +1 -1
  70. package/src/core/math/linalg/lu_factor_linear_system.d.ts.map +1 -1
  71. package/src/core/math/linalg/lu_factor_linear_system.js +108 -117
  72. package/src/core/math/linalg/lu_solve_linear_system.d.ts +1 -1
  73. package/src/core/math/linalg/lu_solve_linear_system.js +53 -53
  74. package/src/core/math/linalg/polynomial_add_into.d.ts +18 -0
  75. package/src/core/math/linalg/polynomial_add_into.d.ts.map +1 -0
  76. package/src/core/math/linalg/polynomial_add_into.js +29 -0
  77. package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts +6 -1
  78. package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts.map +1 -1
  79. package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.js +48 -50
  80. package/src/core/math/linalg/polynomial_cubic_derivative_eval.d.ts +15 -0
  81. package/src/core/math/linalg/polynomial_cubic_derivative_eval.d.ts.map +1 -0
  82. package/src/core/math/linalg/polynomial_cubic_derivative_eval.js +16 -0
  83. package/src/core/math/linalg/polynomial_cubic_horner_eval.d.ts +18 -0
  84. package/src/core/math/linalg/polynomial_cubic_horner_eval.d.ts.map +1 -0
  85. package/src/core/math/linalg/polynomial_cubic_horner_eval.js +19 -0
  86. package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.d.ts +13 -0
  87. package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.d.ts.map +1 -0
  88. package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.js +14 -0
  89. package/src/core/math/linalg/polynomial_multiply.d.ts +21 -0
  90. package/src/core/math/linalg/polynomial_multiply.d.ts.map +1 -0
  91. package/src/core/math/linalg/polynomial_multiply.js +41 -0
  92. package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts +6 -1
  93. package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts.map +1 -1
  94. package/src/core/math/linalg/polynomial_real_roots_in_interval.js +29 -18
  95. package/src/core/math/linalg/polynomial_root_bound_cauchy.d.ts +17 -0
  96. package/src/core/math/linalg/polynomial_root_bound_cauchy.d.ts.map +1 -0
  97. package/src/core/math/linalg/polynomial_root_bound_cauchy.js +30 -0
  98. package/src/core/math/linalg/polynomial_scale_into.d.ts +14 -0
  99. package/src/core/math/linalg/polynomial_scale_into.d.ts.map +1 -0
  100. package/src/core/math/linalg/polynomial_scale_into.js +17 -0
  101. package/src/core/math/linalg/polynomial_sub_into.d.ts +18 -0
  102. package/src/core/math/linalg/polynomial_sub_into.d.ts.map +1 -0
  103. package/src/core/math/linalg/polynomial_sub_into.js +29 -0
  104. package/src/core/math/linalg/solve_linear_system.d.ts +1 -1
  105. package/src/core/math/linalg/solve_linear_system.js +1 -1
  106. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts +4 -4
  107. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts.map +1 -1
  108. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +96 -91
  109. package/src/core/math/solveQuadratic.d.ts +2 -2
  110. package/src/core/math/solveQuadratic.d.ts.map +1 -1
  111. package/src/core/math/solveQuadratic.js +1 -1
  112. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts +18 -10
  113. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts.map +1 -1
  114. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.js +18 -10
  115. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts +13 -6
  116. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts.map +1 -1
  117. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.js +16 -11
  118. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts +25 -3
  119. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts.map +1 -1
  120. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.js +97 -142
  121. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts +30 -4
  122. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts.map +1 -1
  123. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.js +188 -132
  124. package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts +7 -3
  125. package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts.map +1 -1
  126. package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.js +35 -6
  127. package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.d.ts +17 -0
  128. package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.d.ts.map +1 -0
  129. package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.js +87 -0
  130. package/src/core/science/units/MEASUREMENT_UNITS_SI.d.ts +13 -0
  131. package/src/core/science/units/MEASUREMENT_UNITS_SI.d.ts.map +1 -0
  132. package/src/core/science/units/MEASUREMENT_UNITS_SI.js +28 -0
  133. package/src/core/science/units/NamedUnit.d.ts +38 -0
  134. package/src/core/science/units/NamedUnit.d.ts.map +1 -0
  135. package/src/core/science/units/NamedUnit.js +48 -0
  136. package/src/core/science/units/UNIT_DIMENSION_MAPPING.d.ts +14 -0
  137. package/src/core/science/units/UNIT_DIMENSION_MAPPING.d.ts.map +1 -0
  138. package/src/core/science/units/UNIT_DIMENSION_MAPPING.js +29 -0
  139. package/src/core/science/units/UnitDimension.d.ts +26 -0
  140. package/src/core/science/units/UnitDimension.d.ts.map +1 -0
  141. package/src/core/science/units/UnitDimension.js +28 -0
  142. package/src/core/science/units/UnitMatrix.d.ts +117 -0
  143. package/src/core/science/units/UnitMatrix.d.ts.map +1 -0
  144. package/src/core/science/units/UnitMatrix.js +251 -0
  145. package/src/core/science/units/format_quantity.d.ts +25 -0
  146. package/src/core/science/units/format_quantity.d.ts.map +1 -0
  147. package/src/core/science/units/format_quantity.js +74 -0
  148. package/src/core/science/units/magnitude_prefix.d.ts +57 -0
  149. package/src/core/science/units/magnitude_prefix.d.ts.map +1 -0
  150. package/src/core/science/units/magnitude_prefix.js +127 -0
  151. package/src/core/science/units/si/AMPERE.d.ts +7 -0
  152. package/src/core/science/units/si/AMPERE.d.ts.map +1 -0
  153. package/src/core/science/units/si/AMPERE.js +13 -0
  154. package/src/core/science/units/si/CANDELA.d.ts +7 -0
  155. package/src/core/science/units/si/CANDELA.d.ts.map +1 -0
  156. package/src/core/science/units/si/CANDELA.js +13 -0
  157. package/src/core/science/units/si/DIMENSIONLESS.d.ts +8 -0
  158. package/src/core/science/units/si/DIMENSIONLESS.d.ts.map +1 -0
  159. package/src/core/science/units/si/DIMENSIONLESS.js +14 -0
  160. package/src/core/science/units/si/KELVIN.d.ts +7 -0
  161. package/src/core/science/units/si/KELVIN.d.ts.map +1 -0
  162. package/src/core/science/units/si/KELVIN.js +13 -0
  163. package/src/core/science/units/si/KILOGRAM.d.ts +7 -0
  164. package/src/core/science/units/si/KILOGRAM.d.ts.map +1 -0
  165. package/src/core/science/units/si/KILOGRAM.js +13 -0
  166. package/src/core/science/units/si/METER.d.ts +7 -0
  167. package/src/core/science/units/si/METER.d.ts.map +1 -0
  168. package/src/core/science/units/si/METER.js +13 -0
  169. package/src/core/science/units/si/MOLE.d.ts +7 -0
  170. package/src/core/science/units/si/MOLE.d.ts.map +1 -0
  171. package/src/core/science/units/si/MOLE.js +13 -0
  172. package/src/core/science/units/si/SECOND.d.ts +7 -0
  173. package/src/core/science/units/si/SECOND.d.ts.map +1 -0
  174. package/src/core/science/units/si/SECOND.js +13 -0
  175. package/src/core/science/units/si/derived/BECQUEREL.d.ts +10 -0
  176. package/src/core/science/units/si/derived/BECQUEREL.d.ts.map +1 -0
  177. package/src/core/science/units/si/derived/BECQUEREL.js +16 -0
  178. package/src/core/science/units/si/derived/COULOMB.d.ts +7 -0
  179. package/src/core/science/units/si/derived/COULOMB.d.ts.map +1 -0
  180. package/src/core/science/units/si/derived/COULOMB.js +13 -0
  181. package/src/core/science/units/si/derived/FARAD.d.ts +7 -0
  182. package/src/core/science/units/si/derived/FARAD.d.ts.map +1 -0
  183. package/src/core/science/units/si/derived/FARAD.js +13 -0
  184. package/src/core/science/units/si/derived/GRAY.d.ts +10 -0
  185. package/src/core/science/units/si/derived/GRAY.d.ts.map +1 -0
  186. package/src/core/science/units/si/derived/GRAY.js +16 -0
  187. package/src/core/science/units/si/derived/HENRY.d.ts +7 -0
  188. package/src/core/science/units/si/derived/HENRY.d.ts.map +1 -0
  189. package/src/core/science/units/si/derived/HENRY.js +13 -0
  190. package/src/core/science/units/si/derived/HERTZ.d.ts +10 -0
  191. package/src/core/science/units/si/derived/HERTZ.d.ts.map +1 -0
  192. package/src/core/science/units/si/derived/HERTZ.js +16 -0
  193. package/src/core/science/units/si/derived/JOULE.d.ts +7 -0
  194. package/src/core/science/units/si/derived/JOULE.d.ts.map +1 -0
  195. package/src/core/science/units/si/derived/JOULE.js +13 -0
  196. package/src/core/science/units/si/derived/KATAL.d.ts +7 -0
  197. package/src/core/science/units/si/derived/KATAL.d.ts.map +1 -0
  198. package/src/core/science/units/si/derived/KATAL.js +13 -0
  199. package/src/core/science/units/si/derived/LUMEN.d.ts +8 -0
  200. package/src/core/science/units/si/derived/LUMEN.d.ts.map +1 -0
  201. package/src/core/science/units/si/derived/LUMEN.js +14 -0
  202. package/src/core/science/units/si/derived/LUX.d.ts +7 -0
  203. package/src/core/science/units/si/derived/LUX.d.ts.map +1 -0
  204. package/src/core/science/units/si/derived/LUX.js +13 -0
  205. package/src/core/science/units/si/derived/NEWTON.d.ts +7 -0
  206. package/src/core/science/units/si/derived/NEWTON.d.ts.map +1 -0
  207. package/src/core/science/units/si/derived/NEWTON.js +13 -0
  208. package/src/core/science/units/si/derived/OHM.d.ts +7 -0
  209. package/src/core/science/units/si/derived/OHM.d.ts.map +1 -0
  210. package/src/core/science/units/si/derived/OHM.js +13 -0
  211. package/src/core/science/units/si/derived/PASCAL.d.ts +7 -0
  212. package/src/core/science/units/si/derived/PASCAL.d.ts.map +1 -0
  213. package/src/core/science/units/si/derived/PASCAL.js +13 -0
  214. package/src/core/science/units/si/derived/SIEMENS.d.ts +7 -0
  215. package/src/core/science/units/si/derived/SIEMENS.d.ts.map +1 -0
  216. package/src/core/science/units/si/derived/SIEMENS.js +13 -0
  217. package/src/core/science/units/si/derived/SIEVERT.d.ts +10 -0
  218. package/src/core/science/units/si/derived/SIEVERT.d.ts.map +1 -0
  219. package/src/core/science/units/si/derived/SIEVERT.js +16 -0
  220. package/src/core/science/units/si/derived/TESLA.d.ts +7 -0
  221. package/src/core/science/units/si/derived/TESLA.d.ts.map +1 -0
  222. package/src/core/science/units/si/derived/TESLA.js +13 -0
  223. package/src/core/science/units/si/derived/VOLT.d.ts +7 -0
  224. package/src/core/science/units/si/derived/VOLT.d.ts.map +1 -0
  225. package/src/core/science/units/si/derived/VOLT.js +13 -0
  226. package/src/core/science/units/si/derived/WATT.d.ts +7 -0
  227. package/src/core/science/units/si/derived/WATT.d.ts.map +1 -0
  228. package/src/core/science/units/si/derived/WATT.js +13 -0
  229. package/src/core/science/units/si/derived/WEBER.d.ts +7 -0
  230. package/src/core/science/units/si/derived/WEBER.d.ts.map +1 -0
  231. package/src/core/science/units/si/derived/WEBER.js +13 -0
  232. package/src/core/science/units/unit_matrix_to_string.d.ts +29 -0
  233. package/src/core/science/units/unit_matrix_to_string.d.ts.map +1 -0
  234. package/src/core/science/units/unit_matrix_to_string.js +403 -0
  235. package/src/engine/graphics/geometry/MikkT/CalcTexArea.d.ts.map +1 -1
  236. package/src/engine/graphics/geometry/MikkT/CalcTexArea.js +1 -2
  237. package/src/engine/graphics/geometry/MikkT/InitTriInfo.d.ts.map +1 -1
  238. package/src/engine/graphics/geometry/MikkT/InitTriInfo.js +6 -7
@@ -23,12 +23,14 @@ import { v3_slerp } from "./vec3/v3_slerp.js";
23
23
  *
24
24
  * Iterating through a Vector3 instance will yield its components `(x, y, z)` in the corresponding order.
25
25
  *
26
+ * Backed by a `Float64Array` of length 3, so instances are usable directly as typed-array views and indexed access `v[0]`, `v[1]`, `v[2]` aliases `v.x`, `v.y`, `v.z`.
27
+ *
26
28
  * @implements Iterable<number>
27
29
  *
28
30
  * @author Alex Goldring
29
31
  * @copyright Company Named Limited (c) 2025
30
32
  */
31
- export class Vector3 {
33
+ export class Vector3 extends Float64Array {
32
34
  /**
33
35
  *
34
36
  * @param {number} [x=0]
@@ -45,26 +47,11 @@ export class Vector3 {
45
47
  assert.isNumber(z, 'z');
46
48
  assert.notNaN(z, 'z');
47
49
 
48
- /**
49
- * Do not assign directly, use {@link set} method instead
50
- * @readonly
51
- * @type {number}
52
- */
53
- this.x = x;
54
-
55
- /**
56
- * Do not assign directly, use {@link set} method instead
57
- * @readonly
58
- * @type {number}
59
- */
60
- this.y = y;
50
+ super(3);
61
51
 
62
- /**
63
- * Do not assign directly, use {@link set} method instead
64
- * @readonly
65
- * @type {number}
66
- */
67
- this.z = z;
52
+ this[0] = x;
53
+ this[1] = y;
54
+ this[2] = z;
68
55
 
69
56
  /**
70
57
  * Dispatches ( x, y, z, old_x, old_y, old_z )
@@ -75,63 +62,60 @@ export class Vector3 {
75
62
  }
76
63
 
77
64
  /**
78
- *
79
- * @return {number}
65
+ * Ensure that built-in `TypedArray` methods (`map`, `slice`, `subarray`, ...) do not
66
+ * try to construct a `Vector3` via the buffer-form constructor.
67
+ * @returns {Float64ArrayConstructor}
80
68
  */
81
- get 0() {
82
- return this.x;
69
+ static get [Symbol.species]() {
70
+ return Float64Array;
83
71
  }
84
72
 
85
73
  /**
86
74
  *
87
- * @return {number}
75
+ * @returns {number}
88
76
  */
89
- get 1() {
90
- return this.y;
77
+ get x() {
78
+ return this[0];
91
79
  }
92
80
 
93
81
  /**
94
82
  *
95
- * @return {number}
83
+ * @param {number} v
96
84
  */
97
- get 2() {
98
- return this.z;
85
+ set x(v) {
86
+ this[0] = v;
99
87
  }
100
88
 
101
89
  /**
102
90
  *
103
- * @param {number} v
91
+ * @returns {number}
104
92
  */
105
- set 0(v) {
106
- this.x = v;
93
+ get y() {
94
+ return this[1];
107
95
  }
108
96
 
109
97
  /**
110
98
  *
111
99
  * @param {number} v
112
100
  */
113
- set 1(v) {
114
- this.y = v;
101
+ set y(v) {
102
+ this[1] = v;
115
103
  }
116
104
 
117
105
  /**
118
106
  *
119
- * @param {number} v
107
+ * @returns {number}
120
108
  */
121
- set 2(v) {
122
- this.z = v;
109
+ get z() {
110
+ return this[2];
123
111
  }
124
112
 
125
113
  /**
126
114
  *
127
- * @return {Generator<number>}
115
+ * @param {number} v
128
116
  */
129
- * [Symbol.iterator]() {
130
-
131
- yield this.x;
132
- yield this.y;
133
- yield this.z;
134
-
117
+ set z(v) {
118
+ this[2] = v;
135
119
  }
136
120
 
137
121
  /**
@@ -159,9 +143,9 @@ export class Vector3 {
159
143
  toArray(array = [], offset = 0) {
160
144
  assert.isNonNegativeInteger(offset, "offset");
161
145
 
162
- array[offset] = this.x;
163
- array[offset + 1] = this.y;
164
- array[offset + 2] = this.z;
146
+ array[offset] = this[0];
147
+ array[offset + 1] = this[1];
148
+ array[offset + 2] = this[2];
165
149
 
166
150
  return array;
167
151
  }
@@ -182,16 +166,16 @@ export class Vector3 {
182
166
  assert.notNaN(y, "y");
183
167
  assert.notNaN(z, "z");
184
168
 
185
- const oldX = this.x;
186
- const oldY = this.y;
187
- const oldZ = this.z;
169
+ const oldX = this[0];
170
+ const oldY = this[1];
171
+ const oldZ = this[2];
188
172
 
189
173
  if (x !== oldX || y !== oldY || z !== oldZ) {
190
174
  // change has occurred
191
175
 
192
- this.x = x;
193
- this.y = y;
194
- this.z = z;
176
+ this[0] = x;
177
+ this[1] = y;
178
+ this[2] = z;
195
179
 
196
180
  if (this.onChanged.hasHandlers()) {
197
181
  this.onChanged.send6(
@@ -220,7 +204,7 @@ export class Vector3 {
220
204
  * @returns {this}
221
205
  */
222
206
  setX(v) {
223
- return this.set(v, this.y, this.z);
207
+ return this.set(v, this[1], this[2]);
224
208
  }
225
209
 
226
210
  /**
@@ -229,7 +213,7 @@ export class Vector3 {
229
213
  * @returns {this}
230
214
  */
231
215
  setY(v) {
232
- return this.set(this.x, v, this.z);
216
+ return this.set(this[0], v, this[2]);
233
217
  }
234
218
 
235
219
  /**
@@ -238,7 +222,7 @@ export class Vector3 {
238
222
  * @returns {this}
239
223
  */
240
224
  setZ(v) {
241
- return this.set(this.x, this.y, v);
225
+ return this.set(this[0], this[1], v);
242
226
  }
243
227
 
244
228
  /**
@@ -248,7 +232,7 @@ export class Vector3 {
248
232
  * @returns {this}
249
233
  */
250
234
  setXY(x, y) {
251
- return this.set(x, y, this.z);
235
+ return this.set(x, y, this[2]);
252
236
  }
253
237
 
254
238
  /**
@@ -258,7 +242,7 @@ export class Vector3 {
258
242
  * @returns {this}
259
243
  */
260
244
  setXZ(x, z) {
261
- return this.set(x, this.y, z);
245
+ return this.set(x, this[1], z);
262
246
  }
263
247
 
264
248
  /**
@@ -268,7 +252,7 @@ export class Vector3 {
268
252
  * @returns {this}
269
253
  */
270
254
  setYZ(y, z) {
271
- return this.set(this.x, y, z);
255
+ return this.set(this[0], y, z);
272
256
  }
273
257
 
274
258
  /**
@@ -302,7 +286,7 @@ export class Vector3 {
302
286
  * @returns {this}
303
287
  */
304
288
  _add(x, y, z) {
305
- return this.set(this.x + x, this.y + y, this.z + z);
289
+ return this.set(this[0] + x, this[1] + y, this[2] + z);
306
290
  }
307
291
 
308
292
 
@@ -337,9 +321,9 @@ export class Vector3 {
337
321
  * @returns {this}
338
322
  */
339
323
  _sub(x, y, z) {
340
- const _x = this.x - x;
341
- const _y = this.y - y;
342
- const _z = this.z - z;
324
+ const _x = this[0] - x;
325
+ const _y = this[1] - y;
326
+ const _z = this[2] - z;
343
327
 
344
328
  return this.set(_x, _y, _z);
345
329
  }
@@ -352,7 +336,7 @@ export class Vector3 {
352
336
  * @returns {this}
353
337
  */
354
338
  _multiply(x, y, z) {
355
- return this.set(this.x * x, this.y * y, this.z * z);
339
+ return this.set(this[0] * x, this[1] * y, this[2] * z);
356
340
  }
357
341
 
358
342
  /**
@@ -387,9 +371,9 @@ export class Vector3 {
387
371
  */
388
372
  _divide(x, y, z) {
389
373
  return this.set(
390
- this.x / x,
391
- this.y / y,
392
- this.z / z,
374
+ this[0] / x,
375
+ this[1] / y,
376
+ this[2] / z,
393
377
  )
394
378
  }
395
379
 
@@ -423,7 +407,7 @@ export class Vector3 {
423
407
  * @returns {this}
424
408
  */
425
409
  addScalar(val) {
426
- return this.set(this.x + val, this.y + val, this.z + val);
410
+ return this.set(this[0] + val, this[1] + val, this[2] + val);
427
411
  }
428
412
 
429
413
  /**
@@ -440,7 +424,7 @@ export class Vector3 {
440
424
  * @returns {Vector3}
441
425
  */
442
426
  clone() {
443
- return new Vector3(this.x, this.y, this.z);
427
+ return new Vector3(this[0], this[1], this[2]);
444
428
  }
445
429
 
446
430
  /**
@@ -452,7 +436,7 @@ export class Vector3 {
452
436
  assert.isNumber(val, "val");
453
437
  assert.notNaN(val, "val");
454
438
 
455
- return this.set(this.x * val, this.y * val, this.z * val);
439
+ return this.set(this[0] * val, this[1] * val, this[2] * val);
456
440
  }
457
441
 
458
442
  /**
@@ -460,9 +444,9 @@ export class Vector3 {
460
444
  * @returns {boolean}
461
445
  */
462
446
  isZero() {
463
- return this.x === 0
464
- && this.y === 0
465
- && this.z === 0
447
+ return this[0] === 0
448
+ && this[1] === 0
449
+ && this[2] === 0
466
450
  ;
467
451
  }
468
452
 
@@ -516,9 +500,9 @@ export class Vector3 {
516
500
  */
517
501
  abs() {
518
502
  return this.set(
519
- Math.abs(this.x),
520
- Math.abs(this.y),
521
- Math.abs(this.z)
503
+ Math.abs(this[0]),
504
+ Math.abs(this[1]),
505
+ Math.abs(this[2])
522
506
  );
523
507
  }
524
508
 
@@ -536,7 +520,7 @@ export class Vector3 {
536
520
  * @returns {number}
537
521
  */
538
522
  length() {
539
- return v3_length(this.x, this.y, this.z);
523
+ return v3_length(this[0], this[1], this[2]);
540
524
  }
541
525
 
542
526
  /**
@@ -545,7 +529,7 @@ export class Vector3 {
545
529
  * @returns {number}
546
530
  */
547
531
  lengthSqr() {
548
- return v3_length_sqr(this.x, this.y, this.z);
532
+ return v3_length_sqr(this[0], this[1], this[2]);
549
533
  }
550
534
 
551
535
  /**
@@ -553,7 +537,12 @@ export class Vector3 {
553
537
  * @returns {this}
554
538
  */
555
539
  normalize() {
556
- const l = this.length();
540
+ // NOTE: call v3_length directly rather than via `this.length()`.
541
+ // Float64Array exposes `length` as an exotic instance property that V8 inlines
542
+ // through a fast path which bypasses the prototype chain; once an optimized
543
+ // function caller has been specialized for Float64Array shape, `this.length`
544
+ // is read as the array length (a number) rather than our prototype method.
545
+ const l = v3_length(this[0], this[1], this[2]);
557
546
 
558
547
  if (l === 0) {
559
548
  //special case, can't normalize 0 length vector
@@ -591,9 +580,9 @@ export class Vector3 {
591
580
  */
592
581
  negate() {
593
582
  return this.set(
594
- -this.x,
595
- -this.y,
596
- -this.z
583
+ -this[0],
584
+ -this[1],
585
+ -this[2]
597
586
  );
598
587
  }
599
588
 
@@ -615,7 +604,7 @@ export class Vector3 {
615
604
  */
616
605
  _distanceTo(x, y, z) {
617
606
  return v3_distance(
618
- this.x, this.y, this.z,
607
+ this[0], this[1], this[2],
619
608
  x, y, z
620
609
  );
621
610
  }
@@ -640,9 +629,9 @@ export class Vector3 {
640
629
  */
641
630
  _distanceSqrTo(x, y, z) {
642
631
  return v3_length_sqr(
643
- this.x - x,
644
- this.y - y,
645
- this.z - z
632
+ this[0] - x,
633
+ this[1] - y,
634
+ this[2] - z
646
635
  );
647
636
  }
648
637
 
@@ -653,7 +642,7 @@ export class Vector3 {
653
642
  */
654
643
  angleTo(other) {
655
644
  return v3_angle_between(
656
- this.x, this.y, this.z,
645
+ this[0], this[1], this[2],
657
646
  other.x, other.y, other.z
658
647
  );
659
648
  }
@@ -668,9 +657,9 @@ export class Vector3 {
668
657
 
669
658
  //transform point into quaternion
670
659
 
671
- const x = this.x;
672
- const y = this.y;
673
- const z = this.z;
660
+ const x = this[0];
661
+ const y = this[1];
662
+ const z = this[2];
674
663
 
675
664
  const qx = q.x;
676
665
  const qy = q.y;
@@ -700,9 +689,9 @@ export class Vector3 {
700
689
  */
701
690
  sign() {
702
691
  return this.set(
703
- sign(this.x),
704
- sign(this.y),
705
- sign(this.z)
692
+ sign(this[0]),
693
+ sign(this[1]),
694
+ sign(this[2])
706
695
  );
707
696
  }
708
697
 
@@ -758,9 +747,9 @@ export class Vector3 {
758
747
  * @returns {this}
759
748
  */
760
749
  applyMatrix4(m4) {
761
- const x = this.x;
762
- const y = this.y;
763
- const z = this.z;
750
+ const x = this[0];
751
+ const y = this[1];
752
+ const z = this[2];
764
753
 
765
754
  const w = 1 / (m4[3] * x + m4[7] * y + m4[11] * z + m4[15]);
766
755
 
@@ -778,9 +767,9 @@ export class Vector3 {
778
767
  * @returns {this}
779
768
  */
780
769
  applyDirectionMatrix4(m4) {
781
- const x = this.x;
782
- const y = this.y;
783
- const z = this.z;
770
+ const x = this[0];
771
+ const y = this[1];
772
+ const z = this[2];
784
773
 
785
774
  // This is just 3x3 matrix multiplication
786
775
  const _x = m4[0] * x + m4[4] * y + m4[8] * z;
@@ -803,9 +792,9 @@ export class Vector3 {
803
792
  * @returns {this}
804
793
  */
805
794
  applyMatrix3(mat) {
806
- const x = this.x;
807
- const y = this.y;
808
- const z = this.z;
795
+ const x = this[0];
796
+ const y = this[1];
797
+ const z = this[2];
809
798
 
810
799
  const _x = mat[0] * x + mat[3] * y + mat[6] * z;
811
800
  const _y = mat[1] * x + mat[4] * y + mat[7] * z;
@@ -846,7 +835,7 @@ export class Vector3 {
846
835
  * @return {boolean}
847
836
  */
848
837
  _equals(x, y, z) {
849
- return this.x === x && this.y === y && this.z === z;
838
+ return this[0] === x && this[1] === y && this[2] === z;
850
839
  }
851
840
 
852
841
  /**
@@ -868,9 +857,9 @@ export class Vector3 {
868
857
  * @return {boolean}
869
858
  */
870
859
  _roughlyEquals(x, y, z, tolerance = EPSILON) {
871
- return epsilonEquals(this.x, x, tolerance)
872
- && epsilonEquals(this.y, y, tolerance)
873
- && epsilonEquals(this.z, z, tolerance);
860
+ return epsilonEquals(this[0], x, tolerance)
861
+ && epsilonEquals(this[1], y, tolerance)
862
+ && epsilonEquals(this[2], z, tolerance);
874
863
  }
875
864
 
876
865
  /**
@@ -879,9 +868,9 @@ export class Vector3 {
879
868
  */
880
869
  round() {
881
870
  return this.set(
882
- Math.round(this.x),
883
- Math.round(this.y),
884
- Math.round(this.z),
871
+ Math.round(this[0]),
872
+ Math.round(this[1]),
873
+ Math.round(this[2]),
885
874
  );
886
875
  }
887
876
 
@@ -890,9 +879,9 @@ export class Vector3 {
890
879
  * @returns {this}
891
880
  */
892
881
  floor() {
893
- const x = Math.floor(this.x);
894
- const y = Math.floor(this.y);
895
- const z = Math.floor(this.z);
882
+ const x = Math.floor(this[0]);
883
+ const y = Math.floor(this[1]);
884
+ const z = Math.floor(this[2]);
896
885
 
897
886
  return this.set(x, y, z);
898
887
  }
@@ -903,9 +892,9 @@ export class Vector3 {
903
892
  */
904
893
  ceil() {
905
894
  return this.set(
906
- Math.ceil(this.x),
907
- Math.ceil(this.y),
908
- Math.ceil(this.z),
895
+ Math.ceil(this[0]),
896
+ Math.ceil(this[1]),
897
+ Math.ceil(this[2]),
909
898
  );
910
899
  }
911
900
 
@@ -915,9 +904,9 @@ export class Vector3 {
915
904
  * @returns {this}
916
905
  */
917
906
  projectOntoVector3(other) {
918
- const x0 = this.x;
919
- const y0 = this.y;
920
- const z0 = this.z;
907
+ const x0 = this[0];
908
+ const y0 = this[1];
909
+ const z0 = this[2];
921
910
 
922
911
  const x1 = other.x;
923
912
  const y1 = other.y;
@@ -995,7 +984,7 @@ export class Vector3 {
995
984
  */
996
985
  process(processor, thisArg) {
997
986
 
998
- processor.call(thisArg, this.x, this.y, this.z);
987
+ processor.call(thisArg, this[0], this[1], this[2]);
999
988
 
1000
989
  this.onChanged.add(processor, thisArg);
1001
990
 
@@ -1004,9 +993,9 @@ export class Vector3 {
1004
993
 
1005
994
  toJSON() {
1006
995
  return {
1007
- x: this.x,
1008
- y: this.y,
1009
- z: this.z
996
+ x: this[0],
997
+ y: this[1],
998
+ z: this[2]
1010
999
  };
1011
1000
  }
1012
1001
 
@@ -1024,7 +1013,7 @@ export class Vector3 {
1024
1013
  }
1025
1014
 
1026
1015
  toString() {
1027
- return `Vector3{ x:${this.x}, y:${this.y}, z:${this.z} }`;
1016
+ return `Vector3{ x:${this[0]}, y:${this[1]}, z:${this[2]} }`;
1028
1017
  }
1029
1018
 
1030
1019
  /**
@@ -1033,9 +1022,9 @@ export class Vector3 {
1033
1022
  * @deprecated
1034
1023
  */
1035
1024
  toBinaryBuffer(buffer) {
1036
- buffer.writeFloat64(this.x);
1037
- buffer.writeFloat64(this.y);
1038
- buffer.writeFloat64(this.z);
1025
+ buffer.writeFloat64(this[0]);
1026
+ buffer.writeFloat64(this[1]);
1027
+ buffer.writeFloat64(this[2]);
1039
1028
  }
1040
1029
 
1041
1030
  /**
@@ -1057,9 +1046,9 @@ export class Vector3 {
1057
1046
  * @deprecated
1058
1047
  */
1059
1048
  toBinaryBufferFloat32(buffer) {
1060
- buffer.writeFloat32(this.x);
1061
- buffer.writeFloat32(this.y);
1062
- buffer.writeFloat32(this.z);
1049
+ buffer.writeFloat32(this[0]);
1050
+ buffer.writeFloat32(this[1]);
1051
+ buffer.writeFloat32(this[2]);
1063
1052
  }
1064
1053
 
1065
1054
  /**
@@ -1076,9 +1065,9 @@ export class Vector3 {
1076
1065
  }
1077
1066
 
1078
1067
  hash() {
1079
- const x = computeHashFloat(this.x);
1080
- const y = computeHashFloat(this.y);
1081
- const z = computeHashFloat(this.z);
1068
+ const x = computeHashFloat(this[0]);
1069
+ const y = computeHashFloat(this[1]);
1070
+ const z = computeHashFloat(this[2]);
1082
1071
 
1083
1072
  return x ^ (y << 1) ^ (z << 2);
1084
1073
  }
@@ -1153,57 +1142,57 @@ Vector3.prototype.asArray = Vector3.prototype.toArray;
1153
1142
  * @readonly
1154
1143
  * @type {Vector3}
1155
1144
  */
1156
- Vector3.zero = Object.freeze(new Vector3(0, 0, 0));
1145
+ Vector3.zero = new Vector3(0, 0, 0);
1157
1146
 
1158
1147
  /**
1159
1148
  * Useful for setting scale
1160
1149
  * @readonly
1161
1150
  * @type {Vector3}
1162
1151
  */
1163
- Vector3.one = Object.freeze(new Vector3(1, 1, 1));
1152
+ Vector3.one = new Vector3(1, 1, 1);
1164
1153
 
1165
1154
  /**
1166
1155
  * Useful for setting scale
1167
1156
  * @readonly
1168
1157
  * @type {Vector3}
1169
1158
  */
1170
- Vector3.minus_one = Object.freeze(new Vector3(-1, -1, -1));
1159
+ Vector3.minus_one = new Vector3(-1, -1, -1);
1171
1160
 
1172
1161
  /**
1173
1162
  * @readonly
1174
1163
  * @type {Vector3}
1175
1164
  */
1176
- Vector3.up = Object.freeze(new Vector3(0, 1, 0));
1165
+ Vector3.up = new Vector3(0, 1, 0);
1177
1166
 
1178
1167
  /**
1179
1168
  * @readonly
1180
1169
  * @type {Vector3}
1181
1170
  */
1182
- Vector3.down = Object.freeze(new Vector3(0, -1, 0));
1171
+ Vector3.down = new Vector3(0, -1, 0);
1183
1172
 
1184
1173
  /**
1185
1174
  * @readonly
1186
1175
  * @type {Vector3}
1187
1176
  */
1188
- Vector3.left = Object.freeze(new Vector3(-1, 0, 0));
1177
+ Vector3.left = new Vector3(-1, 0, 0);
1189
1178
 
1190
1179
  /**
1191
1180
  * @readonly
1192
1181
  * @type {Vector3}
1193
1182
  */
1194
- Vector3.right = Object.freeze(new Vector3(1, 0, 0));
1183
+ Vector3.right = new Vector3(1, 0, 0);
1195
1184
 
1196
1185
  /**
1197
1186
  * @readonly
1198
1187
  * @type {Vector3}
1199
1188
  */
1200
- Vector3.forward = Object.freeze(new Vector3(0, 0, 1));
1189
+ Vector3.forward = new Vector3(0, 0, 1);
1201
1190
 
1202
1191
  /**
1203
1192
  * @readonly
1204
1193
  * @type {Vector3}
1205
1194
  */
1206
- Vector3.back = Object.freeze(new Vector3(0, 0, -1));
1195
+ Vector3.back = new Vector3(0, 0, -1);
1207
1196
 
1208
1197
  /**
1209
1198
  * @readonly