/** * @license * Copyright thing.js www.vaps.cc */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("core-js/es/array/includes")):"function"==typeof define&&define.amd?define(["exports","core-js/es/array/includes"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).THING={})}(this,(function(t){"use strict";function e(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}const i=navigator.userAgent.toLowerCase(),r=function(t){return t.test(window.navigator?i:"")},n=r(/msie/),s=r(/applewebkit.*chrome*./),o=r(/msie/)||r(/trident/),a=r(/msie 10/),l=r(/edge/),h=r(/firefox/),c=r(/mac/),d=!!window.navigator&&window.navigator.platform.indexOf("Win")>-1,u="ontouchstart"in document.documentElement||!d&&(!!document&&"ontouchend"in document),p=-1!=i.indexOf("mobile")||-1!=i.indexOf("android"),m=/(Android)\s+([\d.]+)/i.test(i),f=/\(i[^;]+;( U;)? cpu.+mac os x/i.test(i),g=/(iPhone|iPad|iPod|iOS|Mac OS X)/i.test(i),v=/(iPhone\sOS)\s([\d_]+)/i.test(i),y=/(iPad).*OS\s([\d_]+)/i.test(i),w=/QQ\/([\d.]+)/i.test(i),x=/wxwork\/.* MicroMessenger/i.test(i),b=/micromessenger/i.test(i)&&!x,_=/WeiBo/i.test(i),A="miniprogram"===window.__wxjs_environment;/AlipayClient/i.test(i);const S=h?"DOMMouseScroll":"mousewheel",T=u?["touchstart","touchmove","touchend","keydown","keyup","keypress","input","contextmenu","compositionstart","compositionupdate","compositionend"]:["keydown","keyup","keypress","input","mousedown","mousemove","mouseup","mouseout",S,"wheel","contextmenu","mouseenter","mouseleave","mouseover","compositionstart","compositionupdate","compositionend"];let E=!1;try{const t=Object.defineProperty({},"passive",{get:function(){E=!0}});window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(Yr){E=!1}const P=E,M=!!E&&{passive:!1,capture:!1},C=!E||{passive:!1,capture:!0};function L(){try{let t=new Array;if(null!=window.screen.deviceXDPI)t[0]=window.screen.deviceXDPI,t[1]=window.screen.deviceYDPI;else{let e=document.createElement("DIV");e.style.cssText="width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden",document.body.appendChild(e),t[0]=parseInt(e.offsetWidth),t[1]=parseInt(e.offsetHeight),e.parentNode.removeChild(e)}return t[0]||96}catch{}return 96}const R=L();var O=Object.freeze({__proto__:null,navTest:r,browserIsIE:n,browserIsChrome:s,browserIsIEorTrident:o,browserIsIE10:a,browserIsEdge:l,browserIsFirefox:h,browserIsMac:c,isWindowPlatform:d,isTouchable:u,isMobile:p,isAndroid:m,isIOS:f,isApple:g,isIphone:v,isIpad:y,isQQ:w,isWeiXinWork:x,isWeiXin:b,isWeiBo:_,isMiniProgram:A,CS_MSWHEEL_KEY:S,CS_EVENT_LIST:T,passiveSupported:P,eventListenerOptionsFalse:M,eventListenerOptionsTrue:C,getPlatform:function(){let t=navigator.userAgent;const e=["Android","iPhone","SymbianOS","Windows Phone","iPad","iPod"];let i=!0,r="PC",n=!1;for(let s=0;s0){i=!1,r=e[s],t.indexOf("MicroMessenger")>0&&(n=!0);break}return{isPC:i,isWeixin:n,platform:r}},getScreenScale:function(){var t=0,e=window.screen;return void 0!==window.devicePixelRatio?t=window.devicePixelRatio:~this.ua.indexOf("msie")?e.deviceXDPI&&e.logicalXDPI&&(t=e.deviceXDPI/e.logicalXDPI):void 0!==window.outerWidth&&void 0!==window.innerWidth&&(t=window.outerWidth/window.innerWidth),t&&(t=Math.round(100*t)),99!==t&&101!==t||(t=100),t},getDPI:L,DPI:R,getPixelPerCentimeter:function(){return L()/2.54}});function F(t){return"object"==typeof HTMLElement?t instanceof HTMLElement:!(!t||"object"!=typeof t||1!==t.nodeType&&9!==t.nodeType||"string"!=typeof t.nodeName)}function N(t,e){let i=t.className.split(/\s+/);for(let t=0;t{e[t]&&(e[t]=e[t].bind(e))}))}function ct(t,e){var i=Math.pow(10,void 0===e?6:e);return Math.round(t*i)/i}function dt(t,e,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;clearTimeout(t.tid),t.tid=window.setTimeout((function(){return t.call(e,i)}),r)}function ut(t,e,i){let r=null,n=!1;function s(){n=!1,r&&(o.apply(i,r),r=!1)}function o(){n?r=arguments:(t.apply(i,arguments),setTimeout(s,e),n=!0)}return o}function pt(t,e){if(!tt(e))for(const i in e)q(e[i])?(q(t[i])||(t[i]={}),pt(t[i],e[i])):void 0===e[i]||Z(e[i])||(t[i]=null===e[i]||F(e[i])?e[i]:JSON.parse(JSON.stringify(e[i])));return t}function mt(t){if(arguments.length>=2)for(let e=1;e=2)for(let e=1;e0&&0==(t-1&t)}function xt(t,e){return t.toArray().map((t=>ct(t,e||5)))}function bt(t,e,i,r,n){return[i,r,n,`${e}px`,t].join(" ")}function _t(t){return Q(t)&&t.lastIndexOf(".")>0?t.split(".").pop():""}function At(t){if(Q(t)&&t.lastIndexOf("/")>0){var e=t.split("/");return e.pop(),e.join("/")}return t}function St(t){if(Q(t)&&t.lastIndexOf("/")>0){var e=t.split("/"),i=e.pop();return{path:e.join("/")+"/",fileName:i}}return null}function Tt(t){let e=t.split("");return"/"!==e[e.length-1]?t+"/":t}function Et(t,e){if(!W(t)||!W(e))return!1;if(t.length!==e.length)return!1;let i=!0;for(let r=0;re&&(e=t[i]);return e}const Mt=function(){function t(t,e){for(var i=0;inull==t,Lt=t=>!Ct(t);var Rt=Object.freeze({__proto__:null,cloneDeep:H,isArray:W,isBoolean:Y,isString:Q,isNumber:J,isFunction:Z,isObject:q,isNull:K,isUndefined:function(t){return void 0===t},isBlank:$,isEmptyObject:tt,isJSON:function(t){if(K(t))return!1;if(q(t)&&!tt(t))return t;let e=!0;if(Q(t))try{var i=JSON.parse(t);if(q(i)&&t.indexOf("{")>-1)return i;e=!1}catch(t){e=!1}return console.error("The "+t+" isn't json"),e},cloneJson:et,cloneArray:function(t){return W(t)?t.concat():[]},isEqualNumber:function(t,e){return Math.abs(t-e)<1e-5},isBase64:it,emptyImageUrl:rt,trim:nt,splitWords:function(t){return nt(t).split(/\s+/)},getObjectFromArray:function(t,e,i,r){if(t&&t.length&&e){for(let n=0,s=t.length;n=1&&((W(t[i])?Et(t[i],t[i-1]):t[i]===t[i-1])&&t.splice(i,1),e(i-1))}(t.length-1)}return t},replaceAll:at,getQueryStr:function(t){let e,i=String(window.document.location.href);return(e=new RegExp("(^|)"+t+"=([^&]*)(&|$)","gi").exec(i))?e[2]:""},encodeUnicode:function(t){for(var e=[],i=0;it?e:t>i?i:t},plusOrMinus:function(t){return 0>t?-1:t>0?1:0},vectorToArray:xt,getCSSFont:bt,getFileExt:_t,getFilePath:At,getFileInfoFromUrl:St,safeUrl:function(t){return["/"].forEach((function(e){t=at(t,e,".")})),t=t.replace(/\\/g,"/")},fixUrlSlash:Tt,equalArray:Et,arrayMin:function(t){if(0===t.length)return 1/0;for(var e=t[0],i=1,r=t.length;i2&&void 0!==arguments[2]&&arguments[2],r=t["_prev_"+e];return i&&delete t["_prev_"+e],r},isNil:Ct,isNotNil:Lt,pendingPromise:function(){let t,e;const i=new Promise(((i,r)=>{t=i,e=r}));return i.reject=e,i.resolve=t,i},getRandomBetween:function(t,e){return Math.random()*(e-t)+t}}),Ot={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-Ot.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*Ot.Bounce.In(2*t):.5*Ot.Bounce.Out(2*t-1)+.5}}},Ft="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},Nt=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=Ft()),void 0===e&&(e=!1);var i=Object.keys(this._tweens);if(0===i.length)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(t[i],t[i-1],i-r):s(t[n],t[n+1>i?i:n+1],r-n)},Bezier:function(t,e){for(var i=0,r=t.length-1,n=Math.pow,s=Dt.Utils.Bernstein,o=0;o<=r;o++)i+=n(1-e,r-o)*n(e,o)*t[o]*s(r,o);return i},CatmullRom:function(t,e){var i=t.length-1,r=i*e,n=Math.floor(r),s=Dt.Utils.CatmullRom;return t[0]===t[i]?(e<0&&(n=Math.floor(r=i*(1+e))),s(t[(n-1+i)%i],t[n],t[(n+1)%i],t[(n+2)%i],r-n)):e<0?t[0]-(s(t[0],t[0],t[1],t[1],-r)-t[0]):e>1?t[i]-(s(t[i],t[i],t[i-1],t[i-1],r-i)-t[i]):s(t[n?n-1:0],t[n],t[i1;r--)i*=r;return t[e]=i,i}}(),CatmullRom:function(t,e,i,r,n){var s=.5*(i-t),o=.5*(r-e),a=n*n;return(2*e-2*i+s+o)*(n*a)+(-3*e+3*i-2*s-o)*a+s*n+e}}},It=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),Ut=new Nt,Bt=function(){function t(t,e){void 0===e&&(e=Ut),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Ot.Linear.None,this._interpolationFunction=Dt.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=It.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.to=function(t,e){return this._valuesEnd=Object.create(t),void 0!==e&&(this._duration=e),this},t.prototype.duration=function(t){return this._duration=t,this},t.prototype.start=function(t){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==t?"string"==typeof t?Ft()+parseFloat(t):t:Ft(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},t.prototype._setupProperties=function(t,e,i,r){for(var n in i){var s=t[n],o=Array.isArray(s),a=o?"array":typeof s,l=!o&&Array.isArray(i[n]);if("undefined"!==a&&"function"!==a){if(l){var h=i[n];if(0===h.length)continue;h=h.map(this._handleRelativeValue.bind(this,s)),i[n]=[s].concat(h)}if("object"!==a&&!o||!s||l)void 0===e[n]&&(e[n]=s),o||(e[n]*=1),r[n]=l?i[n].slice().reverse():e[n]||0;else{for(var c in e[n]=o?[]:{},s)e[n][c]=s[c];r[n]=o?[]:{},this._setupProperties(s,e[n],i[n],r[n])}}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},t.prototype.pause=function(t){return void 0===t&&(t=Ft()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this)),this},t.prototype.resume=function(t){return void 0===t&&(t=Ft()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},t.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;tn)return!1;e&&this.start(t)}if(this._goToEnd=!1,t1?1:r;var s=this._easingFunction(r);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,s),this._onUpdateCallback&&this._onUpdateCallback(this._object,r),1===r){if(this._repeat>0){for(i in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[i]||(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var o=0,a=this._chainedTweens.length;o0)for(let t=0;t0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,e=this.faces.length;t=0;t--){const e=s[t];this.faces.splice(e,1);for(let t=0,i=this.faceVertexUvs.length;t0,a=e.vertexNormals.length>0,l=1!==e.color.r||1!==e.color.g||1!==e.color.b,p=e.vertexColors.length>0;let m=0;if(m=h(m,0,0),m=h(m,1,r),m=h(m,2,n),m=h(m,3,s),m=h(m,4,o),m=h(m,5,a),m=h(m,6,l),m=h(m,7,p),i.push(m),i.push(e.a,e.b,e.c),i.push(e.materialIndex),s){const e=this.faceVertexUvs[0][t];i.push(u(e[0]),u(e[1]),u(e[2]))}if(o&&i.push(c(e.normal)),a){const t=e.vertexNormals;i.push(c(t[0]),c(t[1]),c(t[2]))}if(l&&i.push(d(e.color)),p){const t=e.vertexColors;i.push(d(t[0]),d(t[1]),d(t[2]))}}function h(t,e,i){return i?t|1<0&&(t.data.colors=s),a.length>0&&(t.data.uvs=[a]),t.data.faces=i,t}clone(){return(new ye).copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;const e=t.vertices;for(let t=0,i=e.length;t0){const i=new Float32Array(3*t.normals.length);e.setAttribute("normal",new me.BufferAttribute(i,3).copyVector3sArray(t.normals))}if(t.colors.length>0){const i=new Float32Array(3*t.colors.length);e.setAttribute("color",new me.BufferAttribute(i,3).copyColorsArray(t.colors))}if(t.uvs.length>0){const i=new Float32Array(2*t.uvs.length);e.setAttribute("uv",new me.BufferAttribute(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){const i=new Float32Array(2*t.uvs2.length);e.setAttribute("uv2",new me.BufferAttribute(i,2).copyVector2sArray(t.uvs2))}e.groups=t.groups;for(const i in t.morphTargets){const r=[],n=t.morphTargets[i];for(let t=0,e=n.length;t0){const i=new me.Float32BufferAttribute(4*t.skinIndices.length,4);e.setAttribute("skinIndex",i.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){const i=new me.Float32BufferAttribute(4*t.skinWeights.length,4);e.setAttribute("skinWeight",i.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(e.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new me.BufferGeometry;const i=t.geometry;if(t.isPoints||t.isLine){const t=new me.Float32BufferAttribute(3*i.vertices.length,3),r=new me.Float32BufferAttribute(3*i.colors.length,3);if(e.setAttribute("position",t.copyVector3sArray(i.vertices)),e.setAttribute("color",r.copyColorsArray(i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){const t=new me.Float32BufferAttribute(i.lineDistances.length,1);e.setAttribute("lineDistance",t.copyArray(i.lineDistances))}null!==i.boundingSphere&&(e.boundingSphere=i.boundingSphere.clone()),null!==i.boundingBox&&(e.boundingBox=i.boundingBox.clone())}else t.isMesh&&(e=i.toBufferGeometry());return e}}ye.prototype.isGeometry=!0;class we{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){const e=[];let i,r,n;const s=t.faces;for(r=0;r0,s=r[1]&&r[1].length>0,o=t.morphTargets,a=o.length;let l;if(a>0){l=[];for(let t=0;t0){d=[];for(let t=0;t0&&0===e.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let t=0;te.far?null:{distance:h,point:s.clone(),object:t}}(this,l,n,t,e,i,o);if(null!==g){var v=new be.Face3(h,c,d);return be.Triangle.getNormal(t,e,i,v.normal),g.face=v,g.faceIndex=h,g}console.log("WARNING: intersectionPoint missing")}}(),be.Line.prototype.raycastWithID=(_e=new be.Matrix4,Ae=new be.Ray,Se=new be.Vector3,Te=new be.Vector3,Ee=new be.Vector3,Pe=new be.Vector3,function(t,e){_e.copy(this.matrixWorld).invert(),Ae.copy(e.ray).applyMatrix4(_e);var i=this.geometry;if(i instanceof be.BufferGeometry){var r=i.attributes;if(null===i.index){var n=r.position.array,s=6*t;Se.fromArray(n,s),Te.fromArray(n,s+3),Ae.distanceSqToSegment(Se,Te,Pe,Ee);var o=Ae.origin.distanceTo(Pe);if(oe.far)return;return{distance:o,point:Ee.clone().applyMatrix4(this.matrixWorld),index:s,face:null,faceIndex:null,object:this}}console.log("WARNING: raycastWithID does not support indexed vertices")}}),be.Points.prototype.raycastWithID=function(){var t=new be.Matrix4,e=new be.Ray;return function(i,r){var n=this,s=n.geometry;t.copy(this.matrixWorld).invert(),e.copy(r.ray).applyMatrix4(t);var o=new be.Vector3,a=s.attributes.position.array;return o.fromArray(a,3*i),function(t,i){var s=e.distanceToPoint(t),o=e.closestPointToPoint(t);o.applyMatrix4(n.matrixWorld);var a=r.ray.origin.distanceTo(o);if(!(ar.far))return{distance:a,distanceToRay:s,point:o.clone(),index:i,face:null,object:n}}(o,i)}}(),be.Color.prototype.copy=function(t){return t&&(this.r=t.r,this.g=t.g,this.b=t.b),this},be.Color.prototype.toHexString=function(){return"#"+this.getHexString().toUpperCase()},be.Line.prototype.updatePosition=function(t,e){var i=this.geometry.vertices;if(2==i.length){var r=i[0],n=i[1];r.equals(t)&&n.equals(e)||(r.x=t.x,r.y=t.y,r.z=t.z,n.x=e.x,n.y=e.y,n.z=e.z,this.geometry.boundingSphere=null,this.geometry.verticesNeedUpdate=!0,this.computeLineDistances())}},be.Vector3.prototype.toLogString=function(){return"x: "+this.x+", y: "+this.y+", z: "+this.z},be.Vector3.prototype.log=function(){console.log(this.toLogString())},be.Object3D.prototype.show=function(t){if(t)for(var e=this;e;)e.visible=!0,e=e.parent;else this.visible=t},be.Object3D.prototype.ensureVisible=function(t){if(void 0===t)return!!this.visible&&!!this.layers.mask;if(!Utils.isBoolean(t)){for(var e=this;e;){if(!e.visible)return!1;if(t&&!e.layers.test(t.layers))return!1;e=e.parent}return!0}var i=t;i?this.layers.set(0):this.layers.disable(0),this.visible=i},be.Euler.prototype.multiplyMatrix4=function(t){var e=new be.Quaternion;e.setFromEuler(this);var i=new be.Quaternion;i.setFromRotationMatrix(t),e.multiply(i),this.setFromQuaternion(e)},be.Quaternion.prototype.multiplyMatrix4=function(t){var e=new be.Quaternion;e.setFromRotationMatrix(t),this.multiply(e)},be.OrthographicCamera.prototype.resize=function(t,e){if(void 0!==this.userData){var i=this.userData.depth*this.userData.z,r=i*(t/e);this.left=-r/2,this.right=r/2,this.top=i/2,this.bottom=-i/2,this.updateProjectionMatrix()}},be.Mesh.prototype.verticesCount=function(){return this.geometry?this.geometry.isBufferGeometry?this.geometry.attributes.position.count:this.geometry.vertices.length:0},be.Mesh.prototype.getPerimeter=function(){var t=this.geometry.attributes.position;if(t.count<2)return 0;for(var e=0,i=new be.Vector2(t.getX(0),t.getZ(0)),r=1;r1&&void 0!==arguments[1]?arguments[1]:1e3;this.updateMatrixWorld();var i=new be.Vector3,r=new be.Vector3(0,1,0),n=this.position.clone();i.copy(r).applyQuaternion(this.quaternion),n.add(i.multiplyScalar(e)),n.applyMatrix4(this.matrixWorld);var s=new be.Vector3,o=new be.Vector3(0,-1,0),a=this.position.clone();s.copy(o).applyQuaternion(this.quaternion),a.add(s.multiplyScalar(e)),a.applyMatrix4(this.matrixWorld);var l=new be.Vector3;l.subVectors(a,n),l.normalize();var h=t.clone();h.add(l.clone().multiplyScalar(-e));var c=new be.Raycaster;c.ray.origin.copy(h),c.ray.direction.copy(l);var d=c.intersectObjectForcible(this.parent,!0);return d.length?d[0].point:null},be.Box3.prototype.setFromVisibleObject=function(t){this.makeEmpty(),t.updateMatrixWorld(!0);var e=new be.Vector3,i=this;return t.traverseVisible((function(t){if(!t.isLight&&!t.userData.skipBoundingBox){var r=t.geometry;if(void 0!==r)if(r.isGeometry)for(var n=r.vertices,s=0,o=n.length;s=0&&(W(t[1])||1===t.length)?(this.prefix=t[0],e=t.slice(1)):e=t),e[0]||(e=null),e&&(e=W(e[0])?e:[e]),this.exps=e&&this._validateExps(e)?e:[]}_validateExps(t){const e=["!=","==","<","<=",">",">=","has","!has","!in","in","like","startWith"];let i=!0;return t.forEach((r=>{vt(e,r[0])<0&&(console.log(t),console.warn("过滤器参数错误: ",r,", 过滤器第一位为运算符, 仅包括: "+e),i=!1)})),i}setPrefix(t){this.prefix=t||"all"}add(t,e,i){this.exps.push([t,e,i])}toArray(){return[this.prefix].concat(this.exps)}validate(t){const e=this.prefix,i=this.exps;let r=[];return i.forEach((e=>{const i=e[0],n=e[1],s=function(t){let e=null;if(W(t))switch(t[0]){case"has":case"!has":e=null;break;case"in":case"!in":e=t.slice(2);break;case"!=":case"==":case">":case">=":case"<":case"<=":case"like":case"startWith":case"endWith":e=t[2]}return e}(e);r.push(function(t,e,i,r){if(!t||tt(t))return!1;const n=t[e];switch(i){case"has":return void 0!==n;case"!has":return void 0===n;case"in":return vt(r,n)>=0;case"!in":return vt(r,n)<0;case"!=":return n!==r;case"==":return n===r;case">":return n>r;case">=":return n>=r;case"<":return n=0;case"startWith":return 0==(n||"").toLowerCase().indexOf(r.toLowerCase())}return!1}(t,n,i,s))})),"all"===e?r.filter((t=>t)).length===r.length:"any"===e?r.filter((t=>t)).length>=1:"none"===e?r.filter((t=>!t)).length===r.length:void 0}}const Ce=/^[og]\s*(.+)?/,Le=/^mtllib /,Re=/^usemtl /,Oe=/^usemap /,Fe=new be.Vector3,Ne=new be.Vector3,De=new be.Vector3,Ie=new be.Vector3,Ue=new be.Vector3;function Be(){const t={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(t,e){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=t,void(this.object.fromDeclaration=!1!==e);const i=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:t||"",fromDeclaration:!1!==e,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(t,e){const i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);const r={index:this.materials.length,name:t||"",mtllib:Array.isArray(e)&&e.length>0?e[e.length-1]:"",smooth:void 0!==i?i.smooth:this.smooth,groupStart:void 0!==i?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(t){const e={index:"number"==typeof t?t:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return e.clone=this.clone.bind(e),e}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(t){const e=this.currentMaterial();if(e&&-1===e.groupEnd&&(e.groupEnd=this.geometry.vertices.length/3,e.groupCount=e.groupEnd-e.groupStart,e.inherited=!1),t&&this.materials.length>1)for(let t=this.materials.length-1;t>=0;t--)this.materials[t].groupCount<=0&&this.materials.splice(t,1);return t&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),e}},i&&i.name&&"function"==typeof i.clone){const t=i.clone(0);t.inherited=!0,this.object.materials.push(t)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(t,e){const i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},parseNormalIndex:function(t,e){const i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},parseUVIndex:function(t,e){const i=parseInt(t,10);return 2*(i>=0?i-1:i+e/2)},addVertex:function(t,e,i){const r=this.vertices,n=this.object.geometry.vertices;n.push(r[t+0],r[t+1],r[t+2]),n.push(r[e+0],r[e+1],r[e+2]),n.push(r[i+0],r[i+1],r[i+2])},addVertexPoint:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addVertexLine:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addNormal:function(t,e,i){const r=this.normals,n=this.object.geometry.normals;n.push(r[t+0],r[t+1],r[t+2]),n.push(r[e+0],r[e+1],r[e+2]),n.push(r[i+0],r[i+1],r[i+2])},addFaceNormal:function(t,e,i){const r=this.vertices,n=this.object.geometry.normals;Fe.fromArray(r,t),Ne.fromArray(r,e),De.fromArray(r,i),Ue.subVectors(De,Ne),Ie.subVectors(Fe,Ne),Ue.cross(Ie),Ue.normalize(),n.push(Ue.x,Ue.y,Ue.z),n.push(Ue.x,Ue.y,Ue.z),n.push(Ue.x,Ue.y,Ue.z)},addColor:function(t,e,i){const r=this.colors,n=this.object.geometry.colors;void 0!==r[t]&&n.push(r[t+0],r[t+1],r[t+2]),void 0!==r[e]&&n.push(r[e+0],r[e+1],r[e+2]),void 0!==r[i]&&n.push(r[i+0],r[i+1],r[i+2])},addUV:function(t,e,i){const r=this.uvs,n=this.object.geometry.uvs;n.push(r[t+0],r[t+1]),n.push(r[e+0],r[e+1]),n.push(r[i+0],r[i+1])},addDefaultUV:function(){const t=this.object.geometry.uvs;t.push(0,0),t.push(0,0),t.push(0,0)},addUVLine:function(t){const e=this.uvs;this.object.geometry.uvs.push(e[t+0],e[t+1])},addFace:function(t,e,i,r,n,s,o,a,l){const h=this.vertices.length;let c=this.parseVertexIndex(t,h),d=this.parseVertexIndex(e,h),u=this.parseVertexIndex(i,h);if(this.addVertex(c,d,u),this.addColor(c,d,u),void 0!==o&&""!==o){const t=this.normals.length;c=this.parseNormalIndex(o,t),d=this.parseNormalIndex(a,t),u=this.parseNormalIndex(l,t),this.addNormal(c,d,u)}else this.addFaceNormal(c,d,u);if(void 0!==r&&""!==r){const t=this.uvs.length;c=this.parseUVIndex(r,t),d=this.parseUVIndex(n,t),u=this.parseUVIndex(s,t),this.addUV(c,d,u),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(t){this.object.geometry.type="Points";const e=this.vertices.length;for(let i=0,r=t.length;i=7?e.colors.push(parseFloat(t[4]),parseFloat(t[5]),parseFloat(t[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]));break;case"vt":e.uvs.push(parseFloat(t[1]),parseFloat(t[2]))}}else if("f"===n){const t=r.substr(1).trim().split(/\s+/),i=[];for(let e=0,r=t.length;e0){const t=r.split("/");i.push(t)}}const n=i[0];for(let t=1,r=i.length-1;t1){const t=o[1].trim().toLowerCase();e.object.smooth="0"!==t&&"off"!==t}else e.object.smooth=!0;const t=e.object.currentMaterial();t&&(t.smooth=e.object.smooth)}else{if("\0"===r)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+r+'"')}e.finalize();const l=new be.Group;l.materialLibraries=[].concat(e.materialLibraries);if(!0===!(1===e.objects.length&&0===e.objects[0].geometry.vertices.length))for(let t=0,i=e.objects.length;t0&&h.setAttribute("normal",new be.Float32BufferAttribute(r.normals,3)),r.colors.length>0&&(a=!0,h.setAttribute("color",new be.Float32BufferAttribute(r.colors,3))),!0===r.hasUVIndices&&h.setAttribute("uv",new be.Float32BufferAttribute(r.uvs,2));const c=[];for(let t=0,i=n.length;t1){for(let t=0,e=n.length;t0){const t=new be.PointsMaterial({size:1,sizeAttenuation:!1}),i=new be.BufferGeometry;i.setAttribute("position",new be.Float32BufferAttribute(e.vertices,3)),e.colors.length>0&&void 0!==e.colors[0]&&(i.setAttribute("color",new be.Float32BufferAttribute(e.colors,3)),t.vertexColors=!0);const r=new be.Points(i,t);l.add(r)}return l}}class je extends be.Loader{constructor(t){super(t)}load(t,e,i,r){const n=this,s=""===this.path?be.LoaderUtils.extractUrlBase(t):this.path,o=new be.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(i){try{e(n.parse(i,s))}catch(e){r?r(e):console.error(e),n.manager.itemError(t)}}),i,r)}setMaterialOptions(t){return this.materialOptions=t,this}parse(t,e){const i=t.split("\n");let r={};const n=/\s+/,s={};for(let t=0;t=0?e.substring(0,o):e;a=a.toLowerCase();let l=o>=0?e.substring(o+1):"";if(l=l.trim(),"newmtl"===a)r={name:l},s[l]=r;else if("ka"===a||"kd"===a||"ks"===a||"ke"===a){const t=l.split(n,3);r[a]=[parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2])]}else r[a]=l}const o=new Ve(this.resourcePath||e,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(s),o}}class Ve{constructor(t="",e={}){this.baseUrl=t,this.options=e,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:be.FrontSide,this.wrap=void 0!==this.options.wrap?this.options.wrap:be.RepeatWrapping}setCrossOrigin(t){return this.crossOrigin=t,this}setManager(t){this.manager=t}setMaterials(t){this.materialsInfo=this.convert(t),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(t){if(!this.options)return t;const e={};for(const i in t){const r=t[i],n={};e[i]=n;for(const t in r){let e=!0,i=r[t];const s=t.toLowerCase();switch(s){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(i=[i[0]/255,i[1]/255,i[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===i[0]&&0===i[1]&&0===i[2]&&(e=!1)}e&&(n[s]=i)}}return e}preload(){for(const t in this.materialsInfo)this.create(t)}getIndex(t){return this.nameLookup[t]}getAsArray(){let t=0;for(const e in this.materialsInfo)this.materialsArray[t]=this.create(e),this.nameLookup[e]=t,t++;return this.materialsArray}create(t){return void 0===this.materials[t]&&this.createMaterial_(t),this.materials[t]}createMaterial_(t){const e=this,i=this.materialsInfo[t],r={name:t,side:this.side};function n(t,n){if(r[t])return;const s=e.getTextureParams(n,r),o=e.loadTexture((a=e.baseUrl,"string"!=typeof(l=s.url)||""===l?"":/^https?:\/\//i.test(l)?l:a+l),null,(function(t){const e=t.image;e&&(wt(e.width)&&wt(e.height)?(t.wrapS=be.RepeatWrapping,t.wrapT=be.RepeatWrapping,t.minFilter=be.LinearMipmapLinearFilter):(t.wrapS=be.ClampToEdgeWrapping,t.wrapT=be.ClampToEdgeWrapping,t.minFilter=be.LinearFilter,t.magFilter=be.LinearFilter),t.needsUpdate=!0,i.loaded=!0)}));var a,l;o.repeat.copy(s.scale),o.offset.copy(s.offset),o.wrapS=e.wrap,o.wrapT=e.wrap,"map"!==t&&"emissiveMap"!==t||(o.encoding=be.sRGBEncoding),r[t]=o}for(const t in i){const e=i[t];let s;if(""!==e)switch(t.toLowerCase()){case"kd":r.color=(new be.Color).fromArray(e).convertSRGBToLinear();break;case"ks":r.specular=(new be.Color).fromArray(e).convertSRGBToLinear();break;case"ke":r.emissive=(new be.Color).fromArray(e).convertSRGBToLinear();break;case"map_kd":n("map",e);break;case"map_ks":n("specularMap",e);break;case"map_ke":n("emissiveMap",e);break;case"norm":n("normalMap",e);break;case"map_bump":case"bump":n("bumpMap",e);break;case"map_d":n("alphaMap",e),r.transparent=!0;break;case"ns":r.shininess=parseFloat(e);break;case"d":s=parseFloat(e),s<1&&(r.opacity=s,r.transparent=!0);break;case"tr":s=parseFloat(e),this.options&&this.options.invertTrProperty&&(s=1-s),s>0&&(r.opacity=1-s,r.transparent=!0)}}return this.materials[t]=new be.MeshPhongMaterial(r),this.materials[t]}getTextureParams(t,e){const i={scale:new be.Vector2(1,1),offset:new be.Vector2(0,0)},r=t.split(/\s+/);let n;return n=r.indexOf("-bm"),n>=0&&(e.bumpScale=parseFloat(r[n+1]),r.splice(n,2)),n=r.indexOf("-s"),n>=0&&(i.scale.set(parseFloat(r[n+1]),parseFloat(r[n+2])),r.splice(n,4)),n=r.indexOf("-o"),n>=0&&(i.offset.set(parseFloat(r[n+1]),parseFloat(r[n+2])),r.splice(n,4)),i.url=r.join(" ").trim(),i}loadTexture(t,e,i,r,n){const s=void 0!==this.manager?this.manager:be.DefaultLoadingManager;let o=s.getHandler(t);null===o&&(o=new be.TextureLoader(s)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const a=o.load(t,i,r,n);return void 0!==e&&(a.mapping=e),a}}const ze=new be.Vector3,Ge=new be.Quaternion,He=new be.Vector3;class Xe extends be.Object3D{constructor(t=document.createElement("div")){super(),this.element=t,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 Element&&null!==t.element.parentNode&&t.element.parentNode.removeChild(t.element)}))}))}copy(t,e){return super.copy(t,e),this.element=t.element.cloneNode(!0),this}}Xe.prototype.isCSS3DObject=!0;class We extends Xe{constructor(t){super(t),this.rotation2D=0}copy(t,e){return super.copy(t,e),this.rotation2D=t.rotation2D,this}}We.prototype.isCSS3DSprite=!0;const Ye=new be.Matrix4,Qe=new be.Matrix4;class Je{constructor(t={}){const e=this;let i,r,n,s;const o={camera:{fov:0,style:""},objects:new WeakMap},a=void 0!==t.element?t.element:document.createElement("div");a.style.overflow="hidden",this.domElement=a;const l=document.createElement("div");function h(t){return Math.abs(t)<1e-10?0:t}function c(t){const e=t.elements;return"matrix3d("+h(e[0])+","+h(-e[1])+","+h(e[2])+","+h(e[3])+","+h(e[4])+","+h(-e[5])+","+h(e[6])+","+h(e[7])+","+h(e[8])+","+h(-e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(-e[13])+","+h(e[14])+","+h(e[15])+")"}function d(t){const e=t.elements;return"translate(-50%,-50%)"+("matrix3d("+h(e[0])+","+h(e[1])+","+h(e[2])+","+h(e[3])+","+h(-e[4])+","+h(-e[5])+","+h(-e[6])+","+h(-e[7])+","+h(e[8])+","+h(e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(e[13])+","+h(e[14])+","+h(e[15])+")")}function u(t,i,r,n){if(t.isCSS3DObject){const n=!0===t.visible&&!0===t.layers.test(r.layers);if(t.element.style.display=!0===n?"":"none",!0===n){let n;t.onBeforeRender(e,i,r),t.isCSS3DSprite?(Ye.copy(r.matrixWorldInverse),Ye.transpose(),0!==t.rotation2D&&Ye.multiply(Qe.makeRotationZ(t.rotation2D)),t.matrixWorld.decompose(ze,Ge,He),Ye.setPosition(ze),Ye.scale(He),Ye.elements[3]=0,Ye.elements[7]=0,Ye.elements[11]=0,Ye.elements[15]=1,n=d(Ye)):n=d(t.matrixWorld);const s=t.element,a=o.objects.get(t);if(void 0===a||a.style!==n){s.style.transform=n;const e={style:n};o.objects.set(t,e)}s.parentNode!==l&&l.appendChild(s),t.onAfterRender(e,i,r)}}for(let e=0,n=t.children.length;e=0}function Ke({obj:t,mtl:e,path:i,loadedCallback:r,errorCallback:n,progressCallback:s,loadingManager:o}){if(!t)return;const a=i||At(t)+"/"||"",l=new ke(o),h=()=>{l.load(a+t,r,s,n)};if(e){const t=new je(o);t.setPath(a),t.load(e,(t=>{h(),l.setMaterials(t)}),null,(()=>{n()}))}else h()}function $e(t,e){if(t){if(t.isVector2)return t;if(W(t)){var i=Number(t[0]),r=t.length>1?Number(t[1]):0;return new be.Vector2(i,r)}return Q(t)?(t.split(","),null):t}return e||new be.Vector2}function ti(t,e){if(t){if(t.isVector3)return t;if(q(t)&&void 0!==t.x&&void 0!==t.y&&void 0!==t.y)return new be.Vector3(t.x,t.y,t.z);if(W(t))return 1===t.length?new be.Vector3(Number(t[0]),0,0):2===t.length?new be.Vector3(Number(t[0]),0,Number(t[1])):new be.Vector3(Number(t[0]),Number(t[1]),Number(t[2]));if(Q(t)){for(var i=t.split(/,| /),r=0;r4)&&console.log("parseEuler not impl");var e=Math.degToRad(t[0]%360),i=Math.degToRad(t[1]%360),r=Math.degToRad(t[2]%360);if(3==t.length)return new be.Euler(e,i,r);if(4==t.length)return new be.Euler(e,i,r,t[3])}else{if(t instanceof be.Quaternion){var n=new be.Euler;return n.setFromQuaternion(t),n}console.log("parseEuler not impl")}}function ii(t){var e=ei(t),i=new be.Quaternion;return i.setFromEuler(e),i}function ri(t){return t instanceof be.Euler?[be.Math.radToDeg(t._x),be.Math.radToDeg(t._y),be.Math.radToDeg(t._z)]:t instanceof be.Quaternion?ri((new be.Euler).setFromQuaternion(t)):t}function ni(t,e){return t?Q(t)?new be.Color(t):(t.isColor,t):new be.Color.set(e||"rgb(0, 0, 0)")}function si(t,e,i){return new Ze.HtmlMixer.Plane(t,e,{elementW:i.domWidth,elementH:i.domHeight,planeW:i.planeWidth,planeH:i.planeHeight})}function oi(t){return!!t&&(t.isScene||t.isMesh||t.isSprite||t.isPoints||t.isLine||t.isImmediateRenderObject)}function ai(t){let e=t.parent;if(!e)return t;for(;e.parent;)e=e.parent;return e}function li(t,e){for(var i=[];t.parent;){var r=t.parent,n=getChildIndex(r,t);if(-1==n)break;if(i.push(n),r==e)break;t=r}return i}function hi(t){if(t){t.computeFaceNormals(),t.computeVertexNormals(),t.computeBoundingBox();for(var e=t.boundingBox.max,i=t.boundingBox.min,r=new be.Vector2(0-i.x,0-i.y),n=new be.Vector2(e.x-i.x,e.y-i.y),s=t.faces,o=[],a=0;a0){var p=new Float32Array(3*n.length);e.setAttribute("normal",new be.BufferAttribute(p,3).copyVector3sArray(n))}if(s.length>0){var m=new Float32Array(3*s.length);e.setAttribute("color",new be.BufferAttribute(m,3).copyColorsArray(s))}}Ze.HtmlMixer=Ze.HtmlMixer||{},Ze.HtmlMixer.Context=function(t,e,i){var r=[];this.update=function(){r.forEach((function(t){t()}))};var n=1e3;this.cssFactor=n;var s=new Je;this.rendererCss=s,this.rendererWebgl=t;var o=new be.PerspectiveCamera(i.fov,i.aspect,i.near*n,i.far*n);r.push((function(){o.quaternion.copy(i.quaternion),o.position.copy(i.position).multiplyScalar(n)}));var a=new be.Scene;this.cssScene=a,this.autoUpdateObjects=!0,r.push(function(){!0===this.autoUpdateObjects&&a.traverse((function(t){if(t instanceof be.Scene!=!0){var e=t.userData.mixerPlane;void 0!==e&&e.update()}}))}.bind(this)),r.push((function(t,e){s.render(a,o)}))},Ze.HtmlMixer.Plane=function(t,e,i){(i=i||{}).elementW=i.elementW||768,i.planeW=i.planeW||1,i.planeH=i.planeH||3/4,i.object3d=i.object3d||null,this.domElement=e;var r=[];this.update=function(){r.forEach((function(t){t()}))};var n=i.planeW,s=i.planeH,o=null;if(null===i.object3d){const t=void 0!==i.side?i.side:be.DoubleSide;var a=new be.MeshBasicMaterial({opacity:0,color:new be.Color("black"),blending:be.NoBlending,side:t}),l=new be.PlaneGeometry(i.planeW,i.planeH);o=new be.Mesh(l,a)}else o=i.object3d;this.object3d=o;var h=s/n,c=i.elementW,d=i.elementH||c*h;function u(){e.style.width=c+"px",e.style.height=d+"px"}this.setDomElement=function(t){var i=e;i.parentNode&&i.parentNode.removeChild(i),this.domElement=e=t,p.element=e,u()},u();var p=new Xe(e);this.cssObject=p,p.scale.set(1,1,1).multiplyScalar(t.cssFactor/(c/n)),p.userData.mixerPlane=this,o.addEventListener("added",(function(e){t.cssScene.add(p)})),o.addEventListener("removed",(function(e){t.cssScene.remove(p)})),r.push((function(){o.updateMatrixWorld();var e=o.matrixWorld,i=new be.Vector3,r=new be.Vector3,n=new be.Quaternion;e.decompose(i,n,r),p.quaternion.copy(n),p.position.copy(i).multiplyScalar(t.cssFactor);var s=c/(o.geometry.parameters.width*r.x);p.scale.set(1,1,1).multiplyScalar(t.cssFactor/s)}))};class ui extends be.EventDispatcher{once(t,e){this._listeners||(this._listeners={}),e._once=!0,be.EventDispatcher.prototype.addEventListener.call(this,t,e)}on(t,e){this._listeners||(this._listeners={}),be.EventDispatcher.prototype.addEventListener.call(this,t,e)}dispatchEvent(t){if(this._listeners||(this._listeners={}),void 0!==this._listeners){var e=this._listeners[t.type];if(void 0!==e){t.target=this;var i=e.slice(0);let s=null;for(var r=0,n=i.length;r=2.0 are supported.")));const l=new cr(a,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===o[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(i,r)}parseAsync(t,e){const i=this;return new Promise((function(r,n){i.parse(t,e,r,n)}))}}function fi(){let t={};return{get:function(e){return t[e]},add:function(e,i){t[e]=i},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const gi={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class vi{constructor(t){this.parser=t,this.name=gi.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,r=e.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,n.source,s)}}class Pi{constructor(t){this.parser=t,this.name=gi.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,r=i.json,n=r.textures[t];if(!n.extensions||!n.extensions[e])return null;const s=n.extensions[e],o=r.images[s.source];let a=i.textureLoader;if(o.uri){const t=i.options.manager.getHandler(o.uri);null!==t&&(a=t)}return this.detectSupport().then((function(n){if(n)return i.loadTextureImage(t,s.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Mi{constructor(t){this.name=gi.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const t=i.extensions[this.name],r=this.parser.getDependency("buffer",t.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,n.ready]).then((function(e){const i=t.byteOffset||0,r=t.byteLength||0,s=t.count,o=t.byteStride,a=new ArrayBuffer(s*o),l=new Uint8Array(e[0],i,r);return n.decodeGltfBuffer(new Uint8Array(a),s,o,l,t.mode,t.filter),a}))}return null}}const Ci="glTF",Li=1313821514,Ri=5130562;class Oi{constructor(t){this.name=gi.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12);if(this.header={magic:be.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Ci)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,r=new DataView(t,12);let n=0;for(;n",e).replace("#include ",i).replace("#include ",r).replace("#include ",n).replace("#include ",s)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(t){o.specular.value=t}},specularMap:{get:function(){return o.specularMap.value},set:function(t){o.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(t){o.glossiness.value=t}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(t){o.glossinessMap.value=t,t?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(t)}copy(t){return super.copy(t),this.specularMap=t.specularMap,this.specular.copy(t.specular),this.glossinessMap=t.glossinessMap,this.glossiness=t.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class Ii{constructor(){this.name=gi.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return Di}extendParams(t,e,i){const r=e.extensions[this.name];t.color=new be.Color(1,1,1),t.opacity=1;const n=[];if(Array.isArray(r.diffuseFactor)){const e=r.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==r.diffuseTexture&&n.push(i.assignTexture(t,"map",r.diffuseTexture,be.sRGBEncoding)),t.emissive=new be.Color(0,0,0),t.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,t.specular=new be.Color(1,1,1),Array.isArray(r.specularFactor)&&t.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const e=r.specularGlossinessTexture;n.push(i.assignTexture(t,"glossinessMap",e)),n.push(i.assignTexture(t,"specularMap",e,be.sRGBEncoding))}return Promise.all(n)}createMaterial(t){const e=new Di(t);return e.fog=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=void 0===t.emissiveIntensity?1:t.emissiveIntensity,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,e.normalMapType=be.TangentSpaceNormalMap,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e}}class Ui{constructor(){this.name=gi.KHR_MESH_QUANTIZATION}}class Bi extends be.Interpolant{constructor(t,e,i,r){super(t,e,i,r)}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=t*r*3+r;for(let t=0;t!==r;t++)e[t]=i[n+t];return e}}Bi.prototype.beforeStart_=Bi.prototype.copySampleValue_,Bi.prototype.afterEnd_=Bi.prototype.copySampleValue_,Bi.prototype.interpolate_=function(t,e,i,r){const n=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,h=r-e,c=(i-e)/h,d=c*c,u=d*c,p=t*l,m=p-l,f=-2*u+3*d,g=u-d,v=1-f,y=g-d+c;for(let t=0;t!==o;t++){const e=s[m+t+o],i=s[m+t+a]*h,r=s[p+t+o],l=s[p+t]*h;n[t]=v*e+y*i+f*r+g*l}return n};const ki=new be.Quaternion;class ji extends Bi{interpolate_(t,e,i,r){const n=super.interpolate_(t,e,i,r);return ki.fromArray(n).normalize().toArray(n),n}}const Vi=0,zi=1,Gi=2,Hi=3,Xi=4,Wi=5,Yi=6,Qi={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ji={9728:be.NearestFilter,9729:be.LinearFilter,9984:be.NearestMipmapNearestFilter,9985:be.LinearMipmapNearestFilter,9986:be.NearestMipmapLinearFilter,9987:be.LinearMipmapLinearFilter},Zi={33071:be.ClampToEdgeWrapping,33648:be.MirroredRepeatWrapping,10497:be.RepeatWrapping},qi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ki={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},$i={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},tr={CUBICSPLINE:void 0,LINEAR:be.InterpolateLinear,STEP:be.InterpolateDiscrete},er="OPAQUE",ir="MASK",rr="BLEND";function nr(t,e,i){for(const r in i.extensions)void 0===t[r]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=i.extensions[r])}function sr(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function or(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let i=0,r=e.weights.length;i-1,n=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1;"undefined"==typeof createImageBitmap||i||r&&n<98?this.textureLoader=new be.TextureLoader(this.options.manager):this.textureLoader=new be.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new be.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const i=this,r=this.json,n=this.extensions;this.cache.removeAll(),this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(e){const s={scene:e[0][r.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:r.asset,parser:i,userData:{}};nr(n,s,r),sr(s,r),Promise.all(i._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],i=this.json.meshes||[];for(let i=0,r=e.length;i{const i=this.associations.get(t);null!=i&&this.associations.set(e,i);for(const[i,r]of t.children.entries())n(r,e.children[i])};return n(i,r),r.name+="_instance_"+t.uses[e]++,r}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let i=0;i=2&&p.setY(e,c[t*s+1]),s>=3&&p.setZ(e,c[t*s+2]),s>=4&&p.setW(e,c[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.")}}return p}))}loadTexture(t){const e=this.json,i=this.options,r=e.textures[t].source,n=e.images[r];let s=this.textureLoader;if(n.uri){const t=i.manager.getHandler(n.uri);null!==t&&(s=t)}return this.loadTextureImage(t,r,s)}loadTextureImage(t,e,i){const r=this,n=this.json,s=n.textures[t],o=n.images[e],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(e,i).then((function(e){e.flipY=!1,s.name&&(e.name=s.name);const i=(n.samplers||{})[s.sampler]||{};return e.magFilter=Ji[i.magFilter]||be.LinearFilter,e.minFilter=Ji[i.minFilter]||be.LinearMipmapLinearFilter,e.wrapS=Zi[i.wrapS]||be.RepeatWrapping,e.wrapT=Zi[i.wrapT]||be.RepeatWrapping,r.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[a]=l,l}loadImageSource(t,e){const i=this,r=this.json,n=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const s=r.images[t],o=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=i.getDependency("bufferView",s.bufferView).then((function(t){l=!0;const e=new Blob([t],{type:s.mimeType});return a=o.createObjectURL(e),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(a).then((function(t){return new Promise((function(i,r){let s=i;!0===e.isImageBitmapLoader&&(s=function(t){const e=new be.Texture(t);e.needsUpdate=!0,i(e)}),e.load(be.LoaderUtils.resolveURL(t,n.path),s,void 0,r)}))})).then((function(t){var e;return!0===l&&o.revokeObjectURL(a),t.userData.mimeType=s.mimeType||((e=s.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),t}));return this.sourceCache[t]=h,h}assignTexture(t,e,i,r){const n=this;return this.getDependency("texture",i.index).then((function(s){if(void 0===i.texCoord||0==i.texCoord||"aoMap"===e&&1==i.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+i.texCoord+" for texture "+e+" not yet supported."),n.extensions[gi.KHR_TEXTURE_TRANSFORM]){const t=void 0!==i.extensions?i.extensions[gi.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=n.associations.get(s);s=n.extensions[gi.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),n.associations.set(s,e)}}return void 0!==r&&(s.encoding=r),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let i=t.material;const r=void 0===e.attributes.tangent,n=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new be.PointsMaterial,be.Material.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,e.sizeAttenuation=!1,this.cache.add(t,e)),i=e}else if(t.isLine){const t="LineBasicMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new be.LineBasicMaterial,be.Material.prototype.copy.call(e,i),e.color.copy(i.color),this.cache.add(t,e)),i=e}if(r||n||s){let t="ClonedMaterial:"+i.uuid+":";i.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),r&&(t+="derivative-tangents:"),n&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=i.clone(),n&&(e.vertexColors=!0),s&&(e.flatShading=!0),r&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(i))),i=e}i.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=i}getMaterialType(){return be.MeshStandardMaterial}loadMaterial(t){const e=this,i=this.json,r=this.extensions,n=i.materials[t];let s;const o={},a=n.extensions||{},l=[];if(a[gi.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const t=r[gi.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];s=t.getMaterialType(),l.push(t.extendParams(o,n,e))}else if(a[gi.KHR_MATERIALS_UNLIT]){const t=r[gi.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),l.push(t.extendParams(o,n,e))}else{const i=n.pbrMetallicRoughness||{};if(o.color=new be.Color(1,1,1),o.opacity=1,Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;o.color.fromArray(t),o.opacity=t[3]}void 0!==i.baseColorTexture&&l.push(e.assignTexture(o,"map",i.baseColorTexture,be.sRGBEncoding)),o.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,o.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(l.push(e.assignTexture(o,"metalnessMap",i.metallicRoughnessTexture)),l.push(e.assignTexture(o,"roughnessMap",i.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),l.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,o)}))))}!0===n.doubleSided&&(o.side=be.DoubleSide);const h=n.alphaMode||er;if(h===rr?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===ir&&(o.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&s!==be.MeshBasicMaterial&&(l.push(e.assignTexture(o,"normalMap",n.normalTexture)),o.normalScale=new be.Vector2(1,1),void 0!==n.normalTexture.scale)){const t=n.normalTexture.scale;o.normalScale.set(t,t)}return void 0!==n.occlusionTexture&&s!==be.MeshBasicMaterial&&(l.push(e.assignTexture(o,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(o.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&s!==be.MeshBasicMaterial&&(o.emissive=(new be.Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&s!==be.MeshBasicMaterial&&l.push(e.assignTexture(o,"emissiveMap",n.emissiveTexture,be.sRGBEncoding)),Promise.all(l).then((function(){let i;return i=s===Di?r[gi.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new s(o),n.name&&(i.name=n.name),sr(i,n),e.associations.set(i,{materials:t}),n.extensions&&nr(r,i,n),i}))}createUniqueName(t){const e=be.PropertyBinding.sanitizeNodeName(t||"");let i=e;for(let t=1;this.nodeNamesUsed[i];++t)i=e+"_"+t;return this.nodeNamesUsed[i]=!0,i}loadGeometries(t){const e=this,i=this.extensions,r=this.primitiveCache;function n(t){return i[gi.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(i){return ur(i,t,e)}))}const s=[];for(let i=0,o=t.length;i0&&or(d,n),d.name=e.createUniqueName(n.name||"mesh_"+t),sr(d,n),c.extensions&&nr(r,d,c),e.assignFinalMaterial(d),l.push(d)}for(let i=0,r=l.length;i1?new be.Group:1===e.length?e[0]:new be.Object3D,o!==e[0])for(let t=0,i=e.length;t{const e=new Map;for(const[t,i]of n.associations)(t instanceof be.Material||t instanceof be.Texture)&&e.set(t,i);return t.traverse((t=>{const i=n.associations.get(t);null!=i&&e.set(t,i)})),e})(s),s}))}}function dr(t,e,i,r){const n=i.nodes[t];return r.getDependency("node",t).then((function(t){if(void 0===n.skin)return t;let e;return r.getDependency("skin",n.skin).then((function(t){e=t;const i=[];for(let t=0,n=e.joints.length;t{const i={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(t,i).then(e).catch(r)}),i,r)}decodeDracoFile(t,e,i,r){const n={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};this.decodeGeometry(t,n).then(e)}decodeGeometry(t,e){for(const t in e.attributeTypes){const i=e.attributeTypes[t];void 0!==i.BYTES_PER_ELEMENT&&(e.attributeTypes[t]=i.name)}const i=JSON.stringify(e);if(mr.has(t)){const e=mr.get(t);if(e.key===i)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const n=this.workerNextTaskID++,s=t.byteLength,o=this._getWorker(n,s).then((i=>(r=i,new Promise(((i,s)=>{r._callbacks[n]={resolve:i,reject:s},r.postMessage({type:"decode",id:n,taskConfig:e,buffer:t},[t])}))))).then((t=>this._createGeometry(t.geometry)));return o.catch((()=>!0)).then((()=>{r&&n&&this._releaseTask(r,n)})),mr.set(t,{key:i,promise:o}),o}_createGeometry(t){const e=new be.BufferGeometry;t.index&&e.setIndex(new be.BufferAttribute(t.index.array,1));for(let i=0;i{i.load(t,e,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then((e=>{const i=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const r=gr.toString(),n=["/* draco decoder */",i,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n]))})),this.decoderPending}_getWorker(t,e){return this._initDecoder().then((()=>{if(this.workerPool.lengthe._taskLoad?-1:1}));const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i}))}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map((t=>t._taskLoad)))}dispose(){for(let t=0;t{const e=t.draco,o=new e.Decoder,a=new e.DecoderBuffer;a.Init(new Int8Array(r),r.byteLength);try{const t=function(t,e,r,n){const s=n.attributeIDs,o=n.attributeTypes;let a,l;const h=e.GetEncodedGeometryType(r);if(h===t.TRIANGULAR_MESH)a=new t.Mesh,l=e.DecodeBufferToMesh(r,a);else{if(h!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new t.PointCloud,l=e.DecodeBufferToPointCloud(r,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const c={index:null,attributes:[]};for(const r in s){const l=self[o[r]];let h,d;if(n.useUniqueIDs)d=s[r],h=e.GetAttributeByUniqueId(a,d);else{if(d=e.GetAttributeId(a,t[s[r]]),-1===d)continue;h=e.GetAttribute(a,d)}c.attributes.push(i(t,e,a,r,l,h))}h===t.TRIANGULAR_MESH&&(c.index=function(t,e,i){const r=3*i.num_faces(),n=4*r,s=t._malloc(n);e.GetTrianglesUInt32Array(i,n,s);const o=new Uint32Array(t.HEAPF32.buffer,s,r).slice();return t._free(s),{array:o,itemSize:1}}(t,e,a));return t.destroy(a),c}(e,o,a,s),r=t.attributes.map((t=>t.array.buffer));t.index&&r.push(t.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:t},r)}catch(t){console.error(t),self.postMessage({type:"error",id:n.id,error:t.message})}finally{e.destroy(a),e.destroy(o)}}))}}}var vr={},yr=Uint8Array,wr=Uint16Array,xr=Uint32Array,br=new yr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),_r=new yr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ar=new yr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Sr=function(t,e){for(var i=new wr(31),r=0;r<31;++r)i[r]=e+=1<>>1|(21845&Or)<<1;Fr=(61680&(Fr=(52428&Fr)>>>2|(13107&Fr)<<2))>>>4|(3855&Fr)<<4,Rr[Or]=((65280&Fr)>>>8|(255&Fr)<<8)>>>1}var Nr=function(t,e,i){for(var r=t.length,n=0,s=new wr(e);n>>l]=h}else for(o=new wr(r),n=0;n>>15-t[n]);return o},Dr=new yr(288);for(Or=0;Or<144;++Or)Dr[Or]=8;for(Or=144;Or<256;++Or)Dr[Or]=9;for(Or=256;Or<280;++Or)Dr[Or]=7;for(Or=280;Or<288;++Or)Dr[Or]=8;var Ir=new yr(32);for(Or=0;Or<32;++Or)Ir[Or]=5;var Ur=Nr(Dr,9,0),Br=Nr(Dr,9,1),kr=Nr(Ir,5,0),jr=Nr(Ir,5,1),Vr=function(t){for(var e=t[0],i=1;ie&&(e=t[i]);return e},zr=function(t,e,i){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&i},Gr=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(7&e)},Hr=function(t){return(t+7)/8|0},Xr=function(t,e,i){(null==e||e<0)&&(e=0),(null==i||i>t.length)&&(i=t.length);var r=new(2==t.BYTES_PER_ELEMENT?wr:4==t.BYTES_PER_ELEMENT?xr:yr)(i-e);return r.set(t.subarray(e,i)),r},Wr=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Yr=function(t,e,i){var r=new Error(e||Wr[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,Yr),!i)throw r;return r},Qr=function(t,e,i){var r=t.length;if(!r||i&&i.f&&!i.l)return e||new yr(0);var n=!e||i,s=!i||i.i;i||(i={}),e||(e=new yr(3*r));var o=function(t){var i=e.length;if(t>i){var r=new yr(Math.max(2*i,t));r.set(e),e=r}},a=i.f||0,l=i.p||0,h=i.b||0,c=i.l,d=i.d,u=i.m,p=i.n,m=8*r;do{if(!c){a=zr(t,l,1);var f=zr(t,l+1,3);if(l+=3,!f){var g=t[(P=Hr(l)+4)-4]|t[P-3]<<8,v=P+g;if(v>r){s&&Yr(0);break}n&&o(h+g),e.set(t.subarray(P,v),h),i.b=h+=g,i.p=l=8*v,i.f=a;continue}if(1==f)c=Br,d=jr,u=9,p=5;else if(2==f){var y=zr(t,l,31)+257,w=zr(t,l+10,15)+4,x=y+zr(t,l+5,31)+1;l+=14;for(var b=new yr(x),_=new yr(19),A=0;A>>4)<16)b[A++]=P;else{var C=0,L=0;for(16==P?(L=3+zr(t,l,3),l+=2,C=b[A-1]):17==P?(L=3+zr(t,l,7),l+=3):18==P&&(L=11+zr(t,l,127),l+=7);L--;)b[A++]=C}}var R=b.subarray(0,y),O=b.subarray(y);u=Vr(R),p=Vr(O),c=Nr(R,u,1),d=Nr(O,p,1)}else Yr(1);if(l>m){s&&Yr(0);break}}n&&o(h+131072);for(var F=(1<>>4;if((l+=15&C)>m){s&&Yr(0);break}if(C||Yr(2),I<256)e[h++]=I;else{if(256==I){D=l,c=null;break}var U=I-254;if(I>264){var B=br[A=I-257];U=zr(t,l,(1<>>4;k||Yr(3),l+=15&k;O=Cr[j];if(j>3){B=_r[j];O+=Gr(t,l)&(1<m){s&&Yr(0);break}n&&o(h+131072);for(var V=h+U;h>>8},Zr=function(t,e,i){i<<=7&e;var r=e/8|0;t[r]|=i,t[r+1]|=i>>>8,t[r+2]|=i>>>16},qr=function(t,e){for(var i=[],r=0;ru&&(u=s[r].s);var p=new wr(u+1),m=Kr(i[c-1],p,0);if(m>e){r=0;var f=0,g=m-e,v=1<e))break;f+=v-(1<>>=g;f>0;){var w=s[r].s;p[w]=0&&f;--r){var x=s[r].s;p[x]==e&&(--p[x],++f)}m=e}return[new yr(p),m]},Kr=function(t,e,i){return-1==t.s?Math.max(Kr(t.l,e,i+1),Kr(t.r,e,i+1)):e[t.s]=i},$r=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new wr(++e),r=0,n=t[0],s=1,o=function(t){i[r++]=t},a=1;a<=e;++a)if(t[a]==n&&a!=e)++s;else{if(!n&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=t[a]}return[i.subarray(0,r),e]},tn=function(t,e){for(var i=0,r=0;r>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var s=0;s4&&!E[Ar[M-1]];--M);var C,L,R,O,F=h+5<<3,N=tn(n,Dr)+tn(s,Ir)+o,D=tn(n,u)+tn(s,f)+o+14+3*M+tn(A,E)+(2*A[16]+3*A[17]+7*A[18]);if(F<=N&&F<=D)return en(e,c,t.subarray(l,l+h));if(Jr(e,c,1+(D15&&(Jr(e,c,k[S]>>>5&127),c+=k[S]>>>12)}}}else C=Ur,L=Dr,R=kr,O=Ir;for(S=0;S255){j=r[S]>>>18&31;Zr(e,c,C[j+257]),c+=L[j+257],j>7&&(Jr(e,c,r[S]>>>23&31),c+=br[j]);var V=31&r[S];Zr(e,c,R[V]),c+=O[V],V>3&&(Zr(e,c,r[S]>>>5&8191),c+=_r[V])}else Zr(e,c,C[r[S]]),c+=L[r[S]];return Zr(e,c,C[256]),c+L[256]},nn=new xr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),sn=new yr(0),on=function(t,e,i,r,n,s){var o=t.length,a=new yr(r+o+5*(1+Math.ceil(o/7e3))+n),l=a.subarray(r,a.length-n),h=0;if(!e||o<8)for(var c=0;c<=o;c+=65535){var d=c+65535;d>=o&&(l[h>>3]=s),h=en(l,h+1,t.subarray(c,d))}else{for(var u=nn[e-1],p=u>>>13,m=8191&u,f=(1<7e3||E>24576)&&O>423){h=rn(t,l,0,b,_,A,T,E,M,c-M,h),E=S=T=0,M=c;for(var F=0;F<286;++F)_[F]=0;for(F=0;F<30;++F)A[F]=0}var N=2,D=0,I=m,U=L-R&32767;if(O>2&&C==x(c-U))for(var B=Math.min(p,O)-1,k=Math.min(32767,c),j=Math.min(258,O);U<=k&&--I&&L!=R;){if(t[c+N]==t[c+N-U]){for(var V=0;VN){if(N=V,D=U,V>B)break;var z=Math.min(U,V-2),G=0;for(F=0;FG&&(G=X,R=H)}}}U+=(L=R)-(R=g[L])+32768&32767}if(D){b[E++]=268435456|Pr[N]<<18|Lr[D];var W=31&Pr[N],Y=31&Lr[D];T+=br[W]+_r[Y],++_[257+W],++A[Y],P=c+N,++S}else b[E++]=t[c],++_[t[c]]}}h=rn(t,l,s,b,_,A,T,E,M,c-M,h),!s&&7&h&&(h=en(l,h+1,sn))}return Xr(a,0,r+Hr(h)+n)},an=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var i=e,r=9;--r;)i=(1&i&&-306674912)^i>>>1;t[e]=i}return t}(),ln=function(){var t=-1;return{p:function(e){for(var i=t,r=0;r>>8;t=i},d:function(){return~t}}},hn=function(){var t=1,e=0;return{p:function(i){for(var r=t,n=e,s=0|i.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o>16),n=(65535&n)+15*(n>>16)}t=r,e=n},d:function(){return(255&(t%=65521))<<24|t>>>8<<16|(255&(e%=65521))<<8|e>>>8}}},cn=function(t,e,i,r,n){return on(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,i,r,!n)},dn=function(t,e){var i={};for(var r in t)i[r]=t[r];for(var r in e)i[r]=e[r];return i},un=function(t,e,i){for(var r=t(),n=t.toString(),s=n.slice(n.indexOf("[")+1,n.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o>>0},Mn=function(t,e){return Pn(t,e)+4294967296*Pn(t,e+4)},Cn=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8},Ln=function(t,e){var i=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&Cn(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),i){t[3]=8;for(var r=0;r<=i.length;++r)t[r+10]=i.charCodeAt(r)}},Rn=function(t){31==t[0]&&139==t[1]&&8==t[2]||Yr(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=t[10]|2+(t[11]<<8));for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!t[i++]);return i+(2&e)},On=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},Fn=function(t){return 10+(t.filename&&t.filename.length+1||0)},Nn=function(t,e){var i=e.level,r=0==i?0:i<6?1:9==i?3:2;t[0]=120,t[1]=r<<6|(r?32-2*r:1)},Dn=function(t){(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)&&Yr(6,"invalid zlib data"),32&t[1]&&Yr(6,"invalid zlib data: preset dictionaries not supported")};function In(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var Un=function(){function t(t,e){e||"function"!=typeof t||(e=t,t={}),this.ondata=e,this.o=t||{}}return t.prototype.p=function(t,e){this.ondata(cn(t,this.o,0,0,!e),e)},t.prototype.push=function(t,e){this.ondata||Yr(5),this.d&&Yr(4),this.d=e,this.p(t,e||!1)},t}(),Bn=function(){return function(t,e){Tn([gn,function(){return[Sn,Un]}],this,In.call(this,t,e),(function(t){var e=new Un(t.data);onmessage=Sn(e)}),6)}}();function kn(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&Yr(7),An(t,e,[gn],(function(t){return bn(jn(t.data[0],t.data[1]))}),0,i)}function jn(t,e){return cn(t,e||{},0,0)}var Vn=function(){function t(t){this.s={},this.p=new yr(0),this.ondata=t}return t.prototype.e=function(t){this.ondata||Yr(5),this.d&&Yr(4);var e=this.p.length,i=new yr(e+t.length);i.set(this.p),i.set(t,e),this.p=i},t.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,i=Qr(this.p,this.o,this.s);this.ondata(Xr(i,e,this.s.b),this.d),this.o=Xr(i,this.s.b-32768),this.s.b=this.o.length,this.p=Xr(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}(),zn=function(){return function(t){this.ondata=t,Tn([fn,function(){return[Sn,Vn]}],this,0,(function(){var t=new Vn;onmessage=Sn(t)}),7)}}();function Gn(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&Yr(7),An(t,e,[fn],(function(t){return bn(Hn(t.data[0],_n(t.data[1])))}),1,i)}function Hn(t,e){return Qr(t,e)}var Xn=function(){function t(t,e){this.c=ln(),this.l=0,this.v=1,Un.call(this,t,e)}return t.prototype.push=function(t,e){Un.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var i=cn(t,this.o,this.v&&Fn(this.o),e&&8,!e);this.v&&(Ln(i,this.o),this.v=0),e&&(Cn(i,i.length-8,this.c.d()),Cn(i,i.length-4,this.l)),this.ondata(i,e)},t}(),Wn=function(){return function(t,e){Tn([gn,vn,function(){return[Sn,Un,Xn]}],this,In.call(this,t,e),(function(t){var e=new Xn(t.data);onmessage=Sn(e)}),8)}}();function Yn(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&Yr(7),An(t,e,[gn,vn,function(){return[Qn]}],(function(t){return bn(Qn(t.data[0],t.data[1]))}),2,i)}function Qn(t,e){e||(e={});var i=ln(),r=t.length;i.p(t);var n=cn(t,e,Fn(e),8),s=n.length;return Ln(n,e),Cn(n,s-8,i.d()),Cn(n,s-4,r),n}var Jn=function(){function t(t){this.v=1,Vn.call(this,t)}return t.prototype.push=function(t,e){if(Vn.prototype.e.call(this,t),this.v){var i=this.p.length>3?Rn(this.p):4;if(i>=this.p.length&&!e)return;this.p=this.p.subarray(i),this.v=0}e&&(this.p.length<8&&Yr(6,"invalid gzip data"),this.p=this.p.subarray(0,-8)),Vn.prototype.c.call(this,e)},t}(),Zn=function(){return function(t){this.ondata=t,Tn([fn,yn,function(){return[Sn,Vn,Jn]}],this,0,(function(){var t=new Jn;onmessage=Sn(t)}),9)}}();function qn(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&Yr(7),An(t,e,[fn,yn,function(){return[Kn]}],(function(t){return bn(Kn(t.data[0]))}),3,i)}function Kn(t,e){return Qr(t.subarray(Rn(t),-8),e||new yr(On(t)))}var $n=function(){function t(t,e){this.c=hn(),this.v=1,Un.call(this,t,e)}return t.prototype.push=function(t,e){Un.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var i=cn(t,this.o,this.v&&2,e&&4,!e);this.v&&(Nn(i,this.o),this.v=0),e&&Cn(i,i.length-4,this.c.d()),this.ondata(i,e)},t}(),ts=function(){return function(t,e){Tn([gn,wn,function(){return[Sn,Un,$n]}],this,In.call(this,t,e),(function(t){var e=new $n(t.data);onmessage=Sn(e)}),10)}}();function es(t,e){e||(e={});var i=hn();i.p(t);var r=cn(t,e,2,4);return Nn(r,e),Cn(r,r.length-4,i.d()),r}var is=function(){function t(t){this.v=1,Vn.call(this,t)}return t.prototype.push=function(t,e){if(Vn.prototype.e.call(this,t),this.v){if(this.p.length<2&&!e)return;this.p=this.p.subarray(2),this.v=0}e&&(this.p.length<4&&Yr(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Vn.prototype.c.call(this,e)},t}(),rs=function(){return function(t){this.ondata=t,Tn([fn,xn,function(){return[Sn,Vn,is]}],this,0,(function(){var t=new is;onmessage=Sn(t)}),11)}}();function ns(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&Yr(7),An(t,e,[fn,xn,function(){return[ss]}],(function(t){return bn(ss(t.data[0],_n(t.data[1])))}),5,i)}function ss(t,e){return Qr((Dn(t),t.subarray(2,-4)),e)}var os=function(){function t(t){this.G=Jn,this.I=Vn,this.Z=is,this.ondata=t}return t.prototype.push=function(t,e){if(this.ondata||Yr(5),this.s)this.s.push(t,e);else{if(this.p&&this.p.length){var i=new yr(this.p.length+t.length);i.set(this.p),i.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var r=this,n=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(n):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(n):new this.Z(n),this.s.push(this.p,e),this.p=null}}},t}(),as=function(){function t(t){this.G=Zn,this.I=zn,this.Z=rs,this.ondata=t}return t.prototype.push=function(t,e){os.prototype.push.call(this,t,e)},t}();var ls=function(t,e,i,r){for(var n in t){var s=t[n],o=e+n,a=r;Array.isArray(s)&&(a=dn(r,s[1]),s=s[0]),s instanceof yr?i[o]=[s,a]:(i[o+="/"]=[new yr(0),a],ls(s,o,i,r))}},hs="undefined"!=typeof TextEncoder&&new TextEncoder,cs="undefined"!=typeof TextDecoder&&new TextDecoder,ds=0;try{cs.decode(sn,{stream:!0}),ds=1}catch(t){}var us=function(t){for(var e="",i=0;;){var r=t[i++],n=(r>127)+(r>223)+(r>239);if(i+n>t.length)return[e,Xr(t,i-1)];n?3==n?(r=((15&r)<<18|(63&t[i++])<<12|(63&t[i++])<<6|63&t[i++])-65536,e+=String.fromCharCode(55296|r>>10,56320|1023&r)):e+=1&n?String.fromCharCode((31&r)<<6|63&t[i++]):String.fromCharCode((15&r)<<12|(63&t[i++])<<6|63&t[i++]):e+=String.fromCharCode(r)}},ps=function(){function t(t){this.ondata=t,ds?this.t=new TextDecoder:this.p=sn}return t.prototype.push=function(t,e){if(this.ondata||Yr(5),e=!!e,this.t)return this.ondata(this.t.decode(t,{stream:!0}),e),void(e&&(this.t.decode().length&&Yr(8),this.t=null));this.p||Yr(4);var i=new yr(this.p.length+t.length);i.set(this.p),i.set(t,this.p.length);var r=us(i),n=r[0],s=r[1];e?(s.length&&Yr(8),this.p=null):this.p=s,this.ondata(n,e)},t}(),ms=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,e){this.ondata||Yr(5),this.d&&Yr(4),this.ondata(fs(t),this.d=e||!1)},t}();function fs(t,e){if(e){for(var i=new yr(t.length),r=0;r>1)),o=0,a=function(t){s[o++]=t};for(r=0;rs.length){var l=new yr(o+8+(n-r<<1));l.set(s),s=l}var h=t.charCodeAt(r);h<128||e?a(h):h<2048?(a(192|h>>6),a(128|63&h)):h>55295&&h<57344?(a(240|(h=65536+(1047552&h)|1023&t.charCodeAt(++r))>>18),a(128|h>>12&63),a(128|h>>6&63),a(128|63&h)):(a(224|h>>12),a(128|h>>6&63),a(128|63&h))}return Xr(s,0,o)}function gs(t,e){if(e){for(var i="",r=0;r65535&&Yr(9),e+=r+4}return e},_s=function(t,e,i,r,n,s,o,a){var l=r.length,h=i.extra,c=a&&a.length,d=bs(h);Cn(t,e,null!=o?33639248:67324752),e+=4,null!=o&&(t[e++]=20,t[e++]=i.os),t[e]=20,e+=2,t[e++]=i.flag<<1|(null==s&&8),t[e++]=n&&8,t[e++]=255&i.compression,t[e++]=i.compression>>8;var u=new Date(null==i.mtime?Date.now():i.mtime),p=u.getFullYear()-1980;if((p<0||p>119)&&Yr(10),Cn(t,e,p<<25|u.getMonth()+1<<21|u.getDate()<<16|u.getHours()<<11|u.getMinutes()<<5|u.getSeconds()>>>1),e+=4,null!=s&&(Cn(t,e,i.crc),Cn(t,e+4,s),Cn(t,e+8,i.size)),Cn(t,e+12,l),Cn(t,e+14,d),e+=16,null!=o&&(Cn(t,e,c),Cn(t,e+6,i.attrs),Cn(t,e+10,o),e+=14),t.set(r,e),e+=l,d)for(var m in h){var f=h[m],g=f.length;Cn(t,e,+m),Cn(t,e+2,g),t.set(f,e+4),e+=4+g}return c&&(t.set(a,e),e+=c),e},As=function(t,e,i,r,n){Cn(t,e,101010256),Cn(t,e+8,i),Cn(t,e+10,i),Cn(t,e+12,r),Cn(t,e+16,n)},Ss=function(){function t(t){this.filename=t,this.c=ln(),this.size=0,this.compression=0}return t.prototype.process=function(t,e){this.ondata(null,t,e)},t.prototype.push=function(t,e){this.ondata||Yr(5),this.c.p(t),this.size+=t.length,e&&(this.crc=this.c.d()),this.process(t,e||!1)},t}(),Ts=function(){function t(t,e){var i=this;e||(e={}),Ss.call(this,t),this.d=new Un(e,(function(t,e){i.ondata(null,t,e)})),this.compression=8,this.flag=vs(e.level)}return t.prototype.process=function(t,e){try{this.d.push(t,e)}catch(t){this.ondata(t,null,e)}},t.prototype.push=function(t,e){Ss.prototype.push.call(this,t,e)},t}(),Es=function(){function t(t,e){var i=this;e||(e={}),Ss.call(this,t),this.d=new Bn(e,(function(t,e,r){i.ondata(t,e,r)})),this.compression=8,this.flag=vs(e.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,e){this.d.push(t,e)},t.prototype.push=function(t,e){Ss.prototype.push.call(this,t,e)},t}(),Ps=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var e=this;if(this.ondata||Yr(5),2&this.d)this.ondata(Yr(4+8*(1&this.d),0,1),null,!1);else{var i=fs(t.filename),r=i.length,n=t.comment,s=n&&fs(n),o=r!=t.filename.length||s&&n.length!=s.length,a=r+bs(t.extra)+30;r>65535&&this.ondata(Yr(11,0,1),null,!1);var l=new yr(a);_s(l,0,t,i,o);var h=[l],c=function(){for(var t=0,i=h;t0){var r=Math.min(this.c,t.length),n=t.subarray(0,r);if(this.c-=r,this.d?this.d.push(n,!this.c):this.k[0].push(n),(t=t.subarray(r)).length)return this.push(t,e)}else{var s=0,o=0,a=void 0,l=void 0;this.p.length?t.length?((l=new yr(this.p.length+t.length)).set(this.p),l.set(t,this.p.length)):l=this.p:l=t;for(var h=l.length,c=this.c,d=c&&this.d,u=function(){var t,e=Pn(l,o);if(67324752==e){s=1,a=o,p.d=null,p.c=0;var r=En(l,o+6),n=En(l,o+8),d=2048&r,u=8&r,m=En(l,o+26),f=En(l,o+28);if(h>o+30+m+f){var g=[];p.k.unshift(g),s=2;var v,y=Pn(l,o+18),w=Pn(l,o+22),x=gs(l.subarray(o+30,o+=30+m),!d);4294967295==y?(t=u?[-2]:xs(l,o),y=t[0],w=t[1]):u&&(y=-1),o+=f,p.c=y;var b={name:x,compression:n,start:function(){if(b.ondata||Yr(5),y){var t=i.o[n];t||b.ondata(Yr(14,"unknown compression type "+n,1),null,!1),(v=y<0?new t(x):new t(x,y,w)).ondata=function(t,e,i){b.ondata(t,e,i)};for(var e=0,r=g;e=0&&(b.size=y,b.originalSize=w),p.onfile(b)}return"break"}if(c){if(134695760==e)return a=o+=12+(-2==c&&8),s=3,p.c=0,"break";if(33639248==e)return a=o-=4,s=3,p.c=0,"break"}},p=this;o>4>7||(t[0]<<8|t[1])%31?Gn(t,e,i):ns(t,e,i)},decompressSync:function(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?Kn(t,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Hn(t,e):ss(t,e)},DecodeUTF8:ps,EncodeUTF8:ms,strToU8:fs,strFromU8:gs,ZipPassThrough:Ss,ZipDeflate:Ts,AsyncZipDeflate:Es,Zip:Ps,zip:function(t,e,i){i||(i=e,e={}),"function"!=typeof i&&Yr(7);var r={};ls(t,"",r,e);var n=Object.keys(r),s=n.length,o=0,a=0,l=s,h=new Array(s),c=[],d=function(){for(var t=0;t65535&&S(Yr(11,0,1),null),A)if(g<16e4)try{S(null,jn(l,m))}catch(t){S(t,null)}else c.push(kn(l,m,S));else S(null,l)},f=0;f65535&&Yr(11);var g=c?jn(l,h):l,v=g.length,y=ln();y.p(l),r.push(dn(h,{size:l.length,crc:y.d(),c:g,f:A,m:p,u:d!=o.length||p&&u.length!=m,o:n,compression:c})),n+=30+d+f+v,s+=76+2*(d+f)+(m||0)+v}for(var w=new yr(s+22),x=n,b=s-n,_=0;_65558)return o(Yr(13,0,1),null),n;var l=En(t,a+8);if(l){var h=l,c=Pn(t,a+16),d=4294967295==c;if(d){if(a=Pn(t,a-12),101075792!=Pn(t,a))return o(Yr(13,0,1),null),n;h=l=Pn(t,a+32),c=Pn(t,a+48)}for(var u=e&&e.filter,p=function(e){var i=ws(t,c,d),a=i[0],h=i[1],p=i[2],m=i[3],f=i[4],g=i[5],v=ys(t,g);c=f;var y=function(t,e){t?(n(),o(t,null)):(e&&(s[m]=e),--l||o(null,s))};if(!u||u({name:m,size:h,originalSize:p,compression:a}))if(a)if(8==a){var w=t.subarray(v,v+h);if(h<32e4)try{y(null,Hn(w,new yr(p)))}catch(t){y(t,null)}else r.push(Gn(w,{size:p},y))}else y(Yr(14,"unknown compression type "+a,1),null);else y(null,Xr(t,v,v+h));else y(null,null)},m=0;m65558)&&Yr(13);var n=En(t,r+8);if(!n)return{};var s=Pn(t,r+16),o=4294967295==s;o&&(r=Pn(t,r-12),101075792!=Pn(t,r)&&Yr(13),n=Pn(t,r+32),s=Pn(t,r+48));for(var a=e&&e.filter,l=0;l=e.length&&e===to(t,0,e.length)}(t))Ns=(new zs).parse(t);else{const e=to(t);if(!function(t){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let i=0;function r(e){const r=t[e-1];return t=t.slice(i+e),i++,r}for(let t=0;t0,s="string"==typeof n.Content&&""!==n.Content;if(t||s){const t=this.parseImage(i[r]);e[n.RelativeFilename||n.Filename]=t}}}}for(const i in t){const r=t[i];void 0!==e[r]?t[i]=e[r]:t[i]=t[i].split("\\").pop()}return t}parseImage(t){const e=t.Content,i=t.RelativeFilename||t.Filename,r=i.slice(i.lastIndexOf(".")+1).toLowerCase();let n;switch(r){case"bmp":n="image/bmp";break;case"jpg":case"jpeg":n="image/jpeg";break;case"png":n="image/png";break;case"tif":n="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),n="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof e)return"data:"+n+";base64,"+e;{const t=new Uint8Array(e);return window.URL.createObjectURL(new Blob([t],{type:n}))}}parseTextures(t){const e=new Map;if("Texture"in Ns.Objects){const i=Ns.Objects.Texture;for(const r in i){const n=this.parseTexture(i[r],t);e.set(parseInt(r),n)}}return e}parseTexture(t,e){const i=this.loadTexture(t,e);i.ID=t.id,i.name=t.attrName;const r=t.WrapModeU,n=t.WrapModeV,s=void 0!==r?r.value:0,o=void 0!==n?n.value:0;if(i.wrapS=0===s?be.RepeatWrapping:be.ClampToEdgeWrapping,i.wrapT=0===o?be.RepeatWrapping:be.ClampToEdgeWrapping,"Scaling"in t){const e=t.Scaling.value;i.repeat.x=e[0],i.repeat.y=e[1]}if("Translation"in t){const e=t.Translation.value;i.offset.x=e[0],i.offset.y=e[1]}return i}loadTexture(t,e){let i;const r=this.textureLoader.path,n=Ds.get(t.id).children;let s;void 0!==n&&n.length>0&&void 0!==e[n[0].ID]&&(i=e[n[0].ID],0!==i.indexOf("blob:")&&0!==i.indexOf("data:")||this.textureLoader.setPath(void 0));const o=t.FileName.slice(-3).toLowerCase();if("tga"===o){const e=this.manager.getHandler(".tga");null===e?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),s=new be.Texture):(e.setPath(this.textureLoader.path),s=e.load(i))}else"psd"===o?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),s=new be.Texture):s=this.textureLoader.load(i);return this.textureLoader.setPath(r),s}parseMaterials(t){const e=new Map;if("Material"in Ns.Objects){const i=Ns.Objects.Material;for(const r in i){const n=this.parseMaterial(i[r],t);null!==n&&e.set(parseInt(r),n)}}return e}parseMaterial(t,e){const i=t.id,r=t.attrName;let n=t.ShadingModel;if("object"==typeof n&&(n=n.value),!Ds.has(i))return null;const s=this.parseParameters(t,e,i);let o;switch(n.toLowerCase()){case"phong":o=new be.MeshPhongMaterial;break;case"lambert":o=new be.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to THREE.MeshPhongMaterial.',n),o=new be.MeshPhongMaterial}return o.setValues(s),o.name=r,o}parseParameters(t,e,i){const r={};t.BumpFactor&&(r.bumpScale=t.BumpFactor.value),t.Diffuse?r.color=(new be.Color).fromArray(t.Diffuse.value):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(r.color=(new be.Color).fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(r.displacementScale=t.DisplacementFactor.value),t.Emissive?r.emissive=(new be.Color).fromArray(t.Emissive.value):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(r.emissive=(new be.Color).fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(r.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(r.opacity=parseFloat(t.Opacity.value)),r.opacity<1&&(r.transparent=!0),t.ReflectionFactor&&(r.reflectivity=t.ReflectionFactor.value),t.Shininess&&(r.shininess=t.Shininess.value),t.Specular?r.specular=(new be.Color).fromArray(t.Specular.value):t.SpecularColor&&"Color"===t.SpecularColor.type&&(r.specular=(new be.Color).fromArray(t.SpecularColor.value));const n=this;return Ds.get(i).children.forEach((function(t){const i=t.relationship;switch(i){case"Bump":r.bumpMap=n.getTexture(e,t.ID);break;case"Maya|TEX_ao_map":r.aoMap=n.getTexture(e,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=n.getTexture(e,t.ID),void 0!==r.map&&(r.map.encoding=be.sRGBEncoding);break;case"DisplacementColor":r.displacementMap=n.getTexture(e,t.ID);break;case"EmissiveColor":r.emissiveMap=n.getTexture(e,t.ID),void 0!==r.emissiveMap&&(r.emissiveMap.encoding=be.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=n.getTexture(e,t.ID);break;case"ReflectionColor":r.envMap=n.getTexture(e,t.ID),void 0!==r.envMap&&(r.envMap.mapping=be.EquirectangularReflectionMapping,r.envMap.encoding=be.sRGBEncoding);break;case"SpecularColor":r.specularMap=n.getTexture(e,t.ID),void 0!==r.specularMap&&(r.specularMap.encoding=be.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=n.getTexture(e,t.ID),r.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",i)}})),r}getTexture(t,e){return"LayeredTexture"in Ns.Objects&&e in Ns.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=Ds.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in Ns.Objects){const i=Ns.Objects.Deformer;for(const r in i){const n=i[r],s=Ds.get(parseInt(r));if("Skin"===n.attrType){const e=this.parseSkeleton(s,i);e.ID=r,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),e.geometryID=s.parents[0].ID,t[r]=e}else if("BlendShape"===n.attrType){const t={id:r};t.rawTargets=this.parseMorphTargets(s,i),t.id=r,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),e[r]=t}}}return{skeletons:t,morphTargets:e}}parseSkeleton(t,e){const i=[];return t.children.forEach((function(t){const r=e[t.ID];if("Cluster"!==r.attrType)return;const n={ID:t.ID,indices:[],weights:[],transformLink:(new be.Matrix4).fromArray(r.TransformLink.a)};"Indexes"in r&&(n.indices=r.Indexes.a,n.weights=r.Weights.a),i.push(n)})),{rawBones:i,bones:[]}}parseMorphTargets(t,e){const i=[];for(let r=0;r1?s=o:o.length>0?s=o[0]:(s=new be.MeshPhongMaterial({color:13421772}),o.push(s)),"color"in n.attributes&&o.forEach((function(t){t.vertexColors=!0})),n.FBX_Deformer?(r=new be.SkinnedMesh(n,s),r.normalizeSkinWeights()):r=new be.Mesh(n,s),r}createCurve(t,e){const i=t.children.reduce((function(t,i){return e.has(i.ID)&&(t=e.get(i.ID)),t}),null),r=new be.LineBasicMaterial({color:3342591,linewidth:1});return new be.Line(i,r)}getTransformData(t,e){const i={};"InheritType"in e&&(i.inheritType=parseInt(e.InheritType.value)),i.eulerOrder="RotationOrder"in e?Ks(e.RotationOrder.value):"ZYX","Lcl_Translation"in e&&(i.translation=e.Lcl_Translation.value),"PreRotation"in e&&(i.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(i.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(i.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(i.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(i.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(i.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(i.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(i.rotationPivot=e.RotationPivot.value),t.userData.transformData=i}setLookAtProperties(t,e){if("LookAtProperty"in e){Ds.get(t.ID).children.forEach((function(e){if("LookAtProperty"===e.relationship){const i=Ns.Objects.Model[e.ID];if("Lcl_Translation"in i){const e=i.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(e),Is.add(t.target)):t.lookAt((new be.Vector3).fromArray(e))}}}))}}bindSkeleton(t,e,i){const r=this.parsePoseNodes();for(const n in t){const s=t[n];Ds.get(parseInt(s.ID)).parents.forEach((function(t){if(e.has(t.ID)){const e=t.ID;Ds.get(e).parents.forEach((function(t){if(i.has(t.ID)){i.get(t.ID).bind(new be.Skeleton(s.bones),r[t.ID])}}))}}))}}parsePoseNodes(){const t={};if("Pose"in Ns.Objects){const e=Ns.Objects.Pose;for(const i in e)if("BindPose"===e[i].attrType&&e[i].NbPoseNodes>0){const r=e[i].PoseNode;Array.isArray(r)?r.forEach((function(e){t[e.Node]=(new be.Matrix4).fromArray(e.Matrix.a)})):t[r.Node]=(new be.Matrix4).fromArray(r.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in Ns&&"AmbientColor"in Ns.GlobalSettings){const t=Ns.GlobalSettings.AmbientColor.value,e=t[0],i=t[1],r=t[2];if(0!==e||0!==i||0!==r){const t=new be.Color(e,i,r);Is.add(new be.AmbientLight(t,1))}}}}class ks{parse(t){const e=new Map;if("Geometry"in Ns.Objects){const i=Ns.Objects.Geometry;for(const r in i){const n=Ds.get(parseInt(r)),s=this.parseGeometry(n,i[r],t);e.set(parseInt(r),s)}}return e}parseGeometry(t,e,i){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,i);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(t,e,i){const r=i.skeletons,n=[],s=t.parents.map((function(t){return Ns.Objects.Model[t.ID]}));if(0===s.length)return;const o=t.children.reduce((function(t,e){return void 0!==r[e.ID]&&(t=r[e.ID]),t}),null);t.children.forEach((function(t){void 0!==i.morphTargets[t.ID]&&n.push(i.morphTargets[t.ID])}));const a=s[0],l={};"RotationOrder"in a&&(l.eulerOrder=Ks(a.RotationOrder.value)),"InheritType"in a&&(l.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(l.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(l.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(l.scale=a.GeometricScaling.value);const h=qs(l);return this.genGeometry(e,o,n,h)}genGeometry(t,e,i,r){const n=new be.BufferGeometry;t.attrName&&(n.name=t.attrName);const s=this.parseGeoNode(t,e),o=this.genBuffers(s),a=new be.Float32BufferAttribute(o.vertex,3);if(a.applyMatrix4(r),n.setAttribute("position",a),o.colors.length>0&&n.setAttribute("color",new be.Float32BufferAttribute(o.colors,3)),e&&(n.setAttribute("skinIndex",new be.Uint16BufferAttribute(o.weightsIndices,4)),n.setAttribute("skinWeight",new be.Float32BufferAttribute(o.vertexWeights,4)),n.FBX_Deformer=e),o.normal.length>0){const t=(new be.Matrix3).getNormalMatrix(r),e=new be.Float32BufferAttribute(o.normal,3);e.applyNormalMatrix(t),n.setAttribute("normal",e)}if(o.uvs.forEach((function(t,e){let i="uv"+(e+1).toString();0===e&&(i="uv"),n.setAttribute(i,new be.Float32BufferAttribute(o.uvs[e],2))})),s.material&&"AllSame"!==s.material.mappingType){let t=o.materialIndex[0],e=0;if(o.materialIndex.forEach((function(i,r){i!==t&&(n.addGroup(e,r-e,t),t=i,e=r)})),n.groups.length>0){const e=n.groups[n.groups.length-1],i=e.start+e.count;i!==o.materialIndex.length&&n.addGroup(i,o.materialIndex.length-i,t)}0===n.groups.length&&n.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(n,t,i,r),n}parseGeoNode(t,e){const i={};if(i.vertexPositions=void 0!==t.Vertices?t.Vertices.a:[],i.vertexIndices=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(i.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(i.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(i.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){i.uv=[];let e=0;for(;t.LayerElementUV[e];)t.LayerElementUV[e].UV&&i.uv.push(this.parseUVs(t.LayerElementUV[e])),e++}return i.weightTable={},null!==e&&(i.skeleton=e,e.rawBones.forEach((function(t,e){t.indices.forEach((function(r,n){void 0===i.weightTable[r]&&(i.weightTable[r]=[]),i.weightTable[r].push({id:e,weight:t.weights[n]})}))}))),i}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let i=0,r=0,n=!1,s=[],o=[],a=[],l=[],h=[],c=[];const d=this;return t.vertexIndices.forEach((function(u,p){let m,f=!1;u<0&&(u^=-1,f=!0);let g=[],v=[];if(s.push(3*u,3*u+1,3*u+2),t.color){const e=Qs(p,i,u,t.color);a.push(e[0],e[1],e[2])}if(t.skeleton){if(void 0!==t.weightTable[u]&&t.weightTable[u].forEach((function(t){v.push(t.weight),g.push(t.id)})),v.length>4){n||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),n=!0);const t=[0,0,0,0],e=[0,0,0,0];v.forEach((function(i,r){let n=i,s=g[r];e.forEach((function(e,i,r){if(n>e){r[i]=n,n=e;const o=t[i];t[i]=s,s=o}}))})),g=t,v=e}for(;v.length<4;)v.push(0),g.push(0);for(let t=0;t<4;++t)h.push(v[t]),c.push(g[t])}if(t.normal){const e=Qs(p,i,u,t.normal);o.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(m=Qs(p,i,u,t.material)[0]),t.uv&&t.uv.forEach((function(t,e){const r=Qs(p,i,u,t);void 0===l[e]&&(l[e]=[]),l[e].push(r[0]),l[e].push(r[1])})),r++,f&&(d.genFace(e,t,s,m,o,a,l,h,c,r),i++,r=0,s=[],o=[],a=[],l=[],h=[],c=[])})),e}genFace(t,e,i,r,n,s,o,a,l,h){for(let c=2;c1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=t.get(n[0].ID);i[r]={name:e[r].attrName,layer:s}}return i}addClip(t){let e=[];const i=this;return t.layer.forEach((function(t){e=e.concat(i.generateTracks(t))})),new be.AnimationClip(t.name,-1,e)}generateTracks(t){const e=[];let i=new be.Vector3,r=new be.Quaternion,n=new be.Vector3;if(t.transform&&t.transform.decompose(i,r,n),i=i.toArray(),r=(new be.Euler).setFromQuaternion(r,t.eulerOrder).toArray(),n=n.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const r=this.generateVectorTrack(t.modelName,t.T.curves,i,"position");void 0!==r&&e.push(r)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const i=this.generateRotationTrack(t.modelName,t.R.curves,r,t.preRotation,t.postRotation,t.eulerOrder);void 0!==i&&e.push(i)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const i=this.generateVectorTrack(t.modelName,t.S.curves,n,"scale");void 0!==i&&e.push(i)}if(void 0!==t.DeformPercent){const i=this.generateMorphTrack(t);void 0!==i&&e.push(i)}return e}generateVectorTrack(t,e,i,r){const n=this.getTimesForAllAxes(e),s=this.getKeyframeTrackValues(n,e,i);return new be.VectorKeyframeTrack(t+"."+r,n,s)}generateRotationTrack(t,e,i,r,n,s){void 0!==e.x&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(be.MathUtils.degToRad)),void 0!==e.y&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(be.MathUtils.degToRad)),void 0!==e.z&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(be.MathUtils.degToRad));const o=this.getTimesForAllAxes(e),a=this.getKeyframeTrackValues(o,e,i);void 0!==r&&((r=r.map(be.MathUtils.degToRad)).push(s),r=(new be.Euler).fromArray(r),r=(new be.Quaternion).setFromEuler(r)),void 0!==n&&((n=n.map(be.MathUtils.degToRad)).push(s),n=(new be.Euler).fromArray(n),n=(new be.Quaternion).setFromEuler(n).invert());const l=new be.Quaternion,h=new be.Euler,c=[];for(let t=0;t1){let t=1,i=e[0];for(let r=1;r=180){const s=n/180,o=r/s;let a=i+o;const l=t.times[e-1],h=(t.times[e]-l)/s;let c=l+h;const d=[],u=[];for(;c1&&(i=t[1].replace(/^(\w+)::/,""),r=t[2]),{id:e,name:i,type:r}}parseNodeProperty(t,e,i){let r=e[1].replace(/^"/,"").replace(/"$/,"").trim(),n=e[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===n&&(n=i.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===r){const t=n.split(",").slice(1),e=parseInt(t[0]),i=parseInt(t[1]);let o=n.split(",").slice(3);o=o.map((function(t){return t.trim().replace(/^"/,"")})),r="connections",n=[e,i],function(t,e){for(let i=0,r=t.length,n=e.length;i=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const i={},r=e>=7500?t.getUint64():t.getUint32(),n=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const s=t.getUint8(),o=t.getString(s);if(0===r)return null;const a=[];for(let e=0;e0?a[0]:"",h=a.length>1?a[1]:"",c=a.length>2?a[2]:"";for(i.singleProperty=1===n&&t.getOffset()===r;r>t.getOffset();){const r=this.parseNode(t,e);null!==r&&this.parseSubNode(o,i,r)}return i.propertyList=a,"number"==typeof l&&(i.id=l),""!==h&&(i.attrName=h),""!==c&&(i.attrType=c),""!==o&&(i.name=o),i}parseSubNode(t,e,i){if(!0===i.singleProperty){const t=i.propertyList[0];Array.isArray(t)?(e[i.name]=i,i.a=t):e[i.name]=t}else if("Connections"===t&&"C"===i.name){const t=[];i.propertyList.forEach((function(e,i){0!==i&&t.push(e)})),void 0===e.connections&&(e.connections=[]),e.connections.push(t)}else if("Properties70"===i.name){Object.keys(i).forEach((function(t){e[t]=i[t]}))}else if("Properties70"===t&&"P"===i.name){let t=i.propertyList[0],r=i.propertyList[1];const n=i.propertyList[2],s=i.propertyList[3];let o;0===t.indexOf("Lcl ")&&(t=t.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),o="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[i.propertyList[4],i.propertyList[5],i.propertyList[6]]:i.propertyList[4],e[t]={type:r,type2:n,flag:s,value:o}}else void 0===e[i.name]?"number"==typeof i.id?(e[i.name]={},e[i.name][i.id]=i):e[i.name]=i:"PoseNode"===i.name?(Array.isArray(e[i.name])||(e[i.name]=[e[i.name]]),e[i.name].push(i)):void 0===e[i.name][i.id]&&(e[i.name][i.id]=i)}parseProperty(t){const e=t.getString(1);let i;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return i=t.getUint32(),t.getArrayBuffer(i);case"S":return i=t.getUint32(),t.getString(i);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=t.getUint32(),n=t.getUint32(),s=t.getUint32();if(0===n)switch(e){case"b":case"c":return t.getBooleanArray(r);case"d":return t.getFloat64Array(r);case"f":return t.getFloat32Array(r);case"i":return t.getInt32Array(r);case"l":return t.getInt64Array(r)}void 0===Fs&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const o=ss(new Uint8Array(t.getArrayBuffer(s))),a=new Gs(o.buffer);switch(e){case"b":case"c":return a.getBooleanArray(r);case"d":return a.getFloat64Array(r);case"f":return a.getFloat32Array(r);case"i":return a.getInt32Array(r);case"l":return a.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class Gs{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===e||e}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(t){const e=[];for(let i=0;i=0&&(e=e.slice(0,i)),be.LoaderUtils.decodeText(new Uint8Array(e))}}class Hs{add(t,e){this[t]=e}}function Xs(t){const e=t.match(/FBXVersion: (\d+)/);if(e){return parseInt(e[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Ws(t){return t/46186158e3}const Ys=[];function Qs(t,e,i,r){let n;switch(r.mappingType){case"ByPolygonVertex":n=t;break;case"ByPolygon":n=e;break;case"ByVertice":n=i;break;case"AllSame":n=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(n=r.indices[n]);const s=n*r.dataSize,o=s+r.dataSize;return function(t,e,i,r){for(let n=i,s=0;n{e.onerror=()=>{console.log("error: create db error"),i()},e.onupgradeneeded=t=>{t.currentTarget.result.createObjectStore(this._cacheTableName,{keyPath:"id"}).createIndex("INDEX_ID","id",{unique:!0})},e.onsuccess=e=>{t(e.target.result)}}))}async get(t){return this._db=await this.initDB(),new Promise(((e,i)=>{let r=this._db.transaction(this._cacheTableName,"readwrite").objectStore(this._cacheTableName).get(t);r.onsuccess=t=>{r.result?e(r.result.resource):this.resolve(null)},r.onerror=()=>{e(t)}}))}async set(t){return this._db=await this.initDB(),new Promise(((e,i)=>{let r=this._db.transaction(this._cacheTableName,"readwrite").objectStore(this._cacheTableName).add({id:t.id,resource:t.data});r.onerror=e=>{i(t)},r.onsuccess=i=>{e(t)}}))}clear(){if(!this._db)return;this._db.transaction(this._cacheTableName,"readwrite").objectStore(this._cacheTableName).clear()}async loadNetSource(t){return new Promise(((e,i)=>{fetch(t).then((r=>{200===r.status?r.blob().then((r=>{let n=this._db.transaction(this._cacheTableName,"readwrite").objectStore(this._cacheTableName).add({id:t,blob:r});n.onerror=e=>{console.log("缓存失败"),i(t)},n.onsuccess=i=>{console.log(`创建${t}缓存成功`),e(r)}})):(console.log("未找到缓存资源"),i(t))}))}))}async cacheModel(t){return this._db=await this.initDB(),new Promise(((e,i)=>{let r=this._db.transaction(this._cacheTableName,"readwrite").objectStore(this._cacheTableName).get(t);r.onsuccess=i=>{if(!r.result)return void this.loadNetSource(t).then((t=>{let i=URL.createObjectURL(t);e(i)})).catch((i=>{e(t)}));let n=URL.createObjectURL(r.result.blob);e(n)},r.onerror=()=>{e(t)}}))}async deleteModel(t){return new Promise(((e,i)=>{let r=this._db.transaction(this._cacheTableName,"readwrite").objectStore(this._cacheTableName).get(t);r.onsuccess=()=>{console.log("删除成功"),e("删除成功")},r.onerror=t=>{console.log("删除失败"),i(t)}}))}};window.dbUtil=io;const{EventDispatcher:ro,FileLoader:no,TextureLoader:so,ImageLoader:oo}=be,ao=1,lo=2,ho=3,co="resource.error",uo="resource.loaded";class po extends ui{constructor(t,e,i){if(!t||!Q(t))throw new Error("Resource ID must be uri");super(),this.id=t,this.data=null,this.fileType=_t(t),this.type=e,this.count=0,this.progress=0,this.objects=[],this.config=i,this.status=Qt,this.updated=(new Date).getTime(),io.initDB()}addObject(t,e){t&&(this.hasObject(t)||(this.objects.push(t),this.data&&this.status===Zt?t.dispatchEvent({type:uo,resource:this,config:e}):this.status===qt?t.dispatchEvent({type:co,resource:this,config:e}):(this.once("loaded",(i=>{t.dispatchEvent({type:uo,resource:this,config:e})})),this.once("error",(i=>{t.dispatchEvent({type:co,resource:this,message:i.message,config:e})})))))}removeObject(t){t&&st(this.objects,"uuid",t.uuid)}hasObject(t){let e=!1;if(t)for(let i=0;i{this.fire({type:"loaded"})}),((t,e,i)=>{const r=ct(e/i*100,1);this.fire({type:"progress",progress:r,url:t,total:i})})),this.materials={},this.geometries={},this.textures={},this.objects={},this.materialsRefCounter=new Map,W(t)){const e=ot(t,((t,e)=>t.type===e.type&&t.id===e.id));e.forEach((t=>{this.set(t.id,t.type)}))}this.addEventListener(uo,(t=>{if(t.requestAll){const t=this.getResourcesCount();this._loadedStep+=1;let e=Math.round(100*this._loadedStep/t);100===e?(this._loadedStep=0,this._allLoading=ho):this._allLoading=lo,this.dispatchEvent({type:"progress.update",progress:e})}}))}transformUrl(t){return 0==t.indexOf("./")||0==t.indexOf("//")||0==t.indexOf("http://")||t.indexOf("https://"),t}setViewer(t){this.viewer=t}getRenderer(){const t=this.viewer;return t&&t.rendererManager.renderer}getMaxAnisotropy(){const t=this.getRenderer();return t&&t.capabilities.getMaxAnisotropy()||1}getResourcesCount(){return Object.keys(this.data).length}preloadAll(){if(this._allLoading!==lo){this._allLoading=ao;for(const t in this.data){const e=t.split("_");this.preload(e[0],e[1],!0)}}}toJSON(){const t=[];for(const e in this.data){const i=this.data[e];t[e]={type:i.type}}return t}get(t,e){if(!t||!e)return null;let i=t+"_"+e;return this.data[i]}getById(t){for(const e in Kt){let i=e.toLocaleLowerCase()+"_"+t;const r=this.data[i];if(r)return r}return null}getData(t,e){const i=this.get(t,e);return i&&i.status==Zt?i.data:null}set(t){const{id:e,type:i,object:r,data:n,config:s,cache:o}=t||{};if(!e||!i)return null;const a=i+"_"+e;let l=this.data[a];return l&&l.type===i?(r&&l.addObject(r,s),l.status===Zt&&this.dispatchEvent({type:uo,resource:l}),l):(l||(this.list.push({id:a,type:i}),l=this.data[a]=new po(e,i,s),l.cache=o,n&&this.setResourceData(l,n)),r&&l.addObject(r,s),l.status===Qt&&this.preload(e,i),l.status===Zt?(this.dispatchEvent({type:uo,resource:l}),l):l)}preload(t,e,i){if(t&&e&&this.get(e,t))switch(e){case Kt.IMAGE:this.preloadImage(t,i);break;case Kt.TEXTURE:this.preloadTexture(t,i);break;case Kt.MODEL:this.preloadModel(t,i);break;case Kt.CubeTexture:this.preloadCubeTexture(t,i);break;case Kt.WebView:this.preloadWebView(t,i);break;case Kt.SHADER:break;case Kt.VIDEO:this.preloadVideo(t,i)}}clear(){this.data={},this.list=[],this._preloadAllSign=!1,this.dispatchEvent({type:"clear"})}delete(t,e){const i=this.get(t,e);let r=!0,n="";return i&&(e=t+"_"+e,i.refCount>0?(r=!1,n="Some objects are referencing resource, the resource can't be deleted"):(delete this.data[e],st(this.list,"id",e))),{status:r,error:n,resource:i}}preloadVideo(t,e){const i=this.get(Kt.VIDEO,t);if(!i)return;if(i.status===Zt)return void this.dispatchEvent({type:uo,resource:i,requestAll:e});i.isVideo=!0,i.status=Jt;const r=i.config||{},{loop:n,muted:s,autoplay:o,uvRepeat:a}=r.oldTextureConfig||r;let l=r.width||1920,h=r.height||1080;const c=document.createElement("video");c.id=be.Math.generateUUID(),c.width=l,c.height=h,c.style.width=l+"px",c.style.height=h+"px",c.src=this.transformUrl(i.id),c.muted=!0,c.autoplay=void 0===o||!!o,c.loop=void 0===n||!!n,c.style.display="none",c.autoplay&&c.play();const d=new be.VideoTexture(c);d.wrapS=be.ClampToEdgeWrapping,d.wrapT=be.ClampToEdgeWrapping,d.minFilter=be.LinearFilter,d.magFilter=be.LinearFilter,d.format=be.RGBAFormat,d.encoding=be.sRGBEncoding,d.image.crossOrigin="*",this.setResourceData(i,d,e),setTimeout((()=>{d.image.muted=!!s}),3e3)}preloadTexture(t,e){const i=this.get(Kt.TEXTURE,t);if(!i||i.type!==Kt.TEXTURE)return;if(i.status===Jt)return;if(i.status===Zt)return void this.dispatchEvent({type:uo,resource:i,requestAll:e});i.status=Jt;const r=this;_t(i.id||"").indexOf("mp4")>=0?this.preloadVideo(t,e):new so(this.loadingManager).setCrossOrigin("anonymous").load(this.transformUrl(i.id),(t=>{const n=t.image;t.encoding=be.sRGBEncoding,n&&(wt(n.width)&&wt(n.height)?(t.wrapS=be.RepeatWrapping,t.wrapT=be.RepeatWrapping,t.minFilter=be.LinearMipmapLinearFilter,t.magFilter=be.LinearFilter):(t.wrapS=be.ClampToEdgeWrapping,t.wrapT=be.ClampToEdgeWrapping,t.minFilter=be.LinearFilter,t.magFilter=be.LinearFilter),t.anisotropy=r.getMaxAnisotropy()),r.setResourceData(i,t,e)}),void 0,(t=>{r.setResourceError(i,null,e)}))}preloadCubeTexture(t,e){const i=this.get(Kt.CubeTexture,t);if(!i||i.type!==Kt.CubeTexture)return;if(i.status===Jt)return;if(i.status===Zt)return void this.dispatchEvent({type:uo,resource:i,requestAll:e});if(!i.config&&!i.config.path)return void this.setResourceError(i,"CubeTexture Resource Config is null",e);i.status=Jt;let r=this.transformUrl(i.config.path);const n=i.config.files||["posx.jpg","negx.jpg","posy.jpg","negy.jpg","posz.jpg","negz.jpg"],s=new be.CubeTextureLoader(this.loadingManager);r&&s.setPath(r),s.load(n,(t=>{t.format=be.RGBAFormat,t.encoding=be.sRGBEncoding,this.setResourceData(i,t,e)}),null,(t=>{this.setResourceError(i,"CubeTexture init error",e)}))}preloadImage(t,e){const i=this.get(Kt.IMAGE,t);if(!i||i.type!==Kt.IMAGE)return;if(i.status===Zt)return void this.dispatchEvent({type:uo,resource:i,requestAll:e});const r=this;i.width=0,i.height=0;const n=new oo(this.loadingManager);n.setCrossOrigin("*"),n.load(this.transformUrl(i.id),(t=>{i.width=t.width,i.height=t.height,r.setResourceData(i,t,e)}),null,(t=>{i.data=rt,i.progress=-1,i.status=qt,r.setResourceError(i,null,e)}))}preloadWebView(t,e){const i=this.get(Kt.WebView,t);if(!i||i.type!==Kt.WebView)return;if(i.status===Zt)return void this.dispatchEvent({type:uo,resource:i,requestAll:e});const r=i.config;if(!r||!r.viewer)return void this.setResourceError(i,"WebView Resource Config is null",e);const{viewer:n}=r,s=document.createElement("iframe");s.src=this.transformUrl(i.id),s.style.border="none",this.setResourceData(i,{getMixerPlane:function(t){return si(n.webviewManager.mixerContext,s,t)}},e)}preloadModel(t,e){const i=this.get(Kt.MODEL,t);if(!i||i.type!==Kt.MODEL||!i.config)return;if(i.status===Zt)return void this.dispatchEvent({type:uo,resource:i,requestAll:e});i.status=Jt;const{src:r,modelType:n,type:s}=i.config;switch((n||s).toLocaleLowerCase()){case"obj":if(q(r))this._loadObjModel(r,i,e);else if(Q(r)){var o=new no(this.loadingManager);o.setResponseType("json"),o.load(this.transformUrl(r),(t=>{t?this._loadObjModel(t,i,e):this.setResourceError(i,i.id+" is empty.",e)}),null,(t=>{i.data=null,i.status=qt,i.progress=-1,this.dispatchEvent({type:uo,resource:i,requestAll:e})}))}break;case"gltf":Q(r)&&this._loadGLTFModel(this.transformUrl(r),i,e);break;case"fbx":Q(r)&&this._loadFBXModel(this.transformUrl(r),i,e)}}_loadObjModel(t,e,i){if(!t||!e)return;const{type:r,obj:n,mtl:s,path:o}=t;if("obj"!==r)return;const a=this.transformUrl(o||At(e.id))+"/";Ke({loadingManager:this.loadingManager,obj:n,mtl:s,path:a,loadedCallback:t=>{this.setResourceData(e,t,i)},progressCallback:t=>{this.setResourceProgress(e,t,i)},errorCallback:()=>{this.setResourceError(e,i)}})}_loadGLTFModel(t,e,i){if(!t||!e)return;const{path:r,fileName:n}=St(t);if(e.cache){const t=new mi(this.loadingManager);this.dracoLoader&&t.setDRACOLoader(this.dracoLoader),io.cacheModel(r+n).then((r=>{t.load(r,(t=>{this.setResourceData(e,t,i)}),(t=>{this.setResourceProgress(e,t,i)}),(t=>{console.log(t),this.setResourceError(e,i)}))}))}else{const t=new mi(this.loadingManager).setPath(r);this.dracoLoader&&t.setDRACOLoader(this.dracoLoader),t.load(n,(t=>{this.setResourceData(e,t,i)}),(t=>{this.setResourceProgress(e,t,i)}),(t=>{console.log(t),this.setResourceError(e,i)}))}}_loadFBXModel(t,e,i){const r=new Us(this.loadingManager);e.cache?io.cacheModel(t).then((t=>{r.load(t,(t=>{this.setResourceData(e,t,i)}),(t=>{this.setResourceProgress(e,t,i)}),(t=>{console.log(t),this.setResourceError(e,i)}))})):r.load(t,(t=>{this.setResourceData(e,t,i)}),(t=>{this.setResourceProgress(e,t,i)}),(t=>{console.log(t),this.setResourceError(e,i)}))}setDracoLoader({path:t}){let e=new fr(this.loadingManager);e.setDecoderPath(t||"./libs/thing/draco/"),e.setDecoderConfig({type:"js"}),e.preload(),this.dracoLoader=e}setResourceProgress(t,e,i){t.progress=e,this.dispatchEvent({type:"resource.progress",progress:e,requestAll:i})}setResourceData(t,e,i){t.data=e,t.status=Zt,t.progress=100,this.dispatchEvent({type:uo,resource:t,requestAll:i}),t.fire({type:"loaded",resource:t})}setResourceError(t,e,i){t.data=null,t.status=qt,t.progress=-1,this.dispatchEvent({type:uo,resource:t,requestAll:i}),t.fire({type:"error",message:e})}nameObject(t,e){t.name=e}addObject(t){t.traverse((t=>{void 0!==t.geometry&&this.addGeometry(t.geometry),void 0!==t.material&&this.addMaterial(t.material)}))}removeObject(t){if(null!==t.parent){var e=this;t.traverse((function(t){e.removeCamera(t),e.removeHelper(t),void 0!==t.material&&e.removeMaterial(t.material)})),t.parent.remove(t)}}addGeometry(t){t&&(this.geometries[t.uuid]=t)}setGeometryName(t,e){t.name=e}addMaterial(t){if(Array.isArray(t))for(var e=0,i=t.length;ee!=t))}enbaleRender(){this.viewers.forEach((t=>{t.rendererManager.enableRender()}))}setTexture(t,e,i){if(t&&e&&i)if(i.image&&(t[e]=null),t[e])void 0===i.image||i.image||(t[e]=null,delete i.image),r(t[e],i),t.needsUpdate=!0;else if(i.image||i.path){const n={...i};delete n.image;let s="envMap"==e?Kt.CubeTexture:Kt.TEXTURE,o="envMap"==e?i.path:i.image,a=mo.get(s,o);if(a||(a=mo.set({type:s,id:o,config:n,object:t})),a.data){let i=a.data?.clone();r(i,a.config),t[e]=i,t.needsUpdate=!0}else a.on("loaded",(i=>{let s=a.data?.clone();r(s,n),t[e]=s,t.needsUpdate=!0,this.enbaleRender()}))}function r(t,e){if(t){for(const i in e){const r=e[i];void 0!==r&&(["center","repeat","offset"].includes(i)?t[i].fromArray(r):i.toLowerCase().indexOf("color")>=0?t[i]?t[i].isColor?t[i].setHex(r):t[i]=r:t[i]=r?ni(r):null:t[i]=r)}return t.needsUpdate=!0,t}}}setUniforms(t,e){if(t&&t.uniforms&&e)for(const i in e)if(t.uniforms[i]){let r=i.toLowerCase(),n=e[i];r.indexOf("color")>=0?t.uniforms[i].value.setHex(n):r.indexOf("resolution")>=0?t.uniforms[i].value.fromArray(n):t.uniforms[i].value=n}}backupMaterial(t,e){t.userData.skipStyle||t.isHelper||(Array.isArray(t.material)?(t._init_material&&Array.isArray(t._init_material)||(t._init_material=[]),t.material.forEach(((i,r)=>{i?t._init_material[r]||(t._init_material[r]=i,e&&(t.material[r]=i.clone())):t._init_material[r]}))):(t._init_material||(t._init_material=t.material),e&&(t.material=t.material.clone())))}resetMaterial(t,e){t&&t.traverse((t=>{const i=t.material;if(i)if(e)Array.isArray(i)?i.forEach((t=>{yo(t,e)})):yo(i,e);else if(Array.isArray(i))i.forEach((t=>{for(const e in t)yo(t,e)}));else for(const t in i)yo(i,t)}))}_needResetMaterial(t,e,i){return"transparent"==e&&0==i&&void 0!==t[fo+e]&&(yo(t,e),void 0!==t._init_opacity&&yo(t,"opacity"),!0)}_updateMaterialValue(t,e,i){if(t&&void 0!==t[e]&&"type"!=e){if(function(t,e,i){t&&void 0===t[fo+e]&&(t[fo+e]=i&&i.clone?i.clone():i)}(t,e,t[e]),vo.includes(e))return null===i?t[e]=null:t[e]&&!t[e].isColor||(t[e]=ni(i)),void(t.needsUpdate=!0);if(e.indexOf("Scale")>0||e.indexOf("Position")>0)return Lt(t[e])&&(isNaN(t[e])?t[e].fromArray(i):t[e]=i),void(t.needsUpdate=!0);if(go.includes(e))i?void 0===i&&tt(i)||this.setTexture(t,e,i):(t[e]=null,t.needsUpdate=!0);else{if("uniforms"==e&&t.uniforms)return console.log(i),void this.setUniforms(t,i);this._needResetMaterial(t,e,i)||(t[e]=i),t.needsUpdate=!0}}}updateMaterial(t,e){if(!t.material||!e||t.userData.skipStyle||t.isHelper)return;let i=e.slot;if(Array.isArray(t.material)){const{materialSlot:r}=t.geometry;if(Lt(i)){let n=Q(i)&&r?r[i]:i;if(J(n)&&t.material[n]){e.type&&t.material.type!==e.type&&(t.material[n]=new THREE[e.type]);for(const i in e)this._updateMaterialValue(t.material[n],i,e[i])}}else Array.isArray(e)?e.forEach((e=>{let n=Q(e.slot)&&r?r[e.slot]:i;t.material[n]&&e.type&&t.material[n].type!==e.type&&(t.material[n]=new THREE[e.type]);for(const i in e)"slot"!==i&&"type"!==i&&this._updateMaterialValue(t.material[n],i,e[i])})):t.material.forEach(((i,r)=>{i.type&&t.material[r].type!==i.type&&(t.material[r]=new THREE[i.type]);for(const t in e)this._updateMaterialValue(i,t,e[t])}))}else{if(Array.isArray(e)){const{materialArraySize:i,materialSlot:r}=t.geometry,n=t.material.clone();let s=new Array(i||e.length).toString().split(",").map((t=>t.type?new THREE[t.type]:n.clone()));return e.forEach(((t,e)=>{let i=e;Lt(t.slot)&&(J(t.slot)&&(i=t.slot),r&&Q(t.slot)&&void 0!==r[t.slot]&&(i=r[t.slot]));let n=s[i];for(const e in t)this._updateMaterialValue(n,e,t[e])})),void(t.material=s)}e.type&&t.material.type!==e.type&&(t.material=new THREE[e.type]);for(const i in e)this._updateMaterialValue(t.material,i,e[i])}}createMaterial(t,e){t=t||"MeshStandardMaterial";let i=THREE[t]&&new THREE[t];if(i&&i.isMaterial&&!tt(e))for(const t in e)this._updateMaterialValue(i,t,e[t]);return i}toJSON(t,e){const i=t.toJSON();if(delete i.uuid,e){const e=new THREE[t.type];for(const r in i){if(vo.includes(r)&&(t[r]&&!e[r].equals(t[r])?i[r]=new THREE.Color(i[r]).toHexString():delete i[r]),go.includes(r)&&i[r]){i[r]={image:t[r].image.src};const e=new THREE.Texture,n=["wrapS","wrapT","image","listeners","version","uuid","anisotropy","encoding","userData","matrix"];for(const s in t[r])if(!n.includes(s)){const n=t[r][s];Lt(n)&&(n.equals?n.equals(e[s])||(n.toArray?i[r][s]=n.toArray():n.toHexString&&(i[r][s]=n.toHexString())):n!=e[s]&&(Array.isArray(n)?n.length>0&&(i[r][s]=n):q(n)?tt(n)&&(i[r][s]=n):i[r][s]=n))}}"type"!==r&&t[r]==e[r]&&delete i[r]}}else for(const e in i){const r=i[e];vo.includes(e)&&r&&(i[e]=new THREE.Color(r).toHexString()),go.includes(e)&&r&&(i[e]={image:t[e].image.src})}return i}fromJSON(t){if(!t.type||!THREE[t.type])return null;const e=new THREE[t.type];for(const i in t)"type"==i||"meta"==i||this._updateMaterialValue(e,i,t[i]);return e}},xo={icon:"",fill:!1,fillColor:"#000000",fontSize:14,fontColor:"#111111",fontFamily:"Microsoft Yahei, Times, serif",fontWeight:"normal",fontVariant:"normal",lineGap:6,padding:4,textAlign:"left",textVisible:!0,iconVisible:!0,iconWidth:32,iconHeight:32,iconRotate:0,iconMargin:4,offsetX:0,offsetY:0,strokeWidth:2,strokeColor:"rgba(255,255,255,.85)",outlineWidth:0,outlineColor:"#FFFFFF",text:"",iconPosition:Yt.LEFT,forcePowerOf2:!1};function bo(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}function _o(t,e){let i=0,r=t.length;for(let e=0,n=1,s=2;s{this.needsRedraw=!0,this.redraw()})))),this.needsRedraw=!0,this._outlineTimer=null}get pixelSize(){return this.fontSize/72*96*2}get isTexture(){return!0}get isLabelTexture(){return!0}get lines(){let{text:t,textVisible:e}=this;return e&&""!==t&&Lt(t)?String(t).split("\n"):[]}get textWidth(){let{fontFamily:t,fontStyle:e,fontVariant:i,fontWeight:r,fontSize:n,lines:s,textVisible:o}=this;if(o&&s.length){let o=document.createElement("canvas").getContext("2d");return o.font=bt(t,n,e,i,r),Pt(s.map((t=>o.measureText(t).width)))}return 0}get iconSize(){let t=this.iconWidth,e=this.iconHeight;return t&&e?{width:t,height:e}:this.iconNatureSize}get iconNatureSize(){const t=this._iconResource;return{width:t?t.width:0,height:t?t.height:0}}get textHeight(){let{lineGap:t,lines:e,fontSize:i}=this;return e.length?e.length*i+t*(e.length-1):0}get width(){let t,{text:e,icon:i,padding:r,textWidth:n,iconMargin:s,iconPosition:o,outlineWidth:a,textVisible:l,iconVisible:h}=this,c=this.iconSize;if(!Lt(e)||!l)return this.roundUpPowerOf2(c.width+2*a+2*r);if(!i||!h)return this.roundUpPowerOf2(n+2*a+2*r);switch(o.toLowerCase()){case Yt.LEFT:case Yt.TOP_LEFT:case Yt.TOP_RIGHT:case Yt.BOTTOM_LEFT:case Yt.BOTTOM_RIGHT:case Yt.RIGHT:t=2*r+n+c.width+2*a+s;break;default:t=2*r+Math.max(n,c.width)+2*a+s}return this.roundUpPowerOf2(t)}get height(){let{text:t,padding:e,textHeight:i,iconMargin:r,iconPosition:n,icon:s,outlineWidth:o,iconVisible:a,textVisible:l}=this;const h=this.iconSize;if(!s||!a)return this.roundUpPowerOf2(2*e+i+2*o-2);if(!Lt(t)||!l)return this.roundUpPowerOf2(h.height+2*o+2*e);let c=2*e+2*o;switch(n){case Yt.TOP:case Yt.BOTTOM:c+=i+h.height+r;break;default:c+=Math.max(i,h.height)}return this.roundUpPowerOf2(c)}roundUpPowerOf2(t){return this.forcePowerOf2?bo(t):t}redraw(){let{needsRedraw:t,image:e}=this;if(!t||!e)return;let{fontSize:i,height:r,width:n}=this;if(n&&r){e.width=512,e.height=512;let{textAlign:t,fill:s,fillColor:o,fontColor:a,fontFamily:l,fontStyle:h,fontVariant:c,fontWeight:d,lineGap:u,lines:p,padding:m,text:f,strokeColor:g,strokeWidth:v,textWidth:y,textHeight:w,icon:x,iconRotate:b,iconPosition:_,iconMargin:A,outlineWidth:S,outlineColor:T,iconVisible:E,textVisible:P}=this;const M=this.iconSize,C=M.height,L=M.width;let R=0,O=0,N=0,D=0;R=O=N=D=m+S;const I=_.toLowerCase();let U=e.getContext("2d");if(U.clearRect(0,0,e.width,e.height),U.scale(512/n,512/r),U.save(),s&&o&&(U.fillStyle=o,U.fillRect(0,0,n,r)),f&&P){switch(E&&x&&I.includes("left")&&(t="right",I===Yt.TOP_LEFT&&(D=r-m-S-w),I===Yt.LEFT&&(D=r/2-w/2)),E&&x&&I.includes("right")&&(R=y+A+m+S,t="left",I===Yt.TOP_RIGHT&&(D=r-m-S-w),I===Yt.RIGHT&&(D=r/2-w/2)),E&&x&&"top"===I&&(R=n/2-L/2,D+=C+A),E&&x&&"bottom"===I&&(R=n/2-L/2,O=w+D+A),E&&x&&I.indexOf("center")>=0&&(R=n/2-L/2,D=r/2-w/2),U.textAlign=t,U.font=bt(l,i,h,c,d),U.textBaseline="top",U.fillStyle=a,U.miterLimit=1,U.lineWidth=v,U.strokeStyle=g,t){case"right":N=n-m-S;break;case"center":N=n/2;break;case"left":N=m+S}p.forEach((t=>{v&&U.strokeText(t,N,D),U.fillText(t,N,D),D+=i+u}))}if(x&&E){let t=x;this._iconResource&&(t=this._iconResource.data),F(t)&&(b?(U.translate(R+L/2,O+C/2),U.rotate(b),U.drawImage(t,-L/2,-C/2,L,C),U.rotate(-1*b),U.translate(-R-L/2,-O-C/2)):U.drawImage(t,R,O,L,C))}S&&(U.miterLimit=0,U.strokeStyle=T,U.lineWidth=S,U.strokeRect(Math.max(S/2,1),Math.max(S/2,1),n-S,r-S)),U.restore()}else e.width=e.height=1;this.needsRedraw=!1,this.needsUpdate=!0}dispose(){this._iconResource&&this._iconResource.removeObject(this),be.CanvasTexture.prototype.dispose.call(this)}}Object.keys(xo).forEach((t=>{Object.defineProperty(Po.prototype,t,{get(){return this[`_${t}`]},set(e){this[`_${t}`]!==e&&(this[`_${t}`]=e,"icon"===t&&(this._iconResource&&(this._iconResource.removeObject(this),this._iconResource=null),e&&(it(e)||e instanceof HTMLElement||(this._iconResource=mo.set({id:e,type:Kt.IMAGE,object:this})))),this.needsRedraw=!0,this.redraw())}})}));class Mo extends be.Object3D{constructor(t,e){super(),this.isThing=!0,this._initOption(t),this.setupCommonEvent()}_initOption(t){this.option||(this.option={}),pt(this.option,t||{});const{uuid:e,name:i,visible:r,frustumCulled:n,renderOrder:s,layers:o,position:a,scale:l,rotation:h,matrix:c,up:d,mesh:u,geometry:p,material:m,interact:f,properties:g,refPositions:v,castShadow:y,receiveShadow:w,userData:x,locked:b}=this.option;if(e&&(this.uuid=e),i&&(this.name=i),Lt(r)&&(this.visible=r),a&&this.position&&this.position.copy(ti(a)),Lt(l)&&(J(l)?this.scale.setScalar(l):this.scale.copy(ti(l))),h){const t=ti(h);this.rotation.set(t.x,t.y,t.z)}if(Lt(n)&&(this.frustumCulled=n),Lt(s)&&(this.renderOrder=s),Lt(y)&&(this.castShadow=y),Lt(w)&&(this.receiveShadow=w),Lt(o)&&this.layers.set(o),Lt(b)&&(this.locked=b),this.interact={selectable:!0},Lt(f)&&pt(this.interact,f),x)for(const t in x)this.userData[t]=x[t];c&&this.matrix.copy(c),this.setProperties(g),this.name||(this.name=this.properties.name||""),this.scene=null,this.tickable=!1,this._eventInited=!1,this.setupStyle()}setupCommonEvent(){return this.addEventListener("added",(function(t){const e=t.target;if(e){if(!e.scene){const i=ai(t.target);i.isScene&&(e.scene=i,e.traverse((t=>{t.scene=i})))}e.scene&&(e.scene.dispatchEvent({type:ee,action:"object.added",object:e}),e.dispatchEvent({type:te,scene:e.scene})),e.tickable=!0}})),this.addEventListener("removed",(function(t){const e=t.target;e&&(e.resource&&(e.resource.removeObject(e),e.resource=null),e.scene&&e.scene.dispatchEvent({type:ee,action:"object.removed",object:e}),e.tickable=!1)})),this}setBeforeRender(t){this.traverseChild((e=>{oi(e)&&(e.onBeforeRender=t||(()=>{}))}))}setAfterRender(t){this.traverseChild((e=>{oi(e)&&(e.onAfterRender=t||(()=>{}))}))}onBeforeRender(){this.tickable&&(this.tickable=!1)}clearResource(){return this.resource&&(this.resource.removeObject(this),this.resource=null),this}clear(){const t=this.children||[];for(var e=0;e{Object.defineProperty(i.prototype,t,{get(){return this.object._easyStyle[t]},set(i){let r=e[t];switch(e[t]=i,t){case"transparent":case"opacity":case"color":case"side":case"wireframe":case"emissive":this.object.updateMaterial({[t]:i});break;case"box":this.object.setBoxHelper(i?{color:e.boxColor}:null);break;case"boxColor":e.box&&this.object.setBoxHelper({color:i});break;case"edgeColor":e.edge&&this.object.setEdge({color:i});break;case"edgeOpacity":e.edge&&this.object.setEdge({opacity:i});break;case"edge":this.object.setEdge(i?{color:e.edgeColor,opacity:e.edgeOpacity}:null);break;case"castShadow":case"receiveShadow":this.object.updateBy({[t]:i})}this.object.dispatchEvent({type:"style.change",key:t,oldValue:r,newValue:i})}})})),this.style=new i(this)}_getEasyStyle(t){}_setEasyStyle(t,e){}toJSON(t,e){super.toJSON2();const i={visible:this.visible,position:this.position.toArray(),scale:this.scale.toArray(),rotation:this.rotation.toArray(),layers:this.layers.getChannel(),receiveShadow:this.receiveShadow,castShadow:this.castShadow,material:this.option.material,geometry:this.option.geometry,polygon:this.option.polygon,line:this.option.line,arrow:this.option.arrow,video:this.option.video,style:this.option.style,shader:this.option.shader,points:this.getPoints&&this.getPoints(),properties:this.properties,userData:this.userData,locked:this.locked};let r=new be.Layers;r.set(0);for(const t in i){const e=i[t];switch(t){case"layers":let n=new be.Layers;n.set(e),r.test(n)&&delete i[t];break;case"locked":this.locked||delete i[t];break;default:(null==e||""===e||q(e)&&tt(e)||"scale"==t&&Et(e,[1,1,1])||"position"==t&&Et(e,[0,0,0])||"rotation"==t&&Et(e,[0,0,0,"XYZ"])||"visible"==t&&e||"castShadow"==t&&!e||"receiveShadow"==t&&!e||Array.isArray(e)&&0==e.length)&&delete i[t]}}this.isModel&&(i.size=this.getSize().toArray());return{isThing:!0,name:this.name,type:this.type,config:i}}fade(t,e){var i=(t=t||{}).duration||1e3,r=t.complete;this.fadeTween&&this.fadeTween.stop();var n=this.style.opacity,s={opacity:this.isWebView?e:n},o={opacity:this.isWebView?n:e},a=this;this.visible=!0,this.fadeTween=new Bt(s).to(o,i).easing(Ot.Linear.None).onUpdate((function(t){a.style.opacity=this._object.opacity})).onComplete((function(){let t=a.style.opacity,e=0===t;a.isWebView&&(e=1===t),e&&(a.visible=!1),void 0!==a._fadeTempTransparent&&(a.style.transparent=a._fadeTempTransparent),r&&r()})).start()}fadeIn(t){this._fadeTempTransparent=this.style.transparent,this.style.opacity=0,this.style.transparent=!0,this.fade(t,.99)}fadeOut(t){this._fadeTempTransparent=this.style.transparent,this.style.opacity=.99,this.style.transparent=!0,this.fade(t,0)}clone(){const t=this.toJSON();return t.config.properties&&delete t.config.properties.uuid,new this.constructor(t.config)}}pi(Mo);class Co extends Mo{constructor(t){super(pt({avoid:!1,center:[.5,0],material:{fog:!0,transparent:!0,rotation:0,sizeAttenuation:!1,map:et(xo)}},t)),this.isBillboard=!0,this.type="Billboard";const{avoid:e,visible:i,material:r}=this.option,n=new Po(r.map);n.encoding=be.sRGBEncoding;const s=new be.SpriteMaterial({map:n,sizeAttenuation:!1,depthWrite:!1});this.sprite=new be.Sprite(s),this.add(this.sprite),this.center=$e(this.option.center||[.5,0]),this.box2d=null,this._avoid=e,this._visible=i,this._avoidVisible=!0,this.updateMaterial(this.option.material)}get center(){return this.sprite.center.toArray()}set center(t){this.sprite.center.copy($e(t))}updateMaterial(t){super.updateMaterial(t),this.updateScale(this.spriteComputeParameter)}get spriteComputeParameter(){if(!this.scene)return 0;const t=this.scene.viewer;return t.cameraControl,t.spriteComputeParameter}setupCommonEvent(){this.addEventListener(te,(t=>{const e=t.scene;if(e&&(this.avoid&&!t.scene.avoidBillboards.contains(this)&&t.scene.avoidBillboards.add(this),e.viewer)){const t=this.sprite.material.map,i=e.viewer.spriteComputeParameter;this.updateScale(i),t.needsRedraw=!0,t.redraw()}})),this.addEventListener("removed",(t=>{const e=this.scene;e&&e.avoidBillboards.remove(this)})),Mo.prototype.setupCommonEvent.call(this)}get texture(){return this.sprite.material.map}getSize(){const{width:t,height:e}=this.texture;return{width:t,height:e}}updateBox(t){if(!t)return;const e=t.coordWorldToScreen(this.position);if(e){const{x:t,y:i}=e,{width:r,height:n}=this.getSize();this.box2d=new be.Box2(new be.Vector2(t-r/2,i-n/2),new be.Vector2(t+r/2,i+n/2))}}updateScale(t){if(void 0===(t=t||this.spriteComputeParameter)||t<0)return;const{width:e,height:i}=this.texture;let r=i/t,n=r*e/i;this.sprite.scale.set(ct(n,5),ct(r,5),1).multiplyScalar(1)}get avoid(){return this._avoid}set avoid(t){this._avoid=!!t}}const Lo={material:{},geometry:{}};class Ro extends Mo{constructor(t,e){super(gt({},Lo,t)),this.isGeometryThing=!0;const i=this.createGeometry(this.option.geometry);this.mesh=new be.Mesh(i,new be.MeshStandardMaterial),this.add(this.mesh),this.updateBy({...this.option,geometry:null})}getGeometry(){return this.mesh.geometry}getMaterial(){return this.mesh.material}updateGeometry(t){t&&(t.isBufferGeometry?(this.mesh.geometry.dispose(),this.mesh.geometry=t):(pt(this.option.geometry,t),this.mesh.geometry.dispose(),this.mesh.geometry=this.createGeometry(mt({},this.mesh.geometry.parameters,t))),this.mesh.geometry.computeBoundingBox())}createGeometry(){return new be.BufferGeometry}clone(){const t=super.clone();return t.material=this.mesh.material,t.geometry=this.mesh.geometry,t}}class Oo extends Ro{constructor(t){super(gt({},{name:"Box",geometry:{width:1,height:1,depth:1,widthSegments:1,heightSegments:1,depthSegments:1}},t)),this.type="Box",this.isBox=!0,this.materialArraySize=Oo.materialArraySize,this.materialSlot=Oo.materialSlot}createGeometry(t){const e=THREE.BoxGeometry.fromJSON(t);return e.center(),e.uvsNeedUpdate=!0,e.materialArraySize=Oo.materialArraySize,e.materialSlot=Oo.materialSlot,e}toJSON(t){const e=super.toJSON(t),i=this.mesh.material;if(Array.isArray(i)){const t=i.map((t=>wo.toJSON(t,!0)));e.config.material=t}else e.config.material=wo.toJSON(i,!0);return e}}Oo.materialArraySize=6,Oo.materialSlot={front:0,back:1,top:2,bottom:3,left:4,right:5};class Fo extends Mo{constructor(t){super(pt({src:"",modelType:"gltf",selectLevel:1,animationTimeScale:1,animationEnable:!1,size:null,cache:!1,modifies:{}},t)),this.isSync=!0,this.isModel=!0,this.type="Model",this.selectLevel=this.option.selectLevel,this._src="",this._modelType="",this.animations=[],this._setSrc(this.option.src,this.option.modelType||this.option.type)}get animationEnable(){return this.option.animationEnable}set animationEnable(t){this.option.animationEnable=t,this.mixer.stopAllAction(),t&&this.animations.forEach((t=>{t.clipAction&&t.clipAction.play()}))}_addInitBox(){let{size:t}=this.option;t=ti(t||[1,1,1]);const e=this._initBox=new Oo({geometry:{width:t.x,height:t.y,depth:t.z}});this.add(e)}_removeInitBox(){this.remove(this._initBox),this._initBox=null}setupCommonEvent(){super.setupCommonEvent(),this.addEventListener(te,(t=>{this.scene&&this.scene.dispatchEvent({type:ee,action:"object.loaded",object:this})})),this.loaded=!1,this.addEventListener("resource.loaded",(t=>{setTimeout((()=>{this._setFromResource(t.resource.data),this.traverse((t=>{t.isMesh&&(t.properties||(t.properties={name:t.name,uuid:t.uuid}))})),this.complete&&this.complete(this),this._removeInitBox(),this.loaded=!0,this.dispatchEvent({type:"loaded"})}),50)})),this.addEventListener("resource.error",(t=>{this._removeInitBox(),this.loaded=!0,this.dispatchEvent({type:"error"})}))}_setSrc(t,e){this.loaded=!1,e&&(this._modelType=e),t&&t!==this._src&&(this._src=t,this.resource&&(this.resource.removeObject(this),this.resource=null),q(t)?this.resource=mo.set({id:be.Math.generateUUID(),type:Kt.MODEL,config:{type:this._modelType,src:t},cache:this.option.cache,object:this}):Q(t)&&(this.resource=mo.set({id:t,config:{type:this._modelType,src:t},cache:this.option.cache,type:Kt.MODEL,object:this})))}clear(){super.clear(),this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this),this.animations=[])}_setFromResource(t){switch(this._modelType.toLowerCase()){case"gltf":{let e=(t.scene||t.scenes[0]).clone();e.locked=this.locked;const{animations:i}=t;i&&i.length>0?(this.add(e),this._initAnimations(e,i)):this.add(e)}break;case"obj":const e=t.clone();e.locked=this.locked,this.add(e);break;case"fbx":{let e=t.clone();e.locked=this.locked;const{animations:i}=e;i&&i.length>0?(this.add(e),this._initAnimations(e,i)):this.add(e)}}return this.updateBy(this.option),this}_initAnimations(t,e){this.animations=[];const i=new be.AnimationMixer(t),{animationTimeScale:r}=this.option;r&&(i.timeScale=r);for(let t=0;t{this.mixer&&this.mixer.update(e.deltaTime)}),1))}initExplode(){function t(t,e){return(new be.Vector3).addVectors(t.max,t.min).multiplyScalar(e)}const e=new be.Box3;e.setFromObject(this);const i=t(e,.5),r=new be.Box3;this.traverse((function(e){if(!(e.isMark||e.isMarkChild||e.isLine||e.isSprite)&&e.isMesh){r.setFromObject(e);const n=t(r,.5);e.userData.worldDir=(new be.Vector3).subVectors(n,i).normalize(),e.userData.worldDistance=(new be.Vector3).subVectors(n,i),e.userData.originPosition=e.getWorldPosition(new be.Vector3),e.userData.meshCenter=n.clone(),e.userData.explodeCenter=i.clone()}}))}explode(t){t=t||1,this.traverse((e=>{if(!e.isMesh||!e.userData.originPosition)return;const i=e.userData.worldDir.clone().multiplyScalar(e.userData.worldDistance.length()*t),r=(new be.Vector3).subVectors(e.userData.meshCenter,e.userData.originPosition),n=e.userData.explodeCenter,s=(new be.Vector3).copy(n).add(i).sub(r),o=e.parent?.worldToLocal(s.clone());o&&e.position.copy(o)}))}toJSON(t){if(t=t||{models:{}},this.resource){const e=this.resource.toJSON();t.models||(t.models={}),t.models[e.id]=e}const e=super.toJSON();return e.config.src=this._src,e.config.modelType=this._modelType,e.config.animationTimeScale=this.option.animationTimeScale,e.config.selectLevel=this.selectLevel,e.config.modifies=this.option.modifies,e.config.animationEnable=this.animationEnable,e}get src(){return this._src}}class No extends Ro{constructor(t){super(pt({name:"circle",geometry:{radius:.5,segments:30,thetaStart:0,thetaLength:2*Math.PI}},t)),this.type="Circle",this.isCircle=!0}createGeometry(t){return THREE.CircleGeometry.fromJSON(t)}}class Do extends Ro{constructor(t){super(pt({name:"Cone",geometry:{radius:1,height:1,radialSegments:20,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:2*Math.PI}},t)),this.type="Cone",this.isCone=!0}createGeometry(t){return THREE.ConeGeometry.fromJSON(t)}}class Io extends Ro{constructor(t){super(pt({name:"Cylinder",geometry:{radiusTop:1,radiusBottom:1,radialSegments:30,height:1,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:2*Math.PI}},t)),this.type="Cylinder",this.isCylinder=!0}createGeometry(t){return THREE.CylinderGeometry.fromJSON(t)}}class Uo extends Ro{constructor(t){super(pt({name:"Dodecahedron",geometry:{radius:.5,detail:0}},t)),this.type="Dodecahedron",this.isDodecahedron=!0}createGeometry(t){return THREE.DodecahedronGeometry.fromJSON(t)}}class Bo extends Ro{constructor(t){super(pt({name:"Icosahedron",geometry:{radius:.5,detail:0}},t)),this.type="Icosahedron",this.isIcosahedron=!0}createGeometry(t){return THREE.IcosahedronGeometry.fromJSON(t)}}class ko extends Ro{constructor(t){super(pt({name:"Lathe",geometry:{points:[{x:0,y:.5},{x:.5,y:0},{x:0,y:-.5}],segments:12,phiStart:0,phiLength:2*Math.PI}},t)),this.type="Lathe",this.isLathe=!0}createGeometry(t){return THREE.LatheGeometry.fromJSON(t)}}class jo extends Ro{constructor(t){super(pt({name:"Octahedron",geometry:{radius:.5,detail:0}},t)),this.type="Octahedron",this.isOctahedron=!0}createGeometry(t){return THREE.OctahedronGeometry.fromJSON(t)}}class Vo extends Ro{constructor(t){super(pt({name:"Plane",geometry:{width:1,height:1,widthSegments:1,heightSegments:1}},t)),this.type="Plane",this.isPlane=!0}createGeometry(t){return THREE.PlaneGeometry.fromJSON(t)}get width(){return this.geometry.parameters.width}set width(t){this.geometry.parameters.width=t}get height(){return this.geometry.parameters.height}set height(t){this.geometry.parameters.height=t}}class zo extends Ro{constructor(t){super(pt({name:"Ring",geometry:{innerRadius:.4,outerRadius:.5,thetaSegments:30,phiSegments:30,thetaStart:0,thetaLength:2*Math.PI},material:{}},t)),this.type="Ring",this.isRing=!0}createGeometry(t){return THREE.RingGeometry.fromJSON(t)}}class Go extends Ro{constructor(t){super(pt({name:"Sphere",geometry:{radius:.5,widthSegments:30,heightSegments:30,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI}},t)),this.type="Sphere",this.isSphere=!0}createGeometry(t){return THREE.SphereGeometry.fromJSON(t)}}class Ho extends Ro{constructor(t){super(pt({name:"Tetrahedron",geometry:{radius:.5,detail:0}},t)),this.type="Tetrahedron",this.isTetrahedron=!0}createGeometry(t){return THREE.TetrahedronGeometry.fromJSON(t)}}class Xo extends Ro{constructor(t){super(pt({name:"Torus",geometry:{radius:.5,tube:.25,radialSegments:16,tubularSegments:16,arc:2*Math.PI}},t)),this.type="Torus",this.isTorus=!0}createGeometry(t){return THREE.TorusGeometry.fromJSON(t)}}class Wo extends Ro{constructor(t){super(pt({name:"TorusKnot",geometry:{radius:.5,tube:.2,tubularSegments:64,radialSegments:8,p:2,q:3}},t)),this.type="TorusKnot",this.isTorusKnot=!0}createGeometry(t){return THREE.TorusKnotGeometry.fromJSON(t)}}class Yo extends Ro{constructor(t){super(pt({name:"Capsule",geometry:{radius:.5,height:1,segments:30,phiStart:0,phiLength:2*Math.PI}},t)),this.type="Capsule",this.isCapsule=!0}createGeometry(t){const e=void 0!==t.radius?t.radius:this.option.geometry.radius,i=void 0!==t.height?t.height:this.option.geometry.height,r=[];for(let t=Math.PI/2;t>0;t-=.1)r.push(new THREE.Vector3(Math.cos(t)*e,Math.sin(t)*e+i/2,0));for(let t=i/2;t>-i/2;t-=.1)r.push(new THREE.Vector3(e,t,0));for(let t=0;t<=Math.PI/2;t+=.1)r.push(new THREE.Vector3(Math.cos(t)*e,-Math.sin(t)*e-i/2,0));r.push(new THREE.Vector3(0,-e-i/2,0));const{segments:n,phiStart:s,phiLength:o}=this.option.geometry,a=new THREE.LatheGeometry(r,n,s,o);return a.center(),a.uvsNeedUpdate=!0,a}}class Qo extends Ro{constructor(t){super(pt({name:"Doughnut",geometry:{radius:1,innerRadius:.5,segments:30,phiStart:0,phiLength:2*Math.PI}},t)),this.type="Doughnut",this.isDoughnut=!0}createGeometry(t){const e=void 0!==t.radius?t.radius:this.option.geometry.radius,i=void 0!==t.innerRadius?t.innerRadius:this.option.geometry.innerRadius,r=new THREE.EllipseCurve(0,0,i,i,0,2*Math.PI,!1,0).getPoints(60),n=[];r.forEach((t=>{t.x=t.x+e,n.push(t)}));const{segments:s,phiStart:o,phiLength:a}=this.option.geometry;return new THREE.LatheGeometry(n,s,o,a)}}class Jo extends Mo{constructor(t){super(pt({geometry:{points:[]},material:{size:3,sizeAttenuation:!1,transparent:!0}},t)),this.type="Points",this.mesh=new be.Points(this.createGeometry(this.option.geometry),new be.PointsMaterial),this.mesh.material.depthWrite=!1,this.add(this.mesh),this.updateBy(this.option)}createGeometry(t){const e=[];for(let i=0;i"string"!=typeof t?"":t))):"string"==typeof e&&t.push(e)),this.viewer.style){if(this.viewer.style.stylesheet){const t=this.viewer.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this.viewer.style.sourceCaches;for(const i in e){const r=e[i];if(r.used){const e=r.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}}t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r=0)return!1;return!0})),t.length?(this._innerContainer.innerHTML=t.join(" | "),this._container.classList.remove("THING-attrib-empty")):this._container.classList.add("THING-attrib-empty")}_updateCompact(){this._container&&(this.viewer.container.offsetWidth<=640?this._container.classList.add("THING-compact"):this._container.classList.remove("THING-compact"))}} /*! * camera-controls * https://github.com/yomotsu/camera-controls * (c) 2017 @yomotsu * Released under the MIT License. */ /*! * camera-controls * https://github.com/yomotsu/camera-controls * (c) 2017 @yomotsu * Released under the MIT License. */var ta;function ea(t){return(ta[t]||"").toLowerCase()}function ia(t){return t.isPerspectiveCamera}function ra(t){return t.isOrthographicCamera}!function(t){t[t.NONE=0]="NONE",t[t.ROTATE=1]="ROTATE",t[t.TRUCK=2]="TRUCK",t[t.OFFSET=3]="OFFSET",t[t.DOLLY=4]="DOLLY",t[t.ZOOM=5]="ZOOM",t[t.TOUCH_ROTATE=6]="TOUCH_ROTATE",t[t.TOUCH_TRUCK=7]="TOUCH_TRUCK",t[t.TOUCH_OFFSET=8]="TOUCH_OFFSET",t[t.TOUCH_DOLLY=9]="TOUCH_DOLLY",t[t.TOUCH_ZOOM=10]="TOUCH_ZOOM",t[t.TOUCH_DOLLY_TRUCK=11]="TOUCH_DOLLY_TRUCK",t[t.TOUCH_DOLLY_OFFSET=12]="TOUCH_DOLLY_OFFSET",t[t.TOUCH_ZOOM_TRUCK=13]="TOUCH_ZOOM_TRUCK",t[t.TOUCH_ZOOM_OFFSET=14]="TOUCH_ZOOM_OFFSET"}(ta||(ta={}));const na=2*Math.PI,sa=Math.PI/2;function oa(t,e=1e-5){return Math.abs(t){e.x+=t.clientX,e.y+=t.clientY})),e.x/=t.length,e.y/=t.length}function ua(t,e){return!!ra(t)&&(console.warn(`${e} is not supported in OrthographicCamera`),!0)}function pa(t){return t.invert?t.invert():t.inverse(),t}const ma="undefined"!=typeof window,fa=ma&&/Mac/.test(navigator.platform),ga=!(ma&&"PointerEvent"in window),va=Object.freeze(ta),ya=1/8;let wa,xa,ba,_a,Aa,Sa,Ta,Ea,Pa,Ma,Ca,La,Ra,Oa,Fa,Na,Da,Ia,Ua,Ba,ka;wa=Object.freeze(new be.Vector3(0,0,0)),xa=Object.freeze(new be.Vector3(0,1,0)),ba=Object.freeze(new be.Vector3(0,0,1)),_a=new be.Vector2,Aa=new be.Vector3,Sa=new be.Vector3,Ta=new be.Vector3,Ea=new be.Vector3,Pa=new be.Vector3,Ma=new be.Vector3,Ca=new be.Vector3,La=new be.Vector3,Ra=new be.Spherical,Oa=new be.Spherical,Fa=new be.Box3,Na=new be.Box3,Da=new be.Sphere,Ia=new be.Quaternion,Ua=new be.Quaternion,Ba=new be.Matrix4,ka=new be.Raycaster;class ja extends class{constructor(){this._listeners={}}addEventListener(t,e){const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}removeEventListener(t,e){const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}removeAllEventListeners(t){t?Array.isArray(this._listeners[t])&&(this._listeners[t].length=0):this._listeners={}}dispatchEvent(t){const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,r=i.length;e{},this._enabled=!0,this._state=ta.NONE,this._viewport=null,this._dollyControlAmount=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._activePointers=[],this._truckInternal=(t,e,i)=>{if(ia(this._camera)){const r=Aa.copy(this._camera.position).sub(this._target),n=this._camera.getEffectiveFOV()*be.MathUtils.DEG2RAD,s=r.length()*Math.tan(.5*n),o=this.truckSpeed*t*s/this._elementRect.height,a=this.truckSpeed*e*s/this._elementRect.height;this.verticalDragToForward?(i?this.setFocalOffset(this._focalOffsetEnd.x+o,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(o,0,!0),this.forward(-a,!0)):i?this.setFocalOffset(this._focalOffsetEnd.x+o,this._focalOffsetEnd.y+a,this._focalOffsetEnd.z,!0):this.truck(o,a,!0)}else if(ra(this._camera)){const r=this._camera,n=t*(r.right-r.left)/r.zoom/this._elementRect.width,s=e*(r.top-r.bottom)/r.zoom/this._elementRect.height;i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y+s,this._focalOffsetEnd.z,!0):this.truck(n,s,!0)}},this._rotateInternal=(t,e)=>{const i=na*this.azimuthRotateSpeed*t/this._elementRect.height,r=na*this.polarRotateSpeed*e/this._elementRect.height;this.rotate(i,r,!0)},this._dollyInternal=(t,e,i)=>{const r=Math.pow(.95,-t*this.dollySpeed),n=this._sphericalEnd.radius*r,s=this._sphericalEnd.radius,o=s*(t>=0?-1:1);this.dollyTo(n),this.infinityDolly&&(n{const r=Math.pow(.95,t*this.dollySpeed);this.zoomTo(this._zoom*r),this.dollyToCursor&&(this._dollyControlAmount=this._zoomEnd,this._dollyControlCoord.set(e,i))},void 0===be&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=(new be.Quaternion).setFromUnitVectors(this._camera.up,xa),this._yAxisUpSpaceInverse=pa(this._yAxisUpSpace.clone()),this._state=ta.NONE,this._domElement=e,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._target=new be.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new be.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new be.Spherical).setFromVector3(Aa.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._nearPlaneCorners=[new be.Vector3,new be.Vector3,new be.Vector3,new be.Vector3],this._updateNearPlaneCorners(),this._boundary=new be.Box3(new be.Vector3(-1/0,-1/0,-1/0),new be.Vector3(1/0,1/0,1/0)),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlAmount=0,this._dollyControlCoord=new be.Vector2,this.mouseButtons={left:ta.ROTATE,middle:ta.DOLLY,right:ta.TRUCK,wheel:ia(this._camera)?ta.DOLLY:ra(this._camera)?ta.ZOOM:ta.NONE,shiftLeft:ta.NONE},this.touches={one:ta.TOUCH_ROTATE,two:ia(this._camera)?ta.TOUCH_DOLLY_TRUCK:ra(this._camera)?ta.TOUCH_ZOOM_TRUCK:ta.NONE,three:ta.TOUCH_TRUCK},this._domElement){const t=new be.Vector2,e=new be.Vector2,i=new be.Vector2,r=t=>{if(!this._enabled)return;const e={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY};switch(this._activePointers.push(e),t.button){case be.MOUSE.LEFT:this._state=t.shiftKey?this.mouseButtons.shiftLeft:this.mouseButtons.left;break;case be.MOUSE.MIDDLE:this._state=this.mouseButtons.middle;break;case be.MOUSE.RIGHT:this._state=this.mouseButtons.right}if("touch"===t.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),f()},n=t=>{if(!this._enabled)return;const e={pointerId:0,clientX:t.clientX,clientY:t.clientY};switch(this._activePointers.push(e),t.button){case be.MOUSE.LEFT:this._state=t.shiftKey?this.mouseButtons.shiftLeft:this.mouseButtons.left;break;case be.MOUSE.MIDDLE:this._state=this.mouseButtons.middle;break;case be.MOUSE.RIGHT:this._state=this.mouseButtons.right}this._domElement.ownerDocument.removeEventListener("mousemove",a),this._domElement.ownerDocument.removeEventListener("mouseup",c),this._domElement.ownerDocument.addEventListener("mousemove",a),this._domElement.ownerDocument.addEventListener("mouseup",c),f()},s=t=>{if(this._enabled){switch(t.preventDefault(),Array.prototype.forEach.call(t.changedTouches,(t=>{const e={pointerId:t.identifier,clientX:t.clientX,clientY:t.clientY};this._activePointers.push(e)})),this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}this._domElement.ownerDocument.removeEventListener("touchmove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("touchend",d),this._domElement.ownerDocument.addEventListener("touchmove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("touchend",d),f()}},o=t=>{t.cancelable&&t.preventDefault();const e=t.pointerId,i=this._findPointerById(e);i&&(i.clientX=t.clientX,i.clientY=t.clientY,g())},a=t=>{const e=this._findPointerById(0);e&&(e.clientX=t.clientX,e.clientY=t.clientY,g())},l=t=>{t.cancelable&&t.preventDefault(),Array.prototype.forEach.call(t.changedTouches,(t=>{const e=t.identifier,i=this._findPointerById(e);i&&(i.clientX=t.clientX,i.clientY=t.clientY)})),g()},h=t=>{let e=this._state;const i=t.pointerId,r=this._findPointerById(i);if(r&&this._activePointers.splice(this._activePointers.indexOf(r),1),"touch"===t.pointerType)switch(this._activePointers.length){case 0:this._state=ta.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=ta.NONE;v(e)},c=()=>{const t=this._findPointerById(0);t&&this._activePointers.splice(this._activePointers.indexOf(t),1);let e=this._state;this._state=ta.NONE,v(e)},d=t=>{let e=this._state;switch(Array.prototype.forEach.call(t.changedTouches,(t=>{const e=t.identifier,i=this._findPointerById(e);i&&this._activePointers.splice(this._activePointers.indexOf(i),1)})),this._activePointers.length){case 0:this._state=ta.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}v(e)};let u=-1;const p=t=>{if(!this._enabled||this.mouseButtons.wheel===ta.NONE)return;if(t.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===ta.ROTATE||this.mouseButtons.wheel===ta.TRUCK){const t=performance.now();u-t<1e3&&this._getClientRect(this._elementRect),u=t}const e=fa?-1:-3,i=1===t.deltaMode?t.deltaY/e:t.deltaY/(10*e),r=this.dollyToCursor?(t.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,n=this.dollyToCursor?(t.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case ta.ROTATE:this._rotateInternal(t.deltaX,t.deltaY);break;case ta.TRUCK:this._truckInternal(t.deltaX,t.deltaY,!1);break;case ta.OFFSET:this._truckInternal(t.deltaX,t.deltaY,!0);break;case ta.DOLLY:this._dollyInternal(-i,r,n);break;case ta.ZOOM:this._zoomInternal(-i,r,n)}this.dispatchEvent({type:"control",eventType:ea(this.mouseButtons.wheel),delta:i})},m=t=>{this._enabled&&t.preventDefault()},f=()=>{if(!this._enabled)return;da(this._activePointers,_a),this._getClientRect(this._elementRect),t.copy(_a),e.copy(_a);if(this._activePointers.length>=2){const t=_a.x-this._activePointers[1].clientX,r=_a.y-this._activePointers[1].clientY,n=Math.sqrt(t*t+r*r);i.set(0,n);const s=.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),o=.5*(this._activePointers[0].clientY+this._activePointers[1].clientY);e.set(s,o)}this.dispatchEvent({type:"controlstart",eventType:ea(this._state)+"start"})},g=()=>{if(!this._enabled)return;da(this._activePointers,_a);const r=e.x-_a.x,n=e.y-_a.y;switch(e.copy(_a),this._state){case ta.ROTATE:case ta.TOUCH_ROTATE:this._rotateInternal(r,n);break;case ta.DOLLY:case ta.ZOOM:{const e=this.dollyToCursor?(t.x-this._elementRect.x)/this._elementRect.width*2-1:0,i=this.dollyToCursor?(t.y-this._elementRect.y)/this._elementRect.height*-2+1:0;this._state===ta.DOLLY?this._dollyInternal(n*ya,e,i):this._zoomInternal(n*ya,e,i);break}case ta.TOUCH_DOLLY:case ta.TOUCH_ZOOM:case ta.TOUCH_DOLLY_TRUCK:case ta.TOUCH_ZOOM_TRUCK:case ta.TOUCH_DOLLY_OFFSET:case ta.TOUCH_ZOOM_OFFSET:{const t=_a.x-this._activePointers[1].clientX,s=_a.y-this._activePointers[1].clientY,o=Math.sqrt(t*t+s*s),a=i.y-o;i.set(0,o);const l=this.dollyToCursor?(e.x-this._elementRect.x)/this._elementRect.width*2-1:0,h=this.dollyToCursor?(e.y-this._elementRect.y)/this._elementRect.height*-2+1:0;this._state===ta.TOUCH_DOLLY||this._state===ta.TOUCH_DOLLY_TRUCK||this._state===ta.TOUCH_DOLLY_OFFSET?this._dollyInternal(a*ya,l,h):this._zoomInternal(a*ya,l,h),this._state===ta.TOUCH_DOLLY_TRUCK||this._state===ta.TOUCH_ZOOM_TRUCK?this._truckInternal(r,n,!1):this._state!==ta.TOUCH_DOLLY_OFFSET&&this._state!==ta.TOUCH_ZOOM_OFFSET||this._truckInternal(r,n,!0);break}case ta.TRUCK:case ta.TOUCH_TRUCK:this._truckInternal(r,n,!1);break;case ta.OFFSET:case ta.TOUCH_OFFSET:this._truckInternal(r,n,!0)}this.dispatchEvent({type:"control",eventType:ea(this._state)})},v=t=>{da(this._activePointers,_a),e.copy(_a),0===this._activePointers.length&&(this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("touchmove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("touchend",d),this.dispatchEvent({type:"controlend",eventType:ea(t||this._state)+"end"}))};this._domElement.addEventListener("pointerdown",r),ga&&this._domElement.addEventListener("mousedown",n),ga&&this._domElement.addEventListener("touchstart",s),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",m),this._removeAllEventListeners=()=>{this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("mousedown",n),this._domElement.removeEventListener("touchstart",s),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",m),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",a),this._domElement.ownerDocument.removeEventListener("touchmove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mouseup",c),this._domElement.ownerDocument.removeEventListener("touchend",d)},this.cancel=()=>{if(this._state===ta.NONE)return;let t=this._state;this._state=ta.NONE,this._activePointers.length=0,v(t)}}this.update(0)}static install(){wa=Object.freeze(new be.Vector3(0,0,0)),xa=Object.freeze(new be.Vector3(0,1,0)),ba=Object.freeze(new be.Vector3(0,0,1)),_a=new be.Vector2,Aa=new be.Vector3,Sa=new be.Vector3,Ta=new be.Vector3,Ea=new be.Vector3,Pa=new be.Vector3,Ma=new be.Vector3,Ca=new be.Vector3,La=new be.Vector3,Ra=new be.Spherical,Oa=new be.Spherical,Fa=new be.Box3,Na=new be.Box3,Da=new be.Sphere,Ia=new be.Quaternion,Ua=new be.Quaternion,Ba=new be.Matrix4,ka=new be.Raycaster}static get ACTION(){return va}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,t?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="")}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}addEventListener(t,e){super.addEventListener(t,e)}removeEventListener(t,e){super.removeEventListener(t,e)}rotate(t,e,i=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+e,i)}rotateAzimuthTo(t,e=!1){return this.rotateTo(t,this._sphericalEnd.phi,e)}rotatePolarTo(t,e=!1){return this.rotateTo(this._sphericalEnd.theta,t,e)}rotateTo(t,e,i=!1){const r=be.MathUtils.clamp(t,this.minAzimuthAngle,this.maxAzimuthAngle),n=be.MathUtils.clamp(e,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=n,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const s=!i||aa(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&aa(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(s)}dolly(t,e=!1){return this.dollyTo(this._sphericalEnd.radius-t,e)}dollyTo(t,e=!1){const i=this._sphericalEnd.radius,r=be.MathUtils.clamp(t,this.minDistance,this.maxDistance);if(this.colliderMeshes.length>=1){const t=this._collisionTest(),e=aa(t,this._spherical.radius);if(!(i>r)&&e)return Promise.resolve();this._sphericalEnd.radius=Math.min(r,t)}else this._sphericalEnd.radius=r;this._needsUpdate=!0,e||(this._spherical.radius=this._sphericalEnd.radius);const n=!e||aa(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(n)}zoom(t,e=!1){return this.zoomTo(this._zoomEnd+t,e)}zoomTo(t,e=!1){this._zoomEnd=be.MathUtils.clamp(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const i=!e||aa(this._zoom,this._zoomEnd,this.restThreshold);return this._createOnRestPromise(i)}pan(t,e,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,e,i)}truck(t,e,i=!1){this._camera.updateMatrix(),Ea.setFromMatrixColumn(this._camera.matrix,0),Pa.setFromMatrixColumn(this._camera.matrix,1),Ea.multiplyScalar(t),Pa.multiplyScalar(-e);const r=Aa.copy(Ea).add(Pa),n=Sa.copy(this._targetEnd).add(r);return this.moveTo(n.x,n.y,n.z,i)}forward(t,e=!1){Aa.setFromMatrixColumn(this._camera.matrix,0),Aa.crossVectors(this._camera.up,Aa),Aa.multiplyScalar(t);const i=Sa.copy(this._targetEnd).add(Aa);return this.moveTo(i.x,i.y,i.z,e)}moveTo(t,e,i,r=!1){const n=Aa.set(t,e,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,n,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);const s=!r||aa(this._target.x,this._targetEnd.x,this.restThreshold)&&aa(this._target.y,this._targetEnd.y,this.restThreshold)&&aa(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}fitToBox(t,e,{paddingLeft:i=0,paddingRight:r=0,paddingBottom:n=0,paddingTop:s=0}={}){const o=[],a=t.isBox3?Fa.copy(t):Fa.setFromObject(t);a.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const l=la(this._sphericalEnd.theta,sa),h=la(this._sphericalEnd.phi,sa);o.push(this.rotateTo(l,h,e));const c=Aa.setFromSpherical(this._sphericalEnd).normalize(),d=Ia.setFromUnitVectors(c,ba);aa(Math.abs(c.y),1)&&d.multiply(Ua.setFromAxisAngle(xa,l));const u=Na.makeEmpty();Sa.copy(a.min).applyQuaternion(d),u.expandByPoint(Sa),Sa.copy(a.min).setX(a.max.x).applyQuaternion(d),u.expandByPoint(Sa),Sa.copy(a.min).setY(a.max.y).applyQuaternion(d),u.expandByPoint(Sa),Sa.copy(a.max).setZ(a.min.z).applyQuaternion(d),u.expandByPoint(Sa),Sa.copy(a.min).setZ(a.max.z).applyQuaternion(d),u.expandByPoint(Sa),Sa.copy(a.max).setY(a.min.y).applyQuaternion(d),u.expandByPoint(Sa),Sa.copy(a.max).setX(a.min.x).applyQuaternion(d),u.expandByPoint(Sa),Sa.copy(a.max).applyQuaternion(d),u.expandByPoint(Sa),d.setFromUnitVectors(ba,c),u.min.x-=i,u.min.y-=n,u.max.x+=r,u.max.y+=s;const p=u.getSize(Aa),m=u.getCenter(Sa).applyQuaternion(d);if(ia(this._camera)){const t=this.getDistanceToFitBox(p.x,p.y,p.z);o.push(this.moveTo(m.x,m.y,m.z,e)),o.push(this.dollyTo(t,e)),o.push(this.setFocalOffset(0,0,0,e))}else if(ra(this._camera)){const t=this._camera,i=t.right-t.left,r=t.top-t.bottom,n=Math.min(i/p.x,r/p.y);o.push(this.moveTo(m.x,m.y,m.z,e)),o.push(this.zoomTo(n,e)),o.push(this.setFocalOffset(0,0,0,e))}return Promise.all(o)}fitToSphere(t,e){const i=[],r=t instanceof be.Sphere?Da.copy(t):function(t,e){const i=e,r=i.center;Fa.makeEmpty(),t.traverseVisible((t=>{t.isMesh&&Fa.expandByObject(t)})),Fa.getCenter(r);let n=0;return t.traverseVisible((t=>{if(!t.isMesh)return;const e=t,i=e.geometry.clone();if(i.applyMatrix4(e.matrixWorld),i.isBufferGeometry){const t=i.attributes.position;for(let e=0,i=t.count;ei.pointerId===t&&(e=i,!0))),e}_encloseToBoundary(t,e,i){const r=e.lengthSq();if(0===r)return t;const n=Sa.copy(e).add(t),s=this._boundary.clampPoint(n,Ta).sub(n),o=s.lengthSq();if(0===o)return t.add(e);if(o===r)return t;if(0===i)return t.add(e).add(s);{const r=1+i*o/e.dot(s);return t.add(Sa.copy(e).multiplyScalar(r)).add(s.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(ia(this._camera)){const t=this._camera,e=t.near,i=t.getEffectiveFOV()*be.MathUtils.DEG2RAD,r=Math.tan(.5*i)*e,n=r*t.aspect;this._nearPlaneCorners[0].set(-n,-r,0),this._nearPlaneCorners[1].set(n,-r,0),this._nearPlaneCorners[2].set(n,r,0),this._nearPlaneCorners[3].set(-n,r,0)}else if(ra(this._camera)){const t=this._camera,e=1/t.zoom,i=t.left*e,r=t.right*e,n=t.top*e,s=t.bottom*e;this._nearPlaneCorners[0].set(i,n,0),this._nearPlaneCorners[1].set(r,n,0),this._nearPlaneCorners[2].set(r,s,0),this._nearPlaneCorners[3].set(i,s,0)}}_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1))return t;if(ua(this._camera,"_collisionTest"))return t;const e=Aa.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);Ba.lookAt(wa,e,this._camera.up);for(let i=0;i<4;i++){const r=Sa.copy(this._nearPlaneCorners[i]);r.applyMatrix4(Ba);const n=Ta.addVectors(this._target,r);ka.set(n,e),ka.far=this._spherical.radius+1;const s=ka.intersectObjects(this.colliderMeshes);0!==s.length&&s[0].distance{const e=()=>{this.removeEventListener("rest",e),t()};this.addEventListener("rest",e)})))}_removeAllEventListeners(){}}const Va={PAN:ja.ACTION.TRUCK,ROTATE:ja.ACTION.ROTATE,ZOOM:ja.ACTION.ZOOM,DOLLY:ja.ACTION.DOLLY,DOLLY_PAN:ja.ACTION.DOLLY_TRUCK,ZOOM_PAN:ja.ACTION.ZOOM_TRUCK,NONE:ja.ACTION.NONE},{OrthographicCamera:za,PerspectiveCamera:Ga,Clock:Ha}=be,Xa=["minAzimuthAngle","maxAzimuthAngle","minDistance","maxDistance","maxPolarAngle","minPolarAngle","minZoom","maxZoom"];class Wa extends ui{constructor(t,e){if(super(),!t)throw new Error("init cameraControl error, need Viewer instance");this.viewer=t;const{width:i,height:r}=t.getSize(),n=this.option=pt({width:i,height:r,far:1e4,near:.05,fov:60,orthoFar:1e4,orthoNear:-1e4,aspect:null,isOrtho:!1,center:{x:0,y:0,z:0},position:{x:0,y:50,z:100},enabled:!0,mouseButtonLeft:"rotate",mouseButtonRight:"pan",mouseButtonWheel:"dolly",mouseButtonMiddle:"dolly",moveStep:.25,rotateAngle:1,keypress:!1,type:"3d",minAzimuthAngle:-1/0,maxAzimuthAngle:1/0,minDistance:1,maxDistance:1e4,maxPolarAngle:.5*Math.PI,minPolarAngle:0,dollyToCursor:!0,draggingDampingFactor:4},e||{});this.isOrtho=n.isOrtho,this.type="3d",this.orthographicCamera=null,this.orthographicCameraControls=null,this.perspectiveCamera=null,this.perspectiveCameraControls=null,this._updateClock=new Ha,this._keypress=n.keypress||!1,this.moveStep=n.moveStep||.1,this.rotateAngle=n.rotateAngle||1,this.keypressed={KeyD:!1,KeyA:!1,KeyS:!1,KeyW:!1,ArrowUp:!1,ArrowDown:!1,ArrowLeft:!1,ArrowRight:!1,shift:!1},ht(["_cameraControlStart","_cameraUpdateDelay","_keyDown","_keyUp"],this),this._initCamera(n),this.setRange(n),this.setInteract(n),this.setType(n.type),this._initEvent(),this.updateProjectionMatrix()}tick(t){if(!this.control)return!0;return this.control.update(t)}_initCamera(t){const{width:e,height:i,fov:r,near:n,far:s,orthoNear:o,orthoFar:a,enabled:l,center:h,position:c}=t,d=e/i,u=this.viewer.rendererContainer;this.orthographicCamera=new za(e/-2,e/2,i/2,i/-2,o||n,a||s);const p=this.orthographicCameraControls=new ja(this.orthographicCamera,u);p.enabled=l,this.perspectiveCamera=new Ga(r,d,n,s);const m=this.perspectiveCameraControls=new ja(this.perspectiveCamera,u);m.enabled=l,Object.keys(pe).forEach((t=>{p.camera.layers.enable(pe[t]),m.camera.layers.enable(pe[t])})),this.setCenter(h,!1),this.setPosition(c,!1)}_cameraControlStart(t){}_cameraUpdateDelay(t){if(!this.viewer.sm)return;const e=this.viewer.sm.getScene();if(e){if(e&&e.avoidBillboards.length){e.avoidBillboards.each((t=>{t.updateScale()})),e.avoid&&e.updateAvoid(this.viewer)}this.viewer._updatePopups(),this.viewer._updateControls(),e._updateDefaultLight(),this.viewer.rm.enableRender()}}_cameraUpdateImmediately(){if(!this.viewer.sm)return;const t=this.viewer.sm.getScene();t&&(this.viewer._updatePopups(),t._updateDefaultLight(),this.viewer.rm.enableRender())}_keyDown(t){if(!this.keypress)return;let e=t.code;e=e.indexOf("hift")>0?"shift":e,void 0!==this.keypressed[e]&&(this.keypressed[e]=!0,this._keypressedHandle())}_keyUp(t){if(!this.keypress)return;let e=t.code;e=e.indexOf("hift")>0?"shift":e,void 0!==this.keypressed[e]&&(this.keypressed[e]=!1)}_keypressedHandle(){if(!this.keypress)return;const{moveStep:t,rotateAngle:e,type:i}=this,{KeyA:r,KeyD:n,KeyW:s,KeyS:o,ArrowDown:a,ArrowUp:l,ArrowLeft:h,ArrowRight:c,shift:d}=this.keypressed;d?"3d"==this.type&&(a&&this.truck(0,.5*-t,!1),l&&this.truck(0,.5*t,!1)):(r&&this.pan(-1*t,0,!1),n&&this.pan(t,0,!1),s&&this.forward(t,!1),o&&this.forward(-1*t,!1),"3d"==i&&(c&&this.rotate(e,0,!1),h&&this.rotate(-1*e,0,!1),a&&this.rotate(0,-1*e,!1),l&&this.rotate(0,e,!1))),this.cameraUpdateEvent()}_initEvent(){this.step=0,this.cameraUpdateEvent=ut(this._cameraUpdateDelay,0,this),this.cameraUpdateImmediately=ut(this._cameraUpdateImmediately,100,this),this.control.addEventListener("controlstart",this._cameraControlStart),this.control.addEventListener("control",this.cameraUpdateEvent),this.control.addEventListener("sleep",this.cameraUpdateEvent),this.control.addEventListener("controlend",this.cameraUpdateEvent),this.control.addEventListener("wake",this.cameraUpdateEvent),window.addEventListener("keydown",this._keyDown),window.addEventListener("keyup",this._keyUp)}get enabled(){return this.control.enabled}set enabled(t){this.enabled!==t&&this.setEnabled(t)}get keypress(){return this._keypress}set keypress(t){this._keypress!==t&&(this._keypress=!!t)}setEnabled(t){this.perspectiveCameraControls.enabled=!!t,this.orthographicCameraControls.enabled=!!t}setInteract(t){if(t&&!tt(t))for(const e in t)["mouseButtonLeft","mouseButtonRight","mouseButtonWheel","mouseButtonMiddle"].includes(e)&&(this[e]=t[e]);const{mouseButtonLeft:e,mouseButtonRight:i,mouseButtonWheel:r,mouseButtonMiddle:n}=this,s={left:e?.toUpperCase(),right:i?.toUpperCase(),wheel:r?.toUpperCase(),middle:n?.toUpperCase()};for(const t in s)this.perspectiveCameraControls.mouseButtons[t]=Va[s[t]],this.orthographicCameraControls.mouseButtons[t]="wheel"===t||"middle"===t?Va.ZOOM:Va[s[t]];this.control.dollySpeed=t.dollySpeed||.5,this.control.truckSpeed=t.truckSpeed||2*t.moveStep||1,this.control.dampingFactor=t.dampingFactor||.3,this.control.draggingDampingFactor=t.draggingDampingFactor||1,this.control.dollyToCursor=t.dollyToCursor}setRange(t,e){if(t)if(Q(t)&&void 0!==e&&Xa.includes(t))this.control[t]=e;else if(q(t))for(const e in t)void 0!==t[e]&&Xa.includes(e)&&(this.control[e]=t[e])}getRange(t){return Xa.includes(t)?this.control[t]:void 0}updateProjectionMatrix(){this.perspectiveCamera.updateProjectionMatrix(),this.orthographicCamera.updateProjectionMatrix()}setSize(t,e){if(!J(t)||!J(e))return this;this.width=t,this.height=e;const i=t/e,{perspectiveCamera:r,orthographicCamera:n}=this;return r.aspect=i,n.left=-t/2,n.right=t/2,n.top=e/2,n.bottom=-e/2,this.updateProjectionMatrix(),this}get fov(){return this.camera.fov}set fov(t){this.setFov(t)}setFov(t){return J(t)&&t>=0&&(this.camera.fov=t,this.camera.updateProjectionMatrix()),this}setOrtho(t){if(K(t)||this.isOrtho===t)return this;const e=this.viewer.rendererManager.effectRenderer.enable;this.viewer.rendererManager.setMainRendererEnable(!1);const{perspectiveCamera:i,orthographicCamera:r,orthographicCameraControls:n,perspectiveCameraControls:s}=this,o=this.center,a=this.position;if(t){if(!this.isOrtho){const t=i.fov;var l=2*Math.tan(t/2*Math.PI/180)*a.distanceTo(o),h=l*i.aspect;r.left=-h/2,r.right=h/2,r.top=l/2,r.bottom=-l/2,n.setPosition(a.x,a.y,a.z,!1),n.setTarget(o.x,o.y,o.z,!1),this.control._sphericalEnd.makeSafe(),this.control._needsUpdate=!0}}else this.isOrtho&&(s.setPosition(a.x,a.y,a.z,!1),s.setTarget(o.x,o.y,o.z,!1),this.control._sphericalEnd.makeSafe(),this.control._needsUpdate=!0);return this.isOrtho=!this.isOrtho,this.camera.updateProjectionMatrix(),this._cameraUpdateDelay(),this.viewer.rendererManager.setMainRendererEnable(e),this}setType(t){if(!t||this.type===t)return;this.enableRotate(),this.type=t;const{polarAngle:e,azimuthAngle:i,maxPolarAngle:r,minPolarAngle:n}=this.control;switch(t){case"2d":this._tempPolarAngle=e,this._tempPolarMaxAngle=r,this._tempPolarMinAngle=n,this.setOrtho(!0),this.control.rotateTo(i,0),this.control._sphericalEnd.phi=0,this.control._sphericalEnd.makeSafe(),this.control.maxPolarAngle=0,this.control.minPolarAngle=0,this.control._needsUpdate=!0;break;case"3d":this.setOrtho(!1),void 0!==this._tempPolarAngle&&(this.control.rotateTo(i,this._tempPolarAngle),this.control.maxPolarAngle=this._tempPolarMaxAngle,this.control.minPolarAngle=this._tempPolarMinAngle)}this._cameraUpdateDelay()}get position(){return this.control.getPosition()}set position(t){this.setPosition(t,!0)}setPosition(t,e){const i=ti(t);return i&&this.control.setPosition(i.x,i.y,i.z,e),this}get center(){return this.control.getTarget()}set center(t){this.setCenter(t,!0)}setCenter(t,e=!1){const i=ti(t);return i&&this.control.setTarget(i.x,i.y,i.z,e),this}get far(){return this.camera.far}set far(t){this.setFar(t)}setFar(t){J(t)&&t>1e-5&&(this.camera.far=t,this.camera.updateProjectionMatrix())}get near(){return this.camera.near}set near(t){this.setNear(t)}setNear(t){J(t)&&t>1e-5&&(this.camera.near=t,this.camera.updateProjectionMatrix())}get zoom(){return this.camera.zoom}set zoom(t){this.setZoom(t)}setZoom(t){this.control.zoomTo(t)}get camera(){return this.isOrtho?this.orthographicCamera:this.perspectiveCamera}get control(){return this.isOrtho?this.orthographicCameraControls:this.perspectiveCameraControls}toPerspective(){this._initRange(),this.setOrtho(!1),this._switch2DTo3D()}_switch2DTo3D(){"2d"===this.type&&this.setType("3d")}disableRotate(t){["minAzimuthAngle","maxAzimuthAngle","minPolarAngle","maxPolarAngle"].forEach((t=>{void 0===this["_old_"+t]&&(this["_old_"+t]=this.control[t]),delete this["_old"+t]})),(!t||t&&t.disableAzimuthAngle)&&(this.setRange("minAzimuthAngle",0),this.setRange("maxAzimuthAngle",0)),(!t||t&&t.disablePolarAngle)&&(this.setRange("minPolarAngle",this.control.polarAngle),this.setRange("maxPolarAngle",this.control.polarAngle))}enableRotate(){["minAzimuthAngle","maxAzimuthAngle","minPolarAngle","maxPolarAngle"].forEach((t=>{void 0!==this["_old_"+t]&&(this.setRange(t,this["_old_"+t]),delete this["_old_"+t])}))}_initRange(){this.control.minAzimuthAngle=-1/0,this.control.maxAzimuthAngle=1/0,this.control.minPolarAngle=-1/0,this.control.maxPolarAngle=1/0}toFrontView(){this._initRange(),this._switch2DTo3D(),this.setOrtho(!0),this.rotateTo(0,90,{enableTransition:!1}),this.setRange("minAzimuthAngle",0),this.setRange("maxAzimuthAngle",0),this.setRange("minPolarAngle",Math.PI/2),this.setRange("maxPolarAngle",Math.PI/2)}toBackView(){this._initRange(),this._switch2DTo3D(),this.setOrtho(!0),this.rotateTo(-180,90,{enableTransition:!1}),this.setRange("minAzimuthAngle",-Math.PI),this.setRange("maxAzimuthAngle",-Math.PI),this.setRange("minPolarAngle",Math.PI/2),this.setRange("maxPolarAngle",Math.PI/2)}toLeftView(){this._initRange(),this._switch2DTo3D(),this.setOrtho(!0),this.rotateTo(-90,90,{enableTransition:!1}),this.setRange("minAzimuthAngle",-Math.PI/2),this.setRange("maxAzimuthAngle",-Math.PI/2),this.setRange("minPolarAngle",Math.PI/2),this.setRange("maxPolarAngle",Math.PI/2)}toRightView(){this._initRange(),this._switch2DTo3D(),this.setOrtho(!0),this.rotateTo(90,90,{enableTransition:!1}),this.setRange("minAzimuthAngle",Math.PI/2),this.setRange("maxAzimuthAngle",Math.PI/2),this.setRange("minPolarAngle",Math.PI/2),this.setRange("maxPolarAngle",Math.PI/2)}toTopView(){this._initRange(),this._switch2DTo3D(),this.setOrtho(!0),this.control.rotatePolarTo(0),this.setRange("minPolarAngle",0),this.setRange("maxPolarAngle",0)}toBottomView(){this._initRange(),this._switch2DTo3D(),this.setOrtho(!0),this.control.rotatePolarTo(Math.PI),this.setRange("minPolarAngle",Math.PI),this.setRange("maxPolarAngle",Math.PI)}pan(t,e,i){return this.control.truck(t,e,i),this.viewer.rendererManager.enableRender(),this}forward(t,e){return this.control.forward(t||0,e),this.viewer.rendererManager.enableRender(),this}moveTo(t,e,i,r){return this.control.moveTo(t,e,i,r),this.viewer.rendererManager.enableRender(),this}fitTo(t,e){const i=pt({enableTransition:!1,paddingLeft:1,paddingRight:1,paddingTop:1,paddingBottom:1},e||{}),{polarAngle:r,azimuthAngle:n}=this.control;if(t instanceof be.Object3D){const e=t.getBox3();if(e.min.x==1/0||e.max.x==1/0)return}return this.control.fitToBox(t,i.enableTransition,i),this.control.rotateTo(n,r),this}fitToScene(t){this.fitTo(this.viewer.scene.root,t)}lookAt(t,e,i){return e=e||this.camera.position.clone(),this.control.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,i),this}rotate(t,e,i){const r=pt({enableTransition:!0,unit:"degree"},i||{});return t=t||0,e=e||0,"degree"===r.unit&&(t=be.Math.degToRad(t),e=be.Math.degToRad(e)),e="3d"===this.type?e:0,this.control.rotate(t,e,r.enableTransition),this}rotateTo(t,e,i){const r=pt({enableTransition:!0,unit:"degree"},i||{});let n=t||0,s=e||0;return"degree"===r.unit&&(n=be.Math.degToRad(t),s=be.Math.degToRad(e)),s="3d"===this.type?s:0,J(t)&&J(e)?this.control.rotateTo(n,s,r.enableTransition):J(t)?this.control.rotateAzimuthTo(n,r.enableTransition):J(e)&&this.control.rotatePolarTo(s,r.enableTransition),this}truck(t,e,i){this.control.truck(t||0,e||0,i)}removeEvent(){this.control._removeAllEventListeners(),window.removeEventListener("keydown",this._keyDown),window.removeEventListener("keyup",this._keyUp)}setFirstPersonMode(t,e){if(this.firstPersonMode=!!t,this._switch2DTo3D(),e=e||{},this._oldInteract?t||(this.setInteract({mouseButtonLeft:this._oldInteract.mouseButtonLeft,mouseButtonRight:this._oldInteract.mouseButtonRight}),this.keypress=this._oldInteract.keypress,this.control.minDistance=this._oldInteract.minDistance,this.control.maxDistance=this._oldInteract.maxDistance,this.control.maxPolarAngle=this._oldInteract.maxPolarAngle,this.control.minPolarAngle=this._oldInteract.minPolarAngle,this.control.azimuthRotateSpeed=this._oldInteract.azimuthRotateSpeed,this.control.polarRotateSpeed=this._oldInteract.polarRotateSpeed,this.control.reset().then((()=>{this.setPosition(this._oldInteract.position)}))):this._oldInteract={mouseButtonLeft:this.mouseButtonLeft,mouseButtonMiddle:this.mouseButtonMiddle,mouseButtonRight:this.mouseButtonRight,mouseButtonWheel:this.mouseButtonWheel,keypress:this.keypress,minDistance:this.control.minDistance,maxDistance:this.control.maxDistance,minPolarAngle:this.control.minPolarAngle,maxPolarAngle:this.control.maxPolarAngle,azimuthRotateSpeed:this.control.azimuthRotateSpeed,polarRotateSpeed:this.control.polarRotateSpeed,position:this.position.clone(),target:this.control.getTarget()},t){this.control.minDistance=this.control.maxDistance=1,this.control.azimuthRotateSpeed=-.1,this.control.polarRotateSpeed=-.1,this.control.touches.two="TOUCH_ZOOM_TRUCK",this.control.saveState();const t=this.position.clone();e.offsetY&&(t.y+=e.offsetY||0),t.z+=e.offsetZ||0,t.x+=e.offsetX||0;let i=this.control.getTarget();this.lookAt(i,t,!1),this.control.maxPolarAngle=180*be.Math.DEG2RAD,this.setInteract({mouseButtonLeft:"ROTATE",mouseButtonRight:"PAN"}),this.keypress=!0}}getEyeVector(){let t=this.camera;return t?this.control._target.clone().sub(t.position):new be.Vector3(0,0,-1)}destroy(){this.keypress=!1,this.removeEvent(),this.control.dispose(),this.perspectiveCamera=null,this.perspectiveCameraControls=null,this.orthographicCamera=null,this.orthographicCameraControls=null}}class Ya extends Mo{constructor(t){super(t),this.isGroup=!0,this.type="Group"}toJSON(t){const e=super.toJSON();return{children:this.children.map((e=>e.toJSON(t))),object:{...e.object,children:void 0},config:{...e.config,...this.option},name:this.name,type:this.type}}}var Qa={helper:{grid:{visible:!1,size:200,divisions:200,color1:"#1b1b1b",color2:"#050505",position:[0,0,0]},axes:{visible:!1,size:2e3}},defaultLights:{enable:!0,csm:{enable:!0,maxFar:100,cascades:4,lightColor:"#FFFFFF",lightIntensity:.15,lightDirection:[-.577,-.577,.577]},ambientLight:{intensity:.8,color:16777215},hemisphereLight:{intensity:.5,color:16777215,groundColor:8947848},secondaryLight:{intensity:.2,color:16777215,alpha:.5,beta:.866}},fog:{visible:!1,color:"#ffffff",near:10,far:30},background:"#3C3C3C",envmap:"",avoid:!1,avoidPadding:4,meta:[]};class Ja{constructor(t){t=t||{},this.boxs=[],this.padding=t.padding||0}clear(){this.boxs.length=0}push(t){if(0===this.boxs.length)return this.boxs.push(t),!1;for(let e=0;ei;i++)this._items.push(t[i])}else null!=t&&this._items.push(t)}else if(t>1){let e=Math.min(t,this.maxLength);for(let t=0;e>t;t++)this._items.push(arguments[t])}}forEach(t,e){this.each(t,e)}push(){if(!(this._items.length>=this.maxLength))for(var t=0;t=this.maxLength))return this._items.unshift.apply(this._items,arguments)}size(){return this._items.length}isEmpty(){return 0===this._items.length}add(t,e){this._items.length>=this.maxLength||(void 0===e?this._items.push(t):this._items.splice(e,0,t))}addAll(t){this._items.length>=this.maxLength||(Za(t)&&(t=t._items),isArray(t)?appendArray(this._items,t):this._items.push(t))}get(t){return this._items[t]}slice(t,e){return new qa(this._items.slice(t,e))}remove(t){var e=this._items.indexOf(t);return e>=0&&e=0}indexOf(t){return this._items.indexOf(t)}each(t,e){for(var i=0,r=this._items.length;r>i;i++){var n=this._items[i];e?t.call(e,n,i,this):t(n,i,this)}}reverseEach(t,e){for(var i=this._items.length-1;i>=0;i--){var r=this._items[i];e?t.call(e,r):t(r)}}getArray(){return this._items}toArray(t,e){if(t){for(var i,r=[],n=0,s=this._items.length;s>n;n++)i=this._items[n],e?t.call(e,i)&&r.push(i):t(i)&&r.push(i);return r}return this._items.concat()}toList(t,e){if(t){for(var i,r=new qa,n=0,s=this._items.length;s>n;n++)i=this._items[n],e?t.call(e,i)&&r.add(i):t(i)&&r.add(i);return r}return new qa(this)}reverse(){this._items.reverse()}sort(t){return this._items.sort(t||sortFunc),this}toString(){return this._items.toString()}get length(){return this._items.length}set length(t){this._items.length=t}}const{ObjectLoader:Ka}=THREE;class $a extends Ka{async parseAsync(t){if(!t)return[];t.models&&t.models.length>0&&await this.parseModels(t.models);const e=({type:t,config:i,object:r,name:n,material:s,geometry:o,children:a})=>{const l=Mf(t,n,i);return l?(l.isGroup&&(r&&l.copy(super.parseObject(r)),a&&a.forEach((t=>{const i=e(t);i&&l.add(i)}))),l):null};return t.things?t.things.map(e):[]}parseModels(t,e){(t=t||[]).length;const i=t.map((t=>new Promise((e=>{let i=mo.getById(t.id);i?e():(i=mo.set(t),i.once("loaded",(()=>{e()})))}))));return Promise.all(i)}}class tl extends be.DataTextureLoader{constructor(t){super(t),this.type=be.HalfFloatType}parse(t){const e=function(t,e){switch(t){case 1:console.error("THREE.RGBELoader Read Error: "+(e||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(e||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(e||""));break;default:console.error("THREE.RGBELoader: Error: "+(e||""))}return-1},i=function(t,e,i){e=e||1024;let r=t.pos,n=-1,s=0,o="",a=String.fromCharCode.apply(null,new Uint16Array(t.subarray(r,r+128)));for(;0>(n=a.indexOf("\n"))&&s=t.byteLength||!(l=i(t)))return e(1,"no header found");if(!(h=l.match(/^#\?(\S+)/)))return e(3,"bad initial token");for(a.valid|=1,a.programtype=h[1],a.string+=l+"\n";l=i(t),!1!==l;)if(a.string+=l+"\n","#"!==l.charAt(0)){if((h=l.match(r))&&(a.gamma=parseFloat(h[1])),(h=l.match(n))&&(a.exposure=parseFloat(h[1])),(h=l.match(s))&&(a.valid|=2,a.format=h[1]),(h=l.match(o))&&(a.valid|=4,a.height=parseInt(h[1],10),a.width=parseInt(h[2],10)),2&a.valid&&4&a.valid)break}else a.comments+=l+"\n";return 2&a.valid?4&a.valid?a:e(3,"missing image size specifier"):e(3,"missing format specifier")}(s);if(-1!==o){const t=o.width,i=o.height,a=function(t,i,r){const n=i;if(n<8||n>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);if(n!==(t[2]<<8|t[3]))return e(3,"wrong scanline width");const s=new Uint8Array(4*i*r);if(!s.length)return e(4,"unable to allocate buffer space");let o=0,a=0;const l=4*n,h=new Uint8Array(4),c=new Uint8Array(l);let d=r;for(;d>0&&at.byteLength)return e(1);if(h[0]=t[a++],h[1]=t[a++],h[2]=t[a++],h[3]=t[a++],2!=h[0]||2!=h[1]||(h[2]<<8|h[3])!=n)return e(3,"bad rgbe scanline format");let i,r=0;for(;r128;if(n&&(i-=128),0===i||r+i>l)return e(3,"bad scanline data");if(n){const e=t[a++];for(let t=0;t{this.add(t)})),this.dispatchEvent({type:"ready"})}async preload(t){if(!t)return;const e=new $a;await e.parseAsync(t),this.dispatchEvent({type:"preloaded"})}async _init(t){if(this._avoid=!!this.option.avoid,this.avoidPadding=this.option.avoidPadding,this.setBackground(this.option.background),this._initDefaultLights(t),this.setFog(),this._initHelper(),await this._initThing(),t){const e=this.option.defaultLights.csm;this.csm=new mf({mode:"practical",parent:this.defaultLightGroup,camera:t.camera,...e}),this.csm.setEnable(e.enable),this.option.defaultLights.enable&&e.enable&&this.csm.update(),this.setEnvironment(this.option.envmap,t.rendererManager)}this._inited||(this._inited=!0,setTimeout((()=>{this.dispatchEvent({type:"inited"})}),200))}_initHelper(){this.helperGroup||(this.helperGroup=new Ya,this.helperGroup.name="helperGroup",this.add(this.helperGroup,this)),this.setHelper()}updateAvoid(t){if(!t)return;const{avoid:e,boxCollision:i,avoidBillboards:r}=this;this.boxCollision.clear(),e&&0!=r.length&&r.each((e=>{if(e&&e.avoid&&(e.updateBox(t),!1!==e.parent.visible)){let t=i.push(e.box2d);e.avoid&&(e.visible=!t)}}))}clearAvoidBillboards(){this.boxCollision.clear(),this.avoidBillboards.clear()}_restoreAvoidBillboards(){this.boxCollision.clear(),this.avoidBillboards.each((t=>{t.visible=!0}))}_initEvents(){this.addEventListener("resource.loaded",(function(t){const e=t.resource;if(e&&e===this._backgroundResource)switch(e.type){case Kt.CubeTexture:case Kt.TEXTURE:this.background=e.data}}))}_initRoot(){this.root=new Ya,this.root.name="root",this.root.isRoot=!0,this.add(this.root,this),this.tempRoot=new Ya,this.tempRoot.name="tempRoot",this.add(this.tempRoot,this)}_initDefaultLights(t){this.defaultLightGroup||(this.defaultLightGroup=new Ya,this.defaultLightGroup.name="defaultLightsGroup",this.add(this.defaultLightGroup,this)),this.defaultLightGroup.clear();const e=this.defaultLightGroup;e.visible=this.option.defaultLights.enable;[["ambientLight","ambient"],["hemisphereLight","hemisphere"],["secondaryLight","directional"]].forEach((t=>{const i=t[0];let r=null;switch(t[1]){case"ambient":r=new be.AmbientLight;break;case"directional":r=new be.DirectionalLight;break;case"hemisphere":r=new be.HemisphereLight(16777215,2236962,1)}if(r){r.name=i;const t=e.getObjectByName(r.name);t&&e.remove(t),e.add(r)}})),!this.csm&&t&&t.cameraControl,this.setDefaultLights()}setDefaultLights(t){pt(this.option.defaultLights,et(t||{}));const e=this.option.defaultLights,i=this.defaultLightGroup;if(i.visible=e.enable,["ambientLight","hemisphereLight"].forEach((t=>{const r=i.getObjectByName(t);if(r){const{intensity:i,color:n,groundColor:s}=e[t];r.intensity=i;const o=ni(n);r.color.set(o),s&&r.groundColor.set(ni(s))}})),["secondaryLight"].forEach((t=>{const r=i.getObjectByName(t);if(r){const{intensity:i,color:s,shadow:o,shadowQuality:a}=e[t];r.intensity=i,r.visible=i>0;const l=ni(s);if(r.color.set(l),r.castShadow=o,o){var n={low:512,medium:1024,high:2048,ultra:4096}[a]||1024;r.shadow.bias=-.005,r.shadow.mapSize.set(n,n)}}})),this.csm){const t=e.csm,i=e.enable&&t.enable;this.csm.setEnable(i);for(const e in t)if("lightDirection"==e){let e=(new be.Vector3).fromArray(t.lightDirection);this.csm.lightDirection.copy(e)}else this.csm[e]=t[e];this.csm.updateWithParams()}this._updateDefaultLight()}_updateDefaultLight(t){t=t||(this.viewer?this.viewer.cameraControl:null);const e=this.defaultLightGroup;if(!e||!e.visible||!t)return;const i=(new be.Box3).setFromObject(this);if(!i)return;const r=new be.Sphere;i.getBoundingSphere(r),["secondaryLight"].forEach((i=>{const r=e.getObjectByName(i);if(r){(t?t.position:null)&&(r.target.position.copy(t.control.getTarget()),r.position.copy(t.control.getPosition()),r.target.updateMatrixWorld(!0))}}))}setHelper(t){pt(this.option.helper,t||{});const{grid:e,axes:i}=this.option.helper;this.updateAxesHelper(i),this.updateGridHelper(e)}get gridHelperVisible(){const t=this.helperGroup;let e=!1;return["BaseGrid","ExtendGrid"].forEach((i=>{let r=t.getObjectByName(i);r&&(e=void 0===r.visible||r.visible)})),e}set gridHelperVisible(t){const e=this.helperGroup;["BaseGrid","ExtendGrid"].forEach((i=>{let r=e.getObjectByName(i);r&&(r.visible=t)})),this.option.helper.grid.visible=t}updateGridHelper(t){const e=this.helperGroup;["BaseGrid","ExtendGrid"].forEach((i=>{let r=e.getObjectByName(i);t=t||this.option.helper.grid||{};let n="ExtendGrid"==i?.2:1;if(r||(r=new be.GridHelper(t.size,t.divisions*n,t.color1,t.color1),t.color2,r.material.vertexColors=!1,r.name=i,t.onTop,e.add(r)),t.divisions&&t.size){let e=new be.GridHelper(t.size,t.divisions*n);r.geometry=e.geometry.clone(),r.userData.divisions=t.divisions,r.userData.size=t.size}Lt(t.visible)&&(r.visible=t.visible),t.color1&&"BaseGrid"==r.name&&(r.material.color=new be.Color(t.color1),r.userData.color=r.material.color.toHexString()),t.color2&&"ExtendGrid"==r.name&&(r.material.color=ni(t.color2),r.userData.color=r.material.color.toHexString()),Lt(t.opacity)&&(r.material.transparent=t.opacity<1,r.material.opaicty=t.opacity)})),e.traverse((t=>{t._thing_tag="helper",t.layers.set(pe.IGNORE_RAYCAST)}))}updateAxesHelper(t){if(!t)return;const e="axesHelper",i=this.helperGroup;let r=i.getObjectByName(e);if(r||(r=new be.AxesHelper(t.size),r.layers.set(pe.IGNORE_RAYCAST),r.name=e,i.add(r),this.axesHelper=r),r&&(Lt(t.visible)&&(r.visible=t.visible),t.size)){let e=new be.AxesHelper(t.size);e.layers.set(pe.IGNORE_RAYCAST),r.geometry=e.geometry.clone(),e.remove(),e=null}i.traverse((t=>{t._thing_tag="helper",t.layers.set(pe.IGNORE_RAYCAST)}))}updateBoundingBox(){return this.boundingBox?this.boundingBox.setFromVisibleObject(this):this.boundingBox=(new il).setFromVisibleObject(this),this}setFog(t){pt(this.option.fog,t||{});const{color:e,near:i,far:r,visible:n,density:s,isExp2:o}=this.option.fog;return this.fog,this.fog=o?n?new be.Fog(ni(e),s):null:n?new be.Fog(ni(e),i,r):null,this}update(t){this.deltaTime=t}_addObject(t,e){if(!t||!t instanceof el)return null;t.properties||(t.properties={}),t.properties.uuid||(t.properties.uuid=t.uuid);let i=e;(J(i)||Q(i))&&(i=this.getObjectById(i)),i||(i=this.root),t.traverse((t=>{t.scene=this,t.dispatchEvent({type:te,scene:this}),t.addEventListener(t.isSync?"resource.loaded":"added",(()=>{this.dispatchEvent({type:ee,action:"add",object:t})}))})),e===this?be.Scene.prototype.add.call(this,t):i.add(t)}add(t,e){if(!t)return this;if(t instanceof el)return this._addObject(t,e),t;if(q(t)&&!K(t.type)){const{type:i,config:r,children:n,name:s}=t,o=Mf(i,s,r,n);return o?(this._addObject(o,e),o.helper&&this.helperGroup.add(o.helper),o):this}if(W(t)){let i=[];for(let r=0;r1)be.Scene.prototype.remove.call(this,arguments),this.dispatchEvent({type:ee,action:"remove",objects:[...arguments]});else if(1===arguments.length){let e=null;if(t instanceof el?e=[t]:J(t)?e=[this.getObjectById(t)]:W(t)&&(e=t),W(e)){for(let t=0;t{(e instanceof Fo||e!==this.root||!qe(e))&&t(e)}))}isEmpty(){return 0===this.size()}getObjectByAttribute(t,e){var i=[];return this.each((r=>{r.attr(t)===e&&i.push(r)})),i}toList(){let t=[];return this.each((e=>{t.push(e)})),t}getRoots(){return this.root.children.filter((t=>!qe(t)))}size(){let t=0;return this.each((()=>{t++})),t}clear(){return this.root.clear(),this.boxCollision.clear(),this.avoidBillboards.clear(),this.tempRoot.clear(),this.dispatchEvent({type:ee,action:"clear"}),this}getBrothers(t){const e=[];if(t&&t.parent){const i=t;for(let r=0;r{this.environment=t})),this;this.environment=null}setBackground(t){if(this.option.background=t||null,!t)return this.background=null,void(this._skyMesh&&(this._skyMesh.removeBySelf(),this._skyMesh=null));if(this._backgroundResource&&(this._backgroundResource.removeObject(this),mo.delete(this._backgroundResource.type,this._backgroundResource.id),this._backgroundResource=null),Q(t))return this.background=new be.Color(t),this;if(q(t)){if(t.color)return this.background=new be.Color(t),this;if(t.image){const e=mo.set({id:t.image,type:Kt.TEXTURE,object:this});if(t.isSky){const i=t.far||(this.viewer&&this.viewer.camrea?this.viewer.camrea.far:1e4),r=()=>{const t=new be.Mesh(new be.SphereGeometry(i),new be.MeshBasicMaterial({map:e.data,side:1}));this._skyMesh=t,this.root.add(t)};e.data?r():e.on("loaded",(()=>{r()}))}else this.background=e.data,this._backgroundResource=e;return this}if(t.skyboxPath){let e=Tt(t.skyboxPath);const i=mo.set({id:e,type:Kt.CubeTexture,object:this,config:{path:e,files:t.skyFiles}});return this.background=i.data,this._backgroundResource=i,this}if(t.hdr){return(new tl).loadAsync(mo.transformUrl(t.hdr)).then((t=>{t.mapping=be.EquirectangularReflectionMapping,t.encoding=be.sRGBEncoding,this.background=t,this.environment=t})),this}}return this}getRootTree({keyword:t,type:e}={}){return function i(r,n){for(var s=0,o=r.length;s=0&&!r.userData.hideInTree)&&n.push(r):r.userData.hideInTree||n.push(r)),a.children.length>0&&(a.isNode,i(a.children,r.children))}}return n}(this.root.children,[])}toJSON(){function t(t){const e=[];for(const i in t){const r=t[i];delete r.metadata,e.push(r)}return e}const e={geometries:{},materials:{},textures:{},images:{},shapes:{},models:{},things:[]};const i=[];!function t(e,i){!e.isThing||e.userData.hideInTree||e.isRoot?e.children&&e.children.forEach((e=>{t(e,i)})):i(e)}(this.root,(t=>{i.push(t.toJSON(e))}));const r=t(e.geometries),n=t(e.materials),s=t(e.textures),o=t(e.images),a=t(e.shapes),l=t(e.models);return{...this.option,meta:{things:i,geometries:r,materials:n,textures:s,images:o,shapes:a,models:l,defaultLights:this.option.defaultLights}}}}Mt(nl,[{key:"defaultLightsEnable",get:function(){return this.defaultLightGroup.visible},set:function(t){this.defaultLightsEnable!==!!t&&(this.option.defaultLights.enable=!!t,this.defaultLightGroup&&(this.defaultLightGroup.visible=!!t))}}]),pi(nl),Mt(nl,[{key:"avoid",get:function(){return this._avoid},set:function(t){this._avoid=!!t,this._avoid||this._restoreAvoidBillboards(),this.updateAvoid(this.viewer)}},{key:"avoidPadding",get:function(){return this.boxCollision.padding},set:function(t){this.boxCollision.padding=t,this.updateAvoid(this.viewer)}}]);class sl extends ui{constructor(t,e){super(),this.viewer=t,this.option=pt(et(Qa),e),this.current=null,this.scenes={},this._background=null,this._backgroundResource=null,this._skyBox=null,this._skyBoxResource=null,this.sky=null,this.skyEffectLightConfigCache=null,this._fogConfig=null,this._fogLinear=null,this._fogExp2=null,this._enableDeafultViewPointFile=!1,this._defaultViewPointFileName="viewpoint.json",this._initScenes(),this._initRenderControl()}_initScenes(){const t=this.viewer,e=new nl;e.name="default",e._init(t),this.addScene(e);const i=this.sceneHelpers=new nl;i.name="sceneHelpers",this.addScene(i),i._initDefaultLights();const r=this.htmlScene=new nl;r.name="htmlScene",this.addScene(r)}getScene(t){return this.scenes[t||this.current||"default"]}get scene(){return this.getScene()}setCurrent(t){this.current=t}createScene(t){const e=new nl;return e.name=t,this.addScene(e),e}addScene(t){t.viewer=this.viewer,this.scenes[t.name||t.uuid]=t}loadScene(t,e,i){if(!t||!e)return;let r=this.scenes[t];r||(r=this.createScene(t));const n=this.viewer;async function s(t){r.clear(),r.option=pt(et(Qa),t||{}),await r._init(n),r.dispatchEvent({type:"loaded",viewer:n}),i&&i(r)}if(Q(e)){const t=new be.FileLoader;t.setResponseType("json"),t.load(e,(t=>{t?s(t):this.dispatchEvent({type:"error",message:"Scene config is null"})}),(t=>{this.dispatchEvent({type:"progress",progress:t})}),(t=>{this.dispatchEvent({type:"error",message:"Scene load failure"})}))}else s(e)}_initRenderControl(){new be.Vector3,new be.Vector3}destroy(){for(const t in this.scenes)this.scenes[t].destroy();this.scenes={}}}const ol=new be.Frustum,al=new be.Vector3,ll=new be.Vector3,hl=new be.Vector3,cl=new be.Vector3,dl=new be.Vector3,ul=new be.Vector3,pl=new be.Vector3,ml=new be.Vector3,fl=new be.Vector3,gl=new be.Vector3,vl=new be.Vector3,yl=new be.Vector3,wl=new be.Vector3,xl=new be.Vector3,bl=new be.Matrix4,_l=new be.Quaternion,Al=new be.Vector3;class Sl{constructor(t,e,i=Number.MAX_VALUE){this.camera=t,this.scene=e,this.startPoint=new be.Vector3,this.endPoint=new be.Vector3,this.collection=[],this.instances={},this.deep=i}filterCollection(t){let e=this.collection||[];e=e.map((t=>{let e=[];return t.traverseAncestors((t=>{(t.isMesh||t.isThing||t.isSprite||t.isBillboard)&&!t.isScene&&e.push(t)})),e[0]})).filter((t=>t&&"helper"!=t._thing_tag)),e=ot(e,((t,e)=>t.uuid==e.uuid)),this.filter&&Z(this.filter)&&(e=e.filter(this.filter)),t&&Z(t)&&(e=e.filter(t)),this.collection=e}select(t,e){return this.startPoint=t||this.startPoint,this.endPoint=e||this.endPoint,this.collection=[],this.updateFrustum(this.startPoint,this.endPoint),this.searchChildInFrustum(ol,this.scene),this.filterCollection(),this.collection}updateFrustum(t,e){if(t=t||this.startPoint,e=e||this.endPoint,t.x===e.x&&(e.x+=Number.EPSILON),t.y===e.y&&(e.y+=Number.EPSILON),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(),this.camera.isPerspectiveCamera){ll.copy(t),ll.x=Math.min(t.x,e.x),ll.y=Math.max(t.y,e.y),e.x=Math.max(t.x,e.x),e.y=Math.min(t.y,e.y),hl.setFromMatrixPosition(this.camera.matrixWorld),cl.copy(ll),dl.set(e.x,ll.y,0),ul.copy(e),pl.set(ll.x,e.y,0),cl.unproject(this.camera),dl.unproject(this.camera),ul.unproject(this.camera),pl.unproject(this.camera),yl.copy(cl).sub(hl),wl.copy(dl).sub(hl),xl.copy(ul).sub(hl),yl.normalize(),wl.normalize(),xl.normalize(),yl.multiplyScalar(this.deep),wl.multiplyScalar(this.deep),xl.multiplyScalar(this.deep),yl.add(hl),wl.add(hl),xl.add(hl);const i=ol.planes;i[0].setFromCoplanarPoints(hl,cl,dl),i[1].setFromCoplanarPoints(hl,dl,ul),i[2].setFromCoplanarPoints(ul,pl,hl),i[3].setFromCoplanarPoints(pl,cl,hl),i[4].setFromCoplanarPoints(dl,ul,pl),i[5].setFromCoplanarPoints(xl,wl,yl),i[5].normal.multiplyScalar(-1)}else if(this.camera.isOrthographicCamera){const i=Math.min(t.x,e.x),r=Math.max(t.y,e.y),n=Math.max(t.x,e.x),s=Math.min(t.y,e.y);cl.set(i,r,-1),dl.set(n,r,-1),ul.set(n,s,-1),pl.set(i,s,-1),ml.set(i,r,1),fl.set(n,r,1),gl.set(n,s,1),vl.set(i,s,1),cl.unproject(this.camera),dl.unproject(this.camera),ul.unproject(this.camera),pl.unproject(this.camera),ml.unproject(this.camera),fl.unproject(this.camera),gl.unproject(this.camera),vl.unproject(this.camera);const o=ol.planes;o[0].setFromCoplanarPoints(cl,ml,fl),o[1].setFromCoplanarPoints(dl,fl,gl),o[2].setFromCoplanarPoints(gl,vl,pl),o[3].setFromCoplanarPoints(vl,ml,cl),o[4].setFromCoplanarPoints(dl,ul,pl),o[5].setFromCoplanarPoints(gl,fl,ml),o[5].normal.multiplyScalar(-1)}else console.error("THREE.SelectionBox: Unsupported camera type.")}searchChildInFrustum(t,e){if(e.isMesh||e.isLine||e.isPoints||e.isSprite)if(e.isInstancedMesh){this.instances[e.uuid]=[];for(let i=0;i0)for(let i=0;i * http://jaywcjlove.github.io/hotkeys * * Licensed under the MIT license. */var El="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase().indexOf("firefox")>0;function Pl(t,e,i){t.addEventListener?t.addEventListener(e,i,!1):t.attachEvent&&t.attachEvent("on".concat(e),(function(){i(window.event)}))}function Ml(t,e){for(var i=e.slice(0,e.length-1),r=0;r=0;)e[i-1]+=",",e.splice(i,1),i=e.lastIndexOf("");return e}for(var Ll={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":El?173:189,"=":El?61:187,";":El?59:186,"'":222,"[":219,"]":221,"\\":220},Rl={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},Ol={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Fl={16:!1,18:!1,17:!1,91:!1},Nl={},Dl=1;Dl<20;Dl++)Ll["f".concat(Dl)]=111+Dl;var Il=[],Ul="all",Bl=[],kl=function(t){return Ll[t.toLowerCase()]||Rl[t.toLowerCase()]||t.toUpperCase().charCodeAt(0)};function jl(t){Ul=t||"all"}function Vl(){return Ul||"all"}var zl=function(t){var e=t.key,i=t.scope,r=t.method,n=t.splitKey,s=void 0===n?"+":n;Cl(e).forEach((function(t){var e=t.split(s),n=e.length,o=e[n-1],a="*"===o?"*":kl(o);if(Nl[a]){i||(i=Vl());var l=n>1?Ml(Rl,e):[];Nl[a]=Nl[a].map((function(t){return(!r||t.method===r)&&t.scope===i&&function(t,e){for(var i=t.length>=e.length?t:e,r=t.length>=e.length?e:t,n=!0,s=0;s0,Fl)Object.prototype.hasOwnProperty.call(Fl,n)&&(!Fl[n]&&e.mods.indexOf(+n)>-1||Fl[n]&&-1===e.mods.indexOf(+n))&&(r=!1);(0!==e.mods.length||Fl[16]||Fl[18]||Fl[17]||Fl[91])&&!r&&"*"!==e.shortcut||!1===e.method(t,e)&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0))}}function Hl(t){var e=Nl["*"],i=t.keyCode||t.which||t.charCode;if(Xl.filter.call(this,t)){if(93!==i&&224!==i||(i=91),-1===Il.indexOf(i)&&229!==i&&Il.push(i),["ctrlKey","altKey","shiftKey","metaKey"].forEach((function(e){var i=Ol[e];t[e]&&-1===Il.indexOf(i)?Il.push(i):!t[e]&&Il.indexOf(i)>-1?Il.splice(Il.indexOf(i),1):"metaKey"===e&&t[e]&&3===Il.length&&(t.ctrlKey||t.shiftKey||t.altKey||(Il=Il.slice(Il.indexOf(i))))})),i in Fl){for(var r in Fl[i]=!0,Rl)Rl[r]===i&&(Xl[r]=!0);if(!e)return}for(var n in Fl)Object.prototype.hasOwnProperty.call(Fl,n)&&(Fl[n]=t[Ol[n]]);t.getModifierState&&(!t.altKey||t.ctrlKey)&&t.getModifierState("AltGraph")&&(-1===Il.indexOf(17)&&Il.push(17),-1===Il.indexOf(18)&&Il.push(18),Fl[17]=!0,Fl[18]=!0);var s=Vl();if(e)for(var o=0;o1&&(n=Ml(Rl,t)),(t="*"===(t=t[t.length-1])?"*":kl(t))in Nl||(Nl[t]=[]),Nl[t].push({keyup:l,keydown:h,scope:s,mods:n,shortcut:r[a],method:i,key:r[a],splitKey:c});void 0!==o&&!function(t){return Bl.indexOf(t)>-1}(o)&&window&&(Bl.push(o),Pl(o,"keydown",(function(t){Hl(t)})),Pl(window,"focus",(function(){Il=[]})),Pl(o,"keyup",(function(t){Hl(t),function(t){var e=t.keyCode||t.which||t.charCode,i=Il.indexOf(e);if(i>=0&&Il.splice(i,1),t.key&&"meta"===t.key.toLowerCase()&&Il.splice(0,Il.length),93!==e&&224!==e||(e=91),e in Fl)for(var r in Fl[e]=!1,Rl)Rl[r]===e&&(Xl[r]=!1)}(t)})))}var Wl={setScope:jl,getScope:Vl,deleteScope:function(t,e){var i,r;for(var n in t||(t=Vl()),Nl)if(Object.prototype.hasOwnProperty.call(Nl,n))for(i=Nl[n],r=0;r1?e-1:0),r=1;r{this.ctrlDown=!(this.mode!==$t.POINT||"keyup"===t.type||!Xl.ctrl)}))}_removeEvent(){if(!this._viewer)return;const t=this._viewer.container;this.pointerdown&&t.removeEventListener("pointerdown",this.pointerdown),t.removeEventListener("pointermove",this._pointermove),t.removeEventListener("pointerup",this._pointerup),Xl.unbind("*")}_unique(){this.selection=ot(this.selection,((t,e)=>t.uuid===e.uuid)).filter((t=>t&&0!=t.visible))}_fireSelectChange(){this._unique(),this._updateStyle()}_pointerdown(t){if(this.enabled&&V(t)){if(this._removeStyle(),this.__old_selectedIds=this.selection.map((t=>t.id)),this.mode===$t.RECTANGLE&&this.selectionBox)return this._viewer.cameraControl.enabled=!1,this._updateSelectRegion(t,"startPoint"),void this.helper.onPointerDown(t);if(this.mode===$t.POINT){let e=this._viewer.picker.pick(t).picked||[];if(this.ctrlDown){const t=[];for(let i=0;it||this.selection.includes(t))),this.selection=this.selection.concat(e).filter((e=>!t.includes(e.id)))}else this.selection=e;const i=this.selection.map((t=>t.id));Et(this.__old_selectedIds,i)||this._fireSelectChange()}}}_pointermove(t){this.enabled&&this.helper&&this.helper.isDown&&this.mode===$t.RECTANGLE&&(this._updateSelectRegion(t,"endPoint"),this.helper.onPointerMove(t),this.selection=this.selectionBox.select(),this._fireSelectChange())}_pointerup(t){if(this._viewer.cameraControl.enabled=!0,this.enabled&&V(t)&&this.mode===$t.RECTANGLE&&this.selectionBox){this._updateSelectRegion(t,"endPoint"),this.helper.onPointerUp(t),this.selection=this.selectionBox.select(),this._fireSelectChange();const e=this.selection.map((t=>t.id));Et(this.__old_selectedIds,e)}}_updateSelectRegion(t,e){if(!t)return;const{selectionBox:i}=this;if(i&&i[e]){const{x:r,y:n}=z(this._viewer.container,t);i[e].set(r,n,.5)}}_updateStyle(){const{sceneHelpers:t,rendererManager:e}=this._viewer;this.selection.forEach((i=>{if(!i.isLight)if(e.outline)e.addOutlineObject(i);else{const e=new be.BoxHelper(i,16776960);e.name="SelectBox",e.uuid=i.uuid,t.getObjectByProperty("uuid",i.uuid)||t.add(e)}}))}_removeStyle(){this._viewer.rendererManager;const{rendererManager:t,sceneHelpers:e}=this._viewer;this.selection.forEach((i=>{t.removeOutlineObject(i);const r=e.getObjectByProperty("uuid",i.uuid);r&&r.removeFromParent()}))}setSelection(t){if(!W(t))return;this.clear();const{mode:e}=this;e===$t.RECTANGLE&&this.selectionBox&&(this.selectionBox.collection=t.filter((t=>t)),this.selectionBox.filterCollection()),e===$t.POINT&&(this.selection=t.filter((t=>t))),this._unique(),this._updateStyle()}getSelection(){return this.selection}clear(){this._removeStyle();const{selectionBox:t}=this;t&&(t.endPoint.set(0,0,.5),t.startPoint.set(0,0,.5),t.select()),this.selection=[]}selectByScreenCoordinates(t,e){return this._viewer.getIntersects({clientX:t,clientY:e})}}function Jl(t){var e=document.createElement("div");function i(t){return e.appendChild(t.dom),t}function r(t){for(var i=0;i=s+1e3&&(a.update(1e3*o/(t-s),100),s=t,o=0,h)){var e=performance.memory;h.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576)}return t},update:function(){n=this.end()},domElement:e,setMode:r}}Jl.Panel=function(t,e,i){var r=1/0,n=0,s=Math.round,o=s(window.devicePixelRatio||1),a=120*o,l=48*o,h=3*o,c=2*o,d=3*o,u=15*o,p=114*o,m=30*o,f=document.createElement("canvas");f.width=a,f.height=l,f.style.cssText="width:120px;height:48px";var g=f.getContext("2d");return g.font="bold "+9*o+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=i,g.fillRect(0,0,a,l),g.fillStyle=e,g.fillText(t,h,c),g.fillRect(d,u,p,m),g.fillStyle=i,g.globalAlpha=.9,g.fillRect(d,u,p,m),{dom:f,update:function(l,v){r=Math.min(r,l),n=Math.max(n,l),g.fillStyle=i,g.globalAlpha=1,g.fillRect(0,0,a,u),g.fillStyle=e,g.fillText(s(l)+" "+t+" ("+s(r)+"-"+s(n)+")",h,c),g.drawImage(f,d+o,u,p-o,m,d,u,p-o,m),g.fillRect(d+p-o,u,o,m),g.fillStyle=i,g.globalAlpha=.9,g.fillRect(d+p-o,u,o,s((1-l/v)*m))}}};class Zl extends be.EventDispatcher{constructor(t){super(),this.viewer=t,this.stats=new Jl;const e=this.stats.dom.children;D(this.stats.dom,"debugger-render-stats");for(let t=0;t= edgeVert;","\t\tFxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;","/*--------------------------------------------------------------------------*/","\t\tif(!horzSpan) lumaN = lumaW;","\t\tif(!horzSpan) lumaS = lumaE;","\t\tif(horzSpan) lengthSign = fxaaQualityRcpFrame.y;","\t\tFxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;","/*--------------------------------------------------------------------------*/","\t\tFxaaFloat gradientN = lumaN - lumaM;","\t\tFxaaFloat gradientS = lumaS - lumaM;","\t\tFxaaFloat lumaNN = lumaN + lumaM;","\t\tFxaaFloat lumaSS = lumaS + lumaM;","\t\tFxaaBool pairN = abs(gradientN) >= abs(gradientS);","\t\tFxaaFloat gradient = max(abs(gradientN), abs(gradientS));","\t\tif(pairN) lengthSign = -lengthSign;","\t\tFxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);","/*--------------------------------------------------------------------------*/","\t\tFxaaFloat2 posB;","\t\tposB.x = posM.x;","\t\tposB.y = posM.y;","\t\tFxaaFloat2 offNP;","\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;","\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;","\t\tif(!horzSpan) posB.x += lengthSign * 0.5;","\t\tif( horzSpan) posB.y += lengthSign * 0.5;","/*--------------------------------------------------------------------------*/","\t\tFxaaFloat2 posN;","\t\tposN.x = posB.x - offNP.x * FXAA_QUALITY_P0;","\t\tposN.y = posB.y - offNP.y * FXAA_QUALITY_P0;","\t\tFxaaFloat2 posP;","\t\tposP.x = posB.x + offNP.x * FXAA_QUALITY_P0;","\t\tposP.y = posB.y + offNP.y * FXAA_QUALITY_P0;","\t\tFxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;","\t\tFxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));","\t\tFxaaFloat subpixE = subpixC * subpixC;","\t\tFxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));","/*--------------------------------------------------------------------------*/","\t\tif(!pairN) lumaNN = lumaSS;","\t\tFxaaFloat gradientScaled = gradient * 1.0/4.0;","\t\tFxaaFloat lumaMM = lumaM - lumaNN * 0.5;","\t\tFxaaFloat subpixF = subpixD * subpixE;","\t\tFxaaBool lumaMLTZero = lumaMM < 0.0;","/*--------------------------------------------------------------------------*/","\t\tlumaEndN -= lumaNN * 0.5;","\t\tlumaEndP -= lumaNN * 0.5;","\t\tFxaaBool doneN = abs(lumaEndN) >= gradientScaled;","\t\tFxaaBool doneP = abs(lumaEndP) >= gradientScaled;","\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;","\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;","\t\tFxaaBool doneNP = (!doneN) || (!doneP);","\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;","\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;","/*--------------------------------------------------------------------------*/","\t\tif(doneNP) {","\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;","\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;","\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;","\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;","/*--------------------------------------------------------------------------*/","\t\t\t\t#if (FXAA_QUALITY_PS > 3)","\t\t\t\tif(doneNP) {","\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;","\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;","\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;","\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 4)","\t\t\t\t\t\tif(doneNP) {","\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;","\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;","\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;","\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 5)","\t\t\t\t\t\t\t\tif(doneNP) {","\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;","\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;","\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;","\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 6)","\t\t\t\t\t\t\t\t\t\tif(doneNP) {","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;","\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 7)","\t\t\t\t\t\t\t\t\t\t\t\tif(doneNP) {","\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;","\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;","\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;","\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;","/*--------------------------------------------------------------------------*/","\t\t#if (FXAA_QUALITY_PS > 8)","\t\tif(doneNP) {","\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;","\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;","\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;","\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;","/*--------------------------------------------------------------------------*/","\t\t\t\t#if (FXAA_QUALITY_PS > 9)","\t\t\t\tif(doneNP) {","\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;","\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;","\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;","\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 10)","\t\t\t\t\t\tif(doneNP) {","\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;","\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;","\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;","\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 11)","\t\t\t\t\t\t\t\tif(doneNP) {","\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;","\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;","\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;","\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 12)","\t\t\t\t\t\t\t\t\t\tif(doneNP) {","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;","\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;","\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t\t\t}","\t\t\t\t\t\t\t\t\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t}","\t\t\t\t\t\t\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t}","\t\t\t\t\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t\t\t}","\t\t\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t}","\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t\t\t\t\t}","\t\t\t\t\t\t\t\t\t\t\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t\t\t}","\t\t\t\t\t\t\t\t\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t\t\t}","\t\t\t\t\t\t\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t\t\t\t\t}","\t\t\t\t\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t\t\t}","\t\t\t\t#endif","/*--------------------------------------------------------------------------*/","\t\t}","/*--------------------------------------------------------------------------*/","\t\tFxaaFloat dstN = posM.x - posN.x;","\t\tFxaaFloat dstP = posP.x - posM.x;","\t\tif(!horzSpan) dstN = posM.y - posN.y;","\t\tif(!horzSpan) dstP = posP.y - posM.y;","/*--------------------------------------------------------------------------*/","\t\tFxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;","\t\tFxaaFloat spanLength = (dstP + dstN);","\t\tFxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;","\t\tFxaaFloat spanLengthRcp = 1.0/spanLength;","/*--------------------------------------------------------------------------*/","\t\tFxaaBool directionN = dstN < dstP;","\t\tFxaaFloat dst = min(dstN, dstP);","\t\tFxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;","\t\tFxaaFloat subpixG = subpixF * subpixF;","\t\tFxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;","\t\tFxaaFloat subpixH = subpixG * fxaaQualitySubpix;","/*--------------------------------------------------------------------------*/","\t\tFxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;","\t\tFxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);","\t\tif(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;","\t\tif( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;","\t\t#if (FXAA_DISCARD == 1)","\t\t\t\treturn FxaaTexTop(tex, posM);","\t\t#else","\t\t\t\treturn FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);","\t\t#endif","}","/*==========================================================================*/","#endif","","void main() {","\tgl_FragColor = FxaaPixelShader(","\t\tvUv,","\t\tvec4(0.0),","\t\ttDiffuse,","\t\ttDiffuse,","\t\ttDiffuse,","\t\tresolution,","\t\tvec4(0.0),","\t\tvec4(0.0),","\t\tvec4(0.0),","\t\t0.75,","\t\t0.166,","\t\t0.0833,","\t\t0.0,","\t\t0.0,","\t\t0.0,","\t\tvec4(0.0)","\t);","","\t// TODO avoid querying texture twice for same texel","\tgl_FragColor.a = texture2D(tDiffuse, vUv).a;","}"].join("\n")};var Kl={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\t\n\t\t\tvarying vec2 vUv;\n\t\n\t\t\tvoid main() {\n\t\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\n\t\t\t}",fragmentShader:"\n\t\n\t\t\tuniform float opacity;\n\t\n\t\t\tuniform sampler2D tDiffuse;\n\t\n\t\t\tvarying vec2 vUv;\n\t\n\t\t\tvoid main() {\n\t\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\t\t\t\tgl_FragColor.a *= opacity;\n\t\n\t\n\t\t\t}"};class $l{constructor(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}const th=new be.OrthographicCamera(-1,1,1,-1,0,1),eh=new be.BufferGeometry;eh.setAttribute("position",new be.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),eh.setAttribute("uv",new be.Float32BufferAttribute([0,2,0,0,2,0],2));class ih{constructor(t){this._mesh=new be.Mesh(eh,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,th)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class rh extends $l{constructor(t,e){super(),this.textureID=void 0!==e?e:"tDiffuse",t instanceof be.ShaderMaterial?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=be.UniformsUtils.clone(t.uniforms),this.material=new be.ShaderMaterial({defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new ih(this.material)}render(t,e,i){this.enabled&&(this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this.fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t)))}}class nh extends $l{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,i){const r=t.getContext(),n=t.state;let s,o;n.buffers.color.setMask(!1),n.buffers.depth.setMask(!1),n.buffers.color.setLocked(!0),n.buffers.depth.setLocked(!0),this.inverse?(s=0,o=1):(s=1,o=0),n.buffers.stencil.setTest(!0),n.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),n.buffers.stencil.setFunc(r.ALWAYS,s,4294967295),n.buffers.stencil.setClear(o),n.buffers.stencil.setLocked(!0),t.setRenderTarget(i),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),n.buffers.color.setLocked(!1),n.buffers.depth.setLocked(!1),n.buffers.stencil.setLocked(!1),n.buffers.stencil.setFunc(r.EQUAL,1,4294967295),n.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),n.buffers.stencil.setLocked(!0)}}class sh extends $l{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class oh{constructor(t,e){this.renderer=t,this._pixelRatio=this.renderer.getPixelRatio();const i=t.getSize(new be.Vector2);void 0===e?(this._width=i.width,this._height=i.height,(e=new be.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{minFilter:be.LinearFilter,magFilter:be.LinearFilter,format:be.RGBAFormat,type:be.FloatType,stencilBuffer:!1,encoding:be.sRGBEncoding})).texture.name="EffectComposer.rt1"):(this._width=e.width,this._height=e.height,e.texture.name="EffectComposer.rt1"),this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===Kl&&console.error("THREE.EffectComposer relies on THREE.CopyShader"),void 0===rh&&console.error("THREE.EffectComposer relies on THREE.ShaderPass"),this.copyPass=new rh(Kl),this.clock=new be.Clock}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);-1!==e&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e0){t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const e=t.autoClear;t.autoClear=!1,n&&t.state.buffers.stencil.setTest(!1),t.setClearColor(16777215,1),this.changeVisibilityOfSelectedObjects(!1);const r=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,t.setRenderTarget(this.renderTargetDepthBuffer),t.clear(),t.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,t.setRenderTarget(this.renderTargetMaskBuffer),t.clear(),t.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=r,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,t.setRenderTarget(this.renderTargetMaskDownSampleBuffer),t.clear(),this.fsQuad.render(t),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const t=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(t),this.tempPulseColor2.multiplyScalar(t)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,t.setRenderTarget(this.renderTargetEdgeBuffer1),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=hh.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,t.setRenderTarget(this.renderTargetBlurBuffer1),t.clear(),this.fsQuad.render(t),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=hh.BlurDirectionY,t.setRenderTarget(this.renderTargetEdgeBuffer1),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=hh.BlurDirectionX,t.setRenderTarget(this.renderTargetBlurBuffer2),t.clear(),this.fsQuad.render(t),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=hh.BlurDirectionY,t.setRenderTarget(this.renderTargetEdgeBuffer2),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,n&&t.state.buffers.stencil.setTest(!0),t.setRenderTarget(i),this.fsQuad.render(t),t.setClearColor(0,0),t.autoClear=e,this.renderToScreen&&(this.fsQuad.material=this.materialCopy,i.texture.encoding=t.outputEncoding,this.copyUniforms.tDiffuse.value=i.texture,t.setRenderTarget(null),this.fsQuad.render(t))}}getPrepareMaskMaterial(){return new be.ShaderMaterial({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new be.Vector2(.5,.5)},textureMatrix:{value:null}},vertexShader:"#include \n\t\t\t#include \n\n\t\t\tvarying vec4 projTexCoord;\n\t\t\tvarying vec4 vPosition;\n\t\t\tuniform mat4 textureMatrix;\n\n\t\t\tvoid main() {\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\n\t\t\t\tvPosition = mvPosition;\n\t\t\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t}",fragmentShader:"#include \n\t\t\tvarying vec4 vPosition;\n\t\t\tvarying vec4 projTexCoord;\n\t\t\tuniform sampler2D depthTexture;\n\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\tvoid main() {\n\n\t\t\t\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t}"})}getEdgeDetectionMaterial(){return new be.ShaderMaterial({uniforms:{maskTexture:{value:null},texSize:{value:new be.Vector2(.5,.5)},visibleEdgeColor:{value:new be.Vector3(1,1,1)},hiddenEdgeColor:{value:new be.Vector3(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\tuniform sampler2D maskTexture;\n\t\t\tuniform vec2 texSize;\n\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\tvoid main() {\n\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t}"})}getSeperableBlurMaterial(t){return new be.ShaderMaterial({defines:{MAX_RADIUS:t},uniforms:{colorTexture:{value:null},texSize:{value:new be.Vector2(.5,.5)},direction:{value:new be.Vector2(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"#include \n\t\t\tvarying vec2 vUv;\n\t\t\tuniform sampler2D colorTexture;\n\t\t\tuniform vec2 texSize;\n\t\t\tuniform vec2 direction;\n\t\t\tuniform float kernelRadius;\n\n\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\tfloat weightSum = gaussianPdf(0.0, kernelRadius);\n\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\tfloat w = gaussianPdf(uvOffset.x, kernelRadius);\n\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\tuvOffset += delta;\n\t\t\t\t}\n\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t}"})}getOverlayMaterial(){return new be.ShaderMaterial({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\tuniform sampler2D maskTexture;\n\t\t\tuniform sampler2D edgeTexture1;\n\t\t\tuniform sampler2D edgeTexture2;\n\t\t\tuniform sampler2D patternTexture;\n\t\t\tuniform float edgeStrength;\n\t\t\tuniform float edgeGlow;\n\t\t\tuniform bool usePatternTexture;\n\n\t\t\tvoid main() {\n\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\tif(usePatternTexture)\n\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\tgl_FragColor = finalColor;\n\t\t\t}",blending:be.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0})}}hh.BlurDirectionX=new be.Vector2(1,0),hh.BlurDirectionY=new be.Vector2(0,1);var ch=function(t){null==t&&(t=Math),this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(var e=0;e<256;e++)this.p[e]=Math.floor(256*t.random());this.perm=[];for(e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]};ch.prototype.dot=function(t,e,i){return t[0]*e+t[1]*i},ch.prototype.dot3=function(t,e,i,r){return t[0]*e+t[1]*i+t[2]*r},ch.prototype.dot4=function(t,e,i,r,n){return t[0]*e+t[1]*i+t[2]*r+t[3]*n},ch.prototype.noise=function(t,e){var i,r,n=(t+e)*(.5*(Math.sqrt(3)-1)),s=Math.floor(t+n),o=Math.floor(e+n),a=(3-Math.sqrt(3))/6,l=(s+o)*a,h=t-(s-l),c=e-(o-l);h>c?(i=1,r=0):(i=0,r=1);var d=h-i+a,u=c-r+a,p=h-1+2*a,m=c-1+2*a,f=255&s,g=255&o,v=this.perm[f+this.perm[g]]%12,y=this.perm[f+i+this.perm[g+r]]%12,w=this.perm[f+1+this.perm[g+1]]%12,x=.5-h*h-c*c,b=.5-d*d-u*u,_=.5-p*p-m*m;return 70*((x<0?0:(x*=x)*x*this.dot(this.grad3[v],h,c))+(b<0?0:(b*=b)*b*this.dot(this.grad3[y],d,u))+(_<0?0:(_*=_)*_*this.dot(this.grad3[w],p,m)))},ch.prototype.noise3d=function(t,e,i){var r,n,s,o,a,l,h=(t+e+i)*(1/3),c=Math.floor(t+h),d=Math.floor(e+h),u=Math.floor(i+h),p=1/6,m=(c+d+u)*p,f=t-(c-m),g=e-(d-m),v=i-(u-m);f>=g?g>=v?(r=1,n=0,s=0,o=1,a=1,l=0):f>=v?(r=1,n=0,s=0,o=1,a=0,l=1):(r=0,n=0,s=1,o=1,a=0,l=1):gM?32:0)+(P>C?16:0)+(M>C?8:0)+(P>L?4:0)+(M>L?2:0)+(C>L?1:0),O=P-(n=v[R][0]>=3?1:0)+x,F=M-(s=v[R][1]>=3?1:0)+x,N=C-(o=v[R][2]>=3?1:0)+x,D=L-(a=v[R][3]>=3?1:0)+x,I=P-(l=v[R][0]>=2?1:0)+2*x,U=M-(h=v[R][1]>=2?1:0)+2*x,B=C-(c=v[R][2]>=2?1:0)+2*x,k=L-(d=v[R][3]>=2?1:0)+2*x,j=P-(u=v[R][0]>=1?1:0)+3*x,V=M-(p=v[R][1]>=1?1:0)+3*x,z=C-(m=v[R][2]>=1?1:0)+3*x,G=L-(f=v[R][3]>=1?1:0)+3*x,H=P-1+4*x,X=M-1+4*x,W=C-1+4*x,Y=L-1+4*x,Q=255&_,J=255&A,Z=255&S,q=255&T,K=y[Q+y[J+y[Z+y[q]]]]%32,$=y[Q+n+y[J+s+y[Z+o+y[q+a]]]]%32,tt=y[Q+l+y[J+h+y[Z+c+y[q+d]]]]%32,et=y[Q+u+y[J+p+y[Z+m+y[q+f]]]]%32,it=y[Q+1+y[J+1+y[Z+1+y[q+1]]]]%32,rt=.6-P*P-M*M-C*C-L*L,nt=.6-O*O-F*F-N*N-D*D,st=.6-I*I-U*U-B*B-k*k,ot=.6-j*j-V*V-z*z-G*G,at=.6-H*H-X*X-W*W-Y*Y;return 27*((rt<0?0:(rt*=rt)*rt*this.dot4(g[K],P,M,C,L))+(nt<0?0:(nt*=nt)*nt*this.dot4(g[$],O,F,N,D))+(st<0?0:(st*=st)*st*this.dot4(g[tt],I,U,B,k))+(ot<0?0:(ot*=ot)*ot*this.dot4(g[et],j,V,z,G))+(at<0?0:(at*=at)*at*this.dot4(g[it],H,X,W,Y)))};const dh={defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new be.Vector2},cameraProjectionMatrix:{value:new be.Matrix4},cameraInverseProjectionMatrix:{value:new be.Matrix4},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:"\n\n\tvarying vec2 vUv;\n\n\tvoid main() {\n\n\t\tvUv = uv;\n\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t}",fragmentShader:"\n\n\tuniform sampler2D tDiffuse;\n\tuniform sampler2D tNormal;\n\tuniform sampler2D tDepth;\n\tuniform sampler2D tNoise;\n\n\tuniform vec3 kernel[ KERNEL_SIZE ];\n\n\tuniform vec2 resolution;\n\n\tuniform float cameraNear;\n\tuniform float cameraFar;\n\tuniform mat4 cameraProjectionMatrix;\n\tuniform mat4 cameraInverseProjectionMatrix;\n\n\tuniform float kernelRadius;\n\tuniform float minDistance; // avoid artifacts caused by neighbour fragments with minimal depth difference\n\tuniform float maxDistance; // avoid the influence of fragments which are too far away\n\n\tvarying vec2 vUv;\n\n\t#include \n\n\tfloat getDepth( const in vec2 screenPosition ) {\n\n\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t}\n\n\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\n\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t#else\n\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t#endif\n\n\t}\n\n\tfloat getViewZ( const in float depth ) {\n\n\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\n\t\t#else\n\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\n\t\t#endif\n\n\t}\n\n\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\n\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\n\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\n\t\tclipPosition *= clipW; // unprojection.\n\n\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\n\t}\n\n\tvec3 getViewNormal( const in vec2 screenPosition ) {\n\n\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\n\t}\n\n\tvoid main() {\n\n\t\tfloat depth = getDepth( vUv );\n\t\tfloat viewZ = getViewZ( depth );\n\n\t\tvec3 viewPosition = getViewPosition( vUv, depth, viewZ );\n\t\tvec3 viewNormal = getViewNormal( vUv );\n\n\t\tvec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );\n\t\tvec3 random = vec3( texture2D( tNoise, vUv * noiseScale ).r );\n\n\t\t// compute matrix used to reorient a kernel vector\n\n\t\tvec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );\n\t\tvec3 bitangent = cross( viewNormal, tangent );\n\t\tmat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );\n\n\t float occlusion = 0.0;\n\n\t for ( int i = 0; i < KERNEL_SIZE; i ++ ) {\n\n\t\t\tvec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space\n\t\t\tvec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point\n\n\t\t\tvec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC\n\t\t\tsamplePointNDC /= samplePointNDC.w;\n\n\t\t\tvec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates\n\n\t\t\tfloat realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture\n\t\t\tfloat sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value\n\t\t\tfloat delta = sampleDepth - realDepth;\n\n\t\t\tif ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion\n\n\t\t\t\tocclusion += 1.0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tocclusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );\n\n\t\tgl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );\n\n\t}"},uh={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:"varying vec2 vUv;\n\n\tvoid main() {\n\n\t\tvUv = uv;\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t}",fragmentShader:"uniform sampler2D tDepth;\n\n\tuniform float cameraNear;\n\tuniform float cameraFar;\n\n\tvarying vec2 vUv;\n\n\t#include \n\n\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\n\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t#else\n\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t#endif\n\n\t}\n\n\tvoid main() {\n\n\t\tfloat depth = getLinearDepth( vUv );\n\t\tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n\t}"},ph={uniforms:{tDiffuse:{value:null},resolution:{value:new be.Vector2}},vertexShader:"varying vec2 vUv;\n\n\tvoid main() {\n\n\t\tvUv = uv;\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t}",fragmentShader:"uniform sampler2D tDiffuse;\n\n\tuniform vec2 resolution;\n\n\tvarying vec2 vUv;\n\n\tvoid main() {\n\n\t\tvec2 texelSize = ( 1.0 / resolution );\n\t\tfloat result = 0.0;\n\n\t\tfor ( int i = - 2; i <= 2; i ++ ) {\n\n\t\t\tfor ( int j = - 2; j <= 2; j ++ ) {\n\n\t\t\t\tvec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;\n\t\t\t\tresult += texture2D( tDiffuse, vUv + offset ).r;\n\n\t\t\t}\n\n\t\t}\n\n\t\tgl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );\n\n\t}"};class mh extends $l{constructor(t,e,i,r){super(),this.width=void 0!==i?i:512,this.height=void 0!==r?r:512,this.clear=!0,this.camera=e,this.scene=t,this.kernelRadius=8,this.kernelSize=32,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this._visibilityCache=new Map,this.generateSampleKernel(),this.generateRandomKernelRotations();const n=new be.DepthTexture;n.format=be.DepthStencilFormat,n.type=be.UnsignedInt248Type,this.beautyRenderTarget=new be.WebGLRenderTarget(this.width,this.height),this.normalRenderTarget=new be.WebGLRenderTarget(this.width,this.height,{minFilter:be.NearestFilter,magFilter:be.NearestFilter,depthTexture:n}),this.ssaoRenderTarget=new be.WebGLRenderTarget(this.width,this.height),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new be.ShaderMaterial({defines:Object.assign({},dh.defines),uniforms:be.UniformsUtils.clone(dh.uniforms),vertexShader:dh.vertexShader,fragmentShader:dh.fragmentShader,blending:be.NoBlending}),this.ssaoMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssaoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssaoMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.ssaoMaterial.uniforms.tNoise.value=this.noiseTexture,this.ssaoMaterial.uniforms.kernel.value=this.kernel,this.ssaoMaterial.uniforms.cameraNear.value=this.camera.near,this.ssaoMaterial.uniforms.cameraFar.value=this.camera.far,this.ssaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new be.MeshNormalMaterial,this.normalMaterial.blending=be.NoBlending,this.blurMaterial=new be.ShaderMaterial({defines:Object.assign({},ph.defines),uniforms:be.UniformsUtils.clone(ph.uniforms),vertexShader:ph.vertexShader,fragmentShader:ph.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new be.ShaderMaterial({defines:Object.assign({},uh.defines),uniforms:be.UniformsUtils.clone(uh.uniforms),vertexShader:uh.vertexShader,fragmentShader:uh.fragmentShader,blending:be.NoBlending}),this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new be.ShaderMaterial({uniforms:be.UniformsUtils.clone(Kl.uniforms),vertexShader:Kl.vertexShader,fragmentShader:Kl.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:be.DstColorFactor,blendDst:be.ZeroFactor,blendEquation:be.AddEquation,blendSrcAlpha:be.DstAlphaFactor,blendDstAlpha:be.ZeroFactor,blendEquationAlpha:be.AddEquation}),this.fsQuad=new ih(null),this.originalClearColor=new be.Color}dispose(){this.beautyRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.ssaoRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.normalMaterial.dispose(),this.blurMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}render(t,e){switch(!1===t.capabilities.isWebGL2&&(this.noiseTexture.format=be.LuminanceFormat),t.setRenderTarget(this.beautyRenderTarget),t.clear(),t.render(this.scene,this.camera),this.overrideVisibility(),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.restoreVisibility(),this.ssaoMaterial.uniforms.kernelRadius.value=this.kernelRadius,this.ssaoMaterial.uniforms.minDistance.value=this.minDistance,this.ssaoMaterial.uniforms.maxDistance.value=this.maxDistance,this.renderPass(t,this.ssaoMaterial,this.ssaoRenderTarget),this.renderPass(t,this.blurMaterial,this.blurRenderTarget),this.output){case mh.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=be.NoBlending,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case mh.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=be.NoBlending,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case mh.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=be.NoBlending,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case mh.OUTPUT.Depth:this.renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:e);break;case mh.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=be.NoBlending,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case mh.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=be.NoBlending,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=be.CustomBlending,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;default:console.warn("THREE.SSAOPass: Unknown output type.")}}renderPass(t,e,i,r,n){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(i),t.autoClear=!1,null!=r&&(t.setClearColor(r),t.setClearAlpha(n||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,i,r,n){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(i),t.autoClear=!1,r=e.clearColor||r,n=e.clearAlpha||n,null!=r&&(t.setClearColor(r),t.setClearAlpha(n||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}setSize(t,e){this.width=t,this.height=e,this.beautyRenderTarget.setSize(t,e),this.ssaoRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.blurRenderTarget.setSize(t,e),this.ssaoMaterial.uniforms.resolution.value.set(t,e),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(t,e)}generateSampleKernel(){const t=this.kernelSize,e=this.kernel;for(let i=0;i\n\t\t\tvarying vec2 vUv;\n\t\t\tuniform sampler2D colorTexture;\n\t\t\tuniform vec2 texSize;\n\t\t\tuniform vec2 direction;\n\n\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t}\n\t\t\tvoid main() {\n\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\tfloat fSigma = float(SIGMA);\n\t\t\t\tfloat alphaNum = 0.0;\n\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\n\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\n\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\n\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\n\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\n\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\talphaNum += (texture2D( colorTexture, vUv + uvOffset).a + texture2D( colorTexture, vUv - uvOffset).a) * w;\n\t\t\t\t}\n\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, alphaNum/weightSum);\n\t\t\t}"})}getCompositeMaterial(t){return new be.ShaderMaterial({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\tuniform sampler2D blurTexture1;\n\t\t\tuniform sampler2D blurTexture2;\n\t\t\tuniform sampler2D blurTexture3;\n\t\t\tuniform sampler2D blurTexture4;\n\t\t\tuniform sampler2D blurTexture5;\n\t\t\tuniform sampler2D dirtTexture;\n\t\t\tuniform float bloomStrength;\n\t\t\tuniform float bloomRadius;\n\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t}"})}}wh.BlurDirectionX=new be.Vector2(1,0),wh.BlurDirectionY=new be.Vector2(0,1);const xh={uniforms:{tDiffuse:{value:null},brightness:{value:0},contrast:{value:1},exposure:{value:0},gamma:{value:1},saturation:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","uniform float brightness;","uniform float contrast;","uniform float exposure;","uniform float gamma;","uniform float saturation;","const vec3 w = vec3(0.2125, 0.7154, 0.0721);","void main() {","vec4 tex = texture2D( tDiffuse, vUv );","vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);","color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);","color = clamp( color * pow(2.0, exposure), 0.0, 1.0);","color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);","float luminance = dot( color, w );","color = mix(vec3(luminance), color, saturation);","gl_FragColor = vec4(color, tex.a);","}"].join("\n")};const bh={uniforms:{tDiffuse:{value:null}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\t\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\t\n\t\tvoid main() {\n\n\t\t\t\t\t\tvec4 tex = texture2D( tDiffuse, vUv );\n\n\t\t\tgl_FragColor = LinearTosRGB( tex );\n\n\t\t}"};class _h extends ui{constructor(t,e,i,r){super(),this.viewer=r,this.renderer=t,this.camera=i,this.scene=e,this.enable=!1;const n=t.getSize(new be.Vector2);let s={minFilter:be.LinearFilter,magFilter:be.LinearFilter,format:be.RGBAFormat,type:be.FloatType,stencilBuffer:!0,encoding:be.sRGBEncoding};const o=new be.WebGLRenderTarget(n.width,n.height,s);o.samples=8,this.renderPass=new lh(e,i),this.renderPass.clearColor=new be.Color(0,0,0),this.renderPass.clearAlpha=0;const a=this.composer=new oh(t,o);a.addPass(this.renderPass),this.setBloomPass({enabled:!1}),this.setColorPass({enabled:!1}),this.setOutlinePass({enabled:!1}),this.setFXAAPass({enabled:!0}),this.setGammaCorrectionPass({enabled:!0}),a.readBuffer.texture.encoding=be.sRGBEncoding,a.writeBuffer.texture.encoding=be.sRGBEncoding,a.renderTarget1.texture.encoding=be.sRGBEncoding,a.renderTarget2.texture.encoding=be.sRGBEncoding}setBloomPass(t){if(!t)return;this.bloomPassOption||(this.bloomPassOption={enabled:!1,strength:.14,threshold:.1,radius:.4,selective:!1}),pt(this.bloomPassOption,t);const e=this.bloomPassOption;if(!this.bloomPass){const{width:t,height:n}=this.viewer.getSize();if(this.bloomPass=new wh(new be.Vector2(t,n),e.strength,e.radius,e.threshold),this.composer.addPass(this.bloomPass),e.selective){const t=this.bloomSelectPass=(i=this.composer,(r=new rh(new be.ShaderMaterial({uniforms:{baseTexture:{value:null},bloomTexture:{value:i.renderTarget2.texture}},vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n\t\tvUv = uv;\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n",fragmentShader:"\nuniform sampler2D baseTexture;\nuniform sampler2D bloomTexture;\nvarying vec2 vUv;\nvoid main() {\n\t\tgl_FragColor = ( texture2D( baseTexture, vUv ) + vec4( 1.0 ) * texture2D( bloomTexture, vUv ) );\n}\n",defines:{}}),"baseTexture")).needsSwap=!0,r);this.composer.addPass(t),this.composer.renderToScreen=!1}else this.bloomSelectPass&&(this.composer.removePass(this.bloomSelectPass),this.bloomSelectPass=null)}var i,r;for(const t in e)this.bloomPass[t]=e[t]}setOutlinePass(t){if(!t)return;if(this.outlinePassOption||(this.outlinePassOption={enabled:!1,edgeStrength:5,edgeGlow:1,edgeThickness:1,pulsePeriod:0,visibleEdgeColor:"#ed2a2a",hiddenEdgeColor:"#190a05"}),pt(this.outlinePassOption,t),!this.outlinePass){const{width:t,height:e}=this.viewer.getSize();this.outlinePass=new hh(new be.Vector2(t,e),this.scene,this.camera),this.composer.addPass(this.outlinePass)}const e=this.outlinePassOption;for(const t in e)t.indexOf("Color")<0?this.outlinePass[t]=e[t]:this.outlinePass[t]=ni(e[t])}setSSAOPass(t){if(t){if(this.SSAOPassOption||(this.SSAOPassOption={enabled:!1,kernelRadius:.2,kernelSize:12,minDistance:.005,maxDistance:.1}),pt(this.SSAOPassOption,t),!this.ssaoPass){this.viewer.sceneManager.getScene();const{width:t,height:e}=this.viewer.getSize();this.ssaoPass=new mh(this.scene,this.camera,t,e),this.composer.addPass(this.ssaoPass)}for(const t in this.SSAOPassOption)this.ssaoPass[t]=this.SSAOPassOption[t]}}setFXAAPass(t){if(!t)return;if(this.effectFXAAOption||(this.effectFXAAOption={enabled:!1}),pt(this.effectFXAAOption,t),!this.effectFXAA){const{width:t,height:e}=this.viewer.getSize(),i=this.renderer.getPixelRatio();this.effectFXAA=new rh(ql);const r=this.effectFXAA;r.transparent=!0,r.uniforms.resolution.value.x=1/(t*i*2),r.uniforms.resolution.value.y=1/(e*i*2),this.composer.addPass(this.effectFXAA)}const e=this.effectFXAAOption;for(const t in e)this.effectFXAA[t]=e[t]}setSSAAPass(t){if(t){this.SSAAPassOption||(this.SSAAPassOption={sampleLevel:4,unbiased:!0}),pt(this.SSAAPassOption,t||{}),this.SSAAPass||(this.SSAAPass=new gh(this.scene,this.camera),this.composer.addPass(this.SSAAPass));for(const t in this.SSAAPassOption)this.SSAAPass[t]=this.SSAAPassOption[t]}}setGammaCorrectionPass(t){if(t){if(this.gammaCorrectionPassOption||(this.gammaCorrectionPassOption={enabled:!1}),pt(this.gammaCorrectionPassOption,t||{}),!this.gammaCorrectionPass){const t=this.gammaCorrectionPass=new rh(bh);this.composer.addPass(t)}for(const t in this.gammaCorrectionPassOption)this.gammaCorrectionPass[t]=this.gammaCorrectionPassOption[t]}}setColorPass(t){if(t){this.colorPassOption||(this.colorPassOption={enabled:!1,exposure:0,brightness:0,contrast:1,saturation:1,gamma:1}),pt(this.colorPassOption,t||{}),this.colorPass||(this.colorPass=new rh(xh),this.composer.addPass(this.colorPass));for(const t in this.colorPassOption){const e=this.colorPassOption[t];"enabled"===t?this.colorPass[t]=e:void 0!==this.colorPass.uniforms[t]&&(this.colorPass.uniforms[t].value=e)}}}setSize(t,e){this.composer.setSize(t,e);const i=this.renderer.getPixelRatio();this.effectFXAA&&this.effectFXAA.material.uniforms.resolution.value.set(1/t*i,1/e*i)}render(t,e){this.enable&&(this.renderPass.scene=e,this.composer.render(t),this.bloomSelectPass)}}const Ah={enable:!1,bloom:{enable:!1,strength:.14,radius:.4,threshold:.7},SSAO:{enable:!1,kernelRadius:.2,kernelSize:12},colorCorrection:{enable:!1,exposure:0,brightness:0,contrast:1,saturation:1,gamma:.6},FXAA:{enable:!0},outline:{enable:!0,edgeStrength:2,edgeGlow:.1,edgeThickness:.5,pulsePeriod:0,visibleEdgeColor:"#FF0000",hiddenEdgeColor:"#190a05"}};class Sh extends ui{constructor(t,e){super(),this.option=pt({forceRender:!1,fps:60,devicePixelRatio:window.devicePixelRatio||1,postEffect:et(Ah)},e),zt(),this.viewer=t,this.cssRenderer=this.viewer._cssRenderer,this._cssRendererEnable=!1,this.renderer=this._createRenderer(),this.needRender=!1,this.forceRender=this.option.forceRender,this.fps=this.option.fps,this.clock=new be.Clock,this.elapsedTime=this.clock.getElapsedTime(),this.currentFrame=0,this._renderTimeFlag=0,this.renderer.getContext().canvas.addEventListener("webglcontextlost",(function(t){t.preventDefault()}),!1),this.effectRenderer=null,this._initPmremGenerator(),this.setMainRendererEnable(this.option.postEffect.enable||!1)}get cssRendererEnable(){return this._cssRendererEnable}set cssRendererEnable(t){this._cssRendererEnable=t,this.cssRenderer.domElement.style.display=t?"block":"none"}_initPmremGenerator(){const t=new be.PMREMGenerator(this.renderer);t.compileEquirectangularShader(),this.pmremGenerator=t}loadHDR(t){return new Promise(((e,i)=>{(new tl).load(mo.transformUrl(t),(t=>{const i=this.pmremGenerator.fromEquirectangular(t).texture;i.encoding=be.sRGBEncoding,e(i)}))}))}getRenderer(){return this.effectRenderer||this.renderer}_createRenderer(){const{devicePixelRatio:t}=this.option;var e=new be.WebGLRenderer({preserveDrawingBuffer:!1,antialias:!0,premultipliedAlpha:!0,logarithmicDepthBuffer:!0,alpha:!0});e.setPixelRatio(t);var i=this.viewer.getSize();return e.setSize(i.width,i.height),e.sortObjects=!1,e.shadowMap.enabled=!0,e.shadowMap.type=be.PCFSoftShadowMap,e.outputEncoding=be.sRGBEncoding,e.autoClearDepth=!0,e.autoClearStencil=!0,e.setClearColor(0,0),e.autoClear=!1,e.physicallyCorrectLights=!0,e}_collectRenderStates(){if(!this.debugger.enable)return;var t=this.renderer.info.memory,e=this.renderer.info.render;const i=this.scene.getVerticesCount();this.debugger.renderStates=this.renderStates={geometries:t.geometries,textures:t.textures,frame:e.frame,calls:e.calls,triangles:e.triangles,points:e.points,lines:e.lines,vertices:i}}get fps(){return this._renderFPS}set fps(t){this._renderFPS=t||60,this._renderTime=1/this._renderFPS,this._renderTimeFlag=0}setMainRendererEnable(t){if(!this.effectRenderer){const t=this.viewer.sm.getScene(),e=this.viewer;this.effectRenderer=new _h(this.renderer,t,e.camera,e),this.effectRenderer.renderer.logarithmicDepthBuffer=!0,this.setPostEffect({...this.option.postEffect||{},enable:!0})}this.effectRenderer.enable=t}canUsePostEffect(){return this.effectRenderer&&this.effectRenderer.enable}render(){const{camera:t,cameraControl:e,sceneManager:i}=this.viewer;if(!i||!t)return;const r=i.getScene();if(!r)return;const n=this.deltaTime=this.clock.getDelta();if(this._renderTimeFlag+=n,this.needRender||this._renderTimeFlag>this._renderTime&&this.forceRender){const s=this.renderer,o=i.sceneHelpers;e.tick(n),r.update(n),Xt(),this.canUsePostEffect()?("OrthographicCamera"==t.type?this.effectRenderer.composer.renderer.render(r,t):this.effectRenderer.render(n,r),this.cssRenderer.render(r,t),s.clearDepth(),this.effectRenderer.composer.renderer.render(o,t)):(s.render(r,t),this.cssRenderer.render(r,t),s.clearDepth(),s.render(o,t)),r.csm&&r.csm.update(),this._renderTimeFlag=0,this.needRender=!1,this.dispatchEvent({type:"render",deltaTime:n,clock:this.clock})}this.viewer.debugger&&this.viewer.debugger.update()}enableRender(){this.forceRender||(this.needRender=!0)}start(){this.renderer.setAnimationLoop((()=>{this.render()})),this.needRender=!0}stop(){this.renderer.setAnimationLoop(null)}setSize(t,e){this.renderer.setSize(t,e),this.cssRenderer.setSize(t,e),this.effectRenderer&&this.effectRenderer.setSize(t,e)}closePostEffect(){this.setPostEffect({enable:!1})}setPostEffect(t){if(!t)return;pt(this.option.postEffect,t||{});const e=this.option.postEffect,{bloom:i,SSAO:r,colorCorrection:n,FXAA:s,enable:o,outline:a}=et(e);if(this.effectRenderer&&(this.effectRenderer.enable=o),!this.canUsePostEffect())return;const l=this.effectRenderer;i&&(i.enabled=o&&i.enable,delete i.enable,l.setBloomPass(i)),r&&(r.enabled=o&&r.enable,delete r.enable,l.setSSAOPass(r)),n&&(n.enabled=o&&n.enable,delete n.enable,l.setColorPass(n)),s&&(s.enabled=o&&s.enable,delete s.enable,l.setFXAAPass(s)),a&&(a.enabled=o&&a.enable,delete a.enable,l.setOutlinePass(a)),this.enableRender()}destroy(){this.renderer.dispose(),this.clock.stop(),this.clock=null}addOutlineObject(t){t&&!this.outlinePass.selectedObjects.includes(t)&&this.outlinePass.selectedObjects.push(t)}removeOutlineObject(t){this.outlinePass.selectedObjects=this.outlinePass.selectedObjects.filter((e=>e!==t))}setOutlineObject(t){this.outlinePass.selectedObjects=t?[t]:[]}clearOutlineObjects(){this.outlinePass.selectedObjects=[]}get outlinePass(){return this.effectRenderer.outlinePass}get bloom(){return this.effectRenderer.enable&&this.effectRenderer.bloomPass.enabled}set bloom(t){this.effectRenderer.setBloomPass({enabled:t})}get SSAO(){return this.effectRenderer.enable&&this.effectRenderer.ssaoPass.enabled}set SSAO(t){this.effectRenderer.setSSAOPass({enabled:t})}get outline(){return this.effectRenderer.enable&&this.effectRenderer.outlinePass.enabled}set outline(t){return this.effectRenderer.setOutlinePass({enabled:t})}get FXAA(){return this.effectRenderer.enable&&this.effectRenderer.effectFXAA.enabled}set FXAA(t){this.effectRenderer.setFXAAPass({enabled:t})}}class Th extends ui{constructor(t){super(),this.viewer=t,this.renderer=t.rendererManager.renderer,this._singleClickTimer=null,ht(["_createCommonEvent","_commonEventHandle"],this),this.commonEventTypes=[ne,oe,ae,le,se],this.commonEventTypes.forEach((t=>{this[`__${t}Event`]=this._createCommonEvent(t),this[`_${t}Event`]=ut(this[`__${t}Event`],0,this),this[`_${t}Object`]=null})),this._resizeEvent=ut(t.resize,300,t),this.hotkeysScope="default",this.addEventListener("scopeUpdate",(t=>{this.hotkeysScope=t.scope})),this.init()}init(){this.clear();const t=this.viewer,e=this.viewer.container;window.addEventListener(he,this._resizeEvent,!1),this.commonEventTypes.forEach((t=>{const i=this[`_${t}Event`];let r=t;t===ae&&(r="mousemove"),t===re&&(r="click"),e.addEventListener(r,i,!1)}));const i=t.cameraControl;i.control.addEventListener("control",(t=>{i.dispatchEvent({type:t.eventType,target:t.target}),i.dispatchEvent({type:"change",target:t.target}),"truck"==t.eventType&&i.dispatchEvent({target:t.target,type:"dragging"})})),i.control.addEventListener("controlstart",(t=>{i.dispatchEvent({type:t.eventType,target:t.target}),i.dispatchEvent({type:"changestart",target:t.target}),"truckstart"==t.eventType&&i.dispatchEvent({target:t.target,type:"dragstart"})})),i.control.addEventListener("controlend",(t=>{i.dispatchEvent({type:t.eventType,target:t.target}),i.dispatchEvent({type:"changeend",target:t.target}),"truckend"==t.eventType&&i.dispatchEvent({target:t.target,type:"dragend"})})),t.on("ready",(()=>{t.rendererManager.enableRender()}))}getEventStates(){const{selector:t,cameraControl:e,picker:i}=this.viewer;return{selector:{enabled:t.enabled},cameraControl:{enabled:e.enabled,firstPersonMode:e.firstPersonMode,keypress:e.keypress},picker:{enabled:i.enabled}}}setEventStates(t){if(!t||tt(t))return;const e=pt(this.getEventStates(),et(t||{}));for(const t in e){const i=e[t];for(const e in i)this.viewer[t][e]=i[e]}}trigger(t,e){this.commonEventTypes.includes(t)&&this[`_${t}Event`](e)}_commonEventHandle(t,e){if(!t||!e)return;let i=this[`_${t}Object`],{picked:r,raycasterPicked:n,raycasterSceneHelpersPicked:s}=this.viewer.picker.pick(e),o=r[0]||n[0]?.object||null,a=s[0]?.object||null;i===o&&(i=null);let l=this.viewer.coordScreenToWorldWithPick(e.clientX,e.clientY,0);this.viewer.dispatchEvent({type:t,originalEvent:e,object:o,previousObject:i,position:l,raycaster:n[0],sceneHelpersRaycaster:s[0],sceneHelpersObject:a}),o&&o.dispatchEvent({type:t,originalEvent:e,raycaster:n[0]}),this[`_${t}Object`]=o,this.viewer.rendererManager.enableRender()}_createCommonEvent(t){return e=>{if(this.viewer.hasEvent(t))if(t!==ae&&e.stopPropagation(),t===le&&clearTimeout(this._singleClickTimer),t===ne){clearTimeout(this._singleClickTimer);const i=this.viewer.hasEvent(le);this._singleClickTimer=setTimeout((()=>{this._commonEventHandle(t,e)}),i?250:0)}else this._commonEventHandle(t,e)}}clear(){window.removeEventListener(he,this._resizeEvent);const t=this.viewer.container;this.commonEventTypes.forEach((e=>{const i=this[`_${e}Event`];let r=e;e===ae&&(r="mousemove"),t.removeEventListener(r,i,!1)}))}}class Eh extends be.EventDispatcher{constructor(t){super(),this.viewer=t,this.offsetX=100,this.offsetY=100,this.waitTime=50,this.oldTime=0;const{width:e,height:i}=t.getSize();this.size={width:e,height:i},this.selected=[],this.renderTarget=new be.WebGLRenderTarget(e,i),this.depthMaterial=new be.ShaderMaterial({vertexShader:"\nprecision highp float;\n\nuniform float far;\n\nvarying float depth;\n\nvoid main() {\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n\t\tdepth = gl_Position.z / far;\n}\n",fragmentShader:"\nprecision highp float;\n\nvarying float depth;\n\nvoid main() {\n\n\t\tfloat hex = abs(depth) * 16777215.0; \n\n\t\tfloat r = floor(hex / 65535.0);\n\t\tfloat g = floor((hex - r * 65535.0) / 255.0);\n\t\tfloat b = floor(hex - r * 65535.0 - g * 255.0);\n\t\tfloat a = sign(depth) >= 0.0 ? 1.0 : 0.0; \n\n\t\tgl_FragColor = vec4(r / 255.0, g / 255.0, b / 255.0, a);\n}\n",uniforms:{far:{value:t.camera.far}}}),this.pickedObject=null}pick(t,e){return this.enabled=!0,this.offsetX=t,this.offsetY=e,this.update(),this.enabled=!1,this.selected}update(){if(!this.enabled)return;let t=(new Date).getTime();if(t-this.oldTime{t instanceof be.Mesh&&t.material&&h.push(t)}));for(let t=0;t{const e=t.object?t.object:t,{node:r,level:n}=i(e);return null!=r.selectLevel&&(r.selectLevel<0||r.selectLevel>=n)?e:r})).filter((t=>(!t.parent||t.parent.visible)&&!1!==t.visible&&"helper"!=t._thing_tag&&!0!==t.userData.isLocked&&!t.isGroup&&"GridHelper"!=t.type&&!t.isScene));let r=!1,n=[];for(let e=0;et.uuid==e.uuid)).filter((t=>!1!==t.visible)),this.filter&&Z(this.filter)&&(t=t.filter(this.filter)),e&&Z(e)&&(t=t.filter(e)),t}getIntersects(t,e){const i={picked:[],raycasterPicked:[]};if(!t||!J(t.clientX)||!J(t.clientY))return i;const{camera:r,scene:n,container:s,sceneHelpers:o,renderer:a}=this.viewer,{x:l,y:h,offsetX:c,offsetY:d}=z(s,t)||{};if(void 0===l||void 0===h)return i;const u=this.raycaster,p=new be.Vector3;p.set(l,h,.5),u.setFromCamera(p,r);const{mode:m,picker:f}=this;(new be.Layers).set(pe.IGNORE_RAYCAST);let g=[],v=[];if("gpu"===m);else{var y=[];n.traverseVisible((function(t){t.isGroup||y.push(t)})),g=u.intersectObjects(y,!1);var w=[];o.traverseVisible((function(t){"picker"===t.name&&w.push(t)})),v=u.intersectObjects(w,!1)}return{picked:this._filterIntersects(g,e),raycasterPicked:g,raycasterSceneHelpersPicked:v}}pick(t,e,i){if(!this._enabled)return{picked:[],raycasterPicked:[]};const r=tt(t)||void 0===t.clientX?{clientX:t,clientY:e}:t;return this.getIntersects(r,i)}}var Lh="undefined"!=typeof window&&void 0!==window.document?window.document:{},Rh=function(){for(var t,e=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],i=0,r=e.length,n={};i=200&&e.status<=299}function Bh(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(i){var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}const kh=Dh.saveAs||("object"!=typeof window||window!==Dh?function(){}:"download"in HTMLAnchorElement.prototype?function(t,e,i){var r=Dh.URL||Dh.webkitURL,n=document.createElement("a");e=e||t.name||"download",n.download=e,n.rel="noopener","string"==typeof t?(n.href=t,n.origin!==location.origin?Uh(n.href)?Ih(t,e,i):Bh(n,n.target="_blank"):Bh(n)):(n.href=r.createObjectURL(t),setTimeout((function(){r.revokeObjectURL(n.href)}),4e4),setTimeout((function(){Bh(n)}),0))}:"msSaveOrOpenBlob"in navigator?function(t,e,i){if(e=e||t.name||"download","string"==typeof t)if(Uh(t))Ih(t,e,i);else{var r=document.createElement("a");r.href=t,r.target="_blank",setTimeout((function(){Bh(r)}))}else navigator.msSaveOrOpenBlob(function(t,e){return void 0===e?e={autoBom:!1}:"object"!=typeof e&&(console.warn("Deprecated: Expected third argument to be a object"),e={autoBom:!e}),e.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob([String.fromCharCode(65279),t],{type:t.type}):t}(t,i),e)}:function(t,e,i,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof t)return Ih(t,e,i);var n="application/octet-stream"===t.type,s=/constructor/i.test(Dh.HTMLElement)||Dh.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||n&&s)&&"object"==typeof FileReader){var a=new FileReader;a.onloadend=function(){var t=a.result;t=o?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=t:location=t,r=null},a.readAsDataURL(t)}else{var l=Dh.URL||Dh.webkitURL,h=l.createObjectURL(t);r?r.location=h:location.href=h,r=null,setTimeout((function(){l.revokeObjectURL(h)}),4e4)}});class jh{constructor(t){this.id=-1,this.inMemory=!1,this.updatable=!1,this.type="",this.name="",this.editor=t}toJSON(){const t={};return t.type=this.type,t.id=this.id,t.name=this.name,t}fromJSON(t){this.inMemory=!0,this.type=t.type,this.id=t.id,this.name=t.name}}const Vh=be.ObjectLoader;class zh extends jh{constructor(t,e){super(t),this.type="AddObjectCommand",this.object=e,void 0!==e&&(this.name=`Add Object: ${e.name}`)}execute(){this.editor.addObject(this.object),this.object.isGroup||this.editor.select(this.object)}undo(){this.editor.removeObject(this.object),this.editor.deselect()}toJSON(){const t=super.toJSON(this);return t.object=this.object.toJSON(),t}fromJSON(t){if(super.fromJSON(t),this.object=this.editor.objectByUuid(t.object.object.uuid),void 0===this.object){const e=new Vh;this.object=e.parse(t.object)}}}class Gh extends jh{constructor(t,e,i,r){super(t),this.type="MoveObjectCommand",this.name="Move Object",this.object=e,this.oldParent=void 0!==e?e.parent:void 0,this.oldIndex=void 0!==this.oldParent?this.oldParent.children.indexOf(this.object):void 0,this.newParent=i,this.newIndex=void 0!==r?void 0!==i?i.children.indexOf(r):void 0:void 0!==i?i.children.length:void 0,this.oldParent===this.newParent&&this.newIndex>this.oldIndex&&this.newIndex--,this.newBefore=r}execute(){this.oldParent.remove(this.object);this.newParent.children.splice(this.newIndex,0,this.object),this.object.parent=this.newParent,this.object.dispatchEvent({type:"added"}),this.editor.signals.sceneGraphChanged.dispatch()}undo(){this.newParent.remove(this.object);this.oldParent.children.splice(this.oldIndex,0,this.object),this.object.parent=this.oldParent,this.object.dispatchEvent({type:"added"}),this.editor.signals.sceneGraphChanged.dispatch()}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.newParentUuid=this.newParent.uuid,t.oldParentUuid=this.oldParent.uuid,t.newIndex=this.newIndex,t.oldIndex=this.oldIndex,t}fromJSON(t){super.fromJSON(t),this.object=this.editor.objectByUuid(t.objectUuid),this.oldParent=this.editor.objectByUuid(t.oldParentUuid),void 0===this.oldParent&&(this.oldParent=this.editor.scene),this.newParent=this.editor.objectByUuid(t.newParentUuid),void 0===this.newParent&&(this.newParent=this.editor.scene),this.newIndex=t.newIndex,this.oldIndex=t.oldIndex}}class Hh extends Mo{constructor(t){super(pt({points:[],material:{}},t)),this.type="LineMesh",this.isLineMesh=!0,this.needPoints=!0,this.type="Line",this.vertices=[],this.updateVertices(this.option.points);const e=this.createGeometry(this.vertices);this.line=new be.Line(e,new be.LineBasicMaterial),this.add(this.line),this.updateBy(this.option)}get length(){if(this.vertices.length<2)return 0;let t=0,e=ti(this.vertices[0]);return this.vertices.slice(1).forEach((i=>{t+=e.distanceTo(ti(i)),e=i})),t}getPoints(){return this.vertices.map((t=>t.toArray()))}updatePoints(t){this.updateVertices(t)}updateVertices(t){if(t&&0!==t.length){this.vertices=[];for(let e=0;e=this.vertices.length)&&(this.vertices[t]=ti(e),this.line.geometry.verticesNeedUpdate=!0,this.updateGeometry(),!0)}removePoint(t){t>=this.vertices.length||(this.vertices.splice(t,1),this.updateGeometry())}clear(){this.vertices=[],this.updateGeometry()}}const Xh=new be.Box3,Wh=new be.Vector3;class Yh extends be.InstancedBufferGeometry{constructor(){super(),this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new be.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new be.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new be.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceStart",new be.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceEnd",new be.InterleavedBufferAttribute(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const i=new be.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceColorStart",new be.InterleavedBufferAttribute(i,3,0)),this.setAttribute("instanceColorEnd",new be.InterleavedBufferAttribute(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new be.WireframeGeometry(t.geometry)),this}fromLineSegments(t){const e=t.geometry;if(!e.isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new be.Box3);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),Xh.setFromBufferAttribute(e),this.boundingBox.union(Xh))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new be.Sphere),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let r=0;for(let n=0,s=t.count;n\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// extend the line bounds to encompass\tendcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segements overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include \n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t"};class Qh extends be.ShaderMaterial{constructor(t){super({type:"LineMaterial",uniforms:be.UniformsUtils.clone(be.ShaderLib.line.uniforms),vertexShader:be.ShaderLib.line.vertexShader,fragmentShader:be.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set(t){Boolean(t)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("USE_ALPHA_TO_COVERAGE"in this.defines)},set:function(t){Boolean(t)!==Boolean("USE_ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===t?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}Qh.prototype.isLineMaterial=!0;const Jh=new be.Vector3,Zh=new be.Vector3,qh=new be.Vector4,Kh=new be.Vector4,$h=new be.Vector4,tc=new be.Vector3,ec=new be.Matrix4,ic=new be.Line3,rc=new be.Vector3,nc=new be.Box3,sc=new be.Sphere,oc=new be.Vector4;function ac(t,e,i,r){return oc.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),oc.multiplyScalar(1/oc.w),oc.x=i/r.width,oc.y=i/r.height,oc.applyMatrix4(t.projectionMatrixInverse),oc.multiplyScalar(1/oc.w),Math.abs(Math.max(oc.x,oc.y))}class lc extends be.Mesh{constructor(t=new Yh,e=new Qh({color:16777215*Math.random()})){super(t,e),this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,r=new Float32Array(2*e.count);for(let t=0,n=0,s=e.count;tp&&Kh.z>p)continue;if(qh.z>p){const t=qh.z-Kh.z,e=(qh.z-p)/t;qh.lerp(Kh,e)}else if(Kh.z>p){const t=Kh.z-qh.z,e=(Kh.z-p)/t;Kh.lerp(qh,e)}qh.applyMatrix4(s),Kh.applyMatrix4(s),qh.multiplyScalar(1/qh.w),Kh.multiplyScalar(1/Kh.w),qh.x*=h.x/2,qh.y*=h.y/2,Kh.x*=h.x/2,Kh.y*=h.y/2,ic.start.copy(qh),ic.start.z=0,ic.end.copy(Kh),ic.end.z=0;const i=ic.closestPointToPointParameter(tc,!0);ic.at(i,rc);const n=be.MathUtils.lerp(qh.z,Kh.z,i),a=n>=-1&&n<=1,l=tc.distanceTo(rc)<.5*c;if(a&&l){ic.start.fromBufferAttribute(d,t),ic.end.fromBufferAttribute(u,t),ic.start.applyMatrix4(o),ic.end.applyMatrix4(o);const i=new be.Vector3,n=new be.Vector3;r.distanceSqToSegment(ic.start,ic.end,n,i),e.push({point:n,pointOnLine:i,distance:r.origin.distanceTo(n),object:this,face:null,faceIndex:t,uv:null,uv2:null})}}}}}lc.prototype.isLineSegments2=!0;class hc extends Yh{constructor(){super(),this.type="LineGeometry"}setPositions(t){for(var e=t.length-3,i=new Float32Array(2*e),r=0;r{if(t.scene){const e=t.scene.viewer.getSize();this.mesh.material.resolution.set(e.width,e.height)}}))}get length(){if(this.vertices.length<2)return 0;let t=0,e=ti(this.vertices[0]);return this.vertices.slice(1).forEach((i=>{t+=e.distanceTo(ti(i)),e=i})),t}getPoints(){return this.vertices.map((t=>t.toArray()))}updatePoints(t){if(t&&0!==t.length){this.vertices=[];for(let e=0;e=this.vertices.length)&&(this.vertices[t]=ti(e),this._updateGeometry(),!0)}removePoint(t){t>=this.vertices.length||(this.vertices.splice(t,1),this._updateGeometry())}clear(){this.vertices=[],this._updateGeometry()}}cc.prototype.isLine2=!0;var dc=function(){this.pos=new be.Vector3,this.dir=new be.Vector3,this.right=new be.Vector3,this.up=new be.Vector3,this.dist=0,this.widthScale=1};dc.prototype.lerpPathPoints=function(t,e,i){this.pos.lerpVectors(t.pos,e.pos,i),this.dir.lerpVectors(t.dir,e.dir,i),this.up.lerpVectors(t.up,e.up,i),this.right.lerpVectors(t.right,e.right,i),this.dist=(e.dist-t.dist)*i+t.dist,this.widthScale=(e.widthScale-t.widthScale)*i+t.widthScale},dc.prototype.copy=function(t){this.pos.copy(t.pos),this.dir.copy(t.dir),this.up.copy(t.up),this.right.copy(t.right),this.dist=t.dist,this.widthScale=t.widthScale};const uc=new be.Vector3,pc=new be.Vector3,mc=new be.Vector3,fc=new be.Matrix4,gc=new be.QuadraticBezierCurve3;class vc{constructor(){this.array=[],this.count=0}set(t,e=.1,i=10,r=null,n=!1){if((t=t.slice(0)).length<2)this.count=0;else{n&&!t[0].equals(t[t.length-1])&&t.push((new be.Vector3).copy(t[0]));for(let s=0,o=t.length;s0?this.array[this.count-1].dist:0}_getByIndex(t){return this.array[t]||(this.array[t]=new dc),this.array[t]}_start(t,e,i){this.count=0;const r=this._getByIndex(this.count);if(r.pos.copy(t),r.dir.subVectors(e,t),i)r.up.copy(i);else{let t=Number.MAX_VALUE;const e=Math.abs(r.dir.x),i=Math.abs(r.dir.y),n=Math.abs(r.dir.z);eNumber.EPSILON){n.normalize();const t=Math.acos(Math.min(Math.max(e.dir.dot(i.dir),-1),1));i.up.applyMatrix4(fc.makeRotationAxis(n,t))}i.right.crossVectors(i.dir,i.up).normalize(),i.dist=e.dist+r,i.widthScale=1,i.sharp=!1,this.count++}_corner(t,e,i,r,n){if(i>0&&r>0){const s=function(t,e,i,r,n,s){const o=uc.subVectors(e,t),a=pc.subVectors(i,e),l=o.length(),h=a.length();o.normalize(),a.normalize();const c=Math.min(.999999*(n?l/2:l),r);s.v0.copy(e).sub(o.multiplyScalar(c)),s.v1.copy(e);const d=Math.min(h/2*.999999,r);return s.v2.copy(e).add(a.multiplyScalar(d)),s}(this.array[this.count-1].pos,t,e,i,this.count-1==0,gc),o=s.getPoints(r);for(let t=0;tNumber.EPSILON){t.normalize();const e=Math.acos(Math.min(Math.max(s.dir.dot(o.dir),-1),1));o.up.applyMatrix4(fc.makeRotationAxis(t,e))}o.right.crossVectors(o.dir,o.up).normalize()}o.dist=s.dist+h;const c=a.dot(l);o.widthScale=Math.min(1/Math.sqrt((1+c)/2),1.415)||1,o.sharp=Math.abs(c-1)>.05&&n,this.count++}}var yc=function(){this._drawing=!1,this._includeDrawingPoint=!1,this._points=[],this._lastPoint=new be.Vector3,this._lastFixedPoint=new be.Vector3,this.fixRadius=.5,this.height=.1,this._cornerRadius=.2,this._cornerSplit=10,this._pathPointList=new vc,this._dirty=!0,this.up=new be.Vector3(0,1,0)};Object.defineProperty(yc.prototype,"cornerRadius",{set:function(t){this._cornerRadius=t,this._dirty=!0},get:function(){return this._cornerRadius}}),Object.defineProperty(yc.prototype,"cornerSplit",{set:function(t){this._cornerSplit=t,this._dirty=!0},get:function(){return this._cornerSplit}}),yc.prototype.getPoints=function(){if(this._includeDrawingPoint&&(this._points.pop(),this._includeDrawingPoint=!1),this._drawing&&this._points.length>0){var t=this._getLastFixedPoint();t&&(this._points.push(t),this._includeDrawingPoint=!0)}return this._points},yc.prototype.getPathPointList=function(){return(this._drawing||this._dirty)&&(this._pathPointList.set(this.getPoints(),this._cornerRadius,this._cornerSplit,this.up),this._dirty=!1),this._pathPointList},yc.prototype.update=function(t){this._lastPoint.copy(t),this._lastPoint.y+=this.height},yc.prototype.confirm=function(){this._drawing=!0;var t=this._getLastFixedPoint();t&&(this._includeDrawingPoint&&(this._points.pop(),this._includeDrawingPoint=!1),this._points.push(t.clone())),this._dirty=!0},yc.prototype.start=function(){this._drawing=!0,this._dirty=!0},yc.prototype.stop=function(){this._drawing=!1,this._dirty=!0},yc.prototype.clear=function(){this._drawing=!1,this._includeDrawingPoint=!1,this._points=[],this._dirty=!0};var wc=new be.Vector3;var xc=new be.Vector3,bc=new be.Vector3;yc.prototype._getLastFixedPoint=function(){if(this._lastFixedPoint.copy(this._lastPoint),this._points.length>0){var t=this._includeDrawingPoint?this._points[this._points.length-2]:this._points[this._points.length-1];if(function(t,e){return wc.copy(e).sub(t).length()}(t,this._lastFixedPoint)2:this._points.length>1){var e=this._includeDrawingPoint?this._points[this._points.length-3]:this._points[this._points.length-2];if(xc.subVectors(t,e),bc.subVectors(this._lastFixedPoint,t),xc.normalize(),bc.normalize(),xc.multiplyScalar(-1).dot(bc)>.99)return null}}return this._lastFixedPoint};class _c extends be.BufferGeometry{constructor(t=3e3,e=!1){super(),isNaN(t)?this._initByData(t.pathPointList,t.options,t.usage,e):this._initByMaxVertex(t,e)}_initByMaxVertex(t,e){this.setAttribute("position",new be.BufferAttribute(new Float32Array(3*t),3).setUsage(be.DynamicDrawUsage)),this.setAttribute("normal",new be.BufferAttribute(new Float32Array(3*t),3).setUsage(be.DynamicDrawUsage)),this.setAttribute("uv",new be.BufferAttribute(new Float32Array(2*t),2).setUsage(be.DynamicDrawUsage)),e&&this.setAttribute("uv2",new be.BufferAttribute(new Float32Array(2*t),2).setUsage(be.DynamicDrawUsage)),this.drawRange.start=0,this.drawRange.count=0,this.setIndex(t>65536?new be.Uint32BufferAttribute(3*t,1):new be.Uint16BufferAttribute(3*t,1))}_initByData(t,e={},i,r){const n=Ac(t,e,r);n&&0!==n.count?(this.setAttribute("position",new be.BufferAttribute(new Float32Array(n.position),3).setUsage(i||be.StaticDrawUsage)),this.setAttribute("normal",new be.BufferAttribute(new Float32Array(n.normal),3).setUsage(i||be.StaticDrawUsage)),this.setAttribute("uv",new be.BufferAttribute(new Float32Array(n.uv),2).setUsage(i||be.StaticDrawUsage)),r&&this.setAttribute("uv2",new be.BufferAttribute(new Float32Array(n.uv2),2).setUsage(i||be.StaticDrawUsage)),this.setIndex(n.position.length/3>65536?new be.Uint32BufferAttribute(n.indices,1):new be.Uint16BufferAttribute(n.indices,1))):this._initByMaxVertex(2,r)}update(t,e={}){const i=!!this.getAttribute("uv2"),r=Ac(t,e,i);r?(this._updateAttributes(r.position,r.normal,r.uv,i?r.uv2:null,r.indices),this.drawRange.count=r.count):this.drawRange.count=0}_resizeAttribute(t,e){let i=this.getAttribute(t);for(;i.array.length65535?new Uint32Array(2*t):new Uint16Array(2*t),1);i.name=e.name,i.usage=e.usage,this.setIndex(i),e=i}}_updateAttributes(t,e,i,r,n){this._resizeAttribute("position",t.length);const s=this.getAttribute("position");s.array.set(t,0),s.updateRange.count=t.length,s.needsUpdate=!0,this._resizeAttribute("normal",e.length);const o=this.getAttribute("normal");o.array.set(e,0),o.updateRange.count=e.length,o.needsUpdate=!0,this._resizeAttribute("uv",i.length);const a=this.getAttribute("uv");if(a.array.set(i,0),a.updateRange.count=i.length,a.needsUpdate=!0,r){this._resizeAttribute("uv2",r.length);const t=this.getAttribute("uv2");t.array.set(r,0),t.updateRange.count=r.length,t.needsUpdate=!0}this._resizeIndex(n.length);const l=this.getIndex();l.set(n,0),l.updateRange.count=n.length,l.needsUpdate=!0}}function Ac(t,e,i=!1){const r=e.width||.1,n=void 0!==e.progress?e.progress:1,s=void 0===e.arrow||e.arrow,o=void 0!==e.side?e.side:"both",a=r/2,l="both"!==o?r/2:r,h=t.distance(),c=n*h;if(0==h)return null;const d=a/l,u=a/h;let p=0;const m=[],f=[],g=[],v=[],y=[];let w=0;const x=new be.Vector3,b=new be.Vector3,_=new be.Vector3,A=new be.Vector3,S=new be.Vector3,T=new be.Vector3;function E(t){const e=0===m.length,r=t.sharp&&!e,n=t.dist/l,s=t.dist/h,c=t.dir,E=t.up,P=t.right;if("left"!==o?x.copy(P).multiplyScalar(a*t.widthScale):x.set(0,0,0),"right"!==o?b.copy(P).multiplyScalar(-a*t.widthScale):b.set(0,0,0),x.add(t.pos),b.add(t.pos),r){_.fromArray(m,m.length-6).sub(b),A.fromArray(m,m.length-3).sub(x);const t=_.length()-A.length();let e,r;t>0?(e=_,r=b):(e=A,r=x),S.copy(e).setLength(Math.abs(t)).add(r);let o=T.copy(r).sub(S).normalize().dot(c)*T.copy(r).sub(S).length()*2;T.copy(c).setLength(o).add(S),t>0?(m.push(S.x,S.y,S.z,x.x,x.y,x.z,b.x,b.y,b.z,x.x,x.y,x.z,T.x,T.y,T.z,x.x,x.y,x.z),w+=6,y.push(w-6,w-8,w-7,w-6,w-7,w-5,w-4,w-6,w-5,w-2,w-4,w-1),p+=12):(m.push(b.x,b.y,b.z,S.x,S.y,S.z,b.x,b.y,b.z,x.x,x.y,x.z,b.x,b.y,b.z,T.x,T.y,T.z),w+=6,y.push(w-6,w-8,w-7,w-6,w-7,w-5,w-6,w-5,w-3,w-2,w-3,w-1),p+=12),f.push(E.x,E.y,E.z,E.x,E.y,E.z,E.x,E.y,E.z,E.x,E.y,E.z,E.x,E.y,E.z,E.x,E.y,E.z),g.push(n-d,0,n-d,1,n,0,n,1,n+d,0,n+d,1),i&&v.push(s-u,0,s-u,1,s,0,s,1,s+u,0,s+u,1)}else m.push(b.x,b.y,b.z,x.x,x.y,x.z),f.push(E.x,E.y,E.z,E.x,E.y,E.z),g.push(n,0,n,1),i&&v.push(s,0,s,1),w+=2,e||(y.push(w-2,w-4,w-3,w-2,w-3,w-1),p+=6)}const P=new be.Vector3;let M;if(c>0)for(let e=0;ec){const r=t.array[e-1];M=new dc;const n=(c-r.dist)/(i.dist-r.dist);M.lerpPathPoints(r,i,n),E(M);break}E(i)}else M=t.array[0];return s&&(M=M||t.array[t.count-1],function(t){const e=t.dir,n=t.up,s=t.right,c=t.dist/l,d=t.dist/h;"left"!==o?x.copy(s).multiplyScalar(2*a):x.set(0,0,0),"right"!==o?b.copy(s).multiplyScalar(2*-a):b.set(0,0,0),P.copy(e).setLength(3*a),x.add(t.pos),b.add(t.pos),P.add(t.pos),m.push(b.x,b.y,b.z,x.x,x.y,x.z,P.x,P.y,P.z),f.push(n.x,n.y,n.z,n.x,n.y,n.z,n.x,n.y,n.z),g.push(c,"both"!==o?"right"!==o?-2:0:-.5,c,"both"!==o?"left"!==o?2:0:1.5,c+1.5,"both"!==o?0:.5),i&&v.push(d,"both"!==o?"right"!==o?-2:0:-.5,d,"both"!==o?"left"!==o?2:0:1.5,d+1.5*r/h,"both"!==o?0:.5),w+=3,y.push(w-1,w-3,w-2),p+=3}(M)),{position:m,normal:f,uv:g,uv2:v,indices:y,count:p}}class Sc extends _c{constructor(t=1e3,e=!1){super(t,e)}_initByData(t,e={},i,r){const n=Tc(t,e,r);n&&0!==n.count?(this.setAttribute("position",new be.BufferAttribute(new Float32Array(n.position),3).setUsage(i||be.StaticDrawUsage)),this.setAttribute("normal",new be.BufferAttribute(new Float32Array(n.normal),3).setUsage(i||be.StaticDrawUsage)),this.setAttribute("uv",new be.BufferAttribute(new Float32Array(n.uv),2).setUsage(i||be.StaticDrawUsage)),r&&this.setAttribute("uv2",new be.BufferAttribute(new Float32Array(n.uv2),2).setUsage(i||be.StaticDrawUsage)),this.setIndex(n.position.length/3>65536?new be.Uint32BufferAttribute(n.indices,1):new be.Uint16BufferAttribute(n.indices,1))):this._initByMaxVertex(2,r)}update(t,e={}){const i=!!this.getAttribute("uv2"),r=Tc(t,e,i);r?(this._updateAttributes(r.position,r.normal,r.uv,i?r.uv2:null,r.indices),this.drawRange.count=r.count):this.drawRange.count=0}}function Tc(t,e,i=!1){const r=e.radius||.1,n=void 0!==e.progress?e.progress:1,s=Math.max(2,e.radialSegments||8),o=e.startRad||0,a=2*r*Math.PI,l=t.distance(),h=n*l;if(0==h)return null;let c=0;const d=[],u=[],p=[],m=[],f=[];let g=0;const v=new be.Vector3;function y(t,e,r){const n=0===d.length,s=t.dist/a,h=t.dist/l;for(let n=0;n<=r;n++){let a=n;a==r&&(a=0),v.copy(t.up).applyAxisAngle(t.dir,o+2*Math.PI*a/r).normalize(),d.push(t.pos.x+v.x*e*t.widthScale,t.pos.y+v.y*e*t.widthScale,t.pos.z+v.z*e*t.widthScale),u.push(v.x,v.y,v.z),p.push(s,n/r),i&&m.push(h,n/r),g++}if(!n){const t=g-2*(r+1),e=g-(r+1);for(let i=0;i0)for(let e=0;eh){const n=t.array[e-1],o=new dc,a=(h-n.dist)/(i.dist-n.dist);o.lerpPathPoints(n,i,a),y(o,r,s);break}y(i,r,s)}return{position:d,normal:u,uv:p,uv2:m,indices:f,count:c}}class Ec{constructor(t,e){if(this.data=t||[],this.length=this.data.length,this.compare=e||Pc,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const n=t-1>>1,s=e[n];if(i(r,s)>=0)break;e[t]=s,t=n}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t=0)break;e[t]=s,t=r}e[t]=n}}function Pc(t,e){return te?1:0}function Mc(t,e,i){var r,n,s,o;e=e||1;for(var a=0;as)&&(s=l[0]),(!a||l[1]>o)&&(o=l[1])}var h=s-r,c=o-n,d=Math.min(h,c),u=d/2,p=new Ec(null,Cc);if(0===d)return[r,n];for(var m=r;mg.d&&(g=v);for(var y=p.length;p.length;){var w=p.pop();w.d>g.d&&(g=w,i&&console.log("found best %d after %d probes",Math.round(1e4*w.d)/1e4,y)),w.max-g.d<=e||(u=w.h/2,p.push(new Lc(w.x-u,w.y-u,u,t)),p.push(new Lc(w.x+u,w.y-u,u,t)),p.push(new Lc(w.x-u,w.y+u,u,t)),p.push(new Lc(w.x+u,w.y+u,u,t)),y+=4)}return i&&(console.log("num probes: "+y),console.log("best distance: "+g.d)),[g.x,g.y]}function Cc(t,e){return e.max-t.max}function Lc(t,e,i,r){this.x=t,this.y=e,this.h=i,this.d=function(t,e,i){for(var r=!1,n=1/0,s=0;se!=d[1]>e&&t<(d[0]-c[0])*(e-c[1])/(d[1]-c[1])+c[0]&&(r=!r),n=Math.min(n,Rc(t,e,c,d))}return(r?1:-1)*Math.sqrt(n)}(t,e,r),this.max=this.d+this.h*Math.SQRT2}function Rc(t,e,i,r){var n=i[0],s=i[1],o=r[0]-n,a=r[1]-s;if(0!==o||0!==a){var l=((t-n)*o+(e-s)*a)/(o*o+a*a);l>1?(n=r[0],s=r[1]):l>0&&(n+=o*l,s+=a*l)}return(o=t-n)*o+(a=e-s)*a}class Oc extends Mo{constructor(t){super(pt({points:[],geometry:{width:.1},material:{}},t)),this.isPointsBase=!0,this._points=[],this._pointNodes=[],this._activePlane="",this.internalUserData={},this._editPointNode=new be.Group,this.add(this._editPointNode)}_updateByPoints(){}_createPolygonVertices(t){for(var e=[],i=0;i=this._points.length)return!1;if(!e)return!1;const i=ti(e);return this._points[t]=i,this._updateByPoints(),!0}getPoint(t){return t>=this._points.length?null:this._points[t].toArray()}addPoint(t){if(!t)return-1;const e=ti(t);return this._points.push(e),this._updateByPoints(),this._points.length-1}addPoints(t){if(t&&W(t)){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:1;this._points.splice(t,e),this._updateByPoints()}_createPathNode(t){if(!this.internalUserData.editable)return null;const{width:e,depth:i,height:r}=this.option.geometry;var n=new be.MeshStandardMaterial,s=new be.BoxGeometry(e,i,r),o=new be.Mesh(s,n);return o.updateBy({material:this.option.material}),o.userData={pos:t,subNode:!0,isNode:!0,id:this.id,activePlane:this._activePlane},o.position.copy(t),this._editPointNode.add(o),o}createPathNode(t){var e=this._createPathNode(t);return e?(this._pointNodes.push(e),e):null}insertPathNode(t,e){var i=this._createPathNode(e);return i?(this._pointNodes.splice(t,0,i),i):null}removePathNode(t,e,i){for(var r=Math.min(this._pointNodes.length-t,e),n=t+r,s=t;s=r||h>=r&&di&&(n=!n)}}return!!n}destroy(){this.removePathNode(0,this._pointNodes.length),Node.prototype.destroy.call(this)}update(t){this.synPathNodes()}isRunning(){return!!this.internalUserData.editable}getPoints(){return this._points.map((t=>t.toArray()))}toJSON(t){const e=super.toJSON();return e.config.points=this.getPoints(),e.config.src=this.option.src,e.config.type=this.option.type,e}}function Fc(t){let e,i,r,n=0;for(let s=0;s[])))}const u=Math.log10(1/e),p=Math.pow(10,u);for(let e=0;e0&&this.addPoints(t),Nc.toTrianglesDrawMode(this.pathGeometry,be.TriangleStripDrawMode),!this.line){var e=new be.Mesh(this.pathGeometry,new be.MeshStandardMaterial);e.updateBy({material:this.option.material}),this.line=e,this.add(e)}this.updateGeometry()}_updateByPoints(){this.updateGeometry()}updateGeometry(t){pt(this.option.geometry,t);const e=this.option.geometry;if(this.pathPointList.set(this._points,e.cornerRadius,e.cornerSplit,this.pathUp),this.line&&this.line.geometry){this.line.geometry.dispose();var i=new _c;Nc.toTrianglesDrawMode(i,be.TriangleStripDrawMode),i.update(this.pathPointList,{width:e.width,arrow:e.arrow,side:e.side}),i.computeBoundingSphere(),this.line.geometry=i}}updatePath(){if(!this.isPlaying)return;const{pathGeometry:t,pathPointList:e}=this,{scrollUv:i,scrollSpeed:r,width:n,arrow:s,side:o}=this.option.geometry;var a=e.distance();let l=!1;a>0?(this.playingProgress+=this.playingSpeed/a,this.playingProgress>=1&&(this.playingProgress=1,l=!0)):l=!0,t.update(e,{width:n,arrow:s,side:o,progress:this.playingProgress}),l&&(this.playingCompleteCallback&&this.playingCompleteCallback(this),this.isPlaying=!1)}update(){this.updatePath()}isRunning(){return this.isPlaying}play(t,e){this.playingSpeed=t||this.playingSpeed,this.playingProgress=0,this.isPlaying=!0,this.playingCompleteCallback=e}stop(){this.playingSpeed=1,this.playingProgress=1,this.isPlaying=!1,this.playingCompleteCallback=null}get points(){return this._points.map((t=>t.toArray()))}set points(t){this.updatePoints(t)}}class Ic extends Dc{constructor(t){super(pt({points:[],geometry:{width:.1,cornerRadius:.1,cornerSplit:10,arrow:!1},material:{worldUnits:!0}},t)),this.isRouteLine=!0,this.type="RouteLine",this.needPoints=!0,this.pathGeometry=new _c,this.createLine()}get length(){if(this._points.length<2)return 0;let t=0,e=ti(this._points[0]);return this._points.slice(1).forEach((i=>{t+=e.distanceTo(ti(i)),e=i})),t}updatePoints(t){this._points=t.map((t=>ti(t))),this._updateByPoints()}createGeometry(t){const e=this.option.geometry;this.pathPointList.set(t,e.cornerRadius,e.cornerSplit,this.pathUp);var i=new _c;return Nc.toTrianglesDrawMode(i,be.TriangleStripDrawMode),i.update(this.pathPointList,{width:e.width,arrow:e.arrow,side:e.side}),i.computeBoundingSphere(),i}}class Uc extends Dc{constructor(t){super(pt({points:[],geometry:{radius:.5,radialSegments:20,startRad:0,cornerRadius:.5}},t)),this.isTubeLine=!0,this.type="TubeLine",this.needPoints=!0,this.pathGeometry=new Sc,this.createLine()}get length(){if(this._points.length<2)return 0;let t=0,e=ti(this._points[0]);return this._points.slice(1).forEach((i=>{t+=e.distanceTo(ti(i)),e=i})),t}createGeometry(t){const e=this.option.geometry;this.pathPointList.set(t,e.cornerRadius,e.cornerSplit,this.pathUp);var i=new Sc;return Nc.toTrianglesDrawMode(i,be.TriangleStripDrawMode),i.update(this.pathPointList,{radius:e.radius,radialSegments:e.radialSegments,startRad:e.startRad}),i.computeBoundingSphere(),i}updatePoints(t){if(t&&0!==t.length){this._points=[];for(let e=0;e{t+=e.distanceTo(ti(i)),e=i})),t}createGeometry(){if(!this._points)return new be.BufferGeometry;const t=this.option.geometry,e=new be.CatmullRomCurve3(this._points,t.closed,t.curveType,t.tension);return new be.TubeGeometry(e,t.tubularSegments,t.radius,t.radialSegments,t.closed)}updatePoints(t){if(t&&0!==t.length){this._points=[];for(let e=0;et.toArray()))}set points(t){this.updatePoints(t)}}var jc=Object.freeze({__proto__:null,Line:Hh,Line2:cc,RouteLine:Ic,TubeLine:Uc,CurveLine:Bc,TubeLine2:kc});class Vc extends be.Mesh{constructor(t,e={}){super(t);const i=this,r=void 0!==e.textureWidth?e.textureWidth:512,n=void 0!==e.textureHeight?e.textureHeight:512,s=void 0!==e.clipBias?e.clipBias:0,o=void 0!==e.alpha?e.alpha:1,a=void 0!==e.time?e.time:0,l=void 0!==e.waterNormals?e.waterNormals:null,h=void 0!==e.sunDirection?e.sunDirection:new be.Vector3(.70707,.70707,0),c=new be.Color(void 0!==e.sunColor?e.sunColor:16777215),d=new be.Color(void 0!==e.waterColor?e.waterColor:8355711),u=void 0!==e.eye?e.eye:new be.Vector3(0,0,0),p=void 0!==e.distortionScale?e.distortionScale:20,m=void 0!==e.side?e.side:be.FrontSide,f=void 0!==e.fog&&e.fog,g=void 0!==e.speed?e.speed:1,v=new be.Plane,y=new be.Vector3,w=new be.Vector3,x=new be.Vector3,b=new be.Matrix4,_=new be.Vector3(0,0,-1),A=new be.Vector4,S=new be.Vector3,T=new be.Vector3,E=new be.Vector4,P=new be.Matrix4,M=new be.PerspectiveCamera,C=new be.WebGLRenderTarget(r,n),L={uniforms:be.UniformsUtils.merge([be.UniformsLib.fog,be.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new be.Matrix4},sunColor:{value:new be.Color(8355711)},sunDirection:{value:new be.Vector3(.70707,.70707,0)},eye:{value:new be.Vector3},waterColor:{value:new be.Color(5592405)},speed:{value:0}}]),vertexShader:"\n\t\t\t\tuniform mat4 textureMatrix;\n\t\t\t\tuniform float time;\n\n\t\t\t\tvarying vec4 mirrorCoord;\n\t\t\t\tvarying vec4 worldPosition;\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\t\t\t\t\tmirrorCoord = modelMatrix * vec4( position, 1.0 );\n\t\t\t\t\tworldPosition = mirrorCoord.xyzw;\n\t\t\t\t\tmirrorCoord = textureMatrix * mirrorCoord;\n\t\t\t\t\tvec4 mvPosition =\tmodelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tgl_Position = projectionMatrix * mvPosition;\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t}",fragmentShader:"\n\t\t\t\tuniform sampler2D mirrorSampler;\n\t\t\t\tuniform float alpha;\n\t\t\t\tuniform float time;\n\t\t\t\tuniform float size;\n\t\t\t\tuniform float distortionScale;\n\t\t\t\tuniform sampler2D normalSampler;\n\t\t\t\tuniform vec3 sunColor;\n\t\t\t\tuniform vec3 sunDirection;\n\t\t\t\tuniform vec3 eye;\n\t\t\t\tuniform vec3 waterColor;\n\n\t\t\t\tvarying vec4 mirrorCoord;\n\t\t\t\tvarying vec4 worldPosition;\n\n\t\t\t\tvec4 getNoise( vec2 uv ) {\n\t\t\t\t\tvec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);\n\t\t\t\t\tvec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );\n\t\t\t\t\tvec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );\n\t\t\t\t\tvec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );\n\t\t\t\t\tvec4 noise = texture2D( normalSampler, uv0 ) +\n\t\t\t\t\t\ttexture2D( normalSampler, uv1 ) +\n\t\t\t\t\t\ttexture2D( normalSampler, uv2 ) +\n\t\t\t\t\t\ttexture2D( normalSampler, uv3 );\n\t\t\t\t\treturn noise * 0.5 - 1.0;\n\t\t\t\t}\n\n\t\t\t\tvoid sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {\n\t\t\t\t\tvec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );\n\t\t\t\t\tfloat direction = max( 0.0, dot( eyeDirection, reflection ) );\n\t\t\t\t\tspecularColor += pow( direction, shiny ) * sunColor * spec;\n\t\t\t\t\tdiffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;\n\t\t\t\t}\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include \n\t\t\t\t\tvec4 noise = getNoise( worldPosition.xz * size );\n\t\t\t\t\tvec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );\n\n\t\t\t\t\tvec3 diffuseLight = vec3(0.0);\n\t\t\t\t\tvec3 specularLight = vec3(0.0);\n\n\t\t\t\t\tvec3 worldToEye = eye-worldPosition.xyz;\n\t\t\t\t\tvec3 eyeDirection = normalize( worldToEye );\n\t\t\t\t\tsunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );\n\n\t\t\t\t\tfloat distance = length(worldToEye);\n\n\t\t\t\t\tvec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;\n\t\t\t\t\tvec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );\n\n\t\t\t\t\tfloat theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );\n\t\t\t\t\tfloat rf0 = 0.3;\n\t\t\t\t\tfloat reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );\n\t\t\t\t\tvec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;\n\t\t\t\t\tvec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);\n\t\t\t\t\tvec3 outgoingLight = albedo;\n\t\t\t\t\tgl_FragColor = vec4( outgoingLight, alpha );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t}"},R=new be.ShaderMaterial({fragmentShader:L.fragmentShader,vertexShader:L.vertexShader,uniforms:be.UniformsUtils.clone(L.uniforms),lights:!0,side:m,fog:f});R.uniforms.mirrorSampler.value=C.texture,R.uniforms.textureMatrix.value=P,R.uniforms.alpha.value=o,R.uniforms.time.value=a,R.uniforms.normalSampler.value=l,R.uniforms.sunColor.value=c,R.uniforms.waterColor.value=d,R.uniforms.sunDirection.value=h,R.uniforms.distortionScale.value=p,R.uniforms.eye.value=u,R.uniforms.speed.value=g,i.material=R,i.onBeforeRender=function(t,e,r){let n=R.uniforms.speed.value;if(n>0&&(R.uniforms.time.value+=n/600),w.setFromMatrixPosition(i.matrixWorld),x.setFromMatrixPosition(r.matrixWorld),b.extractRotation(i.matrixWorld),y.set(0,0,1),y.applyMatrix4(b),S.subVectors(w,x),S.dot(y)>0)return;S.reflect(y).negate(),S.add(w),b.extractRotation(r.matrixWorld),_.set(0,0,-1),_.applyMatrix4(b),_.add(x),T.subVectors(w,_),T.reflect(y).negate(),T.add(w),M.position.copy(S),M.up.set(0,1,0),M.up.applyMatrix4(b),M.up.reflect(y),M.lookAt(T),M.far=r.far,M.updateMatrixWorld(),M.projectionMatrix.copy(r.projectionMatrix),P.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),P.multiply(M.projectionMatrix),P.multiply(M.matrixWorldInverse),v.setFromNormalAndCoplanarPoint(y,w),v.applyMatrix4(M.matrixWorldInverse),A.set(v.normal.x,v.normal.y,v.normal.z,v.constant);const o=M.projectionMatrix;E.x=(Math.sign(A.x)+o.elements[8])/o.elements[0],E.y=(Math.sign(A.y)+o.elements[9])/o.elements[5],E.z=-1,E.w=(1+o.elements[10])/o.elements[14],A.multiplyScalar(2/A.dot(E)),o.elements[2]=A.x,o.elements[6]=A.y,o.elements[10]=A.z+1-s,o.elements[14]=A.w,u.setFromMatrixPosition(r.matrixWorld);const a=t.getRenderTarget(),l=t.xr.enabled,h=t.shadowMap.autoUpdate;i.visible=!1,t.xr.enabled=!1,t.shadowMap.autoUpdate=!1,t.setRenderTarget(C),t.state.buffers.depth.setMask(!0),!1===t.autoClear&&t.clear(),t.render(e,M),i.visible=!0,t.xr.enabled=l,t.shadowMap.autoUpdate=h,t.setRenderTarget(a);const c=r.viewport;void 0!==c&&t.state.viewport(c)}}}Vc.prototype.isWater=!0;class zc extends Mo{constructor(t){super(pt({points:[],material:{side:2,uniforms:{textureWidth:512,textureHeight:512,waterNormals:"",time:0,clipBias:.8,alpha:.9,sunColor:16777215,waterColor:"#003399",distortionScale:1,fog:!0,speed:0}},geometryType:"Plane",geometry:{width:10,height:10}},t)),this.type="Water",this.isWater=!0,this.isSync=!0,this.mesh=null;const{geometryType:e,geometry:i,material:r,points:n}=this.option;"Polygon"==e?this.setPoints(n):this._setPlane(i)}setPoints(t){if(!t||!t.length)return;const e=this.points=t.map((t=>ti(t)));var i=new be.Shape(e.map((t=>new be.Vector2(t.x,t.z)))),r=new be.ShapeGeometry(i);this.setGeometry(r)}updateMaterial(t){pt(this.option.material,t);const e=this.option.material.uniforms;if(this.mesh){if(!t)return;const i=this.mesh.material.uniforms;for(const t in e){const r=e[t];if(void 0!==i[t])switch(t){case"waterNormals":r===e.waterNormals||i.normalSample.value||(i.normalSample.value=new be.TextureLoader(mo.loadingManager).load(mo.transformUrl(r),(t=>{t.wrapS=t.wrapT=be.RepeatWrapping})));break;case"waterColor":case"sunColor":i[t].value=new be.Color(r);break;case"eye":case"sunDirection":i[t].value=ti(r);break;default:i[t].value=r}}}else{if(!this._geometry||!e.waterNormals)return;const{waterNormals:t}=e;this.mesh=new Vc(this._geometry,{side:this.option.material.side,...e,waterNormals:(new be.TextureLoader).load(mo.transformUrl(t),(t=>{t.wrapS=t.wrapT=be.RepeatWrapping,this.dispatchEvent({type:"loaded"})}))}),this.mesh.rotation.x=-Math.PI/2,this.add(this.mesh)}}get material(){return this.mesh?this.mesh.material:null}set material(t){this.mesh&&(this.mesh.material=t)}updateGeometry(t){pt(this.option.geometry,t);const{geometryType:e}=this.option;"Plane"===e&&(this._setPlane(t),this.updateMaterial(this.option.material)),"Points"===e&&Array.isArray(t)&&this.setPoints(t)}updatePoints(t){const{geometryType:e}=this.option;"Polygon"===e&&Array.isArray(t)&&this.setPoints(t)}_setPlane(t){pt(this.option.geometry,t);const{geometryType:e,geometry:i}=this.option;this.plane=Mf(e,this.name+"_water",{geometry:i}),this.setGeometry(this.plane)}setGeometry(t){if(!t)return;let e=t;t.isThing&&(e=t.getGeometry()),e&&(this._geometry=e,this.updateMaterial(),this.mesh&&(this.mesh.geometry=e))}getPoints(){return this.points?this.points.map((t=>t.toArray())):[]}}class Gc extends Oc{constructor(t){super(pt({points:[],polygon:{material:{color:"#708090",opacity:.5,side:2}},line:{material:{color:de,dashed:!1,dashScale:1,dashSize:1,dashOffset:1,gapSize:1,opacity:1,linewidth:1,worldUnits:!1}}},t)),this.type="Polygon",this.isPolygon=!0,this.needPoints=!0,this.vertices=[],this._points=[],this.line=new cc({points:[],material:this.option.line.material}),this.add(this.line),this.setPoints(this.option.points),this.updateLine(),this.updatePolygon()}updatePolygon(t){this.mesh&&(pt(this.option.polygon,t),this.mesh.updateBy(this.option.polygon))}updateLine(t){this.line&&(pt(this.option.line,t),this.line.updateBy(this.option.line))}updatePoints(t){this.setPoints(t)}addPoint(t){if(!t)return-1;const e=ti(t);return this.position.y=e.y,e.y=0,this._points.push(e),this._updateByPoints(),this._points.length-1}addPoints(t){if(t&&W(t)){for(var e=0;et.y=i));const r=new be.ShapeGeometry(new be.Shape(e));return r.uvsNeedUpdate=!0,r}_updateByPoints(){if(this._points.length>0&&this.line.updatePoints(this._points.concat(this._points[0])),this._points.length<3)return;const t=this._createGeometry();if(this.mesh)this.mesh.geometry=t;else{const e=this.mesh=new be.Mesh(t,new be.MeshStandardMaterial);e.updateBy({material:this.option.polygon.material}),this.line.updateBy({material:this.option.line.material}),this.add(e),this.mesh.rotation.x=Math.PI/2}}clear(){this._points=[],this.vertices=[],this._updateByPoints()}get points(){return this._points.map((t=>t.toArray()))}set points(t){this.updatePoints(t)}get length(){if(this._points.length<2)return 0;let t=0,e=ti(this._points[0]);return this._points.slice(1).forEach((i=>{t+=e.distanceTo(ti(i)),e=i})),t}}Mt(Gc,[{key:"area",get:function(){var t=be.ShapeUtils.area(this.points_2d);return Math.abs(t)}},{key:"centeriod",get:function(){for(var t=[],e=[],i=0;i80*i){r=s=t[0],n=o=t[1];for(var m=i;ms&&(s=a),l>o&&(o=l);h=0!==(h=Math.max(s-r,o-n))?1/h:0}return Yc(u,p,i,r,n,h),p}function Xc(t,e,i,r,n){var s,o;if(n===fd(t,e,i,r)>0)for(s=e;s=e;s-=r)o=ud(s,t[s],t[s+1],o);return o&&od(o,o.next)&&(pd(o),o=o.next),o}function Wc(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!od(r,r.next)&&0!==sd(r.prev,r,r.next))r=r.next;else{if(pd(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function Yc(t,e,i,r,n,s,o){if(t){!o&&s&&function(t,e,i,r){var n=t;do{null===n.z&&(n.z=ed(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,r,n,s,o,a,l,h=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,r=i,a=0,e=0;e0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=r}s.nextZ=null,h*=2}while(o>1)}(n)}(t,r,n,s);for(var a,l,h=t;t.prev!==t.next;)if(a=t.prev,l=t.next,s?Jc(t,r,n,s):Qc(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),pd(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?Yc(t=Zc(Wc(t),e,i),e,i,r,n,s,2):2===o&&qc(t,e,i,r,n,s):Yc(Wc(t),e,i,r,n,s,1);break}}}function Qc(t){var e=t.prev,i=t,r=t.next;if(sd(e,i,r)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(rd(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&sd(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Jc(t,e,i,r){var n=t.prev,s=t,o=t.next;if(sd(n,s,o)>=0)return!1;for(var a=n.xs.x?n.x>o.x?n.x:o.x:s.x>o.x?s.x:o.x,c=n.y>s.y?n.y>o.y?n.y:o.y:s.y>o.y?s.y:o.y,d=ed(a,l,e,i,r),u=ed(h,c,e,i,r),p=t.prevZ,m=t.nextZ;p&&p.z>=d&&m&&m.z<=u;){if(p!==t.prev&&p!==t.next&&rd(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&sd(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,m!==t.prev&&m!==t.next&&rd(n.x,n.y,s.x,s.y,o.x,o.y,m.x,m.y)&&sd(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;p&&p.z>=d;){if(p!==t.prev&&p!==t.next&&rd(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&sd(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=u;){if(m!==t.prev&&m!==t.next&&rd(n.x,n.y,s.x,s.y,o.x,o.y,m.x,m.y)&&sd(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Zc(t,e,i){var r=t;do{var n=r.prev,s=r.next.next;!od(n,s)&&ad(n,r,r.next,s)&&cd(n,s)&&cd(s,n)&&(e.push(n.i/i),e.push(r.i/i),e.push(s.i/i),pd(r),pd(r.next),r=t=s),r=r.next}while(r!==t);return Wc(r)}function qc(t,e,i,r,n,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&nd(o,a)){var l=dd(o,a);return o=Wc(o,o.next),l=Wc(l,l.next),Yc(o,e,i,r,n,s),void Yc(l,e,i,r,n,s)}a=a.next}o=o.next}while(o!==t)}function Kc(t,e){return t.x-e.x}function $c(t,e){var i=function(t,e){var i,r=e,n=t.x,s=t.y,o=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>o){if(o=a,a===n){if(s===r.y)return r;if(s===r.next.y)return r.next}i=r.x=r.x&&r.x>=c&&n!==r.x&&rd(si.x||r.x===i.x&&td(i,r)))&&(i=r,u=l)),r=r.next}while(r!==h);return i}(t,e);if(!i)return e;var r=dd(i,t),n=Wc(i,i.next);return Wc(r,r.next),e===i?n:e}function td(t,e){return sd(t.prev,t,e.prev)<0&&sd(e.next,t,t.next)<0}function ed(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function id(t){var e=t,i=t;do{(e.x=0&&(t-o)*(r-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(n-o)*(r-a)>=0}function nd(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&ad(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(cd(t,e)&&cd(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&n<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(sd(t.prev,t,e.prev)||sd(t,e.prev,e))||od(t,e)&&sd(t.prev,t,t.next)>0&&sd(e.prev,e,e.next)>0)}function sd(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function od(t,e){return t.x===e.x&&t.y===e.y}function ad(t,e,i,r){var n=hd(sd(t,e,i)),s=hd(sd(t,e,r)),o=hd(sd(i,r,t)),a=hd(sd(i,r,e));return n!==s&&o!==a||(!(0!==n||!ld(t,i,e))||(!(0!==s||!ld(t,r,e))||(!(0!==o||!ld(i,t,r))||!(0!==a||!ld(i,e,r)))))}function ld(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function hd(t){return t>0?1:t<0?-1:0}function cd(t,e){return sd(t.prev,t,t.next)<0?sd(t,e,t.next)>=0&&sd(t,t.prev,e)>=0:sd(t,e,t.prev)<0||sd(t,t.next,e)<0}function dd(t,e){var i=new md(t.i,t.x,t.y),r=new md(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function ud(t,e,i,r){var n=new md(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function pd(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function md(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function fd(t,e,i,r){for(var n=0,s=e,o=i-r;s0&&(r+=t[n-1].length,i.holes.push(r))}return i};var gd=Hc;function vd(t,e,i){var r=e[0],n=e[1],s=i[0]-r,o=i[1]-n;if(0!==s||0!==o){var a=((t[0]-r)*s+(t[1]-n)*o)/(s*s+o*o);a>1?(r=i[0],n=i[1]):a>0&&(r+=s*a,n+=o*a)}return(s=t[0]-r)*s+(o=t[1]-n)*o}function yd(t,e,i,r,n){for(var s,o=r,a=e+1;ao&&(s=a,o=l)}o>r&&(s-e>1&&yd(t,e,s,r,n),n.push(t[s]),i-s>1&&yd(t,s,i,r,n))}function wd(t,e){var i=t.length-1,r=[t[0]];return yd(t,0,i,e,r),r.push(t[i]),r}function xd(t,e,i){if(t.length<=2)return t;var r=void 0!==e?e*e:1;return t=i?t:function(t,e){for(var i,r,n,s,o,a=t[0],l=[a],h=1,c=t.length;he&&(l.push(i),a=i);return a!==i&&l.push(i),l}(t,r),t=wd(t,r)}function bd(t,e){return t[0]*e[0]+t[1]*e[1]}function _d(t,e){var i=e[0],r=e[1],n=Math.sqrt(i*i+r*r);return t[0]=i/n,t[1]=r/n,t}function Ad(t,e,i,r){return t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r,t}function Sd(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t}function Td(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function Ed(t,e){var i=e[0],r=e[1],n=e[2],s=Math.sqrt(i*i+r*r+n*n);return t[0]=i/s,t[1]=r/s,t[2]=n/s,t}function Pd(t,e,i){var r=e[0],n=e[1],s=e[2],o=i[0],a=i[1],l=i[2];return t[0]=n*l-s*a,t[1]=s*o-r*l,t[2]=r*a-n*o,t}var Md=[];function Cd(t,e,i,r){var n=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}(e,i),s=Math.acos(n)*r;return Ad(Md,i,e,-n),function(t,e){var i=e[0],r=e[1],n=e[2],s=Math.sqrt(i*i+r*r+n*n);t[0]=i/s,t[1]=r/s,t[2]=n/s}(Md,Md),function(t,e,i){t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i}(t,e,Math.cos(s)),Ad(t,t,Md,Math.sin(s)),t}function Ld(t,e,i,r,n,s,o,a,l,h){var c=o-n,d=a-s,u=(c*(e-s)-d*(t-n))/(d*(i-t)-c*(r-e));return l&&(l[h=h||0]=t+u*(i-t),l[h+1]=e+u*(r-e)),u}function Rd(t,e,i){if(i-e<3)return 0;for(var r=0,n=2*(i-1),s=2*e;s<2*i;){var o=t[n],a=t[n+1],l=t[s],h=t[s+1];n=s,s+=2,r+=o*h-l*a}return r}function Od(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;return gd(t,e,i)}var Fd=[],Nd=[],Dd=[];function Id(t,e,i,r,n,s,o,a,l){var h,c,d,u=null!=o,p=n,m=null;u&&(m=new Uint32Array(r-i));for(var f=[],g=i;go&&s*C<0){var O=b+Dd[0]*s,F=_+Dd[1]*s,N=Math.acos(L)/2,D=Math.tan(N)*Math.abs(s);e[2*p]=O+Dd[1]*D,e[2*p+1]=F-Dd[0]*D,e[2*++p]=O-Dd[1]*D,e[2*p+1]=F+Dd[0]*D,p++}else E=b+Dd[0]*R,P=_+Dd[1]*R,T=!0;if(T){if(l&&null!=h){var I=Ld(w,x,h,c,b,_,E,P,f,0);I>=-.01&&I<=1.01&&(e[2*d]=E=f[0],e[2*d+1]=P=f[1])}h=e[2*p]=E,c=e[2*p+1]=P,d=p,p++}}else Dd[0]=Fd[1],Dd[1]=-Fd[0],_d(Dd,Dd),E=b+Dd[0]*s,P=_+Dd[1]*s,T=!0;else Dd[0]=Nd[1],Dd[1]=-Nd[0],_d(Dd,Dd),h=e[2*p]=b+Dd[0]*s,c=e[2*p+1]=_+Dd[1]*s,d=p,p++}return m}function Ud(t,e,i,r,n){var s=null!=r?[]:new Float32Array(t.length);if(Id(t,s,0,e&&e.length?e[0]:t.length/2,0,i,r,n,!0),e)for(var o=0;o0&&Bd(t,2,r,n);for(var s=1;s<(e?e.length:0)+1;s++)Rd(t,r=e[s-1],n=e[s]||i)<0&&Bd(t,2,r,n)}var jd=[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]];function Vd(t,e,i,r,n,s){var o=e.vertices,a=e.topVertices,l=e.splittedMap,h=e.depth,c=e.rect,d=r-i,u=s.smoothBevel?1:2,p=Math.min(h/2,s.bevelSize),m=s.bevelSegments,f=n.vertex,g=Math.max(c.width,c.height,h),v=l?function(t){var e=(t+1)%d;return l[t+i]===l[e+i]}:function(t){return!1};if(p>0)for(var y=[0,0,1],w=[],x=[0,0,-1],b=[],_=0,A=new Float32Array(d),S=0;S<2;S++)for(var T=0===S?h-p:p,E=0;E<=m*u;E++){for(var P=0,M=void 0,C=void 0,L=0;L0&&(P+=Math.sqrt((M-k)*(M-k)+(C-j)*(C-j))),E>0||S>0){var z=3*(n.vertex-d),G=t.position[z],H=t.position[z+1],X=t.position[z+2];A[L]+=Math.sqrt((G-k)*(G-k)+(H-j)*(H-j)+(X-V)*(X-V))}if(t.uv[2*n.vertex]=P/g,t.uv[2*n.vertex+1]=A[L]/g,M=k,C=j,n.vertex++,!v(L)&&(u>1&&E%u||1===u&&E>=1))for(var W=0;W<6;W++){var Y=(jd[W][0]+L)%d,Q=jd[W][1]+_;t.indices[n.index++]=(Q-1)*d+Y+f}}_++}else for(var J=0;J<2;J++)for(var Z=0===J?h:0,q=0,K=void 0,$=void 0,tt=0;tt0&&(q+=Math.sqrt((K-it)*(K-it)+($-rt)*($-rt))),t.uv[st]=q/g,t.uv[st+1]=Z/g,K=it,$=rt,n.vertex++}for(var ot=p>0?m*u+1:1,at=0;atr?(s.push(g,v),c.push(f)):(s.push(g,v,g,v),c.push(f,f))}else s.push(g,v,g,v),c.push(f,f)}m0?e.bevelSegments:0;c=c||[],i+=o.length*(e.excludeBottom?1:2),r+=h.length/2*(e.excludeBottom?1:2);for(var p=2+2*u,m=0,f=0,g=0;g65535?Uint32Array:Uint16Array)(i),uv:new Float32Array(2*r)},w={vertex:0,index:0},x=0;x0&&Math.round(C)===C?y.uv[M]=1:y.uv[M]=C%1}return y.normal=function(t,e){function i(t,e,i,r){t[0]=e,t[1]=i,t[2]=r}for(var r=[],n=[],s=[],o=[],a=[],l=[],h=t.length,c=new Float32Array(e.length),d=0;de&&(s.push(n[c]),h=0),a=d,l=u}s.length>=3&&i.push(s)}return i.length>0?i:null}function Wd(t,e){for(var i=[],r=0;r=3&&i.push(n)}return i.length>0?i:null}function Yd(t,e){e=Object.assign({},e);for(var i=[1/0,1/0],r=[-1/0,-1/0],n=0;n0?t.bevelSize:0,t.depth/2)),t.bevelSize>0||(t.bevelSegments=0),t.bevelSegments=Math.round(t.bevelSegments);var e=t.boundingRect;if(t.translate=t.translate||[0,0],t.scale=t.scale||[1,1],t.fitRect){var i=null==t.fitRect.x?e.x||0:t.fitRect.x,r=null==t.fitRect.y?e.y||0:t.fitRect.y,n=t.fitRect.width,s=t.fitRect.height;null==n?null!=s?n=s/e.height*e.width:(n=e.width,s=e.height):null==s&&(s=n/e.width*e.height),t.scale=[n/e.width,s/e.height],t.translate=[(i-e.x)*t.scale[0],(r-e.y)*t.scale[1]]}}(e);for(var s=[],o=e.translate||[0,0],a=e.scale||[1,1],l=e.boundingRect,h={x:l.x*a[0]+o[0],y:l.y*a[1]+o[1],width:l.width*a[0],height:l.height*a[1]},c=Math.min(l.width,l.height)/1e5,d=0;d0&&(u=Wd(u,p)),u){for(var m=gd.flatten(u),f=m.vertices,g=m.holes,v=m.dimensions,y=0;y0?Ud(f,g,e.bevelSize,null,!0):f,x=Od(w,g,v),b=Gd(f,g,e.smoothSide,e.smoothSideThreshold);s.push({indices:x,vertices:b.vertices,rawVertices:f,topVertices:w,holes:b.holes,splittedMap:b.splittedMap,rect:h,depth:"function"==typeof e.depth?e.depth(d):e.depth})}}}return Hd(s,e)}function Qd(t,e,i){for(var r=0;ra?(i?this.setDataMax(o[r][n]):this._max=o[r][n],!1):{x:r,y:n,value:h,radius:c,min:l,max:a}},_unOrganizeData:function(){var t=[],e=this._data,i=this._radi;for(var r in e)for(var n in e[r])t.push({x:r,y:n,radius:i[r][n],value:e[r][n]});return{min:this._min,max:this._max,data:t}},_onExtremaChange:function(){this._coordinator.emit("extremachange",{min:this._min,max:this._max})},addData:function(){if(arguments[0].length>0)for(var t=arguments[0],e=t.length;e--;)this.addData.call(this,t[e]);else{var i=this._organiseData(arguments[0],!0);i&&this._coordinator.emit("renderpartial",{min:this._min,max:this._max,data:[i]})}return this},setData:function(t){var e=t.data,i=e.length;this._data=[],this._radi=[];for(var r=0;r0&&(this._drawAlpha(t),this._colorize())},renderAll:function(t){this._clear(),t.data.length>0&&(this._drawAlpha(function(t){for(var e=[],i=t.min,r=t.max,n=t.radi,s=(t=t.data,Object.keys(t)),o=s.length;o--;)for(var a=s[o],l=Object.keys(t[a]),h=l.length;h--;){var c=l[h],d=t[a][c],u=n[a][c];e.push({x:a,y:c,value:d,radius:u})}return{min:i,max:r,data:e}}(t)),this._colorize())},_updateGradient:function(e){this._palette=t(e)},updateConfig:function(t){t.gradient&&this._updateGradient(t),this._setStyles(t)},setDimensions:function(t,e){this._width=t,this._height=e,this.canvas.width=this.shadowCanvas.width=t,this.canvas.height=this.shadowCanvas.height=e},_clear:function(){this.shadowCtx.clearRect(0,0,this._width,this._height),this.ctx.clearRect(0,0,this._width,this._height)},_setStyles:function(t){this._blur=0==t.blur?0:t.blur||t.defaultBlur,t.backgroundColor&&(this.canvas.style.backgroundColor=t.backgroundColor),this._width=this.canvas.width=this.shadowCanvas.width=t.width||this._width,this._height=this.canvas.height=this.shadowCanvas.height=t.height||this._height,this._opacity=255*(t.opacity||0),this._maxOpacity=255*(t.maxOpacity||t.defaultMaxOpacity),this._minOpacity=255*(t.minOpacity||t.defaultMinOpacity),this._useGradientOpacity=!!t.useGradientOpacity},_drawAlpha:function(t){for(var i=this._min=t.min,r=this._max=t.max,n=(t=t.data||[]).length,s=1-this._blur;n--;){var o,a=t[n],l=a.x,h=a.y,c=a.radius,d=Math.min(a.value,r),u=l-c,p=h-c,m=this.shadowCtx;this._templates[c]?o=this._templates[c]:this._templates[c]=o=e(c,s);var f=(d-i)/(r-i);m.globalAlpha=f<.01?.01:f,m.drawImage(o,u,p),uthis._renderBoundaries[2]&&(this._renderBoundaries[2]=u+2*c),p+2*c>this._renderBoundaries[3]&&(this._renderBoundaries[3]=p+2*c)}},_colorize:function(){var t=this._renderBoundaries[0],e=this._renderBoundaries[1],i=this._renderBoundaries[2]-t,r=this._renderBoundaries[3]-e,n=this._width,s=this._height,o=this._opacity,a=this._maxOpacity,l=this._minOpacity,h=this._useGradientOpacity;t<0&&(t=0),e<0&&(e=0),t+i>n&&(i=n-t),e+r>s&&(r=s-e);for(var c=this.shadowCtx.getImageData(t,e,i,r),d=c.data,u=d.length,p=this._palette,m=3;m0?o:g>0},getDataURL:function(){return this.canvas.toDataURL()}},i}(),$d=(Jd=!1,"canvas2d"===Zd.defaultRenderer&&(Jd=Kd),Jd),tu=function(){for(var t={},e=arguments.length,i=0;i0)return;f.reflect(h).negate(),f.add(c),u.extractRotation(r.matrixWorld),p.set(0,0,-1),p.applyMatrix4(u),p.add(d),g.subVectors(c,p),g.reflect(h).negate(),g.add(c),w.position.copy(f),w.up.set(0,1,0),w.up.applyMatrix4(u),w.up.reflect(h),w.lookAt(g),w.far=r.far,w.updateMatrixWorld(),w.projectionMatrix.copy(r.projectionMatrix),y.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),y.multiply(w.projectionMatrix),y.multiply(w.matrixWorldInverse),y.multiply(i.matrixWorld),l.setFromNormalAndCoplanarPoint(h,c),l.applyMatrix4(w.matrixWorldInverse),m.set(l.normal.x,l.normal.y,l.normal.z,l.constant);const n=w.projectionMatrix;v.x=(Math.sign(m.x)+n.elements[8])/n.elements[0],v.y=(Math.sign(m.y)+n.elements[9])/n.elements[5],v.z=-1,v.w=(1+n.elements[10])/n.elements[14],m.multiplyScalar(2/m.dot(v)),n.elements[2]=m.x,n.elements[6]=m.y,n.elements[10]=m.z+1-o,n.elements[14]=m.w,b.texture.encoding=t.outputEncoding,i.visible=!1;const s=t.getRenderTarget(),a=t.xr.enabled,x=t.shadowMap.autoUpdate;t.xr.enabled=!1,t.shadowMap.autoUpdate=!1,t.setRenderTarget(b),t.state.buffers.depth.setMask(!0),!1===t.autoClear&&t.clear(),t.render(e,w),t.xr.enabled=a,t.shadowMap.autoUpdate=x,t.setRenderTarget(s);const _=r.viewport;void 0!==_&&t.state.viewport(_),i.visible=!0},this.getRenderTarget=function(){return b}}}ru.prototype.isReflector=!0,ru.ReflectorShader={uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null},opacity:{value:null}},vertexShader:"\n\tuniform mat4 textureMatrix;\n\tvarying vec4 vUv;\n\n\t#include \n\t#include \n\n\tvoid main() {\n\n\t\tvUv = textureMatrix * vec4( position, 1.0 );\n\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t#include \n\n\t}",fragmentShader:"\n\tuniform vec3 color;\n\tuniform float opacity;\n\tuniform sampler2D tDiffuse;\n\tvarying vec4 vUv;\n\n\t#include \n\n\tfloat blendOverlay( float base, float blend ) {\n\t\treturn( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );\n\t}\n\n\tvec3 blendOverlay( vec3 base, vec3 blend ) {\n\t\treturn vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );\n\t}\n\n\tvoid main() {\n\t\t#include \n\t\tvec4 base = texture2DProj( tDiffuse, vUv );\n\t\tgl_FragColor = vec4( blendOverlay( base.rgb, color ), opacity );\n\t}"};class nu extends Mo{constructor(t){super(pt({name:"ReflectorPlane",geometry:{width:10,height:10,widthSegments:1,heightSegments:1},material:{uniforms:{textureHeight:window.innerHeight*window.devicePixelRatio,textureWidth:window.innerWidth*window.devicePixelRatio,opacity:.3,color:"#7F7F7F"}}},t)),this.isReflectorPlane=!0,this.type="ReflectorPlane",this.updateGeometry(this.option.geometry),this.updateMaterial(this.option.material)}updateGeometry(t){return pt(this.option.geometry,t||{}),this._geometry=new Vo({geometry:this.option.geometry}).getGeometry(),this.reflector&&(this.reflector.geometry=this._geometry),this._geometry}updateMaterial(t){if(t)if(pt(this.option.material,t),this.reflector){const e=t.uniforms;if(!e)return;if(e.textureWidth||e.textureHeight){const t=this.reflector.getRenderTarget();t.setSize(e.textureWidth||t.width,e.textureHeight||t.height)}const i=this.reflector.material.uniforms;for(const t in e)"color"==t?i.color.value=ni(e[t]):void 0!==i[t]&&(i[t].value=e[t])}else{const t=this.option.material.uniforms,e=new ru(this._geometry,{...t});e.material.uniforms.opacity.value=t.opacity,this.reflector=e,this.add(e)}}get material(){return this.reflector?this.reflector.material:null}set material(t){this.reflector&&(this.reflector.material=t)}}class su extends be.Mesh{constructor(t,e={}){super(t),this.type="Refractor";const i=this,r=void 0!==e.color?new be.Color(e.color):new be.Color(8355711),n=e.textureWidth||512,s=e.textureHeight||512,o=e.clipBias||0,a=e.shader||su.RefractorShader,l=new be.PerspectiveCamera;l.matrixAutoUpdate=!1,l.userData.refractor=!0;const h=new be.Plane,c=new be.Matrix4,d=new be.WebGLRenderTarget(n,s);this.material=new be.ShaderMaterial({uniforms:be.UniformsUtils.clone(a.uniforms),vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,transparent:!0}),this.material.uniforms.color.value=r,this.material.uniforms.tDiffuse.value=d.texture,this.material.uniforms.textureMatrix.value=c;const u=function(){const t=new be.Vector3,e=new be.Vector3,r=new be.Matrix4,n=new be.Vector3,s=new be.Vector3;return function(o){return t.setFromMatrixPosition(i.matrixWorld),e.setFromMatrixPosition(o.matrixWorld),n.subVectors(t,e),r.extractRotation(i.matrixWorld),s.set(0,0,1),s.applyMatrix4(r),n.dot(s)<0}}(),p=function(){const t=new be.Vector3,e=new be.Vector3,r=new be.Quaternion,n=new be.Vector3;return function(){i.matrixWorld.decompose(e,r,n),t.set(0,0,1).applyQuaternion(r).normalize(),t.negate(),h.setFromNormalAndCoplanarPoint(t,e)}}(),m=function(){const t=new be.Plane,e=new be.Vector4,i=new be.Vector4;return function(r){l.matrixWorld.copy(r.matrixWorld),l.matrixWorldInverse.copy(l.matrixWorld).invert(),l.projectionMatrix.copy(r.projectionMatrix),l.far=r.far,t.copy(h),t.applyMatrix4(l.matrixWorldInverse),e.set(t.normal.x,t.normal.y,t.normal.z,t.constant);const n=l.projectionMatrix;i.x=(Math.sign(e.x)+n.elements[8])/n.elements[0],i.y=(Math.sign(e.y)+n.elements[9])/n.elements[5],i.z=-1,i.w=(1+n.elements[10])/n.elements[14],e.multiplyScalar(2/e.dot(i)),n.elements[2]=e.x,n.elements[6]=e.y,n.elements[10]=e.z+1-o,n.elements[14]=e.w}}();this.onBeforeRender=function(t,e,r){d.texture.encoding=t.outputEncoding,!0!==r.userData.refractor&&!0!=!u(r)&&(p(),function(t){c.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),c.multiply(t.projectionMatrix),c.multiply(t.matrixWorldInverse),c.multiply(i.matrixWorld)}(r),m(r),function(t,e,r){i.visible=!1;const n=t.getRenderTarget(),s=t.xr.enabled,o=t.shadowMap.autoUpdate;t.xr.enabled=!1,t.shadowMap.autoUpdate=!1,t.setRenderTarget(d),!1===t.autoClear&&t.clear(),t.render(e,l),t.xr.enabled=s,t.shadowMap.autoUpdate=o,t.setRenderTarget(n);const a=r.viewport;void 0!==a&&t.state.viewport(a),i.visible=!0}(t,e,r))},this.getRenderTarget=function(){return d},this.dispose=function(){d.dispose(),i.material.dispose()}}}su.prototype.isRefractor=!0,su.RefractorShader={uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:"\n\n\tuniform mat4 textureMatrix;\n\n\tvarying vec4 vUv;\n\n\tvoid main() {\n\n\t\tvUv = textureMatrix * vec4( position, 1.0 );\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t}",fragmentShader:"\n\n\tuniform vec3 color;\n\tuniform sampler2D tDiffuse;\n\n\tvarying vec4 vUv;\n\n\tfloat blendOverlay( float base, float blend ) {\n\n\t\treturn( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );\n\n\t}\n\n\tvec3 blendOverlay( vec3 base, vec3 blend ) {\n\n\t\treturn vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );\n\n\t}\n\n\tvoid main() {\n\n\t\tvec4 base = texture2DProj( tDiffuse, vUv );\n\t\tgl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );\n\n\t}"};class ou extends Vo{constructor(t){super(pt({name:"imagePlane",rotation:[-90/be.MathUtils.RAD2DEG,0,0],geometry:{width:0,height:0},material:{map:null,side:2}},t)),this.type="ImagePlane",this.isImagePlane=!0,this.isSync=!0,this.loaded=!1,this._image=null,this.option.material.map,this.mesh.material.addEventListener("resource.loaded",(t=>{this.loaded=!0;const e=t.resource.data?.image;if(e){this._image=e;const t=e.width/e.height,i=this.option.geometry;0==i.width&&0==i.height&&(i.width=1,i.height=1/t),i.width&&0==i.height&&(i.height=i.width/t),i.height&&0==i.width&&(i.width=i.height*t),this.updateGeometry(i)}this.dispatchEvent({type:"loaded"})}))}get image(){let t=this._image;return t?t.src:""}}class au extends Vo{constructor(t){super(pt({geometry:{width:1,height:1},material:{},video:{src:""}},t)),this.type="VideoPlane",this.isVideoPlane=!0,this._video=null,this.addEventListener("removed",(()=>{this.pause(),this.removeVideo()}))}removeVideo(){this.resource&&(this.video&&this.video.pause(),mo.delete(Kt.VIDEO,this.option.video.src))}updateVideo(t){this.removeVideo(),this.resource=mo.set({type:Kt.VIDEO,id:t.src,object:this,config:t}),this.option.video.src=t.src,this._video=this.resource.data,this.mesh.material.map=this.resource.data}get video(){return this.mesh.material.map?.image}play(){this.video.play()}pause(){this.video.pause()}}class lu{constructor(){this.polygons=[]}clone(){let t=new lu;return t.polygons=this.polygons.map((t=>t.clone())),t}toPolygons(){return this.polygons}union(t){let e=new fu(this.clone().polygons),i=new fu(t.clone().polygons);return e.clipTo(i),i.clipTo(e),i.invert(),i.clipTo(e),i.invert(),e.build(i.allPolygons()),lu.fromPolygons(e.allPolygons())}subtract(t){let e=new fu(this.clone().polygons),i=new fu(t.clone().polygons);return e.invert(),e.clipTo(i),i.clipTo(e),i.invert(),i.clipTo(e),i.invert(),e.build(i.allPolygons()),e.invert(),lu.fromPolygons(e.allPolygons())}intersect(t){let e=new fu(this.clone().polygons),i=new fu(t.clone().polygons);return e.invert(),i.clipTo(e),i.invert(),e.clipTo(i),i.clipTo(e),e.build(i.allPolygons()),e.invert(),lu.fromPolygons(e.allPolygons())}inverse(){let t=this.clone();return t.polygons.forEach((t=>t.flip())),t}}lu.fromPolygons=function(t){let e=new lu;return e.polygons=t,e};class hu{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}clone(){return new hu(this.x,this.y,this.z)}negate(){return this.x*=-1,this.y*=-1,this.z*=-1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}times(t){return this.x*=t,this.y*=t,this.z*=t,this}dividedBy(t){return this.x/=t,this.y/=t,this.z/=t,this}lerp(t,e){return this.add(cu.copy(t).sub(this).times(e))}unit(){return this.dividedBy(this.length())}length(){return Math.sqrt(this.x**2+this.y**2+this.z**2)}normalize(){return this.unit()}cross(t){let e=this;const i=e.x,r=e.y,n=e.z,s=t.x,o=t.y,a=t.z;return this.x=r*a-n*o,this.y=n*s-i*a,this.z=i*o-r*s,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}}let cu=new hu,du=new hu;class uu{constructor(t,e,i,r){this.pos=(new hu).copy(t),this.normal=(new hu).copy(e),i&&(this.uv=(new hu).copy(i))&&(this.uv.z=0),r&&(this.color=(new hu).copy(r))}clone(){return new uu(this.pos,this.normal,this.uv,this.color)}flip(){this.normal.negate()}interpolate(t,e){return new uu(this.pos.clone().lerp(t.pos,e),this.normal.clone().lerp(t.normal,e),this.uv&&t.uv&&this.uv.clone().lerp(t.uv,e),this.color&&t.color&&this.color.clone().lerp(t.color,e))}}class pu{constructor(t,e){this.normal=t,this.w=e}clone(){return new pu(this.normal.clone(),this.w)}flip(){this.normal.negate(),this.w=-this.w}splitPolygon(t,e,i,r,n){let s=0,o=[];for(let e=0;epu.EPSILON?1:0;s|=r,o.push(r)}switch(s){case 0:(this.normal.dot(t.plane.normal)>0?e:i).push(t);break;case 1:r.push(t);break;case 2:n.push(t);break;case 3:let s=[],a=[];for(let e=0;e=3&&r.push(new mu(s,t.shared)),a.length>=3&&n.push(new mu(a,t.shared))}}}pu.EPSILON=1e-5,pu.fromPoints=function(t,e,i){let r=cu.copy(e).sub(t).cross(du.copy(i).sub(t)).normalize();return new pu(r.clone(),r.dot(t))};class mu{constructor(t,e){this.vertices=t,this.shared=e,this.plane=pu.fromPoints(t[0].pos,t[1].pos,t[2].pos)}clone(){return new mu(this.vertices.map((t=>t.clone())),this.shared)}flip(){this.vertices.reverse().forEach((t=>t.flip())),this.plane.flip()}}class fu{constructor(t){this.plane=null,this.front=null,this.back=null,this.polygons=[],t&&this.build(t)}clone(){let t=new fu;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map((t=>t.clone())),t}invert(){for(let t=0;tnew mu(t.vertices.map((t=>new uu(t.pos,t.normal,t.uv))),t.shared))))};let gu,vu,yu=!1,wu=0,xu={},bu=()=>yu?gu&&!gu.busy?(gu.busy=!0,{then:t=>t(gu)}):{then:function(){return this}}:(yu=!0,fetch("../csg-lib.js").then((function(t){return t.text().then((function(t){t=t.slice(0,t.lastIndexOf("export"));const e=new Blob([t+"\n\t\t\t\t\t\t\t\t\t\tself.onmessage=(message)=>{\n\t\t\t\t\t\t\t\t\t\tlet task = JSON.parse(message.data)\n\t\t\t\t\t\t\t\t\t\t//console.log(\"Got task:\"+task.op+' '+task.taskId)\n\t\t\t\t\t\t\t\t\t\tpostMessage(JSON.stringify({\n\t\t\t\t\t\t\t\t\t\t\t\ttaskId:task.taskId,\n\t\t\t\t\t\t\t\t\t\t\t\tresult : CSG.fromJSON(task.a)[task.op](CSG.fromJSON(task.b))\n\t\t\t\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconsole.log('CSG worker started!')"],{type:"application/javascript"});vu=URL.createObjectURL(e)})).then((()=>(()=>{const t=new Worker(vu);return t.onmessage=function(t){let e=JSON.parse(t.data),i=xu[e.taskId];delete xu[e.taskId],i.resolve(lu.fromJSON(e.result)),gu.busy=!1},gu={worker:t,busy:!1}})()))})));lu.doAsync=(t,e,i)=>bu().then((r=>{let n={a:t,op:e,b:i,taskId:wu};return xu[wu]=n,wu++,n.result=new Promise(((t,e)=>{n.resolve=t,r.busy=!0,r.worker.postMessage(JSON.stringify(n))})),n.result})),lu.fromGeometry=function(t,e){let i=[];if(t.isGeometry){let r=t.faces,n=t.vertices,s=["a","b","c"];for(let o=0;o({top:0,array:new Float32Array(t),write:function(t){this.array[this.top++]=t.x,this.array[this.top++]=t.y,this.array[this.top++]=t.z}}),Tu=t=>({top:0,array:new Float32Array(t),write:function(t){this.array[this.top++]=t.x,this.array[this.top++]=t.y}});lu.toGeometry=function(t,e=!0){let i,r=t.polygons;if(e){let t=0;r.forEach((e=>t+=e.vertices.length-2)),i=new be.BufferGeometry;let e,n,s=Su(3*t*3),o=Su(3*t*3),a=[];if(r.forEach((i=>{let r=i.vertices,l=r.length;void 0!==i.shared&&(a[i.shared]||(a[i.shared]=[])),l&&(void 0!==r[0].color&&(n||(n=Su(3*t*3))),void 0!==r[0].uv&&(e||(e=Tu(2*t*3))));for(let t=3;t<=l;t++)void 0!==i.shared&&a[i.shared].push(s.top/3,s.top/3+1,s.top/3+2),s.write(r[0].pos),s.write(r[t-2].pos),s.write(r[t-1].pos),o.write(r[0].normal),o.write(r[t-2].normal),o.write(r[t-1].normal),e&&r[0].uv&&(e.write(r[0].uv)||e.write(r[t-2].uv)||e.write(r[t-1].uv)),n&&(n.write(r[0].color)||n.write(r[t-2].color)||n.write(r[t-1].color))})),i.setAttribute("position",new be.BufferAttribute(s.array,3)),i.setAttribute("normal",new be.BufferAttribute(o.array,3)),e&&i.setAttribute("uv",new be.BufferAttribute(e.array,2)),n&&i.setAttribute("color",new be.BufferAttribute(n.array,3)),a.length){let t=[],e=0;for(let r=0;r{t.layers.set(pe.IGNORE_RAYCAST),t.userData.isMeasure=!0,t.userData.hideInTree=!0}))}constructor(t){super(),this.isMeasure=!0,this.option=pt({unit:"m",onTop:!0,linewidth:.002,lineColor:"#FF9900",pointColor:"#FF9900",fillColor:"#FF9900",textFillColor:"#FFFFFF",textStrokeColor:"rgba(0,0,0,.6)",textStrokeWidth:2,fontSize:16,pointOffset:[.5,.5]},t||{}),this.picks={},this.name=this.option.name||"Measure",this.id=be.MathUtils.generateUUID(),this.root=new Ya,this.root.name="Measure",this.root.userData.hideInTree=!0,this.pointsGroup=new Ya,this.root.add(this.pointsGroup),this.line=new cc({points:[],layers:pe.IGNORE_RAYCAST,material:{linewidth:this.option.linewidth,color:this.option.lineColor,worldUnits:!1}}),Bu.signMeasure(this.line),this.root.add(this.line)}addHelperLine(){this.helperLine=new cc({material:{linewidth:this.option.linewidth,color:this.option.lineColor,worldUnits:!1,dashed:!0,dashSize:.15,gapSize:.15}}),this.helperLine.name="HelperLine",this.helperLine.mesh.material.color=new be.Color(this.option.lineColor).addScalar(.6),Bu.signMeasure(this.helperLine),this.root.add(this.helperLine)}setHelper(t){this.helperLine.clear(),this.helperLine.vertices.length<2&&this.helperLine.addPoint(t)}setOnTop(t){[this.line?this.line.mesh?.material:null,this.area?this.area.mesh?.material:null,this.helperLine?this.helperLine.mesh?.material:null].forEach((t=>{t&&(t.depthTest=!1,t.depthWrite=!1,t.side=be.DoubleSide,t.needsUpdate=!0)})),this.line.renderOrder=t?Bu.RENDER_ORDER:0,this.area&&(this.area.renderOrder=t?Bu.RENDER_ORDER:0),this.helperLine&&(this.helperLine.renderOrder=t?Bu.RENDER_ORDER:0),this.root.traverse((t=>{}))}addPick(t,e){this.picks[t]=e||{picked:[],raycasterPicked:[]}}getPick(t){return this.picks[t]}clear(){this.clearHelper(),this.picks={},this.pointsGroup.clear(),this.line.clear(),this.hLine&&this.hLine.clear(),this.area&&this.area.clear()}remove(){this.root.removeFromParent(),this.dispatchEvent({type:"removed",measure:this})}isComplete(){return!1}_updateDistancePoints(){}addPoint(t,e){}getLineDistance(t){if(0===t)return 0;t||(t=this.line.vertices.length);let e=0,i=this.line.vertices.slice(0,t+1);return i.forEach(((t,r)=>{i[r-1]&&(e+=t.distanceTo(i[r-1]))})),e}getDistance(t){let e=0;return t.forEach(((i,r)=>{t[r-1]&&(e+=i.distanceTo(ti(t[r-1])))})),e}getArea(t){return _o(t.map((t=>ti(t))))}getHeight(t,e){return Math.abs(ti(t).y-ti(e).y)}getPoints(){return this.line.vertices.map((t=>t.toArray()))}toJSON(){const t={};return t.id=this.id,t.type=this.type,this.option.mode&&(t.mode=this.option.mode),t.result=this.result,t.points=this.getPoints(),t}fromJSON(t){this.id=t.id,this.option.mode&&t.mode&&(this.option.mode=t.mode),this.setPoints(t.points||[]),this._updateDistancePoints()}setVisible(t){this.root.visible=!!t}updateHelper(){}createLabel(t,e){const i=new Co({position:t,center:e.center||[.5,.5],material:{depthWrite:!1,depthTest:!1,map:{text:"",icon:"",iconWidth:6,iconHeight:6,fontColor:e.fontColor||this.option.textFillColor,strokeWidth:this.option.textStrokeWidth,strokeColor:this.option.textStrokeColor,fontSize:e.fontSize||this.option.fontSize,...e||{}}}});return i.sprite.material.depthTest=!1,i.sprite.material.depthWrite=!1,Bu.signMeasure(i),this.pointsGroup.add(i),i}_createLine(t,e,i){const r=new THING.Line({points:[t,e],material:{color:i||"#FFFFFF",depthTest:!1,depthWrite:!1}});Bu.signMeasure(r),this.root.add(r);let n=new be.Line3(t,e),s=new be.Vector3;n.getCenter(s);let o=ti(t).distanceTo(ti(e));return this.createLabel(s,{text:o.toFixed(2)+"m",center:[.5,-.5],fontColor:"#ffffff"}),o}clearHelper(){this.helperLine&&this.helperLine.clear()}setHelper(t){this.helperLine&&(this.clearHelper(),this.helperLine.addPoint(t))}updateHelper(t){this.helperLine&&(1==this.helperLine.vertices.length&&this.helperLine.addPoint(t),this.helperLine.setPoint(1,t))}setPoints(t){this.clear(),t.forEach((t=>{this.addPoint(t)}))}}Bu.RENDER_ORDER=99999;const ku={SNAP_VERTEX:0,SNAP_MIDPOINT:1,SNAP_CIRCLE_CENTER:2,SNAP_EDGE:3,SNAP_FACE:4,SNAP_CIRCULARARC:5,SNAP_CURVEDEDGE:6,SNAP_CURVEDFACE:7,MEASUREMENT_DISTANCE:1,MEASUREMENT_ANGLE:2,MEASUREMENT_AREA:3,CALIBRATION:4,MEASUREMENT_CHANGED_EVENT:"measurement-changed",UNITS_CALIBRATION_STARTS_EVENT:"units_calibration_starts_event",EPSILON:1e-4},ju=function(t){var e=t.map((t=>ti(t)));if(3!==e.length||function(t){for(var e=0;e[t.x,t.y,t.z]));if(e.forEach(((t,e)=>{this.createLabel(t,{icon:"thing-point",center:this.option.pointOffset})})),this.distance=0,e.length<2)return;let i=this.line.vertices[0],r=this.line.vertices[1];this._createLine(i,r,"#FFFFFF");var n=new be.Vector3(r.x,i.y,r.z),s=new be.Vector3(i.x,i.y,r.z);this.createLabel(n,{icon:"thing-point",center:this.option.pointOffset}),this.createLabel(s,{icon:"thing-point",center:this.option.pointOffset});let o=0;o+=this._createLine(n,s,"#FF0000"),o+=this._createLine(i,s,"#0066ff"),o+=this._createLine(r,n,"#00FF00"),this.distance=o,this.root.locked=!0}addPoint(t,e){let i=this.line.vertices.length;(0==i||i>0&&i<2&&!Vu(t,this.line.vertices[i-1]))&&(this.addPick(i,e),this.line.addPoint(t),this.setHelper(t),this._updateDistancePoints())}},SimpleDistanceMeasure:class extends Bu{constructor(t){super(t),this.type="SimpleDistanceMeasure",this.maxPickCount=2,this.minPickCount=2,this.distance=0,this.addHelperLine(),this.setOnTop(this.option.onTop)}get result(){return(this.distance?Number(this.distance).toFixed(2):0)+"m"}isComplete(){return 2==this.line.vertices.length}_updateLine(){}_updateLabel(){if(2!==this.line.vertices.length)return;let t=this.line.vertices[0],e=this.line.vertices[1],i=new be.Line3(t,e),r=new be.Vector3;i.getCenter(r);let n=ti(t).distanceTo(ti(e));this.distance=n,this.resultLabel=this.createLabel(r,{text:this.result,center:[.5,-.5],fontColor:"#FFFFFF"})}_updateDistancePoints(t){this.pointsGroup.clear(),this.option;this.line.vertices.map((t=>[t.x,t.y,t.z])).forEach(((t,e)=>{this.createLabel(t,{icon:"thing-point",center:this.option.pointOffset})})),this._updateLabel(),this.root.locked=!0}addPoint(t,e){let i=this.line.vertices.length;(0==i||i>0&&i<2&&!Vu(t,this.line.vertices[i-1]))&&(this.addPick(i,e),this.line.addPoint(t),this.setHelper(t),this._updateDistancePoints())}},RectilinearDistanceMeasure:class extends Bu{constructor(t){super(t),this.type="RectilinearDistanceMeasure",this.maxPickCount=this.minPickCount=2,this.distance=0,this.addHelperLine(),this.setOnTop(this.option.onTop)}get result(){return(this.distance?Number(this.distance).toFixed(2):0)+"m"}isComplete(){return 2==this.line.vertices.length}_updateDistancePoints(t){this.pointsGroup.clear();const e=this.line.vertices.map((t=>[t.x,t.y,t.z]));if(this.line.visible=!0,this.distance=0,e.length<2)return;let i=this.line.vertices[0],r=this.line.vertices[1];var n=new be.Vector3(r.x,i.y,r.z),s=new be.Vector3(i.x,i.y,r.z);this.createLabel(n,{icon:"thing-point",center:this.option.pointOffset}),this.createLabel(s,{icon:"thing-point",center:this.option.pointOffset}),this.createLabel(i,{icon:"thing-point",center:this.option.pointOffset}),this._createLine(n,s,"#FF0000"),this.distance=this._createLine(i,s,"#0066ff"),this.line.visible=!1,this.root.locked=!0}addPoint(t,e){let i=this.line.vertices.length;(0==i||i>0&&i<2&&!Vu(t,this.line.vertices[i-1]))&&(this.addPick(i,e),this.line.addPoint(t),this.setHelper(t),this._updateDistancePoints())}},MultipleDistanceMeasure:class extends Bu{constructor(t){super(pt({mode:"segment"},t)),this.type="MultipleDistanceMeasure",this.maxPickCount=Number.MAX_SAFE_INTEGER,this.minPickCount=3,this.distance=0,this.addHelperLine(),this.setOnTop(this.option.onTop)}get result(){return(this.distance?Number(this.distance).toFixed(2):0)+"m"}isComplete(){return this.line.vertices.length>=2}_updateDistancePoints(){this.pointsGroup.clear();const t=this.line.vertices,e=t.map((t=>[t.x,t.y,t.z]));let i=0;const r=this.option.mode;e.forEach(((n,s)=>{this.createLabel(n,{icon:"thing-point",center:this.option.pointOffset});let o=n,a=0;if(s>0&&"segment"==r){a=t[s].distanceTo(t[s-1]);let e=new THREE.Line3(t[s],t[s-1]);o=new THREE.Vector3,e.getCenter(o)}let l="total"==r?this.getLineDistance(s):a;i+=l,this.createLabel(o,{text:l.toFixed(2)+"m",center:[.5,-.5]}),s==e.length-1&&"segment"==r&&this.createLabel(n,{text:i.toFixed(2)+"m",center:[.5,-.5]})})),this.distance=i,this.root.locked=!0}addPoint(t,e){let i=this.line.vertices.length;(0==i||i>0&&!Vu(t,this.line.vertices[i-1]))&&(this.line.addPoint(t),this.addPick(i,e),this.setHelper(t),this._updateDistancePoints())}updateHelper(t){1==this.helperLine.vertices.length&&this.helperLine.addPoint(t),this.helperLine.setPoint(1,t)}},HeightMeasure:class extends Bu{constructor(t){super(t),this.type="HeightMeasure",this.maxPickCount=this.minPickCount=2,this.hLine=new cc({points:[],material:{linewidth:this.option.linewidth,color:this.option.lineColor}}),Bu.signMeasure(this.hLine),this.root.add(this.hLine),this.line.mesh.material.transparent=!0,this.line.mesh.material.opacity=.2,this.setOnTop(this.option.onTop)}get result(){return(this.height?Number(this.height).toFixed(2):0)+"m"}isComplete(){return 2==this.line.vertices.length}setOnTop(t){[this.line?this.line.mesh?.material:null,this.hLine?this.hLine.mesh?.material:null].forEach((t=>{t&&(t.depthTest=!1,t.needsUpdate=!0,t.transparent=!0,t.side=be.DoubleSide)})),this.line&&(this.line.renderOrder=t?Bu.RENDER_ORDER:0),this.hLine&&(this.hLine.renderOrder=t?Bu.RENDER_ORDER:0)}_updateDistancePoints(){this.pointsGroup.clear();const t=this.line.vertices.map((t=>[t.x,t.y,t.z]));if(t.forEach(((t,e)=>{this.createLabel(t,{icon:"thing-point",center:this.option.pointOffset})})),t.length<2)return;let e=t[t.length-1],i=Math.abs(t[0][1]-t[1][1]);this.height=i,this.createLabel(e,{text:i.toFixed(2)+"m(h)",center:[0,-.5]}),this.root.locked=!0}addPoint(t,e){let i=this.line.vertices.length;if(t=ti(t),(0==i||1==i&&!Vu(t,this.line.vertices[0]))&&(this.addPick(i,e),this.line.addPoint(t),this._updateDistancePoints()),i=this.line.vertices.length,2==i){const e=this.line.vertices[0];let i=e.y>=t.y?e:t,r=e.y>=t.y?t:e;this.hLine.addPoint(i);let n=[i.x,r.y,i.z];this.hLine.addPoint(n),this.createLabel(n,{icon:"thing-point",center:this.option.pointOffset})}}},AngleMeasure:class extends Bu{constructor(t){super(t),this.type="AngleMeasure",this.maxPickCount=3,this.minPickCount=3,this.addHelperLine(),this.setOnTop(this.option.onTop)}get result(){return(this.angle?Number(this.angle).toFixed(2):0)+"°"}isComplete(){return 3==this.line.vertices.length}_updateDistancePoints(t){this.pointsGroup.clear();this.line.vertices.forEach(((t,e)=>{this.createLabel(t,{icon:"thing-point",center:this.option.pointOffset})})),this.updateLabel()}updateLabel(){const t=this.line.vertices;null!=this.angle&&(this.label&&this.root.getObjectByProperty("uuid",this.label.uuid)?(this.label.updateMaterial({map:{text:this.result}}),this.label.position.copy(t[1])):this.label=this.createLabel(t[1],{text:this.result,center:[.5,-.5]}))}clearAngleMeshes(){}drawAngle(t,e,i,r,n,s){var o=.001;this.materialAngle||(this.materialAngle=new be.MeshPhongMaterial({color:10066329,opacity:.5,transparent:!0,depthTest:!1,depthWrite:!1,side:be.DoubleSide}),this.materialAngleOutline=new be.MeshBasicMaterial({color:16750848,depthTest:!1,depthWrite:!1}));var a=Math.min(t.distanceTo(e),t.distanceTo(i))/4;this.surfaceColor=new be.MeshBasicMaterial({color:new be.Color(this.option.lineColor),opacity:.4,transparent:!0,depthTest:!1,depthWrite:!1,side:be.DoubleSide});var l=new be.CircleGeometry(a,100,0,n*Math.PI/180),h=new be.Mesh(l,this.surfaceColor);h.traverse((t=>{t.userData.isLocked=!0,t.userData.isMeasure=!0,t.userData.hideInTree=!0})),this.arc&&this.arc.removeBySelf(),this.arc=h,this.root.add(h),h.position.set(t.x,t.y,t.z);var c=h.position.clone();c.add(r),h.lookAt(c),h.updateMatrixWorld();var d=ti(Nc.getPoint(h,1)),u=ti(Nc.getPoint(h,Nc.getVerticesLength(h.geometry)-2));d.applyMatrix4(h.matrixWorld),u.applyMatrix4(h.matrixWorld);var p=new be.Vector3,m=new be.Vector3,f=new be.Vector3,g=new be.Vector3;p.subVectors(d,t),m.subVectors(u,t),f.subVectors(e,t),g.subVectors(i,t);var v,y=p.angleTo(f),w=p.angleTo(g),x=m.angleTo(f),b=m.angleTo(g);v=(y<=o&&y>=-.001||w<=o&&w>=-.001)&&(x<=o&&x>=-.001||b<=o&&b>=-.001)?0:(y<=Math.PI+o&&y>=Math.PI-o||w<=Math.PI+o&&w>=Math.PI-o)&&(x<=Math.PI+o&&x>=Math.PI-o||b<=Math.PI+o&&b>=Math.PI-o)?Math.PI:y<=x+o&&y>=x-o||y<=b+o&&y>=b-o?y:w;var _=new be.Matrix4;_.makeRotationAxis(r,v),_.multiply(h.matrix),h.matrix=_,h.rotation.setFromRotationMatrix(h.matrix),h.updateMatrixWorld(),d=ti(Nc.getPoint(h,1)),u=ti(Nc.getPoint(h,Nc.getVerticesLength(h.geometry)-2)),d.applyMatrix4(h.matrixWorld),u.applyMatrix4(h.matrixWorld),p.subVectors(d,t),m.subVectors(u,t),y=p.angleTo(f),w=p.angleTo(g),x=m.angleTo(f),b=m.angleTo(g),y>=o&&w>=o&&((_=new be.Matrix4).makeRotationAxis(r,2*-v),_.multiply(h.matrix),h.matrix=_,h.rotation.setFromRotationMatrix(h.matrix)),this.midPoint=new be.Vector3;let A=Math.round(Nc.getVerticesLength(h.geometry)/2-1),S=ti(Nc.getPoint(h,A));this.midPoint.copy(S),this.midPoint.applyMatrix4(h.matrixWorld);var T=new be.Vector3;T.subVectors(this.midPoint,t).normalize(),T.multiplyScalar(a/2),this.midPoint.add(T)}updateAngle(){let t=this.line.vertices,e=this.helperLine.vertices,i=[].concat(t);if(2==t.length&&2==e.length&&i.push(e[1]),3!==i.length)return;const r=ju(i);this.angle=r;var n=new be.Vector3,s=new be.Vector3,o=new be.Vector3;s.subVectors(i[0],i[1]),o.subVectors(i[1],i[2]),n.crossVectors(s,o),n.normalize(),this.drawAngle(i[1],i[0],i[2],n,r),this.updateLabel()}addPoint(t,e){let i=this.line.vertices.length;(0==i||i>0&&i<3&&!Vu(t,this.line.vertices[i-1]))&&(this.addPick(i,e),this.line.addPoint(t),this.setHelper(t),this._updateDistancePoints(),this.root.locked=!0)}setHelper(t){this.helperLine.clear(),this.helperLine.addPoint(t)}updateHelper(t){let e=this.helperLine.vertices.length;1==e&&this.helperLine.addPoint(t),this.helperLine.setPoint(1,t),e>1&&this.updateAngle()}fromJSON(t){super.fromJSON(t),this.updateAngle()}},AreaMeasure:class extends Bu{constructor(t){super(t),this.type="AreaMeasure",this.maxPickCount=Number.MAX_SAFE_INTEGER,this.minPickCount=3,this.addHelperLine(),this.area=new Gc({points:[],polygon:{material:{color:this.option.fillColor,opacity:.1,transparent:!0,side:2,depthWrite:!1,depthTest:!1}},line:{material:{linewidth:this.option.linewidth,color:this.option.lineColor,depthWrite:!1,depthTest:!1}}}),this.areaValue=0,this.root.add(this.area),this.setOnTop(this.option.onTop)}get result(){return(this.areaValue?Number(this.areaValue).toFixed(2):0)+"m²"}isComplete(){return this.area.vertices.length>=3}setOnTop(t){[this.line?this.line.mesh.material:null,this.area?this.area?.mesh?.material:null,this.area?this.area?.line?.material:null].forEach((e=>{e&&(e.depthTest=!t,e.needsUpdate=!t,e.transparent=!0,e.side=be.DoubleSide)})),this.line&&(this.line.renderOrder=t?Bu.RENDER_ORDER:0),this.area&&(this.area.renderOrder=t?Bu.RENDER_ORDER:0)}_updateDistancePoints(){this.pointsGroup.clear();const t=this.area.vertices.map((t=>[t.x,t.y||this.area.position.y,t.z]));if(this.area.mesh){const i=this.area.centerPos;i[2]=i[1],i[1]=t[0][1];const r=_o(this.area.vertices);if(this.areaValue=r,r>0){var e=this.createLabel(i,{text:this.result,center:[.5,.5]});e.position.y+=.05,e.renderOrder=999}}t.forEach(((t,e)=>{this.createLabel(t,{icon:"thing-point",center:this.option.pointOffset})})),this.root.locked=!0}getPoints(){return this.area.getPoints().map((t=>[t[0],this.area.position.y||0,t[2]]))}addPoint(t){0==this.area.vertices.length&&this.setHelper(t),this.area.addPoint(t),this._updateDistancePoints()}updateHelper(t){this.area.vertices.length>2?this.clearHelper():(1==this.helperLine.vertices.length&&this.helperLine.addPoint(t),this.helperLine.setPoint(1,t))}}});const Xu=be.ObjectLoader;const Wu=be.ObjectLoader;class Yu extends jh{constructor(t,e,i){super(t),this.type="SetMaterialCommand",this.name="Set Material",this.updatable=!0,this.object=e,this.materialSlot=Q(i.slot)?this.getSlotIndex(i.slot):i.slot;let r=this.editor.getObjectMaterial(e,this.materialSlot);this.oldMaterial=r&&r.clone(),this.newValue=et(i);let n={};for(const t in i)n[t]=e.option?e.option[t]:void 0;this.oldValue=n}getSlotIndex(t){return this.object.materialSlot?this.object.materialSlot[t]:0}execute(){this.object.updateMaterial(this.newValue),this.editor.signals.materialChanged.dispatch(this.object)}undo(){this.editor.setObjectMaterial(this.object,this.materialSlot,this.oldMaterial.clone()),this.editor.signals.materialChanged.dispatch(this.object)}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldValue=null,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.oldValue=t.oldValue,this.newValue=t.newValue,this.object=this.editor.objectByUuid(t.objectUuid)}}const Qu=be.ObjectLoader;const Ju=be.Vector3;class Zu extends jh{constructor(t,e,i,r){super(t),this.type="SetPositionCommand",this.name="Set Position",this.updatable=!0,this.object=e,void 0!==e&&void 0!==i&&(this.oldPosition=e.position.clone(),this.newPosition=ti(i).clone()),void 0!==r&&(this.oldPosition=ti(r).clone())}execute(){this.object.position.copy(this.newPosition),this.object.updateMatrixWorld(!0),this.editor.signals.objectChanged.dispatch(this.object)}undo(){this.object.position.copy(this.oldPosition),this.object.updateMatrixWorld(!0),this.editor.signals.objectChanged.dispatch(this.object)}update(t){this.newPosition.copy(t.newPosition)}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldPosition=this.oldPosition.toArray(),t.newPosition=this.newPosition.toArray(),t}fromJSON(t){super.fromJSON(t),this.object=this.editor.objectByUuid(t.objectUuid),this.oldPosition=(new Ju).fromArray(t.oldPosition),this.newPosition=(new Ju).fromArray(t.newPosition)}}const qu=be.Euler;class Ku extends jh{constructor(t,e,i,r){super(t),this.type="SetRotationCommand",this.name="Set Rotation",this.updatable=!0,this.object=e,void 0!==e&&void 0!==i&&(this.oldRotation=e.rotation.clone(),this.newRotation=i.clone()),void 0!==r&&(this.oldRotation=r.clone())}execute(){this.object.rotation.copy(this.newRotation),this.object.updateMatrixWorld(!0),this.editor.signals.objectChanged.dispatch(this.object)}undo(){this.object.rotation.copy(this.oldRotation),this.object.updateMatrixWorld(!0),this.editor.signals.objectChanged.dispatch(this.object)}update(t){this.newRotation.copy(t.newRotation)}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldRotation=this.oldRotation.toArray(),t.newRotation=this.newRotation.toArray(),t}fromJSON(t){super.fromJSON(t),this.object=this.editor.objectByUuid(t.objectUuid),this.oldRotation=(new qu).fromArray(t.oldRotation),this.newRotation=(new qu).fromArray(t.newRotation)}}const $u=be.Vector3;class tp extends jh{constructor(t,e,i,r){super(t),this.type="SetScaleCommand",this.name="Set Scale",this.updatable=!0,this.object=e,void 0!==e&&void 0!==i&&(this.oldScale=e.scale.clone(),this.newScale=ti(i).clone()),void 0!==r&&(this.oldScale=ti(r).clone())}execute(){this.object.scale.copy(this.newScale),this.object.updateMatrixWorld(!0),this.editor.signals.objectChanged.dispatch(this.object)}undo(){this.object.scale.copy(this.oldScale),this.object.updateMatrixWorld(!0),this.editor.signals.objectChanged.dispatch(this.object)}update(t){this.newScale.copy(t.newScale)}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldScale=this.oldScale.toArray(),t.newScale=this.newScale.toArray(),t}fromJSON(t){super.fromJSON(t),this.object=this.editor.objectByUuid(t.objectUuid),this.oldScale=(new $u).fromArray(t.oldScale),this.newScale=(new $u).fromArray(t.newScale)}}class ep extends jh{constructor(t,e,i){super(t),this.type="SetUuidCommand",this.name="Update UUID",this.object=e,this.oldUuid=void 0!==e?e.uuid:void 0,this.newUuid=i}execute(){this.object.uuid=this.newUuid,this.editor.signals.objectChanged.dispatch(this.object),this.editor.signals.sceneGraphChanged.dispatch()}undo(){this.object.uuid=this.oldUuid,this.editor.signals.objectChanged.dispatch(this.object),this.editor.signals.sceneGraphChanged.dispatch()}toJSON(){const t=super.toJSON(this);return t.oldUuid=this.oldUuid,t.newUuid=this.newUuid,t}fromJSON(t){super.fromJSON(t),this.oldUuid=t.oldUuid,this.newUuid=t.newUuid,this.object=this.editor.objectByUuid(t.oldUuid),void 0===this.object&&(this.object=this.editor.objectByUuid(t.newUuid))}}const ip=["castShadow","receiveShadow"];class rp extends jh{constructor(t,e,i,r){super(t),this.type="SetValueCommand",this.name=`Set ${i}`,this.updatable=!0,this.object=e,this.attributeName=i,this.oldValue=void 0!==e?e[i]:void 0,this.newValue=r}execute(){this.object[this.attributeName]=this.newValue,ip.includes(this.attributeName)&&this.object.traverse((t=>{t[this.attributeName]=this.newValue})),this.editor.signals.objectChanged.dispatch(this.object),this.editor.signals.sceneGraphChanged.dispatch()}undo(){this.object[this.attributeName]=this.oldValue,ip.includes(this.attributeName)&&this.object.traverse((t=>{t[this.attributeName]=this.oldValue})),this.editor.signals.objectChanged.dispatch(this.object),this.editor.signals.sceneGraphChanged.dispatch()}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.attributeName=this.attributeName,t.oldValue=this.oldValue,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.attributeName=t.attributeName,this.oldValue=t.oldValue,this.newValue=t.newValue,this.object=this.editor.objectByUuid(t.objectUuid)}}class np extends jh{constructor(t,e,i,r){super(t),this.type="SetPointsCommand",this.name="Set Points",this.updatable=!0,this.object=e,this.oldValue=r||(e.getPoints?e.getPoints():e.points||[]),this.newValue=i}execute(){this.object.updatePoints(this.newValue),this.editor.signals.objectChanged.dispatch(this.object)}undo(){this.object.updatePoints(this.oldValue),this.editor.signals.objectChanged.dispatch(this.object)}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldValue=this.oldValue,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.oldValue=t.oldValue,this.newValue=t.newValue,this.object=this.editor.objectByUuid(t.objectUuid)}}class sp extends jh{constructor(t,e,i,r){super(t),this.type="SetGeometryConfigCommand",this.name="Set Geometry Config",this.updatable=!0,this.object=e,this.oldValue=r||et(e.option.geometry)||{},this.newValue=i}execute(){this.object.updateBy({geometry:this.newValue}),this.editor.signals.objectChanged.dispatch(this.object)}undo(){this.object.updateBy({geometry:this.oldValue}),this.editor.signals.objectChanged.dispatch(this.object)}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldValue=this.oldValue,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.oldValue=t.oldValue,this.newValue=t.newValue,this.object=this.editor.objectByUuid(t.objectUuid)}}class op extends jh{constructor(t,e,i,r){super(t),this.type="SetArrowCommand",this.name="Set Arrow",this.updatable=!0,this.object=e,this.oldValue=r||et(e.option.arrow)||{},this.newValue=i}execute(){this.object.updateBy({arrow:this.newValue}),this.editor.signals.objectChanged.dispatch(this.object)}undo(){this.object.updateBy({arrow:this.oldValue}),this.editor.signals.objectChanged.dispatch(this.object)}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldValue=this.oldValue,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.oldValue=t.oldValue,this.newValue=t.newValue,this.object=this.editor.objectByUuid(t.objectUuid)}}class ap extends jh{constructor(t,e,i,r){super(t),this.type="SetLineCommand",this.name="Set Line",this.updatable=!0,this.object=e,this.oldValue=r||et(e.option.line)||{},this.newValue=i}execute(){this.object.updateBy({line:this.newValue}),this.editor.signals.objectChanged.dispatch(this.object)}undo(){this.object.updateBy({line:this.oldValue}),this.editor.signals.objectChanged.dispatch(this.object)}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldValue=this.oldValue,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.oldValue=t.oldValue,this.newValue=t.newValue,this.object=this.editor.objectByUuid(t.objectUuid)}}class lp extends jh{constructor(t,e,i,r){super(t),this.type="SetPolygonCommand",this.name="Set Polygon",this.updatable=!0,this.object=e,this.oldValue=r||et(e.option.polygon)||{},this.newValue=i}execute(){this.object.updateBy({polygon:this.newValue}),this.editor.signals.objectChanged.dispatch(this.object)}undo(){this.object.updateBy({polygon:this.oldValue}),this.editor.signals.objectChanged.dispatch(this.object)}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldValue=this.oldValue,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.oldValue=t.oldValue,this.newValue=t.newValue,this.object=this.editor.objectByUuid(t.objectUuid)}}var hp=Object.freeze({__proto__:null,AddObjectCommand:zh,MoveObjectCommand:Gh,AddMeasureCommand:class extends jh{constructor(t,e){super(t),this.type="AddMeasureCommand",this.measure=e,void 0!==e&&(this.name=`Add Measure: ${e.type} - ${e.result}`)}execute(){this.editor.viewer.measureControl.addMeasure(this.measure),this.editor.signals.measureChanged.dispatch(this.measure)}undo(){this.editor.viewer.measureControl.removeMeasure(this.measure),this.editor.signals.measureChanged.dispatch()}toJSON(){const t=super.toJSON(this);return t.measure=this.measure.toJSON(),t}fromJSON(t){super.fromJSON(t),this.measure=this.editor.viewer.measureControl.getMeasure(t.measure.id),void 0===this.measure&&(this.measure=new Hu[t.measure.type])}},RemoveMeasureCommand:class extends jh{constructor(t,e){super(t),this.type="RemoveMeasureCommand",this.measure=e,void 0!==e&&(this.name=`Removed Measure: ${e.type} - ${e.result}`)}execute(){this.editor.viewer.measureControl.removeMeasure(this.measure),this.editor.signals.sceneGraphChanged.dispatch()}undo(){this.editor.viewer.measureControl.addMeasure(this.measure),this.editor.signals.sceneGraphChanged.dispatch()}toJSON(){const t=super.toJSON(this);return t.measure=this.measure.toJSON(),t}fromJSON(t){super.fromJSON(t),this.measure=this.editor.viewer.measureControl.getMeasure(t.measure.id),void 0===this.measure&&(this.measure=new Hu[t.measure.type])}},MultiCmdsCommand:class extends jh{constructor(t,e){super(t),this.type="MultiCmdsCommand",this.name="Multiple Changes",this.cmdArray=void 0!==e?e:[]}execute(){this.editor.signals.sceneGraphChanged.active=!1;for(let t=0;t=0;t--)this.cmdArray[t].undo();this.editor.signals.sceneGraphChanged.active=!0,this.editor.signals.sceneGraphChanged.dispatch()}toJSON(){const t=super.toJSON(this),e=[];for(let t=0;t0&&(i.images=r),i.sourceFile=t.sourceFile,i}}fromJSON(t){function e(t){let e=null;if(null!==t){const i=new Qu,r=i.parseImages(t.images);e=i.parseTextures([t],r)[t.uuid],e.sourceFile=t.sourceFile}return e}super.fromJSON(t),this.object=this.editor.objectByUuid(t.objectUuid),this.mapName=t.mapName,this.oldMap=e(t.oldMap),this.newMap=e(t.newMap)}},SetMaterialValueCommand:class extends jh{constructor(t,e,i,r,n){super(t),this.type="SetMaterialValueCommand",this.name=`Set Material.${i}`,this.updatable=!0,this.object=e,this.material=this.editor.getObjectMaterial(e,n),this.oldValue=void 0!==this.material?this.material[i]:void 0,this.newValue=r,this.attributeName=i}execute(){this.material[this.attributeName]=this.newValue,this.material.needsUpdate=!0,this.editor.signals.objectChanged.dispatch(this.object),this.editor.signals.materialChanged.dispatch(this.material)}undo(){this.material[this.attributeName]=this.oldValue,this.material.needsUpdate=!0,this.editor.signals.objectChanged.dispatch(this.object),this.editor.signals.materialChanged.dispatch(this.material)}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.attributeName=this.attributeName,t.oldValue=this.oldValue,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.attributeName=t.attributeName,this.oldValue=t.oldValue,this.newValue=t.newValue,this.object=this.editor.objectByUuid(t.objectUuid)}},SetMaterialVectorCommand:class extends jh{constructor(t,e,i,r,n){super(t),this.type="SetMaterialColorCommand",this.name=`Set Material.${i}`,this.updatable=!0,this.object=e,this.material=this.editor.getObjectMaterial(e,n),this.oldValue=void 0!==this.material?this.material[i].toArray():void 0,this.newValue=r,this.attributeName=i}execute(){this.material[this.attributeName].fromArray(this.newValue),this.editor.signals.materialChanged.dispatch(this.material)}undo(){this.material[this.attributeName].fromArray(this.oldValue),this.editor.signals.materialChanged.dispatch(this.material)}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.attributeName=this.attributeName,t.oldValue=this.oldValue,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.object=this.editor.objectByUuid(t.objectUuid),this.attributeName=t.attributeName,this.oldValue=t.oldValue,this.newValue=t.newValue}},SetPositionCommand:Zu,SetRotationCommand:Ku,SetScaleCommand:tp,SetSceneCommand:class extends jh{constructor(t,e){if(super(t),this.type="SetSceneCommand",this.name="Set Scene",this.cmdArray=[],void 0!==e)for(this.cmdArray.push(new ep(this.editor,this.editor.scene,e.uuid)),this.cmdArray.push(new rp(this.editor,this.editor.scene,"name",e.name)),this.cmdArray.push(new rp(this.editor,this.editor.scene,"userData",JSON.parse(JSON.stringify(e.userData))));e.children.length>0;){const t=e.children.pop();this.cmdArray.push(new zh(this.editor,t))}}execute(){this.editor.signals.sceneGraphChanged.active=!1;for(let t=0;t=0;t--)this.cmdArray[t].undo();this.editor.signals.sceneGraphChanged.active=!0,this.editor.signals.sceneGraphChanged.dispatch()}toJSON(){const t=super.toJSON(this),e=[];for(let t=0;t{t.layers.set(this.newValue)})),this.editor.signals.objectChanged.dispatch(this.object),this.editor.signals.sceneGraphChanged.dispatch()}undo(){this.object.traverse((t=>{t.layers.set(this.oldValue)})),this.editor.signals.objectChanged.dispatch(this.object),this.editor.signals.sceneGraphChanged.dispatch()}update(t){this.newValue=t.newValue}toJSON(){const t=super.toJSON(this);return t.objectUuid=this.object.uuid,t.oldValue=this.oldValue,t.newValue=this.newValue,t}fromJSON(t){super.fromJSON(t),this.attributeName=t.attributeName,this.oldValue=t.oldValue,this.newValue=t.newValue,this.object=this.editor.objectByUuid(t.objectUuid)}}});function cp(t){this.enable=!0,this.editor=t,this.undos=[],this.redos=[],this.lastCmdTime=new Date,this.idCounter=0,this.historyDisabled=!1,this.config=t.config;const e=this;this.editor.signals.startPlayer.add((function(){e.historyDisabled=!0})),this.editor.signals.stopPlayer.add((function(){e.historyDisabled=!1}))} /** @license * JS Signals * https://www.cnblogs.com/catherinezyr/p/7403485.html * Released under the MIT license * Author: Miller Medeiros * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM) */ function dp(t,e,i,r,n){this._listener=e,this._isOnce=i,this.context=r,this._signal=t,this._priority=n||0}function up(t,e){if("function"!=typeof t)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))}function pp(){this._bindings=[],this._prevParams=null;var t=this;this.dispatch=function(){pp.prototype.dispatch.apply(t,arguments)}}cp.prototype={execute:function(t,e){if(!this.enable)return;const i=this.undos[this.undos.length-1],r=(new Date).getTime()-this.lastCmdTime.getTime(),n=i&&i.updatable&&t.updatable&&i.object===t.object&&i.type===t.type&&i.script===t.script&&i.attributeName===t.attributeName;n&&"SetScriptValueCommand"===t.type||n&&r<500?(i.update(t),t=i):(this.undos.push(t),t.id=++this.idCounter),t.name=void 0!==e?e:t.name,t.execute(),t.inMemory=!0,this.config.getKey("settings/history")&&(t.json=t.toJSON()),this.lastCmdTime=new Date,this.redos=[],this.editor.signals.historyChanged.dispatch(t)},undo:function(){if(!this.enable)return;if(this.historyDisabled)return void alert("Undo/Redo disabled while scene is playing.");let t;return this.undos.length>0&&(t=this.undos.pop(),!1===t.inMemory&&t.fromJSON(t.json)),void 0!==t&&(t.undo(),this.redos.push(t),this.editor.signals.historyChanged.dispatch(t)),t},redo:function(){if(!this.enable)return;if(this.historyDisabled)return void alert("Undo/Redo disabled while scene is playing.");let t;return this.redos.length>0&&(t=this.redos.pop(),!1===t.inMemory&&t.fromJSON(t.json)),void 0!==t&&(t.execute(),this.undos.push(t),this.editor.signals.historyChanged.dispatch(t)),t},toJSON:function(){const t={undos:[],redos:[]};if(!this.config.getKey("settings/history"))return t;for(let e=0;ethis.idCounter?i.id:this.idCounter}for(let e=0;ethis.idCounter?i.id:this.idCounter}this.editor.signals.historyChanged.dispatch(this.undos[this.undos.length-1])}},clear:function(){this.undos=[],this.redos=[],this.idCounter=0,this.editor.signals.historyChanged.dispatch()},goToState:function(t){if(!this.enable)return;if(this.historyDisabled)return void alert("Undo/Redo disabled while scene is playing.");this.editor.signals.sceneGraphChanged.active=!1,this.editor.signals.historyChanged.active=!1;let e=this.undos.length>0?this.undos[this.undos.length-1]:void 0;if(void 0===e||t>e.id)for(e=this.redo();void 0!==e&&t>e.id;)e=this.redo();else for(;e=this.undos[this.undos.length-1],void 0!==e&&t!==e.id;)this.undo();this.editor.signals.sceneGraphChanged.active=!0,this.editor.signals.historyChanged.active=!0,this.editor.signals.sceneGraphChanged.dispatch(),this.editor.signals.historyChanged.dispatch(e)},enableSerialization:function(t){this.goToState(-1),this.editor.signals.sceneGraphChanged.active=!1,this.editor.signals.historyChanged.active=!1;let e=this.redo();for(;void 0!==e;)e.hasOwnProperty("json")||(e.json=e.toJSON()),e=this.redo();this.editor.signals.sceneGraphChanged.active=!0,this.editor.signals.historyChanged.active=!0,this.goToState(t)}},dp.prototype={active:!0,params:null,execute:function(t){var e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,e=this._listener.apply(this.context,i),this._isOnce&&this.detach()),e},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},pp.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(t,e,i,r){var n,s=this._indexOfListener(t,i);if(-1!==s){if((n=this._bindings[s]).isOnce()!==e)throw new Error("You cannot add"+(e?"":"Once")+"() then add"+(e?"Once":"")+"() the same listener without removing the relationship first.")}else n=new dp(this,t,e,i,r),this._addBinding(n);return this.memorize&&this._prevParams&&n.execute(this._prevParams),n},_addBinding:function(t){var e=this._bindings.length;do{--e}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){for(var i,r=this._bindings.length;r--;)if((i=this._bindings[r])._listener===t&&i.context===e)return r;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,i){return up(t,"add"),this._registerListener(t,!1,e,i)},addOnce:function(t,e,i){return up(t,"addOnce"),this._registerListener(t,!0,e,i)},remove:function(t,e){up(t,"remove");var i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t},removeAll:function(){for(var t=this._bindings.length;t--;)this._bindings[t]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(t){if(this.active){var e,i=Array.prototype.slice.call(arguments),r=this._bindings.length;if(this.memorize&&(this._prevParams=i),r){e=this._bindings.slice(),this._shouldPropagate=!0;do{r--}while(e[r]&&this._shouldPropagate&&!1!==e[r].execute(i))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};const mp=pp;function fp(){const t="ThingJS.Editor",e={language:"zh",autosave:!0,"project/title":"","project/editable":!1,"project/vr":!1,"project/renderer/antialias":!0,"project/renderer/shadows":!0,"project/renderer/shadowType":1,"project/renderer/physicallyCorrectLights":!1,"project/renderer/toneMapping":0,"project/renderer/toneMappingExposure":1,"settings/history":!1,"settings/shortcuts/translate":"w","settings/shortcuts/rotate":"e","settings/shortcuts/scale":"r","settings/shortcuts/undo":"z","settings/shortcuts/focus":"f"};if(void 0===window.localStorage[t])window.localStorage[t]=JSON.stringify(e);else{const i=JSON.parse(window.localStorage[t]);for(const t in i)e[t]=i[t]}return{getKey:function(t){return e[t]},setKey:function(){for(let t=0,i=arguments.length;tt&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Y"===r.name&&Math.abs(Kp.copy(om).applyQuaternion(e).dot(this.eye))>t&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Z"===r.name&&Math.abs(Kp.copy(am).applyQuaternion(e).dot(this.eye))>t&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"XY"===r.name&&Math.abs(Kp.copy(am).applyQuaternion(e).dot(this.eye)).9&&(r.visible=!1)),"Y"===this.axis&&(Bp.setFromEuler(qp.set(0,0,Math.PI/2)),r.quaternion.copy(e).multiply(Bp),Math.abs(Kp.copy(om).applyQuaternion(e).dot(this.eye))>.9&&(r.visible=!1)),"Z"===this.axis&&(Bp.setFromEuler(qp.set(0,Math.PI/2,0)),r.quaternion.copy(e).multiply(Bp),Math.abs(Kp.copy(am).applyQuaternion(e).dot(this.eye))>.9&&(r.visible=!1)),"XYZE"===this.axis&&(Bp.setFromEuler(qp.set(0,Math.PI/2,0)),Kp.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(tm.lookAt($p,Kp,om)),r.quaternion.multiply(Bp),r.visible=this.dragging),"E"===this.axis&&(r.visible=!1)):"START"===r.name?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):"END"===r.name?(r.position.copy(this.worldPosition),r.visible=this.dragging):"DELTA"===r.name?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),Ip.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Ip.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(Ip),r.visible=this.dragging):(r.quaternion.copy(e),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=-1!==this.axis.search(r.name)))}super.updateMatrixWorld(t)}}dm.prototype.isTransformControlsGizmo=!0;class um extends Tp{constructor(){super(new Cp(1e5,1e5,2,2),new Ep({visible:!1,wireframe:!0,side:wp,transparent:!0,opacity:.1,toneMapped:!1})),this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),lm.copy(sm).applyQuaternion("local"===e?this.worldQuaternion:im),hm.copy(om).applyQuaternion("local"===e?this.worldQuaternion:im),cm.copy(am).applyQuaternion("local"===e?this.worldQuaternion:im),Kp.copy(hm),this.mode){case"translate":case"scale":switch(this.axis){case"X":Kp.copy(this.eye).cross(lm),nm.copy(lm).cross(Kp);break;case"Y":Kp.copy(this.eye).cross(hm),nm.copy(hm).cross(Kp);break;case"Z":Kp.copy(this.eye).cross(cm),nm.copy(cm).cross(Kp);break;case"XY":nm.copy(cm);break;case"YZ":nm.copy(lm);break;case"XZ":Kp.copy(cm),nm.copy(hm);break;case"XYZ":case"E":nm.set(0,0,0)}break;default:nm.set(0,0,0)}0===nm.length()?this.quaternion.copy(this.cameraQuaternion):(rm.lookAt(Ip.set(0,0,0),nm,Kp),this.quaternion.setFromRotationMatrix(rm)),super.updateMatrixWorld(t)}}um.prototype.isTransformControlsPlane=!0;class pm extends be.Group{constructor(){super(),this.isTransformControlsGroup=!0,this.matrixWorldNeedsUpdate=!0,this.tempMatrix=new be.Matrix4,this.userData.selected=[],this.userData.prevParent=[],this.control=null,this._copy=new be.Group}reset(){this.userData.selected=[],this.userData.prevParent=[],this.position.set(0,0,0),this.scale.set(1,1,1),this.rotation.set(0,0,0),this.matrix=this._copy.matrix.clone(),this.matrixWorld=this._copy.matrixWorld.clone(),this.tempMatrix=new be.Matrix4,this.quaternion.set(0,0,0,1),this.matrixWorldNeedsUpdate=!0}setSelected(t){!t||t.length<1||(t.forEach((t=>{this.userData.selected.includes(t)||(t.userData.preChildrenIndex=t.getInParentIndex())})),t.sort(((t,e)=>t.userData.preChildrenIndex-e.userData.preChildrenIndex)),t.forEach((t=>{this.userData.selected.includes(t)||(t.matrixWorldNeedsUpdate=!0,this.tempMatrix.copy(this.matrixWorld).invert(),t.matrixWorld.premultiply(this.tempMatrix).decompose(t.position,t.quaternion,t.scale),this.userData.selected.push(t),this.userData.prevParent.push(t.parent),this.add(t))})))}getCenter(){var t=(new be.Box3).setFromObject(this);const e=new be.Vector3;return t.getCenter(e),e}removeSelected(){const t=this.userData.selected,e=this.userData.prevParent;for(var i,r=0;r{t.locked=!1,delete t._thing_tag,this.drawing=!1})),this.editor.signals.controlPointsChanged.add((t=>{const e=t.userData.controlPointType;"main"==e&&this._updatePointsByControlPoints(t),"middle"==e&&this._middelToMain(t)}))}hasControlPoints(){return this.points.length>0}_isPointType(t){return["Billboard","Box","Model","Sphere","Circle","Plane","ImageLabel","ImagePlane","ReflectorPlane","Capsule","Cone","Cylinder","Dodecahedron","Doughnut","Icosahedron","Lathe","Ring","Tetrahedron","Torus","TorusKnot"].includes(t)}_isLineType(t){return["Line","RouteLine","TubeLine","Line2","ExtrudeLine"].includes(t)}_isStartEndLineType(t){return["CurveLine","CurveTubeLine"].includes(t)}_isPolygonType(t){return["Polygon","Water","Heatmap","ExtrudePolygon"].includes(t)}_initHelper(){this.lineHelper=new THING.Line({points:[],style:{color:"#FF9900",dotSize:0}}),this.helperRoot.add(this.lineHelper),this.areaHelper=new Gc({points:[],style:{text:"",polygon:{color:this.option.fillColor,opacity:.2,side:2},line:{color:this.option.lineColor}}}),this.helperRoot.add(this.areaHelper),this.controlPointHelper=new THING.Group,this.helperRoot.add(this.controlPointHelper)}_addControlPoint(t,e,i,r){const n=new Co({position:t,center:[.5,.5],material:{depthTest:!1,depthWrite:!1,map:{text:"",icon:"",iconWidth:12,iconHeight:12,fontColor:this.option.textFillColor,strokeWidth:this.option.textStrokeWidth,color:this.option.pointColor,strokeColor:this.option.textStrokeColor,...e||{}}}});return n.userData.object=this._drawObject,n.userData.isControlPoint=!0,n.userData.controlPointType=i||"main",this._drawObject.isPolygon&&(n.position.y=this._drawObject.position.y),n.addEventListener("removed",(()=>{})),void 0!==r?n.insertTo(this.controlPointHelper,r):this.controlPointHelper.add(n),n}setControlPointPosition(t,e){"main"==t.userData.controlPointType&&(t.position.copy(ti(e)),this._updatePointsByControlPoints(t))}setLastControlPointPosition(t){const e=this.controlPointHelper.children,i=e[e.length-1];this.setControlPointPosition(i,t)}setLastControlPointWithScalar(t){if(!t||0==ti(t).lengthSq())return;const e=this.controlPointHelper.children,i=e[e.length-1].position.clone();i.add(ti(t)),this.setLastControlPointPosition(i)}setLastControlPointWithDegree(t){const e=this.controlPointHelper.children,i=e[e.length-1],r=e[e.length-3].position.clone(),n=i.position.clone();n.sub(r);const s=function(t,e,i){let r=(new be.Vector3).copy(t).dot(e);return t.addScalar(Math.cos(i)).add(e.addScalar(r*(1-Math.cos(i)))).add((new be.Vector3).crossVectors(e,t).addScalar(Math.sin(i)))}(new be.Vector3(0,1,0),n,be.MathUtils.DEG2RAD*t);this.setLastControlPointPosition(s)}addControlPoint(t){this._draw(t)}addControlPointWithScalar(t){if(!t||0==ti(t).lengthSq())return;const e=this.controlPointHelper.children,i=e[e.length-1];if(!i)return;const r=i.position.clone();r.add(ti(t)),this.addControlPoint(r)}_updateControlPoints(){this.controlPointHelper.clear();let t=new be.Vector3;t.copy(ti(this.points[0])),this.points.forEach(((e,i)=>{this._addControlPoint(e,{icon:"thing-point",center:[.5,.5]});let r=this.points[i+1];if(r){t.add(ti(r)).multiplyScalar(.5),this._addControlPoint(t,{icon:"thing-point",center:[.5,.5]},"middle").scale.setScalar(.6),t.copy(ti(r))}}))}_updateMiddleControlPointsByControlPoint(t){if("main"!==t.userData.controlPointType)return;const e=this.controlPointHelper.children;let i=-1;for(let r=0;r"middle"!=t.userData.controlPointType)).map((t=>t.position.toArray()));i.forEach((t=>{t[1]-=e})),this.points=i,this._drawObject.updatePoints(this.points),this._drawObject.isPolygon&&(this._drawObject.position.y=t.position.y,this.controlPointHelper.children.forEach((e=>{e.position.y=t.position.y}))),this._updateMiddleControlPointsByControlPoint(t),this.editor.signals.sceneGraphChanged.dispatch()}_updateControlPointsByObject(t){if(!this._drawObject||!this._drawObject.needPoints)return;let e=this._drawObject.getPoints().map((t=>this._drawObject.localToWorld(ti(t)).toArray()));this._drawObject.position.y,this.points=e,0==e.length?this.controlPointHelper.clear():(this._updateControlPoints(),this.editor.signals.sceneGraphChanged.dispatch())}update(){this._drawObject&&this._drawObject.needPoints}_updateLine(){}_clearHelper(){this.lineHelper.setPoints([])}get camera(){return this.viewer.camera}get container(){return this.viewer.container}get scene(){return this.viewer.sceneManager.getScene()}_isComplete(){if(!this._drawObject)return!0;const t=this._drawObject,e=t.type;let i=t.vertices||t.points||t._points;return!i||(this._isLineType(e)?i.length>=2:this._isPolygonType(e)?i.length>=3:!this._isStartEndLineType(e)||2==i.length)}_drawPoint(t,e){if(!t||!e)return;const{type:i}=e;return this._drawObject=new THING[i]({position:t,...e}),this.editor.execute("AddObject",this._drawObject),this.endDraw(),this._drawObject}_addPoint(t){if(this.points.length>0){if(ti(this.points[this.points.length-1]).distanceTo(ti(t))<.001)return!1}return this.points.push(t),!0}__drawLine(t,e){if(!this.enable||!this.drawing)return;if(!this._addPoint(t))return;const{type:i,style:r,properties:n,src:s,rotation:o,avoid:a,name:l}=e;if(this._drawObject){const t=this._drawObject.getPoints();this.editor.execute(new np(this.editor,this._drawObject,this.points,t))}else this._drawObject=new THING[i]({points:this.points,properties:n,name:l}),this._drawObject.locked=!0,this._drawObject._thing_tag="helper",this._drawObject.updateBy(e),this.editor.execute("AddObject",this._drawObject);this._updateControlPoints()}__drawPolygon(t,e){if(!this.enable||!this.drawing)return;if(!this._addPoint(t))return;const{type:i,style:r,properties:n,src:s,rotation:o,avoid:a,name:l,material:h,polygon:c,line:d}=e;if(this._drawObject){const t=this._drawObject.getPoints();this.editor.execute(new np(this.editor,this._drawObject,this.points,t))}else this._drawObject=new THING[i]({...e,points:this.points.map((t=>ti(t)))}),this._drawObject.position.y=this.points[0][1],h&&h.depth&&(this._drawObject.position.y+=h.depth/2),this._drawObject.locked=!0,this._drawObject._thing_tag="helper",this._drawObject.updateBy(e),this.editor.execute("AddObject",this._drawObject);this._updateControlPoints()}_drawModel(){}draw(t){this._resetDraw(),this.viewer.setCursor("crosshair"),this._drawObjectConfig=t,this._drawObject=null,this.drawing=!0}setEditObject(t){this._resetDraw(),this._drawObject=t,this.points=t.getPoints(),this._updateControlPoints();const{editor:e}=this.viewer;e.signals.objectChanged.add(this._objectChangedEvent),e.signals.objectSelected.add(this._objectSelectedEvent)}endEdit(){this._resetDraw();const{editor:t}=this.viewer;t.signals.objectChanged.remove(this._objectChangedEvent),t.signals.objectSelected.remove(this._objectSelectedEvent)}endDraw(){this._drawObject&&this.dispatchEvent({type:"drawEnd",drawObject:this._drawObject}),this.drawing=!1,this._resetDraw()}setEditable(t){this._resetDraw(),this.editing=t}_resetDraw(){this.drawing=!1,this.points=[],this.controlPointHelper.clear(),this._drawObjectConfig=null,this._drawObject=null,this.viewer.setCursor(null)}_draw(t){if(!this.enable||!this._drawObjectConfig)return;const{type:e}=this._drawObjectConfig;this._isPointType(e)&&this._drawPoint(t,this._drawObjectConfig),this._isPolygonType(e)&&this._drawPolygon(t,this._drawObjectConfig),this._isLineType(e)&&this._drawLine(t,this._drawObjectConfig),this._isStartEndLineType(e)}addPoint(t){this._draw(t)}deleteLastPoint(){if(!this._drawObjectConfig)return;const{type:t}=this._drawObjectConfig;if(this._isPolygonType(t)||this._isLineType(t)){const t=this._drawObject.getPoints();this.editor.execute(new np(this.editor,this._drawObject,this.points,t)),this._updateControlPoints()}}activate(){this.enable=!0;const{container:t,editor:e}=this.viewer;t.addEventListener("pointermove",this._onPointerMove),t.addEventListener("pointerdown",this._onPointerDown),t.addEventListener("pointerup",this._onPointerUp),e.signals.objectChanged.add(this._objectChangedEvent),e.signals.objectSelected.add(this._objectSelectedEvent)}deactivate(){this.endDraw(),this.enable=!1;const{container:t,editor:e}=this.viewer;t.removeEventListener("pointermove",this._onPointerMove),t.removeEventListener("pointerdown",this._onPointerDown),t.removeEventListener("pointerup",this._onPointerUp),e.signals.objectChanged.remove(this._objectChangedEvent),e.signals.objectSelected.remove(this._objectSelectedEvent)}_objectSelectedEvent(t){t&&!this.drawing&&this._drawObject==t&&this._updateControlPointsByObject(),this.viewer.rm.enableRender()}_objectChangedEvent(t){const{editor:e,rendererManager:i}=this.viewer;if(this.hasControlPoints()&&e.selected&&!e.selected.userData.isControlPoint&&this._updateControlPointsByObject(e.selected),t.userData.isControlPoint){var r=this.controlPointHelper.children.filter((t=>"main"==t.userData.controlPointType)).map((t=>t.position.toArray()));e.execute(new np(e,t.userData.object,r))}i.enableRender()}_onPointerMove(t){this.enable}_getPosition(t){let e=null,i=this.viewer.picker.pick(t.clientX,t.clientY);return i.raycasterPicked&&(i.raycasterPicked[0]&&i.raycasterPicked[0].point&&(e=i.raycasterPicked[0].point.toArray()),e||(e=this.viewer.coordScreenToWorld(t.clientX,t.clientY))),{picked:i,position:e}}_onPointerDown(t){if(!this.enable||!this.drawing||!this.pickable)return;if(!V(t))return;let{position:e}=this._getPosition(t);this._draw(e)}_onPointerUp(){this.enable&&this.drawing}clear(){this._resetDraw(),this.root.clear()}destroy(){this.endDraw(),this.deactivate(),this.viewer.editor.signals.controlPointsChanged.removeAll()}get pickable(){return this._pickable}set pickable(t){this._pickable=t,this.viewer.setCursor(t?"crosshair":"default")}}class fm extends ui{constructor(t){super();var e=mp.Signal;this.signals={editScript:new e,startPlayer:new e,stopPlayer:new e,toggleVR:new e,exitedVR:new e,editorCleared:new e,controlPointsChanged:new e,savingStarted:new e,savingFinished:new e,transformModeChanged:new e,snapChanged:new e,spaceChanged:new e,rendererCreated:new e,rendererUpdated:new e,sceneBackgroundChanged:new e,sceneEnvironmentChanged:new e,sceneFogChanged:new e,sceneFogSettingsChanged:new e,sceneGraphChanged:new e,sceneRendered:new e,cameraChanged:new e,cameraResetted:new e,cameraViewType:new e,cameraType:new e,geometryChanged:new e,objectSelected:new e,objectFocused:new e,objectAdded:new e,objectChanged:new e,objectRemoved:new e,cameraAdded:new e,cameraRemoved:new e,helperAdded:new e,helperRemoved:new e,materialAdded:new e,materialChanged:new e,materialRemoved:new e,scriptAdded:new e,scriptChanged:new e,scriptRemoved:new e,windowResize:new e,showGridChanged:new e,showHelpersChanged:new e,refreshSidebarObject3D:new e,historyChanged:new e,viewportCameraChanged:new e,measureChanged:new e},this.viewer=t,this.scene=t.sceneManager.getScene(),this.sceneHelpers=t.sceneManager.sceneHelpers,this.config=new fp,this.history=new cp(this),this.drawer=new mm(this),this.object={},this.geometries={},this.materials={},this.textures={},this.scripts={},this.materialsRefCounter=new Map,this.mixer=new THREE.AnimationMixer(this.scene),this.selected=null,this.helpers={},this.cameras={},this.enable=!1;const i=new THREE.Box3Helper(new THREE.Box3);i.name="EditorSelectionBox",i.visible=!1,this.selectionBox=i,this.sceneHelpers.add(i),this.transformControlsGroup=new pm,ht(["_keyDown","_keyUp"],this),this._initTransformControls(),this._initSignals(),this._initEvent()}pickFilter(t){return!0}__clickEvent({object:t,sceneHelpersObject:e}){if(this.enable&&!this.drawer.drawing&&!1!==this.pickable&&(!this.pickFilter||this.pickFilter(t)))if(t){if(t.userData.isLocked||t.locked)return void this.deselect(null);if(t.needPoints){if(t.userData.isMeasure)return void this.select(t);this.status="editPoints",this.drawer.setEditObject(t),this.select(t)}else t.userData.isControlPoint||(this.status="editPoint"),this.select(t)}else if(e){if(e!=this.selectionBox)try{e.isControlPoint?this.select(e):e.userData.object&&this.select(e.userData.object)}catch(t){this.deselect(null)}}else this.deselect()}_initEvent(){this.pickable=!0,this.clickEvent=ut(this.__clickEvent,200,this),this.viewer.on("click",this.clickEvent)}_keyDown(t){if(!this.enable)return;let e=t.code;e=e.indexOf("hift")>0?"shift":e,this._keypressedHandle(e)}_keyUp(t){if(!this.enable)return;let e=t.code;e=e.indexOf("hift")>0?"shift":e,this._keypressedHandle(e)}_keypressedHandle(t){if("Delete"===t)this.deleteSelected()}eachSelected(t){const e=this.selected;e&&(Array.isArray(e)?e:[e]).forEach((e=>{t&&t(e)}))}deleteSelected(){this.eachSelected((t=>{t.removeFromParent&&t.userData.drawPolylineHelperControl,t.userData.isControlPoint?this.drawer._deleteControlPoint(t):this.remove(t)})),this.deselect()}_initSignals(){const{selectionBox:t,transformControls:e,viewer:i}=this,r=this.signals;r.objectSelected.add((r=>{if(!this.enable||!this.pickable)return;t.visible=!1,e.detach();let n=this._preSelected;if(n&&n.userData.isMeasure,r&&!r.needPoints&&r!==this.scene&&r!==i.camera&&(t.box.setFromObject(r,!0),!1===t.box.isEmpty()&&(t.visible=!0),e.attach(r),r.isGroup)){r.matrixWorldNeedsUpdate=!0,t.getCenter();const e=new THREE.Vector3;t.box.getSize(e);const i=(t.box.max.x-t.box.min.x)/2,n=(t.box.max.y-t.box.min.y)/2,s=(t.box.max.z-t.box.min.z)/2;new THREE.Vector3(i,n,s)}i.rendererManager.enableRender()})),r.transformModeChanged.add((t=>{e.setMode(t)})),r.snapChanged.add((t=>{e.setTranslationSnap(t)})),r.spaceChanged.add((t=>{e.setSpace(t)})),r.objectChanged.add((e=>{this.enable&&e&&(this.selected===e&&t.box.setFromObject(e,!0),e.isPerspectiveCamera&&e.updateProjectionMatrix(),void 0!==this.helpers[e.id]&&this.helpers[e.id].update(),i.rendererManager.enableRender())})),r.objectRemoved.add((t=>{this.enable&&(i.cameraControl.enabled=!0,t===e.object&&e.detach(),i.rendererManager.enableRender())})),r.cameraViewType.add((t=>{const e=this.viewer.cameraControl;switch(e.enableRotate(),e.setInteract({mouseButtonRight:"rotate"}),t){case"top":e.toTopView();break;case"bottom":e.toBottomView();break;case"left":e.toLeftView();break;case"right":e.toRightView();break;case"back":e.toBackView();break;case"front":e.toFrontView()}t?(r.cameraType.dispatch("ortho"),["left","right","front","back"].includes(t)&&(e.disableRotate(),e.setInteract({mouseButtonRight:null})),["top","bottom"].includes(t)&&e.disableRotate({disableAzimuthAngle:!1,disablePolarAngle:!0})):r.cameraType.dispatch("perspective"),this.transformControls.camera=this.viewer.camera,i.rendererManager.enableRender()})),r.cameraType.add((t=>{this.viewer.cameraControl.setOrtho("ortho"==t),i.rendererManager.enableRender()})),r.materialChanged.add((()=>{i.rendererManager.enableRender()})),r.historyChanged.add((()=>{i.rendererManager.enableRender()}))}setEnable(t){this.deselect(),this.enable=t,this.transformControls.setEnable(t),t?(window.addEventListener("keydown",this._keyDown),window.addEventListener("keyup",this._keyUp)):(window.removeEventListener("keydown",this._keyDown),window.removeEventListener("keyup",this._keyUp))}draw(t){this.drawer.activate(),this.drawer.draw(t)}endDraw(){this.drawer.endDraw(),this.drawer.deactivate(),this.deselect()}setScene(t){for(this.scene.uuid=t.uuid,this.scene.name=t.name,this.scene.background=t.background,this.scene.environment=t.environment,this.scene.fog=t.fog,this.scene.userData=JSON.parse(JSON.stringify(t.userData)),this.signals.sceneGraphChanged.active=!1;t.children.length>0;)this.addObject(t.children[0]);this.signals.sceneGraphChanged.active=!0,this.signals.sceneGraphChanged.dispatch()}objectByUuid(t){return this.scene.getObjectByProperty("uuid",t,!0)}addObject(t,e,i){var r=this;t.traverse((function(t){void 0!==t.geometry&&r.addGeometry(t.geometry),void 0!==t.material&&r.addMaterial(t.material),r.addCamera(t),r.addHelper(t)})),void 0===e?this.scene.add(t):(e.children.splice(i,0,t),t.parent=e),this.signals.objectAdded.dispatch(t),this.signals.sceneGraphChanged.dispatch()}moveObject(t,e,i){if(void 0===e&&(e=this.scene),e.add(t),void 0!==i){var r=e.children.indexOf(i);e.children.splice(r,0,t),e.children.pop()}this.signals.sceneGraphChanged.dispatch()}nameObject(t,e){t.name=e,this.signals.sceneGraphChanged.dispatch()}removeObject(t){if(null!==t){var e=this;t.traverse((function(t){e.removeCamera(t),e.removeHelper(t),void 0!==t.material&&e.removeMaterial(t.material)})),t.removeFromParent(),this.signals.objectRemoved.dispatch(t),this.signals.sceneGraphChanged.dispatch()}}addGeometry(t){this.geometries[t.uuid]=t}setGeometryName(t,e){t.name=e,this.signals.sceneGraphChanged.dispatch()}addMaterial(t){if(Array.isArray(t))for(var e=0,i=t.length;e{if(!this.enable)return;const t=n.object;if(t.userData.isControlPoint&&this.signals.controlPointsChanged.dispatch(t),t.userData.isRefPoint){const e=t.parent.getBox3(),i=t.position;e.containsPoint(i)||["x","y","z"].forEach((t=>{i[t]e.max[t]&&(i[t]=e.max[t])}))}this.dispatchEvent({type:"objectChange",object:t})})),n.addEventListener("change",(()=>{if(!this.enable)return;const t=n.object;if(void 0!==t){t.isHtmlPlane&&t.children[1]&&(t.children[1].visible=!1),this.selectionBox.box.setFromObject(t,!0);const e=this.helpers[t.id];void 0!==e&&!0!==e.isSkeletonHelper&&e.update(),this.signals.refreshSidebarObject3D.dispatch(t)}r.rendererManager.enableRender()})),n.addEventListener("mouseDown",(s=>{if(!this.enable)return;r.cameraControl.enabled=!1,this.pickable=!1;const o=n.object;t=o.position.clone(),e=o.rotation.clone(),i=o.scale.clone(),o.userData.isControlPoint&&o.userData.object.getPoints()})),n.addEventListener("mouseUp",(o=>{if(!this.enable)return;let a=n.object;if(void 0!==a)switch(n.getMode()){case"translate":t.equals(a.position)||a.userData.isControlPoint||(a.light&&a.type.indexOf("Helper"),this.execute(new Zu(this,a,a.position,t)));break;case"rotate":e.equals(a.rotation)||this.execute(new Ku(this,a,a.rotation,e));break;case"scale":i.equals(a.scale)||this.execute(new tp(this,a,a.scale,i))}r.cameraControl.enabled=!0,setTimeout((()=>{s.pickable=!0}),100)})),n.addEventListener("hoverAxis",(t=>{n.pickable=!1})),this.sceneHelpers.add(n)}setObjectMaterial(t,e,i){Array.isArray(t.material)&&void 0!==e?t.material[e]=i:t.material=i}updateObject(t,e){if(!t||!e||tt(e))return this;const{uuid:i,name:r,visible:n,renderOrder:s,position:o,rotation:a,scale:l,center:h,frustumCulled:c,layers:d,properties:u,interact:p,receiveShadow:m,castShadow:f,recursive:g,box:v,edge:y,geometry:w,style:x,userData:b,locked:_,dimensionHelper:A}=e;if(Lt(c)&&this.execute(new rp(this,t,"frustumCulled",c)),Lt(i)&&this.execute(new rp(this,t,"uuid",i)),Lt(r)&&this.execute(new rp(this,t,"name",r)),Lt(m)&&this.execute(new rp(this,t,"receiveShadow",m)),Lt(f)&&this.execute(new rp(this,t,"castShadow",f)),Lt(n)&&(this.execute(new rp(this,t,"visible",n)),n||t!=this.selected||this.deselect()),Lt(s)&&this.execute(new rp(this,t,"renderOrder",s)),q(u)&&this.execute(new rp(this,t,"properties",u)),q(p)&&this.execute(new rp(this,t,"interact",p)),o&&this.execute(new Zu(this,t,ti(o))),a){const e=ti(a),i=(new THREE.Euler).setFromVector3(new THREE.Vector3(e.x,e.y,e.z));this.execute(new Ku(this,t,i))}if(Lt(l)){let e=new THREE.Vector3;J(l)?e.setScalar(l):e.copy(ti(l)),this.execute(new tp(this,t,e))}if(Lt(e.points)&&t.updatePoints&&this.execute(new np(this,t,e.points)),Lt(w)&&t.updateGeometry&&(this.execute(new sp(this,t,w)),t.dispatchEvent({type:"geometry.change"})),Lt(e.arrow)&&t.updateArrow&&this.execute(new op(this,t,e.arrow)),Lt(e.line)&&t.updateLine&&this.execute(new ap(this,t,e.line)),Lt(e.polygon)&&t.updatePolygon&&this.execute(new lp(this,t,e.polygon)),Lt(d)&&this.execute("SetLayers",t,d),Lt(e.material)&&!tt(e.material)&&this.execute(new Yu(this,t,e.material)),Lt(h)&&this.execute(new rp(this,t,"center",h)),Lt(_)&&this.execute(new rp(this,t,"locked",_)),Lt(A)&&(t.userData.dimensionHelper&&t.userData.dimensionHelper.removeFromParent(),A)){const e=new THING.DimensionHelper(t);e.addEventListener("removed",(()=>{delete t.userData.dimensionHelper})),t.userData.dimensionHelper=e,this.add(e),this.signals.sceneGraphChanged.dispatch()}Lt(e.shader)&&t.updateShader&&t.updateShader(e.shader),e.video&&t.updateVideo&&t.updateVideo(e.video),e.style&&t.updateStyle&&t.updateStyle(e.style),q(v)&&t.setBoxHelper(v),q(y)&&t.setEdge(y),q(b)&&t.updateBy({userData:b}),this.signals.objectChanged.dispatch(t),this.viewer.rendererManager.enableRender()}move(t,e,i){this.execute(new Gh(this,t,e,i))}execute(t,e){if(Q(t)){if(t.indexOf("Command")<0&&(t+="Command"),!hp[t])return;if(e&&e.isSync){const i=[...arguments].slice(2);e.loaded?this.history.execute(new hp[t](this,e,...i)):e.addEventListener("loaded",(()=>{this.history.execute(new hp[t](this,e,...i))}))}else{const e=[...arguments].slice(1);this.history.execute(new hp[t](this,...e))}}else this.history.execute(t)}add(t,e){this.execute("AddObject",t),e&&this.moveObject(t,e)}remove(t){this.execute("RemoveObject",t)}clear(){this.root.children.forEach((t=>{this.remove(t)}))}undo(){this.history.undo()}redo(){this.history.redo()}toJSON(){}fromJSON(){}removeHelper(t){if(void 0!==this.helpers[t.id]){var e=this.helpers[t.id];e.parent.remove(e),delete this.helpers[t.id],this.signals.helperRemoved.dispatch(e)}}getRootTree({keyword:t,type:e}={}){return function i(r,n){for(var s=0,o=r.length;s=0&&!r.userData.hideInTree)&&n.push(r):r.userData.hideInTree||n.push(r)),a.children.length>0&&(a.isNode,i(a.children,r.children))}}return n}(this.root.children,[])}clone(t){if(!t)return;const e=t.clone();e.name=t.name+"Copy",this.add(e)}get root(){return this.viewer.sceneManager.getScene().root}lockAll(){this.root.children.forEach((t=>{t.isLocked=!0})),this.removeTransformControls()}}var gm,vm;fm.prototype.addHelper=(gm=new THREE.SphereGeometry(2,4,2),vm=new THREE.MeshBasicMaterial({color:16711680,visible:!1}),function(t,e){if(void 0===e){if(t.isCamera)e=new THREE.CameraHelper(t);else if(t.isPointLight)e=new THREE.PointLightHelper(t,1);else if(t.isDirectionalLight)e=new THREE.DirectionalLightHelper(t,1);else if(t.isSpotLight)e=new THREE.SpotLightHelper(t);else if(t.isHemisphereLight)e=new THREE.HemisphereLightHelper(t,1);else if(t.isSkinnedMesh)e=new THREE.SkeletonHelper(t.skeleton.bones[0]);else{if(!0!==t.isBone||!0===t.parent?.isBone)return;e=new THREE.SkeletonHelper(t)}const i=new THREE.Mesh(gm,vm);i.name="picker",i.userData.object=t,e.add(i)}this.sceneHelpers.add(e),this.helpers[t.id]=e,this.signals.helperAdded.dispatch(e)});new be.Vector3;let ym=null;class wm extends be.EventDispatcher{constructor(t,e){super(),this.option=mt({unit:"m",pickPointColor:"#FF9900",onTop:!0},e||{}),this.viewer=t,this.root=new Ya,this.root.name="MeasureControlRoot",this.root.userData.hideInTree=!0,this.scene.tempRoot.add(this.root),this.measures=[],this.pickPoint=new Co({center:[.5,.5],material:{depthWrite:!1,depthTest:!1,map:{icon:"thing-point",color:this.option.pickPointColor,iconWidth:8,iconHeight:8}}}),this.pickPoint.visible=!1,this.pickPoint.traverse((t=>{t.userData.isMeasure=!0,t.userData.hideInTree=!0})),this.root.add(this.pickPoint),ht(["_onPointerDown","_onPointerMove","_onPointerMove","_onPointerUp","_dblClick","_objectSelectedEvent"],this),this.mode="MultipleDistance",this.measuring=!1}get scene(){return this.viewer.sceneManager.scene}get editor(){return this.viewer.editor}getMeasure(t){return this.measures.filter((e=>e.id==t))[0]}addMeasure(t){if(!t.isMeasure)return;this.root.add(t.root),this.current=t;this.getMeasure(t.id)||this.measures.push(t)}removeMeasure(t){const e=this.getMeasure(t.id);e&&e.remove(),st(this.measures,"id",t.id)}resetMeasureValues(){this.angle=0,this.distanceX=0,this.distanceY=0,this.distanceZ=0,this.distanceXYZ=0,this.result=null}activate(t,e){if(!Hu[t])return void console.log("Undefined Measure Type");this.deactivate(),ym=this.editor.enable,this.editor.setEnable(!1),D(this.viewer.container,"THING-measure"),this.mode=t,this.measuring=!0;const i=new Hu[t]({...this.option,...e||{}});this._excuteCreateMeasure(i);const{container:r,editor:n}=this.viewer;this.viewer.on("dblclick",this._dblClick),r.addEventListener("pointerdown",this._onPointerDown),r.addEventListener("pointermove",this._onPointerMove),r.addEventListener("pointerup",this._onPointerUp),n.signals.objectSelected.add(this._objectSelectedEvent),this.dispatchEvent({type:"measure.start"})}deactivate(){this.mode&&this.current&&this.current.clearHelper(),I(this.viewer.container,"THING-measure"),this.measuring=!1,this.mode="",this.pickPoint.visible=!1,this.resetMeasureValues(),this.viewer.off("dblclick",this._dblClick);const{container:t,editor:e}=this.viewer;t.removeEventListener("pointerdown",this._onPointerDown),t.removeEventListener("pointermove",this._onPointerMove),t.removeEventListener("pointerup",this._onPointerUp),e.signals.objectSelected.remove(this._objectSelectedEvent)}_objectSelectedEvent(t){t&&t.userData.isMeasure&&(t.updateMaterial({color:ue}),this.viewer.rendererManager.enableRender())}_excuteCreateMeasure(t){t.addEventListener("removed",(t=>{st(this.measures,"id",t.id),this.current==t&&(this.current=null)})),this.editor.execute("AddMeasure",t)}_dblClick(){if(this.current&&this.current.isComplete())return this.deactivate(),void this.dispatchEvent({type:"measure.end"})}_getPosition(t){let e=null,i=this.viewer.picker.pick(t.clientX,t.clientY);return i.raycasterPicked&&(i.raycasterPicked=i.raycasterPicked.filter((t=>t.object?!t.object.userData.isMeasure:t.point)),i.raycasterPicked[0]&&i.raycasterPicked[0].point&&(e=i.raycasterPicked[0].point.toArray(),this.pickPoint.updateMaterial({color:ue})),e||(e=this.viewer.coordScreenToWorld(t.clientX,t.clientY),this.pickPoint.updateMaterial({color:this.option.pickPointColor}))),{picked:i,position:e}}_onPointerMove(t){if(!this.measuring)return;let{position:e}=this._getPosition(t);e&&(this.pickPoint.visible||(this.pickPoint.visible=!0),this.pickPoint.position.set(e[0],e[1],e[2]),this.current&&(this.current.updateHelper(e),this.viewer.rendererManager.enableRender()))}_onPointerDown(t){if(!this.measuring||!this.current||0!=t.button)return;t.preventDefault(),t.stopPropagation();let{position:e,picked:i}=this._getPosition(t);e[1]+=.001,this.current.addPoint(e,i),this.viewer.rendererManager.enableRender()}_onPointerUp(){if(this.measuring)switch(this.mode){case"HeightMeasure":case"DistanceMeasure":case"SimpleDistanceMeasure":case"RectilinearDistanceMeasure":case"AngleMeasure":if(this.current&&this.current.isComplete())return this.viewer.rendererManager.enableRender(),setTimeout((()=>{this.editor.setEnable(ym),ym=null}),100),this.deactivate(),void this.dispatchEvent({type:"measure.end"})}}setVisible(t){this.root.visible=!!t}get visible(){return!1!==this.root.visible}set visible(t){this.setVisible(t)}clear(){this.measures.map((t=>({id:t.id}))).forEach((t=>{this.editor.execute("RemoveMeasure",this.getMeasure(t.id))}))}toJSON(){let t={type:"Measures",measures:[]};return this.measures.forEach((e=>{t.measures.push(e.toJSON())})),t}fromJSON(t){this.clear(),t.measures&&0!=t.measures.length&&t.measures.forEach((t=>{const e=new Hu[t.type](this.option);e.fromJSON(t),this._excuteCreateMeasure(e),e._updateDistancePoints()}))}}wm.RENDER_ORDER=99999;let xm=1;class bm extends ui{constructor(t){super(),this.id=xm,xm++;const e=this.option=pt(et(Nh),t);this.container=null,this._containerOldInfo={},this._loadingContainer=null,this._controlContainer=null,this._controls=[],this._controlPositions={},this._attributionControl=null,this.clock=new be.Clock,this.elapsedTime=0,this.deltaTime=0,this.currentFrame=0,this._fullscreen=!1,!1===e.backwardEnabled&&this.setBackwardEnabled(),ht(["_update","_updatePopups"],this),this.popups=new qa,this.popupsCollision=new Ja({padding:this.option.popupsAvoidPadding}),dt(this.updatePopupsAvoid,this,2e3),this._initContainer(),this.cameraControl=new Wa(this,{...this.option.interact}),this.sceneManager=this.sm=new sl(this),this.sceneManager.loadScene("default",this.option.scene),this.rendererManager=this.rm=new Sh(this,this.option.renderer),this._initRendererContainer(),mo.setViewer(this),this.resourceManager=this.rsm=mo,this.picker=new Ch(this),this.selector=new Ql(this),this.debugger=new Zl(this),this.debugger.show(this.option.debugger),this.eventManager=new Th(this),this.webviewManager=null,this.forceRender=this.option.forceRender,this.editor=new fm(this),this.measureControl=new wm(this),wo.addViewer(this),this.setView(this.option.view),this.rendererManager.start()}_initContainer(){const{container:t,attributions:e,showLogo:i}=this.option;let r=Q(t)?document.querySelector(t)||document.getElementById(t):t;F(r)||(r=document.body);if(r.getAttribute("data-viewerid"))throw new Error("Initialization failed because the target container is in use");if(r&&!this.container){r.setAttribute("data-viewerid",this.id),this.rendererContainer=U("div","THING-container",r),this.container=r,D(r,"THING-wrapper"),this._containerOldInfo={id:r.id,overflow:r.style.overflow,position:r.style.position},r.style.position||(r.style.position="relative"),r.id||r.setAttribute("id","THING-wrapper"),r.style.overflow="hidden";const t=this._controlContainer=U("div","THING-control-container",r);if(["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{this._controlPositions[e]=U("div",`THING-ctrl-${e}`,t)})),i&&this.addControl(new Ko,null),e){const t=this._attributionControl=new $o({customAttribution:e});this.addControl(t,null)}r.addEventListener("mousedown",G),r.addEventListener("mousewheel",G),navigator.userAgent.indexOf("Firefox")>0&&r.addEventListener("DOMMouseScroll",G);const n=new Je,{width:s,height:o}=this.getSize();n.setSize(s,o),n.domElement.style.position="absolute",n.domElement.style.left="0px",n.domElement.style.zIndex=0,n.domElement.style.display="none",this.rendererContainer.appendChild(n.domElement),this._cssRenderer=n}}_getEventTarget(t){const e=this.picker.pick(t.clientX,t.clientY);return e.raycasterPicked&&0==e.raycasterPicked.length?null:e}_initLoadingContainer(){const t=this.container;if(!t)return;(this._loadingContainer=U("div","THING-loading",t)).innerHTML='
Loading...
'}_hideLoading(){const t=this._loadingContainer;t&&(t.style.opacity=0,setTimeout((()=>{t.style.display="none"}),300))}_initRendererContainer(){const t=this.rendererContainer;if(!t)return;const{view:e}=this.option;e.aspect;const{width:i,height:r}=this.getSize();var n=this.renderer;n.domElement.setAttribute("tabindex","-1"),t.appendChild(n.domElement),this._captureDivElement=document.createElement("div"),this._captureRenderer=this._createRenderer(!0),this._captureRenderer.outputEncoding=be.sRGBEncoding,this._captureDivElement.appendChild(this._captureRenderer.domElement),this._resizeCaputureDivElement(i,r)}resize(){const{cameraControl:t,picker:e}=this,{width:i,height:r}=this.getSize();this.rendererManager?.setSize(i,r),this.webviewManager?.setSize(i,r),t.setSize(i,r),e.setSize(i,r),this._updatePopups(),this._resizeCaputureDivElement(i,r),this.rendererManager.enableRender(),this.fire({type:"resize",size:{width:i,height:r}})}addControl(t,e){if(!t)return;if(!e&&t.getDefaultPosition&&(e=t.getDefaultPosition()),e||(e="top-right"),!t||!t.onAdd)return void console.log("Add control error.");const i=t.onAdd(this,e);this._controls.push(t);const r=this._controlPositions[e];return-1!==e.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),t}removeControl(t){return t&&t.onRemove&&(this._constrols=this._constrols.filter((e=>e!==t)),t.onRemove()),this}_updateControls(){this._controls.forEach((t=>{t._update&&t._update()}))}setFullscreen(t){return this._fullscreen=!!t,this._fullscreen&&Fh.isEnabled?(this.fire("fullscreen"),Fh.request(this.container)):(this.fire("exitFullscreen"),Fh.exit())}setView(t,e=!1){return this.selector&&this.selector.update(),t.position&&this.cameraControl.setPosition(t.position,e),t.center&&this.cameraControl.setCenter(t.center,e),t.near&&this.cameraControl.setNear(t.near),t.far&&this.cameraControl.setFar(t.far),t.aspect&&this.cameraControl.setAspect(t.aspect),t.isOrtho&&(this.cameraControl.setOrtho(t.isOrtho),this.cameraControl.zoom=t.zoom||1,this.camera.left=t.left||-1e3,this.camera.right=t.right||1e3,this.camera.top=t.top||-1e3,this.camera.bottom=t.bottom||1e3,t.rotation&&4==t.rotation.length&&(t.rotation[0]||(t.rotation[0]=0),t.rotation[1]||(t.rotation[1]=0),t.rotation[2]||(t.rotation[2]=0),t.rotation[3]||(t.rotation[3]="XYZ"),this.camera.rotation.fromArray(t.rotation)),this.camera.updateProjectionMatrix()),this.cameraControl.cameraUpdateEvent(),this}getView(t){const e=this.cameraControl.camera,i=e instanceof be.OrthographicCamera;return{position:e.position.clone().toArray(),center:this.cameraControl.center.toArray(),far:e.far,near:e.near,aspect:t?this.getAspect():null,fov:e instanceof be.PerspectiveCamera?e.fov:null,isOrtho:i,left:e.left,right:e.right,top:e.top,bottom:e.bottom,zoom:e.zoom,rotation:e.rotation.toArray()}}getAspect(){const t=this.container;return t.clientWidth/(t.clientHeight||window.innerHeight)}pick(t){let e=null,i=this.picker.pick(t.clientX,t.clientY);return i.raycasterPicked&&(i.raycasterPicked[0]&&i.raycasterPicked[0].point&&(e=i.raycasterPicked[0].point.toArray()),e||(e=this.coordScreenToWorld(t.clientX,t.clientY))),{picked:i,position:e}}coordScreenToWorldWithPick(t,e,i,r){const n=this.picker.pick(t,e,r);return n.raycasterPicked&&(0==n.raycasterPicked.length||r&&0==r(n))?this.coordScreenToWorld(t,e,i):xt(n.raycasterPicked[0].point,5)}coordScreenToWorld(t,e,i){const r=this.camera,n=this.container.getBoundingClientRect();t=(t-n.left)/n.width*2-1,e=-(e-n.top)/n.height*2+1;let s=new be.Vector3;const o=new be.Vector3;r.updateProjectionMatrix(),r&&r.isPerspectiveCamera?(o.setFromMatrixPosition(r.matrixWorld),s.set(t,e,0).unproject(r).sub(o).normalize()):r&&r.isOrthographicCamera&&(o.set(t,e,(r.near+r.far)/(r.near-r.far)).unproject(r),s.set(0,0,-1).transformDirection(r.matrixWorld));const a=new be.Vector3(0,1,0).dot(s),l=this.cameraControl.center;if(!(Math.abs(a)<1e-4)){var h=(-o.y+(i||0)+l.y)/s.y,c=(new be.Vector3).copy(o).add((new be.Vector3).copy(s).multiplyScalar(h));return Lt(i)&&(c.y=i),xt(c,3)}}coordWorldToScreen(t,e,i){let r=(t&&t.isVector3?(new be.Vector3).copy(t):new be.Vector3(t,e,i)).project(this.camera);const{width:n,height:s}=this.getSize();let o=n/2,a=s/2;return{x:Math.round(r.x*o+o),y:Math.round(-r.y*a+a)}}getPixelLength(t,e){let i=this.coordWorldToScreen(ti(t)),r=this.coordWorldToScreen(ti(e));return i=new be.Vector2(i.x,i.y),r=new be.Vector2(r.x,r.y),Math.ceil(r.distanceTo(i))}getSize(){const t=this.container;if(!t)return{width:0,height:0};return{width:t.clientWidth||window.innerWidth,height:t.clientHeight||window.innerHeight}}trigger(t,e){this.eventManager.trigger(t,e)}setBackwardEnabled(){history.pushState(null,null,document.URL),window.addEventListener("popstate",(function(){history.pushState(null,null,document.URL)}))}captureScreenshot(t){const e=this.getSize(),i=pt({filename:"screenshot.jpg",mime:"image/jpeg",quality:.8,saveAsFile:!1,width:e.width,height:e.height},t),r=this;let n=this.renderer;this._captureRenderer&&(n=this._captureRenderer);const{width:s,height:o,quality:a,saveAsFile:l,filename:h,mime:c}=i;if(this._resizeCaputureDivElement(s,o),this.cameraControl.setSize(s,o),n.render(this.scene,this.camera),!l){let t=n.domElement.toDataURL(c,a);return this.cameraControl.setSize(e.width,e.height),this._resizeCaputureDivElement(e.width,e.height),t}n.domElement.toBlob((t=>{r.cameraControl.setSize(e.width,e.height),r._resizeCaputureDivElement(e.width,e.height),kh(t,h),r.dispatchEvent({type:"screenshot",data:t})}),c,a)}_createRenderer(){const{devicePixelRatio:t}=this.option;var e=new be.WebGLRenderer({preserveDrawingBuffer:!1,antialias:!0,logarithmicDepthBuffer:!0});e.info.autoReset=!1,e.setPixelRatio(t);var i=this.getSize();return e.setSize(i.width,i.height),e.autoClear=!1,e.shadowMap.enabled=!0,e.shadowMap.type=be.PCFSoftShadowMap,e.outputEncoding=be.sRGBEncoding,e.autoClear=!1,e.autoClearColor=!0,e.autoClearDepth=!0,e.autoClearStencil=!0,e.physicallyCorrectLights=!0,e}_collectRenderStates(){if(!this.debugger.enable)return;var t=this.renderer.info.memory,e=this.renderer.info.render;const i=this.scene.getVerticesCount();this.debugger.renderStates=this.renderStates={geometries:t.geometries,textures:t.textures,frame:e.frame,calls:e.calls,triangles:e.triangles,points:e.points,lines:e.lines,vertices:i}}_resizeCaputureDivElement(t,e){const{_captureDivElement:i,_captureRenderer:r}=this;if(i&&r){var n=i.style;n.width=t+"px",n.height=e+"px",n.display="none",r.setSize(t,e)}}_updatePopups(){this.popups.each((function(t){t.update()})),this.updatePopupsAvoid()}clearPopups(){this.popups._items.forEach((function(t){t&&t.remove()})),this.popups.clear()}updatePopupsAvoid(){this.popupsCollision.clear(),this.option.popupsAvoid&&0!=this.popups.length&&this.popups.each((t=>{if(!t||!t.avoid)return;t.updateBox();let e=this.popupsCollision.push(t.box2d);t.visible=!e}))}clearAvoidPopups(){this.boxCollision.clear(),this.clearPopups()}destroy(){cancelAnimationFrame(this._tick),this._tick=null,mo.clear(),this.selector.deactive(),this.selector=null,this.clearPopups(),this.cameraControl.setEnabled(!1),this.cameraControl.destroy(),this.cameraControl=null,this.rendererManager.destroy(),this.renderStates=null,this.debugger.remove(),this.debugger=null,this.sceneManager.destroy(),this._listeners=[],this.container.removeAttribute("data-viewerid"),I(this.container,"THING-wrapper");for(const t in this._containerOldInfo)this.container.style[t]=this._containerOldInfo[t];this.container.innerHTML="",this.container=null,this.fire("destory")}setCursor(t){this.container.style.cursor=t}initExplodeModel(t){if(!t)return;function e(t,e){return(new be.Vector3).addVectors(t.max,t.min).multiplyScalar(e)}const i=new be.Box3;i.setFromObject(t);const r=e(i,.5),n=new be.Box3;t.traverse((function(t){if(!(t.isMark||t.isMarkChild||t.isLine||t.isSprite)&&t.isMesh){n.setFromObject(t);const i=e(n,.5);t.userData.worldDir=(new be.Vector3).subVectors(i,r).normalize(),t.userData.worldDistance=(new be.Vector3).subVectors(i,r),t.userData.originPosition=t.getWorldPosition(new be.Vector3),t.userData.meshCenter=i.clone(),t.userData.explodeCenter=r.clone()}}))}explodeModel(t,e){t&&(e=e||1,t.traverse((function(t){if(!t.isMesh||!t.userData.originPosition)return;const i=t.userData.worldDir.clone().multiplyScalar(t.userData.worldDistance.length()*e),r=(new be.Vector3).subVectors(t.userData.meshCenter,t.userData.originPosition),n=t.userData.explodeCenter,s=(new be.Vector3).copy(n).add(i).sub(r),o=t.parent?.worldToLocal(s.clone());o&&t.position.copy(o)})))}get fullscreen(){return this._fullscreen}set fullscreen(t){this.setFullscreen(t)}get spriteComputeParameter(){const t=this.camera,e=this.container,{top:i,bottom:r,zoom:n}=t,s=e.clientHeight;let o=1;return o=t.isOrthographicCamera?ct(1/(Math.abs(i-r)/(n*s)),3):ct(s*n/(2*Math.tan(t.fov*be.Math.DEG2RAD/2)),3),o}get scene(){return this.sceneManager.getScene()}get sceneHelpers(){return this.sceneManager.sceneHelpers}get camera(){return this.cameraControl.camera}get renderer(){return this.rendererManager.renderer}get effectRenderer(){return this.rendererManager.effectRenderer}get isMobileDevice(){return p}get size(){return this.getSize()}get viewBox(){const{width:t,height:e}=this.getSize();return new be.Box2(new be.Vector2(0,0),new be.Vector2(t,e))}}const{browserIsEdge:_m,browserIsIE:Am,browserIsIE10:Sm,browserIsIEorTrident:Tm,browserIsMac:Em,browserIsFirefox:Pm,isAndroid:Mm,isApple:Cm,isIOS:Lm,isIpad:Rm,isIphone:Om,isMiniProgram:Fm,isMobile:Nm,isQQ:Dm,isTouchable:Im,isWeiBo:Um,isWeiXin:Bm,isWeiXinWork:km,isWindowPlatform:jm,browserIsChrome:Vm}=O,zm={browserIsChrome:Vm,browserIsEdge:_m,browserIsIE:Am,browserIsIE10:Sm,browserIsIEorTrident:Tm,browserIsMac:Em,browserIsFirefox:Pm,isAndroid:Mm,isApple:Cm,isIOS:Lm,isIpad:Rm,isIphone:Om,isMiniProgram:Fm,isMobile:Nm,isQQ:Dm,isTouchable:Im,isWeiBo:Um,isWeiXin:Bm,isWeiXinWork:km,isWindowPlatform:jm};var Gm=Object.freeze({__proto__:null,Common:Rt,Env:zm,makeWorker:t=>{let e={},i=URL.createObjectURL(new Blob([`(${t.toString()})()`]));window.navigator&&window.navigator.msSaveOrOpenBlob&&(i=window.navigator.msSaveOrOpenBlob(i));const r=new Worker(i);return r.onmessage=({data:{result:t,jobId:i}})=>{e[i](t),delete e[i]},(...t)=>new Promise((i=>{const n=qo++;e[n]=i,r.postMessage({jobId:n,message:t})}))},isUncaffectedObject:qe,getObjectInteractable:function(t,e){return!(!t||!Q(e)||!t instanceof be.Object3D||!t.interact)&&t.interact[e]},getIntersects:function(t,e,i){const{x:r,y:n}=z(t,e)||{};if(void 0===r||void 0===n)return[];const s=new be.Raycaster,o=new be.Vector3;o.set(r,n,.5);const{camera:a,scene:l}=this;return s.setFromCamera(o,a),s.intersectObject(l,!0)},isInCameraVisibleRange:function(t,e){if(!t||!e)return!1;let i=t.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);return!(Math.abs(i.x)>1||Math.abs(i.y)>1||Math.abs(i.z)>1)},loadObjModel:Ke,getVerticesCount:function(t){var e=0;return t&&t.traverse((function(t){t.isMesh&&(e+=t.verticesCount())})),e},parseVector2:$e,parseVector3:ti,parseEuler:ei,parseQuaternion:ii,parseAngles:ri,parseColor:ni,parseSize:function(t){var e=t.width||1,i=t.height||1,r=t.size;return r?J(r)&&(r=[r,r]):r=[e,i],r},parseLength:function(t){if(Q(t)){const e=t.indexOf("px");return e>=0&&(t=t.substring(0,e)),Math.toInteger(t)}return t},parseLoopType:function(t){return J(t)?t:isBoolean(t)?t?be.LoopRepeat:be.Once:"pingpong"==t?be.LoopPingPong:"repeat"==t?be.LoopRepeat:be.LoopOnce},randomVector3:function(){if(1==arguments.length){var t=be.Math.randFloat(-range,range),e=be.Math.randFloat(-range,range),i=be.Math.randFloat(-range,range);return new be.Vector3(t,e,i)}if(3==arguments.length){var r=arguments[0],n=arguments[1],s=arguments[2];t=be.Math.randFloat(-r,r),e=be.Math.randFloat(-n,n),i=be.Math.randFloat(-s,s);return new be.Vector3(t,e,i)}},directionFromAlphaBeta:function(t,e,i){var r=t/180*Math.PI+Math.PI/2,n=-e/180*Math.PI+Math.PI/2,s=i||new be.Vector3,o=Math.sin(r);return s.x=o*Math.cos(n),s.y=-Math.cos(r),s.z=o*Math.sin(n),s},setDirectionalLight:function(t,e,i){if(t&&e&&t.castShadow){const e=t.shadow.camera;let r=i.radius||1e3;e.top=e.right=r,e.bottom=e.left=-r,e.near=.5,e.far=5*r}},getConsumeTime:function(t,e,i,r,n,s){if(n){const t=ti([e.x,e.y,e.z]),r=ti([i.x,i.y,i.z]);return t.distanceTo(r)/n*1e3}return void 0!==r?t?r/t.length:r:s},getMixerPlane:si,emptyObject:function(t,e){for(;t.children.length;)t.removeChild(t.lastChild)},isNeedCloneMaterials:function(t){let e=(t=t||{}).opacity,i=t.color,r=t.alwaysOnTop,n=t.wireframe,s=t.transparent;return!K(e)&&1!==e||(!K(s)||(!K(i)||(!!r||!!n)))},canPutInRenderList:oi,getRoot:ai,getIndexPath:li,getTargetStyle:function(t,e,i,r){const n={};if(!e||!t)return n;let s=i?Object.keys(i):null;for(const o in t){const a=t[o];if(o===e)n[o]=a;else if(o.substring(0,e.length)===e)if(s&&s.includes(o))n[i[o]]=a;else{const t=o.substring(e.length);if(t){n[yt(t)]=a}}else r&&(n[o]=a)}return n},equalTwoValue:function(t,e){if(!t||!e)return t===e;if(Q(t)&&Q(e))return t===e;if(J(t)&&J(e))return t===e;if(q(t)&&q(e)){for(const i in t)if(t[i]!==e[i])return!1;return!0}return t.isColor||e.isColor?ni(t).toHexString()===ni(e).toHexString():W(t)&&W(e)?Et(t,e):t.isVector2||e.isVector2?$e(t).equals($e(e)):t.isVector3||e.isVector3?ti(t).equals(ti(e)):void 0},getMaterialDefaultOption:function(t){if(!t)return{};const e=t.isMaterial?t:be[t]&&new be[t];if(!e||!e.isMaterial)return{};const i={},r=Object.getOwnPropertyNames(e).filter((t=>!["id","uuid","userData","name","type"].includes(t)));for(let t=0;t{for(const i in e)t.userData[i]=e[i]}))},geometryToBufferGeometry:di,roundUpPowerOf2:bo,isPowerOf2:function(t){return t>0&&0==(t&t-1)},isPositiveZero:function(t){return 0===t&&1/t>0},isNegativeZero:function(t){return 0===t&&1/t<0},areaPolygon:_o,caculateAreaOfTriangle:Ao,caculateVolumeOfTriangle:So,caculateGeometrySurfaceAreaAndVolume:function(t){let e=0,i=0,r=t.attributes.position.array;for(let t=0;t{setTimeout((()=>{const r=this.viewer.captureScreenshot({width:t,height:e});i(r)}),100)}))}}});class Hm extends THREE.AmbientLight{constructor(t){const e=pt({color:"#ffffff",intensity:1},t);super(ni(e.color),e.intensity),this.isThing=!0,this.name="AmbientLight",Mo.prototype._initOption.call(this,e)}setupStyle(){}toJSON(t){const e=super.toJSON(t),i=Mo.prototype.toJSON.call(this);return i.config={...e.object,...i.config},i.config.color=this.color.toHexString(),i.config.intensity=this.intensity,delete i.config.matrix,i}}class Xm extends THREE.DirectionalLight{constructor(t){const e=pt({color:"#ffffff",intensity:1,helper:!1,shadow:{bias:1e-5,mapSize:{width:512,height:512},camera:{near:.1,far:500}}},t);super(ni(e.color),e.intensity),this.isThing=!0,this.name="DirectionLight",Mo.prototype._initOption.call(this,e),this.updateShadow(this.option.shadow),this.helper=new THREE.DirectionalLightHelper(this,1),this.helper.visible=this.option.helper,this.setupCommonEvent()}setupStyle(){}setupCommonEvent(){Mo.prototype.setupCommonEvent.call(this),this.addEventListener("added",(()=>{this.scene&&this.scene.add(this.helper)}))}updateShadow(t){pt(this.option.shadow,t);const{mapSize:e,camera:i,bias:r}=this.option.shadow;this.shadow.mapSize.width=e.width,this.shadow.mapSize.height=e.height;for(const t in i)void 0!==this.shadow.camera[t]&&(this.shadow.camera[t]=i[t]);this.shadow.bias=r}toJSON(t){const e=super.toJSON(t),i=Mo.prototype.toJSON.call(this);return i.config={...e.object,...i.config},i.config.color=this.color.toHexString(),i.config.intensity=this.intensity,i.config.helper=this.helper.visible,i.config.shadow=this.option.shadow,delete i.config.matrix,i}}class Wm extends THREE.HemisphereLight{constructor(t){const e=pt({color:"#ffffff",groundColor:"#888888",intensity:1,helper:!1},t);super(ni(e.color),ni(e.groundColor),e.intensity),this.isThing=!0,this.name="HemisphereLight",Mo.prototype._initOption.call(this,e),this.helper=new THREE.HemisphereLightHelper(this,1),this.helper.visible=this.option.helper,this.setupCommonEvent()}setupStyle(){}setupCommonEvent(){Mo.prototype.setupCommonEvent.call(this),this.addEventListener("added",(()=>{this.scene&&this.scene.add(this.helper)}))}toJSON(t){const e=super.toJSON(t),i=Mo.prototype.toJSON.call(this);return i.config={...e.object,...i.config},i.config.color=this.color.toHexString(),i.config.groundColor=this.groundColor.toHexString(),i.config.intensity=this.intensity,i.config.helper=this.helper.visible,delete i.config.matrix,i}}class Ym extends THREE.SpotLight{constructor(t){const e=pt({color:"#ffffff",intensity:1,distance:0,decay:1,castShadow:!1,angle:Math.PI/3,penumbra:.2,helper:!1,shadow:{focus:1,mapSize:{width:1024,height:1024},camera:{near:.1,far:1e3,fov:30}}},t);super(ni(e.color),e.intensity,e.distance,e.angle,e.penumbra,e.decay),this.isThing=!0,this.name="SpotLight",Mo.prototype._initOption.call(this,e),this.updateShadow(this.option.shadow),this.helper=new THREE.SpotLightHelper(this,1),this.helper.visible=this.option.helper,this.setupCommonEvent()}setupStyle(){}setupCommonEvent(){Mo.prototype.setupCommonEvent.call(this),this.addEventListener("added",(()=>{this.scene&&this.scene.add(this.helper)}))}updateShadow(t){pt(this.option.shadow,t);const{mapSize:e,camera:i,focus:r}=this.option.shadow;this.shadow.mapSize.width=e.width,this.shadow.mapSize.height=e.height;for(const t in i)void 0!==this.shadow.camera[t]&&(this.shadow.camera[t]=i[t]);this.shadow.focus=r}toJSON(t){const e=super.toJSON(t),i=Mo.prototype.toJSON.call(this);return i.config={...e.object,...i.config},i.config.color=this.color.toHexString(),i.config.intensity=this.intensity,i.config.distance=this.distance,i.config.decay=this.decay,i.config.angle=this.angle,i.config.penumbra=this.penumbra,i.config.helper=this.helper.visible,i.config.shadow=this.option.shadow,delete i.config.matrix,i}}class Qm extends THREE.PointLight{constructor(t){const e=pt({color:"#ffffff",intensity:1,distance:0,decay:2,helper:!1,castShadow:!1,shadow:{mapSize:{width:512,height:512},camera:{near:.5,far:500}}},t);super(ni(e.color),e.intensity,e.distance,e.decay),this.isThing=!0,this.name="PointLight",Mo.prototype._initOption.call(this,e),this.updateShadow(this.option.shadow),this.helper=new THREE.PointLightHelper(this,1),this.helper.visible=this.option.helper,this.setupCommonEvent()}setupStyle(){}setupCommonEvent(){Mo.prototype.setupCommonEvent.call(this),this.addEventListener("added",(()=>{this.scene&&this.scene.add(this.helper)}))}updateShadow(t){pt(this.option.shadow,t);const{mapSize:e,camera:i,bias:r}=this.option.shadow;this.shadow.mapSize.width=e.width,this.shadow.mapSize.height=e.height;for(const t in i)void 0!==this.shadow.camera[t]&&(this.shadow.camera[t]=i[t]);this.shadow.bias=r}toJSON(t){const e=super.toJSON(t),i=Mo.prototype.toJSON.call(this);return i.config={...e.object,...i.config},i.config.color=this.color.toHexString(),i.config.intensity=this.intensity,i.config.distance=this.distance,i.config.decay=this.decay,i.config.helper=this.helper.visible,i.config.shadow=this.option.shadow,delete i.config.matrix,i}}const{Vector3:Jm,Matrix4:Zm}=be,qm=new Zm;class Km{constructor(t){t=t||{},this.vertices={near:[new Jm,new Jm,new Jm,new Jm],far:[new Jm,new Jm,new Jm,new Jm]},void 0!==t.projectionMatrix&&this.setFromProjectionMatrix(t.projectionMatrix,t.maxFar||1e4)}setFromProjectionMatrix(t,e){const i=0===t.elements[11];return qm.copy(t).invert(),this.vertices.near[0].set(1,1,-1),this.vertices.near[1].set(1,-1,-1),this.vertices.near[2].set(-1,-1,-1),this.vertices.near[3].set(-1,1,-1),this.vertices.near.forEach((function(t){t.applyMatrix4(qm)})),this.vertices.far[0].set(1,1,1),this.vertices.far[1].set(1,-1,1),this.vertices.far[2].set(-1,-1,1),this.vertices.far[3].set(-1,1,1),this.vertices.far.forEach((function(t){t.applyMatrix4(qm);const r=Math.abs(t.z);i?t.z*=Math.min(e/r,1):t.multiplyScalar(Math.min(e/r,1))})),this.vertices}split(t,e){for(;t.length>e.length;)e.push(new Km);e.length=t.length;for(let i=0;i 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\tfloat linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n\tvec2 cascade;\n\tfloat cascadeCenter;\n\tfloat closestEdge;\n\tfloat margin;\n\tfloat csmx;\n\tfloat csmy;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\n\t\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\t\t// NOTE: Depth gets larger away from the camera.\n\t\t\t// cascade.x is closer, cascade.y is further\n\t\t\tcascade = CSM_cascades[ i ];\n\t\t\tcascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n\t\t\tclosestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n\t\t\tmargin = 0.25 * pow( closestEdge, 2.0 );\n\t\t\tcsmx = cascade.x - margin / 2.0;\n\t\t\tcsmy = cascade.y + margin / 2.0;\n\t\t\tif( linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n\t\t\t\tfloat dist = min( linearDepth - csmx, csmy - linearDepth );\n\t\t\t\tfloat ratio = clamp( dist / margin, 0.0, 1.0 );\n\n\t\t\t\tvec3 prevColor = directLight.color;\n\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\tbool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n\t\t\t\tdirectLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n\t\t\t\tReflectedLight prevLight = reflectedLight;\n\t\t\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t\t\t\tbool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n\t\t\t\tfloat blendRatio = shouldBlend ? ratio : 1.0;\n\n\t\t\t\treflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n\t\t\t\treflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n\t\t\t\treflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n\t\t\t\treflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n\t\t\t}\n\t\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\t#else\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\n\t\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );\n\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if ( NUM_DIR_LIGHTS > NUM_DIR_LIGHT_SHADOWS)\n\t\t// compute the lights not casting shadows (if any)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = NUM_DIR_LIGHT_SHADOWS; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\n\t\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\n\t\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",lights_pars_begin:"\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n\t"+be.ShaderChunk.lights_pars_begin},{Vector2:tf,Vector3:ef,DirectionalLight:rf,MathUtils:nf,ShaderChunk:sf,Matrix4:of,Box3:af}=be,lf=new of,hf=new Km,cf=new ef,df=new af,uf=[],pf=[];class mf{constructor(t){t=t||{},this.camera=t.camera,this.parent=t.parent,this.cascades=t.cascades||3,this.maxFar=t.maxFar||1e5,this.mode=t.mode||"practical",this.shadowMapSize=t.shadowMapSize||2048,this.shadowBias=t.shadowBias||1e-6,this.lightDirection=t.lightDirection?ti(t.lightDirection):new ef(1,-1,1).normalize(),this.lightIntensity=t.lightIntensity||1,this.lightColor=t.lightColor||"#FFFFFF",this.lightNear=t.lightNear||1,this.lightFar=t.lightFar||2e3,this.lightMargin=t.lightMargin||200,this.customSplitsCallback=t.customSplitsCallback,this.fade=!1,this.mainFrustum=new Km,this.frustums=[],this.breaks=[],this.lights=[],this.shaders=new Map,this.enable=!0,this.createLights(),this.updateFrustums(),this.injectInclude()}createLights(){for(let t=0;ts.distanceTo(r[2])?n[2]:r[2];let a=s.distanceTo(o);if(this.fade){const t=this.camera,e=Math.max(t.far,this.maxFar),r=i.vertices.far[0].z/(e-t.near);a+=.25*Math.pow(r,2)*(e-t.near)}t.left=-a/2,t.right=a/2,t.top=a/2,t.bottom=-a/2,t.updateProjectionMatrix()}}getBreaks(){const t=this.camera,e=Math.min(t.far,this.maxFar);switch(this.breaks.length=0,this.mode){case"uniform":i(this.cascades,t.near,e,this.breaks);break;case"logarithmic":r(this.cascades,t.near,e,this.breaks);break;case"practical":!function(t,e,n,s,o){uf.length=0,pf.length=0,r(t,e,n,pf),i(t,e,n,uf);for(let e=1;ei;)this.remove(a.pop()),this.remove(l.pop()),this.remove(h.pop());for(;a.length{const e=Mf(t.type,t.name,t.config,t.children);n.add(e)})),n}class Cf{static addOutlines(t,e){if(!t)return[];const i=pt({visibleOnly:!0,meshOnly:!0,replaceOriginalObject:!1,color:"#000000",opacity:1,thresholdAngle:5},e),r=this.OUTLINE_MATERIAL.clone();if(r.color.copy(new THREE.Color(i.color||"#000000")),r.opacity=i.opacity,0===t.children.length&&(i.visibleOnly&&!t.visible||i.meshOnly&&!(t instanceof THREE.Mesh)))return[];const n=t,s=n.children.length;if(s>0)for(let t=s-1;t>=0;--t){const e=n.children[t];this.addOutlines(e,i).forEach((t=>t.applyMatrix4(n.matrixWorld)))}if(!n.geometry)return[];const o=(t,e)=>{const n=new THREE.EdgesGeometry(t,i.thresholdAngle);n.applyMatrix4(e);const s=new THREE.LineSegments(n,r);return s.name="line-edge",s.userData.hideInTree=!0,s.userData.isLocked=!0,s.userData.isOutline=!0,s.userData.skipStyle=!0,s.locked=!0,s.matrixAutoUpdate=!1,s.updateMatrix(),s},a=[];if(n instanceof THREE.InstancedMesh)for(let t=0;t=0;--i){const r=t.children[i];r.children.length>0&&this.updateOutlines(r,e),r.userData.isOutline&&(e.color&&r.material.color.copy(new THREE.Color(e.color)),void 0!==e.opacity&&(r.material.opacity=e.opacity))}}static removeOutlines(t){if(t&&Array.isArray(t.children))for(let e=t.children.length-1;e>=0;--e){const i=t.children[e];i.children.length>0&&this.removeOutlines(i),i.userData.isOutline&&t.remove(i)}}static hasOutline(t){let e=!1;for(let i=0;i0&&(e=this.hasOutline(r),e))break}return e}}Cf.OUTLINE_MATERIAL=new THREE.LineBasicMaterial({name:"outline",color:0,transparent:!0,opacity:.2}),be.Object3D.prototype.getInParentIndex=function(){var t=this.parent.children,e=-1;for(let i=0,r=t.length;ithis.getRefPosition(e.x,e.y,e.z,t)))},be.Object3D.prototype.add=function(t){if(arguments.length>1){for(let t=0;t{t.scene=e})))}t.dispatchEvent({type:"added"}),t.removeEventListener("removed",this._extendRemoved),t.addEventListener("removed",this._extendRemoved)}else{if(q(t)&&!K(t.type)){const{type:e,config:i,children:r,name:n}=t,s=Mf(e,n,i,r);return this.add(s)}console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t)}return this},be.Object3D.prototype._extendRemoved=function(t){var e=t.target;e&&e.resource&&(e.resource.removeObject(e),e.resource=null)},be.Object3D.prototype.removeProperty=function(t){this.properties&&(delete this.properties[t],this.dispatchEvent({type:ie,data:{key:t}}))},be.Object3D.prototype.setProperties=function(t,e){if(this.properties||(this.properties={},this.properties.uuid=this.uuid),t)if(1==arguments.length&&q(t))for(const e in t)this.properties[e]!==t[e]&&(this.properties[e]=t[e]);else{if(this.properties[t]===e)return;this.properties[t]=e}},be.Object3D.prototype.query=function(t){const e=t||{};let i,r,n,s,o;if(q(e)){const{properties:t,type:a,property:l,userData:h,name:c}=e;W(t)&&(n=new Me(t)),W(l)&&(i=new Me(l)),W(h)&&(s=new Me(h)),W(a)&&(r=new Me(a)),W(c)&&(o=new Me(c))}W(e)&&(propsFilter=new Me(e));let a=[];return this.traverse((t=>{let e=!1;e=(!r||r.validate({type:t.type}))&&(!o||o.validate({name:t.name}))&&(!i||i.validate(t))&&(!s||s.validate(t.userData))&&(!n||n.validate(t.properties)),e&&a.push(t)})),a},be.Object3D.prototype.traverseFilter=function(t,e){return this.query(e).forEach((function(e){t&&t(e)})),this},be.Object3D.prototype.traverseMaterial=function(t){return this.traverse((function(e){e.material&&(e.isMesh||e.isLine)&&(Array.isArray(e.material)?e.material.forEach(t):t(e.material))})),this},be.Object3D.prototype.traverseChild=function(t){for(var e=this.children,i=0,r=e.length;i=0;o--){var a=n[o];s=s.children[a]}i.push(s)}return i},be.Object3D.prototype.hasSprite=function(){var t=!1;return this.traverseBreakable((function(e){if(e.isSprite)return t=!0})),t},be.Object3D.prototype.hasTexture=function(t){var e=!1;return this.traverseBreakable((function(i){var r=i.material;for(var n in r){var s=r[n];if(s&&s.isTexture&&s==t)return e=!0}})),e},be.Object3D.prototype.hasMaterial=function(t){var e=!1;return this.traverseBreakable((function(i){if(i.material==t)return e=!0})),e},be.Object3D.prototype.identity=function(){this.matrix.identity(),this.matrix.decompose(this.position,this.quaternion,this.scale),this.updateMatrixWorld(!0)},be.Object3D.prototype.replace=function(t,e,i){if(e&&e.isObject3D)for(var r=0;rthis.children.length||e&&(this.children.splice(t,0,e),e.parent=this,e.dispatchEvent({type:"added"}))},be.Object3D.prototype.getFacesNumber=function(){var t=0;return this.traverse((function(e){if(e.isMesh){var i=e.geometry;i.isBufferGeometry?t+=i.index.count/3:i.isGeometry&&(t+=i.faces.length)}})),t},be.Object3D.prototype.getVerticesNumber=function(){var t=0;return this.traverse((function(e){if(e.isMesh){var i=e.geometry;i.isBufferGeometry?t+=i.index.count:i.isGeometry&&(t+=i.vertices.length)}})),t},be.Object3D.prototype.getNodes=function(){var t=[];return this.traverse((function(e){t.push(e)})),t},be.Object3D.prototype.getNode=function(t){var e;return this.traverseBreakable((function(i){if(i.id==t)return e=i,!0})),e},be.Object3D.prototype.setTransform=function(t){var e=new be.Vector3,i=new be.Vector3,r=new be.Quaternion;t.decompose(e,r,i),this.quaternion.copy(r),this.position.copy(e),this.scale.copy(i)},be.Object3D.prototype.keepSize=function(t,e,i){if(this.parent){var r=new be.Vector3;this.getWorldPosition(r);var n=t.sub(r).length();if(e.isVector2){var s=[i/e.x,i/e.y];this.scale.set(n/s[0],n/s[1],1)}}},be.Object3D.prototype._setWorldPosition=function(t,e){var i=t;this.parent&&(e&&this.parent.updateMatrixWorld(),i=this.parent.worldToLocal(t)),this.position.set(i.x,i.y,i.z)},be.Object3D.prototype._setWorldAngles=function(t){for(var e=this.parent;e;e=e.parent){var i=ii(e.rotation);i.invert(),t.premultiply(i)}var r=ei(t);this.rotation.copy(r)},be.Object3D.prototype._setWorldScale=function(t){for(var e=this.parent;e;e=e.parent){var i=new be.Vector3,r=new be.Quaternion,n=new be.Vector3;e.matrix.decompose(i,r,n),t.divide(n)}this.scale.copy(t)},be.Object3D.prototype.createMergeGeometries=function(){this.updateMatrixWorld();var t=new be.Geometry;return this.traverse((function(e){if(e.isMesh){var i=e.geometry;i.isBufferGeometry&&(i=(new be.Geometry).fromBufferGeometry(i)),t.merge(i,e.matrixWorld)}})),t},be.Object3D.prototype.getRefPosition=function(t,e,i){if(2==arguments.length)return this.getDefaultRefPositions(arguments[1])[arguments[0]];t=void 0!==t?t:.5,e=void 0!==e?e:1,i=void 0!==i?i:.5;var r=this.getBox3(),n=new be.Vector3;r.getSize(n);var s=new be.Vector3;r.getCenter(s),console.log(s);var o=new be.Vector3;return o.x=s.x+n.x*(t-.5),o.y=s.y+n.y*(e-.5),o.z=s.z+n.z*(i-.5),o},be.Object3D.prototype.updateBox=function(){if(this.boxHelper){this.remove(this.boxHelper);const e=this.getBox3();var t=new be.Matrix4;t.copy(this.matrixWorld).invert(),e.applyMatrix4(t),this.boxHelper.box=e,this.attach(this.boxHelper)}},be.Object3D.prototype.getBox3=function(t){return(new be.Box3).setFromObject(this)},be.Object3D.prototype.getCenter=function(){var t=this.getBox3(),e=new be.Vector3;return t.getCenter(e),e},be.Object3D.prototype.getSize=function(){var t=this.getBox3(),e=new be.Vector3;return t.getSize(e),e},be.Object3D.prototype.getAngles=function(){return ri(this.rotation)},be.Object3D.prototype.distanceTo=function(t){return t?(t instanceof be.Object3D&&t.position&&(t=t.position),t.distanceTo(this.position)):0},be.Object3D.prototype.indexOfParent=function(){return this.parent?this.parent.children.indexOf(this):-1},be.Object3D.prototype.indexOf=function(t){return t?this.children.indexOf(t):-1},be.Object3D.prototype.isBrotherOf=function(t){if(!t)return!1;let e=this.parent;return!!e&&-1!==e.children.indexOf(t)},be.Object3D.prototype.getChildNodesNumber=function(t){var e=0;return this.traverse((function(){e++})),e},be.Object3D.prototype.detach=function(t){return this.parent&&this.parent.updateMatrixWorld(),t.attach(this),this},be.Object3D.prototype.getChildrenNames=function(){var t=[];return this.traverse((function(e){e.name&&t.push(e.name)})),t},be.Object3D.prototype.getVisibleChildrenNumber=function(){var t=0;return this.traverse((function(e){e.visible&&t++})),t},be.Object3D.prototype.getInvisibleChildrenNumber=function(){var t=0;return this.traverse((function(e){e.visible||t++})),t},be.Object3D.prototype.getMeshes=function(){var t=[];return this.traverse((function(e){e.isMesh&&t.push(e)})),t},be.Object3D.prototype.getMaterials=function(){var t={};return this.traverse((function(e){e.material&&(Array.isArray(e.material)?e.material.forEach((function(e){t[e.uuid]=e})):t[e.material.uuid]=e.material)})),Object.keys(t).map((e=>t[e]))},be.Object3D.prototype.traverseBreakable=function(t){if(t(this))return this;for(var e=this.children,i=0,r=e.length;iLt(t))).lengtht.dispose())):i.dispose())}))},Object.defineProperty(be.Object3D.prototype,"locked",{get(){return this.layers.getChannel()==pe.IGNORE_RAYCAST},set(t){this.traverse((e=>{e.layers.set(t?pe.IGNORE_RAYCAST:0)}))}});var Lf=Object.freeze({__proto__:null,LabelTexture:Po}),Rf=Object.freeze({__proto__:null,MTLLoader:je,OBJLoader:ke,ThingLoader:$a,GLTFLoader:mi,FBXLoader:Us});function Of(t,e){return Math.sqrt(t*t+e*e)}const Ff=1e-8,Nf=1e-6;var Df=Object.freeze({__proto__:null,CoordinateTransformer:class{constructor(t){t=t||{};var e=this.originLocal1=t.originLocal1||{x:0,y:0},i=this.originLocal2=t.originLocal2||{x:0,y:0},r=this.originXY1=t.originXY1||{x:0,y:0},n=this.originXY2=t.originXY2||{x:0,y:0},s=e,o={x:Math.abs(e.x-i.x),y:Math.abs(e.y-i.y)},a=[{x:r.x,y:r.y},{x:n.x,y:r.y},{x:n.x,y:n.y},{x:r.x,y:n.y}];this._locOrigion=s,this._locRange=o,this._mapOrigion=a[0];var l=this._mapAxisX={x:a[1].x-a[0].x,y:a[1].y-a[0].y},h=this._mapAxisY={x:a[3].x-a[0].x,y:a[3].y-a[0].y},c=this._mapRange={x:this.getVectorLen(l),y:this.getVectorLen(h)};l.x/=c.x,l.y/=c.x,h.x/=c.y,h.y/=c.y}getVectorLen(t){return Math.sqrt(t.x*t.x+t.y*t.y)}transform(t){var e=this._locOrigion,i=this._locRange,r=this._mapRange,n=this._mapOrigion,s=this._mapAxisX,o=this._mapAxisY,a=(t.x-e.x)/i.x,l=(t.y-e.y)/i.y,h=a*r.x,c=l*r.y;return{x:n.x+s.x*h+o.x*c,y:n.y+s.y*h+o.y*c}}toXY(t,e){return this.transform({x:t,y:e})}},GeoCoordinateTransformer:class{constructor(t){t=t||{},this.unit=t.unit||1,this.originLngLat1=t.originLngLat1||{x:0,y:0},this.originLngLat2=t.originLngLat2||{x:0,y:0},this.originXY1=t.originXY1||{x:0,y:0},this.originXY2=t.originXY2||{x:0,y:0},this.translate={x:0,y:0},this.originXY1.x<0&&(this.originXY2.x<0?this.translate.x=Math.abs(this.originXY1.x-this.originXY2.x):this.translate.x=Math.abs(this.originXY1.x)),this.originXY1.y<0&&(this.originXY2.y<0?this.translate.y=Math.abs(this.originXY1.y-this.originXY2.y):this.translate.y=Math.abs(this.originXY1.y))}_getParam(){let t=this.originLngLat1.x,e=this.originLngLat1.y,i=this.originLngLat2.x,r=this.originLngLat2.y,n=this.originXY1.x,s=this.originXY1.y,o=this.originXY2.x,a=this.originXY2.y,l=this.translate.x,h=this.translate.y;return{lon1:t,lat1:e,lon2:i,lat2:r,x1:n+l,y1:s+h,x2:o+l,y2:a+h}}toLngLat(t,e){const{lon1:i,lat1:r,lon2:n,lat2:s,x1:o,y1:a,x2:l,y2:h}=this._getParam();let c=Math.cos(s*Math.PI/180),d=(n-i)*c||Ff,u=s-r||Ff,p=l-o||Nf,m=h-a||Nf,f=t-o||Nf,g=e-a||Nf,v=(f*f+g*g)*(d*d+u*u)/(p*p+m*m||Nf),y=(p*f+g*m)*Of(d,u)*Math.sqrt(v)/(Of(p,m)*Of(f,g)||Nf),w=Math.sqrt(y*y*u*u-(d*d+u*u)*(y*y-v*d*d)),x=(y*u+w)/(d*d+u*u||Ff),b=(y*u-w)/(d*d+u*u||Ff),_=(y-x*u)/(d||Ff)/c+i,A=x+r,S=0,T=0;return((t-o)*(h-a)-(e-a)*(l-o))*((_-i)*(s-r)-(A-r)*(n-i))<0?(S=_,T=A):(S=(y-b*u)/(d||Ff)/c+i,T=b+r),isNaN(S)||isNaN(T)?null:{x:S,y:T}}toXY(t,e){let{lon1:i,lat1:r,lon2:n,lat2:s,x1:o,y1:a,x2:l,y2:h}=this._getParam(),c=Math.cos(s*Math.PI/180),d=(n-i)*c,u=s-r||Ff,p=(t-i)*c||Ff,m=e-r||Ff,f=l-o||Nf,g=h-a||Nf,v=(p*p+m*m)*(f*f+g*g)/(d*d+u*u||Ff),y=(d*p+m*u)*Of(f,g)*Math.sqrt(v)/(Of(d,u)*Of(p,m)||Ff),w=Math.sqrt(Math.abs(y*y*g*g-(f*f+g*g)*(y*y-v*f*f))),x=(y*g+w)/(f*f+g*g||Ff),b=(y*g-w)/(f*f+g*g||Ff),_=(y-x*g)/(f||Ff)+o,A=x+a,S=0,T=0;if(((t-i)*(s-r)-(e-r)*(n-i))*((_-o)*(h-a)-(A-a)*(l-o))<0?(S=_,T=A):(S=(y-b*g)/(f||Ff)+o,T=b+a),isNaN(S)||isNaN(T))return null;let E=this.translate;return{x:S-E.x,y:T-E.y}}}});function If(t,e,i,r,n,s){t=t||24;let o=document.createElement("canvas");o.width=t,o.height=t;let a=o.getContext("2d");return a.fillStyle=e||"#ff0000",a.strokeStyle=s||"#ffffff",a.lineWidth=n||10,a.beginPath(),a.arc(t/2,t/2,t/2,0,2*Math.PI),a.closePath(),i&&a.fill(),r&&a.stroke(),o}const Uf=new Image;Uf.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoxQURGRTMxOEE3QjgxMUU2QTFDQkE2OEJCNDMzQzU4RiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoxQURGRTMxOUE3QjgxMUU2QTFDQkE2OEJCNDMzQzU4RiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjFBREZFMzE2QTdCODExRTZBMUNCQTY4QkI0MzNDNThGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjFBREZFMzE3QTdCODExRTZBMUNCQTY4QkI0MzNDNThGIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+WpeE1wAABsNJREFUeNrcW2tsFUUUnr33FmsxjaVAYwRN/GE0iqKJSoImYvCHilJFjQ/wnSj8UuMLBaOYUHwQ/YGgCdGIiRofMdSA9W2QIrW+Qn8gSjQCWgtCW0OR9nZ3/Gb37O3c7W7vztydu7dO8nX37s7OOfPNmZkzZ6YW55zFTdZzUS9i3DN2An6fj+tM4CzgFKAROI7eHwYOAr8CXcCPjLMOXLsLJciqRt3Ljx8oXaccM5tqgMuAW4ALoWjTGHkbgOlE0DX0rAfYCmwAPgTySSuYMVj5ZmALsBFYADRplNFE326ksprHAwFnAJ8A76PFZ7nmmQxmuWV6ZZ9ZrQTcCUW3AHMTrHgQc10ZQlaVEbACWA9MYuZTA8laUW5ByQyCnK3F38Ws8mk5MBlYUhkCnJDpz2ItICCNyvtpMXTohw5LGTdNAB/1+w4If4SlnTh04GwnTZcVGwNOA9YZHOzUwNjLpJNBAooFvghMYNWTaoG1AR2NWcB8CLikalp/BHNc3QxbQBZ4KkGl84SkyhO65eJagM4gOA+YUaa5tgMfkJ+/j55Nc9cLjF0JzC6jbKHb5UCrKQLuLkO5nzFrPBih3O9EzNPAVZD1LK6nanukMQlQHQOaymgdscS9NKZirZS3S1PWxcBUE2PAbKBeo1/+RgPUHgVpe9xvvG9V5QkdLzBBwDmaA9MSCnaopoPut3oyzzNBwAwNRT4G2tx74UrbMeTYlNf7vo3KUJU708QYcLJGK75dWEc4ARLCwmd2IK9chlo6ycQsMEVRiX+BbZEtXCNVnFPAiweI8WaebVTWsQqyp5ggYKIiAf3A3siVZV5ypvP0zAp1Y/dSWSoE1JkgwFYkQFRpOPSNRW8PS5pYkT58PuboMdbiPZExYEAxfx1Fb8KdqmGqWp7uo91XEWWaaEJX1YBIT9zBhdLxzNsD6C4a6Di1py01gU9ANpDPS2dTWSqpx8Q0qOOUzCvcO1KnsENmAZveOUXToMAVWs6XAQK6NBS5AWgsTH92yEgvkyBbh0fCZCpDVW6XiTGgQ0MRUYHnI8NqpUJv4luvDNUI0XYTFvCtpku7CFiq8Z34ZqHGdwega6cJAnqBjzR985X4u5pCV3HCW6vdb/RkbQb6TEWEXi0jWnM/rfnFZun0EAnT6F27m1dfznozESEvfYrCv8L1Is21+rnAa9SVdrjmOuK6iimzscxoUxsG061xM+vuCzzpElFeEhWdYyA6vExlg0Q3LP4Zpqh3i1Zt1YE1+Pud6aiwbwn3AX2setIvwGMhS+lE/QA57QMRC6tkP8B2nSXG/lGthBoBQZPjbJMbvU2fgHuB70fpZ9gC/PQQhG1OrfKOe05gja7ySR2QWARFfkph0BPTXVlb80oEWE4EODuEdUwzMGAx/9iAcXQD17nrx+j1gMFZYLSgXbi/FuAVMP1BYAHwl9sAdjgq2QUKXhis4S6AGcZtkPV1EgqbOCb3CscSVhxANYRnIOOtpJRVc4XteL0ESSx6xFHY+QmTK3aUH+YKfTwNC/AGTM5uAnYkaPa7gBuT1tPkUdkjUPh6oC+Byg9anqc3MJ4I8GeGq8suhbObmTg9biApjQEZp0T8Ljx9CYdFhLZaNHV8CZP+e8y3hsg+VwkLCPPGYgiH4quANzVMv8MqdQjTKqFbop7gcDjGDHWPpHtY1D5h9Jxz+5gOGIXQI/UyFBIb1QVcYeSf8hBK6Z9SxFL1VuDzmCWLE6g7Q7sZWUjhnZX2ICiZoSVvaow2xS+g+DsxTH838r4QSTgvv++bmQWskYslDVpy5VCBlhi+/hPIO1xEysjCa1xNg2ELpx8obh9VeREpfkNnZVedBBTPBr5VrBxjmbscebjFK6NTRQngVoGIdsvbIAn2oE68a5Xz/q8I8CvGvV3gVcHBD8+WFd5XKOUqQHANQcgSxx+ybiUZ+waepZjmTqe8nU6GbYcZTJX8AP/EgH+OxKlmAkS71RHEcZZaqniWiPDPfmTcts6w/dzBlGizx13/Ics24Cp2i5ok345Lk6pNJBylRdERAk+bgCwp3UAVz0juiTyG8yLPgLMaOE2tIOBR/PoT95uY92+0wwFSc9K9JZXtEBG9zDsOY6dFgAh8nAgMMrXTXPWoxn7Q9TqufwAOqlYbMHNewuLqmbepKqxud1oE9FLLTSA40uqglHk2Ojm2Dtch9xRI6T7uW4HfrYScftIhtS7wNykwiVpEtOIxREYmwp3hUvcZJD1y0nMrpNK+2Q9R3z9K64tDuuaf5CAoFDhAsIgE3yJqJGQlWNJM4Q9wjBUfk7KlGSBPlR+iyifiKv0nwACk4hF6ksLcSAAAAABJRU5ErkJggg==",mo.set({id:"thing-poi",type:"image",data:Uf});(new Image).src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo3NTIwNjM3MkIxOTIxMUVEQjFCREM4RURDMTY0QkZFQiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo3NTIwNjM3M0IxOTIxMUVEQjFCREM4RURDMTY0QkZFQiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjc1MjA2MzcwQjE5MjExRURCMUJEQzhFREMxNjRCRkVCIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjc1MjA2MzcxQjE5MjExRURCMUJEQzhFREMxNjRCRkVCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+TlHQ8gAAGNZJREFUeNrsXWuMZMV1/ur2+zE9r51970IA8yYYOwECxjGgSCFRIuH8iUikKJEtRZH4lfyK4j8hf538IEFRnARbNkgJMRhHjoUBY0wcdhcw3l0e+xpgPbsz+5jZefZrbt9bOXX73pnpnr5V5/buzN5upqC2e7r7vqrO+c53Tp2qElJKtJeHPgBemwWsBMJLcJhY8z74G4zjOh2LDucJO7cM+Y3uHKLDsbpz6c4vQo4NuyYM7RTlujLkXjTFdSB+cgfkb5ZaP09qjhF0IRn1QlslBkV2/KyjmlgRT7NVeqWINVWjulZo10v/QLGl+T2PApo+tBgn2ur+3scCGQ0BIlOMrRJTFBB+DRWBJANItoxAn2p/uAC0EgjpI4Vc59oIjVsnDO5imKvUykE6i2O7Gxfm3kVx+biurexwrGS6mDC4ibouEwZMXu8aijY2F0EAZMuh0geTVSGQITfere8sGQ9oEoawDhEhgiMNDSsM52vvMNnhep2eby2mhp1Hd88mARctbrxj8umSTChx6QTWusubbkhoJFRG0IowYJMRBS8MlQRTm8NQQmiQwRSYCutAEXIuyXLYVee7nI7lCkBwmeS6y5kiWNIAczrN5wqYbDNdYSgVdp/ScP9gwH4YfHPuxyQ4Jkq+XmjVfzaHykcRAMf7vVjDDMIkWDKFw6RlnTpHMIRNGLRQd8+C0Vk61BKa+2+/P52AywgK1Xot9W2D26lRBKApBBJpuoTbEea75amcBtYhjmAQSx3RkprOkh2CKbpYvDRwDNlBSXQmoJPAhCuF8Hlag2EmuhKABl0izYwfmKVWGDpIpy2CyaJNjQeGnRURTIhukCjsvrjei1nAle2vR+maZGSNlWRbBLIeMYTB7YsiEFID8dxIhIzAJUx2NKqXLRj3oBMmEwk1EepA+0UI/EfiAELb6A0fZhJ+jInvA0tGPEAaYL2T24UQaOUKoon06e4vzA00dZ5OeKTmOcM7V/1bi6rP0RGgeUvLdLmChwLCAJU6tt/teLdgaGknvxoGbZKMewjrYGkQKsFEDo6X0BktFCLbkY5nBoI6FdsjgkGEEAx3qhPDFgY30RTxEkyYRoTG55JawfQ8whBFGLwkk0lq/czytV9uBgLANwGKbBSwdryQmw0kNSROGiJyUbwJU+BFagiZ0JgZU4ROhEQAdWRXF23Ut4PwkXi5G2+rGw4QlDrdSI5eE544cDpAZ38FMwAkIxBAUwpWFM/EFNgCI9TLiXvogkmd78ei78voMoGnWwSAr/kKdkqeAHA0gusZCIMrBA25lIYQLyd2YBqo4UQZdaiku8ewduncJsLz+Tmu3xXmAEGpeWZAdAgRh7F3aAIkHOKkY9kC3Fi5mXyGaaLuXjlEU2jQiGvzV59d2f4KLiN973IQILgVBT/DWDt2yIVsoWHHHDtmgmNOGLWbkciwqJ5J8EzEUTCQZvW7IN5fu5wOvFwBCFBAhYhTMCWQ6aJyIkKn6WA0ikZyw80yArR2QgjTOAh3wAjrmP/cSiwmqjd0BUjg2sdYpLqdfu9o7TlHw0zzDDrZcsnwx6MM8AhD0IrrtupcUO6oYWevRPg+f/VytfdKIAB8O6TckPQ6UxAlWGOCWJMwcAQKzHNGiWvAgC4cwqgbal7vfirPayaS7d8gEri2zFPduRIdlIyH5Pj5XPsqI2ieiZRK8IeFo0bxOCggNCHh5id1+rcSqXc20AS0o0DWC0t2imULhnabcuJEBE03xRB0giE1nWeC+7D8ApNS8RROTdi7gCs0cedKIoD0SckebaNzsmc4kUUOcTKlZJl8dRjMgzCct5MgmYaIpTYKaNF3Narlrvy1DeQAQVnyvYIcmnmE6ztWMCGTkz7FSdCExmc3CYTQBJpMuYKmaKBJ4ztzCDUCO9uV9ovNEQAVEVQ3WGRpoin1CRpPgutVmGIDugYyXUNnWjgdyolArn6X8Fn/YtcRm00QAFUWPBQQhAJBZqow+MAmCOZM70aHaBo3lGxy4yTzM5MAcVLlZWj00IrM/DfRDWx/7Gn699qVBFKTxuhCvyatMwlRWDjalJUURRhMJkpn/nTzGVqDPmX6bL7rXtkEL6DVJZTkFUgyBaINBaSGfXPDs6bcfe5xUSJ+OiQwpa9xB4jCUUON+F3EBkzZv5JeQPsZlKsyGCm8yU9/CjcpnEQSTtAobLCJe9/duKToKJwJz+7Ly9D+TeYAawNDyl1Ri5I42tEzyWxQbiqZjpHLLjTUlNtoik1IRI9frH6uBOA8NmjBjo0UAHXDU/Qgw9ANFUdBBS57DyN2puFik43mBKUkQ5BMbuzqbxM+qZ677N7YZA4QlDkfvgbRnFPAI4ScySJhPj93TD3KAlWmXAFhQB4TaoS7iCrmP3VFtH8TxgLCzjRJdWTdsCVnejdnKjfHjTPZYm6WMRCeAq5j9mBE/9bfW8K3+5c2EKU31AQEZcaHsaGW6comeygYWqoTGNOMojAhEAbPJMqaCGGCyJlf0Jx3cfaK2f6rZAKC5phoQQFpYN06dgwG2w/LyzcRPE4alymPLyxtTZc5vP7ZlO2fpdfpK8rIrhICBCig4Gx4HQqY2Ds0TJ4zkqgTBlOyB2fdgCirgZg8gLXMX+DMFWX+l7FCyJUoKhj0S7qJbR2Wn+z65kOZuUS02TeSGZLlDuWapoeHeQPNz5Oe3ZdeHAX9ggDwA0MqQjjixQU4kTyTPw6m2RARNZCbz2+K/nHmAKx/r8jfaWzSQp2bwQHWPvrHVFtRgDMhhMPMOWsERF1HIGq8gTsVLpyzqP6Y9gM/uHoCcOVNQFDO08Mqt2asY1zApOUyQtxAhDB9fgSOP9so+gpeYZxBDfqMb0jLi6uPAAEXOEV1hx/lMrN/zqiczs5yp4x3I1g6QmgSoPWDYUlf8zdN+zebA6yiQHO4eOe6hYxMASABfioWNNE8k1cQxgW4qeKceESrYAh/osdJbPIi3VdDANQDnvRzB13WJErT6JkpNBsmCBxvgssduBM8O8c+1KSac/T3+Q1t9RhwgKBM+V5BEwU4cfmwoAuX9QtN9I8z+YPLG6KalyDsK3B8Q1tcxAcBgsc+RnXvuqgAZ4g1TLslI0LXzdJ2HNdRhxLhQ9/qr7SvEJNXoyM2mwSuLWc92AN2I1jahDP3nzs2IGDOO9BpKDcp1eTCmlPclf1/f8Ntf8xMQHCV9+nx92LtCqSC0XicdX8B/vxEEUHITEgUbTWzlD/gs/HaHzMTsIoC0kOBPQBvadNQ39u0yHI7u+fCu8kTMZmGcC0Ua7Tf3fCWjoQAm2MCgrjAUbq5fSuLTJhCrlEJYJSEExmhMzmCo883SNFnZ+i7iU1RtZgigCpqkGjKJ4Q2u5O7m1OvzznQzdwxjQlwhqDb/X7gCHdV737kAGuv9gtqjv3e/XTjDuqibWETRUyzfcD0NsK4iZ53KL//tF+varnaJmAVBZpweK3HBXSLO5g2iZARRS/KXgGcxS50i1e1/updxGBrvjggQMAF3qH6K8CaMQIGhLFIWjf5foB5+5uoGcCrtv+jOGh/nBCgiQLN1LHrvEUPubN3OUvB6IZluyV7uhXDw+MN6ls14vc2YrIxZ1wQILjqW1RvaEGBKKHVKNPOucydm2nMy0BSUb9xX9gRXwG4euUTDxoFCUGw+KFphA4Muxwl0idgXt07qv1vneXzVly0P44CoBrmIP37mZV8AVNHmFYk46RwSwOfMPnUutU/Vs+RofcqF+Kjq9KyojcEAD5Eqka6CVizBGrYuvymCB2gX5+Hu0gFwF8MW3Tw+5sp8W/GSfvjKgCqgQ5QvdGHTGlMvAwjYzAIA2esoJtlZtcLRIbeH6fX8bg1dpy8gLUlgMqbV1DAtGuoThu7XQ5W5zGA3UbBfh5vApsU9etxBAjiAj+jBr/JT5aQxs2VTAM3HM/BtE0NZ+3A9d9lqH5I9UQcGzquAqDKSY8PSNzixQU4mzBwt4OVhsCOCSU4Q9FrP5UkzFfb9sd4LECHAj+lJrwZ7ZtScFcFBUNrOUvRcPnF+vmEyvZ/EFftjzMHCMoJasATdB93oLlDSWe4N439m9xFDopw1gBudS2FP+b3Wixsv+g9BAhQ4DW6jzu8fAHZNqPItMwMJ1/PBPNRpnfJNtsvcSQ22h+DuYHdo4AiURJ3elvUcGP+nL0Iw9YCCDMBMASNVn8bvHs1bn5/r5mAoJlfoXonmptXS7ZvHxb7N+11GObySWYAqblI5rtxtv29YgKConLmVQLpXd5iyZ2jbZ1dQxOz5y4HG4Yg64Ul2ML1lVi1YA+FgsO64WX697NAyAZVOnvM3UCas7mzKUeguVz+z33fP14t2KMmICiqQd+jB/k8Om2VwknZhqbzOChiSjRp8n413e1HsbP9PeoFtHsEL1FtokAQF9AljnAgX0cETWsaryeIOfpMDfd+0CPI2jMmICjv+fXXqKGrkUfrTL/Rb9PWWYhamb9aEfUlxDDm3w8mIHiMH1K9a4ULdDMxU7eLKDoEmWAIAokV7T9Er0d7SaN6DQFUOYJmPv3dQJtHoGPupkxiDoEMJ4/qkwbVH8Td7+8HAVAN/N9UP9fiEXB3JI+6vxDPVGTp7wOeeRIxbbU+IIHtXEAFWu4LRQGey8abN6jP+BX+hpkvxtL2d4UA8eUAaz2CF6kz7kHYSGGnLeC4q4OYJn6sZ/4/84US/SEA8UeAAAV+Tvf4BcDbnSS80wHOZsz8HUhbc/2UMH6v12x/ryNA0KXP07/3AX7WEBf2w9CAsyxcq7AU6P0b9P4oerQk0dvliOd6AV9c2UwxyqaPYTt8hgV8Wo+x/HWPv9vF4rcxjwP0hgkI7vS7VO/3Vtto36ZOQD+PIMqYwPrvClRfp3q4lzWol01AUJQ3cIA65kt0v2Wtu2baqEmwj1Hz+9SKJv/Vq7Y/KBZ6v0i/I9SE0qT/TJa/7KqC6dW/gyrXfL72fVhtP5f0tP+AL3zoPwToHRMQFDW1/CDVh+iel9p4erStXc2TQpvaL/FcL/r9/YgAgcj+J5rb16datB1t2ou2z9p/hw7I0fp5oP3v9EPDJdE/RXWImn3zsLdrqW5nzzB+YEohbwqMMjX/0TE1Lc5F9L8AKDh+luoX0MwXcEOnfetWAdHvUaRy/VSi59s9R/1kf5uAoKhUrP/1XTQ9qRMdIL+9tpK/pG9ivt0Ptr9fBUB1zHd8F011WMKfW5jwd+JqvgbvgyraXrHmt6ufFwEv5v9uPzVYP8QB2ssvqL5BnffbnkdgWgVMlza+yguUojTo9du97vf3qxvYjgLfoo572H8+VztJpH30sBMpBAbo/Q/p/Tvos9JvJiAoiqS97nWcbIN00cEUiBCz0Px9ymf+3+w37e9nAVAd9bRH2oQfHVxL/ESIzy87RgCV7f8J1UP92FCWkQP0blUd9mMfvsM7WnTwDFa/T3qrlUlPmPqy9BcHoC5z0yvPoLKEnraW8VvEAhSMO5K+lwnfyWvnBM1jhHC8umL7ZRrfp+MOrlxC+RdODxLkmGwbt3GYnwKy4yew6zt/R+8zEE4D9tjeA2f/5K9/LLO535MCi8nFpcTgxMnMwCfvZXKz51LpymJS9bRdKDUqw7vsxWtvry/uv6m+XMw5ooEEnbNaOvTTp8f+59+km0pD2HVM/fHfoHbdjfR+CwHiJQCk3cnyPEqHX4ebLdAHhN0zF5C74a6nal985MHdb/xgdMc7LxcyU+Mp1GtwXLf5gPR/lgR9UAjsymRR33W9PX33I0vn7vldZ1mK50rf/NsDuTMnkCgUIaplXHz0ce9aAv0sAL1K+yzC9lyBzEAOlfIiGiQIe5/7+tDAkVeL2Y/fG2o4DuxkEoI62hL+ylOu5b8nb9F1kD79QWrvJx8Mj7z3hixnB480fnlcLiYzKCTSSOWEd42tQFBcbZxo7r5aq1bQsBsobdv+RyOl0j/ZHx0dtBNJWOkMLOrkeq2KRoVQYLlOguNC0HfJbA7pXA7JXBEuoUP22FuilEw/sXzdTYsXJieeqZSXMJBOelmgPcmPZL8jgOp/YaFep84ldC8ODj06MrbrG8vL1ZxIZ5EgLa8sLqA6OwO7VkOjOAAMjQApIvrlMhJzM0hNN5AuDaIwPOoJQr1hb0ul0t/Yvntf5fyZ0y9UKxW4Un4KEKAHOYA3N8u2sVyvIz0wdMPo2K4n6e+cJcgtkA7mps/DXpyDs/d6DD/y+7j+vnuxa89OJFIpXFooY/zDU5h8+RXUDvwI9tRpFLftRn6gSOd0cul09snRsZ1HZybGT7lELoXodwHoUQoQyMLwtu1P0OseQT0lhMSl8+fQqFeQ/I0/wP1/+lV86Y792JNykJJNf84lNJjdvhtv3/LreOkzD2Pxe/+I8sxxOnYP8oUSGo3Gnnxp+IlqvvgYAYCMuk3RFgfYND9XIpcv3J3NF7/sNMiPI8I3T56Aa1dh3fwo7n3kK7g/n4F7cgIfW0T6vO0biAC6AglXrUubQPKWW/Hi5F+h9uY/oDx7HGkijMlkSnkVXy4Nj95Nbw72EQD0kQlQhJ7IW2Fg8DHqoHSCiJ1NfMCuzkMO3YHSzgcxvDCHY0ds6viGR+ZdaTfjRRYRRJmg4y2krAz2ZTN4f+R3kK9PobwwixFCB7fhpLO5/GOZbO5g1d1yA+NnAkgASFML2XxBpYTBSpA3UFmClcrBTt8IZ2YS48cW1Rf0WwmnUUMiQSiRSBDZUyHAFJKJHEmFoE6n31VnkcjthVs+RTxg2UOBhJt8mARLJZuUt9zAGJZUOr2bOmqfS7BO6gy7sUwCMABRn8bSuRomyiVYyTR5CnWUBku4/bZbURoawNmJCXz44Qk41PmZdIq8hWkkymcJGSqQ1PF2vYYMmQLY2Eeyo/Y6PrlFAuNoBixrxLKsksJ3Im7eZwTsSNQ/hrRzaDgFKG6gEKJaLeLwpXFCA9vbwV6Sa7hcrQNZ6mi3glRjnsDAhjIlTsPxXEwilSU6eGTLDYypG0CcP2sp404wD9WxqtPgwHLn6bWCtKijtlxFmlw/e2EaVVsZc9fjAvl81vMKrAZBPSHIsmxuU2B5aQEu1HmFOrcQ2a1IYHwjgTUhElDVIttuiSBs6zQ7kzpaTSBMUEcLS7mIbjMcTB2boq523DqSdIwaJrCaAuX5/IonNBFAvaLWk+lyn4K0cHLn5CXqoAXLEiVF2qykRR1pISlTHstPLidRTJZgV+oYLY5gNDOkAAA2kcFztWks2BYyuRxqdgWWI4g/AA3yGJKpjEcqSWgWqCUv9T0CVJXCNHos95ludmm5MSldd4Js9W0pxdqJ8IEY/jBKSNgJZOw0BlJDBPkuUnNJjCQHkJdZzJF5qJOdH8oNk9u4jJqj+IINO1PHJTEHcv08NEhYiYmaFJMKUFynx3qa7teRTAH45+uB2f3oqZCnGqI9sbBc/lat9urQwNBtaoQvXxjA3MIl7KaOLlUG4CTIlpNg59JEBi0X5xszZPdTyMoctidHSQjqXi3KvBcnOJ08TUKUQC5XaCqGi1efutYt77+5GXfoNTf5s0WmANyZ7004GxkAnlxcfHZ0x54/d10nPVAcRLmyiJnsJeyv7Eaj3oCg32RLGRIYZfvzyLgp5EjjBbmANSeNhRlyBZ0sLg5OYzYxj+GBMS+iSMhCTkL92c+la7h9oN9JYI+WOpG0anXpkL1cfz6VzvyhInojw9txYWYSx4fGce/0rcjXMsiPkYRnpRcQShLLz8gMCUAC5ekqhshMTAxM48PCCfIICyiVhokckndgJZ5fXJw9VLadfmqy/hIAhXOu48i52Qtf27HrmgcIBfbk80WMuTtxYf483hg7jAdnb8NNp4cxWChAZCwP6gXxA7vs4Ey9hveHJvB28RhSuQy2j+7xvARCgLO1avlr5YU5aX0qEkJ6tGRzeTUWgMWFuVOFQunx0tDoM6S9uSJ9pryC6fkLeCF5CIer4/jV6m7srQ0TEKQwZ1VwKjWDw0NnMJ1ewlB+mJBjW+A/VaV0H5+5MHlKkaKEGhjaEoCYOgKOiyHquCUifhfPT76QTme+mi+Wnmo4jVIun8fe7DVYKi9gIruAkwNHiRa7zRXela9Pdr5I5HB/8VpkMjk4jor+YYG++oupqbMvVCoVjI7tQiqV3hKA2AqAVPF/G2M79uD81AQmz37yzK7d+88US8Nfd1z38yoYUiqNoDQwrEwFGm7D4wEqYJQkAVDBIzWiSKZDBX/ecZ3GX56bmnh9fu4StlHnuyQpamBoSwBiSwEklhaXlL+OodEduHjuLMZPHnt9ZNv2h4ZHxr6SSKb/zJX120Qzs8/3c9WEAUkewrI/lUC8Tz7ev1fLi/9KKLJQq1axbftu+lkCs5em+25uWF8JQKk0gAceuM+L9aeoptP3YubiOdj28kImm/n7oeHRfyFmf48rcR/ZdbU59U7/0HNCiBOWEP/nOI2DiwuzS0uL87hm306C/Z0ef6hWyli2be8a/VSElH0333GrRCjWVhN8usv/CzAAoRgqYLYT1kEAAAAASUVORK5CYII=",mo.set({id:"thing-camera",type:"image",data:Uf}),mo.set({id:"thing-point",type:"image",data:If(100,"#ffffff",!0)}),mo.set({id:"thing-double-point",type:"image",data:function(t,e,i,r){let n=document.createElement("canvas");n.width=e,n.height=e;let s=n.getContext("2d");const o=If(t,i||"#ffffff",!0),a=If(e,r||"rgba(255,255,255,.5)",!0),l=(e-t)/2;return s.drawImage(a,0,0),s.drawImage(o,l,l),n}(50,100)}),mo.set({id:"thing-point-outline",type:"image",data:If(100,"#ffffff",!1,!0,10)}),mo.set({id:"thing-star",type:"image",data:function(t,e){t=t||100;let i=document.createElement("canvas");i.width=t,i.height=t;let r=i.getContext("2d");r.lineWidth=5,r.beginPath();var n=4*Math.PI/5,s=50*Math.sin(0)+50,o=50*Math.cos(0)+50;r.moveTo(o,s);for(var a=0;a<5;a++){var l=n*a;s=50*Math.sin(l)+50,o=50*Math.cos(l)+50,r.lineTo(o,s)}return r.closePath(),r.fillStyle=e||"#FFFFFF",r.fill(),i}(100,"#ffffff")}),mo.set({id:"thing-rect",type:"image",data:function(t,e){t=t||24;let i=document.createElement("canvas");i.width=t,i.height=t;let r=i.getContext("2d");return r.shadowBlur=2,r.shadowColor="rgba(0,0,0,0.8)",r.fillStyle=e||"#ff0000",r.beginPath(),r.fillRect(0,0,t,t),r.closePath(),r.fill(),i}(100,"#ffffff")}),mo.set({id:"thing-triangle",type:"image",data:function(t,e){t=t||100;let i=document.createElement("canvas");i.width=t,i.height=t;let r=i.getContext("2d");r.beginPath();var n=t*Math.sin(Math.PI/3);return r.moveTo(t/2,0),r.lineTo(0,n),r.lineTo(t,n),r.fillStyle=e||"#ffffff",r.fill(),i}(100,"#ffffff")});let Bf="\n\t\tattribute vec3\tcustomColor;\n\t\tattribute float customOpacity;\n\t\tattribute float customSize;\n\t\tattribute float customAngle;\n\t\tattribute float customVisible;\n\t\tvarying vec4\tvColor;\n\t\tvarying float vAngle;\n\t\tvoid main(){\n\t\t\t\tif(customVisible>0.5) {\n\t\t\t\t\t\tvColor = vec4( customColor, customOpacity ); \n\t\t\t\t}else{\n\t\t\t\t\t\tvColor = vec4(0.0, 0.0, 0.0, 0.0);\n\t\t\t\t}\n\t\t\t\tvAngle = customAngle;\n\t\t\t\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\tgl_PointSize = customSize * ( 300.0 / length( mvPosition.xyz ));\n\t\t\t\tgl_Position = projectionMatrix * mvPosition;\n\t\t}\n",kf="\n\t\tuniform sampler2D image;\n\t\tvarying vec4 vColor;\n\t\tvarying float vAngle;\n\n\t\tvoid main(){\n\t\t\t\tgl_FragColor = vColor;\n\t\t\t\tfloat c = cos(vAngle);\n\t\t\t\tfloat s = sin(vAngle);\n\t\t\t\tvec2 rotatedUV = vec2(c * (gl_PointCoord.x - 0.5) + s * (gl_PointCoord.y - 0.5) + 0.5, c * (gl_PointCoord.y - 0.5) - s * (gl_PointCoord.x - 0.5) + 0.5);\n\t\t\t\tvec4 rotatedTexture = texture2D( image,\trotatedUV );\n\t\t\t\tgl_FragColor = gl_FragColor * rotatedTexture;\n\t\t}\n";function jf(t,e){this.times=t||[],this.values=e||[]}function Vf(){this.position=new THREE.Vector3,this.velocity=new THREE.Vector3,this.acceleration=new THREE.Vector3,this.angle=0,this.angleVelocity=0,this.angleAcceleration=0,this.size=16,this.color=new THREE.Color,this.opacity=1,this.age=0,this.alive=0}jf.prototype.lerp=function(t){for(var e=0,i=this.times.length;ethis.times[e];)e++;if(0==e)return this.values[0];if(e==i)return this.values[i-1];var r=(t-this.times[e-1])/(this.times[e]-this.times[e-1]);return this.values[0]instanceof THREE.Vector3?this.values[e-1].clone().lerp(this.values[e],r):this.values[e-1]+r*(this.values[e]-this.values[e-1])},Vf.prototype.update=function(t){if(this.position.add(this.velocity.clone().multiplyScalar(t)),this.velocity.add(this.acceleration.clone().multiplyScalar(t)),this.angle+=.01745329251*this.angleVelocity*t,this.angleVelocity+=.01745329251*this.angleAcceleration*t,this.age+=t,this.sizeTween.times.length>0&&(this.size=this.sizeTween.lerp(this.age)),this.colorTween.times.length>0){var e=this.colorTween.lerp(this.age);this.color=(new THREE.Color).setRGB(e.x,e.y,e.z)}this.opacityTween.times.length>0&&(this.opacity=this.opacityTween.lerp(this.age))};let zf=Object.freeze({CUBE:1,SPHERE:2});function Gf(t){this.parent=t,this.positionStyle=zf.CUBE,this.positionBase=new THREE.Vector3,this.positionSpread=new THREE.Vector3,this.positionRadius=0,this.velocityStyle=zf.CUBE,this.velocityBase=new THREE.Vector3,this.velocitySpread=new THREE.Vector3,this.speedBase=0,this.speedSpread=0,this.accelerationBase=new THREE.Vector3,this.accelerationSpread=new THREE.Vector3,this.angleBase=0,this.angleSpread=0,this.angleVelocityBase=0,this.angleVelocitySpread=0,this.angleAccelerationBase=0,this.angleAccelerationSpread=0,this.sizeBase=0,this.sizeSpread=0,this.sizeTween=new jf,this.colorBase=new THREE.Vector3(0,1,.5),this.colorSpread=new THREE.Vector3(0,0,0),this.colorTween=new jf,this.opacityBase=1,this.opacitySpread=0,this.opacityTween=new jf,this.blendStyle=THREE.NormalBlending,this.particleArray=[],this.particlesPerSecond=100,this.particleDeathAge=1,this.emitterAge=0,this.emitterAlive=!0,this.emitterDeathAge=60,this.particleCount=this.particlesPerSecond*Math.min(this.particleDeathAge,this.emitterDeathAge),this.particleGeometry=new THREE.BufferGeometry,this.particleTexture=null,this.particleMaterial=new THREE.ShaderMaterial({uniforms:{image:{type:"t",value:this.particleTexture}},vertexShader:Bf,fragmentShader:kf,blending:THREE.NormalBlending,side:THREE.DoubleSide,transparent:!0,opacity:1}),this.particleMesh=new THREE.Mesh}Gf.prototype.setValues=function(t){if(void 0!==t){for(var e in this.sizeTween=new jf,this.colorTween=new jf,this.opacityTween=new jf,t)this[e]=t[e];Vf.prototype.sizeTween=this.sizeTween,Vf.prototype.colorTween=this.colorTween,Vf.prototype.opacityTween=this.opacityTween,this.particleArray=[],this.emitterAge=0,this.emitterAlive=!0,this.particleCount=this.particlesPerSecond*Math.min(this.particleDeathAge,this.emitterDeathAge),this.particleGeometry=new ye,this.particleMaterial=new THREE.ShaderMaterial({uniforms:{image:{type:"t",value:this.particleTexture}},vertexShader:Bf,fragmentShader:kf,blending:THREE.NormalBlending,depthWrite:!0,depthTest:!1,side:THREE.DoubleSide,transparent:!0,opacity:1}),this.particleMesh=new THREE.Points}},Gf.prototype.randomValue=function(t,e){return t+e*(Math.random()-.5)},Gf.prototype.randomVector3=function(t,e){var i=new THREE.Vector3(Math.random()-.5,Math.random()-.5,Math.random()-.5);return(new THREE.Vector3).addVectors(t,(new THREE.Vector3).multiplyVectors(e,i))},Gf.prototype.createParticle=function(){var t=new Vf;if(this.positionStyle==zf.CUBE&&(t.position=this.randomVector3(this.positionBase,this.positionSpread)),this.positionStyle==zf.SPHERE){var e=2*Math.random()-1,i=6.2832*Math.random(),r=Math.sqrt(1-e*e),n=new THREE.Vector3(r*Math.cos(i),r*Math.sin(i),e);t.position=(new THREE.Vector3).addVectors(this.positionBase,n.multiplyScalar(this.positionRadius))}if(this.velocityStyle==zf.CUBE&&(t.velocity=this.randomVector3(this.velocityBase,this.velocitySpread)),this.velocityStyle==zf.SPHERE){var s=(new THREE.Vector3).subVectors(t.position,this.positionBase),o=this.randomValue(this.speedBase,this.speedSpread);t.velocity=s.normalize().multiplyScalar(o)}t.acceleration=this.randomVector3(this.accelerationBase,this.accelerationSpread),t.angle=this.randomValue(this.angleBase,this.angleSpread),t.angleVelocity=this.randomValue(this.angleVelocityBase,this.angleVelocitySpread),t.angleAcceleration=this.randomValue(this.angleAccelerationBase,this.angleAccelerationSpread),t.size=this.randomValue(this.sizeBase,this.sizeSpread);var a=this.randomVector3(this.colorBase,this.colorSpread);return t.color=(new THREE.Color).setHSL(a.x,a.y,a.z),t.opacity=this.randomValue(this.opacityBase,this.opacitySpread),t.age=0,t.alive=0,t},Gf.prototype.initialize=function(){let t=[],e=[],i=[],r=[],n=[];for(var s=0;sthis.particleDeathAge&&(this.particleArray[a].alive=0,e.push(a)),i.push(this.particleArray[a].alive),r.push(this.particleArray[a].color),n.push(this.particleArray[a].opacity),s.push(this.particleArray[a].size),o.push(this.particleArray[a].angle));if(di(this.particleGeometry,this.bufferGeometry),this.bufferGeometry.getAttribute("customVisible").copyArray(i),this.bufferGeometry.getAttribute("customColor").copyColorsArray(r),this.bufferGeometry.getAttribute("customOpacity").copyArray(n),this.bufferGeometry.getAttribute("customSize").copyArray(s),this.bufferGeometry.getAttribute("customAngle").copyArray(o),this.bufferGeometry.getAttribute("customVisible").needsUpdate=!0,this.bufferGeometry.getAttribute("customColor").needsUpdate=!0,this.bufferGeometry.getAttribute("customOpacity").needsUpdate=!0,this.bufferGeometry.getAttribute("customSize").needsUpdate=!0,this.bufferGeometry.getAttribute("customAngle").needsUpdate=!0,this.emitterAlive){if(this.emitterAgethis.particleCount&&(h=this.particleCount);for(a=l;athis.emitterDeathAge&&(this.emitterAlive=!1)}},Gf.prototype.destroy=function(){this.parent.remove(this.particleMesh),this.isShow=!1},Gf.prototype.show=function(){this.parent.add(this.particleMesh),this.isShow=!0},Gf.prototype.hide=function(){this.parent.remove(this.particleMesh),this.isShow=!1};const Hf=zf;const Xf=new be.Vector3,Wf=new be.Vector3,Yf=new be.Matrix3;class Qf extends be.LineSegments{constructor(t,e=1,i=16711680){const r=new be.BufferGeometry,n=t.geometry.attributes.normal.count,s=new be.Float32BufferAttribute(2*n*3,3);r.setAttribute("position",s),super(r,new be.LineBasicMaterial({color:i,toneMapped:!1})),this.isHelper=!0,this.object=t,this.size=e,this.type="VertexNormalsHelper",this.matrixAutoUpdate=!1,this.update()}update(){this.object.updateMatrixWorld(!0),Yf.getNormalMatrix(this.object.matrixWorld);const t=this.object.matrixWorld,e=this.geometry.attributes.position,i=this.object.geometry;if(i&&i.isGeometry)console.error("THREE.VertexNormalsHelper no longer supports Geometry. Use THREE.BufferGeometry instead.");else{if(i&&i.isBufferGeometry){const r=i.attributes.position,n=i.attributes.normal;let s=0;for(let i=0,o=r.count;it.preventDefault())),this._content=U("div","THING-ctrl-compass",this._container),this._start=e.startDegree}setStartDegree(t){this._start=t,this._update()}onAdd(t){return this._viewer=t,t.on("rotate",this._update.bind(this)),setTimeout((()=>{this._update()}),100),this._container}onRemove(){j(this._container)}_update(t){const e=this._viewer;if(!e)return;const i=e.camera,r=e.cameraControl.control.getTarget(),n=i.position.x-r.x,s=i.position.z-r.z,o=180*Math.atan2(n,s)/Math.PI+this._start;this._degree=o,this._content.style.transform=`rotateZ(${o}deg)`}correct(){const t=viewer.camera,e=viewer.cameraControl.control.getTarget(),i=t.position.x-e.x,r=t.position.z-e.z;return this._start=-1*Math.atan2(i,r)*180/Math.PI,this._update(),this._start}getDefaultPosition(){return"bottom-left"}},t.Cone=Do,t.ControlHelper=class extends Co{constructor(t,e){super(pt({material:{depthTest:!1,depthWrite:!1,map:{icon:"thing-point",iconWidth:16,iconHeight:16}}},e)),this.name="ControlHelper",this._object=t}update(){}},t.Coords=Df,t.CurveLine=Bc,t.Cylinder=Io,t.DimensionHelper=class extends Mo{constructor(t,e){super(),this.isDimensionHelper=!0,this.option=pt({color:"#ff0000",depthTest:!1,depthWrite:!1,offset:.25,fontSize:18,space:.01,width:!0,height:!0,depth:!0},e),this._object=t,this.name="DimensionHelper",this._initDimensions()}_initDimensions(){const t=this._object,e=t.getBox3(),i=t.getSize(),r=t.getCenter();let n=this.option.offset;const{width:s,depth:o,height:a}=this.option;s&&this._createDimension({size:i.x,width:i.x,position:[r.x,e.min.y,e.max.z+n],rotation:[-Math.PI/2,0,0]}),o&&this._createDimension({size:i.z,width:i.z,position:[e.max.x+n,e.min.y,r.z],rotation:[-Math.PI/2,0,Math.PI/2]}),a&&(this._createDimension({size:i.y,width:i.y,position:[e.max.x+n,r.y,e.max.z+n],rotation:[-Math.PI/2,Math.PI/2,0]}),this._createDimension({size:i.y,width:i.y,position:[e.min.x-n,r.y,e.min.z-n],rotation:[0,0,Math.PI/2]}))}_createDimension({size:t,width:e,position:i,rotation:r}){const n=document.createElement("canvas");if(n.width=120*e>2048?1024:120*e,n.height=40,n.widthparseInt(t))),e=o/Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))*2.54/100;i=ct(t[0]*e,3),r=ct(t[1]*e,3)}this.box&&this.box.updateGeometry({width:i,depth:n,height:r}),this.videoPlane&&this.videoPlane.updateGeometry({width:i-2*e,height:r-2*e})}play(){this.videoPlane.video.play()}pause(){this.videoPlane.video.pause()}updateVideo(t){this.videoPlane&&this.videoPlane.updateVideo(t)}get video(){return this.videoPlane.video}},t.Dodecahedron=Uo,t.Doughnut=Qo,t.DrawControl=mm,t.ExtrudeLine=class extends Ro{constructor(t){super(pt({points:[],geometry:{height:.5,width:0,closed:!1,curveType:"catmullrom",tension:0},material:{side:1}},t)),this.isExtrudeLine=!0,this.type="ExtrudeLine",this.needPoints=!0,this.updatePoints(this.option.points)}get length(){if(this._points.length<2)return 0;let t=0,e=ti(this._points[0]);return this._points.slice(1).forEach((i=>{t+=e.distanceTo(ti(i)),e=i})),t}createGeometry(){if(!this._points||this._points.length<2)return new be.BufferGeometry;const t=this.option.geometry,e=[],{width:i,height:r,closed:n,curveType:s,tension:o}=t;e.push(new be.Vector2(0,i)),e.push(new be.Vector2(-r,i)),e.push(new be.Vector2(-r,0)),e.push(new be.Vector2(0,0));const a=new be.Shape(e),l={steps:100*this._points.length,bevelEnabled:!1,extrudePath:new be.CatmullRomCurve3(this._points,n,s,o)};return new be.ExtrudeGeometry(a,l)}updatePoints(t){if(!t||0===t.length)return;this._points=[];let e="none";for(let i=0;it.toArray()))}set points(t){this.updatePoints(t)}},t.ExtrudePolygon=class extends Oc{constructor(t){super(pt({points:[],geometry:{bevelEnabled:!1,bevelThickness:.1,bevelSize:.2,bevelOffset:.1,bevelSegments:1,depth:1},material:{side:2}},t)),this.type="ExtrudePolygon",this.isExtrudePolygon=!0,this.vertices=[],this._points=[],this.setPoints(this.option.points)}updatePoints(t){this.setPoints(t)}setPoints(t){t=t||[],this._points=[];let e=[];for(let i=0;it.y=r));i=Eo(this._points.slice(0).map((t=>[t.x,t.z])),-.5);var n=new be.Path;n.moveTo(i[0][0],i[0][1]),i.slice(1).forEach((t=>{n.lineTo(t[0],t[1])}));var s=new be.Shape(e);const o={...this.option.geometry};o.depth=-1*o.depth;const a=new be.ExtrudeGeometry(s,o);return a.uvsNeedUpdate=!0,a}_updateByPoints(){if(this._points.length<3)return;const t=this._createGeometry();if(this.mesh)this.mesh.geometry=t;else{const e=this.mesh=new be.Mesh(t,new be.MeshStandardMaterial);this.mesh.rotation.x=Math.PI/2,e.updateBy({material:this.option.material}),this.add(e)}}clear(){this._points=[],this.vertices=[],this._updateByPoints()}},t.ExtrudePolygon2=class extends Ro{constructor(t){super(pt({points:[],rotation:[.5*-Math.PI,0,0],geometry:{depth:1},material:{side:2}},t)),this.type="ExtrudePolygon2",this.isExtrudePolygon2=!0,this.updatePoints(this.option.points)}updatePoints(t){this._points=t,this._points.length>0&&(this.mesh.geometry.dispose(),this.mesh.geometry=this.createGeometry(),this.updateMaterial(this.option.material))}createGeometry(t){if(!this._points)return new be.BufferGeometry;t=t||this.option.geometry;const{indices:e,position:i,uv:r,normal:n}=Yd([this._points],{depth:t.depth}),s=new be.BufferGeometry;return s.setAttribute("position",new be.Float32BufferAttribute(i,3)),s.setAttribute("normal",new be.Float32BufferAttribute(n,3)),s.setIndex(new be.Uint16BufferAttribute(e,1)),s.center(),s}},t.Group=Ya,t.Heatmap=class extends Mo{constructor(t,e){super(pt({style:{radius:15,width:1024,blur:.85,maxOpacity:1,minOpacity:0,gradient:{.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"}},material:{}},e||{})),this.type="Heatmap",this.isHeatmap=!0,this.setData(t)}updateStyle(t){if(pt(this.option.style,t),this.heatmap&&t){this.heatmap.configure(t),this.heatmap._store._cfgRadius=this.option.style.radius;const e=this.heatmap.getData();e.data.forEach((t=>delete t.radius)),this.heatmap.setData(e),this.heatmap.repaint(),this._plane.mesh.material.map.needsUpdate=!0}}setData({data:t,min:e,max:i}){const{width:r}=this.option.style,n=t.map((t=>[t.x,0,t.y]));let s=n.length>0?1:0;const o=new Gc({points:n}),a=o.getBox3();a.expandByScalar(s);const l=(a.max.x-a.min.x)/(a.max.z-a.min.z),h=a.getSize(new THREE.Vector3);let c=Math.round(r/(a.max.x-a.min.x)),d=Math.round(r/l/(a.max.z-a.min.z)),u=Number.MAX_SAFE_INTEGER,p=Number.MIN_SAFE_INTEGER,m=t.map((t=>{const e=t.value;return u=Math.min(u,e),p=Math.max(p,e),{x:Math.round((t.x-a.min.x)*c),y:Math.round((t.y-a.min.z)*d),value:e}}));this.heatMapData=m,this._plane&&(this._plane.removeFromParent(),this._plane=null),this.heatmap?(this.heatmap._renderer.setDimensions(r,Math.round(r/l)),this.heatmap.removeData(),this.heatmap.setDataMax(void 0!==i?i:p),this.heatmap.setDataMin(void 0!==e?e:u),this.heatmap.setData({data:m})):this.heatmap=function(t){const e=pt({data:[],min:0,max:100},t||{}),i=new eu(e);return i._renderer.canvas.dynamic=!0,e.data&&e.data.length>0&&i.setData({data:e.data,min:e.min,max:e.max}),i}({height:Math.round(r/l),data:m,min:void 0!==e?e:u,max:void 0!==i?i:p,...this.option.style});const f=this.heatmap;if(this._plane){const t=this._plane;t.updateBy({geometry:{width:h.x,height:h.z}}),t.position.clone(o.center),t.mesh.material.map.needsUpdate=!0}else{const t=this._plane=new iu(f._renderer.canvas,{position:o.center,rotation:[-90*THREE.MathUtils.DEG2RAD,0,0],geometry:{width:h.x,height:h.z},material:this.option.material});t.mesh.material.depthWrite=!1,t.mesh.material.depthTest=!1,t.mesh.renderOrder=1,this.add(t)}}},t.Helper=$f,t.HemisphereLight=Wm,t.HtmlPlane=class extends Vo{constructor(t,e){super(pt({name:"HtmlPlane",rotation:[0,0,0],border:10,geometry:{width:0,height:0},material:{color:"#000000",side:2}},e)),this.type="HtmlPlane",this.isHtmlPlane=!0,this.createHtml(t)}createHtml(t){if(!t)return;const e=new Xe(t),i=+t.style.width.split("px")[0],r=+t.style.height.split("px")[0],n=this.option.geometry,s=2*this.option.border;e.scale.set(n.width/(i+s),n.height/(r+s),1),this.cssObject=e,this.add(e)}get element(){return this.cssObject.element}set element(t){this.cssObject.element=t}},t.Icosahedron=Bo,t.ImagePlane=ou,t.LAYERS=pe,t.Lathe=ko,t.LightBox=class extends Mo{constructor(t){super(pt({geometry:{width:0,height:0,depth:.01,border:.04},light:{color:"#ffffff",intensity:1},material:{metalness:.5,roughness:.7,side:2,color:"#111111"},style:{images:[],current:0,duration:1e3}},t),!0),this.type="LightBox",this.isLightBox=!0,this.playing=!1,this._timer=null,this._current=0;let{width:e,height:i,depth:r}=this.option.geometry;const n=this.backPlane=new Vo({geometry:{width:e,height:i},position:[0,0,-r/2],rotation:[0,0,0]});this.add(n);const s=this.light=new Uu({color:this.option.color,intensity:this.option.intensity,width:e,height:i});this.add(s);const o=this.imagePlane=new ou({position:[0,0,r/2-.01],rotation:[0,0,0],material:{transparent:!0,opacity:.85}});this.add(o),this.updateBy(this.option)}updateLight(t){if(pt(this.option.light,t),!this.light)return;const e=this.light;this.position;let{depth:i,width:r,height:n,border:s}=this.option.geometry;e.position.x=0,e.position.y=0,e.position.z=i/2+.01,e.width=r-2*s,e.height=n-2*s;const o=this.option.light;e.color=ni(o.color),e.intensity=o.intensity}_updateBoxMesh(){let{border:t,width:e,height:i,depth:r}=this.option.geometry,n=new Oo(this.option),s=new Oo({geometry:{width:e-2*t,height:i-2*t,depth:r}});s.updateMatrix(),n.updateMatrix();let o=lu.fromMesh(n.mesh),a=lu.fromMesh(s.mesh),l=o.subtract(a),h=lu.toMesh(l,n.matrix,new THREE.MeshStandardMaterial);wo.updateMaterial(h,this.option.material),this.mesh&&this.remove(this.mesh),this.add(h),this.mesh=h}updateGeometry(t){pt(this.option.geometry,t);let{border:e,width:i,height:r,depth:n}=this.option.geometry;this._updateBoxMesh(),this.backPlane.updateGeometry({width:i,height:r}),this.backPlane.position.z=-n/2,this.imagePlane.position.z=n/2-.01,this.imagePlane.updateBy({geometry:{width:i-2*e,height:r-2*e}}),this.updateLight()}updateStyle(t){pt(this.option.style,t);const e=this.option.style;this._current=e.current||0,e.images[this._current]||(this._current=0),this.imagePlane.updateBy({material:{map:{image:e.images[this._current]},color:"#ffffff"}})}updateMaterial(t,e){pt(this.option.material,t);let i=this.option.material;wo.updateMaterial(this.mesh,i),wo.updateMaterial(this.backPlane.mesh,{...i,side:2})}_play(){const t=this.option.style.images.length;this._current>t&&(this._current=0),this.playing=!0,this.updateStyle({current:this._current+1})}play(){this.pause(),this._timer=setInterval((()=>{this._play()}),this.option.style.duration)}pause(){clearInterval(this._timer),this._current=0,this.playing=!1}},t.Line=Hh,t.Line2=cc,t.Loader=Rf,t.LogoControl=Ko,t.MeasureControl=wm,t.MeasureMode={MultipleDistance:"MultipleDistance",Distance:"Distance",SimpleDistance:"SimpleDistance",Area:"Area",Angle:"Angle",Height:"Height"},t.MinimapControl=class{constructor(t){this.option=pt({className:"",width:256,scale:1,center:{x:0,y:0}},t),this._container=null,this._viewer=null,this._opacity=1,this._posIndex=3,this.angle=0,this._enable=!0,this.renderer=null,this.scene=new be.Scene,this.camera=null,this.sprite=null,this.ratio=2,this.mainAspect=1,this.renderTarget=null,this.inited=!1,ht(["resize","render","updateBasemap","cameraChange","cameraPositionToMinimapCoords","updateArrowStyle"],this)}_init3d(){const t=(new be.Box3).setFromObject(this._viewer.sm.scene.root);var e=t.max.x>t.max.z?t.max.x:t.max.z,i=Math.abs(t.min.x)>Math.abs(t.min.z)?Math.abs(t.min.x):Math.abs(t.min.z),r=e>i?e:i;r*=1/this.scale,this.camera=new be.OrthographicCamera(-r,r,r,-r,-1e4,1e4),this.camera.position.set(this.center.x,100,this.center.y),this.camera.up=new be.Vector3(0,0,-1).applyEuler(new be.Euler(0,this.angle*Math.PI/180,0,"XYZ")),this.camera.lookAt(new be.Vector3(this.center.x,-1,this.center.y));var n=this._viewer.getSize();this.mainAspect=n.width/n.height,this.ratio=n.width/r,r*this.mainAspect*8<256*this.mainAspect||this.mainAspect,this.renderer||(this.renderer=this._viewer.rm._createRenderer()),this.renderer.setSize(this.width,this.width),this.updateBasemap(),this.inited=!0}setMiniRect(){}onAdd(t,e){this._viewer=t;const i=this._container=U("div","THING-ctrl",null),r=this._minimapContainer=U("div","THING-ctrl-minimap "+this.option.className,i);r.style.pointerEvent="none",i.onmousewheel=i.onmousemove=i.onmousedown=G;const n=U("div","THING-ctrl-minimap-arrow",r);return this.arrowEle=n,this._init3d(),this._viewer.rm.on("render",this.render),this._viewer.on("resize",this.resize),this.resize(),i}_init(){const t=this.renderer=this._viewer.rm._createRenderer();this._minimapContainer.append(t.domElement),this.renderer.setScissorTest(!1);const e=this._viewer.cameraControl.camera.clone();this.camera=e;const i=this._viewer.sm.scene;this.box=(new be.Box3).setFromObject(i.root),this._viewer.rm.addEventListener("render",this.render)}updateBasemap(){const t=this._viewer.sm.scene;var e=t.background;t.background=null,this.renderer.render(t,this.camera);const i=this.renderer.domElement.toDataURL("image/png",.8);this._minimapContainer.style.backgroundImage="url("+i+")",this._minimapContainer.style.backgroundSize="100% 100%",t.background=e}render(){if(!this._viewer.sm)return;this._viewer.sm.scene;const t=this._viewer.rm.renderer,e=this._viewer.camera;var i=t.autoClear;t.autoClear=!1,t.setRenderTarget(null),t.render(this.scene,this.camera),t.autoClear=i;var r=e.position.clone();if(0!=this.angle){var n=new be.Vector3(this.center.x,r.y,this.center.y),s=r.sub(n);s.applyEuler(new be.Euler(0,-this.angle*Math.PI/180,0,"XYZ")),s.add(n),r.copy(s)}var o=this.cameraPositionToMinimapCoords(r),a=o.x,l=o.y;this.updateArrowStyle(a,l,e.position.y);var h,c=e.rotation,d="YXZ"==c.order?c.y:c.z,u=this.arrowEle;h=d>=0?d/Math.PI*180:180*(2-Math.abs(d)/Math.PI),u.style.transform="rotate("+(-h+this.angle)+"deg)"}cameraPositionToMinimapCoords(t){var e,i;i=e=this.width/2;var r,n,s=e/((this.camera.right-this.camera.left)/2);return void 0!==t.x?(r=t.x-this.center.x,n=t.z-this.center.y):(r=t[0]-this.center.x,n=t[2]-this.center.y),{x:r>=0?e-s*r:e+s*Math.abs(r),y:n>=0?i-s*n:i+s*Math.abs(n)}}updateArrowStyle(t,e,i){var r=1/(220/30)*(i>80?i-80:0)+15;r>30&&(r=30);var n=this.arrowEle,s=r;this.width,n.style.right=t-20+"px",n.style.bottom=e-s/2+"px"}__update(){const t=this._viewer.sm.scene,e=this._viewer.cameraControl.camera.position.clone();e.x=t.position.x,e.z=t.position.z,e.y=this.box.max.y+this.option.y,this.camera.position.copy(e),this.camera.lookAt(t.position.clone().setY(0)),this.camera.updateProjectionMatrix(),this.size,this.renderer.render(t,this.camera),this.cameraChange()}cameraChange(){const t=this.size,e=this._viewer.getSize(),i=t.width/e.width,r=t.height/e.height,n=this._viewer.cameraControl,s=this._viewer.cameraControl.camera.position.clone(),o=n.control.getDirection(),a=Math.atan2(o.x,-o.z),l=this.box;var h=new be.Vector3(this.center.x,l.max.y+this.option.y,this.center.y),c=s.sub(h);c.applyEuler(new be.Euler(0,-a*Math.PI/180,0,"XYZ")),c.add(h),s.copy(c);const d=s.multiplyScalar(.9);this.position=d;const u=this._viewer.coordWorldToScreen(d.x,d.y,d.z);this._position=u;const p=this.arrowEle;p.style.transformOrigin="50% 100%",p.style.transform=`\n\t\t\t\ttranslate(${u.x*i}px,${u.y*r}px) \n\t\t\t\t\t\trotate(${180*a/Math.PI}deg)\n\t\t\t\t`}onRemove(){j(this._container),this._viewer.remove("resize",this.resize),this._viewer.rm.removeEventListener("render",this._render),this._viewer.cameraControl.control.removeEventListener("control",this.cameraChange),this._viewer=null}getDefaultPosition(){return"bottom-left"}resize(){if(!this._container)return;const t=this._container.children;if(t.length){const e=this._viewer,i=t[0],r=e.getSize(),n=r.height/r.width;this.size={width:this.width,height:n*this.width},i.style.width=this.width+"px",i.style.height=this.width+"px"}this.renderer&&this.renderer.setSize(this.width,this.width)}destroy(){this.scene.clear(),this.camera=null}_update(){}_recreate(){this.setMiniRect(),this.destroy(),this._init3d()}get width(){return this.option.width}set width(t){this.option.width=t,this.resize(),this._recreate()}get scale(){return this.option.scale}set scale(t){this.option.scale=t,this._recreate()}get center(){return this.option.center}set center(t){this.option.center=t,this._recreate()}get opacity(){return this._opacity}set opacity(t){this._opacity=t,this.sprite.material.opacity=this._opacity}},t.Model=Fo,t.Octahedron=jo,t.POSITION=Yt,t.Plane=Vo,t.PointLight=Qm,t.Points=Jo,t.Polygon=Gc,t.Popup=class extends ui{constructor(t){super(),this.option=pt({offset:null,className:"",tip:!0,closeButton:!0,position:null,html:"",lineWidth:0,lineColor:"rgba(25,25,25, 1)",lineDash:[0,0],lineEndPosition:[.5,1],lineStartOffsetRatio:[1,1],linePointSize:0,linePointColor:"#00ffff",avoid:!1},t||{}),this.container=null,this.contentContainer=null,this.avoid=this.option.avoid,this.id=be.MathUtils.generateUUID(),this._initContainer(),this.setHTML(this.option.html),this.setPosition(this.option.position)}_initContainer(){if(this.container)return;const{className:t,closeButton:e,tip:i}=this.option,r=this.container=U("div","THING-popup-anchor-bottom THING-popup "+t);i&&U("div","THING-popup-tip",r),r.setAttribute("popup-id",this.id),r.style.transition="opacity 0.1s linear",this.contentContainer=U("div","THING-popup-content",r);const n=this.svgContainer=document.createElementNS("http://www.w3.org/2000/svg","svg");if(n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("popup-id",this.id),n.style.transition="opacity 0.1s linear",n.style.position="absolute",n.style.pointerEvents="none",n.style.zIndex=9,n.style.left=0,n.style.top=0,e){const t=U("div","THING-popup-close-button",r);t.style.zIndex=999,t.innerHTML="x";var s=this;t.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),s.hidden()}))}}show(){if(this.visible)return this;this.container.style.display="";return this.svgContainer.style.display="block",this.visible=!0,this}hidden(){if(!this.visible)return this;this.visible=!1;const t=this.container;t.style.display="none";return this.svgContainer.style.display="none",t&&this.dispatchEvent({type:"close"}),this}setPosition(t){return t?(this.position=ti(t),this.update()):this.position=(new be.Vector3).addScalar(-9999),this}setHTML(t){return this.contentContainer.innerHTML="",t&&(Q(t)?this.contentContainer.innerHTML=t||"":F&&this.contentContainer.appendChild(t)),this}get visible(){return 0!=+this.container.style.opacity&&0!=+this.svgContainer.style.opacity}set visible(t){this.container&&(this.container.style.opacity=t?1:0),this.svgContainer&&(this.svgContainer.style.opacity=t?1:0)}remove(){const t=this.container,e=this.svgContainer;return t.parentNode&&t.parentNode.removeChild(t),e.parentNode&&e.parentNode.removeChild(e),this.viewer,this.viewer=null,this.visible=!1,this.dispatchEvent({type:"close"}),this}addTo(t){return t?(this.remove(),this.viewer=t,t.popups.contains(this)||(t.popups.add(this),this.viewer.container.appendChild(this.container),this.viewer.container.appendChild(this.svgContainer),this.viewer._updatePopups(),setTimeout((()=>{this.update(),this.dispatchEvent({type:"open"})}),300)),this):this}updateBox(){if(!this.viewer)return;const{position:t,viewer:e,container:i,option:r}=this,n=e.coordWorldToScreen(t.x,t.y,t.z);if(n){const{x:t,y:e}=n,i=this.option.offset,r=this.container.clientWidth,s=this.container.clientHeight;this.box2d=new be.Box2(new be.Vector2(t-r/2,e-s+i[1]),new be.Vector2(t+r/2+i[0],e))}}update(){if(!this.visible||!this.viewer||!this.position)return;const{position:t,viewer:e,container:i,option:r}=this;let{x:n,y:s}=e.coordWorldToScreen(t.x,t.y,t.z);(isNaN(n)||n==Number.POSITIVE_INFINITY||n==Number.NEGATIVE_INFINITY)&&(n=0),(isNaN(s)||s==Number.POSITIVE_INFINITY||s==Number.NEGATIVE_INFINITY)&&(s=0);const{clientWidth:o,clientHeight:a}=this.container,{width:l,height:h}=e.getSize(),c=$e(r.offset||[0,0]);if(i.style.left=n-o/2+c.x+"px",i.style.top=s-a+c.y+"px",r.lineWidth>0&&this.visible){const{lineDash:t,lineStartOffsetRatio:e,linePointSize:i,linePointColor:d,lineColor:u,lineWidth:p,lineEndPosition:m}=r;let f=n-o*(.5-m[0])+c.x,g=n+(f-n)*e[0],v=s-a*(1-m[1])+c.y,y=s+(v-s)*e[1];const w={x1:n/l*100,y1:s/h*100,x2:g/l*100,y2:y/h*100},x={x1:g/l*100,y1:y/h*100,x2:f/l*100,y2:v/h*100};let b=`\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t`;if((e[0]<1||e[1]<1)&&(b+=`\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t`),i>0&&(b+=`\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t`),this.svgContainer)try{this.svgContainer.innerHTML=b}catch(t){}}}},t.Rain=class extends Mo{constructor(t){super(pt({material:{rainSpeed:.4,rainColor:"#ffffff",radian:100*be.MathUtils.DEG2RAD,dark:.4,transparent:!0,side:2,depthWrite:!1,depthTest:!1}},t)),this.type="Rain",this.isRain=!0,ht(["_updateTime"],this),this.name="rain",this.particle=null,this._createMesh(),this.updateMaterial(this.option.material),this.locked=!0}setupCommonEvent(){super.setupCommonEvent(),this.addEventListener("added",(()=>{if(this.scene&&this.scene.viewer){this.scene.viewer.rm.addEventListener("render",this._updateTime)}})),this.addEventListener("removed",(()=>{if(this.scene&&this.scene.viewer){const{rm:t}=this.scene.viewer;t.removeEventListener("render",this._updateTime)}}))}_updateTime({clock:t}){this.mesh.material.uniforms.u_time.value=t.getElapsedTime()}updateMaterial(t){super.updateMaterial(t);const e=this.option.material;for(const t in e)if(this.mesh.material.uniforms[t]){let i=e[t];"rainColor"==t&&(i=new be.Color(i)),this.mesh.material.uniforms[t].value=i}}_createMesh(){var t=new be.PlaneBufferGeometry(2,2),e={u_time:{type:"f",value:0},tDiffuse:{value:null},u_resolution:{type:"v2",value:new be.Vector2(window.innerWidth,window.innerHeight).multiplyScalar(window.devicePixelRatio)},dark:{type:"f",value:this.option.material.dark},radian:{value:this.option.material.radian},rainSpeed:{value:this.option.material.rainSpeed},rainColor:{value:new be.Color(this.option.material.rainColor)}},i=new be.ShaderMaterial({transparent:!0,uniforms:e,vertexShader:"\n\t\t\t\t\t\t\t\t#define GLSLIFY 1\n\t\t\t\t\t\t\t\tvarying vec2 vUv;\n\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\t\t\t\t\t\tvUv = uv;\n\t\t\t\t\t\t\t\t\t\tgl_Position = vec4( position, 1.0 );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t",fragmentShader:"\n\t\t\t\t\t\t\t\tuniform sampler2D tDiffuse;\n\t\t\t\t\t\t\t\tuniform vec2 u_resolution;\n\t\t\t\t\t\t\t\tuniform float u_time;\n\t\t\t\t\t\t\t\tuniform float rainSpeed;\n\t\t\t\t\t\t\t\tuniform vec3 rainColor;\n\t\t\t\t\t\t\t\tuniform float radian;\n\t\t\t\t\t\t\t\tuniform float dark;\n\t\t\t\t\t\t\t\tvarying highp vec2 vUv;\n\t\t\t\t\t\t\t\tfloat hash(vec2 p){\n\t\t\t\t\t\t\t\t\t\tp\t= 50.0*fract( p*0.3183099 + vec2(0.71,0.113));\n\t\t\t\t\t\t\t\t\t\treturn -1.0+2.0*fract( p.x*p.y*(p.x+p.y) );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfloat noise( in vec2 p ){\n\t\t\t\t\t\t\t\t\t\tvec2 i = floor( p );\n\t\t\t\t\t\t\t\t\t\tvec2 f = fract( p );\n\t\t\t\t\t\t\t\t\t\tvec2 u = f*f*(3.0-2.0*f);\n\t\t\t\t\t\t\t\t\t\treturn mix( mix( hash( i + vec2(0.0,0.0) ), \n\t\t\t\t\t\t\t\t\t\t\t\t\t\thash( i + vec2(1.0,0.0) ), u.x),\n\t\t\t\t\t\t\t\t\t\t\t\tmix( hash( i + vec2(0.0,1.0) ), \n\t\t\t\t\t\t\t\t\t\t\t\t\t\thash( i + vec2(1.0,1.0) ), u.x), u.y);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tvoid main(){\n\t\t\t\t\t\t\t\t\t\tvec3 col=texture(tDiffuse,vUv).rgb;\n\t\t\t\t\t\t\t\t\t\tvec2 q = gl_FragCoord.xy/u_resolution.xy;\n\t\t\t\t\t\t\t\t\t\tvec2 p = -1.0+2.0*q;\n\t\t\t\t\t\t\t\t\t\tp.x *= u_resolution.x/u_resolution.y;\n\t\t\t\t\t\t\t\t\t\tvec2 st =\t(p * vec2(.5, .01)+vec2(u_time)*0.05*rainSpeed)-vec2(q.y*cos(radian),0.0);\n\t\t\t\t\t\t\t\t\t\tst*=1000.;\n\t\t\t\t\t\t\t\t\t\tfloat f = noise(st) * noise(st*.773)* 1.55;\n\t\t\t\t\t\t\t\t\t\tf = clamp(pow(abs(f), 23.0) * 13.0, 0.0, q.y*.14) * 2.7;\n\t\t\t\t\t\t\t\t\t\tcol += clamp(f,0.0,1.0)*rainColor;\n\t\t\t\t\t\t\t\t\t\tgl_FragColor = vec4(col, dark);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t"}),r=new be.Mesh(t,i);this.mesh=r,this.add(r)}toJSON(){return super.toJSON()}},t.RectAreaLight=Uu,t.Reflector=ru,t.ReflectorPlane=nu,t.Refractor=su,t.Ring=zo,t.RomaControl=class extends ui{constructor(t,e,i){if(super(),this.option=pt({speed:40,offsetX:0,offsetY:1.7,offsetZ:0,showPath:!1,points:[],model:null,moveStep:.25,loop:!0,tension:.2,line:null,cameraFollow:!0,godMode:!1,inspectionMode:!1,equalDistance:1,inspectionPauseTime:2e3,audio:"",playAudio:!0},e||{}),this.path=null,this._pathPoints=[],this.viewer=t,this.parent=i||this.viewer.scene,this.root=new Ya,this.parent.add(this.root),this.viewpoints=this.option.viewpoints,this.actions=this.option.actions,this.speed=this.option.speed,this.moveStep=this.option.moveStep,this._startGeometry=new Yo({geometry:{radius:.15,height:.75},material:{side:2,color:"#ff0000",transparent:!0,opacity:.95}}),this.option.model){const t=this.model=new Fo(this.option.model);this.root.add(t)}this.box=new Oo({geometry:{width:.1,depth:.1,height:1.7}}),this.audio=new be.Audio(new be.AudioListener),this.setAudio(this.option.audio),this.status=0,this.time=0,this._oldDampingFactor=t.cameraControl?t.cameraControl.control.dampingFactor:.3,this.setPoints(this.option.points||[]),ht(["_playAction","_onPointerDown","_onPointerMove"],this)}setModelParent(t){this.model&&t.attach(this.model)}_initAudio(){}setAudio(t,e){t&&(new be.AudioLoader).load(mo.transformUrl(t),(t=>{this.audio.setBuffer(t),this.audio.setLoop(!0),this.audio.setVolume(1),this.dispatchEvent({type:"audio.loaded"}),e&&e(this.audio)}))}pickStartPoint(){this.viewer.cameraControl.setFirstPersonMode(!1),this._oldView=this.viewer.getView();const t=this.viewer.rm;t.effectRenderer&&(this._effectRendererEnable=t.effectRenderer.enable,t.effectRenderer.enable=!1),this.viewer.container.addEventListener("pointermove",this._onPointerMove),this.viewer.container.addEventListener("pointerdown",this._onPointerDown)}_onPointerMove(t){const e=this.viewer.sceneManager.sceneHelpers,i=this.viewer.coordScreenToWorldWithPick(t.clientX,t.clientY);i&&(e.hasChild(this._startGeometry)||e.add(this._startGeometry),i[1]+=this._startGeometry.getSize().y/2,this._startGeometry.position.fromArray(i))}_onPointerDown(t){let e=this.viewer.coordScreenToWorldWithPick(t.clientX,t.clientY);const i=this.viewer.cameraControl;if(this.moveStep,i.setPosition(e,!1),i.setFirstPersonMode(!0,this.option),i._oldMoveStep=i.moveStep,i.moveStep=this.moveStep,this._startGeometry.removeBySelf(),this.viewer.container.removeEventListener("pointermove",this._onPointerMove),this.viewer.container.removeEventListener("pointerdown",this._onPointerDown),this.mode="firstPerson",this._effectRendererEnable){this.viewer.rm.effectRenderer.enable=!0,delete this._effectRendererEnable}}_getMileSpeed(){return 1e3*this.speed/3600}setPoints(t){if(!t||!t.length)return;let e=[],i=0;for(let i=0;i{i+=t.distanceTo(e[0])}));const r=this._getMileSpeed(),n=10*Math.round(i/r);if(this.path=new be.CatmullRomCurve3(e,!1,"catmullrom",this.option.tension),this._pathPoints=this.path.getPoints(n),this.option.showPath&&t){const e=this.option.line||{},i=this.routeLine=new cc({points:t,locked:!0,material:{linewidth:3,worldUnits:!1,...e.material||{}}});this.root.add(i)}this._initModel()}isPlaying(){return 1==this.status}isPaused(){return 2==this.status}isStopped(){return 0==this.status}_initModel(){const t=this.model;if(!t)return;let e=this.path.getPointAt(1e-4),i=this.path.getPointAt(2e-4);e&&e.x&&i&&(t.position.set(e.x,e.y,e.z),t.lookAt(i.x,i.y,i.z))}_playAction(){const t=this._pathPoints;if(this.isPlaying()&&t&&t.length){const{loop:i,inspectionMode:r}=this.option,n=t.length;if(this.time>n&&!i)return void this.stop();this.time>n&&(this.time=0,this._visitedPointIndex=0);const s=this.time%n,o=(this.time+1)%n;this.time+=1;let a=this.path.getPointAt(s/n),l=this.path.getPointAt(o/n);if(a&&a.x&&0!==s&&0!==o){this.model&&(this.model.position.set(a.x,a.y,a.z),this.model.lookAt(l.x,l.y,l.z)),this.box.position.set(a.x,a.y,a.z),this.box.lookAt(l.x,l.y,l.z);const{offsetX:t,offsetY:i,offsetZ:r,godMode:n}=this.option,s=new be.Vector3(a.x,a.y+(n?0:i),a.z);if(this.dispatchEvent({type:"playing"}),this.viewer._updatePopups(),this.option.inspectionMode){const{equalDistance:t,inspectionPauseTime:e}=this.option;let i=this._visitedPointIndex;const r=this.points[i];this.time>0&&r&&a.distanceTo(r)<=t&&(this.pause(),this.dispatchEvent({type:"inspection.pause",data:{index:i,point:r.clone()}}),setTimeout((()=>{this._visitedPointIndex+=1,this.dispatchEvent({type:"inspection.continue",data:{index:i,point:r.clone()}}),this.play()}),e||0))}if(this.option.cameraFollow){var e=new be.Vector3(n?0:t,i,n?0:r).applyMatrix4(this.box.matrixWorld);this.viewer.cameraControl.lookAt(s,e,!1)}this.viewer.rendererManager.enableRender()}}this._playActionFrame=requestAnimationFrame(this._playAction)}playAudio(){this.audio&&this.option.playAudio&&this.option.audio&&(this.audio.isPlaying||this.audio.play())}play(){this.isStopped()?(this.time=0,this.status=1,this._playAction()):this.status=1,this.dispatchEvent({type:"play"})}pause(){this.status=2,this.viewer&&(this.audio&&this.option.playAudio&&this.option.audio,this.viewer.cameraControl&&(this.viewer.cameraControl.control.dampingFactor=this._oldDampingFactor),this.dispatchEvent({type:"pause"}))}stop(){this.time=0,cancelAnimationFrame(this._playAction),cancelAnimationFrame(this._playActionFrame),this.status=0,this.time=0,this._visitedPointIndex=0,this._playActionFrame=null,this.audio&&this.option.playAudio&&this.option.audio&&this.audio.stop();const t=this.viewer;t.cameraControl.firstPersonMode&&(t.cameraControl.setFirstPersonMode(!1),t.cameraControl.moveStep=t.cameraControl._oldMoveStep),this._initModel(),this.viewer.cameraControl.control.dampingFactor=this._oldDampingFactor,this.dispatchEvent({type:"stop"})}exit(){this.stop(),this._oldView&&(this.viewer.setView(this._oldView),this._oldView=null),this.dispatchEvent({type:"exit"})}clear(){const t=this.viewer;this._startGeometry.removeBySelf(),t.container.removeEventListener("pointermove",this._onPointerMove),t.container.removeEventListener("pointerdown",this._onPointerDown),t.cameraControl.firstPersonMode&&t.cameraControl.setFirstPersonMode(!1)}destroy(){this.stop(),this.clear(),this.root.clear()}},t.RouteLine=Ic,t.Selector=Ql,t.SmokeFire=class extends Mo{constructor(t){super(pt({particle:{sizeScale:1,positionStyle:"cube",positionBase:[0,0,0],positionRadius:.5,positionSpread:[.5,0,.5],speedBase:.1,speedSpread:.2,sizeBase:0,sizeSpread:0,velocityStyle:"cube",velocityBase:[0,50,0],velocitySpread:[40,50,40],accelerationBase:[0,-10,0],sizeTween:[[0,.2],[2,16]],opacityTween:[[0,.2],[.8,0]],colorTween:[[0,.1],[[.8,.8,.8],[.1,.1,.1]]],colorBase:[1,1,1],angleBase:0,angleSpread:720,angleVelocityBase:0,angleVelocitySpread:720,angleAccelerationBase:0,angleAccelerationSpread:0,particlesPerSecond:300,particleDeathAge:2,particleTexture:"",emitterAge:0,emitterDeathAge:1e4,emitterAlive:!0}},t)),this.isParticle=!0,this.type="SmokeFire",this.isSmokeFire=!0,this.particle={},ht(["_updateParticle"],this)}setupCommonEvent(){super.setupCommonEvent(),this.addEventListener("added",(()=>{if(this.scene){this.updateParticle();const{rm:t}=this.scene.viewer;t.addEventListener("render",this._updateParticle)}}))}_updateParticle({clock:t}){if(!(this.visible&&t&&this.scene&&this.engine))return;let e=t.getDelta();this.engine.update(e)}updateParticle(t){pt(this.option.particle,t);const e=this.option.particle;for(const t in e){const i=e[t];switch(t){case"positionStyle":case"velocityStyle":this.particle[t]=Hf[i.toUpperCase()];break;case"particleTexture":if(i){const e=(new be.TextureLoader).load(mo.transformUrl(i));e.encoding=be.sRGBEncoding,this.particle[t]=e}else this.particle[t]=null;break;case"sizeTween":case"colorTween":case"opacityTween":if(i){const e="sizeTween"===t?this.option.particle.sizeScale:1;let r=i[0].map((t=>Array.isArray(t)?ti(t).multiplyScalar(e):t*e)),n=i[1].map((t=>Array.isArray(t)?ti(t).multiplyScalar(e):t*e));this.particle[t]=new jf(r,n)}else this.particle[t]=new jf;break;case"colorBase":case"colorSpread":case"positionBase":case"positionSpread":case"velocityBase":case"velocitySpread":case"accelerationBase":case"accelerationSpread":this.particle[t]=ti(i);break;default:this.particle[t]=i}}this.engine&&this.engine.destroy(),this.engine=new Gf(this),this.engine.setValues(this.particle),this.engine.initialize()}},t.Snow=class extends Mo{constructor(t){super(pt({number:1e4,range:100,speed:.3,material:{size:2,opacity:.6,depthTest:!1,transparent:!0}},t)),this.type="Snow",this.isSnow=!0,ht(["snowing"],this),this._updatePosition=ut(this.__updatePosition,100,this),this.name="snow",this.speed=this.option.speed,this.size=this.option.material.size,this.particle=null,this._createParticle(),this.updateMaterial(this.option.material),this.locked=!0}setupCommonEvent(){super.setupCommonEvent(),this.addEventListener("added",(()=>{if(this.scene&&this.scene.viewer){const{rm:t,cameraControl:e}=this.scene.viewer;t.addEventListener("render",this.snowing),e.control.addEventListener("control",this._updatePosition)}})),this.addEventListener("removed",(()=>{if(this.scene&&this.scene.viewer){const{rm:t,cameraControl:e}=this.scene.viewer;t.removeEventListener("render",this.snowing),e.control.removeEventListener("control",this._updatePosition)}}))}__updatePosition(){if(this.scene&&this.scene.viewer){const{rm:t,cameraControl:e}=this.scene.viewer,i=e.camera.position;this.position.copy(i),t.enableRender()}}_createParticle(){const{number:t,range:e}=this.option,i=new be.BufferGeometry,r=new be.PointsMaterial({depthWrite:!1,vertexColors:!0,blending:be.AdditiveBlending});let n=[];const s=[];for(let i=0;i{if(this.scene&&this.scene.viewer){this.scene.viewer.rm.addEventListener("render",this._updateTime)}})),this.addEventListener("removed",(()=>{if(this.scene&&this.scene.viewer){const{rm:t}=this.scene.viewer;t.removeEventListener("render",this._updateTime)}}))}updateGeometry(t){super.updateGeometry(t),t&&t.radius&&(this.mesh.material.uniforms.uRadius.value=t.radius)}_updateTime({clock:t}){t&&(this.mesh.material.uniforms.time.value=t.getElapsedTime())}updateMaterial(t){super.updateMaterial(t)}_initMaterial(){const t=this.option.material.uniforms,e=new be.ShaderMaterial({uniforms:{uColor:{value:new be.Color(t.uColor)},uOpacity:{value:t.uOpacity},uSpeed:{value:t.uSpeed},uSge:{value:t.uSge},uRadius:{value:this.option.geometry.radius},time:{value:t.time}},transparent:!0,vertexShader:`\n\t\t\t\t\t\t\t\t${be.ShaderChunk.common}\n\t\t\t\t\t\t\t\t${be.ShaderChunk.logdepthbuf_pars_vertex}\n\t\t\t\t\t\t\t\tvarying vec2 vUv;\n\t\t\t\t\t\t\t\tvoid main() { \n\t\t\t\t\t\t\t\t\t\tvUv = uv;\n\t\t\t\t\t\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\t\t\t\t\t\t${be.ShaderChunk.logdepthbuf_vertex}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t`,fragmentShader:`\n\n\t\t\t\t\t\t${be.ShaderChunk.logdepthbuf_pars_fragment}\n\n\t\t\t\t\t\tvarying vec2 vUv;\n\n\t\t\t\t\t\tuniform vec3 uColor;\n\t\t\t\t\t\tuniform float uOpacity;\n\t\t\t\t\t\tuniform float uSpeed; \n\t\t\t\t\t\tuniform float uSge;\n\t\t\t\t\t\tuniform float time;\n\n\t\t\t\t\t\tfloat PI = 3.14159265;\n\n\t\t\t\t\t\tfloat drawCircle(float index, float range) {\n\t\t\t\t\t\t\t\tfloat opacity = 1.0;\n\t\t\t\t\t\t\t\tif (index >= 1.0 - range) {\n\t\t\t\t\t\t\t\t\t\topacity = 1.0 - (index - (1.0 - range)) / range;\n\t\t\t\t\t\t\t\t} else if(index <= range) {\n\t\t\t\t\t\t\t\t\t\topacity = index / range;\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t\treturn opacity;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfloat distanceTo(vec2 src, vec2 dst) {\n\t\t\t\t\t\t\t\tfloat dx = src.x - dst.x;\n\t\t\t\t\t\t\t\tfloat dy = src.y - dst.y;\n\t\t\t\t\t\t\t\tfloat dv = dx * dx + dy * dy;\n\t\t\t\t\t\t\t\treturn sqrt(dv);\n\t\t\t\t\t\t} \n\n\t\t\t\t\t\tvoid main() { \n\t\t\t\t\t\t\t\tfloat iTime = -time * uSpeed;\n\t\t\t\t\t\t\t\tfloat opacity = 0.0;\n\n\t\t\t\t\t\t\t\tfloat len = distanceTo(vec2(0.5, 0.5), vec2(vUv.x, vUv.y)); \n\t\t\n\t\t\t\t\t\t\t\tfloat size = 1.0 / uSge;\n\t\t\t\t\t\t\t\tvec2 range = vec2(0.65, 0.75);\n\t\t\t\t\t\t\t\tfloat index = mod(iTime + len, size); \n\t\t\t\t\t\t\t\t// 中心圆 \n\t\t\t\t\t\t\t\tvec2 cRadius = vec2(0.06, 0.12); \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (index < size && len <= 0.5) {\t \n\t\t\t\t\t\t\t\t\t\tfloat i = sin(index / size * PI); \n\t\t\n\t\t\t\t\t\t\t\t\t\t// 处理边缘锯齿\n\t\t\t\t\t\t\t\t\t\tif (i >= range.x && i <= range.y){\n\t\t\t\t\t\t\t\t\t\t\t\t// 归一\n\t\t\t\t\t\t\t\t\t\t\t\tfloat t = (i - range.x) / (range.y - range.x);\n\t\t\t\t\t\t\t\t\t\t\t\t// 边缘锯齿范围\n\t\t\t\t\t\t\t\t\t\t\t\tfloat r = 0.3;\n\t\t\t\t\t\t\t\t\t\t\t\topacity = drawCircle(t, r);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t// 渐变\n\t\t\t\t\t\t\t\t\t\topacity *=\t1.0 - len / 0.5;\n\t\t\t\t\t\t\t\t}; \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tgl_FragColor = vec4(uColor, uOpacity * opacity);\n\n\t\t\t\t\t\t\t\t${be.ShaderChunk.logdepthbuf_fragment}\n\t\t\t\t\t\t}`});this.mesh.material=e}},t.hotkeys=Xl,t.materialManager=wo,t.path=qf,t.resourceManager=mo,t.version="1.0.0",Object.defineProperty(t,"__esModule",{value:!0})}));