Is there a simpler way to handle this code for exporting to an STL file or for the cutting function? I find the current method too troublesome. Thank you!
var material1 = new THREE.MeshPhongMaterial( {
color:0xffffff,
} );
loader.load( 'fanban1.stl', function ( geometry ) {
stl_mesh1 = new THREE.Mesh(geometry, material1);
stl_mesh1.position.set(20, 0, 40);
stl_mesh1.rotation.set(-Math.PI / 2, 0, 0);
stl_mesh1.scale.set(0.2, 0.2, 0.2);
group.add(stl_mesh1);
arr_mesh.push(stl_mesh1);
});
var material2 = new THREE.MeshPhongMaterial( {
color:0xFFFF00,
} );
loader.load( 'fanban2.stl', function ( geometry ) {
stl_mesh2 = new THREE.Mesh(geometry, material2);
stl_mesh2.position.set(20, 0, -20);
stl_mesh2.rotation.set(-Math.PI / 2, 0, 0);
stl_mesh2.scale.set(0.3, 0.3, 0.3);
group.add(stl_mesh2);
arr_mesh.push(stl_mesh2);
});
scene.add(group);
After some edits, it looks like this:
var allGeometry = new THREE.Geometry();
loader.load( 'fanban.stl', function ( geometry ) {
stl_mesh = new THREE.Mesh(geometry, material);
stl_mesh.position.set(20, 0, -60);
stl_mesh.rotation.set(-Math.PI / 2, 0, 0);
stl_mesh.scale.set(0.3, 0.3, 0.3);
group.add(stl_mesh);
arr_mesh.push(stl_mesh);
allGeometry.merge(geometry);
});
However, an error is reported: THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.