Integrating Regular Node packages

Hi again!
Today I was wondering, let’s say I want to use Tween.js for interpolating two objects position to give an example. Is it just, installing the dependency via npm (and obviously importing it inside the script) enough?
Now Tween.js specific:

//On the top of the script...
import { Tween, Easing } from "@tweenjs/tween.js";
//Inside monobehaviour...
private myTween? : Tween<Vector3> = undefined;
start(): void {
 this.myTween = new Tween(this.gameObject.position);
update(): void {

//... Inside a function thats gets called when a button is pressed:
this.myTween?.to(newViewPosition.transform.position, 3000).start();

Lets say the code above is inside a valid "typescript monobehaviour :coolcat: " I’m concerned about the update part, if I want multiple tweens I would probably need to use a single monobehaviour as “manager” and call update() only once?. I’m not sure about this since in the docs says that with plain THREE.js tween.update() should be called inside animate() function and on top of it, each tween is a separate instance.

Original Post on Discord

by user 368204675922657280

Here’s a small live example (perhaps you’ve seen this already) Needle Engine Tweenjs Example - StackBlitz

Installing the npm package is enough yeah

I think the rest of your question depends largely on how a) the library works (if they advice to call update() once per frame and the lib handles everything internally) and on b) how you organize your project/code (if you have many components that all have their own tween thing and call update themselves with own lifecycles) or if you have one “tweening manager” that sets everything up and manages the tweening

Awesome! Thanks for the example, it helps a lot :blobaww:

by user 368204675922657280