I'm working on a project in the medical field using threejs, and OBJ files shin bone, my goal is that I get to cut part of the tibia on the basis of a given position, for now I can do that by replacing the vertix of the object, but my problem is that I can not directly update the object, so every time I delete the old object and I upload it, although i put verticeNeedUpdate … My question is if it's possible to directly update the object?
loader.load('img/cube.obj',function(object){
var material = new THREE.MeshLambertMaterial({color:0xA0A0A0});
slice_onZ.onChange(function(z){
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
child.material = material;
geometry = new THREE.Geometry().fromBufferGeometry(child.geometry);
for(var i=0 ; i< geometry.vertices.length ; i++) {
if (geometry.vertices[ i ].x != 0) {
geometry.vertices[ i ].x = z;
}
if (geometry.vertices[ i ].y != 0) {
geometry.vertices[ i ].y = z;
}
if (geometry.vertices[ i ].z != 0) {
geometry.vertices[ i ].z = z;
}
}
geometry.verticesNeedUpdate = true;
mesh = new THREE.Mesh( geometry, material );
console.log(mesh.geometry.attributes);
scene.add(mesh);
}
});
});
},onProgress,onError);
}
there is my code, i try to update geometry but it's doesnt work, i have to reload everytime the object and delete the old one for display the new on.