def setup
createCanvas(100, 100, WEBGL)
@img = loadImage("panda.png")
end
def draw
background(0)
rotateZ(frameCount * 0.02)
rotateX(frameCount * 0.02)
rotateY(frameCount * 0.02)
# pass image as texture
texture(@img)
box(width / 2)
end
def setup
createCanvas(100, 100, WEBGL)
@pg = createGraphics(200, 200)
@pg.textSize(75)
end
def draw
background(0)
orbitControl
@pg.background(255)
@pg.text('hello!', 0, 100)
# pass image as texture
texture(@pg)
rotateX(0.5)
noStroke
plane(50)
end
def setup
createCanvas(100, 100, WEBGL)
@img = loadImage("panda.png")
end
def draw
background(0)
orbitControl
texture(@img)
textureMode(NORMAL)
shape do
vertex(-40, -40, 0, 0)
vertex(40, -40, 1, 0)
vertex(40, 40, 1, 1)
vertex(-40, 40, 0, 1)
end
end
3Dモデルにテクスチャを設定します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| tex | p5.Imageオブジェクト p5.Graphicsオブジェクト |
なし
・WEBGLモードのキャンバスでのみ有効です。
・beginShapeメソッドや shapeメソッドで作成された形体にテクスチャを適用するには
vertexメソッドで uv座標を指定する必要があります。