@woosh/meep-engine 2.109.5 → 2.109.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +211 -179
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +211 -179
- package/editor/tools/v2/TransformControls.js +39 -33
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/BVH.js +8 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +11 -9
- package/src/core/collection/queue/Deque.d.ts.map +1 -1
- package/src/core/collection/queue/Deque.js +8 -5
- package/src/core/geom/3d/Ray3.js +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +1 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +4 -4
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +15 -11
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.d.ts.map +1 -1
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +13 -7
- package/src/core/geom/3d/normal/octahedron/encoding.spec.js +26 -1
- package/src/core/geom/3d/normal/octahedron/prototype.d.ts +2 -0
- package/src/core/geom/3d/normal/octahedron/prototype.d.ts.map +1 -0
- package/src/core/geom/3d/normal/octahedron/prototype.js +226 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.d.ts +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.js +4 -4
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +7 -1
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +6 -0
- package/src/core/geom/vec3/v3_distance.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_distance.js +5 -5
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +10 -0
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +34 -0
- package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts +5 -1
- package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts.map +1 -1
- package/src/core/model/node-graph/json/serializeNodeGraphToJSON.js +11 -6
- package/src/engine/asset/loaders/AssetLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/AssetLoader.js +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.js +6 -1
- package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureHash.js +8 -3
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts.map +1 -1
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +9 -15
- package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts +7 -0
- package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts.map +1 -0
- package/src/engine/graphics/geometry/instancing/geometry_copy.js +15 -0
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -20
- package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts +1 -0
- package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +4 -0
- package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +6 -6
- package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +16 -7
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +3 -2
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +25 -14
- package/src/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +1 -0
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +48 -33
- package/src/engine/graphics/sh3/gi/material/common.glsl +434 -0
- package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts +8 -0
- package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.js +35 -0
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts +8 -0
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +28 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +53 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.js +29 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts +9 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.js +12 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.js +26 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js +62 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/preable.frag.glsl +43 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/preable.vert.glsl +9 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts +9 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.js +12 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +2 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +35 -3
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +67 -8
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +10 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +27 -41
- package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts +17 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js +100 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts +12 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +58 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts +11 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js +45 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.frag.glsl +126 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.vert.glsl +10 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts +13 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +146 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +159 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.vert.glsl +13 -0
- package/src/engine/graphics/sh3/lpv/depth/sh3_bake_depth.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.js → depth/sh3_bake_depth.js} +7 -7
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +3 -6
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +34 -58
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +8 -0
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +8 -5
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts +7 -0
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js +50 -0
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +40 -3
- package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.js → sorting/build_bvh_nodes_distances_along_ray.js} +2 -2
- package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.js → sorting/build_bvh_nodes_distances_sqr_to_point.js} +2 -2
- package/src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.js → sorting/sort_bvh_nodes_by_distance_to_point.js} +3 -3
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +40 -7
- package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts.map +1 -0
- package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js +29 -0
- package/src/engine/graphics/sh3/shader/visualize.frag.glsl +41 -0
- package/src/engine/graphics/sh3/shader/visualize.vert.glsl +9 -0
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +1 -1
- package/src/engine/graphics/texture/debug_preview_texture.d.ts +8 -0
- package/src/engine/graphics/texture/debug_preview_texture.d.ts.map +1 -0
- package/src/engine/graphics/texture/debug_preview_texture.js +38 -0
- package/src/engine/graphics/texture/virtual/prototype.js +4 -3
- package/src/view/View.d.ts.map +1 -1
- package/src/view/View.js +2 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts +0 -8
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts.map +0 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.js +0 -32
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +0 -8
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +0 -1
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +0 -44
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +0 -8
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +0 -1
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +0 -86
- package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +0 -1
- package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +0 -83
- package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +0 -1
- package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +0 -71
- package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +0 -1
- package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +0 -256
- package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts +0 -2
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +0 -27
- package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +0 -1
- /package/src/engine/graphics/sh3/gi/material/{build_fragment_shader.d.ts → space_fragment/build_fragment_shader.d.ts} +0 -0
- /package/src/engine/graphics/sh3/gi/material/{build_vertex_shader.d.ts → space_fragment/build_vertex_shader.d.ts} +0 -0
- /package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.d.ts → depth/sh3_bake_depth.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.d.ts → sorting/build_bvh_nodes_distances_along_ray.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.d.ts → sorting/build_bvh_nodes_distances_sqr_to_point.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.d.ts → sorting/sort_bvh_nodes_by_distance_to_point.d.ts} +0 -0
- /package/src/engine/graphics/sh3/{SH3VisualisationMaterial.d.ts → shader/SH3VisualisationMaterial.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const n=t.length;if(n!==e.length)return!1;let i=0;for(;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(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,i){const r=t[e],s=t[e+1],o=t[e+2],a=1/Math.hypot(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 J={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)R(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:_}}};function P(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 H(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function W(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}let G=0;class Y{constructor(){this.index=G++,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 Y;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){H(this.faces,t)}removeFace(t){P(this.faces,t)}getOtherVertex(t){return W(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 K(t,e,n){const i=t.length;for(let r=0;r<i;r++)t[r]===e&&(t[r]=n)}Y.prototype.isTopoEdge=!0;var Q,X="undefined"!=typeof Float32Array?Float32Array:Array;function Z(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)}),Q=new X(3),X!=Float32Array&&(Q[0]=0,Q[1]=0,Q[2]=0);let tt=0;class et{constructor(){this.index=tt++,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(),Z(this.normal,t.normal)}clone(){const t=new et;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){K(this.edges,t,e)}replaceVertex(t,e){K(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 H(this.edges,t)}removeEdge(t){P(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}}et.prototype.isTopoFace=!0;class nt{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 nt;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,s=t.y,o=t.z,Math.sqrt(function(t,e,n,i,r,s){const o=t-i,a=e-r,h=n-s;return o*o+a*a+h*h}(e,n,i,r,s,o));var e,n,i,r,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return H(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){P(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return H(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 P(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 it(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}nt.prototype.isTopoVertex=!0;class rt{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 rt;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 et;Z(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 nt,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){H(this.vertices,t)}removeVertex(t){var e;e=t,P(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(W(i,t)===e)return i}const r=new Y;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 nt;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 et;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: ${it(this.vertices.length)}, edges: ${it(this.getEdges().size)}, faces: ${it(this.getFaces().size)} }`}}rt.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:J,tensionOptimizeUV:function(t,e,n,i){const r=new rt;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;let i=0;for(;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",L="int16",M="int32",q="float32",T="float64",I={[z]:Uint8Array,[C]:Uint16Array,[V]:Uint32Array,[B]:Int8Array,[L]:Int16Array,[M]:Int32Array,float16:Uint16Array,[q]: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 L;case Int32Array:return M;case Float32Array:return q;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],L=o[A+z],M=o[A+C],q=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,L,M),K=j(p,q,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(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,i){const r=t[e],s=t[e+1],o=t[e+2],a=1/Math.hypot(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 J={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)R(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:_}}};function P(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 H(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function W(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}let G=0;class Y{constructor(){this.index=G++,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 Y;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){H(this.faces,t)}removeFace(t){P(this.faces,t)}getOtherVertex(t){return W(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 K(t,e,n){const i=t.length;for(let r=0;r<i;r++)t[r]===e&&(t[r]=n)}Y.prototype.isTopoEdge=!0;var Q,X="undefined"!=typeof Float32Array?Float32Array:Array;function Z(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)}),Q=new X(3),X!=Float32Array&&(Q[0]=0,Q[1]=0,Q[2]=0);let tt=0;class et{constructor(){this.index=tt++,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(),Z(this.normal,t.normal)}clone(){const t=new et;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){K(this.edges,t,e)}replaceVertex(t,e){K(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 H(this.edges,t)}removeEdge(t){P(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}}et.prototype.isTopoFace=!0;class nt{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 nt;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,s=t.y,o=t.z,Math.hypot(r-e,s-n,o-i);var e,n,i,r,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return H(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){P(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return H(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 P(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 it(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}nt.prototype.isTopoVertex=!0;class rt{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 rt;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 et;Z(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 nt,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){H(this.vertices,t)}removeVertex(t){var e;e=t,P(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(W(i,t)===e)return i}const r=new Y;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 nt;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 et;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: ${it(this.vertices.length)}, edges: ${it(this.getEdges().size)}, faces: ${it(this.getFaces().size)} }`}}rt.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:J,tensionOptimizeUV:function(t,e,n,i){const r=new rt;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
|
@@ -52162,6 +52162,14 @@ class BVH {
|
|
|
52162
52162
|
return this.__root;
|
|
52163
52163
|
}
|
|
52164
52164
|
|
|
52165
|
+
/**
|
|
52166
|
+
* Make sure you understand what you're doing before using this
|
|
52167
|
+
* @param {number} v
|
|
52168
|
+
*/
|
|
52169
|
+
set root(v) {
|
|
52170
|
+
this.__root = v;
|
|
52171
|
+
}
|
|
52172
|
+
|
|
52165
52173
|
/**
|
|
52166
52174
|
*
|
|
52167
52175
|
* @returns {number}
|
|
@@ -56722,7 +56730,7 @@ class AABB3 {
|
|
|
56722
56730
|
|
|
56723
56731
|
/**
|
|
56724
56732
|
* Get center position of the box
|
|
56725
|
-
* @param {Vector3} target where to write result
|
|
56733
|
+
* @param {Vector3} [target] where to write result
|
|
56726
56734
|
*/
|
|
56727
56735
|
getCenter(target = new Vector3$1()) {
|
|
56728
56736
|
const x = this.getCenterX();
|
|
@@ -68009,7 +68017,7 @@ class AssetLoader {
|
|
|
68009
68017
|
*
|
|
68010
68018
|
* @param {AssetRequestScope} scope
|
|
68011
68019
|
* @param {string} path
|
|
68012
|
-
* @param {function(Asset)} success
|
|
68020
|
+
* @param {function(asset:Asset)} success
|
|
68013
68021
|
* @param {function} failure
|
|
68014
68022
|
* @param {function(current:number, total:number)} progress
|
|
68015
68023
|
*/
|
|
@@ -75813,6 +75821,125 @@ class GenericRendererAdapter extends AbstractRenderAdapter {
|
|
|
75813
75821
|
|
|
75814
75822
|
}
|
|
75815
75823
|
|
|
75824
|
+
/**
|
|
75825
|
+
*
|
|
75826
|
+
* @param {Plane} plane
|
|
75827
|
+
* @returns {number}
|
|
75828
|
+
*/
|
|
75829
|
+
function planeHash(plane) {
|
|
75830
|
+
return mortonEncode_magicbits(plane.normal.x, plane.normal.y, plane.normal.z) ^ plane.constant;
|
|
75831
|
+
}
|
|
75832
|
+
|
|
75833
|
+
/**
|
|
75834
|
+
* @template T
|
|
75835
|
+
* @param {T[]} array
|
|
75836
|
+
* @param {function(T):number} elementHashFunction
|
|
75837
|
+
* @returns {number}
|
|
75838
|
+
*/
|
|
75839
|
+
function computeHashArray(array, elementHashFunction) {
|
|
75840
|
+
|
|
75841
|
+
const numArguments = array.length;
|
|
75842
|
+
let hash = numArguments;
|
|
75843
|
+
|
|
75844
|
+
for (let i = 0; i < numArguments; i++) {
|
|
75845
|
+
|
|
75846
|
+
const singleValue = array[i];
|
|
75847
|
+
|
|
75848
|
+
const elementHash = elementHashFunction(singleValue);
|
|
75849
|
+
|
|
75850
|
+
hash = ((hash << 5) - hash) + elementHash;
|
|
75851
|
+
hash |= 0; // Convert to 32bit integer
|
|
75852
|
+
}
|
|
75853
|
+
|
|
75854
|
+
return hash;
|
|
75855
|
+
}
|
|
75856
|
+
|
|
75857
|
+
/**
|
|
75858
|
+
*
|
|
75859
|
+
* @param {THREE.Texture} texture
|
|
75860
|
+
* @return {number}
|
|
75861
|
+
*/
|
|
75862
|
+
function textureHashById(texture) {
|
|
75863
|
+
if (texture === undefined || texture === null) {
|
|
75864
|
+
return 0;
|
|
75865
|
+
}
|
|
75866
|
+
|
|
75867
|
+
return texture.id;
|
|
75868
|
+
}
|
|
75869
|
+
|
|
75870
|
+
/**
|
|
75871
|
+
*
|
|
75872
|
+
* @param {THREE.Color} c
|
|
75873
|
+
*/
|
|
75874
|
+
function computeHashColor(c) {
|
|
75875
|
+
return c.getHex();
|
|
75876
|
+
}
|
|
75877
|
+
|
|
75878
|
+
/**
|
|
75879
|
+
*
|
|
75880
|
+
* @param {Material|MeshStandardMaterial|ShaderMaterial} material
|
|
75881
|
+
* @returns {number}
|
|
75882
|
+
*/
|
|
75883
|
+
function computeMaterialHash(material) {
|
|
75884
|
+
|
|
75885
|
+
let hash = computeHashIntegerArray(
|
|
75886
|
+
computeHashFloat(material.alphaTest),
|
|
75887
|
+
material.blendDst,
|
|
75888
|
+
material.blendDstAlpha === null ? 0 : computeHashFloat(material.blendDstAlpha),
|
|
75889
|
+
material.blendEquation,
|
|
75890
|
+
material.blendEquationAlpha === null ? 0 : computeHashFloat(material.blendEquationAlpha),
|
|
75891
|
+
material.blending,
|
|
75892
|
+
material.blendSrc,
|
|
75893
|
+
material.blendSrcAlpha === null ? 0 : computeHashFloat(material.blendSrcAlpha),
|
|
75894
|
+
material.clipIntersection ? 0 : 1,
|
|
75895
|
+
material.clippingPlanes === null ? 0 : computeHashArray(material.clippingPlanes, planeHash),
|
|
75896
|
+
material.clipShadows ? 0 : 1,
|
|
75897
|
+
material.colorWrite ? 0 : 1,
|
|
75898
|
+
material.depthFunc,
|
|
75899
|
+
material.depthTest ? 0 : 1,
|
|
75900
|
+
material.depthWrite ? 0 : 1,
|
|
75901
|
+
material.fog ? 0 : 1,
|
|
75902
|
+
computeHashFloat(material.opacity),
|
|
75903
|
+
material.polygonOffset ? 0 : 1,
|
|
75904
|
+
computeHashFloat(material.polygonOffsetFactor),
|
|
75905
|
+
computeHashFloat(material.polygonOffsetUnits),
|
|
75906
|
+
computeStringHash(material.precision),
|
|
75907
|
+
material.premultipliedAlpha ? 0 : 1,
|
|
75908
|
+
material.dithering ? 0 : 1,
|
|
75909
|
+
material.flatShading ? 0 : 1,
|
|
75910
|
+
material.side,
|
|
75911
|
+
material.transparent ? 0 : 1,
|
|
75912
|
+
computeStringHash(material.type),
|
|
75913
|
+
material.vertexColors ? 0 : 1,
|
|
75914
|
+
material.visible ? 0 : 1,
|
|
75915
|
+
);
|
|
75916
|
+
|
|
75917
|
+
|
|
75918
|
+
if (material.isMeshStandardMaterial) {
|
|
75919
|
+
hash = computeHashIntegerArray(
|
|
75920
|
+
hash,
|
|
75921
|
+
computeHashColor(material.color),
|
|
75922
|
+
computeHashFloat(material.roughness),
|
|
75923
|
+
computeHashFloat(material.metalness),
|
|
75924
|
+
textureHashById(material.map),
|
|
75925
|
+
textureHashById(material.lightMap),
|
|
75926
|
+
computeHashFloat(material.lightMapIntensity),
|
|
75927
|
+
textureHashById(material.aoMap),
|
|
75928
|
+
computeHashFloat(material.aoMapIntensity),
|
|
75929
|
+
computeHashColor(material.emissive),
|
|
75930
|
+
computeHashFloat(material.emissiveIntensity),
|
|
75931
|
+
textureHashById(material.emissiveMap),
|
|
75932
|
+
computeHashFloat(material.envMapIntensity),
|
|
75933
|
+
textureHashById(material.bumpMap),
|
|
75934
|
+
textureHashById(material.normalMap),
|
|
75935
|
+
);
|
|
75936
|
+
} else if (material.isShaderMaterial) {
|
|
75937
|
+
hash ^= material.lights ? 0 : 1;
|
|
75938
|
+
}
|
|
75939
|
+
|
|
75940
|
+
return hash;
|
|
75941
|
+
}
|
|
75942
|
+
|
|
75816
75943
|
class TextureAttachment {
|
|
75817
75944
|
/**
|
|
75818
75945
|
* @template T
|
|
@@ -75974,6 +76101,46 @@ const TextureAttachmentsByMaterialType = {
|
|
|
75974
76101
|
|
|
75975
76102
|
TextureAttachmentsByMaterialType.MeshPhysicalMaterial = TextureAttachmentsByMaterialType.MeshStandardMaterial;
|
|
75976
76103
|
|
|
76104
|
+
/**
|
|
76105
|
+
* NOTE: based on https://github.com/garycourt/murmurhash-js/blob/master/murmurhash3_gc.js
|
|
76106
|
+
* @param {Uint32Array} key
|
|
76107
|
+
* @param {number} seed
|
|
76108
|
+
* @returns {number}
|
|
76109
|
+
*/
|
|
76110
|
+
function murmur3_32(key, seed) {
|
|
76111
|
+
let h1 = seed;
|
|
76112
|
+
let k1;
|
|
76113
|
+
let i = 0;
|
|
76114
|
+
|
|
76115
|
+
const key_length = key.length;
|
|
76116
|
+
|
|
76117
|
+
while (i < key_length) {
|
|
76118
|
+
k1 = key[i];
|
|
76119
|
+
++i;
|
|
76120
|
+
|
|
76121
|
+
k1 = ((((k1 & 0xffff) * 0xcc9e2d51) + ((((k1 >>> 16) * 0xcc9e2d51) & 0xffff) << 16)));
|
|
76122
|
+
k1 = (k1 << 15) | (k1 >>> 17);
|
|
76123
|
+
k1 = ((((k1 & 0xffff) * 0x1b873593) + ((((k1 >>> 16) * 0x1b873593) & 0xffff) << 16)));
|
|
76124
|
+
|
|
76125
|
+
h1 ^= k1;
|
|
76126
|
+
h1 = (h1 << 13) | (h1 >>> 19);
|
|
76127
|
+
h1 = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16)));
|
|
76128
|
+
h1 = (((h1 & 0xffff) + 0x6b64) + ((((h1 >>> 16) + 0xe654) & 0xffff) << 16));
|
|
76129
|
+
}
|
|
76130
|
+
|
|
76131
|
+
// mix in array length
|
|
76132
|
+
h1 ^= key_length;
|
|
76133
|
+
|
|
76134
|
+
h1 ^= h1 >>> 16;
|
|
76135
|
+
h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16));
|
|
76136
|
+
h1 ^= h1 >>> 13;
|
|
76137
|
+
h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16)));
|
|
76138
|
+
h1 ^= h1 >>> 16;
|
|
76139
|
+
|
|
76140
|
+
// cast to uint32
|
|
76141
|
+
return h1 >>> 0;
|
|
76142
|
+
}
|
|
76143
|
+
|
|
75977
76144
|
/**
|
|
75978
76145
|
* Transfer bitmap contents to Sampler2D, effectively moving data to CPU, making it readable
|
|
75979
76146
|
* @param {WebGL2RenderingContext} gl
|
|
@@ -76165,46 +76332,6 @@ function computeImageBitmapHash(bitmap) {
|
|
|
76165
76332
|
return hash;
|
|
76166
76333
|
}
|
|
76167
76334
|
|
|
76168
|
-
/**
|
|
76169
|
-
* NOTE: based on https://github.com/garycourt/murmurhash-js/blob/master/murmurhash3_gc.js
|
|
76170
|
-
* @param {Uint32Array} key
|
|
76171
|
-
* @param {number} seed
|
|
76172
|
-
* @returns {number}
|
|
76173
|
-
*/
|
|
76174
|
-
function murmur3_32(key, seed) {
|
|
76175
|
-
let h1 = seed;
|
|
76176
|
-
let k1;
|
|
76177
|
-
let i = 0;
|
|
76178
|
-
|
|
76179
|
-
const key_length = key.length;
|
|
76180
|
-
|
|
76181
|
-
while (i < key_length) {
|
|
76182
|
-
k1 = key[i];
|
|
76183
|
-
++i;
|
|
76184
|
-
|
|
76185
|
-
k1 = ((((k1 & 0xffff) * 0xcc9e2d51) + ((((k1 >>> 16) * 0xcc9e2d51) & 0xffff) << 16)));
|
|
76186
|
-
k1 = (k1 << 15) | (k1 >>> 17);
|
|
76187
|
-
k1 = ((((k1 & 0xffff) * 0x1b873593) + ((((k1 >>> 16) * 0x1b873593) & 0xffff) << 16)));
|
|
76188
|
-
|
|
76189
|
-
h1 ^= k1;
|
|
76190
|
-
h1 = (h1 << 13) | (h1 >>> 19);
|
|
76191
|
-
h1 = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16)));
|
|
76192
|
-
h1 = (((h1 & 0xffff) + 0x6b64) + ((((h1 >>> 16) + 0xe654) & 0xffff) << 16));
|
|
76193
|
-
}
|
|
76194
|
-
|
|
76195
|
-
// mix in array length
|
|
76196
|
-
h1 ^= key_length;
|
|
76197
|
-
|
|
76198
|
-
h1 ^= h1 >>> 16;
|
|
76199
|
-
h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16));
|
|
76200
|
-
h1 ^= h1 >>> 13;
|
|
76201
|
-
h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16)));
|
|
76202
|
-
h1 ^= h1 >>> 16;
|
|
76203
|
-
|
|
76204
|
-
// cast to uint32
|
|
76205
|
-
return h1 >>> 0;
|
|
76206
|
-
}
|
|
76207
|
-
|
|
76208
76335
|
/**
|
|
76209
76336
|
*
|
|
76210
76337
|
* @param {Vector2} v
|
|
@@ -76236,7 +76363,12 @@ function computeImageDataHash(image) {
|
|
|
76236
76363
|
|
|
76237
76364
|
let result = 0;
|
|
76238
76365
|
|
|
76239
|
-
if (
|
|
76366
|
+
if (
|
|
76367
|
+
// check that browser/environment has the class at all to avoid potential exceptions
|
|
76368
|
+
// Required for Safari below version 15.6
|
|
76369
|
+
ImageBitmap !== undefined
|
|
76370
|
+
&& (image instanceof ImageBitmap)
|
|
76371
|
+
) {
|
|
76240
76372
|
result = computeImageBitmapHash(image);
|
|
76241
76373
|
} else if (image instanceof HTMLImageElement) {
|
|
76242
76374
|
result = computeStringHash(image.src);
|
|
@@ -76432,7 +76564,12 @@ function textureImagesEqual(a, b) {
|
|
|
76432
76564
|
return false;
|
|
76433
76565
|
}
|
|
76434
76566
|
|
|
76435
|
-
if (
|
|
76567
|
+
if (
|
|
76568
|
+
// check that browser/environment has the class at all to avoid potential exceptions
|
|
76569
|
+
// Required for Safari below version 15.6
|
|
76570
|
+
ImageBitmap !== undefined
|
|
76571
|
+
&& (a instanceof ImageBitmap && b instanceof ImageBitmap)
|
|
76572
|
+
) {
|
|
76436
76573
|
return computeImageBitmapEquality(a, b);
|
|
76437
76574
|
}
|
|
76438
76575
|
|
|
@@ -76536,125 +76673,6 @@ function textureMipmapEqual(a, b) {
|
|
|
76536
76673
|
return fastArrayEquals(aData, bData);
|
|
76537
76674
|
}
|
|
76538
76675
|
|
|
76539
|
-
/**
|
|
76540
|
-
*
|
|
76541
|
-
* @param {Plane} plane
|
|
76542
|
-
* @returns {number}
|
|
76543
|
-
*/
|
|
76544
|
-
function planeHash(plane) {
|
|
76545
|
-
return mortonEncode_magicbits(plane.normal.x, plane.normal.y, plane.normal.z) ^ plane.constant;
|
|
76546
|
-
}
|
|
76547
|
-
|
|
76548
|
-
/**
|
|
76549
|
-
* @template T
|
|
76550
|
-
* @param {T[]} array
|
|
76551
|
-
* @param {function(T):number} elementHashFunction
|
|
76552
|
-
* @returns {number}
|
|
76553
|
-
*/
|
|
76554
|
-
function computeHashArray(array, elementHashFunction) {
|
|
76555
|
-
|
|
76556
|
-
const numArguments = array.length;
|
|
76557
|
-
let hash = numArguments;
|
|
76558
|
-
|
|
76559
|
-
for (let i = 0; i < numArguments; i++) {
|
|
76560
|
-
|
|
76561
|
-
const singleValue = array[i];
|
|
76562
|
-
|
|
76563
|
-
const elementHash = elementHashFunction(singleValue);
|
|
76564
|
-
|
|
76565
|
-
hash = ((hash << 5) - hash) + elementHash;
|
|
76566
|
-
hash |= 0; // Convert to 32bit integer
|
|
76567
|
-
}
|
|
76568
|
-
|
|
76569
|
-
return hash;
|
|
76570
|
-
}
|
|
76571
|
-
|
|
76572
|
-
/**
|
|
76573
|
-
*
|
|
76574
|
-
* @param {THREE.Texture} texture
|
|
76575
|
-
* @return {number}
|
|
76576
|
-
*/
|
|
76577
|
-
function textureHashById(texture) {
|
|
76578
|
-
if (texture === undefined || texture === null) {
|
|
76579
|
-
return 0;
|
|
76580
|
-
}
|
|
76581
|
-
|
|
76582
|
-
return texture.id;
|
|
76583
|
-
}
|
|
76584
|
-
|
|
76585
|
-
/**
|
|
76586
|
-
*
|
|
76587
|
-
* @param {THREE.Color} c
|
|
76588
|
-
*/
|
|
76589
|
-
function computeHashColor(c) {
|
|
76590
|
-
return c.getHex();
|
|
76591
|
-
}
|
|
76592
|
-
|
|
76593
|
-
/**
|
|
76594
|
-
*
|
|
76595
|
-
* @param {Material|MeshStandardMaterial|ShaderMaterial} material
|
|
76596
|
-
* @returns {number}
|
|
76597
|
-
*/
|
|
76598
|
-
function computeMaterialHash(material) {
|
|
76599
|
-
|
|
76600
|
-
let hash = computeHashIntegerArray(
|
|
76601
|
-
computeHashFloat(material.alphaTest),
|
|
76602
|
-
material.blendDst,
|
|
76603
|
-
material.blendDstAlpha === null ? 0 : computeHashFloat(material.blendDstAlpha),
|
|
76604
|
-
material.blendEquation,
|
|
76605
|
-
material.blendEquationAlpha === null ? 0 : computeHashFloat(material.blendEquationAlpha),
|
|
76606
|
-
material.blending,
|
|
76607
|
-
material.blendSrc,
|
|
76608
|
-
material.blendSrcAlpha === null ? 0 : computeHashFloat(material.blendSrcAlpha),
|
|
76609
|
-
material.clipIntersection ? 0 : 1,
|
|
76610
|
-
material.clippingPlanes === null ? 0 : computeHashArray(material.clippingPlanes, planeHash),
|
|
76611
|
-
material.clipShadows ? 0 : 1,
|
|
76612
|
-
material.colorWrite ? 0 : 1,
|
|
76613
|
-
material.depthFunc,
|
|
76614
|
-
material.depthTest ? 0 : 1,
|
|
76615
|
-
material.depthWrite ? 0 : 1,
|
|
76616
|
-
material.fog ? 0 : 1,
|
|
76617
|
-
computeHashFloat(material.opacity),
|
|
76618
|
-
material.polygonOffset ? 0 : 1,
|
|
76619
|
-
computeHashFloat(material.polygonOffsetFactor),
|
|
76620
|
-
computeHashFloat(material.polygonOffsetUnits),
|
|
76621
|
-
computeStringHash(material.precision),
|
|
76622
|
-
material.premultipliedAlpha ? 0 : 1,
|
|
76623
|
-
material.dithering ? 0 : 1,
|
|
76624
|
-
material.flatShading ? 0 : 1,
|
|
76625
|
-
material.side,
|
|
76626
|
-
material.transparent ? 0 : 1,
|
|
76627
|
-
computeStringHash(material.type),
|
|
76628
|
-
material.vertexColors ? 0 : 1,
|
|
76629
|
-
material.visible ? 0 : 1,
|
|
76630
|
-
);
|
|
76631
|
-
|
|
76632
|
-
|
|
76633
|
-
if (material.isMeshStandardMaterial) {
|
|
76634
|
-
hash = computeHashIntegerArray(
|
|
76635
|
-
hash,
|
|
76636
|
-
computeHashColor(material.color),
|
|
76637
|
-
computeHashFloat(material.roughness),
|
|
76638
|
-
computeHashFloat(material.metalness),
|
|
76639
|
-
textureHashById(material.map),
|
|
76640
|
-
textureHashById(material.lightMap),
|
|
76641
|
-
computeHashFloat(material.lightMapIntensity),
|
|
76642
|
-
textureHashById(material.aoMap),
|
|
76643
|
-
computeHashFloat(material.aoMapIntensity),
|
|
76644
|
-
computeHashColor(material.emissive),
|
|
76645
|
-
computeHashFloat(material.emissiveIntensity),
|
|
76646
|
-
textureHashById(material.emissiveMap),
|
|
76647
|
-
computeHashFloat(material.envMapIntensity),
|
|
76648
|
-
textureHashById(material.bumpMap),
|
|
76649
|
-
textureHashById(material.normalMap),
|
|
76650
|
-
);
|
|
76651
|
-
} else if (material.isShaderMaterial) {
|
|
76652
|
-
hash ^= material.lights ? 0 : 1;
|
|
76653
|
-
}
|
|
76654
|
-
|
|
76655
|
-
return hash;
|
|
76656
|
-
}
|
|
76657
|
-
|
|
76658
76676
|
/**
|
|
76659
76677
|
*
|
|
76660
76678
|
* @param {Plane} a
|
|
@@ -77006,6 +77024,22 @@ function composeCompile(previous, next) {
|
|
|
77006
77024
|
return result_function;
|
|
77007
77025
|
}
|
|
77008
77026
|
|
|
77027
|
+
/**
|
|
77028
|
+
*
|
|
77029
|
+
* @param {BufferGeometry} target
|
|
77030
|
+
* @param {BufferGeometry} source
|
|
77031
|
+
*/
|
|
77032
|
+
function geometry_copy(target, source) {
|
|
77033
|
+
target.index = source.index;
|
|
77034
|
+
for (let attributeName in source.attributes) {
|
|
77035
|
+
if (!source.attributes.hasOwnProperty(attributeName)) {
|
|
77036
|
+
continue;
|
|
77037
|
+
}
|
|
77038
|
+
|
|
77039
|
+
target.attributes[attributeName] = source.attributes[attributeName];
|
|
77040
|
+
}
|
|
77041
|
+
}
|
|
77042
|
+
|
|
77009
77043
|
const SHADER_PREAMBLE = `
|
|
77010
77044
|
#define USE_COLOR_ALPHA
|
|
77011
77045
|
#define USE_INSTANCING_COLOR
|
|
@@ -77576,14 +77610,7 @@ class InstancedMeshGroup {
|
|
|
77576
77610
|
geometry.dynamic = true;
|
|
77577
77611
|
|
|
77578
77612
|
//copy instance attributes
|
|
77579
|
-
geometry
|
|
77580
|
-
for (let attributeName in instance.attributes) {
|
|
77581
|
-
if (!instance.attributes.hasOwnProperty(attributeName)) {
|
|
77582
|
-
continue;
|
|
77583
|
-
}
|
|
77584
|
-
|
|
77585
|
-
geometry.attributes[attributeName] = instance.attributes[attributeName];
|
|
77586
|
-
}
|
|
77613
|
+
geometry_copy(geometry, instance);
|
|
77587
77614
|
|
|
77588
77615
|
//build instanced attributes
|
|
77589
77616
|
const newTransformArray = new Float32Array(this.capacity * 16);
|
|
@@ -84987,8 +85014,8 @@ class Deque {
|
|
|
84987
85014
|
|
|
84988
85015
|
let new_length = length * 2;
|
|
84989
85016
|
|
|
84990
|
-
// bigger than Integer.MAX_VALUE
|
|
84991
85017
|
if (new_length > UINT32_MAX) {
|
|
85018
|
+
// clamp to max uint32 value
|
|
84992
85019
|
new_length = UINT32_MAX;
|
|
84993
85020
|
}
|
|
84994
85021
|
|
|
@@ -85018,7 +85045,7 @@ class Deque {
|
|
|
85018
85045
|
* @return {boolean}
|
|
85019
85046
|
*/
|
|
85020
85047
|
isEmpty() {
|
|
85021
|
-
return this
|
|
85048
|
+
return this.#status === STATUS_EMPTY;
|
|
85022
85049
|
}
|
|
85023
85050
|
|
|
85024
85051
|
clear() {
|
|
@@ -85127,9 +85154,10 @@ class Deque {
|
|
|
85127
85154
|
|
|
85128
85155
|
const data = this.#data;
|
|
85129
85156
|
const capacity = data.length;
|
|
85157
|
+
const head = this.#head;
|
|
85130
85158
|
|
|
85131
85159
|
for (let i = 0; i < size; i++) {
|
|
85132
|
-
const index = (
|
|
85160
|
+
const index = (head + i) % capacity;
|
|
85133
85161
|
|
|
85134
85162
|
const el = data[index];
|
|
85135
85163
|
|
|
@@ -85227,13 +85255,15 @@ class Deque {
|
|
|
85227
85255
|
return undefined;
|
|
85228
85256
|
}
|
|
85229
85257
|
|
|
85258
|
+
const data = this.#data;
|
|
85259
|
+
|
|
85230
85260
|
/**
|
|
85231
85261
|
*
|
|
85232
85262
|
* @type {number}
|
|
85233
85263
|
*/
|
|
85234
|
-
const position = (this.#head + index) %
|
|
85264
|
+
const position = (this.#head + index) % data.length;
|
|
85235
85265
|
|
|
85236
|
-
return
|
|
85266
|
+
return data[position];
|
|
85237
85267
|
}
|
|
85238
85268
|
|
|
85239
85269
|
/**
|
|
@@ -106382,9 +106412,11 @@ function v3_morton_encode_transformed(x, y, z, matrix) {
|
|
|
106382
106412
|
* @param {number} z1
|
|
106383
106413
|
* @returns {number}
|
|
106384
106414
|
*/
|
|
106385
|
-
function v3_distance(
|
|
106386
|
-
|
|
106387
|
-
|
|
106415
|
+
function v3_distance(
|
|
106416
|
+
x0, y0, z0,
|
|
106417
|
+
x1, y1, z1
|
|
106418
|
+
) {
|
|
106419
|
+
return Math.hypot(x1 - x0, y1 - y0, z1 - z0);
|
|
106388
106420
|
}
|
|
106389
106421
|
|
|
106390
106422
|
class AbstractTextureAtlas {
|