webvr js meetup initial commit
This commit is contained in:
111
node_modules/three/examples/js/controls/DeviceOrientationControls.js
generated
vendored
Normal file
111
node_modules/three/examples/js/controls/DeviceOrientationControls.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* @author richt / http://richt.me
|
||||
* @author WestLangley / http://github.com/WestLangley
|
||||
*
|
||||
* W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)
|
||||
*/
|
||||
|
||||
THREE.DeviceOrientationControls = function( object ) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
this.object = object;
|
||||
this.object.rotation.reorder( "YXZ" );
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.deviceOrientation = {};
|
||||
this.screenOrientation = 0;
|
||||
|
||||
this.alpha = 0;
|
||||
this.alphaOffsetAngle = 0;
|
||||
|
||||
|
||||
var onDeviceOrientationChangeEvent = function( event ) {
|
||||
|
||||
scope.deviceOrientation = event;
|
||||
|
||||
};
|
||||
|
||||
var onScreenOrientationChangeEvent = function() {
|
||||
|
||||
scope.screenOrientation = window.orientation || 0;
|
||||
|
||||
};
|
||||
|
||||
// The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''
|
||||
|
||||
var setObjectQuaternion = function() {
|
||||
|
||||
var zee = new THREE.Vector3( 0, 0, 1 );
|
||||
|
||||
var euler = new THREE.Euler();
|
||||
|
||||
var q0 = new THREE.Quaternion();
|
||||
|
||||
var q1 = new THREE.Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis
|
||||
|
||||
return function( quaternion, alpha, beta, gamma, orient ) {
|
||||
|
||||
euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us
|
||||
|
||||
quaternion.setFromEuler( euler ); // orient the device
|
||||
|
||||
quaternion.multiply( q1 ); // camera looks out the back of the device, not the top
|
||||
|
||||
quaternion.multiply( q0.setFromAxisAngle( zee, - orient ) ); // adjust for screen orientation
|
||||
|
||||
}
|
||||
|
||||
}();
|
||||
|
||||
this.connect = function() {
|
||||
|
||||
onScreenOrientationChangeEvent(); // run once on load
|
||||
|
||||
window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
|
||||
window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
|
||||
|
||||
scope.enabled = true;
|
||||
|
||||
};
|
||||
|
||||
this.disconnect = function() {
|
||||
|
||||
window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
|
||||
window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
|
||||
|
||||
scope.enabled = false;
|
||||
|
||||
};
|
||||
|
||||
this.update = function() {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
var alpha = scope.deviceOrientation.alpha ? THREE.Math.degToRad( scope.deviceOrientation.alpha ) + this.alphaOffsetAngle : 0; // Z
|
||||
var beta = scope.deviceOrientation.beta ? THREE.Math.degToRad( scope.deviceOrientation.beta ) : 0; // X'
|
||||
var gamma = scope.deviceOrientation.gamma ? THREE.Math.degToRad( scope.deviceOrientation.gamma ) : 0; // Y''
|
||||
var orient = scope.screenOrientation ? THREE.Math.degToRad( scope.screenOrientation ) : 0; // O
|
||||
|
||||
setObjectQuaternion( scope.object.quaternion, alpha, beta, gamma, orient );
|
||||
this.alpha = alpha;
|
||||
|
||||
};
|
||||
|
||||
this.updateAlphaOffsetAngle = function( angle ) {
|
||||
|
||||
this.alphaOffsetAngle = angle;
|
||||
this.update();
|
||||
|
||||
};
|
||||
|
||||
this.dispose = function() {
|
||||
|
||||
this.disconnect();
|
||||
|
||||
};
|
||||
|
||||
this.connect();
|
||||
|
||||
};
|
||||
193
node_modules/three/examples/js/controls/DragControls.js
generated
vendored
Normal file
193
node_modules/three/examples/js/controls/DragControls.js
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* @author zz85 / https://github.com/zz85
|
||||
* @author mrdoob / http://mrdoob.com
|
||||
* Running this will allow you to drag three.js objects around the screen.
|
||||
*/
|
||||
|
||||
THREE.DragControls = function ( _objects, _camera, _domElement ) {
|
||||
|
||||
if ( _objects instanceof THREE.Camera ) {
|
||||
|
||||
console.warn( 'THREE.DragControls: Constructor now expects ( objects, camera, domElement )' );
|
||||
var temp = _objects; _objects = _camera; _camera = temp;
|
||||
|
||||
}
|
||||
|
||||
var _plane = new THREE.Plane();
|
||||
var _raycaster = new THREE.Raycaster();
|
||||
|
||||
var _mouse = new THREE.Vector2();
|
||||
var _offset = new THREE.Vector3();
|
||||
var _intersection = new THREE.Vector3();
|
||||
|
||||
var _selected = null, _hovered = null;
|
||||
|
||||
//
|
||||
|
||||
var scope = this;
|
||||
|
||||
function activate() {
|
||||
|
||||
_domElement.addEventListener( 'mousemove', onDocumentMouseMove, false );
|
||||
_domElement.addEventListener( 'mousedown', onDocumentMouseDown, false );
|
||||
_domElement.addEventListener( 'mouseup', onDocumentMouseUp, false );
|
||||
|
||||
}
|
||||
|
||||
function deactivate() {
|
||||
|
||||
_domElement.removeEventListener( 'mousemove', onDocumentMouseMove, false );
|
||||
_domElement.removeEventListener( 'mousedown', onDocumentMouseDown, false );
|
||||
_domElement.removeEventListener( 'mouseup', onDocumentMouseUp, false );
|
||||
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
|
||||
deactivate();
|
||||
|
||||
}
|
||||
|
||||
function onDocumentMouseMove( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
_mouse.x = ( event.clientX / _domElement.width ) * 2 - 1;
|
||||
_mouse.y = - ( event.clientY / _domElement.height ) * 2 + 1;
|
||||
|
||||
_raycaster.setFromCamera( _mouse, _camera );
|
||||
|
||||
if ( _selected && scope.enabled ) {
|
||||
|
||||
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
|
||||
|
||||
_selected.position.copy( _intersection.sub( _offset ) );
|
||||
|
||||
}
|
||||
|
||||
scope.dispatchEvent( { type: 'drag', object: _selected } );
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
_raycaster.setFromCamera( _mouse, _camera );
|
||||
|
||||
var intersects = _raycaster.intersectObjects( _objects );
|
||||
|
||||
if ( intersects.length > 0 ) {
|
||||
|
||||
var object = intersects[ 0 ].object;
|
||||
|
||||
_plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), object.position );
|
||||
|
||||
if ( _hovered !== object ) {
|
||||
|
||||
scope.dispatchEvent( { type: 'hoveron', object: object } );
|
||||
|
||||
_domElement.style.cursor = 'pointer';
|
||||
_hovered = object;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ( _hovered !== null ) {
|
||||
|
||||
scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );
|
||||
|
||||
_domElement.style.cursor = 'auto';
|
||||
_hovered = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onDocumentMouseDown( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
_raycaster.setFromCamera( _mouse, _camera );
|
||||
|
||||
var intersects = _raycaster.intersectObjects( _objects );
|
||||
|
||||
if ( intersects.length > 0 ) {
|
||||
|
||||
_selected = intersects[ 0 ].object;
|
||||
|
||||
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
|
||||
|
||||
_offset.copy( _intersection ).sub( _selected.position );
|
||||
|
||||
}
|
||||
|
||||
_domElement.style.cursor = 'move';
|
||||
|
||||
scope.dispatchEvent( { type: 'dragstart', object: _selected } );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function onDocumentMouseUp( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if ( _selected ) {
|
||||
|
||||
scope.dispatchEvent( { type: 'dragend', object: _selected } );
|
||||
|
||||
_selected = null;
|
||||
|
||||
}
|
||||
|
||||
_domElement.style.cursor = 'auto';
|
||||
|
||||
}
|
||||
|
||||
activate();
|
||||
|
||||
// API
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.activate = activate;
|
||||
this.deactivate = deactivate;
|
||||
this.dispose = dispose;
|
||||
|
||||
// Backward compatibility
|
||||
|
||||
this.setObjects = function () {
|
||||
|
||||
console.error( 'THREE.DragControls: setObjects() has been removed.' );
|
||||
|
||||
};
|
||||
|
||||
this.on = function ( type, listener ) {
|
||||
|
||||
console.warn( 'THREE.DragControls: on() has been deprecated. Use addEventListener() instead.' );
|
||||
scope.addEventListener( type, listener );
|
||||
|
||||
};
|
||||
|
||||
this.off = function ( type, listener ) {
|
||||
|
||||
console.warn( 'THREE.DragControls: off() has been deprecated. Use removeEventListener() instead.' );
|
||||
scope.removeEventListener( type, listener );
|
||||
|
||||
};
|
||||
|
||||
this.notify = function ( type ) {
|
||||
|
||||
console.error( 'THREE.DragControls: notify() has been deprecated. Use dispatchEvent() instead.' );
|
||||
scope.dispatchEvent( { type: type } );
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
THREE.DragControls.prototype = Object.create( THREE.EventDispatcher.prototype );
|
||||
THREE.DragControls.prototype.constructor = THREE.DragControls;
|
||||
293
node_modules/three/examples/js/controls/EditorControls.js
generated
vendored
Normal file
293
node_modules/three/examples/js/controls/EditorControls.js
generated
vendored
Normal file
@@ -0,0 +1,293 @@
|
||||
/**
|
||||
* @author qiao / https://github.com/qiao
|
||||
* @author mrdoob / http://mrdoob.com
|
||||
* @author alteredq / http://alteredqualia.com/
|
||||
* @author WestLangley / http://github.com/WestLangley
|
||||
*/
|
||||
|
||||
THREE.EditorControls = function ( object, domElement ) {
|
||||
|
||||
domElement = ( domElement !== undefined ) ? domElement : document;
|
||||
|
||||
// API
|
||||
|
||||
this.enabled = true;
|
||||
this.center = new THREE.Vector3();
|
||||
this.panSpeed = 0.001;
|
||||
this.zoomSpeed = 0.001;
|
||||
this.rotationSpeed = 0.005;
|
||||
|
||||
// internals
|
||||
|
||||
var scope = this;
|
||||
var vector = new THREE.Vector3();
|
||||
|
||||
var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2 };
|
||||
var state = STATE.NONE;
|
||||
|
||||
var center = this.center;
|
||||
var normalMatrix = new THREE.Matrix3();
|
||||
var pointer = new THREE.Vector2();
|
||||
var pointerOld = new THREE.Vector2();
|
||||
var spherical = new THREE.Spherical();
|
||||
|
||||
// events
|
||||
|
||||
var changeEvent = { type: 'change' };
|
||||
|
||||
this.focus = function ( target ) {
|
||||
|
||||
var box = new THREE.Box3().setFromObject( target );
|
||||
object.lookAt( center.copy( box.getCenter() ) );
|
||||
scope.dispatchEvent( changeEvent );
|
||||
|
||||
};
|
||||
|
||||
this.pan = function ( delta ) {
|
||||
|
||||
var distance = object.position.distanceTo( center );
|
||||
|
||||
delta.multiplyScalar( distance * scope.panSpeed );
|
||||
delta.applyMatrix3( normalMatrix.getNormalMatrix( object.matrix ) );
|
||||
|
||||
object.position.add( delta );
|
||||
center.add( delta );
|
||||
|
||||
scope.dispatchEvent( changeEvent );
|
||||
|
||||
};
|
||||
|
||||
this.zoom = function ( delta ) {
|
||||
|
||||
var distance = object.position.distanceTo( center );
|
||||
|
||||
delta.multiplyScalar( distance * scope.zoomSpeed );
|
||||
|
||||
if ( delta.length() > distance ) return;
|
||||
|
||||
delta.applyMatrix3( normalMatrix.getNormalMatrix( object.matrix ) );
|
||||
|
||||
object.position.add( delta );
|
||||
|
||||
scope.dispatchEvent( changeEvent );
|
||||
|
||||
};
|
||||
|
||||
this.rotate = function ( delta ) {
|
||||
|
||||
vector.copy( object.position ).sub( center );
|
||||
|
||||
spherical.setFromVector3( vector );
|
||||
|
||||
spherical.theta += delta.x;
|
||||
spherical.phi += delta.y;
|
||||
|
||||
spherical.makeSafe();
|
||||
|
||||
vector.setFromSpherical( spherical );
|
||||
|
||||
object.position.copy( center ).add( vector );
|
||||
|
||||
object.lookAt( center );
|
||||
|
||||
scope.dispatchEvent( changeEvent );
|
||||
|
||||
};
|
||||
|
||||
// mouse
|
||||
|
||||
function onMouseDown( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
if ( event.button === 0 ) {
|
||||
|
||||
state = STATE.ROTATE;
|
||||
|
||||
} else if ( event.button === 1 ) {
|
||||
|
||||
state = STATE.ZOOM;
|
||||
|
||||
} else if ( event.button === 2 ) {
|
||||
|
||||
state = STATE.PAN;
|
||||
|
||||
}
|
||||
|
||||
pointerOld.set( event.clientX, event.clientY );
|
||||
|
||||
domElement.addEventListener( 'mousemove', onMouseMove, false );
|
||||
domElement.addEventListener( 'mouseup', onMouseUp, false );
|
||||
domElement.addEventListener( 'mouseout', onMouseUp, false );
|
||||
domElement.addEventListener( 'dblclick', onMouseUp, false );
|
||||
|
||||
}
|
||||
|
||||
function onMouseMove( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
pointer.set( event.clientX, event.clientY );
|
||||
|
||||
var movementX = pointer.x - pointerOld.x;
|
||||
var movementY = pointer.y - pointerOld.y;
|
||||
|
||||
if ( state === STATE.ROTATE ) {
|
||||
|
||||
scope.rotate( new THREE.Vector3( - movementX * scope.rotationSpeed, - movementY * scope.rotationSpeed, 0 ) );
|
||||
|
||||
} else if ( state === STATE.ZOOM ) {
|
||||
|
||||
scope.zoom( new THREE.Vector3( 0, 0, movementY ) );
|
||||
|
||||
} else if ( state === STATE.PAN ) {
|
||||
|
||||
scope.pan( new THREE.Vector3( - movementX, movementY, 0 ) );
|
||||
|
||||
}
|
||||
|
||||
pointerOld.set( event.clientX, event.clientY );
|
||||
|
||||
}
|
||||
|
||||
function onMouseUp( event ) {
|
||||
|
||||
domElement.removeEventListener( 'mousemove', onMouseMove, false );
|
||||
domElement.removeEventListener( 'mouseup', onMouseUp, false );
|
||||
domElement.removeEventListener( 'mouseout', onMouseUp, false );
|
||||
domElement.removeEventListener( 'dblclick', onMouseUp, false );
|
||||
|
||||
state = STATE.NONE;
|
||||
|
||||
}
|
||||
|
||||
function onMouseWheel( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// if ( scope.enabled === false ) return;
|
||||
|
||||
scope.zoom( new THREE.Vector3( 0, 0, event.deltaY ) );
|
||||
|
||||
}
|
||||
|
||||
function contextmenu( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function() {
|
||||
|
||||
domElement.removeEventListener( 'contextmenu', contextmenu, false );
|
||||
domElement.removeEventListener( 'mousedown', onMouseDown, false );
|
||||
domElement.removeEventListener( 'wheel', onMouseWheel, false );
|
||||
|
||||
domElement.removeEventListener( 'mousemove', onMouseMove, false );
|
||||
domElement.removeEventListener( 'mouseup', onMouseUp, false );
|
||||
domElement.removeEventListener( 'mouseout', onMouseUp, false );
|
||||
domElement.removeEventListener( 'dblclick', onMouseUp, false );
|
||||
|
||||
domElement.removeEventListener( 'touchstart', touchStart, false );
|
||||
domElement.removeEventListener( 'touchmove', touchMove, false );
|
||||
|
||||
};
|
||||
|
||||
domElement.addEventListener( 'contextmenu', contextmenu, false );
|
||||
domElement.addEventListener( 'mousedown', onMouseDown, false );
|
||||
domElement.addEventListener( 'wheel', onMouseWheel, false );
|
||||
|
||||
// touch
|
||||
|
||||
var touch = new THREE.Vector3();
|
||||
|
||||
var touches = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ];
|
||||
var prevTouches = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ];
|
||||
|
||||
var prevDistance = null;
|
||||
|
||||
function touchStart( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1:
|
||||
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
|
||||
touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
|
||||
touches[ 1 ].set( event.touches[ 1 ].pageX, event.touches[ 1 ].pageY, 0 );
|
||||
prevDistance = touches[ 0 ].distanceTo( touches[ 1 ] );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
prevTouches[ 0 ].copy( touches[ 0 ] );
|
||||
prevTouches[ 1 ].copy( touches[ 1 ] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
function touchMove( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
function getClosest( touch, touches ) {
|
||||
|
||||
var closest = touches[ 0 ];
|
||||
|
||||
for ( var i in touches ) {
|
||||
|
||||
if ( closest.distanceTo( touch ) > touches[ i ].distanceTo( touch ) ) closest = touches[ i ];
|
||||
|
||||
}
|
||||
|
||||
return closest;
|
||||
|
||||
}
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1:
|
||||
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
|
||||
touches[ 1 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
|
||||
scope.rotate( touches[ 0 ].sub( getClosest( touches[ 0 ], prevTouches ) ).multiplyScalar( - scope.rotationSpeed ) );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 );
|
||||
touches[ 1 ].set( event.touches[ 1 ].pageX, event.touches[ 1 ].pageY, 0 );
|
||||
distance = touches[ 0 ].distanceTo( touches[ 1 ] );
|
||||
scope.zoom( new THREE.Vector3( 0, 0, prevDistance - distance ) );
|
||||
prevDistance = distance;
|
||||
|
||||
|
||||
var offset0 = touches[ 0 ].clone().sub( getClosest( touches[ 0 ], prevTouches ) );
|
||||
var offset1 = touches[ 1 ].clone().sub( getClosest( touches[ 1 ], prevTouches ) );
|
||||
offset0.x = - offset0.x;
|
||||
offset1.x = - offset1.x;
|
||||
|
||||
scope.pan( offset0.add( offset1 ).multiplyScalar( 0.5 ) );
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
prevTouches[ 0 ].copy( touches[ 0 ] );
|
||||
prevTouches[ 1 ].copy( touches[ 1 ] );
|
||||
|
||||
}
|
||||
|
||||
domElement.addEventListener( 'touchstart', touchStart, false );
|
||||
domElement.addEventListener( 'touchmove', touchMove, false );
|
||||
|
||||
};
|
||||
|
||||
THREE.EditorControls.prototype = Object.create( THREE.EventDispatcher.prototype );
|
||||
THREE.EditorControls.prototype.constructor = THREE.EditorControls;
|
||||
300
node_modules/three/examples/js/controls/FirstPersonControls.js
generated
vendored
Normal file
300
node_modules/three/examples/js/controls/FirstPersonControls.js
generated
vendored
Normal file
@@ -0,0 +1,300 @@
|
||||
/**
|
||||
* @author mrdoob / http://mrdoob.com/
|
||||
* @author alteredq / http://alteredqualia.com/
|
||||
* @author paulirish / http://paulirish.com/
|
||||
*/
|
||||
|
||||
THREE.FirstPersonControls = function ( object, domElement ) {
|
||||
|
||||
this.object = object;
|
||||
this.target = new THREE.Vector3( 0, 0, 0 );
|
||||
|
||||
this.domElement = ( domElement !== undefined ) ? domElement : document;
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.movementSpeed = 1.0;
|
||||
this.lookSpeed = 0.005;
|
||||
|
||||
this.lookVertical = true;
|
||||
this.autoForward = false;
|
||||
|
||||
this.activeLook = true;
|
||||
|
||||
this.heightSpeed = false;
|
||||
this.heightCoef = 1.0;
|
||||
this.heightMin = 0.0;
|
||||
this.heightMax = 1.0;
|
||||
|
||||
this.constrainVertical = false;
|
||||
this.verticalMin = 0;
|
||||
this.verticalMax = Math.PI;
|
||||
|
||||
this.autoSpeedFactor = 0.0;
|
||||
|
||||
this.mouseX = 0;
|
||||
this.mouseY = 0;
|
||||
|
||||
this.lat = 0;
|
||||
this.lon = 0;
|
||||
this.phi = 0;
|
||||
this.theta = 0;
|
||||
|
||||
this.moveForward = false;
|
||||
this.moveBackward = false;
|
||||
this.moveLeft = false;
|
||||
this.moveRight = false;
|
||||
|
||||
this.mouseDragOn = false;
|
||||
|
||||
this.viewHalfX = 0;
|
||||
this.viewHalfY = 0;
|
||||
|
||||
if ( this.domElement !== document ) {
|
||||
|
||||
this.domElement.setAttribute( 'tabindex', - 1 );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
this.handleResize = function () {
|
||||
|
||||
if ( this.domElement === document ) {
|
||||
|
||||
this.viewHalfX = window.innerWidth / 2;
|
||||
this.viewHalfY = window.innerHeight / 2;
|
||||
|
||||
} else {
|
||||
|
||||
this.viewHalfX = this.domElement.offsetWidth / 2;
|
||||
this.viewHalfY = this.domElement.offsetHeight / 2;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.onMouseDown = function ( event ) {
|
||||
|
||||
if ( this.domElement !== document ) {
|
||||
|
||||
this.domElement.focus();
|
||||
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if ( this.activeLook ) {
|
||||
|
||||
switch ( event.button ) {
|
||||
|
||||
case 0: this.moveForward = true; break;
|
||||
case 2: this.moveBackward = true; break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.mouseDragOn = true;
|
||||
|
||||
};
|
||||
|
||||
this.onMouseUp = function ( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if ( this.activeLook ) {
|
||||
|
||||
switch ( event.button ) {
|
||||
|
||||
case 0: this.moveForward = false; break;
|
||||
case 2: this.moveBackward = false; break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.mouseDragOn = false;
|
||||
|
||||
};
|
||||
|
||||
this.onMouseMove = function ( event ) {
|
||||
|
||||
if ( this.domElement === document ) {
|
||||
|
||||
this.mouseX = event.pageX - this.viewHalfX;
|
||||
this.mouseY = event.pageY - this.viewHalfY;
|
||||
|
||||
} else {
|
||||
|
||||
this.mouseX = event.pageX - this.domElement.offsetLeft - this.viewHalfX;
|
||||
this.mouseY = event.pageY - this.domElement.offsetTop - this.viewHalfY;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.onKeyDown = function ( event ) {
|
||||
|
||||
//event.preventDefault();
|
||||
|
||||
switch ( event.keyCode ) {
|
||||
|
||||
case 38: /*up*/
|
||||
case 87: /*W*/ this.moveForward = true; break;
|
||||
|
||||
case 37: /*left*/
|
||||
case 65: /*A*/ this.moveLeft = true; break;
|
||||
|
||||
case 40: /*down*/
|
||||
case 83: /*S*/ this.moveBackward = true; break;
|
||||
|
||||
case 39: /*right*/
|
||||
case 68: /*D*/ this.moveRight = true; break;
|
||||
|
||||
case 82: /*R*/ this.moveUp = true; break;
|
||||
case 70: /*F*/ this.moveDown = true; break;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.onKeyUp = function ( event ) {
|
||||
|
||||
switch ( event.keyCode ) {
|
||||
|
||||
case 38: /*up*/
|
||||
case 87: /*W*/ this.moveForward = false; break;
|
||||
|
||||
case 37: /*left*/
|
||||
case 65: /*A*/ this.moveLeft = false; break;
|
||||
|
||||
case 40: /*down*/
|
||||
case 83: /*S*/ this.moveBackward = false; break;
|
||||
|
||||
case 39: /*right*/
|
||||
case 68: /*D*/ this.moveRight = false; break;
|
||||
|
||||
case 82: /*R*/ this.moveUp = false; break;
|
||||
case 70: /*F*/ this.moveDown = false; break;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.update = function( delta ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
if ( this.heightSpeed ) {
|
||||
|
||||
var y = THREE.Math.clamp( this.object.position.y, this.heightMin, this.heightMax );
|
||||
var heightDelta = y - this.heightMin;
|
||||
|
||||
this.autoSpeedFactor = delta * ( heightDelta * this.heightCoef );
|
||||
|
||||
} else {
|
||||
|
||||
this.autoSpeedFactor = 0.0;
|
||||
|
||||
}
|
||||
|
||||
var actualMoveSpeed = delta * this.movementSpeed;
|
||||
|
||||
if ( this.moveForward || ( this.autoForward && ! this.moveBackward ) ) this.object.translateZ( - ( actualMoveSpeed + this.autoSpeedFactor ) );
|
||||
if ( this.moveBackward ) this.object.translateZ( actualMoveSpeed );
|
||||
|
||||
if ( this.moveLeft ) this.object.translateX( - actualMoveSpeed );
|
||||
if ( this.moveRight ) this.object.translateX( actualMoveSpeed );
|
||||
|
||||
if ( this.moveUp ) this.object.translateY( actualMoveSpeed );
|
||||
if ( this.moveDown ) this.object.translateY( - actualMoveSpeed );
|
||||
|
||||
var actualLookSpeed = delta * this.lookSpeed;
|
||||
|
||||
if ( ! this.activeLook ) {
|
||||
|
||||
actualLookSpeed = 0;
|
||||
|
||||
}
|
||||
|
||||
var verticalLookRatio = 1;
|
||||
|
||||
if ( this.constrainVertical ) {
|
||||
|
||||
verticalLookRatio = Math.PI / ( this.verticalMax - this.verticalMin );
|
||||
|
||||
}
|
||||
|
||||
this.lon += this.mouseX * actualLookSpeed;
|
||||
if ( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed * verticalLookRatio;
|
||||
|
||||
this.lat = Math.max( - 85, Math.min( 85, this.lat ) );
|
||||
this.phi = THREE.Math.degToRad( 90 - this.lat );
|
||||
|
||||
this.theta = THREE.Math.degToRad( this.lon );
|
||||
|
||||
if ( this.constrainVertical ) {
|
||||
|
||||
this.phi = THREE.Math.mapLinear( this.phi, 0, Math.PI, this.verticalMin, this.verticalMax );
|
||||
|
||||
}
|
||||
|
||||
var targetPosition = this.target,
|
||||
position = this.object.position;
|
||||
|
||||
targetPosition.x = position.x + 100 * Math.sin( this.phi ) * Math.cos( this.theta );
|
||||
targetPosition.y = position.y + 100 * Math.cos( this.phi );
|
||||
targetPosition.z = position.z + 100 * Math.sin( this.phi ) * Math.sin( this.theta );
|
||||
|
||||
this.object.lookAt( targetPosition );
|
||||
|
||||
};
|
||||
|
||||
function contextmenu( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function() {
|
||||
|
||||
this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
|
||||
this.domElement.removeEventListener( 'mousedown', _onMouseDown, false );
|
||||
this.domElement.removeEventListener( 'mousemove', _onMouseMove, false );
|
||||
this.domElement.removeEventListener( 'mouseup', _onMouseUp, false );
|
||||
|
||||
window.removeEventListener( 'keydown', _onKeyDown, false );
|
||||
window.removeEventListener( 'keyup', _onKeyUp, false );
|
||||
|
||||
};
|
||||
|
||||
var _onMouseMove = bind( this, this.onMouseMove );
|
||||
var _onMouseDown = bind( this, this.onMouseDown );
|
||||
var _onMouseUp = bind( this, this.onMouseUp );
|
||||
var _onKeyDown = bind( this, this.onKeyDown );
|
||||
var _onKeyUp = bind( this, this.onKeyUp );
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', contextmenu, false );
|
||||
this.domElement.addEventListener( 'mousemove', _onMouseMove, false );
|
||||
this.domElement.addEventListener( 'mousedown', _onMouseDown, false );
|
||||
this.domElement.addEventListener( 'mouseup', _onMouseUp, false );
|
||||
|
||||
window.addEventListener( 'keydown', _onKeyDown, false );
|
||||
window.addEventListener( 'keyup', _onKeyUp, false );
|
||||
|
||||
function bind( scope, fn ) {
|
||||
|
||||
return function () {
|
||||
|
||||
fn.apply( scope, arguments );
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
this.handleResize();
|
||||
|
||||
};
|
||||
293
node_modules/three/examples/js/controls/FlyControls.js
generated
vendored
Normal file
293
node_modules/three/examples/js/controls/FlyControls.js
generated
vendored
Normal file
@@ -0,0 +1,293 @@
|
||||
/**
|
||||
* @author James Baicoianu / http://www.baicoianu.com/
|
||||
*/
|
||||
|
||||
THREE.FlyControls = function ( object, domElement ) {
|
||||
|
||||
this.object = object;
|
||||
|
||||
this.domElement = ( domElement !== undefined ) ? domElement : document;
|
||||
if ( domElement ) this.domElement.setAttribute( 'tabindex', - 1 );
|
||||
|
||||
// API
|
||||
|
||||
this.movementSpeed = 1.0;
|
||||
this.rollSpeed = 0.005;
|
||||
|
||||
this.dragToLook = false;
|
||||
this.autoForward = false;
|
||||
|
||||
// disable default target object behavior
|
||||
|
||||
// internals
|
||||
|
||||
this.tmpQuaternion = new THREE.Quaternion();
|
||||
|
||||
this.mouseStatus = 0;
|
||||
|
||||
this.moveState = { up: 0, down: 0, left: 0, right: 0, forward: 0, back: 0, pitchUp: 0, pitchDown: 0, yawLeft: 0, yawRight: 0, rollLeft: 0, rollRight: 0 };
|
||||
this.moveVector = new THREE.Vector3( 0, 0, 0 );
|
||||
this.rotationVector = new THREE.Vector3( 0, 0, 0 );
|
||||
|
||||
this.handleEvent = function ( event ) {
|
||||
|
||||
if ( typeof this[ event.type ] == 'function' ) {
|
||||
|
||||
this[ event.type ]( event );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.keydown = function( event ) {
|
||||
|
||||
if ( event.altKey ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//event.preventDefault();
|
||||
|
||||
switch ( event.keyCode ) {
|
||||
|
||||
case 16: /* shift */ this.movementSpeedMultiplier = .1; break;
|
||||
|
||||
case 87: /*W*/ this.moveState.forward = 1; break;
|
||||
case 83: /*S*/ this.moveState.back = 1; break;
|
||||
|
||||
case 65: /*A*/ this.moveState.left = 1; break;
|
||||
case 68: /*D*/ this.moveState.right = 1; break;
|
||||
|
||||
case 82: /*R*/ this.moveState.up = 1; break;
|
||||
case 70: /*F*/ this.moveState.down = 1; break;
|
||||
|
||||
case 38: /*up*/ this.moveState.pitchUp = 1; break;
|
||||
case 40: /*down*/ this.moveState.pitchDown = 1; break;
|
||||
|
||||
case 37: /*left*/ this.moveState.yawLeft = 1; break;
|
||||
case 39: /*right*/ this.moveState.yawRight = 1; break;
|
||||
|
||||
case 81: /*Q*/ this.moveState.rollLeft = 1; break;
|
||||
case 69: /*E*/ this.moveState.rollRight = 1; break;
|
||||
|
||||
}
|
||||
|
||||
this.updateMovementVector();
|
||||
this.updateRotationVector();
|
||||
|
||||
};
|
||||
|
||||
this.keyup = function( event ) {
|
||||
|
||||
switch ( event.keyCode ) {
|
||||
|
||||
case 16: /* shift */ this.movementSpeedMultiplier = 1; break;
|
||||
|
||||
case 87: /*W*/ this.moveState.forward = 0; break;
|
||||
case 83: /*S*/ this.moveState.back = 0; break;
|
||||
|
||||
case 65: /*A*/ this.moveState.left = 0; break;
|
||||
case 68: /*D*/ this.moveState.right = 0; break;
|
||||
|
||||
case 82: /*R*/ this.moveState.up = 0; break;
|
||||
case 70: /*F*/ this.moveState.down = 0; break;
|
||||
|
||||
case 38: /*up*/ this.moveState.pitchUp = 0; break;
|
||||
case 40: /*down*/ this.moveState.pitchDown = 0; break;
|
||||
|
||||
case 37: /*left*/ this.moveState.yawLeft = 0; break;
|
||||
case 39: /*right*/ this.moveState.yawRight = 0; break;
|
||||
|
||||
case 81: /*Q*/ this.moveState.rollLeft = 0; break;
|
||||
case 69: /*E*/ this.moveState.rollRight = 0; break;
|
||||
|
||||
}
|
||||
|
||||
this.updateMovementVector();
|
||||
this.updateRotationVector();
|
||||
|
||||
};
|
||||
|
||||
this.mousedown = function( event ) {
|
||||
|
||||
if ( this.domElement !== document ) {
|
||||
|
||||
this.domElement.focus();
|
||||
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if ( this.dragToLook ) {
|
||||
|
||||
this.mouseStatus ++;
|
||||
|
||||
} else {
|
||||
|
||||
switch ( event.button ) {
|
||||
|
||||
case 0: this.moveState.forward = 1; break;
|
||||
case 2: this.moveState.back = 1; break;
|
||||
|
||||
}
|
||||
|
||||
this.updateMovementVector();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.mousemove = function( event ) {
|
||||
|
||||
if ( ! this.dragToLook || this.mouseStatus > 0 ) {
|
||||
|
||||
var container = this.getContainerDimensions();
|
||||
var halfWidth = container.size[ 0 ] / 2;
|
||||
var halfHeight = container.size[ 1 ] / 2;
|
||||
|
||||
this.moveState.yawLeft = - ( ( event.pageX - container.offset[ 0 ] ) - halfWidth ) / halfWidth;
|
||||
this.moveState.pitchDown = ( ( event.pageY - container.offset[ 1 ] ) - halfHeight ) / halfHeight;
|
||||
|
||||
this.updateRotationVector();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.mouseup = function( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if ( this.dragToLook ) {
|
||||
|
||||
this.mouseStatus --;
|
||||
|
||||
this.moveState.yawLeft = this.moveState.pitchDown = 0;
|
||||
|
||||
} else {
|
||||
|
||||
switch ( event.button ) {
|
||||
|
||||
case 0: this.moveState.forward = 0; break;
|
||||
case 2: this.moveState.back = 0; break;
|
||||
|
||||
}
|
||||
|
||||
this.updateMovementVector();
|
||||
|
||||
}
|
||||
|
||||
this.updateRotationVector();
|
||||
|
||||
};
|
||||
|
||||
this.update = function( delta ) {
|
||||
|
||||
var moveMult = delta * this.movementSpeed;
|
||||
var rotMult = delta * this.rollSpeed;
|
||||
|
||||
this.object.translateX( this.moveVector.x * moveMult );
|
||||
this.object.translateY( this.moveVector.y * moveMult );
|
||||
this.object.translateZ( this.moveVector.z * moveMult );
|
||||
|
||||
this.tmpQuaternion.set( this.rotationVector.x * rotMult, this.rotationVector.y * rotMult, this.rotationVector.z * rotMult, 1 ).normalize();
|
||||
this.object.quaternion.multiply( this.tmpQuaternion );
|
||||
|
||||
// expose the rotation vector for convenience
|
||||
this.object.rotation.setFromQuaternion( this.object.quaternion, this.object.rotation.order );
|
||||
|
||||
|
||||
};
|
||||
|
||||
this.updateMovementVector = function() {
|
||||
|
||||
var forward = ( this.moveState.forward || ( this.autoForward && ! this.moveState.back ) ) ? 1 : 0;
|
||||
|
||||
this.moveVector.x = ( - this.moveState.left + this.moveState.right );
|
||||
this.moveVector.y = ( - this.moveState.down + this.moveState.up );
|
||||
this.moveVector.z = ( - forward + this.moveState.back );
|
||||
|
||||
//console.log( 'move:', [ this.moveVector.x, this.moveVector.y, this.moveVector.z ] );
|
||||
|
||||
};
|
||||
|
||||
this.updateRotationVector = function() {
|
||||
|
||||
this.rotationVector.x = ( - this.moveState.pitchDown + this.moveState.pitchUp );
|
||||
this.rotationVector.y = ( - this.moveState.yawRight + this.moveState.yawLeft );
|
||||
this.rotationVector.z = ( - this.moveState.rollRight + this.moveState.rollLeft );
|
||||
|
||||
//console.log( 'rotate:', [ this.rotationVector.x, this.rotationVector.y, this.rotationVector.z ] );
|
||||
|
||||
};
|
||||
|
||||
this.getContainerDimensions = function() {
|
||||
|
||||
if ( this.domElement != document ) {
|
||||
|
||||
return {
|
||||
size : [ this.domElement.offsetWidth, this.domElement.offsetHeight ],
|
||||
offset : [ this.domElement.offsetLeft, this.domElement.offsetTop ]
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
return {
|
||||
size : [ window.innerWidth, window.innerHeight ],
|
||||
offset : [ 0, 0 ]
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function bind( scope, fn ) {
|
||||
|
||||
return function () {
|
||||
|
||||
fn.apply( scope, arguments );
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
function contextmenu( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function() {
|
||||
|
||||
this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
|
||||
this.domElement.removeEventListener( 'mousedown', _mousedown, false );
|
||||
this.domElement.removeEventListener( 'mousemove', _mousemove, false );
|
||||
this.domElement.removeEventListener( 'mouseup', _mouseup, false );
|
||||
|
||||
window.removeEventListener( 'keydown', _keydown, false );
|
||||
window.removeEventListener( 'keyup', _keyup, false );
|
||||
|
||||
};
|
||||
|
||||
var _mousemove = bind( this, this.mousemove );
|
||||
var _mousedown = bind( this, this.mousedown );
|
||||
var _mouseup = bind( this, this.mouseup );
|
||||
var _keydown = bind( this, this.keydown );
|
||||
var _keyup = bind( this, this.keyup );
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', contextmenu, false );
|
||||
|
||||
this.domElement.addEventListener( 'mousemove', _mousemove, false );
|
||||
this.domElement.addEventListener( 'mousedown', _mousedown, false );
|
||||
this.domElement.addEventListener( 'mouseup', _mouseup, false );
|
||||
|
||||
window.addEventListener( 'keydown', _keydown, false );
|
||||
window.addEventListener( 'keyup', _keyup, false );
|
||||
|
||||
this.updateMovementVector();
|
||||
this.updateRotationVector();
|
||||
|
||||
};
|
||||
1016
node_modules/three/examples/js/controls/OrbitControls.js
generated
vendored
Normal file
1016
node_modules/three/examples/js/controls/OrbitControls.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
636
node_modules/three/examples/js/controls/OrthographicTrackballControls.js
generated
vendored
Normal file
636
node_modules/three/examples/js/controls/OrthographicTrackballControls.js
generated
vendored
Normal file
@@ -0,0 +1,636 @@
|
||||
/**
|
||||
* @author Eberhard Graether / http://egraether.com/
|
||||
* @author Mark Lundin / http://mark-lundin.com
|
||||
* @author Patrick Fuller / http://patrick-fuller.com
|
||||
* @author Max Smolens / https://github.com/msmolens
|
||||
*/
|
||||
|
||||
THREE.OrthographicTrackballControls = function ( object, domElement ) {
|
||||
|
||||
var _this = this;
|
||||
var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
|
||||
|
||||
this.object = object;
|
||||
this.domElement = ( domElement !== undefined ) ? domElement : document;
|
||||
|
||||
// API
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.screen = { left: 0, top: 0, width: 0, height: 0 };
|
||||
|
||||
this.radius = 0;
|
||||
|
||||
this.rotateSpeed = 1.0;
|
||||
this.zoomSpeed = 1.2;
|
||||
|
||||
this.noRotate = false;
|
||||
this.noZoom = false;
|
||||
this.noPan = false;
|
||||
this.noRoll = false;
|
||||
|
||||
this.staticMoving = false;
|
||||
this.dynamicDampingFactor = 0.2;
|
||||
|
||||
this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ];
|
||||
|
||||
// internals
|
||||
|
||||
this.target = new THREE.Vector3();
|
||||
|
||||
var EPS = 0.000001;
|
||||
|
||||
var _changed = true;
|
||||
|
||||
var _state = STATE.NONE,
|
||||
_prevState = STATE.NONE,
|
||||
|
||||
_eye = new THREE.Vector3(),
|
||||
|
||||
_rotateStart = new THREE.Vector3(),
|
||||
_rotateEnd = new THREE.Vector3(),
|
||||
|
||||
_zoomStart = new THREE.Vector2(),
|
||||
_zoomEnd = new THREE.Vector2(),
|
||||
|
||||
_touchZoomDistanceStart = 0,
|
||||
_touchZoomDistanceEnd = 0,
|
||||
|
||||
_panStart = new THREE.Vector2(),
|
||||
_panEnd = new THREE.Vector2();
|
||||
|
||||
// for reset
|
||||
|
||||
this.target0 = this.target.clone();
|
||||
this.position0 = this.object.position.clone();
|
||||
this.up0 = this.object.up.clone();
|
||||
|
||||
this.left0 = this.object.left;
|
||||
this.right0 = this.object.right;
|
||||
this.top0 = this.object.top;
|
||||
this.bottom0 = this.object.bottom;
|
||||
|
||||
// events
|
||||
|
||||
var changeEvent = { type: 'change' };
|
||||
var startEvent = { type: 'start' };
|
||||
var endEvent = { type: 'end' };
|
||||
|
||||
|
||||
// methods
|
||||
|
||||
this.handleResize = function () {
|
||||
|
||||
if ( this.domElement === document ) {
|
||||
|
||||
this.screen.left = 0;
|
||||
this.screen.top = 0;
|
||||
this.screen.width = window.innerWidth;
|
||||
this.screen.height = window.innerHeight;
|
||||
|
||||
} else {
|
||||
|
||||
var box = this.domElement.getBoundingClientRect();
|
||||
// adjustments come from similar code in the jquery offset() function
|
||||
var d = this.domElement.ownerDocument.documentElement;
|
||||
this.screen.left = box.left + window.pageXOffset - d.clientLeft;
|
||||
this.screen.top = box.top + window.pageYOffset - d.clientTop;
|
||||
this.screen.width = box.width;
|
||||
this.screen.height = box.height;
|
||||
|
||||
}
|
||||
|
||||
this.radius = 0.5 * Math.min( this.screen.width, this.screen.height );
|
||||
|
||||
this.left0 = this.object.left;
|
||||
this.right0 = this.object.right;
|
||||
this.top0 = this.object.top;
|
||||
this.bottom0 = this.object.bottom;
|
||||
|
||||
};
|
||||
|
||||
this.handleEvent = function ( event ) {
|
||||
|
||||
if ( typeof this[ event.type ] == 'function' ) {
|
||||
|
||||
this[ event.type ]( event );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var getMouseOnScreen = ( function () {
|
||||
|
||||
var vector = new THREE.Vector2();
|
||||
|
||||
return function getMouseOnScreen( pageX, pageY ) {
|
||||
|
||||
vector.set(
|
||||
( pageX - _this.screen.left ) / _this.screen.width,
|
||||
( pageY - _this.screen.top ) / _this.screen.height
|
||||
);
|
||||
|
||||
return vector;
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
var getMouseProjectionOnBall = ( function () {
|
||||
|
||||
var vector = new THREE.Vector3();
|
||||
var objectUp = new THREE.Vector3();
|
||||
var mouseOnBall = new THREE.Vector3();
|
||||
|
||||
return function getMouseProjectionOnBall( pageX, pageY ) {
|
||||
|
||||
mouseOnBall.set(
|
||||
( pageX - _this.screen.width * 0.5 - _this.screen.left ) / _this.radius,
|
||||
( _this.screen.height * 0.5 + _this.screen.top - pageY ) / _this.radius,
|
||||
0.0
|
||||
);
|
||||
|
||||
var length = mouseOnBall.length();
|
||||
|
||||
if ( _this.noRoll ) {
|
||||
|
||||
if ( length < Math.SQRT1_2 ) {
|
||||
|
||||
mouseOnBall.z = Math.sqrt( 1.0 - length * length );
|
||||
|
||||
} else {
|
||||
|
||||
mouseOnBall.z = .5 / length;
|
||||
|
||||
}
|
||||
|
||||
} else if ( length > 1.0 ) {
|
||||
|
||||
mouseOnBall.normalize();
|
||||
|
||||
} else {
|
||||
|
||||
mouseOnBall.z = Math.sqrt( 1.0 - length * length );
|
||||
|
||||
}
|
||||
|
||||
_eye.copy( _this.object.position ).sub( _this.target );
|
||||
|
||||
vector.copy( _this.object.up ).setLength( mouseOnBall.y );
|
||||
vector.add( objectUp.copy( _this.object.up ).cross( _eye ).setLength( mouseOnBall.x ) );
|
||||
vector.add( _eye.setLength( mouseOnBall.z ) );
|
||||
|
||||
return vector;
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
this.rotateCamera = ( function() {
|
||||
|
||||
var axis = new THREE.Vector3(),
|
||||
quaternion = new THREE.Quaternion();
|
||||
|
||||
|
||||
return function rotateCamera() {
|
||||
|
||||
var angle = Math.acos( _rotateStart.dot( _rotateEnd ) / _rotateStart.length() / _rotateEnd.length() );
|
||||
|
||||
if ( angle ) {
|
||||
|
||||
axis.crossVectors( _rotateStart, _rotateEnd ).normalize();
|
||||
|
||||
angle *= _this.rotateSpeed;
|
||||
|
||||
quaternion.setFromAxisAngle( axis, - angle );
|
||||
|
||||
_eye.applyQuaternion( quaternion );
|
||||
_this.object.up.applyQuaternion( quaternion );
|
||||
|
||||
_rotateEnd.applyQuaternion( quaternion );
|
||||
|
||||
if ( _this.staticMoving ) {
|
||||
|
||||
_rotateStart.copy( _rotateEnd );
|
||||
|
||||
} else {
|
||||
|
||||
quaternion.setFromAxisAngle( axis, angle * ( _this.dynamicDampingFactor - 1.0 ) );
|
||||
_rotateStart.applyQuaternion( quaternion );
|
||||
|
||||
}
|
||||
|
||||
_changed = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}() );
|
||||
|
||||
this.zoomCamera = function () {
|
||||
|
||||
if ( _state === STATE.TOUCH_ZOOM_PAN ) {
|
||||
|
||||
var factor = _touchZoomDistanceEnd / _touchZoomDistanceStart;
|
||||
_touchZoomDistanceStart = _touchZoomDistanceEnd;
|
||||
|
||||
_this.object.zoom *= factor;
|
||||
|
||||
_changed = true;
|
||||
|
||||
} else {
|
||||
|
||||
var factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed;
|
||||
|
||||
if ( Math.abs( factor - 1.0 ) > EPS && factor > 0.0 ) {
|
||||
|
||||
_this.object.zoom /= factor;
|
||||
|
||||
if ( _this.staticMoving ) {
|
||||
|
||||
_zoomStart.copy( _zoomEnd );
|
||||
|
||||
} else {
|
||||
|
||||
_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;
|
||||
|
||||
}
|
||||
|
||||
_changed = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.panCamera = ( function() {
|
||||
|
||||
var mouseChange = new THREE.Vector2(),
|
||||
objectUp = new THREE.Vector3(),
|
||||
pan = new THREE.Vector3();
|
||||
|
||||
return function panCamera() {
|
||||
|
||||
mouseChange.copy( _panEnd ).sub( _panStart );
|
||||
|
||||
if ( mouseChange.lengthSq() ) {
|
||||
|
||||
// Scale movement to keep clicked/dragged position under cursor
|
||||
var scale_x = ( _this.object.right - _this.object.left ) / _this.object.zoom;
|
||||
var scale_y = ( _this.object.top - _this.object.bottom ) / _this.object.zoom;
|
||||
mouseChange.x *= scale_x;
|
||||
mouseChange.y *= scale_y;
|
||||
|
||||
pan.copy( _eye ).cross( _this.object.up ).setLength( mouseChange.x );
|
||||
pan.add( objectUp.copy( _this.object.up ).setLength( mouseChange.y ) );
|
||||
|
||||
_this.object.position.add( pan );
|
||||
_this.target.add( pan );
|
||||
|
||||
if ( _this.staticMoving ) {
|
||||
|
||||
_panStart.copy( _panEnd );
|
||||
|
||||
} else {
|
||||
|
||||
_panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( _this.dynamicDampingFactor ) );
|
||||
|
||||
}
|
||||
|
||||
_changed = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}() );
|
||||
|
||||
this.update = function () {
|
||||
|
||||
_eye.subVectors( _this.object.position, _this.target );
|
||||
|
||||
if ( ! _this.noRotate ) {
|
||||
|
||||
_this.rotateCamera();
|
||||
|
||||
}
|
||||
|
||||
if ( ! _this.noZoom ) {
|
||||
|
||||
_this.zoomCamera();
|
||||
|
||||
if ( _changed ) {
|
||||
|
||||
_this.object.updateProjectionMatrix();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! _this.noPan ) {
|
||||
|
||||
_this.panCamera();
|
||||
|
||||
}
|
||||
|
||||
_this.object.position.addVectors( _this.target, _eye );
|
||||
|
||||
_this.object.lookAt( _this.target );
|
||||
|
||||
if ( _changed ) {
|
||||
|
||||
_this.dispatchEvent( changeEvent );
|
||||
|
||||
_changed = false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.reset = function () {
|
||||
|
||||
_state = STATE.NONE;
|
||||
_prevState = STATE.NONE;
|
||||
|
||||
_this.target.copy( _this.target0 );
|
||||
_this.object.position.copy( _this.position0 );
|
||||
_this.object.up.copy( _this.up0 );
|
||||
|
||||
_eye.subVectors( _this.object.position, _this.target );
|
||||
|
||||
_this.object.left = _this.left0;
|
||||
_this.object.right = _this.right0;
|
||||
_this.object.top = _this.top0;
|
||||
_this.object.bottom = _this.bottom0;
|
||||
|
||||
_this.object.lookAt( _this.target );
|
||||
|
||||
_this.dispatchEvent( changeEvent );
|
||||
|
||||
_changed = false;
|
||||
|
||||
};
|
||||
|
||||
// listeners
|
||||
|
||||
function keydown( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
window.removeEventListener( 'keydown', keydown );
|
||||
|
||||
_prevState = _state;
|
||||
|
||||
if ( _state !== STATE.NONE ) {
|
||||
|
||||
return;
|
||||
|
||||
} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noRotate ) {
|
||||
|
||||
_state = STATE.ROTATE;
|
||||
|
||||
} else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && ! _this.noZoom ) {
|
||||
|
||||
_state = STATE.ZOOM;
|
||||
|
||||
} else if ( event.keyCode === _this.keys[ STATE.PAN ] && ! _this.noPan ) {
|
||||
|
||||
_state = STATE.PAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function keyup( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
_state = _prevState;
|
||||
|
||||
window.addEventListener( 'keydown', keydown, false );
|
||||
|
||||
}
|
||||
|
||||
function mousedown( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if ( _state === STATE.NONE ) {
|
||||
|
||||
_state = event.button;
|
||||
|
||||
}
|
||||
|
||||
if ( _state === STATE.ROTATE && ! _this.noRotate ) {
|
||||
|
||||
_rotateStart.copy( getMouseProjectionOnBall( event.pageX, event.pageY ) );
|
||||
_rotateEnd.copy( _rotateStart );
|
||||
|
||||
} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
|
||||
|
||||
_zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
_zoomEnd.copy( _zoomStart );
|
||||
|
||||
} else if ( _state === STATE.PAN && ! _this.noPan ) {
|
||||
|
||||
_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
_panEnd.copy( _panStart )
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener( 'mousemove', mousemove, false );
|
||||
document.addEventListener( 'mouseup', mouseup, false );
|
||||
|
||||
_this.dispatchEvent( startEvent );
|
||||
|
||||
}
|
||||
|
||||
function mousemove( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if ( _state === STATE.ROTATE && ! _this.noRotate ) {
|
||||
|
||||
_rotateEnd.copy( getMouseProjectionOnBall( event.pageX, event.pageY ) );
|
||||
|
||||
} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
|
||||
|
||||
_zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
|
||||
} else if ( _state === STATE.PAN && ! _this.noPan ) {
|
||||
|
||||
_panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mouseup( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
_state = STATE.NONE;
|
||||
|
||||
document.removeEventListener( 'mousemove', mousemove );
|
||||
document.removeEventListener( 'mouseup', mouseup );
|
||||
_this.dispatchEvent( endEvent );
|
||||
|
||||
}
|
||||
|
||||
function mousewheel( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
_zoomStart.y += event.deltaY * 0.01;
|
||||
_this.dispatchEvent( startEvent );
|
||||
_this.dispatchEvent( endEvent );
|
||||
|
||||
}
|
||||
|
||||
function touchstart( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1:
|
||||
_state = STATE.TOUCH_ROTATE;
|
||||
_rotateStart.copy( getMouseProjectionOnBall( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
|
||||
_rotateEnd.copy( _rotateStart );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
_state = STATE.TOUCH_ZOOM_PAN;
|
||||
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
||||
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
||||
_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
|
||||
|
||||
var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
|
||||
var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
|
||||
_panStart.copy( getMouseOnScreen( x, y ) );
|
||||
_panEnd.copy( _panStart );
|
||||
break;
|
||||
|
||||
default:
|
||||
_state = STATE.NONE;
|
||||
|
||||
}
|
||||
_this.dispatchEvent( startEvent );
|
||||
|
||||
}
|
||||
|
||||
function touchmove( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1:
|
||||
_rotateEnd.copy( getMouseProjectionOnBall( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
||||
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
||||
_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
|
||||
|
||||
var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
|
||||
var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
|
||||
_panEnd.copy( getMouseOnScreen( x, y ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
_state = STATE.NONE;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function touchend( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1:
|
||||
_rotateEnd.copy( getMouseProjectionOnBall( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
|
||||
_rotateStart.copy( _rotateEnd );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
_touchZoomDistanceStart = _touchZoomDistanceEnd = 0;
|
||||
|
||||
var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
|
||||
var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
|
||||
_panEnd.copy( getMouseOnScreen( x, y ) );
|
||||
_panStart.copy( _panEnd );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
_state = STATE.NONE;
|
||||
_this.dispatchEvent( endEvent );
|
||||
|
||||
}
|
||||
|
||||
function contextmenu( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function() {
|
||||
|
||||
this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
|
||||
this.domElement.removeEventListener( 'mousedown', mousedown, false );
|
||||
this.domElement.removeEventListener( 'wheel', mousewheel, false );
|
||||
|
||||
this.domElement.removeEventListener( 'touchstart', touchstart, false );
|
||||
this.domElement.removeEventListener( 'touchend', touchend, false );
|
||||
this.domElement.removeEventListener( 'touchmove', touchmove, false );
|
||||
|
||||
document.removeEventListener( 'mousemove', mousemove, false );
|
||||
document.removeEventListener( 'mouseup', mouseup, false );
|
||||
|
||||
window.removeEventListener( 'keydown', keydown, false );
|
||||
window.removeEventListener( 'keyup', keyup, false );
|
||||
|
||||
};
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', contextmenu, false );
|
||||
this.domElement.addEventListener( 'mousedown', mousedown, false );
|
||||
this.domElement.addEventListener( 'wheel', mousewheel, false );
|
||||
|
||||
this.domElement.addEventListener( 'touchstart', touchstart, false );
|
||||
this.domElement.addEventListener( 'touchend', touchend, false );
|
||||
this.domElement.addEventListener( 'touchmove', touchmove, false );
|
||||
|
||||
window.addEventListener( 'keydown', keydown, false );
|
||||
window.addEventListener( 'keyup', keyup, false );
|
||||
|
||||
this.handleResize();
|
||||
|
||||
// force an update at start
|
||||
this.update();
|
||||
|
||||
};
|
||||
|
||||
THREE.OrthographicTrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );
|
||||
THREE.OrthographicTrackballControls.prototype.constructor = THREE.OrthographicTrackballControls;
|
||||
69
node_modules/three/examples/js/controls/PointerLockControls.js
generated
vendored
Normal file
69
node_modules/three/examples/js/controls/PointerLockControls.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @author mrdoob / http://mrdoob.com/
|
||||
*/
|
||||
|
||||
THREE.PointerLockControls = function ( camera ) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
camera.rotation.set( 0, 0, 0 );
|
||||
|
||||
var pitchObject = new THREE.Object3D();
|
||||
pitchObject.add( camera );
|
||||
|
||||
var yawObject = new THREE.Object3D();
|
||||
yawObject.position.y = 10;
|
||||
yawObject.add( pitchObject );
|
||||
|
||||
var PI_2 = Math.PI / 2;
|
||||
|
||||
var onMouseMove = function ( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
|
||||
var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
|
||||
|
||||
yawObject.rotation.y -= movementX * 0.002;
|
||||
pitchObject.rotation.x -= movementY * 0.002;
|
||||
|
||||
pitchObject.rotation.x = Math.max( - PI_2, Math.min( PI_2, pitchObject.rotation.x ) );
|
||||
|
||||
};
|
||||
|
||||
this.dispose = function() {
|
||||
|
||||
document.removeEventListener( 'mousemove', onMouseMove, false );
|
||||
|
||||
};
|
||||
|
||||
document.addEventListener( 'mousemove', onMouseMove, false );
|
||||
|
||||
this.enabled = false;
|
||||
|
||||
this.getObject = function () {
|
||||
|
||||
return yawObject;
|
||||
|
||||
};
|
||||
|
||||
this.getDirection = function() {
|
||||
|
||||
// assumes the camera itself is not rotated
|
||||
|
||||
var direction = new THREE.Vector3( 0, 0, - 1 );
|
||||
var rotation = new THREE.Euler( 0, 0, 0, "YXZ" );
|
||||
|
||||
return function( v ) {
|
||||
|
||||
rotation.set( pitchObject.rotation.x, yawObject.rotation.y, 0 );
|
||||
|
||||
v.copy( direction ).applyEuler( rotation );
|
||||
|
||||
return v;
|
||||
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
};
|
||||
623
node_modules/three/examples/js/controls/TrackballControls.js
generated
vendored
Normal file
623
node_modules/three/examples/js/controls/TrackballControls.js
generated
vendored
Normal file
@@ -0,0 +1,623 @@
|
||||
/**
|
||||
* @author Eberhard Graether / http://egraether.com/
|
||||
* @author Mark Lundin / http://mark-lundin.com
|
||||
* @author Simone Manini / http://daron1337.github.io
|
||||
* @author Luca Antiga / http://lantiga.github.io
|
||||
*/
|
||||
|
||||
THREE.TrackballControls = function ( object, domElement ) {
|
||||
|
||||
var _this = this;
|
||||
var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
|
||||
|
||||
this.object = object;
|
||||
this.domElement = ( domElement !== undefined ) ? domElement : document;
|
||||
|
||||
// API
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.screen = { left: 0, top: 0, width: 0, height: 0 };
|
||||
|
||||
this.rotateSpeed = 1.0;
|
||||
this.zoomSpeed = 1.2;
|
||||
this.panSpeed = 0.3;
|
||||
|
||||
this.noRotate = false;
|
||||
this.noZoom = false;
|
||||
this.noPan = false;
|
||||
|
||||
this.staticMoving = false;
|
||||
this.dynamicDampingFactor = 0.2;
|
||||
|
||||
this.minDistance = 0;
|
||||
this.maxDistance = Infinity;
|
||||
|
||||
this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ];
|
||||
|
||||
// internals
|
||||
|
||||
this.target = new THREE.Vector3();
|
||||
|
||||
var EPS = 0.000001;
|
||||
|
||||
var lastPosition = new THREE.Vector3();
|
||||
|
||||
var _state = STATE.NONE,
|
||||
_prevState = STATE.NONE,
|
||||
|
||||
_eye = new THREE.Vector3(),
|
||||
|
||||
_movePrev = new THREE.Vector2(),
|
||||
_moveCurr = new THREE.Vector2(),
|
||||
|
||||
_lastAxis = new THREE.Vector3(),
|
||||
_lastAngle = 0,
|
||||
|
||||
_zoomStart = new THREE.Vector2(),
|
||||
_zoomEnd = new THREE.Vector2(),
|
||||
|
||||
_touchZoomDistanceStart = 0,
|
||||
_touchZoomDistanceEnd = 0,
|
||||
|
||||
_panStart = new THREE.Vector2(),
|
||||
_panEnd = new THREE.Vector2();
|
||||
|
||||
// for reset
|
||||
|
||||
this.target0 = this.target.clone();
|
||||
this.position0 = this.object.position.clone();
|
||||
this.up0 = this.object.up.clone();
|
||||
|
||||
// events
|
||||
|
||||
var changeEvent = { type: 'change' };
|
||||
var startEvent = { type: 'start' };
|
||||
var endEvent = { type: 'end' };
|
||||
|
||||
|
||||
// methods
|
||||
|
||||
this.handleResize = function () {
|
||||
|
||||
if ( this.domElement === document ) {
|
||||
|
||||
this.screen.left = 0;
|
||||
this.screen.top = 0;
|
||||
this.screen.width = window.innerWidth;
|
||||
this.screen.height = window.innerHeight;
|
||||
|
||||
} else {
|
||||
|
||||
var box = this.domElement.getBoundingClientRect();
|
||||
// adjustments come from similar code in the jquery offset() function
|
||||
var d = this.domElement.ownerDocument.documentElement;
|
||||
this.screen.left = box.left + window.pageXOffset - d.clientLeft;
|
||||
this.screen.top = box.top + window.pageYOffset - d.clientTop;
|
||||
this.screen.width = box.width;
|
||||
this.screen.height = box.height;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.handleEvent = function ( event ) {
|
||||
|
||||
if ( typeof this[ event.type ] == 'function' ) {
|
||||
|
||||
this[ event.type ]( event );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var getMouseOnScreen = ( function () {
|
||||
|
||||
var vector = new THREE.Vector2();
|
||||
|
||||
return function getMouseOnScreen( pageX, pageY ) {
|
||||
|
||||
vector.set(
|
||||
( pageX - _this.screen.left ) / _this.screen.width,
|
||||
( pageY - _this.screen.top ) / _this.screen.height
|
||||
);
|
||||
|
||||
return vector;
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
var getMouseOnCircle = ( function () {
|
||||
|
||||
var vector = new THREE.Vector2();
|
||||
|
||||
return function getMouseOnCircle( pageX, pageY ) {
|
||||
|
||||
vector.set(
|
||||
( ( pageX - _this.screen.width * 0.5 - _this.screen.left ) / ( _this.screen.width * 0.5 ) ),
|
||||
( ( _this.screen.height + 2 * ( _this.screen.top - pageY ) ) / _this.screen.width ) // screen.width intentional
|
||||
);
|
||||
|
||||
return vector;
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
this.rotateCamera = ( function() {
|
||||
|
||||
var axis = new THREE.Vector3(),
|
||||
quaternion = new THREE.Quaternion(),
|
||||
eyeDirection = new THREE.Vector3(),
|
||||
objectUpDirection = new THREE.Vector3(),
|
||||
objectSidewaysDirection = new THREE.Vector3(),
|
||||
moveDirection = new THREE.Vector3(),
|
||||
angle;
|
||||
|
||||
return function rotateCamera() {
|
||||
|
||||
moveDirection.set( _moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0 );
|
||||
angle = moveDirection.length();
|
||||
|
||||
if ( angle ) {
|
||||
|
||||
_eye.copy( _this.object.position ).sub( _this.target );
|
||||
|
||||
eyeDirection.copy( _eye ).normalize();
|
||||
objectUpDirection.copy( _this.object.up ).normalize();
|
||||
objectSidewaysDirection.crossVectors( objectUpDirection, eyeDirection ).normalize();
|
||||
|
||||
objectUpDirection.setLength( _moveCurr.y - _movePrev.y );
|
||||
objectSidewaysDirection.setLength( _moveCurr.x - _movePrev.x );
|
||||
|
||||
moveDirection.copy( objectUpDirection.add( objectSidewaysDirection ) );
|
||||
|
||||
axis.crossVectors( moveDirection, _eye ).normalize();
|
||||
|
||||
angle *= _this.rotateSpeed;
|
||||
quaternion.setFromAxisAngle( axis, angle );
|
||||
|
||||
_eye.applyQuaternion( quaternion );
|
||||
_this.object.up.applyQuaternion( quaternion );
|
||||
|
||||
_lastAxis.copy( axis );
|
||||
_lastAngle = angle;
|
||||
|
||||
} else if ( ! _this.staticMoving && _lastAngle ) {
|
||||
|
||||
_lastAngle *= Math.sqrt( 1.0 - _this.dynamicDampingFactor );
|
||||
_eye.copy( _this.object.position ).sub( _this.target );
|
||||
quaternion.setFromAxisAngle( _lastAxis, _lastAngle );
|
||||
_eye.applyQuaternion( quaternion );
|
||||
_this.object.up.applyQuaternion( quaternion );
|
||||
|
||||
}
|
||||
|
||||
_movePrev.copy( _moveCurr );
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
|
||||
this.zoomCamera = function () {
|
||||
|
||||
var factor;
|
||||
|
||||
if ( _state === STATE.TOUCH_ZOOM_PAN ) {
|
||||
|
||||
factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
|
||||
_touchZoomDistanceStart = _touchZoomDistanceEnd;
|
||||
_eye.multiplyScalar( factor );
|
||||
|
||||
} else {
|
||||
|
||||
factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed;
|
||||
|
||||
if ( factor !== 1.0 && factor > 0.0 ) {
|
||||
|
||||
_eye.multiplyScalar( factor );
|
||||
|
||||
}
|
||||
|
||||
if ( _this.staticMoving ) {
|
||||
|
||||
_zoomStart.copy( _zoomEnd );
|
||||
|
||||
} else {
|
||||
|
||||
_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.panCamera = ( function() {
|
||||
|
||||
var mouseChange = new THREE.Vector2(),
|
||||
objectUp = new THREE.Vector3(),
|
||||
pan = new THREE.Vector3();
|
||||
|
||||
return function panCamera() {
|
||||
|
||||
mouseChange.copy( _panEnd ).sub( _panStart );
|
||||
|
||||
if ( mouseChange.lengthSq() ) {
|
||||
|
||||
mouseChange.multiplyScalar( _eye.length() * _this.panSpeed );
|
||||
|
||||
pan.copy( _eye ).cross( _this.object.up ).setLength( mouseChange.x );
|
||||
pan.add( objectUp.copy( _this.object.up ).setLength( mouseChange.y ) );
|
||||
|
||||
_this.object.position.add( pan );
|
||||
_this.target.add( pan );
|
||||
|
||||
if ( _this.staticMoving ) {
|
||||
|
||||
_panStart.copy( _panEnd );
|
||||
|
||||
} else {
|
||||
|
||||
_panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( _this.dynamicDampingFactor ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
this.checkDistances = function () {
|
||||
|
||||
if ( ! _this.noZoom || ! _this.noPan ) {
|
||||
|
||||
if ( _eye.lengthSq() > _this.maxDistance * _this.maxDistance ) {
|
||||
|
||||
_this.object.position.addVectors( _this.target, _eye.setLength( _this.maxDistance ) );
|
||||
_zoomStart.copy( _zoomEnd );
|
||||
|
||||
}
|
||||
|
||||
if ( _eye.lengthSq() < _this.minDistance * _this.minDistance ) {
|
||||
|
||||
_this.object.position.addVectors( _this.target, _eye.setLength( _this.minDistance ) );
|
||||
_zoomStart.copy( _zoomEnd );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.update = function () {
|
||||
|
||||
_eye.subVectors( _this.object.position, _this.target );
|
||||
|
||||
if ( ! _this.noRotate ) {
|
||||
|
||||
_this.rotateCamera();
|
||||
|
||||
}
|
||||
|
||||
if ( ! _this.noZoom ) {
|
||||
|
||||
_this.zoomCamera();
|
||||
|
||||
}
|
||||
|
||||
if ( ! _this.noPan ) {
|
||||
|
||||
_this.panCamera();
|
||||
|
||||
}
|
||||
|
||||
_this.object.position.addVectors( _this.target, _eye );
|
||||
|
||||
_this.checkDistances();
|
||||
|
||||
_this.object.lookAt( _this.target );
|
||||
|
||||
if ( lastPosition.distanceToSquared( _this.object.position ) > EPS ) {
|
||||
|
||||
_this.dispatchEvent( changeEvent );
|
||||
|
||||
lastPosition.copy( _this.object.position );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.reset = function () {
|
||||
|
||||
_state = STATE.NONE;
|
||||
_prevState = STATE.NONE;
|
||||
|
||||
_this.target.copy( _this.target0 );
|
||||
_this.object.position.copy( _this.position0 );
|
||||
_this.object.up.copy( _this.up0 );
|
||||
|
||||
_eye.subVectors( _this.object.position, _this.target );
|
||||
|
||||
_this.object.lookAt( _this.target );
|
||||
|
||||
_this.dispatchEvent( changeEvent );
|
||||
|
||||
lastPosition.copy( _this.object.position );
|
||||
|
||||
};
|
||||
|
||||
// listeners
|
||||
|
||||
function keydown( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
window.removeEventListener( 'keydown', keydown );
|
||||
|
||||
_prevState = _state;
|
||||
|
||||
if ( _state !== STATE.NONE ) {
|
||||
|
||||
return;
|
||||
|
||||
} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noRotate ) {
|
||||
|
||||
_state = STATE.ROTATE;
|
||||
|
||||
} else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && ! _this.noZoom ) {
|
||||
|
||||
_state = STATE.ZOOM;
|
||||
|
||||
} else if ( event.keyCode === _this.keys[ STATE.PAN ] && ! _this.noPan ) {
|
||||
|
||||
_state = STATE.PAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function keyup( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
_state = _prevState;
|
||||
|
||||
window.addEventListener( 'keydown', keydown, false );
|
||||
|
||||
}
|
||||
|
||||
function mousedown( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if ( _state === STATE.NONE ) {
|
||||
|
||||
_state = event.button;
|
||||
|
||||
}
|
||||
|
||||
if ( _state === STATE.ROTATE && ! _this.noRotate ) {
|
||||
|
||||
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
||||
_movePrev.copy( _moveCurr );
|
||||
|
||||
} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
|
||||
|
||||
_zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
_zoomEnd.copy( _zoomStart );
|
||||
|
||||
} else if ( _state === STATE.PAN && ! _this.noPan ) {
|
||||
|
||||
_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
_panEnd.copy( _panStart );
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener( 'mousemove', mousemove, false );
|
||||
document.addEventListener( 'mouseup', mouseup, false );
|
||||
|
||||
_this.dispatchEvent( startEvent );
|
||||
|
||||
}
|
||||
|
||||
function mousemove( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if ( _state === STATE.ROTATE && ! _this.noRotate ) {
|
||||
|
||||
_movePrev.copy( _moveCurr );
|
||||
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
||||
|
||||
} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
|
||||
|
||||
_zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
|
||||
} else if ( _state === STATE.PAN && ! _this.noPan ) {
|
||||
|
||||
_panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mouseup( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
_state = STATE.NONE;
|
||||
|
||||
document.removeEventListener( 'mousemove', mousemove );
|
||||
document.removeEventListener( 'mouseup', mouseup );
|
||||
_this.dispatchEvent( endEvent );
|
||||
|
||||
}
|
||||
|
||||
function mousewheel( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
switch ( event.deltaMode ) {
|
||||
|
||||
case 2:
|
||||
// Zoom in pages
|
||||
_zoomStart.y -= event.deltaY * 0.025;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// Zoom in lines
|
||||
_zoomStart.y -= event.deltaY * 0.01;
|
||||
break;
|
||||
|
||||
default:
|
||||
// undefined, 0, assume pixels
|
||||
_zoomStart.y -= event.deltaY * 0.00025;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
_this.dispatchEvent( startEvent );
|
||||
_this.dispatchEvent( endEvent );
|
||||
|
||||
}
|
||||
|
||||
function touchstart( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1:
|
||||
_state = STATE.TOUCH_ROTATE;
|
||||
_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
|
||||
_movePrev.copy( _moveCurr );
|
||||
break;
|
||||
|
||||
default: // 2 or more
|
||||
_state = STATE.TOUCH_ZOOM_PAN;
|
||||
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
||||
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
||||
_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
|
||||
|
||||
var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
|
||||
var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
|
||||
_panStart.copy( getMouseOnScreen( x, y ) );
|
||||
_panEnd.copy( _panStart );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
_this.dispatchEvent( startEvent );
|
||||
|
||||
}
|
||||
|
||||
function touchmove( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1:
|
||||
_movePrev.copy( _moveCurr );
|
||||
_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
|
||||
break;
|
||||
|
||||
default: // 2 or more
|
||||
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
||||
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
||||
_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
|
||||
|
||||
var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
|
||||
var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
|
||||
_panEnd.copy( getMouseOnScreen( x, y ) );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function touchend( event ) {
|
||||
|
||||
if ( _this.enabled === false ) return;
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 0:
|
||||
_state = STATE.NONE;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
_state = STATE.TOUCH_ROTATE;
|
||||
_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
|
||||
_movePrev.copy( _moveCurr );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
_this.dispatchEvent( endEvent );
|
||||
|
||||
}
|
||||
|
||||
function contextmenu( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function() {
|
||||
|
||||
this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
|
||||
this.domElement.removeEventListener( 'mousedown', mousedown, false );
|
||||
this.domElement.removeEventListener( 'wheel', mousewheel, false );
|
||||
|
||||
this.domElement.removeEventListener( 'touchstart', touchstart, false );
|
||||
this.domElement.removeEventListener( 'touchend', touchend, false );
|
||||
this.domElement.removeEventListener( 'touchmove', touchmove, false );
|
||||
|
||||
document.removeEventListener( 'mousemove', mousemove, false );
|
||||
document.removeEventListener( 'mouseup', mouseup, false );
|
||||
|
||||
window.removeEventListener( 'keydown', keydown, false );
|
||||
window.removeEventListener( 'keyup', keyup, false );
|
||||
|
||||
};
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', contextmenu, false );
|
||||
this.domElement.addEventListener( 'mousedown', mousedown, false );
|
||||
this.domElement.addEventListener( 'wheel', mousewheel, false );
|
||||
|
||||
this.domElement.addEventListener( 'touchstart', touchstart, false );
|
||||
this.domElement.addEventListener( 'touchend', touchend, false );
|
||||
this.domElement.addEventListener( 'touchmove', touchmove, false );
|
||||
|
||||
window.addEventListener( 'keydown', keydown, false );
|
||||
window.addEventListener( 'keyup', keyup, false );
|
||||
|
||||
this.handleResize();
|
||||
|
||||
// force an update at start
|
||||
this.update();
|
||||
|
||||
};
|
||||
|
||||
THREE.TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );
|
||||
THREE.TrackballControls.prototype.constructor = THREE.TrackballControls;
|
||||
1159
node_modules/three/examples/js/controls/TransformControls.js
generated
vendored
Normal file
1159
node_modules/three/examples/js/controls/TransformControls.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
173
node_modules/three/examples/js/controls/VRControls.js
generated
vendored
Normal file
173
node_modules/three/examples/js/controls/VRControls.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* @author dmarcos / https://github.com/dmarcos
|
||||
* @author mrdoob / http://mrdoob.com
|
||||
*/
|
||||
|
||||
THREE.VRControls = function ( object, onError ) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
var vrDisplay, vrDisplays;
|
||||
|
||||
var standingMatrix = new THREE.Matrix4();
|
||||
|
||||
var frameData = null;
|
||||
|
||||
if ( 'VRFrameData' in window ) {
|
||||
|
||||
frameData = new VRFrameData();
|
||||
|
||||
}
|
||||
|
||||
function gotVRDisplays( displays ) {
|
||||
|
||||
vrDisplays = displays;
|
||||
|
||||
if ( displays.length > 0 ) {
|
||||
|
||||
vrDisplay = displays[ 0 ];
|
||||
|
||||
} else {
|
||||
|
||||
if ( onError ) onError( 'VR input not available.' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( navigator.getVRDisplays ) {
|
||||
|
||||
navigator.getVRDisplays().then( gotVRDisplays ).catch ( function () {
|
||||
|
||||
console.warn( 'THREE.VRControls: Unable to get VR Displays' );
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
// the Rift SDK returns the position in meters
|
||||
// this scale factor allows the user to define how meters
|
||||
// are converted to scene units.
|
||||
|
||||
this.scale = 1;
|
||||
|
||||
// If true will use "standing space" coordinate system where y=0 is the
|
||||
// floor and x=0, z=0 is the center of the room.
|
||||
this.standing = false;
|
||||
|
||||
// Distance from the users eyes to the floor in meters. Used when
|
||||
// standing=true but the VRDisplay doesn't provide stageParameters.
|
||||
this.userHeight = 1.6;
|
||||
|
||||
this.getVRDisplay = function () {
|
||||
|
||||
return vrDisplay;
|
||||
|
||||
};
|
||||
|
||||
this.setVRDisplay = function ( value ) {
|
||||
|
||||
vrDisplay = value;
|
||||
|
||||
};
|
||||
|
||||
this.getVRDisplays = function () {
|
||||
|
||||
console.warn( 'THREE.VRControls: getVRDisplays() is being deprecated.' );
|
||||
return vrDisplays;
|
||||
|
||||
};
|
||||
|
||||
this.getStandingMatrix = function () {
|
||||
|
||||
return standingMatrix;
|
||||
|
||||
};
|
||||
|
||||
this.update = function () {
|
||||
|
||||
if ( vrDisplay ) {
|
||||
|
||||
var pose;
|
||||
|
||||
if ( vrDisplay.getFrameData ) {
|
||||
|
||||
vrDisplay.getFrameData( frameData );
|
||||
pose = frameData.pose;
|
||||
|
||||
} else if ( vrDisplay.getPose ) {
|
||||
|
||||
pose = vrDisplay.getPose();
|
||||
|
||||
}
|
||||
|
||||
if ( pose.orientation !== null ) {
|
||||
|
||||
object.quaternion.fromArray( pose.orientation );
|
||||
|
||||
}
|
||||
|
||||
if ( pose.position !== null ) {
|
||||
|
||||
object.position.fromArray( pose.position );
|
||||
|
||||
} else {
|
||||
|
||||
object.position.set( 0, 0, 0 );
|
||||
|
||||
}
|
||||
|
||||
if ( this.standing ) {
|
||||
|
||||
if ( vrDisplay.stageParameters ) {
|
||||
|
||||
object.updateMatrix();
|
||||
|
||||
standingMatrix.fromArray( vrDisplay.stageParameters.sittingToStandingTransform );
|
||||
object.applyMatrix( standingMatrix );
|
||||
|
||||
} else {
|
||||
|
||||
object.position.setY( object.position.y + this.userHeight );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
object.position.multiplyScalar( scope.scale );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.resetPose = function () {
|
||||
|
||||
if ( vrDisplay ) {
|
||||
|
||||
vrDisplay.resetPose();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.resetSensor = function () {
|
||||
|
||||
console.warn( 'THREE.VRControls: .resetSensor() is now .resetPose().' );
|
||||
this.resetPose();
|
||||
|
||||
};
|
||||
|
||||
this.zeroSensor = function () {
|
||||
|
||||
console.warn( 'THREE.VRControls: .zeroSensor() is now .resetPose().' );
|
||||
this.resetPose();
|
||||
|
||||
};
|
||||
|
||||
this.dispose = function () {
|
||||
|
||||
vrDisplay = null;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user