[SOLVED] Tween.js usage with getPosition()?

Hi there,

Is it possible to use Tween.js with getPosition instead of getLocalPosition? I can’t use Local positions in this situation
The target entity is constant child of another entity
I can’t add another entity as a child to get dummy pos, any other ways?

Okay so the answer is here:

var mat = this.entity.parent.getWorldTransform().invert(); // get inverse world transform of parent
    var worldPosition = this.entity.getPosition();
    var localPosition = new pc.Vec3(); 
    mat.transformPoint(worldPosition, localPosition);

    console.log('Calculated pos');
    console.log(localPosition); //x:0.22019599035674275y:-0.4319997904002637z:0.15780184727611868
    console.log('Actual local pos');

Please see: [SOLVED] Tweening to World Coordinates Instead of Local Coordinates - #9 by mcmorry

Thanks, but I have already found a solution, it’s just easier to convert world position → local and use Tween.js as it should be used

One little question, how do you properly delete cloned property?

var transform = this.entity.parent.getWorldTransform();
var cloned = transform.clone();

When the object is no longer referenced by a variable, it will get garbage collected automatically

Oh, never stop learning.

I’ve got another one, is there any chance tween would work with rigidbody as well?
Or should I just update its position with prototype.update and rigidbody.teleport

Not sure why but seems like Tween.js rewrites every possible Vec3 property stored on entity once this.tween.stop(); happens, strings are fine, took a while to notice it

For kinematic, you can just set the position of the entity like before.

For dynamic, using teleport each frame will look odd but it will work using the method shown in the post linked here: Tween.js usage with getPosition()? - #3 by yaustar

I don’t understand what you mean. Can you provide a new, repro project for this please?

Couldn’t replicate it, it wasn’t a tween, I’ll mark this as solved, thanks.