参考 texture()

texture()

设置将用于形状的纹理。

纹理就像是包裹在形状周围的皮肤。texture() 函数可用于内置的形状,例如 square()sphere(),以及使用 buildGeometry() 等函数创建的自定义形状。要对使用 beginShape() 创建的几何体进行纹理化,必须为每个 vertex() 调用传递 uv 坐标。

参数 tex 是要应用的纹理。texture() 可以使用包括图像、视频和离屏渲染器等来源,例如 p5.Graphicsp5.Framebuffer 对象。

要对使用 beginShape() 创建的几何体进行纹理化,你需要在 vertex() 中指定 uv 坐标。

注意:texture() 只能在 WebGL 模式下使用。

示例

语法

texture(tex)

参数

tex

将媒体用作纹理。

Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/material.js and open a pull request!

相关参考