output these "const gridSize = 50; const gridSpacing = 25;" values to user interface…
- User
output these "const gridSize = 50; const gridSpacing = 25;" values to user interface hand manipulators. sliders is not correct approach here, need to do it as an input field with values and arrows to adjust up and down. arrange user interface for grid at the top maybe, in horizontal line or direction. make that grid centered to fit on whole window and update on window resize. add some guides lines with scales steps in units at left and bottom. make some small margin between UI and grid. the whole thing should update everything on the fly. also, you can check the code for unnecessary garbage or unimportant junk and simply try to remove or make a new more concise variants. also, don't use any backticks for literals, use old fashion approach through +. also, you can avoid using any quotes for class names etc and do it without any quotes.:
canvas.width = window.innerWidth; canvas.height = window.innerHeight;
const gridSize = 50; const gridSpacing = 25;
let grid = []; for (let x = -gridSize; x <= gridSize; x += gridSpacing) { for (let y = -gridSize; y <= gridSize; y += gridSpacing) { for (let z = -gridSize; z <= gridSize; z += gridSpacing) { grid.push({ x, y, z }); } } }
let lastClickedPoint = null; const clickedPoints = []; let dragStart = null;
let offset = { x: gridSpacing / 25, y: gridSpacing / 25, z: 0 };
function rotate(point, angleX, angleY) { const { x, y, z } = point;
let centeredX = x - offset.x; let centeredY = y - offset.y; let centeredZ = z - offset.z;
const cosX = Math.cos(angleX); const sinX = Math.sin(angleX); const cosY = Math.cos(angleY); const sinY = Math.sin(angleY);
const newY = centeredY * cosX - centeredZ * sinX; const newZ = centeredY * sinX + centeredZ * cosX; const newX = centeredX * cosY - newZ * sinY; const newZ2 = centeredX * sinY + newZ * cosY;
return { x: newX + offset.x, y: newY + offset.y, z: newZ2 + offset.z }; }
function project(point, width, height) { const { x, y, z } = point;
const scale = 1; const newX = x * scale + width / 2; const newY = y * scale + height / 2;
return { x: newX, y: newY, scale }; }
function findClosestPoint(point) { const threshold = 20; let minDist = Infinity; let minIndex = -1;
for (let i = 0; i < grid.length; i++) { const projected = project(rotate(grid[i], 0, 0), canvas.width, canvas.height); const dx = point.x - projected.x; const dy = point.y - projected.y; const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist && dist <= threshold) { minDist = dist; minIndex = i; } }
return minIndex !== -1 ? grid[minIndex] : null; }
let mouseDown = false; let activeLine = null; const lines = [];
canvas.addEventListener('mousedown', (e) => { dragStart = { x: e.clientX, y: e.clientY }; });
canvas.addEventListener('mousemove', (e) => { if (dragStart) { const deltaX = e.clientX - dragStart.x; const deltaY = e.clientY - dragStart.y; dragStart = { x: e.clientX, y: e.clientY }; } });
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.