threejs-worldgen
    Preparing search index...

    Function useHeightSampler

    • createHeightSampler for React: a height function is used as-is, a mesh or group (e.g. from a ref callback) is baked once, and again only when terrain or maxResolution changes. No terrain: flat ground at 0.

      Parameters

      • Optionalterrain: Terrain | null
      • maxResolution: number = 1024

      Returns HeightFn

      const [ground, setGround] = useState<Object3D | null>(null)
      const sample = useHeightSampler(ground, 512)
      return <mesh ref={setGround} geometry={terrain} />