What you will learn about WEBVR in Lesson Three:
- Adding, Lights, Shadows and 3D Models
- Physics and Sound
What is an Entity?
A-Frame represents an entity via the
<a-entity> element. As defined in the entity-component-system pattern, entities are placeholder objects to which we plug in components to provide them appearance, behavior, and functionality.
In A-Frame, entities are inherently attached with the position, rotation, and scale components.
For example, we can define an animation that waits 2 seconds before scaling an entity.
<a-animation attribute=”scale” begin=”2000″ to=”2 2 2″></a-animation>
The light component defines the entity as a source of light. Light affects all materials that have not specified a flat shading model with
shader: flat. Note that lights are computationally expensive we should limit the number of lights in a scene.
<a-entity light=“color: #AFA; intensity: 1.5” position=“-1 1 0”></a-entity>
The shadow component enables shadows for an entity and its children. Receiving shadows from surrounding objects and casting shadows onto other objects may (and often should) be allowed independently. Without this component, an entity will not cast nor receive shadows.
this example includes a GLTF model (3D model)
<a-entity light="type:directional; castShadow:true;" position="1 1 1"></a-entity> <a-gltf-model src="tree.gltf" shadow="receive: false"></a-gltf-model>
The sound component defines the entity as a source of sound or audio. The sound component is positional and is thus affected by the components-position.
<a-entity id=“river” geometry=“primitive: plane” material=“color: blue”
position=“-10 0 0” sound=“src: url(river.mp3); autoplay: true”></a-entity>
The physics library is a component for A-Frame physics integration and in this lesson, we will apply it for sound position and interaction.
Example fo an animated sphere including sound interaction:
position=”-3 2 -10″
to: 0 360 0;
sound=”src:#space; on: click; refDistance:4; rolloffFactor:4″></a-sphere>