three.js皮肤点而不是网格

时间:2017-08-04 15:08:49

标签: three.js glsl fbx

我正在导入动画机器人手的.fbx模型。我想使用蒙皮网格,但渲染gl.POINTS而不是标准网格。

这是我最初的(天真的)尝试。我将各个元素从THREE.Mesh交换到THREE.Points:

  loader.load('/robot-arm-01.fbx', (object) => {

    let children = object.children.map(child => {
      child.material = new THREE.ShaderMaterial({
        vertexShader,
        fragmentShader,
        skinning: true
      })
      let points = new THREE.Points(child.geometry, child.material)
      points.position.copy(child.position)
      points.scale.copy(child.scale)
      points.rotation.copy(child.rotation)
      return points
    })
    object.children = children
  })

问题绝对不在我的顶点着色器中,如果我不交换子数组,我可以播放动画

这可以通过gl.POINTS正确显示我的模型,但是我的动画根本没有开始。我在这里缺少什么?

我唯一的想法是在运行时将gl.TRIANGLES的three.js网格绘制调用更改为gl.POINTS。一个人如何做这样的事情并且有更聪明的方法解决这个问题?

1 个答案:

答案 0 :(得分:1)

这可能不是理想的方法,但到目前为止,它对我没有问题。我所做的只是将所有SkinnedMesh参数复制到Points中。希望对您有帮助

getSkinnedPoints(skinnedMesh) {
    const points = new THREE.Points(skinnedMesh.geometry, skinnedMesh.material);

    points.skeleton = skinnedMesh.skeleton;
    points.bindMatrix = skinnedMesh.bindMatrix;
    points.bindMatrixInverse = skinnedMesh.bindMatrixInverse;
    points.bindMode = skinnedMesh.bindMode;
    points.drawMode = skinnedMesh.drawMode;
    points.name = skinnedMesh.name;
    points.parent = skinnedMesh.parent;
    points.uuid = skinnedMesh.uuid;
    points.type = skinnedMesh.type;

    points.isSkinnedMesh = true;
    points.bind = skinnedMesh.bind;
    points.clone = skinnedMesh.clone;
    points.initBones = skinnedMesh.initBones;
    points.normalizeSkinWeights = skinnedMesh.normalizeSkinWeights;
    points.pose = skinnedMesh.pose;
    points.updateMatrixWorld = skinnedMesh.updateMatrixWorld;

    return points; 
}