gl-disjoint-skybox

1.0.1 • Public • Published

gl-disjoint-skybox

Draws a disjoint skybox into a 3D scene.

Install

npm install gl-disjoint-skybox

Example

var debugCubemap = require('gl-cubemap-placeholder');
var createSkybox = require('gl-disjoint-skybox');
 
var textures = debugCubemap(gl);
var skybox = createSkybox(gl, textures);
 
var view = mat4.create();
var projection = mat4.create();
 
mat4.lookAt(view, [0,0,0], [0,0,-1], [0,1,0]);
mat4.perspective(projection, Math.PI/2, width/height, 0.1, 10.0);
 
skybox.draw({
    view: view,
    projection: projection
});
 

API

var createSkybox = require('gl-disjoint-skybox');

Constructor

var skybox = createSkybox(gl, textures)

Returns a skybox object ready for rendering.

Takes a WebGL context gl and a disjoint cubemap textures structured so:

{
    pos: {
        x: gl-texture2d texture,
        y: gl-texture2d texture,
        z: gl-texture2d texture
    },
    neg: {
        x: gl-texture2d texture,
        y: gl-texture2d texture,
        z: gl-texture2d texture
    }
}

See gl-texture2d for more information about the required texture objects.

Methods

skybox.draw(camera)

Takes an object camera that has view and projection fields defined:

{
    view: gl-mat4 view matrix,
    projection: gl-mat4 projection matrix
}

Readme

Keywords

none

Package Sidebar

Install

npm i gl-disjoint-skybox

Weekly Downloads

2

Version

1.0.1

License

Unlicense

Last publish

Collaborators

  • wwwtyro