Skip to content

Commit d726694

Browse files
committed
Core: Convert to es6 class.
1 parent 06eb724 commit d726694

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

src/core/Clock.js

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
function Clock( autoStart ) {
1+
class Clock {
22

3-
this.autoStart = ( autoStart !== undefined ) ? autoStart : true;
3+
constructor( autoStart ) {
44

5-
this.startTime = 0;
6-
this.oldTime = 0;
7-
this.elapsedTime = 0;
5+
this.autoStart = ( autoStart !== undefined ) ? autoStart : true;
86

9-
this.running = false;
7+
this.startTime = 0;
8+
this.oldTime = 0;
9+
this.elapsedTime = 0;
1010

11-
}
11+
this.running = false;
1212

13-
Object.assign( Clock.prototype, {
13+
}
1414

15-
start: function () {
15+
start() {
1616

1717
this.startTime = ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732
1818

1919
this.oldTime = this.startTime;
2020
this.elapsedTime = 0;
2121
this.running = true;
2222

23-
},
23+
}
2424

25-
stop: function () {
25+
stop() {
2626

2727
this.getElapsedTime();
2828
this.running = false;
2929
this.autoStart = false;
3030

31-
},
31+
}
3232

33-
getElapsedTime: function () {
33+
getElapsedTime() {
3434

3535
this.getDelta();
3636
return this.elapsedTime;
3737

38-
},
38+
}
3939

40-
getDelta: function () {
40+
getDelta() {
4141

4242
let diff = 0;
4343

@@ -63,7 +63,6 @@ Object.assign( Clock.prototype, {
6363

6464
}
6565

66-
} );
67-
66+
}
6867

6968
export { Clock };

src/core/Face3.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import { Color } from '../math/Color.js';
22
import { Vector3 } from '../math/Vector3.js';
33

4-
function Face3( a, b, c, normal, color, materialIndex ) {
4+
class Face3 {
55

6-
this.a = a;
7-
this.b = b;
8-
this.c = c;
6+
constructor( a, b, c, normal, color, materialIndex ) {
97

10-
this.normal = ( normal && normal.isVector3 ) ? normal : new Vector3();
11-
this.vertexNormals = Array.isArray( normal ) ? normal : [];
8+
this.a = a;
9+
this.b = b;
10+
this.c = c;
1211

13-
this.color = ( color && color.isColor ) ? color : new Color();
14-
this.vertexColors = Array.isArray( color ) ? color : [];
12+
this.normal = ( normal && normal.isVector3 ) ? normal : new Vector3();
13+
this.vertexNormals = Array.isArray( normal ) ? normal : [];
1514

16-
this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
15+
this.color = ( color && color.isColor ) ? color : new Color();
16+
this.vertexColors = Array.isArray( color ) ? color : [];
1717

18-
}
18+
this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
1919

20-
Object.assign( Face3.prototype, {
20+
}
2121

22-
clone: function () {
22+
clone() {
2323

2424
return new this.constructor().copy( this );
2525

26-
},
26+
}
2727

28-
copy: function ( source ) {
28+
copy( source ) {
2929

3030
this.a = source.a;
3131
this.b = source.b;
@@ -52,7 +52,7 @@ Object.assign( Face3.prototype, {
5252

5353
}
5454

55-
} );
55+
}
5656

5757

5858
export { Face3 };

0 commit comments

Comments
 (0)