Skip to content

Commit 2048e3a

Browse files
committed
address TODO; move more BufferHelper methods; again fix initial occlusion map implementation; fix bug in GraphicsPath.getCurves; change default base color; etc.
1 parent 161a0ed commit 2048e3a

20 files changed

+458
-483
lines changed

demos/implicit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
var mesh = new H3DU.Mesh();
7575
mesh.color3("blue");
7676
surf.evalSurface(mesh, 48, 48, 48, -5, 5, -5, 5, -5, 5);
77-
return new H3DU.MeshBuffer(mesh);
77+
return mesh.toMeshBuffer();
7878
}
7979

8080
var shapeGroup = new H3DU.ShapeGroup();

demos/pathshapes.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
.arcTo(0.5, 0.5, 0, 0.5, 0.5)
6060
.lineTo(-0.5, 0.5)
6161
.closePath().reverse();
62-
path = path.merge(path2); // TODO: Fix path tube
62+
path = path.merge(path2);
6363

6464
function makeLinePath(path, z, flatness) {
6565
"use strict";
@@ -69,7 +69,7 @@
6969
var line = lines[i];
7070
mesh.vertex3(line[0], line[1], z).vertex3(line[2], line[3], z);
7171
}
72-
return mesh;
72+
return mesh.toMeshBuffer();
7373
}
7474
function extrudePath(path, zStart, zEnd, flatness) {
7575
"use strict";
@@ -90,7 +90,7 @@
9090
.vertex3(line[2], line[3], z2)
9191
.vertex3(line[0], line[1], z2);
9292
}
93-
return new H3DU.MeshBuffer(mesh).recalcNormals();
93+
return mesh.toMeshBuffer().recalcNormals(true);
9494
}
9595
function pathClosedFigure(path, zBottom, zTop, flatness) {
9696
"use strict";
@@ -104,13 +104,13 @@
104104
"use strict";
105105
switch(index) {
106106
case 0:
107-
return pathFloor(path, 0, 0.01);
107+
return pathFloor(path, 0, 0.01);
108108
case 1:
109109
return extrudePath(path, -0.2, 0.2, 0.01);
110110
case 2:
111111
return pathClosedFigure(path, -0.25, 0.25, 0.01);
112112
case 3:
113-
return makeTubeFromPath(path, 0.01, 0.1);
113+
return makeTubeFromPath(path, 0.01, 0.1);
114114
case 4: {
115115
var p = new H3DU.GraphicsPath().regularPolygon(0, 0, 8, 1);
116116
return pathClosedFigure(p, -0.25, 0.25, 0.01);

doc/H3DU.BufferHelper.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,9 @@ A helper class for accessing and setting data in vertex attributes.
99

1010
### Methods
1111

12-
* [copy](#H3DU.BufferHelper_copy)<br>Copies the values of a vertex attribute into a new vertex attribute object.
1312
* [makeIndices](#H3DU.BufferHelper_makeIndices)<br>Generates an array of increasing vertex indices
1413
* [merge](#H3DU.BufferHelper_merge)<br>Merges two vertex attributes, whose vertices can be indexed differently, into one
1514
combined vertex attribute.
16-
* [resolveSemantic](#H3DU.BufferHelper_resolveSemantic)<br>Resolves an attribute semantic and semantic index, which
17-
may optionally be given as a string instead, into two numbers giving
18-
the semantic and index.
19-
20-
<a name='H3DU.BufferHelper_copy'></a>
21-
### H3DU.BufferHelper#copy(attr)
22-
23-
Copies the values of a vertex attribute into a new vertex attribute object.
24-
25-
#### Parameters
26-
27-
* `attr` (Type: <a href="H3DU.BufferAccessor.md">H3DU.BufferAccessor</a>)<br>A vertex buffer accessor.
28-
29-
#### Return Value
30-
31-
A copy of the vertex attribute object. (Type: <a href="H3DU.BufferAccessor.md">H3DU.BufferAccessor</a>)
3215

3316
<a name='H3DU.BufferHelper_makeIndices'></a>
3417
### H3DU.BufferHelper#makeIndices(numIndices)
@@ -62,23 +45,4 @@ The merged attribute, where the vertices from the first vertex
6245
attribute come before those from the second. The merged attribute will have as many
6346
values as the sum of the lengths of "indices1" and "indices2". (Type: <a href="H3DU.BufferAccessor.md">H3DU.BufferAccessor</a>)
6447

65-
<a name='H3DU.BufferHelper_resolveSemantic'></a>
66-
### H3DU.BufferHelper#resolveSemantic(name, [index])
67-
68-
Resolves an attribute semantic and semantic index, which
69-
may optionally be given as a string instead, into two numbers giving
70-
the semantic and index.
71-
72-
#### Parameters
73-
74-
* `name` (Type: number | string)<br>An attribute semantic, such as <a href="H3DU.Semantic.md#H3DU.Semantic.POSITION">H3DU.Semantic.POSITION</a>, "POSITION", or "TEXCOORD_0". Throws an error if this value is a string and the string is invalid.
75-
* `index` (Type: number) (optional)<br>The set index of the attribute for the given semantic. 0 is the first index of the attribute, 1 is the second, and so on. This is ignored if "name" is a string. Otherwise, if this value is null, undefined, or omitted, the default is 0.
76-
77-
#### Return Value
78-
79-
A two-element array consisting
80-
of the semantic and semantic index, respectively, described in
81-
the "name" and "index" parameters. Returns null if "name" is a string,
82-
but doesn't describe a valid semantic. (Type: Array.&lt;number>)
83-
8448
[Back to documentation index.](index.md)

doc/H3DU.Material.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ the <a href="H3DU.Math.md#H3DU.Math.colorTosRGB">sRGB color space</a>.
2222

2323
### Members
2424

25+
* [albedo](#H3DU.Material_albedo)<br>Diffusion color of this material (also called "albedo").
2526
* [ambient](#H3DU.Material_ambient)<br>Ambient color of this material.
26-
* [diffuse](#H3DU.Material_diffuse)<br>Diffusion color of this material (also called "albedo").
2727
* [emission](#H3DU.Material_emission)<br>Additive color emitted by objects with this material.
2828
* [emissionMap](#H3DU.Material_emissionMap)<br>Emission map texture.
2929
* [normalMap](#H3DU.Material_normalMap)<br>Normal map (bump map) texture.
@@ -46,6 +46,20 @@ object from an RGBA color.
4646
object from a texture to apply to a 3D object's surface.
4747
* [setParams](#H3DU.Material_setParams)<br>Sets parameters for this material object.
4848

49+
<a name='H3DU.Material_albedo'></a>
50+
### H3DU.Material#albedo
51+
52+
Diffusion color of this material (also called "albedo").
53+
This is the generally perceived color of the material when
54+
specular highlights are absent on the material's surface.
55+
See also <a href="H3DU.PbrMaterial.md#H3DU.PbrMaterial_albedo">H3DU.PbrMaterial#albedo</a>; this property corresponds
56+
more closely to that in the metallic workflow rather than the specular
57+
workflow.
58+
59+
Type: Array.&lt;number>
60+
61+
Default Value: `"[1,1,1,1]"`
62+
4963
<a name='H3DU.Material_ambient'></a>
5064
### H3DU.Material#ambient
5165

@@ -70,20 +84,6 @@ color.
7084

7185
Default Value: `"[0.2,0.2,0.2]"`
7286

73-
<a name='H3DU.Material_diffuse'></a>
74-
### H3DU.Material#diffuse
75-
76-
Diffusion color of this material (also called "albedo").
77-
This is the generally perceived color of the material when
78-
specular highlights are absent on the material's surface.
79-
See also <a href="H3DU.PbrMaterial.md#H3DU.PbrMaterial_albedo">H3DU.PbrMaterial#albedo</a>; this property corresponds
80-
more closely to that in the metallic workflow rather than the specular
81-
workflow.
82-
83-
Type: Array.&lt;number>
84-
85-
Default Value: `"[0.8,0.8,0.8,1]"`
86-
8787
<a name='H3DU.Material_emission'></a>
8888
### H3DU.Material#emission
8989

@@ -97,7 +97,7 @@ Default Value: `"[0,0,0]"`
9797
<a name='H3DU.Material_emissionMap'></a>
9898
### H3DU.Material#emissionMap
9999

100-
Emission map texture.
100+
Emission map texture. See <a href="H3DU.PbrMaterial.md#H3DU.PbrMaterial_emissionMap">H3DU.PbrMaterial#emissionMap</a>.
101101

102102
Type: <a href="H3DU.Texture.md">H3DU.Texture</a> | <a href="H3DU.TextureInfo.md">H3DU.TextureInfo</a> | <a href="H3DU.FrameBufferInfo.md">H3DU.FrameBufferInfo</a>
103103

@@ -116,6 +116,7 @@ Default Value: `null`
116116
### H3DU.Material#occlusionMap
117117

118118
Ambient occlusion map texture.
119+
See <a href="H3DU.PbrMaterial.md#H3DU.PbrMaterial_occlusionMap">H3DU.PbrMaterial#occlusionMap</a>.
119120

120121
Type: <a href="H3DU.Texture.md">H3DU.Texture</a> | <a href="H3DU.TextureInfo.md">H3DU.TextureInfo</a> | <a href="H3DU.FrameBufferInfo.md">H3DU.FrameBufferInfo</a>
121122

@@ -249,7 +250,7 @@ Sets parameters for this material object.
249250

250251
#### Parameters
251252

252-
* `params` (Type: Object)<br>An object whose keys have the possibilities given below, and whose values are those allowed for each key.<ul> <li><code>ambient</code> - A <a href="H3DU.md#H3DU.toGLColor">color vector or string</a> giving the ambient color. (See <a href="H3DU.Material.md#H3DU.Material_ambient">H3DU.Material#ambient</a>.) The default is (0.2, 0.2, 0.2). <li><code>diffuse</code> - A <a href="H3DU.md#H3DU.toGLColor">color vector or string</a> giving the diffusion color (also called "albedo"). (See <a href="H3DU.Material.md#H3DU.Material_diffuse">H3DU.Material#diffuse</a>.) The default is (0.8, 0.8, 0.8). <li><code>specular</code> - A <a href="H3DU.md#H3DU.toGLColor">color vector or string</a> giving the specular reflection. (See <a href="H3DU.Material.md#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.md#H3DU.Material_shininess">H3DU.Material#shininess</a>). Ranges from 0 through 128. The default is 0. <li><code>emission</code> - A <a href="H3DU.md#H3DU.toGLColor">color vector or string</a> giving the additive color. (See <a href="H3DU.Material.md#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.md">H3DU.Texture</a> object, <a href="H3DU.TextureInfo.md">H3DU.TextureInfo</a> object, <a href="H3DU.FrameBufferInfo.md">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.md#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.md#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.md#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.md#H3DU.Material_emissionMap">H3DU.Material#emissionMap</a>). Can be null. <li><code>shader</code> - <a href="H3DU.ShaderInfo.md">H3DU.ShaderInfo</a> object for a WebGL shader program to use when rendering objects with this material. <i>Using <a href="H3DU.ShaderProgram.md">H3DU.ShaderProgram</a> objects in this parameter is deprecated.</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.
253+
* `params` (Type: Object)<br>An object whose keys have the possibilities given below, and whose values are those allowed for each key.<ul> <li><code>ambient</code> - A <a href="H3DU.md#H3DU.toGLColor">color vector or string</a> giving the ambient color. (See <a href="H3DU.Material.md#H3DU.Material_ambient">H3DU.Material#ambient</a>.) The default is (0.2, 0.2, 0.2). <li><code>diffuse</code> - A <a href="H3DU.md#H3DU.toGLColor">color vector or string</a> giving the diffusion color (also called "albedo"). (See H3DU.Material#diffuse.) The default is (0.8, 0.8, 0.8). <li><code>specular</code> - A <a href="H3DU.md#H3DU.toGLColor">color vector or string</a> giving the specular reflection. (See <a href="H3DU.Material.md#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.md#H3DU.Material_shininess">H3DU.Material#shininess</a>). Ranges from 0 through 128. The default is 0. <li><code>emission</code> - A <a href="H3DU.md#H3DU.toGLColor">color vector or string</a> giving the additive color. (See <a href="H3DU.Material.md#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.md">H3DU.Texture</a> object, <a href="H3DU.TextureInfo.md">H3DU.TextureInfo</a> object, <a href="H3DU.FrameBufferInfo.md">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.md#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.md#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.md#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.md#H3DU.Material_emissionMap">H3DU.Material#emissionMap</a>). Can be null. <li><code>shader</code> - <a href="H3DU.ShaderInfo.md">H3DU.ShaderInfo</a> object for a WebGL shader program to use when rendering objects with this material. <i>Using <a href="H3DU.ShaderProgram.md">H3DU.ShaderProgram</a> objects in this parameter is deprecated.</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.
253254

254255
#### Return Value
255256

doc/H3DU.PbrMaterial.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ the <a href="H3DU.Math.md#H3DU.Math.colorTosRGB">sRGB color space</a>.
2525
* [albedoMap](#H3DU.PbrMaterial_albedoMap)<br>A texture indicating the albedo (or base color) of each part of the texture,
2626
in the red, green, blue, and alpha channels.
2727
* [emission](#H3DU.PbrMaterial_emission)<br>Additive color emitted by objects with this material.
28-
* [emissionMap](#H3DU.PbrMaterial_emissionMap)<br>Emission map texture.
28+
* [emissionMap](#H3DU.PbrMaterial_emissionMap)<br>A texture where each pixel identifies the emission of that
29+
part of the texture, as specified in the texture's red, green, and blue channel.
2930
* [invertRoughness](#H3DU.PbrMaterial_invertRoughness)<br>If true, the roughness property is treated as a "glossiness" property,
3031
or 1 minus roughness, and the roughness map is treated as a "glossiness"
3132
map, or an inverted roughness map.
3233
* [metalness](#H3DU.PbrMaterial_metalness)<br>A value indicating whether objects described by this material are metals.
3334
* [metalnessMap](#H3DU.PbrMaterial_metalnessMap)<br>A texture indicating the metalness of each part of the texture,
3435
as specified in the texture's blue channel.
3536
* [normalMap](#H3DU.PbrMaterial_normalMap)<br>Normal map (bump map) texture.
36-
* [occlusionMap](#H3DU.PbrMaterial_occlusionMap)<br>Ambient occlusion map texture.
37+
* [occlusionMap](#H3DU.PbrMaterial_occlusionMap)<br>A texture where each pixel identifies the ambient occlusion of that
38+
part of the texture, as specified in the texture's red channel.
3739
* [roughness](#H3DU.PbrMaterial_roughness)<br>Describes the roughness of the surface described
3840
by this material.
3941
* [roughnessMap](#H3DU.PbrMaterial_roughnessMap)<br>A texture indicating the roughness of each part of the texture,
@@ -98,7 +100,7 @@ colors are used rather than this property to set the color defined here.
98100

99101
Type: Array.&lt;number>
100102

101-
Default Value: `"[0.8,0.8,0.8,1]"`
103+
Default Value: `"[1,1,1,1]"`
102104

103105
<a name='H3DU.PbrMaterial_albedoMap'></a>
104106
### H3DU.PbrMaterial#albedoMap
@@ -130,7 +132,10 @@ Default Value: `"[0,0,0]"`
130132
<a name='H3DU.PbrMaterial_emissionMap'></a>
131133
### H3DU.PbrMaterial#emissionMap
132134

133-
Emission map texture.
135+
A texture where each pixel identifies the emission of that
136+
part of the texture, as specified in the texture's red, green, and blue channel.
137+
If a texture is given, the emission found with this texture is multiplied by
138+
the value of the <a href="H3DU.PbrMaterial.md#H3DU.PbrMaterial_emission">H3DU.PbrMaterial#emission</a> property.
134139

135140
Type: <a href="H3DU.Texture.md">H3DU.Texture</a> | <a href="H3DU.TextureInfo.md">H3DU.TextureInfo</a> | <a href="H3DU.FrameBufferInfo.md">H3DU.FrameBufferInfo</a>
136141

@@ -216,7 +221,8 @@ Default Value: `null`
216221
<a name='H3DU.PbrMaterial_occlusionMap'></a>
217222
### H3DU.PbrMaterial#occlusionMap
218223

219-
Ambient occlusion map texture.
224+
A texture where each pixel identifies the ambient occlusion of that
225+
part of the texture, as specified in the texture's red channel.
220226

221227
Type: <a href="H3DU.Texture.md">H3DU.Texture</a> | <a href="H3DU.TextureInfo.md">H3DU.TextureInfo</a> | <a href="H3DU.FrameBufferInfo.md">H3DU.FrameBufferInfo</a>
222228

0 commit comments

Comments
 (0)