How to filter cubes in scene

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;

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;

Please help.

I’ve created a fiddle with your code:

Can you please use the fiddle to explain what kind of result you expect? As you can see, all cubes are visible. Should the click on a button hide certain cubes?

Yes, If you click on button Filter0 cubes with type 0 will stay show, and cubes with type 1 will be hide. Or If you click on button Filter1 cubes with type 1 will stay show, and cubes with type 0 will be hide.

Is it possible to make that?

I maked that on click on filter button make filtering of array and that call
First time show filtered cubes, but when I click on another button nothing happen.

Please can you help me.

Try it like this:

Use Object3D.visible to control which objects are visible.

That is actually that I need.:blush: Thanks, a lot for help.
Really I appreciate it.