Terrain
Extends:
Implements:
- Disposable ,
- EventListener
The terrain system.
Manages volume modifications and mesh generation.
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) Constructs a new terrain. |
Member Summary
Public Members | ||
public |
A clipmap. |
|
public |
object: Group The terrain mesh. |
|
public |
A thread pool. |
|
public |
The world octree. |
Method Summary
Public Methods | ||
public |
Executes the given SDF. |
|
public |
clear() Resets this terrain by removing all data and closing active worker threads. |
|
public |
dispose() Frees internal resources. |
|
public |
handleEvent(event: Event) Handles events. |
|
public |
Executes the given SDF and discards the volume data that doesn't overlap with the generated data. |
|
public |
Loads a volume data description. |
|
public |
raycast(ray: Ray): WorldOctant[] Finds the world cells that intersect with the given ray. |
|
public |
save(): DOMString Saves a description of the current volume data. |
|
public |
Executes the given SDF and subtracts the generated data from the volume. |
|
public |
union(sdf: SignedDistanceFunction) Executes the given SDF and adds the generated data to the volume. |
|
public |
update(position: Vector3) Updates the terrain geometry. |
Public Constructors
public constructor(options: Object) source
Constructs a new terrain.
Params:
Name | Type | Attribute | Description |
options | Object |
|
The options. |
options.workers | Number |
|
Limits the amount of active workers. Cannot exceed the amount of logical processors. |
options.resolution | Number |
|
The resolution of the volume data. |
options.world | Number |
|
Additional world octree settings. See WorldOctree for details. |
Public Members
public threadPool: ThreadPool source
A thread pool. Each worker from this pool is capable of performing isosurface extractions as well as CSG operations on discrete volume data.
Public Methods
public applyCSG(sdf: SignedDistanceFunction) source
Executes the given SDF.
SDFs without a valid CSG operation type will be ignored. See OperationType for a list of available CSG operation types.
Instead of using this method directly, it's recommended to use the convenience methods union, subtract and intersect.
Params:
Name | Type | Attribute | Description |
sdf | SignedDistanceFunction | An SDF. |
public dispose() source
Frees internal resources.
By calling this method the terrain system will become unoperative.
public handleEvent(event: Event) source
Handles events.
Params:
Name | Type | Attribute | Description |
event | Event | An event. |
public intersect(sdf: SignedDistanceFunction) source
Executes the given SDF and discards the volume data that doesn't overlap with the generated data.
Params:
Name | Type | Attribute | Description |
sdf | SignedDistanceFunction | An SDF. |
public load(data: String) source
Loads a volume data description.
A load event will be dispatched when the loading process has finished.
Params:
Name | Type | Attribute | Description |
data | String | A stringified list of SDF descriptions. |
public raycast(ray: Ray): WorldOctant[] source
Finds the world cells that intersect with the given ray.
Params:
Name | Type | Attribute | Description |
ray | Ray | A ray. |
public save(): DOMString source
Saves a description of the current volume data.
Return:
DOMString | A URL to the exported save data, or null if there is no data. |
public subtract(sdf: SignedDistanceFunction) source
Executes the given SDF and subtracts the generated data from the volume.
Params:
Name | Type | Attribute | Description |
sdf | SignedDistanceFunction | An SDF. |
public union(sdf: SignedDistanceFunction) source
Executes the given SDF and adds the generated data to the volume.
Params:
Name | Type | Attribute | Description |
sdf | SignedDistanceFunction | An SDF. |
public update(position: Vector3) source
Updates the terrain geometry.
This method should be called every time the position has changed.
Params:
Name | Type | Attribute | Description |
position | Vector3 | A position. |