WebGLRenderingContext:clearDepth() 方法

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

WebGL APIWebGLRenderingContext.clearDepth() 方法指定深度缓冲区的清除值。

指定调用 clear() 方法时使用的深度值。该值被限制在 0 到 1 之间。

语法

js
clearDepth(depth)

参数

depth

GLclampf。指定清除深度缓冲区时使用的深度值。默认值为 1。

返回值

无(undefined)。

示例

js
gl.clearDepth(0.5);

查询 DEPTH_CLEAR_VALUE 常量以获取当前深度清除值。

js
gl.getParameter(gl.DEPTH_CLEAR_VALUE);
// 0.5

规范

Specification
WebGL Specification
# 5.14.3

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
clearDepth

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见