How to place imported Blender models in array?

Hello,
I have a problem, I got something like this:
test
that’s test model for my city project, and for this i got code like this:

	var loader = new THREE.GLTFLoader();
	loader.load( 'Building/2.gltf',( gltf ) => {
	this.scene.add(gltf.scene);
    gltf.scene.scale.set(1, 1, 1);
	gltf.scene.position.set(2, 0, 2);
    },
    null,
    null
	);

and my question is, how to make this model in array, I mean every 20px is this model (and next i’ll make every 20px another model) to make little city model, and by the way how to add cast and recive shadows on this?

Thank You Very Much

Are you looking for something like that? https://jsfiddle.net/f2Lommf5/12573/

The idea is to use .clone() to create an exact copy of the object(s) you want to place side by side.

If you want to add shadow casting, it’s best when you traverse gltf.scene once and set castShadow and receiveShadow to true.

gltf.scene.traverse( function( child ) {

    if ( child.isMesh ) {

        child.castShadow = true;
        child.receiveShadow = true;

    }

} );

You also have to set renderer.shadowMap.enabled to true and adding some lights to your scene.

2 Likes

Wow man, it worked, You’re the best, Thanks