#new to 3js, not sure where im going wrong with rendering

46 messages · Page 1 of 1 (latest)

halcyon dome
#
 import React, { Component } from "react";
        import * as THREE from "three";
        import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";

        class Room extends Component {
            componentDidMount() {
                const loader = new GLTFLoader();
                loader.load('src/assets/room.glb', function (gltf: { scene: any; }) {
                    const scene = new THREE.Scene();
                    scene.add(gltf.scene);
                    const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
                    camera.position.z = 5;
                    const renderer = new THREE.WebGLRenderer();
                    renderer.setSize(window.innerWidth, window.innerHeight);
                    document.body.appendChild(renderer.domElement);
                    function animate() {
                        requestAnimationFrame(animate);
                        renderer.render(scene, camera);
                    }
                    animate();
                });
            }
                
            render() {
                return <div />;
            }
        }

        export default Room;
#

please help!!

dense jetty
#

I would start by testing your model in an online viewer -- if you've just exported from Blender, the model itself might have issues that would be easier to solve before bringing it into your application.

halcyon dome
#

i downloaded it from this website!

dense jetty
halcyon dome
#

ahh lights

dense jetty
# halcyon dome i downloaded it from this website!

Nice! All the same though, it is pretty common that downloads from websites have issues. Sketchfab is not using three.js or glTF to display that page, it has its own internal formats, and sometimes the conversion to glTF is imperfect when you download the file.

halcyon dome
#

could you link an online gltf renderer?

dense jetty
halcyon dome
#

it works fine here!

#

so i just need to add some lights

bold notch
halcyon dome
#

wait my thing

#

it looks so bad 😿

#

how do i fix?

bold notch
#

Try AmbientLight with intensity 1. Basically, lighting up everything

halcyon dome
#

😢

#

i noticed this model has different lighting like everywhere

#

do i need to add more lights

bold notch
#

Oh sad, You might need careful approach in lighting

halcyon dome
#

careful approach?

bold notch
#

Looking from this model, it seems like there is some postprocessing also going on. Bloom effect I think.

halcyon dome
#

yes

bold notch
halcyon dome
#

oh man

#

but its possible to get the model to look like the post processed one?

bold notch
#

yes

halcyon dome
#

gotcha

#

lemme tweak around

bold notch
#

From looking at the shadows, it seems like a light is placed at open corner of the cube.

halcyon dome
#

what position would that be

#

wat i have right now

bold notch
halcyon dome
#

okay thank you

#

sounds good

dense jetty
halcyon dome
#

ooo

#

let me check that out

bold notch
halcyon dome
#

very excited lemme try it out