Spaces:
Running
Running
File size: 28,638 Bytes
37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 bd6ccf8 e3cc6e9 37e389b bd6ccf8 e3cc6e9 bd6ccf8 e3cc6e9 bd6ccf8 e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 37e389b e3cc6e9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Laser-Cut Box Generator</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1400px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(10px);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #2c3e50, #34495e);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 2.5em;
margin-bottom: 10px;
font-weight: 300;
}
.header p {
opacity: 0.9;
font-size: 1.1em;
}
.main-content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0;
min-height: 800px;
}
.controls {
padding: 40px;
background: #f8f9fa;
border-right: 1px solid #e9ecef;
overflow-y: auto;
}
.preview {
padding: 40px;
background: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.section {
margin-bottom: 30px;
background: white;
border-radius: 12px;
padding: 25px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
border: 1px solid #e9ecef;
}
.section h3 {
color: #2c3e50;
margin-bottom: 20px;
font-size: 1.2em;
font-weight: 600;
border-bottom: 2px solid #3498db;
padding-bottom: 10px;
}
.form-group {
margin-bottom: 20px;
}
.form-row {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 15px;
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 500;
color: #34495e;
font-size: 0.9em;
}
input, select {
width: 100%;
padding: 12px 15px;
border: 2px solid #e9ecef;
border-radius: 8px;
font-size: 0.95em;
transition: all 0.3s ease;
background: white;
}
input:focus, select:focus {
outline: none;
border-color: #3498db;
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}
.btn {
background: linear-gradient(135deg, #3498db, #2980b9);
color: white;
border: none;
padding: 15px 30px;
border-radius: 8px;
font-size: 1em;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
width: 100%;
margin-top: 10px;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(52, 152, 219, 0.3);
}
.btn:active {
transform: translateY(0);
}
.preview-canvas {
width: 100%;
max-width: 500px;
height: 400px;
border: 2px solid #e9ecef;
border-radius: 12px;
background: #fdfdfd;
margin-bottom: 20px;
}
.dimensions-display {
background: #f8f9fa;
padding: 20px;
border-radius: 8px;
margin-bottom: 20px;
font-family: 'Courier New', monospace;
}
.help-text {
font-size: 0.8em;
color: #7f8c8d;
margin-top: 5px;
line-height: 1.4;
}
.warning {
background: #fff3cd;
border: 1px solid #ffeaa7;
color: #856404;
padding: 12px;
border-radius: 6px;
margin-top: 10px;
font-size: 0.9em;
}
.success {
background: #d4edda;
border: 1px solid #c3e6cb;
color: #155724;
padding: 12px;
border-radius: 6px;
margin-top: 10px;
font-size: 0.9em;
}
.kerf-test {
background: #e8f4f8;
border: 1px solid #bee5eb;
padding: 15px;
border-radius: 8px;
margin-top: 15px;
}
.joint-preview {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
gap: 15px;
margin-top: 15px;
}
.joint-option {
text-align: center;
padding: 15px;
border: 2px solid #e9ecef;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
background: white;
}
.joint-option:hover {
border-color: #3498db;
background: #f8f9fa;
}
.joint-option.selected {
border-color: #3498db;
background: #e8f4f8;
}
.joint-diagram {
width: 80px;
height: 40px;
margin: 0 auto 10px;
background: #34495e;
position: relative;
border-radius: 2px;
}
.finger-joint::after {
content: '';
position: absolute;
top: -5px;
left: 10px;
right: 10px;
height: 50px;
background: repeating-linear-gradient(to right, #3498db 0px, #3498db 8px, transparent 8px, transparent 16px);
}
.download-section {
text-align: center;
margin-top: 30px;
}
.file-format {
display: inline-block;
margin: 0 10px;
padding: 10px 20px;
background: #ecf0f1;
border-radius: 6px;
cursor: pointer;
transition: all 0.3s ease;
}
.file-format:hover {
background: #3498db;
color: white;
}
@media (max-width: 768px) {
.main-content {
grid-template-columns: 1fr;
}
.form-row {
grid-template-columns: 1fr;
}
.container {
margin: 10px;
}
}
.material-guide {
background: #f8f9fa;
border-left: 4px solid #3498db;
padding: 15px;
margin: 15px 0;
}
.material-guide h4 {
color: #2c3e50;
margin-bottom: 10px;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
gap: 15px;
margin-top: 20px;
}
.stat-card {
background: white;
padding: 15px;
border-radius: 8px;
border: 1px solid #e9ecef;
text-align: center;
}
.stat-value {
font-size: 1.5em;
font-weight: bold;
color: #3498db;
}
.stat-label {
font-size: 0.9em;
color: #7f8c8d;
margin-top: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🔥 Advanced Laser-Cut Box Generator</h1>
<p>Professional-grade parametric box design with precision kerf compensation and multiple joint types</p>
</div>
<div class="main-content">
<div class="controls">
<div class="section">
<h3>📐 Box Dimensions</h3>
<div class="form-row">
<div class="form-group">
<label for="width">Width (mm)</label>
<input type="number" id="width" value="100" min="10" max="1000" step="0.1">
<div class="help-text">Internal width of the box</div>
</div>
<div class="form-group">
<label for="depth">Depth (mm)</label>
<input type="number" id="depth" value="80" min="10" max="1000" step="0.1">
<div class="help-text">Internal depth of the box</div>
</div>
<div class="form-group">
<label for="height">Height (mm)</label>
<input type="number" id="height" value="60" min="10" max="1000" step="0.1">
<div class="help-text">Internal height of the box</div>
</div>
</div>
</div>
<div class="section">
<h3>🔧 Material & Cutting Settings</h3>
<div class="form-row">
<div class="form-group">
<label for="thickness">Material Thickness (mm)</label>
<input type="number" id="thickness" value="3.0" min="0.1" max="20" step="0.1">
<div class="help-text">Actual measured thickness</div>
</div>
<div class="form-group">
<label for="kerf">Laser Kerf (mm)</label>
<input type="number" id="kerf" value="0.1" min="0" max="1" step="0.01">
<div class="help-text">Material removed by laser</div>
</div>
<div class="form-group">
<label for="materialType">Material Type</label>
<select id="materialType">
<option value="plywood">Plywood</option>
<option value="mdf">MDF</option>
<option value="acrylic">Acrylic</option>
<option value="cardboard">Cardboard</option>
<option value="custom">Custom</option>
</select>
</div>
</div>
<div class="kerf-test">
<strong>🎯 Kerf Testing Tip:</strong> Cut a small test piece with interlocking tabs to verify your kerf setting before cutting the final box.
</div>
</div>
<div class="section">
<h3>⚙️ Joint Configuration</h3>
<div class="form-group">
<label for="jointType">Joint Type</label>
<div class="joint-preview">
<div class="joint-option selected" data-joint="finger">
<div class="joint-diagram finger-joint"></div>
<div>Finger Joints</div>
</div>
<div class="joint-option" data-joint="dovetail">
<div class="joint-diagram"></div>
<div>Dovetail</div>
</div>
<div class="joint-option" data-joint="simple">
<div class="joint-diagram"></div>
<div>Simple Tab</div>
</div>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="fingerWidth">Tab Width (mm)</label>
<input type="number" id="fingerWidth" value="10" min="2" max="50" step="0.5">
<div class="help-text">Width of individual tabs</div>
</div>
<div class="form-group">
<label for="fingerCount">Fingers per Edge</label>
<select id="fingerCount">
<option value="auto">Auto Calculate</option>
<option value="3">3</option>
<option value="5">5</option>
<option value="7">7</option>
<option value="9">9</option>
<option value="11">11</option>
</select>
</div>
<div class="form-group">
<label for="fingerOffset">Edge Offset (mm)</label>
<input type="number" id="fingerOffset" value="0" min="0" max="20" step="0.5">
<div class="help-text">Distance from edge to first tab</div>
</div>
</div>
</div>
<div class="section">
<h3>📦 Box Configuration</h3>
<div class="form-row">
<div class="form-group">
<label for="boxType">Box Type</label>
<select id="boxType">
<option value="open">Open Top</option>
<option value="closed">Closed Box</option>
<option value="lid">Box with Lid</option>
<option value="sliding">Sliding Lid</option>
</select>
</div>
<div class="form-group">
<label for="bottomType">Bottom Type</label>
<select id="bottomType">
<option value="attached">Attached</option>
<option value="inset">Inset</option>
<option value="none">No Bottom</option>
</select>
</div>
<div class="form-group">
<label for="cornerType">Corner Style</label>
<select id="cornerType">
<option value="square">Square</option>
<option value="rounded">Rounded</option>
<option value="chamfered">Chamfered</option>
</select>
</div>
</div>
</div>
<div class="section">
<h3>🎛️ Advanced Options</h3>
<div class="form-group">
<label>
<input type="checkbox" id="addHoles"> Add mounting holes
</label>
<label>
<input type="checkbox" id="addDividers"> Include dividers
</label>
<label>
<input type="checkbox" id="addVents"> Add ventilation holes
</label>
<label>
<input type="checkbox" id="addLabels"> Add part labels
</label>
</div>
</div>
<button class="btn" onclick="generateBox()">🚀 Generate Box Design</button>
</div>
<div class="preview">
<canvas class="preview-canvas" id="previewCanvas"></canvas>
<div class="dimensions-display" id="dimensionsDisplay">
<strong>📏 Calculated Dimensions:</strong><br>
External: 106.0 × 86.0 × 66.0 mm<br>
Material Usage: 520.0 cm²<br>
Cutting Time: ~8 minutes
</div>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-value" id="partCount">6</div>
<div class="stat-label">Parts</div>
</div>
<div class="stat-card">
<div class="stat-value" id="cutLength">2.4m</div>
<div class="stat-label">Cut Length</div>
</div>
<div class="stat-card">
<div class="stat-value" id="materialUsage">520</div>
<div class="stat-label">cm² Material</div>
</div>
<div class="stat-card">
<div class="stat-value" id="efficiency">85%</div>
<div class="stat-label">Efficiency</div>
</div>
</div>
<div class="download-section">
<h3>📥 Download Files</h3>
<div class="file-format" onclick="downloadFile('svg')">SVG</div>
<div class="file-format" onclick="downloadFile('dxf')">DXF</div>
<div class="file-format" onclick="downloadFile('pdf')">PDF</div>
<div class="file-format" onclick="downloadFile('eps')">EPS</div>
</div>
<div class="material-guide">
<h4>📋 Cutting Guidelines</h4>
<p><strong>Recommended Settings:</strong></p>
<ul>
<li>3mm Plywood: 1000mm/min, 80% power</li>
<li>Cut in this order: 1. Inner holes 2. Finger joints 3. Outer edges</li>
<li>Use air assist for clean cuts</li>
<li>Test fit corner pieces before full cut</li>
</ul>
</div>
</div>
</div>
</div>
<script>
// Global variables for box configuration
let boxConfig = {
width: 100,
depth: 80,
height: 60,
thickness: 3.0,
kerf: 0.1,
jointType: 'finger',
fingerWidth: 10,
fingerCount: 'auto',
boxType: 'open',
bottomType: 'attached'
};
// Material presets for common laser cutting materials
const materialPresets = {
plywood: { kerf: 0.1, density: 0.6 },
mdf: { kerf: 0.12, density: 0.75 },
acrylic: { kerf: 0.05, density: 1.18 },
cardboard: { kerf: 0.02, density: 0.7 }
};
// Initialize the application
function init() {
setupEventListeners();
drawPreview();
updateDimensions();
}
function setupEventListeners() {
// Dimension inputs
['width', 'depth', 'height', 'thickness', 'kerf', 'fingerWidth'].forEach(id => {
document.getElementById(id).addEventListener('input', function() {
boxConfig[id] = parseFloat(this.value);
updateDisplay();
});
});
// Select inputs
['fingerCount', 'boxType', 'bottomType', 'cornerType'].forEach(id => {
document.getElementById(id).addEventListener('change', function() {
boxConfig[id] = this.value;
updateDisplay();
});
});
// Material type change
document.getElementById('materialType').addEventListener('change', function() {
if (materialPresets[this.value]) {
document.getElementById('kerf').value = materialPresets[this.value].kerf;
boxConfig.kerf = materialPresets[this.value].kerf;
updateDisplay();
}
});
// Joint type selection
document.querySelectorAll('.joint-option').forEach(option => {
option.addEventListener('click', function() {
document.querySelectorAll('.joint-option').forEach(o => o.classList.remove('selected'));
this.classList.add('selected');
boxConfig.jointType = this.dataset.joint;
updateDisplay();
});
});
}
function updateDisplay() {
drawPreview();
updateDimensions();
updateStats();
}
function drawPreview() {
const canvas = document.getElementById('previewCanvas');
const ctx = canvas.getContext('2d');
// Set canvas size
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
// Clear canvas
ctx.fillStyle = '#fdfdfd';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Calculate scaling to fit the box in the canvas
const margin = 40;
const availableWidth = canvas.width - 2 * margin;
const availableHeight = canvas.height - 2 * margin;
const boxWidth = boxConfig.width + 2 * boxConfig.thickness;
const boxHeight = boxConfig.height + boxConfig.thickness;
const scale = Math.min(availableWidth / boxWidth, availableHeight / boxHeight);
// Center the drawing
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
ctx.save();
ctx.translate(centerX, centerY);
ctx.scale(scale, scale);
// Draw 3D isometric view of the box
drawIsometricBox(ctx);
ctx.restore();
}
function drawIsometricBox(ctx) {
const w = boxConfig.width;
const h = boxConfig.height;
const d = boxConfig.depth;
const t = boxConfig.thickness;
// Isometric transformation
const isoX = (x, y) => x * 0.866 - y * 0.866;
const isoY = (x, y, z) => x * 0.5 + y * 0.5 - z;
// Colors for different faces
const frontColor = '#3498db';
const topColor = '#2980b9';
const sideColor = '#34495e';
ctx.lineWidth = 2;
ctx.strokeStyle = '#2c3e50';
// Draw front face
ctx.fillStyle = frontColor;
ctx.beginPath();
ctx.moveTo(isoX(-w/2, 0), isoY(-w/2, 0, h));
ctx.lineTo(isoX(w/2, 0), isoY(w/2, 0, h));
ctx.lineTo(isoX(w/2, 0), isoY(w/2, 0, 0));
ctx.lineTo(isoX(-w/2, 0), isoY(-w/2, 0, 0));
ctx.closePath();
ctx.fill();
ctx.stroke();
// Draw finger joints on front face
if (boxConfig.jointType === 'finger') {
drawFingerJoints(ctx, isoX(-w/2, 0), isoY(-w/2, 0, h), isoX(w/2, 0), isoY(w/2, 0, h), 'horizontal');
}
// Draw right side face
ctx.fillStyle = sideColor;
ctx.beginPath();
ctx.moveTo(isoX(w/2, 0), isoY(w/2, 0, h));
ctx.lineTo(isoX(w/2, -d), isoY(w/2, -d, h));
ctx.lineTo(isoX(w/2, -d), isoY(w/2, -d, 0));
ctx.lineTo(isoX(w/2, 0), isoY(w/2, 0, 0));
ctx.closePath();
ctx.fill();
ctx.stroke();
// Draw top face (if closed box)
if (boxConfig.boxType !== 'open') {
ctx.fillStyle = topColor;
ctx.beginPath();
ctx.moveTo(isoX(-w/2, 0), isoY(-w/2, 0, h));
ctx.lineTo(isoX(w/2, 0), isoY(w/2, 0, h));
ctx.lineTo(isoX(w/2, -d), isoY(w/2, -d, h));
ctx.lineTo(isoX(-w/2, -d), isoY(-w/2, -d, h));
ctx.closePath();
ctx.fill();
ctx.stroke();
}
}
function drawFingerJoints(ctx, x1, y1, x2, y2, orientation) {
const fingerCount = calculateFingerCount();
const edgeLength = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
const fingerWidth = edgeLength / (fingerCount * 2 - 1);
ctx.strokeStyle = '#e74c3c';
ctx.lineWidth = 1;
for (let i = 0; i < fingerCount; i++) {
const startRatio = (i * 2) / (fingerCount * 2 - 1);
const endRatio = (i * 2 + 1) / (fingerCount * 2 - 1);
const startX = x1 + (x2 - x1) * startRatio;
const startY = y1 + (y2 - y1) * startRatio;
const endX = x1 + (x2 - x1) * endRatio;
const endY = y1 + (y2 - y1) * endRatio;
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineTo(endX, endY);
ctx.stroke();
}
}
function calculateFingerCount() {
if (boxConfig.fingerCount === 'auto') {
// Auto-calculate based on edge length and finger width
const edgeLength = Math.max(boxConfig.width, boxConfig.depth);
const count = Math.floor(edgeLength / (boxConfig.fingerWidth * 2)) * 2 + 1;
return Math.max(3, Math.min(11, count));
}
return parseInt(boxConfig.fingerCount);
}
function updateDimensions() {
const external = {
width: boxConfig.width + 2 * boxConfig.thickness,
depth: boxConfig.depth + 2 * boxConfig.thickness,
height: boxConfig.height + boxConfig.thickness
};
const materialUsage = calculateMaterialUsage();
const cuttingTime = estimateCuttingTime();
document.getElementById('dimensionsDisplay').innerHTML = `
<strong>📏 Calculated Dimensions:</strong><br>
External: ${external.width.toFixed(1)} × ${external.depth.toFixed(1)} × ${external.height.toFixed(1)} mm<br>
Material Usage: ${materialUsage.toFixed(0)} cm²<br>
Cutting Time: ~${cuttingTime} minutes
`;
}
function updateStats() {
const partCount = calculatePartCount();
const cutLength = calculateCutLength();
const materialUsage = calculateMaterialUsage();
const efficiency = calculateEfficiency();
document.getElementById('partCount').textContent = partCount;
document.getElementById('cutLength').textContent = (cutLength / 1000).toFixed(1) + 'm';
document.getElementById('materialUsage').textContent = Math.round(materialUsage);
document.getElementById('efficiency').textContent = Math.round(efficiency) + '%';
}
function calculatePartCount() {
let count = 4; // Four sides
if (boxConfig.bottomType !== 'none') count += 1; // Bottom
if (boxConfig.boxType === 'closed' || boxConfig.boxType === 'lid') count += 1; // Top
return count;
}
function calculateCutLength() {
const perimeter = 2 * (boxConfig.width + boxConfig.depth + boxConfig.height + boxConfig.thickness);
const fingerCount = calculateFingerCount();
const fingerLength = fingerCount * 8 * boxConfig.fingerWidth; // Approximate finger joint length
return perimeter + fingerLength;
}
function calculateMaterialUsage() {
const area1 = 2 * (boxConfig.width + 2 * boxConfig.thickness) * (boxConfig.height + boxConfig.thickness);
const area2 = 2 * (boxConfig.depth + 2 * boxConfig.thickness) * (boxConfig.height + boxConfig.thickness); |