import * as v from "three"; import { Ray as cs, Plane as hs, MathUtils as bi, Vector3 as pe, Controls as us, MOUSE as ht, TOUCH as lt, Quaternion as qt, Spherical as In, Vector2 as de, Mesh as xi, 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 Ke, DataTexture as Ti, RepeatWrapping as it, MeshNormalMaterial as fs, AddEquation as Dt, ZeroFactor as Lt, DstAlphaFactor as Fn, DstColorFactor as Un, CustomBlending as ps, DepthTexture as ms, DepthStencilFormat as gs, UnsignedInt248Type as _s, NearestFilter as $t, RGBAFormat as ys, UnsignedByteType as ws, AdditiveBlending as bs, MeshBasicMaterial as ct, RawShaderMaterial as xs, 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 Ue, 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 Fs, NearestMipmapNearestFilter as Us, 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 Xs, SkinnedMesh as Ks, LineSegments as Zs, Line as Ys, LineLoop as qs, 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() { this.engine.camera = this.perspectiveCamera; } // 正交相机 switchToOrthographicCamera() { this.engine.camera = this.orthographicCamera; } } 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(), Xn = new hs(), ur = Math.cos(70 * bi.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 qt(), this._lastTargetPosition = new pe(), this._quat = new qt().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 = br.bind(this), this._onTouchMove = xr.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) : (Xn.setFromNormalAndCoplanarPoint(this.object.up, this.target), Ot.intersectPlane(Xn, 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 br(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 xr(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 Kn { 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 Kn(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 Kn( 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 xi(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 Ke() }, cameraProjectionMatrixInverse: { value: new Ke() }, cameraWorldMatrix: { value: new Ke() }, 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 #include #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 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 Ke() }, 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 #include #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, p = (l + h) * u, g = l - p, f = h - p, c = e - g, d = t - f; let m, _; c > d ? (m = 1, _ = 0) : (m = 0, _ = 1); const w = c - m + u, x = 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 + m + this.perm[P + _]] % 12, F = this.perm[C + 1 + this.perm[P + 1]] % 12; let Y = 0.5 - c * c - d * d; Y < 0 ? n = 0 : (Y *= Y, n = Y * Y * this._dot(this.grad3[B], c, d)); let A = 0.5 - w * w - x * x; A < 0 ? i = 0 : (A *= A, i = A * A * this._dot(this.grad3[R], w, x)); let z = 0.5 - T * T - M * M; return z < 0 ? o = 0 : (z *= z, o = z * z * this._dot(this.grad3[F], 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), p = Math.floor(t + h), g = Math.floor(n + h), f = 1 / 6, c = (u + p + g) * f, d = u - c, m = p - c, _ = g - c, w = e - d, x = t - m, T = n - _; let M, C, P, B, R, F; w >= x ? x >= T ? (M = 1, C = 0, P = 0, B = 1, R = 1, F = 0) : w >= T ? (M = 1, C = 0, P = 0, B = 1, R = 0, F = 1) : (M = 0, C = 0, P = 1, B = 1, R = 0, F = 1) : x < T ? (M = 0, C = 0, P = 1, B = 0, R = 1, F = 1) : w < T ? (M = 0, C = 1, P = 0, B = 0, R = 1, F = 1) : (M = 0, C = 1, P = 0, B = 1, R = 1, F = 0); const Y = w - M + f, A = x - C + f, z = T - P + f, b = w - B + 2 * f, U = x - R + 2 * f, J = T - F + 2 * f, G = w - 1 + 3 * f, ne = x - 1 + 3 * f, V = T - 1 + 3 * f, ee = u & 255, O = p & 255, D = g & 255, Q = this.perm[ee + this.perm[O + this.perm[D]]] % 12, q = 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 + F]]] % 12, ue = this.perm[ee + 1 + this.perm[O + 1 + this.perm[D + 1]]] % 12; let fe = 0.6 - w * w - x * x - T * T; fe < 0 ? i = 0 : (fe *= fe, i = fe * fe * this._dot3(this.grad3[Q], w, x, T)); let ie = 0.6 - Y * Y - A * A - z * z; ie < 0 ? o = 0 : (ie *= ie, o = ie * ie * this._dot3(this.grad3[q], Y, A, z)); let oe = 0.6 - b * b - U * U - J * J; oe < 0 ? s = 0 : (oe *= oe, s = oe * oe * this._dot3(this.grad3[Z], b, U, 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, p, g, f, c; const d = (e + t + n + i) * l, m = Math.floor(e + d), _ = Math.floor(t + d), w = Math.floor(n + d), x = Math.floor(i + d), T = (m + _ + w + x) * h, M = m - T, C = _ - T, P = w - T, B = x - T, R = e - M, F = t - C, Y = n - P, A = i - B, z = R > F ? 32 : 0, b = R > Y ? 16 : 0, U = F > Y ? 8 : 0, J = R > A ? 4 : 0, G = F > A ? 2 : 0, ne = Y > A ? 1 : 0, V = z + b + U + 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, q = 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 = F - O + h, y = Y - D + h, j = A - Q + h, I = R - q + 2 * h, E = F - Z + 2 * h, S = Y - ue + 2 * h, k = A - fe + 2 * h, H = R - ie + 3 * h, W = F - oe + 3 * h, L = Y - he + 3 * h, X = A - me + 3 * h, $ = R - 1 + 4 * h, K = F - 1 + 4 * h, te = Y - 1 + 4 * h, le = A - 1 + 4 * h, re = m & 255, we = _ & 255, Pe = w & 255, be = x & 255, Ye = a[re + a[we + a[Pe + a[be]]]] % 32, ge = a[re + ee + a[we + O + a[Pe + D + a[be + Q]]]] % 32, at = a[re + q + a[we + Z + a[Pe + ue + a[be + fe]]]] % 32, bt = a[re + ie + a[we + oe + a[Pe + he + a[be + me]]]] % 32, Re = a[re + 1 + a[we + 1 + a[Pe + 1 + a[be + 1]]]] % 32; let Ge = 0.6 - R * R - F * F - Y * Y - A * A; Ge < 0 ? u = 0 : (Ge *= Ge, u = Ge * Ge * this._dot4(o[Ye], R, F, Y, A)); let qe = 0.6 - Te * Te - ve * ve - y * y - j * j; qe < 0 ? p = 0 : (qe *= qe, p = qe * qe * this._dot4(o[ge], Te, ve, y, j)); let $e = 0.6 - I * I - E * E - S * S - k * k; $e < 0 ? g = 0 : ($e *= $e, g = $e * $e * this._dot4(o[at], I, E, S, k)); let Je = 0.6 - H * H - W * W - L * L - X * X; Je < 0 ? f = 0 : (Je *= Je, f = Je * Je * this._dot4(o[bt], H, W, L, X)); let We = 0.6 - $ * $ - K * K - te * te - le * le; return We < 0 ? c = 0 : (We *= We, c = We * We * this._dot4(o[Re], $, K, te, le)), 27 * (u + p + g + f + 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: Un, blendDst: Lt, blendEquation: Dt, blendSrcAlpha: Fn, 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: Un, blendDst: Lt, blendEquation: Dt, blendSrcAlpha: Fn, 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 p = new ut(o, s, { type: dt }); p.texture.name = "UnrealBloomPass.h" + u, p.texture.generateMipmaps = !1, this.renderTargetsHorizontal.push(p); const g = new ut(o, s, { type: dt }); g.texture.name = "UnrealBloomPass.v" + u, g.texture.generateMipmaps = !1, this.renderTargetsVertical.push(g), 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: bs, 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 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 #include 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 xs({ 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 ); }` ) }, Fr = { 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 Ur { 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(Fr), 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 Ft = 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 Ut(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 Yn; function jr() { return Yn || (Yn = 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 p = typeof Ut == "function" && Ut; if (!u && p) return p(h, !0); if (a) return a(h, !0); var g = new Error("Cannot find module '" + h + "'"); throw g.code = "MODULE_NOT_FOUND", g; } var f = i[h] = { exports: {} }; n[h][0].call(f.exports, function(c) { var d = n[h][1][c]; return s(d || c); }, f, f.exports, t, n, i, o); } return i[h].exports; } for (var a = typeof Ut == "function" && Ut, 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, p, g, f, c, d, m = [], _ = 0, w = l.length, x = w, T = o.getTypeOf(l) !== "string"; _ < l.length; ) x = w - _, p = T ? (h = l[_++], u = _ < w ? l[_++] : 0, _ < w ? l[_++] : 0) : (h = l.charCodeAt(_++), u = _ < w ? l.charCodeAt(_++) : 0, _ < w ? l.charCodeAt(_++) : 0), g = h >> 2, f = (3 & h) << 4 | u >> 4, c = 1 < x ? (15 & u) << 2 | p >> 6 : 64, d = 2 < x ? 63 & p : 64, m.push(a.charAt(g) + a.charAt(f) + a.charAt(c) + a.charAt(d)); return m.join(""); }, i.decode = function(l) { var h, u, p, g, f, c, d = 0, m = 0, _ = "data:"; if (l.substr(0, _.length) === _) throw new Error("Invalid base64 input, it looks like a data url."); var w, x = 3 * (l = l.replace(/[^A-Za-z0-9+/=]/g, "")).length / 4; if (l.charAt(l.length - 1) === a.charAt(64) && x--, l.charAt(l.length - 2) === a.charAt(64) && x--, x % 1 != 0) throw new Error("Invalid base64 input, bad content length."); for (w = s.uint8array ? new Uint8Array(0 | x) : new Array(0 | x); d < l.length; ) h = a.indexOf(l.charAt(d++)) << 2 | (g = a.indexOf(l.charAt(d++))) >> 4, u = (15 & g) << 4 | (f = a.indexOf(l.charAt(d++))) >> 2, p = (3 & f) << 6 | (c = a.indexOf(l.charAt(d++))), w[m++] = h, f !== 64 && (w[m++] = u), c !== 64 && (w[m++] = p); 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, p, g, f, c) { this.compressedSize = u, this.uncompressedSize = p, this.crc32 = g, this.compression = f, 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")), p = this; return u.on("end", function() { if (this.streamInfo.data_length !== p.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, p, g) { return u.pipe(new a()).pipe(new l("uncompressedSize")).pipe(p.compressWorker(g)).pipe(new l("compressedSize")).withStreamInfo("compression", p); }, 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, p, g) { var f = s, c = g + p; h ^= -1; for (var d = g; d < c; d++) h = h >>> 8 ^ f[255 & (h ^ u[d])]; return -1 ^ h; })(0 | l, a, a.length, 0) : (function(h, u, p, g) { var f = s, c = g + p; h ^= -1; for (var d = g; d < c; d++) h = h >>> 8 ^ f[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(p, g) { l.call(this, "FlateWorker/" + p), this._pako = null, this._pakoAction = p, this._pakoOptions = g, this.meta = {}; } i.magic = "\b\0", a.inherits(u, l), u.prototype.processChunk = function(p) { this.meta = p.meta, this._pako === null && this._createPako(), this._pako.push(a.transformTo(h, p.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 p = this; this._pako.onData = function(g) { p.push({ data: g, meta: p.meta }); }; }, i.compressWorker = function(p) { return new u("Deflate", p); }, i.uncompressWorker = function() { return new u("Inflate", {}); }; }, { "./stream/GenericWorker": 28, "./utils": 32, pako: 38 }], 8: [function(t, n, i) { function o(f, c) { var d, m = ""; for (d = 0; d < c; d++) m += String.fromCharCode(255 & f), f >>>= 8; return m; } function s(f, c, d, m, _, w) { var x, T, M = f.file, C = f.compression, P = w !== h.utf8encode, B = a.transformTo("string", w(M.name)), R = a.transformTo("string", h.utf8encode(M.name)), F = M.comment, Y = a.transformTo("string", w(F)), A = a.transformTo("string", h.utf8encode(F)), z = R.length !== M.name.length, b = A.length !== F.length, U = "", J = "", G = "", ne = M.dir, V = M.date, ee = { crc32: 0, compressedSize: 0, uncompressedSize: 0 }; c && !d || (ee.crc32 = f.crc32, ee.compressedSize = f.compressedSize, ee.uncompressedSize = f.uncompressedSize); var O = 0; c && (O |= 8), P || !z && !b || (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)), x = V.getUTCHours(), x <<= 6, x |= V.getUTCMinutes(), x <<= 5, x |= 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, U += "up" + o(J.length, 2) + J), b && (G = o(1, 1) + o(u(Y), 4) + A, U += "uc" + o(G.length, 2) + G); var q = ""; return q += ` \0`, q += o(O, 2), q += C.magic, q += o(x, 2), q += o(T, 2), q += o(ee.crc32, 4), q += o(ee.compressedSize, 4), q += o(ee.uncompressedSize, 4), q += o(B.length, 2), q += o(U.length, 2), { fileRecord: p.LOCAL_FILE_HEADER + q + B + U, dirRecord: p.CENTRAL_FILE_HEADER + o(Q, 2) + q + o(Y.length, 2) + "\0\0\0\0" + o(D, 4) + o(m, 4) + B + U + Y }; } var a = t("../utils"), l = t("../stream/GenericWorker"), h = t("../utf8"), u = t("../crc32"), p = t("../signature"); function g(f, c, d, m) { l.call(this, "ZipFileWorker"), this.bytesWritten = 0, this.zipComment = c, this.zipPlatform = d, this.encodeFileName = m, this.streamFiles = f, this.accumulate = !1, this.contentBuffer = [], this.dirRecords = [], this.currentSourceOffset = 0, this.entriesCount = 0, this.currentFile = null, this._sources = []; } a.inherits(g, l), g.prototype.push = function(f) { var c = f.meta.percent || 0, d = this.entriesCount, m = this._sources.length; this.accumulate ? this.contentBuffer.push(f) : (this.bytesWritten += f.data.length, l.prototype.push.call(this, { data: f.data, meta: { currentFile: this.currentFile, percent: d ? (c + 100 * (d - m - 1)) / d : 100 } })); }, g.prototype.openedSource = function(f) { this.currentSourceOffset = this.bytesWritten, this.currentFile = f.file.name; var c = this.streamFiles && !f.file.dir; if (c) { var d = s(f, c, !1, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); this.push({ data: d.fileRecord, meta: { percent: 0 } }); } else this.accumulate = !0; }, g.prototype.closedSource = function(f) { this.accumulate = !1; var c = this.streamFiles && !f.file.dir, d = s(f, c, !0, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); if (this.dirRecords.push(d.dirRecord), c) this.push({ data: (function(m) { return p.DATA_DESCRIPTOR + o(m.crc32, 4) + o(m.compressedSize, 4) + o(m.uncompressedSize, 4); })(f), meta: { percent: 100 } }); else for (this.push({ data: d.fileRecord, meta: { percent: 0 } }); this.contentBuffer.length; ) this.push(this.contentBuffer.shift()); this.currentFile = null; }, g.prototype.flush = function() { for (var f = this.bytesWritten, c = 0; c < this.dirRecords.length; c++) this.push({ data: this.dirRecords[c], meta: { percent: 100 } }); var d = this.bytesWritten - f, m = (function(_, w, x, T, M) { var C = a.transformTo("string", M(T)); return p.CENTRAL_DIRECTORY_END + "\0\0\0\0" + o(_, 2) + o(_, 2) + o(w, 4) + o(x, 4) + o(C.length, 2) + C; })(this.dirRecords.length, d, f, this.zipComment, this.encodeFileName); this.push({ data: m, meta: { percent: 100 } }); }, g.prototype.prepareNextSource = function() { this.previous = this._sources.shift(), this.openedSource(this.previous.streamInfo), this.isPaused ? this.previous.pause() : this.previous.resume(); }, g.prototype.registerPrevious = function(f) { this._sources.push(f); var c = this; return f.on("data", function(d) { c.processChunk(d); }), f.on("end", function() { c.closedSource(c.previous.streamInfo), c._sources.length ? c.prepareNextSource() : c.end(); }), f.on("error", function(d) { c.error(d); }), this; }, g.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)); }, g.prototype.error = function(f) { var c = this._sources; if (!l.prototype.error.call(this, f)) return !1; for (var d = 0; d < c.length; d++) try { c[d].error(f); } catch { } return !0; }, g.prototype.lock = function() { l.prototype.lock.call(this); for (var f = this._sources, c = 0; c < f.length; c++) f[c].lock(); }, n.exports = g; }, { "../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), p = 0; try { a.forEach(function(g, f) { p++; var c = (function(w, x) { var T = w || x, M = o[T]; if (!M) throw new Error(T + " is not a valid compression method !"); return M; })(f.options.compression, l.compression), d = f.options.compressionOptions || l.compressionOptions || {}, m = f.dir, _ = f.date; f._compressWorker(c, d).withStreamInfo("file", { name: g, dir: m, date: _, comment: f.comment || "", unixPermissions: f.unixPermissions, dosPermissions: f.dosPermissions }).pipe(u); }), u.entriesCount = p; } catch (g) { u.error(g); } 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 p(g) { return new s.Promise(function(f, c) { var d = g.decompressed.getContentWorker().pipe(new h()); d.on("error", function(m) { c(m); }).on("end", function() { d.streamInfo.crc32 !== g.decompressed.crc32 ? c(new Error("Corrupted zip : CRC32 mismatch")) : f(); }).resume(); }); } n.exports = function(g, f) { var c = this; return f = o.extend(f || {}, { base64: !1, checkCRC32: !1, optimizedBinaryString: !1, createFolders: !1, decodeFileName: a.utf8decode }), u.isNode && u.isStream(g) ? s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")) : o.prepareContent("the loaded zip file", g, !0, f.optimizedBinaryString, f.base64).then(function(d) { var m = new l(f); return m.load(d), m; }).then(function(d) { var m = [s.Promise.resolve(d)], _ = d.files; if (f.checkCRC32) for (var w = 0; w < _.length; w++) m.push(p(_[w])); return s.Promise.all(m); }).then(function(d) { for (var m = d.shift(), _ = m.files, w = 0; w < _.length; w++) { var x = _[w], T = x.fileNameStr, M = o.resolve(x.fileNameStr); c.file(M, x.decompressed, { binary: !0, optimizedBinaryString: !0, date: x.date, dir: x.dir, comment: x.fileCommentStr.length ? x.fileCommentStr : null, unixPermissions: x.unixPermissions, dosPermissions: x.dosPermissions, createFolders: f.createFolders }), x.dir || (c.file(M).unsafeOriginalName = T); } return m.zipComment.length && (c.comment = m.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(p, g) { u.push(p) || u._helper.pause(), h && h(g); }).on("error", function(p) { u.emit("error", p); }).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), F = a.extend(P || {}, u); F.date = F.date || /* @__PURE__ */ new Date(), F.compression !== null && (F.compression = F.compression.toUpperCase()), typeof F.unixPermissions == "string" && (F.unixPermissions = parseInt(F.unixPermissions, 8)), F.unixPermissions && 16384 & F.unixPermissions && (F.dir = !0), F.dosPermissions && 16 & F.dosPermissions && (F.dir = !0), F.dir && (M = _(M)), F.createFolders && (B = m(M)) && w.call(this, B, !0); var Y = R === "string" && F.binary === !1 && F.base64 === !1; P && P.binary !== void 0 || (F.binary = !Y), (C instanceof p && C.uncompressedSize === 0 || F.dir || !C || C.length === 0) && (F.base64 = !1, F.binary = !0, C = "", F.compression = "STORE", R = "string"); var A = null; A = C instanceof p || C instanceof l ? C : c.isNode && c.isStream(C) ? new d(M, C) : a.prepareContent(M, C, F.binary, F.optimizedBinaryString, F.base64); var z = new g(M, A, F); this.files[M] = z; } var s = t("./utf8"), a = t("./utils"), l = t("./stream/GenericWorker"), h = t("./stream/StreamHelper"), u = t("./defaults"), p = t("./compressedObject"), g = t("./zipObject"), f = t("./generate"), c = t("./nodejsUtils"), d = t("./nodejs/NodejsStreamInputAdapter"), m = 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 x(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 (x(M)) { var B = M; return this.filter(function(F, Y) { return !Y.dir && B.test(F); }); } var R = this.files[this.root + M]; return R && !R.dir ? R : null; }, folder: function(M) { if (!M) return this; if (x(M)) return this.filter(function(R, F) { return F.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, F) { return F.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 = f.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), p = a.charCodeAt(3), g = this.length - 4; 0 <= g; --g) if (this.data[g] === l && this.data[g + 1] === h && this.data[g + 2] === u && this.data[g + 3] === p) return g - this.zero; return -1; }, s.prototype.readAndCheckSignature = function(a) { var l = a.charCodeAt(0), h = a.charCodeAt(1), u = a.charCodeAt(2), p = a.charCodeAt(3), g = this.readData(4); return l === g[0] && h === g[1] && u === g[2] && p === g[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(p) { var g = o.getTypeOf(p); return o.checkSupport(g), g !== "string" || s.uint8array ? g === "nodebuffer" ? new h(p) : s.uint8array ? new u(o.transformTo("uint8array", p)) : new a(o.transformTo("array", p)) : new l(p); }; }, { "../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"), p = null; if (h.nodestream) try { p = t("../nodejs/NodejsStreamOutputAdapter"); } catch { } function g(c, d) { return new u.Promise(function(m, _) { var w = [], x = 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, F = 0, Y = 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 (Y = new Uint8Array(A), R = 0; R < B.length; R++) Y.set(B[R], F), F += B[R].length; return Y; case "nodebuffer": return Buffer.concat(B); default: throw new Error("concat : unsupported type '" + P + "'"); } })(x, w), M); m(C); } catch (P) { _(P); } w = []; }).resume(); }); } function f(c, d, m) { var _ = d; switch (d) { case "blob": case "arraybuffer": _ = "uint8array"; break; case "base64": _ = "string"; } try { this._internalType = _, this._outputType = d, this._mimeType = m, o.checkSupport(_), this._worker = c.pipe(new s(_)), c.lock(); } catch (w) { this._worker = new a("error"), this._worker.error(w); } } f.prototype = { accumulate: function(c) { return g(this, c); }, on: function(c, d) { var m = this; return c === "data" ? this._worker.on(c, function(_) { d.call(m, _.data, _.meta); }) : this._worker.on(c, function() { o.delay(d, arguments, m); }), 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 p(this, { objectMode: this._outputType !== "nodebuffer" }, c); } }, n.exports = f; }, { "../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 p() { l.call(this, "utf-8 decode"), this.leftOver = null; } function g() { l.call(this, "utf-8 encode"); } i.utf8encode = function(f) { return s.nodebuffer ? a.newBufferFrom(f, "utf-8") : (function(c) { var d, m, _, w, x, T = c.length, M = 0; for (w = 0; w < T; w++) (64512 & (m = c.charCodeAt(w))) == 55296 && w + 1 < T && (64512 & (_ = c.charCodeAt(w + 1))) == 56320 && (m = 65536 + (m - 55296 << 10) + (_ - 56320), w++), M += m < 128 ? 1 : m < 2048 ? 2 : m < 65536 ? 3 : 4; for (d = s.uint8array ? new Uint8Array(M) : new Array(M), w = x = 0; x < M; w++) (64512 & (m = c.charCodeAt(w))) == 55296 && w + 1 < T && (64512 & (_ = c.charCodeAt(w + 1))) == 56320 && (m = 65536 + (m - 55296 << 10) + (_ - 56320), w++), m < 128 ? d[x++] = m : (m < 2048 ? d[x++] = 192 | m >>> 6 : (m < 65536 ? d[x++] = 224 | m >>> 12 : (d[x++] = 240 | m >>> 18, d[x++] = 128 | m >>> 12 & 63), d[x++] = 128 | m >>> 6 & 63), d[x++] = 128 | 63 & m); return d; })(f); }, i.utf8decode = function(f) { return s.nodebuffer ? o.transformTo("nodebuffer", f).toString("utf-8") : (function(c) { var d, m, _, w, x = c.length, T = new Array(2 * x); for (d = m = 0; d < x; ) if ((_ = c[d++]) < 128) T[m++] = _; else if (4 < (w = h[_])) T[m++] = 65533, d += w - 1; else { for (_ &= w === 2 ? 31 : w === 3 ? 15 : 7; 1 < w && d < x; ) _ = _ << 6 | 63 & c[d++], w--; 1 < w ? T[m++] = 65533 : _ < 65536 ? T[m++] = _ : (_ -= 65536, T[m++] = 55296 | _ >> 10 & 1023, T[m++] = 56320 | 1023 & _); } return T.length !== m && (T.subarray ? T = T.subarray(0, m) : T.length = m), o.applyFromCharCode(T); })(f = o.transformTo(s.uint8array ? "uint8array" : "array", f)); }, o.inherits(p, l), p.prototype.processChunk = function(f) { var c = o.transformTo(s.uint8array ? "uint8array" : "array", f.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 m = (function(w, x) { var T; for ((x = x || w.length) > w.length && (x = w.length), T = x - 1; 0 <= T && (192 & w[T]) == 128; ) T--; return T < 0 || T === 0 ? x : T + h[w[T]] > x ? T : x; })(c), _ = c; m !== c.length && (s.uint8array ? (_ = c.subarray(0, m), this.leftOver = c.subarray(m, c.length)) : (_ = c.slice(0, m), this.leftOver = c.slice(m, c.length))), this.push({ data: i.utf8decode(_), meta: f.meta }); }, p.prototype.flush = function() { this.leftOver && this.leftOver.length && (this.push({ data: i.utf8decode(this.leftOver), meta: {} }), this.leftOver = null); }, i.Utf8DecodeWorker = p, o.inherits(g, l), g.prototype.processChunk = function(f) { this.push({ data: i.utf8encode(f.data), meta: f.meta }); }, i.Utf8EncodeWorker = g; }, { "./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, m) { for (var _ = 0; _ < d.length; ++_) m[_] = 255 & d.charCodeAt(_); return m; } t("setimmediate"), i.newBlob = function(d, m) { i.checkSupport("blob"); try { return new Blob([d], { type: m }); } catch { try { var _ = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)(); return _.append(d), _.getBlob(m); } catch { throw new Error("Bug : can't construct the Blob."); } } }; var p = { stringifyByChunk: function(d, m, _) { var w = [], x = 0, T = d.length; if (T <= _) return String.fromCharCode.apply(null, d); for (; x < T; ) m === "array" || m === "nodebuffer" ? w.push(String.fromCharCode.apply(null, d.slice(x, Math.min(x + _, T)))) : w.push(String.fromCharCode.apply(null, d.subarray(x, Math.min(x + _, T)))), x += _; return w.join(""); }, stringifyByChar: function(d) { for (var m = "", _ = 0; _ < d.length; _++) m += String.fromCharCode(d[_]); return m; }, 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 g(d) { var m = 65536, _ = i.getTypeOf(d), w = !0; if (_ === "uint8array" ? w = p.applyCanBeUsed.uint8array : _ === "nodebuffer" && (w = p.applyCanBeUsed.nodebuffer), w) for (; 1 < m; ) try { return p.stringifyByChunk(d, _, m); } catch { m = Math.floor(m / 2); } return p.stringifyByChar(d); } function f(d, m) { for (var _ = 0; _ < d.length; _++) m[_] = d[_]; return m; } i.applyFromCharCode = g; 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: g, 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 g(new Uint8Array(d)); }, array: function(d) { return f(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: g, array: function(d) { return f(d, new Array(d.length)); }, arraybuffer: function(d) { return d.buffer; }, uint8array: h, nodebuffer: function(d) { return a.newBufferFrom(d); } }, c.nodebuffer = { string: g, array: function(d) { return f(d, new Array(d.length)); }, arraybuffer: function(d) { return c.nodebuffer.uint8array(d).buffer; }, uint8array: function(d) { return f(d, new Uint8Array(d.length)); }, nodebuffer: h }, i.transformTo = function(d, m) { if (m = m || "", !d) return m; i.checkSupport(d); var _ = i.getTypeOf(m); return c[_][d](m); }, i.resolve = function(d) { for (var m = d.split("/"), _ = [], w = 0; w < m.length; w++) { var x = m[w]; x === "." || x === "" && w !== 0 && w !== m.length - 1 || (x === ".." ? _.pop() : _.push(x)); } 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 m, _, w = ""; for (_ = 0; _ < (d || "").length; _++) w += "\\x" + ((m = d.charCodeAt(_)) < 16 ? "0" : "") + m.toString(16).toUpperCase(); return w; }, i.delay = function(d, m, _) { setImmediate(function() { d.apply(_ || null, m || []); }); }, i.inherits = function(d, m) { function _() { } _.prototype = m.prototype, d.prototype = new _(); }, i.extend = function() { var d, m, _ = {}; for (d = 0; d < arguments.length; d++) for (m in arguments[d]) Object.prototype.hasOwnProperty.call(arguments[d], m) && _[m] === void 0 && (_[m] = arguments[d][m]); return _; }, i.prepareContent = function(d, m, _, w, x) { return l.Promise.resolve(m).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" && (x ? 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(p) { this.files = [], this.loadOptions = p; } u.prototype = { checkSignature: function(p) { if (!this.reader.readAndCheckSignature(p)) { this.reader.index -= 4; var g = this.reader.readString(4); throw new Error("Corrupted zip or bug: unexpected signature (" + s.pretty(g) + ", expected " + s.pretty(p) + ")"); } }, isSignature: function(p, g) { var f = this.reader.index; this.reader.setIndex(p); var c = this.reader.readString(4) === g; return this.reader.setIndex(f), 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 p = this.reader.readData(this.zipCommentLength), g = h.uint8array ? "uint8array" : "array", f = s.transformTo(g, p); this.zipComment = this.loadOptions.decodeFileName(f); }, 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 p, g, f, c = this.zip64EndOfCentralSize - 44; 0 < c; ) p = this.reader.readInt(2), g = this.reader.readInt(4), f = this.reader.readData(g), this.zip64ExtensibleData[p] = { id: p, length: g, value: f }; }, 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 p, g; for (p = 0; p < this.files.length; p++) g = this.files[p], this.reader.setIndex(g.localHeaderOffset), this.checkSignature(a.LOCAL_FILE_HEADER), g.readLocalPart(this.reader), g.handleUTF8(), g.processAttributes(); }, readCentralDir: function() { var p; for (this.reader.setIndex(this.centralDirOffset); this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER); ) (p = new l({ zip64: this.zip64 }, this.loadOptions)).readCentralPart(this.reader), this.files.push(p); 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 p = this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END); if (p < 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(p); var g = p; 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, (p = 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(p), 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 f = this.centralDirOffset + this.centralDirSize; this.zip64 && (f += 20, f += 12 + this.zip64EndOfCentralSize); var c = g - f; if (0 < c) this.isSignature(g, a.CENTRAL_FILE_HEADER) || (this.reader.zero = c); else if (c < 0) throw new Error("Corrupted zip: missing " + Math.abs(c) + " bytes."); }, prepareReader: function(p) { this.reader = o(p); }, load: function(p) { this.prepareReader(p), 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"), p = t("./support"); function g(f, c) { this.options = f, this.loadOptions = c; } g.prototype = { isEncrypted: function() { return (1 & this.bitFlag) == 1; }, useUTF8: function() { return (2048 & this.bitFlag) == 2048; }, readLocalPart: function(f) { var c, d; if (f.skip(22), this.fileNameLength = f.readInt(2), d = f.readInt(2), this.fileName = f.readData(this.fileNameLength), f.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(m) { for (var _ in u) if (Object.prototype.hasOwnProperty.call(u, _) && u[_].magic === m) 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, f.readData(this.compressedSize)); }, readCentralPart: function(f) { this.versionMadeBy = f.readInt(2), f.skip(2), this.bitFlag = f.readInt(2), this.compressionMethod = f.readString(2), this.date = f.readDate(), this.crc32 = f.readInt(4), this.compressedSize = f.readInt(4), this.uncompressedSize = f.readInt(4); var c = f.readInt(2); if (this.extraFieldsLength = f.readInt(2), this.fileCommentLength = f.readInt(2), this.diskNumberStart = f.readInt(2), this.internalFileAttributes = f.readInt(2), this.externalFileAttributes = f.readInt(4), this.localHeaderOffset = f.readInt(4), this.isEncrypted()) throw new Error("Encrypted zip are not supported"); f.skip(c), this.readExtraFields(f), this.parseZIP64ExtraField(f), this.fileComment = f.readData(this.fileCommentLength); }, processAttributes: function() { this.unixPermissions = null, this.dosPermissions = null; var f = this.versionMadeBy >> 8; this.dir = !!(16 & this.externalFileAttributes), f == 0 && (this.dosPermissions = 63 & this.externalFileAttributes), f == 3 && (this.unixPermissions = this.externalFileAttributes >> 16 & 65535), this.dir || this.fileNameStr.slice(-1) !== "/" || (this.dir = !0); }, parseZIP64ExtraField: function() { if (this.extraFields[1]) { var f = o(this.extraFields[1].value); this.uncompressedSize === s.MAX_VALUE_32BITS && (this.uncompressedSize = f.readInt(8)), this.compressedSize === s.MAX_VALUE_32BITS && (this.compressedSize = f.readInt(8)), this.localHeaderOffset === s.MAX_VALUE_32BITS && (this.localHeaderOffset = f.readInt(8)), this.diskNumberStart === s.MAX_VALUE_32BITS && (this.diskNumberStart = f.readInt(4)); } }, readExtraFields: function(f) { var c, d, m, _ = f.index + this.extraFieldsLength; for (this.extraFields || (this.extraFields = {}); f.index + 4 < _; ) c = f.readInt(2), d = f.readInt(2), m = f.readData(d), this.extraFields[c] = { id: c, length: d, value: m }; f.setIndex(_); }, handleUTF8: function() { var f = p.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(f, this.fileName); this.fileNameStr = this.loadOptions.decodeFileName(d); } var m = this.findExtraFieldUnicodeComment(); if (m !== null) this.fileCommentStr = m; else { var _ = s.transformTo(f, this.fileComment); this.fileCommentStr = this.loadOptions.decodeFileName(_); } } }, findExtraFieldUnicodePath: function() { var f = this.extraFields[28789]; if (f) { var c = o(f.value); return c.readInt(1) !== 1 || l(this.fileName) !== c.readInt(4) ? null : h.utf8decode(c.readData(f.length - 5)); } return null; }, findExtraFieldUnicodeComment: function() { var f = this.extraFields[25461]; if (f) { var c = o(f.value); return c.readInt(1) !== 1 || l(this.fileComment) !== c.readInt(4) ? null : h.utf8decode(c.readData(f.length - 5)); } return null; } }, n.exports = g; }, { "./compressedObject": 2, "./compressions": 3, "./crc32": 4, "./reader/readerFor": 22, "./support": 30, "./utf8": 31, "./utils": 32 }], 35: [function(t, n, i) { function o(c, d, m) { this.name = c, this.dir = m.dir, this.date = m.date, this.comment = m.comment, this.unixPermissions = m.unixPermissions, this.dosPermissions = m.dosPermissions, this._data = d, this._dataBinary = m.binary, this.options = { compression: m.compression, compressionOptions: m.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, m = "string"; try { if (!c) throw new Error("No output type specified."); var _ = (m = c.toLowerCase()) === "string" || m === "text"; m !== "binarystring" && m !== "text" || (m = "string"), d = this._decompressWorker(); var w = !this._dataBinary; w && !_ && (d = d.pipe(new l.Utf8EncodeWorker())), !w && _ && (d = d.pipe(new l.Utf8DecodeWorker())); } catch (x) { (d = new u("error")).error(x); } return new s(d, m, ""); }, 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 m = this._decompressWorker(); return this._dataBinary || (m = m.pipe(new l.Utf8EncodeWorker())), h.createWorkerFrom(m, c, d); }, _decompressWorker: function() { return this._data instanceof h ? this._data.getContentWorker() : this._data instanceof u ? this._data : new a(this._data); } }; for (var p = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"], g = function() { throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); }, f = 0; f < p.length; f++) o.prototype[p[f]] = g; 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), p = o.document.createTextNode(""); u.observe(p, { characterData: !0 }), s = function() { p.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 g = new o.MessageChannel(); g.port1.onmessage = c, s = function() { g.port2.postMessage(0); }; } var f = []; function c() { var d, m; a = !0; for (var _ = f.length; _; ) { for (m = f, f = [], d = -1; ++d < _; ) m[d](); _ = f.length; } a = !1; } n.exports = function(d) { f.push(d) !== 1 || a || s(); }; }).call(this, typeof Ft < "u" ? Ft : 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 p(_) { if (typeof _ != "function") throw new TypeError("resolver must be a function"); this.state = u, this.queue = [], this.outcome = void 0, _ !== s && d(this, _); } function g(_, w, x) { this.promise = _, typeof w == "function" && (this.onFulfilled = w, this.callFulfilled = this.otherCallFulfilled), typeof x == "function" && (this.onRejected = x, this.callRejected = this.otherCallRejected); } function f(_, w, x) { o(function() { var T; try { T = w(x); } 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 x = !1; function T(P) { x || (x = !0, a.reject(_, P)); } function M(P) { x || (x = !0, a.resolve(_, P)); } var C = m(function() { w(M, T); }); C.status === "error" && T(C.value); } function m(_, w) { var x = {}; try { x.value = _(w), x.status = "success"; } catch (T) { x.status = "error", x.value = T; } return x; } (n.exports = p).prototype.finally = function(_) { if (typeof _ != "function") return this; var w = this.constructor; return this.then(function(x) { return w.resolve(_()).then(function() { return x; }); }, function(x) { return w.resolve(_()).then(function() { throw x; }); }); }, p.prototype.catch = function(_) { return this.then(null, _); }, p.prototype.then = function(_, w) { if (typeof _ != "function" && this.state === h || typeof w != "function" && this.state === l) return this; var x = new this.constructor(s); return this.state !== u ? f(x, this.state === h ? _ : w, this.outcome) : this.queue.push(new g(x, _, w)), x; }, g.prototype.callFulfilled = function(_) { a.resolve(this.promise, _); }, g.prototype.otherCallFulfilled = function(_) { f(this.promise, this.onFulfilled, _); }, g.prototype.callRejected = function(_) { a.reject(this.promise, _); }, g.prototype.otherCallRejected = function(_) { f(this.promise, this.onRejected, _); }, a.resolve = function(_, w) { var x = m(c, w); if (x.status === "error") return a.reject(_, x.value); var T = x.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 x = -1, T = _.queue.length; ++x < T; ) _.queue[x].callRejected(w); return _; }, p.resolve = function(_) { return _ instanceof this ? _ : a.resolve(new this(s), _); }, p.reject = function(_) { var w = new this(s); return a.reject(w, _); }, p.all = function(_) { var w = this; if (Object.prototype.toString.call(_) !== "[object Array]") return this.reject(new TypeError("must be an array")); var x = _.length, T = !1; if (!x) return this.resolve([]); for (var M = new Array(x), C = 0, P = -1, B = new this(s); ++P < x; ) R(_[P], P); return B; function R(F, Y) { w.resolve(F).then(function(A) { M[Y] = A, ++C !== x || T || (T = !0, a.resolve(B, M)); }, function(A) { T || (T = !0, a.reject(B, A)); }); } }, p.race = function(_) { var w = this; if (Object.prototype.toString.call(_) !== "[object Array]") return this.reject(new TypeError("must be an array")); var x = _.length, T = !1; if (!x) return this.resolve([]); for (var M = -1, C = new this(s); ++M < x; ) 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, p = 0, g = -1, f = 0, c = 8; function d(_) { if (!(this instanceof d)) return new d(_); this.options = s.assign({ level: g, method: c, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: f, 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 x = o.deflateInit2(this.strm, w.level, w.method, w.windowBits, w.memLevel, w.strategy); if (x !== p) throw new Error(l[x]); 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, (x = o.deflateSetDictionary(this.strm, T)) !== p) throw new Error(l[x]); this._dict_set = !0; } } function m(_, w) { var x = new d(w); if (x.push(_, !0), x.err) throw x.msg || l[x.err]; return x.result; } d.prototype.push = function(_, w) { var x, 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), (x = o.deflate(M, T)) !== 1 && x !== p) return this.onEnd(x), !(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) && x !== 1); return T === 4 ? (x = o.deflateEnd(this.strm), this.onEnd(x), this.ended = !0, x === p) : T !== 2 || (this.onEnd(p), !(M.avail_out = 0)); }, d.prototype.onData = function(_) { this.chunks.push(_); }, d.prototype.onEnd = function(_) { _ === p && (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 = m, i.deflateRaw = function(_, w) { return (w = w || {}).raw = !0, m(_, w); }, i.gzip = function(_, w) { return (w = w || {}).gzip = !0, m(_, 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"), p = t("./zlib/gzheader"), g = Object.prototype.toString; function f(d) { if (!(this instanceof f)) return new f(d); this.options = s.assign({ chunkSize: 16384, windowBits: 0, to: "" }, d || {}); var m = this.options; m.raw && 0 <= m.windowBits && m.windowBits < 16 && (m.windowBits = -m.windowBits, m.windowBits === 0 && (m.windowBits = -15)), !(0 <= m.windowBits && m.windowBits < 16) || d && d.windowBits || (m.windowBits += 32), 15 < m.windowBits && m.windowBits < 48 && (15 & m.windowBits) == 0 && (m.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, m.windowBits); if (_ !== l.Z_OK) throw new Error(h[_]); this.header = new p(), o.inflateGetHeader(this.strm, this.header); } function c(d, m) { var _ = new f(m); if (_.push(d, !0), _.err) throw _.msg || h[_.err]; return _.result; } f.prototype.push = function(d, m) { var _, w, x, T, M, C, P = this.strm, B = this.options.chunkSize, R = this.options.dictionary, F = !1; if (this.ended) return !1; w = m === ~~m ? m : m === !0 ? l.Z_FINISH : l.Z_NO_FLUSH, typeof d == "string" ? P.input = a.binstring2buf(d) : g.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) : g.call(R) === "[object ArrayBuffer]" ? new Uint8Array(R) : R, _ = o.inflateSetDictionary(this.strm, C)), _ === l.Z_BUF_ERROR && F === !0 && (_ = l.Z_OK, F = !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" ? (x = a.utf8border(P.output, P.next_out), T = P.next_out - x, M = a.buf2string(P.output, x), P.next_out = T, P.avail_out = B - T, T && s.arraySet(P.output, P.output, x, T, 0), this.onData(M)) : this.onData(s.shrinkBuf(P.output, P.next_out)))), P.avail_in === 0 && P.avail_out === 0 && (F = !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)); }, f.prototype.onData = function(d) { this.chunks.push(d); }, f.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 = f, i.inflate = c, i.inflateRaw = function(d, m) { return (m = m || {}).raw = !0, c(d, m); }, 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 p in u) u.hasOwnProperty(p) && (l[p] = u[p]); } } 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, p, g) { if (h.subarray && l.subarray) l.set(h.subarray(u, u + p), g); else for (var f = 0; f < p; f++) l[g + f] = h[u + f]; }, flattenChunks: function(l) { var h, u, p, g, f, c; for (h = p = 0, u = l.length; h < u; h++) p += l[h].length; for (c = new Uint8Array(p), h = g = 0, u = l.length; h < u; h++) f = l[h], c.set(f, g), g += f.length; return c; } }, a = { arraySet: function(l, h, u, p, g) { for (var f = 0; f < p; f++) l[g + f] = h[u + f]; }, 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(p, g) { if (g < 65537 && (p.subarray && a || !p.subarray && s)) return String.fromCharCode.apply(null, o.shrinkBuf(p, g)); for (var f = "", c = 0; c < g; c++) f += String.fromCharCode(p[c]); return f; } l[254] = l[254] = 1, i.string2buf = function(p) { var g, f, c, d, m, _ = p.length, w = 0; for (d = 0; d < _; d++) (64512 & (f = p.charCodeAt(d))) == 55296 && d + 1 < _ && (64512 & (c = p.charCodeAt(d + 1))) == 56320 && (f = 65536 + (f - 55296 << 10) + (c - 56320), d++), w += f < 128 ? 1 : f < 2048 ? 2 : f < 65536 ? 3 : 4; for (g = new o.Buf8(w), d = m = 0; m < w; d++) (64512 & (f = p.charCodeAt(d))) == 55296 && d + 1 < _ && (64512 & (c = p.charCodeAt(d + 1))) == 56320 && (f = 65536 + (f - 55296 << 10) + (c - 56320), d++), f < 128 ? g[m++] = f : (f < 2048 ? g[m++] = 192 | f >>> 6 : (f < 65536 ? g[m++] = 224 | f >>> 12 : (g[m++] = 240 | f >>> 18, g[m++] = 128 | f >>> 12 & 63), g[m++] = 128 | f >>> 6 & 63), g[m++] = 128 | 63 & f); return g; }, i.buf2binstring = function(p) { return u(p, p.length); }, i.binstring2buf = function(p) { for (var g = new o.Buf8(p.length), f = 0, c = g.length; f < c; f++) g[f] = p.charCodeAt(f); return g; }, i.buf2string = function(p, g) { var f, c, d, m, _ = g || p.length, w = new Array(2 * _); for (f = c = 0; f < _; ) if ((d = p[f++]) < 128) w[c++] = d; else if (4 < (m = l[d])) w[c++] = 65533, f += m - 1; else { for (d &= m === 2 ? 31 : m === 3 ? 15 : 7; 1 < m && f < _; ) d = d << 6 | 63 & p[f++], m--; 1 < m ? 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(p, g) { var f; for ((g = g || p.length) > p.length && (g = p.length), f = g - 1; 0 <= f && (192 & p[f]) == 128; ) f--; return f < 0 || f === 0 ? g : f + l[p[f]] > g ? f : g; }; }, { "./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, p = 0; a !== 0; ) { for (a -= p = 2e3 < a ? 2e3 : a; u = u + (h = h + s[l++] | 0) | 0, --p; ) ; 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, p = h + l; s ^= -1; for (var g = h; g < p; g++) s = s >>> 8 ^ u[255 & (s ^ a[g])]; 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"), p = 0, g = 4, f = 0, c = -2, d = -1, m = 4, _ = 2, w = 8, x = 9, T = 286, M = 30, C = 19, P = 2 * T + 1, B = 15, R = 3, F = 258, Y = F + R + 1, A = 42, z = 113, b = 1, U = 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 q(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 - Y ? y.strstart - (y.w_size - Y) : 0, X = y.window, $ = y.w_mask, K = y.prev, te = y.strstart + F, le = X[k + H - 1], re = X[k + H]; y.prev_length >= y.good_match && (S >>= 2), W > y.lookahead && (W = y.lookahead); do if (X[(I = j) + H] === re && X[I + H - 1] === le && X[I] === X[k] && X[++I] === X[k + 1]) { k += 2, I++; do ; while (X[++k] === X[++I] && X[++k] === X[++I] && X[++k] === X[++I] && X[++k] === X[++I] && X[++k] === X[++I] && X[++k] === X[++I] && X[++k] === X[++I] && X[++k] === X[++I] && k < te); if (E = F - (te - k), k = te - F, H < E) { if (y.match_start = j, W <= (H = E)) break; le = X[k + H - 1], re = X[k + H]; } } while ((j = K[j & $]) > L && --S != 0); return H <= y.lookahead ? H : y.lookahead; } function ue(y) { var j, I, E, S, k, H, W, L, X, $, K = y.w_size; do { if (S = y.window_size - y.lookahead - y.strstart, y.strstart >= K + (K - Y)) { for (s.arraySet(y.window, y.window, K, K, 0), y.match_start -= K, y.strstart -= K, y.block_start -= K, j = I = y.hash_size; E = y.head[--j], y.head[j] = K <= E ? E - K : 0, --I; ) ; for (j = I = K; E = y.prev[--j], y.prev[j] = K <= E ? E - K : 0, --I; ) ; S += K; } if (y.strm.avail_in === 0) break; if (H = y.strm, W = y.window, L = y.strstart + y.lookahead, X = S, $ = void 0, $ = H.avail_in, X < $ && ($ = X), 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 < Y && y.strm.avail_in !== 0); } function fe(y, j) { for (var I, E; ; ) { if (y.lookahead < Y) { if (ue(y), y.lookahead < Y && j === p) return b; 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 - Y && (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 b; } return y.insert = y.strstart < R - 1 ? y.strstart : R - 1, j === g ? (D(y, !0), y.strm.avail_out === 0 ? J : G) : y.last_lit && (D(y, !1), y.strm.avail_out === 0) ? b : U; } function ie(y, j) { for (var I, E, S; ; ) { if (y.lookahead < Y) { if (ue(y), y.lookahead < Y && j === p) return b; 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 - Y && (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 b; } 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 b; } 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 === g ? (D(y, !0), y.strm.avail_out === 0 ? J : G) : y.last_lit && (D(y, !1), y.strm.avail_out === 0) ? b : U; } 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 = p, a._tr_init(j), f) : ne(y, c); } function Te(y) { var j = me(y); return j === f && (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 || x < S || I !== w || E < 8 || 15 < E || j < 0 || 9 < j || k < 0 || m < 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 === p) return b; 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 - Y && (D(y, !1), y.strm.avail_out === 0)) return b; } return y.insert = 0, j === g ? (D(y, !0), y.strm.avail_out === 0 ? J : G) : (y.strstart > y.block_start && (D(y, !1), y.strm.avail_out), b); }), 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, f) : 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 !== g) 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, q(E, H), E.strstart !== 0 && (q(E, y.adler >>> 16), q(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, f; } else if (y.avail_in === 0 && V(j) <= V(I) && j !== g) 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 !== p && E.status !== 666) { var W = E.strategy === 2 ? (function(L, X) { for (var $; ; ) { if (L.lookahead === 0 && (ue(L), L.lookahead === 0)) { if (X === p) return b; 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 b; } return L.insert = 0, X === g ? (D(L, !0), L.strm.avail_out === 0 ? J : G) : L.last_lit && (D(L, !1), L.strm.avail_out === 0) ? b : U; })(E, j) : E.strategy === 3 ? (function(L, X) { for (var $, K, te, le, re = L.window; ; ) { if (L.lookahead <= F) { if (ue(L), L.lookahead <= F && X === p) return b; if (L.lookahead === 0) break; } if (L.match_length = 0, L.lookahead >= R && 0 < L.strstart && (K = re[te = L.strstart - 1]) === re[++te] && K === re[++te] && K === re[++te]) { le = L.strstart + F; do ; while (K === re[++te] && K === re[++te] && K === re[++te] && K === re[++te] && K === re[++te] && K === re[++te] && K === re[++te] && K === re[++te] && te < le); L.match_length = F - (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 b; } return L.insert = 0, X === g ? (D(L, !0), L.strm.avail_out === 0 ? J : G) : L.last_lit && (D(L, !1), L.strm.avail_out === 0) ? b : U; })(E, j) : o[E.level].func(E, j); if (W !== J && W !== G || (E.status = 666), W === b || W === J) return y.avail_out === 0 && (E.last_flush = -1), f; if (W === U && (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, f; } return j !== g ? f : 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)) : (q(E, y.adler >>> 16), q(E, 65535 & y.adler)), O(y), 0 < E.wrap && (E.wrap = -E.wrap), E.pending !== 0 ? f : 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) : f) : c; }, i.deflateSetDictionary = function(y, j) { var I, E, S, k, H, W, L, X, $ = 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), X = new s.Buf8(I.w_size), s.arraySet(X, j, $ - I.w_size, I.w_size, 0), j = X, $ = 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, f; }, 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, p, g, f, c, d, m, _, w, x, T, M, C, P, B, R, F, Y, A, z, b, U; a = o.state, l = o.next_in, b = o.input, h = l + (o.avail_in - 5), u = o.next_out, U = o.output, p = u - (s - o.avail_out), g = u + (o.avail_out - 257), f = a.dmax, c = a.wsize, d = a.whave, m = a.wnext, _ = a.window, w = a.hold, x = a.bits, T = a.lencode, M = a.distcode, C = (1 << a.lenbits) - 1, P = (1 << a.distbits) - 1; e: do { x < 15 && (w += b[l++] << x, x += 8, w += b[l++] << x, x += 8), B = T[w & C]; t: for (; ; ) { if (w >>>= R = B >>> 24, x -= R, (R = B >>> 16 & 255) === 0) U[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; } F = 65535 & B, (R &= 15) && (x < R && (w += b[l++] << x, x += 8), F += w & (1 << R) - 1, w >>>= R, x -= R), x < 15 && (w += b[l++] << x, x += 8, w += b[l++] << x, x += 8), B = M[w & P]; n: for (; ; ) { if (w >>>= R = B >>> 24, x -= 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 (Y = 65535 & B, x < (R &= 15) && (w += b[l++] << x, (x += 8) < R && (w += b[l++] << x, x += 8)), f < (Y += w & (1 << R) - 1)) { o.msg = "invalid distance too far back", a.mode = 30; break e; } if (w >>>= R, x -= R, (R = u - p) < Y) { if (d < (R = Y - R) && a.sane) { o.msg = "invalid distance too far back", a.mode = 30; break e; } if (z = _, (A = 0) === m) { if (A += c - R, R < F) { for (F -= R; U[u++] = _[A++], --R; ) ; A = u - Y, z = U; } } else if (m < R) { if (A += c + m - R, (R -= m) < F) { for (F -= R; U[u++] = _[A++], --R; ) ; if (A = 0, m < F) { for (F -= R = m; U[u++] = _[A++], --R; ) ; A = u - Y, z = U; } } } else if (A += m - R, R < F) { for (F -= R; U[u++] = _[A++], --R; ) ; A = u - Y, z = U; } for (; 2 < F; ) U[u++] = z[A++], U[u++] = z[A++], U[u++] = z[A++], F -= 3; F && (U[u++] = z[A++], 1 < F && (U[u++] = z[A++])); } else { for (A = u - Y; U[u++] = U[A++], U[u++] = U[A++], U[u++] = U[A++], 2 < (F -= 3); ) ; F && (U[u++] = U[A++], 1 < F && (U[u++] = U[A++])); } break; } } break; } } while (l < h && u < g); l -= F = x >> 3, w &= (1 << (x -= F << 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 < g ? g - u + 257 : 257 - (u - g), a.hold = w, a.bits = x; }; }, {}], 49: [function(t, n, i) { var o = t("../utils/common"), s = t("./adler32"), a = t("./crc32"), l = t("./inffast"), h = t("./inftrees"), u = 1, p = 2, g = 0, f = -2, c = 1, d = 852, m = 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 x(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(m), z.sane = 1, z.back = -1, g) : f; } function T(A) { var z; return A && A.state ? ((z = A.state).wsize = 0, z.whave = 0, z.wnext = 0, x(A)) : f; } function M(A, z) { var b, U; return A && A.state ? (U = A.state, z < 0 ? (b = 0, z = -z) : (b = 1 + (z >> 4), z < 48 && (z &= 15)), z && (z < 8 || 15 < z) ? f : (U.window !== null && U.wbits !== z && (U.window = null), U.wrap = b, U.wbits = z, T(A))) : f; } function C(A, z) { var b, U; return A ? (U = new w(), (A.state = U).window = null, (b = M(A, z)) !== g && (A.state = null), b) : f; } var P, B, R = !0; function F(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(p, 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 Y(A, z, b, U) { 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)), U >= G.wsize ? (o.arraySet(G.window, z, b - G.wsize, G.wsize, 0), G.wnext = 0, G.whave = G.wsize) : (U < (J = G.wsize - G.wnext) && (J = U), o.arraySet(G.window, z, b - U, J, G.wnext), (U -= J) ? (o.arraySet(G.window, z, b - U, U, 0), G.wnext = U, 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 = x, i.inflateInit = function(A) { return C(A, 15); }, i.inflateInit2 = C, i.inflate = function(A, z) { var b, U, J, G, ne, V, ee, O, D, Q, q, 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 f; (b = A.state).mode === 12 && (b.mode = 13), ne = A.next_out, J = A.output, ee = A.avail_out, G = A.next_in, U = A.input, V = A.avail_in, O = b.hold, D = b.bits, Q = V, q = ee, j = g; e: for (; ; ) switch (b.mode) { case c: if (b.wrap === 0) { b.mode = 13; break; } for (; D < 16; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } if (2 & b.wrap && O === 35615) { k[b.check = 0] = 255 & O, k[1] = O >>> 8 & 255, b.check = a(b.check, k, 2, 0), D = O = 0, b.mode = 2; break; } if (b.flags = 0, b.head && (b.head.done = !1), !(1 & b.wrap) || (((255 & O) << 8) + (O >> 8)) % 31) { A.msg = "incorrect header check", b.mode = 30; break; } if ((15 & O) != 8) { A.msg = "unknown compression method", b.mode = 30; break; } if (D -= 4, y = 8 + (15 & (O >>>= 4)), b.wbits === 0) b.wbits = y; else if (y > b.wbits) { A.msg = "invalid window size", b.mode = 30; break; } b.dmax = 1 << y, A.adler = b.check = 1, b.mode = 512 & O ? 10 : 12, D = O = 0; break; case 2: for (; D < 16; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } if (b.flags = O, (255 & b.flags) != 8) { A.msg = "unknown compression method", b.mode = 30; break; } if (57344 & b.flags) { A.msg = "unknown header flags set", b.mode = 30; break; } b.head && (b.head.text = O >> 8 & 1), 512 & b.flags && (k[0] = 255 & O, k[1] = O >>> 8 & 255, b.check = a(b.check, k, 2, 0)), D = O = 0, b.mode = 3; case 3: for (; D < 32; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } b.head && (b.head.time = O), 512 & b.flags && (k[0] = 255 & O, k[1] = O >>> 8 & 255, k[2] = O >>> 16 & 255, k[3] = O >>> 24 & 255, b.check = a(b.check, k, 4, 0)), D = O = 0, b.mode = 4; case 4: for (; D < 16; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } b.head && (b.head.xflags = 255 & O, b.head.os = O >> 8), 512 & b.flags && (k[0] = 255 & O, k[1] = O >>> 8 & 255, b.check = a(b.check, k, 2, 0)), D = O = 0, b.mode = 5; case 5: if (1024 & b.flags) { for (; D < 16; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } b.length = O, b.head && (b.head.extra_len = O), 512 & b.flags && (k[0] = 255 & O, k[1] = O >>> 8 & 255, b.check = a(b.check, k, 2, 0)), D = O = 0; } else b.head && (b.head.extra = null); b.mode = 6; case 6: if (1024 & b.flags && (V < (Z = b.length) && (Z = V), Z && (b.head && (y = b.head.extra_len - b.length, b.head.extra || (b.head.extra = new Array(b.head.extra_len)), o.arraySet(b.head.extra, U, G, Z, y)), 512 & b.flags && (b.check = a(b.check, U, Z, G)), V -= Z, G += Z, b.length -= Z), b.length)) break e; b.length = 0, b.mode = 7; case 7: if (2048 & b.flags) { if (V === 0) break e; for (Z = 0; y = U[G + Z++], b.head && y && b.length < 65536 && (b.head.name += String.fromCharCode(y)), y && Z < V; ) ; if (512 & b.flags && (b.check = a(b.check, U, Z, G)), V -= Z, G += Z, y) break e; } else b.head && (b.head.name = null); b.length = 0, b.mode = 8; case 8: if (4096 & b.flags) { if (V === 0) break e; for (Z = 0; y = U[G + Z++], b.head && y && b.length < 65536 && (b.head.comment += String.fromCharCode(y)), y && Z < V; ) ; if (512 & b.flags && (b.check = a(b.check, U, Z, G)), V -= Z, G += Z, y) break e; } else b.head && (b.head.comment = null); b.mode = 9; case 9: if (512 & b.flags) { for (; D < 16; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } if (O !== (65535 & b.check)) { A.msg = "header crc mismatch", b.mode = 30; break; } D = O = 0; } b.head && (b.head.hcrc = b.flags >> 9 & 1, b.head.done = !0), A.adler = b.check = 0, b.mode = 12; break; case 10: for (; D < 32; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } A.adler = b.check = _(O), D = O = 0, b.mode = 11; case 11: if (b.havedict === 0) return A.next_out = ne, A.avail_out = ee, A.next_in = G, A.avail_in = V, b.hold = O, b.bits = D, 2; A.adler = b.check = 1, b.mode = 12; case 12: if (z === 5 || z === 6) break e; case 13: if (b.last) { O >>>= 7 & D, D -= 7 & D, b.mode = 27; break; } for (; D < 3; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } switch (b.last = 1 & O, D -= 1, 3 & (O >>>= 1)) { case 0: b.mode = 14; break; case 1: if (F(b), b.mode = 20, z !== 6) break; O >>>= 2, D -= 2; break e; case 2: b.mode = 17; break; case 3: A.msg = "invalid block type", b.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 += U[G++] << D, D += 8; } if ((65535 & O) != (O >>> 16 ^ 65535)) { A.msg = "invalid stored block lengths", b.mode = 30; break; } if (b.length = 65535 & O, D = O = 0, b.mode = 15, z === 6) break e; case 15: b.mode = 16; case 16: if (Z = b.length) { if (V < Z && (Z = V), ee < Z && (Z = ee), Z === 0) break e; o.arraySet(J, U, G, Z, ne), V -= Z, G += Z, ee -= Z, ne += Z, b.length -= Z; break; } b.mode = 12; break; case 17: for (; D < 14; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } if (b.nlen = 257 + (31 & O), O >>>= 5, D -= 5, b.ndist = 1 + (31 & O), O >>>= 5, D -= 5, b.ncode = 4 + (15 & O), O >>>= 4, D -= 4, 286 < b.nlen || 30 < b.ndist) { A.msg = "too many length or distance symbols", b.mode = 30; break; } b.have = 0, b.mode = 18; case 18: for (; b.have < b.ncode; ) { for (; D < 3; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } b.lens[H[b.have++]] = 7 & O, O >>>= 3, D -= 3; } for (; b.have < 19; ) b.lens[H[b.have++]] = 0; if (b.lencode = b.lendyn, b.lenbits = 7, I = { bits: b.lenbits }, j = h(0, b.lens, 0, 19, b.lencode, 0, b.work, I), b.lenbits = I.bits, j) { A.msg = "invalid code lengths set", b.mode = 30; break; } b.have = 0, b.mode = 19; case 19: for (; b.have < b.nlen + b.ndist; ) { for (; oe = (S = b.lencode[O & (1 << b.lenbits) - 1]) >>> 16 & 255, he = 65535 & S, !((ie = S >>> 24) <= D); ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } if (he < 16) O >>>= ie, D -= ie, b.lens[b.have++] = he; else { if (he === 16) { for (E = ie + 2; D < E; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } if (O >>>= ie, D -= ie, b.have === 0) { A.msg = "invalid bit length repeat", b.mode = 30; break; } y = b.lens[b.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 += U[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 += U[G++] << D, D += 8; } D -= ie, y = 0, Z = 11 + (127 & (O >>>= ie)), O >>>= 7, D -= 7; } if (b.have + Z > b.nlen + b.ndist) { A.msg = "invalid bit length repeat", b.mode = 30; break; } for (; Z--; ) b.lens[b.have++] = y; } } if (b.mode === 30) break; if (b.lens[256] === 0) { A.msg = "invalid code -- missing end-of-block", b.mode = 30; break; } if (b.lenbits = 9, I = { bits: b.lenbits }, j = h(u, b.lens, 0, b.nlen, b.lencode, 0, b.work, I), b.lenbits = I.bits, j) { A.msg = "invalid literal/lengths set", b.mode = 30; break; } if (b.distbits = 6, b.distcode = b.distdyn, I = { bits: b.distbits }, j = h(p, b.lens, b.nlen, b.ndist, b.distcode, 0, b.work, I), b.distbits = I.bits, j) { A.msg = "invalid distances set", b.mode = 30; break; } if (b.mode = 20, z === 6) break e; case 20: b.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, b.hold = O, b.bits = D, l(A, q), ne = A.next_out, J = A.output, ee = A.avail_out, G = A.next_in, U = A.input, V = A.avail_in, O = b.hold, D = b.bits, b.mode === 12 && (b.back = -1); break; } for (b.back = 0; oe = (S = b.lencode[O & (1 << b.lenbits) - 1]) >>> 16 & 255, he = 65535 & S, !((ie = S >>> 24) <= D); ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } if (oe && (240 & oe) == 0) { for (me = ie, Te = oe, ve = he; oe = (S = b.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 += U[G++] << D, D += 8; } O >>>= me, D -= me, b.back += me; } if (O >>>= ie, D -= ie, b.back += ie, b.length = he, oe === 0) { b.mode = 26; break; } if (32 & oe) { b.back = -1, b.mode = 12; break; } if (64 & oe) { A.msg = "invalid literal/length code", b.mode = 30; break; } b.extra = 15 & oe, b.mode = 22; case 22: if (b.extra) { for (E = b.extra; D < E; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } b.length += O & (1 << b.extra) - 1, O >>>= b.extra, D -= b.extra, b.back += b.extra; } b.was = b.length, b.mode = 23; case 23: for (; oe = (S = b.distcode[O & (1 << b.distbits) - 1]) >>> 16 & 255, he = 65535 & S, !((ie = S >>> 24) <= D); ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } if ((240 & oe) == 0) { for (me = ie, Te = oe, ve = he; oe = (S = b.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 += U[G++] << D, D += 8; } O >>>= me, D -= me, b.back += me; } if (O >>>= ie, D -= ie, b.back += ie, 64 & oe) { A.msg = "invalid distance code", b.mode = 30; break; } b.offset = he, b.extra = 15 & oe, b.mode = 24; case 24: if (b.extra) { for (E = b.extra; D < E; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } b.offset += O & (1 << b.extra) - 1, O >>>= b.extra, D -= b.extra, b.back += b.extra; } if (b.offset > b.dmax) { A.msg = "invalid distance too far back", b.mode = 30; break; } b.mode = 25; case 25: if (ee === 0) break e; if (Z = q - ee, b.offset > Z) { if ((Z = b.offset - Z) > b.whave && b.sane) { A.msg = "invalid distance too far back", b.mode = 30; break; } ue = Z > b.wnext ? (Z -= b.wnext, b.wsize - Z) : b.wnext - Z, Z > b.length && (Z = b.length), fe = b.window; } else fe = J, ue = ne - b.offset, Z = b.length; for (ee < Z && (Z = ee), ee -= Z, b.length -= Z; J[ne++] = fe[ue++], --Z; ) ; b.length === 0 && (b.mode = 21); break; case 26: if (ee === 0) break e; J[ne++] = b.length, ee--, b.mode = 21; break; case 27: if (b.wrap) { for (; D < 32; ) { if (V === 0) break e; V--, O |= U[G++] << D, D += 8; } if (q -= ee, A.total_out += q, b.total += q, q && (A.adler = b.check = b.flags ? a(b.check, J, q, ne - q) : s(b.check, J, q, ne - q)), q = ee, (b.flags ? O : _(O)) !== b.check) { A.msg = "incorrect data check", b.mode = 30; break; } D = O = 0; } b.mode = 28; case 28: if (b.wrap && b.flags) { for (; D < 32; ) { if (V === 0) break e; V--, O += U[G++] << D, D += 8; } if (O !== (4294967295 & b.total)) { A.msg = "incorrect length check", b.mode = 30; break; } D = O = 0; } b.mode = 29; case 29: j = 1; break e; case 30: j = -3; break e; case 31: return -4; case 32: default: return f; } return A.next_out = ne, A.avail_out = ee, A.next_in = G, A.avail_in = V, b.hold = O, b.bits = D, (b.wsize || q !== A.avail_out && b.mode < 30 && (b.mode < 27 || z !== 4)) && Y(A, A.output, A.next_out, q - A.avail_out) ? (b.mode = 31, -4) : (Q -= A.avail_in, q -= A.avail_out, A.total_in += Q, A.total_out += q, b.total += q, b.wrap && q && (A.adler = b.check = b.flags ? a(b.check, J, q, A.next_out - q) : s(b.check, J, q, A.next_out - q)), A.data_type = b.bits + (b.last ? 64 : 0) + (b.mode === 12 ? 128 : 0) + (b.mode === 20 || b.mode === 15 ? 256 : 0), (Q == 0 && q === 0 || z === 4) && j === g && (j = -5), j); }, i.inflateEnd = function(A) { if (!A || !A.state) return f; var z = A.state; return z.window && (z.window = null), A.state = null, g; }, i.inflateGetHeader = function(A, z) { var b; return A && A.state ? (2 & (b = A.state).wrap) == 0 ? f : ((b.head = z).done = !1, g) : f; }, i.inflateSetDictionary = function(A, z) { var b, U = z.length; return A && A.state ? (b = A.state).wrap !== 0 && b.mode !== 11 ? f : b.mode === 11 && s(1, z, U, 0) !== b.check ? -3 : Y(A, z, U, U) ? (b.mode = 31, -4) : (b.havedict = 1, g) : f; }, 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, p, g, f, c, d, m, _) { var w, x, T, M, C, P, B, R, F, Y = _.bits, A = 0, z = 0, b = 0, U = 0, J = 0, G = 0, ne = 0, V = 0, ee = 0, O = 0, D = null, Q = 0, q = new o.Buf16(16), Z = new o.Buf16(16), ue = null, fe = 0; for (A = 0; A <= 15; A++) q[A] = 0; for (z = 0; z < f; z++) q[p[g + z]]++; for (J = Y, U = 15; 1 <= U && q[U] === 0; U--) ; if (U < J && (J = U), U === 0) return c[d++] = 20971520, c[d++] = 20971520, _.bits = 1, 0; for (b = 1; b < U && q[b] === 0; b++) ; for (J < b && (J = b), A = V = 1; A <= 15; A++) if (V <<= 1, (V -= q[A]) < 0) return -1; if (0 < V && (u === 0 || U !== 1)) return -1; for (Z[1] = 0, A = 1; A < 15; A++) Z[A + 1] = Z[A] + q[A]; for (z = 0; z < f; z++) p[g + z] !== 0 && (m[Z[p[g + z]]++] = z); if (P = u === 0 ? (D = ue = m, 19) : u === 1 ? (D = s, Q -= 257, ue = a, fe -= 257, 256) : (D = l, ue = h, -1), A = b, 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, F = m[z] < P ? (R = 0, m[z]) : m[z] > P ? (R = ue[fe + m[z]], D[Q + m[z]]) : (R = 96, 0), w = 1 << A - ne, b = x = 1 << G; c[C + (O >> ne) + (x -= w)] = B << 24 | R << 16 | F | 0, x !== 0; ) ; for (w = 1 << A - 1; O & w; ) w >>= 1; if (w !== 0 ? (O &= w - 1, O += w) : O = 0, z++, --q[A] == 0) { if (A === U) break; A = p[g + m[z]]; } if (J < A && (O & M) !== T) { for (ne === 0 && (ne = J), C += b, V = 1 << (G = A - ne); G + ne < U && !((V -= q[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, p = 256, g = p + 1 + u, f = 30, c = 19, d = 2 * g + 1, m = 15, _ = 16, w = 7, x = 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], F = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], Y = new Array(2 * (g + 2)); l(Y); var A = new Array(2 * f); l(A); var z = new Array(512); l(z); var b = new Array(256); l(b); var U = new Array(u); l(U); var J, G, ne, V = new Array(f); 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 q(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) { q(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, X = new Array(m + 1), $ = 0; for (W = 1; W <= m; W++) X[W] = $ = $ + H[W - 1] << 1; for (L = 0; L <= k; L++) { var K = S[2 * L + 1]; K !== 0 && (S[2 * L] = ue(X[K]++, K)); } } function ie(S) { var k; for (k = 0; k < g; k++) S.dyn_ltree[2 * k] = 0; for (k = 0; k < f; k++) S.dyn_dtree[2 * k] = 0; for (k = 0; k < c; k++) S.bl_tree[2 * k] = 0; S.dyn_ltree[2 * x] = 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, X = 2 * H; return S[L] < S[X] || S[L] === S[X] && 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, X, $, K = 0; if (S.last_lit !== 0) for (; W = S.pending_buf[S.d_buf + 2 * K] << 8 | S.pending_buf[S.d_buf + 2 * K + 1], L = S.pending_buf[S.l_buf + K], K++, W === 0 ? Z(S, L, k) : (Z(S, (X = b[L]) + p + 1, k), ($ = P[X]) !== 0 && q(S, L -= U[X], $), Z(S, X = D(--W), H), ($ = B[X]) !== 0 && q(S, W -= V[X], $)), K < S.last_lit; ) ; Z(S, x, k); } function ve(S, k) { var H, W, L, X = k.dyn_tree, $ = k.stat_desc.static_tree, K = 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++) X[2 * H] !== 0 ? (S.heap[++S.heap_len] = le = H, S.depth[H] = 0) : X[2 * H + 1] = 0; for (; S.heap_len < 2; ) X[2 * (L = S.heap[++S.heap_len] = le < 2 ? ++le : 0)] = 1, S.depth[L] = 0, S.opt_len--, K && (S.static_len -= $[2 * L + 1]); for (k.max_code = le, H = S.heap_len >> 1; 1 <= H; H--) me(S, X, H); for (L = te; H = S.heap[1], S.heap[1] = S.heap[S.heap_len--], me(S, X, 1), W = S.heap[1], S.heap[--S.heap_max] = H, S.heap[--S.heap_max] = W, X[2 * L] = X[2 * H] + X[2 * W], S.depth[L] = (S.depth[H] >= S.depth[W] ? S.depth[H] : S.depth[W]) + 1, X[2 * H + 1] = X[2 * W + 1] = L, S.heap[1] = L++, me(S, X, 1), 2 <= S.heap_len; ) ; S.heap[--S.heap_max] = S.heap[1], (function(re, we) { var Pe, be, Ye, ge, at, bt, Re = we.dyn_tree, Ge = we.max_code, qe = we.stat_desc.static_tree, $e = we.stat_desc.has_stree, Je = we.stat_desc.extra_bits, We = we.stat_desc.extra_base, xt = we.stat_desc.max_length, Rt = 0; for (ge = 0; ge <= m; ge++) re.bl_count[ge] = 0; for (Re[2 * re.heap[re.heap_max] + 1] = 0, Pe = re.heap_max + 1; Pe < d; Pe++) xt < (ge = Re[2 * Re[2 * (be = re.heap[Pe]) + 1] + 1] + 1) && (ge = xt, Rt++), Re[2 * be + 1] = ge, Ge < be || (re.bl_count[ge]++, at = 0, We <= be && (at = Je[be - We]), bt = Re[2 * be], re.opt_len += bt * (ge + at), $e && (re.static_len += bt * (qe[2 * be + 1] + at))); if (Rt !== 0) { do { for (ge = xt - 1; re.bl_count[ge] === 0; ) ge--; re.bl_count[ge]--, re.bl_count[ge + 1] += 2, re.bl_count[xt]--, Rt -= 2; } while (0 < Rt); for (ge = xt; ge !== 0; ge--) for (be = re.bl_count[ge]; be !== 0; ) Ge < (Ye = re.heap[--Pe]) || (Re[2 * Ye + 1] !== ge && (re.opt_len += (ge - Re[2 * Ye + 1]) * Re[2 * Ye], Re[2 * Ye + 1] = ge), be--); } })(S, k), fe(X, le, S.bl_count); } function y(S, k, H) { var W, L, X = -1, $ = k[1], K = 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], ++K < te && L === $ || (K < le ? S.bl_tree[2 * L] += K : L !== 0 ? (L !== X && S.bl_tree[2 * L]++, S.bl_tree[2 * T]++) : K <= 10 ? S.bl_tree[2 * M]++ : S.bl_tree[2 * C]++, X = L, le = (K = 0) === $ ? (te = 138, 3) : L === $ ? (te = 6, 3) : (te = 7, 4)); } function j(S, k, H) { var W, L, X = -1, $ = k[1], K = 0, te = 7, le = 4; for ($ === 0 && (te = 138, le = 3), W = 0; W <= H; W++) if (L = $, $ = k[2 * (W + 1) + 1], !(++K < te && L === $)) { if (K < le) for (; Z(S, L, S.bl_tree), --K != 0; ) ; else L !== 0 ? (L !== X && (Z(S, L, S.bl_tree), K--), Z(S, T, S.bl_tree), q(S, K - 3, 2)) : K <= 10 ? (Z(S, M, S.bl_tree), q(S, K - 3, 3)) : (Z(S, C, S.bl_tree), q(S, K - 11, 7)); X = L, le = (K = 0) === $ ? (te = 138, 3) : L === $ ? (te = 6, 3) : (te = 7, 4); } } l(V); var I = !1; function E(S, k, H, W) { q(S, (h << 1) + (W ? 1 : 0), 3), (function(L, X, $, K) { oe(L), Q(L, $), Q(L, ~$), o.arraySet(L.pending_buf, L.window, X, $, L.pending), L.pending += $; })(S, k, H); } i._tr_init = function(S) { I || ((function() { var k, H, W, L, X, $ = new Array(m + 1); for (L = W = 0; L < u - 1; L++) for (U[L] = W, k = 0; k < 1 << P[L]; k++) b[W++] = L; for (b[W - 1] = L, L = X = 0; L < 16; L++) for (V[L] = X, k = 0; k < 1 << B[L]; k++) z[X++] = L; for (X >>= 7; L < f; L++) for (V[L] = X << 7, k = 0; k < 1 << B[L] - 7; k++) z[256 + X++] = L; for (H = 0; H <= m; H++) $[H] = 0; for (k = 0; k <= 143; ) Y[2 * k + 1] = 8, k++, $[8]++; for (; k <= 255; ) Y[2 * k + 1] = 9, k++, $[9]++; for (; k <= 279; ) Y[2 * k + 1] = 7, k++, $[7]++; for (; k <= 287; ) Y[2 * k + 1] = 8, k++, $[8]++; for (fe(Y, g + 1, $), k = 0; k < f; k++) A[2 * k + 1] = 5, A[2 * k] = ue(k, 5); J = new ee(Y, P, p + 1, g, m), G = new ee(A, B, 0, f, m), 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, X, $ = 0; 0 < S.level ? (S.strm.data_type === 2 && (S.strm.data_type = (function(K) { var te, le = 4093624447; for (te = 0; te <= 31; te++, le >>>= 1) if (1 & le && K.dyn_ltree[2 * te] !== 0) return s; if (K.dyn_ltree[18] !== 0 || K.dyn_ltree[20] !== 0 || K.dyn_ltree[26] !== 0) return a; for (te = 32; te < p; te++) if (K.dyn_ltree[2 * te] !== 0) return a; return s; })(S)), ve(S, S.l_desc), ve(S, S.d_desc), $ = (function(K) { var te; for (y(K, K.dyn_ltree, K.l_desc.max_code), y(K, K.dyn_dtree, K.d_desc.max_code), ve(K, K.bl_desc), te = c - 1; 3 <= te && K.bl_tree[2 * F[te] + 1] === 0; te--) ; return K.opt_len += 3 * (te + 1) + 5 + 5 + 4, te; })(S), L = S.opt_len + 3 + 7 >>> 3, (X = S.static_len + 3 + 7 >>> 3) <= L && (L = X)) : L = X = H + 5, H + 4 <= L && k !== -1 ? E(S, k, H, W) : S.strategy === 4 || X === L ? (q(S, 2 + (W ? 1 : 0), 3), Te(S, Y, A)) : (q(S, 4 + (W ? 1 : 0), 3), (function(K, te, le, re) { var we; for (q(K, te - 257, 5), q(K, le - 1, 5), q(K, re - 4, 4), we = 0; we < re; we++) q(K, K.bl_tree[2 * F[we] + 1], 3); j(K, K.dyn_ltree, te - 1), j(K, K.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 * (b[H] + p + 1)]++, S.dyn_dtree[2 * D(k)]++), S.last_lit === S.lit_bufsize - 1; }, i._tr_align = function(S) { q(S, 2, 3), Z(S, x, Y), (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, p, g = 1, f = {}, c = !1, d = s.document, m = Object.getPrototypeOf && Object.getPrototypeOf(s); m = m && m.setTimeout ? m : 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; } })() ? (p = "setImmediate$" + Math.random() + "$", s.addEventListener ? s.addEventListener("message", x, !1) : s.attachEvent("onmessage", x), function(T) { s.postMessage(p + 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); }, m.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 f[g] = P, l(g), g++; }, m.clearImmediate = _; } function _(T) { delete f[T]; } function w(T) { if (c) setTimeout(w, 0, T); else { var M = f[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 x(T) { T.source === s && typeof T.data == "string" && T.data.indexOf(p) === 0 && w(+T.data.slice(p.length)); } })(typeof self > "u" ? o === void 0 ? this : o : self); }).call(this, typeof Ft < "u" ? Ft : 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 Xr = on("string"), Ee = on("function"), Bi = on("number"), Ct = (r) => r !== null && typeof r == "object", Kr = (r) => r === !0 || r === !1, Xt = (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; } }, Yr = Oe("Date"), qr = 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 Fi(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, Ui = (r) => !_t(r) && r !== et; function Sn() { const { caseless: r, skipUndefined: e } = Ui(this) && this || {}, t = {}, n = (i, o) => { const s = r && Fi(t, o) || o; Xt(t[s]) && Xt(i) ? t[s] = Sn(t[s], i) : Xt(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; } ), qn = (({ 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); }, bo = (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 + "'"); }); } }); }, xo = (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: Xr, isNumber: Bi, isBoolean: Kr, isObject: Ct, isPlainObject: Xt, isEmptyObject: Zr, isReadableStream: no, isRequest: io, isResponse: so, isHeaders: ro, isUndefined: _t, isDate: Yr, isFile: qr, 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: qn, hasOwnProp: qn, // an alias to avoid ESLint no-prototype-builtins detection reduceDescriptors: ji, freezeMethods: bo, toObjectSet: xo, toCamelCase: yo, noop: vo, toFiniteNumber: To, findKey: Fi, global: et, isContextDefined: Ui, 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, m) { return !N.isUndefined(m[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, m) { let _ = c; if (c && !m && 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(x, T) { !(N.isUndefined(x) || x === null) && e.append( // eslint-disable-next-line no-nested-ternary s === !0 ? $n([d], T, o) : s === null ? d : d + "[]", h(x) ); }), !1; } return En(c) ? !0 : (e.append($n(m, d, o), h(c)), !1); } const p = [], g = Object.assign(Do, { defaultVisitor: u, convertValue: h, isVisitable: En }); function f(c, d) { if (!N.isUndefined(c)) { if (p.indexOf(c) !== -1) throw Error("Circular reference detected in " + d.join(".")); p.push(c), N.forEach(c, function(_, w) { (!(N.isUndefined(_) || _ === null) && i.call( e, _, N.isString(w) ? w.trim() : w, d, g )) === !0 && f(_, d ? d.concat(w) : [w]); }), p.pop(); } } if (!N.isObject(r)) throw new TypeError("data must be an object"); return f(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 Xi = On.prototype; Xi.append = function(e, t) { this._pairs.push([e, t]); }; Xi.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 Ki(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), Fo = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Uo = Nn && window.location.href || "http://localhost", jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, hasBrowserEnv: Nn, hasStandardBrowserEnv: Bo, hasStandardBrowserWebWorkerEnv: Fo, navigator: Mn, origin: Uo }, Symbol.toStringTag, { value: "Module" })), xe = { ...jo, ...Io }; function Vo(r, e) { return an(r, new xe.classes.URLSearchParams(), { visitor: function(t, n, i, o) { return xe.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 Yi(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(Yi(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: xe.classes.FormData, Blob: xe.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 Xo = 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" ]), Ko = (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] && Xo[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 Kt(r) { return r === !1 || r == null ? r : N.isArray(r) ? r.map(Kt) : 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 Yo = (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 qo(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 p = N.findKey(i, u); (!p || i[p] === void 0 || h === !0 || h === void 0 && i[p] !== !1) && (i[p || l] = Kt(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()) && !Yo(e)) s(Ko(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] = Kt(i), delete t[o]; return; } const a = e ? qo(o) : String(o).trim(); a !== o && delete t[o], t[a] = Kt(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 qi(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 p = o, g = 0; for (; p !== i; ) g += t[p++], p = p % r; if (i = (i + 1) % r, i === o && (o = (o + 1) % r), h - s < e) return; const f = u && h - u; return f ? Math.round(g * 1e3 / f) : 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(), p = u - t; p >= n ? s(h, u) : (i = h, o || (o = setTimeout(() => { o = null, s(i); }, n - p))); }, () => 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 p = { 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(p); }, 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 = xe.hasStandardBrowserEnv ? /* @__PURE__ */ ((r, e) => (t) => (t = new URL(t, xe.origin), r.protocol === t.protocol && r.host === t.host && (e || r.port === t.port)))( new URL(xe.origin), xe.navigator && /(msie|trident)/i.test(xe.navigator.userAgent) ) : () => !0, na = xe.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, p, g) { return N.isPlainObject(h) && N.isPlainObject(u) ? N.merge.call({ caseless: g }, h, u) : N.isPlainObject(u) ? N.merge({}, u) : N.isArray(u) ? u.slice() : u; } function i(h, u, p, g) { if (N.isUndefined(u)) { if (!N.isUndefined(h)) return n(void 0, h, p, g); } else return n(h, u, p, g); } 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, p) { if (p in e) return n(h, u); if (p 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, p) => i(ii(h), ii(u), p, !0) }; return N.forEach(Object.keys({ ...r, ...e }), function(u) { const p = l[u] || i, g = p(r[u], e[u], u); N.isUndefined(g) && p !== a || (t[u] = g); }), 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 = Ki(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 (xe.hasStandardBrowserEnv || xe.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, p]) => { h.includes(u.toLowerCase()) && s.set(u, p); }); } } if (xe.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, p, g, f, c; function d() { f && f(), c && c(), i.cancelToken && i.cancelToken.unsubscribe(u), i.signal && i.signal.removeEventListener("abort", u); } let m = new XMLHttpRequest(); m.open(i.method.toUpperCase(), i.url, !0), m.timeout = i.timeout; function _() { if (!m) return; const x = Me.from( "getAllResponseHeaders" in m && m.getAllResponseHeaders() ), M = { data: !a || a === "text" || a === "json" ? m.responseText : m.response, status: m.status, statusText: m.statusText, headers: x, config: r, request: m }; $i(function(P) { t(P), d(); }, function(P) { n(P), d(); }, M), m = null; } "onloadend" in m ? m.onloadend = _ : m.onreadystatechange = function() { !m || m.readyState !== 4 || m.status === 0 && !(m.responseURL && m.responseURL.indexOf("file:") === 0) || setTimeout(_); }, m.onabort = function() { m && (n(new se("Request aborted", se.ECONNABORTED, r, m)), m = null); }, m.onerror = function(T) { const M = T && T.message ? T.message : "Network Error", C = new se(M, se.ERR_NETWORK, r, m); C.event = T || null, n(C), m = null; }, m.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, m )), m = null; }, o === void 0 && s.setContentType(null), "setRequestHeader" in m && N.forEach(s.toJSON(), function(T, M) { m.setRequestHeader(M, T); }), N.isUndefined(i.withCredentials) || (m.withCredentials = !!i.withCredentials), a && a !== "json" && (m.responseType = i.responseType), h && ([g, c] = en(h, !0), m.addEventListener("progress", g)), l && m.upload && ([p, f] = en(l), m.upload.addEventListener("progress", p), m.upload.addEventListener("loadend", f)), (i.cancelToken || i.signal) && (u = (x) => { m && (n(!x || x.type ? new wt(null, r, m) : x), m.abort(), m = 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 && xe.protocols.indexOf(w) === -1) { n(new se("Unsupported protocol " + w + ":", se.ERR_BAD_REQUEST, r)); return; } m.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 p = u.byteLength; if (t) { let g = o += p; t(g); } 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(xe.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)), p = { stream: u && ((c) => c.body) }; i && ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((c) => { !p[c] && (p[c] = (d, m) => { let _ = d && d[c]; if (_) return _.call(d); throw new se(`Response type '${c}' is not supported`, se.ERR_NOT_SUPPORT, m); }); }); const g = async (c) => { if (c == null) return 0; if (N.isBlob(c)) return c.size; if (N.isSpecCompliantForm(c)) return (await new t(xe.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; }, f = async (c, d) => { const m = N.toFiniteNumber(c.getContentLength()); return m ?? g(d); }; return async (c) => { let { url: d, method: m, data: _, signal: w, cancelToken: x, timeout: T, onDownloadProgress: M, onUploadProgress: C, responseType: P, headers: B, withCredentials: R = "same-origin", fetchOptions: F } = Qi(c), Y = e || fetch; P = P ? (P + "").toLowerCase() : "text"; let A = aa([w, x && x.toAbortSignal()], T), z = null; const b = A && A.unsubscribe && (() => { A.unsubscribe(); }); let U; try { if (C && h && m !== "get" && m !== "head" && (U = await f(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, q] = ti( U, en(ni(C)) ); _ = si(O.body, ri, Q, q); } } N.isString(R) || (R = R ? "include" : "omit"); const J = o && "credentials" in t.prototype, G = { ...F, signal: A, method: m.toUpperCase(), headers: B.normalize().toJSON(), body: _, duplex: "half", credentials: J ? R : void 0 }; z = o && new t(d, G); let ne = await (o ? Y(z, F) : Y(d, G)); const V = u && (P === "stream" || P === "response"); if (u && (M || V && b)) { const O = {}; ["status", "statusText", "headers"].forEach((Z) => { O[Z] = ne[Z]; }); const D = N.toFiniteNumber(ne.headers.get("content-length")), [Q, q] = M && ti( D, en(ni(M), !0) ) || []; ne = new n( si(ne.body, ri, Q, () => { q && q(), b && b(); }), O ); } P = P || "text"; let ee = await p[N.findKey(p, P) || "text"](ne, c); return !V && b && b(), 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 b && b(), 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} */ 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 qi(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, p = 0, g; if (!l) { const c = [hi.bind(this), void 0]; for (c.unshift(...a), c.push(...h), g = c.length, u = Promise.resolve(t); p < g; ) u = u.then(c[p++], c[p++]); return u; } g = a.length; let f = t; for (; p < g; ) { const c = a[p++], d = a[p++]; try { f = c(f); } catch (m) { d.call(this, m); break; } } try { u = hi.call(this, f); } catch (c) { return Promise.reject(c); } for (p = 0, g = h.length; p < g; ) u = u.then(h[p++], h[p++]); return u; } getUri(e) { e = st(this.defaults, e); const t = Ji(e.baseURL, e.url, e.allowAbsoluteUrls); return Ki(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 = qi; _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) => Yi(N.isHTMLForm(r) ? new FormData(r) : r); _e.getAdapter = ts.getAdapter; _e.HttpStatusCode = An; _e.default = _e; const { Axios: Jl, AxiosError: Ql, CanceledError: ec, isCancel: tc, CancelToken: nc, VERSION: ic, all: sc, Cancel: rc, isAxiosError: oc, spread: ac, toFormData: lc, AxiosHeaders: cc, HttpStatusCode: hc, formToJSON: uc, getAdapter: dc, mergeConfig: fc } = _e; function ba(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("", 0) && t.responseText.includes("", 0) && t.responseText.includes("", 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 xa 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(p) { u({ draco: p }); }, DracoDecoderModule(r); }); break; case "decode": const l = a.buffer, h = a.taskConfig; e.then((u) => { const p = u.draco, g = new p.Decoder(); try { const f = t(p, g, new Int8Array(l), h), c = f.attributes.map((d) => d.array.buffer); f.index && c.push(f.index.array.buffer), self.postMessage({ type: "decode", id: a.id, geometry: f }, c); } catch (f) { console.error(f), self.postMessage({ type: "error", id: a.id, error: f.message }); } finally { p.destroy(g); } }); break; } }; function t(s, a, l, h) { const u = h.attributeIDs, p = h.attributeTypes; let g, f; const c = a.GetEncodedGeometryType(l); if (c === s.TRIANGULAR_MESH) g = new s.Mesh(), f = a.DecodeArrayToMesh(l, l.byteLength, g); else if (c === s.POINT_CLOUD) g = new s.PointCloud(), f = a.DecodeArrayToPointCloud(l, l.byteLength, g); else throw new Error("THREE.DRACOLoader: Unexpected geometry type."); if (!f.ok() || g.ptr === 0) throw new Error("THREE.DRACOLoader: Decoding failed: " + f.error_msg()); const d = { index: null, attributes: [] }; for (const m in u) { const _ = self[p[m]]; let w, x; if (h.useUniqueIDs) x = u[m], w = a.GetAttributeByUniqueId(g, x); else { if (x = a.GetAttributeId(g, s[u[m]]), x === -1) continue; w = a.GetAttribute(g, x); } const T = i(s, a, g, m, _, w); m === "color" && (T.vertexColorSpace = h.vertexColorSpace), d.attributes.push(T); } return c === s.TRIANGULAR_MESH && (d.index = n(s, a, g)), s.destroy(g), d; } function n(s, a, l) { const u = l.num_faces() * 3, p = u * 4, g = s._malloc(p); a.GetTrianglesUInt32Array(l, p, g); const f = new Uint32Array(s.HEAPF32.buffer, g, u).slice(); return s._free(g), { array: f, itemSize: 1 }; } function i(s, a, l, h, u, p) { const g = l.num_points(), f = p.num_components(), c = o(s, u), d = f * u.BYTES_PER_ELEMENT, m = Math.ceil(d / 4) * 4, _ = m / u.BYTES_PER_ELEMENT, w = g * d, x = g * m, T = s._malloc(w); a.GetAttributeDataArrayForAllPoints(l, p, c, w, T); const M = new u(s.HEAPF32.buffer, T, w / u.BYTES_PER_ELEMENT); let C; if (d === m) C = M.slice(); else { C = new u(x / u.BYTES_PER_ELEMENT); let P = 0; for (let B = 0, R = M.length; B < R; B++) { for (let F = 0; F < f; F++) C[P + F] = M[B * f + F]; P += _; } } return s._free(T), { name: h, count: g, itemSize: f, 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((f) => f.url == t), l = e.circularMeps, h = e.rectMeps.filter((f) => f.type === "风管"), u = e.rectMeps.filter((f) => f.type === "桥架"), p = e.ellipseMeps, g = r.scene; if (new v.MeshBasicMaterial(), new v.BufferGeometry(), Vt(g, "InstancedMesh"), l && l.length) { let f = []; 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]), f.push(c); Ht("Circle", g, f, 2); } if (Vt(g, "InstancedMesh"), h && h.length) { let f = []; 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]), f.push(c); Ht("Rect", g, f, 3); } if (Vt(g, "InstancedMesh"), p && p.length) { let f = []; for (let c of p) 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]), f.push(c); Ht("Ellipse", g, f, 4); } if (Vt(g, "InstancedMesh"), u && u.length) { let f = []; 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]), f.push(c); Ht("Bridge", g, f, 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 g = t[h], f = new v.Vector3(g.startPoint.X, 0, -g.startPoint.Y), c = new v.Vector3(g.endPoint.X, 0, -g.endPoint.Y), d = new v.Vector3(g.startPoint.X, g.startPoint.Z, -g.startPoint.Y), m = new v.Vector3(g.endPoint.X, g.endPoint.Z, -g.endPoint.Y), _ = 0, w = 0, x = 0; if (Math.abs(c.clone().sub(f.clone()).z) < 0.01 && Math.abs(c.clone().sub(f.clone()).x) < 0.01) { if (_ = (g.startPoint.Z > g.endPoint.Z ? 1 : -1) * Math.PI * 0.5, g.base_x != null) { var u = new v.Vector3(g.base_x.X, 0, -g.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(f.clone()).cross(new v.Vector3(0, 0, 1)).y > 0 ? -1 : 1) * c.clone().sub(f.clone()).angleTo(new v.Vector3(0, 0, 1)), _ = (g.startPoint.Z > g.endPoint.Z ? 1 : -1) * c.clone().sub(f.clone()).angleTo(m.clone().sub(d.clone())); let T = new v.Matrix4(); const M = new v.Euler(_, w, x, "YXZ"); let C = T.clone().makeRotationFromEuler(M), P, B; r === "Circle" ? (P = g.diameter, B = g.diameter) : (P = g.width, B = g.height); let R = T.clone().makeScale(P, B, g.length); T.multiplyMatrices(C, R), T.setPosition(g.position.x, g.position.y, g.position.z), o.setMatrixAt(h, T.clone()), o.setColorAt(h, g.color), o.geometry.computeBoundingBox(); let F = o.geometry.boundingBox.min.clone().applyMatrix4(T.clone()), Y = o.geometry.boundingBox.max.clone().applyMatrix4(T.clone()), A = new v.Vector3(Math.min(F.x, Y.x), Math.min(F.y, Y.y), Math.min(F.z, Y.z)), z = new v.Vector3(Math.max(F.x, Y.x), Math.max(F.y, Y.y), Math.max(F.z, Y.z)), b = A.clone().add(z.clone()).multiplyScalar(0.5), U = { name: g.name, min: A, max: z, center: b, dbid: h, // url: path + "/" + type, // basePath: url, // relativePath: relativePath, materialName: s.material.name }, J = null, G = null; r === "Circle" && (J = { x: g.startPoint.X * 0.3048, y: g.startPoint.Z * 0.3048, z: -g.startPoint.Y * 0.3048 }, G = { x: g.endPoint.X * 0.3048, y: g.endPoint.Z * 0.3048, z: -g.endPoint.Y * 0.3048 }, U.minC = J, U.maxC = G), l.push(U); } 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 p = []; p = { geometry: o.geometry, matrix: o.matrix, position: o.position, rotation: o.rotation }, o.meshs = p, 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 p = new v.ExtrudeGeometry(s, a), g = new v.MeshPhongMaterial({ color: l, side: v.DoubleSide // depthTest:false // name: path + "/" + type + "/material" }), f = new v.Mesh(p, g); return f.position.set(h.x, h.y, h.z), f.rotation._order = "YXZ", f.rotation.set(u.x, u.y, u.z), f; } } 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 p = r[u]; let g = 0; if (t !== (p.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 f in p.attributes) { if (!n.has(f)) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + '. All geometries must have compatible attributes; make sure "' + f + '" attribute exists among all geometries, or in none of them.'), null; o[f] === void 0 && (o[f] = []), o[f].push(p.attributes[f]), g++; } if (g !== 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 !== p.morphTargetsRelative) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". .morphTargetsRelative must be consistent throughout all geometries."), null; for (const f in p.morphAttributes) { if (!i.has(f)) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". .morphAttributes must be consistent throughout all geometries."), null; s[f] === void 0 && (s[f] = []), s[f].push(p.morphAttributes[f]); } if (e) { let f; if (t) f = p.index.count; else if (p.attributes.position !== void 0) f = p.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, f, u), h += f; } } if (t) { let u = 0; const p = []; for (let g = 0; g < r.length; ++g) { const f = r[g].index; for (let c = 0; c < f.count; ++c) p.push(f.getX(c) + u); u += r[g].attributes.position.count; } l.setIndex(p); } for (const u in o) { const p = di(o[u]); if (!p) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + u + " attribute."), null; l.setAttribute(u, p); } for (const u in s) { const p = s[u][0].length; if (p === 0) break; l.morphAttributes = l.morphAttributes || {}, l.morphAttributes[u] = []; for (let g = 0; g < p; ++g) { const f = []; for (let d = 0; d < s[u].length; ++d) f.push(s[u][d][g]); const c = di(f); 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 p = l / t; for (let g = 0, f = u.count; g < f; g++) for (let c = 0; c < t; c++) { const d = u.getComponent(g, c); a.setComponent(g + p, 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 Ua(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 Fa(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 (p) { i && i(p); 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 p = this.pluginCallbacks[u](h); p.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[p.name] = p, s[p.name] = !0; } if (o.extensionsUsed) for (let u = 0; u < o.extensionsUsed.length; ++u) { const p = o.extensionsUsed[u], g = o.extensionsRequired || []; switch (p) { case ae.KHR_MATERIALS_UNLIT: s[p] = new Ca(); break; case ae.KHR_DRACO_MESH_COMPRESSION: s[p] = new Xa(o, this.dracoLoader); break; case ae.KHR_TEXTURE_TRANSFORM: s[p] = new Ka(); break; case ae.KHR_MESH_QUANTIZATION: s[p] = new Za(); break; default: g.indexOf(p) >= 0 && a[p] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + p + '".'); } } 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} 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 p = 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 = p; break; case "spot": h = new Rs(u), h.distance = p, 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 : Ue; } 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 : Ue; } 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 : Ue; } 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 : Ue; } 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 : Ue; } 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 : Ue; } 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 : Ue; } 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 : Ue; } 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 : Ue; } 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 Fa { 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 : Ue; } 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 Ua { 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, p = i.byteStride, g = new Uint8Array(a, l, h); return s.decodeGltfBufferAsync ? s.decodeGltfBufferAsync(u, p, g, i.mode, i.filter).then(function(f) { return f.buffer; }) : s.ready.then(function() { const f = new ArrayBuffer(u * p); return s.decodeGltfBuffer(new Uint8Array(f), u, p, g, i.mode, i.filter), f; }); }); } 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(), p = u.isGroup ? u.children : [u], g = h[0].count, f = []; for (const c of p) { const d = new Ke(), m = new pe(), _ = new qt(), w = new pe(1, 1, 1), x = new Os(c.geometry, c.material, g); for (let T = 0; T < g; T++) l.TRANSLATION && m.fromBufferAttribute(l.TRANSLATION, T), l.ROTATION && _.fromBufferAttribute(l.ROTATION, T), l.SCALE && w.fromBufferAttribute(l.SCALE, T), x.setMatrixAt(T, d.compose(m, _, w)); for (const T in l) if (T === "_COLOR_0") { const M = l[T]; x.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(x, c), this.parser.assignFinalMaterial(x), f.push(x); } return u.isGroup ? (u.clear(), u.add(...f), u) : f[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 Xa { 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 p = Cn[u] || u.toLowerCase(); a[p] = s[u]; } for (const u in e.attributes) { const p = Cn[u] || u.toLowerCase(); if (s[u] !== void 0) { const g = n.accessors[e.attributes[u]], f = pt[g.componentType]; h[p] = f.name, l[p] = g.normalized === !0; } } return t.getDependency("bufferView", o).then(function(u) { return new Promise(function(p, g) { i.decodeDracoFile(u, function(f) { for (const c in f.attributes) { const d = f.attributes[c], m = l[c]; m !== void 0 && (d.normalized = m); } p(f); }, a, h, Ie, g); }); }); } } class Ka { 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, p = (n - t) / u, g = p * p, f = g * p, c = e * h, d = c - h, m = -2 * f + 3 * g, _ = f - g, w = 1 - m, x = _ - g + p; 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 + x * C + m * P + _ * B; } return o; } } const Ya = new qt(); class qa extends as { interpolate_(e, t, n, i) { const o = super.interpolate_(e, t, n, i); return Ya.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: Us, 9985: Fs, 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" }, Xe = { 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 p = e[h]; if (p.POSITION !== void 0 && (n = !0), p.NORMAL !== void 0 && (i = !0), p.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 p = e[h]; if (n) { const g = p.POSITION !== void 0 ? t.getDependency("accessor", p.POSITION) : r.attributes.position; s.push(g); } if (i) { const g = p.NORMAL !== void 0 ? t.getDependency("accessor", p.NORMAL) : r.attributes.normal; a.push(g); } if (o) { const g = p.COLOR_0 !== void 0 ? t.getDependency("accessor", p.COLOR_0) : r.attributes.color; l.push(g); } } return Promise.all([ Promise.all(s), Promise.all(a), Promise.all(l) ]).then(function(h) { const u = h[0], p = h[1], g = h[2]; return n && (r.morphAttributes.position = u), i && (r.morphAttributes.normal = p), o && (r.morphAttributes.color = g), 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 + ":" + bn(t.attributes) : e = r.indices + ":" + bn(r.attributes) + ":" + r.mode, r.targets !== void 0) for (let n = 0, i = r.targets.length; n < i; n++) e += ":" + bn(r.targets[n]); return e; } function bn(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 Ke(); 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} */ 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>} */ 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} */ 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} */ 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} */ 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, p = u * l, g = i.byteOffset || 0, f = i.bufferView !== void 0 ? n.bufferViews[i.bufferView].byteStride : void 0, c = i.normalized === !0; let d, m; if (f && f !== p) { const _ = Math.floor(g / f), w = "InterleavedBuffer:" + i.bufferView + ":" + i.componentType + ":" + _ + ":" + i.count; let x = t.cache.get(w); x || (d = new h(a, _ * f, i.count * f / u), x = new Ei(d, f / u), t.cache.add(w, x)), m = new Mi(x, l, g % f / u, c); } else a === null ? d = new h(i.count * l) : d = new h(a, g, i.count * l), m = new ft(d, l, c); if (i.sparse !== void 0) { const _ = yn.SCALAR, w = pt[i.sparse.indices.componentType], x = i.sparse.indices.byteOffset || 0, T = i.sparse.values.byteOffset || 0, M = new w(s[1], x, i.sparse.count * _), C = new h(s[2], T, i.sparse.count * l); a !== null && (m = new ft(m.array.slice(), m.itemSize, m.normalized)), m.normalized = !1; for (let P = 0, B = M.length; P < B; P++) { const R = M[P]; if (m.setX(R, C[P * l]), l >= 2 && m.setY(R, C[P * l + 1]), l >= 3 && m.setZ(R, C[P * l + 2]), l >= 4 && m.setW(R, C[P * l + 3]), l >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute."); } m.normalized = c; } return m; }); } /** * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures * * @private * @param {number} textureIndex * @return {Promise} */ 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 g = (o.samplers || {})[s.sampler] || {}; return u.magFilter = mi[g.magFilter] || Tn, u.minFilter = mi[g.minFilter] || ki, u.wrapS = gi[g.wrapS] || it, u.wrapT = gi[g.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((p) => p.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(p) { h = !0; const g = new Blob([p], { type: s.mimeType }); return l = a.createObjectURL(g), 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(p) { return new Promise(function(g, f) { let c = g; t.isImageBitmapLoader === !0 && (c = function(d) { const m = new jn(d); m.needsUpdate = !0, g(m); }), t.load(Et.resolveURL(p, o.path), c, void 0, f); }); }).then(function(p) { return h === !0 && a.revokeObjectURL(l), ze(p, s), p.userData.mimeType = s.mimeType || nl(s.uri), p; }).catch(function(p) { throw console.error("THREE.GLTFLoader: Couldn't load texture", l), p; }); 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} */ 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} */ 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 p = i[ae.KHR_MATERIALS_UNLIT]; s = p.getMaterialType(), h.push(p.extendParams(a, o, t)); } else { const p = o.pbrMetallicRoughness || {}; if (a.color = new Ce(1, 1, 1), a.opacity = 1, Array.isArray(p.baseColorFactor)) { const g = p.baseColorFactor; a.color.setRGB(g[0], g[1], g[2], Ie), a.opacity = g[3]; } p.baseColorTexture !== void 0 && h.push(t.assignTexture(a, "map", p.baseColorTexture, Ze)), a.metalness = p.metallicFactor !== void 0 ? p.metallicFactor : 1, a.roughness = p.roughnessFactor !== void 0 ? p.roughnessFactor : 1, p.metallicRoughnessTexture !== void 0 && (h.push(t.assignTexture(a, "metalnessMap", p.metallicRoughnessTexture)), h.push(t.assignTexture(a, "roughnessMap", p.metallicRoughnessTexture))), s = this._invokeOne(function(g) { return g.getMaterialType && g.getMaterialType(e); }), h.push(Promise.all(this._invokeAll(function(g) { return g.extendMaterialParams && g.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 p = o.normalTexture.scale; a.normalScale.set(p, p); } 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 p = o.emissiveFactor; a.emissive = new Ce().setRGB(p[0], p[1], p[2], Ie); } return o.emissiveTexture !== void 0 && s !== ct && h.push(t.assignTexture(a, "emissiveMap", o.emissiveTexture, Ze)), Promise.all(h).then(function() { const p = new s(a); return o.name && (p.name = o.name), ze(p, o), t.associations.set(p, { materials: e }), o.extensions && Qe(i, p, o), p; }); } /** * When Object3D instances are targeted by animation, they need unique names. * * @private * @param {string} originalName * @return {string} */ createUniqueName(e) { const t = Xs.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} primitives * @return {Promise>} */ 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), p = i[u]; if (p) s.push(p.promise); else { let g; h.extensions && h.extensions[ae.KHR_DRACO_MESH_COMPRESSION] ? g = o(h) : g = _i(new tn(), h, t), i[u] = { primitive: h, promise: g }, s.push(g); } } return Promise.all(s); } /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes * * @private * @param {number} meshIndex * @return {Promise} */ 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], p = []; for (let f = 0, c = u.length; f < c; f++) { const d = u[f], m = s[f]; let _; const w = h[f]; if (m.mode === ke.TRIANGLES || m.mode === ke.TRIANGLE_STRIP || m.mode === ke.TRIANGLE_FAN || m.mode === void 0) _ = o.isSkinnedMesh === !0 ? new Ks(d, w) : new xi(d, w), _.isSkinnedMesh === !0 && _.normalizeSkinWeights(), m.mode === ke.TRIANGLE_STRIP ? _.geometry = fi(_.geometry, Ai) : m.mode === ke.TRIANGLE_FAN && (_.geometry = fi(_.geometry, vn)); else if (m.mode === ke.LINES) _ = new Zs(d, w); else if (m.mode === ke.LINE_STRIP) _ = new Ys(d, w); else if (m.mode === ke.LINE_LOOP) _ = new qs(d, w); else if (m.mode === ke.POINTS) _ = new $s(d, w); else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + m.mode); Object.keys(_.geometry.morphAttributes).length > 0 && el(_, o), _.name = t.createUniqueName(o.name || "mesh_" + e), ze(_, o), m.extensions && Qe(i, _, m), t.assignFinalMaterial(_), p.push(_); } for (let f = 0, c = p.length; f < c; f++) t.associations.set(p[f], { meshes: e, primitives: f }); if (p.length === 1) return o.extensions && Qe(i, p[0], o), p[0]; const g = new hn(); o.extensions && Qe(i, g, o), t.associations.set(g, { meshes: e }); for (let f = 0, c = p.length; f < c; f++) g.add(p[f]); return g; }); } /** * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras * * @private * @param {number} cameraIndex * @return {Promise|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(bi.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} */ 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 p = s[h]; if (p) { a.push(p); const g = new Ke(); o !== null && g.fromArray(o.array, h * 16), l.push(g); } 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} */ 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 p = 0, g = i.channels.length; p < g; p++) { const f = i.channels[p], c = i.samplers[f.sampler], d = f.target, m = 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", m)), 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(p) { const g = p[0], f = p[1], c = p[2], d = p[3], m = p[4], _ = []; for (let x = 0, T = g.length; x < T; x++) { const M = g[x], C = f[x], P = c[x], B = d[x], R = m[x]; if (M === void 0) continue; M.updateMatrix && M.updateMatrix(); const F = n._createAnimationTracks(M, C, P, B, R); if (F) for (let Y = 0; Y < F.length; Y++) _.push(F[Y]); } 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} */ 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], p = h[1], g = h[2]; g !== null && u.traverse(function(f) { f.isSkinnedMesh && f.bind(g, il); }); for (let f = 0, c = p.length; f < c; f++) u.add(p[f]); 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 p = 0, g = h.length; p < g; p++) u.add(h[p]); 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 p = new Ke(); p.fromArray(o.matrix), u.applyMatrix4(p); } 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 p = i.associations.get(u); i.associations.set(u, { ...p }); } 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} */ 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, p = l.length; u < p; u++) o.add(l[u]); const h = (u) => { const p = /* @__PURE__ */ new Map(); for (const [g, f] of i.associations) (g instanceof cn || g instanceof jn) && p.set(g, f); return u.traverse((g) => { const f = i.associations.get(g); f != null && p.set(g, f); }), p; }; return i.associations = h(o), o; }); } _createAnimationTracks(e, t, n, i, o) { const s = [], a = e.name ? e.name : e.uuid, l = []; Xe[o.path] === Xe.weights ? e.traverse(function(g) { g.morphTargetInfluences && l.push(g.name ? g.name : g.uuid); }) : l.push(a); let h; switch (Xe[o.path]) { case Xe.weights: h = Hn; break; case Xe.rotation: h = Gn; break; case Xe.translation: case Xe.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, p = this._getArrayFromAccessor(n); for (let g = 0, f = l.length; g < f; g++) { const c = new h( l[g] + "." + Xe[o.path], t.array, p, 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 ? qa : 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 p = o[h]; if (p.POSITION !== void 0) { const g = t.json.accessors[p.POSITION], f = g.min, c = g.max; if (f !== void 0 && c !== void 0) { if (l.setX(Math.max(Math.abs(f[0]), Math.abs(c[0]))), l.setY(Math.max(Math.abs(f[1]), Math.abs(c[1]))), l.setZ(Math.max(Math.abs(f[2]), Math.abs(c[2]))), g.normalized) { const d = kn(pt[g.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 = {}, ba(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((g) => { g.glb = h, a.has(g.id) == !1 ? a.set(g.id, { infos: [g] }) : a.get(g.id).infos.push(g); }); let u = new Ea(); const p = new xa(); p.setDecoderPath("/static/js/draco/"), p.preload(), u.setDRACOLoader(p), u.load(e.url + i.path + h + ".glb", (g) => { i.glbs[h] = g.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 p = new v.Matrix4(); p.elements = h.matrix; let g = new v.Mesh(u.geometry.clone().applyMatrix4(p), u.material), f = new v.Box3().setFromObject(g); h.box = f, h.mesh = g, g.name = l, g.glb = h.glb, g.url = e.url, s.push(g); } }); }), 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, p = new v.Vector3(l.x + h.x / 2, l.y + h.y / 2, l.z + h.z / 2); u.distanceTo(p), s.elements.forEach((g) => { a.push(g); }), s.children.forEach((g) => { a.push(...n(i, o, g)); }), s.children.findIndex((g) => g.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; }); } // 获取模型的精准位置描述,给大模型用的,主要是 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(h, u) { e.self != null && e.self.disActive != null && e.self.disActive(), e.self = h, e.options = u; }, e.render = function() { e.self && e.self.render != null && e.self.render(); }, e.active = function() { r.container.addEventListener("mousedown", o), r.container.addEventListener("mouseup", a), r.container.addEventListener("mousemove", s); }, e.disActive = function() { r.container.removeEventListener("mousedown", o), r.container.removeEventListener("mouseup", a), r.container.removeEventListener("mousemove", s); }; function t(h) { const u = new v.Vector2(), p = r.renderer.domElement.clientWidth, g = r.renderer.domElement.clientHeight; return u.x = h.clientX / p * 2 - 1, u.y = -(h.clientY / g) * 2 + 1, u; } function n(h) { const u = new v.Raycaster(), p = t(h); return u.setFromCamera(p, r.camera), u; } function i(h, u = !1) { const p = n(h); if (h.raycaster = p, u) { const g = l(p); h.catch = g; } } function o(h) { h.button === 0 && (e.mouseDownTime = Date.now(), e.self && e.self.handleMouseDown != null && (i(h, !0), e.self.handleMouseDown(h))); } function s(h) { e.self && e.self.handleMouseMove != null && (i(h, !0), e.self.handleMouseMove(h)); } function a(h) { if (h.button !== 0) return; const u = Date.now(), p = u - e.mouseDownTime; if (e.self && e.self.handleMouseUp != null && (i(h, !1), e.self.handleMouseUp(h)), p < 100 && e.self && e.self.handleMouseClick != null) { i(h, !0); const g = u - e.lastClickTime; console.log(g), g < 200 ? e.self.handleMouseDoubleClick(h) : e.self.handleMouseClick(h), e.lastClickTime = Date.now(); } } function l(h) { const u = r.octreeBox.rayInterationModel(h); if (u.length !== 0) return u[0]; } return e; } var Yt = { exports: {} }, yl = Yt.exports, wi; function wl() { return wi || (wi = 1, (function(r, e) { (function(t, n) { r.exports = n(); })(yl, function() { var t = function() { function n(f) { return s.appendChild(f.dom), f; } function i(f) { for (var c = 0; c < s.children.length; c++) s.children[c].style.display = c === f ? "block" : "none"; o = f; } 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(f) { f.preventDefault(), i(++o % s.children.length); }, !1); var a = (performance || Date).now(), l = a, h = 0, u = n(new t.Panel("FPS", "#0ff", "#002")), p = n(new t.Panel("MS", "#0f0", "#020")); if (self.performance && self.performance.memory) var g = 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 f = (performance || Date).now(); if (p.update(f - a, 200), f > l + 1e3 && (u.update(1e3 * h / (f - l), 100), l = f, h = 0, g)) { var c = performance.memory; g.update(c.usedJSHeapSize / 1048576, c.jsHeapSizeLimit / 1048576); } return f; }, 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, p = 48 * h, g = 3 * h, f = 2 * h, c = 3 * h, d = 15 * h, m = 74 * h, _ = 30 * h, w = document.createElement("canvas"); w.width = u, w.height = p, w.style.cssText = "width:80px;height:48px"; var x = w.getContext("2d"); return x.font = "bold " + 9 * h + "px Helvetica,Arial,sans-serif", x.textBaseline = "top", x.fillStyle = o, x.fillRect(0, 0, u, p), x.fillStyle = i, x.fillText(n, g, f), x.fillRect(c, d, m, _), x.fillStyle = o, x.globalAlpha = 0.9, x.fillRect(c, d, m, _), { dom: w, update: function(T, M) { s = Math.min(s, T), a = Math.max(a, T), x.fillStyle = o, x.globalAlpha = 1, x.fillRect(0, 0, u, d), x.fillStyle = i, x.fillText(l(T) + " " + n + " (" + l(s) + "-" + l(a) + ")", g, f), x.drawImage(w, c + h, d, m - h, _, c, d, m - h, _), x.fillRect(c + m - h, d, h, _), x.fillStyle = o, x.globalAlpha = 0.9, x.fillRect(c + m - h, d, h, l((1 - T / M) * _)); } }; }, t; }); })(Yt)), Yt.exports; } var bl = wl(); const xl = /* @__PURE__ */ Oi(bl); 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 p = n[s]; if (p.length === 0) continue; for (var g = [a], f = 0, c = p.length; f < c; f += 1) { var d = this._handleRelativeValue(a, p[f]); if (isNaN(d)) { u = !1, console.warn("Found invalid interpolation list. Skipping."); break; } g.push(d); } u && (n[s] = g); } if ((h === "object" || l) && a && !u) { t[s] = l ? [] : {}; var m = a; for (var _ in m) t[s][_] = m[_]; i[s] = l ? [] : {}; var p = n[s]; if (!this._isDynamic) { var w = {}; for (var _ in p) w[_] = p[_]; n[s] = p = w; } this._setupProperties(m, t[s], p, 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 m = Math.trunc(a / l), _ = a - m * l, w = Math.min(_ / n._duration, 1); return w === 0 && a === n._duration ? 1 : w; }, p = u(), g = this._easingFunction(p); if (this._updateProperties(this._object, this._valuesStart, this._valuesEnd, g), this._onUpdateCallback && this._onUpdateCallback(this._object, p), this._duration === 0 || a >= this._duration) if (this._repeat > 0) { var f = Math.min(Math.trunc((a - this._duration) / l) + 1, this._repeat); isFinite(this._repeat) && (this._repeat -= f); 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 * f, 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 Fe = Rn; Fe.getAll.bind(Fe); Fe.removeAll.bind(Fe); Fe.add.bind(Fe); Fe.remove.bind(Fe); Fe.update.bind(Fe); var xn = { 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(), p()); }, 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()), m = e.camera.position.clone().sub(d.clone()).setLength(100); n.camera.position.copy(m), 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 m = r.octreeBox.getBoundingBox(), _ = m.min, w = m.max, x = _.clone().add(w.clone()).multiplyScalar(0.5), T = x.clone().add(d.multiplyScalar(1 * w.distanceTo(_))); l(e.camera.position, T, r.controls.target.clone(), x); }, n.GetCameraPose = function() { var c = e.camera.quaternion, d = e.camera.position, m = r.controls.target, _ = { quaternion: c, position: d, target: m }; return _; }, n.ReductionCameraPose = function(c, d = 1e3, m) { 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), x = new v.Vector3(c.target.x, c.target.y, c.target.z); let T = !1; l( e.camera.position, w, r.controls.target.clone(), x, e.camera.quaternion, _, d, (M) => { m && (T || (m(M), T = !0)); } ), m && setTimeout(() => { T || (m(!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 m = new v.Vector3(1, 1, 1); var _ = d.clone().add(m.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, m, _, w, x, T = 1e3, M) { var C; w && x ? (C = new xn.Tween({ x1: c.x, // 相机当前位置x y1: c.y, // 相机当前位置y z1: c.z, // 相机当前位置z x2: m.x, // 控制当前的中心点x y2: m.y, // 控制当前的中心点y z2: m.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: x._x, // 新的相机quaternion _y: x._y, // 新的相机quaternion _z: x._z, // 新的相机quaternion _w: x._w // 新的相机quaternion }, T )) : (C = new xn.Tween({ x1: c.x, // 相机当前位置x y1: c.y, // 相机当前位置y z1: c.z, // 相机当前位置z x2: m.x, // 控制当前的中心点x y2: m.y, // 控制当前的中心点y z2: m.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 && x ? (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(xn.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 m = t.clientWidth, _ = t.clientWidth, c = m > _ ? m / _ : _ / m, d = 300; n.camera = new v.OrthographicCamera( d * c / -2, d * c / 2, d / 2, d / -2, 0.01, 1e4 ); var m = o.clientWidth, _ = o.clientHeight, w = new v.WebGLRenderer({ alpha: !0 }); w.setSize(m, _), w.setClearAlpha(0), n.sceneOrtho.renderer = w; let x = new v.AmbientLight(16777215, 0.8); n.sceneOrtho.add(x), El(o, w); } function p() { 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 m = []; for (const w of d) m.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), m); n.sceneOrtho.add(_), g(122), o.addEventListener("mousedown", (w) => { var x = {}; x.x = w.offsetX / o.clientWidth * 2 - 1, x.y = -(w.offsetY / o.clientHeight) * 2 + 1; var T = new v.Raycaster(); T.setFromCamera(x, n.camera); const M = T.intersectObjects(a, !1); M.length > 0 && n.ToggleDirectionView(M[0].object.name); }), o.addEventListener("mousemove", (w) => { var x = {}; x.x = w.offsetX / o.clientWidth * 2 - 1, x.y = -(w.offsetY / o.clientHeight) * 2 + 1; var T = new v.Raycaster(); T.setFromCamera(x, 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 g(c) { for (var d = c * 0.5 - 20, m = [ { 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) } ], x = 0; x < m.length; x++) a.push(f(m[x])); for (var x = 0; x < _.length; x++) a.push(f(_[x])); for (var x = 0; x < w.length; x++) a.push(f(w[x])); } function f(c) { const d = new v.BoxGeometry(c.a, c.b, c.c), m = 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(_), x = new v.Mesh(w, m); return x.name = c.name, n.sceneOrtho.add(x), x; } 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); return t.forEach((o) => { let s = o.boundingBox.min, a = o.boundingBox.max; s.x < n.x && (n.x = s.x), s.y < n.y && (n.y = s.y), s.z < n.z && (n.z = s.z), a.x > i.x && (i.x = a.x), a.y > i.y && (i.y = a.y), a.z > i.z && (i.z = a.z); }), { min: n, max: i }; }, 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), p = new v.Vector3(Math.min(h.x, u.X), Math.min(h.y, u.y), Math.min(h.z, u.z)), g = new v.Vector3(Math.max(u.x, h.x), Math.max(u.y, h.y), Math.max(u.z, h.z)), f = new v.Box3(p, g), c = s.ray.intersectsBox(f); if (!(c == null || c == !1)) if (a.children == null || a.children.length == 0) { if (a.elements != null) for (var d of a.elements) { let m = r.engineStatus.hideModels.find((x) => x.url == l.url)?.ids; if (m != null && m.includes(d)) continue; let w = r.models.find((x) => x.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 x = r.models.find((T) => T.url == l.url).nodesMap.get(d); x?.infos.map((M) => M.mesh).forEach((M) => { n.push(M); }); } for (let m of a.children) o(s, m, 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; constructor(e) { this.engine = e, this.boundMouseDown = this.onMouseDown.bind(this), this.boundMouseMove = this.onMouseMove.bind(this), this.boundMouseUp = this.onMouseUp.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"); } /** * 停用工具 * 启用控制器,移除鼠标事件监听器 */ 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"), 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()); } /** * 结束绘制 * 隐藏绘制框 */ 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 p = this.worldToScreen.screenToWorld(u.x, u.y); p && a.push(p); } if (a.length < 3) { const u = this.engine.camera, p = this.engine.scene, g = new v.Box3(); if (p.traverse((f) => { if (f.isMesh && f.visible && f.geometry && (f.geometry.computeBoundingBox(), f.geometry.boundingBox)) { const c = f.geometry.boundingBox.clone(); c.applyMatrix4(f.matrixWorld), g.union(c); } }), g.isEmpty()) for (const c of l) { const d = this.worldToScreen.screenToWorldWithDepth(c.x, c.y, 10); a.push(d); } else { const f = new v.Vector3(); g.getCenter(f); const d = f.clone().sub(u.position).length(); for (const m of l) { const _ = this.worldToScreen.screenToWorldWithDepth(m.x, m.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 p = i.clone().sub(t.position); u.dot(p.normalize()) < 0 && u.negate(); const f = i.clone().sub(u.multiplyScalar(h)); t.position.copy(f), 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 p = new v.Vector3(); t.getWorldDirection(p); const g = s * 1.5, f = i.clone().sub(p.multiplyScalar(g)); t.position.copy(f), 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) => { f(c); }), this.engine.measure.annotationData.elevationAnnotation.forEach((c) => { g(c); }), this.engine.measure.annotationData.coordinateAnnotation.forEach((c) => { p(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 = [ '', '', // 起点 '', // 顶点 '', // 终点 '', // 起点到顶点的线 '', // 顶点到终点的线 '', '' + c.text + "", "" ].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), m = 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", m.x), w.getElementsByTagName("circle")[1].setAttribute("cy", m.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 + " " + m.x + "," + m.y), w.getElementsByTagName("polyline")[1].setAttribute("points", m.x + "," + m.y + " " + _.x + "," + _.y); let x = m.x, T = m.y - 30; w.getElementsByTagName("rect")[0].setAttribute("x", x - 40), w.getElementsByTagName("rect")[0].setAttribute("y", T - 12.5), w.getElementsByTagName("text")[0].setAttribute("x", x), 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 = [ '', '', // 填充区域 '', // 边界线 '', '' + c.text + "", "" ].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 = [], m = 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), m += P.x, _ += P.y; } m = m / d.length, _ = _ / d.length; let w = d.map((C) => C.x + "," + C.y).join(" "), x = c.container; x.getElementsByTagName("polygon")[0].setAttribute("points", w), x.getElementsByTagName("polyline")[0].setAttribute("points", w); let T = m, M = _; x.getElementsByTagName("rect")[0].setAttribute("x", T - 40), x.getElementsByTagName("rect")[0].setAttribute("y", M - 12.5), x.getElementsByTagName("text")[0].setAttribute("x", T), x.getElementsByTagName("text")[0].setAttribute("y", M + 4), x.getElementsByTagName("text")[0].innerHTML = c.text, x.style.top = "0px", x.style.left = "0px"; } function u(c) { if (c.container == null) { let T = [ '', "", '', '', // 箭头形状 "", "", '', // 起点到终点的线,带箭头 '', '' + c.text + "", "" ].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), m = 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 + " " + m.x + "," + m.y); let w = (d.x + m.x) / 2, x = (d.y + m.y) / 2 - 30; _.getElementsByTagName("rect")[0].setAttribute("x", w - 50), _.getElementsByTagName("rect")[0].setAttribute("y", x - 12.5), _.getElementsByTagName("text")[0].setAttribute("x", w), _.getElementsByTagName("text")[0].setAttribute("y", x + 4), _.getElementsByTagName("text")[0].innerHTML = c.text, _.style.top = "0px", _.style.left = "0px"; } function p(c) { if (c.container == null) { let M = [ '', '', '', '' + c.textX + "", '', '' + c.textY + "", '', '' + c.textZ + "", "" ].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, m = 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", m.x), _.setAttribute("cy", m.y)); let w = d.getElementsByTagName("rect"), x = d.getElementsByTagName("text"), T = -55; w[0] && (w[0].setAttribute("x", m.x + 10), w[0].setAttribute("y", m.y + 10 + T)), x[0] && (x[0].setAttribute("x", m.x + 10 + 40), x[0].setAttribute("y", m.y + 10 + 16 + T)), w[1] && (w[1].setAttribute("x", m.x + 10), w[1].setAttribute("y", m.y + 10 + 30 + T)), x[1] && (x[1].setAttribute("x", m.x + 10 + 40), x[1].setAttribute("y", m.y + 10 + 46 + T)), w[2] && (w[2].setAttribute("x", m.x + 10), w[2].setAttribute("y", m.y + 10 + 60 + T)), x[2] && (x[2].setAttribute("x", m.x + 10 + 40), x[2].setAttribute("y", m.y + 10 + 76 + T)), x[0] && (x[0].innerHTML = c.textX), x[1] && (x[1].innerHTML = c.textY), x[2] && (x[2].innerHTML = c.textZ); } function g(c) { if (c.container == null) { let _ = [ '', '', '' + c.text + "", '', "" ].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, m = new Ae(e.engine.camera, e.engine.renderer, e.engine.scene).worldToScreen(c.point); d.style.top = m.y - 48 + "px", d.style.left = m.x - 16 + "px", d.getElementsByTagName("text")[0].innerHTML = c.text; } function f(c) { if (c.container == null) { let w = [ '', '', '', '', '', '' + c.text + "", "" ].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), m = 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 + " " + m.x + "," + m.y), _.getElementsByTagName("circle")[0].setAttribute("cx", d.x), _.getElementsByTagName("circle")[0].setAttribute("cy", d.y), _.getElementsByTagName("circle")[1].setAttribute("cx", m.x), _.getElementsByTagName("circle")[1].setAttribute("cy", m.y), _.getElementsByTagName("rect")[0].setAttribute("x", d.x * 0.5 + m.x * 0.5 - 40), _.getElementsByTagName("rect")[0].setAttribute("y", d.y * 0.5 + m.y * 0.5 - 12.5), _.getElementsByTagName("text")[0].setAttribute("x", d.x * 0.5 + m.x * 0.5 + 40 - 40), _.getElementsByTagName("text")[0].setAttribute("y", d.y * 0.5 + m.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 Fl { 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 Ul { 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 ]), p = [ 0, 1, 2, // 第一个三角形 0, 2, 3 // 第二个三角形 ]; h.setAttribute("position", new v.BufferAttribute(u, 3)), h.setIndex(p); let g = t.meshs.find((_) => _.name == l); if (g == 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 g.geometry = h; const f = 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(f, 3)); let m = t.meshs.find((_) => _.name == l + "Line"); m == null && (m = new v.Line(d, c), m.name = l + "Line", n.add(m), t.meshs.push(m)), m.geometry = d, m.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 ]), p = [ 0, 1, 2, // 第一个三角形 0, 2, 3 // 第二个三角形 ]; h.setAttribute("position", new v.BufferAttribute(u, 3)), h.setIndex(p); let g = t.meshs.find((_) => _.name == l); if (g == 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 g.geometry = h; const f = 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(f, 3)); let m = t.meshs.find((_) => _.name == l + "Line"); m == null && (m = new v.Line(d, c), m.name = l + "Line", n.add(m), t.meshs.push(m)), m.geometry = d, m.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 ]), p = [ 0, 1, 2, // 第一个三角形 0, 2, 3 // 第二个三角形 ]; h.setAttribute("position", new v.BufferAttribute(u, 3)), h.setIndex(p); let g = t.meshs.find((_) => _.name == l); if (g == 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 g.geometry = h; const f = 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(f, 3)); let m = t.meshs.find((_) => _.name == l + "Line"); m == null && (m = new v.Line(d, c), m.name = l + "Line", n.add(m), t.meshs.push(m)), m.geometry = d, m.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); } // 重写鼠标按下事件 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, p, g) { const f = 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 // 第二个三角形 ]; f.setAttribute("position", new v.BufferAttribute(c, 3)), f.setIndex(d); let m = t.engine.scene.children.find((C) => C.type == "Group" && C.name == "ClippingBox"); m == null && (m = new v.Group(), m.name = "ClippingBox", t.engine.scene.add(m)); let _ = t.meshs.find((C) => C.name == g); if (_ == null) { const C = new v.MeshBasicMaterial({ color: 65280, // 绿色 transparent: !0, opacity: 0, side: v.DoubleSide // 双面渲染 }), P = new v.Mesh(f, C); P.normal = p, P.name = g, m.add(P), t.meshs.push(P); } else _.geometry = f; 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 x = 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 == g + "Line"); M == null && (M = new v.Line(T, x), M.name = g + "Line", m.add(M), t.meshs.push(M)), M.geometry = T, M.material = x, g == "前" || g == "左" || g == "底" ? t.engine.sectionPlane.find((C) => C.name == g).setFromNormalAndCoplanarPoint(p.clone().setLength(-1), e.min) : t.engine.sectionPlane.find((C) => C.name == g).setFromNormalAndCoplanarPoint(p.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 Ul(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 Xl { 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 Kl { 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() || ""], p = u.map((g) => g[0]); p = p.filter((g, f) => p.indexOf(g) === f), p.forEach((g) => { let f = { name: s.categorys[g], children: [] }; h.push(f), u.filter((c) => c[0] === g).forEach((c) => { f.children.push({ name: s.names[c[1]], value: s.values[c[2]] }); }); }), l?.(h); } } } class Zl { // 引擎参数 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; // 业务数据 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 Ur(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.measure = new Fl(this), this.modelToolModule = new gl(this), this.modelProperties = new Kl(this), this.interactionModule = new ml(this), this.interactionModule.init(), this.interactionModule.active(), this.modelTree = new Wl(this), this.engineInfo = new Xl(this), this.stats = new xl(), 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 pc(r) { return new Zl(r); } export { pc as createEngine }; //# sourceMappingURL=bim-engine-sdk.es.js.map