@realsee/dnalogel 3.47.1 → 3.47.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.js +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/shared-utils/three/PointSelector/index.d.ts +2 -1
- package/libs/base/BasePlugin.js +1 -1
- package/libs/shared-utils/logger.js +1 -1
- package/libs/shared-utils/three/PointSelector/index.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Gm=Object.defineProperty,Qm=Object.defineProperties;var Wm=Object.getOwnPropertyDescriptors;var mo=Object.getOwnPropertySymbols;var Ac=Object.prototype.hasOwnProperty,bc=Object.prototype.propertyIsEnumerable;var ga=(n,t,e)=>t in n?Gm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,x=(n,t)=>{for(var e in t||(t={}))Ac.call(t,e)&&ga(n,e,t[e]);if(mo)for(var e of mo(t))bc.call(t,e)&&ga(n,e,t[e]);return n},ie=(n,t)=>Qm(n,Wm(t));var Cn=(n,t)=>{var e={};for(var i in n)Ac.call(n,i)&&t.indexOf(i)<0&&(e[i]=n[i]);if(n!=null&&mo)for(var i of mo(n))t.indexOf(i)<0&&bc.call(n,i)&&(e[i]=n[i]);return e};var d=(n,t,e)=>(ga(n,typeof t!="symbol"?t+"":t,e),e);var Q=(n,t,e)=>new Promise((i,s)=>{var o=l=>{try{a(e.next(l))}catch(c){s(c)}},r=l=>{try{a(e.throw(l))}catch(c){s(c)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,r);a((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ze=require("@realsee/five"),W=require("three"),Go=require("three/examples/jsm/renderers/CSS3DRenderer"),fr=require("hammerjs"),gr=require("@realsee/five/line"),Qo=require("animejs"),bf=require("three/examples/jsm/loaders/FBXLoader"),Um=require("earcut"),Ym=require("@realsee/five/gltf-loader");function Xm(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 y=Xm(W);function Zm(){console.debug("%c %c@realsee/dnalogel %cv3.47.1",["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 Jm(){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 yf(){}const yc=()=>Promise.resolve(),wc={__queue:Promise.resolve()};function qm(n=yc){wc.__queue=wc.__queue.then(n).catch(yc)}function po(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 ma(n,t,e){const{x:i,y:s}=n,o=i*t,r=s*e;return{x:o,y:r}}function vo(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 Km(n,t,e=yf){new Promise(i=>{setTimeout(()=>{e(),i(!0)},t*n)})}const $m=window,Cc=window.requestAnimationFrame||$m.webkitRequestAnimationFrame||(n=>setTimeout(n,16));function Bo(n,t=0){t<=0?Cc(n):Cc(()=>Bo(n,t-1))}var ii=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-ii.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?ii.Bounce.In(n*2)*.5:ii.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}}}}),Sn=function(){return performance.now()},wf=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=Sn()),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}(),Xi={Linear:function(n,t){var e=n.length-1,i=e*t,s=Math.floor(i),o=Xi.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=Xi.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=Xi.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=Xi.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}}},vl=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),Ua=new wf,mr=function(){function n(t,e){e===void 0&&(e=Ua),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=ii.Linear.None,this._interpolationFunction=Xi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=vl.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=Sn()),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,v=u.length;g<v;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 A in m)e[r][A]=m[A];s[r]=l?[]:{};var u=i[r];if(!this._isDynamic){var w={};for(var A in u)w[A]=u[A];i[r]=u=w}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=Sn()),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=Sn()),!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=Ua),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=ii.Linear.None),this._easingFunction=t,this},n.prototype.interpolation=function(t){return t===void 0&&(t=Xi.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=Sn()),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),A=a-m*l,w=Math.min(A/i._duration,1);return w===0&&a===i._duration?1:w},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 v=0,p=this._chainedTweens.length;v<p;v++)this._chainedTweens[v].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}(),ep="23.1.1",tp=vl.nextId,si=Ua,ip=si.getAll.bind(si),np=si.removeAll.bind(si),sp=si.add.bind(si),Cf=si.remove.bind(si),op=si.update.bind(si),Pc={Easing:ii,Group:wf,Interpolation:Xi,now:Sn,Sequence:vl,nextId:tp,Tween:mr,VERSION:ep,getAll:ip,removeAll:np,add:sp,remove:Cf,update:op};function rp(n,t,e,i=ii.Linear.None){const s=new mr(n).to(t,e).easing(i).start();function o(r){s.update(r)&&requestAnimationFrame(o)}return requestAnimationFrame(o),s}var gi=(n=>(n.Drawline="Drawline",n.Undo="Undo",n.Exit="Exit",n))(gi||{});const Ss=Symbol("$$PAINT_BRUSH_EVENT$$");function Ao(n){return n[Ss]||(n[Ss]={}),n[Ss]}function ap(n){n[Ss]||delete n[Ss]}let lp=class{hasListener(t){const e=Ao(this);return e&&e[t]&&e[t].length>0}on(t,e,i){const s=Ao(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){ap(this);return}const i=Ao(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=Ao(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 Mi(){return((1+Math.random())*65536|0).toString(16).substring(1)}function lt(){return(Mi()+Mi()+"-"+Mi()+"-4"+Mi().substr(0,3)+"-"+Mi()+"-"+Mi()+Mi()+Mi()).toLowerCase()}const cp=`
|
|
1
|
+
"use strict";var Gm=Object.defineProperty,Qm=Object.defineProperties;var Wm=Object.getOwnPropertyDescriptors;var mo=Object.getOwnPropertySymbols;var Ac=Object.prototype.hasOwnProperty,bc=Object.prototype.propertyIsEnumerable;var ga=(n,t,e)=>t in n?Gm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,x=(n,t)=>{for(var e in t||(t={}))Ac.call(t,e)&&ga(n,e,t[e]);if(mo)for(var e of mo(t))bc.call(t,e)&&ga(n,e,t[e]);return n},ie=(n,t)=>Qm(n,Wm(t));var Cn=(n,t)=>{var e={};for(var i in n)Ac.call(n,i)&&t.indexOf(i)<0&&(e[i]=n[i]);if(n!=null&&mo)for(var i of mo(n))t.indexOf(i)<0&&bc.call(n,i)&&(e[i]=n[i]);return e};var d=(n,t,e)=>(ga(n,typeof t!="symbol"?t+"":t,e),e);var Q=(n,t,e)=>new Promise((i,s)=>{var o=l=>{try{a(e.next(l))}catch(c){s(c)}},r=l=>{try{a(e.throw(l))}catch(c){s(c)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,r);a((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ze=require("@realsee/five"),W=require("three"),Go=require("three/examples/jsm/renderers/CSS3DRenderer"),fr=require("hammerjs"),gr=require("@realsee/five/line"),Qo=require("animejs"),bf=require("three/examples/jsm/loaders/FBXLoader"),Um=require("earcut"),Ym=require("@realsee/five/gltf-loader");function Xm(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 y=Xm(W);function Zm(){console.debug("%c %c@realsee/dnalogel %cv3.47.2",["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 Jm(){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 yf(){}const yc=()=>Promise.resolve(),wc={__queue:Promise.resolve()};function qm(n=yc){wc.__queue=wc.__queue.then(n).catch(yc)}function po(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 ma(n,t,e){const{x:i,y:s}=n,o=i*t,r=s*e;return{x:o,y:r}}function vo(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 Km(n,t,e=yf){new Promise(i=>{setTimeout(()=>{e(),i(!0)},t*n)})}const $m=window,Cc=window.requestAnimationFrame||$m.webkitRequestAnimationFrame||(n=>setTimeout(n,16));function Bo(n,t=0){t<=0?Cc(n):Cc(()=>Bo(n,t-1))}var ii=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-ii.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?ii.Bounce.In(n*2)*.5:ii.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}}}}),Sn=function(){return performance.now()},wf=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=Sn()),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}(),Xi={Linear:function(n,t){var e=n.length-1,i=e*t,s=Math.floor(i),o=Xi.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=Xi.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=Xi.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=Xi.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}}},vl=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),Ua=new wf,mr=function(){function n(t,e){e===void 0&&(e=Ua),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=ii.Linear.None,this._interpolationFunction=Xi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=vl.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=Sn()),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,v=u.length;g<v;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 A in m)e[r][A]=m[A];s[r]=l?[]:{};var u=i[r];if(!this._isDynamic){var w={};for(var A in u)w[A]=u[A];i[r]=u=w}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=Sn()),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=Sn()),!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=Ua),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=ii.Linear.None),this._easingFunction=t,this},n.prototype.interpolation=function(t){return t===void 0&&(t=Xi.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=Sn()),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),A=a-m*l,w=Math.min(A/i._duration,1);return w===0&&a===i._duration?1:w},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 v=0,p=this._chainedTweens.length;v<p;v++)this._chainedTweens[v].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}(),ep="23.1.1",tp=vl.nextId,si=Ua,ip=si.getAll.bind(si),np=si.removeAll.bind(si),sp=si.add.bind(si),Cf=si.remove.bind(si),op=si.update.bind(si),Pc={Easing:ii,Group:wf,Interpolation:Xi,now:Sn,Sequence:vl,nextId:tp,Tween:mr,VERSION:ep,getAll:ip,removeAll:np,add:sp,remove:Cf,update:op};function rp(n,t,e,i=ii.Linear.None){const s=new mr(n).to(t,e).easing(i).start();function o(r){s.update(r)&&requestAnimationFrame(o)}return requestAnimationFrame(o),s}var gi=(n=>(n.Drawline="Drawline",n.Undo="Undo",n.Exit="Exit",n))(gi||{});const Ss=Symbol("$$PAINT_BRUSH_EVENT$$");function Ao(n){return n[Ss]||(n[Ss]={}),n[Ss]}function ap(n){n[Ss]||delete n[Ss]}let lp=class{hasListener(t){const e=Ao(this);return e&&e[t]&&e[t].length>0}on(t,e,i){const s=Ao(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){ap(this);return}const i=Ao(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=Ao(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 Mi(){return((1+Math.random())*65536|0).toString(16).substring(1)}function lt(){return(Mi()+Mi()+"-"+Mi()+"-4"+Mi().substr(0,3)+"-"+Mi()+"-"+Mi()+Mi()+Mi()).toLowerCase()}const cp=`
|
|
2
2
|
<style type="text/css">
|
|
3
3
|
|
|
4
4
|
#_gl_paintBrush {
|
|
@@ -174,7 +174,7 @@ void main() {
|
|
|
174
174
|
float match = 1.0 - uv.x;
|
|
175
175
|
gl_FragColor = vec4(1.0,1.0,1.0,match);
|
|
176
176
|
}
|
|
177
|
-
`;function jp(){const n=new y.PlaneGeometry(.4,.4),t=xp,e=new y.TextureLoader().load(t);e.encoding=y.sRGBEncoding,e.minFilter=y.LinearFilter;const i=new y.MeshBasicMaterial({map:e,transparent:!0,depthTest:!1});return new y.Mesh(n,i)}function zp(){const n=new y.CurvePath;n.add(new y.LineCurve3(new y.Vector3(0,0,0),new y.Vector3(0,0,.1)));const t=new y.TubeGeometry(n,8,.003),e=new y.ShaderMaterial({vertexShader:Tp,fragmentShader:Lp,depthTest:!1,transparent:!0});return new y.Mesh(t,e)}function Op(){const n=new y.SphereGeometry(.01,20,20),t=new y.MeshBasicMaterial({color:10349931,depthTest:!1,transparent:!0,side:y.DoubleSide}),e=new y.Mesh(n,t);return e.position.set(0,0,.1),e}function Vp(){const t=new Wf({pointerEvents:"none",cornerPoints:[new y.Vector3(-.2,.2,0),new y.Vector3(-.2,-.2,0),new y.Vector3(.2,-.2,0),new y.Vector3(.2,.2,0)]}),e=document.createElement("div");return e.style.width="100%",e.style.height="100%",e.style.backgroundImage=`url(${If})`,e.style.backgroundSize="100%",e.style.backgroundRepeat="no-repeat",t.container.appendChild(e),t}class Mf extends y.Object3D{constructor(e){super();d(this,"planeMesh");d(this,"lineMesh");d(this,"ballMesh");d(this,"borderMesh");this.planeMesh=jp(),this.lineMesh=zp(),this.ballMesh=Op(),this.borderMesh=Vp(),this.add(this.planeMesh,this.lineMesh,this.ballMesh,this.borderMesh),Ef(e)}updateWithIntersect(e){if(!e.face)return;const i=new y.Vector3().addVectors(e.point,e.face.normal);this.position.copy(e.point),this.lookAt(i)}show(){this.visible=!0,this.borderMesh.parent||this.add(this.borderMesh)}hide(){this.visible=!1,this.remove(this.borderMesh)}dispose(){var e;(e=this.planeMesh.material.map)==null||e.dispose()}}const Bp=16777215,Mc=16777215,Rp=2,Fn=.6;class kf extends gr.Line{constructor(...t){super(...t)}toJSON(){return{type:"FiveLine",points:this.points.toJSON()}}}class Fp extends gr.THREE_Line2{constructor(...t){super(...t)}toJSON(){return{type:"Five_THREE_Line2",geometryAttributes:this.geometry.attributes}}}class kc extends gr.LineGeometry{constructor(...t){super(...t)}toJSON(){return{type:"FiveLineGeometry",attributes:this.attributes}}}class Np extends gr.LineMaterial{constructor(...t){super(...t)}toJSON(){return{type:"FiveLineMaterial",color:this.color}}}class Lt extends W.Object3D{constructor(){super();d(this,"name","IObject3D");d(this,"needsRender")}removeChildren(){for(;this.children.length>0;)this.remove(this.children[0]);return this}add(...e){const i=e.filter(Boolean);return i.length===0?this:super.add(...i)}addIfNotExists(...e){return e.forEach(i=>{this.children.includes(i)||this.add(i)}),this}remove(...e){if(e.length===0)return this;const i=e.filter(Boolean);return super.remove(...i)}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}}function Hp(n,t){const{x:e,y:i,z:s}=t.clone().project(n);return s>1?void 0:{leftPercent:(e+1)/2*100,topPercent:(-i+1)/2*100}}const xc="LightTagContainer_shgjakdhwakjdhsja";class bl{constructor(t,e,i){d(this,"container");d(this,"visible",!1);d(this,"enabled",!1);d(this,"wrapper");d(this,"tagWrapper");d(this,"five");d(this,"originPosition");d(this,"transformedPosition");d(this,"disposer");d(this,"config");d(this,"onCameraUpdate",()=>{this.visible!==!1&&this.updateScreenPosition()});d(this,"onFiveEveryReady",()=>{var t;if(this.visible&&this.five.state.mode!=="Panorama"){const e=new y.Raycaster;e.set(this.five.camera.position,this.transformedPosition.clone().sub(this.five.camera.position));const i=(t=Vt(this.five).intersectRaycaster(e))==null?void 0:t[0];(i==null?void 0:i.distance)>this.transformedPosition.distanceTo(this.five.camera.position)?(this.container.style.opacity="1",this.container.style.pointerEvents="auto"):(this.container.style.opacity="0",this.container.style.pointerEvents="none")}});var s;this.five=t,this.originPosition=e?Ge(e).clone():void 0,this.transformedPosition=(s=this.originPosition)==null?void 0:s.clone(),this.container=(()=>{const o=document.createElement("div");return o.style.width="0",o.style.height="0",o.style.position="absolute",o})(),this.config=i!=null?i:{},this.enable(),this.show()}show(){this.visible=!0,this.container.style.opacity="1",this.container.style.pointerEvents="auto",this.container.style.transition="opacity 0.2s linear",this.onCameraUpdate()}hide(t){this.visible=!1,t!=null&&t.withAnimation?this.container.style.transition="opacity 0.2s linear":this.container.style.transition="",this.container.style.opacity="0",this.container.style.pointerEvents="none"}enable(){var i,s,o,r;if(this.enabled)return;this.enabled=!0,this.wrapper=(o=(s=this.config.wrapper)!=null?s:(i=this.five.getElement())==null?void 0:i.parentElement)!=null?o:document.body,this.tagWrapper||(this.tagWrapper=(r=document.getElementById(xc))!=null?r:(()=>{const a=document.createElement("div");return a.id=xc,a.style.position="absolute",a.style.top="0",a.style.left="0",a.style.width="100%",a.style.height="100%",a.style.pointerEvents="none",a})(),this.wrapper.contains(this.tagWrapper)||this.wrapper.appendChild(this.tagWrapper)),this.tagWrapper.appendChild(this.container);let t=!1;const e=()=>{t||(t=!0,this.five.ready().then(()=>{this.onFiveEveryReady(),t=!1}))};this.five.on("cameraUpdate",e),this.five.on("cameraUpdate",this.onCameraUpdate),this.disposer=()=>{this.five.off("cameraUpdate",e),this.five.off("cameraUpdate",this.onCameraUpdate)}}disable(){var t;this.enabled&&(this.enabled=!1,this.tagWrapper.removeChild(this.container),(t=this.disposer)==null||t.call(this))}destroy(){this.disable(),this.container.remove()}setTransformMatrix(t){var e;this.transformedPosition=(e=this.originPosition)==null?void 0:e.clone().applyMatrix4(t),this.onCameraUpdate()}setPosition(t){this.transformedPosition=t,this.onCameraUpdate()}updateScreenPosition(){if(!this.transformedPosition){this.container.style.left="-100%",this.container.style.top="-100%";return}const t=Hp(this.five.camera,this.transformedPosition);t?(this.container.style.left=t.leftPercent+"%",this.container.style.top=t.topPercent+"%"):(this.container.style.left="-100%",this.container.style.top="-100%")}}function _p(n,t,e){return new bl(n,t,e)}const Gp={auto:"",pen:"","pen-forbidden":"","pen-crosshair":"","pne-polygon":"","pen-circle":"","crosshair-rectangle":"","crosshair-circle":""};class Qp{constructor(t){d(this,"container");this.container=t}setType(t){const e=Gp[t];e?this.container.style.cursor=`url(${e}), auto`:this.container.style.cursor=t}tip(t){return()=>this.closeTip()}closeTip(){}reset(){this.container.style.cursor="auto"}}class xf extends dt{constructor(e){super();d(this,"five");this.five=e}}const Vs=(n,t)=>{if(!t)return n;const e=new y.Vector3,i=new y.Quaternion,s=new y.Vector3;return t.decompose(e,i,s),n.clone().multiply(s).applyQuaternion(i).add(e)},pa=new Map;class Wp extends xf{constructor(e){super(e);d(this,"_workCode")}get fromType(){var s,o;const e=this.workCode;if(pa.has(e))return pa.get(e);const i=(o=(s=JSON.parse(this.work.raw.works[0]))==null?void 0:s.from_type)!=null?o:"vr";return pa.set(e,i),i}set workCode(e){this._workCode=e}get workCode(){var e;return(e=this._workCode)!=null?e:this.five.state.workCode}get work(){var e,i;return(i=(e=this.five.works)==null?void 0:e.find(s=>s.workCode===this.workCode))!=null?i:this.five.work}get observers(){var e;return(e=this.work)==null?void 0:e.observers}get transform(){var i,s,o,r;const e=(r=(i=this.work)==null?void 0:i.transform)!=null?r:(o=(s=this.work)==null?void 0:s.options)==null?void 0:o.transform;return e?e.clone():new y.Matrix4}getObserverPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.position;if(i)return Vs(i,this.transform)}getObserverStandingPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.standingPosition;if(i)return Vs(i,this.transform)}getObserver(e){var i;return(i=this.observers)==null?void 0:i[e]}}class yl extends xf{constructor(e){super(e);d(this,"workUtil",new Wp(this.five))}get version(){return this.five.constructor.version}get majorVersion(){return Number(this.version.split(".")[0])}get model(){return Vt(this.five)}moveToPano(e,i){const s=this.majorVersion===5?e:{workCode:this.workUtil.workCode,panoIndex:e};return this.five.moveToPano(s,i)}}let Oi=class{constructor(t,e){d(this,"VERSION","3.47.1");d(this,"NAME");d(this,"five");d(this,"workUtil");d(this,"fiveUtil");d(this,"hooks",new dt);d(this,"staticPrefix","//vr-image-4.realsee-cdn.cn");this.updateFive(t),e!=null&&e.staticPrefix&&(this.staticPrefix=e.staticPrefix)}set workCode(t){this.workUtil.workCode=t,this.onWorkCodeChange()}get workCode(){return this.workUtil.workCode}updateFive(t){this.five=t,this.fiveUtil=new yl(t),this.workUtil=this.fiveUtil.workUtil}getCurrentState(){return this.state}absoluteUrl(t){return Dl(this.staticPrefix,t)}onWorkCodeChange(){}};function Df(n,t,e){if(e){const s=new y.Vector3().subVectors(n.position,e).applyQuaternion(n.quaternion.clone().inverse()).applyQuaternion(t).add(e);n.position.copy(s)}n.quaternion.copy(t)}const va=new y.Vector3;class Up extends y.Sphere{expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;va.subVectors(t,this.center);const e=va.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(va,s/i),this.radius+=s}return this}}function Yp(n){const{max:t,min:e}=n;return[new y.Vector3(t.x,t.y,t.z),new y.Vector3(e.x,t.y,t.z),new y.Vector3(e.x,e.y,t.z),new y.Vector3(t.x,e.y,t.z),new y.Vector3(t.x,t.y,e.z),new y.Vector3(e.x,t.y,e.z),new y.Vector3(e.x,e.y,e.z),new y.Vector3(t.x,e.y,e.z)]}function pi(n,t){const{max:e,min:i}=n;switch(t){case 0:return new y.Vector3(e.x,e.y,e.z);case 1:return new y.Vector3(i.x,e.y,e.z);case 2:return new y.Vector3(i.x,i.y,e.z);case 3:return new y.Vector3(e.x,i.y,e.z);case 4:return new y.Vector3(e.x,e.y,i.z);case 5:return new y.Vector3(i.x,e.y,i.z);case 6:return new y.Vector3(i.x,i.y,i.z);case 7:return new y.Vector3(e.x,i.y,i.z)}}function qn(n){return wl(n,"box3")}function Sf(n){return wl(n,"sphere")}function Xp(n){return vr(n,"box3")}function Tf(n){return vr(n,"sphere")}function vr(n,t){const e=t==="box3"?new y.Box3:new Up,i=new y.Vector3;if(n.updateWorldMatrix(!1,!1),n.traverse(s=>{var r;if(s.name==="shadow"||s.type==="Line2")return;const o=s.geometry;if(s.updateWorldMatrix(!1,!1),o!==void 0){const a=(r=o==null?void 0:o.attributes)==null?void 0:r.position;if(a)for(let l=0,c=a.count;l<c;l++)i.fromBufferAttribute(a,l).applyMatrix4(s.matrixWorld),e.expandByPoint(i);else o.vertices&&o.vertices.forEach(l=>{const c=l.clone().applyMatrix4(s.matrixWorld);e.expandByPoint(c)})}}),!e.isEmpty())return e}function wl(n,t){const e=vr(n,t);return e&&e.applyMatrix4(Zp(n.matrixWorld.clone())),e}const Zp=n=>{const t=n.elements,e=t[0],i=t[1],s=t[2],o=t[3],r=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],f=t[10],g=t[11],v=t[12],p=t[13],m=t[14],A=t[15],w=u*m*c-p*f*c+p*l*g-a*m*g-u*l*A+a*f*A,I=v*f*c-h*m*c-v*l*g+r*m*g+h*l*A-r*f*A,P=h*p*c-v*u*c+v*a*g-r*p*g-h*a*A+r*u*A,k=v*u*l-h*p*l-v*a*f+r*p*f+h*a*m-r*u*m,E=e*w+i*I+s*P+o*k;if(E===0)return n.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/E;return t[0]=w*L,t[1]=(p*f*o-u*m*o-p*s*g+i*m*g+u*s*A-i*f*A)*L,t[2]=(a*m*o-p*l*o+p*s*c-i*m*c-a*s*A+i*l*A)*L,t[3]=(u*l*o-a*f*o-u*s*c+i*f*c+a*s*g-i*l*g)*L,t[4]=I*L,t[5]=(h*m*o-v*f*o+v*s*g-e*m*g-h*s*A+e*f*A)*L,t[6]=(v*l*o-r*m*o-v*s*c+e*m*c+r*s*A-e*l*A)*L,t[7]=(r*f*o-h*l*o+h*s*c-e*f*c-r*s*g+e*l*g)*L,t[8]=P*L,t[9]=(v*u*o-h*p*o-v*i*g+e*p*g+h*i*A-e*u*A)*L,t[10]=(r*p*o-v*a*o+v*i*c-e*p*c-r*i*A+e*a*A)*L,t[11]=(h*a*o-r*u*o-h*i*c+e*u*c+r*i*g-e*a*g)*L,t[12]=k*L,t[13]=(h*p*s-v*u*s+v*i*f-e*p*f-h*i*m+e*u*m)*L,t[14]=(v*a*s-r*p*s-v*i*l+e*p*l+r*i*m-e*a*m)*L,t[15]=(r*u*s-h*a*s+h*i*l-e*u*l-r*i*f+e*a*f)*L,n};class Qs extends Lt{constructor(e,i){var s,o;super();d(this,"originObject3D");d(this,"onRender");d(this,"positionFrom");this.originObject3D=e,this.onRender=(s=i==null?void 0:i.onRender)!=null?s:()=>{},this.positionFrom=(o=i==null?void 0:i.positionFrom)!=null?o:"objectPosition"}get helperObject(){return this}render(){this.onRender()}enable(){this.parent.children.includes(this)||this.parent.add(this)}disable(){this.removeFromParent()}show(){this.visible=!0,this.render()}hide(){this.visible=!1,this.render()}raycasterIntersectObject(e,i=[]){return e.intersectObject(this,!0,i)}initialPosition(e){var i,s;this.positionFrom==="objectPosition"?this.position.copy(this.originObject3D.position):this.positionFrom==="boundingBox"?this.position.copy((i=qn(this.originObject3D))==null?void 0:i.getCenter(new y.Vector3)):this.positionFrom==="boundingSphere"?this.position.copy((s=Sf(this.originObject3D))==null?void 0:s.center):this.positionFrom instanceof W.Vector3?this.position.copy(this.positionFrom):this.positionFrom instanceof Function&&this.position.copy(this.positionFrom(this.originObject3D)),e&&this.position.add(e)}setScaleByCamera(e){}initQuaternion(){this.quaternion.copy(this.originObject3D.quaternion)}applyHelperScaleMatrix4(e,i){this.scale.applyMatrix4(e)}setHelperQuaternion(e,i){Df(this,e,i)}applyHelperQuaternion(e,i){if(i){const s=new W.Vector3().subVectors(this.position,i).applyQuaternion(e).add(i);this.position.copy(s)}this.applyQuaternion(e)}dispose(){this.removeFromParent()}}class Jp extends Qs{}class qp extends Qs{}class Kp extends Qs{}class $p extends Qs{}class ev extends Qs{}class tv extends y.Group{constructor(e){super();d(this,"direction");this.direction=e||"x"}}class Dc extends y.Mesh{constructor(e,i,s){super(e,i);d(this,"direction");this.direction=s||"x"}}function iv(n,t){const{offsetWidth:e,offsetHeight:i}=t,{top:s,left:o}=t.getBoundingClientRect();return Object.assign(new y.Vector2,{x:(n.x-o)/e*2-1,y:-(n.y-s)/i*2+1})}function Ar(n,t,e){if(!t||!e||!n)return;const i=iv(t,e);if(Math.abs(i.x)===1||Math.abs(i.y)===1)return;const s=new y.Raycaster;return s.setFromCamera(i,n),s}function nv(n,t){return!(Math.abs(n.x-t.x)>1e-5||Math.abs(n.y-t.y)>1e-5||Math.abs(n.z-t.z)>1e-5)}class Aa extends tv{constructor(e){var h;super(e.direction);d(this,"line");d(this,"arrow");d(this,"lineHeight",.4);d(this,"arrowHeight",.1);this.name="ArrowGroup";const i=new y.Color((h=e.color)!=null?h:16214315),s=new y.MeshBasicMaterial({color:i,depthTest:!1,depthWrite:!1,opacity:1,transparent:!0,side:y.DoubleSide});this.renderOrder=50;const o=new y.ConeGeometry(.04,.1,32),r=new Dc(o,s.clone(),e.direction);r.name=`arrow-${e.direction}`,this.arrow=r;const a=.004,l=new y.CylinderGeometry(a,a,.4,32),c=new Dc(l,s.clone(),e.direction);c.name=`line-${e.direction}`,this.line=c,this.formatArrow(),this.formatLine(),this.add(this.arrow,this.line)}formatArrow(){this.arrow.geometry.translate(0,this.lineHeight+this.arrowHeight/2,0),this.direction==="x"?(this.arrow.geometry.rotateX(Math.PI/2),this.arrow.geometry.rotateY(Math.PI/2)):this.direction==="z"&&this.arrow.geometry.rotateX(Math.PI/2)}formatLine(){this.line.geometry.translate(0,this.lineHeight/2,0),this.direction==="x"?(this.line.geometry.rotateX(Math.PI/2),this.line.geometry.rotateY(Math.PI/2)):this.direction==="z"&&this.line.geometry.rotateX(Math.PI/2)}}const ba={X:15618642,Y:4765519,Z:4227839};class On{static get X(){return new y.Color(ba.X).convertSRGBToLinear().clone()}static get Y(){return new y.Color(ba.Y).convertSRGBToLinear().clone()}static get Z(){return new y.Color(ba.Z).convertSRGBToLinear().clone()}}function Cl(n,t){const s=n.position.distanceTo(t),o=n.fov,r=s/3,a=o/90;return r*a}class sv extends Jp{constructor(e,i){super(e,i);d(this,"xArrow");d(this,"yArrow");d(this,"zArrow");i.xArrowEnable!==!1&&(this.xArrow=new Aa({direction:"x",color:On.X})),i.yArrowEnable!==!1&&(this.yArrow=new Aa({direction:"y",color:On.Y})),i.zArrowEnable!==!1&&(this.zArrow=new Aa({direction:"z",color:On.Z})),this.add(...[this.xArrow,this.yArrow,this.zArrow].filter(Boolean))}show(){super.show(),this.xArrow&&(this.xArrow.visible=!0),this.yArrow&&(this.yArrow.visible=!0),this.zArrow&&(this.zArrow.visible=!0)}setScaleByCamera(e){this.scale.setScalar(Cl(e,this.position))}showDraggingHelper(e){this.xArrow&&(this.xArrow.visible=e.includes("x")),this.yArrow&&(this.yArrow.visible=e.includes("y")),this.zArrow&&(this.zArrow.visible=e.includes("z"))}dispose(){this.remove(...[this.xArrow,this.yArrow,this.zArrow].filter(Boolean)),super.dispose()}}function Ki(n,t){return ov(document.createElement(t!=null?t:"div"),n)}function ov(n,t){if(!t)return n;for(const e in t)e&&t[e]&&(n.style[e]=t[e]);return n}function rv(n){const t=Ki(x({position:"absolute",display:"block",borderRadius:"4px",paddingTop:"1px",paddingBottom:"1px",paddingLeft:"4px",paddingRight:"4px",pointerEvents:"none",userSelect:"none",zIndex:"99999",backgroundColor:"rgba(0,0,0,0.7)",fontSize:"12px",color:"#fff",letterSpacing:"0",lineHeight:"18px"},n)),e=()=>{t.style.display!=="block"&&t.style.top&&t.style.left&&(t.style.display="block")};return{element:t,show:e,hide:()=>{t.style.display="none",t.style.top="",t.style.left=""},setLeftTop:(o,r)=>{t.style.left=o,t.style.top=r,e()}}}class av extends Kp{constructor(e,i){super(e,i);d(this,"xCircle");d(this,"yCircle");d(this,"zCircle");d(this,"children",[]);d(this,"angleTips");d(this,"container");(i==null?void 0:i.yzCircleEnable)!==!1&&(this.xCircle=new ya({direction:"x",color:On.X})),(i==null?void 0:i.xzCircleEnable)!==!1&&(this.yCircle=new ya({direction:"y",color:On.Y})),(i==null?void 0:i.xyCircleEnable)!==!1&&(this.zCircle=new ya({direction:"z",color:On.Z})),i!=null&&i.container&&(i==null?void 0:i.angleTipsEnable)!==!1&&(this.container=i==null?void 0:i.container,this.angleTips=rv({display:"none"}),this.container.appendChild(this.angleTips.element)),this.add(...[this.xCircle,this.yCircle,this.zCircle].filter(Boolean)),this.show()}hide(){this.children.forEach(e=>e.hide())}show(){var e;this.children.forEach(i=>i.showCircle()),(e=this.angleTips)==null||e.hide()}setScaleByCamera(e){this.scale.setScalar(Cl(e,this.position))}showDraggingHelper(e){var i;this.hide(),this.children.filter(s=>e.includes(s.direction)).forEach(s=>s.showRing()),(i=this.angleTips)==null||i.show()}dispose(){var e,i;this.removeFromParent(),(i=(e=this.angleTips)==null?void 0:e.element)==null||i.remove()}}class ya extends y.Group{constructor(e){super();d(this,"direction");d(this,"circle");d(this,"ring");d(this,"angleSector");this.direction=e.direction,this.circle=new lv(e),this.ring=new cv(e),this.angleSector=new hv(e),this.add(this.circle,this.ring,this.angleSector),this.direction==="y"?this.rotateX(Math.PI/2):this.direction==="x"&&this.rotateY(-Math.PI/2)}showCircle(){this.add(this.circle),this.remove(this.ring,this.angleSector)}showRing(){this.add(this.ring,this.angleSector),this.remove(this.circle)}hide(){this.remove(this.ring,this.angleSector,this.circle)}}let lv=class extends y.Mesh{constructor(e){var i;super();d(this,"direction");d(this,"gapAngle",.02);d(this,"geometry",new y.RingGeometry(.25,.3,20,8,this.gapAngle,Math.PI/2-this.gapAngle*2));this.material=new y.MeshBasicMaterial({opacity:.6,color:(i=e.color)!=null?i:16777215,transparent:!0,side:y.DoubleSide,depthTest:!1,depthWrite:!1}),this.renderOrder=50,this.direction=e.direction,this.geometry.name=`RotateHelperCircleGeometry-${this.direction}`}};class cv extends y.Group{constructor(e){super();d(this,"direction");this.direction=e.direction;const i=.015,s=new Array(8).fill(null).map((o,r)=>{const a=new y.RingGeometry(.25,.3,20,8,Math.PI/4*r+i,Math.PI/4-i*2),l=new y.MeshBasicMaterial({opacity:1,color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide});this.renderOrder=50;const c=new y.Mesh(a,l);return c.name=`AxesDashedRing-${this.direction}-${r}`,c});this.add(...s)}}class hv extends y.Mesh{constructor(e){var s;super();d(this,"direction");d(this,"baseAxes");d(this,"angleDirection");switch(e.direction){case"x":this.baseAxes=new y.Vector3(0,0,1);break;case"y":this.baseAxes=new y.Vector3(1,0,0);break;case"z":this.baseAxes=new y.Vector3(1,0,0);break}const i=.3+5e-4;this.geometry=new y.CircleGeometry(i,48,0,1e-4),this.material=new y.MeshBasicMaterial({opacity:.4,color:(s=e.color)!=null?s:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide}),this.renderOrder=50,this.direction=e.direction,this.angleDirection=this.direction==="z"?1:-1}}function dv(){const n=Ki({width:"100%",height:"100%",left:"0",top:"0",position:"absolute",pointerEvents:"none"}),t=Ki({boxSizing:"border-box",width:"100%",height:"100%",left:"0",top:"0",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"}),e=Ki({boxSizing:"border-box",width:"100%",height:"100%",left:"0",top:"0",position:"absolute",border:"1px solid rgba(255,255,255,0.4)"});n.appendChild(t),t.appendChild(e);const i="-4px",s={direction:"nesw",element:ki({cursor:"nesw-resize",left:i,bottom:i})},o={direction:"ns",element:ki({cursor:"ns-resize",bottom:i})},r={direction:"nwse",element:ki({cursor:"nwse-resize",right:i,bottom:i})},a={direction:"ew",element:ki({cursor:"ew-resize",right:i})},l={direction:"nesw",element:ki({cursor:"nesw-resize",right:i,top:i})},c={direction:"ns",element:ki({cursor:"ns-resize",top:i})},h={direction:"nwse",element:ki({cursor:"nwse-resize",left:i,top:i})},u={direction:"ew",element:ki({cursor:"ew-resize",left:i})};return new Array(o,a,c,u,s,r,l,h).forEach(g=>t.appendChild(g.element)),{container:n,squares:[s,o,r,a,l,c,h,u]}}function ki(n){const t=Ki(x({background:"#FFFFFF",width:"9px",height:"9px",position:"absolute",pointerEvents:"none"},n)),e=Ki({width:"15px",height:"15px",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"}),i=Ki({width:"15px",height:"15px",cursor:n==null?void 0:n.cursor,pointerEvents:"auto",background:"transparent"});return i.draggable=!0,e.appendChild(i),t.appendChild(e),t}class uv extends ev{constructor(e,i,s,o){super(e);d(this,"points",[]);d(this,"cornerPositions",[]);d(this,"css3DInstance");d(this,"plane");d(this,"css3DRenderer",new Gn);d(this,"camera");d(this,"scene");d(this,"container");d(this,"enabled",!1);this.camera=s,this.scene=o,this.container=i,this.initRectangleScaleHelper()}get helperObject(){var e;if(!((e=this.css3DInstance)!=null&&e.css3DObject))throw new Error("css3DInstance is not initialized");return this.css3DInstance.css3DObject}applyMatrix4(e){var i;super.applyMatrix4(e),this.helperObject.applyMatrix4(e),(i=this.plane)==null||i.applyMatrix4(e),this.cornerPositions.forEach(s=>s.applyMatrix4(e))}showDraggingHelper(){}applyHelperScaleMatrix4(e,i){var s;(s=this.plane)==null||s.scale.applyMatrix4(e),this.helperObject.applyScaleMatrix4(e)}updatePoints(){const e=this.calculatePointPosition(this.cornerPositions);this.points.forEach((i,s)=>{i.position.copy(e[s])})}applyHelperQuaternion(e,i){var o;const s=(o=this.css3DInstance)==null?void 0:o.css3DObject;if(s){const r=new y.Vector3().subVectors(s.position,i).applyQuaternion(e).add(i);s.position.copy(r),s.applyQuaternion(e)}if(this.plane){const r=new y.Vector3().subVectors(this.plane.position,i).applyQuaternion(e).add(i);this.plane.position.copy(r),this.plane.applyQuaternion(e)}this.cornerPositions.forEach(r=>{const a=new y.Vector3().subVectors(r,i).applyQuaternion(e).add(i);r.copy(a)})}enable(){var e;this.enabled||(this.enabled=!0,(e=this.css3DInstance)==null||e.enable(),this.plane&&this.scene.add(this.plane))}disable(){var e;this.enabled&&(this.enabled=!1,(e=this.css3DInstance)==null||e.disable(),this.plane&&this.scene.remove(this.plane))}show(){var e;(e=this.css3DInstance)==null||e.show(),this.plane&&(this.plane.visible=!0)}hide(){var e;(e=this.css3DInstance)==null||e.hide(),this.plane&&(this.plane.visible=!1)}dispose(){this.disable(),this.css3DRenderer.dispose()}initRectangleScaleHelper(){var a,l;const e=this.getCornerPositions();if(!e)return;this.cornerPositions=e;const i=this.css3DRenderer.create3DElement(this.camera,e,{ratio:.003});if(!i)return;this.css3DInstance=i,i.appendToElement(this.container);const s=i.css3DObject.container,{container:o,squares:r}=dv();this.points=r.map((c,h)=>({direction:c.direction,point:c.element,position:this.calculatePointPosition(e)[h]})),s.insertBefore(o,(a=s.children[0])!=null?a:null),this.helperObject.position.copy(this.originObject3D.position),(l=this.plane)==null||l.position.copy(this.originObject3D.position)}getCornerPositions(){const{originObject3D:e}=this;if(e.isCSS3DObjectPlus)return e.cornerPoints;console.error("当前物体暂时不支持 ScaleHelper")}calculatePointPosition(e){return[e[0].clone(),e[0].clone().add(e[1]).divideScalar(2),e[1].clone(),e[1].clone().add(e[2]).divideScalar(2),e[2].clone(),e[2].clone().add(e[3]).divideScalar(2),e[3].clone(),e[3].clone().add(e[0]).divideScalar(2)]}}class fv extends qp{constructor(e){super(e);d(this,"box");d(this,"outline");d(this,"originObject");d(this,"positionAttribute");this.originObject=e,this.positionAttribute=new y.BufferAttribute(new Float32Array(8*3),3),this.box=this.createBox(),this.outline=this.createOutline(),this.add(this.box,this.outline),this.update()}raycasterIntersectObject(e,i){return e.intersectObject(this,!1,i)}raycast(e,i){this.box.raycast(e,i)}update(){const e=qn(this.originObject);if(!e)return;const{min:i,max:s}=e;this.positionAttribute.setXYZ(0,s.x,s.y,s.z),this.positionAttribute.setXYZ(1,i.x,s.y,s.z),this.positionAttribute.setXYZ(2,i.x,i.y,s.z),this.positionAttribute.setXYZ(3,s.x,i.y,s.z),this.positionAttribute.setXYZ(4,s.x,s.y,i.z),this.positionAttribute.setXYZ(5,i.x,s.y,i.z),this.positionAttribute.setXYZ(6,i.x,i.y,i.z),this.positionAttribute.setXYZ(7,s.x,i.y,i.z),this.positionAttribute.needsUpdate=!0}createOutline(){const e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new y.BufferGeometry;i.setIndex(new y.BufferAttribute(e,1)),i.setAttribute("position",this.positionAttribute);const s=new y.LineBasicMaterial({color:64767,linewidth:1,opacity:1,toneMapped:!1}),o=new y.LineSegments(i,s);return o.matrixAutoUpdate=!1,o}createBox(){const e=new Uint16Array([0,1,2,0,2,3,0,3,7,0,7,4,0,4,5,0,5,1,6,1,5,6,2,1,6,5,4,6,4,7,6,3,2,6,7,3]),i=new y.BufferGeometry;i.setIndex(new y.BufferAttribute(e,1)),i.setAttribute("position",this.positionAttribute);const s=new y.MeshBasicMaterial({color:64767,opacity:.1,depthTest:!1,transparent:!0});return new y.Mesh(i,s)}}function Be(n,t){this._camera=n||null,this._domElement=t||document,this._raycaster=new y.Raycaster,this._selected=null,this._boundObjs={};var e=this;this._$onClick=function(){e._onClick.apply(e,arguments)},this._$onDblClick=function(){e._onDblClick.apply(e,arguments)},this._$onMouseMove=function(){e._onMouseMove.apply(e,arguments)},this._$onMouseDown=function(){e._onMouseDown.apply(e,arguments)},this._$onMouseUp=function(){e._onMouseUp.apply(e,arguments)},this._$onTouchMove=function(){e._onTouchMove.apply(e,arguments)},this._$onTouchStart=function(){e._onTouchStart.apply(e,arguments)},this._$onTouchEnd=function(){e._onTouchEnd.apply(e,arguments)},this._$onContextmenu=function(){e._onContextmenu.apply(e,arguments)},this._domElement.addEventListener("click",this._$onClick,!1),this._domElement.addEventListener("dblclick",this._$onDblClick,!1),this._domElement.addEventListener("mousemove",this._$onMouseMove,!1),this._domElement.addEventListener("mousedown",this._$onMouseDown,!1),this._domElement.addEventListener("mouseup",this._$onMouseUp,!1),this._domElement.addEventListener("touchmove",this._$onTouchMove,!1),this._domElement.addEventListener("touchstart",this._$onTouchStart,!1),this._domElement.addEventListener("touchend",this._$onTouchEnd,!1),this._domElement.addEventListener("contextmenu",this._$onContextmenu,!1)}Be.prototype.destroy=function(){this._domElement.removeEventListener("click",this._$onClick,!1),this._domElement.removeEventListener("dblclick",this._$onDblClick,!1),this._domElement.removeEventListener("mousemove",this._$onMouseMove,!1),this._domElement.removeEventListener("mousedown",this._$onMouseDown,!1),this._domElement.removeEventListener("mouseup",this._$onMouseUp,!1),this._domElement.removeEventListener("touchmove",this._$onTouchMove,!1),this._domElement.removeEventListener("touchstart",this._$onTouchStart,!1),this._domElement.removeEventListener("touchend",this._$onTouchEnd,!1),this._domElement.removeEventListener("contextmenu",this._$onContextmenu,!1)};Be.eventNames=["click","dblclick","mouseover","mouseout","mousemove","mousedown","mouseup","contextmenu","touchstart","touchend"];Be.prototype._getRelativeMouseXY=function(n){var t=n.target||n.srcElement;t.nodeType===3&&(t=t.parentNode);var e={x:0,y:0},i=t,s=getComputedStyle(i,null);e.y+=parseInt(s.getPropertyValue("padding-top"),10),e.x+=parseInt(s.getPropertyValue("padding-left"),10);do e.x+=i.offsetLeft,e.y+=i.offsetTop,s=getComputedStyle(i,null),e.x+=parseInt(s.getPropertyValue("border-left-width"),10),e.y+=parseInt(s.getPropertyValue("border-top-width"),10);while(i=i.offsetParent);var o={width:t===window?window.innerWidth:t.offsetWidth,height:t===window?window.innerHeight:t.offsetHeight};return{x:Number((n.pageX-e.x)/o.width)*2-1,y:-((n.pageY-e.y)/o.height)*2+1}};Be.prototype._objectCtxInit=function(n){n._3xDomEvent={}};Be.prototype._objectCtxDeinit=function(n){delete n._3xDomEvent};Be.prototype._objectCtxIsInit=function(n){return!!n._3xDomEvent};Be.prototype._objectCtxGet=function(n){return n._3xDomEvent};Be.prototype.camera=function(n){return n&&(this._camera=n),this._camera};Be.prototype.bind=function(n,t,e,i){console.assert(Be.eventNames.indexOf(t)!==-1,"not available events:"+t),this._objectCtxIsInit(n)||this._objectCtxInit(n);var s=this._objectCtxGet(n);s[t+"Handlers"]||(s[t+"Handlers"]=[]),s[t+"Handlers"].push({callback:e,useCapture:i}),this._boundObjs[t]===void 0&&(this._boundObjs[t]=[]),this._boundObjs[t].push(n)};Be.prototype.addEventListener=Be.prototype.bind;Be.prototype.unbind=function(n,t,e,i){console.assert(Be.eventNames.indexOf(t)!==-1,"not available events:"+t),this._objectCtxIsInit(n)||this._objectCtxInit(n);var s=this._objectCtxGet(n);s[t+"Handlers"]||(s[t+"Handlers"]=[]);for(var o=s[t+"Handlers"],r=0;r<o.length;r++){var a=o[r];if(e==a.callback&&i==a.useCapture){o.splice(r,1);break}}var l=this._boundObjs[t].indexOf(n);this._boundObjs[t].splice(l,1)};Be.prototype.removeEventListener=Be.prototype.unbind;Be.prototype._bound=function(n,t){var e=this._objectCtxGet(t);return e?!!e[n+"Handlers"]:!1};Be.prototype._onMove=function(n,t,e,i){var s=this._boundObjs[n];if(!(s===void 0||s.length===0)){var o=new y.Vector2;o.set(t,e),this._raycaster.setFromCamera(o,this._camera);var r=this._raycaster.intersectObjects(s),a=this._selected;if(r.length>0){var l,c,h,u=r[0],f=u.object;this._selected=f,h=this._bound("mousemove",f),a!=f&&(l=this._bound("mouseover",f),c=a&&this._bound("mouseout",a))}else c=a&&this._bound("mouseout",a),this._selected=null;h&&this._notify("mousemove",f,i,u),l&&this._notify("mouseover",f,i,u),c&&this._notify("mouseout",a,i,u)}};Be.prototype._onEvent=function(n,t,e,i){var s=this._boundObjs[n];if(!(s===void 0||s.length===0)){var o=new y.Vector2;o.set(t,e),this._raycaster.setFromCamera(o,this._camera);var r=this._raycaster.intersectObjects(s,!0);if(r.length!==0){for(var a=r[0],l=a.object,c=this._objectCtxGet(l),h=l.parent;typeof c=="undefined"&&h;)c=this._objectCtxGet(h),h=h.parent;c&&this._notify(n,l,i,a)}}};Be.prototype._notify=function(n,t,e,i){var s=this._objectCtxGet(t),o=s?s[n+"Handlers"]:null;if(!s||!o||o.length===0){t.parent&&this._notify(n,t.parent,e,i);return}for(var o=s[n+"Handlers"],r=0;r<o.length;r++){var a=o[r],l=!0;a.callback({type:n,target:t,origDomEvent:e,intersect:i,stopPropagation:function(){l=!1}}),l&&a.useCapture===!1&&t.parent&&this._notify(n,t.parent,e,i)}};Be.prototype._onMouseDown=function(n){return this._onMouseEvent("mousedown",n)};Be.prototype._onMouseUp=function(n){return this._onMouseEvent("mouseup",n)};Be.prototype._onMouseEvent=function(n,t){var e=this._getRelativeMouseXY(t);this._onEvent(n,e.x,e.y,t)};Be.prototype._onMouseMove=function(n){var t=this._getRelativeMouseXY(n);this._onMove("mousemove",t.x,t.y,n),this._onMove("mouseover",t.x,t.y,n),this._onMove("mouseout",t.x,t.y,n)};Be.prototype._onClick=function(n){this._onMouseEvent("click",n)};Be.prototype._onDblClick=function(n){this._onMouseEvent("dblclick",n)};Be.prototype._onContextmenu=function(n){this._onMouseEvent("contextmenu",n)};Be.prototype._onTouchStart=function(n){return this._onTouchEvent("touchstart",n)};Be.prototype._onTouchEnd=function(n){return this._onTouchEvent("touchend",n)};Be.prototype._onTouchMove=function(n){if(n.touches.length==1){var t=Number(n.touches[0].pageX/window.innerWidth)*2-1,e=-(n.touches[0].pageY/window.innerHeight)*2+1;this._onMove("mousemove",t,e,n),this._onMove("mouseover",t,e,n),this._onMove("mouseout",t,e,n)}};Be.prototype._onTouchEvent=function(n,t){var e=t.touches;if(e.length==0&&(e=t.changedTouches),e.length==1){var i=Number(e[0].pageX/window.innerWidth)*2-1,s=-(e[0].pageY/window.innerHeight)*2+1;this._onEvent(n,i,s,t)}};function Ai(n){return!ke(n)}function ke(n){return n!=null}function yi(n){return arguments.length===0?[]:Array.isArray(n)?n:[n]}let Ws=class{constructor(t,e){d(this,"originObject3D");d(this,"hooks");d(this,"preventTapDefaultEvent",!1);d(this,"internalHooks");d(this,"disposers",[]);d(this,"helperObject3D");d(this,"camera");d(this,"model");d(this,"scene");d(this,"container");d(this,"domEvents");d(this,"isDragging",!1);d(this,"enabled",!1);d(this,"name","BaseController");d(this,"boundingBox");d(this,"config");d(this,"onRender");d(this,"onWantsTapGesture",t=>{if(this.getIntersectObject(t))return!1});d(this,"onWantsUpdateCameraDistance",()=>{if(this.camera.isPerspectiveCamera){const t=this.camera;this.helperObject3D.setScaleByCamera(t)}});d(this,"getBox",()=>this.boundingBox?this.boundingBox:(this.boundingBox=qn(this.originObject3D),this.boundingBox));var h,u,f;this.hooks=(h=t.sharedHooks)!=null?h:new dt,this.internalHooks=(u=t.sharedInternalHooks)!=null?u:new dt,this.camera=t.camera,this.model=t.model,this.originObject3D=t.originObject3D,this.helperObject3D=t.helperObject3D,this.container=t.container,this.scene=t.scene,this.domEvents=new Be(t.camera,t.container),this.onRender=(f=t.onRender)!=null?f:()=>{},this.config=e!=null?e:{},this.initialHelperPosition(),this.initialHelperQuaternion(),this.onWantsUpdateCameraDistance(),this.enable();const i=this.onSetOriginObjectScale.bind(this),s=this.onSetOriginObjectRotate.bind(this),o=this.onSetOriginObjectPosition.bind(this),r=this.onApplyOriginObjectScale.bind(this),a=this.onApplyOriginObjectRotate.bind(this),l=this.onApplyOriginObjectPosition.bind(this),c=this.initialHelperPosition.bind(this);this.internalHooks.on("setObjectPosition",this.onWantsUpdateCameraDistance),this.internalHooks.on("initialHelperPosition",this.onWantsUpdateCameraDistance),this.internalHooks.on("initialHelperPosition",c),this.internalHooks.on("setObjectScale",i),this.internalHooks.on("setObjectRotate",s),this.internalHooks.on("setObjectPosition",o),this.internalHooks.on("applyObjectPosition",l),this.internalHooks.on("applyObjectRotate",a),this.internalHooks.on("applyObjectScale",r),this.disposers.push(()=>{this.internalHooks.off("setObjectPosition",this.onWantsUpdateCameraDistance),this.internalHooks.off("initialHelperPosition",this.onWantsUpdateCameraDistance),this.internalHooks.off("initialHelperPosition",c),this.internalHooks.off("setObjectScale",i),this.internalHooks.off("setObjectRotate",s),this.internalHooks.off("setObjectPosition",o),this.internalHooks.off("applyObjectPosition",l),this.internalHooks.off("applyObjectRotate",a),this.internalHooks.off("applyObjectScale",r)})}initialHelperPosition(){this.helperObject3D.initialPosition(this.calculateOffset(this.config.offset))}initialHelperQuaternion(){var a,l,c;this.helperObject3D.initQuaternion();const t=(a=this.config.xAxis)!=null?a:new y.Vector3(1,0,0),e=(l=this.config.yAxis)!=null?l:new y.Vector3(0,1,0),i=(c=this.config.zAxis)!=null?c:new y.Vector3(0,0,1),s=new y.Quaternion;s.setFromUnitVectors(new y.Vector3(1,0,0),t.normalize());const o=new y.Quaternion;o.setFromUnitVectors(new y.Vector3(0,1,0),e.normalize());const r=new y.Quaternion;r.setFromUnitVectors(new y.Vector3(0,0,1),i.normalize()),this.helperObject3D.quaternion.premultiply(s),this.helperObject3D.quaternion.premultiply(o),this.helperObject3D.quaternion.premultiply(r)}enable(){this.enabled||(this.enabled=!0,this.scene.add(this.helperObject3D),this.helperObject3D.enable(),this.render())}disable(){this.enabled&&(this.enabled=!1,this.helperObject3D.disable(),this.render())}show(){this.helperObject3D.show(),this.render()}hide(){this.helperObject3D.hide(),this.render()}dispose(){var t;(t=this.disposers)==null||t.forEach(e=>e==null?void 0:e()),this.helperObject3D.dispose(),this.render()}applyHelperMatrix4(t){this.helperObject3D.applyMatrix4(t)}applyHelperQuaternion(t,e){this.helperObject3D.applyHelperQuaternion(t,e)}applyHelperScaleMatrix4(t,e){this.helperObject3D.applyHelperScaleMatrix4(t,e)}onWantsGesture(t,e,i){if(this.isDragging)return!1}onIntersectionOnModelUpdate(t){}onApplyOriginObjectScale(t){this.applyHelperScaleMatrix4(t.matrix,t.origin)}onApplyOriginObjectRotate(t){this.applyHelperQuaternion(t.quaternion,t.origin)}onApplyOriginObjectPosition(t){this.applyHelperMatrix4(t.matrix)}onSetOriginObjectScale(t){this.helperObject3D.scale.copy(t),this.updateOffsetByScale(t)}onSetOriginObjectRotate(t,e){this.helperObject3D.setHelperQuaternion(t,e)}onSetOriginObjectPosition(t){this.helperObject3D.position.copy(t.clone().add(this.calculateOffset(this.config.offset)))}render(){this.onRender()}updateOffsetByScale(t){if(this.boundingBox&&this.config.offset){const e=this.originObject3D.position,i=new y.Vector3().subVectors(this.boundingBox.max,e).multiply(t).add(e),s=new y.Vector3().subVectors(this.boundingBox.min,e).multiply(t).add(e),o=this.calculateOffset(this.config.offset,{min:s,max:i});this.helperObject3D.initialPosition(o)}}hoverListener(t,e=16777215,i=1){const s=yi(t).filter(ke),o=[];for(const r of s)if(r.material||r instanceof y.Group){const a=r instanceof y.Group?r.children.filter(f=>f instanceof y.Mesh):[r];a.forEach(f=>{f.__originalColor__=f.material.color.clone(),f.__originalOpacity__=f.material.opacity});const l=()=>{a.forEach(f=>{f.material.color.set(e),f.material.opacity=i}),this.render()},c=()=>{a.forEach(f=>{f.material.color.copy(f.__originalColor__),f.material.opacity=f.__originalOpacity__}),this.render()},h=()=>{this.isDragging||l()},u=()=>{this.isDragging||c()};for(const f of a)this.domEvents.addEventListener(f,"mouseover",h),this.domEvents.addEventListener(f,"mouseout",u),this.hooks.on("moveStart",l),this.hooks.on("moveEnd",c),this.hooks.on("rotateEnd",c),o.push(()=>{this.domEvents.removeEventListener(f,"mouseover",h),this.domEvents.removeEventListener(f,"mouseout",u),this.hooks.off("moveStart",l),this.hooks.off("moveEnd",c),this.hooks.off("rotateEnd",c)})}return()=>o.forEach(r=>r==null?void 0:r())}getIntersectObject(t){const e=this.camera.position,i=this.helperObject3D;if(!i)return;const s=this.helperObject3D.raycasterIntersectObject(t)[0];if(!s)return;const o=s;if(o.object=i,this.model.intersectRaycaster){const r=this.model.intersectRaycaster(t)[0];if(r&&r.point.distanceTo(e)<o.point.distanceTo(e))return}return o.object}calculateOffset(t,e){const i=new y.Vector3(0,0,0);if(!t)return i;const s=()=>e||this.getBox();if(typeof t.x=="number")i.setX(t.x);else if(typeof t.x=="object"){const o=s();i.setX((o.max.x-o.min.x)*t.x.percents)}if(typeof t.y=="number")i.setY(t.y);else if(typeof t.y=="object"){const o=s();i.setY((o.max.y-o.min.y)*t.y.percents)}if(typeof t.z=="number")i.setZ(t.z);else if(typeof t.z=="object"){const o=s();i.setZ((o.max.z-o.min.z)*t.z.percents)}return i}};const gv=new y.Vector3;function nn(n){var f;const{raycaster:t,line:e,clampToLine:i=!0}=n;if(((f=t.camera)==null?void 0:f.type)==="OrthographicCamera"){const g=t.ray.origin.clone();return e.closestPointToPoint(g,!1,new y.Vector3)}const s=new y.Plane().setFromNormalAndCoplanarPoint(t.ray.direction.clone().normalize(),t.ray.origin),o=s.projectPoint(e.start,new y.Vector3),r=s.projectPoint(e.end,new y.Vector3),a=new y.Line3(o,r),l=a.closestPointToPoint(t.ray.origin,i,gv),c=l.distanceTo(r),h=l.distanceTo(o),u=a.distance();if(c>h&&c>u){const g=-l.distanceTo(o)/u,v=e.start.clone().sub(e.end).normalize();return e.start.sub(v.clone().multiplyScalar(g*e.distance()))}else{const g=l.distanceTo(o)/u;return new y.Vector3().lerpVectors(e.start,e.end,g)}}let mv=class extends Ws{constructor(...e){super(...e);d(this,"name","MoveController");d(this,"startInfo");d(this,"_moveByMouse",{enabled:!1});d(this,"mouseInfo");d(this,"mousedownEventListenerDisposer");const i=this.helperObject3D;this.hoverListener([i.xArrow,i.yArrow,i.zArrow]);const s=this.dragStart.bind(this),o=this.dragging.bind(this),r=this.dragEnd.bind(this),a=this.show.bind(this),l=this.hide.bind(this);this.domEvents.addEventListener(this.helperObject3D,"mousedown",s),document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.hooks.on("rotateStart",l),this.hooks.on("rotateEnd",a),this.hooks.on("scaleStart",l),this.hooks.on("scaleEnd",a),this.hooks.on("moveByMouseEnable",l),this.hooks.on("moveByMouseDisable",a),this.disposers.push(()=>{this.domEvents.removeEventListener(this.helperObject3D,"mousedown",s),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.hooks.off("rotateStart",l),this.hooks.off("rotateEnd",a),this.hooks.off("scaleStart",l),this.hooks.off("scaleEnd",a),this.hooks.off("moveByMouseEnable",l),this.hooks.off("moveByMouseDisable",a)}),this.moveByMouseEnable&&this.moveByMouse()}get moveByMouseEnable(){return this._moveByMouse.enabled}dispose(){var e;super.dispose(),(e=this.disposers)==null||e.forEach(i=>i==null?void 0:i())}moveByMouse(e){this._moveByMouse={enabled:!0,useFaceNormal:e==null?void 0:e.useFaceNormal},this.preventTapDefaultEvent=!0;const i=this.handleMouseDown.bind(this),s=this.handleMouseUp.bind(this);this.hooks.emit("moveByMouseEnable"),setTimeout(()=>{this.container.addEventListener("mousedown",i),this.container.addEventListener("mouseup",s)}),this.mousedownEventListenerDisposer=()=>{this.container.removeEventListener("mousedown",i),this.container.removeEventListener("mouseup",s)}}disableMoveByMouse(){var e;this._moveByMouse={enabled:!1},this.preventTapDefaultEvent=!1,this.hooks.emit("moveByMouseDisable"),(e=this.mousedownEventListenerDisposer)==null||e.call(this)}onIntersectionOnModelUpdate(e){var r,a,l;if(!this.moveByMouseEnable)return;const{point:i,face:s}=e;if(!this.hooks.emit("wantToMove",i)){if(this.originObject3D.position.copy(i),(this._moveByMouse.useFaceNormal===!0||typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.enable!==!1)&&s!=null&&s.normal){const c=(()=>typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.alignmentVector?this._moveByMouse.useFaceNormal.alignmentVector:{x:0,y:1,z:0})(),h=new y.Vector3((r=c.x)!=null?r:0,(a=c.y)!=null?a:0,(l=c.z)!=null?l:0),u=(()=>typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.fixedFaceNormal?this._moveByMouse.useFaceNormal.fixedFaceNormal(s.normal):s.normal)();this.originObject3D.quaternion.setFromUnitVectors(h,u),this.internalHooks.emit("setObjectRotate",this.originObject3D.quaternion.clone())}this.internalHooks.emit("setObjectPosition",i),this.hooks.emit("move",i)}}handleMouseDown(e){const{x:i,y:s}=e;this.mouseInfo={x:i,y:s,mouseDownTimestamp:Date.now()}}handleMouseUp(e){if(!this.mouseInfo)return;const{x:i,y:s}=e;this.mouseInfo.x===i&&this.mouseInfo.y===s&&Date.now()-this.mouseInfo.mouseDownTimestamp<500&&(this.disableMoveByMouse(),this.mouseInfo=void 0)}dragStart(e){if(this.moveByMouseEnable||this.isDragging)return;const i=e==null?void 0:e.intersect;if(!i)return this.dragEnd();const s=(i==null?void 0:i.object).direction;if(!s)return this.dragEnd();const o=new y.Vector3(1,0,0).applyQuaternion(this.helperObject3D.quaternion),r=new y.Vector3(0,1,0).applyQuaternion(this.helperObject3D.quaternion),a=new y.Vector3(0,0,1).applyQuaternion(this.helperObject3D.quaternion),l=(()=>{switch(s){case"x":return o;case"y":return r;case"z":return a}})(),c=i.point.clone(),h=new y.Line3(c.clone().sub(l.normalize()),c.clone().add(l.normalize()));this.startInfo={startVectorProject:c,line:h},this.helperObject3D.showDraggingHelper([s]),this.hooks.emit("moveStart"),this.isDragging=!0}dragging(e){if(!this.isDragging||!this.startInfo)return;const i=Ar(this.camera,e,this.container);return i?(this.move(i),!1):this.dragEnd()}move(e){if(!this.startInfo)return this.dragEnd();const{line:i,startVectorProject:s}=this.startInfo,o=this.originObject3D,r=nn({raycaster:e,line:i,clampToLine:!1}),a=r.clone().sub(s),l=new y.Matrix4;l.setPosition(a);const c=o.position.clone().applyMatrix4(l);this.hooks.emit("wantToMove",c)||(o.applyMatrix4(l),s.copy(r),this.internalHooks.emit("applyObjectPosition",{matrix:l}),this.hooks.emit("move",c))}dragEnd(){this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.hooks.emit("moveEnd"))}};class ws{constructor(t,e,i,s,o,r,a){d(this,"helperController");d(this,"five");d(this,"onFiveWantsUpdateCameraDistance",()=>{var t,e;this.helperController&&((e=(t=this.helperController).onWantsUpdateCameraDistance)==null||e.call(t))});d(this,"onFiveWantsTapGesture",t=>{if(!this.helperController)return;if(this.helperController.preventTapDefaultEvent)return!1;const e=this.helperController.onWantsTapGesture(t);return this.five.needsRender=!0,e});d(this,"onFiveWantsGesture",(...t)=>{if(!this.helperController)return;const e=this.helperController.onWantsGesture(...t);return this.five.needsRender=!0,e});d(this,"onFiveIntersectionOnModelUpdate",(...t)=>{this.helperController&&this.helperController.onIntersectionOnModelUpdate(...t)});const{camera:l,model:c,scene:h}=t,u=t.getElement();if(this.five=t,!l||!c||!u||!h)return;const f=()=>{t.needsRender=!0};this.helperController=new e({camera:l,model:c,originObject3D:i,helperObject3D:s,container:u,scene:h,onRender:f,sharedHooks:r,sharedInternalHooks:a},o),t.on("wantsTapGesture",this.onFiveWantsTapGesture),t.on("wantsGesture",this.onFiveWantsGesture),t.on("intersectionOnModelUpdate",this.onFiveIntersectionOnModelUpdate),t.on("cameraFovUpdate",this.onFiveWantsUpdateCameraDistance),t.on("cameraPositionUpdate",this.onFiveWantsUpdateCameraDistance)}dispose(){var t;this.five.off("wantsTapGesture",this.onFiveWantsTapGesture),this.five.off("wantsGesture",this.onFiveWantsGesture),this.five.off("intersectionOnModelUpdate",this.onFiveIntersectionOnModelUpdate),this.five.off("cameraFovUpdate",this.onFiveWantsUpdateCameraDistance),this.five.off("cameraPositionUpdate",this.onFiveWantsUpdateCameraDistance),(t=this.helperController)==null||t.dispose()}}const pv="v1.0.1",vv="Object3DHelper",Pl=`${vv}@${pv}`,Av=()=>{console.error(`${Pl} is disposed`)},bv=()=>{console.warn(`${Pl} is disabled`)},yv=()=>{console.error(`${Pl} is disabled`)};class wv{constructor(t){d(this,"controllers",{});d(this,"state",{visible:!0,enabled:!0,disposed:!1});d(this,"hooks",new dt);d(this,"eventListener",{});t&&this.addControllers(t),this.setState(this.state)}show(t){return Q(this,null,function*(){this.setState({visible:!0},t)})}hide(t){return Q(this,null,function*(){this.setState({visible:!1},t)})}enable(t){this.setState({enabled:!0},t)}disable(t){this.setState({enabled:!1},t)}dispose(){this.setState({disposed:!0})}setState(t,e){if(this.state.disposed)return Av();if(!this.state.enabled&&t.enabled!==!0&&t.disposed!==!0)return yv();const i=x({},this.state);this.state=x(x({},this.state),t),t.disposed!==void 0&&t.disposed!==i.disposed&&t.disposed&&this.handleDispose(),t.visible!==void 0&&this.handleVisible(t.visible),t.enabled!==void 0&&this.handleEnable(t.enabled),this.hooks.emit("stateChange",{state:this.state,prevState:i})}addControllers(t){this.controllers=x(x({},this.controllers),t),this.setState(this.state)}getCurrentState(){return this.state}handleEnable(t,e=!0){t?(this.everyControllerDo(i=>{i.enable()}),this.hooks.emit("enable",{userAction:e})):(this.everyControllerDo(i=>{i.disable()}),this.hooks.emit("disable",{userAction:e})),this.state.enabled=t}handleVisible(t,e=!0){t?(this.everyControllerDo(i=>{i.show()}),this.actionIfStateIsEnabled(()=>this.hooks.emit("show",{userAction:e}))):(this.everyControllerDo(i=>{i.hide()}),this.actionIfStateIsEnabled(()=>this.hooks.emit("hide",{userAction:e}))),this.state.visible=t}everyControllerDo(t){Object.values(this.controllers).forEach(e=>{e&&t(e)})}handleDispose(){var t,e;Object.values(this.controllers).forEach(i=>{i==null||i.dispose()});for(const i in this.controllers){if(!i)continue;const s=i;(e=(t=this.eventListener)[s])==null||e.call(t)}}actionIfStateIsEnabled(t,e){if(this.state.enabled)return t();e!=null&&e.warnLog&&bv()}}function Il(n){return n*180/Math.PI}function wa(n){return n*Math.PI/180}const Ca=new y.Quaternion;class Cv extends Ws{constructor(...e){var c,h,u;super(...e);d(this,"name","RotateController");d(this,"startInfo");d(this,"removeListener");const i=this.helperObject3D;this.hoverListener([(c=i.xCircle)==null?void 0:c.circle,(h=i.yCircle)==null?void 0:h.circle,(u=i.zCircle)==null?void 0:u.circle].filter(Boolean));const s=this.dragStart.bind(this),o=this.dragging.bind(this),r=this.dragEnd.bind(this),a=this.show.bind(this),l=this.hide.bind(this);this.domEvents.addEventListener(this.helperObject3D,"mousedown",s),document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.hooks.on("moveStart",l),this.hooks.on("moveEnd",a),this.hooks.on("scaleStart",l),this.hooks.on("scaleEnd",a),this.hooks.on("moveByMouseEnable",l),this.hooks.on("moveByMouseDisable",a),this.removeListener=()=>{this.domEvents.removeEventListener(this.helperObject3D,"mousedown",s),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.hooks.off("moveStart",l),this.hooks.off("moveEnd",a),this.hooks.off("scaleStart",l),this.hooks.off("scaleEnd",a),this.hooks.off("moveByMouseEnable",l),this.hooks.off("moveByMouseDisable",a)}}get rotateCenter(){return this.helperObject3D.position.clone()}setRotateAngle(e){const{x:i=0,y:s=0,z:o=0}=e,r=new y.Euler(wa(i),wa(s),wa(o)),a=new y.Quaternion().setFromEuler(r);if(this.hooks.emit("wantToRotate",a))return;const{originObject3D:c,rotateCenter:h}=this;Df(c,a,h),this.internalHooks.emit("setObjectRotate",a,h),this.hooks.emit("rotate",a),this.render()}dispose(){this.removeListener(),super.dispose()}onApplyOriginObjectRotate(e){this.isDragging||super.onApplyOriginObjectRotate(e)}onApplyOriginObjectScale(e){}dragStart(e){if(this.isDragging)return;const i=e==null?void 0:e.intersect;if(!i)return this.dragEnd();const s=(i==null?void 0:i.object).direction;if(!s)return this.dragEnd();const o=i.point,r=this.getAngleHelper(s);this.setTipsAngle(0);const a=o.clone();a.y+=.2,this.setTipsPosition(a);const l=this.helperObject3D.quaternion.clone(),c=(()=>{if(s==="x")return new y.Vector3(1,0,0).applyQuaternion(l);if(s==="y")return new y.Vector3(0,1,0).applyQuaternion(l);if(s==="z")return new y.Vector3(0,0,1).applyQuaternion(l)})(),h=new y.Plane().setFromNormalAndCoplanarPoint(c,o),f=h.projectPoint(o.clone(),new y.Vector3).clone().sub(this.rotateCenter),g=f.angleTo(r.baseAxes.clone().applyQuaternion(l));this.setAngleHelperStart(s,g),this.setAngleHelperLength(s,0),this.startInfo={direction:s,startVector:f,plane:h,angleHelper:r,angle:0,helperQuaternion:l.clone()},Ca.copy(l),this.helperObject3D.showDraggingHelper([s]),this.hooks.emit("rotateStart"),this.isDragging=!0}dragging(e){if(!this.isDragging)return;const i=Ar(this.camera,e,this.container);return i?(this.rotate(i),!1):this.dragEnd()}rotate(e){if(!this.startInfo)return this.dragEnd();const{startVector:i,plane:s,angleHelper:o,direction:r,helperQuaternion:a}=this.startInfo,{originObject3D:l}=this,c=e.ray.intersectPlane(s,new y.Vector3);if(!c)return;const h=this.rotateCenter.clone(),f=s.projectPoint(c.clone(),new y.Vector3).clone().sub(h);if(i.angleTo(f)===0)return;const g=new y.Quaternion().setFromUnitVectors(i.clone().normalize(),f.clone().normalize()),v=l.quaternion.clone().premultiply(g);if(this.hooks.emit("wantToRotate",v))return;const A=new y.Euler().setFromQuaternion(new y.Quaternion().setFromUnitVectors(i.clone().normalize().applyQuaternion(a.clone().inverse()),f.clone().normalize().applyQuaternion(a.clone().inverse())),`${r.toUpperCase()}${"XZY".replace(r.toUpperCase(),"")}`)[r]*o.angleDirection;if(this.startInfo.angle+=A,this.setAngleHelperLength(r,this.startInfo.angle),this.setTipsAngle(Il(this.startInfo.angle)),h){const w=new y.Vector3().subVectors(l.position,h).applyQuaternion(g).add(h);l.position.copy(w)}l.applyQuaternion(g),Ca.premultiply(g),this.internalHooks.emit("applyObjectRotate",{quaternion:g,origin:h}),this.hooks.emit("rotate",l.quaternion),this.startInfo.startVector=f}dragEnd(){this.isDragging&&(this.internalHooks.emit("setObjectRotate",Ca,this.rotateCenter),this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.hooks.emit("rotateEnd"))}getAngleHelper(e){var i,s,o;switch(e){case"x":return(i=this.helperObject3D.xCircle)==null?void 0:i.angleSector;case"y":return(s=this.helperObject3D.yCircle)==null?void 0:s.angleSector;case"z":return(o=this.helperObject3D.zCircle)==null?void 0:o.angleSector}}setAngleHelperStart(e,i){const s=this.getAngleHelper(e);if(!s){console.warn("angleHelper is undefined");return}if(s instanceof y.Mesh&&s.geometry instanceof y.CircleGeometry){const{radius:o,segments:r,thetaLength:a}=s.geometry.parameters;s.geometry=new y.CircleGeometry(o,r,i,a)}else console.warn("only support THREE.CircleGeometry")}setAngleHelperLength(e,i){const o=i>=0?Math.max(i,.001):Math.min(i,-.001),r=this.getAngleHelper(e);if(r instanceof y.Mesh&&r.geometry instanceof y.CircleGeometry){const{radius:a,thetaStart:l}=r.geometry.parameters,c=Math.ceil(Math.abs(o)*(40/(2*Math.PI)));r.geometry=new y.CircleGeometry(a,c,l,o)}else console.warn("only support THREE.CircleGeometry")}setTipsAngle(e){var s;const i=(s=this.helperObject3D.angleTips)==null?void 0:s.element;i&&(i.innerText=`${e.toFixed(0)}°`)}setTipsPosition(e){const i=this.helperObject3D.angleTips;if(!i)return;const s=e.project(this.camera),{x:o,y:r,z:a}=s;if(a>1)return;const l=(o+1)/2*100+"%",c=(-r+1)/2*100+"%";i.setLeftTop(l,c)}}class Pv extends Ws{constructor(...e){super(...e);d(this,"startInfo");d(this,"name","RectangleScaleController")}enable(){this.helperObject3D.enable(),super.enable()}disable(){this.helperObject3D.disable(),super.disable()}show(){this.helperObject3D.show(),super.show()}hide(){this.helperObject3D.hide(),super.hide()}onApplyOriginObjectPosition(e){this.isDragging||super.onApplyOriginObjectPosition(e)}onApplyOriginObjectScale(e){this.helperObject3D.applyHelperScaleMatrix4(e.matrix,e.origin)}getDragPlane(){const e=new y.Plane,i=this.helperObject3D.cornerPositions;if(i.length!==0)return i.length<3?e.setFromNormalAndCoplanarPoint(this.originObject3D.getWorldDirection(new W.Vector3),i[0]):e.setFromCoplanarPoints(i[0],i[1],i[2]),e}dragStart(e,i){var o,r;(r=(o=this.helperObject3D).updatePoints)==null||r.call(o);const s=this.getDragPlane();if(!s)return this.dragEnd();this.startInfo={startPoint:{position:i.position.clone(),direction:i.direction},plane:s},this.hooks.emit("scaleStart"),this.render(),this.isDragging=!0}dragging(e){if(!this.isDragging)return;const i=Ar(this.camera,e,this.container);if(!i)return this.dragEnd();this.scale(i)}scale(e){var Y,H;if(!this.startInfo)return;const i=this.originObject3D,{startPoint:s,plane:o}=this.startInfo,r=this.helperObject3D.cornerPositions;if(r.length<4)return this.dragEnd();const a=e.ray.intersectPlane(o,new W.Vector3);if(!a||nv(a,this.camera.position))return;const l=new W.Vector3().addVectors(r[0],r[2]).divideScalar(2),{position:c,direction:h}=s,u=new W.Vector3().subVectors(r[1],r[0]),f=new W.Vector3().subVectors(r[3],r[0]),g=_=>{const G=new W.Vector3(0,0,0);if(!this.startInfo)return G;const N=(_==="ew"?u:f).clone(),U=c.clone().projectOnVector(N),F=a.clone().projectOnVector(N),X=l.clone().projectOnVector(N);if(F.equals(U))return G;if(_==="ns"&&typeof this.startInfo.dragPointInCenterBottom!="boolean"){const ae=new W.Vector3().subVectors(F,X),re=ae.x<0&&N.x>=0,Pe=ae.y<0&&N.y>=0,ve=ae.z<0&&N.z>=0;this.startInfo.dragPointInCenterBottom=re||Pe||ve}if(_==="ew"&&typeof this.startInfo.dragPointInCenterLeft!="boolean"){const ae=new W.Vector3().subVectors(F,X),re=ae.x<0&&N.x>=0,Pe=ae.y<0&&N.y>=0,ve=ae.z<0&&N.z>=0;this.startInfo.dragPointInCenterLeft=re||Pe||ve}const J=new W.Vector3().subVectors(F,U),q=J.length();return q>.3?(console.warn("offset.length() > 0.3, skipped",q),G):J},v=g("ew"),p=g("ns"),m=()=>{const _=v;this.helperObject3D.cornerPositions.forEach((G,N)=>{var U;(U=this.startInfo)!=null&&U.dragPointInCenterLeft?(N===0||N===3)&&G.add(_):(N===1||N===2)&&G.add(_)})},A=()=>{const _=p;this.helperObject3D.cornerPositions.forEach((G,N)=>{var U;(U=this.startInfo)!=null&&U.dragPointInCenterBottom?(N===0||N===1)&&G.add(_):(N===2||N===3)&&G.add(_)})};switch(h){case"ew":m();break;case"ns":A();break;case"nesw":case"nwse":m(),A()}const w=new W.Vector3().subVectors(r[1],r[0]).length()/u.length(),I=new W.Vector3().subVectors(r[3],r[0]).length()/f.length(),P=new W.Vector3(w,I,1),k=new y.Matrix4().scale(P);i.isCSS3DObjectPlus?i.applyScaleMatrix4(k):i.scale.applyMatrix4(k),s.position.copy(a);const E=new W.Vector3().addVectors(r[0],r[2]).divideScalar(2),L=new W.Vector3().subVectors(E,l),R=new y.Matrix4().setPosition(L);i.applyMatrix4(R),(Y=this.helperObject3D.css3DInstance)==null||Y.css3DObject.applyMatrix4(R),(H=this.helperObject3D.plane)==null||H.applyMatrix4(R),this.internalHooks.emit("applyObjectScale",{matrix:k}),this.internalHooks.emit("applyObjectPosition",{matrix:R}),this.render()}dragEnd(){this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.hooks.emit("scaleEnd"),this.render())}}class Iv extends Pv{constructor(...e){super(...e);d(this,"name","CSS3DScaleController");this.addHTMLEventListener()}addHTMLEventListener(){this.helperObject3D.points.forEach(e=>{if(!e)return;const i=e.point,s=a=>this.dragStart(a,e),o=this.dragging.bind(this),r=this.dragEnd.bind(this);i.addEventListener("dragstart",s),i.addEventListener("drag",o),i.addEventListener("dragend",r)})}}const Gt=document.createElement("div");Gt.classList.add("behindFiveElement");Gt.style.position="absolute";Gt.style.top="0";Gt.style.left="0";Gt.style.width="100%";Gt.style.height="100%";Gt.style.pointerEvents="none";function Lf(n){var i,s,o,r,a;const t=(a=(s=Pa(n.getElement()))!=null?s:Pa((i=n.getElement())==null?void 0:i.parentElement))!=null?a:Pa((r=(o=n.getElement())==null?void 0:o.parentElement)==null?void 0:r.parentElement),e=t==null?void 0:t.parentElement;if(e)return e.contains(Gt)||t.parentElement.insertBefore(Gt,t),Gt;console.error("Can not find a valid element to insert behindFiveElement. How to fix it: https://github.com/realsee-developer/dnalogel/tree/main/plugins/src/CSS3DRenderPlugin/README.md")}function Pa(n){var a;if(!n)return;const t=(a=n.style.position)!=null?a:getComputedStyle(n).position;if(t!=="fixed"&&t!=="absolute"&&t!=="relative")return;const e=getComputedStyle(n),i=e.backgroundColor,s=e.backgroundImage;if(!(i!=="transparent"&&i!=="rgba(0, 0, 0, 0)"&&i!==""||s!=="none"&&s!==""))return n}class Ev extends Ws{constructor(...e){super(...e);d(this,"name","BoundingBoxController")}}class Mv extends $p{constructor(e,i){super(e,i);d(this,"scaleMeshes",[]);d(this,"positions",[]);i&&(this.positions=i.positions)}initialPosition(e){this.position.copy(this.originObject3D.position),this.scaleMeshes.length&&this.remove(...this.scaleMeshes);const i=typeof this.positions=="function"?this.positions():this.positions;i&&(this.scaleMeshes=i.map(s=>{const o=kv();return o.position.copy(s.handlePosition),o.scalePosition=s,o}),this.add(...this.scaleMeshes))}setScaleByCamera(e){this.scaleMeshes.forEach(i=>{i.scale.setScalar(Cl(e,i.scalePosition.handlePosition.clone().applyMatrix4(this.matrixWorld)))})}}function kv(){const t=new y.BoxGeometry(.05,.05,.05),e=new y.MeshBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide}),i=new y.Mesh(t,e);return i.renderOrder=10,i}class xv extends Ws{constructor(...e){super(...e);d(this,"name","ScaleController");d(this,"startInfo");d(this,"dragStart",e=>{if(this.isDragging)return;this.isDragging=!0;const{intersect:i}=e,s=this.camera.position,o=i.object,r=o.scalePosition.basePosition.clone(),l=o.scalePosition.handlePosition.clone().clone().sub(r).clone(),c=new y.Line3(r,r.clone().add(l.normalize().multiplyScalar(5)));c.applyMatrix4(this.helperObject3D.matrixWorld);const h=new y.Raycaster(s,i.point.clone().sub(s)),u=nn({raycaster:h,line:c});this.startInfo={line:c,scaleStartPoint:u,draggingObject:o},this.hooks.emit("scaleStart")});d(this,"dragging",e=>{if(!this.isDragging||!this.startInfo)return;const i=Ar(this.camera,e,this.container);return i?(this.scale(i),!1):this.dragEnd()});d(this,"scale",e=>{var c,h;if(!this.startInfo)return;const{line:i,scaleStartPoint:s,draggingObject:o}=this.startInfo,{scalePosition:r}=o,{basePosition:a}=r,l=nn({raycaster:e,line:i});l.applyMatrix4(new y.Matrix4().getInverse(this.helperObject3D.matrixWorld.clone())),(h=(c=this.config)==null?void 0:c.scaleCallback)==null||h.call(c,{ratio:l.distanceTo(a)/s.distanceTo(a),intersectPoint:l,scalePosition:r}),o.position.copy(l.clone())});d(this,"dragEnd",()=>{this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.internalHooks.emit("initialHelperPosition"),this.hooks.emit("scaleEnd"))});this.domEvents.addEventListener(this.helperObject3D,"mousedown",this.dragStart),document.addEventListener("mousemove",this.dragging),document.addEventListener("mouseup",this.dragEnd)}initialHelperQuaternion(){this.helperObject3D.initQuaternion()}initialHelperPosition(){this.helperObject3D.initialPosition();const e=this;e.offHoverListener&&e.offHoverListener(),e.offHoverListener=this.hoverListener(this.helperObject3D.scaleMeshes)}setScale(e){var l,c,h;let i=1,s=1,o=1;typeof e=="number"?(i=e,s=e,o=e):typeof e=="object"&&(i=(l=e.x)!=null?l:1,s=(c=e.y)!=null?c:1,o=(h=e.z)!=null?h:1);const r=new y.Vector3(i,s,o);this.hooks.emit("wantToScale",r)||(this.originObject3D.scale.copy(r),this.internalHooks.emit("setObjectScale",r),this.hooks.emit("scale",r),this.render())}}function Kn(n){return Q(this,null,function*(){return new Promise(t=>{if(Dv(n))t();else{const e=i=>{const s=Vt(n);i===s&&(n.off("modelLoaded",e),t())};n.on("modelLoaded",e)}})})}function Dv(n){var t;return(t=Vt(n))==null?void 0:t.loaded}const Za="Object3DHelperPlugin",br=Za,Sv=()=>{console.error(`${br} is disposed`)},Tv=()=>{console.warn(`${br} is disabled`)},Lv=()=>{console.error(`${br} is disabled`)};class El extends Oi{constructor(e){super(e);d(this,"name",Za);d(this,"state",{visible:!0,enabled:!0,disposed:!1});d(this,"objectHelperMap",new Map);d(this,"css3DObjectParentMap",new Map);d(this,"css3DRender");this.five=e,this.css3DRender=new Gn(this.five.scene),console.warn("Object3DHelper: 使用此插件,需要在初始化five时,设置five参数: { backgroundAlpha: 0, backgroundColor: 0x000000 }"),Object.assign(window,{[`__${Za.toUpperCase()}_DEBUG__`]:this})}show(e){return Q(this,null,function*(){this.setState({visible:!0},e)})}hide(e){return Q(this,null,function*(){this.setState({visible:!1},e)})}enable(e){this.setState({enabled:!0},e)}disable(e){this.setState({enabled:!1},e)}dispose(){this.setState({disposed:!0})}setState(e,i){if(this.state.disposed)return Sv();if(!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return Lv();const s=x({},this.state);this.state=x(x({},this.state),e),e.disposed!==void 0&&e.disposed!==s.disposed&&e.disposed&&this.handleDispose(),e.visible!==void 0&&e.visible!==s.visible&&this.handleVisible(e.visible),e.enabled!==void 0&&e.enabled!==s.enabled&&this.handleEnable(e.enabled),this.hooks.emit("stateChange",{state:this.state,prevState:s})}getObject3DHelper(e){return this.objectHelperMap.get(e)}addObject3DHelper(e,i={}){var A;if(!e){console.error("Object3D is undefined");return}if(this.objectHelperMap.has(e)){console.warn(`Object3DHelperPlugin: object3D ${e.name} is already has helper`);return}const s=new wv,o=[],r=(A=this.five.getElement())==null?void 0:A.parentElement,a=this.five.camera,c=x(x({},{moveHelper:!0,rotateHelper:!0,scaleHelper:!0,boundingBoxHelper:!1,positionFrom:"objectPosition"}),i),{moveHelper:h,rotateHelper:u,scaleHelper:f,boundingBoxHelper:g}=c,v=new dt,p=new dt,m=w=>{if(w)return typeof w=="boolean"?w:w.enable};if(m(h)){const w=x(x({},this.getConfig(c.moveHelper)),c),I=new sv(e,x({},w)),P=new ws(this.five,mv,e,I,w,v,p);s.addControllers({moveController:P.helperController}),o.push(()=>P.dispose())}if(m(u)){const w=x(x({},this.getConfig(c.rotateHelper)),c),I=new av(e,x({container:r},w)),P=new ws(this.five,Cv,e,I,w,v,p);s.addControllers({rotateController:P.helperController}),o.push(()=>P.dispose())}if(m(g)){const w=new fv(e),I=new ws(this.five,Ev,e,w,void 0,v,p);s.addControllers({boundingBoxController:I.helperController})}if(m(f))if(e.isCSS3DObjectPlus&&r){const w=new uv(e,r,a,this.five.scene),I=new ws(this.five,Iv,e,w,void 0,v,p);s.addControllers({scaleController:I.helperController}),o.push(()=>I.dispose()),Kn(this.five).then(()=>{var P,k;if(e.isCSS3DObjectPlus){const E=e;if(!E||E.mode!=="front")return;const L=(P=this.css3DRender.behindModeCSS3DRenderer.wrapper)!=null?P:Lf(this.five);L&&(this.css3DObjectParentMap.set(E,E.parent),E.removeFromParent(),this.css3DRender.behindModeCSS3DRenderer.setWrapper(L),(k=this.css3DRender.getBehindCSS3DObjectGroup())==null||k.add(E),this.css3DRender.render(this.five.camera))}})}else{const w=x(x({},this.getConfig(c.scaleHelper)),c),I=new Mv(e,w),P=new ws(this.five,xv,e,I,w,v,p);s.addControllers({scaleController:P.helperController}),o.push(()=>P.dispose())}return this.objectHelperMap.set(e,{helper:s,disposers:o}),s.controllers}removeObject3DHelper(e){if(!this.objectHelperMap.has(e))return;const{helper:i,disposers:s}=this.objectHelperMap.get(e);if(i){if(e.isCSS3DObjectPlus){const o=e,r=this.css3DObjectParentMap.get(o);r&&r.add(o),this.css3DRender.render(this.five.camera)}this.objectHelperMap.delete(e),i.dispose(),s==null||s.forEach(o=>o==null?void 0:o())}}handleEnable(e,i=!0){e?(this.everyHelperDo(s=>s.enable()),this.hooks.emit("enable",{userAction:i})):(this.everyHelperDo(s=>s.disable()),this.hooks.emit("disable",{userAction:i})),this.state.enabled=e}handleVisible(e,i=!0){e?(this.everyHelperDo(s=>s.show()),this.actionIfStateIsEnabled(()=>this.hooks.emit("show",{userAction:i}))):(this.everyHelperDo(s=>s.hide()),this.actionIfStateIsEnabled(()=>this.hooks.emit("hide",{userAction:i}))),this.state.visible=e}handleDispose(){this.everyHelperDo((e,i)=>{e.dispose(),i==null||i.forEach(s=>s==null?void 0:s())})}everyHelperDo(e){this.objectHelperMap.forEach(({helper:i,disposers:s})=>{i&&e(i,s)})}actionIfStateIsEnabled(e,i){if(this.state.enabled)return e();i!=null&&i.warnLog&&Tv()}getConfig(e){if(e&&typeof e!="boolean"&&e.enable)return e}}const jv=n=>new El(n);function jf(n,t){const{top:e,left:i,width:s,height:o}=t.getBoundingClientRect();return new y.Vector2((n.x-i)/s*2-1,-(n.y-e)/o*2+1)}class Sc extends y.Raycaster{intersectObject(t,e=!0,i=[]){return Ja(t,this,i,e),i.sort(Tc),i}intersectObjects(t,e=!0,i=[]){for(let s=0,o=t.length;s<o;s++)Ja(t[s],this,i,e);return i.sort(Tc),i}}function Tc(n,t){return n.distance-t.distance}function Ja(n,t,e,i){let s=!0;if(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0){const o=n.children;for(let r=0,a=o.length;r<a;r++)Ja(o[r],t,e,!0)}}function Ml(n,t,e,i){let s=!0;if(n.type!=="Line2"&&(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0)){const o=n.children;for(let r=0,a=o.length;r<a;r++)o[r].type!=="Line2"&&Ml(o[r],t,e,!0)}}class kl{constructor(t,e){d(this,"five");d(this,"dragging",!1);d(this,"boundObject",{});d(this,"config");d(this,"lastMouseDownEvent");d(this,"handleWantsGesture",(t,e)=>{if(e.length!==1)return;const i=e[0];if(i.raycaster){const s=new Sc;s.ray=i.raycaster.ray,s.near=i.raycaster.near,s.far=i.raycaster.far,s.camera=i.raycaster.camera,s.layers=i.raycaster.layers,s.params=i.raycaster.params,i.raycaster=s}if(i){if(t==="mouseMove"&&this.onDomEvent("hover",i),t==="tap"){const s=this.lastMouseDownEvent,o=this.onDomEvent("click",i,s),r=this.onDomEvent("wantDblclick",i,s,this.boundObject.dblclick);if(o===!1||r===!1)return!1}if(this.dragging)return!1}});d(this,"handleDomEvent",(t,e,i)=>{const s={x:e.clientX,y:e.clientY};this.onDomEvent(t,s,e,i)});d(this,"handleMouseEvent",t=>{this.handleDomEvent(t.type,t)});d(this,"handleMousedown",t=>{this.lastMouseDownEvent=t,this.handleDomEvent("mousedown",t),this.handleDomEvent("dragstart",t,this.haveDragEventObject)});d(this,"handleMouseup",t=>{var e;this.dragging=!1,(e=this.haveDragEventObject)==null||e.forEach(i=>{i._dragging&&(i._dragging=!1,this.notify({eventName:"dragend",object:i,originEvent:t,raycaster:this.getRaycaster({x:t.clientX,y:t.clientY})}))}),this.handleDomEvent("mouseup",t)});d(this,"handleMousemove",t=>{var e;this.dragging&&((e=this.boundObject.drag)==null||e.forEach(i=>{i._dragging&&this.notify({eventName:"drag",object:i,originEvent:t,raycaster:this.getRaycaster({x:t.clientX,y:t.clientY})})}))});d(this,"onDomEvent",(t,e,i,s=this.boundObject[t])=>{var f,g,v,p,m;if(!e||!s||(s==null?void 0:s.length)===0)return;const o=[];((f=this.config)==null?void 0:f.fiveModels)!==null&&((g=this.config)!=null&&g.fiveModels?o.push(...this.config.fiveModels):o.push(this.model));const r=o.filter(A=>A.loaded),a=(v=e.raycaster)!=null?v:this.getRaycaster(e);a.params.Points.threshold=.02;const l=a.intersectObjects(s,!0),c=[];r.forEach(A=>{const w=A.intersectRaycaster(a);c.push(...w)});const h=.01;if(c.length>0&&l.length>0&&c[0].distance+h<l[0].distance)return;const u=(p=l==null?void 0:l[0])==null?void 0:p.object;if(t==="wantDblclick")return!1;if((!u||!this.objectIsBound(u))&&t==="hover")for(const A of(m=this.boundObject.hover)!=null?m:[])A._hovered&&this.notify({eventName:"unHover",object:A});if(u&&u&&this.notify({eventName:t,object:u,originEvent:i,raycaster:a,intersects:l}))return!1});d(this,"objectIsBound",t=>{let e=t._domEvent,i=t.parent;for(;typeof e=="undefined"&&i;)e=i._domEvent,i=i.parent;return!!e});d(this,"notify",t=>{var f,g,v;const{eventName:e,object:i,originEvent:s,raycaster:o,intersects:r}=t;let a=!1,l=[];const c=[];let h=i;for(c.push(h);h.parent;)h=h.parent,c.push(h);const u=c.at(-1);if(!((f=this.config)!=null&&f.noEmitWhenNotInScene&&u.type!=="Scene")){for(const p of c){if(a)break;p.draggable&&(e==="dragstart"&&(p._dragging=!0,this.dragging=!0),e==="dragend"&&(p._dragging=!1,this.dragging=!1));const m=p._domEvent;if(!m)continue;const A=m[`${e}Handler`];if(A)for(const[w,I]of A){if(I!=null&&I.noEmitWhenNotInScene&&u.type!=="Scene"||((g=this.config)!=null&&g.noEmitWhenHide||I!=null&&I.noEmitWhenHide)&&!Al(p))continue;if(e==="hover"){if(p._hovered)continue;p._hovered=!0;for(const k of(v=this.boundObject.hover)!=null?v:[])k!==p&&k._hovered&&this.notify({eventName:"unHover",object:k})}if(e==="unHover"){if(!p._hovered)continue;p._hovered=!1}const P=w({type:e,target:p,origDomEvent:s,raycaster:o,intersects:r,stopPropagation:()=>{a=!0}});l.push(P!=null?P:!0)}}if(e==="click"||e==="wantDblclick")return l.some(p=>p===!0)}});this.five=t,this.config=e,t.on("wantsGesture",this.handleWantsGesture),document.addEventListener("mousedown",this.handleMousedown),document.addEventListener("dblclick",this.handleMouseEvent),document.addEventListener("mouseup",this.handleMouseup),document.addEventListener("mousemove",this.handleMousemove)}get haveDragEventObject(){return[...new Set([this.boundObject.dragend,this.boundObject.drag,this.boundObject.dragstart].flat())].filter(Boolean)}get model(){return Vt(this.five)}addAutoBindEventListener(t,e,i,s){const o=()=>this.addEventListener(t,e,i,s),r=()=>this.removeEventListener(t,e,i,s);return t.addEventListener("added",o),t.addEventListener("removed",r),t.addEventListener("dispose",r),()=>{t.removeEventListener("added",o),t.removeEventListener("removed",r),t.removeEventListener("dispose",r)}}addEventListener(t,e,i,s){t._domEvent||(t._domEvent={}),t._domEvent[`${e}Handler`]||(t._domEvent[`${e}Handler`]=[]),this.boundObject[e]||(this.boundObject[e]=[]),this.boundObject[e].includes(t)||this.boundObject[e].push(t),t._domEvent[`${e}Handler`].push([i,x({noEmitWhenHide:!1,noEmitWhenNotInScene:!1},s)])}removeEventListener(t,e,i,...s){var r,a;if(!t._domEvent||(e===void 0&&(Object.keys(this.boundObject).forEach(l=>{var h,u;const c=(h=this.boundObject[l])==null?void 0:h.findIndex(f=>f===t);c!==-1&&((u=this.boundObject[l])==null||u.splice(c,1))}),t._domEvent={}),!t._domEvent[`${e}Handler`]))return;if(i===void 0){delete t._domEvent[`${e}Handler`];return}const o=t._domEvent[`${e}Handler`].findIndex(l=>l[0]===i);if(o!==-1&&(t._domEvent[`${e}Handler`].splice(o,1),t._domEvent[`${e}Handler`].length===0&&delete t._domEvent[`${e}Handler`],t._domEvent&&Object.keys(t._domEvent).length===0&&delete t._domEvent,!t._domEvent)){const l=(r=this.boundObject[e])==null?void 0:r.findIndex(c=>c===t);l!==-1&&((a=this.boundObject[e])==null||a.splice(l,1))}}clear(){this.boundObject={}}dispose(){var t;(t=this.five)==null||t.off("wantsGesture",this.handleWantsGesture),document.removeEventListener("mousedown",this.handleMousedown),document.removeEventListener("mouseup",this.handleMouseup),document.removeEventListener("mousemove",this.handleMousemove),this.boundObject={}}toJSON(){return{boundObject:this.boundObject}}getRaycaster(t){const e=this.five.getElement();if(!e)return;const i=jf(t,e),s=new Sc;return s.setFromCamera(i,this.five.camera),s}}const zf="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function zv(n,t){const{x:e,y:i}=t,s=e*2-1,o=i*2-1,r=new y.Raycaster;return r.setFromCamera({x:s,y:o},n.camera),r.params.Points.threshold=.02,r}function Us(n,t,e){const i=Ov(n,t);return e!=null&&e.virtualPoint?i!=null?i:Of(t):i}function Of(n,t=3){const e=new y.Vector3().addVectors(n.ray.origin,n.ray.direction.clone().normalize().multiplyScalar(t)),i=n.ray.direction.clone().negate();return{distance:t,point:e,object:new y.Object3D,face:new y.Face3(0,0,0,i),raycaster:n,isVirtual:!0}}function Ov(n,t){const s=Vt(n).intersectRaycaster(t)[0];if(s)return ie(x({},s),{raycaster:t,isVirtual:!1})}const Vv=new y.Vector3,Pn=()=>!1;class Vf extends dt{constructor(e,i){var r,a,l;super();d(this,"outOfFive",!1);d(this,"enabled",!1);d(this,"actionIfNoModelUnderMouse","virtualPoint");d(this,"plane");d(this,"pointSelectorHelper");d(this,"hook",this);d(this,"five");d(this,"hammer");d(this,"mode");d(this,"pressDown",!1);d(this,"adherePoints");d(this,"adherePointsRadius",.1);d(this,"lastFiveHelperVisible");d(this,"lastIntersection");d(this,"mousePosition");d(this,"config",{});d(this,"select",e=>{e&&this.updatePointSelectorHelperIntersect(e);const i=this.emit("wantsSelect",this.position);return i||(this.pointSelectorHelper.hide(),this.emit("select",this.position),console.debug(this.position)),!i});d(this,"onEnter",()=>{this.pointSelectorHelper.show(),this.outOfFive=!1,this.emit("intersectionUpdate",this.position)});d(this,"onLeave",()=>{this.pointSelectorHelper.hide(),this.outOfFive=!0,this.emit("intersectionUpdate",null)});d(this,"onTap",e=>{e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),this.select()});d(this,"onPan",e=>{this.pressDown&&(e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),this.mouseNdcPosition&&this.updateByNdcPosition(this.mouseNdcPosition))});d(this,"onPress",e=>{if(e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),!this.mouseNdcPosition)return;const i=this.updateByNdcPosition(this.mouseNdcPosition);this.pressDown=i});d(this,"onPanEnd",()=>{this.pressDown&&(this.pressDown=!1,this.select())});d(this,"updateByMousePosition",e=>{this.five.getElement()&&(this.mousePosition=e,this.updateByNdcPosition(this.mouseNdcPosition))});d(this,"updateByNdcPosition",e=>{var o,r;const i=zv(this.five,e),s=Us(this.five,i);if(s)return this.updatePointSelectorHelperIntersect(s),this.lastIntersection=s,!0;if(this.plane){const a=i.ray.intersectPlane(this.plane,Vv);if(a){const l={distance:this.five.camera.position.distanceTo(a),point:a.clone(),object:new y.Object3D,face:new y.Face3(0,0,0,this.plane.normal.clone()),raycaster:i,isVirtual:!0};return this.updatePointSelectorHelperIntersect(l),!0}}if(this.actionIfNoModelUnderMouse==="lastPoint")return this.updatePointSelectorHelperIntersect(this.lastIntersection),!0;if(this.actionIfNoModelUnderMouse==="virtualPoint"){const a=Of(i,(o=this.lastIntersection)==null?void 0:o.distance);return a.face=new y.Face3(0,0,0,(r=this.lastIntersection)==null?void 0:r.face.normal),this.lastIntersection=a,this.updatePointSelectorHelperIntersect(a),!0}else if(this.actionIfNoModelUnderMouse==="disable")return this.updatePointSelectorHelperIntersect(null),!1});d(this,"updatePointSelectorHelperIntersect",e=>{if(!e){this.onLeave(),this.five.getElement().style.cursor=`url("data:image/svg+xml,%3Csvg width='12px' height='12px' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cpath d='M6,12 C9.3137085,12 12,9.3137085 12,6 C12,2.6862915 9.3137085,0 6,0 C2.6862915,0 0,2.6862915 0,6 C0,9.3137085 2.6862915,12 6,12 Z' fill='%23FF5959'%3E%3C/path%3E%3Cg transform='translate(2, 2)' stroke='%23FFFFFF'%3E%3Ccircle cx='4' cy='4' r='4'%3E%3C/circle%3E%3Cline x1='1.07141075' y1='1.23997894' x2='6.64700843' y2='6.81557662'%3E%3C/line%3E%3C/g%3E%3C/g%3E%3C/svg%3E"), auto`;return}this.onEnter(),this.five.getElement().style.cursor="";const i=x({},e);let s=!1;if(typeof this.adherePoints=="function"&&typeof this.adherePointsRadius=="number"){for(const o of this.adherePoints({intersection:e,pointSelectorInstance:this}))if(o.distanceTo(e.point)<this.adherePointsRadius){i.point=o.clone(),s=!0;break}}this.pointSelectorHelper.updateWithIntersect(i,{emitEvent:!1}),this.emit("intersectionUpdate",i,s)});d(this,"mousePositionToNdcPosition",e=>{const i=this.five.getElement();if(!i)return null;const{top:s,left:o,width:r,height:a}=i.getBoundingClientRect(),{clientX:l,clientY:c}=e;return{x:(l-o)/r,y:1-(c-s)/a}});d(this,"onFiveWantsPanGesture",()=>{if(this.pressDown)return!1});d(this,"renderScreenCenter",()=>{this.updateByNdcPosition({x:.5,y:.5})});d(this,"emitIntersectionUpdate",e=>{this.emit("intersectionUpdate",e)});this.five=e,this.config=x(x({},this.config),i),this.actionIfNoModelUnderMouse=(r=i==null?void 0:i.actionIfNoModelUnderMouse)!=null?r:"virtualPoint";const s=(a=i==null?void 0:i.mode)!=null?a:"auto";s==="auto"?this.mode=zf?"fixed":"cursor":this.mode=s;const o={autoFixPCPosition:this.mode==="cursor",initialPosition:this.mode==="fixed"?{left:"35%",top:"20%"}:void 0};this.pointSelectorHelper=new Rf(this.five,ie(x({},i==null?void 0:i.helper),{magnifierParams:x(x({},o),(l=i==null?void 0:i.helper)==null?void 0:l.magnifierParams)})),this.pointSelectorHelper.hide()}get position(){return this.outOfFive?null:this.pointSelectorHelper.position}get mouseNdcPosition(){return this.mousePosition?this.mousePositionToNdcPosition(this.mousePosition):null}enable(){if(this.enabled)return;this.enabled=!0,this.outOfFive=!1,this.pointSelectorHelper.enable();const e=this.five.getElement();if(!e)throw new Error("five element not found");this.hammer||(this.hammer=new fr(e)),this.mode==="cursor"?(this.five.on("wantsPanGesture",this.onFiveWantsPanGesture),this.five.on("wantsMoveToPano",Pn),this.five.on("wantsChangeMode",Pn),this.five.on("wantsTapGesture",Pn),e.addEventListener("mousemove",this.updateByMousePosition),e.addEventListener("wheel",this.updateByMousePosition),e.addEventListener("mouseenter",this.onEnter),e.addEventListener("mouseout",this.onLeave),this.hammer.on("tap",this.onTap),this.hammer.on("pan",this.onPan),this.hammer.on("press",this.onPress),this.hammer.on("panend",this.onPanEnd)):this.mode==="fixed"&&(this.five.on("panoArrived",this.renderScreenCenter),this.five.on("panGesture",this.renderScreenCenter),this.five.on("interiaPan",this.renderScreenCenter),this.renderScreenCenter(),this.pointSelectorHelper.show()),this.pointSelectorHelper.hooks.on("intersectionUpdate",this.emitIntersectionUpdate),this.lastFiveHelperVisible=this.five.helperVisible,this.five.helperVisible=!1,this.emit("enable")}disable(){if(!this.enabled)return;this.enabled=!1,this.pointSelectorHelper.disable(),this.five.getElement().style.cursor="";const e=this.five.getElement();this.five.off("wantsPanGesture",this.onFiveWantsPanGesture),this.five.off("wantsMoveToPano",Pn),this.five.off("wantsChangeMode",Pn),this.five.off("wantsTapGesture",Pn),this.five.helperVisible=this.lastFiveHelperVisible,e==null||e.removeEventListener("mousemove",this.updateByMousePosition),e==null||e.removeEventListener("wheel",this.updateByMousePosition),e==null||e.removeEventListener("mouseenter",this.onEnter),e==null||e.removeEventListener("mouseout",this.onLeave),this.hammer.off("tap",this.onTap),this.hammer.off("pan",this.onPan),this.hammer.off("press",this.onPress),this.hammer.off("panend",this.onPanEnd),this.five.off("panoArrived",this.renderScreenCenter),this.five.off("panGesture",this.renderScreenCenter),this.five.off("interiaPan",this.renderScreenCenter),this.pointSelectorHelper.hooks.off("intersectionUpdate",this.emitIntersectionUpdate),this.emit("disable")}dispose(){this.disable(),this.pointSelectorHelper.dispose()}setAdherePoints(e,i){e?typeof e=="function"?this.adherePoints=e:this.adherePoints=()=>e:this.adherePoints=null,typeof i=="number"&&(this.adherePointsRadius=i)}}class Bv{constructor(){d(this,"five");d(this,"_cursor");d(this,"_pointSelector");d(this,"_fiveDomEvents");d(this,"_object3DHelper");d(this,"inited",!1);d(this,"init",t=>{this.inited=!0,this.five=t,this._cursor=void 0,this._pointSelector=void 0,this._fiveDomEvents=void 0,this._object3DHelper=void 0})}get cursor(){if(!this.inited)throw new Error("Global not inited");return this._cursor?this._cursor:(this._cursor=new Qp(this.five.getElement()),this._cursor)}get pointSelector(){if(!this.inited)throw new Error("Global not inited");return this._pointSelector?this._pointSelector:(this._pointSelector=new Vf(this.five),this._pointSelector)}get fiveDomEvents(){if(!this.inited)throw new Error("Global not inited");return this._fiveDomEvents?this._fiveDomEvents:(this._fiveDomEvents=new kl(this.five,{noEmitWhenNotInScene:!0}),this._fiveDomEvents)}get object3DHelper(){if(!this.inited)throw new Error("Global not inited");return this._object3DHelper?this._object3DHelper:(this._object3DHelper=new El(this.five),this._object3DHelper)}}const xl=new Bv;window.globalModules=xl;function Bf(n){Lc(n),n.traverse(t=>Lc(t))}function Lc(n){Array.isArray(n.lengthDoms)&&n.lengthDoms[0]instanceof bl&&n.lengthDoms.forEach(e=>e.destroy())}class jc extends Np{constructor(e){var i,s;super(e);d(this,"_three_color");ke(e==null?void 0:e.color)&&(this.three_color=(i=e==null?void 0:e.color)!=null?i:16777215),Object.keys(e).forEach(o=>{["color","dashed","dashScale","dashSize","gapSize","resolution"].includes(o)||o in this&&(this[o]=e[o])}),this.setDashed((s=e==null?void 0:e.dashed)!=null?s:!1)}get three_color(){return this._three_color}set three_color(e){this._three_color=e,this.color=e}setDashed(e){this.dashed=e,e?this.defines.USE_DASH="":delete this.defines.USE_DASH,this.needsUpdate=!0}}class zc extends Fp{constructor(e,i){super(e,i);d(this,"name","Line3")}}class Wt extends Lt{constructor(e){var r,a,l,c,h;super();d(this,"name","LineMesh");d(this,"points");d(this,"lengthDoms",[]);d(this,"highlighted",!1);d(this,"line");d(this,"backLine");d(this,"opacityBeforeHighlight");d(this,"paramsStyle",{});this.paramsStyle=e!=null?e:{};const i=new kc,s=new jc({color:new y.Color((r=e==null?void 0:e.lineColor)!=null?r:Mc),linewidth:(a=e==null?void 0:e.lineWidth)!=null?a:Rp,dashScale:40,opacity:(l=e==null?void 0:e.opacity)!=null?l:1,transparent:!0,dashed:(c=e==null?void 0:e.dashed)!=null?c:!1}),o=new jc({color:new y.Color((h=e==null?void 0:e.lineColor)!=null?h:Mc),linewidth:s.linewidth*.9,dashScale:s.dashScale,opacity:s.opacity*.8,depthTest:!1,depthWrite:!1,transparent:!0,resolution:s.resolution});this.line=new zc(i,s),this.backLine=new zc(i,o),this.line.renderOrder=1,this.backLine.renderOrder=0,this.line.name="lineFrontMaterial",this.backLine.name="lineBackMaterial",e&&this.setStyle(e),e!=null&&e.points&&this.setPoints(e.points),this.addEventListener("removed",()=>{Bf(this)})}get style(){return{lineColor:this.color,lineWidth:this.lineWidth,dashed:this.dashed,occlusionVisibility:this.occlusionVisibility,occlusionMode:this.occlusionMode,lengthEnable:this.paramsStyle.lengthEnable}}get lineWidth(){return this.line.material.linewidth}get color(){return new y.Color(this.line.material.three_color)}get dashed(){return this.line.material.dashed}get occlusionVisibility(){return this.backLine.visible||this.line.material.depthTest===!1}get occlusionMode(){return this.line.material.depthTest===!1?"depthTest":"translucence"}setPoints(e){const i=e.map(Ge).filter(ke);if(this.points=i,i.length<2)return;this.addIfNotExists(this.line,this.backLine);const s=i.flatMap(o=>[o.x,o.y,o.z]);s.length>2&&(this.line.geometry.dispose(),this.line.geometry=new kc,this.backLine.geometry=this.line.geometry),this.line.geometry.setPositions(s),this.line.computeLineDistances(),this.updateLengthItems(),this.needsRender=!0}setResolution(e,i){const s=this.line.material.resolution;(s.x!==e||s.y!==i)&&(s.set(e,i),this.needsRender=!0);const o=this.backLine.material.resolution;(o.x!==e||o.y!==i)&&(o.set(e,i),this.needsRender=!0)}setStyle(e){var o,r,a;this.paramsStyle=x(x({},this.paramsStyle),e),ke(e.lineColor)&&(this.line.material.three_color=new y.Color(e.lineColor),this.backLine.material.three_color=new y.Color(e.lineColor)),ke(e.lineWidth)&&(this.line.material.linewidth=e.lineWidth),ke(e.dashed)&&this.line.material.setDashed(e.dashed),ke(e.opacity)&&(this.line.material.opacity=e.opacity,this.backLine.material.opacity=this.line.material.opacity*.2),this.updateLengthItems();const i=(o=e.occlusionVisibility)!=null?o:this.paramsStyle.occlusionVisibility,s=(a=(r=e.occlusionMode)!=null?r:this.paramsStyle.occlusionMode)!=null?a:"translucence";i?s==="depthTest"?(this.line.material.depthTest=!1,this.backLine.visible=!1):s==="translucence"&&(this.line.material.depthTest=!0,this.backLine.visible=!0,this.line.material.opacity===1?this.backLine.material.setDashed(!0):this.backLine.material.setDashed(this.line.material.dashed)):(this.line.material.depthTest=!0,this.backLine.visible=!1),this.needsRender=!0}highlight(){this.highlighted||(this.highlighted=!0,this.opacityBeforeHighlight=this.line.material.opacity,this.line.material.opacity=this.opacityBeforeHighlight*Fn,this.backLine.material.opacity=this.backLine.material.opacity*Fn,this.needsRender=!0)}unhighlight(){this.highlighted&&(this.highlighted=!1,this.line.material.opacity=this.opacityBeforeHighlight,this.backLine.material.opacity=.2,this.needsRender=!0)}updateLengthItems(){var e,i;if(this.paramsStyle.lengthEnable){const s=(i=(e=this.points)==null?void 0:e.map((o,r)=>{if(r!==0)return[this.points[r-1],o]}).filter(ke))!=null?i:[];s.forEach(([o,r],a)=>{var h;const l=ai(o,r),c=o.distanceTo(r).toFixed(2)+"m";this.lengthDoms[a]=(h=this.lengthDoms[a])!=null?h:new bl(xl.five),this.lengthDoms[a].setPosition(l),this.lengthDoms[a].container.innerHTML=`<div style="pointer-events:none;color:white;">${c}</div>`}),this.lengthDoms.length>s.length&&(this.lengthDoms.slice(s.length).forEach(o=>o.destroy()),this.lengthDoms.length=s.length)}else this.lengthDoms.forEach(s=>s.destroy()),this.lengthDoms=[]}}class Rv extends Go.CSS3DSprite{constructor(){super(...arguments);d(this,"isCSS3DSprite",!0)}}const Fv=`
|
|
177
|
+
`;function jp(){const n=new y.PlaneGeometry(.4,.4),t=xp,e=new y.TextureLoader().load(t);e.encoding=y.sRGBEncoding,e.minFilter=y.LinearFilter;const i=new y.MeshBasicMaterial({map:e,transparent:!0,depthTest:!1});return new y.Mesh(n,i)}function zp(){const n=new y.CurvePath;n.add(new y.LineCurve3(new y.Vector3(0,0,0),new y.Vector3(0,0,.1)));const t=new y.TubeGeometry(n,8,.003),e=new y.ShaderMaterial({vertexShader:Tp,fragmentShader:Lp,depthTest:!1,transparent:!0});return new y.Mesh(t,e)}function Op(){const n=new y.SphereGeometry(.01,20,20),t=new y.MeshBasicMaterial({color:10349931,depthTest:!1,transparent:!0,side:y.DoubleSide}),e=new y.Mesh(n,t);return e.position.set(0,0,.1),e}function Vp(){const t=new Wf({pointerEvents:"none",cornerPoints:[new y.Vector3(-.2,.2,0),new y.Vector3(-.2,-.2,0),new y.Vector3(.2,-.2,0),new y.Vector3(.2,.2,0)]}),e=document.createElement("div");return e.style.width="100%",e.style.height="100%",e.style.backgroundImage=`url(${If})`,e.style.backgroundSize="100%",e.style.backgroundRepeat="no-repeat",t.container.appendChild(e),t}class Mf extends y.Object3D{constructor(e){super();d(this,"planeMesh");d(this,"lineMesh");d(this,"ballMesh");d(this,"borderMesh");this.planeMesh=jp(),this.lineMesh=zp(),this.ballMesh=Op(),this.borderMesh=Vp(),this.add(this.planeMesh,this.lineMesh,this.ballMesh,this.borderMesh),Ef(e)}updateWithIntersect(e){if(!e.face)return;const i=new y.Vector3().addVectors(e.point,e.face.normal);this.position.copy(e.point),this.lookAt(i)}show(){this.visible=!0,this.borderMesh.parent||this.add(this.borderMesh)}hide(){this.visible=!1,this.remove(this.borderMesh)}dispose(){var e;(e=this.planeMesh.material.map)==null||e.dispose()}}const Bp=16777215,Mc=16777215,Rp=2,Fn=.6;class kf extends gr.Line{constructor(...t){super(...t)}toJSON(){return{type:"FiveLine",points:this.points.toJSON()}}}class Fp extends gr.THREE_Line2{constructor(...t){super(...t)}toJSON(){return{type:"Five_THREE_Line2",geometryAttributes:this.geometry.attributes}}}class kc extends gr.LineGeometry{constructor(...t){super(...t)}toJSON(){return{type:"FiveLineGeometry",attributes:this.attributes}}}class Np extends gr.LineMaterial{constructor(...t){super(...t)}toJSON(){return{type:"FiveLineMaterial",color:this.color}}}class Lt extends W.Object3D{constructor(){super();d(this,"name","IObject3D");d(this,"needsRender")}removeChildren(){for(;this.children.length>0;)this.remove(this.children[0]);return this}add(...e){const i=e.filter(Boolean);return i.length===0?this:super.add(...i)}addIfNotExists(...e){return e.forEach(i=>{this.children.includes(i)||this.add(i)}),this}remove(...e){if(e.length===0)return this;const i=e.filter(Boolean);return super.remove(...i)}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}}function Hp(n,t){const{x:e,y:i,z:s}=t.clone().project(n);return s>1?void 0:{leftPercent:(e+1)/2*100,topPercent:(-i+1)/2*100}}const xc="LightTagContainer_shgjakdhwakjdhsja";class bl{constructor(t,e,i){d(this,"container");d(this,"visible",!1);d(this,"enabled",!1);d(this,"wrapper");d(this,"tagWrapper");d(this,"five");d(this,"originPosition");d(this,"transformedPosition");d(this,"disposer");d(this,"config");d(this,"onCameraUpdate",()=>{this.visible!==!1&&this.updateScreenPosition()});d(this,"onFiveEveryReady",()=>{var t;if(this.visible&&this.five.state.mode!=="Panorama"){const e=new y.Raycaster;e.set(this.five.camera.position,this.transformedPosition.clone().sub(this.five.camera.position));const i=(t=Vt(this.five).intersectRaycaster(e))==null?void 0:t[0];(i==null?void 0:i.distance)>this.transformedPosition.distanceTo(this.five.camera.position)?(this.container.style.opacity="1",this.container.style.pointerEvents="auto"):(this.container.style.opacity="0",this.container.style.pointerEvents="none")}});var s;this.five=t,this.originPosition=e?Ge(e).clone():void 0,this.transformedPosition=(s=this.originPosition)==null?void 0:s.clone(),this.container=(()=>{const o=document.createElement("div");return o.style.width="0",o.style.height="0",o.style.position="absolute",o})(),this.config=i!=null?i:{},this.enable(),this.show()}show(){this.visible=!0,this.container.style.opacity="1",this.container.style.pointerEvents="auto",this.container.style.transition="opacity 0.2s linear",this.onCameraUpdate()}hide(t){this.visible=!1,t!=null&&t.withAnimation?this.container.style.transition="opacity 0.2s linear":this.container.style.transition="",this.container.style.opacity="0",this.container.style.pointerEvents="none"}enable(){var i,s,o,r;if(this.enabled)return;this.enabled=!0,this.wrapper=(o=(s=this.config.wrapper)!=null?s:(i=this.five.getElement())==null?void 0:i.parentElement)!=null?o:document.body,this.tagWrapper||(this.tagWrapper=(r=document.getElementById(xc))!=null?r:(()=>{const a=document.createElement("div");return a.id=xc,a.style.position="absolute",a.style.top="0",a.style.left="0",a.style.width="100%",a.style.height="100%",a.style.pointerEvents="none",a})(),this.wrapper.contains(this.tagWrapper)||this.wrapper.appendChild(this.tagWrapper)),this.tagWrapper.appendChild(this.container);let t=!1;const e=()=>{t||(t=!0,this.five.ready().then(()=>{this.onFiveEveryReady(),t=!1}))};this.five.on("cameraUpdate",e),this.five.on("cameraUpdate",this.onCameraUpdate),this.disposer=()=>{this.five.off("cameraUpdate",e),this.five.off("cameraUpdate",this.onCameraUpdate)}}disable(){var t;this.enabled&&(this.enabled=!1,this.tagWrapper.removeChild(this.container),(t=this.disposer)==null||t.call(this))}destroy(){this.disable(),this.container.remove()}setTransformMatrix(t){var e;this.transformedPosition=(e=this.originPosition)==null?void 0:e.clone().applyMatrix4(t),this.onCameraUpdate()}setPosition(t){this.transformedPosition=t,this.onCameraUpdate()}updateScreenPosition(){if(!this.transformedPosition){this.container.style.left="-100%",this.container.style.top="-100%";return}const t=Hp(this.five.camera,this.transformedPosition);t?(this.container.style.left=t.leftPercent+"%",this.container.style.top=t.topPercent+"%"):(this.container.style.left="-100%",this.container.style.top="-100%")}}function _p(n,t,e){return new bl(n,t,e)}const Gp={auto:"",pen:"","pen-forbidden":"","pen-crosshair":"","pne-polygon":"","pen-circle":"","crosshair-rectangle":"","crosshair-circle":""};class Qp{constructor(t){d(this,"container");this.container=t}setType(t){const e=Gp[t];e?this.container.style.cursor=`url(${e}), auto`:this.container.style.cursor=t}tip(t){return()=>this.closeTip()}closeTip(){}reset(){this.container.style.cursor="auto"}}class xf extends dt{constructor(e){super();d(this,"five");this.five=e}}const Vs=(n,t)=>{if(!t)return n;const e=new y.Vector3,i=new y.Quaternion,s=new y.Vector3;return t.decompose(e,i,s),n.clone().multiply(s).applyQuaternion(i).add(e)},pa=new Map;class Wp extends xf{constructor(e){super(e);d(this,"_workCode")}get fromType(){var s,o;const e=this.workCode;if(pa.has(e))return pa.get(e);const i=(o=(s=JSON.parse(this.work.raw.works[0]))==null?void 0:s.from_type)!=null?o:"vr";return pa.set(e,i),i}set workCode(e){this._workCode=e}get workCode(){var e;return(e=this._workCode)!=null?e:this.five.state.workCode}get work(){var e,i;return(i=(e=this.five.works)==null?void 0:e.find(s=>s.workCode===this.workCode))!=null?i:this.five.work}get observers(){var e;return(e=this.work)==null?void 0:e.observers}get transform(){var i,s,o,r;const e=(r=(i=this.work)==null?void 0:i.transform)!=null?r:(o=(s=this.work)==null?void 0:s.options)==null?void 0:o.transform;return e?e.clone():new y.Matrix4}getObserverPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.position;if(i)return Vs(i,this.transform)}getObserverStandingPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.standingPosition;if(i)return Vs(i,this.transform)}getObserver(e){var i;return(i=this.observers)==null?void 0:i[e]}}class yl extends xf{constructor(e){super(e);d(this,"workUtil",new Wp(this.five))}get version(){return this.five.constructor.version}get majorVersion(){return Number(this.version.split(".")[0])}get model(){return Vt(this.five)}moveToPano(e,i){const s=this.majorVersion===5?e:{workCode:this.workUtil.workCode,panoIndex:e};return this.five.moveToPano(s,i)}}let Oi=class{constructor(t,e){d(this,"VERSION","3.47.2");d(this,"NAME");d(this,"five");d(this,"workUtil");d(this,"fiveUtil");d(this,"hooks",new dt);d(this,"staticPrefix","//vr-image-4.realsee-cdn.cn");this.updateFive(t),e!=null&&e.staticPrefix&&(this.staticPrefix=e.staticPrefix)}set workCode(t){this.workUtil.workCode=t,this.onWorkCodeChange()}get workCode(){return this.workUtil.workCode}updateFive(t){this.five=t,this.fiveUtil=new yl(t),this.workUtil=this.fiveUtil.workUtil}getCurrentState(){return this.state}absoluteUrl(t){return Dl(this.staticPrefix,t)}onWorkCodeChange(){}};function Df(n,t,e){if(e){const s=new y.Vector3().subVectors(n.position,e).applyQuaternion(n.quaternion.clone().inverse()).applyQuaternion(t).add(e);n.position.copy(s)}n.quaternion.copy(t)}const va=new y.Vector3;class Up extends y.Sphere{expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;va.subVectors(t,this.center);const e=va.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(va,s/i),this.radius+=s}return this}}function Yp(n){const{max:t,min:e}=n;return[new y.Vector3(t.x,t.y,t.z),new y.Vector3(e.x,t.y,t.z),new y.Vector3(e.x,e.y,t.z),new y.Vector3(t.x,e.y,t.z),new y.Vector3(t.x,t.y,e.z),new y.Vector3(e.x,t.y,e.z),new y.Vector3(e.x,e.y,e.z),new y.Vector3(t.x,e.y,e.z)]}function pi(n,t){const{max:e,min:i}=n;switch(t){case 0:return new y.Vector3(e.x,e.y,e.z);case 1:return new y.Vector3(i.x,e.y,e.z);case 2:return new y.Vector3(i.x,i.y,e.z);case 3:return new y.Vector3(e.x,i.y,e.z);case 4:return new y.Vector3(e.x,e.y,i.z);case 5:return new y.Vector3(i.x,e.y,i.z);case 6:return new y.Vector3(i.x,i.y,i.z);case 7:return new y.Vector3(e.x,i.y,i.z)}}function qn(n){return wl(n,"box3")}function Sf(n){return wl(n,"sphere")}function Xp(n){return vr(n,"box3")}function Tf(n){return vr(n,"sphere")}function vr(n,t){const e=t==="box3"?new y.Box3:new Up,i=new y.Vector3;if(n.updateWorldMatrix(!1,!1),n.traverse(s=>{var r;if(s.name==="shadow"||s.type==="Line2")return;const o=s.geometry;if(s.updateWorldMatrix(!1,!1),o!==void 0){const a=(r=o==null?void 0:o.attributes)==null?void 0:r.position;if(a)for(let l=0,c=a.count;l<c;l++)i.fromBufferAttribute(a,l).applyMatrix4(s.matrixWorld),e.expandByPoint(i);else o.vertices&&o.vertices.forEach(l=>{const c=l.clone().applyMatrix4(s.matrixWorld);e.expandByPoint(c)})}}),!e.isEmpty())return e}function wl(n,t){const e=vr(n,t);return e&&e.applyMatrix4(Zp(n.matrixWorld.clone())),e}const Zp=n=>{const t=n.elements,e=t[0],i=t[1],s=t[2],o=t[3],r=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],f=t[10],g=t[11],v=t[12],p=t[13],m=t[14],A=t[15],w=u*m*c-p*f*c+p*l*g-a*m*g-u*l*A+a*f*A,I=v*f*c-h*m*c-v*l*g+r*m*g+h*l*A-r*f*A,P=h*p*c-v*u*c+v*a*g-r*p*g-h*a*A+r*u*A,k=v*u*l-h*p*l-v*a*f+r*p*f+h*a*m-r*u*m,E=e*w+i*I+s*P+o*k;if(E===0)return n.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/E;return t[0]=w*L,t[1]=(p*f*o-u*m*o-p*s*g+i*m*g+u*s*A-i*f*A)*L,t[2]=(a*m*o-p*l*o+p*s*c-i*m*c-a*s*A+i*l*A)*L,t[3]=(u*l*o-a*f*o-u*s*c+i*f*c+a*s*g-i*l*g)*L,t[4]=I*L,t[5]=(h*m*o-v*f*o+v*s*g-e*m*g-h*s*A+e*f*A)*L,t[6]=(v*l*o-r*m*o-v*s*c+e*m*c+r*s*A-e*l*A)*L,t[7]=(r*f*o-h*l*o+h*s*c-e*f*c-r*s*g+e*l*g)*L,t[8]=P*L,t[9]=(v*u*o-h*p*o-v*i*g+e*p*g+h*i*A-e*u*A)*L,t[10]=(r*p*o-v*a*o+v*i*c-e*p*c-r*i*A+e*a*A)*L,t[11]=(h*a*o-r*u*o-h*i*c+e*u*c+r*i*g-e*a*g)*L,t[12]=k*L,t[13]=(h*p*s-v*u*s+v*i*f-e*p*f-h*i*m+e*u*m)*L,t[14]=(v*a*s-r*p*s-v*i*l+e*p*l+r*i*m-e*a*m)*L,t[15]=(r*u*s-h*a*s+h*i*l-e*u*l-r*i*f+e*a*f)*L,n};class Qs extends Lt{constructor(e,i){var s,o;super();d(this,"originObject3D");d(this,"onRender");d(this,"positionFrom");this.originObject3D=e,this.onRender=(s=i==null?void 0:i.onRender)!=null?s:()=>{},this.positionFrom=(o=i==null?void 0:i.positionFrom)!=null?o:"objectPosition"}get helperObject(){return this}render(){this.onRender()}enable(){this.parent.children.includes(this)||this.parent.add(this)}disable(){this.removeFromParent()}show(){this.visible=!0,this.render()}hide(){this.visible=!1,this.render()}raycasterIntersectObject(e,i=[]){return e.intersectObject(this,!0,i)}initialPosition(e){var i,s;this.positionFrom==="objectPosition"?this.position.copy(this.originObject3D.position):this.positionFrom==="boundingBox"?this.position.copy((i=qn(this.originObject3D))==null?void 0:i.getCenter(new y.Vector3)):this.positionFrom==="boundingSphere"?this.position.copy((s=Sf(this.originObject3D))==null?void 0:s.center):this.positionFrom instanceof W.Vector3?this.position.copy(this.positionFrom):this.positionFrom instanceof Function&&this.position.copy(this.positionFrom(this.originObject3D)),e&&this.position.add(e)}setScaleByCamera(e){}initQuaternion(){this.quaternion.copy(this.originObject3D.quaternion)}applyHelperScaleMatrix4(e,i){this.scale.applyMatrix4(e)}setHelperQuaternion(e,i){Df(this,e,i)}applyHelperQuaternion(e,i){if(i){const s=new W.Vector3().subVectors(this.position,i).applyQuaternion(e).add(i);this.position.copy(s)}this.applyQuaternion(e)}dispose(){this.removeFromParent()}}class Jp extends Qs{}class qp extends Qs{}class Kp extends Qs{}class $p extends Qs{}class ev extends Qs{}class tv extends y.Group{constructor(e){super();d(this,"direction");this.direction=e||"x"}}class Dc extends y.Mesh{constructor(e,i,s){super(e,i);d(this,"direction");this.direction=s||"x"}}function iv(n,t){const{offsetWidth:e,offsetHeight:i}=t,{top:s,left:o}=t.getBoundingClientRect();return Object.assign(new y.Vector2,{x:(n.x-o)/e*2-1,y:-(n.y-s)/i*2+1})}function Ar(n,t,e){if(!t||!e||!n)return;const i=iv(t,e);if(Math.abs(i.x)===1||Math.abs(i.y)===1)return;const s=new y.Raycaster;return s.setFromCamera(i,n),s}function nv(n,t){return!(Math.abs(n.x-t.x)>1e-5||Math.abs(n.y-t.y)>1e-5||Math.abs(n.z-t.z)>1e-5)}class Aa extends tv{constructor(e){var h;super(e.direction);d(this,"line");d(this,"arrow");d(this,"lineHeight",.4);d(this,"arrowHeight",.1);this.name="ArrowGroup";const i=new y.Color((h=e.color)!=null?h:16214315),s=new y.MeshBasicMaterial({color:i,depthTest:!1,depthWrite:!1,opacity:1,transparent:!0,side:y.DoubleSide});this.renderOrder=50;const o=new y.ConeGeometry(.04,.1,32),r=new Dc(o,s.clone(),e.direction);r.name=`arrow-${e.direction}`,this.arrow=r;const a=.004,l=new y.CylinderGeometry(a,a,.4,32),c=new Dc(l,s.clone(),e.direction);c.name=`line-${e.direction}`,this.line=c,this.formatArrow(),this.formatLine(),this.add(this.arrow,this.line)}formatArrow(){this.arrow.geometry.translate(0,this.lineHeight+this.arrowHeight/2,0),this.direction==="x"?(this.arrow.geometry.rotateX(Math.PI/2),this.arrow.geometry.rotateY(Math.PI/2)):this.direction==="z"&&this.arrow.geometry.rotateX(Math.PI/2)}formatLine(){this.line.geometry.translate(0,this.lineHeight/2,0),this.direction==="x"?(this.line.geometry.rotateX(Math.PI/2),this.line.geometry.rotateY(Math.PI/2)):this.direction==="z"&&this.line.geometry.rotateX(Math.PI/2)}}const ba={X:15618642,Y:4765519,Z:4227839};class On{static get X(){return new y.Color(ba.X).convertSRGBToLinear().clone()}static get Y(){return new y.Color(ba.Y).convertSRGBToLinear().clone()}static get Z(){return new y.Color(ba.Z).convertSRGBToLinear().clone()}}function Cl(n,t){const s=n.position.distanceTo(t),o=n.fov,r=s/3,a=o/90;return r*a}class sv extends Jp{constructor(e,i){super(e,i);d(this,"xArrow");d(this,"yArrow");d(this,"zArrow");i.xArrowEnable!==!1&&(this.xArrow=new Aa({direction:"x",color:On.X})),i.yArrowEnable!==!1&&(this.yArrow=new Aa({direction:"y",color:On.Y})),i.zArrowEnable!==!1&&(this.zArrow=new Aa({direction:"z",color:On.Z})),this.add(...[this.xArrow,this.yArrow,this.zArrow].filter(Boolean))}show(){super.show(),this.xArrow&&(this.xArrow.visible=!0),this.yArrow&&(this.yArrow.visible=!0),this.zArrow&&(this.zArrow.visible=!0)}setScaleByCamera(e){this.scale.setScalar(Cl(e,this.position))}showDraggingHelper(e){this.xArrow&&(this.xArrow.visible=e.includes("x")),this.yArrow&&(this.yArrow.visible=e.includes("y")),this.zArrow&&(this.zArrow.visible=e.includes("z"))}dispose(){this.remove(...[this.xArrow,this.yArrow,this.zArrow].filter(Boolean)),super.dispose()}}function Ki(n,t){return ov(document.createElement(t!=null?t:"div"),n)}function ov(n,t){if(!t)return n;for(const e in t)e&&t[e]&&(n.style[e]=t[e]);return n}function rv(n){const t=Ki(x({position:"absolute",display:"block",borderRadius:"4px",paddingTop:"1px",paddingBottom:"1px",paddingLeft:"4px",paddingRight:"4px",pointerEvents:"none",userSelect:"none",zIndex:"99999",backgroundColor:"rgba(0,0,0,0.7)",fontSize:"12px",color:"#fff",letterSpacing:"0",lineHeight:"18px"},n)),e=()=>{t.style.display!=="block"&&t.style.top&&t.style.left&&(t.style.display="block")};return{element:t,show:e,hide:()=>{t.style.display="none",t.style.top="",t.style.left=""},setLeftTop:(o,r)=>{t.style.left=o,t.style.top=r,e()}}}class av extends Kp{constructor(e,i){super(e,i);d(this,"xCircle");d(this,"yCircle");d(this,"zCircle");d(this,"children",[]);d(this,"angleTips");d(this,"container");(i==null?void 0:i.yzCircleEnable)!==!1&&(this.xCircle=new ya({direction:"x",color:On.X})),(i==null?void 0:i.xzCircleEnable)!==!1&&(this.yCircle=new ya({direction:"y",color:On.Y})),(i==null?void 0:i.xyCircleEnable)!==!1&&(this.zCircle=new ya({direction:"z",color:On.Z})),i!=null&&i.container&&(i==null?void 0:i.angleTipsEnable)!==!1&&(this.container=i==null?void 0:i.container,this.angleTips=rv({display:"none"}),this.container.appendChild(this.angleTips.element)),this.add(...[this.xCircle,this.yCircle,this.zCircle].filter(Boolean)),this.show()}hide(){this.children.forEach(e=>e.hide())}show(){var e;this.children.forEach(i=>i.showCircle()),(e=this.angleTips)==null||e.hide()}setScaleByCamera(e){this.scale.setScalar(Cl(e,this.position))}showDraggingHelper(e){var i;this.hide(),this.children.filter(s=>e.includes(s.direction)).forEach(s=>s.showRing()),(i=this.angleTips)==null||i.show()}dispose(){var e,i;this.removeFromParent(),(i=(e=this.angleTips)==null?void 0:e.element)==null||i.remove()}}class ya extends y.Group{constructor(e){super();d(this,"direction");d(this,"circle");d(this,"ring");d(this,"angleSector");this.direction=e.direction,this.circle=new lv(e),this.ring=new cv(e),this.angleSector=new hv(e),this.add(this.circle,this.ring,this.angleSector),this.direction==="y"?this.rotateX(Math.PI/2):this.direction==="x"&&this.rotateY(-Math.PI/2)}showCircle(){this.add(this.circle),this.remove(this.ring,this.angleSector)}showRing(){this.add(this.ring,this.angleSector),this.remove(this.circle)}hide(){this.remove(this.ring,this.angleSector,this.circle)}}let lv=class extends y.Mesh{constructor(e){var i;super();d(this,"direction");d(this,"gapAngle",.02);d(this,"geometry",new y.RingGeometry(.25,.3,20,8,this.gapAngle,Math.PI/2-this.gapAngle*2));this.material=new y.MeshBasicMaterial({opacity:.6,color:(i=e.color)!=null?i:16777215,transparent:!0,side:y.DoubleSide,depthTest:!1,depthWrite:!1}),this.renderOrder=50,this.direction=e.direction,this.geometry.name=`RotateHelperCircleGeometry-${this.direction}`}};class cv extends y.Group{constructor(e){super();d(this,"direction");this.direction=e.direction;const i=.015,s=new Array(8).fill(null).map((o,r)=>{const a=new y.RingGeometry(.25,.3,20,8,Math.PI/4*r+i,Math.PI/4-i*2),l=new y.MeshBasicMaterial({opacity:1,color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide});this.renderOrder=50;const c=new y.Mesh(a,l);return c.name=`AxesDashedRing-${this.direction}-${r}`,c});this.add(...s)}}class hv extends y.Mesh{constructor(e){var s;super();d(this,"direction");d(this,"baseAxes");d(this,"angleDirection");switch(e.direction){case"x":this.baseAxes=new y.Vector3(0,0,1);break;case"y":this.baseAxes=new y.Vector3(1,0,0);break;case"z":this.baseAxes=new y.Vector3(1,0,0);break}const i=.3+5e-4;this.geometry=new y.CircleGeometry(i,48,0,1e-4),this.material=new y.MeshBasicMaterial({opacity:.4,color:(s=e.color)!=null?s:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide}),this.renderOrder=50,this.direction=e.direction,this.angleDirection=this.direction==="z"?1:-1}}function dv(){const n=Ki({width:"100%",height:"100%",left:"0",top:"0",position:"absolute",pointerEvents:"none"}),t=Ki({boxSizing:"border-box",width:"100%",height:"100%",left:"0",top:"0",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"}),e=Ki({boxSizing:"border-box",width:"100%",height:"100%",left:"0",top:"0",position:"absolute",border:"1px solid rgba(255,255,255,0.4)"});n.appendChild(t),t.appendChild(e);const i="-4px",s={direction:"nesw",element:ki({cursor:"nesw-resize",left:i,bottom:i})},o={direction:"ns",element:ki({cursor:"ns-resize",bottom:i})},r={direction:"nwse",element:ki({cursor:"nwse-resize",right:i,bottom:i})},a={direction:"ew",element:ki({cursor:"ew-resize",right:i})},l={direction:"nesw",element:ki({cursor:"nesw-resize",right:i,top:i})},c={direction:"ns",element:ki({cursor:"ns-resize",top:i})},h={direction:"nwse",element:ki({cursor:"nwse-resize",left:i,top:i})},u={direction:"ew",element:ki({cursor:"ew-resize",left:i})};return new Array(o,a,c,u,s,r,l,h).forEach(g=>t.appendChild(g.element)),{container:n,squares:[s,o,r,a,l,c,h,u]}}function ki(n){const t=Ki(x({background:"#FFFFFF",width:"9px",height:"9px",position:"absolute",pointerEvents:"none"},n)),e=Ki({width:"15px",height:"15px",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"}),i=Ki({width:"15px",height:"15px",cursor:n==null?void 0:n.cursor,pointerEvents:"auto",background:"transparent"});return i.draggable=!0,e.appendChild(i),t.appendChild(e),t}class uv extends ev{constructor(e,i,s,o){super(e);d(this,"points",[]);d(this,"cornerPositions",[]);d(this,"css3DInstance");d(this,"plane");d(this,"css3DRenderer",new Gn);d(this,"camera");d(this,"scene");d(this,"container");d(this,"enabled",!1);this.camera=s,this.scene=o,this.container=i,this.initRectangleScaleHelper()}get helperObject(){var e;if(!((e=this.css3DInstance)!=null&&e.css3DObject))throw new Error("css3DInstance is not initialized");return this.css3DInstance.css3DObject}applyMatrix4(e){var i;super.applyMatrix4(e),this.helperObject.applyMatrix4(e),(i=this.plane)==null||i.applyMatrix4(e),this.cornerPositions.forEach(s=>s.applyMatrix4(e))}showDraggingHelper(){}applyHelperScaleMatrix4(e,i){var s;(s=this.plane)==null||s.scale.applyMatrix4(e),this.helperObject.applyScaleMatrix4(e)}updatePoints(){const e=this.calculatePointPosition(this.cornerPositions);this.points.forEach((i,s)=>{i.position.copy(e[s])})}applyHelperQuaternion(e,i){var o;const s=(o=this.css3DInstance)==null?void 0:o.css3DObject;if(s){const r=new y.Vector3().subVectors(s.position,i).applyQuaternion(e).add(i);s.position.copy(r),s.applyQuaternion(e)}if(this.plane){const r=new y.Vector3().subVectors(this.plane.position,i).applyQuaternion(e).add(i);this.plane.position.copy(r),this.plane.applyQuaternion(e)}this.cornerPositions.forEach(r=>{const a=new y.Vector3().subVectors(r,i).applyQuaternion(e).add(i);r.copy(a)})}enable(){var e;this.enabled||(this.enabled=!0,(e=this.css3DInstance)==null||e.enable(),this.plane&&this.scene.add(this.plane))}disable(){var e;this.enabled&&(this.enabled=!1,(e=this.css3DInstance)==null||e.disable(),this.plane&&this.scene.remove(this.plane))}show(){var e;(e=this.css3DInstance)==null||e.show(),this.plane&&(this.plane.visible=!0)}hide(){var e;(e=this.css3DInstance)==null||e.hide(),this.plane&&(this.plane.visible=!1)}dispose(){this.disable(),this.css3DRenderer.dispose()}initRectangleScaleHelper(){var a,l;const e=this.getCornerPositions();if(!e)return;this.cornerPositions=e;const i=this.css3DRenderer.create3DElement(this.camera,e,{ratio:.003});if(!i)return;this.css3DInstance=i,i.appendToElement(this.container);const s=i.css3DObject.container,{container:o,squares:r}=dv();this.points=r.map((c,h)=>({direction:c.direction,point:c.element,position:this.calculatePointPosition(e)[h]})),s.insertBefore(o,(a=s.children[0])!=null?a:null),this.helperObject.position.copy(this.originObject3D.position),(l=this.plane)==null||l.position.copy(this.originObject3D.position)}getCornerPositions(){const{originObject3D:e}=this;if(e.isCSS3DObjectPlus)return e.cornerPoints;console.error("当前物体暂时不支持 ScaleHelper")}calculatePointPosition(e){return[e[0].clone(),e[0].clone().add(e[1]).divideScalar(2),e[1].clone(),e[1].clone().add(e[2]).divideScalar(2),e[2].clone(),e[2].clone().add(e[3]).divideScalar(2),e[3].clone(),e[3].clone().add(e[0]).divideScalar(2)]}}class fv extends qp{constructor(e){super(e);d(this,"box");d(this,"outline");d(this,"originObject");d(this,"positionAttribute");this.originObject=e,this.positionAttribute=new y.BufferAttribute(new Float32Array(8*3),3),this.box=this.createBox(),this.outline=this.createOutline(),this.add(this.box,this.outline),this.update()}raycasterIntersectObject(e,i){return e.intersectObject(this,!1,i)}raycast(e,i){this.box.raycast(e,i)}update(){const e=qn(this.originObject);if(!e)return;const{min:i,max:s}=e;this.positionAttribute.setXYZ(0,s.x,s.y,s.z),this.positionAttribute.setXYZ(1,i.x,s.y,s.z),this.positionAttribute.setXYZ(2,i.x,i.y,s.z),this.positionAttribute.setXYZ(3,s.x,i.y,s.z),this.positionAttribute.setXYZ(4,s.x,s.y,i.z),this.positionAttribute.setXYZ(5,i.x,s.y,i.z),this.positionAttribute.setXYZ(6,i.x,i.y,i.z),this.positionAttribute.setXYZ(7,s.x,i.y,i.z),this.positionAttribute.needsUpdate=!0}createOutline(){const e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new y.BufferGeometry;i.setIndex(new y.BufferAttribute(e,1)),i.setAttribute("position",this.positionAttribute);const s=new y.LineBasicMaterial({color:64767,linewidth:1,opacity:1,toneMapped:!1}),o=new y.LineSegments(i,s);return o.matrixAutoUpdate=!1,o}createBox(){const e=new Uint16Array([0,1,2,0,2,3,0,3,7,0,7,4,0,4,5,0,5,1,6,1,5,6,2,1,6,5,4,6,4,7,6,3,2,6,7,3]),i=new y.BufferGeometry;i.setIndex(new y.BufferAttribute(e,1)),i.setAttribute("position",this.positionAttribute);const s=new y.MeshBasicMaterial({color:64767,opacity:.1,depthTest:!1,transparent:!0});return new y.Mesh(i,s)}}function Be(n,t){this._camera=n||null,this._domElement=t||document,this._raycaster=new y.Raycaster,this._selected=null,this._boundObjs={};var e=this;this._$onClick=function(){e._onClick.apply(e,arguments)},this._$onDblClick=function(){e._onDblClick.apply(e,arguments)},this._$onMouseMove=function(){e._onMouseMove.apply(e,arguments)},this._$onMouseDown=function(){e._onMouseDown.apply(e,arguments)},this._$onMouseUp=function(){e._onMouseUp.apply(e,arguments)},this._$onTouchMove=function(){e._onTouchMove.apply(e,arguments)},this._$onTouchStart=function(){e._onTouchStart.apply(e,arguments)},this._$onTouchEnd=function(){e._onTouchEnd.apply(e,arguments)},this._$onContextmenu=function(){e._onContextmenu.apply(e,arguments)},this._domElement.addEventListener("click",this._$onClick,!1),this._domElement.addEventListener("dblclick",this._$onDblClick,!1),this._domElement.addEventListener("mousemove",this._$onMouseMove,!1),this._domElement.addEventListener("mousedown",this._$onMouseDown,!1),this._domElement.addEventListener("mouseup",this._$onMouseUp,!1),this._domElement.addEventListener("touchmove",this._$onTouchMove,!1),this._domElement.addEventListener("touchstart",this._$onTouchStart,!1),this._domElement.addEventListener("touchend",this._$onTouchEnd,!1),this._domElement.addEventListener("contextmenu",this._$onContextmenu,!1)}Be.prototype.destroy=function(){this._domElement.removeEventListener("click",this._$onClick,!1),this._domElement.removeEventListener("dblclick",this._$onDblClick,!1),this._domElement.removeEventListener("mousemove",this._$onMouseMove,!1),this._domElement.removeEventListener("mousedown",this._$onMouseDown,!1),this._domElement.removeEventListener("mouseup",this._$onMouseUp,!1),this._domElement.removeEventListener("touchmove",this._$onTouchMove,!1),this._domElement.removeEventListener("touchstart",this._$onTouchStart,!1),this._domElement.removeEventListener("touchend",this._$onTouchEnd,!1),this._domElement.removeEventListener("contextmenu",this._$onContextmenu,!1)};Be.eventNames=["click","dblclick","mouseover","mouseout","mousemove","mousedown","mouseup","contextmenu","touchstart","touchend"];Be.prototype._getRelativeMouseXY=function(n){var t=n.target||n.srcElement;t.nodeType===3&&(t=t.parentNode);var e={x:0,y:0},i=t,s=getComputedStyle(i,null);e.y+=parseInt(s.getPropertyValue("padding-top"),10),e.x+=parseInt(s.getPropertyValue("padding-left"),10);do e.x+=i.offsetLeft,e.y+=i.offsetTop,s=getComputedStyle(i,null),e.x+=parseInt(s.getPropertyValue("border-left-width"),10),e.y+=parseInt(s.getPropertyValue("border-top-width"),10);while(i=i.offsetParent);var o={width:t===window?window.innerWidth:t.offsetWidth,height:t===window?window.innerHeight:t.offsetHeight};return{x:Number((n.pageX-e.x)/o.width)*2-1,y:-((n.pageY-e.y)/o.height)*2+1}};Be.prototype._objectCtxInit=function(n){n._3xDomEvent={}};Be.prototype._objectCtxDeinit=function(n){delete n._3xDomEvent};Be.prototype._objectCtxIsInit=function(n){return!!n._3xDomEvent};Be.prototype._objectCtxGet=function(n){return n._3xDomEvent};Be.prototype.camera=function(n){return n&&(this._camera=n),this._camera};Be.prototype.bind=function(n,t,e,i){console.assert(Be.eventNames.indexOf(t)!==-1,"not available events:"+t),this._objectCtxIsInit(n)||this._objectCtxInit(n);var s=this._objectCtxGet(n);s[t+"Handlers"]||(s[t+"Handlers"]=[]),s[t+"Handlers"].push({callback:e,useCapture:i}),this._boundObjs[t]===void 0&&(this._boundObjs[t]=[]),this._boundObjs[t].push(n)};Be.prototype.addEventListener=Be.prototype.bind;Be.prototype.unbind=function(n,t,e,i){console.assert(Be.eventNames.indexOf(t)!==-1,"not available events:"+t),this._objectCtxIsInit(n)||this._objectCtxInit(n);var s=this._objectCtxGet(n);s[t+"Handlers"]||(s[t+"Handlers"]=[]);for(var o=s[t+"Handlers"],r=0;r<o.length;r++){var a=o[r];if(e==a.callback&&i==a.useCapture){o.splice(r,1);break}}var l=this._boundObjs[t].indexOf(n);this._boundObjs[t].splice(l,1)};Be.prototype.removeEventListener=Be.prototype.unbind;Be.prototype._bound=function(n,t){var e=this._objectCtxGet(t);return e?!!e[n+"Handlers"]:!1};Be.prototype._onMove=function(n,t,e,i){var s=this._boundObjs[n];if(!(s===void 0||s.length===0)){var o=new y.Vector2;o.set(t,e),this._raycaster.setFromCamera(o,this._camera);var r=this._raycaster.intersectObjects(s),a=this._selected;if(r.length>0){var l,c,h,u=r[0],f=u.object;this._selected=f,h=this._bound("mousemove",f),a!=f&&(l=this._bound("mouseover",f),c=a&&this._bound("mouseout",a))}else c=a&&this._bound("mouseout",a),this._selected=null;h&&this._notify("mousemove",f,i,u),l&&this._notify("mouseover",f,i,u),c&&this._notify("mouseout",a,i,u)}};Be.prototype._onEvent=function(n,t,e,i){var s=this._boundObjs[n];if(!(s===void 0||s.length===0)){var o=new y.Vector2;o.set(t,e),this._raycaster.setFromCamera(o,this._camera);var r=this._raycaster.intersectObjects(s,!0);if(r.length!==0){for(var a=r[0],l=a.object,c=this._objectCtxGet(l),h=l.parent;typeof c=="undefined"&&h;)c=this._objectCtxGet(h),h=h.parent;c&&this._notify(n,l,i,a)}}};Be.prototype._notify=function(n,t,e,i){var s=this._objectCtxGet(t),o=s?s[n+"Handlers"]:null;if(!s||!o||o.length===0){t.parent&&this._notify(n,t.parent,e,i);return}for(var o=s[n+"Handlers"],r=0;r<o.length;r++){var a=o[r],l=!0;a.callback({type:n,target:t,origDomEvent:e,intersect:i,stopPropagation:function(){l=!1}}),l&&a.useCapture===!1&&t.parent&&this._notify(n,t.parent,e,i)}};Be.prototype._onMouseDown=function(n){return this._onMouseEvent("mousedown",n)};Be.prototype._onMouseUp=function(n){return this._onMouseEvent("mouseup",n)};Be.prototype._onMouseEvent=function(n,t){var e=this._getRelativeMouseXY(t);this._onEvent(n,e.x,e.y,t)};Be.prototype._onMouseMove=function(n){var t=this._getRelativeMouseXY(n);this._onMove("mousemove",t.x,t.y,n),this._onMove("mouseover",t.x,t.y,n),this._onMove("mouseout",t.x,t.y,n)};Be.prototype._onClick=function(n){this._onMouseEvent("click",n)};Be.prototype._onDblClick=function(n){this._onMouseEvent("dblclick",n)};Be.prototype._onContextmenu=function(n){this._onMouseEvent("contextmenu",n)};Be.prototype._onTouchStart=function(n){return this._onTouchEvent("touchstart",n)};Be.prototype._onTouchEnd=function(n){return this._onTouchEvent("touchend",n)};Be.prototype._onTouchMove=function(n){if(n.touches.length==1){var t=Number(n.touches[0].pageX/window.innerWidth)*2-1,e=-(n.touches[0].pageY/window.innerHeight)*2+1;this._onMove("mousemove",t,e,n),this._onMove("mouseover",t,e,n),this._onMove("mouseout",t,e,n)}};Be.prototype._onTouchEvent=function(n,t){var e=t.touches;if(e.length==0&&(e=t.changedTouches),e.length==1){var i=Number(e[0].pageX/window.innerWidth)*2-1,s=-(e[0].pageY/window.innerHeight)*2+1;this._onEvent(n,i,s,t)}};function Ai(n){return!ke(n)}function ke(n){return n!=null}function yi(n){return arguments.length===0?[]:Array.isArray(n)?n:[n]}let Ws=class{constructor(t,e){d(this,"originObject3D");d(this,"hooks");d(this,"preventTapDefaultEvent",!1);d(this,"internalHooks");d(this,"disposers",[]);d(this,"helperObject3D");d(this,"camera");d(this,"model");d(this,"scene");d(this,"container");d(this,"domEvents");d(this,"isDragging",!1);d(this,"enabled",!1);d(this,"name","BaseController");d(this,"boundingBox");d(this,"config");d(this,"onRender");d(this,"onWantsTapGesture",t=>{if(this.getIntersectObject(t))return!1});d(this,"onWantsUpdateCameraDistance",()=>{if(this.camera.isPerspectiveCamera){const t=this.camera;this.helperObject3D.setScaleByCamera(t)}});d(this,"getBox",()=>this.boundingBox?this.boundingBox:(this.boundingBox=qn(this.originObject3D),this.boundingBox));var h,u,f;this.hooks=(h=t.sharedHooks)!=null?h:new dt,this.internalHooks=(u=t.sharedInternalHooks)!=null?u:new dt,this.camera=t.camera,this.model=t.model,this.originObject3D=t.originObject3D,this.helperObject3D=t.helperObject3D,this.container=t.container,this.scene=t.scene,this.domEvents=new Be(t.camera,t.container),this.onRender=(f=t.onRender)!=null?f:()=>{},this.config=e!=null?e:{},this.initialHelperPosition(),this.initialHelperQuaternion(),this.onWantsUpdateCameraDistance(),this.enable();const i=this.onSetOriginObjectScale.bind(this),s=this.onSetOriginObjectRotate.bind(this),o=this.onSetOriginObjectPosition.bind(this),r=this.onApplyOriginObjectScale.bind(this),a=this.onApplyOriginObjectRotate.bind(this),l=this.onApplyOriginObjectPosition.bind(this),c=this.initialHelperPosition.bind(this);this.internalHooks.on("setObjectPosition",this.onWantsUpdateCameraDistance),this.internalHooks.on("initialHelperPosition",this.onWantsUpdateCameraDistance),this.internalHooks.on("initialHelperPosition",c),this.internalHooks.on("setObjectScale",i),this.internalHooks.on("setObjectRotate",s),this.internalHooks.on("setObjectPosition",o),this.internalHooks.on("applyObjectPosition",l),this.internalHooks.on("applyObjectRotate",a),this.internalHooks.on("applyObjectScale",r),this.disposers.push(()=>{this.internalHooks.off("setObjectPosition",this.onWantsUpdateCameraDistance),this.internalHooks.off("initialHelperPosition",this.onWantsUpdateCameraDistance),this.internalHooks.off("initialHelperPosition",c),this.internalHooks.off("setObjectScale",i),this.internalHooks.off("setObjectRotate",s),this.internalHooks.off("setObjectPosition",o),this.internalHooks.off("applyObjectPosition",l),this.internalHooks.off("applyObjectRotate",a),this.internalHooks.off("applyObjectScale",r)})}initialHelperPosition(){this.helperObject3D.initialPosition(this.calculateOffset(this.config.offset))}initialHelperQuaternion(){var a,l,c;this.helperObject3D.initQuaternion();const t=(a=this.config.xAxis)!=null?a:new y.Vector3(1,0,0),e=(l=this.config.yAxis)!=null?l:new y.Vector3(0,1,0),i=(c=this.config.zAxis)!=null?c:new y.Vector3(0,0,1),s=new y.Quaternion;s.setFromUnitVectors(new y.Vector3(1,0,0),t.normalize());const o=new y.Quaternion;o.setFromUnitVectors(new y.Vector3(0,1,0),e.normalize());const r=new y.Quaternion;r.setFromUnitVectors(new y.Vector3(0,0,1),i.normalize()),this.helperObject3D.quaternion.premultiply(s),this.helperObject3D.quaternion.premultiply(o),this.helperObject3D.quaternion.premultiply(r)}enable(){this.enabled||(this.enabled=!0,this.scene.add(this.helperObject3D),this.helperObject3D.enable(),this.render())}disable(){this.enabled&&(this.enabled=!1,this.helperObject3D.disable(),this.render())}show(){this.helperObject3D.show(),this.render()}hide(){this.helperObject3D.hide(),this.render()}dispose(){var t;(t=this.disposers)==null||t.forEach(e=>e==null?void 0:e()),this.helperObject3D.dispose(),this.render()}applyHelperMatrix4(t){this.helperObject3D.applyMatrix4(t)}applyHelperQuaternion(t,e){this.helperObject3D.applyHelperQuaternion(t,e)}applyHelperScaleMatrix4(t,e){this.helperObject3D.applyHelperScaleMatrix4(t,e)}onWantsGesture(t,e,i){if(this.isDragging)return!1}onIntersectionOnModelUpdate(t){}onApplyOriginObjectScale(t){this.applyHelperScaleMatrix4(t.matrix,t.origin)}onApplyOriginObjectRotate(t){this.applyHelperQuaternion(t.quaternion,t.origin)}onApplyOriginObjectPosition(t){this.applyHelperMatrix4(t.matrix)}onSetOriginObjectScale(t){this.helperObject3D.scale.copy(t),this.updateOffsetByScale(t)}onSetOriginObjectRotate(t,e){this.helperObject3D.setHelperQuaternion(t,e)}onSetOriginObjectPosition(t){this.helperObject3D.position.copy(t.clone().add(this.calculateOffset(this.config.offset)))}render(){this.onRender()}updateOffsetByScale(t){if(this.boundingBox&&this.config.offset){const e=this.originObject3D.position,i=new y.Vector3().subVectors(this.boundingBox.max,e).multiply(t).add(e),s=new y.Vector3().subVectors(this.boundingBox.min,e).multiply(t).add(e),o=this.calculateOffset(this.config.offset,{min:s,max:i});this.helperObject3D.initialPosition(o)}}hoverListener(t,e=16777215,i=1){const s=yi(t).filter(ke),o=[];for(const r of s)if(r.material||r instanceof y.Group){const a=r instanceof y.Group?r.children.filter(f=>f instanceof y.Mesh):[r];a.forEach(f=>{f.__originalColor__=f.material.color.clone(),f.__originalOpacity__=f.material.opacity});const l=()=>{a.forEach(f=>{f.material.color.set(e),f.material.opacity=i}),this.render()},c=()=>{a.forEach(f=>{f.material.color.copy(f.__originalColor__),f.material.opacity=f.__originalOpacity__}),this.render()},h=()=>{this.isDragging||l()},u=()=>{this.isDragging||c()};for(const f of a)this.domEvents.addEventListener(f,"mouseover",h),this.domEvents.addEventListener(f,"mouseout",u),this.hooks.on("moveStart",l),this.hooks.on("moveEnd",c),this.hooks.on("rotateEnd",c),o.push(()=>{this.domEvents.removeEventListener(f,"mouseover",h),this.domEvents.removeEventListener(f,"mouseout",u),this.hooks.off("moveStart",l),this.hooks.off("moveEnd",c),this.hooks.off("rotateEnd",c)})}return()=>o.forEach(r=>r==null?void 0:r())}getIntersectObject(t){const e=this.camera.position,i=this.helperObject3D;if(!i)return;const s=this.helperObject3D.raycasterIntersectObject(t)[0];if(!s)return;const o=s;if(o.object=i,this.model.intersectRaycaster){const r=this.model.intersectRaycaster(t)[0];if(r&&r.point.distanceTo(e)<o.point.distanceTo(e))return}return o.object}calculateOffset(t,e){const i=new y.Vector3(0,0,0);if(!t)return i;const s=()=>e||this.getBox();if(typeof t.x=="number")i.setX(t.x);else if(typeof t.x=="object"){const o=s();i.setX((o.max.x-o.min.x)*t.x.percents)}if(typeof t.y=="number")i.setY(t.y);else if(typeof t.y=="object"){const o=s();i.setY((o.max.y-o.min.y)*t.y.percents)}if(typeof t.z=="number")i.setZ(t.z);else if(typeof t.z=="object"){const o=s();i.setZ((o.max.z-o.min.z)*t.z.percents)}return i}};const gv=new y.Vector3;function nn(n){var f;const{raycaster:t,line:e,clampToLine:i=!0}=n;if(((f=t.camera)==null?void 0:f.type)==="OrthographicCamera"){const g=t.ray.origin.clone();return e.closestPointToPoint(g,!1,new y.Vector3)}const s=new y.Plane().setFromNormalAndCoplanarPoint(t.ray.direction.clone().normalize(),t.ray.origin),o=s.projectPoint(e.start,new y.Vector3),r=s.projectPoint(e.end,new y.Vector3),a=new y.Line3(o,r),l=a.closestPointToPoint(t.ray.origin,i,gv),c=l.distanceTo(r),h=l.distanceTo(o),u=a.distance();if(c>h&&c>u){const g=-l.distanceTo(o)/u,v=e.start.clone().sub(e.end).normalize();return e.start.sub(v.clone().multiplyScalar(g*e.distance()))}else{const g=l.distanceTo(o)/u;return new y.Vector3().lerpVectors(e.start,e.end,g)}}let mv=class extends Ws{constructor(...e){super(...e);d(this,"name","MoveController");d(this,"startInfo");d(this,"_moveByMouse",{enabled:!1});d(this,"mouseInfo");d(this,"mousedownEventListenerDisposer");const i=this.helperObject3D;this.hoverListener([i.xArrow,i.yArrow,i.zArrow]);const s=this.dragStart.bind(this),o=this.dragging.bind(this),r=this.dragEnd.bind(this),a=this.show.bind(this),l=this.hide.bind(this);this.domEvents.addEventListener(this.helperObject3D,"mousedown",s),document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.hooks.on("rotateStart",l),this.hooks.on("rotateEnd",a),this.hooks.on("scaleStart",l),this.hooks.on("scaleEnd",a),this.hooks.on("moveByMouseEnable",l),this.hooks.on("moveByMouseDisable",a),this.disposers.push(()=>{this.domEvents.removeEventListener(this.helperObject3D,"mousedown",s),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.hooks.off("rotateStart",l),this.hooks.off("rotateEnd",a),this.hooks.off("scaleStart",l),this.hooks.off("scaleEnd",a),this.hooks.off("moveByMouseEnable",l),this.hooks.off("moveByMouseDisable",a)}),this.moveByMouseEnable&&this.moveByMouse()}get moveByMouseEnable(){return this._moveByMouse.enabled}dispose(){var e;super.dispose(),(e=this.disposers)==null||e.forEach(i=>i==null?void 0:i())}moveByMouse(e){this._moveByMouse={enabled:!0,useFaceNormal:e==null?void 0:e.useFaceNormal},this.preventTapDefaultEvent=!0;const i=this.handleMouseDown.bind(this),s=this.handleMouseUp.bind(this);this.hooks.emit("moveByMouseEnable"),setTimeout(()=>{this.container.addEventListener("mousedown",i),this.container.addEventListener("mouseup",s)}),this.mousedownEventListenerDisposer=()=>{this.container.removeEventListener("mousedown",i),this.container.removeEventListener("mouseup",s)}}disableMoveByMouse(){var e;this._moveByMouse={enabled:!1},this.preventTapDefaultEvent=!1,this.hooks.emit("moveByMouseDisable"),(e=this.mousedownEventListenerDisposer)==null||e.call(this)}onIntersectionOnModelUpdate(e){var r,a,l;if(!this.moveByMouseEnable)return;const{point:i,face:s}=e;if(!this.hooks.emit("wantToMove",i)){if(this.originObject3D.position.copy(i),(this._moveByMouse.useFaceNormal===!0||typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.enable!==!1)&&s!=null&&s.normal){const c=(()=>typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.alignmentVector?this._moveByMouse.useFaceNormal.alignmentVector:{x:0,y:1,z:0})(),h=new y.Vector3((r=c.x)!=null?r:0,(a=c.y)!=null?a:0,(l=c.z)!=null?l:0),u=(()=>typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.fixedFaceNormal?this._moveByMouse.useFaceNormal.fixedFaceNormal(s.normal):s.normal)();this.originObject3D.quaternion.setFromUnitVectors(h,u),this.internalHooks.emit("setObjectRotate",this.originObject3D.quaternion.clone())}this.internalHooks.emit("setObjectPosition",i),this.hooks.emit("move",i)}}handleMouseDown(e){const{x:i,y:s}=e;this.mouseInfo={x:i,y:s,mouseDownTimestamp:Date.now()}}handleMouseUp(e){if(!this.mouseInfo)return;const{x:i,y:s}=e;this.mouseInfo.x===i&&this.mouseInfo.y===s&&Date.now()-this.mouseInfo.mouseDownTimestamp<500&&(this.disableMoveByMouse(),this.mouseInfo=void 0)}dragStart(e){if(this.moveByMouseEnable||this.isDragging)return;const i=e==null?void 0:e.intersect;if(!i)return this.dragEnd();const s=(i==null?void 0:i.object).direction;if(!s)return this.dragEnd();const o=new y.Vector3(1,0,0).applyQuaternion(this.helperObject3D.quaternion),r=new y.Vector3(0,1,0).applyQuaternion(this.helperObject3D.quaternion),a=new y.Vector3(0,0,1).applyQuaternion(this.helperObject3D.quaternion),l=(()=>{switch(s){case"x":return o;case"y":return r;case"z":return a}})(),c=i.point.clone(),h=new y.Line3(c.clone().sub(l.normalize()),c.clone().add(l.normalize()));this.startInfo={startVectorProject:c,line:h},this.helperObject3D.showDraggingHelper([s]),this.hooks.emit("moveStart"),this.isDragging=!0}dragging(e){if(!this.isDragging||!this.startInfo)return;const i=Ar(this.camera,e,this.container);return i?(this.move(i),!1):this.dragEnd()}move(e){if(!this.startInfo)return this.dragEnd();const{line:i,startVectorProject:s}=this.startInfo,o=this.originObject3D,r=nn({raycaster:e,line:i,clampToLine:!1}),a=r.clone().sub(s),l=new y.Matrix4;l.setPosition(a);const c=o.position.clone().applyMatrix4(l);this.hooks.emit("wantToMove",c)||(o.applyMatrix4(l),s.copy(r),this.internalHooks.emit("applyObjectPosition",{matrix:l}),this.hooks.emit("move",c))}dragEnd(){this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.hooks.emit("moveEnd"))}};class ws{constructor(t,e,i,s,o,r,a){d(this,"helperController");d(this,"five");d(this,"onFiveWantsUpdateCameraDistance",()=>{var t,e;this.helperController&&((e=(t=this.helperController).onWantsUpdateCameraDistance)==null||e.call(t))});d(this,"onFiveWantsTapGesture",t=>{if(!this.helperController)return;if(this.helperController.preventTapDefaultEvent)return!1;const e=this.helperController.onWantsTapGesture(t);return this.five.needsRender=!0,e});d(this,"onFiveWantsGesture",(...t)=>{if(!this.helperController)return;const e=this.helperController.onWantsGesture(...t);return this.five.needsRender=!0,e});d(this,"onFiveIntersectionOnModelUpdate",(...t)=>{this.helperController&&this.helperController.onIntersectionOnModelUpdate(...t)});const{camera:l,model:c,scene:h}=t,u=t.getElement();if(this.five=t,!l||!c||!u||!h)return;const f=()=>{t.needsRender=!0};this.helperController=new e({camera:l,model:c,originObject3D:i,helperObject3D:s,container:u,scene:h,onRender:f,sharedHooks:r,sharedInternalHooks:a},o),t.on("wantsTapGesture",this.onFiveWantsTapGesture),t.on("wantsGesture",this.onFiveWantsGesture),t.on("intersectionOnModelUpdate",this.onFiveIntersectionOnModelUpdate),t.on("cameraFovUpdate",this.onFiveWantsUpdateCameraDistance),t.on("cameraPositionUpdate",this.onFiveWantsUpdateCameraDistance)}dispose(){var t;this.five.off("wantsTapGesture",this.onFiveWantsTapGesture),this.five.off("wantsGesture",this.onFiveWantsGesture),this.five.off("intersectionOnModelUpdate",this.onFiveIntersectionOnModelUpdate),this.five.off("cameraFovUpdate",this.onFiveWantsUpdateCameraDistance),this.five.off("cameraPositionUpdate",this.onFiveWantsUpdateCameraDistance),(t=this.helperController)==null||t.dispose()}}const pv="v1.0.1",vv="Object3DHelper",Pl=`${vv}@${pv}`,Av=()=>{console.error(`${Pl} is disposed`)},bv=()=>{console.warn(`${Pl} is disabled`)},yv=()=>{console.error(`${Pl} is disabled`)};class wv{constructor(t){d(this,"controllers",{});d(this,"state",{visible:!0,enabled:!0,disposed:!1});d(this,"hooks",new dt);d(this,"eventListener",{});t&&this.addControllers(t),this.setState(this.state)}show(t){return Q(this,null,function*(){this.setState({visible:!0},t)})}hide(t){return Q(this,null,function*(){this.setState({visible:!1},t)})}enable(t){this.setState({enabled:!0},t)}disable(t){this.setState({enabled:!1},t)}dispose(){this.setState({disposed:!0})}setState(t,e){if(this.state.disposed)return Av();if(!this.state.enabled&&t.enabled!==!0&&t.disposed!==!0)return yv();const i=x({},this.state);this.state=x(x({},this.state),t),t.disposed!==void 0&&t.disposed!==i.disposed&&t.disposed&&this.handleDispose(),t.visible!==void 0&&this.handleVisible(t.visible),t.enabled!==void 0&&this.handleEnable(t.enabled),this.hooks.emit("stateChange",{state:this.state,prevState:i})}addControllers(t){this.controllers=x(x({},this.controllers),t),this.setState(this.state)}getCurrentState(){return this.state}handleEnable(t,e=!0){t?(this.everyControllerDo(i=>{i.enable()}),this.hooks.emit("enable",{userAction:e})):(this.everyControllerDo(i=>{i.disable()}),this.hooks.emit("disable",{userAction:e})),this.state.enabled=t}handleVisible(t,e=!0){t?(this.everyControllerDo(i=>{i.show()}),this.actionIfStateIsEnabled(()=>this.hooks.emit("show",{userAction:e}))):(this.everyControllerDo(i=>{i.hide()}),this.actionIfStateIsEnabled(()=>this.hooks.emit("hide",{userAction:e}))),this.state.visible=t}everyControllerDo(t){Object.values(this.controllers).forEach(e=>{e&&t(e)})}handleDispose(){var t,e;Object.values(this.controllers).forEach(i=>{i==null||i.dispose()});for(const i in this.controllers){if(!i)continue;const s=i;(e=(t=this.eventListener)[s])==null||e.call(t)}}actionIfStateIsEnabled(t,e){if(this.state.enabled)return t();e!=null&&e.warnLog&&bv()}}function Il(n){return n*180/Math.PI}function wa(n){return n*Math.PI/180}const Ca=new y.Quaternion;class Cv extends Ws{constructor(...e){var c,h,u;super(...e);d(this,"name","RotateController");d(this,"startInfo");d(this,"removeListener");const i=this.helperObject3D;this.hoverListener([(c=i.xCircle)==null?void 0:c.circle,(h=i.yCircle)==null?void 0:h.circle,(u=i.zCircle)==null?void 0:u.circle].filter(Boolean));const s=this.dragStart.bind(this),o=this.dragging.bind(this),r=this.dragEnd.bind(this),a=this.show.bind(this),l=this.hide.bind(this);this.domEvents.addEventListener(this.helperObject3D,"mousedown",s),document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.hooks.on("moveStart",l),this.hooks.on("moveEnd",a),this.hooks.on("scaleStart",l),this.hooks.on("scaleEnd",a),this.hooks.on("moveByMouseEnable",l),this.hooks.on("moveByMouseDisable",a),this.removeListener=()=>{this.domEvents.removeEventListener(this.helperObject3D,"mousedown",s),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.hooks.off("moveStart",l),this.hooks.off("moveEnd",a),this.hooks.off("scaleStart",l),this.hooks.off("scaleEnd",a),this.hooks.off("moveByMouseEnable",l),this.hooks.off("moveByMouseDisable",a)}}get rotateCenter(){return this.helperObject3D.position.clone()}setRotateAngle(e){const{x:i=0,y:s=0,z:o=0}=e,r=new y.Euler(wa(i),wa(s),wa(o)),a=new y.Quaternion().setFromEuler(r);if(this.hooks.emit("wantToRotate",a))return;const{originObject3D:c,rotateCenter:h}=this;Df(c,a,h),this.internalHooks.emit("setObjectRotate",a,h),this.hooks.emit("rotate",a),this.render()}dispose(){this.removeListener(),super.dispose()}onApplyOriginObjectRotate(e){this.isDragging||super.onApplyOriginObjectRotate(e)}onApplyOriginObjectScale(e){}dragStart(e){if(this.isDragging)return;const i=e==null?void 0:e.intersect;if(!i)return this.dragEnd();const s=(i==null?void 0:i.object).direction;if(!s)return this.dragEnd();const o=i.point,r=this.getAngleHelper(s);this.setTipsAngle(0);const a=o.clone();a.y+=.2,this.setTipsPosition(a);const l=this.helperObject3D.quaternion.clone(),c=(()=>{if(s==="x")return new y.Vector3(1,0,0).applyQuaternion(l);if(s==="y")return new y.Vector3(0,1,0).applyQuaternion(l);if(s==="z")return new y.Vector3(0,0,1).applyQuaternion(l)})(),h=new y.Plane().setFromNormalAndCoplanarPoint(c,o),f=h.projectPoint(o.clone(),new y.Vector3).clone().sub(this.rotateCenter),g=f.angleTo(r.baseAxes.clone().applyQuaternion(l));this.setAngleHelperStart(s,g),this.setAngleHelperLength(s,0),this.startInfo={direction:s,startVector:f,plane:h,angleHelper:r,angle:0,helperQuaternion:l.clone()},Ca.copy(l),this.helperObject3D.showDraggingHelper([s]),this.hooks.emit("rotateStart"),this.isDragging=!0}dragging(e){if(!this.isDragging)return;const i=Ar(this.camera,e,this.container);return i?(this.rotate(i),!1):this.dragEnd()}rotate(e){if(!this.startInfo)return this.dragEnd();const{startVector:i,plane:s,angleHelper:o,direction:r,helperQuaternion:a}=this.startInfo,{originObject3D:l}=this,c=e.ray.intersectPlane(s,new y.Vector3);if(!c)return;const h=this.rotateCenter.clone(),f=s.projectPoint(c.clone(),new y.Vector3).clone().sub(h);if(i.angleTo(f)===0)return;const g=new y.Quaternion().setFromUnitVectors(i.clone().normalize(),f.clone().normalize()),v=l.quaternion.clone().premultiply(g);if(this.hooks.emit("wantToRotate",v))return;const A=new y.Euler().setFromQuaternion(new y.Quaternion().setFromUnitVectors(i.clone().normalize().applyQuaternion(a.clone().inverse()),f.clone().normalize().applyQuaternion(a.clone().inverse())),`${r.toUpperCase()}${"XZY".replace(r.toUpperCase(),"")}`)[r]*o.angleDirection;if(this.startInfo.angle+=A,this.setAngleHelperLength(r,this.startInfo.angle),this.setTipsAngle(Il(this.startInfo.angle)),h){const w=new y.Vector3().subVectors(l.position,h).applyQuaternion(g).add(h);l.position.copy(w)}l.applyQuaternion(g),Ca.premultiply(g),this.internalHooks.emit("applyObjectRotate",{quaternion:g,origin:h}),this.hooks.emit("rotate",l.quaternion),this.startInfo.startVector=f}dragEnd(){this.isDragging&&(this.internalHooks.emit("setObjectRotate",Ca,this.rotateCenter),this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.hooks.emit("rotateEnd"))}getAngleHelper(e){var i,s,o;switch(e){case"x":return(i=this.helperObject3D.xCircle)==null?void 0:i.angleSector;case"y":return(s=this.helperObject3D.yCircle)==null?void 0:s.angleSector;case"z":return(o=this.helperObject3D.zCircle)==null?void 0:o.angleSector}}setAngleHelperStart(e,i){const s=this.getAngleHelper(e);if(!s){console.warn("angleHelper is undefined");return}if(s instanceof y.Mesh&&s.geometry instanceof y.CircleGeometry){const{radius:o,segments:r,thetaLength:a}=s.geometry.parameters;s.geometry=new y.CircleGeometry(o,r,i,a)}else console.warn("only support THREE.CircleGeometry")}setAngleHelperLength(e,i){const o=i>=0?Math.max(i,.001):Math.min(i,-.001),r=this.getAngleHelper(e);if(r instanceof y.Mesh&&r.geometry instanceof y.CircleGeometry){const{radius:a,thetaStart:l}=r.geometry.parameters,c=Math.ceil(Math.abs(o)*(40/(2*Math.PI)));r.geometry=new y.CircleGeometry(a,c,l,o)}else console.warn("only support THREE.CircleGeometry")}setTipsAngle(e){var s;const i=(s=this.helperObject3D.angleTips)==null?void 0:s.element;i&&(i.innerText=`${e.toFixed(0)}°`)}setTipsPosition(e){const i=this.helperObject3D.angleTips;if(!i)return;const s=e.project(this.camera),{x:o,y:r,z:a}=s;if(a>1)return;const l=(o+1)/2*100+"%",c=(-r+1)/2*100+"%";i.setLeftTop(l,c)}}class Pv extends Ws{constructor(...e){super(...e);d(this,"startInfo");d(this,"name","RectangleScaleController")}enable(){this.helperObject3D.enable(),super.enable()}disable(){this.helperObject3D.disable(),super.disable()}show(){this.helperObject3D.show(),super.show()}hide(){this.helperObject3D.hide(),super.hide()}onApplyOriginObjectPosition(e){this.isDragging||super.onApplyOriginObjectPosition(e)}onApplyOriginObjectScale(e){this.helperObject3D.applyHelperScaleMatrix4(e.matrix,e.origin)}getDragPlane(){const e=new y.Plane,i=this.helperObject3D.cornerPositions;if(i.length!==0)return i.length<3?e.setFromNormalAndCoplanarPoint(this.originObject3D.getWorldDirection(new W.Vector3),i[0]):e.setFromCoplanarPoints(i[0],i[1],i[2]),e}dragStart(e,i){var o,r;(r=(o=this.helperObject3D).updatePoints)==null||r.call(o);const s=this.getDragPlane();if(!s)return this.dragEnd();this.startInfo={startPoint:{position:i.position.clone(),direction:i.direction},plane:s},this.hooks.emit("scaleStart"),this.render(),this.isDragging=!0}dragging(e){if(!this.isDragging)return;const i=Ar(this.camera,e,this.container);if(!i)return this.dragEnd();this.scale(i)}scale(e){var Y,H;if(!this.startInfo)return;const i=this.originObject3D,{startPoint:s,plane:o}=this.startInfo,r=this.helperObject3D.cornerPositions;if(r.length<4)return this.dragEnd();const a=e.ray.intersectPlane(o,new W.Vector3);if(!a||nv(a,this.camera.position))return;const l=new W.Vector3().addVectors(r[0],r[2]).divideScalar(2),{position:c,direction:h}=s,u=new W.Vector3().subVectors(r[1],r[0]),f=new W.Vector3().subVectors(r[3],r[0]),g=_=>{const G=new W.Vector3(0,0,0);if(!this.startInfo)return G;const N=(_==="ew"?u:f).clone(),U=c.clone().projectOnVector(N),F=a.clone().projectOnVector(N),X=l.clone().projectOnVector(N);if(F.equals(U))return G;if(_==="ns"&&typeof this.startInfo.dragPointInCenterBottom!="boolean"){const ae=new W.Vector3().subVectors(F,X),re=ae.x<0&&N.x>=0,Pe=ae.y<0&&N.y>=0,ve=ae.z<0&&N.z>=0;this.startInfo.dragPointInCenterBottom=re||Pe||ve}if(_==="ew"&&typeof this.startInfo.dragPointInCenterLeft!="boolean"){const ae=new W.Vector3().subVectors(F,X),re=ae.x<0&&N.x>=0,Pe=ae.y<0&&N.y>=0,ve=ae.z<0&&N.z>=0;this.startInfo.dragPointInCenterLeft=re||Pe||ve}const J=new W.Vector3().subVectors(F,U),q=J.length();return q>.3?(console.warn("offset.length() > 0.3, skipped",q),G):J},v=g("ew"),p=g("ns"),m=()=>{const _=v;this.helperObject3D.cornerPositions.forEach((G,N)=>{var U;(U=this.startInfo)!=null&&U.dragPointInCenterLeft?(N===0||N===3)&&G.add(_):(N===1||N===2)&&G.add(_)})},A=()=>{const _=p;this.helperObject3D.cornerPositions.forEach((G,N)=>{var U;(U=this.startInfo)!=null&&U.dragPointInCenterBottom?(N===0||N===1)&&G.add(_):(N===2||N===3)&&G.add(_)})};switch(h){case"ew":m();break;case"ns":A();break;case"nesw":case"nwse":m(),A()}const w=new W.Vector3().subVectors(r[1],r[0]).length()/u.length(),I=new W.Vector3().subVectors(r[3],r[0]).length()/f.length(),P=new W.Vector3(w,I,1),k=new y.Matrix4().scale(P);i.isCSS3DObjectPlus?i.applyScaleMatrix4(k):i.scale.applyMatrix4(k),s.position.copy(a);const E=new W.Vector3().addVectors(r[0],r[2]).divideScalar(2),L=new W.Vector3().subVectors(E,l),R=new y.Matrix4().setPosition(L);i.applyMatrix4(R),(Y=this.helperObject3D.css3DInstance)==null||Y.css3DObject.applyMatrix4(R),(H=this.helperObject3D.plane)==null||H.applyMatrix4(R),this.internalHooks.emit("applyObjectScale",{matrix:k}),this.internalHooks.emit("applyObjectPosition",{matrix:R}),this.render()}dragEnd(){this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.hooks.emit("scaleEnd"),this.render())}}class Iv extends Pv{constructor(...e){super(...e);d(this,"name","CSS3DScaleController");this.addHTMLEventListener()}addHTMLEventListener(){this.helperObject3D.points.forEach(e=>{if(!e)return;const i=e.point,s=a=>this.dragStart(a,e),o=this.dragging.bind(this),r=this.dragEnd.bind(this);i.addEventListener("dragstart",s),i.addEventListener("drag",o),i.addEventListener("dragend",r)})}}const Gt=document.createElement("div");Gt.classList.add("behindFiveElement");Gt.style.position="absolute";Gt.style.top="0";Gt.style.left="0";Gt.style.width="100%";Gt.style.height="100%";Gt.style.pointerEvents="none";function Lf(n){var i,s,o,r,a;const t=(a=(s=Pa(n.getElement()))!=null?s:Pa((i=n.getElement())==null?void 0:i.parentElement))!=null?a:Pa((r=(o=n.getElement())==null?void 0:o.parentElement)==null?void 0:r.parentElement),e=t==null?void 0:t.parentElement;if(e)return e.contains(Gt)||t.parentElement.insertBefore(Gt,t),Gt;console.error("Can not find a valid element to insert behindFiveElement. How to fix it: https://github.com/realsee-developer/dnalogel/tree/main/plugins/src/CSS3DRenderPlugin/README.md")}function Pa(n){var a;if(!n)return;const t=(a=n.style.position)!=null?a:getComputedStyle(n).position;if(t!=="fixed"&&t!=="absolute"&&t!=="relative")return;const e=getComputedStyle(n),i=e.backgroundColor,s=e.backgroundImage;if(!(i!=="transparent"&&i!=="rgba(0, 0, 0, 0)"&&i!==""||s!=="none"&&s!==""))return n}class Ev extends Ws{constructor(...e){super(...e);d(this,"name","BoundingBoxController")}}class Mv extends $p{constructor(e,i){super(e,i);d(this,"scaleMeshes",[]);d(this,"positions",[]);i&&(this.positions=i.positions)}initialPosition(e){this.position.copy(this.originObject3D.position),this.scaleMeshes.length&&this.remove(...this.scaleMeshes);const i=typeof this.positions=="function"?this.positions():this.positions;i&&(this.scaleMeshes=i.map(s=>{const o=kv();return o.position.copy(s.handlePosition),o.scalePosition=s,o}),this.add(...this.scaleMeshes))}setScaleByCamera(e){this.scaleMeshes.forEach(i=>{i.scale.setScalar(Cl(e,i.scalePosition.handlePosition.clone().applyMatrix4(this.matrixWorld)))})}}function kv(){const t=new y.BoxGeometry(.05,.05,.05),e=new y.MeshBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide}),i=new y.Mesh(t,e);return i.renderOrder=10,i}class xv extends Ws{constructor(...e){super(...e);d(this,"name","ScaleController");d(this,"startInfo");d(this,"dragStart",e=>{if(this.isDragging)return;this.isDragging=!0;const{intersect:i}=e,s=this.camera.position,o=i.object,r=o.scalePosition.basePosition.clone(),l=o.scalePosition.handlePosition.clone().clone().sub(r).clone(),c=new y.Line3(r,r.clone().add(l.normalize().multiplyScalar(5)));c.applyMatrix4(this.helperObject3D.matrixWorld);const h=new y.Raycaster(s,i.point.clone().sub(s)),u=nn({raycaster:h,line:c});this.startInfo={line:c,scaleStartPoint:u,draggingObject:o},this.hooks.emit("scaleStart")});d(this,"dragging",e=>{if(!this.isDragging||!this.startInfo)return;const i=Ar(this.camera,e,this.container);return i?(this.scale(i),!1):this.dragEnd()});d(this,"scale",e=>{var c,h;if(!this.startInfo)return;const{line:i,scaleStartPoint:s,draggingObject:o}=this.startInfo,{scalePosition:r}=o,{basePosition:a}=r,l=nn({raycaster:e,line:i});l.applyMatrix4(new y.Matrix4().getInverse(this.helperObject3D.matrixWorld.clone())),(h=(c=this.config)==null?void 0:c.scaleCallback)==null||h.call(c,{ratio:l.distanceTo(a)/s.distanceTo(a),intersectPoint:l,scalePosition:r}),o.position.copy(l.clone())});d(this,"dragEnd",()=>{this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.internalHooks.emit("initialHelperPosition"),this.hooks.emit("scaleEnd"))});this.domEvents.addEventListener(this.helperObject3D,"mousedown",this.dragStart),document.addEventListener("mousemove",this.dragging),document.addEventListener("mouseup",this.dragEnd)}initialHelperQuaternion(){this.helperObject3D.initQuaternion()}initialHelperPosition(){this.helperObject3D.initialPosition();const e=this;e.offHoverListener&&e.offHoverListener(),e.offHoverListener=this.hoverListener(this.helperObject3D.scaleMeshes)}setScale(e){var l,c,h;let i=1,s=1,o=1;typeof e=="number"?(i=e,s=e,o=e):typeof e=="object"&&(i=(l=e.x)!=null?l:1,s=(c=e.y)!=null?c:1,o=(h=e.z)!=null?h:1);const r=new y.Vector3(i,s,o);this.hooks.emit("wantToScale",r)||(this.originObject3D.scale.copy(r),this.internalHooks.emit("setObjectScale",r),this.hooks.emit("scale",r),this.render())}}function Kn(n){return Q(this,null,function*(){return new Promise(t=>{if(Dv(n))t();else{const e=i=>{const s=Vt(n);i===s&&(n.off("modelLoaded",e),t())};n.on("modelLoaded",e)}})})}function Dv(n){var t;return(t=Vt(n))==null?void 0:t.loaded}const Za="Object3DHelperPlugin",br=Za,Sv=()=>{console.error(`${br} is disposed`)},Tv=()=>{console.warn(`${br} is disabled`)},Lv=()=>{console.error(`${br} is disabled`)};class El extends Oi{constructor(e){super(e);d(this,"name",Za);d(this,"state",{visible:!0,enabled:!0,disposed:!1});d(this,"objectHelperMap",new Map);d(this,"css3DObjectParentMap",new Map);d(this,"css3DRender");this.five=e,this.css3DRender=new Gn(this.five.scene),console.warn("Object3DHelper: 使用此插件,需要在初始化five时,设置five参数: { backgroundAlpha: 0, backgroundColor: 0x000000 }"),Object.assign(window,{[`__${Za.toUpperCase()}_DEBUG__`]:this})}show(e){return Q(this,null,function*(){this.setState({visible:!0},e)})}hide(e){return Q(this,null,function*(){this.setState({visible:!1},e)})}enable(e){this.setState({enabled:!0},e)}disable(e){this.setState({enabled:!1},e)}dispose(){this.setState({disposed:!0})}setState(e,i){if(this.state.disposed)return Sv();if(!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return Lv();const s=x({},this.state);this.state=x(x({},this.state),e),e.disposed!==void 0&&e.disposed!==s.disposed&&e.disposed&&this.handleDispose(),e.visible!==void 0&&e.visible!==s.visible&&this.handleVisible(e.visible),e.enabled!==void 0&&e.enabled!==s.enabled&&this.handleEnable(e.enabled),this.hooks.emit("stateChange",{state:this.state,prevState:s})}getObject3DHelper(e){return this.objectHelperMap.get(e)}addObject3DHelper(e,i={}){var A;if(!e){console.error("Object3D is undefined");return}if(this.objectHelperMap.has(e)){console.warn(`Object3DHelperPlugin: object3D ${e.name} is already has helper`);return}const s=new wv,o=[],r=(A=this.five.getElement())==null?void 0:A.parentElement,a=this.five.camera,c=x(x({},{moveHelper:!0,rotateHelper:!0,scaleHelper:!0,boundingBoxHelper:!1,positionFrom:"objectPosition"}),i),{moveHelper:h,rotateHelper:u,scaleHelper:f,boundingBoxHelper:g}=c,v=new dt,p=new dt,m=w=>{if(w)return typeof w=="boolean"?w:w.enable};if(m(h)){const w=x(x({},this.getConfig(c.moveHelper)),c),I=new sv(e,x({},w)),P=new ws(this.five,mv,e,I,w,v,p);s.addControllers({moveController:P.helperController}),o.push(()=>P.dispose())}if(m(u)){const w=x(x({},this.getConfig(c.rotateHelper)),c),I=new av(e,x({container:r},w)),P=new ws(this.five,Cv,e,I,w,v,p);s.addControllers({rotateController:P.helperController}),o.push(()=>P.dispose())}if(m(g)){const w=new fv(e),I=new ws(this.five,Ev,e,w,void 0,v,p);s.addControllers({boundingBoxController:I.helperController})}if(m(f))if(e.isCSS3DObjectPlus&&r){const w=new uv(e,r,a,this.five.scene),I=new ws(this.five,Iv,e,w,void 0,v,p);s.addControllers({scaleController:I.helperController}),o.push(()=>I.dispose()),Kn(this.five).then(()=>{var P,k;if(e.isCSS3DObjectPlus){const E=e;if(!E||E.mode!=="front")return;const L=(P=this.css3DRender.behindModeCSS3DRenderer.wrapper)!=null?P:Lf(this.five);L&&(this.css3DObjectParentMap.set(E,E.parent),E.removeFromParent(),this.css3DRender.behindModeCSS3DRenderer.setWrapper(L),(k=this.css3DRender.getBehindCSS3DObjectGroup())==null||k.add(E),this.css3DRender.render(this.five.camera))}})}else{const w=x(x({},this.getConfig(c.scaleHelper)),c),I=new Mv(e,w),P=new ws(this.five,xv,e,I,w,v,p);s.addControllers({scaleController:P.helperController}),o.push(()=>P.dispose())}return this.objectHelperMap.set(e,{helper:s,disposers:o}),s.controllers}removeObject3DHelper(e){if(!this.objectHelperMap.has(e))return;const{helper:i,disposers:s}=this.objectHelperMap.get(e);if(i){if(e.isCSS3DObjectPlus){const o=e,r=this.css3DObjectParentMap.get(o);r&&r.add(o),this.css3DRender.render(this.five.camera)}this.objectHelperMap.delete(e),i.dispose(),s==null||s.forEach(o=>o==null?void 0:o())}}handleEnable(e,i=!0){e?(this.everyHelperDo(s=>s.enable()),this.hooks.emit("enable",{userAction:i})):(this.everyHelperDo(s=>s.disable()),this.hooks.emit("disable",{userAction:i})),this.state.enabled=e}handleVisible(e,i=!0){e?(this.everyHelperDo(s=>s.show()),this.actionIfStateIsEnabled(()=>this.hooks.emit("show",{userAction:i}))):(this.everyHelperDo(s=>s.hide()),this.actionIfStateIsEnabled(()=>this.hooks.emit("hide",{userAction:i}))),this.state.visible=e}handleDispose(){this.everyHelperDo((e,i)=>{e.dispose(),i==null||i.forEach(s=>s==null?void 0:s())})}everyHelperDo(e){this.objectHelperMap.forEach(({helper:i,disposers:s})=>{i&&e(i,s)})}actionIfStateIsEnabled(e,i){if(this.state.enabled)return e();i!=null&&i.warnLog&&Tv()}getConfig(e){if(e&&typeof e!="boolean"&&e.enable)return e}}const jv=n=>new El(n);function jf(n,t){const{top:e,left:i,width:s,height:o}=t.getBoundingClientRect();return new y.Vector2((n.x-i)/s*2-1,-(n.y-e)/o*2+1)}class Sc extends y.Raycaster{intersectObject(t,e=!0,i=[]){return Ja(t,this,i,e),i.sort(Tc),i}intersectObjects(t,e=!0,i=[]){for(let s=0,o=t.length;s<o;s++)Ja(t[s],this,i,e);return i.sort(Tc),i}}function Tc(n,t){return n.distance-t.distance}function Ja(n,t,e,i){let s=!0;if(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0){const o=n.children;for(let r=0,a=o.length;r<a;r++)Ja(o[r],t,e,!0)}}function Ml(n,t,e,i){let s=!0;if(n.type!=="Line2"&&(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0)){const o=n.children;for(let r=0,a=o.length;r<a;r++)o[r].type!=="Line2"&&Ml(o[r],t,e,!0)}}class kl{constructor(t,e){d(this,"five");d(this,"dragging",!1);d(this,"boundObject",{});d(this,"config");d(this,"lastMouseDownEvent");d(this,"handleWantsGesture",(t,e)=>{if(e.length!==1)return;const i=e[0];if(i.raycaster){const s=new Sc;s.ray=i.raycaster.ray,s.near=i.raycaster.near,s.far=i.raycaster.far,s.camera=i.raycaster.camera,s.layers=i.raycaster.layers,s.params=i.raycaster.params,i.raycaster=s}if(i){if(t==="mouseMove"&&this.onDomEvent("hover",i),t==="tap"){const s=this.lastMouseDownEvent,o=this.onDomEvent("click",i,s),r=this.onDomEvent("wantDblclick",i,s,this.boundObject.dblclick);if(o===!1||r===!1)return!1}if(this.dragging)return!1}});d(this,"handleDomEvent",(t,e,i)=>{const s={x:e.clientX,y:e.clientY};this.onDomEvent(t,s,e,i)});d(this,"handleMouseEvent",t=>{this.handleDomEvent(t.type,t)});d(this,"handleMousedown",t=>{this.lastMouseDownEvent=t,this.handleDomEvent("mousedown",t),this.handleDomEvent("dragstart",t,this.haveDragEventObject)});d(this,"handleMouseup",t=>{var e;this.dragging=!1,(e=this.haveDragEventObject)==null||e.forEach(i=>{i._dragging&&(i._dragging=!1,this.notify({eventName:"dragend",object:i,originEvent:t,raycaster:this.getRaycaster({x:t.clientX,y:t.clientY})}))}),this.handleDomEvent("mouseup",t)});d(this,"handleMousemove",t=>{var e;this.dragging&&((e=this.boundObject.drag)==null||e.forEach(i=>{i._dragging&&this.notify({eventName:"drag",object:i,originEvent:t,raycaster:this.getRaycaster({x:t.clientX,y:t.clientY})})}))});d(this,"onDomEvent",(t,e,i,s=this.boundObject[t])=>{var f,g,v,p,m;if(!e||!s||(s==null?void 0:s.length)===0)return;const o=[];((f=this.config)==null?void 0:f.fiveModels)!==null&&((g=this.config)!=null&&g.fiveModels?o.push(...this.config.fiveModels):o.push(this.model));const r=o.filter(A=>A.loaded),a=(v=e.raycaster)!=null?v:this.getRaycaster(e);a.params.Points.threshold=.02;const l=a.intersectObjects(s,!0),c=[];r.forEach(A=>{const w=A.intersectRaycaster(a);c.push(...w)});const h=.01;if(c.length>0&&l.length>0&&c[0].distance+h<l[0].distance)return;const u=(p=l==null?void 0:l[0])==null?void 0:p.object;if(t==="wantDblclick")return!1;if((!u||!this.objectIsBound(u))&&t==="hover")for(const A of(m=this.boundObject.hover)!=null?m:[])A._hovered&&this.notify({eventName:"unHover",object:A});if(u&&u&&this.notify({eventName:t,object:u,originEvent:i,raycaster:a,intersects:l}))return!1});d(this,"objectIsBound",t=>{let e=t._domEvent,i=t.parent;for(;typeof e=="undefined"&&i;)e=i._domEvent,i=i.parent;return!!e});d(this,"notify",t=>{var f,g,v;const{eventName:e,object:i,originEvent:s,raycaster:o,intersects:r}=t;let a=!1,l=[];const c=[];let h=i;for(c.push(h);h.parent;)h=h.parent,c.push(h);const u=c.at(-1);if(!((f=this.config)!=null&&f.noEmitWhenNotInScene&&u.type!=="Scene")){for(const p of c){if(a)break;p.draggable&&(e==="dragstart"&&(p._dragging=!0,this.dragging=!0),e==="dragend"&&(p._dragging=!1,this.dragging=!1));const m=p._domEvent;if(!m)continue;const A=m[`${e}Handler`];if(A)for(const[w,I]of A){if(I!=null&&I.noEmitWhenNotInScene&&u.type!=="Scene"||((g=this.config)!=null&&g.noEmitWhenHide||I!=null&&I.noEmitWhenHide)&&!Al(p))continue;if(e==="hover"){if(p._hovered)continue;p._hovered=!0;for(const k of(v=this.boundObject.hover)!=null?v:[])k!==p&&k._hovered&&this.notify({eventName:"unHover",object:k})}if(e==="unHover"){if(!p._hovered)continue;p._hovered=!1}const P=w({type:e,target:p,origDomEvent:s,raycaster:o,intersects:r,stopPropagation:()=>{a=!0}});l.push(P!=null?P:!0)}}if(e==="click"||e==="wantDblclick")return l.some(p=>p===!0)}});this.five=t,this.config=e,t.on("wantsGesture",this.handleWantsGesture),document.addEventListener("mousedown",this.handleMousedown),document.addEventListener("dblclick",this.handleMouseEvent),document.addEventListener("mouseup",this.handleMouseup),document.addEventListener("mousemove",this.handleMousemove)}get haveDragEventObject(){return[...new Set([this.boundObject.dragend,this.boundObject.drag,this.boundObject.dragstart].flat())].filter(Boolean)}get model(){return Vt(this.five)}addAutoBindEventListener(t,e,i,s){const o=()=>this.addEventListener(t,e,i,s),r=()=>this.removeEventListener(t,e,i,s);return t.addEventListener("added",o),t.addEventListener("removed",r),t.addEventListener("dispose",r),()=>{t.removeEventListener("added",o),t.removeEventListener("removed",r),t.removeEventListener("dispose",r)}}addEventListener(t,e,i,s){t._domEvent||(t._domEvent={}),t._domEvent[`${e}Handler`]||(t._domEvent[`${e}Handler`]=[]),this.boundObject[e]||(this.boundObject[e]=[]),this.boundObject[e].includes(t)||this.boundObject[e].push(t),t._domEvent[`${e}Handler`].push([i,x({noEmitWhenHide:!1,noEmitWhenNotInScene:!1},s)])}removeEventListener(t,e,i,...s){var r,a;if(!t._domEvent||(e===void 0&&(Object.keys(this.boundObject).forEach(l=>{var h,u;const c=(h=this.boundObject[l])==null?void 0:h.findIndex(f=>f===t);c!==-1&&((u=this.boundObject[l])==null||u.splice(c,1))}),t._domEvent={}),!t._domEvent[`${e}Handler`]))return;if(i===void 0){delete t._domEvent[`${e}Handler`];return}const o=t._domEvent[`${e}Handler`].findIndex(l=>l[0]===i);if(o!==-1&&(t._domEvent[`${e}Handler`].splice(o,1),t._domEvent[`${e}Handler`].length===0&&delete t._domEvent[`${e}Handler`],t._domEvent&&Object.keys(t._domEvent).length===0&&delete t._domEvent,!t._domEvent)){const l=(r=this.boundObject[e])==null?void 0:r.findIndex(c=>c===t);l!==-1&&((a=this.boundObject[e])==null||a.splice(l,1))}}clear(){this.boundObject={}}dispose(){var t;(t=this.five)==null||t.off("wantsGesture",this.handleWantsGesture),document.removeEventListener("mousedown",this.handleMousedown),document.removeEventListener("mouseup",this.handleMouseup),document.removeEventListener("mousemove",this.handleMousemove),this.boundObject={}}toJSON(){return{boundObject:this.boundObject}}getRaycaster(t){const e=this.five.getElement();if(!e)return;const i=jf(t,e),s=new Sc;return s.setFromCamera(i,this.five.camera),s}}const zf="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function zv(n,t){const{x:e,y:i}=t,s=e*2-1,o=i*2-1,r=new y.Raycaster;return r.setFromCamera({x:s,y:o},n.camera),r.params.Points.threshold=.02,r}function Us(n,t,e){const i=Ov(n,t);return e!=null&&e.virtualPoint?i!=null?i:Of(t):i}function Of(n,t=3){const e=new y.Vector3().addVectors(n.ray.origin,n.ray.direction.clone().normalize().multiplyScalar(t)),i=n.ray.direction.clone().negate();return{distance:t,point:e,object:new y.Object3D,face:new y.Face3(0,0,0,i),raycaster:n,isVirtual:!0}}function Ov(n,t){const s=Vt(n).intersectRaycaster(t)[0];if(s)return ie(x({},s),{raycaster:t,isVirtual:!1})}const Vv=new y.Vector3,Pn=()=>!1;class Vf extends dt{constructor(e,i){var r,a,l;super();d(this,"outOfFive",!1);d(this,"enabled",!1);d(this,"actionIfNoModelUnderMouse","virtualPoint");d(this,"plane");d(this,"pointSelectorHelper");d(this,"hook",this);d(this,"five");d(this,"hammer");d(this,"mode");d(this,"pressDown",!1);d(this,"adherePoints");d(this,"adherePointsRadius",.1);d(this,"lastFiveHelperVisible");d(this,"lastIntersection");d(this,"mousePosition");d(this,"config",{});d(this,"select",e=>{e&&this.updatePointSelectorHelperIntersect(e);const i=this.emit("wantsSelect",this.position);return i||(this.pointSelectorHelper.hide(),this.emit("select",this.position),console.debug(this.position)),!i});d(this,"onEnter",()=>{this.pointSelectorHelper.show(),this.outOfFive=!1,this.emit("intersectionUpdate",this.position)});d(this,"onLeave",()=>{this.pointSelectorHelper.hide(),this.outOfFive=!0,this.emit("intersectionUpdate",null)});d(this,"onTap",e=>{e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),this.select()});d(this,"onPan",e=>{this.pressDown&&(e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),this.mouseNdcPosition&&this.updateByNdcPosition(this.mouseNdcPosition))});d(this,"onPress",e=>{if(e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),!this.mouseNdcPosition)return;const i=this.updateByNdcPosition(this.mouseNdcPosition);this.pressDown=i});d(this,"onPanEnd",()=>{this.pressDown&&(this.pressDown=!1,this.select())});d(this,"updateByMousePosition",e=>{this.five.getElement()&&(this.mousePosition=e,this.updateByNdcPosition(this.mouseNdcPosition))});d(this,"updateByNdcPosition",e=>{var o,r;const i=zv(this.five,e),s=Us(this.five,i);if(s)return this.updatePointSelectorHelperIntersect(s),this.lastIntersection=s,!0;if(this.plane){const a=i.ray.intersectPlane(this.plane,Vv);if(a){const l={distance:this.five.camera.position.distanceTo(a),point:a.clone(),object:new y.Object3D,face:new y.Face3(0,0,0,this.plane.normal.clone()),raycaster:i,isVirtual:!0};return this.updatePointSelectorHelperIntersect(l),!0}}if(this.actionIfNoModelUnderMouse==="lastPoint")return this.updatePointSelectorHelperIntersect(this.lastIntersection),!0;if(this.actionIfNoModelUnderMouse==="virtualPoint"){const a=Of(i,(o=this.lastIntersection)==null?void 0:o.distance);return a.face=new y.Face3(0,0,0,(r=this.lastIntersection)==null?void 0:r.face.normal),this.lastIntersection=a,this.updatePointSelectorHelperIntersect(a),!0}else if(this.actionIfNoModelUnderMouse==="disable")return this.updatePointSelectorHelperIntersect(null),!1});d(this,"updatePointSelectorHelperIntersect",e=>{if(!e){this.onLeave(),this.five.getElement().style.cursor=`url("data:image/svg+xml,%3Csvg width='12px' height='12px' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cpath d='M6,12 C9.3137085,12 12,9.3137085 12,6 C12,2.6862915 9.3137085,0 6,0 C2.6862915,0 0,2.6862915 0,6 C0,9.3137085 2.6862915,12 6,12 Z' fill='%23FF5959'%3E%3C/path%3E%3Cg transform='translate(2, 2)' stroke='%23FFFFFF'%3E%3Ccircle cx='4' cy='4' r='4'%3E%3C/circle%3E%3Cline x1='1.07141075' y1='1.23997894' x2='6.64700843' y2='6.81557662'%3E%3C/line%3E%3C/g%3E%3C/g%3E%3C/svg%3E"), auto`;return}this.onEnter(),this.five.getElement().style.cursor="";const i=x({},e);let s=!1;if(typeof this.adherePoints=="function"&&typeof this.adherePointsRadius=="number"){for(const o of this.adherePoints({intersection:e,pointSelectorInstance:this}))if(o.distanceTo(e.point)<this.adherePointsRadius){i.point=o.clone(),s=!0;break}}this.pointSelectorHelper.updateWithIntersect(i,{emitEvent:!1}),this.emit("intersectionUpdate",i,s)});d(this,"mousePositionToNdcPosition",e=>{const i=this.five.getElement();if(!i)return null;const{top:s,left:o,width:r,height:a}=i.getBoundingClientRect(),{clientX:l,clientY:c}=e;return{x:(l-o)/r,y:1-(c-s)/a}});d(this,"onFiveWantsPanGesture",()=>{if(this.pressDown)return!1});d(this,"renderScreenCenter",()=>{this.updateByNdcPosition({x:.5,y:.5})});d(this,"emitIntersectionUpdate",e=>{this.emit("intersectionUpdate",e)});this.five=e,this.config=x(x({},this.config),i),this.actionIfNoModelUnderMouse=(r=i==null?void 0:i.actionIfNoModelUnderMouse)!=null?r:"virtualPoint";const s=(a=i==null?void 0:i.mode)!=null?a:"auto";s==="auto"?this.mode=zf?"fixed":"cursor":this.mode=s;const o={autoFixPCPosition:this.mode==="cursor",initialPosition:this.mode==="fixed"?{left:"35%",top:"20%"}:void 0};this.pointSelectorHelper=new Rf(this.five,ie(x({},i==null?void 0:i.helper),{magnifierParams:x(x({},o),(l=i==null?void 0:i.helper)==null?void 0:l.magnifierParams)})),this.pointSelectorHelper.hide()}get position(){return this.outOfFive?null:this.pointSelectorHelper.position}get mouseNdcPosition(){return this.mousePosition?this.mousePositionToNdcPosition(this.mousePosition):null}enable(){if(this.enabled)return;this.enabled=!0,this.outOfFive=!1,this.pointSelectorHelper.enable();const e=this.five.getElement();if(!e)throw new Error("five element not found");this.hammer||(this.hammer=new fr(e)),this.mode==="cursor"?(this.five.on("wantsPanGesture",this.onFiveWantsPanGesture),this.five.on("wantsMoveToPano",Pn),this.five.on("wantsChangeMode",Pn),this.five.on("wantsTapGesture",Pn),e.addEventListener("mousemove",this.updateByMousePosition),e.addEventListener("wheel",this.updateByMousePosition),e.addEventListener("mouseenter",this.onEnter),e.addEventListener("mouseout",this.onLeave),this.hammer.on("tap",this.onTap),this.hammer.on("pan",this.onPan),this.hammer.on("press",this.onPress),this.hammer.on("panend",this.onPanEnd)):this.mode==="fixed"&&(this.five.on("panoArrived",this.renderScreenCenter),this.five.on("panGesture",this.renderScreenCenter),this.five.on("interiaPan",this.renderScreenCenter),this.renderScreenCenter(),this.pointSelectorHelper.show()),this.pointSelectorHelper.hooks.on("intersectionUpdate",this.emitIntersectionUpdate),this.lastFiveHelperVisible=this.five.helperVisible,this.five.helperVisible=!1,this.emit("enable")}disable(){if(!this.enabled)return;this.enabled=!1,this.pointSelectorHelper.disable(),this.five.getElement().style.cursor="";const e=this.five.getElement();this.five.off("wantsPanGesture",this.onFiveWantsPanGesture),this.five.off("wantsMoveToPano",Pn),this.five.off("wantsChangeMode",Pn),this.five.off("wantsTapGesture",Pn),this.five.helperVisible=this.lastFiveHelperVisible,e==null||e.removeEventListener("mousemove",this.updateByMousePosition),e==null||e.removeEventListener("wheel",this.updateByMousePosition),e==null||e.removeEventListener("mouseenter",this.onEnter),e==null||e.removeEventListener("mouseout",this.onLeave),this.hammer.off("tap",this.onTap),this.hammer.off("pan",this.onPan),this.hammer.off("press",this.onPress),this.hammer.off("panend",this.onPanEnd),this.five.off("panoArrived",this.renderScreenCenter),this.five.off("panGesture",this.renderScreenCenter),this.five.off("interiaPan",this.renderScreenCenter),this.pointSelectorHelper.hooks.off("intersectionUpdate",this.emitIntersectionUpdate),this.emit("disable")}dispose(){this.disable(),this.pointSelectorHelper.dispose()}setAdherePoints(e,i){e?typeof e=="function"?this.adherePoints=e:this.adherePoints=()=>e:this.adherePoints=null,typeof i=="number"&&(this.adherePointsRadius=i)}}class Bv{constructor(){d(this,"five");d(this,"_cursor");d(this,"_pointSelector");d(this,"_fiveDomEvents");d(this,"_object3DHelper");d(this,"inited",!1);d(this,"init",t=>{this.inited=!0,this.five=t,this._cursor=void 0,this._pointSelector=void 0,this._fiveDomEvents=void 0,this._object3DHelper=void 0})}get cursor(){if(!this.inited)throw new Error("Global not inited");return this._cursor?this._cursor:(this._cursor=new Qp(this.five.getElement()),this._cursor)}get pointSelector(){if(!this.inited)throw new Error("Global not inited");return this._pointSelector?this._pointSelector:(this._pointSelector=new Vf(this.five),this._pointSelector)}get fiveDomEvents(){if(!this.inited)throw new Error("Global not inited");return this._fiveDomEvents?this._fiveDomEvents:(this._fiveDomEvents=new kl(this.five,{noEmitWhenNotInScene:!0}),this._fiveDomEvents)}get object3DHelper(){if(!this.inited)throw new Error("Global not inited");return this._object3DHelper?this._object3DHelper:(this._object3DHelper=new El(this.five),this._object3DHelper)}}const xl=new Bv;window.globalModules=xl;function Bf(n){Lc(n),n.traverse(t=>Lc(t))}function Lc(n){Array.isArray(n.lengthDoms)&&n.lengthDoms[0]instanceof bl&&n.lengthDoms.forEach(e=>e.destroy())}class jc extends Np{constructor(e){var i,s;super(e);d(this,"_three_color");ke(e==null?void 0:e.color)&&(this.three_color=(i=e==null?void 0:e.color)!=null?i:16777215),Object.keys(e).forEach(o=>{["color","dashed","dashScale","dashSize","gapSize","resolution"].includes(o)||o in this&&(this[o]=e[o])}),this.setDashed((s=e==null?void 0:e.dashed)!=null?s:!1)}get three_color(){return this._three_color}set three_color(e){this._three_color=e,this.color=e}setDashed(e){this.dashed=e,e?this.defines.USE_DASH="":delete this.defines.USE_DASH,this.needsUpdate=!0}}class zc extends Fp{constructor(e,i){super(e,i);d(this,"name","Line3")}}class Wt extends Lt{constructor(e){var r,a,l,c,h;super();d(this,"name","LineMesh");d(this,"points");d(this,"lengthDoms",[]);d(this,"highlighted",!1);d(this,"line");d(this,"backLine");d(this,"opacityBeforeHighlight");d(this,"paramsStyle",{});this.paramsStyle=e!=null?e:{};const i=new kc,s=new jc({color:new y.Color((r=e==null?void 0:e.lineColor)!=null?r:Mc),linewidth:(a=e==null?void 0:e.lineWidth)!=null?a:Rp,dashScale:40,opacity:(l=e==null?void 0:e.opacity)!=null?l:1,transparent:!0,dashed:(c=e==null?void 0:e.dashed)!=null?c:!1}),o=new jc({color:new y.Color((h=e==null?void 0:e.lineColor)!=null?h:Mc),linewidth:s.linewidth*.9,dashScale:s.dashScale,opacity:s.opacity*.8,depthTest:!1,depthWrite:!1,transparent:!0,resolution:s.resolution});this.line=new zc(i,s),this.backLine=new zc(i,o),this.line.renderOrder=1,this.backLine.renderOrder=0,this.line.name="lineFrontMaterial",this.backLine.name="lineBackMaterial",e&&this.setStyle(e),e!=null&&e.points&&this.setPoints(e.points),this.addEventListener("removed",()=>{Bf(this)})}get style(){return{lineColor:this.color,lineWidth:this.lineWidth,dashed:this.dashed,occlusionVisibility:this.occlusionVisibility,occlusionMode:this.occlusionMode,lengthEnable:this.paramsStyle.lengthEnable}}get lineWidth(){return this.line.material.linewidth}get color(){return new y.Color(this.line.material.three_color)}get dashed(){return this.line.material.dashed}get occlusionVisibility(){return this.backLine.visible||this.line.material.depthTest===!1}get occlusionMode(){return this.line.material.depthTest===!1?"depthTest":"translucence"}setPoints(e){const i=e.map(Ge).filter(ke);if(this.points=i,i.length<2)return;this.addIfNotExists(this.line,this.backLine);const s=i.flatMap(o=>[o.x,o.y,o.z]);s.length>2&&(this.line.geometry.dispose(),this.line.geometry=new kc,this.backLine.geometry=this.line.geometry),this.line.geometry.setPositions(s),this.line.computeLineDistances(),this.updateLengthItems(),this.needsRender=!0}setResolution(e,i){const s=this.line.material.resolution;(s.x!==e||s.y!==i)&&(s.set(e,i),this.needsRender=!0);const o=this.backLine.material.resolution;(o.x!==e||o.y!==i)&&(o.set(e,i),this.needsRender=!0)}setStyle(e){var o,r,a;this.paramsStyle=x(x({},this.paramsStyle),e),ke(e.lineColor)&&(this.line.material.three_color=new y.Color(e.lineColor),this.backLine.material.three_color=new y.Color(e.lineColor)),ke(e.lineWidth)&&(this.line.material.linewidth=e.lineWidth),ke(e.dashed)&&this.line.material.setDashed(e.dashed),ke(e.opacity)&&(this.line.material.opacity=e.opacity,this.backLine.material.opacity=this.line.material.opacity*.2),this.updateLengthItems();const i=(o=e.occlusionVisibility)!=null?o:this.paramsStyle.occlusionVisibility,s=(a=(r=e.occlusionMode)!=null?r:this.paramsStyle.occlusionMode)!=null?a:"translucence";i?s==="depthTest"?(this.line.material.depthTest=!1,this.backLine.visible=!1):s==="translucence"&&(this.line.material.depthTest=!0,this.backLine.visible=!0,this.line.material.opacity===1?this.backLine.material.setDashed(!0):this.backLine.material.setDashed(this.line.material.dashed)):(this.line.material.depthTest=!0,this.backLine.visible=!1),this.needsRender=!0}highlight(){this.highlighted||(this.highlighted=!0,this.opacityBeforeHighlight=this.line.material.opacity,this.line.material.opacity=this.opacityBeforeHighlight*Fn,this.backLine.material.opacity=this.backLine.material.opacity*Fn,this.needsRender=!0)}unhighlight(){this.highlighted&&(this.highlighted=!1,this.line.material.opacity=this.opacityBeforeHighlight,this.backLine.material.opacity=.2,this.needsRender=!0)}updateLengthItems(){var e,i;if(this.paramsStyle.lengthEnable){const s=(i=(e=this.points)==null?void 0:e.map((o,r)=>{if(r!==0)return[this.points[r-1],o]}).filter(ke))!=null?i:[];s.forEach(([o,r],a)=>{var h;const l=ai(o,r),c=o.distanceTo(r).toFixed(2)+"m";this.lengthDoms[a]=(h=this.lengthDoms[a])!=null?h:new bl(xl.five),this.lengthDoms[a].setPosition(l),this.lengthDoms[a].container.innerHTML=`<div style="pointer-events:none;color:white;">${c}</div>`}),this.lengthDoms.length>s.length&&(this.lengthDoms.slice(s.length).forEach(o=>o.destroy()),this.lengthDoms.length=s.length)}else this.lengthDoms.forEach(s=>s.destroy()),this.lengthDoms=[]}}class Rv extends Go.CSS3DSprite{constructor(){super(...arguments);d(this,"isCSS3DSprite",!0)}}const Fv=`
|
|
178
178
|
varying vec2 vUv;
|
|
179
179
|
varying float vRadius;
|
|
180
180
|
varying float vDistanceToCamera;
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ import yp from "earcut";
|
|
|
48
48
|
import { GLTFLoader as wp } from "@realsee/five/gltf-loader";
|
|
49
49
|
function Cp() {
|
|
50
50
|
console.debug(
|
|
51
|
-
"%c %c@realsee/dnalogel %cv3.47.
|
|
51
|
+
"%c %c@realsee/dnalogel %cv3.47.2",
|
|
52
52
|
[
|
|
53
53
|
"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=')",
|
|
54
54
|
"background-repeat: no-repeat",
|
|
@@ -2102,7 +2102,7 @@ let Oi = class {
|
|
|
2102
2102
|
/**
|
|
2103
2103
|
* @realsee/dnalogel 版本号
|
|
2104
2104
|
*/
|
|
2105
|
-
d(this, "VERSION", "3.47.
|
|
2105
|
+
d(this, "VERSION", "3.47.2");
|
|
2106
2106
|
d(this, "NAME");
|
|
2107
2107
|
d(this, "five");
|
|
2108
2108
|
d(this, "workUtil");
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(ee,N){typeof exports=="object"&&typeof module!="undefined"?N(exports,require("three"),require("three/examples/jsm/renderers/CSS3DRenderer"),require("@realsee/five/line"),require("animejs"),require("@realsee/five"),require("hammerjs"),require("three/examples/jsm/loaders/FBXLoader"),require("earcut"),require("@realsee/five/gltf-loader")):typeof define=="function"&&define.amd?define(["exports","three","three/examples/jsm/renderers/CSS3DRenderer","@realsee/five/line","animejs","@realsee/five","hammerjs","three/examples/jsm/loaders/FBXLoader","earcut","@realsee/five/gltf-loader"],N):(ee=typeof globalThis!="undefined"?globalThis:ee||self,N(ee.dnalogel={},ee.THREE,ee.CSS3DRenderer,ee.Line,ee.anime,ee.FiveSDK,ee.Hammer,ee.FBXLoader,ee.earcut,ee.GLTFLoader))})(this,function(ee,N,He,wt,Wi,Xe,vn,An,ui,gs){"use strict";var Cx=Object.defineProperty,Px=Object.defineProperties;var Ix=Object.getOwnPropertyDescriptors;var jr=Object.getOwnPropertySymbols;var Gm=Object.prototype.hasOwnProperty,Qm=Object.prototype.propertyIsEnumerable;var yc=(ee,N,He)=>N in ee?Cx(ee,N,{enumerable:!0,configurable:!0,writable:!0,value:He}):ee[N]=He,x=(ee,N)=>{for(var He in N||(N={}))Gm.call(N,He)&&yc(ee,He,N[He]);if(jr)for(var He of jr(N))Qm.call(N,He)&&yc(ee,He,N[He]);return ee},ne=(ee,N)=>Px(ee,Ix(N));var fs=(ee,N)=>{var He={};for(var wt in ee)Gm.call(ee,wt)&&N.indexOf(wt)<0&&(He[wt]=ee[wt]);if(ee!=null&&jr)for(var wt of jr(ee))N.indexOf(wt)<0&&Qm.call(ee,wt)&&(He[wt]=ee[wt]);return He};var d=(ee,N,He)=>(yc(ee,typeof N!="symbol"?N+"":N,He),He);var H=(ee,N,He)=>new Promise((wt,Wi)=>{var Xe=ui=>{try{An(He.next(ui))}catch(gs){Wi(gs)}},vn=ui=>{try{An(He.throw(ui))}catch(gs){Wi(gs)}},An=ui=>ui.done?wt(ui.value):Promise.resolve(ui.value).then(Xe,vn);An((He=He.apply(ee,N)).next())});function Um(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 y=Um(N);function Ym(){console.debug("%c %c@realsee/dnalogel %cv3.47.1",["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 Xm(){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 wc(){}const Cc=()=>Promise.resolve(),Pc={__queue:Promise.resolve()};function Zm(n=Cc){Pc.__queue=Pc.__queue.then(n).catch(Cc)}function lo(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 zr(n,t,e){const{x:i,y:s}=n,o=i*t,r=s*e;return{x:o,y:r}}function co(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 Jm(n,t,e=wc){new Promise(i=>{setTimeout(()=>{e(),i(!0)},t*n)})}const qm=window,Ic=window.requestAnimationFrame||qm.webkitRequestAnimationFrame||(n=>setTimeout(n,16));function ho(n,t=0){t<=0?Ic(n):Ic(()=>ho(n,t-1))}var Kt=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-Kt.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?Kt.Bounce.In(n*2)*.5:Kt.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}}}}),bn=function(){return performance.now()},Mc=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=bn()),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}(),Hi={Linear:function(n,t){var e=n.length-1,i=e*t,s=Math.floor(i),o=Hi.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=Hi.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=Hi.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=Hi.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}}},Or=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),Vr=new Mc,uo=function(){function n(t,e){e===void 0&&(e=Vr),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=Kt.Linear.None,this._interpolationFunction=Hi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Or.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=bn()),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,v=u.length;g<v;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 A in m)e[r][A]=m[A];s[r]=l?[]:{};var u=i[r];if(!this._isDynamic){var w={};for(var A in u)w[A]=u[A];i[r]=u=w}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=bn()),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=bn()),!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=Vr),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=Kt.Linear.None),this._easingFunction=t,this},n.prototype.interpolation=function(t){return t===void 0&&(t=Hi.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=bn()),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),A=a-m*l,w=Math.min(A/i._duration,1);return w===0&&a===i._duration?1:w},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 v=0,p=this._chainedTweens.length;v<p;v++)this._chainedTweens[v].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}(),Km="23.1.1",$m=Or.nextId,$t=Vr,ep=$t.getAll.bind($t),tp=$t.removeAll.bind($t),ip=$t.add.bind($t),Ec=$t.remove.bind($t),np=$t.update.bind($t),kc={Easing:Kt,Group:Mc,Interpolation:Hi,now:bn,Sequence:Or,nextId:$m,Tween:uo,VERSION:Km,getAll:ep,removeAll:tp,add:ip,remove:Ec,update:np};function sp(n,t,e,i=Kt.Linear.None){const s=new uo(n).to(t,e).easing(i).start();function o(r){s.update(r)&&requestAnimationFrame(o)}return requestAnimationFrame(o),s}var fi=(n=>(n.Drawline="Drawline",n.Undo="Undo",n.Exit="Exit",n))(fi||{});const ms=Symbol("$$PAINT_BRUSH_EVENT$$");function fo(n){return n[ms]||(n[ms]={}),n[ms]}function op(n){n[ms]||delete n[ms]}let rp=class{hasListener(t){const e=fo(this);return e&&e[t]&&e[t].length>0}on(t,e,i){const s=fo(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){op(this);return}const i=fo(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=fo(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 ki(){return((1+Math.random())*65536|0).toString(16).substring(1)}function lt(){return(ki()+ki()+"-"+ki()+"-4"+ki().substr(0,3)+"-"+ki()+"-"+ki()+ki()+ki()).toLowerCase()}const ap=`
|
|
1
|
+
(function(ee,N){typeof exports=="object"&&typeof module!="undefined"?N(exports,require("three"),require("three/examples/jsm/renderers/CSS3DRenderer"),require("@realsee/five/line"),require("animejs"),require("@realsee/five"),require("hammerjs"),require("three/examples/jsm/loaders/FBXLoader"),require("earcut"),require("@realsee/five/gltf-loader")):typeof define=="function"&&define.amd?define(["exports","three","three/examples/jsm/renderers/CSS3DRenderer","@realsee/five/line","animejs","@realsee/five","hammerjs","three/examples/jsm/loaders/FBXLoader","earcut","@realsee/five/gltf-loader"],N):(ee=typeof globalThis!="undefined"?globalThis:ee||self,N(ee.dnalogel={},ee.THREE,ee.CSS3DRenderer,ee.Line,ee.anime,ee.FiveSDK,ee.Hammer,ee.FBXLoader,ee.earcut,ee.GLTFLoader))})(this,function(ee,N,He,wt,Wi,Xe,vn,An,ui,gs){"use strict";var Cx=Object.defineProperty,Px=Object.defineProperties;var Ix=Object.getOwnPropertyDescriptors;var jr=Object.getOwnPropertySymbols;var Gm=Object.prototype.hasOwnProperty,Qm=Object.prototype.propertyIsEnumerable;var yc=(ee,N,He)=>N in ee?Cx(ee,N,{enumerable:!0,configurable:!0,writable:!0,value:He}):ee[N]=He,x=(ee,N)=>{for(var He in N||(N={}))Gm.call(N,He)&&yc(ee,He,N[He]);if(jr)for(var He of jr(N))Qm.call(N,He)&&yc(ee,He,N[He]);return ee},ne=(ee,N)=>Px(ee,Ix(N));var fs=(ee,N)=>{var He={};for(var wt in ee)Gm.call(ee,wt)&&N.indexOf(wt)<0&&(He[wt]=ee[wt]);if(ee!=null&&jr)for(var wt of jr(ee))N.indexOf(wt)<0&&Qm.call(ee,wt)&&(He[wt]=ee[wt]);return He};var d=(ee,N,He)=>(yc(ee,typeof N!="symbol"?N+"":N,He),He);var H=(ee,N,He)=>new Promise((wt,Wi)=>{var Xe=ui=>{try{An(He.next(ui))}catch(gs){Wi(gs)}},vn=ui=>{try{An(He.throw(ui))}catch(gs){Wi(gs)}},An=ui=>ui.done?wt(ui.value):Promise.resolve(ui.value).then(Xe,vn);An((He=He.apply(ee,N)).next())});function Um(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 y=Um(N);function Ym(){console.debug("%c %c@realsee/dnalogel %cv3.47.2",["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 Xm(){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 wc(){}const Cc=()=>Promise.resolve(),Pc={__queue:Promise.resolve()};function Zm(n=Cc){Pc.__queue=Pc.__queue.then(n).catch(Cc)}function lo(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 zr(n,t,e){const{x:i,y:s}=n,o=i*t,r=s*e;return{x:o,y:r}}function co(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 Jm(n,t,e=wc){new Promise(i=>{setTimeout(()=>{e(),i(!0)},t*n)})}const qm=window,Ic=window.requestAnimationFrame||qm.webkitRequestAnimationFrame||(n=>setTimeout(n,16));function ho(n,t=0){t<=0?Ic(n):Ic(()=>ho(n,t-1))}var Kt=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-Kt.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?Kt.Bounce.In(n*2)*.5:Kt.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}}}}),bn=function(){return performance.now()},Mc=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=bn()),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}(),Hi={Linear:function(n,t){var e=n.length-1,i=e*t,s=Math.floor(i),o=Hi.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=Hi.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=Hi.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=Hi.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}}},Or=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),Vr=new Mc,uo=function(){function n(t,e){e===void 0&&(e=Vr),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=Kt.Linear.None,this._interpolationFunction=Hi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Or.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=bn()),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,v=u.length;g<v;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 A in m)e[r][A]=m[A];s[r]=l?[]:{};var u=i[r];if(!this._isDynamic){var w={};for(var A in u)w[A]=u[A];i[r]=u=w}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=bn()),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=bn()),!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=Vr),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=Kt.Linear.None),this._easingFunction=t,this},n.prototype.interpolation=function(t){return t===void 0&&(t=Hi.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=bn()),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),A=a-m*l,w=Math.min(A/i._duration,1);return w===0&&a===i._duration?1:w},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 v=0,p=this._chainedTweens.length;v<p;v++)this._chainedTweens[v].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}(),Km="23.1.1",$m=Or.nextId,$t=Vr,ep=$t.getAll.bind($t),tp=$t.removeAll.bind($t),ip=$t.add.bind($t),Ec=$t.remove.bind($t),np=$t.update.bind($t),kc={Easing:Kt,Group:Mc,Interpolation:Hi,now:bn,Sequence:Or,nextId:$m,Tween:uo,VERSION:Km,getAll:ep,removeAll:tp,add:ip,remove:Ec,update:np};function sp(n,t,e,i=Kt.Linear.None){const s=new uo(n).to(t,e).easing(i).start();function o(r){s.update(r)&&requestAnimationFrame(o)}return requestAnimationFrame(o),s}var fi=(n=>(n.Drawline="Drawline",n.Undo="Undo",n.Exit="Exit",n))(fi||{});const ms=Symbol("$$PAINT_BRUSH_EVENT$$");function fo(n){return n[ms]||(n[ms]={}),n[ms]}function op(n){n[ms]||delete n[ms]}let rp=class{hasListener(t){const e=fo(this);return e&&e[t]&&e[t].length>0}on(t,e,i){const s=fo(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){op(this);return}const i=fo(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=fo(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 ki(){return((1+Math.random())*65536|0).toString(16).substring(1)}function lt(){return(ki()+ki()+"-"+ki()+"-4"+ki().substr(0,3)+"-"+ki()+"-"+ki()+ki()+ki()).toLowerCase()}const ap=`
|
|
2
2
|
<style type="text/css">
|
|
3
3
|
|
|
4
4
|
#_gl_paintBrush {
|
|
@@ -174,7 +174,7 @@ void main() {
|
|
|
174
174
|
float match = 1.0 - uv.x;
|
|
175
175
|
gl_FragColor = vec4(1.0,1.0,1.0,match);
|
|
176
176
|
}
|
|
177
|
-
`;function Sp(){const n=new y.PlaneGeometry(.4,.4),t=Ep,e=new y.TextureLoader().load(t);e.encoding=y.sRGBEncoding,e.minFilter=y.LinearFilter;const i=new y.MeshBasicMaterial({map:e,transparent:!0,depthTest:!1});return new y.Mesh(n,i)}function Lp(){const n=new y.CurvePath;n.add(new y.LineCurve3(new y.Vector3(0,0,0),new y.Vector3(0,0,.1)));const t=new y.TubeGeometry(n,8,.003),e=new y.ShaderMaterial({vertexShader:xp,fragmentShader:Dp,depthTest:!1,transparent:!0});return new y.Mesh(t,e)}function Tp(){const n=new y.SphereGeometry(.01,20,20),t=new y.MeshBasicMaterial({color:10349931,depthTest:!1,transparent:!0,side:y.DoubleSide}),e=new y.Mesh(n,t);return e.position.set(0,0,.1),e}function jp(){const t=new ch({pointerEvents:"none",cornerPoints:[new y.Vector3(-.2,.2,0),new y.Vector3(-.2,-.2,0),new y.Vector3(.2,-.2,0),new y.Vector3(.2,.2,0)]}),e=document.createElement("div");return e.style.width="100%",e.style.height="100%",e.style.backgroundImage=`url(${Sc})`,e.style.backgroundSize="100%",e.style.backgroundRepeat="no-repeat",t.container.appendChild(e),t}class jc extends y.Object3D{constructor(e){super();d(this,"planeMesh");d(this,"lineMesh");d(this,"ballMesh");d(this,"borderMesh");this.planeMesh=Sp(),this.lineMesh=Lp(),this.ballMesh=Tp(),this.borderMesh=jp(),this.add(this.planeMesh,this.lineMesh,this.ballMesh,this.borderMesh),Tc(e)}updateWithIntersect(e){if(!e.face)return;const i=new y.Vector3().addVectors(e.point,e.face.normal);this.position.copy(e.point),this.lookAt(i)}show(){this.visible=!0,this.borderMesh.parent||this.add(this.borderMesh)}hide(){this.visible=!1,this.remove(this.borderMesh)}dispose(){var e;(e=this.planeMesh.material.map)==null||e.dispose()}}const zp=16777215,zc=16777215,Op=2,yn=.6;class Oc extends wt.Line{constructor(...t){super(...t)}toJSON(){return{type:"FiveLine",points:this.points.toJSON()}}}class Vp extends wt.THREE_Line2{constructor(...t){super(...t)}toJSON(){return{type:"Five_THREE_Line2",geometryAttributes:this.geometry.attributes}}}class Vc extends wt.LineGeometry{constructor(...t){super(...t)}toJSON(){return{type:"FiveLineGeometry",attributes:this.attributes}}}class Bp extends wt.LineMaterial{constructor(...t){super(...t)}toJSON(){return{type:"FiveLineMaterial",color:this.color}}}class St extends N.Object3D{constructor(){super();d(this,"name","IObject3D");d(this,"needsRender")}removeChildren(){for(;this.children.length>0;)this.remove(this.children[0]);return this}add(...e){const i=e.filter(Boolean);return i.length===0?this:super.add(...i)}addIfNotExists(...e){return e.forEach(i=>{this.children.includes(i)||this.add(i)}),this}remove(...e){if(e.length===0)return this;const i=e.filter(Boolean);return super.remove(...i)}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}}function Rp(n,t){const{x:e,y:i,z:s}=t.clone().project(n);return s>1?void 0:{leftPercent:(e+1)/2*100,topPercent:(-i+1)/2*100}}const Bc="LightTagContainer_shgjakdhwakjdhsja";class Nr{constructor(t,e,i){d(this,"container");d(this,"visible",!1);d(this,"enabled",!1);d(this,"wrapper");d(this,"tagWrapper");d(this,"five");d(this,"originPosition");d(this,"transformedPosition");d(this,"disposer");d(this,"config");d(this,"onCameraUpdate",()=>{this.visible!==!1&&this.updateScreenPosition()});d(this,"onFiveEveryReady",()=>{var t;if(this.visible&&this.five.state.mode!=="Panorama"){const e=new y.Raycaster;e.set(this.five.camera.position,this.transformedPosition.clone().sub(this.five.camera.position));const i=(t=Bt(this.five).intersectRaycaster(e))==null?void 0:t[0];(i==null?void 0:i.distance)>this.transformedPosition.distanceTo(this.five.camera.position)?(this.container.style.opacity="1",this.container.style.pointerEvents="auto"):(this.container.style.opacity="0",this.container.style.pointerEvents="none")}});var s;this.five=t,this.originPosition=e?Ge(e).clone():void 0,this.transformedPosition=(s=this.originPosition)==null?void 0:s.clone(),this.container=(()=>{const o=document.createElement("div");return o.style.width="0",o.style.height="0",o.style.position="absolute",o})(),this.config=i!=null?i:{},this.enable(),this.show()}show(){this.visible=!0,this.container.style.opacity="1",this.container.style.pointerEvents="auto",this.container.style.transition="opacity 0.2s linear",this.onCameraUpdate()}hide(t){this.visible=!1,t!=null&&t.withAnimation?this.container.style.transition="opacity 0.2s linear":this.container.style.transition="",this.container.style.opacity="0",this.container.style.pointerEvents="none"}enable(){var i,s,o,r;if(this.enabled)return;this.enabled=!0,this.wrapper=(o=(s=this.config.wrapper)!=null?s:(i=this.five.getElement())==null?void 0:i.parentElement)!=null?o:document.body,this.tagWrapper||(this.tagWrapper=(r=document.getElementById(Bc))!=null?r:(()=>{const a=document.createElement("div");return a.id=Bc,a.style.position="absolute",a.style.top="0",a.style.left="0",a.style.width="100%",a.style.height="100%",a.style.pointerEvents="none",a})(),this.wrapper.contains(this.tagWrapper)||this.wrapper.appendChild(this.tagWrapper)),this.tagWrapper.appendChild(this.container);let t=!1;const e=()=>{t||(t=!0,this.five.ready().then(()=>{this.onFiveEveryReady(),t=!1}))};this.five.on("cameraUpdate",e),this.five.on("cameraUpdate",this.onCameraUpdate),this.disposer=()=>{this.five.off("cameraUpdate",e),this.five.off("cameraUpdate",this.onCameraUpdate)}}disable(){var t;this.enabled&&(this.enabled=!1,this.tagWrapper.removeChild(this.container),(t=this.disposer)==null||t.call(this))}destroy(){this.disable(),this.container.remove()}setTransformMatrix(t){var e;this.transformedPosition=(e=this.originPosition)==null?void 0:e.clone().applyMatrix4(t),this.onCameraUpdate()}setPosition(t){this.transformedPosition=t,this.onCameraUpdate()}updateScreenPosition(){if(!this.transformedPosition){this.container.style.left="-100%",this.container.style.top="-100%";return}const t=Rp(this.five.camera,this.transformedPosition);t?(this.container.style.left=t.leftPercent+"%",this.container.style.top=t.topPercent+"%"):(this.container.style.left="-100%",this.container.style.top="-100%")}}function Fp(n,t,e){return new Nr(n,t,e)}const Np={auto:"",pen:"","pen-forbidden":"","pen-crosshair":"","pne-polygon":"","pen-circle":"","crosshair-rectangle":"","crosshair-circle":""};class _p{constructor(t){d(this,"container");this.container=t}setType(t){const e=Np[t];e?this.container.style.cursor=`url(${e}), auto`:this.container.style.cursor=t}tip(t){return()=>this.closeTip()}closeTip(){}reset(){this.container.style.cursor="auto"}}class Rc extends ut{constructor(e){super();d(this,"five");this.five=e}}const vs=(n,t)=>{if(!t)return n;const e=new y.Vector3,i=new y.Quaternion,s=new y.Vector3;return t.decompose(e,i,s),n.clone().multiply(s).applyQuaternion(i).add(e)},_r=new Map;class Gp extends Rc{constructor(e){super(e);d(this,"_workCode")}get fromType(){var s,o;const e=this.workCode;if(_r.has(e))return _r.get(e);const i=(o=(s=JSON.parse(this.work.raw.works[0]))==null?void 0:s.from_type)!=null?o:"vr";return _r.set(e,i),i}set workCode(e){this._workCode=e}get workCode(){var e;return(e=this._workCode)!=null?e:this.five.state.workCode}get work(){var e,i;return(i=(e=this.five.works)==null?void 0:e.find(s=>s.workCode===this.workCode))!=null?i:this.five.work}get observers(){var e;return(e=this.work)==null?void 0:e.observers}get transform(){var i,s,o,r;const e=(r=(i=this.work)==null?void 0:i.transform)!=null?r:(o=(s=this.work)==null?void 0:s.options)==null?void 0:o.transform;return e?e.clone():new y.Matrix4}getObserverPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.position;if(i)return vs(i,this.transform)}getObserverStandingPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.standingPosition;if(i)return vs(i,this.transform)}getObserver(e){var i;return(i=this.observers)==null?void 0:i[e]}}class Gr extends Rc{constructor(e){super(e);d(this,"workUtil",new Gp(this.five))}get version(){return this.five.constructor.version}get majorVersion(){return Number(this.version.split(".")[0])}get model(){return Bt(this.five)}moveToPano(e,i){const s=this.majorVersion===5?e:{workCode:this.workUtil.workCode,panoIndex:e};return this.five.moveToPano(s,i)}}let Di=class{constructor(t,e){d(this,"VERSION","3.47.1");d(this,"NAME");d(this,"five");d(this,"workUtil");d(this,"fiveUtil");d(this,"hooks",new ut);d(this,"staticPrefix","//vr-image-4.realsee-cdn.cn");this.updateFive(t),e!=null&&e.staticPrefix&&(this.staticPrefix=e.staticPrefix)}set workCode(t){this.workUtil.workCode=t,this.onWorkCodeChange()}get workCode(){return this.workUtil.workCode}updateFive(t){this.five=t,this.fiveUtil=new Gr(t),this.workUtil=this.fiveUtil.workUtil}getCurrentState(){return this.state}absoluteUrl(t){return aa(this.staticPrefix,t)}onWorkCodeChange(){}};function Fc(n,t,e){if(e){const s=new y.Vector3().subVectors(n.position,e).applyQuaternion(n.quaternion.clone().inverse()).applyQuaternion(t).add(e);n.position.copy(s)}n.quaternion.copy(t)}const Qr=new y.Vector3;class Qp extends y.Sphere{expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Qr.subVectors(t,this.center);const e=Qr.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(Qr,s/i),this.radius+=s}return this}}function Wp(n){const{max:t,min:e}=n;return[new y.Vector3(t.x,t.y,t.z),new y.Vector3(e.x,t.y,t.z),new y.Vector3(e.x,e.y,t.z),new y.Vector3(t.x,e.y,t.z),new y.Vector3(t.x,t.y,e.z),new y.Vector3(e.x,t.y,e.z),new y.Vector3(e.x,e.y,e.z),new y.Vector3(t.x,e.y,e.z)]}function gi(n,t){const{max:e,min:i}=n;switch(t){case 0:return new y.Vector3(e.x,e.y,e.z);case 1:return new y.Vector3(i.x,e.y,e.z);case 2:return new y.Vector3(i.x,i.y,e.z);case 3:return new y.Vector3(e.x,i.y,e.z);case 4:return new y.Vector3(e.x,e.y,i.z);case 5:return new y.Vector3(i.x,e.y,i.z);case 6:return new y.Vector3(i.x,i.y,i.z);case 7:return new y.Vector3(e.x,i.y,i.z)}}function wn(n){return Wr(n,"box3")}function Nc(n){return Wr(n,"sphere")}function Hp(n){return Ao(n,"box3")}function _c(n){return Ao(n,"sphere")}function Ao(n,t){const e=t==="box3"?new y.Box3:new Qp,i=new y.Vector3;if(n.updateWorldMatrix(!1,!1),n.traverse(s=>{var r;if(s.name==="shadow"||s.type==="Line2")return;const o=s.geometry;if(s.updateWorldMatrix(!1,!1),o!==void 0){const a=(r=o==null?void 0:o.attributes)==null?void 0:r.position;if(a)for(let l=0,c=a.count;l<c;l++)i.fromBufferAttribute(a,l).applyMatrix4(s.matrixWorld),e.expandByPoint(i);else o.vertices&&o.vertices.forEach(l=>{const c=l.clone().applyMatrix4(s.matrixWorld);e.expandByPoint(c)})}}),!e.isEmpty())return e}function Wr(n,t){const e=Ao(n,t);return e&&e.applyMatrix4(Up(n.matrixWorld.clone())),e}const Up=n=>{const t=n.elements,e=t[0],i=t[1],s=t[2],o=t[3],r=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],f=t[10],g=t[11],v=t[12],p=t[13],m=t[14],A=t[15],w=u*m*c-p*f*c+p*l*g-a*m*g-u*l*A+a*f*A,I=v*f*c-h*m*c-v*l*g+r*m*g+h*l*A-r*f*A,P=h*p*c-v*u*c+v*a*g-r*p*g-h*a*A+r*u*A,k=v*u*l-h*p*l-v*a*f+r*p*f+h*a*m-r*u*m,M=e*w+i*I+s*P+o*k;if(M===0)return n.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/M;return t[0]=w*T,t[1]=(p*f*o-u*m*o-p*s*g+i*m*g+u*s*A-i*f*A)*T,t[2]=(a*m*o-p*l*o+p*s*c-i*m*c-a*s*A+i*l*A)*T,t[3]=(u*l*o-a*f*o-u*s*c+i*f*c+a*s*g-i*l*g)*T,t[4]=I*T,t[5]=(h*m*o-v*f*o+v*s*g-e*m*g-h*s*A+e*f*A)*T,t[6]=(v*l*o-r*m*o-v*s*c+e*m*c+r*s*A-e*l*A)*T,t[7]=(r*f*o-h*l*o+h*s*c-e*f*c-r*s*g+e*l*g)*T,t[8]=P*T,t[9]=(v*u*o-h*p*o-v*i*g+e*p*g+h*i*A-e*u*A)*T,t[10]=(r*p*o-v*a*o+v*i*c-e*p*c-r*i*A+e*a*A)*T,t[11]=(h*a*o-r*u*o-h*i*c+e*u*c+r*i*g-e*a*g)*T,t[12]=k*T,t[13]=(h*p*s-v*u*s+v*i*f-e*p*f-h*i*m+e*u*m)*T,t[14]=(v*a*s-r*p*s-v*i*l+e*p*l+r*i*m-e*a*m)*T,t[15]=(r*u*s-h*a*s+h*i*l-e*u*l-r*i*f+e*a*f)*T,n};class As extends St{constructor(e,i){var s,o;super();d(this,"originObject3D");d(this,"onRender");d(this,"positionFrom");this.originObject3D=e,this.onRender=(s=i==null?void 0:i.onRender)!=null?s:()=>{},this.positionFrom=(o=i==null?void 0:i.positionFrom)!=null?o:"objectPosition"}get helperObject(){return this}render(){this.onRender()}enable(){this.parent.children.includes(this)||this.parent.add(this)}disable(){this.removeFromParent()}show(){this.visible=!0,this.render()}hide(){this.visible=!1,this.render()}raycasterIntersectObject(e,i=[]){return e.intersectObject(this,!0,i)}initialPosition(e){var i,s;this.positionFrom==="objectPosition"?this.position.copy(this.originObject3D.position):this.positionFrom==="boundingBox"?this.position.copy((i=wn(this.originObject3D))==null?void 0:i.getCenter(new y.Vector3)):this.positionFrom==="boundingSphere"?this.position.copy((s=Nc(this.originObject3D))==null?void 0:s.center):this.positionFrom instanceof N.Vector3?this.position.copy(this.positionFrom):this.positionFrom instanceof Function&&this.position.copy(this.positionFrom(this.originObject3D)),e&&this.position.add(e)}setScaleByCamera(e){}initQuaternion(){this.quaternion.copy(this.originObject3D.quaternion)}applyHelperScaleMatrix4(e,i){this.scale.applyMatrix4(e)}setHelperQuaternion(e,i){Fc(this,e,i)}applyHelperQuaternion(e,i){if(i){const s=new N.Vector3().subVectors(this.position,i).applyQuaternion(e).add(i);this.position.copy(s)}this.applyQuaternion(e)}dispose(){this.removeFromParent()}}class Yp extends As{}class Xp extends As{}class Zp extends As{}class Jp extends As{}class qp extends As{}class Kp extends y.Group{constructor(e){super();d(this,"direction");this.direction=e||"x"}}class Gc extends y.Mesh{constructor(e,i,s){super(e,i);d(this,"direction");this.direction=s||"x"}}function $p(n,t){const{offsetWidth:e,offsetHeight:i}=t,{top:s,left:o}=t.getBoundingClientRect();return Object.assign(new y.Vector2,{x:(n.x-o)/e*2-1,y:-(n.y-s)/i*2+1})}function bo(n,t,e){if(!t||!e||!n)return;const i=$p(t,e);if(Math.abs(i.x)===1||Math.abs(i.y)===1)return;const s=new y.Raycaster;return s.setFromCamera(i,n),s}function ev(n,t){return!(Math.abs(n.x-t.x)>1e-5||Math.abs(n.y-t.y)>1e-5||Math.abs(n.z-t.z)>1e-5)}class Hr extends Kp{constructor(e){var h;super(e.direction);d(this,"line");d(this,"arrow");d(this,"lineHeight",.4);d(this,"arrowHeight",.1);this.name="ArrowGroup";const i=new y.Color((h=e.color)!=null?h:16214315),s=new y.MeshBasicMaterial({color:i,depthTest:!1,depthWrite:!1,opacity:1,transparent:!0,side:y.DoubleSide});this.renderOrder=50;const o=new y.ConeGeometry(.04,.1,32),r=new Gc(o,s.clone(),e.direction);r.name=`arrow-${e.direction}`,this.arrow=r;const a=.004,l=new y.CylinderGeometry(a,a,.4,32),c=new Gc(l,s.clone(),e.direction);c.name=`line-${e.direction}`,this.line=c,this.formatArrow(),this.formatLine(),this.add(this.arrow,this.line)}formatArrow(){this.arrow.geometry.translate(0,this.lineHeight+this.arrowHeight/2,0),this.direction==="x"?(this.arrow.geometry.rotateX(Math.PI/2),this.arrow.geometry.rotateY(Math.PI/2)):this.direction==="z"&&this.arrow.geometry.rotateX(Math.PI/2)}formatLine(){this.line.geometry.translate(0,this.lineHeight/2,0),this.direction==="x"?(this.line.geometry.rotateX(Math.PI/2),this.line.geometry.rotateY(Math.PI/2)):this.direction==="z"&&this.line.geometry.rotateX(Math.PI/2)}}const Ur={X:15618642,Y:4765519,Z:4227839};class Cn{static get X(){return new y.Color(Ur.X).convertSRGBToLinear().clone()}static get Y(){return new y.Color(Ur.Y).convertSRGBToLinear().clone()}static get Z(){return new y.Color(Ur.Z).convertSRGBToLinear().clone()}}function Yr(n,t){const s=n.position.distanceTo(t),o=n.fov,r=s/3,a=o/90;return r*a}class tv extends Yp{constructor(e,i){super(e,i);d(this,"xArrow");d(this,"yArrow");d(this,"zArrow");i.xArrowEnable!==!1&&(this.xArrow=new Hr({direction:"x",color:Cn.X})),i.yArrowEnable!==!1&&(this.yArrow=new Hr({direction:"y",color:Cn.Y})),i.zArrowEnable!==!1&&(this.zArrow=new Hr({direction:"z",color:Cn.Z})),this.add(...[this.xArrow,this.yArrow,this.zArrow].filter(Boolean))}show(){super.show(),this.xArrow&&(this.xArrow.visible=!0),this.yArrow&&(this.yArrow.visible=!0),this.zArrow&&(this.zArrow.visible=!0)}setScaleByCamera(e){this.scale.setScalar(Yr(e,this.position))}showDraggingHelper(e){this.xArrow&&(this.xArrow.visible=e.includes("x")),this.yArrow&&(this.yArrow.visible=e.includes("y")),this.zArrow&&(this.zArrow.visible=e.includes("z"))}dispose(){this.remove(...[this.xArrow,this.yArrow,this.zArrow].filter(Boolean)),super.dispose()}}function Yi(n,t){return iv(document.createElement(t!=null?t:"div"),n)}function iv(n,t){if(!t)return n;for(const e in t)e&&t[e]&&(n.style[e]=t[e]);return n}function nv(n){const t=Yi(x({position:"absolute",display:"block",borderRadius:"4px",paddingTop:"1px",paddingBottom:"1px",paddingLeft:"4px",paddingRight:"4px",pointerEvents:"none",userSelect:"none",zIndex:"99999",backgroundColor:"rgba(0,0,0,0.7)",fontSize:"12px",color:"#fff",letterSpacing:"0",lineHeight:"18px"},n)),e=()=>{t.style.display!=="block"&&t.style.top&&t.style.left&&(t.style.display="block")};return{element:t,show:e,hide:()=>{t.style.display="none",t.style.top="",t.style.left=""},setLeftTop:(o,r)=>{t.style.left=o,t.style.top=r,e()}}}class sv extends Zp{constructor(e,i){super(e,i);d(this,"xCircle");d(this,"yCircle");d(this,"zCircle");d(this,"children",[]);d(this,"angleTips");d(this,"container");(i==null?void 0:i.yzCircleEnable)!==!1&&(this.xCircle=new Xr({direction:"x",color:Cn.X})),(i==null?void 0:i.xzCircleEnable)!==!1&&(this.yCircle=new Xr({direction:"y",color:Cn.Y})),(i==null?void 0:i.xyCircleEnable)!==!1&&(this.zCircle=new Xr({direction:"z",color:Cn.Z})),i!=null&&i.container&&(i==null?void 0:i.angleTipsEnable)!==!1&&(this.container=i==null?void 0:i.container,this.angleTips=nv({display:"none"}),this.container.appendChild(this.angleTips.element)),this.add(...[this.xCircle,this.yCircle,this.zCircle].filter(Boolean)),this.show()}hide(){this.children.forEach(e=>e.hide())}show(){var e;this.children.forEach(i=>i.showCircle()),(e=this.angleTips)==null||e.hide()}setScaleByCamera(e){this.scale.setScalar(Yr(e,this.position))}showDraggingHelper(e){var i;this.hide(),this.children.filter(s=>e.includes(s.direction)).forEach(s=>s.showRing()),(i=this.angleTips)==null||i.show()}dispose(){var e,i;this.removeFromParent(),(i=(e=this.angleTips)==null?void 0:e.element)==null||i.remove()}}class Xr extends y.Group{constructor(e){super();d(this,"direction");d(this,"circle");d(this,"ring");d(this,"angleSector");this.direction=e.direction,this.circle=new ov(e),this.ring=new rv(e),this.angleSector=new av(e),this.add(this.circle,this.ring,this.angleSector),this.direction==="y"?this.rotateX(Math.PI/2):this.direction==="x"&&this.rotateY(-Math.PI/2)}showCircle(){this.add(this.circle),this.remove(this.ring,this.angleSector)}showRing(){this.add(this.ring,this.angleSector),this.remove(this.circle)}hide(){this.remove(this.ring,this.angleSector,this.circle)}}let ov=class extends y.Mesh{constructor(e){var i;super();d(this,"direction");d(this,"gapAngle",.02);d(this,"geometry",new y.RingGeometry(.25,.3,20,8,this.gapAngle,Math.PI/2-this.gapAngle*2));this.material=new y.MeshBasicMaterial({opacity:.6,color:(i=e.color)!=null?i:16777215,transparent:!0,side:y.DoubleSide,depthTest:!1,depthWrite:!1}),this.renderOrder=50,this.direction=e.direction,this.geometry.name=`RotateHelperCircleGeometry-${this.direction}`}};class rv extends y.Group{constructor(e){super();d(this,"direction");this.direction=e.direction;const i=.015,s=new Array(8).fill(null).map((o,r)=>{const a=new y.RingGeometry(.25,.3,20,8,Math.PI/4*r+i,Math.PI/4-i*2),l=new y.MeshBasicMaterial({opacity:1,color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide});this.renderOrder=50;const c=new y.Mesh(a,l);return c.name=`AxesDashedRing-${this.direction}-${r}`,c});this.add(...s)}}class av extends y.Mesh{constructor(e){var s;super();d(this,"direction");d(this,"baseAxes");d(this,"angleDirection");switch(e.direction){case"x":this.baseAxes=new y.Vector3(0,0,1);break;case"y":this.baseAxes=new y.Vector3(1,0,0);break;case"z":this.baseAxes=new y.Vector3(1,0,0);break}const i=.3+5e-4;this.geometry=new y.CircleGeometry(i,48,0,1e-4),this.material=new y.MeshBasicMaterial({opacity:.4,color:(s=e.color)!=null?s:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide}),this.renderOrder=50,this.direction=e.direction,this.angleDirection=this.direction==="z"?1:-1}}function lv(){const n=Yi({width:"100%",height:"100%",left:"0",top:"0",position:"absolute",pointerEvents:"none"}),t=Yi({boxSizing:"border-box",width:"100%",height:"100%",left:"0",top:"0",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"}),e=Yi({boxSizing:"border-box",width:"100%",height:"100%",left:"0",top:"0",position:"absolute",border:"1px solid rgba(255,255,255,0.4)"});n.appendChild(t),t.appendChild(e);const i="-4px",s={direction:"nesw",element:Si({cursor:"nesw-resize",left:i,bottom:i})},o={direction:"ns",element:Si({cursor:"ns-resize",bottom:i})},r={direction:"nwse",element:Si({cursor:"nwse-resize",right:i,bottom:i})},a={direction:"ew",element:Si({cursor:"ew-resize",right:i})},l={direction:"nesw",element:Si({cursor:"nesw-resize",right:i,top:i})},c={direction:"ns",element:Si({cursor:"ns-resize",top:i})},h={direction:"nwse",element:Si({cursor:"nwse-resize",left:i,top:i})},u={direction:"ew",element:Si({cursor:"ew-resize",left:i})};return new Array(o,a,c,u,s,r,l,h).forEach(g=>t.appendChild(g.element)),{container:n,squares:[s,o,r,a,l,c,h,u]}}function Si(n){const t=Yi(x({background:"#FFFFFF",width:"9px",height:"9px",position:"absolute",pointerEvents:"none"},n)),e=Yi({width:"15px",height:"15px",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"}),i=Yi({width:"15px",height:"15px",cursor:n==null?void 0:n.cursor,pointerEvents:"auto",background:"transparent"});return i.draggable=!0,e.appendChild(i),t.appendChild(e),t}class cv extends qp{constructor(e,i,s,o){super(e);d(this,"points",[]);d(this,"cornerPositions",[]);d(this,"css3DInstance");d(this,"plane");d(this,"css3DRenderer",new Sn);d(this,"camera");d(this,"scene");d(this,"container");d(this,"enabled",!1);this.camera=s,this.scene=o,this.container=i,this.initRectangleScaleHelper()}get helperObject(){var e;if(!((e=this.css3DInstance)!=null&&e.css3DObject))throw new Error("css3DInstance is not initialized");return this.css3DInstance.css3DObject}applyMatrix4(e){var i;super.applyMatrix4(e),this.helperObject.applyMatrix4(e),(i=this.plane)==null||i.applyMatrix4(e),this.cornerPositions.forEach(s=>s.applyMatrix4(e))}showDraggingHelper(){}applyHelperScaleMatrix4(e,i){var s;(s=this.plane)==null||s.scale.applyMatrix4(e),this.helperObject.applyScaleMatrix4(e)}updatePoints(){const e=this.calculatePointPosition(this.cornerPositions);this.points.forEach((i,s)=>{i.position.copy(e[s])})}applyHelperQuaternion(e,i){var o;const s=(o=this.css3DInstance)==null?void 0:o.css3DObject;if(s){const r=new y.Vector3().subVectors(s.position,i).applyQuaternion(e).add(i);s.position.copy(r),s.applyQuaternion(e)}if(this.plane){const r=new y.Vector3().subVectors(this.plane.position,i).applyQuaternion(e).add(i);this.plane.position.copy(r),this.plane.applyQuaternion(e)}this.cornerPositions.forEach(r=>{const a=new y.Vector3().subVectors(r,i).applyQuaternion(e).add(i);r.copy(a)})}enable(){var e;this.enabled||(this.enabled=!0,(e=this.css3DInstance)==null||e.enable(),this.plane&&this.scene.add(this.plane))}disable(){var e;this.enabled&&(this.enabled=!1,(e=this.css3DInstance)==null||e.disable(),this.plane&&this.scene.remove(this.plane))}show(){var e;(e=this.css3DInstance)==null||e.show(),this.plane&&(this.plane.visible=!0)}hide(){var e;(e=this.css3DInstance)==null||e.hide(),this.plane&&(this.plane.visible=!1)}dispose(){this.disable(),this.css3DRenderer.dispose()}initRectangleScaleHelper(){var a,l;const e=this.getCornerPositions();if(!e)return;this.cornerPositions=e;const i=this.css3DRenderer.create3DElement(this.camera,e,{ratio:.003});if(!i)return;this.css3DInstance=i,i.appendToElement(this.container);const s=i.css3DObject.container,{container:o,squares:r}=lv();this.points=r.map((c,h)=>({direction:c.direction,point:c.element,position:this.calculatePointPosition(e)[h]})),s.insertBefore(o,(a=s.children[0])!=null?a:null),this.helperObject.position.copy(this.originObject3D.position),(l=this.plane)==null||l.position.copy(this.originObject3D.position)}getCornerPositions(){const{originObject3D:e}=this;if(e.isCSS3DObjectPlus)return e.cornerPoints;console.error("当前物体暂时不支持 ScaleHelper")}calculatePointPosition(e){return[e[0].clone(),e[0].clone().add(e[1]).divideScalar(2),e[1].clone(),e[1].clone().add(e[2]).divideScalar(2),e[2].clone(),e[2].clone().add(e[3]).divideScalar(2),e[3].clone(),e[3].clone().add(e[0]).divideScalar(2)]}}class hv extends Xp{constructor(e){super(e);d(this,"box");d(this,"outline");d(this,"originObject");d(this,"positionAttribute");this.originObject=e,this.positionAttribute=new y.BufferAttribute(new Float32Array(8*3),3),this.box=this.createBox(),this.outline=this.createOutline(),this.add(this.box,this.outline),this.update()}raycasterIntersectObject(e,i){return e.intersectObject(this,!1,i)}raycast(e,i){this.box.raycast(e,i)}update(){const e=wn(this.originObject);if(!e)return;const{min:i,max:s}=e;this.positionAttribute.setXYZ(0,s.x,s.y,s.z),this.positionAttribute.setXYZ(1,i.x,s.y,s.z),this.positionAttribute.setXYZ(2,i.x,i.y,s.z),this.positionAttribute.setXYZ(3,s.x,i.y,s.z),this.positionAttribute.setXYZ(4,s.x,s.y,i.z),this.positionAttribute.setXYZ(5,i.x,s.y,i.z),this.positionAttribute.setXYZ(6,i.x,i.y,i.z),this.positionAttribute.setXYZ(7,s.x,i.y,i.z),this.positionAttribute.needsUpdate=!0}createOutline(){const e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new y.BufferGeometry;i.setIndex(new y.BufferAttribute(e,1)),i.setAttribute("position",this.positionAttribute);const s=new y.LineBasicMaterial({color:64767,linewidth:1,opacity:1,toneMapped:!1}),o=new y.LineSegments(i,s);return o.matrixAutoUpdate=!1,o}createBox(){const e=new Uint16Array([0,1,2,0,2,3,0,3,7,0,7,4,0,4,5,0,5,1,6,1,5,6,2,1,6,5,4,6,4,7,6,3,2,6,7,3]),i=new y.BufferGeometry;i.setIndex(new y.BufferAttribute(e,1)),i.setAttribute("position",this.positionAttribute);const s=new y.MeshBasicMaterial({color:64767,opacity:.1,depthTest:!1,transparent:!0});return new y.Mesh(i,s)}}function Re(n,t){this._camera=n||null,this._domElement=t||document,this._raycaster=new y.Raycaster,this._selected=null,this._boundObjs={};var e=this;this._$onClick=function(){e._onClick.apply(e,arguments)},this._$onDblClick=function(){e._onDblClick.apply(e,arguments)},this._$onMouseMove=function(){e._onMouseMove.apply(e,arguments)},this._$onMouseDown=function(){e._onMouseDown.apply(e,arguments)},this._$onMouseUp=function(){e._onMouseUp.apply(e,arguments)},this._$onTouchMove=function(){e._onTouchMove.apply(e,arguments)},this._$onTouchStart=function(){e._onTouchStart.apply(e,arguments)},this._$onTouchEnd=function(){e._onTouchEnd.apply(e,arguments)},this._$onContextmenu=function(){e._onContextmenu.apply(e,arguments)},this._domElement.addEventListener("click",this._$onClick,!1),this._domElement.addEventListener("dblclick",this._$onDblClick,!1),this._domElement.addEventListener("mousemove",this._$onMouseMove,!1),this._domElement.addEventListener("mousedown",this._$onMouseDown,!1),this._domElement.addEventListener("mouseup",this._$onMouseUp,!1),this._domElement.addEventListener("touchmove",this._$onTouchMove,!1),this._domElement.addEventListener("touchstart",this._$onTouchStart,!1),this._domElement.addEventListener("touchend",this._$onTouchEnd,!1),this._domElement.addEventListener("contextmenu",this._$onContextmenu,!1)}Re.prototype.destroy=function(){this._domElement.removeEventListener("click",this._$onClick,!1),this._domElement.removeEventListener("dblclick",this._$onDblClick,!1),this._domElement.removeEventListener("mousemove",this._$onMouseMove,!1),this._domElement.removeEventListener("mousedown",this._$onMouseDown,!1),this._domElement.removeEventListener("mouseup",this._$onMouseUp,!1),this._domElement.removeEventListener("touchmove",this._$onTouchMove,!1),this._domElement.removeEventListener("touchstart",this._$onTouchStart,!1),this._domElement.removeEventListener("touchend",this._$onTouchEnd,!1),this._domElement.removeEventListener("contextmenu",this._$onContextmenu,!1)},Re.eventNames=["click","dblclick","mouseover","mouseout","mousemove","mousedown","mouseup","contextmenu","touchstart","touchend"],Re.prototype._getRelativeMouseXY=function(n){var t=n.target||n.srcElement;t.nodeType===3&&(t=t.parentNode);var e={x:0,y:0},i=t,s=getComputedStyle(i,null);e.y+=parseInt(s.getPropertyValue("padding-top"),10),e.x+=parseInt(s.getPropertyValue("padding-left"),10);do e.x+=i.offsetLeft,e.y+=i.offsetTop,s=getComputedStyle(i,null),e.x+=parseInt(s.getPropertyValue("border-left-width"),10),e.y+=parseInt(s.getPropertyValue("border-top-width"),10);while(i=i.offsetParent);var o={width:t===window?window.innerWidth:t.offsetWidth,height:t===window?window.innerHeight:t.offsetHeight};return{x:Number((n.pageX-e.x)/o.width)*2-1,y:-((n.pageY-e.y)/o.height)*2+1}},Re.prototype._objectCtxInit=function(n){n._3xDomEvent={}},Re.prototype._objectCtxDeinit=function(n){delete n._3xDomEvent},Re.prototype._objectCtxIsInit=function(n){return!!n._3xDomEvent},Re.prototype._objectCtxGet=function(n){return n._3xDomEvent},Re.prototype.camera=function(n){return n&&(this._camera=n),this._camera},Re.prototype.bind=function(n,t,e,i){console.assert(Re.eventNames.indexOf(t)!==-1,"not available events:"+t),this._objectCtxIsInit(n)||this._objectCtxInit(n);var s=this._objectCtxGet(n);s[t+"Handlers"]||(s[t+"Handlers"]=[]),s[t+"Handlers"].push({callback:e,useCapture:i}),this._boundObjs[t]===void 0&&(this._boundObjs[t]=[]),this._boundObjs[t].push(n)},Re.prototype.addEventListener=Re.prototype.bind,Re.prototype.unbind=function(n,t,e,i){console.assert(Re.eventNames.indexOf(t)!==-1,"not available events:"+t),this._objectCtxIsInit(n)||this._objectCtxInit(n);var s=this._objectCtxGet(n);s[t+"Handlers"]||(s[t+"Handlers"]=[]);for(var o=s[t+"Handlers"],r=0;r<o.length;r++){var a=o[r];if(e==a.callback&&i==a.useCapture){o.splice(r,1);break}}var l=this._boundObjs[t].indexOf(n);this._boundObjs[t].splice(l,1)},Re.prototype.removeEventListener=Re.prototype.unbind,Re.prototype._bound=function(n,t){var e=this._objectCtxGet(t);return e?!!e[n+"Handlers"]:!1},Re.prototype._onMove=function(n,t,e,i){var s=this._boundObjs[n];if(!(s===void 0||s.length===0)){var o=new y.Vector2;o.set(t,e),this._raycaster.setFromCamera(o,this._camera);var r=this._raycaster.intersectObjects(s),a=this._selected;if(r.length>0){var l,c,h,u=r[0],f=u.object;this._selected=f,h=this._bound("mousemove",f),a!=f&&(l=this._bound("mouseover",f),c=a&&this._bound("mouseout",a))}else c=a&&this._bound("mouseout",a),this._selected=null;h&&this._notify("mousemove",f,i,u),l&&this._notify("mouseover",f,i,u),c&&this._notify("mouseout",a,i,u)}},Re.prototype._onEvent=function(n,t,e,i){var s=this._boundObjs[n];if(!(s===void 0||s.length===0)){var o=new y.Vector2;o.set(t,e),this._raycaster.setFromCamera(o,this._camera);var r=this._raycaster.intersectObjects(s,!0);if(r.length!==0){for(var a=r[0],l=a.object,c=this._objectCtxGet(l),h=l.parent;typeof c=="undefined"&&h;)c=this._objectCtxGet(h),h=h.parent;c&&this._notify(n,l,i,a)}}},Re.prototype._notify=function(n,t,e,i){var s=this._objectCtxGet(t),o=s?s[n+"Handlers"]:null;if(!s||!o||o.length===0){t.parent&&this._notify(n,t.parent,e,i);return}for(var o=s[n+"Handlers"],r=0;r<o.length;r++){var a=o[r],l=!0;a.callback({type:n,target:t,origDomEvent:e,intersect:i,stopPropagation:function(){l=!1}}),l&&a.useCapture===!1&&t.parent&&this._notify(n,t.parent,e,i)}},Re.prototype._onMouseDown=function(n){return this._onMouseEvent("mousedown",n)},Re.prototype._onMouseUp=function(n){return this._onMouseEvent("mouseup",n)},Re.prototype._onMouseEvent=function(n,t){var e=this._getRelativeMouseXY(t);this._onEvent(n,e.x,e.y,t)},Re.prototype._onMouseMove=function(n){var t=this._getRelativeMouseXY(n);this._onMove("mousemove",t.x,t.y,n),this._onMove("mouseover",t.x,t.y,n),this._onMove("mouseout",t.x,t.y,n)},Re.prototype._onClick=function(n){this._onMouseEvent("click",n)},Re.prototype._onDblClick=function(n){this._onMouseEvent("dblclick",n)},Re.prototype._onContextmenu=function(n){this._onMouseEvent("contextmenu",n)},Re.prototype._onTouchStart=function(n){return this._onTouchEvent("touchstart",n)},Re.prototype._onTouchEnd=function(n){return this._onTouchEvent("touchend",n)},Re.prototype._onTouchMove=function(n){if(n.touches.length==1){var t=Number(n.touches[0].pageX/window.innerWidth)*2-1,e=-(n.touches[0].pageY/window.innerHeight)*2+1;this._onMove("mousemove",t,e,n),this._onMove("mouseover",t,e,n),this._onMove("mouseout",t,e,n)}},Re.prototype._onTouchEvent=function(n,t){var e=t.touches;if(e.length==0&&(e=t.changedTouches),e.length==1){var i=Number(e[0].pageX/window.innerWidth)*2-1,s=-(e[0].pageY/window.innerHeight)*2+1;this._onEvent(n,i,s,t)}};function mi(n){return!ke(n)}function ke(n){return n!=null}function pi(n){return arguments.length===0?[]:Array.isArray(n)?n:[n]}let bs=class{constructor(t,e){d(this,"originObject3D");d(this,"hooks");d(this,"preventTapDefaultEvent",!1);d(this,"internalHooks");d(this,"disposers",[]);d(this,"helperObject3D");d(this,"camera");d(this,"model");d(this,"scene");d(this,"container");d(this,"domEvents");d(this,"isDragging",!1);d(this,"enabled",!1);d(this,"name","BaseController");d(this,"boundingBox");d(this,"config");d(this,"onRender");d(this,"onWantsTapGesture",t=>{if(this.getIntersectObject(t))return!1});d(this,"onWantsUpdateCameraDistance",()=>{if(this.camera.isPerspectiveCamera){const t=this.camera;this.helperObject3D.setScaleByCamera(t)}});d(this,"getBox",()=>this.boundingBox?this.boundingBox:(this.boundingBox=wn(this.originObject3D),this.boundingBox));var h,u,f;this.hooks=(h=t.sharedHooks)!=null?h:new ut,this.internalHooks=(u=t.sharedInternalHooks)!=null?u:new ut,this.camera=t.camera,this.model=t.model,this.originObject3D=t.originObject3D,this.helperObject3D=t.helperObject3D,this.container=t.container,this.scene=t.scene,this.domEvents=new Re(t.camera,t.container),this.onRender=(f=t.onRender)!=null?f:()=>{},this.config=e!=null?e:{},this.initialHelperPosition(),this.initialHelperQuaternion(),this.onWantsUpdateCameraDistance(),this.enable();const i=this.onSetOriginObjectScale.bind(this),s=this.onSetOriginObjectRotate.bind(this),o=this.onSetOriginObjectPosition.bind(this),r=this.onApplyOriginObjectScale.bind(this),a=this.onApplyOriginObjectRotate.bind(this),l=this.onApplyOriginObjectPosition.bind(this),c=this.initialHelperPosition.bind(this);this.internalHooks.on("setObjectPosition",this.onWantsUpdateCameraDistance),this.internalHooks.on("initialHelperPosition",this.onWantsUpdateCameraDistance),this.internalHooks.on("initialHelperPosition",c),this.internalHooks.on("setObjectScale",i),this.internalHooks.on("setObjectRotate",s),this.internalHooks.on("setObjectPosition",o),this.internalHooks.on("applyObjectPosition",l),this.internalHooks.on("applyObjectRotate",a),this.internalHooks.on("applyObjectScale",r),this.disposers.push(()=>{this.internalHooks.off("setObjectPosition",this.onWantsUpdateCameraDistance),this.internalHooks.off("initialHelperPosition",this.onWantsUpdateCameraDistance),this.internalHooks.off("initialHelperPosition",c),this.internalHooks.off("setObjectScale",i),this.internalHooks.off("setObjectRotate",s),this.internalHooks.off("setObjectPosition",o),this.internalHooks.off("applyObjectPosition",l),this.internalHooks.off("applyObjectRotate",a),this.internalHooks.off("applyObjectScale",r)})}initialHelperPosition(){this.helperObject3D.initialPosition(this.calculateOffset(this.config.offset))}initialHelperQuaternion(){var a,l,c;this.helperObject3D.initQuaternion();const t=(a=this.config.xAxis)!=null?a:new y.Vector3(1,0,0),e=(l=this.config.yAxis)!=null?l:new y.Vector3(0,1,0),i=(c=this.config.zAxis)!=null?c:new y.Vector3(0,0,1),s=new y.Quaternion;s.setFromUnitVectors(new y.Vector3(1,0,0),t.normalize());const o=new y.Quaternion;o.setFromUnitVectors(new y.Vector3(0,1,0),e.normalize());const r=new y.Quaternion;r.setFromUnitVectors(new y.Vector3(0,0,1),i.normalize()),this.helperObject3D.quaternion.premultiply(s),this.helperObject3D.quaternion.premultiply(o),this.helperObject3D.quaternion.premultiply(r)}enable(){this.enabled||(this.enabled=!0,this.scene.add(this.helperObject3D),this.helperObject3D.enable(),this.render())}disable(){this.enabled&&(this.enabled=!1,this.helperObject3D.disable(),this.render())}show(){this.helperObject3D.show(),this.render()}hide(){this.helperObject3D.hide(),this.render()}dispose(){var t;(t=this.disposers)==null||t.forEach(e=>e==null?void 0:e()),this.helperObject3D.dispose(),this.render()}applyHelperMatrix4(t){this.helperObject3D.applyMatrix4(t)}applyHelperQuaternion(t,e){this.helperObject3D.applyHelperQuaternion(t,e)}applyHelperScaleMatrix4(t,e){this.helperObject3D.applyHelperScaleMatrix4(t,e)}onWantsGesture(t,e,i){if(this.isDragging)return!1}onIntersectionOnModelUpdate(t){}onApplyOriginObjectScale(t){this.applyHelperScaleMatrix4(t.matrix,t.origin)}onApplyOriginObjectRotate(t){this.applyHelperQuaternion(t.quaternion,t.origin)}onApplyOriginObjectPosition(t){this.applyHelperMatrix4(t.matrix)}onSetOriginObjectScale(t){this.helperObject3D.scale.copy(t),this.updateOffsetByScale(t)}onSetOriginObjectRotate(t,e){this.helperObject3D.setHelperQuaternion(t,e)}onSetOriginObjectPosition(t){this.helperObject3D.position.copy(t.clone().add(this.calculateOffset(this.config.offset)))}render(){this.onRender()}updateOffsetByScale(t){if(this.boundingBox&&this.config.offset){const e=this.originObject3D.position,i=new y.Vector3().subVectors(this.boundingBox.max,e).multiply(t).add(e),s=new y.Vector3().subVectors(this.boundingBox.min,e).multiply(t).add(e),o=this.calculateOffset(this.config.offset,{min:s,max:i});this.helperObject3D.initialPosition(o)}}hoverListener(t,e=16777215,i=1){const s=pi(t).filter(ke),o=[];for(const r of s)if(r.material||r instanceof y.Group){const a=r instanceof y.Group?r.children.filter(f=>f instanceof y.Mesh):[r];a.forEach(f=>{f.__originalColor__=f.material.color.clone(),f.__originalOpacity__=f.material.opacity});const l=()=>{a.forEach(f=>{f.material.color.set(e),f.material.opacity=i}),this.render()},c=()=>{a.forEach(f=>{f.material.color.copy(f.__originalColor__),f.material.opacity=f.__originalOpacity__}),this.render()},h=()=>{this.isDragging||l()},u=()=>{this.isDragging||c()};for(const f of a)this.domEvents.addEventListener(f,"mouseover",h),this.domEvents.addEventListener(f,"mouseout",u),this.hooks.on("moveStart",l),this.hooks.on("moveEnd",c),this.hooks.on("rotateEnd",c),o.push(()=>{this.domEvents.removeEventListener(f,"mouseover",h),this.domEvents.removeEventListener(f,"mouseout",u),this.hooks.off("moveStart",l),this.hooks.off("moveEnd",c),this.hooks.off("rotateEnd",c)})}return()=>o.forEach(r=>r==null?void 0:r())}getIntersectObject(t){const e=this.camera.position,i=this.helperObject3D;if(!i)return;const s=this.helperObject3D.raycasterIntersectObject(t)[0];if(!s)return;const o=s;if(o.object=i,this.model.intersectRaycaster){const r=this.model.intersectRaycaster(t)[0];if(r&&r.point.distanceTo(e)<o.point.distanceTo(e))return}return o.object}calculateOffset(t,e){const i=new y.Vector3(0,0,0);if(!t)return i;const s=()=>e||this.getBox();if(typeof t.x=="number")i.setX(t.x);else if(typeof t.x=="object"){const o=s();i.setX((o.max.x-o.min.x)*t.x.percents)}if(typeof t.y=="number")i.setY(t.y);else if(typeof t.y=="object"){const o=s();i.setY((o.max.y-o.min.y)*t.y.percents)}if(typeof t.z=="number")i.setZ(t.z);else if(typeof t.z=="object"){const o=s();i.setZ((o.max.z-o.min.z)*t.z.percents)}return i}};const dv=new y.Vector3;function Xi(n){var f;const{raycaster:t,line:e,clampToLine:i=!0}=n;if(((f=t.camera)==null?void 0:f.type)==="OrthographicCamera"){const g=t.ray.origin.clone();return e.closestPointToPoint(g,!1,new y.Vector3)}const s=new y.Plane().setFromNormalAndCoplanarPoint(t.ray.direction.clone().normalize(),t.ray.origin),o=s.projectPoint(e.start,new y.Vector3),r=s.projectPoint(e.end,new y.Vector3),a=new y.Line3(o,r),l=a.closestPointToPoint(t.ray.origin,i,dv),c=l.distanceTo(r),h=l.distanceTo(o),u=a.distance();if(c>h&&c>u){const g=-l.distanceTo(o)/u,v=e.start.clone().sub(e.end).normalize();return e.start.sub(v.clone().multiplyScalar(g*e.distance()))}else{const g=l.distanceTo(o)/u;return new y.Vector3().lerpVectors(e.start,e.end,g)}}let uv=class extends bs{constructor(...e){super(...e);d(this,"name","MoveController");d(this,"startInfo");d(this,"_moveByMouse",{enabled:!1});d(this,"mouseInfo");d(this,"mousedownEventListenerDisposer");const i=this.helperObject3D;this.hoverListener([i.xArrow,i.yArrow,i.zArrow]);const s=this.dragStart.bind(this),o=this.dragging.bind(this),r=this.dragEnd.bind(this),a=this.show.bind(this),l=this.hide.bind(this);this.domEvents.addEventListener(this.helperObject3D,"mousedown",s),document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.hooks.on("rotateStart",l),this.hooks.on("rotateEnd",a),this.hooks.on("scaleStart",l),this.hooks.on("scaleEnd",a),this.hooks.on("moveByMouseEnable",l),this.hooks.on("moveByMouseDisable",a),this.disposers.push(()=>{this.domEvents.removeEventListener(this.helperObject3D,"mousedown",s),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.hooks.off("rotateStart",l),this.hooks.off("rotateEnd",a),this.hooks.off("scaleStart",l),this.hooks.off("scaleEnd",a),this.hooks.off("moveByMouseEnable",l),this.hooks.off("moveByMouseDisable",a)}),this.moveByMouseEnable&&this.moveByMouse()}get moveByMouseEnable(){return this._moveByMouse.enabled}dispose(){var e;super.dispose(),(e=this.disposers)==null||e.forEach(i=>i==null?void 0:i())}moveByMouse(e){this._moveByMouse={enabled:!0,useFaceNormal:e==null?void 0:e.useFaceNormal},this.preventTapDefaultEvent=!0;const i=this.handleMouseDown.bind(this),s=this.handleMouseUp.bind(this);this.hooks.emit("moveByMouseEnable"),setTimeout(()=>{this.container.addEventListener("mousedown",i),this.container.addEventListener("mouseup",s)}),this.mousedownEventListenerDisposer=()=>{this.container.removeEventListener("mousedown",i),this.container.removeEventListener("mouseup",s)}}disableMoveByMouse(){var e;this._moveByMouse={enabled:!1},this.preventTapDefaultEvent=!1,this.hooks.emit("moveByMouseDisable"),(e=this.mousedownEventListenerDisposer)==null||e.call(this)}onIntersectionOnModelUpdate(e){var r,a,l;if(!this.moveByMouseEnable)return;const{point:i,face:s}=e;if(!this.hooks.emit("wantToMove",i)){if(this.originObject3D.position.copy(i),(this._moveByMouse.useFaceNormal===!0||typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.enable!==!1)&&s!=null&&s.normal){const c=(()=>typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.alignmentVector?this._moveByMouse.useFaceNormal.alignmentVector:{x:0,y:1,z:0})(),h=new y.Vector3((r=c.x)!=null?r:0,(a=c.y)!=null?a:0,(l=c.z)!=null?l:0),u=(()=>typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.fixedFaceNormal?this._moveByMouse.useFaceNormal.fixedFaceNormal(s.normal):s.normal)();this.originObject3D.quaternion.setFromUnitVectors(h,u),this.internalHooks.emit("setObjectRotate",this.originObject3D.quaternion.clone())}this.internalHooks.emit("setObjectPosition",i),this.hooks.emit("move",i)}}handleMouseDown(e){const{x:i,y:s}=e;this.mouseInfo={x:i,y:s,mouseDownTimestamp:Date.now()}}handleMouseUp(e){if(!this.mouseInfo)return;const{x:i,y:s}=e;this.mouseInfo.x===i&&this.mouseInfo.y===s&&Date.now()-this.mouseInfo.mouseDownTimestamp<500&&(this.disableMoveByMouse(),this.mouseInfo=void 0)}dragStart(e){if(this.moveByMouseEnable||this.isDragging)return;const i=e==null?void 0:e.intersect;if(!i)return this.dragEnd();const s=(i==null?void 0:i.object).direction;if(!s)return this.dragEnd();const o=new y.Vector3(1,0,0).applyQuaternion(this.helperObject3D.quaternion),r=new y.Vector3(0,1,0).applyQuaternion(this.helperObject3D.quaternion),a=new y.Vector3(0,0,1).applyQuaternion(this.helperObject3D.quaternion),l=(()=>{switch(s){case"x":return o;case"y":return r;case"z":return a}})(),c=i.point.clone(),h=new y.Line3(c.clone().sub(l.normalize()),c.clone().add(l.normalize()));this.startInfo={startVectorProject:c,line:h},this.helperObject3D.showDraggingHelper([s]),this.hooks.emit("moveStart"),this.isDragging=!0}dragging(e){if(!this.isDragging||!this.startInfo)return;const i=bo(this.camera,e,this.container);return i?(this.move(i),!1):this.dragEnd()}move(e){if(!this.startInfo)return this.dragEnd();const{line:i,startVectorProject:s}=this.startInfo,o=this.originObject3D,r=Xi({raycaster:e,line:i,clampToLine:!1}),a=r.clone().sub(s),l=new y.Matrix4;l.setPosition(a);const c=o.position.clone().applyMatrix4(l);this.hooks.emit("wantToMove",c)||(o.applyMatrix4(l),s.copy(r),this.internalHooks.emit("applyObjectPosition",{matrix:l}),this.hooks.emit("move",c))}dragEnd(){this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.hooks.emit("moveEnd"))}};class ys{constructor(t,e,i,s,o,r,a){d(this,"helperController");d(this,"five");d(this,"onFiveWantsUpdateCameraDistance",()=>{var t,e;this.helperController&&((e=(t=this.helperController).onWantsUpdateCameraDistance)==null||e.call(t))});d(this,"onFiveWantsTapGesture",t=>{if(!this.helperController)return;if(this.helperController.preventTapDefaultEvent)return!1;const e=this.helperController.onWantsTapGesture(t);return this.five.needsRender=!0,e});d(this,"onFiveWantsGesture",(...t)=>{if(!this.helperController)return;const e=this.helperController.onWantsGesture(...t);return this.five.needsRender=!0,e});d(this,"onFiveIntersectionOnModelUpdate",(...t)=>{this.helperController&&this.helperController.onIntersectionOnModelUpdate(...t)});const{camera:l,model:c,scene:h}=t,u=t.getElement();if(this.five=t,!l||!c||!u||!h)return;const f=()=>{t.needsRender=!0};this.helperController=new e({camera:l,model:c,originObject3D:i,helperObject3D:s,container:u,scene:h,onRender:f,sharedHooks:r,sharedInternalHooks:a},o),t.on("wantsTapGesture",this.onFiveWantsTapGesture),t.on("wantsGesture",this.onFiveWantsGesture),t.on("intersectionOnModelUpdate",this.onFiveIntersectionOnModelUpdate),t.on("cameraFovUpdate",this.onFiveWantsUpdateCameraDistance),t.on("cameraPositionUpdate",this.onFiveWantsUpdateCameraDistance)}dispose(){var t;this.five.off("wantsTapGesture",this.onFiveWantsTapGesture),this.five.off("wantsGesture",this.onFiveWantsGesture),this.five.off("intersectionOnModelUpdate",this.onFiveIntersectionOnModelUpdate),this.five.off("cameraFovUpdate",this.onFiveWantsUpdateCameraDistance),this.five.off("cameraPositionUpdate",this.onFiveWantsUpdateCameraDistance),(t=this.helperController)==null||t.dispose()}}const Zr="Object3DHelper@v1.0.1",fv=()=>{console.error(`${Zr} is disposed`)},gv=()=>{console.warn(`${Zr} is disabled`)},mv=()=>{console.error(`${Zr} is disabled`)};class pv{constructor(t){d(this,"controllers",{});d(this,"state",{visible:!0,enabled:!0,disposed:!1});d(this,"hooks",new ut);d(this,"eventListener",{});t&&this.addControllers(t),this.setState(this.state)}show(t){return H(this,null,function*(){this.setState({visible:!0},t)})}hide(t){return H(this,null,function*(){this.setState({visible:!1},t)})}enable(t){this.setState({enabled:!0},t)}disable(t){this.setState({enabled:!1},t)}dispose(){this.setState({disposed:!0})}setState(t,e){if(this.state.disposed)return fv();if(!this.state.enabled&&t.enabled!==!0&&t.disposed!==!0)return mv();const i=x({},this.state);this.state=x(x({},this.state),t),t.disposed!==void 0&&t.disposed!==i.disposed&&t.disposed&&this.handleDispose(),t.visible!==void 0&&this.handleVisible(t.visible),t.enabled!==void 0&&this.handleEnable(t.enabled),this.hooks.emit("stateChange",{state:this.state,prevState:i})}addControllers(t){this.controllers=x(x({},this.controllers),t),this.setState(this.state)}getCurrentState(){return this.state}handleEnable(t,e=!0){t?(this.everyControllerDo(i=>{i.enable()}),this.hooks.emit("enable",{userAction:e})):(this.everyControllerDo(i=>{i.disable()}),this.hooks.emit("disable",{userAction:e})),this.state.enabled=t}handleVisible(t,e=!0){t?(this.everyControllerDo(i=>{i.show()}),this.actionIfStateIsEnabled(()=>this.hooks.emit("show",{userAction:e}))):(this.everyControllerDo(i=>{i.hide()}),this.actionIfStateIsEnabled(()=>this.hooks.emit("hide",{userAction:e}))),this.state.visible=t}everyControllerDo(t){Object.values(this.controllers).forEach(e=>{e&&t(e)})}handleDispose(){var t,e;Object.values(this.controllers).forEach(i=>{i==null||i.dispose()});for(const i in this.controllers){if(!i)continue;const s=i;(e=(t=this.eventListener)[s])==null||e.call(t)}}actionIfStateIsEnabled(t,e){if(this.state.enabled)return t();e!=null&&e.warnLog&&gv()}}function Jr(n){return n*180/Math.PI}function qr(n){return n*Math.PI/180}const Kr=new y.Quaternion;class vv extends bs{constructor(...e){var c,h,u;super(...e);d(this,"name","RotateController");d(this,"startInfo");d(this,"removeListener");const i=this.helperObject3D;this.hoverListener([(c=i.xCircle)==null?void 0:c.circle,(h=i.yCircle)==null?void 0:h.circle,(u=i.zCircle)==null?void 0:u.circle].filter(Boolean));const s=this.dragStart.bind(this),o=this.dragging.bind(this),r=this.dragEnd.bind(this),a=this.show.bind(this),l=this.hide.bind(this);this.domEvents.addEventListener(this.helperObject3D,"mousedown",s),document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.hooks.on("moveStart",l),this.hooks.on("moveEnd",a),this.hooks.on("scaleStart",l),this.hooks.on("scaleEnd",a),this.hooks.on("moveByMouseEnable",l),this.hooks.on("moveByMouseDisable",a),this.removeListener=()=>{this.domEvents.removeEventListener(this.helperObject3D,"mousedown",s),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.hooks.off("moveStart",l),this.hooks.off("moveEnd",a),this.hooks.off("scaleStart",l),this.hooks.off("scaleEnd",a),this.hooks.off("moveByMouseEnable",l),this.hooks.off("moveByMouseDisable",a)}}get rotateCenter(){return this.helperObject3D.position.clone()}setRotateAngle(e){const{x:i=0,y:s=0,z:o=0}=e,r=new y.Euler(qr(i),qr(s),qr(o)),a=new y.Quaternion().setFromEuler(r);if(this.hooks.emit("wantToRotate",a))return;const{originObject3D:c,rotateCenter:h}=this;Fc(c,a,h),this.internalHooks.emit("setObjectRotate",a,h),this.hooks.emit("rotate",a),this.render()}dispose(){this.removeListener(),super.dispose()}onApplyOriginObjectRotate(e){this.isDragging||super.onApplyOriginObjectRotate(e)}onApplyOriginObjectScale(e){}dragStart(e){if(this.isDragging)return;const i=e==null?void 0:e.intersect;if(!i)return this.dragEnd();const s=(i==null?void 0:i.object).direction;if(!s)return this.dragEnd();const o=i.point,r=this.getAngleHelper(s);this.setTipsAngle(0);const a=o.clone();a.y+=.2,this.setTipsPosition(a);const l=this.helperObject3D.quaternion.clone(),c=(()=>{if(s==="x")return new y.Vector3(1,0,0).applyQuaternion(l);if(s==="y")return new y.Vector3(0,1,0).applyQuaternion(l);if(s==="z")return new y.Vector3(0,0,1).applyQuaternion(l)})(),h=new y.Plane().setFromNormalAndCoplanarPoint(c,o),f=h.projectPoint(o.clone(),new y.Vector3).clone().sub(this.rotateCenter),g=f.angleTo(r.baseAxes.clone().applyQuaternion(l));this.setAngleHelperStart(s,g),this.setAngleHelperLength(s,0),this.startInfo={direction:s,startVector:f,plane:h,angleHelper:r,angle:0,helperQuaternion:l.clone()},Kr.copy(l),this.helperObject3D.showDraggingHelper([s]),this.hooks.emit("rotateStart"),this.isDragging=!0}dragging(e){if(!this.isDragging)return;const i=bo(this.camera,e,this.container);return i?(this.rotate(i),!1):this.dragEnd()}rotate(e){if(!this.startInfo)return this.dragEnd();const{startVector:i,plane:s,angleHelper:o,direction:r,helperQuaternion:a}=this.startInfo,{originObject3D:l}=this,c=e.ray.intersectPlane(s,new y.Vector3);if(!c)return;const h=this.rotateCenter.clone(),f=s.projectPoint(c.clone(),new y.Vector3).clone().sub(h);if(i.angleTo(f)===0)return;const g=new y.Quaternion().setFromUnitVectors(i.clone().normalize(),f.clone().normalize()),v=l.quaternion.clone().premultiply(g);if(this.hooks.emit("wantToRotate",v))return;const A=new y.Euler().setFromQuaternion(new y.Quaternion().setFromUnitVectors(i.clone().normalize().applyQuaternion(a.clone().inverse()),f.clone().normalize().applyQuaternion(a.clone().inverse())),`${r.toUpperCase()}${"XZY".replace(r.toUpperCase(),"")}`)[r]*o.angleDirection;if(this.startInfo.angle+=A,this.setAngleHelperLength(r,this.startInfo.angle),this.setTipsAngle(Jr(this.startInfo.angle)),h){const w=new y.Vector3().subVectors(l.position,h).applyQuaternion(g).add(h);l.position.copy(w)}l.applyQuaternion(g),Kr.premultiply(g),this.internalHooks.emit("applyObjectRotate",{quaternion:g,origin:h}),this.hooks.emit("rotate",l.quaternion),this.startInfo.startVector=f}dragEnd(){this.isDragging&&(this.internalHooks.emit("setObjectRotate",Kr,this.rotateCenter),this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.hooks.emit("rotateEnd"))}getAngleHelper(e){var i,s,o;switch(e){case"x":return(i=this.helperObject3D.xCircle)==null?void 0:i.angleSector;case"y":return(s=this.helperObject3D.yCircle)==null?void 0:s.angleSector;case"z":return(o=this.helperObject3D.zCircle)==null?void 0:o.angleSector}}setAngleHelperStart(e,i){const s=this.getAngleHelper(e);if(!s){console.warn("angleHelper is undefined");return}if(s instanceof y.Mesh&&s.geometry instanceof y.CircleGeometry){const{radius:o,segments:r,thetaLength:a}=s.geometry.parameters;s.geometry=new y.CircleGeometry(o,r,i,a)}else console.warn("only support THREE.CircleGeometry")}setAngleHelperLength(e,i){const o=i>=0?Math.max(i,.001):Math.min(i,-.001),r=this.getAngleHelper(e);if(r instanceof y.Mesh&&r.geometry instanceof y.CircleGeometry){const{radius:a,thetaStart:l}=r.geometry.parameters,c=Math.ceil(Math.abs(o)*(40/(2*Math.PI)));r.geometry=new y.CircleGeometry(a,c,l,o)}else console.warn("only support THREE.CircleGeometry")}setTipsAngle(e){var s;const i=(s=this.helperObject3D.angleTips)==null?void 0:s.element;i&&(i.innerText=`${e.toFixed(0)}°`)}setTipsPosition(e){const i=this.helperObject3D.angleTips;if(!i)return;const s=e.project(this.camera),{x:o,y:r,z:a}=s;if(a>1)return;const l=(o+1)/2*100+"%",c=(-r+1)/2*100+"%";i.setLeftTop(l,c)}}class Av extends bs{constructor(...e){super(...e);d(this,"startInfo");d(this,"name","RectangleScaleController")}enable(){this.helperObject3D.enable(),super.enable()}disable(){this.helperObject3D.disable(),super.disable()}show(){this.helperObject3D.show(),super.show()}hide(){this.helperObject3D.hide(),super.hide()}onApplyOriginObjectPosition(e){this.isDragging||super.onApplyOriginObjectPosition(e)}onApplyOriginObjectScale(e){this.helperObject3D.applyHelperScaleMatrix4(e.matrix,e.origin)}getDragPlane(){const e=new y.Plane,i=this.helperObject3D.cornerPositions;if(i.length!==0)return i.length<3?e.setFromNormalAndCoplanarPoint(this.originObject3D.getWorldDirection(new N.Vector3),i[0]):e.setFromCoplanarPoints(i[0],i[1],i[2]),e}dragStart(e,i){var o,r;(r=(o=this.helperObject3D).updatePoints)==null||r.call(o);const s=this.getDragPlane();if(!s)return this.dragEnd();this.startInfo={startPoint:{position:i.position.clone(),direction:i.direction},plane:s},this.hooks.emit("scaleStart"),this.render(),this.isDragging=!0}dragging(e){if(!this.isDragging)return;const i=bo(this.camera,e,this.container);if(!i)return this.dragEnd();this.scale(i)}scale(e){var Y,G;if(!this.startInfo)return;const i=this.originObject3D,{startPoint:s,plane:o}=this.startInfo,r=this.helperObject3D.cornerPositions;if(r.length<4)return this.dragEnd();const a=e.ray.intersectPlane(o,new N.Vector3);if(!a||ev(a,this.camera.position))return;const l=new N.Vector3().addVectors(r[0],r[2]).divideScalar(2),{position:c,direction:h}=s,u=new N.Vector3().subVectors(r[1],r[0]),f=new N.Vector3().subVectors(r[3],r[0]),g=Q=>{const W=new N.Vector3(0,0,0);if(!this.startInfo)return W;const _=(Q==="ew"?u:f).clone(),U=c.clone().projectOnVector(_),F=a.clone().projectOnVector(_),X=l.clone().projectOnVector(_);if(F.equals(U))return W;if(Q==="ns"&&typeof this.startInfo.dragPointInCenterBottom!="boolean"){const le=new N.Vector3().subVectors(F,X),ae=le.x<0&&_.x>=0,Ie=le.y<0&&_.y>=0,Ae=le.z<0&&_.z>=0;this.startInfo.dragPointInCenterBottom=ae||Ie||Ae}if(Q==="ew"&&typeof this.startInfo.dragPointInCenterLeft!="boolean"){const le=new N.Vector3().subVectors(F,X),ae=le.x<0&&_.x>=0,Ie=le.y<0&&_.y>=0,Ae=le.z<0&&_.z>=0;this.startInfo.dragPointInCenterLeft=ae||Ie||Ae}const J=new N.Vector3().subVectors(F,U),q=J.length();return q>.3?(console.warn("offset.length() > 0.3, skipped",q),W):J},v=g("ew"),p=g("ns"),m=()=>{const Q=v;this.helperObject3D.cornerPositions.forEach((W,_)=>{var U;(U=this.startInfo)!=null&&U.dragPointInCenterLeft?(_===0||_===3)&&W.add(Q):(_===1||_===2)&&W.add(Q)})},A=()=>{const Q=p;this.helperObject3D.cornerPositions.forEach((W,_)=>{var U;(U=this.startInfo)!=null&&U.dragPointInCenterBottom?(_===0||_===1)&&W.add(Q):(_===2||_===3)&&W.add(Q)})};switch(h){case"ew":m();break;case"ns":A();break;case"nesw":case"nwse":m(),A()}const w=new N.Vector3().subVectors(r[1],r[0]).length()/u.length(),I=new N.Vector3().subVectors(r[3],r[0]).length()/f.length(),P=new N.Vector3(w,I,1),k=new y.Matrix4().scale(P);i.isCSS3DObjectPlus?i.applyScaleMatrix4(k):i.scale.applyMatrix4(k),s.position.copy(a);const M=new N.Vector3().addVectors(r[0],r[2]).divideScalar(2),T=new N.Vector3().subVectors(M,l),R=new y.Matrix4().setPosition(T);i.applyMatrix4(R),(Y=this.helperObject3D.css3DInstance)==null||Y.css3DObject.applyMatrix4(R),(G=this.helperObject3D.plane)==null||G.applyMatrix4(R),this.internalHooks.emit("applyObjectScale",{matrix:k}),this.internalHooks.emit("applyObjectPosition",{matrix:R}),this.render()}dragEnd(){this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.hooks.emit("scaleEnd"),this.render())}}class bv extends Av{constructor(...e){super(...e);d(this,"name","CSS3DScaleController");this.addHTMLEventListener()}addHTMLEventListener(){this.helperObject3D.points.forEach(e=>{if(!e)return;const i=e.point,s=a=>this.dragStart(a,e),o=this.dragging.bind(this),r=this.dragEnd.bind(this);i.addEventListener("dragstart",s),i.addEventListener("drag",o),i.addEventListener("dragend",r)})}}const Qt=document.createElement("div");Qt.classList.add("behindFiveElement"),Qt.style.position="absolute",Qt.style.top="0",Qt.style.left="0",Qt.style.width="100%",Qt.style.height="100%",Qt.style.pointerEvents="none";function Qc(n){var i,s,o,r,a;const t=(a=(s=$r(n.getElement()))!=null?s:$r((i=n.getElement())==null?void 0:i.parentElement))!=null?a:$r((r=(o=n.getElement())==null?void 0:o.parentElement)==null?void 0:r.parentElement),e=t==null?void 0:t.parentElement;if(e)return e.contains(Qt)||t.parentElement.insertBefore(Qt,t),Qt;console.error("Can not find a valid element to insert behindFiveElement. How to fix it: https://github.com/realsee-developer/dnalogel/tree/main/plugins/src/CSS3DRenderPlugin/README.md")}function $r(n){var a;if(!n)return;const t=(a=n.style.position)!=null?a:getComputedStyle(n).position;if(t!=="fixed"&&t!=="absolute"&&t!=="relative")return;const e=getComputedStyle(n),i=e.backgroundColor,s=e.backgroundImage;if(!(i!=="transparent"&&i!=="rgba(0, 0, 0, 0)"&&i!==""||s!=="none"&&s!==""))return n}class yv extends bs{constructor(...e){super(...e);d(this,"name","BoundingBoxController")}}class wv extends Jp{constructor(e,i){super(e,i);d(this,"scaleMeshes",[]);d(this,"positions",[]);i&&(this.positions=i.positions)}initialPosition(e){this.position.copy(this.originObject3D.position),this.scaleMeshes.length&&this.remove(...this.scaleMeshes);const i=typeof this.positions=="function"?this.positions():this.positions;i&&(this.scaleMeshes=i.map(s=>{const o=Cv();return o.position.copy(s.handlePosition),o.scalePosition=s,o}),this.add(...this.scaleMeshes))}setScaleByCamera(e){this.scaleMeshes.forEach(i=>{i.scale.setScalar(Yr(e,i.scalePosition.handlePosition.clone().applyMatrix4(this.matrixWorld)))})}}function Cv(){const t=new y.BoxGeometry(.05,.05,.05),e=new y.MeshBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide}),i=new y.Mesh(t,e);return i.renderOrder=10,i}class Pv extends bs{constructor(...e){super(...e);d(this,"name","ScaleController");d(this,"startInfo");d(this,"dragStart",e=>{if(this.isDragging)return;this.isDragging=!0;const{intersect:i}=e,s=this.camera.position,o=i.object,r=o.scalePosition.basePosition.clone(),l=o.scalePosition.handlePosition.clone().clone().sub(r).clone(),c=new y.Line3(r,r.clone().add(l.normalize().multiplyScalar(5)));c.applyMatrix4(this.helperObject3D.matrixWorld);const h=new y.Raycaster(s,i.point.clone().sub(s)),u=Xi({raycaster:h,line:c});this.startInfo={line:c,scaleStartPoint:u,draggingObject:o},this.hooks.emit("scaleStart")});d(this,"dragging",e=>{if(!this.isDragging||!this.startInfo)return;const i=bo(this.camera,e,this.container);return i?(this.scale(i),!1):this.dragEnd()});d(this,"scale",e=>{var c,h;if(!this.startInfo)return;const{line:i,scaleStartPoint:s,draggingObject:o}=this.startInfo,{scalePosition:r}=o,{basePosition:a}=r,l=Xi({raycaster:e,line:i});l.applyMatrix4(new y.Matrix4().getInverse(this.helperObject3D.matrixWorld.clone())),(h=(c=this.config)==null?void 0:c.scaleCallback)==null||h.call(c,{ratio:l.distanceTo(a)/s.distanceTo(a),intersectPoint:l,scalePosition:r}),o.position.copy(l.clone())});d(this,"dragEnd",()=>{this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.internalHooks.emit("initialHelperPosition"),this.hooks.emit("scaleEnd"))});this.domEvents.addEventListener(this.helperObject3D,"mousedown",this.dragStart),document.addEventListener("mousemove",this.dragging),document.addEventListener("mouseup",this.dragEnd)}initialHelperQuaternion(){this.helperObject3D.initQuaternion()}initialHelperPosition(){this.helperObject3D.initialPosition();const e=this;e.offHoverListener&&e.offHoverListener(),e.offHoverListener=this.hoverListener(this.helperObject3D.scaleMeshes)}setScale(e){var l,c,h;let i=1,s=1,o=1;typeof e=="number"?(i=e,s=e,o=e):typeof e=="object"&&(i=(l=e.x)!=null?l:1,s=(c=e.y)!=null?c:1,o=(h=e.z)!=null?h:1);const r=new y.Vector3(i,s,o);this.hooks.emit("wantToScale",r)||(this.originObject3D.scale.copy(r),this.internalHooks.emit("setObjectScale",r),this.hooks.emit("scale",r),this.render())}}function Pn(n){return H(this,null,function*(){return new Promise(t=>{if(Iv(n))t();else{const e=i=>{const s=Bt(n);i===s&&(n.off("modelLoaded",e),t())};n.on("modelLoaded",e)}})})}function Iv(n){var t;return(t=Bt(n))==null?void 0:t.loaded}const ea="Object3DHelperPlugin",yo=ea,Mv=()=>{console.error(`${yo} is disposed`)},Ev=()=>{console.warn(`${yo} is disabled`)},kv=()=>{console.error(`${yo} is disabled`)};class ta extends Di{constructor(e){super(e);d(this,"name",ea);d(this,"state",{visible:!0,enabled:!0,disposed:!1});d(this,"objectHelperMap",new Map);d(this,"css3DObjectParentMap",new Map);d(this,"css3DRender");this.five=e,this.css3DRender=new Sn(this.five.scene),console.warn("Object3DHelper: 使用此插件,需要在初始化five时,设置five参数: { backgroundAlpha: 0, backgroundColor: 0x000000 }"),Object.assign(window,{[`__${ea.toUpperCase()}_DEBUG__`]:this})}show(e){return H(this,null,function*(){this.setState({visible:!0},e)})}hide(e){return H(this,null,function*(){this.setState({visible:!1},e)})}enable(e){this.setState({enabled:!0},e)}disable(e){this.setState({enabled:!1},e)}dispose(){this.setState({disposed:!0})}setState(e,i){if(this.state.disposed)return Mv();if(!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return kv();const s=x({},this.state);this.state=x(x({},this.state),e),e.disposed!==void 0&&e.disposed!==s.disposed&&e.disposed&&this.handleDispose(),e.visible!==void 0&&e.visible!==s.visible&&this.handleVisible(e.visible),e.enabled!==void 0&&e.enabled!==s.enabled&&this.handleEnable(e.enabled),this.hooks.emit("stateChange",{state:this.state,prevState:s})}getObject3DHelper(e){return this.objectHelperMap.get(e)}addObject3DHelper(e,i={}){var A;if(!e){console.error("Object3D is undefined");return}if(this.objectHelperMap.has(e)){console.warn(`Object3DHelperPlugin: object3D ${e.name} is already has helper`);return}const s=new pv,o=[],r=(A=this.five.getElement())==null?void 0:A.parentElement,a=this.five.camera,c=x(x({},{moveHelper:!0,rotateHelper:!0,scaleHelper:!0,boundingBoxHelper:!1,positionFrom:"objectPosition"}),i),{moveHelper:h,rotateHelper:u,scaleHelper:f,boundingBoxHelper:g}=c,v=new ut,p=new ut,m=w=>{if(w)return typeof w=="boolean"?w:w.enable};if(m(h)){const w=x(x({},this.getConfig(c.moveHelper)),c),I=new tv(e,x({},w)),P=new ys(this.five,uv,e,I,w,v,p);s.addControllers({moveController:P.helperController}),o.push(()=>P.dispose())}if(m(u)){const w=x(x({},this.getConfig(c.rotateHelper)),c),I=new sv(e,x({container:r},w)),P=new ys(this.five,vv,e,I,w,v,p);s.addControllers({rotateController:P.helperController}),o.push(()=>P.dispose())}if(m(g)){const w=new hv(e),I=new ys(this.five,yv,e,w,void 0,v,p);s.addControllers({boundingBoxController:I.helperController})}if(m(f))if(e.isCSS3DObjectPlus&&r){const w=new cv(e,r,a,this.five.scene),I=new ys(this.five,bv,e,w,void 0,v,p);s.addControllers({scaleController:I.helperController}),o.push(()=>I.dispose()),Pn(this.five).then(()=>{var P,k;if(e.isCSS3DObjectPlus){const M=e;if(!M||M.mode!=="front")return;const T=(P=this.css3DRender.behindModeCSS3DRenderer.wrapper)!=null?P:Qc(this.five);T&&(this.css3DObjectParentMap.set(M,M.parent),M.removeFromParent(),this.css3DRender.behindModeCSS3DRenderer.setWrapper(T),(k=this.css3DRender.getBehindCSS3DObjectGroup())==null||k.add(M),this.css3DRender.render(this.five.camera))}})}else{const w=x(x({},this.getConfig(c.scaleHelper)),c),I=new wv(e,w),P=new ys(this.five,Pv,e,I,w,v,p);s.addControllers({scaleController:P.helperController}),o.push(()=>P.dispose())}return this.objectHelperMap.set(e,{helper:s,disposers:o}),s.controllers}removeObject3DHelper(e){if(!this.objectHelperMap.has(e))return;const{helper:i,disposers:s}=this.objectHelperMap.get(e);if(i){if(e.isCSS3DObjectPlus){const o=e,r=this.css3DObjectParentMap.get(o);r&&r.add(o),this.css3DRender.render(this.five.camera)}this.objectHelperMap.delete(e),i.dispose(),s==null||s.forEach(o=>o==null?void 0:o())}}handleEnable(e,i=!0){e?(this.everyHelperDo(s=>s.enable()),this.hooks.emit("enable",{userAction:i})):(this.everyHelperDo(s=>s.disable()),this.hooks.emit("disable",{userAction:i})),this.state.enabled=e}handleVisible(e,i=!0){e?(this.everyHelperDo(s=>s.show()),this.actionIfStateIsEnabled(()=>this.hooks.emit("show",{userAction:i}))):(this.everyHelperDo(s=>s.hide()),this.actionIfStateIsEnabled(()=>this.hooks.emit("hide",{userAction:i}))),this.state.visible=e}handleDispose(){this.everyHelperDo((e,i)=>{e.dispose(),i==null||i.forEach(s=>s==null?void 0:s())})}everyHelperDo(e){this.objectHelperMap.forEach(({helper:i,disposers:s})=>{i&&e(i,s)})}actionIfStateIsEnabled(e,i){if(this.state.enabled)return e();i!=null&&i.warnLog&&Ev()}getConfig(e){if(e&&typeof e!="boolean"&&e.enable)return e}}const xv=n=>new ta(n);function Wc(n,t){const{top:e,left:i,width:s,height:o}=t.getBoundingClientRect();return new y.Vector2((n.x-i)/s*2-1,-(n.y-e)/o*2+1)}class Hc extends y.Raycaster{intersectObject(t,e=!0,i=[]){return ia(t,this,i,e),i.sort(Uc),i}intersectObjects(t,e=!0,i=[]){for(let s=0,o=t.length;s<o;s++)ia(t[s],this,i,e);return i.sort(Uc),i}}function Uc(n,t){return n.distance-t.distance}function ia(n,t,e,i){let s=!0;if(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0){const o=n.children;for(let r=0,a=o.length;r<a;r++)ia(o[r],t,e,!0)}}function na(n,t,e,i){let s=!0;if(n.type!=="Line2"&&(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0)){const o=n.children;for(let r=0,a=o.length;r<a;r++)o[r].type!=="Line2"&&na(o[r],t,e,!0)}}class sa{constructor(t,e){d(this,"five");d(this,"dragging",!1);d(this,"boundObject",{});d(this,"config");d(this,"lastMouseDownEvent");d(this,"handleWantsGesture",(t,e)=>{if(e.length!==1)return;const i=e[0];if(i.raycaster){const s=new Hc;s.ray=i.raycaster.ray,s.near=i.raycaster.near,s.far=i.raycaster.far,s.camera=i.raycaster.camera,s.layers=i.raycaster.layers,s.params=i.raycaster.params,i.raycaster=s}if(i){if(t==="mouseMove"&&this.onDomEvent("hover",i),t==="tap"){const s=this.lastMouseDownEvent,o=this.onDomEvent("click",i,s),r=this.onDomEvent("wantDblclick",i,s,this.boundObject.dblclick);if(o===!1||r===!1)return!1}if(this.dragging)return!1}});d(this,"handleDomEvent",(t,e,i)=>{const s={x:e.clientX,y:e.clientY};this.onDomEvent(t,s,e,i)});d(this,"handleMouseEvent",t=>{this.handleDomEvent(t.type,t)});d(this,"handleMousedown",t=>{this.lastMouseDownEvent=t,this.handleDomEvent("mousedown",t),this.handleDomEvent("dragstart",t,this.haveDragEventObject)});d(this,"handleMouseup",t=>{var e;this.dragging=!1,(e=this.haveDragEventObject)==null||e.forEach(i=>{i._dragging&&(i._dragging=!1,this.notify({eventName:"dragend",object:i,originEvent:t,raycaster:this.getRaycaster({x:t.clientX,y:t.clientY})}))}),this.handleDomEvent("mouseup",t)});d(this,"handleMousemove",t=>{var e;this.dragging&&((e=this.boundObject.drag)==null||e.forEach(i=>{i._dragging&&this.notify({eventName:"drag",object:i,originEvent:t,raycaster:this.getRaycaster({x:t.clientX,y:t.clientY})})}))});d(this,"onDomEvent",(t,e,i,s=this.boundObject[t])=>{var f,g,v,p,m;if(!e||!s||(s==null?void 0:s.length)===0)return;const o=[];((f=this.config)==null?void 0:f.fiveModels)!==null&&((g=this.config)!=null&&g.fiveModels?o.push(...this.config.fiveModels):o.push(this.model));const r=o.filter(A=>A.loaded),a=(v=e.raycaster)!=null?v:this.getRaycaster(e);a.params.Points.threshold=.02;const l=a.intersectObjects(s,!0),c=[];r.forEach(A=>{const w=A.intersectRaycaster(a);c.push(...w)});const h=.01;if(c.length>0&&l.length>0&&c[0].distance+h<l[0].distance)return;const u=(p=l==null?void 0:l[0])==null?void 0:p.object;if(t==="wantDblclick")return!1;if((!u||!this.objectIsBound(u))&&t==="hover")for(const A of(m=this.boundObject.hover)!=null?m:[])A._hovered&&this.notify({eventName:"unHover",object:A});if(u&&u&&this.notify({eventName:t,object:u,originEvent:i,raycaster:a,intersects:l}))return!1});d(this,"objectIsBound",t=>{let e=t._domEvent,i=t.parent;for(;typeof e=="undefined"&&i;)e=i._domEvent,i=i.parent;return!!e});d(this,"notify",t=>{var f,g,v;const{eventName:e,object:i,originEvent:s,raycaster:o,intersects:r}=t;let a=!1,l=[];const c=[];let h=i;for(c.push(h);h.parent;)h=h.parent,c.push(h);const u=c.at(-1);if(!((f=this.config)!=null&&f.noEmitWhenNotInScene&&u.type!=="Scene")){for(const p of c){if(a)break;p.draggable&&(e==="dragstart"&&(p._dragging=!0,this.dragging=!0),e==="dragend"&&(p._dragging=!1,this.dragging=!1));const m=p._domEvent;if(!m)continue;const A=m[`${e}Handler`];if(A)for(const[w,I]of A){if(I!=null&&I.noEmitWhenNotInScene&&u.type!=="Scene"||((g=this.config)!=null&&g.noEmitWhenHide||I!=null&&I.noEmitWhenHide)&&!Rr(p))continue;if(e==="hover"){if(p._hovered)continue;p._hovered=!0;for(const k of(v=this.boundObject.hover)!=null?v:[])k!==p&&k._hovered&&this.notify({eventName:"unHover",object:k})}if(e==="unHover"){if(!p._hovered)continue;p._hovered=!1}const P=w({type:e,target:p,origDomEvent:s,raycaster:o,intersects:r,stopPropagation:()=>{a=!0}});l.push(P!=null?P:!0)}}if(e==="click"||e==="wantDblclick")return l.some(p=>p===!0)}});this.five=t,this.config=e,t.on("wantsGesture",this.handleWantsGesture),document.addEventListener("mousedown",this.handleMousedown),document.addEventListener("dblclick",this.handleMouseEvent),document.addEventListener("mouseup",this.handleMouseup),document.addEventListener("mousemove",this.handleMousemove)}get haveDragEventObject(){return[...new Set([this.boundObject.dragend,this.boundObject.drag,this.boundObject.dragstart].flat())].filter(Boolean)}get model(){return Bt(this.five)}addAutoBindEventListener(t,e,i,s){const o=()=>this.addEventListener(t,e,i,s),r=()=>this.removeEventListener(t,e,i,s);return t.addEventListener("added",o),t.addEventListener("removed",r),t.addEventListener("dispose",r),()=>{t.removeEventListener("added",o),t.removeEventListener("removed",r),t.removeEventListener("dispose",r)}}addEventListener(t,e,i,s){t._domEvent||(t._domEvent={}),t._domEvent[`${e}Handler`]||(t._domEvent[`${e}Handler`]=[]),this.boundObject[e]||(this.boundObject[e]=[]),this.boundObject[e].includes(t)||this.boundObject[e].push(t),t._domEvent[`${e}Handler`].push([i,x({noEmitWhenHide:!1,noEmitWhenNotInScene:!1},s)])}removeEventListener(t,e,i,...s){var r,a;if(!t._domEvent||(e===void 0&&(Object.keys(this.boundObject).forEach(l=>{var h,u;const c=(h=this.boundObject[l])==null?void 0:h.findIndex(f=>f===t);c!==-1&&((u=this.boundObject[l])==null||u.splice(c,1))}),t._domEvent={}),!t._domEvent[`${e}Handler`]))return;if(i===void 0){delete t._domEvent[`${e}Handler`];return}const o=t._domEvent[`${e}Handler`].findIndex(l=>l[0]===i);if(o!==-1&&(t._domEvent[`${e}Handler`].splice(o,1),t._domEvent[`${e}Handler`].length===0&&delete t._domEvent[`${e}Handler`],t._domEvent&&Object.keys(t._domEvent).length===0&&delete t._domEvent,!t._domEvent)){const l=(r=this.boundObject[e])==null?void 0:r.findIndex(c=>c===t);l!==-1&&((a=this.boundObject[e])==null||a.splice(l,1))}}clear(){this.boundObject={}}dispose(){var t;(t=this.five)==null||t.off("wantsGesture",this.handleWantsGesture),document.removeEventListener("mousedown",this.handleMousedown),document.removeEventListener("mouseup",this.handleMouseup),document.removeEventListener("mousemove",this.handleMousemove),this.boundObject={}}toJSON(){return{boundObject:this.boundObject}}getRaycaster(t){const e=this.five.getElement();if(!e)return;const i=Wc(t,e),s=new Hc;return s.setFromCamera(i,this.five.camera),s}}const Yc="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Dv(n,t){const{x:e,y:i}=t,s=e*2-1,o=i*2-1,r=new y.Raycaster;return r.setFromCamera({x:s,y:o},n.camera),r.params.Points.threshold=.02,r}function ws(n,t,e){const i=Sv(n,t);return e!=null&&e.virtualPoint?i!=null?i:Xc(t):i}function Xc(n,t=3){const e=new y.Vector3().addVectors(n.ray.origin,n.ray.direction.clone().normalize().multiplyScalar(t)),i=n.ray.direction.clone().negate();return{distance:t,point:e,object:new y.Object3D,face:new y.Face3(0,0,0,i),raycaster:n,isVirtual:!0}}function Sv(n,t){const s=Bt(n).intersectRaycaster(t)[0];if(s)return ne(x({},s),{raycaster:t,isVirtual:!1})}const Lv=new y.Vector3,In=()=>!1;class Zc extends ut{constructor(e,i){var r,a,l;super();d(this,"outOfFive",!1);d(this,"enabled",!1);d(this,"actionIfNoModelUnderMouse","virtualPoint");d(this,"plane");d(this,"pointSelectorHelper");d(this,"hook",this);d(this,"five");d(this,"hammer");d(this,"mode");d(this,"pressDown",!1);d(this,"adherePoints");d(this,"adherePointsRadius",.1);d(this,"lastFiveHelperVisible");d(this,"lastIntersection");d(this,"mousePosition");d(this,"config",{});d(this,"select",e=>{e&&this.updatePointSelectorHelperIntersect(e);const i=this.emit("wantsSelect",this.position);return i||(this.pointSelectorHelper.hide(),this.emit("select",this.position),console.debug(this.position)),!i});d(this,"onEnter",()=>{this.pointSelectorHelper.show(),this.outOfFive=!1,this.emit("intersectionUpdate",this.position)});d(this,"onLeave",()=>{this.pointSelectorHelper.hide(),this.outOfFive=!0,this.emit("intersectionUpdate",null)});d(this,"onTap",e=>{e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),this.select()});d(this,"onPan",e=>{this.pressDown&&(e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),this.mouseNdcPosition&&this.updateByNdcPosition(this.mouseNdcPosition))});d(this,"onPress",e=>{if(e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),!this.mouseNdcPosition)return;const i=this.updateByNdcPosition(this.mouseNdcPosition);this.pressDown=i});d(this,"onPanEnd",()=>{this.pressDown&&(this.pressDown=!1,this.select())});d(this,"updateByMousePosition",e=>{this.five.getElement()&&(this.mousePosition=e,this.updateByNdcPosition(this.mouseNdcPosition))});d(this,"updateByNdcPosition",e=>{var o,r;const i=Dv(this.five,e),s=ws(this.five,i);if(s)return this.updatePointSelectorHelperIntersect(s),this.lastIntersection=s,!0;if(this.plane){const a=i.ray.intersectPlane(this.plane,Lv);if(a){const l={distance:this.five.camera.position.distanceTo(a),point:a.clone(),object:new y.Object3D,face:new y.Face3(0,0,0,this.plane.normal.clone()),raycaster:i,isVirtual:!0};return this.updatePointSelectorHelperIntersect(l),!0}}if(this.actionIfNoModelUnderMouse==="lastPoint")return this.updatePointSelectorHelperIntersect(this.lastIntersection),!0;if(this.actionIfNoModelUnderMouse==="virtualPoint"){const a=Xc(i,(o=this.lastIntersection)==null?void 0:o.distance);return a.face=new y.Face3(0,0,0,(r=this.lastIntersection)==null?void 0:r.face.normal),this.lastIntersection=a,this.updatePointSelectorHelperIntersect(a),!0}else if(this.actionIfNoModelUnderMouse==="disable")return this.updatePointSelectorHelperIntersect(null),!1});d(this,"updatePointSelectorHelperIntersect",e=>{if(!e){this.onLeave(),this.five.getElement().style.cursor=`url("data:image/svg+xml,%3Csvg width='12px' height='12px' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cpath d='M6,12 C9.3137085,12 12,9.3137085 12,6 C12,2.6862915 9.3137085,0 6,0 C2.6862915,0 0,2.6862915 0,6 C0,9.3137085 2.6862915,12 6,12 Z' fill='%23FF5959'%3E%3C/path%3E%3Cg transform='translate(2, 2)' stroke='%23FFFFFF'%3E%3Ccircle cx='4' cy='4' r='4'%3E%3C/circle%3E%3Cline x1='1.07141075' y1='1.23997894' x2='6.64700843' y2='6.81557662'%3E%3C/line%3E%3C/g%3E%3C/g%3E%3C/svg%3E"), auto`;return}this.onEnter(),this.five.getElement().style.cursor="";const i=x({},e);let s=!1;if(typeof this.adherePoints=="function"&&typeof this.adherePointsRadius=="number"){for(const o of this.adherePoints({intersection:e,pointSelectorInstance:this}))if(o.distanceTo(e.point)<this.adherePointsRadius){i.point=o.clone(),s=!0;break}}this.pointSelectorHelper.updateWithIntersect(i,{emitEvent:!1}),this.emit("intersectionUpdate",i,s)});d(this,"mousePositionToNdcPosition",e=>{const i=this.five.getElement();if(!i)return null;const{top:s,left:o,width:r,height:a}=i.getBoundingClientRect(),{clientX:l,clientY:c}=e;return{x:(l-o)/r,y:1-(c-s)/a}});d(this,"onFiveWantsPanGesture",()=>{if(this.pressDown)return!1});d(this,"renderScreenCenter",()=>{this.updateByNdcPosition({x:.5,y:.5})});d(this,"emitIntersectionUpdate",e=>{this.emit("intersectionUpdate",e)});this.five=e,this.config=x(x({},this.config),i),this.actionIfNoModelUnderMouse=(r=i==null?void 0:i.actionIfNoModelUnderMouse)!=null?r:"virtualPoint";const s=(a=i==null?void 0:i.mode)!=null?a:"auto";s==="auto"?this.mode=Yc?"fixed":"cursor":this.mode=s;const o={autoFixPCPosition:this.mode==="cursor",initialPosition:this.mode==="fixed"?{left:"35%",top:"20%"}:void 0};this.pointSelectorHelper=new eh(this.five,ne(x({},i==null?void 0:i.helper),{magnifierParams:x(x({},o),(l=i==null?void 0:i.helper)==null?void 0:l.magnifierParams)})),this.pointSelectorHelper.hide()}get position(){return this.outOfFive?null:this.pointSelectorHelper.position}get mouseNdcPosition(){return this.mousePosition?this.mousePositionToNdcPosition(this.mousePosition):null}enable(){if(this.enabled)return;this.enabled=!0,this.outOfFive=!1,this.pointSelectorHelper.enable();const e=this.five.getElement();if(!e)throw new Error("five element not found");this.hammer||(this.hammer=new vn(e)),this.mode==="cursor"?(this.five.on("wantsPanGesture",this.onFiveWantsPanGesture),this.five.on("wantsMoveToPano",In),this.five.on("wantsChangeMode",In),this.five.on("wantsTapGesture",In),e.addEventListener("mousemove",this.updateByMousePosition),e.addEventListener("wheel",this.updateByMousePosition),e.addEventListener("mouseenter",this.onEnter),e.addEventListener("mouseout",this.onLeave),this.hammer.on("tap",this.onTap),this.hammer.on("pan",this.onPan),this.hammer.on("press",this.onPress),this.hammer.on("panend",this.onPanEnd)):this.mode==="fixed"&&(this.five.on("panoArrived",this.renderScreenCenter),this.five.on("panGesture",this.renderScreenCenter),this.five.on("interiaPan",this.renderScreenCenter),this.renderScreenCenter(),this.pointSelectorHelper.show()),this.pointSelectorHelper.hooks.on("intersectionUpdate",this.emitIntersectionUpdate),this.lastFiveHelperVisible=this.five.helperVisible,this.five.helperVisible=!1,this.emit("enable")}disable(){if(!this.enabled)return;this.enabled=!1,this.pointSelectorHelper.disable(),this.five.getElement().style.cursor="";const e=this.five.getElement();this.five.off("wantsPanGesture",this.onFiveWantsPanGesture),this.five.off("wantsMoveToPano",In),this.five.off("wantsChangeMode",In),this.five.off("wantsTapGesture",In),this.five.helperVisible=this.lastFiveHelperVisible,e==null||e.removeEventListener("mousemove",this.updateByMousePosition),e==null||e.removeEventListener("wheel",this.updateByMousePosition),e==null||e.removeEventListener("mouseenter",this.onEnter),e==null||e.removeEventListener("mouseout",this.onLeave),this.hammer.off("tap",this.onTap),this.hammer.off("pan",this.onPan),this.hammer.off("press",this.onPress),this.hammer.off("panend",this.onPanEnd),this.five.off("panoArrived",this.renderScreenCenter),this.five.off("panGesture",this.renderScreenCenter),this.five.off("interiaPan",this.renderScreenCenter),this.pointSelectorHelper.hooks.off("intersectionUpdate",this.emitIntersectionUpdate),this.emit("disable")}dispose(){this.disable(),this.pointSelectorHelper.dispose()}setAdherePoints(e,i){e?typeof e=="function"?this.adherePoints=e:this.adherePoints=()=>e:this.adherePoints=null,typeof i=="number"&&(this.adherePointsRadius=i)}}class Tv{constructor(){d(this,"five");d(this,"_cursor");d(this,"_pointSelector");d(this,"_fiveDomEvents");d(this,"_object3DHelper");d(this,"inited",!1);d(this,"init",t=>{this.inited=!0,this.five=t,this._cursor=void 0,this._pointSelector=void 0,this._fiveDomEvents=void 0,this._object3DHelper=void 0})}get cursor(){if(!this.inited)throw new Error("Global not inited");return this._cursor?this._cursor:(this._cursor=new _p(this.five.getElement()),this._cursor)}get pointSelector(){if(!this.inited)throw new Error("Global not inited");return this._pointSelector?this._pointSelector:(this._pointSelector=new Zc(this.five),this._pointSelector)}get fiveDomEvents(){if(!this.inited)throw new Error("Global not inited");return this._fiveDomEvents?this._fiveDomEvents:(this._fiveDomEvents=new sa(this.five,{noEmitWhenNotInScene:!0}),this._fiveDomEvents)}get object3DHelper(){if(!this.inited)throw new Error("Global not inited");return this._object3DHelper?this._object3DHelper:(this._object3DHelper=new ta(this.five),this._object3DHelper)}}const oa=new Tv;window.globalModules=oa;function Jc(n){qc(n),n.traverse(t=>qc(t))}function qc(n){Array.isArray(n.lengthDoms)&&n.lengthDoms[0]instanceof Nr&&n.lengthDoms.forEach(e=>e.destroy())}class Kc extends Bp{constructor(e){var i,s;super(e);d(this,"_three_color");ke(e==null?void 0:e.color)&&(this.three_color=(i=e==null?void 0:e.color)!=null?i:16777215),Object.keys(e).forEach(o=>{["color","dashed","dashScale","dashSize","gapSize","resolution"].includes(o)||o in this&&(this[o]=e[o])}),this.setDashed((s=e==null?void 0:e.dashed)!=null?s:!1)}get three_color(){return this._three_color}set three_color(e){this._three_color=e,this.color=e}setDashed(e){this.dashed=e,e?this.defines.USE_DASH="":delete this.defines.USE_DASH,this.needsUpdate=!0}}class $c extends Vp{constructor(e,i){super(e,i);d(this,"name","Line3")}}class Wt extends St{constructor(e){var r,a,l,c,h;super();d(this,"name","LineMesh");d(this,"points");d(this,"lengthDoms",[]);d(this,"highlighted",!1);d(this,"line");d(this,"backLine");d(this,"opacityBeforeHighlight");d(this,"paramsStyle",{});this.paramsStyle=e!=null?e:{};const i=new Vc,s=new Kc({color:new y.Color((r=e==null?void 0:e.lineColor)!=null?r:zc),linewidth:(a=e==null?void 0:e.lineWidth)!=null?a:Op,dashScale:40,opacity:(l=e==null?void 0:e.opacity)!=null?l:1,transparent:!0,dashed:(c=e==null?void 0:e.dashed)!=null?c:!1}),o=new Kc({color:new y.Color((h=e==null?void 0:e.lineColor)!=null?h:zc),linewidth:s.linewidth*.9,dashScale:s.dashScale,opacity:s.opacity*.8,depthTest:!1,depthWrite:!1,transparent:!0,resolution:s.resolution});this.line=new $c(i,s),this.backLine=new $c(i,o),this.line.renderOrder=1,this.backLine.renderOrder=0,this.line.name="lineFrontMaterial",this.backLine.name="lineBackMaterial",e&&this.setStyle(e),e!=null&&e.points&&this.setPoints(e.points),this.addEventListener("removed",()=>{Jc(this)})}get style(){return{lineColor:this.color,lineWidth:this.lineWidth,dashed:this.dashed,occlusionVisibility:this.occlusionVisibility,occlusionMode:this.occlusionMode,lengthEnable:this.paramsStyle.lengthEnable}}get lineWidth(){return this.line.material.linewidth}get color(){return new y.Color(this.line.material.three_color)}get dashed(){return this.line.material.dashed}get occlusionVisibility(){return this.backLine.visible||this.line.material.depthTest===!1}get occlusionMode(){return this.line.material.depthTest===!1?"depthTest":"translucence"}setPoints(e){const i=e.map(Ge).filter(ke);if(this.points=i,i.length<2)return;this.addIfNotExists(this.line,this.backLine);const s=i.flatMap(o=>[o.x,o.y,o.z]);s.length>2&&(this.line.geometry.dispose(),this.line.geometry=new Vc,this.backLine.geometry=this.line.geometry),this.line.geometry.setPositions(s),this.line.computeLineDistances(),this.updateLengthItems(),this.needsRender=!0}setResolution(e,i){const s=this.line.material.resolution;(s.x!==e||s.y!==i)&&(s.set(e,i),this.needsRender=!0);const o=this.backLine.material.resolution;(o.x!==e||o.y!==i)&&(o.set(e,i),this.needsRender=!0)}setStyle(e){var o,r,a;this.paramsStyle=x(x({},this.paramsStyle),e),ke(e.lineColor)&&(this.line.material.three_color=new y.Color(e.lineColor),this.backLine.material.three_color=new y.Color(e.lineColor)),ke(e.lineWidth)&&(this.line.material.linewidth=e.lineWidth),ke(e.dashed)&&this.line.material.setDashed(e.dashed),ke(e.opacity)&&(this.line.material.opacity=e.opacity,this.backLine.material.opacity=this.line.material.opacity*.2),this.updateLengthItems();const i=(o=e.occlusionVisibility)!=null?o:this.paramsStyle.occlusionVisibility,s=(a=(r=e.occlusionMode)!=null?r:this.paramsStyle.occlusionMode)!=null?a:"translucence";i?s==="depthTest"?(this.line.material.depthTest=!1,this.backLine.visible=!1):s==="translucence"&&(this.line.material.depthTest=!0,this.backLine.visible=!0,this.line.material.opacity===1?this.backLine.material.setDashed(!0):this.backLine.material.setDashed(this.line.material.dashed)):(this.line.material.depthTest=!0,this.backLine.visible=!1),this.needsRender=!0}highlight(){this.highlighted||(this.highlighted=!0,this.opacityBeforeHighlight=this.line.material.opacity,this.line.material.opacity=this.opacityBeforeHighlight*yn,this.backLine.material.opacity=this.backLine.material.opacity*yn,this.needsRender=!0)}unhighlight(){this.highlighted&&(this.highlighted=!1,this.line.material.opacity=this.opacityBeforeHighlight,this.backLine.material.opacity=.2,this.needsRender=!0)}updateLengthItems(){var e,i;if(this.paramsStyle.lengthEnable){const s=(i=(e=this.points)==null?void 0:e.map((o,r)=>{if(r!==0)return[this.points[r-1],o]}).filter(ke))!=null?i:[];s.forEach(([o,r],a)=>{var h;const l=ei(o,r),c=o.distanceTo(r).toFixed(2)+"m";this.lengthDoms[a]=(h=this.lengthDoms[a])!=null?h:new Nr(oa.five),this.lengthDoms[a].setPosition(l),this.lengthDoms[a].container.innerHTML=`<div style="pointer-events:none;color:white;">${c}</div>`}),this.lengthDoms.length>s.length&&(this.lengthDoms.slice(s.length).forEach(o=>o.destroy()),this.lengthDoms.length=s.length)}else this.lengthDoms.forEach(s=>s.destroy()),this.lengthDoms=[]}}class jv extends He.CSS3DSprite{constructor(){super(...arguments);d(this,"isCSS3DSprite",!0)}}const zv=`
|
|
177
|
+
`;function Sp(){const n=new y.PlaneGeometry(.4,.4),t=Ep,e=new y.TextureLoader().load(t);e.encoding=y.sRGBEncoding,e.minFilter=y.LinearFilter;const i=new y.MeshBasicMaterial({map:e,transparent:!0,depthTest:!1});return new y.Mesh(n,i)}function Lp(){const n=new y.CurvePath;n.add(new y.LineCurve3(new y.Vector3(0,0,0),new y.Vector3(0,0,.1)));const t=new y.TubeGeometry(n,8,.003),e=new y.ShaderMaterial({vertexShader:xp,fragmentShader:Dp,depthTest:!1,transparent:!0});return new y.Mesh(t,e)}function Tp(){const n=new y.SphereGeometry(.01,20,20),t=new y.MeshBasicMaterial({color:10349931,depthTest:!1,transparent:!0,side:y.DoubleSide}),e=new y.Mesh(n,t);return e.position.set(0,0,.1),e}function jp(){const t=new ch({pointerEvents:"none",cornerPoints:[new y.Vector3(-.2,.2,0),new y.Vector3(-.2,-.2,0),new y.Vector3(.2,-.2,0),new y.Vector3(.2,.2,0)]}),e=document.createElement("div");return e.style.width="100%",e.style.height="100%",e.style.backgroundImage=`url(${Sc})`,e.style.backgroundSize="100%",e.style.backgroundRepeat="no-repeat",t.container.appendChild(e),t}class jc extends y.Object3D{constructor(e){super();d(this,"planeMesh");d(this,"lineMesh");d(this,"ballMesh");d(this,"borderMesh");this.planeMesh=Sp(),this.lineMesh=Lp(),this.ballMesh=Tp(),this.borderMesh=jp(),this.add(this.planeMesh,this.lineMesh,this.ballMesh,this.borderMesh),Tc(e)}updateWithIntersect(e){if(!e.face)return;const i=new y.Vector3().addVectors(e.point,e.face.normal);this.position.copy(e.point),this.lookAt(i)}show(){this.visible=!0,this.borderMesh.parent||this.add(this.borderMesh)}hide(){this.visible=!1,this.remove(this.borderMesh)}dispose(){var e;(e=this.planeMesh.material.map)==null||e.dispose()}}const zp=16777215,zc=16777215,Op=2,yn=.6;class Oc extends wt.Line{constructor(...t){super(...t)}toJSON(){return{type:"FiveLine",points:this.points.toJSON()}}}class Vp extends wt.THREE_Line2{constructor(...t){super(...t)}toJSON(){return{type:"Five_THREE_Line2",geometryAttributes:this.geometry.attributes}}}class Vc extends wt.LineGeometry{constructor(...t){super(...t)}toJSON(){return{type:"FiveLineGeometry",attributes:this.attributes}}}class Bp extends wt.LineMaterial{constructor(...t){super(...t)}toJSON(){return{type:"FiveLineMaterial",color:this.color}}}class St extends N.Object3D{constructor(){super();d(this,"name","IObject3D");d(this,"needsRender")}removeChildren(){for(;this.children.length>0;)this.remove(this.children[0]);return this}add(...e){const i=e.filter(Boolean);return i.length===0?this:super.add(...i)}addIfNotExists(...e){return e.forEach(i=>{this.children.includes(i)||this.add(i)}),this}remove(...e){if(e.length===0)return this;const i=e.filter(Boolean);return super.remove(...i)}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}}function Rp(n,t){const{x:e,y:i,z:s}=t.clone().project(n);return s>1?void 0:{leftPercent:(e+1)/2*100,topPercent:(-i+1)/2*100}}const Bc="LightTagContainer_shgjakdhwakjdhsja";class Nr{constructor(t,e,i){d(this,"container");d(this,"visible",!1);d(this,"enabled",!1);d(this,"wrapper");d(this,"tagWrapper");d(this,"five");d(this,"originPosition");d(this,"transformedPosition");d(this,"disposer");d(this,"config");d(this,"onCameraUpdate",()=>{this.visible!==!1&&this.updateScreenPosition()});d(this,"onFiveEveryReady",()=>{var t;if(this.visible&&this.five.state.mode!=="Panorama"){const e=new y.Raycaster;e.set(this.five.camera.position,this.transformedPosition.clone().sub(this.five.camera.position));const i=(t=Bt(this.five).intersectRaycaster(e))==null?void 0:t[0];(i==null?void 0:i.distance)>this.transformedPosition.distanceTo(this.five.camera.position)?(this.container.style.opacity="1",this.container.style.pointerEvents="auto"):(this.container.style.opacity="0",this.container.style.pointerEvents="none")}});var s;this.five=t,this.originPosition=e?Ge(e).clone():void 0,this.transformedPosition=(s=this.originPosition)==null?void 0:s.clone(),this.container=(()=>{const o=document.createElement("div");return o.style.width="0",o.style.height="0",o.style.position="absolute",o})(),this.config=i!=null?i:{},this.enable(),this.show()}show(){this.visible=!0,this.container.style.opacity="1",this.container.style.pointerEvents="auto",this.container.style.transition="opacity 0.2s linear",this.onCameraUpdate()}hide(t){this.visible=!1,t!=null&&t.withAnimation?this.container.style.transition="opacity 0.2s linear":this.container.style.transition="",this.container.style.opacity="0",this.container.style.pointerEvents="none"}enable(){var i,s,o,r;if(this.enabled)return;this.enabled=!0,this.wrapper=(o=(s=this.config.wrapper)!=null?s:(i=this.five.getElement())==null?void 0:i.parentElement)!=null?o:document.body,this.tagWrapper||(this.tagWrapper=(r=document.getElementById(Bc))!=null?r:(()=>{const a=document.createElement("div");return a.id=Bc,a.style.position="absolute",a.style.top="0",a.style.left="0",a.style.width="100%",a.style.height="100%",a.style.pointerEvents="none",a})(),this.wrapper.contains(this.tagWrapper)||this.wrapper.appendChild(this.tagWrapper)),this.tagWrapper.appendChild(this.container);let t=!1;const e=()=>{t||(t=!0,this.five.ready().then(()=>{this.onFiveEveryReady(),t=!1}))};this.five.on("cameraUpdate",e),this.five.on("cameraUpdate",this.onCameraUpdate),this.disposer=()=>{this.five.off("cameraUpdate",e),this.five.off("cameraUpdate",this.onCameraUpdate)}}disable(){var t;this.enabled&&(this.enabled=!1,this.tagWrapper.removeChild(this.container),(t=this.disposer)==null||t.call(this))}destroy(){this.disable(),this.container.remove()}setTransformMatrix(t){var e;this.transformedPosition=(e=this.originPosition)==null?void 0:e.clone().applyMatrix4(t),this.onCameraUpdate()}setPosition(t){this.transformedPosition=t,this.onCameraUpdate()}updateScreenPosition(){if(!this.transformedPosition){this.container.style.left="-100%",this.container.style.top="-100%";return}const t=Rp(this.five.camera,this.transformedPosition);t?(this.container.style.left=t.leftPercent+"%",this.container.style.top=t.topPercent+"%"):(this.container.style.left="-100%",this.container.style.top="-100%")}}function Fp(n,t,e){return new Nr(n,t,e)}const Np={auto:"",pen:"","pen-forbidden":"","pen-crosshair":"","pne-polygon":"","pen-circle":"","crosshair-rectangle":"","crosshair-circle":""};class _p{constructor(t){d(this,"container");this.container=t}setType(t){const e=Np[t];e?this.container.style.cursor=`url(${e}), auto`:this.container.style.cursor=t}tip(t){return()=>this.closeTip()}closeTip(){}reset(){this.container.style.cursor="auto"}}class Rc extends ut{constructor(e){super();d(this,"five");this.five=e}}const vs=(n,t)=>{if(!t)return n;const e=new y.Vector3,i=new y.Quaternion,s=new y.Vector3;return t.decompose(e,i,s),n.clone().multiply(s).applyQuaternion(i).add(e)},_r=new Map;class Gp extends Rc{constructor(e){super(e);d(this,"_workCode")}get fromType(){var s,o;const e=this.workCode;if(_r.has(e))return _r.get(e);const i=(o=(s=JSON.parse(this.work.raw.works[0]))==null?void 0:s.from_type)!=null?o:"vr";return _r.set(e,i),i}set workCode(e){this._workCode=e}get workCode(){var e;return(e=this._workCode)!=null?e:this.five.state.workCode}get work(){var e,i;return(i=(e=this.five.works)==null?void 0:e.find(s=>s.workCode===this.workCode))!=null?i:this.five.work}get observers(){var e;return(e=this.work)==null?void 0:e.observers}get transform(){var i,s,o,r;const e=(r=(i=this.work)==null?void 0:i.transform)!=null?r:(o=(s=this.work)==null?void 0:s.options)==null?void 0:o.transform;return e?e.clone():new y.Matrix4}getObserverPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.position;if(i)return vs(i,this.transform)}getObserverStandingPosition(e){var s;const i=(s=this.getObserver(e))==null?void 0:s.standingPosition;if(i)return vs(i,this.transform)}getObserver(e){var i;return(i=this.observers)==null?void 0:i[e]}}class Gr extends Rc{constructor(e){super(e);d(this,"workUtil",new Gp(this.five))}get version(){return this.five.constructor.version}get majorVersion(){return Number(this.version.split(".")[0])}get model(){return Bt(this.five)}moveToPano(e,i){const s=this.majorVersion===5?e:{workCode:this.workUtil.workCode,panoIndex:e};return this.five.moveToPano(s,i)}}let Di=class{constructor(t,e){d(this,"VERSION","3.47.2");d(this,"NAME");d(this,"five");d(this,"workUtil");d(this,"fiveUtil");d(this,"hooks",new ut);d(this,"staticPrefix","//vr-image-4.realsee-cdn.cn");this.updateFive(t),e!=null&&e.staticPrefix&&(this.staticPrefix=e.staticPrefix)}set workCode(t){this.workUtil.workCode=t,this.onWorkCodeChange()}get workCode(){return this.workUtil.workCode}updateFive(t){this.five=t,this.fiveUtil=new Gr(t),this.workUtil=this.fiveUtil.workUtil}getCurrentState(){return this.state}absoluteUrl(t){return aa(this.staticPrefix,t)}onWorkCodeChange(){}};function Fc(n,t,e){if(e){const s=new y.Vector3().subVectors(n.position,e).applyQuaternion(n.quaternion.clone().inverse()).applyQuaternion(t).add(e);n.position.copy(s)}n.quaternion.copy(t)}const Qr=new y.Vector3;class Qp extends y.Sphere{expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Qr.subVectors(t,this.center);const e=Qr.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(Qr,s/i),this.radius+=s}return this}}function Wp(n){const{max:t,min:e}=n;return[new y.Vector3(t.x,t.y,t.z),new y.Vector3(e.x,t.y,t.z),new y.Vector3(e.x,e.y,t.z),new y.Vector3(t.x,e.y,t.z),new y.Vector3(t.x,t.y,e.z),new y.Vector3(e.x,t.y,e.z),new y.Vector3(e.x,e.y,e.z),new y.Vector3(t.x,e.y,e.z)]}function gi(n,t){const{max:e,min:i}=n;switch(t){case 0:return new y.Vector3(e.x,e.y,e.z);case 1:return new y.Vector3(i.x,e.y,e.z);case 2:return new y.Vector3(i.x,i.y,e.z);case 3:return new y.Vector3(e.x,i.y,e.z);case 4:return new y.Vector3(e.x,e.y,i.z);case 5:return new y.Vector3(i.x,e.y,i.z);case 6:return new y.Vector3(i.x,i.y,i.z);case 7:return new y.Vector3(e.x,i.y,i.z)}}function wn(n){return Wr(n,"box3")}function Nc(n){return Wr(n,"sphere")}function Hp(n){return Ao(n,"box3")}function _c(n){return Ao(n,"sphere")}function Ao(n,t){const e=t==="box3"?new y.Box3:new Qp,i=new y.Vector3;if(n.updateWorldMatrix(!1,!1),n.traverse(s=>{var r;if(s.name==="shadow"||s.type==="Line2")return;const o=s.geometry;if(s.updateWorldMatrix(!1,!1),o!==void 0){const a=(r=o==null?void 0:o.attributes)==null?void 0:r.position;if(a)for(let l=0,c=a.count;l<c;l++)i.fromBufferAttribute(a,l).applyMatrix4(s.matrixWorld),e.expandByPoint(i);else o.vertices&&o.vertices.forEach(l=>{const c=l.clone().applyMatrix4(s.matrixWorld);e.expandByPoint(c)})}}),!e.isEmpty())return e}function Wr(n,t){const e=Ao(n,t);return e&&e.applyMatrix4(Up(n.matrixWorld.clone())),e}const Up=n=>{const t=n.elements,e=t[0],i=t[1],s=t[2],o=t[3],r=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],f=t[10],g=t[11],v=t[12],p=t[13],m=t[14],A=t[15],w=u*m*c-p*f*c+p*l*g-a*m*g-u*l*A+a*f*A,I=v*f*c-h*m*c-v*l*g+r*m*g+h*l*A-r*f*A,P=h*p*c-v*u*c+v*a*g-r*p*g-h*a*A+r*u*A,k=v*u*l-h*p*l-v*a*f+r*p*f+h*a*m-r*u*m,M=e*w+i*I+s*P+o*k;if(M===0)return n.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/M;return t[0]=w*T,t[1]=(p*f*o-u*m*o-p*s*g+i*m*g+u*s*A-i*f*A)*T,t[2]=(a*m*o-p*l*o+p*s*c-i*m*c-a*s*A+i*l*A)*T,t[3]=(u*l*o-a*f*o-u*s*c+i*f*c+a*s*g-i*l*g)*T,t[4]=I*T,t[5]=(h*m*o-v*f*o+v*s*g-e*m*g-h*s*A+e*f*A)*T,t[6]=(v*l*o-r*m*o-v*s*c+e*m*c+r*s*A-e*l*A)*T,t[7]=(r*f*o-h*l*o+h*s*c-e*f*c-r*s*g+e*l*g)*T,t[8]=P*T,t[9]=(v*u*o-h*p*o-v*i*g+e*p*g+h*i*A-e*u*A)*T,t[10]=(r*p*o-v*a*o+v*i*c-e*p*c-r*i*A+e*a*A)*T,t[11]=(h*a*o-r*u*o-h*i*c+e*u*c+r*i*g-e*a*g)*T,t[12]=k*T,t[13]=(h*p*s-v*u*s+v*i*f-e*p*f-h*i*m+e*u*m)*T,t[14]=(v*a*s-r*p*s-v*i*l+e*p*l+r*i*m-e*a*m)*T,t[15]=(r*u*s-h*a*s+h*i*l-e*u*l-r*i*f+e*a*f)*T,n};class As extends St{constructor(e,i){var s,o;super();d(this,"originObject3D");d(this,"onRender");d(this,"positionFrom");this.originObject3D=e,this.onRender=(s=i==null?void 0:i.onRender)!=null?s:()=>{},this.positionFrom=(o=i==null?void 0:i.positionFrom)!=null?o:"objectPosition"}get helperObject(){return this}render(){this.onRender()}enable(){this.parent.children.includes(this)||this.parent.add(this)}disable(){this.removeFromParent()}show(){this.visible=!0,this.render()}hide(){this.visible=!1,this.render()}raycasterIntersectObject(e,i=[]){return e.intersectObject(this,!0,i)}initialPosition(e){var i,s;this.positionFrom==="objectPosition"?this.position.copy(this.originObject3D.position):this.positionFrom==="boundingBox"?this.position.copy((i=wn(this.originObject3D))==null?void 0:i.getCenter(new y.Vector3)):this.positionFrom==="boundingSphere"?this.position.copy((s=Nc(this.originObject3D))==null?void 0:s.center):this.positionFrom instanceof N.Vector3?this.position.copy(this.positionFrom):this.positionFrom instanceof Function&&this.position.copy(this.positionFrom(this.originObject3D)),e&&this.position.add(e)}setScaleByCamera(e){}initQuaternion(){this.quaternion.copy(this.originObject3D.quaternion)}applyHelperScaleMatrix4(e,i){this.scale.applyMatrix4(e)}setHelperQuaternion(e,i){Fc(this,e,i)}applyHelperQuaternion(e,i){if(i){const s=new N.Vector3().subVectors(this.position,i).applyQuaternion(e).add(i);this.position.copy(s)}this.applyQuaternion(e)}dispose(){this.removeFromParent()}}class Yp extends As{}class Xp extends As{}class Zp extends As{}class Jp extends As{}class qp extends As{}class Kp extends y.Group{constructor(e){super();d(this,"direction");this.direction=e||"x"}}class Gc extends y.Mesh{constructor(e,i,s){super(e,i);d(this,"direction");this.direction=s||"x"}}function $p(n,t){const{offsetWidth:e,offsetHeight:i}=t,{top:s,left:o}=t.getBoundingClientRect();return Object.assign(new y.Vector2,{x:(n.x-o)/e*2-1,y:-(n.y-s)/i*2+1})}function bo(n,t,e){if(!t||!e||!n)return;const i=$p(t,e);if(Math.abs(i.x)===1||Math.abs(i.y)===1)return;const s=new y.Raycaster;return s.setFromCamera(i,n),s}function ev(n,t){return!(Math.abs(n.x-t.x)>1e-5||Math.abs(n.y-t.y)>1e-5||Math.abs(n.z-t.z)>1e-5)}class Hr extends Kp{constructor(e){var h;super(e.direction);d(this,"line");d(this,"arrow");d(this,"lineHeight",.4);d(this,"arrowHeight",.1);this.name="ArrowGroup";const i=new y.Color((h=e.color)!=null?h:16214315),s=new y.MeshBasicMaterial({color:i,depthTest:!1,depthWrite:!1,opacity:1,transparent:!0,side:y.DoubleSide});this.renderOrder=50;const o=new y.ConeGeometry(.04,.1,32),r=new Gc(o,s.clone(),e.direction);r.name=`arrow-${e.direction}`,this.arrow=r;const a=.004,l=new y.CylinderGeometry(a,a,.4,32),c=new Gc(l,s.clone(),e.direction);c.name=`line-${e.direction}`,this.line=c,this.formatArrow(),this.formatLine(),this.add(this.arrow,this.line)}formatArrow(){this.arrow.geometry.translate(0,this.lineHeight+this.arrowHeight/2,0),this.direction==="x"?(this.arrow.geometry.rotateX(Math.PI/2),this.arrow.geometry.rotateY(Math.PI/2)):this.direction==="z"&&this.arrow.geometry.rotateX(Math.PI/2)}formatLine(){this.line.geometry.translate(0,this.lineHeight/2,0),this.direction==="x"?(this.line.geometry.rotateX(Math.PI/2),this.line.geometry.rotateY(Math.PI/2)):this.direction==="z"&&this.line.geometry.rotateX(Math.PI/2)}}const Ur={X:15618642,Y:4765519,Z:4227839};class Cn{static get X(){return new y.Color(Ur.X).convertSRGBToLinear().clone()}static get Y(){return new y.Color(Ur.Y).convertSRGBToLinear().clone()}static get Z(){return new y.Color(Ur.Z).convertSRGBToLinear().clone()}}function Yr(n,t){const s=n.position.distanceTo(t),o=n.fov,r=s/3,a=o/90;return r*a}class tv extends Yp{constructor(e,i){super(e,i);d(this,"xArrow");d(this,"yArrow");d(this,"zArrow");i.xArrowEnable!==!1&&(this.xArrow=new Hr({direction:"x",color:Cn.X})),i.yArrowEnable!==!1&&(this.yArrow=new Hr({direction:"y",color:Cn.Y})),i.zArrowEnable!==!1&&(this.zArrow=new Hr({direction:"z",color:Cn.Z})),this.add(...[this.xArrow,this.yArrow,this.zArrow].filter(Boolean))}show(){super.show(),this.xArrow&&(this.xArrow.visible=!0),this.yArrow&&(this.yArrow.visible=!0),this.zArrow&&(this.zArrow.visible=!0)}setScaleByCamera(e){this.scale.setScalar(Yr(e,this.position))}showDraggingHelper(e){this.xArrow&&(this.xArrow.visible=e.includes("x")),this.yArrow&&(this.yArrow.visible=e.includes("y")),this.zArrow&&(this.zArrow.visible=e.includes("z"))}dispose(){this.remove(...[this.xArrow,this.yArrow,this.zArrow].filter(Boolean)),super.dispose()}}function Yi(n,t){return iv(document.createElement(t!=null?t:"div"),n)}function iv(n,t){if(!t)return n;for(const e in t)e&&t[e]&&(n.style[e]=t[e]);return n}function nv(n){const t=Yi(x({position:"absolute",display:"block",borderRadius:"4px",paddingTop:"1px",paddingBottom:"1px",paddingLeft:"4px",paddingRight:"4px",pointerEvents:"none",userSelect:"none",zIndex:"99999",backgroundColor:"rgba(0,0,0,0.7)",fontSize:"12px",color:"#fff",letterSpacing:"0",lineHeight:"18px"},n)),e=()=>{t.style.display!=="block"&&t.style.top&&t.style.left&&(t.style.display="block")};return{element:t,show:e,hide:()=>{t.style.display="none",t.style.top="",t.style.left=""},setLeftTop:(o,r)=>{t.style.left=o,t.style.top=r,e()}}}class sv extends Zp{constructor(e,i){super(e,i);d(this,"xCircle");d(this,"yCircle");d(this,"zCircle");d(this,"children",[]);d(this,"angleTips");d(this,"container");(i==null?void 0:i.yzCircleEnable)!==!1&&(this.xCircle=new Xr({direction:"x",color:Cn.X})),(i==null?void 0:i.xzCircleEnable)!==!1&&(this.yCircle=new Xr({direction:"y",color:Cn.Y})),(i==null?void 0:i.xyCircleEnable)!==!1&&(this.zCircle=new Xr({direction:"z",color:Cn.Z})),i!=null&&i.container&&(i==null?void 0:i.angleTipsEnable)!==!1&&(this.container=i==null?void 0:i.container,this.angleTips=nv({display:"none"}),this.container.appendChild(this.angleTips.element)),this.add(...[this.xCircle,this.yCircle,this.zCircle].filter(Boolean)),this.show()}hide(){this.children.forEach(e=>e.hide())}show(){var e;this.children.forEach(i=>i.showCircle()),(e=this.angleTips)==null||e.hide()}setScaleByCamera(e){this.scale.setScalar(Yr(e,this.position))}showDraggingHelper(e){var i;this.hide(),this.children.filter(s=>e.includes(s.direction)).forEach(s=>s.showRing()),(i=this.angleTips)==null||i.show()}dispose(){var e,i;this.removeFromParent(),(i=(e=this.angleTips)==null?void 0:e.element)==null||i.remove()}}class Xr extends y.Group{constructor(e){super();d(this,"direction");d(this,"circle");d(this,"ring");d(this,"angleSector");this.direction=e.direction,this.circle=new ov(e),this.ring=new rv(e),this.angleSector=new av(e),this.add(this.circle,this.ring,this.angleSector),this.direction==="y"?this.rotateX(Math.PI/2):this.direction==="x"&&this.rotateY(-Math.PI/2)}showCircle(){this.add(this.circle),this.remove(this.ring,this.angleSector)}showRing(){this.add(this.ring,this.angleSector),this.remove(this.circle)}hide(){this.remove(this.ring,this.angleSector,this.circle)}}let ov=class extends y.Mesh{constructor(e){var i;super();d(this,"direction");d(this,"gapAngle",.02);d(this,"geometry",new y.RingGeometry(.25,.3,20,8,this.gapAngle,Math.PI/2-this.gapAngle*2));this.material=new y.MeshBasicMaterial({opacity:.6,color:(i=e.color)!=null?i:16777215,transparent:!0,side:y.DoubleSide,depthTest:!1,depthWrite:!1}),this.renderOrder=50,this.direction=e.direction,this.geometry.name=`RotateHelperCircleGeometry-${this.direction}`}};class rv extends y.Group{constructor(e){super();d(this,"direction");this.direction=e.direction;const i=.015,s=new Array(8).fill(null).map((o,r)=>{const a=new y.RingGeometry(.25,.3,20,8,Math.PI/4*r+i,Math.PI/4-i*2),l=new y.MeshBasicMaterial({opacity:1,color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide});this.renderOrder=50;const c=new y.Mesh(a,l);return c.name=`AxesDashedRing-${this.direction}-${r}`,c});this.add(...s)}}class av extends y.Mesh{constructor(e){var s;super();d(this,"direction");d(this,"baseAxes");d(this,"angleDirection");switch(e.direction){case"x":this.baseAxes=new y.Vector3(0,0,1);break;case"y":this.baseAxes=new y.Vector3(1,0,0);break;case"z":this.baseAxes=new y.Vector3(1,0,0);break}const i=.3+5e-4;this.geometry=new y.CircleGeometry(i,48,0,1e-4),this.material=new y.MeshBasicMaterial({opacity:.4,color:(s=e.color)!=null?s:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide}),this.renderOrder=50,this.direction=e.direction,this.angleDirection=this.direction==="z"?1:-1}}function lv(){const n=Yi({width:"100%",height:"100%",left:"0",top:"0",position:"absolute",pointerEvents:"none"}),t=Yi({boxSizing:"border-box",width:"100%",height:"100%",left:"0",top:"0",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"}),e=Yi({boxSizing:"border-box",width:"100%",height:"100%",left:"0",top:"0",position:"absolute",border:"1px solid rgba(255,255,255,0.4)"});n.appendChild(t),t.appendChild(e);const i="-4px",s={direction:"nesw",element:Si({cursor:"nesw-resize",left:i,bottom:i})},o={direction:"ns",element:Si({cursor:"ns-resize",bottom:i})},r={direction:"nwse",element:Si({cursor:"nwse-resize",right:i,bottom:i})},a={direction:"ew",element:Si({cursor:"ew-resize",right:i})},l={direction:"nesw",element:Si({cursor:"nesw-resize",right:i,top:i})},c={direction:"ns",element:Si({cursor:"ns-resize",top:i})},h={direction:"nwse",element:Si({cursor:"nwse-resize",left:i,top:i})},u={direction:"ew",element:Si({cursor:"ew-resize",left:i})};return new Array(o,a,c,u,s,r,l,h).forEach(g=>t.appendChild(g.element)),{container:n,squares:[s,o,r,a,l,c,h,u]}}function Si(n){const t=Yi(x({background:"#FFFFFF",width:"9px",height:"9px",position:"absolute",pointerEvents:"none"},n)),e=Yi({width:"15px",height:"15px",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"}),i=Yi({width:"15px",height:"15px",cursor:n==null?void 0:n.cursor,pointerEvents:"auto",background:"transparent"});return i.draggable=!0,e.appendChild(i),t.appendChild(e),t}class cv extends qp{constructor(e,i,s,o){super(e);d(this,"points",[]);d(this,"cornerPositions",[]);d(this,"css3DInstance");d(this,"plane");d(this,"css3DRenderer",new Sn);d(this,"camera");d(this,"scene");d(this,"container");d(this,"enabled",!1);this.camera=s,this.scene=o,this.container=i,this.initRectangleScaleHelper()}get helperObject(){var e;if(!((e=this.css3DInstance)!=null&&e.css3DObject))throw new Error("css3DInstance is not initialized");return this.css3DInstance.css3DObject}applyMatrix4(e){var i;super.applyMatrix4(e),this.helperObject.applyMatrix4(e),(i=this.plane)==null||i.applyMatrix4(e),this.cornerPositions.forEach(s=>s.applyMatrix4(e))}showDraggingHelper(){}applyHelperScaleMatrix4(e,i){var s;(s=this.plane)==null||s.scale.applyMatrix4(e),this.helperObject.applyScaleMatrix4(e)}updatePoints(){const e=this.calculatePointPosition(this.cornerPositions);this.points.forEach((i,s)=>{i.position.copy(e[s])})}applyHelperQuaternion(e,i){var o;const s=(o=this.css3DInstance)==null?void 0:o.css3DObject;if(s){const r=new y.Vector3().subVectors(s.position,i).applyQuaternion(e).add(i);s.position.copy(r),s.applyQuaternion(e)}if(this.plane){const r=new y.Vector3().subVectors(this.plane.position,i).applyQuaternion(e).add(i);this.plane.position.copy(r),this.plane.applyQuaternion(e)}this.cornerPositions.forEach(r=>{const a=new y.Vector3().subVectors(r,i).applyQuaternion(e).add(i);r.copy(a)})}enable(){var e;this.enabled||(this.enabled=!0,(e=this.css3DInstance)==null||e.enable(),this.plane&&this.scene.add(this.plane))}disable(){var e;this.enabled&&(this.enabled=!1,(e=this.css3DInstance)==null||e.disable(),this.plane&&this.scene.remove(this.plane))}show(){var e;(e=this.css3DInstance)==null||e.show(),this.plane&&(this.plane.visible=!0)}hide(){var e;(e=this.css3DInstance)==null||e.hide(),this.plane&&(this.plane.visible=!1)}dispose(){this.disable(),this.css3DRenderer.dispose()}initRectangleScaleHelper(){var a,l;const e=this.getCornerPositions();if(!e)return;this.cornerPositions=e;const i=this.css3DRenderer.create3DElement(this.camera,e,{ratio:.003});if(!i)return;this.css3DInstance=i,i.appendToElement(this.container);const s=i.css3DObject.container,{container:o,squares:r}=lv();this.points=r.map((c,h)=>({direction:c.direction,point:c.element,position:this.calculatePointPosition(e)[h]})),s.insertBefore(o,(a=s.children[0])!=null?a:null),this.helperObject.position.copy(this.originObject3D.position),(l=this.plane)==null||l.position.copy(this.originObject3D.position)}getCornerPositions(){const{originObject3D:e}=this;if(e.isCSS3DObjectPlus)return e.cornerPoints;console.error("当前物体暂时不支持 ScaleHelper")}calculatePointPosition(e){return[e[0].clone(),e[0].clone().add(e[1]).divideScalar(2),e[1].clone(),e[1].clone().add(e[2]).divideScalar(2),e[2].clone(),e[2].clone().add(e[3]).divideScalar(2),e[3].clone(),e[3].clone().add(e[0]).divideScalar(2)]}}class hv extends Xp{constructor(e){super(e);d(this,"box");d(this,"outline");d(this,"originObject");d(this,"positionAttribute");this.originObject=e,this.positionAttribute=new y.BufferAttribute(new Float32Array(8*3),3),this.box=this.createBox(),this.outline=this.createOutline(),this.add(this.box,this.outline),this.update()}raycasterIntersectObject(e,i){return e.intersectObject(this,!1,i)}raycast(e,i){this.box.raycast(e,i)}update(){const e=wn(this.originObject);if(!e)return;const{min:i,max:s}=e;this.positionAttribute.setXYZ(0,s.x,s.y,s.z),this.positionAttribute.setXYZ(1,i.x,s.y,s.z),this.positionAttribute.setXYZ(2,i.x,i.y,s.z),this.positionAttribute.setXYZ(3,s.x,i.y,s.z),this.positionAttribute.setXYZ(4,s.x,s.y,i.z),this.positionAttribute.setXYZ(5,i.x,s.y,i.z),this.positionAttribute.setXYZ(6,i.x,i.y,i.z),this.positionAttribute.setXYZ(7,s.x,i.y,i.z),this.positionAttribute.needsUpdate=!0}createOutline(){const e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new y.BufferGeometry;i.setIndex(new y.BufferAttribute(e,1)),i.setAttribute("position",this.positionAttribute);const s=new y.LineBasicMaterial({color:64767,linewidth:1,opacity:1,toneMapped:!1}),o=new y.LineSegments(i,s);return o.matrixAutoUpdate=!1,o}createBox(){const e=new Uint16Array([0,1,2,0,2,3,0,3,7,0,7,4,0,4,5,0,5,1,6,1,5,6,2,1,6,5,4,6,4,7,6,3,2,6,7,3]),i=new y.BufferGeometry;i.setIndex(new y.BufferAttribute(e,1)),i.setAttribute("position",this.positionAttribute);const s=new y.MeshBasicMaterial({color:64767,opacity:.1,depthTest:!1,transparent:!0});return new y.Mesh(i,s)}}function Re(n,t){this._camera=n||null,this._domElement=t||document,this._raycaster=new y.Raycaster,this._selected=null,this._boundObjs={};var e=this;this._$onClick=function(){e._onClick.apply(e,arguments)},this._$onDblClick=function(){e._onDblClick.apply(e,arguments)},this._$onMouseMove=function(){e._onMouseMove.apply(e,arguments)},this._$onMouseDown=function(){e._onMouseDown.apply(e,arguments)},this._$onMouseUp=function(){e._onMouseUp.apply(e,arguments)},this._$onTouchMove=function(){e._onTouchMove.apply(e,arguments)},this._$onTouchStart=function(){e._onTouchStart.apply(e,arguments)},this._$onTouchEnd=function(){e._onTouchEnd.apply(e,arguments)},this._$onContextmenu=function(){e._onContextmenu.apply(e,arguments)},this._domElement.addEventListener("click",this._$onClick,!1),this._domElement.addEventListener("dblclick",this._$onDblClick,!1),this._domElement.addEventListener("mousemove",this._$onMouseMove,!1),this._domElement.addEventListener("mousedown",this._$onMouseDown,!1),this._domElement.addEventListener("mouseup",this._$onMouseUp,!1),this._domElement.addEventListener("touchmove",this._$onTouchMove,!1),this._domElement.addEventListener("touchstart",this._$onTouchStart,!1),this._domElement.addEventListener("touchend",this._$onTouchEnd,!1),this._domElement.addEventListener("contextmenu",this._$onContextmenu,!1)}Re.prototype.destroy=function(){this._domElement.removeEventListener("click",this._$onClick,!1),this._domElement.removeEventListener("dblclick",this._$onDblClick,!1),this._domElement.removeEventListener("mousemove",this._$onMouseMove,!1),this._domElement.removeEventListener("mousedown",this._$onMouseDown,!1),this._domElement.removeEventListener("mouseup",this._$onMouseUp,!1),this._domElement.removeEventListener("touchmove",this._$onTouchMove,!1),this._domElement.removeEventListener("touchstart",this._$onTouchStart,!1),this._domElement.removeEventListener("touchend",this._$onTouchEnd,!1),this._domElement.removeEventListener("contextmenu",this._$onContextmenu,!1)},Re.eventNames=["click","dblclick","mouseover","mouseout","mousemove","mousedown","mouseup","contextmenu","touchstart","touchend"],Re.prototype._getRelativeMouseXY=function(n){var t=n.target||n.srcElement;t.nodeType===3&&(t=t.parentNode);var e={x:0,y:0},i=t,s=getComputedStyle(i,null);e.y+=parseInt(s.getPropertyValue("padding-top"),10),e.x+=parseInt(s.getPropertyValue("padding-left"),10);do e.x+=i.offsetLeft,e.y+=i.offsetTop,s=getComputedStyle(i,null),e.x+=parseInt(s.getPropertyValue("border-left-width"),10),e.y+=parseInt(s.getPropertyValue("border-top-width"),10);while(i=i.offsetParent);var o={width:t===window?window.innerWidth:t.offsetWidth,height:t===window?window.innerHeight:t.offsetHeight};return{x:Number((n.pageX-e.x)/o.width)*2-1,y:-((n.pageY-e.y)/o.height)*2+1}},Re.prototype._objectCtxInit=function(n){n._3xDomEvent={}},Re.prototype._objectCtxDeinit=function(n){delete n._3xDomEvent},Re.prototype._objectCtxIsInit=function(n){return!!n._3xDomEvent},Re.prototype._objectCtxGet=function(n){return n._3xDomEvent},Re.prototype.camera=function(n){return n&&(this._camera=n),this._camera},Re.prototype.bind=function(n,t,e,i){console.assert(Re.eventNames.indexOf(t)!==-1,"not available events:"+t),this._objectCtxIsInit(n)||this._objectCtxInit(n);var s=this._objectCtxGet(n);s[t+"Handlers"]||(s[t+"Handlers"]=[]),s[t+"Handlers"].push({callback:e,useCapture:i}),this._boundObjs[t]===void 0&&(this._boundObjs[t]=[]),this._boundObjs[t].push(n)},Re.prototype.addEventListener=Re.prototype.bind,Re.prototype.unbind=function(n,t,e,i){console.assert(Re.eventNames.indexOf(t)!==-1,"not available events:"+t),this._objectCtxIsInit(n)||this._objectCtxInit(n);var s=this._objectCtxGet(n);s[t+"Handlers"]||(s[t+"Handlers"]=[]);for(var o=s[t+"Handlers"],r=0;r<o.length;r++){var a=o[r];if(e==a.callback&&i==a.useCapture){o.splice(r,1);break}}var l=this._boundObjs[t].indexOf(n);this._boundObjs[t].splice(l,1)},Re.prototype.removeEventListener=Re.prototype.unbind,Re.prototype._bound=function(n,t){var e=this._objectCtxGet(t);return e?!!e[n+"Handlers"]:!1},Re.prototype._onMove=function(n,t,e,i){var s=this._boundObjs[n];if(!(s===void 0||s.length===0)){var o=new y.Vector2;o.set(t,e),this._raycaster.setFromCamera(o,this._camera);var r=this._raycaster.intersectObjects(s),a=this._selected;if(r.length>0){var l,c,h,u=r[0],f=u.object;this._selected=f,h=this._bound("mousemove",f),a!=f&&(l=this._bound("mouseover",f),c=a&&this._bound("mouseout",a))}else c=a&&this._bound("mouseout",a),this._selected=null;h&&this._notify("mousemove",f,i,u),l&&this._notify("mouseover",f,i,u),c&&this._notify("mouseout",a,i,u)}},Re.prototype._onEvent=function(n,t,e,i){var s=this._boundObjs[n];if(!(s===void 0||s.length===0)){var o=new y.Vector2;o.set(t,e),this._raycaster.setFromCamera(o,this._camera);var r=this._raycaster.intersectObjects(s,!0);if(r.length!==0){for(var a=r[0],l=a.object,c=this._objectCtxGet(l),h=l.parent;typeof c=="undefined"&&h;)c=this._objectCtxGet(h),h=h.parent;c&&this._notify(n,l,i,a)}}},Re.prototype._notify=function(n,t,e,i){var s=this._objectCtxGet(t),o=s?s[n+"Handlers"]:null;if(!s||!o||o.length===0){t.parent&&this._notify(n,t.parent,e,i);return}for(var o=s[n+"Handlers"],r=0;r<o.length;r++){var a=o[r],l=!0;a.callback({type:n,target:t,origDomEvent:e,intersect:i,stopPropagation:function(){l=!1}}),l&&a.useCapture===!1&&t.parent&&this._notify(n,t.parent,e,i)}},Re.prototype._onMouseDown=function(n){return this._onMouseEvent("mousedown",n)},Re.prototype._onMouseUp=function(n){return this._onMouseEvent("mouseup",n)},Re.prototype._onMouseEvent=function(n,t){var e=this._getRelativeMouseXY(t);this._onEvent(n,e.x,e.y,t)},Re.prototype._onMouseMove=function(n){var t=this._getRelativeMouseXY(n);this._onMove("mousemove",t.x,t.y,n),this._onMove("mouseover",t.x,t.y,n),this._onMove("mouseout",t.x,t.y,n)},Re.prototype._onClick=function(n){this._onMouseEvent("click",n)},Re.prototype._onDblClick=function(n){this._onMouseEvent("dblclick",n)},Re.prototype._onContextmenu=function(n){this._onMouseEvent("contextmenu",n)},Re.prototype._onTouchStart=function(n){return this._onTouchEvent("touchstart",n)},Re.prototype._onTouchEnd=function(n){return this._onTouchEvent("touchend",n)},Re.prototype._onTouchMove=function(n){if(n.touches.length==1){var t=Number(n.touches[0].pageX/window.innerWidth)*2-1,e=-(n.touches[0].pageY/window.innerHeight)*2+1;this._onMove("mousemove",t,e,n),this._onMove("mouseover",t,e,n),this._onMove("mouseout",t,e,n)}},Re.prototype._onTouchEvent=function(n,t){var e=t.touches;if(e.length==0&&(e=t.changedTouches),e.length==1){var i=Number(e[0].pageX/window.innerWidth)*2-1,s=-(e[0].pageY/window.innerHeight)*2+1;this._onEvent(n,i,s,t)}};function mi(n){return!ke(n)}function ke(n){return n!=null}function pi(n){return arguments.length===0?[]:Array.isArray(n)?n:[n]}let bs=class{constructor(t,e){d(this,"originObject3D");d(this,"hooks");d(this,"preventTapDefaultEvent",!1);d(this,"internalHooks");d(this,"disposers",[]);d(this,"helperObject3D");d(this,"camera");d(this,"model");d(this,"scene");d(this,"container");d(this,"domEvents");d(this,"isDragging",!1);d(this,"enabled",!1);d(this,"name","BaseController");d(this,"boundingBox");d(this,"config");d(this,"onRender");d(this,"onWantsTapGesture",t=>{if(this.getIntersectObject(t))return!1});d(this,"onWantsUpdateCameraDistance",()=>{if(this.camera.isPerspectiveCamera){const t=this.camera;this.helperObject3D.setScaleByCamera(t)}});d(this,"getBox",()=>this.boundingBox?this.boundingBox:(this.boundingBox=wn(this.originObject3D),this.boundingBox));var h,u,f;this.hooks=(h=t.sharedHooks)!=null?h:new ut,this.internalHooks=(u=t.sharedInternalHooks)!=null?u:new ut,this.camera=t.camera,this.model=t.model,this.originObject3D=t.originObject3D,this.helperObject3D=t.helperObject3D,this.container=t.container,this.scene=t.scene,this.domEvents=new Re(t.camera,t.container),this.onRender=(f=t.onRender)!=null?f:()=>{},this.config=e!=null?e:{},this.initialHelperPosition(),this.initialHelperQuaternion(),this.onWantsUpdateCameraDistance(),this.enable();const i=this.onSetOriginObjectScale.bind(this),s=this.onSetOriginObjectRotate.bind(this),o=this.onSetOriginObjectPosition.bind(this),r=this.onApplyOriginObjectScale.bind(this),a=this.onApplyOriginObjectRotate.bind(this),l=this.onApplyOriginObjectPosition.bind(this),c=this.initialHelperPosition.bind(this);this.internalHooks.on("setObjectPosition",this.onWantsUpdateCameraDistance),this.internalHooks.on("initialHelperPosition",this.onWantsUpdateCameraDistance),this.internalHooks.on("initialHelperPosition",c),this.internalHooks.on("setObjectScale",i),this.internalHooks.on("setObjectRotate",s),this.internalHooks.on("setObjectPosition",o),this.internalHooks.on("applyObjectPosition",l),this.internalHooks.on("applyObjectRotate",a),this.internalHooks.on("applyObjectScale",r),this.disposers.push(()=>{this.internalHooks.off("setObjectPosition",this.onWantsUpdateCameraDistance),this.internalHooks.off("initialHelperPosition",this.onWantsUpdateCameraDistance),this.internalHooks.off("initialHelperPosition",c),this.internalHooks.off("setObjectScale",i),this.internalHooks.off("setObjectRotate",s),this.internalHooks.off("setObjectPosition",o),this.internalHooks.off("applyObjectPosition",l),this.internalHooks.off("applyObjectRotate",a),this.internalHooks.off("applyObjectScale",r)})}initialHelperPosition(){this.helperObject3D.initialPosition(this.calculateOffset(this.config.offset))}initialHelperQuaternion(){var a,l,c;this.helperObject3D.initQuaternion();const t=(a=this.config.xAxis)!=null?a:new y.Vector3(1,0,0),e=(l=this.config.yAxis)!=null?l:new y.Vector3(0,1,0),i=(c=this.config.zAxis)!=null?c:new y.Vector3(0,0,1),s=new y.Quaternion;s.setFromUnitVectors(new y.Vector3(1,0,0),t.normalize());const o=new y.Quaternion;o.setFromUnitVectors(new y.Vector3(0,1,0),e.normalize());const r=new y.Quaternion;r.setFromUnitVectors(new y.Vector3(0,0,1),i.normalize()),this.helperObject3D.quaternion.premultiply(s),this.helperObject3D.quaternion.premultiply(o),this.helperObject3D.quaternion.premultiply(r)}enable(){this.enabled||(this.enabled=!0,this.scene.add(this.helperObject3D),this.helperObject3D.enable(),this.render())}disable(){this.enabled&&(this.enabled=!1,this.helperObject3D.disable(),this.render())}show(){this.helperObject3D.show(),this.render()}hide(){this.helperObject3D.hide(),this.render()}dispose(){var t;(t=this.disposers)==null||t.forEach(e=>e==null?void 0:e()),this.helperObject3D.dispose(),this.render()}applyHelperMatrix4(t){this.helperObject3D.applyMatrix4(t)}applyHelperQuaternion(t,e){this.helperObject3D.applyHelperQuaternion(t,e)}applyHelperScaleMatrix4(t,e){this.helperObject3D.applyHelperScaleMatrix4(t,e)}onWantsGesture(t,e,i){if(this.isDragging)return!1}onIntersectionOnModelUpdate(t){}onApplyOriginObjectScale(t){this.applyHelperScaleMatrix4(t.matrix,t.origin)}onApplyOriginObjectRotate(t){this.applyHelperQuaternion(t.quaternion,t.origin)}onApplyOriginObjectPosition(t){this.applyHelperMatrix4(t.matrix)}onSetOriginObjectScale(t){this.helperObject3D.scale.copy(t),this.updateOffsetByScale(t)}onSetOriginObjectRotate(t,e){this.helperObject3D.setHelperQuaternion(t,e)}onSetOriginObjectPosition(t){this.helperObject3D.position.copy(t.clone().add(this.calculateOffset(this.config.offset)))}render(){this.onRender()}updateOffsetByScale(t){if(this.boundingBox&&this.config.offset){const e=this.originObject3D.position,i=new y.Vector3().subVectors(this.boundingBox.max,e).multiply(t).add(e),s=new y.Vector3().subVectors(this.boundingBox.min,e).multiply(t).add(e),o=this.calculateOffset(this.config.offset,{min:s,max:i});this.helperObject3D.initialPosition(o)}}hoverListener(t,e=16777215,i=1){const s=pi(t).filter(ke),o=[];for(const r of s)if(r.material||r instanceof y.Group){const a=r instanceof y.Group?r.children.filter(f=>f instanceof y.Mesh):[r];a.forEach(f=>{f.__originalColor__=f.material.color.clone(),f.__originalOpacity__=f.material.opacity});const l=()=>{a.forEach(f=>{f.material.color.set(e),f.material.opacity=i}),this.render()},c=()=>{a.forEach(f=>{f.material.color.copy(f.__originalColor__),f.material.opacity=f.__originalOpacity__}),this.render()},h=()=>{this.isDragging||l()},u=()=>{this.isDragging||c()};for(const f of a)this.domEvents.addEventListener(f,"mouseover",h),this.domEvents.addEventListener(f,"mouseout",u),this.hooks.on("moveStart",l),this.hooks.on("moveEnd",c),this.hooks.on("rotateEnd",c),o.push(()=>{this.domEvents.removeEventListener(f,"mouseover",h),this.domEvents.removeEventListener(f,"mouseout",u),this.hooks.off("moveStart",l),this.hooks.off("moveEnd",c),this.hooks.off("rotateEnd",c)})}return()=>o.forEach(r=>r==null?void 0:r())}getIntersectObject(t){const e=this.camera.position,i=this.helperObject3D;if(!i)return;const s=this.helperObject3D.raycasterIntersectObject(t)[0];if(!s)return;const o=s;if(o.object=i,this.model.intersectRaycaster){const r=this.model.intersectRaycaster(t)[0];if(r&&r.point.distanceTo(e)<o.point.distanceTo(e))return}return o.object}calculateOffset(t,e){const i=new y.Vector3(0,0,0);if(!t)return i;const s=()=>e||this.getBox();if(typeof t.x=="number")i.setX(t.x);else if(typeof t.x=="object"){const o=s();i.setX((o.max.x-o.min.x)*t.x.percents)}if(typeof t.y=="number")i.setY(t.y);else if(typeof t.y=="object"){const o=s();i.setY((o.max.y-o.min.y)*t.y.percents)}if(typeof t.z=="number")i.setZ(t.z);else if(typeof t.z=="object"){const o=s();i.setZ((o.max.z-o.min.z)*t.z.percents)}return i}};const dv=new y.Vector3;function Xi(n){var f;const{raycaster:t,line:e,clampToLine:i=!0}=n;if(((f=t.camera)==null?void 0:f.type)==="OrthographicCamera"){const g=t.ray.origin.clone();return e.closestPointToPoint(g,!1,new y.Vector3)}const s=new y.Plane().setFromNormalAndCoplanarPoint(t.ray.direction.clone().normalize(),t.ray.origin),o=s.projectPoint(e.start,new y.Vector3),r=s.projectPoint(e.end,new y.Vector3),a=new y.Line3(o,r),l=a.closestPointToPoint(t.ray.origin,i,dv),c=l.distanceTo(r),h=l.distanceTo(o),u=a.distance();if(c>h&&c>u){const g=-l.distanceTo(o)/u,v=e.start.clone().sub(e.end).normalize();return e.start.sub(v.clone().multiplyScalar(g*e.distance()))}else{const g=l.distanceTo(o)/u;return new y.Vector3().lerpVectors(e.start,e.end,g)}}let uv=class extends bs{constructor(...e){super(...e);d(this,"name","MoveController");d(this,"startInfo");d(this,"_moveByMouse",{enabled:!1});d(this,"mouseInfo");d(this,"mousedownEventListenerDisposer");const i=this.helperObject3D;this.hoverListener([i.xArrow,i.yArrow,i.zArrow]);const s=this.dragStart.bind(this),o=this.dragging.bind(this),r=this.dragEnd.bind(this),a=this.show.bind(this),l=this.hide.bind(this);this.domEvents.addEventListener(this.helperObject3D,"mousedown",s),document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.hooks.on("rotateStart",l),this.hooks.on("rotateEnd",a),this.hooks.on("scaleStart",l),this.hooks.on("scaleEnd",a),this.hooks.on("moveByMouseEnable",l),this.hooks.on("moveByMouseDisable",a),this.disposers.push(()=>{this.domEvents.removeEventListener(this.helperObject3D,"mousedown",s),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.hooks.off("rotateStart",l),this.hooks.off("rotateEnd",a),this.hooks.off("scaleStart",l),this.hooks.off("scaleEnd",a),this.hooks.off("moveByMouseEnable",l),this.hooks.off("moveByMouseDisable",a)}),this.moveByMouseEnable&&this.moveByMouse()}get moveByMouseEnable(){return this._moveByMouse.enabled}dispose(){var e;super.dispose(),(e=this.disposers)==null||e.forEach(i=>i==null?void 0:i())}moveByMouse(e){this._moveByMouse={enabled:!0,useFaceNormal:e==null?void 0:e.useFaceNormal},this.preventTapDefaultEvent=!0;const i=this.handleMouseDown.bind(this),s=this.handleMouseUp.bind(this);this.hooks.emit("moveByMouseEnable"),setTimeout(()=>{this.container.addEventListener("mousedown",i),this.container.addEventListener("mouseup",s)}),this.mousedownEventListenerDisposer=()=>{this.container.removeEventListener("mousedown",i),this.container.removeEventListener("mouseup",s)}}disableMoveByMouse(){var e;this._moveByMouse={enabled:!1},this.preventTapDefaultEvent=!1,this.hooks.emit("moveByMouseDisable"),(e=this.mousedownEventListenerDisposer)==null||e.call(this)}onIntersectionOnModelUpdate(e){var r,a,l;if(!this.moveByMouseEnable)return;const{point:i,face:s}=e;if(!this.hooks.emit("wantToMove",i)){if(this.originObject3D.position.copy(i),(this._moveByMouse.useFaceNormal===!0||typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.enable!==!1)&&s!=null&&s.normal){const c=(()=>typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.alignmentVector?this._moveByMouse.useFaceNormal.alignmentVector:{x:0,y:1,z:0})(),h=new y.Vector3((r=c.x)!=null?r:0,(a=c.y)!=null?a:0,(l=c.z)!=null?l:0),u=(()=>typeof this._moveByMouse.useFaceNormal=="object"&&this._moveByMouse.useFaceNormal.fixedFaceNormal?this._moveByMouse.useFaceNormal.fixedFaceNormal(s.normal):s.normal)();this.originObject3D.quaternion.setFromUnitVectors(h,u),this.internalHooks.emit("setObjectRotate",this.originObject3D.quaternion.clone())}this.internalHooks.emit("setObjectPosition",i),this.hooks.emit("move",i)}}handleMouseDown(e){const{x:i,y:s}=e;this.mouseInfo={x:i,y:s,mouseDownTimestamp:Date.now()}}handleMouseUp(e){if(!this.mouseInfo)return;const{x:i,y:s}=e;this.mouseInfo.x===i&&this.mouseInfo.y===s&&Date.now()-this.mouseInfo.mouseDownTimestamp<500&&(this.disableMoveByMouse(),this.mouseInfo=void 0)}dragStart(e){if(this.moveByMouseEnable||this.isDragging)return;const i=e==null?void 0:e.intersect;if(!i)return this.dragEnd();const s=(i==null?void 0:i.object).direction;if(!s)return this.dragEnd();const o=new y.Vector3(1,0,0).applyQuaternion(this.helperObject3D.quaternion),r=new y.Vector3(0,1,0).applyQuaternion(this.helperObject3D.quaternion),a=new y.Vector3(0,0,1).applyQuaternion(this.helperObject3D.quaternion),l=(()=>{switch(s){case"x":return o;case"y":return r;case"z":return a}})(),c=i.point.clone(),h=new y.Line3(c.clone().sub(l.normalize()),c.clone().add(l.normalize()));this.startInfo={startVectorProject:c,line:h},this.helperObject3D.showDraggingHelper([s]),this.hooks.emit("moveStart"),this.isDragging=!0}dragging(e){if(!this.isDragging||!this.startInfo)return;const i=bo(this.camera,e,this.container);return i?(this.move(i),!1):this.dragEnd()}move(e){if(!this.startInfo)return this.dragEnd();const{line:i,startVectorProject:s}=this.startInfo,o=this.originObject3D,r=Xi({raycaster:e,line:i,clampToLine:!1}),a=r.clone().sub(s),l=new y.Matrix4;l.setPosition(a);const c=o.position.clone().applyMatrix4(l);this.hooks.emit("wantToMove",c)||(o.applyMatrix4(l),s.copy(r),this.internalHooks.emit("applyObjectPosition",{matrix:l}),this.hooks.emit("move",c))}dragEnd(){this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.hooks.emit("moveEnd"))}};class ys{constructor(t,e,i,s,o,r,a){d(this,"helperController");d(this,"five");d(this,"onFiveWantsUpdateCameraDistance",()=>{var t,e;this.helperController&&((e=(t=this.helperController).onWantsUpdateCameraDistance)==null||e.call(t))});d(this,"onFiveWantsTapGesture",t=>{if(!this.helperController)return;if(this.helperController.preventTapDefaultEvent)return!1;const e=this.helperController.onWantsTapGesture(t);return this.five.needsRender=!0,e});d(this,"onFiveWantsGesture",(...t)=>{if(!this.helperController)return;const e=this.helperController.onWantsGesture(...t);return this.five.needsRender=!0,e});d(this,"onFiveIntersectionOnModelUpdate",(...t)=>{this.helperController&&this.helperController.onIntersectionOnModelUpdate(...t)});const{camera:l,model:c,scene:h}=t,u=t.getElement();if(this.five=t,!l||!c||!u||!h)return;const f=()=>{t.needsRender=!0};this.helperController=new e({camera:l,model:c,originObject3D:i,helperObject3D:s,container:u,scene:h,onRender:f,sharedHooks:r,sharedInternalHooks:a},o),t.on("wantsTapGesture",this.onFiveWantsTapGesture),t.on("wantsGesture",this.onFiveWantsGesture),t.on("intersectionOnModelUpdate",this.onFiveIntersectionOnModelUpdate),t.on("cameraFovUpdate",this.onFiveWantsUpdateCameraDistance),t.on("cameraPositionUpdate",this.onFiveWantsUpdateCameraDistance)}dispose(){var t;this.five.off("wantsTapGesture",this.onFiveWantsTapGesture),this.five.off("wantsGesture",this.onFiveWantsGesture),this.five.off("intersectionOnModelUpdate",this.onFiveIntersectionOnModelUpdate),this.five.off("cameraFovUpdate",this.onFiveWantsUpdateCameraDistance),this.five.off("cameraPositionUpdate",this.onFiveWantsUpdateCameraDistance),(t=this.helperController)==null||t.dispose()}}const Zr="Object3DHelper@v1.0.1",fv=()=>{console.error(`${Zr} is disposed`)},gv=()=>{console.warn(`${Zr} is disabled`)},mv=()=>{console.error(`${Zr} is disabled`)};class pv{constructor(t){d(this,"controllers",{});d(this,"state",{visible:!0,enabled:!0,disposed:!1});d(this,"hooks",new ut);d(this,"eventListener",{});t&&this.addControllers(t),this.setState(this.state)}show(t){return H(this,null,function*(){this.setState({visible:!0},t)})}hide(t){return H(this,null,function*(){this.setState({visible:!1},t)})}enable(t){this.setState({enabled:!0},t)}disable(t){this.setState({enabled:!1},t)}dispose(){this.setState({disposed:!0})}setState(t,e){if(this.state.disposed)return fv();if(!this.state.enabled&&t.enabled!==!0&&t.disposed!==!0)return mv();const i=x({},this.state);this.state=x(x({},this.state),t),t.disposed!==void 0&&t.disposed!==i.disposed&&t.disposed&&this.handleDispose(),t.visible!==void 0&&this.handleVisible(t.visible),t.enabled!==void 0&&this.handleEnable(t.enabled),this.hooks.emit("stateChange",{state:this.state,prevState:i})}addControllers(t){this.controllers=x(x({},this.controllers),t),this.setState(this.state)}getCurrentState(){return this.state}handleEnable(t,e=!0){t?(this.everyControllerDo(i=>{i.enable()}),this.hooks.emit("enable",{userAction:e})):(this.everyControllerDo(i=>{i.disable()}),this.hooks.emit("disable",{userAction:e})),this.state.enabled=t}handleVisible(t,e=!0){t?(this.everyControllerDo(i=>{i.show()}),this.actionIfStateIsEnabled(()=>this.hooks.emit("show",{userAction:e}))):(this.everyControllerDo(i=>{i.hide()}),this.actionIfStateIsEnabled(()=>this.hooks.emit("hide",{userAction:e}))),this.state.visible=t}everyControllerDo(t){Object.values(this.controllers).forEach(e=>{e&&t(e)})}handleDispose(){var t,e;Object.values(this.controllers).forEach(i=>{i==null||i.dispose()});for(const i in this.controllers){if(!i)continue;const s=i;(e=(t=this.eventListener)[s])==null||e.call(t)}}actionIfStateIsEnabled(t,e){if(this.state.enabled)return t();e!=null&&e.warnLog&&gv()}}function Jr(n){return n*180/Math.PI}function qr(n){return n*Math.PI/180}const Kr=new y.Quaternion;class vv extends bs{constructor(...e){var c,h,u;super(...e);d(this,"name","RotateController");d(this,"startInfo");d(this,"removeListener");const i=this.helperObject3D;this.hoverListener([(c=i.xCircle)==null?void 0:c.circle,(h=i.yCircle)==null?void 0:h.circle,(u=i.zCircle)==null?void 0:u.circle].filter(Boolean));const s=this.dragStart.bind(this),o=this.dragging.bind(this),r=this.dragEnd.bind(this),a=this.show.bind(this),l=this.hide.bind(this);this.domEvents.addEventListener(this.helperObject3D,"mousedown",s),document.addEventListener("mousemove",o),document.addEventListener("mouseup",r),this.hooks.on("moveStart",l),this.hooks.on("moveEnd",a),this.hooks.on("scaleStart",l),this.hooks.on("scaleEnd",a),this.hooks.on("moveByMouseEnable",l),this.hooks.on("moveByMouseDisable",a),this.removeListener=()=>{this.domEvents.removeEventListener(this.helperObject3D,"mousedown",s),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.hooks.off("moveStart",l),this.hooks.off("moveEnd",a),this.hooks.off("scaleStart",l),this.hooks.off("scaleEnd",a),this.hooks.off("moveByMouseEnable",l),this.hooks.off("moveByMouseDisable",a)}}get rotateCenter(){return this.helperObject3D.position.clone()}setRotateAngle(e){const{x:i=0,y:s=0,z:o=0}=e,r=new y.Euler(qr(i),qr(s),qr(o)),a=new y.Quaternion().setFromEuler(r);if(this.hooks.emit("wantToRotate",a))return;const{originObject3D:c,rotateCenter:h}=this;Fc(c,a,h),this.internalHooks.emit("setObjectRotate",a,h),this.hooks.emit("rotate",a),this.render()}dispose(){this.removeListener(),super.dispose()}onApplyOriginObjectRotate(e){this.isDragging||super.onApplyOriginObjectRotate(e)}onApplyOriginObjectScale(e){}dragStart(e){if(this.isDragging)return;const i=e==null?void 0:e.intersect;if(!i)return this.dragEnd();const s=(i==null?void 0:i.object).direction;if(!s)return this.dragEnd();const o=i.point,r=this.getAngleHelper(s);this.setTipsAngle(0);const a=o.clone();a.y+=.2,this.setTipsPosition(a);const l=this.helperObject3D.quaternion.clone(),c=(()=>{if(s==="x")return new y.Vector3(1,0,0).applyQuaternion(l);if(s==="y")return new y.Vector3(0,1,0).applyQuaternion(l);if(s==="z")return new y.Vector3(0,0,1).applyQuaternion(l)})(),h=new y.Plane().setFromNormalAndCoplanarPoint(c,o),f=h.projectPoint(o.clone(),new y.Vector3).clone().sub(this.rotateCenter),g=f.angleTo(r.baseAxes.clone().applyQuaternion(l));this.setAngleHelperStart(s,g),this.setAngleHelperLength(s,0),this.startInfo={direction:s,startVector:f,plane:h,angleHelper:r,angle:0,helperQuaternion:l.clone()},Kr.copy(l),this.helperObject3D.showDraggingHelper([s]),this.hooks.emit("rotateStart"),this.isDragging=!0}dragging(e){if(!this.isDragging)return;const i=bo(this.camera,e,this.container);return i?(this.rotate(i),!1):this.dragEnd()}rotate(e){if(!this.startInfo)return this.dragEnd();const{startVector:i,plane:s,angleHelper:o,direction:r,helperQuaternion:a}=this.startInfo,{originObject3D:l}=this,c=e.ray.intersectPlane(s,new y.Vector3);if(!c)return;const h=this.rotateCenter.clone(),f=s.projectPoint(c.clone(),new y.Vector3).clone().sub(h);if(i.angleTo(f)===0)return;const g=new y.Quaternion().setFromUnitVectors(i.clone().normalize(),f.clone().normalize()),v=l.quaternion.clone().premultiply(g);if(this.hooks.emit("wantToRotate",v))return;const A=new y.Euler().setFromQuaternion(new y.Quaternion().setFromUnitVectors(i.clone().normalize().applyQuaternion(a.clone().inverse()),f.clone().normalize().applyQuaternion(a.clone().inverse())),`${r.toUpperCase()}${"XZY".replace(r.toUpperCase(),"")}`)[r]*o.angleDirection;if(this.startInfo.angle+=A,this.setAngleHelperLength(r,this.startInfo.angle),this.setTipsAngle(Jr(this.startInfo.angle)),h){const w=new y.Vector3().subVectors(l.position,h).applyQuaternion(g).add(h);l.position.copy(w)}l.applyQuaternion(g),Kr.premultiply(g),this.internalHooks.emit("applyObjectRotate",{quaternion:g,origin:h}),this.hooks.emit("rotate",l.quaternion),this.startInfo.startVector=f}dragEnd(){this.isDragging&&(this.internalHooks.emit("setObjectRotate",Kr,this.rotateCenter),this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.hooks.emit("rotateEnd"))}getAngleHelper(e){var i,s,o;switch(e){case"x":return(i=this.helperObject3D.xCircle)==null?void 0:i.angleSector;case"y":return(s=this.helperObject3D.yCircle)==null?void 0:s.angleSector;case"z":return(o=this.helperObject3D.zCircle)==null?void 0:o.angleSector}}setAngleHelperStart(e,i){const s=this.getAngleHelper(e);if(!s){console.warn("angleHelper is undefined");return}if(s instanceof y.Mesh&&s.geometry instanceof y.CircleGeometry){const{radius:o,segments:r,thetaLength:a}=s.geometry.parameters;s.geometry=new y.CircleGeometry(o,r,i,a)}else console.warn("only support THREE.CircleGeometry")}setAngleHelperLength(e,i){const o=i>=0?Math.max(i,.001):Math.min(i,-.001),r=this.getAngleHelper(e);if(r instanceof y.Mesh&&r.geometry instanceof y.CircleGeometry){const{radius:a,thetaStart:l}=r.geometry.parameters,c=Math.ceil(Math.abs(o)*(40/(2*Math.PI)));r.geometry=new y.CircleGeometry(a,c,l,o)}else console.warn("only support THREE.CircleGeometry")}setTipsAngle(e){var s;const i=(s=this.helperObject3D.angleTips)==null?void 0:s.element;i&&(i.innerText=`${e.toFixed(0)}°`)}setTipsPosition(e){const i=this.helperObject3D.angleTips;if(!i)return;const s=e.project(this.camera),{x:o,y:r,z:a}=s;if(a>1)return;const l=(o+1)/2*100+"%",c=(-r+1)/2*100+"%";i.setLeftTop(l,c)}}class Av extends bs{constructor(...e){super(...e);d(this,"startInfo");d(this,"name","RectangleScaleController")}enable(){this.helperObject3D.enable(),super.enable()}disable(){this.helperObject3D.disable(),super.disable()}show(){this.helperObject3D.show(),super.show()}hide(){this.helperObject3D.hide(),super.hide()}onApplyOriginObjectPosition(e){this.isDragging||super.onApplyOriginObjectPosition(e)}onApplyOriginObjectScale(e){this.helperObject3D.applyHelperScaleMatrix4(e.matrix,e.origin)}getDragPlane(){const e=new y.Plane,i=this.helperObject3D.cornerPositions;if(i.length!==0)return i.length<3?e.setFromNormalAndCoplanarPoint(this.originObject3D.getWorldDirection(new N.Vector3),i[0]):e.setFromCoplanarPoints(i[0],i[1],i[2]),e}dragStart(e,i){var o,r;(r=(o=this.helperObject3D).updatePoints)==null||r.call(o);const s=this.getDragPlane();if(!s)return this.dragEnd();this.startInfo={startPoint:{position:i.position.clone(),direction:i.direction},plane:s},this.hooks.emit("scaleStart"),this.render(),this.isDragging=!0}dragging(e){if(!this.isDragging)return;const i=bo(this.camera,e,this.container);if(!i)return this.dragEnd();this.scale(i)}scale(e){var Y,G;if(!this.startInfo)return;const i=this.originObject3D,{startPoint:s,plane:o}=this.startInfo,r=this.helperObject3D.cornerPositions;if(r.length<4)return this.dragEnd();const a=e.ray.intersectPlane(o,new N.Vector3);if(!a||ev(a,this.camera.position))return;const l=new N.Vector3().addVectors(r[0],r[2]).divideScalar(2),{position:c,direction:h}=s,u=new N.Vector3().subVectors(r[1],r[0]),f=new N.Vector3().subVectors(r[3],r[0]),g=Q=>{const W=new N.Vector3(0,0,0);if(!this.startInfo)return W;const _=(Q==="ew"?u:f).clone(),U=c.clone().projectOnVector(_),F=a.clone().projectOnVector(_),X=l.clone().projectOnVector(_);if(F.equals(U))return W;if(Q==="ns"&&typeof this.startInfo.dragPointInCenterBottom!="boolean"){const le=new N.Vector3().subVectors(F,X),ae=le.x<0&&_.x>=0,Ie=le.y<0&&_.y>=0,Ae=le.z<0&&_.z>=0;this.startInfo.dragPointInCenterBottom=ae||Ie||Ae}if(Q==="ew"&&typeof this.startInfo.dragPointInCenterLeft!="boolean"){const le=new N.Vector3().subVectors(F,X),ae=le.x<0&&_.x>=0,Ie=le.y<0&&_.y>=0,Ae=le.z<0&&_.z>=0;this.startInfo.dragPointInCenterLeft=ae||Ie||Ae}const J=new N.Vector3().subVectors(F,U),q=J.length();return q>.3?(console.warn("offset.length() > 0.3, skipped",q),W):J},v=g("ew"),p=g("ns"),m=()=>{const Q=v;this.helperObject3D.cornerPositions.forEach((W,_)=>{var U;(U=this.startInfo)!=null&&U.dragPointInCenterLeft?(_===0||_===3)&&W.add(Q):(_===1||_===2)&&W.add(Q)})},A=()=>{const Q=p;this.helperObject3D.cornerPositions.forEach((W,_)=>{var U;(U=this.startInfo)!=null&&U.dragPointInCenterBottom?(_===0||_===1)&&W.add(Q):(_===2||_===3)&&W.add(Q)})};switch(h){case"ew":m();break;case"ns":A();break;case"nesw":case"nwse":m(),A()}const w=new N.Vector3().subVectors(r[1],r[0]).length()/u.length(),I=new N.Vector3().subVectors(r[3],r[0]).length()/f.length(),P=new N.Vector3(w,I,1),k=new y.Matrix4().scale(P);i.isCSS3DObjectPlus?i.applyScaleMatrix4(k):i.scale.applyMatrix4(k),s.position.copy(a);const M=new N.Vector3().addVectors(r[0],r[2]).divideScalar(2),T=new N.Vector3().subVectors(M,l),R=new y.Matrix4().setPosition(T);i.applyMatrix4(R),(Y=this.helperObject3D.css3DInstance)==null||Y.css3DObject.applyMatrix4(R),(G=this.helperObject3D.plane)==null||G.applyMatrix4(R),this.internalHooks.emit("applyObjectScale",{matrix:k}),this.internalHooks.emit("applyObjectPosition",{matrix:R}),this.render()}dragEnd(){this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.hooks.emit("scaleEnd"),this.render())}}class bv extends Av{constructor(...e){super(...e);d(this,"name","CSS3DScaleController");this.addHTMLEventListener()}addHTMLEventListener(){this.helperObject3D.points.forEach(e=>{if(!e)return;const i=e.point,s=a=>this.dragStart(a,e),o=this.dragging.bind(this),r=this.dragEnd.bind(this);i.addEventListener("dragstart",s),i.addEventListener("drag",o),i.addEventListener("dragend",r)})}}const Qt=document.createElement("div");Qt.classList.add("behindFiveElement"),Qt.style.position="absolute",Qt.style.top="0",Qt.style.left="0",Qt.style.width="100%",Qt.style.height="100%",Qt.style.pointerEvents="none";function Qc(n){var i,s,o,r,a;const t=(a=(s=$r(n.getElement()))!=null?s:$r((i=n.getElement())==null?void 0:i.parentElement))!=null?a:$r((r=(o=n.getElement())==null?void 0:o.parentElement)==null?void 0:r.parentElement),e=t==null?void 0:t.parentElement;if(e)return e.contains(Qt)||t.parentElement.insertBefore(Qt,t),Qt;console.error("Can not find a valid element to insert behindFiveElement. How to fix it: https://github.com/realsee-developer/dnalogel/tree/main/plugins/src/CSS3DRenderPlugin/README.md")}function $r(n){var a;if(!n)return;const t=(a=n.style.position)!=null?a:getComputedStyle(n).position;if(t!=="fixed"&&t!=="absolute"&&t!=="relative")return;const e=getComputedStyle(n),i=e.backgroundColor,s=e.backgroundImage;if(!(i!=="transparent"&&i!=="rgba(0, 0, 0, 0)"&&i!==""||s!=="none"&&s!==""))return n}class yv extends bs{constructor(...e){super(...e);d(this,"name","BoundingBoxController")}}class wv extends Jp{constructor(e,i){super(e,i);d(this,"scaleMeshes",[]);d(this,"positions",[]);i&&(this.positions=i.positions)}initialPosition(e){this.position.copy(this.originObject3D.position),this.scaleMeshes.length&&this.remove(...this.scaleMeshes);const i=typeof this.positions=="function"?this.positions():this.positions;i&&(this.scaleMeshes=i.map(s=>{const o=Cv();return o.position.copy(s.handlePosition),o.scalePosition=s,o}),this.add(...this.scaleMeshes))}setScaleByCamera(e){this.scaleMeshes.forEach(i=>{i.scale.setScalar(Yr(e,i.scalePosition.handlePosition.clone().applyMatrix4(this.matrixWorld)))})}}function Cv(){const t=new y.BoxGeometry(.05,.05,.05),e=new y.MeshBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1,transparent:!0,side:y.DoubleSide}),i=new y.Mesh(t,e);return i.renderOrder=10,i}class Pv extends bs{constructor(...e){super(...e);d(this,"name","ScaleController");d(this,"startInfo");d(this,"dragStart",e=>{if(this.isDragging)return;this.isDragging=!0;const{intersect:i}=e,s=this.camera.position,o=i.object,r=o.scalePosition.basePosition.clone(),l=o.scalePosition.handlePosition.clone().clone().sub(r).clone(),c=new y.Line3(r,r.clone().add(l.normalize().multiplyScalar(5)));c.applyMatrix4(this.helperObject3D.matrixWorld);const h=new y.Raycaster(s,i.point.clone().sub(s)),u=Xi({raycaster:h,line:c});this.startInfo={line:c,scaleStartPoint:u,draggingObject:o},this.hooks.emit("scaleStart")});d(this,"dragging",e=>{if(!this.isDragging||!this.startInfo)return;const i=bo(this.camera,e,this.container);return i?(this.scale(i),!1):this.dragEnd()});d(this,"scale",e=>{var c,h;if(!this.startInfo)return;const{line:i,scaleStartPoint:s,draggingObject:o}=this.startInfo,{scalePosition:r}=o,{basePosition:a}=r,l=Xi({raycaster:e,line:i});l.applyMatrix4(new y.Matrix4().getInverse(this.helperObject3D.matrixWorld.clone())),(h=(c=this.config)==null?void 0:c.scaleCallback)==null||h.call(c,{ratio:l.distanceTo(a)/s.distanceTo(a),intersectPoint:l,scalePosition:r}),o.position.copy(l.clone())});d(this,"dragEnd",()=>{this.isDragging&&(this.startInfo=void 0,this.isDragging=!1,this.internalHooks.emit("initialHelperPosition"),this.hooks.emit("scaleEnd"))});this.domEvents.addEventListener(this.helperObject3D,"mousedown",this.dragStart),document.addEventListener("mousemove",this.dragging),document.addEventListener("mouseup",this.dragEnd)}initialHelperQuaternion(){this.helperObject3D.initQuaternion()}initialHelperPosition(){this.helperObject3D.initialPosition();const e=this;e.offHoverListener&&e.offHoverListener(),e.offHoverListener=this.hoverListener(this.helperObject3D.scaleMeshes)}setScale(e){var l,c,h;let i=1,s=1,o=1;typeof e=="number"?(i=e,s=e,o=e):typeof e=="object"&&(i=(l=e.x)!=null?l:1,s=(c=e.y)!=null?c:1,o=(h=e.z)!=null?h:1);const r=new y.Vector3(i,s,o);this.hooks.emit("wantToScale",r)||(this.originObject3D.scale.copy(r),this.internalHooks.emit("setObjectScale",r),this.hooks.emit("scale",r),this.render())}}function Pn(n){return H(this,null,function*(){return new Promise(t=>{if(Iv(n))t();else{const e=i=>{const s=Bt(n);i===s&&(n.off("modelLoaded",e),t())};n.on("modelLoaded",e)}})})}function Iv(n){var t;return(t=Bt(n))==null?void 0:t.loaded}const ea="Object3DHelperPlugin",yo=ea,Mv=()=>{console.error(`${yo} is disposed`)},Ev=()=>{console.warn(`${yo} is disabled`)},kv=()=>{console.error(`${yo} is disabled`)};class ta extends Di{constructor(e){super(e);d(this,"name",ea);d(this,"state",{visible:!0,enabled:!0,disposed:!1});d(this,"objectHelperMap",new Map);d(this,"css3DObjectParentMap",new Map);d(this,"css3DRender");this.five=e,this.css3DRender=new Sn(this.five.scene),console.warn("Object3DHelper: 使用此插件,需要在初始化five时,设置five参数: { backgroundAlpha: 0, backgroundColor: 0x000000 }"),Object.assign(window,{[`__${ea.toUpperCase()}_DEBUG__`]:this})}show(e){return H(this,null,function*(){this.setState({visible:!0},e)})}hide(e){return H(this,null,function*(){this.setState({visible:!1},e)})}enable(e){this.setState({enabled:!0},e)}disable(e){this.setState({enabled:!1},e)}dispose(){this.setState({disposed:!0})}setState(e,i){if(this.state.disposed)return Mv();if(!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return kv();const s=x({},this.state);this.state=x(x({},this.state),e),e.disposed!==void 0&&e.disposed!==s.disposed&&e.disposed&&this.handleDispose(),e.visible!==void 0&&e.visible!==s.visible&&this.handleVisible(e.visible),e.enabled!==void 0&&e.enabled!==s.enabled&&this.handleEnable(e.enabled),this.hooks.emit("stateChange",{state:this.state,prevState:s})}getObject3DHelper(e){return this.objectHelperMap.get(e)}addObject3DHelper(e,i={}){var A;if(!e){console.error("Object3D is undefined");return}if(this.objectHelperMap.has(e)){console.warn(`Object3DHelperPlugin: object3D ${e.name} is already has helper`);return}const s=new pv,o=[],r=(A=this.five.getElement())==null?void 0:A.parentElement,a=this.five.camera,c=x(x({},{moveHelper:!0,rotateHelper:!0,scaleHelper:!0,boundingBoxHelper:!1,positionFrom:"objectPosition"}),i),{moveHelper:h,rotateHelper:u,scaleHelper:f,boundingBoxHelper:g}=c,v=new ut,p=new ut,m=w=>{if(w)return typeof w=="boolean"?w:w.enable};if(m(h)){const w=x(x({},this.getConfig(c.moveHelper)),c),I=new tv(e,x({},w)),P=new ys(this.five,uv,e,I,w,v,p);s.addControllers({moveController:P.helperController}),o.push(()=>P.dispose())}if(m(u)){const w=x(x({},this.getConfig(c.rotateHelper)),c),I=new sv(e,x({container:r},w)),P=new ys(this.five,vv,e,I,w,v,p);s.addControllers({rotateController:P.helperController}),o.push(()=>P.dispose())}if(m(g)){const w=new hv(e),I=new ys(this.five,yv,e,w,void 0,v,p);s.addControllers({boundingBoxController:I.helperController})}if(m(f))if(e.isCSS3DObjectPlus&&r){const w=new cv(e,r,a,this.five.scene),I=new ys(this.five,bv,e,w,void 0,v,p);s.addControllers({scaleController:I.helperController}),o.push(()=>I.dispose()),Pn(this.five).then(()=>{var P,k;if(e.isCSS3DObjectPlus){const M=e;if(!M||M.mode!=="front")return;const T=(P=this.css3DRender.behindModeCSS3DRenderer.wrapper)!=null?P:Qc(this.five);T&&(this.css3DObjectParentMap.set(M,M.parent),M.removeFromParent(),this.css3DRender.behindModeCSS3DRenderer.setWrapper(T),(k=this.css3DRender.getBehindCSS3DObjectGroup())==null||k.add(M),this.css3DRender.render(this.five.camera))}})}else{const w=x(x({},this.getConfig(c.scaleHelper)),c),I=new wv(e,w),P=new ys(this.five,Pv,e,I,w,v,p);s.addControllers({scaleController:P.helperController}),o.push(()=>P.dispose())}return this.objectHelperMap.set(e,{helper:s,disposers:o}),s.controllers}removeObject3DHelper(e){if(!this.objectHelperMap.has(e))return;const{helper:i,disposers:s}=this.objectHelperMap.get(e);if(i){if(e.isCSS3DObjectPlus){const o=e,r=this.css3DObjectParentMap.get(o);r&&r.add(o),this.css3DRender.render(this.five.camera)}this.objectHelperMap.delete(e),i.dispose(),s==null||s.forEach(o=>o==null?void 0:o())}}handleEnable(e,i=!0){e?(this.everyHelperDo(s=>s.enable()),this.hooks.emit("enable",{userAction:i})):(this.everyHelperDo(s=>s.disable()),this.hooks.emit("disable",{userAction:i})),this.state.enabled=e}handleVisible(e,i=!0){e?(this.everyHelperDo(s=>s.show()),this.actionIfStateIsEnabled(()=>this.hooks.emit("show",{userAction:i}))):(this.everyHelperDo(s=>s.hide()),this.actionIfStateIsEnabled(()=>this.hooks.emit("hide",{userAction:i}))),this.state.visible=e}handleDispose(){this.everyHelperDo((e,i)=>{e.dispose(),i==null||i.forEach(s=>s==null?void 0:s())})}everyHelperDo(e){this.objectHelperMap.forEach(({helper:i,disposers:s})=>{i&&e(i,s)})}actionIfStateIsEnabled(e,i){if(this.state.enabled)return e();i!=null&&i.warnLog&&Ev()}getConfig(e){if(e&&typeof e!="boolean"&&e.enable)return e}}const xv=n=>new ta(n);function Wc(n,t){const{top:e,left:i,width:s,height:o}=t.getBoundingClientRect();return new y.Vector2((n.x-i)/s*2-1,-(n.y-e)/o*2+1)}class Hc extends y.Raycaster{intersectObject(t,e=!0,i=[]){return ia(t,this,i,e),i.sort(Uc),i}intersectObjects(t,e=!0,i=[]){for(let s=0,o=t.length;s<o;s++)ia(t[s],this,i,e);return i.sort(Uc),i}}function Uc(n,t){return n.distance-t.distance}function ia(n,t,e,i){let s=!0;if(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0){const o=n.children;for(let r=0,a=o.length;r<a;r++)ia(o[r],t,e,!0)}}function na(n,t,e,i){let s=!0;if(n.type!=="Line2"&&(n.layers.test(t.layers)&&n.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0)){const o=n.children;for(let r=0,a=o.length;r<a;r++)o[r].type!=="Line2"&&na(o[r],t,e,!0)}}class sa{constructor(t,e){d(this,"five");d(this,"dragging",!1);d(this,"boundObject",{});d(this,"config");d(this,"lastMouseDownEvent");d(this,"handleWantsGesture",(t,e)=>{if(e.length!==1)return;const i=e[0];if(i.raycaster){const s=new Hc;s.ray=i.raycaster.ray,s.near=i.raycaster.near,s.far=i.raycaster.far,s.camera=i.raycaster.camera,s.layers=i.raycaster.layers,s.params=i.raycaster.params,i.raycaster=s}if(i){if(t==="mouseMove"&&this.onDomEvent("hover",i),t==="tap"){const s=this.lastMouseDownEvent,o=this.onDomEvent("click",i,s),r=this.onDomEvent("wantDblclick",i,s,this.boundObject.dblclick);if(o===!1||r===!1)return!1}if(this.dragging)return!1}});d(this,"handleDomEvent",(t,e,i)=>{const s={x:e.clientX,y:e.clientY};this.onDomEvent(t,s,e,i)});d(this,"handleMouseEvent",t=>{this.handleDomEvent(t.type,t)});d(this,"handleMousedown",t=>{this.lastMouseDownEvent=t,this.handleDomEvent("mousedown",t),this.handleDomEvent("dragstart",t,this.haveDragEventObject)});d(this,"handleMouseup",t=>{var e;this.dragging=!1,(e=this.haveDragEventObject)==null||e.forEach(i=>{i._dragging&&(i._dragging=!1,this.notify({eventName:"dragend",object:i,originEvent:t,raycaster:this.getRaycaster({x:t.clientX,y:t.clientY})}))}),this.handleDomEvent("mouseup",t)});d(this,"handleMousemove",t=>{var e;this.dragging&&((e=this.boundObject.drag)==null||e.forEach(i=>{i._dragging&&this.notify({eventName:"drag",object:i,originEvent:t,raycaster:this.getRaycaster({x:t.clientX,y:t.clientY})})}))});d(this,"onDomEvent",(t,e,i,s=this.boundObject[t])=>{var f,g,v,p,m;if(!e||!s||(s==null?void 0:s.length)===0)return;const o=[];((f=this.config)==null?void 0:f.fiveModels)!==null&&((g=this.config)!=null&&g.fiveModels?o.push(...this.config.fiveModels):o.push(this.model));const r=o.filter(A=>A.loaded),a=(v=e.raycaster)!=null?v:this.getRaycaster(e);a.params.Points.threshold=.02;const l=a.intersectObjects(s,!0),c=[];r.forEach(A=>{const w=A.intersectRaycaster(a);c.push(...w)});const h=.01;if(c.length>0&&l.length>0&&c[0].distance+h<l[0].distance)return;const u=(p=l==null?void 0:l[0])==null?void 0:p.object;if(t==="wantDblclick")return!1;if((!u||!this.objectIsBound(u))&&t==="hover")for(const A of(m=this.boundObject.hover)!=null?m:[])A._hovered&&this.notify({eventName:"unHover",object:A});if(u&&u&&this.notify({eventName:t,object:u,originEvent:i,raycaster:a,intersects:l}))return!1});d(this,"objectIsBound",t=>{let e=t._domEvent,i=t.parent;for(;typeof e=="undefined"&&i;)e=i._domEvent,i=i.parent;return!!e});d(this,"notify",t=>{var f,g,v;const{eventName:e,object:i,originEvent:s,raycaster:o,intersects:r}=t;let a=!1,l=[];const c=[];let h=i;for(c.push(h);h.parent;)h=h.parent,c.push(h);const u=c.at(-1);if(!((f=this.config)!=null&&f.noEmitWhenNotInScene&&u.type!=="Scene")){for(const p of c){if(a)break;p.draggable&&(e==="dragstart"&&(p._dragging=!0,this.dragging=!0),e==="dragend"&&(p._dragging=!1,this.dragging=!1));const m=p._domEvent;if(!m)continue;const A=m[`${e}Handler`];if(A)for(const[w,I]of A){if(I!=null&&I.noEmitWhenNotInScene&&u.type!=="Scene"||((g=this.config)!=null&&g.noEmitWhenHide||I!=null&&I.noEmitWhenHide)&&!Rr(p))continue;if(e==="hover"){if(p._hovered)continue;p._hovered=!0;for(const k of(v=this.boundObject.hover)!=null?v:[])k!==p&&k._hovered&&this.notify({eventName:"unHover",object:k})}if(e==="unHover"){if(!p._hovered)continue;p._hovered=!1}const P=w({type:e,target:p,origDomEvent:s,raycaster:o,intersects:r,stopPropagation:()=>{a=!0}});l.push(P!=null?P:!0)}}if(e==="click"||e==="wantDblclick")return l.some(p=>p===!0)}});this.five=t,this.config=e,t.on("wantsGesture",this.handleWantsGesture),document.addEventListener("mousedown",this.handleMousedown),document.addEventListener("dblclick",this.handleMouseEvent),document.addEventListener("mouseup",this.handleMouseup),document.addEventListener("mousemove",this.handleMousemove)}get haveDragEventObject(){return[...new Set([this.boundObject.dragend,this.boundObject.drag,this.boundObject.dragstart].flat())].filter(Boolean)}get model(){return Bt(this.five)}addAutoBindEventListener(t,e,i,s){const o=()=>this.addEventListener(t,e,i,s),r=()=>this.removeEventListener(t,e,i,s);return t.addEventListener("added",o),t.addEventListener("removed",r),t.addEventListener("dispose",r),()=>{t.removeEventListener("added",o),t.removeEventListener("removed",r),t.removeEventListener("dispose",r)}}addEventListener(t,e,i,s){t._domEvent||(t._domEvent={}),t._domEvent[`${e}Handler`]||(t._domEvent[`${e}Handler`]=[]),this.boundObject[e]||(this.boundObject[e]=[]),this.boundObject[e].includes(t)||this.boundObject[e].push(t),t._domEvent[`${e}Handler`].push([i,x({noEmitWhenHide:!1,noEmitWhenNotInScene:!1},s)])}removeEventListener(t,e,i,...s){var r,a;if(!t._domEvent||(e===void 0&&(Object.keys(this.boundObject).forEach(l=>{var h,u;const c=(h=this.boundObject[l])==null?void 0:h.findIndex(f=>f===t);c!==-1&&((u=this.boundObject[l])==null||u.splice(c,1))}),t._domEvent={}),!t._domEvent[`${e}Handler`]))return;if(i===void 0){delete t._domEvent[`${e}Handler`];return}const o=t._domEvent[`${e}Handler`].findIndex(l=>l[0]===i);if(o!==-1&&(t._domEvent[`${e}Handler`].splice(o,1),t._domEvent[`${e}Handler`].length===0&&delete t._domEvent[`${e}Handler`],t._domEvent&&Object.keys(t._domEvent).length===0&&delete t._domEvent,!t._domEvent)){const l=(r=this.boundObject[e])==null?void 0:r.findIndex(c=>c===t);l!==-1&&((a=this.boundObject[e])==null||a.splice(l,1))}}clear(){this.boundObject={}}dispose(){var t;(t=this.five)==null||t.off("wantsGesture",this.handleWantsGesture),document.removeEventListener("mousedown",this.handleMousedown),document.removeEventListener("mouseup",this.handleMouseup),document.removeEventListener("mousemove",this.handleMousemove),this.boundObject={}}toJSON(){return{boundObject:this.boundObject}}getRaycaster(t){const e=this.five.getElement();if(!e)return;const i=Wc(t,e),s=new Hc;return s.setFromCamera(i,this.five.camera),s}}const Yc="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Dv(n,t){const{x:e,y:i}=t,s=e*2-1,o=i*2-1,r=new y.Raycaster;return r.setFromCamera({x:s,y:o},n.camera),r.params.Points.threshold=.02,r}function ws(n,t,e){const i=Sv(n,t);return e!=null&&e.virtualPoint?i!=null?i:Xc(t):i}function Xc(n,t=3){const e=new y.Vector3().addVectors(n.ray.origin,n.ray.direction.clone().normalize().multiplyScalar(t)),i=n.ray.direction.clone().negate();return{distance:t,point:e,object:new y.Object3D,face:new y.Face3(0,0,0,i),raycaster:n,isVirtual:!0}}function Sv(n,t){const s=Bt(n).intersectRaycaster(t)[0];if(s)return ne(x({},s),{raycaster:t,isVirtual:!1})}const Lv=new y.Vector3,In=()=>!1;class Zc extends ut{constructor(e,i){var r,a,l;super();d(this,"outOfFive",!1);d(this,"enabled",!1);d(this,"actionIfNoModelUnderMouse","virtualPoint");d(this,"plane");d(this,"pointSelectorHelper");d(this,"hook",this);d(this,"five");d(this,"hammer");d(this,"mode");d(this,"pressDown",!1);d(this,"adherePoints");d(this,"adherePointsRadius",.1);d(this,"lastFiveHelperVisible");d(this,"lastIntersection");d(this,"mousePosition");d(this,"config",{});d(this,"select",e=>{e&&this.updatePointSelectorHelperIntersect(e);const i=this.emit("wantsSelect",this.position);return i||(this.pointSelectorHelper.hide(),this.emit("select",this.position),console.debug(this.position)),!i});d(this,"onEnter",()=>{this.pointSelectorHelper.show(),this.outOfFive=!1,this.emit("intersectionUpdate",this.position)});d(this,"onLeave",()=>{this.pointSelectorHelper.hide(),this.outOfFive=!0,this.emit("intersectionUpdate",null)});d(this,"onTap",e=>{e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),this.select()});d(this,"onPan",e=>{this.pressDown&&(e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),this.mouseNdcPosition&&this.updateByNdcPosition(this.mouseNdcPosition))});d(this,"onPress",e=>{if(e!=null&&e.center&&(this.mousePosition={clientX:e.center.x,clientY:e.center.y}),!this.mouseNdcPosition)return;const i=this.updateByNdcPosition(this.mouseNdcPosition);this.pressDown=i});d(this,"onPanEnd",()=>{this.pressDown&&(this.pressDown=!1,this.select())});d(this,"updateByMousePosition",e=>{this.five.getElement()&&(this.mousePosition=e,this.updateByNdcPosition(this.mouseNdcPosition))});d(this,"updateByNdcPosition",e=>{var o,r;const i=Dv(this.five,e),s=ws(this.five,i);if(s)return this.updatePointSelectorHelperIntersect(s),this.lastIntersection=s,!0;if(this.plane){const a=i.ray.intersectPlane(this.plane,Lv);if(a){const l={distance:this.five.camera.position.distanceTo(a),point:a.clone(),object:new y.Object3D,face:new y.Face3(0,0,0,this.plane.normal.clone()),raycaster:i,isVirtual:!0};return this.updatePointSelectorHelperIntersect(l),!0}}if(this.actionIfNoModelUnderMouse==="lastPoint")return this.updatePointSelectorHelperIntersect(this.lastIntersection),!0;if(this.actionIfNoModelUnderMouse==="virtualPoint"){const a=Xc(i,(o=this.lastIntersection)==null?void 0:o.distance);return a.face=new y.Face3(0,0,0,(r=this.lastIntersection)==null?void 0:r.face.normal),this.lastIntersection=a,this.updatePointSelectorHelperIntersect(a),!0}else if(this.actionIfNoModelUnderMouse==="disable")return this.updatePointSelectorHelperIntersect(null),!1});d(this,"updatePointSelectorHelperIntersect",e=>{if(!e){this.onLeave(),this.five.getElement().style.cursor=`url("data:image/svg+xml,%3Csvg width='12px' height='12px' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cpath d='M6,12 C9.3137085,12 12,9.3137085 12,6 C12,2.6862915 9.3137085,0 6,0 C2.6862915,0 0,2.6862915 0,6 C0,9.3137085 2.6862915,12 6,12 Z' fill='%23FF5959'%3E%3C/path%3E%3Cg transform='translate(2, 2)' stroke='%23FFFFFF'%3E%3Ccircle cx='4' cy='4' r='4'%3E%3C/circle%3E%3Cline x1='1.07141075' y1='1.23997894' x2='6.64700843' y2='6.81557662'%3E%3C/line%3E%3C/g%3E%3C/g%3E%3C/svg%3E"), auto`;return}this.onEnter(),this.five.getElement().style.cursor="";const i=x({},e);let s=!1;if(typeof this.adherePoints=="function"&&typeof this.adherePointsRadius=="number"){for(const o of this.adherePoints({intersection:e,pointSelectorInstance:this}))if(o.distanceTo(e.point)<this.adherePointsRadius){i.point=o.clone(),s=!0;break}}this.pointSelectorHelper.updateWithIntersect(i,{emitEvent:!1}),this.emit("intersectionUpdate",i,s)});d(this,"mousePositionToNdcPosition",e=>{const i=this.five.getElement();if(!i)return null;const{top:s,left:o,width:r,height:a}=i.getBoundingClientRect(),{clientX:l,clientY:c}=e;return{x:(l-o)/r,y:1-(c-s)/a}});d(this,"onFiveWantsPanGesture",()=>{if(this.pressDown)return!1});d(this,"renderScreenCenter",()=>{this.updateByNdcPosition({x:.5,y:.5})});d(this,"emitIntersectionUpdate",e=>{this.emit("intersectionUpdate",e)});this.five=e,this.config=x(x({},this.config),i),this.actionIfNoModelUnderMouse=(r=i==null?void 0:i.actionIfNoModelUnderMouse)!=null?r:"virtualPoint";const s=(a=i==null?void 0:i.mode)!=null?a:"auto";s==="auto"?this.mode=Yc?"fixed":"cursor":this.mode=s;const o={autoFixPCPosition:this.mode==="cursor",initialPosition:this.mode==="fixed"?{left:"35%",top:"20%"}:void 0};this.pointSelectorHelper=new eh(this.five,ne(x({},i==null?void 0:i.helper),{magnifierParams:x(x({},o),(l=i==null?void 0:i.helper)==null?void 0:l.magnifierParams)})),this.pointSelectorHelper.hide()}get position(){return this.outOfFive?null:this.pointSelectorHelper.position}get mouseNdcPosition(){return this.mousePosition?this.mousePositionToNdcPosition(this.mousePosition):null}enable(){if(this.enabled)return;this.enabled=!0,this.outOfFive=!1,this.pointSelectorHelper.enable();const e=this.five.getElement();if(!e)throw new Error("five element not found");this.hammer||(this.hammer=new vn(e)),this.mode==="cursor"?(this.five.on("wantsPanGesture",this.onFiveWantsPanGesture),this.five.on("wantsMoveToPano",In),this.five.on("wantsChangeMode",In),this.five.on("wantsTapGesture",In),e.addEventListener("mousemove",this.updateByMousePosition),e.addEventListener("wheel",this.updateByMousePosition),e.addEventListener("mouseenter",this.onEnter),e.addEventListener("mouseout",this.onLeave),this.hammer.on("tap",this.onTap),this.hammer.on("pan",this.onPan),this.hammer.on("press",this.onPress),this.hammer.on("panend",this.onPanEnd)):this.mode==="fixed"&&(this.five.on("panoArrived",this.renderScreenCenter),this.five.on("panGesture",this.renderScreenCenter),this.five.on("interiaPan",this.renderScreenCenter),this.renderScreenCenter(),this.pointSelectorHelper.show()),this.pointSelectorHelper.hooks.on("intersectionUpdate",this.emitIntersectionUpdate),this.lastFiveHelperVisible=this.five.helperVisible,this.five.helperVisible=!1,this.emit("enable")}disable(){if(!this.enabled)return;this.enabled=!1,this.pointSelectorHelper.disable(),this.five.getElement().style.cursor="";const e=this.five.getElement();this.five.off("wantsPanGesture",this.onFiveWantsPanGesture),this.five.off("wantsMoveToPano",In),this.five.off("wantsChangeMode",In),this.five.off("wantsTapGesture",In),this.five.helperVisible=this.lastFiveHelperVisible,e==null||e.removeEventListener("mousemove",this.updateByMousePosition),e==null||e.removeEventListener("wheel",this.updateByMousePosition),e==null||e.removeEventListener("mouseenter",this.onEnter),e==null||e.removeEventListener("mouseout",this.onLeave),this.hammer.off("tap",this.onTap),this.hammer.off("pan",this.onPan),this.hammer.off("press",this.onPress),this.hammer.off("panend",this.onPanEnd),this.five.off("panoArrived",this.renderScreenCenter),this.five.off("panGesture",this.renderScreenCenter),this.five.off("interiaPan",this.renderScreenCenter),this.pointSelectorHelper.hooks.off("intersectionUpdate",this.emitIntersectionUpdate),this.emit("disable")}dispose(){this.disable(),this.pointSelectorHelper.dispose()}setAdherePoints(e,i){e?typeof e=="function"?this.adherePoints=e:this.adherePoints=()=>e:this.adherePoints=null,typeof i=="number"&&(this.adherePointsRadius=i)}}class Tv{constructor(){d(this,"five");d(this,"_cursor");d(this,"_pointSelector");d(this,"_fiveDomEvents");d(this,"_object3DHelper");d(this,"inited",!1);d(this,"init",t=>{this.inited=!0,this.five=t,this._cursor=void 0,this._pointSelector=void 0,this._fiveDomEvents=void 0,this._object3DHelper=void 0})}get cursor(){if(!this.inited)throw new Error("Global not inited");return this._cursor?this._cursor:(this._cursor=new _p(this.five.getElement()),this._cursor)}get pointSelector(){if(!this.inited)throw new Error("Global not inited");return this._pointSelector?this._pointSelector:(this._pointSelector=new Zc(this.five),this._pointSelector)}get fiveDomEvents(){if(!this.inited)throw new Error("Global not inited");return this._fiveDomEvents?this._fiveDomEvents:(this._fiveDomEvents=new sa(this.five,{noEmitWhenNotInScene:!0}),this._fiveDomEvents)}get object3DHelper(){if(!this.inited)throw new Error("Global not inited");return this._object3DHelper?this._object3DHelper:(this._object3DHelper=new ta(this.five),this._object3DHelper)}}const oa=new Tv;window.globalModules=oa;function Jc(n){qc(n),n.traverse(t=>qc(t))}function qc(n){Array.isArray(n.lengthDoms)&&n.lengthDoms[0]instanceof Nr&&n.lengthDoms.forEach(e=>e.destroy())}class Kc extends Bp{constructor(e){var i,s;super(e);d(this,"_three_color");ke(e==null?void 0:e.color)&&(this.three_color=(i=e==null?void 0:e.color)!=null?i:16777215),Object.keys(e).forEach(o=>{["color","dashed","dashScale","dashSize","gapSize","resolution"].includes(o)||o in this&&(this[o]=e[o])}),this.setDashed((s=e==null?void 0:e.dashed)!=null?s:!1)}get three_color(){return this._three_color}set three_color(e){this._three_color=e,this.color=e}setDashed(e){this.dashed=e,e?this.defines.USE_DASH="":delete this.defines.USE_DASH,this.needsUpdate=!0}}class $c extends Vp{constructor(e,i){super(e,i);d(this,"name","Line3")}}class Wt extends St{constructor(e){var r,a,l,c,h;super();d(this,"name","LineMesh");d(this,"points");d(this,"lengthDoms",[]);d(this,"highlighted",!1);d(this,"line");d(this,"backLine");d(this,"opacityBeforeHighlight");d(this,"paramsStyle",{});this.paramsStyle=e!=null?e:{};const i=new Vc,s=new Kc({color:new y.Color((r=e==null?void 0:e.lineColor)!=null?r:zc),linewidth:(a=e==null?void 0:e.lineWidth)!=null?a:Op,dashScale:40,opacity:(l=e==null?void 0:e.opacity)!=null?l:1,transparent:!0,dashed:(c=e==null?void 0:e.dashed)!=null?c:!1}),o=new Kc({color:new y.Color((h=e==null?void 0:e.lineColor)!=null?h:zc),linewidth:s.linewidth*.9,dashScale:s.dashScale,opacity:s.opacity*.8,depthTest:!1,depthWrite:!1,transparent:!0,resolution:s.resolution});this.line=new $c(i,s),this.backLine=new $c(i,o),this.line.renderOrder=1,this.backLine.renderOrder=0,this.line.name="lineFrontMaterial",this.backLine.name="lineBackMaterial",e&&this.setStyle(e),e!=null&&e.points&&this.setPoints(e.points),this.addEventListener("removed",()=>{Jc(this)})}get style(){return{lineColor:this.color,lineWidth:this.lineWidth,dashed:this.dashed,occlusionVisibility:this.occlusionVisibility,occlusionMode:this.occlusionMode,lengthEnable:this.paramsStyle.lengthEnable}}get lineWidth(){return this.line.material.linewidth}get color(){return new y.Color(this.line.material.three_color)}get dashed(){return this.line.material.dashed}get occlusionVisibility(){return this.backLine.visible||this.line.material.depthTest===!1}get occlusionMode(){return this.line.material.depthTest===!1?"depthTest":"translucence"}setPoints(e){const i=e.map(Ge).filter(ke);if(this.points=i,i.length<2)return;this.addIfNotExists(this.line,this.backLine);const s=i.flatMap(o=>[o.x,o.y,o.z]);s.length>2&&(this.line.geometry.dispose(),this.line.geometry=new Vc,this.backLine.geometry=this.line.geometry),this.line.geometry.setPositions(s),this.line.computeLineDistances(),this.updateLengthItems(),this.needsRender=!0}setResolution(e,i){const s=this.line.material.resolution;(s.x!==e||s.y!==i)&&(s.set(e,i),this.needsRender=!0);const o=this.backLine.material.resolution;(o.x!==e||o.y!==i)&&(o.set(e,i),this.needsRender=!0)}setStyle(e){var o,r,a;this.paramsStyle=x(x({},this.paramsStyle),e),ke(e.lineColor)&&(this.line.material.three_color=new y.Color(e.lineColor),this.backLine.material.three_color=new y.Color(e.lineColor)),ke(e.lineWidth)&&(this.line.material.linewidth=e.lineWidth),ke(e.dashed)&&this.line.material.setDashed(e.dashed),ke(e.opacity)&&(this.line.material.opacity=e.opacity,this.backLine.material.opacity=this.line.material.opacity*.2),this.updateLengthItems();const i=(o=e.occlusionVisibility)!=null?o:this.paramsStyle.occlusionVisibility,s=(a=(r=e.occlusionMode)!=null?r:this.paramsStyle.occlusionMode)!=null?a:"translucence";i?s==="depthTest"?(this.line.material.depthTest=!1,this.backLine.visible=!1):s==="translucence"&&(this.line.material.depthTest=!0,this.backLine.visible=!0,this.line.material.opacity===1?this.backLine.material.setDashed(!0):this.backLine.material.setDashed(this.line.material.dashed)):(this.line.material.depthTest=!0,this.backLine.visible=!1),this.needsRender=!0}highlight(){this.highlighted||(this.highlighted=!0,this.opacityBeforeHighlight=this.line.material.opacity,this.line.material.opacity=this.opacityBeforeHighlight*yn,this.backLine.material.opacity=this.backLine.material.opacity*yn,this.needsRender=!0)}unhighlight(){this.highlighted&&(this.highlighted=!1,this.line.material.opacity=this.opacityBeforeHighlight,this.backLine.material.opacity=.2,this.needsRender=!0)}updateLengthItems(){var e,i;if(this.paramsStyle.lengthEnable){const s=(i=(e=this.points)==null?void 0:e.map((o,r)=>{if(r!==0)return[this.points[r-1],o]}).filter(ke))!=null?i:[];s.forEach(([o,r],a)=>{var h;const l=ei(o,r),c=o.distanceTo(r).toFixed(2)+"m";this.lengthDoms[a]=(h=this.lengthDoms[a])!=null?h:new Nr(oa.five),this.lengthDoms[a].setPosition(l),this.lengthDoms[a].container.innerHTML=`<div style="pointer-events:none;color:white;">${c}</div>`}),this.lengthDoms.length>s.length&&(this.lengthDoms.slice(s.length).forEach(o=>o.destroy()),this.lengthDoms.length=s.length)}else this.lengthDoms.forEach(s=>s.destroy()),this.lengthDoms=[]}}class jv extends He.CSS3DSprite{constructor(){super(...arguments);d(this,"isCSS3DSprite",!0)}}const zv=`
|
|
178
178
|
varying vec2 vUv;
|
|
179
179
|
varying float vRadius;
|
|
180
180
|
varying float vDistanceToCamera;
|
|
@@ -3,8 +3,9 @@ import { PointSelectorHelper, type PointIntersection, type PointSelectorHelperCo
|
|
|
3
3
|
import { type Vector3 } from 'three';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
import { Subscribe } from '../../Subscribe';
|
|
6
|
+
import type { LiteralString } from '../../../typings/utils.type';
|
|
6
7
|
export type { PointIntersection };
|
|
7
|
-
type ActionIfNoModelUnderMouse = 'virtualPoint' | 'lastPoint' | 'disable'
|
|
8
|
+
export type ActionIfNoModelUnderMouse = LiteralString<'virtualPoint' | 'lastPoint' | 'disable'>;
|
|
8
9
|
interface Config {
|
|
9
10
|
/**
|
|
10
11
|
* @description: 选点的两种模式, 'fixed' 为固定选点为屏幕中心点,拖动five画布来更新点,'cursor' 为跟随鼠标移动来更新点, 'auto' 则根据设备类型自动选择
|
package/libs/base/BasePlugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function A() {
|
|
2
2
|
console.debug(
|
|
3
|
-
"%c %c@realsee/dnalogel %cv3.47.
|
|
3
|
+
"%c %c@realsee/dnalogel %cv3.47.2",
|
|
4
4
|
[
|
|
5
5
|
"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=')",
|
|
6
6
|
"background-repeat: no-repeat",
|
|
@@ -3,8 +3,9 @@ import { PointSelectorHelper, type PointIntersection, type PointSelectorHelperCo
|
|
|
3
3
|
import { type Vector3 } from 'three';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
import { Subscribe } from '../../Subscribe';
|
|
6
|
+
import type { LiteralString } from '../../../typings/utils.type';
|
|
6
7
|
export type { PointIntersection };
|
|
7
|
-
type ActionIfNoModelUnderMouse = 'virtualPoint' | 'lastPoint' | 'disable'
|
|
8
|
+
export type ActionIfNoModelUnderMouse = LiteralString<'virtualPoint' | 'lastPoint' | 'disable'>;
|
|
8
9
|
interface Config {
|
|
9
10
|
/**
|
|
10
11
|
* @description: 选点的两种模式, 'fixed' 为固定选点为屏幕中心点,拖动five画布来更新点,'cursor' 为跟随鼠标移动来更新点, 'auto' 则根据设备类型自动选择
|