import {VBOGeometry} from '@xeokit/xeokit-sdk/src/viewer/scene/geometry/VBOGeometry.js'
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:
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 |
Gets the local-space oriented 3D boundary (OBB). |
|
public get |
Gets the primitive type. |
Method Summary
Public Methods | ||
public |
destroy() 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 |
destroy() Destroys this component. |
|
public |
Logs an error for this component to the JavaScript console. |
|
public |
Fires an event on this component. |
|
public |
Returns true if there are any subscribers to the given event on this component. |
|
public |
Tests if this component is of the given type, or is a subclass of the given type. |
|
public |
Logs a console debugging message for this component. |
|
public |
Cancels an event subscription that was previously made with Component#on or Component#once. |
|
public |
Subscribes to an event on this component. |
|
public |
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 |
Logs a warning for this component to the JavaScript console. |
From class Geometry | ||
public |
destroy() |
Public Constructors
public constructor(owner: Component, cfg: *) source
Override:
Geometry#constructorParams:
Name | Type | Attribute | Description |
owner | Component | Owner component. When destroyed, the owner will destroy this component as well. |
|
cfg | * |
|
Configs |
cfg.id | String |
|
Optional ID, unique among all components in the parent Scene, generated automatically when omitted. |
cfg.primitive | String |
|
The primitive type. Accepted values are 'points', 'lines', 'line-loop', 'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'. |
cfg.positions | Number[] |
|
Positions array. |
cfg.normals | Number[] |
|
Vertex normal vectors array. |
cfg.uv | Number[] |
|
UVs array. |
cfg.colors | Number[] |
|
Vertex colors. |
cfg.indices | Number[] |
|
Indices array. |
cfg.edgeThreshold | Number |
|
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'.