Three.js - Why is csg.js not working?

前端 未结 1 1944
时光说笑
时光说笑 2021-01-24 14:42

I tried to use csg.js-functions to cut a sphere out of a box, but it is not working? I read the tutorial on http://learningthreejs.com/blog/2011/12/10/constructive-solid-geometr

相关标签:
1条回答
  • 2021-01-24 15:23

    The article is outdated, this is the new syntax:

    var box = new THREE.Mesh( new THREE.BoxGeometry( 10, 1, 10 ) );
    var box_bsp = new ThreeBSP( box );
    
    var cutgeo = new THREE.SphereGeometry( 1, 16, 8 );
    var sub = new THREE.Mesh( cutgeo );
    var subtract_bsp  = new ThreeBSP( sub );
    var result_bsp  = box_bsp.subtract( substract_bsp );
    
    var result = result_bsp.toMesh();
    scene.add( result );
    

    Three.js r107: http://jsfiddle.net/r7suq1mv/2/

    0 讨论(0)
提交回复
热议问题