soonspacejs
Version:
soonspacejs 2.x
1,412 lines • 754 kB
JavaScript
import * as qn from "three";
import { Vector3 as O, Euler as Fe, Box3 as gn, Scene as qa, Quaternion as De, Object3D as gt, MathUtils as at, CubeTextureLoader as ml, HalfFloatType as pn, EquirectangularReflectionMapping as Hr, Color as Re, Texture as yn, FileLoader as pi, ImageLoader as gl, TextureLoader as Ka, Vector2 as Ce, Matrix4 as ie, BufferAttribute as bt, Vector4 as Zt, CurvePath as yl, LineCurve as vl, LineCurve3 as xl, Line3 as Xa, Matrix3 as vn, Skeleton as fi, AnimationClip as Vt, VectorKeyframeTrack as tn, InterpolateLinear as er, QuaternionKeyframeTrack as nn, EventDispatcher as wl, LoopPingPong as bl, InterpolateDiscrete as Ml, Bone as _s, SkinnedMesh as mi, Uint16BufferAttribute as Ln, Float32BufferAttribute as ke, StringKeyframeTrack as Sl, ColorKeyframeTrack as Tl, NumberKeyframeTrack as Ya, BooleanKeyframeTrack as Cl, KeyframeTrack as Pl, NormalAnimationBlendMode as Dl, FogExp2 as Il, MeshStandardMaterial as Mt, MeshPhongMaterial as gi, MeshPhysicalMaterial as Al, Mesh as je, LineSegments as qr, LineBasicMaterial as Kn, BufferGeometry as st, EdgesGeometry as El, OrthographicCamera as xn, PerspectiveCamera as tr, InstancedMesh as Qa, DynamicDrawUsage as Ll, NoToneMapping as Ns, SRGBColorSpace as Rt, Frustum as Ol, REVISION as yi, WebGLCoordinateSystem as qi, ColorManagement as wr, LinearMipmapLinearFilter as Fl, UnsignedByteType as Ki, DoubleSide as xt, BackSide as Xn, FrontSide as Vs, LinearSRGBColorSpace as Za, RGBAIntegerFormat as Rl, RGIntegerFormat as Bl, RedIntegerFormat as kl, UnsignedIntType as Ja, UnsignedShortType as zl, UnsignedInt248Type as Ul, UnsignedShort4444Type as Nl, UnsignedShort5551Type as Gl, PCFSoftShadowMap as jl, Spherical as pt, Sphere as nr, ShaderMaterial as Ut, WebGLRenderTarget as an, RGBAFormat as Tn, LinearFilter as Nt, DataTexture as Wl, NoColorSpace as _l, RepeatWrapping as Ht, NearestFilter as rn, RedFormat as Vl, FloatType as Hl, DepthTexture as ql, GLBufferAttribute as Kl, InterleavedBufferAttribute as Xl, Raycaster as On, BoxGeometry as Yl, Sprite as un, MeshBasicMaterial as Fn, CanvasTexture as vi, SpriteMaterial as Kr, PMREMGenerator as Ql, AnimationMixer as Zl, Clock as Jl, NeutralToneMapping as $l, AgXToneMapping as ec, ACESFilmicToneMapping as tc, CineonToneMapping as nc, ReinhardToneMapping as sc, UVMapping as rc, CubeTexture as ic, SphereGeometry as Xi, CircleGeometry as ac, PlaneGeometry as Rn, ExtrudeGeometry as oc, Shape as $a, Box2 as Xr, Group as Hs, Triangle as eo, VideoTexture as lc, ShapeGeometry as cc, Plane as hc, AmbientLight as to, DirectionalLight as no, HemisphereLight as uc, SpotLight as so, PointLight as Yr, RectAreaLight as dc, Loader as qs, LoaderUtils as pc, ClampToEdgeWrapping as Yi, PropertyBinding as Ks, Line as fc, ShapeUtils as mc, Material as Qi, PointsMaterial as xs, Points as br, LoadingManager as gc, GridHelper as yc, AxesHelper as vc, Box3Helper as xc, DirectionalLightHelper as wc, HemisphereLightHelper as bc, SpotLightHelper as Mc, PointLightHelper as Sc } from "three";
import * as Zi from "three/examples/jsm/libs/tween.module.js";
import Qr, { Easing as ze, Tween as Tc } from "three/examples/jsm/libs/tween.module.js";
import Yn from "camera-controls";
import { HDRLoader as Cc } from "three/examples/jsm/loaders/HDRLoader.js";
import { GLTFExporter as Pc } from "three/examples/jsm/exporters/GLTFExporter.js";
import { Pass as Dc, EffectPass as Ji, EffectComposer as Ic, RenderPass as Ac, NormalPass as Ec, SMAAEffect as Lc, EdgeDetectionMode as Oc, SMAAPreset as Fc, ToneMappingEffect as Rc, ToneMappingMode as In, BloomEffect as Bc, BlendFunction as $i, OutlineEffect as kc } from "postprocessing";
import { RoomEnvironment as zc } from "three/examples/jsm/environments/RoomEnvironment.js";
import Uc from "three/examples/jsm/libs/stats.module.js";
import { Sky as Nc } from "three/examples/jsm/objects/Sky.js";
import { mergeGeometries as Gc, deinterleaveGeometry as jc } from "three/examples/jsm/utils/BufferGeometryUtils.js";
import { WebGLAnimation as Wc } from "three/src/renderers/webgl/WebGLAnimation.js";
import { WebGLAttributes as _c } from "three/src/renderers/webgl/WebGLAttributes.js";
import { WebGLBackground as Vc } from "three/src/renderers/webgl/WebGLBackground.js";
import { WebGLBindingStates as Hc } from "three/src/renderers/webgl/WebGLBindingStates.js";
import { WebGLBufferRenderer as qc } from "three/src/renderers/webgl/WebGLBufferRenderer.js";
import { WebGLCapabilities as Kc } from "three/src/renderers/webgl/WebGLCapabilities.js";
import { WebGLClipping as Xc } from "three/src/renderers/webgl/WebGLClipping.js";
import { WebGLCubeMaps as Yc } from "three/src/renderers/webgl/WebGLCubeMaps.js";
import { WebGLCubeUVMaps as Qc } from "three/src/renderers/webgl/WebGLCubeUVMaps.js";
import { WebGLExtensions as Zc } from "three/src/renderers/webgl/WebGLExtensions.js";
import { WebGLGeometries as Jc } from "three/src/renderers/webgl/WebGLGeometries.js";
import { WebGLIndexedBufferRenderer as $c } from "three/src/renderers/webgl/WebGLIndexedBufferRenderer.js";
import { WebGLInfo as eh } from "three/src/renderers/webgl/WebGLInfo.js";
import { WebGLMorphtargets as th } from "three/src/renderers/webgl/WebGLMorphtargets.js";
import { WebGLObjects as nh } from "three/src/renderers/webgl/WebGLObjects.js";
import { WebGLPrograms as sh } from "three/src/renderers/webgl/WebGLPrograms.js";
import { WebGLProperties as rh } from "three/src/renderers/webgl/WebGLProperties.js";
import { WebGLRenderLists as ih } from "three/src/renderers/webgl/WebGLRenderLists.js";
import { WebGLRenderStates as ah } from "three/src/renderers/webgl/WebGLRenderStates.js";
import { WebGLRenderTarget as oh } from "three/src/renderers/WebGLRenderTarget.js";
import { WebGLShadowMap as lh } from "three/src/renderers/webgl/WebGLShadowMap.js";
import { WebGLState as ch } from "three/src/renderers/webgl/WebGLState.js";
import { WebGLTextures as hh } from "three/src/renderers/webgl/WebGLTextures.js";
import { WebGLUniforms as Mr } from "three/src/renderers/webgl/WebGLUniforms.js";
import { WebGLUtils as uh } from "three/src/renderers/webgl/WebGLUtils.js";
import { WebXRManager as dh } from "three/src/renderers/webxr/WebXRManager.js";
import { WebGLMaterials as ph } from "three/src/renderers/webgl/WebGLMaterials.js";
import { WebGLUniformsGroups as fh } from "three/src/renderers/webgl/WebGLUniformsGroups.js";
import { createCanvasElement as mh, error as Cn, warn as gh, log as ea, warnOnce as ta, probeAsync as yh } from "three/src/utils.js";
import { getDFGLUT as vh } from "three/src/renderers/shaders/DFGLUTData.js";
import "three/examples/jsm/postprocessing/Pass.js";
import { WorkerPool as ro } from "three/examples/jsm/utils/WorkerPool.js";
import { MeshBVH as xh, computeBoundsTree as wh, disposeBoundsTree as bh, acceleratedRaycast as Mh } from "three-mesh-bvh";
import { RectAreaLightUniformsLib as Sh } from "three/examples/jsm/lights/RectAreaLightUniformsLib.js";
import { GLTFLoader as Th } from "three/examples/jsm/loaders/GLTFLoader.js";
import { STLLoader as Ch } from "three/examples/jsm/loaders/STLLoader.js";
import { TGALoader as Ph } from "three/examples/jsm/loaders/TGALoader.js";
import { DRACOLoader as Dh } from "three/examples/jsm/loaders/DRACOLoader.js";
import { KTX2Loader as Ih } from "three/examples/jsm/loaders/KTX2Loader.js";
import { MeshoptDecoder as Ah } from "three/examples/jsm/libs/meshopt_decoder.module.js";
import * as na from "three/examples/jsm/utils/SkeletonUtils.js";
import * as Eh from "three/examples/jsm/libs/fflate.module.js";
import { NURBSCurve as Lh } from "three/examples/jsm/curves/NURBSCurve.js";
import { RectAreaLightHelper as Oh } from "three/examples/jsm/helpers/RectAreaLightHelper.js";
const Fh = "soonspacejs", Rh = "2.14.29", sa = {
name: Fh,
version: Rh
}, io = "[soonspacejs]: ";
var Bt = /* @__PURE__ */ ((a) => (a.Group = "Group", a.Light = "Light", a.Model = "Model", a.Poi = "Poi", a.PoiNode = "PoiNode", a.Canvas3D = "Canvas3D", a.Topology = "Topology", a.Helper = "Helper", a.Decal = "Decal", a.PluginObject = "PluginObject", a))(Bt || {}), ln = /* @__PURE__ */ ((a) => (a.sbm = "SBM", a.sbmx = "SBMX", a.glb = "GLB", a.gltf = "GLTF", a.fbx = "FBX", a.obj = "OBJ", a.stl = "STL", a))(ln || {});
const Qn = "In soonspacejs: ", dn = (a, e) => {
let t = "";
for (const n in e) t += `${n}: ${e[n]};`;
console.log(`%c${a}`, t);
}, Xs = {}, X = (a) => {
a in Xs || (Xs[a] = !0, console.warn(Qn + a));
}, xi = (a) => {
a in Xs || (Xs[a] = !0, console.error(Qn + a));
};
function We(a) {
return a instanceof O ? a : new O(a.x, a.y, a.z);
}
function wi(a) {
return a instanceof Fe ? a : new Fe(a.x, a.y, a.z);
}
function Bn(a, e) {
const t = new gn();
return a instanceof qa ? a.children.filter((n) => !("isTransformControls" in n)).reduce((n, s) => n.union(new gn().setFromObject(s, e)), t) : t.setFromObject(a, e), t.isEmpty() && (a.getWorldPosition(t.min), t.max.copy(t.min)), t;
}
function Gs(a, e, t) {
const n = t.clone();
return Math.abs(e[a] - t[a]) > Math.PI && (e[a] > t[a] ? n[a] += Math.PI * 2 : n[a] -= Math.PI * 2), n;
}
function Bh(a, e) {
const t = Gs("x", a, e), n = Gs("y", a, e), s = Gs("z", a, e);
return new Fe(
t.x,
n.y,
s.z,
e.order
);
}
function Zn(a) {
return Math.PI / 180 * a;
}
function kh(a) {
return a / (Math.PI / 180);
}
function bi(a, e = !0) {
return e ? {
position: a.getWorldPosition(new O()),
rotation: new Fe().setFromQuaternion(
a.getWorldQuaternion(new De())
),
scale: a.getWorldScale(new O())
} : {
position: a.position.clone(),
rotation: a.rotation.clone(),
scale: a.scale.clone()
};
}
function ao(a, e, t = !0) {
const n = bi(e, t);
a.position.copy(n.position), a.rotation.copy(n.rotation), a.scale.copy(n.scale);
}
function ss(a) {
return a.visible ? a.parent ? ss(a.parent) : !0 : !1;
}
const zh = new O(), Uh = new O(), Nh = new O(), Gh = (a, e, t) => {
const n = t.width / 2, s = t.height / 2;
e.updateMatrixWorld();
const r = a.project(e);
return r.x = r.x * n + n, r.y = -(r.y * s) + s, r;
}, jh = (a, e, t, n = 1) => {
const s = zh.set(a.x / t.width * 2 - 1, -(a.y / t.height) * 2 + 1, n);
return s.unproject(e), s;
}, oo = (a, e, t, n) => {
const s = Gh(Nh.copy(a), t, n);
let r = 0;
for (let i = 0; i < 2; ++i) {
const o = Uh.copy(s).setComponent(i, s.getComponent(i) + e), l = jh(o, t, n, o.z);
r = Math.max(r, a.distanceTo(l));
}
return r;
};
function lo(a, e, t = 5) {
const n = new gt(), s = new O(), r = new O();
return n.position.set(a.x, a.y, a.z), n.rotation.set(e.x, e.y, e.z), n.getWorldDirection(s), s.multiplyScalar(t), r.subVectors(
n.position,
s
), r;
}
function co(a, e) {
const t = a - e;
return at.euclideanModulo(t + Math.PI, Math.PI * 2) - Math.PI;
}
class ho {
min;
roots;
nodes;
constructor() {
this.min = null, this.roots = [], this.nodes = /* @__PURE__ */ new Map();
}
shift() {
const e = this.min;
if (e === null || this.roots.length < 1)
return this.min = null, e;
this.remove(e), this.roots.length > 50 && this.consolidate();
let t = 1 / 0;
const n = this.roots.length;
for (let s = 0; s < n; s++) {
const r = this.roots[s], i = this.getDistance(r);
i < t && (t = i, this.min = r);
}
return e;
}
consolidate() {
const e = [[], [], [], [], [], [], []], t = e.length - 1, n = this.roots.length;
for (let s = 0; s < n; s++) {
const r = this.roots[s], i = this.nodes.get(r);
i && i.depth < t && e[i.depth].push(r);
}
for (let s = 0; s <= t; s++)
for (; e[s].length > 1; ) {
const r = e[s].shift(), i = e[s].shift(), o = s + 1;
let l = -1;
if (r !== void 0 && i !== void 0) {
const c = this.nodes.get(r), u = this.nodes.get(i);
c && u && (c.distance < u.distance ? (c.depth = o, c.children.push(i), u.parent = r, o <= t && e[o].push(r), l = this.roots.indexOf(i)) : (u.depth = o, u.children.push(r), c.parent = i, o <= t && e[o].push(i), l = this.roots.indexOf(r)));
}
l > -1 && this.roots.splice(l, 1);
}
}
add(e, t) {
if (this.nodes.set(e, {
nodeIndex: e,
distance: t,
depth: 0,
parent: null,
children: []
}), this.min === null)
this.min = e;
else {
const n = this.nodes.get(this.min);
n && t < n.distance && (this.min = e);
}
this.roots.push(e);
}
update(e, t) {
this.remove(e), this.add(e, t);
}
remove(e) {
if (!this.nodes.has(e)) return;
const t = this.nodes.get(e)?.children;
if (t && t.length > 0)
for (let s = 0; s < t.length; s++) {
const r = t[s], i = this.nodes.get(r), o = this.nodes.get(e);
i && o && (i.parent = o.parent), i && i.parent === null && this.roots.push(r);
}
let n = this.nodes.get(e)?.parent;
if (n === null) {
const s = this.roots.indexOf(e);
s > -1 && this.roots.splice(s, 1);
} else
for (; n; ) {
const s = this.nodes.get(n);
s && (s.depth--, n = s.parent);
}
}
getDistance(e) {
const t = this.nodes.get(e);
return t ? t.distance : 1 / 0;
}
}
async function An({ path: a = "", file: e }) {
if (Array.isArray(e))
return new ml().setPath(a).loadAsync(e);
{
const t = Pi(e);
if (t === "hdr" || t === "pic") {
const n = await Ti.setPath(a).setDataType(pn).loadAsync(e);
return n.mapping = Hr, n;
} else {
const n = await bn.setPath(a).loadAsync(e);
return n.mapping = Hr, n;
}
}
}
function zn(a) {
if (!a) return null;
const { colors: e, stops: t, size: n = 1024 } = a, s = document.createElement("canvas"), r = s.getContext("2d");
if (!r) return null;
s.width = 16, s.height = n;
const i = r.createLinearGradient(0, 0, 0, n), o = new Re(), l = e.map((u) => o.set(u).getStyle());
for (let u = 0, h = l.length - 1; u <= h; u++)
i.addColorStop(t ? t[u] : u / h, l[u]);
r.fillStyle = i, r.fillRect(0, 0, 16, n);
const c = new yn(s);
return c.needsUpdate = !0, c;
}
const Zr = (a) => {
const e = a.lastIndexOf("/");
return e === -1 ? "./" : a.slice(0, e + 1);
};
function sr(a) {
return ft(a) ? _h(a) : wt(a) ? Wh(a) : a;
}
function Wh(a) {
if (wt(a)) {
const e = {};
for (const t in a)
e[t] = sr(a[t]);
return e;
}
return a;
}
function _h(a) {
return a.map((e) => sr(e));
}
const uo = (a) => kn(a, (e) => e.clone()), po = (a) => kn(a, (e) => e.dispose()), Mi = {}, Jn = new pi();
Jn.setRequestHeader(Mi);
const Si = async (a, e) => (Jn.setResponseType(e), Jn.loadAsync(a)), rr = new gl();
rr.load = (a, e, t, n) => {
const s = new Image();
return Jn.setResponseType("blob"), Jn.load(a, function(r) {
s.src = URL.createObjectURL(r), s.onload = () => {
URL.revokeObjectURL(s.src), e?.(s);
};
}, t, n), s;
};
const bn = new Ka();
bn.setRequestHeader(Mi);
const Ti = new Cc();
Ti.setRequestHeader(Mi);
const fo = new O(), Vh = new O(), mo = new O();
function Hh(a, e) {
const t = mo.setFromMatrixColumn(e.matrixWorld, 2).normalize().negate();
return a.dot(t) < 0;
}
function go(a, e, t, n) {
const s = fo.setFromMatrixPosition(a.matrixWorld), r = s.clone();
r.project(e), t.setFromCamera(new Ce(r.x, r.y), e);
const i = t.intersectObjects(n, !0);
if (i.length) {
const o = i[0].distance;
return s.distanceTo(t.ray.origin) < o;
}
return !0;
}
function Ci(a, e) {
const t = a.parent;
if (!t.occlude) return;
const { occludeThrottle: n } = t;
let s = !0;
if (At(n) && At(a.userData.delta) && (s = performance.now() - a.userData.delta > n), s && t.occlude) {
let r = a.visible;
const i = fo.setFromMatrixPosition(a.matrixWorld), o = Vh.setFromMatrixPosition(e.camera.matrixWorld), l = i.clone().sub(o);
if (t.occlude === !0 || ft(t.occlude)) {
const c = mo.setFromMatrixColumn(e.camera.matrixWorld, 2).normalize().negate();
r = !(l.dot(c) < 0) && go(a, e.camera, e.raycaster, ft(t.occlude) ? t.occlude : e.scener.intersectsList.getAll());
} else {
const c = We(t.occlude);
r = l.dot(c) < 0;
}
a.visible = r, a.userData.delta = performance.now();
}
}
const yo = (a) => {
typeof requestIdleCallback == "function" ? requestIdleCallback(a) : setTimeout(a);
}, qh = (function() {
function a() {
}
return a.prototype.toJson = function(e, t) {
const n = this.xmlStringToXmlDom(e), s = this.xmlToJson(n);
return t && (t.removeLineBreaks && this.removeLineBreaks(s), t.removeComments && this.removeCommentProperties(s), t.transformTextOnly && this.transformTextOnly(s)), s;
}, a.prototype.xmlStringToXmlDom = function(e) {
return new DOMParser().parseFromString(e, "text/xml");
}, a.prototype.removeLineBreaks = function(e) {
const t = this;
Object.keys(e).forEach((function(n, s) {
n === "#text" && Array.isArray(e[n]) && delete e[n], typeof e[n] == "object" && t.removeLineBreaks(e[n]);
}));
}, a.prototype.removeCommentProperties = function(e) {
const t = this;
Object.keys(e).forEach((function(n, s) {
n === "#comment" && delete e[n], typeof e[n] == "object" && t.removeCommentProperties(e[n]);
}));
}, a.prototype.transformTextOnly = function(e) {
const t = this;
Object.keys(e).forEach((function(n, s) {
const r = Object.keys(e[n]).length > 1, i = Object.keys(e[n])[0];
r || typeof e[n][i] == "object" ? t.transformTextOnly(e[n]) : typeof e[n] == "object" && e[n]["#text"] && (e[n] = e[n]["#text"]);
}));
}, a.prototype.xmlToJson = function(e) {
let t = {};
if (e.nodeType == 1) {
if (e.attributes.length > 0) {
t._attributes = {};
for (let n = 0; n < e.attributes.length; n++) {
const s = e.attributes.item(n);
t._attributes[s.nodeName] = s.nodeValue;
}
}
} else e.nodeType == 3 && (t = e.nodeValue);
if (e.hasChildNodes()) for (let n = 0; n < e.childNodes.length; n++) {
const s = e.childNodes.item(n), r = s.nodeName;
if (t[r] === void 0) t[r] = this.xmlToJson(s);
else {
if (t[r].push === void 0) {
const i = t[r];
t[r] = [], t[r].push(i);
}
t[r].push(this.xmlToJson(s));
}
}
return t;
}, a;
})();
function vo(a) {
function e(t) {
return new qh().toJson(t, {
transformTextOnly: !0,
removeComments: !0,
removeLineBreaks: !0
});
}
return Si(a, "text").then((t) => Promise.resolve(e(t)));
}
function js(a) {
const e = new DataView(a);
for (let t = 0; t < e.byteLength; t++) {
const n = e.getUint8(t), s = (n >> 4 & 15) + (n << 4 & 240);
e.setUint8(t, s);
}
return e.buffer;
}
const $n = {
source: null
};
function Kh(a, e) {
$n.source = a;
const t = e();
return $n.source = null, t;
}
function Xh(a) {
return Kh("code", a);
}
async function Yh(a, e) {
$n.source = a;
const t = await e();
return $n.source = null, t;
}
async function Qh(a) {
return Yh("code", a);
}
class Zh {
name = "EXT_mesh_gpu_instancing";
constructor(e) {
this.writer = e;
}
writeNode(e, t) {
if (e.isInstancedMesh !== !0)
return;
const n = e.count, s = new ie(), r = new Float32Array(n * 3), i = new Float32Array(n * 4), o = new Float32Array(n * 3), l = new O(), c = new De(), u = new O();
for (let d = 0; d < n; d++)
e.getMatrixAt(d, s), s.decompose(l, c, u), r[d * 3] = l.x, r[d * 3 + 1] = l.y, r[d * 3 + 2] = l.z, i[d * 4] = c.x, i[d * 4 + 1] = c.y, i[d * 4 + 2] = c.z, i[d * 4 + 3] = c.w, o[d * 3] = u.x, o[d * 3 + 1] = u.y, o[d * 3 + 2] = u.z;
const h = this.writer, p = {};
p.attributes = {
TRANSLATION: h.processAccessor(new bt(r, 3)),
ROTATION: h.processAccessor(new bt(i, 4)),
SCALE: h.processAccessor(new bt(o, 3))
}, t.extensions = t.extensions || {}, t.extensions[this.name] = p, h.extensionsUsed[this.name] = !0;
}
}
function Jh(a, e = {}) {
return new Promise((t, n) => {
const s = new Pc();
s.register((r) => new Zh(r)), s.parse(
a,
(r) => t(r),
(r) => n(r),
e
);
});
}
const $h = Object.prototype.hasOwnProperty, eu = (a, e) => $h.call(a, e), cn = (a) => kt(a) === "String", ir = (a) => kt(a) === "Boolean", At = (a) => kt(a) === "Number", tu = (a) => kt(a) === "Null", nu = (a) => kt(a) === "Undefined", su = (a) => kt(a) === "Symbol", ru = (a) => kt(a) === "Date", ft = Array.isArray, wt = (a) => kt(a) === "Object", Ys = (a) => kt(a) === "Function", iu = (a) => kt(a) === "Promise", kt = (a) => Object.prototype.toString.call(a).slice(8, -1), au = (a) => new Promise((e) => setTimeout(() => e(), a)), Jr = (a) => new TextDecoder().decode(new Uint8Array(a)), Tt = () => io + Math.random().toString(36).substring(7).split("").join("_"), Pi = (a) => {
const { href: e } = new URL(a, location.origin);
if (e.includes(".")) {
const t = e.split(".").pop();
return t ? t.includes("?") ? t.split("?").shift()?.toLowerCase() : t : void 0;
}
}, Di = 1e-5;
function xo(a, e = Di) {
return Math.abs(a) < e;
}
function ou(a, e, t = Di) {
return xo(a - e, t);
}
function wo(a, e = 50) {
let t = 0;
return function(...n) {
clearTimeout(t), t = self.setTimeout(() => a.apply(this, n), e);
};
}
function lu(a, e) {
const t = /* @__PURE__ */ new Map();
return a.reduce((n, s) => {
const r = n.get(s[e]);
return r ? r.push(s) : n.set(s[e], [s]), n;
}, t), t;
}
const kn = (a, e) => ft(a) ? a.map(e) : e(a), ra = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
EPSILON: Di,
IVector3ToEuler: wi,
IVector3ToVector3: We,
MinHeap: ho,
absoluteAngle: co,
approxEquals: ou,
approxZero: xo,
asyncRunWithCode: Qh,
calculateScaleFactor: oo,
cloneDeep: sr,
cloneMaterials: uo,
computeTargetByRotation: lo,
consoleSspTitle: Qn,
debounce: wo,
deg2Euler: Zn,
disposeMaterials: po,
error: xi,
euler2Deg: kh,
exportGltf: Jh,
fetchFile: Si,
getAsciiString: Jr,
getBoundingBox: Bn,
getExtension: Pi,
getSpaceAttributeFromObject: bi,
getTexture: An,
getValueType: kt,
gradientTexture: zn,
groupBy: lu,
hasOwn: eu,
idleTask: yo,
imageLoader: rr,
isArray: ft,
isBoolean: ir,
isDate: ru,
isFunction: Ys,
isNull: tu,
isNumber: At,
isObject: wt,
isObjectBehindCamera: Hh,
isObjectOccludeVisible: go,
isObjectVisible: ss,
isPromise: iu,
isString: cn,
isSymbol: su,
isUndefined: nu,
log: dn,
objectHandle: kn,
parseFilePath: Zr,
poiNodeOccludeHandler: Ci,
propertiesCtx: $n,
randomString: Tt,
rgbeLoader: Ti,
rotationAFix: Bh,
rotationAxisFix: Gs,
runWithCode: Xh,
sleep: au,
swapBytes: js,
syncSpaceAttributeToObject: ao,
textureLoader: bn,
warn: X,
xmlToJson: vo
}, Symbol.toStringTag, { value: "Module" })), cu = {
"Linear.None": ze.Linear.None,
"Quadratic.In": ze.Quadratic.In,
"Quadratic.Out": ze.Quadratic.Out,
"Quadratic.InOut": ze.Quadratic.InOut,
"Cubic.In": ze.Cubic.In,
"Cubic.Out": ze.Cubic.Out,
"Cubic.InOut": ze.Cubic.InOut,
"Quartic.In": ze.Quartic.In,
"Quartic.Out": ze.Quartic.Out,
"Quartic.InOut": ze.Quartic.InOut,
"Quintic.In": ze.Quintic.In,
"Quintic.Out": ze.Quintic.Out,
"Quintic.InOut": ze.Quintic.InOut,
"Sinusoidal.In": ze.Sinusoidal.In,
"Sinusoidal.Out": ze.Sinusoidal.Out,
"Sinusoidal.InOut": ze.Sinusoidal.InOut,
"Exponential.In": ze.Exponential.In,
"Exponential.Out": ze.Exponential.Out,
"Exponential.InOut": ze.Exponential.InOut,
"Circular.In": ze.Circular.In,
"Circular.Out": ze.Circular.Out,
"Circular.InOut": ze.Circular.InOut,
"Elastic.In": ze.Elastic.In,
"Elastic.Out": ze.Elastic.Out,
"Elastic.InOut": ze.Elastic.InOut,
"Back.In": ze.Back.In,
"Back.Out": ze.Back.Out,
"Back.InOut": ze.Back.InOut,
"Bounce.In": ze.Bounce.In,
"Bounce.Out": ze.Bounce.Out,
"Bounce.InOut": ze.Bounce.InOut
};
function $t(a, e, t = {}, n, s) {
return new Promise((r, i) => {
const {
duration: o = 1e3,
delay: l = 0,
repeat: c = !1,
mode: u = "Linear.None",
yoyo: h = !1
} = t, p = cu[u], d = new Tc(a).to(e, o).easing(p).delay(l).onUpdate((f) => {
a instanceof Fe && e instanceof Fe && f instanceof Fe && (f.order = e.order), n?.(f, d);
}).onComplete(() => {
r();
}).onStop(() => {
i("animation stop");
}).onStart(() => {
s?.(d);
});
At(c) ? d.repeat(c) : ir(c) && c && d.repeat(1 / 0), h && d.repeatDelay(20), d.yoyo(h), d.start();
});
}
class ia {
/**
*
* @param target - 被动画的目标对象
* @param points - 路径点列表
* @param options - 选项
*/
constructor(e, t, n = {}) {
this.target = e, this.points = t, Object.assign(this, n);
}
/**
* 移动速度
*/
speed = 1;
/**
* 反向播放
*/
reverse = !1;
/**
* 是否需要旋转
*/
needsRotate = !0;
/**
* 位置更新回调
* @remarks
* 每当目标位置有更新时会触发
*/
onUpdate;
/**
* 动画开始时回调
*/
onStart;
/**
* 每段 tween 动画开始时回调
* @param tween
*/
onEveryStart;
/**
* 当到达一个点时回调
*/
onPoint;
/**
* 当前目标点的索引
*/
index = 1;
/**
* 是否正在播放
*/
get isPlaying() {
return !!this._tween?.isPlaying();
}
_tween = null;
/**
* 播放
*/
async play() {
if (this.isPlaying) return !1;
this.index = 1;
let e = this.points.slice();
return this.reverse && (e = e.reverse()), this._play(e);
}
async _play(e) {
const { target: t } = this, n = this.speed ?? 1, s = this.index;
let r = e[s - 1];
if (!r) return !0;
r.isVector3 || (r = We(r)), r = r.clone();
let i = e[s];
if (!i) return !0;
i.isVector3 || (i = We(i).clone()), i = i.clone();
const l = r.distanceTo(i) / n;
this.needsRotate && (s === 1 && t.parent && t.position.copy(t.parent.worldToLocal(r.clone())), t.lookAt(i)), await $t(
r,
i,
{
duration: l
},
(c, u) => {
if (t.parent) {
const h = t.parent.worldToLocal(c.clone());
t.position.copy(h);
}
this.onUpdate?.(c, u);
},
(c) => {
s === 1 && this.onStart?.(c), this.onEveryStart?.(c), this._tween = c;
}
), this.onPoint?.(s, i), this.index++, await this._play(e);
}
/**
* 暂停
*/
pause() {
this._tween?.pause();
}
resume() {
this._tween?.resume();
}
/**
* 停止
*/
stop() {
this._tween?.stop(), this._tween = null;
}
}
function bo(a) {
var e = typeof a;
return a == null || e !== "object" && e !== "function";
}
function hu(a) {
return a && typeof a[Symbol.iterator] == "function";
}
var $r = /* @__PURE__ */ ((a) => (a[a.x = 0] = "x", a[a.y = 1] = "y", a[a.z = 2] = "z", a))($r || {});
((a) => {
function e(s) {
return a[s];
}
a.toKey = e;
function t(s) {
return a[s];
}
a.toIndex = t;
function n(s) {
const r = (s + 1) % 3, i = (s + 2) % 3;
return [r, i];
}
a.getCrossAxiss = n;
})($r || ($r = {}));
var ei = /* @__PURE__ */ ((a) => (a[a.x = 0] = "x", a[a.y = 1] = "y", a[a.z = 2] = "z", a[a.w = 3] = "w", a))(ei || {});
((a) => {
function e(s) {
return a[s];
}
a.toKey = e;
function t(s) {
return a[s];
}
a.toIndex = t;
function n(s) {
const r = (s + 1) % 4, i = (s + 2) % 4;
return [r, i];
}
a.getCrossAxiss = n;
})(ei || (ei = {}));
var uu = Object.defineProperty, du = (a, e, t) => e in a ? uu(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, _n = (a, e, t) => (du(a, typeof e != "symbol" ? e + "" : e, t), t);
function pu(a) {
return a.w != null ? new Zt().copy(a) : a.z != null ? new O().copy(a) : new Ce().copy(a);
}
function En(a, e, t) {
t = t ?? 0;
const n = t + 1;
if (bo(a))
return a;
if (a.x != null && a.y != null)
return pu(a);
if (Array.isArray(a))
return a.map((s) => En(s, e, n));
if (a instanceof Map) {
const s = /* @__PURE__ */ new Map();
for (const r of a.keys()) {
const i = a.get(r), o = En(i, e, n);
s.set(r, o);
}
return s;
}
if (hu(a)) {
const s = [];
for (const r of a) {
const i = En(r, e, n);
s.push(i);
}
return s;
}
if (t === 0 && typeof a == "object") {
const s = {};
for (const r of Object.keys(a))
s[r] = En(a[r], e, n);
return s;
}
return a;
}
function fu(a, e) {
const t = Math.sqrt(a.lengthSq() * e.lengthSq());
if (t === 0)
return 0;
let n = a.dot(e) / t;
return n = Math.max(-1, Math.min(1, n)), Math.acos(n);
}
function Sr(a, e, t) {
let n = fu(a, e);
return n === 0 ? n : a.clone().cross(e).dot(t) < 0 ? -n : n;
}
function mu(a, e, t) {
const n = e.clone().negate(), s = t.clone().projectOnPlane(e), r = a.clone().projectOnPlane(s), i = Sr(e, r, s), o = e.clone().cross(s), l = a.clone().projectOnPlane(o), c = Sr(e, l, o), u = a.clone().projectOnPlane(n), h = Sr(s, u, n);
return { yaw: i, pitch: c, roll: h };
}
const Tr = 180 / Math.PI, ti = {
yaw: [
{ name: "前", range: [-15, 15] },
{ name: "左", range: [15, 165] },
{ name: "右", range: [-165, -15] },
{ name: "后", range: [-180.1, -165] },
{ name: "后", range: [165, 180.1] }
],
pitch: [
{ name: "前", range: [-15, 15] },
{ name: "上", range: [15, 165] },
{ name: "下", range: [-165, -15] },
{ name: "后", range: [-180.1, -165] },
{ name: "后", range: [165, 180.1] }
],
roll: [
{ name: "上", range: [-15, 15] },
{ name: "左", range: [15, 165] },
{ name: "右", range: [-165, -15] },
{ name: "下", range: [-180.1, -165] },
{ name: "下", range: [165, 180.1] }
]
};
function gu(a) {
const e = {};
for (const [t, n] of Object.entries(a))
e[t] = Array.isArray(n) ? n : Object.entries(n).map(([s, r]) => ({ name: s, range: r }));
return e;
}
const Cr = {
degrees: !0,
map: ti,
front: { x: 0, y: 0, z: 1 },
up: { x: 0, y: 1, z: 0 }
};
class Mo {
constructor(e) {
_n(this, "_options"), _n(this, "_listMap"), _n(this, "_front"), _n(this, "_up"), e && (this.options = e);
}
static get options() {
return this._options ?? (this.options = Cr);
}
static set options(e) {
this._options = Object.assign({}, structuredClone(ti), e);
}
/**
* 默认选项
*/
get defaultOptions() {
return this.constructor.options;
}
get options() {
return this._options ?? (this.options = this.defaultOptions);
}
set options(e) {
this._options = Object.assign({}, structuredClone(this.defaultOptions), e), this._listMap = null, this._front = null, this._up = null;
}
/**
* 是否使用角度,而非弧度
*/
get degrees() {
return this.options.degrees ?? (this.options.degrees = this.defaultOptions.degrees ?? !0);
}
set degrees(e) {
this.options.degrees = e;
}
get map() {
return this.options.map || (this.map = this.defaultOptions.map), this.options.map;
}
set map(e) {
const t = structuredClone(this.defaultOptions.map), n = structuredClone(ti);
e = e ? {
yaw: e.yaw ?? t.yaw ?? n.yaw,
pitch: e.pitch ?? t.pitch ?? n.pitch,
roll: e.roll ?? t.roll ?? n.roll
} : t, this.options.map = e, this._listMap = null;
}
get listMap() {
return this._listMap ?? (this._listMap = gu(this.map ?? {}));
}
get front() {
return this._front || (this.front = this.options.front ?? this.defaultOptions.front ?? Cr.front), this._front;
}
set front(e) {
this._front = new O().copy(e);
}
get up() {
return this._up || (this.up = this.options.up ?? this.defaultOptions.up ?? Cr.up), this._up;
}
set up(e) {
this._up = new O().copy(e);
}
/**
* 计算方位
* @param target
* @param front
* @param up
*/
computeAzimuth(e, t, n) {
const s = new O().copy(e), r = new O().copy(t ?? this.front), i = new O().copy(n ?? this.up);
let { yaw: o, pitch: l, roll: c } = mu(s, r, i);
return this.degrees && (o *= Tr, l *= Tr, c *= Tr), {
yaw: {
angle: o,
name: this.findAzimuthNames("yaw", o)
},
pitch: {
angle: l,
name: this.findAzimuthNames("pitch", l)
},
roll: {
angle: c,
name: this.findAzimuthNames("roll", c)
}
};
}
/**
* 查找匹配的方位名字
* @param type - 类型
* @param angle - 角度
* @returns 匹配的名字列表
*/
findAzimuthNames(e, t) {
const n = [], s = this.listMap[e];
if (!s)
return n;
for (const { name: r, range: [i, o] } of s)
(t >= i && t < o || t <= i && t > o) && n.push(r);
return n;
}
}
_n(Mo, "_options");
new Mo();
function yu(a, e, t) {
const n = t ? (l) => a.getPointAt(l) : (l) => a.getPoint(l);
let s = n(0), r = 0;
const i = [], o = e.length;
for (let l = 0; l < o; l++) {
const c = e[l], u = n(c);
r += u.distanceTo(s), i.push(r), s = u;
}
return { lengths: i, length: i[o - 1] };
}
function vu(a, e) {
let t = a.sampleLength;
if (!t) {
const n = a.sampleNum;
if (n)
return n;
t = 1;
}
return Math.ceil(e / t);
}
function Ii(a) {
const { curve: e } = a;
let t = e.getLength();
const n = vu(a, t);
return e.arcLengthDivisions < n && (e.arcLengthDivisions = n, e.updateArcLengths(), t = e.getLength()), { length: t, division: n };
}
var Ai = /* @__PURE__ */ ((a) => (a.back = "back", a.front = "front", a))(Ai || {});
function So(a) {
const { curve: e, distance: t, fromU: n = 0, side: s, tolerance: r = t * 0.1 } = a, i = a.length ?? e.getLength(), o = e.getPointAt(n);
let l = t / i;
const c = s === "front" ? -1 : 1;
let u = !0, h = n, p = o, d = 0, f = !0;
do {
h = c * l + n;
let v = !1;
h > 1 ? (h = 1, v = !0) : h < 0 && (h = 0, v = !0), p = e.getPointAt(h), d = p.distanceTo(o), u = Math.abs(t - d) > r;
const x = t / d;
if (v && u && x > 1) {
f = !1;
break;
}
l *= x;
} while (u);
return {
succeed: f,
u: h,
point: p,
distance: d
};
}
function xu(a) {
const e = Ei(a), t = [0], n = e.reduce((s, r) => (s += r.distance(), t.push(s), s), 0);
return { lines: e, lengths: t, length: n };
}
function Ei(a) {
const e = [];
return a.reduce((t, n) => {
const s = new Xa(t, n);
return e.push(s), n;
}), e;
}
function wu(a, e) {
const { distSortIndexs: t, clampDists: n, clampPoints: s, ts: r, clampTs: i } = bu(a, e), o = t[0];
return { line: e[o], index: o, clampDist: n[o], clampPoint: s[o], t: r[o], clampT: i[o] };
}
function bu(a, e) {
const t = {
clampDists: [],
clampPoints: [],
distSortIndexs: [],
ts: [],
clampTs: []
};
return e.forEach((n, s) => {
const r = n.closestPointToPointParameter(a), i = at.clamp(r, 0, 1), o = n.at(i, new O()), l = a.distanceTo(o);
t.clampDists.push(l), t.clampPoints.push(o), t.distSortIndexs.push(s), t.ts.push(r), t.clampTs.push(i);
}), t.distSortIndexs.sort((n, s) => t.clampDists[n] - t.clampDists[s]), t;
}
function To(a) {
const e = new yl(), t = a[0].z == null ? vl : xl;
return a.reduce((n, s) => {
const r = new t(n, s);
return e.add(r), s;
}), e;
}
new vn();
var Mu = Object.defineProperty, Su = (a, e, t) => e in a ? Mu(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, Ae = (a, e, t) => (Su(a, typeof e != "symbol" ? e + "" : e, t), t);
const Qs = new O(), Co = new O(1, 1, 1);
new De();
const es = new ie();
function Po(a) {
const { joints: e, axials: t } = a;
if (e)
var n = Tu(e);
else
t ? n = Li(a) : n = Cu(a);
return n;
}
function Li(a) {
const { axials: e, start: t } = a, n = new _s();
t && (n.position.copy(t), n.updateMatrix());
const s = [n];
return e.reduce((r, i) => {
const o = new _s();
return o.position.copy(i), r.add(o), s.push(o), o.updateMatrix(), o;
}, n), n.updateWorldMatrix(!0, !0), s;
}
function Tu(a) {
const e = [];
return a.reduce((t, n) => {
const s = n.clone().sub(t);
return e.push(s), n;
}), Li({ axials: e, start: a[0] });
}
function Cu(a) {
const { start: e, axial: t } = a;
let n = a.number;
const s = new Array(n - 1);
return s.fill(t), Li({ axials: s, start: e });
}
function Pu(a) {
const { geometry: e, flexible: t = 1, axial: n, number: s } = a, r = a.start ?? new O(), i = n.clone().normalize(), o = n.length(), l = s - 1, c = new De().setFromUnitVectors(new O(1, 0, 0), i), u = new ie().compose(r, c, new O(1, 1, 1)).invert(), h = e.getAttribute("position").clone(), p = h.count;
h.applyMatrix4(u);
const d = [], f = [];
for (let v = 0; v < p; v++) {
const x = h.getX(v);
if (x < 0) {
d.push(0, 0, 0, 0), f.push(1, 0, 0, 0);
continue;
}
const S = Math.trunc(x / o);
if (S < l) {
const C = x % o / o * t;
d.push(S, S + 1, 0, 0), f.push(1 - C, C, 0, 0);
continue;
}
d.push(l, 0, 0, 0), f.push(1, 0, 0, 0);
}
return e.setAttribute("skinIndex", new Ln(d, 4)), e.setAttribute("skinWeight", new ke(f, 4)), e;
}
function Nm(a) {
const { skeleton: e, geometryFrame: t } = a, n = e.boneInverses[0].clone().invert(), s = e.boneInverses[1].clone().invert();
if (t) {
const o = t.clone().invert();
n.premultiply(o), s.premultiply(o);
}
const r = new O().setFromMatrixPosition(n), i = new O().setFromMatrixPosition(s);
return i.sub(r), Pu({
...a,
start: r,
axial: i,
number: e.bones.length
});
}
function Do(a) {
const { skeleton: e, geometry: t, flexible: n = 1, geometryFrame: s } = a, r = s?.clone().invert() ?? es.clone(), i = e.boneInverses.map((d) => {
const f = d.clone().invert().premultiply(r);
return new O().setFromMatrixPosition(f);
}), o = Ei(i), l = t.getAttribute("position"), c = l.count, u = [], h = [], p = new O();
for (let d = 0; d < c; d++) {
p.fromBufferAttribute(l, d);
const { index: f, clampT: v } = wu(p, o), x = v * n;
u.push(f, f + 1, 0, 0), h.push(1 - x, x, 0, 0);
}
return t.setAttribute("skinIndex", new Ln(u, 4)), t.setAttribute("skinWeight", new ke(h, 4)), t;
}
function Gm(a) {
const { geometry: e } = a, t = a.material ?? void 0, n = new mi(e, t), s = Po(a);
n.add(s[0]);
const r = new fi(s);
return n.bind(r), Do({ ...a, skeleton: r }), n;
}
function jm(a) {
const { skeleton: e } = a, t = Io(a);
return t.updateMatrix(), t.updateMatrixWorld(), t.bind(e), t;
}
function Io(a) {
const { target: e, skeleton: t } = a, n = e.geometry, s = new mi();
return e.copy.call(s, e, !1), Do({ ...a, geometry: n, skeleton: t, geometryFrame: e.matrixWorld }), s;
}
function Ao(a) {
const { target: e } = a;
let { skeleton: t } = a;
if (t)
var n = t.bones[0];
else {
const r = Po(a);
t = new fi(r), n = r[0];
}
e.add(n), e.updateWorldMatrix(!1, !0), t.calculateInverses(), n.removeFromParent();
const s = Eo({ ...a, target: e, skeleton: t });
return s.add(n), { model: s, skeleton: t, rootBone: n };
}
function Eo(a) {
const { target: e, skeleton: t, parent: n, posOnBone: s } = a, r = e.isMesh, i = r ? Io({ ...a, skeleton: t }) : e.clone(!1);
n && n.add(i), i.updateMatrixWorld(!0), r && (i.bind(t, e.matrixWorld), s && (i.frustumCulled = !1));
const o = e.children;
for (const l of o)
Eo({ ...a, target: l, parent: i });
return i;
}
function Wm(a) {
return a.filter((e) => {
var t;
return !((t = e.parent) != null && t.isBone);
});
}
function Du(a) {
return a.find((e) => {
var t;
return !((t = e.parent) != null && t.isBone);
});
}
function _m(a) {
return Du(a) ?? a[0];
}
function Iu(a) {
return a.curve ? Au(a) : Eu(a);
}
function Au(a) {
const { keyframeTracks: e, duration: t, ...n } = Lo(a), s = new Vt(a.name, t, e);
return { ...n, clip: s };
}
function Lo(a) {
const { curve: e, lookDistance: t } = a, n = a.targetPath ?? "", s = Ii(a).division, r = ar(a, e.getLength()), i = er, o = [], l = Fi(s), c = { ...a, duration: r, division: s, ts: l, lookPoint: { distance: t } }, u = Ri(c), { points: h, rotates: p, ...d } = Oi(c);
if (h.length) {
const f = [];
h.forEach((x, S) => {
x.toArray(f, S * 3);
});
const v = new tn(`${n}.position`, u, f, i);
o.push(v);
}
if (p.length) {
const f = [];
p.forEach((x, S) => {
x.toArray(f, S * 4);
});
const v = new nn(`${n}.quaternion`, u, f, i);
o.push(v);
}
return { ...d, keyframeTracks: o, duration: r };
}
function ar(a, e) {
let t = a.duration;
if (!t) {
const n = a.speed;
if (n == null)
throw "缺少选项 duration 或者 speed";
if (!e)
throw "缺少参数 length";
t = e / n;
}
return t;
}
function Oi(a) {
var e, t;
const { curve: n, target: s, lookPoint: r, enableUp: i, fixUp: o } = a, l = a.position ?? !0, c = a.rotate ?? !0, u = [], h = [], p = [];
if (!(l || c))
return { rotates: u, points: h, curveLength: void 0, lengths: void 0 };
const d = (a.anchor ?? Qs).clone(), f = a.ts ?? a.us, v = !a.ts;
if (!f)
throw "缺少参数:至少传递 ts 和 us 任意之一";
let x = es.clone(), S = es.clone(), C = Co.clone(), M = gt.DEFAULT_UP;
s && (s.updateWorldMatrix(!0, !1), x = s.matrix, S = s.matrixWorld, C = s.scale, M = s.up);
const R = x.clone().invert(), L = S.clone().multiply(R).clone().invert(), I = n.getTangent(0);
I.transformDirection(L);
const U = ((e = a.front) == null ? void 0 : e.clone().normalize()) ?? I, q = ((t = a.up) == null ? void 0 : t.clone().normalize()) ?? M.clone().transformDirection(L);
let Y = x.clone().setPosition(0, 0, 0), _ = (V) => n.getPoint(V), ue = (V) => n.getTangent(V);
v && (_ = (V) => n.getPointAt(V), ue = (V) => n.getTangentAt(V));
const ce = f.length, fe = ce - 1;
let { distance: Z, curveLength: ve, lengths: ne } = r ?? {};
Z = Z ?? 0;
let N = ue;
Z !== 0 && (ne || (ne = yu(n, f, v).lengths), ve == null && (ve = ne[fe]), N = (V, $) => {
const H = _(V);
let ee = (ne[$] + Z) / ve;
return ee > 1 && (ee = 1), n.getPointAt(ee).sub(H).normalize();
});
let J = (V) => {
const $ = f[V], H = N($, V);
H.transformDirection(L), p.push(H);
const ee = V - 1, oe = ee < 0, te = oe ? U : p[ee], ye = new De().setFromUnitVectors(te, H);
if (!oe) {
const Ie = u[ee];
ye.multiply(Ie);
}
return ye.normalize();
};
if (i) {
const V = new O(0, 1, 0);
J = o ? function($) {
const H = f[$], ee = N(H, $);
ee.transformDirection(L), p.push(ee);
const oe = $ - 1, te = oe < 0;
let ye;
if (te)
ye = new De().setFromUnitVectors(U, ee);
else {
const ge = u[oe], Ne = U.clone().applyQuaternion(ge).normalize();
ye = new De().setFromUnitVectors(Ne, ee), ye.multiply(ge);
}
const Ie = q.clone().applyQuaternion(ye).normalize(), me = new De().setFromUnitVectors(Ie, V);
return ye.premultiply(me), ye.normalize();
} : function($) {
const H = f[$], ee = N(H, $);
ee.transformDirection(L), p.push(ee);
const oe = $ - 1, te = oe < 0, ye = te ? U : p[oe], Ie = new De().setFromUnitVectors(ye, ee);
if (te) {
const me = q.clone().applyQuaternion(Ie);
me.projectOnPlane(ee).normalize();
const ge = V.clone().projectOnPlane(ee).normalize(), Ne = new De().setFromUnitVectors(me, ge);
Ie.premultiply(Ne);
} else {
const me = u[oe];
Ie.multiply(me);
}
return Ie.normalize();
};
}
for (let V = 0; V < ce; V++) {
const $ = f[V];
if (c) {
const H = J(V);
u.push(H), Y = new ie().compose(Qs, H, C);
}
if (l) {
const H = _($);
H.applyMatrix4(L);
const ee = d.clone().applyMatrix4(Y);
H.sub(ee), h.push(H);
}
}
return { rotates: u, points: h, curveLength: ve ?? void 0, lengths: ne ?? void 0 };
}
function Fi(a) {
const e = [];
for (let t = 0; t <= a; t++)
e.push(t / a);
return e;
}
function Ri(a) {
const { curve: e, division: t, duration: n } = a, s = e.getLengths(t), r = s.length, i = s[r - 1];
return s.map((o) => o / i * n);
}
function Eu(a) {
const { smooth: e, points: t } = a;
if (e === !1)
var { keyframeTracks: n, duration: s, ...r } = Lu(a);
else {
const o = To(t);
var { keyframeTracks: n, duration: s, ...r } = Lo({ ...a, curve: o });
}
const i = new Vt(a.name, s, n);
return { ...r, clip: i };
}
function Lu(a) {
const e = a.targetPath ?? "", t = a.points, { lines: n, length: s, lengths: r } = xu(t), i = ar(a, s), o = [], l = r.map((d) => d / s * i), { points: c, pointTimes: u, rotates: h, rotateTimes: p } = Ou({ ...a, times: l }, n);
if (c.length) {
const d = [];
c.forEach((v, x) => {
v.toArray(d, x * 3);
});
const f = new tn(`${e}.position`, u, d, er);
o.push(f);
}
if (h.length) {
const d = [];
h.forEach((v, x) => {
v.toArray(d, x * 4);
});
const f = new nn(`${e}.quaternion`, p, d, Ml);
o.push(f);
}
return { keyframeTracks: o, duration: i, lengths: r, curveLength: s };
}
function Ou(a, e) {
var t, n;
const { points: s, target: r, times: i, enableUp: o, fixUp: l } = a, c = a.position ?? !0, u = a.rotate ?? !0, h = s.length, p = h - 1;
e = e ?? Ei(s);
const d = [], f = i, v = [], x = [], S = [], C = { rotates: d, points: v, rotateTimes: f, pointTimes: x };
if (!(c || u))
return C;
const M = (a.anchor ?? Qs).clone();
let R = es.clone(), L = es.clone(), I = Co.clone(), U = gt.DEFAULT_UP;
r && (r.updateWorldMatrix(!0, !1), R = r.matrix, L = r.matrixWorld, I = r.scale, U = r.up);
const q = R.clone().invert(), Y = L.clone().multiply(q).clone().invert(), _ = e[0].delta(new O());
_.transformDirection(Y);
const ue = ((t = a.front) == null ? void 0 : t.clone().normalize()) ?? _, ce = ((n = a.up) == null ? void 0 : n.clone().normalize()) ?? U.clone().transformDirection(Y);
let fe = R.clone().setPosition(0, 0, 0), Z = fe, ve = (ne) => {
const N = e[ne].delta(new O()).normalize();
N.transformDirection(Y), S.push(N);
const J = ne - 1, V = J < 0, $ = V ? ue : S[J], H = new De().setFromUnitVectors($, N);
if (!V) {
const ee = d[J];
H.multiply(ee);
}
return H.normalize();
};
if (o) {
const ne = new O(0, 1, 0);
ve = l ? function(N) {
const J = e[N].delta(new O()).normalize();
J.transformDirection(Y), S.push(J);
const V = N - 1, $ = V < 0;
let H;
if ($)
H = new De().setFromUnitVectors(ue, J);
else {
const te = d[V], ye = ue.clone().applyQuaternion(te).normalize();
H = new De().setFromUnitVectors(ye, J), H.multiply(te);
}
const ee = ce.clone().applyQuaternion(H).normalize(), oe = new De().setFromUnitVectors(ee, ne);
return H.premultiply(oe), H.normalize();
} : function(N) {
const J = e[N].delta(new O()).normalize();
J.transformDirection(Y), S.push(J);
const V = N - 1, $ = V < 0, H = $ ? ue : S[V], ee = new De().setFromUnitVectors(H, J);
if ($) {
const oe = ce.clone().applyQuaternion(ee);
oe.projectOnPlane(J).normalize();
const te = ne.clone().projectOnPlane(J).normalize(), ye = new De().setFromUnitVectors(oe, te);
ee.premultiply(ye);
} else {
const oe = d[V];
ee.multiply(oe);
}
return ee.normalize();
};
}
for (let ne = 0; ne < h; ne++) {
if (u)
if (ne < p) {
const N = ve(ne);
d.push(N), fe = new ie().compose(Qs, N, I);
} else
d.push(d[ne - 1].clone());
if (c) {
const N = i[ne], J = s[ne].clone();
if (J.applyMatrix4(Y), ne > 0) {
const $ = M.clone().applyMatrix4(Z), H = J.clone().sub($);
v.push(H), x.push(N);
}
const V = M.clone().applyMatrix4(fe);
J.sub(V), v.push(J), x.push(N);
}
Z = fe;
}
return C;
}
function Fu(a) {
const e = a.mixer, t = Ao(a), { model: n, skeleton: s } = t, r = { ...a, target: n, skeleton: s }, { clip: i, ...o } = a.posOnBone ? Oo(r) : ku(r);
n.animations.push(i);
const l = e?.clipAction(i, n);
return { ...o, ...t, clip: i, action: l };
}
function Oo(a) {
const { boneTracks: e, duration: t, ...n } = Ru(a), s = e.flat(), r = new Vt(a.name, t, s);
return { ...n, clip: r };
}
function Ru(a) {
const { skeleton: e, targetPath: t } = a, n = e.bones, { times: s, boneSampleDatas: r, duration: i, ...o } = Bu(a), l = s.length, c = er, u = r.map((h, p) => {
const { points: d, rotates: f } = h, v = n[p], x = t ? `${t}.skeleton.bones[${p}]` : `${v.name || v.uuid}`, S = [], C = [];
for (let L = 0; L < l; L++)
d && d[L].toArray(S, L * 3), f[L].toArray(C, L * 4);
const M = [];
if (d) {
const L = new tn(`${x}.position`, s, S, c);
M.push(L);
}
const R = new nn(`${x}.quaternion`, s, C, c);
return M.push(R), M;
});
return { ...o, boneTracks: u, duration: i };
}
function Bu(a) {
var e;
const { curve: t, skeleton: n, stretch: s } = a, { bones: r, boneInverses: i } = n, o = r[0], l = a.target ?? o.parent;
if (!l)
throw "target 或 根骨骼的 parent 不存在";
const c = a.tolerance ?? 0.1;
o.updateWorldMatrix(!0, !0);
const { division: u, length: h } = Ii(a), { matrixWorld: p } = l, d = p.clone().invert(), f = [], v = [];
i.reduce((H, ee) => {
const oe = ee.clone().invert();
f.push(oe);
const te = H.clone().multiply(oe);
return v.push(te), ee;
}, d);
const x = v[0], S = new O(), C = new De(), M = new O();
x.decompose(S, C, M);
const R = ar(a, h), L = Fi(u), I = Ri({ curve: t, division: u, duration: R }), U = L.length, q = [], Y = new O().setFromMatrixPosition(v[1]).negate(), _ = i[0], ue = (e = a.up) == null ? void 0 : e.clone().applyMatrix4(p).transformDirection(_), { points: ce, rotates: fe, ...Z } = Oi({ ...a, curve: t, ts: L, target: o, rotate: !0, front: Y, up: ue, anchor: null });
for (let H = 0; H < U; H++)
q.push(p.clone());
const ve = ce.map((H, ee) => {
const oe = fe[ee];
oe.premultiply(C).normalize();
const te = new ie().compose(H, oe, M);
return te.premultiply(p), te;
}), ne = t.getLengths(u).map((H) => H / h), N = [{ points: ce, rotates: fe, us: ne, matrixs: ve }], J = s ? function(H, ee, oe) {
const te = N[H].us[ee] - oe / h;
return {
u: te,
point: te < 0 ? null : t.getPointAt(te)
};
} :