npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

voxel-sky

v0.3.0

Published

A sky for voxel.js

Downloads

15

Readme

voxel-sky

A sky for voxel.js. Includes a sun, moon and stars.

View this example

example

First off, it is recommended to disable fog and lights in the game when using voxel-sky:

var createEngine = require('voxel-engine');
var game = createEngine({
  fogDisabled: true,
  lightsDisabled: true
});

To simply set the sky to a certain time of day:

var createSky = require('voxel-sky')(game);
var sky = createSky(1200); // Set to noon

Or if you would like to run through a day/night cycle:

var createSky = require('voxel-sky')(game);
var sky = createSky();
game.on('tick', sky);

customize the sky

You can build your own sky using the included helpers:

var createSky = require('voxel-sky')(game);
var sky = createSky(function(time) {
  
  // spin the sky once per day
  this.spin(Math.PI * 2 * (time / 2400));

  // Change the sky pink at 7AM
  if (time === 700) this.color(new this.game.THREE.Color(0xFF36AB), 1000);

  if (time === 0) {
    // paint a green square on the bottom (above your head at 1200)
    this.paint('bottom', function() {
      // The HTML canvas and context for each side are accessible
      this.context.rect((this.canvas.width/2)-25, (this.canvas.height/2)-25, 50, 50);
      this.context.fillStyle = this.rgba(0, 1, 0, 1);
      this.context.fill();
    });

    // paint 500 stars on the top and bottom
    this.paint(['top', 'bottom'], this.stars, 500);

    // paint a big red full moon on every face
    // 0 = full, 0.25 quarter waxing, 0.5 = new, 0.75 quarter waning
    this.paint('all', this.moon, 0, 100, new this.game.THREE.Color(0xFF0000));

    // paint a small green sun on each side face
    this.paint('sides', this.sun, 10, new this.game.THREE.Color(0x00FF00));
  }

  if (time === 400) {
    // clear the canvas on all sides at 4AM
    this.paint('all', this.clear);
  }

  if (time === 1800) {
    // lower the sunlight intensity at 6PM
    this.sunlight.intensity = 0.2;

    // set the ambient color (is a hemisphere light)
    this.ambient.color.setHSV(0.9, 1, 1);
  }
});
game.on('tick', sky);

Check the source of the built-in sky for a more in depth example.

options

There are a variety of starting options for voxel-sky. Just make sure you always pass it a game:

var createSky = require('voxel-sky')({
  game: game,

  // starting time of the day
  time: 2400,

  // size of the sky
  size: game.worldWidth() * 2,

  // initial color of the sky
  color: new game.THREE.Color(0, 0, 0),

  // how fast the sky rotates
  speed: 0.1
});

run the demo

  1. git clone git://github.com/shama/voxel-sky && cd voxel-sky
  2. npm install
  3. npm start

install

With npm do:

npm install voxel-sky

Use browserify to require('voxel-sky').

release history

  • 0.1.0 - initial release

license

Copyright (c) 2013 Kyle Robinson Young Licensed under the MIT license.