Git Product home page Git Product logo

aframe's Introduction

A-Frame

A-Frame

A web framework for building virtual reality experiences.

Coverage Status Downloads Version License

SiteDocsSchoolSlackBlogNewsletter

Examples

Supercraft A-Painter Supermedium A-Blast A-Saturday-Night Musical Forest by @googlecreativelab

Find more examples on the homepage, A Week of A-Frame, and WebVR Directory.

Features

👓 Virtual Reality Made Simple: A-Frame handles the 3D and WebXR boilerplate required to get running across platforms including mobile, desktop, and all headsets (compatible with a WebXR capable browser) just by dropping in <a-scene>.

❤️ Declarative HTML: HTML is easy to read and copy-and-paste. Since A-Frame can be used from HTML, A-Frame is accessible to everyone: web developers, VR and AR enthusiasts, educators, artists, makers, kids.

🔌 Entity-Component Architecture: A-Frame is a powerful framework on top of three.js, providing a declarative, composable, reusable entity-component structure for three.js. While A-Frame can be used from HTML, developers have unlimited access to JavaScript, DOM APIs, three.js, WebXR, and WebGL.

Performance: A-Frame is a thin framework on top of three.js. Although A-Frame uses the DOM, A-Frame does not touch the browser layout engine. Performance is a top priority, being battle-tested on highly interactive WebXR experiences.

🌐 Cross-Platform: Build VR and AR applications for any headset compatible with a WebXR capable browser. Don't have a headset or controllers? No problem! A-Frame still works on standard desktop and smartphones.

🔍 Visual Inspector: A-Frame provides a built-in visual 3D inspector with a workflow similar to a browser's developer tools and interface similar to Unity. Open up any A-Frame scene and hit <ctrl> + <alt> + i.

🏃 Features: Hit the ground running with A-Frame's built-in components such as geometries, materials, lights, animations, models, raycasters, shadows, positional audio, tracked controllers. Get even further with community components such as particle systems, physics, multiuser, oceans, mountains, speech recognition, or teleportation!

Usage

Example

Build VR and AR scenes in the browser with just a few lines of HTML! To start playing and publishing now, remix the starter example on:

Remix Fork

<html>
  <head>
    <script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
  </head>
  <body>
    <a-scene>
      <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
      <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
      <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
      <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
      <a-sky color="#ECECEC"></a-sky>
    </a-scene>
  </body>
</html>

With A-Frame's entity-component architecture, we can drop in community components from the ecosystem (e.g., ocean, physics) and plug them into our objects straight from HTML:

Remix Fork

<html>
  <head>
    <script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
    <script src="https://unpkg.com/[email protected]/dist/aframe-particle-system-component.min.js"></script>
    <script src="https://unpkg.com/aframe-extras.ocean@%5E3.5.x/dist/aframe-extras.ocean.min.js"></script>
    <script src="https://unpkg.com/[email protected]/dist/gradientsky.min.js"></script>
  </head>
  <body>
    <a-scene>
      <a-entity id="rain" particle-system="preset: rain; color: #24CAFF; particleCount: 5000"></a-entity>

      <a-entity id="sphere" geometry="primitive: sphere"
                material="color: #EFEFEF; shader: flat"
                position="0 0.15 -5"
                light="type: point; intensity: 5"
                animation="property: position; easing: easeInOutQuad; dir: alternate; dur: 1000; to: 0 -0.10 -5; loop: true"></a-entity>

      <a-entity id="ocean" ocean="density: 20; width: 50; depth: 50; speed: 4"
                material="color: #9CE3F9; opacity: 0.75; metalness: 0; roughness: 1"
                rotation="-90 0 0"></a-entity>

      <a-entity id="sky" geometry="primitive: sphere; radius: 5000"
                material="shader: gradient; topColor: 235 235 245; bottomColor: 185 185 210"
                scale="-1 1 1"></a-entity>

      <a-entity id="light" light="type: ambient; color: #888"></a-entity>
    </a-scene>
  </body>
</html>

Builds

To use the latest stable build of A-Frame, include aframe.min.js:

<head>
  <script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
</head>

To check out the stable and master builds, see the dist/ folder.

npm

npm install --save aframe
# Or yarn add aframe
require('aframe')  // e.g., with Browserify or Webpack.

Local Development

git clone https://github.com/aframevr/aframe.git  # Clone the repository.
cd aframe && npm install  # Install dependencies.
npm start  # Start the local development server.

And open in your browser http://localhost:9000.

Generating Builds

npm run dist

Questions

For questions and support, ask on StackOverflow.

Stay in Touch

And get in touch with the maintainers!

Contributing

Get involved! Check out the Contributing Guide for how to get started.

You can also support development by buying a gorgeous A-Frame t-shirt with exclusive designs

License

This program is free software and is distributed under an MIT License.

aframe's People

Contributors

adarosecannon avatar arpu avatar benjaminleonard avatar brianpeiris avatar caseyyee avatar cemkod avatar cvan avatar darkwing avatar diarmidmackenzie avatar digitec avatar dirkk0 avatar dmarcos avatar donmccurdy avatar fernandojsg avatar machenmusik avatar mattdesl avatar meta-meta avatar mkungla avatar mqp avatar mrxz avatar msimpson avatar ngokevin avatar nylki avatar rspace avatar supermediumbot avatar takahirox avatar thoragio avatar utopiah avatar vincentfretin avatar wmurphyrd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aframe's Issues

[text] word wrapping

I have a very primitive example, but we should take a look at reusing others' previous solutions.

Add model template

Enables devs to add models to their scenes.

Can specify:

  • URL of model
  • Scale (default is 1)
  • Material (default is to display model's own materials. In future we might want to enable dev to specifying a different material to the template, which is copied to all children of the loaded object)

Most model scales are too large for VR. In the original vr-model component, the solution was to multiply the user-specified scale with an internal value. This was set to 0.01. This approach may not be correct, however. We may instead want to evangelize that devs model their scenes in units that work directly with VR's meter scale, without modification (1 to 1).

Can use pre-refactor vr-model component as one reference: https://github.com/MozVR/vr-components/blob/d455bfbfb60bb048906853f615f5af3431aa5bfb/core/vr-model.js

[text] colors

It would be nice to allow the color to be specified via attribute on the vr-text tag.

unable to npm start

➜  vr-components git:(master) npm run build

> @mozvr/[email protected] build /Users/Nicholas/mozilla/vr-components
> mkdir -p build && browserify ./index.js -o build/vr-components.js --debug -s 'vr-components' -t browserify-css

Error: Cannot find module '@mozvr/vr-markup' from '/Users/Nicholas/mozilla/vr-components'
    at /Users/Nicholas/mozilla/vr-components/node_modules/browserify/node_modules/resolve/lib/async.js:46:17
    at process (/Users/Nicholas/mozilla/vr-components/node_modules/browserify/node_modules/resolve/lib/async.js:173:43)
    at ondir (/Users/Nicholas/mozilla/vr-components/node_modules/browserify/node_modules/resolve/lib/async.js:188:17)
    at load (/Users/Nicholas/mozilla/vr-components/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
    at onex (/Users/Nicholas/mozilla/vr-components/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
    at /Users/Nicholas/mozilla/vr-components/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:95:15)

npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/Nicholas/.nvm/versions/node/v0.12.7/bin/node" "/Users/Nicholas/.nvm/versions/node/v0.12.7/bin/npm" "run" "build"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! @mozvr/[email protected] build: `mkdir -p build && browserify ./index.js -o build/vr-components.js --debug -s 'vr-components' -t browserify-css`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @mozvr/[email protected] build script 'mkdir -p build && browserify ./index.js -o build/vr-components.js --debug -s 'vr-components' -t browserify-css'.
npm ERR! This is most likely a problem with the @mozvr/vr-components package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     mkdir -p build && browserify ./index.js -o build/vr-components.js --debug -s 'vr-components' -t browserify-css
npm ERR! You can get their info via:
npm ERR!     npm owner ls @mozvr/vr-components
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Nicholas/mozilla/vr-components/npm-debug.log

Add skybox primitive

Enables devs to add skies to their scenes.

Dev can specify:

  • URL of textures
  • Radius (default should be very large (eg 5000) but less than default camera far clipping plane distance)
  • Segments (number of times skybox box geometry is divided. Am not sure we need this).
  • Color
  • Effected by fog (boolean, default false)

URL of textures works as follows:

<a-skybox url="images/city/city">

The template then looks inside the directory specified for six images with the city filename and ending with top, bottom, left, right, front, back, respectively. Am not married to this implementation, but it worked well in the original pre-refactor skybox component.

By default the color is transparent, so that a PNG with transparency will appear comped against the background. When then user specifies a color value, the image instead appears comped against this color. The color is also visible while the image is being loaded, or if an image is not specified.

Add image template

Enables devs to add images to their scenes.

Feature set is analogous to pre-refactor component. Dev can specify:

  • URL of image to load
  • Width / height (default is empty, and matches image width/height ratio, with max of 1m)
  • Color (default empty (transparent))
  • Opacity (default 1)

By default the color is transparent, so that a PNG with transparency will appear comped against the background. When then user specifies a color value, the image instead appears comped against this color.

While the image is loading, nothing is visible (can look at adding preloaders and/or placeholders in the future).

Add 360° video player template

Enables devs to create 360° video players.

Features should be in line with what we had in pre-refactor <vr-video> and <vr-video360> components, and with the HTML5 <video> spec.

Dev can specify:

  • Video source
  • Autoplay boolean
  • Looping boolean
  • Height
  • Width
  • Muted boolean
  • Controls boolean (shows or hides controls for playback)

Please add anything missing from the above. Looking at the <video> element spec, I'm not sure how important autobuffer, crossorigin, and poster are, for example.

While the image is loading, nothing is visible. Should look at adding preloaders and/or placeholders in the future.

Get npm private account working again

My CC on file with npm changed. I updated with a new card, and npm shows me a success page and says everything's working. But when I go to npm publish after doing npm login with the mozvr account, no 🎲.

npm ERR! You need a paid account to perform this action. For more info, visit: https://www.npmjs.com/private-modules (2KB)

Here's a workaround until I hear back from npm support folks:

Simply git pull both projects and run these two npm link commands.

Add cylinder template

Enables devs to add cylinders to their scenes.

Dev can specify:

  • Radius (default 0.5)
  • Height (default 1)
  • Radius segments (default 36)
  • Height segments (default 4)
  • Open ended (determines whether caps are added to the cylinder. Default true)

Add sound primitive

Enables devs to add audio to their scenes.

User can specify:

  • Source URL
  • Position of sound
  • Bounding box and falloff (not sure how to articulate this in values)
  • Loop / play-once
  • User triggered (true/false. If true, sound is played when user enters bounding box)

@nickdesaulniers created a component for this under the original architecture. We may be able to re-use some of that logic?

Is dependent on (or related to?) https://github.com/MozVR/vr-markup/issues/255

Determine a way to prevent objects in template code from getting executed

Need to figure out a way to do this:

<template>
  <p>Hi, my name is ${name}.</p>
</template>

```js
var t = document.querySelector('template');
var newHTML = t.innerHTML.replace('${name}', 'seavan');  // This is equivalent to where we do string replacements for variables.

var d = document.createElement('div');
d.innerHTML = newHTML;
document.body.appendChild(d);

Code in <template> elements is not supposed to get executed (i.e., is not live). But because the <template> code has to be parsed to do string replacement.

Add skysphere template

Enables devs to add skies to their scenes.

Dev can specify:

  • URL of texture (equirectangular 2:1 will be the best practice)
  • Radius (default should be very large (eg 5000) but less than default camera far clipping plane distance)
  • Horizontal segments (lower priority. Can provide sane default initially)
  • Vertical segments (lower priority. Can provide sane default initially)
  • Color
  • Effected by fog (boolean, default false)

By default the color is transparent, so that a PNG with transparency will appear comped against the background. When then user specifies a color value, the image instead appears comped against this color. The color is also visible while the image is being loaded, or if an image is not specified.

[text] SDF for crisp fonts

We should generate signed distance fields for crisp font rendering at all magnifications and orientations.

Resolve material URLs from template definition source

How it works today:

vr-components/examples/_templates/skysphere/vr-skysphere.html

<template is="vr-template" name="vr-skysphere" radius="5000" url="default.jpg">
  <vr-object geometry="primitive: sphere; segments: 54; radius: ${radius}" material="url: ${url}"></vr-object>
</template>

vr-components/examples/skysphere/index.html

<vr-skysphere position="0 0 0" url="../_images/panos/city.jpg"></vr-skysphere>

How it should work:

vr-components/examples/_templates/skysphere/vr-skysphere.html

<template is="vr-template" name="vr-skysphere" radius="5000" url="../../skysphere/default.jpg">
  <vr-object geometry="primitive: sphere; segments: 54; radius: ${radius}" material="url: ${url}"></vr-object>
</template>

If a url is passed from <vr-skysphere> instance, we use that URL relative to the location of the HTML document. That's what we're today, and that's fine.

But if a url is not passed and we use the default url defined in the import source, we should resolve those URLs from the location of the HTML import document.

I'm on the fence about making this change because it's kind of weird and inconsistent from a default vs override passed POV, but it is probably a more sane expected default. Perhaps we could accept some type of basepath attribute that would change the base root path of any URLs used inside the template definition. Thoughts?

vr-image default geometry size should match loaded image proportions

Enables devs to simply define an image with src and get a nice result. They can then either use scale or size attributes to adjust as desired.

Currently the defaults are:

var width = this.getAttribute('width', 10);
var height = this.getAttribute('height', 10);

We should wait until the image is loaded, derive the dimensions, create the geometry, then add to the scene.

Add cube template

Enables devs to add cubes to their scenes.

Dev can specify:

  • Width (default 1)
  • Height (default 1)
  • Depth (default 1)

Add grid primitive

Enables the dev to add a grid to their scenes.

Dev can specify:

  • Color (default is gray)
  • Size (width and height of grid in meters. Default is 10)
  • Density (number of horizontal and vertical segments in the grid. Default is 10).

Add sphere template

Enables devs to add cylinders to their scenes.

Dev can specify:

  • Radius (default .5)
  • Horizontal segments (default 36)
  • Height segments (default 18)

Allow composed DOM subtrees to be toggled via a `subtree` attribute/component

<vr-scene>
  <vr-box color="green" position="0 2 0" rotation="-45 45 0"></vr-box>
</vr-scene>

<vr-element name="vr-box">
  <template>
    <vr-object mixin="cube" position="${position}" rotation="${rotation}" material="color: ${color}"></vr-object>
  </template>
</vr-element>

results in this composed (rendered) DOM:

<vr-scene>
  <vr-box color="green">
    <vr-object mixin="cube"  position="0 2 0" rotation="-45 45 0" color="green"></vr-object>
  </vr-box>
</vr-scene>

<vr-element name="vr-box">
  <template>
    <vr-object mixin="cube" position="${position}" rotation="${rotation}" material="color: ${color}"></vr-object>
  </template>
</vr-element>

with shadow DOM, it could be:

<vr-scene>
  <vr-box color="green">
  </vr-box>
</vr-scene>

<vr-element name="vr-box">
  <template>
    <vr-object mixin="cube" position="${position}" rotation="${rotation}" material="color: ${color}"></vr-object>
  </template>
</vr-element>

this bug is to toggle the subtree not to use shadow DOM (which requires quite a hefty polyfill for non-Chrome browsers):

<vr-scene>
  <vr-box color="green" subtree="false"></vr-box>
</vr-scene>

<vr-element name="vr-box">
  <template>
    <vr-object mixin="cube" position="${position}" rotation="${rotation}" material="color: ${color}"></vr-object>
  </template>
</vr-element>

compared with the following:

<vr-scene>
  <vr-box color="green" subtree="true">
    <vr-object mixin="cube"  position="0 2 0" rotation="-45 45 0" color="green"></vr-object>
  </vr-box>
</vr-scene>

<vr-element name="vr-box">
  <template>
    <vr-object mixin="cube" position="${position}" rotation="${rotation}" material="color: ${color}"></vr-object>
  </template>
</vr-element>

glsl shaders broke browserify

ngokevin/aframe-core#237 introduced a new browserify transform for .glsl files.

Because our browserify build isn't using that transform, stuff breaks:

% npm start                                                      /opt/vr-components (master)

> @mozvr/[email protected] start /opt/vr-components
> npm run dev


> @mozvr/[email protected] dev /opt/vr-components
> npm run build && budo index.js:build/vr-components.js --debug -v --port 9000 --onupdate 'semistandard -v $(git ls-files '*.js') | snazzy' -- -s 'vr-components' -t browserify-css | garnish -v


> @mozvr/[email protected] build /opt/vr-components
> mkdir -p build/ && npm run browserify -- --debug -o build/vr-components.js


> @mozvr/[email protected] browserify /opt/vr-components
> browserify ./index.js -s 'vr-components' -t browserify-css "--debug" "-o" "build/vr-components.js"


/opt/vr-markup/src/shaders/pbrFragment.glsl:4
#define PI 3.14159265359
^
ParseError: Unexpected character '#'

Add plane template

Enables devs to add planes to their scenes.

Dev can specify:

  • Width (default 1)
  • Height (default 1)

Planes render "standing up", that is along the X any Y axes. To lie the plane down, the user must rotate it 90°.

May want to enable users to add segments also. eg:

  • Horizontal segments (default 1)
  • Vertical segments (default 1)

Fix `autoplay` + `loop` in video examples

When I did that getAttribute patch, I made autoplay default to false for <vr-video> + <vr-video360>. The examples should at least be autoplay="true" instead of just autoplay. Should fix that.

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.