Ver código fonte

Merge pull request #19994 from DefinitelyMaybe/src/geometires--move-to-es6-classes

geometries: move to es6 classes
Mr.doob 5 anos atrás
pai
commit
b2da39b373

+ 65 - 64
src/geometries/CircleGeometry.js

@@ -6,109 +6,110 @@ import { Vector2 } from '../math/Vector2.js';
 
 // CircleGeometry
 
-function CircleGeometry( radius, segments, thetaStart, thetaLength ) {
+class CircleGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( radius, segments, thetaStart, thetaLength ) {
 
-	this.type = 'CircleGeometry';
+		super();
+		this.type = 'CircleGeometry';
 
-	this.parameters = {
-		radius: radius,
-		segments: segments,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.parameters = {
+			radius: radius,
+			segments: segments,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-	this.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );
-	this.mergeVertices();
+		this.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );
+		this.mergeVertices();
 
-}
+	}
 
-CircleGeometry.prototype = Object.create( Geometry.prototype );
-CircleGeometry.prototype.constructor = CircleGeometry;
+}
 
 // CircleBufferGeometry
 
-function CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) {
+class CircleBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( radius, segments, thetaStart, thetaLength ) {
 
-	this.type = 'CircleBufferGeometry';
+		super();
 
-	this.parameters = {
-		radius: radius,
-		segments: segments,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.type = 'CircleBufferGeometry';
 
-	radius = radius || 1;
-	segments = segments !== undefined ? Math.max( 3, segments ) : 8;
+		this.parameters = {
+			radius: radius,
+			segments: segments,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-	thetaStart = thetaStart !== undefined ? thetaStart : 0;
-	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
+		radius = radius || 1;
+		segments = segments !== undefined ? Math.max( 3, segments ) : 8;
 
-	// buffers
+		thetaStart = thetaStart !== undefined ? thetaStart : 0;
+		thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
 
-	const indices = [];
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
+		// buffers
 
-	// helper variables
+		const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
 
-	const vertex = new Vector3();
-	const uv = new Vector2();
+		// helper variables
 
-	// center point
+		const vertex = new Vector3();
+		const uv = new Vector2();
 
-	vertices.push( 0, 0, 0 );
-	normals.push( 0, 0, 1 );
-	uvs.push( 0.5, 0.5 );
+		// center point
 
-	for ( let s = 0, i = 3; s <= segments; s ++, i += 3 ) {
+		vertices.push( 0, 0, 0 );
+		normals.push( 0, 0, 1 );
+		uvs.push( 0.5, 0.5 );
 
-		const segment = thetaStart + s / segments * thetaLength;
+		for ( let s = 0, i = 3; s <= segments; s ++, i += 3 ) {
 
-		// vertex
+			const segment = thetaStart + s / segments * thetaLength;
 
-		vertex.x = radius * Math.cos( segment );
-		vertex.y = radius * Math.sin( segment );
+			// vertex
 
-		vertices.push( vertex.x, vertex.y, vertex.z );
+			vertex.x = radius * Math.cos( segment );
+			vertex.y = radius * Math.sin( segment );
 
-		// normal
+			vertices.push( vertex.x, vertex.y, vertex.z );
 
-		normals.push( 0, 0, 1 );
+			// normal
 
-		// uvs
+			normals.push( 0, 0, 1 );
 
-		uv.x = ( vertices[ i ] / radius + 1 ) / 2;
-		uv.y = ( vertices[ i + 1 ] / radius + 1 ) / 2;
+			// uvs
 
-		uvs.push( uv.x, uv.y );
+			uv.x = ( vertices[ i ] / radius + 1 ) / 2;
+			uv.y = ( vertices[ i + 1 ] / radius + 1 ) / 2;
 
-	}
+			uvs.push( uv.x, uv.y );
 
-	// indices
+		}
 
-	for ( let i = 1; i <= segments; i ++ ) {
+		// indices
 
-		indices.push( i, i + 1, 0 );
+		for ( let i = 1; i <= segments; i ++ ) {
 
-	}
+			indices.push( i, i + 1, 0 );
 
-	// build geometry
+		}
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+		// build geometry
 
-}
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-CircleBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-CircleBufferGeometry.prototype.constructor = CircleBufferGeometry;
+	}
+
+}
 
 
 export { CircleGeometry, CircleBufferGeometry };

+ 30 - 30
src/geometries/ConeGeometry.js

@@ -3,49 +3,49 @@ import { CylinderBufferGeometry } from './CylinderGeometry.js';
 
 // ConeGeometry
 
-function ConeGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
+class ConeGeometry extends CylinderGeometry {
 
-	CylinderGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );
+	constructor( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
 
-	this.type = 'ConeGeometry';
+		super( 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );
+		this.type = 'ConeGeometry';
 
-	this.parameters = {
-		radius: radius,
-		height: height,
-		radialSegments: radialSegments,
-		heightSegments: heightSegments,
-		openEnded: openEnded,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.parameters = {
+			radius: radius,
+			height: height,
+			radialSegments: radialSegments,
+			heightSegments: heightSegments,
+			openEnded: openEnded,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-}
+	}
 
-ConeGeometry.prototype = Object.create( CylinderGeometry.prototype );
-ConeGeometry.prototype.constructor = ConeGeometry;
+}
 
 // ConeBufferGeometry
 
-function ConeBufferGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
+class ConeBufferGeometry extends CylinderBufferGeometry {
 
-	CylinderBufferGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );
+	constructor( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
 
-	this.type = 'ConeBufferGeometry';
+		super( 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );
+		this.type = 'ConeBufferGeometry';
 
-	this.parameters = {
-		radius: radius,
-		height: height,
-		radialSegments: radialSegments,
-		heightSegments: heightSegments,
-		openEnded: openEnded,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.parameters = {
+			radius: radius,
+			height: height,
+			radialSegments: radialSegments,
+			heightSegments: heightSegments,
+			openEnded: openEnded,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-}
+	}
 
-ConeBufferGeometry.prototype = Object.create( CylinderBufferGeometry.prototype );
-ConeBufferGeometry.prototype.constructor = ConeBufferGeometry;
+}
 
 
 export { ConeGeometry, ConeBufferGeometry };

+ 176 - 176
src/geometries/CylinderGeometry.js

@@ -6,302 +6,302 @@ import { Vector2 } from '../math/Vector2.js';
 
 // CylinderGeometry
 
-function CylinderGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
+class CylinderGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
 
-	this.type = 'CylinderGeometry';
+		super();
+		this.type = 'CylinderGeometry';
 
-	this.parameters = {
-		radiusTop: radiusTop,
-		radiusBottom: radiusBottom,
-		height: height,
-		radialSegments: radialSegments,
-		heightSegments: heightSegments,
-		openEnded: openEnded,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.parameters = {
+			radiusTop: radiusTop,
+			radiusBottom: radiusBottom,
+			height: height,
+			radialSegments: radialSegments,
+			heightSegments: heightSegments,
+			openEnded: openEnded,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-	this.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );
-	this.mergeVertices();
+		this.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );
+		this.mergeVertices();
 
-}
+	}
 
-CylinderGeometry.prototype = Object.create( Geometry.prototype );
-CylinderGeometry.prototype.constructor = CylinderGeometry;
+}
 
 // CylinderBufferGeometry
 
-function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
+class CylinderBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
 
-	this.type = 'CylinderBufferGeometry';
+		super();
+		this.type = 'CylinderBufferGeometry';
 
-	this.parameters = {
-		radiusTop: radiusTop,
-		radiusBottom: radiusBottom,
-		height: height,
-		radialSegments: radialSegments,
-		heightSegments: heightSegments,
-		openEnded: openEnded,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.parameters = {
+			radiusTop: radiusTop,
+			radiusBottom: radiusBottom,
+			height: height,
+			radialSegments: radialSegments,
+			heightSegments: heightSegments,
+			openEnded: openEnded,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-	const scope = this;
+		const scope = this;
 
-	radiusTop = radiusTop !== undefined ? radiusTop : 1;
-	radiusBottom = radiusBottom !== undefined ? radiusBottom : 1;
-	height = height || 1;
+		radiusTop = radiusTop !== undefined ? radiusTop : 1;
+		radiusBottom = radiusBottom !== undefined ? radiusBottom : 1;
+		height = height || 1;
 
-	radialSegments = Math.floor( radialSegments ) || 8;
-	heightSegments = Math.floor( heightSegments ) || 1;
+		radialSegments = Math.floor( radialSegments ) || 8;
+		heightSegments = Math.floor( heightSegments ) || 1;
 
-	openEnded = openEnded !== undefined ? openEnded : false;
-	thetaStart = thetaStart !== undefined ? thetaStart : 0.0;
-	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
+		openEnded = openEnded !== undefined ? openEnded : false;
+		thetaStart = thetaStart !== undefined ? thetaStart : 0.0;
+		thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
 
-	// buffers
+		// buffers
 
-	const indices = [];
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
+		const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
 
-	// helper variables
+		// helper variables
 
-	let index = 0;
-	const indexArray = [];
-	const halfHeight = height / 2;
-	let groupStart = 0;
+		let index = 0;
+		const indexArray = [];
+		const halfHeight = height / 2;
+		let groupStart = 0;
 
-	// generate geometry
+		// generate geometry
 
-	generateTorso();
+		generateTorso();
 
-	if ( openEnded === false ) {
+		if ( openEnded === false ) {
 
-		if ( radiusTop > 0 ) generateCap( true );
-		if ( radiusBottom > 0 ) generateCap( false );
+			if ( radiusTop > 0 ) generateCap( true );
+			if ( radiusBottom > 0 ) generateCap( false );
 
-	}
+		}
 
-	// build geometry
+		// build geometry
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	function generateTorso() {
+		function generateTorso() {
 
-		const normal = new Vector3();
-		const vertex = new Vector3();
+			const normal = new Vector3();
+			const vertex = new Vector3();
 
-		let groupCount = 0;
+			let groupCount = 0;
 
-		// this will be used to calculate the normal
-		const slope = ( radiusBottom - radiusTop ) / height;
+			// this will be used to calculate the normal
+			const slope = ( radiusBottom - radiusTop ) / height;
 
-		// generate vertices, normals and uvs
+			// generate vertices, normals and uvs
 
-		for ( let y = 0; y <= heightSegments; y ++ ) {
+			for ( let y = 0; y <= heightSegments; y ++ ) {
 
-			const indexRow = [];
+				const indexRow = [];
 
-			const v = y / heightSegments;
+				const v = y / heightSegments;
 
-			// calculate the radius of the current row
+				// calculate the radius of the current row
 
-			const radius = v * ( radiusBottom - radiusTop ) + radiusTop;
+				const radius = v * ( radiusBottom - radiusTop ) + radiusTop;
 
-			for ( let x = 0; x <= radialSegments; x ++ ) {
+				for ( let x = 0; x <= radialSegments; x ++ ) {
 
-				const u = x / radialSegments;
+					const u = x / radialSegments;
 
-				const theta = u * thetaLength + thetaStart;
+					const theta = u * thetaLength + thetaStart;
 
-				const sinTheta = Math.sin( theta );
-				const cosTheta = Math.cos( theta );
+					const sinTheta = Math.sin( theta );
+					const cosTheta = Math.cos( theta );
 
-				// vertex
+					// vertex
 
-				vertex.x = radius * sinTheta;
-				vertex.y = - v * height + halfHeight;
-				vertex.z = radius * cosTheta;
-				vertices.push( vertex.x, vertex.y, vertex.z );
+					vertex.x = radius * sinTheta;
+					vertex.y = - v * height + halfHeight;
+					vertex.z = radius * cosTheta;
+					vertices.push( vertex.x, vertex.y, vertex.z );
 
-				// normal
+					// normal
 
-				normal.set( sinTheta, slope, cosTheta ).normalize();
-				normals.push( normal.x, normal.y, normal.z );
+					normal.set( sinTheta, slope, cosTheta ).normalize();
+					normals.push( normal.x, normal.y, normal.z );
 
-				// uv
+					// uv
 
-				uvs.push( u, 1 - v );
+					uvs.push( u, 1 - v );
 
-				// save index of vertex in respective row
+					// save index of vertex in respective row
 
-				indexRow.push( index ++ );
+					indexRow.push( index ++ );
 
-			}
+				}
 
-			// now save vertices of the row in our index array
+				// now save vertices of the row in our index array
 
-			indexArray.push( indexRow );
+				indexArray.push( indexRow );
 
-		}
+			}
+
+			// generate indices
 
-		// generate indices
+			for ( let x = 0; x < radialSegments; x ++ ) {
 
-		for ( let x = 0; x < radialSegments; x ++ ) {
+				for ( let y = 0; y < heightSegments; y ++ ) {
 
-			for ( let y = 0; y < heightSegments; y ++ ) {
+					// we use the index array to access the correct indices
 
-				// we use the index array to access the correct indices
+					const a = indexArray[ y ][ x ];
+					const b = indexArray[ y + 1 ][ x ];
+					const c = indexArray[ y + 1 ][ x + 1 ];
+					const d = indexArray[ y ][ x + 1 ];
 
-				const a = indexArray[ y ][ x ];
-				const b = indexArray[ y + 1 ][ x ];
-				const c = indexArray[ y + 1 ][ x + 1 ];
-				const d = indexArray[ y ][ x + 1 ];
+					// faces
 
-				// faces
+					indices.push( a, b, d );
+					indices.push( b, c, d );
 
-				indices.push( a, b, d );
-				indices.push( b, c, d );
+					// update group counter
 
-				// update group counter
+					groupCount += 6;
 
-				groupCount += 6;
+				}
 
 			}
 
-		}
+			// add a group to the geometry. this will ensure multi material support
 
-		// add a group to the geometry. this will ensure multi material support
+			scope.addGroup( groupStart, groupCount, 0 );
 
-		scope.addGroup( groupStart, groupCount, 0 );
+			// calculate new start value for groups
 
-		// calculate new start value for groups
+			groupStart += groupCount;
 
-		groupStart += groupCount;
+		}
 
-	}
+		function generateCap( top ) {
 
-	function generateCap( top ) {
+			// save the index of the first center vertex
+			const centerIndexStart = index;
 
-		// save the index of the first center vertex
-		const centerIndexStart = index;
+			const uv = new Vector2();
+			const vertex = new Vector3();
 
-		const uv = new Vector2();
-		const vertex = new Vector3();
+			let groupCount = 0;
 
-		let groupCount = 0;
+			const radius = ( top === true ) ? radiusTop : radiusBottom;
+			const sign = ( top === true ) ? 1 : - 1;
 
-		const radius = ( top === true ) ? radiusTop : radiusBottom;
-		const sign = ( top === true ) ? 1 : - 1;
+			// first we generate the center vertex data of the cap.
+			// because the geometry needs one set of uvs per face,
+			// we must generate a center vertex per face/segment
 
-		// first we generate the center vertex data of the cap.
-		// because the geometry needs one set of uvs per face,
-		// we must generate a center vertex per face/segment
+			for ( let x = 1; x <= radialSegments; x ++ ) {
 
-		for ( let x = 1; x <= radialSegments; x ++ ) {
+				// vertex
 
-			// vertex
+				vertices.push( 0, halfHeight * sign, 0 );
 
-			vertices.push( 0, halfHeight * sign, 0 );
+				// normal
 
-			// normal
+				normals.push( 0, sign, 0 );
 
-			normals.push( 0, sign, 0 );
+				// uv
 
-			// uv
+				uvs.push( 0.5, 0.5 );
 
-			uvs.push( 0.5, 0.5 );
+				// increase index
 
-			// increase index
+				index ++;
 
-			index ++;
+			}
 
-		}
+			// save the index of the last center vertex
+			const centerIndexEnd = index;
 
-		// save the index of the last center vertex
-		const centerIndexEnd = index;
+			// now we generate the surrounding vertices, normals and uvs
 
-		// now we generate the surrounding vertices, normals and uvs
+			for ( let x = 0; x <= radialSegments; x ++ ) {
 
-		for ( let x = 0; x <= radialSegments; x ++ ) {
+				const u = x / radialSegments;
+				const theta = u * thetaLength + thetaStart;
 
-			const u = x / radialSegments;
-			const theta = u * thetaLength + thetaStart;
+				const cosTheta = Math.cos( theta );
+				const sinTheta = Math.sin( theta );
 
-			const cosTheta = Math.cos( theta );
-			const sinTheta = Math.sin( theta );
+				// vertex
 
-			// vertex
+				vertex.x = radius * sinTheta;
+				vertex.y = halfHeight * sign;
+				vertex.z = radius * cosTheta;
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			vertex.x = radius * sinTheta;
-			vertex.y = halfHeight * sign;
-			vertex.z = radius * cosTheta;
-			vertices.push( vertex.x, vertex.y, vertex.z );
+				// normal
 
-			// normal
+				normals.push( 0, sign, 0 );
 
-			normals.push( 0, sign, 0 );
+				// uv
 
-			// uv
+				uv.x = ( cosTheta * 0.5 ) + 0.5;
+				uv.y = ( sinTheta * 0.5 * sign ) + 0.5;
+				uvs.push( uv.x, uv.y );
 
-			uv.x = ( cosTheta * 0.5 ) + 0.5;
-			uv.y = ( sinTheta * 0.5 * sign ) + 0.5;
-			uvs.push( uv.x, uv.y );
+				// increase index
 
-			// increase index
+				index ++;
 
-			index ++;
+			}
 
-		}
+			// generate indices
 
-		// generate indices
+			for ( let x = 0; x < radialSegments; x ++ ) {
 
-		for ( let x = 0; x < radialSegments; x ++ ) {
+				const c = centerIndexStart + x;
+				const i = centerIndexEnd + x;
 
-			const c = centerIndexStart + x;
-			const i = centerIndexEnd + x;
+				if ( top === true ) {
 
-			if ( top === true ) {
+					// face top
 
-				// face top
+					indices.push( i, i + 1, c );
 
-				indices.push( i, i + 1, c );
+				} else {
 
-			} else {
+					// face bottom
 
-				// face bottom
+					indices.push( i + 1, i, c );
 
-				indices.push( i + 1, i, c );
+				}
 
-			}
+				groupCount += 3;
 
-			groupCount += 3;
+			}
 
-		}
+			// add a group to the geometry. this will ensure multi material support
 
-		// add a group to the geometry. this will ensure multi material support
+			scope.addGroup( groupStart, groupCount, top === true ? 1 : 2 );
 
-		scope.addGroup( groupStart, groupCount, top === true ? 1 : 2 );
+			// calculate new start value for groups
 
-		// calculate new start value for groups
+			groupStart += groupCount;
 
-		groupStart += groupCount;
+		}
 
 	}
 
 }
 
-CylinderBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-CylinderBufferGeometry.prototype.constructor = CylinderBufferGeometry;
-
 
 export { CylinderGeometry, CylinderBufferGeometry };

+ 55 - 54
src/geometries/DodecahedronGeometry.js

@@ -3,81 +3,82 @@ import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';
 
 // DodecahedronGeometry
 
-function DodecahedronGeometry( radius, detail ) {
+class DodecahedronGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( radius, detail ) {
 
-	this.type = 'DodecahedronGeometry';
+		super();
+		this.type = 'DodecahedronGeometry';
 
-	this.parameters = {
-		radius: radius,
-		detail: detail
-	};
+		this.parameters = {
+			radius: radius,
+			detail: detail
+		};
 
-	this.fromBufferGeometry( new DodecahedronBufferGeometry( radius, detail ) );
-	this.mergeVertices();
+		this.fromBufferGeometry( new DodecahedronBufferGeometry( radius, detail ) );
+		this.mergeVertices();
 
-}
+	}
 
-DodecahedronGeometry.prototype = Object.create( Geometry.prototype );
-DodecahedronGeometry.prototype.constructor = DodecahedronGeometry;
+}
 
 // DodecahedronBufferGeometry
 
-function DodecahedronBufferGeometry( radius, detail ) {
+class DodecahedronBufferGeometry extends PolyhedronBufferGeometry {
 
-	const t = ( 1 + Math.sqrt( 5 ) ) / 2;
-	const r = 1 / t;
+	constructor( radius, detail ) {
 
-	const vertices = [
+		const t = ( 1 + Math.sqrt( 5 ) ) / 2;
+		const r = 1 / t;
 
-		// (±1, ±1, ±1)
-		- 1, - 1, - 1,	- 1, - 1, 1,
-		- 1, 1, - 1, - 1, 1, 1,
-		1, - 1, - 1, 1, - 1, 1,
-		1, 1, - 1, 1, 1, 1,
+		const vertices = [
 
-		// (0, ±1/φ, ±φ)
-		 0, - r, - t, 0, - r, t,
-		 0, r, - t, 0, r, t,
+			// (±1, ±1, ±1)
+			- 1, - 1, - 1,	- 1, - 1, 1,
+			- 1, 1, - 1, - 1, 1, 1,
+			1, - 1, - 1, 1, - 1, 1,
+			1, 1, - 1, 1, 1, 1,
 
-		// (±1/φ, ±φ, 0)
-		- r, - t, 0, - r, t, 0,
-		 r, - t, 0, r, t, 0,
+			// (0, ±1/φ, ±φ)
+			0, - r, - t, 0, - r, t,
+			0, r, - t, 0, r, t,
 
-		// (±φ, 0, ±1/φ)
-		- t, 0, - r, t, 0, - r,
-		- t, 0, r, t, 0, r
-	];
+			// (±1/φ, ±φ, 0)
+			- r, - t, 0, - r, t, 0,
+			r, - t, 0, r, t, 0,
 
-	const indices = [
-		3, 11, 7, 	3, 7, 15, 	3, 15, 13,
-		7, 19, 17, 	7, 17, 6, 	7, 6, 15,
-		17, 4, 8, 	17, 8, 10, 	17, 10, 6,
-		8, 0, 16, 	8, 16, 2, 	8, 2, 10,
-		0, 12, 1, 	0, 1, 18, 	0, 18, 16,
-		6, 10, 2, 	6, 2, 13, 	6, 13, 15,
-		2, 16, 18, 	2, 18, 3, 	2, 3, 13,
-		18, 1, 9, 	18, 9, 11, 	18, 11, 3,
-		4, 14, 12, 	4, 12, 0, 	4, 0, 8,
-		11, 9, 5, 	11, 5, 19, 	11, 19, 7,
-		19, 5, 14, 	19, 14, 4, 	19, 4, 17,
-		1, 12, 14, 	1, 14, 5, 	1, 5, 9
-	];
+			// (±φ, 0, ±1/φ)
+			- t, 0, - r, t, 0, - r,
+			- t, 0, r, t, 0, r
+		];
 
-	PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );
+		const indices = [
+			3, 11, 7, 	3, 7, 15, 	3, 15, 13,
+			7, 19, 17, 	7, 17, 6, 	7, 6, 15,
+			17, 4, 8, 	17, 8, 10, 	17, 10, 6,
+			8, 0, 16, 	8, 16, 2, 	8, 2, 10,
+			0, 12, 1, 	0, 1, 18, 	0, 18, 16,
+			6, 10, 2, 	6, 2, 13, 	6, 13, 15,
+			2, 16, 18, 	2, 18, 3, 	2, 3, 13,
+			18, 1, 9, 	18, 9, 11, 	18, 11, 3,
+			4, 14, 12, 	4, 12, 0, 	4, 0, 8,
+			11, 9, 5, 	11, 5, 19, 	11, 19, 7,
+			19, 5, 14, 	19, 14, 4, 	19, 4, 17,
+			1, 12, 14, 	1, 14, 5, 	1, 5, 9
+		];
 
-	this.type = 'DodecahedronBufferGeometry';
+		super( vertices, indices, radius, detail );
 
-	this.parameters = {
-		radius: radius,
-		detail: detail
-	};
+		this.type = 'DodecahedronBufferGeometry';
 
-}
+		this.parameters = {
+			radius: radius,
+			detail: detail
+		};
 
-DodecahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );
-DodecahedronBufferGeometry.prototype.constructor = DodecahedronBufferGeometry;
+	}
+
+}
 
 
 export { DodecahedronGeometry, DodecahedronBufferGeometry };

+ 56 - 55
src/geometries/EdgesGeometry.js

@@ -3,107 +3,108 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { Geometry } from '../core/Geometry.js';
 import { MathUtils } from '../math/MathUtils.js';
 
-function EdgesGeometry( geometry, thresholdAngle ) {
+class EdgesGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( geometry, thresholdAngle ) {
 
-	this.type = 'EdgesGeometry';
+		super();
 
-	this.parameters = {
-		thresholdAngle: thresholdAngle
-	};
+		this.type = 'EdgesGeometry';
 
-	thresholdAngle = ( thresholdAngle !== undefined ) ? thresholdAngle : 1;
+		this.parameters = {
+			thresholdAngle: thresholdAngle
+		};
 
-	// buffer
+		thresholdAngle = ( thresholdAngle !== undefined ) ? thresholdAngle : 1;
 
-	const vertices = [];
+		// buffer
 
-	// helper variables
+		const vertices = [];
 
-	const thresholdDot = Math.cos( MathUtils.DEG2RAD * thresholdAngle );
-	const edge = [ 0, 0 ], edges = {};
-	let edge1, edge2, key;
-	const keys = [ 'a', 'b', 'c' ];
+		// helper variables
 
-	// prepare source geometry
+		const thresholdDot = Math.cos( MathUtils.DEG2RAD * thresholdAngle );
+		const edge = [ 0, 0 ], edges = {};
+		let edge1, edge2, key;
+		const keys = [ 'a', 'b', 'c' ];
 
-	let geometry2;
+		// prepare source geometry
 
-	if ( geometry.isBufferGeometry ) {
+		let geometry2;
 
-		geometry2 = new Geometry();
-		geometry2.fromBufferGeometry( geometry );
+		if ( geometry.isBufferGeometry ) {
 
-	} else {
+			geometry2 = new Geometry();
+			geometry2.fromBufferGeometry( geometry );
 
-		geometry2 = geometry.clone();
+		} else {
 
-	}
+			geometry2 = geometry.clone();
+
+		}
 
-	geometry2.mergeVertices();
-	geometry2.computeFaceNormals();
+		geometry2.mergeVertices();
+		geometry2.computeFaceNormals();
 
-	const sourceVertices = geometry2.vertices;
-	const faces = geometry2.faces;
+		const sourceVertices = geometry2.vertices;
+		const faces = geometry2.faces;
 
-	// now create a data structure where each entry represents an edge with its adjoining faces
+		// now create a data structure where each entry represents an edge with its adjoining faces
 
-	for ( let i = 0, l = faces.length; i < l; i ++ ) {
+		for ( let i = 0, l = faces.length; i < l; i ++ ) {
 
-		const face = faces[ i ];
+			const face = faces[ i ];
 
-		for ( let j = 0; j < 3; j ++ ) {
+			for ( let j = 0; j < 3; j ++ ) {
 
-			edge1 = face[ keys[ j ] ];
-			edge2 = face[ keys[ ( j + 1 ) % 3 ] ];
-			edge[ 0 ] = Math.min( edge1, edge2 );
-			edge[ 1 ] = Math.max( edge1, edge2 );
+				edge1 = face[ keys[ j ] ];
+				edge2 = face[ keys[ ( j + 1 ) % 3 ] ];
+				edge[ 0 ] = Math.min( edge1, edge2 );
+				edge[ 1 ] = Math.max( edge1, edge2 );
 
-			key = edge[ 0 ] + ',' + edge[ 1 ];
+				key = edge[ 0 ] + ',' + edge[ 1 ];
 
-			if ( edges[ key ] === undefined ) {
+				if ( edges[ key ] === undefined ) {
 
-				edges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ], face1: i, face2: undefined };
+					edges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ], face1: i, face2: undefined };
 
-			} else {
+				} else {
 
-				edges[ key ].face2 = i;
+					edges[ key ].face2 = i;
+
+				}
 
 			}
 
 		}
 
-	}
+		// generate vertices
 
-	// generate vertices
+		for ( key in edges ) {
 
-	for ( key in edges ) {
+			const e = edges[ key ];
 
-		const e = edges[ key ];
+			// an edge is only rendered if the angle (in degrees) between the face normals of the adjoining faces exceeds this value. default = 1 degree.
 
-		// an edge is only rendered if the angle (in degrees) between the face normals of the adjoining faces exceeds this value. default = 1 degree.
+			if ( e.face2 === undefined || faces[ e.face1 ].normal.dot( faces[ e.face2 ].normal ) <= thresholdDot ) {
 
-		if ( e.face2 === undefined || faces[ e.face1 ].normal.dot( faces[ e.face2 ].normal ) <= thresholdDot ) {
+				let vertex = sourceVertices[ e.index1 ];
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			let vertex = sourceVertices[ e.index1 ];
-			vertices.push( vertex.x, vertex.y, vertex.z );
+				vertex = sourceVertices[ e.index2 ];
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			vertex = sourceVertices[ e.index2 ];
-			vertices.push( vertex.x, vertex.y, vertex.z );
+			}
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+	}
 
 }
 
-EdgesGeometry.prototype = Object.create( BufferGeometry.prototype );
-EdgesGeometry.prototype.constructor = EdgesGeometry;
-
 
 export { EdgesGeometry };

Diferenças do arquivo suprimidas por serem muito extensas
+ 382 - 381
src/geometries/ExtrudeGeometry.js


+ 36 - 34
src/geometries/IcosahedronGeometry.js

@@ -3,57 +3,59 @@ import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';
 
 // IcosahedronGeometry
 
-function IcosahedronGeometry( radius, detail ) {
+class IcosahedronGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( radius, detail ) {
 
-	this.type = 'IcosahedronGeometry';
+		super();
 
-	this.parameters = {
-		radius: radius,
-		detail: detail
-	};
+		this.type = 'IcosahedronGeometry';
 
-	this.fromBufferGeometry( new IcosahedronBufferGeometry( radius, detail ) );
-	this.mergeVertices();
+		this.parameters = {
+			radius: radius,
+			detail: detail
+		};
 
-}
+		this.fromBufferGeometry( new IcosahedronBufferGeometry( radius, detail ) );
+		this.mergeVertices();
+
+	}
 
-IcosahedronGeometry.prototype = Object.create( Geometry.prototype );
-IcosahedronGeometry.prototype.constructor = IcosahedronGeometry;
+}
 
 // IcosahedronBufferGeometry
 
-function IcosahedronBufferGeometry( radius, detail ) {
+class IcosahedronBufferGeometry extends PolyhedronBufferGeometry {
 
-	const t = ( 1 + Math.sqrt( 5 ) ) / 2;
+	constructor( radius, detail ) {
 
-	const vertices = [
-		- 1, t, 0, 	1, t, 0, 	- 1, - t, 0, 	1, - t, 0,
-		 0, - 1, t, 	0, 1, t,	0, - 1, - t, 	0, 1, - t,
-		 t, 0, - 1, 	t, 0, 1, 	- t, 0, - 1, 	- t, 0, 1
-	];
+		const t = ( 1 + Math.sqrt( 5 ) ) / 2;
 
-	const indices = [
-		 0, 11, 5, 	0, 5, 1, 	0, 1, 7, 	0, 7, 10, 	0, 10, 11,
-		 1, 5, 9, 	5, 11, 4,	11, 10, 2,	10, 7, 6,	7, 1, 8,
-		 3, 9, 4, 	3, 4, 2,	3, 2, 6,	3, 6, 8,	3, 8, 9,
-		 4, 9, 5, 	2, 4, 11,	6, 2, 10,	8, 6, 7,	9, 8, 1
-	];
+		const vertices = [
+			- 1, t, 0, 	1, t, 0, 	- 1, - t, 0, 	1, - t, 0,
+			0, - 1, t, 	0, 1, t,	0, - 1, - t, 	0, 1, - t,
+			t, 0, - 1, 	t, 0, 1, 	- t, 0, - 1, 	- t, 0, 1
+		];
 
-	PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );
+		const indices = [
+			0, 11, 5, 	0, 5, 1, 	0, 1, 7, 	0, 7, 10, 	0, 10, 11,
+			1, 5, 9, 	5, 11, 4,	11, 10, 2,	10, 7, 6,	7, 1, 8,
+			3, 9, 4, 	3, 4, 2,	3, 2, 6,	3, 6, 8,	3, 8, 9,
+			4, 9, 5, 	2, 4, 11,	6, 2, 10,	8, 6, 7,	9, 8, 1
+		];
 
-	this.type = 'IcosahedronBufferGeometry';
+		super( vertices, indices, radius, detail );
 
-	this.parameters = {
-		radius: radius,
-		detail: detail
-	};
+		this.type = 'IcosahedronBufferGeometry';
 
-}
+		this.parameters = {
+			radius: radius,
+			detail: detail
+		};
+
+	}
 
-IcosahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );
-IcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry;
+}
 
 
 export { IcosahedronGeometry, IcosahedronBufferGeometry };

+ 99 - 97
src/geometries/LatheGeometry.js

@@ -7,163 +7,168 @@ import { MathUtils } from '../math/MathUtils.js';
 
 // LatheGeometry
 
-function LatheGeometry( points, segments, phiStart, phiLength ) {
+class LatheGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( points, segments, phiStart, phiLength ) {
 
-	this.type = 'LatheGeometry';
+		super();
 
-	this.parameters = {
-		points: points,
-		segments: segments,
-		phiStart: phiStart,
-		phiLength: phiLength
-	};
+		this.type = 'LatheGeometry';
 
-	this.fromBufferGeometry( new LatheBufferGeometry( points, segments, phiStart, phiLength ) );
-	this.mergeVertices();
+		this.parameters = {
+			points: points,
+			segments: segments,
+			phiStart: phiStart,
+			phiLength: phiLength
+		};
 
-}
+		this.fromBufferGeometry( new LatheBufferGeometry( points, segments, phiStart, phiLength ) );
+		this.mergeVertices();
 
-LatheGeometry.prototype = Object.create( Geometry.prototype );
-LatheGeometry.prototype.constructor = LatheGeometry;
+	}
+
+}
 
 // LatheBufferGeometry
 
-function LatheBufferGeometry( points, segments, phiStart, phiLength ) {
+class LatheBufferGeometry extends BufferGeometry {
+
+	constructor( points, segments, phiStart, phiLength ) {
 
-	BufferGeometry.call( this );
+		super();
 
-	this.type = 'LatheBufferGeometry';
+		this.type = 'LatheBufferGeometry';
 
-	this.parameters = {
-		points: points,
-		segments: segments,
-		phiStart: phiStart,
-		phiLength: phiLength
-	};
+		this.parameters = {
+			points: points,
+			segments: segments,
+			phiStart: phiStart,
+			phiLength: phiLength
+		};
 
-	segments = Math.floor( segments ) || 12;
-	phiStart = phiStart || 0;
-	phiLength = phiLength || Math.PI * 2;
+		segments = Math.floor( segments ) || 12;
+		phiStart = phiStart || 0;
+		phiLength = phiLength || Math.PI * 2;
 
-	// clamp phiLength so it's in range of [ 0, 2PI ]
+		// clamp phiLength so it's in range of [ 0, 2PI ]
 
-	phiLength = MathUtils.clamp( phiLength, 0, Math.PI * 2 );
+		phiLength = MathUtils.clamp( phiLength, 0, Math.PI * 2 );
 
 
-	// buffers
+		// buffers
 
-	const indices = [];
-	const vertices = [];
-	const uvs = [];
+		const indices = [];
+		const vertices = [];
+		const uvs = [];
 
-	// helper variables
+		// helper variables
 
-	const inverseSegments = 1.0 / segments;
-	const vertex = new Vector3();
-	const uv = new Vector2();
+		const inverseSegments = 1.0 / segments;
+		const vertex = new Vector3();
+		const uv = new Vector2();
 
-	// generate vertices and uvs
+		// generate vertices and uvs
 
-	for ( let i = 0; i <= segments; i ++ ) {
+		for ( let i = 0; i <= segments; i ++ ) {
 
-		const phi = phiStart + i * inverseSegments * phiLength;
+			const phi = phiStart + i * inverseSegments * phiLength;
 
-		const sin = Math.sin( phi );
-		const cos = Math.cos( phi );
+			const sin = Math.sin( phi );
+			const cos = Math.cos( phi );
 
-		for ( let j = 0; j <= ( points.length - 1 ); j ++ ) {
+			for ( let j = 0; j <= ( points.length - 1 ); j ++ ) {
 
-			// vertex
+				// vertex
 
-			vertex.x = points[ j ].x * sin;
-			vertex.y = points[ j ].y;
-			vertex.z = points[ j ].x * cos;
+				vertex.x = points[ j ].x * sin;
+				vertex.y = points[ j ].y;
+				vertex.z = points[ j ].x * cos;
 
-			vertices.push( vertex.x, vertex.y, vertex.z );
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			// uv
+				// uv
 
-			uv.x = i / segments;
-			uv.y = j / ( points.length - 1 );
+				uv.x = i / segments;
+				uv.y = j / ( points.length - 1 );
 
-			uvs.push( uv.x, uv.y );
+				uvs.push( uv.x, uv.y );
 
 
+			}
+
 		}
 
-	}
+		// indices
 
-	// indices
+		for ( let i = 0; i < segments; i ++ ) {
 
-	for ( let i = 0; i < segments; i ++ ) {
+			for ( let j = 0; j < ( points.length - 1 ); j ++ ) {
 
-		for ( let j = 0; j < ( points.length - 1 ); j ++ ) {
+				const base = j + i * points.length;
 
-			const base = j + i * points.length;
+				const a = base;
+				const b = base + points.length;
+				const c = base + points.length + 1;
+				const d = base + 1;
 
-			const a = base;
-			const b = base + points.length;
-			const c = base + points.length + 1;
-			const d = base + 1;
+				// faces
 
-			// faces
+				indices.push( a, b, d );
+				indices.push( b, c, d );
 
-			indices.push( a, b, d );
-			indices.push( b, c, d );
+			}
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+		// generate normals
 
-	// generate normals
+		this.computeVertexNormals();
 
-	this.computeVertexNormals();
+		// if the geometry is closed, we need to average the normals along the seam.
+		// because the corresponding vertices are identical (but still have different UVs).
 
-	// if the geometry is closed, we need to average the normals along the seam.
-	// because the corresponding vertices are identical (but still have different UVs).
+		if ( phiLength === Math.PI * 2 ) {
 
-	if ( phiLength === Math.PI * 2 ) {
+			const normals = this.attributes.normal.array;
+			const n1 = new Vector3();
+			const n2 = new Vector3();
+			const n = new Vector3();
 
-		const normals = this.attributes.normal.array;
-		const n1 = new Vector3();
-		const n2 = new Vector3();
-		const n = new Vector3();
+			// this is the buffer offset for the last line of vertices
 
-		// this is the buffer offset for the last line of vertices
+			const base = segments * points.length * 3;
 
-		const base = segments * points.length * 3;
+			for ( let i = 0, j = 0; i < points.length; i ++, j += 3 ) {
 
-		for ( let i = 0, j = 0; i < points.length; i ++, j += 3 ) {
+				// select the normal of the vertex in the first line
 
-			// select the normal of the vertex in the first line
+				n1.x = normals[ j + 0 ];
+				n1.y = normals[ j + 1 ];
+				n1.z = normals[ j + 2 ];
 
-			n1.x = normals[ j + 0 ];
-			n1.y = normals[ j + 1 ];
-			n1.z = normals[ j + 2 ];
+				// select the normal of the vertex in the last line
 
-			// select the normal of the vertex in the last line
+				n2.x = normals[ base + j + 0 ];
+				n2.y = normals[ base + j + 1 ];
+				n2.z = normals[ base + j + 2 ];
 
-			n2.x = normals[ base + j + 0 ];
-			n2.y = normals[ base + j + 1 ];
-			n2.z = normals[ base + j + 2 ];
+				// average normals
 
-			// average normals
+				n.addVectors( n1, n2 ).normalize();
 
-			n.addVectors( n1, n2 ).normalize();
+				// assign the new values to both normals
 
-			// assign the new values to both normals
+				normals[ j + 0 ] = normals[ base + j + 0 ] = n.x;
+				normals[ j + 1 ] = normals[ base + j + 1 ] = n.y;
+				normals[ j + 2 ] = normals[ base + j + 2 ] = n.z;
 
-			normals[ j + 0 ] = normals[ base + j + 0 ] = n.x;
-			normals[ j + 1 ] = normals[ base + j + 1 ] = n.y;
-			normals[ j + 2 ] = normals[ base + j + 2 ] = n.z;
+			}
 
 		}
 
@@ -171,8 +176,5 @@ function LatheBufferGeometry( points, segments, phiStart, phiLength ) {
 
 }
 
-LatheBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-LatheBufferGeometry.prototype.constructor = LatheBufferGeometry;
-
 
 export { LatheGeometry, LatheBufferGeometry };

+ 33 - 31
src/geometries/OctahedronGeometry.js

@@ -3,53 +3,55 @@ import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';
 
 // OctahedronGeometry
 
-function OctahedronGeometry( radius, detail ) {
+class OctahedronGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( radius, detail ) {
 
-	this.type = 'OctahedronGeometry';
+		super();
 
-	this.parameters = {
-		radius: radius,
-		detail: detail
-	};
+		this.type = 'OctahedronGeometry';
 
-	this.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) );
-	this.mergeVertices();
+		this.parameters = {
+			radius: radius,
+			detail: detail
+		};
 
-}
+		this.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) );
+		this.mergeVertices();
+
+	}
 
-OctahedronGeometry.prototype = Object.create( Geometry.prototype );
-OctahedronGeometry.prototype.constructor = OctahedronGeometry;
+}
 
 // OctahedronBufferGeometry
 
-function OctahedronBufferGeometry( radius, detail ) {
+class OctahedronBufferGeometry extends PolyhedronBufferGeometry {
 
-	const vertices = [
-		1, 0, 0, 	- 1, 0, 0,	0, 1, 0,
-		0, - 1, 0, 	0, 0, 1,	0, 0, - 1
-	];
+	constructor( radius, detail ) {
 
-	const indices = [
-		0, 2, 4,	0, 4, 3,	0, 3, 5,
-		0, 5, 2,	1, 2, 5,	1, 5, 3,
-		1, 3, 4,	1, 4, 2
-	];
+		const vertices = [
+			1, 0, 0, 	- 1, 0, 0,	0, 1, 0,
+			0, - 1, 0, 	0, 0, 1,	0, 0, - 1
+		];
 
-	PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );
+		const indices = [
+			0, 2, 4,	0, 4, 3,	0, 3, 5,
+			0, 5, 2,	1, 2, 5,	1, 5, 3,
+			1, 3, 4,	1, 4, 2
+		];
 
-	this.type = 'OctahedronBufferGeometry';
+		super( vertices, indices, radius, detail );
 
-	this.parameters = {
-		radius: radius,
-		detail: detail
-	};
+		this.type = 'OctahedronBufferGeometry';
 
-}
+		this.parameters = {
+			radius: radius,
+			detail: detail
+		};
+
+	}
 
-OctahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );
-OctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;
+}
 
 
 export { OctahedronGeometry, OctahedronBufferGeometry };

+ 85 - 83
src/geometries/ParametricGeometry.js

@@ -10,149 +10,151 @@ import { Vector3 } from '../math/Vector3.js';
 
 // ParametricGeometry
 
-function ParametricGeometry( func, slices, stacks ) {
+class ParametricGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( func, slices, stacks ) {
 
-	this.type = 'ParametricGeometry';
+		super();
 
-	this.parameters = {
-		func: func,
-		slices: slices,
-		stacks: stacks
-	};
+		this.type = 'ParametricGeometry';
 
-	this.fromBufferGeometry( new ParametricBufferGeometry( func, slices, stacks ) );
-	this.mergeVertices();
+		this.parameters = {
+			func: func,
+			slices: slices,
+			stacks: stacks
+		};
 
-}
+		this.fromBufferGeometry( new ParametricBufferGeometry( func, slices, stacks ) );
+		this.mergeVertices();
+
+	}
 
-ParametricGeometry.prototype = Object.create( Geometry.prototype );
-ParametricGeometry.prototype.constructor = ParametricGeometry;
+}
 
 // ParametricBufferGeometry
 
-function ParametricBufferGeometry( func, slices, stacks ) {
+class ParametricBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( func, slices, stacks ) {
 
-	this.type = 'ParametricBufferGeometry';
+		super();
 
-	this.parameters = {
-		func: func,
-		slices: slices,
-		stacks: stacks
-	};
+		this.type = 'ParametricBufferGeometry';
 
-	// buffers
+		this.parameters = {
+			func: func,
+			slices: slices,
+			stacks: stacks
+		};
 
-	const indices = [];
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
+		// buffers
 
-	const EPS = 0.00001;
+		const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
 
-	const normal = new Vector3();
+		const EPS = 0.00001;
 
-	const p0 = new Vector3(), p1 = new Vector3();
-	const pu = new Vector3(), pv = new Vector3();
+		const normal = new Vector3();
 
-	if ( func.length < 3 ) {
+		const p0 = new Vector3(), p1 = new Vector3();
+		const pu = new Vector3(), pv = new Vector3();
 
-		console.error( 'THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.' );
+		if ( func.length < 3 ) {
 
-	}
+			console.error( 'THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.' );
 
-	// generate vertices, normals and uvs
+		}
 
-	const sliceCount = slices + 1;
+		// generate vertices, normals and uvs
 
-	for ( let i = 0; i <= stacks; i ++ ) {
+		const sliceCount = slices + 1;
 
-		const v = i / stacks;
+		for ( let i = 0; i <= stacks; i ++ ) {
 
-		for ( let j = 0; j <= slices; j ++ ) {
+			const v = i / stacks;
 
-			const u = j / slices;
+			for ( let j = 0; j <= slices; j ++ ) {
 
-			// vertex
+				const u = j / slices;
 
-			func( u, v, p0 );
-			vertices.push( p0.x, p0.y, p0.z );
+				// vertex
 
-			// normal
+				func( u, v, p0 );
+				vertices.push( p0.x, p0.y, p0.z );
 
-			// approximate tangent vectors via finite differences
+				// normal
 
-			if ( u - EPS >= 0 ) {
+				// approximate tangent vectors via finite differences
 
-				func( u - EPS, v, p1 );
-				pu.subVectors( p0, p1 );
+				if ( u - EPS >= 0 ) {
 
-			} else {
+					func( u - EPS, v, p1 );
+					pu.subVectors( p0, p1 );
 
-				func( u + EPS, v, p1 );
-				pu.subVectors( p1, p0 );
+				} else {
 
-			}
+					func( u + EPS, v, p1 );
+					pu.subVectors( p1, p0 );
 
-			if ( v - EPS >= 0 ) {
+				}
 
-				func( u, v - EPS, p1 );
-				pv.subVectors( p0, p1 );
+				if ( v - EPS >= 0 ) {
 
-			} else {
+					func( u, v - EPS, p1 );
+					pv.subVectors( p0, p1 );
 
-				func( u, v + EPS, p1 );
-				pv.subVectors( p1, p0 );
+				} else {
 
-			}
+					func( u, v + EPS, p1 );
+					pv.subVectors( p1, p0 );
 
-			// cross product of tangent vectors returns surface normal
+				}
 
-			normal.crossVectors( pu, pv ).normalize();
-			normals.push( normal.x, normal.y, normal.z );
+				// cross product of tangent vectors returns surface normal
 
-			// uv
+				normal.crossVectors( pu, pv ).normalize();
+				normals.push( normal.x, normal.y, normal.z );
 
-			uvs.push( u, v );
+				// uv
+
+				uvs.push( u, v );
+
+			}
 
 		}
 
-	}
+		// generate indices
 
-	// generate indices
+		for ( let i = 0; i < stacks; i ++ ) {
 
-	for ( let i = 0; i < stacks; i ++ ) {
+			for ( let j = 0; j < slices; j ++ ) {
 
-		for ( let j = 0; j < slices; j ++ ) {
+				const a = i * sliceCount + j;
+				const b = i * sliceCount + j + 1;
+				const c = ( i + 1 ) * sliceCount + j + 1;
+				const d = ( i + 1 ) * sliceCount + j;
 
-			const a = i * sliceCount + j;
-			const b = i * sliceCount + j + 1;
-			const c = ( i + 1 ) * sliceCount + j + 1;
-			const d = ( i + 1 ) * sliceCount + j;
+				// faces one and two
 
-			// faces one and two
+				indices.push( a, b, d );
+				indices.push( b, c, d );
 
-			indices.push( a, b, d );
-			indices.push( b, c, d );
+			}
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+	}
 
 }
 
-ParametricBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-ParametricBufferGeometry.prototype.constructor = ParametricBufferGeometry;
-
 
 export { ParametricGeometry, ParametricBufferGeometry };

+ 68 - 67
src/geometries/PlaneGeometry.js

@@ -4,116 +4,117 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 
 // PlaneGeometry
 
-function PlaneGeometry( width, height, widthSegments, heightSegments ) {
+class PlaneGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( width, height, widthSegments, heightSegments ) {
 
-	this.type = 'PlaneGeometry';
+		super();
 
-	this.parameters = {
-		width: width,
-		height: height,
-		widthSegments: widthSegments,
-		heightSegments: heightSegments
-	};
+		this.type = 'PlaneGeometry';
 
-	this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
-	this.mergeVertices();
+		this.parameters = {
+			width: width,
+			height: height,
+			widthSegments: widthSegments,
+			heightSegments: heightSegments
+		};
 
-}
+		this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
+		this.mergeVertices();
 
-PlaneGeometry.prototype = Object.create( Geometry.prototype );
-PlaneGeometry.prototype.constructor = PlaneGeometry;
+	}
+
+}
 
 // PlaneBufferGeometry
 
-function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
+class PlaneBufferGeometry extends BufferGeometry {
+
+	constructor( width, height, widthSegments, heightSegments ) {
 
-	BufferGeometry.call( this );
+		super();
+		this.type = 'PlaneBufferGeometry';
 
-	this.type = 'PlaneBufferGeometry';
+		this.parameters = {
+			width: width,
+			height: height,
+			widthSegments: widthSegments,
+			heightSegments: heightSegments
+		};
 
-	this.parameters = {
-		width: width,
-		height: height,
-		widthSegments: widthSegments,
-		heightSegments: heightSegments
-	};
+		width = width || 1;
+		height = height || 1;
 
-	width = width || 1;
-	height = height || 1;
+		const width_half = width / 2;
+		const height_half = height / 2;
 
-	const width_half = width / 2;
-	const height_half = height / 2;
+		const gridX = Math.floor( widthSegments ) || 1;
+		const gridY = Math.floor( heightSegments ) || 1;
 
-	const gridX = Math.floor( widthSegments ) || 1;
-	const gridY = Math.floor( heightSegments ) || 1;
+		const gridX1 = gridX + 1;
+		const gridY1 = gridY + 1;
 
-	const gridX1 = gridX + 1;
-	const gridY1 = gridY + 1;
+		const segment_width = width / gridX;
+		const segment_height = height / gridY;
 
-	const segment_width = width / gridX;
-	const segment_height = height / gridY;
+		// buffers
 
-	// buffers
+		const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
 
-	const indices = [];
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
+		// generate vertices, normals and uvs
 
-	// generate vertices, normals and uvs
+		for ( let iy = 0; iy < gridY1; iy ++ ) {
 
-	for ( let iy = 0; iy < gridY1; iy ++ ) {
+			const y = iy * segment_height - height_half;
 
-		const y = iy * segment_height - height_half;
+			for ( let ix = 0; ix < gridX1; ix ++ ) {
 
-		for ( let ix = 0; ix < gridX1; ix ++ ) {
+				const x = ix * segment_width - width_half;
 
-			const x = ix * segment_width - width_half;
+				vertices.push( x, - y, 0 );
 
-			vertices.push( x, - y, 0 );
+				normals.push( 0, 0, 1 );
 
-			normals.push( 0, 0, 1 );
+				uvs.push( ix / gridX );
+				uvs.push( 1 - ( iy / gridY ) );
 
-			uvs.push( ix / gridX );
-			uvs.push( 1 - ( iy / gridY ) );
+			}
 
 		}
 
-	}
+		// indices
 
-	// indices
+		for ( let iy = 0; iy < gridY; iy ++ ) {
 
-	for ( let iy = 0; iy < gridY; iy ++ ) {
+			for ( let ix = 0; ix < gridX; ix ++ ) {
 
-		for ( let ix = 0; ix < gridX; ix ++ ) {
+				const a = ix + gridX1 * iy;
+				const b = ix + gridX1 * ( iy + 1 );
+				const c = ( ix + 1 ) + gridX1 * ( iy + 1 );
+				const d = ( ix + 1 ) + gridX1 * iy;
 
-			const a = ix + gridX1 * iy;
-			const b = ix + gridX1 * ( iy + 1 );
-			const c = ( ix + 1 ) + gridX1 * ( iy + 1 );
-			const d = ( ix + 1 ) + gridX1 * iy;
+				// faces
 
-			// faces
+				indices.push( a, b, d );
+				indices.push( b, c, d );
 
-			indices.push( a, b, d );
-			indices.push( b, c, d );
+			}
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+	}
 
 }
 
-PlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-PlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;
-
 
 export { PlaneGeometry, PlaneBufferGeometry };

+ 175 - 173
src/geometries/PolyhedronGeometry.js

@@ -6,158 +6,163 @@ import { Vector2 } from '../math/Vector2.js';
 
 // PolyhedronGeometry
 
-function PolyhedronGeometry( vertices, indices, radius, detail ) {
+class PolyhedronGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( vertices, indices, radius, detail ) {
 
-	this.type = 'PolyhedronGeometry';
+		super();
 
-	this.parameters = {
-		vertices: vertices,
-		indices: indices,
-		radius: radius,
-		detail: detail
-	};
+		this.type = 'PolyhedronGeometry';
 
-	this.fromBufferGeometry( new PolyhedronBufferGeometry( vertices, indices, radius, detail ) );
-	this.mergeVertices();
+		this.parameters = {
+			vertices: vertices,
+			indices: indices,
+			radius: radius,
+			detail: detail
+		};
 
-}
+		this.fromBufferGeometry( new PolyhedronBufferGeometry( vertices, indices, radius, detail ) );
+		this.mergeVertices();
 
-PolyhedronGeometry.prototype = Object.create( Geometry.prototype );
-PolyhedronGeometry.prototype.constructor = PolyhedronGeometry;
+	}
+
+}
 
 // PolyhedronBufferGeometry
 
-function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
+class PolyhedronBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( vertices, indices, radius, detail ) {
 
-	this.type = 'PolyhedronBufferGeometry';
+		super();
 
-	this.parameters = {
-		vertices: vertices,
-		indices: indices,
-		radius: radius,
-		detail: detail
-	};
+		this.type = 'PolyhedronBufferGeometry';
 
-	radius = radius || 1;
-	detail = detail || 0;
+		this.parameters = {
+			vertices: vertices,
+			indices: indices,
+			radius: radius,
+			detail: detail
+		};
 
-	// default buffer data
+		radius = radius || 1;
+		detail = detail || 0;
 
-	const vertexBuffer = [];
-	const uvBuffer = [];
+		// default buffer data
 
-	// the subdivision creates the vertex buffer data
+		const vertexBuffer = [];
+		const uvBuffer = [];
 
-	subdivide( detail );
+		// the subdivision creates the vertex buffer data
 
-	// all vertices should lie on a conceptual sphere with a given radius
+		subdivide( detail );
 
-	applyRadius( radius );
+		// all vertices should lie on a conceptual sphere with a given radius
 
-	// finally, create the uv data
+		applyRadius( radius );
 
-	generateUVs();
+		// finally, create the uv data
 
-	// build non-indexed geometry
+		generateUVs();
 
-	this.setAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) );
+		// build non-indexed geometry
 
-	if ( detail === 0 ) {
+		this.setAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) );
 
-		this.computeVertexNormals(); // flat normals
+		if ( detail === 0 ) {
 
-	} else {
+			this.computeVertexNormals(); // flat normals
 
-		this.normalizeNormals(); // smooth normals
+		} else {
 
-	}
+			this.normalizeNormals(); // smooth normals
 
-	// helper functions
+		}
+
+		// helper functions
 
-	function subdivide( detail ) {
+		function subdivide( detail ) {
 
-		const a = new Vector3();
-		const b = new Vector3();
-		const c = new Vector3();
+			const a = new Vector3();
+			const b = new Vector3();
+			const c = new Vector3();
 
-		// iterate over all faces and apply a subdivison with the given detail value
+			// iterate over all faces and apply a subdivison with the given detail value
 
-		for ( let i = 0; i < indices.length; i += 3 ) {
+			for ( let i = 0; i < indices.length; i += 3 ) {
 
-			// get the vertices of the face
+				// get the vertices of the face
 
-			getVertexByIndex( indices[ i + 0 ], a );
-			getVertexByIndex( indices[ i + 1 ], b );
-			getVertexByIndex( indices[ i + 2 ], c );
+				getVertexByIndex( indices[ i + 0 ], a );
+				getVertexByIndex( indices[ i + 1 ], b );
+				getVertexByIndex( indices[ i + 2 ], c );
 
-			// perform subdivision
+				// perform subdivision
 
-			subdivideFace( a, b, c, detail );
+				subdivideFace( a, b, c, detail );
+
+			}
 
 		}
 
-	}
+		function subdivideFace( a, b, c, detail ) {
 
-	function subdivideFace( a, b, c, detail ) {
+			const cols = Math.pow( 2, detail );
 
-		const cols = Math.pow( 2, detail );
+			// we use this multidimensional array as a data structure for creating the subdivision
 
-		// we use this multidimensional array as a data structure for creating the subdivision
+			const v = [];
 
-		const v = [];
+			// construct all of the vertices for this subdivision
 
-		// construct all of the vertices for this subdivision
+			for ( let i = 0; i <= cols; i ++ ) {
 
-		for ( let i = 0; i <= cols; i ++ ) {
+				v[ i ] = [];
 
-			v[ i ] = [];
+				const aj = a.clone().lerp( c, i / cols );
+				const bj = b.clone().lerp( c, i / cols );
 
-			const aj = a.clone().lerp( c, i / cols );
-			const bj = b.clone().lerp( c, i / cols );
+				const rows = cols - i;
 
-			const rows = cols - i;
+				for ( let j = 0; j <= rows; j ++ ) {
 
-			for ( let j = 0; j <= rows; j ++ ) {
+					if ( j === 0 && i === cols ) {
 
-				if ( j === 0 && i === cols ) {
+						v[ i ][ j ] = aj;
 
-					v[ i ][ j ] = aj;
+					} else {
 
-				} else {
+						v[ i ][ j ] = aj.clone().lerp( bj, j / rows );
 
-					v[ i ][ j ] = aj.clone().lerp( bj, j / rows );
+					}
 
 				}
 
 			}
 
-		}
+			// construct all of the faces
 
-		// construct all of the faces
+			for ( let i = 0; i < cols; i ++ ) {
 
-		for ( let i = 0; i < cols; i ++ ) {
+				for ( let j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {
 
-			for ( let j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {
+					const k = Math.floor( j / 2 );
 
-				const k = Math.floor( j / 2 );
+					if ( j % 2 === 0 ) {
 
-				if ( j % 2 === 0 ) {
+						pushVertex( v[ i ][ k + 1 ] );
+						pushVertex( v[ i + 1 ][ k ] );
+						pushVertex( v[ i ][ k ] );
 
-					pushVertex( v[ i ][ k + 1 ] );
-					pushVertex( v[ i + 1 ][ k ] );
-					pushVertex( v[ i ][ k ] );
+					} else {
 
-				} else {
+						pushVertex( v[ i ][ k + 1 ] );
+						pushVertex( v[ i + 1 ][ k + 1 ] );
+						pushVertex( v[ i + 1 ][ k ] );
 
-					pushVertex( v[ i ][ k + 1 ] );
-					pushVertex( v[ i + 1 ][ k + 1 ] );
-					pushVertex( v[ i + 1 ][ k ] );
+					}
 
 				}
 
@@ -165,168 +170,165 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 		}
 
-	}
+		function applyRadius( radius ) {
 
-	function applyRadius( radius ) {
+			const vertex = new Vector3();
 
-		const vertex = new Vector3();
+			// iterate over the entire buffer and apply the radius to each vertex
 
-		// iterate over the entire buffer and apply the radius to each vertex
+			for ( let i = 0; i < vertexBuffer.length; i += 3 ) {
 
-		for ( let i = 0; i < vertexBuffer.length; i += 3 ) {
+				vertex.x = vertexBuffer[ i + 0 ];
+				vertex.y = vertexBuffer[ i + 1 ];
+				vertex.z = vertexBuffer[ i + 2 ];
 
-			vertex.x = vertexBuffer[ i + 0 ];
-			vertex.y = vertexBuffer[ i + 1 ];
-			vertex.z = vertexBuffer[ i + 2 ];
+				vertex.normalize().multiplyScalar( radius );
 
-			vertex.normalize().multiplyScalar( radius );
+				vertexBuffer[ i + 0 ] = vertex.x;
+				vertexBuffer[ i + 1 ] = vertex.y;
+				vertexBuffer[ i + 2 ] = vertex.z;
 
-			vertexBuffer[ i + 0 ] = vertex.x;
-			vertexBuffer[ i + 1 ] = vertex.y;
-			vertexBuffer[ i + 2 ] = vertex.z;
+			}
 
 		}
 
-	}
+		function generateUVs() {
 
-	function generateUVs() {
+			const vertex = new Vector3();
 
-		const vertex = new Vector3();
+			for ( let i = 0; i < vertexBuffer.length; i += 3 ) {
 
-		for ( let i = 0; i < vertexBuffer.length; i += 3 ) {
+				vertex.x = vertexBuffer[ i + 0 ];
+				vertex.y = vertexBuffer[ i + 1 ];
+				vertex.z = vertexBuffer[ i + 2 ];
 
-			vertex.x = vertexBuffer[ i + 0 ];
-			vertex.y = vertexBuffer[ i + 1 ];
-			vertex.z = vertexBuffer[ i + 2 ];
+				const u = azimuth( vertex ) / 2 / Math.PI + 0.5;
+				const v = inclination( vertex ) / Math.PI + 0.5;
+				uvBuffer.push( u, 1 - v );
 
-			const u = azimuth( vertex ) / 2 / Math.PI + 0.5;
-			const v = inclination( vertex ) / Math.PI + 0.5;
-			uvBuffer.push( u, 1 - v );
+			}
 
-		}
+			correctUVs();
 
-		correctUVs();
+			correctSeam();
 
-		correctSeam();
+		}
 
-	}
+		function correctSeam() {
 
-	function correctSeam() {
+			// handle case when face straddles the seam, see #3269
 
-		// handle case when face straddles the seam, see #3269
+			for ( let i = 0; i < uvBuffer.length; i += 6 ) {
 
-		for ( let i = 0; i < uvBuffer.length; i += 6 ) {
+				// uv data of a single face
 
-			// uv data of a single face
+				const x0 = uvBuffer[ i + 0 ];
+				const x1 = uvBuffer[ i + 2 ];
+				const x2 = uvBuffer[ i + 4 ];
 
-			const x0 = uvBuffer[ i + 0 ];
-			const x1 = uvBuffer[ i + 2 ];
-			const x2 = uvBuffer[ i + 4 ];
+				const max = Math.max( x0, x1, x2 );
+				const min = Math.min( x0, x1, x2 );
 
-			const max = Math.max( x0, x1, x2 );
-			const min = Math.min( x0, x1, x2 );
+				// 0.9 is somewhat arbitrary
 
-			// 0.9 is somewhat arbitrary
+				if ( max > 0.9 && min < 0.1 ) {
 
-			if ( max > 0.9 && min < 0.1 ) {
+					if ( x0 < 0.2 ) uvBuffer[ i + 0 ] += 1;
+					if ( x1 < 0.2 ) uvBuffer[ i + 2 ] += 1;
+					if ( x2 < 0.2 ) uvBuffer[ i + 4 ] += 1;
 
-				if ( x0 < 0.2 ) uvBuffer[ i + 0 ] += 1;
-				if ( x1 < 0.2 ) uvBuffer[ i + 2 ] += 1;
-				if ( x2 < 0.2 ) uvBuffer[ i + 4 ] += 1;
+				}
 
 			}
 
 		}
 
-	}
+		function pushVertex( vertex ) {
 
-	function pushVertex( vertex ) {
+			vertexBuffer.push( vertex.x, vertex.y, vertex.z );
 
-		vertexBuffer.push( vertex.x, vertex.y, vertex.z );
+		}
 
-	}
+		function getVertexByIndex( index, vertex ) {
 
-	function getVertexByIndex( index, vertex ) {
+			const stride = index * 3;
 
-		const stride = index * 3;
+			vertex.x = vertices[ stride + 0 ];
+			vertex.y = vertices[ stride + 1 ];
+			vertex.z = vertices[ stride + 2 ];
 
-		vertex.x = vertices[ stride + 0 ];
-		vertex.y = vertices[ stride + 1 ];
-		vertex.z = vertices[ stride + 2 ];
+		}
 
-	}
+		function correctUVs() {
 
-	function correctUVs() {
+			const a = new Vector3();
+			const b = new Vector3();
+			const c = new Vector3();
 
-		const a = new Vector3();
-		const b = new Vector3();
-		const c = new Vector3();
+			const centroid = new Vector3();
 
-		const centroid = new Vector3();
+			const uvA = new Vector2();
+			const uvB = new Vector2();
+			const uvC = new Vector2();
 
-		const uvA = new Vector2();
-		const uvB = new Vector2();
-		const uvC = new Vector2();
+			for ( let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) {
 
-		for ( let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) {
+				a.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] );
+				b.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] );
+				c.set( vertexBuffer[ i + 6 ], vertexBuffer[ i + 7 ], vertexBuffer[ i + 8 ] );
 
-			a.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] );
-			b.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] );
-			c.set( vertexBuffer[ i + 6 ], vertexBuffer[ i + 7 ], vertexBuffer[ i + 8 ] );
+				uvA.set( uvBuffer[ j + 0 ], uvBuffer[ j + 1 ] );
+				uvB.set( uvBuffer[ j + 2 ], uvBuffer[ j + 3 ] );
+				uvC.set( uvBuffer[ j + 4 ], uvBuffer[ j + 5 ] );
 
-			uvA.set( uvBuffer[ j + 0 ], uvBuffer[ j + 1 ] );
-			uvB.set( uvBuffer[ j + 2 ], uvBuffer[ j + 3 ] );
-			uvC.set( uvBuffer[ j + 4 ], uvBuffer[ j + 5 ] );
+				centroid.copy( a ).add( b ).add( c ).divideScalar( 3 );
 
-			centroid.copy( a ).add( b ).add( c ).divideScalar( 3 );
+				const azi = azimuth( centroid );
 
-			const azi = azimuth( centroid );
+				correctUV( uvA, j + 0, a, azi );
+				correctUV( uvB, j + 2, b, azi );
+				correctUV( uvC, j + 4, c, azi );
 
-			correctUV( uvA, j + 0, a, azi );
-			correctUV( uvB, j + 2, b, azi );
-			correctUV( uvC, j + 4, c, azi );
+			}
 
 		}
 
-	}
+		function correctUV( uv, stride, vector, azimuth ) {
 
-	function correctUV( uv, stride, vector, azimuth ) {
+			if ( ( azimuth < 0 ) && ( uv.x === 1 ) ) {
 
-		if ( ( azimuth < 0 ) && ( uv.x === 1 ) ) {
+				uvBuffer[ stride ] = uv.x - 1;
 
-			uvBuffer[ stride ] = uv.x - 1;
+			}
 
-		}
+			if ( ( vector.x === 0 ) && ( vector.z === 0 ) ) {
 
-		if ( ( vector.x === 0 ) && ( vector.z === 0 ) ) {
+				uvBuffer[ stride ] = azimuth / 2 / Math.PI + 0.5;
 
-			uvBuffer[ stride ] = azimuth / 2 / Math.PI + 0.5;
+			}
 
 		}
 
-	}
+		// Angle around the Y axis, counter-clockwise when looking from above.
 
-	// Angle around the Y axis, counter-clockwise when looking from above.
+		function azimuth( vector ) {
 
-	function azimuth( vector ) {
+			return Math.atan2( vector.z, - vector.x );
 
-		return Math.atan2( vector.z, - vector.x );
+		}
 
-	}
 
+		// Angle above the XZ plane.
 
-	// Angle above the XZ plane.
+		function inclination( vector ) {
 
-	function inclination( vector ) {
+			return Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) );
 
-		return Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) );
+		}
 
 	}
 
 }
 
-PolyhedronBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-PolyhedronBufferGeometry.prototype.constructor = PolyhedronBufferGeometry;
-
 
 export { PolyhedronGeometry, PolyhedronBufferGeometry };

+ 85 - 83
src/geometries/RingGeometry.js

@@ -6,140 +6,142 @@ import { Vector3 } from '../math/Vector3.js';
 
 // RingGeometry
 
-function RingGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {
+class RingGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {
 
-	this.type = 'RingGeometry';
+		super();
 
-	this.parameters = {
-		innerRadius: innerRadius,
-		outerRadius: outerRadius,
-		thetaSegments: thetaSegments,
-		phiSegments: phiSegments,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.type = 'RingGeometry';
 
-	this.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) );
-	this.mergeVertices();
+		this.parameters = {
+			innerRadius: innerRadius,
+			outerRadius: outerRadius,
+			thetaSegments: thetaSegments,
+			phiSegments: phiSegments,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-}
+		this.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) );
+		this.mergeVertices();
+
+	}
 
-RingGeometry.prototype = Object.create( Geometry.prototype );
-RingGeometry.prototype.constructor = RingGeometry;
+}
 
 // RingBufferGeometry
 
-function RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {
+class RingBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {
 
-	this.type = 'RingBufferGeometry';
+		super();
 
-	this.parameters = {
-		innerRadius: innerRadius,
-		outerRadius: outerRadius,
-		thetaSegments: thetaSegments,
-		phiSegments: phiSegments,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.type = 'RingBufferGeometry';
 
-	innerRadius = innerRadius || 0.5;
-	outerRadius = outerRadius || 1;
+		this.parameters = {
+			innerRadius: innerRadius,
+			outerRadius: outerRadius,
+			thetaSegments: thetaSegments,
+			phiSegments: phiSegments,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-	thetaStart = thetaStart !== undefined ? thetaStart : 0;
-	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
+		innerRadius = innerRadius || 0.5;
+		outerRadius = outerRadius || 1;
 
-	thetaSegments = thetaSegments !== undefined ? Math.max( 3, thetaSegments ) : 8;
-	phiSegments = phiSegments !== undefined ? Math.max( 1, phiSegments ) : 1;
+		thetaStart = thetaStart !== undefined ? thetaStart : 0;
+		thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
 
-	// buffers
+		thetaSegments = thetaSegments !== undefined ? Math.max( 3, thetaSegments ) : 8;
+		phiSegments = phiSegments !== undefined ? Math.max( 1, phiSegments ) : 1;
 
-	const indices = [];
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
+		// buffers
 
-	// some helper variables
+		const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
 
-	let radius = innerRadius;
-	const radiusStep = ( ( outerRadius - innerRadius ) / phiSegments );
-	const vertex = new Vector3();
-	const uv = new Vector2();
+		// some helper variables
 
-	// generate vertices, normals and uvs
+		let radius = innerRadius;
+		const radiusStep = ( ( outerRadius - innerRadius ) / phiSegments );
+		const vertex = new Vector3();
+		const uv = new Vector2();
 
-	for ( let j = 0; j <= phiSegments; j ++ ) {
+		// generate vertices, normals and uvs
 
-		for ( let i = 0; i <= thetaSegments; i ++ ) {
+		for ( let j = 0; j <= phiSegments; j ++ ) {
 
-			// values are generate from the inside of the ring to the outside
+			for ( let i = 0; i <= thetaSegments; i ++ ) {
 
-			const segment = thetaStart + i / thetaSegments * thetaLength;
+				// values are generate from the inside of the ring to the outside
 
-			// vertex
+				const segment = thetaStart + i / thetaSegments * thetaLength;
 
-			vertex.x = radius * Math.cos( segment );
-			vertex.y = radius * Math.sin( segment );
+				// vertex
 
-			vertices.push( vertex.x, vertex.y, vertex.z );
+				vertex.x = radius * Math.cos( segment );
+				vertex.y = radius * Math.sin( segment );
 
-			// normal
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			normals.push( 0, 0, 1 );
+				// normal
 
-			// uv
+				normals.push( 0, 0, 1 );
 
-			uv.x = ( vertex.x / outerRadius + 1 ) / 2;
-			uv.y = ( vertex.y / outerRadius + 1 ) / 2;
+				// uv
 
-			uvs.push( uv.x, uv.y );
+				uv.x = ( vertex.x / outerRadius + 1 ) / 2;
+				uv.y = ( vertex.y / outerRadius + 1 ) / 2;
 
-		}
+				uvs.push( uv.x, uv.y );
 
-		// increase the radius for next row of vertices
+			}
 
-		radius += radiusStep;
+			// increase the radius for next row of vertices
 
-	}
+			radius += radiusStep;
 
-	// indices
+		}
+
+		// indices
+
+		for ( let j = 0; j < phiSegments; j ++ ) {
 
-	for ( let j = 0; j < phiSegments; j ++ ) {
+			const thetaSegmentLevel = j * ( thetaSegments + 1 );
 
-		const thetaSegmentLevel = j * ( thetaSegments + 1 );
+			for ( let i = 0; i < thetaSegments; i ++ ) {
 
-		for ( let i = 0; i < thetaSegments; i ++ ) {
+				const segment = i + thetaSegmentLevel;
 
-			const segment = i + thetaSegmentLevel;
+				const a = segment;
+				const b = segment + thetaSegments + 1;
+				const c = segment + thetaSegments + 2;
+				const d = segment + 1;
 
-			const a = segment;
-			const b = segment + thetaSegments + 1;
-			const c = segment + thetaSegments + 2;
-			const d = segment + 1;
+				// faces
 
-			// faces
+				indices.push( a, b, d );
+				indices.push( b, c, d );
 
-			indices.push( a, b, d );
-			indices.push( b, c, d );
+			}
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+	}
 
 }
 
-RingBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-RingBufferGeometry.prototype.constructor = RingBufferGeometry;
-
 
 export { RingGeometry, RingBufferGeometry };

+ 97 - 97
src/geometries/ShapeGeometry.js

@@ -5,183 +5,183 @@ import { ShapeUtils } from '../extras/ShapeUtils.js';
 
 // ShapeGeometry
 
-function ShapeGeometry( shapes, curveSegments ) {
+class ShapeGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( shapes, curveSegments ) {
 
-	this.type = 'ShapeGeometry';
+		super();
+		this.type = 'ShapeGeometry';
 
-	if ( typeof curveSegments === 'object' ) {
+		if ( typeof curveSegments === 'object' ) {
 
-		console.warn( 'THREE.ShapeGeometry: Options parameter has been removed.' );
+			console.warn( 'THREE.ShapeGeometry: Options parameter has been removed.' );
 
-		curveSegments = curveSegments.curveSegments;
+			curveSegments = curveSegments.curveSegments;
 
-	}
+		}
 
-	this.parameters = {
-		shapes: shapes,
-		curveSegments: curveSegments
-	};
+		this.parameters = {
+			shapes: shapes,
+			curveSegments: curveSegments
+		};
 
-	this.fromBufferGeometry( new ShapeBufferGeometry( shapes, curveSegments ) );
-	this.mergeVertices();
+		this.fromBufferGeometry( new ShapeBufferGeometry( shapes, curveSegments ) );
+		this.mergeVertices();
 
-}
+	}
 
-ShapeGeometry.prototype = Object.create( Geometry.prototype );
-ShapeGeometry.prototype.constructor = ShapeGeometry;
+	toJSON() {
 
-ShapeGeometry.prototype.toJSON = function () {
+		const data = Geometry.prototype.toJSON.call( this );
 
-	const data = Geometry.prototype.toJSON.call( this );
+		const shapes = this.parameters.shapes;
 
-	const shapes = this.parameters.shapes;
+		return toJSON( shapes, data );
 
-	return toJSON( shapes, data );
+	}
 
-};
+}
 
 // ShapeBufferGeometry
 
-function ShapeBufferGeometry( shapes, curveSegments ) {
+class ShapeBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( shapes, curveSegments ) {
 
-	this.type = 'ShapeBufferGeometry';
+		super();
+		this.type = 'ShapeBufferGeometry';
 
-	this.parameters = {
-		shapes: shapes,
-		curveSegments: curveSegments
-	};
+		this.parameters = {
+			shapes: shapes,
+			curveSegments: curveSegments
+		};
 
-	curveSegments = curveSegments || 12;
+		curveSegments = curveSegments || 12;
 
-	// buffers
+		// buffers
 
-	const indices = [];
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
+		const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
 
-	// helper variables
+		// helper variables
 
-	let groupStart = 0;
-	let groupCount = 0;
+		let groupStart = 0;
+		let groupCount = 0;
 
-	// allow single and array values for "shapes" parameter
+		// allow single and array values for "shapes" parameter
 
-	if ( Array.isArray( shapes ) === false ) {
+		if ( Array.isArray( shapes ) === false ) {
 
-		addShape( shapes );
+			addShape( shapes );
 
-	} else {
+		} else {
+
+			for ( let i = 0; i < shapes.length; i ++ ) {
 
-		for ( let i = 0; i < shapes.length; i ++ ) {
+				addShape( shapes[ i ] );
 
-			addShape( shapes[ i ] );
+				this.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support
 
-			this.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support
+				groupStart += groupCount;
+				groupCount = 0;
 
-			groupStart += groupCount;
-			groupCount = 0;
+			}
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
+		// helper functions
 
-	// helper functions
+		function addShape( shape ) {
 
-	function addShape( shape ) {
+			const indexOffset = vertices.length / 3;
+			const points = shape.extractPoints( curveSegments );
 
-		const indexOffset = vertices.length / 3;
-		const points = shape.extractPoints( curveSegments );
+			let shapeVertices = points.shape;
+			const shapeHoles = points.holes;
 
-		let shapeVertices = points.shape;
-		const shapeHoles = points.holes;
+			// check direction of vertices
 
-		// check direction of vertices
+			if ( ShapeUtils.isClockWise( shapeVertices ) === false ) {
 
-		if ( ShapeUtils.isClockWise( shapeVertices ) === false ) {
+				shapeVertices = shapeVertices.reverse();
 
-			shapeVertices = shapeVertices.reverse();
+			}
 
-		}
+			for ( let i = 0, l = shapeHoles.length; i < l; i ++ ) {
 
-		for ( let i = 0, l = shapeHoles.length; i < l; i ++ ) {
+				const shapeHole = shapeHoles[ i ];
 
-			const shapeHole = shapeHoles[ i ];
+				if ( ShapeUtils.isClockWise( shapeHole ) === true ) {
 
-			if ( ShapeUtils.isClockWise( shapeHole ) === true ) {
+					shapeHoles[ i ] = shapeHole.reverse();
 
-				shapeHoles[ i ] = shapeHole.reverse();
+				}
 
 			}
 
-		}
+			const faces = ShapeUtils.triangulateShape( shapeVertices, shapeHoles );
 
-		const faces = ShapeUtils.triangulateShape( shapeVertices, shapeHoles );
+			// join vertices of inner and outer paths to a single array
 
-		// join vertices of inner and outer paths to a single array
+			for ( let i = 0, l = shapeHoles.length; i < l; i ++ ) {
 
-		for ( let i = 0, l = shapeHoles.length; i < l; i ++ ) {
+				const shapeHole = shapeHoles[ i ];
+				shapeVertices = shapeVertices.concat( shapeHole );
 
-			const shapeHole = shapeHoles[ i ];
-			shapeVertices = shapeVertices.concat( shapeHole );
+			}
 
-		}
+			// vertices, normals, uvs
 
-		// vertices, normals, uvs
+			for ( let i = 0, l = shapeVertices.length; i < l; i ++ ) {
 
-		for ( let i = 0, l = shapeVertices.length; i < l; i ++ ) {
+				const vertex = shapeVertices[ i ];
 
-			const vertex = shapeVertices[ i ];
+				vertices.push( vertex.x, vertex.y, 0 );
+				normals.push( 0, 0, 1 );
+				uvs.push( vertex.x, vertex.y ); // world uvs
 
-			vertices.push( vertex.x, vertex.y, 0 );
-			normals.push( 0, 0, 1 );
-			uvs.push( vertex.x, vertex.y ); // world uvs
+			}
 
-		}
+			// incides
 
-		// incides
+			for ( let i = 0, l = faces.length; i < l; i ++ ) {
 
-		for ( let i = 0, l = faces.length; i < l; i ++ ) {
+				const face = faces[ i ];
 
-			const face = faces[ i ];
+				const a = face[ 0 ] + indexOffset;
+				const b = face[ 1 ] + indexOffset;
+				const c = face[ 2 ] + indexOffset;
 
-			const a = face[ 0 ] + indexOffset;
-			const b = face[ 1 ] + indexOffset;
-			const c = face[ 2 ] + indexOffset;
+				indices.push( a, b, c );
+				groupCount += 3;
 
-			indices.push( a, b, c );
-			groupCount += 3;
+			}
 
 		}
 
 	}
 
-}
-
-ShapeBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-ShapeBufferGeometry.prototype.constructor = ShapeBufferGeometry;
+	toJSON() {
 
-ShapeBufferGeometry.prototype.toJSON = function () {
+		const data = BufferGeometry.prototype.toJSON.call( this );
 
-	const data = BufferGeometry.prototype.toJSON.call( this );
+		const shapes = this.parameters.shapes;
 
-	const shapes = this.parameters.shapes;
+		return toJSON( shapes, data );
 
-	return toJSON( shapes, data );
+	}
 
-};
+}
 
 //
 

+ 91 - 91
src/geometries/SphereGeometry.js

@@ -5,154 +5,154 @@ import { Vector3 } from '../math/Vector3.js';
 
 // SphereGeometry
 
-function SphereGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
+class SphereGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
 
-	this.type = 'SphereGeometry';
+		super();
+		this.type = 'SphereGeometry';
 
-	this.parameters = {
-		radius: radius,
-		widthSegments: widthSegments,
-		heightSegments: heightSegments,
-		phiStart: phiStart,
-		phiLength: phiLength,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.parameters = {
+			radius: radius,
+			widthSegments: widthSegments,
+			heightSegments: heightSegments,
+			phiStart: phiStart,
+			phiLength: phiLength,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-	this.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) );
-	this.mergeVertices();
+		this.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) );
+		this.mergeVertices();
 
-}
+	}
 
-SphereGeometry.prototype = Object.create( Geometry.prototype );
-SphereGeometry.prototype.constructor = SphereGeometry;
+}
 
 // SphereBufferGeometry
 
-function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
+class SphereBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
 
-	this.type = 'SphereBufferGeometry';
+		super();
+		this.type = 'SphereBufferGeometry';
 
-	this.parameters = {
-		radius: radius,
-		widthSegments: widthSegments,
-		heightSegments: heightSegments,
-		phiStart: phiStart,
-		phiLength: phiLength,
-		thetaStart: thetaStart,
-		thetaLength: thetaLength
-	};
+		this.parameters = {
+			radius: radius,
+			widthSegments: widthSegments,
+			heightSegments: heightSegments,
+			phiStart: phiStart,
+			phiLength: phiLength,
+			thetaStart: thetaStart,
+			thetaLength: thetaLength
+		};
 
-	radius = radius || 1;
+		radius = radius || 1;
 
-	widthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 );
-	heightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 );
+		widthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 );
+		heightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 );
 
-	phiStart = phiStart !== undefined ? phiStart : 0;
-	phiLength = phiLength !== undefined ? phiLength : Math.PI * 2;
+		phiStart = phiStart !== undefined ? phiStart : 0;
+		phiLength = phiLength !== undefined ? phiLength : Math.PI * 2;
 
-	thetaStart = thetaStart !== undefined ? thetaStart : 0;
-	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
+		thetaStart = thetaStart !== undefined ? thetaStart : 0;
+		thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
 
-	const thetaEnd = Math.min( thetaStart + thetaLength, Math.PI );
+		const thetaEnd = Math.min( thetaStart + thetaLength, Math.PI );
 
-	let index = 0;
-	const grid = [];
+		let index = 0;
+		const grid = [];
 
-	const vertex = new Vector3();
-	const normal = new Vector3();
+		const vertex = new Vector3();
+		const normal = new Vector3();
 
-	// buffers
+		// buffers
 
-	const indices = [];
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
+		const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
 
-	// generate vertices, normals and uvs
+		// generate vertices, normals and uvs
 
-	for ( let iy = 0; iy <= heightSegments; iy ++ ) {
+		for ( let iy = 0; iy <= heightSegments; iy ++ ) {
 
-		const verticesRow = [];
+			const verticesRow = [];
 
-		const v = iy / heightSegments;
+			const v = iy / heightSegments;
 
-		// special case for the poles
+			// special case for the poles
 
-		let uOffset = 0;
+			let uOffset = 0;
 
-		if ( iy == 0 && thetaStart == 0 ) {
+			if ( iy == 0 && thetaStart == 0 ) {
 
-			uOffset = 0.5 / widthSegments;
+				uOffset = 0.5 / widthSegments;
 
-		} else if ( iy == heightSegments && thetaEnd == Math.PI ) {
+			} else if ( iy == heightSegments && thetaEnd == Math.PI ) {
 
-			uOffset = - 0.5 / widthSegments;
+				uOffset = - 0.5 / widthSegments;
 
-		}
+			}
 
-		for ( let ix = 0; ix <= widthSegments; ix ++ ) {
+			for ( let ix = 0; ix <= widthSegments; ix ++ ) {
 
-			const u = ix / widthSegments;
+				const u = ix / widthSegments;
 
-			// vertex
+				// vertex
 
-			vertex.x = - radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
-			vertex.y = radius * Math.cos( thetaStart + v * thetaLength );
-			vertex.z = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
+				vertex.x = - radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
+				vertex.y = radius * Math.cos( thetaStart + v * thetaLength );
+				vertex.z = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
 
-			vertices.push( vertex.x, vertex.y, vertex.z );
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			// normal
+				// normal
 
-			normal.copy( vertex ).normalize();
-			normals.push( normal.x, normal.y, normal.z );
+				normal.copy( vertex ).normalize();
+				normals.push( normal.x, normal.y, normal.z );
 
-			// uv
+				// uv
 
-			uvs.push( u + uOffset, 1 - v );
+				uvs.push( u + uOffset, 1 - v );
 
-			verticesRow.push( index ++ );
+				verticesRow.push( index ++ );
 
-		}
+			}
 
-		grid.push( verticesRow );
+			grid.push( verticesRow );
 
-	}
+		}
+
+		// indices
 
-	// indices
+		for ( let iy = 0; iy < heightSegments; iy ++ ) {
 
-	for ( let iy = 0; iy < heightSegments; iy ++ ) {
+			for ( let ix = 0; ix < widthSegments; ix ++ ) {
 
-		for ( let ix = 0; ix < widthSegments; ix ++ ) {
+				const a = grid[ iy ][ ix + 1 ];
+				const b = grid[ iy ][ ix ];
+				const c = grid[ iy + 1 ][ ix ];
+				const d = grid[ iy + 1 ][ ix + 1 ];
 
-			const a = grid[ iy ][ ix + 1 ];
-			const b = grid[ iy ][ ix ];
-			const c = grid[ iy + 1 ][ ix ];
-			const d = grid[ iy + 1 ][ ix + 1 ];
+				if ( iy !== 0 || thetaStart > 0 ) indices.push( a, b, d );
+				if ( iy !== heightSegments - 1 || thetaEnd < Math.PI ) indices.push( b, c, d );
 
-			if ( iy !== 0 || thetaStart > 0 ) indices.push( a, b, d );
-			if ( iy !== heightSegments - 1 || thetaEnd < Math.PI ) indices.push( b, c, d );
+			}
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+	}
 
 }
 
-SphereBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-SphereBufferGeometry.prototype.constructor = SphereBufferGeometry;
-
 
 export { SphereGeometry, SphereBufferGeometry };

+ 29 - 27
src/geometries/TetrahedronGeometry.js

@@ -3,50 +3,52 @@ import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';
 
 // TetrahedronGeometry
 
-function TetrahedronGeometry( radius, detail ) {
+class TetrahedronGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( radius, detail ) {
 
-	this.type = 'TetrahedronGeometry';
+		super();
+		this.type = 'TetrahedronGeometry';
 
-	this.parameters = {
-		radius: radius,
-		detail: detail
-	};
+		this.parameters = {
+			radius: radius,
+			detail: detail
+		};
 
-	this.fromBufferGeometry( new TetrahedronBufferGeometry( radius, detail ) );
-	this.mergeVertices();
+		this.fromBufferGeometry( new TetrahedronBufferGeometry( radius, detail ) );
+		this.mergeVertices();
+
+	}
 
 }
 
-TetrahedronGeometry.prototype = Object.create( Geometry.prototype );
-TetrahedronGeometry.prototype.constructor = TetrahedronGeometry;
 
 // TetrahedronBufferGeometry
 
-function TetrahedronBufferGeometry( radius, detail ) {
+class TetrahedronBufferGeometry extends PolyhedronBufferGeometry {
 
-	const vertices = [
-		1, 1, 1, 	- 1, - 1, 1, 	- 1, 1, - 1, 	1, - 1, - 1
-	];
+	constructor( radius, detail ) {
 
-	const indices = [
-		2, 1, 0, 	0, 3, 2,	1, 3, 0,	2, 3, 1
-	];
+		const vertices = [
+			1, 1, 1, 	- 1, - 1, 1, 	- 1, 1, - 1, 	1, - 1, - 1
+		];
 
-	PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );
+		const indices = [
+			2, 1, 0, 	0, 3, 2,	1, 3, 0,	2, 3, 1
+		];
 
-	this.type = 'TetrahedronBufferGeometry';
+		super( vertices, indices, radius, detail );
 
-	this.parameters = {
-		radius: radius,
-		detail: detail
-	};
+		this.type = 'TetrahedronBufferGeometry';
 
-}
+		this.parameters = {
+			radius: radius,
+			detail: detail
+		};
 
-TetrahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );
-TetrahedronBufferGeometry.prototype.constructor = TetrahedronBufferGeometry;
+	}
+
+}
 
 
 export { TetrahedronGeometry, TetrahedronBufferGeometry };

+ 32 - 30
src/geometries/TextGeometry.js

@@ -20,60 +20,62 @@ import { ExtrudeBufferGeometry } from './ExtrudeGeometry.js';
 
 // TextGeometry
 
-function TextGeometry( text, parameters ) {
+class TextGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( text, parameters ) {
 
-	this.type = 'TextGeometry';
+		super();
+		this.type = 'TextGeometry';
 
-	this.parameters = {
-		text: text,
-		parameters: parameters
-	};
+		this.parameters = {
+			text: text,
+			parameters: parameters
+		};
 
-	this.fromBufferGeometry( new TextBufferGeometry( text, parameters ) );
-	this.mergeVertices();
+		this.fromBufferGeometry( new TextBufferGeometry( text, parameters ) );
+		this.mergeVertices();
+
+	}
 
 }
 
-TextGeometry.prototype = Object.create( Geometry.prototype );
-TextGeometry.prototype.constructor = TextGeometry;
 
 // TextBufferGeometry
 
-function TextBufferGeometry( text, parameters ) {
+class TextBufferGeometry extends ExtrudeBufferGeometry {
 
-	parameters = parameters || {};
+	constructor( text, parameters ) {
 
-	const font = parameters.font;
+		parameters = parameters || {};
 
-	if ( ! ( font && font.isFont ) ) {
+		const font = parameters.font;
 
-		console.error( 'THREE.TextGeometry: font parameter is not an instance of THREE.Font.' );
-		return new Geometry();
+		if ( ! ( font && font.isFont ) ) {
 
-	}
+			console.error( 'THREE.TextGeometry: font parameter is not an instance of THREE.Font.' );
+			return new Geometry();
 
-	const shapes = font.generateShapes( text, parameters.size );
+		}
 
-	// translate parameters to ExtrudeGeometry API
+		const shapes = font.generateShapes( text, parameters.size );
 
-	parameters.depth = parameters.height !== undefined ? parameters.height : 50;
+		// translate parameters to ExtrudeGeometry API
 
-	// defaults
+		parameters.depth = parameters.height !== undefined ? parameters.height : 50;
 
-	if ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10;
-	if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
-	if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
+		// defaults
 
-	ExtrudeBufferGeometry.call( this, shapes, parameters );
+		if ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10;
+		if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
+		if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
 
-	this.type = 'TextBufferGeometry';
+		super( shapes, parameters );
 
-}
+		this.type = 'TextBufferGeometry';
 
-TextBufferGeometry.prototype = Object.create( ExtrudeBufferGeometry.prototype );
-TextBufferGeometry.prototype.constructor = TextBufferGeometry;
+	}
+
+}
 
 
 export { TextGeometry, TextBufferGeometry };

+ 78 - 77
src/geometries/TorusGeometry.js

@@ -5,130 +5,131 @@ import { Vector3 } from '../math/Vector3.js';
 
 // TorusGeometry
 
-function TorusGeometry( radius, tube, radialSegments, tubularSegments, arc ) {
+class TorusGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( radius, tube, radialSegments, tubularSegments, arc ) {
 
-	this.type = 'TorusGeometry';
+		super();
+		this.type = 'TorusGeometry';
 
-	this.parameters = {
-		radius: radius,
-		tube: tube,
-		radialSegments: radialSegments,
-		tubularSegments: tubularSegments,
-		arc: arc
-	};
+		this.parameters = {
+			radius: radius,
+			tube: tube,
+			radialSegments: radialSegments,
+			tubularSegments: tubularSegments,
+			arc: arc
+		};
 
-	this.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );
-	this.mergeVertices();
+		this.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );
+		this.mergeVertices();
+
+	}
 
 }
 
-TorusGeometry.prototype = Object.create( Geometry.prototype );
-TorusGeometry.prototype.constructor = TorusGeometry;
 
 // TorusBufferGeometry
 
-function TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) {
+class TorusBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( radius, tube, radialSegments, tubularSegments, arc ) {
 
-	this.type = 'TorusBufferGeometry';
+		super();
+		this.type = 'TorusBufferGeometry';
 
-	this.parameters = {
-		radius: radius,
-		tube: tube,
-		radialSegments: radialSegments,
-		tubularSegments: tubularSegments,
-		arc: arc
-	};
+		this.parameters = {
+			radius: radius,
+			tube: tube,
+			radialSegments: radialSegments,
+			tubularSegments: tubularSegments,
+			arc: arc
+		};
 
-	radius = radius || 1;
-	tube = tube || 0.4;
-	radialSegments = Math.floor( radialSegments ) || 8;
-	tubularSegments = Math.floor( tubularSegments ) || 6;
-	arc = arc || Math.PI * 2;
+		radius = radius || 1;
+		tube = tube || 0.4;
+		radialSegments = Math.floor( radialSegments ) || 8;
+		tubularSegments = Math.floor( tubularSegments ) || 6;
+		arc = arc || Math.PI * 2;
 
-	// buffers
+		// buffers
 
-	const indices = [];
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
+		const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
 
-	// helper variables
+		// helper variables
 
-	const center = new Vector3();
-	const vertex = new Vector3();
-	const normal = new Vector3();
+		const center = new Vector3();
+		const vertex = new Vector3();
+		const normal = new Vector3();
 
-	// generate vertices, normals and uvs
+		// generate vertices, normals and uvs
 
-	for ( let j = 0; j <= radialSegments; j ++ ) {
+		for ( let j = 0; j <= radialSegments; j ++ ) {
 
-		for ( let i = 0; i <= tubularSegments; i ++ ) {
+			for ( let i = 0; i <= tubularSegments; i ++ ) {
 
-			const u = i / tubularSegments * arc;
-			const v = j / radialSegments * Math.PI * 2;
+				const u = i / tubularSegments * arc;
+				const v = j / radialSegments * Math.PI * 2;
 
-			// vertex
+				// vertex
 
-			vertex.x = ( radius + tube * Math.cos( v ) ) * Math.cos( u );
-			vertex.y = ( radius + tube * Math.cos( v ) ) * Math.sin( u );
-			vertex.z = tube * Math.sin( v );
+				vertex.x = ( radius + tube * Math.cos( v ) ) * Math.cos( u );
+				vertex.y = ( radius + tube * Math.cos( v ) ) * Math.sin( u );
+				vertex.z = tube * Math.sin( v );
 
-			vertices.push( vertex.x, vertex.y, vertex.z );
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			// normal
+				// normal
 
-			center.x = radius * Math.cos( u );
-			center.y = radius * Math.sin( u );
-			normal.subVectors( vertex, center ).normalize();
+				center.x = radius * Math.cos( u );
+				center.y = radius * Math.sin( u );
+				normal.subVectors( vertex, center ).normalize();
 
-			normals.push( normal.x, normal.y, normal.z );
+				normals.push( normal.x, normal.y, normal.z );
 
-			// uv
+				// uv
 
-			uvs.push( i / tubularSegments );
-			uvs.push( j / radialSegments );
+				uvs.push( i / tubularSegments );
+				uvs.push( j / radialSegments );
+
+			}
 
 		}
 
-	}
+		// generate indices
 
-	// generate indices
+		for ( let j = 1; j <= radialSegments; j ++ ) {
 
-	for ( let j = 1; j <= radialSegments; j ++ ) {
+			for ( let i = 1; i <= tubularSegments; i ++ ) {
 
-		for ( let i = 1; i <= tubularSegments; i ++ ) {
+				// indices
 
-			// indices
+				const a = ( tubularSegments + 1 ) * j + i - 1;
+				const b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;
+				const c = ( tubularSegments + 1 ) * ( j - 1 ) + i;
+				const d = ( tubularSegments + 1 ) * j + i;
 
-			const a = ( tubularSegments + 1 ) * j + i - 1;
-			const b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;
-			const c = ( tubularSegments + 1 ) * ( j - 1 ) + i;
-			const d = ( tubularSegments + 1 ) * j + i;
+				// faces
 
-			// faces
+				indices.push( a, b, d );
+				indices.push( b, c, d );
 
-			indices.push( a, b, d );
-			indices.push( b, c, d );
+			}
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+	}
 
 }
 
-TorusBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-TorusBufferGeometry.prototype.constructor = TorusBufferGeometry;
-
 
 export { TorusGeometry, TorusBufferGeometry };

+ 111 - 110
src/geometries/TorusKnotGeometry.js

@@ -5,181 +5,182 @@ import { Vector3 } from '../math/Vector3.js';
 
 // TorusKnotGeometry
 
-function TorusKnotGeometry( radius, tube, tubularSegments, radialSegments, p, q, heightScale ) {
+class TorusKnotGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( radius, tube, tubularSegments, radialSegments, p, q, heightScale ) {
 
-	this.type = 'TorusKnotGeometry';
+		super();
+		this.type = 'TorusKnotGeometry';
 
-	this.parameters = {
-		radius: radius,
-		tube: tube,
-		tubularSegments: tubularSegments,
-		radialSegments: radialSegments,
-		p: p,
-		q: q
-	};
+		this.parameters = {
+			radius: radius,
+			tube: tube,
+			tubularSegments: tubularSegments,
+			radialSegments: radialSegments,
+			p: p,
+			q: q
+		};
 
-	if ( heightScale !== undefined ) console.warn( 'THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.' );
+		if ( heightScale !== undefined ) console.warn( 'THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.' );
 
-	this.fromBufferGeometry( new TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments, p, q ) );
-	this.mergeVertices();
+		this.fromBufferGeometry( new TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments, p, q ) );
+		this.mergeVertices();
+
+	}
 
 }
 
-TorusKnotGeometry.prototype = Object.create( Geometry.prototype );
-TorusKnotGeometry.prototype.constructor = TorusKnotGeometry;
 
 // TorusKnotBufferGeometry
 
-function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments, p, q ) {
+class TorusKnotBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( radius, tube, tubularSegments, radialSegments, p, q ) {
 
-	this.type = 'TorusKnotBufferGeometry';
+		super();
+		this.type = 'TorusKnotBufferGeometry';
 
-	this.parameters = {
-		radius: radius,
-		tube: tube,
-		tubularSegments: tubularSegments,
-		radialSegments: radialSegments,
-		p: p,
-		q: q
-	};
+		this.parameters = {
+			radius: radius,
+			tube: tube,
+			tubularSegments: tubularSegments,
+			radialSegments: radialSegments,
+			p: p,
+			q: q
+		};
 
-	radius = radius || 1;
-	tube = tube || 0.4;
-	tubularSegments = Math.floor( tubularSegments ) || 64;
-	radialSegments = Math.floor( radialSegments ) || 8;
-	p = p || 2;
-	q = q || 3;
+		radius = radius || 1;
+		tube = tube || 0.4;
+		tubularSegments = Math.floor( tubularSegments ) || 64;
+		radialSegments = Math.floor( radialSegments ) || 8;
+		p = p || 2;
+		q = q || 3;
 
-	// buffers
+		// buffers
 
-	const indices = [];
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
+		const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
 
-	// helper variables
+		// helper variables
 
-	const vertex = new Vector3();
-	const normal = new Vector3();
+		const vertex = new Vector3();
+		const normal = new Vector3();
 
-	const P1 = new Vector3();
-	const P2 = new Vector3();
+		const P1 = new Vector3();
+		const P2 = new Vector3();
 
-	const B = new Vector3();
-	const T = new Vector3();
-	const N = new Vector3();
+		const B = new Vector3();
+		const T = new Vector3();
+		const N = new Vector3();
 
-	// generate vertices, normals and uvs
+		// generate vertices, normals and uvs
 
-	for ( let i = 0; i <= tubularSegments; ++ i ) {
+		for ( let i = 0; i <= tubularSegments; ++ i ) {
 
-		// the radian "u" is used to calculate the position on the torus curve of the current tubular segement
+			// the radian "u" is used to calculate the position on the torus curve of the current tubular segement
 
-		const u = i / tubularSegments * p * Math.PI * 2;
+			const u = i / tubularSegments * p * Math.PI * 2;
 
-		// now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead.
-		// these points are used to create a special "coordinate space", which is necessary to calculate the correct vertex positions
+			// now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead.
+			// these points are used to create a special "coordinate space", which is necessary to calculate the correct vertex positions
 
-		calculatePositionOnCurve( u, p, q, radius, P1 );
-		calculatePositionOnCurve( u + 0.01, p, q, radius, P2 );
+			calculatePositionOnCurve( u, p, q, radius, P1 );
+			calculatePositionOnCurve( u + 0.01, p, q, radius, P2 );
 
-		// calculate orthonormal basis
+			// calculate orthonormal basis
 
-		T.subVectors( P2, P1 );
-		N.addVectors( P2, P1 );
-		B.crossVectors( T, N );
-		N.crossVectors( B, T );
+			T.subVectors( P2, P1 );
+			N.addVectors( P2, P1 );
+			B.crossVectors( T, N );
+			N.crossVectors( B, T );
 
-		// normalize B, N. T can be ignored, we don't use it
+			// normalize B, N. T can be ignored, we don't use it
 
-		B.normalize();
-		N.normalize();
+			B.normalize();
+			N.normalize();
 
-		for ( let j = 0; j <= radialSegments; ++ j ) {
+			for ( let j = 0; j <= radialSegments; ++ j ) {
 
-			// now calculate the vertices. they are nothing more than an extrusion of the torus curve.
-			// because we extrude a shape in the xy-plane, there is no need to calculate a z-value.
+				// now calculate the vertices. they are nothing more than an extrusion of the torus curve.
+				// because we extrude a shape in the xy-plane, there is no need to calculate a z-value.
 
-			const v = j / radialSegments * Math.PI * 2;
-			const cx = - tube * Math.cos( v );
-			const cy = tube * Math.sin( v );
+				const v = j / radialSegments * Math.PI * 2;
+				const cx = - tube * Math.cos( v );
+				const cy = tube * Math.sin( v );
 
-			// now calculate the final vertex position.
-			// first we orient the extrusion with our basis vectos, then we add it to the current position on the curve
+				// now calculate the final vertex position.
+				// first we orient the extrusion with our basis vectos, then we add it to the current position on the curve
 
-			vertex.x = P1.x + ( cx * N.x + cy * B.x );
-			vertex.y = P1.y + ( cx * N.y + cy * B.y );
-			vertex.z = P1.z + ( cx * N.z + cy * B.z );
+				vertex.x = P1.x + ( cx * N.x + cy * B.x );
+				vertex.y = P1.y + ( cx * N.y + cy * B.y );
+				vertex.z = P1.z + ( cx * N.z + cy * B.z );
 
-			vertices.push( vertex.x, vertex.y, vertex.z );
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			// normal (P1 is always the center/origin of the extrusion, thus we can use it to calculate the normal)
+				// normal (P1 is always the center/origin of the extrusion, thus we can use it to calculate the normal)
 
-			normal.subVectors( vertex, P1 ).normalize();
+				normal.subVectors( vertex, P1 ).normalize();
 
-			normals.push( normal.x, normal.y, normal.z );
+				normals.push( normal.x, normal.y, normal.z );
 
-			// uv
+				// uv
 
-			uvs.push( i / tubularSegments );
-			uvs.push( j / radialSegments );
+				uvs.push( i / tubularSegments );
+				uvs.push( j / radialSegments );
+
+			}
 
 		}
 
-	}
+		// generate indices
 
-	// generate indices
+		for ( let j = 1; j <= tubularSegments; j ++ ) {
 
-	for ( let j = 1; j <= tubularSegments; j ++ ) {
+			for ( let i = 1; i <= radialSegments; i ++ ) {
 
-		for ( let i = 1; i <= radialSegments; i ++ ) {
+				// indices
 
-			// indices
+				const a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );
+				const b = ( radialSegments + 1 ) * j + ( i - 1 );
+				const c = ( radialSegments + 1 ) * j + i;
+				const d = ( radialSegments + 1 ) * ( j - 1 ) + i;
 
-			const a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );
-			const b = ( radialSegments + 1 ) * j + ( i - 1 );
-			const c = ( radialSegments + 1 ) * j + i;
-			const d = ( radialSegments + 1 ) * ( j - 1 ) + i;
+				// faces
 
-			// faces
+				indices.push( a, b, d );
+				indices.push( b, c, d );
 
-			indices.push( a, b, d );
-			indices.push( b, c, d );
+			}
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+		// this function calculates the current position on the torus curve
 
-	// this function calculates the current position on the torus curve
+		function calculatePositionOnCurve( u, p, q, radius, position ) {
 
-	function calculatePositionOnCurve( u, p, q, radius, position ) {
+			const cu = Math.cos( u );
+			const su = Math.sin( u );
+			const quOverP = q / p * u;
+			const cs = Math.cos( quOverP );
 
-		const cu = Math.cos( u );
-		const su = Math.sin( u );
-		const quOverP = q / p * u;
-		const cs = Math.cos( quOverP );
+			position.x = radius * ( 2 + cs ) * 0.5 * cu;
+			position.y = radius * ( 2 + cs ) * su * 0.5;
+			position.z = radius * Math.sin( quOverP ) * 0.5;
 
-		position.x = radius * ( 2 + cs ) * 0.5 * cu;
-		position.y = radius * ( 2 + cs ) * su * 0.5;
-		position.z = radius * Math.sin( quOverP ) * 0.5;
+		}
 
 	}
 
 }
 
-TorusKnotBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-TorusKnotBufferGeometry.prototype.constructor = TorusKnotBufferGeometry;
-
 
 export { TorusKnotGeometry, TorusKnotBufferGeometry };

+ 123 - 122
src/geometries/TubeGeometry.js

@@ -6,215 +6,216 @@ import { Vector3 } from '../math/Vector3.js';
 
 // TubeGeometry
 
-function TubeGeometry( path, tubularSegments, radius, radialSegments, closed, taper ) {
+class TubeGeometry extends Geometry {
 
-	Geometry.call( this );
+	constructor( path, tubularSegments, radius, radialSegments, closed, taper ) {
 
-	this.type = 'TubeGeometry';
+		super();
+		this.type = 'TubeGeometry';
 
-	this.parameters = {
-		path: path,
-		tubularSegments: tubularSegments,
-		radius: radius,
-		radialSegments: radialSegments,
-		closed: closed
-	};
+		this.parameters = {
+			path: path,
+			tubularSegments: tubularSegments,
+			radius: radius,
+			radialSegments: radialSegments,
+			closed: closed
+		};
 
-	if ( taper !== undefined ) console.warn( 'THREE.TubeGeometry: taper has been removed.' );
+		if ( taper !== undefined ) console.warn( 'THREE.TubeGeometry: taper has been removed.' );
 
-	const bufferGeometry = new TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed );
+		const bufferGeometry = new TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed );
 
-	// expose internals
+		// expose internals
 
-	this.tangents = bufferGeometry.tangents;
-	this.normals = bufferGeometry.normals;
-	this.binormals = bufferGeometry.binormals;
+		this.tangents = bufferGeometry.tangents;
+		this.normals = bufferGeometry.normals;
+		this.binormals = bufferGeometry.binormals;
 
-	// create geometry
+		// create geometry
 
-	this.fromBufferGeometry( bufferGeometry );
-	this.mergeVertices();
+		this.fromBufferGeometry( bufferGeometry );
+		this.mergeVertices();
+
+	}
 
 }
 
-TubeGeometry.prototype = Object.create( Geometry.prototype );
-TubeGeometry.prototype.constructor = TubeGeometry;
 
 // TubeBufferGeometry
 
-function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed ) {
+class TubeBufferGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( path, tubularSegments, radius, radialSegments, closed ) {
 
-	this.type = 'TubeBufferGeometry';
+		super();
+		this.type = 'TubeBufferGeometry';
 
-	this.parameters = {
-		path: path,
-		tubularSegments: tubularSegments,
-		radius: radius,
-		radialSegments: radialSegments,
-		closed: closed
-	};
+		this.parameters = {
+			path: path,
+			tubularSegments: tubularSegments,
+			radius: radius,
+			radialSegments: radialSegments,
+			closed: closed
+		};
 
-	tubularSegments = tubularSegments || 64;
-	radius = radius || 1;
-	radialSegments = radialSegments || 8;
-	closed = closed || false;
+		tubularSegments = tubularSegments || 64;
+		radius = radius || 1;
+		radialSegments = radialSegments || 8;
+		closed = closed || false;
 
-	const frames = path.computeFrenetFrames( tubularSegments, closed );
+		const frames = path.computeFrenetFrames( tubularSegments, closed );
 
-	// expose internals
+		// expose internals
 
-	this.tangents = frames.tangents;
-	this.normals = frames.normals;
-	this.binormals = frames.binormals;
+		this.tangents = frames.tangents;
+		this.normals = frames.normals;
+		this.binormals = frames.binormals;
 
-	// helper variables
+		// helper variables
 
-	const vertex = new Vector3();
-	const normal = new Vector3();
-	const uv = new Vector2();
-	let P = new Vector3();
+		const vertex = new Vector3();
+		const normal = new Vector3();
+		const uv = new Vector2();
+		let P = new Vector3();
 
-	// buffer
+		// buffer
 
-	const vertices = [];
-	const normals = [];
-	const uvs = [];
-	const indices = [];
+		const vertices = [];
+		const normals = [];
+		const uvs = [];
+		const indices = [];
 
-	// create buffer data
+		// create buffer data
 
-	generateBufferData();
+		generateBufferData();
 
-	// build geometry
+		// build geometry
 
-	this.setIndex( indices );
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
-	this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-	this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+		this.setIndex( indices );
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-	// functions
+		// functions
 
-	function generateBufferData() {
+		function generateBufferData() {
 
-		for ( let i = 0; i < tubularSegments; i ++ ) {
+			for ( let i = 0; i < tubularSegments; i ++ ) {
 
-			generateSegment( i );
+				generateSegment( i );
 
-		}
+			}
 
-		// if the geometry is not closed, generate the last row of vertices and normals
-		// at the regular position on the given path
-		//
-		// if the geometry is closed, duplicate the first row of vertices and normals (uvs will differ)
+			// if the geometry is not closed, generate the last row of vertices and normals
+			// at the regular position on the given path
+			//
+			// if the geometry is closed, duplicate the first row of vertices and normals (uvs will differ)
 
-		generateSegment( ( closed === false ) ? tubularSegments : 0 );
+			generateSegment( ( closed === false ) ? tubularSegments : 0 );
 
-		// uvs are generated in a separate function.
-		// this makes it easy compute correct values for closed geometries
+			// uvs are generated in a separate function.
+			// this makes it easy compute correct values for closed geometries
 
-		generateUVs();
+			generateUVs();
 
-		// finally create faces
+			// finally create faces
 
-		generateIndices();
+			generateIndices();
 
-	}
+		}
 
-	function generateSegment( i ) {
+		function generateSegment( i ) {
 
-		// we use getPointAt to sample evenly distributed points from the given path
+			// we use getPointAt to sample evenly distributed points from the given path
 
-		P = path.getPointAt( i / tubularSegments, P );
+			P = path.getPointAt( i / tubularSegments, P );
 
-		// retrieve corresponding normal and binormal
+			// retrieve corresponding normal and binormal
 
-		const N = frames.normals[ i ];
-		const B = frames.binormals[ i ];
+			const N = frames.normals[ i ];
+			const B = frames.binormals[ i ];
 
-		// generate normals and vertices for the current segment
+			// generate normals and vertices for the current segment
+
+			for ( let j = 0; j <= radialSegments; j ++ ) {
 
-		for ( let j = 0; j <= radialSegments; j ++ ) {
+				const v = j / radialSegments * Math.PI * 2;
 
-			const v = j / radialSegments * Math.PI * 2;
+				const sin = Math.sin( v );
+				const cos = - Math.cos( v );
 
-			const sin = Math.sin( v );
-			const cos = - Math.cos( v );
+				// normal
 
-			// normal
+				normal.x = ( cos * N.x + sin * B.x );
+				normal.y = ( cos * N.y + sin * B.y );
+				normal.z = ( cos * N.z + sin * B.z );
+				normal.normalize();
 
-			normal.x = ( cos * N.x + sin * B.x );
-			normal.y = ( cos * N.y + sin * B.y );
-			normal.z = ( cos * N.z + sin * B.z );
-			normal.normalize();
+				normals.push( normal.x, normal.y, normal.z );
 
-			normals.push( normal.x, normal.y, normal.z );
+				// vertex
 
-			// vertex
+				vertex.x = P.x + radius * normal.x;
+				vertex.y = P.y + radius * normal.y;
+				vertex.z = P.z + radius * normal.z;
 
-			vertex.x = P.x + radius * normal.x;
-			vertex.y = P.y + radius * normal.y;
-			vertex.z = P.z + radius * normal.z;
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			vertices.push( vertex.x, vertex.y, vertex.z );
+			}
 
 		}
 
-	}
+		function generateIndices() {
 
-	function generateIndices() {
+			for ( let j = 1; j <= tubularSegments; j ++ ) {
 
-		for ( let j = 1; j <= tubularSegments; j ++ ) {
+				for ( let i = 1; i <= radialSegments; i ++ ) {
 
-			for ( let i = 1; i <= radialSegments; i ++ ) {
+					const a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );
+					const b = ( radialSegments + 1 ) * j + ( i - 1 );
+					const c = ( radialSegments + 1 ) * j + i;
+					const d = ( radialSegments + 1 ) * ( j - 1 ) + i;
 
-				const a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );
-				const b = ( radialSegments + 1 ) * j + ( i - 1 );
-				const c = ( radialSegments + 1 ) * j + i;
-				const d = ( radialSegments + 1 ) * ( j - 1 ) + i;
+					// faces
 
-				// faces
+					indices.push( a, b, d );
+					indices.push( b, c, d );
 
-				indices.push( a, b, d );
-				indices.push( b, c, d );
+				}
 
 			}
 
 		}
 
-	}
+		function generateUVs() {
 
-	function generateUVs() {
+			for ( let i = 0; i <= tubularSegments; i ++ ) {
 
-		for ( let i = 0; i <= tubularSegments; i ++ ) {
+				for ( let j = 0; j <= radialSegments; j ++ ) {
 
-			for ( let j = 0; j <= radialSegments; j ++ ) {
+					uv.x = i / tubularSegments;
+					uv.y = j / radialSegments;
 
-				uv.x = i / tubularSegments;
-				uv.y = j / radialSegments;
+					uvs.push( uv.x, uv.y );
 
-				uvs.push( uv.x, uv.y );
+				}
 
 			}
 
 		}
 
 	}
+	toJSON() {
 
-}
-
-TubeBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
-TubeBufferGeometry.prototype.constructor = TubeBufferGeometry;
+		const data = BufferGeometry.prototype.toJSON.call( this );
 
-TubeBufferGeometry.prototype.toJSON = function () {
+		data.path = this.parameters.path.toJSON();
 
-	const data = BufferGeometry.prototype.toJSON.call( this );
+		return data;
 
-	data.path = this.parameters.path.toJSON();
+	}
 
-	return data;
+}
 
-};
 
 export { TubeGeometry, TubeBufferGeometry };

+ 83 - 83
src/geometries/WireframeGeometry.js

@@ -2,107 +2,110 @@ import { BufferGeometry } from '../core/BufferGeometry.js';
 import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { Vector3 } from '../math/Vector3.js';
 
-function WireframeGeometry( geometry ) {
+class WireframeGeometry extends BufferGeometry {
 
-	BufferGeometry.call( this );
+	constructor( geometry ) {
 
-	this.type = 'WireframeGeometry';
+		super();
+		this.type = 'WireframeGeometry';
 
-	// buffer
+		// buffer
 
-	const vertices = [];
+		const vertices = [];
 
-	// helper variables
+		// helper variables
 
-	const edge = [ 0, 0 ], edges = {};
-	const keys = [ 'a', 'b', 'c' ];
+		const edge = [ 0, 0 ], edges = {};
+		const keys = [ 'a', 'b', 'c' ];
 
-	// different logic for Geometry and BufferGeometry
+		// different logic for Geometry and BufferGeometry
 
-	if ( geometry && geometry.isGeometry ) {
+		if ( geometry && geometry.isGeometry ) {
 
-		// create a data structure that contains all edges without duplicates
+			// create a data structure that contains all edges without duplicates
 
-		const faces = geometry.faces;
+			const faces = geometry.faces;
 
-		for ( let i = 0, l = faces.length; i < l; i ++ ) {
+			for ( let i = 0, l = faces.length; i < l; i ++ ) {
 
-			const face = faces[ i ];
+				const face = faces[ i ];
 
-			for ( let j = 0; j < 3; j ++ ) {
+				for ( let j = 0; j < 3; j ++ ) {
+
+					const edge1 = face[ keys[ j ] ];
+					const edge2 = face[ keys[ ( j + 1 ) % 3 ] ];
+					edge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates
+					edge[ 1 ] = Math.max( edge1, edge2 );
 
-				const edge1 = face[ keys[ j ] ];
-				const edge2 = face[ keys[ ( j + 1 ) % 3 ] ];
-				edge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates
-				edge[ 1 ] = Math.max( edge1, edge2 );
+					const key = edge[ 0 ] + ',' + edge[ 1 ];
 
-				const key = edge[ 0 ] + ',' + edge[ 1 ];
+					if ( edges[ key ] === undefined ) {
 
-				if ( edges[ key ] === undefined ) {
+						edges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ] };
 
-					edges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ] };
+					}
 
 				}
 
 			}
 
-		}
+			// generate vertices
 
-		// generate vertices
+			for ( const key in edges ) {
 
-		for ( const key in edges ) {
+				const e = edges[ key ];
 
-			const e = edges[ key ];
+				let vertex = geometry.vertices[ e.index1 ];
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			let vertex = geometry.vertices[ e.index1 ];
-			vertices.push( vertex.x, vertex.y, vertex.z );
+				vertex = geometry.vertices[ e.index2 ];
+				vertices.push( vertex.x, vertex.y, vertex.z );
 
-			vertex = geometry.vertices[ e.index2 ];
-			vertices.push( vertex.x, vertex.y, vertex.z );
+			}
 
-		}
+		} else if ( geometry && geometry.isBufferGeometry ) {
 
-	} else if ( geometry && geometry.isBufferGeometry ) {
+			const vertex = new Vector3();
 
-		const vertex = new Vector3();
+			if ( geometry.index !== null ) {
 
-		if ( geometry.index !== null ) {
+				// indexed BufferGeometry
 
-			// indexed BufferGeometry
+				const position = geometry.attributes.position;
+				const indices = geometry.index;
+				let groups = geometry.groups;
 
-			const position = geometry.attributes.position;
-			const indices = geometry.index;
-			let groups = geometry.groups;
+				if ( groups.length === 0 ) {
 
-			if ( groups.length === 0 ) {
+					groups = [ { start: 0, count: indices.count, materialIndex: 0 } ];
 
-				groups = [ { start: 0, count: indices.count, materialIndex: 0 } ];
+				}
 
-			}
+				// create a data structure that contains all eges without duplicates
 
-			// create a data structure that contains all eges without duplicates
+				for ( let o = 0, ol = groups.length; o < ol; ++ o ) {
 
-			for ( let o = 0, ol = groups.length; o < ol; ++ o ) {
+					const group = groups[ o ];
 
-				const group = groups[ o ];
+					const start = group.start;
+					const count = group.count;
 
-				const start = group.start;
-				const count = group.count;
+					for ( let i = start, l = ( start + count ); i < l; i += 3 ) {
 
-				for ( let i = start, l = ( start + count ); i < l; i += 3 ) {
+						for ( let j = 0; j < 3; j ++ ) {
 
-					for ( let j = 0; j < 3; j ++ ) {
+							const edge1 = indices.getX( i + j );
+							const edge2 = indices.getX( i + ( j + 1 ) % 3 );
+							edge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates
+							edge[ 1 ] = Math.max( edge1, edge2 );
 
-						const edge1 = indices.getX( i + j );
-						const edge2 = indices.getX( i + ( j + 1 ) % 3 );
-						edge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates
-						edge[ 1 ] = Math.max( edge1, edge2 );
+							const key = edge[ 0 ] + ',' + edge[ 1 ];
 
-						const key = edge[ 0 ] + ',' + edge[ 1 ];
+							if ( edges[ key ] === undefined ) {
 
-						if ( edges[ key ] === undefined ) {
+								edges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ] };
 
-							edges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ] };
+							}
 
 						}
 
@@ -110,42 +113,42 @@ function WireframeGeometry( geometry ) {
 
 				}
 
-			}
+				// generate vertices
 
-			// generate vertices
+				for ( const key in edges ) {
 
-			for ( const key in edges ) {
+					const e = edges[ key ];
 
-				const e = edges[ key ];
+					vertex.fromBufferAttribute( position, e.index1 );
+					vertices.push( vertex.x, vertex.y, vertex.z );
 
-				vertex.fromBufferAttribute( position, e.index1 );
-				vertices.push( vertex.x, vertex.y, vertex.z );
+					vertex.fromBufferAttribute( position, e.index2 );
+					vertices.push( vertex.x, vertex.y, vertex.z );
 
-				vertex.fromBufferAttribute( position, e.index2 );
-				vertices.push( vertex.x, vertex.y, vertex.z );
+				}
 
-			}
+			} else {
 
-		} else {
+				// non-indexed BufferGeometry
 
-			// non-indexed BufferGeometry
+				const position = geometry.attributes.position;
 
-			const position = geometry.attributes.position;
+				for ( let i = 0, l = ( position.count / 3 ); i < l; i ++ ) {
 
-			for ( let i = 0, l = ( position.count / 3 ); i < l; i ++ ) {
+					for ( let j = 0; j < 3; j ++ ) {
 
-				for ( let j = 0; j < 3; j ++ ) {
+						// three edges per triangle, an edge is represented as (index1, index2)
+						// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)
 
-					// three edges per triangle, an edge is represented as (index1, index2)
-					// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)
+						const index1 = 3 * i + j;
+						vertex.fromBufferAttribute( position, index1 );
+						vertices.push( vertex.x, vertex.y, vertex.z );
 
-					const index1 = 3 * i + j;
-					vertex.fromBufferAttribute( position, index1 );
-					vertices.push( vertex.x, vertex.y, vertex.z );
+						const index2 = 3 * i + ( ( j + 1 ) % 3 );
+						vertex.fromBufferAttribute( position, index2 );
+						vertices.push( vertex.x, vertex.y, vertex.z );
 
-					const index2 = 3 * i + ( ( j + 1 ) % 3 );
-					vertex.fromBufferAttribute( position, index2 );
-					vertices.push( vertex.x, vertex.y, vertex.z );
+					}
 
 				}
 
@@ -153,16 +156,13 @@ function WireframeGeometry( geometry ) {
 
 		}
 
-	}
+		// build geometry
 
-	// build geometry
+		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 
-	this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+	}
 
 }
 
-WireframeGeometry.prototype = Object.create( BufferGeometry.prototype );
-WireframeGeometry.prototype.constructor = WireframeGeometry;
-
 
 export { WireframeGeometry };

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff