Add some bullshit
This commit is contained in:
commit
5f53708fa1
24 files changed
+5954
No files matched your search
+79
@@ -0,0 +1,79 @@
|
||||
import { Canvas, useFrame, useThree } from '@react-three/fiber'
|
||||
import { CuboidCollider, Physics, RigidBody } from '@react-three/rapier';
|
||||
import { useRef, useState } from 'react'
|
||||
import { DirectionalLight, Euler, PCFSoftShadowMap, VSMShadowMap, Vector3 } from 'three';
|
||||
|
||||
function Sub() {
|
||||
const camera = useThree(s => s.camera);
|
||||
|
||||
camera.position.y = 2;
|
||||
camera.position.z = 5;
|
||||
camera.rotation.x = -(Math.PI / 6);
|
||||
return <></>
|
||||
}
|
||||
|
||||
function HeRotates() {
|
||||
const rotation = useRef(0);
|
||||
const objRef = useRef<DirectionalLight>(null);
|
||||
useFrame((three, dt) => {
|
||||
rotation.current += dt;
|
||||
const radius = 5;
|
||||
const centerX = 0;
|
||||
const centerY = 0;
|
||||
|
||||
const x = (radius * Math.cos(rotation.current)) + centerX;
|
||||
const z = (radius * Math.sin(rotation.current)) + centerY;
|
||||
if (objRef.current) {
|
||||
objRef.current.position.x = x;
|
||||
objRef.current.position.z = z;
|
||||
}
|
||||
});
|
||||
|
||||
return <directionalLight color="white" position={[0, 3, 0]} ref={objRef} intensity={3.0} castShadow={true} />
|
||||
}
|
||||
|
||||
function App() {
|
||||
const testRef = useRef();
|
||||
window.amogus = testRef;
|
||||
return (
|
||||
<>
|
||||
<Canvas style={{
|
||||
height: '100%'
|
||||
}}
|
||||
shadows={{
|
||||
type: PCFSoftShadowMap,
|
||||
}}
|
||||
camera={{
|
||||
fov: 90
|
||||
}}
|
||||
>
|
||||
<Sub />
|
||||
<ambientLight intensity={0.1} />
|
||||
<HeRotates />
|
||||
<Physics
|
||||
debug
|
||||
>
|
||||
<RigidBody friction={0} enabledRotations={[true, true, true]} mass={2}>
|
||||
<mesh position={new Vector3(0, 1.5, 0)} rotation={new Euler(-Math.PI/4, 0, -Math.PI/4)} castShadow={true}>
|
||||
<boxGeometry args={[1, 1, 1]} />
|
||||
<meshStandardMaterial color={'red'} />
|
||||
</mesh>
|
||||
</RigidBody>
|
||||
<RigidBody ref={testRef} friction={0} enabledRotations={[true, true, true]} mass={50} angularVelocity={[50, 50, 50]}>
|
||||
<mesh position={new Vector3(3, 1.5, 0)} rotation={new Euler(-Math.PI/4, 0, -Math.PI/4)} castShadow={true}>
|
||||
<boxGeometry args={[1, 1, 1]} />
|
||||
<meshStandardMaterial color={'red'} />
|
||||
</mesh>
|
||||
</RigidBody>
|
||||
<CuboidCollider args={[5, 1, 5]} position={[0, -1, 0]} friction={2}/>
|
||||
<mesh rotation={new Euler(-Math.PI/2, 0, 0)} receiveShadow={true}>
|
||||
<planeGeometry args={[10, 10]} />
|
||||
<meshStandardMaterial color={'white'} />
|
||||
</mesh>
|
||||
</Physics>
|
||||
</Canvas>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
@@ -0,0 +1,8 @@
|
||||
body {
|
||||
margin: 0;
|
||||
|
||||
}
|
||||
#root {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App.tsx'
|
||||
import './index.css'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
)
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
Reference in new issue
Block a user