adrianhajdin / project_3D_developer_portfolio

The most impressive websites in the world use 3D graphics and animations to bring their content to life. Learn how to build your own ThreeJS 3D Developer Portfolio today!
https://jsmastery.pro
5.81k stars 1.29k forks source link

Unable to see desktop_pc/'scene.gltf #69

Open divyanshmathur13 opened 1 year ago

divyanshmathur13 commented 1 year ago

Please help as soon as possible I have followed the steps till video at 53 mins and all things till now are working fine but I AM UNABLE TO THE DESKTOP SCENE.GLTF whereas do not have any error in the terminal. As suggested in the video: import { OrbitControls, Preload, useGLTF} from '@react-three/drei'; is not working for me it is giving me error:
Missing "./examples/js/libs/stats.min" specifier in "three" package [plugin vite:dep-pre-bundle] ![error desktop scene gltf] node_modules/@react-three/drei/core/Stats.js:3:22: 3 │ import StatsImpl from 'three/examples/js/libs/stats.min'; error desktop scene gltf
![error desktop scene gltf code 2](https://github.com/adrianhajdin/project_3D_developer_portfolio/assets/103129455/d06ede6d-73ec-40e6-9689-fd8ce9e4478c)

gaganku commented 1 year ago

Seems like you haven't properly installed the 'three' package.

Open a terminal, cd to your root folder (that contains your package.json and tsconfig.json/jsconfig.json) and run " npm list ". This will show you all of the packages you've installed for your current project.

If 'three' doesn't show up, you must " npm i three --save " (or ' npm i three @types/three --save " of you're using TypeScript).

divyanshmathur13 commented 1 year ago

Seems like you haven't properly installed the 'three' package.

Open a terminal, cd to your root folder (that contains your package.json and tsconfig.json/jsconfig.json) and run " npm list ". This will show you all of the packages you've installed for your current project.

If 'three' doesn't show up, you must " npm i three --save " (or ' npm i three @types/three --save " of you're using TypeScript). I have installed three but still cannot see the desktop.gltf or any image at its place.

Tusharknwl commented 1 year ago

divyanshmathur13 can you provide the whole code of Computers.jsx and check if you are using export default Computers change it to export default ComputersCanvas

Amay-S commented 1 year ago

@Tusharknwl @divyanshmathur13

using export default ComputersCanvas worked. Thanks very much

Kritansh1 commented 1 year ago

@Tusharknwl I'm providing you the code for Computer.jsx please check it, i'm unable to see the computer, also I've installed three properly

import {Suspense,useEffect,useState} from 'react'; import { Canvas } from '@react-three/fiber'; import { OrbitControls,Preload,useGLTF } from '@react-three/drei'; import CanvasLoader from '../Loader'; import { RGBA_ASTC_10x10_Format } from 'three';

const Computers = () => { const computer = useGLTF('./desktop_pc/scene.gltf')

return (

) }

const ComputersCanvas =()=>{ return( <Canvas frameloop="demand" shadows camera={{position: [20,30,5],fov: 25}} gl={{preserveDrawingBuffer:true }}

<Suspense fallback={}> <OrbitControls enableZoom={false} maxPolarAngle={Math.PI / 2} minPolarAngle={Math.PI / 2} />

</Canvas>

) }

export default Computers

Satvik77 commented 1 year ago

@Tusharknwl I'm providing you the code for Computer.jsx please check it, i'm unable to see the computer, also I've installed three properly

import {Suspense,useEffect,useState} from 'react'; import { Canvas } from '@react-three/fiber'; import { OrbitControls,Preload,useGLTF } from '@react-three/drei'; import CanvasLoader from '../Loader'; import { RGBA_ASTC_10x10_Format } from 'three';

const Computers = () => { const computer = useGLTF('./desktop_pc/scene.gltf')

return ( ) }

const ComputersCanvas =()=>{ return( <Canvas frameloop="demand" shadows camera={{position: [20,30,5],fov: 25}} gl={{preserveDrawingBuffer:true }} > <OrbitControls enableZoom={false} maxPolarAngle={Math.PI / 2} minPolarAngle={Math.PI / 2} />

</Canvas>

) }

export default ComputersCanvas;//replace here

Kritansh1 commented 1 year ago

@Tusharknwl I'm providing you the code for Computer.jsx please check it, i'm unable to see the computer, also I've installed three properly import {Suspense,useEffect,useState} from 'react'; import { Canvas } from '@react-three/fiber'; import { OrbitControls,Preload,useGLTF } from '@react-three/drei'; import CanvasLoader from '../Loader'; import { RGBA_ASTC_10x10_Format } from 'three'; const Computers = () => { const computer = useGLTF('./desktop_pc/scene.gltf') return ( ) } const ComputersCanvas =()=>{ return( <Canvas frameloop="demand" shadows camera={{position: [20,30,5],fov: 25}} gl={{preserveDrawingBuffer:true }} > <OrbitControls enableZoom={false} maxPolarAngle={Math.PI / 2} minPolarAngle={Math.PI / 2} />

</Canvas>

) } export default ComputersCanvas;//replace here

Thanks Brother, I need one more help I'm writing the code for about.jsx in that whenever I write it, the page becomes white any solution to that?

khalilsuth commented 11 months ago

@Tusharknwl I'm providing you the code for Computer.jsx please check it, i'm unable to see the computer, also I've installed three properly import {Suspense,useEffect,useState} from 'react'; import { Canvas } from '@react-three/fiber'; import { OrbitControls,Preload,useGLTF } from '@react-three/drei'; import CanvasLoader from '../Loader'; import { RGBA_ASTC_10x10_Format } from 'three'; const Computers = () => { const computer = useGLTF('./desktop_pc/scene.gltf') return ( ) } const ComputersCanvas =()=>{ return( <Canvas frameloop="demand" shadows camera={{position: [20,30,5],fov: 25}} gl={{preserveDrawingBuffer:true }} > <OrbitControls enableZoom={false} maxPolarAngle={Math.PI / 2} minPolarAngle={Math.PI / 2} />

</Canvas>

) } export default ComputersCanvas;//replace here

Hi, can you please help me troubleshoot this issue too? I followed the thread but I must be missing something :/ I was getting errors where the commented code is and saw that you guys didn't return anything so I did the same.

Screenshot 2023-09-25 at 9 49 25 PM
Tusharknwl commented 11 months ago

@khalilsuth you are using the wrong syntax you must return your html element in the return().

update your Computers function like this

const Computers = () => {
    const computer = useGLTF('./desktop_pc/scene.gltf')
        return (
             <mesh> 
                 <hemisphereLight intensity={0.15}
                      groundColor="black" />
                 <pointLight intensity={1} />
                  <primitive 
                       object={computer.scene}
                     />
             </mesh>
          )
 }