node.js 如何在服务器端使用动画补间库?

How to use an animation tweening library on serverside on node.js?

我尝试在 Node.js 上使用 es6-tween。我想计算补间并在更新时通过 Websocket 将它们发送给客户端。 (必须是服务端)

let coords = { x: 0, y: 0 }; // Start at (0, 0)
let tween = await new Tween(coords)
        .to({ x: 100, y: 100 }, 1000)
        .on('update', ({x, y}) => {
            console.log(`The values is x: ${x} and y: ${y}`);
        })
        .start();

永远不会调用更新。我没有任何错误。我怎么能在服务器端使用它?还尝试使用 GASP 或 Tween.js

添加

const { autoPlay, Tween } = TWEEN;
autoPlay(true);

并删除 await.

看到这个pen