Shape
Class for building custom shapes.
Example:
var shape = new NGL.Shape("shape", { disableImpostor: true });
shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );
shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);
shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);
shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);
shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);
shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);
var shapeComp = stage.addComponentFromObject(shape);
geoComp.addRepresentation("buffer");
Constructor Summary
Public Constructor | ||
public |
constructor(name: String, params: Object) |
Member Summary
Public Members | ||
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public get |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public get |
|
Private Members | ||
private |
|
Method Summary
Public Methods | ||
public |
addArrow(position1: Vector3 | Array, position2: Vector3 | Array, color: Color | Array, radius: Float, name: String): Shape Add an arrow |
|
public |
addBox(position: Vector3 | Array, color: Color | Array, size: Float, heightAxis: Vector3 | Array, depthAxis: Vector3 | Array, name: String): Shape Add a box |
|
public |
Add a buffer |
|
public |
addCone(position1: Vector3 | Array, position2: Vector3 | Array, color: Color | Array, radius: Float, name: String): Shape Add a cone |
|
public |
addCylinder(position1: Vector3 | Array, position2: Vector3 | Array, color: Color | Array, radius: Float, name: String): Shape Add a cylinder |
|
public |
addEllipsoid(position: Vector3 | Array, color: Color | Array, radius: Float, majorAxis: Vector3 | Array, minorAxis: Vector3 | Array, name: String): Shape Add an ellipsoid |
|
public |
addLabel() Deprecated, use |
|
public |
addMesh(position: Float32Array | Array, color: Float32Array | Array, index: Uint32Array | Uint16Array | Array, normal: Float32Array | Array, name: String): Shape Add a mesh |
|
public |
addOctahedron(position: Vector3 | Array, color: Color | Array, size: Float, heightAxis: Vector3 | Array, depthAxis: Vector3 | Array, name: String): Shape Add an octahedron |
|
public |
Add a sphere |
|
public |
addTetrahedron(position: Vector3 | Array, color: Color | Array, size: Float, heightAxis: Vector3 | Array, depthAxis: Vector3 | Array, name: String): Shape Add a tetrahedron |
|
public |
Add text |
|
public |
addTorus(position: Vector3 | Array, color: Color | Array, radius: Float, majorAxis: Vector3 | Array, minorAxis: Vector3 | Array, name: String): Shape Add a torus |
|
public |
dispose() |
|
public |
|
Public Constructors
public constructor(name: String, params: Object) source
Params:
Name | Type | Attribute | Description |
name | String | name |
|
params | Object | parameter object |
|
params.aspectRatio | Integer | arrow aspect ratio, used for cylinder radius and cone length |
|
params.sphereDetail | Integer | sphere quality (icosahedron subdivisions) |
|
params.radialSegments | Integer | cylinder quality (number of segments) |
|
params.disableImpostor | Boolean | disable use of raycasted impostors for rendering |
|
params.openEnded | Boolean | capped or not |
|
params.labelParams | TextBufferParameters | label parameters |
Public Members
public [P.getShapeKey('name')] source
public [P.getShapeKey(name)] source
public aspectRatio source
public boundingBox source
public bufferList source
public get center source
public disableImpostor source
public labelParams source
public meshCount source
public name source
public openEnded source
public radialSegments source
public sphereDetail source
public get type source
Private Members
private _center source
Public Methods
public addArrow(position1: Vector3 | Array, position2: Vector3 | Array, color: Color | Array, radius: Float, name: String): Shape source
Add an arrow
Example:
shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);
public addBox(position: Vector3 | Array, color: Color | Array, size: Float, heightAxis: Vector3 | Array, depthAxis: Vector3 | Array, name: String): Shape source
Add a box
Example:
shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);
public addBuffer(buffer: Buffer): Shape source
Add a buffer
Params:
Name | Type | Attribute | Description |
buffer | Buffer | buffer object |
public addCone(position1: Vector3 | Array, position2: Vector3 | Array, color: Color | Array, radius: Float, name: String): Shape source
Add a cone
Example:
shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);
public addCylinder(position1: Vector3 | Array, position2: Vector3 | Array, color: Color | Array, radius: Float, name: String): Shape source
Add a cylinder
Example:
shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);
public addEllipsoid(position: Vector3 | Array, color: Color | Array, radius: Float, majorAxis: Vector3 | Array, minorAxis: Vector3 | Array, name: String): Shape source
Add an ellipsoid
Example:
shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);
public addMesh(position: Float32Array | Array, color: Float32Array | Array, index: Uint32Array | Uint16Array | Array, normal: Float32Array | Array, name: String): Shape source
Add a mesh
Params:
Name | Type | Attribute | Description |
position | Float32Array | Array | positions |
|
color | Float32Array | Array | colors |
|
index | Uint32Array | Uint16Array | Array |
|
indices |
normal | Float32Array | Array |
|
normals |
name | String |
|
text |
Example:
shape.addMesh(
[ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],
[ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]
);
public addOctahedron(position: Vector3 | Array, color: Color | Array, size: Float, heightAxis: Vector3 | Array, depthAxis: Vector3 | Array, name: String): Shape source
Add an octahedron
Example:
shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);
public addSphere(position: Vector3 | Array, color: Color | Array, radius: Float, name: String): Shape source
Add a sphere
Example:
shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);
public addTetrahedron(position: Vector3 | Array, color: Color | Array, size: Float, heightAxis: Vector3 | Array, depthAxis: Vector3 | Array, name: String): Shape source
Add a tetrahedron
Example:
shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);
public addText(position: Vector3 | Array, color: Color | Array, size: Float, text: String): Shape source
Add text
Example:
shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, "Hello");
public addTorus(position: Vector3 | Array, color: Color | Array, radius: Float, majorAxis: Vector3 | Array, minorAxis: Vector3 | Array, name: String): Shape source
Add a torus
Example:
shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);