PointLightShadow.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <!DOCTYPE html>
  2. <html lang="it">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <p class="desc">
  12. Questa classe viene utilizzata internamente da [page:PointLight PointLights] per calcolare le ombre.
  13. </p>
  14. <h2>Codice di Esempio</h2>
  15. <code>
  16. // Crea un WebGLRenderer e attiva le ombre nel renderer
  17. const renderer = new THREE.WebGLRenderer();
  18. renderer.shadowMap.enabled = true;
  19. renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap
  20. // Crea una PointLight e attiva le ombre per la luce
  21. const light = new THREE.PointLight( 0xffffff, 1, 100 );
  22. light.position.set( 0, 10, 4 );
  23. light.castShadow = true; // default false
  24. scene.add( light );
  25. // Imposta le proprietà dell'ombra per la luce
  26. light.shadow.mapSize.width = 512; // default
  27. light.shadow.mapSize.height = 512; // default
  28. light.shadow.camera.near = 0.5; // default
  29. light.shadow.camera.far = 500; // default
  30. // Crea una sfera che proietta le ombre (ma non le riceve)
  31. const sphereGeometry = new THREE.SphereGeometry( 5, 32, 32 );
  32. const sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } );
  33. const sphere = new THREE.Mesh( sphereGeometry, sphereMaterial );
  34. sphere.castShadow = true; //default is false
  35. sphere.receiveShadow = false; //default
  36. scene.add( sphere );
  37. // Crea un piano che riceve le ombre (ma non le proietta)
  38. const planeGeometry = new THREE.PlaneGeometry( 20, 20, 32, 32 );
  39. const planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } )
  40. const plane = new THREE.Mesh( planeGeometry, planeMaterial );
  41. plane.receiveShadow = true;
  42. scene.add( plane );
  43. // Crea un helper per la telecamera ombra (opzionale)
  44. const helper = new THREE.CameraHelper( light.shadow.camera );
  45. scene.add( helper );
  46. </code>
  47. <h2>Costruttore</h2>
  48. <h3>[name]( )</h3>
  49. <p>
  50. Crea una nuova [name]. Questa classe non deve essere chiamata direttamente - viene
  51. chiamata internamente da [page:PointLight].
  52. </p>
  53. <h2>Proprietà</h2>
  54. <p>
  55. Vedi la classe base [page:LightShadow LightShadow] per le proprietà comuni.
  56. </p>
  57. <h3>[property:Boolean isPointLightShadow]</h3>
  58. <p>
  59. Flag di sola lettura per verificare se l'oggetto dato è del tipo [name].
  60. </p>
  61. <h2>Metodi</h2>
  62. <p>
  63. Vedi la classe base [page:LightShadow LightShadow] per i metodi comuni.
  64. </p>
  65. <h3>[method:undefined updateMatrices]( [param:Light light], [param:number viewportIndex])</h3>
  66. <p>
  67. Aggiorna le matrici per la telecamera e l'ombra, utilizzato internamente dal renderer.<br /><br />
  68. light -- la luce per la quale si sta renderizzando l'ombra.<br />
  69. viewportIndex -- calcola la matrice per questo viewport.
  70. </p>
  71. <h2>Source</h2>
  72. <p>
  73. [link:https://github.com/mrdoob/three.js/blob/master/src/lights/[name].js src/lights/[name].js]
  74. </p>
  75. </body>
  76. </html>