Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples: Clean up #14825

Merged
merged 1 commit into from Sep 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions examples/canvas_materials_reflection.html
Expand Up @@ -45,10 +45,7 @@

<script>

var camera, scene, renderer,
particle1, particle2, particle2,
light1, light2, light3,
loader, mesh;
var camera, scene, renderer, loader, mesh;

init();
animate();
Expand Down
83 changes: 42 additions & 41 deletions examples/js/Volume.js
Expand Up @@ -11,7 +11,7 @@
* @param {string} type The type of data (uint8, uint16, ...)
* @param {ArrayBuffer} arrayBuffer The buffer with volume data
*/
THREE.Volume = function( xLength, yLength, zLength, type, arrayBuffer ) {
THREE.Volume = function ( xLength, yLength, zLength, type, arrayBuffer ) {

if ( arguments.length > 0 ) {

Expand Down Expand Up @@ -137,17 +137,17 @@ THREE.Volume = function( xLength, yLength, zLength, type, arrayBuffer ) {
*/
var lowerThreshold = - Infinity;
Object.defineProperty( this, 'lowerThreshold', {
get : function() {
get: function () {

return lowerThreshold;

},
set : function( value ) {
set: function ( value ) {

lowerThreshold = value;
this.sliceList.forEach( function( slice ) {
this.sliceList.forEach( function ( slice ) {

slice.geometryNeedsUpdate = true
slice.geometryNeedsUpdate = true;

} );

Expand All @@ -159,15 +159,15 @@ THREE.Volume = function( xLength, yLength, zLength, type, arrayBuffer ) {
*/
var upperThreshold = Infinity;
Object.defineProperty( this, 'upperThreshold', {
get : function() {
get: function () {

return upperThreshold;

},
set : function( value ) {
set: function ( value ) {

upperThreshold = value;
this.sliceList.forEach( function( slice ) {
this.sliceList.forEach( function ( slice ) {

slice.geometryNeedsUpdate = true;

Expand All @@ -191,7 +191,7 @@ THREE.Volume = function( xLength, yLength, zLength, type, arrayBuffer ) {

THREE.Volume.prototype = {

constructor : THREE.Volume,
constructor: THREE.Volume,

/**
* @member {Function} getData Shortcut for data[access(i,j,k)]
Expand All @@ -201,7 +201,7 @@ THREE.Volume.prototype = {
* @param {number} k Third coordinate
* @returns {number} value in the data array
*/
getData : function( i, j, k ) {
getData: function ( i, j, k ) {

return this.data[ k * this.xLength * this.yLength + j * this.xLength + i ];

Expand All @@ -215,7 +215,7 @@ THREE.Volume.prototype = {
* @param {number} k Third coordinate
* @returns {number} index
*/
access : function( i, j, k ) {
access: function ( i, j, k ) {

return k * this.xLength * this.yLength + j * this.xLength + i;

Expand All @@ -227,7 +227,7 @@ THREE.Volume.prototype = {
* @param {number} index index of the voxel
* @returns {Array} [x,y,z]
*/
reverseAccess : function( index ) {
reverseAccess: function ( index ) {

var z = Math.floor( index / ( this.yLength * this.xLength ) );
var y = Math.floor( ( index - z * this.yLength * this.xLength ) / this.xLength );
Expand All @@ -246,7 +246,7 @@ THREE.Volume.prototype = {
* @param {Object} context You can specify a context in which call the function, default if this Volume
* @returns {THREE.Volume} this
*/
map : function( functionToMap, context ) {
map: function ( functionToMap, context ) {

var length = this.data.length;
context = context || this;
Expand All @@ -268,23 +268,23 @@ THREE.Volume.prototype = {
* @param {number} index the index of the slice
* @returns {Object} an object containing all the usefull information on the geometry of the slice
*/
extractPerpendicularPlane : function( axis, RASIndex ) {
extractPerpendicularPlane: function ( axis, RASIndex ) {

var iLength,
jLength,
sliceAccess,
planeMatrix = ( new THREE.Matrix4() ).identity(),
volume = this,
planeWidth,
planeHeight,
firstSpacing,
secondSpacing,
positionOffset,
IJKIndex;
jLength,
sliceAccess,
planeMatrix = ( new THREE.Matrix4() ).identity(),
volume = this,
planeWidth,
planeHeight,
firstSpacing,
secondSpacing,
positionOffset,
IJKIndex;

var axisInIJK = new THREE.Vector3(),
firstDirection = new THREE.Vector3(),
secondDirection = new THREE.Vector3();
firstDirection = new THREE.Vector3(),
secondDirection = new THREE.Vector3();

var dimensions = new THREE.Vector3( this.xLength, this.yLength, this.zLength );

Expand Down Expand Up @@ -327,6 +327,7 @@ THREE.Volume.prototype = {
positionOffset = ( volume.RASDimensions[ 2 ] - 1 ) / 2;
planeMatrix.setPosition( new THREE.Vector3( 0, 0, RASIndex - positionOffset ) );
break;

}

firstDirection.applyMatrix4( volume.inverseMatrix ).normalize();
Expand All @@ -341,38 +342,38 @@ THREE.Volume.prototype = {

IJKIndex = Math.abs( Math.round( IJKIndex.applyMatrix4( volume.inverseMatrix ).dot( axisInIJK ) ) );
var base = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ) ];
var iDirection = [ firstDirection, secondDirection, axisInIJK ].find( function( x ) {
var iDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {

return Math.abs( x.dot( base[ 0 ] ) ) > 0.9;

} );
var jDirection = [ firstDirection, secondDirection, axisInIJK ].find( function( x ) {
var jDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {

return Math.abs( x.dot( base[ 1 ] ) ) > 0.9;

} );
var kDirection = [ firstDirection, secondDirection, axisInIJK ].find( function( x ) {
var kDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {

return Math.abs( x.dot( base[ 2 ] ) ) > 0.9;

} );
var argumentsWithInversion = [ 'volume.xLength-1-', 'volume.yLength-1-', 'volume.zLength-1-' ];
var argArray = [ iDirection, jDirection, kDirection ].map( function( direction, n ) {
var argArray = [ iDirection, jDirection, kDirection ].map( function ( direction, n ) {

return ( direction.dot( base[ n ] ) > 0 ? '' : argumentsWithInversion[ n ] ) + ( direction === axisInIJK ? 'IJKIndex' : direction.argVar )
return ( direction.dot( base[ n ] ) > 0 ? '' : argumentsWithInversion[ n ] ) + ( direction === axisInIJK ? 'IJKIndex' : direction.argVar );

} );
var argString = argArray.join( ',' );
sliceAccess = eval( '(function sliceAccess (i,j) {return volume.access( ' + argString + ');})' );


return {
iLength : iLength,
jLength : jLength,
sliceAccess : sliceAccess,
matrix : planeMatrix,
planeWidth : planeWidth,
planeHeight : planeHeight
iLength: iLength,
jLength: jLength,
sliceAccess: sliceAccess,
matrix: planeMatrix,
planeWidth: planeWidth,
planeHeight: planeHeight
};

},
Expand All @@ -385,7 +386,7 @@ THREE.Volume.prototype = {
* @param {number} index the index of the slice
* @returns {THREE.VolumeSlice} the extracted slice
*/
extractSlice : function( axis, index ) {
extractSlice: function ( axis, index ) {

var slice = new THREE.VolumeSlice( this, index, axis );
this.sliceList.push( slice );
Expand All @@ -399,9 +400,9 @@ THREE.Volume.prototype = {
* @memberof THREE.Volume
* @returns {THREE.Volume} this
*/
repaintAllSlices : function() {
repaintAllSlices: function () {

this.sliceList.forEach( function( slice ) {
this.sliceList.forEach( function ( slice ) {

slice.repaint();

Expand All @@ -416,7 +417,7 @@ THREE.Volume.prototype = {
* @memberof THREE.Volume
* @returns {Array} [min,max]
*/
computeMinMax : function() {
computeMinMax: function () {

var min = Infinity;
var max = - Infinity;
Expand Down
4 changes: 2 additions & 2 deletions examples/js/controls/TransformControls.js
Expand Up @@ -511,7 +511,7 @@ THREE.TransformControls = function ( camera, domElement ) {
x: ( pointer.clientX - rect.left ) / rect.width * 2 - 1,
y: - ( pointer.clientY - rect.top ) / rect.height * 2 + 1,
button: event.button
}
};

}

Expand Down Expand Up @@ -604,7 +604,7 @@ THREE.TransformControls = function ( camera, domElement ) {

console.warn( 'THREE.TransformControls: update function has been depricated.' );

}
};

};

Expand Down
2 changes: 1 addition & 1 deletion examples/js/loaders/MTLLoader.js
Expand Up @@ -148,7 +148,7 @@ THREE.MTLLoader.prototype = {
info = { name: value };
materialsInfo[ value ] = info;

} else if ( info ) {
} else {

if ( key === 'ka' || key === 'kd' || key === 'ks' ) {

Expand Down