提交 e5f0ec13 编写于 作者: M Mr.doob

UTF8Loader: Updated some of the addAttribute calls.

Need to think what to do when the array is already created, like index in this case...
上级 57354d14
...@@ -34,9 +34,13 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray ...@@ -34,9 +34,13 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
var geometry = new THREE.BufferGeometry(); var geometry = new THREE.BufferGeometry();
var positionArray = new Float32Array( 3 * 3 * ntris ); var positions = new THREE.Float32Attribute( ntris * 3, 3 );
var normalArray = new Float32Array( 3 * 3 * ntris ); var normals = new THREE.Float32Attribute( ntris * 3, 3 );
var uvArray = new Float32Array( 2 * 3 * ntris ); var uvs = new THREE.Float32Attribute( ntris * 3, 2 );
var positionsArray = positions.array;
var normalsArray = normals.array;
var uvsArray = uvs.array;
var i, j, offset; var i, j, offset;
var x, y, z; var x, y, z;
...@@ -56,9 +60,9 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray ...@@ -56,9 +60,9 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
y = attribArray[ i + 1 ]; y = attribArray[ i + 1 ];
z = attribArray[ i + 2 ]; z = attribArray[ i + 2 ];
positionArray[ j++ ] = x; positionsArray[ j++ ] = x;
positionArray[ j++ ] = y; positionsArray[ j++ ] = y;
positionArray[ j++ ] = z; positionsArray[ j++ ] = z;
} }
...@@ -72,8 +76,8 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray ...@@ -72,8 +76,8 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
u = attribArray[ i ]; u = attribArray[ i ];
v = attribArray[ i + 1 ]; v = attribArray[ i + 1 ];
uvArray[ j++ ] = u; uvsArray[ j++ ] = u;
uvArray[ j++ ] = v; uvsArray[ j++ ] = v;
} }
...@@ -88,16 +92,16 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray ...@@ -88,16 +92,16 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
y = attribArray[ i + 1 ]; y = attribArray[ i + 1 ];
z = attribArray[ i + 2 ]; z = attribArray[ i + 2 ];
normalArray[ j++ ] = x; normalsArray[ j++ ] = x;
normalArray[ j++ ] = y; normalsArray[ j++ ] = y;
normalArray[ j++ ] = z; normalsArray[ j++ ] = z;
} }
geometry.addAttribute( 'index', indexArray, 1 ); geometry.addAttribute( 'index', indexArray, 1 );
geometry.addAttribute( 'position', positionArray, 3 ); geometry.addAttribute( 'position', positions );
geometry.addAttribute( 'normal', normalArray, 3 ); geometry.addAttribute( 'normal', normals );
geometry.addAttribute( 'uv', uvArray, 2 ); geometry.addAttribute( 'uv', uvs );
geometry.offsets.push( { start: 0, count: indexArray.length, index: 0 } ); geometry.offsets.push( { start: 0, count: indexArray.length, index: 0 } );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册