Reference API Roblox

Engine API

Website

Related

Reference API Roblox

ProceduralModel

Procedural models support edit-time procedural generation. Instead of manually constructing model content, a procedural model generates its contents automatically in response to parameter changes.

Member index 6

HistoryMember
715GenerationError: string
731Generator: ModuleScript
731Size: Vector3
715ForceGeneration(): bool
715WaitForGenerationAsync(): bool
inherited from Model
731LevelOfDetail: ModelLevelOfDetail
731ModelStreamingMode: ModelStreamingMode
731PrimaryPart: BasePart
731Scale: float
731WorldPivot: CFrame
573AddPersistentPlayer(playerInstance: Player = Player): null
573BreakJoints(): null
607GetBoundingBox(): (CFrame, Vector3)
462GetExtentsSize(): Vector3
731GetModelCFrame(): CFrame
731GetModelSize(): Vector3
648GetPersistentPlayers(): Instances
731GetPrimaryPartCFrame(): CFrame
562GetScale(): float
573MakeJoints(): null
573MoveTo(position: Vector3): null
573RemovePersistentPlayer(playerInstance: Player = Player): null
731ResetOrientationToIdentity(): null
573ScaleTo(newScaleFactor: float): null
731SetIdentityOrientation(): null
731SetPrimaryPartCFrame(cframe: CFrame): null
573TranslateBy(delta: Vector3): null
731breakJoints(): null
731makeJoints(): null
731move(location: Vector3): null
731moveTo(location: Vector3): null
inherited from PVInstance
731Origin: CFrame
731Pivot Offset: CFrame
576GetPivot(): CFrame
573PivotTo(targetCFrame: CFrame): null
inherited from Instance
731Archivable: bool
731Capabilities: SecurityCapabilities
731IsInSandbox: bool
731Name: string
731Parent: Instance
731PredictionMode: PredictionMode
731Sandboxed: bool
731UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
731children(): Instances
731clone(): Instance
731destroy(): null
731findFirstChild(name: string, recursive: bool = false): Instance
731getChildren(): Instances
731isDescendantOf(ancestor: Instance): bool
731remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
731childAdded(child: Instance)
inherited from Object
731ClassName: string
731className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
731isA(className: string): bool
647Changed(property: string)

Description

ProceduralModel inherits from Model and supports edit-time procedural generation of its contents. Instead of manually constructing model content, a procedural model generates its contents automatically in response to parameter changes.

Generation is defined by a generator module, a ModuleScript referenced by the Generator property. The engine invokes the module's OnGenerate function to produce the model's contents.

A procedural model regenerates when any of the following inputs change:

  • The Size property of the procedural model, which defines a bounding box for the model to generate within.
  • Any attributes on the procedural mode, as defined by the generator module.
  • The generator's module sandboxing configuration (Sandboxed and Capabilities).
  • The source code of the generator module.

When any of these inputs change, the engine schedules regeneration. This scheduled regeneration is performed by calling OnGenerate and applying its results once it returns. In most cases, generation happens within the same frame, but can be deferred to maintain performance.

History 13

Members 6

ForceGeneration

Parameters (0)
No parameters.
Returns (1)
bool

History 1

GenerationError

TypeDefault
string

If the generator module encounters an error during generation, the contents of the ProceduralModel are replaced with an error state placeholder. The error is stored in the GenerationError property to give you visibility into why the generation failed.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 1

Tags: [ReadOnly, NotReplicated]

Generator

TypeDefault
ModuleScript

A reference to a ModuleScript containing code that defines how the ProceduralModel generates its contents in response to parameter changes.

Setting Generator triggers generation using the new generator module. The Attributes table exported by the module is automatically applied as default attribute values on the ProceduralModel.

Clearing Generator preserves the current contents of the ProceduralModel, and prevents further generation until a new generator is assigned.

Guidelines for writing the generator module's OnGenerate function:

  • Only write results into the provided targetContainer. OnGenerate should not modify the DataModel directly; writes elsewhere may not interact correctly with engine systems.
  • OnGenerate is allowed to yield and call yielding methods (for example, GeometryService CSG APIs). Generation is considered complete whenever OnGenerate returns.
  • Calling parameters:Pause() inside long-running loops lets the engine break up work. It only yields when needed to avoid dropping frames, so calls are low-cost when the frame budget is not exceeded.

History 3

Size

TypeDefault
Vector312, 12, 12

The Size of a ProceduralModel defines the bounding volume used for generation.

In a standard model, size is a derived output value based on its contents and can be queried using GetBoundingBox(). A procedural model inverts this relationship: Size is an input that determines how generation occurs, and is explicitly set as a property.

The Size property represents the physical dimensions of the ProceduralModel and is affected by ScaleTo. The OnGenerate function in a generator module doesn't need to account for position or scaling: it produces a result of the specified Size around the origin at a scale of 1, and the procedural model system automatically uses PivotTo() and ScaleTo() to place and scale the output in the ProceduralModel.

History 3

WaitForGenerationAsync

Parameters (0)
No parameters.
Returns (1)
bool

Generation is scheduled to run as soon as possible after a parameter changes, but not immediately. Use WaitForGenerationAsync() to wait for generation to complete before parameters are changed.

This method errors if called on a ProceduralModel that is not in the DataModel because generation isn't performed for instances without a parent.

This method returns false if the ProceduralModel is removed from the DataModel while generation is in progress, since this cancels the operation.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

Settings