mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 01:44:19 +01:00
prepare for js compilation
This commit is contained in:
parent
5a9497a703
commit
f1e23e76e7
3 changed files with 89 additions and 4 deletions
79
web/app/app-init.js
Normal file
79
web/app/app-init.js
Normal file
|
|
@ -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 = " <span style='font-size: 8px;'>[" + info + "]</span>";
|
||||
}
|
||||
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( " *****************<br><br><br><br>");
|
||||
for (var i = 0; i < log.length; i++) {
|
||||
$('#log').append( log[i] + " <br>");
|
||||
}
|
||||
};
|
||||
window.onload = function() {
|
||||
setTimeout(start, 0);
|
||||
};
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
|
|
|
|||
Loading…
Reference in a new issue