这不是让我通过小组调整位置,或者当我尝试改变骑士场景的位置本身。知道为什么吗?这似乎是一种错误的行为,但也许我做错了什么。
export const startLocalPlayer = (scene) => {
const { knightScene } = getKnightClone();
group.add(knightScene);
scene.add(group);
group.position.y = 4;
};
和
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
import { AnimationMixer } from "three";
import Store from "../../store/store";
const loader = new GLTFLoader();
let gltf;
export const loadKnight = () => {
loader.load(
"/assets/KnightCharacter.glb",
function (_gltf) {
gltf = _gltf;
gltf.scene.scale.multiplyScalar(0.5);
Store.finishedLoadingAsset();
},
function (xhr) {},
function (error) {
console.log("An error happened");
}
);
};
export const getKnightClone = () => {
let knightScene = gltf.scene.clone();
let theMixer = new AnimationMixer(gltf.scene);
let idleClip = theMixer.clipAction(gltf.animations[0]);
let runningClip = theMixer.clipAction(gltf.animations[3]);
return { knightScene, idleClip, runningClip, theMixer };
};
发布于 2022-08-27 08:21:41
设knightScene = gltf.scene.clone();
复制你的资产如下:
import * as SkeletonUtils from 'three/examples/jsm/utils/SkeletonUtils.js';
// ...
const knightScene = SkeletonUtils.clone( gltf.scene );
Object3D.clone()
还没有正确处理皮肤网格。一个完整的演示展示了SkeletonUtils.clone()
的使用,可以在这里查看:https://threejs.org/examples/#webgl_animation_multiple
https://stackoverflow.com/questions/73508763
复制相似问题