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

humanoid-figure

v1.0.1

Published

mesh and matrix calculations to manipulate a rigged low-poly boxy 3d humanoid figure

Downloads

8

Readme

humanoid-figure

mesh and matrix calculations to manipulate a rigged low-poly boxy 3d humanoid figure

example

view this example

var regl = require('regl')()
var camera = require('regl-camera')(regl, { distance: 4, theta: -Math.PI/4 })
var mat4 = require('gl-mat4')

var skelly = require('humanoid-figure')
var skmatrix = require('humanoid-figure/matrix')
var skmodel = skmatrix({}, skelly)

var draw = {}
Object.keys(skelly).forEach(function (key, i) {
  draw[key] = regl({
    frag: `
      precision highp float;
      void main () {
        gl_FragColor = vec4(1,0.2,0.5,1);
      }
    `,
    vert: `
      precision highp float;
      uniform mat4 projection, view, model;
      attribute vec3 position;
      void main () {
        gl_Position = projection * view * model * vec4(position,1);
      }
    `,
    uniforms: { model: function () { return skmodel[key] } },
    attributes: { position: skelly[key].positions },
    elements: skelly[key].cells
  })
})
regl.frame(function (context) {
  regl.clear({ color: [0,0,0,1], depth: true })
  
  // hand shake
  mat4.identity(skelly.lforearm.matrix)
  mat4.rotateX(skelly.lforearm.matrix,skelly.lforearm.matrix,
    1.2 + Math.sin(context.time*4)*0.2)

  // head bob
  mat4.identity(skelly.head.matrix)
  mat4.rotateX(skelly.head.matrix,skelly.head.matrix,
    Math.sin(context.time*8)*0.2)

  // foot tap
  mat4.identity(skelly.rfoot.matrix)
  mat4.rotateX(skelly.rfoot.matrix,skelly.rfoot.matrix,
    Math.pow(Math.max(0,Math.sin(context.time*2)),8)*0.2)
  mat4.rotateY(skelly.rfoot.matrix,skelly.rfoot.matrix,
    Math.sin(context.time*1)*0.2)

  skmatrix(skmodel, skelly)
  camera(function () {
    Object.keys(draw).forEach(function (key) { draw[key]() })
  })
})

api

var figure = require('humanoid-figure')
var fmatrix = require('humanoid-figure/matrix')

figure

Object mapping shape names to shapes.

The shape names are:

  • chest
  • head
  • larm
  • lfoot
  • lforearm
  • lleg
  • lmiddledistal
  • lpalm
  • lproximal
  • lthigh
  • lthumb
  • neck
  • pelvis
  • rarm
  • rfoot
  • rforearm
  • rleg
  • rmiddledistal
  • rpalm
  • rproximal
  • rthigh
  • rthumb
  • spine

Each shape has:

  • shape.pivot - coordinate to pivot rotation about
  • shape.matrix - matrix to store shape rotations
  • shape.parent - name of parent shape, if applicable
  • shape.positions - geometry verticies
  • shape.cells - geometry triangle vertex indicies

fmatrix(models, figure)

Calculate model matricies for each shape in the figure given each shape's matrix, pivot point, and parent shape.

If a model matrix doesn't exist it will be allocated. Otherwise existing model matricies will be reused. Returns models.

install

npm install humanoid-figure

license

public domain