Search code examples
design-patternsarchitecturecomponentsaframeamazon-ecs

What is the best way to have multiple components of a single type?


For example I want to generalize my existing trigger box component.

I use currently it the following way

<a-camera triggerbox="triggereventname: mytriggerbox"></a-camera> 

but instead I would like to be able to have

<a-camera triggerbox1="triggereventname: SmTB; x0: -20; y0: 0; z0: -20; "
triggerbox2="triggereventname: LgTB; width: 10; height: 10; depth: 10;"
></a-camera> 

and have multiple trigger boxes, not just one, attached to the camera (or any other element).

Unfortunately all the solutions I think of (e.g. re-registering the component with different names for each instance) are horribly ugly. What is the proper way to solve this?


Solution

  • Correct, it will be part of the component API in 0.3.0:

    Here is the master documentation: https://aframe.io/docs/master/core/component.html#multiple-instancing