Libraries & API
Planets
Planet

Planets


Generate a spherical world, like a planet or moon. Also helpful for creating oceans or cloud layers, by layering Planet() components on top of eachother.

Usage

import { Planet } from "@hello-worlds/planet"
import worker from "./Planet.worker"
 
// ...some threejs scene above
const myWorld = new Planet({
  radius: 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
radiusnumberrequiredThe radius of the planet
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 multiplied by lodDistanceComparisonValue, for this reason it must be greater than 0

WorkerProps

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