@woosh/meep-engine 2.124.5 → 2.124.8

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.
@@ -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,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"){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.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 u=new Uint32Array(781250);function d(t,e){return t<e?e:t}function l(t,e){return t<e?t:e}function f(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],f=n[r+5],g=i[s+0],p=i[s+1],y=i[s+2],w=i[s+3],_=i[s+4],m=i[s+5],v=l(o,g),x=l(a,p),A=l(c,y),b=d(h,w),E=d(u,_),$=d(f,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 g(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 p(t,e,n,r,i,s){const o=r-t,a=s-n;return(i-e)*(o+a)+a*o}function y(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 w(t,e,n){const r=t[n],i=t[n+1],s=t[n+2];g(t,e,r,i,s,r,i,s)}function _(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 y(t)|y(e)<<1|y(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)}u.pointer=0;const m=u;class v{__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);g(this.__data_float32,c,n,r,i,s,o,a),this.__data_uint32[c+6]=e}readBounds(t,e,n){h(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let r;r=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(r,e,0),t+=p(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=m.pointer;let r,i,s=n;m[s++]=0,m[s++]=this.__node_count_leaf-1;const o=this.__data_float32;for(;s>n;){s-=2;const n=m[s+1],a=m[s];r=a,i=n;const c=_(o,7*(a+n>>1)+e,t);for(;r<=i;){for(;_(o,7*r+e,t)<c;)r++;for(;_(o,7*i+e,t)>c;)i--;r<=i&&(r!==i&&this.__swap_leaves(r,i),r++,i--)}a<i&&(m[s++]=a,m[s++]=i),r<n&&(m[s++]=r,m[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?f(c,r,c,s,c,e+7*i):t<a?h(c,s,c,r,6):w(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));f(c,6*s,c,t,c,t+6),s++}}}function x(t,e,n){let r=t;return r<e&&(r=e),r<n&&(r=n),r}function A(t,e,n){let r=t;return r>e&&(r=e),r>n&&(r=n),r}function b(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]=A(h,l,p),t[e+1]=A(u,f,y),t[e+2]=A(d,g,w),t[e+3]=x(h,l,p),t[e+4]=x(u,f,y),t[e+5]=x(d,g,w)}(t.__data_float32,o,n,r,i,s),t.__data_uint32[o+6]=e}function E(t){return 1===t.faces.length}function $(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}var F,U="undefined"!=typeof Float32Array?Float32Array:Array;function S(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function z(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function C(){}function V(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function B(t,e){t.__edges.delete(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 q(t,e){return t.v0===e||t.v1===e}function T(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)}),F=new U(3),U!=Float32Array&&(F[0]=0,F[1]=0,F[2]=0);let M=0;class I{index=M++;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 I;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(){return E(this)}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){z(this.faces,t)}removeFace(t){L(this.faces,t)}getOtherVertex(t){return $(this,t)}containsVertex(t){return q(this,t)}containsBothVertices(t,e){return T(this,t,e)}containsSameVerticesAs(t){return T(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 k(t,e,n){return t*t+e*e+n*n}function O(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=k(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}I.prototype.isTopoEdge=!0;let j=0;class D{index=j++;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 D;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++)q(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 z(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 z(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)}replaceAnotherVertex(t){throw new Error('deprecated, use "tm_vert_splice" instead')}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 D;return r.x=t,r.y=e,r.z=n,r}}D.prototype.isTopoVertex=!0;let R=0;class J{index=R++;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(),S(this.normal,t.normal)}clone(){const t=new J;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 z(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){O(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=D.from(t,e,n),u=D.from(r,i,s),d=D.from(o,a,c),l=new I,f=new I,g=new I;l.v0=h,l.v1=u,f.v0=u,f.v1=d,g.v0=d,g.v1=h;const p=new J;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}}J.prototype.isTopoFace=!0;class P{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=C){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 P;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 J;S(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 D,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){z(this.vertices,t)}removeVertex(t){var e;e=t,L(this.vertices,e)}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){B(this,t)}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){var e;e=t,this.__faces.delete(e)}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($(r,t)===e)return r}const i=new I;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 e of t){const n=e.v0,r=e.v1;for(let i of t){if(e===i)continue;const t=i.v0,s=i.v1;if(n===t){if(r!==s)continue}else{if(n!==s)continue;if(r!==t)continue}B(this,i),e.merge(i)}}}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 D;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 J;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: ${V(this.vertices.length)}, edges: ${V(this.getEdges().size)}, faces: ${V(this.getFaces().size)} }`}}P.prototype.isTopoMesh=!0;const H=[],W=[],G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)H[t]=G[t],W[G.charCodeAt(t)]=t;function Y(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(H[(i=e)>>18&63]+H[i>>12&63]+H[i>>6&63]+H[63&i])}var i;return r.join("")}W["-".charCodeAt(0)]=62,W["_".charCodeAt(0)]=63;const K=16383;class Q{static encode(t){return function(t){const e=t.length,n=e%3,r=[],i=e-n;for(let e=0;e<i;e+=K){const n=Y(t,e,e+K>i?i:e+K);r.push(n)}if(1===n){const n=t[e-1];r.push(H[n>>2]+H[n<<4&63]+"==")}else if(2===n){const n=(t[e-2]<<8)+t[e-1];r.push(H[n>>10]+H[n>>4&63]+H[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=W[n]<<18|W[r]<<12|W[i]<<6|W[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=W[n]<<2|W[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=W[n]<<10|W[r]<<4|W[i]>>2,s[o++]=e>>8&255,s[o++]=255&e}return s}(t).buffer}}const X="uint8",Z="uint16",tt="uint32",et="int8",nt="int16",rt="int32",it="float32",st="float64",ot={[X]:Uint8Array,[Z]:Uint16Array,[tt]:Uint32Array,[et]:Int8Array,[nt]:Int16Array,[rt]:Int32Array,float16:Uint16Array,[it]:Float32Array,[st]:Float64Array};function at(t){const e=Object.getPrototypeOf(t).constructor;switch(e){case Uint8Array:case Uint8ClampedArray:return X;case Uint16Array:return Z;case Uint32Array:return tt;case Int8Array:return et;case Int16Array:return nt;case Int32Array:return rt;case Float32Array:return it;case Float64Array:return st;default:throw new Error(`unsupported constructor type ${e.name}`)}}function ct(t,e,n){return t<e?e:t>n?n:t}function ht(t,e,n){return(e-t)*n+t}function ut(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}function dt(t){const e=t>>0;return 4294967295*(t-e)^e}class lt{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=ct(t,0,c),f=ct(e,0,h),g=0|u,p=0|f,y=u-g,w=f-p,_=d(0,g-1),m=d(0,p-1),v=l(c,g+1),x=l(h,p+1),A=l(c,v+1),b=m*a+n,E=p*a+n,$=x*a+n,F=l(h,x+1)*a+n,U=_*r,S=g*r,z=v*r,C=A*r,V=o[b+U],B=o[b+S],L=o[b+z],q=o[b+C],T=o[E+U],M=o[E+S],I=o[E+z],N=o[E+C],k=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=ut(y,V,B,L,q),G=ut(y,T,M,I,N),Y=ut(y,k,O,j,D),K=ut(y,R,J,P,H);return ut(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=ct(t,0,i-1),c=ct(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=ht(w,E,_),S=ht($,F,_);return ht(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(ct(s,0,r-1),ct(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=ct(t,0,this.width),s=ct(e,0,this.height),o=ct(t+n,0,this.width),a=ct(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=ct(t,0,s),c=ct(e,0,o),h=ct(t+n,0,s),u=ct(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=l(e,i),o=l(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+dt(i[t]);return s}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new lt(t,this.itemSize,this.width,this.height)}toJSON(){const t=Q.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:at(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:r,data:i}){const s=function(t){const e=ot[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(r);if("string"==typeof i){const t=Q.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 lt(r,t,e,n)}static uint8(t,e,n){const r=new Uint8Array(e*n*t);return new lt(r,t,e,n)}static uint16(t,e,n){const r=new Uint16Array(e*n*t);return new lt(r,t,e,n)}static uint32(t,e,n){const r=new Uint32Array(e*n*t);return new lt(r,t,e,n)}static int8(t,e,n){const r=new Int8Array(e*n*t);return new lt(r,t,e,n)}static int16(t,e,n){const r=new Int16Array(e*n*t);return new lt(r,t,e,n)}static int32(t,e,n){const r=new Int32Array(e*n*t);return new lt(r,t,e,n)}static float32(t,e,n){const r=new Float32Array(e*n*t);return new lt(r,t,e,n)}static float64(t,e,n){const r=new Float64Array(e*n*t);return new lt(r,t,e,n)}set(){throw new Error("Deprecated, use 'write' instead")}}function ft(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 gt(t,e,n,r,i,s){const o=3*n,a=3*r,c=3*i;O(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 pt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2],a=k(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}lt.prototype.isSampler2D=!0,lt.typeName="Sampler2D";const yt=new Float64Array(3),wt={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];gt(yt,0,r,s,o,t),ft(e,3*r,yt,0),ft(e,3*s,yt,0),ft(e,3*o,yt,0)}!function(t,e=0,n=t.length-e){const r=e+n;for(let n=e;n<r;n+=3)pt(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 v;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;b(t,i,e,n[r],n[r+1],n[r+2])}t.build()}(n,t,e),n},Sampler2D:lt,BufferedGeometryArraysBuilder:wt,tensionOptimizeUV:function(t,e,n,r=3){const i=new P;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(E(i))continue t;const s=2*$(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,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"){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.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 u=new Uint32Array(781250);function d(t,e){return t<e?e:t}function l(t,e){return t<e?t:e}function f(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],f=n[r+5],g=i[s+0],p=i[s+1],y=i[s+2],w=i[s+3],_=i[s+4],m=i[s+5],v=l(o,g),x=l(a,p),A=l(c,y),b=d(h,w),E=d(u,_),$=d(f,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 g(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 p(t,e,n,r,i,s){const o=r-t,a=s-n;return(i-e)*(o+a)+a*o}function y(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 w(t,e,n){const r=t[n],i=t[n+1],s=t[n+2];g(t,e,r,i,s,r,i,s)}function _(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 y(t)|y(e)<<1|y(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)}u.pointer=0;const m=u;class v{__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);g(this.__data_float32,c,n,r,i,s,o,a),this.__data_uint32[c+6]=e}readBounds(t,e,n){h(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let r;r=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(r,e,0),t+=p(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=m.pointer;let r,i,s=n;m[s++]=0,m[s++]=this.__node_count_leaf-1;const o=this.__data_float32;for(;s>n;){s-=2;const n=m[s+1],a=m[s];r=a,i=n;const c=_(o,7*(a+n>>1)+e,t);for(;r<=i;){for(;_(o,7*r+e,t)<c;)r++;for(;_(o,7*i+e,t)>c;)i--;r<=i&&(r!==i&&this.__swap_leaves(r,i),r++,i--)}a<i&&(m[s++]=a,m[s++]=i),r<n&&(m[s++]=r,m[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?f(c,r,c,s,c,e+7*i):t<a?h(c,s,c,r,6):w(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));f(c,6*s,c,t,c,t+6),s++}}}function x(t,e,n){let r=t;return r<e&&(r=e),r<n&&(r=n),r}function A(t,e,n){let r=t;return r>e&&(r=e),r>n&&(r=n),r}function b(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]=A(h,l,p),t[e+1]=A(u,f,y),t[e+2]=A(d,g,w),t[e+3]=x(h,l,p),t[e+4]=x(u,f,y),t[e+5]=x(d,g,w)}(t.__data_float32,o,n,r,i,s),t.__data_uint32[o+6]=e}function E(t){return 1===t.faces.length}function $(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}var F,U="undefined"!=typeof Float32Array?Float32Array:Array;function S(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function z(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function C(){}function V(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function B(t,e){t.__edges.delete(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 q(t,e){return t.v0===e||t.v1===e}function T(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)}),F=new U(3),U!=Float32Array&&(F[0]=0,F[1]=0,F[2]=0);let M=0;class I{index=M++;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 I;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(){return E(this)}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){z(this.faces,t)}removeFace(t){L(this.faces,t)}getOtherVertex(t){return $(this,t)}containsVertex(t){return q(this,t)}containsBothVertices(t,e){return T(this,t,e)}containsSameVerticesAs(t){return T(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 k(t,e,n){return t*t+e*e+n*n}function O(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=k(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}I.prototype.isTopoEdge=!0;let j=0;class D{index=j++;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 D;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++)q(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 z(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 z(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)}replaceAnotherVertex(t){throw new Error('deprecated, use "tm_vert_splice" instead')}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 D;return r.x=t,r.y=e,r.z=n,r}}D.prototype.isTopoVertex=!0;let R=0;class J{index=R++;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(),S(this.normal,t.normal)}clone(){const t=new J;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 z(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){O(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=D.from(t,e,n),u=D.from(r,i,s),d=D.from(o,a,c),l=new I,f=new I,g=new I;l.v0=h,l.v1=u,f.v0=u,f.v1=d,g.v0=d,g.v1=h;const p=new J;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}}J.prototype.isTopoFace=!0;class P{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=C){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 P;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 J;S(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 D,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){z(this.vertices,t)}removeVertex(t){var e;e=t,L(this.vertices,e)}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){B(this,t)}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){var e;e=t,this.__faces.delete(e)}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($(r,t)===e)return r}const i=new I;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 e of t){const n=e.v0,r=e.v1;for(let i of t){if(e===i)continue;const t=i.v0,s=i.v1;if(n===t){if(r!==s)continue}else{if(n!==s)continue;if(r!==t)continue}B(this,i),e.merge(i)}}}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 D;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 J;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: ${V(this.vertices.length)}, edges: ${V(this.getEdges().size)}, faces: ${V(this.getFaces().size)} }`}}P.prototype.isTopoMesh=!0;const H=[],W=[],G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)H[t]=G[t],W[G.charCodeAt(t)]=t;function Y(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(H[(i=e)>>18&63]+H[i>>12&63]+H[i>>6&63]+H[63&i])}var i;return r.join("")}W["-".charCodeAt(0)]=62,W["_".charCodeAt(0)]=63;const K=16383;class Q{static encode(t){return function(t){const e=t.length,n=e%3,r=[],i=e-n;for(let e=0;e<i;e+=K){const n=Y(t,e,e+K>i?i:e+K);r.push(n)}if(1===n){const n=t[e-1];r.push(H[n>>2]+H[n<<4&63]+"==")}else if(2===n){const n=(t[e-2]<<8)+t[e-1];r.push(H[n>>10]+H[n>>4&63]+H[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=W[n]<<18|W[r]<<12|W[i]<<6|W[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=W[n]<<2|W[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=W[n]<<10|W[r]<<4|W[i]>>2,s[o++]=e>>8&255,s[o++]=255&e}return s}(t).buffer}}const X="uint8",Z="uint16",tt="uint32",et="int8",nt="int16",rt="int32",it="float32",st="float64",ot={[X]:Uint8Array,[Z]:Uint16Array,[tt]:Uint32Array,[et]:Int8Array,[nt]:Int16Array,[rt]:Int32Array,float16:Uint16Array,[it]:Float32Array,[st]:Float64Array};function at(t){const e=Object.getPrototypeOf(t).constructor;switch(e){case Uint8Array:case Uint8ClampedArray:return X;case Uint16Array:return Z;case Uint32Array:return tt;case Int8Array:return et;case Int16Array:return nt;case Int32Array:return rt;case Float32Array:return it;case Float64Array:return st;default:throw new Error(`unsupported constructor type ${e.name}`)}}function ct(t,e,n){return t<e?e:t>n?n:t}function ht(t,e,n){return(e-t)*n+t}function ut(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 dt=4294967295;function lt(t){const e=t>>0;return dt-((t-e)*dt>>>0)^e}class ft{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=ct(t,0,c),f=ct(e,0,h),g=0|u,p=0|f,y=u-g,w=f-p,_=d(0,g-1),m=d(0,p-1),v=l(c,g+1),x=l(h,p+1),A=l(c,v+1),b=m*a+n,E=p*a+n,$=x*a+n,F=l(h,x+1)*a+n,U=_*r,S=g*r,z=v*r,C=A*r,V=o[b+U],B=o[b+S],L=o[b+z],q=o[b+C],T=o[E+U],M=o[E+S],I=o[E+z],N=o[E+C],k=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=ut(y,V,B,L,q),G=ut(y,T,M,I,N),Y=ut(y,k,O,j,D),K=ut(y,R,J,P,H);return ut(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=ct(t,0,i-1),c=ct(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=ht(w,E,_),S=ht($,F,_);return ht(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(ct(s,0,r-1),ct(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=ct(t,0,this.width),s=ct(e,0,this.height),o=ct(t+n,0,this.width),a=ct(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=ct(t,0,s),c=ct(e,0,o),h=ct(t+n,0,s),u=ct(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=l(e,i),o=l(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+lt(i[t]);return s}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new ft(t,this.itemSize,this.width,this.height)}toJSON(){const t=Q.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:at(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:r,data:i}){const s=function(t){const e=ot[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(r);if("string"==typeof i){const t=Q.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 ft(r,t,e,n)}static uint8(t,e,n){const r=new Uint8Array(e*n*t);return new ft(r,t,e,n)}static uint16(t,e,n){const r=new Uint16Array(e*n*t);return new ft(r,t,e,n)}static uint32(t,e,n){const r=new Uint32Array(e*n*t);return new ft(r,t,e,n)}static int8(t,e,n){const r=new Int8Array(e*n*t);return new ft(r,t,e,n)}static int16(t,e,n){const r=new Int16Array(e*n*t);return new ft(r,t,e,n)}static int32(t,e,n){const r=new Int32Array(e*n*t);return new ft(r,t,e,n)}static float32(t,e,n){const r=new Float32Array(e*n*t);return new ft(r,t,e,n)}static float64(t,e,n){const r=new Float64Array(e*n*t);return new ft(r,t,e,n)}set(){throw new Error("Deprecated, use 'write' instead")}}function gt(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 pt(t,e,n,r,i,s){const o=3*n,a=3*r,c=3*i;O(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 yt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2],a=k(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}ft.prototype.isSampler2D=!0,ft.typeName="Sampler2D";const wt=new Float64Array(3),_t={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];pt(wt,0,r,s,o,t),gt(e,3*r,wt,0),gt(e,3*s,wt,0),gt(e,3*o,wt,0)}!function(t,e=0,n=t.length-e){const r=e+n;for(let n=e;n<r;n+=3)yt(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 v;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;b(t,i,e,n[r],n[r+1],n[r+2])}t.build()}(n,t,e),n},Sampler2D:ft,BufferedGeometryArraysBuilder:_t,tensionOptimizeUV:function(t,e,n,r=3){const i=new P;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(E(i))continue t;const s=2*$(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.124.5",
8
+ "version": "2.124.8",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,75 +1,331 @@
1
- import Signal from "../events/signal/Signal";
2
-
3
- export class Color {
4
- constructor(r?: number, g?: number, b?: number, a?: number)
5
-
6
- r: number
7
- g: number
8
- b: number
9
- a: number
10
-
11
- 0: number
12
- 1: number
13
- 2: number
14
- 3: number
15
-
16
- readonly onChanged: Signal<number, number, number, number, number, number>
17
-
18
- parse(text: string): void
19
-
20
- set(r: number, g: number, b: number, a: number): void;
21
-
22
- setRGB(r: number, g: number, b: number): void
23
-
24
- setA(a: number): void
25
-
26
- setHSL(h: number, s: number, l: number): void
27
-
28
- setHCL(h: number, c: number, l: number): void
29
-
30
- setHSI(h: number, s: number, i: number): void
31
-
32
- setHSV(h: number, s: number, v: number): void
33
-
34
- getHSV(): { h: number, s: number, v: number }
35
-
36
- toUint(): number
37
-
38
- fromUint(v: number): void
39
-
40
- lerpColors(a: Color, b: Color, f: number): void
41
-
42
- equals(other: Color): boolean
43
-
44
- hash(): number
45
-
46
- copy(other: Color): void
47
-
48
- clone(): Color
49
-
50
- fromJSON(json: any): void
51
-
52
- toJSON(): any
53
-
54
- fromArray(source: ArrayLike<number>, destination_offset?: number): void
55
-
56
- toArray<T extends ArrayLike<number>>(destination?: T, destination_offset?: number): T
57
-
58
- //
59
-
60
- static parse(value: string): Color
61
-
62
- static fromHSV(h: number, s: number, v: number): Color
63
-
64
- static fromRGB(r: number, g: number, b: number): Color
65
-
66
- static readonly red: Color
67
- static readonly green: Color
68
- static readonly blue: Color
69
- static readonly yellow: Color
70
- static readonly cyan: Color
71
- static readonly magenta: Color
72
- static readonly white: Color
73
- static readonly black: Color
74
- static readonly transparent: Color
75
- }
1
+ /**
2
+ * @extends {Array.<number>}
3
+ * @class
4
+ */
5
+ export class Color {
6
+ /**
7
+ *
8
+ * @param {number[]|Float32Array} source
9
+ * @param {number} [offset]
10
+ * @returns {Color}
11
+ */
12
+ static fromArray(source: number[] | Float32Array, offset?: number): Color;
13
+ /**
14
+ *
15
+ * @param {number} r
16
+ * @param {number} g
17
+ * @param {number} b
18
+ * @returns {Color}
19
+ */
20
+ static fromRGB(r: number, g: number, b: number): Color;
21
+ /**
22
+ *
23
+ * @param {number} h
24
+ * @param {number} s
25
+ * @param {number} v
26
+ * @return {Color}
27
+ */
28
+ static fromHSV(h: number, s: number, v: number): Color;
29
+ /**
30
+ *
31
+ * @param {string} str
32
+ * @return {Color}
33
+ */
34
+ static parse(str: string): Color;
35
+ /**
36
+ *
37
+ * @param {Color} input
38
+ * @param {Color} [output]
39
+ * @returns {Color}
40
+ */
41
+ static from_linear_to_sRGB(input: Color, output?: Color): Color;
42
+ /**
43
+ *
44
+ * @param {Color} input
45
+ * @param {Color} [output]
46
+ * @returns {Color}
47
+ */
48
+ static from_sRGB_to_linear(input: Color, output?: Color): Color;
49
+ /**
50
+ *
51
+ * @param {number} [r] Red from 0 to 1
52
+ * @param {number} [g] Green from 0 to 1
53
+ * @param {number} [b] Blue from 0 to 1
54
+ * @param {number} [a] Alpha from 0 to 1 (transparency)
55
+ */
56
+ constructor(r?: number, g?: number, b?: number, a?: number);
57
+ /**
58
+ * Red channel
59
+ * Value from 0 to 1
60
+ * @type {number}
61
+ */
62
+ r: number;
63
+ /**
64
+ * Green channel
65
+ * Value from 0 to 1
66
+ * @type {number}
67
+ */
68
+ g: number;
69
+ /**
70
+ * Blue channel
71
+ * Value from 0 to 1
72
+ * @type {number}
73
+ */
74
+ b: number;
75
+ /**
76
+ * Alpha channel (transparency)
77
+ * Value from 0 to 1
78
+ * @type {number}
79
+ */
80
+ a: number;
81
+ /**
82
+ * @readonly
83
+ * @type {Signal<number,number,number,number, number,number,number,number>}
84
+ */
85
+ readonly onChanged: Signal<number, number, number, number, number, number, number, number>;
86
+ /**
87
+ *
88
+ * @param {number} v
89
+ */
90
+ set 0(v: number);
91
+ /**
92
+ *
93
+ * @returns {number}
94
+ */
95
+ get 0(): number;
96
+ /**
97
+ *
98
+ * @param {number} v
99
+ */
100
+ set 1(v: number);
101
+ /**
102
+ *
103
+ * @returns {number}
104
+ */
105
+ get 1(): number;
106
+ /**
107
+ *
108
+ * @param {number} v
109
+ */
110
+ set 2(v: number);
111
+ /**
112
+ *
113
+ * @returns {number}
114
+ */
115
+ get 2(): number;
116
+ /**
117
+ *
118
+ * @param {number} v
119
+ */
120
+ set 3(v: number);
121
+ /**
122
+ *
123
+ * @returns {number}
124
+ */
125
+ get 3(): number;
126
+ /**
127
+ *
128
+ * @returns {number}
129
+ */
130
+ get x(): number;
131
+ /**
132
+ *
133
+ * @returns {number}
134
+ */
135
+ get y(): number;
136
+ /**
137
+ *
138
+ * @returns {number}
139
+ */
140
+ get z(): number;
141
+ /**
142
+ *
143
+ * @returns {number}
144
+ */
145
+ get w(): number;
146
+ /**
147
+ * Pretending to be an array
148
+ * @return {number}
149
+ */
150
+ get length(): number;
151
+ /**
152
+ *
153
+ * @param {number} r
154
+ * @param {number} g
155
+ * @param {number} b
156
+ */
157
+ setRGB(r: number, g: number, b: number): void;
158
+ /**
159
+ *
160
+ * @param {number} r in range of 0..255
161
+ * @param {number} g in range of 0..255
162
+ * @param {number} b in range of 0..255
163
+ */
164
+ setRGBUint8(r: number, g: number, b: number): void;
165
+ /**
166
+ * set alpha
167
+ * @param {number} a
168
+ */
169
+ setA(a: number): void;
170
+ /**
171
+ *
172
+ * @param {number} r
173
+ * @param {number} g
174
+ * @param {number} b
175
+ * @param {number} a
176
+ */
177
+ set(r: number, g: number, b: number, a?: number): void;
178
+ /**
179
+ * Hue Saturation Lightness
180
+ * @param {number} h 0..1 (hue rotation compressed to normal 0 to 1 range where 1 represents 360deg)
181
+ * @param {number} s 0..1
182
+ * @param {number} l 0..1
183
+ */
184
+ setHSL(h: number, s: number, l: number): void;
185
+ /**
186
+ * Hue Chroma Luma
187
+ * @param {number} h Hue
188
+ * @param {number} c Chroma
189
+ * @param {number} l Luma
190
+ */
191
+ setHCL(h: number, c: number, l: number): void;
192
+ /**
193
+ * NOTE: I'm not sure if the implementation is correct, based on wikipedia article
194
+ * Hue Saturation Intensity
195
+ * @param {number} h 0..1 (hue rotation compressed to normal 0 to 1 range where 1 represents 360deg)
196
+ * @param {number} s 0..1
197
+ * @param {number} i 0..1
198
+ * @see https://en.wikipedia.org/wiki/HSL_and_HSV
199
+ */
200
+ setHSI(h: number, s: number, i: number): void;
201
+ /**
202
+ * Hue Saturation Value
203
+ * @param {number} h 0..1
204
+ * @param {number} s 0..1
205
+ * @param {number} v 0..1
206
+ */
207
+ setHSV(h: number, s: number, v: number): void;
208
+ /**
209
+ *
210
+ * @return {number}
211
+ */
212
+ computeLuminance(): number;
213
+ getHSV(): {
214
+ h: number;
215
+ s: number;
216
+ v: number;
217
+ };
218
+ /**
219
+ * Encodes RGB to uint24
220
+ * @returns {number}
221
+ */
222
+ toUint(): number;
223
+ /**
224
+ * Encodes RGBA to uint32
225
+ * @returns {number}
226
+ */
227
+ toUint32(): number;
228
+ /**
229
+ *
230
+ * @param {number} value
231
+ */
232
+ fromUint(value: number): void;
233
+ /**
234
+ * Returns color in CSS hex color format
235
+ * @example #FF0000
236
+ * @returns {string}
237
+ */
238
+ toHex(): string;
239
+ /**
240
+ *
241
+ * @returns {string}
242
+ */
243
+ toCssRGBAString(): string;
244
+ /**
245
+ *
246
+ * @param {Color} other
247
+ */
248
+ equals(other: Color): boolean;
249
+ /**
250
+ *
251
+ * @param {Color} other
252
+ */
253
+ copy(other: Color): void;
254
+ /**
255
+ *
256
+ * @returns {Color}
257
+ */
258
+ clone(): Color;
259
+ /**
260
+ *
261
+ * @returns {number}
262
+ */
263
+ hash(): number;
264
+ fromJSON({ r, g, b, a }: {
265
+ r: any;
266
+ g: any;
267
+ b: any;
268
+ a?: number;
269
+ }): void;
270
+ toJSON(): {
271
+ r: number;
272
+ g: number;
273
+ b: number;
274
+ a: number;
275
+ };
276
+ /**
277
+ *
278
+ * @param {number[]} [destination]
279
+ * @param {number} [destination_offset]
280
+ * @returns {number[]}
281
+ */
282
+ toArray(destination?: number[], destination_offset?: number): number[];
283
+ /**
284
+ * Can be either RGB or RGBA, in case of 3 element array, A channel will be se to 1
285
+ * @param {number[]|Float32Array} source
286
+ * @param {number} [offset]
287
+ */
288
+ fromArray(source: number[] | Float32Array, offset?: number): void;
289
+ /**
290
+ *
291
+ * @param {BinaryBuffer} buffer
292
+ */
293
+ toBinaryBuffer(buffer: BinaryBuffer): void;
294
+ /**
295
+ *
296
+ * @param {BinaryBuffer} buffer
297
+ */
298
+ fromBinaryBuffer(buffer: BinaryBuffer): void;
299
+ /**
300
+ *
301
+ * @param {string} str CSS-style string
302
+ * @returns {void}
303
+ */
304
+ parse(str: string): void;
305
+ /**
306
+ *
307
+ * @param {Color} a
308
+ * @param {Color} b
309
+ * @param {number} f
310
+ */
311
+ lerpColors(a: Color, b: Color, f: number): void;
312
+ /**
313
+ * @deprecated use {@link Color#toArray} instead
314
+ * @readonly
315
+ */
316
+ readonly writeToArray: (destination?: number[], destination_offset?: number) => number[];
317
+ [Symbol.iterator](): Generator<number, void, unknown>;
318
+ }
319
+ export namespace Color {
320
+ let red: Readonly<Color>;
321
+ let green: Readonly<Color>;
322
+ let blue: Readonly<Color>;
323
+ let yellow: Readonly<Color>;
324
+ let cyan: Readonly<Color>;
325
+ let magenta: Readonly<Color>;
326
+ let white: Readonly<Color>;
327
+ let black: Readonly<Color>;
328
+ let transparent: Readonly<Color>;
329
+ }
330
+ import Signal from "../events/signal/Signal.js";
331
+ //# sourceMappingURL=Color.d.ts.map
@@ -1,29 +1,163 @@
1
- import Signal from "../../events/signal/Signal";
2
- import LinearModifier from "./LinearModifier";
3
-
4
- export default class Stat extends Number {
5
- constructor(base_value: number)
6
-
7
- public readonly onModifierAdded: Signal<LinearModifier>
8
- public readonly onModifierRemoved: Signal<LinearModifier>
9
- public readonly onChanged: Signal<number, number>
10
-
11
- getValue(): number
12
-
13
- getBaseValue(): number
14
-
15
- setBaseValue(v: number): void
16
-
17
- addModifier(mod: LinearModifier): void
18
-
19
- removeModifier(mod: LinearModifier): boolean
20
-
21
- equals(other: Stat): boolean
22
-
23
- copy(other: Stat): void
24
-
25
- toJSON(): any
26
-
27
- fromJSON(json: any): void
28
-
29
- }
1
+ export default Stat;
2
+ /**
3
+ * Modifiable statistic.
4
+ * Allows non-destructive linear arithmetic.
5
+ * Useful when we wish to be able to reverse part or the whole of the computation
6
+ *
7
+ * Main purpose of the class is to facilitate implementation of RPG-like stats, such as maximum health, or armor.
8
+ * These stats can then be modified by various skills, equipment and effects. Each such modification will be added as a separate {@link LinearModifier} and can be reversed by removing the modifier.
9
+ */
10
+ declare class Stat extends Number {
11
+ /**
12
+ *
13
+ * @param {number} input
14
+ * @param {List<LinearModifier>}modifiers
15
+ * @returns {number}
16
+ */
17
+ static applyModifiers(input: number, modifiers: List<LinearModifier>): number;
18
+ /**
19
+ * @param {number} [value]
20
+ * @constructor
21
+ */
22
+ constructor(value?: number);
23
+ /**
24
+ * Unique identifier of a stat, such a health, armor etc.
25
+ * @type {number}
26
+ */
27
+ id: number;
28
+ /**
29
+ * List of modifiers.
30
+ * Order has no influence on final computed value
31
+ * @private
32
+ * @readonly
33
+ * @type {List<LinearModifier>}
34
+ */
35
+ private readonly __modifiers;
36
+ /**
37
+ *
38
+ * @type {function(number): number}
39
+ */
40
+ postprocess: (arg0: number) => number;
41
+ /**
42
+ * Base value that will be affected by modifiers
43
+ * @type {Vector1}
44
+ */
45
+ base: Vector1;
46
+ /**
47
+ * Final computed value. Do not modify this directly
48
+ * @type {Vector1}
49
+ */
50
+ value: Vector1;
51
+ /**
52
+ *
53
+ * @returns {Signal<LinearModifier>}
54
+ */
55
+ get onModifierAdded(): Signal<LinearModifier>;
56
+ /**
57
+ *
58
+ * @returns {Signal<LinearModifier>}
59
+ */
60
+ get onModifierRemoved(): Signal<LinearModifier>;
61
+ /**
62
+ * Remove all modifiers from the stat
63
+ */
64
+ resetModifiers(): void;
65
+ /**
66
+ *
67
+ * @returns {string}
68
+ */
69
+ toString(): string;
70
+ /**
71
+ *
72
+ * @returns {number}
73
+ */
74
+ getValue(): number;
75
+ updateValue(): void;
76
+ /**
77
+ *
78
+ * @returns {number}
79
+ */
80
+ getBaseValue(): number;
81
+ /**
82
+ *
83
+ * @param {number} v
84
+ */
85
+ setBaseValue(v: number): void;
86
+ /**
87
+ * NOTE: do not modify result
88
+ * @return {LinearModifier[]}
89
+ */
90
+ getModifiers(): LinearModifier[];
91
+ /**
92
+ *
93
+ * @param {LinearModifier} mod
94
+ */
95
+ addModifier(mod: LinearModifier): void;
96
+ /**
97
+ *
98
+ * @param {LinearModifier} mod
99
+ * @return {boolean}
100
+ */
101
+ hasModifier(mod: LinearModifier): boolean;
102
+ /**
103
+ *
104
+ * @param {LinearModifier} mod
105
+ * @returns {boolean}
106
+ */
107
+ removeModifier(mod: LinearModifier): boolean;
108
+ /**
109
+ *
110
+ * @param {Stat} other
111
+ * @returns {boolean}
112
+ */
113
+ equals(other: Stat): boolean;
114
+ /**
115
+ *
116
+ * @param {Stat} other
117
+ */
118
+ copy(other: Stat): void;
119
+ /**
120
+ * Copy base value from another stat
121
+ * @param {Stat} other
122
+ */
123
+ copyBase(other: Stat): void;
124
+ /**
125
+ *
126
+ * @param {function(number):number} f
127
+ * @param {number} v
128
+ */
129
+ setBaseFromParametricFunction(f: (arg0: number) => number, v: number): void;
130
+ /**
131
+ * @param {Stat} other
132
+ */
133
+ addNonTransientModifiersFromStat(other: Stat): void;
134
+ toJSON(): {
135
+ base: number;
136
+ modifiers: any;
137
+ };
138
+ fromJSON(json: any): void;
139
+ /**
140
+ *
141
+ * @returns {Signal}
142
+ */
143
+ get onChanged(): Signal;
144
+ /**
145
+ * @readonly
146
+ * @type {boolean}
147
+ */
148
+ readonly isStat: boolean;
149
+ }
150
+ declare namespace Stat {
151
+ namespace Process {
152
+ export function ROUND_DOWN(v: number): number;
153
+ export function NONE(v: any): any;
154
+ export function clampMin(value: number): (arg0: number) => number;
155
+ export function clampMax(value: number): (arg0: number) => number;
156
+ export { chain };
157
+ }
158
+ }
159
+ import Vector1 from "../../geom/Vector1.js";
160
+ import LinearModifier from "./LinearModifier.js";
161
+ import List from "../../collection/list/List.js";
162
+ import { chain } from "../../function/chain.js";
163
+ //# sourceMappingURL=Stat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Stat.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/stat/Stat.js"],"names":[],"mappings":";AASA;;;;;;;GAOG;AACH;IAyPI;;;;;OAKG;IACH,6BAJW,MAAM,aACN,IAAI,CAAC,cAAc,CAAC,GAClB,MAAM,CAoBlB;IA3PD;;;OAGG;IACH,oBAHW,MAAM,EAuBhB;IA7CD;;;OAGG;IACH,IAFU,MAAM,CAET;IAEP;;;;;;OAMG;IACH,6BAAyB;IAEzB;;;OAGG;IACH,aAFU,CAAS,IAAM,EAAN,MAAM,KAAG,MAAM,CAEF;IAY5B;;;OAGG;IACH,MAFU,OAAO,CAEa;IAE9B;;;OAGG;IACH,OAFU,OAAO,CAEc;IAMnC;;;OAGG;IACH,uBAFa,MAAM,CAAC,cAAc,CAAC,CAIlC;IAED;;;OAGG;IACH,yBAFa,MAAM,CAAC,cAAc,CAAC,CAIlC;IAED;;OAEG;IACH,uBAEC;IAUD;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED,oBAUC;IAED;;;OAGG;IACH,gBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFY,cAAc,EAAE,CAI3B;IAED;;;OAGG;IACH,iBAFW,cAAc,QAMxB;IAED;;;;OAIG;IACH,iBAHW,cAAc,GACb,OAAO,CAIlB;IAED;;;;OAIG;IACH,oBAHW,cAAc,GACZ,OAAO,CAQnB;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CASnB;IAED;;;OAGG;IACH,YAFW,IAAI,QAOd;IAED;;;OAGG;IACH,gBAFW,IAAI,QAId;IAED;;;;OAIG;IACH,iCAHW,CAAS,IAAM,EAAN,MAAM,KAAE,MAAM,KACvB,MAAM,QAKhB;IAED;;OAEG;IACH,wCAFW,IAAI,QAmBd;IAED;;;MAKC;IAED,0BAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAIlB;IAwDL;;;OAGG;IACH,iBAFU,OAAO,CAEI;CAjCpB;;;QAOe,8BAHD,MAAM,GACL,MAAM,CAIjB;QACK,kCAEL;QAMS,gCAHC,MAAM,GACJ,CAAS,IAAM,EAAN,MAAM,KAAG,MAAM,CAMpC;;;;oBAtTe,uBAAuB;2BAIhB,qBAAqB;iBAN/B,+BAA+B;sBAC1B,yBAAyB"}
1
+ {"version":3,"file":"Stat.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/stat/Stat.js"],"names":[],"mappings":";AAUA;;;;;;;GAOG;AACH;IAyPI;;;;;OAKG;IACH,6BAJW,MAAM,aACN,IAAI,CAAC,cAAc,CAAC,GAClB,MAAM,CAoBlB;IA3PD;;;OAGG;IACH,oBAHW,MAAM,EAuBhB;IA7CD;;;OAGG;IACH,IAFU,MAAM,CAET;IAEP;;;;;;OAMG;IACH,6BAAyB;IAEzB;;;OAGG;IACH,aAFU,CAAS,IAAM,EAAN,MAAM,KAAG,MAAM,CAEF;IAY5B;;;OAGG;IACH,MAFU,OAAO,CAEa;IAE9B;;;OAGG;IACH,OAFU,OAAO,CAEc;IAMnC;;;OAGG;IACH,uBAFa,MAAM,CAAC,cAAc,CAAC,CAIlC;IAED;;;OAGG;IACH,yBAFa,MAAM,CAAC,cAAc,CAAC,CAIlC;IAED;;OAEG;IACH,uBAEC;IAUD;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED,oBAUC;IAED;;;OAGG;IACH,gBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFY,cAAc,EAAE,CAI3B;IAED;;;OAGG;IACH,iBAFW,cAAc,QAMxB;IAED;;;;OAIG;IACH,iBAHW,cAAc,GACb,OAAO,CAIlB;IAED;;;;OAIG;IACH,oBAHW,cAAc,GACZ,OAAO,CAQnB;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CASnB;IAED;;;OAGG;IACH,YAFW,IAAI,QAOd;IAED;;;OAGG;IACH,gBAFW,IAAI,QAId;IAED;;;;OAIG;IACH,iCAHW,CAAS,IAAM,EAAN,MAAM,KAAE,MAAM,KACvB,MAAM,QAKhB;IAED;;OAEG;IACH,wCAFW,IAAI,QAmBd;IAED;;;MAKC;IAED,0BAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAIlB;IAkEL;;;OAGG;IACH,iBAFU,OAAO,CAEI;CA3CpB;;;QAOe,8BAHD,MAAM,GACL,MAAM,CAIjB;QACK,kCAEL;QAMS,gCAHC,MAAM,GACJ,CAAS,IAAM,EAAN,MAAM,KAAG,MAAM,CAMpC;QAMS,gCAHC,MAAM,GACL,CAAS,IAAM,EAAN,MAAM,KAAG,MAAM,CAMnC;;;;oBAjUe,uBAAuB;2BAKhB,qBAAqB;iBAP/B,+BAA+B;sBAC1B,yBAAyB"}
@@ -5,6 +5,7 @@ import Vector1 from "../../geom/Vector1.js";
5
5
  import { EPSILON } from "../../math/EPSILON.js";
6
6
  import { epsilonEquals } from "../../math/epsilonEquals.js";
7
7
  import { max2 } from "../../math/max2.js";
8
+ import { min2 } from "../../math/min2.js";
8
9
  import LinearModifier from "./LinearModifier.js";
9
10
 
10
11
  /**
@@ -41,7 +42,7 @@ class Stat extends Number {
41
42
  * @param {number} [value]
42
43
  * @constructor
43
44
  */
44
- constructor(value=0) {
45
+ constructor(value = 0) {
45
46
  super();
46
47
 
47
48
  assert.isNumber(value, "value");
@@ -312,6 +313,16 @@ Stat.Process = {
312
313
  return max2(value, v);
313
314
  }
314
315
  },
316
+ /**
317
+ * Clamp the highest value, forcing the result to always be <= value
318
+ * @param {number} value
319
+ * @return {function(number): number}
320
+ */
321
+ clampMax: function (value) {
322
+ return function min(v) {
323
+ return min2(v, value);
324
+ }
325
+ },
315
326
  /**
316
327
  * Allows us to chain multiple effects
317
328
  */
@@ -1 +1 @@
1
- {"version":3,"file":"computeHashFloat.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/numbers/computeHashFloat.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,oCAHW,MAAM,GACJ,MAAM,CAclB"}
1
+ {"version":3,"file":"computeHashFloat.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/numbers/computeHashFloat.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,oCAHW,MAAM,GACJ,MAAM,CAiBlB"}
@@ -13,8 +13,11 @@ export function computeHashFloat(v) {
13
13
 
14
14
  // fractional part is scaled up into uint32 range,
15
15
  // this inexact method, as it will produce 0 hash for values below a certain threshold, but it's fast
16
- const fractionHash = fraction * UINT32_MAX;
16
+ const fraction_hash = ((fraction) * UINT32_MAX) >>> 0;
17
+
18
+ // we flip the order, tiny fractions will result in higher bits of the final hash, leads to better dispersion
19
+ const fraction_hash_inverse = UINT32_MAX - fraction_hash;
17
20
 
18
21
  // take XOR of both parts
19
- return fractionHash ^ whole;
22
+ return fraction_hash_inverse ^ whole;
20
23
  }
@@ -1,7 +1,21 @@
1
1
  /**
2
- * Universally Unique Identifier
3
- * The default is Nil UUID, where all bits are set to 0
4
- * @see IETF RFC 4122
2
+ * Universally Unique Identifier (UUID), a 128 bit label used to uniquely identify resources.
3
+ * The default is Nil UUID, where all bits are set to 0, see {@link UUID.nil}.
4
+ * Also known as GUID ( Globally Unique IDentifier).
5
+ *
6
+ * @see IETF RFC 4122 - https://datatracker.ietf.org/doc/html/rfc4122
7
+ * @example
8
+ * class Student{
9
+ * id: UUID
10
+ * name: string
11
+ * age: number
12
+ * }
13
+ * @example
14
+ * const id_a = UUID.v1();
15
+ * const id_b = UUID.v1();
16
+ *
17
+ * id_a.equals(id_b); // false
18
+
5
19
  */
6
20
  export class UUID {
7
21
  /**
@@ -36,6 +50,22 @@ export class UUID {
36
50
  * @returns {Uint8Array}
37
51
  */
38
52
  get data(): Uint8Array;
53
+ /**
54
+ * The version number is in the most significant 4 bits of the timestamp (bits 4 through 7 of the time_hi_and_version field).
55
+ *
56
+ * @see https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3
57
+ * @return {number}
58
+ * @example
59
+ * UUID.v1().version === 1
60
+ * UUID.v4().version === 4
61
+ */
62
+ get version(): number;
63
+ /**
64
+ * The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.
65
+ * Clears all bits of this UUID.
66
+ * @returns {void}
67
+ */
68
+ nil(): void;
39
69
  /**
40
70
  * Generate Variant 1 UUID
41
71
  * @returns {void}
@@ -1 +1 @@
1
- {"version":3,"file":"UUID.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUID.js"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH;IAkGI;;;OAGG;IACH,aAFY,IAAI,CAQf;IA2BD;;;OAGG;IACH,aAFa,IAAI,CAQhB;IAED;;;;OAIG;IACH,iBAFY,MAAM,CAIjB;IA6CD;;;;OAIG;IACH,qBAHW,MAAM,GACL,IAAI,CAQf;IA/MD;;;OAGG;IACH,gBAFW,MAAM,EAAE,GAAC,UAAU,GAAC,SAAS,CAAC,MAAM,CAAC,EAO/C;IAED;;;OAGG;IACH,YAFa,UAAU,CAItB;IAED;;;OAGG;IACH,MAFa,IAAI,CAwEhB;IAcD;;;OAGG;IACH,MAFa,IAAI,CAqBhB;IAuBD;;;OAGG;IACH,cAFW,MAAM,QAuChB;IAeD;;;;;;OAMG;IACH,YAFa,MAAM,CA2BlB;IAED;;;OAGG;IACH,YAFW,IAAI,QAId;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAcnB;IAED;;;OAGG;IACH,QAFa,MAAM,CAYlB;IAIL;;OAEG;IACH,uBA7EiB,MAAM,CA6EF;IAErB;;OAEG;IACH,4BA7Ie,MAAM,UA6IE;IAQvB;;;OAGG;IACH,iBAFU,OAAO,CAEI;;CAtBpB;;kBAcS,MAAM"}
1
+ {"version":3,"file":"UUID.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUID.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IA2HI;;;OAGG;IACH,aAFY,IAAI,CAQf;IA2BD;;;OAGG;IACH,aAFa,IAAI,CAQhB;IAED;;;;OAIG;IACH,iBAFY,MAAM,CAIjB;IA6CD;;;;OAIG;IACH,qBAHW,MAAM,GACL,IAAI,CAQf;IAxOD;;;OAGG;IACH,gBAFW,MAAM,EAAE,GAAC,UAAU,GAAC,SAAS,CAAC,MAAM,CAAC,EAO/C;IAED;;;OAGG;IACH,YAFa,UAAU,CAItB;IAED;;;;;;;;OAQG;IACH,eALY,MAAM,CAUjB;IAED;;;;OAIG;IACH,OAFa,IAAI,CAIhB;IAED;;;OAGG;IACH,MAFa,IAAI,CAwEhB;IAcD;;;OAGG;IACH,MAFa,IAAI,CAqBhB;IAuBD;;;OAGG;IACH,cAFW,MAAM,QAuChB;IAeD;;;;;;OAMG;IACH,YAFa,MAAM,CA2BlB;IAED;;;OAGG;IACH,YAFW,IAAI,QAId;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAcnB;IAED;;;OAGG;IACH,QAFa,MAAM,CAYlB;IAIL;;OAEG;IACH,uBA7EiB,MAAM,CA6EF;IAErB;;OAEG;IACH,4BA7Ie,MAAM,UA6IE;IAQvB;;;OAGG;IACH,iBAFU,OAAO,CAEI;;CAtBpB;;kBAcS,MAAM"}
@@ -24,9 +24,23 @@ _nodeId[0] |= 0x01;
24
24
  let _clockseq = ((randomUint8(random) << 8) | randomUint8(random)) & 0x3fff;
25
25
 
26
26
  /**
27
- * Universally Unique Identifier
28
- * The default is Nil UUID, where all bits are set to 0
29
- * @see IETF RFC 4122
27
+ * Universally Unique Identifier (UUID), a 128 bit label used to uniquely identify resources.
28
+ * The default is Nil UUID, where all bits are set to 0, see {@link UUID.nil}.
29
+ * Also known as GUID ( Globally Unique IDentifier).
30
+ *
31
+ * @see IETF RFC 4122 - https://datatracker.ietf.org/doc/html/rfc4122
32
+ * @example
33
+ * class Student{
34
+ * id: UUID
35
+ * name: string
36
+ * age: number
37
+ * }
38
+ * @example
39
+ * const id_a = UUID.v1();
40
+ * const id_b = UUID.v1();
41
+ *
42
+ * id_a.equals(id_b); // false
43
+
30
44
  */
31
45
  export class UUID {
32
46
  #data = new Uint8Array(16);
@@ -50,6 +64,31 @@ export class UUID {
50
64
  return this.#data;
51
65
  }
52
66
 
67
+ /**
68
+ * The version number is in the most significant 4 bits of the timestamp (bits 4 through 7 of the time_hi_and_version field).
69
+ *
70
+ * @see https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.3
71
+ * @return {number}
72
+ * @example
73
+ * UUID.v1().version === 1
74
+ * UUID.v4().version === 4
75
+ */
76
+ get version() {
77
+ const bits = this.#data[6];
78
+
79
+ // using bits 4 through 7
80
+ return (bits >> 4) & 15;
81
+ }
82
+
83
+ /**
84
+ * The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.
85
+ * Clears all bits of this UUID.
86
+ * @returns {void}
87
+ */
88
+ nil() {
89
+ this.#data.fill(0);
90
+ }
91
+
53
92
  /**
54
93
  * Generate Variant 1 UUID
55
94
  * @returns {void}
@@ -146,9 +185,9 @@ export class UUID {
146
185
 
147
186
  const data = this.data;
148
187
 
149
- for (let i = 0; i < 16; i+=4) {
188
+ for (let i = 0; i < 16; i += 4) {
150
189
 
151
- const r = ( random() * 4294967296 ) >>> 0;
190
+ const r = (random() * 4294967296) >>> 0;
152
191
 
153
192
  data[i] = r & 0xff;
154
193
  data[i + 1] = (r >>> 8) & 0xff;
@@ -1 +1 @@
1
- {"version":3,"file":"HighlightDefinition.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/highlight/HighlightDefinition.js"],"names":[],"mappings":"AAEA;IA0DI;;;;OAIG;IACH,yBAFY,mBAAmB,CAQ9B;IAED;;;;;;;OAOG;IACH,eANW,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,GACL,mBAAmB,CAQ9B;IAnFD;;;OAGG;IACH,gBAFU,KAAK,CAEK;IAWpB;;;OAGG;IACH,eAFW,MAAM,EAIhB;IAdD;;;OAGG;IACH,eAFa,MAAM,CAIlB;IAUD;;;;OAIG;IACH,cAHW,mBAAmB,GACjB,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;aAQC;IAED;;MAIC;CA8BJ;sBAxFqB,iCAAiC"}
1
+ {"version":3,"file":"HighlightDefinition.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/highlight/HighlightDefinition.js"],"names":[],"mappings":"AAEA;IA0DI;;;;OAIG;IACH,yBAFY,mBAAmB,CAQ9B;IAED;;;;;;;OAOG;IACH,eANW,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,GACL,mBAAmB,CAQ9B;IAnFD;;;OAGG;IACH,gBAFU,KAAK,CAEK;IAWpB;;;OAGG;IACH,eAFW,MAAM,EAIhB;IAdD;;;OAGG;IACH,eAFa,MAAM,CAIlB;IAUD;;;;OAIG;IACH,cAHW,mBAAmB,GACjB,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;aAQC;IAED;;;;;;;MAIC;CA8BJ;sBAxFqB,iCAAiC"}
@@ -61,7 +61,12 @@ declare class Water {
61
61
  fromJSON(json: any): void;
62
62
  toJSON(): {
63
63
  level: number;
64
- color: any;
64
+ color: {
65
+ r: number;
66
+ g: number;
67
+ b: number;
68
+ a: number;
69
+ };
65
70
  };
66
71
  }
67
72
  declare namespace Water {
@@ -1 +1 @@
1
- {"version":3,"file":"Water.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/water/Water.js"],"names":[],"mappings":";AAQA;IAgDI,0BA6BC;IA5ED,eAAuB;IACvB;;;OAGG;IACH,OAFU,KAAK,CAEgB;IAG/B;;;OAGG;IACH,sBAFU,eAAe,CAE0B;IAGnD;;;OAGG;IACH,YAFU,KAAK,CAE6B;IAE5C;;;OAGG;IACH,WAFU,OAAO,CAEY;IAE7B;;;OAGG;IACH,eAFU,OAAO,CAEgB;IAEjC;;;OAGG;IACH,eAFU,OAAO,CAEc;IAE/B;;;OAGG;IACH,YAFU,OAAO,CAEa;IAE9B,eAAsB;IAUlB;;;OAGG;IACH,UAFU,cAAc,CAEJ;IAEpB;;;;OAIG;IACH,sBAAyB;IAY7B,wBAiBC;IAED,qBAcC;IAED;;;;OAIG;IACH,gCAHW,OAAO,aACP,MAAM,QAoChB;IAED,4BA6BC;IAED,0BAOC;IAED;;;MAKC;CACJ;;;;oBA9MmB,kCAAkC;sBADhC,iCAAiC;gCAEvB,mDAAmD;0BAHzD,yCAAyC"}
1
+ {"version":3,"file":"Water.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/water/Water.js"],"names":[],"mappings":";AAQA;IAgDI,0BA6BC;IA5ED,eAAuB;IACvB;;;OAGG;IACH,OAFU,KAAK,CAEgB;IAG/B;;;OAGG;IACH,sBAFU,eAAe,CAE0B;IAGnD;;;OAGG;IACH,YAFU,KAAK,CAE6B;IAE5C;;;OAGG;IACH,WAFU,OAAO,CAEY;IAE7B;;;OAGG;IACH,eAFU,OAAO,CAEgB;IAEjC;;;OAGG;IACH,eAFU,OAAO,CAEc;IAE/B;;;OAGG;IACH,YAFU,OAAO,CAEa;IAE9B,eAAsB;IAUlB;;;OAGG;IACH,UAFU,cAAc,CAEJ;IAEpB;;;;OAIG;IACH,sBAAyB;IAY7B,wBAiBC;IAED,qBAcC;IAED;;;;OAIG;IACH,gCAHW,OAAO,aACP,MAAM,QAoChB;IAED,4BA6BC;IAED,0BAOC;IAED;;;;;;;;MAKC;CACJ;;;;oBA9MmB,kCAAkC;sBADhC,iCAAiC;gCAEvB,mDAAmD;0BAHzD,yCAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateSharedVerticesIndexList.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.js"],"names":[],"mappings":"AA2EA;;;;;;GAMG;AACH,sEALW,MAAM,EAAE,GAAC,UAAU,YACnB,kBAAkB,kBAClB,MAAM,GACJ,IAAI,CAuGhB"}
1
+ {"version":3,"file":"GenerateSharedVerticesIndexList.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.js"],"names":[],"mappings":"AAoGA;;;;;;GAMG;AACH,sEALW,MAAM,EAAE,GAAC,UAAU,YACnB,kBAAkB,kBAClB,MAAM,GACJ,IAAI,CAuGhB"}
@@ -1,7 +1,7 @@
1
1
  import { vec3 } from "gl-matrix";
2
- import { GetPosition } from "./GetPosition.js";
3
2
  import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
4
3
  import { GetNormal } from "./GetNormal.js";
4
+ import { GetPosition } from "./GetPosition.js";
5
5
  import { GetTexCoord } from "./GetTexCoord.js";
6
6
 
7
7
  /**
@@ -12,7 +12,7 @@ import { GetTexCoord } from "./GetTexCoord.js";
12
12
  * @returns {number}
13
13
  */
14
14
  function HASH(x, y, z) {
15
- return ((x) * 73856093) ^ ((y) * 19349663) ^ ((z) * 83492791);
15
+ return (x * 73856093) ^ (y * 19349663) ^ (z * 83492791);
16
16
  }
17
17
 
18
18
  /**
@@ -23,7 +23,7 @@ function HASH(x, y, z) {
23
23
  * @returns {number}
24
24
  */
25
25
  function HASH_F(x, y, z) {
26
- return (computeHashFloat(x) * 73856093) ^ (computeHashFloat(y) * 19349663) ^ (computeHashFloat(z) * 83492791);
26
+ return HASH(computeHashFloat(x), computeHashFloat(y), computeHashFloat(z));
27
27
  }
28
28
 
29
29
  /**
@@ -37,7 +37,7 @@ function HASH_F(x, y, z) {
37
37
  * @param {number} n
38
38
  */
39
39
  function radixsort_pair(comp, data, comp2, data2, n) {
40
- let shift = 0;
40
+
41
41
 
42
42
  let _data_0 = data;
43
43
  let _data_1 = data2;
@@ -45,19 +45,42 @@ function radixsort_pair(comp, data, comp2, data2, n) {
45
45
  let _comp_0 = comp;
46
46
  let _comp_1 = comp2;
47
47
 
48
- for (let pass = 0; pass < 4; pass++, shift += 8) {
49
- const bins = new Int32Array(257);
50
- /* Count number of elements per bin. */
51
- for (let i = 0; i < n; i++) {
52
- bins[((_comp_0[i] >> shift) & 0xff) + 1]++;
48
+ const data_size = 4; // 4 bytes
49
+
50
+ const bins = new Uint32Array(257 * data_size);
51
+
52
+ /* Count number of elements per bin. */
53
+ for (let i = 0; i < n; i++) {
54
+
55
+ for (let pass = 0; pass < data_size; pass++) {
56
+ const shift = 8 * pass;
57
+
58
+ const key = _comp_0[i];
59
+
60
+ const index = pass * 257 + ((key >> shift) & 0xff) + 1;
61
+
62
+ bins[index]++;
63
+
53
64
  }
54
- /* Compute prefix sum to find position of each bin in the sorted array. */
65
+
66
+ }
67
+
68
+ /* Compute prefix sum to find position of each bin in the sorted array. */
69
+ for (let pass = 0; pass < data_size; pass++) {
55
70
  for (let i = 2; i < 256; i++) {
56
- bins[i] += bins[i - 1];
71
+ const offset = pass * 257 + i;
72
+ bins[offset] += bins[offset - 1];
57
73
  }
74
+ }
75
+
76
+ let shift = 0;
77
+ for (let pass = 0; pass < data_size; pass++, shift += 8) {
58
78
  /* Insert the elements in their correct location based on their bin. */
59
79
  for (let i = 0; i < n; i++) {
60
- const pos = bins[(_comp_0[i] >> shift) & 0xff]++;
80
+ const bin_index = pass * 257 + (_comp_0[i] >> shift) & 0xff;
81
+
82
+ const pos = bins[bin_index]++;
83
+
61
84
  _comp_1[pos] = _comp_0[i];
62
85
  _data_1[pos] = _data_0[i];
63
86
  }
@@ -70,7 +93,9 @@ function radixsort_pair(comp, data, comp2, data2, n) {
70
93
  let tmpcomp = _comp_0;
71
94
  _comp_0 = _comp_1;
72
95
  _comp_1 = tmpcomp;
96
+
73
97
  }
98
+
74
99
  }
75
100
 
76
101
  /**