Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Cuboid

The Cuboid (or FlexCuboid) is a modifiable item which can be adjusted in length, width, and height.

Note: Cuboid property adjustments are applied symmetrically.

Hierarchy

Index

Constructors

Properties

active: boolean

Defines this item's active state.

If false, this item

  • Is not visible
  • Ignores (physics-) collisions
  • Ignores tracing, e.g. from RayCast and Input
  • Does not use physics
animated: boolean

Returns true if this item has animation tracks.

center: Vector3

Returns the center point of this item.

returns

center of this item in world space.

children: ItemCollection

Returns all first-level hierarchy children of this item.

Note: This does not return a complete children Transform hierarchy.

See BaseItem.parent

color: Color

Defines color of this item.

To change opacity, use BaseItem.opacity.

height: number

Defines the height of this Cuboid.

This property is multiplied by the item's transform.scale factor.

highlight: { ambient: number; amplitude: number; color: Color; enabled: boolean; frequency: number; intensity: number; type: "default" | "light" | "outline" | "inherited" }

Type declaration

  • ambient: number
    returns

    ambient brightness of the light.

  • amplitude: number
    returns

    intensity-change of the light. Value of 1 causes highlight intensity to fully fade in and out.

  • color: Color
    returns

    color of the light.

  • enabled: boolean

    Toggles the highlight effect on this item. If true, displays item highlight.

  • frequency: number
    returns

    speed of pulsating light effect. Higher values cause fast transition, low values cause slow transition.

  • intensity: number
    returns

    intensity of the light. High values may cause item to be overexposed.

  • type: "default" | "light" | "outline" | "inherited"

    Defines the highlight type of this item.

    • default: item uses highlight and outline
    • light: item uses light only
    • outline: item uses outline only
    • inherited: item uses highlight options from parent-item
    returns

    current highlight type on this item.

    See BaseItem.parent

id: string

The unique id of this item.

If several items share the same name, this item can still be found by its id.

See Scene.getItem

See BaseItem.name

input: { onButtonDown: any; onButtonUp: any; onClick: any; onHover: any; removeDrag: any; setCollisionDrag: any; setItemDrag: any; setPlaneDrag: any; setRotationAxisDrag: any; setRotationContinuousDrag: any; setRotationDrag: any; setSphereDrag: any }

Type declaration

  • onButtonDown:function
    • onButtonDown(handler: (() => void)): void
    • Triggers whenever the main input is pressed down inside of this item.

      Calling this function on an existing handler overwrites the handler.

      Parameters

      • handler: (() => void)

        function to call on press down. Pass null to remove the handler.

          • (): void
          • Returns void

      Returns void

  • onButtonUp:function
    • onButtonUp(handler: (() => void)): void
    • Triggers whenever the main input is released inside of this item.

      Calling this function on an existing handler overwrites the handler.

      Parameters

      • handler: (() => void)

        function to call on release. Pass null to remove the handler.

          • (): void
          • Returns void

      Returns void

  • onClick:function
    • onClick(handler: (() => void)): void
    • Triggers whenever the main input is pressed and released inside of this item.

      Calling this function on an existing click handler overwrites the handler.

      Parameters

      • handler: (() => void)

        function to call after click. Pass null to remove the handler.

          • (): void
          • Returns void

      Returns void

  • onHover:function
    • onHover(handler: ((t: boolean) => void)): void
    • Triggers whenever the item is hovered.

      Calling this function on existing hover handler overwrites the handler.

      Parameters

      • handler: ((t: boolean) => void)

        method to call on hover event. Uses boolean property to determine start and end of hover event. Pass null to remove the handler.

          • (t: boolean): void
          • Parameters

            • t: boolean

            Returns void

      Returns void

  • removeDrag:function
    • removeDrag(): void
    • Returns void

  • setCollisionDrag:function
    • setCollisionDrag(): void
    • setCollisionDrag(callback: (() => void)): void
    • Creates a drag interaction on this item to another item, allowing this item to be moved on the surface of other items.

      Returns void

    • Creates a drag interaction on this item to another item, allowing this item to be moved on the surface of other items.

      Parameters

      • callback: (() => void)

        function to call when the drag interaction ends

          • (): void
          • Returns void

      Returns void

  • setItemDrag:function
    • setItemDrag(target: BaseItem): void
    • setItemDrag(target: BaseItem, callback: (() => void)): void
    • Creates a drag interaction which causes this item to be draggable on the target.

      Parameters

      • target: BaseItem

        item to use as drag surface.

      Returns void

    • Creates a drag interaction which causes this item to be draggable on the target.

      Parameters

      • target: BaseItem

        item to use as drag surface.

      • callback: (() => void)

        function to call when the drag interaction ends.

          • (): void
          • Returns void

      Returns void

  • setPlaneDrag:function
  • setRotationAxisDrag:function
    • setRotationAxisDrag(origin: Vector3, direction: Vector3): void
    • setRotationAxisDrag(origin: Vector3, direction: Vector3, callback: (() => void)): void
    • Parameters

      Returns void

    • Parameters

      • origin: Vector3
      • direction: Vector3
      • callback: (() => void)
          • (): void
          • Returns void

      Returns void

  • setRotationContinuousDrag:function
    • setRotationContinuousDrag(origin: Vector3, direction: Vector3, speed: number): void
    • setRotationContinuousDrag(origin: Vector3, direction: Vector3, speed: number, callback: (() => void)): void
    • Parameters

      Returns void

    • Parameters

      • origin: Vector3
      • direction: Vector3
      • speed: number
      • callback: (() => void)
          • (): void
          • Returns void

      Returns void

  • setRotationDrag:function
    • setRotationDrag(): void
    • setRotationDrag(callback: (() => void)): void
    • Returns void

    • Parameters

      • callback: (() => void)
          • (): void
          • Returns void

      Returns void

  • setSphereDrag:function
    • setSphereDrag(): void
    • setSphereDrag(callback: (() => void)): void
    • Returns void

    • Parameters

      • callback: (() => void)
          • (): void
          • Returns void

      Returns void

length: number

Defines the length of this Cuboid.

This property is multiplied by the item's transform.scale factor.

masking: boolean
name: string

Name of this item displayed in their name tag and in the item hierarchy.

nameVisible: boolean

Toggles visibility of the item name tag.

opacity: number

Normalized opacity of this item.

Note: Items with opacity below 0.3 ignore inputs, e.g. from BaseItem.input.

parent: BaseItem

Returns the parent of this item.

parentSlot: Slot
physics: { angularVelocity: Vector3; angularVelocityLocal: Vector3; enabled: boolean; force: Vector3; friction: number; group: { velocityLocal: Vector3 }; mass: number; position: Vector3; preciseCollision: boolean; restitution: number; softness: number; static: boolean; velocity: Vector3; velocityLocal: Vector3; addToCollisionFilter: any; applyForce: any; applyImpulse: any; applyImpulseLocal: any; onCollisionEnter: any; onCollisionExit: any; removeFromCollisionFilter: any; restrictMovementAxis: any; restrictRotationAxis: any; shiftPosition: any; shiftPositionLocal: any }

Type declaration

  • angularVelocity: Vector3

    Returns world space angularVelocity of this item.

    returns

    angular velocity in world space.

  • angularVelocityLocal: Vector3

    Returns local space angularVelocity of this item.

    returns

    angular velocity in world space.

    See BaseItem.parent

  • enabled: boolean

    Toggles this item to be simulated with physics.

    returns

    physics simulation state.

  • force: Vector3

    Defines directional force that is applied on this item each frame.

    returns

    item force in world space.

  • friction: number

    Defines the friction of this item during movement

    • Value of 0 resembles ice
    • Value of 1 resembles a surface with high friction, e.g. car tyre.
    returns

    item friction.

  • Readonly group: { velocityLocal: Vector3 }
    • velocityLocal: Vector3

      Returns the world space velocity of the group's center of mass.

      returns

      velocity in world space.

  • mass: number

    Defines the mass of this item. Items with higher mass more easily push away items with lower mass.

    returns

    item mass.

  • position: Vector3

    Returns the world space position of the center of mass for this item.

    returns

    center of mass.

  • preciseCollision: boolean

    Toggles precise model collisions.

    If true, this item attempts to use pre-defined collision volumes if available. If false, this item uses simplified boundary box collision.

  • restitution: number

    Defines this item's restitution (bounciness).

    • Restitution of 0 does not cause item to bounce
    • Restitution of 1 causes item to bounce at no loss of energy
    returns

    item restitution.

  • softness: number

    Defines the velocity threshold at which this item is allowed to be repulsed by collisions.

    High values make this item feel soft, low values make it feel solid.

    returns

    item softness.

  • static: boolean

    Defines static state of this item. Static items have indefinite mass and can not be moved by physics forces.

    returns

    static state.

  • velocity: Vector3

    Returns the world space velocity of the item's center of mass.

    returns

    velocity in world space.

  • velocityLocal: Vector3

    Returns the local space velocity of the item's center of mass.

    returns

    velocity in local space.

    See BaseItem.parent

  • addToCollisionFilter:function
    • addToCollisionFilter(item: BaseItem): void
    • Adds collision filter to target item to ignore collisions, even when this item shares the same collision layer.

      Parameters

      • item: BaseItem

        item to add to collision filter

      Returns void

  • applyForce:function
    • Applies constant directional force to this item each frame.

      Parameters

      • force: Vector3

        world space force to apply.

      Returns void

  • applyImpulse:function
    • Pushes this item with the defined impulse for this frame.

      Parameters

      • origin: Vector3

        origin of the impulse in world space.

      • impulse: Vector3

        direction & force of the impulse.

      Returns void

  • applyImpulseLocal:function
    • Pushes this item with the defined impulse relative to its forward direction for this frame.

      Parameters

      • localOrigin: Vector3

        origin of the impulse relative to item forward direction.

      • impulse: Vector3

        direction & force of the impulse.

      Returns void

  • onCollisionEnter:function
    • onCollisionEnter(handler: ((t: BaseItem) => void)): void
    • Handles the start of a physics collision between this item and another item.

      To remove the handler, pass null for handler.

      Parameters

      • handler: ((t: BaseItem) => void)

        passes BaseItem which this item collides against.

      Returns void

  • onCollisionExit:function
    • onCollisionExit(handler: ((t: BaseItem) => void)): void
    • Handles the end of a physics collision between this item and another item.

      To remove the handler, pass null for handler.

      Parameters

      • handler: ((t: BaseItem) => void)

        passes item which this item collided against.

      Returns void

  • removeFromCollisionFilter:function
    • removeFromCollisionFilter(item: BaseItem): void
    • Removes collision filter from the target item.

      Parameters

      • item: BaseItem

        item to remove from collision filter

      Returns void

  • restrictMovementAxis:function
    • restrictMovementAxis(axes: { x?: boolean; y?: boolean; z?: boolean }): void
    • Restricts this item's movement on the defined axes.

      Parameters

      • axes: { x?: boolean; y?: boolean; z?: boolean }

        axes to restrict movement on.

        • Optional Readonly x?: boolean
        • Optional Readonly y?: boolean
        • Optional Readonly z?: boolean

      Returns void

  • restrictRotationAxis:function
    • restrictRotationAxis(axes: { x?: boolean; y?: boolean; z?: boolean }): void
    • Restricts this item's rotation to the defined rotation axes

      Parameters

      • axes: { x?: boolean; y?: boolean; z?: boolean }

        axes to restrict movement one.

        • Optional Readonly x?: boolean
        • Optional Readonly y?: boolean
        • Optional Readonly z?: boolean

      Returns void

  • shiftPosition:function
    • shiftPosition(shift: Vector3): void
    • Moves this item by an offset from its current position.

      Parameters

      • shift: Vector3

        offset from current position in world space.

      Returns void

  • shiftPositionLocal:function
    • shiftPositionLocal(offset: Vector3): void
    • Moves this item by an offset relative to its forward direction.

      Parameters

      • offset: Vector3

        offset relative to forward direction.

      Returns void

relativeTransform: Transform

The relative Transform of this item in local space.

The local space is determined by this item's BaseItem.parent.

See BaseItem.transform

slots: Slot[]

Returns all slots found in this item.

speech: string | number

Defines the text in the speech-bubble of this item.

thought: string | number

Defines the text in the thought-bubble of this item.

transform: Transform

The Transform of this item in world space.

transition: { colorTo: any; lookAt: any; moveBy: any; moveOnPath: any; moveTo: any; opacityTo: any; rotateLocal: any; scaleTo: any; stop: any }

Type declaration

  • colorTo:function
    • Creates a color transition on this item from startColor to endColor over duration.

      Parameters

      • startColor: Color

        start color.

      • endColor: Color

        end color.

      • duration: number

        time in seconds.

      Returns Tweener

      created Tweener.

  • lookAt:function
    • Rotates this item to face towards a target point over duration.

      Parameters

      • target: Vector3

        point in world space.

      • duration: number

        time in seconds.

      Returns Tweener

      created Tweener.

    • Rotates this item to face towards a target point over duration.

      Parameters

      • target: Vector3

        point in world space.

      • duration: number

        time in seconds.

      • callback: (() => void)

        function to call when this item faces the target point.

          • (): void
          • Returns void

      Returns Tweener

      created Tweener.

    • Rotates this item over duration so that

      • its local Y-axis points towards the target point.
      • its local Z-axis points towards the worldUp direction.

      Note: The local Z-axis always attempts to be perpendicular to Y, which may lead to worldUp not always accurately being pointed at.

      Parameters

      • target: Vector3

        point in world space.

      • duration: number

        time in seconds.

      • worldUp: Vector3

        defines the upward direction.

      Returns Tweener

      created Tweener.

    • Rotates this item over duration so that

      • its local Y-axis points towards the target point.
      • its local Z-axis points towards the worldUp direction.

      Note: The local Z-axis always attempts to be perpendicular to Y, which may lead to worldUp not always accurately being pointed at.

      Parameters

      • target: Vector3

        point in world space.

      • duration: number

        time in seconds.

      • worldUp: Vector3

        defines the upward direction.

      • callback: (() => void)

        function to call when this item looks at target.

          • (): void
          • Returns void

      Returns Tweener

      created Tweener.

  • moveBy:function
    • Moves this item from its current position by local offset vector.

      Parameters

      • target: Vector3

        relative offset to apply.

      • duration: number

        time in seconds.

      Returns Tweener

      created Tweener.

    • Moves this item from its current position by local offset vector.

      Parameters

      • target: Vector3

        relative offset to apply.

      • duration: number

        time in seconds.

      • callback: (() => void)

        function to call when the target is reached.

          • (): void
          • Returns void

      Returns Tweener

      created Tweener.

  • moveOnPath:function
    • moveOnPath(options: { endPoint?: number; path: PathItem; repeat?: boolean; reverse?: boolean; speed?: number; startPoint?: number; time?: number; turnWithPath?: boolean; callback?: any }): Tweener
    • Moves this item on a PathItem.

      Example

      //moves an item indefinitely on a PathItem
      const myItem = Scene.getItem("myItem")
      const myPath = Scene.getItem("myPath") as PathItem

      myItem.transition.moveOnPath({
      path: myPath,
      speed: 1.5,
      turnWithPath: true,
      repeat: true
      })

      Parameters

      • options: { endPoint?: number; path: PathItem; repeat?: boolean; reverse?: boolean; speed?: number; startPoint?: number; time?: number; turnWithPath?: boolean; callback?: any }

        path movement options.

        • Optional Readonly endPoint?: number
        • Readonly path: PathItem
        • Optional Readonly repeat?: boolean
        • Optional Readonly reverse?: boolean
        • Optional Readonly speed?: number
        • Optional Readonly startPoint?: number
        • Optional Readonly time?: number
        • Optional Readonly turnWithPath?: boolean

          For closed paths

        • callback?:function
          • callback(): void
          • Returns void

      Returns Tweener

      created Tweener.

  • moveTo:function
    • Moves this item to the target point over duration.

      Parameters

      • target: Vector3

        point in world space.

      • duration: number

        time in seconds.

      Returns Tweener

      created Tweener.

    • Moves this item to the target point over duration.

      Parameters

      • target: Vector3

        point in world space.

      • duration: number

        time in seconds.

      • callback: (() => void)

        function to call when the target is reached.

          • (): void
          • Returns void

      Returns Tweener

      created Tweener.

  • opacityTo:function
    • opacityTo(target: number, duration: number): Tweener
    • opacityTo(target: number, duration: number, callback: (() => void)): Tweener
    • opacityTo(startValue: number, target: number, duration: number): Tweener
    • opacityTo(startValue: number, target: number, duration: number, callback: (() => void)): Tweener
    • Fades this item's to the target opacity over duration.

      Parameters

      • target: number

        opacity to fade to.

      • duration: number

        time in seconds.

      Returns Tweener

      created Tweener.

    • Fades this item's to the target opacity over duration.

      Parameters

      • target: number

        opacity to fade to.

      • duration: number

        time in seconds.

      • callback: (() => void)

        function to call when the target is reached.

          • (): void
          • Returns void

      Returns Tweener

      created Tweener.

    • Fades this item's to the target opacity over duration.

      Parameters

      • startValue: number

        starting opacity.

      • target: number

        opacity to fade to.

      • duration: number

        time in seconds.

      Returns Tweener

      created Tweener.

    • Fades this item's to the target opacity over duration.

      Parameters

      • startValue: number

        starting opacity.

      • target: number

        opacity to fade to.

      • duration: number

        time in seconds.

      • callback: (() => void)

        function to call when the target is reached.

          • (): void
          • Returns void

      Returns Tweener

      created Tweener.

  • rotateLocal:function
    • rotateLocal(axis: Vector3, angleInRadians: number, duration: number): Tweener
    • rotateLocal(axis: Vector3, angleInRadians: number, duration: number, callback: (() => void)): Tweener
    • rotateLocal(offset: Vector3, axis: Vector3, angleInRadians: number, duration: number): Tweener
    • rotateLocal(offset: Vector3, axis: Vector3, angleInRadians: number, duration: number, callback: (() => void)): Tweener
    • Rotates this item by angleInRadians towards axis direction over duration.

      Parameters

      • axis: Vector3

        vector defining the local rotation axis.

      • angleInRadians: number

        rotation in radians.

      • duration: number

        time in seconds.

      Returns Tweener

      created Tweener

    • Rotates this item by angleInRadians towards axis direction over duration.

      Parameters

      • axis: Vector3

        vector defining the local rotation axis.

      • angleInRadians: number

        rotation in radians.

      • duration: number

        time in seconds.

      • callback: (() => void)

        function to call when the Tweener ends.

          • (): void
          • Returns void

      Returns Tweener

      created Tweener

    • Rotates this item by angleInRadians around an offset towards axis direction over duration.

      Parameters

      • offset: Vector3

        offset relative to current position.

      • axis: Vector3

        vector defining the local rotation axis.

      • angleInRadians: number

        rotation in radians.

      • duration: number

        time in seconds.

      Returns Tweener

      created Tweener

    • Rotates this item by angleInRadians around an offset towards axis direction over duration.

      Parameters

      • offset: Vector3

        offset relative to current position.

      • axis: Vector3

        vector defining the local rotation axis.

      • angleInRadians: number

        rotation in radians.

      • duration: number

        time in seconds.

      • callback: (() => void)

        function to call when the Tweener ends.

          • (): void
          • Returns void

      Returns Tweener

      created Tweener

  • scaleTo:function
    • scaleTo(startValue: number, endValue: number, duration: number): Tweener
    • Scales this item from startValue to endValue over duration.

      Parameters

      • startValue: number

        starting size.

      • endValue: number

        target size.

      • duration: number

        time in seconds.

      Returns Tweener

      created Tweener.

  • stop:function
    • stop(): void
    • Stops all Tweener on this item.

      See Tweener

      Returns void

visible: boolean
deprecated

replaced with BaseItem.active ()}

width: number

Defines the width of this Cuboid.

This property is multiplied by the item's transform.scale factor.

Methods

  • addTag(tag: string): void
  • delete(): void
  • Irreversibly removes this item from the Scene.

    Note: This method does not update previously existing item references.

    Returns void

  • deleteChildren(): void
  • getProperty(key: string): string
  • Gets a custom property from this object. Returns null if the property can not be found.

    Parameters

    • key: string

      name of property to search.

    Returns string

  • getSlot(name: string): Slot
  • Returns Slot by name.

    Parameters

    • name: string

      name of slot to find.

    Returns Slot

  • hasTag(tag: string): boolean
  • Returns true if the defined tag can be find in this item.

    Parameters

    Returns boolean

  • onCollisionEnter(handler: ((t: BaseItem) => void)): void
  • Handles the start of a collision between this item and another item.

    To remove the handler, pass null for handler.

    Parameters

    • handler: ((t: BaseItem) => void)

      passes BaseItem which this item collides against.

    Returns void

  • onCollisionExit(handler: ((t: BaseItem) => void)): void
  • Handles the end of a collision between this item and another item.

    Calling this function on an existing collision handler overwrites the handler.

    Parameters

    • handler: ((t: BaseItem) => void)

      passes item which this item collided against.

    Returns void

  • onPropertyChanged(id: string, handler: ((t: string) => void)): void
  • Handles property value changes in this object.

    Parameters

    • id: string

      property to listen to.

    • handler: ((t: string) => void)

      function that's called when property value is changed.

        • (t: string): void
        • Parameters

          • t: string

          Returns void

    Returns void

  • removeFromParent(): void
  • removeTag(tag: string): void
  • setProperty(key: string, value: any): void
  • Sets a custom property to this object.

    Properties are saved as strings.

    Parameters

    • key: string

      property name.

    • value: any

      property value.

    Returns void