1 |
- function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_toPropertyKey(n.key),n)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _createForOfIteratorHelper(t,e){var r,n,i,a,o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(o)return i=!(n=!0),{s:function(){o=o.call(t)},n:function(){var t=o.next();return n=t.done,t},e:function(t){i=!0,r=t},f:function(){try{n||null==o.return||o.return()}finally{if(i)throw r}}};if(Array.isArray(t)||(o=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length)return o&&(t=o),a=0,{s:e=function(){},n:function(){return a>=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(t){throw t},f:e};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,u=[],A=!0,f=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;A=!1}else for(;!(A=(n=a.call(r)).done)&&(u.push(n.value),u.length!==e);A=!0);}catch(t){f=!0,i=t}finally{try{if(!A&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(f)throw i}}return u}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _toPrimitive(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"==typeof t?t:t+""}function _unsupportedIterableToArray(t,e){var r;if(t)return"string"==typeof t?_arrayLikeToArray(t,e):"Map"===(r="Object"===(r={}.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}var obj,PointAttributeTypes={DATA_TYPE_DOUBLE:{ordinal:0,name:"double",size:8},DATA_TYPE_FLOAT:{ordinal:1,name:"float",size:4},DATA_TYPE_INT8:{ordinal:2,name:"int8",size:1},DATA_TYPE_UINT8:{ordinal:3,name:"uint8",size:1},DATA_TYPE_INT16:{ordinal:4,name:"int16",size:2},DATA_TYPE_UINT16:{ordinal:5,name:"uint16",size:2},DATA_TYPE_INT32:{ordinal:6,name:"int32",size:4},DATA_TYPE_UINT32:{ordinal:7,name:"uint32",size:4},DATA_TYPE_INT64:{ordinal:8,name:"int64",size:8},DATA_TYPE_UINT64:{ordinal:9,name:"uint64",size:8}},i=0;for(obj in PointAttributeTypes)PointAttributeTypes[i]=PointAttributeTypes[obj],i++;var PointAttribute=_createClass(function t(e,r,n){_classCallCheck(this,t),this.name=e,this.type=r,this.numElements=n,this.byteSize=this.numElements*this.type.size,this.description="",this.range=[1/0,-1/0]}),typedArrayMapping=(PointAttribute.POSITION_CARTESIAN=new PointAttribute("POSITION_CARTESIAN",PointAttributeTypes.DATA_TYPE_FLOAT,3),PointAttribute.RGBA_PACKED=new PointAttribute("COLOR_PACKED",PointAttributeTypes.DATA_TYPE_INT8,4),PointAttribute.COLOR_PACKED=PointAttribute.RGBA_PACKED,PointAttribute.RGB_PACKED=new PointAttribute("COLOR_PACKED",PointAttributeTypes.DATA_TYPE_INT8,3),PointAttribute.NORMAL_FLOATS=new PointAttribute("NORMAL_FLOATS",PointAttributeTypes.DATA_TYPE_FLOAT,3),PointAttribute.INTENSITY=new PointAttribute("INTENSITY",PointAttributeTypes.DATA_TYPE_UINT16,1),PointAttribute.CLASSIFICATION=new PointAttribute("CLASSIFICATION",PointAttributeTypes.DATA_TYPE_UINT8,1),PointAttribute.NORMAL_SPHEREMAPPED=new PointAttribute("NORMAL_SPHEREMAPPED",PointAttributeTypes.DATA_TYPE_UINT8,2),PointAttribute.NORMAL_OCT16=new PointAttribute("NORMAL_OCT16",PointAttributeTypes.DATA_TYPE_UINT8,2),PointAttribute.NORMAL=new PointAttribute("NORMAL",PointAttributeTypes.DATA_TYPE_FLOAT,3),PointAttribute.RETURN_NUMBER=new PointAttribute("RETURN_NUMBER",PointAttributeTypes.DATA_TYPE_UINT8,1),PointAttribute.NUMBER_OF_RETURNS=new PointAttribute("NUMBER_OF_RETURNS",PointAttributeTypes.DATA_TYPE_UINT8,1),PointAttribute.SOURCE_ID=new PointAttribute("SOURCE_ID",PointAttributeTypes.DATA_TYPE_UINT16,1),PointAttribute.INDICES=new PointAttribute("INDICES",PointAttributeTypes.DATA_TYPE_UINT32,1),PointAttribute.SPACING=new PointAttribute("SPACING",PointAttributeTypes.DATA_TYPE_FLOAT,1),PointAttribute.GPS_TIME=new PointAttribute("GPS_TIME",PointAttributeTypes.DATA_TYPE_DOUBLE,1),{int8:Int8Array,int16:Int16Array,int32:Int32Array,int64:Float64Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,uint64:Float64Array,float:Float32Array,double:Float64Array});Potree={},onmessage=function(t){var e,t=t.data,r=t.buffer,n=t.pointAttributes,i=t.scale,a=(t.name,t.min),o=(t.max,t.size),u=t.offset,A=t.numPoints,f=(performance.now(),new DataView(r)),l={},s=0,T=0,b=_createForOfIteratorHelper(n.attributes);try{for(b.s();!(e=b.n()).done;)T+=e.value.byteSize}catch(t){b.e(t)}finally{b.f()}var y,F=new Uint32Array(Math.pow(32,3)),M=0,P=_createForOfIteratorHelper(n.attributes);try{for(P.s();!(y=P.n()).done;){var _=y.value;if(["POSITION_CARTESIAN","position"].includes(_.name)){for(var B=new ArrayBuffer(4*A*3),p=new Float32Array(B),c=0;c<A;c++){var I=c*T,z=f.getInt32(I+s+0,!0)*i[0]+u[0]-a.x,j=f.getInt32(I+s+4,!0)*i[1]+u[1]-a.y,H=f.getInt32(I+s+8,!0)*i[2]+u[2]-a.z;0==F[function(t,e,r){t=32*t/o.x,e=32*e/o.y,r=32*r/o.z;return Math.min(parseInt(t),31)+32*Math.min(parseInt(e),31)+32*Math.min(parseInt(r),31)*32}(z,j,H)]++&&M++,p[3*c+0]=z,p[3*c+1]=j,p[3*c+2]=H}l[_.name]={buffer:B,attribute:_}}else if(["RGBA","rgba"].includes(_.name)){for(var G=new ArrayBuffer(4*A),E=new Uint8Array(G),m=0;m<A;m++){var d=m*T,N=f.getUint16(d+s+0,!0),v=f.getUint16(d+s+2,!0),O=f.getUint16(d+s+4,!0);E[4*m+0]=255<N?N/256:N,E[4*m+1]=255<v?v/256:v,E[4*m+2]=255<O?O/256:O}l[_.name]={buffer:G,attribute:_}}else{var K,k,x=new ArrayBuffer(4*A),V=new Float32Array(x),W=typedArrayMapping[_.type.name],w=(preciseBuffer=new W(A),0),D=1,$={int8:f.getInt8,int16:f.getInt16,int32:f.getInt32,uint8:f.getUint8,uint16:f.getUint16,uint32:f.getUint32,float:f.getFloat32,double:f.getFloat64}[_.type.name].bind(f);4<_.type.size&&(k=(K=_slicedToArray(_.range,2))[0],D=1/(K[1]-(w=k)));for(var h=0;h<A;h++){var q=$(h*T+s,!0);V[h]=(q-w)*D,preciseBuffer[h]=q}l[_.name]={buffer:x,preciseBuffer:preciseBuffer,attribute:_,offset:w,scale:D}}s+=_.byteSize}}catch(t){P.e(t)}finally{P.f()}for(var t=parseInt(A/M),J=new ArrayBuffer(4*A),Q=new Uint32Array(J),S=0;S<A;S++)Q[S]=S;l.INDICES={buffer:J,attribute:PointAttribute.INDICES};var X,U=_createForOfIteratorHelper(n.vectors);try{for(U.s();!(X=U.n()).done;){var Z,tt=X.value,et=tt.name,rt=tt.attributes,nt=rt.length,it=new ArrayBuffer(nt*A*4),at=new Float32Array(it),ot=0,g=_createForOfIteratorHelper(rt);try{for(g.s();!(Z=g.n()).done;){for(var R=l[Z.value],ut=R.offset,At=R.scale,ft=new DataView(R.buffer),lt=ft.getFloat32.bind(ft),C=0;C<A;C++){var st=lt(4*C,!0);at[C*nt+ot]=st/At+ut}ot++}}catch(t){g.e(t)}finally{g.f()}var Tt=new PointAttribute(et,PointAttributeTypes.DATA_TYPE_FLOAT,3);l[et]={buffer:it,attribute:Tt}}}catch(t){U.e(t)}finally{U.f()}var bt,L={buffer:r,attributeBuffers:l,density:t},Y=[];for(bt in L.attributeBuffers)Y.push(L.attributeBuffers[bt].buffer);Y.push(r),postMessage(L,Y)};
|