Terrain
Stores and edits voxel terrain and water.
- Not creatable
- Created by the engine or used as a base class.
- Inherits
- BasePartPVInstanceInstance
- Replication
- Standard
Behavior
Terrain stores and edits voxel terrain and water.
Summary
Whether terrain decoration is displayed.
The rendered length of terrain grass.
The terrain's cell-coordinate bounds.
The base color used to render water.
The reflectivity used to render water.
The transparency used to render water.
The amplitude used for rendered water waves.
The speed used for rendered water waves.
Returns the world-space center of a terrain cell.
Returns the world-space minimum corner of a terrain cell.
Removes all terrain cells.
Queues clearing of a region and returns a TerrainJob.
Removes water from the supplied region.
Copies terrain into a TerrainRegion.
Returns the number of occupied terrain cells.
Fills a sphere at the world-space center with the specified terrain material.
Fills an oriented box with the specified terrain material.
Fills a capsule with the specified terrain material.
Fills a cylinder with the specified terrain material.
Fills the supplied world-space region with the specified terrain material.
Queues filling of a region and returns a TerrainJob.
Fills the supplied region with water.
Fills a wedge with the specified terrain material.
Generates terrain using the supplied region and generation options.
Queues terrain generation and returns a TerrainJob.
Returns the cell material, block shape, and orientation.
Returns the terrain surface height at the supplied world-space X and Z coordinates, or nil when no surface is found.
Returns the terrain color override for the specified material.
Returns the variant name assigned to a terrain material, or nil when no override exists.
Returns the cell's water-force and direction values.
Returns the water depth at the supplied world-space position.
Imports a heightmap image into the supplied region.
Pastes a TerrainRegion at the supplied cell corner.
Returns material and occupancy arrays indexed as [x][y][z], with one-based indices.
ReplaceMaterial(region: Region3, resolution: number?, sourceMaterial: EnumItem, targetMaterial: EnumItem): ()serial onlyReplaces occupied cells of the selected material within the region.
ReplaceMaterialAsync(region: Region3, resolution: number?, sourceMaterial: EnumItem, targetMaterial: EnumItem): TerrainJobserial onlyQueues material replacement within a region and returns a TerrainJob.
Edits terrain with Add, Subtract, Grow, Erode, Smooth, Flatten, Paint, Replace, Flood, or Drain and returns the changed-cell count.
SetCell(x: number, y: number, z: number, material: EnumItem, block: EnumItem?, orientation: EnumItem?): ()serial onlySets a cell's material and optional block shape.
SetCells(region: Region3, material: EnumItem, block: EnumItem?, orientation: EnumItem?): ()serial onlySets cells within the region to the supplied material and optional block shape.
Sets the terrain color override for the specified material.
Assigns a variant name to a terrain material.
Converts a world-space position to terrain-cell coordinates.
Converts a world-space position to cell coordinates with a preference for an adjacent empty cell.
Converts a world-space position to cell coordinates with a preference for an adjacent occupied cell.
WriteVoxels(region: Region3, resolution: number?, materials: { { { EnumItem } } }, occupancy: { { { number } } }): ()serial onlyWrites material and occupancy arrays indexed as [x][y][z].
WriteVoxelsAsync(region: Region3, resolution: number?, materials: { { { EnumItem } } }, occupancy: { { { number } } }): TerrainJobserial onlyQueues writing voxel arrays and returns a TerrainJob.
Properties
Decoration
Terrain.Decoration: booleanWhether terrain decoration is displayed.
GrassLength
Terrain.GrassLength: numberThe rendered length of terrain grass.
MaxExtents
Terrain.MaxExtents: Region3int16The terrain's cell-coordinate bounds.
WaterColor
Terrain.WaterColor: Color3The base color used to render water.
WaterReflectance
Terrain.WaterReflectance: numberThe reflectivity used to render water.
WaterTransparency
Terrain.WaterTransparency: numberThe transparency used to render water.
WaterWaveSize
Terrain.WaterWaveSize: numberThe amplitude used for rendered water waves.
WaterWaveSpeed
Terrain.WaterWaveSpeed: numberThe speed used for rendered water waves.
Methods
CellCenterToWorld
Returns the world-space center of a terrain cell.
CellCornerToWorld
Returns the world-space minimum corner of a terrain cell.
Clear
Terrain:Clear(): ()Removes all terrain cells.
ClearRegionAsync
Terrain:ClearRegionAsync(region: Region3): TerrainJobQueues clearing of a region and returns a TerrainJob.
ClearWater
Terrain:ClearWater(Region3): numberRemoves water from the supplied region.
CopyRegion
Terrain:CopyRegion(region: Region3): TerrainRegionCopies terrain into a TerrainRegion. Copying more than 16777216 cells at once causes an error.
CountCells
Terrain:CountCells(): numberReturns the number of occupied terrain cells.
FillBall
Fills a sphere at the world-space center with the specified terrain material. Radius is in studs.
FillBlock
Fills an oriented box with the specified terrain material. The transform and dimensions are in world space.
FillCapsule
Fills a capsule with the specified terrain material.
FillCylinder
Fills a cylinder with the specified terrain material.
FillRegion
Fills the supplied world-space region with the specified terrain material.
FillRegionAsync
Terrain:FillRegionAsync(region: Region3, resolution: number?, material: EnumItem): TerrainJobQueues filling of a region and returns a TerrainJob.
FillWater
Terrain:FillWater(Region3, number?): numberFills the supplied region with water.
FillWedge
Fills a wedge with the specified terrain material.
Generate
Terrain:Generate(Region3, table?): numberGenerates terrain using the supplied region and generation options.
GenerateAsync
Terrain:GenerateAsync(region: Region3, options: { [string]: any }?): TerrainJobQueues terrain generation and returns a TerrainJob.
GetCell
Returns the cell material, block shape, and orientation. The current binding returns NegZ for orientation.
GetHeight
Terrain:GetHeight(number, number): number?Returns the terrain surface height at the supplied world-space X and Z coordinates, or nil when no surface is found.
GetMaterialColor
Returns the terrain color override for the specified material.
GetMaterialVariant
Terrain:GetMaterialVariant(material: EnumItem): string?Returns the variant name assigned to a terrain material, or nil when no override exists.
GetWaterCell
Returns the cell's water-force and direction values. This binding reports water presence through the force value and returns NegX for direction.
GetWaterDepth
Terrain:GetWaterDepth(Vector3): numberReturns the water depth at the supplied world-space position. Returns zero when no water depth is available.
ImportHeightmap
Imports a heightmap image into the supplied region. Accepts an optional colormap image and material. The default material is Grass. Unreadable or invalid image data causes an error.
PasteRegion
Terrain:PasteRegion(region: TerrainRegion, corner: Vector3, pasteEmptyCells: boolean?): numberPastes a TerrainRegion at the supplied cell corner. The corner is rounded to integer cell coordinates. paste_empty defaults to true.
ReadVoxels
Terrain:ReadVoxels(Region3, number?): table, tableReturns material and occupancy arrays indexed as [x][y][z], with one-based indices. Occupancy is normalized from 0 to 1. Reading more than 4194304 cells at once causes an error.
ReplaceMaterial
Terrain:ReplaceMaterial(region: Region3, resolution: number?, sourceMaterial: EnumItem, targetMaterial: EnumItem): ()Replaces occupied cells of the selected material within the region. Other materials and cell occupancy are preserved.
ReplaceMaterialAsync
Terrain:ReplaceMaterialAsync(region: Region3, resolution: number?, sourceMaterial: EnumItem, targetMaterial: EnumItem): TerrainJobQueues material replacement within a region and returns a TerrainJob.
Sculpt
Terrain:Sculpt(string, Vector3, number, table?): numberEdits terrain with Add, Subtract, Grow, Erode, Smooth, Flatten, Paint, Replace, Flood, or Drain and returns the changed-cell count. Center and radius must be finite; radius must be positive and is capped at 512 studs. Brush Shape accepts Sphere, Cube, or Cylinder. Replace requires From; Flatten accepts PlanePosition, PlaneNormal, and FlattenMode.
SetCell
Terrain:SetCell(x: number, y: number, z: number, material: EnumItem, block: EnumItem?, orientation: EnumItem?): ()Sets a cell's material and optional block shape. The orientation argument is accepted but is not applied by the current binding.
SetCells
Sets cells within the region to the supplied material and optional block shape. The orientation argument is accepted but is not applied by the current binding.
SetMaterialColor
Sets the terrain color override for the specified material.
SetMaterialVariant
Terrain:SetMaterialVariant(material: EnumItem, variant: string?): ()Assigns a variant name to a terrain material. Pass nil or an empty string to remove the override.
WorldToCell
Converts a world-space position to terrain-cell coordinates.
WorldToCellPreferEmpty
Converts a world-space position to cell coordinates with a preference for an adjacent empty cell.
WorldToCellPreferSolid
Converts a world-space position to cell coordinates with a preference for an adjacent occupied cell.
WriteVoxels
Terrain:WriteVoxels(region: Region3, resolution: number?, materials: { { { EnumItem } } }, occupancy: { { { number } } }): ()Writes material and occupancy arrays indexed as [x][y][z]. The arrays must cover the cell dimensions of the supplied region.
WriteVoxelsAsync
Terrain:WriteVoxelsAsync(region: Region3, resolution: number?, materials: { { { EnumItem } } }, occupancy: { { { number } } }): TerrainJobQueues writing voxel arrays and returns a TerrainJob.
Inherited members
- Properties
- AnchoredAngularVelocityBackSurfaceBottomSurfaceCanCollideCanQueryCanSeparateCanTouchCastShadowCenterOfMassCFrameCollisionFidelityCollisionGroupColorCoordinateFrameCustomPhysicalPropertiesElasticityFaceCountFrictionFrontSurfaceGravityScaleLeftSurfaceLinearVelocityLockedMassMasslessMaterialMaterialSetMaterialVariantPositionReflectanceRenderLayerRightSurfaceRotationShapeSizeSmoothingAngleTextureIdTopSurfaceTransparencyTriangleCountVertexCountVisibilityMask
- Methods
- ApplyAngularImpulse()ApplyImpulse()ApplyImpulseAtPosition()GetContacts()GetExecutionGroup()GetMass()GetMesh()GetNetworkOwner()GetNetworkOwnershipAuto()GetTouchingParts()GetVelocityAtPosition()Intersect()MakeEditable()Separate()SetMesh()SetNetworkOwner()SetNetworkOwnershipAuto()Subtract()Union()
- Events
- TouchedTouchEnded
- Properties
- ArchivableClassNameNameParent
- Methods
- AddComponent()AddTag()ClearAllChildren()ClearTags()Clone()Destroy()FindFirstAncestor()FindFirstAncestorOfClass()FindFirstAncestorWhichIsA()FindFirstChild()FindFirstChildOfClass()FindFirstChildWhichIsA()FindFirstDescendant()GetAttribute()GetAttributeChangedSignal()GetAttributes()GetChildren()GetComponent()GetComponentChangedSignal()GetComponents()GetDebugId()GetDescendants()GetFullName()GetPropertyChangedSignal()GetReferencing()GetTags()HasComponent()HasTag()IsA()IsAncestorOf()IsDescendantOf()RemoveComponent()RemoveTag()SetAttribute()WaitForChild()
- Events
- AncestryChangedAttributeChangedChangedChildAddedChildRemovedDescendantAddedDescendantRemovingDestroying