lingo3d-react
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
114 lines (113 loc) • 4.93 kB
JavaScript
var p = Object.defineProperty;
var M = (t, i, e) => i in t ? p(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e;
var u = (t, i, e) => (M(t, typeof i != "symbol" ? i + "" : i, e), e);
import { ap as g, aq as m, ar as l, as as x, at as b, au as f, av as w, aw as I, ax as P, B as d } from "./index-895cfa2f.mjs";
function v(t) {
const i = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), s = t.clone();
return y(t, s, function(n, c) {
i.set(c, n), e.set(n, c);
}), s.traverse(function(n) {
if (!n.isSkinnedMesh)
return;
const c = n, a = i.get(n), S = a.skeleton.bones;
c.skeleton = a.skeleton.clone(), c.bindMatrix.copy(a.bindMatrix), c.skeleton.bones = S.map(function(h) {
return e.get(h);
}), c.bind(c.skeleton, c.bindMatrix);
}), s;
}
function y(t, i, e) {
e(t, i);
for (let s = 0; s < t.children.length; s++)
y(t.children[s], i.children[s], e);
}
const q = (t, i, e = t.animations) => {
const s = i ? t.clone() : v(t);
return !i && g.add(s), s.animations = e, s;
}, o = (t, i, e, s) => {
if (e == null || x(e, s, i))
return;
const n = t[i];
if (n != e) {
if (n && typeof n == "object" && "set" in n) {
if ("x" in n) {
n.set(e.x ?? e, e.y ?? e);
return;
}
n.set(e);
return;
}
t[i] = e;
}
}, [k, r, R] = m((t, { referenceMaterial: i, defaults: e, MyTextureManager: s }) => {
const n = i.clone();
return n.userData.TextureManager = s, o(n, "color", t[0], e), o(n, "opacity", t[1], e), o(n, "transparent", i.transparent || t[1] !== void 0 && t[1] < 1, e), o(n, "map", l(t[2], t[4], t[5], t[6]), e), o(n, "alphaMap", l(t[3], t[4], t[5], t[6]), e), o(n, "wireframe", t[7], e), o(n, "envMap", l(t[8], t[4], t[5], t[6]), e), o(n, "envMapIntensity", t[9], e), o(n, "aoMap", l(t[10], t[4], t[5], t[6]), e), o(n, "aoMapIntensity", t[11], e), o(n, "bumpMap", l(t[12], t[4], t[5], t[6]), e), o(n, "bumpScale", t[13], e), o(n, "displacementMap", l(t[14], t[4], t[5], t[6]), e), o(n, "displacementScale", t[15], e), o(n, "displacementBias", t[16], e), o(n, "emissive", t[17] ? t[0] : void 0, e), o(n, "emissiveIntensity", t[18], e), o(n, "lightMap", l(t[19], t[4], t[5], t[6]), e), o(n, "lightMapIntensity", t[20], e), o(n, "metalnessMap", l(t[21], t[4], t[5], t[6]), e), o(n, "metalness", t[22], e), o(n, "roughnessMap", l(t[23], t[4], t[5], t[6]), e), o(n, "roughness", t[24], e), o(n, "normalMap", l(t[25], t[4], t[5], t[6]), e), o(n, "normalScale", t[26], e), o(n, "depthTest", t[27], e), n;
}, (t) => t.dispose()), D = (t) => {
var s, n, c, a, S;
const i = {
color: "#" + (((s = t.color) == null ? void 0 : s.getHexString()) ?? "ffffff"),
opacity: t.opacity,
texture: "",
alphaMap: "",
textureRepeat: ((n = t.map) == null ? void 0 : n.repeat) ?? { x: 1, y: 1 },
textureFlipY: ((c = t.map) == null ? void 0 : c.flipY) ?? !1,
textureRotation: (((a = t.map) == null ? void 0 : a.rotation) ?? 0) * b,
wireframe: t.wireframe,
envMap: "",
envMapIntensity: t.envMapIntensity,
aoMap: "",
aoMapIntensity: t.aoMapIntensity,
bumpMap: "",
bumpScale: t.bumpScale,
displacementMap: "",
displacementScale: t.displacementScale,
displacementBias: t.displacementBias,
emissive: t.emissive ? !t.emissive.equals(f) : !1,
emissiveIntensity: t.emissiveIntensity,
lightMap: "",
lightMapIntensity: t.lightMapIntensity,
metalnessMap: "",
metalness: t.metalness,
roughnessMap: "",
roughness: t.roughness,
normalMap: "",
normalScale: ((S = t.normalScale) == null ? void 0 : S.x) ?? 1,
depthTest: t.depthTest
}, e = Object.values(i);
return [i, e];
}, T = (t) => {
const [i, e] = D(t);
R(e, t);
const [s] = I((c) => {
c.materialParamString ? r(c.materialParamString) : c.owner.then(() => r(c.materialParamString));
const a = JSON.stringify(c.materialParams);
c.material = k(c.materialParams, a, { referenceMaterial: t, defaults: i, MyTextureManager: n }), c.materialParamString = a;
});
class n extends w {
constructor(S, h) {
super();
u(this, "object3d");
u(this, "owner");
u(this, "defaults", i);
u(this, "defaultParams", e);
u(this, "addRefreshParamsSystem", s);
this.object3d = S, this.owner = h;
}
}
return u(n, "defaults", i), u(n, "defaultParams", e), u(n, "addRefreshParamsSystem", s), n;
}, L = (t, i) => {
var s;
const e = [];
t.traverse((n) => {
if (n instanceof P ? e.push(n) : i[0] && n instanceof d && (i[0] = !1), "material" in n) {
Array.isArray(n.material) && (n.material = n.material[0]), n.material.opacity === 1 && (n.castShadow = !0, n.receiveShadow = !0), n.material.userData.TextureManager = T(n.material);
return;
}
n.castShadow = !0, n.receiveShadow = !0;
});
for (const n of e)
(s = n.parent) == null || s.remove(n);
};
export {
q as c,
L as p
};