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

ikts

v1.3.7

Published

Inverse Kinematics Library based on the FABRIC algorithm

Downloads

8

Readme

IK.ts – Inverse Kinematics Library

Inverse Kinematics library for use in browsers and node. Based on the Fabrik algorithm. IK.ts is a port of existing IK libraries

Setup

Installation:

> npm i ikts

You can either add the library using html:

<script src="node_modules/ikts/build/IK-browser.js"></script>

and then access the classes using the global object IK.

Or you can include it as a module:

import * as IK from 'ikts';

Basics

The smallest entity in inverse kinematics are bones of fixed length. A sequence of bones is called chain. Inverse kinematics answers the question: Given chains and target positions that these chain should end at, at which position are the bones?

IK.ts organizes multiple chains in so-called structures. Structures can contain multiple chains, which can even be connected to form more complex skeletons.

To start with IK.ts, create chains:

const leg = new IK.Chain3D(); // or Chain2D

For each chain, add a first bone. The initial direction of the bone is necessary to give the algorithm an idea of where the bones should roughly end up at the end, but don't worry, even if you use made up values, the IK.ts is likely to figure it out anyways.

// with start and end positions:
const baseBoneA = new IK.Bone3D( // or Bone2D
    new IK.V3(1, 2, 3), // start position. Use IK.V2 if you are using Chain2D.
    new IK.V3(4, 5, 6)  // end position. Use IK.V2 if you are using Chain2D.
);

// with start position, direction and length:
const baseBoneB = new IK.Bone3D( // or Bone2D
    new IK.V3(1, 2, 3), // start position. Use IK.V2 if you are using Chain2D.
    undefined,          // no end position given
    new IK.V3(7, 8, 9), // direction. Use IK.V2 if you are using Chain2D.
    2                   // length
);

Then add the first bone to their respective chains:

leg.addBone(baseBoneA);

After the first bone is added, adding additional bones is much easier:

leg.addConsecutiveBone(
    IK.V3(2, 3, 4), // direction. Use IK.V2 if you are using Chain2D.
    3               // length
);

Each chain needs a target position. In the next step you will need to supply a target position – if you don't know yours yet, it is ok to initialize it with a position of (0|0|0).

const legTarget = new IK.V3(0, 0, 0); // or IK.V2

When all your chains are done, create a structure and add your chains: create a structure:

const structure = new IK.Structure3D(); // or Structure2D

structure.add(leg, legTarget);

After this, you are ready to go! Just run update (and re-run it whenever you change your targets):

structure.update();

To obtain the position of a certain bone, you can do something like this:

leg.bones[1].start
leg.bones[1].end

That's it! You can have a look at the classes to see all of your options, including bone constraints. I'm planing to add documentation very soon.

Development status and contributing

This project is work in progress. Let me know if you have any issues! Currently I'm not taking code contributions, because it is part of an university project. I am planing to open it up in June.

License and credits

MIT

This library is a TypeScript port of and based on

  • Fullik by lo-th, which is a JavaScript port of
  • Calico by Alastair Lansley and the Federation University Australia, which is an implementation of the
  • FABRIK algorithm by Andreas Aristidou and Joan Lasenby

This library differs from Fullik:

  • IK.ts is written TypeScript, Fullik is JavaScript. You can use IK.ts with JavaScript nevertheless!
  • Fullik is not in the npm registry and doesn't provide you documentation for installation and usage. It does, however, contain demos, from which the correct usage can be deduced. I added some usage information to this document and plan to add more detailed documentation for IK.ts for each method and class based on the calico documentation.
  • IK.ts doesn't have the three.js dependency. If you are developing a three.js project, consider using Fullik instead – both projects work, but the latter is made specifically for usage with three.js