bluegem

1.0.11 • Public • Published

Blue Gem Graphics

A basic 3D library for Javascript. The purpose of the library is not speed or top graphics, but ease of use. The entire API is built around the Java Script Promise Objects.

Example

Creating a camera.

function camera_create () {
    return world.createCamera("camera1");
};

function camera_move(camera) {
    return camera.setPosition([0,0,2]);
};

function camera_set_bg(camera) {
    return camera.setBackgroundColor(bluegem.Color3d.rgba(100,100,100,255));
};

Create a light source

function light_create() {
    return world.createLight("light1");
};

function light_move(light) {
    return light.setPosition([0,1,2]);
};

Add a sphere to the scene.

function entity_create() {
    return world.createEntity("entity1");
};

function entity_attach_sphere(entity) {
    return entity.attachModel("sphere");
};

Putting everything together.

let world = new bluegem.World3d()

// all setup functions go here

// bind world to canvas
world.init("myCanvas")

    // create the camera
    .then(camera_create)
    .then(camera_move)
    .then(camera_set_bg)

    // create a sphere
    .then(entity_create)
    .then(entity_attach_sphere)

    // create light
    .then(light_create)
    .then(light_move)

    // catch all errors
    .catch(console.error);

// start the main loop.
world.start();

![alt text][sphere.png]

Readme

Keywords

none

Package Sidebar

Install

npm i bluegem

Weekly Downloads

7

Version

1.0.11

License

ISC

Unpacked Size

464 kB

Total Files

7

Last publish

Collaborators

  • fredriquesamuels