Created
January 27, 2020 02:50
-
-
Save yertto/bf3fde0e78ea3b9b36000d7a55b14677 to your computer and use it in GitHub Desktop.
Constraining the range of one metaParameter based on another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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