Socket
Socket
Sign inDemoInstall

three-pointer-controls

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three-pointer-controls - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

48

lib/controls.js
// Generated by CoffeeScript 1.9.2
(function() {
var BUTTON, Dolly, KEY, Orbit, Pan, STATE, addWheelListener, clone, defaults, preventDefault, ref, registerEventListeners,
var BUTTON, Dolly, KEY, Orbit, Pan, STATE, UP, addWheelListener, clone, defaults, preventDefault, ref, registerEventListeners,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

@@ -20,2 +20,8 @@

UP = {
x: 0,
y: 1,
z: 0
};
module.exports = function(THREE) {

@@ -39,4 +45,6 @@ var PointerControls;

target: new THREE.Vector3(),
position: void 0,
up: void 0
position: new THREE.Vector3(),
up: new THREE.Vector3(),
upToYp: void 0,
ypToUp: void 0
};

@@ -49,3 +57,2 @@ this.cameras = [];

this.delta = new THREE.Vector2();
this.offset = new THREE.Vector3();
this.pan = new Pan(this);

@@ -58,11 +65,10 @@ this.dolly = new Dolly(this);

PointerControls.prototype.control = function(camera) {
var base, base1;
if (!this.cameras.length) {
this.setHome(camera);
}
this.cameras.push(camera);
if ((base = this.home).position == null) {
base.position = camera.position.clone();
}
if ((base1 = this.home).up == null) {
base1.up = camera.up;
}
this.update();
return {
"with": this.listenTo
};
};

@@ -162,2 +168,4 @@

}
this.home.upToYp = new THREE.Quaternion().setFromUnitVectors(this.home.up, UP);
this.home.ypToUp = this.home.upToYp.clone().inverse();
};

@@ -205,11 +213,17 @@

PointerControls.prototype.update = function() {
var offset, radius, ref1, target, up;
this.offset.copy(this.cameras[0].position).sub(this.target);
var o, offset, radius, ref1, target, u, up;
offset = this.cameras[0].position.clone().sub(this.target);
offset.applyQuaternion(this.home.upToYp);
up = this.cameras[0].up.clone();
up.applyQuaternion(this.home.upToYp);
target = this.pan.update(this.target);
radius = this.dolly.update(this.offset.length());
ref1 = this.orbit.update(this.offset, this.cameras[0].up), offset = ref1.offset, up = ref1.up;
this.offset.copy(offset).multiplyScalar(radius);
radius = this.dolly.update(offset.length());
ref1 = this.orbit.update(offset, up), o = ref1.offset, u = ref1.up;
offset.copy(o).multiplyScalar(radius);
up.copy(u);
offset.applyQuaternion(this.home.ypToUp);
up.applyQuaternion(this.home.ypToUp);
this.updateCamerasTo({
target: target,
offset: this.offset,
offset: offset,
up: up

@@ -216,0 +230,0 @@ });

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.2.0",
"version": "0.3.0",
"main": "./lib/controls.js",

@@ -8,0 +8,0 @@ "scripts": {

@@ -8,3 +8,3 @@ # three-pointer-controls

but with [pointer events](http://www.w3.org/TR/pointerevents) instead of
mouse events. See [test](#Testing) for an example.
mouse events. See [test](#testing) for an example.

@@ -28,2 +28,9 @@ ## Usage

or
```js
controls = new PointerControls()
controls.control(camera).with(domElement)
```
## Testing

@@ -30,0 +37,0 @@

@@ -55,4 +55,3 @@ // Generated by CoffeeScript 1.9.0

controls = new PointerControls();
controls.control(camera);
controls.listenTo(document);
controls.control(camera)["with"](document);
addAxis(scene, 0xff0000, new THREE.Vector3(1, 0, 0));

@@ -59,0 +58,0 @@ addAxis(scene, 0x00ff00, new THREE.Vector3(0, 1, 0));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc