Options
All
  • Public
  • Public/Protected
  • All
Menu

A high-performance model representation for efficient rendering and low memory usage.

Hierarchy

Index

Constructors

Properties

id: string

ID of this Component, unique within the Scene.

Components are mapped by this ID in {@link Scene.components}.

property

id

meta: any

Arbitrary, user-defined metadata on this component.

property

metadata

scene: Scene

The parent Scene that contains this Component.

property

scene

final
viewer: Viewer

The viewer that contains this Scene.

property

viewer

Accessors

  • get aabb(): number[]
  • Gets the VBOSceneModel's World-space 3D axis-aligned bounding box.

    Represented by a six-element Float64Array containing the min/max extents of the axis-aligned volume, ie. [xmin, ymin,zmin,xmax,ymax, zmax].

    Returns number[]

  • get backfaces(): boolean
  • set backfaces(backfaces: boolean): void
  • Sets if backfaces are rendered for this VBOSceneModel.

    Default is false.

    Returns boolean

  • Sets if backfaces are rendered for this VBOSceneModel.

    Default is false.

    When we set this true, then backfaces are always rendered for this VBOSceneModel.

    When we set this false, then we allow the Viewer to decide whether to render backfaces. In this case, the Viewer will:

    • hide backfaces on watertight meshes,
    • show backfaces on open meshes, and
    • always show backfaces on meshes when we slice them open with SectionPlanes.

    Parameters

    • backfaces: boolean

    Returns void

  • get castsShadow(): boolean
  • set castsShadow(castsShadow: boolean): void
  • get clippable(): boolean
  • set clippable(clippable: boolean): void
  • get collidable(): boolean
  • set collidable(collidable: boolean): void
  • get colorize(): number[]
  • set colorize(colorize: number[]): void
  • get culled(): boolean
  • set culled(culled: boolean): void
  • get edges(): boolean
  • set edges(edges: boolean): void
  • get highlighted(): boolean
  • set highlighted(highlighted: boolean): void
  • get isDrawable(): boolean
  • get isEntity(): boolean
  • get isModel(): boolean
  • get isObject(): boolean
  • get matrix(): number[]
  • get numLines(): number
  • get numPoints(): number
  • get numTriangles(): number
  • get objects(): {}
  • get opacity(): number
  • set opacity(opacity: number): void
  • get origin(): number[]
  • The Component that owns the lifecycle of this Component, if any.

    When that component is destroyed, this component will be automatically destroyed also.

    Will be null if this Component has no owner.

    property

    owner

    Returns Component

  • get pbrEnabled(): boolean
  • get pickable(): boolean
  • set pickable(pickable: boolean): void
  • get position(): number[]
  • get quaternion(): number[]
  • get receivesShadow(): boolean
  • set receivesShadow(receivesShadow: boolean): void
  • get rotation(): number[]
  • get saoEnabled(): boolean
  • get scale(): number[]
  • get selected(): boolean
  • set selected(selected: boolean): void
  • get visible(): boolean
  • set visible(visible: boolean): void
  • get worldMatrix(): number[]
  • get worldNormalMatrix(): number[]
  • get xrayed(): boolean
  • set xrayed(xrayed: boolean): void

Methods

  • clear(): void
  • createEntity(cfg: { castsShadow?: boolean; clippable?: boolean; collidable?: boolean; culled?: boolean; edges?: boolean; highlighted?: boolean; id: string; isObject: boolean; meshIds: string[]; pickable?: boolean; receivesShadow?: boolean; selected?: boolean; visible?: boolean; xrayed?: boolean }): Entity
  • Creates an Entity within this VBOSceneModel, giving it one or more meshes previously created with VBOSceneModel.createMesh.

    A mesh can only belong to one Entity, so you'll get an error if you try to reuse a mesh among multiple Entitys.

    Parameters

    • cfg: { castsShadow?: boolean; clippable?: boolean; collidable?: boolean; culled?: boolean; edges?: boolean; highlighted?: boolean; id: string; isObject: boolean; meshIds: string[]; pickable?: boolean; receivesShadow?: boolean; selected?: boolean; visible?: boolean; xrayed?: boolean }

      Entity configuration.

      • Optional castsShadow?: boolean
      • Optional clippable?: boolean
      • Optional collidable?: boolean
      • Optional culled?: boolean
      • Optional edges?: boolean
      • Optional highlighted?: boolean
      • id: string

        Optional ID for the new Entity. Must not clash with any existing components within the Scene.

      • isObject: boolean
      • meshIds: string[]

        IDs of one or more meshes created previously with {@link VBOSceneModel@createMesh}.

      • Optional pickable?: boolean
      • Optional receivesShadow?: boolean
      • Optional selected?: boolean
      • Optional visible?: boolean
      • Optional xrayed?: boolean

    Returns Entity

  • createGeometry(cfg: { colors: number[]; colorsCompressed: number[]; edgeIndices: number[]; id: string | number; indices: number[]; normals: number[]; origin?: number[]; positions: number[]; positionsDecodeMatrix: number[]; primitive: "lines" | "triangles" | "solid" | "surface" }): void
  • Creates a reusable geometry within this VBOSceneModel.

    We can then supply the geometry ID to VBOSceneModel.createMesh when we want to create meshes that instance the geometry.

    If provide a positionsDecodeMatrix , then createGeometry() will assume that the positions and normals arrays are compressed. When compressed, positions will be quantized and in World-space, and normals will be oct-encoded and in World-space.

    Note that positions, normals and indices are all required together.

    Parameters

    • cfg: { colors: number[]; colorsCompressed: number[]; edgeIndices: number[]; id: string | number; indices: number[]; normals: number[]; origin?: number[]; positions: number[]; positionsDecodeMatrix: number[]; primitive: "lines" | "triangles" | "solid" | "surface" }

      Geometry properties.

      • colors: number[]
      • colorsCompressed: number[]
      • edgeIndices: number[]
      • id: string | number

        Mandatory ID for the geometry, to refer to with VBOSceneModel.createMesh.

      • indices: number[]
      • normals: number[]
      • Optional origin?: number[]
      • positions: number[]

        Flat array of positions.

      • positionsDecodeMatrix: number[]
      • primitive: "lines" | "triangles" | "solid" | "surface"

        The primitive type. Accepted values are 'points', 'lines', 'triangles', 'solid' and 'surface'.

    Returns void

  • createMesh(cfg: { color?: number[]; colors: number[]; colorsCompressed: number[]; edgeIndices: number[]; geometryId?: string | number; id: string; indices: number[]; matrix?: number[]; normals: number[]; opacity?: number; origin?: number[]; position?: number[]; positions: number[]; positionsDecodeMatrix: number[]; primitive: "points" | "lines" | "triangles"; rotation?: number[]; scale?: number[] }): void
  • Creates a mesh within this VBOSceneModel.

    A mesh can either share geometry with other meshes, or have its own unique geometry.

    To share a geometry with other meshes, provide the ID of a geometry created earlier with VBOSceneModel.createGeometry.

    To create unique geometry for the mesh, provide geometry data arrays.

    Internally, VBOSceneModel will batch all unique mesh geometries into the same arrays, which improves rendering performance.

    If you accompany the arrays with a positionsDecodeMatrix , then createMesh() will assume that the positions and normals arrays are compressed. When compressed, positions will be quantized and in World-space, and normals will be oct-encoded and in World-space.

    If you accompany the arrays with an origin, then createMesh() will assume that the positions are in relative-to-center (RTC) coordinates, with origin being the origin of their RTC coordinate system.

    When providing either positionsDecodeMatrix or origin, createMesh() will start a new batch each time either of those two parameters change since the last call. Therefore, to combine arrays into the minimum number of batches, it's best for performance to create your shared meshes in runs that have the same value for positionsDecodeMatrix and origin.

    Note that positions, normals and indices are all required together.

    Parameters

    • cfg: { color?: number[]; colors: number[]; colorsCompressed: number[]; edgeIndices: number[]; geometryId?: string | number; id: string; indices: number[]; matrix?: number[]; normals: number[]; opacity?: number; origin?: number[]; position?: number[]; positions: number[]; positionsDecodeMatrix: number[]; primitive: "points" | "lines" | "triangles"; rotation?: number[]; scale?: number[] }

      Object properties.

      • Optional color?: number[]
      • colors: number[]
      • colorsCompressed: number[]
      • edgeIndices: number[]
      • Optional geometryId?: string | number
      • id: string

        Mandatory ID for the new mesh. Must not clash with any existing components within the Scene.

      • indices: number[]
      • Optional matrix?: number[]
      • normals: number[]
      • Optional opacity?: number
      • Optional origin?: number[]
      • Optional position?: number[]
      • positions: number[]
      • positionsDecodeMatrix: number[]
      • primitive: "points" | "lines" | "triangles"
      • Optional rotation?: number[]
      • Optional scale?: number[]

    Returns void

  • destroy(): void
  • error(message: string): void
  • Logs an error for this component to the JavaScript console.

    The console message will have this format: [ERROR] [<component type> =<component id>: <message>

    Also fires the message as an "error" event on the parent Scene.

    Parameters

    • message: string

      The message to log

    Returns void

  • finalize(): void
  • fire(event: string, value: any, forget?: boolean): void
  • Fires an event on this component.

    Notifies existing subscribers to the event, optionally retains the event to give to any subsequent notifications on the event as they are made.

    Parameters

    • event: string

      The event type name

    • value: any

      The event parameters

    • Optional forget: boolean

    Returns void

  • hasSubs(event: string): boolean
  • Returns true if there are any subscribers to the given event on this component.

    Parameters

    • event: string

      The event

    Returns boolean

    True if there are any subscribers to the given event on this component.

  • isType(type: any): boolean
  • log(message: string): void
  • Logs a console debugging message for this component.

    The console message will have this format: [LOG] [<component type> <component id>: <message>

    Also fires the message as a "log" event on the parent Scene.

    Parameters

    • message: string

      The message to log

    Returns void

  • off(subId: string): void
  • on(event: "loaded", callback: (loaded: true) => void, scope?: any): string
  • on(event: "error", callback: (msg: string) => void, scope?: any): string
  • Fires when the model is loaded

    Parameters

    • event: "loaded"

      The loaded event

    • callback: (loaded: true) => void

      Called fired on the event

        • (loaded: true): void
        • Parameters

          • loaded: true

          Returns void

    • Optional scope: any

      Scope for the callback

    Returns string

  • Fires when the loading the model has an error

    Parameters

    • event: "error"

      The error event

    • callback: (msg: string) => void

      Called fired on the event

        • (msg: string): void
        • Parameters

          • msg: string

          Returns void

    • Optional scope: any

      Scope for the callback

    Returns string

  • once(event: string, callback: Function, scope?: any): void
  • Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is subIdd.

    This is equivalent to calling Component.on, and then calling Component.off inside the callback function.

    Parameters

    • event: string

      Data event to listen to

    • callback: Function

      Called when fresh data is available at the event

    • Optional scope: any

    Returns void

  • warn(message: string): void
  • Logs a warning for this component to the JavaScript console.

    The console message will have this format: [WARN] [<component type> =<component id>: <message>

    Also fires the message as a "warn" event on the parent Scene.

    Parameters

    • message: string

      The message to log

    Returns void

Generated using TypeDoc