Skip to content

Commit 69e0171

Browse files
committed
edit docs; etc.
1 parent 2048e3a commit 69e0171

13 files changed

+444
-163
lines changed

demos/halfspace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function getIntersectingPoint(p1, p2, p3) {
1313
var n1 = p1.slice(0, 3);
1414
var n2 = p2.slice(0, 3);
1515
var n3 = p3.slice(0, 3);
16-
var d = H3DU.Math.vec3triple(n1, n2, n3);
16+
var d = H3DU.Math.vec3dot(n1, H3DU.Math.vec3cross(n2, n3));
1717
if(Math.abs(d) >= 1e-9) {
1818
var n12 = H3DU.Math.vec3cross(n1, n2);
1919
var n23 = H3DU.Math.vec3cross(n2, n3);

doc/H3DU.BufferAccessor.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# H3DU.BufferAccessor
2+
3+
[Back to documentation index.](index.md)
4+
5+
<a name='H3DU.BufferAccessor'></a>
6+
### H3DU.BufferAccessor(buffer, offset, countPerValue, [stride])
7+
8+
A <b>vertex attribute object</b>.
9+
10+
#### Parameters
11+
12+
* `buffer` (Type: Float32Array)<br>A buffer to store vertex attribute data; see <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_buffer">H3DU.BufferAccessor#buffer</a>.
13+
* `offset` (Type: number)<br>Offset to the first value; see <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_offset">H3DU.BufferAccessor#offset</a>. Throws an error if less than 0.
14+
* `countPerValue` (Type: number)<br>Number of elements per value; see <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_countPerValue">H3DU.BufferAccessor#countPerValue</a>. Throws an error if 0 or less.
15+
* `stride` (Type: number) (optional)<br>Number of elements from the start of one value to the start of the next; see <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_stride">H3DU.BufferAccessor#stride</a>. If null, undefined, or omitted, has the same value as "countPerValue". Throws an error if 0 or less.
16+
17+
### Members
18+
19+
* [buffer](#H3DU.BufferAccessor_buffer)<br>A <i>buffer</i> of arbitrary size.
20+
* [countPerValue](#H3DU.BufferAccessor_countPerValue)<br>A count of the number of elements each value has.
21+
* [offset](#H3DU.BufferAccessor_offset)<br>An offset, which identifies the index, starting from 0, of the first value
22+
of the attribute within the buffer.
23+
* [stride](#H3DU.BufferAccessor_stride)<br>A stride, which gives the number of elements from the start of one
24+
value to the start of the next.
25+
26+
### Methods
27+
28+
* [copy](#H3DU.BufferAccessor_copy)<br>Copies the values of this accessor into a new vertex attribute object.
29+
* [count](#H3DU.BufferAccessor_count)<br>Gets the number of <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_buffer">values</a> defined for this accessor.
30+
* [get](#H3DU.BufferAccessor_get)<br>Gets the first element of the attribute value with the given vertex index.
31+
* [getVec](#H3DU.BufferAccessor_getVec)<br>Gets the elements of a vertex attribute value.
32+
* [makeBlank](#H3DU.BufferAccessor.makeBlank)<br>Generates a vertex attribute buffer, with each value set to all zeros.
33+
* [set](#H3DU.BufferAccessor_set)<br>Sets the first element of the attribute value with the given vertex index.
34+
* [setVec](#H3DU.BufferAccessor_setVec)<br>Sets the elements of a vertex attribute value.
35+
36+
<a name='H3DU.BufferAccessor_buffer'></a>
37+
### H3DU.BufferAccessor#buffer
38+
39+
A <i>buffer</i> of arbitrary size. This buffer
40+
is made up of <i>values</i>, one for each vertex, and each value
41+
is takes up one or more <i>elements</i> in the buffer, which are numbers such
42+
as X coordinates or red components, depending on the attribute's semantic.
43+
Each value has the same number of elements. An example of a <i>value</i>
44+
is (10, 20, 5), which can take up three consecutive <i>elements</i>
45+
in a <code>Float32Array</code> buffer such as the one given in this
46+
property.
47+
48+
Type: Float32Array
49+
50+
<a name='H3DU.BufferAccessor_countPerValue'></a>
51+
### H3DU.BufferAccessor#countPerValue
52+
53+
A count of the number of elements each value has. For example, 3-dimensional
54+
positions will have 3 elements, one for each coordinate.
55+
56+
Type: number
57+
58+
<a name='H3DU.BufferAccessor_offset'></a>
59+
### H3DU.BufferAccessor#offset
60+
61+
An offset, which identifies the index, starting from 0, of the first value
62+
of the attribute within the buffer. The offset counts the number of
63+
elements in the buffer to the first value. For example, if this value is 6,
64+
then the first element of the first value in the buffer is found at
65+
<code>acc.buffer[acc.offset]</code> (assuming the buffer is
66+
more than 6 elements long).
67+
68+
Type: number
69+
70+
<a name='H3DU.BufferAccessor_stride'></a>
71+
### H3DU.BufferAccessor#stride
72+
73+
A stride, which gives the number of elements from the start of one
74+
value to the start of the next. A "packed" buffer will have a stride
75+
equal to the <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_countPerValue">count per value</a>.
76+
77+
Type: number
78+
79+
<a name='H3DU.BufferAccessor_copy'></a>
80+
### H3DU.BufferAccessor#copy()
81+
82+
Copies the values of this accessor into a new vertex attribute object.
83+
84+
#### Return Value
85+
86+
A copy of the vertex attribute object. (Type: <a href="H3DU.BufferAccessor.md">H3DU.BufferAccessor</a>)
87+
88+
<a name='H3DU.BufferAccessor_count'></a>
89+
### H3DU.BufferAccessor#count()
90+
91+
Gets the number of <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_buffer">values</a> defined for this accessor.
92+
93+
#### Return Value
94+
95+
The number of values defined in this accessor's buffer. (Type: number)
96+
97+
<a name='H3DU.BufferAccessor_get'></a>
98+
### H3DU.BufferAccessor#get(index)
99+
100+
Gets the first element of the attribute value with the given vertex index.
101+
102+
Note that currently, this method does no bounds checking beyond the
103+
checking naturally done when accessing the attribute's buffer.
104+
105+
#### Parameters
106+
107+
* `index` (Type: number)<br>A numeric index, starting from 0, that identifies a value stored in the attribute's buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.
108+
109+
#### Return Value
110+
111+
The first element of the given attribute value. (Type: number)
112+
113+
<a name='H3DU.BufferAccessor_getVec'></a>
114+
### H3DU.BufferAccessor#getVec(index, vec)
115+
116+
Gets the elements of a vertex attribute value.
117+
118+
Note that currently, this method does no bounds checking beyond the
119+
checking naturally done when accessing the attribute's buffer.
120+
121+
#### Parameters
122+
123+
* `index` (Type: number)<br>A numeric index, starting from 0, that identifies a value stored in the attribute's buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.
124+
* `vec` (Type: Array.&lt;number>)<br>An array whose elements will be set to those of the value at the given index. The number of elements copied to this array is the attribute's count per value (see <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_countPerValue">H3DU.BufferAccessor#countPerValue</a>).
125+
126+
#### Return Value
127+
128+
The parameter "vec". (Type: Array.&lt;number>)
129+
130+
<a name='H3DU.BufferAccessor.makeBlank'></a>
131+
### (static) H3DU.BufferAccessor.makeBlank(count, countPerValue)
132+
133+
Generates a vertex attribute buffer, with each value set to all zeros.
134+
135+
#### Parameters
136+
137+
* `count` (Type: number)<br>The number of <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_buffer">values</a> the buffer will hold. For example, (10, 20, 5) is a 3-element value.
138+
* `countPerValue` (Type: number)<br>The number of elements each value will take in the buffer.
139+
140+
#### Return Value
141+
142+
A blank vertex attribute buffer. (Type: <a href="H3DU.BufferAccessor.md">H3DU.BufferAccessor</a>)
143+
144+
<a name='H3DU.BufferAccessor_set'></a>
145+
### H3DU.BufferAccessor#set(index, value)
146+
147+
Sets the first element of the attribute value with the given vertex index.
148+
149+
Note that currently, this method does no bounds checking beyond the
150+
checking naturally done when writing to the attribute's buffer.
151+
152+
#### Parameters
153+
154+
* `index` (Type: number)<br>A numeric index, starting from 0, that identifies a value stored in the attribute's buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.
155+
* `value` (Type: number)<br>The number to set the first element to.
156+
157+
#### Return Value
158+
159+
This object. (Type: <a href="H3DU.BufferAccessor.md">H3DU.BufferAccessor</a>)
160+
161+
<a name='H3DU.BufferAccessor_setVec'></a>
162+
### H3DU.BufferAccessor#setVec(index, vec)
163+
164+
Sets the elements of a vertex attribute value.
165+
166+
Note that currently, this method does no bounds checking beyond the
167+
checking naturally done when writing to the attribute's buffer, except
168+
where noted otherwise.
169+
170+
#### Parameters
171+
172+
* `index` (Type: number)<br>A numeric index, starting from 0, that identifies a value stored in the attribute's buffer. For example, 0 identifies the first value, 1 identifies the second, and so on.
173+
* `vec` (Type: Array.&lt;number>)<br>An array containing the elements to copy to the value at the given index. The number of elements copied is this array's length or the attribute's count per value (see <a href="H3DU.BufferAccessor.md#H3DU.BufferAccessor_countPerValue">H3DU.BufferAccessor#countPerValue</a>), whichever is less.
174+
175+
#### Return Value
176+
177+
This object. (Type: <a href="H3DU.BufferAccessor.md">H3DU.BufferAccessor</a>)
178+
179+
[Back to documentation index.](index.md)

doc/H3DU.Material.md

Lines changed: 16 additions & 16 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").
2625
* [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,20 +46,6 @@ 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-
6349
<a name='H3DU.Material_ambient'></a>
6450
### H3DU.Material#ambient
6551

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

8571
Default Value: `"[0.2,0.2,0.2]"`
8672

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: `"[1,1,1,1]"`
86+
8787
<a name='H3DU.Material_emission'></a>
8888
### H3DU.Material#emission
8989

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

251251
#### Parameters
252252

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.
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 <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.
254254

255255
#### Return Value
256256

doc/H3DU.PiecewiseCurve.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ the piecewise curve.
2323

2424
* `curves` (Type: Array.&lt;Object>)<br>An array of curve evaluator objects, such as an instance of <a href="H3DU.Curve.md">H3DU.Curve</a> or one of its subclasses. The combined curve should be continuous in that the curves that make it up should connect at their end points (except the curve need not be closed).
2525

26+
#### Example
27+
28+
// Generates a piecewise polygon curve from an array of
29+
// vectors (arrays with the same number of elements) that
30+
// specify the points that make up the polygon.
31+
function polygonCurve(points) {
32+
var curves=[]
33+
for(var i=0;i<points.length;i++) {
34+
var cp=points[i]
35+
var np=(i==points.length-1) ? points[0] : points[i+1]
36+
curves.push(H3DU.BSplineCurve.fromBezierCurve([cp,np]))
37+
}
38+
return new H3DU.PiecewiseCurve(curves)
39+
}
40+
2641
### Methods
2742

2843
* [accel](#H3DU.PiecewiseCurve_accel)<br>Finds an approximate acceleration vector at the given U coordinate of this curve.

0 commit comments

Comments
 (0)