Hey,
i develop a Function which should hide all Meshes. There are also 1 Function which hide a Mesh by clicking on it.
Now in the new Function which should hides all Meshes i iterate through a for-loop and choose in every loop the needed region and elements of the Mesh. Now i get everytime at **this.scene.getMeshByID(this.regions["region"].id)**
a null returned. I don’t know why.
I have also the 1 other Function which hide a Mesh by clicking on it. There all works fine. There are the same values like in the new Function. But in the new Function it don’t works. I have debugging and testing now a lot but don’t find the Error…
This is my Code:
regions = {
kamera : { id: ‘Kamera’, alpha: 6.153267413154244, beta: 1.3094542662847675, radius: 20 },
motorschutz : { objects: {object1: ‘Motorschutz Groß’, object2: ‘Motorschutz Groß.001’, object3:‘Motorschutz Groß.002’, object4:‘Motorschutz Groß.003’}, alpha: 5.398361953174415, beta: 1.648784279856813, radius: 20 }
}
hideAllMeshes = () => {
let objects, objectMesh;
for (let region in this.regions){
objects = this.regions[region].objects;
if(objects == undefined){
let object = this.scene.getMeshByID(this.regions[region].id);
object.setEnabled(false);
}else{
for(let object in objects){
objectMesh = this.scene.getMeshByID(this.regions[region].objects[object])
objectMesh.setEnabled(false);
}
}
}
}
//Build the scene when the component has been loaded.
componentDidMount() {
this.setEngine()
this.setScene()
this.setCamera()
this.loadModels().load()
this.hideAllMeshes();
}
Have anyone an Idea why it don’t works?