Libraries & API
Planets
Flatworld

Flat Worlds


Generate a simple flat and square plane with the same subdivided LOD algorithm as other worlds.

Usage

import { FlatWorld } from "@hello-worlds/planet"
import worker from "./flatWorld.worker"
 
// ...some threejs scene above
 
const myWorld = new FlatWorld({
  size: 10_000,
  minCellSize: 32,
  minCellResolution: 48,
  workerProps: {
    numWorkers: 8,
    worker,
  },
  data: {
    seed: "My Cool Seed!",
  },
})
scene.add(myWorld)

Props

PropTypeDefault (if optional)Description
invertedbooleanfalseIf true flips the terrain upside down
sizenumberrequiredThe size of a side of the square FlatWorld
minCellSizenumberrequiredThe smallest size that a terrain chunk will be
minCellResolutionnumberrequiredThe amount of subdivisions in a terrain chunk
materialMaterial (opens in a new tab)undefinedThe material to use
positionVector3 (opens in a new tab)requiredThe position to place the world
lodOriginVector3 (opens in a new tab)requiredthe position where to compare the lod algorithm against, typically your camera position. If the lodOrigin is close to a terrain chunk, it may decided to collapse into a higher level of detail.
workerPropsWorkerPropsrequiredConfig for the worker
dataRecord<string, any>requiredUser datta that will be consumed by the worker threads' generator functions
lodDistanceComparisonValuenumber1.25The quadtree will resolve to a higher level of detail if the lodOrigin position is closer than distance * lodDistanceComparisonValue, for thhis reason it must be greater than 0

WorkerProps

export interface workerProps: {
  worker: new () => Worker
  numWorkers: number
}