-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11349 from WestLangley/dev-fatlines
Added linewidth support
- Loading branch information
Showing
8 changed files
with
1,065 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @author WestLangley / http://github.com/WestLangley | ||
* | ||
*/ | ||
|
||
THREE.Line2 = function ( geometry, material ) { | ||
|
||
THREE.LineSegments2.call( this ); | ||
|
||
this.type = 'Line2'; | ||
|
||
this.geometry = geometry !== undefined ? geometry : new THREE.LineGeometry(); | ||
this.material = material !== undefined ? material : new THREE.LineMaterial( { color: Math.random() * 0xffffff } ); | ||
|
||
}; | ||
|
||
THREE.Line2.prototype = Object.assign( Object.create( THREE.LineSegments2.prototype ), { | ||
|
||
constructor: THREE.Line2, | ||
|
||
isLine2: true, | ||
|
||
copy: function ( source ) { | ||
|
||
// todo | ||
|
||
return this; | ||
|
||
} | ||
|
||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* @author WestLangley / http://github.com/WestLangley | ||
* | ||
*/ | ||
|
||
THREE.LineGeometry = function () { | ||
|
||
THREE.LineSegmentsGeometry.call( this ); | ||
|
||
this.type = 'LineGeometry'; | ||
|
||
}; | ||
|
||
THREE.LineGeometry.prototype = Object.assign( Object.create( THREE.LineSegmentsGeometry.prototype ), { | ||
|
||
constructor: THREE.LineGeometry, | ||
|
||
isLineGeometry: true, | ||
|
||
setPositions: function ( array ) { | ||
|
||
// converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format | ||
|
||
var length = array.length - 3; | ||
var points = new Float32Array( 2 * length ); | ||
|
||
for ( var i = 0; i < length; i += 3 ) { | ||
|
||
points[ 2 * i ] = array[ i ]; | ||
points[ 2 * i + 1 ] = array[ i + 1 ]; | ||
points[ 2 * i + 2 ] = array[ i + 2 ]; | ||
|
||
points[ 2 * i + 3 ] = array[ i + 3 ]; | ||
points[ 2 * i + 4 ] = array[ i + 4 ]; | ||
points[ 2 * i + 5 ] = array[ i + 5 ]; | ||
|
||
} | ||
|
||
THREE.LineSegmentsGeometry.prototype.setPositions.call( this, points ); | ||
|
||
return this; | ||
|
||
}, | ||
|
||
setColors: function ( array ) { | ||
|
||
// converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format | ||
|
||
var length = array.length - 3; | ||
var colors = new Float32Array( 2 * length ); | ||
|
||
for ( var i = 0; i < length; i += 3 ) { | ||
|
||
colors[ 2 * i ] = array[ i ]; | ||
colors[ 2 * i + 1 ] = array[ i + 1 ]; | ||
colors[ 2 * i + 2 ] = array[ i + 2 ]; | ||
|
||
colors[ 2 * i + 3 ] = array[ i + 3 ]; | ||
colors[ 2 * i + 4 ] = array[ i + 4 ]; | ||
colors[ 2 * i + 5 ] = array[ i + 5 ]; | ||
|
||
} | ||
|
||
THREE.LineSegmentsGeometry.prototype.setColors.call( this, colors ); | ||
|
||
return this; | ||
|
||
}, | ||
|
||
fromLine: function ( line ) { | ||
|
||
var geometry = line.geometry; | ||
|
||
if ( geometry.isGeometry ) { | ||
|
||
this.setPositions( geometry.vertices ); | ||
|
||
} else if ( geometry.isBufferGeometry ) { | ||
|
||
this.setPositions( geometry.position.array ); // assumes non-indexed | ||
|
||
} | ||
|
||
// set colors, maybe | ||
|
||
return this; | ||
|
||
}, | ||
|
||
copy: function ( source ) { | ||
|
||
// todo | ||
|
||
return this; | ||
|
||
} | ||
|
||
} ); |
Oops, something went wrong.