From 0adfad526c8017700e76a2225ab565ad7d26ff96 Mon Sep 17 00:00:00 2001 From: ChenX Date: Fri, 17 Jun 2022 10:45:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96:=E6=A8=A1=E5=9E=8B=E6=9D=90?= =?UTF-8?q?=E8=B4=A8=E9=A2=9C=E8=89=B2=E5=92=8C=E6=B8=B2=E6=9F=93=E5=99=A8?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/Add-on/testEntity/ParseMaterialImage.ts | 32 +++------------------ 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 1b1314c02..fb22080e9 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "react-virtualized-auto-sizer": "^1.0.6", "react-window": "^1.8.7", "stats.js": "^0.17.0", - "three": "^0.122.0", + "three": "npm:three-cf@0.122.1", "xaop": "^2.0.0" }, "resolutions": { diff --git a/src/Add-on/testEntity/ParseMaterialImage.ts b/src/Add-on/testEntity/ParseMaterialImage.ts index eeaa894d8..19f0e1081 100644 --- a/src/Add-on/testEntity/ParseMaterialImage.ts +++ b/src/Add-on/testEntity/ParseMaterialImage.ts @@ -1,4 +1,4 @@ -import { DoubleSide, MeshPhongMaterial, MeshPhysicalMaterial, MirroredRepeatWrapping, RepeatWrapping, Texture } from "three"; +import { DoubleSide, MeshPhongMaterial, MeshPhysicalMaterial, MeshPhysicalMaterial2, MirroredRepeatWrapping, RepeatWrapping, Texture } from "three"; import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader"; import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices"; import { LoadImageFromUrl } from "../../Loader/ImageLoader"; @@ -90,7 +90,7 @@ export async function ConverMaterial2(m: MeshPhongMaterial, url: string) let dataString = await (await fetch(GenerateCdnUrl(`/Paks/paks_cooked_2/ue_resource/Content${encodeURI(url)}/${name}.json`))).text(); let data = JSON.parse(dataString); - let mtl = new MeshPhysicalMaterial({ + let mtl = new MeshPhysicalMaterial2({ side: DoubleSide, transparent: false, metalness: Math.max(0.2, data.common_metallic),//至少给个比较小的金属性 保证它的反光,否则马桶会变成纯白 @@ -167,33 +167,9 @@ export async function ConverMaterial2(m: MeshPhongMaterial, url: string) ); } } - // else - { - mtl.color.r = 1 - (1 - data.baseColor_lightColor.r) * (1 - data.baseColor_shadowColor.r); - mtl.color.g = 1 - (1 - data.baseColor_lightColor.g) * (1 - data.baseColor_shadowColor.g); - mtl.color.b = 1 - (1 - data.baseColor_lightColor.b) * (1 - data.baseColor_shadowColor.b); - - if (data.baseColor_brightness > 0) - { - mtl.color.r = Math.pow(mtl.color.r, 1 - data.baseColor_brightness); - mtl.color.g = Math.pow(mtl.color.g, 1 - data.baseColor_brightness); - mtl.color.b = Math.pow(mtl.color.b, 1 - data.baseColor_brightness); - } - else - { - mtl.color.r = Math.pow(mtl.color.r, 1 - data.baseColor_brightness); - mtl.color.g = Math.pow(mtl.color.g, 1 - data.baseColor_brightness); - mtl.color.b = Math.pow(mtl.color.b, 1 - data.baseColor_brightness); - } - // mtl.color.convertLinearToGamma(); - mtl.color.convertGammaToLinear(0.5);//本质上等于上一行代码 - - //下面的代码用于提亮,但是上面的代码已经实现了 所以废弃这个代码 - // let sum = mtl.color.r + mtl.color.g + mtl.color.b; - // if (sum < 1) - // mtl.color.multiplyScalar(1 / sum); - } + mtl.lightColor.setRGB(data.baseColor_lightColor.r, data.baseColor_lightColor.g, data.baseColor_lightColor.b); + mtl.shadowColor.setRGB(data.baseColor_shadowColor.r, data.baseColor_shadowColor.g, data.baseColor_shadowColor.b); return mtl; } catch (error)