Bladeren bron

Merge pull request #21031 from mrdoob/geometry

Moved THREE.Geometry out of core.
Mr.doob 4 jaren geleden
bovenliggende
commit
af5414c0b6

+ 0 - 0
src/core/Geometry.d.ts → examples/jsm/deprecated/Geometry.d.ts


+ 411 - 15
src/core/Geometry.js → examples/jsm/deprecated/Geometry.js

@@ -1,24 +1,26 @@
-import { EventDispatcher } from './EventDispatcher.js';
-import { Face3 } from './Face3.js';
-import { Matrix3 } from '../math/Matrix3.js';
-import { Sphere } from '../math/Sphere.js';
-import { Box3 } from '../math/Box3.js';
-import { Vector3 } from '../math/Vector3.js';
-import { Matrix4 } from '../math/Matrix4.js';
-import { Vector2 } from '../math/Vector2.js';
-import { Color } from '../math/Color.js';
-import { Object3D } from './Object3D.js';
-import { MathUtils } from '../math/MathUtils.js';
-
-let _geometryId = 0; // Geometry uses even numbers as Id
+import {
+	Box3,
+	BufferAttribute,
+	BufferGeometry,
+	Color,
+	EventDispatcher,
+	Face3,
+	Float32BufferAttribute,
+	Matrix3,
+	Matrix4,
+	MathUtils,
+	Object3D,
+	Sphere,
+	Vector2,
+	Vector3
+} from '../../../build/three.module.js';
+
 const _m1 = new Matrix4();
 const _obj = new Object3D();
 const _offset = new Vector3();
 
 function Geometry() {
 
-	Object.defineProperty( this, 'id', { value: _geometryId += 2 } );
-
 	this.uuid = MathUtils.generateUUID();
 
 	this.name = '';
@@ -1365,6 +1367,122 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 	},
 
+	toBufferGeometry: function () {
+
+		const geometry = new DirectGeometry().fromGeometry( this );
+
+		const buffergeometry = new BufferGeometry();
+
+		const positions = new Float32Array( geometry.vertices.length * 3 );
+		buffergeometry.setAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );
+
+		if ( geometry.normals.length > 0 ) {
+
+			const normals = new Float32Array( geometry.normals.length * 3 );
+			buffergeometry.setAttribute( 'normal', new BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );
+
+		}
+
+		if ( geometry.colors.length > 0 ) {
+
+			const colors = new Float32Array( geometry.colors.length * 3 );
+			buffergeometry.setAttribute( 'color', new BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );
+
+		}
+
+		if ( geometry.uvs.length > 0 ) {
+
+			const uvs = new Float32Array( geometry.uvs.length * 2 );
+			buffergeometry.setAttribute( 'uv', new BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );
+
+		}
+
+		if ( geometry.uvs2.length > 0 ) {
+
+			const uvs2 = new Float32Array( geometry.uvs2.length * 2 );
+			buffergeometry.setAttribute( 'uv2', new BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );
+
+		}
+
+		// groups
+
+		buffergeometry.groups = geometry.groups;
+
+		// morphs
+
+		for ( const name in geometry.morphTargets ) {
+
+			const array = [];
+			const morphTargets = geometry.morphTargets[ name ];
+
+			for ( let i = 0, l = morphTargets.length; i < l; i ++ ) {
+
+				const morphTarget = morphTargets[ i ];
+
+				const attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );
+				attribute.name = morphTarget.name;
+
+				array.push( attribute.copyVector3sArray( morphTarget.data ) );
+
+			}
+
+			buffergeometry.morphAttributes[ name ] = array;
+
+		}
+
+		// skinning
+
+		if ( geometry.skinIndices.length > 0 ) {
+
+			const skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );
+			buffergeometry.setAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );
+
+		}
+
+		if ( geometry.skinWeights.length > 0 ) {
+
+			const skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );
+			buffergeometry.setAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );
+
+		}
+
+		//
+
+		if ( geometry.boundingSphere !== null ) {
+
+			buffergeometry.boundingSphere = geometry.boundingSphere.clone();
+
+		}
+
+		if ( geometry.boundingBox !== null ) {
+
+			buffergeometry.boundingBox = geometry.boundingBox.clone();
+
+		}
+
+		return buffergeometry;
+
+	},
+
+	computeTangents: function () {
+
+		console.error( 'THREE.Geometry: .computeTangents() has been removed.' );
+
+	},
+
+	computeLineDistances: function () {
+
+		console.error( 'THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.' );
+
+	},
+
+	applyMatrix: function ( matrix ) {
+
+		console.warn( 'THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().' );
+		return this.applyMatrix4( matrix );
+
+	},
+
 	dispose: function () {
 
 		this.dispatchEvent( { type: 'dispose' } );
@@ -1373,5 +1491,283 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 } );
 
+class DirectGeometry {
+
+	constructor() {
+
+		this.vertices = [];
+		this.normals = [];
+		this.colors = [];
+		this.uvs = [];
+		this.uvs2 = [];
+
+		this.groups = [];
+
+		this.morphTargets = {};
+
+		this.skinWeights = [];
+		this.skinIndices = [];
+
+		// this.lineDistances = [];
+
+		this.boundingBox = null;
+		this.boundingSphere = null;
+
+		// update flags
+
+		this.verticesNeedUpdate = false;
+		this.normalsNeedUpdate = false;
+		this.colorsNeedUpdate = false;
+		this.uvsNeedUpdate = false;
+		this.groupsNeedUpdate = false;
+
+	}
+
+	computeGroups( geometry ) {
+
+		const groups = [];
+
+		let group, i;
+		let materialIndex = undefined;
+
+		const faces = geometry.faces;
+
+		for ( i = 0; i < faces.length; i ++ ) {
+
+			const face = faces[ i ];
+
+			// materials
+
+			if ( face.materialIndex !== materialIndex ) {
+
+				materialIndex = face.materialIndex;
+
+				if ( group !== undefined ) {
+
+					group.count = ( i * 3 ) - group.start;
+					groups.push( group );
+
+				}
+
+				group = {
+					start: i * 3,
+					materialIndex: materialIndex
+				};
+
+			}
+
+		}
+
+		if ( group !== undefined ) {
+
+			group.count = ( i * 3 ) - group.start;
+			groups.push( group );
+
+		}
+
+		this.groups = groups;
+
+	}
+
+	fromGeometry( geometry ) {
+
+		const faces = geometry.faces;
+		const vertices = geometry.vertices;
+		const faceVertexUvs = geometry.faceVertexUvs;
+
+		const hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;
+		const hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;
+
+		// morphs
+
+		const morphTargets = geometry.morphTargets;
+		const morphTargetsLength = morphTargets.length;
+
+		let morphTargetsPosition;
+
+		if ( morphTargetsLength > 0 ) {
+
+			morphTargetsPosition = [];
+
+			for ( let i = 0; i < morphTargetsLength; i ++ ) {
+
+				morphTargetsPosition[ i ] = {
+					name: morphTargets[ i ].name,
+				 	data: []
+				};
+
+			}
+
+			this.morphTargets.position = morphTargetsPosition;
+
+		}
+
+		const morphNormals = geometry.morphNormals;
+		const morphNormalsLength = morphNormals.length;
+
+		let morphTargetsNormal;
+
+		if ( morphNormalsLength > 0 ) {
+
+			morphTargetsNormal = [];
+
+			for ( let i = 0; i < morphNormalsLength; i ++ ) {
+
+				morphTargetsNormal[ i ] = {
+					name: morphNormals[ i ].name,
+				 	data: []
+				};
+
+			}
+
+			this.morphTargets.normal = morphTargetsNormal;
+
+		}
+
+		// skins
+
+		const skinIndices = geometry.skinIndices;
+		const skinWeights = geometry.skinWeights;
+
+		const hasSkinIndices = skinIndices.length === vertices.length;
+		const hasSkinWeights = skinWeights.length === vertices.length;
+
+		//
+
+		if ( vertices.length > 0 && faces.length === 0 ) {
+
+			console.error( 'THREE.DirectGeometry: Faceless geometries are not supported.' );
+
+		}
+
+		for ( let i = 0; i < faces.length; i ++ ) {
+
+			const face = faces[ i ];
+
+			this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] );
+
+			const vertexNormals = face.vertexNormals;
+
+			if ( vertexNormals.length === 3 ) {
+
+				this.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] );
+
+			} else {
+
+				const normal = face.normal;
+
+				this.normals.push( normal, normal, normal );
+
+			}
+
+			const vertexColors = face.vertexColors;
+
+			if ( vertexColors.length === 3 ) {
+
+				this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );
+
+			} else {
+
+				const color = face.color;
+
+				this.colors.push( color, color, color );
+
+			}
+
+			if ( hasFaceVertexUv === true ) {
+
+				const vertexUvs = faceVertexUvs[ 0 ][ i ];
+
+				if ( vertexUvs !== undefined ) {
+
+					this.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );
+
+				} else {
+
+					console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );
+
+					this.uvs.push( new Vector2(), new Vector2(), new Vector2() );
+
+				}
+
+			}
+
+			if ( hasFaceVertexUv2 === true ) {
+
+				const vertexUvs = faceVertexUvs[ 1 ][ i ];
+
+				if ( vertexUvs !== undefined ) {
+
+					this.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );
+
+				} else {
+
+					console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );
+
+					this.uvs2.push( new Vector2(), new Vector2(), new Vector2() );
+
+				}
+
+			}
+
+			// morphs
+
+			for ( let j = 0; j < morphTargetsLength; j ++ ) {
+
+				const morphTarget = morphTargets[ j ].vertices;
+
+				morphTargetsPosition[ j ].data.push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );
+
+			}
+
+			for ( let j = 0; j < morphNormalsLength; j ++ ) {
+
+				const morphNormal = morphNormals[ j ].vertexNormals[ i ];
+
+				morphTargetsNormal[ j ].data.push( morphNormal.a, morphNormal.b, morphNormal.c );
+
+			}
+
+			// skins
+
+			if ( hasSkinIndices ) {
+
+				this.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] );
+
+			}
+
+			if ( hasSkinWeights ) {
+
+				this.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] );
+
+			}
+
+		}
+
+		this.computeGroups( geometry );
+
+		this.verticesNeedUpdate = geometry.verticesNeedUpdate;
+		this.normalsNeedUpdate = geometry.normalsNeedUpdate;
+		this.colorsNeedUpdate = geometry.colorsNeedUpdate;
+		this.uvsNeedUpdate = geometry.uvsNeedUpdate;
+		this.groupsNeedUpdate = geometry.groupsNeedUpdate;
+
+		if ( geometry.boundingSphere !== null ) {
+
+			this.boundingSphere = geometry.boundingSphere.clone();
+
+		}
+
+		if ( geometry.boundingBox !== null ) {
+
+			this.boundingBox = geometry.boundingBox.clone();
+
+		}
+
+		return this;
+
+	}
+
+}
 
 export { Geometry };

+ 0 - 1
examples/jsm/modifiers/SimplifyModifier.js

@@ -1,7 +1,6 @@
 import {
 	BufferGeometry,
 	Float32BufferAttribute,
-	Geometry,
 	Vector3
 } from '../../../build/three.module.js';
 import { BufferGeometryUtils } from '../utils/BufferGeometryUtils.js';

+ 0 - 1
examples/jsm/modifiers/TessellateModifier.js

@@ -2,7 +2,6 @@ import {
 	BufferGeometry,
 	Color,
 	Float32BufferAttribute,
-	Geometry,
 	Vector2,
 	Vector3
 } from '../../../build/three.module.js';

+ 0 - 1
examples/jsm/renderers/Projector.js

@@ -6,7 +6,6 @@ import {
 	DoubleSide,
 	FrontSide,
 	Frustum,
-	Geometry,
 	Light,
 	Line,
 	LineSegments,

+ 1 - 36
src/Three.Legacy.d.ts

@@ -1,36 +1 @@
-import { Geometry } from './core/Geometry';
-import { Material } from './materials/Material';
-import { Object3D } from './core/Object3D';
-import { Scene } from './scenes/Scene';
-
-export namespace SceneUtils {
-	export function createMultiMaterialObject(
-		geometry: Geometry,
-		materials: Material[]
-	): Object3D;
-	export function detach( child: Object3D, parent: Object3D, scene: Scene ): void;
-	export function attach( child: Object3D, scene: Scene, parent: Object3D ): void;
-}
-
-/**
- * @deprecated Use an Array instead.
- */
-export class MultiMaterial extends Material {
-
-	constructor( materials?: Material[] );
-
-	readonly isMultiMaterial: true;
-
-	materials: Material[];
-
-	toJSON( meta: any ): any;
-
-}
-
-/**
- * @deprecated Material.vertexColors is now a boolean.
- */
-export enum Colors {}
-export const NoColors: Colors;
-export const FaceColors: Colors;
-export const VertexColors: Colors;
+export {};

+ 0 - 41
src/Three.Legacy.js

@@ -25,7 +25,6 @@ import { BufferGeometry } from './core/BufferGeometry.js';
 import { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';
 import { InterleavedBuffer } from './core/InterleavedBuffer.js';
 import { Face3 } from './core/Face3.js';
-import { Geometry } from './core/Geometry.js';
 import { Object3D } from './core/Object3D.js';
 import { Uniform } from './core/Uniform.js';
 import { Raycaster } from './core/Raycaster.js';
@@ -283,23 +282,6 @@ Object.assign( CurvePath.prototype, {
 		const pts = this.getSpacedPoints( divisions );
 		return this.createGeometry( pts );
 
-	},
-
-	createGeometry: function ( points ) {
-
-		console.warn( 'THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );
-
-		const geometry = new Geometry();
-
-		for ( let i = 0, l = points.length; i < l; i ++ ) {
-
-			const point = points[ i ];
-			geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
-
-		}
-
-		return geometry;
-
 	}
 
 } );
@@ -947,29 +929,6 @@ Object.assign( Vector4.prototype, {
 
 //
 
-Object.assign( Geometry.prototype, {
-
-	computeTangents: function () {
-
-		console.error( 'THREE.Geometry: .computeTangents() has been removed.' );
-
-	},
-	computeLineDistances: function () {
-
-		console.error( 'THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.' );
-
-	},
-	applyMatrix: function ( matrix ) {
-
-		console.warn( 'THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().' );
-		return this.applyMatrix4( matrix );
-
-	}
-
-} );
-
-//
-
 Object.assign( Object3D.prototype, {
 
 	getChildByName: function ( name ) {

+ 0 - 2
src/Three.d.ts

@@ -93,7 +93,6 @@ export * from './animation/AnimationAction';
 export * from './core/Uniform';
 export * from './core/InstancedBufferGeometry';
 export * from './core/BufferGeometry';
-export * from './core/Geometry';
 export * from './core/InterleavedBufferAttribute';
 export * from './core/InstancedInterleavedBuffer';
 export * from './core/InterleavedBuffer';
@@ -104,7 +103,6 @@ export * from './core/Object3D';
 export * from './core/Raycaster';
 export * from './core/Layers';
 export * from './core/EventDispatcher';
-export * from './core/DirectGeometry';
 export * from './core/Clock';
 export * from './math/interpolants/QuaternionLinearInterpolant';
 export * from './math/interpolants/LinearInterpolant';

+ 0 - 1
src/Three.js

@@ -89,7 +89,6 @@ export { AnimationClip } from './animation/AnimationClip.js';
 export { Uniform } from './core/Uniform.js';
 export { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';
 export { BufferGeometry } from './core/BufferGeometry.js';
-export { Geometry } from './core/Geometry.js';
 export { InterleavedBufferAttribute } from './core/InterleavedBufferAttribute.js';
 export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer.js';
 export { InterleavedBuffer } from './core/InterleavedBuffer.js';

+ 6 - 1
src/animation/AnimationClip.d.ts

@@ -1,8 +1,13 @@
 import { KeyframeTrack } from './KeyframeTrack';
+import { Vector3 } from './../math/Vector3';
 import { Bone } from './../objects/Bone';
-import { MorphTarget } from '../core/Geometry';
 import { AnimationBlendMode } from '../constants';
 
+interface MorphTarget {
+	name: string;
+	vertices: Vector3[];
+}
+
 export class AnimationClip {
 
 	constructor( name?: string, duration?: number, tracks?: KeyframeTrack[], blendMode?: AnimationBlendMode );

+ 0 - 9
src/core/BufferGeometry.d.ts

@@ -4,9 +4,6 @@ import { Sphere } from './../math/Sphere';
 import { Matrix4 } from './../math/Matrix4';
 import { Vector2 } from './../math/Vector2';
 import { Vector3 } from './../math/Vector3';
-import { Object3D } from './Object3D';
-import { Geometry } from './Geometry';
-import { DirectGeometry } from './DirectGeometry';
 import { EventDispatcher } from './EventDispatcher';
 import { InterleavedBufferAttribute } from './InterleavedBufferAttribute';
 
@@ -119,13 +116,7 @@ export class BufferGeometry extends EventDispatcher {
 
 	center(): BufferGeometry;
 
-	setFromObject( object: Object3D ): BufferGeometry;
 	setFromPoints( points: Vector3[] | Vector2[] ): BufferGeometry;
-	updateFromObject( object: Object3D ): void;
-
-	fromGeometry( geometry: Geometry, settings?: any ): BufferGeometry;
-
-	fromDirectGeometry( geometry: DirectGeometry ): BufferGeometry;
 
 	/**
 	 * Computes bounding box of the geometry, updating Geometry.boundingBox attribute.

+ 2 - 277
src/core/BufferGeometry.js

@@ -3,14 +3,13 @@ import { Box3 } from '../math/Box3.js';
 import { EventDispatcher } from './EventDispatcher.js';
 import { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from './BufferAttribute.js';
 import { Sphere } from '../math/Sphere.js';
-import { DirectGeometry } from './DirectGeometry.js';
 import { Object3D } from './Object3D.js';
 import { Matrix4 } from '../math/Matrix4.js';
 import { Matrix3 } from '../math/Matrix3.js';
 import { MathUtils } from '../math/MathUtils.js';
 import { arrayMax } from '../utils.js';
 
-let _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id
+let _id = 0;
 
 const _m1 = new Matrix4();
 const _obj = new Object3D();
@@ -21,7 +20,7 @@ const _vector = new Vector3();
 
 function BufferGeometry() {
 
-	Object.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } );
+	Object.defineProperty( this, 'id', { value: _id ++ } );
 
 	this.uuid = MathUtils.generateUUID();
 
@@ -260,54 +259,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 	},
 
-	setFromObject: function ( object ) {
-
-		// console.log( 'THREE.BufferGeometry.setFromObject(). Converting', object, this );
-
-		const geometry = object.geometry;
-
-		if ( object.isPoints || object.isLine ) {
-
-			const positions = new Float32BufferAttribute( geometry.vertices.length * 3, 3 );
-			const colors = new Float32BufferAttribute( geometry.colors.length * 3, 3 );
-
-			this.setAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );
-			this.setAttribute( 'color', colors.copyColorsArray( geometry.colors ) );
-
-			if ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {
-
-				const lineDistances = new Float32BufferAttribute( geometry.lineDistances.length, 1 );
-
-				this.setAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );
-
-			}
-
-			if ( geometry.boundingSphere !== null ) {
-
-				this.boundingSphere = geometry.boundingSphere.clone();
-
-			}
-
-			if ( geometry.boundingBox !== null ) {
-
-				this.boundingBox = geometry.boundingBox.clone();
-
-			}
-
-		} else if ( object.isMesh ) {
-
-			if ( geometry && geometry.isGeometry ) {
-
-				this.fromGeometry( geometry );
-
-			}
-
-		}
-
-		return this;
-
-	},
-
 	setFromPoints: function ( points ) {
 
 		const position = [];
@@ -325,232 +276,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 	},
 
-	updateFromObject: function ( object ) {
-
-		let geometry = object.geometry;
-
-		if ( object.isMesh ) {
-
-			let direct = geometry.__directGeometry;
-
-			if ( geometry.elementsNeedUpdate === true ) {
-
-				direct = undefined;
-				geometry.elementsNeedUpdate = false;
-
-			}
-
-			if ( direct === undefined ) {
-
-				return this.fromGeometry( geometry );
-
-			}
-
-			direct.verticesNeedUpdate = geometry.verticesNeedUpdate;
-			direct.normalsNeedUpdate = geometry.normalsNeedUpdate;
-			direct.colorsNeedUpdate = geometry.colorsNeedUpdate;
-			direct.uvsNeedUpdate = geometry.uvsNeedUpdate;
-			direct.groupsNeedUpdate = geometry.groupsNeedUpdate;
-
-			geometry.verticesNeedUpdate = false;
-			geometry.normalsNeedUpdate = false;
-			geometry.colorsNeedUpdate = false;
-			geometry.uvsNeedUpdate = false;
-			geometry.groupsNeedUpdate = false;
-
-			geometry = direct;
-
-		}
-
-		if ( geometry.verticesNeedUpdate === true ) {
-
-			const attribute = this.attributes.position;
-
-			if ( attribute !== undefined ) {
-
-				attribute.copyVector3sArray( geometry.vertices );
-				attribute.needsUpdate = true;
-
-			}
-
-			geometry.verticesNeedUpdate = false;
-
-		}
-
-		if ( geometry.normalsNeedUpdate === true ) {
-
-			const attribute = this.attributes.normal;
-
-			if ( attribute !== undefined ) {
-
-				attribute.copyVector3sArray( geometry.normals );
-				attribute.needsUpdate = true;
-
-			}
-
-			geometry.normalsNeedUpdate = false;
-
-		}
-
-		if ( geometry.colorsNeedUpdate === true ) {
-
-			const attribute = this.attributes.color;
-
-			if ( attribute !== undefined ) {
-
-				attribute.copyColorsArray( geometry.colors );
-				attribute.needsUpdate = true;
-
-			}
-
-			geometry.colorsNeedUpdate = false;
-
-		}
-
-		if ( geometry.uvsNeedUpdate ) {
-
-			const attribute = this.attributes.uv;
-
-			if ( attribute !== undefined ) {
-
-				attribute.copyVector2sArray( geometry.uvs );
-				attribute.needsUpdate = true;
-
-			}
-
-			geometry.uvsNeedUpdate = false;
-
-		}
-
-		if ( geometry.lineDistancesNeedUpdate ) {
-
-			const attribute = this.attributes.lineDistance;
-
-			if ( attribute !== undefined ) {
-
-				attribute.copyArray( geometry.lineDistances );
-				attribute.needsUpdate = true;
-
-			}
-
-			geometry.lineDistancesNeedUpdate = false;
-
-		}
-
-		if ( geometry.groupsNeedUpdate ) {
-
-			geometry.computeGroups( object.geometry );
-			this.groups = geometry.groups;
-
-			geometry.groupsNeedUpdate = false;
-
-		}
-
-		return this;
-
-	},
-
-	fromGeometry: function ( geometry ) {
-
-		geometry.__directGeometry = new DirectGeometry().fromGeometry( geometry );
-
-		return this.fromDirectGeometry( geometry.__directGeometry );
-
-	},
-
-	fromDirectGeometry: function ( geometry ) {
-
-		const positions = new Float32Array( geometry.vertices.length * 3 );
-		this.setAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );
-
-		if ( geometry.normals.length > 0 ) {
-
-			const normals = new Float32Array( geometry.normals.length * 3 );
-			this.setAttribute( 'normal', new BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );
-
-		}
-
-		if ( geometry.colors.length > 0 ) {
-
-			const colors = new Float32Array( geometry.colors.length * 3 );
-			this.setAttribute( 'color', new BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );
-
-		}
-
-		if ( geometry.uvs.length > 0 ) {
-
-			const uvs = new Float32Array( geometry.uvs.length * 2 );
-			this.setAttribute( 'uv', new BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );
-
-		}
-
-		if ( geometry.uvs2.length > 0 ) {
-
-			const uvs2 = new Float32Array( geometry.uvs2.length * 2 );
-			this.setAttribute( 'uv2', new BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );
-
-		}
-
-		// groups
-
-		this.groups = geometry.groups;
-
-		// morphs
-
-		for ( const name in geometry.morphTargets ) {
-
-			const array = [];
-			const morphTargets = geometry.morphTargets[ name ];
-
-			for ( let i = 0, l = morphTargets.length; i < l; i ++ ) {
-
-				const morphTarget = morphTargets[ i ];
-
-				const attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );
-				attribute.name = morphTarget.name;
-
-				array.push( attribute.copyVector3sArray( morphTarget.data ) );
-
-			}
-
-			this.morphAttributes[ name ] = array;
-
-		}
-
-		// skinning
-
-		if ( geometry.skinIndices.length > 0 ) {
-
-			const skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );
-			this.setAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );
-
-		}
-
-		if ( geometry.skinWeights.length > 0 ) {
-
-			const skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );
-			this.setAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );
-
-		}
-
-		//
-
-		if ( geometry.boundingSphere !== null ) {
-
-			this.boundingSphere = geometry.boundingSphere.clone();
-
-		}
-
-		if ( geometry.boundingBox !== null ) {
-
-			this.boundingBox = geometry.boundingBox.clone();
-
-		}
-
-		return this;
-
-	},
-
 	computeBoundingBox: function () {
 
 		if ( this.boundingBox === null ) {

+ 0 - 113
src/core/DirectGeometry.d.ts

@@ -1,113 +0,0 @@
-import { Vector3 } from './../math/Vector3';
-import { Color } from './../math/Color';
-import { Vector2 } from './../math/Vector2';
-import { Vector4 } from './../math/Vector4';
-import { Box3 } from './../math/Box3';
-import { Sphere } from './../math/Sphere';
-import { Geometry } from './Geometry';
-import { MorphTarget } from './Geometry';
-
-/**
- * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/DirectGeometry.js|src/core/DirectGeometry.js}
- */
-export class DirectGeometry {
-
-	constructor();
-
-	id: number;
-	uuid: string;
-	name: string;
-	type: string;
-
-	/**
-	 * @default []
-	 */
-	indices: number[];
-
-	/**
-	 * @default []
-	 */
-	vertices: Vector3[];
-
-	/**
-	 * @default []
-	 */
-	normals: Vector3[];
-
-	/**
-	 * @default []
-	 */
-	colors: Color[];
-
-	/**
-	 * @default []
-	 */
-	uvs: Vector2[];
-
-	/**
-	 * @default []
-	 */
-	uvs2: Vector2[];
-
-	/**
-	 * @default []
-	 */
-	groups: { start: number; materialIndex: number }[];
-
-	/**
-	 * @default {}
-	 */
-	morphTargets: MorphTarget[];
-
-	/**
-	 * @default []
-	 */
-	skinWeights: Vector4[];
-
-	/**
-	 * @default []
-	 */
-	skinIndices: Vector4[];
-
-	/**
-	 * @default null
-	 */
-	boundingBox: Box3 | null;
-
-	/**
-	 * @default null
-	 */
-	boundingSphere: Sphere | null;
-
-	/**
-	 * @default false
-	 */
-	verticesNeedUpdate: boolean;
-
-	/**
-	 * @default false
-	 */
-	normalsNeedUpdate: boolean;
-
-	/**
-	 * @default false
-	 */
-	colorsNeedUpdate: boolean;
-
-	/**
-	 * @default false
-	 */
-	uvsNeedUpdate: boolean;
-
-	/**
-	 * @default false
-	 */
-	groupsNeedUpdate: boolean;
-
-	computeBoundingBox(): void;
-	computeBoundingSphere(): void;
-	computeGroups( geometry: Geometry ): void;
-	fromGeometry( geometry: Geometry ): DirectGeometry;
-	dispose(): void;
-
-}

+ 0 - 283
src/core/DirectGeometry.js

@@ -1,283 +0,0 @@
-import { Vector2 } from '../math/Vector2.js';
-
-class DirectGeometry {
-
-	constructor() {
-
-		this.vertices = [];
-		this.normals = [];
-		this.colors = [];
-		this.uvs = [];
-		this.uvs2 = [];
-
-		this.groups = [];
-
-		this.morphTargets = {};
-
-		this.skinWeights = [];
-		this.skinIndices = [];
-
-		// this.lineDistances = [];
-
-		this.boundingBox = null;
-		this.boundingSphere = null;
-
-		// update flags
-
-		this.verticesNeedUpdate = false;
-		this.normalsNeedUpdate = false;
-		this.colorsNeedUpdate = false;
-		this.uvsNeedUpdate = false;
-		this.groupsNeedUpdate = false;
-
-	}
-
-	computeGroups( geometry ) {
-
-		const groups = [];
-
-		let group, i;
-		let materialIndex = undefined;
-
-		const faces = geometry.faces;
-
-		for ( i = 0; i < faces.length; i ++ ) {
-
-			const face = faces[ i ];
-
-			// materials
-
-			if ( face.materialIndex !== materialIndex ) {
-
-				materialIndex = face.materialIndex;
-
-				if ( group !== undefined ) {
-
-					group.count = ( i * 3 ) - group.start;
-					groups.push( group );
-
-				}
-
-				group = {
-					start: i * 3,
-					materialIndex: materialIndex
-				};
-
-			}
-
-		}
-
-		if ( group !== undefined ) {
-
-			group.count = ( i * 3 ) - group.start;
-			groups.push( group );
-
-		}
-
-		this.groups = groups;
-
-	}
-
-	fromGeometry( geometry ) {
-
-		const faces = geometry.faces;
-		const vertices = geometry.vertices;
-		const faceVertexUvs = geometry.faceVertexUvs;
-
-		const hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;
-		const hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;
-
-		// morphs
-
-		const morphTargets = geometry.morphTargets;
-		const morphTargetsLength = morphTargets.length;
-
-		let morphTargetsPosition;
-
-		if ( morphTargetsLength > 0 ) {
-
-			morphTargetsPosition = [];
-
-			for ( let i = 0; i < morphTargetsLength; i ++ ) {
-
-				morphTargetsPosition[ i ] = {
-					name: morphTargets[ i ].name,
-				 	data: []
-				};
-
-			}
-
-			this.morphTargets.position = morphTargetsPosition;
-
-		}
-
-		const morphNormals = geometry.morphNormals;
-		const morphNormalsLength = morphNormals.length;
-
-		let morphTargetsNormal;
-
-		if ( morphNormalsLength > 0 ) {
-
-			morphTargetsNormal = [];
-
-			for ( let i = 0; i < morphNormalsLength; i ++ ) {
-
-				morphTargetsNormal[ i ] = {
-					name: morphNormals[ i ].name,
-				 	data: []
-				};
-
-			}
-
-			this.morphTargets.normal = morphTargetsNormal;
-
-		}
-
-		// skins
-
-		const skinIndices = geometry.skinIndices;
-		const skinWeights = geometry.skinWeights;
-
-		const hasSkinIndices = skinIndices.length === vertices.length;
-		const hasSkinWeights = skinWeights.length === vertices.length;
-
-		//
-
-		if ( vertices.length > 0 && faces.length === 0 ) {
-
-			console.error( 'THREE.DirectGeometry: Faceless geometries are not supported.' );
-
-		}
-
-		for ( let i = 0; i < faces.length; i ++ ) {
-
-			const face = faces[ i ];
-
-			this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] );
-
-			const vertexNormals = face.vertexNormals;
-
-			if ( vertexNormals.length === 3 ) {
-
-				this.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] );
-
-			} else {
-
-				const normal = face.normal;
-
-				this.normals.push( normal, normal, normal );
-
-			}
-
-			const vertexColors = face.vertexColors;
-
-			if ( vertexColors.length === 3 ) {
-
-				this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );
-
-			} else {
-
-				const color = face.color;
-
-				this.colors.push( color, color, color );
-
-			}
-
-			if ( hasFaceVertexUv === true ) {
-
-				const vertexUvs = faceVertexUvs[ 0 ][ i ];
-
-				if ( vertexUvs !== undefined ) {
-
-					this.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );
-
-				} else {
-
-					console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );
-
-					this.uvs.push( new Vector2(), new Vector2(), new Vector2() );
-
-				}
-
-			}
-
-			if ( hasFaceVertexUv2 === true ) {
-
-				const vertexUvs = faceVertexUvs[ 1 ][ i ];
-
-				if ( vertexUvs !== undefined ) {
-
-					this.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );
-
-				} else {
-
-					console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );
-
-					this.uvs2.push( new Vector2(), new Vector2(), new Vector2() );
-
-				}
-
-			}
-
-			// morphs
-
-			for ( let j = 0; j < morphTargetsLength; j ++ ) {
-
-				const morphTarget = morphTargets[ j ].vertices;
-
-				morphTargetsPosition[ j ].data.push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );
-
-			}
-
-			for ( let j = 0; j < morphNormalsLength; j ++ ) {
-
-				const morphNormal = morphNormals[ j ].vertexNormals[ i ];
-
-				morphTargetsNormal[ j ].data.push( morphNormal.a, morphNormal.b, morphNormal.c );
-
-			}
-
-			// skins
-
-			if ( hasSkinIndices ) {
-
-				this.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] );
-
-			}
-
-			if ( hasSkinWeights ) {
-
-				this.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] );
-
-			}
-
-		}
-
-		this.computeGroups( geometry );
-
-		this.verticesNeedUpdate = geometry.verticesNeedUpdate;
-		this.normalsNeedUpdate = geometry.normalsNeedUpdate;
-		this.colorsNeedUpdate = geometry.colorsNeedUpdate;
-		this.uvsNeedUpdate = geometry.uvsNeedUpdate;
-		this.groupsNeedUpdate = geometry.groupsNeedUpdate;
-
-		if ( geometry.boundingSphere !== null ) {
-
-			this.boundingSphere = geometry.boundingSphere.clone();
-
-		}
-
-		if ( geometry.boundingBox !== null ) {
-
-			this.boundingBox = geometry.boundingBox.clone();
-
-		}
-
-		return this;
-
-	}
-
-}
-
-
-export { DirectGeometry };

+ 2 - 3
src/core/Object3D.d.ts

@@ -7,7 +7,6 @@ import { Layers } from './Layers';
 import { WebGLRenderer } from './../renderers/WebGLRenderer';
 import { Scene } from './../scenes/Scene';
 import { Camera } from './../cameras/Camera';
-import { Geometry } from './Geometry';
 import { Material } from './../materials/Material';
 import { Group } from './../objects/Group';
 import { Raycaster } from './Raycaster';
@@ -192,7 +191,7 @@ export class Object3D extends EventDispatcher {
 		renderer: WebGLRenderer,
 		scene: Scene,
 		camera: Camera,
-		geometry: Geometry | BufferGeometry,
+		geometry: BufferGeometry,
 		material: Material,
 		group: Group
 	) => void;
@@ -204,7 +203,7 @@ export class Object3D extends EventDispatcher {
 		renderer: WebGLRenderer,
 		scene: Scene,
 		camera: Camera,
-		geometry: Geometry | BufferGeometry,
+		geometry: BufferGeometry,
 		material: Material,
 		group: Group
 	) => void;

+ 0 - 14
src/extras/core/CurvePath.d.ts

@@ -1,5 +1,4 @@
 import { Curve } from './Curve';
-import { Geometry } from './../../core/Geometry';
 import { Vector } from './../../math/Vector2';
 
 export class CurvePath<T extends Vector> extends Curve<T> {
@@ -26,17 +25,4 @@ export class CurvePath<T extends Vector> extends Curve<T> {
 	getPoint( t: number ): T;
 	getCurveLengths(): number[];
 
-	/**
-	 * @deprecated Use {@link Geometry#setFromPoints new THREE.Geometry().setFromPoints( points )} instead.
-	 */
-	createPointsGeometry( divisions: number ): Geometry;
-	/**
-	 * @deprecated Use {@link Geometry#setFromPoints new THREE.Geometry().setFromPoints( points )} instead.
-	 */
-	createSpacedPointsGeometry( divisions: number ): Geometry;
-	/**
-	 * @deprecated Use {@link Geometry#setFromPoints new THREE.Geometry().setFromPoints( points )} instead.
-	 */
-	createGeometry( points: T[] ): Geometry;
-
 }

+ 3 - 7
src/objects/InstancedMesh.d.ts

@@ -1,4 +1,3 @@
-import { Geometry } from './../core/Geometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Material } from './../materials/Material';
 import { BufferAttribute } from './../core/BufferAttribute';
@@ -6,14 +5,11 @@ import { Mesh } from './Mesh';
 import { Matrix4 } from './../math/Matrix4';
 import { Color } from './../math/Color';
 
-export class InstancedMesh <
-	TGeometry extends Geometry | BufferGeometry = Geometry | BufferGeometry,
-	TMaterial extends Material | Material[] = Material | Material[]
-> extends Mesh<TGeometry, TMaterial> {
+export class InstancedMesh extends Mesh {
 
 	constructor(
-		geometry: TGeometry,
-		material: TMaterial,
+		geometry: BufferGeometry,
+		material: Material | Material[],
 		count: number
 	);
 

+ 5 - 9
src/objects/Line.d.ts

@@ -1,22 +1,18 @@
-import { Geometry } from './../core/Geometry';
 import { Material } from './../materials/Material';
 import { Raycaster } from './../core/Raycaster';
 import { Object3D } from './../core/Object3D';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Intersection } from '../core/Raycaster';
 
-export class Line <
-	TGeometry extends Geometry | BufferGeometry = Geometry | BufferGeometry,
-	TMaterial extends Material | Material[] = Material | Material[]
-> extends Object3D {
+export class Line extends Object3D {
 
 	constructor(
-		geometry?: TGeometry,
-		material?: TMaterial
+		geometry?: BufferGeometry,
+		material?: Material | Material[]
 	);
 
-	geometry: TGeometry;
-	material: TMaterial;
+	geometry: BufferGeometry;
+	material: Material | Material[];
 
 	type: 'Line' | 'LineLoop' | 'LineSegments' | string;
 	readonly isLine: true;

+ 3 - 7
src/objects/LineLoop.d.ts

@@ -1,16 +1,12 @@
 import { Line } from './Line';
-import { Geometry } from './../core/Geometry';
 import { Material } from './../materials/Material';
 import { BufferGeometry } from '../core/BufferGeometry';
 
-export class LineLoop <
-	TGeometry extends Geometry | BufferGeometry = Geometry | BufferGeometry,
-	TMaterial extends Material | Material[] = Material | Material[]
-> extends Line<TGeometry, TMaterial> {
+export class LineLoop extends Line {
 
 	constructor(
-		geometry?: TGeometry,
-		material?: TMaterial
+		geometry?: BufferGeometry,
+		material?: Material | Material[]
 	);
 
 	type: 'LineLoop';

+ 3 - 7
src/objects/LineSegments.d.ts

@@ -1,4 +1,3 @@
-import { Geometry } from './../core/Geometry';
 import { Material } from './../materials/Material';
 import { Line } from './Line';
 import { BufferGeometry } from '../core/BufferGeometry';
@@ -12,14 +11,11 @@ export const LineStrip: number;
  */
 export const LinePieces: number;
 
-export class LineSegments <
-	TGeometry extends Geometry | BufferGeometry = Geometry | BufferGeometry,
-	TMaterial extends Material | Material[] = Material | Material[]
-> extends Line<TGeometry, TMaterial> {
+export class LineSegments extends Line {
 
 	constructor(
-		geometry?: TGeometry,
-		material?: TMaterial
+		geometry?: BufferGeometry,
+		material?: Material | Material[]
 	);
 
 	/**

+ 5 - 9
src/objects/Mesh.d.ts

@@ -1,22 +1,18 @@
-import { Geometry } from './../core/Geometry';
 import { Material } from './../materials/Material';
 import { Raycaster } from './../core/Raycaster';
 import { Object3D } from './../core/Object3D';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Intersection } from '../core/Raycaster';
 
-export class Mesh <
-	TGeometry extends Geometry | BufferGeometry = Geometry | BufferGeometry,
-	TMaterial extends Material | Material[] = Material | Material[]
-> extends Object3D {
+export class Mesh extends Object3D {
 
 	constructor(
-		geometry?: TGeometry,
-		material?: TMaterial
+		geometry?: BufferGeometry,
+		material?: Material | Material[]
 	);
 
-	geometry: TGeometry;
-	material: TMaterial;
+	geometry: BufferGeometry;
+	material: Material | Material[];
 	morphTargetInfluences?: number[];
 	morphTargetDictionary?: { [key: string]: number };
 	readonly isMesh: true;

+ 7 - 11
src/objects/Points.d.ts

@@ -1,4 +1,3 @@
-import { Geometry } from './../core/Geometry';
 import { Material } from './../materials/Material';
 import { Raycaster } from './../core/Raycaster';
 import { Object3D } from './../core/Object3D';
@@ -8,18 +7,15 @@ import { Intersection } from '../core/Raycaster';
 /**
  * A class for displaying points. The points are rendered by the WebGLRenderer using gl.POINTS.
  */
-export class Points <
-	TGeometry extends Geometry | BufferGeometry = Geometry | BufferGeometry,
-	TMaterial extends Material | Material[] = Material | Material[]
-> extends Object3D {
+export class Points extends Object3D {
 
 	/**
-	 * @param geometry An instance of Geometry or BufferGeometry.
+	 * @param geometry An instance of BufferGeometry.
 	 * @param material An instance of Material (optional).
 	 */
 	constructor(
-		geometry?: TGeometry,
-		material?: TMaterial
+		geometry?: BufferGeometry,
+		material?: Material | Material[]
 	);
 
 	type: 'Points';
@@ -28,14 +24,14 @@ export class Points <
 	readonly isPoints: true;
 
 	/**
-	 * An instance of Geometry or BufferGeometry, where each vertex designates the position of a particle in the system.
+	 * An instance of BufferGeometry, where each vertex designates the position of a particle in the system.
 	 */
-	geometry: TGeometry;
+	geometry: BufferGeometry;
 
 	/**
 	 * An instance of Material, defining the object's appearance. Default is a PointsMaterial with randomised colour.
 	 */
-	material: TMaterial;
+	material: Material | Material[];
 
 	raycast( raycaster: Raycaster, intersects: Intersection[] ): void;
 	updateMorphTargets(): void;

+ 3 - 7
src/objects/SkinnedMesh.d.ts

@@ -1,18 +1,14 @@
-import { Geometry } from './../core/Geometry';
 import { Material } from './../materials/Material';
 import { Matrix4 } from './../math/Matrix4';
 import { Skeleton } from './Skeleton';
 import { Mesh } from './Mesh';
 import { BufferGeometry } from '../core/BufferGeometry';
 
-export class SkinnedMesh <
-	TGeometry extends Geometry | BufferGeometry = Geometry | BufferGeometry,
-	TMaterial extends Material | Material[] = Material | Material[]
-> extends Mesh<TGeometry, TMaterial> {
+export class SkinnedMesh extends Mesh {
 
 	constructor(
-		geometry?: TGeometry,
-		material?: TMaterial,
+		geometry?: BufferGeometry,
+		material?: Material | Material[],
 		useVertexTexture?: boolean
 	);
 

+ 1 - 2
src/renderers/WebGLRenderer.d.ts

@@ -17,7 +17,6 @@ import { Material } from './../materials/Material';
 import { ToneMapping, ShadowMapType, CullFace, TextureEncoding } from '../constants';
 import { WebXRManager } from '../renderers/webxr/WebXRManager';
 import { RenderTarget } from './webgl/WebGLRenderLists';
-import { Geometry } from './../core/Geometry';
 import { BufferGeometry } from './../core/BufferGeometry';
 import { Texture } from '../textures/Texture';
 import { XRAnimationLoopCallback } from './webxr/WebXR';
@@ -334,7 +333,7 @@ export class WebGLRenderer implements Renderer {
 	renderBufferDirect(
 		camera: Camera,
 		scene: Scene,
-		geometry: Geometry | BufferGeometry,
+		geometry: BufferGeometry,
 		material: Material,
 		object: Object3D,
 		geometryGroup: any

+ 3 - 4
src/renderers/webgl/WebGLGeometries.d.ts

@@ -2,15 +2,14 @@ import { WebGLAttributes } from './WebGLAttributes';
 import { WebGLInfo } from './WebGLInfo';
 import { BufferAttribute } from '../../core/BufferAttribute';
 import { BufferGeometry } from '../../core/BufferGeometry';
-import { Geometry } from '../../core/Geometry';
 import { Object3D } from '../../core/Object3D';
 
 export class WebGLGeometries {
 
 	constructor( gl: WebGLRenderingContext, attributes: WebGLAttributes, info: WebGLInfo );
 
-	get( object: Object3D, geometry: Geometry | BufferGeometry ): BufferGeometry;
-	update( geometry: Geometry | BufferGeometry ): void;
-	getWireframeAttribute( geometry: Geometry | BufferGeometry ): BufferAttribute;
+	get( object: Object3D, geometry: BufferGeometry ): BufferGeometry;
+	update( geometry: BufferGeometry ): void;
+	getWireframeAttribute( geometry: BufferGeometry ): BufferAttribute;
 
 }

+ 2 - 9
src/renderers/webgl/WebGLGeometries.js

@@ -1,5 +1,4 @@
 import { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute.js';
-import { BufferGeometry } from '../../core/BufferGeometry.js';
 import { arrayMax } from '../../utils.js';
 
 function WebGLGeometries( gl, attributes, info, bindingStates ) {
@@ -63,15 +62,9 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
 
 			buffergeometry = geometry;
 
-		} else if ( geometry.isGeometry ) {
-
-			if ( geometry._bufferGeometry === undefined ) {
-
-				geometry._bufferGeometry = new BufferGeometry().setFromObject( object );
-
-			}
+		} else {
 
-			buffergeometry = geometry._bufferGeometry;
+			console.log( 'TODO: Remove this', geometry );
 
 		}
 

+ 0 - 6
src/renderers/webgl/WebGLObjects.js

@@ -13,12 +13,6 @@ function WebGLObjects( gl, geometries, attributes, info ) {
 
 		if ( updateMap.get( buffergeometry ) !== frame ) {
 
-			if ( geometry.isGeometry ) {
-
-				buffergeometry.updateFromObject( object );
-
-			}
-
 			geometries.update( buffergeometry );
 
 			updateMap.set( buffergeometry, frame );

+ 0 - 309
test/unit/src/core/BufferGeometry.tests.js

@@ -6,16 +6,9 @@ import {
 	Uint16BufferAttribute,
 	Uint32BufferAttribute
 } from '../../../../src/core/BufferAttribute';
-import { Color } from '../../../../src/math/Color';
-import { Vector2 } from '../../../../src/math/Vector2';
 import { Vector3 } from '../../../../src/math/Vector3';
-import { Vector4 } from '../../../../src/math/Vector4';
 import { Matrix4 } from '../../../../src/math/Matrix4';
 import { Sphere } from '../../../../src/math/Sphere';
-import { Geometry } from '../../../../src/core/Geometry';
-import { Face3 } from '../../../../src/core/Face3';
-import { Mesh } from '../../../../src/objects/Mesh';
-import { Line } from '../../../../src/objects/Line.js';
 import {
 	x,
 	y,
@@ -86,36 +79,6 @@ function getNormalsForVertices( vertices, assert ) {
 
 }
 
-function comparePositions( pos, v ) {
-
-	return (
-		pos[ 0 ] === v[ 0 ].x && pos[ 1 ] === v[ 0 ].y && pos[ 2 ] === v[ 0 ].z &&
-		pos[ 3 ] === v[ 1 ].x && pos[ 4 ] === v[ 1 ].y && pos[ 5 ] === v[ 1 ].z &&
-		pos[ 6 ] === v[ 2 ].x && pos[ 7 ] === v[ 2 ].y && pos[ 8 ] === v[ 2 ].z
-	);
-
-}
-
-function compareColors( col, c ) {
-
-	return (
-		col[ 0 ] === c[ 0 ].r && col[ 1 ] === c[ 0 ].g && col[ 2 ] === c[ 0 ].b &&
-		col[ 3 ] === c[ 1 ].r && col[ 4 ] === c[ 1 ].g && col[ 5 ] === c[ 1 ].b &&
-		col[ 6 ] === c[ 2 ].r && col[ 7 ] === c[ 2 ].g && col[ 8 ] === c[ 2 ].b
-	);
-
-}
-
-function compareUvs( uvs, u ) {
-
-	return (
-		uvs[ 0 ] === u[ 0 ].x && uvs[ 1 ] === u[ 0 ].y &&
-		uvs[ 2 ] === u[ 1 ].x && uvs[ 3 ] === u[ 1 ].y &&
-		uvs[ 4 ] === u[ 2 ].x && uvs[ 5 ] === u[ 2 ].y
-	);
-
-}
-
 export default QUnit.module( 'Core', () => {
 
 	QUnit.module( 'BufferGeometry', () => {
@@ -356,278 +319,6 @@ export default QUnit.module( 'Core', () => {
 
 		} );
 
-		QUnit.test( "setFromObject", ( assert ) => {
-
-			var lineGeo = new Geometry();
-			lineGeo.vertices.push(
-				new Vector3( - 10, 0, 0 ),
-				new Vector3( 0, 10, 0 ),
-				new Vector3( 10, 0, 0 )
-			);
-
-			lineGeo.colors.push(
-				new Color( 1, 0, 0 ),
-				new Color( 0, 1, 0 ),
-				new Color( 0, 0, 1 )
-			);
-
-			var line = new Line( lineGeo, null );
-			var geometry = new BufferGeometry().setFromObject( line );
-
-			var pos = geometry.attributes.position.array;
-			var col = geometry.attributes.color.array;
-			var v = lineGeo.vertices;
-			var c = lineGeo.colors;
-
-			assert.ok(
-				// position exists
-				pos !== undefined &&
-
-				// vertex arrays have the same size
-				v.length * 3 === pos.length &&
-
-				// there are three complete vertices (each vertex contains three values)
-				geometry.attributes.position.count === 3 &&
-
-				// check if both arrays contains the same data
-				pos[ 0 ] === v[ 0 ].x && pos[ 1 ] === v[ 0 ].y && pos[ 2 ] === v[ 0 ].z &&
-				pos[ 3 ] === v[ 1 ].x && pos[ 4 ] === v[ 1 ].y && pos[ 5 ] === v[ 1 ].z &&
-				pos[ 6 ] === v[ 2 ].x && pos[ 7 ] === v[ 2 ].y && pos[ 8 ] === v[ 2 ].z
-				, "positions are equal" );
-
-			assert.ok(
-				// color exists
-				col !== undefined &&
-
-				// color arrays have the same size
-				c.length * 3 === col.length &&
-
-				// there are three complete colors (each color contains three values)
-				geometry.attributes.color.count === 3 &&
-
-				// check if both arrays contains the same data
-				col[ 0 ] === c[ 0 ].r && col[ 1 ] === c[ 0 ].g && col[ 2 ] === c[ 0 ].b &&
-				col[ 3 ] === c[ 1 ].r && col[ 4 ] === c[ 1 ].g && col[ 5 ] === c[ 1 ].b &&
-				col[ 6 ] === c[ 2 ].r && col[ 7 ] === c[ 2 ].g && col[ 8 ] === c[ 2 ].b
-				, "colors are equal" );
-
-		} );
-		QUnit.test( "setFromObject (more)", ( assert ) => {
-
-			var lineGeo = new Geometry();
-			lineGeo.vertices.push(
-				new Vector3( - 10, 0, 0 ),
-				new Vector3( 0, 10, 0 ),
-				new Vector3( 10, 0, 0 )
-			);
-
-			lineGeo.colors.push(
-				new Color( 1, 0, 0 ),
-				new Color( 0, 1, 0 ),
-				new Color( 0, 0, 1 )
-			);
-
-			lineGeo.computeBoundingBox();
-			lineGeo.computeBoundingSphere();
-
-			var line = new Line( lineGeo );
-			var geometry = new BufferGeometry().setFromObject( line );
-
-			assert.ok( geometry.boundingBox.equals( lineGeo.boundingBox ), "BoundingBox was set correctly" );
-			assert.ok( geometry.boundingSphere.equals( lineGeo.boundingSphere ), "BoundingSphere was set correctly" );
-
-			var pos = geometry.attributes.position.array;
-			var col = geometry.attributes.color.array;
-			var v = lineGeo.vertices;
-			var c = lineGeo.colors;
-
-			// adapted from setFromObject QUnit.test (way up)
-			assert.notStrictEqual( pos, undefined, "Position attribute exists" );
-			assert.strictEqual( v.length * 3, pos.length, "Vertex arrays have the same size" );
-			assert.strictEqual( geometry.attributes.position.count, 3, "Correct number of vertices" );
-			assert.ok( comparePositions( pos, v ), "Positions are identical" );
-
-			assert.notStrictEqual( col, undefined, "Color attribute exists" );
-			assert.strictEqual( c.length * 3, col.length, "Color arrays have the same size" );
-			assert.strictEqual( geometry.attributes.color.count, 3, "Correct number of colors" );
-			assert.ok( compareColors( col, c ), "Colors are identical" );
-
-			// setFromObject with a Mesh as object
-			lineGeo.faces.push( new Face3( 0, 1, 2 ) );
-			var lineMesh = new Mesh( lineGeo );
-			var geometry = new BufferGeometry().setFromObject( lineMesh );
-
-			// no colors
-			var pos = geometry.attributes.position.array;
-			var v = lineGeo.vertices;
-
-			assert.notStrictEqual( pos, undefined, "Mesh: position attribute exists" );
-			assert.strictEqual( v.length * 3, pos.length, "Mesh: vertex arrays have the same size" );
-			assert.strictEqual( geometry.attributes.position.count, 3, "Mesh: correct number of vertices" );
-			assert.ok( comparePositions( pos, v ), "Mesh: positions are identical" );
-
-		} );
-
-		QUnit.test( "updateFromObject", ( assert ) => {
-
-			var geo = new Geometry();
-
-			geo.vertices.push(
-				new Vector3( - 10, 0, 0 ),
-				new Vector3( 0, 10, 0 ),
-				new Vector3( 10, 0, 0 )
-			);
-
-			geo.faces.push( new Face3( 0, 1, 2 ) );
-
-			geo.faces[ 0 ].vertexColors.push(
-				new Color( 1, 0, 0 ),
-				new Color( 0, 1, 0 ),
-				new Color( 0, 0, 1 )
-			);
-
-			geo.faceVertexUvs[ 0 ] = [
-				[
-					new Vector2( 0, 0 ),
-					new Vector2( 1, 0 ),
-					new Vector2( 1, 1 )
-				]
-			];
-
-			geo.computeFaceNormals();
-			geo.computeVertexNormals();
-
-			geo.verticesNeedUpdate = true;
-			geo.normalsNeedUpdate = true;
-			geo.colorsNeedUpdate = true;
-			geo.uvsNeedUpdate = true;
-			geo.groupsNeedUpdate = true;
-
-			var mesh = new Mesh( geo );
-			var geometry = new BufferGeometry();
-
-			geometry.updateFromObject( mesh ); // first call to create the underlying structure (DirectGeometry)
-			geometry.updateFromObject( mesh ); // second time to actually go thru the motions and update
-
-			var pos = geometry.attributes.position.array;
-			var col = geometry.attributes.color.array;
-			var norm = geometry.attributes.normal.array;
-			var uvs = geometry.attributes.uv.array;
-			var v = geo.vertices;
-			var c = geo.faces[ 0 ].vertexColors;
-			var n = geo.faces[ 0 ].vertexNormals;
-			var u = geo.faceVertexUvs[ 0 ][ 0 ];
-
-			assert.notStrictEqual( pos, undefined, "Position attribute exists" );
-			assert.strictEqual( v.length * 3, pos.length, "Both arrays have the same size" );
-			assert.strictEqual( geometry.attributes.position.count, v.length, "Correct number of vertices" );
-			assert.ok( comparePositions( pos, v ), "Positions are identical" );
-
-			assert.notStrictEqual( col, undefined, "Color attribute exists" );
-			assert.strictEqual( c.length * 3, col.length, "Both arrays have the same size" );
-			assert.strictEqual( geometry.attributes.color.count, c.length, "Correct number of colors" );
-			assert.ok( compareColors( col, c ), "Colors are identical" );
-
-			assert.notStrictEqual( norm, undefined, "Normal attribute exists" );
-			assert.strictEqual( n.length * 3, norm.length, "Both arrays have the same size" );
-			assert.strictEqual( geometry.attributes.normal.count, n.length, "Correct number of normals" );
-			assert.ok( comparePositions( norm, n ), "Normals are identical" );
-
-			assert.notStrictEqual( uvs, undefined, "UV attribute exists" );
-			assert.strictEqual( u.length * 2, uvs.length, "Both arrays have the same size" );
-			assert.strictEqual( geometry.attributes.uv.count, u.length, "Correct number of UV coordinates" );
-			assert.ok( compareUvs( uvs, u ), "UVs are identical" );
-
-		} );
-
-		QUnit.test( "fromGeometry/fromDirectGeometry", ( assert ) => {
-
-			// geometry definition
-
-			var geometry = new Geometry();
-
-			// vertices
-
-			var v1 = new Vector3( 1, - 1, 0 );
-			var v2 = new Vector3( 1, 1, 0 );
-			var v3 = new Vector3( - 1, 1, 0 );
-			var v4 = new Vector3( - 1, - 1, 0 );
-
-			// faces, normals and colors
-
-			geometry.vertices.push( v1, v2, v3, v4 );
-
-			var f1 = new Face3( 0, 1, 2 );
-			f1.normal.set( 0, 0, 1 );
-			f1.color.set( 0xff0000 );
-			var f2 = new Face3( 2, 3, 0 );
-			f2.normal.set( 0, 0, 1 );
-			f2.color.set( 0xff0000 );
-
-			geometry.faces.push( f1, f2 );
-
-			// uvs
-
-			var uvs = geometry.faceVertexUvs[ 0 ];
-			uvs.length = 0;
-
-			uvs.push( [
-				new Vector2( 1, 0 ),
-			  new Vector2( 1, 1 ),
-			  new Vector2( 0, 1 )
-			] );
-
-			uvs.push( [
-				new Vector2( 0, 1 ),
-			  new Vector2( 0, 0 ),
-			  new Vector2( 1, 0 )
-			] );
-
-			// skin weights
-
-			var sw1 = new Vector4( 0.8, 0.2, 0, 0 );
-			var sw2 = new Vector4( 0.7, 0.2, 0.1, 0 );
-			var sw3 = new Vector4( 0.8, 0.1, 0.1, 0 );
-			var sw4 = new Vector4( 1, 0, 0, 0 );
-
-			geometry.skinWeights.push( sw1, sw2, sw3, sw4 );
-
-			 // skin indices
-
-			var si1 = new Vector4( 0, 1, 2, 3 );
-			var si2 = new Vector4( 2, 3, 4, 5 );
-			var si3 = new Vector4( 4, 5, 6, 7 );
-			var si4 = new Vector4( 6, 7, 8, 9 );
-
-			geometry.skinIndices.push( si1, si2, si3, si4 );
-
-			// create BufferGeometry
-
-			var bufferGeometry = new BufferGeometry().fromGeometry( geometry );
-
-			// expected values
-
-			var vertices = new Float32Array( [ 1, - 1, 0, 1, 1, 0, - 1, 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, - 1, 0 ] );
-			var normals = new Float32Array( [ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 ] );
-			var colors = new Float32Array( [ 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 ] );
-			var uvs = new Float32Array( [ 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0 ] );
-			var skinIndices = new Float32Array( [ 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 4, 5, 6, 7, 6, 7, 8, 9, 0, 1, 2, 3 ] );
-			var skindWeights = new Float32Array( [
-				0.8, 0.2, 0, 0, 0.7, 0.2, 0.1, 0, 0.8, 0.1, 0.1, 0,
-				0.8, 0.1, 0.1, 0, 1, 0, 0, 0, 0.8, 0.2, 0, 0
-			] );
-
-			var attributes = bufferGeometry.attributes;
-
-			assert.deepEqual( attributes.position.array, vertices, "Vertices are as expected" );
-			assert.deepEqual( attributes.normal.array, normals, "Normals are as expected" );
-			assert.deepEqual( attributes.color.array, colors, "Colors are as expected" );
-			assert.deepEqual( attributes.uv.array, uvs, "Texture coordinates are as expected" );
-			assert.deepEqual( attributes.skinIndex.array, skinIndices, "Skin indices are as expected" );
-			assert.deepEqual( attributes.skinWeight.array, skindWeights, "Skin weights are as expected" );
-
-		} );
-
 		QUnit.test( "computeBoundingBox", ( assert ) => {
 
 			var bb = getBBForVertices( [ - 1, - 2, - 3, 13, - 2, - 3.5, - 1, - 20, 0, - 4, 5, 6 ] );

+ 0 - 191
test/unit/src/core/DirectGeometry.tests.js

@@ -1,191 +0,0 @@
-/* global QUnit */
-
-import { DirectGeometry } from '../../../../src/core/DirectGeometry';
-import { Vector2 } from '../../../../src/math/Vector2';
-import { Vector3 } from '../../../../src/math/Vector3';
-import { Vector4 } from '../../../../src/math/Vector4';
-import { Color } from '../../../../src/math/Color';
-import { Face3 } from '../../../../src/core/Face3';
-import { Geometry } from '../../../../src/core/Geometry';
-
-export default QUnit.module( 'Core', () => {
-
-	QUnit.module( 'DirectGeometry', () => {
-
-		// INSTANCING
-		QUnit.todo( "Instancing", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		// PUBLIC STUFF
-		QUnit.test( "computeGroups", ( assert ) => {
-
-			var a = new DirectGeometry();
-			var b = new Geometry();
-			var expected = [
-				{ start: 0, materialIndex: 0, count: 3 },
-				{ start: 3, materialIndex: 1, count: 3 },
-				{ start: 6, materialIndex: 2, count: 6 }
-			];
-
-			// we only care for materialIndex
-			b.faces.push(
-				new Face3( 0, 0, 0, undefined, undefined, 0 ),
-				new Face3( 0, 0, 0, undefined, undefined, 1 ),
-				new Face3( 0, 0, 0, undefined, undefined, 2 ),
-				new Face3( 0, 0, 0, undefined, undefined, 2 )
-			);
-
-			a.computeGroups( b );
-
-			assert.deepEqual( a.groups, expected, "Groups are as expected" );
-
-		} );
-
-		QUnit.test( "fromGeometry", ( assert ) => {
-
-			// geometry definition
-
-			var geometry = new Geometry();
-
-			// vertices
-
-			var v1 = new Vector3( 1, - 1, 0 );
-			var v2 = new Vector3( 1, 1, 0 );
-			var v3 = new Vector3( - 1, 1, 0 );
-			var v4 = new Vector3( - 1, - 1, 0 );
-
-			// faces, normals and colors
-
-			geometry.vertices.push( v1, v2, v3, v4 );
-
-			var f1 = new Face3( 0, 1, 2 );
-			f1.normal.set( 0, 0, 1 );
-			f1.color.set( 0xff0000 );
-			var f2 = new Face3( 2, 3, 0 );
-			f2.normal.set( 0, 0, 1 );
-			f2.color.set( 0xff0000 );
-
-			geometry.faces.push( f1, f2 );
-
-			// uvs
-
-			var uvs = geometry.faceVertexUvs[ 0 ];
-			uvs.length = 0;
-
-			uvs.push( [
-				new Vector2( 1, 0 ),
-				new Vector2( 1, 1 ),
-				new Vector2( 0, 1 )
-			] );
-
-			uvs.push( [
-				new Vector2( 0, 1 ),
-				new Vector2( 0, 0 ),
-				new Vector2( 1, 0 )
-			] );
-
-			// skin weights
-
-			var sw1 = new Vector4( 0.8, 0.2, 0, 0 );
-			var sw2 = new Vector4( 0.7, 0.2, 0.1, 0 );
-			var sw3 = new Vector4( 0.8, 0.1, 0.1, 0 );
-			var sw4 = new Vector4( 1, 0, 0, 0 );
-
-			geometry.skinWeights.push( sw1, sw2, sw3, sw4 );
-
-			// skin indices
-
-			var si1 = new Vector4( 0, 1, 2, 3 );
-			var si2 = new Vector4( 2, 3, 4, 5 );
-			var si3 = new Vector4( 4, 5, 6, 7 );
-			var si4 = new Vector4( 6, 7, 8, 9 );
-
-			geometry.skinIndices.push( si1, si2, si3, si4 );
-
-			// create DirectGeometry
-
-			var directGeometry = new DirectGeometry().fromGeometry( geometry );
-
-			// expected values
-
-			var vertices = [
-				// first face
-				new Vector3( 1, - 1, 0 ),
-				new Vector3( 1, 1, 0 ),
-				new Vector3( - 1, 1, 0 ),
-				// second face
-				new Vector3( - 1, 1, 0 ),
-				new Vector3( - 1, - 1, 0 ),
-				new Vector3( 1, - 1, 0 )
-			];
-
-			var normals = [
-				// first face
-				new Vector3( 0, 0, 1 ),
-				new Vector3( 0, 0, 1 ),
-				new Vector3( 0, 0, 1 ),
-				// second face
-				new Vector3( 0, 0, 1 ),
-				new Vector3( 0, 0, 1 ),
-				new Vector3( 0, 0, 1 )
-			];
-
-			var colors = [
-				// first face
-				new Color( 1, 0, 0 ),
-				new Color( 1, 0, 0 ),
-				new Color( 1, 0, 0 ),
-				// second face
-				new Color( 1, 0, 0 ),
-				new Color( 1, 0, 0 ),
-				new Color( 1, 0, 0 )
-			];
-
-			var uvs = [
-				// first face
-				new Vector2( 1, 0 ),
-				new Vector2( 1, 1 ),
-				new Vector2( 0, 1 ),
-				// second face
-				new Vector2( 0, 1 ),
-				new Vector2( 0, 0 ),
-				new Vector2( 1, 0 )
-			];
-
-			var skinIndices = [
-				// first face
-				new Vector4( 0, 1, 2, 3 ),
-				new Vector4( 2, 3, 4, 5 ),
-				new Vector4( 4, 5, 6, 7 ),
-				// second face
-				new Vector4( 4, 5, 6, 7 ),
-				new Vector4( 6, 7, 8, 9 ),
-				new Vector4( 0, 1, 2, 3 )
-			];
-
-			var skinWeights = [
-				// first face
-				new Vector4( 0.8, 0.2, 0, 0 ),
-				new Vector4( 0.7, 0.2, 0.1, 0 ),
-				new Vector4( 0.8, 0.1, 0.1, 0 ),
-				// second face
-				new Vector4( 0.8, 0.1, 0.1, 0 ),
-				new Vector4( 1, 0, 0, 0 ),
-				new Vector4( 0.8, 0.2, 0, 0 )
-			];
-
-			assert.deepEqual( directGeometry.vertices, vertices, "Vertices are as expected" );
-			assert.deepEqual( directGeometry.normals, normals, "Normals are as expected" );
-			assert.deepEqual( directGeometry.colors, colors, "Colors are as expected" );
-			assert.deepEqual( directGeometry.uvs, uvs, "Texture coordinates are as expected" );
-			assert.deepEqual( directGeometry.skinIndices, skinIndices, "Skin indices are as expected" );
-			assert.deepEqual( directGeometry.skinWeights, skinWeights, "Skin weights are as expected" );
-
-		} );
-
-	} );
-
-} );

+ 0 - 462
test/unit/src/core/Geometry.tests.js

@@ -1,462 +0,0 @@
-/* global QUnit */
-
-import { Geometry } from '../../../../src/core/Geometry';
-import { BufferAttribute } from '../../../../src/core/BufferAttribute';
-import { BufferGeometry } from '../../../../src/core/BufferGeometry';
-import { BoxGeometry } from '../../../../src/geometries/BoxGeometry';
-import { DodecahedronGeometry } from '../../../../src/geometries/DodecahedronGeometry';
-import { Vector3 } from '../../../../src/math/Vector3';
-import { Matrix4 } from '../../../../src/math/Matrix4';
-import { Face3 } from '../../../../src/core/Face3';
-import {
-	x,
-	y,
-	z,
-	eps
-} from '../math/Constants.tests';
-
-function getGeometryByParams( x1, y1, z1, x2, y2, z2, x3, y3, z3 ) {
-
-	var geometry = new Geometry();
-
-	// a triangle
-	geometry.vertices = [
-		new Vector3( x1, y1, z1 ),
-		new Vector3( x2, y2, z2 ),
-		new Vector3( x3, y3, z3 )
-	];
-
-	return geometry;
-
-}
-
-function getGeometry() {
-
-	return getGeometryByParams( - 0.5, 0, 0, 0.5, 0, 0, 0, 1, 0 );
-
-}
-
-export default QUnit.module( 'Core', () => {
-
-	QUnit.module( 'Geometry', () => {
-
-		// INHERITANCE
-		QUnit.todo( "Extending", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		// INSTANCING
-		QUnit.todo( "Instancing", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		// PUBLIC STUFF
-		QUnit.todo( "isGeometry", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.test( "applyMatrix4", ( assert ) => {
-
-			var geometry = getGeometry();
-			geometry.faces.push( new Face3( 0, 1, 2 ) );
-			var m = new Matrix4();
-			var expectedVerts = [
-				new Vector3( 1.5, 3, 4 ),
-				new Vector3( 2.5, 3, 4 ),
-				new Vector3( 2, 3, 5 )
-			];
-			var v0, v1, v2;
-
-			m.makeRotationX( Math.PI / 2 );
-			m.setPosition( new Vector3( x, y, z ) );
-
-			geometry.applyMatrix4( m );
-
-			v0 = geometry.vertices[ 0 ];
-			v1 = geometry.vertices[ 1 ];
-			v2 = geometry.vertices[ 2 ];
-			assert.ok(
-				Math.abs( v0.x - expectedVerts[ 0 ].x ) <= eps &&
-				Math.abs( v0.y - expectedVerts[ 0 ].y ) <= eps &&
-				Math.abs( v0.z - expectedVerts[ 0 ].z ) <= eps,
-				"First vertex is as expected"
-			);
-			assert.ok(
-				Math.abs( v1.x - expectedVerts[ 1 ].x ) <= eps &&
-				Math.abs( v1.y - expectedVerts[ 1 ].y ) <= eps &&
-				Math.abs( v1.z - expectedVerts[ 1 ].z ) <= eps,
-				"Second vertex is as expected"
-			);
-			assert.ok(
-				Math.abs( v2.x - expectedVerts[ 2 ].x ) <= eps &&
-				Math.abs( v2.y - expectedVerts[ 2 ].y ) <= eps &&
-				Math.abs( v2.z - expectedVerts[ 2 ].z ) <= eps,
-				"Third vertex is as expected"
-			);
-
-		} );
-
-		QUnit.test( "rotateX", ( assert ) => {
-
-			var geometry = getGeometry();
-
-			var matrix = new Matrix4();
-			matrix.makeRotationX( Math.PI / 2 ); // 90 degree
-
-			geometry.applyMatrix4( matrix );
-
-			var v0 = geometry.vertices[ 0 ], v1 = geometry.vertices[ 1 ], v2 = geometry.vertices[ 2 ];
-			assert.ok( v0.x === - 0.5 && v0.y === 0 && v0.z === 0, "first vertex was rotated" );
-			assert.ok( v1.x === 0.5 && v1.y === 0 && v1.z === 0, "second vertex was rotated" );
-			assert.ok( v2.x === 0 && v2.y < Number.EPSILON && v2.z === 1, "third vertex was rotated" );
-
-		} );
-
-		QUnit.test( "rotateY", ( assert ) => {
-
-			var geometry = getGeometry();
-
-			var matrix = new Matrix4();
-			matrix.makeRotationY( Math.PI ); // 180 degrees
-
-			geometry.applyMatrix4( matrix );
-
-			var v0 = geometry.vertices[ 0 ], v1 = geometry.vertices[ 1 ], v2 = geometry.vertices[ 2 ];
-			assert.ok( v0.x === 0.5 && v0.y === 0 && v0.z < Number.EPSILON, "first vertex was rotated" );
-			assert.ok( v1.x === - 0.5 && v1.y === 0 && v1.z < Number.EPSILON, "second vertex was rotated" );
-			assert.ok( v2.x === 0 && v2.y === 1 && v2.z === 0, "third vertex was rotated" );
-
-		} );
-
-		QUnit.test( "rotateZ", ( assert ) => {
-
-			var geometry = getGeometry();
-
-			var matrix = new Matrix4();
-			matrix.makeRotationZ( Math.PI / 2 * 3 ); // 270 degrees
-
-			geometry.applyMatrix4( matrix );
-
-			var v0 = geometry.vertices[ 0 ], v1 = geometry.vertices[ 1 ], v2 = geometry.vertices[ 2 ];
-			assert.ok( v0.x < Number.EPSILON && v0.y === 0.5 && v0.z === 0, "first vertex was rotated" );
-			assert.ok( v1.x < Number.EPSILON && v1.y === - 0.5 && v1.z === 0, "second vertex was rotated" );
-			assert.ok( v2.x === 1 && v2.y < Number.EPSILON && v2.z === 0, "third vertex was rotated" );
-
-		} );
-
-		QUnit.test( "translate", ( assert ) => {
-
-			var a = getGeometry();
-			var expected = [
-				new Vector3( - 2.5, 3, - 4 ),
-				new Vector3( - 1.5, 3, - 4 ),
-				new Vector3( - 2, 4, - 4 )
-			];
-			var v;
-
-			a.translate( - x, y, - z );
-
-			for ( var i = 0; i < a.vertices.length; i ++ ) {
-
-				v = a.vertices[ i ];
-				assert.ok(
-					Math.abs( v.x - expected[ i ].x ) <= eps &&
-					Math.abs( v.y - expected[ i ].y ) <= eps &&
-					Math.abs( v.z - expected[ i ].z ) <= eps,
-					"Vertex #" + i + " was translated as expected"
-				);
-
-			}
-
-		} );
-
-		QUnit.test( "scale", ( assert ) => {
-
-			var a = getGeometry();
-			var expected = [
-				new Vector3( - 1, 0, 0 ),
-				new Vector3( 1, 0, 0 ),
-				new Vector3( 0, 3, 0 )
-			];
-			var v;
-
-			a.scale( 2, 3, 4 );
-
-			for ( var i = 0; i < a.vertices.length; i ++ ) {
-
-				v = a.vertices[ i ];
-				assert.ok(
-					Math.abs( v.x - expected[ i ].x ) <= eps &&
-					Math.abs( v.y - expected[ i ].y ) <= eps &&
-					Math.abs( v.z - expected[ i ].z ) <= eps,
-					"Vertex #" + i + " was scaled as expected"
-				);
-
-			}
-
-		} );
-
-		QUnit.test( "lookAt", ( assert ) => {
-
-			var a = getGeometry();
-			var expected = [
-				new Vector3( - 0.5, 0, 0 ),
-				new Vector3( 0.5, 0, 0 ),
-				new Vector3( 0, 0.5 * Math.sqrt( 2 ), 0.5 * Math.sqrt( 2 ) )
-			];
-
-			a.lookAt( new Vector3( 0, - 1, 1 ) );
-
-			for ( var i = 0; i < a.vertices.length; i ++ ) {
-
-				var v = a.vertices[ i ];
-				assert.ok(
-					Math.abs( v.x - expected[ i ].x ) <= eps &&
-					Math.abs( v.y - expected[ i ].y ) <= eps &&
-					Math.abs( v.z - expected[ i ].z ) <= eps,
-					"Vertex #" + i + " was adjusted as expected"
-				);
-
-			}
-
-		} );
-
-		QUnit.test( "fromBufferGeometry", ( assert ) => {
-
-			var bufferGeometry = new BufferGeometry();
-			bufferGeometry.setAttribute( 'position', new BufferAttribute( new Float32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] ), 3 ) );
-			bufferGeometry.setAttribute( 'color', new BufferAttribute( new Float32Array( [ 0, 0, 0, 0.5, 0.5, 0.5, 1, 1, 1 ] ), 3 ) );
-			bufferGeometry.setAttribute( 'normal', new BufferAttribute( new Float32Array( [ 0, 1, 0, 1, 0, 1, 1, 1, 0 ] ), 3 ) );
-			bufferGeometry.setAttribute( 'uv', new BufferAttribute( new Float32Array( [ 0, 0, 0, 1, 1, 1 ] ), 2 ) );
-			bufferGeometry.setAttribute( 'uv2', new BufferAttribute( new Float32Array( [ 0, 0, 0, 1, 1, 1 ] ), 2 ) );
-
-			var geometry = new Geometry().fromBufferGeometry( bufferGeometry );
-
-			var colors = geometry.colors;
-			assert.ok(
-				colors[ 0 ].r === 0 && colors[ 0 ].g === 0 && colors[ 0 ].b === 0 &&
-				colors[ 1 ].r === 0.5 && colors[ 1 ].g === 0.5 && colors[ 1 ].b === 0.5 &&
-				colors[ 2 ].r === 1 && colors[ 2 ].g === 1 && colors[ 2 ].b === 1
-				, "colors were created well" );
-
-			var vertices = geometry.vertices;
-			assert.ok(
-				vertices[ 0 ].x === 1 && vertices[ 0 ].y === 2 && vertices[ 0 ].z === 3 &&
-				vertices[ 1 ].x === 4 && vertices[ 1 ].y === 5 && vertices[ 1 ].z === 6 &&
-				vertices[ 2 ].x === 7 && vertices[ 2 ].y === 8 && vertices[ 2 ].z === 9
-				, "vertices were created well" );
-
-			var vNormals = geometry.faces[ 0 ].vertexNormals;
-			assert.ok(
-				vNormals[ 0 ].x === 0 && vNormals[ 0 ].y === 1 && vNormals[ 0 ].z === 0 &&
-				vNormals[ 1 ].x === 1 && vNormals[ 1 ].y === 0 && vNormals[ 1 ].z === 1 &&
-				vNormals[ 2 ].x === 1 && vNormals[ 2 ].y === 1 && vNormals[ 2 ].z === 0
-				, "vertex normals were created well" );
-
-		} );
-
-		QUnit.todo( "center", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.test( "normalize", ( assert ) => {
-
-			var a = getGeometry();
-			var sqrt = 0.5 * Math.sqrt( 2 );
-			var expected = [
-				new Vector3( - sqrt, - sqrt, 0 ),
-				new Vector3( sqrt, - sqrt, 0 ),
-				new Vector3( 0, sqrt, 0 )
-			];
-			var v;
-
-			a.normalize();
-
-			for ( var i = 0; i < a.vertices.length; i ++ ) {
-
-				v = a.vertices[ i ];
-				assert.ok(
-					Math.abs( v.x - expected[ i ].x ) <= eps &&
-					Math.abs( v.y - expected[ i ].y ) <= eps &&
-					Math.abs( v.z - expected[ i ].z ) <= eps,
-					"Vertex #" + i + " was normalized as expected"
-				);
-
-			}
-
-		} );
-
-		QUnit.todo( "computeFaceNormals", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "computeVertexNormals", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "computeFlatVertexNormals", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "computeMorphNormals", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.test( "computeBoundingBox", ( assert ) => {
-
-			var a = new Geometry().fromBufferGeometry( new DodecahedronGeometry() );
-
-			a.computeBoundingBox();
-			assert.strictEqual( a.boundingBox.isEmpty(), false, "Bounding box isn't empty" );
-
-			var allIn = true;
-			for ( var i = 0; i < a.vertices.length; i ++ ) {
-
-				if ( ! a.boundingBox.containsPoint( a.vertices[ i ] ) ) {
-
-					allIn = false;
-
-				}
-
-			}
-			assert.strictEqual( allIn, true, "All vertices are inside the box" );
-
-		} );
-
-		QUnit.test( "computeBoundingSphere", ( assert ) => {
-
-			var a = new Geometry().fromBufferGeometry( new DodecahedronGeometry() );
-
-			a.computeBoundingSphere();
-
-			var allIn = true;
-			for ( var i = 0; i < a.vertices.length; i ++ ) {
-
-				if ( ! a.boundingSphere.containsPoint( a.vertices[ i ] ) ) {
-
-					allIn = false;
-
-				}
-
-			}
-			assert.strictEqual( allIn, true, "All vertices are inside the bounding sphere" );
-
-		} );
-
-		QUnit.todo( "merge", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "mergeMesh", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.test( "mergeVertices", ( assert ) => {
-
-			var a = new Geometry();
-			var b = new BoxGeometry( 1, 1, 1 );
-			var verts, faces, removed;
-
-			a.fromBufferGeometry( b );
-
-			removed = a.mergeVertices();
-			verts = a.vertices.length;
-			faces = a.faces.length;
-
-			assert.strictEqual( removed, 16, "Removed the expected number of vertices" );
-			assert.strictEqual( verts, 8, "Minimum number of vertices remaining" );
-			assert.strictEqual( faces, 12, "Minimum number of faces remaining" );
-
-		} );
-
-		QUnit.test( "sortFacesByMaterialIndex", ( assert ) => {
-
-			var box = new BoxGeometry( 1, 1, 1 );
-			var a = new Geometry().fromBufferGeometry( box );
-			var expected = [ 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 ];
-
-			a.faces.reverse(); // a bit too simple probably, still missing stuff like checking new UVs
-			a.sortFacesByMaterialIndex();
-
-			var indices = [];
-
-			for ( var i = 0; i < a.faces.length; i ++ ) {
-
-				indices.push( a.faces[ i ].materialIndex );
-
-			}
-
-			assert.deepEqual( indices, expected, "Faces in correct order" );
-
-		} );
-
-		QUnit.test( "toJSON", ( assert ) => {
-
-			var a = getGeometry();
-			var gold = {
-				"metadata": {
-					"version": 4.5,
-					"type": "Geometry",
-					"generator": "Geometry.toJSON"
-				},
-				"uuid": null,
-				"type": "Geometry",
-				"data": {
-					"vertices": [ - 0.5, 0, 0, 0.5, 0, 0, 0, 1, 0 ],
-					"normals": [ 0, 0, 1 ],
-					"faces": [ 50, 0, 1, 2, 0, 0, 0, 0, 0 ]
-				}
-			};
-			var json;
-
-			a.faces.push( new Face3( 0, 1, 2 ) );
-			a.computeFaceNormals();
-			a.computeVertexNormals();
-
-			json = a.toJSON();
-			json.uuid = null;
-			assert.deepEqual( json, gold, "Generated JSON is as expected" );
-
-		} );
-
-		QUnit.todo( "clone", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "copy", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "dispose", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-	} );
-
-} );

+ 0 - 2
test/unit/three.source.unit.js

@@ -47,10 +47,8 @@ import './src/cameras/StereoCamera.tests';
 import './src/core/BufferAttribute.tests';
 import './src/core/BufferGeometry.tests';
 import './src/core/Clock.tests';
-import './src/core/DirectGeometry.tests';
 import './src/core/EventDispatcher.tests';
 import './src/core/Face3.tests';
-import './src/core/Geometry.tests';
 import './src/core/InstancedBufferAttribute.tests';
 import './src/core/InstancedBufferGeometry.tests';
 import './src/core/InstancedInterleavedBuffer.tests';