GithubHelp home page GithubHelp logo

agoblinking / aframe-template-component Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 4.0 4.37 MB

Templating component for A-Frame VR. Handlebars.js/Jade/mustache.js/Nunjucks.

Home Page: http://ngokevin.github.io/aframe-template-component/

License: MIT License

JavaScript 100.00%

aframe-template-component's Introduction

aframe-template-component

Once the component API is validated, expect this to be pulled into A-Frame as a standard component.

A template component for A-Frame VR.

Features:

  • Agnostic template engine support, choose from popular templating engines
  • Rendering templates before, at the beginning, at the end, or after entities
  • Loading templates defined within script tags
  • Loading external templates
  • Lazy-loading template engines

template

Supports:

Planned:

Properties

Property Description
src Selector to a <script template> element or a URL to an external template file.
insert Where to insert the rendered HTML using insertAdjacentHTML
type Type of templating engine to use

Local context variables for the template are passed through the element's dataset.

Usage

Browser Installation

Install and use by directly including the browser files:

<head>
  <title>My A-Frame Scene</title>
  <script src="https://rawgit.com/aframevr/aframe/dev/dist/aframe.min.js"></script>
  <script src="https://rawgit.com/ngokevin/aframe-template-component/dev/dist/aframe-template-component.min.js"></script>
</head>

<body>
  <a-scene>
    <a-assets>
      <script id="butterflies" type="text/x-nunjucks-template">
        {% for x in range(0, 10) %}
          {% for z in range(0, 10) %}
            <a-entity template="src: butterfly.template; type: handlebars"
                      data-position="{{ x * 10 }} 1 {{ z * 10 }}"></a-entity>
          {% endfor %}
        {% endfor %}
      </script>

      <script id="forest" type="text/x-nunjucks-template">
        {% for x in range(0, 10) %}
          {% for z in range(0, 10) %}
            <a-entity template="src: tree.template; type: handlebars"
                      data-position="{{ x * 10 }} 0 {{ z * 10 }}"
                      data-trunkcolor="#623B1C"></a-entity>
          {% endfor %}
        {% endfor %}
      </script>

      <script id="clouds" type="text/x-jade-template">
        - for (var x = 0; x < 5; x++) {
          - for (var z = 0; z < 5; z++) {
            a-entity(geometry="primitive: box; depth: 8; height: 1; width: 6", material="opacity: 0.2", position="#{x * 20} 15 #{z * 20}")
          - }
        - }
      </script>
    </a-assets>

    <a-entity template="src: #forest"></a-entity>
    <a-entity template="src: #butterflies"></a-entity>
    <a-entity template="src: #clouds"></a-entity>
  </a-scene>
</body>

NPM Installation

Install via NPM:

npm install aframe-template-component

Then register and use.

var AFRAME = require('aframe');
var templateComponent = require('aframe-template-component').Component;
AFRAME.registerComponent('template', templateComponent);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.