--- title: WebGLRenderingContext.clearDepth() slug: Web/API/WebGLRenderingContext/clearDepth tags: - WebGL - 深度清除值 translation_of: Web/API/WebGLRenderingContext/clearDepth ---
WebGL API的WebGLRenderingContext.clearDepth() 方法用于设置深度缓冲区的深度清除值。
这个深度清除值的设定,是为了调用{{domxref("WebGLRenderingContext.clear", "clear()")}} 的时候使用,这个值的范围是0到1。
void gl.clearDepth(depth);
depthNone.
gl.clearDepth(0.5);
若要获取当前深度清除值,查询DEPTH_CLEAR_VALUE 常量。
gl.getParameter(gl.DEPTH_CLEAR_VALUE); // 0.5
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('WebGL', "#5.14.3", "clearDepth")}} | {{Spec2('WebGL')}} | Initial definition. |
| {{SpecName('OpenGL ES 2.0', "glClearDepthf.xml", "glClearDepthf")}} | {{Spec2('OpenGL ES 2.0')}} | Man page of the OpenGL API. |
{{Compat("api.WebGLRenderingContext.clearDepth")}}