playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF

Home Page:https://playcanvas.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add method for Node

AlexAPPi opened this issue · comments

Now there are 2 methods available, setPosition and setRotation, I suggest adding 1 more method setPositionAndRotation.

public setPositionAndRotation(position: Readonly<pc.Vec3>, rotation: Readonly<pc.Quat>): void;

  • This will further optimize position and rotation manipulations
commented

I think we have an equivalent, or at least it is similar:

entity.getWorldTransform().setTRS(position, rotation, pc.Vec3.ONE);

A much bigger optimization many miss is to use setLocalPosition instead of setPosition where possible.

commented

@AlexAPPi So ive done some performance testing in #6625 and it doesn't seem like the performance gain is reasonable enough to warrant adding this method right now. If this issue was created for a personal project the chances of optimizing other areas would be much more successful that attempting to include this