Parcourir la source

VRMLLoader: Fix transparency settings for lines and points. (#27841)

Michael Herzog il y a 1 an
Parent
commit
4800ed8f2e

+ 6 - 2
examples/jsm/loaders/VRMLLoader.js

@@ -1012,7 +1012,9 @@ class VRMLLoader extends Loader {
 
 
 					const pointsMaterial = new PointsMaterial( {
 					const pointsMaterial = new PointsMaterial( {
 						name: Loader.DEFAULT_MATERIAL_NAME,
 						name: Loader.DEFAULT_MATERIAL_NAME,
-						color: 0xffffff
+						color: 0xffffff,
+						opacity: material.opacity,
+						transparent: material.transparent
 					} );
 					} );
 
 
 					if ( geometry.attributes.color !== undefined ) {
 					if ( geometry.attributes.color !== undefined ) {
@@ -1037,7 +1039,9 @@ class VRMLLoader extends Loader {
 
 
 					const lineMaterial = new LineBasicMaterial( {
 					const lineMaterial = new LineBasicMaterial( {
 						name: Loader.DEFAULT_MATERIAL_NAME,
 						name: Loader.DEFAULT_MATERIAL_NAME,
-						color: 0xffffff
+						color: 0xffffff,
+						opacity: material.opacity,
+						transparent: material.transparent
 					} );
 					} );
 
 
 					if ( geometry.attributes.color !== undefined ) {
 					if ( geometry.attributes.color !== undefined ) {

+ 41 - 0
examples/models/vrml/linesTransparent.wrl

@@ -0,0 +1,41 @@
+#VRML V2.0 utf8
+Transform {
+	translation 0 0 0
+	children[
+		Shape {
+			appearance Appearance {
+				material Material {
+					emissiveColor 1 0 0
+					transparency 0.8
+				}
+			}
+			geometry IndexedLineSet {
+				coord Coordinate {
+					point [
+						0 0 0,
+						1 0 0,
+						1 1 0,
+						0 1 0,
+						0 0 1,
+						1 0 1,
+						1 1 1,
+						0 1 1,
+						0.5 0.5 0,
+						1 0.5 0.5,
+						0.5 1 0.5,
+						0 0.5 0.5,
+						0.5 0 0.5,
+						0.5 0.5 1
+					]
+				}
+				coordIndex [
+					0, 1, -1, 1, 2, -1, 2, 3, -1, 3, 0, -1,
+					4, 5, -1, 5, 6, -1, 6, 7, -1, 7, 4, -1,
+					0, 4, -1, 1, 5, -1, 2, 6, -1, 3, 7, -1,
+					0, 2, -1, 1, 3, -1, 4, 6, -1, 5, 7, -1,
+					8, 13, -1, 9, 11, -1, 10, 12, -1
+				]
+			}
+		}
+	]
+}

+ 1 - 0
examples/webgl_loader_vrml.html

@@ -47,6 +47,7 @@
 				'extrusion2',
 				'extrusion2',
 				'extrusion3',
 				'extrusion3',
 				'lines',
 				'lines',
+				'linesTransparent',
 				'meshWithLines',
 				'meshWithLines',
 				'meshWithTexture',
 				'meshWithTexture',
 				'pixelTexture',
 				'pixelTexture',