Skip to content

Commit

Permalink
Merge branch 'dev-es6-core' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
linbingquan committed Feb 12, 2021
2 parents 8000053 + 72127be commit 3f9cd83
Show file tree
Hide file tree
Showing 12 changed files with 489 additions and 526 deletions.
218 changes: 110 additions & 108 deletions examples/jsm/deprecated/Geometry.js

Large diffs are not rendered by default.

30 changes: 14 additions & 16 deletions examples/jsm/lines/LineGeometry.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';

var LineGeometry = function () {
class LineGeometry extends LineSegmentsGeometry {

LineSegmentsGeometry.call( this );
constructor() {

this.type = 'LineGeometry';
super();

};
Object.defineProperty( this, 'isLineGeometry', { value: true } );

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

constructor: LineGeometry,

isLineGeometry: true,
}

setPositions: function ( array ) {
setPositions( array ) {

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

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

return this;

},
}

setColors: function ( array ) {
setColors( array ) {

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

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

return this;

},
}

fromLine: function ( line ) {
fromLine( line ) {

var geometry = line.geometry;

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

return this;

},
}

copy: function ( /* source */ ) {
copy( /* source */ ) {

// todo

return this;

}

} );
}

export { LineGeometry };
147 changes: 68 additions & 79 deletions examples/jsm/lines/LineSegmentsGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,30 @@ import {
WireframeGeometry
} from '../../../build/three.module.js';

var LineSegmentsGeometry = function () {
const box = new Box3();
const vector = new Vector3();

InstancedBufferGeometry.call( this );
class LineSegmentsGeometry extends InstancedBufferGeometry {

this.type = 'LineSegmentsGeometry';
constructor() {

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 ];
var uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
super();

this.setIndex( index );
this.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
Object.defineProperty( this, 'isLineSegmentsGeometry', { value: true } );

};
this.type = 'LineSegmentsGeometry';

LineSegmentsGeometry.prototype = Object.assign( Object.create( InstancedBufferGeometry.prototype ), {
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 ];
var uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];

constructor: LineSegmentsGeometry,
this.setIndex( index );
this.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

isLineSegmentsGeometry: true,
}

applyMatrix4: function ( matrix ) {
applyMatrix4( matrix ) {

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

return this;

},
}

setPositions: function ( array ) {
setPositions( array ) {

var lineSegments;

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

return this;

},
}

setColors: function ( array ) {
setColors( array ) {

var colors;

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

return this;

},
}

fromWireframeGeometry: function ( geometry ) {
fromWireframeGeometry( geometry ) {

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

return this;

},
}

fromEdgesGeometry: function ( geometry ) {
fromEdgesGeometry( geometry ) {

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

return this;

},
}

fromMesh: function ( mesh ) {
fromMesh( mesh ) {

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

// set colors, maybe

return this;

},
}

fromLineSegments: function ( lineSegments ) {
fromLineSegments( lineSegments ) {

var geometry = lineSegments.geometry;

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

return this;

},

computeBoundingBox: function () {

var box = new Box3();

return function computeBoundingBox() {

if ( this.boundingBox === null ) {

this.boundingBox = new Box3();

}
}

var start = this.attributes.instanceStart;
var end = this.attributes.instanceEnd;
computeBoundingBox() {

if ( start !== undefined && end !== undefined ) {
if ( this.boundingBox === null ) {

this.boundingBox.setFromBufferAttribute( start );
this.boundingBox = new Box3();

box.setFromBufferAttribute( end );
}

this.boundingBox.union( box );
var start = this.attributes.instanceStart;
var end = this.attributes.instanceEnd;

}
if ( start !== undefined && end !== undefined ) {

};
this.boundingBox.setFromBufferAttribute( start );

}(),
box.setFromBufferAttribute( end );

computeBoundingSphere: function () {
this.boundingBox.union( box );

var vector = new Vector3();
}

return function computeBoundingSphere() {
}

if ( this.boundingSphere === null ) {
computeBoundingSphere() {

this.boundingSphere = new Sphere();
if ( this.boundingSphere === null ) {

}
this.boundingSphere = new Sphere();

if ( this.boundingBox === null ) {
}

this.computeBoundingBox();
if ( this.boundingBox === null ) {

}
this.computeBoundingBox();

var start = this.attributes.instanceStart;
var end = this.attributes.instanceEnd;
}

if ( start !== undefined && end !== undefined ) {
var start = this.attributes.instanceStart;
var end = this.attributes.instanceEnd;

var center = this.boundingSphere.center;
if ( start !== undefined && end !== undefined ) {

this.boundingBox.getCenter( center );
var center = this.boundingSphere.center;

var maxRadiusSq = 0;
this.boundingBox.getCenter( center );

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

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

vector.fromBufferAttribute( end, i );
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
vector.fromBufferAttribute( start, i );
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );

}
vector.fromBufferAttribute( end, i );
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );

this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
}

if ( isNaN( this.boundingSphere.radius ) ) {
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );

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

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

}

};
}

}(),
}

toJSON: function () {
toJSON() {

// todo

},
}

applyMatrix: function ( matrix ) {
applyMatrix( matrix ) {

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

return this.applyMatrix4( matrix );

}

} );
}

export { LineSegmentsGeometry };
20 changes: 9 additions & 11 deletions examples/jsm/lines/WireframeGeometry2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@ import {
} from '../../../build/three.module.js';
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';

var WireframeGeometry2 = function ( geometry ) {
class WireframeGeometry2 extends LineSegmentsGeometry {

LineSegmentsGeometry.call( this );
constructor( geometry ) {

this.type = 'WireframeGeometry2';
super();

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

// set colors, maybe
this.type = 'WireframeGeometry2';

};
this.fromWireframeGeometry( new WireframeGeometry( geometry ) );

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

constructor: WireframeGeometry2,
}

isWireframeGeometry2: true

} );
}

export { WireframeGeometry2 };
Loading

0 comments on commit 3f9cd83

Please sign in to comment.