10000 GitHub - ycw/three-spring: Modeling spring motion in threejs.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ycw/three-spring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Modeling spring motion in threejs.

Examples

Installation

CDN

import { Spring } from "//cdn.jsdelivr.net/gh/ycw/three-spring/src/index.js"

NPM

$ npm i ycw/three-spring

import { Spring } from "three-spring"

Usage

// Create
const spring = new Spring({
  p: new THREE.Vector3(..), // pull position
  q: new THREE.Vector3(..), // equilibrium position
  f: 1, // frequency
  k: 0.88, // amplitude attenuation per period
  A: Infinity // amplitude constrait ( 0 = teleport )
});

const clock = new Clock();
renderer.setAnimationLoop(() => { 
  ...
  spring.update(clock.getDelta()); // Update
  mymesh.position.copy(spring.position); // Get
});

Credits

License

About

Modeling spring motion in threejs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0