Преглед изворни кода

Merge pull request #8 from mrdoob/dev

Update
Temdog007 пре 6 година
родитељ
комит
2c28f30e9a

+ 61 - 1
docs/api/en/materials/MeshNormalMaterial.html

@@ -44,6 +44,38 @@
 		<h2>Properties</h2>
 		<h2>Properties</h2>
 		<p>See the base [page:Material] class for common properties.</p>
 		<p>See the base [page:Material] class for common properties.</p>
 
 
+		<h3>[property:Texture bumpMap]</h3>
+		<p>
+			The texture to create a bump map. The black and white values map to the perceived depth in relation to the lights.
+			Bump doesn't actually affect the geometry of the object, only the lighting. If a normal map is defined this will
+			be ignored.
+		</p>
+
+		<h3>[property:Float bumpScale]</h3>
+		<p>How much the bump map affects the material. Typical ranges are 0-1. Default is 1.</p>
+
+		<h3>[property:Texture displacementMap]</h3>
+		<p>
+			The displacement map affects the position of the mesh's vertices. Unlike other maps
+			which only affect the light and shade of the material the displaced vertices can cast shadows,
+			block other objects, and otherwise act as real geometry. The displacement texture is
+			an image where the value of each pixel (white being the highest) is mapped against,
+			and repositions, the vertices of the mesh.
+		</p>
+
+		<h3>[property:Float displacementScale]</h3>
+		<p>
+			How much the displacement map affects the mesh (where black is no displacement,
+			and white is maximum displacement). Without a displacement map set, this value is not applied.
+			 Default is 1.
+		</p>
+
+		<h3>[property:Float displacementBias]</h3>
+		<p>
+			The offset of the displacement map's values on the mesh's vertices.
+			Without a displacement map set, this value is not applied. Default is 0.
+		</p>
+
 		<h3>[property:Boolean fog]</h3>
 		<h3>[property:Boolean fog]</h3>
 		<p>Whether the material is affected by fog. Default is *false*.</p>
 		<p>Whether the material is affected by fog. Default is *false*.</p>
 
 
@@ -57,9 +89,37 @@
 		<h3>[property:Boolean lights]</h3>
 		<h3>[property:Boolean lights]</h3>
 		<p>Whether the material is affected by lights. Default is *false*.</p>
 		<p>Whether the material is affected by lights. Default is *false*.</p>
 
 
-		<h3>[property:boolean morphTargets]</h3>
+		<h3>[property:boolean morphNormals]</h3>
+		<p>
+			Defines whether the material uses morphNormals. Set as true to pass morphNormal
+			attributes from the [page:Geometry]	to the shader. Default is *false*.
+		</p>
+
+		<h3>[property:Boolean morphTargets]</h3>
 		<p>Define whether the material uses morphTargets. Default is false.</p>
 		<p>Define whether the material uses morphTargets. Default is false.</p>
 
 
+		<h3>[property:Texture normalMap]</h3>
+		<p>
+			The texture to create a normal map. The RGB values affect the surface normal for each pixel fragment and change
+			the way the color is lit. Normal maps do not change the actual shape of the surface, only the lighting.
+		</p>
+
+		<h3>[property:Integer normalMapType]</h3>
+		<p>
+			The type of normal map.<br /><br />
+
+			Options are [page:constant THREE.TangentSpaceNormalMap] (default), and [page:constant THREE.ObjectSpaceNormalMap].
+		</p>
+
+		<h3>[property:Vector2 normalScale]</h3>
+		<p>
+			How much the normal map affects the material. Typical ranges are 0-1.
+			Default is a [page:Vector2] set to (1,1).
+		</p>
+
+		<h3>[property:Boolean skinning]</h3>
+		<p>Define whether the material uses skinning. Default is false.</p>
+
 		<h3>[property:boolean wireframe]</h3>
 		<h3>[property:boolean wireframe]</h3>
 		<p>
 		<p>
 			Render geometry as wireframe. Default is false (i.e. render as smooth shaded).
 			Render geometry as wireframe. Default is false (i.e. render as smooth shaded).

+ 42 - 1
docs/api/zh/materials/MeshNormalMaterial.html

@@ -42,6 +42,27 @@
 		<h2>属性(Properties)</h2>
 		<h2>属性(Properties)</h2>
 		<p>常用属性请参见基类[page:Material]。</p>
 		<p>常用属性请参见基类[page:Material]。</p>
 
 
+		<h3>[property:Texture bumpMap]</h3>
+		<p> 用于创建凹凸贴图的纹理。黑色和白色值映射到与光照相关的感知深度。凹凸实际上不会影响对象的几何形状,只影响光照。如果定义了法线贴图,则将忽略该贴图。
+		</p>
+
+		<h3>[property:Float bumpScale]</h3>
+		<p> 凹凸贴图会对材质产生多大影响。典型范围是0-1。默认值为1。</p>
+
+		<h3>[property:Texture displacementMap]</h3>
+		<p> 位移贴图会影响网格顶点的位置,与仅影响材质的光照和阴影的其他贴图不同,移位的顶点可以投射阴影,阻挡其他对象,
+			以及充当真实的几何体。位移纹理是指:网格的所有顶点被映射为图像中每个像素的值(白色是最高的),并且被重定位。
+		</p>
+
+		<h3>[property:Float displacementScale]</h3>
+		<p> 位移贴图对网格的影响程度(黑色是无位移,白色是最大位移)。如果没有设置位移贴图,则不会应用此值。默认值为1。
+		</p>
+
+		<h3>[property:Float displacementBias]</h3>
+		<p>
+			位移贴图在网格顶点上的偏移量。如果没有设置位移贴图,则不会应用此值。默认值为0。
+		</p>
+
 		<h3>[property:Boolean fog]</h3>
 		<h3>[property:Boolean fog]</h3>
 		<p>材质是否受雾影响。默认值为*false*。</p>
 		<p>材质是否受雾影响。默认值为*false*。</p>
 
 
@@ -54,9 +75,29 @@
 		<h3>[property:Boolean lights]</h3>
 		<h3>[property:Boolean lights]</h3>
 		<p>材质是否受到光照的影响。默认值为 *false*。</p>
 		<p>材质是否受到光照的影响。默认值为 *false*。</p>
 
 
-		<h3>[property:boolean morphTargets]</h3>
+		<h3>[property:boolean morphNormals]</h3>
+		<p> 定义是否使用morphNormals。设置为true可将morphNormal属性从[page:Geometry]传递到shader。默认值为*false*。
+		</p>
+
+		<h3>[property:Boolean morphTargets]</h3>
 		<p>定义材质是否使用morphTargets。默认值为false。</p>
 		<p>定义材质是否使用morphTargets。默认值为false。</p>
 
 
+		<h3>[property:Texture normalMap]</h3>
+		<p> 用于创建法线贴图的纹理。RGB值会影响每个像素片段的曲面法线,并更改颜色照亮的方式。法线贴图不会改变曲面的实际形状,只会改变光照。
+		</p>
+
+		<h3>[property:Integer normalMapType]</h3>
+		<p> 法线贴图的类型。<br /><br />
+			选项为[page:constant THREE.TangentSpaceNormalMap](默认)和[page:constant THREE.ObjectSpaceNormalMap]。
+		</p>
+
+		<h3>[property:Vector2 normalScale]</h3>
+		<p> 法线贴图对材质的影响程度。典型范围是0-1。默认值是[page:Vector2]设置为(1,1)。
+		</p>
+
+		<h3>[property:Boolean skinning]</h3>
+		<p>材质是否使用蒙皮。默认值为false。</p>
+
 		<h3>[property:boolean wireframe]</h3>
 		<h3>[property:boolean wireframe]</h3>
 		<p>
 		<p>
 			将几何体渲染为线框。默认值为*false*(即渲染为平滑着色)。
 			将几何体渲染为线框。默认值为*false*(即渲染为平滑着色)。

+ 43 - 3
editor/js/Sidebar.Material.js

@@ -84,6 +84,7 @@ Sidebar.Material = function ( editor ) {
 		'MeshNormalMaterial': 'MeshNormalMaterial',
 		'MeshNormalMaterial': 'MeshNormalMaterial',
 		'MeshLambertMaterial': 'MeshLambertMaterial',
 		'MeshLambertMaterial': 'MeshLambertMaterial',
 		'MeshPhongMaterial': 'MeshPhongMaterial',
 		'MeshPhongMaterial': 'MeshPhongMaterial',
+		'MeshToonMaterial': 'MeshToonMaterial',
 		'MeshStandardMaterial': 'MeshStandardMaterial',
 		'MeshStandardMaterial': 'MeshStandardMaterial',
 		'MeshPhysicalMaterial': 'MeshPhysicalMaterial',
 		'MeshPhysicalMaterial': 'MeshPhysicalMaterial',
 		'ShaderMaterial': 'ShaderMaterial',
 		'ShaderMaterial': 'ShaderMaterial',
@@ -419,6 +420,18 @@ Sidebar.Material = function ( editor ) {
 
 
 	container.add( materialEmissiveMapRow );
 	container.add( materialEmissiveMapRow );
 
 
+	// gradient map
+
+	var materialGradientMapRow = new UI.Row();
+	var materialGradientMapEnabled = new UI.Checkbox( false ).onChange( update );
+	var materialGradientMap = new UI.Texture().onChange( update );
+
+	materialGradientMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/gradientmap' ) ).setWidth( '90px' ) );
+	materialGradientMapRow.add( materialGradientMapEnabled );
+	materialGradientMapRow.add( materialGradientMap );
+
+	container.add( materialGradientMapRow );
+
 	// side
 	// side
 
 
 	var materialSideRow = new UI.Row();
 	var materialSideRow = new UI.Row();
@@ -438,7 +451,7 @@ Sidebar.Material = function ( editor ) {
 	// shading
 	// shading
 
 
 	var materialShadingRow = new UI.Row();
 	var materialShadingRow = new UI.Row();
-	var materialShading = new UI.Checkbox(false).setLeft( '100px' ).onChange( update );
+	var materialShading = new UI.Checkbox( false ).setLeft( '100px' ).onChange( update );
 
 
 	materialShadingRow.add( new UI.Text( strings.getKey( 'sidebar/material/flatshaded' ) ).setWidth( '90px' ) );
 	materialShadingRow.add( new UI.Text( strings.getKey( 'sidebar/material/flatshaded' ) ).setWidth( '90px' ) );
 	materialShadingRow.add( materialShading );
 	materialShadingRow.add( materialShading );
@@ -537,7 +550,7 @@ Sidebar.Material = function ( editor ) {
 
 
 			}
 			}
 
 
-			if ( material instanceof THREE[ materialClass.getValue() ] === false ) {
+			if ( material.type !== materialClass.getValue() ) {
 
 
 				material = new THREE[ materialClass.getValue() ]();
 				material = new THREE[ materialClass.getValue() ]();
 
 
@@ -891,6 +904,20 @@ Sidebar.Material = function ( editor ) {
 
 
 			}
 			}
 
 
+			if ( material.gradientMap !== undefined ) {
+
+				var gradientMapEnabled = materialGradientMapEnabled.getValue() === true;
+
+				var gradientMap = gradientMapEnabled ? materialGradientMap.getValue() : null;
+
+				if ( material.gradientMap !== gradientMap ) {
+
+					editor.execute( new SetMaterialMapCommand( currentObject, 'gradientMap', gradientMap, currentMaterialSlot ) );
+
+				}
+
+			}
+
 			if ( material.side !== undefined ) {
 			if ( material.side !== undefined ) {
 
 
 				var side = parseInt( materialSide.getValue() );
 				var side = parseInt( materialSide.getValue() );
@@ -945,7 +972,7 @@ Sidebar.Material = function ( editor ) {
 
 
 			if ( material.wireframe !== undefined && material.wireframe !== materialWireframe.getValue() ) {
 			if ( material.wireframe !== undefined && material.wireframe !== materialWireframe.getValue() ) {
 
 
-				editor.execute( new SetMaterialValueCommand( currentObject, 'wireframe', materialWireframe.getValue(), currentMaterialSlot) );
+				editor.execute( new SetMaterialValueCommand( currentObject, 'wireframe', materialWireframe.getValue(), currentMaterialSlot ) );
 
 
 			}
 			}
 
 
@@ -996,6 +1023,7 @@ Sidebar.Material = function ( editor ) {
 			'lightMap': materialLightMapRow,
 			'lightMap': materialLightMapRow,
 			'aoMap': materialAOMapRow,
 			'aoMap': materialAOMapRow,
 			'emissiveMap': materialEmissiveMapRow,
 			'emissiveMap': materialEmissiveMapRow,
+			'gradientMap': materialGradientMapRow,
 			'side': materialSideRow,
 			'side': materialSideRow,
 			'flatShading': materialShadingRow,
 			'flatShading': materialShadingRow,
 			'blending': materialBlendingRow,
 			'blending': materialBlendingRow,
@@ -1240,6 +1268,18 @@ Sidebar.Material = function ( editor ) {
 
 
 		}
 		}
 
 
+		if ( material.gradientMap !== undefined ) {
+
+			materialGradientMapEnabled.setValue( material.gradientMap !== null );
+
+			if ( material.gradientMap !== null || resetTextureSelectors ) {
+
+				materialGradientMap.setValue( material.gradientMap );
+
+			}
+
+		}
+
 		if ( material.reflectivity !== undefined ) {
 		if ( material.reflectivity !== undefined ) {
 
 
 			materialReflectivity.setValue( material.reflectivity );
 			materialReflectivity.setValue( material.reflectivity );

+ 1 - 0
editor/js/Strings.js

@@ -207,6 +207,7 @@ var Strings = function ( config ) {
 			'sidebar/material/lightmap': 'Light Map',
 			'sidebar/material/lightmap': 'Light Map',
 			'sidebar/material/aomap': 'AO Map',
 			'sidebar/material/aomap': 'AO Map',
 			'sidebar/material/emissivemap': 'Emissive Map',
 			'sidebar/material/emissivemap': 'Emissive Map',
+			'sidebar/material/gradientmap': 'Gradient Map',
 			'sidebar/material/side': 'Side',
 			'sidebar/material/side': 'Side',
 			'sidebar/material/side/front': 'Front',
 			'sidebar/material/side/front': 'Front',
 			'sidebar/material/side/back': 'Back',
 			'sidebar/material/side/back': 'Back',

+ 37 - 32
examples/js/loaders/GLTFLoader.js

@@ -368,26 +368,26 @@ THREE.GLTFLoader = ( function () {
 	 *
 	 *
 	 * PR: https://github.com/KhronosGroup/glTF/pull/1163
 	 * PR: https://github.com/KhronosGroup/glTF/pull/1163
 	 */
 	 */
-	function GLTFMaterialsUnlitExtension( json ) {
+	function GLTFMaterialsUnlitExtension() {
 
 
 		this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
 		this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
 
 
 	}
 	}
 
 
-	GLTFMaterialsUnlitExtension.prototype.getMaterialType = function ( material ) {
+	GLTFMaterialsUnlitExtension.prototype.getMaterialType = function () {
 
 
 		return THREE.MeshBasicMaterial;
 		return THREE.MeshBasicMaterial;
 
 
 	};
 	};
 
 
-	GLTFMaterialsUnlitExtension.prototype.extendParams = function ( materialParams, material, parser ) {
+	GLTFMaterialsUnlitExtension.prototype.extendParams = function ( materialParams, materialDef, parser ) {
 
 
 		var pending = [];
 		var pending = [];
 
 
 		materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
 		materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
 		materialParams.opacity = 1.0;
 		materialParams.opacity = 1.0;
 
 
-		var metallicRoughness = material.pbrMetallicRoughness;
+		var metallicRoughness = materialDef.pbrMetallicRoughness;
 
 
 		if ( metallicRoughness ) {
 		if ( metallicRoughness ) {
 
 
@@ -563,7 +563,7 @@ THREE.GLTFLoader = ( function () {
 	 *
 	 *
 	 * Specification:
 	 * Specification:
 	 */
 	 */
-	function GLTFTextureTransformExtension( json ) {
+	function GLTFTextureTransformExtension() {
 
 
 		this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
 		this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
 
 
@@ -646,9 +646,9 @@ THREE.GLTFLoader = ( function () {
 
 
 			},
 			},
 
 
-			extendParams: function ( params, material, parser ) {
+			extendParams: function ( materialParams, materialDef, parser ) {
 
 
-				var pbrSpecularGlossiness = material.extensions[ this.name ];
+				var pbrSpecularGlossiness = materialDef.extensions[ this.name ];
 
 
 				var shader = THREE.ShaderLib[ 'standard' ];
 				var shader = THREE.ShaderLib[ 'standard' ];
 
 
@@ -711,13 +711,13 @@ THREE.GLTFLoader = ( function () {
 				uniforms.specularMap = { value: null };
 				uniforms.specularMap = { value: null };
 				uniforms.glossinessMap = { value: null };
 				uniforms.glossinessMap = { value: null };
 
 
-				params.vertexShader = shader.vertexShader;
-				params.fragmentShader = fragmentShader;
-				params.uniforms = uniforms;
-				params.defines = { 'STANDARD': '' };
+				materialParams.vertexShader = shader.vertexShader;
+				materialParams.fragmentShader = fragmentShader;
+				materialParams.uniforms = uniforms;
+				materialParams.defines = { 'STANDARD': '' };
 
 
-				params.color = new THREE.Color( 1.0, 1.0, 1.0 );
-				params.opacity = 1.0;
+				materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
+				materialParams.opacity = 1.0;
 
 
 				var pending = [];
 				var pending = [];
 
 
@@ -725,32 +725,32 @@ THREE.GLTFLoader = ( function () {
 
 
 					var array = pbrSpecularGlossiness.diffuseFactor;
 					var array = pbrSpecularGlossiness.diffuseFactor;
 
 
-					params.color.fromArray( array );
-					params.opacity = array[ 3 ];
+					materialParams.color.fromArray( array );
+					materialParams.opacity = array[ 3 ];
 
 
 				}
 				}
 
 
 				if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) {
 				if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) {
 
 
-					pending.push( parser.assignTexture( params, 'map', pbrSpecularGlossiness.diffuseTexture ) );
+					pending.push( parser.assignTexture( materialParams, 'map', pbrSpecularGlossiness.diffuseTexture ) );
 
 
 				}
 				}
 
 
-				params.emissive = new THREE.Color( 0.0, 0.0, 0.0 );
-				params.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0;
-				params.specular = new THREE.Color( 1.0, 1.0, 1.0 );
+				materialParams.emissive = new THREE.Color( 0.0, 0.0, 0.0 );
+				materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0;
+				materialParams.specular = new THREE.Color( 1.0, 1.0, 1.0 );
 
 
 				if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) {
 				if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) {
 
 
-					params.specular.fromArray( pbrSpecularGlossiness.specularFactor );
+					materialParams.specular.fromArray( pbrSpecularGlossiness.specularFactor );
 
 
 				}
 				}
 
 
 				if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) {
 				if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) {
 
 
 					var specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
 					var specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
-					pending.push( parser.assignTexture( params, 'glossinessMap', specGlossMapDef ) );
-					pending.push( parser.assignTexture( params, 'specularMap', specGlossMapDef ) );
+					pending.push( parser.assignTexture( materialParams, 'glossinessMap', specGlossMapDef ) );
+					pending.push( parser.assignTexture( materialParams, 'specularMap', specGlossMapDef ) );
 
 
 				}
 				}
 
 
@@ -793,6 +793,7 @@ THREE.GLTFLoader = ( function () {
 				material.bumpScale = 1;
 				material.bumpScale = 1;
 
 
 				material.normalMap = params.normalMap === undefined ? null : params.normalMap;
 				material.normalMap = params.normalMap === undefined ? null : params.normalMap;
+
 				if ( params.normalScale ) material.normalScale = params.normalScale;
 				if ( params.normalScale ) material.normalScale = params.normalScale;
 
 
 				material.displacementMap = null;
 				material.displacementMap = null;
@@ -2116,15 +2117,19 @@ THREE.GLTFLoader = ( function () {
 
 
 		return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
 		return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
 
 
-			switch ( mapName ) {
+			if ( ! texture.isCompressedTexture ) {
 
 
-				case 'aoMap':
-				case 'emissiveMap':
-				case 'metalnessMap':
-				case 'normalMap':
-				case 'roughnessMap':
-					texture.format = THREE.RGBFormat;
-					break;
+				switch ( mapName ) {
+
+					case 'aoMap':
+					case 'emissiveMap':
+					case 'metalnessMap':
+					case 'normalMap':
+					case 'roughnessMap':
+						texture.format = THREE.RGBFormat;
+						break;
+
+				}
 
 
 			}
 			}
 
 
@@ -2285,13 +2290,13 @@ THREE.GLTFLoader = ( function () {
 		if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) {
 		if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) {
 
 
 			var sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ];
 			var sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ];
-			materialType = sgExtension.getMaterialType( materialDef );
+			materialType = sgExtension.getMaterialType();
 			pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) );
 			pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) );
 
 
 		} else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
 		} else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
 
 
 			var kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ];
 			var kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ];
-			materialType = kmuExtension.getMaterialType( materialDef );
+			materialType = kmuExtension.getMaterialType();
 			pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) );
 			pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) );
 
 
 		} else {
 		} else {

+ 5 - 0
src/constants.d.ts

@@ -233,3 +233,8 @@ export const RGBDEncoding: TextureEncoding;
 export enum DepthPackingStrategies {}
 export enum DepthPackingStrategies {}
 export const BasicDepthPacking: DepthPackingStrategies;
 export const BasicDepthPacking: DepthPackingStrategies;
 export const RGBADepthPacking: DepthPackingStrategies;
 export const RGBADepthPacking: DepthPackingStrategies;
+
+// Normal Map types
+export enum NormalMapTypes {}
+export const TangentSpaceNormalMap: NormalMapTypes;
+export const ObjectSpaceNormalMap: NormalMapTypes;

+ 3 - 0
src/materials/MeshMatcapMaterial.d.ts

@@ -2,6 +2,7 @@ import { Color } from './../math/Color';
 import { Texture } from './../textures/Texture';
 import { Texture } from './../textures/Texture';
 import { Vector2 } from './../math/Vector2';
 import { Vector2 } from './../math/Vector2';
 import { MaterialParameters, Material } from './Material';
 import { MaterialParameters, Material } from './Material';
+import { NormalMapTypes } from '../constants';
 
 
 export interface MeshMatcapMaterialParameters extends MaterialParameters {
 export interface MeshMatcapMaterialParameters extends MaterialParameters {
 
 
@@ -11,6 +12,7 @@ export interface MeshMatcapMaterialParameters extends MaterialParameters {
 	bumpMap?: Texture;
 	bumpMap?: Texture;
 	bumpScale?: number;
 	bumpScale?: number;
 	normalMap?: Texture;
 	normalMap?: Texture;
+	normalMapType?: NormalMapTypes;
 	normalScale?: Vector2;
 	normalScale?: Vector2;
 	displacementMap?: Texture;
 	displacementMap?: Texture;
 	displacementScale?: number;
 	displacementScale?: number;
@@ -30,6 +32,7 @@ export class MeshMatcapMaterial extends Material {
 	bumpMap: Texture | null;
 	bumpMap: Texture | null;
 	bumpScale: number;
 	bumpScale: number;
 	normalMap: Texture | null;
 	normalMap: Texture | null;
+	normalMapType: NormalMapTypes;
 	normalScale: Vector2;
 	normalScale: Vector2;
 	displacementMap: Texture | null;
 	displacementMap: Texture | null;
 	displacementScale: number;
 	displacementScale: number;

+ 32 - 10
src/materials/MeshNormalMaterial.d.ts

@@ -1,19 +1,41 @@
 import { MaterialParameters, Material } from './Material';
 import { MaterialParameters, Material } from './Material';
+import { Texture } from './../textures/Texture';
+import { Vector2 } from './../math/Vector2';
+import { NormalMapTypes } from '../constants';
 
 
 export interface MeshNormalMaterialParameters extends MaterialParameters {
 export interface MeshNormalMaterialParameters extends MaterialParameters {
-  /** Render geometry as wireframe. Default is false (i.e. render as smooth shaded). */
-  wireframe?: boolean;
-  /** Controls wireframe thickness. Default is 1. */
-  wireframeLinewidth?: number;
-  morphTargets?: boolean;
+
+	bumpMap?: Texture;
+	bumpScale?: number;
+	normalMap?: Texture;
+	normalMapType?: NormalMapTypes;
+	normalScale?: Vector2;
+	displacementMap?: Texture;
+	displacementScale?: number;
+	displacementBias?: number;
+	wireframe?: boolean;
+	wireframeLinewidth?: number;
+	skinning?: boolean;
+	morphTargets?: boolean;
+	morphNormals?: boolean;
 }
 }
 
 
 export class MeshNormalMaterial extends Material {
 export class MeshNormalMaterial extends Material {
-  constructor(parameters?: MeshNormalMaterialParameters);
+	constructor(parameters?: MeshNormalMaterialParameters);
 
 
-  wireframe: boolean;
-  wireframeLinewidth: number;
-  morphTargets: boolean;
+	bumpMap: Texture | null;
+	bumpScale: number;
+	normalMap: Texture | null;
+	normalMapType: NormalMapTypes;
+	normalScale: Vector2;
+	displacementMap: Texture | null;
+	displacementScale: number;
+	displacementBias: number;
+	wireframe: boolean;
+	wireframeLinewidth: number;
+	skinning: boolean;
+	morphTargets: boolean;
+	morphNormals: boolean;
 
 
-  setValues(parameters: MeshNormalMaterialParameters): void;
+	setValues(parameters: MeshNormalMaterialParameters): void;
 }
 }

+ 3 - 1
src/materials/MeshPhongMaterial.d.ts

@@ -2,7 +2,7 @@ import { Color } from './../math/Color';
 import { Texture } from './../textures/Texture';
 import { Texture } from './../textures/Texture';
 import { Vector2 } from './../math/Vector2';
 import { Vector2 } from './../math/Vector2';
 import { MaterialParameters, Material } from './Material';
 import { MaterialParameters, Material } from './Material';
-import { Combine } from '../constants';
+import { Combine, NormalMapTypes } from '../constants';
 
 
 export interface MeshPhongMaterialParameters extends MaterialParameters {
 export interface MeshPhongMaterialParameters extends MaterialParameters {
   /** geometry color in hexadecimal. Default is 0xffffff. */
   /** geometry color in hexadecimal. Default is 0xffffff. */
@@ -21,6 +21,7 @@ export interface MeshPhongMaterialParameters extends MaterialParameters {
   bumpMap?: Texture;
   bumpMap?: Texture;
   bumpScale?: number;
   bumpScale?: number;
   normalMap?: Texture;
   normalMap?: Texture;
+  normalMapType?: NormalMapTypes;
   normalScale?: Vector2;
   normalScale?: Vector2;
   displacementMap?: Texture;
   displacementMap?: Texture;
   displacementScale?: number;
   displacementScale?: number;
@@ -57,6 +58,7 @@ export class MeshPhongMaterial extends Material {
   bumpMap: Texture | null;
   bumpMap: Texture | null;
   bumpScale: number;
   bumpScale: number;
   normalMap: Texture | null;
   normalMap: Texture | null;
+  normalMapType: NormalMapTypes;
   normalScale: Vector2;
   normalScale: Vector2;
   displacementMap: Texture | null;
   displacementMap: Texture | null;
   displacementScale: number;
   displacementScale: number;

+ 3 - 0
src/materials/MeshStandardMaterial.d.ts

@@ -2,6 +2,7 @@ import { Color } from './../math/Color';
 import { Texture } from './../textures/Texture';
 import { Texture } from './../textures/Texture';
 import { Vector2 } from './../math/Vector2';
 import { Vector2 } from './../math/Vector2';
 import { MaterialParameters, Material } from './Material';
 import { MaterialParameters, Material } from './Material';
+import { NormalMapTypes } from '../constants';
 
 
 export interface MeshStandardMaterialParameters extends MaterialParameters {
 export interface MeshStandardMaterialParameters extends MaterialParameters {
   color?: Color | string | number;
   color?: Color | string | number;
@@ -18,6 +19,7 @@ export interface MeshStandardMaterialParameters extends MaterialParameters {
   bumpMap?: Texture;
   bumpMap?: Texture;
   bumpScale?: number;
   bumpScale?: number;
   normalMap?: Texture;
   normalMap?: Texture;
+  normalMapType?: NormalMapTypes;
   normalScale?: Vector2;
   normalScale?: Vector2;
   displacementMap?: Texture;
   displacementMap?: Texture;
   displacementScale?: number;
   displacementScale?: number;
@@ -53,6 +55,7 @@ export class MeshStandardMaterial extends Material {
   bumpMap: Texture | null;
   bumpMap: Texture | null;
   bumpScale: number;
   bumpScale: number;
   normalMap: Texture | null;
   normalMap: Texture | null;
+  normalMapType: NormalMapTypes;
   normalScale: number;
   normalScale: number;
   displacementMap: Texture | null;
   displacementMap: Texture | null;
   displacementScale: number;
   displacementScale: number;

+ 1 - 7
src/renderers/WebGLRenderer.js

@@ -298,13 +298,7 @@ function WebGLRenderer( parameters ) {
 
 
 	// vr
 	// vr
 
 
-	var vr = null;
-
-	if ( typeof navigator !== 'undefined' ) {
-
-		vr = ( 'xr' in navigator ) ? new WebXRManager( _this ) : new WebVRManager( _this );
-
-	}
+	var vr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this ) : new WebVRManager( _this );
 
 
 	this.vr = vr;
 	this.vr = vr;