Giter VIP home page Giter VIP logo

aframe-look-at-billboard-component's Introduction

aframe-look-at-component

Components for A-Frame to tell an entity to face towards another entity or position (look-at), or face the active camera (billboard). Uses three.js's Object3D .lookAt()

The look-at component defines the behavior for an entity to dynamically rotate or face towards another entity or position. The rotation of the entity will be updated on every tick. The look-at component takes a src parameter containing either a vec3 position or a query selector to another entity in it's src parameter, and flags to control it's runtime behavior. The checkSrcEveryFrame flag controls whether the component re-evaluates the query selector each frame, useful if the result of the selector may change over time. This is false by default. The updateWorldTransform flag controls whether the component updates the worldTransform on the underlying THREE.Object3D each frame, or uses the already computed value. This is false by default, since the worst case is that the value from the previous frame will be used (which in many cases is not noticable), and extra updates may be computationally non-trivial (depending on the size of the scene graph). However, if you want to guarantee the current, correct value is used, set this flag.

The billboard component behaves similarly to look-at, but always faces the entity toward the current camera. It takes no parameters.

Values

The attribute values of the look-at component are as follows.

Name Type Description
src selector A query selector indicating another entity to track. If the other entity is moving then the look-at component will track the moving entity.
vec3 An XYZ coordinate. The entity will face towards a static position.
checkSrcEveryFrame boolean whether to re-evaluate the src selector each frame
updateWorldTransform boolean whether to re-compute the underlying Object3D worldTransform

Usage

Browser Installation

Install and use by directly including the browser files:

<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/0.2.0/aframe.min.js"></script>
  <script src="https://rawgit.com/blairmacintyre/aframe-look-at-billboard-component/master/dist/aframe-look-at-billboard-component.min.js"></script>
</head>

<body>
  <a-scene>
    <a-entity id="monster" geometry="primitive: box" material="src: url(monster.png)"
              billboard></a-entity>
    <a-entity id="player" camera></a-entity>

    <a-entity id="dog" geometry="primitive: box" material="src: url(dog.png)"
              look-at="src: #squirrel"></a-entity>
    <a-entity id="squirrel">
      <a-animation id="running" attribute="position" to="100 0 0"></a-animation>
    </a-entity>
  </a-scene>
</body>

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.