Skip to content

Commit 3f9cd83

Browse files
committed
Merge branch 'dev-es6-core' into dev
2 parents 8000053 + 72127be commit 3f9cd83

12 files changed

+489
-526
lines changed

examples/jsm/deprecated/Geometry.js

Lines changed: 110 additions & 108 deletions
Large diffs are not rendered by default.

examples/jsm/lines/LineGeometry.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';
22

3-
var LineGeometry = function () {
3+
class LineGeometry extends LineSegmentsGeometry {
44

5-
LineSegmentsGeometry.call( this );
5+
constructor() {
66

7-
this.type = 'LineGeometry';
7+
super();
88

9-
};
9+
Object.defineProperty( this, 'isLineGeometry', { value: true } );
1010

11-
LineGeometry.prototype = Object.assign( Object.create( LineSegmentsGeometry.prototype ), {
11+
this.type = 'LineGeometry';
1212

13-
constructor: LineGeometry,
14-
15-
isLineGeometry: true,
13+
}
1614

17-
setPositions: function ( array ) {
15+
setPositions( array ) {
1816

1917
// converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format
2018

@@ -37,9 +35,9 @@ LineGeometry.prototype = Object.assign( Object.create( LineSegmentsGeometry.prot
3735

3836
return this;
3937

40-
},
38+
}
4139

42-
setColors: function ( array ) {
40+
setColors( array ) {
4341

4442
// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format
4543

@@ -62,9 +60,9 @@ LineGeometry.prototype = Object.assign( Object.create( LineSegmentsGeometry.prot
6260

6361
return this;
6462

65-
},
63+
}
6664

67-
fromLine: function ( line ) {
65+
fromLine( line ) {
6866

6967
var geometry = line.geometry;
7068

@@ -83,16 +81,16 @@ LineGeometry.prototype = Object.assign( Object.create( LineSegmentsGeometry.prot
8381

8482
return this;
8583

86-
},
84+
}
8785

88-
copy: function ( /* source */ ) {
86+
copy( /* source */ ) {
8987

9088
// todo
9189

9290
return this;
9391

9492
}
9593

96-
} );
94+
}
9795

9896
export { LineGeometry };

examples/jsm/lines/LineSegmentsGeometry.js

Lines changed: 68 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,30 @@ import {
99
WireframeGeometry
1010
} from '../../../build/three.module.js';
1111

12-
var LineSegmentsGeometry = function () {
12+
const box = new Box3();
13+
const vector = new Vector3();
1314

14-
InstancedBufferGeometry.call( this );
15+
class LineSegmentsGeometry extends InstancedBufferGeometry {
1516

16-
this.type = 'LineSegmentsGeometry';
17+
constructor() {
1718

18-
var positions = [ - 1, 2, 0, 1, 2, 0, - 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, - 1, - 1, 0, 1, - 1, 0 ];
19-
var uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
20-
var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
19+
super();
2120

22-
this.setIndex( index );
23-
this.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
24-
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
21+
Object.defineProperty( this, 'isLineSegmentsGeometry', { value: true } );
2522

26-
};
23+
this.type = 'LineSegmentsGeometry';
2724

28-
LineSegmentsGeometry.prototype = Object.assign( Object.create( InstancedBufferGeometry.prototype ), {
25+
var positions = [ - 1, 2, 0, 1, 2, 0, - 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, - 1, - 1, 0, 1, - 1, 0 ];
26+
var uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
27+
var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
2928

30-
constructor: LineSegmentsGeometry,
29+
this.setIndex( index );
30+
this.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
31+
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
3132

32-
isLineSegmentsGeometry: true,
33+
}
3334

34-
applyMatrix4: function ( matrix ) {
35+
applyMatrix4( matrix ) {
3536

3637
var start = this.attributes.instanceStart;
3738
var end = this.attributes.instanceEnd;
@@ -60,9 +61,9 @@ LineSegmentsGeometry.prototype = Object.assign( Object.create( InstancedBufferGe
6061

6162
return this;
6263

63-
},
64+
}
6465

65-
setPositions: function ( array ) {
66+
setPositions( array ) {
6667

6768
var lineSegments;
6869

@@ -88,9 +89,9 @@ LineSegmentsGeometry.prototype = Object.assign( Object.create( InstancedBufferGe
8889

8990
return this;
9091

91-
},
92+
}
9293

93-
setColors: function ( array ) {
94+
setColors( array ) {
9495

9596
var colors;
9697

@@ -111,35 +112,35 @@ LineSegmentsGeometry.prototype = Object.assign( Object.create( InstancedBufferGe
111112

112113
return this;
113114

114-
},
115+
}
115116

116-
fromWireframeGeometry: function ( geometry ) {
117+
fromWireframeGeometry( geometry ) {
117118

118119
this.setPositions( geometry.attributes.position.array );
119120

120121
return this;
121122

122-
},
123+
}
123124

124-
fromEdgesGeometry: function ( geometry ) {
125+
fromEdgesGeometry( geometry ) {
125126

126127
this.setPositions( geometry.attributes.position.array );
127128

128129
return this;
129130

130-
},
131+
}
131132

132-
fromMesh: function ( mesh ) {
133+
fromMesh( mesh ) {
133134

134135
this.fromWireframeGeometry( new WireframeGeometry( mesh.geometry ) );
135136

136137
// set colors, maybe
137138

138139
return this;
139140

140-
},
141+
}
141142

142-
fromLineSegments: function ( lineSegments ) {
143+
fromLineSegments( lineSegments ) {
143144

144145
var geometry = lineSegments.geometry;
145146

@@ -158,104 +159,92 @@ LineSegmentsGeometry.prototype = Object.assign( Object.create( InstancedBufferGe
158159

159160
return this;
160161

161-
},
162-
163-
computeBoundingBox: function () {
164-
165-
var box = new Box3();
166-
167-
return function computeBoundingBox() {
168-
169-
if ( this.boundingBox === null ) {
170-
171-
this.boundingBox = new Box3();
172-
173-
}
162+
}
174163

175-
var start = this.attributes.instanceStart;
176-
var end = this.attributes.instanceEnd;
164+
computeBoundingBox() {
177165

178-
if ( start !== undefined && end !== undefined ) {
166+
if ( this.boundingBox === null ) {
179167

180-
this.boundingBox.setFromBufferAttribute( start );
168+
this.boundingBox = new Box3();
181169

182-
box.setFromBufferAttribute( end );
170+
}
183171

184-
this.boundingBox.union( box );
172+
var start = this.attributes.instanceStart;
173+
var end = this.attributes.instanceEnd;
185174

186-
}
175+
if ( start !== undefined && end !== undefined ) {
187176

188-
};
177+
this.boundingBox.setFromBufferAttribute( start );
189178

190-
}(),
179+
box.setFromBufferAttribute( end );
191180

192-
computeBoundingSphere: function () {
181+
this.boundingBox.union( box );
193182

194-
var vector = new Vector3();
183+
}
195184

196-
return function computeBoundingSphere() {
185+
}
197186

198-
if ( this.boundingSphere === null ) {
187+
computeBoundingSphere() {
199188

200-
this.boundingSphere = new Sphere();
189+
if ( this.boundingSphere === null ) {
201190

202-
}
191+
this.boundingSphere = new Sphere();
203192

204-
if ( this.boundingBox === null ) {
193+
}
205194

206-
this.computeBoundingBox();
195+
if ( this.boundingBox === null ) {
207196

208-
}
197+
this.computeBoundingBox();
209198

210-
var start = this.attributes.instanceStart;
211-
var end = this.attributes.instanceEnd;
199+
}
212200

213-
if ( start !== undefined && end !== undefined ) {
201+
var start = this.attributes.instanceStart;
202+
var end = this.attributes.instanceEnd;
214203

215-
var center = this.boundingSphere.center;
204+
if ( start !== undefined && end !== undefined ) {
216205

217-
this.boundingBox.getCenter( center );
206+
var center = this.boundingSphere.center;
218207

219-
var maxRadiusSq = 0;
208+
this.boundingBox.getCenter( center );
220209

221-
for ( var i = 0, il = start.count; i < il; i ++ ) {
210+
var maxRadiusSq = 0;
222211

223-
vector.fromBufferAttribute( start, i );
224-
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
212+
for ( var i = 0, il = start.count; i < il; i ++ ) {
225213

226-
vector.fromBufferAttribute( end, i );
227-
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
214+
vector.fromBufferAttribute( start, i );
215+
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
228216

229-
}
217+
vector.fromBufferAttribute( end, i );
218+
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
230219

231-
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
220+
}
232221

233-
if ( isNaN( this.boundingSphere.radius ) ) {
222+
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
234223

235-
console.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );
224+
if ( isNaN( this.boundingSphere.radius ) ) {
236225

237-
}
226+
console.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );
238227

239228
}
240229

241-
};
230+
}
242231

243-
}(),
232+
}
244233

245-
toJSON: function () {
234+
toJSON() {
246235

247236
// todo
248237

249-
},
238+
}
250239

251-
applyMatrix: function ( matrix ) {
240+
applyMatrix( matrix ) {
252241

253242
console.warn( 'THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().' );
254243

255244
return this.applyMatrix4( matrix );
256245

257246
}
258247

259-
} );
248+
}
260249

261250
export { LineSegmentsGeometry };

examples/jsm/lines/WireframeGeometry2.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@ import {
33
} from '../../../build/three.module.js';
44
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';
55

6-
var WireframeGeometry2 = function ( geometry ) {
6+
class WireframeGeometry2 extends LineSegmentsGeometry {
77

8-
LineSegmentsGeometry.call( this );
8+
constructor( geometry ) {
99

10-
this.type = 'WireframeGeometry2';
10+
super();
1111

12-
this.fromWireframeGeometry( new WireframeGeometry( geometry ) );
12+
Object.defineProperty( this, 'isWireframeGeometry2', { value: true } );
1313

14-
// set colors, maybe
14+
this.type = 'WireframeGeometry2';
1515

16-
};
16+
this.fromWireframeGeometry( new WireframeGeometry( geometry ) );
1717

18-
WireframeGeometry2.prototype = Object.assign( Object.create( LineSegmentsGeometry.prototype ), {
18+
// set colors, maybe
1919

20-
constructor: WireframeGeometry2,
20+
}
2121

22-
isWireframeGeometry2: true
23-
24-
} );
22+
}
2523

2624
export { WireframeGeometry2 };

0 commit comments

Comments
 (0)