[renderer] Add scene component for renderer config.#3424
[renderer] Add scene component for renderer config.#3424dmarcos merged 7 commits intoaframevr:masterfrom donmccurdy:feat-renderer-properties
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.
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? |
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.
We've been doing vars-on-top (declarations only). Though tempted to just adopt prettier :P
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.
can do an early return and keep an indent if (!node.isMesh) { return; }
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.
I guess this check isn't even really needed?
There was a problem hiding this comment.
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.
Can do setAttribute('renderer', 'antialias', !el.isMobile);
Don't need this.name above either, can just be renderer
|
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.