cubes created by three.js are interfere ,parts of those cubes become transparency when rotating the camera,

。_饼干妹妹 提交于 2019-12-20 04:19:01

问题


I create some cubes with three.js CanvasRender. I met an issue, parts of those cubes become transparency when rotating the camera,please see the image(http://imgur.com/fAY6B). When I change the CanvasRender to WebGLRender, the issue can't be reproduced. I have to use CanvasRender.

Any ideas anyone? Any help will be much appreciated.

for (....){
  var material = new THREE.MeshPhongMaterial({ color: color.getHex(), shading: THREE.FlatShading, overdraw: true});
  var geometry = new THREE.CubeGeometry(width, height, depth, 1, 1, 1);
  var cube = new THREE.Mesh(geometry, material);
  cube.position = position;
  scene.add(cube);
}

I try to set the heightSegments value to higher, it does look well, but still not work as well as I want. The jsfiddle link is here. http://jsfiddle.net/qcy1121/xn7ad/


回答1:


What you are seeing is a limitation of CanvasRenderer due to the way it handles depth-sorting.

While WebGLRenderer sorts at the pixel level, CanvasRenderer sorts at the polygon level.

The best you can do is to increase the tessellation of your cubes like so:

var geometry = new THREE.CubeGeometry(width, height, depth, 1, 10, 1);

Updated fiddle: http://jsfiddle.net/xn7ad/1/

There will be a performance hit.

three.js r.53




回答2:


I hope this would work.

use side: THREE.DoubleSide in material

jsfiddle



来源:https://stackoverflow.com/questions/14019880/cubes-created-by-three-js-are-interfere-parts-of-those-cubes-become-transparenc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!