@woosh/meep-engine 2.111.6 → 2.111.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle-worker-terrain.js +1 -1
- package/package.json +1 -1
- package/src/core/geom/3d/topology/expandConnectivityByLocality.d.ts.map +1 -1
- package/src/core/geom/3d/topology/expandConnectivityByLocality.js +3 -2
- package/src/core/geom/3d/topology/isEdgeConnectedToOutline.d.ts.map +1 -1
- package/src/core/geom/3d/topology/isEdgeConnectedToOutline.js +2 -1
- package/src/core/geom/3d/topology/isVertexConnectedToOutline.d.ts.map +1 -1
- package/src/core/geom/3d/topology/isVertexConnectedToOutline.js +3 -1
- package/src/core/geom/3d/topology/query/query_edge_other_vertex.d.ts.map +1 -1
- package/src/core/geom/3d/topology/query/query_edge_other_vertex.js +3 -0
- package/src/core/geom/3d/topology/util/mesh_flood_fill.d.ts +1 -2
- package/src/core/geom/3d/topology/util/mesh_flood_fill.d.ts.map +1 -1
- package/src/core/geom/3d/topology/util/mesh_flood_fill.js +0 -2
- package/src/engine/ecs/terrain/tiles/TileBuildWorker.js +2 -2
- package/src/engine/graphics/geometry/AttributeSpec.d.ts.map +1 -1
- package/src/engine/graphics/geometry/AttributeSpec.js +8 -8
- package/src/engine/graphics/geometry/computeBoundingSphereFromVertexData.d.ts +2 -2
- package/src/engine/graphics/geometry/computeBoundingSphereFromVertexData.d.ts.map +1 -1
- package/src/engine/graphics/geometry/computeBoundingSphereFromVertexData.js +4 -4
- package/src/engine/graphics/geometry/optimization/geometry_optimize_uv_tension.d.ts +10 -0
- package/src/engine/graphics/geometry/optimization/geometry_optimize_uv_tension.d.ts.map +1 -0
- package/src/engine/{ecs/terrain/util/tensionOptimizeUV.js → graphics/geometry/optimization/geometry_optimize_uv_tension.js} +14 -7
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.d.ts +1 -2
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.d.ts.map +1 -1
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -2
- package/src/engine/graphics/geometry/skining/computeSkinnedMeshVertices.d.ts +1 -1
- package/src/engine/graphics/geometry/skining/computeSkinnedMeshVertices.js +1 -1
- package/src/engine/ecs/terrain/util/tensionOptimizeUV.d.ts +0 -10
- package/src/engine/ecs/terrain/util/tensionOptimizeUV.d.ts.map +0 -1
- package/src/engine/graphics/geometry/BufferGeometryWrap.js +0 -23
- package/src/engine/graphics/geometry/clipping/ClippedGeometry.d.ts +0 -55
- package/src/engine/graphics/geometry/clipping/ClippedGeometry.d.ts.map +0 -1
- package/src/engine/graphics/geometry/clipping/ClippedGeometry.js +0 -144
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}class e{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,i){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,i){throw new Error("Not Implemented")}}class n{describeTo(t){throw new Error("Not Implemented")}}class i extends n{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class r{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class s extends e{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,i){return this.appendList(t,e,n,new r(i)),this}appendList(t,e,n,i){let r=!1;this.appendText(t);const s=i[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())r&&this.appendText(e),this.appendDescriptionOf(t.value),r=!0;return this.appendText(n),this}}class o extends s{value="";appendText(t){return this.value+=t,this}}function a(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n,i,r){let s,o,a;for(a=0;a<r;a++)s=e+a,o=i+a,n[o]=t[s]}a.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},a.notEqual=function(t,e,n){a(t!==e,n)},a.notOk=function(t,e){a(!t,e)},a.equal=function(t,e,n){if(t!==e){const i=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${i}`:i)}},a.logicalyEqual=function(t,e,n){},a.ok=a,a.greaterThan=function(t,e,n){if(!(t>e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} > ${e}.`,new Error(i)}},a.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} >= ${e}.`,new Error(i)}},a.lessThan=function(t,e,n){if(!(t<e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} < ${e}.`,new Error(i)}},a.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} <= ${e}.`,new Error(i)}},a.typeOf=function(t,e,n="value"){const i=typeof t;if(i!==e)throw new Error(`expected ${n} to be ${e}, instead was '${i}'(=${t})`)},a.arrayHas=function(t,e,n="Array does not contain the item"){},a.arrayHasNo=function(t,e,n="Array contains the item"){},a.arrayEqual=function(e,n,i="Arrays are not equal"){if(!t(e,n))throw new Error(i)},a.isInstanceOf=function(t,e,n="value",i=e.name){},a.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},a.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},a.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},a.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},a.isObject=function(t,e="value"){const n=typeof t;if("object"!==n)throw new Error(`expected ${e} to be an object, instead was '${n}'(=${t})`)},a.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},a.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},a.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},a.isArrayLike=function(t,e="value"){if(!(Array.isArray(t)||(n=t,n instanceof Int8Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int16Array||n instanceof Uint16Array||n instanceof Int32Array||n instanceof Uint32Array||n instanceof Float32Array||n instanceof Float64Array)))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`);var n},a.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},a.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},a.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},a.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},a.isFiniteNumber=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},a.that=function(t,e,n){if(n.matches(t))return;const i=new o;throw i.appendText(`Expected ${e} to be `),n.describeTo(i),i.appendText(" instead "),n.describeMismatch(t,i),new Error(i.value)};const c=new Uint32Array(781250);function d(t,e){return t<e?e:t}function u(t,e){return t<e?t:e}function l(t,e,n,i,r,s){const o=n[i+0],a=n[i+1],h=n[i+2],c=n[i+3],l=n[i+4],f=n[i+5],g=r[s+0],_=r[s+1],p=r[s+2],y=r[s+3],m=r[s+4],w=r[s+5],v=u(o,g),x=u(a,_),b=u(h,p),A=d(c,y),E=d(l,m),$=d(f,w);t[e+0]=v,t[e+1]=x,t[e+2]=b,t[e+3]=A,t[e+4]=E,t[e+5]=$}function f(t,e,n,i,r,s,o,a){t[e]=n,t[e+1]=i,t[e+2]=r,t[e+3]=s,t[e+4]=o,t[e+5]=a}function g(t,e,n,i,r,s){const o=i-t,a=s-n;return(r-e)*(o+a)+a*o}function _(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function p(t,e,n){let i=t;return i<e&&(i=e),i<n&&(i=n),i}function y(t,e,n){let i=t;return i>e&&(i=e),i>n&&(i=n),i}function m(t,e,n){const i=t[n],r=t[n+1],s=t[n+2];f(t,e,i,r,s,i,r,s)}function w(t,e,n){const i=t[e],r=t[e+1],s=t[e+2];return function(t,e,n,i){const r=i[0],s=i[1],o=i[2],a=1023*(t-r)/(i[3]-r),h=1023*(e-s)/(i[4]-s),c=1023*(n-o)/(i[5]-o);return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(a),Math.round(h),Math.round(c))}(.5*(i+t[e+3]),.5*(r+t[e+4]),.5*(s+t[e+5]),n)}c.pointer=0;const v=c;class x{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}getLeafAddress(t){return 7*t+6*this.__node_count_binary}setLeafData(t,e,n,i,r,s,o,a){const h=this.getLeafAddress(t);f(this.__data_float32,h,n,i,r,s,o,a),this.__data_uint32[h+6]=e}readBounds(t,e,n){h(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let i;i=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(i,e,0),t+=g(e[0],e[1],e[2],e[3],e[4],e[5])}return t}__compute_bounds_area_of_3_boxes(t,e,n){const i=this.__data_float32;return g(y(i[t+0],i[e+0],i[n+0]),y(i[t+1],i[e+1],i[n+1]),y(i[t+2],i[e+2],i[n+2]),p(i[t+3],i[e+3],i[n+3]),p(i[t+4],i[e+4],i[n+4]),p(i[t+5],i[e+5],i[n+5]))}__fitness_function_should_swap_leaves_sah(t,e){const n=d(t-1,0),i=u(t+1,this.__node_count_leaf-1),r=this.getLeafBlockAddress(),s=7*t+r,o=7*n+r,a=7*i+r,h=7*e+r,c=7*d(e-1,0)+r,l=7*u(e+1,this.__node_count_leaf-1)+r;return this.__compute_bounds_area_of_3_boxes(o,s,a)+this.__compute_bounds_area_of_3_boxes(c,h,l)-(this.__compute_bounds_area_of_3_boxes(o,h,a)+this.__compute_bounds_area_of_3_boxes(c,s,l))}sort_bubble_sah(){const t=this.__node_count_leaf;for(let e=0;e<t;e++)for(let n=e+1;n<t;n++)this.__fitness_function_should_swap_leaves_sah(e,n)>0&&this.__swap_leaves(e,n)}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;let n,i,r=2;v[0]=0,v[1]=this.__node_count_leaf-1;const s=this.__data_float32;for(;r>0;){r-=2;const o=v[r+1],a=v[r];n=a,i=o;const h=w(s,7*(a+o>>1)+e,t);for(;n<=i;){for(;w(s,7*n+e,t)<h;)n++;for(;w(s,7*i+e,t)>h;)i--;n<=i&&(n!==i&&this.__swap_leaves(n,i),n++,i--)}a<i&&(v[r++]=a,v[r++]=i),n<o&&(v[r++]=n,v[r++]=o)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),i=7*t+n,r=7*e+n;!function(t,e,n,i,r){for(let r=0;r<7;r++){const s=e+r,o=i+r,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,i,this.__data_float32,r)}build(){const t=this.__node_count_binary,e=6*t;let n,i,r,s,o=Math.floor(Math.log(t)/Math.log(2));r=Math.pow(2,o),i=6*(r-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<r;n++){const t=n<<1,r=t+1,s=e+7*t;r<a?l(c,i,c,s,c,e+7*r):t<a?h(c,s,c,i,6):m(this.__data_float32,i,i-6),i+=6}for(o--;o>=0;o--)for(r=1<<o,s=r-1,n=0;n<r;n++){const t=6*(1+(s<<1));l(c,6*s,c,t,c,t+6),s++}}}function b(t,e,n,i,r,s){const o=t.getLeafAddress(e);!function(t,e,n,i,r,s){const o=3*i,a=3*r,h=3*s,c=n[o],d=n[o+1],u=n[o+2],l=n[a],f=n[a+1],g=n[a+2],_=n[h],m=n[h+1],w=n[h+2];t[e]=y(c,l,_),t[e+1]=y(d,f,m),t[e+2]=y(u,g,w),t[e+3]=p(c,l,_),t[e+4]=p(d,f,m),t[e+5]=p(u,g,w)}(t.__data_float32,o,n,i,r,s),t.__data_uint32[o+6]=e}const A=[],E=[],$="undefined"!=typeof Uint8Array?Uint8Array:Array,S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)A[t]=S[t],E[S.charCodeAt(t)]=t;function U(t,e,n){const i=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);i.push(A[(r=e)>>18&63]+A[r>>12&63]+A[r>>6&63]+A[63&r])}var r;return i.join("")}E["-".charCodeAt(0)]=62,E["_".charCodeAt(0)]=63;class F{static encode(t){return function(t){let e;const n=t.length,i=n%3,r=[],s=16383,o=n-i;for(let e=0;e<o;e+=s){const n=U(t,e,e+s>o?o:e+s);r.push(n)}return 1===i?(e=t[n-1],r.push(A[e>>2]+A[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],r.push(A[e>>10]+A[e>>4&63]+A[e<<2&63]+"=")),r.join("")}(new Uint8Array(t))}static decode(t){return function(t){var e,n,i=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=i[0],s=i[1],o=new $(function(t,e,n){return 3*(e+n)/4-n}(0,r,s)),a=0,h=s>0?r-4:r;for(n=0;n<h;n+=4)e=E[t.charCodeAt(n)]<<18|E[t.charCodeAt(n+1)]<<12|E[t.charCodeAt(n+2)]<<6|E[t.charCodeAt(n+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2===s&&(e=E[t.charCodeAt(n)]<<2|E[t.charCodeAt(n+1)]>>4,o[a++]=255&e),1===s&&(e=E[t.charCodeAt(n)]<<10|E[t.charCodeAt(n+1)]<<4|E[t.charCodeAt(n+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o}(t).buffer}}const z="uint8",C="uint16",V="uint32",B="int8",q="int16",L="int32",M="float32",T="float64",I={[z]:Uint8Array,[C]:Uint16Array,[V]:Uint32Array,[B]:Int8Array,[q]:Int16Array,[L]:Int32Array,float16:Uint16Array,[M]:Float32Array,[T]:Float64Array};function N(t){switch(Object.getPrototypeOf(t).constructor){case Uint8Array:case Uint8ClampedArray:return z;case Uint16Array:return C;case Uint32Array:return V;case Int8Array:return B;case Int16Array:return q;case Int32Array:return L;case Float32Array:return M;case Float64Array:return T;default:throw new Error("unsupported constructor type")}}function O(t,e,n){return t<e?e:t>n?n:t}function k(t,e,n){return(e-t)*n+t}function j(t,e,n,i,r){return.5*(i-e+(2*e-5*n+4*i-r+(3*(n-i)+r-e)*t)*t)*t+n}class D{constructor(t=[],e=1,n=0,i=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(i)||n<0)throw new Error(`height must be a non-negative integer, instead was ${i}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*i*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*i*e}`);this.width=n,this.height=i,this.itemSize=e,this.data=t,this.version=0}get(t,e,n){throw new Error("Deprecated method, use sampleBilinear instead")}sampleCatmullRomUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelCatmullRomUV(t,e,r)}sampleChannelCatmullRomUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelCatmullRom(i,r,n)}sampleChannelCatmullRom(t,e,n){const i=Math.floor(t),r=Math.floor(e),s=t-i,o=e-r,a=s*(s*(1-.5*s)-.5),h=o*(o*(1-.5*o)-.5),c=s*(.5+s*(2-1.5*s)),d=o*(.5+o*(2-1.5*o)),u=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+c,g=1+o*o*(1.5*o-2.5)+d,_=i-1,p=r-1,y=i+2,m=r+2,w=i+c/f,v=r+d/g;let x=0;return x+=this.sampleChannelBilinear(_,p,n)*a*h,x+=this.sampleChannelBilinear(w,p,n)*f*h,x+=this.sampleChannelBilinear(y,p,n)*u*h,x+=this.sampleChannelBilinear(_,v,n)*a*g,x+=this.sampleChannelBilinear(w,v,n)*f*g,x+=this.sampleChannelBilinear(y,v,n)*u*g,x+=this.sampleChannelBilinear(_,m,n)*a*l,x+=this.sampleChannelBilinear(w,m,n)*f*l,x+=this.sampleChannelBilinear(y,m,n)*u*l,x}sampleBicubicUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelBicubicUV(t,e,r)}sampleBicubic(t,e,n,i){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const i=t*this.width,r=e*this.height;return this.sampleChannelBicubic(i-.5,r-.5,n)}sampleChannelBicubic(t,e,n){const i=this.itemSize,r=this.width,s=this.height,o=this.data,a=r*i,h=r-1,c=s-1,l=O(t,0,h),f=O(e,0,c),g=0|l,_=0|f,p=l-g,y=f-_,m=d(0,g-1),w=d(0,_-1),v=u(h,g+1),x=u(c,_+1),b=u(h,v+1),A=w*a+n,E=_*a+n,$=x*a+n,S=u(c,x+1)*a+n,U=m*i,F=g*i,z=v*i,C=b*i,V=o[A+U],B=o[A+F],q=o[A+z],L=o[A+C],M=o[E+U],T=o[E+F],I=o[E+z],N=o[E+C],k=o[$+U],D=o[$+F],R=o[$+z],J=o[$+C],P=o[S+U],H=o[S+F],W=o[S+z],G=o[S+C],Y=j(p,V,B,q,L),K=j(p,M,T,I,N),Q=j(p,k,D,R,J),X=j(p,P,H,W,G);return j(y,Y,K,Q,X)}sampleBilinearUV(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelBilinear(i,r,n)}sampleChannelBilinear(t,e,n){const i=this.itemSize,r=this.width,s=r*i,o=this.height-1,a=O(t,0,r-1),h=O(e,0,o),c=a>>>0,d=h>>>0,u=d*s,l=c*i+n,f=u+l;let g,_;g=a===c?c:c+1,_=h===d?d:d+1;const p=this.data,y=p[f];if(c===g&&d===_)return y;const m=a-c,w=h-d,v=g*i+n,x=_*s,b=x+l,A=x+v,E=p[u+v],$=p[b],S=p[A],U=k(y,E,m),F=k($,S,m);return k(U,F,w)}sampleNearestUV(t,e,n){const i=this.width,r=this.height,s=Math.round(t*i-.5),o=Math.round(e*r-.5);this.read(O(s,0,i-1),O(o,0,r-1),n)}readChannel(t,e,n){const i=(e*this.width+t)*this.itemSize+n;return this.data[i]}read(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++)n[t]=this.data[s+t]}write(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++)this.data[s+t]=n[t]}sample(t,e,n){const i=[];return this.sampleBilinear(t*(this.width-1),e*(this.height-1),i,0),n.readFromArray(i),i[0]}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,i=t%n,r=t/n|0;e.set(i,r)}copy(t,e,n,i,r,s,o){const a=Math.min(s,t.width-e,this.width-i),h=Math.min(o,t.height-n,this.height-r),c=this.itemSize,d=t.itemSize,u=Math.min(c,d),l=c*this.width,f=d*t.width,g=t.data,_=this.data;let p,y,m;for(y=0;y<h;y++){const t=(y+r)*l,s=(y+n)*f;for(p=0;p<a;p++){const n=t+(p+i)*c,r=s+(p+e)*d;for(m=0;m<u;m++)_[n+m]=g[r+m]}}this.version++}zeroFill(t,e,n,i){const r=O(t,0,this.width),s=O(e,0,this.height),o=O(t+n,0,this.width),a=O(e+i,0,this.height),h=this.data,c=this.itemSize,d=c*this.width,u=r*c,l=o*c;let f;for(f=s;f<a;f++){const t=f*d;h.fill(0,t+u,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,i=this.data,r=i.length;for(let s=t;s<r;s+=n)i[s]=e;this.version++}fill(t,e,n,i,r){const s=this.width,o=this.height,a=O(t,0,s),h=O(e,0,o),c=O(t+n,0,s),d=O(e+i,0,o),u=this.data,l=this.itemSize,f=l*s;let g,_,p;for(g=h;g<d;g++){const t=g*f;for(_=a;_<c;_++){const e=t+_*l;for(p=0;p<l;p++)u[e+p]=r[p]}}this.version++}writeChannel(t,e,n,i){const r=(e*this.width+t)*this.itemSize+n;this.data[r]=i,this.version++}set(t,e,n){const i=this.data,r=this.itemSize,s=r*this.width*e+t*r;for(let t=0;t<r;t++)i[s+t]=n[t];this.version++}traverseCircle(t,e,n,i){let r,s;const o=0|t,a=0|e,h=n*n,c=Math.ceil(n);for(s=-c;s<=c;s++){const t=s*s;for(r=-c;r<=c;r++)r*r+t<=h&&i(o+r,a+s,this)}}resize(t,e,n=!0){const i=this.width,r=this.height;if(i===t&&r===e)return;const s=this.itemSize,o=t*e*s,a=this.data,h=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===i)h.set(a.subarray(0,Math.min(a.length,o)));else{const n=u(e,r),o=u(t,i);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const r=(e*t+n)*s,o=(e*i+n)*s;for(let t=0;t<s;t++)h[r+t]=a[o+t]}}this.width=t,this.height=e,this.data=h,this.version++}computeByteSize(){let t;return t=Array.isArray(this.data)?8*this.data.length:this.data.buffer.byteLength,t+280}equals(e){return this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const i=e.length;if(i!==n.length)return!1;if(0===i)return!0;if(i<128)return t(e,n);const r=e.byteLength;if(r!==n.byteLength)return!1;const s=e.constructor;if(s!==n.constructor)return!1;const o=e.buffer,a=n.buffer;if(o===a&&e.byteOffset===n.byteOffset)return!0;let h=e,c=n;const d=s.BYTES_PER_ELEMENT;return d<4&&r%4==0?(h=new Uint32Array(o,e.byteOffset,r/4),c=new Uint32Array(a,n.byteOffset,r/4)):d<2&&r%2==0&&(h=new Uint16Array(o,e.byteOffset,r/2),c=new Uint16Array(a,n.byteOffset,r/2)),t(h,c)}(this.data,e.data)}hash(){let t=((65535&this.width)<<16|65535&this.height)^this.itemSize;const e=this.data.length,n=Math.max(1,Math.ceil(e/509));return t^=function(t,e,n,i){let r=n;for(let e=0;e<n;e+=i)r=(r<<5)-r+(t[e]>>>0);return r>>>0}(this.data,0,e,n),t}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new D(t,this.itemSize,this.width,this.height)}toJSON(){const t=F.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:N(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:i,data:r}){const s=function(t){const e=I[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(i);if("string"==typeof r){const t=F.decode(r);this.data=new s(t)}else{if(!Array.isArray(r))throw new Error("Unsupported data format");this.data=new s(r)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const i=new Uint8ClampedArray(e*n*t);return new D(i,t,e,n)}static uint8(t,e,n){const i=new Uint8Array(e*n*t);return new D(i,t,e,n)}static uint16(t,e,n){const i=new Uint16Array(e*n*t);return new D(i,t,e,n)}static uint32(t,e,n){const i=new Uint32Array(e*n*t);return new D(i,t,e,n)}static int8(t,e,n){const i=new Int8Array(e*n*t);return new D(i,t,e,n)}static int16(t,e,n){const i=new Int16Array(e*n*t);return new D(i,t,e,n)}static int32(t,e,n){const i=new Int32Array(e*n*t);return new D(i,t,e,n)}static float32(t,e,n){const i=new Float32Array(e*n*t);return new D(i,t,e,n)}static float64(t,e,n){const i=new Float64Array(e*n*t);return new D(i,t,e,n)}}function R(t,e,n,i){const r=n[i],s=n[i+1],o=n[i+2];t[e]+=r,t[e+1]+=s,t[e+2]+=o}function J(t,e,n,i,r,s,o,a,h,c,d){const u=h-s,l=c-o,f=d-a,g=n-s,_=i-o,p=r-a,y=l*p-f*_,m=f*g-u*p,w=u*_-l*g,v=function(t,e,n){return t*t+e*e+n*n}(y,m,w);if(0===v)return t[e]=0,t[e+1]=1,void(t[e+2]=0);const x=1/Math.sqrt(v),b=y*x,A=m*x,E=w*x;t[e]=b,t[e+1]=A,t[e+2]=E}function P(t,e,n,i,r,s){const o=3*n,a=3*i,h=3*r;J(t,e,s[o],s[o+1],s[o+2],s[a],s[a+1],s[a+2],s[h],s[h+1],s[h+2])}function H(t,e,n){return Math.sqrt(t*t+e*e+n*n)}function W(t,e,n,i){const r=n[i],s=n[i+1],o=n[i+2],a=1/H(r,s,o);t[e]=r*a,t[e+1]=s*a,t[e+2]=o*a}D.prototype.isSampler2D=!0,D.typeName="Sampler2D";const G=new Float64Array(3),Y={build:function(t,e,n,i,r,s){const o=n.x*s,a=n.y*s,h=o-1,c=a-1;let d=0,u=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),_=new Float32Array(2*l);let p,y;const m=n.y/r.y/c,w=n.x/r.x/h,v=e.y/r.y,x=e.x/r.x,b=r.x*i.x,A=r.y*i.y;let E,$,S;for(p=0;p<a;p++){const e=p*m+v;for(S=e*A,y=0;y<o;y++){const n=y*w+x;E=n*b,$=t.sampleChannelBicubicUV(n,e,0),f[d]=E,f[d+1]=$,f[d+2]=S,_[u]=n,_[u+1]=e,d+=3,u+=2}}d=0;const U=new(f.length/3>65535?Uint32Array:Uint16Array)(h*c*6);for(p=0;p<c;p++)for(y=0;y<h;y++){const t=y+o*p,e=y+o*(p+1),n=y+1+o*(p+1),i=y+1+o*p;U[d]=t,U[d+1]=e,U[d+2]=i,U[d+3]=e,U[d+4]=n,U[d+5]=i,d+=6}return function(t,e,n){const i=n.length;for(let r=0;r<i;r+=3){const i=n[r],s=n[r+1],o=n[r+2];P(G,0,i,s,o,t),R(e,3*i,G,0),R(e,3*s,G,0),R(e,3*o,G,0)}!function(t,e=0,n=t.length-e){const i=e+n;for(let n=e;n<i;n+=3)W(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:_}}};var K,Q="undefined"!=typeof Float32Array?Float32Array:Array;function X(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 tt(){}function et(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function nt(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}function it(t,e,n=0,i=t.length){const r=n+i;for(let i=n;i<r;i++)if(t[i]===e)return t.splice(i,1),!0;return!1}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),K=new Q(3),Q!=Float32Array&&(K[0]=0,K[1]=0,K[2]=0);let rt=0;class st{constructor(){this.index=rt++,this.v0=null,this.v1=null,this.faces=[],this.lengthSqr=-1}get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new st;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsEdge(this)||(t(`Missing back-link from face[${r}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,i=n.length;for(let t=0;t<i;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){return 1===this.faces.length}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,i=t.y,r=t.z,s=n-e.x,o=i-e.y,a=r-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,i=e.length;for(let r=0;r<i;r++){const i=e[r];i.removeEdge(t),-1===n.indexOf(i)&&(n.push(i),i.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){Z(this.faces,t)}removeFace(t){it(this.faces,t)}getOtherVertex(t){return nt(this,t)}containsVertex(t){return e=t,this.v0===e||this.v1===e;var e}containsBothVertices(t,e){return function(t,e,n){const i=t.v0,r=t.v1;return!(i!==e&&i!==n||r!==e&&r!==n)}(this,t,e)}containsSameVerticesAs(t){return this.containsBothVertices(t.v0,t.v1)}}function ot(t,e,n){const i=t.length;for(let r=0;r<i;r++)t[r]===e&&(t[r]=n)}st.prototype.isTopoEdge=!0;let at=0;class ht{constructor(){this.index=at++,this.vertices=[],this.edges=[],this.normal=[0,0,0]}get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),X(this.normal,t.normal)}clone(){const t=new ht;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,i=n.length;3!==i&&(t(`Expected number of vertices is 3, instead got ${i}`),e=!1);for(let r=0;r<i;r++)n[r].containsFace(this)||(t(`Missing back-link from vertex[${r}]`),e=!1);const r=this.edges,s=r.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)r[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){ot(this.edges,t,e)}replaceVertex(t,e){ot(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],i=t[2];return e===n||e===i||n===i}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,i=n.length;for(let t=0;t<i;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return Z(this.edges,t)}removeEdge(t){it(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],i=t[2];!function(t,e,n,i){J(t,0,e[0],e[1],e[2],n[0],n[1],n[2],i[0],i[1],i[2])}(this.normal,e,n,i)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].faces,o=r.length;for(let i=0;i<o;i++){const s=r[i];s!==this&&(t[e+n]=s,n++)}}return n}}ht.prototype.isTopoFace=!0;class ct{constructor(){this.index=0,this.edges=[],this.faces=[],this.x=0,this.y=0,this.z=0}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new ct;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsVertex(this)||(t(`Missing back-link from face[${r}]`),e=!1);const r=this.edges,s=r.length;for(let n=0;n<s;n++)r[n].containsVertex(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,i=this.z,H(t.x-e,t.y-n,t.z-i);var e,n,i}addFace(t){this.faces.push(t)}addUniqueFace(t){return Z(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){it(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return Z(this.edges,t)}replaceEdge(t,e){const n=this.edges,i=n.indexOf(t);n[i]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return it(this.edges,t)}replaceAnotherVertex(t){const e=t.faces,n=e.length;let i=0;for(;i<n;i++){const n=e[i];n.replaceVertex(t,this),this.addUniqueFace(n)}const r=t.edges,s=r.length;for(i=0;i<s;i++){const e=r[i];e.replaceVertex(t,this),this.addUniqueEdge(e)}}computeNeighbourVertices(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].getOtherVertex(this);t[e+n]=r,n++}return n}}ct.prototype.isTopoVertex=!0;class dt{constructor(){this.vertices=[],this.__edges=new Set,this.__faces=new Set}get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t=tt){let e=!0,n="",i=0;function r(r){t(`${n}[${i}]: ${r}`),e=!1}n="Edge",i=0;const s=this.getEdges();for(let t of s){t.validate(r),this.containsVertex(t.v0)||r("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||r("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||r(`Link to off-mesh face[${t}]`)}i++}const o=this.getFaces();n="Face",i=0;for(let t of o){t.validate(r);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||r(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||r(`Link to off-mesh vertex[${t}]`)}i++}const a=this.vertices,h=a.length;n="Vertex";for(let t=0;t<h;t++){i=t;const e=a[t];e.validate(r);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||r(`Link to off-mesh edge[${t}]`)}const o=e.faces,h=o.length;for(let t=0;t<h;t++){const e=o[t];this.containsFace(e)||r(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new dt;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let i=0;i<n;i++){const n=e[i];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new ht;X(n.normal,t.normal);const i=t.vertices;for(let t=0;t<3;t++){const r=i[t];let s=e.get(r.index);void 0===s&&(s=new ct,s.index=r.index,s.x=r.x,s.y=r.y,s.z=r.z,e.set(r.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n),this.patchFaceEdges(n)}patchFaceEdges(t){const e=t.vertices,n=e[0],i=e[1],r=e[2],s=this.ensureEdge(n,i),o=this.ensureEdge(i,r),a=this.ensureEdge(r,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,it(this.vertices,e)}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){var e;e=t,this.__edges.delete(e)}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const i=t.vertices,r=i.length;for(let t=0;t<r;t++){const e=i[t];this.addUniqueVertex(e)}}removeFace(t){var e;e=t,this.__faces.delete(e)}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,i=n.length;for(let r=0;r<i;r++){const i=n[r];if(nt(i,t)===e)return i}const r=new st;return r.v0=t,r.v1=e,t.edges.push(r),e.edges.push(r),this.__edges.add(r),r}mergeEdges(){const t=this.getEdges();for(let e of t){const n=e.v0,i=e.v1;for(let r of t){if(e===r)continue;const t=r.v0,s=r.v1;if(n===t){if(i!==s)continue}else{if(n!==s)continue;if(i!==t)continue}this.removeEdge(r),e.merge(r)}}}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}build(t,e){const n=e.length,i=t.length/3,r=this.vertices;for(let e=0;e<i;e++){const n=3*e,i=new ct;i.index=e,i.x=t[n],i.y=t[n+1],i.z=t[n+2],r[e]=i}const s=n/3,o=this.getFaces();for(let t=0;t<s;t++){const n=3*t,i=e[n],s=e[n+1],a=e[n+2],h=r[i],c=r[s],d=r[a],u=new ht;u.index=t;const l=this.ensureEdge(h,c),f=this.ensureEdge(c,d),g=this.ensureEdge(d,h);l.faces.push(u),f.faces.push(u),g.faces.push(u),u.vertices.push(h,c,d),u.edges.push(l,f,g),h.faces.push(u),c.faces.push(u),d.faces.push(u),o.add(u)}}toString(){return`TopoMesh{ vertices: ${et(this.vertices.length)}, edges: ${et(this.getEdges().size)}, faces: ${et(this.getFaces().size)} }`}}dt.prototype.isTopoMesh=!0,self.Lib={build_bvh(t,e){const n=new x;return function(t,e,n){const i=n.length/3;t.setLeafCount(i),t.initialize_structure();for(let r=0;r<i;r++){const i=3*r;b(t,r,e,n[i],n[i+1],n[i+2])}t.build()}(n,t,e),n},Sampler2D:D,BufferedGeometryArraysBuilder:Y,tensionOptimizeUV:function(t,e,n,i){const r=new dt;r.build(t,n),r.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<i;t++)t:for(let t=0;t<s;t++){const n=r.vertices[t],i=n.edges,s=i.length;if(0===s)continue;let o=0,a=0,h=0;for(let t=0;t<s;t++){const r=i[t];if(r.isTopologyBorder())continue t;const s=2*r.getOtherVertex(n).index,c=e[s],d=e[s+1],u=1/r.lengthSqr;o+=c*u,a+=d*u,h+=u}const c=o/h,d=a/h,u=2*n.index;e[u]=c,e[u+1]=d}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s>e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s<e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}}};
|
|
1
|
+
function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}class e{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,i){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,i){throw new Error("Not Implemented")}}class n{describeTo(t){throw new Error("Not Implemented")}}class i extends n{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class r{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class s extends e{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,i){return this.appendList(t,e,n,new r(i)),this}appendList(t,e,n,i){let r=!1;this.appendText(t);const s=i[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())r&&this.appendText(e),this.appendDescriptionOf(t.value),r=!0;return this.appendText(n),this}}class o extends s{value="";appendText(t){return this.value+=t,this}}function a(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n,i,r){let s,o,a;for(a=0;a<r;a++)s=e+a,o=i+a,n[o]=t[s]}a.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},a.notEqual=function(t,e,n){a(t!==e,n)},a.notOk=function(t,e){a(!t,e)},a.equal=function(t,e,n){if(t!==e){const i=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${i}`:i)}},a.logicalyEqual=function(t,e,n){},a.ok=a,a.greaterThan=function(t,e,n){if(!(t>e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} > ${e}.`,new Error(i)}},a.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} >= ${e}.`,new Error(i)}},a.lessThan=function(t,e,n){if(!(t<e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} < ${e}.`,new Error(i)}},a.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let i="";throw void 0!==n&&(i+=n+". "),i+=`Expected ${t} <= ${e}.`,new Error(i)}},a.typeOf=function(t,e,n="value"){const i=typeof t;if(i!==e)throw new Error(`expected ${n} to be ${e}, instead was '${i}'(=${t})`)},a.arrayHas=function(t,e,n="Array does not contain the item"){},a.arrayHasNo=function(t,e,n="Array contains the item"){},a.arrayEqual=function(e,n,i="Arrays are not equal"){if(!t(e,n))throw new Error(i)},a.isInstanceOf=function(t,e,n="value",i=e.name){},a.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},a.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},a.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},a.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},a.isObject=function(t,e="value"){const n=typeof t;if("object"!==n)throw new Error(`expected ${e} to be an object, instead was '${n}'(=${t})`)},a.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},a.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},a.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},a.isArrayLike=function(t,e="value"){if(!(Array.isArray(t)||(n=t,n instanceof Int8Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int16Array||n instanceof Uint16Array||n instanceof Int32Array||n instanceof Uint32Array||n instanceof Float32Array||n instanceof Float64Array)))throw new Error(`expected ${e} to be an array-like structure, instead was something else (typeof ='${typeof t}')`);var n},a.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},a.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},a.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},a.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},a.isFiniteNumber=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},a.that=function(t,e,n){if(n.matches(t))return;const i=new o;throw i.appendText(`Expected ${e} to be `),n.describeTo(i),i.appendText(" instead "),n.describeMismatch(t,i),new Error(i.value)};const c=new Uint32Array(781250);function d(t,e){return t<e?e:t}function u(t,e){return t<e?t:e}function l(t,e,n,i,r,s){const o=n[i+0],a=n[i+1],h=n[i+2],c=n[i+3],l=n[i+4],f=n[i+5],g=r[s+0],_=r[s+1],p=r[s+2],y=r[s+3],m=r[s+4],w=r[s+5],v=u(o,g),x=u(a,_),b=u(h,p),A=d(c,y),E=d(l,m),$=d(f,w);t[e+0]=v,t[e+1]=x,t[e+2]=b,t[e+3]=A,t[e+4]=E,t[e+5]=$}function f(t,e,n,i,r,s,o,a){t[e]=n,t[e+1]=i,t[e+2]=r,t[e+3]=s,t[e+4]=o,t[e+5]=a}function g(t,e,n,i,r,s){const o=i-t,a=s-n;return(r-e)*(o+a)+a*o}function _(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function p(t,e,n){let i=t;return i<e&&(i=e),i<n&&(i=n),i}function y(t,e,n){let i=t;return i>e&&(i=e),i>n&&(i=n),i}function m(t,e,n){const i=t[n],r=t[n+1],s=t[n+2];f(t,e,i,r,s,i,r,s)}function w(t,e,n){const i=t[e],r=t[e+1],s=t[e+2];return function(t,e,n,i){const r=i[0],s=i[1],o=i[2],a=1023*(t-r)/(i[3]-r),h=1023*(e-s)/(i[4]-s),c=1023*(n-o)/(i[5]-o);return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(a),Math.round(h),Math.round(c))}(.5*(i+t[e+3]),.5*(r+t[e+4]),.5*(s+t[e+5]),n)}c.pointer=0;const v=c;class x{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}getLeafAddress(t){return 7*t+6*this.__node_count_binary}setLeafData(t,e,n,i,r,s,o,a){const h=this.getLeafAddress(t);f(this.__data_float32,h,n,i,r,s,o,a),this.__data_uint32[h+6]=e}readBounds(t,e,n){h(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let i;i=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(i,e,0),t+=g(e[0],e[1],e[2],e[3],e[4],e[5])}return t}__compute_bounds_area_of_3_boxes(t,e,n){const i=this.__data_float32;return g(y(i[t+0],i[e+0],i[n+0]),y(i[t+1],i[e+1],i[n+1]),y(i[t+2],i[e+2],i[n+2]),p(i[t+3],i[e+3],i[n+3]),p(i[t+4],i[e+4],i[n+4]),p(i[t+5],i[e+5],i[n+5]))}__fitness_function_should_swap_leaves_sah(t,e){const n=d(t-1,0),i=u(t+1,this.__node_count_leaf-1),r=this.getLeafBlockAddress(),s=7*t+r,o=7*n+r,a=7*i+r,h=7*e+r,c=7*d(e-1,0)+r,l=7*u(e+1,this.__node_count_leaf-1)+r;return this.__compute_bounds_area_of_3_boxes(o,s,a)+this.__compute_bounds_area_of_3_boxes(c,h,l)-(this.__compute_bounds_area_of_3_boxes(o,h,a)+this.__compute_bounds_area_of_3_boxes(c,s,l))}sort_bubble_sah(){const t=this.__node_count_leaf;for(let e=0;e<t;e++)for(let n=e+1;n<t;n++)this.__fitness_function_should_swap_leaves_sah(e,n)>0&&this.__swap_leaves(e,n)}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;let n,i,r=2;v[0]=0,v[1]=this.__node_count_leaf-1;const s=this.__data_float32;for(;r>0;){r-=2;const o=v[r+1],a=v[r];n=a,i=o;const h=w(s,7*(a+o>>1)+e,t);for(;n<=i;){for(;w(s,7*n+e,t)<h;)n++;for(;w(s,7*i+e,t)>h;)i--;n<=i&&(n!==i&&this.__swap_leaves(n,i),n++,i--)}a<i&&(v[r++]=a,v[r++]=i),n<o&&(v[r++]=n,v[r++]=o)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),i=7*t+n,r=7*e+n;!function(t,e,n,i,r){for(let r=0;r<7;r++){const s=e+r,o=i+r,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,i,this.__data_float32,r)}build(){const t=this.__node_count_binary,e=6*t;let n,i,r,s,o=Math.floor(Math.log(t)/Math.log(2));r=Math.pow(2,o),i=6*(r-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<r;n++){const t=n<<1,r=t+1,s=e+7*t;r<a?l(c,i,c,s,c,e+7*r):t<a?h(c,s,c,i,6):m(this.__data_float32,i,i-6),i+=6}for(o--;o>=0;o--)for(r=1<<o,s=r-1,n=0;n<r;n++){const t=6*(1+(s<<1));l(c,6*s,c,t,c,t+6),s++}}}function b(t,e,n,i,r,s){const o=t.getLeafAddress(e);!function(t,e,n,i,r,s){const o=3*i,a=3*r,h=3*s,c=n[o],d=n[o+1],u=n[o+2],l=n[a],f=n[a+1],g=n[a+2],_=n[h],m=n[h+1],w=n[h+2];t[e]=y(c,l,_),t[e+1]=y(d,f,m),t[e+2]=y(u,g,w),t[e+3]=p(c,l,_),t[e+4]=p(d,f,m),t[e+5]=p(u,g,w)}(t.__data_float32,o,n,i,r,s),t.__data_uint32[o+6]=e}function A(t){return 1===t.faces.length}function E(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}var $,S="undefined"!=typeof Float32Array?Float32Array:Array;function U(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function F(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function z(){}function C(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function V(t,e,n=0,i=t.length){const r=n+i;for(let i=n;i<r;i++)if(t[i]===e)return t.splice(i,1),!0;return!1}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),$=new S(3),S!=Float32Array&&($[0]=0,$[1]=0,$[2]=0);let B=0;class q{constructor(){this.index=B++,this.v0=null,this.v1=null,this.faces=[],this.lengthSqr=-1}get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new q;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsEdge(this)||(t(`Missing back-link from face[${r}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,i=n.length;for(let t=0;t<i;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){return A(this)}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,i=t.y,r=t.z,s=n-e.x,o=i-e.y,a=r-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,i=e.length;for(let r=0;r<i;r++){const i=e[r];i.removeEdge(t),-1===n.indexOf(i)&&(n.push(i),i.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){F(this.faces,t)}removeFace(t){V(this.faces,t)}getOtherVertex(t){return E(this,t)}containsVertex(t){return e=t,this.v0===e||this.v1===e;var e}containsBothVertices(t,e){return function(t,e,n){const i=t.v0,r=t.v1;return!(i!==e&&i!==n||r!==e&&r!==n)}(this,t,e)}containsSameVerticesAs(t){return this.containsBothVertices(t.v0,t.v1)}}function L(t,e,n){const i=t.length;for(let r=0;r<i;r++)t[r]===e&&(t[r]=n)}function M(t,e,n,i,r,s,o,a,h,c,d){const u=h-s,l=c-o,f=d-a,g=n-s,_=i-o,p=r-a,y=l*p-f*_,m=f*g-u*p,w=u*_-l*g,v=function(t,e,n){return t*t+e*e+n*n}(y,m,w);if(0===v)return t[e]=0,t[e+1]=1,void(t[e+2]=0);const x=1/Math.sqrt(v),b=y*x,A=m*x,E=w*x;t[e]=b,t[e+1]=A,t[e+2]=E}q.prototype.isTopoEdge=!0;let T=0;class I{constructor(){this.index=T++,this.vertices=[],this.edges=[],this.normal=[0,0,0]}get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),U(this.normal,t.normal)}clone(){const t=new I;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,i=n.length;3!==i&&(t(`Expected number of vertices is 3, instead got ${i}`),e=!1);for(let r=0;r<i;r++)n[r].containsFace(this)||(t(`Missing back-link from vertex[${r}]`),e=!1);const r=this.edges,s=r.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)r[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){L(this.edges,t,e)}replaceVertex(t,e){L(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],i=t[2];return e===n||e===i||n===i}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,i=n.length;for(let t=0;t<i;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return F(this.edges,t)}removeEdge(t){V(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],i=t[2];!function(t,e,n,i){M(t,0,e[0],e[1],e[2],n[0],n[1],n[2],i[0],i[1],i[2])}(this.normal,e,n,i)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].faces,o=r.length;for(let i=0;i<o;i++){const s=r[i];s!==this&&(t[e+n]=s,n++)}}return n}}function N(t,e,n){return Math.sqrt(t*t+e*e+n*n)}I.prototype.isTopoFace=!0;class k{constructor(){this.index=0,this.edges=[],this.faces=[],this.x=0,this.y=0,this.z=0}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new k;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,i=n.length;for(let r=0;r<i;r++)n[r].containsVertex(this)||(t(`Missing back-link from face[${r}]`),e=!1);const r=this.edges,s=r.length;for(let n=0;n<s;n++)r[n].containsVertex(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,i=this.z,N(t.x-e,t.y-n,t.z-i);var e,n,i}addFace(t){this.faces.push(t)}addUniqueFace(t){return F(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){V(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return F(this.edges,t)}replaceEdge(t,e){const n=this.edges,i=n.indexOf(t);n[i]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return V(this.edges,t)}replaceAnotherVertex(t){const e=t.faces,n=e.length;let i=0;for(;i<n;i++){const n=e[i];n.replaceVertex(t,this),this.addUniqueFace(n)}const r=t.edges,s=r.length;for(i=0;i<s;i++){const e=r[i];e.replaceVertex(t,this),this.addUniqueEdge(e)}}computeNeighbourVertices(t,e){let n=0;const i=this.edges,r=i.length;for(let s=0;s<r;s++){const r=i[s].getOtherVertex(this);t[e+n]=r,n++}return n}}k.prototype.isTopoVertex=!0;class O{constructor(){this.vertices=[],this.__edges=new Set,this.__faces=new Set}get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t=z){let e=!0,n="",i=0;function r(r){t(`${n}[${i}]: ${r}`),e=!1}n="Edge",i=0;const s=this.getEdges();for(let t of s){t.validate(r),this.containsVertex(t.v0)||r("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||r("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||r(`Link to off-mesh face[${t}]`)}i++}const o=this.getFaces();n="Face",i=0;for(let t of o){t.validate(r);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||r(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||r(`Link to off-mesh vertex[${t}]`)}i++}const a=this.vertices,h=a.length;n="Vertex";for(let t=0;t<h;t++){i=t;const e=a[t];e.validate(r);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||r(`Link to off-mesh edge[${t}]`)}const o=e.faces,h=o.length;for(let t=0;t<h;t++){const e=o[t];this.containsFace(e)||r(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new O;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let i=0;i<n;i++){const n=e[i];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new I;U(n.normal,t.normal);const i=t.vertices;for(let t=0;t<3;t++){const r=i[t];let s=e.get(r.index);void 0===s&&(s=new k,s.index=r.index,s.x=r.x,s.y=r.y,s.z=r.z,e.set(r.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n),this.patchFaceEdges(n)}patchFaceEdges(t){const e=t.vertices,n=e[0],i=e[1],r=e[2],s=this.ensureEdge(n,i),o=this.ensureEdge(i,r),a=this.ensureEdge(r,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){F(this.vertices,t)}removeVertex(t){var e;e=t,V(this.vertices,e)}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){var e;e=t,this.__edges.delete(e)}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const i=t.vertices,r=i.length;for(let t=0;t<r;t++){const e=i[t];this.addUniqueVertex(e)}}removeFace(t){var e;e=t,this.__faces.delete(e)}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,i=n.length;for(let r=0;r<i;r++){const i=n[r];if(E(i,t)===e)return i}const r=new q;return r.v0=t,r.v1=e,t.edges.push(r),e.edges.push(r),this.__edges.add(r),r}mergeEdges(){const t=this.getEdges();for(let e of t){const n=e.v0,i=e.v1;for(let r of t){if(e===r)continue;const t=r.v0,s=r.v1;if(n===t){if(i!==s)continue}else{if(n!==s)continue;if(i!==t)continue}this.removeEdge(r),e.merge(r)}}}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}build(t,e){const n=e.length,i=t.length/3,r=this.vertices;for(let e=0;e<i;e++){const n=3*e,i=new k;i.index=e,i.x=t[n],i.y=t[n+1],i.z=t[n+2],r[e]=i}const s=n/3,o=this.getFaces();for(let t=0;t<s;t++){const n=3*t,i=e[n],s=e[n+1],a=e[n+2],h=r[i],c=r[s],d=r[a],u=new I;u.index=t;const l=this.ensureEdge(h,c),f=this.ensureEdge(c,d),g=this.ensureEdge(d,h);l.faces.push(u),f.faces.push(u),g.faces.push(u),u.vertices.push(h,c,d),u.edges.push(l,f,g),h.faces.push(u),c.faces.push(u),d.faces.push(u),o.add(u)}}toString(){return`TopoMesh{ vertices: ${C(this.vertices.length)}, edges: ${C(this.getEdges().size)}, faces: ${C(this.getFaces().size)} }`}}O.prototype.isTopoMesh=!0;const j=[],D=[],R="undefined"!=typeof Uint8Array?Uint8Array:Array,J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)j[t]=J[t],D[J.charCodeAt(t)]=t;function P(t,e,n){const i=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);i.push(j[(r=e)>>18&63]+j[r>>12&63]+j[r>>6&63]+j[63&r])}var r;return i.join("")}D["-".charCodeAt(0)]=62,D["_".charCodeAt(0)]=63;class H{static encode(t){return function(t){let e;const n=t.length,i=n%3,r=[],s=16383,o=n-i;for(let e=0;e<o;e+=s){const n=P(t,e,e+s>o?o:e+s);r.push(n)}return 1===i?(e=t[n-1],r.push(j[e>>2]+j[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],r.push(j[e>>10]+j[e>>4&63]+j[e<<2&63]+"=")),r.join("")}(new Uint8Array(t))}static decode(t){return function(t){var e,n,i=function(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=i[0],s=i[1],o=new R(function(t,e,n){return 3*(e+n)/4-n}(0,r,s)),a=0,h=s>0?r-4:r;for(n=0;n<h;n+=4)e=D[t.charCodeAt(n)]<<18|D[t.charCodeAt(n+1)]<<12|D[t.charCodeAt(n+2)]<<6|D[t.charCodeAt(n+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2===s&&(e=D[t.charCodeAt(n)]<<2|D[t.charCodeAt(n+1)]>>4,o[a++]=255&e),1===s&&(e=D[t.charCodeAt(n)]<<10|D[t.charCodeAt(n+1)]<<4|D[t.charCodeAt(n+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o}(t).buffer}}const W="uint8",G="uint16",Y="uint32",K="int8",Q="int16",X="int32",Z="float32",tt="float64",et={[W]:Uint8Array,[G]:Uint16Array,[Y]:Uint32Array,[K]:Int8Array,[Q]:Int16Array,[X]:Int32Array,float16:Uint16Array,[Z]:Float32Array,[tt]:Float64Array};function nt(t){switch(Object.getPrototypeOf(t).constructor){case Uint8Array:case Uint8ClampedArray:return W;case Uint16Array:return G;case Uint32Array:return Y;case Int8Array:return K;case Int16Array:return Q;case Int32Array:return X;case Float32Array:return Z;case Float64Array:return tt;default:throw new Error("unsupported constructor type")}}function it(t,e,n){return t<e?e:t>n?n:t}function rt(t,e,n){return(e-t)*n+t}function st(t,e,n,i,r){return.5*(i-e+(2*e-5*n+4*i-r+(3*(n-i)+r-e)*t)*t)*t+n}class ot{constructor(t=[],e=1,n=0,i=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(i)||n<0)throw new Error(`height must be a non-negative integer, instead was ${i}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*i*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*i*e}`);this.width=n,this.height=i,this.itemSize=e,this.data=t,this.version=0}get(t,e,n){throw new Error("Deprecated method, use sampleBilinear instead")}sampleCatmullRomUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelCatmullRomUV(t,e,r)}sampleChannelCatmullRomUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelCatmullRom(i,r,n)}sampleChannelCatmullRom(t,e,n){const i=Math.floor(t),r=Math.floor(e),s=t-i,o=e-r,a=s*(s*(1-.5*s)-.5),h=o*(o*(1-.5*o)-.5),c=s*(.5+s*(2-1.5*s)),d=o*(.5+o*(2-1.5*o)),u=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+c,g=1+o*o*(1.5*o-2.5)+d,_=i-1,p=r-1,y=i+2,m=r+2,w=i+c/f,v=r+d/g;let x=0;return x+=this.sampleChannelBilinear(_,p,n)*a*h,x+=this.sampleChannelBilinear(w,p,n)*f*h,x+=this.sampleChannelBilinear(y,p,n)*u*h,x+=this.sampleChannelBilinear(_,v,n)*a*g,x+=this.sampleChannelBilinear(w,v,n)*f*g,x+=this.sampleChannelBilinear(y,v,n)*u*g,x+=this.sampleChannelBilinear(_,m,n)*a*l,x+=this.sampleChannelBilinear(w,m,n)*f*l,x+=this.sampleChannelBilinear(y,m,n)*u*l,x}sampleBicubicUV(t,e,n){const i=this.itemSize;for(let r=0;r<i;r++)n[r]=this.sampleChannelBicubicUV(t,e,r)}sampleBicubic(t,e,n,i){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const i=t*this.width,r=e*this.height;return this.sampleChannelBicubic(i-.5,r-.5,n)}sampleChannelBicubic(t,e,n){const i=this.itemSize,r=this.width,s=this.height,o=this.data,a=r*i,h=r-1,c=s-1,l=it(t,0,h),f=it(e,0,c),g=0|l,_=0|f,p=l-g,y=f-_,m=d(0,g-1),w=d(0,_-1),v=u(h,g+1),x=u(c,_+1),b=u(h,v+1),A=w*a+n,E=_*a+n,$=x*a+n,S=u(c,x+1)*a+n,U=m*i,F=g*i,z=v*i,C=b*i,V=o[A+U],B=o[A+F],q=o[A+z],L=o[A+C],M=o[E+U],T=o[E+F],I=o[E+z],N=o[E+C],k=o[$+U],O=o[$+F],j=o[$+z],D=o[$+C],R=o[S+U],J=o[S+F],P=o[S+z],H=o[S+C],W=st(p,V,B,q,L),G=st(p,M,T,I,N),Y=st(p,k,O,j,D),K=st(p,R,J,P,H);return st(y,W,G,Y,K)}sampleBilinearUV(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,i=0){const r=this.itemSize;for(let s=0;s<r;s++)n[s+i]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const i=t*this.width-.5,r=e*this.height-.5;return this.sampleChannelBilinear(i,r,n)}sampleChannelBilinear(t,e,n){const i=this.itemSize,r=this.width,s=r*i,o=this.height-1,a=it(t,0,r-1),h=it(e,0,o),c=a>>>0,d=h>>>0,u=d*s,l=c*i+n,f=u+l;let g,_;g=a===c?c:c+1,_=h===d?d:d+1;const p=this.data,y=p[f];if(c===g&&d===_)return y;const m=a-c,w=h-d,v=g*i+n,x=_*s,b=x+l,A=x+v,E=p[u+v],$=p[b],S=p[A],U=rt(y,E,m),F=rt($,S,m);return rt(U,F,w)}sampleNearestUV(t,e,n){const i=this.width,r=this.height,s=Math.round(t*i-.5),o=Math.round(e*r-.5);this.read(it(s,0,i-1),it(o,0,r-1),n)}readChannel(t,e,n){const i=(e*this.width+t)*this.itemSize+n;return this.data[i]}read(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++)n[t]=this.data[s+t]}write(t,e,n){const i=this.width,r=this.itemSize,s=(e*i+t)*r;for(let t=0;t<r;t++)this.data[s+t]=n[t]}sample(t,e,n){const i=[];return this.sampleBilinear(t*(this.width-1),e*(this.height-1),i,0),n.readFromArray(i),i[0]}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,i=t%n,r=t/n|0;e.set(i,r)}copy(t,e,n,i,r,s,o){const a=Math.min(s,t.width-e,this.width-i),h=Math.min(o,t.height-n,this.height-r),c=this.itemSize,d=t.itemSize,u=Math.min(c,d),l=c*this.width,f=d*t.width,g=t.data,_=this.data;let p,y,m;for(y=0;y<h;y++){const t=(y+r)*l,s=(y+n)*f;for(p=0;p<a;p++){const n=t+(p+i)*c,r=s+(p+e)*d;for(m=0;m<u;m++)_[n+m]=g[r+m]}}this.version++}zeroFill(t,e,n,i){const r=it(t,0,this.width),s=it(e,0,this.height),o=it(t+n,0,this.width),a=it(e+i,0,this.height),h=this.data,c=this.itemSize,d=c*this.width,u=r*c,l=o*c;let f;for(f=s;f<a;f++){const t=f*d;h.fill(0,t+u,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,i=this.data,r=i.length;for(let s=t;s<r;s+=n)i[s]=e;this.version++}fill(t,e,n,i,r){const s=this.width,o=this.height,a=it(t,0,s),h=it(e,0,o),c=it(t+n,0,s),d=it(e+i,0,o),u=this.data,l=this.itemSize,f=l*s;let g,_,p;for(g=h;g<d;g++){const t=g*f;for(_=a;_<c;_++){const e=t+_*l;for(p=0;p<l;p++)u[e+p]=r[p]}}this.version++}writeChannel(t,e,n,i){const r=(e*this.width+t)*this.itemSize+n;this.data[r]=i,this.version++}set(t,e,n){const i=this.data,r=this.itemSize,s=r*this.width*e+t*r;for(let t=0;t<r;t++)i[s+t]=n[t];this.version++}traverseCircle(t,e,n,i){let r,s;const o=0|t,a=0|e,h=n*n,c=Math.ceil(n);for(s=-c;s<=c;s++){const t=s*s;for(r=-c;r<=c;r++)r*r+t<=h&&i(o+r,a+s,this)}}resize(t,e,n=!0){const i=this.width,r=this.height;if(i===t&&r===e)return;const s=this.itemSize,o=t*e*s,a=this.data,h=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===i)h.set(a.subarray(0,Math.min(a.length,o)));else{const n=u(e,r),o=u(t,i);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const r=(e*t+n)*s,o=(e*i+n)*s;for(let t=0;t<s;t++)h[r+t]=a[o+t]}}this.width=t,this.height=e,this.data=h,this.version++}computeByteSize(){let t;return t=Array.isArray(this.data)?8*this.data.length:this.data.buffer.byteLength,t+280}equals(e){return this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const i=e.length;if(i!==n.length)return!1;if(0===i)return!0;if(i<128)return t(e,n);const r=e.byteLength;if(r!==n.byteLength)return!1;const s=e.constructor;if(s!==n.constructor)return!1;const o=e.buffer,a=n.buffer;if(o===a&&e.byteOffset===n.byteOffset)return!0;let h=e,c=n;const d=s.BYTES_PER_ELEMENT;return d<4&&r%4==0?(h=new Uint32Array(o,e.byteOffset,r/4),c=new Uint32Array(a,n.byteOffset,r/4)):d<2&&r%2==0&&(h=new Uint16Array(o,e.byteOffset,r/2),c=new Uint16Array(a,n.byteOffset,r/2)),t(h,c)}(this.data,e.data)}hash(){let t=((65535&this.width)<<16|65535&this.height)^this.itemSize;const e=this.data.length,n=Math.max(1,Math.ceil(e/509));return t^=function(t,e,n,i){let r=n;for(let e=0;e<n;e+=i)r=(r<<5)-r+(t[e]>>>0);return r>>>0}(this.data,0,e,n),t}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new ot(t,this.itemSize,this.width,this.height)}toJSON(){const t=H.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:nt(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:i,data:r}){const s=function(t){const e=et[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(i);if("string"==typeof r){const t=H.decode(r);this.data=new s(t)}else{if(!Array.isArray(r))throw new Error("Unsupported data format");this.data=new s(r)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const i=new Uint8ClampedArray(e*n*t);return new ot(i,t,e,n)}static uint8(t,e,n){const i=new Uint8Array(e*n*t);return new ot(i,t,e,n)}static uint16(t,e,n){const i=new Uint16Array(e*n*t);return new ot(i,t,e,n)}static uint32(t,e,n){const i=new Uint32Array(e*n*t);return new ot(i,t,e,n)}static int8(t,e,n){const i=new Int8Array(e*n*t);return new ot(i,t,e,n)}static int16(t,e,n){const i=new Int16Array(e*n*t);return new ot(i,t,e,n)}static int32(t,e,n){const i=new Int32Array(e*n*t);return new ot(i,t,e,n)}static float32(t,e,n){const i=new Float32Array(e*n*t);return new ot(i,t,e,n)}static float64(t,e,n){const i=new Float64Array(e*n*t);return new ot(i,t,e,n)}}function at(t,e,n,i){const r=n[i],s=n[i+1],o=n[i+2];t[e]+=r,t[e+1]+=s,t[e+2]+=o}function ht(t,e,n,i,r,s){const o=3*n,a=3*i,h=3*r;M(t,e,s[o],s[o+1],s[o+2],s[a],s[a+1],s[a+2],s[h],s[h+1],s[h+2])}function ct(t,e,n,i){const r=n[i],s=n[i+1],o=n[i+2],a=1/N(r,s,o);t[e]=r*a,t[e+1]=s*a,t[e+2]=o*a}ot.prototype.isSampler2D=!0,ot.typeName="Sampler2D";const dt=new Float64Array(3),ut={build:function(t,e,n,i,r,s){const o=n.x*s,a=n.y*s,h=o-1,c=a-1;let d=0,u=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),_=new Float32Array(2*l);let p,y;const m=n.y/r.y/c,w=n.x/r.x/h,v=e.y/r.y,x=e.x/r.x,b=r.x*i.x,A=r.y*i.y;let E,$,S;for(p=0;p<a;p++){const e=p*m+v;for(S=e*A,y=0;y<o;y++){const n=y*w+x;E=n*b,$=t.sampleChannelBicubicUV(n,e,0),f[d]=E,f[d+1]=$,f[d+2]=S,_[u]=n,_[u+1]=e,d+=3,u+=2}}d=0;const U=new(f.length/3>65535?Uint32Array:Uint16Array)(h*c*6);for(p=0;p<c;p++)for(y=0;y<h;y++){const t=y+o*p,e=y+o*(p+1),n=y+1+o*(p+1),i=y+1+o*p;U[d]=t,U[d+1]=e,U[d+2]=i,U[d+3]=e,U[d+4]=n,U[d+5]=i,d+=6}return function(t,e,n){const i=n.length;for(let r=0;r<i;r+=3){const i=n[r],s=n[r+1],o=n[r+2];ht(dt,0,i,s,o,t),at(e,3*i,dt,0),at(e,3*s,dt,0),at(e,3*o,dt,0)}!function(t,e=0,n=t.length-e){const i=e+n;for(let n=e;n<i;n+=3)ct(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:_}}};self.Lib={build_bvh(t,e){const n=new x;return function(t,e,n){const i=n.length/3;t.setLeafCount(i),t.initialize_structure();for(let r=0;r<i;r++){const i=3*r;b(t,r,e,n[i],n[i+1],n[i+2])}t.build()}(n,t,e),n},Sampler2D:ot,BufferedGeometryArraysBuilder:ut,tensionOptimizeUV:function(t,e,n,i=3){const r=new O;r.build(t,n),r.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<i;t++)t:for(let t=0;t<s;t++){const n=r.vertices[t],i=n.edges,s=i.length;if(0===s)continue;let o=0,a=0,h=0;for(let t=0;t<s;t++){const r=i[t];if(A(r))continue t;const s=2*E(r,n).index,c=e[s],d=e[s+1],u=1/r.lengthSqr;o+=c*u,a+=d*u,h+=u}const c=o/h,d=a/h,u=2*n.index;e[u]=c,e[u+1]=d}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s>e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,i=t.data,r=i.length;if(0===r)return;let s=i[e],o=e;for(let t=e+n;t<r;t+=n){const e=i[t];s<e&&(s=e,o=t)}const a=t.width,h=o/n|0;return{index:o,value:s,x:h%a,y:h/a|0}}};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandConnectivityByLocality.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/topology/expandConnectivityByLocality.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expandConnectivityByLocality.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/topology/expandConnectivityByLocality.js"],"names":[],"mappings":"AAgEA;;;;GAIG;AACH,gFAkCC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
2
|
-
import { computeTopoMeshVertexDuplicates } from "./computeTopoMeshVertexDuplicates.js";
|
|
3
2
|
import { arraySetSortingDiff } from "../../../collection/array/arraySetSortingDiff.js";
|
|
4
3
|
import { compareFaces } from "./compareFaces.js";
|
|
4
|
+
import { computeTopoMeshVertexDuplicates } from "./computeTopoMeshVertexDuplicates.js";
|
|
5
|
+
import { query_edge_other_vertex } from "./query/query_edge_other_vertex.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
@@ -25,7 +26,7 @@ function findCommonDuplicateEdges(result, source_a, source_b) {
|
|
|
25
26
|
for (j = 0; j < edge_count_a; j++) {
|
|
26
27
|
const topoEdge = edges_a[j];
|
|
27
28
|
|
|
28
|
-
const other_vertex_a = topoEdge
|
|
29
|
+
const other_vertex_a = query_edge_other_vertex(topoEdge, v_a);
|
|
29
30
|
|
|
30
31
|
if (source_b.includes(other_vertex_a)) {
|
|
31
32
|
const existing_result_place = result.indexOf(topoEdge);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEdgeConnectedToOutline.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/topology/isEdgeConnectedToOutline.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isEdgeConnectedToOutline.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/topology/isEdgeConnectedToOutline.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,0DAFa,OAAO,CAMnB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isVertexConnectedToOutline } from "./isVertexConnectedToOutline.js";
|
|
2
|
+
import { query_edge_is_boundary } from "./query/query_edge_is_boundary.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Determines whether the given edge is part of the topology outline (outer edge)
|
|
@@ -6,7 +7,7 @@ import { isVertexConnectedToOutline } from "./isVertexConnectedToOutline.js";
|
|
|
6
7
|
* @returns {boolean}
|
|
7
8
|
*/
|
|
8
9
|
export function isEdgeConnectedToOutline(edge) {
|
|
9
|
-
return edge
|
|
10
|
+
return query_edge_is_boundary(edge)
|
|
10
11
|
|| isVertexConnectedToOutline(edge.v0)
|
|
11
12
|
|| isVertexConnectedToOutline(edge.v1);
|
|
12
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isVertexConnectedToOutline.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/topology/isVertexConnectedToOutline.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isVertexConnectedToOutline.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/topology/isVertexConnectedToOutline.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,gEAFa,OAAO,CAenB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { query_edge_is_boundary } from "./query/query_edge_is_boundary.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Determines whether vertex is part of the topology outline (outer edge)
|
|
3
5
|
* @param {TopoVertex} vertex
|
|
@@ -10,7 +12,7 @@ export function isVertexConnectedToOutline(vertex) {
|
|
|
10
12
|
for (let i = 0; i < n; i++) {
|
|
11
13
|
const edge = edges[i];
|
|
12
14
|
|
|
13
|
-
if (edge
|
|
15
|
+
if (query_edge_is_boundary(edge)) {
|
|
14
16
|
return true;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query_edge_other_vertex.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/query/query_edge_other_vertex.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wEAFa,aAAW,IAAI,
|
|
1
|
+
{"version":3,"file":"query_edge_other_vertex.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/query/query_edge_other_vertex.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wEAFa,aAAW,IAAI,CAgB3B"}
|
|
@@ -10,6 +10,9 @@ export function query_edge_other_vertex(edge, v) {
|
|
|
10
10
|
assert.notNull(edge, 'edge');
|
|
11
11
|
assert.notNull(v, 'v');
|
|
12
12
|
|
|
13
|
+
assert.equal(edge.isTopoEdge,true,'edge.isTopoEdge !== true');
|
|
14
|
+
assert.equal(v.isTopoVertex,true,'v.isTopoVertex !== true');
|
|
15
|
+
|
|
13
16
|
if (edge.v0 === v) {
|
|
14
17
|
return edge.v1;
|
|
15
18
|
} else if (edge.v1 === v) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
|
-
* @param {TopoMesh} mesh
|
|
4
3
|
* @param {TopoTriangle[]} initial_set indices of triangles that make up initial set, these are triangles that we start from, they will also be included in the resulting set
|
|
5
4
|
* @param {function(tri:TopoTriangle, prev:TopoTriangle):boolean} filter decides whether a triangle should be included or not
|
|
6
5
|
* @returns {TopoTriangle[]} set of selected triangles, will include initial set as well
|
|
7
6
|
*/
|
|
8
|
-
export function mesh_flood_fill({
|
|
7
|
+
export function mesh_flood_fill({ initial_set, filter }: TopoTriangle[]): TopoTriangle[];
|
|
9
8
|
//# sourceMappingURL=mesh_flood_fill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh_flood_fill.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/util/mesh_flood_fill.js"],"names":[],"mappings":"AAQA
|
|
1
|
+
{"version":3,"file":"mesh_flood_fill.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/util/mesh_flood_fill.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,yDAJW,cAAc,GAEZ,cAAc,CA8C1B"}
|
|
@@ -8,13 +8,11 @@ const neighbours = [];
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
|
-
* @param {TopoMesh} mesh
|
|
12
11
|
* @param {TopoTriangle[]} initial_set indices of triangles that make up initial set, these are triangles that we start from, they will also be included in the resulting set
|
|
13
12
|
* @param {function(tri:TopoTriangle, prev:TopoTriangle):boolean} filter decides whether a triangle should be included or not
|
|
14
13
|
* @returns {TopoTriangle[]} set of selected triangles, will include initial set as well
|
|
15
14
|
*/
|
|
16
15
|
export function mesh_flood_fill({
|
|
17
|
-
mesh,
|
|
18
16
|
initial_set,
|
|
19
17
|
filter
|
|
20
18
|
}) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BinaryUint32BVH } from "../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
|
|
2
2
|
import { bvh32_from_indexed_geometry } from "../../../graphics/geometry/bvh/buffered/bvh32_from_indexed_geometry.js";
|
|
3
|
+
import { geometry_optimize_uv_tension } from "../../../graphics/geometry/optimization/geometry_optimize_uv_tension.js";
|
|
3
4
|
import { Sampler2D } from '../../../graphics/texture/sampler/Sampler2D.js';
|
|
4
5
|
import { sampler2d_channel_compute_max } from "../../../graphics/texture/sampler/sampler2d_channel_compute_max.js";
|
|
5
6
|
import { sampler2d_channel_compute_min } from "../../../graphics/texture/sampler/sampler2d_channel_compute_min.js";
|
|
6
7
|
import BufferedGeometryArraysBuilder from '../BufferedGeometryArraysBuilder.js';
|
|
7
|
-
import { tensionOptimizeUV } from "../util/tensionOptimizeUV.js";
|
|
8
8
|
|
|
9
9
|
self.Lib = {
|
|
10
10
|
/**
|
|
@@ -21,7 +21,7 @@ self.Lib = {
|
|
|
21
21
|
},
|
|
22
22
|
Sampler2D,
|
|
23
23
|
BufferedGeometryArraysBuilder,
|
|
24
|
-
tensionOptimizeUV,
|
|
24
|
+
tensionOptimizeUV: geometry_optimize_uv_tension,
|
|
25
25
|
sampler2d_channel_compute_min,
|
|
26
26
|
sampler2d_channel_compute_max
|
|
27
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeSpec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/geometry/AttributeSpec.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IA+BI,uCAMC;IA0DD;;;;;OAKG;IACH,iBAJW,aAAa,KACb,aAAa,GACZ,MAAM,CAIjB;IArGG;;;OAGG;IACH,MAFU,MAAM,
|
|
1
|
+
{"version":3,"file":"AttributeSpec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/geometry/AttributeSpec.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IA+BI,uCAMC;IA0DD;;;;;OAKG;IACH,iBAJW,aAAa,KACb,aAAa,GACZ,MAAM,CAIjB;IArGG;;;OAGG;IACH,MAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,MAFU,cAAc,CAEM;IAE9B;;;;;OAKG;IACH,UAFU,MAAM,CAEH;IAEb;;;;;OAKG;IACH,YAFU,OAAO,CAEE;IAWvB;;;;;aAoBC;IAED;;;;;MAOC;IAED,eAEC;IAED;;;;OAIG;IACH,cAHW,aAAa,GACX,OAAO,CAQnB;IAED;;;OAGG;IACH,eAFa,MAAM,CAIlB;IAaL;;;OAGG;IACH,0BAFU,OAAO,CAEsB;CANtC;+BAhH8B,6CAA6C"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
+
import { assert } from "../../../core/assert.js";
|
|
1
2
|
import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
|
|
2
|
-
import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
|
|
3
3
|
import { DataTypeByteSizes } from "../../../core/binary/type/DataTypeByteSizes.js";
|
|
4
|
-
import {
|
|
4
|
+
import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Describes data structure of a single data attribute, such as a scalar, or a vector
|
|
8
8
|
* This structure is designed to map well to GPU shader formats and is intended for larger datasets, such as meshes or particle clouds
|
|
9
9
|
*/
|
|
10
10
|
export class AttributeSpec {
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
/**
|
|
13
13
|
* Typically unique within a given set, used to identify the attribute
|
|
14
14
|
* @type {string}
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
name = "";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* How the attribute is stored in memory and interpreted
|
|
20
20
|
* @type {BinaryDataType}
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
type = BinaryDataType.Float32;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* How many elements the attribute uses. This is cardinality of a vector.
|
|
@@ -27,7 +27,7 @@ export class AttributeSpec {
|
|
|
27
27
|
* must be greater or equal to 1
|
|
28
28
|
* @type {number}
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
itemSize = 1;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Normalized values will be automatically converted to float32 in the shader
|
|
@@ -35,8 +35,8 @@ export class AttributeSpec {
|
|
|
35
35
|
* Applies to integer types only
|
|
36
36
|
* @type {boolean}
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
normalized = false;
|
|
39
|
+
|
|
40
40
|
|
|
41
41
|
static fromJSON(j) {
|
|
42
42
|
const r = new AttributeSpec();
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
|
-
* @param {Float32Array}
|
|
7
|
+
* @param {Float32Array} positions
|
|
8
8
|
* @param {Vector4|Vector4Like} result
|
|
9
9
|
*/
|
|
10
|
-
export function computeBoundingSphereFromVertexData(
|
|
10
|
+
export function computeBoundingSphereFromVertexData(positions: Float32Array, result: Vector4 | Vector4Like): void;
|
|
11
11
|
/**
|
|
12
12
|
* {{set:function(x:number,y:number,z:number,w:number):void}}
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeBoundingSphereFromVertexData.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/geometry/computeBoundingSphereFromVertexData.js"],"names":[],"mappings":"AAGA;;;GAGG;AAEH;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"computeBoundingSphereFromVertexData.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/geometry/computeBoundingSphereFromVertexData.js"],"names":[],"mappings":"AAGA;;;GAGG;AAEH;;;;GAIG;AACH,+DAHW,YAAY,UACZ,UAAQ,WAAW,QAiB7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PointSet } from "../../../core/geom/packing/miniball/PointSet.js";
|
|
2
1
|
import { Miniball } from "../../../core/geom/packing/miniball/Miniball.js";
|
|
2
|
+
import { PointSet } from "../../../core/geom/packing/miniball/PointSet.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef Vector4Like {{set:function(x:number,y:number,z:number,w:number):void}}
|
|
@@ -8,12 +8,12 @@ import { Miniball } from "../../../core/geom/packing/miniball/Miniball.js";
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
|
-
* @param {Float32Array}
|
|
11
|
+
* @param {Float32Array} positions
|
|
12
12
|
* @param {Vector4|Vector4Like} result
|
|
13
13
|
*/
|
|
14
|
-
export function computeBoundingSphereFromVertexData(
|
|
14
|
+
export function computeBoundingSphereFromVertexData(positions, result) {
|
|
15
15
|
|
|
16
|
-
const pointSet = new PointSet(
|
|
16
|
+
const pointSet = new PointSet(positions.length / 3, 3, positions);
|
|
17
17
|
const miniball = new Miniball(pointSet);
|
|
18
18
|
|
|
19
19
|
const aCenter = miniball.center();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Move UVs to reduce stretching
|
|
3
|
+
*
|
|
4
|
+
* @param {Float32Array} positions
|
|
5
|
+
* @param {Float32Array} uvs
|
|
6
|
+
* @param {Uint16Array} faces
|
|
7
|
+
* @param {number} [steps] Number of optimization passes to perform
|
|
8
|
+
*/
|
|
9
|
+
export function geometry_optimize_uv_tension(positions: Float32Array, uvs: Float32Array, faces: Uint16Array, steps?: number): void;
|
|
10
|
+
//# sourceMappingURL=geometry_optimize_uv_tension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry_optimize_uv_tension.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/optimization/geometry_optimize_uv_tension.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,wDALW,YAAY,OACZ,YAAY,SACZ,WAAW,UACX,MAAM,QAwEhB"}
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
+
import { query_edge_is_boundary } from "../../../../core/geom/3d/topology/query/query_edge_is_boundary.js";
|
|
2
|
+
import { query_edge_other_vertex } from "../../../../core/geom/3d/topology/query/query_edge_other_vertex.js";
|
|
1
3
|
import { TopoMesh } from "../../../../core/geom/3d/topology/struct/TopoMesh.js";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Move UVs to reduce stretching
|
|
5
7
|
*
|
|
6
|
-
* @param {Float32Array}
|
|
8
|
+
* @param {Float32Array} positions
|
|
7
9
|
* @param {Float32Array} uvs
|
|
8
10
|
* @param {Uint16Array} faces
|
|
9
|
-
* @param {number} steps Number of optimization passes to perform
|
|
11
|
+
* @param {number} [steps] Number of optimization passes to perform
|
|
10
12
|
*/
|
|
11
|
-
export function
|
|
13
|
+
export function geometry_optimize_uv_tension(
|
|
14
|
+
positions,
|
|
15
|
+
uvs,
|
|
16
|
+
faces,
|
|
17
|
+
steps = 3
|
|
18
|
+
) {
|
|
12
19
|
|
|
13
20
|
// Build topology from the data, we need to know which faces are connected to each vertex
|
|
14
21
|
const topo = new TopoMesh();
|
|
15
22
|
|
|
16
|
-
topo.build(
|
|
23
|
+
topo.build(positions, faces);
|
|
17
24
|
topo.computeEdgeSquaredLengths();
|
|
18
25
|
|
|
19
|
-
const nVertices =
|
|
26
|
+
const nVertices = positions.length / 3;
|
|
20
27
|
|
|
21
28
|
for (let i = 0; i < steps; i++) {
|
|
22
29
|
|
|
@@ -44,12 +51,12 @@ export function tensionOptimizeUV(vertices, uvs, faces, steps) {
|
|
|
44
51
|
for (let k = 0; k < nAttachedEdges; k++) {
|
|
45
52
|
const attachedEdge = attachedEdges[k];
|
|
46
53
|
|
|
47
|
-
if (attachedEdge
|
|
54
|
+
if (query_edge_is_boundary(attachedEdge)) {
|
|
48
55
|
//edge vertex, no adjustment possible
|
|
49
56
|
continue loop_vertices;
|
|
50
57
|
}
|
|
51
58
|
|
|
52
|
-
const otherVertex = attachedEdge
|
|
59
|
+
const otherVertex = query_edge_other_vertex(attachedEdge, topoVertex);
|
|
53
60
|
|
|
54
61
|
const otherUvAddress = otherVertex.index * 2;
|
|
55
62
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param {THREE.Object3D} input
|
|
4
|
-
* @param context
|
|
5
4
|
* @returns {THREE.Object3D}
|
|
6
5
|
*/
|
|
7
|
-
export function merge_geometry_hierarchy(input: THREE.Object3D
|
|
6
|
+
export function merge_geometry_hierarchy(input: THREE.Object3D): THREE.Object3D;
|
|
8
7
|
//# sourceMappingURL=merge_geometry_hierarchy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge_geometry_hierarchy.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js"],"names":[],"mappings":"AAwPA
|
|
1
|
+
{"version":3,"file":"merge_geometry_hierarchy.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js"],"names":[],"mappings":"AAwPA;;;;GAIG;AACH,gDAHW,MAAM,QAAQ,GACZ,MAAM,QAAQ,CA0E1B"}
|
|
@@ -249,10 +249,9 @@ function apply_transform_to_another_three_object(source, destination) {
|
|
|
249
249
|
/**
|
|
250
250
|
*
|
|
251
251
|
* @param {THREE.Object3D} input
|
|
252
|
-
* @param context
|
|
253
252
|
* @returns {THREE.Object3D}
|
|
254
253
|
*/
|
|
255
|
-
export function merge_geometry_hierarchy(input
|
|
254
|
+
export function merge_geometry_hierarchy(input) {
|
|
256
255
|
// material cache
|
|
257
256
|
const material_cache = new StaticMaterialCache();
|
|
258
257
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NOTE: the method is completely
|
|
2
|
+
* NOTE: the method is completely inlined for better performance. 0 function calls within the skinning loop
|
|
3
3
|
* @param {Float32Array} destination Skinned vertex positions
|
|
4
4
|
* @param {SkinnedMesh} mesh
|
|
5
5
|
* @param {number} [destination_offset=0]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Matrix4 as ThreeMatrix4 } from "three";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* NOTE: the method is completely
|
|
4
|
+
* NOTE: the method is completely inlined for better performance. 0 function calls within the skinning loop
|
|
5
5
|
* @param {Float32Array} destination Skinned vertex positions
|
|
6
6
|
* @param {SkinnedMesh} mesh
|
|
7
7
|
* @param {number} [destination_offset=0]
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Move UVs to reduce stretching
|
|
3
|
-
*
|
|
4
|
-
* @param {Float32Array} vertices
|
|
5
|
-
* @param {Float32Array} uvs
|
|
6
|
-
* @param {Uint16Array} faces
|
|
7
|
-
* @param {number} steps Number of optimization passes to perform
|
|
8
|
-
*/
|
|
9
|
-
export function tensionOptimizeUV(vertices: Float32Array, uvs: Float32Array, faces: Uint16Array, steps: number): void;
|
|
10
|
-
//# sourceMappingURL=tensionOptimizeUV.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tensionOptimizeUV.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/util/tensionOptimizeUV.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,4CALW,YAAY,OACZ,YAAY,SACZ,WAAW,SACX,MAAM,QAmEhB"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const BufferGeometryWrap = function (bufferGeometry) {
|
|
3
|
-
this.source = bufferGeometry;
|
|
4
|
-
};
|
|
5
|
-
BufferGeometryWrap.prototype.bindVertex = function (index, v3, writeBack) {
|
|
6
|
-
const vertices = this.source.attributes.vertices;
|
|
7
|
-
const vArray = vertices.array;
|
|
8
|
-
const offset = (index * 3);
|
|
9
|
-
v3.set(vArray[offset], vArray[offset + 1], vArray[offset + 2]);
|
|
10
|
-
//
|
|
11
|
-
if (writeBack) {
|
|
12
|
-
v3.onChanged.add(function () {
|
|
13
|
-
vArray[offset] = v3.x;
|
|
14
|
-
vArray[offset + 1] = v3.y;
|
|
15
|
-
vArray[offset + 2] = v3.z;
|
|
16
|
-
vertices.needsUpdate = true;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
BufferGeometryWrap.prototype.bindFace = function (index, face, writeBack) {
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
export default BufferGeometryWrap;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export class ClippedGeometry {
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @type {THREE.BufferGeometry}
|
|
5
|
-
*/
|
|
6
|
-
output: THREE.BufferGeometry;
|
|
7
|
-
/**
|
|
8
|
-
* @type {THREE.BufferGeometry}
|
|
9
|
-
*/
|
|
10
|
-
input: THREE.BufferGeometry;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @type {Plane[]}
|
|
14
|
-
*/
|
|
15
|
-
planes: Plane[];
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @type {Uint32Array}
|
|
19
|
-
* @private
|
|
20
|
-
*/
|
|
21
|
-
private __input_buffer_indices;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @type {Float32Array}
|
|
25
|
-
* @private
|
|
26
|
-
*/
|
|
27
|
-
private __input_buffer_positions;
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @type {number}
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
private __output_vertex_cursor;
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @type {number}
|
|
37
|
-
* @private
|
|
38
|
-
*/
|
|
39
|
-
private __output_index_cursor;
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @param {number} input_index
|
|
43
|
-
* @private
|
|
44
|
-
*/
|
|
45
|
-
private __output_copy_face;
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @param {number} input_index
|
|
49
|
-
* @param {Plane} plane
|
|
50
|
-
* @private
|
|
51
|
-
*/
|
|
52
|
-
private __clip_face;
|
|
53
|
-
compute(): void;
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=ClippedGeometry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClippedGeometry.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/clipping/ClippedGeometry.js"],"names":[],"mappings":"AAIA;IAGQ;;;OAGG;IACH,QAFU,MAAM,cAAc,CAEZ;IAElB;;OAEG;IACH,OAFU,MAAM,cAAc,CAEb;IAEjB;;;OAGG;IACH,QAFU,OAAO,CAED;IAEhB;;;;OAIG;IACH,+BAAkC;IAElC;;;;OAIG;IACH,iCAAoC;IAEpC;;;;OAIG;IACH,+BAA+B;IAE/B;;;;OAIG;IACH,8BAA8B;IAGlC;;;;OAIG;IACH,2BAEC;IAED;;;;;OAKG;IACH,oBA8DC;IAED,gBAUC;CACJ"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { v3_distance_above_plane } from "../../../../core/geom/vec3/v3_distance_above_plane.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// TODO incomplete
|
|
5
|
-
export class ClippedGeometry {
|
|
6
|
-
constructor() {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @type {THREE.BufferGeometry}
|
|
11
|
-
*/
|
|
12
|
-
this.output = null;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @type {THREE.BufferGeometry}
|
|
16
|
-
*/
|
|
17
|
-
this.input = null;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @type {Plane[]}
|
|
22
|
-
*/
|
|
23
|
-
this.planes = [];
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @type {Uint32Array}
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
this.__input_buffer_indices = null;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @type {Float32Array}
|
|
35
|
-
* @private
|
|
36
|
-
*/
|
|
37
|
-
this.__input_buffer_positions = null;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @type {number}
|
|
42
|
-
* @private
|
|
43
|
-
*/
|
|
44
|
-
this.__output_vertex_cursor = 0
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @type {number}
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
this.__output_index_cursor = 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
* @param {number} input_index
|
|
57
|
-
* @private
|
|
58
|
-
*/
|
|
59
|
-
__output_copy_face(input_index) {
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
* @param {number} input_index
|
|
66
|
-
* @param {Plane} plane
|
|
67
|
-
* @private
|
|
68
|
-
*/
|
|
69
|
-
__clip_face(input_index, plane) {
|
|
70
|
-
const input_indices = this.__input_buffer_indices;
|
|
71
|
-
const input_vertices = this.__input_buffer_positions;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// read vertices
|
|
75
|
-
const index3 = input_index * 3;
|
|
76
|
-
|
|
77
|
-
const a = input_indices[index3];
|
|
78
|
-
const b = input_indices[index3 + 1];
|
|
79
|
-
const c = input_indices[index3 + 2];
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// read positions
|
|
83
|
-
const a3 = a * 3;
|
|
84
|
-
|
|
85
|
-
const a_x = input_vertices[a3];
|
|
86
|
-
const a_y = input_vertices[a3 + 1];
|
|
87
|
-
const a_z = input_vertices[a3 + 2];
|
|
88
|
-
|
|
89
|
-
const b3 = b * 3;
|
|
90
|
-
|
|
91
|
-
const b_x = input_vertices[b3];
|
|
92
|
-
const b_y = input_vertices[b3 + 1];
|
|
93
|
-
const b_z = input_vertices[b3 + 2];
|
|
94
|
-
|
|
95
|
-
const c3 = c * 3;
|
|
96
|
-
|
|
97
|
-
const c_x = input_vertices[c3];
|
|
98
|
-
const c_y = input_vertices[c3 + 1];
|
|
99
|
-
const c_z = input_vertices[c3 + 2];
|
|
100
|
-
|
|
101
|
-
// compute distance to plane for each vertex
|
|
102
|
-
const normal = plane.normal;
|
|
103
|
-
|
|
104
|
-
const normal_x = normal.x;
|
|
105
|
-
const normal_y = normal.y;
|
|
106
|
-
const normal_z = normal.z;
|
|
107
|
-
|
|
108
|
-
const plane_constant = plane.constant;
|
|
109
|
-
|
|
110
|
-
const a_distance = v3_distance_above_plane(a_x, a_y, a_z, normal_x, normal_y, normal_z, plane_constant);
|
|
111
|
-
const b_distance = v3_distance_above_plane(b_x, b_y, b_z, normal_x, normal_y, normal_z, plane_constant);
|
|
112
|
-
const c_distance = v3_distance_above_plane(c_x, c_y, c_z, normal_x, normal_y, normal_z, plane_constant);
|
|
113
|
-
|
|
114
|
-
const a_out = a_distance <= 0;
|
|
115
|
-
const b_out = b_distance <= 0;
|
|
116
|
-
const c_out = c_distance <= 0;
|
|
117
|
-
|
|
118
|
-
// count vertices that are out
|
|
119
|
-
const out_count = (a_out ? 1 : 0) + (b_out ? 1 : 0) + (c_out ? 1 : 0);
|
|
120
|
-
|
|
121
|
-
switch (out_count) {
|
|
122
|
-
case 0:
|
|
123
|
-
// all points are above the plane
|
|
124
|
-
this.__output_copy_face(input_index);
|
|
125
|
-
case 3:
|
|
126
|
-
// all points are below
|
|
127
|
-
// fallthrough
|
|
128
|
-
default:
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
compute() {
|
|
134
|
-
const planes = this.planes;
|
|
135
|
-
const plane_count = planes.length;
|
|
136
|
-
|
|
137
|
-
for (let i = 0; i < plane_count; i++) {
|
|
138
|
-
const plane = planes[i];
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
}
|