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

dom3d

v0.1.3

Published

> DOM3D is an open source engine for making 2.5D scenes (e.g. 2D planes moving/rotating in 3D space) in normal HTML/Javascript pages.

Downloads

5

Readme

DOM3D

DOM3D is an open source engine for making 2.5D scenes (e.g. 2D planes moving/rotating in 3D space) in normal HTML/Javascript pages.

What makes DOM3D different?

There's a lot of 3D engines out there in the world. However, DOM3D isn't quite like any of them. It's unique for a few reasons:

  1. Merger of 2D and 3D - DOM3D is designed for the purpose of melding 3D abilities into otherwise 2D designs, making it extremely practical. The main way in which this manifests is that the math is manipulated to make all 3D objects display exactly as 2D objects would whenever their z-coordinate is at zero. In a normal 3D scene an object that is left or right of center would be skewed compared to an object at true center in any non-orthographic viewing. In DOM3D this is not the case.

  2. Simple tech - DOM3D uses affine only transformations applied to normal DOM objects. All 3D effects are created completely through CSS matrix manipulation. This means browsers need not have actual 3D support to utilize it, and more importantly you're working with familiar DOM objects.

  3. Forward kinematics with global sorting - Most CSS transformation based 3D capabilities are not forward kinematic, or at very least tend to not be able to sort children in different containers against each other properly. Meanwhile most fully forward kinematic engines tend to be complex triangle/texture/camera based engines. DOM3D offers a truly forward kinematic and globally sorting engine while still maintaining the simplicity of working with familiar DOM style elements.

What is DOM3D for?

DOM3D is not for 3D models, geometry, textures, etc. It's for taking the type of design elements you may have on a normal web page and building them with the ability to easily move in 3D space with full forward kinematic (i.e. parent/child containers) and sorting abilities.

Long story short: a 1st person shooter game? No. A really cool photo album with complex 3D effects? Yes.


How to use it?

Make a Stage3D

Every scene needs a stage at its root. The stage will be associated with a DOM element in your page. So

<div id="my-stage"></div>
var stage = new Stage3D('#my-stage');

We've now created a stage object which we can add other DOM3D elements into and associated it with a DOM element on the page. The location of that DOM element will be considered point 0,0,0 for the scene.

Make Some Elements

The basic class for DOM elements which will move around in the 3D scene is the Element3D class. This represents a normal DOM element that will be put inside #my-stage and then be manipulated in 3D by DOM3D.

var elem1 = new Element3D();
elem1.style.width = '50px';
elem1.style.height = '50px';
elem1.style.backgroundColor = 'green';
elem1.z = 10;

var elem2 = new Element3D();
elem2.style.width = '50px';
elem2.style.height = '50px';
elem2.style.backgroundColor = 'red';
elem2.z = -10;

The Element3D objects represent normal DOM elements. Notice that we can give them custom markup, apply CSS, etc. They'll just be 2D planes in a 3D world.

Then we manipulate them in that 3D world via x, y, and z coordinates and rotX, rotY, and rotZ axis. You can also set a regX and regY to set the registration point that it rotates around.

Add Elements to the Stage

Elements can be added right to the Stage3D instance. However for our demo we're gonna make a group so that we can spin them around easily.

var group = new Group3D();
group.add(elem1, elem2);
stage.add(group);

elem1 and elem2 are now children of group, which is now a child of stage. The scene will now render the elements, and the group can be easily manipulated.

Move It!

Of course, the scene seems pretty bland without any movement showing off the 3D yet! In this case we can use the render events from stage to add a bit of motion:

stage.addListener(StageEvent.UPDATE, function(){
    group.rotX += 0.5;
    group.rotY += 0.2;
})

Documentation

The above is a quick example intro of how DOM3D works. But it's not intended to be actual documentation.

DOM3D has 2 basic types of documentation. First it has practical example based docs about usage. Then it also has technical API documentation detailing each class/method/property generated from javadoc style commenting.