Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -316,14 +316,41 @@ class LightingControl3D(gr.HTML):
|
|
| 316 |
updateTextureFromUrl(props.imageUrl);
|
| 317 |
}
|
| 318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
// Studio LED light model
|
| 320 |
const lightGroup = new THREE.Group();
|
| 321 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
const ledPanel = new THREE.Mesh(new THREE.BoxGeometry(0.6, 0.6, 0.1), ledMat);
|
| 323 |
lightGroup.add(ledPanel);
|
| 324 |
|
| 325 |
-
const spotLight = new THREE.SpotLight(0xffffff, 10, 10, Math.PI /
|
| 326 |
-
spotLight.position.set(0, 0, 0);
|
| 327 |
spotLight.castShadow = true;
|
| 328 |
spotLight.shadow.mapSize.width = 1024;
|
| 329 |
spotLight.shadow.mapSize.height = 1024;
|
|
@@ -332,6 +359,11 @@ class LightingControl3D(gr.HTML):
|
|
| 332 |
spotLight.shadow.bias = -0.005;
|
| 333 |
lightGroup.add(spotLight);
|
| 334 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
scene.add(lightGroup);
|
| 336 |
|
| 337 |
// BLUE: Azimuth ring
|
|
@@ -402,7 +434,6 @@ class LightingControl3D(gr.HTML):
|
|
| 402 |
|
| 403 |
lightGroup.position.set(lightX, lightY, lightZ);
|
| 404 |
lightGroup.lookAt(CENTER);
|
| 405 |
-
spotLight.lookAt(CENTER);
|
| 406 |
|
| 407 |
azimuthHandle.position.set(AZIMUTH_RADIUS * Math.sin(azRad), 0.05, AZIMUTH_RADIUS * Math.cos(azRad));
|
| 408 |
elevationHandle.position.set(-0.8, ELEVATION_RADIUS * Math.sin(elRad) + CENTER.y, ELEVATION_RADIUS * Math.cos(elRad));
|
|
|
|
| 316 |
updateTextureFromUrl(props.imageUrl);
|
| 317 |
}
|
| 318 |
|
| 319 |
+
// Create LED texture
|
| 320 |
+
function createLEDTexture() {
|
| 321 |
+
const canvas = document.createElement('canvas');
|
| 322 |
+
canvas.width = 64;
|
| 323 |
+
canvas.height = 64;
|
| 324 |
+
const ctx = canvas.getContext('2d');
|
| 325 |
+
ctx.fillStyle = '#000000';
|
| 326 |
+
ctx.fillRect(0, 0, 64, 64);
|
| 327 |
+
for (let i = 0; i < 8; i++) {
|
| 328 |
+
for (let j = 0; j < 8; j++) {
|
| 329 |
+
ctx.fillStyle = '#ffffff';
|
| 330 |
+
ctx.beginPath();
|
| 331 |
+
ctx.arc(4 + 8 * i, 4 + 8 * j, 3, 0, Math.PI * 2);
|
| 332 |
+
ctx.fill();
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
return new THREE.CanvasTexture(canvas);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
// Studio LED light model
|
| 339 |
const lightGroup = new THREE.Group();
|
| 340 |
+
const ledTexture = createLEDTexture();
|
| 341 |
+
const ledMat = new THREE.MeshStandardMaterial({
|
| 342 |
+
color: 0x111111,
|
| 343 |
+
emissive: 0xffffff,
|
| 344 |
+
emissiveIntensity: 2,
|
| 345 |
+
emissiveMap: ledTexture,
|
| 346 |
+
roughness: 0.5,
|
| 347 |
+
metalness: 0
|
| 348 |
+
});
|
| 349 |
const ledPanel = new THREE.Mesh(new THREE.BoxGeometry(0.6, 0.6, 0.1), ledMat);
|
| 350 |
lightGroup.add(ledPanel);
|
| 351 |
|
| 352 |
+
const spotLight = new THREE.SpotLight(0xffffff, 10, 10, Math.PI / 3, 1, 1);
|
| 353 |
+
spotLight.position.set(0, 0, -0.05);
|
| 354 |
spotLight.castShadow = true;
|
| 355 |
spotLight.shadow.mapSize.width = 1024;
|
| 356 |
spotLight.shadow.mapSize.height = 1024;
|
|
|
|
| 359 |
spotLight.shadow.bias = -0.005;
|
| 360 |
lightGroup.add(spotLight);
|
| 361 |
|
| 362 |
+
const lightTarget = new THREE.Object3D();
|
| 363 |
+
lightTarget.position.copy(CENTER);
|
| 364 |
+
scene.add(lightTarget);
|
| 365 |
+
spotLight.target = lightTarget;
|
| 366 |
+
|
| 367 |
scene.add(lightGroup);
|
| 368 |
|
| 369 |
// BLUE: Azimuth ring
|
|
|
|
| 434 |
|
| 435 |
lightGroup.position.set(lightX, lightY, lightZ);
|
| 436 |
lightGroup.lookAt(CENTER);
|
|
|
|
| 437 |
|
| 438 |
azimuthHandle.position.set(AZIMUTH_RADIUS * Math.sin(azRad), 0.05, AZIMUTH_RADIUS * Math.cos(azRad));
|
| 439 |
elevationHandle.position.set(-0.8, ELEVATION_RADIUS * Math.sin(elRad) + CENTER.y, ELEVATION_RADIUS * Math.cos(elRad));
|