Files
bim_engine/.recycle/2026-01-22/src/bim-engine-sdk.es.js
yuding f2460fb981 refactor: 重命名SDK为iflow-engine,使用npm包引入第三方引擎
- 将包名从 @fishdingding/bim-engine-sdk 改为 iflow-engine
- 将构建输出文件从 bim-engine-sdk.*.js 改为 iflow-engine.*.js
- 将全局变量从 LyzBimEngineSDK 改为 IflowEngine
- 将第三方引擎SDK从本地引入改为npm包引入 (iflow-engine-base)
- 移除本地 src/engine_base 目录,移至回收站
- 更新所有文档和demo中的引用
2026-01-22 11:29:51 +08:00

12426 lines
517 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as v from "three";
import { Ray as cs, Plane as hs, MathUtils as xi, Vector3 as pe, Controls as us, MOUSE as ht, TOUCH as lt, Quaternion as Yt, Spherical as In, Vector2 as de, Mesh as bi, OrthographicCamera as vi, BufferGeometry as tn, Float32BufferAttribute as Bn, ShaderMaterial as Le, UniformsUtils as Ve, WebGLRenderTarget as ut, HalfFloatType as dt, NoBlending as je, Clock as ds, Color as Ce, Matrix4 as Xe, DataTexture as Ti, RepeatWrapping as it, MeshNormalMaterial as fs, AddEquation as Dt, ZeroFactor as Lt, DstAlphaFactor as Un, DstColorFactor as Fn, CustomBlending as ps, DepthTexture as ms, DepthStencilFormat as gs, UnsignedInt248Type as _s, NearestFilter as $t, RGBAFormat as ys, UnsignedByteType as ws, AdditiveBlending as xs, MeshBasicMaterial as ct, RawShaderMaterial as bs, ColorManagement as Jt, SRGBTransfer as vs, LinearToneMapping as Ts, ReinhardToneMapping as Ss, CineonToneMapping as Es, ACESFilmicToneMapping as Ms, AgXToneMapping as As, NeutralToneMapping as Cs, CustomToneMapping as ks, Loader as Si, FileLoader as Qt, SRGBColorSpace as Ze, LinearSRGBColorSpace as Ie, BufferAttribute as ft, InterleavedBuffer as Ei, InterleavedBufferAttribute as Mi, TrianglesDrawMode as Ps, TriangleFanDrawMode as vn, TriangleStripDrawMode as Ai, LoaderUtils as Et, MeshPhysicalMaterial as Fe, SpotLight as Rs, PointLight as Ds, DirectionalLight as Ls, InstancedMesh as Os, InstancedBufferAttribute as Ns, Object3D as Ci, TextureLoader as zs, ImageBitmapLoader as Is, LinearMipmapLinearFilter as ki, NearestMipmapLinearFilter as Bs, LinearMipmapNearestFilter as Us, NearestMipmapNearestFilter as Fs, LinearFilter as Tn, MirroredRepeatWrapping as js, ClampToEdgeWrapping as Vs, PointsMaterial as Hs, Material as cn, LineBasicMaterial as Gs, MeshStandardMaterial as Pi, DoubleSide as Ws, PropertyBinding as Ks, SkinnedMesh as Xs, LineSegments as Zs, Line as qs, LineLoop as Ys, Points as $s, Group as hn, PerspectiveCamera as Js, Skeleton as Qs, AnimationClip as er, Bone as tr, InterpolateDiscrete as nr, InterpolateLinear as Ri, Texture as jn, VectorKeyframeTrack as Vn, NumberKeyframeTrack as Hn, QuaternionKeyframeTrack as Gn, FrontSide as ir, Interpolant as sr, Box3 as rr, Sphere as or } from "three";
class ar {
engine;
scene;
constructor(e) {
this.engine = e, this.scene = new v.Scene();
}
}
class lr {
engine;
// 透视相机
perspectiveCamera;
// 正交相机
orthographicCamera;
constructor(e) {
this.engine = e, this.perspectiveCamera = new v.PerspectiveCamera(
60,
this.engine.container.clientWidth / this.engine.container.clientHeight,
0.1,
1e3
), this.perspectiveCamera.position.set(2, 2, 2), this.perspectiveCamera.lookAt(0, 0, 0);
const t = 50, n = this.engine.container.clientWidth / this.engine.container.clientHeight;
this.orthographicCamera = new v.OrthographicCamera(t * n / -2, t * n / 2, t / 2, t / -2, 0.1, 1e3);
}
// 透视相机
switchToPerspectiveCamera() {
const e = this.engine.camera.position.clone(), t = this.engine.controls.target.clone();
this.engine.camera = this.perspectiveCamera, this.engine.scene.camera = this.perspectiveCamera, this.perspectiveCamera.position.copy(e), this.perspectiveCamera.lookAt(t), this.engine.controlModule.orbitControls.object = this.perspectiveCamera, this.engine.controlModule.firstPersonControls.camera = this.perspectiveCamera, this.engine.composerModule.init();
}
// 正交相机
switchToOrthographicCamera() {
const e = this.engine.camera.position.clone(), t = this.engine.controls.target.clone();
this.engine.camera = this.orthographicCamera, this.engine.scene.camera = this.orthographicCamera, this.orthographicCamera.position.copy(e), this.orthographicCamera.lookAt(t), this.engine.controlModule.orbitControls.object = this.orthographicCamera, this.engine.controlModule.firstPersonControls.camera = this.orthographicCamera, this.engine.composerModule.init();
}
// 获取当前相机类型
getCameraType() {
return this.engine.camera === this.perspectiveCamera ? "perspective" : this.engine.camera === this.orthographicCamera ? "orthographic" : "perspective";
}
// 获取当前相机姿态
getCameraPose() {
const e = this.engine.camera, t = this.getCameraType(), n = {
type: t,
position: {
x: e.position.x,
y: e.position.y,
z: e.position.z
},
rotation: {
x: e.rotation.x,
y: e.rotation.y,
z: e.rotation.z
},
quaternion: {
x: e.quaternion.x,
y: e.quaternion.y,
z: e.quaternion.z,
w: e.quaternion.w
}
};
return this.engine.controls && this.engine.controls.target && (n.target = {
x: this.engine.controls.target.x,
y: this.engine.controls.target.y,
z: this.engine.controls.target.z
}), t === "orthographic" && (n.zoom = e.zoom), n;
}
// 通过相机姿态还原相机位置
restoreCameraPose(e) {
this.getCameraType() !== e.type && (e.type === "perspective" ? this.switchToPerspectiveCamera() : this.switchToOrthographicCamera());
const n = this.engine.camera;
n.position.set(e.position.x, e.position.y, e.position.z), e.quaternion ? n.quaternion.set(
e.quaternion.x,
e.quaternion.y,
e.quaternion.z,
e.quaternion.w
) : e.rotation && n.rotation.set(e.rotation.x, e.rotation.y, e.rotation.z), e.target && this.engine.controls && this.engine.controls.target && this.engine.controls.target.set(
e.target.x,
e.target.y,
e.target.z
), e.type === "orthographic" && e.zoom !== void 0 && (n.zoom = e.zoom, n.updateProjectionMatrix()), n.updateMatrix(), n.updateMatrixWorld(!0), this.engine.controls && this.engine.controls.update && this.engine.controls.update();
}
}
class cr {
engine;
deviceType;
constructor(e) {
this.engine = e, this.deviceType = "PC";
}
// 获取设备类型
getDeviceType() {
return this.deviceType;
}
// 获取容器尺寸
getContainerSize() {
return {
width: this.engine.container.clientWidth,
height: this.engine.container.clientHeight
};
}
}
class hr {
engine;
renderer;
constructor(e) {
this.engine = e, this.renderer = null;
}
createRenderer() {
const { width: e, height: t } = this.engine.deviceModule.getContainerSize();
return this.renderer = new v.WebGLRenderer({
antialias: this.engine.options.antialias ?? !0,
alpha: !0,
premultipliedAlpha: !1
}), this.renderer.setClearColor(0, 0), this.renderer.setSize(e, t), this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.shadowMap.enabled = !0, this.renderer.shadowMap.type = v.PCFSoftShadowMap, this.renderer.localClippingEnabled = !0, this.renderer.outputColorSpace = v.SRGBColorSpace, this.renderer.toneMapping = v.ACESFilmicToneMapping, this.renderer.toneMappingExposure = 1.5, this.engine.container.appendChild(this.renderer.domElement), this.renderer;
}
disposeRenderer() {
this.renderer?.dispose();
}
}
const Wn = { type: "change" }, Dn = { type: "start" }, Di = { type: "end" }, Ot = new cs(), Kn = new hs(), ur = Math.cos(70 * xi.DEG2RAD), ye = new pe(), Se = 2 * Math.PI, ce = {
NONE: -1,
ROTATE: 0,
DOLLY: 1,
PAN: 2,
TOUCH_ROTATE: 3,
TOUCH_PAN: 4,
TOUCH_DOLLY_PAN: 5,
TOUCH_DOLLY_ROTATE: 6
}, un = 1e-6;
class dr extends us {
/**
* Constructs a new controls instance.
*
* @param {Object3D} object - The object that is managed by the controls.
* @param {?HTMLElement} domElement - The HTML element used for event listeners.
*/
constructor(e, t, n = null) {
super(t, n), this.engine = e, this.state = ce.NONE, this.target = new pe(), this.cursor = new pe(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: ht.ROTATE, MIDDLE: ht.DOLLY, RIGHT: ht.PAN }, this.touches = { ONE: lt.ROTATE, TWO: lt.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new pe(), this._lastQuaternion = new Yt(), this._lastTargetPosition = new pe(), this._quat = new Yt().setFromUnitVectors(t.up, new pe(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new In(), this._sphericalDelta = new In(), this._scale = 1, this._panOffset = new pe(), this._rotateStart = new de(), this._rotateEnd = new de(), this._rotateDelta = new de(), this._panStart = new de(), this._panEnd = new de(), this._panDelta = new de(), this._dollyStart = new de(), this._dollyEnd = new de(), this._dollyDelta = new de(), this._dollyDirection = new pe(), this._mouse = new de(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = pr.bind(this), this._onPointerDown = fr.bind(this), this._onPointerUp = mr.bind(this), this._onContextMenu = vr.bind(this), this._onMouseWheel = yr.bind(this), this._onKeyDown = wr.bind(this), this._onTouchStart = xr.bind(this), this._onTouchMove = br.bind(this), this._onMouseDown = gr.bind(this), this._onMouseMove = _r.bind(this), this._interceptControlDown = Tr.bind(this), this._interceptControlUp = Sr.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
}
connect(e) {
super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), this.domElement.style.touchAction = "none";
}
disconnect() {
this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = "auto";
}
dispose() {
this.disconnect();
}
/**
* Get the current vertical rotation, in radians.
*
* @return {number} The current vertical rotation, in radians.
*/
getPolarAngle() {
return this._spherical.phi;
}
/**
* Get the current horizontal rotation, in radians.
*
* @return {number} The current horizontal rotation, in radians.
*/
getAzimuthalAngle() {
return this._spherical.theta;
}
/**
* Returns the distance from the camera to the target.
*
* @return {number} The distance from the camera to the target.
*/
getDistance() {
return this.object.position.distanceTo(this.target);
}
/**
* Adds key event listeners to the given DOM element.
* `window` is a recommended argument for using this method.
*
* @param {HTMLElement} domElement - The DOM element
*/
listenToKeyEvents(e) {
e.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = e;
}
/**
* Removes the key event listener previously defined with `listenToKeyEvents()`.
*/
stopListenToKeyEvents() {
this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
}
/**
* Save the current state of the controls. This can later be recovered with `reset()`.
*/
saveState() {
this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
}
/**
* Reset the controls to their state from either the last time the `saveState()`
* was called, or the initial state.
*/
reset() {
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(Wn), this.update(), this.state = ce.NONE;
}
update(e = null) {
const t = this.object.position;
ye.copy(t).sub(this.target), ye.applyQuaternion(this._quat), this._spherical.setFromVector3(ye), this.autoRotate && this.state === ce.NONE && this._rotateLeft(this._getAutoRotationAngle(e)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);
let n = this.minAzimuthAngle, i = this.maxAzimuthAngle;
isFinite(n) && isFinite(i) && (n < -Math.PI ? n += Se : n > Math.PI && (n -= Se), i < -Math.PI ? i += Se : i > Math.PI && (i -= Se), n <= i ? this._spherical.theta = Math.max(n, Math.min(i, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (n + i) / 2 ? Math.max(n, this._spherical.theta) : Math.min(i, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
let o = !1;
if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
this._spherical.radius = this._clampDistance(this._spherical.radius);
else {
const s = this._spherical.radius;
this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), o = s != this._spherical.radius;
}
if (ye.setFromSpherical(this._spherical), ye.applyQuaternion(this._quatInverse), t.copy(this.target).add(ye), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) {
let s = null;
if (this.object.isPerspectiveCamera) {
const a = ye.length();
s = this._clampDistance(a * this._scale);
const l = a - s;
this.object.position.addScaledVector(this._dollyDirection, l), this.object.updateMatrixWorld(), o = !!l;
} else if (this.object.isOrthographicCamera) {
const a = new pe(this._mouse.x, this._mouse.y, 0);
a.unproject(this.object);
const l = this.object.zoom;
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), o = l !== this.object.zoom;
const h = new pe(this._mouse.x, this._mouse.y, 0);
h.unproject(this.object), this.object.position.sub(h).add(a), this.object.updateMatrixWorld(), s = ye.length();
} else
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
s !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position) : (Ot.origin.copy(this.object.position), Ot.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(Ot.direction)) < ur ? this.object.lookAt(this.target) : (Kn.setFromNormalAndCoplanarPoint(this.object.up, this.target), Ot.intersectPlane(Kn, this.target))));
} else if (this.object.isOrthographicCamera) {
const s = this.object.zoom;
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), s !== this.object.zoom && (this.object.updateProjectionMatrix(), o = !0);
}
return this._scale = 1, this._performCursorZoom = !1, o || this._lastPosition.distanceToSquared(this.object.position) > un || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > un || this._lastTargetPosition.distanceToSquared(this.target) > un ? (this.dispatchEvent(Wn), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
}
_getAutoRotationAngle(e) {
return e !== null ? Se / 60 * this.autoRotateSpeed * e : Se / 60 / 60 * this.autoRotateSpeed;
}
_getZoomScale(e) {
const t = Math.abs(e * 0.01);
return Math.pow(0.95, this.zoomSpeed * t);
}
_rotateLeft(e) {
this._sphericalDelta.theta -= e;
}
_rotateUp(e) {
this._sphericalDelta.phi -= e;
}
_panLeft(e, t) {
ye.setFromMatrixColumn(t, 0), ye.multiplyScalar(-e), this._panOffset.add(ye);
}
_panUp(e, t) {
this.screenSpacePanning === !0 ? ye.setFromMatrixColumn(t, 1) : (ye.setFromMatrixColumn(t, 0), ye.crossVectors(this.object.up, ye)), ye.multiplyScalar(e), this._panOffset.add(ye);
}
// deltaX and deltaY are in pixels; right and down are positive
_pan(e, t) {
const n = this.domElement;
if (this.object.isPerspectiveCamera) {
const i = this.object.position;
ye.copy(i).sub(this.target);
let o = ye.length();
o *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * o / n.clientHeight, this.object.matrix), this._panUp(2 * t * o / n.clientHeight, this.object.matrix);
} else this.object.isOrthographicCamera ? (this._panLeft(e * (this.object.right - this.object.left) / this.object.zoom / n.clientWidth, this.object.matrix), this._panUp(t * (this.object.top - this.object.bottom) / this.object.zoom / n.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
}
_dollyOut(e) {
this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
}
_dollyIn(e) {
this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
}
_updateZoomParameters(e, t) {
if (!this.zoomToCursor)
return;
this._performCursorZoom = !0;
const n = this.domElement.getBoundingClientRect(), i = e - n.left, o = t - n.top, s = n.width, a = n.height;
this._mouse.x = i / s * 2 - 1, this._mouse.y = -(o / a) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
}
_clampDistance(e) {
return Math.max(this.minDistance, Math.min(this.maxDistance, e));
}
//
// event callbacks - update the object state
//
_handleMouseDownRotate(e) {
this._rotateStart.set(e.clientX, e.clientY);
}
_handleMouseDownDolly(e) {
this._updateZoomParameters(e.clientX, e.clientX), this._dollyStart.set(e.clientX, e.clientY);
}
_handleMouseDownPan(e) {
this._panStart.set(e.clientX, e.clientY);
}
_handleMouseMoveRotate(e) {
this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
const t = this.domElement;
this._rotateLeft(Se * this._rotateDelta.x / t.clientHeight), this._rotateUp(Se * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
}
_handleMouseMoveDolly(e) {
this._dollyEnd.set(e.clientX, e.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.update();
}
_handleMouseMovePan(e) {
this._panEnd.set(e.clientX, e.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update();
}
_handleMouseWheel(e) {
this._updateZoomParameters(e.clientX, e.clientY), e.deltaY < 0 ? this._dollyIn(this._getZoomScale(e.deltaY)) : e.deltaY > 0 && this._dollyOut(this._getZoomScale(e.deltaY)), this.update();
}
_handleKeyDown(e) {
let t = !1;
switch (e.code) {
case this.keys.UP:
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(Se * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), t = !0;
break;
case this.keys.BOTTOM:
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(-Se * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), t = !0;
break;
case this.keys.LEFT:
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(Se * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), t = !0;
break;
case this.keys.RIGHT:
e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(-Se * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), t = !0;
break;
}
t && (e.preventDefault(), this.update());
}
_handleTouchStartRotate(e) {
if (this._pointers.length === 1)
this._rotateStart.set(e.pageX, e.pageY);
else {
const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), i = 0.5 * (e.pageY + t.y);
this._rotateStart.set(n, i);
}
}
_handleTouchStartPan(e) {
if (this._pointers.length === 1)
this._panStart.set(e.pageX, e.pageY);
else {
const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), i = 0.5 * (e.pageY + t.y);
this._panStart.set(n, i);
}
}
_handleTouchStartDolly(e) {
const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, i = e.pageY - t.y, o = Math.sqrt(n * n + i * i);
this._dollyStart.set(0, o);
}
_handleTouchStartDollyPan(e) {
this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e);
}
_handleTouchStartDollyRotate(e) {
this.enableZoom && this._handleTouchStartDolly(e), this.enableRotate && this._handleTouchStartRotate(e);
}
_handleTouchMoveRotate(e) {
if (this._pointers.length == 1)
this._rotateEnd.set(e.pageX, e.pageY);
else {
const n = this._getSecondPointerPosition(e), i = 0.5 * (e.pageX + n.x), o = 0.5 * (e.pageY + n.y);
this._rotateEnd.set(i, o);
}
this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
const t = this.domElement;
this._rotateLeft(Se * this._rotateDelta.x / t.clientHeight), this._rotateUp(Se * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd);
}
_handleTouchMovePan(e) {
if (this._pointers.length === 1)
this._panEnd.set(e.pageX, e.pageY);
else {
const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), i = 0.5 * (e.pageY + t.y);
this._panEnd.set(n, i);
}
this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
}
_handleTouchMoveDolly(e) {
const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, i = e.pageY - t.y, o = Math.sqrt(n * n + i * i);
this._dollyEnd.set(0, o), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
const s = (e.pageX + t.x) * 0.5, a = (e.pageY + t.y) * 0.5;
this._updateZoomParameters(s, a);
}
_handleTouchMoveDollyPan(e) {
this.enableZoom && this._handleTouchMoveDolly(e), this.enablePan && this._handleTouchMovePan(e);
}
_handleTouchMoveDollyRotate(e) {
this.enableZoom && this._handleTouchMoveDolly(e), this.enableRotate && this._handleTouchMoveRotate(e);
}
// pointers
_addPointer(e) {
this._pointers.push(e.pointerId);
}
_removePointer(e) {
delete this._pointerPositions[e.pointerId];
for (let t = 0; t < this._pointers.length; t++)
if (this._pointers[t] == e.pointerId) {
this._pointers.splice(t, 1);
return;
}
}
_isTrackingPointer(e) {
for (let t = 0; t < this._pointers.length; t++)
if (this._pointers[t] == e.pointerId) return !0;
return !1;
}
_trackPointer(e) {
let t = this._pointerPositions[e.pointerId];
t === void 0 && (t = new de(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);
}
_getSecondPointerPosition(e) {
const t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
return this._pointerPositions[t];
}
//
_customWheelEvent(e) {
const t = e.deltaMode, n = {
clientX: e.clientX,
clientY: e.clientY,
deltaY: e.deltaY
};
switch (t) {
case 1:
n.deltaY *= 16;
break;
case 2:
n.deltaY *= 100;
break;
}
return e.ctrlKey && !this._controlActive && (n.deltaY *= 10), n;
}
}
function fr(r) {
this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(r.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(r) && (this._addPointer(r), r.pointerType === "touch" ? this._onTouchStart(r) : this._onMouseDown(r)));
}
function pr(r) {
this.enabled !== !1 && (r.pointerType === "touch" ? this._onTouchMove(r) : this._onMouseMove(r));
}
function mr(r) {
switch (this._removePointer(r), this._pointers.length) {
case 0:
this.domElement.releasePointerCapture(r.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(Di), this.state = ce.NONE;
break;
case 1:
const e = this._pointers[0], t = this._pointerPositions[e];
this._onTouchStart({ pointerId: e, pageX: t.x, pageY: t.y });
break;
}
}
function gr(r) {
let e;
switch (r.button) {
case 0:
e = this.mouseButtons.LEFT;
break;
case 1:
e = this.mouseButtons.MIDDLE;
break;
case 2:
e = this.mouseButtons.RIGHT;
break;
default:
e = -1;
}
switch (e) {
case ht.DOLLY:
if (this.enableZoom === !1) return;
this._handleMouseDownDolly(r), this.state = ce.DOLLY;
break;
case ht.ROTATE:
if (r.ctrlKey || r.metaKey || r.shiftKey) {
if (this.enablePan === !1) return;
this._handleMouseDownPan(r), this.state = ce.PAN;
} else {
if (this.enableRotate === !1) return;
this._handleMouseDownRotate(r), this.state = ce.ROTATE;
}
break;
case ht.PAN:
if (r.ctrlKey || r.metaKey || r.shiftKey) {
if (this.enableRotate === !1) return;
this._handleMouseDownRotate(r), this.state = ce.ROTATE;
} else {
if (this.enablePan === !1) return;
this._handleMouseDownPan(r), this.state = ce.PAN;
}
break;
default:
this.state = ce.NONE;
}
this.state !== ce.NONE && this.dispatchEvent(Dn);
}
function _r(r) {
switch (this.state) {
case ce.ROTATE:
if (this.enableRotate === !1) return;
this._handleMouseMoveRotate(r);
break;
case ce.DOLLY:
if (this.enableZoom === !1) return;
this._handleMouseMoveDolly(r);
break;
case ce.PAN:
if (this.enablePan === !1) return;
this._handleMouseMovePan(r);
break;
}
}
function yr(r) {
this.enabled === !1 || this.enableZoom === !1 || this.state !== ce.NONE || (r.preventDefault(), this.dispatchEvent(Dn), this._handleMouseWheel(this._customWheelEvent(r)), this.dispatchEvent(Di));
}
function wr(r) {
this.enabled !== !1 && this._handleKeyDown(r);
}
function xr(r) {
switch (this._trackPointer(r), this._pointers.length) {
case 1:
switch (this.touches.ONE) {
case lt.ROTATE:
if (this.enableRotate === !1) return;
this._handleTouchStartRotate(r), this.state = ce.TOUCH_ROTATE;
break;
case lt.PAN:
if (this.enablePan === !1) return;
this._handleTouchStartPan(r), this.state = ce.TOUCH_PAN;
break;
default:
this.state = ce.NONE;
}
break;
case 2:
switch (this.touches.TWO) {
case lt.DOLLY_PAN:
if (this.enableZoom === !1 && this.enablePan === !1) return;
this._handleTouchStartDollyPan(r), this.state = ce.TOUCH_DOLLY_PAN;
break;
case lt.DOLLY_ROTATE:
if (this.enableZoom === !1 && this.enableRotate === !1) return;
this._handleTouchStartDollyRotate(r), this.state = ce.TOUCH_DOLLY_ROTATE;
break;
default:
this.state = ce.NONE;
}
break;
default:
this.state = ce.NONE;
}
this.state !== ce.NONE && this.dispatchEvent(Dn);
}
function br(r) {
switch (this._trackPointer(r), this.state) {
case ce.TOUCH_ROTATE:
if (this.enableRotate === !1) return;
this._handleTouchMoveRotate(r), this.update();
break;
case ce.TOUCH_PAN:
if (this.enablePan === !1) return;
this._handleTouchMovePan(r), this.update();
break;
case ce.TOUCH_DOLLY_PAN:
if (this.enableZoom === !1 && this.enablePan === !1) return;
this._handleTouchMoveDollyPan(r), this.update();
break;
case ce.TOUCH_DOLLY_ROTATE:
if (this.enableZoom === !1 && this.enableRotate === !1) return;
this._handleTouchMoveDollyRotate(r), this.update();
break;
default:
this.state = ce.NONE;
}
}
function vr(r) {
this.enabled !== !1 && r.preventDefault();
}
function Tr(r) {
r.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
function Sr(r) {
r.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
}
class Xn {
constructor(e, t, n, i) {
this._Engine = e, this.camera = t, this.domElement = n, this._isEnabled = !1, this._rayOriginOffset = new v.Vector3(0, -1, 0), this._camerLocalDirection = new v.Vector3(), this._tmpVector = new v.Vector3(), this._rayCaster = new v.Raycaster(), this._fallingTime = 0, this._euler = new v.Euler(0, 0, 0, "YZX"), this._prevMouseX = 0, this._prevMouseY = 0, this.applyGravity = !1, this.gravityMinHeight = !0, this.applyCollision = !0, this.positionEasing = !0, this.lookflag = 1, this.lookSpeed = 8e-3, this.moveSpeed = 0.02, this.playerHeight = 1.4, this.maxRotateX = 0.8, this.g = 9.8, this.bindmousedown = this._Engine && this._Engine.DeviceType !== "PC" ? this.onTouchStart.bind(this) : this.onMouseDown.bind(this), this.bindmouseup = this._Engine && this._Engine.DeviceType !== "PC" ? this.onTouchEnd.bind(this) : this.onMouseUp.bind(this), this.bindmousemove = this._Engine && this._Engine.DeviceType !== "PC" ? this.onTouchMove.bind(this) : this.onMouseMove.bind(this), this.bindonKeyDown = this.onKeyDown.bind(this), this.bindonKeyUp = this.onKeyUp.bind(this), this.bindMousewheel = this.onMousewheel.bind(this), this.needMousewheel = !1, this.moveWheelRun = !0, this.moveWheelStop = !1, this.wheelClock, this.keydown = !1, this.GetEngine = () => e;
}
/**
* @param {Object} colliders set objects for collision detection
*/
set colliders(e) {
this._rayCastObjects = e;
}
/**
* @param {boolean} isEnabled set if this camera control is enabled
*/
set enabled(e) {
this._isEnabled !== e && (this._isEnabled = e, this._euler.setFromQuaternion(this.camera.quaternion), e ? this.addEvents() : this.removeEvents());
}
/**
* @description: getter if current camera control is enabled.
*/
get enabled() {
return this._isEnabled;
}
addEvents() {
const e = this._Engine?.DeviceType, t = e === "PC" || !e;
console.log("[FirstPersonCameraControl] addEvents - DeviceType:", e, "isPC:", t), t ? (console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"), this.domElement.addEventListener("mousedown", this.bindmousedown, !1), this.domElement.addEventListener("mouseup", this.bindmouseup, !1)) : (console.log("[FirstPersonCameraControl] 添加触摸事件监听器"), this.domElement.addEventListener("touchstart", this.bindmousedown, !1), this.domElement.addEventListener("touchend", this.bindmouseup, !1)), window.addEventListener("keydown", this.bindonKeyDown, !1), window.addEventListener("keyup", this.bindonKeyUp, !1), this.needMousewheel && (document.addEventListener && document.addEventListener("DOMMouseScroll", this.bindMousewheel, !1), window.addEventListener("mousewheel", this.bindMousewheel, !1));
}
removeEvents() {
this._Engine && this._Engine.DeviceType !== "PC" ? (this.domElement.removeEventListener("touchstart", this.bindmousedown), this.domElement.removeEventListener("touchend", this.bindmouseup), this.domElement.removeEventListener("touchmove", this.bindmousemove)) : (this.domElement.removeEventListener("mousedown", this.bindmousedown), this.domElement.removeEventListener("mouseup", this.bindmouseup), this.domElement.removeEventListener("mousemove", this.bindmousemove)), window.removeEventListener("keydown", this.bindonKeyDown), window.removeEventListener("keyup", this.bindonKeyUp), this.needMousewheel && (document.addEventListener && document.removeEventListener("DOMMouseScroll", this.bindMousewheel), window.removeEventListener("mousewheel", this.bindMousewheel));
}
onMousewheel(e) {
debugger;
let t;
switch (e.wheelDelta ? (e.wheelDelta > 0 && (t = "up"), e.wheelDelta < 0 && (t = "down")) : e.detail && (e.detail < 0 && (t = "up"), e.detail > 0 && (t = "down")), t) {
case "up":
this._camerLocalDirection.z = 1;
break;
case "down":
this._camerLocalDirection.z = -1;
break;
}
this.moveWheelRun == !0 ? (this.moveWheelRun = !1, this.moveWheelStop = !0, this.wheelClock = setTimeout(() => {
this.moveWheelStop == !0 && (this.moveWheelStop = !1, this.moveWheelRun = !0, this._camerLocalDirection.z = 0);
}, 200)) : (clearTimeout(this.wheelClock), this.wheelClock = setTimeout(() => {
this.moveWheelStop == !0 && (this.moveWheelStop = !1, this.moveWheelRun = !0, this._camerLocalDirection.z = 0);
}, 150));
}
onMouseDown(e) {
console.log("[FirstPersonCameraControl] onMouseDown 被调用", e), this.domElement.addEventListener("mousemove", this.bindmousemove, !1), this._prevMouseX = e.screenX, this._prevMouseY = e.screenY;
}
onMouseMove(e) {
if (this._isEnabled == !1)
return;
let t = this._prevMouseX ? e.screenX - this._prevMouseX : 0, n = this._prevMouseY ? e.screenY - this._prevMouseY : 0, i = this._euler.x - n * this.lookflag * this.lookSpeed;
i >= 0 ? i < this.maxRotateX ? this._euler.x = i : this._euler.x = this.maxRotateX : i > -this.maxRotateX ? this._euler.x = i : this._euler.x = -this.maxRotateX, this._euler.y -= t * this.lookSpeed, this.camera.quaternion.setFromEuler(this._euler), this._prevMouseX = e.screenX, this._prevMouseY = e.screenY;
let o = this.GetEngine();
o.movefirst = !0;
var s = new CustomEvent("bimengine:camerachange", {
detail: ""
});
window.dispatchEvent(s);
}
onMouseUp(e) {
let t = this.GetEngine();
t.movefirst = !1, this.domElement.removeEventListener("mousemove", this.bindmousemove);
}
onTouchStart(e) {
this.domElement.addEventListener("touchmove", this.bindmousemove, !1), this._prevMouseX = e.targetTouches[0].clientX, this._prevMouseY = e.targetTouches[0].clientY;
}
onTouchMove(e) {
if (this._isEnabled == !1)
return;
let t = this._prevMouseX ? e.targetTouches[0].clientX - this._prevMouseX : 0, n = this._prevMouseY ? e.targetTouches[0].clientY - this._prevMouseY : 0, i = this._euler.x - n * this.lookflag * this.lookSpeed;
i >= 0 ? i < this.maxRotateX ? this._euler.x = i : this._euler.x = this.maxRotateX : i > -this.maxRotateX ? this._euler.x = i : this._euler.x = -this.maxRotateX, this._euler.y -= t * this.lookSpeed, this.camera.quaternion.setFromEuler(this._euler), this._prevMouseX = e.targetTouches[0].clientX, this._prevMouseY = e.targetTouches[0].clientY;
let o = this.GetEngine();
o.movefirst = !0;
var s = new CustomEvent("bimengine:camerachange", {
detail: ""
});
window.dispatchEvent(s);
}
onTouchEnd(e) {
let t = this.GetEngine();
t.movefirst = !1, this.domElement.removeEventListener("touchmove", this.bindmousemove);
}
onKeyDown(e) {
var t = new CustomEvent("bimengine:camerachange", {
detail: ""
});
let n = this.GetEngine();
switch (n.movefirst = !0, window.dispatchEvent(t), e.keyCode) {
case 38:
this.rotateY(-1);
break;
case 81:
this.keydown = !0, this._camerLocalDirection.y = 1;
break;
case 69:
this._camerLocalDirection.y = -1;
break;
case 87:
this._camerLocalDirection.z = 1;
break;
case 37:
this.rotateX(-1);
break;
case 65:
this._camerLocalDirection.x = -1;
break;
case 40:
this.rotateY(1);
break;
case 83:
this._camerLocalDirection.z = -1;
break;
case 39:
this.rotateX(1);
break;
case 68:
this._camerLocalDirection.x = 1;
break;
}
}
onKeyUp(e) {
let t = this.GetEngine();
switch (t.movefirst = !1, e.keyCode) {
case 38:
// up
case 87:
this._camerLocalDirection.z = 0;
break;
case 37:
// left
case 65:
this._camerLocalDirection.x = 0;
break;
case 40:
// down
case 83:
this._camerLocalDirection.z = 0;
break;
case 39:
// right
case 68:
this._camerLocalDirection.x = 0;
break;
case 81:
case 69:
this.keydown = !1, this._camerLocalDirection.y = 0;
break;
}
}
/**
* @description: rotate camera by left/right
* @param {Number} value
* @return: null
*/
rotateX(e) {
this._euler.y -= e * this.lookSpeed, this.camera.quaternion.setFromEuler(this._euler);
}
/**
* @description: rotate camera by up/down
* @param {Number} value
* @return: null
*/
rotateY(e) {
let t = this._euler.x - e * this.lookflag * 0.5 * this.lookSpeed;
t >= 0 ? t < this.maxRotateX ? this._euler.x = t : this._euler.x = this.maxRotateX : t > -this.maxRotateX ? this._euler.x = t : this._euler.x = -this.maxRotateX, this.camera.quaternion.setFromEuler(this._euler);
}
/**
* @description: update current calcuate each frame.
*/
update() {
this.keydown || this.gravityTest(), this.collisionTest();
}
gravityTest() {
if (this.applyGravity) {
let e = !0;
this._fallingTime += 0.01, this._tmpVector.set(0, -1, 0);
const t = this.hitTest();
if (t) {
const n = t.point.add(new v.Vector3(0, this.playerHeight, 0));
if (this.positionEasing) {
if (n.y >= this.camera.position.y || n.y - this.camera.position.y < 0.2) {
this.setCameraHeight(this.camera.position.y + (n.y - this.camera.position.y) * 0.08), this._fallingTime = 0, e = !1;
return;
}
} else t.distance < this.playerHeight && (this.setCameraHeight(n.y), this._fallingTime = 0, e = !1);
}
e && this.setCameraHeight(this.camera.position.y - this.g * Math.pow(this._fallingTime, 2));
} else
this.setCameraHeight(this.camera.position.y);
}
collisionTest() {
this._camerLocalDirection.x !== 0 && this.collisionTestX(), this._camerLocalDirection.z !== 0 && this.collisionTestZ(), this._camerLocalDirection.y !== 0 && this.collisionTestY();
}
collisionTestX() {
let e = this.GetEngine();
if (e.movefirst = !0, this._tmpVector.setFromMatrixColumn(this.camera.matrix, 0), this._tmpVector.multiplyScalar(this._camerLocalDirection.x), this.applyCollision) {
const t = this.hitTest();
if (t && t.distance < 0.3)
return;
}
this.camera.position.addScaledVector(this._tmpVector, this.moveSpeed);
}
collisionTestZ() {
let e = this.GetEngine();
if (e.movefirst = !0, this._tmpVector.setFromMatrixColumn(this.camera.matrix, 0), this._tmpVector.crossVectors(this.camera.up, this._tmpVector), this._tmpVector.multiplyScalar(this._camerLocalDirection.z), this.applyCollision) {
const t = this.hitTest();
if (t && t.distance < 0.3)
return;
}
this.camera.position.addScaledVector(this._tmpVector, this.moveSpeed);
}
collisionTestY() {
let e = this.GetEngine();
if (e.movefirst = !0, this._tmpVector.setFromMatrixColumn(this.camera.matrix, 0), this._tmpVector = new v.Vector3(0, 1, 0), this._tmpVector.multiplyScalar(this._camerLocalDirection.y), this.applyCollision) {
const n = this.hitTest();
if (n && n.distance < 0.3)
return;
}
let t = this.camera.position.clone().addScaledVector(this._tmpVector, this.moveSpeed);
this.setCameraHeight(t.y);
}
// 设置相机Y方向位置
setCameraHeight(e) {
let t = this.getMinHeight();
this.gravityMinHeight && t !== void 0 && e < t ? this.camera.position.y = t : this.camera.position.y = e;
}
// 获得所有模型最低点
getMinHeight() {
let e, t = this.GetEngine(), n = t.ToolUntils ? t.ToolUntils.GetBoundingBox(t) : null;
return t && n && (e = n.min.y), e;
}
hitTest() {
const e = this.camera.position.clone().add(this._rayOriginOffset);
this._rayCaster.ray.origin = e, this._rayCaster.ray.direction = this._tmpVector;
var n = this.GetEngine().scene.ground;
return n && n.material.type, null;
}
}
class Er {
engine;
orbitControls;
firstPersonControls;
isActive = !0;
constructor(e) {
this.engine = e, this.init();
}
init() {
this.orbitControls = new dr(this.engine, this.engine.camera, this.engine.renderer.domElement), this.firstPersonControls = new Xn(this.engine, this.engine.camera, this.engine.renderer.domElement);
}
active() {
this.isActive = !0, this.orbitControls.enabled = !0;
}
disActive() {
this.isActive = !1, this.orbitControls.enabled = !1;
}
// 切换第一人称漫游模式
switchFirstPersonMode() {
this.firstPersonControls = new Xn(
this.engine,
this.engine.camera,
this.engine.renderer.domElement,
[]
), this.orbitControls.enabled = !1, this.firstPersonControls.enabled = !0, this.firstPersonControls.isActive = !0;
}
// 切换默认模式
switchDefaultMode() {
this.firstPersonControls && (this.firstPersonControls.enabled = !1), this.orbitControls.enabled = !0;
}
update() {
this.firstPersonControls.enabled && this.firstPersonControls.update();
}
}
const tt = {
name: "CopyShader",
uniforms: {
tDiffuse: { value: null },
opacity: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`
),
fragmentShader: (
/* glsl */
`
uniform float opacity;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = opacity * texel;
}`
)
};
class ot {
/**
* Constructs a new pass.
*/
constructor() {
this.isPass = !0, this.enabled = !0, this.needsSwap = !0, this.clear = !1, this.renderToScreen = !1;
}
/**
* Sets the size of the pass.
*
* @abstract
* @param {number} width - The width to set.
* @param {number} height - The height to set.
*/
setSize() {
}
/**
* This method holds the render logic of a pass. It must be implemented in all derived classes.
*
* @abstract
* @param {WebGLRenderer} renderer - The renderer.
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
* destination for the pass.
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
* previous pass from this buffer.
* @param {number} deltaTime - The delta time in seconds.
* @param {boolean} maskActive - Whether masking is active or not.
*/
render() {
console.error("THREE.Pass: .render() must be implemented in derived pass.");
}
/**
* Frees the GPU-related resources allocated by this instance. Call this
* method whenever the pass is no longer used in your app.
*
* @abstract
*/
dispose() {
}
}
const Mr = new vi(-1, 1, 1, -1, 0, 1);
class Ar extends tn {
constructor() {
super(), this.setAttribute("position", new Bn([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3)), this.setAttribute("uv", new Bn([0, 2, 0, 0, 2, 0], 2));
}
}
const Cr = new Ar();
class nn {
/**
* Constructs a new full screen quad.
*
* @param {?Material} material - The material to render te full screen quad with.
*/
constructor(e) {
this._mesh = new bi(Cr, e);
}
/**
* Frees the GPU-related resources allocated by this instance. Call this
* method whenever the instance is no longer used in your app.
*/
dispose() {
this._mesh.geometry.dispose();
}
/**
* Renders the full screen quad.
*
* @param {WebGLRenderer} renderer - The renderer.
*/
render(e) {
e.render(this._mesh, Mr);
}
/**
* The quad's material.
*
* @type {?Material}
*/
get material() {
return this._mesh.material;
}
set material(e) {
this._mesh.material = e;
}
}
class Wt extends ot {
/**
* Constructs a new shader pass.
*
* @param {Object|ShaderMaterial} [shader] - A shader object holding vertex and fragment shader as well as
* defines and uniforms. It's also valid to pass a custom shader material.
* @param {string} [textureID='tDiffuse'] - The name of the texture uniform that should sample
* the read buffer.
*/
constructor(e, t = "tDiffuse") {
super(), this.textureID = t, this.uniforms = null, this.material = null, e instanceof Le ? (this.uniforms = e.uniforms, this.material = e) : e && (this.uniforms = Ve.clone(e.uniforms), this.material = new Le({
name: e.name !== void 0 ? e.name : "unspecified",
defines: Object.assign({}, e.defines),
uniforms: this.uniforms,
vertexShader: e.vertexShader,
fragmentShader: e.fragmentShader
})), this._fsQuad = new nn(this.material);
}
/**
* Performs the shader pass.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
* destination for the pass.
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
* previous pass from this buffer.
* @param {number} deltaTime - The delta time in seconds.
* @param {boolean} maskActive - Whether masking is active or not.
*/
render(e, t, n) {
this.uniforms[this.textureID] && (this.uniforms[this.textureID].value = n.texture), this._fsQuad.material = this.material, this.renderToScreen ? (e.setRenderTarget(null), this._fsQuad.render(e)) : (e.setRenderTarget(t), this.clear && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), this._fsQuad.render(e));
}
/**
* Frees the GPU-related resources allocated by this instance. Call this
* method whenever the pass is no longer used in your app.
*/
dispose() {
this.material.dispose(), this._fsQuad.dispose();
}
}
class Zn extends ot {
/**
* Constructs a new mask pass.
*
* @param {Scene} scene - The 3D objects in this scene will define the mask.
* @param {Camera} camera - The camera.
*/
constructor(e, t) {
super(), this.scene = e, this.camera = t, this.clear = !0, this.needsSwap = !1, this.inverse = !1;
}
/**
* Performs a mask pass with the configured scene and camera.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
* destination for the pass.
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
* previous pass from this buffer.
* @param {number} deltaTime - The delta time in seconds.
* @param {boolean} maskActive - Whether masking is active or not.
*/
render(e, t, n) {
const i = e.getContext(), o = e.state;
o.buffers.color.setMask(!1), o.buffers.depth.setMask(!1), o.buffers.color.setLocked(!0), o.buffers.depth.setLocked(!0);
let s, a;
this.inverse ? (s = 0, a = 1) : (s = 1, a = 0), o.buffers.stencil.setTest(!0), o.buffers.stencil.setOp(i.REPLACE, i.REPLACE, i.REPLACE), o.buffers.stencil.setFunc(i.ALWAYS, s, 4294967295), o.buffers.stencil.setClear(a), o.buffers.stencil.setLocked(!0), e.setRenderTarget(n), this.clear && e.clear(), e.render(this.scene, this.camera), e.setRenderTarget(t), this.clear && e.clear(), e.render(this.scene, this.camera), o.buffers.color.setLocked(!1), o.buffers.depth.setLocked(!1), o.buffers.color.setMask(!0), o.buffers.depth.setMask(!0), o.buffers.stencil.setLocked(!1), o.buffers.stencil.setFunc(i.EQUAL, 1, 4294967295), o.buffers.stencil.setOp(i.KEEP, i.KEEP, i.KEEP), o.buffers.stencil.setLocked(!0);
}
}
class kr extends ot {
/**
* Constructs a new clear mask pass.
*/
constructor() {
super(), this.needsSwap = !1;
}
/**
* Performs the clear of the currently defined mask.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
* destination for the pass.
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
* previous pass from this buffer.
* @param {number} deltaTime - The delta time in seconds.
* @param {boolean} maskActive - Whether masking is active or not.
*/
render(e) {
e.state.buffers.stencil.setLocked(!1), e.state.buffers.stencil.setTest(!1);
}
}
class Pr {
/**
* Constructs a new effect composer.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {WebGLRenderTarget} [renderTarget] - This render target and a clone will
* be used as the internal read and write buffers. If not given, the composer creates
* the buffers automatically.
*/
constructor(e, t) {
if (this.renderer = e, this._pixelRatio = e.getPixelRatio(), t === void 0) {
const n = e.getSize(new de());
this._width = n.width, this._height = n.height, t = new ut(this._width * this._pixelRatio, this._height * this._pixelRatio, { type: dt }), t.texture.name = "EffectComposer.rt1";
} else
this._width = t.width, this._height = t.height;
this.renderTarget1 = t, this.renderTarget2 = t.clone(), this.renderTarget2.texture.name = "EffectComposer.rt2", this.writeBuffer = this.renderTarget1, this.readBuffer = this.renderTarget2, this.renderToScreen = !0, this.passes = [], this.copyPass = new Wt(tt), this.copyPass.material.blending = je, this.clock = new ds();
}
/**
* Swaps the internal read/write buffers.
*/
swapBuffers() {
const e = this.readBuffer;
this.readBuffer = this.writeBuffer, this.writeBuffer = e;
}
/**
* Adds the given pass to the pass chain.
*
* @param {Pass} pass - The pass to add.
*/
addPass(e) {
this.passes.push(e), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
}
/**
* Inserts the given pass at a given index.
*
* @param {Pass} pass - The pass to insert.
* @param {number} index - The index into the pass chain.
*/
insertPass(e, t) {
this.passes.splice(t, 0, e), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
}
/**
* Removes the given pass from the pass chain.
*
* @param {Pass} pass - The pass to remove.
*/
removePass(e) {
const t = this.passes.indexOf(e);
t !== -1 && this.passes.splice(t, 1);
}
/**
* Returns `true` if the pass for the given index is the last enabled pass in the pass chain.
*
* @param {number} passIndex - The pass index.
* @return {boolean} Whether the pass for the given index is the last pass in the pass chain.
*/
isLastEnabledPass(e) {
for (let t = e + 1; t < this.passes.length; t++)
if (this.passes[t].enabled)
return !1;
return !0;
}
/**
* Executes all enabled post-processing passes in order to produce the final frame.
*
* @param {number} deltaTime - The delta time in seconds. If not given, the composer computes
* its own time delta value.
*/
render(e) {
e === void 0 && (e = this.clock.getDelta());
const t = this.renderer.getRenderTarget();
let n = !1;
for (let i = 0, o = this.passes.length; i < o; i++) {
const s = this.passes[i];
if (s.enabled !== !1) {
if (s.renderToScreen = this.renderToScreen && this.isLastEnabledPass(i), s.render(this.renderer, this.writeBuffer, this.readBuffer, e, n), s.needsSwap) {
if (n) {
const a = this.renderer.getContext(), l = this.renderer.state.buffers.stencil;
l.setFunc(a.NOTEQUAL, 1, 4294967295), this.copyPass.render(this.renderer, this.writeBuffer, this.readBuffer, e), l.setFunc(a.EQUAL, 1, 4294967295);
}
this.swapBuffers();
}
Zn !== void 0 && (s instanceof Zn ? n = !0 : s instanceof kr && (n = !1));
}
}
this.renderer.setRenderTarget(t);
}
/**
* Resets the internal state of the EffectComposer.
*
* @param {WebGLRenderTarget} [renderTarget] - This render target has the same purpose like
* the one from the constructor. If set, it is used to setup the read and write buffers.
*/
reset(e) {
if (e === void 0) {
const t = this.renderer.getSize(new de());
this._pixelRatio = this.renderer.getPixelRatio(), this._width = t.width, this._height = t.height, e = this.renderTarget1.clone(), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
}
this.renderTarget1.dispose(), this.renderTarget2.dispose(), this.renderTarget1 = e, this.renderTarget2 = e.clone(), this.writeBuffer = this.renderTarget1, this.readBuffer = this.renderTarget2;
}
/**
* Resizes the internal read and write buffers as well as all passes. Similar to {@link WebGLRenderer#setSize},
* this method honors the current pixel ration.
*
* @param {number} width - The width in logical pixels.
* @param {number} height - The height in logical pixels.
*/
setSize(e, t) {
this._width = e, this._height = t;
const n = this._width * this._pixelRatio, i = this._height * this._pixelRatio;
this.renderTarget1.setSize(n, i), this.renderTarget2.setSize(n, i);
for (let o = 0; o < this.passes.length; o++)
this.passes[o].setSize(n, i);
}
/**
* Sets device pixel ratio. This is usually used for HiDPI device to prevent blurring output.
* Setting the pixel ratio will automatically resize the composer.
*
* @param {number} pixelRatio - The pixel ratio to set.
*/
setPixelRatio(e) {
this._pixelRatio = e, this.setSize(this._width, this._height);
}
/**
* Frees the GPU-related resources allocated by this instance. Call this
* method whenever the composer is no longer used in your app.
*/
dispose() {
this.renderTarget1.dispose(), this.renderTarget2.dispose(), this.copyPass.dispose();
}
}
class Rr extends ot {
/**
* Constructs a new render pass.
*
* @param {Scene} scene - The scene to render.
* @param {Camera} camera - The camera.
* @param {?Material} [overrideMaterial=null] - The override material. If set, this material is used
* for all objects in the scene.
* @param {?(number|Color|string)} [clearColor=null] - The clear color of the render pass.
* @param {?number} [clearAlpha=null] - The clear alpha of the render pass.
*/
constructor(e, t, n = null, i = null, o = null) {
super(), this.scene = e, this.camera = t, this.overrideMaterial = n, this.clearColor = i, this.clearAlpha = o, this.clear = !0, this.clearDepth = !1, this.needsSwap = !1, this._oldClearColor = new Ce();
}
/**
* Performs a beauty pass with the configured scene and camera.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
* destination for the pass.
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
* previous pass from this buffer.
* @param {number} deltaTime - The delta time in seconds.
* @param {boolean} maskActive - Whether masking is active or not.
*/
render(e, t, n) {
const i = e.autoClear;
e.autoClear = !1;
let o, s;
this.overrideMaterial !== null && (s = this.scene.overrideMaterial, this.scene.overrideMaterial = this.overrideMaterial), this.clearColor !== null && (e.getClearColor(this._oldClearColor), e.setClearColor(this.clearColor, e.getClearAlpha())), this.clearAlpha !== null && (o = e.getClearAlpha(), e.setClearAlpha(this.clearAlpha)), this.clearDepth == !0 && e.clearDepth(), e.setRenderTarget(this.renderToScreen ? null : n), this.clear === !0 && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), e.render(this.scene, this.camera), this.clearColor !== null && e.setClearColor(this._oldClearColor), this.clearAlpha !== null && e.setClearAlpha(o), this.overrideMaterial !== null && (this.scene.overrideMaterial = s), e.autoClear = i;
}
}
const Nt = {
defines: {
PERSPECTIVE_CAMERA: 1,
SAMPLES: 16,
NORMAL_VECTOR_TYPE: 1,
DEPTH_SWIZZLING: "x",
SCREEN_SPACE_RADIUS: 0,
SCREEN_SPACE_RADIUS_SCALE: 100,
SCENE_CLIP_BOX: 0
},
uniforms: {
tNormal: { value: null },
tDepth: { value: null },
tNoise: { value: null },
resolution: { value: new de() },
cameraNear: { value: null },
cameraFar: { value: null },
cameraProjectionMatrix: { value: new Xe() },
cameraProjectionMatrixInverse: { value: new Xe() },
cameraWorldMatrix: { value: new Xe() },
radius: { value: 0.25 },
distanceExponent: { value: 1 },
thickness: { value: 1 },
distanceFallOff: { value: 1 },
scale: { value: 1 },
sceneBoxMin: { value: new pe(-1, -1, -1) },
sceneBoxMax: { value: new pe(1, 1, 1) }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`
),
fragmentShader: (
/* glsl */
`
varying vec2 vUv;
uniform highp sampler2D tNormal;
uniform highp sampler2D tDepth;
uniform sampler2D tNoise;
uniform vec2 resolution;
uniform float cameraNear;
uniform float cameraFar;
uniform mat4 cameraProjectionMatrix;
uniform mat4 cameraProjectionMatrixInverse;
uniform mat4 cameraWorldMatrix;
uniform float radius;
uniform float distanceExponent;
uniform float thickness;
uniform float distanceFallOff;
uniform float scale;
#if SCENE_CLIP_BOX == 1
uniform vec3 sceneBoxMin;
uniform vec3 sceneBoxMax;
#endif
#include <common>
#include <packing>
#ifndef FRAGMENT_OUTPUT
#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)
#endif
vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
return viewSpacePosition.xyz / viewSpacePosition.w;
}
float getDepth(const vec2 uv) {
return textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;
}
float fetchDepth(const ivec2 uv) {
return texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;
}
float getViewZ(const in float depth) {
#if PERSPECTIVE_CAMERA == 1
return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
#else
return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
#endif
}
vec3 computeNormalFromDepth(const vec2 uv) {
vec2 size = vec2(textureSize(tDepth, 0));
ivec2 p = ivec2(uv * size);
float c0 = fetchDepth(p);
float l2 = fetchDepth(p - ivec2(2, 0));
float l1 = fetchDepth(p - ivec2(1, 0));
float r1 = fetchDepth(p + ivec2(1, 0));
float r2 = fetchDepth(p + ivec2(2, 0));
float b2 = fetchDepth(p - ivec2(0, 2));
float b1 = fetchDepth(p - ivec2(0, 1));
float t1 = fetchDepth(p + ivec2(0, 1));
float t2 = fetchDepth(p + ivec2(0, 2));
float dl = abs((2.0 * l1 - l2) - c0);
float dr = abs((2.0 * r1 - r2) - c0);
float db = abs((2.0 * b1 - b2) - c0);
float dt = abs((2.0 * t1 - t2) - c0);
vec3 ce = getViewPosition(uv, c0).xyz;
vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
return normalize(cross(dpdx, dpdy));
}
vec3 getViewNormal(const vec2 uv) {
#if NORMAL_VECTOR_TYPE == 2
return normalize(textureLod(tNormal, uv, 0.).rgb);
#elif NORMAL_VECTOR_TYPE == 1
return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
#else
return computeNormalFromDepth(uv);
#endif
}
vec3 getSceneUvAndDepth(vec3 sampleViewPos) {
vec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);
vec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;
float sampleSceneDepth = getDepth(sampleUv);
return vec3(sampleUv, sampleSceneDepth);
}
void main() {
float depth = getDepth(vUv.xy);
if (depth >= 1.0) {
discard;
return;
}
vec3 viewPos = getViewPosition(vUv, depth);
vec3 viewNormal = getViewNormal(vUv);
float radiusToUse = radius;
float distanceFalloffToUse = thickness;
#if SCREEN_SPACE_RADIUS == 1
float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;
radiusToUse *= radiusScale;
distanceFalloffToUse *= radiusScale;
#endif
#if SCENE_CLIP_BOX == 1
vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;
float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));
if (boxDistance > radiusToUse) {
discard;
return;
}
#endif
vec2 noiseResolution = vec2(textureSize(tNoise, 0));
vec2 noiseUv = vUv * resolution / noiseResolution;
vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
vec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;
vec3 tangent = normalize(vec3(randomVec.xy, 0.));
vec3 bitangent = vec3(-tangent.y, tangent.x, 0.);
mat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));
const int DIRECTIONS = SAMPLES < 30 ? 3 : 5;
const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;
float ao = 0.0;
for (int i = 0; i < DIRECTIONS; ++i) {
float angle = float(i) / float(DIRECTIONS) * PI;
vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);
sampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);
vec3 viewDir = normalize(-viewPos.xyz);
vec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));
vec3 sliceTangent = cross(sliceBitangent, viewDir);
vec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));
vec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);
vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));
for (int j = 0; j < STEPS; ++j) {
vec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);
vec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);
vec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
vec3 viewDelta = sampleSceneViewPos - viewPos;
if (abs(viewDelta.z) < thickness) {
float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
cosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));
}
sampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);
sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
viewDelta = sampleSceneViewPos - viewPos;
if (abs(viewDelta.z) < thickness) {
float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
cosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));
}
}
vec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);
float nx = dot(normalInSlice, sliceTangent);
float ny = dot(normalInSlice, viewDir);
float nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);
float nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);
float occlusion = nx * nxb + ny * nyb;
ao += occlusion;
}
ao = clamp(ao / float(DIRECTIONS), 0., 1.);
#if SCENE_CLIP_BOX == 1
ao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));
#endif
ao = pow(ao, scale);
gl_FragColor = FRAGMENT_OUTPUT;
}`
)
}, zt = {
defines: {
PERSPECTIVE_CAMERA: 1
},
uniforms: {
tDepth: { value: null },
cameraNear: { value: null },
cameraFar: { value: null }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`
),
fragmentShader: (
/* glsl */
`
uniform sampler2D tDepth;
uniform float cameraNear;
uniform float cameraFar;
varying vec2 vUv;
#include <packing>
float getLinearDepth( const in vec2 screenPosition ) {
#if PERSPECTIVE_CAMERA == 1
float fragCoordZ = texture2D( tDepth, screenPosition ).x;
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
#else
return texture2D( tDepth, screenPosition ).x;
#endif
}
void main() {
float depth = getLinearDepth( vUv );
gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
}`
)
}, dn = {
uniforms: {
tDiffuse: { value: null },
intensity: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`
),
fragmentShader: (
/* glsl */
`
uniform float intensity;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
}`
)
};
function Dr(r = 5) {
const e = Math.floor(r) % 2 === 0 ? Math.floor(r) + 1 : Math.floor(r), t = Lr(e), n = t.length, i = new Uint8Array(n * 4);
for (let s = 0; s < n; ++s) {
const a = t[s], l = 2 * Math.PI * a / n, h = new pe(
Math.cos(l),
Math.sin(l),
0
).normalize();
i[s * 4] = (h.x * 0.5 + 0.5) * 255, i[s * 4 + 1] = (h.y * 0.5 + 0.5) * 255, i[s * 4 + 2] = 127, i[s * 4 + 3] = 255;
}
const o = new Ti(i, e, e);
return o.wrapS = it, o.wrapT = it, o.needsUpdate = !0, o;
}
function Lr(r) {
const e = Math.floor(r) % 2 === 0 ? Math.floor(r) + 1 : Math.floor(r), t = e * e, n = Array(t).fill(0);
let i = Math.floor(e / 2), o = e - 1;
for (let s = 1; s <= t; ) {
if (i === -1 && o === e ? (o = e - 2, i = 0) : (o === e && (o = 0), i < 0 && (i = e - 1)), n[i * e + o] !== 0) {
o -= 2, i++;
continue;
} else
n[i * e + o] = s++;
o++, i--;
}
return n;
}
const It = {
defines: {
SAMPLES: 16,
SAMPLE_VECTORS: Li(16, 2, 1),
NORMAL_VECTOR_TYPE: 1,
DEPTH_VALUE_SOURCE: 0
},
uniforms: {
tDiffuse: { value: null },
tNormal: { value: null },
tDepth: { value: null },
tNoise: { value: null },
resolution: { value: new de() },
cameraProjectionMatrixInverse: { value: new Xe() },
lumaPhi: { value: 5 },
depthPhi: { value: 5 },
normalPhi: { value: 5 },
radius: { value: 4 },
index: { value: 0 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`
),
fragmentShader: (
/* glsl */
`
varying vec2 vUv;
uniform sampler2D tDiffuse;
uniform sampler2D tNormal;
uniform sampler2D tDepth;
uniform sampler2D tNoise;
uniform vec2 resolution;
uniform mat4 cameraProjectionMatrixInverse;
uniform float lumaPhi;
uniform float depthPhi;
uniform float normalPhi;
uniform float radius;
uniform int index;
#include <common>
#include <packing>
#ifndef SAMPLE_LUMINANCE
#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)
#endif
#ifndef FRAGMENT_OUTPUT
#define FRAGMENT_OUTPUT vec4(denoised, 1.)
#endif
float getLuminance(const in vec3 a) {
return SAMPLE_LUMINANCE;
}
const vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;
vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
return viewSpacePosition.xyz / viewSpacePosition.w;
}
float getDepth(const vec2 uv) {
#if DEPTH_VALUE_SOURCE == 1
return textureLod(tDepth, uv.xy, 0.0).a;
#else
return textureLod(tDepth, uv.xy, 0.0).r;
#endif
}
float fetchDepth(const ivec2 uv) {
#if DEPTH_VALUE_SOURCE == 1
return texelFetch(tDepth, uv.xy, 0).a;
#else
return texelFetch(tDepth, uv.xy, 0).r;
#endif
}
vec3 computeNormalFromDepth(const vec2 uv) {
vec2 size = vec2(textureSize(tDepth, 0));
ivec2 p = ivec2(uv * size);
float c0 = fetchDepth(p);
float l2 = fetchDepth(p - ivec2(2, 0));
float l1 = fetchDepth(p - ivec2(1, 0));
float r1 = fetchDepth(p + ivec2(1, 0));
float r2 = fetchDepth(p + ivec2(2, 0));
float b2 = fetchDepth(p - ivec2(0, 2));
float b1 = fetchDepth(p - ivec2(0, 1));
float t1 = fetchDepth(p + ivec2(0, 1));
float t2 = fetchDepth(p + ivec2(0, 2));
float dl = abs((2.0 * l1 - l2) - c0);
float dr = abs((2.0 * r1 - r2) - c0);
float db = abs((2.0 * b1 - b2) - c0);
float dt = abs((2.0 * t1 - t2) - c0);
vec3 ce = getViewPosition(uv, c0).xyz;
vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz
: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz
: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
return normalize(cross(dpdx, dpdy));
}
vec3 getViewNormal(const vec2 uv) {
#if NORMAL_VECTOR_TYPE == 2
return normalize(textureLod(tNormal, uv, 0.).rgb);
#elif NORMAL_VECTOR_TYPE == 1
return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
#else
return computeNormalFromDepth(uv);
#endif
}
void denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {
vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);
float sampleDepth = getDepth(sampleUv);
vec3 sampleNormal = getViewNormal(sampleUv);
vec3 neighborColor = sampleTexel.rgb;
vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);
float normalDiff = dot(viewNormal, sampleNormal);
float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);
float lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));
float lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);
float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));
float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);
float w = lumaSimilarity * depthSimilarity * normalSimilarity;
denoised += w * neighborColor;
totalWeight += w;
}
void main() {
float depth = getDepth(vUv.xy);
vec3 viewNormal = getViewNormal(vUv);
if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {
discard;
return;
}
vec4 texel = textureLod(tDiffuse, vUv, 0.0);
vec3 center = texel.rgb;
vec3 viewPos = getViewPosition(vUv, depth);
vec2 noiseResolution = vec2(textureSize(tNoise, 0));
vec2 noiseUv = vUv * resolution / noiseResolution;
vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));
mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);
float totalWeight = 1.0;
vec3 denoised = texel.rgb;
for (int i = 0; i < SAMPLES; i++) {
vec3 sampleDir = poissonDisk[i];
vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);
vec2 sampleUv = vUv + offset;
denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);
}
if (totalWeight > 0.) {
denoised /= totalWeight;
}
gl_FragColor = FRAGMENT_OUTPUT;
}`
)
};
function Li(r, e, t) {
const n = Or(
r,
e,
t
);
let i = "vec3[SAMPLES](";
for (let o = 0; o < r; o++) {
const s = n[o];
i += `vec3(${s.x}, ${s.y}, ${s.z})${o < r - 1 ? "," : ")"}`;
}
return i;
}
function Or(r, e, t) {
const n = [];
for (let i = 0; i < r; i++) {
const o = 2 * Math.PI * e * i / r, s = Math.pow(i / (r - 1), t);
n.push(new pe(Math.cos(o), Math.sin(o), s));
}
return n;
}
class Nr {
/**
* Constructs a new simplex noise object.
*
* @param {Object} [r=Math] - A math utility class that holds a `random()` method. This makes it
* possible to pass in custom random number generator.
*/
constructor(e = Math) {
this.grad3 = [
[1, 1, 0],
[-1, 1, 0],
[1, -1, 0],
[-1, -1, 0],
[1, 0, 1],
[-1, 0, 1],
[1, 0, -1],
[-1, 0, -1],
[0, 1, 1],
[0, -1, 1],
[0, 1, -1],
[0, -1, -1]
], this.grad4 = [
[0, 1, 1, 1],
[0, 1, 1, -1],
[0, 1, -1, 1],
[0, 1, -1, -1],
[0, -1, 1, 1],
[0, -1, 1, -1],
[0, -1, -1, 1],
[0, -1, -1, -1],
[1, 0, 1, 1],
[1, 0, 1, -1],
[1, 0, -1, 1],
[1, 0, -1, -1],
[-1, 0, 1, 1],
[-1, 0, 1, -1],
[-1, 0, -1, 1],
[-1, 0, -1, -1],
[1, 1, 0, 1],
[1, 1, 0, -1],
[1, -1, 0, 1],
[1, -1, 0, -1],
[-1, 1, 0, 1],
[-1, 1, 0, -1],
[-1, -1, 0, 1],
[-1, -1, 0, -1],
[1, 1, 1, 0],
[1, 1, -1, 0],
[1, -1, 1, 0],
[1, -1, -1, 0],
[-1, 1, 1, 0],
[-1, 1, -1, 0],
[-1, -1, 1, 0],
[-1, -1, -1, 0]
], this.p = [];
for (let t = 0; t < 256; t++)
this.p[t] = Math.floor(e.random() * 256);
this.perm = [];
for (let t = 0; t < 512; t++)
this.perm[t] = this.p[t & 255];
this.simplex = [
[0, 1, 2, 3],
[0, 1, 3, 2],
[0, 0, 0, 0],
[0, 2, 3, 1],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 2, 3, 0],
[0, 2, 1, 3],
[0, 0, 0, 0],
[0, 3, 1, 2],
[0, 3, 2, 1],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 3, 2, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 2, 0, 3],
[0, 0, 0, 0],
[1, 3, 0, 2],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 3, 0, 1],
[2, 3, 1, 0],
[1, 0, 2, 3],
[1, 0, 3, 2],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 0, 3, 1],
[0, 0, 0, 0],
[2, 1, 3, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 0, 1, 3],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[3, 0, 1, 2],
[3, 0, 2, 1],
[0, 0, 0, 0],
[3, 1, 2, 0],
[2, 1, 0, 3],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[3, 1, 0, 2],
[0, 0, 0, 0],
[3, 2, 0, 1],
[3, 2, 1, 0]
];
}
/**
* A 2D simplex noise method.
*
* @param {number} xin - The x coordinate.
* @param {number} yin - The y coordinate.
* @return {number} The noise value.
*/
noise(e, t) {
let n, i, o;
const s = 0.5 * (Math.sqrt(3) - 1), a = (e + t) * s, l = Math.floor(e + a), h = Math.floor(t + a), u = (3 - Math.sqrt(3)) / 6, f = (l + h) * u, m = l - f, p = h - f, c = e - m, d = t - p;
let g, _;
c > d ? (g = 1, _ = 0) : (g = 0, _ = 1);
const w = c - g + u, b = d - _ + u, T = c - 1 + 2 * u, M = d - 1 + 2 * u, C = l & 255, P = h & 255, B = this.perm[C + this.perm[P]] % 12, R = this.perm[C + g + this.perm[P + _]] % 12, U = this.perm[C + 1 + this.perm[P + 1]] % 12;
let q = 0.5 - c * c - d * d;
q < 0 ? n = 0 : (q *= q, n = q * q * this._dot(this.grad3[B], c, d));
let A = 0.5 - w * w - b * b;
A < 0 ? i = 0 : (A *= A, i = A * A * this._dot(this.grad3[R], w, b));
let z = 0.5 - T * T - M * M;
return z < 0 ? o = 0 : (z *= z, o = z * z * this._dot(this.grad3[U], T, M)), 70 * (n + i + o);
}
/**
* A 3D simplex noise method.
*
* @param {number} xin - The x coordinate.
* @param {number} yin - The y coordinate.
* @param {number} zin - The z coordinate.
* @return {number} The noise value.
*/
noise3d(e, t, n) {
let i, o, s, a;
const h = (e + t + n) * 0.3333333333333333, u = Math.floor(e + h), f = Math.floor(t + h), m = Math.floor(n + h), p = 1 / 6, c = (u + f + m) * p, d = u - c, g = f - c, _ = m - c, w = e - d, b = t - g, T = n - _;
let M, C, P, B, R, U;
w >= b ? b >= T ? (M = 1, C = 0, P = 0, B = 1, R = 1, U = 0) : w >= T ? (M = 1, C = 0, P = 0, B = 1, R = 0, U = 1) : (M = 0, C = 0, P = 1, B = 1, R = 0, U = 1) : b < T ? (M = 0, C = 0, P = 1, B = 0, R = 1, U = 1) : w < T ? (M = 0, C = 1, P = 0, B = 0, R = 1, U = 1) : (M = 0, C = 1, P = 0, B = 1, R = 1, U = 0);
const q = w - M + p, A = b - C + p, z = T - P + p, x = w - B + 2 * p, F = b - R + 2 * p, J = T - U + 2 * p, G = w - 1 + 3 * p, ne = b - 1 + 3 * p, V = T - 1 + 3 * p, ee = u & 255, O = f & 255, D = m & 255, Q = this.perm[ee + this.perm[O + this.perm[D]]] % 12, Y = this.perm[ee + M + this.perm[O + C + this.perm[D + P]]] % 12, Z = this.perm[ee + B + this.perm[O + R + this.perm[D + U]]] % 12, ue = this.perm[ee + 1 + this.perm[O + 1 + this.perm[D + 1]]] % 12;
let fe = 0.6 - w * w - b * b - T * T;
fe < 0 ? i = 0 : (fe *= fe, i = fe * fe * this._dot3(this.grad3[Q], w, b, T));
let ie = 0.6 - q * q - A * A - z * z;
ie < 0 ? o = 0 : (ie *= ie, o = ie * ie * this._dot3(this.grad3[Y], q, A, z));
let oe = 0.6 - x * x - F * F - J * J;
oe < 0 ? s = 0 : (oe *= oe, s = oe * oe * this._dot3(this.grad3[Z], x, F, J));
let he = 0.6 - G * G - ne * ne - V * V;
return he < 0 ? a = 0 : (he *= he, a = he * he * this._dot3(this.grad3[ue], G, ne, V)), 32 * (i + o + s + a);
}
/**
* A 4D simplex noise method.
*
* @param {number} x - The x coordinate.
* @param {number} y - The y coordinate.
* @param {number} z - The z coordinate.
* @param {number} w - The w coordinate.
* @return {number} The noise value.
*/
noise4d(e, t, n, i) {
const o = this.grad4, s = this.simplex, a = this.perm, l = (Math.sqrt(5) - 1) / 4, h = (5 - Math.sqrt(5)) / 20;
let u, f, m, p, c;
const d = (e + t + n + i) * l, g = Math.floor(e + d), _ = Math.floor(t + d), w = Math.floor(n + d), b = Math.floor(i + d), T = (g + _ + w + b) * h, M = g - T, C = _ - T, P = w - T, B = b - T, R = e - M, U = t - C, q = n - P, A = i - B, z = R > U ? 32 : 0, x = R > q ? 16 : 0, F = U > q ? 8 : 0, J = R > A ? 4 : 0, G = U > A ? 2 : 0, ne = q > A ? 1 : 0, V = z + x + F + J + G + ne, ee = s[V][0] >= 3 ? 1 : 0, O = s[V][1] >= 3 ? 1 : 0, D = s[V][2] >= 3 ? 1 : 0, Q = s[V][3] >= 3 ? 1 : 0, Y = s[V][0] >= 2 ? 1 : 0, Z = s[V][1] >= 2 ? 1 : 0, ue = s[V][2] >= 2 ? 1 : 0, fe = s[V][3] >= 2 ? 1 : 0, ie = s[V][0] >= 1 ? 1 : 0, oe = s[V][1] >= 1 ? 1 : 0, he = s[V][2] >= 1 ? 1 : 0, me = s[V][3] >= 1 ? 1 : 0, Te = R - ee + h, ve = U - O + h, y = q - D + h, j = A - Q + h, I = R - Y + 2 * h, E = U - Z + 2 * h, S = q - ue + 2 * h, k = A - fe + 2 * h, H = R - ie + 3 * h, W = U - oe + 3 * h, L = q - he + 3 * h, K = A - me + 3 * h, $ = R - 1 + 4 * h, X = U - 1 + 4 * h, te = q - 1 + 4 * h, le = A - 1 + 4 * h, re = g & 255, we = _ & 255, Pe = w & 255, xe = b & 255, qe = a[re + a[we + a[Pe + a[xe]]]] % 32, ge = a[re + ee + a[we + O + a[Pe + D + a[xe + Q]]]] % 32, at = a[re + Y + a[we + Z + a[Pe + ue + a[xe + fe]]]] % 32, xt = a[re + ie + a[we + oe + a[Pe + he + a[xe + me]]]] % 32, Re = a[re + 1 + a[we + 1 + a[Pe + 1 + a[xe + 1]]]] % 32;
let Ge = 0.6 - R * R - U * U - q * q - A * A;
Ge < 0 ? u = 0 : (Ge *= Ge, u = Ge * Ge * this._dot4(o[qe], R, U, q, A));
let Ye = 0.6 - Te * Te - ve * ve - y * y - j * j;
Ye < 0 ? f = 0 : (Ye *= Ye, f = Ye * Ye * this._dot4(o[ge], Te, ve, y, j));
let $e = 0.6 - I * I - E * E - S * S - k * k;
$e < 0 ? m = 0 : ($e *= $e, m = $e * $e * this._dot4(o[at], I, E, S, k));
let Je = 0.6 - H * H - W * W - L * L - K * K;
Je < 0 ? p = 0 : (Je *= Je, p = Je * Je * this._dot4(o[xt], H, W, L, K));
let We = 0.6 - $ * $ - X * X - te * te - le * le;
return We < 0 ? c = 0 : (We *= We, c = We * We * this._dot4(o[Re], $, X, te, le)), 27 * (u + f + m + p + c);
}
// private
_dot(e, t, n) {
return e[0] * t + e[1] * n;
}
_dot3(e, t, n, i) {
return e[0] * t + e[1] * n + e[2] * i;
}
_dot4(e, t, n, i, o) {
return e[0] * t + e[1] * n + e[2] * i + e[3] * o;
}
}
class De extends ot {
/**
* Constructs a new GTAO pass.
*
* @param {Scene} scene - The scene to compute the AO for.
* @param {Camera} camera - The camera.
* @param {number} [width=512] - The width of the effect.
* @param {number} [height=512] - The height of the effect.
* @param {Object} [parameters] - The pass parameters.
* @param {Object} [aoParameters] - The AO parameters.
* @param {Object} [pdParameters] - The denoise parameters.
*/
constructor(e, t, n = 512, i = 512, o, s, a) {
super(), this.width = n, this.height = i, this.clear = !0, this.camera = t, this.scene = e, this.output = 0, this._renderGBuffer = !0, this._visibilityCache = [], this.blendIntensity = 1, this.pdRings = 2, this.pdRadiusExponent = 2, this.pdSamples = 16, this.gtaoNoiseTexture = Dr(), this.pdNoiseTexture = this._generateNoise(), this.gtaoRenderTarget = new ut(this.width, this.height, { type: dt }), this.pdRenderTarget = this.gtaoRenderTarget.clone(), this.gtaoMaterial = new Le({
defines: Object.assign({}, Nt.defines),
uniforms: Ve.clone(Nt.uniforms),
vertexShader: Nt.vertexShader,
fragmentShader: Nt.fragmentShader,
blending: je,
depthTest: !1,
depthWrite: !1
}), this.gtaoMaterial.defines.PERSPECTIVE_CAMERA = this.camera.isPerspectiveCamera ? 1 : 0, this.gtaoMaterial.uniforms.tNoise.value = this.gtaoNoiseTexture, this.gtaoMaterial.uniforms.resolution.value.set(this.width, this.height), this.gtaoMaterial.uniforms.cameraNear.value = this.camera.near, this.gtaoMaterial.uniforms.cameraFar.value = this.camera.far, this.normalMaterial = new fs(), this.normalMaterial.blending = je, this.pdMaterial = new Le({
defines: Object.assign({}, It.defines),
uniforms: Ve.clone(It.uniforms),
vertexShader: It.vertexShader,
fragmentShader: It.fragmentShader,
depthTest: !1,
depthWrite: !1
}), this.pdMaterial.uniforms.tDiffuse.value = this.gtaoRenderTarget.texture, this.pdMaterial.uniforms.tNoise.value = this.pdNoiseTexture, this.pdMaterial.uniforms.resolution.value.set(this.width, this.height), this.pdMaterial.uniforms.lumaPhi.value = 10, this.pdMaterial.uniforms.depthPhi.value = 2, this.pdMaterial.uniforms.normalPhi.value = 3, this.pdMaterial.uniforms.radius.value = 8, this.depthRenderMaterial = new Le({
defines: Object.assign({}, zt.defines),
uniforms: Ve.clone(zt.uniforms),
vertexShader: zt.vertexShader,
fragmentShader: zt.fragmentShader,
blending: je
}), this.depthRenderMaterial.uniforms.cameraNear.value = this.camera.near, this.depthRenderMaterial.uniforms.cameraFar.value = this.camera.far, this.copyMaterial = new Le({
uniforms: Ve.clone(tt.uniforms),
vertexShader: tt.vertexShader,
fragmentShader: tt.fragmentShader,
transparent: !0,
depthTest: !1,
depthWrite: !1,
blendSrc: Fn,
blendDst: Lt,
blendEquation: Dt,
blendSrcAlpha: Un,
blendDstAlpha: Lt,
blendEquationAlpha: Dt
}), this.blendMaterial = new Le({
uniforms: Ve.clone(dn.uniforms),
vertexShader: dn.vertexShader,
fragmentShader: dn.fragmentShader,
transparent: !0,
depthTest: !1,
depthWrite: !1,
blending: ps,
blendSrc: Fn,
blendDst: Lt,
blendEquation: Dt,
blendSrcAlpha: Un,
blendDstAlpha: Lt,
blendEquationAlpha: Dt
}), this._fsQuad = new nn(null), this._originalClearColor = new Ce(), this.setGBuffer(o ? o.depthTexture : void 0, o ? o.normalTexture : void 0), s !== void 0 && this.updateGtaoMaterial(s), a !== void 0 && this.updatePdMaterial(a);
}
/**
* Sets the size of the pass.
*
* @param {number} width - The width to set.
* @param {number} height - The height to set.
*/
setSize(e, t) {
this.width = e, this.height = t, this.gtaoRenderTarget.setSize(e, t), this.normalRenderTarget.setSize(e, t), this.pdRenderTarget.setSize(e, t), this.gtaoMaterial.uniforms.resolution.value.set(e, t), this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix), this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse), this.pdMaterial.uniforms.resolution.value.set(e, t), this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse);
}
/**
* Frees the GPU-related resources allocated by this instance. Call this
* method whenever the pass is no longer used in your app.
*/
dispose() {
this.gtaoNoiseTexture.dispose(), this.pdNoiseTexture.dispose(), this.normalRenderTarget.dispose(), this.gtaoRenderTarget.dispose(), this.pdRenderTarget.dispose(), this.normalMaterial.dispose(), this.pdMaterial.dispose(), this.copyMaterial.dispose(), this.depthRenderMaterial.dispose(), this._fsQuad.dispose();
}
/**
* A texture holding the computed AO.
*
* @type {Texture}
* @readonly
*/
get gtaoMap() {
return this.pdRenderTarget.texture;
}
/**
* Configures the GBuffer of this pass. If no arguments are passed,
* the pass creates an internal render target for holding depth
* and normal data.
*
* @param {DepthTexture} [depthTexture] - The depth texture.
* @param {DepthTexture} [normalTexture] - The normal texture.
*/
setGBuffer(e, t) {
e !== void 0 ? (this.depthTexture = e, this.normalTexture = t, this._renderGBuffer = !1) : (this.depthTexture = new ms(), this.depthTexture.format = gs, this.depthTexture.type = _s, this.normalRenderTarget = new ut(this.width, this.height, {
minFilter: $t,
magFilter: $t,
type: dt,
depthTexture: this.depthTexture
}), this.normalTexture = this.normalRenderTarget.texture, this._renderGBuffer = !0);
const n = this.normalTexture ? 1 : 0, i = this.depthTexture === this.normalTexture ? "w" : "x";
this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE = n, this.gtaoMaterial.defines.DEPTH_SWIZZLING = i, this.gtaoMaterial.uniforms.tNormal.value = this.normalTexture, this.gtaoMaterial.uniforms.tDepth.value = this.depthTexture, this.pdMaterial.defines.NORMAL_VECTOR_TYPE = n, this.pdMaterial.defines.DEPTH_SWIZZLING = i, this.pdMaterial.uniforms.tNormal.value = this.normalTexture, this.pdMaterial.uniforms.tDepth.value = this.depthTexture, this.depthRenderMaterial.uniforms.tDepth.value = this.normalRenderTarget.depthTexture;
}
/**
* Configures the clip box of the GTAO shader with the given AABB.
*
* @param {?Box3} box - The AABB enclosing the scene that should receive AO. When passing
* `null`, to clip box is used.
*/
setSceneClipBox(e) {
e ? (this.gtaoMaterial.needsUpdate = this.gtaoMaterial.defines.SCENE_CLIP_BOX !== 1, this.gtaoMaterial.defines.SCENE_CLIP_BOX = 1, this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min), this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)) : (this.gtaoMaterial.needsUpdate = this.gtaoMaterial.defines.SCENE_CLIP_BOX === 0, this.gtaoMaterial.defines.SCENE_CLIP_BOX = 0);
}
/**
* Updates the GTAO material from the given parameter object.
*
* @param {Object} parameters - The GTAO material parameters.
*/
updateGtaoMaterial(e) {
e.radius !== void 0 && (this.gtaoMaterial.uniforms.radius.value = e.radius), e.distanceExponent !== void 0 && (this.gtaoMaterial.uniforms.distanceExponent.value = e.distanceExponent), e.thickness !== void 0 && (this.gtaoMaterial.uniforms.thickness.value = e.thickness), e.distanceFallOff !== void 0 && (this.gtaoMaterial.uniforms.distanceFallOff.value = e.distanceFallOff, this.gtaoMaterial.needsUpdate = !0), e.scale !== void 0 && (this.gtaoMaterial.uniforms.scale.value = e.scale), e.samples !== void 0 && e.samples !== this.gtaoMaterial.defines.SAMPLES && (this.gtaoMaterial.defines.SAMPLES = e.samples, this.gtaoMaterial.needsUpdate = !0), e.screenSpaceRadius !== void 0 && (e.screenSpaceRadius ? 1 : 0) !== this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS && (this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS = e.screenSpaceRadius ? 1 : 0, this.gtaoMaterial.needsUpdate = !0);
}
/**
* Updates the Denoise material from the given parameter object.
*
* @param {Object} parameters - The denoise parameters.
*/
updatePdMaterial(e) {
let t = !1;
e.lumaPhi !== void 0 && (this.pdMaterial.uniforms.lumaPhi.value = e.lumaPhi), e.depthPhi !== void 0 && (this.pdMaterial.uniforms.depthPhi.value = e.depthPhi), e.normalPhi !== void 0 && (this.pdMaterial.uniforms.normalPhi.value = e.normalPhi), e.radius !== void 0 && e.radius !== this.radius && (this.pdMaterial.uniforms.radius.value = e.radius), e.radiusExponent !== void 0 && e.radiusExponent !== this.pdRadiusExponent && (this.pdRadiusExponent = e.radiusExponent, t = !0), e.rings !== void 0 && e.rings !== this.pdRings && (this.pdRings = e.rings, t = !0), e.samples !== void 0 && e.samples !== this.pdSamples && (this.pdSamples = e.samples, t = !0), t && (this.pdMaterial.defines.SAMPLES = this.pdSamples, this.pdMaterial.defines.SAMPLE_VECTORS = Li(this.pdSamples, this.pdRings, this.pdRadiusExponent), this.pdMaterial.needsUpdate = !0);
}
/**
* Performs the GTAO pass.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
* destination for the pass.
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
* previous pass from this buffer.
* @param {number} deltaTime - The delta time in seconds.
* @param {boolean} maskActive - Whether masking is active or not.
*/
render(e, t, n) {
switch (this._renderGBuffer && (this._overrideVisibility(), this._renderOverride(e, this.normalMaterial, this.normalRenderTarget, 7829503, 1), this._restoreVisibility()), this.gtaoMaterial.uniforms.cameraNear.value = this.camera.near, this.gtaoMaterial.uniforms.cameraFar.value = this.camera.far, this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix), this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse), this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld), this._renderPass(e, this.gtaoMaterial, this.gtaoRenderTarget, 16777215, 1), this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse), this._renderPass(e, this.pdMaterial, this.pdRenderTarget, 16777215, 1), this.output) {
case De.OUTPUT.Off:
break;
case De.OUTPUT.Diffuse:
this.copyMaterial.uniforms.tDiffuse.value = n.texture, this.copyMaterial.blending = je, this._renderPass(e, this.copyMaterial, this.renderToScreen ? null : t);
break;
case De.OUTPUT.AO:
this.copyMaterial.uniforms.tDiffuse.value = this.gtaoRenderTarget.texture, this.copyMaterial.blending = je, this._renderPass(e, this.copyMaterial, this.renderToScreen ? null : t);
break;
case De.OUTPUT.Denoise:
this.copyMaterial.uniforms.tDiffuse.value = this.pdRenderTarget.texture, this.copyMaterial.blending = je, this._renderPass(e, this.copyMaterial, this.renderToScreen ? null : t);
break;
case De.OUTPUT.Depth:
this.depthRenderMaterial.uniforms.cameraNear.value = this.camera.near, this.depthRenderMaterial.uniforms.cameraFar.value = this.camera.far, this._renderPass(e, this.depthRenderMaterial, this.renderToScreen ? null : t);
break;
case De.OUTPUT.Normal:
this.copyMaterial.uniforms.tDiffuse.value = this.normalRenderTarget.texture, this.copyMaterial.blending = je, this._renderPass(e, this.copyMaterial, this.renderToScreen ? null : t);
break;
case De.OUTPUT.Default:
this.copyMaterial.uniforms.tDiffuse.value = n.texture, this.copyMaterial.blending = je, this._renderPass(e, this.copyMaterial, this.renderToScreen ? null : t), this.blendMaterial.uniforms.intensity.value = this.blendIntensity, this.blendMaterial.uniforms.tDiffuse.value = this.pdRenderTarget.texture, this._renderPass(e, this.blendMaterial, this.renderToScreen ? null : t);
break;
default:
console.warn("THREE.GTAOPass: Unknown output type.");
}
}
// internals
_renderPass(e, t, n, i, o) {
e.getClearColor(this._originalClearColor);
const s = e.getClearAlpha(), a = e.autoClear;
e.setRenderTarget(n), e.autoClear = !1, i != null && (e.setClearColor(i), e.setClearAlpha(o || 0), e.clear()), this._fsQuad.material = t, this._fsQuad.render(e), e.autoClear = a, e.setClearColor(this._originalClearColor), e.setClearAlpha(s);
}
_renderOverride(e, t, n, i, o) {
e.getClearColor(this._originalClearColor);
const s = e.getClearAlpha(), a = e.autoClear;
e.setRenderTarget(n), e.autoClear = !1, i = t.clearColor || i, o = t.clearAlpha || o, i != null && (e.setClearColor(i), e.setClearAlpha(o || 0), e.clear()), this.scene.overrideMaterial = t, e.render(this.scene, this.camera), this.scene.overrideMaterial = null, e.autoClear = a, e.setClearColor(this._originalClearColor), e.setClearAlpha(s);
}
_overrideVisibility() {
const e = this.scene, t = this._visibilityCache;
e.traverse(function(n) {
(n.isPoints || n.isLine || n.isLine2) && n.visible && (n.visible = !1, t.push(n));
});
}
_restoreVisibility() {
const e = this._visibilityCache;
for (let t = 0; t < e.length; t++)
e[t].visible = !0;
e.length = 0;
}
_generateNoise(e = 64) {
const t = new Nr(), n = e * e * 4, i = new Uint8Array(n);
for (let s = 0; s < e; s++)
for (let a = 0; a < e; a++) {
const l = s, h = a;
i[(s * e + a) * 4] = (t.noise(l, h) * 0.5 + 0.5) * 255, i[(s * e + a) * 4 + 1] = (t.noise(l + e, h) * 0.5 + 0.5) * 255, i[(s * e + a) * 4 + 2] = (t.noise(l, h + e) * 0.5 + 0.5) * 255, i[(s * e + a) * 4 + 3] = (t.noise(l + e, h + e) * 0.5 + 0.5) * 255;
}
const o = new Ti(i, e, e, ys, ws);
return o.wrapS = it, o.wrapT = it, o.needsUpdate = !0, o;
}
}
De.OUTPUT = {
Off: -1,
Default: 0,
Diffuse: 1,
Depth: 2,
Normal: 3,
AO: 4,
Denoise: 5
};
const zr = {
uniforms: {
tDiffuse: { value: null },
luminosityThreshold: { value: 1 },
smoothWidth: { value: 1 },
defaultColor: { value: new Ce(0) },
defaultOpacity: { value: 0 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`
),
fragmentShader: (
/* glsl */
`
uniform sampler2D tDiffuse;
uniform vec3 defaultColor;
uniform float defaultOpacity;
uniform float luminosityThreshold;
uniform float smoothWidth;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
float v = luminance( texel.xyz );
vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
gl_FragColor = mix( outputColor, texel, alpha );
}`
)
};
class gt extends ot {
/**
* Constructs a new Unreal Bloom pass.
*
* @param {Vector2} [resolution] - The effect's resolution.
* @param {number} [strength=1] - The Bloom strength.
* @param {number} radius - The Bloom radius.
* @param {number} threshold - The luminance threshold limits which bright areas contribute to the Bloom effect.
*/
constructor(e, t = 1, n, i) {
super(), this.strength = t, this.radius = n, this.threshold = i, this.resolution = e !== void 0 ? new de(e.x, e.y) : new de(256, 256), this.clearColor = new Ce(0, 0, 0), this.needsSwap = !1, this.renderTargetsHorizontal = [], this.renderTargetsVertical = [], this.nMips = 5;
let o = Math.round(this.resolution.x / 2), s = Math.round(this.resolution.y / 2);
this.renderTargetBright = new ut(o, s, { type: dt }), this.renderTargetBright.texture.name = "UnrealBloomPass.bright", this.renderTargetBright.texture.generateMipmaps = !1;
for (let u = 0; u < this.nMips; u++) {
const f = new ut(o, s, { type: dt });
f.texture.name = "UnrealBloomPass.h" + u, f.texture.generateMipmaps = !1, this.renderTargetsHorizontal.push(f);
const m = new ut(o, s, { type: dt });
m.texture.name = "UnrealBloomPass.v" + u, m.texture.generateMipmaps = !1, this.renderTargetsVertical.push(m), o = Math.round(o / 2), s = Math.round(s / 2);
}
const a = zr;
this.highPassUniforms = Ve.clone(a.uniforms), this.highPassUniforms.luminosityThreshold.value = i, this.highPassUniforms.smoothWidth.value = 0.01, this.materialHighPassFilter = new Le({
uniforms: this.highPassUniforms,
vertexShader: a.vertexShader,
fragmentShader: a.fragmentShader
}), this.separableBlurMaterials = [];
const l = [6, 10, 14, 18, 22];
o = Math.round(this.resolution.x / 2), s = Math.round(this.resolution.y / 2);
for (let u = 0; u < this.nMips; u++)
this.separableBlurMaterials.push(this._getSeparableBlurMaterial(l[u])), this.separableBlurMaterials[u].uniforms.invSize.value = new de(1 / o, 1 / s), o = Math.round(o / 2), s = Math.round(s / 2);
this.compositeMaterial = this._getCompositeMaterial(this.nMips), this.compositeMaterial.uniforms.blurTexture1.value = this.renderTargetsVertical[0].texture, this.compositeMaterial.uniforms.blurTexture2.value = this.renderTargetsVertical[1].texture, this.compositeMaterial.uniforms.blurTexture3.value = this.renderTargetsVertical[2].texture, this.compositeMaterial.uniforms.blurTexture4.value = this.renderTargetsVertical[3].texture, this.compositeMaterial.uniforms.blurTexture5.value = this.renderTargetsVertical[4].texture, this.compositeMaterial.uniforms.bloomStrength.value = t, this.compositeMaterial.uniforms.bloomRadius.value = 0.1;
const h = [1, 0.8, 0.6, 0.4, 0.2];
this.compositeMaterial.uniforms.bloomFactors.value = h, this.bloomTintColors = [new pe(1, 1, 1), new pe(1, 1, 1), new pe(1, 1, 1), new pe(1, 1, 1), new pe(1, 1, 1)], this.compositeMaterial.uniforms.bloomTintColors.value = this.bloomTintColors, this.copyUniforms = Ve.clone(tt.uniforms), this.blendMaterial = new Le({
uniforms: this.copyUniforms,
vertexShader: tt.vertexShader,
fragmentShader: tt.fragmentShader,
blending: xs,
depthTest: !1,
depthWrite: !1,
transparent: !0
}), this._oldClearColor = new Ce(), this._oldClearAlpha = 1, this._basic = new ct(), this._fsQuad = new nn(null);
}
/**
* Frees the GPU-related resources allocated by this instance. Call this
* method whenever the pass is no longer used in your app.
*/
dispose() {
for (let e = 0; e < this.renderTargetsHorizontal.length; e++)
this.renderTargetsHorizontal[e].dispose();
for (let e = 0; e < this.renderTargetsVertical.length; e++)
this.renderTargetsVertical[e].dispose();
this.renderTargetBright.dispose();
for (let e = 0; e < this.separableBlurMaterials.length; e++)
this.separableBlurMaterials[e].dispose();
this.compositeMaterial.dispose(), this.blendMaterial.dispose(), this._basic.dispose(), this._fsQuad.dispose();
}
/**
* Sets the size of the pass.
*
* @param {number} width - The width to set.
* @param {number} height - The height to set.
*/
setSize(e, t) {
let n = Math.round(e / 2), i = Math.round(t / 2);
this.renderTargetBright.setSize(n, i);
for (let o = 0; o < this.nMips; o++)
this.renderTargetsHorizontal[o].setSize(n, i), this.renderTargetsVertical[o].setSize(n, i), this.separableBlurMaterials[o].uniforms.invSize.value = new de(1 / n, 1 / i), n = Math.round(n / 2), i = Math.round(i / 2);
}
/**
* Performs the Bloom pass.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
* destination for the pass.
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
* previous pass from this buffer.
* @param {number} deltaTime - The delta time in seconds.
* @param {boolean} maskActive - Whether masking is active or not.
*/
render(e, t, n, i, o) {
e.getClearColor(this._oldClearColor), this._oldClearAlpha = e.getClearAlpha();
const s = e.autoClear;
e.autoClear = !1, e.setClearColor(this.clearColor, 0), o && e.state.buffers.stencil.setTest(!1), this.renderToScreen && (this._fsQuad.material = this._basic, this._basic.map = n.texture, e.setRenderTarget(null), e.clear(), this._fsQuad.render(e)), this.highPassUniforms.tDiffuse.value = n.texture, this.highPassUniforms.luminosityThreshold.value = this.threshold, this._fsQuad.material = this.materialHighPassFilter, e.setRenderTarget(this.renderTargetBright), e.clear(), this._fsQuad.render(e);
let a = this.renderTargetBright;
for (let l = 0; l < this.nMips; l++)
this._fsQuad.material = this.separableBlurMaterials[l], this.separableBlurMaterials[l].uniforms.colorTexture.value = a.texture, this.separableBlurMaterials[l].uniforms.direction.value = gt.BlurDirectionX, e.setRenderTarget(this.renderTargetsHorizontal[l]), e.clear(), this._fsQuad.render(e), this.separableBlurMaterials[l].uniforms.colorTexture.value = this.renderTargetsHorizontal[l].texture, this.separableBlurMaterials[l].uniforms.direction.value = gt.BlurDirectionY, e.setRenderTarget(this.renderTargetsVertical[l]), e.clear(), this._fsQuad.render(e), a = this.renderTargetsVertical[l];
this._fsQuad.material = this.compositeMaterial, this.compositeMaterial.uniforms.bloomStrength.value = this.strength, this.compositeMaterial.uniforms.bloomRadius.value = this.radius, this.compositeMaterial.uniforms.bloomTintColors.value = this.bloomTintColors, e.setRenderTarget(this.renderTargetsHorizontal[0]), e.clear(), this._fsQuad.render(e), this._fsQuad.material = this.blendMaterial, this.copyUniforms.tDiffuse.value = this.renderTargetsHorizontal[0].texture, o && e.state.buffers.stencil.setTest(!0), this.renderToScreen ? (e.setRenderTarget(null), this._fsQuad.render(e)) : (e.setRenderTarget(n), this._fsQuad.render(e)), e.setClearColor(this._oldClearColor, this._oldClearAlpha), e.autoClear = s;
}
// internals
_getSeparableBlurMaterial(e) {
const t = [], n = e / 3;
for (let i = 0; i < e; i++)
t.push(0.39894 * Math.exp(-0.5 * i * i / (n * n)) / n);
return new Le({
defines: {
KERNEL_RADIUS: e
},
uniforms: {
colorTexture: { value: null },
invSize: { value: new de(0.5, 0.5) },
// inverse texture size
direction: { value: new de(0.5, 0.5) },
gaussianCoefficients: { value: t }
// precomputed Gaussian coefficients
},
vertexShader: `varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,
fragmentShader: `#include <common>
varying vec2 vUv;
uniform sampler2D colorTexture;
uniform vec2 invSize;
uniform vec2 direction;
uniform float gaussianCoefficients[KERNEL_RADIUS];
void main() {
float weightSum = gaussianCoefficients[0];
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
float x = float(i);
float w = gaussianCoefficients[i];
vec2 uvOffset = direction * invSize * x;
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
diffuseSum += ( sample1 + sample2 ) * w;
}
gl_FragColor = vec4( diffuseSum, 1.0 );
}`
});
}
_getCompositeMaterial(e) {
return new Le({
defines: {
NUM_MIPS: e
},
uniforms: {
blurTexture1: { value: null },
blurTexture2: { value: null },
blurTexture3: { value: null },
blurTexture4: { value: null },
blurTexture5: { value: null },
bloomStrength: { value: 1 },
bloomFactors: { value: null },
bloomTintColors: { value: null },
bloomRadius: { value: 0 }
},
vertexShader: `varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,
fragmentShader: `varying vec2 vUv;
uniform sampler2D blurTexture1;
uniform sampler2D blurTexture2;
uniform sampler2D blurTexture3;
uniform sampler2D blurTexture4;
uniform sampler2D blurTexture5;
uniform float bloomStrength;
uniform float bloomRadius;
uniform float bloomFactors[NUM_MIPS];
uniform vec3 bloomTintColors[NUM_MIPS];
float lerpBloomFactor(const in float factor) {
float mirrorFactor = 1.2 - factor;
return mix(factor, mirrorFactor, bloomRadius);
}
void main() {
gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
}`
});
}
}
gt.BlurDirectionX = new de(1, 0);
gt.BlurDirectionY = new de(0, 1);
const Bt = {
name: "OutputShader",
uniforms: {
tDiffuse: { value: null },
toneMappingExposure: { value: 1 }
},
vertexShader: (
/* glsl */
`
precision highp float;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute vec2 uv;
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`
),
fragmentShader: (
/* glsl */
`
precision highp float;
uniform sampler2D tDiffuse;
#include <tonemapping_pars_fragment>
#include <colorspace_pars_fragment>
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
// tone mapping
#ifdef LINEAR_TONE_MAPPING
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
#elif defined( REINHARD_TONE_MAPPING )
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
#elif defined( CINEON_TONE_MAPPING )
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
#elif defined( ACES_FILMIC_TONE_MAPPING )
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
#elif defined( AGX_TONE_MAPPING )
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
#elif defined( NEUTRAL_TONE_MAPPING )
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
#elif defined( CUSTOM_TONE_MAPPING )
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
#endif
// color space
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
}`
)
};
class Ir extends ot {
/**
* Constructs a new output pass.
*/
constructor() {
super(), this.uniforms = Ve.clone(Bt.uniforms), this.material = new bs({
name: Bt.name,
uniforms: this.uniforms,
vertexShader: Bt.vertexShader,
fragmentShader: Bt.fragmentShader
}), this._fsQuad = new nn(this.material), this._outputColorSpace = null, this._toneMapping = null;
}
/**
* Performs the output pass.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
* destination for the pass.
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
* previous pass from this buffer.
* @param {number} deltaTime - The delta time in seconds.
* @param {boolean} maskActive - Whether masking is active or not.
*/
render(e, t, n) {
this.uniforms.tDiffuse.value = n.texture, this.uniforms.toneMappingExposure.value = e.toneMappingExposure, (this._outputColorSpace !== e.outputColorSpace || this._toneMapping !== e.toneMapping) && (this._outputColorSpace = e.outputColorSpace, this._toneMapping = e.toneMapping, this.material.defines = {}, Jt.getTransfer(this._outputColorSpace) === vs && (this.material.defines.SRGB_TRANSFER = ""), this._toneMapping === Ts ? this.material.defines.LINEAR_TONE_MAPPING = "" : this._toneMapping === Ss ? this.material.defines.REINHARD_TONE_MAPPING = "" : this._toneMapping === Es ? this.material.defines.CINEON_TONE_MAPPING = "" : this._toneMapping === Ms ? this.material.defines.ACES_FILMIC_TONE_MAPPING = "" : this._toneMapping === As ? this.material.defines.AGX_TONE_MAPPING = "" : this._toneMapping === Cs ? this.material.defines.NEUTRAL_TONE_MAPPING = "" : this._toneMapping === ks && (this.material.defines.CUSTOM_TONE_MAPPING = ""), this.material.needsUpdate = !0), this.renderToScreen === !0 ? (e.setRenderTarget(null), this._fsQuad.render(e)) : (e.setRenderTarget(t), this.clear && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), this._fsQuad.render(e));
}
/**
* Frees the GPU-related resources allocated by this instance. Call this
* method whenever the pass is no longer used in your app.
*/
dispose() {
this.material.dispose(), this._fsQuad.dispose();
}
}
const Br = {
name: "FXAAShader",
uniforms: {
tDiffuse: { value: null },
resolution: { value: new de(1 / 1024, 1 / 512) }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`
),
fragmentShader: (
/* glsl */
`
uniform sampler2D tDiffuse;
uniform vec2 resolution;
varying vec2 vUv;
#define EDGE_STEP_COUNT 6
#define EDGE_GUESS 8.0
#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0
const float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );
float _ContrastThreshold = 0.0312;
float _RelativeThreshold = 0.063;
float _SubpixelBlending = 1.0;
vec4 Sample( sampler2D tex2D, vec2 uv ) {
return texture( tex2D, uv );
}
float SampleLuminance( sampler2D tex2D, vec2 uv ) {
return dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );
}
float SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {
uv += texSize * vec2(uOffset, vOffset);
return SampleLuminance(tex2D, uv);
}
struct LuminanceData {
float m, n, e, s, w;
float ne, nw, se, sw;
float highest, lowest, contrast;
};
LuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {
LuminanceData l;
l.m = SampleLuminance( tex2D, uv );
l.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );
l.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );
l.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );
l.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );
l.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );
l.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );
l.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );
l.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );
l.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );
l.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );
l.contrast = l.highest - l.lowest;
return l;
}
bool ShouldSkipPixel( LuminanceData l ) {
float threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );
return l.contrast < threshold;
}
float DeterminePixelBlendFactor( LuminanceData l ) {
float f = 2.0 * ( l.n + l.e + l.s + l.w );
f += l.ne + l.nw + l.se + l.sw;
f *= 1.0 / 12.0;
f = abs( f - l.m );
f = clamp( f / l.contrast, 0.0, 1.0 );
float blendFactor = smoothstep( 0.0, 1.0, f );
return blendFactor * blendFactor * _SubpixelBlending;
}
struct EdgeData {
bool isHorizontal;
float pixelStep;
float oppositeLuminance, gradient;
};
EdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {
EdgeData e;
float horizontal =
abs( l.n + l.s - 2.0 * l.m ) * 2.0 +
abs( l.ne + l.se - 2.0 * l.e ) +
abs( l.nw + l.sw - 2.0 * l.w );
float vertical =
abs( l.e + l.w - 2.0 * l.m ) * 2.0 +
abs( l.ne + l.nw - 2.0 * l.n ) +
abs( l.se + l.sw - 2.0 * l.s );
e.isHorizontal = horizontal >= vertical;
float pLuminance = e.isHorizontal ? l.n : l.e;
float nLuminance = e.isHorizontal ? l.s : l.w;
float pGradient = abs( pLuminance - l.m );
float nGradient = abs( nLuminance - l.m );
e.pixelStep = e.isHorizontal ? texSize.y : texSize.x;
if (pGradient < nGradient) {
e.pixelStep = -e.pixelStep;
e.oppositeLuminance = nLuminance;
e.gradient = nGradient;
} else {
e.oppositeLuminance = pLuminance;
e.gradient = pGradient;
}
return e;
}
float DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {
vec2 uvEdge = uv;
vec2 edgeStep;
if (e.isHorizontal) {
uvEdge.y += e.pixelStep * 0.5;
edgeStep = vec2( texSize.x, 0.0 );
} else {
uvEdge.x += e.pixelStep * 0.5;
edgeStep = vec2( 0.0, texSize.y );
}
float edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;
float gradientThreshold = e.gradient * 0.25;
vec2 puv = uvEdge + edgeStep * edgeSteps[0];
float pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
bool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
for ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {
puv += edgeStep * edgeSteps[i];
pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
}
if ( !pAtEnd ) {
puv += edgeStep * EDGE_GUESS;
}
vec2 nuv = uvEdge - edgeStep * edgeSteps[0];
float nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
bool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
for ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {
nuv -= edgeStep * edgeSteps[i];
nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
}
if ( !nAtEnd ) {
nuv -= edgeStep * EDGE_GUESS;
}
float pDistance, nDistance;
if ( e.isHorizontal ) {
pDistance = puv.x - uv.x;
nDistance = uv.x - nuv.x;
} else {
pDistance = puv.y - uv.y;
nDistance = uv.y - nuv.y;
}
float shortestDistance;
bool deltaSign;
if ( pDistance <= nDistance ) {
shortestDistance = pDistance;
deltaSign = pLuminanceDelta >= 0.0;
} else {
shortestDistance = nDistance;
deltaSign = nLuminanceDelta >= 0.0;
}
if ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {
return 0.0;
}
return 0.5 - shortestDistance / ( pDistance + nDistance );
}
vec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {
LuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );
if ( ShouldSkipPixel( luminance ) ) {
return Sample( tex2D, uv );
}
float pixelBlend = DeterminePixelBlendFactor( luminance );
EdgeData edge = DetermineEdge( texSize, luminance );
float edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );
float finalBlend = max( pixelBlend, edgeBlend );
if (edge.isHorizontal) {
uv.y += edge.pixelStep * finalBlend;
} else {
uv.x += edge.pixelStep * finalBlend;
}
return Sample( tex2D, uv );
}
void main() {
gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
}`
)
}, Ur = {
uniforms: {
tDiffuse: { value: null },
saturation: { value: 1.2 },
// 饱和度值1.0为原始大于1.0增加饱和度
contrast: { value: 1.2 }
// 对比度值1.0为原始大于1.0增加对比度
},
vertexShader: `
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
uniform sampler2D tDiffuse;
uniform float saturation;
uniform float contrast;
varying vec2 vUv;
void main() {
vec4 color = texture2D(tDiffuse, vUv);
// 转换为灰度值用于饱和度调整
float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
// 混合原始颜色和灰度值来调整饱和度
color.rgb = mix(vec3(gray), color.rgb, saturation);
// 调整对比度
color.rgb = (color.rgb - 0.5) * contrast + 0.5;
gl_FragColor = color;
}
`
};
class Fr {
engine;
composer;
saturationPass;
constructor(e) {
this.engine = e;
}
resize() {
const { width: e, height: t } = this.engine.deviceModule.getContainerSize(), n = e / t;
if (this.composer) {
this.composer.setPixelRatio(n), this.composer.setSize(e, t);
const i = this.composer.passes.find((o) => o instanceof Wt && o.material.uniforms.resolution);
i && (i.material.uniforms.resolution.value.x = 1 / (e * n), i.material.uniforms.resolution.value.y = 1 / (t * n));
}
}
init() {
const { width: e, height: t } = this.engine.deviceModule.getContainerSize(), n = this.engine.scene, i = this.engine.camera, o = this.engine.renderer, s = e / t;
this.composer = new Pr(o), this.composer.setPixelRatio(s), this.composer.setSize(e, t);
const a = new Rr(n, i);
this.composer.addPass(a);
const l = new De(n, i, e, t);
l.output = De.OUTPUT.Default, l.blendIntensity = 0.5, l.updateGtaoMaterial && l.updateGtaoMaterial({
radius: 1,
// 减小半径以获得更紧密、更逼真的接触阴影 (原为 10)
distanceExponent: 1,
// 衰减
thickness: 1,
// 厚度
scale: 1,
// 缩放
distanceFallOff: 1,
// 距离衰减
screenSpaceRadius: !0
}), new gt(
new v.Vector2(e, t),
0.1,
// 强度
0.1,
// 半径
0.5
// 阈值
), this.saturationPass = new Wt(Ur), this.saturationPass.uniforms.saturation.value = 1.3, this.saturationPass.uniforms.contrast.value = 1.1, this.composer.addPass(this.saturationPass);
const h = new Ir();
this.composer.addPass(h);
const u = new Wt(Br);
u.material.uniforms.resolution.value.x = 1 / (e * s), u.material.uniforms.resolution.value.y = 1 / (t * s), this.composer.addPass(u);
}
}
var Ut = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Oi(r) {
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
}
function Ft(r) {
throw new Error('Could not dynamically require "' + r + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var fn = { exports: {} };
var qn;
function jr() {
return qn || (qn = 1, (function(r, e) {
(function(t) {
r.exports = t();
})(function() {
return (function t(n, i, o) {
function s(h, u) {
if (!i[h]) {
if (!n[h]) {
var f = typeof Ft == "function" && Ft;
if (!u && f) return f(h, !0);
if (a) return a(h, !0);
var m = new Error("Cannot find module '" + h + "'");
throw m.code = "MODULE_NOT_FOUND", m;
}
var p = i[h] = { exports: {} };
n[h][0].call(p.exports, function(c) {
var d = n[h][1][c];
return s(d || c);
}, p, p.exports, t, n, i, o);
}
return i[h].exports;
}
for (var a = typeof Ft == "function" && Ft, l = 0; l < o.length; l++) s(o[l]);
return s;
})({ 1: [function(t, n, i) {
var o = t("./utils"), s = t("./support"), a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
i.encode = function(l) {
for (var h, u, f, m, p, c, d, g = [], _ = 0, w = l.length, b = w, T = o.getTypeOf(l) !== "string"; _ < l.length; ) b = w - _, f = T ? (h = l[_++], u = _ < w ? l[_++] : 0, _ < w ? l[_++] : 0) : (h = l.charCodeAt(_++), u = _ < w ? l.charCodeAt(_++) : 0, _ < w ? l.charCodeAt(_++) : 0), m = h >> 2, p = (3 & h) << 4 | u >> 4, c = 1 < b ? (15 & u) << 2 | f >> 6 : 64, d = 2 < b ? 63 & f : 64, g.push(a.charAt(m) + a.charAt(p) + a.charAt(c) + a.charAt(d));
return g.join("");
}, i.decode = function(l) {
var h, u, f, m, p, c, d = 0, g = 0, _ = "data:";
if (l.substr(0, _.length) === _) throw new Error("Invalid base64 input, it looks like a data url.");
var w, b = 3 * (l = l.replace(/[^A-Za-z0-9+/=]/g, "")).length / 4;
if (l.charAt(l.length - 1) === a.charAt(64) && b--, l.charAt(l.length - 2) === a.charAt(64) && b--, b % 1 != 0) throw new Error("Invalid base64 input, bad content length.");
for (w = s.uint8array ? new Uint8Array(0 | b) : new Array(0 | b); d < l.length; ) h = a.indexOf(l.charAt(d++)) << 2 | (m = a.indexOf(l.charAt(d++))) >> 4, u = (15 & m) << 4 | (p = a.indexOf(l.charAt(d++))) >> 2, f = (3 & p) << 6 | (c = a.indexOf(l.charAt(d++))), w[g++] = h, p !== 64 && (w[g++] = u), c !== 64 && (w[g++] = f);
return w;
};
}, { "./support": 30, "./utils": 32 }], 2: [function(t, n, i) {
var o = t("./external"), s = t("./stream/DataWorker"), a = t("./stream/Crc32Probe"), l = t("./stream/DataLengthProbe");
function h(u, f, m, p, c) {
this.compressedSize = u, this.uncompressedSize = f, this.crc32 = m, this.compression = p, this.compressedContent = c;
}
h.prototype = { getContentWorker: function() {
var u = new s(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")), f = this;
return u.on("end", function() {
if (this.streamInfo.data_length !== f.uncompressedSize) throw new Error("Bug : uncompressed data size mismatch");
}), u;
}, getCompressedWorker: function() {
return new s(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression);
} }, h.createWorkerFrom = function(u, f, m) {
return u.pipe(new a()).pipe(new l("uncompressedSize")).pipe(f.compressWorker(m)).pipe(new l("compressedSize")).withStreamInfo("compression", f);
}, n.exports = h;
}, { "./external": 6, "./stream/Crc32Probe": 25, "./stream/DataLengthProbe": 26, "./stream/DataWorker": 27 }], 3: [function(t, n, i) {
var o = t("./stream/GenericWorker");
i.STORE = { magic: "\0\0", compressWorker: function() {
return new o("STORE compression");
}, uncompressWorker: function() {
return new o("STORE decompression");
} }, i.DEFLATE = t("./flate");
}, { "./flate": 7, "./stream/GenericWorker": 28 }], 4: [function(t, n, i) {
var o = t("./utils"), s = (function() {
for (var a, l = [], h = 0; h < 256; h++) {
a = h;
for (var u = 0; u < 8; u++) a = 1 & a ? 3988292384 ^ a >>> 1 : a >>> 1;
l[h] = a;
}
return l;
})();
n.exports = function(a, l) {
return a !== void 0 && a.length ? o.getTypeOf(a) !== "string" ? (function(h, u, f, m) {
var p = s, c = m + f;
h ^= -1;
for (var d = m; d < c; d++) h = h >>> 8 ^ p[255 & (h ^ u[d])];
return -1 ^ h;
})(0 | l, a, a.length, 0) : (function(h, u, f, m) {
var p = s, c = m + f;
h ^= -1;
for (var d = m; d < c; d++) h = h >>> 8 ^ p[255 & (h ^ u.charCodeAt(d))];
return -1 ^ h;
})(0 | l, a, a.length, 0) : 0;
};
}, { "./utils": 32 }], 5: [function(t, n, i) {
i.base64 = !1, i.binary = !1, i.dir = !1, i.createFolders = !0, i.date = null, i.compression = null, i.compressionOptions = null, i.comment = null, i.unixPermissions = null, i.dosPermissions = null;
}, {}], 6: [function(t, n, i) {
var o = null;
o = typeof Promise < "u" ? Promise : t("lie"), n.exports = { Promise: o };
}, { lie: 37 }], 7: [function(t, n, i) {
var o = typeof Uint8Array < "u" && typeof Uint16Array < "u" && typeof Uint32Array < "u", s = t("pako"), a = t("./utils"), l = t("./stream/GenericWorker"), h = o ? "uint8array" : "array";
function u(f, m) {
l.call(this, "FlateWorker/" + f), this._pako = null, this._pakoAction = f, this._pakoOptions = m, this.meta = {};
}
i.magic = "\b\0", a.inherits(u, l), u.prototype.processChunk = function(f) {
this.meta = f.meta, this._pako === null && this._createPako(), this._pako.push(a.transformTo(h, f.data), !1);
}, u.prototype.flush = function() {
l.prototype.flush.call(this), this._pako === null && this._createPako(), this._pako.push([], !0);
}, u.prototype.cleanUp = function() {
l.prototype.cleanUp.call(this), this._pako = null;
}, u.prototype._createPako = function() {
this._pako = new s[this._pakoAction]({ raw: !0, level: this._pakoOptions.level || -1 });
var f = this;
this._pako.onData = function(m) {
f.push({ data: m, meta: f.meta });
};
}, i.compressWorker = function(f) {
return new u("Deflate", f);
}, i.uncompressWorker = function() {
return new u("Inflate", {});
};
}, { "./stream/GenericWorker": 28, "./utils": 32, pako: 38 }], 8: [function(t, n, i) {
function o(p, c) {
var d, g = "";
for (d = 0; d < c; d++) g += String.fromCharCode(255 & p), p >>>= 8;
return g;
}
function s(p, c, d, g, _, w) {
var b, T, M = p.file, C = p.compression, P = w !== h.utf8encode, B = a.transformTo("string", w(M.name)), R = a.transformTo("string", h.utf8encode(M.name)), U = M.comment, q = a.transformTo("string", w(U)), A = a.transformTo("string", h.utf8encode(U)), z = R.length !== M.name.length, x = A.length !== U.length, F = "", J = "", G = "", ne = M.dir, V = M.date, ee = { crc32: 0, compressedSize: 0, uncompressedSize: 0 };
c && !d || (ee.crc32 = p.crc32, ee.compressedSize = p.compressedSize, ee.uncompressedSize = p.uncompressedSize);
var O = 0;
c && (O |= 8), P || !z && !x || (O |= 2048);
var D = 0, Q = 0;
ne && (D |= 16), _ === "UNIX" ? (Q = 798, D |= (function(Z, ue) {
var fe = Z;
return Z || (fe = ue ? 16893 : 33204), (65535 & fe) << 16;
})(M.unixPermissions, ne)) : (Q = 20, D |= (function(Z) {
return 63 & (Z || 0);
})(M.dosPermissions)), b = V.getUTCHours(), b <<= 6, b |= V.getUTCMinutes(), b <<= 5, b |= V.getUTCSeconds() / 2, T = V.getUTCFullYear() - 1980, T <<= 4, T |= V.getUTCMonth() + 1, T <<= 5, T |= V.getUTCDate(), z && (J = o(1, 1) + o(u(B), 4) + R, F += "up" + o(J.length, 2) + J), x && (G = o(1, 1) + o(u(q), 4) + A, F += "uc" + o(G.length, 2) + G);
var Y = "";
return Y += `
\0`, Y += o(O, 2), Y += C.magic, Y += o(b, 2), Y += o(T, 2), Y += o(ee.crc32, 4), Y += o(ee.compressedSize, 4), Y += o(ee.uncompressedSize, 4), Y += o(B.length, 2), Y += o(F.length, 2), { fileRecord: f.LOCAL_FILE_HEADER + Y + B + F, dirRecord: f.CENTRAL_FILE_HEADER + o(Q, 2) + Y + o(q.length, 2) + "\0\0\0\0" + o(D, 4) + o(g, 4) + B + F + q };
}
var a = t("../utils"), l = t("../stream/GenericWorker"), h = t("../utf8"), u = t("../crc32"), f = t("../signature");
function m(p, c, d, g) {
l.call(this, "ZipFileWorker"), this.bytesWritten = 0, this.zipComment = c, this.zipPlatform = d, this.encodeFileName = g, this.streamFiles = p, this.accumulate = !1, this.contentBuffer = [], this.dirRecords = [], this.currentSourceOffset = 0, this.entriesCount = 0, this.currentFile = null, this._sources = [];
}
a.inherits(m, l), m.prototype.push = function(p) {
var c = p.meta.percent || 0, d = this.entriesCount, g = this._sources.length;
this.accumulate ? this.contentBuffer.push(p) : (this.bytesWritten += p.data.length, l.prototype.push.call(this, { data: p.data, meta: { currentFile: this.currentFile, percent: d ? (c + 100 * (d - g - 1)) / d : 100 } }));
}, m.prototype.openedSource = function(p) {
this.currentSourceOffset = this.bytesWritten, this.currentFile = p.file.name;
var c = this.streamFiles && !p.file.dir;
if (c) {
var d = s(p, c, !1, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
this.push({ data: d.fileRecord, meta: { percent: 0 } });
} else this.accumulate = !0;
}, m.prototype.closedSource = function(p) {
this.accumulate = !1;
var c = this.streamFiles && !p.file.dir, d = s(p, c, !0, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
if (this.dirRecords.push(d.dirRecord), c) this.push({ data: (function(g) {
return f.DATA_DESCRIPTOR + o(g.crc32, 4) + o(g.compressedSize, 4) + o(g.uncompressedSize, 4);
})(p), meta: { percent: 100 } });
else for (this.push({ data: d.fileRecord, meta: { percent: 0 } }); this.contentBuffer.length; ) this.push(this.contentBuffer.shift());
this.currentFile = null;
}, m.prototype.flush = function() {
for (var p = this.bytesWritten, c = 0; c < this.dirRecords.length; c++) this.push({ data: this.dirRecords[c], meta: { percent: 100 } });
var d = this.bytesWritten - p, g = (function(_, w, b, T, M) {
var C = a.transformTo("string", M(T));
return f.CENTRAL_DIRECTORY_END + "\0\0\0\0" + o(_, 2) + o(_, 2) + o(w, 4) + o(b, 4) + o(C.length, 2) + C;
})(this.dirRecords.length, d, p, this.zipComment, this.encodeFileName);
this.push({ data: g, meta: { percent: 100 } });
}, m.prototype.prepareNextSource = function() {
this.previous = this._sources.shift(), this.openedSource(this.previous.streamInfo), this.isPaused ? this.previous.pause() : this.previous.resume();
}, m.prototype.registerPrevious = function(p) {
this._sources.push(p);
var c = this;
return p.on("data", function(d) {
c.processChunk(d);
}), p.on("end", function() {
c.closedSource(c.previous.streamInfo), c._sources.length ? c.prepareNextSource() : c.end();
}), p.on("error", function(d) {
c.error(d);
}), this;
}, m.prototype.resume = function() {
return !!l.prototype.resume.call(this) && (!this.previous && this._sources.length ? (this.prepareNextSource(), !0) : this.previous || this._sources.length || this.generatedError ? void 0 : (this.end(), !0));
}, m.prototype.error = function(p) {
var c = this._sources;
if (!l.prototype.error.call(this, p)) return !1;
for (var d = 0; d < c.length; d++) try {
c[d].error(p);
} catch {
}
return !0;
}, m.prototype.lock = function() {
l.prototype.lock.call(this);
for (var p = this._sources, c = 0; c < p.length; c++) p[c].lock();
}, n.exports = m;
}, { "../crc32": 4, "../signature": 23, "../stream/GenericWorker": 28, "../utf8": 31, "../utils": 32 }], 9: [function(t, n, i) {
var o = t("../compressions"), s = t("./ZipFileWorker");
i.generateWorker = function(a, l, h) {
var u = new s(l.streamFiles, h, l.platform, l.encodeFileName), f = 0;
try {
a.forEach(function(m, p) {
f++;
var c = (function(w, b) {
var T = w || b, M = o[T];
if (!M) throw new Error(T + " is not a valid compression method !");
return M;
})(p.options.compression, l.compression), d = p.options.compressionOptions || l.compressionOptions || {}, g = p.dir, _ = p.date;
p._compressWorker(c, d).withStreamInfo("file", { name: m, dir: g, date: _, comment: p.comment || "", unixPermissions: p.unixPermissions, dosPermissions: p.dosPermissions }).pipe(u);
}), u.entriesCount = f;
} catch (m) {
u.error(m);
}
return u;
};
}, { "../compressions": 3, "./ZipFileWorker": 8 }], 10: [function(t, n, i) {
function o() {
if (!(this instanceof o)) return new o();
if (arguments.length) throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
this.files = /* @__PURE__ */ Object.create(null), this.comment = null, this.root = "", this.clone = function() {
var s = new o();
for (var a in this) typeof this[a] != "function" && (s[a] = this[a]);
return s;
};
}
(o.prototype = t("./object")).loadAsync = t("./load"), o.support = t("./support"), o.defaults = t("./defaults"), o.version = "3.10.1", o.loadAsync = function(s, a) {
return new o().loadAsync(s, a);
}, o.external = t("./external"), n.exports = o;
}, { "./defaults": 5, "./external": 6, "./load": 11, "./object": 15, "./support": 30 }], 11: [function(t, n, i) {
var o = t("./utils"), s = t("./external"), a = t("./utf8"), l = t("./zipEntries"), h = t("./stream/Crc32Probe"), u = t("./nodejsUtils");
function f(m) {
return new s.Promise(function(p, c) {
var d = m.decompressed.getContentWorker().pipe(new h());
d.on("error", function(g) {
c(g);
}).on("end", function() {
d.streamInfo.crc32 !== m.decompressed.crc32 ? c(new Error("Corrupted zip : CRC32 mismatch")) : p();
}).resume();
});
}
n.exports = function(m, p) {
var c = this;
return p = o.extend(p || {}, { base64: !1, checkCRC32: !1, optimizedBinaryString: !1, createFolders: !1, decodeFileName: a.utf8decode }), u.isNode && u.isStream(m) ? s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")) : o.prepareContent("the loaded zip file", m, !0, p.optimizedBinaryString, p.base64).then(function(d) {
var g = new l(p);
return g.load(d), g;
}).then(function(d) {
var g = [s.Promise.resolve(d)], _ = d.files;
if (p.checkCRC32) for (var w = 0; w < _.length; w++) g.push(f(_[w]));
return s.Promise.all(g);
}).then(function(d) {
for (var g = d.shift(), _ = g.files, w = 0; w < _.length; w++) {
var b = _[w], T = b.fileNameStr, M = o.resolve(b.fileNameStr);
c.file(M, b.decompressed, { binary: !0, optimizedBinaryString: !0, date: b.date, dir: b.dir, comment: b.fileCommentStr.length ? b.fileCommentStr : null, unixPermissions: b.unixPermissions, dosPermissions: b.dosPermissions, createFolders: p.createFolders }), b.dir || (c.file(M).unsafeOriginalName = T);
}
return g.zipComment.length && (c.comment = g.zipComment), c;
});
};
}, { "./external": 6, "./nodejsUtils": 14, "./stream/Crc32Probe": 25, "./utf8": 31, "./utils": 32, "./zipEntries": 33 }], 12: [function(t, n, i) {
var o = t("../utils"), s = t("../stream/GenericWorker");
function a(l, h) {
s.call(this, "Nodejs stream input adapter for " + l), this._upstreamEnded = !1, this._bindStream(h);
}
o.inherits(a, s), a.prototype._bindStream = function(l) {
var h = this;
(this._stream = l).pause(), l.on("data", function(u) {
h.push({ data: u, meta: { percent: 0 } });
}).on("error", function(u) {
h.isPaused ? this.generatedError = u : h.error(u);
}).on("end", function() {
h.isPaused ? h._upstreamEnded = !0 : h.end();
});
}, a.prototype.pause = function() {
return !!s.prototype.pause.call(this) && (this._stream.pause(), !0);
}, a.prototype.resume = function() {
return !!s.prototype.resume.call(this) && (this._upstreamEnded ? this.end() : this._stream.resume(), !0);
}, n.exports = a;
}, { "../stream/GenericWorker": 28, "../utils": 32 }], 13: [function(t, n, i) {
var o = t("readable-stream").Readable;
function s(a, l, h) {
o.call(this, l), this._helper = a;
var u = this;
a.on("data", function(f, m) {
u.push(f) || u._helper.pause(), h && h(m);
}).on("error", function(f) {
u.emit("error", f);
}).on("end", function() {
u.push(null);
});
}
t("../utils").inherits(s, o), s.prototype._read = function() {
this._helper.resume();
}, n.exports = s;
}, { "../utils": 32, "readable-stream": 16 }], 14: [function(t, n, i) {
n.exports = { isNode: typeof Buffer < "u", newBufferFrom: function(o, s) {
if (Buffer.from && Buffer.from !== Uint8Array.from) return Buffer.from(o, s);
if (typeof o == "number") throw new Error('The "data" argument must not be a number');
return new Buffer(o, s);
}, allocBuffer: function(o) {
if (Buffer.alloc) return Buffer.alloc(o);
var s = new Buffer(o);
return s.fill(0), s;
}, isBuffer: function(o) {
return Buffer.isBuffer(o);
}, isStream: function(o) {
return o && typeof o.on == "function" && typeof o.pause == "function" && typeof o.resume == "function";
} };
}, {}], 15: [function(t, n, i) {
function o(M, C, P) {
var B, R = a.getTypeOf(C), U = a.extend(P || {}, u);
U.date = U.date || /* @__PURE__ */ new Date(), U.compression !== null && (U.compression = U.compression.toUpperCase()), typeof U.unixPermissions == "string" && (U.unixPermissions = parseInt(U.unixPermissions, 8)), U.unixPermissions && 16384 & U.unixPermissions && (U.dir = !0), U.dosPermissions && 16 & U.dosPermissions && (U.dir = !0), U.dir && (M = _(M)), U.createFolders && (B = g(M)) && w.call(this, B, !0);
var q = R === "string" && U.binary === !1 && U.base64 === !1;
P && P.binary !== void 0 || (U.binary = !q), (C instanceof f && C.uncompressedSize === 0 || U.dir || !C || C.length === 0) && (U.base64 = !1, U.binary = !0, C = "", U.compression = "STORE", R = "string");
var A = null;
A = C instanceof f || C instanceof l ? C : c.isNode && c.isStream(C) ? new d(M, C) : a.prepareContent(M, C, U.binary, U.optimizedBinaryString, U.base64);
var z = new m(M, A, U);
this.files[M] = z;
}
var s = t("./utf8"), a = t("./utils"), l = t("./stream/GenericWorker"), h = t("./stream/StreamHelper"), u = t("./defaults"), f = t("./compressedObject"), m = t("./zipObject"), p = t("./generate"), c = t("./nodejsUtils"), d = t("./nodejs/NodejsStreamInputAdapter"), g = function(M) {
M.slice(-1) === "/" && (M = M.substring(0, M.length - 1));
var C = M.lastIndexOf("/");
return 0 < C ? M.substring(0, C) : "";
}, _ = function(M) {
return M.slice(-1) !== "/" && (M += "/"), M;
}, w = function(M, C) {
return C = C !== void 0 ? C : u.createFolders, M = _(M), this.files[M] || o.call(this, M, null, { dir: !0, createFolders: C }), this.files[M];
};
function b(M) {
return Object.prototype.toString.call(M) === "[object RegExp]";
}
var T = { load: function() {
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
}, forEach: function(M) {
var C, P, B;
for (C in this.files) B = this.files[C], (P = C.slice(this.root.length, C.length)) && C.slice(0, this.root.length) === this.root && M(P, B);
}, filter: function(M) {
var C = [];
return this.forEach(function(P, B) {
M(P, B) && C.push(B);
}), C;
}, file: function(M, C, P) {
if (arguments.length !== 1) return M = this.root + M, o.call(this, M, C, P), this;
if (b(M)) {
var B = M;
return this.filter(function(U, q) {
return !q.dir && B.test(U);
});
}
var R = this.files[this.root + M];
return R && !R.dir ? R : null;
}, folder: function(M) {
if (!M) return this;
if (b(M)) return this.filter(function(R, U) {
return U.dir && M.test(R);
});
var C = this.root + M, P = w.call(this, C), B = this.clone();
return B.root = P.name, B;
}, remove: function(M) {
M = this.root + M;
var C = this.files[M];
if (C || (M.slice(-1) !== "/" && (M += "/"), C = this.files[M]), C && !C.dir) delete this.files[M];
else for (var P = this.filter(function(R, U) {
return U.name.slice(0, M.length) === M;
}), B = 0; B < P.length; B++) delete this.files[P[B].name];
return this;
}, generate: function() {
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
}, generateInternalStream: function(M) {
var C, P = {};
try {
if ((P = a.extend(M || {}, { streamFiles: !1, compression: "STORE", compressionOptions: null, type: "", platform: "DOS", comment: null, mimeType: "application/zip", encodeFileName: s.utf8encode })).type = P.type.toLowerCase(), P.compression = P.compression.toUpperCase(), P.type === "binarystring" && (P.type = "string"), !P.type) throw new Error("No output type specified.");
a.checkSupport(P.type), P.platform !== "darwin" && P.platform !== "freebsd" && P.platform !== "linux" && P.platform !== "sunos" || (P.platform = "UNIX"), P.platform === "win32" && (P.platform = "DOS");
var B = P.comment || this.comment || "";
C = p.generateWorker(this, P, B);
} catch (R) {
(C = new l("error")).error(R);
}
return new h(C, P.type || "string", P.mimeType);
}, generateAsync: function(M, C) {
return this.generateInternalStream(M).accumulate(C);
}, generateNodeStream: function(M, C) {
return (M = M || {}).type || (M.type = "nodebuffer"), this.generateInternalStream(M).toNodejsStream(C);
} };
n.exports = T;
}, { "./compressedObject": 2, "./defaults": 5, "./generate": 9, "./nodejs/NodejsStreamInputAdapter": 12, "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31, "./utils": 32, "./zipObject": 35 }], 16: [function(t, n, i) {
n.exports = t("stream");
}, { stream: void 0 }], 17: [function(t, n, i) {
var o = t("./DataReader");
function s(a) {
o.call(this, a);
for (var l = 0; l < this.data.length; l++) a[l] = 255 & a[l];
}
t("../utils").inherits(s, o), s.prototype.byteAt = function(a) {
return this.data[this.zero + a];
}, s.prototype.lastIndexOfSignature = function(a) {
for (var l = a.charCodeAt(0), h = a.charCodeAt(1), u = a.charCodeAt(2), f = a.charCodeAt(3), m = this.length - 4; 0 <= m; --m) if (this.data[m] === l && this.data[m + 1] === h && this.data[m + 2] === u && this.data[m + 3] === f) return m - this.zero;
return -1;
}, s.prototype.readAndCheckSignature = function(a) {
var l = a.charCodeAt(0), h = a.charCodeAt(1), u = a.charCodeAt(2), f = a.charCodeAt(3), m = this.readData(4);
return l === m[0] && h === m[1] && u === m[2] && f === m[3];
}, s.prototype.readData = function(a) {
if (this.checkOffset(a), a === 0) return [];
var l = this.data.slice(this.zero + this.index, this.zero + this.index + a);
return this.index += a, l;
}, n.exports = s;
}, { "../utils": 32, "./DataReader": 18 }], 18: [function(t, n, i) {
var o = t("../utils");
function s(a) {
this.data = a, this.length = a.length, this.index = 0, this.zero = 0;
}
s.prototype = { checkOffset: function(a) {
this.checkIndex(this.index + a);
}, checkIndex: function(a) {
if (this.length < this.zero + a || a < 0) throw new Error("End of data reached (data length = " + this.length + ", asked index = " + a + "). Corrupted zip ?");
}, setIndex: function(a) {
this.checkIndex(a), this.index = a;
}, skip: function(a) {
this.setIndex(this.index + a);
}, byteAt: function() {
}, readInt: function(a) {
var l, h = 0;
for (this.checkOffset(a), l = this.index + a - 1; l >= this.index; l--) h = (h << 8) + this.byteAt(l);
return this.index += a, h;
}, readString: function(a) {
return o.transformTo("string", this.readData(a));
}, readData: function() {
}, lastIndexOfSignature: function() {
}, readAndCheckSignature: function() {
}, readDate: function() {
var a = this.readInt(4);
return new Date(Date.UTC(1980 + (a >> 25 & 127), (a >> 21 & 15) - 1, a >> 16 & 31, a >> 11 & 31, a >> 5 & 63, (31 & a) << 1));
} }, n.exports = s;
}, { "../utils": 32 }], 19: [function(t, n, i) {
var o = t("./Uint8ArrayReader");
function s(a) {
o.call(this, a);
}
t("../utils").inherits(s, o), s.prototype.readData = function(a) {
this.checkOffset(a);
var l = this.data.slice(this.zero + this.index, this.zero + this.index + a);
return this.index += a, l;
}, n.exports = s;
}, { "../utils": 32, "./Uint8ArrayReader": 21 }], 20: [function(t, n, i) {
var o = t("./DataReader");
function s(a) {
o.call(this, a);
}
t("../utils").inherits(s, o), s.prototype.byteAt = function(a) {
return this.data.charCodeAt(this.zero + a);
}, s.prototype.lastIndexOfSignature = function(a) {
return this.data.lastIndexOf(a) - this.zero;
}, s.prototype.readAndCheckSignature = function(a) {
return a === this.readData(4);
}, s.prototype.readData = function(a) {
this.checkOffset(a);
var l = this.data.slice(this.zero + this.index, this.zero + this.index + a);
return this.index += a, l;
}, n.exports = s;
}, { "../utils": 32, "./DataReader": 18 }], 21: [function(t, n, i) {
var o = t("./ArrayReader");
function s(a) {
o.call(this, a);
}
t("../utils").inherits(s, o), s.prototype.readData = function(a) {
if (this.checkOffset(a), a === 0) return new Uint8Array(0);
var l = this.data.subarray(this.zero + this.index, this.zero + this.index + a);
return this.index += a, l;
}, n.exports = s;
}, { "../utils": 32, "./ArrayReader": 17 }], 22: [function(t, n, i) {
var o = t("../utils"), s = t("../support"), a = t("./ArrayReader"), l = t("./StringReader"), h = t("./NodeBufferReader"), u = t("./Uint8ArrayReader");
n.exports = function(f) {
var m = o.getTypeOf(f);
return o.checkSupport(m), m !== "string" || s.uint8array ? m === "nodebuffer" ? new h(f) : s.uint8array ? new u(o.transformTo("uint8array", f)) : new a(o.transformTo("array", f)) : new l(f);
};
}, { "../support": 30, "../utils": 32, "./ArrayReader": 17, "./NodeBufferReader": 19, "./StringReader": 20, "./Uint8ArrayReader": 21 }], 23: [function(t, n, i) {
i.LOCAL_FILE_HEADER = "PK", i.CENTRAL_FILE_HEADER = "PK", i.CENTRAL_DIRECTORY_END = "PK", i.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x07", i.ZIP64_CENTRAL_DIRECTORY_END = "PK", i.DATA_DESCRIPTOR = "PK\x07\b";
}, {}], 24: [function(t, n, i) {
var o = t("./GenericWorker"), s = t("../utils");
function a(l) {
o.call(this, "ConvertWorker to " + l), this.destType = l;
}
s.inherits(a, o), a.prototype.processChunk = function(l) {
this.push({ data: s.transformTo(this.destType, l.data), meta: l.meta });
}, n.exports = a;
}, { "../utils": 32, "./GenericWorker": 28 }], 25: [function(t, n, i) {
var o = t("./GenericWorker"), s = t("../crc32");
function a() {
o.call(this, "Crc32Probe"), this.withStreamInfo("crc32", 0);
}
t("../utils").inherits(a, o), a.prototype.processChunk = function(l) {
this.streamInfo.crc32 = s(l.data, this.streamInfo.crc32 || 0), this.push(l);
}, n.exports = a;
}, { "../crc32": 4, "../utils": 32, "./GenericWorker": 28 }], 26: [function(t, n, i) {
var o = t("../utils"), s = t("./GenericWorker");
function a(l) {
s.call(this, "DataLengthProbe for " + l), this.propName = l, this.withStreamInfo(l, 0);
}
o.inherits(a, s), a.prototype.processChunk = function(l) {
if (l) {
var h = this.streamInfo[this.propName] || 0;
this.streamInfo[this.propName] = h + l.data.length;
}
s.prototype.processChunk.call(this, l);
}, n.exports = a;
}, { "../utils": 32, "./GenericWorker": 28 }], 27: [function(t, n, i) {
var o = t("../utils"), s = t("./GenericWorker");
function a(l) {
s.call(this, "DataWorker");
var h = this;
this.dataIsReady = !1, this.index = 0, this.max = 0, this.data = null, this.type = "", this._tickScheduled = !1, l.then(function(u) {
h.dataIsReady = !0, h.data = u, h.max = u && u.length || 0, h.type = o.getTypeOf(u), h.isPaused || h._tickAndRepeat();
}, function(u) {
h.error(u);
});
}
o.inherits(a, s), a.prototype.cleanUp = function() {
s.prototype.cleanUp.call(this), this.data = null;
}, a.prototype.resume = function() {
return !!s.prototype.resume.call(this) && (!this._tickScheduled && this.dataIsReady && (this._tickScheduled = !0, o.delay(this._tickAndRepeat, [], this)), !0);
}, a.prototype._tickAndRepeat = function() {
this._tickScheduled = !1, this.isPaused || this.isFinished || (this._tick(), this.isFinished || (o.delay(this._tickAndRepeat, [], this), this._tickScheduled = !0));
}, a.prototype._tick = function() {
if (this.isPaused || this.isFinished) return !1;
var l = null, h = Math.min(this.max, this.index + 16384);
if (this.index >= this.max) return this.end();
switch (this.type) {
case "string":
l = this.data.substring(this.index, h);
break;
case "uint8array":
l = this.data.subarray(this.index, h);
break;
case "array":
case "nodebuffer":
l = this.data.slice(this.index, h);
}
return this.index = h, this.push({ data: l, meta: { percent: this.max ? this.index / this.max * 100 : 0 } });
}, n.exports = a;
}, { "../utils": 32, "./GenericWorker": 28 }], 28: [function(t, n, i) {
function o(s) {
this.name = s || "default", this.streamInfo = {}, this.generatedError = null, this.extraStreamInfo = {}, this.isPaused = !0, this.isFinished = !1, this.isLocked = !1, this._listeners = { data: [], end: [], error: [] }, this.previous = null;
}
o.prototype = { push: function(s) {
this.emit("data", s);
}, end: function() {
if (this.isFinished) return !1;
this.flush();
try {
this.emit("end"), this.cleanUp(), this.isFinished = !0;
} catch (s) {
this.emit("error", s);
}
return !0;
}, error: function(s) {
return !this.isFinished && (this.isPaused ? this.generatedError = s : (this.isFinished = !0, this.emit("error", s), this.previous && this.previous.error(s), this.cleanUp()), !0);
}, on: function(s, a) {
return this._listeners[s].push(a), this;
}, cleanUp: function() {
this.streamInfo = this.generatedError = this.extraStreamInfo = null, this._listeners = [];
}, emit: function(s, a) {
if (this._listeners[s]) for (var l = 0; l < this._listeners[s].length; l++) this._listeners[s][l].call(this, a);
}, pipe: function(s) {
return s.registerPrevious(this);
}, registerPrevious: function(s) {
if (this.isLocked) throw new Error("The stream '" + this + "' has already been used.");
this.streamInfo = s.streamInfo, this.mergeStreamInfo(), this.previous = s;
var a = this;
return s.on("data", function(l) {
a.processChunk(l);
}), s.on("end", function() {
a.end();
}), s.on("error", function(l) {
a.error(l);
}), this;
}, pause: function() {
return !this.isPaused && !this.isFinished && (this.isPaused = !0, this.previous && this.previous.pause(), !0);
}, resume: function() {
if (!this.isPaused || this.isFinished) return !1;
var s = this.isPaused = !1;
return this.generatedError && (this.error(this.generatedError), s = !0), this.previous && this.previous.resume(), !s;
}, flush: function() {
}, processChunk: function(s) {
this.push(s);
}, withStreamInfo: function(s, a) {
return this.extraStreamInfo[s] = a, this.mergeStreamInfo(), this;
}, mergeStreamInfo: function() {
for (var s in this.extraStreamInfo) Object.prototype.hasOwnProperty.call(this.extraStreamInfo, s) && (this.streamInfo[s] = this.extraStreamInfo[s]);
}, lock: function() {
if (this.isLocked) throw new Error("The stream '" + this + "' has already been used.");
this.isLocked = !0, this.previous && this.previous.lock();
}, toString: function() {
var s = "Worker " + this.name;
return this.previous ? this.previous + " -> " + s : s;
} }, n.exports = o;
}, {}], 29: [function(t, n, i) {
var o = t("../utils"), s = t("./ConvertWorker"), a = t("./GenericWorker"), l = t("../base64"), h = t("../support"), u = t("../external"), f = null;
if (h.nodestream) try {
f = t("../nodejs/NodejsStreamOutputAdapter");
} catch {
}
function m(c, d) {
return new u.Promise(function(g, _) {
var w = [], b = c._internalType, T = c._outputType, M = c._mimeType;
c.on("data", function(C, P) {
w.push(C), d && d(P);
}).on("error", function(C) {
w = [], _(C);
}).on("end", function() {
try {
var C = (function(P, B, R) {
switch (P) {
case "blob":
return o.newBlob(o.transformTo("arraybuffer", B), R);
case "base64":
return l.encode(B);
default:
return o.transformTo(P, B);
}
})(T, (function(P, B) {
var R, U = 0, q = null, A = 0;
for (R = 0; R < B.length; R++) A += B[R].length;
switch (P) {
case "string":
return B.join("");
case "array":
return Array.prototype.concat.apply([], B);
case "uint8array":
for (q = new Uint8Array(A), R = 0; R < B.length; R++) q.set(B[R], U), U += B[R].length;
return q;
case "nodebuffer":
return Buffer.concat(B);
default:
throw new Error("concat : unsupported type '" + P + "'");
}
})(b, w), M);
g(C);
} catch (P) {
_(P);
}
w = [];
}).resume();
});
}
function p(c, d, g) {
var _ = d;
switch (d) {
case "blob":
case "arraybuffer":
_ = "uint8array";
break;
case "base64":
_ = "string";
}
try {
this._internalType = _, this._outputType = d, this._mimeType = g, o.checkSupport(_), this._worker = c.pipe(new s(_)), c.lock();
} catch (w) {
this._worker = new a("error"), this._worker.error(w);
}
}
p.prototype = { accumulate: function(c) {
return m(this, c);
}, on: function(c, d) {
var g = this;
return c === "data" ? this._worker.on(c, function(_) {
d.call(g, _.data, _.meta);
}) : this._worker.on(c, function() {
o.delay(d, arguments, g);
}), this;
}, resume: function() {
return o.delay(this._worker.resume, [], this._worker), this;
}, pause: function() {
return this._worker.pause(), this;
}, toNodejsStream: function(c) {
if (o.checkSupport("nodestream"), this._outputType !== "nodebuffer") throw new Error(this._outputType + " is not supported by this method");
return new f(this, { objectMode: this._outputType !== "nodebuffer" }, c);
} }, n.exports = p;
}, { "../base64": 1, "../external": 6, "../nodejs/NodejsStreamOutputAdapter": 13, "../support": 30, "../utils": 32, "./ConvertWorker": 24, "./GenericWorker": 28 }], 30: [function(t, n, i) {
if (i.base64 = !0, i.array = !0, i.string = !0, i.arraybuffer = typeof ArrayBuffer < "u" && typeof Uint8Array < "u", i.nodebuffer = typeof Buffer < "u", i.uint8array = typeof Uint8Array < "u", typeof ArrayBuffer > "u") i.blob = !1;
else {
var o = new ArrayBuffer(0);
try {
i.blob = new Blob([o], { type: "application/zip" }).size === 0;
} catch {
try {
var s = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)();
s.append(o), i.blob = s.getBlob("application/zip").size === 0;
} catch {
i.blob = !1;
}
}
}
try {
i.nodestream = !!t("readable-stream").Readable;
} catch {
i.nodestream = !1;
}
}, { "readable-stream": 16 }], 31: [function(t, n, i) {
for (var o = t("./utils"), s = t("./support"), a = t("./nodejsUtils"), l = t("./stream/GenericWorker"), h = new Array(256), u = 0; u < 256; u++) h[u] = 252 <= u ? 6 : 248 <= u ? 5 : 240 <= u ? 4 : 224 <= u ? 3 : 192 <= u ? 2 : 1;
h[254] = h[254] = 1;
function f() {
l.call(this, "utf-8 decode"), this.leftOver = null;
}
function m() {
l.call(this, "utf-8 encode");
}
i.utf8encode = function(p) {
return s.nodebuffer ? a.newBufferFrom(p, "utf-8") : (function(c) {
var d, g, _, w, b, T = c.length, M = 0;
for (w = 0; w < T; w++) (64512 & (g = c.charCodeAt(w))) == 55296 && w + 1 < T && (64512 & (_ = c.charCodeAt(w + 1))) == 56320 && (g = 65536 + (g - 55296 << 10) + (_ - 56320), w++), M += g < 128 ? 1 : g < 2048 ? 2 : g < 65536 ? 3 : 4;
for (d = s.uint8array ? new Uint8Array(M) : new Array(M), w = b = 0; b < M; w++) (64512 & (g = c.charCodeAt(w))) == 55296 && w + 1 < T && (64512 & (_ = c.charCodeAt(w + 1))) == 56320 && (g = 65536 + (g - 55296 << 10) + (_ - 56320), w++), g < 128 ? d[b++] = g : (g < 2048 ? d[b++] = 192 | g >>> 6 : (g < 65536 ? d[b++] = 224 | g >>> 12 : (d[b++] = 240 | g >>> 18, d[b++] = 128 | g >>> 12 & 63), d[b++] = 128 | g >>> 6 & 63), d[b++] = 128 | 63 & g);
return d;
})(p);
}, i.utf8decode = function(p) {
return s.nodebuffer ? o.transformTo("nodebuffer", p).toString("utf-8") : (function(c) {
var d, g, _, w, b = c.length, T = new Array(2 * b);
for (d = g = 0; d < b; ) if ((_ = c[d++]) < 128) T[g++] = _;
else if (4 < (w = h[_])) T[g++] = 65533, d += w - 1;
else {
for (_ &= w === 2 ? 31 : w === 3 ? 15 : 7; 1 < w && d < b; ) _ = _ << 6 | 63 & c[d++], w--;
1 < w ? T[g++] = 65533 : _ < 65536 ? T[g++] = _ : (_ -= 65536, T[g++] = 55296 | _ >> 10 & 1023, T[g++] = 56320 | 1023 & _);
}
return T.length !== g && (T.subarray ? T = T.subarray(0, g) : T.length = g), o.applyFromCharCode(T);
})(p = o.transformTo(s.uint8array ? "uint8array" : "array", p));
}, o.inherits(f, l), f.prototype.processChunk = function(p) {
var c = o.transformTo(s.uint8array ? "uint8array" : "array", p.data);
if (this.leftOver && this.leftOver.length) {
if (s.uint8array) {
var d = c;
(c = new Uint8Array(d.length + this.leftOver.length)).set(this.leftOver, 0), c.set(d, this.leftOver.length);
} else c = this.leftOver.concat(c);
this.leftOver = null;
}
var g = (function(w, b) {
var T;
for ((b = b || w.length) > w.length && (b = w.length), T = b - 1; 0 <= T && (192 & w[T]) == 128; ) T--;
return T < 0 || T === 0 ? b : T + h[w[T]] > b ? T : b;
})(c), _ = c;
g !== c.length && (s.uint8array ? (_ = c.subarray(0, g), this.leftOver = c.subarray(g, c.length)) : (_ = c.slice(0, g), this.leftOver = c.slice(g, c.length))), this.push({ data: i.utf8decode(_), meta: p.meta });
}, f.prototype.flush = function() {
this.leftOver && this.leftOver.length && (this.push({ data: i.utf8decode(this.leftOver), meta: {} }), this.leftOver = null);
}, i.Utf8DecodeWorker = f, o.inherits(m, l), m.prototype.processChunk = function(p) {
this.push({ data: i.utf8encode(p.data), meta: p.meta });
}, i.Utf8EncodeWorker = m;
}, { "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./support": 30, "./utils": 32 }], 32: [function(t, n, i) {
var o = t("./support"), s = t("./base64"), a = t("./nodejsUtils"), l = t("./external");
function h(d) {
return d;
}
function u(d, g) {
for (var _ = 0; _ < d.length; ++_) g[_] = 255 & d.charCodeAt(_);
return g;
}
t("setimmediate"), i.newBlob = function(d, g) {
i.checkSupport("blob");
try {
return new Blob([d], { type: g });
} catch {
try {
var _ = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)();
return _.append(d), _.getBlob(g);
} catch {
throw new Error("Bug : can't construct the Blob.");
}
}
};
var f = { stringifyByChunk: function(d, g, _) {
var w = [], b = 0, T = d.length;
if (T <= _) return String.fromCharCode.apply(null, d);
for (; b < T; ) g === "array" || g === "nodebuffer" ? w.push(String.fromCharCode.apply(null, d.slice(b, Math.min(b + _, T)))) : w.push(String.fromCharCode.apply(null, d.subarray(b, Math.min(b + _, T)))), b += _;
return w.join("");
}, stringifyByChar: function(d) {
for (var g = "", _ = 0; _ < d.length; _++) g += String.fromCharCode(d[_]);
return g;
}, applyCanBeUsed: { uint8array: (function() {
try {
return o.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;
} catch {
return !1;
}
})(), nodebuffer: (function() {
try {
return o.nodebuffer && String.fromCharCode.apply(null, a.allocBuffer(1)).length === 1;
} catch {
return !1;
}
})() } };
function m(d) {
var g = 65536, _ = i.getTypeOf(d), w = !0;
if (_ === "uint8array" ? w = f.applyCanBeUsed.uint8array : _ === "nodebuffer" && (w = f.applyCanBeUsed.nodebuffer), w) for (; 1 < g; ) try {
return f.stringifyByChunk(d, _, g);
} catch {
g = Math.floor(g / 2);
}
return f.stringifyByChar(d);
}
function p(d, g) {
for (var _ = 0; _ < d.length; _++) g[_] = d[_];
return g;
}
i.applyFromCharCode = m;
var c = {};
c.string = { string: h, array: function(d) {
return u(d, new Array(d.length));
}, arraybuffer: function(d) {
return c.string.uint8array(d).buffer;
}, uint8array: function(d) {
return u(d, new Uint8Array(d.length));
}, nodebuffer: function(d) {
return u(d, a.allocBuffer(d.length));
} }, c.array = { string: m, array: h, arraybuffer: function(d) {
return new Uint8Array(d).buffer;
}, uint8array: function(d) {
return new Uint8Array(d);
}, nodebuffer: function(d) {
return a.newBufferFrom(d);
} }, c.arraybuffer = { string: function(d) {
return m(new Uint8Array(d));
}, array: function(d) {
return p(new Uint8Array(d), new Array(d.byteLength));
}, arraybuffer: h, uint8array: function(d) {
return new Uint8Array(d);
}, nodebuffer: function(d) {
return a.newBufferFrom(new Uint8Array(d));
} }, c.uint8array = { string: m, array: function(d) {
return p(d, new Array(d.length));
}, arraybuffer: function(d) {
return d.buffer;
}, uint8array: h, nodebuffer: function(d) {
return a.newBufferFrom(d);
} }, c.nodebuffer = { string: m, array: function(d) {
return p(d, new Array(d.length));
}, arraybuffer: function(d) {
return c.nodebuffer.uint8array(d).buffer;
}, uint8array: function(d) {
return p(d, new Uint8Array(d.length));
}, nodebuffer: h }, i.transformTo = function(d, g) {
if (g = g || "", !d) return g;
i.checkSupport(d);
var _ = i.getTypeOf(g);
return c[_][d](g);
}, i.resolve = function(d) {
for (var g = d.split("/"), _ = [], w = 0; w < g.length; w++) {
var b = g[w];
b === "." || b === "" && w !== 0 && w !== g.length - 1 || (b === ".." ? _.pop() : _.push(b));
}
return _.join("/");
}, i.getTypeOf = function(d) {
return typeof d == "string" ? "string" : Object.prototype.toString.call(d) === "[object Array]" ? "array" : o.nodebuffer && a.isBuffer(d) ? "nodebuffer" : o.uint8array && d instanceof Uint8Array ? "uint8array" : o.arraybuffer && d instanceof ArrayBuffer ? "arraybuffer" : void 0;
}, i.checkSupport = function(d) {
if (!o[d.toLowerCase()]) throw new Error(d + " is not supported by this platform");
}, i.MAX_VALUE_16BITS = 65535, i.MAX_VALUE_32BITS = -1, i.pretty = function(d) {
var g, _, w = "";
for (_ = 0; _ < (d || "").length; _++) w += "\\x" + ((g = d.charCodeAt(_)) < 16 ? "0" : "") + g.toString(16).toUpperCase();
return w;
}, i.delay = function(d, g, _) {
setImmediate(function() {
d.apply(_ || null, g || []);
});
}, i.inherits = function(d, g) {
function _() {
}
_.prototype = g.prototype, d.prototype = new _();
}, i.extend = function() {
var d, g, _ = {};
for (d = 0; d < arguments.length; d++) for (g in arguments[d]) Object.prototype.hasOwnProperty.call(arguments[d], g) && _[g] === void 0 && (_[g] = arguments[d][g]);
return _;
}, i.prepareContent = function(d, g, _, w, b) {
return l.Promise.resolve(g).then(function(T) {
return o.blob && (T instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(T)) !== -1) && typeof FileReader < "u" ? new l.Promise(function(M, C) {
var P = new FileReader();
P.onload = function(B) {
M(B.target.result);
}, P.onerror = function(B) {
C(B.target.error);
}, P.readAsArrayBuffer(T);
}) : T;
}).then(function(T) {
var M = i.getTypeOf(T);
return M ? (M === "arraybuffer" ? T = i.transformTo("uint8array", T) : M === "string" && (b ? T = s.decode(T) : _ && w !== !0 && (T = (function(C) {
return u(C, o.uint8array ? new Uint8Array(C.length) : new Array(C.length));
})(T))), T) : l.Promise.reject(new Error("Can't read the data of '" + d + "'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));
});
};
}, { "./base64": 1, "./external": 6, "./nodejsUtils": 14, "./support": 30, setimmediate: 54 }], 33: [function(t, n, i) {
var o = t("./reader/readerFor"), s = t("./utils"), a = t("./signature"), l = t("./zipEntry"), h = t("./support");
function u(f) {
this.files = [], this.loadOptions = f;
}
u.prototype = { checkSignature: function(f) {
if (!this.reader.readAndCheckSignature(f)) {
this.reader.index -= 4;
var m = this.reader.readString(4);
throw new Error("Corrupted zip or bug: unexpected signature (" + s.pretty(m) + ", expected " + s.pretty(f) + ")");
}
}, isSignature: function(f, m) {
var p = this.reader.index;
this.reader.setIndex(f);
var c = this.reader.readString(4) === m;
return this.reader.setIndex(p), c;
}, readBlockEndOfCentral: function() {
this.diskNumber = this.reader.readInt(2), this.diskWithCentralDirStart = this.reader.readInt(2), this.centralDirRecordsOnThisDisk = this.reader.readInt(2), this.centralDirRecords = this.reader.readInt(2), this.centralDirSize = this.reader.readInt(4), this.centralDirOffset = this.reader.readInt(4), this.zipCommentLength = this.reader.readInt(2);
var f = this.reader.readData(this.zipCommentLength), m = h.uint8array ? "uint8array" : "array", p = s.transformTo(m, f);
this.zipComment = this.loadOptions.decodeFileName(p);
}, readBlockZip64EndOfCentral: function() {
this.zip64EndOfCentralSize = this.reader.readInt(8), this.reader.skip(4), this.diskNumber = this.reader.readInt(4), this.diskWithCentralDirStart = this.reader.readInt(4), this.centralDirRecordsOnThisDisk = this.reader.readInt(8), this.centralDirRecords = this.reader.readInt(8), this.centralDirSize = this.reader.readInt(8), this.centralDirOffset = this.reader.readInt(8), this.zip64ExtensibleData = {};
for (var f, m, p, c = this.zip64EndOfCentralSize - 44; 0 < c; ) f = this.reader.readInt(2), m = this.reader.readInt(4), p = this.reader.readData(m), this.zip64ExtensibleData[f] = { id: f, length: m, value: p };
}, readBlockZip64EndOfCentralLocator: function() {
if (this.diskWithZip64CentralDirStart = this.reader.readInt(4), this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8), this.disksCount = this.reader.readInt(4), 1 < this.disksCount) throw new Error("Multi-volumes zip are not supported");
}, readLocalFiles: function() {
var f, m;
for (f = 0; f < this.files.length; f++) m = this.files[f], this.reader.setIndex(m.localHeaderOffset), this.checkSignature(a.LOCAL_FILE_HEADER), m.readLocalPart(this.reader), m.handleUTF8(), m.processAttributes();
}, readCentralDir: function() {
var f;
for (this.reader.setIndex(this.centralDirOffset); this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER); ) (f = new l({ zip64: this.zip64 }, this.loadOptions)).readCentralPart(this.reader), this.files.push(f);
if (this.centralDirRecords !== this.files.length && this.centralDirRecords !== 0 && this.files.length === 0) throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
}, readEndOfCentral: function() {
var f = this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);
if (f < 0) throw this.isSignature(0, a.LOCAL_FILE_HEADER) ? new Error("Corrupted zip: can't find end of central directory") : new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");
this.reader.setIndex(f);
var m = f;
if (this.checkSignature(a.CENTRAL_DIRECTORY_END), this.readBlockEndOfCentral(), this.diskNumber === s.MAX_VALUE_16BITS || this.diskWithCentralDirStart === s.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === s.MAX_VALUE_16BITS || this.centralDirRecords === s.MAX_VALUE_16BITS || this.centralDirSize === s.MAX_VALUE_32BITS || this.centralDirOffset === s.MAX_VALUE_32BITS) {
if (this.zip64 = !0, (f = this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR)) < 0) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");
if (this.reader.setIndex(f), this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR), this.readBlockZip64EndOfCentralLocator(), !this.isSignature(this.relativeOffsetEndOfZip64CentralDir, a.ZIP64_CENTRAL_DIRECTORY_END) && (this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END), this.relativeOffsetEndOfZip64CentralDir < 0)) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");
this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir), this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END), this.readBlockZip64EndOfCentral();
}
var p = this.centralDirOffset + this.centralDirSize;
this.zip64 && (p += 20, p += 12 + this.zip64EndOfCentralSize);
var c = m - p;
if (0 < c) this.isSignature(m, a.CENTRAL_FILE_HEADER) || (this.reader.zero = c);
else if (c < 0) throw new Error("Corrupted zip: missing " + Math.abs(c) + " bytes.");
}, prepareReader: function(f) {
this.reader = o(f);
}, load: function(f) {
this.prepareReader(f), this.readEndOfCentral(), this.readCentralDir(), this.readLocalFiles();
} }, n.exports = u;
}, { "./reader/readerFor": 22, "./signature": 23, "./support": 30, "./utils": 32, "./zipEntry": 34 }], 34: [function(t, n, i) {
var o = t("./reader/readerFor"), s = t("./utils"), a = t("./compressedObject"), l = t("./crc32"), h = t("./utf8"), u = t("./compressions"), f = t("./support");
function m(p, c) {
this.options = p, this.loadOptions = c;
}
m.prototype = { isEncrypted: function() {
return (1 & this.bitFlag) == 1;
}, useUTF8: function() {
return (2048 & this.bitFlag) == 2048;
}, readLocalPart: function(p) {
var c, d;
if (p.skip(22), this.fileNameLength = p.readInt(2), d = p.readInt(2), this.fileName = p.readData(this.fileNameLength), p.skip(d), this.compressedSize === -1 || this.uncompressedSize === -1) throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");
if ((c = (function(g) {
for (var _ in u) if (Object.prototype.hasOwnProperty.call(u, _) && u[_].magic === g) return u[_];
return null;
})(this.compressionMethod)) === null) throw new Error("Corrupted zip : compression " + s.pretty(this.compressionMethod) + " unknown (inner file : " + s.transformTo("string", this.fileName) + ")");
this.decompressed = new a(this.compressedSize, this.uncompressedSize, this.crc32, c, p.readData(this.compressedSize));
}, readCentralPart: function(p) {
this.versionMadeBy = p.readInt(2), p.skip(2), this.bitFlag = p.readInt(2), this.compressionMethod = p.readString(2), this.date = p.readDate(), this.crc32 = p.readInt(4), this.compressedSize = p.readInt(4), this.uncompressedSize = p.readInt(4);
var c = p.readInt(2);
if (this.extraFieldsLength = p.readInt(2), this.fileCommentLength = p.readInt(2), this.diskNumberStart = p.readInt(2), this.internalFileAttributes = p.readInt(2), this.externalFileAttributes = p.readInt(4), this.localHeaderOffset = p.readInt(4), this.isEncrypted()) throw new Error("Encrypted zip are not supported");
p.skip(c), this.readExtraFields(p), this.parseZIP64ExtraField(p), this.fileComment = p.readData(this.fileCommentLength);
}, processAttributes: function() {
this.unixPermissions = null, this.dosPermissions = null;
var p = this.versionMadeBy >> 8;
this.dir = !!(16 & this.externalFileAttributes), p == 0 && (this.dosPermissions = 63 & this.externalFileAttributes), p == 3 && (this.unixPermissions = this.externalFileAttributes >> 16 & 65535), this.dir || this.fileNameStr.slice(-1) !== "/" || (this.dir = !0);
}, parseZIP64ExtraField: function() {
if (this.extraFields[1]) {
var p = o(this.extraFields[1].value);
this.uncompressedSize === s.MAX_VALUE_32BITS && (this.uncompressedSize = p.readInt(8)), this.compressedSize === s.MAX_VALUE_32BITS && (this.compressedSize = p.readInt(8)), this.localHeaderOffset === s.MAX_VALUE_32BITS && (this.localHeaderOffset = p.readInt(8)), this.diskNumberStart === s.MAX_VALUE_32BITS && (this.diskNumberStart = p.readInt(4));
}
}, readExtraFields: function(p) {
var c, d, g, _ = p.index + this.extraFieldsLength;
for (this.extraFields || (this.extraFields = {}); p.index + 4 < _; ) c = p.readInt(2), d = p.readInt(2), g = p.readData(d), this.extraFields[c] = { id: c, length: d, value: g };
p.setIndex(_);
}, handleUTF8: function() {
var p = f.uint8array ? "uint8array" : "array";
if (this.useUTF8()) this.fileNameStr = h.utf8decode(this.fileName), this.fileCommentStr = h.utf8decode(this.fileComment);
else {
var c = this.findExtraFieldUnicodePath();
if (c !== null) this.fileNameStr = c;
else {
var d = s.transformTo(p, this.fileName);
this.fileNameStr = this.loadOptions.decodeFileName(d);
}
var g = this.findExtraFieldUnicodeComment();
if (g !== null) this.fileCommentStr = g;
else {
var _ = s.transformTo(p, this.fileComment);
this.fileCommentStr = this.loadOptions.decodeFileName(_);
}
}
}, findExtraFieldUnicodePath: function() {
var p = this.extraFields[28789];
if (p) {
var c = o(p.value);
return c.readInt(1) !== 1 || l(this.fileName) !== c.readInt(4) ? null : h.utf8decode(c.readData(p.length - 5));
}
return null;
}, findExtraFieldUnicodeComment: function() {
var p = this.extraFields[25461];
if (p) {
var c = o(p.value);
return c.readInt(1) !== 1 || l(this.fileComment) !== c.readInt(4) ? null : h.utf8decode(c.readData(p.length - 5));
}
return null;
} }, n.exports = m;
}, { "./compressedObject": 2, "./compressions": 3, "./crc32": 4, "./reader/readerFor": 22, "./support": 30, "./utf8": 31, "./utils": 32 }], 35: [function(t, n, i) {
function o(c, d, g) {
this.name = c, this.dir = g.dir, this.date = g.date, this.comment = g.comment, this.unixPermissions = g.unixPermissions, this.dosPermissions = g.dosPermissions, this._data = d, this._dataBinary = g.binary, this.options = { compression: g.compression, compressionOptions: g.compressionOptions };
}
var s = t("./stream/StreamHelper"), a = t("./stream/DataWorker"), l = t("./utf8"), h = t("./compressedObject"), u = t("./stream/GenericWorker");
o.prototype = { internalStream: function(c) {
var d = null, g = "string";
try {
if (!c) throw new Error("No output type specified.");
var _ = (g = c.toLowerCase()) === "string" || g === "text";
g !== "binarystring" && g !== "text" || (g = "string"), d = this._decompressWorker();
var w = !this._dataBinary;
w && !_ && (d = d.pipe(new l.Utf8EncodeWorker())), !w && _ && (d = d.pipe(new l.Utf8DecodeWorker()));
} catch (b) {
(d = new u("error")).error(b);
}
return new s(d, g, "");
}, async: function(c, d) {
return this.internalStream(c).accumulate(d);
}, nodeStream: function(c, d) {
return this.internalStream(c || "nodebuffer").toNodejsStream(d);
}, _compressWorker: function(c, d) {
if (this._data instanceof h && this._data.compression.magic === c.magic) return this._data.getCompressedWorker();
var g = this._decompressWorker();
return this._dataBinary || (g = g.pipe(new l.Utf8EncodeWorker())), h.createWorkerFrom(g, c, d);
}, _decompressWorker: function() {
return this._data instanceof h ? this._data.getContentWorker() : this._data instanceof u ? this._data : new a(this._data);
} };
for (var f = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"], m = function() {
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
}, p = 0; p < f.length; p++) o.prototype[f[p]] = m;
n.exports = o;
}, { "./compressedObject": 2, "./stream/DataWorker": 27, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31 }], 36: [function(t, n, i) {
(function(o) {
var s, a, l = o.MutationObserver || o.WebKitMutationObserver;
if (l) {
var h = 0, u = new l(c), f = o.document.createTextNode("");
u.observe(f, { characterData: !0 }), s = function() {
f.data = h = ++h % 2;
};
} else if (o.setImmediate || o.MessageChannel === void 0) s = "document" in o && "onreadystatechange" in o.document.createElement("script") ? function() {
var d = o.document.createElement("script");
d.onreadystatechange = function() {
c(), d.onreadystatechange = null, d.parentNode.removeChild(d), d = null;
}, o.document.documentElement.appendChild(d);
} : function() {
setTimeout(c, 0);
};
else {
var m = new o.MessageChannel();
m.port1.onmessage = c, s = function() {
m.port2.postMessage(0);
};
}
var p = [];
function c() {
var d, g;
a = !0;
for (var _ = p.length; _; ) {
for (g = p, p = [], d = -1; ++d < _; ) g[d]();
_ = p.length;
}
a = !1;
}
n.exports = function(d) {
p.push(d) !== 1 || a || s();
};
}).call(this, typeof Ut < "u" ? Ut : typeof self < "u" ? self : typeof window < "u" ? window : {});
}, {}], 37: [function(t, n, i) {
var o = t("immediate");
function s() {
}
var a = {}, l = ["REJECTED"], h = ["FULFILLED"], u = ["PENDING"];
function f(_) {
if (typeof _ != "function") throw new TypeError("resolver must be a function");
this.state = u, this.queue = [], this.outcome = void 0, _ !== s && d(this, _);
}
function m(_, w, b) {
this.promise = _, typeof w == "function" && (this.onFulfilled = w, this.callFulfilled = this.otherCallFulfilled), typeof b == "function" && (this.onRejected = b, this.callRejected = this.otherCallRejected);
}
function p(_, w, b) {
o(function() {
var T;
try {
T = w(b);
} catch (M) {
return a.reject(_, M);
}
T === _ ? a.reject(_, new TypeError("Cannot resolve promise with itself")) : a.resolve(_, T);
});
}
function c(_) {
var w = _ && _.then;
if (_ && (typeof _ == "object" || typeof _ == "function") && typeof w == "function") return function() {
w.apply(_, arguments);
};
}
function d(_, w) {
var b = !1;
function T(P) {
b || (b = !0, a.reject(_, P));
}
function M(P) {
b || (b = !0, a.resolve(_, P));
}
var C = g(function() {
w(M, T);
});
C.status === "error" && T(C.value);
}
function g(_, w) {
var b = {};
try {
b.value = _(w), b.status = "success";
} catch (T) {
b.status = "error", b.value = T;
}
return b;
}
(n.exports = f).prototype.finally = function(_) {
if (typeof _ != "function") return this;
var w = this.constructor;
return this.then(function(b) {
return w.resolve(_()).then(function() {
return b;
});
}, function(b) {
return w.resolve(_()).then(function() {
throw b;
});
});
}, f.prototype.catch = function(_) {
return this.then(null, _);
}, f.prototype.then = function(_, w) {
if (typeof _ != "function" && this.state === h || typeof w != "function" && this.state === l) return this;
var b = new this.constructor(s);
return this.state !== u ? p(b, this.state === h ? _ : w, this.outcome) : this.queue.push(new m(b, _, w)), b;
}, m.prototype.callFulfilled = function(_) {
a.resolve(this.promise, _);
}, m.prototype.otherCallFulfilled = function(_) {
p(this.promise, this.onFulfilled, _);
}, m.prototype.callRejected = function(_) {
a.reject(this.promise, _);
}, m.prototype.otherCallRejected = function(_) {
p(this.promise, this.onRejected, _);
}, a.resolve = function(_, w) {
var b = g(c, w);
if (b.status === "error") return a.reject(_, b.value);
var T = b.value;
if (T) d(_, T);
else {
_.state = h, _.outcome = w;
for (var M = -1, C = _.queue.length; ++M < C; ) _.queue[M].callFulfilled(w);
}
return _;
}, a.reject = function(_, w) {
_.state = l, _.outcome = w;
for (var b = -1, T = _.queue.length; ++b < T; ) _.queue[b].callRejected(w);
return _;
}, f.resolve = function(_) {
return _ instanceof this ? _ : a.resolve(new this(s), _);
}, f.reject = function(_) {
var w = new this(s);
return a.reject(w, _);
}, f.all = function(_) {
var w = this;
if (Object.prototype.toString.call(_) !== "[object Array]") return this.reject(new TypeError("must be an array"));
var b = _.length, T = !1;
if (!b) return this.resolve([]);
for (var M = new Array(b), C = 0, P = -1, B = new this(s); ++P < b; ) R(_[P], P);
return B;
function R(U, q) {
w.resolve(U).then(function(A) {
M[q] = A, ++C !== b || T || (T = !0, a.resolve(B, M));
}, function(A) {
T || (T = !0, a.reject(B, A));
});
}
}, f.race = function(_) {
var w = this;
if (Object.prototype.toString.call(_) !== "[object Array]") return this.reject(new TypeError("must be an array"));
var b = _.length, T = !1;
if (!b) return this.resolve([]);
for (var M = -1, C = new this(s); ++M < b; ) P = _[M], w.resolve(P).then(function(B) {
T || (T = !0, a.resolve(C, B));
}, function(B) {
T || (T = !0, a.reject(C, B));
});
var P;
return C;
};
}, { immediate: 36 }], 38: [function(t, n, i) {
var o = {};
(0, t("./lib/utils/common").assign)(o, t("./lib/deflate"), t("./lib/inflate"), t("./lib/zlib/constants")), n.exports = o;
}, { "./lib/deflate": 39, "./lib/inflate": 40, "./lib/utils/common": 41, "./lib/zlib/constants": 44 }], 39: [function(t, n, i) {
var o = t("./zlib/deflate"), s = t("./utils/common"), a = t("./utils/strings"), l = t("./zlib/messages"), h = t("./zlib/zstream"), u = Object.prototype.toString, f = 0, m = -1, p = 0, c = 8;
function d(_) {
if (!(this instanceof d)) return new d(_);
this.options = s.assign({ level: m, method: c, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: p, to: "" }, _ || {});
var w = this.options;
w.raw && 0 < w.windowBits ? w.windowBits = -w.windowBits : w.gzip && 0 < w.windowBits && w.windowBits < 16 && (w.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new h(), this.strm.avail_out = 0;
var b = o.deflateInit2(this.strm, w.level, w.method, w.windowBits, w.memLevel, w.strategy);
if (b !== f) throw new Error(l[b]);
if (w.header && o.deflateSetHeader(this.strm, w.header), w.dictionary) {
var T;
if (T = typeof w.dictionary == "string" ? a.string2buf(w.dictionary) : u.call(w.dictionary) === "[object ArrayBuffer]" ? new Uint8Array(w.dictionary) : w.dictionary, (b = o.deflateSetDictionary(this.strm, T)) !== f) throw new Error(l[b]);
this._dict_set = !0;
}
}
function g(_, w) {
var b = new d(w);
if (b.push(_, !0), b.err) throw b.msg || l[b.err];
return b.result;
}
d.prototype.push = function(_, w) {
var b, T, M = this.strm, C = this.options.chunkSize;
if (this.ended) return !1;
T = w === ~~w ? w : w === !0 ? 4 : 0, typeof _ == "string" ? M.input = a.string2buf(_) : u.call(_) === "[object ArrayBuffer]" ? M.input = new Uint8Array(_) : M.input = _, M.next_in = 0, M.avail_in = M.input.length;
do {
if (M.avail_out === 0 && (M.output = new s.Buf8(C), M.next_out = 0, M.avail_out = C), (b = o.deflate(M, T)) !== 1 && b !== f) return this.onEnd(b), !(this.ended = !0);
M.avail_out !== 0 && (M.avail_in !== 0 || T !== 4 && T !== 2) || (this.options.to === "string" ? this.onData(a.buf2binstring(s.shrinkBuf(M.output, M.next_out))) : this.onData(s.shrinkBuf(M.output, M.next_out)));
} while ((0 < M.avail_in || M.avail_out === 0) && b !== 1);
return T === 4 ? (b = o.deflateEnd(this.strm), this.onEnd(b), this.ended = !0, b === f) : T !== 2 || (this.onEnd(f), !(M.avail_out = 0));
}, d.prototype.onData = function(_) {
this.chunks.push(_);
}, d.prototype.onEnd = function(_) {
_ === f && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = s.flattenChunks(this.chunks)), this.chunks = [], this.err = _, this.msg = this.strm.msg;
}, i.Deflate = d, i.deflate = g, i.deflateRaw = function(_, w) {
return (w = w || {}).raw = !0, g(_, w);
}, i.gzip = function(_, w) {
return (w = w || {}).gzip = !0, g(_, w);
};
}, { "./utils/common": 41, "./utils/strings": 42, "./zlib/deflate": 46, "./zlib/messages": 51, "./zlib/zstream": 53 }], 40: [function(t, n, i) {
var o = t("./zlib/inflate"), s = t("./utils/common"), a = t("./utils/strings"), l = t("./zlib/constants"), h = t("./zlib/messages"), u = t("./zlib/zstream"), f = t("./zlib/gzheader"), m = Object.prototype.toString;
function p(d) {
if (!(this instanceof p)) return new p(d);
this.options = s.assign({ chunkSize: 16384, windowBits: 0, to: "" }, d || {});
var g = this.options;
g.raw && 0 <= g.windowBits && g.windowBits < 16 && (g.windowBits = -g.windowBits, g.windowBits === 0 && (g.windowBits = -15)), !(0 <= g.windowBits && g.windowBits < 16) || d && d.windowBits || (g.windowBits += 32), 15 < g.windowBits && g.windowBits < 48 && (15 & g.windowBits) == 0 && (g.windowBits |= 15), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new u(), this.strm.avail_out = 0;
var _ = o.inflateInit2(this.strm, g.windowBits);
if (_ !== l.Z_OK) throw new Error(h[_]);
this.header = new f(), o.inflateGetHeader(this.strm, this.header);
}
function c(d, g) {
var _ = new p(g);
if (_.push(d, !0), _.err) throw _.msg || h[_.err];
return _.result;
}
p.prototype.push = function(d, g) {
var _, w, b, T, M, C, P = this.strm, B = this.options.chunkSize, R = this.options.dictionary, U = !1;
if (this.ended) return !1;
w = g === ~~g ? g : g === !0 ? l.Z_FINISH : l.Z_NO_FLUSH, typeof d == "string" ? P.input = a.binstring2buf(d) : m.call(d) === "[object ArrayBuffer]" ? P.input = new Uint8Array(d) : P.input = d, P.next_in = 0, P.avail_in = P.input.length;
do {
if (P.avail_out === 0 && (P.output = new s.Buf8(B), P.next_out = 0, P.avail_out = B), (_ = o.inflate(P, l.Z_NO_FLUSH)) === l.Z_NEED_DICT && R && (C = typeof R == "string" ? a.string2buf(R) : m.call(R) === "[object ArrayBuffer]" ? new Uint8Array(R) : R, _ = o.inflateSetDictionary(this.strm, C)), _ === l.Z_BUF_ERROR && U === !0 && (_ = l.Z_OK, U = !1), _ !== l.Z_STREAM_END && _ !== l.Z_OK) return this.onEnd(_), !(this.ended = !0);
P.next_out && (P.avail_out !== 0 && _ !== l.Z_STREAM_END && (P.avail_in !== 0 || w !== l.Z_FINISH && w !== l.Z_SYNC_FLUSH) || (this.options.to === "string" ? (b = a.utf8border(P.output, P.next_out), T = P.next_out - b, M = a.buf2string(P.output, b), P.next_out = T, P.avail_out = B - T, T && s.arraySet(P.output, P.output, b, T, 0), this.onData(M)) : this.onData(s.shrinkBuf(P.output, P.next_out)))), P.avail_in === 0 && P.avail_out === 0 && (U = !0);
} while ((0 < P.avail_in || P.avail_out === 0) && _ !== l.Z_STREAM_END);
return _ === l.Z_STREAM_END && (w = l.Z_FINISH), w === l.Z_FINISH ? (_ = o.inflateEnd(this.strm), this.onEnd(_), this.ended = !0, _ === l.Z_OK) : w !== l.Z_SYNC_FLUSH || (this.onEnd(l.Z_OK), !(P.avail_out = 0));
}, p.prototype.onData = function(d) {
this.chunks.push(d);
}, p.prototype.onEnd = function(d) {
d === l.Z_OK && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = s.flattenChunks(this.chunks)), this.chunks = [], this.err = d, this.msg = this.strm.msg;
}, i.Inflate = p, i.inflate = c, i.inflateRaw = function(d, g) {
return (g = g || {}).raw = !0, c(d, g);
}, i.ungzip = c;
}, { "./utils/common": 41, "./utils/strings": 42, "./zlib/constants": 44, "./zlib/gzheader": 47, "./zlib/inflate": 49, "./zlib/messages": 51, "./zlib/zstream": 53 }], 41: [function(t, n, i) {
var o = typeof Uint8Array < "u" && typeof Uint16Array < "u" && typeof Int32Array < "u";
i.assign = function(l) {
for (var h = Array.prototype.slice.call(arguments, 1); h.length; ) {
var u = h.shift();
if (u) {
if (typeof u != "object") throw new TypeError(u + "must be non-object");
for (var f in u) u.hasOwnProperty(f) && (l[f] = u[f]);
}
}
return l;
}, i.shrinkBuf = function(l, h) {
return l.length === h ? l : l.subarray ? l.subarray(0, h) : (l.length = h, l);
};
var s = { arraySet: function(l, h, u, f, m) {
if (h.subarray && l.subarray) l.set(h.subarray(u, u + f), m);
else for (var p = 0; p < f; p++) l[m + p] = h[u + p];
}, flattenChunks: function(l) {
var h, u, f, m, p, c;
for (h = f = 0, u = l.length; h < u; h++) f += l[h].length;
for (c = new Uint8Array(f), h = m = 0, u = l.length; h < u; h++) p = l[h], c.set(p, m), m += p.length;
return c;
} }, a = { arraySet: function(l, h, u, f, m) {
for (var p = 0; p < f; p++) l[m + p] = h[u + p];
}, flattenChunks: function(l) {
return [].concat.apply([], l);
} };
i.setTyped = function(l) {
l ? (i.Buf8 = Uint8Array, i.Buf16 = Uint16Array, i.Buf32 = Int32Array, i.assign(i, s)) : (i.Buf8 = Array, i.Buf16 = Array, i.Buf32 = Array, i.assign(i, a));
}, i.setTyped(o);
}, {}], 42: [function(t, n, i) {
var o = t("./common"), s = !0, a = !0;
try {
String.fromCharCode.apply(null, [0]);
} catch {
s = !1;
}
try {
String.fromCharCode.apply(null, new Uint8Array(1));
} catch {
a = !1;
}
for (var l = new o.Buf8(256), h = 0; h < 256; h++) l[h] = 252 <= h ? 6 : 248 <= h ? 5 : 240 <= h ? 4 : 224 <= h ? 3 : 192 <= h ? 2 : 1;
function u(f, m) {
if (m < 65537 && (f.subarray && a || !f.subarray && s)) return String.fromCharCode.apply(null, o.shrinkBuf(f, m));
for (var p = "", c = 0; c < m; c++) p += String.fromCharCode(f[c]);
return p;
}
l[254] = l[254] = 1, i.string2buf = function(f) {
var m, p, c, d, g, _ = f.length, w = 0;
for (d = 0; d < _; d++) (64512 & (p = f.charCodeAt(d))) == 55296 && d + 1 < _ && (64512 & (c = f.charCodeAt(d + 1))) == 56320 && (p = 65536 + (p - 55296 << 10) + (c - 56320), d++), w += p < 128 ? 1 : p < 2048 ? 2 : p < 65536 ? 3 : 4;
for (m = new o.Buf8(w), d = g = 0; g < w; d++) (64512 & (p = f.charCodeAt(d))) == 55296 && d + 1 < _ && (64512 & (c = f.charCodeAt(d + 1))) == 56320 && (p = 65536 + (p - 55296 << 10) + (c - 56320), d++), p < 128 ? m[g++] = p : (p < 2048 ? m[g++] = 192 | p >>> 6 : (p < 65536 ? m[g++] = 224 | p >>> 12 : (m[g++] = 240 | p >>> 18, m[g++] = 128 | p >>> 12 & 63), m[g++] = 128 | p >>> 6 & 63), m[g++] = 128 | 63 & p);
return m;
}, i.buf2binstring = function(f) {
return u(f, f.length);
}, i.binstring2buf = function(f) {
for (var m = new o.Buf8(f.length), p = 0, c = m.length; p < c; p++) m[p] = f.charCodeAt(p);
return m;
}, i.buf2string = function(f, m) {
var p, c, d, g, _ = m || f.length, w = new Array(2 * _);
for (p = c = 0; p < _; ) if ((d = f[p++]) < 128) w[c++] = d;
else if (4 < (g = l[d])) w[c++] = 65533, p += g - 1;
else {
for (d &= g === 2 ? 31 : g === 3 ? 15 : 7; 1 < g && p < _; ) d = d << 6 | 63 & f[p++], g--;
1 < g ? w[c++] = 65533 : d < 65536 ? w[c++] = d : (d -= 65536, w[c++] = 55296 | d >> 10 & 1023, w[c++] = 56320 | 1023 & d);
}
return u(w, c);
}, i.utf8border = function(f, m) {
var p;
for ((m = m || f.length) > f.length && (m = f.length), p = m - 1; 0 <= p && (192 & f[p]) == 128; ) p--;
return p < 0 || p === 0 ? m : p + l[f[p]] > m ? p : m;
};
}, { "./common": 41 }], 43: [function(t, n, i) {
n.exports = function(o, s, a, l) {
for (var h = 65535 & o | 0, u = o >>> 16 & 65535 | 0, f = 0; a !== 0; ) {
for (a -= f = 2e3 < a ? 2e3 : a; u = u + (h = h + s[l++] | 0) | 0, --f; ) ;
h %= 65521, u %= 65521;
}
return h | u << 16 | 0;
};
}, {}], 44: [function(t, n, i) {
n.exports = { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BLOCK: 5, Z_TREES: 6, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1, Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_BUF_ERROR: -5, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4, Z_DEFAULT_STRATEGY: 0, Z_BINARY: 0, Z_TEXT: 1, Z_UNKNOWN: 2, Z_DEFLATED: 8 };
}, {}], 45: [function(t, n, i) {
var o = (function() {
for (var s, a = [], l = 0; l < 256; l++) {
s = l;
for (var h = 0; h < 8; h++) s = 1 & s ? 3988292384 ^ s >>> 1 : s >>> 1;
a[l] = s;
}
return a;
})();
n.exports = function(s, a, l, h) {
var u = o, f = h + l;
s ^= -1;
for (var m = h; m < f; m++) s = s >>> 8 ^ u[255 & (s ^ a[m])];
return -1 ^ s;
};
}, {}], 46: [function(t, n, i) {
var o, s = t("../utils/common"), a = t("./trees"), l = t("./adler32"), h = t("./crc32"), u = t("./messages"), f = 0, m = 4, p = 0, c = -2, d = -1, g = 4, _ = 2, w = 8, b = 9, T = 286, M = 30, C = 19, P = 2 * T + 1, B = 15, R = 3, U = 258, q = U + R + 1, A = 42, z = 113, x = 1, F = 2, J = 3, G = 4;
function ne(y, j) {
return y.msg = u[j], j;
}
function V(y) {
return (y << 1) - (4 < y ? 9 : 0);
}
function ee(y) {
for (var j = y.length; 0 <= --j; ) y[j] = 0;
}
function O(y) {
var j = y.state, I = j.pending;
I > y.avail_out && (I = y.avail_out), I !== 0 && (s.arraySet(y.output, j.pending_buf, j.pending_out, I, y.next_out), y.next_out += I, j.pending_out += I, y.total_out += I, y.avail_out -= I, j.pending -= I, j.pending === 0 && (j.pending_out = 0));
}
function D(y, j) {
a._tr_flush_block(y, 0 <= y.block_start ? y.block_start : -1, y.strstart - y.block_start, j), y.block_start = y.strstart, O(y.strm);
}
function Q(y, j) {
y.pending_buf[y.pending++] = j;
}
function Y(y, j) {
y.pending_buf[y.pending++] = j >>> 8 & 255, y.pending_buf[y.pending++] = 255 & j;
}
function Z(y, j) {
var I, E, S = y.max_chain_length, k = y.strstart, H = y.prev_length, W = y.nice_match, L = y.strstart > y.w_size - q ? y.strstart - (y.w_size - q) : 0, K = y.window, $ = y.w_mask, X = y.prev, te = y.strstart + U, le = K[k + H - 1], re = K[k + H];
y.prev_length >= y.good_match && (S >>= 2), W > y.lookahead && (W = y.lookahead);
do
if (K[(I = j) + H] === re && K[I + H - 1] === le && K[I] === K[k] && K[++I] === K[k + 1]) {
k += 2, I++;
do
;
while (K[++k] === K[++I] && K[++k] === K[++I] && K[++k] === K[++I] && K[++k] === K[++I] && K[++k] === K[++I] && K[++k] === K[++I] && K[++k] === K[++I] && K[++k] === K[++I] && k < te);
if (E = U - (te - k), k = te - U, H < E) {
if (y.match_start = j, W <= (H = E)) break;
le = K[k + H - 1], re = K[k + H];
}
}
while ((j = X[j & $]) > L && --S != 0);
return H <= y.lookahead ? H : y.lookahead;
}
function ue(y) {
var j, I, E, S, k, H, W, L, K, $, X = y.w_size;
do {
if (S = y.window_size - y.lookahead - y.strstart, y.strstart >= X + (X - q)) {
for (s.arraySet(y.window, y.window, X, X, 0), y.match_start -= X, y.strstart -= X, y.block_start -= X, j = I = y.hash_size; E = y.head[--j], y.head[j] = X <= E ? E - X : 0, --I; ) ;
for (j = I = X; E = y.prev[--j], y.prev[j] = X <= E ? E - X : 0, --I; ) ;
S += X;
}
if (y.strm.avail_in === 0) break;
if (H = y.strm, W = y.window, L = y.strstart + y.lookahead, K = S, $ = void 0, $ = H.avail_in, K < $ && ($ = K), I = $ === 0 ? 0 : (H.avail_in -= $, s.arraySet(W, H.input, H.next_in, $, L), H.state.wrap === 1 ? H.adler = l(H.adler, W, $, L) : H.state.wrap === 2 && (H.adler = h(H.adler, W, $, L)), H.next_in += $, H.total_in += $, $), y.lookahead += I, y.lookahead + y.insert >= R) for (k = y.strstart - y.insert, y.ins_h = y.window[k], y.ins_h = (y.ins_h << y.hash_shift ^ y.window[k + 1]) & y.hash_mask; y.insert && (y.ins_h = (y.ins_h << y.hash_shift ^ y.window[k + R - 1]) & y.hash_mask, y.prev[k & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = k, k++, y.insert--, !(y.lookahead + y.insert < R)); ) ;
} while (y.lookahead < q && y.strm.avail_in !== 0);
}
function fe(y, j) {
for (var I, E; ; ) {
if (y.lookahead < q) {
if (ue(y), y.lookahead < q && j === f) return x;
if (y.lookahead === 0) break;
}
if (I = 0, y.lookahead >= R && (y.ins_h = (y.ins_h << y.hash_shift ^ y.window[y.strstart + R - 1]) & y.hash_mask, I = y.prev[y.strstart & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = y.strstart), I !== 0 && y.strstart - I <= y.w_size - q && (y.match_length = Z(y, I)), y.match_length >= R) if (E = a._tr_tally(y, y.strstart - y.match_start, y.match_length - R), y.lookahead -= y.match_length, y.match_length <= y.max_lazy_match && y.lookahead >= R) {
for (y.match_length--; y.strstart++, y.ins_h = (y.ins_h << y.hash_shift ^ y.window[y.strstart + R - 1]) & y.hash_mask, I = y.prev[y.strstart & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = y.strstart, --y.match_length != 0; ) ;
y.strstart++;
} else y.strstart += y.match_length, y.match_length = 0, y.ins_h = y.window[y.strstart], y.ins_h = (y.ins_h << y.hash_shift ^ y.window[y.strstart + 1]) & y.hash_mask;
else E = a._tr_tally(y, 0, y.window[y.strstart]), y.lookahead--, y.strstart++;
if (E && (D(y, !1), y.strm.avail_out === 0)) return x;
}
return y.insert = y.strstart < R - 1 ? y.strstart : R - 1, j === m ? (D(y, !0), y.strm.avail_out === 0 ? J : G) : y.last_lit && (D(y, !1), y.strm.avail_out === 0) ? x : F;
}
function ie(y, j) {
for (var I, E, S; ; ) {
if (y.lookahead < q) {
if (ue(y), y.lookahead < q && j === f) return x;
if (y.lookahead === 0) break;
}
if (I = 0, y.lookahead >= R && (y.ins_h = (y.ins_h << y.hash_shift ^ y.window[y.strstart + R - 1]) & y.hash_mask, I = y.prev[y.strstart & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = y.strstart), y.prev_length = y.match_length, y.prev_match = y.match_start, y.match_length = R - 1, I !== 0 && y.prev_length < y.max_lazy_match && y.strstart - I <= y.w_size - q && (y.match_length = Z(y, I), y.match_length <= 5 && (y.strategy === 1 || y.match_length === R && 4096 < y.strstart - y.match_start) && (y.match_length = R - 1)), y.prev_length >= R && y.match_length <= y.prev_length) {
for (S = y.strstart + y.lookahead - R, E = a._tr_tally(y, y.strstart - 1 - y.prev_match, y.prev_length - R), y.lookahead -= y.prev_length - 1, y.prev_length -= 2; ++y.strstart <= S && (y.ins_h = (y.ins_h << y.hash_shift ^ y.window[y.strstart + R - 1]) & y.hash_mask, I = y.prev[y.strstart & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = y.strstart), --y.prev_length != 0; ) ;
if (y.match_available = 0, y.match_length = R - 1, y.strstart++, E && (D(y, !1), y.strm.avail_out === 0)) return x;
} else if (y.match_available) {
if ((E = a._tr_tally(y, 0, y.window[y.strstart - 1])) && D(y, !1), y.strstart++, y.lookahead--, y.strm.avail_out === 0) return x;
} else y.match_available = 1, y.strstart++, y.lookahead--;
}
return y.match_available && (E = a._tr_tally(y, 0, y.window[y.strstart - 1]), y.match_available = 0), y.insert = y.strstart < R - 1 ? y.strstart : R - 1, j === m ? (D(y, !0), y.strm.avail_out === 0 ? J : G) : y.last_lit && (D(y, !1), y.strm.avail_out === 0) ? x : F;
}
function oe(y, j, I, E, S) {
this.good_length = y, this.max_lazy = j, this.nice_length = I, this.max_chain = E, this.func = S;
}
function he() {
this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = w, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new s.Buf16(2 * P), this.dyn_dtree = new s.Buf16(2 * (2 * M + 1)), this.bl_tree = new s.Buf16(2 * (2 * C + 1)), ee(this.dyn_ltree), ee(this.dyn_dtree), ee(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new s.Buf16(B + 1), this.heap = new s.Buf16(2 * T + 1), ee(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new s.Buf16(2 * T + 1), ee(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0;
}
function me(y) {
var j;
return y && y.state ? (y.total_in = y.total_out = 0, y.data_type = _, (j = y.state).pending = 0, j.pending_out = 0, j.wrap < 0 && (j.wrap = -j.wrap), j.status = j.wrap ? A : z, y.adler = j.wrap === 2 ? 0 : 1, j.last_flush = f, a._tr_init(j), p) : ne(y, c);
}
function Te(y) {
var j = me(y);
return j === p && (function(I) {
I.window_size = 2 * I.w_size, ee(I.head), I.max_lazy_match = o[I.level].max_lazy, I.good_match = o[I.level].good_length, I.nice_match = o[I.level].nice_length, I.max_chain_length = o[I.level].max_chain, I.strstart = 0, I.block_start = 0, I.lookahead = 0, I.insert = 0, I.match_length = I.prev_length = R - 1, I.match_available = 0, I.ins_h = 0;
})(y.state), j;
}
function ve(y, j, I, E, S, k) {
if (!y) return c;
var H = 1;
if (j === d && (j = 6), E < 0 ? (H = 0, E = -E) : 15 < E && (H = 2, E -= 16), S < 1 || b < S || I !== w || E < 8 || 15 < E || j < 0 || 9 < j || k < 0 || g < k) return ne(y, c);
E === 8 && (E = 9);
var W = new he();
return (y.state = W).strm = y, W.wrap = H, W.gzhead = null, W.w_bits = E, W.w_size = 1 << W.w_bits, W.w_mask = W.w_size - 1, W.hash_bits = S + 7, W.hash_size = 1 << W.hash_bits, W.hash_mask = W.hash_size - 1, W.hash_shift = ~~((W.hash_bits + R - 1) / R), W.window = new s.Buf8(2 * W.w_size), W.head = new s.Buf16(W.hash_size), W.prev = new s.Buf16(W.w_size), W.lit_bufsize = 1 << S + 6, W.pending_buf_size = 4 * W.lit_bufsize, W.pending_buf = new s.Buf8(W.pending_buf_size), W.d_buf = 1 * W.lit_bufsize, W.l_buf = 3 * W.lit_bufsize, W.level = j, W.strategy = k, W.method = I, Te(y);
}
o = [new oe(0, 0, 0, 0, function(y, j) {
var I = 65535;
for (I > y.pending_buf_size - 5 && (I = y.pending_buf_size - 5); ; ) {
if (y.lookahead <= 1) {
if (ue(y), y.lookahead === 0 && j === f) return x;
if (y.lookahead === 0) break;
}
y.strstart += y.lookahead, y.lookahead = 0;
var E = y.block_start + I;
if ((y.strstart === 0 || y.strstart >= E) && (y.lookahead = y.strstart - E, y.strstart = E, D(y, !1), y.strm.avail_out === 0) || y.strstart - y.block_start >= y.w_size - q && (D(y, !1), y.strm.avail_out === 0)) return x;
}
return y.insert = 0, j === m ? (D(y, !0), y.strm.avail_out === 0 ? J : G) : (y.strstart > y.block_start && (D(y, !1), y.strm.avail_out), x);
}), new oe(4, 4, 8, 4, fe), new oe(4, 5, 16, 8, fe), new oe(4, 6, 32, 32, fe), new oe(4, 4, 16, 16, ie), new oe(8, 16, 32, 32, ie), new oe(8, 16, 128, 128, ie), new oe(8, 32, 128, 256, ie), new oe(32, 128, 258, 1024, ie), new oe(32, 258, 258, 4096, ie)], i.deflateInit = function(y, j) {
return ve(y, j, w, 15, 8, 0);
}, i.deflateInit2 = ve, i.deflateReset = Te, i.deflateResetKeep = me, i.deflateSetHeader = function(y, j) {
return y && y.state ? y.state.wrap !== 2 ? c : (y.state.gzhead = j, p) : c;
}, i.deflate = function(y, j) {
var I, E, S, k;
if (!y || !y.state || 5 < j || j < 0) return y ? ne(y, c) : c;
if (E = y.state, !y.output || !y.input && y.avail_in !== 0 || E.status === 666 && j !== m) return ne(y, y.avail_out === 0 ? -5 : c);
if (E.strm = y, I = E.last_flush, E.last_flush = j, E.status === A) if (E.wrap === 2) y.adler = 0, Q(E, 31), Q(E, 139), Q(E, 8), E.gzhead ? (Q(E, (E.gzhead.text ? 1 : 0) + (E.gzhead.hcrc ? 2 : 0) + (E.gzhead.extra ? 4 : 0) + (E.gzhead.name ? 8 : 0) + (E.gzhead.comment ? 16 : 0)), Q(E, 255 & E.gzhead.time), Q(E, E.gzhead.time >> 8 & 255), Q(E, E.gzhead.time >> 16 & 255), Q(E, E.gzhead.time >> 24 & 255), Q(E, E.level === 9 ? 2 : 2 <= E.strategy || E.level < 2 ? 4 : 0), Q(E, 255 & E.gzhead.os), E.gzhead.extra && E.gzhead.extra.length && (Q(E, 255 & E.gzhead.extra.length), Q(E, E.gzhead.extra.length >> 8 & 255)), E.gzhead.hcrc && (y.adler = h(y.adler, E.pending_buf, E.pending, 0)), E.gzindex = 0, E.status = 69) : (Q(E, 0), Q(E, 0), Q(E, 0), Q(E, 0), Q(E, 0), Q(E, E.level === 9 ? 2 : 2 <= E.strategy || E.level < 2 ? 4 : 0), Q(E, 3), E.status = z);
else {
var H = w + (E.w_bits - 8 << 4) << 8;
H |= (2 <= E.strategy || E.level < 2 ? 0 : E.level < 6 ? 1 : E.level === 6 ? 2 : 3) << 6, E.strstart !== 0 && (H |= 32), H += 31 - H % 31, E.status = z, Y(E, H), E.strstart !== 0 && (Y(E, y.adler >>> 16), Y(E, 65535 & y.adler)), y.adler = 1;
}
if (E.status === 69) if (E.gzhead.extra) {
for (S = E.pending; E.gzindex < (65535 & E.gzhead.extra.length) && (E.pending !== E.pending_buf_size || (E.gzhead.hcrc && E.pending > S && (y.adler = h(y.adler, E.pending_buf, E.pending - S, S)), O(y), S = E.pending, E.pending !== E.pending_buf_size)); ) Q(E, 255 & E.gzhead.extra[E.gzindex]), E.gzindex++;
E.gzhead.hcrc && E.pending > S && (y.adler = h(y.adler, E.pending_buf, E.pending - S, S)), E.gzindex === E.gzhead.extra.length && (E.gzindex = 0, E.status = 73);
} else E.status = 73;
if (E.status === 73) if (E.gzhead.name) {
S = E.pending;
do {
if (E.pending === E.pending_buf_size && (E.gzhead.hcrc && E.pending > S && (y.adler = h(y.adler, E.pending_buf, E.pending - S, S)), O(y), S = E.pending, E.pending === E.pending_buf_size)) {
k = 1;
break;
}
k = E.gzindex < E.gzhead.name.length ? 255 & E.gzhead.name.charCodeAt(E.gzindex++) : 0, Q(E, k);
} while (k !== 0);
E.gzhead.hcrc && E.pending > S && (y.adler = h(y.adler, E.pending_buf, E.pending - S, S)), k === 0 && (E.gzindex = 0, E.status = 91);
} else E.status = 91;
if (E.status === 91) if (E.gzhead.comment) {
S = E.pending;
do {
if (E.pending === E.pending_buf_size && (E.gzhead.hcrc && E.pending > S && (y.adler = h(y.adler, E.pending_buf, E.pending - S, S)), O(y), S = E.pending, E.pending === E.pending_buf_size)) {
k = 1;
break;
}
k = E.gzindex < E.gzhead.comment.length ? 255 & E.gzhead.comment.charCodeAt(E.gzindex++) : 0, Q(E, k);
} while (k !== 0);
E.gzhead.hcrc && E.pending > S && (y.adler = h(y.adler, E.pending_buf, E.pending - S, S)), k === 0 && (E.status = 103);
} else E.status = 103;
if (E.status === 103 && (E.gzhead.hcrc ? (E.pending + 2 > E.pending_buf_size && O(y), E.pending + 2 <= E.pending_buf_size && (Q(E, 255 & y.adler), Q(E, y.adler >> 8 & 255), y.adler = 0, E.status = z)) : E.status = z), E.pending !== 0) {
if (O(y), y.avail_out === 0) return E.last_flush = -1, p;
} else if (y.avail_in === 0 && V(j) <= V(I) && j !== m) return ne(y, -5);
if (E.status === 666 && y.avail_in !== 0) return ne(y, -5);
if (y.avail_in !== 0 || E.lookahead !== 0 || j !== f && E.status !== 666) {
var W = E.strategy === 2 ? (function(L, K) {
for (var $; ; ) {
if (L.lookahead === 0 && (ue(L), L.lookahead === 0)) {
if (K === f) return x;
break;
}
if (L.match_length = 0, $ = a._tr_tally(L, 0, L.window[L.strstart]), L.lookahead--, L.strstart++, $ && (D(L, !1), L.strm.avail_out === 0)) return x;
}
return L.insert = 0, K === m ? (D(L, !0), L.strm.avail_out === 0 ? J : G) : L.last_lit && (D(L, !1), L.strm.avail_out === 0) ? x : F;
})(E, j) : E.strategy === 3 ? (function(L, K) {
for (var $, X, te, le, re = L.window; ; ) {
if (L.lookahead <= U) {
if (ue(L), L.lookahead <= U && K === f) return x;
if (L.lookahead === 0) break;
}
if (L.match_length = 0, L.lookahead >= R && 0 < L.strstart && (X = re[te = L.strstart - 1]) === re[++te] && X === re[++te] && X === re[++te]) {
le = L.strstart + U;
do
;
while (X === re[++te] && X === re[++te] && X === re[++te] && X === re[++te] && X === re[++te] && X === re[++te] && X === re[++te] && X === re[++te] && te < le);
L.match_length = U - (le - te), L.match_length > L.lookahead && (L.match_length = L.lookahead);
}
if (L.match_length >= R ? ($ = a._tr_tally(L, 1, L.match_length - R), L.lookahead -= L.match_length, L.strstart += L.match_length, L.match_length = 0) : ($ = a._tr_tally(L, 0, L.window[L.strstart]), L.lookahead--, L.strstart++), $ && (D(L, !1), L.strm.avail_out === 0)) return x;
}
return L.insert = 0, K === m ? (D(L, !0), L.strm.avail_out === 0 ? J : G) : L.last_lit && (D(L, !1), L.strm.avail_out === 0) ? x : F;
})(E, j) : o[E.level].func(E, j);
if (W !== J && W !== G || (E.status = 666), W === x || W === J) return y.avail_out === 0 && (E.last_flush = -1), p;
if (W === F && (j === 1 ? a._tr_align(E) : j !== 5 && (a._tr_stored_block(E, 0, 0, !1), j === 3 && (ee(E.head), E.lookahead === 0 && (E.strstart = 0, E.block_start = 0, E.insert = 0))), O(y), y.avail_out === 0)) return E.last_flush = -1, p;
}
return j !== m ? p : E.wrap <= 0 ? 1 : (E.wrap === 2 ? (Q(E, 255 & y.adler), Q(E, y.adler >> 8 & 255), Q(E, y.adler >> 16 & 255), Q(E, y.adler >> 24 & 255), Q(E, 255 & y.total_in), Q(E, y.total_in >> 8 & 255), Q(E, y.total_in >> 16 & 255), Q(E, y.total_in >> 24 & 255)) : (Y(E, y.adler >>> 16), Y(E, 65535 & y.adler)), O(y), 0 < E.wrap && (E.wrap = -E.wrap), E.pending !== 0 ? p : 1);
}, i.deflateEnd = function(y) {
var j;
return y && y.state ? (j = y.state.status) !== A && j !== 69 && j !== 73 && j !== 91 && j !== 103 && j !== z && j !== 666 ? ne(y, c) : (y.state = null, j === z ? ne(y, -3) : p) : c;
}, i.deflateSetDictionary = function(y, j) {
var I, E, S, k, H, W, L, K, $ = j.length;
if (!y || !y.state || (k = (I = y.state).wrap) === 2 || k === 1 && I.status !== A || I.lookahead) return c;
for (k === 1 && (y.adler = l(y.adler, j, $, 0)), I.wrap = 0, $ >= I.w_size && (k === 0 && (ee(I.head), I.strstart = 0, I.block_start = 0, I.insert = 0), K = new s.Buf8(I.w_size), s.arraySet(K, j, $ - I.w_size, I.w_size, 0), j = K, $ = I.w_size), H = y.avail_in, W = y.next_in, L = y.input, y.avail_in = $, y.next_in = 0, y.input = j, ue(I); I.lookahead >= R; ) {
for (E = I.strstart, S = I.lookahead - (R - 1); I.ins_h = (I.ins_h << I.hash_shift ^ I.window[E + R - 1]) & I.hash_mask, I.prev[E & I.w_mask] = I.head[I.ins_h], I.head[I.ins_h] = E, E++, --S; ) ;
I.strstart = E, I.lookahead = R - 1, ue(I);
}
return I.strstart += I.lookahead, I.block_start = I.strstart, I.insert = I.lookahead, I.lookahead = 0, I.match_length = I.prev_length = R - 1, I.match_available = 0, y.next_in = W, y.input = L, y.avail_in = H, I.wrap = k, p;
}, i.deflateInfo = "pako deflate (from Nodeca project)";
}, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./messages": 51, "./trees": 52 }], 47: [function(t, n, i) {
n.exports = function() {
this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1;
};
}, {}], 48: [function(t, n, i) {
n.exports = function(o, s) {
var a, l, h, u, f, m, p, c, d, g, _, w, b, T, M, C, P, B, R, U, q, A, z, x, F;
a = o.state, l = o.next_in, x = o.input, h = l + (o.avail_in - 5), u = o.next_out, F = o.output, f = u - (s - o.avail_out), m = u + (o.avail_out - 257), p = a.dmax, c = a.wsize, d = a.whave, g = a.wnext, _ = a.window, w = a.hold, b = a.bits, T = a.lencode, M = a.distcode, C = (1 << a.lenbits) - 1, P = (1 << a.distbits) - 1;
e: do {
b < 15 && (w += x[l++] << b, b += 8, w += x[l++] << b, b += 8), B = T[w & C];
t: for (; ; ) {
if (w >>>= R = B >>> 24, b -= R, (R = B >>> 16 & 255) === 0) F[u++] = 65535 & B;
else {
if (!(16 & R)) {
if ((64 & R) == 0) {
B = T[(65535 & B) + (w & (1 << R) - 1)];
continue t;
}
if (32 & R) {
a.mode = 12;
break e;
}
o.msg = "invalid literal/length code", a.mode = 30;
break e;
}
U = 65535 & B, (R &= 15) && (b < R && (w += x[l++] << b, b += 8), U += w & (1 << R) - 1, w >>>= R, b -= R), b < 15 && (w += x[l++] << b, b += 8, w += x[l++] << b, b += 8), B = M[w & P];
n: for (; ; ) {
if (w >>>= R = B >>> 24, b -= R, !(16 & (R = B >>> 16 & 255))) {
if ((64 & R) == 0) {
B = M[(65535 & B) + (w & (1 << R) - 1)];
continue n;
}
o.msg = "invalid distance code", a.mode = 30;
break e;
}
if (q = 65535 & B, b < (R &= 15) && (w += x[l++] << b, (b += 8) < R && (w += x[l++] << b, b += 8)), p < (q += w & (1 << R) - 1)) {
o.msg = "invalid distance too far back", a.mode = 30;
break e;
}
if (w >>>= R, b -= R, (R = u - f) < q) {
if (d < (R = q - R) && a.sane) {
o.msg = "invalid distance too far back", a.mode = 30;
break e;
}
if (z = _, (A = 0) === g) {
if (A += c - R, R < U) {
for (U -= R; F[u++] = _[A++], --R; ) ;
A = u - q, z = F;
}
} else if (g < R) {
if (A += c + g - R, (R -= g) < U) {
for (U -= R; F[u++] = _[A++], --R; ) ;
if (A = 0, g < U) {
for (U -= R = g; F[u++] = _[A++], --R; ) ;
A = u - q, z = F;
}
}
} else if (A += g - R, R < U) {
for (U -= R; F[u++] = _[A++], --R; ) ;
A = u - q, z = F;
}
for (; 2 < U; ) F[u++] = z[A++], F[u++] = z[A++], F[u++] = z[A++], U -= 3;
U && (F[u++] = z[A++], 1 < U && (F[u++] = z[A++]));
} else {
for (A = u - q; F[u++] = F[A++], F[u++] = F[A++], F[u++] = F[A++], 2 < (U -= 3); ) ;
U && (F[u++] = F[A++], 1 < U && (F[u++] = F[A++]));
}
break;
}
}
break;
}
} while (l < h && u < m);
l -= U = b >> 3, w &= (1 << (b -= U << 3)) - 1, o.next_in = l, o.next_out = u, o.avail_in = l < h ? h - l + 5 : 5 - (l - h), o.avail_out = u < m ? m - u + 257 : 257 - (u - m), a.hold = w, a.bits = b;
};
}, {}], 49: [function(t, n, i) {
var o = t("../utils/common"), s = t("./adler32"), a = t("./crc32"), l = t("./inffast"), h = t("./inftrees"), u = 1, f = 2, m = 0, p = -2, c = 1, d = 852, g = 592;
function _(A) {
return (A >>> 24 & 255) + (A >>> 8 & 65280) + ((65280 & A) << 8) + ((255 & A) << 24);
}
function w() {
this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new o.Buf16(320), this.work = new o.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0;
}
function b(A) {
var z;
return A && A.state ? (z = A.state, A.total_in = A.total_out = z.total = 0, A.msg = "", z.wrap && (A.adler = 1 & z.wrap), z.mode = c, z.last = 0, z.havedict = 0, z.dmax = 32768, z.head = null, z.hold = 0, z.bits = 0, z.lencode = z.lendyn = new o.Buf32(d), z.distcode = z.distdyn = new o.Buf32(g), z.sane = 1, z.back = -1, m) : p;
}
function T(A) {
var z;
return A && A.state ? ((z = A.state).wsize = 0, z.whave = 0, z.wnext = 0, b(A)) : p;
}
function M(A, z) {
var x, F;
return A && A.state ? (F = A.state, z < 0 ? (x = 0, z = -z) : (x = 1 + (z >> 4), z < 48 && (z &= 15)), z && (z < 8 || 15 < z) ? p : (F.window !== null && F.wbits !== z && (F.window = null), F.wrap = x, F.wbits = z, T(A))) : p;
}
function C(A, z) {
var x, F;
return A ? (F = new w(), (A.state = F).window = null, (x = M(A, z)) !== m && (A.state = null), x) : p;
}
var P, B, R = !0;
function U(A) {
if (R) {
var z;
for (P = new o.Buf32(512), B = new o.Buf32(32), z = 0; z < 144; ) A.lens[z++] = 8;
for (; z < 256; ) A.lens[z++] = 9;
for (; z < 280; ) A.lens[z++] = 7;
for (; z < 288; ) A.lens[z++] = 8;
for (h(u, A.lens, 0, 288, P, 0, A.work, { bits: 9 }), z = 0; z < 32; ) A.lens[z++] = 5;
h(f, A.lens, 0, 32, B, 0, A.work, { bits: 5 }), R = !1;
}
A.lencode = P, A.lenbits = 9, A.distcode = B, A.distbits = 5;
}
function q(A, z, x, F) {
var J, G = A.state;
return G.window === null && (G.wsize = 1 << G.wbits, G.wnext = 0, G.whave = 0, G.window = new o.Buf8(G.wsize)), F >= G.wsize ? (o.arraySet(G.window, z, x - G.wsize, G.wsize, 0), G.wnext = 0, G.whave = G.wsize) : (F < (J = G.wsize - G.wnext) && (J = F), o.arraySet(G.window, z, x - F, J, G.wnext), (F -= J) ? (o.arraySet(G.window, z, x - F, F, 0), G.wnext = F, G.whave = G.wsize) : (G.wnext += J, G.wnext === G.wsize && (G.wnext = 0), G.whave < G.wsize && (G.whave += J))), 0;
}
i.inflateReset = T, i.inflateReset2 = M, i.inflateResetKeep = b, i.inflateInit = function(A) {
return C(A, 15);
}, i.inflateInit2 = C, i.inflate = function(A, z) {
var x, F, J, G, ne, V, ee, O, D, Q, Y, Z, ue, fe, ie, oe, he, me, Te, ve, y, j, I, E, S = 0, k = new o.Buf8(4), H = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
if (!A || !A.state || !A.output || !A.input && A.avail_in !== 0) return p;
(x = A.state).mode === 12 && (x.mode = 13), ne = A.next_out, J = A.output, ee = A.avail_out, G = A.next_in, F = A.input, V = A.avail_in, O = x.hold, D = x.bits, Q = V, Y = ee, j = m;
e: for (; ; ) switch (x.mode) {
case c:
if (x.wrap === 0) {
x.mode = 13;
break;
}
for (; D < 16; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if (2 & x.wrap && O === 35615) {
k[x.check = 0] = 255 & O, k[1] = O >>> 8 & 255, x.check = a(x.check, k, 2, 0), D = O = 0, x.mode = 2;
break;
}
if (x.flags = 0, x.head && (x.head.done = !1), !(1 & x.wrap) || (((255 & O) << 8) + (O >> 8)) % 31) {
A.msg = "incorrect header check", x.mode = 30;
break;
}
if ((15 & O) != 8) {
A.msg = "unknown compression method", x.mode = 30;
break;
}
if (D -= 4, y = 8 + (15 & (O >>>= 4)), x.wbits === 0) x.wbits = y;
else if (y > x.wbits) {
A.msg = "invalid window size", x.mode = 30;
break;
}
x.dmax = 1 << y, A.adler = x.check = 1, x.mode = 512 & O ? 10 : 12, D = O = 0;
break;
case 2:
for (; D < 16; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if (x.flags = O, (255 & x.flags) != 8) {
A.msg = "unknown compression method", x.mode = 30;
break;
}
if (57344 & x.flags) {
A.msg = "unknown header flags set", x.mode = 30;
break;
}
x.head && (x.head.text = O >> 8 & 1), 512 & x.flags && (k[0] = 255 & O, k[1] = O >>> 8 & 255, x.check = a(x.check, k, 2, 0)), D = O = 0, x.mode = 3;
case 3:
for (; D < 32; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
x.head && (x.head.time = O), 512 & x.flags && (k[0] = 255 & O, k[1] = O >>> 8 & 255, k[2] = O >>> 16 & 255, k[3] = O >>> 24 & 255, x.check = a(x.check, k, 4, 0)), D = O = 0, x.mode = 4;
case 4:
for (; D < 16; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
x.head && (x.head.xflags = 255 & O, x.head.os = O >> 8), 512 & x.flags && (k[0] = 255 & O, k[1] = O >>> 8 & 255, x.check = a(x.check, k, 2, 0)), D = O = 0, x.mode = 5;
case 5:
if (1024 & x.flags) {
for (; D < 16; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
x.length = O, x.head && (x.head.extra_len = O), 512 & x.flags && (k[0] = 255 & O, k[1] = O >>> 8 & 255, x.check = a(x.check, k, 2, 0)), D = O = 0;
} else x.head && (x.head.extra = null);
x.mode = 6;
case 6:
if (1024 & x.flags && (V < (Z = x.length) && (Z = V), Z && (x.head && (y = x.head.extra_len - x.length, x.head.extra || (x.head.extra = new Array(x.head.extra_len)), o.arraySet(x.head.extra, F, G, Z, y)), 512 & x.flags && (x.check = a(x.check, F, Z, G)), V -= Z, G += Z, x.length -= Z), x.length)) break e;
x.length = 0, x.mode = 7;
case 7:
if (2048 & x.flags) {
if (V === 0) break e;
for (Z = 0; y = F[G + Z++], x.head && y && x.length < 65536 && (x.head.name += String.fromCharCode(y)), y && Z < V; ) ;
if (512 & x.flags && (x.check = a(x.check, F, Z, G)), V -= Z, G += Z, y) break e;
} else x.head && (x.head.name = null);
x.length = 0, x.mode = 8;
case 8:
if (4096 & x.flags) {
if (V === 0) break e;
for (Z = 0; y = F[G + Z++], x.head && y && x.length < 65536 && (x.head.comment += String.fromCharCode(y)), y && Z < V; ) ;
if (512 & x.flags && (x.check = a(x.check, F, Z, G)), V -= Z, G += Z, y) break e;
} else x.head && (x.head.comment = null);
x.mode = 9;
case 9:
if (512 & x.flags) {
for (; D < 16; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if (O !== (65535 & x.check)) {
A.msg = "header crc mismatch", x.mode = 30;
break;
}
D = O = 0;
}
x.head && (x.head.hcrc = x.flags >> 9 & 1, x.head.done = !0), A.adler = x.check = 0, x.mode = 12;
break;
case 10:
for (; D < 32; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
A.adler = x.check = _(O), D = O = 0, x.mode = 11;
case 11:
if (x.havedict === 0) return A.next_out = ne, A.avail_out = ee, A.next_in = G, A.avail_in = V, x.hold = O, x.bits = D, 2;
A.adler = x.check = 1, x.mode = 12;
case 12:
if (z === 5 || z === 6) break e;
case 13:
if (x.last) {
O >>>= 7 & D, D -= 7 & D, x.mode = 27;
break;
}
for (; D < 3; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
switch (x.last = 1 & O, D -= 1, 3 & (O >>>= 1)) {
case 0:
x.mode = 14;
break;
case 1:
if (U(x), x.mode = 20, z !== 6) break;
O >>>= 2, D -= 2;
break e;
case 2:
x.mode = 17;
break;
case 3:
A.msg = "invalid block type", x.mode = 30;
}
O >>>= 2, D -= 2;
break;
case 14:
for (O >>>= 7 & D, D -= 7 & D; D < 32; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if ((65535 & O) != (O >>> 16 ^ 65535)) {
A.msg = "invalid stored block lengths", x.mode = 30;
break;
}
if (x.length = 65535 & O, D = O = 0, x.mode = 15, z === 6) break e;
case 15:
x.mode = 16;
case 16:
if (Z = x.length) {
if (V < Z && (Z = V), ee < Z && (Z = ee), Z === 0) break e;
o.arraySet(J, F, G, Z, ne), V -= Z, G += Z, ee -= Z, ne += Z, x.length -= Z;
break;
}
x.mode = 12;
break;
case 17:
for (; D < 14; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if (x.nlen = 257 + (31 & O), O >>>= 5, D -= 5, x.ndist = 1 + (31 & O), O >>>= 5, D -= 5, x.ncode = 4 + (15 & O), O >>>= 4, D -= 4, 286 < x.nlen || 30 < x.ndist) {
A.msg = "too many length or distance symbols", x.mode = 30;
break;
}
x.have = 0, x.mode = 18;
case 18:
for (; x.have < x.ncode; ) {
for (; D < 3; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
x.lens[H[x.have++]] = 7 & O, O >>>= 3, D -= 3;
}
for (; x.have < 19; ) x.lens[H[x.have++]] = 0;
if (x.lencode = x.lendyn, x.lenbits = 7, I = { bits: x.lenbits }, j = h(0, x.lens, 0, 19, x.lencode, 0, x.work, I), x.lenbits = I.bits, j) {
A.msg = "invalid code lengths set", x.mode = 30;
break;
}
x.have = 0, x.mode = 19;
case 19:
for (; x.have < x.nlen + x.ndist; ) {
for (; oe = (S = x.lencode[O & (1 << x.lenbits) - 1]) >>> 16 & 255, he = 65535 & S, !((ie = S >>> 24) <= D); ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if (he < 16) O >>>= ie, D -= ie, x.lens[x.have++] = he;
else {
if (he === 16) {
for (E = ie + 2; D < E; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if (O >>>= ie, D -= ie, x.have === 0) {
A.msg = "invalid bit length repeat", x.mode = 30;
break;
}
y = x.lens[x.have - 1], Z = 3 + (3 & O), O >>>= 2, D -= 2;
} else if (he === 17) {
for (E = ie + 3; D < E; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
D -= ie, y = 0, Z = 3 + (7 & (O >>>= ie)), O >>>= 3, D -= 3;
} else {
for (E = ie + 7; D < E; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
D -= ie, y = 0, Z = 11 + (127 & (O >>>= ie)), O >>>= 7, D -= 7;
}
if (x.have + Z > x.nlen + x.ndist) {
A.msg = "invalid bit length repeat", x.mode = 30;
break;
}
for (; Z--; ) x.lens[x.have++] = y;
}
}
if (x.mode === 30) break;
if (x.lens[256] === 0) {
A.msg = "invalid code -- missing end-of-block", x.mode = 30;
break;
}
if (x.lenbits = 9, I = { bits: x.lenbits }, j = h(u, x.lens, 0, x.nlen, x.lencode, 0, x.work, I), x.lenbits = I.bits, j) {
A.msg = "invalid literal/lengths set", x.mode = 30;
break;
}
if (x.distbits = 6, x.distcode = x.distdyn, I = { bits: x.distbits }, j = h(f, x.lens, x.nlen, x.ndist, x.distcode, 0, x.work, I), x.distbits = I.bits, j) {
A.msg = "invalid distances set", x.mode = 30;
break;
}
if (x.mode = 20, z === 6) break e;
case 20:
x.mode = 21;
case 21:
if (6 <= V && 258 <= ee) {
A.next_out = ne, A.avail_out = ee, A.next_in = G, A.avail_in = V, x.hold = O, x.bits = D, l(A, Y), ne = A.next_out, J = A.output, ee = A.avail_out, G = A.next_in, F = A.input, V = A.avail_in, O = x.hold, D = x.bits, x.mode === 12 && (x.back = -1);
break;
}
for (x.back = 0; oe = (S = x.lencode[O & (1 << x.lenbits) - 1]) >>> 16 & 255, he = 65535 & S, !((ie = S >>> 24) <= D); ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if (oe && (240 & oe) == 0) {
for (me = ie, Te = oe, ve = he; oe = (S = x.lencode[ve + ((O & (1 << me + Te) - 1) >> me)]) >>> 16 & 255, he = 65535 & S, !(me + (ie = S >>> 24) <= D); ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
O >>>= me, D -= me, x.back += me;
}
if (O >>>= ie, D -= ie, x.back += ie, x.length = he, oe === 0) {
x.mode = 26;
break;
}
if (32 & oe) {
x.back = -1, x.mode = 12;
break;
}
if (64 & oe) {
A.msg = "invalid literal/length code", x.mode = 30;
break;
}
x.extra = 15 & oe, x.mode = 22;
case 22:
if (x.extra) {
for (E = x.extra; D < E; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
x.length += O & (1 << x.extra) - 1, O >>>= x.extra, D -= x.extra, x.back += x.extra;
}
x.was = x.length, x.mode = 23;
case 23:
for (; oe = (S = x.distcode[O & (1 << x.distbits) - 1]) >>> 16 & 255, he = 65535 & S, !((ie = S >>> 24) <= D); ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if ((240 & oe) == 0) {
for (me = ie, Te = oe, ve = he; oe = (S = x.distcode[ve + ((O & (1 << me + Te) - 1) >> me)]) >>> 16 & 255, he = 65535 & S, !(me + (ie = S >>> 24) <= D); ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
O >>>= me, D -= me, x.back += me;
}
if (O >>>= ie, D -= ie, x.back += ie, 64 & oe) {
A.msg = "invalid distance code", x.mode = 30;
break;
}
x.offset = he, x.extra = 15 & oe, x.mode = 24;
case 24:
if (x.extra) {
for (E = x.extra; D < E; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
x.offset += O & (1 << x.extra) - 1, O >>>= x.extra, D -= x.extra, x.back += x.extra;
}
if (x.offset > x.dmax) {
A.msg = "invalid distance too far back", x.mode = 30;
break;
}
x.mode = 25;
case 25:
if (ee === 0) break e;
if (Z = Y - ee, x.offset > Z) {
if ((Z = x.offset - Z) > x.whave && x.sane) {
A.msg = "invalid distance too far back", x.mode = 30;
break;
}
ue = Z > x.wnext ? (Z -= x.wnext, x.wsize - Z) : x.wnext - Z, Z > x.length && (Z = x.length), fe = x.window;
} else fe = J, ue = ne - x.offset, Z = x.length;
for (ee < Z && (Z = ee), ee -= Z, x.length -= Z; J[ne++] = fe[ue++], --Z; ) ;
x.length === 0 && (x.mode = 21);
break;
case 26:
if (ee === 0) break e;
J[ne++] = x.length, ee--, x.mode = 21;
break;
case 27:
if (x.wrap) {
for (; D < 32; ) {
if (V === 0) break e;
V--, O |= F[G++] << D, D += 8;
}
if (Y -= ee, A.total_out += Y, x.total += Y, Y && (A.adler = x.check = x.flags ? a(x.check, J, Y, ne - Y) : s(x.check, J, Y, ne - Y)), Y = ee, (x.flags ? O : _(O)) !== x.check) {
A.msg = "incorrect data check", x.mode = 30;
break;
}
D = O = 0;
}
x.mode = 28;
case 28:
if (x.wrap && x.flags) {
for (; D < 32; ) {
if (V === 0) break e;
V--, O += F[G++] << D, D += 8;
}
if (O !== (4294967295 & x.total)) {
A.msg = "incorrect length check", x.mode = 30;
break;
}
D = O = 0;
}
x.mode = 29;
case 29:
j = 1;
break e;
case 30:
j = -3;
break e;
case 31:
return -4;
case 32:
default:
return p;
}
return A.next_out = ne, A.avail_out = ee, A.next_in = G, A.avail_in = V, x.hold = O, x.bits = D, (x.wsize || Y !== A.avail_out && x.mode < 30 && (x.mode < 27 || z !== 4)) && q(A, A.output, A.next_out, Y - A.avail_out) ? (x.mode = 31, -4) : (Q -= A.avail_in, Y -= A.avail_out, A.total_in += Q, A.total_out += Y, x.total += Y, x.wrap && Y && (A.adler = x.check = x.flags ? a(x.check, J, Y, A.next_out - Y) : s(x.check, J, Y, A.next_out - Y)), A.data_type = x.bits + (x.last ? 64 : 0) + (x.mode === 12 ? 128 : 0) + (x.mode === 20 || x.mode === 15 ? 256 : 0), (Q == 0 && Y === 0 || z === 4) && j === m && (j = -5), j);
}, i.inflateEnd = function(A) {
if (!A || !A.state) return p;
var z = A.state;
return z.window && (z.window = null), A.state = null, m;
}, i.inflateGetHeader = function(A, z) {
var x;
return A && A.state ? (2 & (x = A.state).wrap) == 0 ? p : ((x.head = z).done = !1, m) : p;
}, i.inflateSetDictionary = function(A, z) {
var x, F = z.length;
return A && A.state ? (x = A.state).wrap !== 0 && x.mode !== 11 ? p : x.mode === 11 && s(1, z, F, 0) !== x.check ? -3 : q(A, z, F, F) ? (x.mode = 31, -4) : (x.havedict = 1, m) : p;
}, i.inflateInfo = "pako inflate (from Nodeca project)";
}, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./inffast": 48, "./inftrees": 50 }], 50: [function(t, n, i) {
var o = t("../utils/common"), s = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0], a = [16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78], l = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0], h = [16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64];
n.exports = function(u, f, m, p, c, d, g, _) {
var w, b, T, M, C, P, B, R, U, q = _.bits, A = 0, z = 0, x = 0, F = 0, J = 0, G = 0, ne = 0, V = 0, ee = 0, O = 0, D = null, Q = 0, Y = new o.Buf16(16), Z = new o.Buf16(16), ue = null, fe = 0;
for (A = 0; A <= 15; A++) Y[A] = 0;
for (z = 0; z < p; z++) Y[f[m + z]]++;
for (J = q, F = 15; 1 <= F && Y[F] === 0; F--) ;
if (F < J && (J = F), F === 0) return c[d++] = 20971520, c[d++] = 20971520, _.bits = 1, 0;
for (x = 1; x < F && Y[x] === 0; x++) ;
for (J < x && (J = x), A = V = 1; A <= 15; A++) if (V <<= 1, (V -= Y[A]) < 0) return -1;
if (0 < V && (u === 0 || F !== 1)) return -1;
for (Z[1] = 0, A = 1; A < 15; A++) Z[A + 1] = Z[A] + Y[A];
for (z = 0; z < p; z++) f[m + z] !== 0 && (g[Z[f[m + z]]++] = z);
if (P = u === 0 ? (D = ue = g, 19) : u === 1 ? (D = s, Q -= 257, ue = a, fe -= 257, 256) : (D = l, ue = h, -1), A = x, C = d, ne = z = O = 0, T = -1, M = (ee = 1 << (G = J)) - 1, u === 1 && 852 < ee || u === 2 && 592 < ee) return 1;
for (; ; ) {
for (B = A - ne, U = g[z] < P ? (R = 0, g[z]) : g[z] > P ? (R = ue[fe + g[z]], D[Q + g[z]]) : (R = 96, 0), w = 1 << A - ne, x = b = 1 << G; c[C + (O >> ne) + (b -= w)] = B << 24 | R << 16 | U | 0, b !== 0; ) ;
for (w = 1 << A - 1; O & w; ) w >>= 1;
if (w !== 0 ? (O &= w - 1, O += w) : O = 0, z++, --Y[A] == 0) {
if (A === F) break;
A = f[m + g[z]];
}
if (J < A && (O & M) !== T) {
for (ne === 0 && (ne = J), C += x, V = 1 << (G = A - ne); G + ne < F && !((V -= Y[G + ne]) <= 0); ) G++, V <<= 1;
if (ee += 1 << G, u === 1 && 852 < ee || u === 2 && 592 < ee) return 1;
c[T = O & M] = J << 24 | G << 16 | C - d | 0;
}
}
return O !== 0 && (c[C + O] = A - ne << 24 | 64 << 16 | 0), _.bits = J, 0;
};
}, { "../utils/common": 41 }], 51: [function(t, n, i) {
n.exports = { 2: "need dictionary", 1: "stream end", 0: "", "-1": "file error", "-2": "stream error", "-3": "data error", "-4": "insufficient memory", "-5": "buffer error", "-6": "incompatible version" };
}, {}], 52: [function(t, n, i) {
var o = t("../utils/common"), s = 0, a = 1;
function l(S) {
for (var k = S.length; 0 <= --k; ) S[k] = 0;
}
var h = 0, u = 29, f = 256, m = f + 1 + u, p = 30, c = 19, d = 2 * m + 1, g = 15, _ = 16, w = 7, b = 256, T = 16, M = 17, C = 18, P = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], B = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13], R = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7], U = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], q = new Array(2 * (m + 2));
l(q);
var A = new Array(2 * p);
l(A);
var z = new Array(512);
l(z);
var x = new Array(256);
l(x);
var F = new Array(u);
l(F);
var J, G, ne, V = new Array(p);
function ee(S, k, H, W, L) {
this.static_tree = S, this.extra_bits = k, this.extra_base = H, this.elems = W, this.max_length = L, this.has_stree = S && S.length;
}
function O(S, k) {
this.dyn_tree = S, this.max_code = 0, this.stat_desc = k;
}
function D(S) {
return S < 256 ? z[S] : z[256 + (S >>> 7)];
}
function Q(S, k) {
S.pending_buf[S.pending++] = 255 & k, S.pending_buf[S.pending++] = k >>> 8 & 255;
}
function Y(S, k, H) {
S.bi_valid > _ - H ? (S.bi_buf |= k << S.bi_valid & 65535, Q(S, S.bi_buf), S.bi_buf = k >> _ - S.bi_valid, S.bi_valid += H - _) : (S.bi_buf |= k << S.bi_valid & 65535, S.bi_valid += H);
}
function Z(S, k, H) {
Y(S, H[2 * k], H[2 * k + 1]);
}
function ue(S, k) {
for (var H = 0; H |= 1 & S, S >>>= 1, H <<= 1, 0 < --k; ) ;
return H >>> 1;
}
function fe(S, k, H) {
var W, L, K = new Array(g + 1), $ = 0;
for (W = 1; W <= g; W++) K[W] = $ = $ + H[W - 1] << 1;
for (L = 0; L <= k; L++) {
var X = S[2 * L + 1];
X !== 0 && (S[2 * L] = ue(K[X]++, X));
}
}
function ie(S) {
var k;
for (k = 0; k < m; k++) S.dyn_ltree[2 * k] = 0;
for (k = 0; k < p; k++) S.dyn_dtree[2 * k] = 0;
for (k = 0; k < c; k++) S.bl_tree[2 * k] = 0;
S.dyn_ltree[2 * b] = 1, S.opt_len = S.static_len = 0, S.last_lit = S.matches = 0;
}
function oe(S) {
8 < S.bi_valid ? Q(S, S.bi_buf) : 0 < S.bi_valid && (S.pending_buf[S.pending++] = S.bi_buf), S.bi_buf = 0, S.bi_valid = 0;
}
function he(S, k, H, W) {
var L = 2 * k, K = 2 * H;
return S[L] < S[K] || S[L] === S[K] && W[k] <= W[H];
}
function me(S, k, H) {
for (var W = S.heap[H], L = H << 1; L <= S.heap_len && (L < S.heap_len && he(k, S.heap[L + 1], S.heap[L], S.depth) && L++, !he(k, W, S.heap[L], S.depth)); ) S.heap[H] = S.heap[L], H = L, L <<= 1;
S.heap[H] = W;
}
function Te(S, k, H) {
var W, L, K, $, X = 0;
if (S.last_lit !== 0) for (; W = S.pending_buf[S.d_buf + 2 * X] << 8 | S.pending_buf[S.d_buf + 2 * X + 1], L = S.pending_buf[S.l_buf + X], X++, W === 0 ? Z(S, L, k) : (Z(S, (K = x[L]) + f + 1, k), ($ = P[K]) !== 0 && Y(S, L -= F[K], $), Z(S, K = D(--W), H), ($ = B[K]) !== 0 && Y(S, W -= V[K], $)), X < S.last_lit; ) ;
Z(S, b, k);
}
function ve(S, k) {
var H, W, L, K = k.dyn_tree, $ = k.stat_desc.static_tree, X = k.stat_desc.has_stree, te = k.stat_desc.elems, le = -1;
for (S.heap_len = 0, S.heap_max = d, H = 0; H < te; H++) K[2 * H] !== 0 ? (S.heap[++S.heap_len] = le = H, S.depth[H] = 0) : K[2 * H + 1] = 0;
for (; S.heap_len < 2; ) K[2 * (L = S.heap[++S.heap_len] = le < 2 ? ++le : 0)] = 1, S.depth[L] = 0, S.opt_len--, X && (S.static_len -= $[2 * L + 1]);
for (k.max_code = le, H = S.heap_len >> 1; 1 <= H; H--) me(S, K, H);
for (L = te; H = S.heap[1], S.heap[1] = S.heap[S.heap_len--], me(S, K, 1), W = S.heap[1], S.heap[--S.heap_max] = H, S.heap[--S.heap_max] = W, K[2 * L] = K[2 * H] + K[2 * W], S.depth[L] = (S.depth[H] >= S.depth[W] ? S.depth[H] : S.depth[W]) + 1, K[2 * H + 1] = K[2 * W + 1] = L, S.heap[1] = L++, me(S, K, 1), 2 <= S.heap_len; ) ;
S.heap[--S.heap_max] = S.heap[1], (function(re, we) {
var Pe, xe, qe, ge, at, xt, Re = we.dyn_tree, Ge = we.max_code, Ye = we.stat_desc.static_tree, $e = we.stat_desc.has_stree, Je = we.stat_desc.extra_bits, We = we.stat_desc.extra_base, bt = we.stat_desc.max_length, Rt = 0;
for (ge = 0; ge <= g; ge++) re.bl_count[ge] = 0;
for (Re[2 * re.heap[re.heap_max] + 1] = 0, Pe = re.heap_max + 1; Pe < d; Pe++) bt < (ge = Re[2 * Re[2 * (xe = re.heap[Pe]) + 1] + 1] + 1) && (ge = bt, Rt++), Re[2 * xe + 1] = ge, Ge < xe || (re.bl_count[ge]++, at = 0, We <= xe && (at = Je[xe - We]), xt = Re[2 * xe], re.opt_len += xt * (ge + at), $e && (re.static_len += xt * (Ye[2 * xe + 1] + at)));
if (Rt !== 0) {
do {
for (ge = bt - 1; re.bl_count[ge] === 0; ) ge--;
re.bl_count[ge]--, re.bl_count[ge + 1] += 2, re.bl_count[bt]--, Rt -= 2;
} while (0 < Rt);
for (ge = bt; ge !== 0; ge--) for (xe = re.bl_count[ge]; xe !== 0; ) Ge < (qe = re.heap[--Pe]) || (Re[2 * qe + 1] !== ge && (re.opt_len += (ge - Re[2 * qe + 1]) * Re[2 * qe], Re[2 * qe + 1] = ge), xe--);
}
})(S, k), fe(K, le, S.bl_count);
}
function y(S, k, H) {
var W, L, K = -1, $ = k[1], X = 0, te = 7, le = 4;
for ($ === 0 && (te = 138, le = 3), k[2 * (H + 1) + 1] = 65535, W = 0; W <= H; W++) L = $, $ = k[2 * (W + 1) + 1], ++X < te && L === $ || (X < le ? S.bl_tree[2 * L] += X : L !== 0 ? (L !== K && S.bl_tree[2 * L]++, S.bl_tree[2 * T]++) : X <= 10 ? S.bl_tree[2 * M]++ : S.bl_tree[2 * C]++, K = L, le = (X = 0) === $ ? (te = 138, 3) : L === $ ? (te = 6, 3) : (te = 7, 4));
}
function j(S, k, H) {
var W, L, K = -1, $ = k[1], X = 0, te = 7, le = 4;
for ($ === 0 && (te = 138, le = 3), W = 0; W <= H; W++) if (L = $, $ = k[2 * (W + 1) + 1], !(++X < te && L === $)) {
if (X < le) for (; Z(S, L, S.bl_tree), --X != 0; ) ;
else L !== 0 ? (L !== K && (Z(S, L, S.bl_tree), X--), Z(S, T, S.bl_tree), Y(S, X - 3, 2)) : X <= 10 ? (Z(S, M, S.bl_tree), Y(S, X - 3, 3)) : (Z(S, C, S.bl_tree), Y(S, X - 11, 7));
K = L, le = (X = 0) === $ ? (te = 138, 3) : L === $ ? (te = 6, 3) : (te = 7, 4);
}
}
l(V);
var I = !1;
function E(S, k, H, W) {
Y(S, (h << 1) + (W ? 1 : 0), 3), (function(L, K, $, X) {
oe(L), Q(L, $), Q(L, ~$), o.arraySet(L.pending_buf, L.window, K, $, L.pending), L.pending += $;
})(S, k, H);
}
i._tr_init = function(S) {
I || ((function() {
var k, H, W, L, K, $ = new Array(g + 1);
for (L = W = 0; L < u - 1; L++) for (F[L] = W, k = 0; k < 1 << P[L]; k++) x[W++] = L;
for (x[W - 1] = L, L = K = 0; L < 16; L++) for (V[L] = K, k = 0; k < 1 << B[L]; k++) z[K++] = L;
for (K >>= 7; L < p; L++) for (V[L] = K << 7, k = 0; k < 1 << B[L] - 7; k++) z[256 + K++] = L;
for (H = 0; H <= g; H++) $[H] = 0;
for (k = 0; k <= 143; ) q[2 * k + 1] = 8, k++, $[8]++;
for (; k <= 255; ) q[2 * k + 1] = 9, k++, $[9]++;
for (; k <= 279; ) q[2 * k + 1] = 7, k++, $[7]++;
for (; k <= 287; ) q[2 * k + 1] = 8, k++, $[8]++;
for (fe(q, m + 1, $), k = 0; k < p; k++) A[2 * k + 1] = 5, A[2 * k] = ue(k, 5);
J = new ee(q, P, f + 1, m, g), G = new ee(A, B, 0, p, g), ne = new ee(new Array(0), R, 0, c, w);
})(), I = !0), S.l_desc = new O(S.dyn_ltree, J), S.d_desc = new O(S.dyn_dtree, G), S.bl_desc = new O(S.bl_tree, ne), S.bi_buf = 0, S.bi_valid = 0, ie(S);
}, i._tr_stored_block = E, i._tr_flush_block = function(S, k, H, W) {
var L, K, $ = 0;
0 < S.level ? (S.strm.data_type === 2 && (S.strm.data_type = (function(X) {
var te, le = 4093624447;
for (te = 0; te <= 31; te++, le >>>= 1) if (1 & le && X.dyn_ltree[2 * te] !== 0) return s;
if (X.dyn_ltree[18] !== 0 || X.dyn_ltree[20] !== 0 || X.dyn_ltree[26] !== 0) return a;
for (te = 32; te < f; te++) if (X.dyn_ltree[2 * te] !== 0) return a;
return s;
})(S)), ve(S, S.l_desc), ve(S, S.d_desc), $ = (function(X) {
var te;
for (y(X, X.dyn_ltree, X.l_desc.max_code), y(X, X.dyn_dtree, X.d_desc.max_code), ve(X, X.bl_desc), te = c - 1; 3 <= te && X.bl_tree[2 * U[te] + 1] === 0; te--) ;
return X.opt_len += 3 * (te + 1) + 5 + 5 + 4, te;
})(S), L = S.opt_len + 3 + 7 >>> 3, (K = S.static_len + 3 + 7 >>> 3) <= L && (L = K)) : L = K = H + 5, H + 4 <= L && k !== -1 ? E(S, k, H, W) : S.strategy === 4 || K === L ? (Y(S, 2 + (W ? 1 : 0), 3), Te(S, q, A)) : (Y(S, 4 + (W ? 1 : 0), 3), (function(X, te, le, re) {
var we;
for (Y(X, te - 257, 5), Y(X, le - 1, 5), Y(X, re - 4, 4), we = 0; we < re; we++) Y(X, X.bl_tree[2 * U[we] + 1], 3);
j(X, X.dyn_ltree, te - 1), j(X, X.dyn_dtree, le - 1);
})(S, S.l_desc.max_code + 1, S.d_desc.max_code + 1, $ + 1), Te(S, S.dyn_ltree, S.dyn_dtree)), ie(S), W && oe(S);
}, i._tr_tally = function(S, k, H) {
return S.pending_buf[S.d_buf + 2 * S.last_lit] = k >>> 8 & 255, S.pending_buf[S.d_buf + 2 * S.last_lit + 1] = 255 & k, S.pending_buf[S.l_buf + S.last_lit] = 255 & H, S.last_lit++, k === 0 ? S.dyn_ltree[2 * H]++ : (S.matches++, k--, S.dyn_ltree[2 * (x[H] + f + 1)]++, S.dyn_dtree[2 * D(k)]++), S.last_lit === S.lit_bufsize - 1;
}, i._tr_align = function(S) {
Y(S, 2, 3), Z(S, b, q), (function(k) {
k.bi_valid === 16 ? (Q(k, k.bi_buf), k.bi_buf = 0, k.bi_valid = 0) : 8 <= k.bi_valid && (k.pending_buf[k.pending++] = 255 & k.bi_buf, k.bi_buf >>= 8, k.bi_valid -= 8);
})(S);
};
}, { "../utils/common": 41 }], 53: [function(t, n, i) {
n.exports = function() {
this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0;
};
}, {}], 54: [function(t, n, i) {
(function(o) {
(function(s, a) {
if (!s.setImmediate) {
var l, h, u, f, m = 1, p = {}, c = !1, d = s.document, g = Object.getPrototypeOf && Object.getPrototypeOf(s);
g = g && g.setTimeout ? g : s, l = {}.toString.call(s.process) === "[object process]" ? function(T) {
process.nextTick(function() {
w(T);
});
} : (function() {
if (s.postMessage && !s.importScripts) {
var T = !0, M = s.onmessage;
return s.onmessage = function() {
T = !1;
}, s.postMessage("", "*"), s.onmessage = M, T;
}
})() ? (f = "setImmediate$" + Math.random() + "$", s.addEventListener ? s.addEventListener("message", b, !1) : s.attachEvent("onmessage", b), function(T) {
s.postMessage(f + T, "*");
}) : s.MessageChannel ? ((u = new MessageChannel()).port1.onmessage = function(T) {
w(T.data);
}, function(T) {
u.port2.postMessage(T);
}) : d && "onreadystatechange" in d.createElement("script") ? (h = d.documentElement, function(T) {
var M = d.createElement("script");
M.onreadystatechange = function() {
w(T), M.onreadystatechange = null, h.removeChild(M), M = null;
}, h.appendChild(M);
}) : function(T) {
setTimeout(w, 0, T);
}, g.setImmediate = function(T) {
typeof T != "function" && (T = new Function("" + T));
for (var M = new Array(arguments.length - 1), C = 0; C < M.length; C++) M[C] = arguments[C + 1];
var P = { callback: T, args: M };
return p[m] = P, l(m), m++;
}, g.clearImmediate = _;
}
function _(T) {
delete p[T];
}
function w(T) {
if (c) setTimeout(w, 0, T);
else {
var M = p[T];
if (M) {
c = !0;
try {
(function(C) {
var P = C.callback, B = C.args;
switch (B.length) {
case 0:
P();
break;
case 1:
P(B[0]);
break;
case 2:
P(B[0], B[1]);
break;
case 3:
P(B[0], B[1], B[2]);
break;
default:
P.apply(a, B);
}
})(M);
} finally {
_(T), c = !1;
}
}
}
}
function b(T) {
T.source === s && typeof T.data == "string" && T.data.indexOf(f) === 0 && w(+T.data.slice(f.length));
}
})(typeof self > "u" ? o === void 0 ? this : o : self);
}).call(this, typeof Ut < "u" ? Ut : typeof self < "u" ? self : typeof window < "u" ? window : {});
}, {}] }, {}, [10])(10);
});
})(fn)), fn.exports;
}
var Vr = jr();
const Hr = /* @__PURE__ */ Oi(Vr);
function Ni(r, e) {
return function() {
return r.apply(e, arguments);
};
}
const { toString: Gr } = Object.prototype, { getPrototypeOf: Ln } = Object, { iterator: sn, toStringTag: zi } = Symbol, rn = /* @__PURE__ */ ((r) => (e) => {
const t = Gr.call(e);
return r[t] || (r[t] = t.slice(8, -1).toLowerCase());
})(/* @__PURE__ */ Object.create(null)), Oe = (r) => (r = r.toLowerCase(), (e) => rn(e) === r), on = (r) => (e) => typeof e === r, { isArray: yt } = Array, _t = on("undefined");
function At(r) {
return r !== null && !_t(r) && r.constructor !== null && !_t(r.constructor) && Ee(r.constructor.isBuffer) && r.constructor.isBuffer(r);
}
const Ii = Oe("ArrayBuffer");
function Wr(r) {
let e;
return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? e = ArrayBuffer.isView(r) : e = r && r.buffer && Ii(r.buffer), e;
}
const Kr = on("string"), Ee = on("function"), Bi = on("number"), Ct = (r) => r !== null && typeof r == "object", Xr = (r) => r === !0 || r === !1, Kt = (r) => {
if (rn(r) !== "object")
return !1;
const e = Ln(r);
return (e === null || e === Object.prototype || Object.getPrototypeOf(e) === null) && !(zi in r) && !(sn in r);
}, Zr = (r) => {
if (!Ct(r) || At(r))
return !1;
try {
return Object.keys(r).length === 0 && Object.getPrototypeOf(r) === Object.prototype;
} catch {
return !1;
}
}, qr = Oe("Date"), Yr = Oe("File"), $r = Oe("Blob"), Jr = Oe("FileList"), Qr = (r) => Ct(r) && Ee(r.pipe), eo = (r) => {
let e;
return r && (typeof FormData == "function" && r instanceof FormData || Ee(r.append) && ((e = rn(r)) === "formdata" || // detect form-data instance
e === "object" && Ee(r.toString) && r.toString() === "[object FormData]"));
}, to = Oe("URLSearchParams"), [no, io, so, ro] = ["ReadableStream", "Request", "Response", "Headers"].map(Oe), oo = (r) => r.trim ? r.trim() : r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
function kt(r, e, { allOwnKeys: t = !1 } = {}) {
if (r === null || typeof r > "u")
return;
let n, i;
if (typeof r != "object" && (r = [r]), yt(r))
for (n = 0, i = r.length; n < i; n++)
e.call(null, r[n], n, r);
else {
if (At(r))
return;
const o = t ? Object.getOwnPropertyNames(r) : Object.keys(r), s = o.length;
let a;
for (n = 0; n < s; n++)
a = o[n], e.call(null, r[a], a, r);
}
}
function Ui(r, e) {
if (At(r))
return null;
e = e.toLowerCase();
const t = Object.keys(r);
let n = t.length, i;
for (; n-- > 0; )
if (i = t[n], e === i.toLowerCase())
return i;
return null;
}
const et = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, Fi = (r) => !_t(r) && r !== et;
function Sn() {
const { caseless: r, skipUndefined: e } = Fi(this) && this || {}, t = {}, n = (i, o) => {
const s = r && Ui(t, o) || o;
Kt(t[s]) && Kt(i) ? t[s] = Sn(t[s], i) : Kt(i) ? t[s] = Sn({}, i) : yt(i) ? t[s] = i.slice() : (!e || !_t(i)) && (t[s] = i);
};
for (let i = 0, o = arguments.length; i < o; i++)
arguments[i] && kt(arguments[i], n);
return t;
}
const ao = (r, e, t, { allOwnKeys: n } = {}) => (kt(e, (i, o) => {
t && Ee(i) ? r[o] = Ni(i, t) : r[o] = i;
}, { allOwnKeys: n }), r), lo = (r) => (r.charCodeAt(0) === 65279 && (r = r.slice(1)), r), co = (r, e, t, n) => {
r.prototype = Object.create(e.prototype, n), r.prototype.constructor = r, Object.defineProperty(r, "super", {
value: e.prototype
}), t && Object.assign(r.prototype, t);
}, ho = (r, e, t, n) => {
let i, o, s;
const a = {};
if (e = e || {}, r == null) return e;
do {
for (i = Object.getOwnPropertyNames(r), o = i.length; o-- > 0; )
s = i[o], (!n || n(s, r, e)) && !a[s] && (e[s] = r[s], a[s] = !0);
r = t !== !1 && Ln(r);
} while (r && (!t || t(r, e)) && r !== Object.prototype);
return e;
}, uo = (r, e, t) => {
r = String(r), (t === void 0 || t > r.length) && (t = r.length), t -= e.length;
const n = r.indexOf(e, t);
return n !== -1 && n === t;
}, fo = (r) => {
if (!r) return null;
if (yt(r)) return r;
let e = r.length;
if (!Bi(e)) return null;
const t = new Array(e);
for (; e-- > 0; )
t[e] = r[e];
return t;
}, po = /* @__PURE__ */ ((r) => (e) => r && e instanceof r)(typeof Uint8Array < "u" && Ln(Uint8Array)), mo = (r, e) => {
const n = (r && r[sn]).call(r);
let i;
for (; (i = n.next()) && !i.done; ) {
const o = i.value;
e.call(r, o[0], o[1]);
}
}, go = (r, e) => {
let t;
const n = [];
for (; (t = r.exec(e)) !== null; )
n.push(t);
return n;
}, _o = Oe("HTMLFormElement"), yo = (r) => r.toLowerCase().replace(
/[-_\s]([a-z\d])(\w*)/g,
function(t, n, i) {
return n.toUpperCase() + i;
}
), Yn = (({ hasOwnProperty: r }) => (e, t) => r.call(e, t))(Object.prototype), wo = Oe("RegExp"), ji = (r, e) => {
const t = Object.getOwnPropertyDescriptors(r), n = {};
kt(t, (i, o) => {
let s;
(s = e(i, o, r)) !== !1 && (n[o] = s || i);
}), Object.defineProperties(r, n);
}, xo = (r) => {
ji(r, (e, t) => {
if (Ee(r) && ["arguments", "caller", "callee"].indexOf(t) !== -1)
return !1;
const n = r[t];
if (Ee(n)) {
if (e.enumerable = !1, "writable" in e) {
e.writable = !1;
return;
}
e.set || (e.set = () => {
throw Error("Can not rewrite read-only method '" + t + "'");
});
}
});
}, bo = (r, e) => {
const t = {}, n = (i) => {
i.forEach((o) => {
t[o] = !0;
});
};
return yt(r) ? n(r) : n(String(r).split(e)), t;
}, vo = () => {
}, To = (r, e) => r != null && Number.isFinite(r = +r) ? r : e;
function So(r) {
return !!(r && Ee(r.append) && r[zi] === "FormData" && r[sn]);
}
const Eo = (r) => {
const e = new Array(10), t = (n, i) => {
if (Ct(n)) {
if (e.indexOf(n) >= 0)
return;
if (At(n))
return n;
if (!("toJSON" in n)) {
e[i] = n;
const o = yt(n) ? [] : {};
return kt(n, (s, a) => {
const l = t(s, i + 1);
!_t(l) && (o[a] = l);
}), e[i] = void 0, o;
}
}
return n;
};
return t(r, 0);
}, Mo = Oe("AsyncFunction"), Ao = (r) => r && (Ct(r) || Ee(r)) && Ee(r.then) && Ee(r.catch), Vi = ((r, e) => r ? setImmediate : e ? ((t, n) => (et.addEventListener("message", ({ source: i, data: o }) => {
i === et && o === t && n.length && n.shift()();
}, !1), (i) => {
n.push(i), et.postMessage(t, "*");
}))(`axios@${Math.random()}`, []) : (t) => setTimeout(t))(
typeof setImmediate == "function",
Ee(et.postMessage)
), Co = typeof queueMicrotask < "u" ? queueMicrotask.bind(et) : typeof process < "u" && process.nextTick || Vi, ko = (r) => r != null && Ee(r[sn]), N = {
isArray: yt,
isArrayBuffer: Ii,
isBuffer: At,
isFormData: eo,
isArrayBufferView: Wr,
isString: Kr,
isNumber: Bi,
isBoolean: Xr,
isObject: Ct,
isPlainObject: Kt,
isEmptyObject: Zr,
isReadableStream: no,
isRequest: io,
isResponse: so,
isHeaders: ro,
isUndefined: _t,
isDate: qr,
isFile: Yr,
isBlob: $r,
isRegExp: wo,
isFunction: Ee,
isStream: Qr,
isURLSearchParams: to,
isTypedArray: po,
isFileList: Jr,
forEach: kt,
merge: Sn,
extend: ao,
trim: oo,
stripBOM: lo,
inherits: co,
toFlatObject: ho,
kindOf: rn,
kindOfTest: Oe,
endsWith: uo,
toArray: fo,
forEachEntry: mo,
matchAll: go,
isHTMLForm: _o,
hasOwnProperty: Yn,
hasOwnProp: Yn,
// an alias to avoid ESLint no-prototype-builtins detection
reduceDescriptors: ji,
freezeMethods: xo,
toObjectSet: bo,
toCamelCase: yo,
noop: vo,
toFiniteNumber: To,
findKey: Ui,
global: et,
isContextDefined: Fi,
isSpecCompliantForm: So,
toJSONObject: Eo,
isAsyncFn: Mo,
isThenable: Ao,
setImmediate: Vi,
asap: Co,
isIterable: ko
};
function se(r, e, t, n, i) {
Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = r, this.name = "AxiosError", e && (this.code = e), t && (this.config = t), n && (this.request = n), i && (this.response = i, this.status = i.status ? i.status : null);
}
N.inherits(se, Error, {
toJSON: function() {
return {
// Standard
message: this.message,
name: this.name,
// Microsoft
description: this.description,
number: this.number,
// Mozilla
fileName: this.fileName,
lineNumber: this.lineNumber,
columnNumber: this.columnNumber,
stack: this.stack,
// Axios
config: N.toJSONObject(this.config),
code: this.code,
status: this.status
};
}
});
const Hi = se.prototype, Gi = {};
[
"ERR_BAD_OPTION_VALUE",
"ERR_BAD_OPTION",
"ECONNABORTED",
"ETIMEDOUT",
"ERR_NETWORK",
"ERR_FR_TOO_MANY_REDIRECTS",
"ERR_DEPRECATED",
"ERR_BAD_RESPONSE",
"ERR_BAD_REQUEST",
"ERR_CANCELED",
"ERR_NOT_SUPPORT",
"ERR_INVALID_URL"
// eslint-disable-next-line func-names
].forEach((r) => {
Gi[r] = { value: r };
});
Object.defineProperties(se, Gi);
Object.defineProperty(Hi, "isAxiosError", { value: !0 });
se.from = (r, e, t, n, i, o) => {
const s = Object.create(Hi);
N.toFlatObject(r, s, function(u) {
return u !== Error.prototype;
}, (h) => h !== "isAxiosError");
const a = r && r.message ? r.message : "Error", l = e == null && r ? r.code : e;
return se.call(s, a, l, t, n, i), r && s.cause == null && Object.defineProperty(s, "cause", { value: r, configurable: !0 }), s.name = r && r.name || "Error", o && Object.assign(s, o), s;
};
const Po = null;
function En(r) {
return N.isPlainObject(r) || N.isArray(r);
}
function Wi(r) {
return N.endsWith(r, "[]") ? r.slice(0, -2) : r;
}
function $n(r, e, t) {
return r ? r.concat(e).map(function(i, o) {
return i = Wi(i), !t && o ? "[" + i + "]" : i;
}).join(t ? "." : "") : e;
}
function Ro(r) {
return N.isArray(r) && !r.some(En);
}
const Do = N.toFlatObject(N, {}, null, function(e) {
return /^is[A-Z]/.test(e);
});
function an(r, e, t) {
if (!N.isObject(r))
throw new TypeError("target must be an object");
e = e || new FormData(), t = N.toFlatObject(t, {
metaTokens: !0,
dots: !1,
indexes: !1
}, !1, function(d, g) {
return !N.isUndefined(g[d]);
});
const n = t.metaTokens, i = t.visitor || u, o = t.dots, s = t.indexes, l = (t.Blob || typeof Blob < "u" && Blob) && N.isSpecCompliantForm(e);
if (!N.isFunction(i))
throw new TypeError("visitor must be a function");
function h(c) {
if (c === null) return "";
if (N.isDate(c))
return c.toISOString();
if (N.isBoolean(c))
return c.toString();
if (!l && N.isBlob(c))
throw new se("Blob is not supported. Use a Buffer instead.");
return N.isArrayBuffer(c) || N.isTypedArray(c) ? l && typeof Blob == "function" ? new Blob([c]) : Buffer.from(c) : c;
}
function u(c, d, g) {
let _ = c;
if (c && !g && typeof c == "object") {
if (N.endsWith(d, "{}"))
d = n ? d : d.slice(0, -2), c = JSON.stringify(c);
else if (N.isArray(c) && Ro(c) || (N.isFileList(c) || N.endsWith(d, "[]")) && (_ = N.toArray(c)))
return d = Wi(d), _.forEach(function(b, T) {
!(N.isUndefined(b) || b === null) && e.append(
// eslint-disable-next-line no-nested-ternary
s === !0 ? $n([d], T, o) : s === null ? d : d + "[]",
h(b)
);
}), !1;
}
return En(c) ? !0 : (e.append($n(g, d, o), h(c)), !1);
}
const f = [], m = Object.assign(Do, {
defaultVisitor: u,
convertValue: h,
isVisitable: En
});
function p(c, d) {
if (!N.isUndefined(c)) {
if (f.indexOf(c) !== -1)
throw Error("Circular reference detected in " + d.join("."));
f.push(c), N.forEach(c, function(_, w) {
(!(N.isUndefined(_) || _ === null) && i.call(
e,
_,
N.isString(w) ? w.trim() : w,
d,
m
)) === !0 && p(_, d ? d.concat(w) : [w]);
}), f.pop();
}
}
if (!N.isObject(r))
throw new TypeError("data must be an object");
return p(r), e;
}
function Jn(r) {
const e = {
"!": "%21",
"'": "%27",
"(": "%28",
")": "%29",
"~": "%7E",
"%20": "+",
"%00": "\0"
};
return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g, function(n) {
return e[n];
});
}
function On(r, e) {
this._pairs = [], r && an(r, this, e);
}
const Ki = On.prototype;
Ki.append = function(e, t) {
this._pairs.push([e, t]);
};
Ki.toString = function(e) {
const t = e ? function(n) {
return e.call(this, n, Jn);
} : Jn;
return this._pairs.map(function(i) {
return t(i[0]) + "=" + t(i[1]);
}, "").join("&");
};
function Lo(r) {
return encodeURIComponent(r).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
}
function Xi(r, e, t) {
if (!e)
return r;
const n = t && t.encode || Lo;
N.isFunction(t) && (t = {
serialize: t
});
const i = t && t.serialize;
let o;
if (i ? o = i(e, t) : o = N.isURLSearchParams(e) ? e.toString() : new On(e, t).toString(n), o) {
const s = r.indexOf("#");
s !== -1 && (r = r.slice(0, s)), r += (r.indexOf("?") === -1 ? "?" : "&") + o;
}
return r;
}
class Qn {
constructor() {
this.handlers = [];
}
/**
* Add a new interceptor to the stack
*
* @param {Function} fulfilled The function to handle `then` for a `Promise`
* @param {Function} rejected The function to handle `reject` for a `Promise`
*
* @return {Number} An ID used to remove interceptor later
*/
use(e, t, n) {
return this.handlers.push({
fulfilled: e,
rejected: t,
synchronous: n ? n.synchronous : !1,
runWhen: n ? n.runWhen : null
}), this.handlers.length - 1;
}
/**
* Remove an interceptor from the stack
*
* @param {Number} id The ID that was returned by `use`
*
* @returns {void}
*/
eject(e) {
this.handlers[e] && (this.handlers[e] = null);
}
/**
* Clear all interceptors from the stack
*
* @returns {void}
*/
clear() {
this.handlers && (this.handlers = []);
}
/**
* Iterate over all the registered interceptors
*
* This method is particularly useful for skipping over any
* interceptors that may have become `null` calling `eject`.
*
* @param {Function} fn The function to call for each interceptor
*
* @returns {void}
*/
forEach(e) {
N.forEach(this.handlers, function(n) {
n !== null && e(n);
});
}
}
const Zi = {
silentJSONParsing: !0,
forcedJSONParsing: !0,
clarifyTimeoutError: !1
}, Oo = typeof URLSearchParams < "u" ? URLSearchParams : On, No = typeof FormData < "u" ? FormData : null, zo = typeof Blob < "u" ? Blob : null, Io = {
isBrowser: !0,
classes: {
URLSearchParams: Oo,
FormData: No,
Blob: zo
},
protocols: ["http", "https", "file", "blob", "url", "data"]
}, Nn = typeof window < "u" && typeof document < "u", Mn = typeof navigator == "object" && navigator || void 0, Bo = Nn && (!Mn || ["ReactNative", "NativeScript", "NS"].indexOf(Mn.product) < 0), Uo = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Fo = Nn && window.location.href || "http://localhost", jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
hasBrowserEnv: Nn,
hasStandardBrowserEnv: Bo,
hasStandardBrowserWebWorkerEnv: Uo,
navigator: Mn,
origin: Fo
}, Symbol.toStringTag, { value: "Module" })), be = {
...jo,
...Io
};
function Vo(r, e) {
return an(r, new be.classes.URLSearchParams(), {
visitor: function(t, n, i, o) {
return be.isNode && N.isBuffer(t) ? (this.append(n, t.toString("base64")), !1) : o.defaultVisitor.apply(this, arguments);
},
...e
});
}
function Ho(r) {
return N.matchAll(/\w+|\[(\w*)]/g, r).map((e) => e[0] === "[]" ? "" : e[1] || e[0]);
}
function Go(r) {
const e = {}, t = Object.keys(r);
let n;
const i = t.length;
let o;
for (n = 0; n < i; n++)
o = t[n], e[o] = r[o];
return e;
}
function qi(r) {
function e(t, n, i, o) {
let s = t[o++];
if (s === "__proto__") return !0;
const a = Number.isFinite(+s), l = o >= t.length;
return s = !s && N.isArray(i) ? i.length : s, l ? (N.hasOwnProp(i, s) ? i[s] = [i[s], n] : i[s] = n, !a) : ((!i[s] || !N.isObject(i[s])) && (i[s] = []), e(t, n, i[s], o) && N.isArray(i[s]) && (i[s] = Go(i[s])), !a);
}
if (N.isFormData(r) && N.isFunction(r.entries)) {
const t = {};
return N.forEachEntry(r, (n, i) => {
e(Ho(n), i, t, 0);
}), t;
}
return null;
}
function Wo(r, e, t) {
if (N.isString(r))
try {
return (e || JSON.parse)(r), N.trim(r);
} catch (n) {
if (n.name !== "SyntaxError")
throw n;
}
return (t || JSON.stringify)(r);
}
const Pt = {
transitional: Zi,
adapter: ["xhr", "http", "fetch"],
transformRequest: [function(e, t) {
const n = t.getContentType() || "", i = n.indexOf("application/json") > -1, o = N.isObject(e);
if (o && N.isHTMLForm(e) && (e = new FormData(e)), N.isFormData(e))
return i ? JSON.stringify(qi(e)) : e;
if (N.isArrayBuffer(e) || N.isBuffer(e) || N.isStream(e) || N.isFile(e) || N.isBlob(e) || N.isReadableStream(e))
return e;
if (N.isArrayBufferView(e))
return e.buffer;
if (N.isURLSearchParams(e))
return t.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), e.toString();
let a;
if (o) {
if (n.indexOf("application/x-www-form-urlencoded") > -1)
return Vo(e, this.formSerializer).toString();
if ((a = N.isFileList(e)) || n.indexOf("multipart/form-data") > -1) {
const l = this.env && this.env.FormData;
return an(
a ? { "files[]": e } : e,
l && new l(),
this.formSerializer
);
}
}
return o || i ? (t.setContentType("application/json", !1), Wo(e)) : e;
}],
transformResponse: [function(e) {
const t = this.transitional || Pt.transitional, n = t && t.forcedJSONParsing, i = this.responseType === "json";
if (N.isResponse(e) || N.isReadableStream(e))
return e;
if (e && N.isString(e) && (n && !this.responseType || i)) {
const s = !(t && t.silentJSONParsing) && i;
try {
return JSON.parse(e, this.parseReviver);
} catch (a) {
if (s)
throw a.name === "SyntaxError" ? se.from(a, se.ERR_BAD_RESPONSE, this, null, this.response) : a;
}
}
return e;
}],
/**
* A timeout in milliseconds to abort a request. If set to 0 (default) a
* timeout is not created.
*/
timeout: 0,
xsrfCookieName: "XSRF-TOKEN",
xsrfHeaderName: "X-XSRF-TOKEN",
maxContentLength: -1,
maxBodyLength: -1,
env: {
FormData: be.classes.FormData,
Blob: be.classes.Blob
},
validateStatus: function(e) {
return e >= 200 && e < 300;
},
headers: {
common: {
Accept: "application/json, text/plain, */*",
"Content-Type": void 0
}
}
};
N.forEach(["delete", "get", "head", "post", "put", "patch"], (r) => {
Pt.headers[r] = {};
});
const Ko = N.toObjectSet([
"age",
"authorization",
"content-length",
"content-type",
"etag",
"expires",
"from",
"host",
"if-modified-since",
"if-unmodified-since",
"last-modified",
"location",
"max-forwards",
"proxy-authorization",
"referer",
"retry-after",
"user-agent"
]), Xo = (r) => {
const e = {};
let t, n, i;
return r && r.split(`
`).forEach(function(s) {
i = s.indexOf(":"), t = s.substring(0, i).trim().toLowerCase(), n = s.substring(i + 1).trim(), !(!t || e[t] && Ko[t]) && (t === "set-cookie" ? e[t] ? e[t].push(n) : e[t] = [n] : e[t] = e[t] ? e[t] + ", " + n : n);
}), e;
}, ei = Symbol("internals");
function vt(r) {
return r && String(r).trim().toLowerCase();
}
function Xt(r) {
return r === !1 || r == null ? r : N.isArray(r) ? r.map(Xt) : String(r);
}
function Zo(r) {
const e = /* @__PURE__ */ Object.create(null), t = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
let n;
for (; n = t.exec(r); )
e[n[1]] = n[2];
return e;
}
const qo = (r) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());
function pn(r, e, t, n, i) {
if (N.isFunction(n))
return n.call(this, e, t);
if (i && (e = t), !!N.isString(e)) {
if (N.isString(n))
return e.indexOf(n) !== -1;
if (N.isRegExp(n))
return n.test(e);
}
}
function Yo(r) {
return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (e, t, n) => t.toUpperCase() + n);
}
function $o(r, e) {
const t = N.toCamelCase(" " + e);
["get", "set", "has"].forEach((n) => {
Object.defineProperty(r, n + t, {
value: function(i, o, s) {
return this[n].call(this, e, i, o, s);
},
configurable: !0
});
});
}
let Me = class {
constructor(e) {
e && this.set(e);
}
set(e, t, n) {
const i = this;
function o(a, l, h) {
const u = vt(l);
if (!u)
throw new Error("header name must be a non-empty string");
const f = N.findKey(i, u);
(!f || i[f] === void 0 || h === !0 || h === void 0 && i[f] !== !1) && (i[f || l] = Xt(a));
}
const s = (a, l) => N.forEach(a, (h, u) => o(h, u, l));
if (N.isPlainObject(e) || e instanceof this.constructor)
s(e, t);
else if (N.isString(e) && (e = e.trim()) && !qo(e))
s(Xo(e), t);
else if (N.isObject(e) && N.isIterable(e)) {
let a = {}, l, h;
for (const u of e) {
if (!N.isArray(u))
throw TypeError("Object iterator must return a key-value pair");
a[h = u[0]] = (l = a[h]) ? N.isArray(l) ? [...l, u[1]] : [l, u[1]] : u[1];
}
s(a, t);
} else
e != null && o(t, e, n);
return this;
}
get(e, t) {
if (e = vt(e), e) {
const n = N.findKey(this, e);
if (n) {
const i = this[n];
if (!t)
return i;
if (t === !0)
return Zo(i);
if (N.isFunction(t))
return t.call(this, i, n);
if (N.isRegExp(t))
return t.exec(i);
throw new TypeError("parser must be boolean|regexp|function");
}
}
}
has(e, t) {
if (e = vt(e), e) {
const n = N.findKey(this, e);
return !!(n && this[n] !== void 0 && (!t || pn(this, this[n], n, t)));
}
return !1;
}
delete(e, t) {
const n = this;
let i = !1;
function o(s) {
if (s = vt(s), s) {
const a = N.findKey(n, s);
a && (!t || pn(n, n[a], a, t)) && (delete n[a], i = !0);
}
}
return N.isArray(e) ? e.forEach(o) : o(e), i;
}
clear(e) {
const t = Object.keys(this);
let n = t.length, i = !1;
for (; n--; ) {
const o = t[n];
(!e || pn(this, this[o], o, e, !0)) && (delete this[o], i = !0);
}
return i;
}
normalize(e) {
const t = this, n = {};
return N.forEach(this, (i, o) => {
const s = N.findKey(n, o);
if (s) {
t[s] = Xt(i), delete t[o];
return;
}
const a = e ? Yo(o) : String(o).trim();
a !== o && delete t[o], t[a] = Xt(i), n[a] = !0;
}), this;
}
concat(...e) {
return this.constructor.concat(this, ...e);
}
toJSON(e) {
const t = /* @__PURE__ */ Object.create(null);
return N.forEach(this, (n, i) => {
n != null && n !== !1 && (t[i] = e && N.isArray(n) ? n.join(", ") : n);
}), t;
}
[Symbol.iterator]() {
return Object.entries(this.toJSON())[Symbol.iterator]();
}
toString() {
return Object.entries(this.toJSON()).map(([e, t]) => e + ": " + t).join(`
`);
}
getSetCookie() {
return this.get("set-cookie") || [];
}
get [Symbol.toStringTag]() {
return "AxiosHeaders";
}
static from(e) {
return e instanceof this ? e : new this(e);
}
static concat(e, ...t) {
const n = new this(e);
return t.forEach((i) => n.set(i)), n;
}
static accessor(e) {
const n = (this[ei] = this[ei] = {
accessors: {}
}).accessors, i = this.prototype;
function o(s) {
const a = vt(s);
n[a] || ($o(i, s), n[a] = !0);
}
return N.isArray(e) ? e.forEach(o) : o(e), this;
}
};
Me.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
N.reduceDescriptors(Me.prototype, ({ value: r }, e) => {
let t = e[0].toUpperCase() + e.slice(1);
return {
get: () => r,
set(n) {
this[t] = n;
}
};
});
N.freezeMethods(Me);
function mn(r, e) {
const t = this || Pt, n = e || t, i = Me.from(n.headers);
let o = n.data;
return N.forEach(r, function(a) {
o = a.call(t, o, i.normalize(), e ? e.status : void 0);
}), i.normalize(), o;
}
function Yi(r) {
return !!(r && r.__CANCEL__);
}
function wt(r, e, t) {
se.call(this, r ?? "canceled", se.ERR_CANCELED, e, t), this.name = "CanceledError";
}
N.inherits(wt, se, {
__CANCEL__: !0
});
function $i(r, e, t) {
const n = t.config.validateStatus;
!t.status || !n || n(t.status) ? r(t) : e(new se(
"Request failed with status code " + t.status,
[se.ERR_BAD_REQUEST, se.ERR_BAD_RESPONSE][Math.floor(t.status / 100) - 4],
t.config,
t.request,
t
));
}
function Jo(r) {
const e = /^([-+\w]{1,25})(:?\/\/|:)/.exec(r);
return e && e[1] || "";
}
function Qo(r, e) {
r = r || 10;
const t = new Array(r), n = new Array(r);
let i = 0, o = 0, s;
return e = e !== void 0 ? e : 1e3, function(l) {
const h = Date.now(), u = n[o];
s || (s = h), t[i] = l, n[i] = h;
let f = o, m = 0;
for (; f !== i; )
m += t[f++], f = f % r;
if (i = (i + 1) % r, i === o && (o = (o + 1) % r), h - s < e)
return;
const p = u && h - u;
return p ? Math.round(m * 1e3 / p) : void 0;
};
}
function ea(r, e) {
let t = 0, n = 1e3 / e, i, o;
const s = (h, u = Date.now()) => {
t = u, i = null, o && (clearTimeout(o), o = null), r(...h);
};
return [(...h) => {
const u = Date.now(), f = u - t;
f >= n ? s(h, u) : (i = h, o || (o = setTimeout(() => {
o = null, s(i);
}, n - f)));
}, () => i && s(i)];
}
const en = (r, e, t = 3) => {
let n = 0;
const i = Qo(50, 250);
return ea((o) => {
const s = o.loaded, a = o.lengthComputable ? o.total : void 0, l = s - n, h = i(l), u = s <= a;
n = s;
const f = {
loaded: s,
total: a,
progress: a ? s / a : void 0,
bytes: l,
rate: h || void 0,
estimated: h && a && u ? (a - s) / h : void 0,
event: o,
lengthComputable: a != null,
[e ? "download" : "upload"]: !0
};
r(f);
}, t);
}, ti = (r, e) => {
const t = r != null;
return [(n) => e[0]({
lengthComputable: t,
total: r,
loaded: n
}), e[1]];
}, ni = (r) => (...e) => N.asap(() => r(...e)), ta = be.hasStandardBrowserEnv ? /* @__PURE__ */ ((r, e) => (t) => (t = new URL(t, be.origin), r.protocol === t.protocol && r.host === t.host && (e || r.port === t.port)))(
new URL(be.origin),
be.navigator && /(msie|trident)/i.test(be.navigator.userAgent)
) : () => !0, na = be.hasStandardBrowserEnv ? (
// Standard browser envs support document.cookie
{
write(r, e, t, n, i, o, s) {
if (typeof document > "u") return;
const a = [`${r}=${encodeURIComponent(e)}`];
N.isNumber(t) && a.push(`expires=${new Date(t).toUTCString()}`), N.isString(n) && a.push(`path=${n}`), N.isString(i) && a.push(`domain=${i}`), o === !0 && a.push("secure"), N.isString(s) && a.push(`SameSite=${s}`), document.cookie = a.join("; ");
},
read(r) {
if (typeof document > "u") return null;
const e = document.cookie.match(new RegExp("(?:^|; )" + r + "=([^;]*)"));
return e ? decodeURIComponent(e[1]) : null;
},
remove(r) {
this.write(r, "", Date.now() - 864e5, "/");
}
}
) : (
// Non-standard browser env (web workers, react-native) lack needed support.
{
write() {
},
read() {
return null;
},
remove() {
}
}
);
function ia(r) {
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(r);
}
function sa(r, e) {
return e ? r.replace(/\/?\/$/, "") + "/" + e.replace(/^\/+/, "") : r;
}
function Ji(r, e, t) {
let n = !ia(e);
return r && (n || t == !1) ? sa(r, e) : e;
}
const ii = (r) => r instanceof Me ? { ...r } : r;
function st(r, e) {
e = e || {};
const t = {};
function n(h, u, f, m) {
return N.isPlainObject(h) && N.isPlainObject(u) ? N.merge.call({ caseless: m }, h, u) : N.isPlainObject(u) ? N.merge({}, u) : N.isArray(u) ? u.slice() : u;
}
function i(h, u, f, m) {
if (N.isUndefined(u)) {
if (!N.isUndefined(h))
return n(void 0, h, f, m);
} else return n(h, u, f, m);
}
function o(h, u) {
if (!N.isUndefined(u))
return n(void 0, u);
}
function s(h, u) {
if (N.isUndefined(u)) {
if (!N.isUndefined(h))
return n(void 0, h);
} else return n(void 0, u);
}
function a(h, u, f) {
if (f in e)
return n(h, u);
if (f in r)
return n(void 0, h);
}
const l = {
url: o,
method: o,
data: o,
baseURL: s,
transformRequest: s,
transformResponse: s,
paramsSerializer: s,
timeout: s,
timeoutMessage: s,
withCredentials: s,
withXSRFToken: s,
adapter: s,
responseType: s,
xsrfCookieName: s,
xsrfHeaderName: s,
onUploadProgress: s,
onDownloadProgress: s,
decompress: s,
maxContentLength: s,
maxBodyLength: s,
beforeRedirect: s,
transport: s,
httpAgent: s,
httpsAgent: s,
cancelToken: s,
socketPath: s,
responseEncoding: s,
validateStatus: a,
headers: (h, u, f) => i(ii(h), ii(u), f, !0)
};
return N.forEach(Object.keys({ ...r, ...e }), function(u) {
const f = l[u] || i, m = f(r[u], e[u], u);
N.isUndefined(m) && f !== a || (t[u] = m);
}), t;
}
const Qi = (r) => {
const e = st({}, r);
let { data: t, withXSRFToken: n, xsrfHeaderName: i, xsrfCookieName: o, headers: s, auth: a } = e;
if (e.headers = s = Me.from(s), e.url = Xi(Ji(e.baseURL, e.url, e.allowAbsoluteUrls), r.params, r.paramsSerializer), a && s.set(
"Authorization",
"Basic " + btoa((a.username || "") + ":" + (a.password ? unescape(encodeURIComponent(a.password)) : ""))
), N.isFormData(t)) {
if (be.hasStandardBrowserEnv || be.hasStandardBrowserWebWorkerEnv)
s.setContentType(void 0);
else if (N.isFunction(t.getHeaders)) {
const l = t.getHeaders(), h = ["content-type", "content-length"];
Object.entries(l).forEach(([u, f]) => {
h.includes(u.toLowerCase()) && s.set(u, f);
});
}
}
if (be.hasStandardBrowserEnv && (n && N.isFunction(n) && (n = n(e)), n || n !== !1 && ta(e.url))) {
const l = i && o && na.read(o);
l && s.set(i, l);
}
return e;
}, ra = typeof XMLHttpRequest < "u", oa = ra && function(r) {
return new Promise(function(t, n) {
const i = Qi(r);
let o = i.data;
const s = Me.from(i.headers).normalize();
let { responseType: a, onUploadProgress: l, onDownloadProgress: h } = i, u, f, m, p, c;
function d() {
p && p(), c && c(), i.cancelToken && i.cancelToken.unsubscribe(u), i.signal && i.signal.removeEventListener("abort", u);
}
let g = new XMLHttpRequest();
g.open(i.method.toUpperCase(), i.url, !0), g.timeout = i.timeout;
function _() {
if (!g)
return;
const b = Me.from(
"getAllResponseHeaders" in g && g.getAllResponseHeaders()
), M = {
data: !a || a === "text" || a === "json" ? g.responseText : g.response,
status: g.status,
statusText: g.statusText,
headers: b,
config: r,
request: g
};
$i(function(P) {
t(P), d();
}, function(P) {
n(P), d();
}, M), g = null;
}
"onloadend" in g ? g.onloadend = _ : g.onreadystatechange = function() {
!g || g.readyState !== 4 || g.status === 0 && !(g.responseURL && g.responseURL.indexOf("file:") === 0) || setTimeout(_);
}, g.onabort = function() {
g && (n(new se("Request aborted", se.ECONNABORTED, r, g)), g = null);
}, g.onerror = function(T) {
const M = T && T.message ? T.message : "Network Error", C = new se(M, se.ERR_NETWORK, r, g);
C.event = T || null, n(C), g = null;
}, g.ontimeout = function() {
let T = i.timeout ? "timeout of " + i.timeout + "ms exceeded" : "timeout exceeded";
const M = i.transitional || Zi;
i.timeoutErrorMessage && (T = i.timeoutErrorMessage), n(new se(
T,
M.clarifyTimeoutError ? se.ETIMEDOUT : se.ECONNABORTED,
r,
g
)), g = null;
}, o === void 0 && s.setContentType(null), "setRequestHeader" in g && N.forEach(s.toJSON(), function(T, M) {
g.setRequestHeader(M, T);
}), N.isUndefined(i.withCredentials) || (g.withCredentials = !!i.withCredentials), a && a !== "json" && (g.responseType = i.responseType), h && ([m, c] = en(h, !0), g.addEventListener("progress", m)), l && g.upload && ([f, p] = en(l), g.upload.addEventListener("progress", f), g.upload.addEventListener("loadend", p)), (i.cancelToken || i.signal) && (u = (b) => {
g && (n(!b || b.type ? new wt(null, r, g) : b), g.abort(), g = null);
}, i.cancelToken && i.cancelToken.subscribe(u), i.signal && (i.signal.aborted ? u() : i.signal.addEventListener("abort", u)));
const w = Jo(i.url);
if (w && be.protocols.indexOf(w) === -1) {
n(new se("Unsupported protocol " + w + ":", se.ERR_BAD_REQUEST, r));
return;
}
g.send(o || null);
});
}, aa = (r, e) => {
const { length: t } = r = r ? r.filter(Boolean) : [];
if (e || t) {
let n = new AbortController(), i;
const o = function(h) {
if (!i) {
i = !0, a();
const u = h instanceof Error ? h : this.reason;
n.abort(u instanceof se ? u : new wt(u instanceof Error ? u.message : u));
}
};
let s = e && setTimeout(() => {
s = null, o(new se(`timeout ${e} of ms exceeded`, se.ETIMEDOUT));
}, e);
const a = () => {
r && (s && clearTimeout(s), s = null, r.forEach((h) => {
h.unsubscribe ? h.unsubscribe(o) : h.removeEventListener("abort", o);
}), r = null);
};
r.forEach((h) => h.addEventListener("abort", o));
const { signal: l } = n;
return l.unsubscribe = () => N.asap(a), l;
}
}, la = function* (r, e) {
let t = r.byteLength;
if (t < e) {
yield r;
return;
}
let n = 0, i;
for (; n < t; )
i = n + e, yield r.slice(n, i), n = i;
}, ca = async function* (r, e) {
for await (const t of ha(r))
yield* la(t, e);
}, ha = async function* (r) {
if (r[Symbol.asyncIterator]) {
yield* r;
return;
}
const e = r.getReader();
try {
for (; ; ) {
const { done: t, value: n } = await e.read();
if (t)
break;
yield n;
}
} finally {
await e.cancel();
}
}, si = (r, e, t, n) => {
const i = ca(r, e);
let o = 0, s, a = (l) => {
s || (s = !0, n && n(l));
};
return new ReadableStream({
async pull(l) {
try {
const { done: h, value: u } = await i.next();
if (h) {
a(), l.close();
return;
}
let f = u.byteLength;
if (t) {
let m = o += f;
t(m);
}
l.enqueue(new Uint8Array(u));
} catch (h) {
throw a(h), h;
}
},
cancel(l) {
return a(l), i.return();
}
}, {
highWaterMark: 2
});
}, ri = 64 * 1024, { isFunction: jt } = N, ua = (({ Request: r, Response: e }) => ({
Request: r,
Response: e
}))(N.global), {
ReadableStream: oi,
TextEncoder: ai
} = N.global, li = (r, ...e) => {
try {
return !!r(...e);
} catch {
return !1;
}
}, da = (r) => {
r = N.merge.call({
skipUndefined: !0
}, ua, r);
const { fetch: e, Request: t, Response: n } = r, i = e ? jt(e) : typeof fetch == "function", o = jt(t), s = jt(n);
if (!i)
return !1;
const a = i && jt(oi), l = i && (typeof ai == "function" ? /* @__PURE__ */ ((c) => (d) => c.encode(d))(new ai()) : async (c) => new Uint8Array(await new t(c).arrayBuffer())), h = o && a && li(() => {
let c = !1;
const d = new t(be.origin, {
body: new oi(),
method: "POST",
get duplex() {
return c = !0, "half";
}
}).headers.has("Content-Type");
return c && !d;
}), u = s && a && li(() => N.isReadableStream(new n("").body)), f = {
stream: u && ((c) => c.body)
};
i && ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((c) => {
!f[c] && (f[c] = (d, g) => {
let _ = d && d[c];
if (_)
return _.call(d);
throw new se(`Response type '${c}' is not supported`, se.ERR_NOT_SUPPORT, g);
});
});
const m = async (c) => {
if (c == null)
return 0;
if (N.isBlob(c))
return c.size;
if (N.isSpecCompliantForm(c))
return (await new t(be.origin, {
method: "POST",
body: c
}).arrayBuffer()).byteLength;
if (N.isArrayBufferView(c) || N.isArrayBuffer(c))
return c.byteLength;
if (N.isURLSearchParams(c) && (c = c + ""), N.isString(c))
return (await l(c)).byteLength;
}, p = async (c, d) => {
const g = N.toFiniteNumber(c.getContentLength());
return g ?? m(d);
};
return async (c) => {
let {
url: d,
method: g,
data: _,
signal: w,
cancelToken: b,
timeout: T,
onDownloadProgress: M,
onUploadProgress: C,
responseType: P,
headers: B,
withCredentials: R = "same-origin",
fetchOptions: U
} = Qi(c), q = e || fetch;
P = P ? (P + "").toLowerCase() : "text";
let A = aa([w, b && b.toAbortSignal()], T), z = null;
const x = A && A.unsubscribe && (() => {
A.unsubscribe();
});
let F;
try {
if (C && h && g !== "get" && g !== "head" && (F = await p(B, _)) !== 0) {
let O = new t(d, {
method: "POST",
body: _,
duplex: "half"
}), D;
if (N.isFormData(_) && (D = O.headers.get("content-type")) && B.setContentType(D), O.body) {
const [Q, Y] = ti(
F,
en(ni(C))
);
_ = si(O.body, ri, Q, Y);
}
}
N.isString(R) || (R = R ? "include" : "omit");
const J = o && "credentials" in t.prototype, G = {
...U,
signal: A,
method: g.toUpperCase(),
headers: B.normalize().toJSON(),
body: _,
duplex: "half",
credentials: J ? R : void 0
};
z = o && new t(d, G);
let ne = await (o ? q(z, U) : q(d, G));
const V = u && (P === "stream" || P === "response");
if (u && (M || V && x)) {
const O = {};
["status", "statusText", "headers"].forEach((Z) => {
O[Z] = ne[Z];
});
const D = N.toFiniteNumber(ne.headers.get("content-length")), [Q, Y] = M && ti(
D,
en(ni(M), !0)
) || [];
ne = new n(
si(ne.body, ri, Q, () => {
Y && Y(), x && x();
}),
O
);
}
P = P || "text";
let ee = await f[N.findKey(f, P) || "text"](ne, c);
return !V && x && x(), await new Promise((O, D) => {
$i(O, D, {
data: ee,
headers: Me.from(ne.headers),
status: ne.status,
statusText: ne.statusText,
config: c,
request: z
});
});
} catch (J) {
throw x && x(), J && J.name === "TypeError" && /Load failed|fetch/i.test(J.message) ? Object.assign(
new se("Network Error", se.ERR_NETWORK, c, z),
{
cause: J.cause || J
}
) : se.from(J, J && J.code, c, z);
}
};
}, fa = /* @__PURE__ */ new Map(), es = (r) => {
let e = r && r.env || {};
const { fetch: t, Request: n, Response: i } = e, o = [
n,
i,
t
];
let s = o.length, a = s, l, h, u = fa;
for (; a--; )
l = o[a], h = u.get(l), h === void 0 && u.set(l, h = a ? /* @__PURE__ */ new Map() : da(e)), u = h;
return h;
};
es();
const zn = {
http: Po,
xhr: oa,
fetch: {
get: es
}
};
N.forEach(zn, (r, e) => {
if (r) {
try {
Object.defineProperty(r, "name", { value: e });
} catch {
}
Object.defineProperty(r, "adapterName", { value: e });
}
});
const ci = (r) => `- ${r}`, pa = (r) => N.isFunction(r) || r === null || r === !1;
function ma(r, e) {
r = N.isArray(r) ? r : [r];
const { length: t } = r;
let n, i;
const o = {};
for (let s = 0; s < t; s++) {
n = r[s];
let a;
if (i = n, !pa(n) && (i = zn[(a = String(n)).toLowerCase()], i === void 0))
throw new se(`Unknown adapter '${a}'`);
if (i && (N.isFunction(i) || (i = i.get(e))))
break;
o[a || "#" + s] = i;
}
if (!i) {
const s = Object.entries(o).map(
([l, h]) => `adapter ${l} ` + (h === !1 ? "is not supported by the environment" : "is not available in the build")
);
let a = t ? s.length > 1 ? `since :
` + s.map(ci).join(`
`) : " " + ci(s[0]) : "as no adapter specified";
throw new se(
"There is no suitable adapter to dispatch the request " + a,
"ERR_NOT_SUPPORT"
);
}
return i;
}
const ts = {
/**
* Resolve an adapter from a list of adapter names or functions.
* @type {Function}
*/
getAdapter: ma,
/**
* Exposes all known adapters
* @type {Object<string, Function|Object>}
*/
adapters: zn
};
function gn(r) {
if (r.cancelToken && r.cancelToken.throwIfRequested(), r.signal && r.signal.aborted)
throw new wt(null, r);
}
function hi(r) {
return gn(r), r.headers = Me.from(r.headers), r.data = mn.call(
r,
r.transformRequest
), ["post", "put", "patch"].indexOf(r.method) !== -1 && r.headers.setContentType("application/x-www-form-urlencoded", !1), ts.getAdapter(r.adapter || Pt.adapter, r)(r).then(function(n) {
return gn(r), n.data = mn.call(
r,
r.transformResponse,
n
), n.headers = Me.from(n.headers), n;
}, function(n) {
return Yi(n) || (gn(r), n && n.response && (n.response.data = mn.call(
r,
r.transformResponse,
n.response
), n.response.headers = Me.from(n.response.headers))), Promise.reject(n);
});
}
const ns = "1.13.2", ln = {};
["object", "boolean", "number", "function", "string", "symbol"].forEach((r, e) => {
ln[r] = function(n) {
return typeof n === r || "a" + (e < 1 ? "n " : " ") + r;
};
});
const ui = {};
ln.transitional = function(e, t, n) {
function i(o, s) {
return "[Axios v" + ns + "] Transitional option '" + o + "'" + s + (n ? ". " + n : "");
}
return (o, s, a) => {
if (e === !1)
throw new se(
i(s, " has been removed" + (t ? " in " + t : "")),
se.ERR_DEPRECATED
);
return t && !ui[s] && (ui[s] = !0, console.warn(
i(
s,
" has been deprecated since v" + t + " and will be removed in the near future"
)
)), e ? e(o, s, a) : !0;
};
};
ln.spelling = function(e) {
return (t, n) => (console.warn(`${n} is likely a misspelling of ${e}`), !0);
};
function ga(r, e, t) {
if (typeof r != "object")
throw new se("options must be an object", se.ERR_BAD_OPTION_VALUE);
const n = Object.keys(r);
let i = n.length;
for (; i-- > 0; ) {
const o = n[i], s = e[o];
if (s) {
const a = r[o], l = a === void 0 || s(a, o, r);
if (l !== !0)
throw new se("option " + o + " must be " + l, se.ERR_BAD_OPTION_VALUE);
continue;
}
if (t !== !0)
throw new se("Unknown option " + o, se.ERR_BAD_OPTION);
}
}
const Zt = {
assertOptions: ga,
validators: ln
}, Ne = Zt.validators;
let nt = class {
constructor(e) {
this.defaults = e || {}, this.interceptors = {
request: new Qn(),
response: new Qn()
};
}
/**
* Dispatch a request
*
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
* @param {?Object} config
*
* @returns {Promise} The Promise to be fulfilled
*/
async request(e, t) {
try {
return await this._request(e, t);
} catch (n) {
if (n instanceof Error) {
let i = {};
Error.captureStackTrace ? Error.captureStackTrace(i) : i = new Error();
const o = i.stack ? i.stack.replace(/^.+\n/, "") : "";
try {
n.stack ? o && !String(n.stack).endsWith(o.replace(/^.+\n.+\n/, "")) && (n.stack += `
` + o) : n.stack = o;
} catch {
}
}
throw n;
}
}
_request(e, t) {
typeof e == "string" ? (t = t || {}, t.url = e) : t = e || {}, t = st(this.defaults, t);
const { transitional: n, paramsSerializer: i, headers: o } = t;
n !== void 0 && Zt.assertOptions(n, {
silentJSONParsing: Ne.transitional(Ne.boolean),
forcedJSONParsing: Ne.transitional(Ne.boolean),
clarifyTimeoutError: Ne.transitional(Ne.boolean)
}, !1), i != null && (N.isFunction(i) ? t.paramsSerializer = {
serialize: i
} : Zt.assertOptions(i, {
encode: Ne.function,
serialize: Ne.function
}, !0)), t.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls !== void 0 ? t.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : t.allowAbsoluteUrls = !0), Zt.assertOptions(t, {
baseUrl: Ne.spelling("baseURL"),
withXsrfToken: Ne.spelling("withXSRFToken")
}, !0), t.method = (t.method || this.defaults.method || "get").toLowerCase();
let s = o && N.merge(
o.common,
o[t.method]
);
o && N.forEach(
["delete", "get", "head", "post", "put", "patch", "common"],
(c) => {
delete o[c];
}
), t.headers = Me.concat(s, o);
const a = [];
let l = !0;
this.interceptors.request.forEach(function(d) {
typeof d.runWhen == "function" && d.runWhen(t) === !1 || (l = l && d.synchronous, a.unshift(d.fulfilled, d.rejected));
});
const h = [];
this.interceptors.response.forEach(function(d) {
h.push(d.fulfilled, d.rejected);
});
let u, f = 0, m;
if (!l) {
const c = [hi.bind(this), void 0];
for (c.unshift(...a), c.push(...h), m = c.length, u = Promise.resolve(t); f < m; )
u = u.then(c[f++], c[f++]);
return u;
}
m = a.length;
let p = t;
for (; f < m; ) {
const c = a[f++], d = a[f++];
try {
p = c(p);
} catch (g) {
d.call(this, g);
break;
}
}
try {
u = hi.call(this, p);
} catch (c) {
return Promise.reject(c);
}
for (f = 0, m = h.length; f < m; )
u = u.then(h[f++], h[f++]);
return u;
}
getUri(e) {
e = st(this.defaults, e);
const t = Ji(e.baseURL, e.url, e.allowAbsoluteUrls);
return Xi(t, e.params, e.paramsSerializer);
}
};
N.forEach(["delete", "get", "head", "options"], function(e) {
nt.prototype[e] = function(t, n) {
return this.request(st(n || {}, {
method: e,
url: t,
data: (n || {}).data
}));
};
});
N.forEach(["post", "put", "patch"], function(e) {
function t(n) {
return function(o, s, a) {
return this.request(st(a || {}, {
method: e,
headers: n ? {
"Content-Type": "multipart/form-data"
} : {},
url: o,
data: s
}));
};
}
nt.prototype[e] = t(), nt.prototype[e + "Form"] = t(!0);
});
let _a = class is {
constructor(e) {
if (typeof e != "function")
throw new TypeError("executor must be a function.");
let t;
this.promise = new Promise(function(o) {
t = o;
});
const n = this;
this.promise.then((i) => {
if (!n._listeners) return;
let o = n._listeners.length;
for (; o-- > 0; )
n._listeners[o](i);
n._listeners = null;
}), this.promise.then = (i) => {
let o;
const s = new Promise((a) => {
n.subscribe(a), o = a;
}).then(i);
return s.cancel = function() {
n.unsubscribe(o);
}, s;
}, e(function(o, s, a) {
n.reason || (n.reason = new wt(o, s, a), t(n.reason));
});
}
/**
* Throws a `CanceledError` if cancellation has been requested.
*/
throwIfRequested() {
if (this.reason)
throw this.reason;
}
/**
* Subscribe to the cancel signal
*/
subscribe(e) {
if (this.reason) {
e(this.reason);
return;
}
this._listeners ? this._listeners.push(e) : this._listeners = [e];
}
/**
* Unsubscribe from the cancel signal
*/
unsubscribe(e) {
if (!this._listeners)
return;
const t = this._listeners.indexOf(e);
t !== -1 && this._listeners.splice(t, 1);
}
toAbortSignal() {
const e = new AbortController(), t = (n) => {
e.abort(n);
};
return this.subscribe(t), e.signal.unsubscribe = () => this.unsubscribe(t), e.signal;
}
/**
* Returns an object that contains a new `CancelToken` and a function that, when called,
* cancels the `CancelToken`.
*/
static source() {
let e;
return {
token: new is(function(i) {
e = i;
}),
cancel: e
};
}
};
function ya(r) {
return function(t) {
return r.apply(null, t);
};
}
function wa(r) {
return N.isObject(r) && r.isAxiosError === !0;
}
const An = {
Continue: 100,
SwitchingProtocols: 101,
Processing: 102,
EarlyHints: 103,
Ok: 200,
Created: 201,
Accepted: 202,
NonAuthoritativeInformation: 203,
NoContent: 204,
ResetContent: 205,
PartialContent: 206,
MultiStatus: 207,
AlreadyReported: 208,
ImUsed: 226,
MultipleChoices: 300,
MovedPermanently: 301,
Found: 302,
SeeOther: 303,
NotModified: 304,
UseProxy: 305,
Unused: 306,
TemporaryRedirect: 307,
PermanentRedirect: 308,
BadRequest: 400,
Unauthorized: 401,
PaymentRequired: 402,
Forbidden: 403,
NotFound: 404,
MethodNotAllowed: 405,
NotAcceptable: 406,
ProxyAuthenticationRequired: 407,
RequestTimeout: 408,
Conflict: 409,
Gone: 410,
LengthRequired: 411,
PreconditionFailed: 412,
PayloadTooLarge: 413,
UriTooLong: 414,
UnsupportedMediaType: 415,
RangeNotSatisfiable: 416,
ExpectationFailed: 417,
ImATeapot: 418,
MisdirectedRequest: 421,
UnprocessableEntity: 422,
Locked: 423,
FailedDependency: 424,
TooEarly: 425,
UpgradeRequired: 426,
PreconditionRequired: 428,
TooManyRequests: 429,
RequestHeaderFieldsTooLarge: 431,
UnavailableForLegalReasons: 451,
InternalServerError: 500,
NotImplemented: 501,
BadGateway: 502,
ServiceUnavailable: 503,
GatewayTimeout: 504,
HttpVersionNotSupported: 505,
VariantAlsoNegotiates: 506,
InsufficientStorage: 507,
LoopDetected: 508,
NotExtended: 510,
NetworkAuthenticationRequired: 511,
WebServerIsDown: 521,
ConnectionTimedOut: 522,
OriginIsUnreachable: 523,
TimeoutOccurred: 524,
SslHandshakeFailed: 525,
InvalidSslCertificate: 526
};
Object.entries(An).forEach(([r, e]) => {
An[e] = r;
});
function ss(r) {
const e = new nt(r), t = Ni(nt.prototype.request, e);
return N.extend(t, nt.prototype, e, { allOwnKeys: !0 }), N.extend(t, e, null, { allOwnKeys: !0 }), t.create = function(i) {
return ss(st(r, i));
}, t;
}
const _e = ss(Pt);
_e.Axios = nt;
_e.CanceledError = wt;
_e.CancelToken = _a;
_e.isCancel = Yi;
_e.VERSION = ns;
_e.toFormData = an;
_e.AxiosError = se;
_e.Cancel = _e.CanceledError;
_e.all = function(e) {
return Promise.all(e);
};
_e.spread = ya;
_e.isAxiosError = wa;
_e.mergeConfig = st;
_e.AxiosHeaders = Me;
_e.formToJSON = (r) => qi(N.isHTMLForm(r) ? new FormData(r) : r);
_e.getAdapter = ts.getAdapter;
_e.HttpStatusCode = An;
_e.default = _e;
const {
Axios: Ql,
AxiosError: ec,
CanceledError: tc,
isCancel: nc,
CancelToken: ic,
VERSION: sc,
all: rc,
Cancel: oc,
isAxiosError: ac,
spread: lc,
toFormData: cc,
AxiosHeaders: hc,
HttpStatusCode: uc,
formToJSON: dc,
getAdapter: fc,
mergeConfig: pc
} = _e;
function xa(r, e) {
var t;
if (window.XMLHttpRequest ? t = new XMLHttpRequest() : window.ActiveXObject ? t = new window.ActiveXObject() : alert("请升级至最新版本的浏览器"), t != null) {
let n = r + "?timestamp=" + (/* @__PURE__ */ new Date()).getTime();
t.open("GET", n, !0), t.send(null), t.onreadystatechange = function() {
t.readyState == 4 && t.status == 200 && (t.responseText.includes("</html>", 0) && t.responseText.includes("</body>", 0) && t.responseText.includes("</head>", 0) ? e(null) : e(t.responseText));
}, t.onloadend = function() {
t.readyState == 4 && t.status == 404 && t.status == 502 && e(null);
};
}
}
function rs(r, e) {
_e({
method: "get",
responseType: "blob",
url: r + "?timestamp=" + (/* @__PURE__ */ new Date()).getTime()
// 文件所在阿里云的链接地址
}).then((n) => {
let i = new window.File([n.data], "semantics", {
type: "zip"
});
Hr.loadAsync(i).then((o) => {
for (let s in o.files)
o.file(o.files[s].name).async("blob").then((l) => {
t(l, "utf-8", function(h, u) {
e(u);
});
});
});
});
function t(n, i, o) {
var s = new FileReader(), a = new Blob([n]);
s.onload = function(l) {
o(null, l.target.result);
}, s.onerror = function(l) {
o(l.error, null);
}, s.readAsText(a, i);
}
}
const _n = /* @__PURE__ */ new WeakMap();
class ba extends Si {
/**
* Constructs a new Draco loader.
*
* @param {LoadingManager} [manager] - The loading manager.
*/
constructor(e) {
super(e), this.decoderPath = "", this.decoderConfig = {}, this.decoderBinary = null, this.decoderPending = null, this.workerLimit = 4, this.workerPool = [], this.workerNextTaskID = 1, this.workerSourceURL = "", this.defaultAttributeIDs = {
position: "POSITION",
normal: "NORMAL",
color: "COLOR",
uv: "TEX_COORD"
}, this.defaultAttributeTypes = {
position: "Float32Array",
normal: "Float32Array",
color: "Float32Array",
uv: "Float32Array"
};
}
/**
* Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.
*
* @param {string} path - The decoder path.
* @return {DRACOLoader} A reference to this loader.
*/
setDecoderPath(e) {
return this.decoderPath = e, this;
}
/**
* Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.
*
* @param {{type:('js'|'wasm')}} config - The decoder config.
* @return {DRACOLoader} A reference to this loader.
*/
setDecoderConfig(e) {
return this.decoderConfig = e, this;
}
/**
* Sets the maximum number of Web Workers to be used during decoding.
* A lower limit may be preferable if workers are also for other tasks in the application.
*
* @param {number} workerLimit - The worker limit.
* @return {DRACOLoader} A reference to this loader.
*/
setWorkerLimit(e) {
return this.workerLimit = e, this;
}
/**
* Starts loading from the given URL and passes the loaded Draco asset
* to the `onLoad()` callback.
*
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
* @param {function(BufferGeometry)} onLoad - Executed when the loading process has been finished.
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
* @param {onErrorCallback} onError - Executed when errors occur.
*/
load(e, t, n, i) {
const o = new Qt(this.manager);
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, (s) => {
this.parse(s, t, i);
}, n, i);
}
/**
* Parses the given Draco data.
*
* @param {ArrayBuffer} buffer - The raw Draco data as an array buffer.
* @param {function(BufferGeometry)} onLoad - Executed when the loading/parsing process has been finished.
* @param {onErrorCallback} onError - Executed when errors occur.
*/
parse(e, t, n = () => {
}) {
this.decodeDracoFile(e, t, null, null, Ze, n).catch(n);
}
//
decodeDracoFile(e, t, n, i, o = Ie, s = () => {
}) {
const a = {
attributeIDs: n || this.defaultAttributeIDs,
attributeTypes: i || this.defaultAttributeTypes,
useUniqueIDs: !!n,
vertexColorSpace: o
};
return this.decodeGeometry(e, a).then(t).catch(s);
}
decodeGeometry(e, t) {
const n = JSON.stringify(t);
if (_n.has(e)) {
const l = _n.get(e);
if (l.key === n)
return l.promise;
if (e.byteLength === 0)
throw new Error(
"THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred."
);
}
let i;
const o = this.workerNextTaskID++, s = e.byteLength, a = this._getWorker(o, s).then((l) => (i = l, new Promise((h, u) => {
i._callbacks[o] = { resolve: h, reject: u }, i.postMessage({ type: "decode", id: o, taskConfig: t, buffer: e }, [e]);
}))).then((l) => this._createGeometry(l.geometry));
return a.catch(() => !0).then(() => {
i && o && this._releaseTask(i, o);
}), _n.set(e, {
key: n,
promise: a
}), a;
}
_createGeometry(e) {
const t = new tn();
e.index && t.setIndex(new ft(e.index.array, 1));
for (let n = 0; n < e.attributes.length; n++) {
const { name: i, array: o, itemSize: s, stride: a, vertexColorSpace: l } = e.attributes[n];
let h;
if (s === a)
h = new ft(o, s);
else {
const u = new Ei(o, a);
h = new Mi(u, s, 0);
}
i === "color" && (this._assignVertexColorSpace(h, l), h.normalized = !(o instanceof Float32Array)), t.setAttribute(i, h);
}
return t;
}
_assignVertexColorSpace(e, t) {
if (t !== Ze) return;
const n = new Ce();
for (let i = 0, o = e.count; i < o; i++)
n.fromBufferAttribute(e, i), Jt.colorSpaceToWorking(n, Ze), e.setXYZ(i, n.r, n.g, n.b);
}
_loadLibrary(e, t) {
const n = new Qt(this.manager);
return n.setPath(this.decoderPath), n.setResponseType(t), n.setWithCredentials(this.withCredentials), new Promise((i, o) => {
n.load(e, i, void 0, o);
});
}
preload() {
return this._initDecoder(), this;
}
_initDecoder() {
if (this.decoderPending) return this.decoderPending;
const e = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];
return e ? t.push(this._loadLibrary("draco_decoder.js", "text")) : (t.push(this._loadLibrary("draco_wasm_wrapper.js", "text")), t.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"))), this.decoderPending = Promise.all(t).then((n) => {
const i = n[0];
e || (this.decoderConfig.wasmBinary = n[1]);
const o = va.toString(), s = [
"/* draco decoder */",
i,
"",
"/* worker */",
o.substring(o.indexOf("{") + 1, o.lastIndexOf("}"))
].join(`
`);
this.workerSourceURL = URL.createObjectURL(new Blob([s]));
}), this.decoderPending;
}
_getWorker(e, t) {
return this._initDecoder().then(() => {
if (this.workerPool.length < this.workerLimit) {
const i = new Worker(this.workerSourceURL);
i._callbacks = {}, i._taskCosts = {}, i._taskLoad = 0, i.postMessage({ type: "init", decoderConfig: this.decoderConfig }), i.onmessage = function(o) {
const s = o.data;
switch (s.type) {
case "decode":
i._callbacks[s.id].resolve(s);
break;
case "error":
i._callbacks[s.id].reject(s);
break;
default:
console.error('THREE.DRACOLoader: Unexpected message, "' + s.type + '"');
}
}, this.workerPool.push(i);
} else
this.workerPool.sort(function(i, o) {
return i._taskLoad > o._taskLoad ? -1 : 1;
});
const n = this.workerPool[this.workerPool.length - 1];
return n._taskCosts[e] = t, n._taskLoad += t, n;
});
}
_releaseTask(e, t) {
e._taskLoad -= e._taskCosts[t], delete e._callbacks[t], delete e._taskCosts[t];
}
debug() {
console.log("Task load: ", this.workerPool.map((e) => e._taskLoad));
}
dispose() {
for (let e = 0; e < this.workerPool.length; ++e)
this.workerPool[e].terminate();
return this.workerPool.length = 0, this.workerSourceURL !== "" && URL.revokeObjectURL(this.workerSourceURL), this;
}
}
function va() {
let r, e;
onmessage = function(s) {
const a = s.data;
switch (a.type) {
case "init":
r = a.decoderConfig, e = new Promise(function(u) {
r.onModuleLoaded = function(f) {
u({ draco: f });
}, DracoDecoderModule(r);
});
break;
case "decode":
const l = a.buffer, h = a.taskConfig;
e.then((u) => {
const f = u.draco, m = new f.Decoder();
try {
const p = t(f, m, new Int8Array(l), h), c = p.attributes.map((d) => d.array.buffer);
p.index && c.push(p.index.array.buffer), self.postMessage({ type: "decode", id: a.id, geometry: p }, c);
} catch (p) {
console.error(p), self.postMessage({ type: "error", id: a.id, error: p.message });
} finally {
f.destroy(m);
}
});
break;
}
};
function t(s, a, l, h) {
const u = h.attributeIDs, f = h.attributeTypes;
let m, p;
const c = a.GetEncodedGeometryType(l);
if (c === s.TRIANGULAR_MESH)
m = new s.Mesh(), p = a.DecodeArrayToMesh(l, l.byteLength, m);
else if (c === s.POINT_CLOUD)
m = new s.PointCloud(), p = a.DecodeArrayToPointCloud(l, l.byteLength, m);
else
throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
if (!p.ok() || m.ptr === 0)
throw new Error("THREE.DRACOLoader: Decoding failed: " + p.error_msg());
const d = { index: null, attributes: [] };
for (const g in u) {
const _ = self[f[g]];
let w, b;
if (h.useUniqueIDs)
b = u[g], w = a.GetAttributeByUniqueId(m, b);
else {
if (b = a.GetAttributeId(m, s[u[g]]), b === -1) continue;
w = a.GetAttribute(m, b);
}
const T = i(s, a, m, g, _, w);
g === "color" && (T.vertexColorSpace = h.vertexColorSpace), d.attributes.push(T);
}
return c === s.TRIANGULAR_MESH && (d.index = n(s, a, m)), s.destroy(m), d;
}
function n(s, a, l) {
const u = l.num_faces() * 3, f = u * 4, m = s._malloc(f);
a.GetTrianglesUInt32Array(l, f, m);
const p = new Uint32Array(s.HEAPF32.buffer, m, u).slice();
return s._free(m), { array: p, itemSize: 1 };
}
function i(s, a, l, h, u, f) {
const m = l.num_points(), p = f.num_components(), c = o(s, u), d = p * u.BYTES_PER_ELEMENT, g = Math.ceil(d / 4) * 4, _ = g / u.BYTES_PER_ELEMENT, w = m * d, b = m * g, T = s._malloc(w);
a.GetAttributeDataArrayForAllPoints(l, f, c, w, T);
const M = new u(s.HEAPF32.buffer, T, w / u.BYTES_PER_ELEMENT);
let C;
if (d === g)
C = M.slice();
else {
C = new u(b / u.BYTES_PER_ELEMENT);
let P = 0;
for (let B = 0, R = M.length; B < R; B++) {
for (let U = 0; U < p; U++)
C[P + U] = M[B * p + U];
P += _;
}
}
return s._free(T), {
name: h,
count: m,
itemSize: p,
array: C,
stride: _
};
}
function o(s, a) {
switch (a) {
case Float32Array:
return s.DT_FLOAT32;
case Int8Array:
return s.DT_INT8;
case Int16Array:
return s.DT_INT16;
case Int32Array:
return s.DT_INT32;
case Uint8Array:
return s.DT_UINT8;
case Uint16Array:
return s.DT_UINT16;
case Uint32Array:
return s.DT_UINT32;
}
}
}
var Mt = /* @__PURE__ */ ((r) => (r.ModelLoadStart = "model-load-start", r.ModelLoadProgress = "model-load-progress", r.ModelLoaded = "model-loaded", r.ModelError = "model-error", r.SelectionChanged = "selection-changed", r.HoverChanged = "hover-changed", r.Click = "click", r.MouseMove = "mouse-move", r.CameraChanged = "camera-changed", r.CameraIdle = "camera-idle", r.EngineFree = "engine-free", r.EngineBusy = "engine-busy", r))(Mt || {});
function Ta(r, e, t, n) {
let i = 0, o = 0, s = 0, a = r.models.find((p) => p.url == t), l = e.circularMeps, h = e.rectMeps.filter((p) => p.type === "风管"), u = e.rectMeps.filter((p) => p.type === "桥架"), f = e.ellipseMeps, m = r.scene;
if (new v.MeshBasicMaterial(), new v.BufferGeometry(), Vt(m, "InstancedMesh"), l && l.length) {
let p = [];
for (let c of l)
c.color = new v.Color(`rgb(${c.color})`), c.position = {
x: c.startPoint.X * 0.3048 + i,
y: c.startPoint.Z * 0.3048 + o,
z: -c.startPoint.Y * 0.3048 + s
}, c.rotation = {
x: 0,
y: 0,
z: 0
}, a.nodesMap.set(c.id, [c]), p.push(c);
Ht("Circle", m, p, 2);
}
if (Vt(m, "InstancedMesh"), h && h.length) {
let p = [];
for (let c of h)
c.color = new v.Color(`rgb(${c.color})`), c.position = {
x: c.startPoint.X * 0.3048 + i,
y: c.startPoint.Z * 0.3048 + o,
z: -c.startPoint.Y * 0.3048 + s
}, c.rotation = {
x: 0,
y: 0,
z: 0
}, a.nodesMap.set(c.id, [c]), p.push(c);
Ht("Rect", m, p, 3);
}
if (Vt(m, "InstancedMesh"), f && f.length) {
let p = [];
for (let c of f)
c.color = new v.Color(`rgb(${c.color})`), c.position = {
x: c.startPoint.X * 0.3048 + i,
y: c.startPoint.Z * 0.3048 + o,
z: -c.startPoint.Y * 0.3048 + s
}, c.rotation = {
x: 0,
y: 0,
z: 0
}, a.nodesMap.set(c.id, [c]), p.push(c);
Ht("Ellipse", m, p, 4);
}
if (Vt(m, "InstancedMesh"), u && u.length) {
let p = [];
for (let c of u)
c.color = new v.Color(`rgb(${c.color})`), c.position = {
x: c.startPoint.X * 0.3048 + i,
y: c.startPoint.Z * 0.3048 + o,
z: -c.startPoint.Y * 0.3048 + s
}, c.rotation = {
x: 0,
y: 0,
z: 0
}, a.nodesMap.set(c.id, [c]), p.push(c);
Ht("Bridge", m, p, 5);
}
}
function Vt(r, e) {
let t = new v.InstancedMesh(e.geometry, e.material, 1);
t.index = e.index, t.dataType = e.type, t.url = e.url, t.relativeIndex = e.relativeIndex, t.name = "机电", r.add(t);
}
function Ht(r, e, t, n, i) {
let o, s, a = {
width: 1,
height: 1,
length: 1,
diameter: 1,
color: new v.Color(),
position: {
x: 0,
y: 0,
z: 0
},
rotation: {
x: 0,
y: 0,
z: 0
}
};
switch (r) {
case "Rect":
s = Gt("Rect", a);
break;
case "Bridge":
s = Gt("Bridge", a);
break;
case "Circle":
s = Gt("Circle", a);
break;
case "Ellipse":
s = Gt("Ellipse", a);
break;
}
s && (o = new v.InstancedMesh(s.geometry, s.material, t.length));
let l = [];
for (var h = 0; h < t.length; h++) {
let m = t[h], p = new v.Vector3(m.startPoint.X, 0, -m.startPoint.Y), c = new v.Vector3(m.endPoint.X, 0, -m.endPoint.Y), d = new v.Vector3(m.startPoint.X, m.startPoint.Z, -m.startPoint.Y), g = new v.Vector3(m.endPoint.X, m.endPoint.Z, -m.endPoint.Y), _ = 0, w = 0, b = 0;
if (Math.abs(c.clone().sub(p.clone()).z) < 0.01 && Math.abs(c.clone().sub(p.clone()).x) < 0.01) {
if (_ = (m.startPoint.Z > m.endPoint.Z ? 1 : -1) * Math.PI * 0.5, m.base_x != null) {
var u = new v.Vector3(m.base_x.X, 0, -m.base_x.Y);
w = (u.clone().cross(new v.Vector3(0, 0, 1)).y <= 0 ? 1 : -1) * u.angleTo(new v.Vector3(0, 0, 1)) + Math.PI * 0.5;
}
} else
w = (c.clone().sub(p.clone()).cross(new v.Vector3(0, 0, 1)).y > 0 ? -1 : 1) * c.clone().sub(p.clone()).angleTo(new v.Vector3(0, 0, 1)), _ = (m.startPoint.Z > m.endPoint.Z ? 1 : -1) * c.clone().sub(p.clone()).angleTo(g.clone().sub(d.clone()));
let T = new v.Matrix4();
const M = new v.Euler(_, w, b, "YXZ");
let C = T.clone().makeRotationFromEuler(M), P, B;
r === "Circle" ? (P = m.diameter, B = m.diameter) : (P = m.width, B = m.height);
let R = T.clone().makeScale(P, B, m.length);
T.multiplyMatrices(C, R), T.setPosition(m.position.x, m.position.y, m.position.z), o.setMatrixAt(h, T.clone()), o.setColorAt(h, m.color), o.geometry.computeBoundingBox();
let U = o.geometry.boundingBox.min.clone().applyMatrix4(T.clone()), q = o.geometry.boundingBox.max.clone().applyMatrix4(T.clone()), A = new v.Vector3(Math.min(U.x, q.x), Math.min(U.y, q.y), Math.min(U.z, q.z)), z = new v.Vector3(Math.max(U.x, q.x), Math.max(U.y, q.y), Math.max(U.z, q.z)), x = A.clone().add(z.clone()).multiplyScalar(0.5), F = {
name: m.name,
min: A,
max: z,
center: x,
dbid: h,
// url: path + "/" + type,
// basePath: url,
// relativePath: relativePath,
materialName: s.material.name
}, J = null, G = null;
r === "Circle" && (J = {
x: m.startPoint.X * 0.3048,
y: m.startPoint.Z * 0.3048,
z: -m.startPoint.Y * 0.3048
}, G = {
x: m.endPoint.X * 0.3048,
y: m.endPoint.Z * 0.3048,
z: -m.endPoint.Y * 0.3048
}, F.minC = J, F.maxC = G), l.push(F);
}
o.castShadow = !0, o.ElementInfos = l, o.name = "rootModel", o.TypeName = "InstancedMesh-Pipe", o.PipeType = r, o.MeshId = null, o.realMaterial = o.material.clone(), o.originalMaterial = o.material.clone();
let f = [];
f = {
geometry: o.geometry,
matrix: o.matrix,
position: o.position,
rotation: o.rotation
}, o.meshs = f, o.instanceMatrix && o.instanceMatrix.array && (o.cloneInstanceMatrix = Array.from(o.instanceMatrix.array)), o.index = n, o.Version = "V1", e.children[n] = o;
}
function Gt(r, e, t) {
let n = new v.Shape();
switch (e.width = e.width * 0.3048, e.height = e.height * 0.3048, e.diameter = e.diameter * 0.3048, r) {
case "Rect":
n.moveTo(-e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, e.height / 2), n.lineTo(e.width / 2, e.height / 2), n.lineTo(e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, -e.height / 2);
break;
case "Ellipse":
n.moveTo(-e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, e.height / 2), n.lineTo(e.width / 2, e.height / 2), n.lineTo(e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, -e.height / 2);
break;
case "Bridge":
n.moveTo(-e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, e.height / 2), n.lineTo(-e.width / 2 + 0.01, e.height / 2), n.lineTo(-e.width / 2 + 0.01, -e.height / 2 + 0.01), n.lineTo(e.width / 2 - 0.01, -e.height / 2 + 0.01), n.lineTo(e.width / 2 - 0.01, e.height / 2), n.lineTo(e.width / 2, e.height / 2), n.lineTo(e.width / 2, -e.height / 2), n.lineTo(-e.width / 2, -e.height / 2);
break;
case "Circle":
n.moveTo(0, 0), n.absarc(0, 0, e.diameter * 0.5, 0, Math.PI * 2, !1);
break;
}
const i = {
depth: e.length * 0.3048,
//拉伸长度
bevelEnabled: !1
};
return o(n, i, e.color, e.position, e.rotation);
function o(s, a, l, h, u) {
let f = new v.ExtrudeGeometry(s, a), m = new v.MeshPhongMaterial({
color: l,
side: v.DoubleSide
// depthTest:false
// name: path + "/" + type + "/material"
}), p = new v.Mesh(f, m);
return p.position.set(h.x, h.y, h.z), p.rotation._order = "YXZ", p.rotation.set(u.x, u.y, u.z), p;
}
}
function Sa(r, e = !1) {
const t = r[0].index !== null, n = new Set(Object.keys(r[0].attributes)), i = new Set(Object.keys(r[0].morphAttributes)), o = {}, s = {}, a = r[0].morphTargetsRelative, l = new tn();
let h = 0;
for (let u = 0; u < r.length; ++u) {
const f = r[u];
let m = 0;
if (t !== (f.index !== null))
return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."), null;
for (const p in f.attributes) {
if (!n.has(p))
return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + '. All geometries must have compatible attributes; make sure "' + p + '" attribute exists among all geometries, or in none of them.'), null;
o[p] === void 0 && (o[p] = []), o[p].push(f.attributes[p]), m++;
}
if (m !== n.size)
return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". Make sure all geometries have the same number of attributes."), null;
if (a !== f.morphTargetsRelative)
return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". .morphTargetsRelative must be consistent throughout all geometries."), null;
for (const p in f.morphAttributes) {
if (!i.has(p))
return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". .morphAttributes must be consistent throughout all geometries."), null;
s[p] === void 0 && (s[p] = []), s[p].push(f.morphAttributes[p]);
}
if (e) {
let p;
if (t)
p = f.index.count;
else if (f.attributes.position !== void 0)
p = f.attributes.position.count;
else
return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". The geometry must have either an index or a position attribute"), null;
l.addGroup(h, p, u), h += p;
}
}
if (t) {
let u = 0;
const f = [];
for (let m = 0; m < r.length; ++m) {
const p = r[m].index;
for (let c = 0; c < p.count; ++c)
f.push(p.getX(c) + u);
u += r[m].attributes.position.count;
}
l.setIndex(f);
}
for (const u in o) {
const f = di(o[u]);
if (!f)
return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + u + " attribute."), null;
l.setAttribute(u, f);
}
for (const u in s) {
const f = s[u][0].length;
if (f === 0) break;
l.morphAttributes = l.morphAttributes || {}, l.morphAttributes[u] = [];
for (let m = 0; m < f; ++m) {
const p = [];
for (let d = 0; d < s[u].length; ++d)
p.push(s[u][d][m]);
const c = di(p);
if (!c)
return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + u + " morphAttribute."), null;
l.morphAttributes[u].push(c);
}
}
return l;
}
function di(r) {
let e, t, n, i = -1, o = 0;
for (let h = 0; h < r.length; ++h) {
const u = r[h];
if (e === void 0 && (e = u.array.constructor), e !== u.array.constructor)
return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."), null;
if (t === void 0 && (t = u.itemSize), t !== u.itemSize)
return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."), null;
if (n === void 0 && (n = u.normalized), n !== u.normalized)
return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."), null;
if (i === -1 && (i = u.gpuType), i !== u.gpuType)
return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."), null;
o += u.count * t;
}
const s = new e(o), a = new ft(s, t, n);
let l = 0;
for (let h = 0; h < r.length; ++h) {
const u = r[h];
if (u.isInterleavedBufferAttribute) {
const f = l / t;
for (let m = 0, p = u.count; m < p; m++)
for (let c = 0; c < t; c++) {
const d = u.getComponent(m, c);
a.setComponent(m + f, c, d);
}
} else
s.set(u.array, l);
l += u.count * t;
}
return i !== void 0 && (a.gpuType = i), a;
}
function fi(r, e) {
if (e === Ps)
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), r;
if (e === vn || e === Ai) {
let t = r.getIndex();
if (t === null) {
const s = [], a = r.getAttribute("position");
if (a !== void 0) {
for (let l = 0; l < a.count; l++)
s.push(l);
r.setIndex(s), t = r.getIndex();
} else
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), r;
}
const n = t.count - 2, i = [];
if (e === vn)
for (let s = 1; s <= n; s++)
i.push(t.getX(0)), i.push(t.getX(s)), i.push(t.getX(s + 1));
else
for (let s = 0; s < n; s++)
s % 2 === 0 ? (i.push(t.getX(s)), i.push(t.getX(s + 1)), i.push(t.getX(s + 2))) : (i.push(t.getX(s + 2)), i.push(t.getX(s + 1)), i.push(t.getX(s)));
i.length / 3 !== n && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
const o = r.clone();
return o.setIndex(i), o.clearGroups(), o;
} else
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), r;
}
class Ea extends Si {
/**
* Constructs a new glTF loader.
*
* @param {LoadingManager} [manager] - The loading manager.
*/
constructor(e) {
super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
return new Pa(t);
}), this.register(function(t) {
return new Ra(t);
}), this.register(function(t) {
return new Fa(t);
}), this.register(function(t) {
return new ja(t);
}), this.register(function(t) {
return new Va(t);
}), this.register(function(t) {
return new La(t);
}), this.register(function(t) {
return new Oa(t);
}), this.register(function(t) {
return new Na(t);
}), this.register(function(t) {
return new za(t);
}), this.register(function(t) {
return new ka(t);
}), this.register(function(t) {
return new Ia(t);
}), this.register(function(t) {
return new Da(t);
}), this.register(function(t) {
return new Ua(t);
}), this.register(function(t) {
return new Ba(t);
}), this.register(function(t) {
return new Aa(t);
}), this.register(function(t) {
return new Ha(t);
}), this.register(function(t) {
return new Ga(t);
});
}
/**
* Starts loading from the given URL and passes the loaded glTF asset
* to the `onLoad()` callback.
*
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
* @param {onErrorCallback} onError - Executed when errors occur.
*/
load(e, t, n, i) {
const o = this;
let s;
if (this.resourcePath !== "")
s = this.resourcePath;
else if (this.path !== "") {
const h = Et.extractUrlBase(e);
s = Et.resolveURL(h, this.path);
} else
s = Et.extractUrlBase(e);
this.manager.itemStart(e);
const a = function(h) {
i ? i(h) : console.error(h), o.manager.itemError(e), o.manager.itemEnd(e);
}, l = new Qt(this.manager);
l.setPath(this.path), l.setResponseType("arraybuffer"), l.setRequestHeader(this.requestHeader), l.setWithCredentials(this.withCredentials), l.load(e, function(h) {
try {
o.parse(h, s, function(u) {
t(u), o.manager.itemEnd(e);
}, a);
} catch (u) {
a(u);
}
}, n, a);
}
/**
* Sets the given Draco loader to this loader. Required for decoding assets
* compressed with the `KHR_draco_mesh_compression` extension.
*
* @param {DRACOLoader} dracoLoader - The Draco loader to set.
* @return {GLTFLoader} A reference to this loader.
*/
setDRACOLoader(e) {
return this.dracoLoader = e, this;
}
/**
* Sets the given KTX2 loader to this loader. Required for loading KTX2
* compressed textures.
*
* @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
* @return {GLTFLoader} A reference to this loader.
*/
setKTX2Loader(e) {
return this.ktx2Loader = e, this;
}
/**
* Sets the given meshopt decoder. Required for decoding assets
* compressed with the `EXT_meshopt_compression` extension.
*
* @param {Object} meshoptDecoder - The meshopt decoder to set.
* @return {GLTFLoader} A reference to this loader.
*/
setMeshoptDecoder(e) {
return this.meshoptDecoder = e, this;
}
/**
* Registers a plugin callback. This API is internally used to implement the various
* glTF extensions but can also used by third-party code to add additional logic
* to the loader.
*
* @param {function(parser:GLTFParser)} callback - The callback function to register.
* @return {GLTFLoader} A reference to this loader.
*/
register(e) {
return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
}
/**
* Unregisters a plugin callback.
*
* @param {Function} callback - The callback function to unregister.
* @return {GLTFLoader} A reference to this loader.
*/
unregister(e) {
return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
}
/**
* Parses the given FBX data and returns the resulting group.
*
* @param {string|ArrayBuffer} data - The raw glTF data.
* @param {string} path - The URL base path.
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
* @param {onErrorCallback} onError - Executed when errors occur.
*/
parse(e, t, n, i) {
let o;
const s = {}, a = {}, l = new TextDecoder();
if (typeof e == "string")
o = JSON.parse(e);
else if (e instanceof ArrayBuffer)
if (l.decode(new Uint8Array(e, 0, 4)) === os) {
try {
s[ae.KHR_BINARY_GLTF] = new Wa(e);
} catch (f) {
i && i(f);
return;
}
o = JSON.parse(s[ae.KHR_BINARY_GLTF].content);
} else
o = JSON.parse(l.decode(e));
else
o = e;
if (o.asset === void 0 || o.asset.version[0] < 2) {
i && i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
return;
}
const h = new sl(o, {
path: t || this.resourcePath || "",
crossOrigin: this.crossOrigin,
requestHeader: this.requestHeader,
manager: this.manager,
ktx2Loader: this.ktx2Loader,
meshoptDecoder: this.meshoptDecoder
});
h.fileLoader.setRequestHeader(this.requestHeader);
for (let u = 0; u < this.pluginCallbacks.length; u++) {
const f = this.pluginCallbacks[u](h);
f.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[f.name] = f, s[f.name] = !0;
}
if (o.extensionsUsed)
for (let u = 0; u < o.extensionsUsed.length; ++u) {
const f = o.extensionsUsed[u], m = o.extensionsRequired || [];
switch (f) {
case ae.KHR_MATERIALS_UNLIT:
s[f] = new Ca();
break;
case ae.KHR_DRACO_MESH_COMPRESSION:
s[f] = new Ka(o, this.dracoLoader);
break;
case ae.KHR_TEXTURE_TRANSFORM:
s[f] = new Xa();
break;
case ae.KHR_MESH_QUANTIZATION:
s[f] = new Za();
break;
default:
m.indexOf(f) >= 0 && a[f] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + f + '".');
}
}
h.setExtensions(s), h.setPlugins(a), h.parse(n, i);
}
/**
* Async version of {@link GLTFLoader#parse}.
*
* @async
* @param {string|ArrayBuffer} data - The raw glTF data.
* @param {string} path - The URL base path.
* @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
*/
parseAsync(e, t) {
const n = this;
return new Promise(function(i, o) {
n.parse(e, t, i, o);
});
}
}
function Ma() {
let r = {};
return {
get: function(e) {
return r[e];
},
add: function(e, t) {
r[e] = t;
},
remove: function(e) {
delete r[e];
},
removeAll: function() {
r = {};
}
};
}
const ae = {
KHR_BINARY_GLTF: "KHR_binary_glTF",
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
KHR_MATERIALS_IOR: "KHR_materials_ior",
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
EXT_MATERIALS_BUMP: "EXT_materials_bump",
EXT_TEXTURE_WEBP: "EXT_texture_webp",
EXT_TEXTURE_AVIF: "EXT_texture_avif",
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
};
class Aa {
constructor(e) {
this.parser = e, this.name = ae.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
}
_markDefs() {
const e = this.parser, t = this.parser.json.nodes || [];
for (let n = 0, i = t.length; n < i; n++) {
const o = t[n];
o.extensions && o.extensions[this.name] && o.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, o.extensions[this.name].light);
}
}
_loadLight(e) {
const t = this.parser, n = "light:" + e;
let i = t.cache.get(n);
if (i) return i;
const o = t.json, l = ((o.extensions && o.extensions[this.name] || {}).lights || [])[e];
let h;
const u = new Ce(16777215);
l.color !== void 0 && u.setRGB(l.color[0], l.color[1], l.color[2], Ie);
const f = l.range !== void 0 ? l.range : 0;
switch (l.type) {
case "directional":
h = new Ls(u), h.target.position.set(0, 0, -1), h.add(h.target);
break;
case "point":
h = new Ds(u), h.distance = f;
break;
case "spot":
h = new Rs(u), h.distance = f, l.spot = l.spot || {}, l.spot.innerConeAngle = l.spot.innerConeAngle !== void 0 ? l.spot.innerConeAngle : 0, l.spot.outerConeAngle = l.spot.outerConeAngle !== void 0 ? l.spot.outerConeAngle : Math.PI / 4, h.angle = l.spot.outerConeAngle, h.penumbra = 1 - l.spot.innerConeAngle / l.spot.outerConeAngle, h.target.position.set(0, 0, -1), h.add(h.target);
break;
default:
throw new Error("THREE.GLTFLoader: Unexpected light type: " + l.type);
}
return h.position.set(0, 0, 0), ze(h, l), l.intensity !== void 0 && (h.intensity = l.intensity), h.name = t.createUniqueName(l.name || "light_" + e), i = Promise.resolve(h), t.cache.add(n, i), i;
}
getDependency(e, t) {
if (e === "light")
return this._loadLight(t);
}
createNodeAttachment(e) {
const t = this, n = this.parser, o = n.json.nodes[e], a = (o.extensions && o.extensions[this.name] || {}).light;
return a === void 0 ? null : this._loadLight(a).then(function(l) {
return n._getNodeRef(t.cache, a, l);
});
}
}
class Ca {
constructor() {
this.name = ae.KHR_MATERIALS_UNLIT;
}
getMaterialType() {
return ct;
}
extendParams(e, t, n) {
const i = [];
e.color = new Ce(1, 1, 1), e.opacity = 1;
const o = t.pbrMetallicRoughness;
if (o) {
if (Array.isArray(o.baseColorFactor)) {
const s = o.baseColorFactor;
e.color.setRGB(s[0], s[1], s[2], Ie), e.opacity = s[3];
}
o.baseColorTexture !== void 0 && i.push(n.assignTexture(e, "map", o.baseColorTexture, Ze));
}
return Promise.all(i);
}
}
class ka {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_EMISSIVE_STRENGTH;
}
extendMaterialParams(e, t) {
const i = this.parser.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = i.extensions[this.name].emissiveStrength;
return o !== void 0 && (t.emissiveIntensity = o), Promise.resolve();
}
}
class Pa {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_CLEARCOAT;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const n = this.parser, i = n.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = [], s = i.extensions[this.name];
if (s.clearcoatFactor !== void 0 && (t.clearcoat = s.clearcoatFactor), s.clearcoatTexture !== void 0 && o.push(n.assignTexture(t, "clearcoatMap", s.clearcoatTexture)), s.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = s.clearcoatRoughnessFactor), s.clearcoatRoughnessTexture !== void 0 && o.push(n.assignTexture(t, "clearcoatRoughnessMap", s.clearcoatRoughnessTexture)), s.clearcoatNormalTexture !== void 0 && (o.push(n.assignTexture(t, "clearcoatNormalMap", s.clearcoatNormalTexture)), s.clearcoatNormalTexture.scale !== void 0)) {
const a = s.clearcoatNormalTexture.scale;
t.clearcoatNormalScale = new de(a, a);
}
return Promise.all(o);
}
}
class Ra {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_DISPERSION;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const i = this.parser.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = i.extensions[this.name];
return t.dispersion = o.dispersion !== void 0 ? o.dispersion : 0, Promise.resolve();
}
}
class Da {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_IRIDESCENCE;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const n = this.parser, i = n.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = [], s = i.extensions[this.name];
return s.iridescenceFactor !== void 0 && (t.iridescence = s.iridescenceFactor), s.iridescenceTexture !== void 0 && o.push(n.assignTexture(t, "iridescenceMap", s.iridescenceTexture)), s.iridescenceIor !== void 0 && (t.iridescenceIOR = s.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), s.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = s.iridescenceThicknessMinimum), s.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = s.iridescenceThicknessMaximum), s.iridescenceThicknessTexture !== void 0 && o.push(n.assignTexture(t, "iridescenceThicknessMap", s.iridescenceThicknessTexture)), Promise.all(o);
}
}
class La {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_SHEEN;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const n = this.parser, i = n.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = [];
t.sheenColor = new Ce(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
const s = i.extensions[this.name];
if (s.sheenColorFactor !== void 0) {
const a = s.sheenColorFactor;
t.sheenColor.setRGB(a[0], a[1], a[2], Ie);
}
return s.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = s.sheenRoughnessFactor), s.sheenColorTexture !== void 0 && o.push(n.assignTexture(t, "sheenColorMap", s.sheenColorTexture, Ze)), s.sheenRoughnessTexture !== void 0 && o.push(n.assignTexture(t, "sheenRoughnessMap", s.sheenRoughnessTexture)), Promise.all(o);
}
}
class Oa {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_TRANSMISSION;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const n = this.parser, i = n.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = [], s = i.extensions[this.name];
return s.transmissionFactor !== void 0 && (t.transmission = s.transmissionFactor), s.transmissionTexture !== void 0 && o.push(n.assignTexture(t, "transmissionMap", s.transmissionTexture)), Promise.all(o);
}
}
class Na {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_VOLUME;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const n = this.parser, i = n.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = [], s = i.extensions[this.name];
t.thickness = s.thicknessFactor !== void 0 ? s.thicknessFactor : 0, s.thicknessTexture !== void 0 && o.push(n.assignTexture(t, "thicknessMap", s.thicknessTexture)), t.attenuationDistance = s.attenuationDistance || 1 / 0;
const a = s.attenuationColor || [1, 1, 1];
return t.attenuationColor = new Ce().setRGB(a[0], a[1], a[2], Ie), Promise.all(o);
}
}
class za {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_IOR;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const i = this.parser.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = i.extensions[this.name];
return t.ior = o.ior !== void 0 ? o.ior : 1.5, Promise.resolve();
}
}
class Ia {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_SPECULAR;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const n = this.parser, i = n.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = [], s = i.extensions[this.name];
t.specularIntensity = s.specularFactor !== void 0 ? s.specularFactor : 1, s.specularTexture !== void 0 && o.push(n.assignTexture(t, "specularIntensityMap", s.specularTexture));
const a = s.specularColorFactor || [1, 1, 1];
return t.specularColor = new Ce().setRGB(a[0], a[1], a[2], Ie), s.specularColorTexture !== void 0 && o.push(n.assignTexture(t, "specularColorMap", s.specularColorTexture, Ze)), Promise.all(o);
}
}
class Ba {
constructor(e) {
this.parser = e, this.name = ae.EXT_MATERIALS_BUMP;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const n = this.parser, i = n.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = [], s = i.extensions[this.name];
return t.bumpScale = s.bumpFactor !== void 0 ? s.bumpFactor : 1, s.bumpTexture !== void 0 && o.push(n.assignTexture(t, "bumpMap", s.bumpTexture)), Promise.all(o);
}
}
class Ua {
constructor(e) {
this.parser = e, this.name = ae.KHR_MATERIALS_ANISOTROPY;
}
getMaterialType(e) {
const n = this.parser.json.materials[e];
return !n.extensions || !n.extensions[this.name] ? null : Fe;
}
extendMaterialParams(e, t) {
const n = this.parser, i = n.json.materials[e];
if (!i.extensions || !i.extensions[this.name])
return Promise.resolve();
const o = [], s = i.extensions[this.name];
return s.anisotropyStrength !== void 0 && (t.anisotropy = s.anisotropyStrength), s.anisotropyRotation !== void 0 && (t.anisotropyRotation = s.anisotropyRotation), s.anisotropyTexture !== void 0 && o.push(n.assignTexture(t, "anisotropyMap", s.anisotropyTexture)), Promise.all(o);
}
}
class Fa {
constructor(e) {
this.parser = e, this.name = ae.KHR_TEXTURE_BASISU;
}
loadTexture(e) {
const t = this.parser, n = t.json, i = n.textures[e];
if (!i.extensions || !i.extensions[this.name])
return null;
const o = i.extensions[this.name], s = t.options.ktx2Loader;
if (!s) {
if (n.extensionsRequired && n.extensionsRequired.indexOf(this.name) >= 0)
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
return null;
}
return t.loadTextureImage(e, o.source, s);
}
}
class ja {
constructor(e) {
this.parser = e, this.name = ae.EXT_TEXTURE_WEBP;
}
loadTexture(e) {
const t = this.name, n = this.parser, i = n.json, o = i.textures[e];
if (!o.extensions || !o.extensions[t])
return null;
const s = o.extensions[t], a = i.images[s.source];
let l = n.textureLoader;
if (a.uri) {
const h = n.options.manager.getHandler(a.uri);
h !== null && (l = h);
}
return n.loadTextureImage(e, s.source, l);
}
}
class Va {
constructor(e) {
this.parser = e, this.name = ae.EXT_TEXTURE_AVIF;
}
loadTexture(e) {
const t = this.name, n = this.parser, i = n.json, o = i.textures[e];
if (!o.extensions || !o.extensions[t])
return null;
const s = o.extensions[t], a = i.images[s.source];
let l = n.textureLoader;
if (a.uri) {
const h = n.options.manager.getHandler(a.uri);
h !== null && (l = h);
}
return n.loadTextureImage(e, s.source, l);
}
}
class Ha {
constructor(e) {
this.name = ae.EXT_MESHOPT_COMPRESSION, this.parser = e;
}
loadBufferView(e) {
const t = this.parser.json, n = t.bufferViews[e];
if (n.extensions && n.extensions[this.name]) {
const i = n.extensions[this.name], o = this.parser.getDependency("buffer", i.buffer), s = this.parser.options.meshoptDecoder;
if (!s || !s.supported) {
if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
return null;
}
return o.then(function(a) {
const l = i.byteOffset || 0, h = i.byteLength || 0, u = i.count, f = i.byteStride, m = new Uint8Array(a, l, h);
return s.decodeGltfBufferAsync ? s.decodeGltfBufferAsync(u, f, m, i.mode, i.filter).then(function(p) {
return p.buffer;
}) : s.ready.then(function() {
const p = new ArrayBuffer(u * f);
return s.decodeGltfBuffer(new Uint8Array(p), u, f, m, i.mode, i.filter), p;
});
});
} else
return null;
}
}
class Ga {
constructor(e) {
this.name = ae.EXT_MESH_GPU_INSTANCING, this.parser = e;
}
createNodeMesh(e) {
const t = this.parser.json, n = t.nodes[e];
if (!n.extensions || !n.extensions[this.name] || n.mesh === void 0)
return null;
const i = t.meshes[n.mesh];
for (const h of i.primitives)
if (h.mode !== ke.TRIANGLES && h.mode !== ke.TRIANGLE_STRIP && h.mode !== ke.TRIANGLE_FAN && h.mode !== void 0)
return null;
const s = n.extensions[this.name].attributes, a = [], l = {};
for (const h in s)
a.push(this.parser.getDependency("accessor", s[h]).then((u) => (l[h] = u, l[h])));
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(e)), Promise.all(a).then((h) => {
const u = h.pop(), f = u.isGroup ? u.children : [u], m = h[0].count, p = [];
for (const c of f) {
const d = new Xe(), g = new pe(), _ = new Yt(), w = new pe(1, 1, 1), b = new Os(c.geometry, c.material, m);
for (let T = 0; T < m; T++)
l.TRANSLATION && g.fromBufferAttribute(l.TRANSLATION, T), l.ROTATION && _.fromBufferAttribute(l.ROTATION, T), l.SCALE && w.fromBufferAttribute(l.SCALE, T), b.setMatrixAt(T, d.compose(g, _, w));
for (const T in l)
if (T === "_COLOR_0") {
const M = l[T];
b.instanceColor = new Ns(M.array, M.itemSize, M.normalized);
} else T !== "TRANSLATION" && T !== "ROTATION" && T !== "SCALE" && c.geometry.setAttribute(T, l[T]);
Ci.prototype.copy.call(b, c), this.parser.assignFinalMaterial(b), p.push(b);
}
return u.isGroup ? (u.clear(), u.add(...p), u) : p[0];
}));
}
}
const os = "glTF", Tt = 12, pi = { JSON: 1313821514, BIN: 5130562 };
class Wa {
constructor(e) {
this.name = ae.KHR_BINARY_GLTF, this.content = null, this.body = null;
const t = new DataView(e, 0, Tt), n = new TextDecoder();
if (this.header = {
magic: n.decode(new Uint8Array(e.slice(0, 4))),
version: t.getUint32(4, !0),
length: t.getUint32(8, !0)
}, this.header.magic !== os)
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
if (this.header.version < 2)
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
const i = this.header.length - Tt, o = new DataView(e, Tt);
let s = 0;
for (; s < i; ) {
const a = o.getUint32(s, !0);
s += 4;
const l = o.getUint32(s, !0);
if (s += 4, l === pi.JSON) {
const h = new Uint8Array(e, Tt + s, a);
this.content = n.decode(h);
} else if (l === pi.BIN) {
const h = Tt + s;
this.body = e.slice(h, h + a);
}
s += a;
}
if (this.content === null)
throw new Error("THREE.GLTFLoader: JSON content not found.");
}
}
class Ka {
constructor(e, t) {
if (!t)
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
this.name = ae.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
}
decodePrimitive(e, t) {
const n = this.json, i = this.dracoLoader, o = e.extensions[this.name].bufferView, s = e.extensions[this.name].attributes, a = {}, l = {}, h = {};
for (const u in s) {
const f = Cn[u] || u.toLowerCase();
a[f] = s[u];
}
for (const u in e.attributes) {
const f = Cn[u] || u.toLowerCase();
if (s[u] !== void 0) {
const m = n.accessors[e.attributes[u]], p = pt[m.componentType];
h[f] = p.name, l[f] = m.normalized === !0;
}
}
return t.getDependency("bufferView", o).then(function(u) {
return new Promise(function(f, m) {
i.decodeDracoFile(u, function(p) {
for (const c in p.attributes) {
const d = p.attributes[c], g = l[c];
g !== void 0 && (d.normalized = g);
}
f(p);
}, a, h, Ie, m);
});
});
}
}
class Xa {
constructor() {
this.name = ae.KHR_TEXTURE_TRANSFORM;
}
extendTexture(e, t) {
return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e;
}
}
class Za {
constructor() {
this.name = ae.KHR_MESH_QUANTIZATION;
}
}
class as extends sr {
constructor(e, t, n, i) {
super(e, t, n, i);
}
copySampleValue_(e) {
const t = this.resultBuffer, n = this.sampleValues, i = this.valueSize, o = e * i * 3 + i;
for (let s = 0; s !== i; s++)
t[s] = n[o + s];
return t;
}
interpolate_(e, t, n, i) {
const o = this.resultBuffer, s = this.sampleValues, a = this.valueSize, l = a * 2, h = a * 3, u = i - t, f = (n - t) / u, m = f * f, p = m * f, c = e * h, d = c - h, g = -2 * p + 3 * m, _ = p - m, w = 1 - g, b = _ - m + f;
for (let T = 0; T !== a; T++) {
const M = s[d + T + a], C = s[d + T + l] * u, P = s[c + T + a], B = s[c + T] * u;
o[T] = w * M + b * C + g * P + _ * B;
}
return o;
}
}
const qa = new Yt();
class Ya extends as {
interpolate_(e, t, n, i) {
const o = super.interpolate_(e, t, n, i);
return qa.fromArray(o).normalize().toArray(o), o;
}
}
const ke = {
POINTS: 0,
LINES: 1,
LINE_LOOP: 2,
LINE_STRIP: 3,
TRIANGLES: 4,
TRIANGLE_STRIP: 5,
TRIANGLE_FAN: 6
}, pt = {
5120: Int8Array,
5121: Uint8Array,
5122: Int16Array,
5123: Uint16Array,
5125: Uint32Array,
5126: Float32Array
}, mi = {
9728: $t,
9729: Tn,
9984: Fs,
9985: Us,
9986: Bs,
9987: ki
}, gi = {
33071: Vs,
33648: js,
10497: it
}, yn = {
SCALAR: 1,
VEC2: 2,
VEC3: 3,
VEC4: 4,
MAT2: 4,
MAT3: 9,
MAT4: 16
}, Cn = {
POSITION: "position",
NORMAL: "normal",
TANGENT: "tangent",
TEXCOORD_0: "uv",
TEXCOORD_1: "uv1",
TEXCOORD_2: "uv2",
TEXCOORD_3: "uv3",
COLOR_0: "color",
WEIGHTS_0: "skinWeight",
JOINTS_0: "skinIndex"
}, Ke = {
scale: "scale",
translation: "position",
rotation: "quaternion",
weights: "morphTargetInfluences"
}, $a = {
CUBICSPLINE: void 0,
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
// keyframe track will be initialized with a default interpolation type, then modified.
LINEAR: Ri,
STEP: nr
}, wn = {
OPAQUE: "OPAQUE",
MASK: "MASK",
BLEND: "BLEND"
};
function Ja(r) {
return r.DefaultMaterial === void 0 && (r.DefaultMaterial = new Pi({
color: 16777215,
emissive: 0,
metalness: 1,
roughness: 1,
transparent: !1,
depthTest: !0,
side: ir
})), r.DefaultMaterial;
}
function Qe(r, e, t) {
for (const n in t.extensions)
r[n] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[n] = t.extensions[n]);
}
function ze(r, e) {
e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(r.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
}
function Qa(r, e, t) {
let n = !1, i = !1, o = !1;
for (let h = 0, u = e.length; h < u; h++) {
const f = e[h];
if (f.POSITION !== void 0 && (n = !0), f.NORMAL !== void 0 && (i = !0), f.COLOR_0 !== void 0 && (o = !0), n && i && o) break;
}
if (!n && !i && !o) return Promise.resolve(r);
const s = [], a = [], l = [];
for (let h = 0, u = e.length; h < u; h++) {
const f = e[h];
if (n) {
const m = f.POSITION !== void 0 ? t.getDependency("accessor", f.POSITION) : r.attributes.position;
s.push(m);
}
if (i) {
const m = f.NORMAL !== void 0 ? t.getDependency("accessor", f.NORMAL) : r.attributes.normal;
a.push(m);
}
if (o) {
const m = f.COLOR_0 !== void 0 ? t.getDependency("accessor", f.COLOR_0) : r.attributes.color;
l.push(m);
}
}
return Promise.all([
Promise.all(s),
Promise.all(a),
Promise.all(l)
]).then(function(h) {
const u = h[0], f = h[1], m = h[2];
return n && (r.morphAttributes.position = u), i && (r.morphAttributes.normal = f), o && (r.morphAttributes.color = m), r.morphTargetsRelative = !0, r;
});
}
function el(r, e) {
if (r.updateMorphTargets(), e.weights !== void 0)
for (let t = 0, n = e.weights.length; t < n; t++)
r.morphTargetInfluences[t] = e.weights[t];
if (e.extras && Array.isArray(e.extras.targetNames)) {
const t = e.extras.targetNames;
if (r.morphTargetInfluences.length === t.length) {
r.morphTargetDictionary = {};
for (let n = 0, i = t.length; n < i; n++)
r.morphTargetDictionary[t[n]] = n;
} else
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
}
}
function tl(r) {
let e;
const t = r.extensions && r.extensions[ae.KHR_DRACO_MESH_COMPRESSION];
if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + xn(t.attributes) : e = r.indices + ":" + xn(r.attributes) + ":" + r.mode, r.targets !== void 0)
for (let n = 0, i = r.targets.length; n < i; n++)
e += ":" + xn(r.targets[n]);
return e;
}
function xn(r) {
let e = "";
const t = Object.keys(r).sort();
for (let n = 0, i = t.length; n < i; n++)
e += t[n] + ":" + r[t[n]] + ";";
return e;
}
function kn(r) {
switch (r) {
case Int8Array:
return 1 / 127;
case Uint8Array:
return 1 / 255;
case Int16Array:
return 1 / 32767;
case Uint16Array:
return 1 / 65535;
default:
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
}
}
function nl(r) {
return r.search(/\.jpe?g($|\?)/i) > 0 || r.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : r.search(/\.webp($|\?)/i) > 0 || r.search(/^data\:image\/webp/) === 0 ? "image/webp" : r.search(/\.ktx2($|\?)/i) > 0 || r.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
}
const il = new Xe();
class sl {
constructor(e = {}, t = {}) {
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new Ma(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
let n = !1, i = -1, o = !1, s = -1;
if (typeof navigator < "u") {
const a = navigator.userAgent;
n = /^((?!chrome|android).)*safari/i.test(a) === !0;
const l = a.match(/Version\/(\d+)/);
i = n && l ? parseInt(l[1], 10) : -1, o = a.indexOf("Firefox") > -1, s = o ? a.match(/Firefox\/([0-9]+)\./)[1] : -1;
}
typeof createImageBitmap > "u" || n && i < 17 || o && s < 98 ? this.textureLoader = new zs(this.options.manager) : this.textureLoader = new Is(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Qt(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
}
setExtensions(e) {
this.extensions = e;
}
setPlugins(e) {
this.plugins = e;
}
parse(e, t) {
const n = this, i = this.json, o = this.extensions;
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(s) {
return s._markDefs && s._markDefs();
}), Promise.all(this._invokeAll(function(s) {
return s.beforeRoot && s.beforeRoot();
})).then(function() {
return Promise.all([
n.getDependencies("scene"),
n.getDependencies("animation"),
n.getDependencies("camera")
]);
}).then(function(s) {
const a = {
scene: s[0][i.scene || 0],
scenes: s[0],
animations: s[1],
cameras: s[2],
asset: i.asset,
parser: n,
userData: {}
};
return Qe(o, a, i), ze(a, i), Promise.all(n._invokeAll(function(l) {
return l.afterRoot && l.afterRoot(a);
})).then(function() {
for (const l of a.scenes)
l.updateMatrixWorld();
e(a);
});
}).catch(t);
}
/**
* Marks the special nodes/meshes in json for efficient parse.
*
* @private
*/
_markDefs() {
const e = this.json.nodes || [], t = this.json.skins || [], n = this.json.meshes || [];
for (let i = 0, o = t.length; i < o; i++) {
const s = t[i].joints;
for (let a = 0, l = s.length; a < l; a++)
e[s[a]].isBone = !0;
}
for (let i = 0, o = e.length; i < o; i++) {
const s = e[i];
s.mesh !== void 0 && (this._addNodeRef(this.meshCache, s.mesh), s.skin !== void 0 && (n[s.mesh].isSkinnedMesh = !0)), s.camera !== void 0 && this._addNodeRef(this.cameraCache, s.camera);
}
}
/**
* Counts references to shared node / Object3D resources. These resources
* can be reused, or "instantiated", at multiple nodes in the scene
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
* be marked. Non-scenegraph resources (like Materials, Geometries, and
* Textures) can be reused directly and are not marked here.
*
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
*
* @private
* @param {Object} cache
* @param {Object3D} index
*/
_addNodeRef(e, t) {
t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
}
/**
* Returns a reference to a shared resource, cloning it if necessary.
*
* @private
* @param {Object} cache
* @param {number} index
* @param {Object} object
* @return {Object}
*/
_getNodeRef(e, t, n) {
if (e.refs[t] <= 1) return n;
const i = n.clone(), o = (s, a) => {
const l = this.associations.get(s);
l != null && this.associations.set(a, l);
for (const [h, u] of s.children.entries())
o(u, a.children[h]);
};
return o(n, i), i.name += "_instance_" + e.uses[t]++, i;
}
_invokeOne(e) {
const t = Object.values(this.plugins);
t.push(this);
for (let n = 0; n < t.length; n++) {
const i = e(t[n]);
if (i) return i;
}
return null;
}
_invokeAll(e) {
const t = Object.values(this.plugins);
t.unshift(this);
const n = [];
for (let i = 0; i < t.length; i++) {
const o = e(t[i]);
o && n.push(o);
}
return n;
}
/**
* Requests the specified dependency asynchronously, with caching.
*
* @private
* @param {string} type
* @param {number} index
* @return {Promise<Object3D|Material|Texture|AnimationClip|ArrayBuffer|Object>}
*/
getDependency(e, t) {
const n = e + ":" + t;
let i = this.cache.get(n);
if (!i) {
switch (e) {
case "scene":
i = this.loadScene(t);
break;
case "node":
i = this._invokeOne(function(o) {
return o.loadNode && o.loadNode(t);
});
break;
case "mesh":
i = this._invokeOne(function(o) {
return o.loadMesh && o.loadMesh(t);
});
break;
case "accessor":
i = this.loadAccessor(t);
break;
case "bufferView":
i = this._invokeOne(function(o) {
return o.loadBufferView && o.loadBufferView(t);
});
break;
case "buffer":
i = this.loadBuffer(t);
break;
case "material":
i = this._invokeOne(function(o) {
return o.loadMaterial && o.loadMaterial(t);
});
break;
case "texture":
i = this._invokeOne(function(o) {
return o.loadTexture && o.loadTexture(t);
});
break;
case "skin":
i = this.loadSkin(t);
break;
case "animation":
i = this._invokeOne(function(o) {
return o.loadAnimation && o.loadAnimation(t);
});
break;
case "camera":
i = this.loadCamera(t);
break;
default:
if (i = this._invokeOne(function(o) {
return o != this && o.getDependency && o.getDependency(e, t);
}), !i)
throw new Error("Unknown type: " + e);
break;
}
this.cache.add(n, i);
}
return i;
}
/**
* Requests all dependencies of the specified type asynchronously, with caching.
*
* @private
* @param {string} type
* @return {Promise<Array<Object>>}
*/
getDependencies(e) {
let t = this.cache.get(e);
if (!t) {
const n = this, i = this.json[e + (e === "mesh" ? "es" : "s")] || [];
t = Promise.all(i.map(function(o, s) {
return n.getDependency(e, s);
})), this.cache.add(e, t);
}
return t;
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
*
* @private
* @param {number} bufferIndex
* @return {Promise<ArrayBuffer>}
*/
loadBuffer(e) {
const t = this.json.buffers[e], n = this.fileLoader;
if (t.type && t.type !== "arraybuffer")
throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
if (t.uri === void 0 && e === 0)
return Promise.resolve(this.extensions[ae.KHR_BINARY_GLTF].body);
const i = this.options;
return new Promise(function(o, s) {
n.load(Et.resolveURL(t.uri, i.path), o, void 0, function() {
s(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
});
});
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
*
* @private
* @param {number} bufferViewIndex
* @return {Promise<ArrayBuffer>}
*/
loadBufferView(e) {
const t = this.json.bufferViews[e];
return this.getDependency("buffer", t.buffer).then(function(n) {
const i = t.byteLength || 0, o = t.byteOffset || 0;
return n.slice(o, o + i);
});
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
*
* @private
* @param {number} accessorIndex
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
*/
loadAccessor(e) {
const t = this, n = this.json, i = this.json.accessors[e];
if (i.bufferView === void 0 && i.sparse === void 0) {
const s = yn[i.type], a = pt[i.componentType], l = i.normalized === !0, h = new a(i.count * s);
return Promise.resolve(new ft(h, s, l));
}
const o = [];
return i.bufferView !== void 0 ? o.push(this.getDependency("bufferView", i.bufferView)) : o.push(null), i.sparse !== void 0 && (o.push(this.getDependency("bufferView", i.sparse.indices.bufferView)), o.push(this.getDependency("bufferView", i.sparse.values.bufferView))), Promise.all(o).then(function(s) {
const a = s[0], l = yn[i.type], h = pt[i.componentType], u = h.BYTES_PER_ELEMENT, f = u * l, m = i.byteOffset || 0, p = i.bufferView !== void 0 ? n.bufferViews[i.bufferView].byteStride : void 0, c = i.normalized === !0;
let d, g;
if (p && p !== f) {
const _ = Math.floor(m / p), w = "InterleavedBuffer:" + i.bufferView + ":" + i.componentType + ":" + _ + ":" + i.count;
let b = t.cache.get(w);
b || (d = new h(a, _ * p, i.count * p / u), b = new Ei(d, p / u), t.cache.add(w, b)), g = new Mi(b, l, m % p / u, c);
} else
a === null ? d = new h(i.count * l) : d = new h(a, m, i.count * l), g = new ft(d, l, c);
if (i.sparse !== void 0) {
const _ = yn.SCALAR, w = pt[i.sparse.indices.componentType], b = i.sparse.indices.byteOffset || 0, T = i.sparse.values.byteOffset || 0, M = new w(s[1], b, i.sparse.count * _), C = new h(s[2], T, i.sparse.count * l);
a !== null && (g = new ft(g.array.slice(), g.itemSize, g.normalized)), g.normalized = !1;
for (let P = 0, B = M.length; P < B; P++) {
const R = M[P];
if (g.setX(R, C[P * l]), l >= 2 && g.setY(R, C[P * l + 1]), l >= 3 && g.setZ(R, C[P * l + 2]), l >= 4 && g.setW(R, C[P * l + 3]), l >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
}
g.normalized = c;
}
return g;
});
}
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
*
* @private
* @param {number} textureIndex
* @return {Promise<?Texture>}
*/
loadTexture(e) {
const t = this.json, n = this.options, o = t.textures[e].source, s = t.images[o];
let a = this.textureLoader;
if (s.uri) {
const l = n.manager.getHandler(s.uri);
l !== null && (a = l);
}
return this.loadTextureImage(e, o, a);
}
loadTextureImage(e, t, n) {
const i = this, o = this.json, s = o.textures[e], a = o.images[t], l = (a.uri || a.bufferView) + ":" + s.sampler;
if (this.textureCache[l])
return this.textureCache[l];
const h = this.loadImageSource(t, n).then(function(u) {
u.flipY = !1, u.name = s.name || a.name || "", u.name === "" && typeof a.uri == "string" && a.uri.startsWith("data:image/") === !1 && (u.name = a.uri);
const m = (o.samplers || {})[s.sampler] || {};
return u.magFilter = mi[m.magFilter] || Tn, u.minFilter = mi[m.minFilter] || ki, u.wrapS = gi[m.wrapS] || it, u.wrapT = gi[m.wrapT] || it, u.generateMipmaps = !u.isCompressedTexture && u.minFilter !== $t && u.minFilter !== Tn, i.associations.set(u, { textures: e }), u;
}).catch(function() {
return null;
});
return this.textureCache[l] = h, h;
}
loadImageSource(e, t) {
const n = this, i = this.json, o = this.options;
if (this.sourceCache[e] !== void 0)
return this.sourceCache[e].then((f) => f.clone());
const s = i.images[e], a = self.URL || self.webkitURL;
let l = s.uri || "", h = !1;
if (s.bufferView !== void 0)
l = n.getDependency("bufferView", s.bufferView).then(function(f) {
h = !0;
const m = new Blob([f], { type: s.mimeType });
return l = a.createObjectURL(m), l;
});
else if (s.uri === void 0)
throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
const u = Promise.resolve(l).then(function(f) {
return new Promise(function(m, p) {
let c = m;
t.isImageBitmapLoader === !0 && (c = function(d) {
const g = new jn(d);
g.needsUpdate = !0, m(g);
}), t.load(Et.resolveURL(f, o.path), c, void 0, p);
});
}).then(function(f) {
return h === !0 && a.revokeObjectURL(l), ze(f, s), f.userData.mimeType = s.mimeType || nl(s.uri), f;
}).catch(function(f) {
throw console.error("THREE.GLTFLoader: Couldn't load texture", l), f;
});
return this.sourceCache[e] = u, u;
}
/**
* Asynchronously assigns a texture to the given material parameters.
*
* @private
* @param {Object} materialParams
* @param {string} mapName
* @param {Object} mapDef
* @param {string} [colorSpace]
* @return {Promise<Texture>}
*/
assignTexture(e, t, n, i) {
const o = this;
return this.getDependency("texture", n.index).then(function(s) {
if (!s) return null;
if (n.texCoord !== void 0 && n.texCoord > 0 && (s = s.clone(), s.channel = n.texCoord), o.extensions[ae.KHR_TEXTURE_TRANSFORM]) {
const a = n.extensions !== void 0 ? n.extensions[ae.KHR_TEXTURE_TRANSFORM] : void 0;
if (a) {
const l = o.associations.get(s);
s = o.extensions[ae.KHR_TEXTURE_TRANSFORM].extendTexture(s, a), o.associations.set(s, l);
}
}
return i !== void 0 && (s.colorSpace = i), e[t] = s, s;
});
}
/**
* Assigns final material to a Mesh, Line, or Points instance. The instance
* already has a material (generated from the glTF material options alone)
* but reuse of the same glTF material may require multiple threejs materials
* to accommodate different primitive types, defines, etc. New materials will
* be created if necessary, and reused from a cache.
*
* @private
* @param {Object3D} mesh Mesh, Line, or Points instance.
*/
assignFinalMaterial(e) {
const t = e.geometry;
let n = e.material;
const i = t.attributes.tangent === void 0, o = t.attributes.color !== void 0, s = t.attributes.normal === void 0;
if (e.isPoints) {
const a = "PointsMaterial:" + n.uuid;
let l = this.cache.get(a);
l || (l = new Hs(), cn.prototype.copy.call(l, n), l.color.copy(n.color), l.map = n.map, l.sizeAttenuation = !1, this.cache.add(a, l)), n = l;
} else if (e.isLine) {
const a = "LineBasicMaterial:" + n.uuid;
let l = this.cache.get(a);
l || (l = new Gs(), cn.prototype.copy.call(l, n), l.color.copy(n.color), l.map = n.map, this.cache.add(a, l)), n = l;
}
if (i || o || s) {
let a = "ClonedMaterial:" + n.uuid + ":";
i && (a += "derivative-tangents:"), o && (a += "vertex-colors:"), s && (a += "flat-shading:");
let l = this.cache.get(a);
l || (l = n.clone(), o && (l.vertexColors = !0), s && (l.flatShading = !0), i && (l.normalScale && (l.normalScale.y *= -1), l.clearcoatNormalScale && (l.clearcoatNormalScale.y *= -1)), this.cache.add(a, l), this.associations.set(l, this.associations.get(n))), n = l;
}
e.material = n;
}
getMaterialType() {
return Pi;
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
*
* @private
* @param {number} materialIndex
* @return {Promise<Material>}
*/
loadMaterial(e) {
const t = this, n = this.json, i = this.extensions, o = n.materials[e];
let s;
const a = {}, l = o.extensions || {}, h = [];
if (l[ae.KHR_MATERIALS_UNLIT]) {
const f = i[ae.KHR_MATERIALS_UNLIT];
s = f.getMaterialType(), h.push(f.extendParams(a, o, t));
} else {
const f = o.pbrMetallicRoughness || {};
if (a.color = new Ce(1, 1, 1), a.opacity = 1, Array.isArray(f.baseColorFactor)) {
const m = f.baseColorFactor;
a.color.setRGB(m[0], m[1], m[2], Ie), a.opacity = m[3];
}
f.baseColorTexture !== void 0 && h.push(t.assignTexture(a, "map", f.baseColorTexture, Ze)), a.metalness = f.metallicFactor !== void 0 ? f.metallicFactor : 1, a.roughness = f.roughnessFactor !== void 0 ? f.roughnessFactor : 1, f.metallicRoughnessTexture !== void 0 && (h.push(t.assignTexture(a, "metalnessMap", f.metallicRoughnessTexture)), h.push(t.assignTexture(a, "roughnessMap", f.metallicRoughnessTexture))), s = this._invokeOne(function(m) {
return m.getMaterialType && m.getMaterialType(e);
}), h.push(Promise.all(this._invokeAll(function(m) {
return m.extendMaterialParams && m.extendMaterialParams(e, a);
})));
}
o.doubleSided === !0 && (a.side = Ws);
const u = o.alphaMode || wn.OPAQUE;
if (u === wn.BLEND ? (a.transparent = !0, a.depthWrite = !1) : (a.transparent = !1, u === wn.MASK && (a.alphaTest = o.alphaCutoff !== void 0 ? o.alphaCutoff : 0.5)), o.normalTexture !== void 0 && s !== ct && (h.push(t.assignTexture(a, "normalMap", o.normalTexture)), a.normalScale = new de(1, 1), o.normalTexture.scale !== void 0)) {
const f = o.normalTexture.scale;
a.normalScale.set(f, f);
}
if (o.occlusionTexture !== void 0 && s !== ct && (h.push(t.assignTexture(a, "aoMap", o.occlusionTexture)), o.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = o.occlusionTexture.strength)), o.emissiveFactor !== void 0 && s !== ct) {
const f = o.emissiveFactor;
a.emissive = new Ce().setRGB(f[0], f[1], f[2], Ie);
}
return o.emissiveTexture !== void 0 && s !== ct && h.push(t.assignTexture(a, "emissiveMap", o.emissiveTexture, Ze)), Promise.all(h).then(function() {
const f = new s(a);
return o.name && (f.name = o.name), ze(f, o), t.associations.set(f, { materials: e }), o.extensions && Qe(i, f, o), f;
});
}
/**
* When Object3D instances are targeted by animation, they need unique names.
*
* @private
* @param {string} originalName
* @return {string}
*/
createUniqueName(e) {
const t = Ks.sanitizeNodeName(e || "");
return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
*
* Creates BufferGeometries from primitives.
*
* @private
* @param {Array<GLTF.Primitive>} primitives
* @return {Promise<Array<BufferGeometry>>}
*/
loadGeometries(e) {
const t = this, n = this.extensions, i = this.primitiveCache;
function o(a) {
return n[ae.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a, t).then(function(l) {
return _i(l, a, t);
});
}
const s = [];
for (let a = 0, l = e.length; a < l; a++) {
const h = e[a], u = tl(h), f = i[u];
if (f)
s.push(f.promise);
else {
let m;
h.extensions && h.extensions[ae.KHR_DRACO_MESH_COMPRESSION] ? m = o(h) : m = _i(new tn(), h, t), i[u] = { primitive: h, promise: m }, s.push(m);
}
}
return Promise.all(s);
}
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
*
* @private
* @param {number} meshIndex
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
*/
loadMesh(e) {
const t = this, n = this.json, i = this.extensions, o = n.meshes[e], s = o.primitives, a = [];
for (let l = 0, h = s.length; l < h; l++) {
const u = s[l].material === void 0 ? Ja(this.cache) : this.getDependency("material", s[l].material);
a.push(u);
}
return a.push(t.loadGeometries(s)), Promise.all(a).then(function(l) {
const h = l.slice(0, l.length - 1), u = l[l.length - 1], f = [];
for (let p = 0, c = u.length; p < c; p++) {
const d = u[p], g = s[p];
let _;
const w = h[p];
if (g.mode === ke.TRIANGLES || g.mode === ke.TRIANGLE_STRIP || g.mode === ke.TRIANGLE_FAN || g.mode === void 0)
_ = o.isSkinnedMesh === !0 ? new Xs(d, w) : new bi(d, w), _.isSkinnedMesh === !0 && _.normalizeSkinWeights(), g.mode === ke.TRIANGLE_STRIP ? _.geometry = fi(_.geometry, Ai) : g.mode === ke.TRIANGLE_FAN && (_.geometry = fi(_.geometry, vn));
else if (g.mode === ke.LINES)
_ = new Zs(d, w);
else if (g.mode === ke.LINE_STRIP)
_ = new qs(d, w);
else if (g.mode === ke.LINE_LOOP)
_ = new Ys(d, w);
else if (g.mode === ke.POINTS)
_ = new $s(d, w);
else
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + g.mode);
Object.keys(_.geometry.morphAttributes).length > 0 && el(_, o), _.name = t.createUniqueName(o.name || "mesh_" + e), ze(_, o), g.extensions && Qe(i, _, g), t.assignFinalMaterial(_), f.push(_);
}
for (let p = 0, c = f.length; p < c; p++)
t.associations.set(f[p], {
meshes: e,
primitives: p
});
if (f.length === 1)
return o.extensions && Qe(i, f[0], o), f[0];
const m = new hn();
o.extensions && Qe(i, m, o), t.associations.set(m, { meshes: e });
for (let p = 0, c = f.length; p < c; p++)
m.add(f[p]);
return m;
});
}
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
*
* @private
* @param {number} cameraIndex
* @return {Promise<Camera>|undefined}
*/
loadCamera(e) {
let t;
const n = this.json.cameras[e], i = n[n.type];
if (!i) {
console.warn("THREE.GLTFLoader: Missing camera parameters.");
return;
}
return n.type === "perspective" ? t = new Js(xi.radToDeg(i.yfov), i.aspectRatio || 1, i.znear || 1, i.zfar || 2e6) : n.type === "orthographic" && (t = new vi(-i.xmag, i.xmag, i.ymag, -i.ymag, i.znear, i.zfar)), n.name && (t.name = this.createUniqueName(n.name)), ze(t, n), Promise.resolve(t);
}
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
*
* @private
* @param {number} skinIndex
* @return {Promise<Skeleton>}
*/
loadSkin(e) {
const t = this.json.skins[e], n = [];
for (let i = 0, o = t.joints.length; i < o; i++)
n.push(this._loadNodeShallow(t.joints[i]));
return t.inverseBindMatrices !== void 0 ? n.push(this.getDependency("accessor", t.inverseBindMatrices)) : n.push(null), Promise.all(n).then(function(i) {
const o = i.pop(), s = i, a = [], l = [];
for (let h = 0, u = s.length; h < u; h++) {
const f = s[h];
if (f) {
a.push(f);
const m = new Xe();
o !== null && m.fromArray(o.array, h * 16), l.push(m);
} else
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[h]);
}
return new Qs(a, l);
});
}
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
*
* @private
* @param {number} animationIndex
* @return {Promise<AnimationClip>}
*/
loadAnimation(e) {
const t = this.json, n = this, i = t.animations[e], o = i.name ? i.name : "animation_" + e, s = [], a = [], l = [], h = [], u = [];
for (let f = 0, m = i.channels.length; f < m; f++) {
const p = i.channels[f], c = i.samplers[p.sampler], d = p.target, g = d.node, _ = i.parameters !== void 0 ? i.parameters[c.input] : c.input, w = i.parameters !== void 0 ? i.parameters[c.output] : c.output;
d.node !== void 0 && (s.push(this.getDependency("node", g)), a.push(this.getDependency("accessor", _)), l.push(this.getDependency("accessor", w)), h.push(c), u.push(d));
}
return Promise.all([
Promise.all(s),
Promise.all(a),
Promise.all(l),
Promise.all(h),
Promise.all(u)
]).then(function(f) {
const m = f[0], p = f[1], c = f[2], d = f[3], g = f[4], _ = [];
for (let b = 0, T = m.length; b < T; b++) {
const M = m[b], C = p[b], P = c[b], B = d[b], R = g[b];
if (M === void 0) continue;
M.updateMatrix && M.updateMatrix();
const U = n._createAnimationTracks(M, C, P, B, R);
if (U)
for (let q = 0; q < U.length; q++)
_.push(U[q]);
}
const w = new er(o, void 0, _);
return ze(w, i), w;
});
}
createNodeMesh(e) {
const t = this.json, n = this, i = t.nodes[e];
return i.mesh === void 0 ? null : n.getDependency("mesh", i.mesh).then(function(o) {
const s = n._getNodeRef(n.meshCache, i.mesh, o);
return i.weights !== void 0 && s.traverse(function(a) {
if (a.isMesh)
for (let l = 0, h = i.weights.length; l < h; l++)
a.morphTargetInfluences[l] = i.weights[l];
}), s;
});
}
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
*
* @private
* @param {number} nodeIndex
* @return {Promise<Object3D>}
*/
loadNode(e) {
const t = this.json, n = this, i = t.nodes[e], o = n._loadNodeShallow(e), s = [], a = i.children || [];
for (let h = 0, u = a.length; h < u; h++)
s.push(n.getDependency("node", a[h]));
const l = i.skin === void 0 ? Promise.resolve(null) : n.getDependency("skin", i.skin);
return Promise.all([
o,
Promise.all(s),
l
]).then(function(h) {
const u = h[0], f = h[1], m = h[2];
m !== null && u.traverse(function(p) {
p.isSkinnedMesh && p.bind(m, il);
});
for (let p = 0, c = f.length; p < c; p++)
u.add(f[p]);
return u;
});
}
// ._loadNodeShallow() parses a single node.
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
_loadNodeShallow(e) {
const t = this.json, n = this.extensions, i = this;
if (this.nodeCache[e] !== void 0)
return this.nodeCache[e];
const o = t.nodes[e], s = o.name ? i.createUniqueName(o.name) : "", a = [], l = i._invokeOne(function(h) {
return h.createNodeMesh && h.createNodeMesh(e);
});
return l && a.push(l), o.camera !== void 0 && a.push(i.getDependency("camera", o.camera).then(function(h) {
return i._getNodeRef(i.cameraCache, o.camera, h);
})), i._invokeAll(function(h) {
return h.createNodeAttachment && h.createNodeAttachment(e);
}).forEach(function(h) {
a.push(h);
}), this.nodeCache[e] = Promise.all(a).then(function(h) {
let u;
if (o.isBone === !0 ? u = new tr() : h.length > 1 ? u = new hn() : h.length === 1 ? u = h[0] : u = new Ci(), u !== h[0])
for (let f = 0, m = h.length; f < m; f++)
u.add(h[f]);
if (o.name && (u.userData.name = o.name, u.name = s), ze(u, o), o.extensions && Qe(n, u, o), o.matrix !== void 0) {
const f = new Xe();
f.fromArray(o.matrix), u.applyMatrix4(f);
} else
o.translation !== void 0 && u.position.fromArray(o.translation), o.rotation !== void 0 && u.quaternion.fromArray(o.rotation), o.scale !== void 0 && u.scale.fromArray(o.scale);
if (!i.associations.has(u))
i.associations.set(u, {});
else if (o.mesh !== void 0 && i.meshCache.refs[o.mesh] > 1) {
const f = i.associations.get(u);
i.associations.set(u, { ...f });
}
return i.associations.get(u).nodes = e, u;
}), this.nodeCache[e];
}
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
*
* @private
* @param {number} sceneIndex
* @return {Promise<Group>}
*/
loadScene(e) {
const t = this.extensions, n = this.json.scenes[e], i = this, o = new hn();
n.name && (o.name = i.createUniqueName(n.name)), ze(o, n), n.extensions && Qe(t, o, n);
const s = n.nodes || [], a = [];
for (let l = 0, h = s.length; l < h; l++)
a.push(i.getDependency("node", s[l]));
return Promise.all(a).then(function(l) {
for (let u = 0, f = l.length; u < f; u++)
o.add(l[u]);
const h = (u) => {
const f = /* @__PURE__ */ new Map();
for (const [m, p] of i.associations)
(m instanceof cn || m instanceof jn) && f.set(m, p);
return u.traverse((m) => {
const p = i.associations.get(m);
p != null && f.set(m, p);
}), f;
};
return i.associations = h(o), o;
});
}
_createAnimationTracks(e, t, n, i, o) {
const s = [], a = e.name ? e.name : e.uuid, l = [];
Ke[o.path] === Ke.weights ? e.traverse(function(m) {
m.morphTargetInfluences && l.push(m.name ? m.name : m.uuid);
}) : l.push(a);
let h;
switch (Ke[o.path]) {
case Ke.weights:
h = Hn;
break;
case Ke.rotation:
h = Gn;
break;
case Ke.translation:
case Ke.scale:
h = Vn;
break;
default:
switch (n.itemSize) {
case 1:
h = Hn;
break;
case 2:
case 3:
default:
h = Vn;
break;
}
break;
}
const u = i.interpolation !== void 0 ? $a[i.interpolation] : Ri, f = this._getArrayFromAccessor(n);
for (let m = 0, p = l.length; m < p; m++) {
const c = new h(
l[m] + "." + Ke[o.path],
t.array,
f,
u
);
i.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(c), s.push(c);
}
return s;
}
_getArrayFromAccessor(e) {
let t = e.array;
if (e.normalized) {
const n = kn(t.constructor), i = new Float32Array(t.length);
for (let o = 0, s = t.length; o < s; o++)
i[o] = t[o] * n;
t = i;
}
return t;
}
_createCubicSplineTrackInterpolant(e) {
e.createInterpolant = function(n) {
const i = this instanceof Gn ? Ya : as;
return new i(this.times, this.values, this.getValueSize() / 3, n);
}, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
}
}
function rl(r, e, t) {
const n = e.attributes, i = new rr();
if (n.POSITION !== void 0) {
const a = t.json.accessors[n.POSITION], l = a.min, h = a.max;
if (l !== void 0 && h !== void 0) {
if (i.set(
new pe(l[0], l[1], l[2]),
new pe(h[0], h[1], h[2])
), a.normalized) {
const u = kn(pt[a.componentType]);
i.min.multiplyScalar(u), i.max.multiplyScalar(u);
}
} else {
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
return;
}
} else
return;
const o = e.targets;
if (o !== void 0) {
const a = new pe(), l = new pe();
for (let h = 0, u = o.length; h < u; h++) {
const f = o[h];
if (f.POSITION !== void 0) {
const m = t.json.accessors[f.POSITION], p = m.min, c = m.max;
if (p !== void 0 && c !== void 0) {
if (l.setX(Math.max(Math.abs(p[0]), Math.abs(c[0]))), l.setY(Math.max(Math.abs(p[1]), Math.abs(c[1]))), l.setZ(Math.max(Math.abs(p[2]), Math.abs(c[2]))), m.normalized) {
const d = kn(pt[m.componentType]);
l.multiplyScalar(d);
}
a.max(l);
} else
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
}
}
i.expandByVector(a);
}
r.boundingBox = i;
const s = new or();
i.getCenter(s.center), s.radius = i.min.distanceTo(i.max) / 2, r.boundingSphere = s;
}
function _i(r, e, t) {
const n = e.attributes, i = [];
function o(s, a) {
return t.getDependency("accessor", s).then(function(l) {
r.setAttribute(a, l);
});
}
for (const s in n) {
const a = Cn[s] || s.toLowerCase();
a in r.attributes || i.push(o(n[s], a));
}
if (e.indices !== void 0 && !r.index) {
const s = t.getDependency("accessor", e.indices).then(function(a) {
r.setIndex(a);
});
i.push(s);
}
return Jt.workingColorSpace !== Ie && "COLOR_0" in n && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Jt.workingColorSpace}" not supported.`), ze(r, e), rl(r, e, t), Promise.all(i).then(function() {
return e.targets !== void 0 ? Qa(r, e.targets, t) : r;
});
}
function ol(r, e, t) {
let n = new v.Group();
n.name = e, r.scene.add(n), rs(e + "/info.zip?v=" + Date.now(), (i) => {
let o = JSON.parse(i);
r.engineStatus.models.push({
type: "light",
info: o,
name: o.baseInfo.name,
status: "loading",
url: e,
elements: /* @__PURE__ */ new Map()
}), r.models == null && (r.models = []), r.models.push({
url: e,
nodesMap: /* @__PURE__ */ new Map(),
boundingBox: {
min: new v.Vector3(o.baseInfo.min.X * 0.3048, o.baseInfo.min.Z * 0.3048, -o.baseInfo.min.Y * 0.3048),
max: new v.Vector3(o.baseInfo.max.X * 0.3048, o.baseInfo.max.Z * 0.3048, -o.baseInfo.max.Y * 0.3048)
}
}), r.events.trigger(Mt.EngineFree, null);
});
}
function al(r) {
r.engineStatus.models.forEach((e) => {
e.loadStatus == null && (e.loadStatus = {
mep: !1,
instance: !1,
normal: !1
}), e.status === "loading" && e.type === "light" && (e.loadStatus.modelMep != !0 && (e.loadStatus.modelMep = !0, Ta(r, e.info.modelMep, e.url)), e.loadStatus.normal != !0 && ll(r, e));
});
}
function ll(r, e) {
if (r.camera.position, e.size, e.info == null || e.info.lods == null)
return;
e.info.lods.forEach((i) => {
if (i.status != !0)
if (i.glbs == null)
console.log("加载GLB............."), i.glbs = {}, xa(e.url + i.path + "/nodes.json?v=" + Date.now(), (o) => {
let s = JSON.parse(o), a = /* @__PURE__ */ new Map();
r.models.find((h) => h.url == e.url).nodesMap = a;
let l = 0;
for (let h in s) {
s[h].forEach((m) => {
m.glb = h, a.has(m.id) == !1 ? a.set(m.id, { infos: [m] }) : a.get(m.id).infos.push(m);
});
let u = new Ea();
const f = new ba();
f.setDecoderPath("/static/js/draco/"), f.preload(), u.setDRACOLoader(f), u.load(e.url + i.path + h + ".glb", (m) => {
i.glbs[h] = m.scene.children, l++, l == Object.keys(s).length && r.engineStatus.isFree && (r.events.trigger(Mt.EngineFree, null), r.viewCube.CameraGoHome());
});
}
});
else {
console.log("加载模型.............");
let o = n(e, i, i.octreeBox), s = [], a = r.models.find((l) => l.url == e.url);
o.forEach((l) => {
a.nodesMap.has(l) && a.nodesMap.get(l).infos.forEach((h) => {
let u = i.glbs[h.glb][h.mesh];
if (u != null && u.geometry != null && u.material != null) {
let f = new v.Matrix4();
f.elements = h.matrix;
let m = new v.Mesh(u.geometry.clone().applyMatrix4(f), u.material), p = new v.Box3().setFromObject(m);
h.box = p, h.mesh = m, m.name = l, m.glb = h.glb, m.url = e.url, s.push(m);
}
});
}), console.log("加载模型数量", s.length), cl(e.url, r, s);
}
});
function n(i, o, s) {
let a = [];
if (s.status != !0) {
if (!r.engineStatus.isFree)
return a;
let l = new v.Vector3(s.min.X, s.min.Z, -s.min.Y), h = new v.Vector3(s.max.X, s.max.Z, -s.max.Y);
h.distanceTo(l);
let u = r.camera.position, f = new v.Vector3(l.x + h.x / 2, l.y + h.y / 2, l.z + h.z / 2);
u.distanceTo(f), s.elements.forEach((m) => {
a.push(m);
}), s.children.forEach((m) => {
a.push(...n(i, o, m));
}), s.children.findIndex((m) => m.status != !0) == -1 && (s.status = !0), s.children.length == 0 && (s.status = !0);
}
return a;
}
}
function cl(r, e, t) {
let n = [];
t.forEach((i) => {
n.findIndex((s) => s.glb == i.glb) == -1 ? n.push({
glb: i.glb,
meshes: [i],
currentIndex: i.geometry.index.count,
indexes: /* @__PURE__ */ new Map()
}) : (n.find((s) => s.glb == i.glb).meshes.push(i), n.find((s) => s.glb == i.glb).currentIndex += i.geometry.index.count);
let o = n.find((s) => s.glb == i.glb);
o.indexes.set(Number(i.name), [o.currentIndex - i.geometry.index.count, o.currentIndex]);
}), n.forEach((i) => {
let o = e.scene.children.find((s) => s instanceof v.Mesh && s.url == r && s.glb == i.glb);
if (o != null)
o.castShadow = !0, o.receiveShadow = !0;
else {
let s = new v.BufferGeometry();
i.meshes.map((h) => h.material), s = Sa(i.meshes.map((h) => h.geometry), !0);
let a = new v.Mesh(s, i.meshes.map((h) => h.material));
a.castShadow = !0, a.receiveShadow = !0, e.scene.add(a), a.index = e.scene.children.length - 1, a.url = r, a.glb = i.glb, a.indexes = i.indexes, a.materialClone = i.meshes[0].material;
let l = e.models.find((h) => h.url == r);
if (l != null) {
let h = 0;
i.indexes.forEach((u) => {
l.nodesMap.get(Number(i.meshes[h].name)).indexes == null && (l.nodesMap.get(Number(i.meshes[h].name)).indexes = []), l.nodesMap.get(Number(i.meshes[h].name)).indexes.push([a.index, h++, u[0], u[1]]);
});
}
hl(a.material);
}
});
}
function hl(r) {
r.shadowSide = v.FrontSide, r.roughness = 0.6, r.metalness = 0, r.map != null && (r.map.colorSpace = v.SRGBColorSpace, r.map.needsUpdate = !0, console.log("优化贴图")), r instanceof v.MeshStandardMaterial && (r.map && (r.map.colorSpace = v.SRGBColorSpace, r.map.needsUpdate = !0), r.emissiveMap && (r.emissiveMap.colorSpace = v.SRGBColorSpace, r.emissiveMap.needsUpdate = !0), r.roughnessMap && (r.roughnessMap.colorSpace = v.LinearSRGBColorSpace, r.roughnessMap.needsUpdate = !0), r.metalnessMap && (r.metalnessMap.colorSpace = v.LinearSRGBColorSpace, r.metalnessMap.needsUpdate = !0), r.normalMap && (r.normalMap.colorSpace = v.LinearSRGBColorSpace, r.normalMap.needsUpdate = !0), r.aoMap && (r.aoMap.colorSpace = v.LinearSRGBColorSpace, r.aoMap.needsUpdate = !0), r.roughness = Math.max(0.1, Math.min(1, r.roughness)), r.metalness = Math.max(0, Math.min(1, r.metalness)), r.envMapIntensity = r.envMapIntensity || 1, r.needsUpdate = !0), r instanceof v.MeshPhysicalMaterial && (this.optimizeMaterial(r), r.transmissionMap && (r.transmissionMap.colorSpace = v.LinearSRGBColorSpace, r.transmissionMap.needsUpdate = !0), r.thicknessMap && (r.thicknessMap.colorSpace = v.LinearSRGBColorSpace, r.thicknessMap.needsUpdate = !0), r.transmission = Math.max(0, Math.min(1, r.transmission)), r.thickness = Math.max(0, Math.min(10, r.thickness))), r instanceof v.MeshBasicMaterial && r.map && (r.map.colorSpace = v.SRGBColorSpace, r.map.needsUpdate = !0), r instanceof v.MeshLambertMaterial && (r.map && (r.map.colorSpace = v.SRGBColorSpace, r.map.needsUpdate = !0), r.emissiveMap && (r.emissiveMap.colorSpace = v.SRGBColorSpace, r.emissiveMap.needsUpdate = !0));
}
class ul {
engine;
constructor(e) {
this.engine = e;
}
// 加载多个模型
async loadModels(e, t) {
for (const i of e)
n(i) === "light" && ol(this.engine, i);
function n(i) {
const o = i.split(".").pop();
return o === "glb" || o === "gltf" ? "gltf" : "light";
}
}
}
class dl {
engine;
isFree;
highlightModels;
hideModels;
models;
constructor(e) {
this.engine = e, this.isFree = !0, this.highlightModels = [], this.hideModels = [], this.models = [];
}
init() {
this.engine.events.on(Mt.EngineFree, () => {
this.updateFree(!0), console.log("引擎空闲"), al(this.engine);
}), this.engine.events.on(Mt.EngineBusy, () => {
this.updateFree(!1), console.log("引擎繁忙");
});
}
// 更新引擎空闲状态
updateFree(e) {
this.isFree = e;
}
// 关闭所有功能
closeAllFunction = () => {
};
}
class fl {
listeners = /* @__PURE__ */ new Map();
on(e, t) {
this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t);
}
off(e, t) {
if (!this.listeners.has(e)) return;
const n = this.listeners.get(e), i = n.indexOf(t);
i !== -1 && n.splice(i, 1);
}
trigger(e, t) {
this.listeners.has(e) && this.listeners.get(e).forEach((n) => {
try {
n(t);
} catch (i) {
console.error(`Error in event listener for ${e}:`, i);
}
});
}
}
class pl {
engine;
constructor(e) {
this.engine = e;
}
// 加入场景基本光照
init() {
const e = new v.DirectionalLight(16777215, 2);
e.position.set(10, 20, 10), e.castShadow = !0, e.shadow.mapSize.width = 4096, e.shadow.mapSize.height = 4096, e.shadow.camera.near = 0.1, e.shadow.camera.far = 500, e.shadow.bias = -5e-5, e.shadow.normalBias = 0.02;
const t = 50;
e.shadow.camera.left = -t, e.shadow.camera.right = t, e.shadow.camera.top = t, e.shadow.camera.bottom = -t, e.shadow.radius = 2, this.engine.scene.add(e);
const n = new v.AmbientLight(16777215, 1);
this.engine.scene.add(n);
}
}
var Be = /* @__PURE__ */ ((r) => (r.ModelLoadStart = "model-load-start", r.ModelLoadProgress = "model-load-progress", r.ModelLoaded = "model-loaded", r.ModelError = "model-error", r.SelectionChanged = "selection-changed", r.HoverChanged = "hover-changed", r.Click = "click", r.MouseMove = "mouse-move", r.CameraChanged = "camera-changed", r.CameraIdle = "camera-idle", r.EngineFree = "engine-free", r.EngineBusy = "engine-busy", r.MeasureChanged = "measure-changed", r))(Be || {});
class ml {
engine;
behavior;
isCtrlDown = !1;
constructor(e) {
this.engine = e;
}
init() {
this.behavior = this.engine.handelBehaved, this.behavior.init(this);
}
active() {
this.behavior.active();
}
disActive() {
this.behavior.disActive();
}
// 键盘事件
handelKeyCtrlUp() {
this.isCtrlDown = !1;
}
handelKeyCtrlDown() {
this.isCtrlDown = !0;
}
// 业务功能-监听鼠标谈起,点选模型
handleMouseClick(e) {
if (e.catch) {
const t = e.catch;
t.object, this.engine.events.trigger(Be.Click, t);
let n = t.object;
this.isCtrlDown || this.engine.modelToolModule.unhighlightAllModels(), console.log([{ url: n.url, ids: [n.name] }]), this.engine.modelToolModule.highlightModel([{ url: n.url, ids: [n.name] }]);
} else
this.engine.modelToolModule.unhighlightAllModels();
}
// 双击模型事件
handleMouseDoubleClick(e) {
if (e.catch) {
const n = e.catch;
n.object, this.engine.events.trigger(Be.Click, n);
let i = n.object, a = this.engine.models.find((h) => h.url === i.url).nodesMap.get(i.name).infos.map((h) => h.box), l = t(a);
this.engine.viewCube.zoomToModel(l);
}
function t(n) {
let i = new v.Vector3(1e8, 1e9, 1e10), o = new v.Vector3(-1e8, -1e9, -1e10);
return n.forEach((s) => {
s.min.x < i.x && (i.x = s.min.x), s.min.y < i.y && (i.y = s.min.y), s.min.z < i.z && (i.z = s.min.z), s.max.x > o.x && (o.x = s.max.x), s.max.y > o.y && (o.y = s.max.y), s.max.z > o.z && (o.z = s.max.z);
}), new v.Box3(i, o);
}
}
}
class gl {
engine;
highlightMaterial;
hideMaterial;
constructor(e) {
this.engine = e, this.highlightMaterial = new v.MeshBasicMaterial({
color: 43775,
// 明显的蓝色
depthTest: !1,
// 不进行深度测试,始终显示
depthWrite: !1,
// 不写入深度缓冲
transparent: !0,
opacity: 0.5,
// 半透明效果
side: v.DoubleSide
// 双面渲染
}), this.hideMaterial = new v.MeshBasicMaterial({
color: 0,
// 明显的蓝色
depthTest: !1,
// 不进行深度测试,始终显示
depthWrite: !1,
// 不写入深度缓冲
transparent: !0,
opacity: 0,
// 半透明效果
side: v.DoubleSide
// 双面渲染
});
}
// 设置模型高亮
highlightModel(e) {
e.forEach((t) => {
t.ids.forEach((n) => {
this.engine.models.find((o) => o.url == t.url).nodesMap.get(n).indexes.forEach((o) => {
yi(this.engine.scene.children[o[0]]), this.engine.scene.children[o[0]].material[o[1]] = this.highlightMaterial;
});
}), this.engine.engineStatus.highlightModels.push(t);
});
}
// 取消模型高亮
unhighlightModel(e) {
e.forEach((t) => {
t.ids.forEach((n) => {
this.engine.models.find((o) => o.url == t.url).nodesMap.get(n).indexes.forEach((o) => {
this.engine.scene.children[o[0]].material[o[1]] = this.engine.scene.children[o[0]].materialClone;
});
});
});
}
// 取消所有模型高亮
unhighlightAllModels() {
this.engine.engineStatus.highlightModels.forEach((e) => {
this.unhighlightModel([e]);
}), this.engine.engineStatus.highlightModels = [];
}
// 隐藏模型
hideModel(e) {
e.forEach((t) => {
t.ids.forEach((i) => {
this.engine.models.find((s) => s.url == t.url).nodesMap.get(i).indexes.forEach((s) => {
yi(this.engine.scene.children[s[0]]), this.engine.scene.children[s[0]].material[s[1]] = this.hideMaterial;
});
});
let n = this.engine.engineStatus.hideModels.find((i) => i.url == t.url);
n != null ? n.ids.push(...t.ids) : this.engine.engineStatus.hideModels.push({
url: t.url,
ids: t.ids
}), this.engine.engineStatus.highlightModels = [];
});
}
// 显示模型
showModel(e) {
e.forEach((t) => {
t.ids.forEach((n) => {
this.engine.models.find((o) => o.url == t.url).nodesMap.get(n).indexes.forEach((o) => {
this.engine.scene.children[o[0]].material[o[1]] = this.engine.scene.children[o[0]].materialClone;
});
}), this.engine.engineStatus.hideModels.push(t);
});
}
// 显示所有模型
showAllModels() {
this.engine.scene.children.forEach((e) => {
e.isMesh && this.showModel(e);
}), this.engine.engineStatus.hideModels = [];
}
// 设置模型颜色
setModelColor(e, t) {
e.material.color.set(t);
}
// 设置所有模型颜色
setAllModelsColor(e) {
this.engine.scene.children.forEach((t) => {
t.isMesh;
});
}
// 恢复所有模型颜色
restoreAllModelsColor() {
this.engine.scene.children.forEach((e) => {
e.isMesh;
});
}
// 获取当前选中模型的box包围盒
getModelsBox(e) {
new v.Box3();
let t = [];
return e.forEach((i) => {
let o = this.engine.models.find((s) => s.url == i.url);
i.ids.forEach((s) => {
o.nodesMap.get(s).infos.forEach((l) => {
t.push(l.box);
});
});
}), n(t);
function n(i) {
let o = new v.Vector3(1e8, 1e9, 1e10), s = new v.Vector3(-1e8, -1e9, -1e10);
return i.forEach((a) => {
a.min.x < o.x && (o.x = a.min.x), a.min.y < o.y && (o.y = a.min.y), a.min.z < o.z && (o.z = a.min.z), a.max.x > s.x && (s.x = a.max.x), a.max.y > s.y && (s.y = a.max.y), a.max.z > s.z && (s.z = a.max.z);
}), new v.Box3(o, s);
}
}
// 获取模型的精准位置描述,给大模型用的,主要是
getModelDescription(e) {
}
}
function yi(r) {
(r.isSplit == null || r.isSplit == null || r.isSplit == !1) && (r.isSplit = !0);
}
function _l(r) {
const e = {
self: null,
// 当前激活的行为对象
options: null,
// 行为配置选项
mouseDownTime: 0,
// 鼠标按下时的时间戳
lastClickTime: 0
// 上次点击时间
};
e.init = function(f, m) {
e.self != null && e.self.disActive != null && e.self.disActive(), e.self = f, e.options = m;
}, e.render = function() {
e.self && e.self.render != null && e.self.render();
}, e.active = function() {
r.container.addEventListener("mousedown", a), r.container.addEventListener("mouseup", h), r.container.addEventListener("mousemove", l), window.addEventListener("keydown", t), window.addEventListener("keyup", n);
}, e.disActive = function() {
r.container.removeEventListener("mousedown", a), r.container.removeEventListener("mouseup", h), r.container.removeEventListener("mousemove", l), window.removeEventListener("keydown", t), window.removeEventListener("keyup", n);
};
function t(f) {
(f.keyCode === 8 || f.keyCode === 46) && e.self && e.self.handelKeyDeleteDown != null && e.self.handelKeyDeleteDown(), f.keyCode === 27 && e.self && e.self.handelKeyEscDown != null && e.self.handelKeyEscDown(), f.keyCode === 13 && e.self && e.self.handelKeyEnterDown != null && e.self.handelKeyEnterDown(), f.keyCode === 32 && e.self && e.self.handelKeySpaceDown != null && e.self.handelKeySpaceDown(), f.key === "Control" && e.self && e.self.handelKeyCtrlDown != null && e.self.handelKeyCtrlDown(), f.key === "Shift" && e.self && e.self.handelKeyShiftDown != null && e.self.handelKeyShiftDown(), f.key === "Meta" && e.self && e.self.handelKeyMetaDown != null && e.self.handelKeyMetaDown();
}
function n(f) {
f.key === "Alt" && e.self && e.self.handelKeyAltUp != null && e.self.handelKeyAltUp(), f.key === "Tab" && e.self && e.self.handelKeyTabUp != null && e.self.handelKeyTabUp(), f.key === "Control" && e.self && e.self.handelKeyCtrlUp != null && e.self.handelKeyCtrlUp(), f.key === "Shift" && e.self && e.self.handelKeyShiftUp != null && e.self.handelKeyShiftUp(), f.key === "Meta" && e.self && e.self.handelKeyMetaUp != null && e.self.handelKeyMetaUp(), f.key === "Command" && e.self && e.self.handelKeyCommandUp != null && e.self.handelKeyCommandUp(), f.key === "Windows" && e.self && e.self.handelKeyWindowsUp != null && e.self.handelKeyWindowsUp();
}
function i(f) {
const m = new v.Vector2(), p = r.renderer.domElement.clientWidth, c = r.renderer.domElement.clientHeight;
return m.x = f.clientX / p * 2 - 1, m.y = -(f.clientY / c) * 2 + 1, m;
}
function o(f) {
const m = new v.Raycaster(), p = i(f);
return m.setFromCamera(p, r.camera), m;
}
function s(f, m = !1) {
const p = o(f);
if (f.raycaster = p, m) {
const c = u(p);
f.catch = c;
}
}
function a(f) {
f.button === 0 && (e.mouseDownTime = Date.now(), e.self && e.self.handleMouseDown != null && (s(f, !0), e.self.handleMouseDown(f)));
}
function l(f) {
e.self && e.self.handleMouseMove != null && (s(f, !0), e.self.handleMouseMove(f));
}
function h(f) {
if (f.button !== 0)
return;
const m = Date.now(), p = m - e.mouseDownTime;
if (e.self && e.self.handleMouseUp != null && (s(f, !1), e.self.handleMouseUp(f)), p < 100 && e.self && e.self.handleMouseClick != null) {
s(f, !0);
const c = m - e.lastClickTime;
console.log(c), c < 200 ? e.self.handleMouseDoubleClick(f) : e.self.handleMouseClick(f), e.lastClickTime = Date.now();
}
}
function u(f) {
const m = r.octreeBox.rayInterationModel(f);
if (m.length !== 0)
return m[0];
}
return e;
}
var qt = { exports: {} }, yl = qt.exports, wi;
function wl() {
return wi || (wi = 1, (function(r, e) {
(function(t, n) {
r.exports = n();
})(yl, function() {
var t = function() {
function n(p) {
return s.appendChild(p.dom), p;
}
function i(p) {
for (var c = 0; c < s.children.length; c++) s.children[c].style.display = c === p ? "block" : "none";
o = p;
}
var o = 0, s = document.createElement("div");
s.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000", s.addEventListener("click", function(p) {
p.preventDefault(), i(++o % s.children.length);
}, !1);
var a = (performance || Date).now(), l = a, h = 0, u = n(new t.Panel("FPS", "#0ff", "#002")), f = n(new t.Panel("MS", "#0f0", "#020"));
if (self.performance && self.performance.memory) var m = n(new t.Panel("MB", "#f08", "#201"));
return i(0), { REVISION: 16, dom: s, addPanel: n, showPanel: i, begin: function() {
a = (performance || Date).now();
}, end: function() {
h++;
var p = (performance || Date).now();
if (f.update(p - a, 200), p > l + 1e3 && (u.update(1e3 * h / (p - l), 100), l = p, h = 0, m)) {
var c = performance.memory;
m.update(c.usedJSHeapSize / 1048576, c.jsHeapSizeLimit / 1048576);
}
return p;
}, update: function() {
a = this.end();
}, domElement: s, setMode: i };
};
return t.Panel = function(n, i, o) {
var s = 1 / 0, a = 0, l = Math.round, h = l(window.devicePixelRatio || 1), u = 80 * h, f = 48 * h, m = 3 * h, p = 2 * h, c = 3 * h, d = 15 * h, g = 74 * h, _ = 30 * h, w = document.createElement("canvas");
w.width = u, w.height = f, w.style.cssText = "width:80px;height:48px";
var b = w.getContext("2d");
return b.font = "bold " + 9 * h + "px Helvetica,Arial,sans-serif", b.textBaseline = "top", b.fillStyle = o, b.fillRect(0, 0, u, f), b.fillStyle = i, b.fillText(n, m, p), b.fillRect(c, d, g, _), b.fillStyle = o, b.globalAlpha = 0.9, b.fillRect(c, d, g, _), { dom: w, update: function(T, M) {
s = Math.min(s, T), a = Math.max(a, T), b.fillStyle = o, b.globalAlpha = 1, b.fillRect(0, 0, u, d), b.fillStyle = i, b.fillText(l(T) + " " + n + " (" + l(s) + "-" + l(a) + ")", m, p), b.drawImage(w, c + h, d, g - h, _, c, d, g - h, _), b.fillRect(c + g - h, d, h, _), b.fillStyle = o, b.globalAlpha = 0.9, b.fillRect(c + g - h, d, h, l((1 - T / M) * _));
} };
}, t;
});
})(qt)), qt.exports;
}
var xl = wl();
const bl = /* @__PURE__ */ Oi(xl);
var mt = Object.freeze({
Linear: Object.freeze({
None: function(r) {
return r;
},
In: function(r) {
return r;
},
Out: function(r) {
return r;
},
InOut: function(r) {
return r;
}
}),
Quadratic: Object.freeze({
In: function(r) {
return r * r;
},
Out: function(r) {
return r * (2 - r);
},
InOut: function(r) {
return (r *= 2) < 1 ? 0.5 * r * r : -0.5 * (--r * (r - 2) - 1);
}
}),
Cubic: Object.freeze({
In: function(r) {
return r * r * r;
},
Out: function(r) {
return --r * r * r + 1;
},
InOut: function(r) {
return (r *= 2) < 1 ? 0.5 * r * r * r : 0.5 * ((r -= 2) * r * r + 2);
}
}),
Quartic: Object.freeze({
In: function(r) {
return r * r * r * r;
},
Out: function(r) {
return 1 - --r * r * r * r;
},
InOut: function(r) {
return (r *= 2) < 1 ? 0.5 * r * r * r * r : -0.5 * ((r -= 2) * r * r * r - 2);
}
}),
Quintic: Object.freeze({
In: function(r) {
return r * r * r * r * r;
},
Out: function(r) {
return --r * r * r * r * r + 1;
},
InOut: function(r) {
return (r *= 2) < 1 ? 0.5 * r * r * r * r * r : 0.5 * ((r -= 2) * r * r * r * r + 2);
}
}),
Sinusoidal: Object.freeze({
In: function(r) {
return 1 - Math.sin((1 - r) * Math.PI / 2);
},
Out: function(r) {
return Math.sin(r * Math.PI / 2);
},
InOut: function(r) {
return 0.5 * (1 - Math.sin(Math.PI * (0.5 - r)));
}
}),
Exponential: Object.freeze({
In: function(r) {
return r === 0 ? 0 : Math.pow(1024, r - 1);
},
Out: function(r) {
return r === 1 ? 1 : 1 - Math.pow(2, -10 * r);
},
InOut: function(r) {
return r === 0 ? 0 : r === 1 ? 1 : (r *= 2) < 1 ? 0.5 * Math.pow(1024, r - 1) : 0.5 * (-Math.pow(2, -10 * (r - 1)) + 2);
}
}),
Circular: Object.freeze({
In: function(r) {
return 1 - Math.sqrt(1 - r * r);
},
Out: function(r) {
return Math.sqrt(1 - --r * r);
},
InOut: function(r) {
return (r *= 2) < 1 ? -0.5 * (Math.sqrt(1 - r * r) - 1) : 0.5 * (Math.sqrt(1 - (r -= 2) * r) + 1);
}
}),
Elastic: Object.freeze({
In: function(r) {
return r === 0 ? 0 : r === 1 ? 1 : -Math.pow(2, 10 * (r - 1)) * Math.sin((r - 1.1) * 5 * Math.PI);
},
Out: function(r) {
return r === 0 ? 0 : r === 1 ? 1 : Math.pow(2, -10 * r) * Math.sin((r - 0.1) * 5 * Math.PI) + 1;
},
InOut: function(r) {
return r === 0 ? 0 : r === 1 ? 1 : (r *= 2, r < 1 ? -0.5 * Math.pow(2, 10 * (r - 1)) * Math.sin((r - 1.1) * 5 * Math.PI) : 0.5 * Math.pow(2, -10 * (r - 1)) * Math.sin((r - 1.1) * 5 * Math.PI) + 1);
}
}),
Back: Object.freeze({
In: function(r) {
var e = 1.70158;
return r === 1 ? 1 : r * r * ((e + 1) * r - e);
},
Out: function(r) {
var e = 1.70158;
return r === 0 ? 0 : --r * r * ((e + 1) * r + e) + 1;
},
InOut: function(r) {
var e = 2.5949095;
return (r *= 2) < 1 ? 0.5 * (r * r * ((e + 1) * r - e)) : 0.5 * ((r -= 2) * r * ((e + 1) * r + e) + 2);
}
}),
Bounce: Object.freeze({
In: function(r) {
return 1 - mt.Bounce.Out(1 - r);
},
Out: function(r) {
return r < 1 / 2.75 ? 7.5625 * r * r : r < 2 / 2.75 ? 7.5625 * (r -= 1.5 / 2.75) * r + 0.75 : r < 2.5 / 2.75 ? 7.5625 * (r -= 2.25 / 2.75) * r + 0.9375 : 7.5625 * (r -= 2.625 / 2.75) * r + 0.984375;
},
InOut: function(r) {
return r < 0.5 ? mt.Bounce.In(r * 2) * 0.5 : mt.Bounce.Out(r * 2 - 1) * 0.5 + 0.5;
}
}),
generatePow: function(r) {
return r === void 0 && (r = 4), r = r < Number.EPSILON ? Number.EPSILON : r, r = r > 1e4 ? 1e4 : r, {
In: function(e) {
return Math.pow(e, r);
},
Out: function(e) {
return 1 - Math.pow(1 - e, r);
},
InOut: function(e) {
return e < 0.5 ? Math.pow(e * 2, r) / 2 : (1 - Math.pow(2 - e * 2, r)) / 2 + 0.5;
}
};
}
}), St = function() {
return performance.now();
}, vl = (
/** @class */
(function() {
function r() {
this._tweens = {}, this._tweensAddedDuringUpdate = {};
}
return r.prototype.getAll = function() {
var e = this;
return Object.keys(this._tweens).map(function(t) {
return e._tweens[t];
});
}, r.prototype.removeAll = function() {
this._tweens = {};
}, r.prototype.add = function(e) {
this._tweens[e.getId()] = e, this._tweensAddedDuringUpdate[e.getId()] = e;
}, r.prototype.remove = function(e) {
delete this._tweens[e.getId()], delete this._tweensAddedDuringUpdate[e.getId()];
}, r.prototype.update = function(e, t) {
e === void 0 && (e = St()), t === void 0 && (t = !1);
var n = Object.keys(this._tweens);
if (n.length === 0)
return !1;
for (; n.length > 0; ) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < n.length; i++) {
var o = this._tweens[n[i]], s = !t;
o && o.update(e, s) === !1 && !t && delete this._tweens[n[i]];
}
n = Object.keys(this._tweensAddedDuringUpdate);
}
return !0;
}, r;
})()
), Pn = {
Linear: function(r, e) {
var t = r.length - 1, n = t * e, i = Math.floor(n), o = Pn.Utils.Linear;
return e < 0 ? o(r[0], r[1], n) : e > 1 ? o(r[t], r[t - 1], t - n) : o(r[i], r[i + 1 > t ? t : i + 1], n - i);
},
Utils: {
Linear: function(r, e, t) {
return (e - r) * t + r;
}
}
}, ls = (
/** @class */
(function() {
function r() {
}
return r.nextId = function() {
return r._nextId++;
}, r._nextId = 0, r;
})()
), Rn = new vl(), Tl = (
/** @class */
(function() {
function r(e, t) {
t === void 0 && (t = Rn), this._object = e, this._group = t, this._isPaused = !1, this._pauseStart = 0, this._valuesStart = {}, this._valuesEnd = {}, this._valuesStartRepeat = {}, this._duration = 1e3, this._isDynamic = !1, this._initialRepeat = 0, this._repeat = 0, this._yoyo = !1, this._isPlaying = !1, this._reversed = !1, this._delayTime = 0, this._startTime = 0, this._easingFunction = mt.Linear.None, this._interpolationFunction = Pn.Linear, this._chainedTweens = [], this._onStartCallbackFired = !1, this._onEveryStartCallbackFired = !1, this._id = ls.nextId(), this._isChainStopped = !1, this._propertiesAreSetUp = !1, this._goToEnd = !1;
}
return r.prototype.getId = function() {
return this._id;
}, r.prototype.isPlaying = function() {
return this._isPlaying;
}, r.prototype.isPaused = function() {
return this._isPaused;
}, r.prototype.getDuration = function() {
return this._duration;
}, r.prototype.to = function(e, t) {
if (t === void 0 && (t = 1e3), this._isPlaying)
throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");
return this._valuesEnd = e, this._propertiesAreSetUp = !1, this._duration = t < 0 ? 0 : t, this;
}, r.prototype.duration = function(e) {
return e === void 0 && (e = 1e3), this._duration = e < 0 ? 0 : e, this;
}, r.prototype.dynamic = function(e) {
return e === void 0 && (e = !1), this._isDynamic = e, this;
}, r.prototype.start = function(e, t) {
if (e === void 0 && (e = St()), t === void 0 && (t = !1), this._isPlaying)
return this;
if (this._group && this._group.add(this), this._repeat = this._initialRepeat, this._reversed) {
this._reversed = !1;
for (var n in this._valuesStartRepeat)
this._swapEndStartRepeatValues(n), this._valuesStart[n] = this._valuesStartRepeat[n];
}
if (this._isPlaying = !0, this._isPaused = !1, this._onStartCallbackFired = !1, this._onEveryStartCallbackFired = !1, this._isChainStopped = !1, this._startTime = e, this._startTime += this._delayTime, !this._propertiesAreSetUp || t) {
if (this._propertiesAreSetUp = !0, !this._isDynamic) {
var i = {};
for (var o in this._valuesEnd)
i[o] = this._valuesEnd[o];
this._valuesEnd = i;
}
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, t);
}
return this;
}, r.prototype.startFromCurrentValues = function(e) {
return this.start(e, !0);
}, r.prototype._setupProperties = function(e, t, n, i, o) {
for (var s in n) {
var a = e[s], l = Array.isArray(a), h = l ? "array" : typeof a, u = !l && Array.isArray(n[s]);
if (!(h === "undefined" || h === "function")) {
if (u) {
var f = n[s];
if (f.length === 0)
continue;
for (var m = [a], p = 0, c = f.length; p < c; p += 1) {
var d = this._handleRelativeValue(a, f[p]);
if (isNaN(d)) {
u = !1, console.warn("Found invalid interpolation list. Skipping.");
break;
}
m.push(d);
}
u && (n[s] = m);
}
if ((h === "object" || l) && a && !u) {
t[s] = l ? [] : {};
var g = a;
for (var _ in g)
t[s][_] = g[_];
i[s] = l ? [] : {};
var f = n[s];
if (!this._isDynamic) {
var w = {};
for (var _ in f)
w[_] = f[_];
n[s] = f = w;
}
this._setupProperties(g, t[s], f, i[s], o);
} else
(typeof t[s] > "u" || o) && (t[s] = a), l || (t[s] *= 1), u ? i[s] = n[s].slice().reverse() : i[s] = t[s] || 0;
}
}
}, r.prototype.stop = function() {
return this._isChainStopped || (this._isChainStopped = !0, this.stopChainedTweens()), this._isPlaying ? (this._group && this._group.remove(this), this._isPlaying = !1, this._isPaused = !1, this._onStopCallback && this._onStopCallback(this._object), this) : this;
}, r.prototype.end = function() {
return this._goToEnd = !0, this.update(1 / 0), this;
}, r.prototype.pause = function(e) {
return e === void 0 && (e = St()), this._isPaused || !this._isPlaying ? this : (this._isPaused = !0, this._pauseStart = e, this._group && this._group.remove(this), this);
}, r.prototype.resume = function(e) {
return e === void 0 && (e = St()), !this._isPaused || !this._isPlaying ? this : (this._isPaused = !1, this._startTime += e - this._pauseStart, this._pauseStart = 0, this._group && this._group.add(this), this);
}, r.prototype.stopChainedTweens = function() {
for (var e = 0, t = this._chainedTweens.length; e < t; e++)
this._chainedTweens[e].stop();
return this;
}, r.prototype.group = function(e) {
return e === void 0 && (e = Rn), this._group = e, this;
}, r.prototype.delay = function(e) {
return e === void 0 && (e = 0), this._delayTime = e, this;
}, r.prototype.repeat = function(e) {
return e === void 0 && (e = 0), this._initialRepeat = e, this._repeat = e, this;
}, r.prototype.repeatDelay = function(e) {
return this._repeatDelayTime = e, this;
}, r.prototype.yoyo = function(e) {
return e === void 0 && (e = !1), this._yoyo = e, this;
}, r.prototype.easing = function(e) {
return e === void 0 && (e = mt.Linear.None), this._easingFunction = e, this;
}, r.prototype.interpolation = function(e) {
return e === void 0 && (e = Pn.Linear), this._interpolationFunction = e, this;
}, r.prototype.chain = function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
return this._chainedTweens = e, this;
}, r.prototype.onStart = function(e) {
return this._onStartCallback = e, this;
}, r.prototype.onEveryStart = function(e) {
return this._onEveryStartCallback = e, this;
}, r.prototype.onUpdate = function(e) {
return this._onUpdateCallback = e, this;
}, r.prototype.onRepeat = function(e) {
return this._onRepeatCallback = e, this;
}, r.prototype.onComplete = function(e) {
return this._onCompleteCallback = e, this;
}, r.prototype.onStop = function(e) {
return this._onStopCallback = e, this;
}, r.prototype.update = function(e, t) {
var n = this, i;
if (e === void 0 && (e = St()), t === void 0 && (t = !0), this._isPaused)
return !0;
var o, s = this._startTime + this._duration;
if (!this._goToEnd && !this._isPlaying) {
if (e > s)
return !1;
t && this.start(e, !0);
}
if (this._goToEnd = !1, e < this._startTime)
return !0;
this._onStartCallbackFired === !1 && (this._onStartCallback && this._onStartCallback(this._object), this._onStartCallbackFired = !0), this._onEveryStartCallbackFired === !1 && (this._onEveryStartCallback && this._onEveryStartCallback(this._object), this._onEveryStartCallbackFired = !0);
var a = e - this._startTime, l = this._duration + ((i = this._repeatDelayTime) !== null && i !== void 0 ? i : this._delayTime), h = this._duration + this._repeat * l, u = function() {
if (n._duration === 0 || a > h)
return 1;
var g = Math.trunc(a / l), _ = a - g * l, w = Math.min(_ / n._duration, 1);
return w === 0 && a === n._duration ? 1 : w;
}, f = u(), m = this._easingFunction(f);
if (this._updateProperties(this._object, this._valuesStart, this._valuesEnd, m), this._onUpdateCallback && this._onUpdateCallback(this._object, f), this._duration === 0 || a >= this._duration)
if (this._repeat > 0) {
var p = Math.min(Math.trunc((a - this._duration) / l) + 1, this._repeat);
isFinite(this._repeat) && (this._repeat -= p);
for (o in this._valuesStartRepeat)
!this._yoyo && typeof this._valuesEnd[o] == "string" && (this._valuesStartRepeat[o] = // eslint-disable-next-line
// @ts-ignore FIXME?
this._valuesStartRepeat[o] + parseFloat(this._valuesEnd[o])), this._yoyo && this._swapEndStartRepeatValues(o), this._valuesStart[o] = this._valuesStartRepeat[o];
return this._yoyo && (this._reversed = !this._reversed), this._startTime += l * p, this._onRepeatCallback && this._onRepeatCallback(this._object), this._onEveryStartCallbackFired = !1, !0;
} else {
this._onCompleteCallback && this._onCompleteCallback(this._object);
for (var c = 0, d = this._chainedTweens.length; c < d; c++)
this._chainedTweens[c].start(this._startTime + this._duration, !1);
return this._isPlaying = !1, !1;
}
return !0;
}, r.prototype._updateProperties = function(e, t, n, i) {
for (var o in n)
if (t[o] !== void 0) {
var s = t[o] || 0, a = n[o], l = Array.isArray(e[o]), h = Array.isArray(a), u = !l && h;
u ? e[o] = this._interpolationFunction(a, i) : typeof a == "object" && a ? this._updateProperties(e[o], s, a, i) : (a = this._handleRelativeValue(s, a), typeof a == "number" && (e[o] = s + (a - s) * i));
}
}, r.prototype._handleRelativeValue = function(e, t) {
return typeof t != "string" ? t : t.charAt(0) === "+" || t.charAt(0) === "-" ? e + parseFloat(t) : parseFloat(t);
}, r.prototype._swapEndStartRepeatValues = function(e) {
var t = this._valuesStartRepeat[e], n = this._valuesEnd[e];
typeof n == "string" ? this._valuesStartRepeat[e] = this._valuesStartRepeat[e] + parseFloat(n) : this._valuesStartRepeat[e] = this._valuesEnd[e], this._valuesEnd[e] = t;
}, r;
})()
);
ls.nextId;
var Ue = Rn;
Ue.getAll.bind(Ue);
Ue.removeAll.bind(Ue);
Ue.add.bind(Ue);
Ue.remove.bind(Ue);
Ue.update.bind(Ue);
var bn = {
Easing: mt,
Tween: Tl
};
function Sl() {
return new v.Scene();
}
function El(r, e) {
r.appendChild(e.domElement);
}
function Ml(r, e, t) {
var n = new Object();
n.visible = !0;
let i = null, o, s, a = [];
n.init = function() {
o || (h(), u(), f());
}, n.Hide = function() {
o.style.display = "none", n.visible = !1;
}, n.Show = function() {
o.style.display = "block", n.visible = !0;
}, n.RenderScene = function() {
n.camera.quaternion.copy(e.camera.quaternion);
let d = new v.Vector3(0, 0, -1).clone().applyMatrix4(e.camera.matrixWorld.clone()), g = e.camera.position.clone().sub(d.clone()).setLength(100);
n.camera.position.copy(g), n.camera.lookAt(new v.Vector3()), n.sceneOrtho.renderer.render(n.sceneOrtho, n.camera);
}, n.ToggleDirectionView = function(c) {
console.log(c);
var d = new v.Vector3(0, 0, 0);
c == "top" ? d = new v.Vector3(0, 1, 0) : c == "down" ? d = new v.Vector3(0, -1, 0) : c == "front" ? d = new v.Vector3(0, 0, 1) : c == "left" ? d = new v.Vector3(-1, 0, 0) : c == "back" ? d = new v.Vector3(0, 0, -1) : c == "right" ? d = new v.Vector3(1, 0, 0) : c == "top_front" ? d = new v.Vector3(1, 1, 0) : c == "top_left" ? d = new v.Vector3(0, 1, -1) : c == "top_back" ? d = new v.Vector3(-1, 1, 0) : c == "top_right" ? d = new v.Vector3(0, 1, 1) : c == "down_front" ? d = new v.Vector3(1, -1, 0) : c == "down_left" ? d = new v.Vector3(0, -1, -1) : c == "down_back" ? d = new v.Vector3(-1, -1, 0) : c == "down_right" ? d = new v.Vector3(0, -1, 1) : c == "front_right" ? d = new v.Vector3(1, 0, 1) : c == "right_back" ? d = new v.Vector3(-1, 0, 1) : c == "back_left" ? d = new v.Vector3(-1, 0, -1) : c == "left_front" ? d = new v.Vector3(1, 0, -1) : c == "top_left_front" ? d = new v.Vector3(1, 1, -1) : c == "top_front_right" ? d = new v.Vector3(1, 1, 1) : c == "top_right_back" ? d = new v.Vector3(-1, 1, 1) : c == "top_back_left" ? d = new v.Vector3(-1, 1, -1) : c == "button_left_front" ? d = new v.Vector3(1, -1, -1) : c == "button_front_right" ? d = new v.Vector3(1, -1, 1) : c == "button_right_back" ? d = new v.Vector3(-1, 1, 1) : c == "button_back_left" && (d = new v.Vector3(-1, -1, -1));
var g = r.octreeBox.getBoundingBox(), _ = g.min, w = g.max, b = _.clone().add(w.clone()).multiplyScalar(0.5), T = b.clone().add(d.multiplyScalar(1 * w.distanceTo(_)));
l(e.camera.position, T, r.controls.target.clone(), b);
}, n.GetCameraPose = function() {
var c = e.camera.quaternion, d = e.camera.position, g = r.controls.target, _ = {
quaternion: c,
position: d,
target: g
};
return _;
}, n.ReductionCameraPose = function(c, d = 1e3, g) {
var _ = new v.Quaternion(
c.quaternion._x,
c.quaternion._y,
c.quaternion._z,
c.quaternion._w
), w = new v.Vector3(c.position.x, c.position.y, c.position.z), b = new v.Vector3(c.target.x, c.target.y, c.target.z);
let T = !1;
l(
e.camera.position,
w,
r.controls.target.clone(),
b,
e.camera.quaternion,
_,
d,
(M) => {
g && (T || (g(M), T = !0));
}
), g && setTimeout(() => {
T || (g(!0), T = !0);
}, d + 10);
}, n.CameraGoHome = function() {
var c = r.octreeBox.getBoundingBox();
console.log(c.min, c.max);
var d = c.min.clone().add(c.max.clone()).multiplyScalar(0.5);
let g = new v.Vector3(1, 1, 1);
var _ = d.clone().add(g.multiplyScalar(1 * c.max.distanceTo(c.min)));
l(e.camera.position, _, r.controls.target.clone(), d);
}, n.zoomToBox = function(c) {
var d = c.min.clone().add(c.max.clone()).multiplyScalar(0.5);
let _ = e.camera.position.clone().sub(r.controls.target.clone()).normalize();
var w = d.clone().add(_.multiplyScalar(1 * c.max.distanceTo(c.min)));
l(e.camera.position, w, r.controls.target.clone(), d);
};
function l(c, d, g, _, w, b, T = 1e3, M) {
var C;
w && b ? (C = new bn.Tween({
x1: c.x,
// 相机当前位置x
y1: c.y,
// 相机当前位置y
z1: c.z,
// 相机当前位置z
x2: g.x,
// 控制当前的中心点x
y2: g.y,
// 控制当前的中心点y
z2: g.z,
// 控制当前的中心点z
_x: w._x,
// 相机当前quaternion
_y: w._y,
// 相机当前quaternion
_z: w._z,
// 相机当前quaternion
_w: w._w
// 相机当前quaternion
}), C.to(
{
x1: d.x,
// 新的相机位置x
y1: d.y,
// 新的相机位置y
z1: d.z,
// 新的相机位置z
x2: _.x,
// 新的控制中心点位置x
y2: _.y,
// 新的控制中心点位置x
z2: _.z,
// 新的控制中心点位置x
_x: b._x,
// 新的相机quaternion
_y: b._y,
// 新的相机quaternion
_z: b._z,
// 新的相机quaternion
_w: b._w
// 新的相机quaternion
},
T
)) : (C = new bn.Tween({
x1: c.x,
// 相机当前位置x
y1: c.y,
// 相机当前位置y
z1: c.z,
// 相机当前位置z
x2: g.x,
// 控制当前的中心点x
y2: g.y,
// 控制当前的中心点y
z2: g.z
// 控制当前的中心点z
}), C.to(
{
x1: d.x,
// 新的相机位置x
y1: d.y,
// 新的相机位置y
z1: d.z,
// 新的相机位置z
x2: _.x,
// 新的控制中心点位置x
y2: _.y,
// 新的控制中心点位置x
z2: _.z
// 新的控制中心点位置x
},
T
)), C.onUpdate(function(B) {
w && b ? (e.camera.quaternion._x = B._x, e.camera.quaternion._y = B._y, e.camera.quaternion._z = B._z, e.camera.quaternion._w = B._w) : r.controls.auto = !0, e.camera.position.x = B.x1, e.camera.position.y = B.y1, e.camera.position.z = B.z1, r.controls.target.x = B.x2, r.controls.target.y = B.y2, r.controls.target.z = B.z2, r.controls.update(), n.RenderScene();
}), C.onComplete(function(B) {
r.controls.auto = !1, n.RenderScene(), M && M(!0), cancelAnimationFrame(i), i = null;
}), C.easing(bn.Easing.Cubic.InOut);
function P(B) {
i = requestAnimationFrame(P), C.update();
}
C.start(), P();
}
function h() {
o = document.createElement("div"), o.className = "ViewCube", t.appendChild(o), s = document.createElement("div"), s.className = "ViewAttr", t.appendChild(s);
var c = document.createElement("div");
c.className = "homeViewWrapper", c.addEventListener("mousedown", function() {
console.log("归位"), n.CameraGoHome();
}), o.appendChild(c);
}
function u() {
n.sceneOrtho = Sl();
var g = t.clientWidth, _ = t.clientWidth, c = g > _ ? g / _ : _ / g, d = 300;
n.camera = new v.OrthographicCamera(
d * c / -2,
d * c / 2,
d / 2,
d / -2,
0.01,
1e4
);
var g = o.clientWidth, _ = o.clientHeight, w = new v.WebGLRenderer({
alpha: !0
});
w.setSize(g, _), w.setClearAlpha(0), n.sceneOrtho.renderer = w;
let b = new v.AmbientLight(16777215, 0.8);
n.sceneOrtho.add(b), El(o, w);
}
function f() {
const c = "/assets/viewcube/";
let d = [
{
label: "右",
icon: c + "cn_right.png"
},
{
label: "左",
icon: c + "cn_left.png"
},
{
label: "顶",
icon: c + "cn_top.png"
},
{
label: "底",
icon: c + "cn_bottom.png"
},
{
label: "前",
icon: c + "cn_front.png"
},
{
label: "后",
icon: c + "cn_back.png"
}
];
var g = [];
for (const w of d)
g.push(
new v.MeshBasicMaterial({
color: 16777215,
map: new v.TextureLoader().load(w.icon)
})
);
new v.MeshLambertMaterial({
color: 255
});
var _ = new v.Mesh(new v.BoxGeometry(110, 110, 110), g);
n.sceneOrtho.add(_), m(122), o.addEventListener("mousedown", (w) => {
var b = {};
b.x = w.offsetX / o.clientWidth * 2 - 1, b.y = -(w.offsetY / o.clientHeight) * 2 + 1;
var T = new v.Raycaster();
T.setFromCamera(b, n.camera);
const M = T.intersectObjects(a, !1);
M.length > 0 && n.ToggleDirectionView(M[0].object.name);
}), o.addEventListener("mousemove", (w) => {
var b = {};
b.x = w.offsetX / o.clientWidth * 2 - 1, b.y = -(w.offsetY / o.clientHeight) * 2 + 1;
var T = new v.Raycaster();
T.setFromCamera(b, n.camera);
const M = T.intersectObjects(a, !1);
for (var C of a)
C.material.opacity = 0.01;
M.length > 0 && (M[0].object.material.opacity = 0.2);
});
}
function m(c) {
for (var d = c * 0.5 - 20, g = [
{
name: "right",
a: 30,
b: 75,
c: 75,
point: new v.Vector3(d, 0, 0)
},
{
name: "back",
a: 75,
b: 75,
c: 30,
point: new v.Vector3(0, 0, -d)
},
{
name: "left",
a: 30,
b: 75,
c: 75,
point: new v.Vector3(-d, 0, 0)
},
{
name: "front",
a: 75,
b: 75,
c: 30,
point: new v.Vector3(0, 0, d)
},
{
name: "top",
a: 75,
b: 30,
c: 75,
point: new v.Vector3(0, d, 0)
},
{
name: "button",
a: 75,
b: 30,
c: 75,
point: new v.Vector3(0, -d, 0)
}
], _ = [
{
name: "top_right_back",
a: 30,
b: 30,
c: 30,
point: new v.Vector3(-d, d, d)
},
{
name: "button_front_right",
a: 30,
b: 30,
c: 30,
point: new v.Vector3(-d, -d, d)
},
{
name: "top_front_right",
a: 30,
b: 30,
c: 30,
point: new v.Vector3(d, d, d)
},
{
name: "button_right_back",
a: 30,
b: 30,
c: 30,
point: new v.Vector3(d, -d, d)
},
{
name: "top_back_left",
a: 30,
b: 30,
c: 30,
point: new v.Vector3(-d, d, -d)
},
{
name: "button_back_left",
a: 30,
b: 30,
c: 30,
point: new v.Vector3(-d, -d, -d)
},
{
name: "top_left_front",
a: 30,
b: 30,
c: 30,
point: new v.Vector3(d, d, -d)
},
{
name: "button_left_front",
a: 30,
b: 30,
c: 30,
point: new v.Vector3(d, -d, -d)
}
], w = [
{
name: "top_front",
a: 30,
b: 30,
c: 75,
point: new v.Vector3(d, d, 0)
},
{
name: "top_right",
a: 75,
b: 30,
c: 30,
point: new v.Vector3(0, d, d)
},
{
name: "top_back",
a: 30,
b: 30,
c: 75,
point: new v.Vector3(-d, d, 0)
},
{
name: "top_left",
a: 75,
b: 30,
c: 30,
point: new v.Vector3(0, d, -d)
},
{
name: "button_front",
a: 30,
b: 30,
c: 75,
point: new v.Vector3(d, -d, 0)
},
{
name: "button_right",
a: 75,
b: 30,
c: 30,
point: new v.Vector3(0, -d, d)
},
{
name: "button_back",
a: 30,
b: 30,
c: 75,
point: new v.Vector3(-d, -d, 0)
},
{
name: "button_left",
a: 75,
b: 30,
c: 30,
point: new v.Vector3(0, -d, -d)
},
{
name: "front_right",
a: 30,
b: 75,
c: 30,
point: new v.Vector3(d, 0, d)
},
{
name: "right_back",
a: 30,
b: 75,
c: 30,
point: new v.Vector3(-d, 0, d)
},
{
name: "back_left",
a: 30,
b: 75,
c: 30,
point: new v.Vector3(-d, 0, -d)
},
{
name: "left_front",
a: 30,
b: 75,
c: 30,
point: new v.Vector3(d, 0, -d)
}
], b = 0; b < g.length; b++)
a.push(p(g[b]));
for (var b = 0; b < _.length; b++)
a.push(p(_[b]));
for (var b = 0; b < w.length; b++)
a.push(p(w[b]));
}
function p(c) {
const d = new v.BoxGeometry(c.a, c.b, c.c), g = new v.MeshBasicMaterial({
color: "blue",
transparent: !0,
opacity: 0.01
}), _ = new v.Matrix4().makeTranslation(c.point.x, c.point.y, c.point.z);
let w = d.applyMatrix4(_), b = new v.Mesh(w, g);
return b.name = c.name, n.sceneOrtho.add(b), b;
}
return n;
}
class Al {
engine;
cubeTool;
constructor(e) {
this.engine = e;
}
init() {
this.cubeTool = Ml(this.engine, this.engine.scene, this.engine.container), this.cubeTool.init();
}
// 相机回归正位
CameraGoHome() {
this.cubeTool.CameraGoHome();
}
// 缩放到指定模型
zoomToModel(e) {
this.cubeTool.zoomToBox(e);
}
}
function Cl(r) {
let e = new Object();
return e.getBoundingBox = function() {
let t = r.models, n = new v.Vector3(1e8, 1e9, 1e10), i = new v.Vector3(-1e8, -1e9, -1e10);
t.forEach((f) => {
let m = f.boundingBox.min, p = f.boundingBox.max;
m.x < n.x && (n.x = m.x), m.y < n.y && (n.y = m.y), m.z < n.z && (n.z = m.z), p.x > i.x && (i.x = p.x), p.y > i.y && (i.y = p.y), p.z > i.z && (i.z = p.z);
});
let o = Math.min(n.x, i.x), s = Math.min(n.y, i.y), a = Math.min(n.z, i.z), l = Math.max(n.x, i.x), h = Math.max(n.y, i.y), u = Math.max(n.z, i.z);
return {
min: new v.Vector3(o, s, a),
max: new v.Vector3(l, h, u)
};
}, e.rayInterationModel = function(t) {
let n = [];
return r.engineStatus.models.forEach((s) => {
s.info.lods.forEach((a) => {
let l = a.octreeBox;
o(t, l, s);
});
}), t.intersectObjects(n, !1);
function o(s, a, l) {
if (a == null)
return;
let h = new v.Vector3(a.min.X * 0.3048, a.min.Z * 0.3048, -a.min.Y * 0.3048), u = new v.Vector3(a.max.X * 0.3048, a.max.Z * 0.3048, -a.max.Y * 0.3048), f = new v.Vector3(Math.min(h.x, u.X), Math.min(h.y, u.y), Math.min(h.z, u.z)), m = new v.Vector3(Math.max(u.x, h.x), Math.max(u.y, h.y), Math.max(u.z, h.z)), p = new v.Box3(f, m), c = s.ray.intersectsBox(p);
if (!(c == null || c == !1))
if (a.children == null || a.children.length == 0) {
if (a.elements != null)
for (var d of a.elements) {
let g = r.engineStatus.hideModels.find((b) => b.url == l.url)?.ids;
if (g != null && g.includes(d))
continue;
let w = r.models.find((b) => b.url == l.url).nodesMap.get(d);
w?.infos.map((T) => T.mesh).forEach((T) => {
n.push(T);
});
}
} else {
if (a.elements != null)
for (var d of a.elements) {
let _ = r.engineStatus.hideModels.find((T) => T.url == l.url)?.ids;
if (_ != null && _.includes(d))
continue;
let b = r.models.find((T) => T.url == l.url).nodesMap.get(d);
b?.infos.map((M) => M.mesh).forEach((M) => {
n.push(M);
});
}
for (let g of a.children)
o(s, g, l);
}
}
}, e;
}
class Ae {
/**
* 构造函数
* @param camera - Three.js 相机对象(用于投影计算)
* @param renderer - Three.js 渲染器对象(用于获取画布尺寸)
* @param scene - Three.js 场景对象(用于屏幕坐标转世界坐标时的射线检测,可选)
*/
constructor(e, t, n) {
this.camera = e, this.renderer = t, this.scene = n, this.raycaster = new v.Raycaster();
}
raycaster;
/**
* 将世界坐标转换为屏幕坐标(归一化坐标,范围 -1 到 1
* @param worldPos - 世界空间中的3D坐标点
* @returns 归一化的屏幕坐标x 和 y 的范围都是 -1 到 1
* x: -1 表示屏幕左边缘1 表示屏幕右边缘
* y: -1 表示屏幕下边缘1 表示屏幕上边缘
*/
worldToScreenNormalized(e) {
const t = e.clone();
return t.project(this.camera), new v.Vector2(t.x, t.y);
}
/**
* 将世界坐标转换为屏幕坐标(像素坐标)
* @param worldPos - 世界空间中的3D坐标点
* @returns 屏幕像素坐标x 和 y 表示在画布上的实际像素位置
* x: 0 表示屏幕左边缘width 表示屏幕右边缘
* y: 0 表示屏幕上边缘height 表示屏幕下边缘
*/
worldToScreen(e) {
const t = this.worldToScreenNormalized(e), n = this.renderer.domElement.width, i = this.renderer.domElement.height, o = (t.x + 1) * n / 2, s = (1 - t.y) * i / 2;
return new v.Vector2(o, s);
}
/**
* 将屏幕坐标(像素坐标)转换为归一化坐标
* @param screenX - 屏幕像素 X 坐标
* @param screenY - 屏幕像素 Y 坐标
* @returns 归一化的屏幕坐标,范围 -1 到 1
*/
screenToNormalized(e, t) {
const n = this.renderer.domElement.width, i = this.renderer.domElement.height, o = e / n * 2 - 1, s = -(t / i * 2 - 1);
return new v.Vector2(o, s);
}
/**
* 将屏幕坐标(像素坐标)转换为世界坐标
* 使用射线检测,返回与场景中第一个相交对象的世界坐标点
* @param screenX - 屏幕像素 X 坐标
* @param screenY - 屏幕像素 Y 坐标
* @param objects - 可选,指定要检测的对象数组。如果不提供且 scene 存在,则检测场景中的所有对象
* @returns 世界坐标点,如果没有相交则返回 null
*/
screenToWorld(e, t, n) {
if (!this.scene && !n)
return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"), null;
const i = this.screenToNormalized(e, t);
this.raycaster.setFromCamera(i, this.camera);
const o = n || this.scene.children, s = this.raycaster.intersectObjects(o, !0);
return s.length > 0 ? s[0].point : null;
}
/**
* 将屏幕坐标(像素坐标)转换为世界坐标(指定深度)
* 使用相机的逆投影,在指定的深度平面上计算世界坐标
* @param screenX - 屏幕像素 X 坐标
* @param screenY - 屏幕像素 Y 坐标
* @param depth - 深度值(距离相机的距离),默认为 0相机近平面
* @returns 世界坐标点
*/
screenToWorldWithDepth(e, t, n = 0) {
const i = this.screenToNormalized(e, t), o = new v.Vector3(i.x, i.y, n);
return o.unproject(this.camera), o;
}
/**
* 更新相机引用(当相机发生变化时调用)
* @param camera - 新的相机对象
*/
updateCamera(e) {
this.camera = e;
}
/**
* 更新渲染器引用(当渲染器发生变化时调用)
* @param renderer - 新的渲染器对象
*/
updateRenderer(e) {
this.renderer = e;
}
/**
* 更新场景引用(当场景发生变化时调用)
* @param scene - 新的场景对象
*/
updateScene(e) {
this.scene = e;
}
}
class kl {
engine;
// 绘制状态
isDrawing = !1;
startPoint = new v.Vector2();
endPoint = new v.Vector2();
// UI绘制框元素
selectionBox = null;
// 坐标转换工具
worldToScreen = null;
// 事件处理函数绑定(用于后续移除监听器)
boundMouseDown;
boundMouseMove;
boundMouseUp;
boundKeyDown;
constructor(e) {
this.engine = e, this.boundMouseDown = this.onMouseDown.bind(this), this.boundMouseMove = this.onMouseMove.bind(this), this.boundMouseUp = this.onMouseUp.bind(this), this.boundKeyDown = this.onKeyDown.bind(this);
}
/**
* 初始化工具
* 创建绘制框UI元素初始化坐标转换工具
*/
init() {
this.createSelectionBoxElement(), this.engine.scene && this.engine.camera && this.engine.renderer && (this.worldToScreen = new Ae(
this.engine.camera,
this.engine.renderer,
this.engine.scene
));
}
/**
* 激活工具
* 禁用控制器,添加鼠标事件监听器和键盘事件监听器
*/
active() {
this.engine.controlModule.disActive();
const e = this.engine.renderer?.domElement;
e && (e.addEventListener("mousedown", this.boundMouseDown), e.addEventListener("mousemove", this.boundMouseMove), e.addEventListener("mouseup", this.boundMouseUp), e.style.cursor = "crosshair"), window.addEventListener("keydown", this.boundKeyDown);
}
/**
* 停用工具
* 启用控制器,移除鼠标事件监听器和键盘事件监听器
*/
disActive() {
this.engine.controlModule.active();
const e = this.engine.renderer?.domElement;
e && (e.removeEventListener("mousedown", this.boundMouseDown), e.removeEventListener("mousemove", this.boundMouseMove), e.removeEventListener("mouseup", this.boundMouseUp), e.style.cursor = "default"), window.removeEventListener("keydown", this.boundKeyDown), this.isDrawing && this.endDrawing();
}
/**
* 创建绘制框UI元素
* 用于在屏幕上显示用户绘制的区域
*/
createSelectionBoxElement() {
this.selectionBox = document.createElement("div"), this.selectionBox.style.position = "absolute", this.selectionBox.style.border = "2px dashed #00aaff", this.selectionBox.style.backgroundColor = "rgba(0, 170, 255, 0.1)", this.selectionBox.style.pointerEvents = "none", this.selectionBox.style.display = "none", this.selectionBox.style.zIndex = "1000", this.selectionBox.style.boxSizing = "border-box";
const e = this.engine.renderer?.domElement;
e && e.parentElement && e.parentElement.appendChild(this.selectionBox);
}
/**
* 鼠标按下事件处理
* 开始绘制区域
*/
onMouseDown(e) {
if (e.button !== 0) return;
const t = this.engine.renderer?.domElement;
if (!t) return;
const n = t.getBoundingClientRect();
this.startPoint.set(e.clientX - n.left, e.clientY - n.top), this.endPoint.copy(this.startPoint), this.isDrawing = !0, this.selectionBox && (this.selectionBox.style.display = "block", this.updateSelectionBoxUI()), e.preventDefault(), e.stopPropagation();
}
/**
* 鼠标移动事件处理
* 更新绘制框的显示
*/
onMouseMove(e) {
if (!this.isDrawing) return;
const t = this.engine.renderer?.domElement;
if (!t) return;
const n = t.getBoundingClientRect();
this.endPoint.set(e.clientX - n.left, e.clientY - n.top), this.updateSelectionBoxUI(), e.preventDefault(), e.stopPropagation();
}
/**
* 鼠标释放事件处理
* 结束绘制,执行缩放操作
*/
onMouseUp(e) {
this.isDrawing && (this.endDrawing(), this.performZoom(), e.preventDefault(), e.stopPropagation(), this.disActive());
}
/**
* 键盘按下事件处理
* 按下 ESC 键时退出功能
*/
onKeyDown(e) {
e.key === "Escape" && (this.disActive(), e.preventDefault(), e.stopPropagation());
}
/**
* 结束绘制
* 隐藏绘制框
*/
endDrawing() {
this.isDrawing && (this.isDrawing = !1, this.selectionBox && (this.selectionBox.style.display = "none"));
}
/**
* 更新绘制框UI
* 根据起点和终点更新绘制框的位置和大小
*/
updateSelectionBoxUI() {
if (!this.selectionBox) return;
const e = Math.min(this.startPoint.x, this.endPoint.x), t = Math.min(this.startPoint.y, this.endPoint.y), n = Math.abs(this.endPoint.x - this.startPoint.x), i = Math.abs(this.endPoint.y - this.startPoint.y);
this.selectionBox.style.left = `${e}px`, this.selectionBox.style.top = `${t}px`, this.selectionBox.style.width = `${n}px`, this.selectionBox.style.height = `${i}px`;
}
/**
* 执行缩放操作
* 将屏幕区域转换为世界坐标,计算包围盒,调整相机视角
*/
performZoom() {
const e = Math.abs(this.endPoint.x - this.startPoint.x), t = Math.abs(this.endPoint.y - this.startPoint.y);
if (e < 5 || t < 5)
return;
if (!this.worldToScreen) {
console.warn("RangeScale: 坐标转换工具未初始化");
return;
}
const n = Math.min(this.startPoint.x, this.endPoint.x), i = Math.max(this.startPoint.x, this.endPoint.x), o = Math.min(this.startPoint.y, this.endPoint.y), s = Math.max(this.startPoint.y, this.endPoint.y), a = [], l = [
{ x: n, y: o },
// 左上
{ x: i, y: o },
// 右上
{ x: i, y: s },
// 右下
{ x: n, y: s }
// 左下
];
for (const u of l) {
const f = this.worldToScreen.screenToWorld(u.x, u.y);
f && a.push(f);
}
if (a.length < 3) {
const u = this.engine.camera, f = this.engine.scene, m = new v.Box3();
if (f.traverse((p) => {
if (p.isMesh && p.visible && p.geometry && (p.geometry.computeBoundingBox(), p.geometry.boundingBox)) {
const c = p.geometry.boundingBox.clone();
c.applyMatrix4(p.matrixWorld), m.union(c);
}
}), m.isEmpty())
for (const c of l) {
const d = this.worldToScreen.screenToWorldWithDepth(c.x, c.y, 10);
a.push(d);
}
else {
const p = new v.Vector3();
m.getCenter(p);
const d = p.clone().sub(u.position).length();
for (const g of l) {
const _ = this.worldToScreen.screenToWorldWithDepth(g.x, g.y, d);
a.push(_);
}
}
}
if (a.length < 3) {
console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");
return;
}
const h = new v.Box3();
for (const u of a)
h.expandByPoint(u);
if (h.isEmpty()) {
console.warn("RangeScale: 计算得到的包围盒无效");
return;
}
this.fitCameraToBoundingBox(h);
}
/**
* 调整相机视角以适应包围盒
* @param boundingBox - 要适应的包围盒
*/
fitCameraToBoundingBox(e) {
const t = this.engine.camera, n = this.engine.controls;
if (!t || !n) {
console.warn("RangeScale: 相机或控制器未初始化");
return;
}
const i = new v.Vector3();
e.getCenter(i);
const o = new v.Vector3();
e.getSize(o);
const s = Math.max(o.x, o.y, o.z);
if (t instanceof v.PerspectiveCamera) {
const a = t.fov * (Math.PI / 180), h = s / (2 * Math.tan(a / 2)) * 1.2, u = new v.Vector3();
t.getWorldDirection(u);
const f = i.clone().sub(t.position);
u.dot(f.normalize()) < 0 && u.negate();
const p = i.clone().sub(u.multiplyScalar(h));
t.position.copy(p), n.target && n.target.copy(i), t.lookAt(i), n.update();
} else if (t instanceof v.OrthographicCamera) {
const l = s * 1.2, h = this.engine.renderer?.domElement, u = h ? h.width / h.height : 1;
t.left = -l * u / 2, t.right = l * u / 2, t.top = l / 2, t.bottom = -l / 2, t.updateProjectionMatrix();
const f = new v.Vector3();
t.getWorldDirection(f);
const m = s * 1.5, p = i.clone().sub(f.multiplyScalar(m));
t.position.copy(p), n.target && n.target.copy(i), t.lookAt(i), n.update();
}
}
}
class Pl {
engine;
constructor(e) {
this.engine = e;
}
init() {
}
}
class He {
engine;
constructor(e) {
this.engine = e;
}
// 渲染捕捉点事件
renderCatchElementEvent(e) {
}
// 渲染捕捉点
renderCatchElement(e) {
const t = this.engine.measure.annotationContainer.getElementsByClassName("catch-point");
if (t.length > 0) {
let n = new v.Vector2(-1e3, -1e3);
e != null && (n = new Ae(this.engine.camera, this.engine.renderer, this.engine.scene).worldToScreen(e.point));
const i = t[0];
i.style.left = n.x + "px", i.style.top = n.y + "px", console.log("更新位置");
} else {
if (e == null)
return;
const n = new Ae(this.engine.camera, this.engine.renderer, this.engine.scene).worldToScreen(e.point), i = document.createElement("div");
i.className = "catch-point", i.style.left = n.x + "px", i.style.top = n.y + "px", i.style.width = "10px", i.style.height = "10px", i.style.backgroundColor = "red", i.style.borderRadius = "50%", i.style.pointerEvents = "none", i.style.position = "absolute", i.style.zIndex = "1000", this.engine.measure.annotationContainer.appendChild(i);
}
return e;
}
// 绘制普通标注
drawNormalAnnotation() {
let e = this;
this.engine.measure.annotationData.normalAnnotation.forEach((c) => {
p(c);
}), this.engine.measure.annotationData.elevationAnnotation.forEach((c) => {
m(c);
}), this.engine.measure.annotationData.coordinateAnnotation.forEach((c) => {
f(c);
}), this.engine.measure.annotationData.angleAnnotation.forEach((c) => {
l(c);
}), this.engine.measure.annotationData.areaAnnotation.forEach((c) => {
h(c);
}), this.engine.measure.annotationData.slopeAnnotation.forEach((c) => {
u(c);
});
function l(c) {
if (c.container == null) {
let M = [
'<svg class="measureSvg">',
'<circle cx="50" cy="50" r="5" fill="#f99d0b" />',
// 起点
'<circle cx="50" cy="50" r="5" fill="#f99d0b" />',
// 顶点
'<circle cx="50" cy="50" r="5" fill="#f99d0b" />',
// 终点
'<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>',
// 起点到顶点的线
'<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>',
// 顶点到终点的线
'<rect x="0" y="0" width="80" height="25" class="measureBack" />',
'<text x="40" y="16" text-anchor="middle" class="measureLabel">' + c.text + "</text>",
"</svg>"
].join("");
c.container = document.createElement("div"), c.container.className = "angle-annotation", c.container.id = c.id, c.container.innerHTML = M, e.engine.measure.annotationContainer.appendChild(c.container), c.container.getElementsByTagName("svg")[0].addEventListener("click", function() {
c.container.getElementsByTagName("svg")[0].classList.add("Hight");
});
}
let d = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point1), g = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point2), _ = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point3), w = c.container;
w.getElementsByTagName("circle")[0].setAttribute("cx", d.x), w.getElementsByTagName("circle")[0].setAttribute("cy", d.y), w.getElementsByTagName("circle")[1].setAttribute("cx", g.x), w.getElementsByTagName("circle")[1].setAttribute("cy", g.y), w.getElementsByTagName("circle")[2].setAttribute("cx", _.x), w.getElementsByTagName("circle")[2].setAttribute("cy", _.y), w.getElementsByTagName("polyline")[0].setAttribute("points", d.x + "," + d.y + " " + g.x + "," + g.y), w.getElementsByTagName("polyline")[1].setAttribute("points", g.x + "," + g.y + " " + _.x + "," + _.y);
let b = g.x, T = g.y - 30;
w.getElementsByTagName("rect")[0].setAttribute("x", b - 40), w.getElementsByTagName("rect")[0].setAttribute("y", T - 12.5), w.getElementsByTagName("text")[0].setAttribute("x", b), w.getElementsByTagName("text")[0].setAttribute("y", T + 4), w.getElementsByTagName("text")[0].innerHTML = c.text, w.style.top = "0px", w.style.left = "0px";
}
function h(c) {
if (c.container == null) {
let C = [
'<svg class="measureSvg">',
'<polygon fill="rgba(255, 165, 0, 0.3)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>',
// 填充区域
'<polyline stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>',
// 边界线
'<rect x="0" y="0" width="80" height="25" class="measureBack" />',
'<text x="40" y="16" text-anchor="middle" class="measureLabel">' + c.text + "</text>",
"</svg>"
].join("");
c.container = document.createElement("div"), c.container.className = "area-annotation", c.container.id = c.id, c.container.innerHTML = C, e.engine.measure.annotationContainer.appendChild(c.container), c.container.getElementsByTagName("svg")[0].addEventListener("click", function() {
c.container.getElementsByTagName("svg")[0].classList.add("Hight");
});
}
if (!c.points || c.points.length < 3)
return;
let d = [], g = 0, _ = 0;
for (let C = 0; C < c.points.length; C++) {
let P = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.points[C]);
d.push(P), g += P.x, _ += P.y;
}
g = g / d.length, _ = _ / d.length;
let w = d.map((C) => C.x + "," + C.y).join(" "), b = c.container;
b.getElementsByTagName("polygon")[0].setAttribute("points", w), b.getElementsByTagName("polyline")[0].setAttribute("points", w);
let T = g, M = _;
b.getElementsByTagName("rect")[0].setAttribute("x", T - 40), b.getElementsByTagName("rect")[0].setAttribute("y", M - 12.5), b.getElementsByTagName("text")[0].setAttribute("x", T), b.getElementsByTagName("text")[0].setAttribute("y", M + 4), b.getElementsByTagName("text")[0].innerHTML = c.text, b.style.top = "0px", b.style.left = "0px";
}
function u(c) {
if (c.container == null) {
let T = [
'<svg class="measureSvg">',
"<defs>",
'<marker id="slope-arrow-' + c.id + '" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">',
'<path d="M0,0 L0,6 L9,3 z" fill="orange" stroke="orange" />',
// 箭头形状
"</marker>",
"</defs>",
'<polyline stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-' + c.id + ')" style="fill: none; opacity: 1;"/>',
// 起点到终点的线,带箭头
'<rect x="0" y="0" width="100" height="25" class="measureBack" />',
'<text x="50" y="16" text-anchor="middle" class="measureLabel">' + c.text + "</text>",
"</svg>"
].join("");
c.container = document.createElement("div"), c.container.className = "slope-annotation", c.container.id = c.id, c.container.innerHTML = T, e.engine.measure.annotationContainer.appendChild(c.container), c.container.getElementsByTagName("svg")[0].addEventListener("click", function() {
c.container.getElementsByTagName("svg")[0].classList.add("Hight");
});
}
let d = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point1), g = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point2), _ = c.container;
_.getElementsByTagName("polyline")[0].setAttribute("points", d.x + "," + d.y + " " + g.x + "," + g.y);
let w = (d.x + g.x) / 2, b = (d.y + g.y) / 2 - 30;
_.getElementsByTagName("rect")[0].setAttribute("x", w - 50), _.getElementsByTagName("rect")[0].setAttribute("y", b - 12.5), _.getElementsByTagName("text")[0].setAttribute("x", w), _.getElementsByTagName("text")[0].setAttribute("y", b + 4), _.getElementsByTagName("text")[0].innerHTML = c.text, _.style.top = "0px", _.style.left = "0px";
}
function f(c) {
if (c.container == null) {
let M = [
'<svg class="measureSvg">',
'<circle cx="0" cy="0" r="5" fill="#f99d0b" />',
'<rect x="0" y="-25" width="100" height="25" class="measureBack" />',
'<text x="40" y="-11" text-anchor="middle" class="measureLabel">' + c.textX + "</text>",
'<rect x="0" y="-10" width="100" height="25" class="measureBack" />',
'<text x="40" y="25" text-anchor="middle" class="measureLabel">' + c.textY + "</text>",
'<rect x="0" y="10" width="100" height="25" class="measureBack" />',
'<text x="40" y="51" text-anchor="middle" class="measureLabel">' + c.textZ + "</text>",
"</svg>"
].join("");
c.container = document.createElement("div"), c.container.className = "coordinate-annotation", c.container.id = c.id, c.container.style.position = "absolute", c.container.style.pointerEvents = "none", c.container.innerHTML = M, e.engine.measure.annotationContainer.appendChild(c.container), c.container.getElementsByTagName("svg")[0].addEventListener("click", function() {
c.container.getElementsByTagName("svg")[0].classList.add("Hight");
});
}
let d = c.container, g = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point);
d.style.top = "0px", d.style.left = "0px";
let _ = d.getElementsByTagName("circle")[0];
_ && (_.setAttribute("cx", g.x), _.setAttribute("cy", g.y));
let w = d.getElementsByTagName("rect"), b = d.getElementsByTagName("text"), T = -55;
w[0] && (w[0].setAttribute("x", g.x + 10), w[0].setAttribute("y", g.y + 10 + T)), b[0] && (b[0].setAttribute("x", g.x + 10 + 40), b[0].setAttribute("y", g.y + 10 + 16 + T)), w[1] && (w[1].setAttribute("x", g.x + 10), w[1].setAttribute("y", g.y + 10 + 30 + T)), b[1] && (b[1].setAttribute("x", g.x + 10 + 40), b[1].setAttribute("y", g.y + 10 + 46 + T)), w[2] && (w[2].setAttribute("x", g.x + 10), w[2].setAttribute("y", g.y + 10 + 60 + T)), b[2] && (b[2].setAttribute("x", g.x + 10 + 40), b[2].setAttribute("y", g.y + 10 + 76 + T)), b[0] && (b[0].innerHTML = c.textX), b[1] && (b[1].innerHTML = c.textY), b[2] && (b[2].innerHTML = c.textZ);
}
function m(c) {
if (c.container == null) {
let _ = [
'<svg width="100" height="50" class="measureSvg">',
'<rect x="0" y="0" width="80" height="25" class="measureBack" />',
'<text x="40" y="16" text-anchor="middle" class="measureLabel">' + c.text + "</text>",
'<polyline stroke="#f99d0b" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',
"</svg>"
].join("");
c.container = document.createElement("div"), c.container.className = "elevation-annotation", c.container.id = c.id, c.container.style.position = "absolute", c.container.style.pointerEvents = "none", c.container.innerHTML = _, e.engine.measure.annotationContainer.appendChild(c.container), c.container.getElementsByTagName("svg")[0].addEventListener("click", function() {
c.container.getElementsByTagName("svg")[0].classList.add("Hight");
});
}
let d = c.container, g = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point);
d.style.top = g.y - 48 + "px", d.style.left = g.x - 16 + "px", d.getElementsByTagName("text")[0].innerHTML = c.text;
}
function p(c) {
if (c.container == null) {
let w = [
'<svg class="measureSvg">',
'<circle cx="50" cy="50" r="5" fill="#f99d0b" />',
'<circle cx="50" cy="50" r="5" fill="#f99d0b" />',
'<polyline stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>',
'<rect x="0" y="0" width="80" height="25" class="measureBack" />',
'<text x="40" y="16" text-anchor="middle" class="measureLabel">' + c.text + "</text>",
"</svg>"
].join("");
c.container = document.createElement("div"), c.container.className = "normal-annotation", c.container.id = c.id, c.container.innerHTML = w, e.engine.measure.annotationContainer.appendChild(c.container), c.container.getElementsByTagName("svg")[0].addEventListener("click", function() {
c.container.getElementsByTagName("svg")[0].classList.add("Hight");
});
}
let d = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point1), g = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point2), _ = c.container;
_.getElementsByTagName("polyline")[0].setAttribute("points", d.x + "," + d.y + " " + g.x + "," + g.y), _.getElementsByTagName("circle")[0].setAttribute("cx", d.x), _.getElementsByTagName("circle")[0].setAttribute("cy", d.y), _.getElementsByTagName("circle")[1].setAttribute("cx", g.x), _.getElementsByTagName("circle")[1].setAttribute("cy", g.y), _.getElementsByTagName("rect")[0].setAttribute("x", d.x * 0.5 + g.x * 0.5 - 40), _.getElementsByTagName("rect")[0].setAttribute("y", d.y * 0.5 + g.y * 0.5 - 12.5), _.getElementsByTagName("text")[0].setAttribute("x", d.x * 0.5 + g.x * 0.5 + 40 - 40), _.getElementsByTagName("text")[0].setAttribute("y", d.y * 0.5 + g.y * 0.5 + 16 - 12.5), _.getElementsByTagName("text")[0].innerHTML = c.text, _.style.top = "0px", _.style.left = "0px";
}
}
// 绘制文本标注
drawTextAnnotation(e) {
console.log(e);
}
// 绘制坐标标注
drawCoordinateAnnotation(e) {
console.log(e);
}
// 绘制角度标注
drawAngleAnnotation(e) {
console.log(e);
}
// 绘制距离标注
drawDistanceAnnotation(e) {
console.log(e);
}
// 绘制面积标注
drawAreaAnnotation(e) {
console.log(e);
}
// 绘制体积标注
drawVolumeAnnotation(e) {
console.log(e);
}
}
class Rl {
engine;
isActive = !1;
tools;
constructor(e) {
this.engine = e, this.tools = new He(e);
}
// 启动净高测量
active() {
this.isActive = !0, this.listenMouseMove();
}
// 停止净高测量
disActive() {
this.isActive = !1;
}
// 激活时,监听鼠标移动,并获取鼠标点击的模型或者点
listenMouseMove() {
this.engine.events.on(Be.MouseMove, (e) => {
this.tools.renderCatchElement(e);
});
}
}
function rt() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
var e = Math.random() * 16 | 0, t = r == "x" ? e : e & 3 | 8;
return t.toString(16);
});
}
class Dl {
engine;
tools;
isActive = !1;
points = [];
behavior;
constructor(e) {
this.engine = e, this.tools = new He(e);
}
// 启动距离测量
active() {
this.isActive = !0, this.points = [], this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active();
}
// 停止距离测量
disActive() {
this.points = [], this.isActive = !1, this.behavior.disActive();
}
handleMouseClick(e) {
if (e.catch == null)
return;
let t = this.tools.renderCatchElement(e.catch);
if (this.points.length == 0)
this.points.push(t.point);
else if (this.points.length == 1) {
let n = this.engine.measure.annotationData.normalAnnotation.find((i) => i.isSelect == !0);
if (n == null)
return;
n.point2 = t.point, n.isSelect = !1, this.points = [], this.engine.events.trigger(Be.MeasureChanged, n);
}
}
handleMouseMove(e) {
if (e.catch == null)
return;
let t = this.tools.renderCatchElement(e.catch);
if (t != null && this.points.length == 1) {
let n = this.engine.measure.annotationData.normalAnnotation.find((i) => i.isSelect == !0);
n == null && (n = {
id: rt(),
point1: this.points[0].clone(),
point2: t.point.clone(),
text: this.points[0].clone().distanceTo(t.point.clone()).toFixed(2) + " m",
isSelect: !0
}, this.engine.measure.annotationData.normalAnnotation.push(n)), n.point2 = t.point, n.text = n.point1.clone().distanceTo(n.point2.clone()).toFixed(2) + " m", console.log("距离", n.text);
}
}
}
class Ll {
engine;
isActive = !1;
tools;
constructor(e) {
this.engine = e, this.tools = new He(e);
}
active() {
this.isActive = !0;
}
disActive() {
this.isActive = !1;
}
}
class Ol {
engine;
isActive = !1;
tools;
behavior;
constructor(e) {
this.engine = e, this.tools = new He(e);
}
active() {
this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(), this.isActive = !0;
}
disActive() {
this.isActive = !1, this.behavior.disActive();
}
handleMouseMove(e) {
if (e.catch == null)
return;
let t = this.engine.measure.annotationData.elevationAnnotation.find((n) => n.isSelect == !0);
t == null && (t = {
id: rt(),
point: e.catch.point.clone(),
text: Math.round(e.catch.point.y) + " m",
isSelect: !0
}, this.engine.measure.annotationData.elevationAnnotation.push(t)), t.point = e.catch.point.clone(), t.text = Math.round(e.catch.point.y) + " m";
}
handleMouseClick(e) {
if (e.catch == null)
return;
let t = this.engine.measure.annotationData.elevationAnnotation.find((n) => n.isSelect == !0);
t != null && (t.isSelect = !1, t.point = e.catch.point.clone(), t.text = Math.round(e.catch.point.y) + " m", this.engine.events.trigger(Be.MeasureChanged, t));
}
}
class Nl {
engine;
isActive = !1;
tools;
behavior;
constructor(e) {
this.engine = e, this.tools = new He(e);
}
active() {
this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active(), this.isActive = !0;
}
disActive() {
this.isActive = !1, this.behavior.disActive();
}
handleMouseMove(e) {
if (e.catch == null)
return;
let t = this.engine.measure.annotationData.coordinateAnnotation.find((n) => n.isSelect == !0);
t == null && (t = {
id: rt(),
point: e.catch.point.clone(),
text: Math.round(e.catch.point.y) + " m",
isSelect: !0
}, this.engine.measure.annotationData.coordinateAnnotation.push(t)), t.point = e.catch.point.clone(), t.textX = Math.round(e.catch.point.x) + " m", t.textY = Math.round(e.catch.point.y) + " m", t.textZ = Math.round(e.catch.point.z) + " m";
}
handleMouseClick(e) {
if (e.catch == null)
return;
let t = this.engine.measure.annotationData.coordinateAnnotation.find((n) => n.isSelect == !0);
t != null && (t.isSelect = !1, t.point = e.catch.point.clone(), t.textX = Math.round(e.catch.point.x) + " m", t.textY = Math.round(e.catch.point.y) + " m", t.textZ = Math.round(e.catch.point.z) + " m", this.engine.events.trigger(Be.MeasureChanged, t));
}
}
class zl {
engine;
tools;
// 存储三个点:起点、顶点(中间点)、终点
points = [];
behavior;
constructor(e) {
this.engine = e, this.tools = new He(e);
}
// 启动角度测量
active() {
this.points = [], this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active();
}
// 停止角度测量
disActive() {
this.points = [], this.behavior.disActive();
}
// 计算三点形成的角度(以第二个点为顶点)
// point1: 起点, point2: 顶点, point3: 终点
calculateAngle(e, t, n) {
const i = new v.Vector3().subVectors(e, t), o = new v.Vector3().subVectors(n, t), s = i.length(), a = o.length();
if (s === 0 || a === 0)
return 0;
const h = i.dot(o) / (s * a), u = Math.max(-1, Math.min(1, h));
return Math.acos(u) * (180 / Math.PI);
}
// 处理鼠标点击事件
handleMouseClick(e) {
if (e.catch == null)
return;
let t = this.tools.renderCatchElement(e.catch);
if (this.points.length == 0)
this.points.push(t.point);
else if (this.points.length == 1)
this.points.push(t.point);
else if (this.points.length == 2) {
let n = this.engine.measure.annotationData.angleAnnotation.find((i) => i.isSelect == !0);
if (n == null)
return;
n.point3 = t.point.clone(), n.angle = this.calculateAngle(n.point1, n.point2, n.point3), n.text = n.angle.toFixed(2) + "°", n.isSelect = !1, this.points = [], this.engine.events.trigger(Be.MeasureChanged, n);
}
}
// 处理鼠标移动事件
handleMouseMove(e) {
if (e.catch == null)
return;
let t = this.tools.renderCatchElement(e.catch);
if (t != null && this.points.length != 1 && this.points.length == 2) {
let n = this.engine.measure.annotationData.angleAnnotation.find((i) => i.isSelect == !0);
n == null && (n = {
id: rt(),
point1: this.points[0].clone(),
// 起点
point2: this.points[1].clone(),
// 顶点(中间点)
point3: t.point.clone(),
// 终点(实时更新)
angle: 0,
text: "0.00°",
isSelect: !0
}, this.engine.measure.annotationData.angleAnnotation.push(n)), n.point3 = t.point.clone(), n.angle = this.calculateAngle(n.point1, n.point2, n.point3), n.text = n.angle.toFixed(2) + "°", console.log("角度", n.text);
}
}
}
class Il {
engine;
tools;
// 存储多个点,用于围成区域
points = [];
behavior;
constructor(e) {
this.engine = e, this.tools = new He(e);
}
// 启动面积测量
active() {
this.points = [], this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active();
}
// 停止面积测量
disActive() {
this.points = [], this.behavior.disActive();
}
// 计算多边形面积(使用鞋带公式/Shoelace formula
// 注意这个方法假设点在同一个平面上使用XZ平面投影计算面积
calculateArea(e) {
if (e.length < 3)
return 0;
let t = 0;
const n = e.length;
for (let i = 0; i < n; i++) {
const o = (i + 1) % n;
t += e[i].x * e[o].z, t -= e[o].x * e[i].z;
}
return t = Math.abs(t) / 2, t;
}
// 处理鼠标点击事件
handleMouseClick(e) {
if (e.catch == null)
return;
let t = this.tools.renderCatchElement(e.catch);
if (this.points.push(t.point.clone()), this.points.length >= 3) {
let n = this.engine.measure.annotationData.areaAnnotation.find((i) => i.isSelect == !0);
n == null ? (n = {
id: rt(),
points: this.points.map((i) => i.clone()),
// 复制所有点
area: 0,
text: "0.00 m²",
isSelect: !0
}, this.engine.measure.annotationData.areaAnnotation.push(n)) : n.points = this.points.map((i) => i.clone()), n.area = this.calculateArea(n.points), n.text = n.area.toFixed(2) + " m²", console.log("面积", n.text);
}
}
// 处理鼠标移动事件
handleMouseMove(e) {
if (e.catch == null)
return;
let t = this.tools.renderCatchElement(e.catch);
if (t != null && this.points.length >= 2) {
let n = this.engine.measure.annotationData.areaAnnotation.find((i) => i.isSelect == !0);
if (n == null) {
if (this.points.length >= 2) {
let i = this.points.map((o) => o.clone());
i.push(t.point.clone()), i.length >= 3 && (n = {
id: rt(),
points: i,
area: 0,
text: "0.00 m²",
isSelect: !0
}, this.engine.measure.annotationData.areaAnnotation.push(n));
}
} else if (n.points.length > 0) {
const i = n.points.length - 1;
n.points[i] = t.point.clone();
} else
n.points = this.points.map((i) => i.clone()), n.points.push(t.point.clone());
n && n.points.length >= 3 && (n.area = this.calculateArea(n.points), n.text = n.area.toFixed(2) + " m²");
}
}
// 完成面积测量(可以用于双击或右键完成)
finishMeasure() {
let e = this.engine.measure.annotationData.areaAnnotation.find((t) => t.isSelect == !0);
e != null && e.points.length >= 3 && (e.points.length > this.points.length && (e.points = this.points.map((t) => t.clone())), e.area = this.calculateArea(e.points), e.text = e.area.toFixed(2) + " m²", e.isSelect = !1, this.points = [], this.engine.events.trigger(Be.MeasureChanged, e));
}
}
class Bl {
engine;
tools;
// 存储两个点:起点和终点
points = [];
behavior;
constructor(e) {
this.engine = e, this.tools = new He(e);
}
// 启动坡度测量
active() {
this.points = [], this.behavior = this.engine.handelBehaved, this.behavior.init(this), this.behavior.active();
}
// 停止坡度测量
disActive() {
this.points = [], this.behavior.disActive();
}
// 计算两点之间的坡度
// point1: 起点, point2: 终点
// 返回:{ percentage: 坡度百分比, angle: 坡度角度(度), heightDiff: 高度差, horizontalDist: 水平距离 }
calculateSlope(e, t) {
const n = t.y - e.y, i = t.x - e.x, o = t.z - e.z, s = Math.sqrt(i * i + o * o);
if (s === 0)
return {
percentage: 0,
angle: 0,
heightDiff: n,
horizontalDist: 0
};
const a = n / s * 100, h = Math.atan(n / s) * (180 / Math.PI);
return {
percentage: a,
angle: h,
heightDiff: n,
horizontalDist: s
};
}
// 处理鼠标点击事件
handleMouseClick(e) {
if (e.catch == null)
return;
let t = this.tools.renderCatchElement(e.catch);
if (this.points.length == 0)
this.points.push(t.point);
else if (this.points.length == 1) {
let n = this.engine.measure.annotationData.slopeAnnotation.find((o) => o.isSelect == !0);
if (n == null)
return;
n.point2 = t.point.clone();
const i = this.calculateSlope(n.point1, n.point2);
n.slopePercentage = i.percentage, n.slopeAngle = i.angle, n.heightDiff = i.heightDiff, n.horizontalDist = i.horizontalDist, n.text = i.percentage.toFixed(2) + "% (" + i.angle.toFixed(2) + "°)", n.isSelect = !1, this.points = [], this.engine.events.trigger(Be.MeasureChanged, n);
}
}
// 处理鼠标移动事件
handleMouseMove(e) {
if (e.catch == null)
return;
let t = this.tools.renderCatchElement(e.catch);
if (t != null && this.points.length == 1) {
let n = this.engine.measure.annotationData.slopeAnnotation.find((o) => o.isSelect == !0);
n == null && (n = {
id: rt(),
point1: this.points[0].clone(),
// 起点
point2: t.point.clone(),
// 终点(实时更新)
slopePercentage: 0,
slopeAngle: 0,
heightDiff: 0,
horizontalDist: 0,
text: "0.00% (0.00°)",
isSelect: !0
}, this.engine.measure.annotationData.slopeAnnotation.push(n)), n.point2 = t.point.clone();
const i = this.calculateSlope(n.point1, n.point2);
n.slopePercentage = i.percentage, n.slopeAngle = i.angle, n.heightDiff = i.heightDiff, n.horizontalDist = i.horizontalDist, n.text = i.percentage.toFixed(2) + "% (" + i.angle.toFixed(2) + "°)", console.log("坡度", n.text);
}
}
}
class Ul {
isActive = !1;
engine;
clearHeightMeasure;
distanceMeasure;
clearDistanceMeasure;
elevationMeasure;
pointMeasure;
angleMeasure;
areaMeasure;
slopeMeasure;
tools;
annotationContainer;
// 存储标注信息
annotationData = {
normalAnnotation: [],
textAnnotation: [],
coordinateAnnotation: [],
angleAnnotation: [],
distanceAnnotation: [],
areaAnnotation: [],
slopeAnnotation: [],
elevationAnnotation: [],
volumeAnnotation: []
};
constructor(e) {
this.engine = e, this.clearHeightMeasure = new Rl(e), this.distanceMeasure = new Dl(e), this.clearDistanceMeasure = new Ll(e), this.elevationMeasure = new Ol(e), this.pointMeasure = new Nl(e), this.angleMeasure = new zl(e), this.areaMeasure = new Il(e), this.slopeMeasure = new Bl(e), this.tools = new He(e), this.annotationContainer = document.createElement("div"), this.annotationContainer.className = "annotation-container", e.container.parentElement.appendChild(this.annotationContainer);
}
active() {
this.isActive = !0;
}
disActive() {
this.clearAll(), this.isActive = !1;
}
// 清除所有测量
clearAll() {
this.annotationData.normalAnnotation = [], this.annotationData.textAnnotation = [], this.annotationData.coordinateAnnotation = [], this.annotationData.angleAnnotation = [], this.annotationData.distanceAnnotation = [], this.annotationData.areaAnnotation = [], this.annotationData.slopeAnnotation = [], this.annotationData.elevationAnnotation = [], this.annotationData.volumeAnnotation = [];
}
// 更新标注
update() {
this.isActive && this.tools.drawNormalAnnotation();
}
}
class Fl {
engine;
isActive = !1;
isDrag = !1;
meshs = [];
box;
pickPoint;
pickNormal;
pickMesh;
box_;
plane;
constructor(e) {
this.engine = e, this.meshs = [], this.box = null;
}
// 启动
active() {
this.isActive != !0 && (this.isActive = !0, this.init(), this.engine.handelBehaved.init(this), this.engine.handelBehaved.active());
}
disActive() {
this.isActive = !1, this.engine.handelBehaved.disActive();
}
// 初始化
init() {
let e = this.engine.octreeBox.getBoundingBox();
this.box = e, this.updata_face(e);
}
// 更新面
updata_face(e) {
let t = this, n = t.engine.scene.children.find((s) => s.type == "Group" && s.name == "ClippingBox");
n == null && (n = new v.Group(), n.name = "ClippingBox", t.engine.scene.add(n));
let i = [
new v.Vector3(e.min.x, e.min.y, e.min.z),
new v.Vector3(e.max.x, e.min.y, e.min.z),
new v.Vector3(e.max.x, e.max.y, e.min.z),
new v.Vector3(e.min.x, e.max.y, e.min.z)
];
o(i, new v.Vector3(0, 0, -1), "前");
function o(s, a, l) {
const h = new v.BufferGeometry(), u = new Float32Array([
s[0].x,
s[0].y,
s[0].z,
// 点1
s[1].x,
s[1].y,
s[1].z,
// 点2
s[2].x,
s[2].y,
s[2].z,
// 点3
s[3].x,
s[3].y,
s[3].z
// 点4
]), f = [
0,
1,
2,
// 第一个三角形
0,
2,
3
// 第二个三角形
];
h.setAttribute("position", new v.BufferAttribute(u, 3)), h.setIndex(f);
let m = t.meshs.find((_) => _.name == l);
if (m == null) {
const _ = new v.MeshBasicMaterial({
color: 65280,
// 绿色
transparent: !0,
opacity: 0.02,
side: v.DoubleSide
// 双面渲染
}), w = new v.Mesh(h, _);
w.normal = a, w.name = l, n.add(w), t.meshs.push(w);
} else
m.geometry = h;
const p = new Float32Array([
s[0].x,
s[0].y,
s[0].z,
// 点1
s[1].x,
s[1].y,
s[1].z,
// 点2
s[2].x,
s[2].y,
s[2].z,
// 点3
s[3].x,
s[3].y,
s[3].z,
// 点4
s[0].x,
s[0].y,
s[0].z
// 点1
]);
let c = new v.LineBasicMaterial({ color: 255 }), d = new v.BufferGeometry();
d.setAttribute("position", new v.BufferAttribute(p, 3));
let g = t.meshs.find((_) => _.name == l + "Line");
g == null && (g = new v.Line(d, c), g.name = l + "Line", n.add(g), t.meshs.push(g)), g.geometry = d, g.material = c, t.engine.sectionPlane.find((_) => _.name == l).setFromNormalAndCoplanarPoint(a.clone().setLength(-1), e.min), t.engine.scene.children.filter((_) => _.type == "Mesh" && _.url).forEach((_) => {
_.material && Array.isArray(_.material) ? _.material.forEach((w) => {
w.clippingPlanes = t.engine.sectionPlane;
}) : _.material.clippingPlanes = t.engine.sectionPlane;
});
}
}
// 重写鼠标按下事件
handleMouseDown(e) {
this.isDrag = !0;
const t = e.raycaster.intersectObjects(this.meshs, !1);
if (t != null && t.length > 0)
if (this.pickPoint = t[0].point, this.pickNormal = t[0].face.normal, this.engine.controls.enabled = !1, this.pickMesh = t[0].object, this.box_ = {
min: this.box.min.clone(),
max: this.box.max.clone()
}, this.pickNormal.y == 0) {
const n = new v.Plane();
n.setFromNormalAndCoplanarPoint(new v.Vector3(0, 1, 0), this.pickPoint), this.plane = n;
} else {
let n = new v.Vector3(this.engine.camera.position.x, this.pickPoint.y, this.engine.camera.position.z);
const i = new v.Plane();
i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1), this.pickPoint), this.plane = i;
}
}
handleMouseUp(e) {
this.isDrag = !1, this.pickPoint = null, this.pickNormal = null, this.pickMesh = null, this.engine.controls.enabled = !0;
}
handleMouseMove(e) {
this.meshs.forEach((n) => {
n.material.opacity = 0;
});
const t = e.raycaster.intersectObjects(this.meshs, !1);
if (t != null && t.length > 0 && (t[0].object.material.opacity = 0.05), this.pickPoint != null) {
const n = new v.Vector3();
if (e.raycaster.ray.intersectPlane(this.plane, n)) {
let i = n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());
this.pickMesh.name == "前" || this.pickMesh.name == "左" || this.pickMesh.name == "底" ? this.box.min = this.box_.min.clone().add(this.pickNormal.clone().setLength(i)) : this.box.max = this.box_.max.clone().add(this.pickNormal.clone().setLength(i)), this.updata_face(this.box);
}
}
}
}
class jl {
engine;
isActive = !1;
isDrag = !1;
meshs = [];
box;
pickPoint;
pickNormal;
pickMesh;
box_;
plane;
constructor(e) {
this.engine = e, this.meshs = [], this.box = null;
}
// 启动
active() {
this.isActive != !0 && (this.isActive = !0, this.init(), this.engine.handelBehaved.init(this), this.engine.handelBehaved.active());
}
disActive() {
this.isActive = !1, this.engine.handelBehaved.disActive();
}
// 初始化
init() {
let e = this.engine.octreeBox.getBoundingBox();
this.box = e, this.updata_face(e);
}
// 更新面
updata_face(e) {
let t = this, n = t.engine.scene.children.find((s) => s.type == "Group" && s.name == "ClippingBox");
n == null && (n = new v.Group(), n.name = "ClippingBox", t.engine.scene.add(n));
let i = [
new v.Vector3(e.min.x, e.max.y, e.min.z),
new v.Vector3(e.max.x, e.max.y, e.min.z),
new v.Vector3(e.max.x, e.max.y, e.max.z),
new v.Vector3(e.min.x, e.max.y, e.max.z)
];
o(i, new v.Vector3(0, 1, 0), "顶");
function o(s, a, l) {
const h = new v.BufferGeometry(), u = new Float32Array([
s[0].x,
s[0].y,
s[0].z,
// 点1
s[1].x,
s[1].y,
s[1].z,
// 点2
s[2].x,
s[2].y,
s[2].z,
// 点3
s[3].x,
s[3].y,
s[3].z
// 点4
]), f = [
0,
1,
2,
// 第一个三角形
0,
2,
3
// 第二个三角形
];
h.setAttribute("position", new v.BufferAttribute(u, 3)), h.setIndex(f);
let m = t.meshs.find((_) => _.name == l);
if (m == null) {
const _ = new v.MeshBasicMaterial({
color: 65280,
// 绿色
transparent: !0,
opacity: 0.02,
side: v.DoubleSide
// 双面渲染
}), w = new v.Mesh(h, _);
w.normal = a, w.name = l, n.add(w), t.meshs.push(w);
} else
m.geometry = h;
const p = new Float32Array([
s[0].x,
s[0].y,
s[0].z,
// 点1
s[1].x,
s[1].y,
s[1].z,
// 点2
s[2].x,
s[2].y,
s[2].z,
// 点3
s[3].x,
s[3].y,
s[3].z,
// 点4
s[0].x,
s[0].y,
s[0].z
// 点1
]);
let c = new v.LineBasicMaterial({ color: 255 }), d = new v.BufferGeometry();
d.setAttribute("position", new v.BufferAttribute(p, 3));
let g = t.meshs.find((_) => _.name == l + "Line");
g == null && (g = new v.Line(d, c), g.name = l + "Line", n.add(g), t.meshs.push(g)), g.geometry = d, g.material = c, t.engine.sectionPlane.find((_) => _.name == l).setFromNormalAndCoplanarPoint(a.clone().setLength(-1), e.max), t.engine.scene.children.filter((_) => _.type == "Mesh" && _.url).forEach((_) => {
_.material && Array.isArray(_.material) ? _.material.forEach((w) => {
w.clippingPlanes = t.engine.sectionPlane;
}) : _.material.clippingPlanes = t.engine.sectionPlane;
});
}
}
// 重写鼠标按下事件
handleMouseDown(e) {
this.isDrag = !0;
const t = e.raycaster.intersectObjects(this.meshs, !1);
if (t != null && t.length > 0)
if (this.pickPoint = t[0].point, this.pickNormal = t[0].face.normal, this.engine.controls.enabled = !1, this.pickMesh = t[0].object, this.box_ = {
min: this.box.min.clone(),
max: this.box.max.clone()
}, this.pickNormal.y == 0) {
const n = new v.Plane();
n.setFromNormalAndCoplanarPoint(new v.Vector3(0, 1, 0), this.pickPoint), this.plane = n;
} else {
let n = new v.Vector3(this.engine.camera.position.x, this.pickPoint.y, this.engine.camera.position.z);
const i = new v.Plane();
i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1), this.pickPoint), this.plane = i;
}
}
handleMouseUp(e) {
this.isDrag = !1, this.pickPoint = null, this.pickNormal = null, this.pickMesh = null, this.engine.controls.enabled = !0;
}
handleMouseMove(e) {
this.meshs.forEach((n) => {
n.material.opacity = 0;
});
const t = e.raycaster.intersectObjects(this.meshs, !1);
if (t != null && t.length > 0 && (t[0].object.material.opacity = 0.05), this.pickPoint != null) {
const n = new v.Vector3();
if (e.raycaster.ray.intersectPlane(this.plane, n)) {
let i = n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());
this.pickMesh.name == "前" || this.pickMesh.name == "左" || this.pickMesh.name == "底" ? this.box.min = this.box_.min.clone().add(this.pickNormal.clone().setLength(i)) : this.box.max = this.box_.max.clone().add(this.pickNormal.clone().setLength(i)), this.updata_face(this.box);
}
}
}
}
class Vl {
engine;
isActive = !1;
isDrag = !1;
meshs = [];
box;
pickPoint;
pickNormal;
pickMesh;
box_;
plane;
constructor(e) {
this.engine = e, this.meshs = [], this.box = null;
}
// 启动
active() {
this.isActive != !0 && (this.isActive = !0, this.init(), this.engine.handelBehaved.init(this), this.engine.handelBehaved.active());
}
disActive() {
this.isActive = !1, this.engine.handelBehaved.disActive();
}
// 初始化
init() {
let e = this.engine.octreeBox.getBoundingBox();
this.box = e, this.updata_face(e);
}
// 更新面
updata_face(e) {
let t = this, n = t.engine.scene.children.find((s) => s.type == "Group" && s.name == "ClippingBox");
n == null && (n = new v.Group(), n.name = "ClippingBox", t.engine.scene.add(n));
let i = [
new v.Vector3(e.min.x, e.min.y, e.max.z),
new v.Vector3(e.min.x, e.min.y, e.min.z),
new v.Vector3(e.min.x, e.max.y, e.min.z),
new v.Vector3(e.min.x, e.max.y, e.max.z)
];
o(i, new v.Vector3(-1, 0, 0), "左");
function o(s, a, l) {
const h = new v.BufferGeometry(), u = new Float32Array([
s[0].x,
s[0].y,
s[0].z,
// 点1
s[1].x,
s[1].y,
s[1].z,
// 点2
s[2].x,
s[2].y,
s[2].z,
// 点3
s[3].x,
s[3].y,
s[3].z
// 点4
]), f = [
0,
1,
2,
// 第一个三角形
0,
2,
3
// 第二个三角形
];
h.setAttribute("position", new v.BufferAttribute(u, 3)), h.setIndex(f);
let m = t.meshs.find((_) => _.name == l);
if (m == null) {
const _ = new v.MeshBasicMaterial({
color: 65280,
// 绿色
transparent: !0,
opacity: 0.02,
side: v.DoubleSide
// 双面渲染
}), w = new v.Mesh(h, _);
w.normal = a, w.name = l, n.add(w), t.meshs.push(w);
} else
m.geometry = h;
const p = new Float32Array([
s[0].x,
s[0].y,
s[0].z,
// 点1
s[1].x,
s[1].y,
s[1].z,
// 点2
s[2].x,
s[2].y,
s[2].z,
// 点3
s[3].x,
s[3].y,
s[3].z,
// 点4
s[0].x,
s[0].y,
s[0].z
// 点1
]);
let c = new v.LineBasicMaterial({ color: 255 }), d = new v.BufferGeometry();
d.setAttribute("position", new v.BufferAttribute(p, 3));
let g = t.meshs.find((_) => _.name == l + "Line");
g == null && (g = new v.Line(d, c), g.name = l + "Line", n.add(g), t.meshs.push(g)), g.geometry = d, g.material = c, t.engine.sectionPlane.find((_) => _.name == l).setFromNormalAndCoplanarPoint(a.clone().setLength(-1), e.min), t.engine.scene.children.filter((_) => _.type == "Mesh" && _.url).forEach((_) => {
_.material && Array.isArray(_.material) ? _.material.forEach((w) => {
w.clippingPlanes = t.engine.sectionPlane;
}) : _.material.clippingPlanes = t.engine.sectionPlane;
});
}
}
// 重写鼠标按下事件
handleMouseDown(e) {
this.isDrag = !0;
const t = e.raycaster.intersectObjects(this.meshs, !1);
if (t != null && t.length > 0)
if (this.pickPoint = t[0].point, this.pickNormal = t[0].face.normal, this.engine.controls.enabled = !1, this.pickMesh = t[0].object, this.box_ = {
min: this.box.min.clone(),
max: this.box.max.clone()
}, this.pickNormal.y == 0) {
const n = new v.Plane();
n.setFromNormalAndCoplanarPoint(new v.Vector3(0, 1, 0), this.pickPoint), this.plane = n;
} else {
let n = new v.Vector3(this.engine.camera.position.x, this.pickPoint.y, this.engine.camera.position.z);
const i = new v.Plane();
i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1), this.pickPoint), this.plane = i;
}
}
handleMouseUp(e) {
this.isDrag = !1, this.pickPoint = null, this.pickNormal = null, this.pickMesh = null, this.engine.controls.enabled = !0;
}
handleMouseMove(e) {
this.meshs.forEach((n) => {
n.material.opacity = 0;
});
const t = e.raycaster.intersectObjects(this.meshs, !1);
if (t != null && t.length > 0 && (t[0].object.material.opacity = 0.05), this.pickPoint != null) {
const n = new v.Vector3();
if (e.raycaster.ray.intersectPlane(this.plane, n)) {
let i = n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());
this.pickMesh.name == "前" || this.pickMesh.name == "左" || this.pickMesh.name == "底" ? this.box.min = this.box_.min.clone().add(this.pickNormal.clone().setLength(i)) : this.box.max = this.box_.max.clone().add(this.pickNormal.clone().setLength(i)), this.updata_face(this.box);
}
}
}
}
class Hl {
engine;
isActive = !1;
box;
pickPoint;
pickNormal;
pickMesh;
box_;
plane;
meshs;
isDrag = !1;
constructor(e) {
this.engine = e, this.meshs = [];
}
active() {
this.isActive = !0, this.init(), this.engine.handelBehaved.init(this), this.engine.handelBehaved.active();
}
disActive() {
this.isActive = !1, this.engine.handelBehaved.disActive();
}
// 初始化
init() {
let e = this.engine.octreeBox.getBoundingBox();
this.box = e, this.updata_face(e);
}
// 获取xyz值
getboxXyz() {
return {
minX: this.box.min.x,
minY: this.box.min.y,
minZ: this.box.min.z,
maxX: this.box.max.x,
maxY: this.box.max.y,
maxZ: this.box.max.z
};
}
setboxXyz(e) {
this.box.min.x = e.minX, this.box.min.y = e.minY, this.box.min.z = e.minZ, this.box.max.x = e.maxX, this.box.max.y = e.maxY, this.box.max.z = e.maxZ, this.updata_face(this.box);
}
// 设置剖切的box
setBox(e) {
this.box = e, this.updata_face(e);
}
// 反向剖切
reverseBox() {
}
// 重写鼠标按下事件
handleMouseDown(e) {
this.isDrag = !0;
const t = e.raycaster.intersectObjects(this.meshs, !1);
if (t != null && t.length > 0)
if (this.pickPoint = t[0].point, this.pickNormal = t[0].face.normal, this.engine.controls.enabled = !1, this.pickMesh = t[0].object, this.box_ = {
min: this.box.min.clone(),
max: this.box.max.clone()
}, this.pickNormal.y == 0) {
const n = new v.Plane();
n.setFromNormalAndCoplanarPoint(new v.Vector3(0, 1, 0), this.pickPoint), this.plane = n;
} else {
let n = new v.Vector3(this.engine.camera.position.x, this.pickPoint.y, this.engine.camera.position.z);
const i = new v.Plane();
i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1), this.pickPoint), this.plane = i;
}
}
handleMouseUp(e) {
this.isDrag = !1, this.pickPoint = null, this.pickNormal = null, this.pickMesh = null, this.engine.controls.enabled = !0;
}
handleMouseMove(e) {
this.meshs.forEach((n) => {
n.material.opacity = 0;
});
const t = e.raycaster.intersectObjects(this.meshs, !1);
if (t != null && t.length > 0 && (t[0].object.material.opacity = 0.05), this.pickPoint != null) {
const n = new v.Vector3();
if (e.raycaster.ray.intersectPlane(this.plane, n)) {
let i = n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());
this.pickMesh.name == "前" || this.pickMesh.name == "左" || this.pickMesh.name == "底" ? this.box.min = this.box_.min.clone().add(this.pickNormal.clone().setLength(i)) : this.box.max = this.box_.max.clone().add(this.pickNormal.clone().setLength(i)), this.updata_face(this.box);
}
}
}
// 更新面
updata_face(e) {
let t = this, n = [
new v.Vector3(e.min.x, e.min.y, e.min.z),
new v.Vector3(e.max.x, e.min.y, e.min.z),
new v.Vector3(e.max.x, e.max.y, e.min.z),
new v.Vector3(e.min.x, e.max.y, e.min.z)
], i = [
new v.Vector3(e.min.x, e.min.y, e.max.z),
new v.Vector3(e.max.x, e.min.y, e.max.z),
new v.Vector3(e.max.x, e.max.y, e.max.z),
new v.Vector3(e.min.x, e.max.y, e.max.z)
], o = [
new v.Vector3(e.max.x, e.min.y, e.max.z),
new v.Vector3(e.max.x, e.min.y, e.min.z),
new v.Vector3(e.max.x, e.max.y, e.min.z),
new v.Vector3(e.max.x, e.max.y, e.max.z)
], s = [
new v.Vector3(e.min.x, e.min.y, e.min.z),
new v.Vector3(e.min.x, e.min.y, e.max.z),
new v.Vector3(e.min.x, e.max.y, e.max.z),
new v.Vector3(e.min.x, e.max.y, e.min.z)
], a = [
new v.Vector3(e.min.x, e.max.y, e.min.z),
new v.Vector3(e.max.x, e.max.y, e.min.z),
new v.Vector3(e.max.x, e.max.y, e.max.z),
new v.Vector3(e.min.x, e.max.y, e.max.z)
], l = [
new v.Vector3(e.min.x, e.min.y, e.min.z),
new v.Vector3(e.max.x, e.min.y, e.min.z),
new v.Vector3(e.max.x, e.min.y, e.max.z),
new v.Vector3(e.min.x, e.min.y, e.max.z)
];
h(n, new v.Vector3(0, 0, -1), "前"), h(i, new v.Vector3(0, 0, 1), "后"), h(o, new v.Vector3(1, 0, 0), "右"), h(s, new v.Vector3(-1, 0, 0), "左"), h(a, new v.Vector3(0, 1, 0), "顶"), h(l, new v.Vector3(0, -1, 0), "底");
function h(u, f, m) {
const p = new v.BufferGeometry(), c = new Float32Array([
u[0].x,
u[0].y,
u[0].z,
// 点1
u[1].x,
u[1].y,
u[1].z,
// 点2
u[2].x,
u[2].y,
u[2].z,
// 点3
u[3].x,
u[3].y,
u[3].z
// 点4
]), d = [
0,
1,
2,
// 第一个三角形
0,
2,
3
// 第二个三角形
];
p.setAttribute("position", new v.BufferAttribute(c, 3)), p.setIndex(d);
let g = t.engine.scene.children.find((C) => C.type == "Group" && C.name == "ClippingBox");
g == null && (g = new v.Group(), g.name = "ClippingBox", t.engine.scene.add(g));
let _ = t.meshs.find((C) => C.name == m);
if (_ == null) {
const C = new v.MeshBasicMaterial({
color: 65280,
// 绿色
transparent: !0,
opacity: 0,
side: v.DoubleSide
// 双面渲染
}), P = new v.Mesh(p, C);
P.normal = f, P.name = m, g.add(P), t.meshs.push(P);
} else
_.geometry = p;
const w = new Float32Array([
u[0].x,
u[0].y,
u[0].z,
// 点1
u[1].x,
u[1].y,
u[1].z,
// 点2
u[2].x,
u[2].y,
u[2].z,
// 点3
u[3].x,
u[3].y,
u[3].z,
// 点4
u[0].x,
u[0].y,
u[0].z
// 点1
]);
let b = new v.LineBasicMaterial({ color: 255 }), T = new v.BufferGeometry();
T.setAttribute("position", new v.BufferAttribute(w, 3));
let M = t.meshs.find((C) => C.name == m + "Line");
M == null && (M = new v.Line(T, b), M.name = m + "Line", g.add(M), t.meshs.push(M)), M.geometry = T, M.material = b, m == "前" || m == "左" || m == "底" ? t.engine.sectionPlane.find((C) => C.name == m).setFromNormalAndCoplanarPoint(f.clone().setLength(-1), e.min) : t.engine.sectionPlane.find((C) => C.name == m).setFromNormalAndCoplanarPoint(f.clone().setLength(-1), e.max), t.engine.scene.children.filter((C) => C.type == "Mesh" && C.url).forEach((C) => {
C.material && Array.isArray(C.material) ? C.material.forEach((P) => {
P.clippingPlanes = t.engine.sectionPlane;
}) : C.material.clippingPlanes = t.engine.sectionPlane;
});
}
}
}
class Gl {
engine;
sectionPlaneX;
sectionPlaneY;
sectionPlaneZ;
sectionBox;
constructor(e) {
this.engine = e, this.sectionPlaneX = new Fl(e), this.sectionPlaneY = new jl(e), this.sectionPlaneZ = new Vl(e), this.sectionBox = new Hl(e);
let t = new v.Plane(new v.Vector3(0, 0, 1), 1e5);
t.name = "前";
let n = new v.Plane(new v.Vector3(0, 0, 1), 1e5);
n.name = "左";
let i = new v.Plane(new v.Vector3(0, 0, 1), 1e5);
i.name = "后";
let o = new v.Plane(new v.Vector3(0, 0, 1), 1e5);
o.name = "右";
let s = new v.Plane(new v.Vector3(0, 0, 1), 1e5);
s.name = "顶";
let a = new v.Plane(new v.Vector3(0, 0, 1), 1e5);
a.name = "底", this.engine.sectionPlane = [t, n, i, o, s, a];
}
disActive() {
this.sectionPlaneX.disActive(), this.sectionPlaneY.disActive(), this.sectionPlaneZ.disActive(), this.sectionBox.disActive();
}
}
class Wl {
engine;
constructor(e) {
this.engine = e;
}
// 获取模型树数据
getTreeData() {
let e = [];
return this.engine.engineStatus.models.forEach((t) => {
e.push({
children: t.info.modelTree.modelTreeLevel,
name: t.info.baseInfo.name
});
}), e;
}
}
class Kl {
engine;
constructor(e) {
this.engine = e;
}
/**
* 获取引擎统计信息
* 统计场景中所有网格的顶点数和三角面数
* @returns 返回包含顶点数和三角面数的对象
*/
getEngineInfo() {
let e = 0, t = 0, n = 0;
return !this.engine || !this.engine.scene ? {
totalVertices: 0,
totalTriangles: 0,
meshCount: 0
} : (this.engine.scene.traverse((i) => {
if (i instanceof v.Mesh) {
const o = i.geometry;
if (o && o.attributes) {
const s = o.attributes.position;
if (s) {
const a = s.count;
e += a;
let l = 0;
o.index ? l = o.index.count / 3 : l = a / 3, t += l, n++;
}
}
}
}), {
totalVertices: Math.floor(e),
totalTriangles: Math.floor(t),
meshCount: n
});
}
}
class Xl {
engine;
constructor(e) {
this.engine = e;
}
init() {
}
// 查询构件属性
getModelProperties(e, t, n) {
let i = this.engine.engineStatus.models.find((s) => s.url === e);
i.properties == null && rs(e + "/property.zip", (s) => {
let a = JSON.parse(s);
i.properties = a, setTimeout(() => {
o(a, t, n);
}, 100);
}), o(i.properties, t, n);
function o(s, a, l) {
let h = [], u = s.models[a.toString() || ""], f = u.map((m) => m[0]);
f = f.filter((m, p) => f.indexOf(m) === p), f.forEach((m) => {
let p = {
name: s.categorys[m],
children: []
};
h.push(p), u.filter((c) => c[0] === m).forEach((c) => {
p.children.push({
name: s.names[c[1]],
value: s.values[c[2]]
});
});
}), l?.({
properties: h,
materials: []
});
}
}
}
class Zl {
engine;
constructor(e) {
this.engine = e;
}
// 获取模型中所有的类型
getModelTypes() {
let e = [];
this.engine.engineStatus.models.forEach((t) => {
t.info.modelMapper.forEach((i) => {
e.push(i.typeName);
});
});
}
// 获取模型中所有的专业
getModelMajors() {
let e = [];
this.engine.engineStatus.models.forEach((t) => {
t.info.modelMapper.forEach((i) => {
e.push(i.majorName);
});
});
}
// 获取模型中所有的楼层
getModelLevels() {
let e = [];
this.engine.engineStatus.models.forEach((t) => {
t.info.modelMapper.forEach((i) => {
e.push(i.levelName);
});
});
}
// 批量获取模型映射
getModelMappers(e) {
}
// 获取模型的mapper
getModelMapper(e, t) {
let n = this.engine.engineStatus.models.find((s) => s.url == e);
return n ? n.info.modelMapper.find((s) => s.id == t) : null;
}
// 获取通类构件
getModelSWithType(e, t) {
let n = [];
return this.engine.engineStatus.models.forEach((i) => {
let o = {
url: i.url,
ids: []
};
n.push(o), i.info.modelMapper.filter((a) => a.typeName === e).forEach((a) => {
o.ids.push(Number(a.id));
});
}), t(n), n;
}
// 获取同层构件
getModelSWithLevel(e, t) {
let n = [];
return this.engine.engineStatus.models.forEach((i) => {
let o = {
url: i.url,
ids: []
};
n.push(o), i.info.modelMapper.filter((a) => a.levelName === e).forEach((a) => {
o.ids.push(Number(a.id));
});
}), t(n), n;
}
// 获取通专业构件
getModelsWithMajor(e, t) {
let n = [];
return this.engine.engineStatus.models.forEach((i) => {
let o = {
url: i.url,
ids: []
};
n.push(o), i.info.modelMapper.filter((a) => a.majorName === e).forEach((a) => {
o.ids.push(Number(a.id));
});
}), t(n), n;
}
}
class ql {
// 引擎参数
options;
DeviceType;
animationId = null;
animate;
// 基础模块
scene;
camera;
renderer;
sceneModule;
cameraModule;
deviceModule;
renderModule;
controlModule;
composerModule;
loaderModule;
engineStatus;
events;
lightModule;
interactionModule;
modelToolModule;
handelBehaved;
octreeBox;
controls;
stats;
// 功能模块
viewCube;
rangeScale;
setting;
measure;
clipping;
modelTree;
engineInfo;
modelProperties;
modelMapperBatch;
// 业务数据
models = [];
// 引擎容器
container;
constructor(e) {
if (this.options = e, this.container = document.getElementById(e.containerId), !this.container)
throw new Error(`Container ${e.containerId} not found`);
this.deviceModule = new cr(this), this.DeviceType = this.deviceModule.getDeviceType(), this.cameraModule = new lr(this), this.sceneModule = new ar(this), this.scene = this.sceneModule.scene, this.renderModule = new hr(this), this.renderer = this.renderModule.createRenderer(), this.camera = this.cameraModule.orthographicCamera, this.scene.camera = this.camera, this.controlModule = new Er(this), this.controlModule.switchDefaultMode(), this.controls = this.controlModule.orbitControls, this.composerModule = new Fr(this), this.composerModule.init(), this.events = new fl(), this.engineStatus = new dl(this), this.engineStatus.init(), this.loaderModule = new ul(this), this.lightModule = new pl(this), this.lightModule.init(), this.viewCube = new Al(this), this.viewCube.init(), this.octreeBox = Cl(this), this.rangeScale = new kl(this), this.rangeScale.init(), this.clipping = new Gl(this), this.setting = new Pl(this), this.setting.init(), this.handelBehaved = _l(this), this.modelMapperBatch = new Zl(this), this.measure = new Ul(this), this.modelToolModule = new gl(this), this.modelProperties = new Xl(this), this.interactionModule = new ml(this), this.interactionModule.init(), this.interactionModule.active(), this.modelTree = new Wl(this), this.engineInfo = new Kl(this), this.stats = new bl(), this.stats.showPanel(0), this.stats.dom.style.position = "absolute", this.stats.dom.style.top = "0px", this.stats.dom.style.left = "0px", this.stats.dom.style.zIndex = "1000", this.container.appendChild(this.stats.dom), this.animate = () => {
this.animationId = requestAnimationFrame(this.animate), this.stats && this.stats.begin(), this.composerModule && this.composerModule.composer.render(), this.viewCube.cubeTool.RenderScene(), this.measure.update(), this.controlModule.update(), this.stats && this.stats.end();
}, this.animate();
}
}
function mc(r) {
return new ql(r);
}
export {
mc as createEngine
};
//# sourceMappingURL=bim-engine-sdk.es.js.map