live update, but only with run server though

This commit is contained in:
Val Erastov 2014-11-05 00:13:53 -08:00
parent 92ff059969
commit 95df51104d
2 changed files with 32 additions and 9 deletions

View file

@ -264,17 +264,20 @@ TCAD.SketchFace.prototype.SKETCH_MATERIAL = new THREE.LineBasicMaterial({
color: 0xFFFFFF, linewidth: 3});
TCAD.SketchFace.prototype.syncSketches = function(geom) {
var i;
var normal = this.polygon.normal;
var offVector = normal.multiply(0.5);
if (this.sketch3DGroup != null) {
this.sketch3DGroup.remove(this.sketch3DGroup.children);
for (var i = this.sketch3DGroup.children.length - 1; i >= 0; --i) {
this.sketch3DGroup.remove(this.sketch3DGroup.children[i]);
}
} else {
this.sketch3DGroup = new THREE.Object3D();
}
this.geom = [];
var i = 0;
var _3dTransformation = new TCAD.Matrix().setBasis(TCAD.geom.someBasis(this.polygon.shell, normal));
//we lost depth or z off in 2d sketch, calculate it again
var depth = normal.dot(this.polygon.shell[0]);

View file

@ -22,13 +22,33 @@ TCAD.App = function() {
}
this.viewer.render();
var viewer = this.viewer;
var app = this;
function storage_handler(evt) {
console.log('The modified key was '+evt.key);
console.log('The original value was '+evt.oldValue);
console.log('The new value is '+evt.newValue);
console.log('The URL of the page that made the change was '+evt.url);
console.log('The window where the change was made was '+evt.source);
// console.log('The modified key was '+evt.key);
// console.log('The original value was '+evt.oldValue);
// console.log('The new value is '+evt.newValue);
// console.log('The URL of the page that made the change was '+evt.url);
// console.log('The window where the change was made was '+evt.source);
var prefix = "TCAD.projects."+app.id+".sketch.";
if (evt.key.indexOf(prefix) < 0) return;
sketchFaceId = evt.key.substring(prefix.length);
for (var oi = 0; oi < viewer.scene.children.length; ++oi) {
var obj = viewer.scene.children[oi];
if (obj.geometry !== undefined && obj.geometry.polyFaces !== undefined) {
for (var i = 0; i < box.geometry.polyFaces.length; i++) {
var sketchFace = box.geometry.polyFaces[i];
if (sketchFace.id == sketchFaceId) {
var geom = TCAD.workbench.readSketchGeom(JSON.parse(evt.newValue));
sketchFace.syncSketches(geom);
viewer.render();
break;
}
}
}
}
}
window.addEventListener('storage', storage_handler, false);