Explorar o código

TSL: UniformsNode use correct Int/Uint Arrays (#28723)

Renaud Rohlinger hai 1 ano
pai
achega
7bc5aae1f9
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      examples/jsm/nodes/accessors/UniformsNode.js

+ 6 - 1
examples/jsm/nodes/accessors/UniformsNode.js

@@ -118,7 +118,12 @@ class UniformsNode extends BufferNode {
 		this._elementType = this.elementType === null ? getValueType( this.array[ 0 ] ) : this.elementType;
 		this._elementLength = builder.getTypeLength( this._elementType );
 
-		this.value = new Float32Array( length * 4 );
+		let arrayType = Float32Array;
+
+		if ( this._elementType.charAt( 0 ) === 'i' ) arrayType = Int32Array;
+		else if ( this._elementType.charAt( 0 ) === 'u' ) arrayType = Uint32Array;
+
+		this.value = new arrayType( length * 4 );
 		this.bufferCount = length;
 		this.bufferType = builder.changeComponentType( 'vec4', builder.getComponentType( this._elementType ) );