-
-
Notifications
You must be signed in to change notification settings - Fork 9
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 #70 from cdriesler/voronoi-lol
- Loading branch information
Showing
16 changed files
with
175 additions
and
81 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
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 |
---|---|---|
@@ -1,26 +1,33 @@ | ||
import React from 'react' | ||
import React, { useMemo } from 'react' | ||
import { Curve } from './lib/geometry' | ||
|
||
export const SceneGrid = (): React.ReactElement => { | ||
const extents = 20 | ||
const steps = Array.from('x'.repeat(extents * 2 + 1)) | ||
|
||
return ( | ||
<> | ||
{steps.map((x, i) => { | ||
return ( | ||
<> | ||
<Curve | ||
curve={{ degree: 1, segments: [[i - extents, -extents, 0, 0, 0, 0, 0, 0, 0, i - extents, extents, 0]] }} | ||
material={{ width: 0.04, color: '#98E2C6' }} | ||
/> | ||
<Curve | ||
curve={{ degree: 1, segments: [[-extents, i - extents, 0, 0, 0, 0, 0, 0, 0, extents, i - extents, 0]] }} | ||
material={{ width: 0.04, color: '#98E2C6' }} | ||
/> | ||
</> | ||
) | ||
})} | ||
</> | ||
const grid = useMemo( | ||
() => ( | ||
<> | ||
{steps.map((x, i) => { | ||
return ( | ||
<> | ||
<Curve | ||
curve={{ degree: 1, segments: [[i - extents, -extents, 0, 0, 0, 0, 0, 0, 0, i - extents, extents, 0]] }} | ||
material={{ size: 0.04, color: '#98E2C6', opacity: 1 }} | ||
key={`grid-a-${i}`} | ||
/> | ||
<Curve | ||
curve={{ degree: 1, segments: [[-extents, i - extents, 0, 0, 0, 0, 0, 0, 0, extents, i - extents, 0]] }} | ||
material={{ size: 0.04, color: '#98E2C6', opacity: 1 }} | ||
key={`grid-b-${i}`} | ||
/> | ||
</> | ||
) | ||
})} | ||
</> | ||
), | ||
[] | ||
) | ||
|
||
return grid | ||
} |
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 |
---|---|---|
@@ -1,18 +1,24 @@ | ||
import React from 'react' | ||
import { Sphere } from '@react-three/drei' | ||
import { Glasshopper } from 'glib' | ||
import { DrawMaterial } from '../types' | ||
|
||
type PointProps = { | ||
point: Glasshopper.Geometry.Point | ||
selected: boolean | ||
material: DrawMaterial | ||
} | ||
|
||
export const PointGeometry = ({ point, selected }: PointProps): React.ReactElement => { | ||
export const PointGeometry = ({ point, material }: PointProps): React.ReactElement => { | ||
const { x, y, z } = point | ||
|
||
return ( | ||
<Sphere visible args={[0.1, 10, 10]} position={[x, z, -y]}> | ||
<meshBasicMaterial attach="material" color={selected ? 'green' : 'darkred'} opacity={0.6} transparent={true} /> | ||
<meshBasicMaterial | ||
attach="material" | ||
color={material.color} | ||
opacity={material.opacity} | ||
transparent={material.opacity < 1} | ||
/> | ||
</Sphere> | ||
) | ||
} |
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,5 @@ | ||
export type DrawMaterial = { | ||
opacity: number | ||
color: string | ||
size: number | ||
} |
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 @@ | ||
export type DrawMode = 'default' | 'selection' |
Oops, something went wrong.