Skip to content

Instantly share code, notes, and snippets.

@yertto
Created January 27, 2020 02:50
Show Gist options
  • Save yertto/bf3fde0e78ea3b9b36000d7a55b14677 to your computer and use it in GitHub Desktop.
Save yertto/bf3fde0e78ea3b9b36000d7a55b14677 to your computer and use it in GitHub Desktop.
Constraining the range of one metaParameter based on another
var makerjs = require('makerjs');
function nut(nutSize, holeSize) {
this.nutSize = nutSize;
this.models = { nut: new makerjs.models.Polygon(6, this.nutSize) };
this.paths = { hole: new makerjs.paths.Circle(holeSize) };
}
function maxHoleSize(_this) {
var result = _this.nutSize - 3;
console.log("Max hole size: " + result);
return result;
}
nut.metaParameters = [
{ title: "nutSize" , type: "range", min: 5, max: 20, value: 8 },
{ title: "holeSize", type: "range", min: 0, max: maxHoleSize, value: 5 }
];
module.exports = nut;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment