Skip to content

Commit fa0de62

Browse files
author
jolica
committed
Refactor: Replace Math.max/min with xb.clamp utility
1 parent 8b10d70 commit fa0de62

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

demos/math3d/Math3D.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class Math3D extends xb.Script {
9696

9797
this.keyboard = new Keyboard();
9898
this.add(this.keyboard);
99-
this.keyboard.position.set(0, -0.3, -0.);
99+
this.keyboard.position.set(0, -0.3, 0);
100100

101101
const startFn = this.mathObjects[0].functionText;
102102

@@ -191,7 +191,7 @@ export class Math3D extends xb.Script {
191191
try {
192192
z = zFunction(x, y);
193193
// Clamp the value to stay between -Z_LIMIT and Z_LIMIT
194-
z = Math.max(-Z_LIMIT, Math.min(Z_LIMIT, z));
194+
z = xb.clamp(z, -Z_LIMIT, Z_LIMIT);
195195

196196
// Handle cases where the math results in NaN (not a number)
197197
if (isNaN(z)) z = 0;

0 commit comments

Comments
 (0)