I recently created a building model using 3DS Max, where each room is represented by a modified cube. To load the OBJ file along with its corresponding MTL, I utilized OBJMTLLoader. However, my current challenge lies in highlighting specific rooms based on user requirements.
To address this issue, I implemented dat.gui to present a menu allowing users to mark/unmark rooms for emphasis (potentially by adjusting room size or material).
Displayed below is the code for my loader:
var loader = new THREE.OBJMTLLoader();
loader.load( 'models/ed.obj', 'models/textures/ed.mtl',
//onLoad()
function ( object ){
contenido = object;
contenido.position.set(0,0,0);
contenido.position.y = -80;
contenido.name = 'building';
scene.add(contenido);
return contenido;
}
The transparency functionality allows manipulation of the entire model by adjusting opacity through a dat.gui bar labeled opciones.Opacidad:
contenido.traverse( function( object ) {
if( object.material ) {
object.material.opacity = opciones.Opacidad;
object.material.transparent = true;
}
While this feature works as intended, I encountered difficulties when attempting to access internal cubes within the geometry to highlight them in wireframe mode. The following method was used:
contenido.getObjectByName("RoomNameIn3DSMax").material.wireframe=true;
Despite successfully locating these objects without errors, they do not appear in wireframe mode. This inconsistency may be attributed to the Groups generated by the OBJMTLLoader.
Additionally, alternative approaches such as the one shown below did not yield desired outcomes:
contenido.traverse( function ( child ) {
if ( child.name == "NameInOBJor3DSMax" ) {
child.material.wireframe = true;
}
})
Hence, my primary query revolves around effectively accessing internal modules of the model loaded via OBJMTLLoader. Any insights or assistance on this matter would be greatly appreciated.
For further details and access to the code and files, please visit the following link: 3DBuilding link.
Thank you in advance for your help and suggestions!