-
Notifications
You must be signed in to change notification settings - Fork 73
Adding linear interpolation support to Object3DSync behavior #178
base: master
Are you sure you want to change the base?
Conversation
Updated to latest
Updates to documentation.
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. |
} | ||
else { | ||
object3d.scale.set(value.scale.x, value.scale.y, value.scale.z); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to separate this new code out into helper functions, since setupReceive
is quite large at this point.
Also, you may be able to refactor a lot of the code into a shared helper, since the lerping operations are almost identical for position, rotation and scale.
Same applies to the code in update
below.
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 to v0.28.1
Updated to v0.28.1
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 } }));