Skip to main content

Spawning Templates and Refining Snap-Points

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.

<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

Popular posts from this blog

[FINAL] - Where to find our game

Hello future builders, we're 3 programmer-artists that make up the Seismic Octopus team: Mitchell Koch - lead programmer, game tester, researcher  Priscilla Lo - project manager, sound design, lead 2D artist, programmer, documentation  Maxime Vincent - lead 3D artist, lighting designer, game tester We finished this course in May 2020 with a final release of Build-a-Furniture available on GitHub: https://github.com/Areizza/Build-a-Furniture Although this semester was full of hardships and unprecedented times near the end, we got through it together and are proud to present our simple web-VR game. Check it out and let us know what you think! :)

Catalogue, Sound Effects, JSON for Instructions

This week I updated the image for the catalogue and added it to the Living Room environment as an image plane (~2hrs). I am currently adding smaller clickable planes on top of it to represent the different furniture options to choose to build. A screenshot of this can be seen below. I also looked for some sound effects to use for user feedback (~2hrs) when pieces are combined together correctly, incorrectly, pieces are dropped, etc. These sound files have been added to the shared drive and will be implemented in the code in the next few days. Some example sounds can be listened to at the following links: https://freesound.org/people/NenadSimic/sounds/150879/ https://freesound.org/people/grunz/sounds/109662/ https://freesound.org/people/GabrielAraujo/sounds/242501/ https://freesound.org/people/kirbydx/sounds/175409/  I also worked on adding JSON for the builder.js and finder.js files to store the required information for the instructions (~1hr). An example o...

Building the Shelf and Chairs

With the final submission looming closer, most of my effort was directed at replacing some hard-coded game-play functionality with dynamic data from the Builder and Finder systems (~3 hours), assisting my team with issues they encountered (~2-3 hours), and getting the shelf and chair ready to be built by the players (~8 hours). The Builder and Finder systems still had a few hard-coded values from the Beta build of the project that were specific to constructing the table, so I worked on replacing those with the data that is contained in the instructions arrays that Priscilla and Maxime created this week.  I was initially have problems accessing this array before I discovered that JavaScript arrays can be accessed by string, which simplified it a lot.  Below is an example of the before and after of this process. // Before socket . on ( 'setFurn' , function ( data ) { this . current = data . id ; // Where data.id was always "table" this . step = ...