API Docs for:
Show:

GL.Buffer Class

Defined in: ../src/mesh.js:26

A data buffer to be stored in the GPU

Constructor

GL.Buffer

(
  • target
  • data
  • spacing
  • stream_type
)

Defined in ../src/mesh.js:26

Parameters:

  • target Number

    gl.ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER

  • data ArrayBufferView

    the data in typed-array format

  • spacing Number

    number of numbers per component (3 per vertex, 2 per uvs...), default 3

  • stream_type Enum

    default gl.STATIC_DRAW (other: gl.DYNAMIC_DRAW, gl.STREAM_DRAW

Methods

applyTransform

(
  • mat
)

Defined in ../src/mesh.js:70

Applies a mat4 transform to every triplets in the buffer (assuming they are points) No upload is performed (to ensure efficiency in case there are several operations performed)

Parameters:

  • mat Mat4

clone

(
  • share
)

Defined in ../src/mesh.js:196

Clones one buffer (it allows to share the same data between both buffers)

Parameters:

  • share Boolean

    if you want that both buffers share the same data (default false) return {GL.Buffer} buffer cloned

delete

()

Defined in ../src/mesh.js:255

Deletes the content from the GPU and destroys the handler

forEach

(
  • callback
)

Defined in ../src/mesh.js:55

Applies an action to every vertex in this buffer

Parameters:

  • callback Function

    to be called for every vertex (or whatever is contained in the buffer)

setData

(
  • data
  • offset
)

Defined in ../src/mesh.js:134

Assign data to buffer and uploads it (it allows range)

Parameters:

  • data ArrayBufferView

    in Float32Array format usually

  • offset Number

    offset in bytes

upload

(
  • stream_type
)

Defined in ../src/mesh.js:87

Uploads the buffer data (stored in this.data) to the GPU

Parameters:

  • stream_type Number

    default gl.STATIC_DRAW (other: gl.DYNAMIC_DRAW, gl.STREAM_DRAW

uploadRange

(
  • start
  • size
)

Defined in ../src/mesh.js:174

Uploads part of the buffer data (stored in this.data) to the GPU

Parameters:

  • start Number

    offset in bytes

  • size Number

    sizes in bytes