Giter Site home page Giter Site logo

goldst / ik.ts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lo-th/fullik

3.0 3.0 1.0 15.25 MB

TypeScript / JavaScript fast iterative solver for Inverse Kinematics

Home Page: https://goldst.dev/IK.ts

License: MIT License

JavaScript 50.08% TypeScript 49.92%

ik.ts's People

Contributors

goldst avatar lo-th avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

minitoine

ik.ts's Issues

How to move an existing chain and target?

Hello!

I have been trying to implement this library, I have it working if I re-create the chain/bones each frame. However, trying to preserve the structure, chain3d etc I get some weird results...

  createIKStructure() {
    const segment = this.segment;
    this.ikLegTarget = new IK.V3(this.footPosition.x, this.footPosition.y, this.footPosition.z); // or IK.V2
    this.ikLeg = new IK.Chain3D(); // or Chain2D
    this.ikLeg.setFixedBaseMode(true);
    const leg = this.ikLeg; // or Chain2D
    // with start position, direction and length:
    const baseBoneA = new IK.Bone3D( // or Bone2D
        new IK.V3(segment.x, segment.y, segment.z), // start position. Use IK.V2 if you are using Chain2D.
        undefined,          // no end position given
        new IK.V3(0, 1, 0), // direction. Use IK.V2 if you are using Chain2D.
        1                   // length
    );
    leg.addBone(baseBoneA);
    leg.addConsecutiveBone(
        new IK.V3(0, -1, 0), // direction. Use IK.V2 if you are using Chain2D.
        1               // length
    );
    this.structure = new IK.Structure3D(); // or Structure2D
    this.structure.add(leg, this.ikLegTarget);
  }

  update(delta) {
    this.createIKStructure(); // only works if i do this, below lines seem to do nothing/produce buggy results
    leg.baseLocation.set(segment.x, segment.y, segment.z);

    this.ikLegTarget.set(this.footPosition.x, this.footPosition.y, this.footPosition.z); // or IK.V2

    this.structure.update();
  }

As you can see from this rough snippet, I tried using a few methods to reset the base location and others. Doesnt seem to do much besides produce buggy results. Re-creating everything produces the correct result from what I can see. Any ideas how to approach this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.