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.65 MB
JavaScript
import { EventDispatcher as Ui, Clock as tp, Vector3 as b, MOUSE as xa, TOUCH as Sa, Spherical as Cn, Quaternion as ve, Vector2 as oe, Ray as sA, Plane as xl, MathUtils as Qe, Object3D as ai, Raycaster as kh, CylinderGeometry as zi, BoxGeometry as ri, BufferGeometry as ii, Float32BufferAttribute as $e, Mesh as J, OctahedronGeometry as Cc, Line as Cs, SphereGeometry as bn, Euler as dt, Matrix4 as ce, PlaneGeometry as Nh, DoubleSide as Ds, TorusGeometry as sh, LineBasicMaterial as Gr, MeshBasicMaterial as ma, Group as Ci, Box3 as mo, Box2 as rA, Cache as Bi, DataTexture as Ao, RGBAFormat as Jt, UnsignedByteType as ut, LinearSRGBColorSpace as mt, DataUtils as Vi, RGBM16ColorSpace as ip, SRGBColorSpace as pt, NoColorSpace as ni, BufferAttribute as qe, InstancedBufferAttribute as sp, InterleavedBuffer as nA, InterleavedBufferAttribute as wr, TrianglesDrawMode as t0, TriangleFanDrawMode as hd, TriangleStripDrawMode as aA, HalfFloatType as lt, FloatType as wt, RGBADepthPacking as fl, BasicDepthPacking as oA, UnsignedInt248Type as i0, UnsignedShort5551Type as s0, UnsignedShort4444Type as r0, UnsignedIntType as rp, IntType as n0, UnsignedShortType as a0, ShortType as o0, ByteType as l0, DisplayP3ColorSpace as lA, EquirectangularReflectionMapping as ql, CubeUVReflectionMapping as c0, CubeReflectionMapping as h0, UVMapping as cA, CustomBlending as fr, MultiplyBlending as hA, SubtractiveBlending as uA, AdditiveBlending as dA, NormalBlending as Gh, NoBlending as rr, Texture as Li, InstancedMesh as jh, ShaderMaterial as Vr, PerspectiveCamera as Yl, Scene as Xa, HemisphereLight as pA, InstancedBufferGeometry as u0, InstancedInterleavedBuffer as rh, WireframeGeometry as fA, Sphere as zh, ShaderLib as Qr, UniformsUtils as Kl, UniformsLib as fn, Vector4 as gt, Line3 as gA, OrthographicCamera as yo, WebGLRenderer as np, BackSide as mA, Color as Z, Sprite as AA, CanvasTexture as vo, RepeatWrapping as us, LinearFilter as Ne, SpriteMaterial as yA, CurvePath as ap, Matrix2 as d0, Matrix3 as Hh, ObjectLoader as op, MaterialLoader as p0, Shape as Vh, Curve as vA, Path as f0, ArcCurve as _A, CatmullRomCurve3 as nh, CubicBezierCurve as wA, CubicBezierCurve3 as CA, EllipseCurve as lp, LineCurve as Wh, LineCurve3 as Jl, QuadraticBezierCurve as bA, QuadraticBezierCurve3 as EA, SplineCurve as xA, AnimationClip as cp, Source as SA, CubeTexture as g0, FileLoader as Qt, ShaderChunk as os, ClampToEdgeWrapping as Ei, MirroredRepeatWrapping as Sl, NearestFilter as Cr, NearestMipmapNearestFilter as hp, NearestMipmapLinearFilter as up, LinearMipmapNearestFilter as dp, LinearMipmapLinearFilter as ta, NeverDepth as m0, AlwaysDepth as A0, LessDepth as y0, LessEqualDepth as MA, EqualDepth as v0, GreaterEqualDepth as _0, GreaterDepth as w0, NotEqualDepth as C0, AddEquation as pp, SubtractEquation as b0, ReverseSubtractEquation as E0, MinEquation as x0, MaxEquation as S0, ZeroFactor as Lf, OneFactor as Of, SrcColorFactor as Ff, OneMinusSrcColorFactor as Uf, SrcAlphaFactor as ud, OneMinusSrcAlphaFactor as dd, DstAlphaFactor as Qf, OneMinusDstAlphaFactor as kf, DstColorFactor as Nf, OneMinusDstColorFactor as Gf, SrcAlphaSaturateFactor as M0, ConstantColorFactor as bc, OneMinusConstantColorFactor as Ec, ConstantAlphaFactor as al, OneMinusConstantAlphaFactor as ol, TangentSpaceNormalMap as Ml, ObjectSpaceNormalMap as I0, FrontSide as _o, KeepStencilOp as wu, AlwaysStencilFunc as D0, MultiplyOperation as IA, ColorManagement as gl, GLSL3 as T0, GLSL1 as B0, MeshDepthMaterial as fp, MeshPhysicalMaterial as qh, MeshPhongMaterial as ml, AmbientLight as DA, DirectionalLight as Xl, PointLight as Il, RectAreaLight as TA, SpotLight as Yh, WebGLRenderTarget as gp, DepthTexture as P0, DepthFormat as R0, WebGLCubeRenderTarget as L0, LinearMipMapLinearFilter as jf, LoadingManager as O0, LoaderUtils as br, Uniform as F0, CompressedTexture as Al, PropertyBinding as Wr, InterpolateDiscrete as BA, InterpolateLinear as mp, MeshStandardMaterial as $l, ImageUtils as U0, TextureLoader as ia, ImageBitmapLoader as Q0, Material as yl, SkinnedMesh as PA, LineSegments as pd, LineLoop as k0, Points as vl, Skeleton as RA, Bone as fd, Loader as Oi, VectorKeyframeTrack as gd, NumberKeyframeTrack as md, QuaternionKeyframeTrack as ah, Interpolant as N0, PointsMaterial as Jn, DefaultLoadingManager as G0, MeshLambertMaterial as j0, Uint16BufferAttribute as z0, ShapeUtils as H0, DataTextureLoader as LA, RedFormat as Fa, BufferGeometryLoader as V0, ImageLoader as W0, VideoTexture as zf, NoToneMapping as q0, PCFShadowMap as Y0, ACESFilmicToneMapping as OA, LinearToneMapping as K0, ReinhardToneMapping as J0, CineonToneMapping as X0, CustomToneMapping as $0, AgXToneMapping as Z0, CompressedCubeTexture as e_, CompressedArrayTexture as t_, LinearDisplayP3ColorSpace as i_, RGBA_ASTC_6x6_Format as Hf, RGFormat as ll, Data3DTexture as s_, RGB_S3TC_DXT1_Format as r_, RGB_PVRTC_4BPPV1_Format as n_, RGB_ETC2_Format as a_, RGB_ETC1_Format as o_, RGBA_S3TC_DXT5_Format as l_, RGBA_PVRTC_4BPPV1_Format as c_, RGBA_ETC2_EAC_Format as h_, RGBA_BPTC_Format as u_, RGBA_ASTC_4x4_Format as d_, CompressedTextureLoader as p_, Camera as FA, Triangle as UA, MeshNormalMaterial as f_, LoopRepeat as Vf, LoopOnce as Wf, AnimationMixer as g_, TubeGeometry as m_, ShapeGeometry as A_ } from "three";
import { AmbientLight as oL, AnimationAction as lL, AnimationClip as cL, AnimationLoader as hL, AnimationMixer as uL, AnimationObjectGroup as dL, AnimationUtils as pL, ArcCurve as fL, ArrayCamera as gL, ArrowHelper as mL, Audio as AL, AudioAnalyser as yL, AudioContext as vL, AudioListener as _L, AudioLoader as wL, AxesHelper as CL, BatchedMesh as bL, Bone as EL, BooleanKeyframeTrack as xL, Box2 as SL, Box3 as ML, Box3Helper as IL, BoxGeometry as DL, BoxHelper as TL, BufferAttribute as BL, BufferGeometry as PL, BufferGeometryLoader as RL, Cache as LL, Camera as OL, CameraHelper as FL, CanvasTexture as UL, CapsuleGeometry as QL, CatmullRomCurve3 as kL, CircleGeometry as NL, Clock as GL, Color as jL, ColorKeyframeTrack as zL, ColorManagement as HL, CompressedArrayTexture as VL, CompressedCubeTexture as WL, CompressedTexture as qL, CompressedTextureLoader as YL, ConeGeometry as KL, CubeCamera as JL, CubeTexture as XL, CubeTextureLoader as $L, CubicBezierCurve as ZL, CubicBezierCurve3 as eO, CubicInterpolant as tO, Curve as iO, CurvePath as sO, CylinderGeometry as rO, Cylindrical as nO, Data3DTexture as aO, DataArrayTexture as oO, DataTexture as lO, DataTextureLoader as cO, DataUtils as hO, DefaultLoadingManager as uO, DepthTexture as dO, DirectionalLight as pO, DirectionalLightHelper as fO, DiscreteInterpolant as gO, DodecahedronGeometry as mO, EdgesGeometry as AO, EllipseCurve as yO, Euler as vO, EventDispatcher as _O, ExtrudeGeometry as wO, FileLoader as CO, Float16BufferAttribute as bO, Float32BufferAttribute as EO, Fog as xO, FogExp2 as SO, FramebufferTexture as MO, Frustum as IO, GLBufferAttribute as DO, GridHelper as TO, Group as BO, HemisphereLight as PO, HemisphereLightHelper as RO, IcosahedronGeometry as LO, ImageBitmapLoader as OO, ImageLoader as FO, ImageUtils as UO, InstancedBufferAttribute as QO, InstancedBufferGeometry as kO, InstancedInterleavedBuffer as NO, InstancedMesh as GO, Int16BufferAttribute as jO, Int32BufferAttribute as zO, Int8BufferAttribute as HO, InterleavedBuffer as VO, InterleavedBufferAttribute as WO, Interpolant as qO, KeyframeTrack as YO, LOD as KO, LatheGeometry as JO, Layers as XO, Light as $O, LightProbe as ZO, Line as eF, Line3 as tF, LineBasicMaterial as iF, LineCurve as sF, LineCurve3 as rF, LineDashedMaterial as nF, LineLoop as aF, LineSegments as oF, LinearInterpolant as lF, Loader as cF, LoaderUtils as hF, LoadingManager as uF, Material as dF, MaterialLoader as pF, MathUtils as fF, Matrix2 as gF, Matrix3 as mF, Matrix4 as AF, Mesh as yF, MeshBasicMaterial as vF, MeshDepthMaterial as _F, MeshDistanceMaterial as wF, MeshLambertMaterial as CF, MeshMatcapMaterial as bF, MeshNormalMaterial as EF, MeshPhongMaterial as xF, MeshPhysicalMaterial as SF, MeshStandardMaterial as MF, MeshToonMaterial as IF, NumberKeyframeTrack as DF, Object3D as TF, ObjectLoader as BF, OctahedronGeometry as PF, OrthographicCamera as RF, PMREMGenerator as LF, Path as OF, PerspectiveCamera as FF, Plane as UF, PlaneGeometry as QF, PlaneHelper as kF, PointLight as NF, PointLightHelper as GF, Points as jF, PointsMaterial as zF, PolarGridHelper as HF, PolyhedronGeometry as VF, PositionalAudio as WF, PropertyBinding as qF, PropertyMixer as YF, QuadraticBezierCurve as KF, QuadraticBezierCurve3 as JF, Quaternion as XF, QuaternionKeyframeTrack as $F, QuaternionLinearInterpolant as ZF, RawShaderMaterial as eU, Ray as tU, Raycaster as iU, RectAreaLight as sU, RenderTarget as rU, RingGeometry as nU, Scene as aU, ShaderChunk as oU, ShaderLib as lU, ShaderMaterial as cU, ShadowMaterial as hU, Shape as uU, ShapeGeometry as dU, ShapePath as pU, ShapeUtils as fU, Skeleton as gU, SkeletonHelper as mU, SkinnedMesh as AU, Source as yU, Sphere as vU, SphereGeometry as _U, Spherical as wU, SphericalHarmonics3 as CU, SplineCurve as bU, SpotLight as EU, SpotLightHelper as xU, Sprite as SU, SpriteMaterial as MU, StereoCamera as IU, StringKeyframeTrack as DU, TetrahedronGeometry as TU, Texture as BU, TextureLoader as PU, TorusGeometry as RU, TorusKnotGeometry as LU, Triangle as OU, TubeGeometry as FU, Uint16BufferAttribute as UU, Uint32BufferAttribute as QU, Uint8BufferAttribute as kU, Uint8ClampedBufferAttribute as NU, Uniform as GU, UniformsGroup as jU, UniformsLib as zU, UniformsUtils as HU, Vector2 as VU, Vector3 as WU, Vector4 as qU, VectorKeyframeTrack as YU, VideoTexture as KU, WebGL3DRenderTarget as JU, WebGLArrayRenderTarget as XU, WebGLCubeRenderTarget as $U, WebGLRenderTarget as ZU, WebGLRenderer as eQ, WebGLUtils as tQ, WireframeGeometry as iQ } from "three";
import { serialize as S, onChangeDispatchEvent as Aa, serializable as Zl, now as Es, objectHasOwn as Ss, safeSetProperty as xi, FnCaller as Ap, getOrCall as xe, deepAccessObject as Kh, LinearToSRGB as y_, canvasFlipY as QA, Serialization as Xe, getTypedArray as v_, arrayBufferToBase64 as Cu, base64ToArrayBuffer as kA, timeout as Zi, onChange as N, blobToDataURL as NA, parseFileExtension as oh, embedUrlRefs as __, svgUrl as w_, objectMap as C_, uploadFile as b_, downloadBlob as yp, copyProps as E_, onChange3 as de, onChange2 as it, glsl as Bn, includesAll as x_, escapeRegExp as Ad, imageUrlToImageData as S_, aesGcmDecrypt as M_, aesGcmEncrypt as I_, getUrlQueryParam as vp, downloadFile as D_, wrapThisFunction2 as T_, updateBit as GA, createCanvasElement as B_, windowDialogWrapper as P_, createDiv as An, createStyles as Dl, escapeHtml as xc, JSUndoManager as R_, recordUndoCommand as L_, setValueUndoCommand as O_, SimpleEventDispatcher as F_, PointerDragHelper as U_, absMax as Q_, imageBitmapToBase64 as k_, makeColorSvgCircle as N_, toTitleCase as G_ } from "ts-browser-helpers";
import { Damper as rQ, FnCaller as nQ, JSUndoManager as aQ, LinearToSRGB as oQ, PointerDragHelper as lQ, SRGBToLinear as cQ, Serialization as hQ, SimpleEventDispatcher as uQ, TYPED_ARRAYS as dQ, absMax as pQ, aesGcmDecrypt as fQ, aesGcmEncrypt as gQ, arrayBufferToBase64 as mQ, base64ToArrayBuffer as AQ, blobToDataURL as yQ, blobToImage as vQ, canvasFlipY as _Q, clearBit as wQ, clonePrimitive as CQ, cloneScriptTag as bQ, colorToDataUrl as EQ, copyPrimitive as xQ, copyProps as SQ, createCanvasElement as MQ, createDiv as IQ, createImage as DQ, createScriptFromURL as TQ, createStyles as BQ, css as PQ, deepAccessObject as RQ, downloadBlob as LQ, downloadFile as OQ, embedUrlRefs as FQ, equalsPrimitive as UQ, escapeRegExp as QQ, findLastIndex as kQ, getFileHandle as NQ, getFilenameFromPath as GQ, getKeyByValue as jQ, getNewFileHandle as zQ, getOrCall as HQ, getPropertyDescriptor as VQ, getTypedArray as WQ, getUrlQueryParam as qQ, glsl as YQ, html as KQ, htmlDialogWrapper as JQ, htmlToCanvas as XQ, htmlToPng as $Q, htmlToSvg as ZQ, imageBitmapToBase64 as ek, imageBitmapToBlob as tk, imageBitmapToCanvas as ik, imageDataToCanvas as sk, imageToCanvas as rk, imageUrlToImageData as nk, includesAll as ak, isPropertyWritable as ok, isWebpExportSupported as lk, longestCommonPrefix as ck, makeColorSvg as hk, makeColorSvgCircle as uk, makeTextSvg as dk, mobileAndTabletCheck as pk, now as fk, objectHasOwn as gk, objectMap as mk, objectMap2 as Ak, onChange as yk, onChange2 as vk, onChange3 as _k, onChangeDispatchEvent as wk, parseFileExtension as Ck, pathJoin as bk, prettyScrollbar as Ek, readFile as xk, recordUndoCommand as Sk, remoteWorkerURL as Mk, replaceAll as Ik, safeReplaceString as Dk, safeSetProperty as Tk, serializable as Bk, serialize as Pk, setInnerHTMLWithScripts as Rk, setUrlQueryParam as Lk, setValueUndoCommand as Ok, svgToCanvas as Fk, svgToPng as Uk, svgUrl as Qk, timeout as kk, toCamelCase as Nk, toTitleCase as Gk, updateBit as jk, uploadFile as zk, uuidV4 as Hk, verifyPermission as Vk, windowDialogWrapper as Wk, wrapThisFunction as qk, wrapThisFunction2 as Yk, writeFile as Kk } from "ts-browser-helpers";
import { uiInput as se, uiToggle as F, uiButton as me, uiFolderContainer as Ee, uiVector as yt, uiPanelContainer as Pn, uiSlider as te, generateUiConfig as Pt, generateValueConfig as ot, uiDropdown as Nt, uiNumber as Re, uiColor as Mi, uiImage as Zr, uiConfig as Ls, uiMonitor as wo, generateUiFolder as j_ } from "uiconfig.js";
import { UiConfigMethods as Xk, UiConfigRenderer as $k, UiConfigRendererBase as Zk, UiConfigTypeMap as e3, generateUiConfig as t3, generateUiFolder as i3, generateValueConfig as s3, uiButton as r3, uiColor as n3, uiConfig as a3, uiContainer as o3, uiDropdown as l3, uiFolderContainer as c3, uiImage as h3, uiInput as u3, uiMonitor as d3, uiNumber as p3, uiPanelContainer as f3, uiSlider as g3, uiToggle as m3, uiVector as A3 } from "uiconfig.js";
import { bounceInOut as z_, bounceIn as H_, bounceOut as V_, anticipate as W_, backInOut as q_, backOut as Y_, backIn as K_, circInOut as J_, circOut as X_, circIn as $_, easeInOut as Z_, easeOut as ew, easeIn as tw, linear as iw, animate as jA, keyframes as sw } from "@repalash/popmotion";
import { animate as v3 } from "@repalash/popmotion";
import rw from "stats.js";
function qf(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 ec(r) {
return r.startsWith("http://") || r.startsWith("https://") || r.startsWith("data:") || r.startsWith("asset://") || r.startsWith("/") || r.startsWith("//");
}
const nw = `#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
`, aw = `#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
`, ow = `#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
`, lw = "varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}", cw = "varying vec2 vUv;void main(){gl_FragColor=vec4(vUv,0.0,1.0);}", hw = `#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
`, zA = {
simpleCameraHelpers: nw,
cameraHelpers: aw,
randomHelpers: ow,
defaultVertex: lw,
defaultFragment: cw,
voronoiNoise: hw
};
var uw = Object.defineProperty, dw = Object.getOwnPropertyDescriptor, Dr = (r, e, t, i) => {
for (var s = i > 1 ? void 0 : i ? dw(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 && uw(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 tp(!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" });
}
};
Dr([
se("Time", { readOnly: !0 })
], Ts.prototype, "time", 1);
Dr([
se("Delta", { readOnly: !0 })
], Ts.prototype, "delta", 2);
Dr([
se("Max Time"),
S(),
Aa("endTimeChanged")
], Ts.prototype, "endTime", 2);
Dr([
F("Reset on End"),
S(),
Aa("resetOnEndChanged")
], Ts.prototype, "resetOnEnd", 2);
Dr([
F("Stop on End"),
S(),
Aa("stopOnEndChanged")
], Ts.prototype, "stopOnEnd", 2);
Dr([
se("Running", { readOnly: !0 })
], Ts.prototype, "running", 2);
Dr([
me("Start")
], Ts.prototype, "start", 1);
Dr([
me("Stop")
], Ts.prototype, "stop", 1);
Dr([
me("Reset")
], Ts.prototype, "reset", 1);
Ts = Dr([
Zl("ViewerTimeline"),
Ee("Timeline")
], Ts);
class pw {
constructor(e) {
this._stats = new rw(), 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 fw = ".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}", Bh = class Bh {
/**
* 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>" + fw + "</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;
}
};
Bh.Element = void 0, Bh._inited = !1;
let lh = Bh;
const Ph = class Ph {
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 (Ph.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 });
}
};
Ph.USE_DATA_TRANSFER_ITEMS = !0;
let yd = Ph;
const Yf = { type: "change" }, bu = { type: "start" }, Kf = { type: "end" }, Sc = new sA(), Jf = new xl(), gw = Math.cos(70 * Qe.DEG2RAD);
class HA 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: xa.ROTATE, MIDDLE: xa.DOLLY, RIGHT: xa.PAN }, this.touches = { ONE: Sa.ROTATE, TWO: Sa.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(P) {
P.addEventListener("keydown", Ea), this._domElementKeyEvents = P;
}, this.stopListenToKeyEvents = function() {
this._domElementKeyEvents.removeEventListener("keydown", Ea), 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(Yf), i.update(), n = s.NONE;
}, this.update = (function() {
const P = new b(), ee = new ve().setFromUnitVectors(e.up, new b(0, 1, 0)), j = ee.clone().invert(), Je = new b(), yi = new ve(), lr = new b(), Ji = 2 * Math.PI, vu = 0;
return function(_u = null) {
if (this.throttleUpdate && this.throttleUpdate >= 1 && Date.now() - vu < 1e3 / this.throttleUpdate)
return;
const Ho = i.object.position;
P.copy(Ho).sub(i.target), P.applyQuaternion(ee), o.setFromVector3(P), i.autoRotate && n === s.NONE && L(D(_u)), i.enableDamping ? (o.theta += l.theta * i.dampingFactor, o.phi += l.phi * i.dampingFactor) : (o.theta += l.theta, o.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 ? o.theta = Math.max(Gs, Math.min(js, o.theta)) : o.theta = o.theta > (Gs + js) / 2 ? Math.max(Gs, o.theta) : Math.min(js, 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 Vo = 0, zn = !1;
if (i.zoomToCursor && M || i.object.isOrthographicCamera)
o.radius = fe(o.radius);
else {
const Xi = 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 && (Vo = i.minDistance - o.radius), i.autoPullTarget && o.radius > i.maxDistance && (Vo = i.maxDistance - o.radius), o.radius = fe(o.radius), zn = Xi != o.radius;
}
P.setFromSpherical(o), P.applyQuaternion(j), Ho.copy(i.target).add(P), i.target.add(P.normalize().multiplyScalar(-Vo)), Ho.clamp(i.clampMin, i.clampMax), i.target.clamp(i.clampMin, i.clampMax), i.object.lookAt(i.target);
let Hn = !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), Hn = !0) : (l.set(0, 0, 0), h.set(0, 0, 0)), i.zoomToCursor && M) {
let Xi = null;
if (i.object.isPerspectiveCamera) {
const zs = o.radius;
Xi = o.radius * c, Xi = fe(Xi);
const Hs = zs - Xi;
i.object.position.addScaledVector(w, Hs), i.object.updateMatrixWorld(), zn = !!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(), zn = 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 = o.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) : (Sc.origin.copy(i.object.position), Sc.direction.set(0, 0, -1).transformDirection(i.object.matrix), Math.abs(i.object.up.dot(Sc.direction)) < gw ? e.lookAt(i.target) : (Jf.setFromNormalAndCoplanarPoint(i.object.up, i.target), Sc.intersectPlane(Jf, 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(), zn = !0);
}
return c = 1, M = !1, zn || Hn || Je.distanceToSquared(i.object.position) > a || 8 * (1 - yi.dot(i.object.quaternion)) > a || lr.distanceToSquared(i.target) > a ? (i.dispatchEvent(Yf), 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", _c), i.domElement.removeEventListener("pointerdown", gc), i.domElement.removeEventListener("pointercancel", nn), i.domElement.removeEventListener("wheel", Ac), i.domElement.removeEventListener("pointermove", Go), i.domElement.removeEventListener("pointerup", nn), i.domElement.getRootNode().removeEventListener("keydown", yc, { capture: !0 }), i._domElementKeyEvents !== null && (i._domElementKeyEvents.removeEventListener("keydown", Ea), 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 Cn(), l = new Cn(0, 0, 0);
let c = 1;
const h = new b(), u = new oe(), d = new oe(), p = new oe(), f = new oe(), g = new oe(), m = new oe(), y = new oe(), _ = new oe(), v = new oe(), w = new b(), I = new oe();
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 ye(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) {
ye(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) {
ye(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 Pr(P) {
i.enableZoom && Ni(P), i.enablePan && Ai(P);
}
function ks(P) {
i.enableZoom && Ni(P), i.enableRotate && Qs(P);
}
function Rr(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 No(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 fc(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;
ye(lr, Ji);
}
function fu(P) {
i.enableZoom && fc(P), i.enablePan && No(P);
}
function gu(P) {
i.enableZoom && fc(P), i.enableRotate && Rr(P);
}
function gc(P) {
i.enabled !== !1 && (B.length === 0 && (i.domElement.setPointerCapture(P.pointerId), i.domElement.addEventListener("pointermove", Go), i.domElement.addEventListener("pointerup", nn)), !Ns(P) && (yu(P), P.pointerType === "touch" ? jn(P) : mu(P)));
}
function Go(P) {
i.enabled !== !1 && (P.pointerType === "touch" ? Au(P) : P.buttons ? mc(P) : nn(P));
}
function nn(P) {
switch (As(P), B.length) {
case 0:
i.domElement.releasePointerCapture(P.pointerId), i.domElement.removeEventListener("pointermove", Go), i.domElement.removeEventListener("pointerup", nn), i.dispatchEvent(Kf), n = s.NONE;
break;
case 1:
const ee = B[0], j = C[ee];
jn({ pointerId: ee, pageX: j.x, pageY: j.y });
break;
}
}
function mu(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 xa.DOLLY:
if (i.enableZoom === !1) return;
we(P), n = s.DOLLY;
break;
case xa.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 xa.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(bu);
}
function mc(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 Ac(P) {
i.enabled === !1 || i.enableZoom === !1 || n !== s.NONE || (P.preventDefault(), i.dispatchEvent(bu), Ht(jo(P)), i.dispatchEvent(Kf));
}
function jo(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 yc(P) {
P.key === "Control" && (x = !0, i.domElement.getRootNode().addEventListener("keyup", vc, { passive: !0, capture: !0 }));
}
function vc(P) {
P.key === "Control" && (x = !1, i.domElement.getRootNode().removeEventListener("keyup", vc, { passive: !0, capture: !0 }));
}
function Ea(P) {
i.enabled === !1 || i.enablePan === !1 || ei(P);
}
function jn(P) {
switch (zo(P), B.length) {
case 1:
switch (i.touches.ONE) {
case Sa.ROTATE:
if (i.enableRotate === !1) return;
Qs(P), n = s.TOUCH_ROTATE;
break;
case Sa.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 Sa.DOLLY_PAN:
if (i.enableZoom === !1 && i.enablePan === !1) return;
Pr(P), n = s.TOUCH_DOLLY_PAN;
break;
case Sa.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(bu);
}
function Au(P) {
switch (zo(P), n) {
case s.TOUCH_ROTATE:
if (i.enableRotate === !1) return;
Rr(P), i.update();
break;
case s.TOUCH_PAN:
if (i.enablePan === !1) return;
No(P), i.update();
break;
case s.TOUCH_DOLLY_PAN:
if (i.enableZoom === !1 && i.enablePan === !1) return;
fu(P), i.update();
break;
case s.TOUCH_DOLLY_ROTATE:
if (i.enableZoom === !1 && i.enableRotate === !1) return;
gu(P), i.update();
break;
default:
n = s.NONE;
}
}
function _c(P) {
i.enabled !== !1 && P.preventDefault();
}
function yu(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) {