Browse Source

ColladaLoader: Fix line rendering with incompatible materials. (#25017)

Michael Herzog 2 years ago
parent
commit
46fb35af1f
1 changed files with 28 additions and 0 deletions
  1. 28 0
      examples/jsm/loaders/ColladaLoader.js

+ 28 - 0
examples/jsm/loaders/ColladaLoader.js

@@ -3764,6 +3764,34 @@ class ColladaLoader extends Loader {
 
 				}
 
+				// Collada allows to use phong and lambert materials with lines. Replacing these cases with LineBasicMaterial.
+
+				if ( type === 'lines' || type === 'linestrips' ) {
+
+					for ( let i = 0, l = materials.length; i < l; i ++ ) {
+
+						const material = materials[ i ];
+
+						if ( material.isMeshPhongMaterial === true || material.isMeshLambertMaterial === true ) {
+
+							const lineMaterial = new LineBasicMaterial();
+
+							// copy compatible properties
+
+							lineMaterial.color.copy( material.color );
+							lineMaterial.opacity = material.opacity;
+							lineMaterial.transparent = material.transparent;
+
+							// replace material
+
+							materials[ i ] = lineMaterial;
+
+						}
+
+					}
+
+				}
+
 				// regard skinning
 
 				const skinning = ( geometry.data.attributes.skinIndex !== undefined );