()
| 96 | |
| 97 | // --- INIT THREE.JS --- |
| 98 | function init() { |
| 99 | scene = new THREE.Scene(); |
| 100 | camera = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 1500); |
| 101 | camera.position.z = targetCameraZ; // Starting with a wider default view |
| 102 | |
| 103 | renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); |
| 104 | renderer.setSize(window.innerWidth, window.innerHeight); |
| 105 | renderer.setPixelRatio(window.devicePixelRatio); |
| 106 | |
| 107 | const container = document.getElementById('container'); |
| 108 | if (container) { |
| 109 | container.appendChild(renderer.domElement); |
| 110 | } else { |
| 111 | console.error("HTML element with id 'container' not found!"); |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | particles = createParticleSystem(); |
| 116 | scene.add(particles); |
| 117 | window.addEventListener('resize', onWindowResize); |
| 118 | initGUI(); |
| 119 | |
| 120 | // --- Get references for drawing --- |
| 121 | videoElement = document.querySelector('.input_video'); |
| 122 | canvasElement = document.querySelector('.output_canvas'); |
| 123 | if (canvasElement) { |
| 124 | canvasCtx = canvasElement.getContext('2d'); |
| 125 | } else { |
| 126 | console.error("Output canvas element not found!"); |
| 127 | } |
| 128 | // --- |
| 129 | |
| 130 | setupBloom(); |
| 131 | setupHandTracking(); // Setup hand tracking last |
| 132 | } |
| 133 | |
| 134 | // --- WINDOW RESIZE --- |
| 135 | function onWindowResize() { |
no test coverage detected