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
Prop | Type | Default (if optional) | Description |
---|---|---|---|
inverted | boolean | false | If true, flips the terrain upside down |
radius | number | required | The radius of the planet |
minCellSize | number | required | The smallest size that a terrain chunk will be |
minCellResolution | number | required | The amount of subdivisions in a terrain chunk |
material | Material (opens in a new tab) | undefined | The material to use |
position | Vector3 (opens in a new tab) | required | The position to place the world |
lodOrigin | Vector3 (opens in a new tab) | required | the 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. |
workerProps | WorkerProps | required | Config for the worker |
data | Record<string, any> | required | User datta that will be consumed by the worker threads' generator functions |
lodDistanceComparisonValue | number | 1.25 | The 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
}