소스 검색

Merge pull request #6453 from WestLangley/dev-shapes

Added example of ShapeGeometry with texture
Ricardo Cabello 10 년 전
부모
커밋
c7ff082b82
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 15 0
      examples/webgl_geometry_shapes.html

+ 15 - 0
examples/webgl_geometry_shapes.html

@@ -64,11 +64,26 @@
 				group.position.y = 50;
 				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 ) {
 
 					var points = shape.createPointsGeometry();
 					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
 
 					var geometry = new THREE.ShapeGeometry( shape );