瀏覽代碼

Update LWOLoader to more closely match LW native materials (#22776)

on the z 3 年之前
父節點
當前提交
964ea37e40
共有 3 個文件被更改,包括 11 次插入8 次删除
  1. 8 6
      examples/jsm/loaders/LWOLoader.js
  2. 1 0
      examples/jsm/loaders/lwo/LWO2Parser.js
  3. 2 2
      examples/jsm/loaders/lwo/LWO3Parser.js

+ 8 - 6
examples/jsm/loaders/LWOLoader.js

@@ -4,10 +4,10 @@
  * @desc Load files in LWO3 and LWO2 format on Three.js
  *
  * LWO3 format specification:
- * 	http://static.lightwave3d.com/sdk/2018/html/filefmts/lwo3.html
+ *  https://static.lightwave3d.com/sdk/2019/html/filefmts/lwo3.html
  *
  * LWO2 format specification:
- * 	http://static.lightwave3d.com/sdk/2018/html/filefmts/lwo2.html
+ *  https://static.lightwave3d.com/sdk/2019/html/filefmts/lwo2.html
  *
  **/
 
@@ -465,7 +465,7 @@ class MaterialParser {
 					break;
 				case 'Roughness':
 					maps.roughnessMap = texture;
-					maps.roughness = 0.5;
+					maps.roughness = 1;
 					break;
 				case 'Specular':
 					maps.specularMap = texture;
@@ -480,7 +480,7 @@ class MaterialParser {
 					break;
 				case 'Metallic':
 					maps.metalnessMap = texture;
-					maps.metalness = 0.5;
+					maps.metalness = 1;
 					break;
 				case 'Transparency':
 				case 'Alpha':
@@ -591,7 +591,7 @@ class MaterialParser {
 
 		if ( attributes[ 'Bump Height' ] ) params.bumpScale = attributes[ 'Bump Height' ].value * 0.1;
 
-		if ( attributes[ 'Refraction Index' ] ) params.refractionRatio = 1 / attributes[ 'Refraction Index' ].value;
+		if ( attributes[ 'Refraction Index' ] ) params.refractionRatio = 0.98 / attributes[ 'Refraction Index' ].value;
 
 		this.parsePhysicalAttributes( params, attributes, maps );
 		this.parseStandardAttributes( params, attributes, maps );
@@ -707,10 +707,12 @@ class MaterialParser {
 
 				if ( attributes.metalness !== undefined ) {
 
-					delete attributes.metalness;
+					attributes.metalness = 1; // For most transparent materials metalness should be set to 1 if not otherwise defined. If set to 0 no refraction will be visible
 
 				}
 
+				attributes.opacity = 1; // transparency fades out refraction, forcing opacity to 1 ensures a closer visual match to the material in Lightwave.
+
 			} else envMap.mapping = EquirectangularReflectionMapping;
 
 			maps.envMap = envMap;

+ 1 - 0
examples/jsm/loaders/lwo/LWO2Parser.js

@@ -106,6 +106,7 @@ LWO2Parser.prototype = {
 			case 'WRPW': // image wrap w ( for cylindrical and spherical projections)
 			case 'WRPH': // image wrap h
 			case 'NMOD':
+			case 'NSEL':
 			case 'NPRW':
 			case 'NPLA':
 			case 'NODS':

+ 2 - 2
examples/jsm/loaders/lwo/LWO3Parser.js

@@ -38,8 +38,8 @@ LWO3Parser.prototype = {
 			case 'NORM':
 
 			// ENVL FORM skipped
-			case 'PRE ':
-			case 'POST':
+			case 'PRE ': // Pre-loop behavior for the keyframe
+			case 'POST': // Post-loop behavior for the keyframe
 			case 'KEY ':
 			case 'SPAN':