@@ -9261,7 +9261,7 @@ THREE.Face3.prototype = {
9261
9261
* @author mrdoob / http://mrdoob.com/
9262
9262
*/
9263
9263
9264
- THREE.BufferAttribute = function ( array, itemSize ) {
9264
+ THREE.BufferAttribute = function ( array, itemSize, normalized ) {
9265
9265
9266
9266
this.uuid = THREE.Math.generateUUID();
9267
9267
@@ -9272,6 +9272,7 @@ THREE.BufferAttribute = function ( array, itemSize ) {
9272
9272
this.updateRange = { offset: 0, count: - 1 };
9273
9273
9274
9274
this.version = 0;
9275
+ this.normalized = normalized === true;
9275
9276
9276
9277
};
9277
9278
@@ -12329,7 +12330,8 @@ THREE.BufferGeometry.prototype = {
12329
12330
data.data.attributes[ key ] = {
12330
12331
itemSize: attribute.itemSize,
12331
12332
type: attribute.array.constructor.name,
12332
- array: array
12333
+ array: array,
12334
+ normalized: attribute.normalized
12333
12335
};
12334
12336
12335
12337
}
@@ -19126,7 +19128,7 @@ THREE.BufferGeometryLoader.prototype = {
19126
19128
var attribute = attributes[ key ];
19127
19129
var typedArray = new TYPED_ARRAYS[ attribute.type ]( attribute.array );
19128
19130
19129
- geometry.addAttribute( key, new THREE.BufferAttribute( typedArray, attribute.itemSize ) );
19131
+ geometry.addAttribute( key, new THREE.BufferAttribute( typedArray, attribute.itemSize, attribute.normalized ) );
19130
19132
19131
19133
}
19132
19134
@@ -25751,6 +25753,44 @@ THREE.WebGLRenderer = function ( parameters ) {
25751
25753
25752
25754
if ( geometryAttribute !== undefined ) {
25753
25755
25756
+ var type = _gl.FLOAT;
25757
+ var array = geometryAttribute.array;
25758
+ var normalized = geometryAttribute.normalized;
25759
+
25760
+ if ( array instanceof Float32Array ) {
25761
+
25762
+ type = _gl.FLOAT;
25763
+
25764
+ } else if ( array instanceof Float64Array ) {
25765
+
25766
+ console.warn("Unsupported data buffer format: Float64Array");
25767
+
25768
+ } else if ( array instanceof Uint16Array ) {
25769
+
25770
+ type = _gl.UNSIGNED_SHORT;
25771
+
25772
+ } else if ( array instanceof Int16Array ) {
25773
+
25774
+ type = _gl.SHORT;
25775
+
25776
+ } else if ( array instanceof Uint32Array ) {
25777
+
25778
+ type = _gl.UNSIGNED_INT;
25779
+
25780
+ } else if ( array instanceof Int32Array ) {
25781
+
25782
+ type = _gl.INT;
25783
+
25784
+ } else if ( array instanceof Int8Array ) {
25785
+
25786
+ type = _gl.BYTE;
25787
+
25788
+ } else if ( array instanceof Uint8Array ) {
25789
+
25790
+ type = _gl.UNSIGNED_BYTE;
25791
+
25792
+ }
25793
+
25754
25794
var size = geometryAttribute.itemSize;
25755
25795
var buffer = objects.getAttributeBuffer( geometryAttribute );
25756
25796
@@ -25777,7 +25817,7 @@ THREE.WebGLRenderer = function ( parameters ) {
25777
25817
}
25778
25818
25779
25819
_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer );
25780
- _gl.vertexAttribPointer( programAttribute, size, _gl.FLOAT, false , stride * data.array.BYTES_PER_ELEMENT, ( startIndex * stride + offset ) * data.array.BYTES_PER_ELEMENT );
25820
+ _gl.vertexAttribPointer( programAttribute, size, type, normalized , stride * data.array.BYTES_PER_ELEMENT, ( startIndex * stride + offset ) * data.array.BYTES_PER_ELEMENT );
25781
25821
25782
25822
} else {
25783
25823
@@ -25797,19 +25837,8 @@ THREE.WebGLRenderer = function ( parameters ) {
25797
25837
25798
25838
}
25799
25839
25800
- var type = _gl.FLOAT;
25801
- var normalized = false;
25802
- var array = geometryAttribute.array;
25803
-
25804
- if ( array instanceof Uint8Array ) {
25805
-
25806
- type = _gl.UNSIGNED_BYTE;
25807
- normalized = true;
25808
-
25809
- }
25810
-
25811
25840
_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer );
25812
- _gl.vertexAttribPointer( programAttribute, size, type, normalized, 0, startIndex * size * array.BYTES_PER_ELEMENT );
25841
+ _gl.vertexAttribPointer( programAttribute, size, type, normalized, 0, startIndex * size * geometryAttribute. array.BYTES_PER_ELEMENT );
25813
25842
25814
25843
}
25815
25844
0 commit comments