RepeatWrapping returns Cannot read property 'set' of undefined

I can’t seem to set the repeat on a texture…

const geometry = new THREE.BoxGeometry(10,20,20);

            let cubeMat = new THREE.MeshBasicMaterial( {map: new THREE.TextureLoader().load('/materials/plaid3.jpg'), 
                         side: THREE.DoubleSide, name: "cubeMat"});
                        
                    cubeMat.wrapS = THREE.RepeatWrapping;
					cubeMat.wrapT = THREE.RepeatWrapping;
					const tileX = 4;
					const tileY = 4;
					cubeMat.repeat.set(tileX, tileY);


			const cube = new THREE.Mesh( geometry, cubeMat );
			scene.add( cube );

throws the error setTiling.html:38 Uncaught TypeError: Cannot read property ‘set’ of undefined

  • at setTiling.html:38*

What am I missing? Many thanks.

Im not 100% sure but I think you need to use

var texture = loader.load( 'myTexture.jpg', function ( texture ) {

    texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
    texture.offset.set( 0, 0 );
    texture.repeat.set( 2, 2 );

} );

let cubeMat = new THREE.MeshBasicMaterial( {map: texure, 
                         side: THREE.DoubleSide, name: "cubeMat"});

…Texture.wrapS = THREE.RepeatWrapping;

see BeginnerExample from Collection of examples from discourse.threejs.org

// … step 05: modify standard geometries

ropeTexture

That worked! Many, many thanks, forerunrun!

@Bruce_Hammond pleasure