NemoZhong / blog-nemo

0 stars 0 forks source link

r3f学习笔记 #15

Open NemoZhong opened 1 year ago

NemoZhong commented 1 year ago

最近几个月都在沉迷《八方旅人2》,由于最近比较空闲,想把“卡斯蒂”卡妈妈在海里的小船里漂荡的画面用react-three-fiber绘制出来。于是去网上找了个非常贴切的模型 作者只卖船,不卖海😭 image

NemoZhong commented 1 year ago

物料(模型,材质,全景图)资源地址 ✈️

NemoZhong commented 1 year ago

模型✈️

NemoZhong commented 1 year ago

虽然下载了船的模型,但是使用.obj和.mtl文件后渲染并不正确(猜测3dmax建模导出obj模型和贴图出问题了),因为.obj和.mtl文件全是配置项,故学习一下.mtl文件

image

newmtl name 材质名称 Ka r g b a-Ambient Light-环境光反射 - r,g,b取值范围[0,1] 对应[0,255] Kd r g b d-Diffuse Lighting-漫反射光照 - Ks r g b s-Specular Lighting-镜面反射光照 -

NemoZhong commented 1 year ago

Ns 反光度 取值范围[0,1000] 用于描述镜面光照强度 illum 光照模型,取值 0-10 0 Color on and Ambient off 1 Color on and Ambient on 2 Highlight on 3 Reflection on and Ray trace on 4 Transparency: Glass on Reflection: Ray trace on 5 Reflection: Fresnel on and Ray trace on 6 Transparency: Refraction on Reflection: Fresnel off and Ray trace on 7 Transparency: Refraction on Reflection: Fresnel on and Ray trace on 8 Reflection on and Ray trace off 9 Transparency: Glass on Reflection: Ray trace off 10 Casts shadows onto invisible surfaces

😅 反射这些可以通过后期处理,实际上完全可以只要贴图。。。

NemoZhong commented 1 year ago

image

.glb和.gltf

NemoZhong commented 1 year ago

import { Canvas } from '@react-three/fiber';

NemoZhong commented 1 year ago

import { useLoader } from '@react-three/fiber'; (常用的模型加载方式)

useLoader第四个参数回调是加载进度onProgress?: (event: ProgressEvent) => void