Model Object Facade (ModelObject)

Published Updated
Detailed specification of the ModelObject facade in the Aircada SDK, providing programmatic control over 3D mesh files, physics, colliders, and shadow rendering.

The ModelObject is the fundamental programmatic facade for imported 3D mesh assets in Aircada (e.g. GLTF, OBJ, or FBX formats, type: 'MODEL'). It extends the base ISceneObject interface to expose high-performance spatial transformations, physical collision boundaries, and material characteristics.

Operators query and manipulate ModelObject instances using default references decorated with @SceneObjectProperty(). Once bound by the runtime engine, developers can dynamically alter model pivots, physics attributes, and interact with user gestures.

Model Material Override Action Input Example#

Example showing how to activate a model and dynamically allocate material override instances.

Example showing how to show a ModelObject and instantiate its material parameters.

typescript
// Hydrate and instanciate individual material parameters
this.industrialPump.show();
this.industrialPump.materialInstance();
Showing industrialPump and allocating material instance properties.

Model Mesh Click Events and Listener Teardown#

Example illustrating how to bind click listeners to ModelObjects to displace them, and cleanly unsubscribe using the Dispose pattern.

Example showing how to subscribe to click events on a ModelObject mesh to displace its position and cleanly dispose the listener.

DisplacementTrigger.ts (typescript)
import { Setup, Dispose, Operator, SceneObjectProperty, ModelObject } from "@aircada/spec";
import { SceneObjects } from "../registry/scene.registry";

@Operator({
    name: "Displacement Trigger",
    type: "DISPLACEMENT_TRIGGER"
})
export class DisplacementTrigger {
    // Direct 3D mesh reference: matches an actual object in the 3D scene configured and referenced in the auto-generated scene.registry file.
    @SceneObjectProperty()
    targetMesh: ModelObject = SceneObjects.DICE_MESH;

    private unsubscribeToClick?: () => void;

    @Setup()
    setup() {
        // Attach click listener and save unsubscribe callback
        this.unsubscribeToClick = this.targetMesh.onClick.addListener(() => {
            console.log("Mesh clicked! Elevating dice physically...");
            this.targetMesh.position.set(0, 5.0, 0); // Displace physically upwards
        });
    }

    @Dispose()
    dispose() {
        // Prevent memory leaks by cleaning up the listener
        this.unsubscribeToClick?.();
    }
}
Operator class modifying targetMesh position on click and cleaning up listener on dispose.

Declaring ModelObject References in Operators#

Example showing how to reference an imported 3D model inside an Operator class and trigger setup actions.

Example showing how to declare a ModelObject property and show the model on setup.

AssetController.ts (typescript)
import { Setup, Operator, SceneObjectProperty, ModelObject } from "@aircada/spec";
import { SceneObjects } from "../registry/scene.registry";

@Operator({
    name: "Asset Animation Controller",
    type: "ASSET_ANIMATION_CONTROLLER"
})
export class AssetController {
    // Direct 3D mesh reference: matches an actual object in the 3D scene configured and referenced in the auto-generated scene.registry file.
    @SceneObjectProperty()
    industrialPump: ModelObject = SceneObjects.PUMP_1;

    @Setup()
    setup() {
        // Set initial visibility on startup
        this.industrialPump.show();
    }
}
Operator class declaring industrialPump property as a ModelObject and showing it on setup.

Configuring Model Collider Bounds and Physics#

Example illustrating how to enable collision physics, set high surface friction, and cast realistic shadows.

Example showing how to configure physics, collider properties, and shadows on a ModelObject.

typescript
// Configure model as a heavy, highly frictional physical rigid body
this.industrialPump.castShadows = true;
this.industrialPump.receiveShadow = true;
this.industrialPump.isCollider = true;
this.industrialPump.reactToWorldForces = true;
this.industrialPump.colliderFriction = 0.85;
this.industrialPump.colliderElasticity = 0.1; // Low bounce
this.industrialPump.colliderDensity = 0.9;
Enabling shadows, physical colliders, friction, elasticity, and density on ModelObject.

ModelObject Action Inputs and Mesh Commands#

Control methods exposed as inputs on ModelObject instances to handle visibility and rebind material states.

Inputs represent imperative operations that other systems can trigger on a ModelObject facade:

Available Inputs:

  • show(): Renders the mesh visible in the active viewport and enables physical boundaries.
  • hide(): Disables rendering and physical bounds detection completely.
  • materialInstance(): Rebinds standard texture assets dynamically to instantiate individual surface overrides.
  • dataInput(payload: DataBlock[]): Streams serializable data blocks to drive visual components or animate states.
  • show() / hide(): Safe, non-destructive visibility switches.
  • materialInstance(): Dynamically overrides base glTF textures with custom runtime instances.
  • dataInput(payload): Dynamic pipeline data intake.

ModelObject Event Outputs and Gesture Streams#

Asynchronous event channels capturing clicks, dragging states, and pipeline data propagation.

Outputs allow Operators to subscribe to reactive runtime events dispatched by the ModelObject:

Available Outputs:

  • onClick: AirEvent<void>: Dispatched once when a user taps or clicks on the model's visual or physical bounds.
  • whileHeld: AirEvent<void>: Fired continuously on every frame while the user maintains an active select gesture on the model.
  • onRelease: AirEvent<void>: Dispatched when a click, select, or drag gesture is ended.
  • dataOutput: AirEvent<DataBlock[]>: Emits custom pipeline values downstream to other nodes.
  • onClick: Pointer click trigger.
  • whileHeld: Continuous interaction tracking, excellent for real-time physics manipulation.
  • onRelease: Selection ended trigger.
  • dataOutput: Custom pipeline event emitter for transferring serializable states.

ModelObject Direct Properties and Overrides#

Comprehensive breakdown of direct flat properties on ModelObject including transforms, materials, useOriginal override rules, pivots, shadows, and physics.

A ModelObject exposes flat direct properties for spatial transformations, material surfaces, pivots, shadow casting, and collision physics at runtime.

Direct Spatial Transforms:

  • position: Vector3: Spatial translation coordinates (X, Y, Z).
  • rotation: Euler | Quaternion: Spatial rotation orientation.
  • scale: Vector3: Spatial scale factors along world axes.

Direct Material Properties:

  • color: string: Hex color code string for the primary surface mesh (e.g. '#18181B').
  • roughness: number: Surface roughness factor (Range: 0.0 smooth mirror to 1.0 matte rough).
  • metalness: number: Surface metallicity factor (Range: 0.0 dielectric to 1.0 metallic conductor).
  • opacity: number: Surface alpha opacity (Range: 0.0 transparent to 1.0 opaque).
  • envMapIntensity: number: Environment reflection and lighting multiplier.
  • useOriginal: boolean: When true, preserves the custom baked glTF textures rather than applying scene material overrides.
  • linkedMaterialId: string: Reference ID to a shared scene material asset.

๐Ÿ›‘ Material Overrides & Studio useOriginal Flag

Dynamic Runtime Material Overrides: In order for programmatic property mutations (e.g. model.color = '#18181B', model.roughness = 0.2, model.metalness = 0.95, model.colorMap = ...) to take visual effect in the Three.js viewport, the ModelObject in Studio MUST have useOriginal: false (Material Overrides enabled).

If useOriginal is true, the rendering engine prioritizes the asset's embedded baked glTF shader over dynamic script properties, causing script updates to succeed in data but produce no visual change in the viewport.

Mesh Pivot and Bounds:

  • pivotOffset: Vector3: Moves the model relative to its coordinate handle. Useful for centering off-origin meshes.
  • pivotRotation: Quaternion: Adjusts internal mesh coordinate axes.
  • boundingScale: Vector3: Sets size boundaries of the mesh along spatial axes.
  • renderOrder: number: Adjusts painter-sorting prioritization for overlapping or translucent geometry.
  • mediaItemId: string: Complex media asset reference ID holding the source file.

Shadow Behaviors:

  • castShadows: boolean: Enables the mesh to block light rays and project shadows on other objects.
  • receiveShadow: boolean: Renders physical light shadows projected by other casting elements.

Physics and Colliders:

  • isCollider: boolean: Enables collision bounds detection for physical simulations or raycasts.
  • colliderOffset / Rotation / Scale: Configures physical bounding box bounds separate from visual mesh.
  • reactToWorldForces: boolean: Registers object as rigid dynamic body responding to gravity and collision impacts.
  • colliderFriction: number: Surface friction coefficient (FLOAT, Range: 0 to 1).
  • colliderElasticity: number: Restitution bouncy coefficient (FLOAT, Range: 0 to 1).
  • colliderDensity: number: Material mass density calculations (FLOAT, Range: 0 to 1).
  • Flat Properties: Transform and material properties exist directly on the ModelObject facade.
  • Material Overrides (useOriginal: false): Programmatic material updates require useOriginal: false to override baked glTF shaders.
  • pivotOffset: Real-time adjustment to correct physical rotational handles.
  • reactToWorldForces: Activates rigid-body gravity and collision physical simulation.
  • castShadows / receiveShadow: Realistic occlusion shadows.
  • isCollider: Toggles raycast bounds and rigid physical collisions.

ModelObject Child Facades and Architecture#

Overview of flat properties on ModelObject and attached visual effect subsystems.

In modern Aircada SDK conventions (@aircada/spec), ModelObject exposes transform and material properties directly on the flat facade for maximum performance and ergonomics:

  • Flat Materials: Direct access to .color, .roughness, .metalness, .opacity, and .linkedMaterialId. For details, see the 3D Materials & Facades guide.
  • Effects Subsystem (.effects): Dedicated facade for runtime visual highlight shaders (e.g. blinking, highlight outlines). For details, see the The Effects Facade API guide.