소스 검색

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

Renaud Rohlinger 1 년 전
부모
커밋
7bc5aae1f9
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  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._elementType = this.elementType === null ? getValueType( this.array[ 0 ] ) : this.elementType;
 		this._elementLength = builder.getTypeLength( 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.bufferCount = length;
 		this.bufferType = builder.changeComponentType( 'vec4', builder.getComponentType( this._elementType ) );
 		this.bufferType = builder.changeComponentType( 'vec4', builder.getComponentType( this._elementType ) );