开发者社区> 镜像站> NPM> gl-clear
gl-clear
A helper WebGL module for clearing the current buffer – extracted from [@mikolalysenko](http://github.com/mikolalysenko)'s [gl-now](http://github.com/mikolalysenko/gl-now).
Last updated 6 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gl-clear 
SYNC missed versions from official npm registry.

gl-clear stable

A helper WebGL module for clearing the current buffer – extracted from @mikolalysenko's gl-now.

Usage

NPM

clear = glClear(options)

Creates a clear function for you, accepting the following options:

  • color: An RGBA array for the colors to clear the buffer to, between 0 and 1. Set to false to disable.
  • depth: A single value to clear the depth buffer to. Set to false to disable.
  • stencil: A single value to clear the stencil buffer to, disabled by default.

clear(gl)

Clears the current buffer on the gl context.

clear.color = color

Updates the clear color. Set to false to disable.

clear.depth = depth

Updates the depth value to clear to. Set to false to disable.

clear.stencil = stencil

Updates the stencil value to clear to. Set to false to disable.

Alternatives

This module is intended as a small shorthand to WebGL's clear methods. Thankfully clearing is a simple procedure so you are also welcome to fall back onto WebGL's clear methods if gl-clear doesn't meet your needs. For example:

// clear the screen red, and clear the depth buffer:
gl.clearColor(1, 0, 0, 1)
gl.clearDepth(1)
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

If you've written your own clear module, let us know and we'll link to it here!

License

MIT. See LICENSE.md for details.

Current Tags

  • 2.0.0                                ...           latest (6 years ago)

4 Versions

  • 2.0.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
  • 0.0.0                                ...           7 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 2
Dependencies (0)
None
Dev Dependencies (8)