PointLightShadow.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. This is used internally by [page:PointLight PointLights] for calculating shadows
  14. </p>
  15. <h2>Example</h2>
  16. <p>
  17. <code>
  18. //Create a WebGLRenderer and turn on shadows in the renderer
  19. var renderer = new THREE.WebGLRenderer();
  20. renderer.shadowMap.enabled = true;
  21. renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap
  22. //Create a PointLight and turn on shadows for the light
  23. var light = new THREE.PointLight( 0xffffff, 1, 100 );
  24. light.position.set( 0, 10, 0 );
  25. light.castShadow = true; // default false
  26. scene.add( light );
  27. //Set up shadow properties for the light
  28. light.shadow.mapSize.width = 512; // default
  29. light.shadow.mapSize.height = 512; // default
  30. light.shadow.camera.near = 0.5; // default
  31. light.shadow.camera.far = 500 // default
  32. //Create a sphere that cast shadows (but does not receive them)
  33. var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 );
  34. var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } );
  35. var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial );
  36. sphere.castShadow = true; //default is false
  37. sphere.receiveShadow = false; //default
  38. scene.add( sphere );
  39. //Create a plane that receives shadows (but does not cast them)
  40. var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 );
  41. var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } )
  42. var plane = new THREE.Mesh( planeGeometry, planeMaterial );
  43. plane.receiveShadow = true;
  44. scene.add( plane );
  45. //Create a helper for the shadow camera (optional)
  46. var helper = new THREE.CameraHelper( light.shadow.camera );
  47. scene.add( helper );
  48. </code>
  49. </p>
  50. <h2>Constructor</h2>
  51. <h3>[name]( )</h3>
  52. <p>
  53. Creates a new [name]. This is not intended to be called directly - it is called
  54. internally by [page:PointLight].
  55. </p>
  56. <h2>Properties</h2>
  57. <p>
  58. See the base [page:LightShadow LightShadow] class for common properties.
  59. </p>
  60. <h2>Methods</h2>
  61. <p>
  62. See the base [page:LightShadow LightShadow] class for common methods.
  63. </p>
  64. <h2>Source</h2>
  65. <p>
  66. [link:https://github.com/mrdoob/three.js/blob/master/src/lights/[name].js src/lights/[name].js]
  67. </p>
  68. </body>
  69. </html>