在开始之前,我会说我对Blender /3DSMAX/ ThreeJS和图形编程是个新手。
我从StarCraft编辑器中导出了一只野马(从StarCraft)拍打翅膀的动画作为.m3文件,我将其导入到搅拌器中。在导出时,我可以将生成的.json导入到我的ES6应用程序中,但由于某些原因,使用THREE.Animation时,虽然导入的Mutalisk的位置正确更改,但它来回摆动,Mutalisk对象的实际摆动并未发生。
我的渲染器看起来像这样:
import THREE from 'three';
export default class Renderer {
constructor(game, canvas) {
this.game = game;
this.canvas = canvas;
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(75, this.canvas.width / this.canvas.height, 1, 10000);
this.camera.position.z = 2;
this.camera.position.y = 1;
this.clock = new THREE.Clock;
this.renderer = new THREE.WebGLRenderer({ canvas: this.canvas });
this.renderer.setSize( this.canvas.width, this.canvas.height );
}
// called by my Game class, which waits for the mesh to load before attempting to add it to the scene
addMeshToScene(mesh) {
this.mesh = mesh;
this.scene.add(this.mesh);
this.animation = new THREE.Animation(
this.mesh,
this.mesh.geometry.animations[ 2 ]
);
this.animation.play();
}
renderFrame() {
THREE.AnimationHandler.update(this.clock.getDelta());
this.renderer.render(this.scene, this.camera);
}
}
这是渲染。正如我所说的,我的浏览器中的Mutalisk沿着Y轴弹跳,但没有摆动。
有没有人能解释为什么运动会发生,而不是拍打?
编辑:这是我的搅拌机导出设置。
发布于 2015-09-19 22:12:24
解决了。问题是材质必须处于蒙皮模式才能正确包裹骨架。当我从JSON创建网格时,我必须设置material.skinning = true
import THREE from 'three';
export default class Mesh {
constructor(name) {
this.name = name;
this.loaded = false;
this.filepath = `./meshes/${this.name}.json`
this.load();
}
load() {
var loader = new THREE.JSONLoader();
loader.load(this.filepath, (geometry) => {
this.geometry = geometry;
var material = new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true } );
material.skinning = true; // this is where the magic happens
this.mesh = new THREE.SkinnedMesh(geometry, material);
this.loaded = true;
});
}
}
https://stackoverflow.com/questions/32665180
复制