ExtrudeGeometry.html 3.4 KB
Newer Older
1 2 3 4
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
M
Mr.doob 已提交
5
		<base href="../../../" />
6 7 8 9 10 11 12 13
		<script src="page.js"></script>
		<link type="text/css" rel="stylesheet" href="page.css" />
	</head>
	<body>
		[page:BufferGeometry] &rarr;

		<h1>[name]</h1>

M
Mugen87 已提交
14
		<p class="desc">Creates extruded geometry from a path shape.</p>
15

M
Mugen87 已提交
16
		<iframe id="scene" src="scenes/geometry-browser.html#ExtrudeGeometry"></iframe>
17 18 19 20 21 22 23

		<script>

		// iOS iframe auto-resize workaround

		if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {

M
Mugen87 已提交
24
			const scene = document.getElementById( 'scene' );
25 26 27 28 29 30 31 32 33

			scene.style.width = getComputedStyle( scene ).width;
			scene.style.height = getComputedStyle( scene ).height;
			scene.setAttribute( 'scrolling', 'no' );

		}

		</script>

M
Mugen87 已提交
34
		<h2>Code Example</h2>
35 36 37


		<code>
M
Mugen87 已提交
38
		const length = 12, width = 8;
39

M
Mugen87 已提交
40
		const shape = new THREE.Shape();
41 42 43 44 45 46
		shape.moveTo( 0,0 );
		shape.lineTo( 0, width );
		shape.lineTo( length, width );
		shape.lineTo( length, 0 );
		shape.lineTo( 0, 0 );

M
Mugen87 已提交
47
		const extrudeSettings = {
48
			steps: 2,
49
			depth: 16,
50 51 52
			bevelEnabled: true,
			bevelThickness: 1,
			bevelSize: 1,
53
			bevelOffset: 0,
54
			bevelSegments: 1
55 56
		};

M
Mugen87 已提交
57
		const geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings );
M
Mugen87 已提交
58 59
		const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
		const mesh = new THREE.Mesh( geometry, material ) ;
60 61 62 63 64 65 66
		scene.add( mesh );
		</code>


		<h2>Constructor</h2>


67
		<h3>[name]([param:Array shapes], [param:Object options])</h3>
68
		<p>
69 70 71 72 73 74
		shapes — Shape or an array of shapes. <br />
		options — Object that can contain the following parameters.

			<ul>
				<li>curveSegments — int. Number of points on the curves. Default is 12.</li>
				<li>steps — int. Number of points used for subdividing segments along the depth of the extruded spline. Default is 1.</li>
75
				<li>depth — float. Depth to extrude the shape. Default is 100.</li>
76 77
				<li>bevelEnabled — bool. Apply beveling to the shape. Default is true.</li>
				<li>bevelThickness — float. How deep into the original shape the bevel goes. Default is 6.</li>
78
				<li>bevelSize — float. Distance from the shape outline that the bevel extends. Default is bevelThickness - 2.</li>
79
				<li>bevelOffset — float. Distance from the shape outline that the bevel starts. Default is 0.</li>
80
				<li>bevelSegments — int. Number of bevel layers. Default is 3.</li>
81
				<li>extrudePath — THREE.Curve. A 3D spline path along which the shape should be extruded. Bevels not supported for path extrusion.</li>
82 83 84
				<li>UVGenerator —  Object. object that provides UV generator functions</li>
			</ul>

85 86
		</p>
		<p>
87
			This object extrudes a 2D shape to a 3D geometry.
88
		</p>
89

90
		<p>
M
Mugen87 已提交
91 92
			When creating a Mesh with this geometry, if you'd like to have a separate material used for its face
			and its extruded sides, you can use an array of materials. The first material will be
93
			applied to the face; the second material will be applied to the sides.
94
		</p>
95

96
		<h2>Properties</h2>
M
Mugen87 已提交
97
		<p>See the base [page:BufferGeometry] class for common properties.</p>
98 99 100 101 102 103

		<h3>[property:Object parameters]</h3>
		<p>
		An object with a property for each of the constructor parameters. Any modification after instantiation does not change the geometry.
		</p>

M
Mugen87 已提交
104 105 106
		<h2>Methods</h2>
		<p>See the base [page:BufferGeometry] class for common methods.</p>

107 108
		<h2>Source</h2>

M
Mugen87 已提交
109
		<p>
M
Mr.doob 已提交
110
			[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
M
Mugen87 已提交
111
		</p>
112 113
	</body>
</html>