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.
772 lines (771 loc) • 1.55 MB
JavaScript
import { EventDispatcher as Di, Clock as hd, Vector3 as S, MOUSE as la, TOUCH as ca, Spherical as hn, Quaternion as ye, Vector2 as ge, Ray as Hy, Plane as ud, MathUtils as Qe, Object3D as Ci, Raycaster as dd, CylinderGeometry as hs, BoxGeometry as Ai, BufferGeometry as ti, Float32BufferAttribute as nt, Mesh as ee, OctahedronGeometry as Jl, Line as js, SphereGeometry as Ra, Euler as ft, Matrix4 as _e, PlaneGeometry as ah, DoubleSide as vs, TorusGeometry as Up, LineBasicMaterial as rn, MeshBasicMaterial as wl, Box3 as Ja, Box2 as eA, Cache as bi, DataTexture as Xa, RGBAFormat as zt, UnsignedByteType as ct, LinearSRGBColorSpace as At, DataUtils as Qi, RGBM16ColorSpace as pd, SRGBColorSpace as ht, NoColorSpace as ei, BufferAttribute as We, InstancedBufferAttribute as fd, InterleavedBuffer as tA, InterleavedBufferAttribute as pr, TrianglesDrawMode as Vy, TriangleFanDrawMode as Cu, TriangleStripDrawMode as iA, HalfFloatType as at, FloatType as Ct, RGBADepthPacking as Wo, BasicDepthPacking as sA, UnsignedInt248Type as Wy, UnsignedShort5551Type as qy, UnsignedShort4444Type as Yy, UnsignedIntType as gd, IntType as Ky, UnsignedShortType as Jy, ShortType as Xy, ByteType as $y, DisplayP3ColorSpace as rA, EquirectangularReflectionMapping as bl, CubeUVReflectionMapping as Zy, CubeReflectionMapping as ev, UVMapping as nA, CustomBlending as ar, MultiplyBlending as aA, SubtractiveBlending as oA, AdditiveBlending as lA, NormalBlending as oh, NoBlending as Ks, Texture as Si, InstancedMesh as lh, ShaderMaterial as Or, PerspectiveCamera as El, Scene as La, HemisphereLight as cA, InstancedBufferGeometry as tv, InstancedInterleavedBuffer as Mc, WireframeGeometry as hA, Sphere as ch, ShaderLib as Dr, UniformsUtils as xl, UniformsLib as en, Vector4 as gt, Line3 as uA, OrthographicCamera as $a, WebGLRenderer as Ad, BackSide as dA, Color as X, Sprite as pA, CanvasTexture as Za, RepeatWrapping as is, LinearFilter as Ne, SpriteMaterial as fA, CurvePath as gA, Matrix2 as iv, Matrix3 as hh, ObjectLoader as md, MaterialLoader as sv, Shape as rv, Curve as AA, Path as nv, ArcCurve as av, CatmullRomCurve3 as _u, CubicBezierCurve as ov, CubicBezierCurve3 as lv, EllipseCurve as cv, LineCurve as hv, LineCurve3 as uv, QuadraticBezierCurve as dv, QuadraticBezierCurve3 as pv, SplineCurve as fv, AnimationClip as yd, Source as mA, CubeTexture as gv, FileLoader as Ot, ShaderChunk as Zi, ClampToEdgeWrapping as yi, MirroredRepeatWrapping as sl, NearestFilter as fr, NearestMipmapNearestFilter as vd, NearestMipmapLinearFilter as Cd, LinearMipmapNearestFilter as _d, LinearMipmapLinearFilter as kn, NeverDepth as Av, AlwaysDepth as mv, LessDepth as yv, LessEqualDepth as yA, EqualDepth as vv, GreaterEqualDepth as Cv, GreaterDepth as _v, NotEqualDepth as wv, AddEquation as wd, SubtractEquation as bv, ReverseSubtractEquation as Ev, MinEquation as xv, MaxEquation as Sv, ZeroFactor as Qp, OneFactor as kp, SrcColorFactor as Np, OneMinusSrcColorFactor as Gp, SrcAlphaFactor as wu, OneMinusSrcAlphaFactor as bu, DstAlphaFactor as jp, OneMinusDstAlphaFactor as zp, DstColorFactor as Hp, OneMinusDstColorFactor as Vp, SrcAlphaSaturateFactor as Iv, ConstantColorFactor as Xl, OneMinusConstantColorFactor as $l, ConstantAlphaFactor as Qo, OneMinusConstantAlphaFactor as ko, TangentSpaceNormalMap as rl, ObjectSpaceNormalMap as Mv, FrontSide as eo, KeepStencilOp as kh, AlwaysStencilFunc as Dv, MultiplyOperation as vA, ColorManagement as qo, GLSL3 as Tv, GLSL1 as Bv, MeshDepthMaterial as bd, MeshPhysicalMaterial as uh, MeshPhongMaterial as Yo, Group as zs, AmbientLight as CA, DirectionalLight as Sl, PointLight as nl, RectAreaLight as _A, SpotLight as dh, WebGLRenderTarget as Ed, DepthTexture as Pv, DepthFormat as Rv, WebGLCubeRenderTarget as Lv, LinearMipMapLinearFilter as Wp, LoadingManager as Ov, LoaderUtils as gr, Uniform as Fv, CompressedTexture as Ko, PropertyBinding as Fr, InterpolateDiscrete as wA, InterpolateLinear as xd, MeshStandardMaterial as Il, ImageUtils as Uv, TextureLoader as Nn, ImageBitmapLoader as Qv, Material as Jo, SkinnedMesh as bA, LineSegments as Eu, LineLoop as kv, Points as Xo, Skeleton as EA, Bone as xu, Loader as Ii, VectorKeyframeTrack as Su, NumberKeyframeTrack as Iu, QuaternionKeyframeTrack as Dc, Interpolant as Nv, PointsMaterial as On, DefaultLoadingManager as Gv, MeshLambertMaterial as jv, Uint16BufferAttribute as zv, ShapeUtils as Hv, DataTextureLoader as xA, RedFormat as va, BufferGeometryLoader as Vv, ImageLoader as Wv, VideoTexture as qp, NoToneMapping as qv, PCFShadowMap as Yv, MeshNormalMaterial as Kv, Camera as SA, CompressedTextureLoader as Jv, CompressedCubeTexture as Xv, CompressedArrayTexture as $v, LinearDisplayP3ColorSpace as Zv, RGBA_ASTC_6x6_Format as Yp, RGFormat as No, Data3DTexture as e0, RGB_S3TC_DXT1_Format as t0, RGB_PVRTC_4BPPV1_Format as i0, RGB_ETC2_Format as s0, RGB_ETC1_Format as r0, RGBA_S3TC_DXT5_Format as n0, RGBA_PVRTC_4BPPV1_Format as a0, RGBA_ETC2_EAC_Format as o0, RGBA_BPTC_Format as l0, RGBA_ASTC_4x4_Format as c0, ACESFilmicToneMapping as IA, LinearToneMapping as h0, ReinhardToneMapping as u0, CineonToneMapping as d0, CustomToneMapping as p0, AgXToneMapping as f0, LoopRepeat as Kp, LoopOnce as Jp, AnimationMixer as g0, Triangle as MA } from "three";
import { AmbientLight as UR, AnimationAction as QR, AnimationClip as kR, AnimationLoader as NR, AnimationMixer as GR, AnimationObjectGroup as jR, AnimationUtils as zR, ArcCurve as HR, ArrayCamera as VR, ArrowHelper as WR, Audio as qR, AudioAnalyser as YR, AudioContext as KR, AudioListener as JR, AudioLoader as XR, AxesHelper as $R, BatchedMesh as ZR, Bone as e2, BooleanKeyframeTrack as t2, Box2 as i2, Box3 as s2, Box3Helper as r2, BoxGeometry as n2, BoxHelper as a2, BufferAttribute as o2, BufferGeometry as l2, BufferGeometryLoader as c2, Cache as h2, Camera as u2, CameraHelper as d2, CanvasTexture as p2, CapsuleGeometry as f2, CatmullRomCurve3 as g2, CircleGeometry as A2, Clock as m2, Color as y2, ColorKeyframeTrack as v2, ColorManagement as C2, CompressedArrayTexture as _2, CompressedCubeTexture as w2, CompressedTexture as b2, CompressedTextureLoader as E2, ConeGeometry as x2, CubeCamera as S2, CubeTexture as I2, CubeTextureLoader as M2, CubicBezierCurve as D2, CubicBezierCurve3 as T2, CubicInterpolant as B2, Curve as P2, CurvePath as R2, CylinderGeometry as L2, Cylindrical as O2, Data3DTexture as F2, DataArrayTexture as U2, DataTexture as Q2, DataTextureLoader as k2, DataUtils as N2, DefaultLoadingManager as G2, DepthTexture as j2, DirectionalLight as z2, DirectionalLightHelper as H2, DiscreteInterpolant as V2, DodecahedronGeometry as W2, EdgesGeometry as q2, EllipseCurve as Y2, Euler as K2, EventDispatcher as J2, ExtrudeGeometry as X2, FileLoader as $2, Float16BufferAttribute as Z2, Float32BufferAttribute as eL, Fog as tL, FogExp2 as iL, FramebufferTexture as sL, Frustum as rL, GLBufferAttribute as nL, GridHelper as aL, Group as oL, HemisphereLight as lL, HemisphereLightHelper as cL, IcosahedronGeometry as hL, ImageBitmapLoader as uL, ImageLoader as dL, ImageUtils as pL, InstancedBufferAttribute as fL, InstancedBufferGeometry as gL, InstancedInterleavedBuffer as AL, InstancedMesh as mL, Int16BufferAttribute as yL, Int32BufferAttribute as vL, Int8BufferAttribute as CL, InterleavedBuffer as _L, InterleavedBufferAttribute as wL, Interpolant as bL, KeyframeTrack as EL, LOD as xL, LatheGeometry as SL, Layers as IL, Light as ML, LightProbe as DL, Line as TL, Line3 as BL, LineBasicMaterial as PL, LineCurve as RL, LineCurve3 as LL, LineDashedMaterial as OL, LineLoop as FL, LineSegments as UL, LinearInterpolant as QL, Loader as kL, LoaderUtils as NL, LoadingManager as GL, Material as jL, MaterialLoader as zL, MathUtils as HL, Matrix2 as VL, Matrix3 as WL, Matrix4 as qL, Mesh as YL, MeshBasicMaterial as KL, MeshDepthMaterial as JL, MeshDistanceMaterial as XL, MeshLambertMaterial as $L, MeshMatcapMaterial as ZL, MeshNormalMaterial as eO, MeshPhongMaterial as tO, MeshPhysicalMaterial as iO, MeshStandardMaterial as sO, MeshToonMaterial as rO, NumberKeyframeTrack as nO, Object3D as aO, ObjectLoader as oO, OctahedronGeometry as lO, OrthographicCamera as cO, PMREMGenerator as hO, Path as uO, PerspectiveCamera as dO, Plane as pO, PlaneGeometry as fO, PlaneHelper as gO, PointLight as AO, PointLightHelper as mO, Points as yO, PointsMaterial as vO, PolarGridHelper as CO, PolyhedronGeometry as _O, PositionalAudio as wO, PropertyBinding as bO, PropertyMixer as EO, QuadraticBezierCurve as xO, QuadraticBezierCurve3 as SO, Quaternion as IO, QuaternionKeyframeTrack as MO, QuaternionLinearInterpolant as DO, RawShaderMaterial as TO, Ray as BO, Raycaster as PO, RectAreaLight as RO, RenderTarget as LO, RingGeometry as OO, Scene as FO, ShaderChunk as UO, ShaderLib as QO, ShaderMaterial as kO, ShadowMaterial as NO, Shape as GO, ShapeGeometry as jO, ShapePath as zO, ShapeUtils as HO, Skeleton as VO, SkeletonHelper as WO, SkinnedMesh as qO, Source as YO, Sphere as KO, SphereGeometry as JO, Spherical as XO, SphericalHarmonics3 as $O, SplineCurve as ZO, SpotLight as eF, SpotLightHelper as tF, Sprite as iF, SpriteMaterial as sF, StereoCamera as rF, StringKeyframeTrack as nF, TetrahedronGeometry as aF, Texture as oF, TextureLoader as lF, TorusGeometry as cF, TorusKnotGeometry as hF, Triangle as uF, TubeGeometry as dF, Uint16BufferAttribute as pF, Uint32BufferAttribute as fF, Uint8BufferAttribute as gF, Uint8ClampedBufferAttribute as AF, Uniform as mF, UniformsGroup as yF, UniformsLib as vF, UniformsUtils as CF, Vector2 as _F, Vector3 as wF, Vector4 as bF, VectorKeyframeTrack as EF, VideoTexture as xF, WebGL3DRenderTarget as SF, WebGLArrayRenderTarget as IF, WebGLCubeRenderTarget as MF, WebGLRenderTarget as DF, WebGLRenderer as TF, WebGLUtils as BF, WireframeGeometry as PF } from "three";
import { serialize as x, onChangeDispatchEvent as to, serializable as Ml, now as fs, objectHasOwn as As, safeSetProperty as vi, FnCaller as Sd, getOrCall as xe, deepAccessObject as ph, LinearToSRGB as A0, canvasFlipY as DA, Serialization as $e, getTypedArray as m0, arrayBufferToBase64 as Nh, base64ToArrayBuffer as TA, timeout as Vi, onChange as H, blobToDataURL as BA, parseFileExtension as Tc, embedUrlRefs as y0, svgUrl as v0, objectMap as C0, uploadFile as _0, downloadBlob as Id, copyProps as w0, onChange3 as he, onChange2 as tt, glsl as mn, includesAll as b0, escapeRegExp as Mu, imageUrlToImageData as E0, aesGcmDecrypt as x0, aesGcmEncrypt as S0, getUrlQueryParam as Md, downloadFile as I0, wrapThisFunction2 as M0, createDiv as nn, updateBit as PA, createStyles as al, escapeHtml as Zl, JSUndoManager as D0, recordUndoCommand as T0, setValueUndoCommand as B0, SimpleEventDispatcher as P0, PointerDragHelper as R0, absMax as L0, imageBitmapToBase64 as O0, makeColorSvgCircle as F0, createCanvasElement as U0, windowDialogWrapper as Q0 } from "ts-browser-helpers";
import { Damper as LF, FnCaller as OF, JSUndoManager as FF, LinearToSRGB as UF, PointerDragHelper as QF, SRGBToLinear as kF, Serialization as NF, SimpleEventDispatcher as GF, TYPED_ARRAYS as jF, absMax as zF, aesGcmDecrypt as HF, aesGcmEncrypt as VF, arrayBufferToBase64 as WF, base64ToArrayBuffer as qF, blobToDataURL as YF, blobToImage as KF, canvasFlipY as JF, clearBit as XF, clonePrimitive as $F, cloneScriptTag as ZF, colorToDataUrl as eU, copyPrimitive as tU, copyProps as iU, createCanvasElement as sU, createDiv as rU, createImage as nU, createScriptFromURL as aU, createStyles as oU, css as lU, deepAccessObject as cU, downloadBlob as hU, downloadFile as uU, embedUrlRefs as dU, equalsPrimitive as pU, escapeRegExp as fU, findLastIndex as gU, getFileHandle as AU, getFilenameFromPath as mU, getKeyByValue as yU, getNewFileHandle as vU, getOrCall as CU, getPropertyDescriptor as _U, getTypedArray as wU, getUrlQueryParam as bU, glsl as EU, html as xU, htmlDialogWrapper as SU, htmlToCanvas as IU, htmlToPng as MU, htmlToSvg as DU, imageBitmapToBase64 as TU, imageBitmapToBlob as BU, imageBitmapToCanvas as PU, imageDataToCanvas as RU, imageToCanvas as LU, imageUrlToImageData as OU, includesAll as FU, isPropertyWritable as UU, isWebpExportSupported as QU, longestCommonPrefix as kU, makeColorSvg as NU, makeColorSvgCircle as GU, makeTextSvg as jU, mobileAndTabletCheck as zU, now as HU, objectHasOwn as VU, objectMap as WU, objectMap2 as qU, onChange as YU, onChange2 as KU, onChange3 as JU, onChangeDispatchEvent as XU, parseFileExtension as $U, pathJoin as ZU, prettyScrollbar as eQ, readFile as tQ, recordUndoCommand as iQ, remoteWorkerURL as sQ, replaceAll as rQ, safeReplaceString as nQ, safeSetProperty as aQ, serializable as oQ, serialize as lQ, setInnerHTMLWithScripts as cQ, setUrlQueryParam as hQ, setValueUndoCommand as uQ, svgToCanvas as dQ, svgToPng as pQ, svgUrl as fQ, timeout as gQ, toCamelCase as AQ, toTitleCase as mQ, updateBit as yQ, uploadFile as vQ, uuidV4 as CQ, verifyPermission as _Q, windowDialogWrapper as wQ, wrapThisFunction as bQ, wrapThisFunction2 as EQ, writeFile as xQ } from "ts-browser-helpers";
import { uiInput as ie, uiToggle as U, uiButton as me, uiFolderContainer as Me, uiVector as mt, uiPanelContainer as yn, uiSlider as re, generateUiConfig as Ht, generateValueConfig as RA, uiDropdown as Wt, uiNumber as Pe, uiColor as Ti, uiImage as zr, uiConfig as Js, uiMonitor as io, generateUiFolder as k0 } from "uiconfig.js";
import { UiConfigMethods as IQ, UiConfigRenderer as MQ, UiConfigRendererBase as DQ, UiConfigTypeMap as TQ, generateUiConfig as BQ, generateUiFolder as PQ, generateValueConfig as RQ, uiButton as LQ, uiColor as OQ, uiConfig as FQ, uiContainer as UQ, uiDropdown as QQ, uiFolderContainer as kQ, uiImage as NQ, uiInput as GQ, uiMonitor as jQ, uiNumber as zQ, uiPanelContainer as HQ, uiSlider as VQ, uiToggle as WQ, uiVector as qQ } from "uiconfig.js";
import N0 from "stats.js";
import { bounceInOut as G0, bounceIn as j0, bounceOut as z0, anticipate as H0, backInOut as V0, backOut as W0, backIn as q0, circInOut as Y0, circOut as K0, circIn as J0, easeInOut as X0, easeOut as $0, easeIn as Z0, linear as eC, animate as LA, keyframes as tC } from "@repalash/popmotion";
import { animate as KQ } from "@repalash/popmotion";
function Xp(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 Dl(r) {
return r.startsWith("http://") || r.startsWith("https://") || r.startsWith("data:") || r.startsWith("asset://") || r.startsWith("/") || r.startsWith("//");
}
const iC = `#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
`, sC = `#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
`, rC = `#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
`, nC = "varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}", aC = "varying vec2 vUv;void main(){gl_FragColor=vec4(vUv,0.0,1.0);}", oC = `#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
`, OA = {
simpleCameraHelpers: iC,
cameraHelpers: sC,
randomHelpers: rC,
defaultVertex: nC,
defaultFragment: aC,
voronoiNoise: oC
};
var lC = Object.defineProperty, cC = Object.getOwnPropertyDescriptor, _r = (r, e, t, i) => {
for (var s = i > 1 ? void 0 : i ? cC(e, t) : e, n = r.length - 1, a; n >= 0; n--)
(a = r[n]) && (s = (i ? a(e, t, s) : a(s)) || s);
return i && s && lC(e, t, s), s;
};
let Cs = class extends Di {
constructor() {
super(...arguments), this._time = 0, this.delta = 0, this.endTime = 2, this.resetOnEnd = !0, this.stopOnEnd = !1, this.running = !1, this._clock = new hd(!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" });
}
};
_r([
ie("Time", { readOnly: !0 })
], Cs.prototype, "time", 1);
_r([
ie("Delta", { readOnly: !0 })
], Cs.prototype, "delta", 2);
_r([
ie("Max Time"),
x(),
to("endTimeChanged")
], Cs.prototype, "endTime", 2);
_r([
U("Reset on End"),
x(),
to("resetOnEndChanged")
], Cs.prototype, "resetOnEnd", 2);
_r([
U("Stop on End"),
x(),
to("stopOnEndChanged")
], Cs.prototype, "stopOnEnd", 2);
_r([
ie("Running", { readOnly: !0 })
], Cs.prototype, "running", 2);
_r([
me("Start")
], Cs.prototype, "start", 1);
_r([
me("Stop")
], Cs.prototype, "stop", 1);
_r([
me("Reset")
], Cs.prototype, "reset", 1);
Cs = _r([
Ml("ViewerTimeline"),
Me("Timeline")
], Cs);
class hC {
constructor(e) {
this._stats = new N0(), 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 uC = ".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}", Zc = class Zc {
/**
* 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 a = document.createElement("div");
a.id = "customContextMenu", a.style.top = i + "px", a.style.left = t + "px", a.innerHTML = "<style>" + uC + "</style>";
for (const [o, l] of Object.entries(e)) {
const c = document.createElement("div");
c.classList.add("customContextMenuItems"), c.textContent = o, a.appendChild(c), c.onclick = async () => {
await l(), n && this.Remove();
};
}
return this.Element = a, s && document.body.appendChild(a), a;
}
/**
* Removes the context menu from the DOM.
*/
static Remove() {
this.Element?.remove(), this.Element = void 0;
}
};
Zc.Element = void 0, Zc._inited = !1;
let Bc = Zc;
const eh = class eh {
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 (eh.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(), a = (o) => {
o.length ? (t = t.concat(o), n.readEntries(a)) : this._loadNextEntry(e, t, i);
};
n.readEntries(a);
} 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 });
}
};
eh.USE_DATA_TRANSFER_ITEMS = !0;
let Du = eh;
const $p = { type: "change" }, Gh = { type: "start" }, Zp = { type: "end" }, ec = new Hy(), ef = new ud(), dC = Math.cos(70 * Qe.DEG2RAD);
class FA extends Di {
constructor(e, t) {
super(), this.object = e, this.domElement = t, this.domElement.style.touchAction = "none", this.enabled = !0, this.target = new S(), this.cursor = new S(), this.minDistance = 1e-5, this.maxDistance = 1 / 0, this.autoPushTarget = !0, this.autoPullTarget = !0, this.clampMax = new S(1 / 0, 1 / 0, 1 / 0), this.clampMin = new S(-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: la.ROTATE, MIDDLE: la.DOLLY, RIGHT: la.PAN }, this.touches = { ONE: ca.ROTATE, TWO: ca.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 o.phi;
}, this.getAzimuthalAngle = function() {
return o.theta;
}, this.getDistance = function() {
return this.object.position.distanceTo(this.target);
}, this.listenToKeyEvents = function(I) {
I.addEventListener("keydown", oa), this._domElementKeyEvents = I;
}, this.stopListenToKeyEvents = function() {
this._domElementKeyEvents.removeEventListener("keydown", oa), 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($p), i.update(), n = s.NONE;
}, this.update = (function() {
const I = new S(), Z = new ye().setFromUnitVectors(e.up, new S(0, 1, 0)), N = Z.clone().invert(), Je = new S(), pi = new ye(), er = new S(), ji = 2 * Math.PI, Uh = 0;
return function(Qh = null) {
if (this.throttleUpdate && this.throttleUpdate >= 1 && Date.now() - Uh < 1e3 / this.throttleUpdate)
return;
const So = i.object.position;
I.copy(So).sub(i.target), I.applyQuaternion(Z), o.setFromVector3(I), i.autoRotate && n === s.NONE && O(B(Qh)), i.enableDamping ? (o.theta += l.theta * i.dampingFactor, o.phi += l.phi * i.dampingFactor) : (o.theta += l.theta, o.phi += l.phi);
let Ts = i.minAzimuthAngle, Bs = i.maxAzimuthAngle;
isFinite(Ts) && isFinite(Bs) && (Ts < -Math.PI ? Ts += ji : Ts > Math.PI && (Ts -= ji), Bs < -Math.PI ? Bs += ji : Bs > Math.PI && (Bs -= ji), Ts <= Bs ? o.theta = Math.max(Ts, Math.min(Bs, o.theta)) : o.theta = o.theta > (Ts + Bs) / 2 ? Math.max(Ts, o.theta) : Math.min(Bs, o.theta)), o.phi = Math.max(i.minPolarAngle, Math.min(i.maxPolarAngle, o.phi)), o.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 Io = 0, Mn = !1;
if (i.zoomToCursor && P || i.object.isOrthographicCamera)
o.radius = de(o.radius);
else {
const zi = o.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)), o.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)), o.radius *= c), i.autoPushTarget && o.radius < i.minDistance && (Io = i.minDistance - o.radius), i.autoPullTarget && o.radius > i.maxDistance && (Io = i.maxDistance - o.radius), o.radius = de(o.radius), Mn = zi != o.radius;
}
I.setFromSpherical(o), I.applyQuaternion(N), So.copy(i.target).add(I), i.target.add(I.normalize().multiplyScalar(-Io)), So.clamp(i.clampMin, i.clampMax), i.target.clamp(i.clampMin, i.clampMax), i.object.lookAt(i.target);
let Dn = !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), Dn = !0) : (l.set(0, 0, 0), h.set(0, 0, 0)), i.zoomToCursor && P) {
let zi = null;
if (i.object.isPerspectiveCamera) {
const Ps = o.radius;
zi = o.radius * c, zi = de(zi);
const Rs = Ps - zi;
i.object.position.addScaledVector(C, Rs), i.object.updateMatrixWorld(), Mn = !!Rs;
} else if (i.object.isOrthographicCamera) {
const Ps = new S(T.x, T.y, 0);
Ps.unproject(i.object);
const Rs = i.object.zoom;
i.object.zoom = Math.max(i.minZoom, Math.min(i.maxZoom, i.object.zoom / c)), i.object.updateProjectionMatrix(), Mn = Rs !== i.object.zoom;
const Re = new S(T.x, T.y, 0);
Re.unproject(i.object), i.object.position.sub(Re).add(Ps), i.object.updateMatrixWorld(), zi = o.radius;
} else
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), i.zoomToCursor = !1;
zi !== null && (this.screenSpacePanning ? i.target.set(0, 0, -1).transformDirection(i.object.matrix).multiplyScalar(zi).add(i.object.position) : (ec.origin.copy(i.object.position), ec.direction.set(0, 0, -1).transformDirection(i.object.matrix), Math.abs(i.object.up.dot(ec.direction)) < dC ? e.lookAt(i.target) : (ef.setFromNormalAndCoplanarPoint(i.object.up, i.target), ec.intersectPlane(ef, i.target))));
} else if (i.object.isOrthographicCamera) {
const zi = i.object.zoom;
i.object.zoom = Math.max(i.minZoom, Math.min(i.maxZoom, i.object.zoom / c)), zi !== i.object.zoom && (i.object.updateProjectionMatrix(), Mn = !0);
}
return c = 1, P = !1, Mn || Dn || Je.distanceToSquared(i.object.position) > a || 8 * (1 - pi.dot(i.object.quaternion)) > a || er.distanceToSquared(i.target) > a ? (i.dispatchEvent($p), Je.copy(i.object.position), pi.copy(i.object.quaternion), er.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", Yl), i.domElement.removeEventListener("pointerdown", zl), i.domElement.removeEventListener("pointercancel", qr), i.domElement.removeEventListener("wheel", Vl), i.domElement.removeEventListener("pointermove", bo), i.domElement.removeEventListener("pointerup", qr), i.domElement.getRootNode().removeEventListener("keydown", Wl, { capture: !0 }), i._domElementKeyEvents !== null && (i._domElementKeyEvents.removeEventListener("keydown", oa), 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 a = 1e-6, o = new hn(), l = new hn(0, 0, 0);
let c = 1;
const h = new S(), u = new ge(), d = new ge(), p = new ge(), f = new ge(), g = new ge(), A = new ge(), y = new ge(), _ = new ge(), v = new ge(), C = new S(), T = new ge();
let P = !1;
const R = [], b = {};
let E = !1;
function B(I) {
return I !== null ? 2 * Math.PI / 60 * i.autoRotateSpeed * I : 2 * Math.PI / 60 / 60 * i.autoRotateSpeed;
}
function D(I) {
return i.enableDamping && !i.zoomToCursor && !i.object.isOrthographicCamera ? 1 : Math.pow(0.95, i.zoomSpeed);
}
function O(I) {
l.theta -= I;
}
function $(I) {
l.phi -= I;
}
this.rotateUp = $, this.rotateLeft = O;
const j = (function() {
const I = new S();
return function(N, Je) {
I.setFromMatrixColumn(Je, 0), I.multiplyScalar(-N), h.add(I);
};
})(), Y = (function() {
const I = new S();
return function(N, Je) {
i.screenSpacePanning === !0 ? I.setFromMatrixColumn(Je, 1) : (I.setFromMatrixColumn(Je, 0), I.crossVectors(i.object.up, I)), I.multiplyScalar(N), h.add(I);
};
})(), W = (function() {
const I = new S();
return function(N, Je) {
const pi = i.domElement;
if (i.object.isPerspectiveCamera) {
const er = i.object.position;
I.copy(er).sub(i.target);
let ji = I.length();
ji *= Math.tan(i.object.fov / 2 * Math.PI / 180), j(2 * N * ji / pi.clientHeight, i.object.matrix), Y(2 * Je * ji / pi.clientHeight, i.object.matrix);
} else i.object.isOrthographicCamera ? (j(N * (i.object.right - i.object.left) / i.object.zoom / pi.clientWidth, i.object.matrix), Y(Je * (i.object.top - i.object.bottom) / i.object.zoom / pi.clientHeight, i.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), i.enablePan = !1);
};
})();
function q(I, Z = 0) {
i.object.isPerspectiveCamera || i.object.isOrthographicCamera ? (c /= I, l.radius = Math.max(-i.maxZoomSpeed, Math.min(i.maxZoomSpeed, l.radius - Z))) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), i.enableZoom = !1);
}
function ne(I, Z = 0) {
i.object.isPerspectiveCamera || i.object.isOrthographicCamera ? (c *= I, l.radius = Math.max(-i.maxZoomSpeed, Math.min(i.maxZoomSpeed, l.radius + Z))) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), i.enableZoom = !1);
}
this.zoomIn = function(I) {
q(1, I * i.zoomSpeed);
}, this.zoomOut = function(I) {
ne(1, I * i.zoomSpeed);
};
function ve(I, Z) {
if (!i.zoomToCursor)
return;
P = !0;
const N = i.domElement.getBoundingClientRect(), Je = I - N.left, pi = Z - N.top, er = N.width, ji = N.height;
T.x = Je / er * 2 - 1, T.y = -(pi / ji) * 2 + 1, C.set(T.x, T.y, 1).unproject(i.object).sub(i.object.position).normalize();
}
function de(I) {
return Math.max(i.minDistance, Math.min(i.maxDistance, I));
}
function ze(I) {
u.set(I.clientX, I.clientY);
}
function Ce(I) {
ve(I.clientX, I.clientX), y.set(I.clientX, I.clientY);
}
function be(I) {
f.set(I.clientX, I.clientY);
}
function He(I) {
d.set(I.clientX, I.clientY), p.subVectors(d, u).multiplyScalar(i.rotateSpeed);
const Z = i.domElement;
O(2 * Math.PI * p.x / Z.clientHeight), $(2 * Math.PI * p.y / Z.clientHeight), u.copy(d), i.update();
}
function Be(I) {
_.set(I.clientX, I.clientY), v.subVectors(_, y), v.y > 0 ? q(D(v.y)) : v.y < 0 && ne(D(v.y)), y.copy(_), i.update();
}
function Ae(I) {
g.set(I.clientX, I.clientY), A.subVectors(g, f).multiplyScalar(i.panSpeed), W(A.x, A.y), f.copy(g), i.update();
}
function kt(I) {
ve(I.clientX, I.clientY);
let Z = 0;
switch (I.deltaMode) {
case 2:
Z += I.deltaY * 1;
break;
case 1:
Z += I.deltaY * 0.4;
break;
default:
Z += I.deltaY * 0.01;
break;
}
I.deltaY < 0 ? i.zoomToCursor || i.object.isOrthographicCamera ? ne(D()) : ne(1, Z * i.zoomSpeed) : I.deltaY > 0 && (i.zoomToCursor || i.object.isOrthographicCamera ? q(D()) : q(1, -Z * i.zoomSpeed)), i.update();
}
function Kt(I) {
let Z = !1;
switch (I.code) {
case i.keys.UP:
I.ctrlKey || I.metaKey || I.shiftKey ? $(2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : W(0, i.keyPanSpeed), Z = !0;
break;
case i.keys.BOTTOM:
I.ctrlKey || I.metaKey || I.shiftKey ? $(-2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : W(0, -i.keyPanSpeed), Z = !0;
break;
case i.keys.LEFT:
I.ctrlKey || I.metaKey || I.shiftKey ? O(2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : W(i.keyPanSpeed, 0), Z = !0;
break;
case i.keys.RIGHT:
I.ctrlKey || I.metaKey || I.shiftKey ? O(-2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : W(-i.keyPanSpeed, 0), Z = !0;
break;
}
Z && (I.preventDefault(), i.update());
}
function Is(I) {
if (R.length === 1)
u.set(I.pageX, I.pageY);
else {
const Z = Yi(I), N = 0.5 * (I.pageX + Z.x), Je = 0.5 * (I.pageY + Z.y);
u.set(N, Je);
}
}
function di(I) {
if (R.length === 1)
f.set(I.pageX, I.pageY);
else {
const Z = Yi(I), N = 0.5 * (I.pageX + Z.x), Je = 0.5 * (I.pageY + Z.y);
f.set(N, Je);
}
}
function Ri(I) {
const Z = Yi(I), N = I.pageX - Z.x, Je = I.pageY - Z.y, pi = Math.sqrt(N * N + Je * Je);
y.set(0, pi);
}
function br(I) {
i.enableZoom && Ri(I), i.enablePan && di(I);
}
function Ms(I) {
i.enableZoom && Ri(I), i.enableRotate && Is(I);
}
function Er(I) {
if (R.length == 1)
d.set(I.pageX, I.pageY);
else {
const N = Yi(I), Je = 0.5 * (I.pageX + N.x), pi = 0.5 * (I.pageY + N.y);
d.set(Je, pi);
}
p.subVectors(d, u).multiplyScalar(i.rotateSpeed);
const Z = i.domElement;
O(2 * Math.PI * p.x / Z.clientHeight), $(2 * Math.PI * p.y / Z.clientHeight), u.copy(d);
}
function wo(I) {
if (R.length === 1)
g.set(I.pageX, I.pageY);
else {
const Z = Yi(I), N = 0.5 * (I.pageX + Z.x), Je = 0.5 * (I.pageY + Z.y);
g.set(N, Je);
}
A.subVectors(g, f).multiplyScalar(i.panSpeed), W(A.x, A.y), f.copy(g);
}
function jl(I) {
const Z = Yi(I), N = I.pageX - Z.x, Je = I.pageY - Z.y, pi = Math.sqrt(N * N + Je * Je);
_.set(0, pi), v.set(0, Math.pow(_.y / y.y, i.zoomSpeed * 6)), q(v.y), y.copy(_);
const er = (I.pageX + Z.x) * 0.5, ji = (I.pageY + Z.y) * 0.5;
ve(er, ji);
}
function Ph(I) {
i.enableZoom && jl(I), i.enablePan && wo(I);
}
function Rh(I) {
i.enableZoom && jl(I), i.enableRotate && Er(I);
}
function zl(I) {
i.enabled !== !1 && (R.length === 0 && (i.domElement.setPointerCapture(I.pointerId), i.domElement.addEventListener("pointermove", bo), i.domElement.addEventListener("pointerup", qr)), !Ds(I) && (Fh(I), I.pointerType === "touch" ? In(I) : Lh(I)));
}
function bo(I) {
i.enabled !== !1 && (I.pointerType === "touch" ? Oh(I) : I.buttons ? Hl(I) : qr(I));
}
function qr(I) {
switch (os(I), R.length) {
case 0:
i.domElement.releasePointerCapture(I.pointerId), i.domElement.removeEventListener("pointermove", bo), i.domElement.removeEventListener("pointerup", qr), i.dispatchEvent(Zp), n = s.NONE;
break;
case 1:
const Z = R[0], N = b[Z];
In({ pointerId: Z, pageX: N.x, pageY: N.y });
break;
}
}
function Lh(I) {
let Z;
switch (I.button) {
case 0:
Z = i.mouseButtons.LEFT;
break;
case 1:
Z = i.mouseButtons.MIDDLE;
break;
case 2:
Z = i.mouseButtons.RIGHT;
break;
default:
Z = -1;
}
switch (Z) {
case la.DOLLY:
if (i.enableZoom === !1) return;
Ce(I), n = s.DOLLY;
break;
case la.ROTATE:
if (I.ctrlKey || I.metaKey || I.shiftKey) {
if (i.enablePan === !1) return;
be(I), n = s.PAN;
} else {
if (i.enableRotate === !1) return;
ze(I), n = s.ROTATE;
}
break;
case la.PAN:
if (I.ctrlKey || I.metaKey || I.shiftKey) {
if (i.enableRotate === !1) return;
ze(I), n = s.ROTATE;
} else {
if (i.enablePan === !1) return;
be(I), n = s.PAN;
}
break;
default:
n = s.NONE;
}
n !== s.NONE && i.dispatchEvent(Gh);
}
function Hl(I) {
switch (n) {
case s.ROTATE:
if (i.enableRotate === !1) return;
He(I);
break;
case s.DOLLY:
if (i.enableZoom === !1) return;
Be(I);
break;
case s.PAN:
if (i.enablePan === !1) return;
Ae(I);
break;
}
}
function Vl(I) {
i.enabled === !1 || i.enableZoom === !1 || n !== s.NONE || (I.preventDefault(), i.dispatchEvent(Gh), kt(Eo(I)), i.dispatchEvent(Zp));
}
function Eo(I) {
const Z = I.deltaMode, N = {
clientX: I.clientX,
clientY: I.clientY,
deltaY: I.deltaY
};
switch (Z) {
case 1:
N.deltaY *= 16;
break;
case 2:
N.deltaY *= 100;
break;
}
return I.ctrlKey && !E && (N.deltaY *= 10), N;
}
function Wl(I) {
I.key === "Control" && (E = !0, i.domElement.getRootNode().addEventListener("keyup", ql, { passive: !0, capture: !0 }));
}
function ql(I) {
I.key === "Control" && (E = !1, i.domElement.getRootNode().removeEventListener("keyup", ql, { passive: !0, capture: !0 }));
}
function oa(I) {
i.enabled === !1 || i.enablePan === !1 || Kt(I);
}
function In(I) {
switch (xo(I), R.length) {
case 1:
switch (i.touches.ONE) {
case ca.ROTATE:
if (i.enableRotate === !1) return;
Is(I), n = s.TOUCH_ROTATE;
break;
case ca.PAN:
if (i.enablePan === !1) return;
di(I), n = s.TOUCH_PAN;
break;
default:
n = s.NONE;
}
break;
case 2:
switch (i.touches.TWO) {
case ca.DOLLY_PAN:
if (i.enableZoom === !1 && i.enablePan === !1) return;
br(I), n = s.TOUCH_DOLLY_PAN;
break;
case ca.DOLLY_ROTATE:
if (i.enableZoom === !1 && i.enableRotate === !1) return;
Ms(I), n = s.TOUCH_DOLLY_ROTATE;
break;
default:
n = s.NONE;
}
break;
default:
n = s.NONE;
}
n !== s.NONE && i.dispatchEvent(Gh);
}
function Oh(I) {
switch (xo(I), n) {
case s.TOUCH_ROTATE:
if (i.enableRotate === !1) return;
Er(I), i.update();
break;
case s.TOUCH_PAN:
if (i.enablePan === !1) return;
wo(I), i.update();
break;
case s.TOUCH_DOLLY_PAN:
if (i.enableZoom === !1 && i.enablePan === !1) return;
Ph(I), i.update();
break;
case s.TOUCH_DOLLY_ROTATE:
if (i.enableZoom === !1 && i.enableRotate === !1) return;
Rh(I), i.update();
break;
default:
n = s.NONE;
}
}
function Yl(I) {
i.enabled !== !1 && I.preventDefault();
}
function Fh(I) {
R.push(I.pointerId);
}
function os(I) {
delete b[I.pointerId];
for (let Z = 0; Z < R.length; Z++)
if (R[Z] == I.pointerId) {
R.splice(Z, 1);
return;
}
}
function Ds(I) {
for (let Z = 0; Z < R.length; Z++)