-
Notifications
You must be signed in to change notification settings - Fork 0
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
5d204cb
commit 39c1fa1
Showing
20 changed files
with
541 additions
and
212 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,56 @@ | ||
import * as React from 'react'; | ||
import { useState } from 'react'; | ||
import Widget from './Widget'; | ||
import useInertia from '../hooks/inertia'; | ||
|
||
import EnvironmentBall from '../widgets/environmentBall'; | ||
import { ROTATE_SENSITIVITY } from '../constants'; | ||
|
||
export default function BackgroundSettings({ | ||
rotation, | ||
backgroundOffset, | ||
setBackgroundOffset, | ||
}) { | ||
const [lastPosition, setLastPosition] = useState(0); | ||
const [rotating, setRotating] = useState(false); | ||
|
||
const stopRotating = (e: React.PointerEvent) => { | ||
if (rotating) { | ||
setRotating(false); | ||
} | ||
}; | ||
|
||
const handlePointerDown = (e: React.PointerEvent) => { | ||
if (e.button === 0) { | ||
setLastPosition(e.clientX); | ||
setRotating(true); | ||
} | ||
}; | ||
const handlePointerUp = (e: React.PointerEvent) => { | ||
stopRotating(e); | ||
}; | ||
const handlePointerMove = (e: React.PointerEvent) => { | ||
if (rotating) { | ||
const deltaAngle = (lastPosition - e.clientX) * -ROTATE_SENSITIVITY; | ||
|
||
setBackgroundOffset(backgroundOffset + deltaAngle); | ||
setLastPosition(e.clientX); | ||
} | ||
}; | ||
const handlePointerLeave = (e: React.PointerEvent) => { | ||
stopRotating(e); | ||
}; | ||
|
||
export default function BackgroundSettings({ rotation, backgroundOffset }) { | ||
return ( | ||
<Widget constructor={EnvironmentBall} widgetProps={{ rotation, backgroundOffset }} style={{width: '150px', height: '150px'}} zindex={1} /> | ||
<Widget | ||
constructor={EnvironmentBall} | ||
widgetProps={{ rotation, backgroundOffset }} | ||
style={{ width: '150px', height: '150px' }} | ||
zindex={1} | ||
onPointerDown={handlePointerDown} | ||
onPointerUp={handlePointerUp} | ||
onPointerMove={handlePointerMove} | ||
onPointerLeave={handlePointerLeave} | ||
/> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,76 @@ | ||
import { vec3 } from 'gl-matrix'; | ||
import * as React from 'react'; | ||
import { useContext, useState } from 'react'; | ||
import { HALF_COLOR } from '../../constants'; | ||
import ColorWheel from '../ColorWheel'; | ||
import TabPanel from './TabPanel'; | ||
import { WindowContext } from '../Widget'; | ||
|
||
export default function BrushMaterial({ visible, onClick }) { | ||
const windowManager = useContext(WindowContext); | ||
|
||
const [brushColor, setBrushColor] = useState(vec3.create()); | ||
const [roughness, setRoughness] = useState(0.5); | ||
const [metallic, setMetallic] = useState(0); | ||
|
||
const color = vec3.create(); | ||
vec3.mul(color, brushColor, [255, 255, 255]); | ||
vec3.round(color, color); | ||
|
||
// TODO: use http://danielstern.ca/range.css/ to style the range inputs | ||
|
||
return ( | ||
<TabPanel | ||
buttonClass="brush-color" | ||
buttonStyle={{ backgroundColor: `rgb(${color})` }} | ||
showPanel={visible} | ||
onClick={onClick} | ||
> | ||
<div className="border-top" /> | ||
<ColorWheel | ||
brushColor={brushColor} | ||
setBrushColor={(c: vec3) => { | ||
setBrushColor(c); | ||
windowManager.slate.brushColor = c; | ||
}} | ||
/> | ||
<div | ||
style={{ | ||
backgroundColor: HALF_COLOR, | ||
padding: '22px', | ||
}} | ||
> | ||
<label> | ||
Roughness | ||
<input | ||
type="range" | ||
min="0" | ||
max="1" | ||
step="0.01" | ||
value={roughness} | ||
onChange={(e) => { | ||
const r = e.target.valueAsNumber; | ||
setRoughness(r); | ||
windowManager.slate.brushRoughness = r; | ||
}} | ||
/> | ||
</label> | ||
<label> | ||
Metallic | ||
<input | ||
type="range" | ||
min="0" | ||
max="1" | ||
step="0.01" | ||
value={metallic} | ||
onChange={(e) => { | ||
const m = e.target.valueAsNumber; | ||
setMetallic(e.target.valueAsNumber); | ||
windowManager.slate.brushMetallic = m; | ||
}} | ||
/> | ||
</label> | ||
</div> | ||
</TabPanel> | ||
); | ||
} |
Oops, something went wrong.