Skip to content

Commit

Permalink
Updated examples builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Dec 16, 2021
1 parent 793dbff commit 9a74771
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 243 deletions.
1 change: 0 additions & 1 deletion examples/js/animation/MMDPhysics.js
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,6 @@

}


function createCapsuleGeometry( radius, cylinderHeight, segmentsRadius, segmentsHeight ) {

var geometry = new THREE.CylinderGeometry( radius, radius, cylinderHeight, segmentsRadius, segmentsHeight, true );
Expand Down
58 changes: 22 additions & 36 deletions examples/js/controls/ArcballControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
const _raycaster = new THREE.Raycaster();

const _offset = new THREE.Vector3();

const _gizmoMatrixStateTemp = new THREE.Matrix4();

const _cameraMatrixStateTemp = new THREE.Matrix4();

const _scalePointTemp = new THREE.Vector3();
/**
*
* @param {Camera} camera Virtual camera used in the scene
Expand Down Expand Up @@ -567,28 +573,6 @@

};

this.onKeyDown = event => {

if ( event.key == 'c' ) {

if ( event.ctrlKey || event.metaKey ) {

this.copyState();

}

} else if ( event.key == 'v' ) {

if ( event.ctrlKey || event.metaKey ) {

this.pasteState();

}

}

};

this.onSinglePanStart = ( event, operation ) => {

if ( this.enabled ) {
Expand Down Expand Up @@ -1621,13 +1605,13 @@

this._translationMatrix.makeTranslation( _offset.x, _offset.y, _offset.z );

const gizmoStateTemp = this._gizmoMatrixState.clone();
_gizmoMatrixStateTemp.copy( this._gizmoMatrixState );

this._gizmoMatrixState.premultiply( this._translationMatrix );

this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );

const cameraStateTemp = this._cameraMatrixState.clone();
_cameraMatrixStateTemp.copy( this._cameraMatrixState );

this._cameraMatrixState.premultiply( this._translationMatrix );

Expand All @@ -1640,9 +1624,9 @@

}

this._gizmoMatrixState.copy( gizmoStateTemp );
this._gizmoMatrixState.copy( _gizmoMatrixStateTemp );

this._cameraMatrixState.copy( cameraStateTemp );
this._cameraMatrixState.copy( _cameraMatrixStateTemp );

};

Expand Down Expand Up @@ -2163,7 +2147,8 @@

this.scale = ( size, point, scaleGizmos = true ) => {

const scalePoint = point.clone();
_scalePointTemp.copy( point );

let sizeInverse = 1 / size;

if ( this.camera.isOrthographicCamera ) {
Expand Down Expand Up @@ -2199,11 +2184,13 @@
this._m4_2.multiply( this._translationMatrix ); //move camera and gizmos to obtain pinch effect


scalePoint.sub( this._v3_1 );
const amount = scalePoint.clone().multiplyScalar( sizeInverse );
scalePoint.sub( amount );
_scalePointTemp.sub( this._v3_1 );

const amount = _scalePointTemp.clone().multiplyScalar( sizeInverse );

_scalePointTemp.sub( amount );

this._m4_1.makeTranslation( scalePoint.x, scalePoint.y, scalePoint.z );
this._m4_1.makeTranslation( _scalePointTemp.x, _scalePointTemp.y, _scalePointTemp.z );

this._m4_2.premultiply( this._m4_1 );

Expand All @@ -2217,7 +2204,7 @@
this._v3_2.setFromMatrixPosition( this._gizmoMatrixState ); //move camera


let distance = this._v3_1.distanceTo( scalePoint );
let distance = this._v3_1.distanceTo( _scalePointTemp );

let amount = distance - distance * sizeInverse; //check min and max distance

Expand All @@ -2235,18 +2222,18 @@

}

_offset.copy( scalePoint ).sub( this._v3_1 ).normalize().multiplyScalar( amount );
_offset.copy( _scalePointTemp ).sub( this._v3_1 ).normalize().multiplyScalar( amount );

this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );

if ( scaleGizmos ) {

//scale gizmos so they appear in the same spot having the same dimension
const pos = this._v3_2;
distance = pos.distanceTo( scalePoint );
distance = pos.distanceTo( _scalePointTemp );
amount = distance - distance * sizeInverse;

_offset.copy( scalePoint ).sub( this._v3_2 ).normalize().multiplyScalar( amount );
_offset.copy( _scalePointTemp ).sub( this._v3_2 ).normalize().multiplyScalar( amount );

this._translationMatrix.makeTranslation( pos.x, pos.y, pos.z );

Expand Down Expand Up @@ -2827,7 +2814,6 @@
this.domElement.addEventListener( 'wheel', this.onWheel );
this.domElement.addEventListener( 'pointerdown', this.onPointerDown );
this.domElement.addEventListener( 'pointercancel', this.onPointerCancel );
window.addEventListener( 'keydown', this.onKeyDown );
window.addEventListener( 'resize', this.onWindowResize );

} //listeners
Expand Down
Loading

0 comments on commit 9a74771

Please sign in to comment.