// Defining variables for 3 obj models: cushion, backrest, and frame, and a group variable chair01 to include all 3 obj models
var cushion;
var backrest;
var frame;
var chair01 = new THREE.Object3D();
var loader = new THREE.OBJLoader( manager );
// Loading obj models using a function
loadObj("chair/obj/cushion.obj", cushion, materialCushion);
loadObj("chair/obj/backrest.obj", backrest, materialBackrest);
loadObj("chair/obj/frame.obj", frame, materialFrame);
function loadObj(path, name, material) {
loader.load('model-stuff/' + path, function( object ) {
object.traverse( function ( child ){
if ( child instanceof THREE.Mesh ) {
var uvs = child.geometry.attributes.uv.array;
child.geometry.addAttribute( 'uv2', new THREE.BufferAttribute( uvs, 2 ) );
child.material = material;
child.receiveShadow = true;
child.castShadow = true;
}
});
name = object;
name.position.y = -10;
chair01.add( name );
}, onProgress, onError);
}
// Adding chair01 to the scene
scene.add(chair01);
// Removing frame from chair01
manager.onLoad = function() {
chair01.remove(frame);
}
In the code above, obj models are loaded using the loadObj function. However, there seems to be an issue with removing the "frame" from chair01.
I have attempted an alternative method, and it seems that when the obj models are not loaded via the loadObj function, I am able to successfully remove the frame from chair01.