Browse Source

Merge branch 'dev' into dev44

Mr.doob 4 years ago
parent
commit
1ccc726477
45 changed files with 1756 additions and 3431 deletions
  1. 168 133
      build/three.js
  2. 0 0
      build/three.min.js
  3. 115 116
      build/three.module.js
  4. 0 1
      examples/files.json
  5. 0 421
      examples/js/modifiers/SubdivisionModifier.js
  6. 192 166
      examples/js/modifiers/TessellateModifier.js
  7. 312 1
      examples/js/utils/BufferGeometryUtils.js
  8. 0 0
      examples/jsm/deprecated/Geometry.d.ts
  9. 411 15
      examples/jsm/deprecated/Geometry.js
  10. 0 1
      examples/jsm/modifiers/SimplifyModifier.js
  11. 0 14
      examples/jsm/modifiers/SubdivisionModifier.d.ts
  12. 0 431
      examples/jsm/modifiers/SubdivisionModifier.js
  13. 2 3
      examples/jsm/modifiers/TessellateModifier.d.ts
  14. 196 168
      examples/jsm/modifiers/TessellateModifier.js
  15. 0 1
      examples/jsm/renderers/Projector.js
  16. 313 0
      examples/jsm/utils/BufferGeometryUtils.js
  17. BIN
      examples/screenshots/webgl_modifier_subdivision.jpg
  18. 0 136
      examples/webgl_modifier_subdivision.html
  19. 1 36
      src/Three.Legacy.d.ts
  20. 0 41
      src/Three.Legacy.js
  21. 0 2
      src/Three.d.ts
  22. 0 1
      src/Three.js
  23. 6 1
      src/animation/AnimationClip.d.ts
  24. 0 9
      src/core/BufferGeometry.d.ts
  25. 3 278
      src/core/BufferGeometry.js
  26. 0 113
      src/core/DirectGeometry.d.ts
  27. 0 283
      src/core/DirectGeometry.js
  28. 2 3
      src/core/Object3D.d.ts
  29. 0 14
      src/extras/core/CurvePath.d.ts
  30. 3 7
      src/objects/InstancedMesh.d.ts
  31. 5 9
      src/objects/Line.d.ts
  32. 3 7
      src/objects/LineLoop.d.ts
  33. 3 7
      src/objects/LineSegments.d.ts
  34. 5 9
      src/objects/Mesh.d.ts
  35. 7 11
      src/objects/Points.d.ts
  36. 3 7
      src/objects/SkinnedMesh.d.ts
  37. 1 2
      src/renderers/WebGLRenderer.d.ts
  38. 3 4
      src/renderers/webgl/WebGLGeometries.d.ts
  39. 2 9
      src/renderers/webgl/WebGLGeometries.js
  40. 0 6
      src/renderers/webgl/WebGLObjects.js
  41. 0 309
      test/unit/src/core/BufferGeometry.tests.js
  42. 0 191
      test/unit/src/core/DirectGeometry.tests.js
  43. 0 462
      test/unit/src/core/Geometry.tests.js
  44. 0 2
      test/unit/three.source.unit.js
  45. 0 1
      utils/modularize.js

+ 168 - 133
build/three.js

@@ -270,6 +270,36 @@
 	var GLSL1 = '100';
 	var GLSL1 = '100';
 	var GLSL3 = '300 es';
 	var GLSL3 = '300 es';
 
 
+	function _defineProperties(target, props) {
+		for (var i = 0; i < props.length; i++) {
+			var descriptor = props[i];
+			descriptor.enumerable = descriptor.enumerable || false;
+			descriptor.configurable = true;
+			if ("value" in descriptor) descriptor.writable = true;
+			Object.defineProperty(target, descriptor.key, descriptor);
+		}
+	}
+
+	function _createClass(Constructor, protoProps, staticProps) {
+		if (protoProps) _defineProperties(Constructor.prototype, protoProps);
+		if (staticProps) _defineProperties(Constructor, staticProps);
+		return Constructor;
+	}
+
+	function _inheritsLoose(subClass, superClass) {
+		subClass.prototype = Object.create(superClass.prototype);
+		subClass.prototype.constructor = subClass;
+		subClass.__proto__ = superClass;
+	}
+
+	function _assertThisInitialized(self) {
+		if (self === void 0) {
+			throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
+		}
+
+		return self;
+	}
+
 	/**
 	/**
 	 * https://github.com/mrdoob/eventdispatcher.js/
 	 * https://github.com/mrdoob/eventdispatcher.js/
 	 */
 	 */
@@ -453,36 +483,6 @@
 		}
 		}
 	};
 	};
 
 
-	function _defineProperties(target, props) {
-		for (var i = 0; i < props.length; i++) {
-			var descriptor = props[i];
-			descriptor.enumerable = descriptor.enumerable || false;
-			descriptor.configurable = true;
-			if ("value" in descriptor) descriptor.writable = true;
-			Object.defineProperty(target, descriptor.key, descriptor);
-		}
-	}
-
-	function _createClass(Constructor, protoProps, staticProps) {
-		if (protoProps) _defineProperties(Constructor.prototype, protoProps);
-		if (staticProps) _defineProperties(Constructor, staticProps);
-		return Constructor;
-	}
-
-	function _inheritsLoose(subClass, superClass) {
-		subClass.prototype = Object.create(superClass.prototype);
-		subClass.prototype.constructor = subClass;
-		subClass.__proto__ = superClass;
-	}
-
-	function _assertThisInitialized(self) {
-		if (self === void 0) {
-			throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
-		}
-
-		return self;
-	}
-
 	var Vector2 = /*#__PURE__*/function () {
 	var Vector2 = /*#__PURE__*/function () {
 		function Vector2(x, y) {
 		function Vector2(x, y) {
 			if (x === void 0) {
 			if (x === void 0) {
@@ -1977,28 +1977,37 @@
 	 * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
 	 * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
 	*/
 	*/
 
 
-	function WebGLRenderTarget(width, height, options) {
-		this.width = width;
-		this.height = height;
-		this.scissor = new Vector4(0, 0, width, height);
-		this.scissorTest = false;
-		this.viewport = new Vector4(0, 0, width, height);
-		options = options || {};
-		this.texture = new Texture(undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);
-		this.texture.image = {};
-		this.texture.image.width = width;
-		this.texture.image.height = height;
-		this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
-		this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
-		this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
-		this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
-		this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
-	}
-
-	WebGLRenderTarget.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
-		constructor: WebGLRenderTarget,
-		isWebGLRenderTarget: true,
-		setSize: function setSize(width, height) {
+	var WebGLRenderTarget = /*#__PURE__*/function (_EventDispatcher) {
+		_inheritsLoose(WebGLRenderTarget, _EventDispatcher);
+
+		function WebGLRenderTarget(width, height, options) {
+			var _this;
+
+			_this = _EventDispatcher.call(this) || this;
+			Object.defineProperty(_assertThisInitialized(_this), 'isWebGLRenderTarget', {
+				value: true
+			});
+			_this.width = width;
+			_this.height = height;
+			_this.scissor = new Vector4(0, 0, width, height);
+			_this.scissorTest = false;
+			_this.viewport = new Vector4(0, 0, width, height);
+			options = options || {};
+			_this.texture = new Texture(undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);
+			_this.texture.image = {};
+			_this.texture.image.width = width;
+			_this.texture.image.height = height;
+			_this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
+			_this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
+			_this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
+			_this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
+			_this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
+			return _this;
+		}
+
+		var _proto = WebGLRenderTarget.prototype;
+
+		_proto.setSize = function setSize(width, height) {
 			if (this.width !== width || this.height !== height) {
 			if (this.width !== width || this.height !== height) {
 				this.width = width;
 				this.width = width;
 				this.height = height;
 				this.height = height;
@@ -2009,11 +2018,13 @@
 
 
 			this.viewport.set(0, 0, width, height);
 			this.viewport.set(0, 0, width, height);
 			this.scissor.set(0, 0, width, height);
 			this.scissor.set(0, 0, width, height);
-		},
-		clone: function clone() {
+		};
+
+		_proto.clone = function clone() {
 			return new this.constructor().copy(this);
 			return new this.constructor().copy(this);
-		},
-		copy: function copy(source) {
+		};
+
+		_proto.copy = function copy(source) {
 			this.width = source.width;
 			this.width = source.width;
 			this.height = source.height;
 			this.height = source.height;
 			this.viewport.copy(source.viewport);
 			this.viewport.copy(source.viewport);
@@ -2022,28 +2033,42 @@
 			this.stencilBuffer = source.stencilBuffer;
 			this.stencilBuffer = source.stencilBuffer;
 			this.depthTexture = source.depthTexture;
 			this.depthTexture = source.depthTexture;
 			return this;
 			return this;
-		},
-		dispose: function dispose() {
+		};
+
+		_proto.dispose = function dispose() {
 			this.dispatchEvent({
 			this.dispatchEvent({
 				type: 'dispose'
 				type: 'dispose'
 			});
 			});
+		};
+
+		return WebGLRenderTarget;
+	}(EventDispatcher);
+
+	var WebGLMultisampleRenderTarget = /*#__PURE__*/function (_WebGLRenderTarget) {
+		_inheritsLoose(WebGLMultisampleRenderTarget, _WebGLRenderTarget);
+
+		function WebGLMultisampleRenderTarget(width, height, options) {
+			var _this;
+
+			_this = _WebGLRenderTarget.call(this, width, height, options) || this;
+			Object.defineProperty(_assertThisInitialized(_this), 'isWebGLMultisampleRenderTarget', {
+				value: true
+			});
+			_this.samples = 4;
+			return _this;
 		}
 		}
-	});
 
 
-	function WebGLMultisampleRenderTarget(width, height, options) {
-		WebGLRenderTarget.call(this, width, height, options);
-		this.samples = 4;
-	}
+		var _proto = WebGLMultisampleRenderTarget.prototype;
+
+		_proto.copy = function copy(source) {
+			_WebGLRenderTarget.prototype.copy.call(this, source);
 
 
-	WebGLMultisampleRenderTarget.prototype = Object.assign(Object.create(WebGLRenderTarget.prototype), {
-		constructor: WebGLMultisampleRenderTarget,
-		isWebGLMultisampleRenderTarget: true,
-		copy: function copy(source) {
-			WebGLRenderTarget.prototype.copy.call(this, source);
 			this.samples = source.samples;
 			this.samples = source.samples;
 			return this;
 			return this;
-		}
-	});
+		};
+
+		return WebGLMultisampleRenderTarget;
+	}(WebGLRenderTarget);
 
 
 	var Quaternion = /*#__PURE__*/function () {
 	var Quaternion = /*#__PURE__*/function () {
 		function Quaternion(x, y, z, w) {
 		function Quaternion(x, y, z, w) {
@@ -9652,75 +9677,85 @@
 		}
 		}
 	});
 	});
 
 
-	function WebGLCubeRenderTarget(size, options, dummy) {
-		if (Number.isInteger(options)) {
-			console.warn('THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )');
-			options = dummy;
+	var WebGLCubeRenderTarget = /*#__PURE__*/function (_WebGLRenderTarget) {
+		_inheritsLoose(WebGLCubeRenderTarget, _WebGLRenderTarget);
+
+		function WebGLCubeRenderTarget(size, options, dummy) {
+			var _this;
+
+			if (Number.isInteger(options)) {
+				console.warn('THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )');
+				options = dummy;
+			}
+
+			_this = _WebGLRenderTarget.call(this, size, size, options) || this;
+			Object.defineProperty(_assertThisInitialized(_this), 'isWebGLCubeRenderTarget', {
+				value: true
+			});
+			options = options || {};
+			_this.texture = new CubeTexture(undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);
+			_this.texture._needsFlipEnvMap = false;
+			return _this;
 		}
 		}
 
 
-		WebGLRenderTarget.call(this, size, size, options);
-		options = options || {};
-		this.texture = new CubeTexture(undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);
-		this.texture._needsFlipEnvMap = false;
-	}
+		var _proto = WebGLCubeRenderTarget.prototype;
 
 
-	WebGLCubeRenderTarget.prototype = Object.create(WebGLRenderTarget.prototype);
-	WebGLCubeRenderTarget.prototype.constructor = WebGLCubeRenderTarget;
-	WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true;
+		_proto.fromEquirectangularTexture = function fromEquirectangularTexture(renderer, texture) {
+			this.texture.type = texture.type;
+			this.texture.format = RGBAFormat; // see #18859
 
 
-	WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function (renderer, texture) {
-		this.texture.type = texture.type;
-		this.texture.format = RGBAFormat; // see #18859
+			this.texture.encoding = texture.encoding;
+			this.texture.generateMipmaps = texture.generateMipmaps;
+			this.texture.minFilter = texture.minFilter;
+			this.texture.magFilter = texture.magFilter;
+			var shader = {
+				uniforms: {
+					tEquirect: {
+						value: null
+					}
+				},
+				vertexShader:
+				/* glsl */
+				"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",
+				fragmentShader:
+				/* glsl */
+				"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"
+			};
+			var geometry = new BoxGeometry(5, 5, 5);
+			var material = new ShaderMaterial({
+				name: 'CubemapFromEquirect',
+				uniforms: cloneUniforms(shader.uniforms),
+				vertexShader: shader.vertexShader,
+				fragmentShader: shader.fragmentShader,
+				side: BackSide,
+				blending: NoBlending
+			});
+			material.uniforms.tEquirect.value = texture;
+			var mesh = new Mesh(geometry, material);
+			var currentMinFilter = texture.minFilter; // Avoid blurred poles
 
 
-		this.texture.encoding = texture.encoding;
-		this.texture.generateMipmaps = texture.generateMipmaps;
-		this.texture.minFilter = texture.minFilter;
-		this.texture.magFilter = texture.magFilter;
-		var shader = {
-			uniforms: {
-				tEquirect: {
-					value: null
-				}
-			},
-			vertexShader:
-			/* glsl */
-			"\n\n\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t#include <begin_vertex>\n\t\t\t\t#include <project_vertex>\n\n\t\t\t}\n\t\t",
-			fragmentShader:
-			/* glsl */
-			"\n\n\t\t\tuniform sampler2D tEquirect;\n\n\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t}\n\t\t"
-		};
-		var geometry = new BoxGeometry(5, 5, 5);
-		var material = new ShaderMaterial({
-			name: 'CubemapFromEquirect',
-			uniforms: cloneUniforms(shader.uniforms),
-			vertexShader: shader.vertexShader,
-			fragmentShader: shader.fragmentShader,
-			side: BackSide,
-			blending: NoBlending
-		});
-		material.uniforms.tEquirect.value = texture;
-		var mesh = new Mesh(geometry, material);
-		var currentMinFilter = texture.minFilter; // Avoid blurred poles
-
-		if (texture.minFilter === LinearMipmapLinearFilter) texture.minFilter = LinearFilter;
-		var camera = new CubeCamera(1, 10, this);
-		camera.update(renderer, mesh);
-		texture.minFilter = currentMinFilter;
-		mesh.geometry.dispose();
-		mesh.material.dispose();
-		return this;
-	};
+			if (texture.minFilter === LinearMipmapLinearFilter) texture.minFilter = LinearFilter;
+			var camera = new CubeCamera(1, 10, this);
+			camera.update(renderer, mesh);
+			texture.minFilter = currentMinFilter;
+			mesh.geometry.dispose();
+			mesh.material.dispose();
+			return this;
+		};
 
 
-	WebGLCubeRenderTarget.prototype.clear = function (renderer, color, depth, stencil) {
-		var currentRenderTarget = renderer.getRenderTarget();
+		_proto.clear = function clear(renderer, color, depth, stencil) {
+			var currentRenderTarget = renderer.getRenderTarget();
 
 
-		for (var i = 0; i < 6; i++) {
-			renderer.setRenderTarget(this, i);
-			renderer.clear(color, depth, stencil);
-		}
+			for (var i = 0; i < 6; i++) {
+				renderer.setRenderTarget(this, i);
+				renderer.clear(color, depth, stencil);
+			}
 
 
-		renderer.setRenderTarget(currentRenderTarget);
-	};
+			renderer.setRenderTarget(currentRenderTarget);
+		};
+
+		return WebGLCubeRenderTarget;
+	}(WebGLRenderTarget);
 
 
 	function DataTexture(data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {
 	function DataTexture(data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {
 		Texture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
 		Texture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
@@ -18797,10 +18832,10 @@
 						return;
 						return;
 					}
 					}
 
 
-					var halfFloatSupportedByExt = textureType === HalfFloatType && (extensions.get('EXT_color_buffer_half_float') || capabilities.isWebGL2 && extensions.get('EXT_color_buffer_float'));
+					var halfFloatSupportedByExt = textureType === HalfFloatType && (extensions.has('EXT_color_buffer_half_float') || capabilities.isWebGL2 && extensions.has('EXT_color_buffer_float'));
 
 
 					if (textureType !== UnsignedByteType && utils.convert(textureType) !== _gl.getParameter(35738) && // IE11, Edge and Chrome Mac < 52 (#9513)
 					if (textureType !== UnsignedByteType && utils.convert(textureType) !== _gl.getParameter(35738) && // IE11, Edge and Chrome Mac < 52 (#9513)
-					!(textureType === FloatType && (capabilities.isWebGL2 || extensions.get('OES_texture_float') || extensions.get('WEBGL_color_buffer_float'))) && // Chrome Mac >= 52 and Firefox
+					!(textureType === FloatType && (capabilities.isWebGL2 || extensions.has('OES_texture_float') || extensions.has('WEBGL_color_buffer_float'))) && // Chrome Mac >= 52 and Firefox
 					!halfFloatSupportedByExt) {
 					!halfFloatSupportedByExt) {
 						console.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.');
 						console.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.');
 						return;
 						return;

File diff suppressed because it is too large
+ 0 - 0
build/three.min.js


+ 115 - 116
build/three.module.js

@@ -2388,40 +2388,40 @@ class Vector4 {
  * Texture parameters for an auto-generated target texture
  * Texture parameters for an auto-generated target texture
  * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
  * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
 */
 */
-function WebGLRenderTarget( width, height, options ) {
+class WebGLRenderTarget extends EventDispatcher {
 
 
-	this.width = width;
-	this.height = height;
+	constructor( width, height, options ) {
 
 
-	this.scissor = new Vector4( 0, 0, width, height );
-	this.scissorTest = false;
+		super();
 
 
-	this.viewport = new Vector4( 0, 0, width, height );
+		Object.defineProperty( this, 'isWebGLRenderTarget', { value: true } );
 
 
-	options = options || {};
+		this.width = width;
+		this.height = height;
 
 
-	this.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+		this.scissor = new Vector4( 0, 0, width, height );
+		this.scissorTest = false;
 
 
-	this.texture.image = {};
-	this.texture.image.width = width;
-	this.texture.image.height = height;
+		this.viewport = new Vector4( 0, 0, width, height );
 
 
-	this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
-	this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
+		options = options || {};
 
 
-	this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
-	this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
-	this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
+		this.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
 
 
-}
+		this.texture.image = {};
+		this.texture.image.width = width;
+		this.texture.image.height = height;
 
 
-WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
+		this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
+		this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
 
 
-	constructor: WebGLRenderTarget,
+		this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
+		this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
+		this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
 
 
-	isWebGLRenderTarget: true,
+	}
 
 
-	setSize: function ( width, height ) {
+	setSize( width, height ) {
 
 
 		if ( this.width !== width || this.height !== height ) {
 		if ( this.width !== width || this.height !== height ) {
 
 
@@ -2438,15 +2438,15 @@ WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prot
 		this.viewport.set( 0, 0, width, height );
 		this.viewport.set( 0, 0, width, height );
 		this.scissor.set( 0, 0, width, height );
 		this.scissor.set( 0, 0, width, height );
 
 
-	},
+	}
 
 
-	clone: function () {
+	clone() {
 
 
 		return new this.constructor().copy( this );
 		return new this.constructor().copy( this );
 
 
-	},
+	}
 
 
-	copy: function ( source ) {
+	copy( source ) {
 
 
 		this.width = source.width;
 		this.width = source.width;
 		this.height = source.height;
 		this.height = source.height;
@@ -2461,33 +2461,31 @@ WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prot
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	dispose: function () {
+	dispose() {
 
 
 		this.dispatchEvent( { type: 'dispose' } );
 		this.dispatchEvent( { type: 'dispose' } );
 
 
 	}
 	}
 
 
-} );
-
-function WebGLMultisampleRenderTarget( width, height, options ) {
+}
 
 
-	WebGLRenderTarget.call( this, width, height, options );
+class WebGLMultisampleRenderTarget extends WebGLRenderTarget {
 
 
-	this.samples = 4;
+	constructor( width, height, options ) {
 
 
-}
+		super( width, height, options );
 
 
-WebGLMultisampleRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), {
+		Object.defineProperty( this, 'isWebGLMultisampleRenderTarget', { value: true } );
 
 
-	constructor: WebGLMultisampleRenderTarget,
+		this.samples = 4;
 
 
-	isWebGLMultisampleRenderTarget: true,
+	}
 
 
-	copy: function ( source ) {
+	copy( source ) {
 
 
-		WebGLRenderTarget.prototype.copy.call( this, source );
+		super.copy.call( this, source );
 
 
 		this.samples = source.samples;
 		this.samples = source.samples;
 
 
@@ -2495,7 +2493,7 @@ WebGLMultisampleRenderTarget.prototype = Object.assign( Object.create( WebGLRend
 
 
 	}
 	}
 
 
-} );
+}
 
 
 class Quaternion {
 class Quaternion {
 
 
@@ -12339,137 +12337,138 @@ Object.defineProperty( CubeTexture.prototype, 'images', {
 
 
 } );
 } );
 
 
-function WebGLCubeRenderTarget( size, options, dummy ) {
+class WebGLCubeRenderTarget extends WebGLRenderTarget {
 
 
-	if ( Number.isInteger( options ) ) {
+	constructor( size, options, dummy ) {
 
 
-		console.warn( 'THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )' );
+		if ( Number.isInteger( options ) ) {
 
 
-		options = dummy;
+			console.warn( 'THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )' );
 
 
-	}
+			options = dummy;
 
 
-	WebGLRenderTarget.call( this, size, size, options );
+		}
 
 
-	options = options || {};
+		super( size, size, options );
 
 
-	this.texture = new CubeTexture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+		Object.defineProperty( this, 'isWebGLCubeRenderTarget', { value: true } );
 
 
-	this.texture._needsFlipEnvMap = false;
+		options = options || {};
 
 
-}
+		this.texture = new CubeTexture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
 
 
-WebGLCubeRenderTarget.prototype = Object.create( WebGLRenderTarget.prototype );
-WebGLCubeRenderTarget.prototype.constructor = WebGLCubeRenderTarget;
+		this.texture._needsFlipEnvMap = false;
 
 
-WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true;
+	}
 
 
-WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function ( renderer, texture ) {
+	fromEquirectangularTexture( renderer, texture ) {
 
 
-	this.texture.type = texture.type;
-	this.texture.format = RGBAFormat; // see #18859
-	this.texture.encoding = texture.encoding;
+		this.texture.type = texture.type;
+		this.texture.format = RGBAFormat; // see #18859
+		this.texture.encoding = texture.encoding;
 
 
-	this.texture.generateMipmaps = texture.generateMipmaps;
-	this.texture.minFilter = texture.minFilter;
-	this.texture.magFilter = texture.magFilter;
+		this.texture.generateMipmaps = texture.generateMipmaps;
+		this.texture.minFilter = texture.minFilter;
+		this.texture.magFilter = texture.magFilter;
 
 
-	const shader = {
+		const shader = {
 
 
-		uniforms: {
-			tEquirect: { value: null },
-		},
+			uniforms: {
+				tEquirect: { value: null },
+			},
 
 
-		vertexShader: /* glsl */`
+			vertexShader: /* glsl */`
 
 
-			varying vec3 vWorldDirection;
+				varying vec3 vWorldDirection;
 
 
-			vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
+				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
 
 
-				return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
+					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
 
 
-			}
+				}
 
 
-			void main() {
+				void main() {
 
 
-				vWorldDirection = transformDirection( position, modelMatrix );
+					vWorldDirection = transformDirection( position, modelMatrix );
 
 
-				#include <begin_vertex>
-				#include <project_vertex>
+					#include <begin_vertex>
+					#include <project_vertex>
 
 
-			}
-		`,
+				}
+			`,
 
 
-		fragmentShader: /* glsl */`
+			fragmentShader: /* glsl */`
 
 
-			uniform sampler2D tEquirect;
+				uniform sampler2D tEquirect;
 
 
-			varying vec3 vWorldDirection;
+				varying vec3 vWorldDirection;
 
 
-			#include <common>
+				#include <common>
 
 
-			void main() {
+				void main() {
 
 
-				vec3 direction = normalize( vWorldDirection );
+					vec3 direction = normalize( vWorldDirection );
 
 
-				vec2 sampleUV = equirectUv( direction );
+					vec2 sampleUV = equirectUv( direction );
 
 
-				gl_FragColor = texture2D( tEquirect, sampleUV );
+					gl_FragColor = texture2D( tEquirect, sampleUV );
 
 
-			}
-		`
-	};
+				}
+			`
+		};
 
 
-	const geometry = new BoxGeometry( 5, 5, 5 );
+		const geometry = new BoxGeometry( 5, 5, 5 );
 
 
-	const material = new ShaderMaterial( {
+		const material = new ShaderMaterial( {
 
 
-		name: 'CubemapFromEquirect',
+			name: 'CubemapFromEquirect',
 
 
-		uniforms: cloneUniforms( shader.uniforms ),
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader,
-		side: BackSide,
-		blending: NoBlending
+			uniforms: cloneUniforms( shader.uniforms ),
+			vertexShader: shader.vertexShader,
+			fragmentShader: shader.fragmentShader,
+			side: BackSide,
+			blending: NoBlending
 
 
-	} );
+		} );
 
 
-	material.uniforms.tEquirect.value = texture;
+		material.uniforms.tEquirect.value = texture;
 
 
-	const mesh = new Mesh( geometry, material );
+		const mesh = new Mesh( geometry, material );
 
 
-	const currentMinFilter = texture.minFilter;
+		const currentMinFilter = texture.minFilter;
 
 
-	// Avoid blurred poles
-	if ( texture.minFilter === LinearMipmapLinearFilter ) texture.minFilter = LinearFilter;
+		// Avoid blurred poles
+		if ( texture.minFilter === LinearMipmapLinearFilter ) texture.minFilter = LinearFilter;
 
 
-	const camera = new CubeCamera( 1, 10, this );
-	camera.update( renderer, mesh );
+		const camera = new CubeCamera( 1, 10, this );
+		camera.update( renderer, mesh );
 
 
-	texture.minFilter = currentMinFilter;
+		texture.minFilter = currentMinFilter;
 
 
-	mesh.geometry.dispose();
-	mesh.material.dispose();
+		mesh.geometry.dispose();
+		mesh.material.dispose();
 
 
-	return this;
+		return this;
 
 
-};
+	}
 
 
-WebGLCubeRenderTarget.prototype.clear = function ( renderer, color, depth, stencil ) {
+	clear( renderer, color, depth, stencil ) {
 
 
-	const currentRenderTarget = renderer.getRenderTarget();
+		const currentRenderTarget = renderer.getRenderTarget();
 
 
-	for ( let i = 0; i < 6; i ++ ) {
+		for ( let i = 0; i < 6; i ++ ) {
 
 
-		renderer.setRenderTarget( this, i );
+			renderer.setRenderTarget( this, i );
 
 
-		renderer.clear( color, depth, stencil );
+			renderer.clear( color, depth, stencil );
 
 
-	}
+		}
 
 
-	renderer.setRenderTarget( currentRenderTarget );
+		renderer.setRenderTarget( currentRenderTarget );
 
 
-};
+	}
+
+}
 
 
 function DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
 function DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
 
 
@@ -25159,10 +25158,10 @@ function WebGLRenderer( parameters ) {
 
 
 				}
 				}
 
 
-				const halfFloatSupportedByExt = textureType === HalfFloatType && ( extensions.get( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.get( 'EXT_color_buffer_float' ) ) );
+				const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.has( 'EXT_color_buffer_float' ) ) );
 
 
 				if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( 35738 ) && // IE11, Edge and Chrome Mac < 52 (#9513)
 				if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( 35738 ) && // IE11, Edge and Chrome Mac < 52 (#9513)
-					! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.get( 'OES_texture_float' ) || extensions.get( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox
+					! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float' ) || extensions.has( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox
 					! halfFloatSupportedByExt ) {
 					! halfFloatSupportedByExt ) {
 
 
 					console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
 					console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );

+ 0 - 1
examples/files.json

@@ -185,7 +185,6 @@
 		"webgl_modifier_curve_instanced",
 		"webgl_modifier_curve_instanced",
 		"webgl_modifier_edgesplit",
 		"webgl_modifier_edgesplit",
 		"webgl_modifier_simplifier",
 		"webgl_modifier_simplifier",
-		"webgl_modifier_subdivision",
 		"webgl_modifier_tessellation",
 		"webgl_modifier_tessellation",
 		"webgl_morphtargets",
 		"webgl_morphtargets",
 		"webgl_morphtargets_horse",
 		"webgl_morphtargets_horse",

+ 0 - 421
examples/js/modifiers/SubdivisionModifier.js

@@ -1,421 +0,0 @@
-/**
- *	Subdivision Geometry Modifier
- *		using Loop Subdivision Scheme
- *
- *	References:
- *		http://graphics.stanford.edu/~mdfisher/subdivision.html
- *		http://www.holmes3d.net/graphics/subdivision/
- *		http://www.cs.rutgers.edu/~decarlo/readings/subdiv-sg00c.pdf
- *
- *	Known Issues:
- *		- currently doesn't handle "Sharp Edges"
- */
-
-THREE.SubdivisionModifier = function ( subdivisions ) {
-
-	this.subdivisions = ( subdivisions === undefined ) ? 1 : subdivisions;
-
-};
-
-// Applies the "modify" pattern
-THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
-
-	var isBufferGeometry = geometry.isBufferGeometry;
-
-	if ( isBufferGeometry ) {
-
-		geometry = new THREE.Geometry().fromBufferGeometry( geometry );
-
-	} else {
-
-		geometry = geometry.clone();
-
-	}
-
-	geometry.mergeVertices( 6 );
-
-	var repeats = this.subdivisions;
-
-	while ( repeats -- > 0 ) {
-
-		this.smooth( geometry );
-
-	}
-
-	geometry.computeFaceNormals();
-	geometry.computeVertexNormals();
-
-	if ( isBufferGeometry ) {
-
-		return new THREE.BufferGeometry().fromGeometry( geometry );
-
-	} else {
-
-		return geometry;
-
-	}
-
-};
-
-( function () {
-
-	// Some constants
-	var ABC = [ 'a', 'b', 'c' ];
-
-
-	function getEdge( a, b, map ) {
-
-		var vertexIndexA = Math.min( a, b );
-		var vertexIndexB = Math.max( a, b );
-
-		var key = vertexIndexA + '_' + vertexIndexB;
-
-		return map[ key ];
-
-	}
-
-
-	function processEdge( a, b, vertices, map, face, metaVertices ) {
-
-		var vertexIndexA = Math.min( a, b );
-		var vertexIndexB = Math.max( a, b );
-
-		var key = vertexIndexA + '_' + vertexIndexB;
-
-		var edge;
-
-		if ( key in map ) {
-
-			edge = map[ key ];
-
-		} else {
-
-			var vertexA = vertices[ vertexIndexA ];
-			var vertexB = vertices[ vertexIndexB ];
-
-			edge = {
-
-				a: vertexA, // pointer reference
-				b: vertexB,
-				newEdge: null,
-				// aIndex: a, // numbered reference
-				// bIndex: b,
-				faces: [] // pointers to face
-
-			};
-
-			map[ key ] = edge;
-
-		}
-
-		edge.faces.push( face );
-
-		metaVertices[ a ].edges.push( edge );
-		metaVertices[ b ].edges.push( edge );
-
-
-	}
-
-	function generateLookups( vertices, faces, metaVertices, edges ) {
-
-		var i, il, face;
-
-		for ( i = 0, il = vertices.length; i < il; i ++ ) {
-
-			metaVertices[ i ] = { edges: [] };
-
-		}
-
-		for ( i = 0, il = faces.length; i < il; i ++ ) {
-
-			face = faces[ i ];
-
-			processEdge( face.a, face.b, vertices, edges, face, metaVertices );
-			processEdge( face.b, face.c, vertices, edges, face, metaVertices );
-			processEdge( face.c, face.a, vertices, edges, face, metaVertices );
-
-		}
-
-	}
-
-	function newFace( newFaces, a, b, c, materialIndex ) {
-
-		newFaces.push( new THREE.Face3( a, b, c, undefined, undefined, materialIndex ) );
-
-	}
-
-	function midpoint( a, b ) {
-
-		return ( Math.abs( b - a ) / 2 ) + Math.min( a, b );
-
-	}
-
-	function newUv( newUvs, a, b, c ) {
-
-		newUvs.push( [ a.clone(), b.clone(), c.clone() ] );
-
-	}
-
-	/////////////////////////////
-
-	// Performs one iteration of Subdivision
-	THREE.SubdivisionModifier.prototype.smooth = function ( geometry ) {
-
-		var tmp = new THREE.Vector3();
-
-		var oldVertices, oldFaces, oldUvs;
-		var newVertices, newFaces, newUVs = [];
-
-		var n, i, il, j, k;
-		var metaVertices, sourceEdges;
-
-		// new stuff.
-		var sourceEdges, newEdgeVertices, newSourceVertices;
-
-		oldVertices = geometry.vertices; // { x, y, z}
-		oldFaces = geometry.faces; // { a: oldVertex1, b: oldVertex2, c: oldVertex3 }
-		oldUvs = geometry.faceVertexUvs;
-
-		var hasUvs = oldUvs[ 0 ] !== undefined && oldUvs[ 0 ].length > 0;
-
-		if ( hasUvs ) {
-
-			for ( var j = 0; j < oldUvs.length; j ++ ) {
-
-				newUVs.push( [] );
-
-			}
-
-		}
-
-		/******************************************************
-		 *
-		 * Step 0: Preprocess Geometry to Generate edges Lookup
-		 *
-		 *******************************************************/
-
-		metaVertices = new Array( oldVertices.length );
-		sourceEdges = {}; // Edge => { oldVertex1, oldVertex2, faces[]  }
-
-		generateLookups( oldVertices, oldFaces, metaVertices, sourceEdges );
-
-
-		/******************************************************
-		 *
-		 *	Step 1.
-		 *	For each edge, create a new Edge Vertex,
-		 *	then position it.
-		 *
-		 *******************************************************/
-
-		newEdgeVertices = [];
-		var other, currentEdge, newEdge, face;
-		var edgeVertexWeight, adjacentVertexWeight, connectedFaces;
-
-		for ( i in sourceEdges ) {
-
-			currentEdge = sourceEdges[ i ];
-			newEdge = new THREE.Vector3();
-
-			edgeVertexWeight = 3 / 8;
-			adjacentVertexWeight = 1 / 8;
-
-			connectedFaces = currentEdge.faces.length;
-
-			// check how many linked faces. 2 should be correct.
-			if ( connectedFaces != 2 ) {
-
-				// if length is not 2, handle condition
-				edgeVertexWeight = 0.5;
-				adjacentVertexWeight = 0;
-
-				if ( connectedFaces != 1 ) {
-
-					// console.warn( 'Subdivision Modifier: Number of connected faces != 2, is: ', connectedFaces, currentEdge );
-
-				}
-
-			}
-
-			newEdge.addVectors( currentEdge.a, currentEdge.b ).multiplyScalar( edgeVertexWeight );
-
-			tmp.set( 0, 0, 0 );
-
-			for ( j = 0; j < connectedFaces; j ++ ) {
-
-				face = currentEdge.faces[ j ];
-
-				for ( k = 0; k < 3; k ++ ) {
-
-					other = oldVertices[ face[ ABC[ k ] ] ];
-					if ( other !== currentEdge.a && other !== currentEdge.b ) break;
-
-				}
-
-				tmp.add( other );
-
-			}
-
-			tmp.multiplyScalar( adjacentVertexWeight );
-			newEdge.add( tmp );
-
-			currentEdge.newEdge = newEdgeVertices.length;
-			newEdgeVertices.push( newEdge );
-
-			// console.log(currentEdge, newEdge);
-
-		}
-
-		/******************************************************
-		 *
-		 *	Step 2.
-		 *	Reposition each source vertices.
-		 *
-		 *******************************************************/
-
-		var beta, sourceVertexWeight, connectingVertexWeight;
-		var connectingEdge, connectingEdges, oldVertex, newSourceVertex;
-		newSourceVertices = [];
-
-		for ( i = 0, il = oldVertices.length; i < il; i ++ ) {
-
-			oldVertex = oldVertices[ i ];
-
-			// find all connecting edges (using lookupTable)
-			connectingEdges = metaVertices[ i ].edges;
-			n = connectingEdges.length;
-
-			if ( n == 3 ) {
-
-				beta = 3 / 16;
-
-			} else if ( n > 3 ) {
-
-				beta = 3 / ( 8 * n ); // Warren's modified formula
-
-			}
-
-			// Loop's original beta formula
-			// beta = 1 / n * ( 5/8 - Math.pow( 3/8 + 1/4 * Math.cos( 2 * Math. PI / n ), 2) );
-
-			sourceVertexWeight = 1 - n * beta;
-			connectingVertexWeight = beta;
-
-			if ( n <= 2 ) {
-
-				// crease and boundary rules
-				// console.warn('crease and boundary rules');
-
-				if ( n == 2 ) {
-
-					// console.warn( '2 connecting edges', connectingEdges );
-					sourceVertexWeight = 3 / 4;
-					connectingVertexWeight = 1 / 8;
-
-					// sourceVertexWeight = 1;
-					// connectingVertexWeight = 0;
-
-				} else if ( n == 1 ) {
-
-					// console.warn( 'only 1 connecting edge' );
-
-				} else if ( n == 0 ) {
-
-					// console.warn( '0 connecting edges' );
-
-				}
-
-			}
-
-			newSourceVertex = oldVertex.clone().multiplyScalar( sourceVertexWeight );
-
-			tmp.set( 0, 0, 0 );
-
-			for ( j = 0; j < n; j ++ ) {
-
-				connectingEdge = connectingEdges[ j ];
-				other = connectingEdge.a !== oldVertex ? connectingEdge.a : connectingEdge.b;
-				tmp.add( other );
-
-			}
-
-			tmp.multiplyScalar( connectingVertexWeight );
-			newSourceVertex.add( tmp );
-
-			newSourceVertices.push( newSourceVertex );
-
-		}
-
-
-		/******************************************************
-		 *
-		 *	Step 3.
-		 *	Generate Faces between source vertices
-		 *	and edge vertices.
-		 *
-		 *******************************************************/
-
-		newVertices = newSourceVertices.concat( newEdgeVertices );
-		var sl = newSourceVertices.length, edge1, edge2, edge3;
-		newFaces = [];
-
-		var uv, x0, x1, x2;
-		var x3 = new THREE.Vector2();
-		var x4 = new THREE.Vector2();
-		var x5 = new THREE.Vector2();
-
-		for ( i = 0, il = oldFaces.length; i < il; i ++ ) {
-
-			face = oldFaces[ i ];
-
-			// find the 3 new edges vertex of each old face
-
-			edge1 = getEdge( face.a, face.b, sourceEdges ).newEdge + sl;
-			edge2 = getEdge( face.b, face.c, sourceEdges ).newEdge + sl;
-			edge3 = getEdge( face.c, face.a, sourceEdges ).newEdge + sl;
-
-			// create 4 faces.
-
-			newFace( newFaces, edge1, edge2, edge3, face.materialIndex );
-			newFace( newFaces, face.a, edge1, edge3, face.materialIndex );
-			newFace( newFaces, face.b, edge2, edge1, face.materialIndex );
-			newFace( newFaces, face.c, edge3, edge2, face.materialIndex );
-
-			// create 4 new uv's
-
-			if ( hasUvs ) {
-
-				for ( var j = 0; j < oldUvs.length; j ++ ) {
-
-					uv = oldUvs[ j ][ i ];
-
-					x0 = uv[ 0 ];
-					x1 = uv[ 1 ];
-					x2 = uv[ 2 ];
-
-					x3.set( midpoint( x0.x, x1.x ), midpoint( x0.y, x1.y ) );
-					x4.set( midpoint( x1.x, x2.x ), midpoint( x1.y, x2.y ) );
-					x5.set( midpoint( x0.x, x2.x ), midpoint( x0.y, x2.y ) );
-
-					newUv( newUVs[ j ], x3, x4, x5 );
-					newUv( newUVs[ j ], x0, x3, x5 );
-
-					newUv( newUVs[ j ], x1, x4, x3 );
-					newUv( newUVs[ j ], x2, x5, x4 );
-
-				}
-
-			}
-
-		}
-
-		// Overwrite old arrays
-		geometry.vertices = newVertices;
-		geometry.faces = newFaces;
-		if ( hasUvs ) geometry.faceVertexUvs = newUVs;
-
-		// console.log('done');
-
-	};
-
-} )();

+ 192 - 166
examples/js/modifiers/TessellateModifier.js

@@ -2,273 +2,299 @@
  * Break faces with edges longer than maxEdgeLength
  * Break faces with edges longer than maxEdgeLength
  */
  */
 
 
-THREE.TessellateModifier = function ( maxEdgeLength = 0.1, maxIterations = 6, maxFaces = Infinity ) {
+THREE.TessellateModifier = function ( maxEdgeLength = 0.1, maxIterations = 6 ) {
 
 
 	this.maxEdgeLength = maxEdgeLength;
 	this.maxEdgeLength = maxEdgeLength;
 	this.maxIterations = maxIterations;
 	this.maxIterations = maxIterations;
-	this.maxFaces = maxFaces;
 
 
 };
 };
 
 
-// Applies the "modify" pattern
 THREE.TessellateModifier.prototype.modify = function ( geometry ) {
 THREE.TessellateModifier.prototype.modify = function ( geometry ) {
 
 
-	const isBufferGeometry = geometry.isBufferGeometry;
+	if ( geometry.isGeometry === true ) {
 
 
-	if ( isBufferGeometry ) {
+		console.error( 'THREE.TessellateModifier no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
+		return geometry;
 
 
-		geometry = new THREE.Geometry().fromBufferGeometry( geometry );
+	}
 
 
-	} else {
+	if ( geometry.index !== null ) {
 
 
-		geometry = geometry.clone();
+		geometry = geometry.toNonIndexed();
 
 
 	}
 	}
 
 
-	geometry.mergeVertices( 6 );
+	//
 
 
-	let finalized = false;
-	let iteration = 0;
+	const maxIterations = this.maxIterations;
 	const maxEdgeLengthSquared = this.maxEdgeLength * this.maxEdgeLength;
 	const maxEdgeLengthSquared = this.maxEdgeLength * this.maxEdgeLength;
 
 
-	let edge;
-
-	while ( ! finalized && iteration < this.maxIterations && geometry.faces.length < this.maxFaces ) {
-
-		const faces = [];
-		const faceVertexUvs = [];
-
-		finalized = true;
-		iteration ++;
-
-		for ( var i = 0, il = geometry.faceVertexUvs.length; i < il; i ++ ) {
-
-			faceVertexUvs[ i ] = [];
-
-		}
-
-		for ( var i = 0, il = geometry.faces.length; i < il; i ++ ) {
+	const va = new THREE.Vector3();
+	const vb = new THREE.Vector3();
+	const vc = new THREE.Vector3();
+	const vm = new THREE.Vector3();
+	const vs = [ va, vb, vc, vm ];
+
+	const na = new THREE.Vector3();
+	const nb = new THREE.Vector3();
+	const nc = new THREE.Vector3();
+	const nm = new THREE.Vector3();
+	const ns = [ na, nb, nc, nm ];
+
+	const ca = new THREE.Color();
+	const cb = new THREE.Color();
+	const cc = new THREE.Color();
+	const cm = new THREE.Color();
+	const cs = [ ca, cb, cc, cm ];
+
+	const ua = new THREE.Vector2();
+	const ub = new THREE.Vector2();
+	const uc = new THREE.Vector2();
+	const um = new THREE.Vector2();
+	const us = [ ua, ub, uc, um ];
+
+	const u2a = new THREE.Vector2();
+	const u2b = new THREE.Vector2();
+	const u2c = new THREE.Vector2();
+	const u2m = new THREE.Vector2();
+	const u2s = [ u2a, u2b, u2c, u2m ];
+
+	const attributes = geometry.attributes;
+	const hasNormals = attributes.normal !== undefined;
+	const hasColors = attributes.color !== undefined;
+	const hasUVs = attributes.uv !== undefined;
+	const hasUV2s = attributes.uv2 !== undefined;
+
+	let positions = attributes.position.array;
+	let normals = hasNormals ? attributes.normal.array : null;
+	let colors = hasColors ? attributes.color.array : null;
+	let uvs = hasUVs ? attributes.uv.array : null;
+	let uv2s = hasUV2s ? attributes.uv2.array : null;
+
+	let positions2 = positions;
+	let normals2 = normals;
+	let colors2 = colors;
+	let uvs2 = uvs;
+	let uv2s2 = uv2s;
 
 
-			const face = geometry.faces[ i ];
-
-			if ( face instanceof THREE.Face3 ) {
-
-				const a = face.a;
-				const b = face.b;
-				const c = face.c;
-
-				const va = geometry.vertices[ a ];
-				const vb = geometry.vertices[ b ];
-				const vc = geometry.vertices[ c ];
-
-				const dab = va.distanceToSquared( vb );
-				const dbc = vb.distanceToSquared( vc );
-				const dac = va.distanceToSquared( vc );
+	let iteration = 0;
+	let tessellating = true;
 
 
-				const limitReached = ( faces.length + il - i ) >= this.maxFaces;
+	function addTriangle( a, b, c ) {
 
 
-				if ( ! limitReached && ( dab > maxEdgeLengthSquared || dbc > maxEdgeLengthSquared || dac > maxEdgeLengthSquared ) ) {
+		const v1 = vs[ a ];
+		const v2 = vs[ b ];
+		const v3 = vs[ c ];
 
 
-					finalized = false;
+		positions2.push( v1.x, v1.y, v1.z );
+		positions2.push( v2.x, v2.y, v2.z );
+		positions2.push( v3.x, v3.y, v3.z );
 
 
-					const m = geometry.vertices.length;
+		if ( hasNormals ) {
 
 
-					const triA = face.clone();
-					const triB = face.clone();
+			const n1 = ns[ a ];
+			const n2 = ns[ b ];
+			const n3 = ns[ c ];
 
 
-					if ( dab >= dbc && dab >= dac ) {
+			normals2.push( n1.x, n1.y, n1.z );
+			normals2.push( n2.x, n2.y, n2.z );
+			normals2.push( n3.x, n3.y, n3.z );
 
 
-						var vm = va.clone();
-						vm.lerp( vb, 0.5 );
+		}
 
 
-						triA.a = a;
-						triA.b = m;
-						triA.c = c;
+		if ( hasColors ) {
 
 
-						triB.a = m;
-						triB.b = b;
-						triB.c = c;
+			const c1 = cs[ a ];
+			const c2 = cs[ b ];
+			const c3 = cs[ c ];
 
 
-						if ( face.vertexNormals.length === 3 ) {
+			colors2.push( c1.x, c1.y, c1.z );
+			colors2.push( c2.x, c2.y, c2.z );
+			colors2.push( c3.x, c3.y, c3.z );
 
 
-							var vnm = face.vertexNormals[ 0 ].clone();
-							vnm.lerp( face.vertexNormals[ 1 ], 0.5 );
+		}
 
 
-							triA.vertexNormals[ 1 ].copy( vnm );
-							triB.vertexNormals[ 0 ].copy( vnm );
+		if ( hasUVs ) {
 
 
-						}
+			const u1 = us[ a ];
+			const u2 = us[ b ];
+			const u3 = us[ c ];
 
 
-						if ( face.vertexColors.length === 3 ) {
+			uvs2.push( u1.x, u1.y );
+			uvs2.push( u2.x, u2.y );
+			uvs2.push( u3.x, u3.y );
 
 
-							var vcm = face.vertexColors[ 0 ].clone();
-							vcm.lerp( face.vertexColors[ 1 ], 0.5 );
+		}
 
 
-							triA.vertexColors[ 1 ].copy( vcm );
-							triB.vertexColors[ 0 ].copy( vcm );
+		if ( hasUV2s ) {
 
 
-						}
+			const u21 = u2s[ a ];
+			const u22 = u2s[ b ];
+			const u23 = u2s[ c ];
 
 
-						edge = 0;
+			uv2s2.push( u21.x, u21.y );
+			uv2s2.push( u22.x, u22.y );
+			uv2s2.push( u23.x, u23.y );
 
 
-					} else if ( dbc >= dab && dbc >= dac ) {
+		}
 
 
-						var vm = vb.clone();
-						vm.lerp( vc, 0.5 );
+	}
 
 
-						triA.a = a;
-						triA.b = b;
-						triA.c = m;
+	while ( tessellating && iteration < maxIterations ) {
 
 
-						triB.a = m;
-						triB.b = c;
-						triB.c = a;
+		iteration ++;
+		tessellating = false;
 
 
-						if ( face.vertexNormals.length === 3 ) {
+		positions = positions2;
+		positions2 = [];
 
 
-							var vnm = face.vertexNormals[ 1 ].clone();
-							vnm.lerp( face.vertexNormals[ 2 ], 0.5 );
+		if ( hasNormals ) {
 
 
-							triA.vertexNormals[ 2 ].copy( vnm );
+			normals = normals2;
+			normals2 = [];
 
 
-							triB.vertexNormals[ 0 ].copy( vnm );
-							triB.vertexNormals[ 1 ].copy( face.vertexNormals[ 2 ] );
-							triB.vertexNormals[ 2 ].copy( face.vertexNormals[ 0 ] );
+		}
 
 
-						}
+		if ( hasColors ) {
 
 
-						if ( face.vertexColors.length === 3 ) {
+			colors = colors2;
+			colors2 = [];
 
 
-							var vcm = face.vertexColors[ 1 ].clone();
-							vcm.lerp( face.vertexColors[ 2 ], 0.5 );
+		}
 
 
-							triA.vertexColors[ 2 ].copy( vcm );
+		if ( hasUVs ) {
 
 
-							triB.vertexColors[ 0 ].copy( vcm );
-							triB.vertexColors[ 1 ].copy( face.vertexColors[ 2 ] );
-							triB.vertexColors[ 2 ].copy( face.vertexColors[ 0 ] );
+			uvs = uvs2;
+			uvs2 = [];
 
 
-						}
+		}
 
 
-						edge = 1;
+		if ( hasUV2s ) {
 
 
-					} else {
+			uv2s = uv2s2;
+			uv2s2 = [];
 
 
-						var vm = va.clone();
-						vm.lerp( vc, 0.5 );
+		}
 
 
-						triA.a = a;
-						triA.b = b;
-						triA.c = m;
+		for ( var i = 0, i2 = 0, il = positions.length; i < il; i += 9, i2 += 6 ) {
 
 
-						triB.a = m;
-						triB.b = b;
-						triB.c = c;
+			va.fromArray( positions, i + 0 );
+			vb.fromArray( positions, i + 3 );
+			vc.fromArray( positions, i + 6 );
 
 
-						if ( face.vertexNormals.length === 3 ) {
+			if ( hasNormals ) {
 
 
-							var vnm = face.vertexNormals[ 0 ].clone();
-							vnm.lerp( face.vertexNormals[ 2 ], 0.5 );
+				na.fromArray( normals, i + 0 );
+				nb.fromArray( normals, i + 3 );
+				nc.fromArray( normals, i + 6 );
 
 
-							triA.vertexNormals[ 2 ].copy( vnm );
-							triB.vertexNormals[ 0 ].copy( vnm );
+			}
 
 
-						}
+			if ( hasColors ) {
 
 
-						if ( face.vertexColors.length === 3 ) {
+				ca.fromArray( colors, i + 0 );
+				cb.fromArray( colors, i + 3 );
+				cc.fromArray( colors, i + 6 );
 
 
-							var vcm = face.vertexColors[ 0 ].clone();
-							vcm.lerp( face.vertexColors[ 2 ], 0.5 );
+			}
 
 
-							triA.vertexColors[ 2 ].copy( vcm );
-							triB.vertexColors[ 0 ].copy( vcm );
+			if ( hasUVs ) {
 
 
-						}
+				ua.fromArray( uvs, i2 + 0 );
+				ub.fromArray( uvs, i2 + 2 );
+				uc.fromArray( uvs, i2 + 4 );
 
 
-						edge = 2;
+			}
 
 
-					}
+			if ( hasUV2s ) {
 
 
-					faces.push( triA, triB );
-					geometry.vertices.push( vm );
+				u2a.fromArray( uv2s, i2 + 0 );
+				u2b.fromArray( uv2s, i2 + 2 );
+				u2c.fromArray( uv2s, i2 + 4 );
 
 
-					for ( var j = 0, jl = geometry.faceVertexUvs.length; j < jl; j ++ ) {
+			}
 
 
-						if ( geometry.faceVertexUvs[ j ].length ) {
+			const dab = va.distanceToSquared( vb );
+			const dbc = vb.distanceToSquared( vc );
+			const dac = va.distanceToSquared( vc );
 
 
-							const uvs = geometry.faceVertexUvs[ j ][ i ];
+			if ( dab > maxEdgeLengthSquared || dbc > maxEdgeLengthSquared || dac > maxEdgeLengthSquared ) {
 
 
-							const uvA = uvs[ 0 ];
-							const uvB = uvs[ 1 ];
-							const uvC = uvs[ 2 ];
+				tessellating = true;
 
 
-							// AB
+				if ( dab >= dbc && dab >= dac ) {
 
 
-							if ( edge === 0 ) {
+					vm.lerpVectors( va, vb, 0.5 );
+					if ( hasNormals ) nm.lerpVectors( na, nb, 0.5 );
+					if ( hasColors ) cm.lerpColors( ca, cb, 0.5 );
+					if ( hasUVs ) um.lerpVectors( ua, ub, 0.5 );
+					if ( hasUV2s ) u2m.lerpVectors( u2a, u2b, 0.5 );
 
 
-								var uvM = uvA.clone();
-								uvM.lerp( uvB, 0.5 );
+					addTriangle( 0, 3, 2 );
+					addTriangle( 3, 1, 2 );
 
 
-								var uvsTriA = [ uvA.clone(), uvM.clone(), uvC.clone() ];
-								var uvsTriB = [ uvM.clone(), uvB.clone(), uvC.clone() ];
+				} else if ( dbc >= dab && dbc >= dac ) {
 
 
-								// BC
+					vm.lerpVectors( vb, vc, 0.5 );
+					if ( hasNormals ) nm.lerpVectors( nb, nc, 0.5 );
+					if ( hasColors ) cm.lerpColors( cb, cc, 0.5 );
+					if ( hasUVs ) um.lerpVectors( ub, uc, 0.5 );
+					if ( hasUV2s ) u2m.lerpVectors( u2b, u2c, 0.5 );
 
 
-							} else if ( edge === 1 ) {
+					addTriangle( 0, 1, 3 );
+					addTriangle( 3, 2, 0 );
 
 
-								var uvM = uvB.clone();
-								uvM.lerp( uvC, 0.5 );
+				} else {
 
 
-								var uvsTriA = [ uvA.clone(), uvB.clone(), uvM.clone() ];
-								var uvsTriB = [ uvM.clone(), uvC.clone(), uvA.clone() ];
+					vm.lerpVectors( va, vc, 0.5 );
+					if ( hasNormals ) nm.lerpVectors( na, nc, 0.5 );
+					if ( hasColors ) cm.lerpColors( ca, cc, 0.5 );
+					if ( hasUVs ) um.lerpVectors( ua, uc, 0.5 );
+					if ( hasUV2s ) u2m.lerpVectors( u2a, u2c, 0.5 );
 
 
-								// AC
+					addTriangle( 0, 1, 3 );
+					addTriangle( 3, 1, 2 );
 
 
-							} else {
+				}
 
 
-								var uvM = uvA.clone();
-								uvM.lerp( uvC, 0.5 );
+			} else {
 
 
-								var uvsTriA = [ uvA.clone(), uvB.clone(), uvM.clone() ];
-								var uvsTriB = [ uvM.clone(), uvB.clone(), uvC.clone() ];
+				addTriangle( 0, 1, 2 );
 
 
-							}
+			}
 
 
-							faceVertexUvs[ j ].push( uvsTriA, uvsTriB );
+		}
 
 
-						}
+	}
 
 
-					}
+	const geometry2 = new THREE.BufferGeometry();
 
 
-				} else {
+	geometry2.setAttribute( 'position', new THREE.Float32BufferAttribute( positions2, 3 ) );
 
 
-					faces.push( face );
+	if ( hasNormals ) {
 
 
-					for ( var j = 0, jl = geometry.faceVertexUvs.length; j < jl; j ++ ) {
+		geometry2.setAttribute( 'normal', new THREE.Float32BufferAttribute( normals2, 3 ) );
 
 
-						faceVertexUvs[ j ].push( geometry.faceVertexUvs[ j ][ i ] );
+	}
 
 
-					}
+	if ( hasColors ) {
 
 
-				}
+		geometry2.setAttribute( 'color', new THREE.Float32BufferAttribute( colors2, 3 ) );
 
 
-			}
+	}
 
 
-		}
+	if ( hasUVs ) {
 
 
-		geometry.faces = faces;
-		geometry.faceVertexUvs = faceVertexUvs;
+		geometry2.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs2, 2 ) );
 
 
 	}
 	}
 
 
-	if ( isBufferGeometry ) {
-
-		return new THREE.BufferGeometry().fromGeometry( geometry );
+	if ( hasUV2s ) {
 
 
-	} else {
-
-		return geometry;
+		geometry2.setAttribute( 'uv2', new THREE.Float32BufferAttribute( uv2s2, 2 ) );
 
 
 	}
 	}
 
 
+	return geometry2;
+
 };
 };

+ 312 - 1
examples/js/utils/BufferGeometryUtils.js

@@ -585,7 +585,6 @@ THREE.BufferGeometryUtils = {
 						newIndices.push( index.getX( i + 1 ) );
 						newIndices.push( index.getX( i + 1 ) );
 						newIndices.push( index.getX( i + 2 ) );
 						newIndices.push( index.getX( i + 2 ) );
 
 
-
 					} else {
 					} else {
 
 
 						newIndices.push( index.getX( i + 2 ) );
 						newIndices.push( index.getX( i + 2 ) );
@@ -619,6 +618,318 @@ THREE.BufferGeometryUtils = {
 
 
 		}
 		}
 
 
+	},
+
+	/**
+	 * Calculates the morphed attributes of a morphed/skinned BufferGeometry.
+	 * Helpful for Raytracing or Decals.
+	 * @param {Object3D} object
+	 * @return {Object} An Object with original position/normal attributes and morphed ones.
+	 */
+	computeMorphedBufferGeometry: function ( object ) {
+
+		if ( ! object ) {
+
+			console.error( 'Please provide an object' );
+			return null;
+
+		}
+
+		if ( ! object.geometry ) {
+
+			console.error( 'Please provide an object with a geometry' );
+			return null;
+
+		}
+
+		if ( ! object.geometry.isBufferGeometry ) {
+
+			console.error( 'Geometry is not a BufferGeometry' );
+			return null;
+
+		}
+
+		var _vA = new THREE.Vector3();
+		var _vB = new THREE.Vector3();
+		var _vC = new THREE.Vector3();
+
+		var _tempA = new THREE.Vector3();
+		var _tempB = new THREE.Vector3();
+		var _tempC = new THREE.Vector3();
+
+		var _morphA = new THREE.Vector3();
+		var _morphB = new THREE.Vector3();
+		var _morphC = new THREE.Vector3();
+
+		function _calculateMorphedAttributeData(
+			object,
+			material,
+			attribute,
+			morphAttribute,
+			morphTargetsRelative,
+			a,
+			b,
+			c,
+			modifiedAttributeArray
+		) {
+
+			_vA.fromBufferAttribute( attribute, a );
+			_vB.fromBufferAttribute( attribute, b );
+			_vC.fromBufferAttribute( attribute, c );
+
+			var morphInfluences = object.morphTargetInfluences;
+
+			if ( material.morphTargets && morphAttribute && morphInfluences ) {
+
+				_morphA.set( 0, 0, 0 );
+				_morphB.set( 0, 0, 0 );
+				_morphC.set( 0, 0, 0 );
+
+				for ( var i = 0, il = morphAttribute.length; i < il; i ++ ) {
+
+					var influence = morphInfluences[ i ];
+					var morphAttribute = morphAttribute[ i ];
+
+					if ( influence === 0 ) continue;
+
+					_tempA.fromBufferAttribute( morphAttribute, a );
+					_tempB.fromBufferAttribute( morphAttribute, b );
+					_tempC.fromBufferAttribute( morphAttribute, c );
+
+					if ( morphTargetsRelative ) {
+
+						_morphA.addScaledVector( _tempA, influence );
+						_morphB.addScaledVector( _tempB, influence );
+						_morphC.addScaledVector( _tempC, influence );
+
+					} else {
+
+						_morphA.addScaledVector( _tempA.sub( _vA ), influence );
+						_morphB.addScaledVector( _tempB.sub( _vB ), influence );
+						_morphC.addScaledVector( _tempC.sub( _vC ), influence );
+
+					}
+
+				}
+
+				_vA.add( _morphA );
+				_vB.add( _morphB );
+				_vC.add( _morphC );
+
+			}
+
+			if ( object.isSkinnedMesh ) {
+
+				object.boneTransform( a, _vA );
+				object.boneTransform( b, _vB );
+				object.boneTransform( c, _vC );
+
+			}
+
+			modifiedAttributeArray[ a * 3 + 0 ] = _vA.x;
+			modifiedAttributeArray[ a * 3 + 1 ] = _vA.y;
+			modifiedAttributeArray[ a * 3 + 2 ] = _vA.z;
+			modifiedAttributeArray[ b * 3 + 0 ] = _vB.x;
+			modifiedAttributeArray[ b * 3 + 1 ] = _vB.y;
+			modifiedAttributeArray[ b * 3 + 2 ] = _vB.z;
+			modifiedAttributeArray[ c * 3 + 0 ] = _vC.x;
+			modifiedAttributeArray[ c * 3 + 1 ] = _vC.y;
+			modifiedAttributeArray[ c * 3 + 2 ] = _vC.z;
+
+		}
+
+		var geometry = object.geometry;
+		var material = object.material;
+
+		var a, b, c;
+		var index = geometry.index;
+		var positionAttribute = geometry.attributes.position;
+		var morphPosition = geometry.morphAttributes.position;
+		var morphTargetsRelative = geometry.morphTargetsRelative;
+		var normalAttribute = geometry.attributes.normal;
+		var morphNormal = geometry.morphAttributes.position;
+
+		var groups = geometry.groups;
+		var drawRange = geometry.drawRange;
+		var i, j, il, jl;
+		var group, groupMaterial;
+		var start, end;
+
+		var modifiedPosition = new Float32Array( positionAttribute.count * positionAttribute.itemSize );
+		var modifiedNormal = new Float32Array( normalAttribute.count * normalAttribute.itemSize );
+
+		if ( index !== null ) {
+
+			// indexed buffer geometry
+
+			if ( Array.isArray( material ) ) {
+
+				for ( i = 0, il = groups.length; i < il; i ++ ) {
+
+					group = groups[ i ];
+					groupMaterial = material[ group.materialIndex ];
+
+					start = Math.max( group.start, drawRange.start );
+					end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
+
+					for ( j = start, jl = end; j < jl; j += 3 ) {
+
+						a = index.getX( j );
+						b = index.getX( j + 1 );
+						c = index.getX( j + 2 );
+
+						_calculateMorphedAttributeData(
+							object,
+							groupMaterial,
+							positionAttribute,
+							morphPosition,
+							morphTargetsRelative,
+							a, b, c,
+							modifiedPosition
+						);
+
+						_calculateMorphedAttributeData(
+							object,
+							groupMaterial,
+							normalAttribute,
+							morphNormal,
+							morphTargetsRelative,
+							a, b, c,
+							modifiedNormal
+						);
+
+					}
+
+				}
+
+			} else {
+
+				start = Math.max( 0, drawRange.start );
+				end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
+
+				for ( i = start, il = end; i < il; i += 3 ) {
+
+					a = index.getX( i );
+					b = index.getX( i + 1 );
+					c = index.getX( i + 2 );
+
+					_calculateMorphedAttributeData(
+						object,
+						material,
+						positionAttribute,
+						morphPosition,
+						morphTargetsRelative,
+						a, b, c,
+						modifiedPosition
+					);
+
+					_calculateMorphedAttributeData(
+						object,
+						material,
+						normalAttribute,
+						morphNormal,
+						morphTargetsRelative,
+						a, b, c,
+						modifiedNormal
+					);
+
+				}
+
+			}
+
+		} else if ( positionAttribute !== undefined ) {
+
+			// non-indexed buffer geometry
+
+			if ( Array.isArray( material ) ) {
+
+				for ( i = 0, il = groups.length; i < il; i ++ ) {
+
+					group = groups[ i ];
+					groupMaterial = material[ group.materialIndex ];
+
+					start = Math.max( group.start, drawRange.start );
+					end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
+
+					for ( j = start, jl = end; j < jl; j += 3 ) {
+
+						a = j;
+						b = j + 1;
+						c = j + 2;
+
+						_calculateMorphedAttributeData(
+							object,
+							groupMaterial,
+							positionAttribute,
+							morphPosition,
+							morphTargetsRelative,
+							a, b, c,
+							modifiedPosition
+						);
+
+						_calculateMorphedAttributeData(
+							object,
+							groupMaterial,
+							normalAttribute,
+							morphNormal,
+							morphTargetsRelative,
+							a, b, c,
+							modifiedNormal
+						);
+
+					}
+
+				}
+
+			} else {
+
+				start = Math.max( 0, drawRange.start );
+				end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) );
+
+				for ( i = start, il = end; i < il; i += 3 ) {
+
+					a = i;
+					b = i + 1;
+					c = i + 2;
+
+					_calculateMorphedAttributeData(
+						object,
+						material,
+						positionAttribute,
+						morphPosition,
+						morphTargetsRelative,
+						a, b, c,
+						modifiedPosition
+					);
+
+					_calculateMorphedAttributeData(
+						object,
+						material,
+						normalAttribute,
+						morphNormal,
+						morphTargetsRelative,
+						a, b, c,
+						modifiedNormal
+					);
+
+				}
+
+			}
+
+		}
+
+		var morphedPositionAttribute = new THREE.Float32BufferAttribute( modifiedPosition, 3 );
+		var morphedNormalAttribute = new THREE.Float32BufferAttribute( modifiedNormal, 3 );
+
+		return {
+
+			positionAttribute: positionAttribute,
+			normalAttribute: normalAttribute,
+			morphedPositionAttribute: morphedPositionAttribute,
+			morphedNormalAttribute: morphedNormalAttribute
+
+		};
+
 	}
 	}
 
 
 };
 };

+ 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 _m1 = new Matrix4();
 const _obj = new Object3D();
 const _obj = new Object3D();
 const _offset = new Vector3();
 const _offset = new Vector3();
 
 
 function Geometry() {
 function Geometry() {
 
 
-	Object.defineProperty( this, 'id', { value: _geometryId += 2 } );
-
 	this.uuid = MathUtils.generateUUID();
 	this.uuid = MathUtils.generateUUID();
 
 
 	this.name = '';
 	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 () {
 	dispose: function () {
 
 
 		this.dispatchEvent( { type: 'dispose' } );
 		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 };
 export { Geometry };

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

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

+ 0 - 14
examples/jsm/modifiers/SubdivisionModifier.d.ts

@@ -1,14 +0,0 @@
-import {
-	BufferGeometry,
-	Geometry
-} from '../../../src/Three';
-
-export class SubdivisionModifier {
-
-	constructor( subdivisions?: number );
-	subdivisions: number;
-
-	modify( geometry: Geometry | BufferGeometry ): Geometry | BufferGeometry;
-	smooth( geometry: Geometry ): void;
-
-}

+ 0 - 431
examples/jsm/modifiers/SubdivisionModifier.js

@@ -1,431 +0,0 @@
-import {
-	BufferGeometry,
-	Face3,
-	Geometry,
-	Vector2,
-	Vector3
-} from '../../../build/three.module.js';
-
-/**
- *	Subdivision Geometry Modifier
- *		using Loop Subdivision Scheme
- *
- *	References:
- *		http://graphics.stanford.edu/~mdfisher/subdivision.html
- *		http://www.holmes3d.net/graphics/subdivision/
- *		http://www.cs.rutgers.edu/~decarlo/readings/subdiv-sg00c.pdf
- *
- *	Known Issues:
- *		- currently doesn't handle "Sharp Edges"
- */
-
-var SubdivisionModifier = function ( subdivisions ) {
-
-	this.subdivisions = ( subdivisions === undefined ) ? 1 : subdivisions;
-
-};
-
-// Applies the "modify" pattern
-SubdivisionModifier.prototype.modify = function ( geometry ) {
-
-	var isBufferGeometry = geometry.isBufferGeometry;
-
-	if ( isBufferGeometry ) {
-
-		geometry = new Geometry().fromBufferGeometry( geometry );
-
-	} else {
-
-		geometry = geometry.clone();
-
-	}
-
-	geometry.mergeVertices( 6 );
-
-	var repeats = this.subdivisions;
-
-	while ( repeats -- > 0 ) {
-
-		this.smooth( geometry );
-
-	}
-
-	geometry.computeFaceNormals();
-	geometry.computeVertexNormals();
-
-	if ( isBufferGeometry ) {
-
-		return new BufferGeometry().fromGeometry( geometry );
-
-	} else {
-
-		return geometry;
-
-	}
-
-};
-
-( function () {
-
-	// Some constants
-	var ABC = [ 'a', 'b', 'c' ];
-
-
-	function getEdge( a, b, map ) {
-
-		var vertexIndexA = Math.min( a, b );
-		var vertexIndexB = Math.max( a, b );
-
-		var key = vertexIndexA + '_' + vertexIndexB;
-
-		return map[ key ];
-
-	}
-
-
-	function processEdge( a, b, vertices, map, face, metaVertices ) {
-
-		var vertexIndexA = Math.min( a, b );
-		var vertexIndexB = Math.max( a, b );
-
-		var key = vertexIndexA + '_' + vertexIndexB;
-
-		var edge;
-
-		if ( key in map ) {
-
-			edge = map[ key ];
-
-		} else {
-
-			var vertexA = vertices[ vertexIndexA ];
-			var vertexB = vertices[ vertexIndexB ];
-
-			edge = {
-
-				a: vertexA, // pointer reference
-				b: vertexB,
-				newEdge: null,
-				// aIndex: a, // numbered reference
-				// bIndex: b,
-				faces: [] // pointers to face
-
-			};
-
-			map[ key ] = edge;
-
-		}
-
-		edge.faces.push( face );
-
-		metaVertices[ a ].edges.push( edge );
-		metaVertices[ b ].edges.push( edge );
-
-
-	}
-
-	function generateLookups( vertices, faces, metaVertices, edges ) {
-
-		var i, il, face;
-
-		for ( i = 0, il = vertices.length; i < il; i ++ ) {
-
-			metaVertices[ i ] = { edges: [] };
-
-		}
-
-		for ( i = 0, il = faces.length; i < il; i ++ ) {
-
-			face = faces[ i ];
-
-			processEdge( face.a, face.b, vertices, edges, face, metaVertices );
-			processEdge( face.b, face.c, vertices, edges, face, metaVertices );
-			processEdge( face.c, face.a, vertices, edges, face, metaVertices );
-
-		}
-
-	}
-
-	function newFace( newFaces, a, b, c, materialIndex ) {
-
-		newFaces.push( new Face3( a, b, c, undefined, undefined, materialIndex ) );
-
-	}
-
-	function midpoint( a, b ) {
-
-		return ( Math.abs( b - a ) / 2 ) + Math.min( a, b );
-
-	}
-
-	function newUv( newUvs, a, b, c ) {
-
-		newUvs.push( [ a.clone(), b.clone(), c.clone() ] );
-
-	}
-
-	/////////////////////////////
-
-	// Performs one iteration of Subdivision
-	SubdivisionModifier.prototype.smooth = function ( geometry ) {
-
-		var tmp = new Vector3();
-
-		var oldVertices, oldFaces, oldUvs;
-		var newVertices, newFaces, newUVs = [];
-
-		var n, i, il, j, k;
-		var metaVertices, sourceEdges;
-
-		// new stuff.
-		var sourceEdges, newEdgeVertices, newSourceVertices;
-
-		oldVertices = geometry.vertices; // { x, y, z}
-		oldFaces = geometry.faces; // { a: oldVertex1, b: oldVertex2, c: oldVertex3 }
-		oldUvs = geometry.faceVertexUvs;
-
-		var hasUvs = oldUvs[ 0 ] !== undefined && oldUvs[ 0 ].length > 0;
-
-		if ( hasUvs ) {
-
-			for ( var j = 0; j < oldUvs.length; j ++ ) {
-
-				newUVs.push( [] );
-
-			}
-
-		}
-
-		/******************************************************
-		 *
-		 * Step 0: Preprocess Geometry to Generate edges Lookup
-		 *
-		 *******************************************************/
-
-		metaVertices = new Array( oldVertices.length );
-		sourceEdges = {}; // Edge => { oldVertex1, oldVertex2, faces[]  }
-
-		generateLookups( oldVertices, oldFaces, metaVertices, sourceEdges );
-
-
-		/******************************************************
-		 *
-		 *	Step 1.
-		 *	For each edge, create a new Edge Vertex,
-		 *	then position it.
-		 *
-		 *******************************************************/
-
-		newEdgeVertices = [];
-		var other, currentEdge, newEdge, face;
-		var edgeVertexWeight, adjacentVertexWeight, connectedFaces;
-
-		for ( i in sourceEdges ) {
-
-			currentEdge = sourceEdges[ i ];
-			newEdge = new Vector3();
-
-			edgeVertexWeight = 3 / 8;
-			adjacentVertexWeight = 1 / 8;
-
-			connectedFaces = currentEdge.faces.length;
-
-			// check how many linked faces. 2 should be correct.
-			if ( connectedFaces != 2 ) {
-
-				// if length is not 2, handle condition
-				edgeVertexWeight = 0.5;
-				adjacentVertexWeight = 0;
-
-				if ( connectedFaces != 1 ) {
-
-					// console.warn( 'Subdivision Modifier: Number of connected faces != 2, is: ', connectedFaces, currentEdge );
-
-				}
-
-			}
-
-			newEdge.addVectors( currentEdge.a, currentEdge.b ).multiplyScalar( edgeVertexWeight );
-
-			tmp.set( 0, 0, 0 );
-
-			for ( j = 0; j < connectedFaces; j ++ ) {
-
-				face = currentEdge.faces[ j ];
-
-				for ( k = 0; k < 3; k ++ ) {
-
-					other = oldVertices[ face[ ABC[ k ] ] ];
-					if ( other !== currentEdge.a && other !== currentEdge.b ) break;
-
-				}
-
-				tmp.add( other );
-
-			}
-
-			tmp.multiplyScalar( adjacentVertexWeight );
-			newEdge.add( tmp );
-
-			currentEdge.newEdge = newEdgeVertices.length;
-			newEdgeVertices.push( newEdge );
-
-			// console.log(currentEdge, newEdge);
-
-		}
-
-		/******************************************************
-		 *
-		 *	Step 2.
-		 *	Reposition each source vertices.
-		 *
-		 *******************************************************/
-
-		var beta, sourceVertexWeight, connectingVertexWeight;
-		var connectingEdge, connectingEdges, oldVertex, newSourceVertex;
-		newSourceVertices = [];
-
-		for ( i = 0, il = oldVertices.length; i < il; i ++ ) {
-
-			oldVertex = oldVertices[ i ];
-
-			// find all connecting edges (using lookupTable)
-			connectingEdges = metaVertices[ i ].edges;
-			n = connectingEdges.length;
-
-			if ( n == 3 ) {
-
-				beta = 3 / 16;
-
-			} else if ( n > 3 ) {
-
-				beta = 3 / ( 8 * n ); // Warren's modified formula
-
-			}
-
-			// Loop's original beta formula
-			// beta = 1 / n * ( 5/8 - Math.pow( 3/8 + 1/4 * Math.cos( 2 * Math. PI / n ), 2) );
-
-			sourceVertexWeight = 1 - n * beta;
-			connectingVertexWeight = beta;
-
-			if ( n <= 2 ) {
-
-				// crease and boundary rules
-				// console.warn('crease and boundary rules');
-
-				if ( n == 2 ) {
-
-					// console.warn( '2 connecting edges', connectingEdges );
-					sourceVertexWeight = 3 / 4;
-					connectingVertexWeight = 1 / 8;
-
-					// sourceVertexWeight = 1;
-					// connectingVertexWeight = 0;
-
-				} else if ( n == 1 ) {
-
-					// console.warn( 'only 1 connecting edge' );
-
-				} else if ( n == 0 ) {
-
-					// console.warn( '0 connecting edges' );
-
-				}
-
-			}
-
-			newSourceVertex = oldVertex.clone().multiplyScalar( sourceVertexWeight );
-
-			tmp.set( 0, 0, 0 );
-
-			for ( j = 0; j < n; j ++ ) {
-
-				connectingEdge = connectingEdges[ j ];
-				other = connectingEdge.a !== oldVertex ? connectingEdge.a : connectingEdge.b;
-				tmp.add( other );
-
-			}
-
-			tmp.multiplyScalar( connectingVertexWeight );
-			newSourceVertex.add( tmp );
-
-			newSourceVertices.push( newSourceVertex );
-
-		}
-
-
-		/******************************************************
-		 *
-		 *	Step 3.
-		 *	Generate Faces between source vertices
-		 *	and edge vertices.
-		 *
-		 *******************************************************/
-
-		newVertices = newSourceVertices.concat( newEdgeVertices );
-		var sl = newSourceVertices.length, edge1, edge2, edge3;
-		newFaces = [];
-
-		var uv, x0, x1, x2;
-		var x3 = new Vector2();
-		var x4 = new Vector2();
-		var x5 = new Vector2();
-
-		for ( i = 0, il = oldFaces.length; i < il; i ++ ) {
-
-			face = oldFaces[ i ];
-
-			// find the 3 new edges vertex of each old face
-
-			edge1 = getEdge( face.a, face.b, sourceEdges ).newEdge + sl;
-			edge2 = getEdge( face.b, face.c, sourceEdges ).newEdge + sl;
-			edge3 = getEdge( face.c, face.a, sourceEdges ).newEdge + sl;
-
-			// create 4 faces.
-
-			newFace( newFaces, edge1, edge2, edge3, face.materialIndex );
-			newFace( newFaces, face.a, edge1, edge3, face.materialIndex );
-			newFace( newFaces, face.b, edge2, edge1, face.materialIndex );
-			newFace( newFaces, face.c, edge3, edge2, face.materialIndex );
-
-			// create 4 new uv's
-
-			if ( hasUvs ) {
-
-				for ( var j = 0; j < oldUvs.length; j ++ ) {
-
-					uv = oldUvs[ j ][ i ];
-
-					x0 = uv[ 0 ];
-					x1 = uv[ 1 ];
-					x2 = uv[ 2 ];
-
-					x3.set( midpoint( x0.x, x1.x ), midpoint( x0.y, x1.y ) );
-					x4.set( midpoint( x1.x, x2.x ), midpoint( x1.y, x2.y ) );
-					x5.set( midpoint( x0.x, x2.x ), midpoint( x0.y, x2.y ) );
-
-					newUv( newUVs[ j ], x3, x4, x5 );
-					newUv( newUVs[ j ], x0, x3, x5 );
-
-					newUv( newUVs[ j ], x1, x4, x3 );
-					newUv( newUVs[ j ], x2, x5, x4 );
-
-				}
-
-			}
-
-		}
-
-		// Overwrite old arrays
-		geometry.vertices = newVertices;
-		geometry.faces = newFaces;
-		if ( hasUvs ) geometry.faceVertexUvs = newUVs;
-
-		// console.log('done');
-
-	};
-
-} )();
-
-export { SubdivisionModifier };

+ 2 - 3
examples/jsm/modifiers/TessellateModifier.d.ts

@@ -5,11 +5,10 @@ import {
 
 
 export class TessellateModifier {
 export class TessellateModifier {
 
 
-	constructor( maxEdgeLength?: number, maxIterations?: number, maxFaces?: number );
+	constructor( maxEdgeLength?: number, maxIterations?: number );
 	maxEdgeLength: number = 0.1;
 	maxEdgeLength: number = 0.1;
 	maxIterations: number = 6;
 	maxIterations: number = 6;
-	maxFaces: number = Infinity;
 
 
-	modify( geometry: Geometry | BufferGeometry ): Geometry | BufferGeometry;
+	modify( geometry: BufferGeometry ): BufferGeometry;
 
 
 }
 }

+ 196 - 168
examples/jsm/modifiers/TessellateModifier.js

@@ -1,282 +1,310 @@
 import {
 import {
 	BufferGeometry,
 	BufferGeometry,
-	Face3,
-	Geometry
+	Color,
+	Float32BufferAttribute,
+	Vector2,
+	Vector3
 } from '../../../build/three.module.js';
 } from '../../../build/three.module.js';
 
 
 /**
 /**
  * Break faces with edges longer than maxEdgeLength
  * Break faces with edges longer than maxEdgeLength
  */
  */
 
 
-var TessellateModifier = function ( maxEdgeLength = 0.1, maxIterations = 6, maxFaces = Infinity ) {
+var TessellateModifier = function ( maxEdgeLength = 0.1, maxIterations = 6 ) {
 
 
 	this.maxEdgeLength = maxEdgeLength;
 	this.maxEdgeLength = maxEdgeLength;
 	this.maxIterations = maxIterations;
 	this.maxIterations = maxIterations;
-	this.maxFaces = maxFaces;
 
 
 };
 };
 
 
-// Applies the "modify" pattern
 TessellateModifier.prototype.modify = function ( geometry ) {
 TessellateModifier.prototype.modify = function ( geometry ) {
 
 
-	const isBufferGeometry = geometry.isBufferGeometry;
+	if ( geometry.isGeometry === true ) {
 
 
-	if ( isBufferGeometry ) {
+		console.error( 'THREE.TessellateModifier no longer supports Geometry. Use BufferGeometry instead.' );
+		return geometry;
 
 
-		geometry = new Geometry().fromBufferGeometry( geometry );
+	}
 
 
-	} else {
+	if ( geometry.index !== null ) {
 
 
-		geometry = geometry.clone();
+		geometry = geometry.toNonIndexed();
 
 
 	}
 	}
 
 
-	geometry.mergeVertices( 6 );
+	//
 
 
-	let finalized = false;
-	let iteration = 0;
+	const maxIterations = this.maxIterations;
 	const maxEdgeLengthSquared = this.maxEdgeLength * this.maxEdgeLength;
 	const maxEdgeLengthSquared = this.maxEdgeLength * this.maxEdgeLength;
 
 
-	let edge;
-
-	while ( ! finalized && iteration < this.maxIterations && geometry.faces.length < this.maxFaces ) {
-
-		const faces = [];
-		const faceVertexUvs = [];
-
-		finalized = true;
-		iteration ++;
-
-		for ( var i = 0, il = geometry.faceVertexUvs.length; i < il; i ++ ) {
-
-			faceVertexUvs[ i ] = [];
-
-		}
-
-		for ( var i = 0, il = geometry.faces.length; i < il; i ++ ) {
+	const va = new Vector3();
+	const vb = new Vector3();
+	const vc = new Vector3();
+	const vm = new Vector3();
+	const vs = [ va, vb, vc, vm ];
+
+	const na = new Vector3();
+	const nb = new Vector3();
+	const nc = new Vector3();
+	const nm = new Vector3();
+	const ns = [ na, nb, nc, nm ];
+
+	const ca = new Color();
+	const cb = new Color();
+	const cc = new Color();
+	const cm = new Color();
+	const cs = [ ca, cb, cc, cm ];
+
+	const ua = new Vector2();
+	const ub = new Vector2();
+	const uc = new Vector2();
+	const um = new Vector2();
+	const us = [ ua, ub, uc, um ];
+
+	const u2a = new Vector2();
+	const u2b = new Vector2();
+	const u2c = new Vector2();
+	const u2m = new Vector2();
+	const u2s = [ u2a, u2b, u2c, u2m ];
+
+	const attributes = geometry.attributes;
+	const hasNormals = attributes.normal !== undefined;
+	const hasColors = attributes.color !== undefined;
+	const hasUVs = attributes.uv !== undefined;
+	const hasUV2s = attributes.uv2 !== undefined;
+
+	let positions = attributes.position.array;
+	let normals = hasNormals ? attributes.normal.array : null;
+	let colors = hasColors ? attributes.color.array : null;
+	let uvs = hasUVs ? attributes.uv.array : null;
+	let uv2s = hasUV2s ? attributes.uv2.array : null;
+
+	let positions2 = positions;
+	let normals2 = normals;
+	let colors2 = colors;
+	let uvs2 = uvs;
+	let uv2s2 = uv2s;
 
 
-			const face = geometry.faces[ i ];
-
-			if ( face instanceof Face3 ) {
-
-				const a = face.a;
-				const b = face.b;
-				const c = face.c;
-
-				const va = geometry.vertices[ a ];
-				const vb = geometry.vertices[ b ];
-				const vc = geometry.vertices[ c ];
-
-				const dab = va.distanceToSquared( vb );
-				const dbc = vb.distanceToSquared( vc );
-				const dac = va.distanceToSquared( vc );
+	let iteration = 0;
+	let tessellating = true;
 
 
-				const limitReached = ( faces.length + il - i ) >= this.maxFaces;
+	function addTriangle( a, b, c ) {
 
 
-				if ( ! limitReached && ( dab > maxEdgeLengthSquared || dbc > maxEdgeLengthSquared || dac > maxEdgeLengthSquared ) ) {
+		const v1 = vs[ a ];
+		const v2 = vs[ b ];
+		const v3 = vs[ c ];
 
 
-					finalized = false;
+		positions2.push( v1.x, v1.y, v1.z );
+		positions2.push( v2.x, v2.y, v2.z );
+		positions2.push( v3.x, v3.y, v3.z );
 
 
-					const m = geometry.vertices.length;
+		if ( hasNormals ) {
 
 
-					const triA = face.clone();
-					const triB = face.clone();
+			const n1 = ns[ a ];
+			const n2 = ns[ b ];
+			const n3 = ns[ c ];
 
 
-					if ( dab >= dbc && dab >= dac ) {
+			normals2.push( n1.x, n1.y, n1.z );
+			normals2.push( n2.x, n2.y, n2.z );
+			normals2.push( n3.x, n3.y, n3.z );
 
 
-						var vm = va.clone();
-						vm.lerp( vb, 0.5 );
+		}
 
 
-						triA.a = a;
-						triA.b = m;
-						triA.c = c;
+		if ( hasColors ) {
 
 
-						triB.a = m;
-						triB.b = b;
-						triB.c = c;
+			const c1 = cs[ a ];
+			const c2 = cs[ b ];
+			const c3 = cs[ c ];
 
 
-						if ( face.vertexNormals.length === 3 ) {
+			colors2.push( c1.x, c1.y, c1.z );
+			colors2.push( c2.x, c2.y, c2.z );
+			colors2.push( c3.x, c3.y, c3.z );
 
 
-							var vnm = face.vertexNormals[ 0 ].clone();
-							vnm.lerp( face.vertexNormals[ 1 ], 0.5 );
+		}
 
 
-							triA.vertexNormals[ 1 ].copy( vnm );
-							triB.vertexNormals[ 0 ].copy( vnm );
+		if ( hasUVs ) {
 
 
-						}
+			const u1 = us[ a ];
+			const u2 = us[ b ];
+			const u3 = us[ c ];
 
 
-						if ( face.vertexColors.length === 3 ) {
+			uvs2.push( u1.x, u1.y );
+			uvs2.push( u2.x, u2.y );
+			uvs2.push( u3.x, u3.y );
 
 
-							var vcm = face.vertexColors[ 0 ].clone();
-							vcm.lerp( face.vertexColors[ 1 ], 0.5 );
+		}
 
 
-							triA.vertexColors[ 1 ].copy( vcm );
-							triB.vertexColors[ 0 ].copy( vcm );
+		if ( hasUV2s ) {
 
 
-						}
+			const u21 = u2s[ a ];
+			const u22 = u2s[ b ];
+			const u23 = u2s[ c ];
 
 
-						edge = 0;
+			uv2s2.push( u21.x, u21.y );
+			uv2s2.push( u22.x, u22.y );
+			uv2s2.push( u23.x, u23.y );
 
 
-					} else if ( dbc >= dab && dbc >= dac ) {
+		}
 
 
-						var vm = vb.clone();
-						vm.lerp( vc, 0.5 );
+	}
 
 
-						triA.a = a;
-						triA.b = b;
-						triA.c = m;
+	while ( tessellating && iteration < maxIterations ) {
 
 
-						triB.a = m;
-						triB.b = c;
-						triB.c = a;
+		iteration ++;
+		tessellating = false;
 
 
-						if ( face.vertexNormals.length === 3 ) {
+		positions = positions2;
+		positions2 = [];
 
 
-							var vnm = face.vertexNormals[ 1 ].clone();
-							vnm.lerp( face.vertexNormals[ 2 ], 0.5 );
+		if ( hasNormals ) {
 
 
-							triA.vertexNormals[ 2 ].copy( vnm );
+			normals = normals2;
+			normals2 = [];
 
 
-							triB.vertexNormals[ 0 ].copy( vnm );
-							triB.vertexNormals[ 1 ].copy( face.vertexNormals[ 2 ] );
-							triB.vertexNormals[ 2 ].copy( face.vertexNormals[ 0 ] );
+		}
 
 
-						}
+		if ( hasColors ) {
 
 
-						if ( face.vertexColors.length === 3 ) {
+			colors = colors2;
+			colors2 = [];
 
 
-							var vcm = face.vertexColors[ 1 ].clone();
-							vcm.lerp( face.vertexColors[ 2 ], 0.5 );
+		}
 
 
-							triA.vertexColors[ 2 ].copy( vcm );
+		if ( hasUVs ) {
 
 
-							triB.vertexColors[ 0 ].copy( vcm );
-							triB.vertexColors[ 1 ].copy( face.vertexColors[ 2 ] );
-							triB.vertexColors[ 2 ].copy( face.vertexColors[ 0 ] );
+			uvs = uvs2;
+			uvs2 = [];
 
 
-						}
+		}
 
 
-						edge = 1;
+		if ( hasUV2s ) {
 
 
-					} else {
+			uv2s = uv2s2;
+			uv2s2 = [];
 
 
-						var vm = va.clone();
-						vm.lerp( vc, 0.5 );
+		}
 
 
-						triA.a = a;
-						triA.b = b;
-						triA.c = m;
+		for ( var i = 0, i2 = 0, il = positions.length; i < il; i += 9, i2 += 6 ) {
 
 
-						triB.a = m;
-						triB.b = b;
-						triB.c = c;
+			va.fromArray( positions, i + 0 );
+			vb.fromArray( positions, i + 3 );
+			vc.fromArray( positions, i + 6 );
 
 
-						if ( face.vertexNormals.length === 3 ) {
+			if ( hasNormals ) {
 
 
-							var vnm = face.vertexNormals[ 0 ].clone();
-							vnm.lerp( face.vertexNormals[ 2 ], 0.5 );
+				na.fromArray( normals, i + 0 );
+				nb.fromArray( normals, i + 3 );
+				nc.fromArray( normals, i + 6 );
 
 
-							triA.vertexNormals[ 2 ].copy( vnm );
-							triB.vertexNormals[ 0 ].copy( vnm );
+			}
 
 
-						}
+			if ( hasColors ) {
 
 
-						if ( face.vertexColors.length === 3 ) {
+				ca.fromArray( colors, i + 0 );
+				cb.fromArray( colors, i + 3 );
+				cc.fromArray( colors, i + 6 );
 
 
-							var vcm = face.vertexColors[ 0 ].clone();
-							vcm.lerp( face.vertexColors[ 2 ], 0.5 );
+			}
 
 
-							triA.vertexColors[ 2 ].copy( vcm );
-							triB.vertexColors[ 0 ].copy( vcm );
+			if ( hasUVs ) {
 
 
-						}
+				ua.fromArray( uvs, i2 + 0 );
+				ub.fromArray( uvs, i2 + 2 );
+				uc.fromArray( uvs, i2 + 4 );
 
 
-						edge = 2;
+			}
 
 
-					}
+			if ( hasUV2s ) {
 
 
-					faces.push( triA, triB );
-					geometry.vertices.push( vm );
+				u2a.fromArray( uv2s, i2 + 0 );
+				u2b.fromArray( uv2s, i2 + 2 );
+				u2c.fromArray( uv2s, i2 + 4 );
 
 
-					for ( var j = 0, jl = geometry.faceVertexUvs.length; j < jl; j ++ ) {
+			}
 
 
-						if ( geometry.faceVertexUvs[ j ].length ) {
+			const dab = va.distanceToSquared( vb );
+			const dbc = vb.distanceToSquared( vc );
+			const dac = va.distanceToSquared( vc );
 
 
-							const uvs = geometry.faceVertexUvs[ j ][ i ];
+			if ( dab > maxEdgeLengthSquared || dbc > maxEdgeLengthSquared || dac > maxEdgeLengthSquared ) {
 
 
-							const uvA = uvs[ 0 ];
-							const uvB = uvs[ 1 ];
-							const uvC = uvs[ 2 ];
+				tessellating = true;
 
 
-							// AB
+				if ( dab >= dbc && dab >= dac ) {
 
 
-							if ( edge === 0 ) {
+					vm.lerpVectors( va, vb, 0.5 );
+					if ( hasNormals ) nm.lerpVectors( na, nb, 0.5 );
+					if ( hasColors ) cm.lerpColors( ca, cb, 0.5 );
+					if ( hasUVs ) um.lerpVectors( ua, ub, 0.5 );
+					if ( hasUV2s ) u2m.lerpVectors( u2a, u2b, 0.5 );
 
 
-								var uvM = uvA.clone();
-								uvM.lerp( uvB, 0.5 );
+					addTriangle( 0, 3, 2 );
+					addTriangle( 3, 1, 2 );
 
 
-								var uvsTriA = [ uvA.clone(), uvM.clone(), uvC.clone() ];
-								var uvsTriB = [ uvM.clone(), uvB.clone(), uvC.clone() ];
+				} else if ( dbc >= dab && dbc >= dac ) {
 
 
-								// BC
+					vm.lerpVectors( vb, vc, 0.5 );
+					if ( hasNormals ) nm.lerpVectors( nb, nc, 0.5 );
+					if ( hasColors ) cm.lerpColors( cb, cc, 0.5 );
+					if ( hasUVs ) um.lerpVectors( ub, uc, 0.5 );
+					if ( hasUV2s ) u2m.lerpVectors( u2b, u2c, 0.5 );
 
 
-							} else if ( edge === 1 ) {
+					addTriangle( 0, 1, 3 );
+					addTriangle( 3, 2, 0 );
 
 
-								var uvM = uvB.clone();
-								uvM.lerp( uvC, 0.5 );
+				} else {
 
 
-								var uvsTriA = [ uvA.clone(), uvB.clone(), uvM.clone() ];
-								var uvsTriB = [ uvM.clone(), uvC.clone(), uvA.clone() ];
+					vm.lerpVectors( va, vc, 0.5 );
+					if ( hasNormals ) nm.lerpVectors( na, nc, 0.5 );
+					if ( hasColors ) cm.lerpColors( ca, cc, 0.5 );
+					if ( hasUVs ) um.lerpVectors( ua, uc, 0.5 );
+					if ( hasUV2s ) u2m.lerpVectors( u2a, u2c, 0.5 );
 
 
-								// AC
+					addTriangle( 0, 1, 3 );
+					addTriangle( 3, 1, 2 );
 
 
-							} else {
+				}
 
 
-								var uvM = uvA.clone();
-								uvM.lerp( uvC, 0.5 );
+			} else {
 
 
-								var uvsTriA = [ uvA.clone(), uvB.clone(), uvM.clone() ];
-								var uvsTriB = [ uvM.clone(), uvB.clone(), uvC.clone() ];
+				addTriangle( 0, 1, 2 );
 
 
-							}
+			}
 
 
-							faceVertexUvs[ j ].push( uvsTriA, uvsTriB );
+		}
 
 
-						}
+	}
 
 
-					}
+	const geometry2 = new BufferGeometry();
 
 
-				} else {
+	geometry2.setAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) );
 
 
-					faces.push( face );
+	if ( hasNormals ) {
 
 
-					for ( var j = 0, jl = geometry.faceVertexUvs.length; j < jl; j ++ ) {
+		geometry2.setAttribute( 'normal', new Float32BufferAttribute( normals2, 3 ) );
 
 
-						faceVertexUvs[ j ].push( geometry.faceVertexUvs[ j ][ i ] );
+	}
 
 
-					}
+	if ( hasColors ) {
 
 
-				}
+		geometry2.setAttribute( 'color', new Float32BufferAttribute( colors2, 3 ) );
 
 
-			}
+	}
 
 
-		}
+	if ( hasUVs ) {
 
 
-		geometry.faces = faces;
-		geometry.faceVertexUvs = faceVertexUvs;
+		geometry2.setAttribute( 'uv', new Float32BufferAttribute( uvs2, 2 ) );
 
 
 	}
 	}
 
 
-	if ( isBufferGeometry ) {
-
-		return new BufferGeometry().fromGeometry( geometry );
+	if ( hasUV2s ) {
 
 
-	} else {
-
-		return geometry;
+		geometry2.setAttribute( 'uv2', new Float32BufferAttribute( uv2s2, 2 ) );
 
 
 	}
 	}
 
 
+	return geometry2;
+
 };
 };
 
 
 export { TessellateModifier };
 export { TessellateModifier };

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

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

+ 313 - 0
examples/jsm/utils/BufferGeometryUtils.js

@@ -1,6 +1,7 @@
 import {
 import {
 	BufferAttribute,
 	BufferAttribute,
 	BufferGeometry,
 	BufferGeometry,
+	Float32BufferAttribute,
 	InterleavedBuffer,
 	InterleavedBuffer,
 	InterleavedBufferAttribute,
 	InterleavedBufferAttribute,
 	TriangleFanDrawMode,
 	TriangleFanDrawMode,
@@ -631,6 +632,318 @@ var BufferGeometryUtils = {
 
 
 	}
 	}
 
 
+	/**
+	 * Calculates the morphed attributes of a morphed/skinned BufferGeometry.
+	 * Helpful for Raytracing or Decals.
+	 * @param {Object3D} object
+	 * @return {Object} An Object with original position/normal attributes and morphed ones.
+	 */
+	computeMorphedBufferGeometry: function ( object ) {
+
+		if ( ! object ) {
+
+			console.error( 'Please provide an object' );
+			return null;
+
+		}
+
+		if ( ! object.geometry ) {
+
+			console.error( 'Please provide an object with a geometry' );
+			return null;
+
+		}
+
+		if ( ! object.geometry.isBufferGeometry ) {
+
+			console.error( 'Geometry is not a BufferGeometry' );
+			return null;
+
+		}
+
+		var _vA = new Vector3();
+		var _vB = new Vector3();
+		var _vC = new Vector3();
+
+		var _tempA = new Vector3();
+		var _tempB = new Vector3();
+		var _tempC = new Vector3();
+
+		var _morphA = new Vector3();
+		var _morphB = new Vector3();
+		var _morphC = new Vector3();
+
+		function _calculateMorphedAttributeData(
+			object,
+			material,
+			attribute,
+			morphAttribute,
+			morphTargetsRelative,
+			a,
+			b,
+			c,
+			modifiedAttributeArray
+		) {
+
+			_vA.fromBufferAttribute( attribute, a );
+			_vB.fromBufferAttribute( attribute, b );
+			_vC.fromBufferAttribute( attribute, c );
+
+			var morphInfluences = object.morphTargetInfluences;
+
+			if ( material.morphTargets && morphAttribute && morphInfluences ) {
+
+				_morphA.set( 0, 0, 0 );
+				_morphB.set( 0, 0, 0 );
+				_morphC.set( 0, 0, 0 );
+
+				for ( var i = 0, il = morphAttribute.length; i < il; i ++ ) {
+
+					var influence = morphInfluences[ i ];
+					var morphAttribute = morphAttribute[ i ];
+
+					if ( influence === 0 ) continue;
+
+					_tempA.fromBufferAttribute( morphAttribute, a );
+					_tempB.fromBufferAttribute( morphAttribute, b );
+					_tempC.fromBufferAttribute( morphAttribute, c );
+
+					if ( morphTargetsRelative ) {
+
+						_morphA.addScaledVector( _tempA, influence );
+						_morphB.addScaledVector( _tempB, influence );
+						_morphC.addScaledVector( _tempC, influence );
+
+					} else {
+
+						_morphA.addScaledVector( _tempA.sub( _vA ), influence );
+						_morphB.addScaledVector( _tempB.sub( _vB ), influence );
+						_morphC.addScaledVector( _tempC.sub( _vC ), influence );
+
+					}
+
+				}
+
+				_vA.add( _morphA );
+				_vB.add( _morphB );
+				_vC.add( _morphC );
+
+			}
+
+			if ( object.isSkinnedMesh ) {
+
+				object.boneTransform( a, _vA );
+				object.boneTransform( b, _vB );
+				object.boneTransform( c, _vC );
+
+			}
+
+			modifiedAttributeArray[ a * 3 + 0 ] = _vA.x;
+			modifiedAttributeArray[ a * 3 + 1 ] = _vA.y;
+			modifiedAttributeArray[ a * 3 + 2 ] = _vA.z;
+			modifiedAttributeArray[ b * 3 + 0 ] = _vB.x;
+			modifiedAttributeArray[ b * 3 + 1 ] = _vB.y;
+			modifiedAttributeArray[ b * 3 + 2 ] = _vB.z;
+			modifiedAttributeArray[ c * 3 + 0 ] = _vC.x;
+			modifiedAttributeArray[ c * 3 + 1 ] = _vC.y;
+			modifiedAttributeArray[ c * 3 + 2 ] = _vC.z;
+
+		}
+
+		var geometry = object.geometry;
+		var material = object.material;
+
+		var a, b, c;
+		var index = geometry.index;
+		var positionAttribute = geometry.attributes.position;
+		var morphPosition = geometry.morphAttributes.position;
+		var morphTargetsRelative = geometry.morphTargetsRelative;
+		var normalAttribute = geometry.attributes.normal;
+		var morphNormal = geometry.morphAttributes.position;
+
+		var groups = geometry.groups;
+		var drawRange = geometry.drawRange;
+		var i, j, il, jl;
+		var group, groupMaterial;
+		var start, end;
+
+		var modifiedPosition = new Float32Array( positionAttribute.count * positionAttribute.itemSize );
+		var modifiedNormal = new Float32Array( normalAttribute.count * normalAttribute.itemSize );
+
+		if ( index !== null ) {
+
+			// indexed buffer geometry
+
+			if ( Array.isArray( material ) ) {
+
+				for ( i = 0, il = groups.length; i < il; i ++ ) {
+
+					group = groups[ i ];
+					groupMaterial = material[ group.materialIndex ];
+
+					start = Math.max( group.start, drawRange.start );
+					end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
+
+					for ( j = start, jl = end; j < jl; j += 3 ) {
+
+						a = index.getX( j );
+						b = index.getX( j + 1 );
+						c = index.getX( j + 2 );
+
+						_calculateMorphedAttributeData(
+							object,
+							groupMaterial,
+							positionAttribute,
+							morphPosition,
+							morphTargetsRelative,
+							a, b, c,
+							modifiedPosition
+						);
+
+						_calculateMorphedAttributeData(
+							object,
+							groupMaterial,
+							normalAttribute,
+							morphNormal,
+							morphTargetsRelative,
+							a, b, c,
+							modifiedNormal
+						);
+
+					}
+
+				}
+
+			} else {
+
+				start = Math.max( 0, drawRange.start );
+				end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
+
+				for ( i = start, il = end; i < il; i += 3 ) {
+
+					a = index.getX( i );
+					b = index.getX( i + 1 );
+					c = index.getX( i + 2 );
+
+					_calculateMorphedAttributeData(
+						object,
+						material,
+						positionAttribute,
+						morphPosition,
+						morphTargetsRelative,
+						a, b, c,
+						modifiedPosition
+					);
+
+					_calculateMorphedAttributeData(
+						object,
+						material,
+						normalAttribute,
+						morphNormal,
+						morphTargetsRelative,
+						a, b, c,
+						modifiedNormal
+					);
+
+				}
+
+			}
+
+		} else if ( positionAttribute !== undefined ) {
+
+			// non-indexed buffer geometry
+
+			if ( Array.isArray( material ) ) {
+
+				for ( i = 0, il = groups.length; i < il; i ++ ) {
+
+					group = groups[ i ];
+					groupMaterial = material[ group.materialIndex ];
+
+					start = Math.max( group.start, drawRange.start );
+					end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
+
+					for ( j = start, jl = end; j < jl; j += 3 ) {
+
+						a = j;
+						b = j + 1;
+						c = j + 2;
+
+						_calculateMorphedAttributeData(
+							object,
+							groupMaterial,
+							positionAttribute,
+							morphPosition,
+							morphTargetsRelative,
+							a, b, c,
+							modifiedPosition
+						);
+
+						_calculateMorphedAttributeData(
+							object,
+							groupMaterial,
+							normalAttribute,
+							morphNormal,
+							morphTargetsRelative,
+							a, b, c,
+							modifiedNormal
+						);
+
+					}
+
+				}
+
+			} else {
+
+				start = Math.max( 0, drawRange.start );
+				end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) );
+
+				for ( i = start, il = end; i < il; i += 3 ) {
+
+					a = i;
+					b = i + 1;
+					c = i + 2;
+
+					_calculateMorphedAttributeData(
+						object,
+						material,
+						positionAttribute,
+						morphPosition,
+						morphTargetsRelative,
+						a, b, c,
+						modifiedPosition
+					);
+
+					_calculateMorphedAttributeData(
+						object,
+						material,
+						normalAttribute,
+						morphNormal,
+						morphTargetsRelative,
+						a, b, c,
+						modifiedNormal
+					);
+
+				}
+
+			}
+
+		}
+
+		var morphedPositionAttribute = new Float32BufferAttribute( modifiedPosition, 3 );
+		var morphedNormalAttribute = new Float32BufferAttribute( modifiedNormal, 3 );
+
+		return {
+
+			positionAttribute: positionAttribute,
+			normalAttribute: normalAttribute,
+			morphedPositionAttribute: morphedPositionAttribute,
+			morphedNormalAttribute: morphedNormalAttribute
+
+		};
+
+	}
+
 };
 };
 
 
 export { BufferGeometryUtils };
 export { BufferGeometryUtils };

BIN
examples/screenshots/webgl_modifier_subdivision.jpg


+ 0 - 136
examples/webgl_modifier_subdivision.html

@@ -1,136 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<title>three.js webgl - modifier - Subdivisions using Loop Subdivision Scheme</title>
-		<meta charset="utf-8">
-		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
-		<link type="text/css" rel="stylesheet" href="main.css">
-	</head>
-	<body>
-		<div id="info">
-			<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - subdivision modifier
-		</div>
-
-		<script type="module">
-
-			import * as THREE from '../build/three.module.js';
-
-			import { GUI } from './jsm/libs/dat.gui.module.js';
-			import { OrbitControls } from './jsm/controls/OrbitControls.js';
-			import { SubdivisionModifier } from './jsm/modifiers/SubdivisionModifier.js';
-
-			let camera, scene, renderer, smoothMesh;
-
-			const material = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true } );
-			const wireframeMaterial = new THREE.LineBasicMaterial();
-
-			const params = {
-				subdivisions: 2
-			};
-
-			init();
-
-			function init() {
-
-				camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 500 );
-				camera.position.z = 100;
-
-				scene = new THREE.Scene();
-
-				scene.add( new THREE.AmbientLight( 0xffffff, 0.2 ) );
-
-				const light = new THREE.PointLight( 0xffffff, 0.8 );
-				light.position.set( 0, 50, 100 );
-				scene.add( light );
-
-				const loader = new THREE.BufferGeometryLoader();
-				loader.load( 'models/json/WaltHeadLo_buffergeometry.json', function ( geometry ) {
-
-					const mesh = new THREE.Mesh( geometry, material );
-					mesh.position.x = 32;
-					scene.add( mesh );
-
-					const wireframe = new THREE.WireframeGeometry( geometry );
-					const line = new THREE.LineSegments( wireframe, wireframeMaterial );
-					mesh.add( line );
-
-					const gui = new GUI();
-
-					gui.add( params, 'subdivisions', 0, 3 ).step( 1 ).onChange( function ( subdivisions ) {
-
-						subdivide( geometry, subdivisions );
-						render();
-
-					} );
-
-					//
-
-					subdivide( geometry, params.subdivisions );
-
-					render();
-
-				} );
-
-				renderer = new THREE.WebGLRenderer( { antialias: true } );
-				renderer.setPixelRatio( window.devicePixelRatio );
-				renderer.setSize( window.innerWidth, window.innerHeight );
-				document.body.appendChild( renderer.domElement );
-
-				//
-
-				const controls = new OrbitControls( camera, renderer.domElement );
-				controls.addEventListener( 'change', render );
-				controls.minDistance = 50;
-				controls.maxDistance = 400;
-
-				window.addEventListener( 'resize', onWindowResize, false );
-
-			}
-
-			function subdivide( geometry, subdivisions ) {
-
-				const modifier = new SubdivisionModifier( subdivisions );
-
-				const smoothGeometry = modifier.modify( geometry );
-
-				if ( smoothMesh !== undefined ) {
-
-					smoothMesh.geometry.dispose();
-					smoothMesh.children[ 0 ].geometry.dispose();
-
-					scene.remove( smoothMesh );
-
-				}
-
-				smoothMesh = new THREE.Mesh( smoothGeometry, material );
-				smoothMesh.position.x = - 32;
-
-				const wireframe = new THREE.WireframeGeometry( smoothGeometry );
-				const line = new THREE.LineSegments( wireframe, wireframeMaterial );
-				smoothMesh.add( line );
-
-				scene.add( smoothMesh );
-
-			}
-
-			function onWindowResize() {
-
-				camera.aspect = window.innerWidth / window.innerHeight;
-				camera.updateProjectionMatrix();
-
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
-				render();
-
-			}
-
-			function render() {
-
-				renderer.render( scene, camera );
-
-			}
-
-		</script>
-
-	</body>
-</html>

+ 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 { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';
 import { InterleavedBuffer } from './core/InterleavedBuffer.js';
 import { InterleavedBuffer } from './core/InterleavedBuffer.js';
 import { Face3 } from './core/Face3.js';
 import { Face3 } from './core/Face3.js';
-import { Geometry } from './core/Geometry.js';
 import { Object3D } from './core/Object3D.js';
 import { Object3D } from './core/Object3D.js';
 import { Uniform } from './core/Uniform.js';
 import { Uniform } from './core/Uniform.js';
 import { Raycaster } from './core/Raycaster.js';
 import { Raycaster } from './core/Raycaster.js';
@@ -283,23 +282,6 @@ Object.assign( CurvePath.prototype, {
 		const pts = this.getSpacedPoints( divisions );
 		const pts = this.getSpacedPoints( divisions );
 		return this.createGeometry( pts );
 		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, {
 Object.assign( Object3D.prototype, {
 
 
 	getChildByName: function ( name ) {
 	getChildByName: function ( name ) {

+ 0 - 2
src/Three.d.ts

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

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

@@ -1,8 +1,13 @@
 import { KeyframeTrack } from './KeyframeTrack';
 import { KeyframeTrack } from './KeyframeTrack';
+import { Vector3 } from './../math/Vector3';
 import { Bone } from './../objects/Bone';
 import { Bone } from './../objects/Bone';
-import { MorphTarget } from '../core/Geometry';
 import { AnimationBlendMode } from '../constants';
 import { AnimationBlendMode } from '../constants';
 
 
+interface MorphTarget {
+	name: string;
+	vertices: Vector3[];
+}
+
 export class AnimationClip {
 export class AnimationClip {
 
 
 	constructor( name?: string, duration?: number, tracks?: KeyframeTrack[], blendMode?: AnimationBlendMode );
 	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 { Matrix4 } from './../math/Matrix4';
 import { Vector2 } from './../math/Vector2';
 import { Vector2 } from './../math/Vector2';
 import { Vector3 } from './../math/Vector3';
 import { Vector3 } from './../math/Vector3';
-import { Object3D } from './Object3D';
-import { Geometry } from './Geometry';
-import { DirectGeometry } from './DirectGeometry';
 import { EventDispatcher } from './EventDispatcher';
 import { EventDispatcher } from './EventDispatcher';
 import { InterleavedBufferAttribute } from './InterleavedBufferAttribute';
 import { InterleavedBufferAttribute } from './InterleavedBufferAttribute';
 
 
@@ -119,13 +116,7 @@ export class BufferGeometry extends EventDispatcher {
 
 
 	center(): BufferGeometry;
 	center(): BufferGeometry;
 
 
-	setFromObject( object: Object3D ): BufferGeometry;
 	setFromPoints( points: Vector3[] | Vector2[] ): 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.
 	 * Computes bounding box of the geometry, updating Geometry.boundingBox attribute.

+ 3 - 278
src/core/BufferGeometry.js

@@ -4,14 +4,13 @@ import { Box3 } from '../math/Box3.js';
 import { EventDispatcher } from './EventDispatcher.js';
 import { EventDispatcher } from './EventDispatcher.js';
 import { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from './BufferAttribute.js';
 import { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from './BufferAttribute.js';
 import { Sphere } from '../math/Sphere.js';
 import { Sphere } from '../math/Sphere.js';
-import { DirectGeometry } from './DirectGeometry.js';
 import { Object3D } from './Object3D.js';
 import { Object3D } from './Object3D.js';
 import { Matrix4 } from '../math/Matrix4.js';
 import { Matrix4 } from '../math/Matrix4.js';
 import { Matrix3 } from '../math/Matrix3.js';
 import { Matrix3 } from '../math/Matrix3.js';
 import { MathUtils } from '../math/MathUtils.js';
 import { MathUtils } from '../math/MathUtils.js';
 import { arrayMax } from '../utils.js';
 import { arrayMax } from '../utils.js';
 
 
-let _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id
+let _id = 0;
 
 
 const _m1 = new Matrix4();
 const _m1 = new Matrix4();
 const _obj = new Object3D();
 const _obj = new Object3D();
@@ -22,7 +21,7 @@ const _vector = new Vector3();
 
 
 function BufferGeometry() {
 function BufferGeometry() {
 
 
-	Object.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } );
+	Object.defineProperty( this, 'id', { value: _id ++ } );
 
 
 	this.uuid = MathUtils.generateUUID();
 	this.uuid = MathUtils.generateUUID();
 
 
@@ -261,54 +260,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 ) {
 	setFromPoints: function ( points ) {
 
 
 		const position = [];
 		const position = [];
@@ -326,232 +277,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 () {
 	computeBoundingBox: function () {
 
 
 		if ( this.boundingBox === null ) {
 		if ( this.boundingBox === null ) {
@@ -1092,7 +817,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 
 		if ( this.index === null ) {
 		if ( this.index === null ) {
 
 
-			console.warn( 'THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.' );
+			console.warn( 'THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.' );
 			return this;
 			return this;
 
 
 		}
 		}

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

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

@@ -1,5 +1,4 @@
 import { Curve } from './Curve';
 import { Curve } from './Curve';
-import { Geometry } from './../../core/Geometry';
 import { Vector } from './../../math/Vector2';
 import { Vector } from './../../math/Vector2';
 
 
 export class CurvePath<T extends Vector> extends Curve<T> {
 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;
 	getPoint( t: number ): T;
 	getCurveLengths(): number[];
 	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 { BufferGeometry } from '../core/BufferGeometry';
 import { Material } from './../materials/Material';
 import { Material } from './../materials/Material';
 import { BufferAttribute } from './../core/BufferAttribute';
 import { BufferAttribute } from './../core/BufferAttribute';
@@ -6,14 +5,11 @@ import { Mesh } from './Mesh';
 import { Matrix4 } from './../math/Matrix4';
 import { Matrix4 } from './../math/Matrix4';
 import { Color } from './../math/Color';
 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(
 	constructor(
-		geometry: TGeometry,
-		material: TMaterial,
+		geometry: BufferGeometry,
+		material: Material | Material[],
 		count: number
 		count: number
 	);
 	);
 
 

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

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

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

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

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

@@ -1,4 +1,3 @@
-import { Geometry } from './../core/Geometry';
 import { Material } from './../materials/Material';
 import { Material } from './../materials/Material';
 import { Line } from './Line';
 import { Line } from './Line';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
@@ -12,14 +11,11 @@ export const LineStrip: number;
  */
  */
 export const LinePieces: 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(
 	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 { Material } from './../materials/Material';
 import { Raycaster } from './../core/Raycaster';
 import { Raycaster } from './../core/Raycaster';
 import { Object3D } from './../core/Object3D';
 import { Object3D } from './../core/Object3D';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Intersection } from '../core/Raycaster';
 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(
 	constructor(
-		geometry?: TGeometry,
-		material?: TMaterial
+		geometry?: BufferGeometry,
+		material?: Material | Material[]
 	);
 	);
 
 
-	geometry: TGeometry;
-	material: TMaterial;
+	geometry: BufferGeometry;
+	material: Material | Material[];
 	morphTargetInfluences?: number[];
 	morphTargetInfluences?: number[];
 	morphTargetDictionary?: { [key: string]: number };
 	morphTargetDictionary?: { [key: string]: number };
 	readonly isMesh: true;
 	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 { Material } from './../materials/Material';
 import { Raycaster } from './../core/Raycaster';
 import { Raycaster } from './../core/Raycaster';
 import { Object3D } from './../core/Object3D';
 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.
  * 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).
 	 * @param material An instance of Material (optional).
 	 */
 	 */
 	constructor(
 	constructor(
-		geometry?: TGeometry,
-		material?: TMaterial
+		geometry?: BufferGeometry,
+		material?: Material | Material[]
 	);
 	);
 
 
 	type: 'Points';
 	type: 'Points';
@@ -28,14 +24,14 @@ export class Points <
 	readonly isPoints: true;
 	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.
 	 * 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;
 	raycast( raycaster: Raycaster, intersects: Intersection[] ): void;
 	updateMorphTargets(): 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 { Material } from './../materials/Material';
 import { Matrix4 } from './../math/Matrix4';
 import { Matrix4 } from './../math/Matrix4';
 import { Skeleton } from './Skeleton';
 import { Skeleton } from './Skeleton';
 import { Mesh } from './Mesh';
 import { Mesh } from './Mesh';
 import { BufferGeometry } from '../core/BufferGeometry';
 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(
 	constructor(
-		geometry?: TGeometry,
-		material?: TMaterial,
+		geometry?: BufferGeometry,
+		material?: Material | Material[],
 		useVertexTexture?: boolean
 		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 { ToneMapping, ShadowMapType, CullFace, TextureEncoding } from '../constants';
 import { WebXRManager } from '../renderers/webxr/WebXRManager';
 import { WebXRManager } from '../renderers/webxr/WebXRManager';
 import { RenderTarget } from './webgl/WebGLRenderLists';
 import { RenderTarget } from './webgl/WebGLRenderLists';
-import { Geometry } from './../core/Geometry';
 import { BufferGeometry } from './../core/BufferGeometry';
 import { BufferGeometry } from './../core/BufferGeometry';
 import { Texture } from '../textures/Texture';
 import { Texture } from '../textures/Texture';
 import { XRAnimationLoopCallback } from './webxr/WebXR';
 import { XRAnimationLoopCallback } from './webxr/WebXR';
@@ -334,7 +333,7 @@ export class WebGLRenderer implements Renderer {
 	renderBufferDirect(
 	renderBufferDirect(
 		camera: Camera,
 		camera: Camera,
 		scene: Scene,
 		scene: Scene,
-		geometry: Geometry | BufferGeometry,
+		geometry: BufferGeometry,
 		material: Material,
 		material: Material,
 		object: Object3D,
 		object: Object3D,
 		geometryGroup: any
 		geometryGroup: any

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

@@ -2,15 +2,14 @@ import { WebGLAttributes } from './WebGLAttributes';
 import { WebGLInfo } from './WebGLInfo';
 import { WebGLInfo } from './WebGLInfo';
 import { BufferAttribute } from '../../core/BufferAttribute';
 import { BufferAttribute } from '../../core/BufferAttribute';
 import { BufferGeometry } from '../../core/BufferGeometry';
 import { BufferGeometry } from '../../core/BufferGeometry';
-import { Geometry } from '../../core/Geometry';
 import { Object3D } from '../../core/Object3D';
 import { Object3D } from '../../core/Object3D';
 
 
 export class WebGLGeometries {
 export class WebGLGeometries {
 
 
 	constructor( gl: WebGLRenderingContext, attributes: WebGLAttributes, info: WebGLInfo );
 	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 { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute.js';
-import { BufferGeometry } from '../../core/BufferGeometry.js';
 import { arrayMax } from '../../utils.js';
 import { arrayMax } from '../../utils.js';
 
 
 function WebGLGeometries( gl, attributes, info, bindingStates ) {
 function WebGLGeometries( gl, attributes, info, bindingStates ) {
@@ -63,15 +62,9 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
 
 
 			buffergeometry = geometry;
 			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 ( updateMap.get( buffergeometry ) !== frame ) {
 
 
-			if ( geometry.isGeometry ) {
-
-				buffergeometry.updateFromObject( object );
-
-			}
-
 			geometries.update( buffergeometry );
 			geometries.update( buffergeometry );
 
 
 			updateMap.set( buffergeometry, frame );
 			updateMap.set( buffergeometry, frame );

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

@@ -6,16 +6,9 @@ import {
 	Uint16BufferAttribute,
 	Uint16BufferAttribute,
 	Uint32BufferAttribute
 	Uint32BufferAttribute
 } from '../../../../src/core/BufferAttribute';
 } from '../../../../src/core/BufferAttribute';
-import { Color } from '../../../../src/math/Color';
-import { Vector2 } from '../../../../src/math/Vector2';
 import { Vector3 } from '../../../../src/math/Vector3';
 import { Vector3 } from '../../../../src/math/Vector3';
-import { Vector4 } from '../../../../src/math/Vector4';
 import { Matrix4 } from '../../../../src/math/Matrix4';
 import { Matrix4 } from '../../../../src/math/Matrix4';
 import { Sphere } from '../../../../src/math/Sphere';
 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 {
 import {
 	x,
 	x,
 	y,
 	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', () => {
 export default QUnit.module( 'Core', () => {
 
 
 	QUnit.module( 'BufferGeometry', () => {
 	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 ) => {
 		QUnit.test( "computeBoundingBox", ( assert ) => {
 
 
 			var bb = getBBForVertices( [ - 1, - 2, - 3, 13, - 2, - 3.5, - 1, - 20, 0, - 4, 5, 6 ] );
 			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/BufferAttribute.tests';
 import './src/core/BufferGeometry.tests';
 import './src/core/BufferGeometry.tests';
 import './src/core/Clock.tests';
 import './src/core/Clock.tests';
-import './src/core/DirectGeometry.tests';
 import './src/core/EventDispatcher.tests';
 import './src/core/EventDispatcher.tests';
 import './src/core/Face3.tests';
 import './src/core/Face3.tests';
-import './src/core/Geometry.tests';
 import './src/core/InstancedBufferAttribute.tests';
 import './src/core/InstancedBufferAttribute.tests';
 import './src/core/InstancedBufferGeometry.tests';
 import './src/core/InstancedBufferGeometry.tests';
 import './src/core/InstancedInterleavedBuffer.tests';
 import './src/core/InstancedInterleavedBuffer.tests';

+ 0 - 1
utils/modularize.js

@@ -120,7 +120,6 @@ var files = [
 
 
 	{ path: 'modifiers/EdgeSplitModifier.js', dependencies: [ { name: 'BufferGeometryUtils', path: 'utils/BufferGeometryUtils.js' } ], ignoreList: [ 'Geometry' ] },
 	{ path: 'modifiers/EdgeSplitModifier.js', dependencies: [ { name: 'BufferGeometryUtils', path: 'utils/BufferGeometryUtils.js' } ], ignoreList: [ 'Geometry' ] },
 	{ path: 'modifiers/SimplifyModifier.js', dependencies: [ { name: 'BufferGeometryUtils', path: 'utils/BufferGeometryUtils.js' } ], ignoreList: [] },
 	{ path: 'modifiers/SimplifyModifier.js', dependencies: [ { name: 'BufferGeometryUtils', path: 'utils/BufferGeometryUtils.js' } ], ignoreList: [] },
-	{ path: 'modifiers/SubdivisionModifier.js', dependencies: [], ignoreList: [] },
 	{ path: 'modifiers/TessellateModifier.js', dependencies: [], ignoreList: [] },
 	{ path: 'modifiers/TessellateModifier.js', dependencies: [], ignoreList: [] },
 
 
 	{ path: 'objects/Lensflare.js', dependencies: [], ignoreList: [] },
 	{ path: 'objects/Lensflare.js', dependencies: [], ignoreList: [] },

Some files were not shown because too many files changed in this diff