@realsee/dnalogel
Version:
101 lines (88 loc) • 1.1 MB
JavaScript
(function(K,G){typeof exports=="object"&&typeof module!="undefined"?G(exports,require("three"),require("@realsee/five"),require("animejs"),require("three/examples/jsm/renderers/CSS3DRenderer"),require("hammerjs"),require("@realsee/five/line"),require("three/examples/jsm/loaders/FBXLoader"),require("earcut"),require("@realsee/five/gltf-loader")):typeof define=="function"&&define.amd?define(["exports","three","@realsee/five","animejs","three/examples/jsm/renderers/CSS3DRenderer","hammerjs","@realsee/five/line","three/examples/jsm/loaders/FBXLoader","earcut","@realsee/five/gltf-loader"],G):(K=typeof globalThis!="undefined"?globalThis:K||self,G(K.dnalogel={},K.THREE,K.FiveSDK,K.anime,K.CSS3DRenderer,K.Hammer,K.Line,K.FBXLoader,K.earcut,K.GLTFLoader))})(this,function(K,G,ve,pt,Ri,gn,Ni,mn,ai,ls){"use strict";var M3=Object.defineProperty,E3=Object.defineProperties;var k3=Object.getOwnPropertyDescriptors;var Dr=Object.getOwnPropertySymbols;var mm=Object.prototype.hasOwnProperty,pm=Object.prototype.propertyIsEnumerable;var sc=(K,G,ve)=>G in K?M3(K,G,{enumerable:!0,configurable:!0,writable:!0,value:ve}):K[G]=ve,x=(K,G)=>{for(var ve in G||(G={}))mm.call(G,ve)&&sc(K,ve,G[ve]);if(Dr)for(var ve of Dr(G))pm.call(G,ve)&&sc(K,ve,G[ve]);return K},re=(K,G)=>E3(K,k3(G));var to=(K,G)=>{var ve={};for(var pt in K)mm.call(K,pt)&&G.indexOf(pt)<0&&(ve[pt]=K[pt]);if(K!=null&&Dr)for(var pt of Dr(K))G.indexOf(pt)<0&&pm.call(K,pt)&&(ve[pt]=K[pt]);return ve};var d=(K,G,ve)=>(sc(K,typeof G!="symbol"?G+"":G,ve),ve);var F=(K,G,ve)=>new Promise((pt,Ri)=>{var gn=ai=>{try{mn(ve.next(ai))}catch(ls){Ri(ls)}},Ni=ai=>{try{mn(ve.throw(ai))}catch(ls){Ri(ls)}},mn=ai=>ai.done?pt(ai.value):Promise.resolve(ai.value).then(gn,Ni);mn((ve=ve.apply(K,G)).next())});function vm(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const w=vm(G);function bm(){console.debug("%c %c@realsee/dnalogel %cv3.30.4",["background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAMCAMAAACHgmeRAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABLFBMVEUAAAAapPoap/oaqvkbrfkbr/gZnfwZoPsaqfnD4v/E4/8Ylv0clPm93/+/4P/B4f8Yj/683/8Wif+33P8Uhv+x2f8ShP+s1v8Pgf+n0/8Nf/+h0f8Lff8Lff8Nf/9dl/+czv8KfP8KfP+Lxf+Uyv+Xy/+Hwv+Jw/+Mxf+Oxv+RyP8aovsapfoap/oZmfwZm/wZnvsYnPsYkf4YlP0NePsDYfgYcfi43f+63v8Xiv8Xjf4EWfwCV/sWZ/qz2v+02/8Vh/8WiP8EUf8CTf4WXv2u1/+v2P8Thf8Thv8ETf8CR/8VV/+o1f+q1f8Qgv8Rg/8DSv8BRf8UVP+j0v+k0v8OgP8Pgf8DR/8DQv9Nhf+dzv+fz/+Kv/+Vyv+Xy/+azf+Oxv+Qx/+SyP////8MUhLdAAAAK3RSTlMACEWQ2bd98uQECPXxqO7c+Pb49vj2+Pb49vj23Oul8fMHA+TwerXXjEIG2P+bHgAAAAFiS0dEY1y+LaoAAAB+SURBVAjXY2BgZGJmYWVgYGBgY9fW0eVg4ORi4NbTNzDk4eXjZxAwMjYxNTO3EGQQsrSytrG1sxdmEHFwdHJ2cXUTZRBz9/D08vbxFWeQ8PMPCAwKDpFkkAoNC4+IjIqWZpCRlZOPiY2LV2BQVGJQTkhMUlEFWaOmrqGpxQAAyg0S9Dq+VPYAAAAASUVORK5CYII=')","background-repeat: no-repeat","background-position: 0 center","padding-left: 8px"].join(";"),"","background-color: #12ce9b;color:black;padding:0 6px;border-radius: 3px")}function ym(){const n=typeof OffscreenCanvas!="undefined",t=n&&new OffscreenCanvas(1,1).getContext("webgl")!==null;n&&!t&&Object.assign(window,{OffscreenCanvas:function(e,i){const s=document.createElement("canvas");return s.width=e,s.height=i,s}})}function oc(){}const rc=()=>Promise.resolve(),ac={__queue:Promise.resolve()};function wm(n=rc){ac.__queue=ac.__queue.then(n).catch(rc)}function io(n,t,e){const i=n.x,s=n.y,o=Math.floor(i/t*1e4)/1e4,r=Math.floor(s/e*1e4)/1e4;return{x:o,y:r}}function xr(n,t,e){const{x:i,y:s}=n,o=i*t,r=s*e;return{x:o,y:r}}function no(n){if(n.length<2)return{};const t=n.slice(-2),e=t[0],i={x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2};return{control:e,end:i}}function Cm(n,t,e=oc){new Promise(i=>{setTimeout(()=>{e(),i(!0)},t*n)})}const Pm=window,lc=window.requestAnimationFrame||Pm.webkitRequestAnimationFrame||(n=>setTimeout(n,16));function so(n,t=0){t<=0?lc(n):lc(()=>so(n,t-1))}var Vt=Object.freeze({Linear:Object.freeze({None:function(n){return n},In:function(n){return this.None(n)},Out:function(n){return this.None(n)},InOut:function(n){return this.None(n)}}),Quadratic:Object.freeze({In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}}),Cubic:Object.freeze({In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}}),Quartic:Object.freeze({In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}}),Quintic:Object.freeze({In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}}),Sinusoidal:Object.freeze({In:function(n){return 1-Math.sin((1-n)*Math.PI/2)},Out:function(n){return Math.sin(n*Math.PI/2)},InOut:function(n){return .5*(1-Math.sin(Math.PI*(.5-n)))}}),Exponential:Object.freeze({In:function(n){return n===0?0:Math.pow(1024,n-1)},Out:function(n){return n===1?1:1-Math.pow(2,-10*n)},InOut:function(n){return n===0?0:n===1?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(-Math.pow(2,-10*(n-1))+2)}}),Circular:Object.freeze({In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}}),Elastic:Object.freeze({In:function(n){return n===0?0:n===1?1:-Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI)},Out:function(n){return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n-.1)*5*Math.PI)+1},InOut:function(n){return n===0?0:n===1?1:(n*=2,n<1?-.5*Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI):.5*Math.pow(2,-10*(n-1))*Math.sin((n-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(n){var t=1.70158;return n===1?1:n*n*((t+1)*n-t)},Out:function(n){var t=1.70158;return n===0?0:--n*n*((t+1)*n+t)+1},InOut:function(n){var t=2.5949095;return(n*=2)<1?.5*(n*n*((t+1)*n-t)):.5*((n-=2)*n*((t+1)*n+t)+2)}}),Bounce:Object.freeze({In:function(n){return 1-Vt.Bounce.Out(1-n)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(n){return n<.5?Vt.Bounce.In(n*2)*.5:Vt.Bounce.Out(n*2-1)*.5+.5}}),generatePow:function(n){return n===void 0&&(n=4),n=n<Number.EPSILON?Number.EPSILON:n,n=n>1e4?1e4:n,{In:function(t){return Math.pow(t,n)},Out:function(t){return 1-Math.pow(1-t,n)},InOut:function(t){return t<.5?Math.pow(t*2,n)/2:(1-Math.pow(2-t*2,n))/2+.5}}}}),pn=function(){return performance.now()},cc=function(){function n(){this._tweens={},this._tweensAddedDuringUpdate={}}return n.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},n.prototype.removeAll=function(){this._tweens={}},n.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},n.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},n.prototype.update=function(t,e){t===void 0&&(t=pn()),e===void 0&&(e=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<i.length;s++){var o=this._tweens[i[s]],r=!e;o&&o.update(t,r)===!1&&!e&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},n}(),Gi={Linear:function(n,t){var e=n.length-1,i=e*t,s=Math.floor(i),o=Gi.Utils.Linear;return t<0?o(n[0],n[1],i):t>1?o(n[e],n[e-1],e-i):o(n[s],n[s+1>e?e:s+1],i-s)},Bezier:function(n,t){for(var e=0,i=n.length-1,s=Math.pow,o=Gi.Utils.Bernstein,r=0;r<=i;r++)e+=s(1-t,i-r)*s(t,r)*n[r]*o(i,r);return e},CatmullRom:function(n,t){var e=n.length-1,i=e*t,s=Math.floor(i),o=Gi.Utils.CatmullRom;return n[0]===n[e]?(t<0&&(s=Math.floor(i=e*(1+t))),o(n[(s-1+e)%e],n[s],n[(s+1)%e],n[(s+2)%e],i-s)):t<0?n[0]-(o(n[0],n[0],n[1],n[1],-i)-n[0]):t>1?n[e]-(o(n[e],n[e],n[e-1],n[e-1],i-e)-n[e]):o(n[s?s-1:0],n[s],n[e<s+1?e:s+1],n[e<s+2?e:s+2],i-s)},Utils:{Linear:function(n,t,e){return(t-n)*e+n},Bernstein:function(n,t){var e=Gi.Utils.Factorial;return e(n)/e(t)/e(n-t)},Factorial:function(){var n=[1];return function(t){var e=1;if(n[t])return n[t];for(var i=t;i>1;i--)e*=i;return n[t]=e,e}}(),CatmullRom:function(n,t,e,i,s){var o=(e-n)*.5,r=(i-t)*.5,a=s*s,l=s*a;return(2*t-2*e+o+r)*l+(-3*t+3*e-2*o-r)*a+o*s+t}}},Sr=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),Lr=new cc,oo=function(){function n(t,e){e===void 0&&(e=Lr),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Vt.Linear.None,this._interpolationFunction=Gi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Sr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.getDuration=function(){return this._duration},n.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},n.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t<0?0:t,this},n.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},n.prototype.start=function(t,e){if(t===void 0&&(t=pn()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var o in this._valuesEnd)s[o]=this._valuesEnd[o];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},n.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},n.prototype._setupProperties=function(t,e,i,s,o){for(var r in i){var a=t[r],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(i[r]);if(!(c==="undefined"||c==="function")){if(h){var u=i[r];if(u.length===0)continue;for(var f=[a],g=0,A=u.length;g<A;g+=1){var p=this._handleRelativeValue(a,u[g]);if(isNaN(p)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}f.push(p)}h&&(i[r]=f)}if((c==="object"||l)&&a&&!h){e[r]=l?[]:{};var m=a;for(var b in m)e[r][b]=m[b];s[r]=l?[]:{};var u=i[r];if(!this._isDynamic){var y={};for(var b in u)y[b]=u[b];i[r]=u=y}this._setupProperties(m,e[r],u,s[r],o)}else(typeof e[r]=="undefined"||o)&&(e[r]=a),l||(e[r]*=1),h?s[r]=i[r].slice().reverse():s[r]=e[r]||0}}},n.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},n.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},n.prototype.pause=function(t){return t===void 0&&(t=pn()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},n.prototype.resume=function(t){return t===void 0&&(t=pn()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},n.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},n.prototype.group=function(t){return t===void 0&&(t=Lr),this._group=t,this},n.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},n.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},n.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},n.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},n.prototype.easing=function(t){return t===void 0&&(t=Vt.Linear.None),this._easingFunction=t,this},n.prototype.interpolation=function(t){return t===void 0&&(t=Gi.Linear),this._interpolationFunction=t,this},n.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},n.prototype.onStart=function(t){return this._onStartCallback=t,this},n.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},n.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},n.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},n.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},n.prototype.onStop=function(t){return this._onStopCallback=t,this},n.prototype.update=function(t,e){var i=this,s;if(t===void 0&&(t=pn()),e===void 0&&(e=!0),this._isPaused)return!0;var o,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>r)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=t-this._startTime,l=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(i._duration===0||a>c)return 1;var m=Math.trunc(a/l),b=a-m*l,y=Math.min(b/i._duration,1);return y===0&&a===i._duration?1:y},u=h(),f=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,f),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var g=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=g);for(o in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[o]=="string"&&(this._valuesStartRepeat[o]=this._valuesStartRepeat[o]+parseFloat(this._valuesEnd[o])),this._yoyo&&this._swapEndStartRepeatValues(o),this._valuesStart[o]=this._valuesStartRepeat[o];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*g,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var A=0,p=this._chainedTweens.length;A<p;A++)this._chainedTweens[A].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},n.prototype._updateProperties=function(t,e,i,s){for(var o in i)if(e[o]!==void 0){var r=e[o]||0,a=i[o],l=Array.isArray(t[o]),c=Array.isArray(a),h=!l&&c;h?t[o]=this._interpolationFunction(a,s):typeof a=="object"&&a?this._updateProperties(t[o],r,a,s):(a=this._handleRelativeValue(r,a),typeof a=="number"&&(t[o]=r+(a-r)*s))}},n.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},n.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];typeof i=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(i):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},n}(),Im="23.1.1",Mm=Sr.nextId,Xt=Lr,Em=Xt.getAll.bind(Xt),km=Xt.removeAll.bind(Xt),Dm=Xt.add.bind(Xt),hc=Xt.remove.bind(Xt),xm=Xt.update.bind(Xt),dc={Easing:Vt,Group:cc,Interpolation:Gi,now:pn,Sequence:Sr,nextId:Mm,Tween:oo,VERSION:Im,getAll:Em,removeAll:km,add:Dm,remove:hc,update:xm};function Sm(n,t,e,i=Vt.Linear.None){const s=new oo(n).to(t,e).easing(i).start();function o(r){s.update(r)&&requestAnimationFrame(o)}return requestAnimationFrame(o),s}var li=(n=>(n.Drawline="Drawline",n.Undo="Undo",n.Exit="Exit",n))(li||{});const cs=Symbol("$$PAINT_BRUSH_EVENT$$");function ro(n){return n[cs]||(n[cs]={}),n[cs]}function Lm(n){n[cs]||delete n[cs]}let Tm=class{hasListener(t){const e=ro(this);return e&&e[t]&&e[t].length>0}on(t,e,i){const s=ro(this);return s[t]||(s[t]=[]),s[t].push([e,i||!1]),()=>this.off(t,e)}once(t,e){return this.on(t,e,!0)}off(t,e){if(t===void 0){Lm(this);return}const i=ro(this);if(i[t]||(i[t]=[]),e===void 0){i[t].length=0;return}let s=0;for(;s<i[t].length&&i[t][s][0]!==e;s++);s<i[t].length&&i[t].splice(s,1)}emit(t,...e){let i=!1;const o=ro(this)[t]||[];for(let r of o.slice()){const[a,l=!1]=r,c=a(...e);l&&this.off(t,a),c===!1&&(i=!0)}return i}};function Ci(){return((1+Math.random())*65536|0).toString(16).substring(1)}function nt(){return(Ci()+Ci()+"-"+Ci()+"-4"+Ci().substr(0,3)+"-"+Ci()+"-"+Ci()+Ci()+Ci()).toLowerCase()}const jm=`
<style type="text/css">
#_gl_paintBrush {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
transform: translateZ(0);
z-index: 1997;
pointer-events: none;
opacity: 0;
transition: all 500ms;
}
#_gl_paintBrush.brushing {
opacity: 1;
}
#_gl_paintBrush ._paintBrush-canvas {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
#_gl_paintBrush ._paintBrush-canvas--sync {
pointer-events: none;
z-index: 0;
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
#_gl_paintBrush ._paintBrush-canvas {
pointer-events: none;
z-index: 1;
}
#_gl_paintBrush.brushing ._paintBrush-canvas {
pointer-events: auto;
}
#_gl_paintBrush ._paintBrush-ctrl {
width: 140px;
height: 52px;
position: absolute;
bottom: 28px;
right: 50%;
transform: translateX(50%);
font-size: 10px;
color: white;
z-index: 2;
}
#_gl_paintBrush.brushing ._paintBrush-ctrl {
pointer-events: auto;
}
#_gl_paintBrush ._paintBrush-ctrl ._paintBrush-ctrlinner {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 100%;
border-radius: 26px;
padding: 8px 16px;
box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.2);
background-image: linear-gradient(180deg, hsl(0deg 0% 0% / 57%), hsl(0deg 0% 0% / 70%) 117%);
}
._paintBrush-ctrlitem {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 38px;
height: 38px;
cursor: pointer;
}
._paintBrush-ctrlitem--undo >.brush-icon{
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyMnB4IiB2aWV3Qm94PSIwIDAgMjIgMjIiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8ZGVmcz4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjQ1LjY3NTI0OCUiIHgyPSItMTYuOTYxMDIzJSIgeTI9Ijg0LjIzODQxOTglIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkZGRkYiIG9mZnNldD0iMCUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgc3RvcC1vcGFjaXR5PSIwLjMwMzY3Njc5MiIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZGVmcz4KICAgIDxnIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xNDAuMDAwMDAwLCAtNzQwLjAwMDAwMCkiPgogICAgICAgICAgICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxNDAuMDAwMDAwLCA3NDAuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8cmVjdCBmaWxsPSIjRDhEOEQ4IiBvcGFjaXR5PSIwIiB4PSIwIiB5PSIwIiB3aWR0aD0iMjIiIGhlaWdodD0iMjIiPjwvcmVjdD4KICAgICAgICAgICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDQuMDAwMDAwLCAyLjk5MDY1OSkiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMCwzLjc1ODc1NzA5IEw5Ljg0Mzc1LDMuNzU4NzU3MDkgQzEyLjY5MTQ2ODIsMy43NTg3NTcwOSAxNSw2LjA2NzI4ODg1IDE1LDguOTE1MDA3MDkgQzE1LDExLjc2MjcyNTMgMTIuNjkxNDY4MiwxNC4wNzEyNTcxIDkuODQzNzUsMTQuMDcxMjU3MSBMMSwxNC4wNzEyNTcxIiBzdHJva2U9InVybCgjbGluZWFyR3JhZGllbnQtMSkiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cG9seWxpbmUgc3Ryb2tlPSIjRkZGRkZGIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBwb2ludHM9IjMuNzkwMjI3MDcgNy41Mzk2NjA2NCAwIDMuNzU4NzU3MDkgMy43OTAyMjcwNyAwIj48L3BvbHlsaW5lPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=);
background-size: 100%;
width: 22px;
height: 22px;
}
._paintBrush-ctrlitem--close >.brush-icon {
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyMnB4IiB2aWV3Qm94PSIwIDAgMjIgMjIiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8ZGVmcz4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwLjAyMDY5MyUiIHkxPSItMTMuNzMzMzc1MSUiIHgyPSI1MCUiIHkyPSIxMTQuMTEwOTk0JSIgaWQ9ImxpbmVhckdyYWRpZW50LTEiPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRkZGRkZGIiBvZmZzZXQ9IjAlIj48L3N0b3A+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkZGRkYiIHN0b3Atb3BhY2l0eT0iMC42MDEwNDM0ODgiIG9mZnNldD0iNDkuMzA4NDg4MiUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMTAwJSIgaWQ9ImxpbmVhckdyYWRpZW50LTIiPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRkZGRkZGIiBvZmZzZXQ9IjAlIj48L3N0b3A+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkZGRkYiIG9mZnNldD0iNTUuOTY4MTUzNSUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZGVmcz4KICAgIDxnIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnPgogICAgICAgICAgICA8cmVjdCBmaWxsPSIjRDhEOEQ4IiBvcGFjaXR5PSIwIiB4PSIwIiB5PSIwIiB3aWR0aD0iMjIiIGhlaWdodD0iMjIiPjwvcmVjdD4KICAgICAgICAgICAgPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNC4wMDAwMDAsIDUuMDAwMDAwKSIgZmlsbC1ydWxlPSJub256ZXJvIj4KICAgICAgICAgICAgICAgIDxnPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik03LC0yLjk4ODE2NTY4IEM3LjUxMjgzNTg0LC0yLjk4ODE2NTY4IDcuOTM1NTA3MTYsLTIuNjAyMTI1NDkgNy45OTMyNzIyNywtMi4xMDQ3ODY4MSBMOCwtMS45ODgxNjU2OCBMOCwxMy45OTgxMTQ2IEM4LDE0LjU1MDM5OTMgNy41NTIyODQ3NSwxNC45OTgxMTQ2IDcsMTQuOTk4MTE0NiBDNi40ODcxNjQxNiwxNC45OTgxMTQ2IDYuMDY0NDkyODQsMTQuNjEyMDc0NCA2LjAwNjcyNzczLDE0LjExNDczNTcgTDYsMTMuOTk4MTE0NiBMNiwtMS45ODgxNjU2OCBDNiwtMi41NDA0NTA0MyA2LjQ0NzcxNTI1LC0yLjk4ODE2NTY4IDcsLTIuOTg4MTY1NjggWiIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNy4wMDAwMDAsIDYuMDA0OTc0KSByb3RhdGUoLTQ1LjAwMDAwMCkgdHJhbnNsYXRlKC03LjAwMDAwMCwgLTYuMDA0OTc0KSAiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNNywtMi45ODgxNjU2OCBDNy41MTI4MzU4NCwtMi45ODgxNjU2OCA3LjkzNTUwNzE2LC0yLjYwMjEyNTQ5IDcuOTkzMjcyMjcsLTIuMTA0Nzg2ODEgTDgsLTEuOTg4MTY1NjggTDgsMTMuOTk4MTE0NiBDOCwxNC41NTAzOTkzIDcuNTUyMjg0NzUsMTQuOTk4MTE0NiA3LDE0Ljk5ODExNDYgQzYuNDg3MTY0MTYsMTQuOTk4MTE0NiA2LjA2NDQ5Mjg0LDE0LjYxMjA3NDQgNi4wMDY3Mjc3MywxNC4xMTQ3MzU3IEw2LDEzLjk5ODExNDYgTDYsLTEuOTg4MTY1NjggQzYsLTIuNTQwNDUwNDMgNi40NDc3MTUyNSwtMi45ODgxNjU2OCA3LC0yLjk4ODE2NTY4IFoiIGZpbGw9InVybCgjbGluZWFyR3JhZGllbnQtMikiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDcuMDAwMDAwLCA2LjAwNDk3NCkgcm90YXRlKC0xMzUuMDAwMDAwKSB0cmFuc2xhdGUoLTcuMDAwMDAwLCAtNi4wMDQ5NzQpICI+PC9wYXRoPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=);
background-size: 100%;
width: 22px;
height: 22px;
}
</style>
`;let zm=class extends Tm{constructor(e){super();d(this,"configs");d(this,"clientWidth");d(this,"clientHeight");d(this,"ready",!1);d(this,"uuid",nt());d(this,"tween");d(this,"tweening",!1);d(this,"container");d(this,"canvas");d(this,"data",{});d(this,"tempLine",{});this.configs=e,this.clientWidth=document.body.clientWidth,this.clientHeight=document.body.clientHeight,this.container=this.ifInsertToDOM(),this.canvas={},this.initCtrl()}get color(){return this.configs.currentColor}get state(){return this.data}get dpr(){return this.configs.DPR||1}ifInsertToDOM(){if(this.container)return this.container;if(this.configs.container)this.configs.container.id="_gl_paintBrush",this.container=this.configs.container;else if(document.getElementById("_gl_paintBrush"))this.container=document.getElementById("_gl_paintBrush");else{const e=document.createElement("div");e.id="_gl_paintBrush",document.body.appendChild(e),this.container=e}return this.container.innerHTML=jm,this.container}initCanvas(e){const i=document.createElement("canvas");i.className=e,i.width=this.clientWidth,i.height=this.clientHeight;const s=i.getContext("2d");if(s)return s.lineWidth=5*this.dpr,s.lineCap="round",s.lineJoin="round",this.container.appendChild(i),i}initCtrl(){const e=document.createElement("div");e.className="_paintBrush-ctrl";const i=document.createElement("div");i.className="_paintBrush-ctrlinner";const s=document.createElement("a");s.className="_paintBrush-ctrlitem _paintBrush-ctrlitem--undo",s.addEventListener("click",a=>{var f;if(a.stopPropagation(),this.configs.onClickUndo&&this.configs.onClickUndo(),!this.canvas[this.uuid]||!this.data[this.uuid]||this.data[this.uuid].length===0)return;const l=this.data[this.uuid].pop();l&&this.emitStateChange({type:li.Undo,color:this.color,ready:this.ready,state:l,uuid:this.uuid});const c=(f=this.canvas[this.uuid])==null?void 0:f.getContext("2d");if(!this.canvas[this.uuid])return;const{width:h,height:u}=this.canvas[this.uuid];c&&c.clearRect(0,0,h,u),this.data[this.uuid].forEach(g=>this.handleDrawLine(this.uuid,g,{withUndo:!0}))});const o=document.createElement("a");return o.className="_paintBrush-ctrlitem _paintBrush-ctrlitem--close",o.addEventListener("click",a=>{a.stopPropagation(),this.closeBrush(),this.configs.onClickClose&&this.configs.onClickClose()}),[s,o].forEach(a=>{const l=document.createElement("i");l.className="brush-icon";const c=document.createElement("span");c.className="brush-txt",c.innerText=a.className.endsWith("undo")?this.configs.onUndoText:this.configs.onExitText,a.appendChild(l),a.appendChild(c)}),i.appendChild(s),i.appendChild(o),e.appendChild(i),this.container.appendChild(e),e}openBrush(){if(this.ready)return;this.canvas[this.uuid]||(this.canvas[this.uuid]=this.initCanvas("_paintBrush-canvas")),this.container.className="brushing";const e=this.canvas[this.uuid];e.getContext("2d").clearRect(0,0,e.width,e.height),this.openBrushHandle(),this.ready=!0,this.emit("readyChange",!0)}closeBrush(){this.ready&&(this.container.className="",this.data={},this.tempLine={},Object.keys(this.canvas).forEach(e=>{this.canvas[e].ontouchstart=()=>!1,this.canvas[e].ontouchmove=()=>!1,this.canvas[e].ontouchend=()=>!1,this.canvas[e].ontouchcancel=()=>!1;const i=this.canvas[e].getContext("2d");i&&i.clearRect(0,0,this.canvas[e].width,this.canvas[e].height)}),this.ready=!1,this.emit("readyChange",!1),this.emitStateChange({type:li.Exit,color:this.color,ready:!1,uuid:this.uuid}))}updateCurrentColor(e){const i=this.canvas[this.uuid];if(!i)return;const s=i.getContext("2d");s&&(this.configs.currentColor=e,s.strokeStyle=e)}openBrushHandle(){const e=this.canvas[this.uuid];if(!e)return;const i=e.getContext("2d");if(!i)return;const s=this.color||"#6D92FF";i.strokeStyle=s;let o=null,r=[],a,l=[],c=0;const h=(u,f,g)=>{const A=this.color||"#ff0000";i.strokeStyle=A,i.beginPath(),i.moveTo(u.x,u.y),i.quadraticCurveTo(f.x,f.y,g.x,g.y),i.stroke()};e.onmousedown=u=>{u.preventDefault(),c=Date.now();const f=u.clientX,g=u.clientY;r=[],r.push({x:f,y:g}),o={x:f,y:g},a=io({x:f,y:g},this.clientWidth,this.clientHeight),l=[]},e.onmousemove=u=>{if(u.preventDefault(),!o)return;const f=Number(u.clientX),g=Number(u.clientY);if(Math.abs(f-o.x)<5&&Math.abs(g-o.y)<5||(r.push({x:f,y:g}),l.push(io({x:f,y:g},this.clientWidth,this.clientHeight)),r.length<3))return;const{control:A,end:p}=no(r);!A||!p||(h(o,A,p),o=p)},e.onmouseup=u=>{if(u.preventDefault(),o=null,r.length<3)return;this.data[this.uuid]||(this.data[this.uuid]=[]);const f=Date.now()-c,g={move:Object.assign({},a),uuid:this.uuid,line:[...l],color:this.color,duration:f<1280?f:f<2e3?1280:0};this.data[this.uuid].push(g),so(()=>{this.emitStateChange({type:li.Drawline,color:this.color,ready:this.ready,state:g,uuid:this.uuid})})},e.ontouchstart=u=>{u.preventDefault(),c=Date.now();const f=u.touches[0].clientX,g=u.touches[0].clientY;r=[],r.push({x:f,y:g}),o={x:f,y:g},a=io({x:f,y:g},this.clientWidth,this.clientHeight),l=[]},e.ontouchmove=u=>{if(u.preventDefault(),!o)return;const f=Number(u.touches[0].clientX),g=Number(u.touches[0].clientY);if(Math.abs(f-o.x)<5&&Math.abs(g-o.y)<5||(r.push({x:f,y:g}),l.push(io({x:f,y:g},this.clientWidth,this.clientHeight)),r.length<3))return;const{control:A,end:p}=no(r);!A||!p||(h(o,A,p),o=p)},e.ontouchend=e.ontouchcancel=u=>{if(u.preventDefault(),o=null,r.length<3)return;this.data[this.uuid]||(this.data[this.uuid]=[]);const f=Date.now()-c,g={move:Object.assign({},a),line:[...l],uuid:this.uuid,color:this.color,duration:f<1280?f:f<2e3?1280:0};this.data[this.uuid].push(g),so(()=>{this.emitStateChange({type:li.Drawline,color:this.color,ready:this.ready,state:g,uuid:this.uuid})})}}emitStateChange(e,i=!0){if(e.type!==li.Drawline){this.emit("stateChange",e,i);return}const s=Date.now(),o=e.state;if(!o||!o.line)return;const r=Math.ceil(o.line.length/100);for(let a=0;a<r;a++){const l={uuid:this.uuid,color:this.color,ready:this.ready,type:e.type,state:{uuid:this.uuid,move:o.move,duration:o.duration,color:this.color,line:o.line.slice(a*100,(a+1)*100)},timestamp:s,end:a===r-1};Cm(a,20,()=>{this.emit("stateChange",l,i)})}}action(e){const{ready:i,type:s,uuid:o}=e;if(!i&&this.ready){this.closeBrush();return}if(i&&!this.ready){this.openBrush();return}if(this.ready)switch(s){case li.Drawline:const{state:r,timestamp:a,end:l}=e;if(!a||!r)return;this.tempLine[a]=[].concat(this.tempLine[a]||[],r.line),l&&(Object.assign(r,{line:this.tempLine[a]}),this.handleDrawLine(o,r,{},()=>delete this.tempLine[a]));break;case li.Undo:this.handleUndo(o);break}}handleDrawLine(e,i,{withUndo:s=!1},o=oc){!i||Object.prototype.toString.call(i)!="[object Object]"||Object.keys(i).length===0||wm(()=>new Promise(r=>{if(s||(this.canvas[e]||(this.canvas[e]=this.initCanvas("_paintBrush-canvas--sync")),this.data[e]||(this.data[e]=[]),this.data[e].push(i)),!this.canvas[e])return;const a=this.canvas[e].getContext("2d");if(!a)return;const{line:l=[],color:c="black",duration:h=0,uuid:u}=i,f=xr(i.move||{},this.clientWidth,this.clientHeight);let g=[f];if(a.strokeStyle=c,a.beginPath(),a.moveTo(f.x,f.y),h&&!s){let A=[];const p=this;p.tween=Sm({step:0},{step:l.length-1},h).onUpdate(({step:m})=>{var y;if(p.tweening=!0,!p.ready)return a.clearRect(0,0,p.canvas[u].width,p.canvas[u].height),(y=p.tween)==null?void 0:y.stop();const b=Math.floor(m);if(!A.find(P=>P===b)){if(A.push(b),g.push(xr(l[b],p.clientWidth,p.clientHeight)),g.length<3)return;const{control:P,end:I}=no(g);if(!P||!I)return;a.quadraticCurveTo(P.x,P.y,I.x,I.y),a.stroke()}}).onComplete(m=>{p.tween=void 0,p.tweening=!1,A=[],g=[],o&&o(),r()})}else{for(let A=0;A<l.length;A++){if(g.push(xr(l[A],this.clientWidth,this.clientHeight)),g.length<3)continue;const{control:p,end:m}=no(g);!p||!m||a.quadraticCurveTo(p.x,p.y,m.x,m.y)}a.stroke(),g=[],o&&o(),r()}}))}handleUndo(e){if(!this.canvas[e]||!this.data[e]||this.data[e].length===0)return;this.data[e].pop();const i=()=>{var o;const s=(o=this.canvas[e])==null?void 0:o.getContext("2d");s&&s.clearRect(0,0,this.canvas[e].width,this.canvas[e].height),this.data[e].forEach(r=>this.handleDrawLine(e,r,{withUndo:!0}))};if(this.tween&&this.tweening){this.tween.stop(),so(i,60);return}i()}destroyBrush(){this.closeBrush(),this.ready=!1,this.emit("readyChange",!0)}};class Om{constructor(t={}){d(this,"controller");const e=Object.assign({currentColor:"#f44336",onUndoText:"回退",onExitText:"关闭"},t);this.controller=new zm(e)}on(t,e){this.controller.on(t,e)}off(t,e){this.controller.off(t,e)}once(t,e){this.controller.once(t,e)}show(){this.controller.openBrush()}action(t){this.controller.action(t)}get state(){return this.controller.state}get configs(){return this.controller.configs}dispose(){return this.controller.destroyBrush()}setCurrentColor(t){this.controller.updateCurrentColor(t)}}const Bm=(n,t)=>{var _,N;let e=(N=(_=t==null?void 0:t.initialState)==null?void 0:_.enabled)!=null?N:!0,i=!1,s=!0,o=null;const a=x(x({},{lookAtCurrentCamera:!1,lockedPanoIndex:null,lockedLatitude:null,lockedLongitude:null}),t==null?void 0:t.config),l=new w.Scene,c=new ve.Camera(60);let h=new w.Object3D,u,f;{const H=new w.DirectionalLight(16777215,.5);H.position.copy(new w.Vector3(1,1,1)),l.add(H)}{const H=new w.DirectionalLight(16777215,.3);l.add(H)}{const H=new w.AmbientLight(16777215,.3);l.add(H)}l.add(h);const g=()=>{if(i)return;u=k(n.model,c.fov,c.aspect),f=n.model.bounding.getCenter(new w.Vector3),l.remove(h),h=Y(n.model),l.add(h),i=!0,j();function H(q){const Z=q.clone();return Z.uniforms.modelAlpha.value=1,Z.uniforms.map.value&&(Z.uniforms.map.value.needsUpdate=!0),Z}function Y(q){if(q instanceof w.Mesh){const Z=q.geometry,te=Array.isArray(q.material)?q.material.map(H):H(q.material);return new w.Mesh(Z,te)}else if(q instanceof w.Group){const Z=new w.Group;return q.children.forEach(te=>Z.add(Y(te))),Z}else{const Z=new w.Object3D;return q.children.forEach(te=>Z.add(Y(te))),Z}}},A=()=>{if(n.renderer)return o||(o=new w.WebGLRenderer({antialias:!1,alpha:!0}),o.setPixelRatio(n.renderer.getPixelRatio()),o.outputEncoding=w.sRGBEncoding,o.setClearColor(1579548,0),o.autoClear=!0),o},p=()=>{h.traverse(H=>{H instanceof w.Mesh&&[].concat(H.material).forEach(q=>q.dispose())}),l.remove(h),h=new w.Object3D,l.add(h),i=!1,j()},m=()=>{e&&(i||g())},b=()=>{e||(e=!0,l.add(h),!i&&n.model.loaded&&g(),j())},y=()=>{e&&(l.remove(h),s=!0,R(),e=!1)},P=(H,Y={})=>{const q=A();if(!q)return;H.appendChild(q.domElement),I(Y);const Z=window.getComputedStyle(H).position;Z!=="relative"&&Z!=="absolute"&&Z!=="fixed"&&Z!=="sticky"&&(H.style.position="relative")},I=(H={})=>{if(!o)return;const q=o.domElement.parentNode;if(q!=null&&q.nodeName){const{width:Z=q.offsetWidth,height:te=q.offsetHeight}=H;o.setSize(Z,te),c.aspect=Z/te,c.updateProjectionMatrix()}j()};function k(H,Y,q){const Z=H.bounding,te=Math.pow(Math.pow(Z.max.x-Z.min.x+1,2)+Math.pow(Z.max.y-Z.min.y+1,2)+Math.pow(Z.max.z-Z.min.z+1,2),1/2);let ge=te/2/Math.tan(Math.PI*Y/360);return q<1&&(ge=ge/q),isNaN(ge)?te:ge}function M(H){return n.work.observers[H].standingPosition.clone()}const j=()=>{if(!e||!u||!f)return;const H=n.getPose();H.fov=c.fov,H.offset=f,H.distance=u,typeof a.lockedLatitude=="number"&&(H.latitude=a.lockedLatitude),typeof a.lockedLongitude=="number"&&(H.longitude=a.lockedLongitude),typeof a.lockedPanoIndex=="number"&&(H.offset=M(a.lockedPanoIndex)),a.lookAtCurrentCamera&&(H.offset=n.camera.position.clone().setY(n.camera.position.y+1)),c.setFromPose(H),s=!0},R=()=>{!e||s!==!0||!o||!o.domElement.parentNode||o.domElement.parentNode.offsetWidth===0||(o.render(l,c),s=!1)},U=()=>{o&&o.dispose(),o=null},W=H=>{Object.assign(a,H),j()},Q=()=>({enabled:e});return Object.assign(window,{camera:c}),n.on("modelLoaded",m),n.on("modelWillLoad",p),n.on("cameraDirectionUpdate",j),n.on("dispose",U),n.on("renderFrame",R),n.on("cameraPositionUpdate",j),{appendTo:P,refresh:I,changeConfigs:W,enable:b,disable:y,getCurrentState:Q}},Vm=({x:n,y:t,z:e})=>new G.Vector3(n,t,e),ci=n=>new G.Vector3().fromArray(n),Be=n=>{if(n)return n instanceof G.Vector3?n:Array.isArray(n)?ci(n):Vm(n)};function Rm(n){if(n)return Array.isArray(n)?typeof n[0]=="number"?Be(n):n.map(Be):Be(n)}function hi(n){return arguments.length===0?[]:Array.isArray(n)?n:[n]}function Qi(n){const t=[];return hi(n).forEach(i=>{i.traverse(s=>{s.isCSS3DObjectPlus&&t.push(s)})}),t}function ao(n,t){const e=Math.round(n);return e%2===0?e:e+(t!=null&&t.floor?-1:1)}function Nm(n,t,e=!0){if(!n)return console.error("createResizeObserver: element is undefined"),{observe:()=>{},unobserve:()=>{}};const i=()=>{const o=ao(n.clientWidth,{floor:!0}),r=ao(n.clientHeight,{floor:!0});t(o,r)};if(typeof ResizeObserver=="undefined"||!ResizeObserver)return console.warn("createResizeObserver: ResizeObserver is undefined"),{observe:()=>i(),unobserve:()=>{}};const s=new ResizeObserver(i);return e&&i(),{observe:()=>s.observe(n),unobserve:()=>s.unobserve(n)}}class uc extends Ri.CSS3DRenderer{constructor(){super();d(this,"wrapper");d(this,"requestAnimationFrameId");d(this,"resizeDisoper");this.domElement.classList.add("ICSS3DRenderer"),this.domElement.style.position="absolute",this.domElement.style.top="0",this.domElement.style.left="0",this.domElement.style.userSelect="none",this.domElement.style.pointerEvents="none"}setWrapper(e){if(!e)throw new Error("CSS3DRenderer: wrapper is required");if(e.contains(this.domElement))return;const i=this.wrapper;return i&&i.contains(this.domElement)&&this.domElement.remove(),this.appendToElement(e),this.wrapper=e,this}appendToElement(e){e.appendChild(this.domElement);const i=(r,a)=>this.setSize(r,a),{observe:s,unobserve:o}=Nm(e,i,!0);s(),this.resizeDisoper=o,this.wrapper=e}renderEveryFrame(e,i){if(this.wrapper||console.warn("wrapper is not find, creating a html element and call setWrapper(wrapper)",this,e),this.requestAnimationFrameId)return;const s=()=>{this.requestAnimationFrameId=requestAnimationFrame(s),e.visible&&Qi(e).length!==0&&this.render(e,i)};s()}stopRender(){this.requestAnimationFrameId&&cancelAnimationFrame(this.requestAnimationFrameId)}dispose(){var e;this.stopRender(),(e=this.resizeDisoper)==null||e.call(this),this.domElement.remove()}}function Gm(n){return typeof Symbol=="undefined"?`$Symbol<${n}>$`:Symbol(n)}const hs=Gm("$$EVENT$$");function lo(n){return n[hs]||(n[hs]={}),n[hs]}function Qm(n){n[hs]&&delete n[hs]}class Zt{hasListener(t){const e=lo(this);return!!(e!=null&&e[t]&&e[t].length>0)}on(t,e,i){const s=lo(this);return s[t]||(s[t]=[]),s[t].push([e,i||!1]),()=>this.off(t,e)}once(t,e){return this.on(t,e,!0)}off(t,e){if(t===void 0){Qm(this);return}const i=lo(this);if(i[t]||(i[t]=[]),e===void 0){i[t].length=0;return}let s=0;for(;s<i[t].length&&i[t][s][0]!==e;s++);s<i[t].length&&i[t].splice(s,1)}emit(t,...e){let i=!1;const o=lo(this)[t]||[];for(let r of o.slice()){const[a,l=!1]=r,c=a(...e);l&&this.off(t,a),c===!1&&(i=!0)}return i}}class Fm extends w.Mesh{constructor(e,i){const s=new w.MeshBasicMaterial({opacity:0,color:0,transparent:!1,side:w.DoubleSide}),o=new w.PlaneGeometry(e,i);super(o,s);d(this,"name","opacity-mesh")}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}}function Pi(...n){const t=new G.Vector3;return n.forEach(e=>t.add(e)),t.divideScalar(n.length),t}const Tr=n=>n?n.visible===!1?!1:Tr(n.parent):!0,fc=1,_m=`CSS3DObjectPlus@${fc}`,Hm=.00216,Wm=.003;class Um extends Ri.CSS3DObject{constructor(e){var k,M,j;const i=e.container,s=e.cornerPoints,o=(k=e.ratio)!=null?k:Wm,r=(M=e.dpr)!=null?M:1,a=(j=e.pointerEvents)!=null?j:"auto",l=Math.max(Hm,o),c=s[0].distanceTo(s[1]),h=s[1].distanceTo(s[2]),u=ao(c/o*r),f=ao(h/o*r),g=Pi(...s);let A;if(l===o)i.style.width=`${u}px`,i.style.height=`${f}px`,A=i;else{const R=document.createElement("div");R.style.width=`${u}px`,R.style.height=`${f}px`,R.style.pointerEvents="none";const U=o/l;i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.width=`${U*u}px`,i.style.height=`${U*f}px`,R.appendChild(i),A=R}super(A);d(this,"version",fc);d(this,"isCSS3DObjectPlus",!0);d(this,"container");d(this,"width");d(this,"height");d(this,"domWidthPx");d(this,"domHeightPx");d(this,"cornerPoints");d(this,"centerPosition");d(this,"ratio");d(this,"mode","front");d(this,"hooks",new Zt);d(this,"opacityMesh");d(this,"selfVisible",!0);d(this,"setVisible",e=>{this.selfVisible=e,this.visible=Tr(this.parent)&&this.selfVisible,this.opacityMesh&&(this.opacityMesh.visible=this.visible)});d(this,"updateVisible",()=>{this.setVisible(this.selfVisible)});d(this,"createOpacityMesh",e=>{const{domWidthPx:i,domHeightPx:s}=e,o=new Fm(i,s);return o.position.copy(e.position),o.rotation.copy(e.rotation),o.scale.copy(e.scale),o});if(i.style.pointerEvents=a,Object.assign(i.style,e.style),this.scale.set(l,l,l),this.cornerPoints=s,this.ratio=o,this.container=i,e.mode&&(this.mode=e.mode),l===o)this.width=c,this.height=h,this.domWidthPx=u,this.domHeightPx=f,this.centerPosition=g;else{const R=o/l;this.width=R*c,this.height=R*h,this.domWidthPx=R*u,this.domHeightPx=R*f,this.centerPosition=new G.Vector3().subVectors(g,s[0]).multiplyScalar(R).add(s[0])}i.classList.add(`${_m}__container`);const p=new G.Vector3().subVectors(s[1],s[0]),m=new G.Vector3().subVectors(s[3],s[0]),b=new G.Vector3().crossVectors(p,m).normalize();this.lookAt(b);const y=this.up.clone().applyQuaternion(this.quaternion),P=m.clone(),I=new G.Vector3().crossVectors(y,P).normalize();this.rotateOnWorldAxis(I,y.angleTo(P)),this.position.copy(g),this.addEventListener("added",()=>{var R;this.mode==="front"&&((R=this.opacityMesh)==null||R.removeFromParent())}),this.addEventListener("removed",()=>{var R;(R=this.opacityMesh)==null||R.removeFromParent()})}removeFromParent(){var i;const e=this.parent;return e!==null&&e.remove(this),(i=this.opacityMesh)==null||i.removeFromParent(),this}removeOpacityMesh(){var e;return(e=this.opacityMesh)==null||e.removeFromParent(),this.opacityMesh=void 0,this}dispose(){var e;this.container.remove(),this.removeFromParent(),(e=this.opacityMesh)==null||e.removeFromParent()}getOpacityMesh(){if(this.opacityMesh)return this.opacityMesh;{const e=this.createOpacityMesh(this);return this.opacityMesh=e,e}}applyMatrix4(e){var i;super.applyMatrix4(e),(i=this.opacityMesh)==null||i.applyMatrix4(e)}applyQuaternion(e){var i;return super.applyQuaternion(e),(i=this.opacityMesh)==null||i.applyQuaternion(e),this}applyScaleMatrix4(e){var i;this.scale.applyMatrix4(e),(i=this.opacityMesh)==null||i.scale.applyMatrix4(e)}}class Ym extends w.Scene{constructor(){super()}add(...t){return super.add(...t),Qi(t).forEach(e=>{e.mode="front"}),this}}class Xm extends w.Scene{constructor(e){super();d(this,"scene");if(!e)throw new Error("CSS3DBehindScene: scene is required");this.scene=e}add(...e){return super.add(...e),Qi(e).forEach(i=>{i.mode="behind",this.scene.add(i.getOpacityMesh())}),this}remove(...e){return Qi(e).forEach(i=>{var s;(s=i.opacityMesh)==null||s.removeFromParent(),i.opacityMesh=null}),super.remove(...e),this}}class gc extends w.Group{constructor(e){super();d(this,"isCSS3DGroup",!0);d(this,"mode");d(this,"CSS3DObjectLength",0);this.mode=e}add(...e){return Qi(e).forEach(i=>{i.mode=this.mode}),super.add(...e),this.updateLength(),this}setVisible(e){this.visible=e,this.traverse(i=>{i.isCSS3DObjectPlus&&i.updateVisible()})}remove(...e){return super.remove(...e),this.updateLength(),this}updateLength(){this.CSS3DObjectLength=Qi(this).length}}class Zm extends gc{constructor(){super("front")}}class Jm extends gc{constructor(e){super("behind");d(this,"scene");if(!e)throw new Error("CSS3DBehindScene: scene is required");this.scene=e}add(...e){return Qi(e).forEach(i=>{this.scene.add(i.getOpacityMesh())}),super.add(...e),this}}const qm=3,jr="CSS3DRenderer",ds=`${jr}@${qm}`,An=()=>{console.error(`${ds} is disposed`)},Ke={css3DObjects:[],frontModeStore:{css3DRenderer:(()=>{const n=new uc;return n.domElement.style.zIndex="1",n})()},behindModeStore:{css3DRenderer:new uc}};function mc(n){return Ke.css3DObjects.find(t=>t.id===n)}function Km(n){Ke.frontModeStore.css3DRenderer.setWrapper(n)}function $m(n){Ke.behindModeStore.css3DRenderer.setWrapper(n)}class vn{constructor(t){d(this,"hooks",new Zt);d(this,"state",{enabled:!0,visible:!0,disposed:!1});d(this,"_scene");d(this,"store",{frontModeGroup:new Zm});d(this,"create3DElement",(t,e,i)=>{if(this.state.disposed)return An();const s=(()=>{const k={ratio:.00216,devicePixelRatio:1,mode:"front",autoRender:!0,container:document.createElement("div"),pointerEvents:"none",wrapperStyle:{}};return Object.assign(k,i)})(),o=e.map(Be);if((o==null?void 0:o.length)<4)return console.error(`${ds}: requires 4 point but params may have fewer`);const{ratio:r,devicePixelRatio:a,mode:l,autoRender:c,container:h,pointerEvents:u,wrapperStyle:f}=s;let g=!1;const A=this.createObject(o,{ratio:r,dpr:a,container:h,mode:l,pointerEvents:u,wrapperStyle:f});Ke.css3DObjects.push(A),s.scene&&this.setScene(s.scene);const p=()=>{if(g)return;const k=A.mode==="front"?this.getFrontCSS3DObjectGroup():this.getBehindCSS3DObjectGroup();k&&k.add(A)},m=()=>{g||(p(),this.render(t),this.hooks.emit("render"))},b=k=>this.setVisibleById(A.id,k),y=k=>this.setEnabledById(A.id,k),P=()=>(g=!0,A.removeFromParent(),!0),I=l==="front"?Ke.frontModeStore.css3DRenderer:Ke.behindModeStore.css3DRenderer;return c&&m(),{id:A.uuid,container:h,css3DObject:A,render:c?void 0:m,show:()=>b(!0),hide:()=>b(!1),setVisible:b,enable:()=>y(!0),disable:()=>y(!1),setEnabled:y,dispose:P,appendToElement:k=>I.setWrapper(k)}});d(this,"setVisibleById",(t,e)=>{var i;(i=mc(t))==null||i.setVisible(e)});d(this,"setEnabledById",(t,e)=>{const i=mc(t);if(!i)return;const s=i.mode==="front"?this.getFrontCSS3DObjectGroup({addGroupIfNotExists:!1}):this.getBehindCSS3DObjectGroup({addGroupIfNotExists:!1});s&&(e?s.add(i):s.remove(i))});d(this,"createObject",(t,e)=>{const i=new Um(re(x({cornerPoints:t},e),{style:e.wrapperStyle}));return i.element.classList.add(`${jr}__container`),i.element.id=`${jr}__container--${i.uuid}`,i});t&&this.setScene(t)}get scene(){return this._scene||console.error("scene doesn't exist!, please call setScene(scene) first"),this._scene}static get frontModeCSS3DRenderer(){return Ke.frontModeStore.css3DRenderer}static get behindModeCSS3DRenderer(){return Ke.behindModeStore.css3DRenderer}get frontModeCSS3DRenderer(){return Ke.frontModeStore.css3DRenderer}get behindModeCSS3DRenderer(){return Ke.behindModeStore.css3DRenderer}setScene(t){this._scene=t}getCurrentState(){return this.state}setState(t,e={userAction:!0}){if(this.state.disposed)return An();const i=x({},this.state);this.state=Object.assign(this.state,t),i.visible!==this.state.visible&&(t.visible?this.handleShow():this.handleHide()),i.enabled!==this.state.enabled&&(t.enabled?this.handleEnable():this.handleDisable()),i.disposed!==this.state.disposed&&this.handleDispose(),this.hooks.emit("stateChange",{state:this.state,prevState:i,userAction:e.userAction})}dispose(){this.setState({disposed:!0}),this.hooks.emit("dispose")}show(){return F(this,arguments,function*({userAction:t}={userAction:!0}){if(this.state.disposed)return An();this.setState({visible:!0},{userAction:t}),this.hooks.emit("show",{userAction:t})})}hide(){return F(this,arguments,function*({userAction:t}={userAction:!0}){if(this.state.disposed)return An();this.setState({visible:!1},{userAction:t}),this.hooks.emit("hide",{userAction:t})})}enable({userAction:t}={userAction:!0}){if(this.state.disposed)return An();this.setState({enabled:!0},{userAction:t}),this.hooks.emit("enable",{userAction:t})}disable({userAction:t}={userAction:!0}){if(this.state.disposed)return An();this.setState({enabled:!1},{userAction:t}),this.hooks.emit("disable",{userAction:t})}getFrontCSS3DScene({createSceneIfNotExists:t=!1}={}){var i;const e=(i=Ke.frontModeStore)==null?void 0:i.css3DScene;if(e)return e;if(t){const s=new Ym;Ke.frontModeStore.css3DScene=s}return Ke.frontModeStore.css3DScene}getBehindCSS3DScene({createSceneIfNotExists:t=!1}={}){var i,s;const e=(i=Ke.behindModeStore)==null?void 0:i.css3DScene;if(e)return e;if(t){const o=(s=Ke.behindModeStore.scene)!=null?s:this.scene;if(!o){console.error(`${ds}: scene is required when mode is behind`);return}const r=new Xm(o);Ke.behindModeStore.css3DScene=r,Ke.behindModeStore.scene=o}return Ke.behindModeStore.css3DScene}getFrontCSS3DObjectGroup({addGroupIfNotExists:t=!0}={}){const e=this.getFrontCSS3DScene({createSceneIfNotExists:t});return t&&e&&(e.getObjectById(this.store.frontModeGroup.id)||e.add(this.store.frontModeGroup)),this.store.frontModeGroup}getBehindCSS3DObjectGroup({addGroupIfNotExists:t=!0}={}){var i;const e=this.getBehindCSS3DScene({createSceneIfNotExists:t});if(t&&e&&this.scene){const s=(i=this.store.behindModeGroup)!=null?i:new Jm(this.scene);this.store.behindModeGroup=s,e.getObjectById(s.id)||e.add(s)}return this.store.behindModeGroup}render(t){var e,i;if(this.getFrontCSS3DObjectGroup({addGroupIfNotExists:!1}).CSS3DObjectLength>0){const s=this.getFrontCSS3DScene({createSceneIfNotExists:!0});if(!s)return console.error(`${ds}: css3DScene is required when mode is front`);Ke.frontModeStore.css3DRenderer.renderEveryFrame(s,t)}if(((i=(e=this.getBehindCSS3DObjectGroup({addGroupIfNotExists:!1}))==null?void 0:e.CSS3DObjectLength)!=null?i:0)>0){const s=this.getBehindCSS3DScene({createSceneIfNotExists:!0});if(!s)return console.error(`${ds}: css3DScene is required when mode is behind`);Ke.behindModeStore.css3DRenderer.renderEveryFrame(s,t)}}handleShow(){return F(this,null,function*(){var t;this.store.frontModeGroup.setVisible(!0),(t=this.store.behindModeGroup)==null||t.setVisible(!0)})}handleHide(){return F(this,null,function*(){var t;this.store.frontModeGroup.setVisible(!1),(t=this.store.behindModeGroup)==null||t.setVisible(!1)})}handleEnable(){var t,e;(t=this.getFrontCSS3DScene())==null||t.add(this.store.frontModeGroup),this.store.behindModeGroup&&((e=this.getBehindCSS3DScene())==null||e.add(this.store.behindModeGroup))}handleDisable(){var t,e,i;this.store.frontModeGroup.children.forEach(s=>{s instanceof Ri.CSS3DObject&&s.element instanceof Element&&s.element.parentNode!==null&&s.element.remove()}),(t=this.store.behindModeGroup)==null||t.children.forEach(s=>{s instanceof Ri.CSS3DObject&&s.element instanceof Element&&s.element.parentNode!==null&&s.element.remove()}),(e=this.getFrontCSS3DScene())==null||e.remove(this.store.frontModeGroup),this.store.behindModeGroup&&((i=this.getBehindCSS3DScene())==null||i.remove(this.store.behindModeGroup))}handleDispose(){this.handleDisable(