Options
All
  • Public
  • Public/Protected
  • All
Menu

Class 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');

Hierarchy

  • Shape

Index

Constructors

constructor

Properties

Optional _center

_center: Vector3

_primitiveData

_primitiveData: object

Type declaration

  • [k: string]: any

boundingBox

boundingBox: Box3 = new Box3()

bufferList

bufferList: Buffer[] = []

meshCount

meshCount: number = 0

name

name: string

parameters

parameters: ShapeParameters

Accessors

center

  • get center(): Vector3

type

  • get type(): string

Methods

addArrow

  • addArrow(position1: Vector3 | [number, number, number], position2: Vector3 | [number, number, number], color: Color | [number, number, number], radius: number, name: string): this
  • Add an arrow

    example

    shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);

    Parameters

    • position1: Vector3 | [number, number, number]

      from position vector or array

    • position2: Vector3 | [number, number, number]

      to position vector or array

    • color: Color | [number, number, number]

      color object or array

    • radius: number

      radius value

    • name: string

    Returns this

    this object

addBox

  • addBox(position: Vector3 | [number, number, number], color: Color | [number, number, number], size: number, heightAxis: Vector3 | [number, number, number], depthAxis: Vector3 | [number, number, number], name: string): this
  • Add a box

    example

    shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);

    Parameters

    • position: Vector3 | [number, number, number]

      position vector or array

    • color: Color | [number, number, number]

      color object or array

    • size: number

      size value

    • heightAxis: Vector3 | [number, number, number]

      height axis vector or array

    • depthAxis: Vector3 | [number, number, number]

      depth axis vector or array

    • name: string

    Returns this

    this object

addBuffer

  • addBuffer(buffer: Buffer): this

addCone

  • addCone(position1: Vector3 | [number, number, number], position2: Vector3 | [number, number, number], color: Color | [number, number, number], radius: number, name: string): this
  • Add a cone

    example

    shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);

    Parameters

    • position1: Vector3 | [number, number, number]

      from position vector or array

    • position2: Vector3 | [number, number, number]

      to position vector or array

    • color: Color | [number, number, number]

      color object or array

    • radius: number

      radius value

    • name: string

    Returns this

    this object

addCylinder

  • addCylinder(position1: Vector3 | [number, number, number], position2: Vector3 | [number, number, number], color: Color | [number, number, number], radius: number, name: string): this
  • Add a cylinder

    example

    shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);

    Parameters

    • position1: Vector3 | [number, number, number]

      from position vector or array

    • position2: Vector3 | [number, number, number]

      to position vector or array

    • color: Color | [number, number, number]

      color object or array

    • radius: number

      radius value

    • name: string

    Returns this

    this object

addEllipsoid

  • addEllipsoid(position: Vector3 | [number, number, number], color: Color | [number, number, number], radius: number, majorAxis: Vector3 | [number, number, number], minorAxis: Vector3 | [number, number, number], name: string): this
  • Add an ellipsoid

    example

    shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);

    Parameters

    • position: Vector3 | [number, number, number]

      position vector or array

    • color: Color | [number, number, number]

      color object or array

    • radius: number

      radius value

    • majorAxis: Vector3 | [number, number, number]

      major axis vector or array

    • minorAxis: Vector3 | [number, number, number]

      minor axis vector or array

    • name: string

    Returns this

    this object

addLabel

  • addLabel(position: Vector3 | [number, number, number], color: Color | [number, number, number], size: number, text: string): this
  • Deprecated, use .addText

    Parameters

    • position: Vector3 | [number, number, number]
    • color: Color | [number, number, number]
    • size: number
    • text: string

    Returns this

addMesh

  • addMesh(position: Float32Array | number[], color: Float32Array | number[], index: Uint32Array | Uint16Array | number[], normal: Float32Array | number[], name?: undefined | string): this
  • Add a mesh

    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 ] );

    Parameters

    • position: Float32Array | number[]

      positions

    • color: Float32Array | number[]

      colors

    • index: Uint32Array | Uint16Array | number[]
    • normal: Float32Array | number[]
    • Optional name: undefined | string

    Returns this

    this object

addOctahedron

  • addOctahedron(position: Vector3 | [number, number, number], color: Color | [number, number, number], size: number, heightAxis: Vector3 | [number, number, number], depthAxis: Vector3 | [number, number, number], name: string): this
  • Add an octahedron

    example

    shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);

    Parameters

    • position: Vector3 | [number, number, number]

      position vector or array

    • color: Color | [number, number, number]

      color object or array

    • size: number

      size value

    • heightAxis: Vector3 | [number, number, number]

      height axis vector or array

    • depthAxis: Vector3 | [number, number, number]

      depth axis vector or array

    • name: string

    Returns this

    this object

addPoint

  • addPoint(position: Vector3 | [number, number, number], color: Color | [number, number, number], name: string): this
  • Add point

    example

    shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);

    Parameters

    • position: Vector3 | [number, number, number]

      position vector or array

    • color: Color | [number, number, number]

      color object or array

    • name: string

    Returns this

    this object

addSphere

  • addSphere(position: Vector3 | [number, number, number], color: Color | [number, number, number], radius: number, name: string): this
  • Add a sphere

    example

    shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);

    Parameters

    • position: Vector3 | [number, number, number]

      position vector or array

    • color: Color | [number, number, number]

      color object or array

    • radius: number

      radius value

    • name: string

    Returns this

    this object

addTetrahedron

  • addTetrahedron(position: Vector3 | [number, number, number], color: Color | [number, number, number], size: number, heightAxis: Vector3 | [number, number, number], depthAxis: Vector3 | [number, number, number], name: string): this
  • Add a tetrahedron

    example

    shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);

    Parameters

    • position: Vector3 | [number, number, number]

      position vector or array

    • color: Color | [number, number, number]

      color object or array

    • size: number

      size value

    • heightAxis: Vector3 | [number, number, number]

      height axis vector or array

    • depthAxis: Vector3 | [number, number, number]

      depth axis vector or array

    • name: string

    Returns this

    this object

addText

  • addText(position: Vector3 | [number, number, number], color: Color | [number, number, number], size: number, text: string): this
  • Add text

    example

    shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, "Hello");

    Parameters

    • position: Vector3 | [number, number, number]

      position vector or array

    • color: Color | [number, number, number]

      color object or array

    • size: number

      size value

    • text: string

      text value

    Returns this

    this object

addTorus

  • addTorus(position: Vector3 | [number, number, number], color: Color | [number, number, number], radius: number, majorAxis: Vector3 | [number, number, number], minorAxis: Vector3 | [number, number, number], name: string): this
  • Add a torus

    example

    shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);

    Parameters

    • position: Vector3 | [number, number, number]

      position vector or array

    • color: Color | [number, number, number]

      color object or array

    • radius: number

      radius value

    • majorAxis: Vector3 | [number, number, number]

      major axis vector or array

    • minorAxis: Vector3 | [number, number, number]

      minor axis vector or array

    • name: string

    Returns this

    this object

addWideline

  • addWideline(position1: Vector3 | [number, number, number], position2: Vector3 | [number, number, number], color: Color | [number, number, number], name: string): this
  • Add a wideline

    example

    shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);

    Parameters

    • position1: Vector3 | [number, number, number]

      from position vector or array

    • position2: Vector3 | [number, number, number]

      to position vector or array

    • color: Color | [number, number, number]

      color object or array

    • name: string

    Returns this

    this object

dispose

  • dispose(): void

getBufferList

Generated using TypeDoc