AltspaceSDK icon indicating copy to clipboard operation
AltspaceSDK copied to clipboard

Adding linear interpolation support to Object3DSync behavior

Open NGenesis opened this issue 7 years ago • 4 comments

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 } }));

NGenesis avatar Dec 15 '16 10:12 NGenesis

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.

smsithlord avatar Dec 15 '16 14:12 smsithlord

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?

NGenesis avatar Dec 19 '16 23:12 NGenesis

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.

brianpeiris avatar Dec 21 '16 01:12 brianpeiris

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.

smsithlord avatar Dec 22 '16 14:12 smsithlord