npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

threeleapcontrols

v1.0.1

Published

Camera and objects controls which you can use with your Leap Motion controller to rotate, zoom / scale and pan any camera or object in your 3D scene.

Downloads

3

Readme

threeleapcontrols

Introduction

Three.js provides several control classes in order to interact with your 3D world. They are located under three.js/examples/js/controls in your Three.js directory. With threeleapcontrols you can use your leap motion controller to rotate, zoom/scale and pan any camera or object in your 3D scene.

Requirements

  • a leap motion controller
  • leapjs (javascript sdk for leap motion controller)
  • Three.js (javascript library for creating and displaying 3D computer graphics on a browser)
  • a browser which supports WebGL, e.g. Google Chrome

Showcase

Check out the example file example.html and/or see it in action here.

Usage

First, you load the necessary javascript files in your HTML document

<script src="three.min.js"></script>
<script src="leap.min.js"></script>
<script src="LeapCameraControls.js"></script>

You create a scene, a camera and a renderer with Three.js. Then connect your camera of your scene with leap camera controls by setting

cameraControls = new THREE.LeapCameraControls(camera);

In your Leap.loop you need to call the update method on frame. After that it is necessary to render again.

Leap.loop(function(frame){
  // maybe some modifications to your scene
  // ...

  cameraControls.update(frame); // rotating, zooming & panning
  renderer.render(scene, camera);
});

In order to rotate, scale and pan an arbitrary object in your scene, load the leap object controls

<script src="LeapObjectControls.js"></script>

and then connect the camera and your object, e.g. a cube by

cubeControls = new THREE.LeapObjectControls(camera, cube);

The corresponding Leap.loop looks like

Leap.loop(function(frame){
  // maybe some modifications to your scene
  // ...

  cubeControls.update(frame); // rotating, scaling & panning
  renderer.render(scene, camera);
});

Note: Rotating objects with LeapObjectControls is work in progress and not yet finished!

Configuration

There are several options for your camera actions rotate, zoom and pan available. Here, we are setting the pan options (you can set the same attributes for rotating and panning):

controls.panEnabled      = true;
controls.panSpeed        = 1.0;
controls.panHands        = 2;
controls.panFingers      = [6, 12];
controls.panRightHanded  = true; // right-handed
controls.panHandPosition = true; // palm position used
controls.panStabilized   = true; // stabilized palm position used

You can disable panning by setting panEnabled to false. Increase or decrease the speed of panning by adjusting panSpeed. You can set the number of hands with option panHands, i.e. the gesture is only triggered if the number of hands over your leap is equal to the specified panHands. It is possible to use a range of numbers (array of length 2 with integers), e.g. if [1, 2] is given, panning will be done, if one or two hands are used. The same goes for panFingers. If you set panHands to 2, then you can specify via panRightHanded, which hand will be used for controlling the camera. If you set panFingers to 1 or [1, 1] and panHandPosition to false, then the position of your finger tip will be used (instead of the position of your palm). If you set panStabilized to true the stabilized palm or finger tip position is used.

By default vertical rotating is bounded to a range of π, meaning the angle between the camera-to-target vector and the y-axis is greater than 0 and less than π. You can modify the range by setting rotateMin and rotateMax. Horizontal rotating is not limited.

You can set the minimum and maximum distances for zooming with zoomMin and zoomMax.

The default values are

// rotation
this.rotateEnabled       = true;
this.rotateSpeed         = 1.0;
this.rotateHands         = 1;
this.rotateFingers       = [2, 3]; 
this.rotateRightHanded   = true;
this.rotateHandPosition  = true;
this.rotateStabilized    = false;
this.rotateMin           = 0;
this.rotateMax           = Math.PI;

// zoom
this.zoomEnabled         = true;
this.zoomSpeed           = 1.0;
this.zoomHands           = 1;
this.zoomFingers         = [4, 5];
this.zoomRightHanded     = true;
this.zoomHandPosition    = true;
this.zoomStabilized      = false;
this.zoomMin             = _this.camera.near;
this.zoomMax             = _this.camera.far;

// pan
this.panEnabled          = true;
this.panSpeed            = 1.0;
this.panHands            = 2;
this.panFingers          = [6, 12];
this.panRightHanded      = true;
this.panHandPosition     = true;
this.panStabilized       = false;

In your leap object controls the zoom options are scale options, i.e. zoomEnabled will be scaleEnabled, etc..