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

threejs-dice

v1.1.0

Published

Create 3d dice which can be rolled.

Downloads

176

Readme

threejs-dice

Create dice for your threejs scene and throw them on a specific side with cannonjs.

Dice types Start rolling Finished rolling

Features

  • 4/6/8/10/12/20 sided dice available
  • Customize the appearance of the dice
  • You can define the side/value, which should be upside after the die has fallen

Demos

  • Types and sizes - See the possible dice shapes and options (size / font color / back color)
  • Rolling - See, how you can roll 5 dice, which will always land on the same sides

Install

npm install threejs-dice

Usage

<script src="lib/dice.js"></script>

<script>
    // Setup your threejs scene
    var scene = new THREE.Scene();
    // ...
    
    // Setup your cannonjs world
    var world = new CANNON.World();
    // ...
    
    DiceManager.setWorld(world);
    
    // Create a dice
    var dice = new DiceD6({backColor: '#ff0000}); //DiceD6 for six-sided dice; for options see DiceObject
    scene.add(dice.getObject());
    
    // If you want to place the mesh somewhere else, you have to update the body
    dice.getObject().position.x = 150;
    dice.getObject().position.y = 100;
    dice.getObject().rotation.x = 20 * Math.PI / 180;
    dice.updateBodyFromMesh();
    
    // Set the value of the side, which will be upside after the dice lands
    DiceManager.prepareValues([{dice: dice, value: 6}]);
    
    //Animate everything
    function animate() {
        world.step(1.0 / 60.0);
        
        dice.updateMeshFromBody(); // Call this after updating the physics world for rearranging the mesh according to the body
        
        renderer.render(scene, camera);
        
        requestAnimationFrame(animate);
    }
    requestAnimationFrame(animate);
    
</script>

Credits

Based on the "Online 3D dice roller" from http://a.teall.info/dice (http://www.teall.info/2014/01/online-3d-dice-roller.htm). Credits go to Anton Natarov, who published it under public domain. Online 3D dice roller

"You can assume that it has the MIT license (or that else) if you wish so. I do not love any licenses at all and prefer to simply say that it is completely free =)" - Anton Natarov