This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
OrbitControls provides orbiting for objects around a target
version 2.0.0
license MIT
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 2.0.0
Committed At 2017-05-05 18:59:51 UTC
mkovacs/quaternion 1.0.0 <= v < 2.0.0 1.0.0
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1
elm-community/linear-algebra 1.0.0 <= v < 4.0.0 3.1.2

Modules

README

elm-orbit-controls

An Elm library that provides the ability to orbit an object in space around a target. This library is a port of other orbit control implementations:

Dependencies

This project requires the use of the elm-community/linear-algebra package for Vectors and Matrices.

Documentation

See the generated documentation in the elm package repository

Basic Example

import OrbitControls
import Math.Vector3 exposing (Vec3)

type alias Model = {
  -- You must keep track of the state in your model
  state: OrbitControls.State,

  -- We want to orbit the camera around a target
  cameraPosition: Vec3
}

-- Include a Msg that can receive Orbit events
type Msg =
  OnOrbit OrbitControls.OrbitEvent

init : ( Model, Cmd Msg )
init =
  ( { state = OrbitControls.defaultState }, Cmd.none)

-- Add listeners to the DOM element you are embedding your content in
view : Model -> Html Msg
view model =
  div (OrbitControls.listeners model.state OnOrbit)
      [ WebGL.toHtml ... ]


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
  case msg of
    OnOrbit event ->
      let
        ( updatedCamera, updatedState ) =
          OrbitControls.apply
            event
            ( model.cameraPosition, model.state )

        -- Do something with the new camera position
        ...
      in
        -- Keep track of the updated state
        ( { model | state = updatedState }, Cmd.none )