| | Updating Directional Light | |
| | Author | Message |
---|
Khappa MJ
Posts : 8 Points : 14 Reputation : 0 Join date : 2017-02-10
| Subject: Updating Directional Light Tue Feb 21, 2017 12:18 pm | |
| I have also posted this in Reddit:
I need to dinamycally update DiretionalLight parameters. So, some of them like position, intenstity and color are working properly. Problem is in helper and shadow.camera helper. Here I have these code in a function:
light.shadow.camera.right = newVal; light.shadow.camera.left = -newVal; light.shadow.camera.updateProjectionMatrix();
but it doesnt update light and helper. Any help? Please?
| |
| | | Atrahasis
Posts : 5 Points : 10 Reputation : 1 Join date : 2017-02-17
| Subject: Re: Updating Directional Light Tue Feb 21, 2017 4:07 pm | |
| Your question is about the DirectionnalLightHelper. However the helper is a geometry, with vertices and lines, so if you change the light's camera parameters, you would need to dynamically change the position array of the lines geometry according to your new parameters. Check the DirectionnalLightHelper class for more details. | |
| | | Khappa MJ
Posts : 8 Points : 14 Reputation : 0 Join date : 2017-02-10
| Subject: Re: Updating Directional Light Tue Feb 21, 2017 4:31 pm | |
| Hi Atrahasis and thanks for your reply. I thought about DirectionnalLightHelper but now my question is: once I've created the helper and light and add both to the scene, how can i juts modify light parameters using helper?
In the threejs examples i hadnt find a good example/tut which explains crearly this, do you know if there is some other resource?
Thanks a lot
| |
| | | Atrahasis
Posts : 5 Points : 10 Reputation : 1 Join date : 2017-02-17
| Subject: Re: Updating Directional Light Tue Feb 21, 2017 4:47 pm | |
| I havent found a question about that on stackoverflow either so feel free to ask there. - Quote :
- how can i juts modify light parameters using helper?
The helper is independant, you cannot do that, I think the only way is my previous answer. | |
| | | Khappa MJ
Posts : 8 Points : 14 Reputation : 0 Join date : 2017-02-10
| Subject: Re: Updating Directional Light Tue Feb 21, 2017 4:51 pm | |
| oh... I found this example in threejs documentation: - Code:
-
//Create a WebGLRenderer and turn on shadows in the renderer var renderer = new THREE.WebGLRenderer(); renderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap
//Create a DirectionalLight and turn on shadows for the light var light = new THREE.DirectionalLight( 0xffffff, 1, 100 ); light.position.set( 0, 1, 0 ); //default; light shining from top light.castShadow = true; // default false scene.add( light );
//Set up shadow properties for the light light.shadow.mapSize.width = 512; // default light.shadow.mapSize.height = 512; // default light.shadow.camera.near = 0.5; // default light.shadow.camera.far = 500 // default
//Create a sphere that cast shadows (but does not receive them) var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); sphere.castShadow = true; //default is false sphere.receiveShadow = false; //default scene.add( sphere );
//Create a plane that receives shadows (but does not cast them) var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) var plane = new THREE.Mesh( planeGeometry, planeMaterial ); plane.receiveShadow = true; scene.add( plane );
//Create a helper for the shadow camera (optional) var helper = new THREE.CameraHelper( light.shadow.camera ); scene.add( helper );
What i basically need now is to modify dinamically these parameters in the example above (its the same): light.shadow.camera.near = 0.5; light.shadow.camera.far = 500How is it possible? | |
| | | Sponsored content
| Subject: Re: Updating Directional Light | |
| |
| | | | Updating Directional Light | |
|
Similar topics | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| Our first goal | Mon Feb 27, 2017 10:12 am by Admin | More than 20 users,
almost 150 posts,
a new big project is coming,
about …
| Comments: 0 |
Forum changements | Tue Feb 21, 2017 6:10 pm by Admin | Dear members,
I have personally made some changements into the forum, now …
| Comments: 2 |
A new revision of the forum rules | Tue Feb 07, 2017 9:40 pm by Admin | Dear Members,
it is my pleasure to tell you below all the new functions I …
| Comments: 0 |
Top posting users this week | |
|