prithivMLmods commited on
Commit
f211d0c
·
verified ·
1 Parent(s): c49bc1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -49
app.py CHANGED
@@ -191,18 +191,19 @@ class LightingControl3D(gr.HTML):
191
  // Lighting
192
  scene.add(new THREE.AmbientLight(0xffffff, 0.1));
193
 
 
 
 
 
 
 
 
 
 
 
194
  // Grid
195
  scene.add(new THREE.GridHelper(8, 16, 0x333333, 0x222222));
196
 
197
- // Floor for shadows
198
- const floorGeometry = new THREE.PlaneGeometry(10, 10);
199
- const floorMaterial = new THREE.ShadowMaterial({ opacity: 0.3 });
200
- const floor = new THREE.Mesh(floorGeometry, floorMaterial);
201
- floor.rotation.x = -Math.PI / 2;
202
- floor.position.y = 0;
203
- floor.receiveShadow = true;
204
- scene.add(floor);
205
-
206
  // Constants
207
  const CENTER = new THREE.Vector3(0, 0.75, 0);
208
  const BASE_DISTANCE = 2.5;
@@ -315,47 +316,21 @@ class LightingControl3D(gr.HTML):
315
  updateTextureFromUrl(props.imageUrl);
316
  }
317
 
318
- // Light model - Enhanced light bulb
319
  const lightGroup = new THREE.Group();
320
-
321
- // Bulb glass
322
- const bulbMat = new THREE.MeshStandardMaterial({
323
- color: 0xffffff,
324
- transparent: true,
325
- opacity: 0.3,
326
- emissive: 0xffff00,
327
- emissiveIntensity: 0.5,
328
- roughness: 0.1,
329
- metalness: 0.1
330
- });
331
- const bulbGeometry = new THREE.SphereGeometry(0.15, 32, 32, 0, Math.PI * 2, 0, Math.PI * 0.8); // Slightly elongated
332
- const bulb = new THREE.Mesh(bulbGeometry, bulbMat);
333
- lightGroup.add(bulb);
334
-
335
- // Bulb base
336
- const baseMat = new THREE.MeshStandardMaterial({ color: 0xaaaaaa, metalness: 0.8, roughness: 0.2 });
337
- const baseGeometry = new THREE.CylinderGeometry(0.08, 0.12, 0.1, 32);
338
- const base = new THREE.Mesh(baseGeometry, baseMat);
339
- base.position.y = -0.15;
340
- lightGroup.add(base);
341
-
342
- // Filament
343
- const filamentMat = new THREE.MeshBasicMaterial({ color: 0xffaa00, wireframe: true });
344
- const filamentGeometry = new THREE.TorusGeometry(0.05, 0.005, 16, 100);
345
- const filament = new THREE.Mesh(filamentGeometry, filamentMat);
346
- filament.rotation.x = Math.PI / 2;
347
- filament.position.y = 0.05;
348
- lightGroup.add(filament);
349
-
350
- // Point light
351
- const pointLight = new THREE.PointLight(0xffffff, 5, 0, 2);
352
- pointLight.castShadow = true;
353
- pointLight.shadow.mapSize.width = 512;
354
- pointLight.shadow.mapSize.height = 512;
355
- pointLight.shadow.camera.near = 0.5;
356
- pointLight.shadow.camera.far = 500;
357
- pointLight.shadow.bias = -0.0001;
358
- lightGroup.add(pointLight);
359
 
360
  scene.add(lightGroup);
361
 
@@ -426,6 +401,8 @@ class LightingControl3D(gr.HTML):
426
  const lightZ = distance * Math.cos(azRad) * Math.cos(elRad);
427
 
428
  lightGroup.position.set(lightX, lightY, lightZ);
 
 
429
 
430
  azimuthHandle.position.set(AZIMUTH_RADIUS * Math.sin(azRad), 0.05, AZIMUTH_RADIUS * Math.cos(azRad));
431
  elevationHandle.position.set(-0.8, ELEVATION_RADIUS * Math.sin(elRad) + CENTER.y, ELEVATION_RADIUS * Math.cos(elRad));
 
191
  // Lighting
192
  scene.add(new THREE.AmbientLight(0xffffff, 0.1));
193
 
194
+ // Ground plane for shadows
195
+ const ground = new THREE.Mesh(
196
+ new THREE.PlaneGeometry(10, 10),
197
+ new THREE.ShadowMaterial({ opacity: 0.3 })
198
+ );
199
+ ground.rotation.x = -Math.PI / 2;
200
+ ground.position.y = 0;
201
+ ground.receiveShadow = true;
202
+ scene.add(ground);
203
+
204
  // Grid
205
  scene.add(new THREE.GridHelper(8, 16, 0x333333, 0x222222));
206
 
 
 
 
 
 
 
 
 
 
207
  // Constants
208
  const CENTER = new THREE.Vector3(0, 0.75, 0);
209
  const BASE_DISTANCE = 2.5;
 
316
  updateTextureFromUrl(props.imageUrl);
317
  }
318
 
319
+ // Studio LED light model
320
  const lightGroup = new THREE.Group();
321
+ const ledMat = new THREE.MeshStandardMaterial({ color: 0xffffff, emissive: 0xffffff, emissiveIntensity: 0.8 });
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 / 4, 0.5, 1);
326
+ spotLight.position.set(0, 0, 0);
327
+ spotLight.castShadow = true;
328
+ spotLight.shadow.mapSize.width = 1024;
329
+ spotLight.shadow.mapSize.height = 1024;
330
+ spotLight.shadow.camera.near = 0.5;
331
+ spotLight.shadow.camera.far = 500;
332
+ spotLight.shadow.bias = -0.005;
333
+ lightGroup.add(spotLight);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
 
335
  scene.add(lightGroup);
336
 
 
401
  const lightZ = distance * Math.cos(azRad) * Math.cos(elRad);
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));