瀏覽代碼

Merge pull request #19188 from linbingquan/dev-examples-api

Examples: Make box geometry generation more flexible in webgl_lines_dashed.
Mr.doob 5 年之前
父節點
當前提交
2b0b6b793a
共有 1 個文件被更改,包括 30 次插入28 次删除
  1. 30 28
      examples/webgl_lines_dashed.html

+ 30 - 28
examples/webgl_lines_dashed.html

@@ -51,9 +51,9 @@
 				objects.push( line );
 				objects.push( line );
 				scene.add( line );
 				scene.add( line );
 
 
-				var geometryCube = cube( 50 );
+				var geometryBox = box( 50, 50, 50 );
 
 
-				var lineSegments = new THREE.LineSegments( geometryCube, new THREE.LineDashedMaterial( { color: 0xffaa00, dashSize: 3, gapSize: 1 } ) );
+				var lineSegments = new THREE.LineSegments( geometryBox, new THREE.LineDashedMaterial( { color: 0xffaa00, dashSize: 3, gapSize: 1 } ) );
 				lineSegments.computeLineDistances();
 				lineSegments.computeLineDistances();
 
 
 				objects.push( lineSegments );
 				objects.push( lineSegments );
@@ -75,49 +75,51 @@
 
 
 			}
 			}
 
 
-			function cube( size ) {
+			function box( width, height, depth ) {
 
 
-				var h = size * 0.5;
+				width = width * 0.5,
+				height = height * 0.5,
+				depth = depth * 0.5;
 
 
 				var geometry = new THREE.BufferGeometry();
 				var geometry = new THREE.BufferGeometry();
 				var position = [];
 				var position = [];
 
 
 				position.push(
 				position.push(
-					- h, - h, - h,
-					- h, h, - h,
+					- width, - height, - depth,
+					- width, height, - depth,
 
 
-					- h, h, - h,
-					h, h, - h,
+					- width, height, - depth,
+					width, height, - depth,
 
 
-					h, h, - h,
-					h, - h, - h,
+					width, height, - depth,
+					width, - height, - depth,
 
 
-					h, - h, - h,
-					- h, - h, - h,
+					width, - height, - depth,
+					- width, - height, - depth,
 
 
-					- h, - h, h,
-					- h, h, h,
+					- width, - height, depth,
+					- width, height, depth,
 
 
-					- h, h, h,
-					h, h, h,
+					- width, height, depth,
+					width, height, depth,
 
 
-					h, h, h,
-					h, - h, h,
+					width, height, depth,
+					width, - height, depth,
 
 
-					h, - h, h,
-					- h, - h, h,
+					width, - height, depth,
+					- width, - height, depth,
 
 
-					- h, - h, - h,
-					- h, - h, h,
+					- width, - height, - depth,
+					- width, - height, depth,
 
 
-					- h, h, - h,
-					- h, h, h,
+					- width, height, - depth,
+					- width, height, depth,
 
 
-					h, h, - h,
-					h, h, h,
+					width, height, - depth,
+					width, height, depth,
 
 
-					h, - h, - h,
-					h, - h, h
+					width, - height, - depth,
+					width, - height, depth
 				 );
 				 );
 
 
 				geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( position, 3 ) );
 				geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( position, 3 ) );