@woosh/meep-engine 2.126.53 → 2.126.56
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/package.json +1 -1
- package/src/core/geom/3d/mat4/m4_extract_scale.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_extract_scale.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_extract_scale.js +9 -3
- package/src/core/geom/3d/mat4/m4_inverse_rotation_translation.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_inverse_rotation_translation.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_inverse_rotation_translation.js +3 -0
- package/src/core/geom/3d/mat4/m4_invert.d.ts +1 -1
- package/src/core/geom/3d/mat4/m4_invert.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_invert.js +5 -2
- package/src/core/geom/3d/mat4/m4_make_scale.d.ts +1 -1
- package/src/core/geom/3d/mat4/m4_make_scale.js +1 -1
- package/src/core/geom/3d/mat4/m4_make_translation.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_make_translation.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_make_translation.js +3 -0
- package/src/core/geom/3d/mat4/m4_multiply.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_multiply.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_multiply.js +3 -0
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.js +3 -0
- package/src/core/geom/3d/mat4/m4_orthographic_off_center_z0.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_orthographic_off_center_z0.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_orthographic_off_center_z0.js +3 -0
- package/src/core/geom/3d/mat4/m4_rotation_translation.d.ts +2 -1
- package/src/core/geom/3d/mat4/m4_rotation_translation.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_rotation_translation.js +3 -0
- package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts.map +1 -1
- package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +5 -10
- package/src/core/geom/3d/morton/v3_morton_encode_normalized.d.ts +9 -0
- package/src/core/geom/3d/morton/v3_morton_encode_normalized.d.ts.map +1 -0
- package/src/core/geom/3d/morton/v3_morton_encode_normalized.js +26 -0
- package/src/core/geom/3d/morton/v3_morton_encode_transformed.d.ts.map +1 -1
- package/src/core/geom/3d/morton/v3_morton_encode_transformed.js +10 -16
- package/src/core/geom/vec3/v3_array_centroid.d.ts +11 -0
- package/src/core/geom/vec3/v3_array_centroid.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_array_centroid.js +40 -0
- package/src/engine/ecs/Entity.d.ts.map +1 -1
- package/src/engine/ecs/Entity.js +34 -16
- package/src/engine/ecs/EntityReference.d.ts +2 -1
- package/src/engine/ecs/EntityReference.d.ts.map +1 -1
- package/src/engine/ecs/EntityReference.js +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function e(t){if("object"!=typeof t)return!1;if(null===t)return!1;const e=t.constructor;return e===Uint8Array||e===Uint16Array||e===Uint32Array||e===Int8Array||e===Int16Array||e===Int32Array||e===Float32Array||e===Float64Array||e===BigUint64Array||e===BigInt64Array}class n{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,r){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,r){throw new Error("Not Implemented")}}class r{describeTo(t){throw new Error("Not Implemented")}}class i extends r{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class s{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class o extends n{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,r){return this.appendList(t,e,n,new s(r)),this}appendList(t,e,n,r){let i=!1;this.appendText(t);const s=r[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())i&&this.appendText(e),this.appendDescriptionOf(t.value),i=!0;return this.appendText(n),this}}class a extends o{value="";appendText(t){return this.value+=t,this}}function c(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n="value"){if(-1===e.indexOf(t))throw new Error(`${n} must be one of [${e.join(", ")}], instead was '${t}'`)}const u=["string","boolean","number","object","undefined","function","symbol"];function d(t,e,n,r,i){let s,o,a;for(a=0;a<i;a++)s=e+a,o=r+a,n[o]=t[s]}c.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(", ")}]`)},c.notEqual=function(t,e,n){c(t!==e,n)},c.notOk=function(t,e){c(!t,e)},c.equal=function(t,e,n){if(t!==e){const r=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${r}`:r)}},c.logicalyEqual=function(t,e,n){},c.ok=c,c.greaterThan=function(t,e,n){if(!(t>e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} > ${e}.`,new Error(r)}},c.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} >= ${e}.`,new Error(r)}},c.lessThan=function(t,e,n){if(!(t<e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} < ${e}.`,new Error(r)}},c.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} <= ${e}.`,new Error(r)}},c.typeOf=function(t,e,n="value"){h(typeof t,u);const r=typeof t;if(r!==e)throw new Error(`expected ${n} to be ${e}, instead was '${r}'(=${t})`)},c.arrayHas=function(t,e,n="Array does not contain the item"){},c.arrayHasNo=function(t,e,n="Array contains the item"){},c.arrayEqual=function(e,n,r="Arrays are not equal"){if(!t(e,n))throw new Error(r)},c.isOneOf=h,c.isInstanceOf=function(t,e,n="value",r=e.name){},c.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})`)},c.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})`)},c.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})`)},c.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})`)},c.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})`)},c.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},c.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},c.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}')`)},c.isArrayLike=function(t,n="value"){if(!function(t){if(Array.isArray(t))return!0;if("object"!=typeof t)return!1;if(null===t)return!1;if(e(t))return!0;const n=t.length;return!("number"!=typeof n&&!Number.isInteger(n)||n<0)}(t))throw new Error(`expected ${n} to be an array-like structure, instead was something else (typeof ='${typeof t}')`)},c.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},c.undefined=function(t,e="value"){if(void 0!==t)throw new Error(`${e} is not undefined`)},c.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},c.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},c.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},c.isFinite=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},c.isFiniteNumber=c.isFinite,c.that=function(t,e,n){if(n.matches(t))return;const r=new a;throw r.appendText(`Expected ${e} to be `),n.describeTo(r),r.appendText(" instead "),n.describeMismatch(t,r),new Error(r.value)};const l=new Uint32Array(781250);function f(t,e){return t<e?e:t}function g(t,e){return t<e?t:e}function p(t,e,n,r,i,s){const o=n[r+0],a=n[r+1],c=n[r+2],h=n[r+3],u=n[r+4],d=n[r+5],l=i[s+0],p=i[s+1],y=i[s+2],w=i[s+3],_=i[s+4],m=i[s+5],v=g(o,l),x=g(a,p),A=g(c,y),b=f(h,w),E=f(u,_),$=f(d,m);t[e+0]=v,t[e+1]=x,t[e+2]=A,t[e+3]=b,t[e+4]=E,t[e+5]=$}function y(t,e,n,r,i,s,o,a){t[e]=n,t[e+1]=r,t[e+2]=i,t[e+3]=s,t[e+4]=o,t[e+5]=a}function w(t,e,n,r,i,s){const o=r-t,a=s-n;return(i-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 m(t,e,n){const r=t[n],i=t[n+1],s=t[n+2];y(t,e,r,i,s,r,i,s)}function v(t,e,n){const r=t[e],i=t[e+1],s=t[e+2];return function(t,e,n,r){const i=r[0],s=r[1],o=r[2],a=1023*(t-i)/(r[3]-i),c=1023*(e-s)/(r[4]-s),h=1023*(n-o)/(r[5]-o);return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(a),Math.round(c),Math.round(h))}(.5*(r+t[e+3]),.5*(i+t[e+4]),.5*(s+t[e+5]),n)}l.pointer=0;const x=l;class A{__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,r,i,s,o,a){const c=this.getLeafAddress(t);y(this.__data_float32,c,n,r,i,s,o,a),this.__data_uint32[c+6]=e}readBounds(t,e,n){d(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 r;r=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(r,e,0),t+=w(e[0],e[1],e[2],e[3],e[4],e[5])}return t}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;const n=x.pointer;let r,i,s=n;x[s++]=0,x[s++]=this.__node_count_leaf-1;const o=this.__data_float32;for(;s>n;){s-=2;const n=x[s+1],a=x[s];r=a,i=n;const c=v(o,7*(a+n>>1)+e,t);for(;r<=i;){for(;v(o,7*r+e,t)<c;)r++;for(;v(o,7*i+e,t)>c;)i--;r<=i&&(r!==i&&this.__swap_leaves(r,i),r++,i--)}a<i&&(x[s++]=a,x[s++]=i),r<n&&(x[s++]=r,x[s++]=n)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),r=7*t+n,i=7*e+n;!function(t,e,n,r,i){for(let i=0;i<7;i++){const s=e+i,o=r+i,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,r,this.__data_float32,i)}build(){const t=this.__node_count_binary,e=6*t;let n,r,i,s,o=Math.floor(Math.log(t)/Math.log(2));i=Math.pow(2,o),r=6*(i-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<i;n++){const t=n<<1,i=t+1,s=e+7*t;i<a?p(c,r,c,s,c,e+7*i):t<a?d(c,s,c,r,6):m(this.__data_float32,r,r-6),r+=6}for(o--;o>=0;o--)for(i=1<<o,s=i-1,n=0;n<i;n++){const t=6*(1+(s<<1));p(c,6*s,c,t,c,t+6),s++}}}function b(t,e,n){let r=t;return r<e&&(r=e),r<n&&(r=n),r}function E(t,e,n){let r=t;return r>e&&(r=e),r>n&&(r=n),r}function $(t,e,n,r,i,s){const o=t.getLeafAddress(e);!function(t,e,n,r,i,s){const o=3*r,a=3*i,c=3*s,h=n[o],u=n[o+1],d=n[o+2],l=n[a],f=n[a+1],g=n[a+2],p=n[c],y=n[c+1],w=n[c+2];t[e]=E(h,l,p),t[e+1]=E(u,f,y),t[e+2]=E(d,g,w),t[e+3]=b(h,l,p),t[e+4]=b(u,f,y),t[e+5]=b(d,g,w)}(t.__data_float32,o,n,r,i,s),t.__data_uint32[o+6]=e}function F(t){return 1===t.faces.length}function U(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}var S,z="undefined"!=typeof Float32Array?Float32Array:Array;function C(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function V(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function B(){}function q(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function L(t,e,n=0,r=t.length){const i=n+r;for(let r=n;r<i;r++)if(t[r]===e)return t.splice(r,1),!0;return!1}function T(t,e){return t.v0===e||t.v1===e}function M(t,e,n){const r=t.v0,i=t.v1;return!(r!==e&&r!==n||i!==e&&i!==n)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),S=new z(3),z!=Float32Array&&(S[0]=0,S[1]=0,S[2]=0);let I=0;class k{index=I++;v0=null;v1=null;faces=[];lengthSqr=-1;get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new k;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsEdge(this)||(t(`Missing back-link from face[${i}]`),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,r=n.length;for(let t=0;t<r;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){throw new Error('deprecated, use "query_edge_is_boundary" instead')}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,r=t.y,i=t.z,s=n-e.x,o=r-e.y,a=i-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,r=e.length;for(let i=0;i<r;i++){const r=e[i];r.removeEdge(t),-1===n.indexOf(r)&&(n.push(r),r.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){V(this.faces,t)}removeFace(t){L(this.faces,t)}getOtherVertex(t){return U(this,t)}containsVertex(t){return T(this,t)}containsBothVertices(t,e){return M(this,t,e)}containsSameVerticesAs(t){return M(this,t.v0,t.v1)}}function N(t,e,n){const r=t.length;for(let i=0;i<r;i++)t[i]===e&&(t[i]=n);return t}function O(t,e,n){return t*t+e*e+n*n}function j(t,e,n,r,i,s,o,a,c,h,u){const d=c-s,l=h-o,f=u-a,g=n-s,p=r-o,y=i-a,w=l*y-f*p,_=f*g-d*y,m=d*p-l*g,v=O(w,_,m);if(0===v)return t[e]=0,t[e+1]=1,void(t[e+2]=0);const x=1/Math.sqrt(v),A=w*x,b=_*x,E=m*x;t[e]=A,t[e+1]=b,t[e+2]=E}k.prototype.isTopoEdge=!0;let D=0;class R{index=D++;edges=[];faces=[];x=0;y=0;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 R;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsVertex(this)||(t(`Missing back-link from face[${i}]`),e=!1);const i=this.edges,s=i.length;for(let n=0;n<s;n++)T(i[n],this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,r=this.z,i=t.x-e,s=t.y-n,o=t.z-r,Math.sqrt(i*i+s*s+o*o);var e,n,r,i,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return V(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){L(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return V(this.edges,t)}replaceEdge(t,e){const n=this.edges,r=n.indexOf(t);n[r]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return L(this.edges,t)}computeNeighbourVertices(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].getOtherVertex(this);t[e+n]=i,n++}return n}static from(t,e,n){const r=new R;return r.x=t,r.y=e,r.z=n,r}}R.prototype.isTopoVertex=!0;let J=0;class P{index=J++;vertices=[];edges=[];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(),C(this.normal,t.normal)}clone(){const t=new P;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,r=n.length;3!==r&&(t(`Expected number of vertices is 3, instead got ${r}`),e=!1);for(let i=0;i<r;i++)n[i].containsFace(this)||(t(`Missing back-link from vertex[${i}]`),e=!1);const i=this.edges,s=i.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)i[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){N(this.edges,t,e)}replaceVertex(t,e){N(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],r=t[2];return e===n||e===r||n===r}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,r=n.length;for(let t=0;t<r;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return V(this.edges,t)}removeEdge(t){L(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],r=t[2];!function(t,e,n,r){j(t,0,e[0],e[1],e[2],n[0],n[1],n[2],r[0],r[1],r[2])}(this.normal,e,n,r)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].faces,o=i.length;for(let r=0;r<o;r++){const s=i[r];s!==this&&(t[e+n]=s,n++)}}return n}static fromPoints(t,e,n,r,i,s,o,a,c){const h=R.from(t,e,n),u=R.from(r,i,s),d=R.from(o,a,c),l=new k,f=new k,g=new k;l.v0=h,l.v1=u,f.v0=u,f.v1=d,g.v0=d,g.v1=h;const p=new P;return p.edges.push(l,f,g),p.vertices.push(h,u,d),h.faces.push(p),u.faces.push(p),d.faces.push(p),l.faces.push(p),f.faces.push(p),g.faces.push(p),h.edges.push(l,g),u.edges.push(l,f),d.edges.push(f,g),p}}P.prototype.isTopoFace=!0;class H{vertices=[];__edges=new Set;__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=B){let e=!0,n="",r=0;function i(i){t(`${n}[${r}]: ${i}`),e=!1}n="Edge",r=0;const s=this.getEdges();for(let t of s){t.validate(i),this.containsVertex(t.v0)||i("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||i("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)||i(`Link to off-mesh face[${t}]`)}r++}const o=this.getFaces();n="Face",r=0;for(let t of o){t.validate(i);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||i(`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)||i(`Link to off-mesh vertex[${t}]`)}r++}const a=this.vertices,c=a.length;n="Vertex";for(let t=0;t<c;t++){r=t;const e=a[t];e.validate(i);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||i(`Link to off-mesh edge[${t}]`)}const o=e.faces,c=o.length;for(let t=0;t<c;t++){const e=o[t];this.containsFace(e)||i(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new H;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let r=0;r<n;r++){const n=e[r];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 P;C(n.normal,t.normal);const r=t.vertices;for(let t=0;t<3;t++){const i=r[t];let s=e.get(i.index);void 0===s&&(s=new R,s.index=i.index,s.x=i.x,s.y=i.y,s.z=i.z,e.set(i.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n),this.patchFaceEdges(n)}patchFaceEdges(t){const e=t.vertices,n=e[0],r=e[1],i=e[2],s=this.ensureEdge(n,r),o=this.ensureEdge(r,i),a=this.ensureEdge(i,n);s.addUniqueFace(t),o.addUniqueFace(t),a.addUniqueFace(t),t.addUniqueEdge(s),t.addUniqueEdge(o),t.addUniqueEdge(a)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){V(this.vertices,t)}removeVertex(t){throw new Error("deprecated, use tm_kill_only_vert instead")}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){throw new Error("deprecated, use tm_kill_only_edge instead")}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 r=t.vertices,i=r.length;for(let t=0;t<i;t++){const e=r[t];this.addUniqueVertex(e)}}removeFace(t){throw new Error("deprecated, use tm_kill_only_face instead")}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,r=n.length;for(let i=0;i<r;i++){const r=n[i];if(U(r,t)===e)return r}const i=new k;return i.v0=t,i.v1=e,t.edges.push(i),e.edges.push(i),this.__edges.add(i),i}mergeEdges(){const t=this.getEdges();for(let n of t){const r=n.v0,i=n.v1;for(let s of t){if(n===s)continue;const t=s.v0,o=s.v1;if(r===t){if(i!==o)continue}else{if(r!==o)continue;if(i!==t)continue}e=s,this.__edges.delete(e),n.merge(s)}}var e}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}setVerticesFromArray(t){const e=t.length/3,n=this.vertices;for(let r=0;r<e;r++){const e=3*r,i=new R;i.index=r,i.x=t[e],i.y=t[e+1],i.z=t[e+2],n[r]=i}}setFacesFromIndexArray(t){const e=t.length,n=this.vertices,r=e/3;for(let e=0;e<r;e++){const r=3*e,i=t[r],s=t[r+1],o=t[r+2];this.createTriangle(e,n[i],n[s],n[o])}}setFacedUnindexed(){const t=this.vertices,e=t.length/3;for(let n=0;n<e;n++){const e=3*n;this.createTriangle(n,t[e],t[e+1],t[e+2])}}build(t,e){this.setVerticesFromArray(t),null==e?this.setFacedUnindexed():this.setFacesFromIndexArray(e)}createTriangle(t,e,n,r){const i=new P;i.index=t;const s=this.ensureEdge(e,n),o=this.ensureEdge(n,r),a=this.ensureEdge(r,e);return s.faces.push(i),o.faces.push(i),a.faces.push(i),i.vertices.push(e,n,r),i.edges.push(s,o,a),e.faces.push(i),n.faces.push(i),r.faces.push(i),this.__faces.add(i),i}toString(){return`TopoMesh{ vertices: ${q(this.vertices.length)}, edges: ${q(this.getEdges().size)}, faces: ${q(this.getFaces().size)} }`}}H.prototype.isTopoMesh=!0;const W=[],G=[],Y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)W[t]=Y[t],G[Y.charCodeAt(t)]=t;function K(t,e,n){const r=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);r.push(W[(i=e)>>18&63]+W[i>>12&63]+W[i>>6&63]+W[63&i])}var i;return r.join("")}G["-".charCodeAt(0)]=62,G["_".charCodeAt(0)]=63;const Q=16383;class X{static encode(t){return function(t){const e=t.length,n=e%3,r=[],i=e-n;for(let e=0;e<i;e+=Q){const n=K(t,e,e+Q>i?i:e+Q);r.push(n)}if(1===n){const n=t[e-1];r.push(W[n>>2]+W[n<<4&63]+"==")}else if(2===n){const n=(t[e-2]<<8)+t[e-1];r.push(W[n>>10]+W[n>>4&63]+W[n<<2&63]+"=")}return r.join("")}(new Uint8Array(t))}static decode(t){return function(t){let e;const n=function(t){const e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");let n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=n[0],i=n[1],s=new Uint8Array(function(t,e){return 3*(t+e)/4-e}(r,i));let o=0;const a=i>0?r-4:r;let c=0;for(;c<a;c+=4){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2),a=t.charCodeAt(c+3);e=G[n]<<18|G[r]<<12|G[i]<<6|G[a],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=255&e}if(2===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1);e=G[n]<<2|G[r]>>4,s[o++]=255&e}if(1===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2);e=G[n]<<10|G[r]<<4|G[i]>>2,s[o++]=e>>8&255,s[o++]=255&e}return s}(t).buffer}}const Z="uint8",tt="uint16",et="uint32",nt="int8",rt="int16",it="int32",st="float32",ot="float64",at={[Z]:Uint8Array,[tt]:Uint16Array,[et]:Uint32Array,[nt]:Int8Array,[rt]:Int16Array,[it]:Int32Array,float16:Uint16Array,[st]:Float32Array,[ot]:Float64Array};function ct(t){const e=Object.getPrototypeOf(t).constructor;switch(e){case Uint8Array:case Uint8ClampedArray:return Z;case Uint16Array:return tt;case Uint32Array:return et;case Int8Array:return nt;case Int16Array:return rt;case Int32Array:return it;case Float32Array:return st;case Array:case Float64Array:return ot;default:throw new Error(`unsupported constructor type ${e.name}`)}}function ht(t,e,n){return t<e?e:t>n?n:t}function ut(t,e,n){return(e-t)*n+t}function dt(t,e,n,r,i){return.5*(r-e+(2*e-5*n+4*r-i+(3*(n-r)+i-e)*t)*t)*t+n}const lt=4294967295;function ft(t){const e=t>>0;return lt-((t-e)*lt>>>0)^e}class gt{constructor(t=[],e=1,n=0,r=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(r)||n<0)throw new Error(`height must be a non-negative integer, instead was ${r}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*r*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*r*e}`);this.width=n,this.height=r,this.itemSize=e,this.data=t,this.version=0}sampleCatmullRomUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelCatmullRomUV(t,e,i)}sampleChannelCatmullRomUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelCatmullRom(r,i,n)}sampleChannelCatmullRom(t,e,n){const r=Math.floor(t),i=Math.floor(e),s=t-r,o=e-i,a=s*(s*(1-.5*s)-.5),c=o*(o*(1-.5*o)-.5),h=s*(.5+s*(2-1.5*s)),u=o*(.5+o*(2-1.5*o)),d=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+h,g=1+o*o*(1.5*o-2.5)+u,p=r-1,y=i-1,w=r+2,_=i+2,m=r+h/f,v=i+u/g;let x=0;return x+=this.sampleChannelBilinear(p,y,n)*a*c,x+=this.sampleChannelBilinear(m,y,n)*f*c,x+=this.sampleChannelBilinear(w,y,n)*d*c,x+=this.sampleChannelBilinear(p,v,n)*a*g,x+=this.sampleChannelBilinear(m,v,n)*f*g,x+=this.sampleChannelBilinear(w,v,n)*d*g,x+=this.sampleChannelBilinear(p,_,n)*a*l,x+=this.sampleChannelBilinear(m,_,n)*f*l,x+=this.sampleChannelBilinear(w,_,n)*d*l,x}sampleBicubicUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelBicubicUV(t,e,i)}sampleBicubic(t,e,n,r){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const r=t*this.width,i=e*this.height;return this.sampleChannelBicubic(r-.5,i-.5,n)}sampleChannelBicubic(t,e,n){const r=this.itemSize,i=this.width,s=this.height,o=this.data,a=i*r,c=i-1,h=s-1,u=ht(t,0,c),d=ht(e,0,h),l=0|u,p=0|d,y=u-l,w=d-p,_=f(0,l-1),m=f(0,p-1),v=g(c,l+1),x=g(h,p+1),A=g(c,v+1),b=m*a+n,E=p*a+n,$=x*a+n,F=g(h,x+1)*a+n,U=_*r,S=l*r,z=v*r,C=A*r,V=o[b+U],B=o[b+S],q=o[b+z],L=o[b+C],T=o[E+U],M=o[E+S],I=o[E+z],k=o[E+C],N=o[$+U],O=o[$+S],j=o[$+z],D=o[$+C],R=o[F+U],J=o[F+S],P=o[F+z],H=o[F+C],W=dt(y,V,B,q,L),G=dt(y,T,M,I,k),Y=dt(y,N,O,j,D),K=dt(y,R,J,P,H);return dt(w,W,G,Y,K)}sampleBilinearUV(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelBilinear(r,i,n)}sampleChannelBilinear(t,e,n){const r=this.itemSize,i=this.width,s=i*r,o=this.height-1,a=ht(t,0,i-1),c=ht(e,0,o),h=a>>>0,u=c>>>0,d=u*s,l=h*r+n,f=d+l;let g,p;g=a===h?h:h+1,p=c===u?u:u+1;const y=this.data,w=y[f];if(h===g&&u===p)return w;const _=a-h,m=c-u,v=g*r+n,x=p*s,A=x+l,b=x+v,E=y[d+v],$=y[A],F=y[b],U=ut(w,E,_),S=ut($,F,_);return ut(U,S,m)}sampleNearestUV(t,e,n){const r=this.width,i=this.height,s=Math.round(t*r-.5),o=Math.round(e*i-.5);this.read(ht(s,0,r-1),ht(o,0,i-1),n)}readChannel(t,e,n){const r=(e*this.width+t)*this.itemSize+n;return this.data[r]}read(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)n[t]=this.data[s+t]}write(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)this.data[s+t]=n[t];this.version++}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,r=t%n,i=t/n|0;e.set(r,i)}copy(t,e,n,r,i,s,o){const a=Math.min(s,t.width-e,this.width-r),c=Math.min(o,t.height-n,this.height-i),h=this.itemSize,u=t.itemSize,d=Math.min(h,u),l=h*this.width,f=u*t.width,g=t.data,p=this.data;let y,w,_;for(w=0;w<c;w++){const t=(w+i)*l,s=(w+n)*f;for(y=0;y<a;y++){const n=t+(y+r)*h,i=s+(y+e)*u;for(_=0;_<d;_++)p[n+_]=g[i+_]}}this.version++}zeroFill(t,e,n,r){const i=ht(t,0,this.width),s=ht(e,0,this.height),o=ht(t+n,0,this.width),a=ht(e+r,0,this.height),c=this.data,h=this.itemSize,u=h*this.width,d=i*h,l=o*h;let f;for(f=s;f<a;f++){const t=f*u;c.fill(0,t+d,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,r=this.data,i=r.length;for(let s=t;s<i;s+=n)r[s]=e;this.version++}fill(t,e,n,r,i){const s=this.width,o=this.height,a=ht(t,0,s),c=ht(e,0,o),h=ht(t+n,0,s),u=ht(e+r,0,o),d=this.data,l=this.itemSize,f=l*s;let g,p,y;for(g=c;g<u;g++){const t=g*f;for(p=a;p<h;p++){const e=t+p*l;for(y=0;y<l;y++)d[e+y]=i[y]}}this.version++}writeChannel(t,e,n,r){const i=(e*this.width+t)*this.itemSize+n;this.data[i]=r,this.version++}traverseCircle(t,e,n,r){let i,s;const o=0|t,a=0|e,c=n*n,h=Math.ceil(n);for(s=-h;s<=h;s++){const t=s*s;for(i=-h;i<=h;i++)i*i+t<=c&&r(o+i,a+s,this)}}resize(t,e,n=!0){const r=this.width,i=this.height;if(r===t&&i===e)return;const s=this.itemSize,o=t*e*s,a=this.data,c=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===r)c.set(a.subarray(0,Math.min(a.length,o)));else{const n=g(e,i),o=g(t,r);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const i=(e*t+n)*s,o=(e*r+n)*s;for(let t=0;t<s;t++)c[i+t]=a[o+t]}}this.width=t,this.height=e,this.data=c,this.version++}computeByteSize(){let t;const e=this.data;return t=Array.isArray(e)?8*e.length:e.byteLength,t+280}equals(e){return this===e||this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const r=e.length;if(r!==n.length)return!1;const i=e.constructor;if(i!==n.constructor)return!1;if(0===r)return!0;if(r<128)return t(e,n);const s=e.byteLength;if(s!==n.byteLength)return!1;const o=e.buffer,a=n.buffer,c=e.byteOffset,h=n.byteOffset;if(o===a&&c===h)return!0;let u=e,d=n;const l=i.BYTES_PER_ELEMENT,f=function(t,e,n){const r=t|e|n;return 0==(3&r)?4:0==(1&r)?2:1}(c,h,s);return l<4&&4===f?(u=new Uint32Array(o,c,s>>>2),d=new Uint32Array(a,h,s>>>2)):l<2&&2===f&&(u=new Uint16Array(o,c,s>>>1),d=new Uint16Array(a,h,s>>>1)),t(u,d)}(this.data,e.data)}hash(){const t=this.itemSize,n=this.width,r=this.height,i=this.data;let s=((65535&n)<<16|65535&r)^t;const o=n*r*t;if(e(i))s^=function(t,e,n){const r=e|n;return 0==(3&r)?function(t,e,n){let r=n;for(let e=0;e<n;++e)r=(r<<5)-r+t[e];return r}(new Uint32Array(t,e,n>>>2),0,n>>>2):0==(2&r)?function(t,e,n){let r=n,i=0;for(0!=(1&n)&&(r=(r<<5)-r+t[i++]);i<n;i+=2)r=(r<<5)-r+(t[i]<<16|t[i+1]);return r}(new Uint16Array(t,e,n>>>1),0,n>>>1):function(t,e,n){let r=n,i=0;const s=3&n;for(;i<0+s;i++)r=(r<<5)-r+t[i];for(;i<n;i+=4)r=(r<<5)-r+(t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24);return r}(new Uint8Array(t,e,n),0,n)}(i.buffer,i.byteOffset,i.byteLength);else for(let t=0;t<o;++t)s=(s<<5)-s+ft(i[t]);return s}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new gt(t,this.itemSize,this.width,this.height)}toJSON(){const t=X.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:ct(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:r,data:i}){const s=function(t){const e=at[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(r);if("string"==typeof i){const t=X.decode(i);this.data=new s(t)}else{if(!Array.isArray(i))throw new Error("Unsupported data format");this.data=new s(i)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const r=new Uint8ClampedArray(e*n*t);return new gt(r,t,e,n)}static uint8(t,e,n){const r=new Uint8Array(e*n*t);return new gt(r,t,e,n)}static uint16(t,e,n){const r=new Uint16Array(e*n*t);return new gt(r,t,e,n)}static uint32(t,e,n){const r=new Uint32Array(e*n*t);return new gt(r,t,e,n)}static int8(t,e,n){const r=new Int8Array(e*n*t);return new gt(r,t,e,n)}static int16(t,e,n){const r=new Int16Array(e*n*t);return new gt(r,t,e,n)}static int32(t,e,n){const r=new Int32Array(e*n*t);return new gt(r,t,e,n)}static float32(t,e,n){const r=new Float32Array(e*n*t);return new gt(r,t,e,n)}static float64(t,e,n){const r=new Float64Array(e*n*t);return new gt(r,t,e,n)}}function pt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2];t[e]+=i,t[e+1]+=s,t[e+2]+=o}function yt(t,e,n,r,i,s){const o=3*n,a=3*r,c=3*i;j(t,e,s[o],s[o+1],s[o+2],s[a],s[a+1],s[a+2],s[c],s[c+1],s[c+2])}function wt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2],a=O(i,s,o),c=0!==a?1/Math.sqrt(a):1;t[e]=i*c,t[e+1]=s*c,t[e+2]=o*c}gt.prototype.isSampler2D=!0,gt.typeName="Sampler2D";const _t=new Float64Array(3),mt={build:function(t,e,n,r,i,s){const o=n.x*s,a=n.y*s,c=o-1,h=a-1;let u=0,d=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),p=new Float32Array(2*l);let y,w;const _=n.y/i.y/h,m=n.x/i.x/c,v=e.y/i.y,x=e.x/i.x,A=i.x*r.x,b=i.y*r.y;let E,$,F;for(y=0;y<a;y++){const e=y*_+v;for(F=e*b,w=0;w<o;w++){const n=w*m+x;E=n*A,$=t.sampleChannelBicubicUV(n,e,0),f[u]=E,f[u+1]=$,f[u+2]=F,p[d]=n,p[d+1]=e,u+=3,d+=2}}u=0;const U=new(function(t){if(t<=256)return Uint8Array;if(t<=65536)return Uint16Array;if(t<=4294967295)return Uint32Array;throw new Error(`Unsupported size ${t}`)}(f.length/3))(c*h*6);for(y=0;y<h;y++)for(w=0;w<c;w++){const t=w+o*y,e=w+o*(y+1),n=w+1+o*(y+1),r=w+1+o*y;U[u]=t,U[u+1]=e,U[u+2]=r,U[u+3]=e,U[u+4]=n,U[u+5]=r,u+=6}return function(t,e,n){const r=n.length;for(let i=0;i<r;i+=3){const r=n[i],s=n[i+1],o=n[i+2];yt(_t,0,r,s,o,t),pt(e,3*r,_t,0),pt(e,3*s,_t,0),pt(e,3*o,_t,0)}!function(t,e=0,n=t.length-e){const r=e+n;for(let n=e;n<r;n+=3)wt(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:p}}};self.Lib={build_bvh(t,e){const n=new A;return function(t,e,n){const r=n.length/3;t.setLeafCount(r),t.initialize_structure();for(let i=0;i<r;i++){const r=3*i;$(t,i,e,n[r],n[r+1],n[r+2])}t.build()}(n,t,e),n},Sampler2D:gt,BufferedGeometryArraysBuilder:mt,tensionOptimizeUV:function(t,e,n,r=3){const i=new H;i.build(t,n),i.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<r;t++)t:for(let t=0;t<s;t++){const n=i.vertices[t],r=n.edges,s=r.length;if(0===s)continue;let o=0,a=0,c=0;for(let t=0;t<s;t++){const i=r[t];if(F(i))continue t;const s=2*U(i,n).index,h=e[s],u=e[s+1],d=1/i.lengthSqr;o+=h*d,a+=u*d,c+=d}const h=o/c,u=a/c,d=2*n.index;e[d]=h,e[d+1]=u}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s>e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s<e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}}};
|
|
1
|
+
function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function e(t){if("object"!=typeof t)return!1;if(null===t)return!1;const e=t.constructor;return e===Uint8Array||e===Uint16Array||e===Uint32Array||e===Int8Array||e===Int16Array||e===Int32Array||e===Float32Array||e===Float64Array||e===BigUint64Array||e===BigInt64Array}class n{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,r){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,r){throw new Error("Not Implemented")}}class r{describeTo(t){throw new Error("Not Implemented")}}class i extends r{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class s{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class o extends n{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,r){return this.appendList(t,e,n,new s(r)),this}appendList(t,e,n,r){let i=!1;this.appendText(t);const s=r[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())i&&this.appendText(e),this.appendDescriptionOf(t.value),i=!0;return this.appendText(n),this}}class a extends o{value="";appendText(t){return this.value+=t,this}}function c(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n="value"){if(-1===e.indexOf(t))throw new Error(`${n} must be one of [${e.join(", ")}], instead was '${t}'`)}const u=["string","boolean","number","object","undefined","function","symbol"];function d(t,e,n,r,i){let s,o,a;for(a=0;a<i;a++)s=e+a,o=r+a,n[o]=t[s]}c.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(", ")}]`)},c.notEqual=function(t,e,n){c(t!==e,n)},c.notOk=function(t,e){c(!t,e)},c.equal=function(t,e,n){if(t!==e){const r=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${r}`:r)}},c.logicalyEqual=function(t,e,n){},c.ok=c,c.greaterThan=function(t,e,n){if(!(t>e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} > ${e}.`,new Error(r)}},c.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} >= ${e}.`,new Error(r)}},c.lessThan=function(t,e,n){if(!(t<e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} < ${e}.`,new Error(r)}},c.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} <= ${e}.`,new Error(r)}},c.typeOf=function(t,e,n="value"){h(typeof t,u);const r=typeof t;if(r!==e)throw new Error(`expected ${n} to be ${e}, instead was '${r}'(=${t})`)},c.arrayHas=function(t,e,n="Array does not contain the item"){},c.arrayHasNo=function(t,e,n="Array contains the item"){},c.arrayEqual=function(e,n,r="Arrays are not equal"){if(!t(e,n))throw new Error(r)},c.isOneOf=h,c.isInstanceOf=function(t,e,n="value",r=e.name){},c.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})`)},c.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})`)},c.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})`)},c.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})`)},c.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})`)},c.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},c.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},c.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}')`)},c.isArrayLike=function(t,n="value"){if(!function(t){if(Array.isArray(t))return!0;if("object"!=typeof t)return!1;if(null===t)return!1;if(e(t))return!0;const n=t.length;return!("number"!=typeof n&&!Number.isInteger(n)||n<0)}(t))throw new Error(`expected ${n} to be an array-like structure, instead was something else (typeof ='${typeof t}')`)},c.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},c.undefined=function(t,e="value"){if(void 0!==t)throw new Error(`${e} is not undefined`)},c.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},c.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},c.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},c.isFinite=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},c.isFiniteNumber=c.isFinite,c.that=function(t,e,n){if(n.matches(t))return;const r=new a;throw r.appendText(`Expected ${e} to be `),n.describeTo(r),r.appendText(" instead "),n.describeMismatch(t,r),new Error(r.value)};const l=new Uint32Array(781250);function f(t,e){return t<e?e:t}function g(t,e){return t<e?t:e}function p(t,e,n,r,i,s){const o=n[r+0],a=n[r+1],c=n[r+2],h=n[r+3],u=n[r+4],d=n[r+5],l=i[s+0],p=i[s+1],y=i[s+2],w=i[s+3],_=i[s+4],m=i[s+5],v=g(o,l),x=g(a,p),A=g(c,y),b=f(h,w),E=f(u,_),$=f(d,m);t[e+0]=v,t[e+1]=x,t[e+2]=A,t[e+3]=b,t[e+4]=E,t[e+5]=$}function y(t,e,n,r,i,s,o,a){t[e]=n,t[e+1]=r,t[e+2]=i,t[e+3]=s,t[e+4]=o,t[e+5]=a}function w(t,e,n,r,i,s){const o=r-t,a=s-n;return(i-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 m(t,e,n){const r=t[n],i=t[n+1],s=t[n+2];y(t,e,r,i,s,r,i,s)}function v(t,e,n){const r=t[e],i=t[e+1],s=t[e+2];return function(t,e,n,r){const i=r[0],s=r[1],o=r[2];return function(t,e,n){const r=1023*t,i=1023*e,s=1023*n;return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(r),Math.round(i),Math.round(s))}((t-i)/(r[3]-i),(e-s)/(r[4]-s),(n-o)/(r[5]-o))}(.5*(r+t[e+3]),.5*(i+t[e+4]),.5*(s+t[e+5]),n)}l.pointer=0;const x=l;class A{__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,r,i,s,o,a){const c=this.getLeafAddress(t);y(this.__data_float32,c,n,r,i,s,o,a),this.__data_uint32[c+6]=e}readBounds(t,e,n){d(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 r;r=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(r,e,0),t+=w(e[0],e[1],e[2],e[3],e[4],e[5])}return t}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;const n=x.pointer;let r,i,s=n;x[s++]=0,x[s++]=this.__node_count_leaf-1;const o=this.__data_float32;for(;s>n;){s-=2;const n=x[s+1],a=x[s];r=a,i=n;const c=v(o,7*(a+n>>1)+e,t);for(;r<=i;){for(;v(o,7*r+e,t)<c;)r++;for(;v(o,7*i+e,t)>c;)i--;r<=i&&(r!==i&&this.__swap_leaves(r,i),r++,i--)}a<i&&(x[s++]=a,x[s++]=i),r<n&&(x[s++]=r,x[s++]=n)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),r=7*t+n,i=7*e+n;!function(t,e,n,r,i){for(let i=0;i<7;i++){const s=e+i,o=r+i,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,r,this.__data_float32,i)}build(){const t=this.__node_count_binary,e=6*t;let n,r,i,s,o=Math.floor(Math.log(t)/Math.log(2));i=Math.pow(2,o),r=6*(i-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<i;n++){const t=n<<1,i=t+1,s=e+7*t;i<a?p(c,r,c,s,c,e+7*i):t<a?d(c,s,c,r,6):m(this.__data_float32,r,r-6),r+=6}for(o--;o>=0;o--)for(i=1<<o,s=i-1,n=0;n<i;n++){const t=6*(1+(s<<1));p(c,6*s,c,t,c,t+6),s++}}}function b(t,e,n){let r=t;return r<e&&(r=e),r<n&&(r=n),r}function E(t,e,n){let r=t;return r>e&&(r=e),r>n&&(r=n),r}function $(t,e,n,r,i,s){const o=t.getLeafAddress(e);!function(t,e,n,r,i,s){const o=3*r,a=3*i,c=3*s,h=n[o],u=n[o+1],d=n[o+2],l=n[a],f=n[a+1],g=n[a+2],p=n[c],y=n[c+1],w=n[c+2];t[e]=E(h,l,p),t[e+1]=E(u,f,y),t[e+2]=E(d,g,w),t[e+3]=b(h,l,p),t[e+4]=b(u,f,y),t[e+5]=b(d,g,w)}(t.__data_float32,o,n,r,i,s),t.__data_uint32[o+6]=e}function F(t){return 1===t.faces.length}function U(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}var S,z="undefined"!=typeof Float32Array?Float32Array:Array;function C(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function V(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function B(){}function q(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function L(t,e,n=0,r=t.length){const i=n+r;for(let r=n;r<i;r++)if(t[r]===e)return t.splice(r,1),!0;return!1}function T(t,e){return t.v0===e||t.v1===e}function M(t,e,n){const r=t.v0,i=t.v1;return!(r!==e&&r!==n||i!==e&&i!==n)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),S=new z(3),z!=Float32Array&&(S[0]=0,S[1]=0,S[2]=0);let I=0;class k{index=I++;v0=null;v1=null;faces=[];lengthSqr=-1;get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new k;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsEdge(this)||(t(`Missing back-link from face[${i}]`),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,r=n.length;for(let t=0;t<r;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){throw new Error('deprecated, use "query_edge_is_boundary" instead')}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,r=t.y,i=t.z,s=n-e.x,o=r-e.y,a=i-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,r=e.length;for(let i=0;i<r;i++){const r=e[i];r.removeEdge(t),-1===n.indexOf(r)&&(n.push(r),r.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){V(this.faces,t)}removeFace(t){L(this.faces,t)}getOtherVertex(t){return U(this,t)}containsVertex(t){return T(this,t)}containsBothVertices(t,e){return M(this,t,e)}containsSameVerticesAs(t){return M(this,t.v0,t.v1)}}function N(t,e,n){const r=t.length;for(let i=0;i<r;i++)t[i]===e&&(t[i]=n);return t}function O(t,e,n){return t*t+e*e+n*n}function j(t,e,n,r,i,s,o,a,c,h,u){const d=c-s,l=h-o,f=u-a,g=n-s,p=r-o,y=i-a,w=l*y-f*p,_=f*g-d*y,m=d*p-l*g,v=O(w,_,m);if(0===v)return t[e]=0,t[e+1]=1,void(t[e+2]=0);const x=1/Math.sqrt(v),A=w*x,b=_*x,E=m*x;t[e]=A,t[e+1]=b,t[e+2]=E}k.prototype.isTopoEdge=!0;let D=0;class R{index=D++;edges=[];faces=[];x=0;y=0;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 R;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsVertex(this)||(t(`Missing back-link from face[${i}]`),e=!1);const i=this.edges,s=i.length;for(let n=0;n<s;n++)T(i[n],this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,r=this.z,i=t.x-e,s=t.y-n,o=t.z-r,Math.sqrt(i*i+s*s+o*o);var e,n,r,i,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return V(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){L(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return V(this.edges,t)}replaceEdge(t,e){const n=this.edges,r=n.indexOf(t);n[r]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return L(this.edges,t)}computeNeighbourVertices(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].getOtherVertex(this);t[e+n]=i,n++}return n}static from(t,e,n){const r=new R;return r.x=t,r.y=e,r.z=n,r}}R.prototype.isTopoVertex=!0;let J=0;class P{index=J++;vertices=[];edges=[];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(),C(this.normal,t.normal)}clone(){const t=new P;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,r=n.length;3!==r&&(t(`Expected number of vertices is 3, instead got ${r}`),e=!1);for(let i=0;i<r;i++)n[i].containsFace(this)||(t(`Missing back-link from vertex[${i}]`),e=!1);const i=this.edges,s=i.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)i[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){N(this.edges,t,e)}replaceVertex(t,e){N(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],r=t[2];return e===n||e===r||n===r}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,r=n.length;for(let t=0;t<r;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return V(this.edges,t)}removeEdge(t){L(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],r=t[2];!function(t,e,n,r){j(t,0,e[0],e[1],e[2],n[0],n[1],n[2],r[0],r[1],r[2])}(this.normal,e,n,r)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].faces,o=i.length;for(let r=0;r<o;r++){const s=i[r];s!==this&&(t[e+n]=s,n++)}}return n}static fromPoints(t,e,n,r,i,s,o,a,c){const h=R.from(t,e,n),u=R.from(r,i,s),d=R.from(o,a,c),l=new k,f=new k,g=new k;l.v0=h,l.v1=u,f.v0=u,f.v1=d,g.v0=d,g.v1=h;const p=new P;return p.edges.push(l,f,g),p.vertices.push(h,u,d),h.faces.push(p),u.faces.push(p),d.faces.push(p),l.faces.push(p),f.faces.push(p),g.faces.push(p),h.edges.push(l,g),u.edges.push(l,f),d.edges.push(f,g),p}}P.prototype.isTopoFace=!0;class H{vertices=[];__edges=new Set;__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=B){let e=!0,n="",r=0;function i(i){t(`${n}[${r}]: ${i}`),e=!1}n="Edge",r=0;const s=this.getEdges();for(let t of s){t.validate(i),this.containsVertex(t.v0)||i("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||i("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)||i(`Link to off-mesh face[${t}]`)}r++}const o=this.getFaces();n="Face",r=0;for(let t of o){t.validate(i);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||i(`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)||i(`Link to off-mesh vertex[${t}]`)}r++}const a=this.vertices,c=a.length;n="Vertex";for(let t=0;t<c;t++){r=t;const e=a[t];e.validate(i);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||i(`Link to off-mesh edge[${t}]`)}const o=e.faces,c=o.length;for(let t=0;t<c;t++){const e=o[t];this.containsFace(e)||i(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new H;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let r=0;r<n;r++){const n=e[r];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 P;C(n.normal,t.normal);const r=t.vertices;for(let t=0;t<3;t++){const i=r[t];let s=e.get(i.index);void 0===s&&(s=new R,s.index=i.index,s.x=i.x,s.y=i.y,s.z=i.z,e.set(i.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n),this.patchFaceEdges(n)}patchFaceEdges(t){const e=t.vertices,n=e[0],r=e[1],i=e[2],s=this.ensureEdge(n,r),o=this.ensureEdge(r,i),a=this.ensureEdge(i,n);s.addUniqueFace(t),o.addUniqueFace(t),a.addUniqueFace(t),t.addUniqueEdge(s),t.addUniqueEdge(o),t.addUniqueEdge(a)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){V(this.vertices,t)}removeVertex(t){throw new Error("deprecated, use tm_kill_only_vert instead")}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){throw new Error("deprecated, use tm_kill_only_edge instead")}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 r=t.vertices,i=r.length;for(let t=0;t<i;t++){const e=r[t];this.addUniqueVertex(e)}}removeFace(t){throw new Error("deprecated, use tm_kill_only_face instead")}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,r=n.length;for(let i=0;i<r;i++){const r=n[i];if(U(r,t)===e)return r}const i=new k;return i.v0=t,i.v1=e,t.edges.push(i),e.edges.push(i),this.__edges.add(i),i}mergeEdges(){const t=this.getEdges();for(let n of t){const r=n.v0,i=n.v1;for(let s of t){if(n===s)continue;const t=s.v0,o=s.v1;if(r===t){if(i!==o)continue}else{if(r!==o)continue;if(i!==t)continue}e=s,this.__edges.delete(e),n.merge(s)}}var e}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}setVerticesFromArray(t){const e=t.length/3,n=this.vertices;for(let r=0;r<e;r++){const e=3*r,i=new R;i.index=r,i.x=t[e],i.y=t[e+1],i.z=t[e+2],n[r]=i}}setFacesFromIndexArray(t){const e=t.length,n=this.vertices,r=e/3;for(let e=0;e<r;e++){const r=3*e,i=t[r],s=t[r+1],o=t[r+2];this.createTriangle(e,n[i],n[s],n[o])}}setFacedUnindexed(){const t=this.vertices,e=t.length/3;for(let n=0;n<e;n++){const e=3*n;this.createTriangle(n,t[e],t[e+1],t[e+2])}}build(t,e){this.setVerticesFromArray(t),null==e?this.setFacedUnindexed():this.setFacesFromIndexArray(e)}createTriangle(t,e,n,r){const i=new P;i.index=t;const s=this.ensureEdge(e,n),o=this.ensureEdge(n,r),a=this.ensureEdge(r,e);return s.faces.push(i),o.faces.push(i),a.faces.push(i),i.vertices.push(e,n,r),i.edges.push(s,o,a),e.faces.push(i),n.faces.push(i),r.faces.push(i),this.__faces.add(i),i}toString(){return`TopoMesh{ vertices: ${q(this.vertices.length)}, edges: ${q(this.getEdges().size)}, faces: ${q(this.getFaces().size)} }`}}H.prototype.isTopoMesh=!0;const W=[],G=[],Y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)W[t]=Y[t],G[Y.charCodeAt(t)]=t;function K(t,e,n){const r=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);r.push(W[(i=e)>>18&63]+W[i>>12&63]+W[i>>6&63]+W[63&i])}var i;return r.join("")}G["-".charCodeAt(0)]=62,G["_".charCodeAt(0)]=63;const Q=16383;class X{static encode(t){return function(t){const e=t.length,n=e%3,r=[],i=e-n;for(let e=0;e<i;e+=Q){const n=K(t,e,e+Q>i?i:e+Q);r.push(n)}if(1===n){const n=t[e-1];r.push(W[n>>2]+W[n<<4&63]+"==")}else if(2===n){const n=(t[e-2]<<8)+t[e-1];r.push(W[n>>10]+W[n>>4&63]+W[n<<2&63]+"=")}return r.join("")}(new Uint8Array(t))}static decode(t){return function(t){let e;const n=function(t){const e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");let n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=n[0],i=n[1],s=new Uint8Array(function(t,e){return 3*(t+e)/4-e}(r,i));let o=0;const a=i>0?r-4:r;let c=0;for(;c<a;c+=4){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2),a=t.charCodeAt(c+3);e=G[n]<<18|G[r]<<12|G[i]<<6|G[a],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=255&e}if(2===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1);e=G[n]<<2|G[r]>>4,s[o++]=255&e}if(1===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2);e=G[n]<<10|G[r]<<4|G[i]>>2,s[o++]=e>>8&255,s[o++]=255&e}return s}(t).buffer}}const Z="uint8",tt="uint16",et="uint32",nt="int8",rt="int16",it="int32",st="float32",ot="float64",at={[Z]:Uint8Array,[tt]:Uint16Array,[et]:Uint32Array,[nt]:Int8Array,[rt]:Int16Array,[it]:Int32Array,float16:Uint16Array,[st]:Float32Array,[ot]:Float64Array};function ct(t){const e=Object.getPrototypeOf(t).constructor;switch(e){case Uint8Array:case Uint8ClampedArray:return Z;case Uint16Array:return tt;case Uint32Array:return et;case Int8Array:return nt;case Int16Array:return rt;case Int32Array:return it;case Float32Array:return st;case Array:case Float64Array:return ot;default:throw new Error(`unsupported constructor type ${e.name}`)}}function ht(t,e,n){return t<e?e:t>n?n:t}function ut(t,e,n){return(e-t)*n+t}function dt(t,e,n,r,i){return.5*(r-e+(2*e-5*n+4*r-i+(3*(n-r)+i-e)*t)*t)*t+n}const lt=4294967295;function ft(t){const e=t>>0;return lt-((t-e)*lt>>>0)^e}class gt{constructor(t=[],e=1,n=0,r=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(r)||n<0)throw new Error(`height must be a non-negative integer, instead was ${r}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*r*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*r*e}`);this.width=n,this.height=r,this.itemSize=e,this.data=t,this.version=0}sampleCatmullRomUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelCatmullRomUV(t,e,i)}sampleChannelCatmullRomUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelCatmullRom(r,i,n)}sampleChannelCatmullRom(t,e,n){const r=Math.floor(t),i=Math.floor(e),s=t-r,o=e-i,a=s*(s*(1-.5*s)-.5),c=o*(o*(1-.5*o)-.5),h=s*(.5+s*(2-1.5*s)),u=o*(.5+o*(2-1.5*o)),d=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+h,g=1+o*o*(1.5*o-2.5)+u,p=r-1,y=i-1,w=r+2,_=i+2,m=r+h/f,v=i+u/g;let x=0;return x+=this.sampleChannelBilinear(p,y,n)*a*c,x+=this.sampleChannelBilinear(m,y,n)*f*c,x+=this.sampleChannelBilinear(w,y,n)*d*c,x+=this.sampleChannelBilinear(p,v,n)*a*g,x+=this.sampleChannelBilinear(m,v,n)*f*g,x+=this.sampleChannelBilinear(w,v,n)*d*g,x+=this.sampleChannelBilinear(p,_,n)*a*l,x+=this.sampleChannelBilinear(m,_,n)*f*l,x+=this.sampleChannelBilinear(w,_,n)*d*l,x}sampleBicubicUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelBicubicUV(t,e,i)}sampleBicubic(t,e,n,r){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const r=t*this.width,i=e*this.height;return this.sampleChannelBicubic(r-.5,i-.5,n)}sampleChannelBicubic(t,e,n){const r=this.itemSize,i=this.width,s=this.height,o=this.data,a=i*r,c=i-1,h=s-1,u=ht(t,0,c),d=ht(e,0,h),l=0|u,p=0|d,y=u-l,w=d-p,_=f(0,l-1),m=f(0,p-1),v=g(c,l+1),x=g(h,p+1),A=g(c,v+1),b=m*a+n,E=p*a+n,$=x*a+n,F=g(h,x+1)*a+n,U=_*r,S=l*r,z=v*r,C=A*r,V=o[b+U],B=o[b+S],q=o[b+z],L=o[b+C],T=o[E+U],M=o[E+S],I=o[E+z],k=o[E+C],N=o[$+U],O=o[$+S],j=o[$+z],D=o[$+C],R=o[F+U],J=o[F+S],P=o[F+z],H=o[F+C],W=dt(y,V,B,q,L),G=dt(y,T,M,I,k),Y=dt(y,N,O,j,D),K=dt(y,R,J,P,H);return dt(w,W,G,Y,K)}sampleBilinearUV(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelBilinear(r,i,n)}sampleChannelBilinear(t,e,n){const r=this.itemSize,i=this.width,s=i*r,o=this.height-1,a=ht(t,0,i-1),c=ht(e,0,o),h=a>>>0,u=c>>>0,d=u*s,l=h*r+n,f=d+l;let g,p;g=a===h?h:h+1,p=c===u?u:u+1;const y=this.data,w=y[f];if(h===g&&u===p)return w;const _=a-h,m=c-u,v=g*r+n,x=p*s,A=x+l,b=x+v,E=y[d+v],$=y[A],F=y[b],U=ut(w,E,_),S=ut($,F,_);return ut(U,S,m)}sampleNearestUV(t,e,n){const r=this.width,i=this.height,s=Math.round(t*r-.5),o=Math.round(e*i-.5);this.read(ht(s,0,r-1),ht(o,0,i-1),n)}readChannel(t,e,n){const r=(e*this.width+t)*this.itemSize+n;return this.data[r]}read(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)n[t]=this.data[s+t]}write(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)this.data[s+t]=n[t];this.version++}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,r=t%n,i=t/n|0;e.set(r,i)}copy(t,e,n,r,i,s,o){const a=Math.min(s,t.width-e,this.width-r),c=Math.min(o,t.height-n,this.height-i),h=this.itemSize,u=t.itemSize,d=Math.min(h,u),l=h*this.width,f=u*t.width,g=t.data,p=this.data;let y,w,_;for(w=0;w<c;w++){const t=(w+i)*l,s=(w+n)*f;for(y=0;y<a;y++){const n=t+(y+r)*h,i=s+(y+e)*u;for(_=0;_<d;_++)p[n+_]=g[i+_]}}this.version++}zeroFill(t,e,n,r){const i=ht(t,0,this.width),s=ht(e,0,this.height),o=ht(t+n,0,this.width),a=ht(e+r,0,this.height),c=this.data,h=this.itemSize,u=h*this.width,d=i*h,l=o*h;let f;for(f=s;f<a;f++){const t=f*u;c.fill(0,t+d,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,r=this.data,i=r.length;for(let s=t;s<i;s+=n)r[s]=e;this.version++}fill(t,e,n,r,i){const s=this.width,o=this.height,a=ht(t,0,s),c=ht(e,0,o),h=ht(t+n,0,s),u=ht(e+r,0,o),d=this.data,l=this.itemSize,f=l*s;let g,p,y;for(g=c;g<u;g++){const t=g*f;for(p=a;p<h;p++){const e=t+p*l;for(y=0;y<l;y++)d[e+y]=i[y]}}this.version++}writeChannel(t,e,n,r){const i=(e*this.width+t)*this.itemSize+n;this.data[i]=r,this.version++}traverseCircle(t,e,n,r){let i,s;const o=0|t,a=0|e,c=n*n,h=Math.ceil(n);for(s=-h;s<=h;s++){const t=s*s;for(i=-h;i<=h;i++)i*i+t<=c&&r(o+i,a+s,this)}}resize(t,e,n=!0){const r=this.width,i=this.height;if(r===t&&i===e)return;const s=this.itemSize,o=t*e*s,a=this.data,c=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===r)c.set(a.subarray(0,Math.min(a.length,o)));else{const n=g(e,i),o=g(t,r);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const i=(e*t+n)*s,o=(e*r+n)*s;for(let t=0;t<s;t++)c[i+t]=a[o+t]}}this.width=t,this.height=e,this.data=c,this.version++}computeByteSize(){let t;const e=this.data;return t=Array.isArray(e)?8*e.length:e.byteLength,t+280}equals(e){return this===e||this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const r=e.length;if(r!==n.length)return!1;const i=e.constructor;if(i!==n.constructor)return!1;if(0===r)return!0;if(r<128)return t(e,n);const s=e.byteLength;if(s!==n.byteLength)return!1;const o=e.buffer,a=n.buffer,c=e.byteOffset,h=n.byteOffset;if(o===a&&c===h)return!0;let u=e,d=n;const l=i.BYTES_PER_ELEMENT,f=function(t,e,n){const r=t|e|n;return 0==(3&r)?4:0==(1&r)?2:1}(c,h,s);return l<4&&4===f?(u=new Uint32Array(o,c,s>>>2),d=new Uint32Array(a,h,s>>>2)):l<2&&2===f&&(u=new Uint16Array(o,c,s>>>1),d=new Uint16Array(a,h,s>>>1)),t(u,d)}(this.data,e.data)}hash(){const t=this.itemSize,n=this.width,r=this.height,i=this.data;let s=((65535&n)<<16|65535&r)^t;const o=n*r*t;if(e(i))s^=function(t,e,n){const r=e|n;return 0==(3&r)?function(t,e,n){let r=n;for(let e=0;e<n;++e)r=(r<<5)-r+t[e];return r}(new Uint32Array(t,e,n>>>2),0,n>>>2):0==(2&r)?function(t,e,n){let r=n,i=0;for(0!=(1&n)&&(r=(r<<5)-r+t[i++]);i<n;i+=2)r=(r<<5)-r+(t[i]<<16|t[i+1]);return r}(new Uint16Array(t,e,n>>>1),0,n>>>1):function(t,e,n){let r=n,i=0;const s=3&n;for(;i<0+s;i++)r=(r<<5)-r+t[i];for(;i<n;i+=4)r=(r<<5)-r+(t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24);return r}(new Uint8Array(t,e,n),0,n)}(i.buffer,i.byteOffset,i.byteLength);else for(let t=0;t<o;++t)s=(s<<5)-s+ft(i[t]);return s}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new gt(t,this.itemSize,this.width,this.height)}toJSON(){const t=X.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:ct(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:r,data:i}){const s=function(t){const e=at[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(r);if("string"==typeof i){const t=X.decode(i);this.data=new s(t)}else{if(!Array.isArray(i))throw new Error("Unsupported data format");this.data=new s(i)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const r=new Uint8ClampedArray(e*n*t);return new gt(r,t,e,n)}static uint8(t,e,n){const r=new Uint8Array(e*n*t);return new gt(r,t,e,n)}static uint16(t,e,n){const r=new Uint16Array(e*n*t);return new gt(r,t,e,n)}static uint32(t,e,n){const r=new Uint32Array(e*n*t);return new gt(r,t,e,n)}static int8(t,e,n){const r=new Int8Array(e*n*t);return new gt(r,t,e,n)}static int16(t,e,n){const r=new Int16Array(e*n*t);return new gt(r,t,e,n)}static int32(t,e,n){const r=new Int32Array(e*n*t);return new gt(r,t,e,n)}static float32(t,e,n){const r=new Float32Array(e*n*t);return new gt(r,t,e,n)}static float64(t,e,n){const r=new Float64Array(e*n*t);return new gt(r,t,e,n)}}function pt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2];t[e]+=i,t[e+1]+=s,t[e+2]+=o}function yt(t,e,n,r,i,s){const o=3*n,a=3*r,c=3*i;j(t,e,s[o],s[o+1],s[o+2],s[a],s[a+1],s[a+2],s[c],s[c+1],s[c+2])}function wt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2],a=O(i,s,o),c=0!==a?1/Math.sqrt(a):1;t[e]=i*c,t[e+1]=s*c,t[e+2]=o*c}gt.prototype.isSampler2D=!0,gt.typeName="Sampler2D";const _t=new Float64Array(3),mt={build:function(t,e,n,r,i,s){const o=n.x*s,a=n.y*s,c=o-1,h=a-1;let u=0,d=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),p=new Float32Array(2*l);let y,w;const _=n.y/i.y/h,m=n.x/i.x/c,v=e.y/i.y,x=e.x/i.x,A=i.x*r.x,b=i.y*r.y;let E,$,F;for(y=0;y<a;y++){const e=y*_+v;for(F=e*b,w=0;w<o;w++){const n=w*m+x;E=n*A,$=t.sampleChannelBicubicUV(n,e,0),f[u]=E,f[u+1]=$,f[u+2]=F,p[d]=n,p[d+1]=e,u+=3,d+=2}}u=0;const U=new(function(t){if(t<=256)return Uint8Array;if(t<=65536)return Uint16Array;if(t<=4294967295)return Uint32Array;throw new Error(`Unsupported size ${t}`)}(f.length/3))(c*h*6);for(y=0;y<h;y++)for(w=0;w<c;w++){const t=w+o*y,e=w+o*(y+1),n=w+1+o*(y+1),r=w+1+o*y;U[u]=t,U[u+1]=e,U[u+2]=r,U[u+3]=e,U[u+4]=n,U[u+5]=r,u+=6}return function(t,e,n){const r=n.length;for(let i=0;i<r;i+=3){const r=n[i],s=n[i+1],o=n[i+2];yt(_t,0,r,s,o,t),pt(e,3*r,_t,0),pt(e,3*s,_t,0),pt(e,3*o,_t,0)}!function(t,e=0,n=t.length-e){const r=e+n;for(let n=e;n<r;n+=3)wt(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:p}}};self.Lib={build_bvh(t,e){const n=new A;return function(t,e,n){const r=n.length/3;t.setLeafCount(r),t.initialize_structure();for(let i=0;i<r;i++){const r=3*i;$(t,i,e,n[r],n[r+1],n[r+2])}t.build()}(n,t,e),n},Sampler2D:gt,BufferedGeometryArraysBuilder:mt,tensionOptimizeUV:function(t,e,n,r=3){const i=new H;i.build(t,n),i.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<r;t++)t:for(let t=0;t<s;t++){const n=i.vertices[t],r=n.edges,s=r.length;if(0===s)continue;let o=0,a=0,c=0;for(let t=0;t<s;t++){const i=r[t];if(F(i))continue t;const s=2*U(i,n).index,h=e[s],u=e[s+1],d=1/i.lengthSqr;o+=h*d,a+=u*d,c+=d}const h=o/c,u=a/c,d=2*n.index;e[d]=h,e[d+1]=u}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s>e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s<e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}}};
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.126.
|
|
8
|
+
"version": "2.126.56",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @param {number[]|Float32Array} out
|
|
4
4
|
* @param {number} out_offset
|
|
5
5
|
* @param {number[]|Float32Array} mat4
|
|
6
|
+
* @returns {number[]} `out` parameter
|
|
6
7
|
*/
|
|
7
|
-
export function m4_extract_scale(out: number[] | Float32Array, out_offset: number, mat4: number[] | Float32Array):
|
|
8
|
+
export function m4_extract_scale(out: number[] | Float32Array, out_offset: number, mat4: number[] | Float32Array): number[];
|
|
8
9
|
//# sourceMappingURL=m4_extract_scale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m4_extract_scale.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_extract_scale.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"m4_extract_scale.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_extract_scale.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,sCALW,MAAM,EAAE,GAAC,YAAY,cACrB,MAAM,QACN,MAAM,EAAE,GAAC,YAAY,GACnB,MAAM,EAAE,CAiCpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assert } from "../../../assert.js";
|
|
1
2
|
import { v3_length } from "../../vec3/v3_length.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -5,11 +6,15 @@ import { v3_length } from "../../vec3/v3_length.js";
|
|
|
5
6
|
* @param {number[]|Float32Array} out
|
|
6
7
|
* @param {number} out_offset
|
|
7
8
|
* @param {number[]|Float32Array} mat4
|
|
9
|
+
* @returns {number[]} `out` parameter
|
|
8
10
|
*/
|
|
9
11
|
export function m4_extract_scale(
|
|
10
12
|
out, out_offset,
|
|
11
13
|
mat4
|
|
12
|
-
){
|
|
14
|
+
) {
|
|
15
|
+
assert.isArrayLike(out, 'out');
|
|
16
|
+
assert.isNonNegativeInteger(out_offset, 'out_offset');
|
|
17
|
+
assert.isArrayLike(mat4, 'mat4');
|
|
13
18
|
|
|
14
19
|
const m11 = mat4[0];
|
|
15
20
|
const m12 = mat4[1];
|
|
@@ -30,7 +35,8 @@ export function m4_extract_scale(
|
|
|
30
35
|
const scale_z = v3_length(m31, m32, m33);
|
|
31
36
|
|
|
32
37
|
out[out_offset] = scale_x;
|
|
33
|
-
out[out_offset+1] = scale_y;
|
|
34
|
-
out[out_offset+2] = scale_z;
|
|
38
|
+
out[out_offset + 1] = scale_y;
|
|
39
|
+
out[out_offset + 2] = scale_z;
|
|
35
40
|
|
|
41
|
+
return out;
|
|
36
42
|
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* @param {number[]} output 4x4 matrix
|
|
4
4
|
* @param {number[]} rotation_matrix 3x3 mat
|
|
5
5
|
* @param {number[]} translation 3d vector
|
|
6
|
+
* @returns {number[]} `output` parameter
|
|
6
7
|
* @see m4_rotation_translation
|
|
7
8
|
*/
|
|
8
|
-
export function m4_inverse_rotation_translation(output: number[], rotation_matrix: number[], translation: number[]):
|
|
9
|
+
export function m4_inverse_rotation_translation(output: number[], rotation_matrix: number[], translation: number[]): number[];
|
|
9
10
|
//# sourceMappingURL=m4_inverse_rotation_translation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m4_inverse_rotation_translation.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_inverse_rotation_translation.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"m4_inverse_rotation_translation.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_inverse_rotation_translation.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wDANW,MAAM,EAAE,mBACR,MAAM,EAAE,eACR,MAAM,EAAE,GACN,MAAM,EAAE,CAmCpB"}
|
|
@@ -5,6 +5,7 @@ import { v3_dot } from "../../vec3/v3_dot.js";
|
|
|
5
5
|
* @param {number[]} output 4x4 matrix
|
|
6
6
|
* @param {number[]} rotation_matrix 3x3 mat
|
|
7
7
|
* @param {number[]} translation 3d vector
|
|
8
|
+
* @returns {number[]} `output` parameter
|
|
8
9
|
* @see m4_rotation_translation
|
|
9
10
|
*/
|
|
10
11
|
export function m4_inverse_rotation_translation(
|
|
@@ -37,4 +38,6 @@ export function m4_inverse_rotation_translation(
|
|
|
37
38
|
output[13] = -v3_dot(t[0], t[1], t[2], r[3], r[4], r[5]);
|
|
38
39
|
output[14] = -v3_dot(t[0], t[1], t[2], r[6], r[7], r[8]);
|
|
39
40
|
output[15] = 1;
|
|
41
|
+
|
|
42
|
+
return output;
|
|
40
43
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @see Adapted from glMatrix
|
|
4
4
|
* @param {Float64Array|Float32Array|number[]|mat4} out
|
|
5
5
|
* @param {Float64Array|Float32Array|number[]|mat4} input
|
|
6
|
-
* @returns {boolean}
|
|
6
|
+
* @returns {boolean} true iff determinant is not 0, otherwise matrix is non-invertible and false is returned
|
|
7
7
|
*/
|
|
8
8
|
export function m4_invert(out: Float64Array | Float32Array | number[] | mat4, input: Float64Array | Float32Array | number[] | mat4): boolean;
|
|
9
9
|
//# sourceMappingURL=m4_invert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m4_invert.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_invert.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,+BAJW,YAAY,GAAC,YAAY,GAAC,MAAM,EAAE,GAAC,IAAI,SACvC,YAAY,GAAC,YAAY,GAAC,MAAM,EAAE,GAAC,IAAI,GACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"m4_invert.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_invert.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,+BAJW,YAAY,GAAC,YAAY,GAAC,MAAM,EAAE,GAAC,IAAI,SACvC,YAAY,GAAC,YAAY,GAAC,MAAM,EAAE,GAAC,IAAI,GACrC,OAAO,CAkEnB"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @see Adapted from glMatrix
|
|
4
4
|
* @param {Float64Array|Float32Array|number[]|mat4} out
|
|
5
5
|
* @param {Float64Array|Float32Array|number[]|mat4} input
|
|
6
|
-
* @returns {boolean}
|
|
6
|
+
* @returns {boolean} true iff determinant is not 0, otherwise matrix is non-invertible and false is returned
|
|
7
7
|
*/
|
|
8
8
|
export function m4_invert(out, input) {
|
|
9
9
|
|
|
@@ -11,14 +11,17 @@ export function m4_invert(out, input) {
|
|
|
11
11
|
a01 = input[1],
|
|
12
12
|
a02 = input[2],
|
|
13
13
|
a03 = input[3];
|
|
14
|
+
|
|
14
15
|
const a10 = input[4],
|
|
15
16
|
a11 = input[5],
|
|
16
17
|
a12 = input[6],
|
|
17
18
|
a13 = input[7];
|
|
19
|
+
|
|
18
20
|
const a20 = input[8],
|
|
19
21
|
a21 = input[9],
|
|
20
22
|
a22 = input[10],
|
|
21
23
|
a23 = input[11];
|
|
24
|
+
|
|
22
25
|
const a30 = input[12],
|
|
23
26
|
a31 = input[13],
|
|
24
27
|
a32 = input[14],
|
|
@@ -41,7 +44,7 @@ export function m4_invert(out, input) {
|
|
|
41
44
|
const det =
|
|
42
45
|
b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
43
46
|
|
|
44
|
-
if (
|
|
47
|
+
if (det === 0) {
|
|
45
48
|
// determinant is 0, can't invert
|
|
46
49
|
return false;
|
|
47
50
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {ArrayLike<number>} output 4x4 matrix output will be written here
|
|
5
5
|
* @param {ArrayLike<number>} scale 3d vector
|
|
6
|
-
* @returns {ArrayLike<number>}
|
|
6
|
+
* @returns {ArrayLike<number>} `output` parameter returned for convenience
|
|
7
7
|
*/
|
|
8
8
|
export function m4_make_scale(output: ArrayLike<number>, scale: ArrayLike<number>): ArrayLike<number>;
|
|
9
9
|
//# sourceMappingURL=m4_make_scale.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {ArrayLike<number>} output 4x4 matrix output will be written here
|
|
5
5
|
* @param {ArrayLike<number>} scale 3d vector
|
|
6
|
-
* @returns {ArrayLike<number>}
|
|
6
|
+
* @returns {ArrayLike<number>} `output` parameter returned for convenience
|
|
7
7
|
*/
|
|
8
8
|
export function m4_make_scale(output, scale) {
|
|
9
9
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Create a 4x4 matrix that corresponds to translation transform
|
|
3
3
|
* @param {ArrayLike<number>} output
|
|
4
4
|
* @param {ArrayLike<number>} translation 3d vector
|
|
5
|
+
* @returns {ArrayLike<number>} output parameter
|
|
5
6
|
*/
|
|
6
|
-
export function m4_make_translation(output: ArrayLike<number>, translation: ArrayLike<number>):
|
|
7
|
+
export function m4_make_translation(output: ArrayLike<number>, translation: ArrayLike<number>): ArrayLike<number>;
|
|
7
8
|
//# sourceMappingURL=m4_make_translation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m4_make_translation.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_make_translation.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"m4_make_translation.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_make_translation.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,4CAJW,SAAS,CAAC,MAAM,CAAC,eACjB,SAAS,CAAC,MAAM,CAAC,GACf,SAAS,CAAC,MAAM,CAAC,CAU7B"}
|
|
@@ -5,6 +5,7 @@ import { M4_IDENTITY } from "./M4_IDENTITY.js";
|
|
|
5
5
|
* Create a 4x4 matrix that corresponds to translation transform
|
|
6
6
|
* @param {ArrayLike<number>} output
|
|
7
7
|
* @param {ArrayLike<number>} translation 3d vector
|
|
8
|
+
* @returns {ArrayLike<number>} output parameter
|
|
8
9
|
*/
|
|
9
10
|
export function m4_make_translation(output, translation) {
|
|
10
11
|
array_copy(M4_IDENTITY, 0, output, 0, 16);
|
|
@@ -12,4 +13,6 @@ export function m4_make_translation(output, translation) {
|
|
|
12
13
|
output[12] = translation[0];
|
|
13
14
|
output[13] = translation[1];
|
|
14
15
|
output[14] = translation[2];
|
|
16
|
+
|
|
17
|
+
return output;
|
|
15
18
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @param {number[]|ArrayLike<number>|Float32Array} out the receiving matrix
|
|
6
6
|
* @param {number[]|ArrayLike<number>|Float32Array} a the first operand
|
|
7
7
|
* @param {number[]|ArrayLike<number>|Float32Array} b the second operand
|
|
8
|
+
* @returns {number[]} `out` parameter
|
|
8
9
|
*/
|
|
9
|
-
export function m4_multiply(out: number[] | ArrayLike<number> | Float32Array, a: number[] | ArrayLike<number> | Float32Array, b: number[] | ArrayLike<number> | Float32Array):
|
|
10
|
+
export function m4_multiply(out: number[] | ArrayLike<number> | Float32Array, a: number[] | ArrayLike<number> | Float32Array, b: number[] | ArrayLike<number> | Float32Array): number[];
|
|
10
11
|
//# sourceMappingURL=m4_multiply.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m4_multiply.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_multiply.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"m4_multiply.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_multiply.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,iCALW,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,GAAC,YAAY,KACvC,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,GAAC,YAAY,KACvC,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,GAAC,YAAY,GACrC,MAAM,EAAE,CA0EpB"}
|
|
@@ -7,6 +7,7 @@ import { assert } from "../../../assert.js";
|
|
|
7
7
|
* @param {number[]|ArrayLike<number>|Float32Array} out the receiving matrix
|
|
8
8
|
* @param {number[]|ArrayLike<number>|Float32Array} a the first operand
|
|
9
9
|
* @param {number[]|ArrayLike<number>|Float32Array} b the second operand
|
|
10
|
+
* @returns {number[]} `out` parameter
|
|
10
11
|
*/
|
|
11
12
|
export function m4_multiply(out, a, b) {
|
|
12
13
|
assert.isArrayLike(out, 'out');
|
|
@@ -78,4 +79,6 @@ export function m4_multiply(out, a, b) {
|
|
|
78
79
|
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
79
80
|
|
|
80
81
|
assert.greaterThanOrEqual(out.length, 16, 'out.length'); // check at the end to avoid having to explicitly deal with the `Array` type
|
|
82
|
+
|
|
83
|
+
return out;
|
|
81
84
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @param {number[]|Float32Array} out
|
|
6
6
|
* @param {number[]|Float32Array} a
|
|
7
7
|
* @param {number[]|Float32Array} b
|
|
8
|
+
* @returns {number[]|Float32Array} `out` parameter
|
|
8
9
|
*/
|
|
9
|
-
export function m4_multiply_alphatensor(out: number[] | Float32Array, a: number[] | Float32Array, b: number[] | Float32Array):
|
|
10
|
+
export function m4_multiply_alphatensor(out: number[] | Float32Array, a: number[] | Float32Array, b: number[] | Float32Array): number[] | Float32Array;
|
|
10
11
|
//# sourceMappingURL=m4_multiply_alphatensor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m4_multiply_alphatensor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_multiply_alphatensor.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"m4_multiply_alphatensor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_multiply_alphatensor.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,6CALW,MAAM,EAAE,GAAC,YAAY,KACrB,MAAM,EAAE,GAAC,YAAY,KACrB,MAAM,EAAE,GAAC,YAAY,GACnB,MAAM,EAAE,GAAC,YAAY,CA8IjC"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @param {number[]|Float32Array} out
|
|
6
6
|
* @param {number[]|Float32Array} a
|
|
7
7
|
* @param {number[]|Float32Array} b
|
|
8
|
+
* @returns {number[]|Float32Array} `out` parameter
|
|
8
9
|
*/
|
|
9
10
|
export function m4_multiply_alphatensor(out, a, b) {
|
|
10
11
|
// read out matricies
|
|
@@ -144,4 +145,6 @@ export function m4_multiply_alphatensor(out, a, b) {
|
|
|
144
145
|
out[13] = c42;
|
|
145
146
|
out[14] = c43;
|
|
146
147
|
out[15] = c44;
|
|
148
|
+
|
|
149
|
+
return out;
|
|
147
150
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @param {number} top Upper y-value at the near plane (y1)
|
|
9
9
|
* @param {number} z_near Depth of the near plane (z0)
|
|
10
10
|
* @param {number} z_far Depth of the far plane (z1)
|
|
11
|
+
* @returns {number[]} `output` parameter
|
|
11
12
|
*/
|
|
12
|
-
export function m4_orthographic_off_center_z0(output: number[] | Float32Array[], left: number, right: number, bottom: number, top: number, z_near: number, z_far: number):
|
|
13
|
+
export function m4_orthographic_off_center_z0(output: number[] | Float32Array[], left: number, right: number, bottom: number, top: number, z_near: number, z_far: number): number[];
|
|
13
14
|
//# sourceMappingURL=m4_orthographic_off_center_z0.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m4_orthographic_off_center_z0.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_orthographic_off_center_z0.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"m4_orthographic_off_center_z0.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_orthographic_off_center_z0.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,sDATW,MAAM,EAAE,GAAC,YAAY,EAAE,QACvB,MAAM,SACN,MAAM,UACN,MAAM,OACN,MAAM,UACN,MAAM,SACN,MAAM,GACJ,MAAM,EAAE,CA+BpB"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @param {number} top Upper y-value at the near plane (y1)
|
|
9
9
|
* @param {number} z_near Depth of the near plane (z0)
|
|
10
10
|
* @param {number} z_far Depth of the far plane (z1)
|
|
11
|
+
* @returns {number[]} `output` parameter
|
|
11
12
|
*/
|
|
12
13
|
export function m4_orthographic_off_center_z0(
|
|
13
14
|
output,
|
|
@@ -36,4 +37,6 @@ export function m4_orthographic_off_center_z0(
|
|
|
36
37
|
output[13] = (top + bottom) / (bottom - top);
|
|
37
38
|
output[14] = z_near / (z_near - z_far);
|
|
38
39
|
output[15] = 1;
|
|
40
|
+
|
|
41
|
+
return output;
|
|
39
42
|
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* @param {number[]} output 4x4 matrix
|
|
4
4
|
* @param {number[]} rotation_matrix 3x3 mat
|
|
5
5
|
* @param {number[]} translation 3d vector
|
|
6
|
+
* @returns {number[]} `output` parameter
|
|
6
7
|
* @see m4_inverse_rotation_translation
|
|
7
8
|
*/
|
|
8
|
-
export function m4_rotation_translation(output: number[], rotation_matrix: number[], translation: number[]):
|
|
9
|
+
export function m4_rotation_translation(output: number[], rotation_matrix: number[], translation: number[]): number[];
|
|
9
10
|
//# sourceMappingURL=m4_rotation_translation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m4_rotation_translation.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_rotation_translation.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"m4_rotation_translation.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/m4_rotation_translation.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,gDANW,MAAM,EAAE,mBACR,MAAM,EAAE,eACR,MAAM,EAAE,GACN,MAAM,EAAE,CA6BpB"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @param {number[]} output 4x4 matrix
|
|
4
4
|
* @param {number[]} rotation_matrix 3x3 mat
|
|
5
5
|
* @param {number[]} translation 3d vector
|
|
6
|
+
* @returns {number[]} `output` parameter
|
|
6
7
|
* @see m4_inverse_rotation_translation
|
|
7
8
|
*/
|
|
8
9
|
export function m4_rotation_translation(output, rotation_matrix, translation) {
|
|
@@ -29,4 +30,6 @@ export function m4_rotation_translation(output, rotation_matrix, translation) {
|
|
|
29
30
|
output[13] = t[1];
|
|
30
31
|
output[14] = t[2];
|
|
31
32
|
output[15] = 1;
|
|
33
|
+
|
|
34
|
+
return output;
|
|
32
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v3_morton_encode_bounded.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_bounded.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,4CANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GAAC,KAAK,GACZ,MAAM,
|
|
1
|
+
{"version":3,"file":"v3_morton_encode_bounded.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_bounded.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,4CANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GAAC,KAAK,GACZ,MAAM,CAqBlB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { v3_morton_encode_normalized } from "./v3_morton_encode_normalized.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {number} x
|
|
@@ -21,14 +21,9 @@ export function v3_morton_encode_bounded(x, y, z, bounds) {
|
|
|
21
21
|
const bounds_span_y = bounds_y1 - bounds_y0;
|
|
22
22
|
const bounds_span_z = bounds_z1 - bounds_z0;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return v3_morton_encode(
|
|
30
|
-
Math.round(ndc_x),
|
|
31
|
-
Math.round(ndc_y),
|
|
32
|
-
Math.round(ndc_z)
|
|
24
|
+
return v3_morton_encode_normalized(
|
|
25
|
+
(x - bounds_x0) / bounds_span_x,
|
|
26
|
+
(y - bounds_y0) / bounds_span_y,
|
|
27
|
+
(z - bounds_z0) / bounds_span_z
|
|
33
28
|
);
|
|
34
29
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Note: does not clamp, make sure that inputs are within 0..1 range.
|
|
3
|
+
* @param {number} x value between 0 and 1
|
|
4
|
+
* @param {number} y value between 0 and 1
|
|
5
|
+
* @param {number} z value between 0 and 1
|
|
6
|
+
* @returns {number} morton code
|
|
7
|
+
*/
|
|
8
|
+
export function v3_morton_encode_normalized(x: number, y: number, z: number): number;
|
|
9
|
+
//# sourceMappingURL=v3_morton_encode_normalized.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3_morton_encode_normalized.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_normalized.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,+CALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAiBlB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { assert } from "../../../assert.js";
|
|
2
|
+
import v3_morton_encode from "./v3_morton_encode.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Note: does not clamp, make sure that inputs are within 0..1 range.
|
|
6
|
+
* @param {number} x value between 0 and 1
|
|
7
|
+
* @param {number} y value between 0 and 1
|
|
8
|
+
* @param {number} z value between 0 and 1
|
|
9
|
+
* @returns {number} morton code
|
|
10
|
+
*/
|
|
11
|
+
export function v3_morton_encode_normalized(x, y, z) {
|
|
12
|
+
assert.isNumber(x, 'x');
|
|
13
|
+
assert.isNumber(y, 'y');
|
|
14
|
+
assert.isNumber(z, 'z');
|
|
15
|
+
|
|
16
|
+
// scale to 10 bits
|
|
17
|
+
const ndc_x = 1023 * x;
|
|
18
|
+
const ndc_y = 1023 * y;
|
|
19
|
+
const ndc_z = 1023 * z;
|
|
20
|
+
|
|
21
|
+
return v3_morton_encode(
|
|
22
|
+
Math.round(ndc_x),
|
|
23
|
+
Math.round(ndc_y),
|
|
24
|
+
Math.round(ndc_z)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v3_morton_encode_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_transformed.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,gDANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GACN,MAAM,
|
|
1
|
+
{"version":3,"file":"v3_morton_encode_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_transformed.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,gDANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GACN,MAAM,CAqBlB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { clamp01 } from "../../../math/clamp01.js";
|
|
2
|
+
import { v3_morton_encode_normalized } from "./v3_morton_encode_normalized.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Assumes that coordinates will be mapped to -1..1 range after transform
|
|
@@ -17,22 +17,16 @@ export function v3_morton_encode_transformed(x, y, z, matrix) {
|
|
|
17
17
|
const _z = matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14];
|
|
18
18
|
const _w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15];
|
|
19
19
|
|
|
20
|
-
const d =
|
|
20
|
+
const d = 0.5 / _w;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const ndc_z = _z * d;
|
|
22
|
+
const n_x = clamp01(_x * d + 0.5);
|
|
23
|
+
const n_y = clamp01(_y * d + 0.5);
|
|
24
|
+
const n_z = clamp01(_z * d + 0.5);
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return v3_morton_encode(
|
|
33
|
-
Math.round(px),
|
|
34
|
-
Math.round(py),
|
|
35
|
-
Math.round(pz)
|
|
26
|
+
return v3_morton_encode_normalized(
|
|
27
|
+
n_x,
|
|
28
|
+
n_y,
|
|
29
|
+
n_z
|
|
36
30
|
);
|
|
37
31
|
}
|
|
38
32
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute average-weighted centroid of a set of 3d vectors
|
|
3
|
+
* @param {number[]} out
|
|
4
|
+
* @param {number} out_offset where to start writing the result
|
|
5
|
+
* @param {number[]} input
|
|
6
|
+
* @param {number} input_offset where to start reading
|
|
7
|
+
* @param {number} count how many elements to use
|
|
8
|
+
* @returns {number[]} same as the `out` parameter, returned for convenience
|
|
9
|
+
*/
|
|
10
|
+
export function v3_array_centroid(out: number[], out_offset: number, input: number[], input_offset: number, count: number): number[];
|
|
11
|
+
//# sourceMappingURL=v3_array_centroid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3_array_centroid.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_array_centroid.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,uCAPW,MAAM,EAAE,cACR,MAAM,SACN,MAAM,EAAE,gBACR,MAAM,SACN,MAAM,GACJ,MAAM,EAAE,CA8BpB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compute average-weighted centroid of a set of 3d vectors
|
|
5
|
+
* @param {number[]} out
|
|
6
|
+
* @param {number} out_offset where to start writing the result
|
|
7
|
+
* @param {number[]} input
|
|
8
|
+
* @param {number} input_offset where to start reading
|
|
9
|
+
* @param {number} count how many elements to use
|
|
10
|
+
* @returns {number[]} same as the `out` parameter, returned for convenience
|
|
11
|
+
*/
|
|
12
|
+
export function v3_array_centroid(out, out_offset, input, input_offset, count) {
|
|
13
|
+
assert.isNonNegativeInteger(out_offset, 'out_offset');
|
|
14
|
+
assert.isNonNegativeInteger(input_offset, 'input_offset');
|
|
15
|
+
assert.isNonNegativeInteger(count, 'count');
|
|
16
|
+
|
|
17
|
+
let x = 0;
|
|
18
|
+
let y = 0;
|
|
19
|
+
let z = 0;
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < count; i++) {
|
|
22
|
+
const offset = input_offset + i * 3;
|
|
23
|
+
|
|
24
|
+
x += input[offset];
|
|
25
|
+
y += input[offset + 1];
|
|
26
|
+
z += input[offset + 2];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (count > 0) { // avoid division by zero
|
|
30
|
+
x /= count;
|
|
31
|
+
y /= count;
|
|
32
|
+
z /= count;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
out[out_offset] = x;
|
|
36
|
+
out[out_offset + 1] = y;
|
|
37
|
+
out[out_offset + 2] = z;
|
|
38
|
+
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":"AAgBA
|
|
1
|
+
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH;IAsbI;;;;;;;;;;;;OAYG;IACH,+BAJW,MAAM,WACN,sBAAsB,GACpB,MAAM,CAqBlB;IApdD;;;;;OAKG;IACH,oBAFU,eAAe,CAES;IAGlC;;;OAGG;IACH,UAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,2BAAgB;IAShB;;;;;;OAMG;IACH,SAJU,sBAAsB,CAIjB;IAEf;;;OAGG;IACH,OAFU,WAAW,GAAC,MAAM,CAEN;IAEtB;;;;OAIG;IACH,yBAAgB;IAEhB;;OAEG;IACH;QACI;;WAEG;;MAEL;IAUF;;;OAGG;IACH,eAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,WAAW,GAChB,OAAO,CAMnB;IAED;;;OAGG;IACH,gBAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;;;;;OAOG;IACH,wBALa,OAAO,CAOnB;IAED;;OAEG;IACH,4BAQC;IAED;;;OAGG;IACH,aAFY,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,IAJa,CAAC,sBACH,CAAC,GACC,MAAM,CAsBlB;IAED;;;;;OAKG;IACH,aAJa,CAAC,SACH,CAAC,GACC,OAAO,CAInB;IAED;;;;OAIG;IACH,aAJa,CAAC,SACH,KAAK,CAAC,CAAC,CAAC,GACN,CAAC,GAAC,IAAI,CAclB;IAED;;;;;OAKG;IACH,iBAJa,CAAC,SACH,KAAK,CAAC,CAAC,CAAC,GACN,CAAC,CAUb;IAED;;;;OAIG;IACH,kCAFa,GAAC,GAAC,IAAI,CA0BlB;IAED;;;;OAIG;IACH,qBAHW,MAAM,UACN,GAAC,QAQX;IAED;;;OAGG;IACH,wBAFW,MAAM,gBAiBhB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,gCAEN,GAAC,GACC,MAAM,CAalB;IAED;;;;;;OAMG;IACH,+BALW,MAAM,gCAEN,GAAC,GACC,MAAM,CAyBlB;IAED;;;;;;OAMG;IACH,WAJa,OAAO,CA0BnB;IAED;;;;;;;;;;;;;;;OAeG;IACH,eALW,sBAAsB,GADpB,MAAM,CA+DlB;IAqCL;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;;CAPxB;;gCAhgB+B,sBAAsB;4BAD1B,kBAAkB;mBAF3B,oCAAoC"}
|
package/src/engine/ecs/Entity.js
CHANGED
|
@@ -39,6 +39,7 @@ const DEFAULT_FLAGS =
|
|
|
39
39
|
* // ... Once entity is no longer needed, we destroy it
|
|
40
40
|
* entity.destroy();
|
|
41
41
|
*
|
|
42
|
+
* @see {@link EntityComponentDataset}
|
|
42
43
|
* @author Alex Goldring
|
|
43
44
|
* @copyright Company Named Limited (c) 2025
|
|
44
45
|
*/
|
|
@@ -46,7 +47,7 @@ export class Entity {
|
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* Reference to the entity in a dataset. Do not modify directly.
|
|
49
|
-
* Only valid when the entity is built
|
|
50
|
+
* Only valid when the entity is built, check with {@link isBuilt}.
|
|
50
51
|
* @readonly
|
|
51
52
|
* @type {EntityReference}
|
|
52
53
|
*/
|
|
@@ -78,6 +79,7 @@ export class Entity {
|
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
81
|
* Listeners added before the entity is build live here
|
|
82
|
+
* @private
|
|
81
83
|
* @type {{name:string,listener:(function|Function), context:*}[]}
|
|
82
84
|
*/
|
|
83
85
|
#deferredListeners = [];
|
|
@@ -86,17 +88,19 @@ export class Entity {
|
|
|
86
88
|
* Dataset in which this entity exists, if built. If not built - null.
|
|
87
89
|
* Do not modify directly.
|
|
88
90
|
* @type {EntityComponentDataset}
|
|
91
|
+
* @see {@link build}
|
|
92
|
+
* @see {@link destroy}
|
|
89
93
|
*/
|
|
90
94
|
dataset = null;
|
|
91
95
|
|
|
92
96
|
/**
|
|
93
|
-
*
|
|
97
|
+
* Do not modify directly unless you understand the consequences of doing so.
|
|
94
98
|
* @type {EntityFlags|number}
|
|
95
99
|
*/
|
|
96
100
|
flags = DEFAULT_FLAGS;
|
|
97
101
|
|
|
98
102
|
/**
|
|
99
|
-
* Arbitrary user
|
|
103
|
+
* Arbitrary user data, add anything you want here.
|
|
100
104
|
* @readonly
|
|
101
105
|
* @type {Object}
|
|
102
106
|
*/
|
|
@@ -148,8 +152,12 @@ export class Entity {
|
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
/**
|
|
155
|
+
* True is the entity is currently attached to a dataset. When this is `true`, {@link dataset} property will be set as well.
|
|
151
156
|
* @readonly
|
|
152
157
|
* @returns {boolean}
|
|
158
|
+
* @see {@link build}
|
|
159
|
+
* @see {@link destroy}
|
|
160
|
+
*
|
|
153
161
|
*/
|
|
154
162
|
get isBuilt() {
|
|
155
163
|
return this.getFlag(EntityFlags.Built);
|
|
@@ -177,35 +185,38 @@ export class Entity {
|
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
/**
|
|
180
|
-
* @
|
|
181
|
-
*
|
|
188
|
+
* Note that this is live-edit, if the {@link Entity} is built - component will be added to the dataset as well.
|
|
189
|
+
*
|
|
190
|
+
* @template T class of the component
|
|
191
|
+
* @param {T} component_instance
|
|
182
192
|
* @returns {Entity}
|
|
183
193
|
*/
|
|
184
|
-
add(
|
|
185
|
-
assert.defined(
|
|
186
|
-
assert.notNull(
|
|
194
|
+
add(component_instance) {
|
|
195
|
+
assert.defined(component_instance, 'component_instance');
|
|
196
|
+
assert.notNull(component_instance, 'component_instance');
|
|
187
197
|
|
|
188
|
-
assert.notOk(this.hasComponent(Object.getPrototypeOf(
|
|
198
|
+
assert.notOk(this.hasComponent(Object.getPrototypeOf(component_instance).constructor), 'Component of this type already exists');
|
|
189
199
|
|
|
190
|
-
this.components.push(
|
|
200
|
+
this.components.push(component_instance);
|
|
191
201
|
|
|
192
202
|
if (this.getFlag(EntityFlags.Built)) {
|
|
193
203
|
|
|
194
204
|
//already built, add component to entity
|
|
195
205
|
|
|
196
206
|
if (this.getFlag(EntityFlags.RegisterComponents)) {
|
|
197
|
-
this.dataset.registerComponentType(
|
|
207
|
+
this.dataset.registerComponentType(component_instance.constructor)
|
|
198
208
|
}
|
|
199
209
|
|
|
200
|
-
this.dataset.addComponentToEntity(this.reference.id,
|
|
210
|
+
this.dataset.addComponentToEntity(this.reference.id, component_instance);
|
|
201
211
|
}
|
|
202
212
|
|
|
203
213
|
return this;
|
|
204
214
|
}
|
|
205
215
|
|
|
206
216
|
/**
|
|
217
|
+
* Check if a component of a given type is present on this entity.
|
|
207
218
|
* @template T
|
|
208
|
-
* @param {T} klass
|
|
219
|
+
* @param {T} klass type of the component
|
|
209
220
|
* @returns {boolean}
|
|
210
221
|
*/
|
|
211
222
|
hasComponent(klass) {
|
|
@@ -214,7 +225,7 @@ export class Entity {
|
|
|
214
225
|
|
|
215
226
|
/**
|
|
216
227
|
* @template T
|
|
217
|
-
* @param {Class<T>} klass
|
|
228
|
+
* @param {Class<T>} klass type of the component
|
|
218
229
|
* @returns {T|null} component of specified class
|
|
219
230
|
*/
|
|
220
231
|
getComponent(klass) {
|
|
@@ -248,7 +259,7 @@ export class Entity {
|
|
|
248
259
|
}
|
|
249
260
|
|
|
250
261
|
/**
|
|
251
|
-
*
|
|
262
|
+
* Note that this is live-edit, if the {@link Entity} is built - component will be removed from the dataset as well.
|
|
252
263
|
* @param {function} klass
|
|
253
264
|
* @returns {*|null}
|
|
254
265
|
*/
|
|
@@ -365,8 +376,11 @@ export class Entity {
|
|
|
365
376
|
}
|
|
366
377
|
|
|
367
378
|
/**
|
|
368
|
-
* Removes built entity from the {@link EntityManager}.
|
|
379
|
+
* Removes built entity from the {@link EntityManager}.
|
|
380
|
+
* Note that the destroyed {@link Entity} can be later re-built.
|
|
369
381
|
* @returns {boolean} true if entity was destroyed, false if entity was not built
|
|
382
|
+
* @see {@link build}
|
|
383
|
+
* @see {@link isBuilt}
|
|
370
384
|
*/
|
|
371
385
|
destroy() {
|
|
372
386
|
if (!this.getFlag(EntityFlags.Built)) {
|
|
@@ -404,6 +418,9 @@ export class Entity {
|
|
|
404
418
|
*
|
|
405
419
|
* @returns {number} entity ID
|
|
406
420
|
* @param {EntityComponentDataset} dataset
|
|
421
|
+
* @see {@link destroy}
|
|
422
|
+
* @see {@link isBuilt}
|
|
423
|
+
*
|
|
407
424
|
*/
|
|
408
425
|
build(dataset) {
|
|
409
426
|
assert.defined(dataset, "dataset");
|
|
@@ -466,6 +483,7 @@ export class Entity {
|
|
|
466
483
|
|
|
467
484
|
/**
|
|
468
485
|
* Extract data about an entity and its components from a dataset.
|
|
486
|
+
* Note that this behaves the same way as if you first created the {@link Entity} and then called {@link build} on it, just the other way around.
|
|
469
487
|
*
|
|
470
488
|
* @example
|
|
471
489
|
* const ecd:EntityComponentDataset = ...;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* // 4. After you no longer need the entity - destroy the entity via reference.
|
|
15
15
|
* entityRef.destroy(ecd);
|
|
16
16
|
*
|
|
17
|
+
* @see {@link EntityComponentDataset}
|
|
17
18
|
* @author Alex Goldring
|
|
18
19
|
* @copyright Company Named Limited (c) 2025
|
|
19
20
|
*/
|
|
@@ -41,7 +42,7 @@ export class EntityReference {
|
|
|
41
42
|
/**
|
|
42
43
|
* Entity generation number. This uniquely identifies an entity in combination with the ID
|
|
43
44
|
* Generation of an existing entity must match for it to be considered "the same".
|
|
44
|
-
* see {@link EntityComponentDataset.getEntityGeneration}
|
|
45
|
+
* @see {@link EntityComponentDataset.getEntityGeneration}
|
|
45
46
|
* @type {number}
|
|
46
47
|
*/
|
|
47
48
|
generation: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityReference.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityReference.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"EntityReference.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityReference.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAsHI;;;;;OAKG;IACH,gBAJW,MAAM,cACN,MAAM,GACL,eAAe,CAQ1B;IAED;;;;;OAKG;IACH,iBAJW,sBAAsB,MACtB,MAAM,GACJ,eAAe,CAQ3B;IA9ID;;;;OAIG;IACH,IAFU,MAAM,CAET;IAEP;;;;;OAKG;IACH,YAFU,MAAM,CAED;IAEf;;;OAGG;IACH,YAFW,eAAe,QAKzB;IAED;;;OAGG;IACH,SAFa,eAAe,CAQ3B;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,cAHW,eAAe,GACd,OAAO,CAMlB;IAED;;;;OAIG;IACH,YAHW,sBAAsB,GACpB,OAAO,CAYnB;IAED;;;;;OAKG;IACH,aAHW,sBAAsB,GACpB,OAAO,CASnB;IAED;;;;OAIG;IACH,UAHW,sBAAsB,UACtB,MAAM,QAShB;IAED;;;;OAIG;IACH,SAHW,MAAM,cACN,MAAM,QAUhB;IA+BL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;;cAWS,eAAe"}
|
|
@@ -16,6 +16,7 @@ import { assert } from "../../core/assert.js";
|
|
|
16
16
|
* // 4. After you no longer need the entity - destroy the entity via reference.
|
|
17
17
|
* entityRef.destroy(ecd);
|
|
18
18
|
*
|
|
19
|
+
* @see {@link EntityComponentDataset}
|
|
19
20
|
* @author Alex Goldring
|
|
20
21
|
* @copyright Company Named Limited (c) 2025
|
|
21
22
|
*/
|
|
@@ -31,7 +32,7 @@ export class EntityReference {
|
|
|
31
32
|
/**
|
|
32
33
|
* Entity generation number. This uniquely identifies an entity in combination with the ID
|
|
33
34
|
* Generation of an existing entity must match for it to be considered "the same".
|
|
34
|
-
* see {@link EntityComponentDataset.getEntityGeneration}
|
|
35
|
+
* @see {@link EntityComponentDataset.getEntityGeneration}
|
|
35
36
|
* @type {number}
|
|
36
37
|
*/
|
|
37
38
|
generation = -1
|
|
@@ -62,7 +63,7 @@ export class EntityReference {
|
|
|
62
63
|
* @return {number}
|
|
63
64
|
*/
|
|
64
65
|
hash() {
|
|
65
|
-
return this.id ^ this.generation;
|
|
66
|
+
return (this.id * 31) ^ this.generation;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -173,7 +174,7 @@ export class EntityReference {
|
|
|
173
174
|
EntityReference.prototype.isEntityReference = true;
|
|
174
175
|
|
|
175
176
|
/**
|
|
176
|
-
* Special singleton to describe an invalid reference
|
|
177
|
+
* Special utility singleton to describe an invalid reference.
|
|
177
178
|
* @readonly
|
|
178
179
|
* @type {EntityReference}
|
|
179
180
|
*/
|