UNPKG

@cognite/potree-core

Version:

Potree wrapper for threejs applications

1 lines 136 kB
!function(e,t){for(var n in t)e[n]=t[n]}(exports,function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t){e.exports=require("three")},function(e,t,n){"use strict";var i=window.URL||window.webkitURL;e.exports=function(e,t){try{try{var n;try{(n=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder)).append(e),n=n.getBlob()}catch(t){n=new Blob([e])}return new Worker(i.createObjectURL(n))}catch(t){return new Worker("data:application/javascript,"+encodeURIComponent(e))}}catch(e){if(!t)throw Error("Inline worker is not supported");return new Worker(t)}}},function(e,t,n){e.exports=function(){return n(1)('!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";function n(e){this.buffer=e,this.u8=new Uint8Array(e);var t=new ArrayBuffer(4),r=new Float32Array(t),n=new Uint8Array(t);this.getUint32=function(e){return this.u8[e+3]<<24|this.u8[e+2]<<16|this.u8[e+1]<<8|this.u8[e]},this.getUint16=function(e){return this.u8[e+1]<<8|this.u8[e]},this.getFloat32=function(e){return n[0]=this.u8[e+0],n[1]=this.u8[e+1],n[2]=this.u8[e+2],n[3]=this.u8[e+3],r[0]},this.getUint8=function(e){return this.u8[e]}}function i(e){this.version=e;var t=-1===e.indexOf(".")?e.length:e.indexOf(".");this.versionMajor=parseInt(e.substr(0,t)),this.versionMinor=parseInt(e.substr(t+1)),0===this.versionMinor.length&&(this.versionMinor=0)}onmessage=function(e){if(e.data&&e.data.buffer)try{var t=e.data.buffer,r=e.data.pointAttributes,a=t.byteLength/r.byteSize,s=new n(t),o=new i(e.data.version),u=e.data.offset,f=e.data.scale,A=(e.data.spacing,e.data.hasChildren,e.data.name,[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]),T=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],b=[0,0,0],_={},h=0;for(var I of r.attributes){if(I.name===P.POSITION_CARTESIAN.name){for(var N=new ArrayBuffer(4*a*3),y=new Float32Array(N),E=0;E<a;E++){o.newerThan("1.3")?(F=s.getUint32(h+E*r.byteSize+0,!0)*f,R=s.getUint32(h+E*r.byteSize+4,!0)*f,Y=s.getUint32(h+E*r.byteSize+8,!0)*f):(F=s.getFloat32(E*r.byteSize+0,!0)+u[0],R=s.getFloat32(E*r.byteSize+4,!0)+u[1],Y=s.getFloat32(E*r.byteSize+8,!0)+u[2]),y[3*E+0]=F,y[3*E+1]=R,y[3*E+2]=Y,b[0]+=F/a,b[1]+=R/a,b[2]+=Y/a,A[0]=Math.min(A[0],F),A[1]=Math.min(A[1],R),A[2]=Math.min(A[2],Y),T[0]=Math.max(T[0],F),T[1]=Math.max(T[1],R),T[2]=Math.max(T[2],Y)}_[I.name]={buffer:N,attribute:I}}else if(I.name===P.COLOR_PACKED.name){N=new ArrayBuffer(4*a);var l=new Uint8Array(N);for(E=0;E<a;E++)l[4*E+0]=s.getUint8(h+E*r.byteSize+0),l[4*E+1]=s.getUint8(h+E*r.byteSize+1),l[4*E+2]=s.getUint8(h+E*r.byteSize+2);_[I.name]={buffer:N,attribute:I}}else if(I.name===P.INTENSITY.name){N=new ArrayBuffer(4*a);var S=new Float32Array(N);for(E=0;E<a;E++){var m=s.getUint16(h+E*r.byteSize,!0);S[E]=m}_[I.name]={buffer:N,attribute:I}}else if(I.name===P.CLASSIFICATION.name){N=new ArrayBuffer(a);var M=new Uint8Array(N);for(E=0;E<a;E++){var O=s.getUint8(h+E*r.byteSize);M[E]=O}_[I.name]={buffer:N,attribute:I}}else if(I.name===P.NORMAL_SPHEREMAPPED.name){N=new ArrayBuffer(4*a*3);var v=new Float32Array(N);for(E=0;E<a;E++){var d=s.getUint8(h+E*r.byteSize+0),g=s.getUint8(h+E*r.byteSize+1),w=2*(d/255)-1,c=2*(g/255)-1,z=1,U=w*-w+c*-c+1*z;z=U,w*=Math.sqrt(U),c*=Math.sqrt(U),w*=2,c*=2,z=2*z-1,v[3*E+0]=w,v[3*E+1]=c,v[3*E+2]=z}_[I.name]={buffer:N,attribute:I}}else if(I.name===P.NORMAL_OCT16.name){for(N=new ArrayBuffer(4*a*3),v=new Float32Array(N),E=0;E<a;E++){d=s.getUint8(h+E*r.byteSize+0),g=s.getUint8(h+E*r.byteSize+1);var D=d/255*2-1,p=g/255*2-1,Y=1-Math.abs(D)-Math.abs(p),F=0,R=0;Y>=0?(F=D,R=p):(F=-(p/Math.sign(p)-1)/Math.sign(D),R=-(D/Math.sign(D)-1)/Math.sign(p));var L=Math.sqrt(F*F+R*R+Y*Y);F/=L,R/=L,Y/=L,v[3*E+0]=F,v[3*E+1]=R,v[3*E+2]=Y}_[I.name]={buffer:N,attribute:I}}else if(I.name===P.NORMAL.name){for(N=new ArrayBuffer(4*a*3),v=new Float32Array(N),E=0;E<a;E++){F=s.getFloat32(h+E*r.byteSize+0,!0),R=s.getFloat32(h+E*r.byteSize+4,!0),Y=s.getFloat32(h+E*r.byteSize+8,!0);v[3*E+0]=F,v[3*E+1]=R,v[3*E+2]=Y}_[I.name]={buffer:N,attribute:I}}h+=I.byteSize}N=new ArrayBuffer(4*a);for(var C=new Uint32Array(N),B=0;B<a;B++)C[B]=B;_[P.INDICES.name]={buffer:N,attribute:P.INDICES};var x={buffer:t,mean:b,attributeBuffers:_,tightBoundingBox:{min:A,max:T}},j=[];for(var G in x.attributeBuffers)j.push(x.attributeBuffers[G].buffer);j.push(t),postMessage(x,j)}catch(e){postMessage({error:"Exeption thrown during execution."})}},i.prototype.newerThan=function(e){var t=new i(e);return this.versionMajor>t.versionMajor||this.versionMajor===t.versionMajor&&this.versionMinor>t.versionMinor};var a=0,s=1,o=4,u=5,f=6,A=7,T=8,b=9,_=10,h=11,I=12,N=13,y=14,E=15,l={DATA_TYPE_DOUBLE:{ordinal:0,size:8},DATA_TYPE_FLOAT:{ordinal:1,size:4},DATA_TYPE_INT8:{ordinal:2,size:1},DATA_TYPE_UINT8:{ordinal:3,size:1},DATA_TYPE_INT16:{ordinal:4,size:2},DATA_TYPE_UINT16:{ordinal:5,size:2},DATA_TYPE_INT32:{ordinal:6,size:4},DATA_TYPE_UINT32:{ordinal:7,size:4},DATA_TYPE_INT64:{ordinal:8,size:8},DATA_TYPE_UINT64:{ordinal:9,size:8}},S=0;for(var m in l)l[S]=l[m],S++;function P(e,t,r){this.name=e,this.type=t,this.numElements=r,this.byteSize=this.numElements*this.type.size}function M(e){if(this.attributes=[],this.byteSize=0,this.size=0,null!=e)for(var t=0;t<e.length;t++){var r=P[e[t]];this.attributes.push(r),this.byteSize+=r.byteSize,this.size++}}P.POSITION_CARTESIAN=new P(a,l.DATA_TYPE_FLOAT,3),P.RGBA_PACKED=new P(s,l.DATA_TYPE_INT8,4),P.COLOR_PACKED=P.RGBA_PACKED,P.RGB_PACKED=new P(s,l.DATA_TYPE_INT8,3),P.NORMAL_FLOATS=new P(o,l.DATA_TYPE_FLOAT,3),P.FILLER_1B=new P(u,l.DATA_TYPE_UINT8,1),P.INTENSITY=new P(f,l.DATA_TYPE_UINT16,1),P.CLASSIFICATION=new P(A,l.DATA_TYPE_UINT8,1),P.NORMAL_SPHEREMAPPED=new P(T,l.DATA_TYPE_UINT8,2),P.NORMAL_OCT16=new P(b,l.DATA_TYPE_UINT8,2),P.NORMAL=new P(_,l.DATA_TYPE_FLOAT,3),P.RETURN_NUMBER=new P(h,l.DATA_TYPE_UINT8,1),P.NUMBER_OF_RETURNS=new P(I,l.DATA_TYPE_UINT8,1),P.SOURCE_ID=new P(N,l.DATA_TYPE_UINT8,1),P.INDICES=new P(y,l.DATA_TYPE_UINT32,1),P.SPACING=new P(E,l.DATA_TYPE_FLOAT,1),M.prototype.add=function(e){this.attributes.push(e),this.byteSize+=e.byteSize,this.size++},M.prototype.hasColors=function(){for(var e in this.attributes){if(this.attributes[e].name===s)return!0}return!1},M.prototype.hasNormals=function(){for(var e in this.attributes){var t=this.attributes[e];if(t===P.NORMAL_SPHEREMAPPED||t===P.NORMAL_FLOATS||t===P.NORMAL||t===P.NORMAL_OCT16)return!0}return!1}}]);\n//# sourceMappingURL=main.map',null)}},function(e,t,n){e.exports=function(){return n(1)('!function(e){var r={};function n(t){if(r[t])return r[t].exports;var a=r[t]={i:t,l:!1,exports:{}};return e[t].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var a in e)n.d(t,a,function(r){return e[r]}.bind(null,a));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){"use strict";onmessage=function(e){if(e.data&&e.data.buffer){for(var r=e.data.buffer,n=e.data.numPoints,t=e.data.pointSize,a=e.data.pointFormatID,i=e.data.scale,o=e.data.offset,u=(new Uint8Array(r),new DataView(r)),f=new ArrayBuffer(40*n),m=(new DataView(f),{min:[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],max:[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY]}),s=[0,0,0],c=new ArrayBuffer(3*n*4),I=new ArrayBuffer(4*n),y=new ArrayBuffer(4*n),l=new ArrayBuffer(n),d=new ArrayBuffer(n),b=new ArrayBuffer(n),p=new ArrayBuffer(2*n),w=new Float32Array(c),N=new Uint8Array(I),A=new Float32Array(y),g=new Uint8Array(l),v=new Uint8Array(d),x=new Uint8Array(b),T=new Uint16Array(p),U=0;U<n;U++){var O=u.getInt32(U*t+0,!0),_=u.getInt32(U*t+4,!0),B=u.getInt32(U*t+8,!0),M=O*i[0]+o[0]-e.data.mins[0],S=_*i[1]+o[1]-e.data.mins[1],E=B*i[2]+o[2]-e.data.mins[2];w[3*U+0]=M,w[3*U+1]=S,w[3*U+2]=E,s[0]+=M/n,s[1]+=S/n,s[2]+=E/n,m.min[0]=Math.min(m.min[0],M),m.min[1]=Math.min(m.min[1],S),m.min[2]=Math.min(m.min[2],E),m.max[0]=Math.max(m.max[0],M),m.max[1]=Math.max(m.max[1],S),m.max[2]=Math.max(m.max[2],E);var F=u.getUint16(U*t+12,!0);A[U]=F;var P=u.getUint8(U*t+14,!0),h=7&P,V=(56&P)>>3;v[U]=h,x[U]=V;var j=u.getUint8(U*t+15,!0);g[U]=j;var Y=u.getUint16(U*t+18,!0);if(T[U]=Y,2===a){var D=u.getUint16(U*t+20,!0)/256,G=u.getUint16(U*t+22,!0)/256,R=u.getUint16(U*t+24,!0)/256;N[4*U+0]=D,N[4*U+1]=G,N[4*U+2]=R,N[4*U+3]=255}}var z=new ArrayBuffer(4*n),k=new Uint32Array(z);for(U=0;U<n;U++)k[U]=U;var q={mean:s,position:c,color:I,intensity:y,classification:l,returnNumber:d,numberOfReturns:b,pointSourceID:p,tightBoundingBox:m,indices:z};postMessage(q,[q.position,q.color,q.intensity,q.classification,q.returnNumber,q.numberOfReturns,q.pointSourceID,q.indices])}}}]);\n//# sourceMappingURL=main.map',null)}},function(e,t,n){e.exports=function(){return n(1)('!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";onmessage=function(e){var t=e.data.boundingBox,n=new Float32Array(e.data.position),r=n.length/3,o=t.max[0]-t.min[0],a=t.max[1]-t.min[1],i=(t.max[2],t.min[2],new Float32Array(4096));i.fill(-1/0);for(var u=0;u<r;u++){var f=n[3*u+0],l=n[3*u+1],c=n[3*u+2],d=f/o,s=l/a;i[parseInt(Math.min(64*d,63))+64*parseInt(Math.min(64*s,63))]=c}var p={dem:{width:64,height:64,data:i.buffer}};postMessage(p,[p.dem.data])}}]);\n//# sourceMappingURL=main.map',null)}},function(e,t,n){e.exports=function(){return n(1)('!function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t){onmessage=function(e){if(performance.mark("laslaz-start"),!e.data||!e.data.buffer)return;let t=e.data.buffer,r=e.data.numPoints,n=e.data.pointSize,a=e.data.pointFormatID,i=e.data.scale,o=e.data.offset,u=(new Uint8Array(t),new DataView(t)),f={min:[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],max:[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY]},l=[0,0,0],m=new ArrayBuffer(3*r*4),c=new ArrayBuffer(4*r),s=new ArrayBuffer(4*r),I=new ArrayBuffer(r),d=new ArrayBuffer(r),p=new ArrayBuffer(r),b=new ArrayBuffer(2*r),g=new Float32Array(m),N=new Uint8Array(c),w=new Float32Array(s),A=new Uint8Array(I),U=new Uint8Array(d),T=new Uint8Array(p),M=new Uint16Array(b),O=2==a||3==a,_=2==a?20:28,S=!1;if(O){let e,t,a,i;for(let o=0;o<r&&!S;++o)i=o*n,e=u.getUint16(i+_,!0),t=u.getUint16(i+_+2,!0),a=u.getUint16(i+_+4,!0),(e>255||t>255||a>255)&&(S=!0)}for(let t=0;t<r;t++){let a=u.getInt32(t*n+0,!0),m=u.getInt32(t*n+4,!0),c=u.getInt32(t*n+8,!0);x=a*i[0]+o[0]-e.data.mins[0],y=m*i[1]+o[1]-e.data.mins[1],z=c*i[2]+o[2]-e.data.mins[2],g[3*t+0]=x,g[3*t+1]=y,g[3*t+2]=z,l[0]+=x/r,l[1]+=y/r,l[2]+=z/r,f.min[0]=Math.min(f.min[0],x),f.min[1]=Math.min(f.min[1],y),f.min[2]=Math.min(f.min[2],z),f.max[0]=Math.max(f.max[0],x),f.max[1]=Math.max(f.max[1],y),f.max[2]=Math.max(f.max[2],z);let s=u.getUint16(t*n+12,!0);w[t]=s;let I=u.getUint8(t*n+14,!0),d=7&I,p=(56&I)>>3;U[t]=d,T[t]=p;let b=u.getUint8(t*n+15,!0);A[t]=b;let B=u.getUint16(t*n+18,!0);if(M[t]=B,O){let e=u.getUint16(t*n+_,!0),r=u.getUint16(t*n+_+2,!0),a=u.getUint16(t*n+_+4,!0);S&&(e/=256,r/=256,a/=256),N[4*t+0]=e,N[4*t+1]=r,N[4*t+2]=a,N[4*t+3]=255}}let B=new ArrayBuffer(4*r),E=new Uint32Array(B);for(let e=0;e<r;e++)E[e]=e;performance.mark("laslaz-end"),performance.clearMarks(),performance.clearMeasures();let F={mean:l,position:m,color:c,intensity:s,classification:I,returnNumber:d,numberOfReturns:p,pointSourceID:b,tightBoundingBox:f,indices:B};postMessage(F,[F.position,F.color,F.intensity,F.classification,F.returnNumber,F.numberOfReturns,F.pointSourceID,F.indices])}}]);\n//# sourceMappingURL=main.map',null)}},function(e,t,n){e.exports=function(){return n(1)('!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t){Potree={},onmessage=function(e){if(!e.data||!e.data.buffer)return;let t,r,n,i,a,u,o,f,s,c,l,m,d,y,b,A,g,w,p,x,M,U=e.data.buffer,h=new DataView(U),N=e.data.schema,B=e.data.scale,O=e.data.offset,_=e.data.mins,I=N.reduce((e,t)=>(e[t.name]=t,e),{}),v=e=>{let t=(e=>{let t=0;for(var r=0;r<N.length;++r){if(N[r].name==e)return t;t+=N[r].size}})(e),r=I[e].type,n=I[e].size;if("signed"==r)switch(n){case 1:return e=>h.getInt8(e+t);case 2:return e=>h.getInt16(e+t,!0);case 4:return e=>h.getInt32(e+t,!0);case 8:return e=>h.getInt64(e+t,!0)}if("unsigned"==r)switch(n){case 1:return e=>h.getUint8(e+t);case 2:return e=>h.getUint16(e+t,!0);case 4:return e=>h.getUint32(e+t,!0);case 8:return e=>h.getUint64(e+t,!0)}if("float"==r)switch(n){case 4:return e=>h.getFloat32(e+t,!0);case 8:return e=>h.getFloat64(e+t,!0)}let i=JSON.stringify(I[e]);throw new Error(`Invalid dimension specification for ${e}: ${i}`)},S=N.reduce((e,t)=>e+t.size,0),P=U.byteLength/S,R=!1;if(I.X&&I.Y&&I.Z&&(t=new ArrayBuffer(4*P*3),f=new Float32Array(t),b=[v("X"),v("Y"),v("Z")]),I.Red&&I.Green&&I.Blue){let e,t,n,i;r=new ArrayBuffer(4*P),s=new Uint8Array(r),A=[v("Red"),v("Green"),v("Blue")];for(let r=0;r<P&&!R;++r)i=r*S,e=A[0](i),t=A[1](i),n=A[2](i),(e>255||t>255||n>255)&&(R=!0)}I.Intensity&&(n=new ArrayBuffer(4*P),c=new Float32Array(n),g=v("Intensity")),I.Classification&&(i=new ArrayBuffer(P),l=new Uint8Array(i),w=v("Classification")),I.ReturnNumber&&(a=new ArrayBuffer(P),m=new Uint8Array(a),p=v("ReturnNumber")),I.NumberOfReturns&&(u=new ArrayBuffer(P),d=new Uint8Array(u),x=v("NumberOfReturns")),I.PointSourceId&&(o=new ArrayBuffer(2*P),y=new Uint16Array(o),M=v("PointSourceId"));let X,j,E,L,V,z,F=[0,0,0],C={min:[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],max:[-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE]};for(let e=0;e<P;++e){let t=e*S;f&&(X=b[0](t)*B.x+O.x-_[0],j=b[1](t)*B.y+O.y-_[1],E=b[2](t)*B.z+O.z-_[2],F[0]+=X/P,F[1]+=j/P,F[2]+=E/P,C.min[0]=Math.min(C.min[0],X),C.min[1]=Math.min(C.min[1],j),C.min[2]=Math.min(C.min[2],E),C.max[0]=Math.max(C.max[0],X),C.max[1]=Math.max(C.max[1],j),C.max[2]=Math.max(C.max[2],E),f[3*e+0]=X,f[3*e+1]=j,f[3*e+2]=E),s&&(L=A[0](t),V=A[1](t),z=A[2](t),R&&(L/=256,V/=256,z/=256),s[4*e+0]=L,s[4*e+1]=V,s[4*e+2]=z),c&&(c[e]=g(t)),l&&(l[e]=w(t)),m&&(m[e]=p(t)),d&&(d[e]=x(t)),y&&(y[e]=M(t))}let G=new ArrayBuffer(4*P),T=new Uint32Array(G);for(let e=0;e<P;++e)T[e]=e;let Y={numPoints:P,tightBoundingBox:C,mean:F,position:t,color:r,intensity:n,classification:i,returnNumber:a,numberOfReturns:u,pointSourceId:o,indices:G},Z=[Y.position,Y.color,Y.intensity,Y.classification,Y.returnNumber,Y.numberOfReturns,Y.pointSourceId,Y.indices].filter(e=>e);postMessage(Y,Z)}}]);\n//# sourceMappingURL=main.map',null)}},function(e,t,n){"use strict";n.r(t),n.d(t,"Global",(function(){return g})),n.d(t,"AttributeLocations",(function(){return ce})),n.d(t,"Classification",(function(){return fe})),n.d(t,"PointSizeType",(function(){return pe})),n.d(t,"PointShape",(function(){return me})),n.d(t,"PointColorType",(function(){return ge})),n.d(t,"TreeType",(function(){return ve})),n.d(t,"loadPointCloud",(function(){return ye})),n.d(t,"updateVisibility",(function(){return xe})),n.d(t,"updatePointClouds",(function(){return be})),n.d(t,"updateVisibilityStructures",(function(){return we})),n.d(t,"BinaryHeap",(function(){return he})),n.d(t,"LRU",(function(){return r})),n.d(t,"HelperUtils",(function(){return te})),n.d(t,"VersionUtils",(function(){return P})),n.d(t,"WorkerManager",(function(){return m})),n.d(t,"PointAttribute",(function(){return A})),n.d(t,"PointAttributes",(function(){return T})),n.d(t,"PointAttributeNames",(function(){return y})),n.d(t,"PointAttributeTypes",(function(){return x})),n.d(t,"Gradients",(function(){return ne})),n.d(t,"Points",(function(){return Ae})),n.d(t,"Shaders",(function(){return ie})),n.d(t,"DEM",(function(){return N})),n.d(t,"DEMNode",(function(){return B})),n.d(t,"PointCloudTree",(function(){return E})),n.d(t,"PointCloudArena4D",(function(){return ue})),n.d(t,"PointCloudOctree",(function(){return ae})),n.d(t,"PointCloudOctreeGeometry",(function(){return j})),n.d(t,"PointCloudOctreeGeometryNode",(function(){return Y})),n.d(t,"PointCloudArena4DGeometry",(function(){return de})),n.d(t,"PointCloudGreyhoundGeometry",(function(){return _})),n.d(t,"PointCloudEptGeometry",(function(){return Q})),n.d(t,"PointCloudEptGeometryNode",(function(){return $})),n.d(t,"PointCloudMaterial",(function(){return re})),n.d(t,"LASLoader",(function(){return U})),n.d(t,"BinaryLoader",(function(){return z})),n.d(t,"GreyhoundUtils",(function(){return O})),n.d(t,"GreyhoundLoader",(function(){return R})),n.d(t,"GreyhoundBinaryLoader",(function(){return C})),n.d(t,"POCLoader",(function(){return W})),n.d(t,"LASLAZLoader",(function(){return H})),n.d(t,"EptLoader",(function(){return ee})),n.d(t,"EptLaszipLoader",(function(){return q})),n.d(t,"EptBinaryLoader",(function(){return X})),n.d(t,"BasicGroup",(function(){return Te})),n.d(t,"Group",(function(){return Be})),n.d(t,"XHRFactory",(function(){return M}));class i{constructor(e){this.previous=null,this.next=null,this.node=e}}class r{constructor(){this.first=null,this.last=null,this.items={},this.elements=0,this.numPoints=0}size(){return this.elements}contains(e){return null==this.items[e.id]}touch(e){var t;e.loaded&&(null==this.items[e.id]?((t=new i(e)).previous=this.last,this.last=t,null!==t.previous&&(t.previous.next=t),this.items[e.id]=t,this.elements++,null===this.first&&(this.first=t),this.numPoints+=e.numPoints):null===(t=this.items[e.id]).previous?null!==t.next&&(this.first=t.next,this.first.previous=null,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t):null!==t.next&&(t.previous.next=t.next,t.next.previous=t.previous,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t))}remove(e){var t=this.items[e.id];t&&(1===this.elements?(this.first=null,this.last=null):(t.previous||(this.first=t.next,this.first.previous=null),t.next||(this.last=t.previous,this.last.next=null),t.previous&&t.next&&(t.previous.next=t.next,t.next.previous=t.previous)),delete this.items[e.id],this.elements--,this.numPoints-=e.numPoints)}getLRUItem(){return null===this.first?null:this.first.node}toString(){for(var e="{ ",t=this.first;null!==t;)e+=t.node.id,null!==t.next&&(e+=", "),t=t.next;return e+="}",e+="("+this.size()+")"}freeMemory(){if(!(this.elements<=1))for(;this.numPoints>g.pointLoadLimit;){var e=this.first.node;this.disposeDescendants(e)}}disposeDescendants(e){var t=[];for(t.push(e);t.length>0;){var n=t.pop();for(var i in n.dispose(),this.remove(n),n.children){if(n.children.hasOwnProperty(i))n.children[i].loaded&&t.push(n.children[i])}}}}var o=n(2),a=n.n(o),s=n(3),u=n.n(s),l=n(4),d=n.n(l),h=n(5),c=n.n(h),f=n(6),p=n.n(f);class m{constructor(){this.workers=[];for(var e=0;e<7;e++)this.workers.push([])}getWorker(e){if(this.workers[e].length>0)return this.workers[e].pop();switch(e){case 0:return new a.a;case 1:throw"LASLAZWorker not implemented";case 2:return new u.a;case 3:throw"GreyhoundBinaryDecoderWorker not implemented";case 4:return new d.a;case 5:return new c.a;case 6:return new p.a;default:throw"Unknown worker requested"}}returnWorker(e,t){this.workers[e].push(t)}runTask(e,t,n,i){var r=this,o=this.getWorker(e);o.onmessage=function(n){t(n),r.returnWorker(e,o)},void 0!==i?o.postMessage(n,i):o.postMessage(n)}}m.BINARY_DECODER=0,m.LAS_LAZ=1,m.LAS_DECODER=2,m.GREYHOUND=3,m.DEM=4,m.EPT_LAS_ZIP_DECODER=5,m.EPT_BINARY_DECODER=6;var g={debug:{},workerPath:function(){var e=function(){if(document&&document.currentScript)return document.currentScript;const e=document.getElementsByTagName("script");return e&&e.length?e[e.length-1].getAttribute("src"):null}();if(e&&e.src){var t=new URL(e.src+"/..").href;return"/"===t.slice(-1)&&(t=t.slice(0,-1)),t}return console.error("Potree: Was unable to find its script path using document.currentScript."),""}(),maxNodesLoadGPUFrame:20,maxDEMLevel:0,maxNodesLoading:void 0!==navigator.hardwareConcurrency?navigator.hardwareConcurrency:4,pointLoadLimit:1e10,numNodesLoading:0,measureTimings:!1,workerPool:new m,lru:new r,pointcloudTransformVersion:void 0},v=n(0),y={POSITION_CARTESIAN:0,COLOR_PACKED:1,COLOR_FLOATS_1:2,COLOR_FLOATS_255:3,NORMAL_FLOATS:4,FILLER:5,INTENSITY:6,CLASSIFICATION:7,NORMAL_SPHEREMAPPED:8,NORMAL_OCT16:9,NORMAL:10,RETURN_NUMBER:11,NUMBER_OF_RETURNS:12,SOURCE_ID:13,INDICES:14,SPACING:15},x={DATA_TYPE_DOUBLE:{ordinal:0,size:8},DATA_TYPE_FLOAT:{ordinal:1,size:4},DATA_TYPE_INT8:{ordinal:2,size:1},DATA_TYPE_UINT8:{ordinal:3,size:1},DATA_TYPE_INT16:{ordinal:4,size:2},DATA_TYPE_UINT16:{ordinal:5,size:2},DATA_TYPE_INT32:{ordinal:6,size:4},DATA_TYPE_UINT32:{ordinal:7,size:4},DATA_TYPE_INT64:{ordinal:8,size:8},DATA_TYPE_UINT64:{ordinal:9,size:8}},b=0;for(var w in x)x[b]=x[w],b++;function A(e,t,n){this.name=e,this.type=t,this.numElements=n,this.byteSize=this.numElements*this.type.size}function T(e){if(this.attributes=[],this.byteSize=0,this.size=0,null!=e)for(var t=0;t<e.length;t++){var n=A[e[t]];this.attributes.push(n),this.byteSize+=n.byteSize,this.size++}}A.POSITION_CARTESIAN=new A(y.POSITION_CARTESIAN,x.DATA_TYPE_FLOAT,3),A.RGBA_PACKED=new A(y.COLOR_PACKED,x.DATA_TYPE_INT8,4),A.COLOR_PACKED=A.RGBA_PACKED,A.RGB_PACKED=new A(y.COLOR_PACKED,x.DATA_TYPE_INT8,3),A.NORMAL_FLOATS=new A(y.NORMAL_FLOATS,x.DATA_TYPE_FLOAT,3),A.FILLER_1B=new A(y.FILLER,x.DATA_TYPE_UINT8,1),A.INTENSITY=new A(y.INTENSITY,x.DATA_TYPE_UINT16,1),A.CLASSIFICATION=new A(y.CLASSIFICATION,x.DATA_TYPE_UINT8,1),A.NORMAL_SPHEREMAPPED=new A(y.NORMAL_SPHEREMAPPED,x.DATA_TYPE_UINT8,2),A.NORMAL_OCT16=new A(y.NORMAL_OCT16,x.DATA_TYPE_UINT8,2),A.NORMAL=new A(y.NORMAL,x.DATA_TYPE_FLOAT,3),A.RETURN_NUMBER=new A(y.RETURN_NUMBER,x.DATA_TYPE_UINT8,1),A.NUMBER_OF_RETURNS=new A(y.NUMBER_OF_RETURNS,x.DATA_TYPE_UINT8,1),A.SOURCE_ID=new A(y.SOURCE_ID,x.DATA_TYPE_UINT8,1),A.INDICES=new A(y.INDICES,x.DATA_TYPE_UINT32,1),A.SPACING=new A(y.SPACING,x.DATA_TYPE_FLOAT,1),T.prototype.add=function(e){this.attributes.push(e),this.byteSize+=e.byteSize,this.size++},T.prototype.hasColors=function(){for(var e in this.attributes){if(this.attributes[e].name===y.COLOR_PACKED)return!0}return!1},T.prototype.hasNormals=function(){for(var e in this.attributes){var t=this.attributes[e];if(t===A.NORMAL_SPHEREMAPPED||t===A.NORMAL_FLOATS||t===A.NORMAL||t===A.NORMAL_OCT16)return!0}return!1};class B{constructor(e,t,n){this.name=e,this.box=t,this.tileSize=n,this.level=this.name.length-1,this.data=new Float32Array(n*n),this.data.fill(-1/0),this.children=[],this.mipMap=[this.data],this.mipMapNeedsUpdate=!0}createMipMap(){this.mipMap=[this.data];for(var e=this.tileSize,t=parseInt(e/2),n=this.data;t>1;){for(var i=new Float32Array(t*t),r=0;r<t;r++)for(var o=0;o<t;o++){var a=n[2*r+0+2*o*e],s=n[2*r+0+2*o*e+e],u=n[2*r+1+2*o*e],l=n[2*r+1+2*o*e+e],[d,h]=[0,0];isFinite(a)&&(d+=a,h+=1),isFinite(s)&&(d+=s,h+=1),isFinite(u)&&(d+=u,h+=1),isFinite(l)&&(d+=l,h+=1),d/=h,i[r+o*t]=d}this.mipMap.push(i),n=i,e=t,t=parseInt(t/2)}this.mipMapNeedsUpdate=!1}uv(e){var t=this.box.getSize(new v.Vector3);return[(e.x-this.box.min.x)/t.x,(e.y-this.box.min.y)/t.y]}heightAtMipMapLevel(e,t){var n=this.uv(e),i=parseInt(this.tileSize/parseInt(2**t)),r=this.mipMap[t],o=Math.min(n[0]*i,i-1),a=Math.min(n[1]*i,i-1),s=o%1,u=a%1,[l,d]=[Math.floor(o),Math.ceil(o)],[h,c]=[Math.floor(a),Math.ceil(a)],f=r[l+i*h],p=r[l+i*c],m=r[d+i*h],g=r[d+i*c],v=isFinite(f)?(1-s)*(1-u):0,y=isFinite(p)?(1-s)*u:0,x=isFinite(m)?s*(1-u):0,b=isFinite(g)?s*u:0,w=v+y+x+b;if(v/=w,y/=w,x/=w,b/=w,0===w)return null;var A=0;return isFinite(f)&&(A+=f*v),isFinite(p)&&(A+=p*y),isFinite(m)&&(A+=m*x),isFinite(g)&&(A+=g*b),A}height(e){for(var t=null,n=0;n<this.mipMap.length;n++)if(null!==(t=this.heightAtMipMapLevel(e,n)))return t;return t}traverse(e,t=0){for(var n of(e(this,t),this.children.filter(e=>void 0!==e)))n.traverse(e,t+1)}}class N{constructor(e){this.pointcloud=e,this.matrix=null,this.boundingBox=null,this.tileSize=64,this.root=null,this.version=0}expandAndFindByBox(e,t){if(0===t)return[this.root];for(var n=[],i=[this.root];i.length>0;){var r=i.pop(),o=r.box.getSize(new v.Vector3),a={x:(e.min.x-r.box.min.x)/o.x,y:(e.min.y-r.box.min.y)/o.y},s={x:(e.max.x-r.box.max.x)/o.x,y:(e.max.y-r.box.max.y)/o.y};for(var u of(a.x=a.x<.5?0:1,a.y=a.y<.5?0:1,s.x=s.x<.5?0:1,s.y=s.y<.5?0:1,0===a.x&&0===a.y&&1===s.x&&1===s.y?[0,1,2,3]:a.x===s.x&&a.y===s.y?[a.x<<1|a.y]:[a.x<<1|a.y,s.x<<1|s.y])){if(void 0===r.children[u]){var l=r.box.clone();(2&u)>0?l.min.x+=o.x/2:l.max.x-=o.x/2,(1&u)>0?l.min.y+=o.y/2:l.max.y-=o.y/2;var d=new B(r.name+u,l,this.tileSize);r.children[u]=d}(d=r.children[u]).level<t?i.push(d):n.push(d)}}return n}childIndex(e){var[t,n]=e.map(e=>e<.5?0:1);return t<<1|n}height(e){if(!this.root)return 0;for(var t=null,n=[this.root];;){var i=n[n.length-1],r=i.height(e);null!==r&&(t=r);var o=i.uv(e),a=this.childIndex(o);if(!i.children[a])break;n.push(i.children[a])}return t+this.pointcloud.position.z}update(e){null!==this.matrix&&this.matrix.equals(this.pointcloud.matrixWorld)||(this.matrix=this.pointcloud.matrixWorld.clone(),this.boundingBox=this.pointcloud.boundingBox.clone().applyMatrix4(this.matrix),this.root=new B("r",this.boundingBox,this.tileSize),this.version++);var t=null;for(var n of e)if(void 0===n.demVersion||n.demVersion<this.version){t=n;break}if(null!==t){var i=t.getBoundingBox().clone().applyMatrix4(this.matrix),r=i.getSize(new v.Vector3),o=this.expandAndFindByBox(i,t.getLevel());t.demVersion=this.version;var a=t.geometryNode.geometry.attributes.position.array,s={boundingBox:{min:t.getBoundingBox().min.toArray(),max:t.getBoundingBox().max.toArray()},position:new Float32Array(a).buffer},u=[s.position],l=this;g.workerPool.runTask(m.DEM,(function(e){var t=new Float32Array(e.data.dem.data);for(var n of o){for(var a=n.box.getSize(new v.Vector3),s=0;s<l.tileSize;s++)for(var u=0;u<l.tileSize;u++){var d=s/(l.tileSize-1),h=u/(l.tileSize-1),c=n.box.min.x+d*a.x,f=n.box.min.y+h*a.y,p=l.tileSize*(c-i.min.x)/r.x,m=l.tileSize*(f-i.min.y)/r.y;p<0||p>l.tileSize||(m<0||m>l.tileSize||(p=Math.min(Math.floor(p),l.tileSize-1),m=Math.min(Math.floor(m),l.tileSize-1),n.data[s+l.tileSize*u]=t[p+l.tileSize*m]))}n.createMipMap(),n.mipMapNeedsUpdate=!0}}),s,u)}}}class S{constructor(){this.needsTransformUpdate=!0}getChildren(){}getBoundingBox(){}isLoaded(){}isGeometryNode(){}isTreeNode(){}getLevel(){}getBoundingSphere(){}}class E extends v.Object3D{constructor(){super(),this.dem=new N(this)}initialized(){return null!==this.root}}class _{constructor(){this.spacing=0,this.boundingBox=null,this.root=null,this.nodes=null,this.pointAttributes={},this.hierarchyStepSize=-1,this.loader=null,this.schema=null,this.baseDepth=null,this.offset=null,this.projection=null,this.boundingSphere=null,this.serverURL=null,this.normalize={color:!1,intensity:!1}}}function I(e,t,n,i,r){this.id=I.IDCount++,this.name=e,this.index=parseInt(e.charAt(e.length-1)),this.pcoGeometry=t,this.geometry=null,this.boundingBox=n,this.boundingSphere=n.getBoundingSphere(new v.Sphere),this.scale=i,this.offset=r,this.children={},this.numPoints=0,this.level=null,this.loaded=!1,this.oneTimeDisposeHandlers=[],this.baseLoaded=!1;var o=new v.Vector3,a=this.boundingBox.clone();a.min.sub(this.pcoGeometry.boundingBox.getCenter(o)),a.max.sub(this.pcoGeometry.boundingBox.getCenter(o)),this.scale&&(a.min.multiplyScalar(1/this.scale),a.max.multiplyScalar(1/this.scale)),this.greyhoundBounds=a,this.greyhoundOffset=this.pcoGeometry.offset.clone().add(this.pcoGeometry.boundingBox.getSize(new v.Vector3).multiplyScalar(.5))}function P(e){this.version=e;var t=-1===e.indexOf(".")?e.length:e.indexOf(".");this.versionMajor=parseInt(e.substr(0,t)),this.versionMinor=parseInt(e.substr(t+1)),0===this.versionMinor.length&&(this.versionMinor=0)}I.IDCount=0,I.prototype=Object.create(S.prototype),I.prototype.isGeometryNode=function(){return!0},I.prototype.isTreeNode=function(){return!1},I.prototype.isLoaded=function(){return this.loaded},I.prototype.getBoundingSphere=function(){return this.boundingSphere},I.prototype.getBoundingBox=function(){return this.boundingBox},I.prototype.getLevel=function(){return this.level},I.prototype.getChildren=function(){for(var e=[],t=0;t<8;++t)this.children[t]&&e.push(this.children[t]);return e},I.prototype.getURL=function(){var e=this.pcoGeometry.schema,t=this.greyhoundBounds,n=t.min.x+","+t.min.y+","+t.min.z+","+t.max.x+","+t.max.y+","+t.max.z,i=this.pcoGeometry.serverURL+"read?depthBegin="+(this.baseLoaded?this.level+this.pcoGeometry.baseDepth:0)+"&depthEnd="+(this.level+this.pcoGeometry.baseDepth+1)+"&bounds=["+n+"]&schema="+JSON.stringify(e)+"&compress=true";if(this.scale&&(i+="&scale="+this.scale),this.greyhoundOffset){var r=this.greyhoundOffset;i+="&offset=["+r.x+","+r.y+","+r.z+"]"}return this.baseLoaded||(this.baseLoaded=!0),i},I.prototype.addChild=function(e){this.children[e.index]=e,e.parent=this},I.prototype.load=function(){!0===this.loading||!0===this.loaded||g.numNodesLoading>=g.maxNodesLoading||(this.loading=!0,g.numNodesLoading++,this.level%this.pcoGeometry.hierarchyStepSize==0&&this.hasChildren?this.loadHierarchyThenPoints():this.loadPoints())},I.prototype.loadPoints=function(){this.pcoGeometry.loader.load(this)},I.prototype.loadHierarchyThenPoints=function(){var e=[0,2,1,3,4,6,5,7],t=function(n,i,r){var o,a;Object.keys(n).forEach((function(s){if("n"!==s){switch(s){case"swd":o=n.swd,a=i+e[0];break;case"nwd":o=n.nwd,a=i+e[1];break;case"swu":o=n.swu,a=i+e[2];break;case"nwu":o=n.nwu,a=i+e[3];break;case"sed":o=n.sed,a=i+e[4];break;case"ned":o=n.ned,a=i+e[5];break;case"seu":o=n.seu,a=i+e[6];break;case"neu":o=n.neu,a=i+e[7]}var u,l;r.push({children:(u=o,l=0,Object.keys(u).forEach((function(t){"swd"===t?l+=1<<e[0]:"nwd"===t?l+=1<<e[1]:"swu"===t?l+=1<<e[2]:"nwu"===t?l+=1<<e[3]:"sed"===t?l+=1<<e[4]:"ned"===t?l+=1<<e[5]:"seu"===t?l+=1<<e[6]:"neu"===t&&(l+=1<<e[7])})),l),numPoints:o.n,name:a}),t(o,a,r)}}))};if(this.level%this.pcoGeometry.hierarchyStepSize==0){var n=this.level+this.pcoGeometry.baseDepth,i=n+this.pcoGeometry.hierarchyStepSize+2,r=this.greyhoundBounds,o=r.min.x+","+r.min.y+","+r.min.z+","+r.max.x+","+r.max.y+","+r.max.z,a=this.pcoGeometry.serverURL+"hierarchy?bounds=["+o+"]&depthBegin="+n+"&depthEnd="+i;if(this.scale&&(a+="&scale="+this.scale),this.greyhoundOffset){var s=this.greyhoundOffset;a+="&offset=["+s.x+","+s.y+","+s.z+"]"}var u=this,l=XHRFactory.createXMLHttpRequest();l.overrideMimeType("text/plain"),l.open("GET",a,!0),l.onload=function(e){try{!function(e,n){var i=[];e.numPoints=n.n,t(n,e.name,i);var r={};r[e.name]=e;for(var o=e.pcoGeometry,a=0;a<i.length;a++){var s=i[a].name,u=i[a].numPoints,l=parseInt(s.charAt(s.length-1)),d=r[s.substring(0,s.length-1)],h=s.length-1,c=new I(s,o,R.createChildAABB(d.boundingBox,l),e.scale,e.offset);c.level=h,c.numPoints=u,c.hasChildren=i[a].children>0,c.spacing=o.spacing/Math.pow(2,h),d.addChild(c),r[s]=c}e.loadPoints()}(u,JSON.parse(l.responseText)||{})}catch(e){g.numNodesLoading--,console.error("Potree: Exception thrown parsing points.",e)}},l.onerror=function(e){console.log("Potree: Failed to load file! HTTP status "+l.status+", file:"+a,e)},l.send(null)}},I.prototype.getNumPoints=function(){return this.numPoints},I.prototype.dispose=function(){if(this.geometry&&null!=this.parent){this.geometry.dispose(),this.geometry=null,this.loaded=!1;for(var e=0;e<this.oneTimeDisposeHandlers.length;e++){(0,this.oneTimeDisposeHandlers[e])()}this.oneTimeDisposeHandlers=[]}},Object.assign(I.prototype,v.EventDispatcher.prototype),P.prototype.newerThan=function(e){var t=new P(e);return this.versionMajor>t.versionMajor||this.versionMajor===t.versionMajor&&this.versionMinor>t.versionMinor},P.prototype.equalOrHigher=function(e){var t=new P(e);return this.versionMajor>t.versionMajor||this.versionMajor===t.versionMajor&&this.versionMinor>=t.versionMinor},P.prototype.upTo=function(e){return!this.newerThan(e)};const M={config:{withCredentials:!1,customHeaders:[{header:null,value:null}]},createXMLHttpRequest:function(){let e=new XMLHttpRequest;if(this.config.customHeaders&&Array.isArray(this.config.customHeaders)&&this.config.customHeaders.length>0){let t=e.open,n=this.config.customHeaders;e.open=function(){t.apply(this,[].slice.call(arguments)),n.forEach((function(t){t.header&&t.value&&e.setRequestHeader(t.header,t.value)}))}}return e},fetch:async function(e){const t=new Headers;this.config.customHeaders&&this.config.customHeaders.forEach((function(e){e.header&&e.value&&t.append(e.header,e.value)}));const n={headers:t,credentials:M.config.withCredentials?"include":"same-origin"};return fetch(e,n)}};class C{constructor(e,t,n){this.version="string"==typeof e?new P(e):e,this.boundingBox=t,this.scale=n}load(e){if(!e.loaded){var t=this,n=e.getURL(),i=M.createXMLHttpRequest();i.overrideMimeType("text/plain"),i.open("GET",n,!0),i.responseType="arraybuffer",i.overrideMimeType("text/plain; charset=x-user-defined"),i.onload=function(){try{t.parse(e,i.response)}catch(e){console.error("Potree: Exception thrown parsing points.",e),g.numNodesLoading--}},i.onerror=function(e){g.numNodesLoading--,console.error("Potree: Failed to load file.",i,n)},i.send(null)}}parse(e,t){var n=new DataView(t,t.byteLength-4,4).getUint32(0,!0),i=e.pcoGeometry.pointAttributes;e.numPoints=n;var r=e.boundingBox,o=new THREE.Vector3,a=e.pcoGeometry.boundingBox.getCenter(o).sub(e.boundingBox.min),s={buffer:t,pointAttributes:i,version:this.version.version,schema:e.pcoGeometry.schema,min:[r.min.x,r.min.y,r.min.z],max:[r.max.x,r.max.y,r.max.z],offset:a.toArray(),scale:this.scale,normalize:e.pcoGeometry.normalize};g.workerPool.runTask(m.GREYHOUND,(function(t){var n=t.data,i=n.attributeBuffers,r=new THREE.Box3((new THREE.Vector3).fromArray(n.tightBoundingBox.min),(new THREE.Vector3).fromArray(n.tightBoundingBox.max)),o=new THREE.BufferGeometry;for(var a in i){var s=i[a].buffer;if(parseInt(a)===y.POSITION_CARTESIAN)o.setAttribute("position",new THREE.BufferAttribute(new Float32Array(s),3));else if(parseInt(a)===y.COLOR_PACKED)o.setAttribute("color",new THREE.BufferAttribute(new Uint8Array(s),4,!0));else if(parseInt(a)===y.INTENSITY)o.setAttribute("intensity",new THREE.BufferAttribute(new Float32Array(s),1));else if(parseInt(a)===y.CLASSIFICATION)o.setAttribute("classification",new THREE.BufferAttribute(new Uint8Array(s),1));else if(parseInt(a)===y.NORMAL_SPHEREMAPPED)o.setAttribute("normal",new THREE.BufferAttribute(new Float32Array(s),3));else if(parseInt(a)===y.NORMAL_OCT16)o.setAttribute("normal",new THREE.BufferAttribute(new Float32Array(s),3));else if(parseInt(a)===y.NORMAL)o.setAttribute("normal",new THREE.BufferAttribute(new Float32Array(s),3));else if(parseInt(a)===y.INDICES){(u=new THREE.BufferAttribute(new Uint8Array(s),4)).normalized=!0,o.setAttribute("indices",u)}else if(parseInt(a)===y.SPACING){var u=new THREE.BufferAttribute(new Float32Array(s),1);o.setAttribute("spacing",u)}}r.max.sub(r.min),r.min.set(0,0,0),e.numPoints=n.numPoints,e.geometry=o,e.mean=new THREE.Vector3(...n.mean),e.tightBoundingBox=r,e.loaded=!0,e.loading=!1,g.numNodesLoading--}),s,[s.buffer])}}class O{static getQueryParam(e){e=e.replace(/[[\]]/g,"\\$&");var t=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(window.location.href);return t?t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"":null}static createSchema(e){var t=[{name:"X",size:4,type:"signed"},{name:"Y",size:4,type:"signed"},{name:"Z",size:4,type:"signed"}];return e.forEach((function(e){"COLOR_PACKED"===e?(t.push({name:"Red",size:2,type:"unsigned"}),t.push({name:"Green",size:2,type:"unsigned"}),t.push({name:"Blue",size:2,type:"unsigned"})):"INTENSITY"===e?t.push({name:"Intensity",size:2,type:"unsigned"}):"CLASSIFICATION"===e&&t.push({name:"Classification",size:1,type:"unsigned"})})),t}static fetch(e,t){var n=M.createXMLHttpRequest();n.overrideMimeType("text/plain"),n.open("GET",e,!0),n.onreadystatechange=function(){4===n.readyState&&(200===n.status||0===n.status?t(null,n.responseText):t(n.responseText))},n.send(null)}static fetchBinary(e,t){var n=M.createXMLHttpRequest();n.overrideMimeType("text/plain"),n.open("GET",e,!0),n.responseType="arraybuffer",n.onreadystatechange=function(){4===n.readyState&&(200===n.status||0===n.status?t(null,n.response):t(n.responseText))},n.send(null)}static pointSizeFrom(e){return e.reduce((e,t)=>e+t.size,0)}static getNormalization(e,t,n){var i=[{name:"X",size:4,type:"floating"},{name:"Y",size:4,type:"floating"},{name:"Z",size:4,type:"floating"},{name:"Red",size:2,type:"unsigned"},{name:"Green",size:2,type:"unsigned"},{name:"Blue",size:2,type:"unsigned"},{name:"Intensity",size:2,type:"unsigned"}],r=e+"read?depth="+t+"&schema="+JSON.stringify(i);O.fetchBinary(r,(function(e,t){if(e)throw new Error(e);for(var r=new DataView(t),o=t.byteLength-4,a=O.pointSizeFrom(i),s=!1,u=!1,l=0;l<o&&((r.getUint16(l+12,!0)>255||r.getUint16(l+14,!0)>255||r.getUint16(l+16,!0)>255)&&(s=!0),r.getUint16(l+18,!0)>255&&(u=!0),!s||!u);l+=a);n(null,{color:s,intensity:u})}))}}function R(){}R.loadInfoJSON=function(e,t){},R.load=function(e,t){try{var n=e.split("greyhound://")[1];1===n.split("http://").length&&1===n.split("https://").length&&(n="http://"+n),O.fetch(n+"info",(function(e,i){if(e)throw new Error(e);var r=JSON.parse(i),o=new P("1.4"),a=r.bounds,s=r.scale||.01;Array.isArray(s)&&(s=Math.min(s[0],s[1],s[2])),O.getQueryParam("scale")&&(s=parseFloat(O.getQueryParam("scale")));var u=Math.max(8,r.baseDepth),l=["POSITION_CARTESIAN"],d=!1,h=!1,c=!1;r.schema.forEach((function(e){"Intensity"===e.name&&l.push("INTENSITY"),"Classification"===e.name&&l.push("CLASSIFICATION"),"Red"===e.name?d=!0:"Green"===e.name?h=!0:"Blue"===e.name&&(c=!0)})),d&&h&&c&&l.push("COLOR_PACKED");var f=new _;f.serverURL=n,f.spacing=(a[3]-a[0])/Math.pow(2,u),f.baseDepth=u,f.hierarchyStepSize=5,f.schema=O.createSchema(l);var p=O.pointSizeFrom(f.schema);f.pointAttributes=new T(l),f.pointAttributes.byteSize=p;var m=new THREE.Box3((new THREE.Vector3).fromArray(a,0),(new THREE.Vector3).fromArray(a,3)),g=m.min.clone();m.max.sub(m.min),m.min.set(0,0,0),f.projection=r.srs,f.boundingBox=m,f.boundingSphere=m.getBoundingSphere(new THREE.Sphere),f.scale=s,f.offset=g,f.loader=new C(o,m,f.scale);var v={},y=new I("r",f,m,s,g);y.level=0,y.hasChildren=!0,y.numPoints=r.numPoints,y.spacing=f.spacing,f.root=y,f.root.load(),v.r=y,f.nodes=v,O.getNormalization(n,r.baseDepth,(function(e,n){n.color&&(f.normalize.color=!0),n.intensity&&(f.normalize.intensity=!0),t(f)}))}))}catch(n){console.log("Potree: Loading failed.",e,n),t()}},R.loadPointAttributes=function(e){for(var t=e.pointAttributes,n=new T,i=0;i<t.length;i++){var r=A[t[i]];n.add(r)}return n},R.createChildAABB=function(e,t){var n=e.min,i=e.max,r=(new THREE.Vector3).copy(i).sub(n).multiplyScalar(.5),o=new THREE.Vector3(r.x,0,0),a=new THREE.Vector3(0,r.y,0),s=new THREE.Vector3(0,0,r.z),u=n,l=(new THREE.Vector3).add(n).add(r);return 1===t?(n=(new THREE.Vector3).copy(u).add(s),i=(new THREE.Vector3).copy(l).add(s)):3===t?(n=(new THREE.Vector3).copy(u).add(s).add(a),i=(new THREE.Vector3).copy(l).add(s).add(a)):0===t?(n=u,i=l):2===t?(n=(new THREE.Vector3).copy(u).add(a),i=(new THREE.Vector3).copy(l).add(a)):5===t?(n=(new THREE.Vector3).copy(u).add(s).add(o),i=(new THREE.Vector3).copy(l).add(s).add(o)):7===t?(n=(new THREE.Vector3).copy(u).add(r),i=(new THREE.Vector3).copy(l).add(r)):4===t?(n=(new THREE.Vector3).copy(u).add(o),i=(new THREE.Vector3).copy(l).add(o)):6===t&&(n=(new THREE.Vector3).copy(u).add(o).add(a),i=(new THREE.Vector3).copy(l).add(o).add(a)),new THREE.Box3(n,i)};class z{constructor(e,t,n){this.version="string"==typeof e?new P(e):e,this.boundingBox=t,this.scale=n}load(e){if(!e.loaded){var t=e.getURL();this.version.equalOrHigher("1.4")&&(t+=".bin");var n=this,i=M.createXMLHttpRequest();i.open("GET",t,!0),i.responseType="arraybuffer",i.overrideMimeType("text/plain; charset=x-user-defined"),i.onload=function(){try{n.parse(e,i.response)}catch(e){g.numNodesLoading--,console.error("Potree: Exception thrown parsing points.",e)}},i.onerror=function(e){g.numNodesLoading--,console.error("Potree: Failed to load file.",i,t)},i.send(null)}}parse(e,t){var n=e.pcoGeometry.pointAttributes,i=t.byteLength/e.pcoGeometry.pointAttributes.byteSize;this.version.upTo("1.5")&&(e.numPoints=i);var r={buffer:t,pointAttributes:n,version:this.version.version,min:[e.boundingBox.min.x,e.boundingBox.min.y,e.boundingBox.min.z],offset:[e.pcoGeometry.offset.x,e.pcoGeometry.offset.y,e.pcoGeometry.offset.z],scale:this.scale,spacing:e.spacing,hasChildren:e.hasChildren,name:e.name};g.workerPool.runTask(m.BINARY_DECODER,(function(t){var i=t.data;if(void 0!==i.error)return g.numNodesLoading--,void console.error("Potree: Binary worker error.",i);var r=i.attributeBuffers,o=new v.Box3((new v.Vector3).fromArray(i.tightBoundingBox.min),(new v.Vector3).fromArray(i.tightBoundingBox.max)),a=new v.BufferGeometry;for(var s in r){var u=r[s].buffer;if(parseInt(s)===y.POSITION_CARTESIAN)a.setAttribute("position",new v.BufferAttribute(new Float32Array(u),3));else if(parseInt(s)===y.COLOR_PACKED)a.setAttribute("color",new v.BufferAttribute(new Uint8Array(u),4,!0));else if(parseInt(s)===y.INTENSITY)a.setAttribute("intensity",new v.BufferAttribute(new Float32Array(u),1));else if(parseInt(s)===y.CLASSIFICATION)a.setAttribute("classification",new v.BufferAttribute(new Uint8Array(u),1));else if(parseInt(s)===y.NORMAL_SPHEREMAPPED)a.setAttribute("normal",new v.BufferAttribute(new Float32Array(u),3));else if(parseInt(s)===y.NORMAL_OCT16)a.setAttribute("normal",new v.BufferAttribute(new Float32Array(u),3));else if(parseInt(s)===y.NORMAL)a.setAttribute("normal",new v.BufferAttribute(new Float32Array(u),3));else if(parseInt(s)===y.INDICES){(l=new v.BufferAttribute(new Uint8Array(u),4)).normalized=!0,a.setAttribute("indices",l)}else if(parseInt(s)===y.SPACING){var l=new v.BufferAttribute(new Float32Array(u),1);a.setAttribute("spacing",l)}}o.max.sub(o.min),o.min.set(0,0,0);var d=t.data.buffer.byteLength/n.byteSize;e.numPoints=d,e.geometry=a,e.mean=new v.Vector3(...i.mean),e.tightBoundingBox=o,e.loaded=!0,e.loading=!1,e.estimatedSpacing=i.estimatedSpacing,g.numNodesLoading--}),r,[r.buffer])}}var D=[function(e){return{position:[e.getInt32(0,!0),e.getInt32(4,!0),e.getInt32(8,!0)],intensity:e.getUint16(12,!0),classification:e.getUint8(16,!0)}},function(e){return{position:[e.getInt32(0,!0),e.getInt32(4,!0),e.getInt32(8,!0)],intensity:e.getUint16(12,!0),classification:e.getUint8(16,!0)}},function(e){return{position:[e.getInt32(0,!0),e.getInt32(4,!0),e.getInt32(8,!0)],intensity:e.getUint16(12,!0),classification:e.getUint8(16,!0),color:[e.getUint16(20,!0),e.getUint16(22,!0),e.getUint16(24,!0)]}},function(e){return{position:[e.getInt32(0,!0),e.getInt32(4,!0),e.getInt32(8,!0)],intensity:e.getUint16(12,!0),classification:e.getUint8(16,!0),color:[e.getUint16(28,!0),e.getUint16(30,!0),e.getUint16(32,!0)]}}];function L(e,t,n,i){i=void 0===i||0===i?1:i;var r=new t(e.slice(n,n+t.BYTES_PER_ELEMENT*i));if(void 0===i||1===i)return r[0];for(var o=[],a=0;a<i;a++)o.push(r[a]);return o}function U(e){this.arraybuffer=e}function F(e){var t=this;this.arraybuffer=e,this.nextCB=null,this.dorr=function(e,n){t.nextCB=n,g.workerPool.runTask(m.LAS_LAZ,(function(e){null!==t.nextCB&&(t.nextCB(e.data),t.nextCB=null)}),e)}}function V(e){if(this.arraybuffer=e,this.determineVersion(),this.version>12)throw new Error("Only file versions <= 1.2 are supported at this time");if(this.determineFormat(),void 0===D[this.formatId])throw new Error("The point format ID is not supported");this.loader=this.isCompressed?new F(this.arraybuffer):new U(this.arraybuffer)}function G(e,t,n,i,r,o,a,s){this.arrayb=e,this.decoder=D[t],this.pointsCount=i,this.pointSize=n,this.scale=r,this.offset=o,this.mins=a,this.maxs=s}U.prototype.open=function(){return this.readOffset=0,new Promise((function(e,t){setTimeout(e,0)}))},U.prototype.getHeader=function(){var e=this;return new Promise((function(t,n){setTimeout((function(){e.header=function(e){var t={};t.pointsOffset=L(e,Uint32Array,96),t.pointsFormatId=L(e,Uint8Array,104),t.pointsStructSize=L(e,Uint16Array,105),t.pointsCount=L(e,Uint32Array,107);var n=131;t.scale=L(e,Float64Array,n,3),n+=24,t.offset=L(e,Float64Array,n,3),n+=24;var i=L(e,Float64Array,n,6);return n+=48,t.maxs=[i[0],i[2],i[4]],t.mins=[i[1],i[3],i[5]],t}(e.arraybuffer),t(e.header)}),0)}))},U.prototype.readData=function(e,t,n){var i=this;return new Promise((function(t,r){setTimeout((function(){if(!i.header)return r(new Error("Cannot start reading data till a header request is issued"));var o;if(n<=1){e=Math.min(e,i.header.pointsCount-i.readOffset);var a=(o=i.header.pointsOffset+i.readOffset*i.header.pointsStructSize)+e*i.header.pointsStructSize;t({buffer:i.arraybuffer.slice(o,a),count:e,hasMoreData:i.readOffset+e<i.header.pointsCount}),i.readOffset+=e}else{for(var s=Math.min(e*n,i.header.pointsCount-i.readOffset),u=Math.ceil(s/n),l=0,d=new Uint8Array(u*i.header.pointsStructSize),h=0;h<s;h++){if(h%n==0){o=i.header.pointsOffset+i.readOffset*i.header.pointsStructSize;var c=new Uint8Array(i.arraybuffer,o,i.header.pointsStructSize);d.set(c,l*i.header.pointsStructSize),l++}i.readOffset++}t({buffer:d.buffer,count:l,hasMoreData:i.readOffset<i.header.pointsCount})}}),0)}))},U.prototype.close=function(){var e=this;return new Promise((function(t,n){e.arraybuffer=null,setTimeout(t,0)}))},F.prototype.open=function(){var e=this;return new Promise((function(t,n){e.dorr({type:"open",arraybuffer:e.arraybuffer},(function(e){if(1!==e.status)return n(new Error("Failed to open file"));t(!0)}))}))},F.prototype.getHeade