regl-primitive

1.0.1 • Public • Published

regl-primitive

Create a regl draw command from a simplicial complex.

Example

const primitive = require('regl-primitive')
const bunny = require('bunny')
const regl = require('regl')()
 
const camera = require('regl-camera')(regl, {
  center: [0, 2.5, 0],
  distance: 20
})
 
const drawBunny = primitive(regl, bunny, {
  vert: `
  precision mediump float;
  attribute vec3 position, normal;
  uniform mat4 projection, view;
  varying vec3 vnormal;
  void main () {
    vnormal = normal;
    gl_Position = projection * view * vec4(position, 1.0);
  }
  `,
 
  frag:`
  precision mediump float;
  varying vec3 vnormal;
  void main () {
    gl_FragColor = vec4(abs(vnormal), 1.0);
  }
  `
})
 
regl.frame(() => camera(() => drawBunny()))
 

Installation

$ npm install regl-primitive --save

See demo here

API

Constructor

const primitive = require('regl-primitive')(regl, complex[, options])

where regl-primitive expects the following arguments:

  • regl - A handle to a regl instance
  • complex - An object exposing at least positions (See simplicial-complex)
  • [configuration] - An optional object that extends the initial state used to create a regl draw command

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i regl-primitive

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • littlstar
  • werle