-
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.
test hello-react-three-fiber and bun
- Loading branch information
Showing
10 changed files
with
111 additions
and
19 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 |
---|---|---|
@@ -1,22 +1,28 @@ | ||
const load_script = (src) => { | ||
console.log(`loading ${src}`); | ||
const script = document.createElement('script'); | ||
script.type = 'module'; | ||
script.src = src; | ||
document.head.appendChild(script); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', async () => { | ||
|
||
const code_tags = document.querySelectorAll('article code'); | ||
|
||
if (code_tags.length != 0) { | ||
console.log('loading shiki.js'); | ||
const script = document.createElement('script'); | ||
script.type = 'module'; | ||
script.src = 'shiki.js'; | ||
document.head.appendChild(script); | ||
load_script('shiki.js'); | ||
} | ||
|
||
const embeded_shaders = document.querySelectorAll('.embeded-shader'); | ||
|
||
if (embeded_shaders.length != 0) { | ||
console.log('loading shader.js'); | ||
const shaderScript = document.createElement('script'); | ||
shaderScript.type = 'module'; | ||
shaderScript.src = 'shader.js'; | ||
document.head.appendChild(shaderScript); | ||
load_script('shader.js'); | ||
} | ||
|
||
const r3f_root = document.querySelector('#r3f-root'); | ||
|
||
if(r3f_root) { | ||
load_script('hello-react-three-fiber.js'); | ||
} | ||
}); |
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,35 @@ | ||
// example from https://github.com/pmndrs/react-three-fiber | ||
// bun install three react-dom react @react-three/fiber | ||
import * as THREE from 'three' | ||
import { createRoot } from 'react-dom/client' | ||
import React, { useRef, useState } from 'react' | ||
import { Canvas, useFrame, ThreeElements } from '@react-three/fiber' | ||
|
||
function Box(props: ThreeElements['mesh']) { | ||
const ref = useRef<THREE.Mesh>(null!) | ||
const [hovered, hover] = useState(false) | ||
const [clicked, click] = useState(false) | ||
useFrame((state, delta) => (ref.current.rotation.x += delta)) | ||
return ( | ||
<mesh | ||
{...props} | ||
ref={ref} | ||
scale={clicked ? 1.5 : 1} | ||
onClick={(event) => click(!clicked)} | ||
onPointerOver={(event) => hover(true)} | ||
onPointerOut={(event) => hover(false)}> | ||
<boxGeometry args={[1, 1, 1]} /> | ||
<meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} /> | ||
</mesh> | ||
) | ||
} | ||
|
||
createRoot(document.getElementById('r3f-root') as HTMLElement).render( | ||
<Canvas> | ||
<ambientLight intensity={Math.PI / 2} /> | ||
<spotLight position={[10, 10, 10]} angle={0.15} penumbra={1} decay={0} intensity={Math.PI} /> | ||
<pointLight position={[-10, -10, -10]} decay={0} intensity={Math.PI} /> | ||
<Box position={[-1.2, 0, 0]} /> | ||
<Box position={[1.2, 0, 0]} /> | ||
</Canvas>, | ||
) |
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 @@ | ||
{ "dependencies": { "@react-three/fiber": "^8.17.5", "react": "^18.3.1", "react-dom": "^18.3.1", "three": "^0.167.1" } } |
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,18 @@ | ||
\import{macros} | ||
% clifford hopf spin tt ag math draft | ||
\tag{math} | ||
\tag{draft} | ||
|
||
% definition theorem lemma construction observation | ||
% convention corollary axiom example exercise proof | ||
% discussion remark notation | ||
% \taxon{} | ||
% \refcardt{lemma}{}{}{}{ | ||
|
||
% kostecki2011introduction leinster2016basic nakahira2023diagrammatic rosiak2022sheaf | ||
|
||
% cox1997ideals gathmann2013commutative | ||
|
||
\note{test hello-react-three-fiber and bun}{ | ||
\<html:div>[id]{r3f-root}{} | ||
} |