未验证 提交 ca023aa9 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #13794 from Mugen87/dev4

Examples: Clean up
......@@ -199,7 +199,7 @@ THREE.EditorControls = function ( object, domElement ) {
}
this.dispose = function() {
this.dispose = function () {
domElement.removeEventListener( 'contextmenu', contextmenu, false );
domElement.removeEventListener( 'mousedown', onMouseDown, false );
......
......@@ -184,7 +184,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
};
this.update = function( delta ) {
this.update = function ( delta ) {
if ( this.enabled === false ) return;
......@@ -259,7 +259,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
}
this.dispose = function() {
this.dispose = function () {
this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
this.domElement.removeEventListener( 'mousedown', _onMouseDown, false );
......
......@@ -39,7 +39,7 @@ THREE.FlyControls = function ( object, domElement ) {
};
this.keydown = function( event ) {
this.keydown = function ( event ) {
if ( event.altKey ) {
......@@ -78,7 +78,7 @@ THREE.FlyControls = function ( object, domElement ) {
};
this.keyup = function( event ) {
this.keyup = function ( event ) {
switch ( event.keyCode ) {
......@@ -109,7 +109,7 @@ THREE.FlyControls = function ( object, domElement ) {
};
this.mousedown = function( event ) {
this.mousedown = function ( event ) {
if ( this.domElement !== document ) {
......@@ -139,16 +139,16 @@ THREE.FlyControls = function ( object, domElement ) {
};
this.mousemove = function( event ) {
this.mousemove = function ( event ) {
if ( ! this.dragToLook || this.mouseStatus > 0 ) {
var container = this.getContainerDimensions();
var halfWidth = container.size[ 0 ] / 2;
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.moveState.yawLeft = - ( ( event.pageX - container.offset[ 0 ] ) - halfWidth ) / halfWidth;
this.moveState.pitchDown = ( ( event.pageY - container.offset[ 1 ] ) - halfHeight ) / halfHeight;
this.updateRotationVector();
......@@ -156,7 +156,7 @@ THREE.FlyControls = function ( object, domElement ) {
};
this.mouseup = function( event ) {
this.mouseup = function ( event ) {
event.preventDefault();
event.stopPropagation();
......@@ -184,7 +184,7 @@ THREE.FlyControls = function ( object, domElement ) {
};
this.update = function( delta ) {
this.update = function ( delta ) {
var moveMult = delta * this.movementSpeed;
var rotMult = delta * this.rollSpeed;
......@@ -202,42 +202,42 @@ THREE.FlyControls = function ( object, domElement ) {
};
this.updateMovementVector = function() {
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.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.updateRotationVector = function () {
this.rotationVector.x = ( - this.moveState.pitchDown + this.moveState.pitchUp );
this.rotationVector.y = ( - this.moveState.yawRight + this.moveState.yawLeft );
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() {
this.getContainerDimensions = function () {
if ( this.domElement != document ) {
return {
size : [ this.domElement.offsetWidth, this.domElement.offsetHeight ],
offset : [ this.domElement.offsetLeft, this.domElement.offsetTop ]
size: [ this.domElement.offsetWidth, this.domElement.offsetHeight ],
offset: [ this.domElement.offsetLeft, this.domElement.offsetTop ]
};
} else {
return {
size : [ window.innerWidth, window.innerHeight ],
offset : [ 0, 0 ]
size: [ window.innerWidth, window.innerHeight ],
offset: [ 0, 0 ]
};
}
......@@ -260,7 +260,7 @@ THREE.FlyControls = function ( object, domElement ) {
}
this.dispose = function() {
this.dispose = function () {
this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
this.domElement.removeEventListener( 'mousedown', _mousedown, false );
......@@ -282,10 +282,10 @@ THREE.FlyControls = function ( object, domElement ) {
this.domElement.addEventListener( 'mousemove', _mousemove, false );
this.domElement.addEventListener( 'mousedown', _mousedown, false );
this.domElement.addEventListener( 'mouseup', _mouseup, false );
this.domElement.addEventListener( 'mouseup', _mouseup, false );
window.addEventListener( 'keydown', _keydown, false );
window.addEventListener( 'keyup', _keyup, false );
window.addEventListener( 'keyup', _keyup, false );
this.updateMovementVector();
this.updateRotationVector();
......
......@@ -457,7 +457,7 @@ THREE.OrbitControls = function ( object, domElement ) {
rotateEnd.set( event.clientX, event.clientY );
rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );;
rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
......
......@@ -31,7 +31,7 @@ THREE.PointerLockControls = function ( camera ) {
};
this.dispose = function() {
this.dispose = function () {
document.removeEventListener( 'mousemove', onMouseMove, false );
......@@ -47,14 +47,14 @@ THREE.PointerLockControls = function ( camera ) {
};
this.getDirection = function() {
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" );
var rotation = new THREE.Euler( 0, 0, 0, 'YXZ' );
return function( v ) {
return function ( v ) {
rotation.set( pitchObject.rotation.x, yawObject.rotation.y, 0 );
......
......@@ -44,24 +44,24 @@ THREE.TrackballControls = function ( object, domElement ) {
var lastPosition = new THREE.Vector3();
var _state = STATE.NONE,
_prevState = STATE.NONE,
_prevState = STATE.NONE,
_eye = new THREE.Vector3(),
_eye = new THREE.Vector3(),
_movePrev = new THREE.Vector2(),
_moveCurr = new THREE.Vector2(),
_movePrev = new THREE.Vector2(),
_moveCurr = new THREE.Vector2(),
_lastAxis = new THREE.Vector3(),
_lastAngle = 0,
_lastAxis = new THREE.Vector3(),
_lastAngle = 0,
_zoomStart = new THREE.Vector2(),
_zoomEnd = new THREE.Vector2(),
_zoomStart = new THREE.Vector2(),
_zoomEnd = new THREE.Vector2(),
_touchZoomDistanceStart = 0,
_touchZoomDistanceEnd = 0,
_touchZoomDistanceStart = 0,
_touchZoomDistanceEnd = 0,
_panStart = new THREE.Vector2(),
_panEnd = new THREE.Vector2();
_panStart = new THREE.Vector2(),
_panEnd = new THREE.Vector2();
// for reset
......@@ -145,7 +145,7 @@ THREE.TrackballControls = function ( object, domElement ) {
}() );
this.rotateCamera = ( function() {
this.rotateCamera = ( function () {
var axis = new THREE.Vector3(),
quaternion = new THREE.Quaternion(),
......@@ -235,7 +235,7 @@ THREE.TrackballControls = function ( object, domElement ) {
};
this.panCamera = ( function() {
this.panCamera = ( function () {
var mouseChange = new THREE.Vector2(),
objectUp = new THREE.Vector3(),
......@@ -469,7 +469,7 @@ THREE.TrackballControls = function ( object, domElement ) {
function mousewheel( event ) {
if ( _this.enabled === false ) return;
if ( _this.noZoom === true ) return;
event.preventDefault();
......@@ -587,7 +587,7 @@ THREE.TrackballControls = function ( object, domElement ) {
}
this.dispose = function() {
this.dispose = function () {
this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
this.domElement.removeEventListener( 'mousedown', mousedown, false );
......
......@@ -21,7 +21,7 @@
this.oldColor = this.color.clone();
this.oldOpacity = this.opacity;
this.highlight = function( highlighted ) {
this.highlight = function ( highlighted ) {
if ( highlighted ) {
......@@ -58,7 +58,7 @@
this.oldColor = this.color.clone();
this.oldOpacity = this.opacity;
this.highlight = function( highlighted ) {
this.highlight = function ( highlighted ) {
if ( highlighted ) {
......@@ -103,9 +103,9 @@
var planeMaterial = new THREE.MeshBasicMaterial( { visible: false, side: THREE.DoubleSide } );
var planes = {
"XY": new THREE.Mesh( planeGeometry, planeMaterial ),
"YZ": new THREE.Mesh( planeGeometry, planeMaterial ),
"XZ": new THREE.Mesh( planeGeometry, planeMaterial ),
"XY": new THREE.Mesh( planeGeometry, planeMaterial ),
"YZ": new THREE.Mesh( planeGeometry, planeMaterial ),
"XZ": new THREE.Mesh( planeGeometry, planeMaterial ),
"XYZE": new THREE.Mesh( planeGeometry, planeMaterial )
};
......@@ -124,7 +124,7 @@
//// HANDLES AND PICKERS
var setupGizmos = function( gizmoMap, parent ) {
var setupGizmos = function ( gizmoMap, parent ) {
for ( var name in gizmoMap ) {
......@@ -176,7 +176,7 @@
this.highlight = function ( axis ) {
this.traverse( function( child ) {
this.traverse( function ( child ) {
if ( child.material && child.material.highlight ) {
......@@ -207,7 +207,7 @@
var vec2 = new THREE.Vector3( 0, 1, 0 );
var lookAtMatrix = new THREE.Matrix4();
this.traverse( function( child ) {
this.traverse( function ( child ) {
if ( child.name.search( "E" ) !== - 1 ) {
......@@ -235,13 +235,13 @@
arrowGeometry.merge( mesh.geometry, mesh.matrix );
var lineXGeometry = new THREE.BufferGeometry();
lineXGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 1, 0, 0 ], 3 ) );
lineXGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 1, 0, 0 ], 3 ) );
var lineYGeometry = new THREE.BufferGeometry();
lineYGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) );
lineYGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) );
var lineZGeometry = new THREE.BufferGeometry();
lineZGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) );
lineZGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) );
this.handleGizmos = {
......@@ -671,12 +671,12 @@
var oldScale = new THREE.Vector3();
var oldRotationMatrix = new THREE.Matrix4();
var parentRotationMatrix = new THREE.Matrix4();
var parentRotationMatrix = new THREE.Matrix4();
var parentScale = new THREE.Vector3();
var worldPosition = new THREE.Vector3();
var worldRotation = new THREE.Euler();
var worldRotationMatrix = new THREE.Matrix4();
var worldRotationMatrix = new THREE.Matrix4();
var camPosition = new THREE.Vector3();
var camRotation = new THREE.Euler();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册