gl-disjoint-skybox
Draws a disjoint skybox into a 3D scene.
Last updated 5 years ago by wwwtyro .
Unlicense · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gl-disjoint-skybox 
SYNC missed versions from official npm registry.

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
}

skybox.update(textures)

Updates the skybox textures. Takes a disjoint cubemap textures structured as described in the constructor.

skybox.dispose()

Disposes of all resources associated with the skybox.

Current Tags

  • 1.0.1                                ...           latest (5 years ago)

2 Versions

  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (5)
Dev Dependencies (2)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |