UNPKG

@realsee/dnalogel

Version:
1,334 lines (1,321 loc) 2.44 MB
var Yy = Object.defineProperty, Zy = Object.defineProperties; var qy = Object.getOwnPropertyDescriptors; var Da = Object.getOwnPropertySymbols; var Ad = Object.prototype.hasOwnProperty, wd = Object.prototype.propertyIsEnumerable; var pi = Math.pow, dc = (n, t, e) => t in n ? Yy(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, R = (n, t) => { for (var e in t || (t = {})) Ad.call(t, e) && dc(n, e, t[e]); if (Da) for (var e of Da(t)) wd.call(t, e) && dc(n, e, t[e]); return n; }, ue = (n, t) => Zy(n, qy(t)); var is = (n, t) => { var e = {}; for (var i in n) Ad.call(n, i) && t.indexOf(i) < 0 && (e[i] = n[i]); if (n != null && Da) for (var i of Da(n)) t.indexOf(i) < 0 && wd.call(n, i) && (e[i] = n[i]); return e; }; var f = (n, t, e) => (dc(n, typeof t != "symbol" ? t + "" : t, e), e); var ee = (n, t, e) => new Promise((i, s) => { var o = (l) => { try { a(e.next(l)); } catch (c) { s(c); } }, r = (l) => { try { a(e.throw(l)); } catch (c) { s(c); } }, a = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(o, r); a((e = e.apply(n, t)).next()); }); import { InternalWebGLRenderer as Jy, Camera as Ky, loadAt3d as $y, Five as Ut, Subscribe as nr, AnimationFrameLoop as eb, loadGltf as tb } from "@realsee/five"; import * as b from "three"; import { Vector3 as pe, Vector2 as Xt, Object3D as zo, Matrix4 as ot, LineSegments as ib, ShaderMaterial as Rl, Group as On, Raycaster as sr, MeshBasicMaterial as Xr, Vector4 as Os, Curve as L0, Loader as Pd, LoaderUtils as fc, FileLoader as nb, TextureLoader as Uh, RepeatWrapping as Cd, ClampToEdgeWrapping as Id, Texture as Md, MeshPhongMaterial as pc, MeshLambertMaterial as sb, Color as Bt, sRGBEncoding as zr, EquirectangularReflectionMapping as ob, Bone as Ed, PropertyBinding as La, OrthographicCamera as rb, PerspectiveCamera as ab, PointLight as kd, MathUtils as on, SpotLight as lb, DirectionalLight as cb, SkinnedMesh as hb, Mesh as Oo, LineBasicMaterial as ub, Line as db, Skeleton as fb, AmbientLight as pb, BufferGeometry as za, Float32BufferAttribute as vo, Uint16BufferAttribute as mb, Matrix3 as gb, BufferAttribute as vb, AnimationClip as yb, Quaternion as js, Euler as Dn, VectorKeyframeTrack as bb, QuaternionKeyframeTrack as Ab, NumberKeyframeTrack as wb, CanvasTexture as Pb, AnimationMixer as Cb, PlaneGeometry as Ib, LinearFilter as th, CurvePath as Mb, LineCurve3 as Eb, TubeGeometry as kb, SphereGeometry as xb, DoubleSide as z0, RingGeometry as Sb, VideoTexture as Tb, SphereBufferGeometry as Db, Box3 as Lb } from "three"; import { LineGeometry as zb, LineMaterial as Ob, THREE_Line2 as jb, Line as O0 } from "@realsee/five/line"; import { GLTFLoader as j0 } from "@realsee/five/gltf-loader"; function Rb() { console.debug( "%c %c@realsee/dnalogel %cv3.78.0", [ "background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAMCAMAAACHgmeRAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABLFBMVEUAAAAapPoap/oaqvkbrfkbr/gZnfwZoPsaqfnD4v/E4/8Ylv0clPm93/+/4P/B4f8Yj/683/8Wif+33P8Uhv+x2f8ShP+s1v8Pgf+n0/8Nf/+h0f8Lff8Lff8Nf/9dl/+czv8KfP8KfP+Lxf+Uyv+Xy/+Hwv+Jw/+Mxf+Oxv+RyP8aovsapfoap/oZmfwZm/wZnvsYnPsYkf4YlP0NePsDYfgYcfi43f+63v8Xiv8Xjf4EWfwCV/sWZ/qz2v+02/8Vh/8WiP8EUf8CTf4WXv2u1/+v2P8Thf8Thv8ETf8CR/8VV/+o1f+q1f8Qgv8Rg/8DSv8BRf8UVP+j0v+k0v8OgP8Pgf8DR/8DQv9Nhf+dzv+fz/+Kv/+Vyv+Xy/+azf+Oxv+Qx/+SyP////8MUhLdAAAAK3RSTlMACEWQ2bd98uQECPXxqO7c+Pb49vj2+Pb49vj23Oul8fMHA+TwerXXjEIG2P+bHgAAAAFiS0dEY1y+LaoAAAB+SURBVAjXY2BgZGJmYWVgYGBgY9fW0eVg4ORi4NbTNzDk4eXjZxAwMjYxNTO3EGQQsrSytrG1sxdmEHFwdHJ2cXUTZRBz9/D08vbxFWeQ8PMPCAwKDpFkkAoNC4+IjIqWZpCRlZOPiY2LV2BQVGJQTkhMUlEFWaOmrqGpxQAAyg0S9Dq+VPYAAAAASUVORK5CYII=')", "background-repeat: no-repeat", "background-position: 0 center", "padding-left: 8px" ].join(";"), "", "background-color: #12ce9b;color:black;padding:0 6px;border-radius: 3px" ); } function _b() { const n = typeof OffscreenCanvas != "undefined", t = n && new OffscreenCanvas(1, 1).getContext("webgl") !== null; n && !t && Object.assign(window, { OffscreenCanvas: function(e, i) { const s = document.createElement("canvas"); return s.width = e, s.height = i, s; } }); } function R0() { } const xd = () => Promise.resolve(), Sd = { __queue: Promise.resolve() }; function Bb(n = xd) { Sd.__queue = Sd.__queue.then(n).catch(xd); } function Oa(n, t, e) { const i = n.x, s = n.y, o = Math.floor(i / t * 1e4) / 1e4, r = Math.floor(s / e * 1e4) / 1e4; return { x: o, y: r }; } function mc(n, t, e) { const { x: i, y: s } = n, o = i * t, r = s * e; return { x: o, y: r }; } function ja(n) { if (n.length < 2) return {}; const t = n.slice(-2), e = t[0], i = { x: (t[0].x + t[1].x) / 2, y: (t[0].y + t[1].y) / 2 }; return { control: e, end: i }; } function Vb(n, t, e = R0) { new Promise((i) => { setTimeout(() => { e(), i(!0); }, t * n); }); } const Fb = window, Td = window.requestAnimationFrame || Fb.webkitRequestAnimationFrame || ((n) => setTimeout(n, 16)); function Ka(n, t = 0) { t <= 0 ? Td(n) : Td(() => Ka(n, t - 1)); } var Qi = Object.freeze({ Linear: Object.freeze({ None: function(n) { return n; }, In: function(n) { return n; }, Out: function(n) { return n; }, InOut: function(n) { return n; } }), Quadratic: Object.freeze({ In: function(n) { return n * n; }, Out: function(n) { return n * (2 - n); }, InOut: function(n) { return (n *= 2) < 1 ? 0.5 * n * n : -0.5 * (--n * (n - 2) - 1); } }), Cubic: Object.freeze({ In: function(n) { return n * n * n; }, Out: function(n) { return --n * n * n + 1; }, InOut: function(n) { return (n *= 2) < 1 ? 0.5 * n * n * n : 0.5 * ((n -= 2) * n * n + 2); } }), Quartic: Object.freeze({ In: function(n) { return n * n * n * n; }, Out: function(n) { return 1 - --n * n * n * n; }, InOut: function(n) { return (n *= 2) < 1 ? 0.5 * n * n * n * n : -0.5 * ((n -= 2) * n * n * n - 2); } }), Quintic: Object.freeze({ In: function(n) { return n * n * n * n * n; }, Out: function(n) { return --n * n * n * n * n + 1; }, InOut: function(n) { return (n *= 2) < 1 ? 0.5 * n * n * n * n * n : 0.5 * ((n -= 2) * n * n * n * n + 2); } }), Sinusoidal: Object.freeze({ In: function(n) { return 1 - Math.sin((1 - n) * Math.PI / 2); }, Out: function(n) { return Math.sin(n * Math.PI / 2); }, InOut: function(n) { return 0.5 * (1 - Math.sin(Math.PI * (0.5 - n))); } }), Exponential: Object.freeze({ In: function(n) { return n === 0 ? 0 : Math.pow(1024, n - 1); }, Out: function(n) { return n === 1 ? 1 : 1 - Math.pow(2, -10 * n); }, InOut: function(n) { return n === 0 ? 0 : n === 1 ? 1 : (n *= 2) < 1 ? 0.5 * Math.pow(1024, n - 1) : 0.5 * (-Math.pow(2, -10 * (n - 1)) + 2); } }), Circular: Object.freeze({ In: function(n) { return 1 - Math.sqrt(1 - n * n); }, Out: function(n) { return Math.sqrt(1 - --n * n); }, InOut: function(n) { return (n *= 2) < 1 ? -0.5 * (Math.sqrt(1 - n * n) - 1) : 0.5 * (Math.sqrt(1 - (n -= 2) * n) + 1); } }), Elastic: Object.freeze({ In: function(n) { return n === 0 ? 0 : n === 1 ? 1 : -Math.pow(2, 10 * (n - 1)) * Math.sin((n - 1.1) * 5 * Math.PI); }, Out: function(n) { return n === 0 ? 0 : n === 1 ? 1 : Math.pow(2, -10 * n) * Math.sin((n - 0.1) * 5 * Math.PI) + 1; }, InOut: function(n) { return n === 0 ? 0 : n === 1 ? 1 : (n *= 2, n < 1 ? -0.5 * Math.pow(2, 10 * (n - 1)) * Math.sin((n - 1.1) * 5 * Math.PI) : 0.5 * Math.pow(2, -10 * (n - 1)) * Math.sin((n - 1.1) * 5 * Math.PI) + 1); } }), Back: Object.freeze({ In: function(n) { var t = 1.70158; return n === 1 ? 1 : n * n * ((t + 1) * n - t); }, Out: function(n) { var t = 1.70158; return n === 0 ? 0 : --n * n * ((t + 1) * n + t) + 1; }, InOut: function(n) { var t = 2.5949095; return (n *= 2) < 1 ? 0.5 * (n * n * ((t + 1) * n - t)) : 0.5 * ((n -= 2) * n * ((t + 1) * n + t) + 2); } }), Bounce: Object.freeze({ In: function(n) { return 1 - Qi.Bounce.Out(1 - n); }, Out: function(n) { return n < 1 / 2.75 ? 7.5625 * n * n : n < 2 / 2.75 ? 7.5625 * (n -= 1.5 / 2.75) * n + 0.75 : n < 2.5 / 2.75 ? 7.5625 * (n -= 2.25 / 2.75) * n + 0.9375 : 7.5625 * (n -= 2.625 / 2.75) * n + 0.984375; }, InOut: function(n) { return n < 0.5 ? Qi.Bounce.In(n * 2) * 0.5 : Qi.Bounce.Out(n * 2 - 1) * 0.5 + 0.5; } }), generatePow: function(n) { return n === void 0 && (n = 4), n = n < Number.EPSILON ? Number.EPSILON : n, n = n > 1e4 ? 1e4 : n, { In: function(t) { return Math.pow(t, n); }, Out: function(t) { return 1 - Math.pow(1 - t, n); }, InOut: function(t) { return t < 0.5 ? Math.pow(t * 2, n) / 2 : (1 - Math.pow(2 - t * 2, n)) / 2 + 0.5; } }; } }), Eo = function() { return performance.now(); }, _0 = ( /** @class */ function() { function n() { this._tweens = {}, this._tweensAddedDuringUpdate = {}; } return n.prototype.getAll = function() { var t = this; return Object.keys(this._tweens).map(function(e) { return t._tweens[e]; }); }, n.prototype.removeAll = function() { this._tweens = {}; }, n.prototype.add = function(t) { this._tweens[t.getId()] = t, this._tweensAddedDuringUpdate[t.getId()] = t; }, n.prototype.remove = function(t) { delete this._tweens[t.getId()], delete this._tweensAddedDuringUpdate[t.getId()]; }, n.prototype.update = function(t, e) { t === void 0 && (t = Eo()), e === void 0 && (e = !1); var i = Object.keys(this._tweens); if (i.length === 0) return !1; for (; i.length > 0; ) { this._tweensAddedDuringUpdate = {}; for (var s = 0; s < i.length; s++) { var o = this._tweens[i[s]], r = !e; o && o.update(t, r) === !1 && !e && delete this._tweens[i[s]]; } i = Object.keys(this._tweensAddedDuringUpdate); } return !0; }, n; }() ), Rs = { Linear: function(n, t) { var e = n.length - 1, i = e * t, s = Math.floor(i), o = Rs.Utils.Linear; return t < 0 ? o(n[0], n[1], i) : t > 1 ? o(n[e], n[e - 1], e - i) : o(n[s], n[s + 1 > e ? e : s + 1], i - s); }, Bezier: function(n, t) { for (var e = 0, i = n.length - 1, s = Math.pow, o = Rs.Utils.Bernstein, r = 0; r <= i; r++) e += s(1 - t, i - r) * s(t, r) * n[r] * o(i, r); return e; }, CatmullRom: function(n, t) { var e = n.length - 1, i = e * t, s = Math.floor(i), o = Rs.Utils.CatmullRom; return n[0] === n[e] ? (t < 0 && (s = Math.floor(i = e * (1 + t))), o(n[(s - 1 + e) % e], n[s], n[(s + 1) % e], n[(s + 2) % e], i - s)) : t < 0 ? n[0] - (o(n[0], n[0], n[1], n[1], -i) - n[0]) : t > 1 ? n[e] - (o(n[e], n[e], n[e - 1], n[e - 1], i - e) - n[e]) : o(n[s ? s - 1 : 0], n[s], n[e < s + 1 ? e : s + 1], n[e < s + 2 ? e : s + 2], i - s); }, Utils: { Linear: function(n, t, e) { return (t - n) * e + n; }, Bernstein: function(n, t) { var e = Rs.Utils.Factorial; return e(n) / e(t) / e(n - t); }, Factorial: function() { var n = [1]; return function(t) { var e = 1; if (n[t]) return n[t]; for (var i = t; i > 1; i--) e *= i; return n[t] = e, e; }; }(), CatmullRom: function(n, t, e, i, s) { var o = (e - n) * 0.5, r = (i - t) * 0.5, a = s * s, l = s * a; return (2 * t - 2 * e + o + r) * l + (-3 * t + 3 * e - 2 * o - r) * a + o * s + t; } } }, Qh = ( /** @class */ function() { function n() { } return n.nextId = function() { return n._nextId++; }, n._nextId = 0, n; }() ), ih = new _0(), _l = ( /** @class */ function() { function n(t, e) { e === void 0 && (e = ih), this._object = t, this._group = e, 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 = Qi.Linear.None, this._interpolationFunction = Rs.Linear, this._chainedTweens = [], this._onStartCallbackFired = !1, this._onEveryStartCallbackFired = !1, this._id = Qh.nextId(), this._isChainStopped = !1, this._propertiesAreSetUp = !1, this._goToEnd = !1; } return n.prototype.getId = function() { return this._id; }, n.prototype.isPlaying = function() { return this._isPlaying; }, n.prototype.isPaused = function() { return this._isPaused; }, n.prototype.getDuration = function() { return this._duration; }, n.prototype.to = function(t, e) { if (e === void 0 && (e = 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 = t, this._propertiesAreSetUp = !1, this._duration = e < 0 ? 0 : e, this; }, n.prototype.duration = function(t) { return t === void 0 && (t = 1e3), this._duration = t < 0 ? 0 : t, this; }, n.prototype.dynamic = function(t) { return t === void 0 && (t = !1), this._isDynamic = t, this; }, n.prototype.start = function(t, e) { if (t === void 0 && (t = Eo()), e === void 0 && (e = !1), this._isPlaying) return this; if (this._group && this._group.add(this), this._repeat = this._initialRepeat, this._reversed) { this._reversed = !1; for (var i in this._valuesStartRepeat) this._swapEndStartRepeatValues(i), this._valuesStart[i] = this._valuesStartRepeat[i]; } if (this._isPlaying = !0, this._isPaused = !1, this._onStartCallbackFired = !1, this._onEveryStartCallbackFired = !1, this._isChainStopped = !1, this._startTime = t, this._startTime += this._delayTime, !this._propertiesAreSetUp || e) { if (this._propertiesAreSetUp = !0, !this._isDynamic) { var s = {}; for (var o in this._valuesEnd) s[o] = this._valuesEnd[o]; this._valuesEnd = s; } this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, e); } return this; }, n.prototype.startFromCurrentValues = function(t) { return this.start(t, !0); }, n.prototype._setupProperties = function(t, e, i, s, o) { for (var r in i) { var a = t[r], l = Array.isArray(a), c = l ? "array" : typeof a, h = !l && Array.isArray(i[r]); if (!(c === "undefined" || c === "function")) { if (h) { var u = i[r]; if (u.length === 0) continue; for (var d = [a], p = 0, m = u.length; p < m; p += 1) { var g = this._handleRelativeValue(a, u[p]); if (isNaN(g)) { h = !1, console.warn("Found invalid interpolation list. Skipping."); break; } d.push(g); } h && (i[r] = d); } if ((c === "object" || l) && a && !h) { e[r] = l ? [] : {}; var v = a; for (var y in v) e[r][y] = v[y]; s[r] = l ? [] : {}; var u = i[r]; if (!this._isDynamic) { var w = {}; for (var y in u) w[y] = u[y]; i[r] = u = w; } this._setupProperties(v, e[r], u, s[r], o); } else (typeof e[r] == "undefined" || o) && (e[r] = a), l || (e[r] *= 1), h ? s[r] = i[r].slice().reverse() : s[r] = e[r] || 0; } } }, n.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; }, n.prototype.end = function() { return this._goToEnd = !0, this.update(1 / 0), this; }, n.prototype.pause = function(t) { return t === void 0 && (t = Eo()), this._isPaused || !this._isPlaying ? this : (this._isPaused = !0, this._pauseStart = t, this._group && this._group.remove(this), this); }, n.prototype.resume = function(t) { return t === void 0 && (t = Eo()), !this._isPaused || !this._isPlaying ? this : (this._isPaused = !1, this._startTime += t - this._pauseStart, this._pauseStart = 0, this._group && this._group.add(this), this); }, n.prototype.stopChainedTweens = function() { for (var t = 0, e = this._chainedTweens.length; t < e; t++) this._chainedTweens[t].stop(); return this; }, n.prototype.group = function(t) { return t === void 0 && (t = ih), this._group = t, this; }, n.prototype.delay = function(t) { return t === void 0 && (t = 0), this._delayTime = t, this; }, n.prototype.repeat = function(t) { return t === void 0 && (t = 0), this._initialRepeat = t, this._repeat = t, this; }, n.prototype.repeatDelay = function(t) { return this._repeatDelayTime = t, this; }, n.prototype.yoyo = function(t) { return t === void 0 && (t = !1), this._yoyo = t, this; }, n.prototype.easing = function(t) { return t === void 0 && (t = Qi.Linear.None), this._easingFunction = t, this; }, n.prototype.interpolation = function(t) { return t === void 0 && (t = Rs.Linear), this._interpolationFunction = t, this; }, n.prototype.chain = function() { for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e]; return this._chainedTweens = t, this; }, n.prototype.onStart = function(t) { return this._onStartCallback = t, this; }, n.prototype.onEveryStart = function(t) { return this._onEveryStartCallback = t, this; }, n.prototype.onUpdate = function(t) { return this._onUpdateCallback = t, this; }, n.prototype.onRepeat = function(t) { return this._onRepeatCallback = t, this; }, n.prototype.onComplete = function(t) { return this._onCompleteCallback = t, this; }, n.prototype.onStop = function(t) { return this._onStopCallback = t, this; }, n.prototype.update = function(t, e) { var i = this, s; if (t === void 0 && (t = Eo()), e === void 0 && (e = !0), this._isPaused) return !0; var o, r = this._startTime + this._duration; if (!this._goToEnd && !this._isPlaying) { if (t > r) return !1; e && this.start(t, !0); } if (this._goToEnd = !1, t < 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 = t - this._startTime, l = this._duration + ((s = this._repeatDelayTime) !== null && s !== void 0 ? s : this._delayTime), c = this._duration + this._repeat * l, h = function() { if (i._duration === 0 || a > c) return 1; var v = Math.trunc(a / l), y = a - v * l, w = Math.min(y / i._duration, 1); return w === 0 && a === i._duration ? 1 : w; }, u = h(), d = this._easingFunction(u); if (this._updateProperties(this._object, this._valuesStart, this._valuesEnd, d), this._onUpdateCallback && this._onUpdateCallback(this._object, u), this._duration === 0 || a >= this._duration) if (this._repeat > 0) { var p = Math.min(Math.trunc((a - this._duration) / l) + 1, this._repeat); isFinite(this._repeat) && (this._repeat -= p); for (o in this._valuesStartRepeat) !this._yoyo && typeof this._valuesEnd[o] == "string" && (this._valuesStartRepeat[o] = // eslint-disable-next-line // @ts-ignore FIXME? this._valuesStartRepeat[o] + parseFloat(this._valuesEnd[o])), this._yoyo && this._swapEndStartRepeatValues(o), this._valuesStart[o] = this._valuesStartRepeat[o]; return this._yoyo && (this._reversed = !this._reversed), this._startTime += l * p, this._onRepeatCallback && this._onRepeatCallback(this._object), this._onEveryStartCallbackFired = !1, !0; } else { this._onCompleteCallback && this._onCompleteCallback(this._object); for (var m = 0, g = this._chainedTweens.length; m < g; m++) this._chainedTweens[m].start(this._startTime + this._duration, !1); return this._isPlaying = !1, !1; } return !0; }, n.prototype._updateProperties = function(t, e, i, s) { for (var o in i) if (e[o] !== void 0) { var r = e[o] || 0, a = i[o], l = Array.isArray(t[o]), c = Array.isArray(a), h = !l && c; h ? t[o] = this._interpolationFunction(a, s) : typeof a == "object" && a ? this._updateProperties(t[o], r, a, s) : (a = this._handleRelativeValue(r, a), typeof a == "number" && (t[o] = r + (a - r) * s)); } }, n.prototype._handleRelativeValue = function(t, e) { return typeof e != "string" ? e : e.charAt(0) === "+" || e.charAt(0) === "-" ? t + parseFloat(e) : parseFloat(e); }, n.prototype._swapEndStartRepeatValues = function(t) { var e = this._valuesStartRepeat[t], i = this._valuesEnd[t]; typeof i == "string" ? this._valuesStartRepeat[t] = this._valuesStartRepeat[t] + parseFloat(i) : this._valuesStartRepeat[t] = this._valuesEnd[t], this._valuesEnd[t] = e; }, n; }() ), Hb = "23.1.3", Nb = Qh.nextId, un = ih, Gb = un.getAll.bind(un), Wb = un.removeAll.bind(un), Ub = un.add.bind(un), B0 = un.remove.bind(un), Qb = un.update.bind(un), Dd = { Easing: Qi, Group: _0, Interpolation: Rs, now: Eo, Sequence: Qh, nextId: Nb, Tween: _l, VERSION: Hb, getAll: Gb, removeAll: Wb, add: Ub, remove: B0, update: Qb }; function Xb(n, t, e, i = Qi.Linear.None) { const s = new _l(n).to(t, e).easing(i).start(); function o(r) { s.update(r) && requestAnimationFrame(o); } return requestAnimationFrame(o), s; } var os = /* @__PURE__ */ ((n) => (n.Drawline = "Drawline", n.Undo = "Undo", n.Exit = "Exit", n))(os || {}); const Br = Symbol("$$PAINT_BRUSH_EVENT$$"); function Ra(n) { return n[Br] || (n[Br] = {}), n[Br]; } function Yb(n) { n[Br] || delete n[Br]; } let Zb = class { /** * 判断是否注册了事件 * @param name 事件类型 */ hasListener(t) { const e = Ra(this); return e && e[t] && e[t].length > 0; } /** * 注册事件 * @param name 事件类型 * @param callback 事件回调函数 * @param once 是否只执行一次 * @returns 解除事件 * @template K 预设的监听事件名称 * @template C 回调函数函数上下文 */ on(t, e, i) { const s = Ra(this); return s[t] || (s[t] = []), s[t].push([e, i || !1]), () => this.off(t, e); } /** * 注册事件(是否只执行一次) * @param name 事件类型 * @param callback 事件回调函数 * @returns 解除事件 * @template K 预设的监听事件名称 * @template C 回调函数函数上下文 */ once(t, e) { return this.on(t, e, !0); } /** * 解除事件 * * 如果 name 不传的话解除对应所有事件 * 如果 name, callback 不传的话解除所有name的所有事件 * @param name 事件类型 * @param callback 事件回调函数 * @template K 预设的监听事件名称 */ off(t, e) { if (t === void 0) { Yb(this); return; } const i = Ra(this); if (i[t] || (i[t] = []), e === void 0) { i[t].length = 0; return; } let s = 0; for (; s < i[t].length && i[t][s][0] !== e; s++) ; s < i[t].length && i[t].splice(s, 1); } /** * 触发事件 * @param name 事件类型 * @param data 触发事件的数据 * @returns canceled 是否被触发取消 * @template K 预设的监听事件名称 */ emit(t, ...e) { let i = !1; const o = Ra(this)[t] || []; for (let r of o.slice()) { const [a, l = !1] = r, c = a(...e); l && this.off(t, a), c === !1 && (i = !0); } return i; } }; function ns() { return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1); } function Mt() { return (ns() + ns() + "-" + ns() + "-4" + ns().substr(0, 3) + "-" + ns() + "-" + ns() + ns() + ns()).toLowerCase(); } const qb = ` <style type="text/css"> #_gl_paintBrush { position: fixed; top: 0; bottom: 0; left: 0; right: 0; transform: translateZ(0); z-index: 1997; pointer-events: none; opacity: 0; transition: all 500ms; } #_gl_paintBrush.brushing { opacity: 1; } #_gl_paintBrush ._paintBrush-canvas { position: absolute; width: 100%; height: 100%; left: 0; top: 0; } #_gl_paintBrush ._paintBrush-canvas--sync { pointer-events: none; z-index: 0; position: absolute; width: 100%; height: 100%; left: 0; top: 0; } #_gl_paintBrush ._paintBrush-canvas { pointer-events: none; z-index: 1; } #_gl_paintBrush.brushing ._paintBrush-canvas { pointer-events: auto; } #_gl_paintBrush ._paintBrush-ctrl { width: 140px; height: 52px; position: absolute; bottom: 28px; right: 50%; transform: translateX(50%); font-size: 10px; color: white; z-index: 2; } #_gl_paintBrush.brushing ._paintBrush-ctrl { pointer-events: auto; } #_gl_paintBrush ._paintBrush-ctrl ._paintBrush-ctrlinner { display: flex; justify-content: space-between; align-items: center; width: 100%; height: 100%; border-radius: 26px; padding: 8px 16px; box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.2); background-image: linear-gradient(180deg, hsl(0deg 0% 0% / 57%), hsl(0deg 0% 0% / 70%) 117%); } ._paintBrush-ctrlitem { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 38px; height: 38px; cursor: pointer; } ._paintBrush-ctrlitem--undo >.brush-icon{ background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyMnB4IiB2aWV3Qm94PSIwIDAgMjIgMjIiIHZlc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zLjc1ODc1NzA5IEw5Ljg0Mzc1LDMuNzU4NzU3MDkgQzEyLjY5MTQ2ODIsMy43NTg3NTcwOSAxNSw2LjA2NzI4ODg1IDE1LDguOTE1MDA3MDkgQzE1LDExLjc2MjcyNTMgMTIuNjkxNDY4MiwxNC4wNzEyNTcxIDkuODQzNzUsMTQuMDcxMjU3MSBMMSwxNC4wNzEyNTcxIiBzdHJva2U9InVybCgjbGluZWFyR3JhZGllbnQtMSkiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cG9seWxpbmUgc3Ryb2tlPSIjRkZGRkZGIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBwb2ludHM9IjMuNzkwMjI3MDcgNy41Mzk2NjA2NCAwIDMuNzU4NzU3MDkgMy43OTAyMjcwNyAwIj48L3BvbHlsaW5lPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=); background-size: 100%; width: 22px; height: 22px; } ._paintBrush-ctrlitem--close >.brush-icon { background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyMnB4IiB2aWV3Qm94PSIwIDAgMjIgMjIiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8ZGVmcz4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwLjAyMDY5MyUiIHkxPSItMTMuNzMzMzc1MSUiIHgyPSI1MCUiIHkyPSIxMTQuMTEwOTk0JSIgaWQ9ImxpbmVhckdyYWRpZW50LTEiPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRkZGRkZGIiBvZmZzZXQ9IjAlIj48L3N0b3A+CiAg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tMikiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDcuMDAwMDAwLCA2LjAwNDk3NCkgcm90YXRlKC0xMzUuMDAwMDAwKSB0cmFuc2xhdGUoLTcuMDAwMDAwLCAtNi4wMDQ5NzQpICI+PC9wYXRoPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=); background-size: 100%; width: 22px; height: 22px; } </style> `; let Jb = class extends Zb { constructor(e) { super(); f(this, "configs"); f(this, "clientWidth"); f(this, "clientHeight"); f(this, "ready", !1); f(this, "uuid", Mt()); f(this, "tween"); f(this, "tweening", !1); f(this, "container"); f(this, "canvas"); f(this, "data", {}); f(this, "tempLine", {}); this.configs = e, this.clientWidth = document.body.clientWidth, this.clientHeight = document.body.clientHeight, this.container = this.ifInsertToDOM(), this.canvas = {}, this.initCtrl(); } get color() { return this.configs.currentColor; } get state() { return this.data; } get dpr() { return this.configs.DPR || 1; } ifInsertToDOM() { if (this.container) return this.container; if (this.configs.container) this.configs.container.id = "_gl_paintBrush", this.container = this.configs.container; else if (document.getElementById("_gl_paintBrush")) this.container = document.getElementById("_gl_paintBrush"); else { const e = document.createElement("div"); e.id = "_gl_paintBrush", document.body.appendChild(e), this.container = e; } return this.container.innerHTML = qb, this.container; } /** * * @param className 初始化画板 * @returns */ initCanvas(e) { const i = document.createElement("canvas"); i.className = e, i.width = this.clientWidth, i.height = this.clientHeight; const s = i.getContext("2d"); if (s) return s.lineWidth = 5 * this.dpr, s.lineCap = "round", s.lineJoin = "round", this.container.appendChild(i), i; } /** * 初始化操作面板 * @returns */ initCtrl() { const e = document.createElement("div"); e.className = "_paintBrush-ctrl"; const i = document.createElement("div"); i.className = "_paintBrush-ctrlinner"; const s = document.createElement("a"); s.className = "_paintBrush-ctrlitem _paintBrush-ctrlitem--undo", s.addEventListener("click", (a) => { var d; if (a.stopPropagation(), this.configs.onClickUndo && this.configs.onClickUndo(), !this.canvas[this.uuid] || !this.data[this.uuid] || this.data[this.uuid].length === 0) return; const l = this.data[this.uuid].pop(); l && this.emitStateChange({ type: os.Undo, color: this.color, ready: this.ready, state: l, uuid: this.uuid }); const c = (d = this.canvas[this.uuid]) == null ? void 0 : d.getContext("2d"); if (!this.canvas[this.uuid]) return; const { width: h, height: u } = this.canvas[this.uuid]; c && c.clearRect(0, 0, h, u), this.data[this.uuid].forEach((p) => this.handleDrawLine(this.uuid, p, { withUndo: !0 })); }); const o = document.createElement("a"); return o.className = "_paintBrush-ctrlitem _paintBrush-ctrlitem--close", o.addEventListener("click", (a) => { a.stopPropagation(), this.closeBrush(), this.configs.onClickClose && this.configs.onClickClose(); }), [s, o].forEach((a) => { const l = document.createElement("i"); l.className = "brush-icon"; const c = document.createElement("span"); c.className = "brush-txt", c.innerText = a.className.endsWith("undo") ? this.configs.onUndoText : this.configs.onExitText, a.appendChild(l), a.appendChild(c); }), i.appendChild(s), i.appendChild(o), e.appendChild(i), this.container.appendChild(e), e; } openBrush() { if (this.ready) return; this.canvas[this.uuid] || (this.canvas[this.uuid] = this.initCanvas("_paintBrush-canvas")), this.container.className = "brushing"; const e = this.canvas[this.uuid]; e.getContext("2d").clearRect(0, 0, e.width, e.height), this.openBrushHandle(), this.ready = !0, this.emit("readyChange", !0); } closeBrush() { this.ready && (this.container.className = "", this.data = {}, this.tempLine = {}, Object.keys(this.canvas).forEach((e) => { this.canvas[e].ontouchstart = () => !1, this.canvas[e].ontouchmove = () => !1, this.canvas[e].ontouchend = () => !1, this.canvas[e].ontouchcancel = () => !1; const i = this.canvas[e].getContext("2d"); i && i.clearRect(0, 0, this.canvas[e].width, this.canvas[e].height); }), this.ready = !1, this.emit("readyChange", !1), this.emitStateChange({ type: os.Exit, color: this.color, ready: !1, uuid: this.uuid })); } updateCurrentColor(e) { const i = this.canvas[this.uuid]; if (!i) return; const s = i.getContext("2d"); s && (this.configs.currentColor = e, s.strokeStyle = e); } openBrushHandle() { const e = this.canvas[this.uuid]; if (!e) return; const i = e.getContext("2d"); if (!i) return; const s = this.color || "#6D92FF"; i.strokeStyle = s; let o = null, r = [], a, l = [], c = 0; const h = (u, d, p) => { const m = this.color || "#ff0000"; i.strokeStyle = m, i.beginPath(), i.moveTo(u.x, u.y), i.quadraticCurveTo(d.x, d.y, p.x, p.y), i.stroke(); }; e.onmousedown = (u) => { u.preventDefault(), c = Date.now(); const d = u.clientX, p = u.clientY; r = [], r.push({ x: d, y: p }), o = { x: d, y: p }, a = Oa({ x: d, y: p }, this.clientWidth, this.clientHeight), l = []; }, e.onmousemove = (u) => { if (u.preventDefault(), !o) return; const d = Number(u.clientX), p = Number(u.clientY); if (Math.abs(d - o.x) < 5 && Math.abs(p - o.y) < 5 || (r.push({ x: d, y: p }), l.push(Oa({ x: d, y: p }, this.clientWidth, this.clientHeight)), r.length < 3)) return; const { control: m, end: g } = ja(r); !m || !g || (h(o, m, g), o = g); }, e.onmouseup = (u) => { if (u.preventDefault(), o = null, r.length < 3) return; this.data[this.uuid] || (this.data[this.uuid] = []); const d = Date.now() - c, p = { move: Object.assign({}, a), uuid: this.uuid, line: [...l], color: this.color, duration: d < 1280 ? d : d < 2e3 ? 1280 : 0 // 单次笔迹时长超过2000ms不加动画 }; this.data[this.uuid].push(p), Ka(() => { this.emitStateChange({ type: os.Drawline, color: this.color, ready: this.ready, state: p, uuid: this.uuid }); }); }, e.ontouchstart = (u) => { u.preventDefault(), c = Date.now(); const d = u.touches[0].clientX, p = u.touches[0].clientY; r = [], r.push({ x: d, y: p }), o = { x: d, y: p }, a = Oa({ x: d, y: p }, this.clientWidth, this.clientHeight), l = []; }, e.ontouchmove = (u) => { if (u.preventDefault(), !o) return; const d = Number(u.touches[0].clientX), p = Number(u.touches[0].clientY); if (Math.abs(d - o.x) < 5 && Math.abs(p - o.y) < 5 || (r.push({ x: d, y: p }), l.push(Oa({ x: d, y: p }, this.clientWidth, this.clientHeight)), r.length < 3)) return; const { control: m, end: g } = ja(r); !m || !g || (h(o, m, g), o = g); }, e.ontouchend = e.ontouchcancel = (u) => { if (u.preventDefault(), o = null, r.length < 3) return; this.data[this.uuid] || (this.data[this.uuid] = []); const d = Date.now() - c, p = { move: Object.assign({}, a), line: [...l], uuid: this.uuid, color: this.color, duration: d < 1280 ? d : d < 2e3 ? 1280 : 0 // 单次笔迹时长超过2000ms不加动画 }; this.data[this.uuid].push(p), Ka(() => { this.emitStateChange({ type: os.Drawline, color: this.color, ready: this.ready, state: p, uuid: this.uuid }); }); }; } emitStateChange(e, i = !0) { if (e.type !== os.Drawline) { this.emit("stateChange", e, i); return; } const s = Date.now(), o = e.state; if (!o || !o.line) return; const r = Math.ceil(o.line.length / 100); for (let a = 0; a < r; a++) { const l = { uuid: this.uuid, color: this.color, ready: this.ready, type: e.type, state: { uuid: this.uuid, move: o.move, duration: o.duration, color: this.color, line: o.line.slice(a * 100, (a + 1) * 100) }, timestamp: s, end: a === r - 1 }; Vb(a, 20, () => { this.emit("stateChange", l, i); }); } } action(e) { const { ready: i, type: s, uuid: o } = e; if (!i && this.ready) { this.closeBrush(); return; } if (i && !this.ready) { this.openBrush(); return; } if (this.ready) switch (s) { case os.Drawline: const { state: r, timestamp: a, end: l } = e; if (!a || !r) return; this.tempLine[a] = [].concat(this.tempLine[a] || [], r.line), l && (Object.assign(r, { line: this.tempLine[a] }), this.handleDrawLine(o, r, {}, () => delete this.tempLine[a])); break; case os.Undo: this.handleUndo(o); break; } } handleDrawLine(e, i, { withUndo: s = !1 }, o = R0) { !i || Object.prototype.toString.call(i) != "[object Object]" || Object.keys(i).length === 0 || Bb(() => new Promise((r) => { if (s || (this.canvas[e] || (this.canvas[e] = this.initCanvas("_paintBrush-canvas--sync")), this.data[e] || (this.data[e] = []), this.data[e].push(i)), !this.canvas[e]) return; const a = this.canvas[e].getContext("2d"); if (!a) return; const { line: l = [], color: c = "black", duration: h = 0, uuid: u } = i, d = mc(i.move || {}, this.clientWidth, this.clientHeight); let p = [d]; if (a.strokeStyle = c, a.beginPath(), a.moveTo(d.x, d.y), h && !s) { let m = []; const g = this; g.tween = Xb({ step: 0 }, { step: l.length - 1 }, h).onUpdate(({ step: v }) => { var w; if (g.tweening = !0, !g.ready) return a.clearRect(0, 0, g.canvas[u].width, g.canvas[u].height), (w = g.tween) == null ? void 0 : w.stop(); const y = Math.floor(v); if (!m.find((I) => I === y)) { if (m.push(y), p.push(mc(l[y], g.clientWidth, g.clientHeight)), p.length < 3) return; const { control: I, end: C } = ja(p); if (!I || !C) return; a.quadraticCurveTo(I.x, I.y, C.x, C.y), a.stroke(); } }).onComplete((v) => { g.tween = void 0, g.tweening = !1, m = [], p = [], o && o(), r(); }); } else { for (let m = 0; m < l.length; m++) { if (p.push(mc(l[m], this.clientWidth, this.clientHeight)), p.length < 3) continue; const { control: g, end: v } = ja(p); !g || !v || a.quadraticCurveTo(g.x, g.y, v.x, v.y); } a.stroke(), p = [], o && o(), r(); } })); } handleUndo(e) { if (!this.canvas[e] || !this.data[e] || this.data[e].length === 0) return; this.data[e].pop(); const i = () => { var o; const s = (o = this.canvas[e]) == null ? void 0 : o.getContext("2d"); s && s.clearRect(0, 0, this.canvas[e].width, this.canvas[e].height), this.data[e].forEach((r) => this.handleDrawLine(e, r, { withUndo: !0 })); }; if (this.tween && this.tweening) { this.tween.stop(), Ka(i, 60); return; } i(); } destroyBrush() { this.closeBrush(), this.ready = !1, this.emit("readyChange", !0); } }; class QD { constructor(t = {}) { f(this, "controller"); const e = Object.assign({ currentColor: "#f44336", onUndoText: "回退", onExitText: "关闭" }, t); this.controller = new Jb(e); } on(t, e) { this.controller.on(t, e); } off(t, e) { this.controller.off(t, e); } once(t, e) { this.controller.once(t, e); } /** * 显示画笔。 */ show() { this.controller.openBrush(); } action(t) { this.controller.action(t); } /** * 获取画笔状态。 */ get state() { return this.controller.state; } get configs() { return this.controller.configs; } /** * 销毁。 * * @deprecated * * @description 画笔应该维护一个 **全局单例**,重复利用。 */ dispose() { return this.controller.destroyBrush(); } setCurrentColor(t) { this.controller.updateCurrentColor(t); } } function Kb(n) { return typeof Symbol == "undefined" ? `$Symbol<${n}>$` : Symbol(n); } const Vr = Kb("$$EVENT$$"); function Ir(n) { return n[Vr] || (n[Vr] = {}), n[Vr]; } function $b(n) { n[Vr] && delete n[Vr]; } class St { /** * 判断是否注册了事件 * @param name - 事件类型 */ hasListener(t) { const e = Ir(this); return !!(e != null && e[t] && e[t].length > 0); } /** * 注册事件 * @param name - 事件类型 * @param callback - 事件回调函数 * @param once - 是否只执行一次 * @returns 解除事件 * @template K - 预设的监听事件名称 * @template C - 回调函数函数上下文 */ on(t, e, i) { const s = Ir(this); return s[t] || (s[t] = []), s[t].push([e, i || !1]), () => this.off(t, e); } /** * 注册事件(是否只执行一次) * @param name - 事件类型 * @param callback - 事件回调函数 * @returns 解除事件 * @template K - 预设的监听事件名称 * @template C - 回调函数函数上下文 */ once(t, e) { return this.on(t, e, !0); } /** * 解除事件 * * 如果 name 不传的话解除对应所有事件 * 如果 name, callback 不传的话解除所有name的所有事件 * @param name - 事件类型 * @param callback - 事件回调函数 * @template K - 预设的监听事件名称 */ off(t, e) { if (t === void 0) { $b(this); return; } const i = Ir(this); if (i[t] || (i[t] = []), e === void 0) { i[t].length = 0; return; } let s = 0; for (; s < i[t].length && i[t][s][0] !== e; s++) ; s < i[t].length && i[t].splice(s, 1); } /** * 触发事件 * @param name - 事件类型 * @param data - 触发事件的数据 * @returns canceled 是否被触发取消 * @template K - 预设的监听事件名称 */ emit(t, ...e) { let i = !1; const o = Ir(this)[t] || []; for (let r of o.slice()) { const [a, l = !1] = r, c = a(...e); l && this.off(t, a), c === !1 && (i = !0); } return i; } /** * 触发事件并返回监听器的返回值 * @param name - 事件类型 * @param data - 触发事件的数据 * @returns 监听器的返回值数组 * @template K - 预设的监听事件名称 */ emitWithResult(t, ...e) { let i; const o = Ir(this)[t] || []; for (let r of o.slice()) { const [a, l = !1] = r, c = a(...e); i || (i = c), l && this.off(t, a); } return i; } } class nh { constructor(t = 0, e = 0) { f(this, "min"); f(this, "max"); f(this, "isInterval", !0); this.min = t, this.max = e; } fromArray(t) { return this.min = t[0], this.max = t[1], this; } /** 两个区间是否重叠 */ isOverlap(t) { return Math.min(this.max, t.max) < Math.max(this.min, t.min); } /** 是否包含区间 */ contains(t) { return this.min < t.min && this.max > t.max; } } let eA = class { constructor(t, e) { f(this, "min"); f(this, "max"); f(this, "xInterval"); f(this, "yInterval"); f(this, "isRectangle", !0); this.min = t, this.max = e, this.xInterval = new nh(this.min.x, this.max.x), this.yInterval = new nh(this.min.y, this.max.y); } /** 是否与矩形是否重叠 */ isOverlapWithRectangle(t) { return !this.xInterval.isOverlap(t.xInterval) && !this.yInterval.isOverlap(t.yInterval); } /** 是否包含目标矩形 */ containsRect(t) { return this.xInterval.contains(t.xInterval) && this.yInterval.contains(t.yInterval); } }; function tA(n) { n.sort(function(i, s) { return i.x != s.x ? i.x - s.x : i.y - s.y; }); const t = n.length, e = []; for (let i = 0; i < 2 * t; i++) { const s = i < t ? i : 2 * t - 1 - i; for (; e.length >= 2 && iA(e[e.length - 2], e[e.length - 1], n[s]); ) e.pop(); e.push(n[s]); } return e.pop(), e; } function iA(n, t, e) { const i = (n.x - t.x) * (e.y - t.y) - (n.y - t.y) * (e.x - t.x), s = (n.x - t.x) * (e.x - t.x) + (n.y - t.y) * (e.y - t.y); return i < 0 || i == 0 && s <= 0; } function Ld(n, t) { const e = n[0], i = n[1]; let s = !1; for (let o = 0, r = t.length - 1; o < t.length; r = o++) { const a = t[o][0], l = t[o][1], c = t[r][0], h = t[r][1]; l > i != h > i && e < (c - a) * (i - l) / (h - l) + a && (s = !s); } return s; } const nA = ({ x: n, y: t, z: e }) => new pe(n, t, e), Lt = (n) => new pe().fromArray(n), Re = (n) => { if (n) return n instanceof pe ? n : Array.isArray(n) ? Lt(n) : nA(n); }; function sA(n) { if (n) return Array.isArray(n) ? typeof n[0] == "number" ? Re(n) : n.map(Re) : Re(n); } function gc(n, t, e) { const { x: i, y: s, z: o } = t.clone().project(n); return o > 1 ? void 0 : { leftPx: (i + 1) / 2 * e.x, topPx: (-s + 1) / 2 * e.y }; } function Si(n) { var e; return ((e = n.models) == null ? void 0 : e.filter((i) => i.name === n.state.workCode)[0]) || n.model; } class V0 extends St { constructor(e) { super(); f(this, "five"); this.five = e; } } const Vt = (n, t) => { if (!t) return n; const e = new b.Vector3(), i = new b.Quaternion(), s = new b.Vector3(); return t.decompose(e, i, s), n.clone().multiply(s).applyQuaternion(i).add(e); }, vc = /* @__PURE__ */ new Map(); class oA extends V0 { constructor(e) { super(e); f(this, "_workCode"); } get fromType() { var s, o; const e = this.workCode; if (vc.has(e)) return vc.get(e); const i = (o = (s = JSON.parse(this.work.raw.works[0])) == null ? void 0 : s.from_type) != null ? o : "vr"; return vc.set(e, i), i; } /** * @description 设置插件当前的 workCode */ set workCode(e) { this._workCode = e; } /** * @description 获取插件当前的 workCode */ get workCode() { var e; return (e = this._workCode) != null ? e : this.five.state.workCode; } /** * @description 获取当前的 work */ get work() { var e, i; return (i = (e = this.five.works) == null ? void 0 : e.find((s) => s.workCode === this.workCode)) != null ? i : this.five.work; } get observers() { var e; return (e = this.work) == null ? void 0 : e.observers; } get transform() { var i, s, o, r; const e = (r = (i = this.work) == null ? void 0 : i.transform) != null ? r : (o = (s = this.work) == null ? void 0 : s.options) == null ? void 0 : o.transform; return e ? e.clone() : new b.Matrix4(); } getResolvedObserver(e) { return this.five.works.getResolvedObserver({ workCode: this.workCode, panoIndex: e }); } /** * @description 获取全景点坐标 */ getObserverPosition(e) { var s; const i = (s = this.getObserver(e)) == null ? void 0 : s.position; if (i) return Vt(i, this.transform); } /** * @description 获取全景点位和模型的地面坐标 */ getObserverStandingPosition(e) { var s; const i = (s = this.getObserver(e)) == null ? void 0 : s.standingPosition; if (i) return Vt(i, this.transform); } /** * @description 获取observer */ getObserver(e) { var i; return (i = this.observers) == null ? void 0 : i[e]; } } class Bl extends V0 { constructor(e) { super(e); f(this, "workUtil", new oA(this.five)); } get version() { return this.five.constru