This example展示瞭如何建立自己的貼圖:
function mipmap(size, color) {
var imageCanvas = document.createElement("canvas"),
context = imageCanvas.getContext("2d");
imageCanvas.width = imageCanvas.height = size;
context.fillStyle = "#444";
context.fillRect(0, 0, size, size);
context.fillStyle = color;
context.fillRect(0, 0, size/2, size/2);
context.fillRect(size/2, size/2, size/2, size/2);
return imageCanvas;
}
var canvas = mipmap(128, '#f00');
var textureCanvas1 = new THREE.Texture(canvas, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping);
textureCanvas1.repeat.set(1000, 1000);
textureCanvas1.mipmaps[ 0 ] = canvas;
textureCanvas1.mipmaps[ 1 ] = mipmap(64, '#0f0');
textureCanvas1.mipmaps[ 2 ] = mipmap(32, '#00f');
textureCanvas1.mipmaps[ 3 ] = mipmap(16, '#400');
textureCanvas1.mipmaps[ 4 ] = mipmap(8, '#040');
textureCanvas1.mipmaps[ 5 ] = mipmap(4, '#004');
textureCanvas1.mipmaps[ 6 ] = mipmap(2, '#044');
textureCanvas1.mipmaps[ 7 ] = mipmap(1, '#404');
textureCanvas1.needsUpdate = true;
感謝您的答覆。對於記錄我想說,無論是畫布或圖像可以飼料作爲mipmap。在我的情況下,問題是由於一些生成的mipmap很糟糕,mipmap金字塔的最後3個級別的大小沒有正確的大小,所以整個紋理被視爲黑色,作爲正確的紋理被丟棄。 –