# 構造參數
## canvas
> 類型 HTMLCanvasElement | [OffscreenCanvas](https://developer.mozilla.org/zh-CN/docs/Web/API/OffscreenCanvas)
> dom 節點
``` js
// 例一
new WebGLRenderer({
canvas:document.createElement('canvas')
})
// 例二
new WebGLRenderer({
canvas: new OffscreenCanvas(256, 256)
})
```
## context
> 類型 WebGLRenderingContext
>可用于將渲染器附加到已有的渲染環境([RenderingContext](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext))中。默認值是null
``` js
// 例一
var canvas = document.getElementById('myCanvas');
new WebGLRenderer({
// '2d' or '3d' 都是不行的
context:canvas.getContext('webgl')
})
```
## precision
> 類型 string
> 精度 可以是 **"highp"** , **"mediump"** 或者 **"lowp"** . 如果設備支持,默認為 **"highp"**
## alpha
> 類型 boolean
> canvas是否包含alpha (透明度)。默認為**false**
## premultipliedAlpha
> 類型 boolean
> renderer是否假設顏色有premultiplied alpha
> ([位圖圖像](https://en.wikipedia.org/wiki/Bitmap_image "位圖圖像")或[alpha混合](https://en.wikipedia.org/wiki/Alpha_blending "阿爾法混合")計算的一種變體,其中假定RGB顏色值已經乘以alpha通道,以減少[Alpha混合](https://en.wikipedia.org/wiki/Alpha_blending "阿爾法混合")期間的計算;使用[混合操作](https://en.wikipedia.org/w/index.php?title=Blend_operation&action=edit&redlink=1 "混合操作(頁面不存在)"):`dst *= (1 - alpha) + src`;能夠[混合](https://en.wikipedia.org/wiki/Alpha_blending "阿爾法混合")具有[混合](https://en.wikipedia.org/wiki/Additive_blending "添加劑混合")效果的[Alpha混合](https://en.wikipedia.org/wiki/Alpha_blending "Alpha blending"))
## antialias
> 類型 boolean
> 是否執行抗鋸齒。默認為 **false**.
## stencil
> 類型 boolean
> 繪圖緩存是否有一個至少8位的模板緩存([stencil buffer](https://en.wikipedia.org/wiki/Stencil_buffer))
> 模版緩沖([stencil buffer](https://en.wikipedia.org/wiki/Stencil_buffer))或印模緩沖,是在OpenGL三維繪圖等計算機圖像硬件中常見的除顏色緩沖、像素緩沖、深度緩沖之外另一種數據緩沖
> [相關連接csdn](https://blog.csdn.net/silangquan/article/details/46608915)
## preserveDrawingBuffer
> 類型 boolean
> 是否保留緩直到手動清除或被覆蓋
## powerPreference
> 類型 string
> 提示用戶代理怎樣的配置更適用于當前WebGL環境。 可能是 **"high-performance"** , **"low-power"** 或 **"default"** 。默認是 **"default"** . 詳見[WebGL spec](https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.12)
## failIfMajorPerformanceCaveat
> 類型 boolean
## depth
> 類型 boolean
> 繪圖緩存是否有一個至少6位的深度緩存([depth buffer](https://en.wikipedia.org/wiki/Z-buffering))。 默認是 **true**.
## logarithmicDepthBuffer
> 類型 boolean
> 是否使用對數深度緩存。如果要在單個場景中處理巨大的比例差異,就有必要使用