-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f99643
commit 1fd557b
Showing
24 changed files
with
3,727 additions
and
37 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
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
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
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,87 @@ | ||
import { CubicBezierCurve3, Vector2, Vector3 } from 'three' | ||
import { Line2, LineGeometry, LineMaterial } from 'src/vendor/three-fatline/src' | ||
import Color from 'color' | ||
|
||
export interface Curve { | ||
color: string | ||
points: [Vector3, Vector3, Vector3, Vector3] | ||
} | ||
|
||
const CURVES: Curve[] = [ | ||
{ | ||
color: '#f00', | ||
points: [ | ||
// prettier-ignore | ||
new Vector3(-10, 0, 0), | ||
new Vector3(-5, 15, 0), | ||
new Vector3(20, 15, 0), | ||
new Vector3(10, 0, 0), | ||
], | ||
}, | ||
{ | ||
color: '#00f', | ||
points: [ | ||
// prettier-ignore | ||
new Vector3(-10, 0, 0), | ||
new Vector3(0, -5, 5), | ||
new Vector3(0, -8, 5), | ||
new Vector3(10, 0, 0), | ||
], | ||
}, | ||
{ | ||
color: '#0f0', | ||
points: [ | ||
// prettier-ignore | ||
new Vector3(-10, 0, 0), | ||
new Vector3(0, 0, 2), | ||
new Vector3(0, 2, 0), | ||
new Vector3(10, 0, 0), | ||
], | ||
}, | ||
{ | ||
color: '#0ff', | ||
points: [ | ||
// prettier-ignore | ||
new Vector3(-10, 0, 0), | ||
new Vector3(-15, 5, 2), | ||
new Vector3(-20, 2, 5), | ||
new Vector3(-10, 0, 0), | ||
], | ||
}, | ||
{ | ||
color: '#ff0', | ||
points: [ | ||
// prettier-ignore | ||
new Vector3(10, 0, 0), | ||
new Vector3(20, 5, 2), | ||
new Vector3(15, 2, 5), | ||
new Vector3(10, 0, 0), | ||
], | ||
}, | ||
] | ||
|
||
export function makeBezierCurve( | ||
bezierPoints: [Vector3, Vector3, Vector3, Vector3], | ||
color: string, | ||
resolution: Vector2, | ||
) { | ||
const points = new CubicBezierCurve3(...bezierPoints).getPoints(50) | ||
|
||
const geometry = new LineGeometry() | ||
geometry.setPositions(points.flatMap(({ x, y, z }) => [x, y, z])) | ||
|
||
const material = new LineMaterial({ | ||
color: new Color(color).rgbNumber(), | ||
linewidth: 10, | ||
resolution, | ||
}) | ||
|
||
const curve = new Line2(geometry, material) | ||
curve.geometry.computeBoundingSphere() | ||
|
||
return curve | ||
} | ||
|
||
export function makeBezierCurves(resolution: Vector2) { | ||
return CURVES.map((curve) => makeBezierCurve(curve.points, curve.color, resolution)) | ||
} |
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,36 @@ | ||
three-fatline | ||
============= | ||
|
||
[![NPM package][npm-img]][npm-url] | ||
[![Build Size][build-size-img]][build-size-url] | ||
[![NPM Downloads][npm-downloads-img]][npm-downloads-url] | ||
|
||
A modularized version of [https://github.com/mrdoob/three.js/blob/master/examples/js/lines/](https://github.com/mrdoob/three.js/blob/master/examples/js/lines/). | ||
|
||
See the [example](https://vasturiano.github.io/three-fatline/example/fat-lines/) ([source](https://github.com/vasturiano/three-fatline/blob/master/example/fat-lines/index.html)) | ||
|
||
#### Usage Example: | ||
```js | ||
import { Line2, LineGeometry, LineMaterial } from 'three-fatline'; | ||
|
||
const geometry = new LineGeometry(); | ||
geometry.setPositions([-160, 200, 0, 0, -200, 0, 160, 200, 0]); // [ x1, y1, z1, x2, y2, z2, ... ] format | ||
|
||
const material = new LineMaterial({ | ||
color: 'red', | ||
linewidth: 10, // px | ||
resolution: new THREE.Vector2(640, 480) // resolution of the viewport | ||
// dashed, dashScale, dashSize, gapSize | ||
}); | ||
|
||
const myLine = new Line2(geometry, matLine); | ||
|
||
myLine.computeLineDistances(); | ||
``` | ||
|
||
[npm-img]: https://img.shields.io/npm/v/three-fatline | ||
[npm-url]: https://npmjs.org/package/three-fatline | ||
[build-size-img]: https://img.shields.io/bundlephobia/minzip/three-fatline | ||
[build-size-url]: https://bundlephobia.com/result?p=three-fatline | ||
[npm-downloads-img]: https://img.shields.io/npm/dt/three-fatline | ||
[npm-downloads-url]: https://www.npmtrends.com/three-fatline |
Oops, something went wrong.
1fd557b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
pangraph – ./
pangraph-git-web-neherlab.vercel.app
pangraph-neherlab.vercel.app
pangraph.vercel.app