Skip to content

Commit b37f144

Browse files
committed
move some Extras classes to the H3DU namespace; disallow H3DU.Texture in H3DU.Shape setMaterial method; add descriptions to doc summaries
1 parent ee8a285 commit b37f144

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2758
-1727
lines changed

build/publish.js

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,16 @@ function Doc(name) {
6666
this.methods = {};
6767
this.events = {};
6868
this.members = {};
69+
this.descriptions = {};
6970
this.name = name;
7071
this.getFileName = function() {
7172
return path.join(Doc.outputDir,
7273
Doc.typeToName(this.name));
7374
};
74-
this.getText = function() {
75+
this.getText = function(docs) {
7576
var entry = this.entry + this.constructorEntry;
7677
var keys;
77-
function memToIndex(mem, title) {
78+
function memToIndex(mem, title, docs) {
7879
if(Object.keys(mem).length > 0) {
7980
var indexStr = "### " + helper.htmlsafe(title) + "\n\n";
8081
Object.keys(mem).sort().forEach(function(name) {
@@ -83,16 +84,20 @@ function Doc(name) {
8384
if(hname.lastIndexOf("#") >= 0)
8485
hname = hname.substr(hname.lastIndexOf("#") + 1);
8586
var tname = "[" + helper.htmlsafe(hname) + "](#" + val[1] + ")";
87+
var tdesc = docs.descriptions[val[2]];
88+
if(tdesc) {
89+
tname += "<br>" + tdesc;
90+
}
8691
indexStr += "* " + tname + "\n";
8792
});
8893
return indexStr + "\n";
8994
} else {
9095
return "";
9196
}
9297
}
93-
entry += memToIndex(this.members, "Members");
94-
entry += memToIndex(this.events, "Events");
95-
entry += memToIndex(this.methods, "Methods");
98+
entry += memToIndex(this.members, "Members", docs);
99+
entry += memToIndex(this.events, "Events", docs);
100+
entry += memToIndex(this.methods, "Methods", docs);
96101
keys = Object.keys(this.members).sort();
97102
for(var i = 0;i < keys.length;i++) {
98103
entry += this.members[keys[i]][0];
@@ -133,13 +138,13 @@ function DocCollection() {
133138
return this.docs[parent];
134139
};
135140
this.addMethod = function(parent, name, entry, longname) {
136-
this.get(parent).methods[name] = [entry, Doc.toHash(longname)];
141+
this.get(parent).methods[name] = [entry, Doc.toHash(longname), longname];
137142
};
138143
this.addEvent = function(parent, name, entry, longname) {
139-
this.get(parent).events[name] = [entry, Doc.toHash(longname)];
144+
this.get(parent).events[name] = [entry, Doc.toHash(longname), longname];
140145
};
141146
this.addMember = function(parent, name, entry, longname) {
142-
this.get(parent).members[name] = [entry, Doc.toHash(longname)];
147+
this.get(parent).members[name] = [entry, Doc.toHash(longname), longname];
143148
};
144149
this.addConstructor = function(parent, entry) {
145150
this.get(parent).constructorEntry = entry;
@@ -152,13 +157,17 @@ function DocCollection() {
152157
// Write individual type files
153158
Object.keys(this.docs).forEach(function(doc) {
154159
fs.writeFileSync(that.docs[doc].getFileName(),
155-
normalizeLines(that.docs[doc].getText()), "utf8");
160+
normalizeLines(that.docs[doc].getText(that)), "utf8");
156161
});
157162
// Write index
158163
var indexStr = "# Documentation Index\n\n";
159164
Object.keys(this.typeNames).sort().forEach(function(name) {
160165
var tname = name;
161166
tname = helper.linkto(tname, helper.htmlsafe(tname));
167+
var tdesc = that.descriptions[name];
168+
if(tdesc) {
169+
tname += "<br>" + tdesc;
170+
}
162171
indexStr += "* " + tname + "\n";
163172
});
164173
indexStr += "\n";
@@ -226,6 +235,37 @@ function typeNames(nodes) {
226235
return names;
227236
}
228237

238+
function descriptions(nodes) {
239+
"use strict";
240+
var descriptions = {};
241+
nodes.forEach(function (node) {
242+
if(node.undocumented === true)return;
243+
if(node.access === "private") {
244+
return;
245+
}
246+
var desc = "";
247+
if(typeof node.deprecated !== "undefined" && node.deprecated !== null) {
248+
var dep = node.deprecated === true ? "Yes" : node.deprecated;
249+
desc = "<b>Deprecated: " + normspace(dep) + "</b>";
250+
} else if(node.kind === "class") {
251+
desc = normspace(node.classdesc || "") + " ";
252+
desc += normspace(node.description || "");
253+
// We only need the first "sentence" of the description
254+
desc = desc.replace(/\.\s+[\s\S]*$/, ".");
255+
} else {
256+
desc = normspace(node.description || "");
257+
// We only need the first "sentence" of the description
258+
desc = desc.replace(/\.\s+[\s\S]*$/, ".");
259+
}
260+
desc = desc.replace(/^\s+/, "");
261+
desc = desc.replace(/\s+$/, "");
262+
if(desc.length > 0) {
263+
descriptions[node.longname] = desc;
264+
}
265+
});
266+
return descriptions;
267+
}
268+
229269
function registerLinks(docCollection, nodes) {
230270
"use strict";
231271
nodes.forEach(function(node) {
@@ -402,14 +442,13 @@ function fillCollection(docCollection, nodes, parentlong) {
402442
exports.publish = function(input, o, t) {
403443
"use strict";
404444
helper.fileExtension = ".md";
405-
console.log(Object.keys(t));
406445
helper.setTutorials(t);
407446
var inputget = input().get();
408447
var docCollection = new DocCollection();
409448
docCollection.tutorials = t;
410449
docCollection.readme = o.readme;
450+
docCollection.descriptions = descriptions(inputget);
411451
docCollection.typeNames = typeNames(inputget);
412-
console.log(o.readme);
413452
registerLinks(docCollection, inputget);
414453
fillCollection(docCollection, inputget);
415454
docCollection.write();

demos/builtinshapes.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</p>
2929
<canvas id=canvas></canvas>
3030
<script id="demo">
31-
/* global Camera, FrameCounterDiv, H3DU, InputTracker */
31+
/* global FrameCounterDiv, H3DU */
3232
// <!--
3333
/*
3434
Written by Peter O. in 2015.
@@ -81,8 +81,8 @@
8181
var scene = new H3DU.Scene3D(document.getElementById("canvas"))
8282
.setClearColor("white");
8383
sub = new H3DU.Batch3D();
84-
var input = new InputTracker(document);
85-
var camera = new Camera(sub, 45, 1, 1000).setDistance(5)
84+
var input = new H3DU.InputTracker(document);
85+
var camera = new H3DU.Camera(sub, 45, 1, 1000).setDistance(5)
8686
.moveAngleVertical(-90);
8787
var xyz = new H3DU.ShapeGroup();
8888
var pc = new FrameCounterDiv();

demos/clock.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</p>
1717
<canvas id=canvas></canvas>
1818
<script id="demo">
19-
/* global Camera, FrameCounterDiv, H3DU, InputTracker */
19+
/* global FrameCounterDiv, H3DU */
2020
// <!--
2121
/*
2222
Written by Peter O. in 2015.
@@ -117,8 +117,8 @@
117117
.setClearColor("white")
118118
.cullFace(H3DU.Scene3D.BACK);
119119
var sub = new H3DU.Batch3D();
120-
var camera = new Camera(sub, 45, 1, 1000).setDistance(5);
121-
var input = new InputTracker(scene.getCanvas());
120+
var camera = new H3DU.Camera(sub, 45, 1, 1000).setDistance(5);
121+
var input = new H3DU.InputTracker(scene.getCanvas());
122122
var pc = new FrameCounterDiv();
123123
var clock = new ClockShape(sub);
124124
document.getElementById("colorsetting").addEventListener("change",

demos/curves.html

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<canvas id=canvas>
2020
</canvas>
2121
<script id="demo">
22-
/* global Camera, Epitrochoid, FrameCounterDiv, H3DU, Hypotrochoid, InputTracker, Trochoid, addLink, makeMesh, pushSettings */
22+
/* global FrameCounterDiv, H3DU, addLink, makeMesh, pushSettings */
2323
// <!--
2424
/*
2525
Written by Peter O. in 2015.
@@ -30,26 +30,6 @@
3030
at: http://peteroupc.github.io/
3131
*/
3232

33-
/*
34-
var Hypocycloid = {
35-
"create":function(outerRadius, innerRadius) {
36-
"use strict";
37-
return new Hypotrochoid(outerRadius, innerRadius, innerRadius);
38-
}
39-
};
40-
var Epicycloid = {
41-
"create":function(outerRadius, innerRadius) {
42-
"use strict";
43-
return new Epitrochoid(outerRadius, innerRadius, innerRadius);
44-
}
45-
};
46-
var HypocycloidSeal={create:function(radius,points) {
47-
return Hypocycloid.create(radius,radius/points);
48-
}}
49-
var EpicycloidSeal={create:function(radius,points) {
50-
return Epicycloid.create(radius,radius/points);
51-
}}
52-
*/
5333
var allsettings = {};
5434
function TorusKnot(p, q, outerRadius, innerRadius) {
5535
"use strict";
@@ -136,7 +116,7 @@
136116
"use strict";
137117
pushSettings(allsettings, function(allsettings) {
138118
return makeThinCurveMesh(
139-
new Hypotrochoid(
119+
new H3DU.Hypotrochoid(
140120
allsettings["ht-outer"],
141121
allsettings["ht-inner"],
142122
allsettings["ht-dist"]
@@ -152,7 +132,7 @@
152132
"use strict";
153133
pushSettings(allsettings, function(allsettings) {
154134
return makeThinCurveMesh(
155-
new Epitrochoid(
135+
new H3DU.Epitrochoid(
156136
allsettings["et-outer"],
157137
allsettings["et-inner"],
158138
allsettings["et-dist"]
@@ -168,7 +148,7 @@
168148
"use strict";
169149
pushSettings(allsettings, function(allsettings) {
170150
return makeThinCurveMesh(
171-
new Trochoid(
151+
new H3DU.Trochoid(
172152
allsettings["et-inner"],
173153
allsettings["et-dist"]
174154
));
@@ -181,10 +161,10 @@
181161
// Create the 3D scene; find the HTML canvas and pass it
182162
// to Scene3D.
183163
var scene = new H3DU.Scene3D(document.getElementById("canvas"));
184-
var input = new InputTracker(document);
164+
var input = new H3DU.InputTracker(document);
185165
scene.setClearColor("white");
186166
var sub = new H3DU.Batch3D();
187-
var camera = new Camera(sub, 45, 1, 100);
167+
var camera = new H3DU.Camera(sub, 45, 1, 100);
188168
camera.setDistance(5);
189169
var pc = new FrameCounterDiv();
190170
link0();

demos/curvesexpr.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</div>
3838
<canvas id=canvas></canvas>
3939
<script id="demo">
40-
/* global Camera, FrameCounterDiv, H3DU, InputTracker, addRange, getExpression, updateShape */
40+
/* global FrameCounterDiv, H3DU, addRange, getExpression, updateShape */
4141
// <!--
4242
/*
4343
Written by Peter O. in 2015.
@@ -230,11 +230,11 @@
230230
// Create the 3D scene; find the HTML canvas and pass it
231231
// to Scene3D.
232232
var scene = new H3DU.Scene3D(document.getElementById("canvas"));
233-
var input = new InputTracker(document);
233+
var input = new H3DU.InputTracker(document);
234234
scene.setClearColor("white");
235235
scene.cullFace(H3DU.Scene3D.FRONT);
236236
var sub = new H3DU.Batch3D();
237-
var camera = new Camera(sub, 45, 1, 100).setDistance(5);
237+
var camera = new H3DU.Camera(sub, 45, 1, 100).setDistance(5);
238238
var pc = new FrameCounterDiv();
239239
link0();
240240
sub.addShape(shapeGroup);

demos/implicit.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<div id="settings" style="position:absolute;left:0;top:3em"></div>
1717
<canvas id=canvas></canvas>
1818
<script id="demo">
19-
/* global Camera, FrameCounterDiv, H3DU, ImplicitSurface, InputTracker, addLink, input, pushSettings */
19+
/* global FrameCounterDiv, H3DU, ImplicitSurface, addLink, input, pushSettings */
2020
// <!--
2121
/*
2222
Written by Peter O. in 2015.
@@ -222,10 +222,10 @@
222222
// Create the 3D scene; find the HTML canvas and pass it
223223
// to Scene3D.
224224
var scene = new H3DU.Scene3D(document.getElementById("canvas"));
225-
var input = new InputTracker(document);
225+
var input = new H3DU.InputTracker(document);
226226
scene.setClearColor("white");
227227
var sub = new H3DU.Batch3D();
228-
var camera = new Camera(sub, 45, 1, 100);
228+
var camera = new H3DU.Camera(sub, 45, 1, 100);
229229
camera.setDistance(5);
230230
var pc = new FrameCounterDiv();
231231
link1();

demos/marchingdots.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<body>
1313
<canvas id=canvas></canvas>
1414
<script id="demo">
15-
/* global FrameCounterDiv, GraphicsPath, H3DU */
15+
/* global FrameCounterDiv, H3DU */
1616
// <!--
1717
/*
1818
Written by Peter O. in 2015.
@@ -25,7 +25,7 @@
2525

2626
// Path taken from a public domain SVG icon, which was
2727
// created by Jakub Steiner
28-
var path = GraphicsPath.fromString(
28+
var path = H3DU.GraphicsPath.fromString(
2929
"M 44.155643,23.75 C 44.155643,45.413332 45.663332,43.905643 24,43.905643 2.3366679,43.905643 3.8443565,45.413332 3.8443565,23.75 3.8443565,2.0866679 2.3366679,3.5943565 24,3.5943565 c 21.663332,0 20.155643,-1.5076886 20.155643,20.1556435 z"
3030
);
3131
var curves = path.getCurves(0.2);

demos/obj.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Spot, a public domain model from Keenan Clark<br>
1919
</div>
2020
<script id="demo">
21-
/* global Camera, H3DU, InputTracker, ObjData, addLink */
21+
/* global H3DU, ObjData, addLink */
2222
// <!--
2323
/*
2424
Written by Peter O. in 2015.
@@ -35,8 +35,8 @@
3535
scene.setClearColor("white");
3636
var sub = new H3DU.Batch3D();
3737
var loader = new H3DU.TextureLoader();
38-
var camera = new Camera(sub, 45, 1, 1000).setDistance(5);
39-
var input = new InputTracker(document);
38+
var camera = new H3DU.Camera(sub, 45, 1, 1000).setDistance(5);
39+
var input = new H3DU.InputTracker(document);
4040
var startfunc = null;
4141
var shape = null;
4242
addLink("Toboggan", startfunc = function() {

demos/pathshapes.html

Lines changed: 4 additions & 4 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 Camera, CurveTube, FrameCounterDiv, GraphicsPath, H3DU, InputTracker */
26+
/* global CurveTube, FrameCounterDiv, H3DU */
2727
// <!--
2828
/*
2929
Written by Peter O. in 2015.
@@ -35,7 +35,7 @@
3535
*/
3636

3737
// Make a polygon with a hole
38-
var path = new GraphicsPath()
38+
var path = new H3DU.GraphicsPath()
3939
.moveTo(-1, 1, 0)
4040
.lineTo(0, 1)
4141
.arcTo(1, 1, 1, 0, 1)
@@ -138,9 +138,9 @@
138138
var scene = new H3DU.Scene3D(document.getElementById("canvas"));
139139
scene.setClearColor("white");
140140
sub = new H3DU.Batch3D();
141-
var camera = new Camera(sub, 45, 1, 1000).setDistance(5)
141+
var camera = new H3DU.Camera(sub, 45, 1, 1000).setDistance(5)
142142
.moveAngleVertical(-90);
143-
var input = new InputTracker(document);
143+
var input = new H3DU.InputTracker(document);
144144
var xyz = new H3DU.ShapeGroup();
145145
var pc = new FrameCounterDiv();
146146
shape = null;

demos/pathtube.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<body>
1515
<canvas id=canvas></canvas>
1616
<script id="demo">
17-
/* global FrameCounterDiv, GraphicsPath, H3DU */
17+
/* global FrameCounterDiv, H3DU */
1818
// <!--
1919
/*
2020
Written by Peter O. in 2015.
@@ -27,7 +27,7 @@
2727

2828
// Path taken from a public domain SVG icon, which was
2929
// created by Jakub Steiner
30-
var path = GraphicsPath.fromString(
30+
var path = H3DU.GraphicsPath.fromString(
3131
"M 44.155643,23.75 C 44.155643,45.413332 45.663332,43.905643 24,43.905643 2.3366679,43.905643 3.8443565,45.413332 3.8443565,23.75 3.8443565,2.0866679 2.3366679,3.5943565 24,3.5943565 c 21.663332,0 20.155643,-1.5076886 20.155643,20.1556435 z"
3232
);
3333
/* exported getPoints */

0 commit comments

Comments
 (0)