PIXI.Geometry

class Geometry

The Geometry represents a model. It consists of two components:

  • GeometryStyle - The structure of the model such as the attributes layout
  • GeometryData - the data of the model - this consists of buffers. This can include anything from positions, uvs, normals, colors etc.

Geometry can be defined without passing in a style or data if required (thats how I prefer!)

let geometry = new PIXI.Geometry();

geometry.addAttribute('positions', [0, 0, 100, 0, 100, 100, 0, 100], 2);
geometry.addAttribute('uvs', [0,0,1,0,1,1,0,1],2)
geometry.addIndex([0,1,2,1,3,2])

Constructor


new PIXI.Geometry(buffers: Array<PIXI.Buffer>, attributes: { [key: string]: PIXI.Attribute }) → {}
Parameters:
Name Type Description
buffers Array<PIXI.Buffer>

An array of buffers. optional.

attributes { [key: string]: PIXI.Attribute }

Of the geometry, optional structure of the attributes layout

Summary


Properties from Geometry

object
glVertexArrayObjects
number
instanceCount = 1
boolean
instanced

Whether the geometry is instanced.

number
refCount

Count of existing (not destroyed) meshes that reference this geometry.

Methods from Geometry

PIXI.Geometry
static merge(geometries: Array<PIXI.Geometry>)

Merges an array of geometries into a new single one.

this
addAttribute(id: string, buffer: PIXI.Buffer | number<Array>, size: number, normalized: boolean, type: PIXI.TYPES, stride: number, start: number, instance: boolean)
PIXI.Geometry
addIndex(buffer: PIXI.Buffer | number<Array>)
PIXI.Geometry
clone()
void
destroy()

Destroys the geometry.

void
dispose()

Disposes WebGL resources that are connected to this geometry.

PIXI.Attribute
getAttribute(id: string)
PIXI.Buffer
getBuffer(id: string)
PIXI.Buffer
getIndex()
number
getSize()

Get the size of the geometries, in vertices.

PIXI.Geometry
interleave()

Public Properties


glVertexArrayObjects Geometry.ts:59
glVertexArrayObjects: object

A map of renderer IDs to webgl VAOs

instanceCount Geometry.ts:53
instanceCount: number = 1

Number of instances in this geometry, pass it to GeometrySystem.draw().

instanced Geometry.ts:50
instanced: boolean

Whether the geometry is instanced.

refCount Geometry.ts:66
refCount: number

Count of existing (not destroyed) meshes that reference this geometry.

Public Methods


merge Geometry.ts:331
static merge(geometries: Array<PIXI.Geometry>) → {PIXI.Geometry}

Merges an array of geometries into a new single one.

Geometry attribute styles must match for this operation to work.

Parameters:
Name Type Description
geometries Array<PIXI.Geometry>

array of geometries to merge

Returns:
Type Description
PIXI.Geometry
  • Shiny new geometry!
addAttribute Geometry.ts:92
addAttribute(id: string, buffer: PIXI.Buffer | number<Array>, size: number, normalized: boolean, type: PIXI.TYPES, stride: number, start: number, instance: boolean) → {this}

Adds an attribute to the geometry Note: stride and start should be undefined if you dont know them, not 0!

Parameters:
Name Type Attributes Default Description
id string

the name of the attribute (matching up to a shader)

buffer PIXI.Buffer | number<Array>

the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it.

size number 0

the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2

normalized boolean false

should the data be normalized.

type PIXI.TYPES

<optional>

PIXI.TYPES.FLOAT

what type of number is the attribute. Check {PIXI.TYPES} to see the ones available

stride number

<optional>

0

How far apart, in bytes, the start of each value is. (used for interleaving data)

start number

<optional>

0

How far into the array to start reading values (used for interleaving data)

instance boolean false

Instancing flag

Returns:
Type Description
this
  • Returns self, useful for chaining.
addIndex Geometry.ts:174
addIndex(buffer: PIXI.Buffer | number<Array>) → {PIXI.Geometry}

Adds an index buffer to the geometry The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer.

Parameters:
Name Type Attributes Description
buffer PIXI.Buffer | number<Array>

<optional>

The buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it.

Returns:
Type Description
PIXI.Geometry
  • Returns self, useful for chaining.
clone Geometry.ts:294
clone() → {PIXI.Geometry}

Returns a clone of the geometry.

Returns:
Type Description
PIXI.Geometry
  • A new clone of this geometry.
destroy Geometry.ts:284
destroy() → {void}

Destroys the geometry.

Returns:
Type Description
void
dispose Geometry.ts:278
dispose() → {void}

Disposes WebGL resources that are connected to this geometry.

Returns:
Type Description
void
getAttribute Geometry.ts:154
getAttribute(id: string) → {PIXI.Attribute}

Returns the requested attribute.

Parameters:
Name Type Description
id string

The name of the attribute required

Returns:
Type Description
PIXI.Attribute
  • The attribute requested.
getBuffer Geometry.ts:164
getBuffer(id: string) → {PIXI.Buffer}

Returns the requested buffer.

Parameters:
Name Type Description
id string

The name of the buffer required.

Returns:
Type Description
PIXI.Buffer
  • The buffer requested.
getIndex Geometry.ts:206
getIndex() → {PIXI.Buffer}

Returns the index buffer

Returns:
Type Description
PIXI.Buffer
  • The index buffer.
getSize Geometry.ts:264
getSize() → {number}

Get the size of the geometries, in vertices.

Returns:
Type Description
number
interleave Geometry.ts:215
interleave() → {PIXI.Geometry}

This function modifies the structure so that all current attributes become interleaved into a single buffer This can be useful if your model remains static as it offers a little performance boost

Returns:
Type Description
PIXI.Geometry
  • Returns self, useful for chaining.

Powered by webdoc!