2
0
Эх сурвалжийг харах

Merge pull request #6453 from WestLangley/dev-shapes

Added example of ShapeGeometry with texture
Ricardo Cabello 10 жил өмнө
parent
commit
c7ff082b82

+ 15 - 0
examples/webgl_geometry_shapes.html

@@ -64,11 +64,26 @@
 				group.position.y = 50;
 				group.position.y = 50;
 				scene.add( group );
 				scene.add( group );
 
 
+				var texture = THREE.ImageUtils.loadTexture( "textures/UV_Grid_Sm.jpg" );
+				texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
+				texture.repeat.set( 0.008, 0.008 );
+
 				function addShape( shape, extrudeSettings, color, x, y, z, rx, ry, rz, s ) {
 				function addShape( shape, extrudeSettings, color, x, y, z, rx, ry, rz, s ) {
 
 
 					var points = shape.createPointsGeometry();
 					var points = shape.createPointsGeometry();
 					var spacedPoints = shape.createSpacedPointsGeometry( 50 );
 					var spacedPoints = shape.createSpacedPointsGeometry( 50 );
 
 
+					// flat shape with texture
+					// note: default UVs generated by ShapeGemoetry are simply the x- and y-coordinates of the vertices
+
+					var geometry = new THREE.ShapeGeometry( shape );
+
+					var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { side: THREE.DoubleSide, map: texture } ) );
+					mesh.position.set( x, y, z - 175 );
+					mesh.rotation.set( rx, ry, rz );
+					mesh.scale.set( s, s, s );
+					group.add( mesh );
+
 					// flat shape
 					// flat shape
 
 
 					var geometry = new THREE.ShapeGeometry( shape );
 					var geometry = new THREE.ShapeGeometry( shape );