-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathH3DU.Shape.html
executable file
·318 lines (240 loc) · 12.8 KB
/
H3DU.Shape.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<!DOCTYPE html><html xmlns:dc="http://purl.org/dc/terms/"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width"><link rel=stylesheet type="text/css" href="/style.css">
<script type="text/x-mathjax-config"> MathJax.Hub.Config({"HTML-CSS": { availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, preferredFont: "TeX" },
tex2jax: { displayMath: [ ["$$","$$"], ["\\[", "\\]"] ], inlineMath: [ ["$", "$"], ["\\\\(","\\\\)"] ], processEscapes: true } });
</script><script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML-full"></script></head><body> <div class="header">
<nav><p><a href="#navigation">Menu</a> - <a href="#top">Top</a> - <a href="/">Home</a></nav></div>
<div class="mainarea" id="top">
<h1 id="h3dushape">H3DU.Shape</h1>
<p><a href="index.html">Back to documentation index.</a></p>
<p><a name="H3DU.Shape"></a>
### new H3DU.Shape(mesh)</p>
<p>An object that associates a geometric mesh (the shape of the object) with
a transformation matrix (which defines the object’s position and size).
See the “<a href="tutorial-shapes.html">Creating Shapes</a>” tutorial.</p>
<h4 id="parameters">Parameters</h4>
<ul>
<li><code>mesh</code> (Type: MeshBuffer)<br />A mesh in the form of a buffer object. Cannot be null.</li>
</ul>
<h3 id="methods">Methods</h3>
<ul>
<li><a href="#H3DU.Shape_copy">copy</a><br />Makes a copy of this object.</li>
<li><a href="#H3DU.Shape_getBounds">getBounds</a><br />Finds a bounding box that holds all vertices in this shape.</li>
<li><a href="#H3DU.Shape_getMatrix">getMatrix</a><br />Gets the transformation matrix used by this shape.</li>
<li><a href="#H3DU.Shape_getMeshBuffer">getMeshBuffer</a><br />Returns a reference to the mesh buffer used by this shape.</li>
<li><a href="#H3DU.Shape_getTransform">getTransform</a><br />Returns the transform used by this shape object.</li>
<li><a href="#H3DU.Shape_getVisible">getVisible</a><br />Gets whether this shape will be drawn on rendering.</li>
<li><a href="#H3DU.Shape_primitiveCount">primitiveCount</a><br />Gets the number of primitives (triangles, lines,
and points) composed by all shapes in this scene.</li>
<li><a href="#H3DU.Shape_setPosition">setPosition</a><br />Sets the relative position of this shape from its original
position.</li>
<li><a href="#H3DU.Shape_setQuaternion">setQuaternion</a><br />Sets this object’s rotation in the form of a <a href="tutorial-glmath.html">quaternion</a>.</li>
<li><a href="#H3DU.Shape_setScale">setScale</a><br />Sets the scale of this shape relative to its original
size.</li>
<li><a href="#H3DU.Shape_setTransform">setTransform</a><br />Sets this shape’s transformation
to a copy of the specified transformation.</li>
<li><a href="#H3DU.Shape_setVisible">setVisible</a><br />Sets whether this shape will be drawn on rendering.</li>
<li><a href="#H3DU.Shape_vertexCount">vertexCount</a><br />Gets the number of vertices composed by
all shapes in this scene.</li>
</ul>
<p><a name="H3DU.Shape_copy"></a>
### H3DU.Shape#copy()</p>
<p>Makes a copy of this object. The copied object
will have its own version of the transform.
The copied shape won’t have a parent.</p>
<h4 id="return-value">Return Value</h4>
<p>A copy of this object. (Type: Shape)</p>
<p><a name="H3DU.Shape_getBounds"></a>
### H3DU.Shape#getBounds()</p>
<p>Finds a bounding box that holds all vertices in this shape.
The bounding box is not guaranteed to be the
tightest, and the box will be transformed to world space
using this object’s transform.</p>
<h4 id="return-value-1">Return Value</h4>
<p>An array of six numbers describing an
axis-aligned bounding box
that fits all vertices in the shape. The first three numbers
are the smallest-valued x-, y-, and z-coordinates, and the
last three are the largest-valued x-, y-, and z-coordinates.
If the shape has no vertices, returns the array [Inf, Inf, Inf, -Inf,
-Inf, -Inf]. (Type: Array.<number>)</p>
<p><a name="H3DU.Shape_getMatrix"></a>
### H3DU.Shape#getMatrix()</p>
<p>Gets the transformation matrix used by this shape.
See Transform#getMatrix.</p>
<h4 id="return-value-2">Return Value</h4>
<p>The current transformation matrix. (Type: Array.<number>)</p>
<p><a name="H3DU.Shape_getMeshBuffer"></a>
### H3DU.Shape#getMeshBuffer()</p>
<p>Returns a reference to the mesh buffer used by this shape.</p>
<h4 id="return-value-3">Return Value</h4>
<p>Return value. (Type: MeshBuffer)</p>
<p><a name="H3DU.Shape_getTransform"></a>
### H3DU.Shape#getTransform()</p>
<p>Returns the transform used by this shape object.
The transform won’t be copied.</p>
<h4 id="return-value-4">Return Value</h4>
<p>Return value. (Type: Transform)</p>
<p><a name="H3DU.Shape_getVisible"></a>
### H3DU.Shape#getVisible()</p>
<p>Gets whether this shape will be drawn on rendering.</p>
<h4 id="return-value-5">Return Value</h4>
<p>True if this shape will be visible; otherwise, false. (Type: boolean)</p>
<p><a name="H3DU.Shape_primitiveCount"></a>
### H3DU.Shape#primitiveCount()</p>
<p>Gets the number of primitives (triangles, lines,
and points) composed by all shapes in this scene.</p>
<h4 id="return-value-6">Return Value</h4>
<p>Return value. (Type: number)</p>
<p><a name="H3DU.Shape_setPosition"></a>
### H3DU.Shape#setPosition(x, [y], [z])</p>
<p>Sets the relative position of this shape from its original
position. See Transform#setPosition</p>
<h4 id="parameters-1">Parameters</h4>
<ul>
<li>
<table>
<tbody>
<tr>
<td><code>x</code> (Type: Array.<number></td>
<td>number)<br />The x-coordinate. If “y” and “z” are null, undefined, or omitted, this is instead a 3-element array giving the x-, y-, and z-coordinates, or a single number giving the coordinate for all three dimensions.</td>
</tr>
</tbody>
</table>
</li>
<li><code>y</code> (Type: number) (optional)<br />The y-coordinate. If “x” is an array, this parameter may be omitted.</li>
<li><code>z</code> (Type: number) (optional)<br />The z-coordinate. If “x” is an array, this parameter may be omitted.</li>
</ul>
<h4 id="return-value-7">Return Value</h4>
<p>This object. (Type: Shape)</p>
<h4 id="examples">Examples</h4>
<pre>// Set the relative position to 2 units along x-axis, 4 units along y-axis,
// and 5 units along z-axis
shape.setPosition(2,4,5);
// same, but passing an array
shape.setPosition([2,4,5]);
</pre>
<p><a name="H3DU.Shape_setQuaternion"></a>
### H3DU.Shape#setQuaternion(quat)</p>
<p>Sets this object’s rotation in the form of a <a href="tutorial-glmath.html">quaternion</a>.
See Transform#setQuaternion.</p>
<h4 id="parameters-2">Parameters</h4>
<ul>
<li><code>quat</code> (Type: Array.<number>)<br />A four-element array describing the rotation.</li>
</ul>
<h4 id="return-value-8">Return Value</h4>
<p>This object. (Type: Shape)</p>
<h4 id="examples-1">Examples</h4>
<pre>// rotate the shape 40 units about x-axis, 20 units about y-axis,
// and 50 units about z-axis
shape.setQuaternion(H3DU.MathUtil.quatFromTaitBryan(40,20,50));
// rotate the shape 20 units about y-axis
shape.setQuaternion(H3DU.MathUtil.quatFromAxisAngle(20,0,1,0));
</pre>
<p><a name="H3DU.Shape_setScale"></a>
### H3DU.Shape#setScale(x, [y], [z])</p>
<p>Sets the scale of this shape relative to its original
size. See Transform#setScale</p>
<h4 id="parameters-3">Parameters</h4>
<ul>
<li>
<table>
<tbody>
<tr>
<td><code>x</code> (Type: number</td>
<td>Array.<number>)<br />x-axis scaling factor for this shape object. If “y” and “z” are null, undefined, or omitted, this is instead a 3-element array giving the scaling factors for the X, Y, and Z dimensions, respectively, or a single number giving the scaling factor for all three dimensions.</td>
</tr>
</tbody>
</table>
</li>
<li><code>y</code> (Type: number) (optional)<br />y-axis scaling factor for this shape object.</li>
<li><code>z</code> (Type: number) (optional)<br />z-axis scaling factor for this shape object.</li>
</ul>
<h4 id="return-value-9">Return Value</h4>
<p>This object. (Type: Shape)</p>
<h4 id="examples-2">Examples</h4>
<pre>// scale the shape by 2x in all axes
shape.setScale(2,2,2);
// same, but passing an array
shape.setScale([2,2,2]);
</pre>
<p><a name="H3DU.Shape_setTransform"></a>
### H3DU.Shape#setTransform(transform)</p>
<p>Sets this shape’s transformation
to a copy of the specified transformation.</p>
<h4 id="parameters-4">Parameters</h4>
<ul>
<li><code>transform</code> (Type: Transform)<br />The transformation to set to a copy of.</li>
</ul>
<h4 id="return-value-10">Return Value</h4>
<p>This object. (Type: Shape)</p>
<p><a name="H3DU.Shape_setVisible"></a>
### H3DU.Shape#setVisible(value)</p>
<p>Sets whether this shape will be drawn on rendering.</p>
<h4 id="parameters-5">Parameters</h4>
<ul>
<li><code>value</code> (Type: boolean)<br />True if this shape will be visible; otherwise, false.</li>
</ul>
<h4 id="return-value-11">Return Value</h4>
<p>This object. (Type: Shape)</p>
<p><a name="H3DU.Shape_vertexCount"></a>
### H3DU.Shape#vertexCount()</p>
<p>Gets the number of vertices composed by
all shapes in this scene.</p>
<h4 id="return-value-12">Return Value</h4>
<p>Return value. (Type: number)</p>
<p><a href="index.html">Back to documentation index.</a></p>
</div><nav id="navigation"><ul>
<li><a href="/">Back to start site.</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io">This site's repository (source code)</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io/issues">Post an issue or comment</a></ul>
<div class="noprint">
<p>
<a href="//twitter.com/intent/tweet">Share via Twitter</a>, <a href="//www.facebook.com/sharer/sharer.php" id="sharer">Share via Facebook</a>
</p>
</div>
<h3 id="navigation">Navigation</h3>
<ul>
<li><a href="BSplineCurve.html">BSplineCurve</a></li>
<li><a href="BSplineSurface.html">BSplineSurface</a></li>
<li><a href="BufferAccessor.html">BufferAccessor</a></li>
<li><a href="Curve.html">Curve</a></li>
<li><a href="CurveBuilder.html">CurveBuilder</a></li>
<li><a href="GraphicsPath.html">GraphicsPath</a></li>
<li><a href="H3DU.html">H3DU</a></li>
<li><a href="MathUtil.html">MathUtil</a></li>
<li><a href="MeshBuffer.html">MeshBuffer</a></li>
<li><a href="Meshes.html">Meshes</a></li>
<li><a href="PiecewiseCurve.html">PiecewiseCurve</a></li>
<li><a href="Semantic.html">Semantic</a></li>
<li><a href="ShapeGroup.html">ShapeGroup</a></li>
<li><a href="Surface.html">Surface</a></li>
<li><a href="SurfaceBuilder.html">SurfaceBuilder</a></li>
<li><a href="Transform.html">Transform</a></li>
<li><a href="extras_camera.html">module:extras/camera</a></li>
<li><a href="extras_camera.Camera.html">module:extras/camera.Camera</a></li>
<li><a href="extras_camera.InputTracker.html">module:extras/camera.InputTracker</a></li>
<li><a href="extras_createwasher.html">module:extras/createwasher</a></li>
<li><a href="extras_curvetube.html">module:extras/curvetube</a></li>
<li><a href="extras_curvetube.CurveTube.html">module:extras/curvetube.CurveTube</a></li>
<li><a href="extras_derivedcurves.html">module:extras/derivedcurves</a></li>
<li><a href="extras_evaluators.html">module:extras/evaluators</a></li>
<li><a href="extras_evaluators.Roulette.html">module:extras/evaluators.Roulette</a></li>
<li><a href="extras_evaluators.SurfaceOfRevolution.html">module:extras/evaluators.SurfaceOfRevolution</a></li>
<li><a href="extras_fourierknot.html">module:extras/fourierknot</a></li>
<li><a href="extras_gradients.html">module:extras/gradients</a></li>
<li><a href="extras_marbleshader2.html">module:extras/marbleshader2</a></li>
<li><a href="extras_matrixstack.html">module:extras/matrixstack</a></li>
<li><a href="extras_matrixstack.MatrixStack.html">module:extras/matrixstack.MatrixStack</a></li>
<li><a href="extras_moresurfaces.html">module:extras/moresurfaces</a></li>
<li><a href="extras_moresurfaces.KleinBottle.html">module:extras/moresurfaces.KleinBottle</a></li>
<li><a href="extras_moresurfaces.MoebiusStrip.html">module:extras/moresurfaces.MoebiusStrip</a></li>
<li><a href="extras_pathutil.html">module:extras/pathutil</a></li>
<li><a href="extras_randompolygon.html">module:extras/randompolygon</a></li>
<li><a href="extras_starpolygon.html">module:extras/starpolygon</a></li>
<li><a href="extras_superellipsoid.html">module:extras/superellipsoid</a></li>
<li><a href="extras_superellipsoid.Supershape.html">module:extras/superellipsoid.Supershape</a></li>
<li><a href="extras_superellipsoid.Supertoroid.html">module:extras/superellipsoid.Supertoroid</a></li>
<li><a href="extras_torusknot.html">module:extras/torusknot</a></li>
<li><a href="extras_torusknot.TorusKnot.html">module:extras/torusknot.TorusKnot</a></li>
</ul>
</nav></body></html>