New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow directional lights to automatically follow shadows #5025
Conversation
TODO: Update renderer docs and update material docs |
Can we break exposure and auto shadows in two PRs? Sorry for the extra work. It will make for a more clear changelog and easier to debug in the future if there are any issues |
sure, i'll leave this one for shadows and make a new one for exposure related bits |
81ec901
to
59d8a5f
Compare
@@ -15,6 +15,7 @@ registerPrimitive('a-light', { | |||
penumbra: 'light.penumbra', | |||
type: 'light.type', | |||
target: 'light.target', | |||
envmap: 'light.envMap' | |||
envmap: 'light.envMap', | |||
'auto-shadow-cam': 'light.shadowCameraAutoTarget' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camel case for consistency with property names convention and probably avoid shortening automaticShadowCameraTarget
makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
c83d7e8
to
8351215
Compare
I updated the name to be |
src/components/light.js
Outdated
@@ -11,6 +11,23 @@ var CubeLoader = new THREE.CubeTextureLoader(); | |||
|
|||
var probeCache = {}; | |||
|
|||
function distanceOfPointFromPlane (positionOnPlane, planeNormal, p1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe factor out into utils/math.js to keep this tidier.
src/components/light.js
Outdated
@@ -146,6 +172,50 @@ module.exports.Component = registerComponent('light', { | |||
this.updateShadow(); | |||
}, | |||
|
|||
tick: (function tickSetup () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to name this function
src/components/light.js
Outdated
var sphere = new THREE.Sphere(); | ||
var tempVector = new THREE.Vector3(); | ||
|
||
return function tick () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to name this function
src/components/light.js
Outdated
var tempVector = new THREE.Vector3(); | ||
|
||
return function tick () { | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyway to simplify this condition and do an early return for readability?
if (XXX) { return; }
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Hello, World! • A-Frame</title> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, AR World!
perhaps to differentiate
<head> | ||
<meta charset="utf-8"> | ||
<title>Hello, World! • A-Frame</title> | ||
<meta name="description" content="Hello, World! • A-Frame"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, AR World!
perhaps
src/utils/math.js
Outdated
* @param {THREE.Vector3} p1 point to test | ||
* @returns Number | ||
*/ | ||
function distanceOfPointFromPlane (positionOnPlane, planeNormal, p1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pointToTest
instead of p1
src/utils/math.js
Outdated
* @param {THREE.Vector3} out where to store the result. | ||
* @returns | ||
*/ | ||
function nearestPointInPlane (positionOnPlane, planeNormal, p1, out) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pointToTest
instead of p1
resultPoint
Fixed, sorry for the delay. |
Thanks so much for the patience! I really appreciate. This is awesome work. Thanks soooo much! Have a nice wekend. |
Description:
To make AR look believable it really helps to have tone mapping and have shadows that show on the real floor.
Unfortunately when you place an AR object it's easy to leave the region covered by the shadow map. This PR adds the ability to
allow the light's shadow map to automatically follow a particular 3D model to ensure it always has a good shadow.
Changes proposed:
shadowCamAutoTarget
to light for Directional lights andauto-shadow-cam
to<a-light>
In the image above both Torus Knots are pure white but the one on the left has
toneMapped:false
to still displays brightly.There is a link to the live demo so you can see how the AR looks: https://ada-aframe-test.glitch.me/
The example included in this relies on #5029