-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[renderer] Add scene component for renderer config. #3424
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
Conversation
src/core/scene/a-scene.js
Outdated
| * Determines state of various renderer properties. | ||
| * This could be done by a component, but it's important | ||
| * to know the values when the renderer is created, so | ||
| * that materials don't need to be recompiled. |
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.
Correction: we only need to know antialias up front.
|
I would try using |
|
Would you want to roll antialias into that, or leave it as-is? Other than that a “real” component would be fine. |
|
Yeah, we can roll anti-alias into that, and deprecate the current |
|
Ok, implemented |
|
Looks good. There's no problem with the component setting up too late? |
ngokevin
left a comment
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.
noice
src/components/scene/renderer.js
Outdated
|
|
||
| // Default not AA for mobile. | ||
| // NOTE: This default is also applied in a-scene.js. | ||
| var attrString = HTMLElement.prototype.getAttribute.call(el, this.name); |
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.
We've been doing vars-on-top (declarations only). Though tempted to just adopt prettier :P
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.
Done
src/components/scene/renderer.js
Outdated
| if (needsShaderUpdate) { | ||
| warn('Modifying renderer properties at runtime requires shader update and may drop frames.'); | ||
| sceneEl.object3D.traverse(function (node) { | ||
| if (node.isMesh) { |
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.
can do an early return and keep an indent if (!node.isMesh) { return; }
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.
Done
src/components/scene/renderer.js
Outdated
| renderer.physicallyCorrectLights = data.physicallyCorrectLights; | ||
| }, | ||
| update: function (prevData) { | ||
| if (!Object.keys(prevData).length) { return; } |
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.
I guess this check isn't even really needed?
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.
It's needed, update() is called during initialization and we don't want to set .needsUpdate=true unnecessarily.
src/components/scene/renderer.js
Outdated
| // NOTE: This default is also applied in a-scene.js. | ||
| var attrString = HTMLElement.prototype.getAttribute.call(el, this.name); | ||
| if (attrString && !attrString.match(/($|\W)antialias\W/)) { | ||
| el.setAttribute(this.name, {antialias: !el.isMobile}); |
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.
Can do setAttribute('renderer', 'antialias', !el.isMobile);
Don't need this.name above either, can just be renderer
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.
Done
|
Default components are gone on #3490. We need to adapt this PR |
Well, the Having trouble doing a @dmarcos — without default components, the only issue I see is that I can't detect whether the |
|
Resolved the initialization issue by checking |
|
Besides the warning messages. Should we reflect in the docs that antialias cannot be changed after initialization? |
|
Done (and rebased). |
|
Better not to introduce API changes on a minor version. We can deprecate |
|
Thank you! |
Ok, note this PR does log a warning about |
Resolves #666.