mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-11 10:53:45 +01:00
refresh sketches button
This commit is contained in:
parent
07c4de0040
commit
b3560b726a
2 changed files with 40 additions and 10 deletions
|
|
@ -13,6 +13,8 @@ TCAD.UI = function(app) {
|
|||
actionsF.add(actions.tools, 'extrude');
|
||||
actionsF.add(actions.tools, 'cut');
|
||||
actionsF.add(actions.tools, 'edit');
|
||||
actionsF.add(actions.tools, 'save');
|
||||
actionsF.add(actions.tools, 'refreshSketches');
|
||||
actionsF.open();
|
||||
|
||||
// var propsF = gui.addFolder('Properties');
|
||||
|
|
@ -33,7 +35,24 @@ TCAD.UI.Actions = function(scope) {
|
|||
|
||||
edit : function() {
|
||||
scope.app.sketchFace();
|
||||
},
|
||||
|
||||
save : function() {
|
||||
scope.app.save();
|
||||
},
|
||||
|
||||
refreshSketches : function() {
|
||||
scope.app.refreshSketches();
|
||||
},
|
||||
|
||||
undo : function() {
|
||||
scope.app.undo();
|
||||
},
|
||||
|
||||
redo : function() {
|
||||
scope.app.redo();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,16 +10,7 @@ TCAD.App = function() {
|
|||
|
||||
var box = TCAD.utils.createSolidMesh(TCAD.utils.createBox(500));
|
||||
this.viewer.scene.add( box );
|
||||
for (var i = 0; i < box.geometry.polyFaces.length; i++) {
|
||||
var sketchFace = box.geometry.polyFaces[i];
|
||||
var faceStorageKey = this.faceStorageKey(sketchFace.id);
|
||||
|
||||
var savedFace = localStorage.getItem(faceStorageKey);
|
||||
if (savedFace != null) {
|
||||
var geom = TCAD.workbench.readSketchGeom(JSON.parse(savedFace));
|
||||
sketchFace.syncSketches(geom);
|
||||
}
|
||||
}
|
||||
this._refreshSketches();
|
||||
this.viewer.render();
|
||||
|
||||
var viewer = this.viewer;
|
||||
|
|
@ -107,7 +98,27 @@ TCAD.App.prototype.cut = function() {
|
|||
|
||||
};
|
||||
|
||||
TCAD.App.prototype.refreshSketches = function() {
|
||||
this._refreshSketches();
|
||||
this.viewer.render();
|
||||
};
|
||||
|
||||
TCAD.App.prototype._refreshSketches = function() {
|
||||
for (var oi = 0; oi < this.viewer.scene.children.length; ++oi) {
|
||||
var obj = this.viewer.scene.children[oi];
|
||||
if (obj.geometry !== undefined && obj.geometry.polyFaces !== undefined) {
|
||||
for (var i = 0; i < obj.geometry.polyFaces.length; i++) {
|
||||
var sketchFace = obj.geometry.polyFaces[i];
|
||||
var faceStorageKey = this.faceStorageKey(sketchFace.id);
|
||||
var savedFace = localStorage.getItem(faceStorageKey);
|
||||
if (savedFace != null) {
|
||||
var geom = TCAD.workbench.readSketchGeom(JSON.parse(savedFace));
|
||||
sketchFace.syncSketches(geom);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TCAD.App.prototype.save = function() {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue