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

Replaced Math.max.apply( Max, ... ) with setIndexArray(). See #10603.

上级 a8b8af08
......@@ -125,7 +125,7 @@ THREE.AssimpJSONLoader.prototype = {
}
geometry.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( indices, 1 ) );
geometry.setIndexArray( indices );
geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
if ( normals.length > 0 ) {
......
......@@ -263,15 +263,7 @@
if ( geoNode.indices !== undefined && geoNode.indices.length > 0 ) {
if ( Math.max.apply( Math, geoNode.indices ) > 65535 ) {
tmpGeo.setIndex( new THREE.BufferAttribute( new Uint32Array( geoNode.indices ), 1 ) );
} else {
tmpGeo.setIndex( new THREE.BufferAttribute( new Uint16Array( geoNode.indices ), 1 ) );
}
tmpGeo.setIndexArray( geoNode.indices );
}
......
......@@ -1477,7 +1477,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
var initGeometry = function () {
geometry.setIndex( new ( Math.max.apply( Math, buffer.indices ) > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( buffer.indices, 1 ) );
geometry.setIndexArray( buffer.indices );
geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( buffer.normals, 3 ) );
geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( buffer.uvs, 2 ) );
......
......@@ -313,8 +313,11 @@ THREE.PLYLoader.prototype = {
// mandatory buffer data
if ( buffer.indices.length > 0 ) {
geometry.setIndex( new ( Math.max.apply( Math, buffer.indices ) > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( buffer.indices, 1 ) );
geometry.setIndexArray( buffer.indices );
}
geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
// optional buffer data
......
......@@ -514,7 +514,7 @@ BufferGeometry.prototype = {
if ( geometry.indices.length > 0 ) {
var TypeArray = Math.max.apply( Math, geometry.indices ) > 65535 ? Uint32Array : Uint16Array;
var TypeArray = _Math.arrayMax( geometry.indices ) > 65535 ? Uint32Array : Uint16Array;
var indices = new TypeArray( geometry.indices.length * 3 );
this.setIndex( new BufferAttribute( indices, 1 ).copyIndicesArray( geometry.indices ) );
......
......@@ -32,7 +32,7 @@ BoxGeometry.prototype.constructor = BoxGeometry;
* @author Mugen87 / https://github.com/Mugen87
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { Vector3 } from '../math/Vector3';
......@@ -82,7 +82,7 @@ function BoxBufferGeometry( width, height, depth, widthSegments, heightSegments,
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -29,7 +29,7 @@ CircleGeometry.prototype.constructor = CircleGeometry;
* @author Mugen87 / https://github.com/Mugen87
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { Vector3 } from '../math/Vector3';
import { Vector2 } from '../math/Vector2';
......@@ -106,7 +106,7 @@ function CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) {
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -33,7 +33,7 @@ CylinderGeometry.prototype.constructor = CylinderGeometry;
* @author Mugen87 / https://github.com/Mugen87
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { Vector3 } from '../math/Vector3';
import { Vector2 } from '../math/Vector2';
......@@ -96,7 +96,7 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -34,7 +34,7 @@ function LatheGeometry( points, segments, phiStart, phiLength ) {
LatheGeometry.prototype = Object.create( Geometry.prototype );
LatheGeometry.prototype.constructor = LatheGeometry;
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { Vector3 } from '../math/Vector3';
import { Vector2 } from '../math/Vector2';
......@@ -62,7 +62,7 @@ function LatheBufferGeometry( points, segments, phiStart, phiLength ) {
phiLength = phiLength || Math.PI * 2;
// clamp phiLength so it's in range of [ 0, 2PI ]
phiLength = _Math.clamp( phiLength, 0, Math.PI * 2 );
......@@ -135,7 +135,7 @@ function LatheBufferGeometry( points, segments, phiStart, phiLength ) {
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -35,7 +35,7 @@ ParametricGeometry.prototype.constructor = ParametricGeometry;
*/
import { BufferGeometry } from '../core/BufferGeometry';
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
function ParametricBufferGeometry( func, slices, stacks ) {
......@@ -100,7 +100,7 @@ function ParametricBufferGeometry( func, slices, stacks ) {
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -32,7 +32,7 @@ PlaneGeometry.prototype.constructor = PlaneGeometry;
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
......@@ -112,7 +112,7 @@ function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -30,7 +30,7 @@ RingGeometry.prototype.constructor = RingGeometry;
* @author Mugen87 / https://github.com/Mugen87
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { Vector2 } from '../math/Vector2';
import { Vector3 } from '../math/Vector3';
......@@ -97,7 +97,7 @@ function RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegment
normals.push( 0, 0, 1 );
// uv
uv.x = ( vertex.x / outerRadius + 1 ) / 2;
uv.y = ( vertex.y / outerRadius + 1 ) / 2;
......@@ -137,7 +137,7 @@ function RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegment
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -35,7 +35,7 @@ ShapeGeometry.prototype.constructor = ShapeGeometry;
* @author Mugen87 / https://github.com/Mugen87
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { ShapeUtils } from '../extras/ShapeUtils';
......@@ -87,7 +87,7 @@ function ShapeBufferGeometry( shapes, curveSegments ) {
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -32,7 +32,7 @@ SphereGeometry.prototype.constructor = SphereGeometry;
* @author Mugen87 / https://github.com/Mugen87
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { Vector3 } from '../math/Vector3';
......@@ -137,7 +137,7 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -31,7 +31,7 @@ TorusGeometry.prototype.constructor = TorusGeometry;
* @author Mugen87 / https://github.com/Mugen87
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { Vector3 } from '../math/Vector3';
......@@ -128,7 +128,7 @@ function TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -34,7 +34,7 @@ TorusKnotGeometry.prototype.constructor = TorusKnotGeometry;
* see: http://www.blackpawn.com/texts/pqtorus/
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { Vector3 } from '../math/Vector3';
import { Vector2 } from '../math/Vector2';
......@@ -166,7 +166,7 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -48,7 +48,7 @@ TubeGeometry.prototype.constructor = TubeGeometry;
* @author Mugen87 / https://github.com/Mugen87
*/
import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry';
import { Vector2 } from '../math/Vector2';
import { Vector3 } from '../math/Vector3';
......@@ -101,7 +101,7 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
// build geometry
this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
this.setIndexArray( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
......
......@@ -3,6 +3,7 @@
*/
import { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute';
import { _Math } from '../../math/Math';
import { WebGLGeometries } from './WebGLGeometries';
function WebGLObjects( gl, properties, info ) {
......@@ -234,7 +235,7 @@ function WebGLObjects( gl, properties, info ) {
// console.timeEnd( 'wireframe' );
var attribute = new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );
var attribute = new ( _Math.arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );
updateAttribute( attribute, gl.ELEMENT_ARRAY_BUFFER );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册