[英]Automate texture mapping in Three.js
如果是平铺纹理(重复时没有接缝),您可以根据立方体的大小重复纹理。
// depending on how you create the cube, the actual size of the cube is hidden either in
// the geometry, the transformation matrix (or object scale), or both. This should respect all.
var size = cube.geometry.boundingBox.getSize().multiply(cube.scale);
// adjust size of texture with `resolution` or some constant
var repeatFactor = resolution * size.x;
var texture = cube.material.map;
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( repeatFactor, repeatFactor );
texture.needsUpdate = true;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.