Reference Source
public class | source

VBOGeometry

Extends:

ComponentGeometry → VBOGeometry

A Geometry that keeps its geometry data solely in GPU memory, without retaining it in browser memory.

VBOGeometry uses less memory than ReadableGeometry, which keeps its geometry data in both browser and GPU memory.

Usage

Creating a Mesh with a VBOGeometry that defines a single triangle, plus a PhongMaterial with diffuse Texture:

[Run this example]

import {Viewer, Mesh, VBOGeometry, PhongMaterial, Texture} from "xeokit-sdk.es.js";

const viewer = new Viewer({
        canvasId: "myCanvas"
    });

new Mesh(viewer.scene, {
        geometry: new VBOGeometry(viewer.scene, {
            primitive: "triangles",
            positions: [0.0, 3, 0.0, -3, -3, 0.0, 3, -3, 0.0],
            normals: [0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0],
            uv: [0.0, 0.0, 0.5, 1.0, 1.0, 0.0],
            indices: [0, 1, 2]
        }),
        material: new PhongMaterial(viewer.scene, {
            diffuseMap: new Texture(viewer.scene, {
                src: "textures/diffuse/uvGrid2.jpg"
            }),
            backfaces: true
        })
    });

Constructor Summary

Public Constructor
public

constructor(owner: Component, cfg: *)

Member Summary

Public Members
public get

Gets the local-space axis-aligned 3D boundary (AABB).

public get

Approximate number of triangles in this VBOGeometry.

public get

obb: Number[]

Gets the local-space oriented 3D boundary (OBB).

public get

Gets the primitive type.

Method Summary

Public Methods
public

Destroys this component.

Inherited Summary

From class Component
public get

The Component that owns the lifecycle of this Component, if any.

public

True as soon as this Component has been destroyed

public

ID of this Component, unique within the Scene.

public

meta: *

Arbitrary, user-defined metadata on this component.

public

The parent Scene that contains this Component.

public

The viewer that contains this Scene.

public

clear()

Destroys all Components that are owned by this.

public

Destroys this component.

public

error(message: String)

Logs an error for this component to the JavaScript console.

public

fire(event: String, value: Object, forget: Boolean)

Fires an event on this component.

public

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

public

isType(type: *): *: Boolean

Tests if this component is of the given type, or is a subclass of the given type.

public

log(message: String)

Logs a console debugging message for this component.

public

off(subId: String)

Cancels an event subscription that was previously made with Component#on or Component#once.

public

on(event: String, callback: Function, scope: Object): String

Subscribes to an event on this component.

public

once(event: String, callback: Function, scope: Object)

Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is subIdd.

public

scheduleTask(task: *)

Schedule a task to perform on the next browser interval

public

warn(message: String)

Logs a warning for this component to the JavaScript console.

From class Geometry
public

Public Constructors

public constructor(owner: Component, cfg: *) source

Override:

Geometry#constructor

Params:

NameTypeAttributeDescription
owner Component

Owner component. When destroyed, the owner will destroy this component as well.

cfg *
  • optional

Configs

cfg.id String
  • optional

Optional ID, unique among all components in the parent Scene, generated automatically when omitted.

cfg.primitive String
  • optional
  • default: "triangles"

The primitive type. Accepted values are 'points', 'lines', 'line-loop', 'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'.

cfg.positions Number[]
  • optional

Positions array.

cfg.normals Number[]
  • optional

Vertex normal vectors array.

cfg.uv Number[]
  • optional

UVs array.

cfg.colors Number[]
  • optional

Vertex colors.

cfg.indices Number[]
  • optional

Indices array.

cfg.edgeThreshold Number
  • optional
  • default: 10

When autogenerating edges for supporting Drawable#edges, this indicates the threshold angle (in degrees) between the face normals of adjacent triangles below which the edge is discarded.

Public Members

public get aabb: Number[] source

Gets the local-space axis-aligned 3D boundary (AABB).

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

public get numTriangles: Number source

Approximate number of triangles in this VBOGeometry.

Will be zero if VBOGeometry#primitive is not 'triangles', 'triangle-strip' or 'triangle-fan'.

public get obb: Number[] source

Gets the local-space oriented 3D boundary (OBB).

The OBB is represented by a 32-element Float64Array containing the eight vertices of the box, where each vertex is a homogeneous coordinate having [x,y,z,w] elements.

public get primitive: String source

Gets the primitive type.

Possible types are: 'points', 'lines', 'line-loop', 'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'.

Public Methods

public destroy() source

Destroys this component.

Override:

Geometry#destroy