【发布时间】:2015-12-16 09:07:06
【问题描述】:
我先说我是 Blender / 3DS MAX / ThreeJS 和图形编程的新手。
我从星际争霸编辑器中将异龙(来自星际争霸)拍打翅膀的动画导出为 .m3 文件,然后将其导入 Blender。导出后,我可以将生成的 .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);
}
}
这是渲染。正如我所说,我浏览器中的异龙在 Y 轴上弹跳,但没有摆动。
谁能解释一下为什么会发生运动,而不是拍打?
编辑:这是我的 Blender 导出设置。
【问题讨论】:
-
有趣的是,我刚刚注意到我所有的动画[] 每个都有 44 个步骤。我猜这可能是我的 Blender 导出的问题。
-
你能报告你在导出器中选择了哪些动画参数吗?
-
如何实例化
Renderer?你在哪里打电话addMeshToScene,在哪里打电话renderFrame? -
在我的 Game 类中,有一个 setup 方法只调用了
this.setRenderer(new Renderer(this, this.canvas))。我不认为那部分代码不是问题。在 Blender 中:几何:顶点、面、法线、UV、骨骼、蒙皮。应用修改器(选中)几何 UInt16Array。骨骼动画,休息。嵌入动画。设置,复制纹理。 -
我用我当前的代码创建了一个仓库。我所说的一切都在
client/js/renderer.js
标签: javascript 3d three.js ecmascript-6 blender