【问题标题】:CSG operations on bufferGeometrybufferGeometry 上的 CSG 操作
【发布时间】:2016-07-13 23:43:29
【问题描述】:

我目前正在使用 three.js 几何类来创建一个形状,然后对该形状执行多个 CSG 操作。从而不断地重新绘制形状。

这个执行多个 csg 操作的过程很慢,因为我使用光线投射来获取单击时的形状并执行所选形状和预定义形状(任何形状或几何形状)的 CSG。

所以我的问题是:

  • 使用缓冲区几何会加速我的 CSG,但是否有任何库可以在 THREE.BufferGeometry 实例上执行 CSG 操作?

  • 有没有一种方法可以通过使用任何其他方法来加快进程?

这是我的代码流程:

var objects = [];

init();
render();

function init(){
 //scene and camera setup ... etc
   var sphere =  new THREE.SphereGeometry(200, 32, 32);
   objects.push(sphere);
 // raycasting config
 // bind mouse click and move event
 }
  function onMouseDown() {

   var intersects = raycaster.intersectObjects(objects);
   .....
   // get intersected shape ..
   // perfrom csg with predifend shape .
   // Also contains steps to convert 
      geometry to *CSG libaray geometry* 
      and back to Three.js geometry)..
   // replace the shape with existing
   .....
    render();
 }

我正在使用 this 库进行 CSG 操作,整体流程类似于三个.js 示例中的 this example

【问题讨论】:

    标签: javascript three.js buffer-geometry threecsg


    【解决方案1】:

    我没有用于性能比较的元素,但是您可以在 Wilt 的 ThreeCSG ThreeCSG develop 的开发分支中找到缓冲几何库

    它支持缓冲几何(来自示例):

    var nonIndexedBoxMesh = new THREE.Mesh( nonIndexedBufferGeometry, material );
    var bsp1 = new ThreeBSP( nonIndexedBoxMesh );
    var indexedBoxMesh = new THREE.Mesh( indexedBufferGeometry, material );
    var bsp2 = new ThreeBSP( indexedBoxMesh );
    var geometry = bsp1.subtract( bsp2 ).toBufferGeometry();
    var mesh = new THREE.Mesh( geometry, material );
    

    它适用于 r75

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-16
      • 2014-04-03
      • 2013-08-13
      • 2014-12-23
      • 1970-01-01
      • 2020-07-18
      • 2012-06-07
      • 1970-01-01
      相关资源
      最近更新 更多