t3d. SphereGeometry

A class for generating sphere geometries. The geometry is created by sweeping and calculating vertexes around the Y axis (horizontal sweep) and the Z axis (vertical sweep). Thus, incomplete spheres (akin to 'sphere slices') can be created through the use of different values of phiStart, phiLength, thetaStart and thetaLength, in order to define the points in which we start (or end) calculating those vertices.

Constructor

new SphereGeometry(radiusopt, widthSegmentsopt, heightSegmentsopt, phiStartopt, phiLengthopt, thetaStartopt, thetaLengthopt)

Parameters:
NameTypeAttributesDefaultDescription
radiusNumber<optional>
1— sphere radius. Default is 1.
widthSegmentsNumber<optional>
8— number of horizontal segments. Minimum value is 3, and the default is 8.
heightSegmentsNumber<optional>
6— number of vertical segments. Minimum value is 2, and the default is 6.
phiStartNumber<optional>
0— specify horizontal starting angle. Default is 0.
phiLengthNumber<optional>
Math.PI*2— specify horizontal sweep angle size. Default is Math.PI * 2.
thetaStartNumber<optional>
0— specify vertical starting angle. Default is 0.
thetaLengthNumber<optional>
Math.PI— specify vertical sweep angle size. Default is Math.PI.

Extends

Members

attributes :Object

This hashmap has as id the name of the attribute to be set and as value the buffer to set it to. Rather than accessing this property directly, use t3d.Geometry#addAttribute and t3d.Geometry#getAttribute to access attributes of this geometry.
Type:
  • Object

boundingBox :t3d.Box3

Bounding box for the bufferGeometry, which can be calculated with t3d.Geometry#computeBoundingBox.
Default Value
  • t3d.Box3()

boundingSphere :t3d.Sphere

Bounding sphere for the bufferGeometry, which can be calculated with t3d.Geometry#computeBoundingSphere.
Default Value
  • t3d.Sphere()

groups :Array

Split the geometry into groups, each of which will be rendered in a separate WebGL draw call. This allows an array of materials to be used with the geometry. Each group is an object of the form: { start: Integer, count: Integer, materialIndex: Integer }, or { multiDrawStarts: Integer[], multiDrawCounts: Integer[], multiDrawCount: Integer, materialIndex: Integer } if multiDraw is available.
Type:
  • Array
Default Value
  • []

(readonly) id :Number

Unique number for this geometry instance.
Type:
  • Number

index :t3d.Attribute|Null

Allows for vertices to be re-used across multiple triangles; this is called using "indexed triangles" and each triangle is associated with the indices of three vertices. This attribute therefore stores the index of each vertex for each triangular face. If this attribute is not set, the renderer assumes that each three contiguous positions represent a single triangle.
Type:

instanceCount :Number

The number of instances to be rendered. If set to -1 (default), instanced rendering is disabled. This property is used for instanced rendering, where multiple copies of the geometry are drawn with a single draw call.
Type:
  • Number
Default Value
  • -1

morphAttributes :Object

Hashmap of Attributes Array for morph targets.
Type:
  • Object

(readonly) uuid :String

UUID of this geometry instance. This gets automatically assigned, so this shouldn't be edited.
Type:
  • String

version :Number

A version number, incremented every time the attribute object or index object changes to mark VAO drity.
Type:
  • Number
Default Value
  • 0

Methods

addAttribute(name, attribute)

Adds an attribute to this geometry. Use this rather than the attributes property.
Parameters:
NameTypeDescription
nameString
attributet3d.Attribute

addEventListener(type, listener, thisObjectopt)

Adds a listener to an event type.
Parameters:
NameTypeAttributesDefaultDescription
typeStringThe type of event to listen to.
listenerfunctionThe function that gets called when the event is fired.
thisObjectObject<optional>
thisThe Object of calling listener method.

addGroup(start, count, materialIndexopt)

Adds a group to this geometry; see the t3d.Geometry#groups for details.
Parameters:
NameTypeAttributesDefaultDescription
startNumber
countNumber
materialIndexNumber<optional>
0

clearGroups()

Clears all groups.

clone() → {t3d.Geometry}

Creates a clone of this Geometry.
Returns:
Type: 
t3d.Geometry

computeBoundingBox()

Computes bounding box of the geometry, updating t3d.Geometry#boundingBox. Bounding boxes aren't computed by default. They need to be explicitly computed.

computeBoundingSphere()

Computes bounding sphere of the geometry, updating t3d.Geometry#boundingSphere. Bounding spheres aren't computed by default. They need to be explicitly computed.

copy(source) → {t3d.Geometry}

Copies another Geometry to this Geometry.
Parameters:
NameTypeDescription
sourcet3d.GeometryThe geometry to be copied.
Returns:
Type: 
t3d.Geometry

dispatchEvent(event)

Fire an event.
Parameters:
NameTypeDescription
eventObjectThe event that gets fired.

dispose()

Disposes the object from memory. You need to call this when you want the BufferGeometry removed while the application is running.

getAttribute(name) → {t3d.Attribute}

Returns the attribute with the specified name.
Parameters:
NameTypeDescription
nameString
Returns:
Type: 
t3d.Attribute

removeAttribute(name)

Removes the attribute with the specified name.
Parameters:
NameTypeDescription
nameString

removeEventListener(type, listener, thisObjectopt)

Removes a listener from an event type.
Parameters:
NameTypeAttributesDefaultDescription
typeStringThe type of the listener that gets removed.
listenerfunctionThe listener function that gets removed.
thisObjectObject<optional>
thisthisObject - The Object of calling listener method.

setIndex(index)

Set the t3d.Geometry#index buffer.
Parameters:
NameTypeDescription
indexArray | t3d.Attribute | Null