threepipe
Version:
A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.
766 lines (765 loc) • 1.67 MB
JavaScript
import { EventDispatcher as Ui, Clock as rp, Vector3 as b, MOUSE as Mo, TOUCH as Io, Spherical as bn, Quaternion as ye, Vector2 as ae, Ray as aA, Plane as Sl, MathUtils as Qe, Object3D as oi, Raycaster as Gh, CylinderGeometry as zi, BoxGeometry as ri, BufferGeometry as ii, Float32BufferAttribute as Ze, Mesh as J, OctahedronGeometry as bc, Line as Cs, SphereGeometry as En, Euler as dt, Matrix4 as le, PlaneGeometry as jh, DoubleSide as Ds, TorusGeometry as rh, LineBasicMaterial as jr, MeshBasicMaterial as yo, Group as Ci, Box3 as Aa, Box2 as lA, Cache as Bi, DataTexture as ya, RGBAFormat as Jt, UnsignedByteType as ut, LinearSRGBColorSpace as mt, DataUtils as Vi, RGBM16ColorSpace as np, SRGBColorSpace as pt, NoColorSpace as ni, BufferAttribute as qe, InstancedBufferAttribute as op, InterleavedBuffer as cA, InterleavedBufferAttribute as Cr, TrianglesDrawMode as o0, TriangleFanDrawMode as dd, TriangleStripDrawMode as hA, HalfFloatType as lt, FloatType as wt, RGBADepthPacking as gl, BasicDepthPacking as uA, UnsignedInt248Type as a0, UnsignedShort5551Type as l0, UnsignedShort4444Type as c0, UnsignedIntType as ap, IntType as h0, UnsignedShortType as u0, ShortType as d0, ByteType as p0, DisplayP3ColorSpace as dA, EquirectangularReflectionMapping as Yl, CubeUVReflectionMapping as f0, CubeReflectionMapping as g0, UVMapping as pA, CustomBlending as fr, MultiplyBlending as fA, SubtractiveBlending as gA, AdditiveBlending as mA, NormalBlending as zh, NoBlending as rr, Texture as Li, InstancedMesh as Hh, ShaderMaterial as Wr, PerspectiveCamera as Kl, Scene as Zo, HemisphereLight as AA, InstancedBufferGeometry as m0, InstancedInterleavedBuffer as nh, WireframeGeometry as yA, Sphere as Vh, ShaderLib as kr, UniformsUtils as Jl, UniformsLib as gn, Vector4 as gt, Line3 as vA, OrthographicCamera as va, WebGLRenderer as lp, BackSide as _A, Color as Z, Sprite as wA, CanvasTexture as _a, RepeatWrapping as us, LinearFilter as Ne, SpriteMaterial as CA, CurvePath as cp, Matrix2 as A0, Matrix3 as Wh, ObjectLoader as hp, MaterialLoader as y0, Shape as qh, Curve as bA, Path as v0, ArcCurve as EA, CatmullRomCurve3 as oh, CubicBezierCurve as xA, CubicBezierCurve3 as SA, EllipseCurve as up, LineCurve as Yh, LineCurve3 as Xl, QuadraticBezierCurve as MA, QuadraticBezierCurve3 as IA, SplineCurve as DA, AnimationClip as dp, Source as TA, CubeTexture as _0, FileLoader as Qt, ShaderChunk as as, ClampToEdgeWrapping as Ei, MirroredRepeatWrapping as Ml, NearestFilter as br, NearestMipmapNearestFilter as pp, NearestMipmapLinearFilter as fp, LinearMipmapNearestFilter as gp, LinearMipmapLinearFilter as io, NeverDepth as w0, AlwaysDepth as C0, LessDepth as b0, LessEqualDepth as BA, EqualDepth as E0, GreaterEqualDepth as x0, GreaterDepth as S0, NotEqualDepth as M0, AddEquation as mp, SubtractEquation as I0, ReverseSubtractEquation as D0, MinEquation as T0, MaxEquation as B0, ZeroFactor as Qf, OneFactor as kf, SrcColorFactor as Nf, OneMinusSrcColorFactor as Gf, SrcAlphaFactor as pd, OneMinusSrcAlphaFactor as fd, DstAlphaFactor as jf, OneMinusDstAlphaFactor as zf, DstColorFactor as Hf, OneMinusDstColorFactor as Vf, SrcAlphaSaturateFactor as P0, ConstantColorFactor as Ec, OneMinusConstantColorFactor as xc, ConstantAlphaFactor as al, OneMinusConstantAlphaFactor as ll, TangentSpaceNormalMap as Il, ObjectSpaceNormalMap as R0, FrontSide as wa, KeepStencilOp as bu, AlwaysStencilFunc as L0, MultiplyOperation as PA, ColorManagement as ml, GLSL3 as O0, GLSL1 as F0, MeshDepthMaterial as Ap, MeshPhysicalMaterial as Kh, MeshPhongMaterial as Al, AmbientLight as RA, DirectionalLight as $l, PointLight as Dl, RectAreaLight as LA, SpotLight as Jh, WebGLRenderTarget as yp, DepthTexture as U0, DepthFormat as Q0, WebGLCubeRenderTarget as k0, LinearMipMapLinearFilter as Wf, LoadingManager as N0, LoaderUtils as Er, Uniform as G0, CompressedTexture as yl, PropertyBinding as qr, InterpolateDiscrete as OA, InterpolateLinear as vp, MeshStandardMaterial as Zl, ImageUtils as j0, TextureLoader as so, ImageBitmapLoader as z0, Material as vl, SkinnedMesh as FA, LineSegments as gd, LineLoop as H0, Points as _l, Skeleton as UA, Bone as md, Loader as Oi, VectorKeyframeTrack as Ad, NumberKeyframeTrack as yd, QuaternionKeyframeTrack as ah, Interpolant as V0, PointsMaterial as Xn, DefaultLoadingManager as W0, MeshLambertMaterial as q0, Uint16BufferAttribute as Y0, ShapeUtils as K0, DataTextureLoader as QA, RedFormat as Qo, BufferGeometryLoader as J0, ImageLoader as X0, VideoTexture as qf, NoToneMapping as $0, PCFShadowMap as Z0, ACESFilmicToneMapping as kA, LinearToneMapping as e_, ReinhardToneMapping as t_, CineonToneMapping as i_, CustomToneMapping as s_, AgXToneMapping as r_, CompressedCubeTexture as n_, CompressedArrayTexture as o_, LinearDisplayP3ColorSpace as a_, RGBA_ASTC_6x6_Format as Yf, RGFormat as cl, Data3DTexture as l_, RGB_S3TC_DXT1_Format as c_, RGB_PVRTC_4BPPV1_Format as h_, RGB_ETC2_Format as u_, RGB_ETC1_Format as d_, RGBA_S3TC_DXT5_Format as p_, RGBA_PVRTC_4BPPV1_Format as f_, RGBA_ETC2_EAC_Format as g_, RGBA_BPTC_Format as m_, RGBA_ASTC_4x4_Format as A_, CompressedTextureLoader as y_, Camera as NA, Triangle as GA, MeshNormalMaterial as v_, LoopRepeat as Kf, LoopOnce as Jf, AnimationMixer as __, TubeGeometry as w_, ShapeGeometry as C_ } from "three";
import { AmbientLight as fL, AnimationAction as gL, AnimationClip as mL, AnimationLoader as AL, AnimationMixer as yL, AnimationObjectGroup as vL, AnimationUtils as _L, ArcCurve as wL, ArrayCamera as CL, ArrowHelper as bL, Audio as EL, AudioAnalyser as xL, AudioContext as SL, AudioListener as ML, AudioLoader as IL, AxesHelper as DL, BatchedMesh as TL, Bone as BL, BooleanKeyframeTrack as PL, Box2 as RL, Box3 as LL, Box3Helper as OL, BoxGeometry as FL, BoxHelper as UL, BufferAttribute as QL, BufferGeometry as kL, BufferGeometryLoader as NL, Cache as GL, Camera as jL, CameraHelper as zL, CanvasTexture as HL, CapsuleGeometry as VL, CatmullRomCurve3 as WL, CircleGeometry as qL, Clock as YL, Color as KL, ColorKeyframeTrack as JL, ColorManagement as XL, CompressedArrayTexture as $L, CompressedCubeTexture as ZL, CompressedTexture as eO, CompressedTextureLoader as tO, ConeGeometry as iO, CubeCamera as sO, CubeTexture as rO, CubeTextureLoader as nO, CubicBezierCurve as oO, CubicBezierCurve3 as aO, CubicInterpolant as lO, Curve as cO, CurvePath as hO, CylinderGeometry as uO, Cylindrical as dO, Data3DTexture as pO, DataArrayTexture as fO, DataTexture as gO, DataTextureLoader as mO, DataUtils as AO, DefaultLoadingManager as yO, DepthTexture as vO, DirectionalLight as _O, DirectionalLightHelper as wO, DiscreteInterpolant as CO, DodecahedronGeometry as bO, EdgesGeometry as EO, EllipseCurve as xO, Euler as SO, EventDispatcher as MO, ExtrudeGeometry as IO, FileLoader as DO, Float16BufferAttribute as TO, Float32BufferAttribute as BO, Fog as PO, FogExp2 as RO, FramebufferTexture as LO, Frustum as OO, GLBufferAttribute as FO, GridHelper as UO, Group as QO, HemisphereLight as kO, HemisphereLightHelper as NO, IcosahedronGeometry as GO, ImageBitmapLoader as jO, ImageLoader as zO, ImageUtils as HO, InstancedBufferAttribute as VO, InstancedBufferGeometry as WO, InstancedInterleavedBuffer as qO, InstancedMesh as YO, Int16BufferAttribute as KO, Int32BufferAttribute as JO, Int8BufferAttribute as XO, InterleavedBuffer as $O, InterleavedBufferAttribute as ZO, Interpolant as eF, KeyframeTrack as tF, LOD as iF, LatheGeometry as sF, Layers as rF, Light as nF, LightProbe as oF, Line as aF, Line3 as lF, LineBasicMaterial as cF, LineCurve as hF, LineCurve3 as uF, LineDashedMaterial as dF, LineLoop as pF, LineSegments as fF, LinearInterpolant as gF, Loader as mF, LoaderUtils as AF, LoadingManager as yF, Material as vF, MaterialLoader as _F, MathUtils as wF, Matrix2 as CF, Matrix3 as bF, Matrix4 as EF, Mesh as xF, MeshBasicMaterial as SF, MeshDepthMaterial as MF, MeshDistanceMaterial as IF, MeshLambertMaterial as DF, MeshMatcapMaterial as TF, MeshNormalMaterial as BF, MeshPhongMaterial as PF, MeshPhysicalMaterial as RF, MeshStandardMaterial as LF, MeshToonMaterial as OF, NumberKeyframeTrack as FF, Object3D as UF, ObjectLoader as QF, OctahedronGeometry as kF, OrthographicCamera as NF, PMREMGenerator as GF, Path as jF, PerspectiveCamera as zF, Plane as HF, PlaneGeometry as VF, PlaneHelper as WF, PointLight as qF, PointLightHelper as YF, Points as KF, PointsMaterial as JF, PolarGridHelper as XF, PolyhedronGeometry as $F, PositionalAudio as ZF, PropertyBinding as eU, PropertyMixer as tU, QuadraticBezierCurve as iU, QuadraticBezierCurve3 as sU, Quaternion as rU, QuaternionKeyframeTrack as nU, QuaternionLinearInterpolant as oU, RawShaderMaterial as aU, Ray as lU, Raycaster as cU, RectAreaLight as hU, RenderTarget as uU, RingGeometry as dU, Scene as pU, ShaderChunk as fU, ShaderLib as gU, ShaderMaterial as mU, ShadowMaterial as AU, Shape as yU, ShapeGeometry as vU, ShapePath as _U, ShapeUtils as wU, Skeleton as CU, SkeletonHelper as bU, SkinnedMesh as EU, Source as xU, Sphere as SU, SphereGeometry as MU, Spherical as IU, SphericalHarmonics3 as DU, SplineCurve as TU, SpotLight as BU, SpotLightHelper as PU, Sprite as RU, SpriteMaterial as LU, StereoCamera as OU, StringKeyframeTrack as FU, TetrahedronGeometry as UU, Texture as QU, TextureLoader as kU, TorusGeometry as NU, TorusKnotGeometry as GU, Triangle as jU, TubeGeometry as zU, Uint16BufferAttribute as HU, Uint32BufferAttribute as VU, Uint8BufferAttribute as WU, Uint8ClampedBufferAttribute as qU, Uniform as YU, UniformsGroup as KU, UniformsLib as JU, UniformsUtils as XU, Vector2 as $U, Vector3 as ZU, Vector4 as eQ, VectorKeyframeTrack as tQ, VideoTexture as iQ, WebGL3DRenderTarget as sQ, WebGLArrayRenderTarget as rQ, WebGLCubeRenderTarget as nQ, WebGLRenderTarget as oQ, WebGLRenderer as aQ, WebGLUtils as lQ, WireframeGeometry as cQ } from "three";
import { serialize as S, onChangeDispatchEvent as vo, serializable as ec, now as Es, objectHasOwn as Ss, safeSetProperty as xi, FnCaller as _p, getOrCall as xe, deepAccessObject as Xh, LinearToSRGB as b_, canvasFlipY as jA, Serialization as Xe, getTypedArray as E_, arrayBufferToBase64 as Eu, base64ToArrayBuffer as zA, timeout as Zi, onChange as N, blobToDataURL as HA, parseFileExtension as lh, embedUrlRefs as x_, svgUrl as S_, objectMap as M_, uploadFile as I_, downloadBlob as wp, copyProps as D_, onChange3 as de, onChange2 as it, glsl as Pn, includesAll as T_, escapeRegExp as vd, imageUrlToImageData as B_, aesGcmDecrypt as P_, aesGcmEncrypt as R_, getUrlQueryParam as Cp, downloadFile as L_, wrapThisFunction2 as O_, updateBit as VA, createCanvasElement as F_, windowDialogWrapper as U_, createDiv as yn, createStyles as Tl, escapeHtml as Sc, JSUndoManager as Q_, recordUndoCommand as k_, setValueUndoCommand as N_, SimpleEventDispatcher as G_, PointerDragHelper as j_, absMax as z_, imageBitmapToBase64 as H_, makeColorSvgCircle as V_, toTitleCase as W_ } from "ts-browser-helpers";
import { Damper as uQ, FnCaller as dQ, JSUndoManager as pQ, LinearToSRGB as fQ, PointerDragHelper as gQ, SRGBToLinear as mQ, Serialization as AQ, SimpleEventDispatcher as yQ, TYPED_ARRAYS as vQ, absMax as _Q, aesGcmDecrypt as wQ, aesGcmEncrypt as CQ, arrayBufferToBase64 as bQ, base64ToArrayBuffer as EQ, blobToDataURL as xQ, blobToImage as SQ, canvasFlipY as MQ, clearBit as IQ, clonePrimitive as DQ, cloneScriptTag as TQ, colorToDataUrl as BQ, copyPrimitive as PQ, copyProps as RQ, createCanvasElement as LQ, createDiv as OQ, createImage as FQ, createScriptFromURL as UQ, createStyles as QQ, css as kQ, deepAccessObject as NQ, downloadBlob as GQ, downloadFile as jQ, embedUrlRefs as zQ, equalsPrimitive as HQ, escapeRegExp as VQ, findLastIndex as WQ, getFileHandle as qQ, getFilenameFromPath as YQ, getKeyByValue as KQ, getNewFileHandle as JQ, getOrCall as XQ, getPropertyDescriptor as $Q, getTypedArray as ZQ, getUrlQueryParam as ek, glsl as tk, html as ik, htmlDialogWrapper as sk, htmlToCanvas as rk, htmlToPng as nk, htmlToSvg as ok, imageBitmapToBase64 as ak, imageBitmapToBlob as lk, imageBitmapToCanvas as ck, imageDataToCanvas as hk, imageToCanvas as uk, imageUrlToImageData as dk, includesAll as pk, isPropertyWritable as fk, isWebpExportSupported as gk, longestCommonPrefix as mk, makeColorSvg as Ak, makeColorSvgCircle as yk, makeTextSvg as vk, mobileAndTabletCheck as _k, now as wk, objectHasOwn as Ck, objectMap as bk, objectMap2 as Ek, onChange as xk, onChange2 as Sk, onChange3 as Mk, onChangeDispatchEvent as Ik, parseFileExtension as Dk, pathJoin as Tk, prettyScrollbar as Bk, readFile as Pk, recordUndoCommand as Rk, remoteWorkerURL as Lk, replaceAll as Ok, safeReplaceString as Fk, safeSetProperty as Uk, serializable as Qk, serialize as kk, setInnerHTMLWithScripts as Nk, setUrlQueryParam as Gk, setValueUndoCommand as jk, svgToCanvas as zk, svgToPng as Hk, svgUrl as Vk, timeout as Wk, toCamelCase as qk, toTitleCase as Yk, updateBit as Kk, uploadFile as Jk, uuidV4 as Xk, verifyPermission as $k, windowDialogWrapper as Zk, wrapThisFunction as e3, wrapThisFunction2 as t3, writeFile as i3 } from "ts-browser-helpers";
import { uiInput as se, uiToggle as F, uiButton as me, uiFolderContainer as Ee, uiVector as yt, uiPanelContainer as Rn, uiSlider as te, generateUiConfig as Pt, generateValueConfig as at, uiDropdown as Nt, uiNumber as Re, uiColor as Mi, uiImage as en, uiConfig as Ls, uiMonitor as Ca, generateUiFolder as q_ } from "uiconfig.js";
import { UiConfigMethods as r3, UiConfigRenderer as n3, UiConfigRendererBase as o3, UiConfigTypeMap as a3, generateUiConfig as l3, generateUiFolder as c3, generateValueConfig as h3, uiButton as u3, uiColor as d3, uiConfig as p3, uiContainer as f3, uiDropdown as g3, uiFolderContainer as m3, uiImage as A3, uiInput as y3, uiMonitor as v3, uiNumber as _3, uiPanelContainer as w3, uiSlider as C3, uiToggle as b3, uiVector as E3 } from "uiconfig.js";
import { bounceInOut as Y_, bounceIn as K_, bounceOut as J_, anticipate as X_, backInOut as $_, backOut as Z_, backIn as ew, circInOut as tw, circOut as iw, circIn as sw, easeInOut as rw, easeOut as nw, easeIn as ow, linear as aw, animate as WA, keyframes as lw } from "@repalash/popmotion";
import { animate as S3 } from "@repalash/popmotion";
import cw from "stats.js";
function Xf(r, e) {
let t = r, i;
for (; !i && t; )
t = Object.getPrototypeOf(t), t && (i = Object.getOwnPropertyDescriptor(t, e));
return { proto: t, protoDesc: i };
}
function tc(r) {
return r.startsWith("http://") || r.startsWith("https://") || r.startsWith("data:") || r.startsWith("asset://") || r.startsWith("/") || r.startsWith("//");
}
const hw = `#ifndef SIMPLE_CAMERA_HELPERS
#define SIMPLE_CAMERA_HELPERS
#ifndef USE_TRANSMISSION
uniform mat4 projectionMatrix;
#endif
vec3 viewToScreen(const in vec3 pos){vec4 projected=projectionMatrix*vec4(pos,1.0);return vec3(0.5+0.5*projected.xy/projected.w,projected.w);}vec3 screenToView(const in vec2 uv,const in float viewZ){vec2 uv_=2.*uv-1.;float xe=-(uv_.x+projectionMatrix[2][0])*viewZ/projectionMatrix[0][0];float ye=-(uv_.y+projectionMatrix[2][1])*viewZ/projectionMatrix[1][1];return vec3(xe,ye,viewZ);}
#endif
`, uw = `#ifndef BASIC_CAMERA_HELPERS
#define BASIC_CAMERA_HELPERS
uniform mat4 projection;uniform vec2 cameraNearFar;uniform vec3 cameraPositionWorld;
#ifndef THREE_PACKING_INCLUDED
#define THREE_PACKING_INCLUDED
#include <packing>
#endif
float linstep(float edge0,float edge1,float value){return clamp((value-edge0)/(edge1-edge0),0.0,1.0);}float depthToViewZ(const in float depth){return(depth>0.999)?-cameraNearFar.y*1000.0 :-mix(cameraNearFar.x,cameraNearFar.y,depth);}float viewZToDepth(const in float viewZ){return linstep(-cameraNearFar.x,-cameraNearFar.y,viewZ);}vec4 viewToScreen3(const in vec3 pos){vec4 projected=projection*vec4(pos,1.0);projected.z=pos.z;projected.w=1./projected.w;projected.xyz*=projected.w;projected.xy=0.5+0.5*projected.xy;return projected;}vec3 screenToView3(const in vec2 uv,const in float viewZ){vec2 uv_=2.*uv-1.;float xe=-(uv_.x+projection[2][0])*viewZ/projection[0][0];float ye=-(uv_.y+projection[2][1])*viewZ/projection[1][1];return vec3(xe,ye,viewZ);}float viewZFromNDCZ(const in float depth){
#if PERSPECTIVE_CAMERA == 1
return perspectiveDepthToViewZ(depth,cameraNearFar.x,cameraNearFar.y);
#else
return orthographicDepthToViewZ(depth,cameraNearFar.x,cameraNearFar.y);
#endif
}
#endif
`, dw = `#ifndef BASIC_RANDOM_HELPERS
#define BASIC_RANDOM_HELPERS
float random(float n){return fract(sin(n)*43758.5453123);}float random2(vec2 n,float x){n+=x;return fract(sin(dot(n.xy,vec2(12.9898,78.233)))*43758.5453);}float random3(vec3 v){v=fract(v*443.8975);v+=dot(v,v.yzx+19.19);return fract((v.x+v.y)*v.z);}float interleavedGradientNoise(const in vec2 fragCoord,const in float seed){vec3 magic=vec3(0.06711056,0.00583715,52.9829189);return fract(magic.z*fract(dot(fragCoord.xy+seed*vec2(2.083,4.867),magic.xy)));}vec3 hash3(vec2 p){vec3 q=vec3(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3)),dot(p,vec2(419.2,371.9)));return fract(sin(q)*43758.5453);}
#endif
`, pw = "varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}", fw = "varying vec2 vUv;void main(){gl_FragColor=vec4(vUv,0.0,1.0);}", gw = `#ifndef VORONOI_HELPER
#define VORONOI_HELPER
float voronoi_distance(vec2 a,vec2 b,float metric){return distance(a,b);}float voronoi_f1_2d(in vec2 coord,in float randomness,in float flakeClamp,in float flakeRadius,inout vec3 outColor){vec2 cellPosition=floor(coord);vec2 localPosition=coord-cellPosition;float minDistance=8.0;vec2 targetOffset,targetPosition;for(int j=-1;j<=1;j++){for(int i=-1;i<=1;i++){vec2 cellOffset=vec2(i,j);vec2 pointPosition=cellOffset+hash3(cellPosition+cellOffset).xy*randomness;float distanceToPoint=voronoi_distance(pointPosition,localPosition,1.);if(distanceToPoint<minDistance){targetOffset=cellOffset;minDistance=distanceToPoint;targetPosition=pointPosition;}}}float outDistance=minDistance;float dist=step(flakeRadius,outDistance);outColor=hash3(cellPosition+hash3(cellPosition+targetOffset).xy*randomness+targetOffset);vec3 outColor1=minDistance<flakeRadius ? outColor : vec3(0.5,0.5,1.);outDistance=mix(dist,minDistance,flakeClamp);outColor=mix(outColor1,outColor,flakeClamp);return outDistance;}
#endif
`, qA = {
simpleCameraHelpers: hw,
cameraHelpers: uw,
randomHelpers: dw,
defaultVertex: pw,
defaultFragment: fw,
voronoiNoise: gw
};
var mw = Object.defineProperty, Aw = Object.getOwnPropertyDescriptor, Tr = (r, e, t, i) => {
for (var s = i > 1 ? void 0 : i ? Aw(e, t) : e, n = r.length - 1, o; n >= 0; n--)
(o = r[n]) && (s = (i ? o(e, t, s) : o(s)) || s);
return i && s && mw(e, t, s), s;
};
let Ts = class extends Ui {
constructor() {
super(...arguments), this._time = 0, this.delta = 0, this.endTime = 2, this.resetOnEnd = !0, this.stopOnEnd = !1, this.running = !1, this._clock = new rp(!1), this._start = !1, this._stop = !1, this._reset = !1, this._step = !1;
}
get time() {
return this._time;
}
/**
* Set the current time and step a frame
* @param value
*/
set time(r) {
this._time !== r && this.setTime(r, !0);
}
/**
* Returns true if the timeline is running or if it is set to step this/next frame.
*/
shouldRun() {
return this.running || this._step;
}
start() {
this._start = !0, this._stop && (this._stop = !1), this._step && (this._step = !1);
}
stop() {
this._stop = !0, this._start && (this._start = !1), this._step && (this._step = !1);
}
reset() {
this._reset = !0, this._step && (this._step = !1);
}
update(r) {
if (this._refreshParams(), !this.running) {
this.delta = this._clock.getDelta(), this._time = this._clock.elapsedTime;
return;
}
const e = r.getPlugin("ProgressivePlugin")?.postFrameConvergedRecordingDelta();
e && e > 0 ? (this.delta = e / 1e3, this._clock.oldTime += e, this._clock.elapsedTime += this.delta, this._time = this._clock.elapsedTime, this.dispatchEvent({ type: "update" })) : e !== void 0 && e === 0 ? (this.delta = 0, this._time = this._clock.elapsedTime) : (e === void 0 || e < 0) && (this.delta = this._clock.getDelta(), this._time = this._clock.elapsedTime, this.dispatchEvent({ type: "update" })), this._refreshParams();
}
_refreshParams() {
const r = this.endTime > 0 && this.time >= this.endTime && this.running, e = this.resetOnEnd && r, t = this.stopOnEnd && r;
(this._stop || t) && (this._clock.stop(), this._start = !1, this._stop = !1, this.running = this._clock.running, this.dispatchEvent({ type: "stop" })), this._start && (this._clock.start(), this._clock.elapsedTime = this.time, this._start = !1, this.running = this._clock.running, this.dispatchEvent({ type: "start" })), (this._reset || e) && (this._clock.elapsedTime = 0, this.time = 0, this.delta = 0, this._reset = !1, this.dispatchEvent({ type: "reset" })), this.running = this._clock.running;
}
// todo better name
update2(r) {
this._step = !1;
}
setTime(r, e = !0) {
r < 0 && (r = 0), this._clock.elapsedTime = r, this._time = r, this.delta = 0, this._reset = !1, this._start || (this._step = e), this.dispatchEvent({ type: "update" });
}
};
Tr([
se("Time", { readOnly: !0 })
], Ts.prototype, "time", 1);
Tr([
se("Delta", { readOnly: !0 })
], Ts.prototype, "delta", 2);
Tr([
se("Max Time"),
S(),
vo("endTimeChanged")
], Ts.prototype, "endTime", 2);
Tr([
F("Reset on End"),
S(),
vo("resetOnEndChanged")
], Ts.prototype, "resetOnEnd", 2);
Tr([
F("Stop on End"),
S(),
vo("stopOnEndChanged")
], Ts.prototype, "stopOnEnd", 2);
Tr([
se("Running", { readOnly: !0 })
], Ts.prototype, "running", 2);
Tr([
me("Start")
], Ts.prototype, "start", 1);
Tr([
me("Stop")
], Ts.prototype, "stop", 1);
Tr([
me("Reset")
], Ts.prototype, "reset", 1);
Ts = Tr([
ec("ViewerTimeline"),
Ee("Timeline")
], Ts);
class yw {
constructor(e) {
this._stats = new cw(), this._container = e, this._stats.dom.id = "stats-js", this._stats.dom.style.position = "absolute", this._stats.dom.style.left = "unset", this._stats.dom.style.right = "0";
}
show() {
this._container.appendChild(this._stats.dom), this._stats.showPanel(0);
}
hide() {
this._container.removeChild(this._stats.dom);
}
begin() {
this._stats.begin();
}
end() {
this._stats.end();
}
}
const vw = ".CustomContextMenu{position:absolute;background:#333e;min-width:8rem;color:#fff;font-size:.8rem;overflow:hidden;border-radius:8px;box-shadow:2px 2px 10px #6666;z-index:100000}.CustomContextMenu div{cursor:pointer;padding:6px 10px;transition:background-color .25s ease-in-out}.CustomContextMenu div:hover{background:#1a1a1c}#customContextMenu{background:#333e;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:.5px solid rgba(20,20,20,.3);width:auto;height:auto;position:absolute;display:flex;flex-direction:column;z-index:9999;padding:.4rem .25rem;border-radius:.375rem;min-width:8rem;pointer-events:auto;box-shadow:0 2px 10px #0c0c0c33}.customContextMenuItems{color:#fff;font-size:.8rem;font-family:monospace;background-color:transparent;cursor:pointer;padding:4px 8px;border-radius:.25rem;line-height:1rem;font-weight:500;transition:background-color .25s ease-in-out}.customContextMenuItems:hover{color:#fff;background-color:#017aff}", Rh = class Rh {
/**
* Initializes the context menu by adding event listeners.
* This method should be called before creating a context menu.
*/
static _initialize() {
this._inited = !0, document.addEventListener("pointerdown", (e) => {
this.Element && !this.Element.contains(e.target) && e.button === 0 && this.Remove();
});
}
/**
* Creates a custom context menu with specified items and options.
*
* @param items - An object containing menu item labels and corresponding callback functions.
* @param x - The horizontal position of the context menu.
* @param y - The vertical position of the context menu.
* @param show - Indicates whether the context menu should be displayed immediately.
* @param removeOnSelect - Indicates whether the context menu should be removed after an item is selected.
* @returns The HTML element representing the created context menu.
*/
static Create(e, t, i, s = !0, n = !0) {
this._inited || this._initialize(), this.Element && this.Remove();
const o = document.createElement("div");
o.id = "customContextMenu", o.style.top = i + "px", o.style.left = t + "px", o.innerHTML = "<style>" + vw + "</style>";
for (const [a, l] of Object.entries(e)) {
const c = document.createElement("div");
c.classList.add("customContextMenuItems"), c.textContent = a, o.appendChild(c), c.onclick = async () => {
await l(), n && this.Remove();
};
}
return this.Element = o, s && document.body.appendChild(o), o;
}
/**
* Removes the context menu from the DOM.
*/
static Remove() {
this.Element?.remove(), this.Element = void 0;
}
};
Rh.Element = void 0, Rh._inited = !1;
let ch = Rh;
const Lh = class Lh {
get inputEl() {
return this._inputEl;
}
get el() {
return this._el;
}
constructor(e, t, i) {
this._el = e, this._inputEl = t, this._listeners = {
drop: [],
dropstart: [],
droperror: []
}, this._onDragover = this._onDragover.bind(this), this._onDrop = this._onDrop.bind(this), this._onSelect = this._onSelect.bind(this), e?.addEventListener("dragover", this._onDragover, !1), e?.addEventListener("drop", this._onDrop, !1), t?.addEventListener("change", this._onSelect), i && Object.entries(i).forEach(([s, n]) => n && this.on(s, n));
}
on(e, t) {
return this._listeners[e].push(t), this;
}
_emit(e, t) {
return this._listeners[e].forEach((i) => i(t)), this;
}
/**
* Destroys the instance.
*/
destroy() {
const e = this._el, t = this._inputEl;
e?.removeEventListener("dragover", this._onDragover), e?.removeEventListener("drop", this._onDrop), t?.removeEventListener("change", this._onSelect);
}
/**
* References (and horror):
* - https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/items
* - https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/files
* - https://code.flickr.net/2012/12/10/drag-n-drop/
* - https://stackoverflow.com/q/44842247/1314762
*
*/
_onDrop(e) {
e.stopPropagation(), e.preventDefault(), this._emit("dropstart");
const t = Array.from(e.dataTransfer?.files || []), i = Array.from(e.dataTransfer?.items || []);
if (t.length === 0 && i.length === 0) {
this._fail("Required drag-and-drop APIs are not supported in this browser.");
return;
}
if (Lh.USE_DATA_TRANSFER_ITEMS && i.length > 0) {
const s = i.map((n) => n.webkitGetAsEntry());
this._loadNextEntry(/* @__PURE__ */ new Map(), s, e);
return;
}
this._emit("drop", {
nativeEvent: e,
files: new Map(t.map((s) => (s.filePath = s.name, [s.filePath, s])))
});
}
/**
* @param {Event} e
*/
_onDragover(e) {
e.stopPropagation(), e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy");
}
_onSelect(e) {
if (!this._inputEl) {
console.warn("Invalid Dropzone event ", e);
return;
}
this._emit("dropstart");
const t = [].slice.call(this._inputEl.files ?? new FileList()), i = /* @__PURE__ */ new Map();
t.forEach((s) => {
s.filePath = s.webkitRelativePath || s.name, i.set(s.filePath, s);
}), this._emit("drop", { files: i, nativeEvent: e });
}
/**
* Iterates through a list of FileSystemEntry objects, creates the fileMap
* tree, and emits the result.
* @param fileMap
* @param {Array<FileSystemEntry>} entries
* @param e
*/
_loadNextEntry(e, t, i) {
const s = t.pop();
if (!s) {
this._emit("drop", { files: e, nativeEvent: i });
return;
}
if (s.isFile)
s.file((n) => {
n.filePath = s.fullPath, e.set(s.fullPath, n), this._loadNextEntry(e, t, i);
}, (n) => console.error("Could not load file: %s", s.fullPath, n, "Try setting Dropzone.USE_DATA_TRANSFER_ITEMS to false."));
else if (s.isDirectory) {
const n = s.createReader(), o = (a) => {
a.length ? (t = t.concat(a), n.readEntries(o)) : this._loadNextEntry(e, t, i);
};
n.readEntries(o);
} else
console.warn("Unknown asset type: " + s.fullPath), this._loadNextEntry(e, t, i);
}
// /**
// * Inflates a File in .ZIP format, creates the fileMap tree, and emits the
// * result.
// * @param {File} file
// */
// _loadZip(file) {
// const pending = []
// const fileMap = new Map()
// const archive = new fs.FS()
//
// const traverse = (node) => {
// if (node.directory) {
// node.children.forEach(traverse)
// } else if (node.name[0] !== '.') {
// pending.push(new Promise((resolve) => {
// node.getData(new zip.BlobWriter(), (blob) => {
// blob.name = node.name
// fileMap.set(node.getFullname(), blob)
// resolve()
// })
// }))
// }
// }
//
// archive.importBlob(file, () => {
// traverse(archive.root)
// Promise.all(pending).then(() => {
// this._emit('drop', {files: fileMap, archive: file})
// })
// })
// }
// /**
// * @param {File} file
// * @return {Boolean}
// */
// _isZip(file) {
// return file.type === 'application/zip' || file.name.match(/\.zip$/)
// }
/**
* @throws
*/
_fail(e) {
this._emit("droperror", { message: e });
}
};
Lh.USE_DATA_TRANSFER_ITEMS = !0;
let _d = Lh;
const $f = { type: "change" }, xu = { type: "start" }, Zf = { type: "end" }, Mc = new aA(), eg = new Sl(), _w = Math.cos(70 * Qe.DEG2RAD);
class YA extends Ui {
constructor(e, t) {
super(), this.object = e, this.domElement = t, this.domElement.style.touchAction = "none", this.enabled = !0, this.target = new b(), this.cursor = new b(), this.minDistance = 1e-5, this.maxDistance = 1 / 0, this.autoPushTarget = !0, this.autoPullTarget = !0, this.clampMax = new b(1 / 0, 1 / 0, 1 / 0), this.clampMin = new b(-1 / 0, -1 / 0, -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 = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.maxZoomSpeed = 1, this.maxZoomSpeed = 1, this.dollyZoom = !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.throttleUpdate = 0, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: Mo.ROTATE, MIDDLE: Mo.DOLLY, RIGHT: Mo.PAN }, this.touches = { ONE: Io.ROTATE, TWO: Io.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this.getPolarAngle = function() {
return a.phi;
}, this.getAzimuthalAngle = function() {
return a.theta;
}, this.getDistance = function() {
return this.object.position.distanceTo(this.target);
}, this.listenToKeyEvents = function(P) {
P.addEventListener("keydown", So), this._domElementKeyEvents = P;
}, this.stopListenToKeyEvents = function() {
this._domElementKeyEvents.removeEventListener("keydown", So), this._domElementKeyEvents = null;
}, this.saveState = function() {
i.target0.copy(i.target), i.position0.copy(i.object.position), i.zoom0 = i.object.zoom;
}, this.reset = function() {
i.target.copy(i.target0), i.object.position.copy(i.position0), i.object.zoom = i.zoom0, i.object.updateProjectionMatrix(), i.dispatchEvent($f), i.update(), n = s.NONE;
}, this.update = (function() {
const P = new b(), ee = new ye().setFromUnitVectors(e.up, new b(0, 1, 0)), j = ee.clone().invert(), Je = new b(), yi = new ye(), lr = new b(), Ji = 2 * Math.PI, wu = 0;
return function(Cu = null) {
if (this.throttleUpdate && this.throttleUpdate >= 1 && Date.now() - wu < 1e3 / this.throttleUpdate)
return;
const Va = i.object.position;
P.copy(Va).sub(i.target), P.applyQuaternion(ee), a.setFromVector3(P), i.autoRotate && n === s.NONE && L(D(Cu)), i.enableDamping ? (a.theta += l.theta * i.dampingFactor, a.phi += l.phi * i.dampingFactor) : (a.theta += l.theta, a.phi += l.phi);
let Gs = i.minAzimuthAngle, js = i.maxAzimuthAngle;
isFinite(Gs) && isFinite(js) && (Gs < -Math.PI ? Gs += Ji : Gs > Math.PI && (Gs -= Ji), js < -Math.PI ? js += Ji : js > Math.PI && (js -= Ji), Gs <= js ? a.theta = Math.max(Gs, Math.min(js, a.theta)) : a.theta = a.theta > (Gs + js) / 2 ? Math.max(Gs, a.theta) : Math.min(js, a.theta)), a.phi = Math.max(i.minPolarAngle, Math.min(i.maxPolarAngle, a.phi)), a.makeSafe(), i.enableDamping === !0 ? i.target.addScaledVector(h, i.dampingFactor) : i.target.add(h), i.target.sub(i.cursor), i.target.clampLength(i.minTargetRadius, i.maxTargetRadius), i.target.add(i.cursor);
let Wa = 0, Hn = !1;
if (i.zoomToCursor && M || i.object.isOrthographicCamera)
a.radius = fe(a.radius);
else {
const Xi = a.radius;
Math.abs(l.radius) > 0 && (i.dollyZoom && (i.object.zoom = Math.max(Math.max(i.minZoom, 0.1), Math.min(Math.min(i.maxZoom, 20), i.object.zoom * (1 + l.radius * (i.enableDamping ? i.dampingFactor : 1)))), i.object.updateProjectionMatrix(), (i.object.zoom >= Math.min(i.maxZoom, 20) || i.object.zoom <= Math.max(i.minZoom, 0.1)) && (l.radius = 0)), a.radius *= 1 + l.radius * (i.enableDamping ? i.dampingFactor : 1)), Math.abs(c - 1) > 1e-5 && (i.dollyZoom && (i.object.zoom = Math.max(Math.max(i.minZoom, 0.1), Math.min(Math.min(i.maxZoom, 20), i.object.zoom * c)), i.object.updateProjectionMatrix(), (i.object.zoom >= Math.min(i.maxZoom, 20) || i.object.zoom <= Math.max(i.minZoom, 0.1)) && (c = 1)), a.radius *= c), i.autoPushTarget && a.radius < i.minDistance && (Wa = i.minDistance - a.radius), i.autoPullTarget && a.radius > i.maxDistance && (Wa = i.maxDistance - a.radius), a.radius = fe(a.radius), Hn = Xi != a.radius;
}
P.setFromSpherical(a), P.applyQuaternion(j), Va.copy(i.target).add(P), i.target.add(P.normalize().multiplyScalar(-Wa)), Va.clamp(i.clampMin, i.clampMax), i.target.clamp(i.clampMin, i.clampMax), i.object.lookAt(i.target);
let Vn = !1;
if (i.enableDamping === !0 && Math.abs(l.theta) + Math.abs(l.phi) + Math.abs(l.radius) + h.length() > 1e-3 ? (l.theta *= 1 - i.dampingFactor, l.phi *= 1 - i.dampingFactor, l.radius *= 1 - i.dampingFactor, h.multiplyScalar(1 - i.dampingFactor), Vn = !0) : (l.set(0, 0, 0), h.set(0, 0, 0)), i.zoomToCursor && M) {
let Xi = null;
if (i.object.isPerspectiveCamera) {
const zs = a.radius;
Xi = a.radius * c, Xi = fe(Xi);
const Hs = zs - Xi;
i.object.position.addScaledVector(w, Hs), i.object.updateMatrixWorld(), Hn = !!Hs;
} else if (i.object.isOrthographicCamera) {
const zs = new b(I.x, I.y, 0);
zs.unproject(i.object);
const Hs = i.object.zoom;
i.object.zoom = Math.max(i.minZoom, Math.min(i.maxZoom, i.object.zoom / c)), i.object.updateProjectionMatrix(), Hn = Hs !== i.object.zoom;
const Le = new b(I.x, I.y, 0);
Le.unproject(i.object), i.object.position.sub(Le).add(zs), i.object.updateMatrixWorld(), Xi = a.radius;
} else
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), i.zoomToCursor = !1;
Xi !== null && (this.screenSpacePanning ? i.target.set(0, 0, -1).transformDirection(i.object.matrix).multiplyScalar(Xi).add(i.object.position) : (Mc.origin.copy(i.object.position), Mc.direction.set(0, 0, -1).transformDirection(i.object.matrix), Math.abs(i.object.up.dot(Mc.direction)) < _w ? e.lookAt(i.target) : (eg.setFromNormalAndCoplanarPoint(i.object.up, i.target), Mc.intersectPlane(eg, i.target))));
} else if (i.object.isOrthographicCamera) {
const Xi = i.object.zoom;
i.object.zoom = Math.max(i.minZoom, Math.min(i.maxZoom, i.object.zoom / c)), Xi !== i.object.zoom && (i.object.updateProjectionMatrix(), Hn = !0);
}
return c = 1, M = !1, Hn || Vn || Je.distanceToSquared(i.object.position) > o || 8 * (1 - yi.dot(i.object.quaternion)) > o || lr.distanceToSquared(i.target) > o ? (i.dispatchEvent($f), Je.copy(i.object.position), yi.copy(i.object.quaternion), lr.copy(i.target), !0) : !1;
};
})(), this.stopDamping = function() {
l.set(0, 0, 0), h.set(0, 0, 0);
}, this.dispose = function() {
i.domElement.removeEventListener("contextmenu", wc), i.domElement.removeEventListener("pointerdown", mc), i.domElement.removeEventListener("pointercancel", on), i.domElement.removeEventListener("wheel", yc), i.domElement.removeEventListener("pointermove", ja), i.domElement.removeEventListener("pointerup", on), i.domElement.getRootNode().removeEventListener("keydown", vc, { capture: !0 }), i._domElementKeyEvents !== null && (i._domElementKeyEvents.removeEventListener("keydown", So), i._domElementKeyEvents = null);
};
const i = this, s = {
NONE: -1,
ROTATE: 0,
DOLLY: 1,
PAN: 2,
TOUCH_ROTATE: 3,
TOUCH_PAN: 4,
TOUCH_DOLLY_PAN: 5,
TOUCH_DOLLY_ROTATE: 6
};
let n = s.NONE;
const o = 1e-6, a = new bn(), l = new bn(0, 0, 0);
let c = 1;
const h = new b(), u = new ae(), d = new ae(), p = new ae(), f = new ae(), g = new ae(), m = new ae(), y = new ae(), _ = new ae(), v = new ae(), w = new b(), I = new ae();
let M = !1;
const B = [], C = {};
let x = !1;
function D(P) {
return P !== null ? 2 * Math.PI / 60 * i.autoRotateSpeed * P : 2 * Math.PI / 60 / 60 * i.autoRotateSpeed;
}
function T(P) {
return i.enableDamping && !i.zoomToCursor && !i.object.isOrthographicCamera ? 1 : Math.pow(0.95, i.zoomSpeed);
}
function L(P) {
l.theta -= P;
}
function W(P) {
l.phi -= P;
}
this.rotateUp = W, this.rotateLeft = L;
const Q = (function() {
const P = new b();
return function(j, Je) {
P.setFromMatrixColumn(Je, 0), P.multiplyScalar(-j), h.add(P);
};
})(), q = (function() {
const P = new b();
return function(j, Je) {
i.screenSpacePanning === !0 ? P.setFromMatrixColumn(Je, 1) : (P.setFromMatrixColumn(Je, 0), P.crossVectors(i.object.up, P)), P.multiplyScalar(j), h.add(P);
};
})(), V = (function() {
const P = new b();
return function(j, Je) {
const yi = i.domElement;
if (i.object.isPerspectiveCamera) {
const lr = i.object.position;
P.copy(lr).sub(i.target);
let Ji = P.length();
Ji *= Math.tan(i.object.fov / 2 * Math.PI / 180), Q(2 * j * Ji / yi.clientHeight, i.object.matrix), q(2 * Je * Ji / yi.clientHeight, i.object.matrix);
} else i.object.isOrthographicCamera ? (Q(j * (i.object.right - i.object.left) / i.object.zoom / yi.clientWidth, i.object.matrix), q(Je * (i.object.top - i.object.bottom) / i.object.zoom / yi.clientHeight, i.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), i.enablePan = !1);
};
})();
function Y(P, ee = 0) {
i.object.isPerspectiveCamera || i.object.isOrthographicCamera ? (c /= P, l.radius = Math.max(-i.maxZoomSpeed, Math.min(i.maxZoomSpeed, l.radius - ee))) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), i.enableZoom = !1);
}
function ie(P, ee = 0) {
i.object.isPerspectiveCamera || i.object.isOrthographicCamera ? (c *= P, l.radius = Math.max(-i.maxZoomSpeed, Math.min(i.maxZoomSpeed, l.radius + ee))) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), i.enableZoom = !1);
}
this.zoomIn = function(P) {
Y(1, P * i.zoomSpeed);
}, this.zoomOut = function(P) {
ie(1, P * i.zoomSpeed);
};
function ve(P, ee) {
if (!i.zoomToCursor)
return;
M = !0;
const j = i.domElement.getBoundingClientRect(), Je = P - j.left, yi = ee - j.top, lr = j.width, Ji = j.height;
I.x = Je / lr * 2 - 1, I.y = -(yi / Ji) * 2 + 1, w.set(I.x, I.y, 1).unproject(i.object).sub(i.object.position).normalize();
}
function fe(P) {
return Math.max(i.minDistance, Math.min(i.maxDistance, P));
}
function He(P) {
u.set(P.clientX, P.clientY);
}
function we(P) {
ve(P.clientX, P.clientX), y.set(P.clientX, P.clientY);
}
function Se(P) {
f.set(P.clientX, P.clientY);
}
function Ve(P) {
d.set(P.clientX, P.clientY), p.subVectors(d, u).multiplyScalar(i.rotateSpeed);
const ee = i.domElement;
L(2 * Math.PI * p.x / ee.clientHeight), W(2 * Math.PI * p.y / ee.clientHeight), u.copy(d), i.update();
}
function Pe(P) {
_.set(P.clientX, P.clientY), v.subVectors(_, y), v.y > 0 ? Y(T(v.y)) : v.y < 0 && ie(T(v.y)), y.copy(_), i.update();
}
function _e(P) {
g.set(P.clientX, P.clientY), m.subVectors(g, f).multiplyScalar(i.panSpeed), V(m.x, m.y), f.copy(g), i.update();
}
function Ht(P) {
ve(P.clientX, P.clientY);
let ee = 0;
switch (P.deltaMode) {
case 2:
ee += P.deltaY * 1;
break;
case 1:
ee += P.deltaY * 0.4;
break;
default:
ee += P.deltaY * 0.01;
break;
}
P.deltaY < 0 ? i.zoomToCursor || i.object.isOrthographicCamera ? ie(T()) : ie(1, ee * i.zoomSpeed) : P.deltaY > 0 && (i.zoomToCursor || i.object.isOrthographicCamera ? Y(T()) : Y(1, -ee * i.zoomSpeed)), i.update();
}
function ei(P) {
let ee = !1;
switch (P.code) {
case i.keys.UP:
P.ctrlKey || P.metaKey || P.shiftKey ? W(2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : V(0, i.keyPanSpeed), ee = !0;
break;
case i.keys.BOTTOM:
P.ctrlKey || P.metaKey || P.shiftKey ? W(-2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : V(0, -i.keyPanSpeed), ee = !0;
break;
case i.keys.LEFT:
P.ctrlKey || P.metaKey || P.shiftKey ? L(2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : V(i.keyPanSpeed, 0), ee = !0;
break;
case i.keys.RIGHT:
P.ctrlKey || P.metaKey || P.shiftKey ? L(-2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : V(-i.keyPanSpeed, 0), ee = !0;
break;
}
ee && (P.preventDefault(), i.update());
}
function Qs(P) {
if (B.length === 1)
u.set(P.pageX, P.pageY);
else {
const ee = is(P), j = 0.5 * (P.pageX + ee.x), Je = 0.5 * (P.pageY + ee.y);
u.set(j, Je);
}
}
function Ai(P) {
if (B.length === 1)
f.set(P.pageX, P.pageY);
else {
const ee = is(P), j = 0.5 * (P.pageX + ee.x), Je = 0.5 * (P.pageY + ee.y);
f.set(j, Je);
}
}
function Ni(P) {
const ee = is(P), j = P.pageX - ee.x, Je = P.pageY - ee.y, yi = Math.sqrt(j * j + Je * Je);
y.set(0, yi);
}
function Rr(P) {
i.enableZoom && Ni(P), i.enablePan && Ai(P);
}
function ks(P) {
i.enableZoom && Ni(P), i.enableRotate && Qs(P);
}
function Lr(P) {
if (B.length == 1)
d.set(P.pageX, P.pageY);
else {
const j = is(P), Je = 0.5 * (P.pageX + j.x), yi = 0.5 * (P.pageY + j.y);
d.set(Je, yi);
}
p.subVectors(d, u).multiplyScalar(i.rotateSpeed);
const ee = i.domElement;
L(2 * Math.PI * p.x / ee.clientHeight), W(2 * Math.PI * p.y / ee.clientHeight), u.copy(d);
}
function Ga(P) {
if (B.length === 1)
g.set(P.pageX, P.pageY);
else {
const ee = is(P), j = 0.5 * (P.pageX + ee.x), Je = 0.5 * (P.pageY + ee.y);
g.set(j, Je);
}
m.subVectors(g, f).multiplyScalar(i.panSpeed), V(m.x, m.y), f.copy(g);
}
function gc(P) {
const ee = is(P), j = P.pageX - ee.x, Je = P.pageY - ee.y, yi = Math.sqrt(j * j + Je * Je);
_.set(0, yi), v.set(0, Math.pow(_.y / y.y, i.zoomSpeed * 6)), Y(v.y), y.copy(_);
const lr = (P.pageX + ee.x) * 0.5, Ji = (P.pageY + ee.y) * 0.5;
ve(lr, Ji);
}
function mu(P) {
i.enableZoom && gc(P), i.enablePan && Ga(P);
}
function Au(P) {
i.enableZoom && gc(P), i.enableRotate && Lr(P);
}
function mc(P) {
i.enabled !== !1 && (B.length === 0 && (i.domElement.setPointerCapture(P.pointerId), i.domElement.addEventListener("pointermove", ja), i.domElement.addEventListener("pointerup", on)), !Ns(P) && (_u(P), P.pointerType === "touch" ? zn(P) : yu(P)));
}
function ja(P) {
i.enabled !== !1 && (P.pointerType === "touch" ? vu(P) : P.buttons ? Ac(P) : on(P));
}
function on(P) {
switch (As(P), B.length) {
case 0:
i.domElement.releasePointerCapture(P.pointerId), i.domElement.removeEventListener("pointermove", ja), i.domElement.removeEventListener("pointerup", on), i.dispatchEvent(Zf), n = s.NONE;
break;
case 1:
const ee = B[0], j = C[ee];
zn({ pointerId: ee, pageX: j.x, pageY: j.y });
break;
}
}
function yu(P) {
let ee;
switch (P.button) {
case 0:
ee = i.mouseButtons.LEFT;
break;
case 1:
ee = i.mouseButtons.MIDDLE;
break;
case 2:
ee = i.mouseButtons.RIGHT;
break;
default:
ee = -1;
}
switch (ee) {
case Mo.DOLLY:
if (i.enableZoom === !1) return;
we(P), n = s.DOLLY;
break;
case Mo.ROTATE:
if (P.ctrlKey || P.metaKey || P.shiftKey) {
if (i.enablePan === !1) return;
Se(P), n = s.PAN;
} else {
if (i.enableRotate === !1) return;
He(P), n = s.ROTATE;
}
break;
case Mo.PAN:
if (P.ctrlKey || P.metaKey || P.shiftKey) {
if (i.enableRotate === !1) return;
He(P), n = s.ROTATE;
} else {
if (i.enablePan === !1) return;
Se(P), n = s.PAN;
}
break;
default:
n = s.NONE;
}
n !== s.NONE && i.dispatchEvent(xu);
}
function Ac(P) {
switch (n) {
case s.ROTATE:
if (i.enableRotate === !1) return;
Ve(P);
break;
case s.DOLLY:
if (i.enableZoom === !1) return;
Pe(P);
break;
case s.PAN:
if (i.enablePan === !1) return;
_e(P);
break;
}
}
function yc(P) {
i.enabled === !1 || i.enableZoom === !1 || n !== s.NONE || (P.preventDefault(), i.dispatchEvent(xu), Ht(za(P)), i.dispatchEvent(Zf));
}
function za(P) {
const ee = P.deltaMode, j = {
clientX: P.clientX,
clientY: P.clientY,
deltaY: P.deltaY
};
switch (ee) {
case 1:
j.deltaY *= 16;
break;
case 2:
j.deltaY *= 100;
break;
}
return P.ctrlKey && !x && (j.deltaY *= 10), j;
}
function vc(P) {
P.key === "Control" && (x = !0, i.domElement.getRootNode().addEventListener("keyup", _c, { passive: !0, capture: !0 }));
}
function _c(P) {
P.key === "Control" && (x = !1, i.domElement.getRootNode().removeEventListener("keyup", _c, { passive: !0, capture: !0 }));
}
function So(P) {
i.enabled === !1 || i.enablePan === !1 || ei(P);
}
function zn(P) {
switch (Ha(P), B.length) {
case 1:
switch (i.touches.ONE) {
case Io.ROTATE:
if (i.enableRotate === !1) return;
Qs(P), n = s.TOUCH_ROTATE;
break;
case Io.PAN:
if (i.enablePan === !1) return;
Ai(P), n = s.TOUCH_PAN;
break;
default:
n = s.NONE;
}
break;
case 2:
switch (i.touches.TWO) {
case Io.DOLLY_PAN:
if (i.enableZoom === !1 && i.enablePan === !1) return;
Rr(P), n = s.TOUCH_DOLLY_PAN;
break;
case Io.DOLLY_ROTATE:
if (i.enableZoom === !1 && i.enableRotate === !1) return;
ks(P), n = s.TOUCH_DOLLY_ROTATE;
break;
default:
n = s.NONE;
}
break;
default:
n = s.NONE;
}
n !== s.NONE && i.dispatchEvent(xu);
}
function vu(P) {
switch (Ha(P), n) {
case s.TOUCH_ROTATE:
if (i.enableRotate === !1) return;
Lr(P), i.update();
break;
case s.TOUCH_PAN:
if (i.enablePan === !1) return;
Ga(P), i.update();
break;
case s.TOUCH_DOLLY_PAN:
if (i.enableZoom === !1 && i.enablePan === !1) return;
mu(P), i.update();
break;
case s.TOUCH_DOLLY_ROTATE:
if (i.enableZoom === !1 && i.enableRotate === !1) return;
Au(P), i.update();
break;
default:
n = s.NONE;
}
}
function wc(P) {
i.enabled !== !1 && P.preventDefault();
}
function _u(P) {
B.push(P.pointerId);
}
function As(P) {
delete C[P.pointerId];
for (let ee = 0; ee < B.length; ee++)
if (B[ee] == P.pointerId) {