-
Notifications
You must be signed in to change notification settings - Fork 11
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 #10 from readyplayerme/feature/canvas-addons
Feature/canvas addons
- Loading branch information
Showing
9 changed files
with
137 additions
and
21 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 |
---|---|---|
|
@@ -28,6 +28,8 @@ coverage | |
# Library | ||
/dist | ||
|
||
# IDE Logs | ||
.idea | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
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,27 @@ | ||
import React, { FC, useRef } from 'react'; | ||
import { Mesh, TextureLoader } from 'three'; | ||
import { useFrame, useLoader } from '@react-three/fiber'; | ||
import { MeshProps } from '@react-three/fiber/dist/declarations/src/three-types'; | ||
|
||
export type Background = { src?: string } & MeshProps; | ||
|
||
const Box: FC<Background> = ({ src = '', ...baseProps }) => { | ||
const ref = useRef<Mesh>(); | ||
const texture = useLoader(TextureLoader, src); | ||
|
||
useFrame(() => { | ||
if (ref.current?.rotation.y) { | ||
ref.current.rotation.y += 0.01; | ||
} | ||
}); | ||
|
||
return ( | ||
<mesh ref={ref} castShadow receiveShadow {...baseProps}> | ||
<boxBufferGeometry /> | ||
<meshPhysicalMaterial map={texture} /> | ||
<axesHelper /> | ||
</mesh> | ||
); | ||
}; | ||
|
||
export default Box; |
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,21 @@ | ||
import React, { FC } from 'react'; | ||
import { useThree } from '@react-three/fiber'; | ||
|
||
export type CaptureType = (image?: string) => void; | ||
|
||
type CaptureProps = { | ||
onCapture?: CaptureType; | ||
}; | ||
|
||
const Capture: FC<CaptureProps> = ({ onCapture }) => { | ||
const gl = useThree((state) => state.gl); | ||
|
||
if (onCapture) { | ||
onCapture(gl.domElement.toDataURL('image/png', 0.1)); | ||
} | ||
|
||
// eslint-disable-next-line react/jsx-no-useless-fragment | ||
return <></>; | ||
}; | ||
|
||
export default Capture; |
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