1

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.

houssk
  • 146
  • 1
  • 7
  • Does `mesh.geometry.attributes.position.needsUpdate = true;` work? If not, please provide more information so your problem can be reproduced. – WestLangley Apr 04 '16 at 13:47
  • Hello thanks for your answer, it's doesn't work i dont have acces to attributes, for example for update cube i write this code – houssk Apr 04 '16 at 21:54
  • See http://stackoverflow.com/questions/31859819/how-to-update-the-geometry-vertex-position-objloader/31861313#31861313. – WestLangley Apr 04 '16 at 22:17

0 Answers0