trillion-viewer
Version:
Trillion 3D Viewer
17 lines • 922 kB
JavaScript
var US=Object.defineProperty,VS=(t,e,n)=>e in t?US(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,H=(t,e,n)=>VS(t,typeof e!="symbol"?e+"":e,n);import*as Qd from"react";import Uo,{createContext as Wi,useContext as ct,useState as Ce,useEffect as ie,useRef as An,useCallback as Vo,useId as qd,Component as HS,useLayoutEffect as WS,useInsertionEffect as m0,useMemo as hr,forwardRef as YS,Fragment as g0,createElement as GS,Children as XS,isValidElement as KS,lazy as Tt,Suspense as Jd}from"react";import*as J from"three";import{DataTextureLoader as v0,HalfFloatType as Tn,FloatType as kn,DataUtils as Ho,LinearSRGBColorSpace as dn,LinearFilter as kt,Ray as ZS,Plane as $d,MathUtils as y0,Vector3 as L,Controls as b0,MOUSE as Rn,TOUCH as Dn,Quaternion as Et,Spherical as $r,Vector2 as Me,Raycaster as QS,Euler as Yi,Matrix4 as De,Object3D as Wo,MeshBasicMaterial as ei,LineBasicMaterial as w0,CylinderGeometry as $t,BoxGeometry as Xt,BufferGeometry as rs,Float32BufferAttribute as x0,Mesh as ue,OctahedronGeometry as Ql,Line as Tr,SphereGeometry as qS,TorusGeometry as is,PlaneGeometry as JS,DoubleSide as eh,TrianglesDrawMode as $S,TriangleFanDrawMode as th,TriangleStripDrawMode as _0,RGBAFormat as Xn,RedFormat as nh,NoColorSpace as S0,Loader as M0,FileLoader as ql,SRGBColorSpace as pr,BufferAttribute as fr,Color as wt,ColorManagement as rh,LoaderUtils as os,SpotLight as eM,PointLight as E0,DirectionalLight as P0,MeshPhysicalMaterial as Kn,InstancedMesh as tM,InstancedBufferAttribute as nM,TextureLoader as rM,ImageBitmapLoader as iM,InterleavedBuffer as oM,InterleavedBufferAttribute as aM,LinearMipmapLinearFilter as C0,RepeatWrapping as as,NearestFilter as Ft,PointsMaterial as sM,Material as ih,MeshStandardMaterial as A0,PropertyBinding as lM,SkinnedMesh as cM,LineSegments as uM,LineLoop as dM,Points as hM,Group as Jl,PerspectiveCamera as T0,OrthographicCamera as k0,Skeleton as pM,AnimationClip as fM,Bone as mM,InterpolateLinear as R0,NearestMipmapNearestFilter as gM,LinearMipmapNearestFilter as vM,NearestMipmapLinearFilter as yM,ClampToEdgeWrapping as bM,MirroredRepeatWrapping as wM,InterpolateDiscrete as xM,FrontSide as oh,Texture as D0,VectorKeyframeTrack as I0,NumberKeyframeTrack as O0,QuaternionKeyframeTrack as L0,Box3 as hn,Sphere as ah,Interpolant as _M,PMREMGenerator as SM,LoadingManager as MM,PCFSoftShadowMap as EM,EventDispatcher as PM,Line3 as kr,Triangle as Yo,REVISION as sh,BackSide as CM,UnsignedIntType as Go,DataTexture as $l,IntType as lh,UnsignedByteType as N0,UnsignedShortType as AM,ByteType as F0,ShortType as TM,RGBAIntegerFormat as ch,RGFormat as kM,RGIntegerFormat as z0,RedIntegerFormat as RM,ShaderMaterial as Zn,WebGLRenderTarget as Gi,WebGLMultipleRenderTargets as DM,DepthTexture as IM,PointLightHelper as OM,DirectionalLightHelper as LM,CanvasTexture as B0}from"three";import*as _e from"postprocessing";import{Pass as NM,Selection as FM,BlendFunction as ss,SMAAPreset as zM,EdgeDetectionMode as BM,PredicationMode as jM}from"postprocessing";import UM from"react-dom/client";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="1daef982-466d-458f-9851-9a65f36ff242",t._sentryDebugIdIdentifier="sentry-dbid-1daef982-466d-458f-9851-9a65f36ff242")}catch{}})();var VM=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};VM.SENTRY_RELEASE={id:"trillion-viewer-react@0.40.5"};function HM(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var j0={exports:{}},ec={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var WM=Uo,YM=Symbol.for("react.element"),GM=Symbol.for("react.fragment"),XM=Object.prototype.hasOwnProperty,KM=WM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ZM={key:!0,ref:!0,__self:!0,__source:!0};function U0(t,e,n){var r,i={},o=null,a=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(a=e.ref);for(r in e)XM.call(e,r)&&!ZM.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:YM,type:t,key:o,ref:a,props:i,_owner:KM.current}}ec.Fragment=GM,ec.jsx=U0,ec.jsxs=U0,j0.exports=ec;var I=j0.exports,V0=Symbol.for("immer-nothing"),H0=Symbol.for("immer-draftable"),pn=Symbol.for("immer-state");function Qn(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Xo=Object.getPrototypeOf;function Ko(t){return!!t&&!!t[pn]}function Xi(t){var e;return t?W0(t)||Array.isArray(t)||!!t[H0]||!!((e=t.constructor)!=null&&e[H0])||rc(t)||ic(t):!1}var QM=Object.prototype.constructor.toString();function W0(t){if(!t||typeof t!="object")return!1;const e=Xo(t);if(e===null)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===QM}function tc(t,e){nc(t)===0?Reflect.ownKeys(t).forEach(n=>{e(n,t[n],t)}):t.forEach((n,r)=>e(r,n,t))}function nc(t){const e=t[pn];return e?e.type_:Array.isArray(t)?1:rc(t)?2:ic(t)?3:0}function uh(t,e){return nc(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Y0(t,e,n){const r=nc(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function qM(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function rc(t){return t instanceof Map}function ic(t){return t instanceof Set}function Ki(t){return t.copy_||t.base_}function dh(t,e){if(rc(t))return new Map(t);if(ic(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=W0(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[pn];let i=Reflect.ownKeys(r);for(let o=0;o<i.length;o++){const a=i[o],s=r[a];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(r[a]={configurable:!0,writable:!0,enumerable:s.enumerable,value:t[a]})}return Object.create(Xo(t),r)}else{const r=Xo(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function hh(t,e=!1){return oc(t)||Ko(t)||!Xi(t)||(nc(t)>1&&(t.set=t.add=t.clear=t.delete=JM),Object.freeze(t),e&&Object.entries(t).forEach(([n,r])=>hh(r,!0))),t}function JM(){Qn(2)}function oc(t){return Object.isFrozen(t)}var $M={};function Zi(t){const e=$M[t];return e||Qn(0,t),e}var ls;function G0(){return ls}function eE(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function X0(t,e){e&&(Zi("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function ph(t){fh(t),t.drafts_.forEach(tE),t.drafts_=null}function fh(t){t===ls&&(ls=t.parent_)}function K0(t){return ls=eE(ls,t)}function tE(t){const e=t[pn];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Z0(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[pn].modified_&&(ph(e),Qn(4)),Xi(t)&&(t=ac(e,t),e.parent_||sc(e,t)),e.patches_&&Zi("Patches").generateReplacementPatches_(n[pn].base_,t,e.patches_,e.inversePatches_)):t=ac(e,n,[]),ph(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==V0?t:void 0}function ac(t,e,n){if(oc(e))return e;const r=e[pn];if(!r)return tc(e,(i,o)=>Q0(t,r,e,i,o,n)),e;if(r.scope_!==t)return e;if(!r.modified_)return sc(t,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let o=i,a=!1;r.type_===3&&(o=new Set(i),i.clear(),a=!0),tc(o,(s,l)=>Q0(t,r,i,s,l,n,a)),sc(t,i,!1),n&&t.patches_&&Zi("Patches").generatePatches_(r,n,t.patches_,t.inversePatches_)}return r.copy_}function Q0(t,e,n,r,i,o,a){if(Ko(i)){const s=o&&e&&e.type_!==3&&!uh(e.assigned_,r)?o.concat(r):void 0,l=ac(t,i,s);if(Y0(n,r,l),Ko(l))t.canAutoFreeze_=!1;else return}else a&&n.add(i);if(Xi(i)&&!oc(i)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;ac(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&sc(t,i)}}function sc(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&hh(e,n)}function nE(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:G0(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=mh;n&&(i=[r],o=cs);const{revoke:a,proxy:s}=Proxy.revocable(i,o);return r.draft_=s,r.revoke_=a,s}var mh={get(t,e){if(e===pn)return t;const n=Ki(t);if(!uh(n,e))return rE(t,n,e);const r=n[e];return t.finalized_||!Xi(r)?r:r===gh(t.base_,e)?(yh(t),t.copy_[e]=bh(r,t)):r},has(t,e){return e in Ki(t)},ownKeys(t){return Reflect.ownKeys(Ki(t))},set(t,e,n){const r=q0(Ki(t),e);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=gh(Ki(t),e),o=i?.[pn];if(o&&o.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(qM(n,i)&&(n!==void 0||uh(t.base_,e)))return!0;yh(t),vh(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty(t,e){return gh(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,yh(t),vh(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Ki(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Qn(11)},getPrototypeOf(t){return Xo(t.base_)},setPrototypeOf(){Qn(12)}},cs={};tc(mh,(t,e)=>{cs[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}}),cs.deleteProperty=function(t,e){return cs.set.call(this,t,e,void 0)},cs.set=function(t,e,n){return mh.set.call(this,t[0],e,n,t[0])};function gh(t,e){const n=t[pn];return(n?Ki(n):t)[e]}function rE(t,e,n){var r;const i=q0(e,n);return i?"value"in i?i.value:(r=i.get)==null?void 0:r.call(t.draft_):void 0}function q0(t,e){if(!(e in t))return;let n=Xo(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Xo(n)}}function vh(t){t.modified_||(t.modified_=!0,t.parent_&&vh(t.parent_))}function yh(t){t.copy_||(t.copy_=dh(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var iE=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const o=n;n=e;const a=this;return function(s=o,...l){return a.produce(s,c=>n.call(this,c,...l))}}typeof n!="function"&&Qn(6),r!==void 0&&typeof r!="function"&&Qn(7);let i;if(Xi(e)){const o=K0(this),a=bh(e,void 0);let s=!0;try{i=n(a),s=!1}finally{s?ph(o):fh(o)}return X0(o,r),Z0(i,o)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===V0&&(i=void 0),this.autoFreeze_&&hh(i,!0),r){const o=[],a=[];Zi("Patches").generateReplacementPatches_(e,i,o,a),r(o,a)}return i}else Qn(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(o,...a)=>this.produceWithPatches(o,s=>e(s,...a));let r,i;return[this.produce(e,n,(o,a)=>{r=o,i=a}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){Xi(t)||Qn(8),Ko(t)&&(t=oE(t));const e=K0(this),n=bh(t,void 0);return n[pn].isManual_=!0,fh(e),n}finishDraft(t,e){const n=t&&t[pn];(!n||!n.isManual_)&&Qn(9);const{scope_:r}=n;return X0(r,e),Z0(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const i=e[n];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}n>-1&&(e=e.slice(n+1));const r=Zi("Patches").applyPatches_;return Ko(t)?r(t,e):this.produce(t,i=>r(i,e))}};function bh(t,e){const n=rc(t)?Zi("MapSet").proxyMap_(t,e):ic(t)?Zi("MapSet").proxySet_(t,e):nE(t,e);return(e?e.scope_:G0()).drafts_.push(n),n}function oE(t){return Ko(t)||Qn(10,t),J0(t)}function J0(t){if(!Xi(t)||oc(t))return t;const e=t[pn];let n;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=dh(t,e.scope_.immer_.useStrictShallowCopy_)}else n=dh(t,!0);return tc(n,(r,i)=>{Y0(n,r,J0(i))}),e&&(e.finalized_=!1),n}var fn=new iE,aE=fn.produce;fn.produceWithPatches.bind(fn),fn.setAutoFreeze.bind(fn),fn.setUseStrictShallowCopy.bind(fn),fn.applyPatches.bind(fn),fn.createDraft.bind(fn),fn.finishDraft.bind(fn);const sE=t=>(e,n,r)=>(r.setState=(i,o,...a)=>{const s=typeof i=="function"?aE(i):i;return e(s,o,...a)},t(r.setState,n,r)),lE=sE,$0={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1,VITE_GTM_DATA_LAYER_NAME:"dataLayer_trillion_viewer",VITE_GTM_ID:"GTM-WZSB8JP",VITE_GTM_SERVER_CONTAINER_PATH:"https://tag.trillion.jewelry",VITE_IS_LIBRARY_MODE:"true",VITE_SENTRY_DSN:"https://ed1a10e35a3a5931bab5af312c3e4cec@o4506462464638976.ingest.sentry.io/4506473723199488",VITE_USER_NODE_ENV:"production"},wh=new Map,lc=t=>{const e=wh.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,r])=>[n,r.getState()])):{}},cE=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const r=wh.get(n.name);if(r)return{type:"tracked",store:t,...r};const i={connection:e.connect(n),stores:{}};return wh.set(n.name,i),{type:"tracked",store:t,...i}},uE=(t,e={})=>(n,r,i)=>{const{enabled:o,anonymousActionType:a,store:s,...l}=e;let c;try{c=(o??($0?"library":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return t(n,r,i);const{connection:u,...d}=cE(s,c,l);let h=!0;i.setState=(y,m,f)=>{const g=n(y,m);if(!h)return g;const b=f===void 0?{type:a||"anonymous"}:typeof f=="string"?{type:f}:f;return s===void 0?(u?.send(b,r()),g):(u?.send({...b,type:`${s}/${b.type}`},{...lc(l.name),[s]:i.getState()}),g)};const p=(...y)=>{const m=h;h=!1,n(...y),h=m},v=t(i.setState,r,i);if(d.type==="untracked"?u?.init(v):(d.stores[d.store]=i,u?.init(Object.fromEntries(Object.entries(d.stores).map(([y,m])=>[y,y===d.store?v:m.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let y=!1;const m=i.dispatch;i.dispatch=(...f)=>{($0?"library":void 0)!=="production"&&f[0].type==="__setState"&&!y&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),y=!0),m(...f)}}return u.subscribe(y=>{var m;switch(y.type){case"ACTION":if(typeof y.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return xh(y.payload,f=>{if(f.type==="__setState"){if(s===void 0){p(f.state);return}Object.keys(f.state).length!==1&&console.error(`
[zustand devtools middleware] Unsupported __setState action format.
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
`);const g=f.state[s];if(g==null)return;JSON.stringify(i.getState())!==JSON.stringify(g)&&p(g);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(f)});case"DISPATCH":switch(y.payload.type){case"RESET":return p(v),s===void 0?u?.init(i.getState()):u?.init(lc(l.name));case"COMMIT":if(s===void 0){u?.init(i.getState());return}return u?.init(lc(l.name));case"ROLLBACK":return xh(y.state,f=>{if(s===void 0){p(f),u?.init(i.getState());return}p(f[s]),u?.init(lc(l.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return xh(y.state,f=>{if(s===void 0){p(f);return}JSON.stringify(i.getState())!==JSON.stringify(f[s])&&p(f[s])});case"IMPORT_STATE":{const{nextLiftedState:f}=y.payload,g=(m=f.computedStates.slice(-1)[0])==null?void 0:m.state;if(!g)return;p(s===void 0?g:g[s]),u?.send(null,f);return}case"PAUSE_RECORDING":return h=!h}return}}),v},dE=uE,xh=(t,e)=>{let n;try{n=JSON.parse(t)}catch(r){console.error("[zustand devtools middleware] Could not parse the received json",r)}n!==void 0&&e(n)},hE=t=>(e,n,r)=>{const i=r.subscribe;return r.subscribe=(o,a,s)=>{let l=o;if(a){const c=s?.equalityFn||Object.is;let u=o(r.getState());l=d=>{const h=o(d);if(!c(u,h)){const p=u;a(u=h,p)}},s!=null&&s.fireImmediately&&a(u,u)}return i(l)},t(e,n,r)},pE=hE;class cc{constructor(e){this.minDistance=1,this.maxDistance=10,this.maxAzimuthAngle=1/0,this.minAzimuthAngle=1/0,this.maxPolarAngle=Math.PI,this.minPolarAngle=0,this.minDistance=e?.minDistance??0,this.maxDistance=e?.maxDistance??1/0,this.maxAzimuthAngle=e?.maxAzimuthAngle??1/0,this.minAzimuthAngle=e?.minAzimuthAngle??1/0,this.maxPolarAngle=e?.maxPolarAngle??Math.PI,this.minPolarAngle=e?.minPolarAngle??0}}function fE(){return{jewelryId:"",defaultCameraConstraints:new cc,isGUIEnabled:!1,isShowPerformance:!1,cameraController:void 0,rotateObject:!1,rotateSpeed:void 0,isStopped:!0,isLoading:!0,width:0,height:0,zoomMin:void 0,zoomMax:void 0,reducePixelRatio:!1,isFreeMoveCameraModeEnabled:!1,pointsOfView:[],currentPointOfViewIndx:-1,onViewerConfigSaved:void 0,onWidgetConfigSaved:void 0,onEnvironmentUpload:void 0,cameraIsAnimating:!1,autoRotate:!0,autoRotateSpeed:0,applyAutoZoomOnFirstPOV:!0,background:void 0,viewerConfig:void 0,widgetConfig:void 0,bloom:void 0,bloomSelective:void 0,depthOfField:void 0,smaa:void 0,ssao:void 0,n8ao:void 0,textureMapping:void 0,toneMapping:void 0,posteffectsConfigJson:void 0,startSize:void 0,darkPointsOfView:void 0,loaderTheme:"darkOnLight",currentMaterialColor:void 0,reflectionMap:void 0,envMapRotation:{x:0,y:0,z:0},backgroundColor:16777215,applyEnvMapOnBackground:!1,environmentIntensity:1,backgroundBlurriness:0,backgroundRotation:{x:0,y:0,z:0},currentDiamondCut:void 0,currentLetter:void 0,currentHalo:void 0,currentSize:void 0,currentBand:void 0,engravingText:void 0,selectedJewelTab:"Band Ring",tryon:void 0,materials:{},selectedMaterialConfigs:{},baseToneMappingActive:!0}}const mE=fE(),gE=(t,e)=>({...mE,setJewelryId:n=>{t({jewelryId:n})},setDefaultCameraConstraints:n=>{t({defaultCameraConstraints:n})},setIsGUIEnabled:n=>{t({isGUIEnabled:n})},setIsPerformanceEnabled:n=>{t({isShowPerformance:n})},setCameraController:n=>{t({cameraController:n})},setRotateObject:n=>{t({rotateObject:n})},setRotateSpeed:n=>{t({rotateSpeed:n})},setIsStopped:n=>{t({isStopped:n})},setIsLoading:n=>{t({isLoading:n})},setWidth:n=>{t({width:n})},setHeight:n=>{t({height:n})},setReducePixelRatio:n=>{t({reducePixelRatio:n})},setIsFreeMoveCameraModeEnabled:n=>{t({isFreeMoveCameraModeEnabled:n})},setPointsOfView:n=>{t({pointsOfView:n})},setCurrentPointOfViewIndx:n=>{t({currentPointOfViewIndx:n})},getCurrentPointOfView:()=>{const n=e().currentPointOfViewIndx;if(n!==-1)return e().pointsOfView[n]},setOnViewerConfigSaved:n=>{t({onViewerConfigSaved:n})},setOnWidgetConfigSaved:n=>{t({onWidgetConfigSaved:n})},setOnEnvironmentUpload:n=>{t({onEnvironmentUpload:n})},setCameraIsAnimating:n=>{t({cameraIsAnimating:n})},setAutoRotate:n=>{t({autoRotate:n})},setAutoRotateSpeed:n=>{t({autoRotateSpeed:n})},setApplyAutoZoomOnFirstPOV(n){t({applyAutoZoomOnFirstPOV:n})},setBackground:n=>{t({background:n})},setViewerConfig:n=>{t({viewerConfig:n})},setWidgetConfig:n=>{t({widgetConfig:n})},setBloom:n=>{t({bloom:n})},setBloomSelective:n=>{t({bloomSelective:n})},setDepthOfField:n=>{t({depthOfField:n})},setSmaa:n=>{t({smaa:n})},setSsao:n=>{t({ssao:n})},setN8ao:n=>{t({n8ao:n})},setTextureMapping:n=>{t({textureMapping:n})},setToneMapping:n=>{t({toneMapping:n})},setPosteffectsConfigJson:n=>{t({posteffectsConfigJson:n})},setStartSize:n=>{t({startSize:n})},setZoomMax:n=>{t({zoomMax:n})},setZoomMin:n=>{t({zoomMin:n})},setDarkPointsOfView:n=>{t({darkPointsOfView:n})},setLoaderTheme:n=>{t({loaderTheme:n})},setCurrentMaterialColor:n=>{t({currentMaterialColor:n})},setCurrentDiamondCut:n=>{t({currentDiamondCut:n})},setCurrentHalo:n=>{t({currentHalo:n})},setCurrentSize:n=>{t({currentSize:n})},setCurrentBand:n=>{t({currentBand:n})},setReflectionMap:n=>{t({reflectionMap:n})},setEnvMapRotation:n=>{t({envMapRotation:n})},setBackgroundColor(n){t({backgroundColor:n})},setRotateEnvMapWithCamera(n){t({rotateEnvMapWithCamera:n})},setApplyEnvMapOnBackground(n){t({applyEnvMapOnBackground:n})},setEnvironmentIntensity(n){t({environmentIntensity:n})},setBackgroundBlurriness(n){t({backgroundBlurriness:n})},setBackgroundRotation(n){t({backgroundRotation:n})},setEngravingText:n=>{t({engravingText:n})},setCurrentLetter:n=>{t({currentLetter:n})},setSelectedJewelTab:n=>{t({selectedJewelTab:n})},setTryon:n=>{t({tryon:n})},setMaterials:n=>{t({materials:n})},setMaterialConfigIdx:(n,r)=>{const{selectedMaterialConfigs:i}=e();i[n]=r},setBaseToneMappingActive:n=>{t({baseToneMappingActive:n})}}),ev=t=>{let e;const n=new Set,r=(s,l)=>{const c=typeof s=="function"?s(e):s;if(!Object.is(c,e)){const u=e;e=l??(typeof c!="object"||c===null)?c:Object.assign({},e,c),n.forEach(d=>d(e,u))}},i=()=>e,o={setState:r,getState:i,getInitialState:()=>a,subscribe:s=>(n.add(s),()=>n.delete(s))},a=e=t(r,i,o);return o},vE=t=>t?ev(t):ev,yE=t=>t;function bE(t,e=yE){const n=Uo.useSyncExternalStore(t.subscribe,()=>e(t.getState()),()=>e(t.getInitialState()));return Uo.useDebugValue(n),n}function tv(){return vE()(dE(pE(lE((...t)=>({...gE(...t)}))),{name:"trillion-viewer-store"}))}const Qi=Wi(tv()),Y=t=>bE(ct(Qi),t),wE="_viewer_container_1ejps_1",xE="_preloader_1ejps_7",_E="_gui_container_1ejps_17",SE="_loadingAnimation_1ejps_24",ME="_point_of_interest_button_1ejps_32",EE="_point_of_interest_button_wrap_1ejps_43",PE="_remove_point_of_interest_button_1ejps_49",CE="_add_point_of_interest_button_1ejps_49",AE="_add_point_of_interest_button_text_1ejps_60",TE="_remove_point_of_interest_button_text_1ejps_74",kE="_point_of_interest_list_1ejps_89",RE="_select_wrapper_1ejps_106",DE="_viewer_container_mobile_1ejps_119",mr={viewer_container:wE,preloader:xE,gui_container:_E,loadingAnimation:SE,point_of_interest_button:ME,point_of_interest_button_wrap:EE,remove_point_of_interest_button:PE,add_point_of_interest_button:CE,add_point_of_interest_button_text:AE,remove_point_of_interest_button_text:TE,point_of_interest_list:kE,select_wrapper:RE,viewer_container_mobile:DE};class nv extends v0{constructor(e){super(e),this.type=Tn}parse(e){const n=function(f,g){switch(f){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(g||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(g||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(g||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(g||""))}},r=`
`,i=function(f,g,b){g=g||1024;let x=f.pos,S=-1,E=0,M="",P=String.fromCharCode.apply(null,new Uint16Array(f.subarray(x,x+128)));for(;0>(S=P.indexOf(r))&&E<g&&x<f.byteLength;)M+=P,E+=P.length,x+=128,P+=String.fromCharCode.apply(null,new Uint16Array(f.subarray(x,x+128)));return-1<S?(f.pos+=E+S+1,M+P.slice(0,S)):!1},o=function(f){const g=/^#\?(\S+)/,b=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,x=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,S=/^\s*FORMAT=(\S+)\s*$/,E=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,M={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let P,A;for((f.pos>=f.byteLength||!(P=i(f)))&&n(1,"no header found"),(A=P.match(g))||n(3,"bad initial token"),M.valid|=1,M.programtype=A[1],M.string+=P+`
`;P=i(f),P!==!1;){if(M.string+=P+`
`,P.charAt(0)==="#"){M.comments+=P+`
`;continue}if((A=P.match(b))&&(M.gamma=parseFloat(A[1])),(A=P.match(x))&&(M.exposure=parseFloat(A[1])),(A=P.match(S))&&(M.valid|=2,M.format=A[1]),(A=P.match(E))&&(M.valid|=4,M.height=parseInt(A[1],10),M.width=parseInt(A[2],10)),M.valid&2&&M.valid&4)break}return M.valid&2||n(3,"missing format specifier"),M.valid&4||n(3,"missing image size specifier"),M},a=function(f,g,b){const x=g;if(x<8||x>32767||f[0]!==2||f[1]!==2||f[2]&128)return new Uint8Array(f);x!==(f[2]<<8|f[3])&&n(3,"wrong scanline width");const S=new Uint8Array(4*g*b);S.length||n(4,"unable to allocate buffer space");let E=0,M=0;const P=4*x,A=new Uint8Array(4),k=new Uint8Array(P);let D=b;for(;D>0&&M<f.byteLength;){M+4>f.byteLength&&n(1),A[0]=f[M++],A[1]=f[M++],A[2]=f[M++],A[3]=f[M++],(A[0]!=2||A[1]!=2||(A[2]<<8|A[3])!=x)&&n(3,"bad rgbe scanline format");let O=0,z;for(;O<P&&M<f.byteLength;){z=f[M++];const $=z>128;if($&&(z-=128),(z===0||O+z>P)&&n(3,"bad scanline data"),$){const Z=f[M++];for(let re=0;re<z;re++)k[O++]=Z}else k.set(f.subarray(M,M+z),O),O+=z,M+=z}const X=x;for(let $=0;$<X;$++){let Z=0;S[E]=k[$+Z],Z+=x,S[E+1]=k[$+Z],Z+=x,S[E+2]=k[$+Z],Z+=x,S[E+3]=k[$+Z],E+=4}D--}return S},s=function(f,g,b,x){const S=f[g+3],E=Math.pow(2,S-128)/255;b[x+0]=f[g+0]*E,b[x+1]=f[g+1]*E,b[x+2]=f[g+2]*E,b[x+3]=1},l=function(f,g,b,x){const S=f[g+3],E=Math.pow(2,S-128)/255;b[x+0]=Ho.toHalfFloat(Math.min(f[g+0]*E,65504)),b[x+1]=Ho.toHalfFloat(Math.min(f[g+1]*E,65504)),b[x+2]=Ho.toHalfFloat(Math.min(f[g+2]*E,65504)),b[x+3]=Ho.toHalfFloat(1)},c=new Uint8Array(e);c.pos=0;const u=o(c),d=u.width,h=u.height,p=a(c.subarray(c.pos),d,h);let v,y,m;switch(this.type){case kn:m=p.length/4;const f=new Float32Array(m*4);for(let b=0;b<m;b++)s(p,b*4,f,b*4);v=f,y=kn;break;case Tn:m=p.length/4;const g=new Uint16Array(m*4);for(let b=0;b<m;b++)l(p,b*4,g,b*4);v=g,y=Tn;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:d,height:h,data:v,header:u.string,gamma:u.gamma,exposure:u.exposure,type:y}}setDataType(e){return this.type=e,this}load(e,n,r,i){function o(a,s){switch(a.type){case kn:case Tn:a.colorSpace=dn,a.minFilter=kt,a.magFilter=kt,a.generateMipmaps=!1,a.flipY=!0;break}n&&n(a,s)}return super.load(e,o,r,i)}}const rv={type:"change"},_h={type:"start"},iv={type:"end"},uc=new ZS,ov=new $d,IE=Math.cos(70*y0.DEG2RAD),xt=new L,en=2*Math.PI,Be={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Sh=1e-6;class OE extends b0{constructor(e,n=null){super(e,n),this.state=Be.NONE,this.enabled=!0,this.target=new L,this.cursor=new L,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Rn.ROTATE,MIDDLE:Rn.DOLLY,RIGHT:Rn.PAN},this.touches={ONE:Dn.ROTATE,TWO:Dn.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new L,this._lastQuaternion=new Et,this._lastTargetPosition=new L,this._quat=new Et().setFromUnitVectors(e.up,new L(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new $r,this._sphericalDelta=new $r,this._scale=1,this._panOffset=new L,this._rotateStart=new Me,this._rotateEnd=new Me,this._rotateDelta=new Me,this._panStart=new Me,this._panEnd=new Me,this._panDelta=new Me,this._dollyStart=new Me,this._dollyEnd=new Me,this._dollyDelta=new Me,this._dollyDirection=new L,this._mouse=new Me,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=NE.bind(this),this._onPointerDown=LE.bind(this),this._onPointerUp=FE.bind(this),this._onContextMenu=WE.bind(this),this._onMouseWheel=jE.bind(this),this._onKeyDown=UE.bind(this),this._onTouchStart=VE.bind(this),this._onTouchMove=HE.bind(this),this._onMouseDown=zE.bind(this),this._onMouseMove=BE.bind(this),this._interceptControlDown=YE.bind(this),this._interceptControlUp=GE.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(rv),this.update(),this.state=Be.NONE}update(e=null){const n=this.object.position;xt.copy(n).sub(this.target),xt.applyQuaternion(this._quat),this._spherical.setFromVector3(xt),this.autoRotate&&this.state===Be.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=en:r>Math.PI&&(r-=en),i<-Math.PI?i+=en:i>Math.PI&&(i-=en),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=a!=this._spherical.radius}if(xt.setFromSpherical(this._spherical),xt.applyQuaternion(this._quatInverse),n.copy(this.target).add(xt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const s=xt.length();a=this._clampDistance(s*this._scale);const l=s-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),o=!!l}else if(this.object.isOrthographicCamera){const s=new L(this._mouse.x,this._mouse.y,0);s.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=l!==this.object.zoom;const c=new L(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(s),this.object.updateMatrixWorld(),a=xt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(uc.origin.copy(this.object.position),uc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(uc.direction))<IE?this.object.lookAt(this.target):(ov.setFromNormalAndCoplanarPoint(this.object.up,this.target),uc.intersectPlane(ov,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>Sh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Sh||this._lastTargetPosition.distanceToSquared(this.target)>Sh?(this.dispatchEvent(rv),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?en/60*this.autoRotateSpeed*e:en/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){xt.setFromMatrixColumn(n,0),xt.multiplyScalar(-e),this._panOffset.add(xt)}_panUp(e,n){this.screenSpacePanning===!0?xt.setFromMatrixColumn(n,1):(xt.setFromMatrixColumn(n,0),xt.crossVectors(this.object.up,xt)),xt.multiplyScalar(e),this._panOffset.add(xt)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;xt.copy(i).sub(this.target);let o=xt.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/r.clientHeight,this.object.matrix),this._panUp(2*n*o/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,o=n-r.top,a=r.width,s=r.height;this._mouse.x=i/a*2-1,this._mouse.y=-(o/s)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(en*this._rotateDelta.x/n.clientHeight),this._rotateUp(en*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(en*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-en*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(en*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-en*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,o=Math.sqrt(r*r+i*i);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),o=.5*(e.pageY+r.y);this._rotateEnd.set(i,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(en*this._rotateDelta.x/n.clientHeight),this._rotateUp(en*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,o=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+n.x)*.5,s=(e.pageY+n.y)*.5;this._updateZoomParameters(a,s)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new Me,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function LE(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t)))}function NE(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function FE(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(iv),this.state=Be.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function zE(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Rn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Be.DOLLY;break;case Rn.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Be.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Be.ROTATE}break;case Rn.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Be.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Be.PAN}break;default:this.state=Be.NONE}this.state!==Be.NONE&&this.dispatchEvent(_h)}function BE(t){switch(this.state){case Be.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Be.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Be.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function jE(t){this.enabled===!1||this.enableZoom===!1||this.state!==Be.NONE||(t.preventDefault(),this.dispatchEvent(_h),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(iv))}function UE(t){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(t)}function VE(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Dn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Be.TOUCH_ROTATE;break;case Dn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Be.TOUCH_PAN;break;default:this.state=Be.NONE}break;case 2:switch(this.touches.TWO){case Dn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Be.TOUCH_DOLLY_PAN;break;case Dn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Be.TOUCH_DOLLY_ROTATE;break;default:this.state=Be.NONE}break;default:this.state=Be.NONE}this.state!==Be.NONE&&this.dispatchEvent(_h)}function HE(t){switch(this._trackPointer(t),this.state){case Be.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Be.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Be.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Be.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Be.NONE}}function WE(t){this.enabled!==!1&&t.preventDefault()}function YE(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function GE(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const qi=new QS,zt=new L,ti=new L,nt=new Et,av={X:new L(1,0,0),Y:new L(0,1,0),Z:new L(0,0,1)},Mh={type:"change"},sv={type:"mouseDown",mode:null},lv={type:"mouseUp",mode:null},cv={type:"objectChange"};class XE extends b0{constructor(e,n=null){super(void 0,n);const r=new $E(this);this._root=r;const i=new eP;this._gizmo=i,r.add(i);const o=new tP;this._plane=o,r.add(o);const a=this;function s(b,x){let S=x;Object.defineProperty(a,b,{get:function(){return S!==void 0?S:x},set:function(E){S!==E&&(S=E,o[b]=E,i[b]=E,a.dispatchEvent({type:b+"-changed",value:E}),a.dispatchEvent(Mh))}}),a[b]=x,o[b]=x,i[b]=x}s("camera",e),s("object",void 0),s("enabled",!0),s("axis",null),s("mode","translate"),s("translationSnap",null),s("rotationSnap",null),s("scaleSnap",null),s("space","world"),s("size",1),s("dragging",!1),s("showX",!0),s("showY",!0),s("showZ",!0),s("minX",-1/0),s("maxX",1/0),s("minY",-1/0),s("maxY",1/0),s("minZ",-1/0),s("maxZ",1/0);const l=new L,c=new L,u=new Et,d=new Et,h=new L,p=new Et,v=new L,y=new L,m=new L,f=0,g=new L;s("worldPosition",l),s("worldPositionStart",c),s("worldQuaternion",u),s("worldQuaternionStart",d),s("cameraPosition",h),s("cameraQuaternion",p),s("pointStart",v),s("pointEnd",y),s("rotationAxis",m),s("rotationAngle",f),s("eye",g),this._offset=new L,this._startNorm=new L,this._endNorm=new L,this._cameraScale=new L,this._parentPosition=new L,this._parentQuaternion=new Et,this._parentQuaternionInv=new Et,this._parentScale=new L,this._worldScaleStart=new L,this._worldQuaternionInv=new Et,this._worldScale=new L,this._positionStart=new L,this._quaternionStart=new Et,this._scaleStart=new L,this._getPointer=KE.bind(this),this._onPointerDown=QE.bind(this),this._onPointerHover=ZE.bind(this),this._onPointerMove=qE.bind(this),this._onPointerUp=JE.bind(this),n!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&qi.setFromCamera(e,this.camera);const n=Eh(this._gizmo.picker[this.mode],qi);n?this.axis=n.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&qi.setFromCamera(e,this.camera);const n=Eh(this._plane,qi,!0);n&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(n.point).sub(this.worldPositionStart)),this.dragging=!0,sv.mode=this.mode,this.dispatchEvent(sv)}}pointerMove(e){const n=this.axis,r=this.mode,i=this.object;let o=this.space;if(r==="scale"?o="local":(n==="E"||n==="XYZE"||n==="XYZ")&&(o="world"),i===void 0||n===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&qi.setFromCamera(e,this.camera);const a=Eh(this._plane,qi,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),r==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),o==="local"&&n!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),n.indexOf("X")===-1&&(this._offset.x=0),n.indexOf("Y")===-1&&(this._offset.y=0),n.indexOf("Z")===-1&&(this._offset.z=0),o==="local"&&n!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(o==="local"&&(i.position.applyQuaternion(nt.copy(this._quaternionStart).invert()),n.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),n.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),n.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),o==="world"&&(i.parent&&i.position.add(zt.setFromMatrixPosition(i.parent.matrixWorld)),n.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),n.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),n.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(zt.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(r==="scale"){if(n.search("XYZ")!==-1){let s=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(s*=-1),ti.set(s,s,s)}else zt.copy(this.pointStart),ti.copy(this.pointEnd),zt.applyQuaternion(this._worldQuaternionInv),ti.applyQuaternion(this._worldQuaternionInv),ti.divide(zt),n.search("X")===-1&&(ti.x=1),n.search("Y")===-1&&(ti.y=1),n.search("Z")