Coder Social home page Coder Social logo

aframe-camera-controls's Introduction

aframe-camera-controls

A-frame plugins for Camera-controls.

READ CAREFULLY

This is just a quick'n'dirty (literally nothing more than a copy'n'paste, do not expect nothing classy guys) implementation of Threejs camera controls Plugin as A-frame component. The base is the awesome Superframe (ex-kframe) orbit-controls plugin

Basic Usage

Add the component to the camera element:

<a-entity
  id="the-camera"
  cameracontrols="initialPosition: 3.5909066036114665 1.5843741492086918 5.575048598071086; dollySpeed: 1; truckSpeed: 2; minPolarAngle: 20; maxPolarAngle: 105; minDistance: 5; maxDistance: 11; dampingFactor: 0.08; target: #the-element-we-are-looking-at;"
  camera="zoom: 1;"
  position="0 0 0"
  rotation="0 0 0">
</a-entity>

... move the camera as you want, then get the current position:

let position = document.querySelector('#the-camera').components.cameracontrols.cameraControls.toJSON();

Animate the camera to a position:

document.querySelector('#the-camera').components.cameracontrols.cameraControls.fromJSON( JSON.stringify( position ), true);

Example of a position value:

{
  "enabled": true,
  "minDistance": 0,
  "maxDistance": 1.7976931348623e+308,
  "minPolarAngle": 0,
  "maxPolarAngle": 3.1415926535898,
  "minAzimuthAngle": -1.7976931348623e+308,
  "maxAzimuthAngle": 1.7976931348623e+308,
  "dampingFactor": 0.05,
  "draggingDampingFactor": 0.25,
  "dollySpeed": 1,
  "truckSpeed": 2,
  "target": [-0.37917888854706, -0.47959704424181, -0.13915770200862],
  "position": [-4.613750653072203, 4.525158764957159, 2.224967126484331],
  "target0": [0, 0, 0],
  "position0": [0, 2, 0]
}

aframe-camera-controls's People

Contributors

strae avatar

Watchers

 avatar

Forkers

hassadee

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.