GPUTexture:width 屬性

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

安全上下文: 此功能僅在安全上下文(HTTPS)中可用,且支援此功能的瀏覽器數量有限。

注意:此功能在 Web Workers 中可用。

GPUTexture 介面的 **width** 只讀屬性表示 GPUTexture 的寬度。

此屬性是根據在最初的 GPUDevice.createTexture() 呼叫中傳入的描述符物件中的 size 屬性值設定的。

一個數字。

示例

js
// …

const depthTexture = device.createTexture({
  size: [640, 480],
  format: "depth24plus",
  usage: GPUTextureUsage.RENDER_ATTACHMENT,
});

console.log(depthTexture.width); // 640

規範

規範
WebGPU
# dom-gputexture-width

瀏覽器相容性

另見