Skip to content

Commit

Permalink
new architecture for this package
Browse files Browse the repository at this point in the history
  • Loading branch information
PolGuixe committed Dec 23, 2017
1 parent 222371f commit c2c0db6
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 69 deletions.
4 changes: 3 additions & 1 deletion src/extras/controls/MouseControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import THREE from 'three';
* This controls allow to change the orientation of the camera using the mouse
*/

THREE.MouseControls = function ( object ) {
const MouseControls = function ( object ) {

var scope = this;
var PI_2 = Math.PI / 2;
Expand Down Expand Up @@ -62,3 +62,5 @@ THREE.MouseControls = function ( object ) {
document.addEventListener( 'mousemove', onMouseMove, false );

};

export default MouseControls;
11 changes: 6 additions & 5 deletions src/extras/controls/OrbitControls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Added in order to make it work with a modular approach
import THREE from 'three';

/**
Expand All @@ -16,7 +15,7 @@ import THREE from 'three';
// Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
// Pan - right mouse, or arrow keys / touch: three finter swipe

THREE.OrbitControls = function ( object, domElement ) {
const OrbitControls = function ( object, domElement ) {

this.object = object;

Expand Down Expand Up @@ -911,10 +910,10 @@ THREE.OrbitControls = function ( object, domElement ) {

};

THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
THREE.OrbitControls.prototype.constructor = THREE.OrbitControls;
OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
OrbitControls.prototype.constructor = OrbitControls;

Object.defineProperties( THREE.OrbitControls.prototype, {
Object.defineProperties( OrbitControls.prototype, {

center: {

Expand Down Expand Up @@ -1038,3 +1037,5 @@ Object.defineProperties( THREE.OrbitControls.prototype, {
}

} );

export default OrbitControls;
8 changes: 5 additions & 3 deletions src/extras/controls/TrackballControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import THREE from 'three';
* @author Luca Antiga / http://lantiga.github.io
*/

THREE.TrackballControls = function ( object, domElement ) {
const TrackballControls = function ( object, domElement ) {

var _this = this;
var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
Expand Down Expand Up @@ -622,5 +622,7 @@ THREE.TrackballControls = function ( object, domElement ) {

};

THREE.TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );
THREE.TrackballControls.prototype.constructor = THREE.TrackballControls;
TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );
TrackballControls.prototype.constructor = TrackballControls;

export default TrackballControls;
8 changes: 6 additions & 2 deletions src/extras/exporters/OBJExporter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import THREE from 'three';

/**
* @author mrdoob / http://mrdoob.com/
*/

THREE.OBJExporter = function () {};
const OBJExporter = function () {};

THREE.OBJExporter.prototype = {
OBJExporter.prototype = {

constructor: THREE.OBJExporter,

Expand Down Expand Up @@ -254,3 +256,5 @@ THREE.OBJExporter.prototype = {
}

};

export default OBJExporter;
8 changes: 6 additions & 2 deletions src/extras/exporters/STLBinaryExporter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import THREE from 'three';

/**
* @author kovacsv / http://kovacsv.hu/
* @author mrdoob / http://mrdoob.com/
* @author mudcube / http://mudcu.be/
*/

THREE.STLBinaryExporter = function () {};
const STLBinaryExporter = function () {};

THREE.STLBinaryExporter.prototype = {
STLBinaryExporter.prototype = {

constructor: THREE.STLBinaryExporter,

Expand Down Expand Up @@ -92,3 +94,5 @@ THREE.STLBinaryExporter.prototype = {
}() )

};

export default STLBinaryExporter;
8 changes: 6 additions & 2 deletions src/extras/exporters/STLExporter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import THREE from 'three';

/**
* @author kovacsv / http://kovacsv.hu/
* @author mrdoob / http://mrdoob.com/
*/

THREE.STLExporter = function () {};
const STLExporter = function () {};

THREE.STLExporter.prototype = {
STLExporter.prototype = {

constructor: THREE.STLExporter,

Expand Down Expand Up @@ -73,3 +75,5 @@ THREE.STLExporter.prototype = {
}() )

};

export default STLExporter;
13 changes: 8 additions & 5 deletions src/extras/geometry/curves/NURBSCurve.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import THREE from 'three';

/**
* @author renej
* NURBS curve object
Expand All @@ -13,7 +15,7 @@
* NURBS curve
**************************************************************/

THREE.NURBSCurve = function ( degree, knots /* array of reals */, controlPoints /* array of Vector(2|3|4) */ ) {
const NURBSCurve = function ( degree, knots /* array of reals */, controlPoints /* array of Vector(2|3|4) */ ) {

this.degree = degree;
this.knots = knots;
Expand All @@ -29,11 +31,11 @@ THREE.NURBSCurve = function ( degree, knots /* array of reals */, controlPoints
};


THREE.NURBSCurve.prototype = Object.create( THREE.Curve.prototype );
THREE.NURBSCurve.prototype.constructor = THREE.NURBSCurve;
NURBSCurve.prototype = Object.create( THREE.Curve.prototype );
NURBSCurve.prototype.constructor = NURBSCurve;


THREE.NURBSCurve.prototype.getPoint = function ( t ) {
NURBSCurve.prototype.getPoint = function ( t ) {

var u = this.knots[ 0 ] + t * ( this.knots[ this.knots.length - 1 ] - this.knots[ 0 ] ); // linear mapping t->u

Expand All @@ -52,7 +54,7 @@ THREE.NURBSCurve.prototype.getPoint = function ( t ) {
};


THREE.NURBSCurve.prototype.getTangent = function ( t ) {
NURBSCurve.prototype.getTangent = function ( t ) {

var u = this.knots[ 0 ] + t * ( this.knots[ this.knots.length - 1 ] - this.knots[ 0 ] );
var ders = THREE.NURBSUtils.calcNURBSDerivatives( this.degree, this.knots, this.controlPoints, u, 1 );
Expand All @@ -63,3 +65,4 @@ THREE.NURBSCurve.prototype.getTangent = function ( t ) {

};

export default NURBSCurve;
9 changes: 6 additions & 3 deletions src/extras/geometry/curves/NURBSSurface.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import THREE from 'three';

/**
* @author renej
* NURBS surface object
Expand All @@ -11,7 +13,7 @@
* NURBS surface
**************************************************************/

THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of reals */, controlPoints /* array^2 of Vector(2|3|4) */ ) {
const NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of reals */, controlPoints /* array^2 of Vector(2|3|4) */ ) {

this.degree1 = degree1;
this.degree2 = degree2;
Expand All @@ -38,9 +40,9 @@ THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of re
};


THREE.NURBSSurface.prototype = {
NURBSSurface.prototype = {

constructor: THREE.NURBSSurface,
constructor: NURBSSurface,

getPoint: function ( t1, t2 ) {

Expand All @@ -53,3 +55,4 @@ THREE.NURBSSurface.prototype = {
};


export default NURBSSurface;
25 changes: 13 additions & 12 deletions src/extras/geometry/curves/NURBSUtils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import THREE from 'three';

/**
* @author renej
* NURBS utils
Expand All @@ -11,15 +13,15 @@
* NURBS Utils
**************************************************************/

THREE.NURBSUtils = {
const NURBSUtils = {

/*
Finds knot vector span.
p : degree
u : parametric value
U : knot vector
returns the span
*/
findSpan: function( p, u, U ) {
Expand All @@ -43,7 +45,7 @@ THREE.NURBSUtils = {
var mid = Math.floor( ( low + high ) / 2 );

while ( u < U[ mid ] || u >= U[ mid + 1 ] ) {

if ( u < U[ mid ] ) {

high = mid;
Expand All @@ -61,16 +63,16 @@ THREE.NURBSUtils = {
return mid;

},


/*
Calculate basis functions. See The NURBS Book, page 70, algorithm A2.2
span : span in which u lies
u : parametric point
p : degree
U : knot vector
returns array[p+1] with basis functions values.
*/
calcBasisFunctions: function( span, u, p, U ) {
Expand All @@ -81,7 +83,7 @@ THREE.NURBSUtils = {
N[ 0 ] = 1.0;

for ( var j = 1; j <= p; ++ j ) {

left[ j ] = u - U[ span + 1 - j ];
right[ j ] = U[ span + j ] - u;

Expand All @@ -108,7 +110,7 @@ THREE.NURBSUtils = {

/*
Calculate B-Spline curve points. See The NURBS Book, page 82, algorithm A3.1.
p : degree of B-Spline
U : knot vector
P : control points (x, y, z, w)
Expand Down Expand Up @@ -422,7 +424,7 @@ THREE.NURBSUtils = {

/*
Calculate rational B-Spline surface point. See The NURBS Book, page 134, algorithm A4.3.
p1, p2 : degrees of B-Spline surface
U1, U2 : knot vectors
P : control points (x, y, z, w)
Expand Down Expand Up @@ -468,5 +470,4 @@ THREE.NURBSUtils = {

};



export default NURBSUtils;
12 changes: 8 additions & 4 deletions src/extras/loaders/3MFLoader.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
THREE.ThreeMFLoader = function ( manager ) {
import THREE from 'three';

const ThreeMFLoader = function ( manager ) {

this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
this.availableExtensions = [];

};

THREE.ThreeMFLoader.prototype = {
ThreeMFLoader.prototype = {

constructor: THREE.ThreeMFLoader,

Expand Down Expand Up @@ -267,7 +269,7 @@ THREE.ThreeMFLoader.prototype = {
}

if ( pid ) {

triangleProperty[ 'pid' ] = pid;

}
Expand Down Expand Up @@ -540,7 +542,7 @@ THREE.ThreeMFLoader.prototype = {
var modelsKeys = Object.keys( modelsData );

for ( var i = 0; i < modelsKeys.length; i++ ) {

var modelsKey = modelsKeys[ i ];
var modelData = modelsData[ modelsKey ];
var modelXml = modelData[ 'xml' ];
Expand Down Expand Up @@ -602,3 +604,5 @@ THREE.ThreeMFLoader.prototype = {
}

};

export default ThreeMFLoader;
8 changes: 6 additions & 2 deletions src/extras/loaders/BinaryLoader.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import THREE from 'Three';

/**
* @author alteredq / http://alteredqualia.com/
*/

THREE.BinaryLoader = function ( manager ) {
const BinaryLoader = function ( manager ) {

if ( typeof manager === 'boolean' ) {

Expand All @@ -15,7 +17,7 @@ THREE.BinaryLoader = function ( manager ) {

};

THREE.BinaryLoader.prototype = {
BinaryLoader.prototype = {

constructor: THREE.BinaryLoader,

Expand Down Expand Up @@ -696,3 +698,5 @@ THREE.BinaryLoader.prototype = {
}

};

export default BinaryLoader;
8 changes: 6 additions & 2 deletions src/extras/loaders/OBJLoader.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import THREE from 'Three';

/**
* @author mrdoob / http://mrdoob.com/
*/

THREE.OBJLoader = function ( manager ) {
const OBJLoader = function ( manager ) {

this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;

Expand Down Expand Up @@ -35,7 +37,7 @@ THREE.OBJLoader = function ( manager ) {

};

THREE.OBJLoader.prototype = {
OBJLoader.prototype = {

constructor: THREE.OBJLoader,

Expand Down Expand Up @@ -716,3 +718,5 @@ THREE.OBJLoader.prototype = {
}

};

export default OBJLoader;
Loading

0 comments on commit c2c0db6

Please sign in to comment.