First of all, please understand that I am not good at English.
I'm using react three fiber so hard. I uploaded the obj file using OBJLoader.
In this way, image A was rendered. But the quality is very, very bad...
I want to increase the quality like image B.
I don't know if I matched the map of the material incorrectly
What should I do??
Thanks for sharing your wisdom
Image A
Image B
import React, {useMemo, useRef, useEffect, useState, Suspense} from 'react';
import * as THREE from 'three';
import {Canvas, useFrame, useGraph, useLoader, useThree, createPortal, ObjectMap} from "@react-three/fiber";
import {OrbitControls, OrthographicCamera, useCamera, Html, useProgress, Stats, Center} from "@react-three/drei";
import styled from "styled-components";
import {OBJLoader} from 'three/examples/jsm/loaders/OBJLoader'
import {CameraControls, CameraControlsType} from "./cameraControls";
import LightController from "./lightController";
// @ts-ignore
import objectImage from 'assets/images/NT_NO061/NT_NO061.obj';
import aoMapImage from 'assets/images/NT_NO061/Textures/T_NT_NO061_AO.png';
import mapImage from 'assets/images/NT_NO061/Textures/T_NT_NO061_D.png';
import normalMapImage from 'assets/images/NT_NO061/Textures/T_NT_NO061_N.png';
import roughnessMapImage from 'assets/images/NT_NO061/Textures/T_NT_NO061_R.png';
type geometryType = {
attach: string,
vertices: any,
onUpdate: any
}
type flag = {
video: boolean,
minimap: boolean
}
const Wrapper = styled.div`
canvas {
height: 594px
}
`
const ReactThreeFiber = () => {
const cameraControls = useRef<CameraControlsType | null>(null) as any;
const [aoMap, map, normalMap, roughnessMap] = useLoader(THREE.TextureLoader, [
aoMapImage,
mapImage,
normalMapImage,
roughnessMapImage
])
const [progressValue, setProgressValue] = useState<number>(0);
const scene = useLoader(OBJLoader, objectImage, loader => {
loader.manager.onProgress = (url, loaded, total) => {
console.log('url, loaded, total', url, loaded, total)
}
}) as any;
const {nodes} = useGraph(scene) as ObjectMap;
const {geometry} = useMemo(() => nodes[Object.keys(nodes)[0]] as any, []);
const material = new THREE.MeshPhongMaterial();
*** Question!! What should I add here to improve the quality?? ***
material.map = map;
material.normalMap = normalMap;
material.shininess = 70;
let startPoint = 3
const lookAtPos = new THREE.Vector3()
return (
<Wrapper>
<Canvas
camera={{position: [3, 3, 3]}}
onCreated={({scene}) => scene.background = new THREE.Color('#000')}
frameloop={'demand'}
>
<CameraControls
ref={cameraControls}
minDistance={2}
maxDistance={7}
/>
<LightController/>
<OrbitControls/>
<Center>
<mesh
position={[0, -2, 0]}
geometry={geometry}
material={material}
/>
</Center>
<Stats/>
</Canvas>
</Wrapper>
);
}
export default React.memo(ReactThreeFiber);