mylingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
30 lines • 1.16 kB
JavaScript
import { FBXLoader } from "./loaders/FBXLoader";
import { Bone, Light } from "three";
import { forceGet } from "@lincode/utils";
import cloneSkinnedMesh from "../cloneSkinnedMesh";
import { handleProgress } from "./bytesLoaded";
const cache = new Map();
const loader = new FBXLoader();
export default async (url, clone) => {
const [group, noBone] = await forceGet(cache, url, () => new Promise((resolve, reject) => {
loader.load(url, (group) => {
const lights = [];
let noBone = true;
group.traverse((child) => {
if (child instanceof Light)
lights.push(child);
else if (noBone && child instanceof Bone)
noBone = false;
child.castShadow = true;
child.receiveShadow = true;
});
for (const light of lights)
light.parent?.remove(light);
resolve([group, noBone]);
}, handleProgress(url), reject);
}));
if (clone)
return cloneSkinnedMesh(group, noBone);
return group;
};
//# sourceMappingURL=loadFBX.js.map