Explorar el Código

Updated examples builds.

Mr.doob hace 3 años
padre
commit
0786073c4e

+ 60 - 0
examples/js/exporters/GLTFExporter.js

@@ -35,6 +35,11 @@
 				return new GLTFMaterialsClearcoatExtension( writer );
 
 			} );
+			this.register( function ( writer ) {
+
+				return new GLTFMaterialsIridescenceExtension( writer );
+
+			} );
 
 		}
 
@@ -2218,6 +2223,61 @@
 
 		}
 
+	}
+	/**
+ * Iridescence Materials Extension
+ *
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
+ */
+
+
+	class GLTFMaterialsIridescenceExtension {
+
+		constructor( writer ) {
+
+			this.writer = writer;
+			this.name = 'KHR_materials_iridescence';
+
+		}
+
+		writeMaterial( material, materialDef ) {
+
+			if ( ! material.isMeshPhysicalMaterial ) return;
+			const writer = this.writer;
+			const extensionsUsed = writer.extensionsUsed;
+			const extensionDef = {};
+			extensionDef.iridescenceFactor = material.iridescence;
+
+			if ( material.iridescenceMap ) {
+
+				const iridescenceMapDef = {
+					index: writer.processTexture( material.iridescenceMap )
+				};
+				writer.applyTextureTransform( iridescenceMapDef, material.iridescenceMap );
+				extensionDef.iridescenceTexture = iridescenceMapDef;
+
+			}
+
+			extensionDef.iridescenceIor = material.iridescenceIOR;
+			extensionDef.iridescenceThicknessMinimum = material.iridescenceThicknessRange[ 0 ];
+			extensionDef.iridescenceThicknessMaximum = material.iridescenceThicknessRange[ 1 ];
+
+			if ( material.iridescenceThicknessMap ) {
+
+				const iridescenceThicknessMapDef = {
+					index: writer.processTexture( material.iridescenceThicknessMap )
+				};
+				writer.applyTextureTransform( iridescenceThicknessMapDef, material.iridescenceThicknessMap );
+				extensionDef.iridescenceThicknessTexture = iridescenceThicknessMapDef;
+
+			}
+
+			materialDef.extensions = materialDef.extensions || {};
+			materialDef.extensions[ this.name ] = extensionDef;
+			extensionsUsed[ this.name ] = true;
+
+		}
+
 	}
 	/**
  * Transmission Materials Extension

+ 0 - 7
examples/js/geometries/DecalGeometry.js

@@ -45,13 +45,6 @@
 				const vertex = new THREE.Vector3();
 				const normal = new THREE.Vector3(); // handle different geometry types
 
-				if ( mesh.geometry.isGeometry === true ) {
-
-					console.error( 'THREE.DecalGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
-					return;
-
-				}
-
 				const geometry = mesh.geometry;
 				const positionAttribute = geometry.attributes.position;
 				const normalAttribute = geometry.attributes.normal; // first, create an array of 'DecalVertex' objects

+ 1 - 6
examples/js/helpers/VertexNormalsHelper.js

@@ -38,12 +38,7 @@
 
 			const objGeometry = this.object.geometry;
 
-			if ( objGeometry && objGeometry.isGeometry ) {
-
-				console.error( 'THREE.VertexNormalsHelper no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-				return;
-
-			} else if ( objGeometry && objGeometry.isBufferGeometry ) {
+			if ( objGeometry ) {
 
 				const objPos = objGeometry.attributes.position;
 				const objNorm = objGeometry.attributes.normal;

+ 2 - 12
examples/js/lines/LineGeometry.js

@@ -57,18 +57,8 @@
 		fromLine( line ) {
 
 			const geometry = line.geometry;
-
-			if ( geometry.isGeometry ) {
-
-				console.error( 'THREE.LineGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-				return;
-
-			} else if ( geometry.isBufferGeometry ) {
-
-				this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
-
-			} // set colors, maybe
-
+			this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
+			// set colors, maybe
 
 			return this;
 

+ 2 - 12
examples/js/lines/LineSegmentsGeometry.js

@@ -125,18 +125,8 @@
 		fromLineSegments( lineSegments ) {
 
 			const geometry = lineSegments.geometry;
-
-			if ( geometry.isGeometry ) {
-
-				console.error( 'THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-				return;
-
-			} else if ( geometry.isBufferGeometry ) {
-
-				this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
-
-			} // set colors, maybe
-
+			this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
+			// set colors, maybe
 
 			return this;
 

+ 1 - 1
examples/js/loaders/GLTFLoader.js

@@ -364,8 +364,8 @@
 		KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
 		KHR_MATERIALS_SHEEN: 'KHR_materials_sheen',
 		KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
-		KHR_MATERIALS_IRIDESCENCE: 'KHR_materials_iridescence',
 		KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
+		KHR_MATERIALS_IRIDESCENCE: 'KHR_materials_iridescence',
 		KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
 		KHR_MATERIALS_VOLUME: 'KHR_materials_volume',
 		KHR_TEXTURE_BASISU: 'KHR_texture_basisu',

+ 6 - 15
examples/js/math/ConvexHull.js

@@ -73,24 +73,15 @@
 
 				if ( geometry !== undefined ) {
 
-					if ( geometry.isGeometry ) {
+					const attribute = geometry.attributes.position;
 
-						console.error( 'THREE.ConvexHull no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-						return;
+					if ( attribute !== undefined ) {
 
-					} else if ( geometry.isBufferGeometry ) {
+						for ( let i = 0, l = attribute.count; i < l; i ++ ) {
 
-						const attribute = geometry.attributes.position;
-
-						if ( attribute !== undefined ) {
-
-							for ( let i = 0, l = attribute.count; i < l; i ++ ) {
-
-								const point = new THREE.Vector3();
-								point.fromBufferAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
-								points.push( point );
-
-							}
+							const point = new THREE.Vector3();
+							point.fromBufferAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
+							points.push( point );
 
 						}
 

+ 0 - 7
examples/js/modifiers/EdgeSplitModifier.js

@@ -139,13 +139,6 @@
 
 			}
 
-			if ( geometry.isGeometry === true ) {
-
-				console.error( 'THREE.EdgeSplitModifier no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
-				return;
-
-			}
-
 			let hadNormals = false;
 			let oldNormals = null;
 

+ 0 - 7
examples/js/modifiers/SimplifyModifier.js

@@ -15,13 +15,6 @@
 
 		modify( geometry, count ) {
 
-			if ( geometry.isGeometry === true ) {
-
-				console.error( 'THREE.SimplifyModifier no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-				return;
-
-			}
-
 			geometry = geometry.clone();
 			const attributes = geometry.attributes; // this modifier can only process indexed and non-indexed geomtries with a position attribute
 

+ 0 - 7
examples/js/modifiers/TessellateModifier.js

@@ -15,13 +15,6 @@
 
 		modify( geometry ) {
 
-			if ( geometry.isGeometry === true ) {
-
-				console.error( 'THREE.TessellateModifier no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-				return geometry;
-
-			}
-
 			if ( geometry.index !== null ) {
 
 				geometry = geometry.toNonIndexed();

+ 97 - 124
examples/js/renderers/Projector.js

@@ -433,114 +433,102 @@
 
 					if ( object.isMesh ) {
 
-						if ( geometry.isBufferGeometry ) {
+						let material = object.material;
+						const isMultiMaterial = Array.isArray( material );
+						const attributes = geometry.attributes;
+						const groups = geometry.groups;
+						if ( attributes.position === undefined ) continue;
+						const positions = attributes.position.array;
 
-							let material = object.material;
-							const isMultiMaterial = Array.isArray( material );
-							const attributes = geometry.attributes;
-							const groups = geometry.groups;
-							if ( attributes.position === undefined ) continue;
-							const positions = attributes.position.array;
-
-							for ( let i = 0, l = positions.length; i < l; i += 3 ) {
-
-								let x = positions[ i ];
-								let y = positions[ i + 1 ];
-								let z = positions[ i + 2 ];
-								const morphTargets = geometry.morphAttributes.position;
+						for ( let i = 0, l = positions.length; i < l; i += 3 ) {
 
-								if ( morphTargets !== undefined ) {
+							let x = positions[ i ];
+							let y = positions[ i + 1 ];
+							let z = positions[ i + 2 ];
+							const morphTargets = geometry.morphAttributes.position;
 
-									const morphTargetsRelative = geometry.morphTargetsRelative;
-									const morphInfluences = object.morphTargetInfluences;
+							if ( morphTargets !== undefined ) {
 
-									for ( let t = 0, tl = morphTargets.length; t < tl; t ++ ) {
+								const morphTargetsRelative = geometry.morphTargetsRelative;
+								const morphInfluences = object.morphTargetInfluences;
 
-										const influence = morphInfluences[ t ];
-										if ( influence === 0 ) continue;
-										const target = morphTargets[ t ];
+								for ( let t = 0, tl = morphTargets.length; t < tl; t ++ ) {
 
-										if ( morphTargetsRelative ) {
+									const influence = morphInfluences[ t ];
+									if ( influence === 0 ) continue;
+									const target = morphTargets[ t ];
 
-											x += target.getX( i / 3 ) * influence;
-											y += target.getY( i / 3 ) * influence;
-											z += target.getZ( i / 3 ) * influence;
+									if ( morphTargetsRelative ) {
 
-										} else {
+										x += target.getX( i / 3 ) * influence;
+										y += target.getY( i / 3 ) * influence;
+										z += target.getZ( i / 3 ) * influence;
 
-											x += ( target.getX( i / 3 ) - positions[ i ] ) * influence;
-											y += ( target.getY( i / 3 ) - positions[ i + 1 ] ) * influence;
-											z += ( target.getZ( i / 3 ) - positions[ i + 2 ] ) * influence;
+									} else {
 
-										}
+										x += ( target.getX( i / 3 ) - positions[ i ] ) * influence;
+										y += ( target.getY( i / 3 ) - positions[ i + 1 ] ) * influence;
+										z += ( target.getZ( i / 3 ) - positions[ i + 2 ] ) * influence;
 
 									}
 
 								}
 
-								renderList.pushVertex( x, y, z );
-
 							}
 
-							if ( attributes.normal !== undefined ) {
+							renderList.pushVertex( x, y, z );
+
+						}
 
-								const normals = attributes.normal.array;
+						if ( attributes.normal !== undefined ) {
 
-								for ( let i = 0, l = normals.length; i < l; i += 3 ) {
+							const normals = attributes.normal.array;
 
-									renderList.pushNormal( normals[ i ], normals[ i + 1 ], normals[ i + 2 ] );
+							for ( let i = 0, l = normals.length; i < l; i += 3 ) {
 
-								}
+								renderList.pushNormal( normals[ i ], normals[ i + 1 ], normals[ i + 2 ] );
 
 							}
 
-							if ( attributes.color !== undefined ) {
+						}
 
-								const colors = attributes.color.array;
+						if ( attributes.color !== undefined ) {
 
-								for ( let i = 0, l = colors.length; i < l; i += 3 ) {
+							const colors = attributes.color.array;
 
-									renderList.pushColor( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] );
+							for ( let i = 0, l = colors.length; i < l; i += 3 ) {
 
-								}
+								renderList.pushColor( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] );
 
 							}
 
-							if ( attributes.uv !== undefined ) {
+						}
 
-								const uvs = attributes.uv.array;
+						if ( attributes.uv !== undefined ) {
 
-								for ( let i = 0, l = uvs.length; i < l; i += 2 ) {
+							const uvs = attributes.uv.array;
 
-									renderList.pushUv( uvs[ i ], uvs[ i + 1 ] );
+							for ( let i = 0, l = uvs.length; i < l; i += 2 ) {
 
-								}
+								renderList.pushUv( uvs[ i ], uvs[ i + 1 ] );
 
 							}
 
-							if ( geometry.index !== null ) {
-
-								const indices = geometry.index.array;
-
-								if ( groups.length > 0 ) {
-
-									for ( let g = 0; g < groups.length; g ++ ) {
+						}
 
-										const group = groups[ g ];
-										material = isMultiMaterial === true ? object.material[ group.materialIndex ] : object.material;
-										if ( material === undefined ) continue;
+						if ( geometry.index !== null ) {
 
-										for ( let i = group.start, l = group.start + group.count; i < l; i += 3 ) {
+							const indices = geometry.index.array;
 
-											renderList.pushTriangle( indices[ i ], indices[ i + 1 ], indices[ i + 2 ], material );
+							if ( groups.length > 0 ) {
 
-										}
+								for ( let g = 0; g < groups.length; g ++ ) {
 
-									}
+									const group = groups[ g ];
+									material = isMultiMaterial === true ? object.material[ group.materialIndex ] : object.material;
+									if ( material === undefined ) continue;
 
-								} else {
-
-									for ( let i = 0, l = indices.length; i < l; i += 3 ) {
+									for ( let i = group.start, l = group.start + group.count; i < l; i += 3 ) {
 
 										renderList.pushTriangle( indices[ i ], indices[ i + 1 ], indices[ i + 2 ], material );
 
@@ -550,25 +538,25 @@
 
 							} else {
 
-								if ( groups.length > 0 ) {
+								for ( let i = 0, l = indices.length; i < l; i += 3 ) {
 
-									for ( let g = 0; g < groups.length; g ++ ) {
+									renderList.pushTriangle( indices[ i ], indices[ i + 1 ], indices[ i + 2 ], material );
 
-										const group = groups[ g ];
-										material = isMultiMaterial === true ? object.material[ group.materialIndex ] : object.material;
-										if ( material === undefined ) continue;
+								}
 
-										for ( let i = group.start, l = group.start + group.count; i < l; i += 3 ) {
+							}
 
-											renderList.pushTriangle( i, i + 1, i + 2, material );
+						} else {
 
-										}
+							if ( groups.length > 0 ) {
 
-									}
+								for ( let g = 0; g < groups.length; g ++ ) {
 
-								} else {
+									const group = groups[ g ];
+									material = isMultiMaterial === true ? object.material[ group.materialIndex ] : object.material;
+									if ( material === undefined ) continue;
 
-									for ( let i = 0, l = positions.length / 3; i < l; i += 3 ) {
+									for ( let i = group.start, l = group.start + group.count; i < l; i += 3 ) {
 
 										renderList.pushTriangle( i, i + 1, i + 2, material );
 
@@ -576,12 +564,15 @@
 
 								}
 
-							}
+							} else {
+
+								for ( let i = 0, l = positions.length / 3; i < l; i += 3 ) {
 
-						} else if ( geometry.isGeometry ) {
+									renderList.pushTriangle( i, i + 1, i + 2, material );
 
-							console.error( 'THREE.Projector no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-							return;
+								}
+
+							}
 
 						}
 
@@ -589,89 +580,71 @@
 
 						_modelViewProjectionMatrix.multiplyMatrices( _viewProjectionMatrix, _modelMatrix );
 
-						if ( geometry.isBufferGeometry ) {
-
-							const attributes = geometry.attributes;
+						const attributes = geometry.attributes;
 
-							if ( attributes.position !== undefined ) {
+						if ( attributes.position !== undefined ) {
 
-								const positions = attributes.position.array;
-
-								for ( let i = 0, l = positions.length; i < l; i += 3 ) {
+							const positions = attributes.position.array;
 
-									renderList.pushVertex( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] );
+							for ( let i = 0, l = positions.length; i < l; i += 3 ) {
 
-								}
+								renderList.pushVertex( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] );
 
-								if ( attributes.color !== undefined ) {
+							}
 
-									const colors = attributes.color.array;
+							if ( attributes.color !== undefined ) {
 
-									for ( let i = 0, l = colors.length; i < l; i += 3 ) {
+								const colors = attributes.color.array;
 
-										renderList.pushColor( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] );
+								for ( let i = 0, l = colors.length; i < l; i += 3 ) {
 
-									}
+									renderList.pushColor( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] );
 
 								}
 
-								if ( geometry.index !== null ) {
+							}
 
-									const indices = geometry.index.array;
+							if ( geometry.index !== null ) {
 
-									for ( let i = 0, l = indices.length; i < l; i += 2 ) {
+								const indices = geometry.index.array;
 
-										renderList.pushLine( indices[ i ], indices[ i + 1 ] );
+								for ( let i = 0, l = indices.length; i < l; i += 2 ) {
 
-									}
+									renderList.pushLine( indices[ i ], indices[ i + 1 ] );
 
-								} else {
+								}
 
-									const step = object.isLineSegments ? 2 : 1;
+							} else {
 
-									for ( let i = 0, l = positions.length / 3 - 1; i < l; i += step ) {
+								const step = object.isLineSegments ? 2 : 1;
 
-										renderList.pushLine( i, i + 1 );
+								for ( let i = 0, l = positions.length / 3 - 1; i < l; i += step ) {
 
-									}
+									renderList.pushLine( i, i + 1 );
 
 								}
 
 							}
 
-						} else if ( geometry.isGeometry ) {
-
-							console.error( 'THREE.Projector no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-							return;
-
 						}
 
 					} else if ( object.isPoints ) {
 
 						_modelViewProjectionMatrix.multiplyMatrices( _viewProjectionMatrix, _modelMatrix );
 
-						if ( geometry.isGeometry ) {
+						const attributes = geometry.attributes;
 
-							console.error( 'THREE.Projector no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-							return;
+						if ( attributes.position !== undefined ) {
 
-						} else if ( geometry.isBufferGeometry ) {
-
-							const attributes = geometry.attributes;
-
-							if ( attributes.position !== undefined ) {
-
-								const positions = attributes.position.array;
-
-								for ( let i = 0, l = positions.length; i < l; i += 3 ) {
+							const positions = attributes.position.array;
 
-									_vector4.set( positions[ i ], positions[ i + 1 ], positions[ i + 2 ], 1 );
+							for ( let i = 0, l = positions.length; i < l; i += 3 ) {
 
-									_vector4.applyMatrix4( _modelViewProjectionMatrix );
+								_vector4.set( positions[ i ], positions[ i + 1 ], positions[ i + 2 ], 1 );
 
-									pushPoint( _vector4, object, camera );
+								_vector4.applyMatrix4( _modelViewProjectionMatrix );
 
-								}
+								pushPoint( _vector4, object, camera );
 
 							}
 

+ 23 - 33
examples/js/utils/UVsDebug.js

@@ -29,46 +29,36 @@
 
 		ctx.fillStyle = 'rgb( 255, 255, 255 )';
 		ctx.fillRect( 0, 0, width, height );
+		const index = geometry.index;
+		const uvAttribute = geometry.attributes.uv;
 
-		if ( geometry.isGeometry ) {
+		if ( index ) {
 
-			console.error( 'THREE.UVsDebug no longer supports Geometry. Use THREE.BufferGeometry instead.' );
-			return;
+			// indexed geometry
+			for ( let i = 0, il = index.count; i < il; i += 3 ) {
 
-		} else {
-
-			const index = geometry.index;
-			const uvAttribute = geometry.attributes.uv;
-
-			if ( index ) {
-
-				// indexed geometry
-				for ( let i = 0, il = index.count; i < il; i += 3 ) {
-
-					face[ 0 ] = index.getX( i );
-					face[ 1 ] = index.getX( i + 1 );
-					face[ 2 ] = index.getX( i + 2 );
-					uvs[ 0 ].fromBufferAttribute( uvAttribute, face[ 0 ] );
-					uvs[ 1 ].fromBufferAttribute( uvAttribute, face[ 1 ] );
-					uvs[ 2 ].fromBufferAttribute( uvAttribute, face[ 2 ] );
-					processFace( face, uvs, i / 3 );
+				face[ 0 ] = index.getX( i );
+				face[ 1 ] = index.getX( i + 1 );
+				face[ 2 ] = index.getX( i + 2 );
+				uvs[ 0 ].fromBufferAttribute( uvAttribute, face[ 0 ] );
+				uvs[ 1 ].fromBufferAttribute( uvAttribute, face[ 1 ] );
+				uvs[ 2 ].fromBufferAttribute( uvAttribute, face[ 2 ] );
+				processFace( face, uvs, i / 3 );
 
-				}
-
-			} else {
+			}
 
-				// non-indexed geometry
-				for ( let i = 0, il = uvAttribute.count; i < il; i += 3 ) {
+		} else {
 
-					face[ 0 ] = i;
-					face[ 1 ] = i + 1;
-					face[ 2 ] = i + 2;
-					uvs[ 0 ].fromBufferAttribute( uvAttribute, face[ 0 ] );
-					uvs[ 1 ].fromBufferAttribute( uvAttribute, face[ 1 ] );
-					uvs[ 2 ].fromBufferAttribute( uvAttribute, face[ 2 ] );
-					processFace( face, uvs, i / 3 );
+			// non-indexed geometry
+			for ( let i = 0, il = uvAttribute.count; i < il; i += 3 ) {
 
-				}
+				face[ 0 ] = i;
+				face[ 1 ] = i + 1;
+				face[ 2 ] = i + 2;
+				uvs[ 0 ].fromBufferAttribute( uvAttribute, face[ 0 ] );
+				uvs[ 1 ].fromBufferAttribute( uvAttribute, face[ 1 ] );
+				uvs[ 2 ].fromBufferAttribute( uvAttribute, face[ 2 ] );
+				processFace( face, uvs, i / 3 );
 
 			}