What is the correct way to edit the vertices of a box geometry?

后端 未结 1 491
抹茶落季
抹茶落季 2021-01-14 11:13

So I\'m editing the vertices of many box geometries to create unique shapes, or to modify the heights of the geometries. It works fine and my scenes look correct (here\'s an

1条回答
  •  礼貌的吻别
    2021-01-14 11:59

    After a bunch of research, I've found that currently, the correct way to do this is to convert your BoxGeometry objects to BufferGeometry or regular Geometry objects. You can do this after editing their vertices.

    So something like this

    var box = new THREE.BoxGeometry(64 , 32 , 64);
    
    box.verticesNeedUpdate = true;
    box.vertices[0].y = 128;
    box.vertices[1].y = 128;
    
    var geometry = new THREE.BufferGeometry().fromGeometry(box);
    
    //or alternatively
    
    var geometry = new THREE.Geometry();
    geometry.merge(box);
    

    Now, if you export the object using the ObjectExporter it should load into http://threejs.org/editor fine.

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