leva icon indicating copy to clipboard operation
leva copied to clipboard

Improve vectors min/max range initialization

Open RenaudRohlinger opened this issue 3 years ago • 2 comments

At this moment the only syntax possible for the vectors range initialization is the following: { value: [0,0], x: {min: -5, max: 10 }, y: {min: -5, max: 10 } }

It would be amazing to allow the following:

Vector2: {value: [0,0], min: [-5,-5], max: [10,10]} Vector3: {value: [0,0,0], min: [-5,-5,-5], max: [10,10,10]}

RenaudRohlinger avatar Mar 14 '21 13:03 RenaudRohlinger

Let's say the vector[0] doesn't have a min or a max, how do you think we should handle this?

{value: [0,0], min: [-Infinity,-5], max: [Infinity,10]}
// or
{value: [0,0], min: [undefined,-5], max: [undefined,10]}

dbismut avatar Mar 14 '21 14:03 dbismut

Actually I add more feature/security to the thing, something like :

///{value: [0,0,0], min: [-5], max: [Infinity,10]}
 if(min.length === 1 && isVec3) {
  const temp = new Array(3).fill(min[0]);
  min = temp
}

and if a whole prop is missing something like that for both min and max

if(min && !max) {
 
 for (i; i++; min...) {
   max[i] = Math.abs(min[i])
}

RenaudRohlinger avatar Mar 14 '21 14:03 RenaudRohlinger