鸟翅膀没有与three.js帆布几何鸟拍打

时间:2018-01-04 17:29:45

标签: three.js

我给画布一个透明的背景,下面的代码让它看起来像鸟儿飞过一个风景。但是当我这样做时,鸟儿的翅膀不再襟翼。我究竟做错了什么?

renderer = new THREE.CanvasRenderer();
renderer.setClearColor(0x000000, 0);
renderer.setPixelRatio(window.devicePixelRatio);
renderer = new THREE.WebGLRenderer({alpha: true, canvas: birdscanvas});

如果我发表评论

renderer = new THREE.WebGLRenderer({alpha: true, canvas: birdscanvas});
鸟翼襟翼。

Example here

1 个答案:

答案 0 :(得分:2)

按如下方式更改

  renderer = new THREE.CanvasRenderer({
    alpha: true,
    canvas: birdscanvas
  });
  renderer.setClearColor(0x000000, 0);
  renderer.setPixelRatio(window.devicePixelRatio);
  // renderer = new THREE.WebGLRenderer({ alpha: true, canvas: birdscanvas });

对于基于WebGLRenderer的,请按以下步骤操作;

  renderer = new THREE.WebGLRenderer({
    alpha: true,
    canvas: birdscanvas
  });
  renderer.setClearColor(0x000000, 0);
  renderer.setPixelRatio(window.devicePixelRatio);

render方法中,在for循环的末尾添加以下行;

  bird.geometry.verticesNeedUpdate = true;