Open NGenesis opened 7 years ago
Just want to suggest that sometimes a "speed" is useful to use instead of a duration of the total lerp. This would allow an object to always lerp-sync at the same speed regardless of the distance of the lerp.
Thanks for the suggestion @smsithlord, I'll take a look at revising for speed over duration sometime this week.
I have also been debating whether the lerp algorithm should be applied by default. Is this going to cause any notable issues with existing apps that expect objects to snap from one position to another? Any thoughts on this?
Thanks for tacking this @NGenesis. I agree about lerping at a constant speed. You shouldn't have to worry about breaking existing apps, since the SDK library is versioned. However, I would still opt for disabling lerping by default, since it could be quite surprising if all you want is a basic transform sync.
Off by default might be best. If the coder is doing stuff like testing object distances to detect a game event, they probably expect the objects to snap to position on clients. I do expect most people to always use it though. The side-effects of lerp syncing on clients is minimal.
Another useful behavior to consider is a "lerpMove" behavior that animates object transforms on the local PC as well, but special care must be given to make a lerpMove behavior play nice with a lerpSync behavior on the same object.
Updated Object3DSync behavior to support linear interpolation for position and scale updates, and spherical linear interpolation for rotation updates, which aids in smoothing out jerky object synchronization.
Interpolation is currently enabled by default, and can be explicitly enabled or disabled on creation of the behavior with config parameters. For example:
obj.addBehavior(Object3DSync({ position: true, rotation: true, scale: true, lerp: { position: true, rotation: true, scale: false, duration: 150 } }));