This past week saw the development of a component for spawning in pieces of furniture with their snap-points already attached (~4 hours), as well as an improvement on the snapping system that removed strange physics behaviour from joined components and increased maintainability (~6 hours). Unfortunately the week was also busy there was less progress on the code than I had hoped for.
Since there will be a lot of different pieces that could be spawned by either the Finder or Builder in the course of a game we needed some way of quickly creating the entities with their snap-point already placed, and they had to be identical for both players. The solution I found involves the aframe-template-component, which allows an entity to pull child elements and attributes from an external storage file. The below code demonstrates the implementation of a template file.
This template file can then be added in the <a-assets> tag and applied to an entity like so:
I do want to see if the templates can be stored in a .json file to reduce the number of files we need to create.
Additionally, I implemented a 'tier' property on the snap-point component that is used to indicate the piece's child/parent relationship to the rest of the furniture pieces. This replaces the "isParent" boolean that was originally used to indicate which piece was the parent. This new property allows for more complex parent/child structures.
With the beta deadline fast approaching the next week will see a dramatic ramp up in the work being completed.
Since there will be a lot of different pieces that could be spawned by either the Finder or Builder in the course of a game we needed some way of quickly creating the entities with their snap-point already placed, and they had to be identical for both players. The solution I found involves the aframe-template-component, which allows an entity to pull child elements and attributes from an external storage file. The below code demonstrates the implementation of a template file.
<a-mixin id="wing" geometry="primitive: box; depth: .005; height: 1; width: 0.5" pivot="0.15 0" material="color: red" scale="0.5 0.625 0.5">
</a-mixin> <a-mixin id="flap" attribute="rotation" direction="alternate" repeat="indefinite">
</a-mixin> <a-entity position="{{ position }}"> <a-animation attribute="rotation" to="0 360 0" dur="3000" easing="linear" repeat="indefinite"></a-animation> <a-entity rotation="0 90 0" position="2.5 -1 0"> <a-entity rotation="-45 0 90"> <a-entity mixin="wing"> <a-animation mixin="flap" to="0 120 10"></a-animation> </a-entity> </a-entity> <a-entity rotation="-45 0 90"> <a-entity mixin="wing"> <a-animation mixin="flap" to="0 -120 10"></a-animation> </a-entity> </a-entity> </a-entity> </a-entity>
This template file can then be added in the <a-assets> tag and applied to an entity like so:
<script id="butterflies" src="butterflies.template"> <a-entity template="src: butterfly.template; type: handlebars" data-position="{{ x * 10 }} 1 {{ z * 10 }}"></a-entity> </script>
I do want to see if the templates can be stored in a .json file to reduce the number of files we need to create.
Additionally, I implemented a 'tier' property on the snap-point component that is used to indicate the piece's child/parent relationship to the rest of the furniture pieces. This replaces the "isParent" boolean that was originally used to indicate which piece was the parent. This new property allows for more complex parent/child structures.
With the beta deadline fast approaching the next week will see a dramatic ramp up in the work being completed.
Comments
Post a Comment