I have array with postion and type. And show all cubes on their positions.
array = [
{ name: 'iadA', pos: new THREE.Vector3(-40, -40, 10), type: 0, error: false, warning: true },
{ name: 'iadB', pos: new THREE.Vector3(+20, -55, 20), type: 1, error: false, warning: false },
{ name: 'aBCF', pos: new THREE.Vector3(-40, -32, 0), type: 0, error: true, warning: false },
{ name: 'aF', pos: new THREE.Vector3(-10, -22, 0), type: 7, error: false, warning: false }
]
for(let x in array) {
let geometry = new THREE.CubeGeometry( 1, 1, 1);
let cube = new THREE.Mesh( geometry , this.color);
cube.position.x = array[x].pos.x;
cube.position.y = array[x].pos.y;
cube.position.z = array[x].pos.z;
this.scene.add(cube);
}
And when I want to filter it by type 0 or 1 I get filtered array in console.log. But my cubes on scene don’t refreshing.
<button type="button" (click)="filter('0')">Filter0</button>
<button type="button" (click)="filter('1')">Filter1</button>
filter(type) {
let positions = array.filter(ar => {
return ar.type == type;
});
console.log(positions);
}
Please help.
Thanks