Capítulo 786 de 859

Chapter 786: UniformsGroup

Core Idea

A class for managing multiple uniforms in a single group. The renderer will process such a definition as a single UBO.

Since this class can only be used in context of ShaderMaterial, it is only supported in WebGLRenderer.

Key Concepts

  • buffer : Float32Array: A Float32 array buffer with the uniform values.
  • byteLength : number: The byte length of the buffer with correct buffer alignment.
  • id : number (readonly): The ID of the 3D object.
  • isUniformsGroup : boolean (readonly): This flag can be used for type testing.
  • isUniformsGroup : boolean (readonly): This flag can be used for type testing.
  • name : string: The name of the uniforms group.
  • uniforms : Array.<Uniform>: An array holding the uniforms.
  • uniforms : Array.<Uniform>: An array of uniform objects.
  • usage : StaticDrawUsage | DynamicDrawUsage | StreamDrawUsage | StaticReadUsage | DynamicReadUsage | StreamReadUsage | StaticCopyUsage | DynamicCopyUsage | StreamCopyUsage: The buffer usage.
  • values : Array.<number>: An array with the raw uniform values.

Reference Tables

Constructor

Signature
new UniformsGroup()

Properties

PropertyDescription
.buffer : Float32ArrayA Float32 array buffer with the uniform values.
.byteLength : numberThe byte length of the buffer with correct buffer alignment.
.id : number (readonly)The ID of the 3D object.
.isUniformsGroup : boolean (readonly)This flag can be used for type testing.
.isUniformsGroup : boolean (readonly)This flag can be used for type testing.
.name : stringThe name of the uniforms group.
.uniforms : Array.<Uniform>An array holding the uniforms.
.uniforms : Array.<Uniform>An array of uniform objects.
`.usage : StaticDrawUsageDynamicDrawUsage
.values : Array.<number>An array with the raw uniform values.

Methods

MethodDescription
.add( uniform : Uniform ) : UniformsGroupAdds the given uniform to this uniforms group.
.addUniform( uniform : Uniform ) : UniformsGroupAdds a uniform to this group.
.addUniformUpdateRange( uniform : Uniform )Adds a uniform's update range to this buffer.
.clearUpdateRanges()Clears all update ranges of this buffer.
.clone() : UniformsGroupReturns a new uniforms group with copied values from this instance.
.copy( source : UniformsGroup ) : UniformsGroupCopies the values of the given uniforms group to this instance.
.dispose()Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
.release()Releases the buffer.
.remove( uniform : Uniform ) : UniformsGroupRemoves the given uniform from this uniforms group.
.removeUniform( uniform : Uniform ) : UniformsGroupRemoves a uniform from this group.
.setName( name : string ) : UniformsGroupSets the name of this uniforms group.
`.setUsage( value : StaticDrawUsageDynamicDrawUsage
.update() : booleanUpdates this group by updating each uniform object of the internal uniform list. The uniform objects check if their values has actually changed so this method only returns true if there is a real v…
.updateByType( uniform : Uniform ) : booleanUpdates a given uniform by calling an update method matching the uniforms type.
.updateColor( uniform : ColorUniform ) : booleanUpdates a given Color uniform.
.updateMatrix3( uniform : Matrix3Uniform ) : booleanUpdates a given Matrix3 uniform.
.updateMatrix4( uniform : Matrix4Uniform ) : booleanUpdates a given Matrix4 uniform.
.updateNumber( uniform : NumberUniform ) : booleanUpdates a given Number uniform.
.updateVector2( uniform : Vector2Uniform ) : booleanUpdates a given Vector2 uniform.
.updateVector3( uniform : Vector3Uniform ) : booleanUpdates a given Vector3 uniform.
.updateVector4( uniform : Vector4Uniform ) : booleanUpdates a given Vector4 uniform.

Key Takeaways

  1. UniformsGroup extends: EventDispatcher
  2. Most relevant properties: buffer, byteLength, id, isUniformsGroup.
  3. Key methods: add, addUniform, addUniformUpdateRange, clearUpdateRanges.

Connects To