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-portal

v0.0.1

Published

create teleport portals for voxel.js textured with the camera view at the destination

Downloads

12

Readme

voxel-portal

Create teleport portals for voxel.js textured with the camera view at the destination.

example

View this example.

var createEngine = require('voxel-engine');

var game = createEngine({
    generate: function(x, y, z) {
        var d = Math.sqrt(x*x + y*y + z*z);
        return d < 20 && y >= -10 && (y < 0 || y*y <= 0.5*x*x + z*z / 64);
    },
    texturePath: './textures/',
    materials: [ 'grass_top', 'obsidian', 'netherrack' ],
    startingPosition: [ 0, 100, 0 ]
});
game.appendTo('#container');

var explode = require('voxel-debris')(game);
var erase = true;
function ctrlToggle (ev) { erase = !ev.ctrlKey }
game.requestPointerLock('canvas');

// build back plates for the portals out of obsidian and netherrack
for (var z = -225; z <= 200; z+= 425) {
    for (var y = 50; y <= 125; y += 25) {
        for (var x = -75; x <= 50; x += 25) {
            game.setBlock({ x: x, y: y, z: z }, z < 0 ? 2 : 3);
        }
    }
}

var createPortal = require('voxel-portal')(game);

var a = createPortal({
    x: 0, y: 100, z: 200,
    width: 100, height: 50
});
var b = createPortal({
    x: 0, y: 100, z: -200,
    width: 100, height: 50
});

a.show(b, { x: 0, y: 0, z: 1 });
b.show(a, { x: 0, y: 0, z: -1 });

a.on('enter', function () {
    console.log('ENTER A');
    game.moveToPosition(b.position);
});

b.on('enter', function () {
    console.log('ENTER B');
    game.moveToPosition(a.position);
});

game.on('mousedown', function (pos) {
    if (erase) explode(pos)
    else game.createBlock(pos, 1)
});

window.addEventListener('keydown', ctrlToggle);
window.addEventListener('keyup', ctrlToggle);

methods

var voxelPortal = require('voxel-portal')

var createPortal = voxelPortal(game)

Return a function for making portals given a voxel-engine game instance.

var portal = createPortal(opts)

Create a portal opts.width width and opts.height tall at the coordinate (opts.x, opts.y, opts.z).

portal.show(target, direction)

Show the view from target looking with the direction vector.

target can have a .position or it can have .x, .y, and .z fields itself directly.

events

portal.on('enter', function () {})

When a player's position intersects the portal bounding box, this event fires.

It's up to you to teleport the player from here.

install

With npm do:

npm install voxel-portal

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

license

MIT