Skip to content

Commit

Permalink
feature: shader initial
Browse files Browse the repository at this point in the history
  • Loading branch information
linround committed Mar 29, 2024
1 parent 3fdae2e commit add0cff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Layout/LayoutComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {RightSide} from "./RightSide.tsx";
import layoutCss from './layout.module.less'

export function LayoutComponent() {
console.log('LayoutComponent, render')
return (
<div>
<HeaderComponent />
Expand Down
9 changes: 8 additions & 1 deletion src/component/ThreeCanvas/ThreeCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let uniforms:any = null
let canvas:any = null
const defaultUrl = 'https://fal-cdn.batuhan-941.workers.dev/files/monkey/M5iiSBcsoX6ERJ1jlRkxK.jpeg'
export function ThreeCanvas() {
console.log('ThreeCanvas,render')
const ref = useRef<HTMLCanvasElement>(null)
const {imgURL} = React.useContext(demoPromptsContext)
const [height, setHeight] = useState(0)
Expand All @@ -25,6 +26,7 @@ export function ThreeCanvas() {
setHeight(height)
}
useEffect(()=>{
console.log('ThreeCanvas,canvas effect')
canvas = ref.current
if (canvas) {
(async function () {
Expand Down Expand Up @@ -80,7 +82,12 @@ export function ThreeCanvas() {
y = canvas.height - e.offsetY
})
}
},[ref, imgURL])
},[ref])

useEffect(() => {
console.log(imgURL)
uniforms.iChannel0.value = createImgTexture(imgURL)
}, [imgURL]);
return (
<canvas width={width} height={height} ref={ref}/>
)
Expand Down
10 changes: 4 additions & 6 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import {VisualContext} from "./context/VisualContext.tsx";

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<VisualContext value={{}}>
<App />
</VisualContext>
</React.StrictMode>,

<VisualContext value={{}}>
<App />
</VisualContext>,
)

0 comments on commit add0cff

Please sign in to comment.