I think this might be a dumb mistake which I’ll understand after a good night’s sleep, but maybe someone can help me already.
I have made an easy little app to create gradient images or slopes. Here is the code:
// Define a properties array that returns array of objects representing
// the accepted properties for your application
var properties = [
{type: 'range', id: "Width", value: 4, min: 1, max: 10, step: 1},
{type: 'range', id: "Height", value: 4, min: 1, max: 10, step: 1},
{type: 'range', id: "Depth", value: 0.4, min: 0.0, max: 1.0, step: 0.05},
{type: 'range', id: "Steps", value: 10, min: 0, max: 100, step: 1},
{type: 'list', id: "Type", value: "Horizontal", options: ["Horizontal", "Vertical", "Diagonal"]}
];
// Define an executor function that builds an array of volumes,
// and passes it to the provided success callback, or invokes the failure
// callback if unable to do so
var executor = function(args, success, failure) {
var params = args.params;
var material = args.material;
var volumes = [];
var width = params["Width"];
var height = params["Height"];
var depth = params["Depth"];
var numSteps = params["Steps"];
var gradientType = params["Type"];
const changeWidth = (gradientType != "Vertical");
const changeHeight = (gradientType != "Horizontal");
const maxDepth = depth*material.dimensions.z;
const step = 1.0/numSteps;
for (ratio=1.0; ratio > step; ratio-=step) {
var w = width * (changeWidth? ratio : 1.0);
var h = height * (changeHeight? ratio : 1.0);
var d = depth * ratio;
volumes.push({
shape: {
type: "rectangle",
center: {
x: width - (w / 2),
y: height - (h / 2)
},
flipping: {},
width: w,
height: h,
rotation: 0
},
cut: {
depth: d,
type: 'fill',
tabPreference: false
}
});
}
success(volumes);
};
For some reason, when I use the app and set the “Depth” to 0.5, it is already black and if I move the cursor above that, the app gets stuck in “loading”.
So my question is: why is the maximum depth 0.5*material.dimensions.z instead of just material.dimensions.z?