-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathH3DU.Material.html
executable file
·351 lines (246 loc) · 18.7 KB
/
H3DU.Material.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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!DOCTYPE html><html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><title>H3DU.Material</title><meta name="viewport" content="width=device-width"><link rel=stylesheet type="text/css" href="/style.css"></head><body> <div class="header">
<p><a href="#navigation">Menu</a> - <a href="#top">Top</a> - <a href="/">Home</a> -
<a href="http://peteroupc.github.io/">Donate to Me</a></p></div>
<div class="mainarea" id="top">
<h1>H3DU.Material</h1>
<p><a href="index.html">Back to documentation index.</a></p>
<p><a name='H3DU.Material'></a></p>
<h3>H3DU.Material([params], [diffuse], [specular], [shininess], [emission])</h3>
<p>Specifies parameters for geometry materials, which describe the appearance of a
3D object. This includes how an object scatters or reflects light,
as well as a texture image to apply on that object's surface.</p>
<p>NOTE: The default shader program assumes that all colors and the diffuse texture specified in this object are in
<a href="H3DU.Math.html#H3DU.Math.colorTosRGB">companded sRGB</a>.</p>
<h4>Parameters</h4>
<ul>
<li><code>params</code> (Type: Array.<number>) (optional)<br>An object as described in <a href="H3DU.Material.html#H3DU.Material_setParams">H3DU.Material#setParams</a>. <i>Using this parameter as a <a href="H3DU.html#H3DU.toGLColor">color vector or string</a> giving the ambient color is obsolete since version 2.0.</i></li>
<li><code>diffuse</code> (Type: Array.<number>) (optional)<br>A <a href="H3DU.html#H3DU.toGLColor">color vector or string</a> giving the diffusion color (also called "albedo"). <i>This parameter is obsolete.</i></li>
<li><code>specular</code> (Type: Array.<number>) (optional)<br>A <a href="H3DU.html#H3DU.toGLColor">color vector or string</a> giving the specular highlight reflection. <i>This parameter is obsolete.</i></li>
<li><code>shininess</code> (Type: Array.<number>) (optional)<br>Specular highlight exponent of this material. <i>This parameter is obsolete.</i></li>
<li><code>emission</code> (Type: Array.<number>) (optional)<br>A <a href="H3DU.html#H3DU.toGLColor">color vector or string</a> giving the additive color emitted by an object. <i>This parameter is obsolete.</i></li>
</ul>
<h3>Members</h3>
<ul>
<li><a href="#H3DU.Material_ambient">ambient</a><br>Ambient color of this material.</li>
<li><a href="#H3DU.Material_diffuse">diffuse</a><br>Diffusion color of this material (also called "albedo").</li>
<li><a href="#H3DU.Material_emission">emission</a><br>Additive color emitted by objects with this material.</li>
<li><a href="#H3DU.Material_emissionMap">emissionMap</a><br>Emission map texture.</li>
<li><a href="#H3DU.Material_normalMap">normalMap</a><br>Normal map (bump map) texture.</li>
<li><a href="#H3DU.Material_occlusionMap">occlusionMap</a><br>Ambient occlusion map texture.</li>
<li><a href="#H3DU.Material_shader">shader</a><br>Shader program to use when rendering objects with this material.</li>
<li><a href="#H3DU.Material_shininess">shininess</a><br>Specular highlight exponent of this material.</li>
<li><a href="#H3DU.Material_specular">specular</a><br>Specular highlight reflection of this material.</li>
<li><a href="#H3DU.Material_specularMap">specularMap</a><br>Specular map texture.</li>
<li><a href="#H3DU.Material_texture">texture</a><br>Texture for this material.</li>
</ul>
<h3>Methods</h3>
<ul>
<li><a href="#H3DU.Material_copy">copy</a><br>Clones this object's parameters to a new H3DU.Material
object and returns that object.</li>
<li><a href="#H3DU.Material.fromBasic">fromBasic</a><br>Creates a material with its emission color set to the specified color.</li>
<li><a href="#H3DU.Material.fromBasicTexture">fromBasicTexture</a><br>Creates a material with its emission texture set to the specified texture.</li>
<li><a href="#H3DU.Material.fromColor">fromColor</a><br>Convenience method that returns an <a href="H3DU.Material.html">H3DU.Material</a>
object from an RGBA color.</li>
<li><a href="#H3DU.Material.fromTexture">fromTexture</a><br>Convenience method that returns an <a href="H3DU.Material.html">H3DU.Material</a>
object from a texture to apply to a 3D object's surface.</li>
<li><a href="#H3DU.Material_setParams">setParams</a><br>Sets parameters for this material object.</li>
</ul>
<p><a name='H3DU.Material_ambient'></a></p>
<h3>H3DU.Material#ambient</h3>
<p>Ambient color of this material.</p>
<p>Ambient color indicates how much an object's color is affected by ambient
lights, those that color pixels the same way regardless
of direction or distance.
Because every part of an object will be shaded the same way by ambient
colors, an object with just ambient color will not look much like a 3D object.</p>
<p>(Ambient color simulates the effect of light being scattered multiple times
from the same surface.)
This value is a 3-element array giving the red, green, and blue
components of the ambient color; the final ambient color depends
on the ambient color of the scene.
(0,0,0) means no ambient color,
and (1,1,1) means total ambient color.</p>
<p>Setting ambient color and diffusion color to the same value usually defines an object's
color.</p>
<p>Default Value: <code>"[0.2,0.2,0.2]"</code></p>
<p><a name='H3DU.Material_diffuse'></a></p>
<h3>H3DU.Material#diffuse</h3>
<p>Diffusion color of this material (also called "albedo").
This is the generally perceived color of the material when
specular highlights are absent on the material's surface.
See also <a href="H3DU.PbrMaterial.html#H3DU.PbrMaterial_albedo">H3DU.PbrMaterial#albedo</a>; this property corresponds
more closely to that in the metallic workflow rather than the specular
workflow.</p>
<p>Type: Array.<number></p>
<p>Default Value: <code>"[1,1,1,1]"</code></p>
<p><a name='H3DU.Material_emission'></a></p>
<h3>H3DU.Material#emission</h3>
<p>Additive color emitted by objects with this material.
See <a href="H3DU.PbrMaterial.html#H3DU.PbrMaterial_emission">H3DU.PbrMaterial#emission</a>.</p>
<p>Type: Array.<number></p>
<p>Default Value: <code>"[0,0,0]"</code></p>
<p><a name='H3DU.Material_emissionMap'></a></p>
<h3>H3DU.Material#emissionMap</h3>
<p>Emission map texture. See <a href="H3DU.PbrMaterial.html#H3DU.PbrMaterial_emissionMap">H3DU.PbrMaterial#emissionMap</a>.</p>
<p>Type: <a href="H3DU.Texture.html">H3DU.Texture</a> | <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> | <a href="H3DU.FrameBufferInfo.html">H3DU.FrameBufferInfo</a></p>
<p>Default Value: <code>null</code></p>
<p><a name='H3DU.Material_normalMap'></a></p>
<h3>H3DU.Material#normalMap</h3>
<p>Normal map (bump map) texture. See <a href="H3DU.PbrMaterial.html#H3DU.PbrMaterial_normalMap">H3DU.PbrMaterial#normalMap</a>.</p>
<p>Type: <a href="H3DU.Texture.html">H3DU.Texture</a> | <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> | <a href="H3DU.FrameBufferInfo.html">H3DU.FrameBufferInfo</a></p>
<p>Default Value: <code>null</code></p>
<p><a name='H3DU.Material_occlusionMap'></a></p>
<h3>H3DU.Material#occlusionMap</h3>
<p>Ambient occlusion map texture.
See <a href="H3DU.PbrMaterial.html#H3DU.PbrMaterial_occlusionMap">H3DU.PbrMaterial#occlusionMap</a>.</p>
<p>Type: <a href="H3DU.Texture.html">H3DU.Texture</a> | <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> | <a href="H3DU.FrameBufferInfo.html">H3DU.FrameBufferInfo</a></p>
<p>Default Value: <code>null</code></p>
<p><a name='H3DU.Material_shader'></a></p>
<h3>H3DU.Material#shader</h3>
<p>Shader program to use when rendering objects with this material.</p>
<p>Default Value: <code>null</code></p>
<p><a name='H3DU.Material_shininess'></a></p>
<h3>H3DU.Material#shininess</h3>
<p>Specular highlight exponent of this material.
The greater the number, the more concentrated the specular
highlights are (and the smoother the material behaves).
The lower the number, the more extended the highlights are (and the rougher the material behaves).
Ranges from 0 through 128.</p>
<p>Default Value: <code>32</code></p>
<p><a name='H3DU.Material_specular'></a></p>
<h3>H3DU.Material#specular</h3>
<p>Specular highlight reflection of this material.
This is usually a shade of gray (all three components are the same),
but can be colored if the material represents an uncoated metal of some sort.
See also <a href="H3DU.PbrMaterial.html#H3DU.PbrMaterial_specular">H3DU.PbrMaterial#specular</a>.
NOTE: Before version 2.0, this value's default was (0,0,0).</p>
<p>Type: Array.<number></p>
<p>Default Value: <code>"[0.2,0.2,0.2]"</code></p>
<p><a name='H3DU.Material_specularMap'></a></p>
<h3>H3DU.Material#specularMap</h3>
<p>Specular map texture.
See <a href="H3DU.PbrMaterial.html#H3DU.PbrMaterial_specularMap">H3DU.PbrMaterial#specularMap</a>.
NOTE: If this property specifies a texture, this property will be used
for the specular reflection rather than the "specular" property. This behavior
is a change from versions earlier than 2.0, where this property, if present,
multiplied the value of the "specular" property.</p>
<p>Type: <a href="H3DU.Texture.html">H3DU.Texture</a> | <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> | <a href="H3DU.FrameBufferInfo.html">H3DU.FrameBufferInfo</a></p>
<p>Default Value: <code>null</code></p>
<p><a name='H3DU.Material_texture'></a></p>
<h3>H3DU.Material#texture</h3>
<p>Texture for this material. Each color in the texture
sets the diffusion (also called "albedo")
of each part of the material.</p>
<p>Type: <a href="H3DU.Texture.html">H3DU.Texture</a> | <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> | <a href="H3DU.FrameBufferInfo.html">H3DU.FrameBufferInfo</a></p>
<p>Default Value: <code>null</code></p>
<p><a name='H3DU.Material_copy'></a></p>
<h3>H3DU.Material#copy()</h3>
<p>Clones this object's parameters to a new H3DU.Material
object and returns that object. The material's texture
maps and shader info, if any, won't be cloned, but rather, a reference
to the same object will be used.</p>
<h4>Return Value</h4>
<p>A copy of this object. (Type: <a href="H3DU.Material.html">H3DU.Material</a>)</p>
<p><a name='H3DU.Material.fromBasic'></a></p>
<h3>(static) H3DU.Material.fromBasic()</h3>
<p>Creates a material with its emission color set to the specified color.
The effect will be that objects with that material will be drawn in that
color without shading.</p>
<h4>Return Value</h4>
<p>A new material with the specified emission color. (Type: <a href="H3DU.Material.html">H3DU.Material</a>)</p>
<p><a name='H3DU.Material.fromBasicTexture'></a></p>
<h3>(static) H3DU.Material.fromBasicTexture()</h3>
<p>Creates a material with its emission texture set to the specified texture.
The effect will be that objects with that material will be drawn in that
texture without shading.</p>
<h4>Return Value</h4>
<p>A new material with the specified emission texture. (Type: <a href="H3DU.Material.html">H3DU.Material</a>)</p>
<p><a name='H3DU.Material.fromColor'></a></p>
<h3>(static) H3DU.Material.fromColor(r, g, b, [a])</h3>
<p>Convenience method that returns an <a href="H3DU.Material.html">H3DU.Material</a>
object from an RGBA color.</p>
<h4>Parameters</h4>
<ul>
<li><code>r</code> (Type: Array.<number> | number | string)<br>A <a href="H3DU.html#H3DU.toGLColor">color vector or string</a>, or the red color component (0-1).</li>
<li><code>g</code> (Type: number)<br>Green color component (0-1). May be null or omitted if a string or array is given as the "r" parameter.</li>
<li><code>b</code> (Type: number)<br>Blue color component (0-1). May be null or omitted if a string or array is given as the "r" parameter.</li>
<li><code>a</code> (Type: number) (optional)<br>Alpha color component (0-1). If the "r" parameter is given and this parameter is null, undefined, or omitted, this value is treated as 1.0.</li>
</ul>
<h4>Return Value</h4>
<p>The resulting material object. (Type: <a href="H3DU.Material.html">H3DU.Material</a>)</p>
<p><a name='H3DU.Material.fromTexture'></a></p>
<h3>(static) H3DU.Material.fromTexture(texture)</h3>
<p>Convenience method that returns an <a href="H3DU.Material.html">H3DU.Material</a>
object from a texture to apply to a 3D object's surface.</p>
<h4>Parameters</h4>
<ul>
<li><code>texture</code> (Type: <a href="H3DU.Texture.html">H3DU.Texture</a> | <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> | string)<br>An <a href="H3DU.Texture.html">H3DU.Texture</a> object, an <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> object, or a string with the URL of the texture data. In the case of a string the texture will be loaded via the JavaScript DOM's Image class. However, this method will not load that image yet.</li>
</ul>
<h4>Return Value</h4>
<p>The resulting material object. (Type: <a href="H3DU.Material.html">H3DU.Material</a>)</p>
<p><a name='H3DU.Material_setParams'></a></p>
<h3>H3DU.Material#setParams(params)</h3>
<p>Sets parameters for this material object.</p>
<h4>Parameters</h4>
<ul>
<li><code>params</code> (Type: Object)<br>An object whose keys have the possibilities given later, and whose values are those allowed for each key.<ul> <li><code>ambient</code> - A <a href="H3DU.html#H3DU.toGLColor">color vector or string</a> giving the ambient color. (See <a href="H3DU.Material.html#H3DU.Material_ambient">H3DU.Material#ambient</a>.) The default is (0.2, 0.2, 0.2). <li><code>diffuse</code> - A <a href="H3DU.html#H3DU.toGLColor">color vector or string</a> giving the diffusion color (also called "albedo"). (See <a href="H3DU.Material.html#H3DU.Material_diffuse">H3DU.Material#diffuse</a>.) The default is (0.8, 0.8, 0.8). <li><code>specular</code> - A <a href="H3DU.html#H3DU.toGLColor">color vector or string</a> giving the specular reflection. (See <a href="H3DU.Material.html#H3DU.Material_specular">H3DU.Material#specular</a>.) The default is (0,0,0), meaning no specular highlights. <li><code>shininess</code> - Specular reflection exponent. (See <a href="H3DU.Material.html#H3DU.Material_shininess">H3DU.Material#shininess</a>). Ranges from 0 through 128. The default is 0. <li><code>emission</code> - A <a href="H3DU.html#H3DU.toGLColor">color vector or string</a> giving the additive color. (See <a href="H3DU.Material.html#H3DU.Material_emission">H3DU.Material#emission</a>.) If this is an array, its numbers can range from -1 to 1. The default is (0,0,0). <li><code>texture</code> - <a href="H3DU.Texture.html">H3DU.Texture</a> object, <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> object, <a href="H3DU.FrameBufferInfo.html">H3DU.FrameBufferInfo</a> object, ora string with the URL of the texture to use. Can be null. <li><code>specularMap</code> - Specular map texture, taking the same types as the "texture" parameter (see <a href="H3DU.Material.html#H3DU.Material_specularMap">H3DU.Material#specularMap</a>). Can be null. <li><code>normalMap</code> - Normal map texture, taking the same types as the "texture" parameter (see <a href="H3DU.Material.html#H3DU.Material_normalMap">H3DU.Material#normalMap</a>). Can be null. <li><code>occlusionMap</code> - Ambient occlusion map texture, taking the same types as the "texture" parameter (see <a href="H3DU.Material.html#H3DU.Material_occlusionMap">H3DU.Material#occlusionMap</a>). Can be null. <li><code>emissionMap</code> - Emission map texture, taking the same types as the "texture" parameter (see <a href="H3DU.Material.html#H3DU.Material_emissionMap">H3DU.Material#emissionMap</a>). Can be null. <li><code>shader</code> - <a href="H3DU.ShaderInfo.html">H3DU.ShaderInfo</a> object for a WebGL shader program to use when rendering objects with this material. <i>Using <a href="H3DU.ShaderProgram.html">H3DU.ShaderProgram</a> objects in this parameter is obsolete.</i> </ul> Any or all of these keys can exist in the parameters object. If a value is null or undefined, it is ignored unless otherwise noted.</li>
</ul>
<h4>Return Value</h4>
<p>This object. (Type: <a href="H3DU.Material.html">H3DU.Material</a>)</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>
<p>
<a href="//twitter.com/share">Share via Twitter</a>, <a href="//www.facebook.com/sharer/sharer.php" id="sharer">Share via Facebook</a>
</p>
</div>
<h3>Navigation</h3>
<ul>
<li><a href="DrawingToy.html">DrawingToy</a></li>
<li><a href="Epitrochoid.html">Epitrochoid</a></li>
<li><a href="H3DU.html">H3DU</a></li>
<li><a href="H3DU.BSplineCurve.html">H3DU.BSplineCurve</a></li>
<li><a href="H3DU.BSplineSurface.html">H3DU.BSplineSurface</a></li>
<li><a href="H3DU.BufferAccessor.html">H3DU.BufferAccessor</a></li>
<li><a href="H3DU.Camera.html">H3DU.Camera</a></li>
<li><a href="H3DU.Curve.html">H3DU.Curve</a></li>
<li><a href="H3DU.CurveBuilder.html">H3DU.CurveBuilder</a></li>
<li><a href="H3DU.CurveTube.html">H3DU.CurveTube</a></li>
<li><a href="H3DU.GraphicsPath.html">H3DU.GraphicsPath</a></li>
<li><a href="H3DU.InputTracker.html">H3DU.InputTracker</a></li>
<li><a href="H3DU.MathUtil.html">H3DU.MathUtil</a></li>
<li><a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a></li>
<li><a href="H3DU.Meshes.html">H3DU.Meshes</a></li>
<li><a href="H3DU.PiecewiseCurve.html">H3DU.PiecewiseCurve</a></li>
<li><a href="H3DU.Shape.html">H3DU.Shape</a></li>
<li><a href="H3DU.ShapeGroup.html">H3DU.ShapeGroup</a></li>
<li><a href="H3DU.Surface.html">H3DU.Surface</a></li>
<li><a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a></li>
<li><a href="H3DU.TextFont.html">H3DU.TextFont</a></li>
<li><a href="H3DU.TextureAtlas.html">H3DU.TextureAtlas</a></li>
<li><a href="H3DU.Transform.html">H3DU.Transform</a></li>
<li><a href="Hypotrochoid.html">Hypotrochoid</a></li>
<li><a href="MatrixStack.html">MatrixStack</a></li>
<li><a href="Polyhedra.html">Polyhedra</a></li>
<li><a href="Promise.html">Promise</a></li>
<li><a href="Semantic.html">Semantic</a></li>
<li><a href="StarField.html">StarField</a></li>
<li><a href="Superellipsoid.html">Superellipsoid</a></li>
<li><a href="Supertoroid.html">Supertoroid</a></li>
<li><a href="SurfaceOfRevolution.html">SurfaceOfRevolution</a></li>
<li><a href="Trochoid.html">Trochoid</a></li>
<li><a href="curveCatacaustic.html">curveCatacaustic</a></li>
<li><a href="curveEvolute.html">curveEvolute</a></li>
<li><a href="curveInverse.html">curveInverse</a></li>
<li><a href="curveInvolute.html">curveInvolute</a></li>
<li><a href="curveOrthotomic.html">curveOrthotomic</a></li>
<li><a href="curvePedalCurve.html">curvePedalCurve</a></li>
<li><a href="curveRadialCurve.html">curveRadialCurve</a></li>
<li><a href="polarCurve.html">polarCurve</a></li>
<li><a href="ruledSurface.html">ruledSurface</a></li>
<li><a href="spiralCurve.html">spiralCurve</a></li>
</ul>
</nav>
</body></html>