Socket
Socket
Sign inDemoInstall

three-pointer-controls

Package Overview
Dependencies
4
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

87

lib/controls.js

@@ -25,2 +25,6 @@ // Generated by CoffeeScript 1.9.2

this.update = bind(this.update, this);
this.updateCamerasTo = bind(this.updateCamerasTo, this);
this.set = bind(this.set, this);
this.reset = bind(this.reset, this);
this.setHome = bind(this.setHome, this);
this.onMouseWheel = bind(this.onMouseWheel, this);

@@ -33,4 +37,9 @@ this.onPointerUp = bind(this.onPointerUp, this);

this.config = clone(defaults);
this.home = {
target: new THREE.Vector3(),
position: void 0,
up: void 0
};
this.cameras = [];
this.target = new THREE.Vector3();
this.target = this.home.target.clone();
this.state = STATE.NONE;

@@ -48,3 +57,11 @@ this.start = new THREE.Vector2();

PointerControls.prototype.control = function(camera) {
var base, base1;
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();
};

@@ -132,10 +149,46 @@

PointerControls.prototype.update = function() {
var camera, i, len, newOrbit, newRadius, position, ref1;
this.offset.copy(this.cameras[0].position).sub(this.target);
this.target.copy(this.pan.update(this.target));
newRadius = this.dolly.update(this.offset.length());
newOrbit = this.orbit.update(this.offset, this.cameras[0].up);
this.offset.copy(newOrbit.offset).multiplyScalar(newRadius);
position = this.target.clone().add(this.offset);
PointerControls.prototype.setHome = function(arg) {
var position, target, up;
target = arg.target, position = arg.position, up = arg.up;
if (target) {
this.home.target.copy(target);
}
if (position) {
this.home.position.copy(position);
}
if (up) {
this.home.up.copy(up);
}
};
PointerControls.prototype.reset = function() {
this.set(this.home);
};
PointerControls.prototype.set = function(arg) {
var offset, position, target, up;
target = arg.target, position = arg.position, offset = arg.offset, up = arg.up;
this.pan.reset();
this.dolly.reset();
this.orbit.reset();
this.updateCamerasTo.apply(this, arguments);
};
PointerControls.prototype.updateCamerasTo = function(arg) {
var camera, i, len, offset, position, ref1, target, up;
target = arg.target, position = arg.position, offset = arg.offset, up = arg.up;
if (target) {
this.target.copy(target);
}
if (offset) {
if (position == null) {
position = this.target.clone().add(offset);
}
}
if (position == null) {
position = this.cameras[0].position;
}
if (up == null) {
up = this.cameras[0].up;
}
ref1 = this.cameras;

@@ -145,3 +198,3 @@ for (i = 0, len = ref1.length; i < len; i++) {

camera.position.copy(position);
camera.up.copy(newOrbit.up);
camera.up.copy(up);
camera.lookAt(this.target);

@@ -151,2 +204,16 @@ }

PointerControls.prototype.update = function() {
var offset, radius, ref1, target, up;
this.offset.copy(this.cameras[0].position).sub(this.target);
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);
this.updateCamerasTo({
target: target,
offset: this.offset,
up: up
});
};
return PointerControls;

@@ -153,0 +220,0 @@

@@ -15,5 +15,10 @@ // Generated by CoffeeScript 1.9.2

this.getConfig = bind(this.getConfig, this);
this.dolly = 1;
this.reset = bind(this.reset, this);
this.reset();
}
Dolly.prototype.reset = function() {
return this.dolly = 1;
};
Dolly.prototype.getConfig = function() {

@@ -20,0 +25,0 @@ return this.controls.config.dolly;

@@ -14,2 +14,7 @@ // Generated by CoffeeScript 1.9.2

this.getConfig = bind(this.getConfig, this);
this.reset = bind(this.reset, this);
this.reset();
}
Orbit.prototype.reset = function() {
this.delta = {

@@ -19,3 +24,4 @@ yaw: 0,

};
}
return this.totalDelta = void 0;
};

@@ -22,0 +28,0 @@ Orbit.prototype.getConfig = function() {

9

lib/Pan.js

@@ -17,3 +17,8 @@ // Generated by CoffeeScript 1.9.2

this.panBy = bind(this.panBy, this);
this.delta = {
this.reset = bind(this.reset, this);
this.reset();
}
Pan.prototype.reset = function() {
return this.delta = {
x: 0,

@@ -23,3 +28,3 @@ y: 0,

};
}
};

@@ -26,0 +31,0 @@ Pan.prototype.panBy = function(arg) {

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

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc