Forum

How to change mesh of 3d object

19 June 2017 14:07
I need to change mesh for an object using JS (I don't want to change object parameters, only the mesh of it).
Just like i can do it in Blender here:



I was looking for the method in API Reference but I didn't found anything similar to that.

Please help!
21 June 2017 14:14
I think the closest thing you will get can be found in the Geometry Change code snippet. Click the 'View Code' button at the lower left of the page. The code looks like this:

function geometry_change(indices, positions) {
    var plane_blue = m_scs.get_object_by_name("Plane");
    var plane_red = m_scs.get_object_by_name("Plane.002");
    var indices = new Uint16Array([0,1,2,3,4,5]);
    var positions_blue = new Float32Array([0,0,1, -1,-1,0, 1,1,0, 1,1,0, -1,-1,0, 1,-1,0]);
    var positions_red = new Float32Array([-9,9,1, -10,8,0, -8,10,0, -8,10,0, -10,8,0, -8,8,0]);

    m_geom.override_geometry(plane_blue, "Material", indices, positions_blue, false);
    m_geom.override_geometry(plane_red, "Material.002", indices, positions_red, false);
    // update object's boundings after mesh geometry changing 
    m_obj.update_boundings(plane_blue);
    m_obj.update_boundings(plane_red);
}
 
Please register or log in to leave a reply.