Introduce sceneOnly flag for components#5465
Merged
dmarcos merged 2 commits intoaframevr:masterfrom Feb 17, 2024
Merged
Conversation
dmarcos
reviewed
Feb 17, 2024
src/core/a-entity.js
Outdated
| // Initialize dependencies first | ||
| this.initComponentDependencies(componentName); | ||
|
|
||
| // If component is sceneOnly check the entity is the scene element |
Member
There was a problem hiding this comment.
Wonder if it would be better to add this logic in the component constructor. Also the multiplicity check below. to keep things tidier here
Contributor
Author
There was a problem hiding this comment.
The component does have all the information needed to perform these checks, so I moved the checks. Inside component.js is now also the only place the sceneOnly and multiple flag are read, which is nice.
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
There are a couple of components intended to be used on
<a-scene>exclusively. These reside insrc/components/scene, but little prevents people from (accidentally) using them on other entities. Only thefogcomponent performed a check that it was applied to the scene.Instead of adding similar checks to all these components, this PR introduces a
sceneOnlyflag that components can set in their definition. Similar to themultipleflag this will throw when asceneOnlycomponent is being added to an entity that isn't the scene.Changes proposed:
sceneOnlyflag in property definitionsceneOnlycomponents are only added to<a-scene>otherwise throw an Error