What could be causing my 3D model to not align with what it's supposed to look like

I have been working on a website using React and Next.js, and I am trying to incorporate a 3D model into my site. After downloading a file in glb format, I noticed some discrepancies between the model I saw on this website and the one displayed on my own website.

Using @react-three/fiber, @react-three/drei, and three, I managed to display the model on my website. However, the view was different from what I observed in the Babylon Sandbox:

Babylon Sandbox view

My website's view

Here are the converted codes from the glb file:

// Code for importing and displaying the model
import React, { useRef } from 'react'
import { useGLTF } from '@react-three/drei'

export default function Model(props) {
  const { nodes, materials } = useGLTF('/apple-iphone-13-pro-max.glb')
  return (
    <group {...props} dispose={null}>
      <group rotation={[-Math.PI / 2, 0, 0]}>
        // Additional mesh components...
      </group>
    </group>
  )
}

useGLTF.preload('/apple-iphone-13-pro-max.glb')

And here is where I display the model:

// Code for rendering the model with lighting and controls
import React, { Suspense } from "react";
import { Canvas } from "@react-three/fiber";
import { OrbitControls } from "@react-three/drei";
import Model from "./apple-iphone-13-pro-max";

const ModelDisplayer = () => {
  return (
    <Canvas
      camera={{ position: [5, 5, 5], fov: 10 }}
      className="w-full h-full bg-orange-500"
    >
      <Suspense fallback={null}>
        <Model position={[0, 0, 0]} />
      </Suspense>
      <ambientLight intensity={7} />
      <directionalLight intensity={3} />
      <OrbitControls />
    </Canvas>
  );
};

export default ModelDisplayer;

I have tried adjusting the directionalLight and ambientLight settings but couldn't achieve the same model view as seen in the Babylon Sandbox. As I lack experience with these packages and the canvas element, any guidance on how to match the views would be greatly appreciated. Thank you for your help!

Answer №1

Take a look at the drei Staging feature.

You might be interested in exploring the Stage and Environment components as well.

This functionality will help you with studio lighting, shadows, and more.

UPDATE

Using Stage from drei:

import { Stage } from "@react-three/drei";
...
...

<Stage>
    <Model />
</Stage>

Add your model component and place it within a Stage Component.

You can also include props for the Stage component like

  • intensity
  • environment
  • preset
  • shadows and others.

For more information, refer to the documentation here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unexpected output from Material UI Textfield

When attempting to print a page of my React app using window.print(), everything prints correctly except for the Textfield component from Material UI. It works fine when there are only a few lines of text, but when there is a lot of text, it appears like t ...

Utilize React to Effectively Control Multiple Audio Files on a Single Page, Ensuring Only One Plays at a Time with Function

I am currently working on a new React app that includes multiple music cards on the same page. I am looking to modify the state of the previous card before updating the state of the new card. Essentially, I aim to pause the audio playing in the previous ca ...

Is there a way to rectify the issue where Auth::check() continues to return false despite being logged in?

I have a web app project where users can save their favorite websites. However, I am facing an issue where Auth::check() always returns false even when I am logged in as a user and trying to retrieve data through the API. I have one WebsiteController set ...

What is the best way to reset local state after triggering a success action in Redux Saga?

I'm looking to reset my component state after a successful call in redux saga. Is there a way to achieve this? Currently, I am using the component state to track my input value. this.state = { department: '', }; The solution I have im ...

Guide on programmatically importing excel/CSV data into MongoDB collection/documents using MERN stack

I have a spreadsheet containing employee information. My objective is to save this data from the Excel file into a MongoDB database, specifically in the employee collection (each row from the spreadsheet as a document in MongoDB). This process is being car ...

Once I deployed my Nextjs website on Vercel, I encountered an issue when attempting to log in with Google as it kept redirecting me to localhost:

I rely on supabase for my backend operations. While attempting to log in using Google, I need to ensure that it does not redirect me to localhost. ...

Unable to show information post retrieval

My current challenge involves fetching data from a REST endpoint using axios, rendering it in my app.js component, and then sharing it with the entire app through the context API: axios.js import axios from 'axios'; const instance = axios.crea ...

Error message: In ReactJS, Firebase is requesting the "projectId" app configuration value which has not been provided, resulting in the error code installations/missing-app-config-values

When I deploy my Firebase React app using the command line, everything works fine. However, I encounter an error when deploying it with Travis. https://i.stack.imgur.com/372a3.png Here are my configuration files. .travis.yml language: node_js node_js: ...

Issues with Material-UI React components functionality

I recently discovered http://www.material-ui.com/ for front end design and decided to give it a try by following the getting started tutorial. I created an HTML file with the following code : <!DOCTYPE html> <html> <head> <meta ch ...

Typescript's dynamic React component and its conditional types

I am currently working on a dynamic React component and I am facing an issue with properly passing the correct propType based on the selected component. The error arises when using <SelectComponent {...props.props} /> because the props do not match t ...

Unable to extract query parameters from URL using Express JS as req.query returns an empty object

I came across discussions about this issue here and here, but unfortunately, the solutions provided didn't work for me. I'm attempting to extract parameters from the URL using req.query. In my server.js file, I've implemented the following: ...

.css files standing their ground against modifications

Currently, I'm utilizing the WebStorm IDE to work on my React project. My goal is to make modifications to the app.css files in order to update the design. However, each time I attempt to build or run the project, it dismisses all of the changes I&apo ...

``Can you help me understand how to display two different values in the same field

import React, { Component } from 'react' import DatePicker from 'material-ui/DatePicker'; class CombinedDateField extends Component { state = { first:'', second:'', } handleChangeFirstEventDate = (event, ...

Issue with MUI icon import: React, Typescript, and MUI type error - Overload does not match this call

Within my component, I am importing the following: import LogoutIcon from "@mui/icons-material/Logout"; import useLogout from "@/hooks/auth/useLogout"; const { trigger: logoutTrigger } = useLogout(); However, when utilizing this compo ...

Tabbed navigation with Material UI and URL routing

Currently, I am utilizing Material UI Tabs and attempting to create a functionality where clicking on a tab redirects the user to a specific tab with a link while remaining on the same main page. Here is an example of what I am trying to achieve, please t ...

I'm having trouble locating the module "script!foundation-sites/dist/foundation.min.js on Heroic."

This is the content of my webpack.config.js file: var webpack = require('webpack'); var path = require('path'); process.env.NODE_ENV = process.env.NODE_ENV || 'development'; module.exports = { entry: [ 'script!jque ...

React Native's setState function not causing a re-render

When using this component, the expected behavior is as follows: I press it, the selectedOpacity() function is called, the state is updated so it now renders with opacity=1. However, for some reason, after calling this.setState, it is not re-rendering. I h ...

Customize a theme component only when it is a child of another component

I am trying to customize the CSS of MuiButton only when it is nested inside a MuiDialog. https://i.stack.imgur.com/13doLm.png In regular CSS, you could achieve this with: .MuiDialog-root .MuiButton-root { border: 5px solid blue; } However, I am strug ...

Retrieve a dynamic hex color variable for Tailwind CSS using Next.js

I need to dynamically change the colors based on a hex code retrieved from a database. In my variables.js file: const primaryColor = "#000000"; const secondaryColor = "#ff0000"; const notCheckedColor = "#9CA3AF"; export { primaryColor, secondaryColor, no ...

Encountering a problem with Axios get request error in React and Redux when communicating with a Laravel 5.2 API

Currently, I am utilizing react alongside redux and axios for handling asynchronous actions. The backend is powered by Laravel 5.2 API which is located on a subdomain, while React resides on the main domain. However, whenever I attempt to make an async GET ...