Skip to the content

Adding Directional Light

  • Adding Directional Light :
    Creates a directional light with a white color and having  intensity of 1setting the position to (0, 5, 0), the light source is placed at the center horizontally x-axis , 5 units above the ground vertically y-axis, and at the center of the scene depth-wise z-axis.Enables the light to cast shadows.Adds the directional light to the scene.

  • Setting ShadowMap :
    Sets the near and far plane distance for the shadow camera. This determines how close and far to the camera shadows will be rendered.


// Adding Directional Light
  const light = new THREE.DirectionalLight( 0xffffff, 1 );
  light.position.set( 0, 5, 0 ); 
  light.castShadow = true; 
  scene.add( light );

//Setting ShadowMap for renderer
  renderer.shadowMap.near = 0.5;
  renderer.shadowMap.far = 500;

About the author

BJ Patel

BJ Patel is an expert user of Umbraco. Always keen to share hints and tips on getting the best out of Umbraco.

comments powered by Disqus

Join Our Community

This is a promo pod

Join Our Community Become a part of our developer community. Share your projects, get feedback, and collaborate with like-minded individuals.

Your contributions help us continue creating valuable content. Consider supporting us by sharing our content.

Junagadh, Gujarat

Latest Blog Posts

Sample

Maui Layouts

Texture

Three.js link

THREE.js

code for cube task 2

TASK section 1

Section 2

Code for cube

Adding 3D object

Cast Shadow

Creating Ground Plane

Directional Light

function stop animate

function showShadow

GUI

adding color

Adding Buttons

THREE.js (1)

Test page Stand

CUBE three.js

Support Us.