diff --git a/js/cam/Machine.js b/js/cam/Machine.js index 9d2bc95aafe5444bd218f7133208418250ff1a62..6d4c71d445d0b667cb50f5c09045d125a232eaaa 100644 --- a/js/cam/Machine.js +++ b/js/cam/Machine.js @@ -63,19 +63,20 @@ Machine.prototype.pause = function(){ }; Machine.prototype._animateMesh = function(mesh, axis, speed, target, callback){ - var increment = (target-mesh.position[axis])/20; + var increment = 0.1/speed;//based on 1/10th of sec if (increment == 0) { if (callback) callback(); return; } var direction = 1; if (increment<0) direction = -1; - increment = Math.max(Math.abs(increment), 0.0001)*direction; + increment = Math.max(Math.abs(increment), 0.00001)*direction;//need to put a min on the increment - other wise this stall out with floating pt tol dmaGlobals.three.startAnimationLoop(); - this._incrementalMove(mesh, axis, increment, target, direction, callback); + var simSpeed = 100/dmaGlobals.assembler.get("simSpeed");//1/10th of sec + this._incrementalMove(mesh, axis, increment, target, direction, callback, simSpeed); }; -Machine.prototype._incrementalMove = function(mesh, axis, increment, target, direction, callback){ +Machine.prototype._incrementalMove = function(mesh, axis, increment, target, direction, callback, simSpeed){ var self = this; setTimeout(function(){ if ((target-mesh.position[axis])*direction <= 0) { @@ -84,8 +85,8 @@ Machine.prototype._incrementalMove = function(mesh, axis, increment, target, dir } if (Math.abs(target-mesh.position[axis]) < Math.abs(increment)) mesh.position[axis] = target;//don't overshoot else mesh.position[axis] += increment; - self._incrementalMove(mesh, axis, increment, target, direction, callback) - },100); + self._incrementalMove(mesh, axis, increment, target, direction, callback, simSpeed) + },simSpeed); }; Machine.prototype.destroy = function(){ @@ -128,7 +129,7 @@ Shopbot.prototype.moveTo = function(x, y, z, speed, wcs, callback){ function sketchyCallback(){ totalThreads -= 1; if (totalThreads > 0) return; - return callback(); + callback(); } this._moveAxis(endEffector, x, "x", speed.xy, wcs, sketchyCallback); this._moveAxis(endEffector, y, "y", speed.xy, wcs, sketchyCallback); diff --git a/js/menus/CamMenuView.js b/js/menus/CamMenuView.js index ac31cfcc8fa0fa969877efbf77aeab3c78b90d35..be7f92bbe4223b1c6d75f8fd9ca5681b31d78cdb 100644 --- a/js/menus/CamMenuView.js +++ b/js/menus/CamMenuView.js @@ -77,6 +77,24 @@ CamMenuView = Backbone.View.extend({ else this.assembler.set(property, newVal); }, + _updatePosNumber: function(e, property){ + e.preventDefault(); + var newVal = parseFloat($(e.target).val()); + if (isNaN(newVal)) return; + newVal = parseFloat(newVal.toFixed(4)); + if (newVal <= 0) { + console.warn("value must be positive"); + return; + } + var object = this.assembler.get(property); + if ($(e.target).data("type")) { + object[$(e.target).data("type")] = newVal; + this.assembler.trigger("change:" + property); + this.assembler.trigger("change"); + } + else this.assembler.set(property, newVal); + }, + _updateRelativeStockPosition: function(e){ e.preventDefault(); var newVal = parseFloat($(e.target).val());