threejs-worldgen
    Preparing search index...

    Class FloatingOrigin

    Keeps the camera near render-space (0, 0, 0) so float32 GPU math stays precise at planet scale. When the camera drifts past threshold, the world position at render zero (origin) moves to the camera, the camera moves back to zero, and listeners shift whatever they render (terrain, water, controls targets, …) by the same amount.

    const floating = new FloatingOrigin(camera)
    floating.onRebase((origin, shift) => { terrain.setOrigin(origin); controls.target.sub(shiftVector(shift)) })
    // each frame: floating.update()
    Index
    camera: Camera

    The camera being followed.

    Settings.

    origin: Vec3

    World (planet-centred) position currently at render-space zero, float64.

    • Calls listener(origin, shift) after each rebase. Returns an unsubscribe function.

      Parameters

      • listener: (origin: Vec3, shift: Vec3) => void

      Returns () => void

    • Moves render zero by shift (render-space metres): the camera and every listener move by −shift.

      Parameters

      Returns boolean

    • Rebases if the camera is past the threshold. Returns true when it did.

      Returns boolean