@woosh/meep-engine 2.110.8 → 2.110.9

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 (175) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +93 -106
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +93 -106
  5. package/editor/tools/v2/TransformControls.js +11 -6
  6. package/package.json +2 -1
  7. package/src/core/UUID.d.ts +3 -0
  8. package/src/core/UUID.d.ts.map +1 -1
  9. package/src/core/UUID.js +9 -7
  10. package/src/core/collection/array/arraySetDiff.d.ts.map +1 -1
  11. package/src/core/collection/array/arraySetDiff.js +0 -1
  12. package/src/core/collection/array/binarySearchHighIndex.d.ts.map +1 -1
  13. package/src/core/collection/array/binarySearchHighIndex.js +7 -1
  14. package/src/core/collection/array/computeHashArray.d.ts.map +1 -1
  15. package/src/core/collection/array/computeHashArray.js +3 -2
  16. package/src/core/collection/array/fastArrayEquals.d.ts +1 -0
  17. package/src/core/collection/array/fastArrayEquals.d.ts.map +1 -1
  18. package/src/core/collection/array/fastArrayEquals.js +1 -0
  19. package/src/core/collection/array/isArrayEqual.d.ts.map +1 -1
  20. package/src/core/collection/array/isArrayEqual.js +9 -12
  21. package/src/core/collection/array/isArrayEqual.spec.d.ts +2 -0
  22. package/src/core/collection/array/isArrayEqual.spec.d.ts.map +1 -0
  23. package/src/core/collection/array/isArrayEqual.spec.js +25 -0
  24. package/src/core/collection/array/typed/is_typed_array_equals.d.ts.map +1 -1
  25. package/src/core/collection/array/typed/is_typed_array_equals.js +1 -0
  26. package/src/core/function/makeSequenceLoop.d.ts.map +1 -0
  27. package/src/core/geom/3d/shape/AbstractShape3D.d.ts.map +1 -1
  28. package/src/core/geom/3d/shape/AbstractShape3D.js +14 -0
  29. package/src/core/geom/3d/shape/PointShape3D.d.ts +9 -0
  30. package/src/core/geom/3d/shape/PointShape3D.d.ts.map +1 -0
  31. package/src/core/geom/3d/shape/PointShape3D.js +14 -0
  32. package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
  33. package/src/core/geom/3d/shape/TransformedShape3D.js +26 -8
  34. package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
  35. package/src/core/geom/3d/shape/UnionShape3D.js +33 -4
  36. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
  37. package/src/core/geom/3d/shape/UnitCubeShape3D.js +13 -6
  38. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  39. package/src/core/geom/3d/shape/UnitSphereShape3D.js +10 -0
  40. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +15 -8
  41. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  42. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +33 -9
  43. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.d.ts +1 -1
  44. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.d.ts.map +1 -1
  45. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +7 -7
  46. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.d.ts +2 -0
  47. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.d.ts.map +1 -0
  48. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.js +38 -0
  49. package/src/core/geom/3d/v3_compute_triangle_normal.js +1 -1
  50. package/src/core/geom/3d/v3_negate_array.d.ts +9 -0
  51. package/src/core/geom/3d/v3_negate_array.d.ts.map +1 -0
  52. package/src/core/geom/3d/v3_negate_array.js +16 -0
  53. package/src/core/geom/Quaternion.d.ts.map +1 -1
  54. package/src/core/geom/Quaternion.js +30 -77
  55. package/src/core/geom/Vector3.d.ts +4 -0
  56. package/src/core/geom/Vector3.js +4 -4
  57. package/src/core/geom/vec3/v3_cross_array.d.ts +11 -0
  58. package/src/core/geom/vec3/v3_cross_array.d.ts.map +1 -0
  59. package/src/core/geom/vec3/v3_cross_array.js +31 -0
  60. package/src/core/geom/vec3/v3_displace_in_direction.js +3 -2
  61. package/src/core/geom/vec3/v3_displace_in_direction_array.d.ts +12 -0
  62. package/src/core/geom/vec3/v3_displace_in_direction_array.d.ts.map +1 -0
  63. package/src/core/geom/vec3/v3_displace_in_direction_array.js +22 -0
  64. package/src/core/geom/vec3/v3_dot_array_array.d.ts.map +1 -1
  65. package/src/core/geom/vec3/v3_dot_array_array.js +4 -1
  66. package/src/core/geom/vec3/v3_normalize_array.d.ts +3 -3
  67. package/src/core/geom/vec3/v3_normalize_array.d.ts.map +1 -1
  68. package/src/core/geom/vec3/v3_normalize_array.js +3 -3
  69. package/src/core/math/copysign.d.ts +1 -1
  70. package/src/core/math/copysign.js +1 -1
  71. package/src/core/math/epsilonEquals.d.ts.map +1 -1
  72. package/src/core/math/epsilonEquals.js +3 -2
  73. package/src/core/math/linalg/README.md +1 -1
  74. package/src/core/math/random/randomGaussian.spec.js +1 -1
  75. package/src/core/math/spline/spline_hermite3.d.ts +1 -1
  76. package/src/core/math/spline/spline_hermite3.js +1 -1
  77. package/src/core/process/delay.d.ts +6 -1
  78. package/src/core/process/delay.d.ts.map +1 -1
  79. package/src/core/process/delay.js +6 -1
  80. package/src/core/process/undo/Mark.d.ts +5 -5
  81. package/src/core/process/undo/Mark.d.ts.map +1 -1
  82. package/src/core/process/undo/Mark.js +6 -5
  83. package/src/core/process/worker/WorkerBuilder.d.ts +13 -2
  84. package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
  85. package/src/core/process/worker/WorkerBuilder.js +8 -0
  86. package/src/core/process/worker/WorkerProxy.d.ts +16 -6
  87. package/src/core/process/worker/WorkerProxy.d.ts.map +1 -1
  88. package/src/core/process/worker/WorkerProxy.js +24 -5
  89. package/src/engine/EngineHarness.d.ts +7 -1
  90. package/src/engine/EngineHarness.d.ts.map +1 -1
  91. package/src/engine/EngineHarness.js +12 -1
  92. package/src/engine/animation/clip/AnimationTrack.d.ts.map +1 -1
  93. package/src/engine/animation/clip/AnimationTrack.js +3 -0
  94. package/src/engine/animation/clip/bind_property_writer.d.ts +2 -2
  95. package/src/engine/animation/clip/bind_property_writer.d.ts.map +1 -1
  96. package/src/engine/animation/clip/bind_property_writer.js +22 -13
  97. package/src/engine/animation/clip/curve_from_track_data.d.ts.map +1 -1
  98. package/src/engine/animation/clip/curve_from_track_data.js +9 -1
  99. package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -1
  100. package/src/engine/animation/clip/ecd_bind_animation_curve.js +6 -5
  101. package/src/engine/animation/curve/AnimationCurve.d.ts +21 -0
  102. package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
  103. package/src/engine/animation/curve/AnimationCurve.js +43 -15
  104. package/src/engine/animation/curve/AnimationCurve.spec.js +67 -0
  105. package/src/engine/animation/curve/Keyframe.d.ts +24 -3
  106. package/src/engine/animation/curve/Keyframe.d.ts.map +1 -1
  107. package/src/engine/animation/curve/Keyframe.js +49 -3
  108. package/src/engine/animation/curve/Keyframe.spec.js +11 -0
  109. package/src/engine/animation/curve/animation_curve_compute_aabb.d.ts +7 -0
  110. package/src/engine/animation/curve/animation_curve_compute_aabb.d.ts.map +1 -0
  111. package/src/engine/animation/curve/{compute_curve_aabb.js → animation_curve_compute_aabb.js} +1 -1
  112. package/src/engine/animation/curve/animation_curve_optimize.d.ts +8 -0
  113. package/src/engine/animation/curve/animation_curve_optimize.d.ts.map +1 -0
  114. package/src/engine/animation/curve/animation_curve_optimize.js +89 -0
  115. package/src/engine/animation/curve/animation_curve_optimize.spec.d.ts +2 -0
  116. package/src/engine/animation/curve/animation_curve_optimize.spec.d.ts.map +1 -0
  117. package/src/engine/animation/curve/animation_curve_optimize.spec.js +50 -0
  118. package/src/engine/animation/curve/draw/build_curve_editor.js +2 -2
  119. package/src/engine/animation/curve/evaluate_two_key_curve.d.ts +9 -0
  120. package/src/engine/animation/curve/evaluate_two_key_curve.d.ts.map +1 -0
  121. package/src/engine/animation/curve/evaluate_two_key_curve.js +23 -0
  122. package/src/engine/animation/curve/prototypeGLTF.js +14 -14
  123. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.d.ts +6 -1
  124. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.d.ts.map +1 -1
  125. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +11 -6
  126. package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.js +5 -5
  127. package/src/engine/ecs/guid/{GUID.d.ts → UUID.d.ts} +17 -12
  128. package/src/engine/ecs/guid/UUID.d.ts.map +1 -0
  129. package/src/engine/ecs/guid/{GUID.js → UUID.js} +35 -12
  130. package/src/engine/ecs/guid/UUID.spec.d.ts +2 -0
  131. package/src/engine/ecs/guid/UUID.spec.d.ts.map +1 -0
  132. package/src/engine/ecs/guid/{GUID.spec.js → UUID.spec.js} +18 -12
  133. package/src/engine/ecs/guid/UUIDSerializationAdapter.d.ts +18 -0
  134. package/src/engine/ecs/guid/UUIDSerializationAdapter.d.ts.map +1 -0
  135. package/src/engine/ecs/guid/{GUIDSerializationAdapter.js → UUIDSerializationAdapter.js} +5 -5
  136. package/src/engine/ecs/ik/InverseKinematics.js +3 -3
  137. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.d.ts.map +1 -1
  138. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +1 -140
  139. package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -1
  140. package/src/engine/intelligence/blackboard/BlackboardDynamicStorageAdapter.d.ts +1 -1
  141. package/src/engine/intelligence/blackboard/BlackboardDynamicStorageAdapter.js +4 -4
  142. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts +13 -0
  143. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -0
  144. package/src/engine/physics/gjk/expanding_polytope_algorithm.js +395 -0
  145. package/src/engine/physics/gjk/expanding_polytope_algorithm.spec.d.ts +2 -0
  146. package/src/engine/physics/gjk/expanding_polytope_algorithm.spec.d.ts.map +1 -0
  147. package/src/engine/physics/gjk/expanding_polytope_algorithm.spec.js +46 -0
  148. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.d.ts +18 -0
  149. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.d.ts.map +1 -0
  150. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.js +277 -0
  151. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.spec.d.ts +2 -0
  152. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.spec.d.ts.map +1 -0
  153. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.spec.js +43 -0
  154. package/src/engine/physics/inverse_kinematics/fabrik/fabrik_solve.d.ts +12 -0
  155. package/src/engine/physics/inverse_kinematics/fabrik/fabrik_solve.d.ts.map +1 -0
  156. package/src/engine/physics/inverse_kinematics/fabrik/fabrik_solve.js +100 -0
  157. package/src/engine/physics/inverse_kinematics/fabrik/prototype.d.ts +2 -0
  158. package/src/engine/physics/inverse_kinematics/fabrik/prototype.d.ts.map +1 -0
  159. package/src/engine/physics/inverse_kinematics/fabrik/prototype.js +112 -0
  160. package/src/engine/physics/inverse_kinematics/two_joint_ik.d.ts +16 -0
  161. package/src/engine/physics/inverse_kinematics/two_joint_ik.d.ts.map +1 -0
  162. package/src/engine/physics/inverse_kinematics/two_joint_ik.js +127 -0
  163. package/src/view/elements/DropDownSelectionView.js +2 -2
  164. package/src/view/elements/tiles2d/Tile.d.ts.map +1 -1
  165. package/src/view/elements/tiles2d/Tile.js +2 -3
  166. package/src/core/math/makeSequenceLoop.d.ts.map +0 -1
  167. package/src/engine/animation/curve/compute_curve_aabb.d.ts +0 -7
  168. package/src/engine/animation/curve/compute_curve_aabb.d.ts.map +0 -1
  169. package/src/engine/ecs/guid/GUID.d.ts.map +0 -1
  170. package/src/engine/ecs/guid/GUID.spec.d.ts +0 -2
  171. package/src/engine/ecs/guid/GUID.spec.d.ts.map +0 -1
  172. package/src/engine/ecs/guid/GUIDSerializationAdapter.d.ts +0 -18
  173. package/src/engine/ecs/guid/GUIDSerializationAdapter.d.ts.map +0 -1
  174. /package/src/core/{math → function}/makeSequenceLoop.d.ts +0 -0
  175. /package/src/core/{math → function}/makeSequenceLoop.js +0 -0
@@ -1 +1 @@
1
- function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}class e{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,i){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,i){throw new Error("Not Implemented")}}class n{describeTo(t){throw new Error("Not Implemented")}}class i extends n{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class r{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class s extends e{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,i){return this.appendList(t,e,n,new r(i)),this}appendList(t,e,n,i){let r=!1;this.appendText(t);const s=i[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())r&&this.appendText(e),this.appendDescriptionOf(t.value),r=!0;return this.appendText(n),this}}class o extends s{value="";appendText(t){return this.value+=t,this}}function a(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n,i,r){let s,o,a;for(a=0;a<r;a++)s=e+a,o=i+a,n[o]=t[s]}a.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},a.notEqual=function(t,e,n){a(t!==e,n)},a.notOk=function(t,e){a(!t,e)},a.equal=function(t,e,n){if(t!==e){const i=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${i}`:i)}},a.logicalyEqual=function(t,e,n){},a.ok=a,a.greaterThan=function(t,e,n){if(!(t>e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} > ${e}.`,new Error(i)}},a.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} >= ${e}.`,new Error(i)}},a.lessThan=function(t,e,n){if(!(t<e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} < ${e}.`,new Error(i)}},a.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} <= ${e}.`,new Error(i)}},a.typeOf=function(t,e,n="value"){const i=typeof t;if(i!==e)throw new Error(`expected ${n} to be ${e}, instead was '${i}'(=${t})`)},a.arrayHas=function(t,e,n="Array does not contain the item"){},a.arrayHasNo=function(t,e,n="Array contains the item"){},a.arrayEqual=function(e,n,i="Arrays are not equal"){if(!t(e,n))throw new Error(i)},a.isInstanceOf=function(t,e,n="value",i=e.name){},a.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},a.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},a.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},a.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},a.isObject=function(t,e="value"){const n=typeof t;if("object"!==n)throw new Error(`expected ${e} to be an object, instead was '${n}'(=${t})`)},a.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},a.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},a.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},a.isArrayLike=function(t,e="value"){if(!(Array.isArray(t)||(n=t,n instanceof Int8Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int16Array||n instanceof Uint16Array||n instanceof Int32Array||n instanceof Uint32Array||n instanceof Float32Array||n instanceof Float64Array)))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`);var n},a.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},a.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},a.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},a.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},a.isFiniteNumber=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},a.that=function(t,e,n){if(n.matches(t))return;const i=new o;throw i.appendText(`Expected ${e} to be `),n.describeTo(i),i.appendText(" instead "),n.describeMismatch(t,i),new Error(i.value)};const c=new Uint32Array(781250);function d(t,e){return t<e?e:t}function u(t,e){return t<e?t:e}function l(t,e,n,i,r,s){const o=n[i+0],a=n[i+1],h=n[i+2],c=n[i+3],l=n[i+4],f=n[i+5],g=r[s+0],_=r[s+1],p=r[s+2],y=r[s+3],m=r[s+4],w=r[s+5],v=u(o,g),x=u(a,_),b=u(h,p),A=d(c,y),E=d(l,m),$=d(f,w);t[e+0]=v,t[e+1]=x,t[e+2]=b,t[e+3]=A,t[e+4]=E,t[e+5]=$}function f(t,e,n,i,r,s,o,a){t[e]=n,t[e+1]=i,t[e+2]=r,t[e+3]=s,t[e+4]=o,t[e+5]=a}function g(t,e,n,i,r,s){const o=i-t,a=s-n;return(r-e)*(o+a)+a*o}function _(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function p(t,e,n){let i=t;return i<e&&(i=e),i<n&&(i=n),i}function y(t,e,n){let i=t;return i>e&&(i=e),i>n&&(i=n),i}function m(t,e,n){const i=t[n],r=t[n+1],s=t[n+2];f(t,e,i,r,s,i,r,s)}function w(t,e,n){const i=t[e],r=t[e+1],s=t[e+2];return function(t,e,n,i){const r=i[0],s=i[1],o=i[2],a=1023*(t-r)/(i[3]-r),h=1023*(e-s)/(i[4]-s),c=1023*(n-o)/(i[5]-o);return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(a),Math.round(h),Math.round(c))}(.5*(i+t[e+3]),.5*(r+t[e+4]),.5*(s+t[e+5]),n)}c.pointer=0;const v=c;class x{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}getLeafAddress(t){return 7*t+6*this.__node_count_binary}setLeafData(t,e,n,i,r,s,o,a){const h=this.getLeafAddress(t);f(this.__data_float32,h,n,i,r,s,o,a),this.__data_uint32[h+6]=e}readBounds(t,e,n){h(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let i;i=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(i,e,0),t+=g(e[0],e[1],e[2],e[3],e[4],e[5])}return t}__compute_bounds_area_of_3_boxes(t,e,n){const i=this.__data_float32;return g(y(i[t+0],i[e+0],i[n+0]),y(i[t+1],i[e+1],i[n+1]),y(i[t+2],i[e+2],i[n+2]),p(i[t+3],i[e+3],i[n+3]),p(i[t+4],i[e+4],i[n+4]),p(i[t+5],i[e+5],i[n+5]))}__fitness_function_should_swap_leaves_sah(t,e){const n=d(t-1,0),i=u(t+1,this.__node_count_leaf-1),r=this.getLeafBlockAddress(),s=7*t+r,o=7*n+r,a=7*i+r,h=7*e+r,c=7*d(e-1,0)+r,l=7*u(e+1,this.__node_count_leaf-1)+r;return this.__compute_bounds_area_of_3_boxes(o,s,a)+this.__compute_bounds_area_of_3_boxes(c,h,l)-(this.__compute_bounds_area_of_3_boxes(o,h,a)+this.__compute_bounds_area_of_3_boxes(c,s,l))}sort_bubble_sah(){const t=this.__node_count_leaf;for(let e=0;e<t;e++)for(let n=e+1;n<t;n++)this.__fitness_function_should_swap_leaves_sah(e,n)>0&&this.__swap_leaves(e,n)}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;let n,i,r=2;v[0]=0,v[1]=this.__node_count_leaf-1;const s=this.__data_float32;for(;r>0;){r-=2;const o=v[r+1],a=v[r];n=a,i=o;const h=w(s,7*(a+o>>1)+e,t);for(;n<=i;){for(;w(s,7*n+e,t)<h;)n++;for(;w(s,7*i+e,t)>h;)i--;n<=i&&(n!==i&&this.__swap_leaves(n,i),n++,i--)}a<i&&(v[r++]=a,v[r++]=i),n<o&&(v[r++]=n,v[r++]=o)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),i=7*t+n,r=7*e+n;!function(t,e,n,i,r){for(let r=0;r<7;r++){const s=e+r,o=i+r,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,i,this.__data_float32,r)}build(){const t=this.__node_count_binary,e=6*t;let n,i,r,s,o=Math.floor(Math.log(t)/Math.log(2));r=Math.pow(2,o),i=6*(r-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<r;n++){const t=n<<1,r=t+1,s=e+7*t;r<a?l(c,i,c,s,c,e+7*r):t<a?h(c,s,c,i,6):m(this.__data_float32,i,i-6),i+=6}for(o--;o>=0;o--)for(r=1<<o,s=r-1,n=0;n<r;n++){const t=6*(1+(s<<1));l(c,6*s,c,t,c,t+6),s++}}}function b(t,e,n,i,r,s){const o=t.getLeafAddress(e);!function(t,e,n,i,r,s){const o=3*i,a=3*r,h=3*s,c=n[o],d=n[o+1],u=n[o+2],l=n[a],f=n[a+1],g=n[a+2],_=n[h],m=n[h+1],w=n[h+2];t[e]=y(c,l,_),t[e+1]=y(d,f,m),t[e+2]=y(u,g,w),t[e+3]=p(c,l,_),t[e+4]=p(d,f,m),t[e+5]=p(u,g,w)}(t.__data_float32,o,n,i,r,s),t.__data_uint32[o+6]=e}const A=[],E=[],$="undefined"!=typeof Uint8Array?Uint8Array:Array,S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)A[t]=S[t],E[S.charCodeAt(t)]=t;function U(t,e,n){const i=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);i.push(A[(r=e)>>18&63]+A[r>>12&63]+A[r>>6&63]+A[63&r])}var r;return i.join("")}E["-".charCodeAt(0)]=62,E["_".charCodeAt(0)]=63;class F{static encode(t){return function(t){let e;const n=t.length,i=n%3,r=[],s=16383,o=n-i;for(let e=0;e<o;e+=s){const n=U(t,e,e+s>o?o:e+s);r.push(n)}return 1===i?(e=t[n-1],r.push(A[e>>2]+A[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],r.push(A[e>>10]+A[e>>4&63]+A[e<<2&63]+"=")),r.join("")}(new Uint8Array(t))}static decode(t){return function(t){var e,n,i=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=i[0],s=i[1],o=new $(function(t,e,n){return 3*(e+n)/4-n}(0,r,s)),a=0,h=s>0?r-4:r;for(n=0;n<h;n+=4)e=E[t.charCodeAt(n)]<<18|E[t.charCodeAt(n+1)]<<12|E[t.charCodeAt(n+2)]<<6|E[t.charCodeAt(n+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2===s&&(e=E[t.charCodeAt(n)]<<2|E[t.charCodeAt(n+1)]>>4,o[a++]=255&e),1===s&&(e=E[t.charCodeAt(n)]<<10|E[t.charCodeAt(n+1)]<<4|E[t.charCodeAt(n+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o}(t).buffer}}const z="uint8",C="uint16",V="uint32",B="int8",q="int16",L="int32",M="float32",T="float64",I={[z]:Uint8Array,[C]:Uint16Array,[V]:Uint32Array,[B]:Int8Array,[q]:Int16Array,[L]:Int32Array,float16:Uint16Array,[M]:Float32Array,[T]:Float64Array};function N(t){switch(Object.getPrototypeOf(t).constructor){case Uint8Array:case Uint8ClampedArray:return z;case Uint16Array:return C;case Uint32Array:return V;case Int8Array:return B;case Int16Array:return q;case Int32Array:return L;case Float32Array:return M;case Float64Array:return T;default:throw new Error("unsupported constructor type")}}function O(t,e,n){return t<e?e:t>n?n:t}function k(t,e,n){return(e-t)*n+t}function j(t,e,n,i,r){return.5*(i-e+(2*e-5*n+4*i-r+(3*(n-i)+r-e)*t)*t)*t+n}class D{constructor(t=[],e=1,n=0,i=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(i)||n<0)throw new Error(`height must be a non-negative integer, instead was ${i}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*i*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*i*e}`);this.width=n,this.height=i,this.itemSize=e,this.data=t,this.version=0}get(t,e,n){throw new Error("Deprecated method, use sampleBilinear instead")}sampleCatmullRomUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelCatmullRomUV(t,e,r)}sampleChannelCatmullRomUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelCatmullRom(i,r,n)}sampleChannelCatmullRom(t,e,n){const i=Math.floor(t),r=Math.floor(e),s=t-i,o=e-r,a=s*(s*(1-.5*s)-.5),h=o*(o*(1-.5*o)-.5),c=s*(.5+s*(2-1.5*s)),d=o*(.5+o*(2-1.5*o)),u=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+c,g=1+o*o*(1.5*o-2.5)+d,_=i-1,p=r-1,y=i+2,m=r+2,w=i+c/f,v=r+d/g;let x=0;return x+=this.sampleChannelBilinear(_,p,n)*a*h,x+=this.sampleChannelBilinear(w,p,n)*f*h,x+=this.sampleChannelBilinear(y,p,n)*u*h,x+=this.sampleChannelBilinear(_,v,n)*a*g,x+=this.sampleChannelBilinear(w,v,n)*f*g,x+=this.sampleChannelBilinear(y,v,n)*u*g,x+=this.sampleChannelBilinear(_,m,n)*a*l,x+=this.sampleChannelBilinear(w,m,n)*f*l,x+=this.sampleChannelBilinear(y,m,n)*u*l,x}sampleBicubicUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelBicubicUV(t,e,r)}sampleBicubic(t,e,n,i){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const i=t*this.width,r=e*this.height;return this.sampleChannelBicubic(i-.5,r-.5,n)}sampleChannelBicubic(t,e,n){const i=this.itemSize,r=this.width,s=this.height,o=this.data,a=r*i,h=r-1,c=s-1,l=O(t,0,h),f=O(e,0,c),g=0|l,_=0|f,p=l-g,y=f-_,m=d(0,g-1),w=d(0,_-1),v=u(h,g+1),x=u(c,_+1),b=u(h,v+1),A=w*a+n,E=_*a+n,$=x*a+n,S=u(c,x+1)*a+n,U=m*i,F=g*i,z=v*i,C=b*i,V=o[A+U],B=o[A+F],q=o[A+z],L=o[A+C],M=o[E+U],T=o[E+F],I=o[E+z],N=o[E+C],k=o[$+U],D=o[$+F],R=o[$+z],J=o[$+C],P=o[S+U],H=o[S+F],W=o[S+z],G=o[S+C],Y=j(p,V,B,q,L),K=j(p,M,T,I,N),Q=j(p,k,D,R,J),X=j(p,P,H,W,G);return j(y,Y,K,Q,X)}sampleBilinearUV(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelBilinear(i,r,n)}sampleChannelBilinear(t,e,n){const i=this.itemSize,r=this.width,s=r*i,o=this.height-1,a=O(t,0,r-1),h=O(e,0,o),c=a>>>0,d=h>>>0,u=d*s,l=c*i+n,f=u+l;let g,_;g=a===c?c:c+1,_=h===d?d:d+1;const p=this.data,y=p[f];if(c===g&&d===_)return y;const m=a-c,w=h-d,v=g*i+n,x=_*s,b=x+l,A=x+v,E=p[u+v],$=p[b],S=p[A],U=k(y,E,m),F=k($,S,m);return k(U,F,w)}sampleNearestUV(t,e,n){const i=this.width,r=this.height,s=Math.round(t*i-.5),o=Math.round(e*r-.5);this.read(O(s,0,i-1),O(o,0,r-1),n)}readChannel(t,e,n){const i=(e*this.width+t)*this.itemSize+n;return this.data[i]}read(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++)n[t]=this.data[s+t]}write(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++)this.data[s+t]=n[t]}sample(t,e,n){const i=[];return this.sampleBilinear(t*(this.width-1),e*(this.height-1),i,0),n.readFromArray(i),i[0]}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,i=t%n,r=t/n|0;e.set(i,r)}copy(t,e,n,i,r,s,o){const a=Math.min(s,t.width-e,this.width-i),h=Math.min(o,t.height-n,this.height-r),c=this.itemSize,d=t.itemSize,u=Math.min(c,d),l=c*this.width,f=d*t.width,g=t.data,_=this.data;let p,y,m;for(y=0;y<h;y++){const t=(y+r)*l,s=(y+n)*f;for(p=0;p<a;p++){const n=t+(p+i)*c,r=s+(p+e)*d;for(m=0;m<u;m++)_[n+m]=g[r+m]}}this.version++}zeroFill(t,e,n,i){const r=O(t,0,this.width),s=O(e,0,this.height),o=O(t+n,0,this.width),a=O(e+i,0,this.height),h=this.data,c=this.itemSize,d=c*this.width,u=r*c,l=o*c;let f;for(f=s;f<a;f++){const t=f*d;h.fill(0,t+u,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,i=this.data,r=i.length;for(let s=t;s<r;s+=n)i[s]=e;this.version++}fill(t,e,n,i,r){const s=this.width,o=this.height,a=O(t,0,s),h=O(e,0,o),c=O(t+n,0,s),d=O(e+i,0,o),u=this.data,l=this.itemSize,f=l*s;let g,_,p;for(g=h;g<d;g++){const t=g*f;for(_=a;_<c;_++){const e=t+_*l;for(p=0;p<l;p++)u[e+p]=r[p]}}this.version++}writeChannel(t,e,n,i){const r=(e*this.width+t)*this.itemSize+n;this.data[r]=i,this.version++}set(t,e,n){const i=this.data,r=this.itemSize,s=r*this.width*e+t*r;for(let t=0;t<r;t++)i[s+t]=n[t];this.version++}traverseCircle(t,e,n,i){let r,s;const o=0|t,a=0|e,h=n*n,c=Math.ceil(n);for(s=-c;s<=c;s++){const t=s*s;for(r=-c;r<=c;r++)r*r+t<=h&&i(o+r,a+s,this)}}resize(t,e,n=!0){const i=this.width,r=this.height;if(i===t&&r===e)return;const s=this.itemSize,o=t*e*s,a=this.data,h=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===i)h.set(a.subarray(0,Math.min(a.length,o)));else{const n=u(e,r),o=u(t,i);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const r=(e*t+n)*s,o=(e*i+n)*s;for(let t=0;t<s;t++)h[r+t]=a[o+t]}}this.width=t,this.height=e,this.data=h,this.version++}computeByteSize(){let t;return t=Array.isArray(this.data)?8*this.data.length:this.data.buffer.byteLength,t+280}equals(e){return this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const i=e.length;if(i!==n.length)return!1;if(0===i)return!0;if(i<128)return t(e,n);const r=e.byteLength;if(r!==n.byteLength)return!1;const s=e.constructor;if(s!==n.constructor)return!1;const o=e.buffer,a=n.buffer;if(o===a&&e.byteOffset===n.byteOffset)return!0;let h=e,c=n;const d=s.BYTES_PER_ELEMENT;return d<4&&r%4==0?(h=new Uint32Array(o,e.byteOffset,r/4),c=new Uint32Array(a,n.byteOffset,r/4)):d<2&&r%2==0&&(h=new Uint16Array(o,e.byteOffset,r/2),c=new Uint16Array(a,n.byteOffset,r/2)),t(h,c)}(this.data,e.data)}hash(){let t=((65535&this.width)<<16|65535&this.height)^this.itemSize;const e=this.data.length,n=Math.max(1,Math.ceil(e/509));return t^=function(t,e,n,i){let r=n;for(let e=0;e<n;e+=i)r=(r<<5)-r+(t[e]>>>0);return r>>>0}(this.data,0,e,n),t}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new D(t,this.itemSize,this.width,this.height)}toJSON(){const t=F.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:N(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:i,data:r}){const s=function(t){const e=I[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(i);if("string"==typeof r){const t=F.decode(r);this.data=new s(t)}else{if(!Array.isArray(r))throw new Error("Unsupported data format");this.data=new s(r)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const i=new Uint8ClampedArray(e*n*t);return new D(i,t,e,n)}static uint8(t,e,n){const i=new Uint8Array(e*n*t);return new D(i,t,e,n)}static uint16(t,e,n){const i=new Uint16Array(e*n*t);return new D(i,t,e,n)}static uint32(t,e,n){const i=new Uint32Array(e*n*t);return new D(i,t,e,n)}static int8(t,e,n){const i=new Int8Array(e*n*t);return new D(i,t,e,n)}static int16(t,e,n){const i=new Int16Array(e*n*t);return new D(i,t,e,n)}static int32(t,e,n){const i=new Int32Array(e*n*t);return new D(i,t,e,n)}static float32(t,e,n){const i=new Float32Array(e*n*t);return new D(i,t,e,n)}static float64(t,e,n){const i=new Float64Array(e*n*t);return new D(i,t,e,n)}}function R(t,e,n){return Math.sqrt(t*t+e*e+n*n)}function J(t,e,n,i){const r=t[e],s=t[e+1],o=t[e+2],a=1/R(r,s,o);n[i]=r*a,n[i+1]=s*a,n[i+2]=o*a}D.prototype.isSampler2D=!0,D.typeName="Sampler2D";const P={build:function(t,e,n,i,r,s){const o=n.x*s,a=n.y*s,h=o-1,c=a-1;let d=0,u=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),_=new Float32Array(2*l);let p,y;const m=n.y/r.y/c,w=n.x/r.x/h,v=e.y/r.y,x=e.x/r.x,b=r.x*i.x,A=r.y*i.y;let E,$,S;for(p=0;p<a;p++){const e=p*m+v;for(S=e*A,y=0;y<o;y++){const n=y*w+x;E=n*b,$=t.sampleChannelBicubicUV(n,e,0),f[d]=E,f[d+1]=$,f[d+2]=S,_[u]=n,_[u+1]=e,d+=3,u+=2}}d=0;const U=new(f.length/3>65535?Uint32Array:Uint16Array)(h*c*6);for(p=0;p<c;p++)for(y=0;y<h;y++){const t=y+o*p,e=y+o*(p+1),n=y+1+o*(p+1),i=y+1+o*p;U[d]=t,U[d+1]=e,U[d+2]=i,U[d+3]=e,U[d+4]=n,U[d+5]=i,d+=6}return function(t,e,n){let i,r,s,o,a,h,c,d,u,l,f,g,_,p,y,m,w,v,x,b,A,E=0;const $=n.length;for(;E<$;E+=3)i=3*n[E],r=3*n[E+1],s=3*n[E+2],o=t[i],a=t[i+1],h=t[i+2],c=t[r],d=t[r+1],u=t[r+2],l=t[s],f=t[s+1],g=t[s+2],_=l-c,p=f-d,y=g-u,m=o-c,w=a-d,v=h-u,x=p*v-y*w,b=y*m-_*v,A=_*w-p*m,e[i]+=x,e[i+1]+=b,e[i+2]+=A,e[r]+=x,e[r+1]+=b,e[r+2]+=A,e[s]+=x,e[s+1]+=b,e[s+2]+=A;!function(t){const e=t.length;for(let n=0;n<e;n+=3)J(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:_}}};function H(t,e,n=0,i=t.length){const r=n+i;for(let i=n;i<r;i++)if(t[i]===e)return t.splice(i,1),!0;return!1}function W(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function G(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}let Y=0;class K{constructor(){this.index=Y++,this.v0=null,this.v1=null,this.faces=[],this.lengthSqr=-1}get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new K;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsEdge(this)||(t(`Missing back-link from face[${r}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,i=n.length;for(let t=0;t<i;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){return 1===this.faces.length}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,i=t.y,r=t.z,s=n-e.x,o=i-e.y,a=r-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,i=e.length;for(let r=0;r<i;r++){const i=e[r];i.removeEdge(t),-1===n.indexOf(i)&&(n.push(i),i.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){W(this.faces,t)}removeFace(t){H(this.faces,t)}getOtherVertex(t){return G(this,t)}containsVertex(t){return e=t,this.v0===e||this.v1===e;var e}containsBothVertices(t,e){return function(t,e,n){const i=t.v0,r=t.v1;return!(i!==e&&i!==n||r!==e&&r!==n)}(this,t,e)}containsSameVerticesAs(t){return this.containsBothVertices(t.v0,t.v1)}}function Q(t,e,n){const i=t.length;for(let r=0;r<i;r++)t[r]===e&&(t[r]=n)}K.prototype.isTopoEdge=!0;var X,Z="undefined"!=typeof Float32Array?Float32Array:Array;function tt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),X=new Z(3),Z!=Float32Array&&(X[0]=0,X[1]=0,X[2]=0);let et=0;class nt{constructor(){this.index=et++,this.vertices=[],this.edges=[],this.normal=[0,0,0]}get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),tt(this.normal,t.normal)}clone(){const t=new nt;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,i=n.length;3!==i&&(t(`Expected number of vertices is 3, instead got ${i}`),e=!1);for(let r=0;r<i;r++)n[r].containsFace(this)||(t(`Missing back-link from vertex[${r}]`),e=!1);const r=this.edges,s=r.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)r[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){Q(this.edges,t,e)}replaceVertex(t,e){Q(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],i=t[2];return e===n||e===i||n===i}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,i=n.length;for(let t=0;t<i;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return W(this.edges,t)}removeEdge(t){H(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],i=t[2];!function(t,e,n,i){!function(t,e,n,i,r,s,o,a,h,c,d){const u=h-s,l=c-o,f=d-a,g=n-s,_=i-o,p=r-a,y=l*p-f*_,m=f*g-u*p,w=u*_-l*g,v=function(t,e,n){return t*t+e*e+n*n}(y,m,w);if(0===v)return t[0]=0,t[1]=1,void(t[2]=0);const x=1/Math.sqrt(v),b=y*x,A=m*x,E=w*x;t[0]=b,t[1]=A,t[2]=E}(t,0,e[0],e[1],e[2],n[0],n[1],n[2],i[0],i[1],i[2])}(this.normal,e,n,i)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].faces,o=r.length;for(let i=0;i<o;i++){const s=r[i];s!==this&&(t[e+n]=s,n++)}}return n}}nt.prototype.isTopoFace=!0;class it{constructor(){this.index=0,this.edges=[],this.faces=[],this.x=0,this.y=0,this.z=0}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new it;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsVertex(this)||(t(`Missing back-link from face[${r}]`),e=!1);const r=this.edges,s=r.length;for(let n=0;n<s;n++)r[n].containsVertex(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,i=this.z,R(t.x-e,t.y-n,t.z-i);var e,n,i}addFace(t){this.faces.push(t)}addUniqueFace(t){return W(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){H(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return W(this.edges,t)}replaceEdge(t,e){const n=this.edges,i=n.indexOf(t);n[i]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return H(this.edges,t)}replaceAnotherVertex(t){const e=t.faces,n=e.length;let i=0;for(;i<n;i++){const n=e[i];n.replaceVertex(t,this),this.addUniqueFace(n)}const r=t.edges,s=r.length;for(i=0;i<s;i++){const e=r[i];e.replaceVertex(t,this),this.addUniqueEdge(e)}}computeNeighbourVertices(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].getOtherVertex(this);t[e+n]=r,n++}return n}}function rt(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}it.prototype.isTopoVertex=!0;class st{constructor(){this.vertices=[],this.__edges=new Set,this.__faces=new Set}get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t){let e=!0,n="",i=0;function r(r){t(`${n}[${i}]: ${r}`),e=!1}n="Edge",i=0;const s=this.getEdges();for(let t of s){t.validate(r),this.containsVertex(t.v0)||r("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||r("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||r(`Link to off-mesh face[${t}]`)}i++}const o=this.getFaces();n="Face",i=0;for(let t of o){t.validate(r);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||r(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||r(`Link to off-mesh vertex[${t}]`)}i++}const a=this.vertices,h=a.length;n="Vertex";for(let t=0;t<h;t++){i=t;const e=a[t];e.validate(r);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||r(`Link to off-mesh edge[${t}]`)}const o=e.faces,h=o.length;for(let t=0;t<h;t++){const e=o[t];this.containsFace(e)||r(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new st;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let i=0;i<n;i++){const n=e[i];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new nt;tt(n.normal,t.normal);const i=t.vertices;for(let t=0;t<3;t++){const r=i[t];let s=e.get(r.index);void 0===s&&(s=new it,s.index=r.index,s.x=r.x,s.y=r.y,s.z=r.z,e.set(r.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n);const r=n.vertices,s=r[0],o=r[1],a=r[2],h=this.ensureEdge(s,o),c=this.ensureEdge(o,a),d=this.ensureEdge(a,s);h.addUniqueFace(n),c.addUniqueFace(n),d.addUniqueFace(n),n.addUniqueEdge(h),n.addUniqueEdge(c),n.addUniqueEdge(d)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){W(this.vertices,t)}removeVertex(t){var e;e=t,H(this.vertices,e)}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){var e;e=t,this.__edges.delete(e)}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const i=t.vertices,r=i.length;for(let t=0;t<r;t++){const e=i[t];this.addUniqueVertex(e)}}removeFace(t){var e;e=t,this.__faces.delete(e)}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,i=n.length;for(let r=0;r<i;r++){const i=n[r];if(G(i,t)===e)return i}const r=new K;return r.v0=t,r.v1=e,t.edges.push(r),e.edges.push(r),this.__edges.add(r),r}mergeEdges(){const t=this.getEdges();for(let e of t){const n=e.v0,i=e.v1;for(let r of t){if(e===r)continue;const t=r.v0,s=r.v1;if(n===t){if(i!==s)continue}else{if(n!==s)continue;if(i!==t)continue}this.removeEdge(r),e.merge(r)}}}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}build(t,e){const n=e.length,i=t.length/3,r=this.vertices;for(let e=0;e<i;e++){const n=3*e,i=new it;i.index=e,i.x=t[n],i.y=t[n+1],i.z=t[n+2],r[e]=i}const s=n/3,o=this.getFaces();for(let t=0;t<s;t++){const n=3*t,i=e[n],s=e[n+1],a=e[n+2],h=r[i],c=r[s],d=r[a],u=new nt;u.index=t;const l=this.ensureEdge(h,c),f=this.ensureEdge(c,d),g=this.ensureEdge(d,h);l.faces.push(u),f.faces.push(u),g.faces.push(u),u.vertices.push(h,c,d),u.edges.push(l,f,g),h.faces.push(u),c.faces.push(u),d.faces.push(u),o.add(u)}}toString(){return`TopoMesh{ vertices: ${rt(this.vertices.length)}, edges: ${rt(this.getEdges().size)}, faces: ${rt(this.getFaces().size)} }`}}st.prototype.isTopoMesh=!0,self.Lib={build_bvh(t,e){const n=new x;return function(t,e,n){const i=n.length/3;t.setLeafCount(i),t.initialize_structure();for(let r=0;r<i;r++){const i=3*r;b(t,r,e,n[i],n[i+1],n[i+2])}t.build()}(n,t,e),n},Sampler2D:D,BufferedGeometryArraysBuilder:P,tensionOptimizeUV:function(t,e,n,i){const r=new st;r.build(t,n),r.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<i;t++)t:for(let t=0;t<s;t++){const n=r.vertices[t],i=n.edges,s=i.length;if(0===s)continue;let o=0,a=0,h=0;for(let t=0;t<s;t++){const r=i[t];if(r.isTopologyBorder())continue t;const s=2*r.getOtherVertex(n).index,c=e[s],d=e[s+1],u=1/r.lengthSqr;o+=c*u,a+=d*u,h+=u}const c=o/h,d=a/h,u=2*n.index;e[u]=c,e[u+1]=d}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s>e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s<e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}}};
1
+ function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}class e{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,i){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,i){throw new Error("Not Implemented")}}class n{describeTo(t){throw new Error("Not Implemented")}}class i extends n{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class r{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class s extends e{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,i){return this.appendList(t,e,n,new r(i)),this}appendList(t,e,n,i){let r=!1;this.appendText(t);const s=i[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())r&&this.appendText(e),this.appendDescriptionOf(t.value),r=!0;return this.appendText(n),this}}class o extends s{value="";appendText(t){return this.value+=t,this}}function a(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n,i,r){let s,o,a;for(a=0;a<r;a++)s=e+a,o=i+a,n[o]=t[s]}a.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},a.notEqual=function(t,e,n){a(t!==e,n)},a.notOk=function(t,e){a(!t,e)},a.equal=function(t,e,n){if(t!==e){const i=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${i}`:i)}},a.logicalyEqual=function(t,e,n){},a.ok=a,a.greaterThan=function(t,e,n){if(!(t>e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} > ${e}.`,new Error(i)}},a.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} >= ${e}.`,new Error(i)}},a.lessThan=function(t,e,n){if(!(t<e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} < ${e}.`,new Error(i)}},a.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} <= ${e}.`,new Error(i)}},a.typeOf=function(t,e,n="value"){const i=typeof t;if(i!==e)throw new Error(`expected ${n} to be ${e}, instead was '${i}'(=${t})`)},a.arrayHas=function(t,e,n="Array does not contain the item"){},a.arrayHasNo=function(t,e,n="Array contains the item"){},a.arrayEqual=function(e,n,i="Arrays are not equal"){if(!t(e,n))throw new Error(i)},a.isInstanceOf=function(t,e,n="value",i=e.name){},a.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},a.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},a.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},a.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},a.isObject=function(t,e="value"){const n=typeof t;if("object"!==n)throw new Error(`expected ${e} to be an object, instead was '${n}'(=${t})`)},a.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},a.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},a.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},a.isArrayLike=function(t,e="value"){if(!(Array.isArray(t)||(n=t,n instanceof Int8Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int16Array||n instanceof Uint16Array||n instanceof Int32Array||n instanceof Uint32Array||n instanceof Float32Array||n instanceof Float64Array)))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`);var n},a.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},a.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},a.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},a.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},a.isFiniteNumber=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},a.that=function(t,e,n){if(n.matches(t))return;const i=new o;throw i.appendText(`Expected ${e} to be `),n.describeTo(i),i.appendText(" instead "),n.describeMismatch(t,i),new Error(i.value)};const c=new Uint32Array(781250);function d(t,e){return t<e?e:t}function u(t,e){return t<e?t:e}function l(t,e,n,i,r,s){const o=n[i+0],a=n[i+1],h=n[i+2],c=n[i+3],l=n[i+4],f=n[i+5],g=r[s+0],_=r[s+1],p=r[s+2],y=r[s+3],m=r[s+4],w=r[s+5],v=u(o,g),x=u(a,_),b=u(h,p),A=d(c,y),E=d(l,m),$=d(f,w);t[e+0]=v,t[e+1]=x,t[e+2]=b,t[e+3]=A,t[e+4]=E,t[e+5]=$}function f(t,e,n,i,r,s,o,a){t[e]=n,t[e+1]=i,t[e+2]=r,t[e+3]=s,t[e+4]=o,t[e+5]=a}function g(t,e,n,i,r,s){const o=i-t,a=s-n;return(r-e)*(o+a)+a*o}function _(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function p(t,e,n){let i=t;return i<e&&(i=e),i<n&&(i=n),i}function y(t,e,n){let i=t;return i>e&&(i=e),i>n&&(i=n),i}function m(t,e,n){const i=t[n],r=t[n+1],s=t[n+2];f(t,e,i,r,s,i,r,s)}function w(t,e,n){const i=t[e],r=t[e+1],s=t[e+2];return function(t,e,n,i){const r=i[0],s=i[1],o=i[2],a=1023*(t-r)/(i[3]-r),h=1023*(e-s)/(i[4]-s),c=1023*(n-o)/(i[5]-o);return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(a),Math.round(h),Math.round(c))}(.5*(i+t[e+3]),.5*(r+t[e+4]),.5*(s+t[e+5]),n)}c.pointer=0;const v=c;class x{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}getLeafAddress(t){return 7*t+6*this.__node_count_binary}setLeafData(t,e,n,i,r,s,o,a){const h=this.getLeafAddress(t);f(this.__data_float32,h,n,i,r,s,o,a),this.__data_uint32[h+6]=e}readBounds(t,e,n){h(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let i;i=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(i,e,0),t+=g(e[0],e[1],e[2],e[3],e[4],e[5])}return t}__compute_bounds_area_of_3_boxes(t,e,n){const i=this.__data_float32;return g(y(i[t+0],i[e+0],i[n+0]),y(i[t+1],i[e+1],i[n+1]),y(i[t+2],i[e+2],i[n+2]),p(i[t+3],i[e+3],i[n+3]),p(i[t+4],i[e+4],i[n+4]),p(i[t+5],i[e+5],i[n+5]))}__fitness_function_should_swap_leaves_sah(t,e){const n=d(t-1,0),i=u(t+1,this.__node_count_leaf-1),r=this.getLeafBlockAddress(),s=7*t+r,o=7*n+r,a=7*i+r,h=7*e+r,c=7*d(e-1,0)+r,l=7*u(e+1,this.__node_count_leaf-1)+r;return this.__compute_bounds_area_of_3_boxes(o,s,a)+this.__compute_bounds_area_of_3_boxes(c,h,l)-(this.__compute_bounds_area_of_3_boxes(o,h,a)+this.__compute_bounds_area_of_3_boxes(c,s,l))}sort_bubble_sah(){const t=this.__node_count_leaf;for(let e=0;e<t;e++)for(let n=e+1;n<t;n++)this.__fitness_function_should_swap_leaves_sah(e,n)>0&&this.__swap_leaves(e,n)}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;let n,i,r=2;v[0]=0,v[1]=this.__node_count_leaf-1;const s=this.__data_float32;for(;r>0;){r-=2;const o=v[r+1],a=v[r];n=a,i=o;const h=w(s,7*(a+o>>1)+e,t);for(;n<=i;){for(;w(s,7*n+e,t)<h;)n++;for(;w(s,7*i+e,t)>h;)i--;n<=i&&(n!==i&&this.__swap_leaves(n,i),n++,i--)}a<i&&(v[r++]=a,v[r++]=i),n<o&&(v[r++]=n,v[r++]=o)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),i=7*t+n,r=7*e+n;!function(t,e,n,i,r){for(let r=0;r<7;r++){const s=e+r,o=i+r,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,i,this.__data_float32,r)}build(){const t=this.__node_count_binary,e=6*t;let n,i,r,s,o=Math.floor(Math.log(t)/Math.log(2));r=Math.pow(2,o),i=6*(r-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<r;n++){const t=n<<1,r=t+1,s=e+7*t;r<a?l(c,i,c,s,c,e+7*r):t<a?h(c,s,c,i,6):m(this.__data_float32,i,i-6),i+=6}for(o--;o>=0;o--)for(r=1<<o,s=r-1,n=0;n<r;n++){const t=6*(1+(s<<1));l(c,6*s,c,t,c,t+6),s++}}}function b(t,e,n,i,r,s){const o=t.getLeafAddress(e);!function(t,e,n,i,r,s){const o=3*i,a=3*r,h=3*s,c=n[o],d=n[o+1],u=n[o+2],l=n[a],f=n[a+1],g=n[a+2],_=n[h],m=n[h+1],w=n[h+2];t[e]=y(c,l,_),t[e+1]=y(d,f,m),t[e+2]=y(u,g,w),t[e+3]=p(c,l,_),t[e+4]=p(d,f,m),t[e+5]=p(u,g,w)}(t.__data_float32,o,n,i,r,s),t.__data_uint32[o+6]=e}const A=[],E=[],$="undefined"!=typeof Uint8Array?Uint8Array:Array,S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)A[t]=S[t],E[S.charCodeAt(t)]=t;function U(t,e,n){const i=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);i.push(A[(r=e)>>18&63]+A[r>>12&63]+A[r>>6&63]+A[63&r])}var r;return i.join("")}E["-".charCodeAt(0)]=62,E["_".charCodeAt(0)]=63;class F{static encode(t){return function(t){let e;const n=t.length,i=n%3,r=[],s=16383,o=n-i;for(let e=0;e<o;e+=s){const n=U(t,e,e+s>o?o:e+s);r.push(n)}return 1===i?(e=t[n-1],r.push(A[e>>2]+A[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],r.push(A[e>>10]+A[e>>4&63]+A[e<<2&63]+"=")),r.join("")}(new Uint8Array(t))}static decode(t){return function(t){var e,n,i=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=i[0],s=i[1],o=new $(function(t,e,n){return 3*(e+n)/4-n}(0,r,s)),a=0,h=s>0?r-4:r;for(n=0;n<h;n+=4)e=E[t.charCodeAt(n)]<<18|E[t.charCodeAt(n+1)]<<12|E[t.charCodeAt(n+2)]<<6|E[t.charCodeAt(n+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2===s&&(e=E[t.charCodeAt(n)]<<2|E[t.charCodeAt(n+1)]>>4,o[a++]=255&e),1===s&&(e=E[t.charCodeAt(n)]<<10|E[t.charCodeAt(n+1)]<<4|E[t.charCodeAt(n+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o}(t).buffer}}const z="uint8",C="uint16",V="uint32",B="int8",q="int16",L="int32",M="float32",T="float64",I={[z]:Uint8Array,[C]:Uint16Array,[V]:Uint32Array,[B]:Int8Array,[q]:Int16Array,[L]:Int32Array,float16:Uint16Array,[M]:Float32Array,[T]:Float64Array};function N(t){switch(Object.getPrototypeOf(t).constructor){case Uint8Array:case Uint8ClampedArray:return z;case Uint16Array:return C;case Uint32Array:return V;case Int8Array:return B;case Int16Array:return q;case Int32Array:return L;case Float32Array:return M;case Float64Array:return T;default:throw new Error("unsupported constructor type")}}function O(t,e,n){return t<e?e:t>n?n:t}function k(t,e,n){return(e-t)*n+t}function j(t,e,n,i,r){return.5*(i-e+(2*e-5*n+4*i-r+(3*(n-i)+r-e)*t)*t)*t+n}class D{constructor(t=[],e=1,n=0,i=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(i)||n<0)throw new Error(`height must be a non-negative integer, instead was ${i}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*i*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*i*e}`);this.width=n,this.height=i,this.itemSize=e,this.data=t,this.version=0}get(t,e,n){throw new Error("Deprecated method, use sampleBilinear instead")}sampleCatmullRomUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelCatmullRomUV(t,e,r)}sampleChannelCatmullRomUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelCatmullRom(i,r,n)}sampleChannelCatmullRom(t,e,n){const i=Math.floor(t),r=Math.floor(e),s=t-i,o=e-r,a=s*(s*(1-.5*s)-.5),h=o*(o*(1-.5*o)-.5),c=s*(.5+s*(2-1.5*s)),d=o*(.5+o*(2-1.5*o)),u=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+c,g=1+o*o*(1.5*o-2.5)+d,_=i-1,p=r-1,y=i+2,m=r+2,w=i+c/f,v=r+d/g;let x=0;return x+=this.sampleChannelBilinear(_,p,n)*a*h,x+=this.sampleChannelBilinear(w,p,n)*f*h,x+=this.sampleChannelBilinear(y,p,n)*u*h,x+=this.sampleChannelBilinear(_,v,n)*a*g,x+=this.sampleChannelBilinear(w,v,n)*f*g,x+=this.sampleChannelBilinear(y,v,n)*u*g,x+=this.sampleChannelBilinear(_,m,n)*a*l,x+=this.sampleChannelBilinear(w,m,n)*f*l,x+=this.sampleChannelBilinear(y,m,n)*u*l,x}sampleBicubicUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelBicubicUV(t,e,r)}sampleBicubic(t,e,n,i){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const i=t*this.width,r=e*this.height;return this.sampleChannelBicubic(i-.5,r-.5,n)}sampleChannelBicubic(t,e,n){const i=this.itemSize,r=this.width,s=this.height,o=this.data,a=r*i,h=r-1,c=s-1,l=O(t,0,h),f=O(e,0,c),g=0|l,_=0|f,p=l-g,y=f-_,m=d(0,g-1),w=d(0,_-1),v=u(h,g+1),x=u(c,_+1),b=u(h,v+1),A=w*a+n,E=_*a+n,$=x*a+n,S=u(c,x+1)*a+n,U=m*i,F=g*i,z=v*i,C=b*i,V=o[A+U],B=o[A+F],q=o[A+z],L=o[A+C],M=o[E+U],T=o[E+F],I=o[E+z],N=o[E+C],k=o[$+U],D=o[$+F],R=o[$+z],J=o[$+C],P=o[S+U],H=o[S+F],W=o[S+z],G=o[S+C],Y=j(p,V,B,q,L),K=j(p,M,T,I,N),Q=j(p,k,D,R,J),X=j(p,P,H,W,G);return j(y,Y,K,Q,X)}sampleBilinearUV(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelBilinear(i,r,n)}sampleChannelBilinear(t,e,n){const i=this.itemSize,r=this.width,s=r*i,o=this.height-1,a=O(t,0,r-1),h=O(e,0,o),c=a>>>0,d=h>>>0,u=d*s,l=c*i+n,f=u+l;let g,_;g=a===c?c:c+1,_=h===d?d:d+1;const p=this.data,y=p[f];if(c===g&&d===_)return y;const m=a-c,w=h-d,v=g*i+n,x=_*s,b=x+l,A=x+v,E=p[u+v],$=p[b],S=p[A],U=k(y,E,m),F=k($,S,m);return k(U,F,w)}sampleNearestUV(t,e,n){const i=this.width,r=this.height,s=Math.round(t*i-.5),o=Math.round(e*r-.5);this.read(O(s,0,i-1),O(o,0,r-1),n)}readChannel(t,e,n){const i=(e*this.width+t)*this.itemSize+n;return this.data[i]}read(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++)n[t]=this.data[s+t]}write(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++)this.data[s+t]=n[t]}sample(t,e,n){const i=[];return this.sampleBilinear(t*(this.width-1),e*(this.height-1),i,0),n.readFromArray(i),i[0]}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,i=t%n,r=t/n|0;e.set(i,r)}copy(t,e,n,i,r,s,o){const a=Math.min(s,t.width-e,this.width-i),h=Math.min(o,t.height-n,this.height-r),c=this.itemSize,d=t.itemSize,u=Math.min(c,d),l=c*this.width,f=d*t.width,g=t.data,_=this.data;let p,y,m;for(y=0;y<h;y++){const t=(y+r)*l,s=(y+n)*f;for(p=0;p<a;p++){const n=t+(p+i)*c,r=s+(p+e)*d;for(m=0;m<u;m++)_[n+m]=g[r+m]}}this.version++}zeroFill(t,e,n,i){const r=O(t,0,this.width),s=O(e,0,this.height),o=O(t+n,0,this.width),a=O(e+i,0,this.height),h=this.data,c=this.itemSize,d=c*this.width,u=r*c,l=o*c;let f;for(f=s;f<a;f++){const t=f*d;h.fill(0,t+u,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,i=this.data,r=i.length;for(let s=t;s<r;s+=n)i[s]=e;this.version++}fill(t,e,n,i,r){const s=this.width,o=this.height,a=O(t,0,s),h=O(e,0,o),c=O(t+n,0,s),d=O(e+i,0,o),u=this.data,l=this.itemSize,f=l*s;let g,_,p;for(g=h;g<d;g++){const t=g*f;for(_=a;_<c;_++){const e=t+_*l;for(p=0;p<l;p++)u[e+p]=r[p]}}this.version++}writeChannel(t,e,n,i){const r=(e*this.width+t)*this.itemSize+n;this.data[r]=i,this.version++}set(t,e,n){const i=this.data,r=this.itemSize,s=r*this.width*e+t*r;for(let t=0;t<r;t++)i[s+t]=n[t];this.version++}traverseCircle(t,e,n,i){let r,s;const o=0|t,a=0|e,h=n*n,c=Math.ceil(n);for(s=-c;s<=c;s++){const t=s*s;for(r=-c;r<=c;r++)r*r+t<=h&&i(o+r,a+s,this)}}resize(t,e,n=!0){const i=this.width,r=this.height;if(i===t&&r===e)return;const s=this.itemSize,o=t*e*s,a=this.data,h=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===i)h.set(a.subarray(0,Math.min(a.length,o)));else{const n=u(e,r),o=u(t,i);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const r=(e*t+n)*s,o=(e*i+n)*s;for(let t=0;t<s;t++)h[r+t]=a[o+t]}}this.width=t,this.height=e,this.data=h,this.version++}computeByteSize(){let t;return t=Array.isArray(this.data)?8*this.data.length:this.data.buffer.byteLength,t+280}equals(e){return this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const i=e.length;if(i!==n.length)return!1;if(0===i)return!0;if(i<128)return t(e,n);const r=e.byteLength;if(r!==n.byteLength)return!1;const s=e.constructor;if(s!==n.constructor)return!1;const o=e.buffer,a=n.buffer;if(o===a&&e.byteOffset===n.byteOffset)return!0;let h=e,c=n;const d=s.BYTES_PER_ELEMENT;return d<4&&r%4==0?(h=new Uint32Array(o,e.byteOffset,r/4),c=new Uint32Array(a,n.byteOffset,r/4)):d<2&&r%2==0&&(h=new Uint16Array(o,e.byteOffset,r/2),c=new Uint16Array(a,n.byteOffset,r/2)),t(h,c)}(this.data,e.data)}hash(){let t=((65535&this.width)<<16|65535&this.height)^this.itemSize;const e=this.data.length,n=Math.max(1,Math.ceil(e/509));return t^=function(t,e,n,i){let r=n;for(let e=0;e<n;e+=i)r=(r<<5)-r+(t[e]>>>0);return r>>>0}(this.data,0,e,n),t}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new D(t,this.itemSize,this.width,this.height)}toJSON(){const t=F.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:N(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:i,data:r}){const s=function(t){const e=I[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(i);if("string"==typeof r){const t=F.decode(r);this.data=new s(t)}else{if(!Array.isArray(r))throw new Error("Unsupported data format");this.data=new s(r)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const i=new Uint8ClampedArray(e*n*t);return new D(i,t,e,n)}static uint8(t,e,n){const i=new Uint8Array(e*n*t);return new D(i,t,e,n)}static uint16(t,e,n){const i=new Uint16Array(e*n*t);return new D(i,t,e,n)}static uint32(t,e,n){const i=new Uint32Array(e*n*t);return new D(i,t,e,n)}static int8(t,e,n){const i=new Int8Array(e*n*t);return new D(i,t,e,n)}static int16(t,e,n){const i=new Int16Array(e*n*t);return new D(i,t,e,n)}static int32(t,e,n){const i=new Int32Array(e*n*t);return new D(i,t,e,n)}static float32(t,e,n){const i=new Float32Array(e*n*t);return new D(i,t,e,n)}static float64(t,e,n){const i=new Float64Array(e*n*t);return new D(i,t,e,n)}}function R(t,e,n){return Math.sqrt(t*t+e*e+n*n)}function J(t,e,n,i){const r=n[i],s=n[i+1],o=n[i+2],a=1/R(r,s,o);t[e]=r*a,t[e+1]=s*a,t[e+2]=o*a}D.prototype.isSampler2D=!0,D.typeName="Sampler2D";const P={build:function(t,e,n,i,r,s){const o=n.x*s,a=n.y*s,h=o-1,c=a-1;let d=0,u=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),_=new Float32Array(2*l);let p,y;const m=n.y/r.y/c,w=n.x/r.x/h,v=e.y/r.y,x=e.x/r.x,b=r.x*i.x,A=r.y*i.y;let E,$,S;for(p=0;p<a;p++){const e=p*m+v;for(S=e*A,y=0;y<o;y++){const n=y*w+x;E=n*b,$=t.sampleChannelBicubicUV(n,e,0),f[d]=E,f[d+1]=$,f[d+2]=S,_[u]=n,_[u+1]=e,d+=3,u+=2}}d=0;const U=new(f.length/3>65535?Uint32Array:Uint16Array)(h*c*6);for(p=0;p<c;p++)for(y=0;y<h;y++){const t=y+o*p,e=y+o*(p+1),n=y+1+o*(p+1),i=y+1+o*p;U[d]=t,U[d+1]=e,U[d+2]=i,U[d+3]=e,U[d+4]=n,U[d+5]=i,d+=6}return function(t,e,n){let i,r,s,o,a,h,c,d,u,l,f,g,_,p,y,m,w,v,x,b,A,E=0;const $=n.length;for(;E<$;E+=3)i=3*n[E],r=3*n[E+1],s=3*n[E+2],o=t[i],a=t[i+1],h=t[i+2],c=t[r],d=t[r+1],u=t[r+2],l=t[s],f=t[s+1],g=t[s+2],_=l-c,p=f-d,y=g-u,m=o-c,w=a-d,v=h-u,x=p*v-y*w,b=y*m-_*v,A=_*w-p*m,e[i]+=x,e[i+1]+=b,e[i+2]+=A,e[r]+=x,e[r+1]+=b,e[r+2]+=A,e[s]+=x,e[s+1]+=b,e[s+2]+=A;!function(t){const e=t.length;for(let n=0;n<e;n+=3)J(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:_}}};function H(t,e,n=0,i=t.length){const r=n+i;for(let i=n;i<r;i++)if(t[i]===e)return t.splice(i,1),!0;return!1}function W(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function G(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}let Y=0;class K{constructor(){this.index=Y++,this.v0=null,this.v1=null,this.faces=[],this.lengthSqr=-1}get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new K;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsEdge(this)||(t(`Missing back-link from face[${r}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,i=n.length;for(let t=0;t<i;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){return 1===this.faces.length}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,i=t.y,r=t.z,s=n-e.x,o=i-e.y,a=r-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,i=e.length;for(let r=0;r<i;r++){const i=e[r];i.removeEdge(t),-1===n.indexOf(i)&&(n.push(i),i.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){W(this.faces,t)}removeFace(t){H(this.faces,t)}getOtherVertex(t){return G(this,t)}containsVertex(t){return e=t,this.v0===e||this.v1===e;var e}containsBothVertices(t,e){return function(t,e,n){const i=t.v0,r=t.v1;return!(i!==e&&i!==n||r!==e&&r!==n)}(this,t,e)}containsSameVerticesAs(t){return this.containsBothVertices(t.v0,t.v1)}}function Q(t,e,n){const i=t.length;for(let r=0;r<i;r++)t[r]===e&&(t[r]=n)}K.prototype.isTopoEdge=!0;var X,Z="undefined"!=typeof Float32Array?Float32Array:Array;function tt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),X=new Z(3),Z!=Float32Array&&(X[0]=0,X[1]=0,X[2]=0);let et=0;class nt{constructor(){this.index=et++,this.vertices=[],this.edges=[],this.normal=[0,0,0]}get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),tt(this.normal,t.normal)}clone(){const t=new nt;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,i=n.length;3!==i&&(t(`Expected number of vertices is 3, instead got ${i}`),e=!1);for(let r=0;r<i;r++)n[r].containsFace(this)||(t(`Missing back-link from vertex[${r}]`),e=!1);const r=this.edges,s=r.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)r[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){Q(this.edges,t,e)}replaceVertex(t,e){Q(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],i=t[2];return e===n||e===i||n===i}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,i=n.length;for(let t=0;t<i;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return W(this.edges,t)}removeEdge(t){H(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],i=t[2];!function(t,e,n,i){!function(t,e,n,i,r,s,o,a,h,c,d){const u=h-s,l=c-o,f=d-a,g=n-s,_=i-o,p=r-a,y=l*p-f*_,m=f*g-u*p,w=u*_-l*g,v=function(t,e,n){return t*t+e*e+n*n}(y,m,w);if(0===v)return t[0]=0,t[1]=1,void(t[2]=0);const x=1/Math.sqrt(v),b=y*x,A=m*x,E=w*x;t[0]=b,t[1]=A,t[2]=E}(t,0,e[0],e[1],e[2],n[0],n[1],n[2],i[0],i[1],i[2])}(this.normal,e,n,i)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].faces,o=r.length;for(let i=0;i<o;i++){const s=r[i];s!==this&&(t[e+n]=s,n++)}}return n}}nt.prototype.isTopoFace=!0;class it{constructor(){this.index=0,this.edges=[],this.faces=[],this.x=0,this.y=0,this.z=0}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new it;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsVertex(this)||(t(`Missing back-link from face[${r}]`),e=!1);const r=this.edges,s=r.length;for(let n=0;n<s;n++)r[n].containsVertex(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,i=this.z,R(t.x-e,t.y-n,t.z-i);var e,n,i}addFace(t){this.faces.push(t)}addUniqueFace(t){return W(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){H(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return W(this.edges,t)}replaceEdge(t,e){const n=this.edges,i=n.indexOf(t);n[i]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return H(this.edges,t)}replaceAnotherVertex(t){const e=t.faces,n=e.length;let i=0;for(;i<n;i++){const n=e[i];n.replaceVertex(t,this),this.addUniqueFace(n)}const r=t.edges,s=r.length;for(i=0;i<s;i++){const e=r[i];e.replaceVertex(t,this),this.addUniqueEdge(e)}}computeNeighbourVertices(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].getOtherVertex(this);t[e+n]=r,n++}return n}}function rt(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}it.prototype.isTopoVertex=!0;class st{constructor(){this.vertices=[],this.__edges=new Set,this.__faces=new Set}get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t){let e=!0,n="",i=0;function r(r){t(`${n}[${i}]: ${r}`),e=!1}n="Edge",i=0;const s=this.getEdges();for(let t of s){t.validate(r),this.containsVertex(t.v0)||r("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||r("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||r(`Link to off-mesh face[${t}]`)}i++}const o=this.getFaces();n="Face",i=0;for(let t of o){t.validate(r);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||r(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||r(`Link to off-mesh vertex[${t}]`)}i++}const a=this.vertices,h=a.length;n="Vertex";for(let t=0;t<h;t++){i=t;const e=a[t];e.validate(r);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||r(`Link to off-mesh edge[${t}]`)}const o=e.faces,h=o.length;for(let t=0;t<h;t++){const e=o[t];this.containsFace(e)||r(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new st;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let i=0;i<n;i++){const n=e[i];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new nt;tt(n.normal,t.normal);const i=t.vertices;for(let t=0;t<3;t++){const r=i[t];let s=e.get(r.index);void 0===s&&(s=new it,s.index=r.index,s.x=r.x,s.y=r.y,s.z=r.z,e.set(r.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n);const r=n.vertices,s=r[0],o=r[1],a=r[2],h=this.ensureEdge(s,o),c=this.ensureEdge(o,a),d=this.ensureEdge(a,s);h.addUniqueFace(n),c.addUniqueFace(n),d.addUniqueFace(n),n.addUniqueEdge(h),n.addUniqueEdge(c),n.addUniqueEdge(d)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){W(this.vertices,t)}removeVertex(t){var e;e=t,H(this.vertices,e)}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){var e;e=t,this.__edges.delete(e)}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const i=t.vertices,r=i.length;for(let t=0;t<r;t++){const e=i[t];this.addUniqueVertex(e)}}removeFace(t){var e;e=t,this.__faces.delete(e)}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,i=n.length;for(let r=0;r<i;r++){const i=n[r];if(G(i,t)===e)return i}const r=new K;return r.v0=t,r.v1=e,t.edges.push(r),e.edges.push(r),this.__edges.add(r),r}mergeEdges(){const t=this.getEdges();for(let e of t){const n=e.v0,i=e.v1;for(let r of t){if(e===r)continue;const t=r.v0,s=r.v1;if(n===t){if(i!==s)continue}else{if(n!==s)continue;if(i!==t)continue}this.removeEdge(r),e.merge(r)}}}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}build(t,e){const n=e.length,i=t.length/3,r=this.vertices;for(let e=0;e<i;e++){const n=3*e,i=new it;i.index=e,i.x=t[n],i.y=t[n+1],i.z=t[n+2],r[e]=i}const s=n/3,o=this.getFaces();for(let t=0;t<s;t++){const n=3*t,i=e[n],s=e[n+1],a=e[n+2],h=r[i],c=r[s],d=r[a],u=new nt;u.index=t;const l=this.ensureEdge(h,c),f=this.ensureEdge(c,d),g=this.ensureEdge(d,h);l.faces.push(u),f.faces.push(u),g.faces.push(u),u.vertices.push(h,c,d),u.edges.push(l,f,g),h.faces.push(u),c.faces.push(u),d.faces.push(u),o.add(u)}}toString(){return`TopoMesh{ vertices: ${rt(this.vertices.length)}, edges: ${rt(this.getEdges().size)}, faces: ${rt(this.getFaces().size)} }`}}st.prototype.isTopoMesh=!0,self.Lib={build_bvh(t,e){const n=new x;return function(t,e,n){const i=n.length/3;t.setLeafCount(i),t.initialize_structure();for(let r=0;r<i;r++){const i=3*r;b(t,r,e,n[i],n[i+1],n[i+2])}t.build()}(n,t,e),n},Sampler2D:D,BufferedGeometryArraysBuilder:P,tensionOptimizeUV:function(t,e,n,i){const r=new st;r.build(t,n),r.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<i;t++)t:for(let t=0;t<s;t++){const n=r.vertices[t],i=n.edges,s=i.length;if(0===s)continue;let o=0,a=0,h=0;for(let t=0;t<s;t++){const r=i[t];if(r.isTopologyBorder())continue t;const s=2*r.getOtherVertex(n).index,c=e[s],d=e[s+1],u=1/r.lengthSqr;o+=c*u,a+=d*u,h+=u}const c=o/h,d=a/h,u=2*n.index;e[u]=c,e[u+1]=d}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s>e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s<e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}}};
package/build/meep.cjs CHANGED
@@ -1748,10 +1748,10 @@ const EPSILON = 0.000001;
1748
1748
  * Comparison of two numbers with a given tolerance
1749
1749
  * @param {number} a
1750
1750
  * @param {number} b
1751
- * @param {number} tolerance
1751
+ * @param {number} [tolerance]
1752
1752
  * @returns {boolean}
1753
1753
  */
1754
- function epsilonEquals(a, b, tolerance) {
1754
+ function epsilonEquals(a, b, tolerance = EPSILON) {
1755
1755
 
1756
1756
  return Math.abs(a - b) <= tolerance;
1757
1757
  }
@@ -2607,10 +2607,10 @@ let Vector3$1 = class Vector3 {
2607
2607
 
2608
2608
  // calculate quat * vector
2609
2609
 
2610
- var ix = qw * x + qy * z - qz * y;
2611
- var iy = qw * y + qz * x - qx * z;
2612
- var iz = qw * z + qx * y - qy * x;
2613
- var iw = -qx * x - qy * y - qz * z;
2610
+ const ix = qw * x + qy * z - qz * y;
2611
+ const iy = qw * y + qz * x - qx * z;
2612
+ const iz = qw * z + qx * y - qy * x;
2613
+ const iw = -qx * x - qy * y - qz * z;
2614
2614
 
2615
2615
  // calculate result * inverse quat
2616
2616
 
@@ -3192,9 +3192,9 @@ Vector3$1.typeName = "Vector3";
3192
3192
  */
3193
3193
  Vector3$1._dot = v3_dot;
3194
3194
 
3195
- const forward = new Vector3$1();
3196
- const up = new Vector3$1();
3197
- const right = new Vector3$1();
3195
+ const scratch_v3_a = new Vector3$1();
3196
+ const scratch_v3_b = new Vector3$1();
3197
+ const scratch_v3_c = new Vector3$1();
3198
3198
 
3199
3199
  const sin$1 = Math.sin;
3200
3200
  const cos$1 = Math.cos;
@@ -3295,12 +3295,12 @@ let Quaternion$1 = class Quaternion {
3295
3295
  * @param {number} uz up vector
3296
3296
  */
3297
3297
  _lookRotation(fx, fy, fz, ux, uy, uz) {
3298
- forward.set(fx, fy, fz);
3299
- forward.normalize();
3298
+ scratch_v3_a.set(fx, fy, fz);
3299
+ scratch_v3_a.normalize();
3300
3300
 
3301
- right._crossVectors(ux, uy, uz, forward.x, forward.y, forward.z);
3301
+ scratch_v3_c._crossVectors(ux, uy, uz, scratch_v3_a.x, scratch_v3_a.y, scratch_v3_a.z);
3302
3302
 
3303
- if (right.lengthSq() === 0) {
3303
+ if (scratch_v3_c.lengthSq() === 0) {
3304
3304
  // up and forward are parallel
3305
3305
 
3306
3306
  /*
@@ -3309,32 +3309,32 @@ let Quaternion$1 = class Quaternion {
3309
3309
  */
3310
3310
 
3311
3311
  if (Math.abs(uz) === 1) {
3312
- forward.x += 0.001;
3312
+ scratch_v3_a.x += 0.001;
3313
3313
  } else {
3314
- forward.z += 0.001;
3314
+ scratch_v3_a.z += 0.001;
3315
3315
  }
3316
3316
 
3317
- forward.normalize();
3318
- right._crossVectors(ux, uy, uz, forward.x, forward.y, forward.z);
3317
+ scratch_v3_a.normalize();
3318
+ scratch_v3_c._crossVectors(ux, uy, uz, scratch_v3_a.x, scratch_v3_a.y, scratch_v3_a.z);
3319
3319
 
3320
3320
  }
3321
3321
 
3322
- right.normalize();
3322
+ scratch_v3_c.normalize();
3323
3323
 
3324
- up.crossVectors(forward, right);
3324
+ scratch_v3_b.crossVectors(scratch_v3_a, scratch_v3_c);
3325
3325
 
3326
3326
  // construct partial transform matrix
3327
- const m00 = right.x;
3328
- const m10 = right.y;
3329
- const m20 = right.z;
3327
+ const m00 = scratch_v3_c.x;
3328
+ const m10 = scratch_v3_c.y;
3329
+ const m20 = scratch_v3_c.z;
3330
3330
 
3331
- const m01 = up.x;
3332
- const m11 = up.y;
3333
- const m21 = up.z;
3331
+ const m01 = scratch_v3_b.x;
3332
+ const m11 = scratch_v3_b.y;
3333
+ const m21 = scratch_v3_b.z;
3334
3334
 
3335
- const m02 = forward.x;
3336
- const m12 = forward.y;
3337
- const m22 = forward.z;
3335
+ const m02 = scratch_v3_a.x;
3336
+ const m12 = scratch_v3_a.y;
3337
+ const m22 = scratch_v3_a.z;
3338
3338
 
3339
3339
  this.__setFromRotationMatrix(
3340
3340
  m00, m01, m02,
@@ -3368,7 +3368,7 @@ let Quaternion$1 = class Quaternion {
3368
3368
  }
3369
3369
 
3370
3370
  /**
3371
- *
3371
+ * Makes this quaternion into an inverse of the other
3372
3372
  * @param {Quaternion} other
3373
3373
  */
3374
3374
  copyInverse(other) {
@@ -3388,7 +3388,7 @@ let Quaternion$1 = class Quaternion {
3388
3388
  const length_sqr = x * x + y * y + z * z + w * w;
3389
3389
 
3390
3390
  if (length_sqr === 0) {
3391
- this.set(0, 0, 0, 0);
3391
+ this.set(0, 0, 0, 1);
3392
3392
  return;
3393
3393
  }
3394
3394
 
@@ -3444,6 +3444,7 @@ let Quaternion$1 = class Quaternion {
3444
3444
  * @param {number} angle
3445
3445
  */
3446
3446
  _fromAxisAngle(ax, ay, az, angle) {
3447
+
3447
3448
  const halfAngle = angle * 0.5;
3448
3449
 
3449
3450
  const sinA2 = sin$1(halfAngle);
@@ -3482,7 +3483,7 @@ let Quaternion$1 = class Quaternion {
3482
3483
  // perform projection of rotation onto axis
3483
3484
  const d = v3_dot(x, y, z, axis.x, axis.y, axis.z);
3484
3485
 
3485
- const mag2 = (axis.x * axis.x + axis.y * axis.y + axis.z * axis.z);
3486
+ const mag2 = axis.x * axis.x + axis.y * axis.y + axis.z * axis.z;
3486
3487
 
3487
3488
  const m = d / mag2;
3488
3489
 
@@ -3996,58 +3997,6 @@ let Quaternion$1 = class Quaternion {
3996
3997
  this.set(_x, _y, _z, _w);
3997
3998
  }
3998
3999
 
3999
- /**
4000
- * Based on blog post: http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
4001
- * @param {Vector3} from
4002
- * @param {Vector3} to
4003
- */
4004
- fromNonUnitVectors(from, to) {
4005
- //quat quat::fromtwovectors(vec3 u, vec3 v)
4006
- // {
4007
- // vec3 w = cross(u, v);
4008
- // quat q = quat(dot(u, v), w.x, w.y, w.z);
4009
- // q.w += length(q);
4010
- // return normalize(q);
4011
- // }
4012
-
4013
- const ax = from.x;
4014
- const ay = from.y;
4015
- const az = from.z;
4016
-
4017
- const bx = to.x;
4018
- const by = to.y;
4019
- const bz = to.z;
4020
-
4021
- //compute cross product
4022
- const crossX = ay * bz - az * by;
4023
- const crossY = az * bx - ax * bz;
4024
- const crossZ = ax * by - ay * bx;
4025
-
4026
- const uv_dot = v3_dot(ax, ay, az, bx, by, bz);
4027
-
4028
-
4029
- const qX = crossX;
4030
- const qY = crossY;
4031
- const qZ = crossZ;
4032
- const qW = uv_dot;
4033
-
4034
- const p0 = qX * qX + qY * qY + qZ * qZ;
4035
-
4036
- const l0 = Math.sqrt(p0 + qW * qW);
4037
-
4038
- const qW_1 = qW + l0;
4039
-
4040
- //normalize result
4041
- const l1 = 1 / Math.sqrt(p0 + qW_1 * qW_1);
4042
-
4043
- const x = qX * l1;
4044
- const y = qY * l1;
4045
- const z = qZ * l1;
4046
- const w = qW * l1;
4047
-
4048
- this.set(x, y, z, w);
4049
- }
4050
-
4051
4000
  /**
4052
4001
  * NOTE: Vectors need to be normalized
4053
4002
  * Based on blog post: http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
@@ -49028,6 +48977,7 @@ function compute_typed_array_constructor_from_data_type(dt) {
49028
48977
  * @returns {boolean}
49029
48978
  */
49030
48979
  function is_typed_array_equals(a, b) {
48980
+
49031
48981
  if (a === b) {
49032
48982
  // quick shortcut
49033
48983
  return true;
@@ -61407,7 +61357,6 @@ function arrayIndexByEquality(array, element, equals) {
61407
61357
  */
61408
61358
  function arraySetDiff(a, b, equals = strictEquals) {
61409
61359
 
61410
- // TODO we can do this faster if we use a comparator instead of equality and pre-sort the data
61411
61360
  const uniqueA = a.slice();
61412
61361
  const uniqueB = b.slice();
61413
61362
 
@@ -63458,7 +63407,13 @@ function needsSerialization(value) {
63458
63407
 
63459
63408
  class WorkerProxy {
63460
63409
 
63410
+ /**
63411
+ *
63412
+ * @type {{}}
63413
+ * @private
63414
+ */
63461
63415
  __pending = {};
63416
+
63462
63417
  __isRunning = false;
63463
63418
 
63464
63419
  /**
@@ -63486,11 +63441,12 @@ class WorkerProxy {
63486
63441
  /**
63487
63442
  * Invoke a given method on the worker, as defined by the `WorkerBuilder`
63488
63443
  * @template T
63489
- * @param {number} name Method's name
63444
+ * @param {string} name Method's name
63490
63445
  * @param {Array} args
63491
63446
  * @return {Promise<T>} eventual result of the invoked method
63492
63447
  */
63493
63448
  $submitRequest(name, args) {
63449
+
63494
63450
  const pending = this.__pending[name];
63495
63451
 
63496
63452
  const argumentCount = args.length;
@@ -63537,7 +63493,13 @@ class WorkerProxy {
63537
63493
  });
63538
63494
  }
63539
63495
 
63496
+ /**
63497
+ *
63498
+ * @param {string} name
63499
+ * @private
63500
+ */
63540
63501
  __makeMethod(name) {
63502
+
63541
63503
  if (this.__pending.hasOwnProperty(name)) {
63542
63504
  throw new Error(`Method '${name}' already defined`);
63543
63505
  }
@@ -63622,15 +63584,16 @@ class WorkerProxy {
63622
63584
  /**
63623
63585
  *
63624
63586
  * @param {number} id
63625
- * @param {string} methodName
63587
+ * @param {string} method_name
63626
63588
  * @returns {boolean}
63627
63589
  */
63628
- cancelRequest(id, methodName) {
63590
+ cancelRequest(id, method_name) {
63591
+
63629
63592
  //find request
63630
- const requestQueue = this.__pending[methodName];
63593
+ const requestQueue = this.__pending[method_name];
63631
63594
 
63632
63595
  if (requestQueue === undefined) {
63633
- throw new Error(`No request queue for method name '${methodName}'`);
63596
+ throw new Error(`No request queue for method name '${method_name}'`);
63634
63597
  }
63635
63598
 
63636
63599
  const n = requestQueue.length;
@@ -63702,8 +63665,16 @@ const RxMatchFunctionName = /(function\s*)([a-zA-Z0-9_]+)?(\s*\([^\]]*\)\s*\{.*)
63702
63665
 
63703
63666
  class WorkerBuilder {
63704
63667
 
63668
+ /**
63669
+ *
63670
+ * @type {string[]}
63671
+ */
63705
63672
  imports = [];
63706
63673
  methods = {};
63674
+ /**
63675
+ *
63676
+ * @type {{f:function, name:string}[]}
63677
+ */
63707
63678
  functions = [];
63708
63679
  preamble = new LineBuilder();
63709
63680
 
@@ -75920,9 +75891,10 @@ function planeHash(plane) {
75920
75891
  * @template T
75921
75892
  * @param {T[]} array
75922
75893
  * @param {function(T):number} elementHashFunction
75894
+ * @param {*} [thisArg]
75923
75895
  * @returns {number}
75924
75896
  */
75925
- function computeHashArray(array, elementHashFunction) {
75897
+ function computeHashArray(array, elementHashFunction, thisArg) {
75926
75898
 
75927
75899
  const numArguments = array.length;
75928
75900
  let hash = numArguments;
@@ -75931,7 +75903,7 @@ function computeHashArray(array, elementHashFunction) {
75931
75903
 
75932
75904
  const singleValue = array[i];
75933
75905
 
75934
- const elementHash = elementHashFunction(singleValue);
75906
+ const elementHash = elementHashFunction.call(thisArg, singleValue);
75935
75907
 
75936
75908
  hash = ((hash << 5) - hash) + elementHash;
75937
75909
  hash |= 0; // Convert to 32bit integer
@@ -76270,6 +76242,7 @@ function bitmap2sampler_gl(gl, sampler, bitmap) {
76270
76242
  *
76271
76243
  * @param {number[]|Uint8Array} a
76272
76244
  * @param {number[]|Uint8Array} b
76245
+ * @returns {boolean}
76273
76246
  */
76274
76247
  function fastArrayEquals(a, b) {
76275
76248
  if (Array.isArray(a) || Array.isArray(b)) {
@@ -89110,7 +89083,13 @@ function compare_three_objects(a, b) {
89110
89083
  * @param {number} [maxIndex]
89111
89084
  * @return {number} Index
89112
89085
  */
89113
- function binarySearchHighIndex(array, el, compareFunction, minIndex = 0, maxIndex = array.length - 1) {
89086
+ function binarySearchHighIndex(
89087
+ array,
89088
+ el,
89089
+ compareFunction,
89090
+ minIndex = 0,
89091
+ maxIndex = array.length - 1
89092
+ ) {
89114
89093
  let min = minIndex;
89115
89094
  let max = maxIndex;
89116
89095
 
@@ -98074,16 +98053,16 @@ ObjectPoolFactory.prototype.create = ObjectPoolFactory.prototype.get;
98074
98053
  */
98075
98054
  function isArrayEqual(first, second) {
98076
98055
 
98077
- const il = first.length;
98056
+ const element_count = first.length;
98078
98057
 
98079
- if (il !== second.length) {
98058
+ if (element_count !== second.length) {
98080
98059
  // arrays are of different size
98081
98060
  return false;
98082
98061
  }
98083
98062
 
98084
98063
  let i = 0;
98085
98064
 
98086
- for (; i < il; i++) {
98065
+ for (; i < element_count; i++) {
98087
98066
 
98088
98067
  const a = first[i];
98089
98068
  const b = second[i];
@@ -98092,19 +98071,16 @@ function isArrayEqual(first, second) {
98092
98071
  continue;
98093
98072
  }
98094
98073
 
98095
-
98096
- if (a === undefined) {
98097
- // A is undefined, and B is something else
98098
- return false;
98099
- }
98100
-
98101
- if (a === null) {
98102
- // A is null and B is something else
98074
+ if (
98075
+ a === undefined || a === null
98076
+ || b === undefined || b === null
98077
+ ) {
98078
+ // shortcut to avoid working with nulls and undefined values
98103
98079
  return false;
98104
98080
  }
98105
98081
 
98106
98082
  // try "equals" method
98107
- if (typeof a.equals === "function") {
98083
+ if (typeof a === "object" && typeof a.equals === "function") {
98108
98084
 
98109
98085
  if (!a.equals(b)) {
98110
98086
  return false;
@@ -115039,7 +115015,7 @@ function removeBindings(mapping, devices, proxies) {
115039
115015
  }
115040
115016
 
115041
115017
  /**
115042
- * @deprecated Use {@link InputSystem} instead
115018
+ * Prefer to use {@link InputSystem} instead
115043
115019
  */
115044
115020
  class InputControllerSystem extends System {
115045
115021
  constructor(devices) {
@@ -116106,6 +116082,17 @@ class EngineHarness {
116106
116082
  this.p = null;
116107
116083
  }
116108
116084
 
116085
+ /**
116086
+ * Quick initialization of the engine in a sensible default configuration
116087
+ * @param {(config:EngineConfiguration,engine:Engine)=>*} [configuration]
116088
+ * @return {Promise<Engine>}
116089
+ */
116090
+ static async bootstrap({ configuration } = {}) {
116091
+ const harness = new EngineHarness();
116092
+
116093
+ return harness.initialize({ configuration });
116094
+ }
116095
+
116109
116096
  /**
116110
116097
  *
116111
116098
  * @param {Engine} engine
@@ -116123,7 +116110,7 @@ class EngineHarness {
116123
116110
  }
116124
116111
 
116125
116112
  /**
116126
- * @param {(config:EngineConfiguration,engine:Engine)=>*} configuration
116113
+ * @param {(config:EngineConfiguration,engine:Engine)=>*} [configuration]
116127
116114
  * @param {boolean} [enable_localization] Whether or not to load localization data
116128
116115
  * @returns {Promise<Engine>}
116129
116116
  */