now what about actual snapping functionality? I don’t want to use grid as to be fully…
- User
now what about actual snapping functionality? I don’t want to use grid as to be fully permanently snapped all around, I want grid to be determinant measurement element, on which you can extend wireframe but in reality it will not be actually attached to grid but appear in that unattached position, it should allow only to extend for both vertices and new edges created. need to rework that “addEdge” button to actually handle all the functionality, to not permanently snap new vertex+edge to grid but to permanently snap it to the actual wireframe construct forma. also, need to be sure that the grid is in constant and extendable (full canvas size) static position and not affected by anything, except as the instrument of pure positioning.:
} .green-dot { position: absolute; width: 5px; height: 5px; background-color: lime; border-radius: 50%; pointer-events: none; z-index:0; }const ctx = canvas.getContext('2d'); const vmcMenu = document.getElementById('vmc-menu');
const greenDotContainer = document.createElement('div'); document.body.appendChild(greenDotContainer);const vertices = [ [0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0], [0, 0, 1], [0, 1, 1], [1, 1, 1], [1, 0, 1], ];
const edges = [ [0, 1], [1, 2], [2, 3], [3, 0], [0, 4], [1, 5], [2, 6], [3, 7], [4, 5], [5, 6], [6, 7], [7, 4], ];
const scale = 0.025; const zoom = 1; const offsetX = 0.5; const offsetY = 0.5;
let angleX = 0; let angleY = 0; let angleZ = 0; let bestIndex = -1; let bestDistance = Infinity; let startNewEdgeIndex = -1; let isMouseDown = false; let prevMousePos = null;
// Red Dot const redDot = document.getElementById('red-dot');
document.getElementById('add-edge').addEventListener('click', () => { if (bestIndex === -1) return; if (startNewEdgeIndex === -1) { const {x, y} = snapToGrid(window.event.clientX, window.event.clientY); const newVertexX = (x - canvas.width / 2) / (canvas.height * scale) + offsetX; const newVertexY = (y - canvas.height / 2) / (canvas.height * scale) + offsetY; const newVertexZ = 0; vertices.push([newVertexX.toPrecision(4), newVertexY.toPrecision(4), newVertexZ]); startNewEdgeIndex = vertices.length - 1; } else { edges.push([startNewEdgeIndex, bestIndex]); startNewEdgeIndex = -1; } });
// Remove Edge document.getElementById('remove-edge').addEventListener('click', () => { if (bestIndex === -1) return; edges.forEach((edge, index) => { if (edge.includes(bestIndex)) { edges.splice(index, 1); } }); });
function rotateX(angle) { const c = Math.cos(angle); const s = Math.sin(angle); return [ [1, 0, 0], [0, c, -s], [0, s, c], ]; }
function rotateY(angle) { const c = Math.cos(angle); const s = Math.sin(angle); return [ [c, 0, s], [0, 1, 0], [-s, 0, c], ]; }
function rotateZ(angle) { const c = Math.cos(angle); const s = Math.sin(angle); return [ [c, -s, 0], [s, c, 0], [0, 0, 1], ]; }
function project(vertex, scale, offsetX, offsetY, zoom) { const [x, y, z] = vertex; const posX = (x - offsetX) * scale; const posY = (y - offsetY) * scale; const posZ = z * scale;
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.