-
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
Showing
11 changed files
with
275 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ body, | |
} | ||
|
||
body { | ||
background: lightblue; | ||
/* background: lightblue; */ | ||
} | ||
|
||
|
||
|
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,69 @@ | ||
import * as THREE from 'three' | ||
import React, { useRef, useState } from 'react' | ||
import { Canvas, useFrame, useThree } from '@react-three/fiber' | ||
|
||
import { useEffect } from 'react' | ||
|
||
import { OrbitControls, useGLTF, } from '@react-three/drei' | ||
|
||
import GLTFLoader from '../util/gltfLoader' | ||
|
||
|
||
|
||
export default function App() { | ||
return ( | ||
<Canvas camera={{ position: [5, 5, -5] }} gl={{ preserveDrawingBuffer: true }}> | ||
<Scene /> | ||
</Canvas> | ||
) | ||
} | ||
|
||
function Scene() { | ||
|
||
useEffect(() => { | ||
|
||
}, []) | ||
return ( | ||
<> | ||
<hemisphereLight intensity={0.45} /> | ||
<spotLight angle={0.4} penumbra={1} position={[20, 30, 2.5]} castShadow shadow-bias={-0.00001} /> | ||
<directionalLight color="red" position={[-10, -10, 0]} intensity={1.5} /> | ||
<OrbitControls /> | ||
|
||
<Model /> | ||
</> | ||
|
||
) | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
function Model(props) { | ||
const group = useRef() | ||
// const { nodes, materials } = useGLTF('https://vazxmixjsiawhamofees.supabase.co/storage/v1/object/public/models/star/model.gltf') | ||
// const { scene } = useThree() | ||
const { scene } = useGLTF('QuestionBlock.glb') | ||
|
||
|
||
|
||
function handleClick() { | ||
console.log("clicked"); | ||
} | ||
|
||
useEffect(() => { | ||
// GLTFLoader('QuestionBlock.glb').then((glb) => { | ||
// glb.scale.set(0.1,0.1,0.1) | ||
// scene.add(glb) | ||
// }) | ||
}, []) | ||
return ( | ||
<group ref={group} {...props} dispose={null}> | ||
<primitive onClick={handleClick} object={scene}/> | ||
</group> | ||
) | ||
} | ||
|
||
useGLTF.preload('QuestionBlock.glb') |
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 { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader"; | ||
import { KTX2Loader } from "three/examples/jsm/loaders/KTX2Loader.js"; | ||
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js"; | ||
import { MeshoptDecoder } from "three/examples/jsm/libs/meshopt_decoder.module.js"; | ||
|
||
|
||
export default function Loader(path) { | ||
const loader = new GLTFLoader().setDRACOLoader(new DRACOLoader().setDecoderPath("assets/wasm/")) | ||
.setKTX2Loader(new KTX2Loader().setTranscoderPath("assets/wasm/")) | ||
.setMeshoptDecoder(MeshoptDecoder); | ||
|
||
return new Promise((resolve) => { | ||
loader.load(path, (gltf) => { | ||
// console.log(gltf) | ||
const scene = gltf.scene || gltf.scenes[0]; | ||
if (!scene) { | ||
throw new Error( | ||
"This model contains no scene, and cannot be viewed here. However," + | ||
" it may contain individual 3D resources." | ||
); | ||
} | ||
|
||
resolve(scene); | ||
// resolve(gltf); | ||
}); | ||
}); | ||
} |
39d8a66
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
r3f-lab – ./
r3f-lab.vercel.app
r3f-lab-git-master-chunghosuk.vercel.app
r3f-lab-chunghosuk.vercel.app