Skip to content

Commit ddf8ce2

Browse files
committed
Reduce use of global variables; add to release notes; fix mistake in commenting GLSL that kept earlier specular fix from working; change default shininess; etc.
1 parent 69cbe87 commit ddf8ce2

16 files changed

+275
-265
lines changed

demos/curves.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
addLink("Torus knot", link0 = function() {
7878
"use strict";
79-
pushSettings(allsettings, function(allsettings) {
79+
pushSettings(allsettings, shapeGroup, function(allsettings) {
8080
return makeMesh(
8181
new H3DU.CurveTube(new TorusKnot(
8282
allsettings["torusknot-p"],
@@ -90,7 +90,7 @@
9090

9191
addLink("Swept torus knot", function() {
9292
"use strict";
93-
pushSettings(allsettings, function(allsettings) {
93+
pushSettings(allsettings, shapeGroup, function(allsettings) {
9494
return makeMesh(
9595
new H3DU.CurveTube(new TorusKnot(
9696
allsettings["torusknot-p"],
@@ -104,7 +104,7 @@
104104

105105
addLink("Flattened torus knot", function() {
106106
"use strict";
107-
pushSettings(allsettings, function(allsettings) {
107+
pushSettings(allsettings, shapeGroup, function(allsettings) {
108108
return makeMesh(
109109
new H3DU.CurveTube(TorusKnot.getFlatCurve(
110110
allsettings["torusknot-p"]
@@ -114,7 +114,7 @@
114114

115115
addLink("Hypotrochoid", function() {
116116
"use strict";
117-
pushSettings(allsettings, function(allsettings) {
117+
pushSettings(allsettings, shapeGroup, function(allsettings) {
118118
return makeThinCurveMesh(
119119
new H3DU.Hypotrochoid(
120120
allsettings["ht-outer"],
@@ -130,7 +130,7 @@
130130

131131
addLink("Epitrochoid", function() {
132132
"use strict";
133-
pushSettings(allsettings, function(allsettings) {
133+
pushSettings(allsettings, shapeGroup, function(allsettings) {
134134
return makeThinCurveMesh(
135135
new H3DU.Epitrochoid(
136136
allsettings["et-outer"],
@@ -146,7 +146,7 @@
146146

147147
addLink("Trochoid", function() {
148148
"use strict";
149-
pushSettings(allsettings, function(allsettings) {
149+
pushSettings(allsettings, shapeGroup, function(allsettings) {
150150
return makeThinCurveMesh(
151151
new H3DU.Trochoid(
152152
allsettings["et-inner"],

demos/curvesexpr.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@
186186
"use strict";
187187
ranges.push(addRange(label, min, max, step, allsettings[name], function(val) {
188188
allsettings[name] = val;
189-
updateShape(updateMesh, allsettings);
189+
updateShape(updateMesh, allsettings, shapeGroup);
190190
}));
191191
}
192192
function validateListener(id, key) {
193193
"use strict";
194194
var func = function(e) {
195195
if(validateExpr(e.target.value)) {
196196
allsettings[key] = e.target.value;
197-
updateShape(updateMesh, allsettings);
197+
updateShape(updateMesh, allsettings, shapeGroup);
198198
}
199199
};
200200
allsettings[key] = document.getElementById(id).value;
@@ -206,7 +206,7 @@
206206
var func = function(e) {
207207
if(validateConst(e.target.value)) {
208208
allsettings[key] = e.target.value;
209-
updateShape(updateMesh, allsettings);
209+
updateShape(updateMesh, allsettings, shapeGroup);
210210
}
211211
};
212212
allsettings[key] = document.getElementById(id).value;
@@ -225,7 +225,7 @@
225225
for(i = 0;i < consts.length;i++) {
226226
validateConstListener(consts[i], ckeys[i]);
227227
}
228-
updateShape(updateMesh, allsettings);
228+
updateShape(updateMesh, allsettings, shapeGroup);
229229
}
230230
// Create the 3D scene; find the HTML canvas and pass it
231231
// to Scene3D.

demos/demoutil.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global H3DU, alert, shapeGroup */
1+
/* global H3DU, alert */
22
/* exported formulaEditorHelp */
33
function formulaEditorHelp() {
44
"use strict";
@@ -108,7 +108,7 @@ function saveString(string, type, filename) {
108108
document.body.removeChild(a);
109109
}
110110

111-
function updateShape(func, allsettings) {
111+
function updateShape(func, allsettings, shapeGroup) {
112112
"use strict";
113113
var settings = document.getElementById("settings-link");
114114
if(!settings) {
@@ -139,12 +139,12 @@ function updateShape(func, allsettings) {
139139
}
140140

141141
/* exported pushSettings */
142-
function pushSettings(allsettings, updateMeshFunc, settings) {
142+
function pushSettings(allsettings, shapeGroup, updateMeshFunc, settings) {
143143
"use strict";
144144
function settingOnChange(name, updateMeshFunc) {
145145
return function(val) {
146146
allsettings[name] = val;
147-
updateShape(updateMeshFunc, allsettings);
147+
updateShape(updateMeshFunc, allsettings, shapeGroup);
148148
};
149149
}
150150
var ranges = [];
@@ -164,7 +164,7 @@ function pushSettings(allsettings, updateMeshFunc, settings) {
164164
}
165165
}
166166
setRanges(ranges);
167-
updateShape(updateMeshFunc, allsettings);
167+
updateShape(updateMeshFunc, allsettings, shapeGroup);
168168
}
169169

170170
/* exported makeMesh */

demos/implicit.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
var link1 = null;
120120
addLink("Ellipsoid", link1 = function() {
121121
"use strict";
122-
pushSettings(allsettings, function(allsettings) {
122+
pushSettings(allsettings, shapeGroup, function(allsettings) {
123123
return makeImplicit(
124124
new Ellipsoid(
125125
allsettings["superel-x"],
@@ -135,7 +135,7 @@
135135

136136
addLink("Hyperboloid of One Sheet", function() {
137137
"use strict";
138-
pushSettings(allsettings, function(allsettings) {
138+
pushSettings(allsettings, shapeGroup, function(allsettings) {
139139
return makeImplicit(
140140
new HyperboloidOneSheet(
141141
allsettings["hyp1-x"],
@@ -150,7 +150,7 @@
150150
});
151151
addLink("Cylinder", function() {
152152
"use strict";
153-
pushSettings(allsettings, function(allsettings) {
153+
pushSettings(allsettings, shapeGroup, function(allsettings) {
154154
var cyl = new Cylinder(
155155
allsettings["cylinder-rad"]
156156
);
@@ -160,7 +160,7 @@
160160

161161
addLink("Union: Cylinder and sphere", function() {
162162
"use strict";
163-
pushSettings(allsettings, function(allsettings) {
163+
pushSettings(allsettings, shapeGroup, function(allsettings) {
164164
var cyl = new Cylinder(
165165
allsettings["cylinder-rad"]
166166
);
@@ -175,7 +175,7 @@
175175
});
176176
addLink("Intersection: Cylinder and sphere", function() {
177177
"use strict";
178-
pushSettings(allsettings, function(allsettings) {
178+
pushSettings(allsettings, shapeGroup, function(allsettings) {
179179
var cyl = new Cylinder(
180180
allsettings["cylinder-rad"]
181181
);
@@ -190,7 +190,7 @@
190190
});
191191
addLink("Cylinder minus sphere", function() {
192192
"use strict";
193-
pushSettings(allsettings, function(allsettings) {
193+
pushSettings(allsettings, shapeGroup, function(allsettings) {
194194
var cyl = new Cylinder(
195195
allsettings["cylinder-rad"]
196196
);
@@ -205,7 +205,7 @@
205205
});
206206
addLink("Sphere minus cylinder", function() {
207207
"use strict";
208-
pushSettings(allsettings, function(allsettings) {
208+
pushSettings(allsettings, shapeGroup, function(allsettings) {
209209
var cyl = new Cylinder(
210210
allsettings["cylinder-rad"]
211211
);

demos/pathshapes.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</p>
2424
<canvas id=canvas></canvas>
2525
<script id="demo">
26-
/* global CurveTube, H3DU */
26+
/* global H3DU */
2727
// <!--
2828
/*
2929
Written by Peter O. in 2015.
@@ -59,7 +59,7 @@
5959
var resolution = Math.ceil(curves.getLength() / flatness / 10);
6060
var curveSection = pathSection ? pathSection.getCurves(flatness) : null;
6161
new H3DU.SurfaceEval()
62-
.vertex(new CurveTube(curves, thickness, curveSection))
62+
.vertex(new H3DU.CurveTube(curves, thickness, curveSection))
6363
.setAutoNormal(true)
6464
.evalSurface(mesh, H3DU.Mesh.TRIANGLES, resolution,
6565
Math.ceil(2 * thickness / flatness));

demos/surfaces.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174

175175
addLink("Superellipsoid", link0 = function() {
176176
"use strict";
177-
pushSettings(allsettings, function(allsettings) {
177+
pushSettings(allsettings, shapeGroup, function(allsettings) {
178178
var surf = new Superellipsoid(
179179
allsettings["superel-x"],
180180
allsettings["superel-y"],
@@ -194,46 +194,46 @@
194194

195195
addLink("Klein bottle", function() {
196196
"use strict";
197-
pushSettings(allsettings, function() {
197+
pushSettings(allsettings, shapeGroup, function() {
198198
return makeMesh(
199199
new KleinBottle());
200200
}, {});
201201
});
202202
addLink("Surface of revolution for f(x) = sin x", function() {
203203
"use strict";
204-
pushSettings(allsettings, function() {
204+
pushSettings(allsettings, shapeGroup, function() {
205205
return makeMesh(H3DU.SurfaceOfRevolution.fromFunction(function(x) {
206206
return Math.sin(x);
207207
}, -Math.PI, Math.PI, [1, 0, 0]));
208208
}, {});
209209
});
210210
addLink("Surface of revolution for f(x) = x<sup>2</sup>", function() {
211211
"use strict";
212-
pushSettings(allsettings, function() {
212+
pushSettings(allsettings, shapeGroup, function() {
213213
return makeMesh(H3DU.SurfaceOfRevolution.fromFunction(function(x) {
214214
return x * x;
215215
}, -1, 1, [1, 0, 0]));
216216
}, {});
217217
});
218218
addLink("...for f(x) = x<sup>2</sup>+0.01", function() {
219219
"use strict";
220-
pushSettings(allsettings, function() {
220+
pushSettings(allsettings, shapeGroup, function() {
221221
return makeMesh(H3DU.SurfaceOfRevolution.fromFunction(function(x) {
222222
return x * x + 0.01;
223223
}, -1, 1, [1, 0, 0]));
224224
}, {});
225225
});
226226
addLink("Cylinder", function() {
227227
"use strict";
228-
pushSettings(allsettings, function() {
228+
pushSettings(allsettings, shapeGroup, function() {
229229
return makeMesh(H3DU.SurfaceOfRevolution.fromFunction(function() {
230230
return 1;
231231
}, -1, 1, [0, 1, 0]));
232232
}, {});
233233
});
234234
addLink("Cone", function() {
235235
"use strict";
236-
pushSettings(allsettings, function() {
236+
pushSettings(allsettings, shapeGroup, function() {
237237
return makeMesh(H3DU.SurfaceOfRevolution.fromFunction(function(x) {
238238
x += -1;
239239
return x / 2;
@@ -242,13 +242,13 @@
242242
});
243243
addLink("Torus as Surface of Revolution", function() {
244244
"use strict";
245-
pushSettings(allsettings, function() {
245+
pushSettings(allsettings, shapeGroup, function() {
246246
return makeMesh(H3DU.SurfaceOfRevolution.torus(1, 0.125));
247247
}, {});
248248
});
249249
addLink("M&ouml;bius-like strip", function() {
250250
"use strict";
251-
pushSettings(allsettings, function(allsettings) {
251+
pushSettings(allsettings, shapeGroup, function(allsettings) {
252252
return makeMesh(
253253
new MoebiusLikeStrip(
254254
allsettings["moeb-maj"],
@@ -264,7 +264,7 @@
264264

265265
addLink("Supertoroid", function() {
266266
"use strict";
267-
pushSettings(allsettings, function(allsettings) {
267+
pushSettings(allsettings, shapeGroup, function(allsettings) {
268268
return makeMesh(
269269
new Supertoroid(
270270
allsettings["superto-x"],
@@ -284,7 +284,7 @@
284284

285285
addLink("M&ouml;bius strip", function() {
286286
"use strict";
287-
pushSettings(allsettings, function(allsettings) {
287+
pushSettings(allsettings, shapeGroup, function(allsettings) {
288288
return makeMesh(
289289
new MoebiusStrip(
290290
allsettings["moeb2-r"],
@@ -299,7 +299,7 @@
299299
var bsplineSurf = null;
300300
addLink("B-Spline Surface", function() {
301301
"use strict";
302-
pushSettings(allsettings, function() {
302+
pushSettings(allsettings, shapeGroup, function() {
303303
var bspline = [];
304304
for(var i = 0;i <= 5;i++) {
305305
var c = [];

demos/surfacesexpr.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@
196196
"use strict";
197197
ranges.push(addRange(label, min, max, step, allsettings[name], function(val) {
198198
allsettings[name] = val;
199-
updateShape(updateMesh, allsettings);
199+
updateShape(updateMesh, allsettings, shapeGroup);
200200
}));
201201
}
202202
function validateListener(id, key) {
203203
"use strict";
204204
var func = function(e) {
205205
if(validateExpr(e.target.value)) {
206206
allsettings[key] = e.target.value;
207-
updateShape(updateMesh, allsettings);
207+
updateShape(updateMesh, allsettings, shapeGroup);
208208
}
209209
};
210210
allsettings[key] = document.getElementById(id).value;
@@ -216,7 +216,7 @@
216216
var func = function(e) {
217217
if(validateConst(e.target.value)) {
218218
allsettings[key] = e.target.value;
219-
updateShape(updateMesh, allsettings);
219+
updateShape(updateMesh, allsettings, shapeGroup);
220220
}
221221
};
222222
allsettings[key] = document.getElementById(id).value;
@@ -235,7 +235,7 @@
235235
for(i = 0;i < consts.length;i++) {
236236
validateConstListener(consts[i], ckeys[i]);
237237
}
238-
updateShape(updateMesh, allsettings);
238+
updateShape(updateMesh, allsettings, shapeGroup);
239239
}
240240

241241
// Create the 3D scene; find the HTML canvas and pass it

doc/H3DU.Material.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Specular highlight exponent of this material.
164164
The greater the number, the more concentrated the specular
165165
highlights are (and the smoother the material behaves).
166166
The lower the number, the more extended the highlights are (and the rougher the material behaves).
167-
Ranges from 0 through 128.
167+
Ranges from 0 through 128. Default is 32.
168168

169169
### H3DU.Material#specular <a id='H3DU.Material_specular'></a>
170170

doc/H3DU.Texture.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Specifies a texture, which can serve as image data applied to
1212
By default, texture coordinates go from (0,0) at the lower left corner
1313
to (1,1) at the upper right corner.
1414

15+
For best results, any textures to be used in WebGL should have
16+
width and height each equal to a power of 2, such as 2, 4, 8, 16,
17+
and 32.
18+
1519
#### Parameters
1620

1721
* `name` (Type: String)<br>

doc/tutorial-history.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ There are many, many changes to version 2.0.0-beta1 from version 1.5.1. Here ar
3535
as an extra that adds methods that compute the intersection, difference, union, and XOR of two
3636
polygons. Path triangulation now supports polygons with holes.
3737
- 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.
38+
- The default value for specular materials (<a href="H3DU.Material.md">H3DU.Material</a>) is now (0.1, 0.1, 0.1).
3839
- The Mesh class no longer supports multiple primitive types (lines, triangles, points). Using different modes that use the same primitive type (for example, TRIANGLE_FAN and QUAD_STRIP) in the same mesh is still supported.
3940
- Many of the tutorials were edited heavily to accommodate the new version. The `GraphicsPath` tutorial was added.
4041
- There were also numerous bug fixes.
42+
- A known issue: When using the <a href="H3DU.Camera.md">H3DU.Camera</a> in conjunction with the compatibility behavior of <a href="H3DU.Scene3D.md">H3DU.Scene3D</a>, only one side of the scene will appear lighted by default.
4143

4244
Version 1.5.1:
4345

0 commit comments

Comments
 (0)