@jdultra/threedtiles 13.2.3 → 13.2.4

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.
@@ -26,7 +26,7 @@ Example:
26
26
  * @author Kirk Qi
27
27
  * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
28
28
  * @license MIT License
29
- */class kt extends Lc{constructor(t=[],a){super(a);yt(this,"_elements",[]);yt(this,"_DEFAULT_COMPARATOR",(t,a)=>{if(typeof t=="object"||typeof a=="object")throw TypeError("When comparing object types, a custom comparator must be defined in the constructor's options parameter.");return t>a?1:t<a?-1:0});yt(this,"_comparator",this._DEFAULT_COMPARATOR);if(a){const{comparator:n}=a;n&&(this._comparator=n)}this.addMany(t)}get elements(){return this._elements}get size(){return this.elements.length}get leaf(){return this.elements[this.size-1]??void 0}static heapify(t,a){return new kt(t,a)}add(t){return this._elements.push(t),this._bubbleUp(this.elements.length-1)}addMany(t){const a=[];for(const n of t)this._toElementFn?a.push(this.add(this._toElementFn(n))):a.push(this.add(n));return a}poll(){if(this.elements.length===0)return;const t=this.elements[0],a=this.elements.pop();return this.elements.length&&(this.elements[0]=a,this._sinkDown(0,this.elements.length>>1)),t}peek(){return this.elements[0]}isEmpty(){return this.size===0}clear(){this._elements=[]}refill(t){return this._elements=t,this.fix()}has(t){return this.elements.includes(t)}delete(t){const a=this.elements.indexOf(t);return!(a<0)&&(a===0?this.poll():a===this.elements.length-1?this.elements.pop():(this.elements.splice(a,1,this.elements.pop()),this._bubbleUp(a),this._sinkDown(a,this.elements.length>>1)),!0)}dfs(t="PRE"){const a=[],n=i=>{const o=2*i+1,s=o+1;i<this.size&&(t==="IN"?(n(o),a.push(this.elements[i]),n(s)):t==="PRE"?(a.push(this.elements[i]),n(o),n(s)):t==="POST"&&(n(o),n(s),a.push(this.elements[i])))};return n(0),a}clone(){return new kt(this,{comparator:this.comparator,toElementFn:this.toElementFn})}sort(){const t=[],a=new kt(this,{comparator:this.comparator});for(;a.size!==0;){const n=a.poll();n!==void 0&&t.push(n)}return t}fix(){const t=[];for(let a=Math.floor(this.size/2);a>=0;a--)t.push(this._sinkDown(a,this.elements.length>>1));return t}filter(t,a){const n=new kt([],{toElementFn:this.toElementFn,comparator:this.comparator});let i=0;for(const o of this)t.call(a,o,i,this)&&n.add(o),i++;return n}map(t,a,n,i){const o=new kt([],{comparator:a,toElementFn:n});let s=0;for(const A of this)o.add(t.call(i,A,s,this)),s++;return o}get comparator(){return this._comparator}*_getIterator(){for(const t of this.elements)yield t}_bubbleUp(t){const a=this.elements[t];for(;t>0;){const n=t-1>>1,i=this.elements[n];if(this.comparator(i,a)<=0)break;this.elements[t]=i,t=n}return this.elements[t]=a,!0}_sinkDown(t,a){const n=this.elements[t];for(;t<a;){let i=t<<1|1;const o=i+1;let s=this.elements[i];if(o<this.elements.length&&this.comparator(s,this.elements[o])>0&&(i=o,s=this.elements[o]),this.comparator(s,n)>=0)break;this.elements[t]=s,t=i}return this.elements[t]=n,!0}}(function(r){r[r.VISIT=0]="VISIT",r[r.PROCESS=1]="PROCESS"})(kn||(kn={}));class ea extends kt{constructor(e=[],t){super(e,t)}clone(){return new ea(this,{comparator:this.comparator,toElementFn:this.toElementFn})}filter(e,t){const a=new ea([],{toElementFn:this.toElementFn,comparator:this.comparator});let n=0;for(const i of this)e.call(t,i,n,this)&&a.add(i),n++;return a}map(e,t,a,n){const i=new ea([],{comparator:t,toElementFn:a});let o=0;for(const s of this)i.add(e.call(n,s,o,this)),o++;return i}}class ta extends ea{constructor(e=[],t){super(e,t)}clone(){return new ta(this,{comparator:this.comparator,toElementFn:this.toElementFn})}filter(e,t){const a=new ta([],{toElementFn:this.toElementFn,comparator:this.comparator});let n=0;for(const i of this)e.call(t,i,n,this)&&a.add(i),n++;return a}map(e,t,a,n){const i=new ta([],{comparator:t,toElementFn:a});let o=0;for(const s of this)i.add(e.call(n,s,o,this)),o++;return i}}function Gc(r){return new Worker(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/PointsManager.worker-dH1fNyu8.js").href:new URL("assets/PointsManager.worker-dH1fNyu8.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),{type:"module",name:r==null?void 0:r.name})}new E.Box3,new E.Vector3,new E.Vector3,new E.Vector3,new E.Vector3;const ua=new E.Vector3,_c=new E.Vector3,qi=new E.Matrix3;qi.set(1,0,0,0,0,1,0,-1,0);const Hc=new E.Matrix4().set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);function ar(r,e){return(E.DataUtils.toHalfFloat(r)|E.DataUtils.toHalfFloat(e)<<16)>>>0}class Oc extends E.Mesh{constructor(e,t,a){const i=Math.min(Math.ceil(1)*1024,Math.pow(1024,2));let o=1*Math.pow(1024,2);o=Math.floor(o/i)*i;const s=new E.WebGL3DRenderTarget(1024,1024,1,{magFilter:E.NearestFilter,minFilter:E.NearestFilter,type:E.UnsignedIntType,format:E.RGBAIntegerFormat,anisotropy:0,depthBuffer:!1,resolveDepthBuffer:!1});s.texture.type=E.UnsignedIntType,s.texture.format=E.RGBAIntegerFormat,s.texture.internalFormat="RGBA32UI",e.initRenderTarget(s);const A=new E.WebGL3DRenderTarget(1024,1024,1,{magFilter:E.NearestFilter,minFilter:E.NearestFilter,anisotropy:0,type:E.UnsignedIntType,format:E.RGBAIntegerFormat,depthBuffer:!1,resolveDepthBuffer:!1});A.texture.type=E.UnsignedIntType,A.texture.format=E.RGBAIntegerFormat,A.texture.internalFormat="RGBA32UI",e.initRenderTarget(A);const u=new E.ShaderMaterial({glslVersion:E.GLSL3,uniforms:{textureSize:{value:1024},numSlices:{value:1},covarianceTexture:{value:A.texture},positionColorTexture:{value:s.texture},zUpToYUpMatrix3x3:{value:qi},sizeMultiplier:{value:1},cropRadius:{value:Number.MAX_VALUE},cameraNear:{value:.01},cameraFar:{value:10},computeLinearDepth:{value:!0},viewportPixelSize:{value:new E.Vector2},k:{value:2},beta_k:{value:2},minSplatPixelSize:{value:0},minOpacity:{value:.01},culling:{value:!0}},vertexShader:Ji(),fragmentShader:a||Ki(),transparent:!0,side:E.FrontSide,depthTest:!1,depthWrite:!1}),c=new E.InstancedBufferGeometry,d=new Float32Array([-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,-.5,0]);c.setIndex([0,2,1,2,3,1]),c.setAttribute("position",new E.BufferAttribute(d,3));const l=new Uint32Array(o),h=new E.InstancedBufferAttribute(l,1,!1);h.needsUpdate=!0,h.setUsage(E.DynamicDrawUsage),c.setAttribute("order",h),c.instanceCount=0,super(c,u),this.matrixAutoUpdate=!1,this.numBatches=0,this.numVisibleBatches=0,this.orderAttribute=h,this.textureSize=1024,this.numTextures=1,this.batchSize=i,this.maxSplats=o,this.numSplatsRendered=0,this.positionColorRenderTarget=s,this.covarianceRenderTarget=A,this.renderer=e,this.sortID=0,this.freeAddresses=new ta;for(let g=0;g<this.maxSplats;g+=i)this.freeAddresses.add(g);this.worker=new Gc({}),this.sortListeners=[],this.worker.onmessage=g=>{console.log(g.data.sortPerf);const f=new Uint32Array(g.data.order);if(this.numSplatsRendered=f.length,f.length>this.orderAttribute.count){const m=new E.InstancedBufferGeometry,p=new Float32Array([-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,-.5,0]),C=[0,2,1,2,3,1];m.setIndex(C),m.setAttribute("position",new E.BufferAttribute(p,3));const I=new Uint32Array(this.maxSplats),x=new E.InstancedBufferAttribute(I,1,!1);x.needsUpdate=!0,x.setUsage(E.DynamicDrawUsage),m.setAttribute("order",x),m.instanceCount=0,this.geometry.dispose(),this.geometry=m,this.orderAttribute=x}this.orderAttribute.clearUpdateRanges(),this.orderAttribute.set(f),this.orderAttribute.addUpdateRange(0,f.length),this.orderAttribute.needsUpdate=!0,this.geometry.instanceCount=g.data.count,this.geometry.needsUpdate=!0;for(let m=this.sortListeners.length-1;m>=0;m--)this.sortListeners[m](g.data.id)&&this.sortListeners.splice(m,1)},this.cameraPosition=new E.Vector3(0,0,0),this.viewProjModel,this.rotateOnAxis(new E.Vector3(1,0,0),.5*Math.PI),this.frustumCulled=!1,this.copyMaterial2D=new E.ShaderMaterial({glslVersion:E.GLSL3,uniforms:{sourceTexture:{}},vertexShader:Un(),fragmentShader:`
29
+ */class kt extends Lc{constructor(t=[],a){super(a);yt(this,"_elements",[]);yt(this,"_DEFAULT_COMPARATOR",(t,a)=>{if(typeof t=="object"||typeof a=="object")throw TypeError("When comparing object types, a custom comparator must be defined in the constructor's options parameter.");return t>a?1:t<a?-1:0});yt(this,"_comparator",this._DEFAULT_COMPARATOR);if(a){const{comparator:n}=a;n&&(this._comparator=n)}this.addMany(t)}get elements(){return this._elements}get size(){return this.elements.length}get leaf(){return this.elements[this.size-1]??void 0}static heapify(t,a){return new kt(t,a)}add(t){return this._elements.push(t),this._bubbleUp(this.elements.length-1)}addMany(t){const a=[];for(const n of t)this._toElementFn?a.push(this.add(this._toElementFn(n))):a.push(this.add(n));return a}poll(){if(this.elements.length===0)return;const t=this.elements[0],a=this.elements.pop();return this.elements.length&&(this.elements[0]=a,this._sinkDown(0,this.elements.length>>1)),t}peek(){return this.elements[0]}isEmpty(){return this.size===0}clear(){this._elements=[]}refill(t){return this._elements=t,this.fix()}has(t){return this.elements.includes(t)}delete(t){const a=this.elements.indexOf(t);return!(a<0)&&(a===0?this.poll():a===this.elements.length-1?this.elements.pop():(this.elements.splice(a,1,this.elements.pop()),this._bubbleUp(a),this._sinkDown(a,this.elements.length>>1)),!0)}dfs(t="PRE"){const a=[],n=i=>{const o=2*i+1,s=o+1;i<this.size&&(t==="IN"?(n(o),a.push(this.elements[i]),n(s)):t==="PRE"?(a.push(this.elements[i]),n(o),n(s)):t==="POST"&&(n(o),n(s),a.push(this.elements[i])))};return n(0),a}clone(){return new kt(this,{comparator:this.comparator,toElementFn:this.toElementFn})}sort(){const t=[],a=new kt(this,{comparator:this.comparator});for(;a.size!==0;){const n=a.poll();n!==void 0&&t.push(n)}return t}fix(){const t=[];for(let a=Math.floor(this.size/2);a>=0;a--)t.push(this._sinkDown(a,this.elements.length>>1));return t}filter(t,a){const n=new kt([],{toElementFn:this.toElementFn,comparator:this.comparator});let i=0;for(const o of this)t.call(a,o,i,this)&&n.add(o),i++;return n}map(t,a,n,i){const o=new kt([],{comparator:a,toElementFn:n});let s=0;for(const A of this)o.add(t.call(i,A,s,this)),s++;return o}get comparator(){return this._comparator}*_getIterator(){for(const t of this.elements)yield t}_bubbleUp(t){const a=this.elements[t];for(;t>0;){const n=t-1>>1,i=this.elements[n];if(this.comparator(i,a)<=0)break;this.elements[t]=i,t=n}return this.elements[t]=a,!0}_sinkDown(t,a){const n=this.elements[t];for(;t<a;){let i=t<<1|1;const o=i+1;let s=this.elements[i];if(o<this.elements.length&&this.comparator(s,this.elements[o])>0&&(i=o,s=this.elements[o]),this.comparator(s,n)>=0)break;this.elements[t]=s,t=i}return this.elements[t]=n,!0}}(function(r){r[r.VISIT=0]="VISIT",r[r.PROCESS=1]="PROCESS"})(kn||(kn={}));class ea extends kt{constructor(e=[],t){super(e,t)}clone(){return new ea(this,{comparator:this.comparator,toElementFn:this.toElementFn})}filter(e,t){const a=new ea([],{toElementFn:this.toElementFn,comparator:this.comparator});let n=0;for(const i of this)e.call(t,i,n,this)&&a.add(i),n++;return a}map(e,t,a,n){const i=new ea([],{comparator:t,toElementFn:a});let o=0;for(const s of this)i.add(e.call(n,s,o,this)),o++;return i}}class ta extends ea{constructor(e=[],t){super(e,t)}clone(){return new ta(this,{comparator:this.comparator,toElementFn:this.toElementFn})}filter(e,t){const a=new ta([],{toElementFn:this.toElementFn,comparator:this.comparator});let n=0;for(const i of this)e.call(t,i,n,this)&&a.add(i),n++;return a}map(e,t,a,n){const i=new ta([],{comparator:t,toElementFn:a});let o=0;for(const s of this)i.add(e.call(n,s,o,this)),o++;return i}}function Gc(r){return new Worker(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/PointsManager.worker-dH1fNyu8.js").href:new URL("assets/PointsManager.worker-dH1fNyu8.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),{type:"module",name:r==null?void 0:r.name})}new E.Box3,new E.Vector3,new E.Vector3,new E.Vector3,new E.Vector3;const ua=new E.Vector3,_c=new E.Vector3,qi=new E.Matrix3;qi.set(1,0,0,0,0,1,0,-1,0);const Hc=new E.Matrix4().set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);function ar(r,e){return(E.DataUtils.toHalfFloat(r)|E.DataUtils.toHalfFloat(e)<<16)>>>0}class Oc extends E.Mesh{constructor(e,t,a){const i=Math.min(Math.ceil(1)*1024,Math.pow(1024,2));let o=1*Math.pow(1024,2);o=Math.floor(o/i)*i;const s=new E.WebGL3DRenderTarget(1024,1024,1,{magFilter:E.NearestFilter,minFilter:E.NearestFilter,type:E.UnsignedIntType,format:E.RGBAIntegerFormat,anisotropy:0,depthBuffer:!1,resolveDepthBuffer:!1});s.texture.type=E.UnsignedIntType,s.texture.format=E.RGBAIntegerFormat,s.texture.internalFormat="RGBA32UI",e.initRenderTarget(s);const A=new E.WebGL3DRenderTarget(1024,1024,1,{magFilter:E.NearestFilter,minFilter:E.NearestFilter,anisotropy:0,type:E.UnsignedIntType,format:E.RGBAIntegerFormat,depthBuffer:!1,resolveDepthBuffer:!1});A.texture.type=E.UnsignedIntType,A.texture.format=E.RGBAIntegerFormat,A.texture.internalFormat="RGBA32UI",e.initRenderTarget(A);const u=new E.ShaderMaterial({glslVersion:E.GLSL3,uniforms:{textureSize:{value:1024},numSlices:{value:1},covarianceTexture:{value:A.texture},positionColorTexture:{value:s.texture},zUpToYUpMatrix3x3:{value:qi},sizeMultiplier:{value:1},cropRadius:{value:Number.MAX_VALUE},cameraNear:{value:.01},cameraFar:{value:10},computeLinearDepth:{value:!0},viewportPixelSize:{value:new E.Vector2},k:{value:2},beta_k:{value:2},minSplatPixelSize:{value:0},minOpacity:{value:.01},culling:{value:!0}},vertexShader:Ji(),fragmentShader:a||Ki(),transparent:!0,side:E.FrontSide,depthTest:!1,depthWrite:!1}),c=new E.InstancedBufferGeometry,d=new Float32Array([-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,-.5,0]);c.setIndex([0,2,1,2,3,1]),c.setAttribute("position",new E.BufferAttribute(d,3));const l=new Uint32Array(o),h=new E.InstancedBufferAttribute(l,1,!1);h.needsUpdate=!0,h.setUsage(E.DynamicDrawUsage),c.setAttribute("order",h),c.instanceCount=0,super(c,u),this.matrixAutoUpdate=!1,this.numBatches=0,this.numVisibleBatches=0,this.orderAttribute=h,this.textureSize=1024,this.numTextures=1,this.batchSize=i,this.maxSplats=o,this.numSplatsRendered=0,this.positionColorRenderTarget=s,this.covarianceRenderTarget=A,this.renderer=e,this.sortID=0,this.freeAddresses=new ta;for(let g=0;g<this.maxSplats;g+=i)this.freeAddresses.add(g);this.worker=new Gc({}),this.sortListeners=[],this.worker.onmessage=g=>{const f=new Uint32Array(g.data.order);if(this.numSplatsRendered=f.length,f.length>this.orderAttribute.count){const m=new E.InstancedBufferGeometry,p=new Float32Array([-.5,.5,0,.5,.5,0,-.5,-.5,0,.5,-.5,0]),C=[0,2,1,2,3,1];m.setIndex(C),m.setAttribute("position",new E.BufferAttribute(p,3));const I=new Uint32Array(this.maxSplats),x=new E.InstancedBufferAttribute(I,1,!1);x.needsUpdate=!0,x.setUsage(E.DynamicDrawUsage),m.setAttribute("order",x),m.instanceCount=0,this.geometry.dispose(),this.geometry=m,this.orderAttribute=x}this.orderAttribute.clearUpdateRanges(),this.orderAttribute.set(f),this.orderAttribute.addUpdateRange(0,f.length),this.orderAttribute.needsUpdate=!0,this.geometry.instanceCount=g.data.count,this.geometry.needsUpdate=!0;for(let m=this.sortListeners.length-1;m>=0;m--)this.sortListeners[m](g.data.id)&&this.sortListeners.splice(m,1)},this.cameraPosition=new E.Vector3(0,0,0),this.viewProjModel,this.rotateOnAxis(new E.Vector3(1,0,0),.5*Math.PI),this.frustumCulled=!1,this.copyMaterial2D=new E.ShaderMaterial({glslVersion:E.GLSL3,uniforms:{sourceTexture:{}},vertexShader:Un(),fragmentShader:`
30
30
  precision highp float;
31
31
  layout(location = 0) out uvec4 fragColor;
32
32
  uniform highp usampler2D sourceTexture;