Reputation: 352
What's the correct way to tile a texture in https://threejs.org/editor/ ? I've created a plane with a material called m1 and tried to edit the material script to:
function update( event ) {
m1.wrapS = texture.wrapT = THREE.RepeatWrapping;
m1.repeat.set( 2, 2 );
}
Upvotes: 0
Views: 2157
Reputation: 191
It's not hard to do, but you have no ui to access this parameter. So what you need to do is to create an script attached to any object (it's good to keep scenes in order so attach it to the material) and it should by like:
// To access scene material we pick it's parent object
var myObject = scene.getObjectByName( "ObjectName" );
// We need to set the Wrappers like THREE.RepeatWrapping in order to make it happen.
myObject.material.map.wrapS = myObject.material.map.wrapT = THREE.RepeatWrapping;
// Now we only need to set a new map.repeat
myObject.material.map.repeat.set( 2, 2 );
function update( event ) {
}
As you can see the code is not set into update() because if you do like that material will be changing in every three update, so it will be a loss of memory if this value is not going to change.
Upvotes: 2