diff --git a/web/app/app-init.js b/web/app/app-init.js
new file mode 100644
index 00000000..4801e743
--- /dev/null
+++ b/web/app/app-init.js
@@ -0,0 +1,79 @@
+ function start() {
+ var app = new TCAD.App2D();
+ app.loadFromLocalStorage();
+ var actionsWin = new TCAD.ui.Window($('#actions'));
+
+ TCAD.ui.bindOpening( $('#showActions'), actionsWin );
+ var addAction = TCAD.ui.createActionsWinBuilder(actionsWin);
+
+ for (var p = 0; p < app._actionsOrder.length; ++p) {
+ var act = app.actions[app._actionsOrder[p]];
+ addAction(act.desc, act.action);
+ $('.act-' + act.id).click(act.action).attr('title', act.desc);
+ }
+
+ function infoStr(c) {
+ if (c.SettableFields === undefined) return "";
+ var info = Object.keys(c.SettableFields).map(function(f) {
+ return Number(c[f]).toFixed(2);
+ }).join(", ");
+ if (info.length != 0) {
+ info = " [" + info + "]";
+ }
+ return info;
+ }
+
+ var pm = app.viewer.parametricManager;
+ var constrList = new TCAD.ui.List($('#constrs'), {
+ items : function() {
+ var theItems = [];
+ for (var j = 0; j < pm.subSystems.length; j++) {
+ var sub = pm.subSystems[j];
+ for (var i = 0; i < sub.constraints.length; ++i) {
+ var constr = sub.constraints[i];
+ if (constr.aux !== true) {
+ theItems.push({name : constr.UI_NAME + infoStr(constr), constr : constr});
+ }
+ }
+ }
+ return theItems;
+ },
+
+ remove : function(item) {
+ pm.remove(item.constr);
+ },
+
+ mouseleave : function(item) {
+ app.viewer.deselectAll();
+ app.viewer.refresh();
+ },
+
+ hover : function(item) {
+ app.viewer.select(item.constr.getObjects(), true);
+ app.viewer.refresh();
+ },
+
+ click : function(item) {
+ var c = item.constr;
+ if (c.SettableFields === undefined) return;
+ for (var f in c.SettableFields) {
+ var value = c[f];
+ var intro = c.SettableFields[f];
+ value = TCAD.TWO.utils.askNumber(intro, value.toFixed(4), prompt);
+ c[f] = value;
+ }
+ app.viewer.parametricManager.refresh();
+ }
+ });
+ app.viewer.parametricManager.listeners.push(function() {constrList.refresh()});
+ constrList.refresh();
+ }
+ window.___log = function(log) {
+ $('#log').append( " *****************
");
+ for (var i = 0; i < log.length; i++) {
+ $('#log').append( log[i] + "
");
+ }
+ };
+ window.onload = function() {
+ setTimeout(start, 0);
+ };
diff --git a/web/app/engine.js b/web/app/engine.js
index 02f89be5..2752c6a0 100644
--- a/web/app/engine.js
+++ b/web/app/engine.js
@@ -306,6 +306,7 @@ TCAD.geom.extrude = function(source, target) {
TCAD.geom.FACE_COUNTER = 0;
+/** @Constructor **/
TCAD.Solid = function(polygons, material) {
THREE.Geometry.call( this );
this.dynamic = true; //true by default
@@ -365,8 +366,11 @@ TCAD.Solid = function(polygons, material) {
this.mergeVertices();
};
-TCAD.Solid.prototype = Object.create( THREE.Geometry.prototype );
+if (typeof THREE !== "undefined") {
+ TCAD.Solid.prototype = Object.create( THREE.Geometry.prototype );
+}
+/** @Constructor **/
TCAD.SketchFace = function(solid, poly) {
var proto = poly.__face;
poly.__face = this;
@@ -388,8 +392,10 @@ TCAD.SketchFace = function(solid, poly) {
}
};
-TCAD.SketchFace.prototype.SKETCH_MATERIAL = new THREE.LineBasicMaterial({
- color: 0xFFFFFF, linewidth: 3});
+if (typeof THREE !== "undefined") {
+ TCAD.SketchFace.prototype.SKETCH_MATERIAL = new THREE.LineBasicMaterial({
+ color: 0xFFFFFF, linewidth: 3});
+}
TCAD.SketchFace.prototype.syncSketches = function(geom) {
var i;
diff --git a/web/app/sketcher/main2d.js b/web/app/sketcher/main2d.js
index 953b95f2..2692e452 100644
--- a/web/app/sketcher/main2d.js
+++ b/web/app/sketcher/main2d.js
@@ -213,7 +213,7 @@ TCAD.App2D.prototype.initSketchManager = function(data, ext) {
if (!localStorage.hasOwnProperty(name)) {
continue;
}
- if (name.startsWith(TCAD.STORAGE_PREFIX)) {
+ if (name.indexOf(TCAD.STORAGE_PREFIX) === 0) {
name = name.substring(TCAD.STORAGE_PREFIX.length);
}
theItems.push({name : name});