@reall3d/reall3dviewer 0.0.1
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/README.md +1 -0
- package/dist/assets/Sorter-Dl_LG4bh.js +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/pkg.d.ts +285 -0
- package/dist/pkg.js +4923 -0
- package/dist/pkg.umd.cjs +725 -0
- package/dist/style.css +1 -0
- package/package.json +21 -0
package/dist/pkg.umd.cjs
ADDED
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
(function(ge,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("three"),require("@gotoeasy/three-tile")):typeof define=="function"&&define.amd?define(["exports","three","@gotoeasy/three-tile"],u):(ge=typeof globalThis<"u"?globalThis:ge||self,u(ge.reall3dviewer={},ge.THREE,ge.tt))})(this,function(ge,u,ks){"use strict";var Et=typeof document<"u"?document.currentScript:null;function _s(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const et=_s(ks);let w=1;const Fe=w++,kt=w++,Se=w++,Pn=w++,_t=w++,It=w++,Rn=w++,Dt=w++,Bn=w++,ke=w++,$=w++,W=w++,Ln=w++,Pt=w++,Ae=w++,_e=w++,be=w++,Oe=w++,Un=w++,Fn=w++,On=w++,Is=w++,zn=w++,Vn=w++,Rt=w++,Ds=w++,Ps=w++,Hn=w++,j=w++;w++;const ne=w++,ze=w++,Ie=w++,Qn=w++,Wn=w++,$n=w++,Nn=w++,Rs=w++,Gn=w++,Bt=w++,Lt=w++,Yn=w++,jn=w++,qn=w++,Ve=w++,Xn=w++,He=w++,Zn=w++,tt=w++,Ut=w++,nt=w++,Kn=w++,Ft=w++,Bs=w++,Ot=w++,Jn=w++,ei=w++,it=w++,st=w++,at=w++,ot=w++,ti=w++,zt=w++,_=w++,xe=w++,Qe=w++,U=w++,rt=w++,ni=w++,Ls=w++,J=w++,Vt=w++,ae=w++,ii=w++,si=w++,ai=w++,oi=w++,Ht=w++,ri=w++,Me=w++,ci=w++,li=w++,ct=w++,Us=w++,di=w++,ui=w++;w++;const lt=w++,Qt=w++,fi=w++,pi=w++,Wt=w++,dt=w++,$t=w++,We=w++,oe=w++,Nt=w++,hi=w++,Fs=w++,gi=w++,mi=w++,Ai=w++,Os=w++,zs=w++,ut=w++,ft=w++,Gt=w++,De=w++,Ce=w++,$e=w++,pt=w++,yi=w++,N=w++,q=w++,Vs=w++,wi=w++,ht=w++,gt=w++,Hs=w++,Yt=w++,jt=w++,ye=w++,Ne=w++,Pe=w++,Qs=w++,vi=w++,Ws=w++;w++,w++,w++,w++,w++;const we=w++,Ge=w++,mt=w++,qt=w++,Si=w++,bi=w++,Xt=w++,ve=w++,Ye=w++,xi=w++,Zt=w++,Mi=w++,$s=w++,Ns=w++,Kt=w++,Ci=w++,Jt=w++,en=w++,tn=w++,At=w++,Ti=w++,Ei=w++,yt=w++,me=w++,ki=w++,_i=w++;w++;const je=w++,Ii=w++,Di=w++,nn=w++,Pi=w++,Gs=w++,Ri=w++,Bi=w++,Li=w++,Ui=w++;w++;const Fi=w++,Oi=w++,G=w++,sn=w++,an=w++,on=w++,Ys=w++,zi=w++,js=w++,qs=w++,Xs=w++,Zs=w++,Ks=w++,Vi=w++,Hi=w++;w++,w++,w++,w++,w++;class rn{constructor(){this.map=new Map}on(e,t=null,n=!1){if(!e)return console.error("Invalid event key",e),null;if(!t)return this.map.get(e);if(n){let a=this.map.get(e);a?typeof a=="function"?console.error("Invalid event type","multiFn=true",e):a.push(t):(a=[],this.map.set(e,a),a.push(t))}else{let a=this.map.get(e);a?typeof a=="function"?console.warn("Replace event",e):console.error("Invalid event type","multiFn=false",e):this.map.set(e,t)}return this.map.get(e)}fire(e,...t){const n=this.map.get(e);if(!n){this.map.size&&console.log("Undefined event:",e,"(",...t,")");return}if(typeof n=="function")return n(...t);let a=[];return n.forEach(o=>a.push(o(...t))),a}tryFire(e,...t){return this.map.get(e)?this.fire(e,...t):void 0}off(e){this.map.delete(e)}clear(){this.map.clear()}}class Js{}class ea{constructor(e,t={}){this.fileSize=0,this.downloadSize=0,this.status=0,this.splatData=null,this.watermarkData=null,this.dataSplatCount=0,this.watermarkCount=0,this.sh12Data=[],this.sh3Data=[],this.sh12Count=0,this.sh3Count=0,this.rowLength=0,this.modelSplatCount=-1,this.downloadSplatCount=0,this.renderSplatCount=0,this.header=null,this.dataShDegree=0,this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0,this.minZ=1/0,this.maxZ=-1/0,this.topY=0,this.currentRadius=0,this.textWatermarkVersion=0,this.lastTextWatermarkVersion=0,this.fetchLimit=0,this.opts={...e},this.meta=t,t.autoCut&&(this.map=new Map),e.format||(e.url?.endsWith(".spx")?this.opts.format="spx":e.url?.endsWith(".splat")?this.opts.format="splat":e.url?.endsWith(".ply")?this.opts.format="ply":e.url?.endsWith(".spz")?this.opts.format="spz":console.error("unknow format!")),this.abortController=new AbortController}}var R=(i=>(i[i.FetchReady=0]="FetchReady",i[i.Fetching=1]="Fetching",i[i.FetchDone=2]="FetchDone",i[i.FetchAborted=3]="FetchAborted",i[i.FetchFailed=4]="FetchFailed",i[i.Invalid=5]="Invalid",i))(R||{});const wt="v1.5.0-dev-map",re=navigator.userAgent.includes("Mobi"),ta="QWERTYUIOPLKJHGFDSAZXCVBNM1234567890qwertyuioplkjhgfdsazxcvbnm`~!@#$%^&*()-_=+\\|]}[{'\";::,<.>//? ",Re=128,na=32,L=32,ia=20,sa=16,Qi=64*1024,aa=1024*1e4,oa=10240*1e4,vt=.28209479177387814,ra=0,ca=20,cn=1,qe=2,ln=3,la=3141592653,dn="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEeBmABfQF9YAAAYAF9AX9gAX8Bf2ACf38AYAJ/fwF/AhoCA2VudgRleHBmAAADZW52Bm1lbW9yeQIAAAMGBQECAwQFByEEEV9fd2FzbV9jYWxsX2N0b3JzAAEBSAADAXcABAFEAAUKigsFAwABC3IBBH8gALwiBEH///8DcSEBAkAgBEEXdkH/AXEiAkUNACACQfAATQRAIAFBgICABHJB8QAgAmt2IQEMAQsgAkGNAUsEQEGA+AEhA0EAIQEMAQsgAkEKdEGAgAdrIQMLIAMgBEEQdkGAgAJxciABQQ12cgsyAQJ/QcGmFiEBA0AgACACai0AACABQSFscyEBIAJBAWoiAkH8AEcNAAsgASAAKAJ8RwszACAAQQhBBCABQQFGG2pBADYCACAAQQA2ABwgAP0MAAABAIwRFgCVAWwS7YEyE/0LAgwLqQkDKH8OfQR8IAEoAgRBi/AJRgR/IAEoAgAiBEEASgRAIAFBCWoiAiAEQRNsaiEIIAIgBEESbGohCSACIARBEWxqIQogAiAEQQR0aiELIAIgBEEPbGohDCACIARBDmxqIQ0gAiAEQQ1saiEOIAIgBEEMbGohDyACIARBC2xqIRAgAiAEQQpsaiERIAIgBEEJbGohEiACIARBBmxqIRMgAiAEQQNsaiEUIAEtAAghFUEAIQIDQCACIAlqLQAAIQcgAiAKai0AACEWIAIgC2otAAAhFyACIAxqLQAAIRggAiANai0AACEZIAIgDmotAAAhGiACIA9qLQAAIRsgAiAQai0AACEcIAIgEWotAAAhHSACIBJqLQAAIR4gEyACQQNsIgNqIgUtAAAhHyADIBRqIgYtAAAhICABIANqIgMtAAohISADLQAJISIgBS0AASEjIAYtAAEhJCADLQALIiXAISYgBS0AAiInwCEoIAYtAAIiBsAhKUEAIQUgFQRAIAggAkEBdGoiAy0AASIFQQh0QYD+AXEgAy0AAHIgBUEJdEGAgARxciEFCyAes0MAAIA9lEMAACDBkhAAIS8gHbNDAACAPZRDAAAgwZIQACExIByzQwAAgD2UQwAAIMGSEAAhMkMAAAAAQwAAgD8gB7NDAAAAw5JDAAAAPJQiKiAqlCAXs0MAAADDkkMAAAA8lCIrICuUIBazQwAAAMOSQwAAADyUIiwgLJSSkpMiLZEgLUMAAAAAXRshLSAAIAJBBXRqIgMgIUEIdCAiciAlQRB0ciIHQYCAgHhyIAcgJkEASBuyQwAAgDmUOAIAIAMgBTYCDCADICNBCHQgH3IgJ0EQdHIiBUGAgIB4ciAFIChBAEgbskMAAIA5lDgCCCADICRBCHQgIHIgBkEQdHIiBUGAgIB4ciAFIClBAEgbskMAAIA5lDgCBCADICsgKiAqlCAsICyUIC0gLZQgKyArlJKSkpEiLpUiKyAqIC6VIiqUIjQgLSAulSIwICwgLpUiLJQiNZK7IjggOKAgMrsiOKK2Ii0gLZREAAAAAAAA8D8gLCAslCIyICogKpQiNpK7IjogOqChIC+7IjqitiIuIC6UICsgLJQiMyAwICqUIjeTuyI7IDugIDG7IjuitiIvIC+UkpJDAACAQJQQAiAtICwgKpQiMSAwICuUIjCTuyI5IDmgIDiitiIqlCAuIDMgN5K7IjkgOaAgOqK2IiyUIC9EAAAAAAAA8D8gKyArlCIzIDaSuyI5IDmgoSA7orYiK5SSkkMAAIBAlBACQRB0cjYCECADIC1EAAAAAAAA8D8gMyAykrsiOSA5oKEgOKK2Ii2UIC4gNCA1k7siOCA4oCA6orYiLpQgLyAxIDCSuyI4IDigIDuitiIvlJKSQwAAgECUEAIgKiAqlCAsICyUICsgK5SSkkMAAIBAlBACQRB0cjYCFCADIBpBCHQgG3IgGUEQdHIgGEEYdHI2AhwgAyAqIC2UICwgLpQgKyAvlJKSQwAAgECUEAIgLSAtlCAuIC6UIC8gL5SSkkMAAIBAlBACQRB0cjYCGCACQQFqIgIgBEcNAAsLQQAFQQELCw==",un="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEpBmACf38Bf2ABfQF9YAAAYAF9AX9gAX8Bf2ANf399fX19fX19fX19fwACGgIDZW52BGV4cGYAAQNlbnYGbWVtb3J5AgAAAwcGAgMEBQAAByEEEV9fd2FzbV9jYWxsX2N0b3JzAAEBSAADAXMABQFEAAYKnhUGAwABC3IBBH8gALwiBEH///8DcSEBAkAgBEEXdkH/AXEiAkUNACACQfAATQRAIAFBgICABHJB8QAgAmt2IQEMAQsgAkGNAUsEQEGA+AEhA0EAIQEMAQsgAkEKdEGAgAdrIQMLIAMgBEEQdkGAgAJxciABQQ12cgsyAQJ/QZWjAyEBA0AgACACai0AACABQSFscyEBIAJBAWoiAkH8AEcNAAsgASAAKAJ8RwvpAwIEfAR9IAAgAUECdGoiACACOAIAIABBADYCDCAAIAQ4AgggACADOAIEIAAgCSALIAuUIAogCpQgCCAIlCAJIAmUkpKSkSIElSICIAsgBJUiA5QiCSAIIASVIgggCiAElSIElCIKkrsiDSANoCAHuyINorYiByAHlEQAAAAAAADwPyAEIASUIgsgAyADlCISkrsiDyAPoKEgBbsiD6K2IgUgBZQgAiAElCIRIAggA5QiE5O7IhAgEKAgBrsiEKK2IgYgBpSSkkMAAIBAlBACIAcgBCADlCIUIAggApQiCJO7Ig4gDqAgDaK2IgOUIAUgESATkrsiDiAOoCAPorYiBJQgBkQAAAAAAADwPyACIAKUIhEgEpK7Ig4gDqChIBCitiIClJKSQwAAgECUEAJBEHRyNgIQIAAgB0QAAAAAAADwPyARIAuSuyIOIA6goSANorYiB5QgBSAJIAqTuyINIA2gIA+itiIFlCAGIBQgCJK7Ig0gDaAgEKK2IgaUkpJDAACAQJQQAiADIAOUIAQgBJQgAiAClJKSQwAAgECUEAJBEHRyNgIUIAAgDDYCHCAAIAMgB5QgBCAFlCACIAaUkpJDAACAQJQQAiAHIAeUIAUgBZQgBiAGlJKSQwAAgECUEAJBEHRyNgIYC70BAQJ/IAFBAEoEQANAIAAgA0EDdCAAIANBBXRqIgIqAgAgAioCBCACKgIIIAIqAgwgAioCECACKgIUIAItABy4RAAAAAAAAGDAoEQAAAAAAACAP6K2IAItAB24RAAAAAAAAGDAoEQAAAAAAACAP6K2IAItAB64RAAAAAAAAGDAoEQAAAAAAACAP6K2IAItAB+4RAAAAAAAAGDAoEQAAAAAAACAP6K2IAIoAhgQBCADQQFqIgMgAUcNAAsLQQALxw4BHH8CfwJAAkACQAJAAkAgASgCBCICQQFrDgMBAgMAC0EBIAJBFEcNBBogASgCACIDQQBKBEAgAUEIaiICIANBE2xqIQUgAiADQRJsaiEGIAIgA0ERbGohCCACIANBBHRqIQkgAiADQQ9saiEKIAIgA0EObGohCyACIANBDWxqIQwgAiADQQxsaiENIAIgA0ELbGohDiACIANBCmxqIQ8gAiADQQlsaiEQIAIgA0EGbGohESACIANBA2xqIRJBACECA0AgAiAMai0AACETIAIgDWotAAAhFCACIAtqLQAAIRUgAiAKai0AACEWIAIgBWotAAAhFyACIAZqLQAAIRggAiAIai0AACEZIAIgCWotAAAhGyACIA5qLQAAIRwgAiAPai0AACEdIAAgAkEDdCABIAJBA2wiBGoiBy8ACCAHLAAKIgdB/wFxQRB0ciIaQYCAgHhyIBogB0EASBuyQwAAgDmUIAQgEmoiBy8AACAHLAACIgdB/wFxQRB0ciIaQYCAgHhyIBogB0EASBuyQwAAgDmUIAQgEWoiBC8AACAELAACIgRB/wFxQRB0ciIHQYCAgHhyIAcgBEEASBuyQwAAgDmUIAIgEGotAACzQwAAgD2UQwAAIMGSEAAgHbNDAACAPZRDAAAgwZIQACAcs0MAAIA9lEMAACDBkhAAIBu4RAAAAAAAAGDAoEQAAAAAAACAP6K2IBm4RAAAAAAAAGDAoEQAAAAAAACAP6K2IBi4RAAAAAAAAGDAoEQAAAAAAACAP6K2IBe4RAAAAAAAAGDAoEQAAAAAAACAP6K2IBQgE0EIdHIgFUEQdHIgFkEYdHIQBCACQQFqIgIgA0cNAAsLDAMLIAEoAgAiBUEASgRAA0AgASADQQlsaiICLQANIQYgAi0ADCEIIAItAAshCSACLQAKIQogAi0ACSELIAItAAghDCACLQAQIQ0gAi0ADyEOIAItAA4hAiAAIANBBHRqIgRCgICAgBA3AgggBCANQRB0QYCA4AdxIA5BFXRBgICA+AFxIAJBGnRBgICAgH5xcnI2AgQgBCAGQQF2QfwAcSAIQQR0QYAfcSAJQQl0QYDgB3EgCkEOdEGAgPgBcSALQRN0QYCAgD5xIAxBGHRBgICAQHFycnJyciACQQZ2cjYCACADQQFqIgMgBUcNAAsLDAILIAEoAgAiCEEASgRAA0AgASADQRhsaiICLQAaIQkgAi0AGSEKIAItABghCyACLQAXIQwgAi0AFiENIAItABUhDiACLQANIQ8gAi0ADCEQIAItAAshESACLQAKIRIgAi0ACSETIAItAAghFCACLQAUIQUgAi0AEyEVIAItABIhFiACLQARIRcgAi0AECEYIAItAA8hGSACLQAOIQYgACADQQR0aiIEIAItAB9BBXRBgD5xIAItAB5BCnRBgMAPcSACLQAdQQ90QYCA8ANxIAItABxBFHRBgICA/ABxIAItABsiAkEZdEGAgICAf3FycnJyQQFyNgIMIAQgFUEBdEHwA3EgFkEGdEGA/ABxIBdBC3RBgIAfcSAYQRB0QYCA4AdxIBlBFXRBgICA+AFxIAZBGnRBgICAgH5xcnJycnIgBUEEdnI2AgQgBCAPQQF2QfwAcSAQQQR0QYAfcSARQQl0QYDgB3EgEkEOdEGAgPgBcSATQRN0QYCAgD5xIBRBGHRBgICAQHFycnJyciAGQQZ2cjYCACAEIAlBAnZBPnEgCkEDdEHAD3EgC0EIdEGA8ANxIAxBDXRBgID8AHEgDUESdEGAgIAfcSAOQRd0QYCAgOAHcSAFQRx0QYCAgIB4cXJycnJyciACQQd2cjYCCCADQQFqIgMgCEcNAAsLDAELIAEoAgAiCEEASgRAA0AgASADQRVsaiICLQAaIQkgAi0AGSEKIAItABghCyACLQAXIQwgAi0AFiENIAItABUhDiACLQANIQ8gAi0ADCEQIAItAAshESACLQAKIRIgAi0ACSETIAItAAghFCACLQAUIQUgAi0AEyEVIAItABIhFiACLQARIRcgAi0AECEYIAItAA8hGSACLQAOIQYgACADQQR0aiIEIAItABxBFHRBgICA/ABxIAItABsiAkEZdEGAgICAf3FyQQFyNgIMIAQgFUEBdEHwA3EgFkEGdEGA/ABxIBdBC3RBgIAfcSAYQRB0QYCA4AdxIBlBFXRBgICA+AFxIAZBGnRBgICAgH5xcnJycnIgBUEEdnI2AgQgBCAPQQF2QfwAcSAQQQR0QYAfcSARQQl0QYDgB3EgEkEOdEGAgPgBcSATQRN0QYCAgD5xIBRBGHRBgICAQHFycnJyciAGQQZ2cjYCACAEIAlBAnZBPnEgCkEDdEHAD3EgC0EIdEGA8ANxIAxBDXRBgID8AHEgDUESdEGAgIAfcSAOQRd0QYCAgOAHcSAFQRx0QYCAgIB4cXJycnJyciACQQd2cjYCCCADQQFqIgMgCEcNAAsLC0EACws=";async function da(i){const e=new Uint32Array(i.buffer),t=new Float32Array(i.buffer),n=new Js;n.Fixed=String.fromCharCode(i[0])+String.fromCharCode(i[1])+String.fromCharCode(i[2]),n.Version=i[3],n.SplatCount=e[1],n.MinX=t[2],n.MaxX=t[3],n.MinY=t[4],n.MaxY=t[5],n.MinZ=t[6],n.MaxZ=t[7],n.MinTopY=t[8],n.MaxTopY=t[9],n.CreateDate=e[10],n.CreaterId=e[11],n.ExclusiveId=e[12],n.ShDegree=i[52],n.Flag1=i[53],n.Flag2=i[54],n.Flag3=i[55],n.Reserve1=e[14],n.Reserve2=e[15];let a="";for(let p=64;p<124;p++)a+=String.fromCharCode(i[p]);if(n.Comment=a.trim(),n.HashCheck=!0,n.Fixed!=="spx"&&n.Version!==1)return null;const o=n.CreaterId==1202056903?un:dn,s=WebAssembly.compile(Uint8Array.from(atob(o),p=>p.charCodeAt(0)).buffer),r=new WebAssembly.Memory({initial:1,maximum:1}),f=(await WebAssembly.instantiate(await s,{env:{memory:r,expf:St}})).exports.H;return new Uint8Array(r.buffer).set(i,0),f(0)&&(n.HashCheck=!1),n}async function ce(i){const e=new Uint32Array(i.slice(0,8).buffer),t=e[0],n=e[1],a=cn==n,o=qe==n,s=ln==n,r=a||o||s,c=!r,f=n==20||r?un:dn,l=t*(r?sa:L),d=WebAssembly.compile(Uint8Array.from(atob(f),M=>M.charCodeAt(0)).buffer),p=Math.floor((l+i.byteLength)/Qi)+2,g=new WebAssembly.Memory({initial:p,maximum:p}),y=(await WebAssembly.instantiate(await d,{env:{memory:g,expf:St}})).exports.D,m=new Uint8Array(g.buffer);return m.set(i,l),y(0,l)?{splatCount:t,blockFormat:n,success:!1}:{splatCount:t,blockFormat:n,success:!0,datas:m.slice(0,l),isSplat:c,isSh:r,isSh1:a,isSh2:o,isSh3:s}}async function fn(i,e){const t=WebAssembly.compile(Uint8Array.from(atob(un),f=>f.charCodeAt(0)).buffer),n=Math.floor(e*L/Qi)+2,a=new WebAssembly.Memory({initial:n,maximum:n}),s=(await WebAssembly.instantiate(await t,{env:{memory:a,expf:St}})).exports.s,r=new Uint8Array(a.buffer);r.set(i.slice(0,e*L),0);const c=s(0,e);return c?(console.error("splat data parser failed:",c),new Uint8Array(0)):r.slice(0,e*L)}async function ua(i,e,t=!0,n=!0){const a=WebAssembly.compile(Uint8Array.from(atob(dn),d=>d.charCodeAt(0)).buffer),o=new WebAssembly.Memory({initial:1,maximum:1}),r=(await WebAssembly.instantiate(await a,{env:{memory:o,expf:St}})).exports.w,c=new Uint8Array(o.buffer),f=new Float32Array(c.buffer),l=n?-1:1;return f[0]=i,t?f[1]=l*e:f[2]=l*e,r(0,t?1:0),c.slice(0,L)}function St(i){return Math.exp(i)}const Be=re?20480:51200;async function fa(i){let e=0;try{i.status=R.Fetching;const n=i.abortController.signal,a=i.opts.fetchReload?"reload":"default",o=await fetch(i.opts.url,{mode:"cors",credentials:"omit",cache:a,signal:n});if(o.status!=200){console.warn(`fetch error: ${o.status}`),i.status===R.Fetching&&(i.status=R.FetchFailed);return}const s=o.body.getReader(),r=parseInt(o.headers.get("content-length")||"0");i.rowLength=32,i.fileSize=r;const c=r/i.rowLength|0;if(c<1){console.warn("data empty",i.opts.url),i.status===R.Fetching&&(i.status=R.Invalid);return}i.modelSplatCount=c,i.downloadSplatCount=0,i.splatData=new Uint8Array(Math.min(i.modelSplatCount,i.fetchLimit)*32),i.watermarkData=new Uint8Array(0);let f=new Uint8Array(32),l=0;for(;;){let{done:d,value:p}=await s.read();if(d)break;l+p.byteLength<i.rowLength?(f.set(p,l),l+=p.byteLength,e+=p.length,i.downloadSize=e):(l=await t(i,l,f,p),l&&f.set(p.slice(p.byteLength-l),0)),i.downloadSplatCount>=i.fetchLimit&&i.abortController.abort()}}catch(n){n.name==="AbortError"?(console.log("Fetch Abort",i.opts.url),i.status===R.Fetching&&(i.status=R.FetchAborted)):(console.error(n),i.status===R.Fetching&&(i.status=R.FetchFailed))}finally{i.status===R.Fetching&&(i.status=R.FetchDone)}async function t(n,a,o,s){return new Promise(async r=>{let c=(a+s.byteLength)/n.rowLength|0,f=(a+s.byteLength)%n.rowLength,l;a?(l=new Uint8Array(c*n.rowLength),l.set(o.slice(0,a),0),l.set(s.slice(0,s.byteLength-f),a)):l=s.slice(0,c*n.rowLength),n.downloadSplatCount+c>n.fetchLimit&&(c=n.fetchLimit-n.downloadSplatCount,f=0);const d=async()=>{if(c>Be){const p=await fn(l,Be);Wi(n,p),n.downloadSplatCount+=Be,e+=Be*n.rowLength,n.downloadSize=e,c-=Be,l=l.slice(Be*n.rowLength),setTimeout(d)}else{const p=await fn(l,c);Wi(n,p),n.downloadSplatCount+=c,e+=c*n.rowLength,n.downloadSize=e,r(f)}};await d()})}}function Wi(i,e){let t=e.byteLength/L;const n=Math.min(i.fetchLimit,i.modelSplatCount);i.dataSplatCount+t>n?(t=n-i.dataSplatCount,i.splatData.set(e.slice(0,t*L),i.dataSplatCount*L)):i.splatData.set(e,i.dataSplatCount*L);const a=new Float32Array(e.buffer);for(let s=0,r=0,c=0,f=0;s<t;s++)r=a[s*8],c=a[s*8+1],f=a[s*8+2],i.minX=Math.min(i.minX,r),i.maxX=Math.max(i.maxX,r),i.minY=Math.min(i.minY,c),i.maxY=Math.max(i.maxY,c),i.minZ=Math.min(i.minZ,f),i.maxZ=Math.max(i.maxZ,f);i.dataSplatCount+=t;const o=i.header?.MinTopY||0;i.currentRadius=Math.sqrt(i.maxX*i.maxX+o*o+i.maxZ*i.maxZ),i.aabbCenter=new u.Vector3((i.minX+i.maxX)/2,(i.minY+i.maxY)/2,(i.minZ+i.maxZ)/2)}function pn(i){let e=!1;const t=(h,y,m)=>i.on(h,y,m),n=(h,...y)=>i.fire(h,...y),a=!n(_).renderer;t(ae,()=>n(_).debugMode),t(zt,()=>e=!0);let o=0;(function h(){o++,!e&&requestAnimationFrame(h)})(),t(Fe,(h,y=null,m=0)=>{const A=()=>{e||(m>0?!(o%m)&&h(o):h(o),y&&y()&&requestAnimationFrame(A))};A()}),t(kt,(h,y=null,m=20)=>{const A=()=>{e||(h(),y&&y()&&setTimeout(A,m))};A()});let s=!1,r=0,c=0;t(ci,()=>{s=!0,n(_).debugMode?((async()=>{const h=document.querySelector("#gsviewer #progressBarWrap");if(h){h.style.display="block";const y=document.querySelector("#gsviewer #progressBar");y&&(y.style.width="0%")}})(),(async()=>document.querySelector("#gsviewer .logo")?.classList.add("loading"))()):parent?.onProgress&&parent.onProgress(.001,"0.001%")}),t(ct,h=>{h&&(r=h),s=!1,h!==void 0&&((async()=>{const y=document.querySelector("#gsviewer #progressBarWrap");y&&(y.style.display="none")})(),(async()=>document.querySelector("#gsviewer .logo")?.classList.remove("loading"))(),parent?.onProgress&&parent.onProgress(0,"100%",9))}),t(li,h=>{s=!0,n(_).debugMode?(async()=>{const y=document.querySelector("#gsviewer #progressBar");y&&(y.style.width=`${h}%`)})():parent?.onProgress&&parent.onProgress(h,`${h}%`)}),t(Us,()=>s),t(di,h=>{c=h}),t(ui,()=>!s&&r&&c>=r),t(xe,()=>{const y=n(ke).parentElement.getBoundingClientRect();return{width:y.width,height:y.height,left:y.left,top:y.top}}),t(Me,h=>{let y=h.x.toFixed(3).split("."),m=h.y.toFixed(3).split("."),A=h.z.toFixed(3).split(".");return(y[1]==="000"||y[1]==="00000")&&(y[1]="0"),(m[1]==="000"||m[1]==="00000")&&(m[1]="0"),(A[1]==="000"||A[1]==="00000")&&(A[1]="0"),`${y.join(".")}, ${m.join(".")}, ${A.join(".")}`}),t(Ds,h=>btoa(h)),t(Ps,h=>atob(h));const f=.001;let l=new u.Vector3,d=new u.Vector3,p=0;t(Ls,()=>{const h=n($),y=h.fov,m=h.position.clone(),A=h.getWorldDirection(new u.Vector3);return Math.abs(p-y)<f&&Math.abs(m.x-l.x)<f&&Math.abs(m.y-l.y)<f&&Math.abs(m.z-l.z)<f&&Math.abs(A.x-d.x)<f&&Math.abs(A.y-d.y)<f&&Math.abs(A.z-d.z)<f?!1:(p=y,l=m,d=A,!0)}),t(ve,h=>{if(!h)return;const y=[];h.traverse(m=>y.push(m)),y.forEach(m=>{m.dispose?m.dispose():(m.geometry?.dispose?.(),m.material&&m.material instanceof Array?m.material.forEach(A=>A?.dispose?.()):m.material?.dispose?.())}),h.clear()}),t(ne,async({renderSplatCount:h,visibleSplatCount:y,modelSplatCount:m,fps:A,realFps:M,sortTime:x,fov:S,position:T,lookUp:v,lookAt:I,worker:b,scene:D,scale:E,cuts:C,shDegree:B}={})=>{if(!n(ae))return;B!==void 0&&g("shDegree",`${B}`),h!==void 0&&g("renderSplatCount",`${h}`),y!==void 0&&g("visibleSplatCount",`${y}`),m!==void 0&&g("modelSplatCount",`${m}`),A!==void 0&&g("fps",A),M!==void 0&&g("realFps",`raw ${M}`),x!==void 0&&g("sort",`${x} ms`),!a&&n(J)?C!==void 0&&g("cuts",`(${C} cuts)`):g("cuts",""),b&&g("worker",`${b}`),D&&g("scene",D),S&&g("fov",S),T&&g("position",T),v&&g("lookUp",v),I&&g("lookAt",I),I&&g("viewer-version",wt);let k=performance.memory||{usedJSHeapSize:0,totalJSHeapSize:0,jsHeapSizeLimit:0},P="",F=k.usedJSHeapSize/1024/1024;F>1e3?P+=(F/1024).toFixed(2)+" G":P+=F.toFixed(0)+" M",P+=" / ";let O=k.totalJSHeapSize/1024/1024;O>1e3?P+=(O/1024).toFixed(2)+" G":P+=O.toFixed(0)+" M";let Q=k.jsHeapSizeLimit/1024/1024;P+=" / ",Q>1e3?P+=(Q/1024).toFixed(2)+" G":P+=Q.toFixed(0)+" M",g("memory",P),E&&g("scale",E)});async function g(h,y){let m=document.querySelector(`#gsviewer .debug .${h}`);m&&(m.innerText=y)}}function pa(i=0){const e=new Date;return e.setDate(e.getDate()-7),i>=e.getFullYear()*1e4+(e.getMonth()+1)*100+e.getDate()}async function $i(i){try{const e=new ReadableStream({async start(n){n.enqueue(i),n.close()}}),t=new Response(e.pipeThrough(new DecompressionStream("gzip")));return new Uint8Array(await t.arrayBuffer())}catch(e){return console.error("unGzip Failed:",e),null}}function ee(i){return i<0?0:i>255?255:i|0}function bt(i){const e=ee(Math.round(i*128)+128);return ee(Math.floor((e+4)/8)*8)}const ha=[ra,la];async function ga(i){try{i.status=R.Fetching;const e=i.abortController.signal,t=i.opts.fetchReload?"reload":"default",n=await fetch(i.opts.url,{mode:"cors",credentials:"omit",cache:t,signal:e});if(n.status!=200){console.warn(`fetch error: ${n.status}`),i.status===R.Fetching&&(i.status=R.FetchFailed);return}const a=n.body.getReader(),o=parseInt(n.headers.get("content-length")||"0");if(o-Re<ia){console.warn("data empty",i.opts.url),i.status===R.Fetching&&(i.status=R.Invalid);return}i.fileSize=o;let r=[],c=new Uint8Array(Re),f=new Uint8Array(L),l=0,d=!1,p=0,g=0,h,y=!1;for(;;){let{done:m,value:A}=await a.read();if(m)break;if(i.downloadSize+=A.byteLength,r){r.push(A);let S=0;for(let I=0;I<r.length;I++)S+=r[I].byteLength;if(S<Re)continue;let T=0;for(let I=0;I<r.length;I++)T+r[I].byteLength<Re?(c.set(r[I],T),T+=r[I].byteLength):(c.set(r[I].slice(0,Re-T),T),A=new Uint8Array(r[I].slice(Re-T)));const v=await da(c);if(!v){i.abortController.abort(),i.status===R.Fetching&&(i.status=R.Invalid),console.error("invalid spx format");continue}if(i.header=v,i.modelSplatCount=v.SplatCount,i.dataShDegree=v.ShDegree,i.aabbCenter=new u.Vector3((v.MaxX+v.MaxX)/2,(v.MinY+v.MaxY)/2,(v.MinZ+v.MaxZ)/2),r=null,c=null,!ha.includes(v.ExclusiveId)){i.abortController.abort(),i.status=R.Invalid,console.error("Unrecognized format, creater id =",v.CreaterId,", exclusive id =",v.ExclusiveId,v.Comment);continue}}if(!d){if(l+A.byteLength<4){f.set(A,l),l+=A.byteLength;continue}const S=new Uint8Array(l+A.byteLength);S.set(f.slice(0,l),0),S.set(A,l),A=S.slice(4),l=0,d=!0,h=[],g=0;const T=new Int32Array(S.slice(0,4).buffer);y=T[0]<0,p=Math.abs(T[0])}let M=g+A.byteLength;if(h.push(A),M<p){g+=A.byteLength;continue}for(;M>=p;){let S=new Uint8Array(p),T=0;for(let I=0;I<h.length;I++)T+h[I].byteLength<p?(S.set(h[I],T),T+=h[I].byteLength):(S.set(h[I].slice(0,p-T),T),A=new Uint8Array(h[I].slice(p-T)));y&&(S=await $i(S));const v=await ce(S);if(!v.success){console.error("spx block data parser failed. block format:",v.blockFormat),i.abortController.abort(),i.status=R.Invalid;break}if(v.isSplat)i.downloadSplatCount+=v.datas.byteLength/32,ma(i,v.datas);else{const I=Math.min(i.fetchLimit,i.modelSplatCount);if(v.isSh3)if(i.sh3Count+v.splatCount>I){const b=I-i.sh3Count;i.sh3Data.push(v.datas.slice(0,b*16)),i.sh3Count+=b}else i.sh3Data.push(v.datas),i.sh3Count+=v.splatCount;else if(i.sh12Count+v.splatCount>I){const b=I-i.sh12Count;i.sh12Data.push(v.datas.slice(0,b*16)),i.sh12Count+=b}else i.sh12Data.push(v.datas),i.sh12Count+=v.splatCount}if(A.byteLength<4){f.set(A,0),l=A.byteLength,d=!1;break}else{const I=new Int32Array(A.slice(0,4).buffer);p=Math.abs(I[0]),y=I[0]<0,A=A.slice(4),M=A.byteLength,h=[A],g=A.byteLength}}const x=i.fetchLimit;i.header.ShDegree===3?i.downloadSplatCount>=x&&i.sh12Count>=x&&i.sh3Count>=x&&i.abortController.abort():i.header.ShDegree?i.downloadSplatCount>=x&&i.sh12Count>=x&&i.abortController.abort():i.downloadSplatCount>=x&&i.abortController.abort()}}catch(e){e.name==="AbortError"?(console.log("Fetch Abort",i.opts.url),i.status===R.Fetching&&(i.status=R.FetchAborted)):(console.error(e),i.status===R.Fetching&&(i.status=R.FetchFailed),i.abortController.abort())}finally{i.status===R.Fetching&&(i.status=R.FetchDone)}}function ma(i,e){let t=!!i.meta.autoCut,n=e.byteLength/32;const a=4096;if(!t){const c=Math.min(i.fetchLimit,i.modelSplatCount);if(!i.splatData&&(i.splatData=new Uint8Array(c*L)),!i.watermarkData&&(i.watermarkData=new Uint8Array(0)),i.dataSplatCount+n>c&&(n=c-i.dataSplatCount,!n))return;const f=new Float32Array(e.buffer),l=new Uint32Array(e.buffer);for(let p=0,g=0,h=0,y=0;p<n;p++)if(g=f[p*8],h=f[p*8+1],y=f[p*8+2],i.minX=Math.min(i.minX,g),i.maxX=Math.max(i.maxX,g),i.minY=Math.min(i.minY,h),i.maxY=Math.max(i.maxY,h),i.minZ=Math.min(i.minZ,y),i.maxZ=Math.max(i.maxZ,y),l[p*8+3]>>16){if(i.watermarkCount*L===i.watermarkData.byteLength){const m=new Uint8Array((i.watermarkCount+a)*L);m.set(i.watermarkData,0),i.watermarkData=m}i.watermarkData.set(e.slice(p*32,p*32+32),i.watermarkCount++*L)}else i.splatData.set(e.slice(p*32,p*32+32),i.dataSplatCount++*L);const d=i.header.MinTopY||0;i.currentRadius=Math.sqrt(i.maxX*i.maxX+d*d+i.maxZ*i.maxZ);return}let o=Math.min(Math.max(i.meta.autoCut,2),50);!i.watermarkData&&(i.watermarkData=new Uint8Array(0));const s=new Float32Array(e.buffer),r=new Uint32Array(e.buffer);for(let c=0,f=Math.floor(e.byteLength/L),l=0,d=0,p=0,g="";c<f;c++){if(r[c*8+3]>>16){if(i.watermarkCount*L===i.watermarkData.byteLength){const A=new Uint8Array((i.watermarkCount+a)*L);A.set(i.watermarkData,0),i.watermarkData=A}i.watermarkData.set(e.slice(c*32,c*32+32),i.watermarkCount++*L);continue}l=s[c*8],d=s[c*8+1],p=s[c*8+2];let h=Math.min(o-1,Math.floor(Math.max(0,l-i.header.MinX)/(i.header.MaxX-i.header.MinX)*o)),y=Math.min(o-1,Math.floor(Math.max(0,p-i.header.MinZ)/(i.header.MaxZ-i.header.MinZ)*o));g=`${h}-${y}`;let m=i.map.get(g);if(!m)m={},m.minX=l,m.maxX=l,m.minY=d,m.maxY=d,m.minZ=p,m.maxZ=p,m.centerX=l,m.centerY=d,m.centerZ=p,m.radius=0,m.splatData=new Uint8Array(a*L),m.splatData.set(e.slice(c*L,c*L+L),0),m.splatCount=1,i.map.set(g,m);else{if(m.splatData.byteLength/L==m.splatCount){const S=new Uint8Array(m.splatData.byteLength+a*L);S.set(m.splatData,0),m.splatData=S}m.minX=Math.min(m.minX,l),m.maxX=Math.max(m.maxX,l),m.minY=Math.min(m.minY,d),m.maxY=Math.max(m.maxY,d),m.minZ=Math.min(m.minZ,p),m.maxZ=Math.max(m.maxZ,p),m.centerX=(m.maxX+m.minX)/2,m.centerY=(m.maxY+m.minY)/2,m.centerZ=(m.maxZ+m.minZ)/2;const A=m.maxX-m.minX,M=m.maxY-m.minY,x=m.maxZ-m.minZ;m.radius=Math.sqrt(A*A+M*M+x*x)/2,m.splatData.set(e.slice(c*L,c*L+L),m.splatCount++*L)}i.dataSplatCount++}}const Xe=re?20480:51200;async function Aa(i){try{i.status=R.Fetching;const a=i.abortController.signal,o=i.opts.fetchReload?"reload":"default",s=await fetch(i.opts.url,{mode:"cors",credentials:"omit",cache:o,signal:a});if(s.status!=200){console.warn(`fetch error: ${s.status}`),i.status===R.Fetching&&(i.status=R.FetchFailed);return}const r=s.body.getReader(),c=parseInt(s.headers.get("content-length")||"0");i.fileSize=c,i.downloadSize=0,i.downloadSplatCount=0,i.watermarkData=new Uint8Array(0);let f=new Uint8Array(256),l=0,d=[],p;for(;;){let{done:g,value:h}=await r.read();if(g)break;if(i.downloadSize+=h.byteLength,d){if(d.push(h),i.downloadSize<200)continue;const y=new Uint8Array(i.downloadSize);for(let m=0,A=0;m<d.length;m++)y.set(d[m],A),A+=d[m].byteLength;if(p=n(y),!p){d=[y];continue}d=null,h=y.slice(p.headerLength),i.rowLength=p.rowLength,i.dataShDegree=p.shDegree,i.modelSplatCount=p.vertexCount,i.splatData=new Uint8Array(Math.min(i.modelSplatCount,i.fetchLimit)*32)}l+h.byteLength<i.rowLength?(f.set(h,l),l+=h.byteLength):(l=await e(p,i,l,f,h),l&&f.set(h.slice(h.byteLength-l),0)),i.downloadSplatCount>=i.fetchLimit&&i.abortController.abort()}}catch(a){a.name==="AbortError"?(console.log("Fetch Abort",i.opts.url),i.status===R.Fetching&&(i.status=R.FetchAborted)):(console.error(a),i.status===R.Fetching&&(i.status=R.FetchFailed))}finally{i.status===R.Fetching&&(i.status=R.FetchDone)}async function e(a,o,s,r,c){return new Promise(async f=>{let l=(s+c.byteLength)/o.rowLength|0,d=(s+c.byteLength)%o.rowLength,p;s?(p=new Uint8Array(l*o.rowLength),p.set(r.slice(0,s),0),p.set(c.slice(0,c.byteLength-d),s)):p=c.slice(0,l*o.rowLength),o.downloadSplatCount+l>o.fetchLimit&&(l=o.fetchLimit-o.downloadSplatCount,d=0);const g=async()=>{if(l>Xe){const h=await t(a,p,Xe);Ni(o,h),o.downloadSplatCount+=Xe,l-=Xe,p=p.slice(Xe*o.rowLength),setTimeout(g)}else{const h=await t(a,p,l);Ni(o,h),o.downloadSplatCount+=l,f(d)}};await g()})}async function t(a,o,s){const r=new Uint8Array(s*na),c=new Float32Array(o.buffer),f=new Float32Array(r.buffer);for(let l=0;l<s;l++)f[l*8+0]=c[(l*i.rowLength+a.offsets.x)/4],f[l*8+1]=c[(l*i.rowLength+a.offsets.y)/4],f[l*8+2]=c[(l*i.rowLength+a.offsets.z)/4],f[l*8+3]=Math.exp(c[(l*i.rowLength+a.offsets.scale_0)/4]),f[l*8+4]=Math.exp(c[(l*i.rowLength+a.offsets.scale_1)/4]),f[l*8+5]=Math.exp(c[(l*i.rowLength+a.offsets.scale_2)/4]),r[l*32+24]=ee((.5+vt*c[(l*i.rowLength+a.offsets.f_dc_0)/4])*255),r[l*32+25]=ee((.5+vt*c[(l*i.rowLength+a.offsets.f_dc_1)/4])*255),r[l*32+26]=ee((.5+vt*c[(l*i.rowLength+a.offsets.f_dc_2)/4])*255),r[l*32+27]=ee(1/(1+Math.exp(-c[(l*i.rowLength+a.offsets.opacity)/4]))*255),r[l*32+28]=ee(c[(l*i.rowLength+a.offsets.rot_0)/4]*128+128),r[l*32+29]=ee(c[(l*i.rowLength+a.offsets.rot_1)/4]*128+128),r[l*32+30]=ee(c[(l*i.rowLength+a.offsets.rot_2)/4]*128+128),r[l*32+31]=ee(c[(l*i.rowLength+a.offsets.rot_3)/4]*128+128);if(a.shDegree==3){const d=new Uint8Array(s*24+8),p=new Uint8Array(s*21+8),g=new Uint32Array(2);g[0]=s,g[1]=qe,d.set(new Uint8Array(g.buffer),0);const h=new Uint32Array(2);h[0]=s,h[1]=ln,p.set(new Uint8Array(h.buffer),0);for(let A=0,M=0;A<s;A++)for(let x=0;x<8;x++)for(let S=0;S<3;S++)d[8+M++]=bt(c[(A*i.rowLength+a.offsets["f_rest_"+(x+S*15)])/4]);for(let A=0,M=0;A<s;A++)for(let x=8;x<15;x++)for(let S=0;S<3;S++)p[8+M++]=bt(c[(A*i.rowLength+a.offsets["f_rest_"+(x+S*15)])/4]);const y=await ce(d);i.sh12Data.push(y.datas);const m=await ce(p);i.sh3Data.push(m.datas)}else if(a.shDegree==2){const d=new Uint8Array(s*24+8),p=new Uint32Array(2);p[0]=s,p[1]=qe,d.set(new Uint8Array(p.buffer),0);for(let h=0,y=0;h<s;h++)for(let m=0;m<8;m++)for(let A=0;A<3;A++)d[8+y++]=bt(c[(h*i.rowLength+a.offsets["f_rest_"+(m+A*8)])/4]);const g=await ce(d);i.sh12Data.push(g.datas)}else if(a.shDegree==1){const d=new Uint8Array(s*9+8),p=new Uint32Array(2);p[0]=s,p[1]=cn,d.set(new Uint8Array(p.buffer),0);for(let h=0,y=0;h<s;h++)for(let m=0;m<3;m++)for(let A=0;A<3;A++)d[8+y++]=bt(c[(h*i.rowLength+a.offsets["f_rest_"+(m+A*3)])/4]);const g=await ce(d);i.sh12Data.push(g.datas)}return await fn(r,s)}function n(a){let o=new TextDecoder().decode(a.slice(0,2048));const s=`end_header
|
|
2
|
+
`,r=o.indexOf(s);if(r<0){if(a.byteLength>1024*2)throw new Error("Unable to read .ply file header");return null}if(!o.startsWith("ply")||o.indexOf("format binary_little_endian 1.0")<0)throw new Error("Unknow .ply file header");const c=parseInt(/element vertex (\d+)\n/.exec(o)[1]);let f=0,l={},d={};const p={double:"getFloat64",int:"getInt32",uint:"getUint32",float:"getFloat32",short:"getInt16",ushort:"getUint16",uchar:"getUint8"};for(let y of o.slice(0,r).split(`
|
|
3
|
+
`).filter(m=>m.startsWith("property "))){const[m,A,M]=y.split(" "),x=p[A]||"getInt8";d[M]=x,l[M]=f,f+=parseInt(x.replace(/[^\d]/g,""))/8}let g=0;d.f_rest_44?g=3:d.f_rest_23?g=2:d.f_rest_8&&(g=1);const h=["x","y","z","scale_0","scale_1","scale_2","f_dc_0","f_dc_1","f_dc_2","opacity","rot_0","rot_1","rot_2","rot_3"];for(let y=0;y<h.length;y++){const m=h[y];if(!d[m])throw new Error(`Property not found: ${m}`)}return{headerLength:r+s.length,offsets:l,rowLength:f,vertexCount:c,shDegree:g}}}function Ni(i,e){let t=e.byteLength/L;const n=Math.min(i.fetchLimit,i.modelSplatCount);i.dataSplatCount+t>n?(t=n-i.dataSplatCount,i.splatData.set(e.slice(0,t*L),i.dataSplatCount*L)):i.splatData.set(e,i.dataSplatCount*L);const a=new Float32Array(e.buffer);for(let s=0,r=0,c=0,f=0;s<t;s++)r=a[s*8],c=a[s*8+1],f=a[s*8+2],i.minX=Math.min(i.minX,r),i.maxX=Math.max(i.maxX,r),i.minY=Math.min(i.minY,c),i.maxY=Math.max(i.maxY,c),i.minZ=Math.min(i.minZ,f),i.maxZ=Math.max(i.maxZ,f);i.dataSplatCount+=t;const o=0;i.currentRadius=Math.sqrt(i.maxX*i.maxX+o*o+i.maxZ*i.maxZ),i.aabbCenter=new u.Vector3((i.minX+i.maxX)/2,(i.minY+i.maxY)/2,(i.minZ+i.maxZ)/2)}const z=re?20480:51200,hn=16;async function ya(i){try{i.status=R.Fetching;const a=i.abortController.signal,o=i.opts.fetchReload?"reload":"default",s=await fetch(i.opts.url,{mode:"cors",credentials:"omit",cache:o,signal:a});if(s.status!=200){console.warn(`fetch error: ${s.status}`),i.status===R.Fetching&&(i.status=R.FetchFailed);return}const r=s.body.getReader(),c=parseInt(s.headers.get("content-length")||"0");i.fileSize=c,i.downloadSize=0,i.downloadSplatCount=0,i.watermarkData=new Uint8Array(0);const f=new Uint8Array(c);for(;;){let{done:p,value:g}=await r.read();if(p)break;f.set(g,i.downloadSize),i.downloadSize+=g.length}const l=await $i(f);if(!l||l.length<16){console.error("Invalid spz format"),i.status=R.Invalid;return}const d=n(l);i.modelSplatCount=d.numPoints,i.dataShDegree=d.shDegree,i.splatData=new Uint8Array(Math.min(i.modelSplatCount,i.fetchLimit)*32),await e(d,i,l)}catch(a){a.name==="AbortError"?(console.log("Fetch Abort",i.opts.url),i.status===R.Fetching&&(i.status=R.FetchAborted)):(console.error(a),i.status===R.Fetching&&(i.status=R.FetchFailed))}finally{i.status===R.Fetching&&(i.status=R.FetchDone)}async function e(a,o,s){const r=a.numPoints*9,c=a.numPoints,f=a.numPoints*3,l=a.numPoints*3,d=a.numPoints*3,p=hn,g=p+r,h=g+c,y=h+f,m=y+l,A=m+d,M=Math.min(a.numPoints,o.fetchLimit),x=Math.ceil(M/z);for(let S=0;S<x;S++){let T=S<x-1?z:M-S*z;o.dataSplatCount+T>o.fetchLimit&&(T=o.fetchLimit-o.dataSplatCount);const v=new Uint8Array(T*20+8),I=new Uint32Array(2);I[0]=T,I[1]=ca,v.set(new Uint8Array(I.buffer),0);let b=8;for(let C=0;C<T;C++)v[b++]=s[p+(S*z+C)*9+0],v[b++]=s[p+(S*z+C)*9+1],v[b++]=s[p+(S*z+C)*9+2];for(let C=0;C<T;C++)v[b++]=s[p+(S*z+C)*9+3],v[b++]=s[p+(S*z+C)*9+4],v[b++]=s[p+(S*z+C)*9+5];for(let C=0;C<T;C++)v[b++]=s[p+(S*z+C)*9+6],v[b++]=s[p+(S*z+C)*9+7],v[b++]=s[p+(S*z+C)*9+8];for(let C=0;C<T;C++)v[b++]=s[y+(S*z+C)*3];for(let C=0;C<T;C++)v[b++]=s[y+(S*z+C)*3+1];for(let C=0;C<T;C++)v[b++]=s[y+(S*z+C)*3+2];for(let C=0;C<T;C++)v[b++]=gn(s[h+(S*z+C)*3]);for(let C=0;C<T;C++)v[b++]=gn(s[h+(S*z+C)*3+1]);for(let C=0;C<T;C++)v[b++]=gn(s[h+(S*z+C)*3+2]);const D=[];for(let C=0,B=0,k=0,P=0;C<T;C++)v[b++]=s[g+(S*z+C)],B=s[m+(S*z+C)*3+0],k=s[m+(S*z+C)*3+1],P=s[m+(S*z+C)*3+2],D.push(wa(B,k,P));for(let C=0;C<T;C++)v[b++]=D[C][0];for(let C=0;C<T;C++)v[b++]=D[C][1];for(let C=0;C<T;C++)v[b++]=D[C][2];for(let C=0;C<T;C++)v[b++]=D[C][3];const E=await ce(v);if(t(a,o,E.datas),a.shDegree===1){const C=new Uint8Array(T*9+8),B=new Uint32Array(2);B[0]=T,B[1]=cn,C.set(new Uint8Array(B.buffer),0);for(let P=0,F=8;P<T;P++)C.set(s.slice(A+(S*z+P)*9,A+(S*z+P)*9+9),F),F+=9;const k=await ce(C);o.sh12Data.push(k.datas)}else if(a.shDegree===2){const C=new Uint8Array(T*24+8),B=new Uint32Array(2);B[0]=T,B[1]=qe,C.set(new Uint8Array(B.buffer),0);for(let P=0,F=8;P<T;P++)C.set(s.slice(A+(S*z+P)*24,A+(S*z+P)*24+24),F),F+=24;const k=await ce(C);o.sh12Data.push(k.datas)}else if(a.shDegree===3){const C=new Uint8Array(T*24+8),B=new Uint32Array(2);B[0]=T,B[1]=qe,C.set(new Uint8Array(B.buffer),0);for(let Q=0,se=8;Q<T;Q++)C.set(s.slice(A+(S*z+Q)*45,A+(S*z+Q)*45+24),se),se+=24;const k=await ce(C);o.sh12Data.push(k.datas);const P=new Uint8Array(T*21+8),F=new Uint32Array(2);F[0]=T,F[1]=ln,P.set(new Uint8Array(F.buffer),0);for(let Q=0,se=8;Q<T;Q++)P.set(s.slice(A+(S*z+Q)*45+24,A+(S*z+Q)*45+45),se),se+=21;const O=await ce(P);o.sh3Data.push(O.datas)}if(o.dataSplatCount>=o.fetchLimit)break}}function t(a,o,s){let r=s.byteLength/L;const c=Math.min(o.fetchLimit,a.numPoints);o.dataSplatCount+r>c?(r=c-o.dataSplatCount,o.splatData.set(s.slice(0,r*L),o.dataSplatCount*L)):o.splatData.set(s,o.dataSplatCount*L);const f=new Float32Array(s.buffer);for(let d=0,p=0,g=0,h=0;d<r;d++)p=f[d*8],g=f[d*8+1],h=f[d*8+2],o.minX=Math.min(o.minX,p),o.maxX=Math.max(o.maxX,p),o.minY=Math.min(o.minY,g),o.maxY=Math.max(o.maxY,g),o.minZ=Math.min(o.minZ,h),o.maxZ=Math.max(o.maxZ,h);o.dataSplatCount+=r,o.downloadSplatCount+=r;const l=0;o.currentRadius=Math.sqrt(o.maxX*o.maxX+l*l+o.maxZ*o.maxZ),o.aabbCenter=new u.Vector3((o.minX+o.maxX)/2,(o.minY+o.maxY)/2,(o.minZ+o.maxZ)/2)}function n(a){const o=a.slice(0,hn),s=new Uint32Array(o.buffer),r={};if(r.magic=s[0],r.version=s[1],r.numPoints=s[2],r.shDegree=o[12],r.fractionalBits=o[13],r.flags=o[14],r.reserved=o[15],r.magic!==1347635022)throw new Error("[SPZ ERROR] header not found");if(r.version!==2)throw new Error("[SPZ ERROR] ersion not supported:"+r.version);if(r.shDegree>3)throw new Error("[SPZ ERROR] unsupported SH degree:"+r.shDegree);if(r.fractionalBits!==12)throw new Error("[SPZ ERROR] unsupported FractionalBits:"+r.fractionalBits);let c=0;if(r.shDegree===1?c=9:r.shDegree===2?c=24:r.shDegree===3&&(c=45),a.length!==hn+r.numPoints*(19+c))throw new Error("[SPZ ERROR] invalid spz data");return r}}function gn(i){const e=(i-127.5)/38.25;return ee((.5+vt*e)*255)}function wa(i,e,t){const n=i/127.5-1,a=e/127.5-1,o=t/127.5-1,s=Math.sqrt(Math.max(0,1-(n*n+a*a+o*o)));return[ee(s*128+128),ee(n*128+128),ee(a*128+128),ee(o*128+128)]}function va(i){const e=(M,x,S)=>i.on(M,x,S),t=(M,...x)=>i.fire(M,...x);let n,a=Date.now()+36e5,o=null,s,r={index:0,version:0},c={version:0},f=!1;const l=t(J);e(Ri,()=>s?.aabbCenter||new u.Vector3);let d;const p=new Promise(M=>d=M);e(ze,async()=>{const M=t(_);let x=re?M.maxRenderCountOfMobile:M.maxRenderCountOfPc;if(!M.bigSceneMode){let S=await p;x=Math.min(S,x)+10240}return x}),e(je,async M=>{const x=t(_);if(x.bigSceneMode)return 1;let S=re?x.maxRenderCountOfMobile:x.maxRenderCountOfPc,T=await p;if(S=Math.min(T,S),!s.dataShDegree)return 1;if(M>=3){if(s.dataShDegree<3)return 1}else if(M>=1){if(s.dataShDegree<1)return 1}else return 1;const v=1024*2;return Math.ceil(S/v)}),e(nn,async()=>t(_).bigSceneMode?0:(await p,s.dataShDegree)),e(Zt,async(M,x=!0)=>{try{await p;const S=!!s.header?.Flag2;o=await t(xi,M,x,S),s&&(s.textWatermarkVersion=Date.now())}catch{console.info("failed to generate watermark")}}),e(Wt,()=>{if(l)return r.version<=c.version?r.xyz:c.xyz;if(s?.status===R.FetchDone||s?.status===R.FetchAborted){if(s.activePoints&&s.activePoints.length===void 0)return s.activePoints;const M={},x=r.xyz;for(let S=0,T=x.length/3,v=0,I=0,b=0,D="";S<T;S++)v=x[S*3],I=x[S*3+1],b=x[S*3+2],D=`${Math.floor(v/2)*2+1},${Math.floor(I/2)*2+1},${Math.floor(b/2)*2+1}`,(M[D]=M[D]||[]).push(v,I,b);return s.activePoints=M}return r.xyz});async function g(M){if(n)return;if(s&&(s.status===R.Invalid||s.status===R.FetchFailed))return t(_).viewerEvents?.fire(j),t(ct,0)||t(ne,{renderSplatCount:0,visibleSplatCount:0,modelSplatCount:0});if(!s||!s.downloadSize)return;const x=s.status!==R.FetchReady&&s.status!==R.Fetching;if(x){const S=Math.min(s.fetchLimit,s.downloadSplatCount);!s.notifyFetchStopDone&&(s.notifyFetchStopDone=!0)&&t(ct,S)}else t(li,100*s.downloadSize/s.fileSize);s.downloadSplatCount&&(f||(f=!0,setTimeout(async()=>{await h(x),f=!1})))}async function h(M){if(n)return;const x=r,S=await t(ze),T=o;let v=s.dataSplatCount,I=M?s.watermarkCount:0,b=s.meta.showWatermark&&M?(T?.byteLength||0)/32:0;if(s.renderSplatCount=v+I+b,s.renderSplatCount>=S&&(s.renderSplatCount=S,I=0,b=0,v>S&&(v=S)),t(ne,{visibleSplatCount:s.renderSplatCount,modelSplatCount:s.modelSplatCount+b}),Date.now()-x.textureReadyTime<(re?600:300)||s.smallSceneUploadDone&&s.lastTextWatermarkVersion==s.textWatermarkVersion)return;if(!x.version){t(Zn,(s.header?.Flag2?s.header.MaxTopY:s.header?.MinTopY)||0);let O=s.opts.format;s.opts.format=="spx"&&(O="spx"+(s.header.ExclusiveId?(" "+s.header.ExclusiveId).substring(0,6):"")),t(ne,{scene:`small (${O})`})}s.lastTextWatermarkVersion=s.textWatermarkVersion,x.textureReady=!1;const D=1024*2,E=Math.ceil(2*S/D),C=new Uint32Array(D*E*4),B=new Float32Array(C.buffer),k=new Uint8Array(C.buffer);k.set(s.splatData.slice(0,v*32),0),I&&k.set(s.watermarkData.slice(0,I*32),v*32),b&&k.set(T.slice(0,b*32),(v+I)*32);const P=new Float32Array(s.renderSplatCount*3);for(let O=0,Q=0;O<s.renderSplatCount;O++)P[O*3]=B[O*8],P[O*3+1]=B[O*8+1],P[O*3+2]=B[O*8+2];const F=Date.now();if(x.version=F,x.txdata=C,x.xyz=P,x.renderSplatCount=s.renderSplatCount,x.visibleSplatCount=s.downloadSplatCount+b,x.modelSplatCount=s.downloadSplatCount+b,x.watermarkCount=I+b,x.minX=s.minX,x.maxX=s.maxX,x.minY=s.minY,x.maxY=s.maxY,x.minZ=s.minZ,x.maxZ=s.maxZ,t(_i,x,s.currentRadius,s.currentRadius),a=F,M&&!s.smallSceneUploadDone){s.smallSceneUploadDone=!0,t(Ii,s.sh12Data),t(Di,s.sh3Data),s.sh12Data=null,s.sh3Data=null;const O=t(_);t(Ot,O.shDegree===void 0?3:O.shDegree),t(Wt)}t(ne,{renderSplatCount:s.renderSplatCount})}function y(){n||(n=!0,s?.abortController?.abort(),s?.map?.clear(),s=null,o=null,r=null,c=null)}function m(M){if(M.opts.format==="spx")ga(M);else if(M.opts.format==="splat")fa(M);else if(M.opts.format==="ply")Aa(M);else if(M.opts.format==="spz")ya(M);else return!1;return!0}async function A(M,x){if(n)return;const S=t(_),T=re?S.maxRenderCountOfMobile:S.maxRenderCountOfPc,v=t(J);if(M.fetchReload=pa(x.updateDate||0),s=new ea(M,x),v&&x.autoCut){const D=x.pcDownloadLimitSplatCount||oa,E=x.mobileDownloadLimitSplatCount||aa,C=re?E:D;s.fetchLimit=Math.min(x.autoCut*x.autoCut*T+T,C)}else s.fetchLimit=T;const I=Date.now(),b=()=>{if(!s||s.status==R.Invalid||s.status==R.FetchFailed)return d(0);if(s.modelSplatCount>=0)d(s.modelSplatCount),setTimeout(()=>t(ri),5);else{if(Date.now()-I>=3e3)return d(0);setTimeout(b,10)}};if(b(),!m(s)){console.error("Unsupported format:",M.format),t(ct,0);return}t(ci)}e(ii,async(M,x)=>await A(M,x)),e(si,(M=1e4)=>Date.now()-a<M),e(ai,()=>y()),t(Fe,async()=>await g(),()=>!n)}function Sa(){return`
|
|
4
|
+
precision highp float;
|
|
5
|
+
|
|
6
|
+
uniform highp usampler2D splatTexture0, splatTexture1, splatShTexture12, splatShTexture3;
|
|
7
|
+
uniform vec2 focal, viewport;
|
|
8
|
+
uniform int usingIndex, pointMode, bigSceneMode, showWaterMark, debugEffect, shDegree;
|
|
9
|
+
uniform float topY, currentVisibleRadius, currentLightRadius, performanceNow;
|
|
10
|
+
uniform vec4 markPoint, waterMarkColor;
|
|
11
|
+
|
|
12
|
+
attribute uint splatIndex;
|
|
13
|
+
|
|
14
|
+
varying vec4 vColor;
|
|
15
|
+
varying vec3 vPosition;
|
|
16
|
+
|
|
17
|
+
const float FactorSH = 0.0625;
|
|
18
|
+
const uint MaskSH = 0x1Fu;
|
|
19
|
+
const float SH_C1 = 0.4886025119029199;
|
|
20
|
+
const float[5] SH_C2 = float[](1.0925484305920792f, -1.0925484305920792f, 0.31539156525252005f, -1.0925484305920792f, 0.5462742152960396f);
|
|
21
|
+
const float[7] SH_C3 = float[](-0.5900435899266435f, 2.890611442640554f, -0.4570457994644658f, 0.3731763325901154f, -0.4570457994644658f, 1.445305721320277f, -0.5900435899266435f);
|
|
22
|
+
|
|
23
|
+
vec3[15] readShDatas() {
|
|
24
|
+
int shCnt = 0;
|
|
25
|
+
float[45] fSHs;
|
|
26
|
+
uvec4 rgb12 = texelFetch(splatShTexture12, ivec2((splatIndex & 0x7ffu), (splatIndex >> 11)), 0);
|
|
27
|
+
if ( rgb12.a > 0u ) {
|
|
28
|
+
shCnt = 3;
|
|
29
|
+
fSHs[0] = float((rgb12.r >> 27) & MaskSH) * FactorSH - 1.0;
|
|
30
|
+
fSHs[1] = float((rgb12.r >> 22) & MaskSH) * FactorSH - 1.0;
|
|
31
|
+
fSHs[2] = float((rgb12.r >> 17) & MaskSH) * FactorSH - 1.0;
|
|
32
|
+
fSHs[3] = float((rgb12.r >> 12) & MaskSH) * FactorSH - 1.0;
|
|
33
|
+
fSHs[4] = float((rgb12.r >> 7) & MaskSH) * FactorSH - 1.0;
|
|
34
|
+
fSHs[5] = float((rgb12.r >> 2) & MaskSH) * FactorSH - 1.0;
|
|
35
|
+
fSHs[6] = float(( (rgb12.r << 3) | (rgb12.g >> 29) ) & MaskSH) * FactorSH - 1.0;
|
|
36
|
+
fSHs[7] = float((rgb12.g >> 24) & MaskSH) * FactorSH - 1.0;
|
|
37
|
+
fSHs[8] = float((rgb12.g >> 19) & MaskSH) * FactorSH - 1.0;
|
|
38
|
+
|
|
39
|
+
if (shDegree > 1) {
|
|
40
|
+
shCnt = 8;
|
|
41
|
+
fSHs[9] = float((rgb12.g >> 14) & MaskSH) * FactorSH - 1.0;
|
|
42
|
+
fSHs[10] = float((rgb12.g >> 9) & MaskSH) * FactorSH - 1.0;
|
|
43
|
+
fSHs[11] = float((rgb12.g >> 4) & MaskSH) * FactorSH - 1.0;
|
|
44
|
+
fSHs[12] = float(( (rgb12.g << 1) | (rgb12.b >> 31) ) & MaskSH) * FactorSH - 1.0;
|
|
45
|
+
fSHs[13] = float((rgb12.b >> 26) & MaskSH) * FactorSH - 1.0;
|
|
46
|
+
fSHs[14] = float((rgb12.b >> 21) & MaskSH) * FactorSH - 1.0;
|
|
47
|
+
fSHs[15] = float((rgb12.b >> 16) & MaskSH) * FactorSH - 1.0;
|
|
48
|
+
fSHs[16] = float((rgb12.b >> 11) & MaskSH) * FactorSH - 1.0;
|
|
49
|
+
fSHs[17] = float((rgb12.b >> 6) & MaskSH) * FactorSH - 1.0;
|
|
50
|
+
fSHs[18] = float((rgb12.b >> 1) & MaskSH) * FactorSH - 1.0;
|
|
51
|
+
fSHs[19] = float(( (rgb12.b << 4) | (rgb12.a >> 28) ) & MaskSH) * FactorSH - 1.0;
|
|
52
|
+
fSHs[20] = float(((rgb12.a >> 23) & MaskSH)) * FactorSH - 1.0;
|
|
53
|
+
fSHs[21] = float((rgb12.a >> 18) & MaskSH) * FactorSH - 1.0;
|
|
54
|
+
fSHs[22] = float((rgb12.a >> 13) & MaskSH) * FactorSH - 1.0;
|
|
55
|
+
fSHs[23] = float((rgb12.a >> 8) & MaskSH) * FactorSH - 1.0;
|
|
56
|
+
|
|
57
|
+
if (shDegree > 2) {
|
|
58
|
+
uvec4 rgb3 = texelFetch(splatShTexture3, ivec2(splatIndex & 0x7ffu, splatIndex >> 11), 0);
|
|
59
|
+
if ( rgb3.a > 0u ) {
|
|
60
|
+
shCnt = 15;
|
|
61
|
+
fSHs[24] = float((rgb3.r >> 27) & MaskSH) * FactorSH - 1.0;
|
|
62
|
+
fSHs[25] = float((rgb3.r >> 22) & MaskSH) * FactorSH - 1.0;
|
|
63
|
+
fSHs[26] = float((rgb3.r >> 17) & MaskSH) * FactorSH - 1.0;
|
|
64
|
+
fSHs[27] = float((rgb3.r >> 12) & MaskSH) * FactorSH - 1.0;
|
|
65
|
+
fSHs[28] = float((rgb3.r >> 7) & MaskSH) * FactorSH - 1.0;
|
|
66
|
+
fSHs[29] = float((rgb3.r >> 2) & MaskSH) * FactorSH - 1.0;
|
|
67
|
+
fSHs[30] = float(( (rgb3.r << 3) | (rgb3.g >> 29) ) & MaskSH) * FactorSH - 1.0;
|
|
68
|
+
fSHs[31] = float((rgb3.g >> 24) & MaskSH) * FactorSH - 1.0;
|
|
69
|
+
fSHs[32] = float((rgb3.g >> 19) & MaskSH) * FactorSH - 1.0;
|
|
70
|
+
fSHs[33] = float((rgb3.g >> 14) & MaskSH) * FactorSH - 1.0;
|
|
71
|
+
fSHs[34] = float((rgb3.g >> 9) & MaskSH) * FactorSH - 1.0;
|
|
72
|
+
fSHs[35] = float((rgb3.g >> 4) & MaskSH) * FactorSH - 1.0;
|
|
73
|
+
fSHs[36] = float(( (rgb3.g << 1) | (rgb3.b >> 31) ) & MaskSH) * FactorSH - 1.0;
|
|
74
|
+
fSHs[37] = float((rgb3.b >> 26) & MaskSH) * FactorSH - 1.0;
|
|
75
|
+
fSHs[38] = float((rgb3.b >> 21) & MaskSH) * FactorSH - 1.0;
|
|
76
|
+
fSHs[39] = float((rgb3.b >> 16) & MaskSH) * FactorSH - 1.0;
|
|
77
|
+
fSHs[40] = float((rgb3.b >> 11) & MaskSH) * FactorSH - 1.0;
|
|
78
|
+
fSHs[41] = float((rgb3.b >> 6) & MaskSH) * FactorSH - 1.0;
|
|
79
|
+
fSHs[42] = float((rgb3.b >> 1) & MaskSH) * FactorSH - 1.0;
|
|
80
|
+
fSHs[43] = float(( (rgb3.b << 4) | (rgb3.a >> 28) ) & MaskSH) * FactorSH - 1.0;
|
|
81
|
+
fSHs[44] = float((rgb3.a >> 23) & MaskSH) * FactorSH - 1.0;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
vec3[15] sh;
|
|
88
|
+
for (int i = 0; i < 15; ++i) {
|
|
89
|
+
sh[i] = i < shCnt ? vec3(fSHs[i*3], fSHs[i*3 + 1], fSHs[i*3 + 2]) : vec3(0.0);
|
|
90
|
+
}
|
|
91
|
+
return sh;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// https://github.com/graphdeco-inria/gaussian-splatting/blob/main/utils/sh_utils.py
|
|
95
|
+
vec3 evalSH(in vec3 v3Cen) {
|
|
96
|
+
vec3 dir = normalize(v3Cen - cameraPosition);
|
|
97
|
+
float x = dir.x;
|
|
98
|
+
float y = dir.y;
|
|
99
|
+
float z = dir.z;
|
|
100
|
+
|
|
101
|
+
vec3[15] sh = readShDatas();
|
|
102
|
+
vec3 result = SH_C1 * (-sh[0] * y + sh[1] * z - sh[2] * x);
|
|
103
|
+
|
|
104
|
+
if (shDegree > 1) {
|
|
105
|
+
float xx = x * x;
|
|
106
|
+
float yy = y * y;
|
|
107
|
+
float zz = z * z;
|
|
108
|
+
float xy = x * y;
|
|
109
|
+
float yz = y * z;
|
|
110
|
+
float xz = x * z;
|
|
111
|
+
|
|
112
|
+
result +=
|
|
113
|
+
sh[3] * (SH_C2[0] * xy) +
|
|
114
|
+
sh[4] * (SH_C2[1] * yz) +
|
|
115
|
+
sh[5] * (SH_C2[2] * (2.0 * zz - xx - yy)) +
|
|
116
|
+
sh[6] * (SH_C2[3] * xz) +
|
|
117
|
+
sh[7] * (SH_C2[4] * (xx - yy));
|
|
118
|
+
|
|
119
|
+
if (shDegree > 2) {
|
|
120
|
+
result +=
|
|
121
|
+
sh[8] * (SH_C3[0] * y * (3.0 * xx - yy)) +
|
|
122
|
+
sh[9] * (SH_C3[1] * xy * z) +
|
|
123
|
+
sh[10] * (SH_C3[2] * y * (4.0 * zz - xx - yy)) +
|
|
124
|
+
sh[11] * (SH_C3[3] * z * (2.0 * zz - 3.0 * xx - 3.0 * yy)) +
|
|
125
|
+
sh[12] * (SH_C3[4] * x * (4.0 * zz - xx - yy)) +
|
|
126
|
+
sh[13] * (SH_C3[5] * z * (xx - yy)) +
|
|
127
|
+
sh[14] * (SH_C3[6] * x * (xx - 3.0 * yy));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
void main () {
|
|
134
|
+
uvec4 cen, cov3d;
|
|
135
|
+
if (bigSceneMode == 1) {
|
|
136
|
+
if (usingIndex == 0){
|
|
137
|
+
cen = texelFetch(splatTexture0, ivec2((splatIndex & 0x3ffu) << 1, splatIndex >> 10), 0);
|
|
138
|
+
cov3d = texelFetch(splatTexture0, ivec2(((splatIndex & 0x3ffu) << 1) | 1u, splatIndex >> 10), 0);
|
|
139
|
+
}else{
|
|
140
|
+
cen = texelFetch(splatTexture1, ivec2((splatIndex & 0x3ffu) << 1, splatIndex >> 10), 0);
|
|
141
|
+
cov3d = texelFetch(splatTexture1, ivec2(((splatIndex & 0x3ffu) << 1) | 1u, splatIndex >> 10), 0);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
cen = texelFetch(splatTexture0, ivec2((splatIndex & 0x3ffu) << 1, splatIndex >> 10), 0);
|
|
145
|
+
cov3d = texelFetch(splatTexture0, ivec2(((splatIndex & 0x3ffu) << 1) | 1u, splatIndex >> 10), 0);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
int waterMarkValue = int((cen.w & 65536u) >> 16u);
|
|
149
|
+
int cenState = int(cen.w & 65535u);
|
|
150
|
+
|
|
151
|
+
vec3 v3Cen = uintBitsToFloat(cen.xyz);
|
|
152
|
+
|
|
153
|
+
if ( waterMarkValue == 1 && debugEffect == 1) {
|
|
154
|
+
// 水印动画
|
|
155
|
+
v3Cen.y += sin(performanceNow*0.002 + v3Cen.x) * 0.1;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
vec4 cam = modelViewMatrix * vec4(v3Cen, 1.0);
|
|
159
|
+
vec4 pos2d = projectionMatrix * cam;
|
|
160
|
+
float clip = 1.2 * pos2d.w;
|
|
161
|
+
if (pos2d.z < -clip || pos2d.x < -clip || pos2d.x > clip || pos2d.y < -clip || pos2d.y > clip
|
|
162
|
+
|| waterMarkValue == 1 && (showWaterMark == 0 || pointMode == 1) ) {
|
|
163
|
+
gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
float currentRadius = length(vec3(0.0, topY, 0.0) - v3Cen);
|
|
168
|
+
if ( currentVisibleRadius > 0.0 && currentRadius > currentVisibleRadius ) {
|
|
169
|
+
gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
vec2 uh1 = unpackHalf2x16(cov3d.x), uh2 = unpackHalf2x16(cov3d.y), uh3 = unpackHalf2x16(cov3d.z);
|
|
174
|
+
mat3 Vrk = mat3(uh1.x, uh1.y, uh2.x, uh1.y, uh2.y, uh3.x, uh2.x, uh3.x, uh3.y);
|
|
175
|
+
|
|
176
|
+
float ZxZ = cam.z * cam.z;
|
|
177
|
+
mat3 J_m3 = mat3(
|
|
178
|
+
focal.x / cam.z, 0.0, -(focal.x * cam.x) / ZxZ,
|
|
179
|
+
0.0, focal.y / cam.z, -(focal.y * cam.y) / ZxZ,
|
|
180
|
+
0.0, 0.0, 0.0
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
mat3 T_m3 = transpose(mat3(modelViewMatrix)) * J_m3;
|
|
184
|
+
mat3 cov2d = transpose(T_m3) * Vrk * T_m3;
|
|
185
|
+
|
|
186
|
+
cov2d[0][0] += 0.3;
|
|
187
|
+
cov2d[1][1] += 0.3;
|
|
188
|
+
vec3 cov2Dv = vec3(cov2d[0][0], cov2d[0][1], cov2d[1][1]);
|
|
189
|
+
float eigenValue1 = 0.5 * (cov2Dv.x + cov2Dv.z) + sqrt((cov2Dv.x + cov2Dv.z) * (cov2Dv.x + cov2Dv.z) / 4.0 - (cov2Dv.x * cov2Dv.z - cov2Dv.y * cov2Dv.y));
|
|
190
|
+
float eigenValue2 = max( 0.5 * (cov2Dv.x + cov2Dv.z) - sqrt((cov2Dv.x + cov2Dv.z) * (cov2Dv.x + cov2Dv.z) / 4.0 - (cov2Dv.x * cov2Dv.z - cov2Dv.y * cov2Dv.y)), 0.0);
|
|
191
|
+
float eigenValueOrig1 = eigenValue1;
|
|
192
|
+
float eigenValueOrig2 = eigenValue2;
|
|
193
|
+
|
|
194
|
+
int lightColorFlag = 0;
|
|
195
|
+
if ( waterMarkValue == 0 ) {
|
|
196
|
+
if ( pointMode == 1 ) {
|
|
197
|
+
eigenValue1 = eigenValue2 = 0.5;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if ( bigSceneMode == 0 && currentLightRadius > 0.0 ) {
|
|
201
|
+
// 仅小场景支持光圈过渡效果
|
|
202
|
+
if ( currentRadius < currentLightRadius && currentRadius > currentLightRadius * 0.9 ) {
|
|
203
|
+
eigenValue1 = eigenValueOrig1;
|
|
204
|
+
eigenValue2 = eigenValueOrig2;
|
|
205
|
+
lightColorFlag = 1;
|
|
206
|
+
}
|
|
207
|
+
if ( currentRadius < currentLightRadius * 0.9 ){
|
|
208
|
+
if ( pointMode == 1 ){
|
|
209
|
+
eigenValue1 = eigenValueOrig1;
|
|
210
|
+
eigenValue2 = eigenValueOrig2;
|
|
211
|
+
} else {
|
|
212
|
+
eigenValue1 = eigenValue2 = 0.5;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
int iSelectPoint = 0;
|
|
219
|
+
if (markPoint.w > 0.0 && length(vec3(markPoint.xyz) - v3Cen) < 0.000001){
|
|
220
|
+
iSelectPoint = 1;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
vPosition = vec3(position.xy, -1.0);
|
|
224
|
+
vec2 eigenVector1 = normalize(vec2(cov2Dv.y, eigenValue1 - cov2Dv.x));
|
|
225
|
+
if (iSelectPoint == 1){
|
|
226
|
+
vColor = vec4(1.0, 1.0, 0.0, 1.0);
|
|
227
|
+
eigenValue1 = eigenValue2 = 10.0;
|
|
228
|
+
eigenVector1 = normalize(vec2(10.0, eigenValue1 - 10.0));
|
|
229
|
+
vPosition.z = 1.0;
|
|
230
|
+
} else if ( lightColorFlag == 1 ) {
|
|
231
|
+
vColor = vec4(1.0, 1.0, 1.0, 0.2);
|
|
232
|
+
} else if ( waterMarkValue == 1 ) {
|
|
233
|
+
vColor = waterMarkColor;
|
|
234
|
+
} else {
|
|
235
|
+
vColor = vec4( float(cov3d.w & 0xFFu) / 255.0, float((cov3d.w >> 8) & 0xFFu) / 255.0, float((cov3d.w >> 16) & 0xFFu) / 255.0, float(cov3d.w >> 24) / 255.0 );
|
|
236
|
+
if (shDegree > 0) {
|
|
237
|
+
vColor.rgb += evalSH(v3Cen);
|
|
238
|
+
vColor.rgb = clamp(vColor.rgb, vec3(0.), vec3(1.));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
vec2 eigenVector2 = vec2(eigenVector1.y, -eigenVector1.x);
|
|
243
|
+
vec2 majorAxis = eigenVector1 * min(sqrt(2.0 * eigenValue1), 1024.0);
|
|
244
|
+
vec2 minorAxis = eigenVector2 * min(sqrt(2.0 * eigenValue2), 1024.0);
|
|
245
|
+
|
|
246
|
+
vec2 v2Center = vec2(pos2d) / pos2d.w; // NDC坐标
|
|
247
|
+
gl_Position = vec4(
|
|
248
|
+
v2Center
|
|
249
|
+
+ vPosition.x * majorAxis / viewport
|
|
250
|
+
+ vPosition.y * minorAxis / viewport
|
|
251
|
+
, 1.0, 1.0);
|
|
252
|
+
|
|
253
|
+
}
|
|
254
|
+
`}function ba(){return`
|
|
255
|
+
precision highp float;
|
|
256
|
+
|
|
257
|
+
uniform float lightFactor;
|
|
258
|
+
|
|
259
|
+
varying vec4 vColor;
|
|
260
|
+
varying vec3 vPosition;
|
|
261
|
+
|
|
262
|
+
void main(){
|
|
263
|
+
float dtPos = -dot(vPosition.xy, vPosition.xy);
|
|
264
|
+
if (dtPos < -4.0) discard;
|
|
265
|
+
|
|
266
|
+
dtPos = vPosition.z > 0.0 ? 1.0 : exp(dtPos) * vColor.a;
|
|
267
|
+
gl_FragColor = vec4(lightFactor * vColor.rgb, dtPos);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
`}function xa(){return`
|
|
271
|
+
uniform vec2 viewport;
|
|
272
|
+
uniform vec3 realFocusPosition;
|
|
273
|
+
|
|
274
|
+
varying vec4 ndcPosition;
|
|
275
|
+
varying vec4 ndcCenter;
|
|
276
|
+
varying vec4 ndcFocusPosition;
|
|
277
|
+
varying float vAngle;
|
|
278
|
+
|
|
279
|
+
void main() {
|
|
280
|
+
vec4 viewPosition = modelViewMatrix * vec4(position.xyz, 1.0);
|
|
281
|
+
vec4 viewCenter = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);
|
|
282
|
+
|
|
283
|
+
vec4 viewFocusPosition = modelViewMatrix * vec4(realFocusPosition, 1.0);
|
|
284
|
+
|
|
285
|
+
ndcPosition = projectionMatrix * viewPosition;
|
|
286
|
+
ndcPosition = ndcPosition * vec4(1.0 / ndcPosition.w);
|
|
287
|
+
ndcCenter = projectionMatrix * viewCenter;
|
|
288
|
+
ndcCenter = ndcCenter * vec4(1.0 / ndcCenter.w);
|
|
289
|
+
|
|
290
|
+
ndcFocusPosition = projectionMatrix * viewFocusPosition;
|
|
291
|
+
ndcFocusPosition = ndcFocusPosition * vec4(1.0 / ndcFocusPosition.w);
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
// 计算角度
|
|
295
|
+
vec2 screenPosition = vec2(ndcPosition) * viewport;
|
|
296
|
+
vec2 screenCenter = vec2(ndcCenter) * viewport;
|
|
297
|
+
vec2 screenVec = screenPosition - screenCenter;
|
|
298
|
+
float angle = atan(screenVec.y, screenVec.x);
|
|
299
|
+
|
|
300
|
+
// 将角度从弧度转换为度数
|
|
301
|
+
vAngle = angle * (180.0 / 3.14159265) + 90.0;
|
|
302
|
+
|
|
303
|
+
gl_Position = projectionMatrix * viewPosition;
|
|
304
|
+
|
|
305
|
+
}
|
|
306
|
+
`}function Ma(){return`
|
|
307
|
+
uniform vec3 cycleColor;
|
|
308
|
+
uniform vec2 viewport;
|
|
309
|
+
uniform float opacity;
|
|
310
|
+
|
|
311
|
+
varying vec4 ndcPosition;
|
|
312
|
+
varying vec4 ndcCenter;
|
|
313
|
+
varying vec4 ndcFocusPosition;
|
|
314
|
+
varying float vAngle;
|
|
315
|
+
|
|
316
|
+
void main() {
|
|
317
|
+
vec2 screenPosition = vec2(ndcPosition) * viewport;
|
|
318
|
+
vec2 screenCenter = vec2(ndcCenter) * viewport;
|
|
319
|
+
|
|
320
|
+
vec2 screenVec = screenPosition - screenCenter;
|
|
321
|
+
|
|
322
|
+
float projectedRadius = length(screenVec);
|
|
323
|
+
|
|
324
|
+
float lineWidth = 0.0005 * viewport.y;
|
|
325
|
+
float aaRange = 0.0025 * viewport.y;
|
|
326
|
+
float radius = 0.06 * viewport.y;
|
|
327
|
+
float radDiff = abs(projectedRadius - radius) - lineWidth;
|
|
328
|
+
float alpha = 1.0 - clamp(radDiff / 5.0, 0.0, 1.0);
|
|
329
|
+
|
|
330
|
+
// 将圆分成3段显示
|
|
331
|
+
float segmentAngle = 120.0;
|
|
332
|
+
if (mod(vAngle, segmentAngle) > segmentAngle * 0.8) {
|
|
333
|
+
alpha = 0.0;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
gl_FragColor = vec4(cycleColor.rgb, alpha * opacity);
|
|
337
|
+
}
|
|
338
|
+
`}const Gi="currentVisibleRadius",Yi="currentLightRadius",ji="realFocusPosition",mn="splatShTexture12",An="splatShTexture3",qi="performanceNow",Ca="waterMarkColor",Xi="showWaterMark",yn="splatTexture0",wn="splatTexture1",Zi="bigSceneMode",Ki="lightFactor",Ji="debugEffect",es="usingIndex",Ta="cycleColor",Ea="splatIndex",ts="pointMode",ns="markPoint",is="shDegree",Ze="viewport",vn="opacity",ss="focal",as="topY";let V=0;V++;const os=`$${V++}`;V++,V++,V++;const rs=`$${V++}`,ka=`$${V++}`,cs=`$${V++}`,_a=`$${V++}`,Ia=`$${V++}`,Da=`$${V++}`,Pa=`$${V++}`,Ra=`$${V++}`;V++;const Ba=`$${V++}`,La=`$${V++}`;V++;const Ua=`$${V++}`;V++;const Fa=`$${V++}`;V++;const Oa=`$${V++}`,za=`$${V++}`,Va=`$${V++}`,Ha=`$${V++}`,Qa=`$${V++}`,Wa=`$${V++}`,$a=`$${V++}`,Na=`$${V++}`;V++;function Ga(i){let e=!1;const t=(d,p,g)=>i.on(d,p,g),n=(d,...p)=>i.fire(d,...p);let a=0,o=0;const s=[];let r=0;t(Pi,()=>r),t(Wn,async()=>{const d=new u.InstancedBufferGeometry;d.setIndex([0,1,2,0,2,3]);const p=new Float32Array(4*3),g=new u.BufferAttribute(p,3);d.setAttribute("position",g),g.setXYZ(0,-2,-2,0),g.setXYZ(1,-2,2,0),g.setXYZ(2,2,2,0),g.setXYZ(3,2,-2,0),g.needsUpdate=!0;let h=new u.InstancedBufferGeometry().copy(d);const y=await n(ze);if(e)return;const m=new Uint32Array(y),A=new u.InstancedBufferAttribute(m,1,!1);return A.setUsage(u.DynamicDrawUsage),A.needsUpdate=!0,h.setAttribute(Ea,A),h.instanceCount=0,t(Yn,(M,x,S,T)=>{n(qn,x),m.set(M,0),A.clearUpdateRanges(),A.addUpdateRange(0,M.length),A.needsUpdate=!0,h.instanceCount=M.length,n(N),n(ne,{sortTime:`${S} / ${Date.now()-T}`})}),t(Rs,()=>h),t(Jn,()=>{A.array=null,h.dispose()}),h}),t($n,async()=>{const d=await n(ze);if(e)return;const p=1024*2,g=Math.ceil(2*d/p),h=n(_),y=new u.ShaderMaterial({uniforms:n(Qn),vertexShader:Sa(),fragmentShader:ba(),transparent:!0,alphaTest:1,blending:u.NormalBlending,depthTest:h.depthTest!==!1,depthWrite:!1,side:u.DoubleSide}),m=new Uint32Array(p*g*4);let A=new u.DataTexture(m,p,g,u.RGBAIntegerFormat,u.UnsignedIntType);A.internalFormat="RGBA32UI",A.needsUpdate=!0,y.uniforms[yn].value=A;const M=n(J)?g:1,x=new Uint32Array(p*M*4);let S=new u.DataTexture(x,p,M,u.RGBAIntegerFormat,u.UnsignedIntType);S.internalFormat="RGBA32UI",S.needsUpdate=!0,y.uniforms[wn].value=S;const T=await n(je,1),v=new Uint32Array(p*T*4);let I=new u.DataTexture(v,p,T,u.RGBAIntegerFormat,u.UnsignedIntType);I.internalFormat="RGBA32UI",I.needsUpdate=!0,y.uniforms[mn].value=I;const b=await n(je,3),D=new Uint32Array(p*b*4);let E=new u.DataTexture(D,p,b,u.RGBAIntegerFormat,u.UnsignedIntType);E.internalFormat="RGBA32UI",E.needsUpdate=!0,y.uniforms[An].value=E,y.needsUpdate=!0;let C=!1;t(jn,k=>{if(!n(J)){if(C&&!k.renderSplatCount)return;C=!k.renderSplatCount}const P=k.txdata;k.txdata=null;const F=new u.DataTexture(P,p,g,u.RGBAIntegerFormat,u.UnsignedIntType);F.onUpdate=()=>{k.textureReady=!0,k.textureReadyTime=Date.now(),l(k),n(di,k.renderSplatCount)},F.internalFormat="RGBA32UI",F.needsUpdate=!0,k.index?(y.uniforms[wn].value=F,S=F):(y.uniforms[yn].value=F,A=F),y.needsUpdate=!0,n(N)}),t(Ii,async k=>{if(n(J)||!k||!k.length)return;const P=new Uint32Array(p*await n(je,1)*4),F=new Uint8Array(P.buffer);for(let Q=0,se=0;Q<k.length;Q++)F.set(k[Q],se),se+=k[Q].byteLength;const O=new u.DataTexture(P,p,T,u.RGBAIntegerFormat,u.UnsignedIntType);O.internalFormat="RGBA32UI",O.needsUpdate=!0,y.uniforms[mn].value=O,y.needsUpdate=!0,n(N)}),t(Di,async k=>{if(n(J)||!k||!k.length)return;const P=new Uint32Array(p*await n(je,3)*4),F=new Uint8Array(P.buffer);for(let Q=0,se=0;Q<k.length;Q++)F.set(k[Q],se),se+=k[Q].byteLength;const O=new u.DataTexture(P,p,T,u.RGBAIntegerFormat,u.UnsignedIntType);O.internalFormat="RGBA32UI",O.needsUpdate=!0,y.uniforms[An].value=O,y.needsUpdate=!0,n(N)}),t(Gn,()=>y),t(Bt,()=>{const k=n($),{width:P,height:F}=n(xe),O=Math.abs(k.projectionMatrix.elements[0])*.5*P,Q=Math.abs(k.projectionMatrix.elements[5])*.5*F,se=n(Gn);se.uniforms[ss].value.set(O,Q),se.uniformsNeedUpdate=!0,n(N)}),t(Lt,()=>{const{width:k,height:P}=n(xe);y.uniforms[Ze].value.set(k,P),y.uniformsNeedUpdate=!0,n(N)}),t(qn,k=>{y.uniforms[es].value=k,y.uniformsNeedUpdate=!0,n(N)}),t(Ve,k=>{const P=n(_);k===void 0&&(k=!P.pointcloudMode),y.uniforms[ts].value=k?1:0,y.uniformsNeedUpdate=!0,P.pointcloudMode=k,n(N),P.viewerEvents&&(P.viewerEvents.fire(_).pointcloudMode=k)}),t(Xn,k=>{y.uniforms[Zi].value=k?1:0,y.uniformsNeedUpdate=!0;const P=n(_);P.bigSceneMode=k,n(N)}),t(He,k=>{y.uniforms[Ki].value=k,y.uniformsNeedUpdate=!0;const P=n(_);P.lightFactor=k,n(N)});let B=!1;return t(Zn,k=>{n(J)||B||(B=!0,y.uniforms[as].value=k,y.uniformsNeedUpdate=!0,n(N))}),t(tt,k=>{y.uniforms[Gi].value=k,y.uniformsNeedUpdate=!0,n(N)}),t(Ut,k=>{y.uniforms[Yi].value=k,y.uniformsNeedUpdate=!0,n(N)}),t(nt,(k,P,F,O)=>{y.uniforms[ns].value=[k,P,F,O?1:-1],y.uniformsNeedUpdate=!0,n(N)}),t(Ft,(k=!0)=>{y.uniforms[Xi].value=k?1:0,y.uniformsNeedUpdate=!0,n(N)}),t(Kn,k=>{y.uniforms[qi].value=k,y.uniformsNeedUpdate=!0}),t(Bs,k=>{y.uniforms[Ji].value=k,y.uniformsNeedUpdate=!0}),t(Ot,async k=>{if(n(J))return;const P=await n(nn);k<0&&(k=0),k>P&&(k=P),r=k,y.uniforms[is].value=k,y.uniformsNeedUpdate=!0,n(ne,{shDegree:`${k} / max ${P}`}),n(N)}),t(ei,()=>{y.dispose(),A&&A.dispose(),S&&S.dispose(),I&&I.dispose(),E&&E.dispose()}),y}),t(Nn,async()=>{const d=new u.Mesh(await n(Wn),await n($n));return n(Bt),n(Lt),n(Xn,n(J)),n(Ve,n(Vt)),d});function c(){n(Bt),n(Lt)}window.addEventListener("resize",c),t(oi,()=>{e=!0,window.removeEventListener("resize",c),n(Jn),n(ei)}),t(ri,async()=>{if(n(J))return;let d=.01,p=.01,g=!1,h=0;n(tt,p),n(Fe,()=>{if(e||o<=p)return;p+=(o-p)*d,n(tt,p);let y=n(ui);y&&!h&&(h=Date.now());let m=p/a;y&&(m>.9||Date.now()-h>2500)?(n(Vt)&&n(Ht,!0),n(tt,0),g=!0):y&&m>.7?d=Math.min(d*1.2,.3):y&&m>.5?d=Math.min(d*1.2,.2):m>.4&&(d=Math.min(d*1.05,.1))},()=>!e&&!g,3)}),t(Ht,(d=!1)=>{if(n(J))return;for(;s.length;)s.pop().stop=!0;const p=n(_),g=a*.001;let h={currentPointMode:p.pointcloudMode,stepRate:.0015,currentLightRadius:g,stop:!1};s.push(h),n(Fe,()=>{e||(h.currentLightRadius+=a*h.stepRate,n(Ut,h.currentLightRadius),h.currentLightRadius>a?(n(Ve,!h.currentPointMode),n(Ut,0),h.stop=!0,s.length===1&&s[0]===h&&s.pop(),d&&n(_)?.viewerEvents?.fire(Ge),n(_)?.viewerEvents?.fire(Ti)):h.currentLightRadius/a<.4?h.stepRate=Math.min(h.stepRate*1.02,.03):h.stepRate*=1.04)},()=>!e&&!h.stop)}),t(Qn,()=>({[yn]:{type:"t",value:null},[wn]:{type:"t",value:null},[mn]:{type:"t",value:null},[An]:{type:"t",value:null},[ss]:{type:"v2",value:new u.Vector2},[Ze]:{type:"v2",value:new u.Vector2},[es]:{type:"int",value:0},[ts]:{type:"int",value:0},[Ji]:{type:"int",value:1},[Zi]:{type:"int",value:0},[is]:{type:"int",value:0},[Ki]:{type:"float",value:1},[as]:{type:"float",value:0},[Gi]:{type:"float",value:0},[Yi]:{type:"float",value:0},[ns]:{type:"v4",value:new u.Vector4(0,0,0,-1)},[qi]:{type:"float",value:performance.now()},[Ca]:{type:"v4",value:new u.Vector4(1,1,0,.5)},[Xi]:{type:"int",value:1}}));const f=n(Bn);f.onmessage=d=>{const p=d.data;p[os]&&n(Yn,p[os],p[rs],p[Pa],p[Da],p[cs])},t(_i,(d,p,g)=>{n(J)||(o=p,a=g),n(jn,d)});function l(d){const p=d.xyz.slice(0);f.postMessage({[Ra]:!0,[Fa]:p,[Na]:d.watermarkCount,[rs]:d.index,[ka]:d.version,[cs]:d.renderSplatCount,[_a]:d.visibleSplatCount,[Ia]:d.modelSplatCount,[Oa]:d.minX,[za]:d.maxX,[Va]:d.minY,[Ha]:d.maxY,[Qa]:d.minZ,[Wa]:d.maxZ},[p.buffer])}}function Ya(i){const e=(a,...o)=>i.fire(a,...o),t=(a,o,s)=>i.on(a,o,s),n=new Set(ta.split(""));t(xi,async(a="",o=!0,s=!0)=>{const r=a.trim().substring(0,100);let c=await e(Pn,r),f=[];for(let x=0;x<c.length;x++){let S=[],T=c[x];for(let v=0;v<T.length;v++)S.push([(T[v]%20-10)*.02,((T[v]/20|0)-10)*.02]);f.push(S)}let l=[],d=r.split("");for(let x=0;x<d.length;x++)l[x]=n.has(d[x])?.22:.4;let p=d.length/2|0,g=l[p]/2,h=!(d.length%2),y=h?0:-g;for(let x=p-1;x>=0;x--){y-=l[x]/2;for(let S of f[x])S[0]+=y;y-=l[x]/2}g=l[p]/2,y=h?0:g;for(let x=f.length-p;x<f.length;x++){y+=l[x]/2;for(let S of f[x])S[0]+=y;y+=l[x]/2}let m=0;for(let x of f)m+=x.length;const A=new Uint8Array(m*L);let M=0;for(let x of f)for(let S of x)A.set(await ua(S[0],S[1],o,s),L*M++);return A})}function Sn(i){const e=(t,n,a)=>i.on(t,n,a);e(Se,t=>{t.url;const n={...t};delete n.url;const a=JSON.stringify(n,null,2);console.info(a)}),e(Pn,(t="")=>{const n="https://reall3d.com/gsfont/api/getGaussianText",a=new FormData;return a.append("text",t.substring(0,100)),a.append("ver",wt),new Promise(o=>{fetch(n,{method:"POST",body:a}).then(s=>s.ok?s.json():{}).then(s=>s.success?o(JSON.parse(s.data)):o([])).catch(s=>o([]))})})}function ja(i){let e=!1;const t=(r,c,f)=>i.on(r,c,f),n=(r,...c)=>i.fire(r,...c);t(ti,()=>e=!0);const a=new Map,o=new Map;t(it,()=>n(ae)&&a.set(Date.now(),1)),t(st,()=>n(ae)&&n(Ie,a)),t(at,()=>n(ae)&&o.set(Date.now(),1)),t(ot,()=>n(ae)&&n(Ie,o)),t(Ce,()=>{e||(n(at),n(ae)&&n(ne,{fov:n(Oe),position:n(Me,n(be)),lookAt:n(Me,n(Ae)),lookUp:n(Me,n(_e))}))},!0);let s=0;t(De,()=>{e||(n(Un),n(ae)&&(n(it),!(s++%5)&&n(ne,{fps:n(st),realFps:n(ot)})))},!0),t(Ie,r=>{let c=[],f=Date.now(),l=0;for(const d of r.keys())f-d<=1e3?l++:c.push(d);return c.forEach(d=>r.delete(d)),Math.min(l,30)}),window.addEventListener("beforeunload",()=>n(rt))}function qa(i){const e={...i};return e.bigSceneMode??(e.bigSceneMode=!1),e.pointcloudMode??(e.pointcloudMode=!e.bigSceneMode),e.lightFactor??(e.lightFactor=1),e.name??(e.name=""),e.showWatermark??(e.showWatermark=!0),e}function ls(i){const e={...i};return e.position=e.position?[...e.position]:[0,-5,15],e.lookAt=e.lookAt?[...e.lookAt]:[0,0,0],e.lookUp=e.lookUp?[...e.lookUp]:[0,-1,0],e.fov??(e.fov=45),e.near??(e.near=.001),e.far??(e.far=1e3),e.enableDamping??(e.enableDamping=!0),e.autoRotate??(e.autoRotate=!0),e.enableZoom??(e.enableZoom=!0),e.enableRotate??(e.enableRotate=!0),e.enablePan??(e.enablePan=!0),e.enableKeyboard??(e.enableKeyboard=!0),e.bigSceneMode??(e.bigSceneMode=!1),e.pointcloudMode??(e.pointcloudMode=!e.bigSceneMode),e.lightFactor??(e.lightFactor=1.1),e.maxRenderCountOfMobile??(e.maxRenderCountOfMobile=e.bigSceneMode?256*1e4:384*10240),e.maxRenderCountOfPc??(e.maxRenderCountOfPc=e.bigSceneMode?320*1e4:384*1e4),e.debugMode??(e.debugMode=location.protocol==="http:"||/^test\./.test(location.host)),e.markMode??(e.markMode=!1),e.markVisible??(e.markVisible=!0),e.meterScale??(e.meterScale=1),e}function Xa(i){let e;i.root?e=typeof i.root=="string"?document.querySelector(i.root)||document.querySelector("#gsviewer"):i.root:e=document.querySelector("#gsviewer"),e||(e=document.createElement("div"),e.id="gsviewer",document.body.appendChild(e));let t=document.querySelector("#gsviewer-canvas")||void 0,n=null;return i.renderer?n=i.renderer:(n=new u.WebGLRenderer({canvas:t,antialias:!1,stencil:!0,logarithmicDepthBuffer:!0,precision:"highp"}),n.setSize(e.clientWidth,e.clientHeight),n.setPixelRatio(Math.min(devicePixelRatio,2)),i.renderer=n),t=n.domElement,t.id="gsviewer-canvas",e.appendChild(n.domElement),n}function Za(i){let e=i.camera;if(!e){const t=i.renderer.domElement,n=t.width/t.height;let a=new u.Vector3().fromArray(i.lookUp),o=new u.Vector3().fromArray(i.lookAt),s=new u.Vector3().fromArray(i.position);e=new u.PerspectiveCamera(i.fov,n,i.near,i.far),e.position.copy(s),e.up.copy(a).normalize(),e.lookAt(o),i.camera=e}return i.camera}function Ka(i){const{renderer:e,scene:t}=i,n={renderer:e,scene:t};return n.viewerEvents=i.viewerEvents,n.debugMode=i.debugMode,n.renderer=i.renderer,n.scene=i.scene,n.controls=i.controls,n.bigSceneMode=i.bigSceneMode,n.pointcloudMode=i.pointcloudMode,n.maxRenderCountOfMobile=i.maxRenderCountOfMobile,n.maxRenderCountOfPc=i.maxRenderCountOfPc,n.lightFactor=i.lightFactor,n.shDegree=i.shDegree,n}function Ja(i){const e=(a,o,s)=>i.on(a,o,s),t=(a,...o)=>i.fire(a,...o),n=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/Sorter-Dl_LG4bh.js").href:new URL("assets/Sorter-Dl_LG4bh.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Et&&Et.tagName.toUpperCase()==="SCRIPT"&&Et.src||new URL("pkg.umd.cjs",document.baseURI).href),{type:"module"});e(Bn,()=>n),e(zn,()=>n.postMessage({[Ua]:t(On)})),e(Vn,()=>n.terminate()),(async()=>n.postMessage({[$a]:!0,[La]:await t(ze),[Ba]:t(J)}))()}class le extends u.Mesh{constructor(e){super(),this.isSplatMesh=!0,this.disposed=!1;const t=new rn,n=(r,c,f)=>t.on(r,c,f),a=(r,...c)=>t.fire(r,...c),o=qa(e),s=o.controls.object;n(_,()=>o),n(ke,()=>o.renderer.domElement),n($,()=>s),n(Oe,()=>s.fov),n(be,(r=!1)=>r?s.position.clone():s.position),n(Ae,(r=!1)=>r?o.controls.target.clone():o.controls.target),n(On,()=>s.projectionMatrix.clone().multiply(s.matrixWorldInverse).multiply(this.matrix).toArray()),n(Is,()=>s.projectionMatrix.clone().multiply(s.matrixWorldInverse)),n(Gs,()=>s.getWorldDirection(new u.Vector3).toArray()),n(Qe,()=>o.renderer),n(U,()=>o.scene),n(J,()=>o.bigSceneMode),n(Vt,()=>o.pointcloudMode),n(me,()=>this),n(N,()=>o.viewerEvents?.fire(q)),pn(t),Sn(t),va(t),Ja(t),Ga(t),Ya(t),this.name=`${o.name||this.id}`,this.events=t,this.opts=o,(async()=>(this.copy(await t.fire(Nn)),o.matrix&&this.applyMatrix4(o.matrix),this.frustumCulled=!1,this.onBeforeRender=()=>{a(zn),a(Kn,performance.now())},this.onAfterRender=()=>{a(si,1e4)&&a(N)}))()}options(e){if(this.disposed)return;const t=(a,...o)=>this.events.fire(a,...o),n=this.opts;return e&&(e.pointcloudMode!==void 0&&t(Ve,e.pointcloudMode),e.lightFactor!==void 0&&t(He,e.lightFactor),e.maxRenderCountOfMobile!==void 0&&(n.maxRenderCountOfMobile=e.maxRenderCountOfMobile),e.maxRenderCountOfPc!==void 0&&(n.maxRenderCountOfPc=e.maxRenderCountOfPc),t(N)),{...n}}async addModel(e,t){this.disposed||(this.meta=t,await this.events.fire(ii,e,t))}fire(e,...t){if(!this.disposed)return this.events.fire(e,...t)}dispose(){if(this.disposed)return;this.disposed=!0;const e=(t,...n)=>this.events.fire(t,...n);e(ve,this),e(U).remove(this),e(zt),e(ai),e(Vn),e(oi),this.events.clear(),this.events=null,this.opts=null,this.onAfterRender=null}}class eo extends u.Object3D{constructor(e=new u.Vector3(0,0,1),t=new u.Vector3(0,0,0),n=1,a=.1,o=16776960,s=n*.2,r=s*.2){super(),this._axis=new u.Vector3,this.type="ArrowHelper";const c=new u.CylinderGeometry(a,a,n,32);c.translate(0,n/2,0);const f=new u.CylinderGeometry(0,r,s,32);f.translate(0,n,0),this.position.copy(t);const l=new u.MeshBasicMaterial({color:o,toneMapped:!1});l.side=u.DoubleSide,this.line=new u.Mesh(c,l),this.line.matrixAutoUpdate=!1,this.line.ignoreIntersect=!0,this.add(this.line);const d=new u.MeshBasicMaterial({color:o,toneMapped:!1});d.side=u.DoubleSide,this.cone=new u.Mesh(f,d),this.cone.matrixAutoUpdate=!1,this.cone.ignoreIntersect=!0,this.add(this.cone),this.setDirection(e),this.renderOrder=99999}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{this._axis.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(this._axis,t)}}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}function to(i){const e=(y,m,A)=>i.on(y,m,A),t=(y,...m)=>i.fire(y,...m),n=new u.PlaneGeometry(1,1);n.rotateX(-Math.PI/2);const a=new u.MeshBasicMaterial({color:16777215});a.transparent=!0,a.opacity=.6,a.depthTest=!1,a.depthWrite=!1,a.side=u.DoubleSide;const o=new u.Mesh(n,a);o.ignoreIntersect=!0;const s=new u.Vector3(0,-1,0);s.normalize();const r=new u.Vector3(0,0,0),c=.5,f=.01,l=16777062,d=.1,p=.03,g=new eo(s,r,c,f,l,d,p),h=new u.Object3D;h.add(o),h.add(g),h.renderOrder=99999,o.renderOrder=99999,h.visible=!1,t(U).add(h),e(zs,()=>h),e(ut,y=>{t(ft,!0),h.visible=y===void 0?!h.visible:y,t(q)}),e(Gt,()=>h.visible),e(ft,(y=!1)=>{if(y||h.visible){const m=new u.Quaternion,A=new u.Vector3(0,-1,0);m.setFromUnitVectors(A,t(_e)),h.position.copy(t(Ae)),h.quaternion.copy(m)}})}const ds={type:"change"},bn={type:"start"},us={type:"end"},xt=new u.Ray,fs=new u.Plane,no=Math.cos(70*u.MathUtils.DEG2RAD),Y=new u.Vector3,ie=2*Math.PI,H={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},xn=1e-6;class ps extends u.Controls{constructor(e,t=null){super(e,t),this.state=H.NONE,this.enabled=!0,this.target=new u.Vector3,this.cursor=new u.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.MOUSE.ROTATE,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.PAN},this.touches={ONE:u.TOUCH.ROTATE,TWO:u.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new u.Vector3,this._lastQuaternion=new u.Quaternion,this._lastTargetPosition=new u.Vector3,this._quat=new u.Quaternion().setFromUnitVectors(e.up,new u.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new u.Spherical,this._sphericalDelta=new u.Spherical,this._scale=1,this._panOffset=new u.Vector3,this._rotateStart=new u.Vector2,this._rotateEnd=new u.Vector2,this._rotateDelta=new u.Vector2,this._panStart=new u.Vector2,this._panEnd=new u.Vector2,this._panDelta=new u.Vector2,this._dollyStart=new u.Vector2,this._dollyEnd=new u.Vector2,this._dollyDelta=new u.Vector2,this._dollyDirection=new u.Vector3,this._mouse=new u.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=so.bind(this),this._onPointerDown=io.bind(this),this._onPointerUp=ao.bind(this),this._onContextMenu=po.bind(this),this._onMouseWheel=co.bind(this),this._onKeyDown=lo.bind(this),this._onTouchStart=uo.bind(this),this._onTouchMove=fo.bind(this),this._onMouseDown=oo.bind(this),this._onMouseMove=ro.bind(this),this._interceptControlDown=ho.bind(this),this._interceptControlUp=go.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ds),this.update(),this.state=H.NONE}update(e=null){const t=this.object.position;Y.copy(t).sub(this.target),Y.applyQuaternion(this._quat),this._spherical.setFromVector3(Y),this.autoRotate&&this.state===H.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,a=this.maxAzimuthAngle;isFinite(n)&&isFinite(a)&&(n<-Math.PI?n+=ie:n>Math.PI&&(n-=ie),a<-Math.PI?a+=ie:a>Math.PI&&(a-=ie),n<=a?this._spherical.theta=Math.max(n,Math.min(a,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+a)/2?Math.max(n,this._spherical.theta):Math.min(a,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=s!=this._spherical.radius}if(Y.setFromSpherical(this._spherical),Y.applyQuaternion(this._quatInverse),t.copy(this.target).add(Y),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){const r=Y.length();s=this._clampDistance(r*this._scale);const c=r-s;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),o=!!c}else if(this.object.isOrthographicCamera){const r=new u.Vector3(this._mouse.x,this._mouse.y,0);r.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=c!==this.object.zoom;const f=new u.Vector3(this._mouse.x,this._mouse.y,0);f.unproject(this.object),this.object.position.sub(f).add(r),this.object.updateMatrixWorld(),s=Y.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;s!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position):(xt.origin.copy(this.object.position),xt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(xt.direction))<no?this.object.lookAt(this.target):(fs.setFromNormalAndCoplanarPoint(this.object.up,this.target),xt.intersectPlane(fs,this.target))))}else if(this.object.isOrthographicCamera){const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>xn||8*(1-this._lastQuaternion.dot(this.object.quaternion))>xn||this._lastTargetPosition.distanceToSquared(this.target)>xn?(this.dispatchEvent(ds),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ie/60*this.autoRotateSpeed*e:ie/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Y.setFromMatrixColumn(t,0),Y.multiplyScalar(-e),this._panOffset.add(Y)}_panUp(e,t){this.screenSpacePanning===!0?Y.setFromMatrixColumn(t,1):(Y.setFromMatrixColumn(t,0),Y.crossVectors(this.object.up,Y)),Y.multiplyScalar(e),this._panOffset.add(Y)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const a=this.object.position;Y.copy(a).sub(this.target);let o=Y.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/n.clientHeight,this.object.matrix),this._panUp(2*t*o/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),a=e-n.left,o=t-n.top,s=n.width,r=n.height;this._mouse.x=a/s*2-1,this._mouse.y=-(o/r)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(ie*this._rotateDelta.x/t.clientHeight),this._rotateUp(ie*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(ie*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-ie*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(ie*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-ie*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),a=.5*(e.pageY+t.y);this._rotateStart.set(n,a)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),a=.5*(e.pageY+t.y);this._panStart.set(n,a)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,a=e.pageY-t.y,o=Math.sqrt(n*n+a*a);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),a=.5*(e.pageX+n.x),o=.5*(e.pageY+n.y);this._rotateEnd.set(a,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(ie*this._rotateDelta.x/t.clientHeight),this._rotateUp(ie*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),a=.5*(e.pageY+t.y);this._panEnd.set(n,a)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,a=e.pageY-t.y,o=Math.sqrt(n*n+a*a);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=(e.pageX+t.x)*.5,r=(e.pageY+t.y)*.5;this._updateZoomParameters(s,r)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new u.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function io(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function so(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function ao(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(us),this.state=H.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function oo(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case u.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=H.DOLLY;break;case u.MOUSE.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=H.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=H.ROTATE}break;case u.MOUSE.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=H.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=H.PAN}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(bn)}function ro(i){switch(this.state){case H.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case H.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case H.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function co(i){this.enabled===!1||this.enableZoom===!1||this.state!==H.NONE||(i.preventDefault(),this.dispatchEvent(bn),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(us))}function lo(i){this.enabled!==!1&&this._handleKeyDown(i)}function uo(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case u.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=H.TOUCH_ROTATE;break;case u.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=H.TOUCH_PAN;break;default:this.state=H.NONE}break;case 2:switch(this.touches.TWO){case u.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=H.TOUCH_DOLLY_PAN;break;case u.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=H.TOUCH_DOLLY_ROTATE;break;default:this.state=H.NONE}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(bn)}function fo(i){switch(this._trackPointer(i),this.state){case H.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case H.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case H.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case H.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=H.NONE}}function po(i){this.enabled!==!1&&i.preventDefault()}function ho(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function go(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class mo extends ps{constructor(e){const t=e.camera;super(t,e.renderer.domElement);const n=this;n.dampingFactor=.1,n.rotateSpeed=.4,n.updateByOptions(e)}updateByOptions(e={}){const t=this;e.enableDamping!==void 0&&(t.enableDamping=e.enableDamping),e.autoRotate!==void 0&&(t.autoRotate=e.autoRotate),e.enableZoom!==void 0&&(t.enableZoom=e.enableZoom),e.enableRotate!==void 0&&(t.enableRotate=e.enableRotate),e.enablePan!==void 0&&(t.enablePan=e.enablePan),e.minDistance!==void 0&&(t.minDistance=e.minDistance),e.maxDistance!==void 0&&(t.maxDistance=e.maxDistance),e.minPolarAngle!==void 0&&(t.minPolarAngle=e.minPolarAngle),e.maxPolarAngle!==void 0&&(t.maxPolarAngle=e.maxPolarAngle),e.fov!==void 0&&(t.object.fov=e.fov),e.near!==void 0&&(t.object.near=e.near),e.far!==void 0&&(t.object.far=e.far),e.position&&t.object.position.fromArray(e.position),e.lookAt&&t.target.fromArray(e.lookAt),e.lookUp&&t.object.up.fromArray(e.lookUp),re&&t._dollyOut?.(.75),t.updateRotateAxis(),t.update()}updateRotateAxis(){this._quat?.setFromUnitVectors?.(this.object.up,new u.Vector3(0,1,0)),this._quatInverse=this._quat?.clone?.()?.invert?.()}}class Ao extends ps{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons={LEFT:u.MOUSE.PAN,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.ROTATE},this.touches={ONE:u.TOUCH.PAN,TWO:u.TOUCH.DOLLY_ROTATE}}}const hs=new u.Box3,Mt=new u.Vector3;class gs extends u.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new u.Float32BufferAttribute(e,3)),this.setAttribute("uv",new u.Float32BufferAttribute(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new u.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new u.InterleavedBufferAttribute(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new u.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new u.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new u.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new u.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),hs.setFromBufferAttribute(t),this.boundingBox.union(hs))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new u.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let a=0;for(let o=0,s=e.count;o<s;o++)Mt.fromBufferAttribute(e,o),a=Math.max(a,n.distanceToSquared(Mt)),Mt.fromBufferAttribute(t,o),a=Math.max(a,n.distanceToSquared(Mt));this.boundingSphere.radius=Math.sqrt(a),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}u.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new u.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},u.ShaderLib.line={uniforms:u.UniformsUtils.merge([u.UniformsLib.common,u.UniformsLib.fog,u.UniformsLib.line]),vertexShader:`
|
|
339
|
+
#include <common>
|
|
340
|
+
#include <color_pars_vertex>
|
|
341
|
+
#include <fog_pars_vertex>
|
|
342
|
+
#include <logdepthbuf_pars_vertex>
|
|
343
|
+
#include <clipping_planes_pars_vertex>
|
|
344
|
+
|
|
345
|
+
uniform float linewidth;
|
|
346
|
+
uniform vec2 resolution;
|
|
347
|
+
|
|
348
|
+
attribute vec3 instanceStart;
|
|
349
|
+
attribute vec3 instanceEnd;
|
|
350
|
+
|
|
351
|
+
attribute vec3 instanceColorStart;
|
|
352
|
+
attribute vec3 instanceColorEnd;
|
|
353
|
+
|
|
354
|
+
#ifdef WORLD_UNITS
|
|
355
|
+
|
|
356
|
+
varying vec4 worldPos;
|
|
357
|
+
varying vec3 worldStart;
|
|
358
|
+
varying vec3 worldEnd;
|
|
359
|
+
|
|
360
|
+
#ifdef USE_DASH
|
|
361
|
+
|
|
362
|
+
varying vec2 vUv;
|
|
363
|
+
|
|
364
|
+
#endif
|
|
365
|
+
|
|
366
|
+
#else
|
|
367
|
+
|
|
368
|
+
varying vec2 vUv;
|
|
369
|
+
|
|
370
|
+
#endif
|
|
371
|
+
|
|
372
|
+
#ifdef USE_DASH
|
|
373
|
+
|
|
374
|
+
uniform float dashScale;
|
|
375
|
+
attribute float instanceDistanceStart;
|
|
376
|
+
attribute float instanceDistanceEnd;
|
|
377
|
+
varying float vLineDistance;
|
|
378
|
+
|
|
379
|
+
#endif
|
|
380
|
+
|
|
381
|
+
void trimSegment( const in vec4 start, inout vec4 end ) {
|
|
382
|
+
|
|
383
|
+
// trim end segment so it terminates between the camera plane and the near plane
|
|
384
|
+
|
|
385
|
+
// conservative estimate of the near plane
|
|
386
|
+
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|
387
|
+
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|
388
|
+
float nearEstimate = - 0.5 * b / a;
|
|
389
|
+
|
|
390
|
+
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
|
391
|
+
|
|
392
|
+
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|
393
|
+
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
void main() {
|
|
397
|
+
|
|
398
|
+
#ifdef USE_COLOR
|
|
399
|
+
|
|
400
|
+
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|
401
|
+
|
|
402
|
+
#endif
|
|
403
|
+
|
|
404
|
+
#ifdef USE_DASH
|
|
405
|
+
|
|
406
|
+
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
|
407
|
+
vUv = uv;
|
|
408
|
+
|
|
409
|
+
#endif
|
|
410
|
+
|
|
411
|
+
float aspect = resolution.x / resolution.y;
|
|
412
|
+
|
|
413
|
+
// camera space
|
|
414
|
+
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
415
|
+
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
416
|
+
|
|
417
|
+
#ifdef WORLD_UNITS
|
|
418
|
+
|
|
419
|
+
worldStart = start.xyz;
|
|
420
|
+
worldEnd = end.xyz;
|
|
421
|
+
|
|
422
|
+
#else
|
|
423
|
+
|
|
424
|
+
vUv = uv;
|
|
425
|
+
|
|
426
|
+
#endif
|
|
427
|
+
|
|
428
|
+
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
429
|
+
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
430
|
+
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
431
|
+
// perhaps there is a more elegant solution -- WestLangley
|
|
432
|
+
|
|
433
|
+
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|
434
|
+
|
|
435
|
+
if ( perspective ) {
|
|
436
|
+
|
|
437
|
+
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|
438
|
+
|
|
439
|
+
trimSegment( start, end );
|
|
440
|
+
|
|
441
|
+
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|
442
|
+
|
|
443
|
+
trimSegment( end, start );
|
|
444
|
+
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// clip space
|
|
450
|
+
vec4 clipStart = projectionMatrix * start;
|
|
451
|
+
vec4 clipEnd = projectionMatrix * end;
|
|
452
|
+
|
|
453
|
+
// ndc space
|
|
454
|
+
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
|
455
|
+
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
|
456
|
+
|
|
457
|
+
// direction
|
|
458
|
+
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
|
459
|
+
|
|
460
|
+
// account for clip-space aspect ratio
|
|
461
|
+
dir.x *= aspect;
|
|
462
|
+
dir = normalize( dir );
|
|
463
|
+
|
|
464
|
+
#ifdef WORLD_UNITS
|
|
465
|
+
|
|
466
|
+
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|
467
|
+
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|
468
|
+
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|
469
|
+
vec3 worldFwd = cross( worldDir, worldUp );
|
|
470
|
+
worldPos = position.y < 0.5 ? start: end;
|
|
471
|
+
|
|
472
|
+
// height offset
|
|
473
|
+
float hw = linewidth * 0.5;
|
|
474
|
+
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|
475
|
+
|
|
476
|
+
// don't extend the line if we're rendering dashes because we
|
|
477
|
+
// won't be rendering the endcaps
|
|
478
|
+
#ifndef USE_DASH
|
|
479
|
+
|
|
480
|
+
// cap extension
|
|
481
|
+
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|
482
|
+
|
|
483
|
+
// add width to the box
|
|
484
|
+
worldPos.xyz += worldFwd * hw;
|
|
485
|
+
|
|
486
|
+
// endcaps
|
|
487
|
+
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|
488
|
+
|
|
489
|
+
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|
490
|
+
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
#endif
|
|
494
|
+
|
|
495
|
+
// project the worldpos
|
|
496
|
+
vec4 clip = projectionMatrix * worldPos;
|
|
497
|
+
|
|
498
|
+
// shift the depth of the projected points so the line
|
|
499
|
+
// segments overlap neatly
|
|
500
|
+
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|
501
|
+
clip.z = clipPose.z * clip.w;
|
|
502
|
+
|
|
503
|
+
#else
|
|
504
|
+
|
|
505
|
+
vec2 offset = vec2( dir.y, - dir.x );
|
|
506
|
+
// undo aspect ratio adjustment
|
|
507
|
+
dir.x /= aspect;
|
|
508
|
+
offset.x /= aspect;
|
|
509
|
+
|
|
510
|
+
// sign flip
|
|
511
|
+
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
512
|
+
|
|
513
|
+
// endcaps
|
|
514
|
+
if ( position.y < 0.0 ) {
|
|
515
|
+
|
|
516
|
+
offset += - dir;
|
|
517
|
+
|
|
518
|
+
} else if ( position.y > 1.0 ) {
|
|
519
|
+
|
|
520
|
+
offset += dir;
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// adjust for linewidth
|
|
525
|
+
offset *= linewidth;
|
|
526
|
+
|
|
527
|
+
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
528
|
+
offset /= resolution.y;
|
|
529
|
+
|
|
530
|
+
// select end
|
|
531
|
+
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
532
|
+
|
|
533
|
+
// back to clip space
|
|
534
|
+
offset *= clip.w;
|
|
535
|
+
|
|
536
|
+
clip.xy += offset;
|
|
537
|
+
|
|
538
|
+
#endif
|
|
539
|
+
|
|
540
|
+
gl_Position = clip;
|
|
541
|
+
|
|
542
|
+
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|
543
|
+
|
|
544
|
+
#include <logdepthbuf_vertex>
|
|
545
|
+
#include <clipping_planes_vertex>
|
|
546
|
+
#include <fog_vertex>
|
|
547
|
+
|
|
548
|
+
}
|
|
549
|
+
`,fragmentShader:`
|
|
550
|
+
uniform vec3 diffuse;
|
|
551
|
+
uniform float opacity;
|
|
552
|
+
uniform float linewidth;
|
|
553
|
+
|
|
554
|
+
#ifdef USE_DASH
|
|
555
|
+
|
|
556
|
+
uniform float dashOffset;
|
|
557
|
+
uniform float dashSize;
|
|
558
|
+
uniform float gapSize;
|
|
559
|
+
|
|
560
|
+
#endif
|
|
561
|
+
|
|
562
|
+
varying float vLineDistance;
|
|
563
|
+
|
|
564
|
+
#ifdef WORLD_UNITS
|
|
565
|
+
|
|
566
|
+
varying vec4 worldPos;
|
|
567
|
+
varying vec3 worldStart;
|
|
568
|
+
varying vec3 worldEnd;
|
|
569
|
+
|
|
570
|
+
#ifdef USE_DASH
|
|
571
|
+
|
|
572
|
+
varying vec2 vUv;
|
|
573
|
+
|
|
574
|
+
#endif
|
|
575
|
+
|
|
576
|
+
#else
|
|
577
|
+
|
|
578
|
+
varying vec2 vUv;
|
|
579
|
+
|
|
580
|
+
#endif
|
|
581
|
+
|
|
582
|
+
#include <common>
|
|
583
|
+
#include <color_pars_fragment>
|
|
584
|
+
#include <fog_pars_fragment>
|
|
585
|
+
#include <logdepthbuf_pars_fragment>
|
|
586
|
+
#include <clipping_planes_pars_fragment>
|
|
587
|
+
|
|
588
|
+
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|
589
|
+
|
|
590
|
+
float mua;
|
|
591
|
+
float mub;
|
|
592
|
+
|
|
593
|
+
vec3 p13 = p1 - p3;
|
|
594
|
+
vec3 p43 = p4 - p3;
|
|
595
|
+
|
|
596
|
+
vec3 p21 = p2 - p1;
|
|
597
|
+
|
|
598
|
+
float d1343 = dot( p13, p43 );
|
|
599
|
+
float d4321 = dot( p43, p21 );
|
|
600
|
+
float d1321 = dot( p13, p21 );
|
|
601
|
+
float d4343 = dot( p43, p43 );
|
|
602
|
+
float d2121 = dot( p21, p21 );
|
|
603
|
+
|
|
604
|
+
float denom = d2121 * d4343 - d4321 * d4321;
|
|
605
|
+
|
|
606
|
+
float numer = d1343 * d4321 - d1321 * d4343;
|
|
607
|
+
|
|
608
|
+
mua = numer / denom;
|
|
609
|
+
mua = clamp( mua, 0.0, 1.0 );
|
|
610
|
+
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
|
611
|
+
mub = clamp( mub, 0.0, 1.0 );
|
|
612
|
+
|
|
613
|
+
return vec2( mua, mub );
|
|
614
|
+
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
void main() {
|
|
618
|
+
|
|
619
|
+
#include <clipping_planes_fragment>
|
|
620
|
+
|
|
621
|
+
#ifdef USE_DASH
|
|
622
|
+
|
|
623
|
+
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|
624
|
+
|
|
625
|
+
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|
626
|
+
|
|
627
|
+
#endif
|
|
628
|
+
|
|
629
|
+
float alpha = opacity;
|
|
630
|
+
|
|
631
|
+
#ifdef WORLD_UNITS
|
|
632
|
+
|
|
633
|
+
// Find the closest points on the view ray and the line segment
|
|
634
|
+
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
|
635
|
+
vec3 lineDir = worldEnd - worldStart;
|
|
636
|
+
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
|
637
|
+
|
|
638
|
+
vec3 p1 = worldStart + lineDir * params.x;
|
|
639
|
+
vec3 p2 = rayEnd * params.y;
|
|
640
|
+
vec3 delta = p1 - p2;
|
|
641
|
+
float len = length( delta );
|
|
642
|
+
float norm = len / linewidth;
|
|
643
|
+
|
|
644
|
+
#ifndef USE_DASH
|
|
645
|
+
|
|
646
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
647
|
+
|
|
648
|
+
float dnorm = fwidth( norm );
|
|
649
|
+
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|
650
|
+
|
|
651
|
+
#else
|
|
652
|
+
|
|
653
|
+
if ( norm > 0.5 ) {
|
|
654
|
+
|
|
655
|
+
discard;
|
|
656
|
+
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
#endif
|
|
660
|
+
|
|
661
|
+
#endif
|
|
662
|
+
|
|
663
|
+
#else
|
|
664
|
+
|
|
665
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
666
|
+
|
|
667
|
+
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|
668
|
+
float a = vUv.x;
|
|
669
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
670
|
+
float len2 = a * a + b * b;
|
|
671
|
+
float dlen = fwidth( len2 );
|
|
672
|
+
|
|
673
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
674
|
+
|
|
675
|
+
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
|
676
|
+
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
#else
|
|
680
|
+
|
|
681
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
682
|
+
|
|
683
|
+
float a = vUv.x;
|
|
684
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
685
|
+
float len2 = a * a + b * b;
|
|
686
|
+
|
|
687
|
+
if ( len2 > 1.0 ) discard;
|
|
688
|
+
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
#endif
|
|
692
|
+
|
|
693
|
+
#endif
|
|
694
|
+
|
|
695
|
+
vec4 diffuseColor = vec4( diffuse, alpha );
|
|
696
|
+
|
|
697
|
+
#include <logdepthbuf_fragment>
|
|
698
|
+
#include <color_fragment>
|
|
699
|
+
|
|
700
|
+
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|
701
|
+
|
|
702
|
+
#include <tonemapping_fragment>
|
|
703
|
+
#include <colorspace_fragment>
|
|
704
|
+
#include <fog_fragment>
|
|
705
|
+
#include <premultiplied_alpha_fragment>
|
|
706
|
+
|
|
707
|
+
}
|
|
708
|
+
`};class Le extends u.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:u.UniformsUtils.clone(u.ShaderLib.line.uniforms),vertexShader:u.ShaderLib.line.vertexShader,fragmentShader:u.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Mn=new u.Vector4,ms=new u.Vector3,As=new u.Vector3,X=new u.Vector4,Z=new u.Vector4,de=new u.Vector4,Cn=new u.Vector3,Tn=new u.Matrix4,K=new u.Line3,ys=new u.Vector3,Ct=new u.Box3,Tt=new u.Sphere,ue=new u.Vector4;let fe,Te;function ws(i,e,t){return ue.set(0,0,-e,1).applyMatrix4(i.projectionMatrix),ue.multiplyScalar(1/ue.w),ue.x=Te/t.width,ue.y=Te/t.height,ue.applyMatrix4(i.projectionMatrixInverse),ue.multiplyScalar(1/ue.w),Math.abs(Math.max(ue.x,ue.y))}function yo(i,e){const t=i.matrixWorld,n=i.geometry,a=n.attributes.instanceStart,o=n.attributes.instanceEnd,s=Math.min(n.instanceCount,a.count);for(let r=0,c=s;r<c;r++){K.start.fromBufferAttribute(a,r),K.end.fromBufferAttribute(o,r),K.applyMatrix4(t);const f=new u.Vector3,l=new u.Vector3;fe.distanceSqToSegment(K.start,K.end,l,f),l.distanceTo(f)<Te*.5&&e.push({point:l,pointOnLine:f,distance:fe.origin.distanceTo(l),object:i,face:null,faceIndex:r,uv:null,uv1:null})}}function wo(i,e,t){const n=e.projectionMatrix,o=i.material.resolution,s=i.matrixWorld,r=i.geometry,c=r.attributes.instanceStart,f=r.attributes.instanceEnd,l=Math.min(r.instanceCount,c.count),d=-e.near;fe.at(1,de),de.w=1,de.applyMatrix4(e.matrixWorldInverse),de.applyMatrix4(n),de.multiplyScalar(1/de.w),de.x*=o.x/2,de.y*=o.y/2,de.z=0,Cn.copy(de),Tn.multiplyMatrices(e.matrixWorldInverse,s);for(let p=0,g=l;p<g;p++){if(X.fromBufferAttribute(c,p),Z.fromBufferAttribute(f,p),X.w=1,Z.w=1,X.applyMatrix4(Tn),Z.applyMatrix4(Tn),X.z>d&&Z.z>d)continue;if(X.z>d){const x=X.z-Z.z,S=(X.z-d)/x;X.lerp(Z,S)}else if(Z.z>d){const x=Z.z-X.z,S=(Z.z-d)/x;Z.lerp(X,S)}X.applyMatrix4(n),Z.applyMatrix4(n),X.multiplyScalar(1/X.w),Z.multiplyScalar(1/Z.w),X.x*=o.x/2,X.y*=o.y/2,Z.x*=o.x/2,Z.y*=o.y/2,K.start.copy(X),K.start.z=0,K.end.copy(Z),K.end.z=0;const y=K.closestPointToPointParameter(Cn,!0);K.at(y,ys);const m=u.MathUtils.lerp(X.z,Z.z,y),A=m>=-1&&m<=1,M=Cn.distanceTo(ys)<Te*.5;if(A&&M){K.start.fromBufferAttribute(c,p),K.end.fromBufferAttribute(f,p),K.start.applyMatrix4(s),K.end.applyMatrix4(s);const x=new u.Vector3,S=new u.Vector3;fe.distanceSqToSegment(K.start,K.end,S,x),t.push({point:S,pointOnLine:x,distance:fe.origin.distanceTo(S),object:i,face:null,faceIndex:p,uv:null,uv1:null})}}}class vo extends u.Mesh{constructor(e=new gs,t=new Le({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,a=new Float32Array(2*t.count);for(let s=0,r=0,c=t.count;s<c;s++,r+=2)ms.fromBufferAttribute(t,s),As.fromBufferAttribute(n,s),a[r]=r===0?0:a[r-1],a[r+1]=a[r]+ms.distanceTo(As);const o=new u.InstancedInterleavedBuffer(a,2,1);return e.setAttribute("instanceDistanceStart",new u.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new u.InterleavedBufferAttribute(o,1,1)),this}raycast(e,t){const n=this.material.worldUnits,a=e.camera;a===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;fe=e.ray;const s=this.matrixWorld,r=this.geometry,c=this.material;Te=c.linewidth+o,r.boundingSphere===null&&r.computeBoundingSphere(),Tt.copy(r.boundingSphere).applyMatrix4(s);let f;if(n)f=Te*.5;else{const d=Math.max(a.near,Tt.distanceToPoint(fe.origin));f=ws(a,d,c.resolution)}if(Tt.radius+=f,fe.intersectsSphere(Tt)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),Ct.copy(r.boundingBox).applyMatrix4(s);let l;if(n)l=Te*.5;else{const d=Math.max(a.near,Ct.distanceToPoint(fe.origin));l=ws(a,d,c.resolution)}Ct.expandByScalar(l),fe.intersectsBox(Ct)!==!1&&(n?yo(this,t):wo(this,a,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Mn),this.material.uniforms.resolution.value.set(Mn.z,Mn.w))}}class Ke extends gs{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let a=0;a<t;a+=3)n[2*a]=e[a],n[2*a+1]=e[a+1],n[2*a+2]=e[a+2],n[2*a+3]=e[a+3],n[2*a+4]=e[a+4],n[2*a+5]=e[a+5];return super.setPositions(n),this}setColors(e){const t=e.length-3,n=new Float32Array(2*t);for(let a=0;a<t;a+=3)n[2*a]=e[a],n[2*a+1]=e[a+1],n[2*a+2]=e[a+2],n[2*a+3]=e[a+3],n[2*a+4]=e[a+4],n[2*a+5]=e[a+5];return super.setColors(n),this}setFromPoints(e){const t=e.length-1,n=new Float32Array(6*t);for(let a=0;a<t;a++)n[6*a]=e[a].x,n[6*a+1]=e[a].y,n[6*a+2]=e[a].z||0,n[6*a+3]=e[a+1].x,n[6*a+4]=e[a+1].y,n[6*a+5]=e[a+1].z||0;return super.setPositions(n),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class Ee extends vo{constructor(e=new Ke,t=new Le({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const vs=new u.Vector3,So=new u.Quaternion,Ss=new u.Vector3;class bo extends u.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}}class te extends bo{constructor(e){super(e),this.isCSS3DSprite=!0,this.rotation2D=0}copy(e,t){return super.copy(e,t),this.rotation2D=e.rotation2D,this}}const pe=new u.Matrix4,xo=new u.Matrix4;class Mo{constructor(e={}){const t=this;let n,a,o,s;const r={camera:{style:""},objects:new WeakMap},c=e.element!==void 0?e.element:document.createElement("div");c.style.overflow="hidden",this.domElement=c;const f=document.createElement("div");f.style.transformOrigin="0 0",f.style.pointerEvents="none",c.appendChild(f);const l=document.createElement("div");l.style.transformStyle="preserve-3d",f.appendChild(l),this.getSize=function(){return{width:n,height:a}},this.render=function(m,A){const M=A.projectionMatrix.elements[5]*s;A.view&&A.view.enabled?(f.style.transform=`translate( ${-A.view.offsetX*(n/A.view.width)}px, ${-A.view.offsetY*(a/A.view.height)}px )`,f.style.transform+=`scale( ${A.view.fullWidth/A.view.width}, ${A.view.fullHeight/A.view.height} )`):f.style.transform="",m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),A.parent===null&&A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld();let x,S;A.isOrthographicCamera&&(x=-(A.right+A.left)/2,S=(A.top+A.bottom)/2);const T=A.view&&A.view.enabled?A.view.height/A.view.fullHeight:1,v=A.isOrthographicCamera?`scale( ${T} )scale(`+M+")translate("+d(x)+"px,"+d(S)+"px)"+p(A.matrixWorldInverse):`scale( ${T} )translateZ(`+M+"px)"+p(A.matrixWorldInverse),b=(A.isPerspectiveCamera?"perspective("+M+"px) ":"")+v+"translate("+o+"px,"+s+"px)";r.camera.style!==b&&(l.style.transform=b,r.camera.style=b),y(m,m,A)},this.setSize=function(m,A){n=m,a=A,o=n/2,s=a/2,c.style.width=m+"px",c.style.height=A+"px",f.style.width=m+"px",f.style.height=A+"px",l.style.width=m+"px",l.style.height=A+"px"};function d(m){return Math.abs(m)<1e-10?0:m}function p(m){const A=m.elements;return"matrix3d("+d(A[0])+","+d(-A[1])+","+d(A[2])+","+d(A[3])+","+d(A[4])+","+d(-A[5])+","+d(A[6])+","+d(A[7])+","+d(A[8])+","+d(-A[9])+","+d(A[10])+","+d(A[11])+","+d(A[12])+","+d(-A[13])+","+d(A[14])+","+d(A[15])+")"}function g(m){const A=m.elements;return"translate(-50%,-50%)"+("matrix3d("+d(A[0])+","+d(A[1])+","+d(A[2])+","+d(A[3])+","+d(-A[4])+","+d(-A[5])+","+d(-A[6])+","+d(-A[7])+","+d(A[8])+","+d(A[9])+","+d(A[10])+","+d(A[11])+","+d(A[12])+","+d(A[13])+","+d(A[14])+","+d(A[15])+")")}function h(m){m.isCSS3DObject&&(m.element.style.display="none");for(let A=0,M=m.children.length;A<M;A++)h(m.children[A])}function y(m,A,M,x){if(m.visible===!1){h(m);return}if(m.isCSS3DObject){const S=m.layers.test(M.layers)===!0,T=m.element;if(T.style.display=S===!0?"":"none",S===!0){m.onBeforeRender(t,A,M);let v;m.isCSS3DSprite?(pe.copy(M.matrixWorldInverse),pe.transpose(),m.rotation2D!==0&&pe.multiply(xo.makeRotationZ(m.rotation2D)),m.matrixWorld.decompose(vs,So,Ss),pe.setPosition(vs),pe.scale(Ss),pe.elements[3]=0,pe.elements[7]=0,pe.elements[11]=0,pe.elements[15]=1,v=g(pe)):v=g(m.matrixWorld);const I=r.objects.get(m);if(I===void 0||I.style!==v){T.style.transform=v;const b={style:v};r.objects.set(m,b)}T.parentNode!==l&&l.appendChild(T),m.onAfterRender(t,A,M)}}for(let S=0,T=m.children.length;S<T;S++)y(m.children[S],A,M)}}}class En extends Ee{constructor(e){super(),this.isMark=!0,this.disposed=!1,this.events=e}drawStart(e,t){if(this.disposed)return;const n=this,a=document.querySelectorAll(".mark-wrap-line.main-warp").length+1,o={type:"MarkDistanceLine",name:t||"line"+Date.now(),startPoint:e.toArray(),endPoint:e.toArray(),lineColor:"#eeee00",lineWidth:3,mainTagColor:"#c4c4c4",mainTagBackground:"#2E2E30",mainTagOpacity:.8,mainTagVisible:!0,distanceTagColor:"#000000",distanceTagBackground:"#e0ffff",distanceTagOpacity:.9,distanceTagVisible:!0,title:"标记距离"+a},s=new Ke;s.setPositions([...o.startPoint,...o.endPoint]);const r=new Le({color:o.lineColor,linewidth:o.lineWidth});r.resolution.set(innerWidth,innerHeight),n.copy(new Ee(s,r));const c=new u.CircleGeometry(.05,32),f=new u.MeshBasicMaterial({color:16777215,side:u.DoubleSide});f.transparent=!0,f.opacity=.6;const l=new u.Mesh(c,f);l.position.copy(e),l.isMark=!0;const d=new u.Mesh(c,f);d.position.copy(e),d.isMark=!0;const p=document.createElement("div");p.innerHTML=`<div style='flex-direction: column;align-items: center;display: flex;pointer-events: none;margin-bottom: 40px;'>
|
|
709
|
+
<span class="${o.name}-main-tag" style="color:${o.mainTagColor};background:${o.mainTagBackground};opacity:${o.mainTagOpacity};padding:1px 5px 2px 5px;border-radius: 4px;user-select: none;font-size: 12px;pointer-events: auto;">${o.title}</span>
|
|
710
|
+
</div>`,p.classList.add("mark-wrap-line",`${o.name}`,"main-warp"),p.style.position="absolute",p.style.borderRadius="4px",p.style.cursor="pointer",p.onclick=()=>{if(n.events.fire(_).markMode)return;const m=parent?.onActiveMark;m?.(n.getMarkData(!0)),n.events.fire(j)},p.oncontextmenu=m=>m.preventDefault();const g=new te(p);g.position.copy(e),g.element.style.pointerEvents="none",g.scale.set(.01,.01,.01),g.visible=o.mainTagVisible;const h=document.createElement("div");h.innerHTML=`<span class="${t}-distance-tag ${t}-distance-tag0" style="color:${o.distanceTagColor};background:${o.distanceTagBackground};opacity:${o.distanceTagOpacity};padding: 1px 5px;border-radius: 4px;margin-bottom: 5px;user-select: none;font-size: 12px;pointer-events: none;"></span>`,h.classList.add("mark-wrap-line",`${t}`,"distance-warp"),h.style.position="absolute",h.style.borderRadius="4px",h.style.pointerEvents="none";const y=new te(h);y.position.set(e.x,e.y,e.z),y.element.style.pointerEvents="none",y.scale.set(.008,.008,.008),y.visible=!1,n.add(l,d,g,y),n.data=o,n.circleStart=l,n.circleEnd=d,n.css3dTag=y,n.css3dMainTag=g,n.events.fire(ye,n)}drawUpdate(e,t=!0){if(this.disposed)return;const n=this;if(e?.endPoint){t&&(n.data.endPoint=[...e.endPoint]);const a=new u.Vector3().fromArray(n.data.startPoint),o=new u.Vector3().fromArray(e.endPoint);n.geometry.setPositions([...n.data.startPoint,...e.endPoint]);const s=new u.Vector3((a.x+o.x)/2,(a.y+o.y)/2,(a.z+o.z)/2);n.css3dTag.position.set(s.x,s.y,s.z);const r=o.clone().sub(a).normalize();n.circleStart.lookAt(n.circleStart.position.clone().add(r)),n.circleEnd.lookAt(n.circleEnd.position.clone().add(r));const c=a.distanceTo(o);n.css3dTag.visible=c>.5;const f=(c*n.events.fire(_).meterScale).toFixed(2)+" m";n.css3dTag.element.childNodes[0].innerText=f}e?.lineColor&&(t&&(n.data.lineColor=e.lineColor),n.material.color.set(e.lineColor)),e?.lineWidth&&(t&&(n.data.lineWidth=e.lineWidth),n.material.linewidth=e.lineWidth),e?.mainTagColor&&(t&&(n.data.mainTagColor=e.mainTagColor),document.querySelector(`.${n.data.name}-main-tag`).style.color=e.mainTagColor),e?.mainTagBackground&&(t&&(n.data.mainTagBackground=e.mainTagBackground),document.querySelector(`.${n.data.name}-main-tag`).style.background=e.mainTagBackground),e?.mainTagOpacity&&(t&&(n.data.mainTagOpacity=e.mainTagOpacity),document.querySelector(`.${n.data.name}-main-tag`).style.opacity=e.mainTagOpacity.toString()),e?.mainTagVisible!==void 0&&(t&&(n.data.mainTagVisible=e.mainTagVisible),n.css3dMainTag.visible=e.mainTagVisible),e?.distanceTagColor&&(t&&(n.data.distanceTagColor=e.distanceTagColor),document.querySelector(`.${n.data.name}-distance-tag0`).style.color=e.distanceTagColor),e?.distanceTagBackground&&(t&&(n.data.distanceTagBackground=e.distanceTagBackground),document.querySelector(`.${n.data.name}-distance-tag0`).style.background=e.distanceTagBackground),e?.distanceTagOpacity&&(t&&(n.data.distanceTagOpacity=e.distanceTagOpacity),document.querySelector(`.${n.data.name}-distance-tag0`).style.opacity=e.distanceTagOpacity.toString()),e?.distanceTagVisible!==void 0&&(t&&(n.data.distanceTagVisible=e.distanceTagVisible),n.css3dTag.visible=e.distanceTagVisible),e?.title!==void 0&&(t&&(n.data.title=e.title),this.css3dMainTag.element.querySelector(`.${n.data.name}-main-tag`).innerText=e.title),e?.note!==void 0&&t&&(n.data.note=e.note),n.events.fire(q)}updateByMeterScale(e){const t=this,n=new u.Vector3().fromArray(t.data.startPoint),a=new u.Vector3().fromArray(t.data.endPoint),o=(n.distanceTo(a)*e).toFixed(2)+" m";t.css3dTag.element.childNodes[0].innerText=o}drawFinish(e){if(this.disposed)return;const t=this;t.data.endPoint=[...e.toArray()];const n=new u.Vector3().fromArray(t.data.startPoint),a=new u.Vector3().fromArray(t.data.endPoint),o=new u.Vector3((n.x+a.x)/2,(n.y+a.y)/2,(n.z+a.z)/2);t.geometry.setPositions([...t.data.startPoint,...t.data.endPoint]),t.css3dTag.position.set(o.x,o.y,o.z);const s=a.clone().sub(n).normalize();t.circleStart.lookAt(t.circleStart.position.clone().add(s)),t.circleEnd.lookAt(t.circleEnd.position.clone().add(s)),t.circleEnd.position.copy(a);const r=n.distanceTo(a);t.css3dTag.visible=!0;const c=(r*t.events.fire(_).meterScale).toFixed(2)+" m";t.css3dTag.element.childNodes[0].innerText=c,t.events.fire(we);const f=parent?.onActiveMark,l=t.getMarkData(!0);l.isNew=!0,l.meterScale=t.events.fire(_).meterScale,f?.(l)}draw(e){if(this.disposed)return;const t=this,n={type:"MarkDistanceLine",name:e.name||"line"+Date.now(),startPoint:[...e.startPoint],endPoint:[...e.endPoint],lineColor:e.lineColor||"#eeee00",lineWidth:e.lineWidth||3,mainTagColor:e.mainTagColor||"#c4c4c4",mainTagBackground:e.mainTagBackground||"#2E2E30",mainTagOpacity:e.mainTagOpacity||.8,mainTagVisible:e.mainTagVisible===void 0?!0:e.mainTagVisible,distanceTagColor:e.distanceTagColor||"#000000",distanceTagBackground:e.distanceTagBackground||"#e0ffff",distanceTagOpacity:e.distanceTagOpacity||.9,distanceTagVisible:e.distanceTagVisible===void 0?!0:e.distanceTagVisible,title:e.title||"标记距离"},a=new u.Vector3().fromArray(n.startPoint),o=new u.Vector3().fromArray(n.endPoint),s=new u.Vector3((a.x+o.x)/2,(a.y+o.y)/2,(a.z+o.z)/2),r=new Ke;r.setPositions([...n.startPoint,...n.endPoint]);const c=new Le({color:n.lineColor,linewidth:n.lineWidth});c.resolution.set(innerWidth,innerHeight),t.copy(new Ee(r,c));const f=new u.CircleGeometry(.05,32),l=new u.MeshBasicMaterial({color:16777215,side:u.DoubleSide});l.transparent=!0,l.opacity=.6;const d=new u.Mesh(f,l);d.position.copy(a),d.isMark=!0;const p=new u.Mesh(f,l);p.position.copy(o),p.isMark=!0;const g=o.clone().sub(a).normalize();d.lookAt(d.position.clone().add(g)),p.lookAt(p.position.clone().add(g));const h=n.name,y=document.createElement("div");y.innerHTML=`<div style='flex-direction: column;align-items: center;display: flex;pointer-events: none;margin-bottom: 40px;'>
|
|
711
|
+
<span class="${h}-main-tag" style="color:${n.mainTagColor};background:${n.mainTagBackground};opacity:${n.mainTagOpacity};padding:1px 5px 2px 5px;border-radius: 4px;margin-bottom: 5px;user-select: none;font-size: 12px;pointer-events: auto;">${n.title}</span>
|
|
712
|
+
</div>`,y.classList.add("mark-wrap-line",`${n.name}`,"main-warp"),y.style.position="absolute",y.style.borderRadius="4px",y.style.cursor="pointer",y.onclick=()=>{if(t.events.fire(_).markMode)return;const T=parent?.onActiveMark;T?.(t.getMarkData(!0)),t.events.fire(j)},y.oncontextmenu=T=>T.preventDefault();const m=new te(y);m.position.copy(a),m.element.style.pointerEvents="none",m.scale.set(.01,.01,.01),m.visible=n.mainTagVisible;const M=(a.distanceTo(o)*t.events.fire(_).meterScale).toFixed(2)+" m",x=document.createElement("div");x.innerHTML=`<span class="${h}-distance-tag ${h}-distance-tag0" style="color:${n.distanceTagColor};background:${n.distanceTagBackground};opacity:${n.distanceTagOpacity};padding: 1px 5px;border-radius: 4px;margin-bottom: 5px;user-select: none;font-size: 12px;pointer-events: none;">${M}</span>`,x.classList.add("mark-wrap-line",`${h}`,"distance-warp"),x.style.position="absolute",x.style.borderRadius="4px",x.style.pointerEvents="none";const S=new te(x);S.position.copy(s),S.element.style.pointerEvents="none",S.scale.set(.008,.008,.008),S.visible=n.distanceTagVisible,t.add(d,p,m,S),t.data=n,t.circleStart=d,t.circleEnd=p,t.css3dTag=S,t.css3dMainTag=m,t.events.fire(ye,t)}getMarkData(e=!1){const t={...this.data};return e?(delete t.startPoint,delete t.endPoint):(t.startPoint=[...t.startPoint],t.endPoint=[...t.endPoint]),t}dispose(){if(this.disposed)return;const e=this;e.disposed=!0,e.events.fire(ve,e),e.events.fire(U).remove(e),e.events.fire(Pe,e),document.querySelectorAll(`.${e.data.name}`).forEach(n=>n.parentElement?.removeChild(n)),e.events=null,e.data=null,e.circleStart=null,e.circleEnd=null,e.css3dTag=null,e.css3dMainTag=null}}class kn extends Ee{constructor(e){super(),this.isMark=!0,this.disposed=!1,this.css3dTags=[],this.group=new u.Group,this.add(this.group),this.events=e}drawStart(e,t){if(this.disposed)return;const n=document.querySelectorAll(".mark-wrap-lines.main-warp").length+1,a={type:"MarkMultiLines",name:t||"lines"+Date.now(),points:[...e.toArray(),...e.toArray()],lineColor:"#eeee00",lineWidth:3,mainTagColor:"#c4c4c4",mainTagBackground:"#2E2E30",mainTagOpacity:.8,mainTagVisible:!0,distanceTagColor:"#000000",distanceTagBackground:"#e0ffff",distanceTagOpacity:.9,distanceTagVisible:!0,title:"标记线"+n,note:""};this.draw(a)}drawUpdate(e,t=!0,n,a=!1){if(this.disposed)return;const o=this;if(n)if(a){const s=o.data.points.length,r=o.css3dTags.length-1,c=new u.Vector3().fromArray(o.data.points.slice(s-6,s-3)),f=n,l=new u.Vector3((c.x+f.x)/2,(c.y+f.y)/2,(c.z+f.z)/2),p=(c.distanceTo(f)*o.events.fire(_).meterScale).toFixed(2)+" m";o.css3dTags[r].element.childNodes[0].innerText=p,o.css3dTags[r].position.set(l.x,l.y,l.z),o.css3dTags[r].visible=!0,o.data.points.pop(),o.data.points.pop(),o.data.points.pop(),o.data.points=[...o.data.points,...n.toArray(),...n.toArray()],o.css3dTags[o.css3dTags.length-1].visible=!0,this.draw(this.data)}else{const s=o.data.points.length;o.data.points[s-3]=n.x,o.data.points[s-2]=n.y,o.data.points[s-1]=n.z;const r=o.css3dTags.length-1,c=new u.Vector3().fromArray(o.data.points.slice(s-6,s-3)),f=new u.Vector3().fromArray(o.data.points.slice(s-3)),l=new u.Vector3((c.x+f.x)/2,(c.y+f.y)/2,(c.z+f.z)/2),d=c.distanceTo(f),p=(d*o.events.fire(_).meterScale).toFixed(2)+" m";o.css3dTags[r].element.childNodes[0].innerText=p,o.geometry.setPositions([...o.data.points]),o.css3dTags[r].position.set(l.x,l.y,l.z),o.css3dTags[r].visible=a?!0:d>.5}e?.lineColor&&(t&&(o.data.lineColor=e.lineColor),o.material.color.set(e.lineColor)),e?.lineWidth&&(t&&(o.data.lineWidth=e.lineWidth),o.material.linewidth=e.lineWidth),e?.mainTagColor&&(t&&(o.data.mainTagColor=e.mainTagColor),document.querySelector(`.${o.data.name}-main-tag`).style.color=e.mainTagColor),e?.mainTagBackground&&(t&&(o.data.mainTagBackground=e.mainTagBackground),document.querySelector(`.${o.data.name}-main-tag`).style.background=e.mainTagBackground),e?.mainTagOpacity&&(t&&(o.data.mainTagOpacity=e.mainTagOpacity),document.querySelector(`.${o.data.name}-main-tag`).style.opacity=e.mainTagOpacity.toString()),e?.mainTagVisible!==void 0&&(t&&(o.data.mainTagVisible=e.mainTagVisible),o.css3dMainTag.visible=e.mainTagVisible),e?.distanceTagColor&&(t&&(o.data.distanceTagColor=e.distanceTagColor),document.querySelectorAll(`.${o.data.name}-distance-tag`)?.forEach(r=>r.style.color=e.distanceTagColor)),e?.distanceTagBackground&&(t&&(o.data.distanceTagBackground=e.distanceTagBackground),document.querySelectorAll(`.${o.data.name}-distance-tag`)?.forEach(r=>r.style.background=e.distanceTagBackground)),e?.distanceTagOpacity&&(t&&(o.data.distanceTagOpacity=e.distanceTagOpacity),document.querySelectorAll(`.${o.data.name}-distance-tag`)?.forEach(r=>r.style.opacity=e.distanceTagOpacity.toString())),e?.distanceTagVisible!==void 0&&(t&&(o.data.distanceTagVisible=e.distanceTagVisible),o.css3dTags.forEach(s=>s.visible=e.distanceTagVisible)),e?.title!==void 0&&(t&&(o.data.title=e.title),this.css3dMainTag.element.querySelector(`.${o.data.name}-main-tag`).innerText=e.title),e?.note!==void 0&&t&&(o.data.note=e.note),o.events.fire(q)}updateByMeterScale(e){const t=this,n=[];for(let s=0,r=t.data.points.length/3;s<r;s++)n.push(new u.Vector3(t.data.points[s*3],t.data.points[s*3+1],t.data.points[s*3+2]));let a,o;for(let s=1;s<n.length;s++)a=n[s-1],o=n[s],t.css3dTags[s-1].element.childNodes[0].innerText=(a.distanceTo(o)*e).toFixed(2)+" m"}drawFinish(e){if(this.disposed)return;const t=this,n=t.data.points.length,a=new u.Vector3().fromArray(t.data.points.slice(n-6,n-3)),o=new u.Vector3().fromArray(t.data.points.slice(n-3));if((!e||a.distanceTo(o)<.001)&&(t.data.points.pop(),t.data.points.pop(),t.data.points.pop(),t.draw(t.data)),t.events.fire(we),t.data.points.length<6){t.dispose();return}else{for(;t.css3dTags.length>t.data.points.length/3-1;){const c=t.css3dTags.pop();t.group.remove(c),c.element.parentElement?.removeChild(c.element)}t.css3dTags[t.css3dTags.length-1].visible=!0}const s=parent?.onActiveMark,r=t.getMarkData(!0);r.isNew=!0,r.meterScale=t.events.fire(_).meterScale,s?.(r)}draw(e,t=!1){if(this.disposed)return;const n=this;this.css3dTags=this.css3dTags||[];const a={type:"MarkMultiLines",name:e.name||"lines"+Date.now(),points:[...e.points],lineColor:e.lineColor||"#eeee00",lineWidth:e.lineWidth||3,mainTagColor:e.mainTagColor||"#c4c4c4",mainTagBackground:e.mainTagBackground||"#2E2E30",mainTagOpacity:e.mainTagOpacity||.8,mainTagVisible:e.mainTagVisible===void 0?!0:e.mainTagVisible,distanceTagColor:e.distanceTagColor||"#000000",distanceTagBackground:e.distanceTagBackground||"#e0ffff",distanceTagOpacity:e.distanceTagOpacity||.9,distanceTagVisible:e.distanceTagVisible===void 0?!0:e.distanceTagVisible,title:e.title||"标记线"+(document.querySelectorAll(".mark-wrap-lines.main-warp").length+1),note:e.note||""},o=n.geometry,s=n.material,r=new Ke;r.setPositions([...a.points]);const c=new Le({color:a.lineColor,linewidth:a.lineWidth});c.resolution.set(innerWidth,innerHeight),n.copy(new Ee(r,c)),o?.dispose(),s?.dispose();const f=a.name,l=a.points.length/3-1;if(!n.css3dMainTag){const d=document.createElement("div");d.innerHTML=`<div style='flex-direction: column;align-items: center;display: flex;pointer-events: none;margin-bottom: 40px;'>
|
|
713
|
+
<span class="${f}-main-tag" style="color:${a.mainTagColor};background:${a.mainTagBackground};opacity:${a.mainTagOpacity};padding:1px 5px 2px 5px;border-radius: 4px;user-select: none;font-size: 12px;pointer-events: auto;">${a.title}</span>
|
|
714
|
+
</div>`,d.classList.add("mark-wrap-lines",`${a.name}`,"main-warp"),d.style.position="absolute",d.style.borderRadius="4px",d.style.cursor="pointer",d.onclick=()=>{if(n.events.fire(_).markMode)return;const g=parent?.onActiveMark,h=n.getMarkData(!0);h.meterScale=n.events.fire(_).meterScale,g?.(h),n.events.fire(j)},d.oncontextmenu=g=>g.preventDefault();const p=new te(d);p.position.set(a.points[0],a.points[1],a.points[2]),p.element.style.pointerEvents="none",p.scale.set(.01,.01,.01),p.visible=a.mainTagVisible,n.group.add(p),n.css3dMainTag=p}for(let d=n.css3dTags.length;d<l;d++){const p=new u.Vector3().fromArray(a.points.slice(d*3,d*3+3)),g=new u.Vector3().fromArray(a.points.slice(d*3+3,d*3+6)),h=new u.Vector3((p.x+g.x)/2,(p.y+g.y)/2,(p.z+g.z)/2),m=(p.distanceTo(g)*n.events.fire(_).meterScale).toFixed(2)+" m",A=document.createElement("div");A.innerHTML=`<span class="${f}-distance-tag ${f}-distance-tag${d}" style="color:${a.distanceTagColor};background:${a.distanceTagBackground};opacity:${a.distanceTagOpacity};padding: 1px 5px;border-radius: 4px;margin-bottom: 5px;user-select: none;font-size: 12px;pointer-events: none;">${m}</span>`,A.classList.add("mark-wrap-lines",`${f}`,"distance-warp"),A.style.position="absolute",A.style.borderRadius="4px",A.style.display="none";const M=new te(A);M.position.copy(h),M.element.style.pointerEvents="none",M.scale.set(.008,.008,.008),M.visible=a.distanceTagVisible,n.css3dTags.push(M),n.group.add(M)}t||(n.css3dTags[n.css3dTags.length-1].visible=!1),n.data=a,n.events.fire(ye,n)}getMarkData(e=!1){const t={...this.data};return e?delete t.points:t.points=[...t.points],t}dispose(){if(this.disposed)return;const e=this;e.disposed=!0,e.events.fire(ve,e),e.events.fire(U).remove(e),e.events.fire(Pe,e),e.geometry.dispose(),e.material.dispose(),document.querySelectorAll(`.${e.data.name}`).forEach(n=>n.parentElement?.removeChild(n)),e.events=null,e.data=null,e.css3dTags=null,e.group=null}}class bs extends u.Group{constructor(e,t,n){super(),this.isMark=!0,this.disposed=!1,this.events=e;const a=this;let o;if(t instanceof u.Vector3){const c=document.querySelectorAll(".mark-wrap-point").length+1;o={type:"MarkSinglePoint",name:n||"point"+Date.now(),point:t.toArray(),iconName:"#svgicon-point2",iconColor:"#eeee00",iconOpacity:.8,mainTagColor:"#c4c4c4",mainTagBackground:"#2E2E30",mainTagOpacity:.8,title:"标记点"+c,note:""}}else o={type:"MarkSinglePoint",name:t.name||"point"+Date.now(),point:[...t.point],iconName:t.iconName||"#svgicon-point2",iconColor:t.iconColor||"#eeee00",iconOpacity:t.iconOpacity||.8,mainTagColor:t.mainTagColor||"#c4c4c4",mainTagBackground:t.mainTagBackground||"#2E2E30",mainTagOpacity:t.mainTagOpacity||.8,title:t.title||"标记点",note:t.note||""};const s=document.createElement("div");s.innerHTML=`<div style='flex-direction: column;align-items: center;display: flex;pointer-events: none;margin-bottom: 40px;'>
|
|
715
|
+
<span class="${o.name}" style="color:${o.mainTagColor};background:${o.mainTagBackground};opacity:${o.mainTagOpacity};padding:1px 5px 2px 5px;border-radius: 4px;margin-bottom: 5px;user-select: none;font-size: 12px;pointer-events: auto;">${o.title}</span>
|
|
716
|
+
<svg height="20" width="20" style="color:${o.iconColor};opacity:${o.iconOpacity};"><use href="${o.iconName}" fill="currentColor" /></svg>
|
|
717
|
+
</div>`,s.classList.add("mark-wrap-point",`mark-wrap-${o.name}`),s.style.position="absolute",s.style.borderRadius="4px",s.style.cursor="pointer",s.onclick=()=>{if(a.events.fire(_).markMode)return;const c=parent?.onActiveMark;c?.(a.getMarkData(!0)),a.events.fire(j)},s.oncontextmenu=c=>c.preventDefault();const r=new te(s);r.position.set(o.point[0],o.point[1],o.point[2]),r.element.style.pointerEvents="none",r.scale.set(.01,.01,.01),a.data=o,a.css3dTag=r,a.add(r),e.fire(ye,a)}drawUpdate(e,t=!0){if(this.disposed)return;const n=this;if(e?.iconName){t&&(n.data.iconName=e.iconName);const a=this.css3dTag.element.querySelector(`.mark-wrap-${n.data.name} svg`);a.innerHTML=`<use href="${e.iconName}" fill="currentColor" />`}if(e?.iconColor){t&&(n.data.iconColor=e.iconColor);const a=this.css3dTag.element.querySelector(`.mark-wrap-${n.data.name} svg`);a.style.color=e.iconColor}if(e?.iconOpacity){t&&(n.data.iconOpacity=e.iconOpacity);const a=this.css3dTag.element.querySelector(`.mark-wrap-${n.data.name} svg`);a.style.opacity=e.iconOpacity.toString()}e?.mainTagColor&&(t&&(n.data.mainTagColor=e.mainTagColor),this.css3dTag.element.querySelector(`.${n.data.name}`).style.color=e.mainTagColor),e?.mainTagBackground&&(t&&(n.data.mainTagBackground=e.mainTagBackground),this.css3dTag.element.querySelector(`.${n.data.name}`).style.background=e.mainTagBackground),e?.mainTagOpacity&&(t&&(n.data.mainTagOpacity=e.mainTagOpacity),this.css3dTag.element.querySelector(`.${n.data.name}`).style.opacity=e.mainTagOpacity.toString()),e?.title!==void 0&&(t&&(n.data.title=e.title),this.css3dTag.element.querySelector(`.${n.data.name}`).innerText=e.title),e?.note!==void 0&&t&&(n.data.note=e.note),n.events.fire(q)}resetMeterScale(e){e?.meterScale!==void 0&&(this.events.fire(_).meterScale=e.meterScale)}drawFinish(){if(this.disposed)return;const e=this;e.events.fire(we);const t=parent?.onActiveMark,n=e.getMarkData(!0);n.isNew=!0,n.meterScale=e.events.fire(_).meterScale,t?.(n)}getMarkData(e=!1){const t={...this.data};return e?delete t.point:t.point=[...t.point],t}dispose(){if(this.disposed)return;const e=this;e.disposed=!0,e.events.fire(ve,e),e.events.fire(U).remove(e),e.events.fire(Pe,e);const t=document.querySelector(`.mark-wrap-${e.data.name}`);t?.parentElement?.removeChild?.(t),e.events=null,e.data=null,e.css3dTag=null}}class _n extends Ee{constructor(e){super(),this.isMark=!0,this.disposed=!1,this.css3dTags=[],this.group=new u.Group,this.add(this.group),this.events=e}drawStart(e,t){if(this.disposed)return;const n=document.querySelectorAll(".mark-wrap-plans.main-warp").length+1,a={type:"MarkMultiPlans",name:t||"plans"+Date.now(),points:[...e.toArray(),...e.toArray()],lineColor:"#eeee00",lineWidth:3,mainTagColor:"#c4c4c4",mainTagBackground:"#2E2E30",mainTagOpacity:.8,mainTagVisible:!0,areaTagColor:"#000000",areaTagBackground:"#e0ffff",areaTagOpacity:.8,distanceTagVisible:!0,areaTagVisible:!0,planOpacity:.5,title:"标记面"+n,note:""};this.draw(a)}drawUpdate(e,t=!0,n,a=!1){if(this.disposed)return;const o=this;if(n)if(a){const s=o.data.points.length,r=o.css3dTags.length-1,c=new u.Vector3().fromArray(o.data.points.slice(s-6,s-3)),f=n,l=new u.Vector3((c.x+f.x)/2,(c.y+f.y)/2,(c.z+f.z)/2),p=(c.distanceTo(f)*o.events.fire(_).meterScale).toFixed(2)+" m";o.css3dTags[r].element.innerText=p,o.css3dTags[r].position.set(l.x,l.y,l.z),o.css3dTags[r].visible=!0,o.data.points.pop(),o.data.points.pop(),o.data.points.pop(),o.data.points=[...o.data.points,...n.toArray(),...n.toArray()],this.draw(this.data)}else{const s=o.data.points.length;o.data.points[s-3]=n.x,o.data.points[s-2]=n.y,o.data.points[s-1]=n.z;const r=o.css3dTags.length-1,c=new u.Vector3().fromArray(o.data.points.slice(s-6,s-3)),f=new u.Vector3().fromArray(o.data.points.slice(s-3)),l=new u.Vector3((c.x+f.x)/2,(c.y+f.y)/2,(c.z+f.z)/2),d=c.distanceTo(f),p=(d*o.events.fire(_).meterScale).toFixed(2)+" m";o.css3dTags[r].element.innerText=p,o.geometry.setPositions([...o.data.points]),o.css3dTags[r].position.set(l.x,l.y,l.z),o.css3dTags[r].visible=a?!0:d>.5,o.meshPlans.geometry.setAttribute("position",new u.BufferAttribute(new Float32Array(o.data.points),3)),o.meshPlans.geometry.attributes.position.needsUpdate=!0;const g=o.events.fire(_t,o.data.points);o.css3dAreaTag.position.copy(g);const h=o.events.fire(It,o.data.points);o.css3dAreaTag.element.childNodes[0].innerText=h.toFixed(2)+" m²"}if(e?.lineColor&&(t&&(o.data.lineColor=e.lineColor),o.material.color.set(e.lineColor),o.meshPlans.material.color.set(e.lineColor)),e?.lineWidth&&(t&&(o.data.lineWidth=e.lineWidth),o.material.linewidth=e.lineWidth),e?.mainTagColor&&(t&&(o.data.mainTagColor=e.mainTagColor),document.querySelector(`.${o.data.name}-main-tag`).style.color=e.mainTagColor),e?.mainTagBackground&&(t&&(o.data.mainTagBackground=e.mainTagBackground),document.querySelector(`.${o.data.name}-main-tag`).style.background=e.mainTagBackground),e?.mainTagOpacity&&(t&&(o.data.mainTagOpacity=e.mainTagOpacity),document.querySelector(`.${o.data.name}-main-tag`).style.opacity=e.mainTagOpacity.toString()),e?.mainTagVisible!==void 0&&(t&&(o.data.mainTagVisible=e.mainTagVisible),o.css3dMainTag.visible=e.mainTagVisible),e?.areaTagVisible!==void 0&&(t&&(o.data.areaTagVisible=e.areaTagVisible),o.css3dAreaTag.visible=e.areaTagVisible),e?.areaTagColor){t&&(o.data.areaTagColor=e.areaTagColor);const s=document.querySelector(`.${o.data.name}-area-tag`);s&&(s.style.color=e.areaTagColor)}if(e?.areaTagBackground){t&&(o.data.areaTagBackground=e.areaTagBackground);const s=document.querySelector(`.${o.data.name}-area-tag`);s&&(s.style.background=e.areaTagBackground)}if(e?.areaTagOpacity){t&&(o.data.areaTagOpacity=e.areaTagOpacity);const s=document.querySelector(`.${o.data.name}-area-tag`);s&&(s.style.opacity=e.areaTagOpacity.toString())}e?.distanceTagVisible!==void 0&&(t&&(o.data.distanceTagVisible=e.distanceTagVisible),o.css3dTags.forEach(s=>s.visible=e.distanceTagVisible)),e?.planOpacity&&(t&&(o.data.planOpacity=e.planOpacity),this.meshPlans.material.opacity=e.planOpacity),e?.title!==void 0&&(t&&(o.data.title=e.title),this.css3dMainTag.element.querySelector(`.${o.data.name}-main-tag`).innerText=e.title),e?.note!==void 0&&t&&(o.data.note=e.note),o.events.fire(q)}updateByMeterScale(e){const t=this,n=[];for(let r=0,c=t.data.points.length/3;r<c;r++)n.push(new u.Vector3(t.data.points[r*3],t.data.points[r*3+1],t.data.points[r*3+2]));let a,o;for(let r=1;r<n.length;r++)a=n[r-1],o=n[r],t.css3dTags[r-1].element.innerText=(a.distanceTo(o)*e).toFixed(2)+" m";const s=t.events.fire(Rn,n,e);t.css3dAreaTag.element.childNodes[0].innerText=s.toFixed(2)+" m²"}drawFinish(e){if(this.disposed)return;const t=this,n=t.data.points.length,a=new u.Vector3().fromArray(t.data.points.slice(n-6,n-3)),o=new u.Vector3().fromArray(t.data.points.slice(n-3));if((!e||a.distanceTo(o)<1e-4)&&(t.data.points.pop(),t.data.points.pop(),t.data.points.pop()),t.events.fire(we),t.data.points.length<9){t.dispose();return}for(;t.css3dTags.length>t.data.points.length/3-1;){const c=t.css3dTags.pop();t.group.remove(c),c.element.parentElement?.removeChild(c.element)}t.data.points.push(t.data.points[0],t.data.points[1],t.data.points[2]),t.draw(t.data,!0),t.css3dTags[t.css3dTags.length-1].visible=!0;const s=parent?.onActiveMark,r=t.getMarkData(!0);r.isNew=!0,r.meterScale=t.events.fire(_).meterScale,s?.(r)}draw(e,t=!1){if(this.disposed)return;const n=this;this.css3dTags=this.css3dTags||[];const a={type:"MarkMultiPlans",name:e.name||"plans"+Date.now(),points:[...e.points],lineColor:e.lineColor||"#eeee00",lineWidth:e.lineWidth||3,mainTagColor:e.mainTagColor||"#c4c4c4",mainTagBackground:e.mainTagBackground||"#2E2E30",mainTagOpacity:e.mainTagOpacity||.8,mainTagVisible:e.mainTagVisible===void 0?!0:e.mainTagVisible,areaTagColor:e.areaTagColor||"#000000",areaTagBackground:e.areaTagBackground||"#e0ffff",areaTagOpacity:e.areaTagOpacity||.9,areaTagVisible:e.areaTagVisible===void 0?!0:e.areaTagVisible,distanceTagVisible:e.distanceTagVisible===void 0?!0:e.distanceTagVisible,planOpacity:e.planOpacity||.5,title:e.title||"标记面"+(document.querySelectorAll(".mark-wrap-plans.main-warp").length+1),note:e.note||""},o=n.geometry,s=n.material,r=new Ke;r.setPositions([...a.points]);const c=new Le({color:a.lineColor,linewidth:a.lineWidth});c.resolution.set(innerWidth,innerHeight),n.copy(new Ee(r,c)),o?.dispose(),s?.dispose();const f=a.name,l=a.points.length/3-1;if(!n.css3dMainTag){const g=document.createElement("div");g.innerHTML=`<div style='flex-direction: column;align-items: center;display: flex;pointer-events: none;margin-bottom: 40px;'>
|
|
718
|
+
<span class="${f}-main-tag" style="color:${a.mainTagColor};background:${a.mainTagBackground};opacity:${a.mainTagOpacity};padding:1px 5px 2px 5px;border-radius: 4px;user-select: none;font-size: 12px;pointer-events: auto;">${a.title}</span>
|
|
719
|
+
</div>`,g.classList.add("mark-wrap-plans",`${a.name}`,"main-warp"),g.style.position="absolute",g.style.borderRadius="4px",g.style.cursor="pointer",g.onclick=()=>{if(n.events.fire(_).markMode)return;const y=parent?.onActiveMark,m=n.getMarkData(!0);m.meterScale=n.events.fire(_).meterScale,y?.(m),n.events.fire(j)},g.oncontextmenu=y=>y.preventDefault();const h=new te(g);h.position.set(a.points[0],a.points[1],a.points[2]),h.element.style.pointerEvents="none",h.scale.set(.01,.01,.01),h.visible=a.mainTagVisible,n.group.add(h),n.css3dMainTag=h}const d=n.events.fire(It,a.points).toFixed(2)+" m²",p=n.events.fire(_t,a.points);if(n.css3dAreaTag)n.css3dAreaTag.position.copy(p),n.css3dAreaTag.element.childNodes[0].innerText=d;else{const g=document.createElement("div");g.innerHTML=`<span class="${f}-area-tag" style="color:${a.areaTagColor};background:${a.areaTagBackground};opacity:${a.areaTagOpacity};padding:1px 5px 2px 5px;border-radius: 4px;user-select: none;font-size: 12px;pointer-events: none;">${d}</span>`,g.classList.add("mark-wrap-plans",`${a.name}`,"area-warp"),g.style.position="absolute",g.style.borderRadius="4px";const h=new te(g);h.position.copy(p),h.element.style.pointerEvents="none",h.scale.set(.01,.01,.01),n.group.add(h),n.css3dAreaTag=h}n.css3dAreaTag.visible=a.points.length>6&&a.areaTagVisible;for(let g=n.css3dTags.length;g<l;g++){const h=new u.Vector3().fromArray(a.points.slice(g*3,g*3+3)),y=new u.Vector3().fromArray(a.points.slice(g*3+3,g*3+6)),m=new u.Vector3((h.x+y.x)/2,(h.y+y.y)/2,(h.z+y.z)/2),M=(h.distanceTo(y)*n.events.fire(_).meterScale).toFixed(2)+" m",x=document.createElement("div");x.innerText=M,x.style.color="white",x.classList.add("mark-wrap-plans",`${f}`,"distance-warp"),x.style.position="absolute",x.style.borderRadius="4px",x.style.display="none";const S=new te(x);S.position.copy(m),S.element.style.pointerEvents="none",S.scale.set(.008,.008,.008),S.visible=a.distanceTagVisible,n.css3dTags.push(S),n.group.add(S)}n.drawPlans(a),t||(n.css3dTags[n.css3dTags.length-1].visible=!1),n.data=a,n.events.fire(ye,n)}drawPlans(e){const t=this;if(!t.meshPlans){const n=new u.BufferGeometry;n.setAttribute("position",new u.BufferAttribute(new Float32Array,3)),n.attributes.position.needsUpdate=!0;const a=new u.BufferAttribute(new Uint16Array([]),1);n.setIndex(a);const o=new u.MeshBasicMaterial({color:e.lineColor,transparent:!0,opacity:e.planOpacity,side:u.DoubleSide});t.meshPlans=new u.Mesh(n,o),t.meshPlans.renderOrder=1,t.meshPlans.isMark=!0,t.group.add(t.meshPlans)}if(e.points.length>6){t.meshPlans.geometry.setAttribute("position",new u.BufferAttribute(new Float32Array(e.points),3)),t.meshPlans.geometry.attributes.position.needsUpdate=!0;let n=e.points.length/3-2;const a=new u.Vector3().fromArray(e.points.slice(0,3)),o=new u.Vector3().fromArray(e.points.slice(-3));a.distanceTo(o)<1e-4&&n--;const s=new Uint16Array(n*3);for(let r=0;r<n;r++)s[r*3]=0,s[r*3+1]=r+1,s[r*3+2]=r+2;t.meshPlans.geometry.setIndex(new u.BufferAttribute(s,1))}}getMarkData(e=!1){const t={...this.data};return e?delete t.points:t.points=[...t.points],t}dispose(){if(this.disposed)return;const e=this;e.disposed=!0,e.events.fire(ve,e),e.events.fire(U).remove(e),e.events.fire(Pe,e),e.geometry.dispose(),e.material.dispose(),document.querySelectorAll(`.${e.data.name}`).forEach(n=>n.parentElement?.removeChild(n)),e.events=null,e.data=null,e.css3dTags=null,e.group=null,e.meshPlans=null,e.css3dMainTag=null,e.css3dAreaTag=null}}class xs extends u.Group{constructor(e){super(),this.isMark=!0,this.disposed=!1,this.events=e}drawStart(e,t){if(this.disposed)return;const n=this,a=document.querySelectorAll(".mark-wrap-circle.main-warp").length+1,o={type:"MarkCirclePlan",name:t||"circle"+Date.now(),startPoint:e.toArray(),radius:.05,circleColor:"#eeee00",circleOpacity:.5,mainTagColor:"#c4c4c4",mainTagBackground:"#2E2E30",mainTagOpacity:.8,mainTagVisible:!0,circleTagColor:"#000000",circleTagBackground:"#e0ffff",circleTagOpacity:.9,circleTagVisible:!0,title:"标记圆面"+a},s=new u.CircleGeometry(o.radius,32),r=new u.MeshBasicMaterial({color:o.circleColor,side:u.DoubleSide,transparent:!0});r.opacity=o.circleOpacity;const c=new u.Mesh(s,r);c.position.copy(e),c.isMark=!0,c.renderOrder=1;const f=new u.Vector3(0,1,0).normalize();c.lookAt(c.position.clone().add(f));const l=document.createElement("div");l.innerHTML=`<div style='flex-direction: column;align-items: center;display: flex;pointer-events: none;margin-bottom: 40px;'>
|
|
720
|
+
<span class="${o.name}-main-tag" style="color:${o.mainTagColor};background:${o.mainTagBackground};opacity:${o.mainTagOpacity};padding:1px 5px 2px 5px;border-radius: 4px;user-select: none;font-size: 12px;pointer-events: auto;">${o.title}</span>
|
|
721
|
+
</div>`,l.classList.add("mark-wrap-circle",`${o.name}`,"main-warp"),l.style.position="absolute",l.style.borderRadius="4px",l.style.cursor="pointer",l.onclick=()=>{if(n.events.fire(_).markMode)return;const h=parent?.onActiveMark;h?.(n.getMarkData(!0)),n.events.fire(j)},l.oncontextmenu=h=>h.preventDefault();const d=new te(l);d.position.copy(e),d.element.style.pointerEvents="none",d.scale.set(.01,.01,.01),d.visible=o.mainTagVisible;const p=document.createElement("div");p.innerHTML=`<span class="${t}-circle-tag" style="color:${o.circleTagColor};background:${o.circleTagBackground};opacity:${o.circleTagOpacity};padding: 1px 5px;border-radius: 4px;margin-bottom: 5px;user-select: none;font-size: 12px;pointer-events: none;"></span>`,p.classList.add("mark-wrap-circle",`${t}`,"circle-warp"),p.style.position="absolute",p.style.borderRadius="4px",p.style.pointerEvents="none";const g=new te(p);g.position.set(e.x+Math.min(o.radius/2,.5),e.y,e.z),g.element.style.pointerEvents="none",g.scale.set(.008,.008,.008),g.visible=!1,n.add(c,d,g),n.data=o,n.circleMesh=c,n.css3dTag=g,n.css3dMainTag=d,n.events.fire(ye,n)}drawUpdate(e,t=!0,n){if(this.disposed)return;const a=this;if(n){const o=new u.Vector3().fromArray(a.data.startPoint),s=o.distanceTo(new u.Vector3(n.x,o.y,n.z));t&&(a.data.radius=s),a.circleMesh.geometry.copy(new u.CircleGeometry(s,128)),a.css3dTag.visible=s>.3;const r=s*a.events.fire(_).meterScale,c=(Math.PI*r*r).toFixed(2)+" m²";a.css3dTag.element.childNodes[0].innerText=c,a.css3dTag.position.set(o.x+Math.min(a.data.radius/2,.5),o.y,o.z)}if(e?.radius){const o=new u.Vector3().fromArray(a.data.startPoint),s=e?.radius;t&&(a.data.radius=s),a.circleMesh.geometry.copy(new u.CircleGeometry(s,128)),a.css3dTag.visible=s>.3;const r=s*a.events.fire(_).meterScale,c=(Math.PI*r*r).toFixed(2)+" m²";a.css3dTag.element.childNodes[0].innerText=c,a.css3dTag.position.set(o.x+Math.min(s/2,.5),o.y,o.z)}e?.circleColor&&(t&&(a.data.circleColor=e.circleColor),a.circleMesh.material.color.set(e.circleColor)),e?.circleOpacity&&(t&&(a.data.circleOpacity=e.circleOpacity),a.circleMesh.material.opacity=e.circleOpacity),e?.mainTagColor&&(t&&(a.data.mainTagColor=e.mainTagColor),document.querySelector(`.${a.data.name}-main-tag`).style.color=e.mainTagColor),e?.mainTagBackground&&(t&&(a.data.mainTagBackground=e.mainTagBackground),document.querySelector(`.${a.data.name}-main-tag`).style.background=e.mainTagBackground),e?.mainTagOpacity&&(t&&(a.data.mainTagOpacity=e.mainTagOpacity),document.querySelector(`.${a.data.name}-main-tag`).style.opacity=e.mainTagOpacity.toString()),e?.mainTagVisible!==void 0&&(t&&(a.data.mainTagVisible=e.mainTagVisible),a.css3dMainTag.visible=e.mainTagVisible),e?.circleTagColor&&(t&&(a.data.circleTagColor=e.circleTagColor),document.querySelector(`.${a.data.name}-circle-tag`).style.color=e.circleTagColor),e?.circleTagBackground&&(t&&(a.data.circleTagBackground=e.circleTagBackground),document.querySelector(`.${a.data.name}-circle-tag`).style.background=e.circleTagBackground),e?.circleTagOpacity&&(t&&(a.data.circleTagOpacity=e.circleTagOpacity),document.querySelector(`.${a.data.name}-circle-tag`).style.opacity=e.circleTagOpacity.toString()),e?.circleTagVisible!==void 0&&(t&&(a.data.circleTagVisible=e.circleTagVisible),a.css3dTag.visible=e.circleTagVisible),e?.title!==void 0&&(t&&(a.data.title=e.title),this.css3dMainTag.element.querySelector(`.${a.data.name}-main-tag`).innerText=e.title),e?.note!==void 0&&t&&(a.data.note=e.note),a.events.fire(q)}updateByMeterScale(e){const t=this,n=t.data.radius*e,a=(Math.PI*n*n).toFixed(2)+" m²";t.css3dTag.element.childNodes[0].innerText=a}drawFinish(e){if(this.disposed)return;const t=this,n=new u.Vector3().fromArray(t.data.startPoint),a=n.distanceTo(new u.Vector3(e.x,n.y,e.z));t.data.radius=a,t.circleMesh.geometry.copy(new u.CircleGeometry(a,128));const o=t.data.radius*t.events.fire(_).meterScale,s=(Math.PI*o*o).toFixed(2)+" m²";t.css3dTag.element.childNodes[0].innerText=s,t.events.fire(we);const r=parent?.onActiveMark,c=t.getMarkData(!0);c.isNew=!0,c.meterScale=t.events.fire(_).meterScale,r?.(c)}draw(e){if(this.disposed)return;const t=this,n={type:"MarkCirclePlan",name:e.name||"circle"+Date.now(),startPoint:[...e.startPoint],radius:e.radius,circleColor:e.circleColor||"#eeee00",circleOpacity:e.circleOpacity||.5,mainTagColor:e.mainTagColor||"#c4c4c4",mainTagBackground:e.mainTagBackground||"#2E2E30",mainTagOpacity:e.mainTagOpacity||.8,mainTagVisible:e.mainTagVisible===void 0?!0:e.mainTagVisible,circleTagColor:e.circleTagColor||"#000000",circleTagBackground:e.circleTagBackground||"#e0ffff",circleTagOpacity:e.circleTagOpacity||.9,circleTagVisible:e.circleTagVisible===void 0?!0:e.circleTagVisible,title:e.title||"标记圆面"},a=new u.CircleGeometry(n.radius,128),o=new u.MeshBasicMaterial({color:n.circleColor,side:u.DoubleSide,transparent:!0});o.opacity=n.circleOpacity;const s=new u.Mesh(a,o);s.position.fromArray(n.startPoint),s.isMark=!0,s.renderOrder=1;const r=new u.Vector3(0,1,0).normalize();s.lookAt(s.position.clone().add(r));const c=n.name,f=document.createElement("div");f.innerHTML=`<div style='flex-direction: column;align-items: center;display: flex;pointer-events: none;margin-bottom: 40px;'>
|
|
722
|
+
<span class="${c}-main-tag" style="color:${n.mainTagColor};background:${n.mainTagBackground};opacity:${n.mainTagOpacity};padding:1px 5px 2px 5px;border-radius: 4px;margin-bottom: 5px;user-select: none;font-size: 12px;pointer-events: auto;">${n.title}</span>
|
|
723
|
+
</div>`,f.classList.add("mark-wrap-circle",`${n.name}`,"main-warp"),f.style.position="absolute",f.style.borderRadius="4px",f.style.cursor="pointer",f.onclick=()=>{if(t.events.fire(_).markMode)return;const m=parent?.onActiveMark;m?.(t.getMarkData(!0)),t.events.fire(j)},f.oncontextmenu=m=>m.preventDefault();const l=new u.Vector3().fromArray(n.startPoint),d=n.radius*t.events.fire(_).meterScale,p=(Math.PI*d*d).toFixed(2)+" m²",g=new te(f);g.position.copy(l),g.element.style.pointerEvents="none",g.scale.set(.01,.01,.01),g.visible=n.mainTagVisible;const h=document.createElement("div");h.innerHTML=`<span class="${c}-distance-tag ${c}-circle-tag" style="color:${n.circleTagColor};background:${n.circleTagBackground};opacity:${n.circleTagOpacity};padding: 1px 5px;border-radius: 4px;margin-bottom: 5px;user-select: none;font-size: 12px;pointer-events: none;">${p}</span>`,h.classList.add("mark-wrap-circle",`${c}`,"circle-warp"),h.style.position="absolute",h.style.borderRadius="4px",h.style.pointerEvents="none";const y=new te(h);y.position.set(l.x+Math.min(n.radius/2,.5),l.y,l.z),y.element.style.pointerEvents="none",y.scale.set(.008,.008,.008),y.visible=n.circleTagVisible,t.add(s,g,y),t.data=n,t.circleMesh=s,t.css3dTag=y,t.css3dMainTag=g,t.events.fire(ye,t)}getMarkData(e=!1){const t={...this.data};return e?(delete t.startPoint,delete t.radius):t.startPoint=[...t.startPoint],t}dispose(){if(this.disposed)return;const e=this;e.disposed=!0,e.events.fire(ve,e),e.events.fire(U).remove(e),e.events.fire(Pe,e),document.querySelectorAll(`.${e.data.name}`).forEach(n=>n.parentElement?.removeChild(n)),e.events=null,e.data=null,e.circleMesh=null,e.css3dTag=null,e.css3dMainTag=null}}let Co=class{constructor(){this.down=0,this.move=!1,this.downTime=0,this.isDbClick=!1,this.x=0,this.y=0,this.lastClickX=0,this.lastClickY=0,this.lastClickPointTime=0,this.lastMovePoint=null,this.lastMovePointTime=0}};function To(i){const e=(b,D,E)=>i.on(b,D,E),t=(b,...D)=>i.fire(b,...D),n=t(ke);let a=new Set,o,s=new Co,r;e(Hn,()=>{t(W).autoRotate=t(_).autoRotate=!0}),e(j,(b=!0)=>{t(W).autoRotate=t(_).autoRotate=!1,b&&t(yt)}),e(Qt,(b=!0)=>{if(o)return;const D=t(W),E=b?Math.PI/128:-(Math.PI/128),C=new u.Matrix4().makeRotationAxis(new u.Vector3(0,0,-1).transformDirection(D.object.matrixWorld),E);D.object.up.transformDirection(C),t(q)}),e(fi,()=>{o||i.fire(Qt,!0)}),e(pi,()=>{o||i.fire(Qt,!1)}),e(ht,b=>{const D=t(_);b??(b=!D.pointcloudMode),D.pointcloudMode=b,t(U).traverse(C=>C instanceof le&&C.fire(Ve,b))}),e(gt,()=>{t(U).traverse(D=>D instanceof le&&D.fire(Ht))}),e(He,b=>{t(U).traverse(E=>E instanceof le&&E.fire(He,b))}),e(Bi,()=>{const b=t(U);let D;b.traverse(E=>E instanceof le&&(D=E)),D&&t(Pt,D.fire(Ri))}),e(lt,()=>{if(!a.size)return;const b=t(_);if(!b.enableKeyboard)return a.clear();if(b.markMode&&a.has("Escape")){t(Ye),a.clear();return}a.has("Space")?(b.bigSceneMode?t(ht):t(gt),a.clear()):a.has("KeyR")?(b.autoRotate?t(j):t(Hn),a.clear()):a.has("KeyM")?(t(Ge,!b.markVisible),a.clear()):a.has("ArrowLeft")?(t(fi),t(ut,!0),a.clear()):a.has("ArrowRight")?(t(pi),t(ut,!0),a.clear()):a.has("KeyP")?(t(At,!0),a.clear()):a.has("Equal")?(t(Kt),a.clear()):a.has("Minus")?(t(Jt),a.clear()):a.has("KeyY")?(t(qt),a.clear()):a.has("KeyI")?(t(ki),a.clear()):a.has("KeyF")?(t(Bi),a.clear()):a.has("F2")&&(!b.bigSceneMode&&window.open("/editor/index.html?url="+encodeURIComponent(t(me).meta.url)),a.clear())}),e(We,async(b,D)=>{if(s.move)return;const E=await t(dt,b,D);E.length&&t(Pt,E[0],!0)}),e(oe,async(b,D)=>{const E=t(U),C=[];E.traverse(k=>k instanceof le&&C.push(k));const B=await t(dt,b,D);return B.length?(C.length&&C[0].fire(nt,B[0].x,B[0].y,B[0].z,!0),new u.Vector3(B[0].x,B[0].y,B[0].z)):(C.length&&C[0].fire(nt,0,0,0,!1),null)}),e(Nt,async()=>{const b=t(U),D=[];b.traverse(E=>E instanceof le&&D.push(E));for(let E=0;E<D.length;E++)D[E].fire(nt,0,0,0,!1)});const c=b=>{b.target.type!=="text"&&(o||b.code==="F5"||(b.preventDefault(),b.code!=="KeyR"&&(a.add(b.code),t(j)),r=Date.now()))},f=b=>{b.target.type!=="text"&&(o||(b.code==="KeyR"&&a.add(b.code),(b.code==="ArrowLeft"||b.code==="ArrowRight")&&t(Fn),r=Date.now()))};e(Ce,()=>{t(Gt)&&Date.now()-r>2e3&&(t(ut,!1),t(qt))},!0);const l=()=>{a.clear()},d=b=>{parent&&setTimeout(()=>window.focus()),b.preventDefault(),!o&&(t(j),r=Date.now())},p=b=>{b.preventDefault(),!o&&(t(j),r=Date.now())};let g,h,y,m;e(Ye,()=>{g?.dispose(),h?.dispose(),y?.dispose(),m?.dispose(),g=null,h=null,y=null,m=null,s.lastMovePoint=null,t(we)});const A=async b=>{parent&&setTimeout(()=>window.focus()),b.preventDefault(),!o&&(t(j),s.down=b.button===2?2:1,s.move=!1,s.isDbClick=Date.now()-s.downTime<300,r=Date.now(),s.downTime=Date.now())},M=async b=>{if(b.preventDefault(),o)return;s.down&&(s.move=!0,r=Date.now());const D=t(_);if(D.markMode){const E=await t(oe,b.clientX,b.clientY);E&&!s.down&&D.markType==="distance"&&g?g.drawUpdate({endPoint:E.toArray()}):!s.down&&D.markType==="circle"&&m?E?(m.drawUpdate(null,!0,E),s.lastMovePoint=E,s.lastMovePointTime=Date.now()):(s.lastMovePoint=null,s.lastMovePointTime=0):!s.down&&D.markType==="lines"&&h?E?(h.drawUpdate(null,!0,E),s.lastMovePoint=E,s.lastMovePointTime=Date.now()):(s.lastMovePoint=null,s.lastMovePointTime=0):!s.down&&D.markType==="plans"&&y&&(E?(y.drawUpdate(null,!0,E),s.lastMovePoint=E,s.lastMovePointTime=Date.now()):(s.lastMovePoint=null,s.lastMovePointTime=0))}},x=async b=>{if(b.preventDefault(),o)return;const D=t(_);if(s.isDbClick&&(h?Math.abs(b.clientX-s.lastClickX)<2&&Math.abs(b.clientY-s.lastClickY)<2&&(h.drawFinish(s.lastClickPointTime>0),h=null,s.lastMovePoint=null):y&&Math.abs(b.clientX-s.lastClickX)<2&&Math.abs(b.clientY-s.lastClickY)<2&&(y.drawFinish(s.lastClickPointTime>0),y=null,s.lastMovePoint=null)),D.markMode&&s.down===1&&!s.move&&Date.now()-s.downTime<500){if(D.markType==="point"){if(await t(oe,b.clientX,b.clientY)){const C=new bs(i,await t(oe,b.clientX,b.clientY));t(U).add(C),C.drawFinish()}}else if(D.markType==="distance")if(g){const E=await t(oe,b.clientX,b.clientY);E?(g.drawFinish(E),g=null):s.isDbClick&&t(Ye)}else{const E=await t(oe,b.clientX,b.clientY);E&&(g=new En(i),g.drawStart(E),t(U).add(g))}else if(D.markType==="lines")if(h)if(s.lastMovePoint&&t($t,b.clientX,b.clientY,s.lastMovePoint)<.03)h.drawUpdate(null,!0,s.lastMovePoint,!0),s.lastClickPointTime=Date.now();else{const E=await t(oe,b.clientX,b.clientY);E?(h.drawUpdate(null,!0,E,!0),s.lastClickPointTime=Date.now()):s.lastClickPointTime=0}else{const E=await t(oe,b.clientX,b.clientY);E&&(h=new kn(i),h.drawStart(E),t(U).add(h))}else if(D.markType==="plans")if(y)if(s.lastMovePoint&&t($t,b.clientX,b.clientY,s.lastMovePoint)<.03)y.drawUpdate(null,!0,s.lastMovePoint,!0),s.lastClickPointTime=Date.now();else{const E=await t(oe,b.clientX,b.clientY);E?(y.drawUpdate(null,!0,E,!0),s.lastClickPointTime=Date.now()):s.lastClickPointTime=0}else{const E=await t(oe,b.clientX,b.clientY);E&&(y=new _n(i),y.drawStart(E),t(U).add(y))}else if(D.markType==="circle")if(m){const E=await t(oe,b.clientX,b.clientY);E?(m.drawFinish(E),m=null):s.isDbClick&&t(Ye)}else{const E=await t(oe,b.clientX,b.clientY);E&&(m=new xs(i),m.drawStart(E),t(U).add(m))}s.lastClickX=b.clientX,s.lastClickY=b.clientY}s.down===2&&!s.move&&t(We,b.clientX,b.clientY),s.down=0,s.move=!1,r=Date.now()};function S(b){b.preventDefault(),!o&&(t(j),s.down=b.touches.length,s.down===1&&(s.move=!1,s.x=b.touches[0].clientX,s.y=b.touches[0].clientY))}function T(b){b.touches.length===1&&(s.move=!0)}function v(b){s.down===1&&!s.move&&t(We,s.x,s.y)}window.addEventListener("keydown",c),window.addEventListener("keyup",f),window.addEventListener("blur",l),window.addEventListener("wheel",d,{passive:!1}),n.addEventListener("contextmenu",p),n.addEventListener("mousedown",A),n.addEventListener("mousemove",M),n.addEventListener("mouseup",x),n.addEventListener("touchstart",S,{passive:!1}),n.addEventListener("touchmove",T,{passive:!1}),n.addEventListener("touchend",v,{passive:!1}),window.addEventListener("resize",I);function I(){const{width:b,height:D}=t(xe),E=t($);E.aspect=b/D,E.updateProjectionMatrix(),t(Yt).setSize(b,D);const B=t(Qe);B.setPixelRatio(Math.min(devicePixelRatio,2)),B.setSize(b,D)}e(Rt,()=>{o=!0,window.removeEventListener("keydown",c),window.removeEventListener("keyup",f),window.removeEventListener("blur",l),window.removeEventListener("wheel",d),n.removeEventListener("contextmenu",p),n.removeEventListener("mousedown",A),n.removeEventListener("mousemove",M),n.removeEventListener("mouseup",x),n.removeEventListener("touchstart",S),n.removeEventListener("touchmove",T),n.removeEventListener("touchend",v),window.removeEventListener("resize",I)})}function Ms(i){const e=new u.Raycaster,t=.02,n=(o,s,r)=>i.on(o,s,r),a=(o,...s)=>i.fire(o,...s);n(dt,async(o,s)=>{const{width:r,height:c,left:f,top:l}=a(xe),d=new u.Vector2;d.x=(o-f)/r*2-1,d.y=(l-s)/c*2+1;const p=a($);e.setFromCamera(d,p);const g=[],h=a(U),y=[],m=[];h.traverse(function(S){S instanceof le?m.push(S):S.isMesh&&!S.ignoreIntersect&&!S.isMark&&y.push(S)});const A=e.intersectObjects(y,!0);for(let S=0;S<A.length;S++)g.push(new u.Sphere(A[S].point,e.ray.distanceToPoint(A[S].point)));const M=p.projectionMatrix.clone().multiply(p.matrixWorldInverse);for(let S=0;S<m.length;S++){const T=m[S].fire(Wt);if(T)if(T.length!==void 0){const v=T,I=v.length/3;for(let b=0;b<I;b++){const D=new u.Vector3(v[3*b+0],v[3*b+1],v[3*b+2]),E=new u.Vector4(D.x,D.y,D.z,1).applyMatrix4(M),C=E.x/E.w,B=E.y/E.w;Math.sqrt((C-d.x)**2+(B-d.y)**2)<=t&&g.push(new u.Sphere(D,e.ray.distanceToPoint(D)))}}else for(let v of Object.keys(T)){const I=v.split(","),b=new u.Vector3(Number(I[0]),Number(I[1]),Number(I[2]));if(e.ray.distanceToPoint(b)<=1.4143){const D=T[v];for(let E=0,C=D.length/3;E<C;E++){const B=new u.Vector3(D[3*E+0],D[3*E+1],D[3*E+2]),k=new u.Vector4(B.x,B.y,B.z,1).applyMatrix4(M),P=k.x/k.w,F=k.y/k.w;Math.sqrt((P-d.x)**2+(F-d.y)**2)<=t&&g.push(new u.Sphere(B,e.ray.distanceToPoint(B)))}}}}g.sort((S,T)=>S.radius-T.radius);const x=[];for(let S=0;S<g.length;S++)x.push(g[S].center);return x}),n($t,(o,s,r)=>{const{width:c,height:f,left:l,top:d}=a(xe),p=new u.Vector2;p.x=(o-l)/c*2-1,p.y=(d-s)/f*2+1;const g=a($);return e.setFromCamera(p,g),e.ray.distanceToPoint(r)})}function Eo(i){const e=(r,c,f)=>i.on(r,c,f),t=(r,...c)=>i.fire(r,...c);e(Oe,()=>t($).fov),e(be,(r=!1)=>r?t($).position.clone():t($).position),e(Ae,(r=!1)=>r?t(W).target.clone():t(W).target),e(_e,(r=!1)=>r?t($).up.clone():t($).up),e(Pt,(r,c=!1)=>{if(t(gi,r),!c){t(W).target.copy(r),t(ft);return}const f=t(W).target.clone();let l=0;t(Fe,()=>{l+=.03,t(W).target.copy(f.clone().lerp(r,l)),t(ft)},()=>l<1)}),e(Ln,()=>{let r=t(be).toArray(),c=t(_e).toArray(),f=t(Ae).toArray();return{position:r,lookUp:c,lookAt:f}}),e(Un,()=>t(W).update()),e(Fn,()=>t(W).updateRotateAxis());const n=.01;let a=new u.Vector3,o=new u.Vector3,s=0;e(ni,()=>{const r=t(W).object,c=r.fov,f=r.position.clone(),l=r.getWorldDirection(new u.Vector3);return Math.abs(s-c)<n&&Math.abs(f.x-a.x)<n&&Math.abs(f.y-a.y)<n&&Math.abs(f.z-a.z)<n&&Math.abs(l.x-o.x)<n&&Math.abs(l.y-o.y)<n&&Math.abs(l.z-o.z)<n?!1:(s=c,a=f,o=l,!0)})}class ko extends u.Mesh{constructor(){super(...arguments),this.ignoreIntersect=!0}}function _o(i){let e=!1;const t=(r,c,f)=>i.on(r,c,f),n=(r,...c)=>i.fire(r,...c),a=[],o=new u.Vector3,s=new u.Matrix4;t(hi,()=>{const r=new u.SphereGeometry(.5,32,32),c=Io();c.depthTest=!1,c.depthWrite=!1,c.transparent=!0;const f=new ko;return f.copy(new u.Mesh(r,c)),t(Fs,()=>c),t(mi,l=>{e||(c.uniforms[vn].value=l,l<=.01?f.visible=!1:f.visible=!0,c.uniformsNeedUpdate=!0,n(q))}),t(gi,l=>{if(e)return;const d=n($);s.copy(d.matrixWorld).invert(),o.copy(l).applyMatrix4(s),o.normalize().multiplyScalar(10),o.applyMatrix4(d.matrixWorld);const{width:p,height:g}=n(xe);c.uniforms[Ze].value.set(p,g),f.position.copy(o),c.uniforms[ji].value.copy(l),c.uniforms[Ze].value.set(p,g),c.uniforms[vn].value=1,c.uniformsNeedUpdate=!0,n(Ai),n(q)}),t(Os,()=>{e||(e=!0,c.dispose(),r.dispose())}),f.renderOrder=99999,f}),t(Ai,()=>{for(;a.length;)a.pop().opacity=0;let r={opacity:1};a.push(r),n(kt,()=>{!e&&r.opacity>0&&(r.opacity<.2?r.opacity=0:r.opacity>.6?r.opacity=Math.max(r.opacity-=.01,0):r.opacity=Math.max(r.opacity-=.03,0),n(mi,r.opacity))},()=>!e&&r.opacity>0)})}function Io(){const i={[Ta]:{type:"v3",value:new u.Color},[ji]:{type:"v3",value:new u.Vector3},[Ze]:{type:"v2",value:new u.Vector2},[vn]:{value:0}};return new u.ShaderMaterial({uniforms:i,vertexShader:xa(),fragmentShader:Ma(),transparent:!0,depthTest:!1,depthWrite:!1,side:u.FrontSide})}function Cs(i){const e=(s,r,c)=>i.on(s,r,c),t=(s,...r)=>i.fire(s,...r),n=new Map,a=document.createElement("div");a.classList.add("mark-warp"),document.body.appendChild(a);const o=new Mo;o.setSize(innerWidth,innerHeight),o.domElement.style.position="absolute",o.domElement.style.top="0px",o.domElement.style.pointerEvents="none",a.appendChild(o.domElement),e(Hs,()=>a),e(Yt,()=>o),e(jt,()=>document.body.removeChild(a)),e(Ce,()=>o.render(t(U),t($)),!0),e(ye,s=>{const r=s?.getMarkData?.()?.name||s?.name;r&&n.set(r,new WeakRef(s))}),e(Pe,s=>{const r=s?.getMarkData?.()?.name||s?.name;n.delete(r)}),e(Ne,s=>n.get(s)?.deref()),e(Qs,(s,r)=>{const c=t(Ne,s);!c||!r||c.drawUpdate?.(r)}),e(Ws,s=>{const r=t(Ne,s);return r?r.getMarkData?.():{}}),e(Ge,s=>{s!==void 0&&(t(_).markVisible=s),t(U).traverse(r=>r.isMark&&(r.visible=t(_).markVisible)),t(q)}),e(qt,async()=>{const s=[];t(U).traverse(c=>{if(c.isMark){const f=c.getMarkData?.();f&&s.push(f)}});const r=t(me).meta||{};return s.length?r.marks=s:delete r.marks,r.cameraInfo=t(Ln),await t(Se,r)}),e(mt,async()=>{const s=[];t(U).traverse(c=>{if(c.isMark){const f=c.getMarkData?.();f&&s.push(f)}});const r=t(me).meta||{};return s.length?r.marks=s:delete r.marks,await t(Se,r)}),e(Si,async()=>{const s=t(me).meta||{};delete s.marks;const r=await t(Se,s),c=[];return n.forEach(f=>c.push(f)),c.forEach(f=>f.deref()?.dispose?.()),t(q),r}),e(bi,async()=>{t(U).traverse(r=>{r.isMark&&r.getMarkData?.()});const s=t(me).meta||{};return s.watermark=t(yi)||"",await t(Se,s)}),e(Xt,s=>{s.meterScale&&(t(_).meterScale=s.meterScale,t(ne,{scale:`1 : ${t(_).meterScale} m`})),t(W).updateByOptions({...s,...s.cameraInfo||{}}),(s.marks||[]).forEach(c=>{if(c.type==="MarkSinglePoint"){const f=new bs(i,c);f.visible=!1,t(U).add(f)}else if(c.type==="MarkDistanceLine"){const f=new En(i);f.draw(c),f.visible=!1,t(U).add(f)}else if(c.type==="MarkMultiLines"){const f=new kn(i);f.draw(c,!0),f.visible=!1,t(U).add(f)}else if(c.type==="MarkMultiPlans"){const f=new _n(i);f.draw(c,!0),f.visible=!1,t(U).add(f)}else if(c.type==="MarkCirclePlan"){const f=new xs(i);f.draw(c),f.visible=!1,t(U).add(f)}}),t(en,s.flyPositions||[]),t(tn,s.flyTargets||[])}),e(we,()=>{const s=t(_);s.markMode=!1,t(Nt),t(q)}),e(vi,(s,r=!0)=>{const c=s?.meterScale;if(c){if(typeof c!="number"||c<=0){console.warn("meterScale is not a number or <= 0",s);return}r&&(t(_).meterScale=s.meterScale),t(ne,{scale:`1 : ${c} m`});for(const f of n.values()){const l=f.deref();l&&(l instanceof En||l instanceof kn||l instanceof _n)&&l.updateByMeterScale(c)}}}),e(_t,s=>{const r=new u.Vector3().fromArray(s.slice(0,3)),c=new u.Vector3().fromArray(s.slice(-6,-3)),f=new u.Vector3().fromArray(s.slice(-3)),l=r.distanceTo(f)<1e-4,d=c.distanceTo(f)<1e-4,p=new u.Vector3,g=l||d?s.length/3-1:s.length/3;for(let h=0;h<g;h++)p.add(new u.Vector3(s[h*3],s[h*3+1],s[h*3+2]));return p.divideScalar(g),p}),e(It,s=>{const r=[];for(let d=0,p=s.length/3;d<p;d++)r.push(new u.Vector3(s[d*3],s[d*3+1],s[d*3+2]));const c=r[0].distanceTo(r[r.length-1])<1e-4,f=r[r.length-2].distanceTo(r[r.length-1])<1e-4;if((c||f)&&r.pop(),r.length<3)return 0;let l=0;for(let d=0,p=r.length-2;d<p;d++)l+=t(Dt,r[0],r[d+1],r[d+2],t(_).meterScale);return l}),e(Rn,(s,r)=>{let c=0;for(let f=0,l=s.length-2;f<l;f++)c+=t(Dt,s[0],s[f+1],s[f+2],r);return c}),e(Dt,(s,r,c,f)=>{const l=s.distanceTo(r)*f,d=r.distanceTo(c)*f,p=c.distanceTo(s)*f,g=(l+d+p)/2;return Math.sqrt(g*(g-l)*(g-d)*(g-p))})}function Do(i){const e=(p,...g)=>i.fire(p,...g),t=(p,g,h)=>i.on(p,g,h),n=[],a=[];let o=!1,s=!1;t(yt,()=>o=!1),t(Ei,()=>o=!0),t(Mi,()=>n),t($s,()=>{const p=[];for(let g=0,h=n.length;g<h;g++)p.push(...n[g].toArray());return p}),t(Ns,()=>{const p=[];for(let g=0,h=a.length;g<h;g++)p.push(...a[g].toArray());return p}),t(en,p=>{for(let g=0,h=p.length/3|0;g<h;g++)n[g]=new u.Vector3(p[g*3+0],p[g*3+1],p[g*3+2])}),t(tn,p=>{for(let g=0,h=p.length/3|0;g<h;g++)a[g]=new u.Vector3(p[g*3+0],p[g*3+1],p[g*3+2])}),t(Kt,()=>{const p=e(W);n.push(p.object.position.clone()),a.push(p.target.clone())}),t(Jt,()=>{n.length=0,a.length=0}),t(Ci,async()=>{const p=e(me).meta||{};if(n.length){const g=[],h=[];for(let y=0,m=n.length;y<m;y++)g.push(...n[y].toArray()),h.push(...a[y].toArray());p.flyPositions=g,p.flyTargets=h}else delete p.flyPositions,delete p.flyTargets;return await e(Se,p)}),t(Ti,()=>{s||(s=!0)&&e(At)});let r=0;const c=120*1e3;let f=0,l,d;t(At,p=>{if(r=0,f=Date.now(),l=null,d=null,!n.length||!p&&!e(W).autoRotate)return;const g=e(W),h=[g.object.position.clone()],y=[g.target.clone()],m=e(Mi)||[];for(let A=0,M=Math.min(m.length,100);A<M;A++)m[A]&&h.push(m[A]),a[A]&&y.push(a[A]);l=new u.CatmullRomCurve3(h),l.closed=!0,d=new u.CatmullRomCurve3(y),d.closed=!0,e(Ei),e(j,!1)}),t($e,()=>{if(Date.now()-f>c&&e(yt),!o||!l||!d)return;const p=e(W);r=(Date.now()-f)/c;const g=l.getPoint(r),h=d.getPoint(r);p.object.position.set(g.x,g.y,g.z),p.target.set(h.x,h.y,h.z)},!0)}class Po{constructor(e={}){this.disposed=!1,this.updateTime=0,this.needUpdate=!0,console.info("Reall3dViewer",wt),this.init(ls(e)),!e.disableDropLocalFile&&this.enableDropLocalFile()}init(e){const t=this;e.position=e.position?[...e.position]:[0,-5,15],e.lookAt=e.lookAt?[...e.lookAt]:[0,0,0],e.lookUp=e.lookUp?[...e.lookUp]:[0,-1,0];const n=Xa(e),a=e.scene=e.scene||new u.Scene;Za(e);const o=e.controls=new mo(e);o.updateByOptions(e);const s=new rn;e.viewerEvents=s,t.events=s;const r=(d,p,g)=>s.on(d,p,g),c=(d,...p)=>s.fire(d,...p);r(_,()=>e),r(ke,()=>n.domElement),r(Qe,()=>n),r(U,()=>a),r(W,()=>o),r($,()=>o.object),r(J,()=>e.bigSceneMode),r(Vs,d=>e.pointcloudMode=d);const f=[];r(q,()=>{for(t.needUpdate=!0;f.length;)f.pop().stop=!0;let d={count:0,stop:!1};f.push(d),c(kt,()=>{!t.disposed&&(t.needUpdate=!0),d.count++>=600&&(d.stop=!0)},()=>!t.disposed&&(c(Gt)||!d.stop),10)}),pn(s),ja(s),Sn(s),Eo(s),Cs(s),To(s),Ms(s),_o(s),Do(s),t.splatMesh=new le(Ka(e)),r(me,()=>t.splatMesh),a.add(t.splatMesh),to(s),a.add(new u.AmbientLight("#ffffff",2)),a.add(c(hi)),n.setAnimationLoop(t.update.bind(t)),r(wi,()=>{o.update(),!t.needUpdate&&c(ni)&&c(q)}),r(De,()=>c(lt),!0),r(De,()=>c(wi),!0),r(Ce,()=>{try{!(t.needUpdate=!1)&&n.render(a,c($))}catch(d){console.warn(d.message)}},!0),r($e,()=>{},!0),r(rt,()=>t.dispose()),r(ki,()=>console.info(JSON.stringify(c(me).meta||{},null,2)));let l="";r(pt,(d="")=>{l=d,t.splatMesh.fire(Zt,l,!0)}),r(yi,()=>l),c(ne,{scale:`1 : ${c(_).meterScale} m`}),t.initGsApi()}enableDropLocalFile(){const e=this;document.addEventListener("dragover",function(t){t.preventDefault(),t.stopPropagation()}),document.addEventListener("drop",async function(t){t.preventDefault(),t.stopPropagation();let n=t.dataTransfer.files[0];if(!n)return;let a;if(n.name.endsWith(".spx"))a="spx";else if(n.name.endsWith(".splat"))a="splat";else if(n.name.endsWith(".ply"))a="ply";else if(n.name.endsWith(".spz"))a="spz";else return console.error("unsupported format:",n.name);const o=URL.createObjectURL(n),s=e.events.fire(_);s.bigSceneMode=!1,s.pointcloudMode=!0,s.autoRotate=!0,s.debugMode=!0,e.reset(s),setTimeout(async()=>{await e.addModel({url:o,format:a}),URL.revokeObjectURL(o)})})}update(){const e=this;if(e.disposed)return;const t=(n,...a)=>e.events.fire(n,...a);Date.now()-e.updateTime>30&&(t(De),e.needUpdate&&t(Ce),t($e))}fire(e,t,n){const a=this;e===1&&a.splatMesh.fire(Ft,t),e===2&&a.events.fire(Kt),e===3&&a.events.fire(At,!0),e===4&&a.events.fire(Jt),e===5&&a.events.fire(Ci),e===6&&a.events.fire(mt),e===7&&a.events.fire(Si),e===8&&(async()=>{let o=await a.splatMesh.fire(nn);t&&(o=a.splatMesh.fire(Pi)+t),a.splatMesh.fire(Ot,o)})()}options(e){const t=this;if(t.disposed)return{};const n=(r,...c)=>t.events.fire(r,...c);let a;return n(U).traverse(r=>!a&&r instanceof le&&(a=r.options())),e&&(e.autoRotate!==void 0&&(n(W).autoRotate=e.autoRotate,n(_).autoRotate=e.autoRotate),e.pointcloudMode!==void 0&&n(ht,e.pointcloudMode),e.lightFactor!==void 0&&n(He,e.lightFactor),e.maxRenderCountOfMobile&&(n(_).maxRenderCountOfMobile=e.maxRenderCountOfMobile),e.maxRenderCountOfPc&&(n(_).maxRenderCountOfPc=e.maxRenderCountOfPc),e.debugMode!==void 0&&(n(_).debugMode=e.debugMode),e.markType!==void 0&&(n(_).markType=e.markType),e.markVisible!==void 0&&n(Ge,e.markVisible),e.meterScale!==void 0&&(n(_).meterScale=e.meterScale),e.markMode!==void 0&&(n(_).markMode=e.markMode,!e.markMode&&n(Nt),n(W).autoRotate=n(_).autoRotate=!1)),n(W).updateByOptions(e),n(ne,{scale:`1 : ${n(_).meterScale} m`}),Object.assign({...n(_)},a)}reset(e={}){const t=this;t.dispose(),t.disposed=!1,t.init(ls(e))}switchDeiplayMode(){const e=this;e.disposed||e.events.fire(gt)}async addScene(e){const t=this;if(t.disposed)return;const n=(s,...r)=>t.events.fire(s,...r);let a={};try{const s=await fetch(e,{mode:"cors",credentials:"omit",cache:"reload"});if(s.status===200)a=await s.json();else return console.error("scene file fetch failed, status:",s.status)}catch(s){return console.error("scene file fetch failed",s.message)}if(!a.url)return console.error("missing model file url");if(!a.url.endsWith(".bin")&&!a.url.endsWith(".spx"))return console.error("The format is unsupported in the large scene mode",a.url);const o={...a,...a.cameraInfo||{}};a.autoCut=Math.min(Math.max(a.autoCut||0,0),50),o.bigSceneMode=a.autoCut>1,t.reset({...o}),!o.bigSceneMode&&delete a.autoCut,t.splatMesh.meta=a,re&&(a.cameraInfo?.position||a.cameraInfo?.lookAt)&&t.events.fire(W)._dollyOut(.75),o.bigSceneMode?(n(en,a.flyPositions||[]),n(tn,a.flyTargets||[])):n(Xt,a),await t.splatMesh.addModel({url:a.url},a),await n(pt,a.watermark),n(W).updateRotateAxis()}async addModel(e){const t=this;if(t.disposed)return;const n=(c,...f)=>t.events.fire(c,...f);let a="",o={url:""};if(Object.prototype.toString.call(e)==="[object String]"?e.endsWith(".meta.json")?a=e:o.url=e:o=e,!o.url&&!a)return console.error("model url is empty");const s=n(_);s.bigSceneMode=!1;let r={};if(!o.url.startsWith("blob:"))try{a=a||o.url.substring(0,o.url.lastIndexOf("."))+".meta.json";const c=await fetch(a,{mode:"cors",credentials:"omit",cache:"reload"});c.status===200?r=await c.json():console.warn("meta file fetch failed, status:",c.status)}catch(c){console.warn("meta file fetch failed",c.message,o.url)}if(r.showWatermark=r.showWatermark!==!1,r.url=r.url||o.url,delete r.autoCut,!o.format)if(o.url=o.url||r.url,o.url.endsWith(".spx"))o.format="spx";else if(o.url.endsWith(".splat"))o.format="splat";else if(o.url.endsWith(".ply"))o.format="ply";else if(o.url.endsWith(".spz"))o.format="spz";else{console.error("unknow format!",o.url);return}n(Xt,r),await t.splatMesh.addModel(o,r),await n(pt,r.watermark)}initGsApi(){const e=(l,...d)=>this.events.fire(l,...d),t=()=>{setTimeout(()=>window.focus()),e(yt),e(W).autoRotate=e(_).autoRotate=!e(_).autoRotate},n=(l=!0)=>{setTimeout(()=>window.focus()),l=!!l;const d=e(_);d.pointcloudMode!==l&&(d.bigSceneMode?e(ht,l):e(gt))},a=(l=!0)=>{setTimeout(()=>window.focus()),e(Ge,!!l)},o=l=>{setTimeout(()=>window.focus());const d=e(_);if(d.markMode)return!1;if(l===1)d.markType="point";else if(l===2)d.markType="lines";else if(l===3)d.markType="plans";else if(l===4)d.markType="distance";else return!1;return d.markMode=!0,e(j),!0},s=async l=>(setTimeout(()=>window.focus()),l?(e(Ne,l)?.dispose(),e(q),await e(mt)):!1),r=async(l,d=!0)=>(e(vi,l,d),e(Ne,l?.name)?.drawUpdate?.(l,d),e(q),d?(setTimeout(()=>window.focus()),await e(mt)):!0),c=(l=!0)=>{setTimeout(()=>window.focus()),e(Ft,!!l)},f=(l,d=!0)=>{e(pt,l),d&&e(bi,l)};window.$api={switchAutoRotate:t,changePointCloudMode:n,showMark:a,startMark:o,deleteMark:s,updateMark:r,showWaterMark:c,setWaterMark:f}}dispose(){const e=this;if(e.disposed)return;e.disposed=!0;const t=(a,...o)=>e.events.fire(a,...o);t(zt),t(ti),t(jt),t(Rt),t(W).dispose(),t(ve,t(U));const n=t(Qe);n.clear(),n.dispose(),e.splatMesh=null,e.events.clear(),e.events=null}}function Ro(i){const e=(s,r,c)=>i.on(s,r,c),t=(s,...r)=>i.fire(s,...r),n=re?1:20,a=new Map,o=new Map;e(it,()=>t(ae)&&a.set(Date.now(),1)),e(st,()=>t(ae)&&t(Ie,a)),e(at,()=>t(ae)&&o.set(Date.now(),1)),e(ot,()=>t(ae)&&t(Ie,o)),e(Ie,s=>{let r=[],c=Date.now(),f=0;for(const l of s.keys())c-l<=1e3?f++:r.push(l);return r.forEach(l=>s.delete(l)),Math.min(f,30)}),e(G,()=>{const s=t(U),r=t($),c=[];return s?.traverse(function(f){f.isWarpSplatMesh&&f.splatMesh?.visible&&c.push(f)}),c.sort((f,l)=>r.position.distanceTo(f.position)-r.position.distanceTo(l.position)),window.splat=c[0]?.splatMesh,c[0]?.splatMesh}),e(Vi,()=>{const s=t(U),r=t($),c=[];s?.traverse(function(f){f.isWarpSplatMesh&&c.push(f)}),c.sort((f,l)=>r.position.distanceTo(f.position)-r.position.distanceTo(l.position));for(let f=0;f<c.length;f++)c[f].active=f<n,c[f].splatMesh&&(c[f].splatMesh.renderOrder=1e3-f)}),e(Hi,()=>{const s=t(U),r=[];s?.traverse(c=>r.push(c)),r.forEach(c=>{c.dispose?c.dispose():(c.geometry?.dispose?.(),c.material&&c.material instanceof Array?c.material.forEach(f=>f?.dispose?.()):c.material?.dispose?.())}),s?.clear()}),e(sn,(s=.1)=>{const r=t(G);r&&r.visible&&r.rotateOnAxis(new u.Vector3(1,0,0),u.MathUtils.degToRad(s))}),e(an,(s=.1)=>{const r=t(G);r&&r.visible&&r.rotateOnAxis(new u.Vector3(0,1,0),u.MathUtils.degToRad(s))}),e(on,(s=.1)=>{const r=t(G);r&&r.visible&&r.rotateOnAxis(new u.Vector3(0,0,1),u.MathUtils.degToRad(s))}),e(Ys,(s=.01)=>{const r=t(G);r&&r.visible&&(r.position.x+=s)}),e(zi,(s=.01)=>{const r=t(G);r&&r.visible&&(r.position.y+=s)}),e(js,(s=.01)=>{const r=t(G);r&&r.visible&&(r.position.z+=s)}),e(qs,s=>{const r=t(G);r&&r.visible&&s&&r.position.copy(s),console.info(r,s)}),e(Xs,(s=.01)=>{const r=t(G);r&&r.visible&&r.scale.set(r.scale.x+s,r.scale.y+s,r.scale.z+s)}),e(Zs,()=>{const s=t(G);s&&(s.visible=!s.visible)}),e(Ks,async s=>{if(!s&&(s=t(G)),!s)return;const r=s.meta||{};return r.transform=s.matrix.toArray(),await t(Se,JSON.stringify(r),s.meta.url)}),e(Li,()=>{const s=t(_).root,r=new u.WebGLRenderer({antialias:!1,logarithmicDepthBuffer:!0,stencil:!0,alpha:!0,precision:"highp"});return r.setSize(s.clientWidth,s.clientHeight),r.setPixelRatio(Math.min(devicePixelRatio,2)),e(Qe,()=>r),e(ke,()=>r.domElement),r}),e(Ui,()=>{const s=new u.Scene,r=14414079;return s.background=new u.Color(r),s.fog=new u.FogExp2(r,0),e(U,()=>s),s}),e(Fi,()=>{const r=t($),c=t(U),f=t(_),l=new Ao(t($),f.root);return l.screenSpacePanning=!1,l.minDistance=.1,l.maxDistance=1e5,l.maxPolarAngle=1.2,l.enableDamping=!0,l.dampingFactor=.07,l.zoomToCursor=!0,l.minAzimuthAngle=0,l.maxAzimuthAngle=0,l.addEventListener("change",()=>{const d=Math.max(l.getPolarAngle(),.1),p=Math.max(l.getDistance(),.1);l.zoomSpeed=Math.max(Math.log(p),0)+.5,r.far=u.MathUtils.clamp(p/d*8,100,2e5),r.near=r.far/1e3,r.updateProjectionMatrix(),c.fog instanceof u.FogExp2&&(c.fog.density=d/(p+5)*1*.25),l.maxPolarAngle=Math.min(Math.pow(1e4/p,4),1.2)}),e(W,()=>l),e(Oe,()=>r.fov),e(be,(d=!1)=>d?r.position.clone():r.position),e(Ae,(d=!1)=>d?l.target.clone():l.target),e(_e,(d=!1)=>d?r.up.clone():r.up),l}),e(Oi,()=>{const s=new u.DirectionalLight(16777215,1);return s.position.set(0,2e3,1e3),s}),window.addEventListener("beforeunload",()=>t(rt))}function Bo(i){let{root:e="#map",debugMode:t}=i;return e?e=typeof e=="string"?document.querySelector(e)||document.querySelector("#map"):e:e=document.querySelector("#map"),e||(e=document.createElement("div"),e.id="map",document.querySelector("#gsviewer").appendChild(e)),{root:e,debugMode:t}}function Lo(){const i="7f8f4f56f3ccda758f9a497e2b981018",e=new et.plugin.TDTSource({token:i,style:"img_w"}),t=new et.plugin.TDTSource({token:i,style:"cia_w"}),n=location.host.includes("reall3d.com")?[e,t]:new et.plugin.BingSource,a=new et.TileMap({imgSource:n,lon0:90,minLevel:2,maxLevel:16});return a.scale.set(10,10,10),a.rotateX(-Math.PI/2),a.autoUpdate=!1,a}class Uo{constructor(){this.down=0,this.move=!1,this.downTime=0,this.isDbClick=!1,this.x=0,this.y=0,this.lastClickX=0,this.lastClickY=0,this.lastClickPointTime=0,this.lastMovePoint=null,this.lastMovePointTime=0}}function Fo(i){const e=(v,I,b)=>i.on(v,I,b),t=(v,...I)=>i.fire(v,...I),n=t(ke);let a=new Set,o,s=new Uo;e(lt,()=>{if(a.size)if(a.has("KeyH")){const v=t(G);v&&(v.visible=!v.visible),a.clear()}else if(a.has("Equal")){const v=t(G);if(!v||!v.visible)return a.clear();if(a.has("KeyX")){const I=u.MathUtils.degToRad(.1);v.rotateOnAxis(new u.Vector3(1,0,0),I)}else v.scale.set(v.scale.x+.01,v.scale.y+.01,v.scale.z+.01)}else if(a.has("Minus")){const v=t(G);if(!v||!v.visible)return a.clear();if(a.has("KeyX")){const I=u.MathUtils.degToRad(-.1);v.rotateOnAxis(new u.Vector3(1,0,0),I)}else v.scale.set(v.scale.x-.01,v.scale.y-.01,v.scale.z-.01)}else if(a.has("ArrowUp")){const v=t(G);v&&v.visible&&(v.position.z+=.1)}else if(a.has("ArrowDown")){const v=t(G);v&&v.visible&&(v.position.z-=.1)}else if(a.has("ArrowRight")){const v=t(G);v&&v.visible&&(v.position.x+=.1)}else if(a.has("ArrowLeft")){const v=t(G);v&&v.visible&&(v.position.x-=.1)}else if(a.has("KeyU")){const v=t(G);if(v){const I=v.meta||{};I.transform=v.matrix.toArray()}}else a.has("KeyQ")?t(sn,.1):a.has("KeyW")?t(an,.1):a.has("KeyE")?t(on,.1):a.has("KeyA")?t(sn,-.1):a.has("KeyS")?t(an,-.1):a.has("KeyD")?t(on,-.1):a.has("KeyY")?t(zi,a.has("ShiftLeft")||a.has("ShiftRight")?-.1:.1):a.has("KeyC")&&console.info("position=",t(be).toArray(),"lookat=",t(Ae).toArray())});const r=v=>{console.info(v.code),v.target.type!=="text"&&(o||v.code==="F5"||(v.preventDefault(),a.add(v.code)))},c=v=>{v.target.type!=="text"&&(o||a.clear())},f=()=>{a.clear()},l=v=>{parent&&setTimeout(()=>window.focus()),v.preventDefault()},d=async v=>{v.preventDefault()};let p,g,h,y;e(Ye,()=>{p?.dispose(),g?.dispose(),h?.dispose(),y?.dispose(),p=null,g=null,h=null,y=null,s.lastMovePoint=null,t(we)});const m=async v=>{parent&&setTimeout(()=>window.focus()),v.preventDefault(),!o&&(s.down=v.button===2?2:1,s.move=!1,s.isDbClick=Date.now()-s.downTime<300,s.downTime=Date.now())},A=async v=>{v.preventDefault(),!o&&s.down&&(s.move=!0)},M=async v=>{v.preventDefault(),!o&&(s.down=0,s.move=!1)};function x(v){v.preventDefault(),!o&&(s.down=v.touches.length,s.down===1&&(s.move=!1,s.x=v.touches[0].clientX,s.y=v.touches[0].clientY))}function S(v){v.touches.length===1&&(s.move=!0)}function T(v){s.down===1&&!s.move&&t(We,s.x,s.y)}window.addEventListener("keydown",r),window.addEventListener("keyup",c),window.addEventListener("blur",f),window.addEventListener("wheel",l,{passive:!1}),n.addEventListener("contextmenu",d),n.addEventListener("mousedown",m),n.addEventListener("mousemove",A),n.addEventListener("mouseup",M),n.addEventListener("touchstart",x,{passive:!1}),n.addEventListener("touchmove",S,{passive:!1}),n.addEventListener("touchend",T,{passive:!1}),e(Rt,()=>{o=!0,window.removeEventListener("keydown",r),window.removeEventListener("keyup",c),window.removeEventListener("blur",f),window.removeEventListener("wheel",l),n.removeEventListener("contextmenu",d),n.removeEventListener("mousedown",m),n.removeEventListener("mousemove",A),n.removeEventListener("mouseup",M),n.removeEventListener("touchstart",x),n.removeEventListener("touchmove",S),n.removeEventListener("touchend",T)}),e(We,async(v,I)=>await t(dt,v,I))}var Ue=Object.freeze({Linear:Object.freeze({None:function(i){return i},In:function(i){return i},Out:function(i){return i},InOut:function(i){return i}}),Quadratic:Object.freeze({In:function(i){return i*i},Out:function(i){return i*(2-i)},InOut:function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)}}),Cubic:Object.freeze({In:function(i){return i*i*i},Out:function(i){return--i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)}}),Quartic:Object.freeze({In:function(i){return i*i*i*i},Out:function(i){return 1- --i*i*i*i},InOut:function(i){return(i*=2)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2)}}),Quintic:Object.freeze({In:function(i){return i*i*i*i*i},Out:function(i){return--i*i*i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2)}}),Sinusoidal:Object.freeze({In:function(i){return 1-Math.sin((1-i)*Math.PI/2)},Out:function(i){return Math.sin(i*Math.PI/2)},InOut:function(i){return .5*(1-Math.sin(Math.PI*(.5-i)))}}),Exponential:Object.freeze({In:function(i){return i===0?0:Math.pow(1024,i-1)},Out:function(i){return i===1?1:1-Math.pow(2,-10*i)},InOut:function(i){return i===0?0:i===1?1:(i*=2)<1?.5*Math.pow(1024,i-1):.5*(-Math.pow(2,-10*(i-1))+2)}}),Circular:Object.freeze({In:function(i){return 1-Math.sqrt(1-i*i)},Out:function(i){return Math.sqrt(1- --i*i)},InOut:function(i){return(i*=2)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1)}}),Elastic:Object.freeze({In:function(i){return i===0?0:i===1?1:-Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI)},Out:function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin((i-.1)*5*Math.PI)+1},InOut:function(i){return i===0?0:i===1?1:(i*=2,i<1?-.5*Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI):.5*Math.pow(2,-10*(i-1))*Math.sin((i-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(i){var e=1.70158;return i===1?1:i*i*((e+1)*i-e)},Out:function(i){var e=1.70158;return i===0?0:--i*i*((e+1)*i+e)+1},InOut:function(i){var e=2.5949095;return(i*=2)<1?.5*(i*i*((e+1)*i-e)):.5*((i-=2)*i*((e+1)*i+e)+2)}}),Bounce:Object.freeze({In:function(i){return 1-Ue.Bounce.Out(1-i)},Out:function(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},InOut:function(i){return i<.5?Ue.Bounce.In(i*2)*.5:Ue.Bounce.Out(i*2-1)*.5+.5}}),generatePow:function(i){return i===void 0&&(i=4),i=i<Number.EPSILON?Number.EPSILON:i,i=i>1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),Je=function(){return performance.now()},Oo=function(){function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,e)}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var a=0,o=t;a<o.length;a++){var s=o[a];(e=s._group)===null||e===void 0||e.remove(s),s._group=this,this._tweens[s.getId()]=s,this._tweensAddedDuringUpdate[s.getId()]=s}},i.prototype.remove=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=0,a=e;n<a.length;n++){var o=a[n];o._group=void 0,delete this._tweens[o.getId()],delete this._tweensAddedDuringUpdate[o.getId()]}},i.prototype.allStopped=function(){return this.getAll().every(function(e){return!e.isPlaying()})},i.prototype.update=function(e,t){e===void 0&&(e=Je()),t===void 0&&(t=!0);var n=Object.keys(this._tweens);if(n.length!==0)for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var a=0;a<n.length;a++){var o=this._tweens[n[a]],s=!t;o&&o.update(e,s)===!1&&!t&&this.remove(o)}n=Object.keys(this._tweensAddedDuringUpdate)}},i}(),In={Linear:function(i,e){var t=i.length-1,n=t*e,a=Math.floor(n),o=In.Utils.Linear;return e<0?o(i[0],i[1],n):e>1?o(i[t],i[t-1],t-n):o(i[a],i[a+1>t?t:a+1],n-a)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},Ts=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),Dn=new Oo,zo=function(){function i(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Ue.Linear.None,this._interpolationFunction=In.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Ts.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof t=="object"?(this._group=t,t.add(this)):t===!0&&(this._group=Dn,Dn.add(this))}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=Je()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var a={};for(var o in this._valuesEnd)a[o]=this._valuesEnd[o];this._valuesEnd=a}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,a,o){for(var s in n){var r=e[s],c=Array.isArray(r),f=c?"array":typeof r,l=!c&&Array.isArray(n[s]);if(!(f==="undefined"||f==="function")){if(l){var d=n[s];if(d.length===0)continue;for(var p=[r],g=0,h=d.length;g<h;g+=1){var y=this._handleRelativeValue(r,d[g]);if(isNaN(y)){l=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(y)}l&&(n[s]=p)}if((f==="object"||c)&&r&&!l){t[s]=c?[]:{};var m=r;for(var A in m)t[s][A]=m[A];a[s]=c?[]:{};var d=n[s];if(!this._isDynamic){var M={};for(var A in d)M[A]=d[A];n[s]=d=M}this._setupProperties(m,t[s],d,a[s],o)}else(typeof t[s]>"u"||o)&&(t[s]=r),c||(t[s]*=1),l?a[s]=n[s].slice().reverse():a[s]=t[s]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},i.prototype.pause=function(e){return e===void 0&&(e=Je()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},i.prototype.resume=function(e){return e===void 0&&(e=Je()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},i.prototype.group=function(e){return e?(e.add(this),this):(console.warn("tween.group() without args has been removed, use group.add(tween) instead."),this)},i.prototype.remove=function(){var e;return(e=this._group)===null||e===void 0||e.remove(this),this},i.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},i.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},i.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},i.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},i.prototype.easing=function(e){return e===void 0&&(e=Ue.Linear.None),this._easingFunction=e,this},i.prototype.interpolation=function(e){return e===void 0&&(e=In.Linear),this._interpolationFunction=e,this},i.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},i.prototype.onStart=function(e){return this._onStartCallback=e,this},i.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},i.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},i.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},i.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},i.prototype.onStop=function(e){return this._onStopCallback=e,this},i.prototype.update=function(e,t){var n=this,a;if(e===void 0&&(e=Je()),t===void 0&&(t=i.autoStartOnUpdate),this._isPaused)return!0;var o;if(!this._goToEnd&&!this._isPlaying)if(t)this.start(e,!0);else return!1;if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var s=e-this._startTime,r=this._duration+((a=this._repeatDelayTime)!==null&&a!==void 0?a:this._delayTime),c=this._duration+this._repeat*r,f=function(){if(n._duration===0||s>c)return 1;var y=Math.trunc(s/r),m=s-y*r,A=Math.min(m/n._duration,1);return A===0&&s===n._duration?1:A},l=f(),d=this._easingFunction(l);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,d),this._onUpdateCallback&&this._onUpdateCallback(this._object,l),this._duration===0||s>=this._duration)if(this._repeat>0){var p=Math.min(Math.trunc((s-this._duration)/r)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=p);for(o in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[o]=="string"&&(this._valuesStartRepeat[o]=this._valuesStartRepeat[o]+parseFloat(this._valuesEnd[o])),this._yoyo&&this._swapEndStartRepeatValues(o),this._valuesStart[o]=this._valuesStartRepeat[o];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=r*p,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,h=this._chainedTweens.length;g<h;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},i.prototype._updateProperties=function(e,t,n,a){for(var o in n)if(t[o]!==void 0){var s=t[o]||0,r=n[o],c=Array.isArray(e[o]),f=Array.isArray(r),l=!c&&f;l?e[o]=this._interpolationFunction(r,a):typeof r=="object"&&r?this._updateProperties(e[o],s,r,a):(r=this._handleRelativeValue(s,r),typeof r=="number"&&(e[o]=s+(r-s)*a))}},i.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},i.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},i.autoStartOnUpdate=!1,i}();Ts.nextId;var he=Dn;he.getAll.bind(he),he.removeAll.bind(he),he.add.bind(he),he.remove.bind(he),he.update.bind(he);const Es=navigator.userAgent.includes("Mobi");class Vo extends u.Mesh{constructor(e,t){super(),this.isWarpSplatMesh=!0,this.lastActiveTime=Date.now(),this.active=!1,this.disposed=!1,this.mapViewer=t,this.addScene(e),this.frustumCulled=!1}async addScene(e){const t=this,{renderer:n,scene:a,controls:o,tileMap:s}=t.mapViewer;fetch(e,{mode:"cors",credentials:"omit",cache:"reload"}).then(r=>r.ok?r.json():{}).then(r=>{const c=new u.Matrix4;if(r.transform)c.fromArray(r.transform);else if(r.WGS84){const h=s.geo2world(new u.Vector3().fromArray(r.WGS84));c.makeTranslation(h.x,h.y,h.z)}r.autoCut&&(r.autoCut=Math.min(Math.max(r.autoCut,1),50));const f=r.autoCut&&r.autoCut>1,l=!1,d=!1,p=r.showWatermark!==!1,g={renderer:n,scene:a,controls:o,pointcloudMode:l,bigSceneMode:f,matrix:c,showWatermark:p,depthTest:d};g.maxRenderCountOfMobile??(g.maxRenderCountOfMobile=g.bigSceneMode?128*10240:400*1e4),g.maxRenderCountOfPc??(g.maxRenderCountOfPc=g.bigSceneMode?320*1e4:400*1e4),g.debugMode=this.mapViewer.events.fire(_).debugMode,t.opts=g,t.meta=r,a.add(t),t.initCSS3DSprite(g),t.applyMatrix4(c)}).catch(r=>{console.error(r.message)})}async initCSS3DSprite(e){const t=this,n=document.createElement("div");n.innerHTML=`<div title="${t.meta.name}" style='flex-direction: column;align-items: center;display: flex;pointer-events: auto;margin-bottom: 20px;'>
|
|
724
|
+
<svg height="20" width="20" style="color:#eeee00;opacity:0.9;"><use href="#svgicon-point3" fill="currentColor" /></svg>
|
|
725
|
+
</div>`,n.classList.add("splatmesh-point"),n.style.position="absolute",n.style.borderRadius="4px",n.style.cursor="pointer";let a=null;n.onclick=()=>{if(a)return;const s=t.position,r=e.controls,c=r.object.position.clone(),f=Es?6:2,l=s.clone().sub(c).normalize(),d=s.clone().sub(l.multiplyScalar(f)),p={x:c.x,y:c.y,z:c.z,tx:r.target.x,ty:r.target.y,tz:r.target.z},g={x:d.x,y:d.y,z:d.z,tx:s.x,ty:s.y,tz:s.z};a=new zo(p).to(g,3e3),a.easing(Ue.Sinusoidal.InOut).start().onUpdate(()=>{const h=p.y<.1?.1:p.y;r.object.position.set(p.x,h,p.z),r.target.set(p.tx,p.ty,p.tz)}).onComplete(()=>{a=null})},n.oncontextmenu=s=>s.preventDefault();const o=new te(n);o.element.style.pointerEvents="none",o.visible=!1,o.applyMatrix4(e.matrix),t.css3dTag=o,e.scene.add(o),t.onBeforeRender=()=>{a?.update();const s=Es?50:30,r=t.position.distanceTo(t.mapViewer.controls.object.position);if(r>s){t.css3dTag.visible=t.opts.controls.object.position.y>2;let c=.002*r;o.scale.set(c,c,c),t.css3dTag.visible=!0,t.splatMesh&&(t.splatMesh.visible=!1)}else{if(!t.active){t.splatMesh&&(t.splatMesh.visible=!1);let c=.002*r;o.scale.set(c,c,c),t.css3dTag.visible=!0;return}if(t.lastActiveTime=Date.now(),t.css3dTag.visible=!1,t.splatMesh)t.splatMesh.visible=!0;else{const c=t.meta,f={...t.opts};c.autoCut&&(f.bigSceneMode=!0);const l=new le(f);t.splatMesh=l,t.opts.scene.add(l),l.applyMatrix4(t.opts.matrix),l.meta=c;const d=c.watermark||c.name||"";c.showWatermark=c.showWatermark!==!1,l.fire(Zt,d,!0,!1),l.addModel({url:t.meta.url},t.meta)}}},t.onAfterRender=()=>{t.splatMesh&&(!t.active||Date.now()-t.lastActiveTime>1*60*1e3)&&setTimeout(()=>{t.splatMesh?.dispose(),t.splatMesh=null},5)}}dispose(){const e=this;e.disposed||(e.disposed=!0,e.opts.scene.remove(e.css3dTag),e.splatMesh?.dispose(),e.meta=null,e.splatMesh=null,e.opts=null,e.css3dTag=null,e.mapViewer=null)}}class Ho extends u.EventDispatcher{constructor(e={}){console.info("Reall3dMapViewer",wt),super(),this.clock=new u.Clock,this.updateTime=0,this.disposed=!1;const t=this,n=new rn;t.events=n;const a=(r,c,f)=>n.on(r,c,f),o=(r,...c)=>n.fire(r,...c);t.tileMap=Lo();const s=Bo(e);a(_,()=>s),pn(n),Sn(n),Ro(n),Ms(n),Cs(n),t.camera=new u.PerspectiveCamera(60,1,.01,1e4),a($,()=>t.camera),t.container=s.root,t.renderer=o(Li),t.scene=o(Ui),t.controls=o(Fi),t.ambLight=new u.AmbientLight(16777215,1),t.scene.add(t.ambLight),t.dirLight=o(Oi),t.scene.add(t.dirLight),t.scene.add(t.tileMap),t.container.appendChild(t.renderer.domElement),window.addEventListener("resize",t.resize.bind(t)),t.resize(),t.renderer.setAnimationLoop(t.animate.bind(t)),Fo(n),a(rt,()=>t.dispose()),a(De,()=>{o(at),t.controls.update(),o(Vi),o(lt)},!0),a($e,()=>{t.dispatchEvent({type:"update",delta:t.clock.getDelta()}),t.updateTime=Date.now(),o(ae)&&o(ne,{fps:o(st),realFps:o(ot),fov:o(Oe),position:o(Me,o(be)),lookAt:o(Me,o(Ae)),lookUp:o(Me,o(_e))})},!0),a(Ce,()=>{t.tileMap.update(t.camera);try{t.renderer.render(t.scene,t.camera)}catch(r){console.warn(r.message)}},!0)}addScenes(e){const t=this;fetch(e,{mode:"cors",credentials:"omit",cache:"reload"}).then(n=>n.ok?n.json():{}).then(n=>{const a=new u.Vector3().fromArray(n.position||[17e3,3e4,-35e3]),o=new u.Vector3().fromArray(n.lookAt||[17e3,0,-35e3]);t.controls.object.position.copy(a),t.controls.target.copy(o),t.dirLight.target.position.copy(o);const s=new Set;for(let r of n.scenes)s.has(r)||(new Vo(r,t),s.add(r))}).catch(n=>{console.error(n.message)})}resize(){const e=this;if(e.disposed)return;const t=e.container.clientWidth,n=e.container.clientHeight;e.renderer.setPixelRatio(Math.min(devicePixelRatio,2)),e.renderer.setSize(t,n),e.camera.aspect=t/n,e.camera.updateProjectionMatrix(),e.events.fire(Yt).setSize(t,n)}animate(){const e=this,t=(n,...a)=>e.events.fire(n,...a);t(it),Date.now()-e.updateTime>30&&(t(De),t(Ce),t($e))}dispose(){const e=this;if(e.disposed)return;e.disposed=!0;const t=e.renderer.domElement;e.events.fire(jt),e.events.fire(Hi),e.renderer.clear(),e.renderer.dispose(),e.events.clear(),e.scene=null,e.renderer=null,e.camera=null,e.controls=null,e.ambLight=null,e.dirLight=null,e.container.removeChild(t),e.container.classList.add("hidden"),e.container=null,e.clock=null,e.events=null,e.tileMap=null}}ge.Reall3dMapViewer=Ho,ge.Reall3dViewer=Po,Object.defineProperty(ge,Symbol.toStringTag,{value:"Module"})});
|