An open API service indexing awesome lists of open source software.

https://github.com/danielgamage/stereo-convergence

Viewer for stereoscopic images and video
https://github.com/danielgamage/stereo-convergence

stereoscopy

Last synced: 11 months ago
JSON representation

Viewer for stereoscopic images and video

Awesome Lists containing this project

README

          

![Stereo Convergence example](http://i.giphy.com/3o6ozDEG1tnY7hmbsc.gif)

# Stereo Convergence

[![npm](https://img.shields.io/npm/v/stereo-convergence.svg?maxAge=864000)](https://www.npmjs.com/package/stereo-convergence)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/danielgamage/stereo-convergence/master/LICENSE.md)
[![David](https://img.shields.io/david/dev/danielgamage/stereo-convergence.svg?maxAge=2592000)]()

2D javascript stereoscopic viewer.

## Installation

#### npm
```bash
npm install --save stereo-convergence
```

## Usage

Convergence requires a container element with two child elements for each eye, each with some sort of unique identifier.

#### Basic

```html




...

// select StereoConvergence containers
var playerEl = document.querySelector('[data-stereo-player]')

// store instance in variable for further manipulation
var stereoPlayer = new StereoConvergence({player: playerEl})

// initialize instance
stereoPlayer.init()

```

But this may be an oversimplified example. If you have more than one player, you need to initialize for each element. You may also want to manage configuration in javascript. To do this, pass an `options` object:

#### Advanced

```html

let globalOptions = {
left: '.stereo-convergence__eye--left',
right: '.stereo-convergence__eye--right',
clip: false
}

let playerEls = document.querySelectorAll('.stereo-convergence')
let instances = []

// NodeList → Array & loop through items
[...playerEls].map((el, i) => {

let localOptions = {
// you can hypothetically fetch options dynamically
player: el,
min: data.players[i].min,
max: data.players[i].max
}

// A. use the spread operator (...) to dump the two options objects into one object argument for StereoConvergence
// B. store each instance in an array for further manipulation
instances[i] = new StereoConvergence({...localOptions, ...globalOptions})
instances[i].init()
})

```

## Properties

#### `player`

_Object_: DOM element | **Required**

Valueless attribute denotes container element to base image positioning from.

#### `left`
#### `right`

_String_: CSS selector

`left` Default: `'[data-stereo-eye="left"]'`

`right` Default: `'[data-stereo-eye="right"]'`

Two properties, `left` and `right`, denote a selector to query via `querySelector` within the player. **There should only be two eyes**.

```js
left: '[data-stereo-eye="left"]'
right: '[data-stereo-eye="right"]'
```

#### `min`

_Number_: Float

Default: `-1`

Property adjusts the minimum divergence as a percentage of the image width.

#### `max`

_Number_: Float

Default: `1`

Property adjusts the maximum divergence as a percentage of the image width.

#### `clip`

_Boolean_

Default: `true`

Extends the images by the maximum distance the images can shift from center during interaction (ie, the largest absolute value between `min` and `max`), removing gaps from the edges of the stereo-player during interaction.