cyclecad 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/index.html +93 -0
- package/package.json +1 -1
package/app/index.html
CHANGED
|
@@ -1363,6 +1363,99 @@
|
|
|
1363
1363
|
<div id="toast-container"></div>
|
|
1364
1364
|
|
|
1365
1365
|
<script type="module">
|
|
1366
|
+
// ===== Three.js Imports =====
|
|
1367
|
+
import * as THREE from 'three';
|
|
1368
|
+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
1369
|
+
import { GridHelper } from 'three';
|
|
1370
|
+
|
|
1371
|
+
// ===== Three.js Viewport Setup =====
|
|
1372
|
+
const scene = new THREE.Scene();
|
|
1373
|
+
scene.background = new THREE.Color(0x2d2d30);
|
|
1374
|
+
|
|
1375
|
+
const viewportEl = document.getElementById('viewport-container');
|
|
1376
|
+
const canvas = viewportEl.querySelector('canvas') || document.createElement('canvas');
|
|
1377
|
+
if (!canvas.parentElement) viewportEl.appendChild(canvas);
|
|
1378
|
+
|
|
1379
|
+
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
|
|
1380
|
+
renderer.setPixelRatio(window.devicePixelRatio);
|
|
1381
|
+
renderer.shadowMap.enabled = true;
|
|
1382
|
+
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
1383
|
+
|
|
1384
|
+
const camera = new THREE.PerspectiveCamera(50, 1, 0.1, 10000);
|
|
1385
|
+
camera.position.set(150, 120, 200);
|
|
1386
|
+
camera.lookAt(0, 0, 0);
|
|
1387
|
+
|
|
1388
|
+
const controls = new OrbitControls(camera, renderer.domElement);
|
|
1389
|
+
controls.enableDamping = true;
|
|
1390
|
+
controls.dampingFactor = 0.08;
|
|
1391
|
+
controls.target.set(0, 0, 0);
|
|
1392
|
+
|
|
1393
|
+
// Lights
|
|
1394
|
+
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
|
|
1395
|
+
scene.add(ambientLight);
|
|
1396
|
+
const dirLight = new THREE.DirectionalLight(0xffffff, 0.8);
|
|
1397
|
+
dirLight.position.set(200, 300, 150);
|
|
1398
|
+
dirLight.castShadow = true;
|
|
1399
|
+
scene.add(dirLight);
|
|
1400
|
+
const fillLight = new THREE.DirectionalLight(0x8899bb, 0.3);
|
|
1401
|
+
fillLight.position.set(-100, 50, -100);
|
|
1402
|
+
scene.add(fillLight);
|
|
1403
|
+
|
|
1404
|
+
// Grid
|
|
1405
|
+
const grid = new THREE.GridHelper(500, 50, 0x444444, 0x333333);
|
|
1406
|
+
scene.add(grid);
|
|
1407
|
+
|
|
1408
|
+
// Demo geometry — a sample part so viewport isn't empty
|
|
1409
|
+
const boxGeo = new THREE.BoxGeometry(60, 40, 80);
|
|
1410
|
+
const boxMat = new THREE.MeshStandardMaterial({ color: 0x0284C7, metalness: 0.3, roughness: 0.6 });
|
|
1411
|
+
const box = new THREE.Mesh(boxGeo, boxMat);
|
|
1412
|
+
box.position.y = 20;
|
|
1413
|
+
box.castShadow = true;
|
|
1414
|
+
box.receiveShadow = true;
|
|
1415
|
+
scene.add(box);
|
|
1416
|
+
|
|
1417
|
+
const cylGeo = new THREE.CylinderGeometry(12, 12, 50, 32);
|
|
1418
|
+
const cylMat = new THREE.MeshStandardMaterial({ color: 0x10b981, metalness: 0.4, roughness: 0.5 });
|
|
1419
|
+
const cyl = new THREE.Mesh(cylGeo, cylMat);
|
|
1420
|
+
cyl.position.set(0, 45, 0);
|
|
1421
|
+
cyl.castShadow = true;
|
|
1422
|
+
scene.add(cyl);
|
|
1423
|
+
|
|
1424
|
+
// Ground plane
|
|
1425
|
+
const groundGeo = new THREE.PlaneGeometry(500, 500);
|
|
1426
|
+
const groundMat = new THREE.ShadowMaterial({ opacity: 0.15 });
|
|
1427
|
+
const ground = new THREE.Mesh(groundGeo, groundMat);
|
|
1428
|
+
ground.rotation.x = -Math.PI / 2;
|
|
1429
|
+
ground.receiveShadow = true;
|
|
1430
|
+
scene.add(ground);
|
|
1431
|
+
|
|
1432
|
+
// Resize handler
|
|
1433
|
+
function resizeViewport() {
|
|
1434
|
+
const w = viewportEl.clientWidth;
|
|
1435
|
+
const h = viewportEl.clientHeight;
|
|
1436
|
+
if (w === 0 || h === 0) return;
|
|
1437
|
+
camera.aspect = w / h;
|
|
1438
|
+
camera.updateProjectionMatrix();
|
|
1439
|
+
renderer.setSize(w, h);
|
|
1440
|
+
}
|
|
1441
|
+
new ResizeObserver(resizeViewport).observe(viewportEl);
|
|
1442
|
+
resizeViewport();
|
|
1443
|
+
|
|
1444
|
+
// Animation loop
|
|
1445
|
+
function animate() {
|
|
1446
|
+
requestAnimationFrame(animate);
|
|
1447
|
+
controls.update();
|
|
1448
|
+
renderer.render(scene, camera);
|
|
1449
|
+
}
|
|
1450
|
+
animate();
|
|
1451
|
+
|
|
1452
|
+
// Expose globals for modules
|
|
1453
|
+
window.THREE = THREE;
|
|
1454
|
+
window._scene = scene;
|
|
1455
|
+
window._camera = camera;
|
|
1456
|
+
window._renderer = renderer;
|
|
1457
|
+
window._controls = controls;
|
|
1458
|
+
|
|
1366
1459
|
// ===== Global State =====
|
|
1367
1460
|
const appState = {
|
|
1368
1461
|
currentWorkspace: 'design',
|
package/package.json
CHANGED