@realsee/dnalogel
Version:
1,267 lines (1,254 loc) • 1.5 MB
JavaScript
var Im = Object.defineProperty, Em = Object.defineProperties;
var Mm = Object.getOwnPropertyDescriptors;
var po = Object.getOwnPropertySymbols;
var rc = Object.prototype.hasOwnProperty, ac = Object.prototype.propertyIsEnumerable;
var da = (n, t, e) => t in n ? Im(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, D = (n, t) => {
for (var e in t || (t = {}))
rc.call(t, e) && da(n, e, t[e]);
if (po)
for (var e of po(t))
ac.call(t, e) && da(n, e, t[e]);
return n;
}, se = (n, t) => Em(n, Mm(t));
var vs = (n, t) => {
var e = {};
for (var i in n)
rc.call(n, i) && t.indexOf(i) < 0 && (e[i] = n[i]);
if (n != null && po)
for (var i of po(n))
t.indexOf(i) < 0 && ac.call(n, i) && (e[i] = n[i]);
return e;
};
var d = (n, t, e) => (da(n, typeof t != "symbol" ? t + "" : t, e), e);
var Q = (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 { Camera as km, Subscribe as Tt, Five as dt } from "@realsee/five";
import * as w from "three";
import { Vector3 as oe, LineSegments as xm, Group as Sn, Raycaster as Xn, MeshBasicMaterial as Hs, CanvasTexture as Dm, AnimationMixer as Sm, Color as Zn, TextureLoader as Ku, Vector2 as yt, Object3D as Tm, PlaneGeometry as Lm, sRGBEncoding as jm, LinearFilter as Ga, Mesh as Ss, CurvePath as zm, LineCurve3 as Om, TubeGeometry as Bm, ShaderMaterial as $u, SphereGeometry as Rm, DoubleSide as ef, RingGeometry as Vm, Quaternion as ul, Euler as lc, Matrix4 as Ms, VideoTexture as Hm, Vector4 as Nm, SphereBufferGeometry as Qm } from "three";
import { CSS3DRenderer as Gm, CSS3DObject as Fa } from "three/examples/jsm/renderers/CSS3DRenderer";
import ur from "hammerjs";
import _o from "animejs";
import { Line as Fm, LineGeometry as cc, LineMaterial as _m, THREE_Line2 as Wm } from "@realsee/five/line";
import { FBXLoader as tf } from "three/examples/jsm/loaders/FBXLoader";
import Um from "earcut";
import { GLTFLoader as Ym } from "@realsee/five/gltf-loader";
function Xm() {
console.debug(
"%c %c@realsee/dnalogel %cv3.30.4",
[
"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 Zm() {
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 nf() {
}
const hc = () => Promise.resolve(), dc = {
__queue: Promise.resolve()
};
function Jm(n = hc) {
dc.__queue = dc.__queue.then(n).catch(hc);
}
function Ao(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 ua(n, t, e) {
const { x: i, y: s } = n, o = i * t, r = s * e;
return { x: o, y: r };
}
function vo(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 qm(n, t, e = nf) {
new Promise((i) => {
setTimeout(() => {
e(), i(!0);
}, t * n);
});
}
const Km = window, uc = window.requestAnimationFrame || Km.webkitRequestAnimationFrame || ((n) => setTimeout(n, 16));
function Vo(n, t = 0) {
t <= 0 ? uc(n) : uc(() => Vo(n, t - 1));
}
var Gt = Object.freeze({
Linear: Object.freeze({
None: function(n) {
return n;
},
In: function(n) {
return this.None(n);
},
Out: function(n) {
return this.None(n);
},
InOut: function(n) {
return this.None(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 - Gt.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 ? Gt.Bounce.In(n * 2) * 0.5 : Gt.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;
}
};
}
}), En = function() {
return performance.now();
}, sf = (
/** @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 = En()), 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;
}()
), Wi = {
Linear: function(n, t) {
var e = n.length - 1, i = e * t, s = Math.floor(i), o = Wi.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 = Wi.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 = Wi.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 = Wi.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;
}
}
}, fl = (
/** @class */
function() {
function n() {
}
return n.nextId = function() {
return n._nextId++;
}, n._nextId = 0, n;
}()
), _a = new sf(), fr = (
/** @class */
function() {
function n(t, e) {
e === void 0 && (e = _a), 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 = Gt.Linear.None, this._interpolationFunction = Wi.Linear, this._chainedTweens = [], this._onStartCallbackFired = !1, this._onEveryStartCallbackFired = !1, this._id = fl.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 = En()), 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 f = [a], g = 0, A = u.length; g < A; g += 1) {
var p = this._handleRelativeValue(a, u[g]);
if (isNaN(p)) {
h = !1, console.warn("Found invalid interpolation list. Skipping.");
break;
}
f.push(p);
}
h && (i[r] = f);
}
if ((c === "object" || l) && a && !h) {
e[r] = l ? [] : {};
var m = a;
for (var b in m)
e[r][b] = m[b];
s[r] = l ? [] : {};
var u = i[r];
if (!this._isDynamic) {
var y = {};
for (var b in u)
y[b] = u[b];
i[r] = u = y;
}
this._setupProperties(m, 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 = En()), 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 = En()), !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 = _a), 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 = Gt.Linear.None), this._easingFunction = t, this;
}, n.prototype.interpolation = function(t) {
return t === void 0 && (t = Wi.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 = En()), 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 m = Math.trunc(a / l), b = a - m * l, y = Math.min(b / i._duration, 1);
return y === 0 && a === i._duration ? 1 : y;
}, u = h(), f = this._easingFunction(u);
if (this._updateProperties(this._object, this._valuesStart, this._valuesEnd, f), this._onUpdateCallback && this._onUpdateCallback(this._object, u), this._duration === 0 || a >= this._duration)
if (this._repeat > 0) {
var g = Math.min(Math.trunc((a - this._duration) / l) + 1, this._repeat);
isFinite(this._repeat) && (this._repeat -= g);
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 * g, this._onRepeatCallback && this._onRepeatCallback(this._object), this._onEveryStartCallbackFired = !1, !0;
} else {
this._onCompleteCallback && this._onCompleteCallback(this._object);
for (var A = 0, p = this._chainedTweens.length; A < p; A++)
this._chainedTweens[A].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;
}()
), $m = "23.1.1", ep = fl.nextId, ti = _a, tp = ti.getAll.bind(ti), ip = ti.removeAll.bind(ti), np = ti.add.bind(ti), of = ti.remove.bind(ti), sp = ti.update.bind(ti), fc = {
Easing: Gt,
Group: sf,
Interpolation: Wi,
now: En,
Sequence: fl,
nextId: ep,
Tween: fr,
VERSION: $m,
getAll: tp,
removeAll: ip,
add: np,
remove: of,
update: sp
};
function op(n, t, e, i = Gt.Linear.None) {
const s = new fr(n).to(t, e).easing(i).start();
function o(r) {
s.update(r) && requestAnimationFrame(o);
}
return requestAnimationFrame(o), s;
}
var Ii = /* @__PURE__ */ ((n) => (n.Drawline = "Drawline", n.Undo = "Undo", n.Exit = "Exit", n))(Ii || {});
const Ts = Symbol("$$PAINT_BRUSH_EVENT$$");
function bo(n) {
return n[Ts] || (n[Ts] = {}), n[Ts];
}
function rp(n) {
n[Ts] || delete n[Ts];
}
let ap = class {
/**
* 判断是否注册了事件
* @param name 事件类型
*/
hasListener(t) {
const e = bo(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 = bo(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) {
rp(this);
return;
}
const i = bo(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 = bo(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 Ci() {
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
}
function nt() {
return (Ci() + Ci() + "-" + Ci() + "-4" + Ci().substr(0, 3) + "-" + Ci() + "-" + Ci() + Ci() + Ci()).toLowerCase();
}
const lp = `
<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,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyMnB4IiB2aWV3Qm94PSIwIDAgMjIgMjIiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8ZGVmcz4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjQ1LjY3NTI0OCUiIHgyPSItMTYuOTYxMDIzJSIgeTI9Ijg0LjIzODQxOTglIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkZGRkYiIG9mZnNldD0iMCUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgc3RvcC1vcGFjaXR5PSIwLjMwMzY3Njc5MiIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZGVmcz4KICAgIDxnIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xNDAuMDAwMDAwLCAtNzQwLjAwMDAwMCkiPgogICAgICAgICAgICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxNDAuMDAwMDAwLCA3NDAuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8cmVjdCBmaWxsPSIjRDhEOEQ4IiBvcGFjaXR5PSIwIiB4PSIwIiB5PSIwIiB3aWR0aD0iMjIiIGhlaWdodD0iMjIiPjwvcmVjdD4KICAgICAgICAgICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDQuMDAwMDAwLCAyLjk5MDY1OSkiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMCwzLjc1ODc1NzA5IEw5Ljg0Mzc1LDMuNzU4NzU3MDkgQzEyLjY5MTQ2ODIsMy43NTg3NTcwOSAxNSw2LjA2NzI4ODg1IDE1LDguOTE1MDA3MDkgQzE1LDExLjc2MjcyNTMgMTIuNjkxNDY4MiwxNC4wNzEyNTcxIDkuODQzNzUsMTQuMDcxMjU3MSBMMSwxNC4wNzEyNTcxIiBzdHJva2U9InVybCgjbGluZWFyR3JhZGllbnQtMSkiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cG9seWxpbmUgc3Ryb2tlPSIjRkZGRkZGIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBwb2ludHM9IjMuNzkwMjI3MDcgNy41Mzk2NjA2NCAwIDMuNzU4NzU3MDkgMy43OTAyMjcwNyAwIj48L3BvbHlsaW5lPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=);
background-size: 100%;
width: 22px;
height: 22px;
}
._paintBrush-ctrlitem--close >.brush-icon {
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyMnB4IiB2aWV3Qm94PSIwIDAgMjIgMjIiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8ZGVmcz4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwLjAyMDY5MyUiIHkxPSItMTMuNzMzMzc1MSUiIHgyPSI1MCUiIHkyPSIxMTQuMTEwOTk0JSIgaWQ9ImxpbmVhckdyYWRpZW50LTEiPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRkZGRkZGIiBvZmZzZXQ9IjAlIj48L3N0b3A+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkZGRkYiIHN0b3Atb3BhY2l0eT0iMC42MDEwNDM0ODgiIG9mZnNldD0iNDkuMzA4NDg4MiUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMTAwJSIgaWQ9ImxpbmVhckdyYWRpZW50LTIiPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRkZGRkZGIiBvZmZzZXQ9IjAlIj48L3N0b3A+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGRkZGRkYiIG9mZnNldD0iNTUuOTY4MTUzNSUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZGVmcz4KICAgIDxnIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnPgogICAgICAgICAgICA8cmVjdCBmaWxsPSIjRDhEOEQ4IiBvcGFjaXR5PSIwIiB4PSIwIiB5PSIwIiB3aWR0aD0iMjIiIGhlaWdodD0iMjIiPjwvcmVjdD4KICAgICAgICAgICAgPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNC4wMDAwMDAsIDUuMDAwMDAwKSIgZmlsbC1ydWxlPSJub256ZXJvIj4KICAgICAgICAgICAgICAgIDxnPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik03LC0yLjk4ODE2NTY4IEM3LjUxMjgzNTg0LC0yLjk4ODE2NTY4IDcuOTM1NTA3MTYsLTIuNjAyMTI1NDkgNy45OTMyNzIyNywtMi4xMDQ3ODY4MSBMOCwtMS45ODgxNjU2OCBMOCwxMy45OTgxMTQ2IEM4LDE0LjU1MDM5OTMgNy41NTIyODQ3NSwxNC45OTgxMTQ2IDcsMTQuOTk4MTE0NiBDNi40ODcxNjQxNiwxNC45OTgxMTQ2IDYuMDY0NDkyODQsMTQuNjEyMDc0NCA2LjAwNjcyNzczLDE0LjExNDczNTcgTDYsMTMuOTk4MTE0NiBMNiwtMS45ODgxNjU2OCBDNiwtMi41NDA0NTA0MyA2LjQ0NzcxNTI1LC0yLjk4ODE2NTY4IDcsLTIuOTg4MTY1NjggWiIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNy4wMDAwMDAsIDYuMDA0OTc0KSByb3RhdGUoLTQ1LjAwMDAwMCkgdHJhbnNsYXRlKC03LjAwMDAwMCwgLTYuMDA0OTc0KSAiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNNywtMi45ODgxNjU2OCBDNy41MTI4MzU4NCwtMi45ODgxNjU2OCA3LjkzNTUwNzE2LC0yLjYwMjEyNTQ5IDcuOTkzMjcyMjcsLTIuMTA0Nzg2ODEgTDgsLTEuOTg4MTY1NjggTDgsMTMuOTk4MTE0NiBDOCwxNC41NTAzOTkzIDcuNTUyMjg0NzUsMTQuOTk4MTE0NiA3LDE0Ljk5ODExNDYgQzYuNDg3MTY0MTYsMTQuOTk4MTE0NiA2LjA2NDQ5Mjg0LDE0LjYxMjA3NDQgNi4wMDY3Mjc3MywxNC4xMTQ3MzU3IEw2LDEzLjk5ODExNDYgTDYsLTEuOTg4MTY1NjggQzYsLTIuNTQwNDUwNDMgNi40NDc3MTUyNSwtMi45ODgxNjU2OCA3LC0yLjk4ODE2NTY4IFoiIGZpbGw9InVybCgjbGluZWFyR3JhZGllbnQtMikiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDcuMDAwMDAwLCA2LjAwNDk3NCkgcm90YXRlKC0xMzUuMDAwMDAwKSB0cmFuc2xhdGUoLTcuMDAwMDAwLCAtNi4wMDQ5NzQpICI+PC9wYXRoPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=);
background-size: 100%;
width: 22px;
height: 22px;
}
</style>
`;
let cp = class extends ap {
constructor(e) {
super();
d(this, "configs");
d(this, "clientWidth");
d(this, "clientHeight");
d(this, "ready", !1);
d(this, "uuid", nt());
d(this, "tween");
d(this, "tweening", !1);
d(this, "container");
d(this, "canvas");
d(this, "data", {});
d(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 = lp, 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 f;
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: Ii.Undo,
color: this.color,
ready: this.ready,
state: l,
uuid: this.uuid
});
const c = (f = this.canvas[this.uuid]) == null ? void 0 : f.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((g) => this.handleDrawLine(this.uuid, g, { 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: Ii.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, f, g) => {
const A = this.color || "#ff0000";
i.strokeStyle = A, i.beginPath(), i.moveTo(u.x, u.y), i.quadraticCurveTo(f.x, f.y, g.x, g.y), i.stroke();
};
e.onmousedown = (u) => {
u.preventDefault(), c = Date.now();
const f = u.clientX, g = u.clientY;
r = [], r.push({ x: f, y: g }), o = { x: f, y: g }, a = Ao({ x: f, y: g }, this.clientWidth, this.clientHeight), l = [];
}, e.onmousemove = (u) => {
if (u.preventDefault(), !o)
return;
const f = Number(u.clientX), g = Number(u.clientY);
if (Math.abs(f - o.x) < 5 && Math.abs(g - o.y) < 5 || (r.push({ x: f, y: g }), l.push(Ao({ x: f, y: g }, this.clientWidth, this.clientHeight)), r.length < 3))
return;
const { control: A, end: p } = vo(r);
!A || !p || (h(o, A, p), o = p);
}, e.onmouseup = (u) => {
if (u.preventDefault(), o = null, r.length < 3)
return;
this.data[this.uuid] || (this.data[this.uuid] = []);
const f = Date.now() - c, g = {
move: Object.assign({}, a),
uuid: this.uuid,
line: [...l],
color: this.color,
duration: f < 1280 ? f : f < 2e3 ? 1280 : 0
// 单次笔迹时长超过2000ms不加动画
};
this.data[this.uuid].push(g), Vo(() => {
this.emitStateChange({
type: Ii.Drawline,
color: this.color,
ready: this.ready,
state: g,
uuid: this.uuid
});
});
}, e.ontouchstart = (u) => {
u.preventDefault(), c = Date.now();
const f = u.touches[0].clientX, g = u.touches[0].clientY;
r = [], r.push({ x: f, y: g }), o = { x: f, y: g }, a = Ao({ x: f, y: g }, this.clientWidth, this.clientHeight), l = [];
}, e.ontouchmove = (u) => {
if (u.preventDefault(), !o)
return;
const f = Number(u.touches[0].clientX), g = Number(u.touches[0].clientY);
if (Math.abs(f - o.x) < 5 && Math.abs(g - o.y) < 5 || (r.push({ x: f, y: g }), l.push(Ao({ x: f, y: g }, this.clientWidth, this.clientHeight)), r.length < 3))
return;
const { control: A, end: p } = vo(r);
!A || !p || (h(o, A, p), o = p);
}, e.ontouchend = e.ontouchcancel = (u) => {
if (u.preventDefault(), o = null, r.length < 3)
return;
this.data[this.uuid] || (this.data[this.uuid] = []);
const f = Date.now() - c, g = {
move: Object.assign({}, a),
line: [...l],
uuid: this.uuid,
color: this.color,
duration: f < 1280 ? f : f < 2e3 ? 1280 : 0
// 单次笔迹时长超过2000ms不加动画
};
this.data[this.uuid].push(g), Vo(() => {
this.emitStateChange({
type: Ii.Drawline,
color: this.color,
ready: this.ready,
state: g,
uuid: this.uuid
});
});
};
}
emitStateChange(e, i = !0) {
if (e.type !== Ii.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
};
qm(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 Ii.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 Ii.Undo:
this.handleUndo(o);
break;
}
}
handleDrawLine(e, i, { withUndo: s = !1 }, o = nf) {
!i || Object.prototype.toString.call(i) != "[object Object]" || Object.keys(i).length === 0 || Jm(() => 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, f = ua(i.move || {}, this.clientWidth, this.clientHeight);
let g = [f];
if (a.strokeStyle = c, a.beginPath(), a.moveTo(f.x, f.y), h && !s) {
let A = [];
const p = this;
p.tween = op({ step: 0 }, { step: l.length - 1 }, h).onUpdate(({ step: m }) => {
var y;
if (p.tweening = !0, !p.ready)
return a.clearRect(0, 0, p.canvas[u].width, p.canvas[u].height), (y = p.tween) == null ? void 0 : y.stop();
const b = Math.floor(m);
if (!A.find((P) => P === b)) {
if (A.push(b), g.push(ua(l[b], p.clientWidth, p.clientHeight)), g.length < 3)
return;
const { control: P, end: I } = vo(g);
if (!P || !I)
return;
a.quadraticCurveTo(P.x, P.y, I.x, I.y), a.stroke();
}
}).onComplete((m) => {
p.tween = void 0, p.tweening = !1, A = [], g = [], o && o(), r();
});
} else {
for (let A = 0; A < l.length; A++) {
if (g.push(ua(l[A], this.clientWidth, this.clientHeight)), g.length < 3)
continue;
const { control: p, end: m } = vo(g);
!p || !m || a.quadraticCurveTo(p.x, p.y, m.x, m.y);
}
a.stroke(), g = [], 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(), Vo(i, 60);
return;
}
i();
}
destroyBrush() {
this.closeBrush(), this.ready = !1, this.emit("readyChange", !0);
}
};
class B3 {
constructor(t = {}) {
d(this, "controller");
const e = Object.assign({
currentColor: "#f44336",
onUndoText: "回退",
onExitText: "关闭"
}, t);
this.controller = new cp(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);
}
}
const R3 = (n, t) => {
var G, H;
let e = (H = (G = t == null ? void 0 : t.initialState) == null ? void 0 : G.enabled) != null ? H : !0, i = !1, s = !0, o = null;
const a = D(D({}, {
lookAtCurrentCamera: !1,
lockedPanoIndex: null,
lockedLatitude: null,
lockedLongitude: null
}), t == null ? void 0 : t.config), l = new w.Scene(), c = new km(60);
let h = new w.Object3D(), u, f;
{
const F = new w.DirectionalLight(16777215, 0.5);
F.position.copy(new w.Vector3(1, 1, 1)), l.add(F);
}
{
const F = new w.DirectionalLight(16777215, 0.3);
l.add(F);
}
{
const F = new w.AmbientLight(16777215, 0.3);
l.add(F);
}
l.add(h);
const g = () => {
if (i)
return;
u = k(n.model, c.fov, c.aspect), f = n.model.bounding.getCenter(new w.Vector3()), l.remove(h), h = U(n.model), l.add(h), i = !0, j();
function F(Z) {
const X = Z.clone();
return X.uniforms.modelAlpha.value = 1, X.uniforms.map.value && (X.uniforms.map.value.needsUpdate = !0), X;
}
function U(Z) {
if (Z instanceof w.Mesh) {
const X = Z.geometry, $ = Array.isArray(Z.material) ? Z.material.map(F) : F(Z.material);
return new w.Mesh(X, $);
} else if (Z instanceof w.Group) {
const X = new w.Group();
return Z.children.forEach(($) => X.add(U($))), X;
} else {
const X = new w.Object3D();
return Z.children.forEach(($) => X.add(U($))), X;
}
}
}, A = () => {
if (n.renderer)
return o || (o = new w.WebGLRenderer({ antialias: !1, alpha: !0 }), o.setPixelRatio(n.renderer.getPixelRatio()), o.outputEncoding = w.sRGBEncoding, o.setClearColor(1579548, 0), o.autoClear = !0), o;
}, p = () => {
h.traverse((F) => {
F instanceof w.Mesh && [].concat(F.material).forEach((Z) => Z.dispose());
}), l.remove(h), h = new w.Object3D(), l.add(h), i = !1, j();
}, m = () => {
e && (i || g());
}, b = () => {
e || (e = !0, l.add(h), !i && n.model.loaded && g(), j());
}, y = () => {
e && (l.remove(h), s = !0, V(), e = !1);
}, P = (F, U = {}) => {
const Z = A();
if (!Z)
return;
F.appendChild(Z.domElement), I(U);
const X = window.getComputedStyle(F).position;
X !== "relative" && X !== "absolute" && X !== "fixed" && X !== "sticky" && (F.style.position = "relative");
}, I = (F = {}) => {
if (!o)
return;
const Z = o.domElement.parentNode;
if (Z != null && Z.nodeName) {
const { width: X = Z.offsetWidth, height: $ = Z.offsetHeight } = F;
o.setSize(X, $), c.aspect = X / $, c.updateProjectionMatrix();
}
j();
};
function k(F, U, Z) {
const X = F.bounding, $ = Math.pow(
Math.pow(X.max.x - X.min.x + 1, 2) + Math.pow(X.max.y - X.min.y + 1, 2) + Math.pow(X.max.z - X.min.z + 1, 2),
1 / 2
);
let de = $ / 2 / Math.tan(Math.PI * U / 360);
return Z < 1 && (de = de / Z), isNaN(de) ? $ : de;
}
function E(F) {
return n.work.observers[F].standingPosition.clone();
}
const j = () => {
if (!e || !u || !f)
return;
const F = n.getPose();
F.fov = c.fov, F.offset = f, F.distance = u, typeof a.lockedLatitude == "number" && (F.latitude = a.lockedLatitude), typeof a.lockedLongitude == "number" && (F.longitude = a.lockedLongitude), typeof a.lockedPanoIndex == "number" && (F.offset = E(a.lockedPanoIndex)), a.lookAtCurrentCamera && (F.offset = n.camera.position.clone().setY(n.camera.position.y + 1)), c.setFromPose(F), s = !0;
}, V = () => {
!e || s !== !0 || !o || !o.domElement.parentNode || o.domElement.parentNode.offsetWidth === 0 || (o.render(l, c), s = !1);
}, W = () => {
o && o.dispose(), o = null;
}, _ = (F) => {
Object.assign(a, F), j();
}, N = () => ({
enabled: e
});
return Object.assign(window, { camera: c }), n.on("modelLoaded", m), n.on("modelWillLoad", p), n.on("cameraDirectionUpdate", j), n.on("dispose", W), n.on("renderFrame", V), n.on("cameraPositionUpdate", j), { appendTo: P, refresh: I, changeConfigs: _, enable: b, disable: y, getCurrentState: N };
}, hp = ({ x: n, y: t, z: e }) => new oe(n, t, e), fi = (n) => new oe().fromArray(n), Be = (n) => {
if (n)
return n instanceof oe ? n : Array.isArray(n) ? fi(n) : hp(n);
};
function dp(n) {
if (n)
return Array.isArray(n) ? typeof n[0] == "number" ? Be(n) : n.map(Be) : Be(n);
}
function pi(n) {
return arguments.length === 0 ? [] : Array.isArray(n) ? n : [n];
}
function qi(n) {
const t = [];
return pi(n).forEach((i) => {
i.traverse((s) => {
s.isCSS3DObjectPlus && t.push(s);
});
}), t;
}
function Wo(n, t) {
const e = Math.round(n);
return e % 2 === 0 ? e : e + (t != null && t.floor ? -1 : 1);
}
function up(n, t, e = !0) {
if (!n)
return console.error("createResizeObserver: element is undefined"), { observe: () => {
}, unobserve: () => {
} };
const i = () => {
const o = Wo(n.clientWidth, { floor: !0 }), r = Wo(n.clientHeight, { floor: !0 });
t(o, r);
};
if (typeof ResizeObserver == "undefined" || !ResizeObserver)
return console.warn("createResizeObserver: ResizeObserver is undefined"), { observe: () => i(), unobserve: () => {
} };
const s = new ResizeObserver(i);
return e && i(), {
observe: () => s.observe(n),
unobserve: () => s.unobserve(n)
};
}
class gc extends Gm {
constructor() {
super();
d(this, "wrapper");
d(this, "requestAnimationFrameId");
d(this, "resizeDisoper");
this.domElement.classList.add("ICSS3DRenderer"), this.domElement.style.position = "absolute", this.domElement.style.top = "0", this.domElement.style.left = "0", this.domElement.style.userSelect = "none", this.domElement.style.pointerEvents = "none";
}
setWrapper(e) {
if (!e)
throw new Error("CSS3DRenderer: wrapper is required");
if (e.contains(this.domElement))
return;
const i = this.wrapper;
return i && i.contains(this.domElement) && this.domElement.remove(), this.appendToElement(e), this.wrapper = e, this;
}
appendToElement(e) {
e.appendChild(this.domElement);
const i = (r, a) => this.setSize(r, a), { observe: s, unobserve: o } = up(e, i, !0);
s(), this.resizeDisoper = o, this.wrapper = e;
}
renderEveryFrame(e, i) {
if (this.wrapper || console.warn("wrapper is not find, creating a html element and call setWrapper(wrapper)", this, e), this.requestAnimationFrameId)
return;
const s = () => {
this.requestAnimationFrameId = requestAnimationFrame(s), e.visible && qi(e).length !== 0 && this.render(e, i);
};
s();
}
stopRender() {
this.requestAnimationFrameId && cancelAnimationFrame(this.requestAnimationFrameId);
}
dispose() {
var e;
this.stopRender(), (e = this.resizeDisoper) == null || e.call(this), this.domElement.remove();
}
}
function fp(n) {
return typeof Symbol == "undefined" ? `$Symbol<${n}>$` : Symbol(n);
}
const Ls = fp("$$EVENT$$");
function yo(n) {
return n[Ls] || (n[Ls] = {}), n[Ls];
}
function gp(n) {
n[Ls] && delete n[Ls];
}
class ii {
/**
* 判断是否注册了事件
* @param name - 事件类型
*/
hasListener(t) {
const e = yo(this);
return !!(e != null && e[t] && e[t].length > 0);
}
/**
* 注册事件
* @param name - 事件类型
* @param callback - 事件回调函数
* @param