Skip to content

Commit 161f018

Browse files
committed
Address more TODOs; etc.
1 parent d24762c commit 161f018

18 files changed

+378
-174
lines changed

demos/bsp.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ BspTree.prototype._clipInternal = function(polygons) {
263263
return ret;
264264
};
265265
/**
266-
* TODO: Not documented yet.
267-
* @param {*} node
266+
* Clips the solid areas of another BSP tree out of this one.
267+
* @param {BspTree} node Another BSP tree.
268268
* @returns {BspTree} This object.
269269
* @memberof! BspTree#
270270
*/
@@ -316,8 +316,9 @@ BspTree.prototype._clipflip2 = function(other) {
316316
return this;
317317
};
318318
/**
319-
* TODO: Not documented yet.
320-
* @param {*} other
319+
* Generates a BSP tree that consists of the solid areas of
320+
* this tree or the given tree or both.
321+
* @param {BspTree} other The second BSP tree.
321322
* @returns {BspTree} The resulting tree.
322323
* @memberof! BspTree#
323324
*/
@@ -330,8 +331,9 @@ BspTree.prototype.union = function(other) {
330331
otherBsp._clipflip2(thisBsp).getPolygons()));
331332
};
332333
/**
333-
* TODO: Not documented yet.
334-
* @param {*} other
334+
* Generates a BSP tree that consists of the solid areas of
335+
* this tree that are not common to the given tree.
336+
* @param {BspTree} other The second BSP tree.
335337
* @returns {BspTree} The resulting tree.
336338
* @memberof! BspTree#
337339
*/
@@ -344,8 +346,9 @@ BspTree.prototype.difference = function(other) {
344346
otherBsp._clipflip2(thisBsp).getPolygons())).flip();
345347
};
346348
/**
347-
* TODO: Not documented yet.
348-
* @param {*} other
349+
* Generates a BSP tree that consists of the solid areas common
350+
* to both this tree and the given tree.
351+
* @param {BspTree} other The second BSP tree.
349352
* @returns {BspTree} The resulting tree.
350353
* @memberof! BspTree#
351354
*/
@@ -358,8 +361,9 @@ BspTree.prototype.intersection = function(other) {
358361
otherBsp.getPolygons())).flip();
359362
};
360363
/**
361-
* TODO: Not documented yet.
362-
* @param {*} other
364+
* Generates a BSP tree that consists of the solid areas of
365+
* this tree or the given tree but not both.
366+
* @param {BspTree} other The second BSP tree.
363367
* @returns {BspTree} The resulting tree.
364368
* @memberof! BspTree#
365369
*/

demos/gears.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
mesh.mode(H3DU.Mesh.QUAD_STRIP );
3535
var angleStep = H3DU.Math.PiTimes2 / teeth;
3636
var cosStep = Math.cos(angleStep);
37-
var sinStep = (angleStep>=0 && angleStep<6.283185307179586) ? (angleStep<=3.141592653589793 ? Math.sqrt(1.0-cosStep*cosStep) : -Math.sqrt(1.0-cosStep*cosStep)) : Math.sin(angleStep);
37+
var sinStep = angleStep >= 0 && angleStep < 6.283185307179586 ? angleStep <= 3.141592653589793 ? Math.sqrt(1.0 - cosStep * cosStep) : -Math.sqrt(1.0 - cosStep * cosStep) : Math.sin(angleStep);
3838
sinAngle = 0.0; // sin(0.0deg)
3939
cosAngle = 1.0; // cos(0.0deg)
4040
for(i = 0; i <= teeth; i++) {
@@ -55,7 +55,7 @@
5555
da = 2.0 * Math.PI / teeth / 4.0;
5656
angleStep = H3DU.Math.PiTimes2 / teeth;
5757
cosStep = Math.cos(angleStep);
58-
sinStep = (angleStep>=0 && angleStep<6.283185307179586) ? (angleStep<=3.141592653589793 ? Math.sqrt(1.0-cosStep*cosStep) : -Math.sqrt(1.0-cosStep*cosStep)) : Math.sin(angleStep);
58+
sinStep = angleStep >= 0 && angleStep < 6.283185307179586 ? angleStep <= 3.141592653589793 ? Math.sqrt(1.0 - cosStep * cosStep) : -Math.sqrt(1.0 - cosStep * cosStep) : Math.sin(angleStep);
5959
sinAngle = 0.0; // sin(0.0deg)
6060
cosAngle = 1.0; // cos(0.0deg)
6161
for(i = 0; i < teeth; i++) {

demos/picking.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,27 @@ function getIntersectionRayBox(ray, box) {
7373
];
7474
}
7575

76+
/* exported polygonToPlane */
77+
function polygonToPlane(polygon) {
78+
"use strict";
79+
if(polygon.length < 3) {
80+
return [0, 0, 0, 0, 0, 0];
81+
}
82+
var normal = H3DU.Math.vec3cross(polygon[0], polygon[1]);
83+
var centroid = H3DU.Math.vec3copy(polygon[0]);
84+
for(var i = 1; i < polygon.length; i++) {
85+
var nextIndex = i + 1 === polygon.length ? 0 : i + 1;
86+
H3DU.Math.vec3addInPlace(normal,
87+
H3DU.Math.vec3cross(polygon[i], polygon[nextIndex]));
88+
H3DU.Math.vec3addInPlace(centroid, polygon[i]);
89+
}
90+
H3DU.Math.vec3scaleInPlace(centroid, 1.0 / polygon.length);
91+
var plane = [
92+
normal[0], normal[1], normal[2],
93+
centroid[0], centroid[1], centroid[2]];
94+
return plane;
95+
}
96+
7697
function triangleToPlane(face) {
7798
"use strict";
7899
var ac = H3DU.Math.vec3sub(face[0], face[2]);

doc/H3DU.CubeMap.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<a name='H3DU.CubeMap'></a>
66
### H3DU.CubeMap(name)
77

8-
TODO: Not documented yet.
8+
A cube map, or a set of six textures forming the sides of a cube.
99

1010
#### Parameters
1111

12-
* `name` (Type: Array.&lt;(String|Texture)>)<br>
13-
An array of six elements, each of which is a URL of the texture data or the texture object itself. However, this constructor will not load those images yet. The six images are, in order, the image seen when looking toward the positive X axis, the negative X axis, positive Y, negative Y, positive Z, and negative Z.
12+
* `name` (Type: Array.&lt;(String|Texture|TextureInfo)>)<br>
13+
An array of six elements, each of which is a URL of the texture data or the texture object itself. However, this constructor will not load those images yet. The six texture are, in order, the texture seen when looking toward the positive X axis, the negative X axis, positive Y, negative Y, positive Z, and negative Z.
1414

1515
### Methods
1616

@@ -62,8 +62,8 @@ Sets a texture used by this cube map.
6262

6363
* `index` (Type: Number)<br>
6464
Texture index to set, from 0 through 5.
65-
* `texture` (Type: <a href="H3DU.Texture.md">H3DU.Texture</a> | String)<br>
66-
An <a href="H3DU.Texture.md">H3DU.Texture</a> object or a string with the URL of the texture data.
65+
* `texture` (Type: <a href="H3DU.Texture.md">H3DU.Texture</a> | <a href="H3DU.TextureInfo.md">H3DU.TextureInfo</a> | String)<br>
66+
An <a href="H3DU.Texture.md">H3DU.Texture</a> object, a texture information object, or a string with the URL of the texture data.
6767

6868
#### Return Value
6969

doc/H3DU.MeshBuffer.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ and points) composed by all shapes in this mesh.
2525
mesh buffer (or sets an
2626
existing attribute's information).
2727
* [setIndices](#H3DU.MeshBuffer_H3DU.MeshBuffer_setIndices)<br>Sets the array of vertex indices used by this mesh buffer.
28-
* [setPrimitiveType](#H3DU.MeshBuffer_H3DU.MeshBuffer_setPrimitiveType)<br>TODO: Not documented yet.
28+
* [setPrimitiveType](#H3DU.MeshBuffer_H3DU.MeshBuffer_setPrimitiveType)<br>Sets the type of graphics primitives stored in this mesh buffer.
2929
* [vertexCount](#H3DU.MeshBuffer_H3DU.MeshBuffer_vertexCount)<br>Gets the number of vertices in this mesh buffer
3030

3131
<a name='H3DU.MeshBuffer_H3DU.MeshBuffer_getBounds'></a>
@@ -128,15 +128,16 @@ This object. (Type: <a href="H3DU.MeshBuffer.md">H3DU.MeshBuffer</a>)
128128
<a name='H3DU.MeshBuffer_H3DU.MeshBuffer_setPrimitiveType'></a>
129129
### H3DU.MeshBuffer#setPrimitiveType(primType)
130130

131-
TODO: Not documented yet.
131+
Sets the type of graphics primitives stored in this mesh buffer.
132132

133133
#### Parameters
134134

135-
* `primType` (Type: *)
135+
* `primType` (Type: Number)<br>
136+
The primitive type, either <a href="H3DU.Mesh.md#H3DU.Mesh.TRIANGLES">H3DU.Mesh.TRIANGLES</a>, <a href="H3DU.Mesh.md#H3DU.Mesh.LINES">H3DU.Mesh.LINES</a>, or <a href="H3DU.Mesh.md#H3DU.Mesh.POINTS">H3DU.Mesh.POINTS</a>.
136137

137138
#### Return Value
138139

139-
Return value. (Type: *)
140+
This object. (Type: <a href="H3DU.MeshBuffer.md">H3DU.MeshBuffer</a>)
140141

141142
<a name='H3DU.MeshBuffer_H3DU.MeshBuffer_vertexCount'></a>
142143
### H3DU.MeshBuffer#vertexCount()

doc/H3DU.TextureLoader.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ to WebGL contexts.
1515
* [loadAndMapTexture](#H3DU.TextureLoader_H3DU.TextureLoader_loadAndMapTexture)<br>Loads the texture referred to in an array of URLs and
1616
uploads its texture data to a WebGL context.
1717
* [loadAndMapTexturesAll](#H3DU.TextureLoader_H3DU.TextureLoader_loadAndMapTexturesAll)<br>Loads one or more textures by their URL and uploads their data to a WebGL context.
18-
* [loadCubeMap](#H3DU.TextureLoader_H3DU.TextureLoader_loadCubeMap)<br>TODO: Not documented yet.
18+
* [loadCubeMap](#H3DU.TextureLoader_H3DU.TextureLoader_loadCubeMap)<br>Loads the textures described in a cube map.
1919
* [loadTexture](#H3DU.TextureLoader_H3DU.TextureLoader_loadTexture)<br>Loads a texture by its URL and stores its data.
2020
* [loadTexturesAll](#H3DU.TextureLoader_H3DU.TextureLoader_loadTexturesAll)<br>Loads the textures referred to in an array of URLs and
2121
stores their texture data.
@@ -89,12 +89,12 @@ resolves, each item in the resulting array will be a loaded
8989
<a name='H3DU.TextureLoader_H3DU.TextureLoader_loadCubeMap'></a>
9090
### H3DU.TextureLoader#loadCubeMap(texturesOrCubeMap, [resolve], [reject])
9191

92-
TODO: Not documented yet.
92+
Loads the textures described in a cube map.
9393

9494
#### Parameters
9595

9696
* `texturesOrCubeMap` (Type: Array.&lt;(String|<a href="H3DU.TextureInfo.md">H3DU.TextureInfo</a>|<a href="H3DU.Texture.md">H3DU.Texture</a>)> | <a href="H3DU.CubeMap.md">H3DU.CubeMap</a>)<br>
97-
TODO: Not documented yet
97+
Either an array of objects described in H3DU.TextureLoader.loadTexture or a cube map object.
9898
* `resolve` (Type: function) (optional)<br>
9999
A function called as each individual texture is loaded and its promise resolves.
100100
* `reject` (Type: function) (optional)<br>

doc/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* <a href="Epitrochoid.md">Epitrochoid</a><br><b>Deprecated: Use <a href="H3DU.Epitrochoid.md">H3DU.Epitrochoid</a> instead.</b>
66
* <a href="FrameCounter.md">FrameCounter</a><br><b>Deprecated: Use <a href="H3DU.FrameCounter.md">H3DU.FrameCounter</a> instead.</b>
77
* <a href="FrameCounterDiv.md">FrameCounterDiv</a><br><b>Deprecated: Use <a href="H3DU.FrameCounterDiv.md">H3DU.FrameCounterDiv</a> instead.</b>
8+
* <a href="GraphicsPath.md">GraphicsPath</a><br><b>Deprecated: Use <a href="H3DU.GraphicsPath.md">H3DU.GraphicsPath</a> instead.</b>
89
* <a href="H3DU.md">H3DU</a><br>The Public Domain HTML 3D Library contains classes and utility
910
methods to ease the development of HTML 3D applications, such
1011
as Web sites, in browsers that support 3D drawing using the HTML5 Canvas.
@@ -18,7 +19,7 @@ Use the <a href="H3DU.MeshBuffer.md">H3DU.MeshBuffer</a> class instead, which is
1819
contexts.</b>
1920
* <a href="H3DU.Camera.md">H3DU.Camera</a><br>A class for controlling the projection and
2021
view of a 3D scene, in the nature of an abstract "camera".
21-
* <a href="H3DU.CubeMap.md">H3DU.CubeMap</a><br>TODO: Not documented yet.
22+
* <a href="H3DU.CubeMap.md">H3DU.CubeMap</a><br>A cube map, or a set of six textures forming the sides of a cube.
2223
* <a href="H3DU.CurveEval.md">H3DU.CurveEval</a><br>An evaluator of parametric curve functions for generating
2324
vertex positions and colors of a curve.
2425
* <a href="H3DU.CurveTube.md">H3DU.CurveTube</a><br>Evaluator for a parametric surface in the form
@@ -32,6 +33,7 @@ contexts.</b>
3233
* <a href="H3DU.FrameBufferInfo.md">H3DU.FrameBufferInfo</a><br>Describes a frame buffer.
3334
* <a href="H3DU.FrameCounter.md">H3DU.FrameCounter</a><br>A class for finding the frame rate of an HTML rendering.
3435
* <a href="H3DU.FrameCounterDiv.md">H3DU.FrameCounterDiv</a><br>A class that displays a frame counter HTML element.
36+
* <a href="H3DU.GraphicsPath.md">H3DU.GraphicsPath</a><br>Represents a two-dimensional path.
3537
* <a href="H3DU.Hypotrochoid.md">H3DU.Hypotrochoid</a><br>Parametric evaluator for a
3638
curve drawn by a circle that rolls along the inside
3739
of another circle, whose position is fixed with a center of (0,0).

doc/tutorial-history.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ There are many, many changes to version 2.0.0-beta1 from version 1.5.1. Here are
3232
- The experimental 2D canvas renderer in _surfaces2d.html_, was abandoned.
3333
- Added `dispose` method to `H3DU.Scene3D`.
3434
- Added `createPointedStar` and `createLathe` methods to `H3DU.Meshes`.
35-
- Added `getBounds` and `toLinePath` methods to H3DU.GraphicsPath, an extra, as well
35+
- Added `getBounds` and `toLinePath` methods to <a href="H3DU.GraphicsPath.md">H3DU.GraphicsPath</a>, an extra, as well
3636
as an extra that adds methods that compute the intersection, difference, union, and XOR of two
3737
polygons. Path triangulation now supports polygons with holes.
3838
- The default light configuration is no lights when creating a <a href="H3DU.LightSource.md">H3DU.LightSource</a>. The exception, for compatibility purposes, is when using a <a href="H3DU.Scene3D.md">H3DU.Scene3D</a> without rendering a custom `Batch3D`, in which case the default is one light source with its default values.

doc/tutorial-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ Version 2.0.0-beta1:
394394
- The experimental 2D canvas renderer in _surfaces2d.html_, was abandoned.
395395
- Added `dispose` method to `H3DU.Scene3D`.
396396
- Added `createPointedStar` and `createLathe` methods to `H3DU.Meshes`.
397-
- Added `getBounds` and `toLinePath` methods to H3DU.GraphicsPath, an extra, as well
397+
- Added `getBounds` and `toLinePath` methods to <a href="H3DU.GraphicsPath.md">H3DU.GraphicsPath</a>, an extra, as well
398398
as an extra that adds methods that compute the intersection, difference, union, and XOR of two
399399
polygons. Path triangulation now supports polygons with holes.
400400
- The default light configuration is no lights when creating a <a href="H3DU.LightSource.md">H3DU.LightSource</a>. The exception, for compatibility purposes, is when using a <a href="H3DU.Scene3D.md">H3DU.Scene3D</a> without rendering a custom `Batch3D`, in which case the default is one light source with its default values.

doc/tutorial-paths.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ as well as closed figures made from several path segments.
2525
<a id=How_to_Use></a>
2626
## How to Use
2727

28-
2D paths are implemented in a class called `H3DU.GraphicsPath`, found in the file _extras/path.js_ in
28+
2D paths are implemented in a class called <a href="H3DU.GraphicsPath.md">`H3DU.GraphicsPath`</a>, found in the file _extras/path.js_ in
2929
the HTML 3D Library download. To use this class, you must include the script "extras/path.js",
3030
as in this example.
3131

@@ -56,7 +56,7 @@ lines, the "Q", "C", "S", and "T" commands create B&eacute;zier curves, the "A"
5656
creates elliptical arcs, and the "Z" command closes the path. If the letters are
5757
lower-cased, X and Y coordinates are relative to the current position.
5858

59-
For more information, see the H3DU.GraphicsPath.fromString method documentation.
59+
For more information, see the <a href="H3DU.GraphicsPath.md#H3DU.GraphicsPath.fromString">H3DU.GraphicsPath.fromString</a> method documentation.
6060
That method is also how you create a 2D path from an SVG path string, as in this
6161
example:
6262

0 commit comments

Comments
 (0)