CanvasTexture 画布纹理

—> Texture

CanvasTexture 里面的第一个参数就是 H5 的 canvas 标签对象.

function CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { } var canvas = document.createElement( "canvas" ), context = canvas.getContext( "2d" ); canvas.width = canvas.height = 512; context.fillStyle = "rgb(100, 20, 140)"; context.fillRect(0, 0, 512,512); context.translate(300, 80); for(var i = 0; i < 80; i++){ context.transform(0.95, 0, 0, 0.95, 40, 40); context.rotate(Math.PI/12); context.fillStyle = "#ee6688"; context.beginPath(); context.arc(0, 0, 20, 0, Math.PI*2, true); context.closePath(); context.fill(); } var canvasTexture = new THREE.CanvasTexture( canvas ); var planeGeometry = new THREE.PlaneGeometry( 6, 6 ), material = new THREE.MeshStandardMaterial( { map: canvasTexture, side:THREE.DoubleSide }), plane = new THREE.Mesh( planeGeometry, material); scene.add( plane );

Attributes

isCanvasTexture : Boolean

Default value : true (只读)
Description : 类型是否为CanvasTexture.

needsUpdate : Boolean

Default value : true
Description : 下次使用纹理时触发更新.