@equinor/videx-3d
    Preparing search index...

    Function useBuoyancy

    • Make an object float on the ocean by following the wave field provided by an enclosing <Ocean>. Reusable for any floating component: pass a ref to the object's group and a few body-frame sample points (e.g. bow / stern / port / starboard at the waterline).

      Each frame the water height is sampled at those points (accounting for the object's current heading and X/Z position) and a plane is fitted to them to drive:

      • heave → position.y (mean surface height),
      • pitch → rotation.z (fore/aft slope),
      • roll → rotation.x (port/starboard slope), each critically-damped toward its target so the motion stays smooth and frame-rate independent. The object's heading (rotation.y) is left untouched.

      No-op when there is no enclosing <Ocean> (the object keeps its static pose). Allocation-free and only a handful of cheap samples per frame.

      Parameters

      Returns void