Skip to content
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

Introduce sceneOnly flag for components #5465

Merged
merged 2 commits into from
Feb 17, 2024

Conversation

mrxz
Copy link
Contributor

@mrxz mrxz commented Feb 15, 2024

Description:
There are a couple of components intended to be used on <a-scene> exclusively. These reside in src/components/scene, but little prevents people from (accidentally) using them on other entities. Only the fog component performed a check that it was applied to the scene.

Instead of adding similar checks to all these components, this PR introduces a sceneOnly flag that components can set in their definition. Similar to the multiple flag this will throw when a sceneOnly component is being added to an entity that isn't the scene.

Changes proposed:

  • Introduce sceneOnly flag in property definition
  • Verify that sceneOnly components are only added to <a-scene> otherwise throw an Error

@@ -310,6 +310,11 @@ class AEntity extends ANode {
// Initialize dependencies first
this.initComponentDependencies(componentName);

// If component is sceneOnly check the entity is the scene element
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if it would be better to add this logic in the component constructor. Also the multiplicity check below. to keep things tidier here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dmarcos
Copy link
Member

dmarcos commented Feb 17, 2024

Thank you!

@dmarcos dmarcos merged commit 807b1de into aframevr:master Feb 17, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants