star_mod_renderer
Advanced tools
Comparing version 1.0.28 to 1.0.29
124
default.js
@@ -43,14 +43,14 @@ import * as THREE from 'star_mod_custom_three'; | ||
name: 'dreamland', | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686649142_b_sky.png', | ||
abroadPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686649287_b_sky.png' | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686829260_20230615-164749.jpg', | ||
abroadPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686829260_20230615-164749.jpg' | ||
}, | ||
sky: { | ||
name: 'sky', | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686649233_d_sky.png', | ||
abroadPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686649304_d_sky.png' | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686829171_20230615-164800.jpg', | ||
abroadPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686829171_20230615-164800.jpg' | ||
}, | ||
dusk: { | ||
name: 'dusk', | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686649249_e_sky.png', | ||
abroadPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686649324_e_sky.png' | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686829290_20230615-164803.jpg', | ||
abroadPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686829290_20230615-164803.jpg' | ||
} | ||
@@ -84,3 +84,7 @@ } | ||
export const GLASS_MATERIAL_KEY = 4; | ||
export const FEMALE_BODY_MATERIAL_KEY = 7; | ||
export const MALE_BODY_MATERIAL_KEY = 5; | ||
export const defaultPreviewData = { | ||
@@ -132,4 +136,18 @@ cameraPosition: { x: 0, y: 0, z: 0 }, | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1684145150_F_CSZ_01_Head.FBX' | ||
} | ||
}, | ||
}, | ||
7: { | ||
name: '女身', | ||
fbx: { | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686902121_F_CSZ_01_Body.FBX', | ||
abroadPath: '' | ||
}, | ||
}, | ||
5: { | ||
name: '男身', | ||
fbx: { | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686908967_M_CSZ_body_01.FBX', | ||
abroadPath: '' | ||
}, | ||
} | ||
} | ||
@@ -151,1 +169,93 @@ | ||
} | ||
// 玻璃、男性头部皮肤、男性身体皮肤、女性头部皮肤、女性身体皮肤 | ||
export const specificMaterial = { | ||
glass: { | ||
key: GLASS_MATERIAL_KEY, | ||
materialParams: { | ||
color: 0xffffff, | ||
metalness: 0, | ||
roughness: 0, | ||
ior: 2, | ||
envMapIntensity: 1, | ||
transmission: 1, // use material.transmission for glass materials | ||
specularIntensity: 1, | ||
specularColor: 0xffffff, | ||
opacity: 1, | ||
side: THREE.DoubleSide, | ||
transparent: true, | ||
map: null, | ||
normalMap: null, | ||
aoMap: null, | ||
roughnessMap: null, | ||
metalnessMap: null, | ||
emissiveIntensityMap: null, | ||
emissiveMap: null, | ||
emissive: 1, | ||
} | ||
}, | ||
femaleBody: { | ||
key: FEMALE_BODY_MATERIAL_KEY, | ||
dTGA: { | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686901817_F_bdy_01_D.png', | ||
abroadPath: '' | ||
}, | ||
nTGA: { | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686901841_F_bdy_01_N.png', | ||
abroadPath: '' | ||
}, | ||
srmTGA: { | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686901855_F_bdy_01_g.png', | ||
abroadPath: '' | ||
}, | ||
materialParams: { | ||
color: 0xffffff, | ||
metalness: 0, | ||
roughness: 1, | ||
map: null, | ||
normalMap: null, | ||
aoMap: null, | ||
roughnessMap: null, | ||
metalnessMap: null, | ||
emissiveIntensityMap: null, | ||
emissiveMap: null, | ||
emissive: 1, | ||
clearcoat: 0.1, | ||
clearcoatRoughness: 0.5, | ||
reflectivity: 0.1, | ||
sheen: 0.2, | ||
} | ||
}, | ||
maleBody: { | ||
key: MALE_BODY_MATERIAL_KEY, | ||
dTGA: { | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686908999_M_body_01_D.png', | ||
abroadPath: '' | ||
}, | ||
nTGA: { | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686909039_M_body_01_N.png', | ||
abroadPath: '' | ||
}, | ||
srmTGA: { | ||
domesticPath: 'https://westar-cdn-source-1258344700.cos.ap-nanjing.myqcloud.com/mod/modOfficial/1686909553_M_body_01_g.png', | ||
abroadPath: '' | ||
}, | ||
materialParams: { | ||
color: 0xffffff, | ||
metalness: 0, | ||
roughness: 1, | ||
map: null, | ||
normalMap: null, | ||
aoMap: null, | ||
roughnessMap: null, | ||
metalnessMap: null, | ||
emissiveIntensityMap: null, | ||
emissiveMap: null, | ||
emissive: 1, | ||
clearcoat: 0.1, | ||
clearcoatRoughness: 0.5, | ||
reflectivity: 0.1, | ||
sheen: 0.2, | ||
} | ||
} | ||
}; |
@@ -30,2 +30,12 @@ import { FBXLoader } from "./FBXLoader"; | ||
function loadPNGFile(url) { | ||
const loader = new THREE.TextureLoader(); | ||
return new Promise((resolve) => { | ||
loader.load(url, | ||
(data) => { | ||
resolve(data); | ||
}) | ||
}); | ||
} | ||
export async function loadFile({ url, type }) { | ||
@@ -41,2 +51,7 @@ if (type === "fbx") { | ||
} | ||
if (type === 'png') { | ||
const res = await loadPNGFile(url); | ||
return res; | ||
} | ||
} | ||
@@ -43,0 +58,0 @@ |
@@ -7,2 +7,13 @@ import * as THREE from 'star_mod_custom_three'; | ||
} from '../parser'; | ||
import { | ||
specificMaterial, | ||
GLASS_MATERIAL_KEY, | ||
FEMALE_BODY_MATERIAL_KEY, | ||
MALE_BODY_MATERIAL_KEY, | ||
FEMALE_HEAD_MATERIAL_KEY, | ||
MALE_HEAD_MATERIAL_KEY | ||
} from '../../default'; | ||
import { | ||
loadFile, | ||
} from '../filesHelper'; | ||
@@ -129,4 +140,12 @@ export class ModelProcessor { | ||
opacity: 1, | ||
map: null, | ||
normalMap: null, | ||
aoMap: null, | ||
roughnessMap: null, | ||
metalnessMap: null, | ||
emissiveIntensityMap: null, | ||
emissiveMap: null, | ||
emissive: 1, | ||
}); | ||
material.aoMapIntensity = 0; | ||
material.needsUpdate = true; | ||
@@ -136,33 +155,99 @@ return material; | ||
async createSpecificMaterial(type) { | ||
if (type === GLASS_MATERIAL_KEY) { | ||
return this.createGlassMaterial(); | ||
} | ||
if (type === FEMALE_BODY_MATERIAL_KEY || type === MALE_BODY_MATERIAL_KEY || type === FEMALE_HEAD_MATERIAL_KEY || type === MALE_HEAD_MATERIAL_KEY) { | ||
return await this.createSkin(type); | ||
} | ||
} | ||
createGlassMaterial() { | ||
const material = new THREE.MeshPhysicalMaterial(specificMaterial.glass.materialParams); | ||
material.materialType = GLASS_MATERIAL_KEY; | ||
material.needsUpdate = true; | ||
return material; | ||
} | ||
async createSkin(type) { | ||
// TODO: 新增 zip file helper, 下载并解压 zip 文件, loader tga 后设置纹理内容 | ||
if (type === FEMALE_BODY_MATERIAL_KEY) { | ||
const material = new THREE.MeshPhysicalMaterial(specificMaterial.femaleBody.materialParams); | ||
material.materialType = FEMALE_BODY_MATERIAL_KEY; | ||
const files = await Promise.all([ | ||
loadFile({ | ||
url: process.env.VUE_APP_NAME == "abroad" ? specificMaterial.femaleBody.dTGA.abroadPath : specificMaterial.femaleBody.dTGA.domesticPath, | ||
type: 'png' | ||
}), | ||
loadFile({ | ||
url: process.env.VUE_APP_NAME == "abroad" ? specificMaterial.femaleBody.nTGA.abroadPath : specificMaterial.femaleBody.nTGA.domesticPath, | ||
type: 'png' | ||
}), | ||
loadFile({ | ||
url: process.env.VUE_APP_NAME == "abroad" ? specificMaterial.femaleBody.srmTGA.abroadPath : specificMaterial.femaleBody.srmTGA.domesticPath, | ||
type: 'png' | ||
}), | ||
]); | ||
material.map = files[0]; | ||
material.normalMap = files[1]; | ||
material.clearcoatRoughnessMap = files[2]; // g | ||
material.needsUpdate = true; | ||
return material; | ||
} | ||
if (type === MALE_BODY_MATERIAL_KEY) { | ||
const material = new THREE.MeshPhysicalMaterial(specificMaterial.maleBody.materialParams); | ||
material.materialType = MALE_BODY_MATERIAL_KEY; | ||
const files = await Promise.all([ | ||
loadFile({ | ||
url: process.env.VUE_APP_NAME == "abroad" ? specificMaterial.maleBody.dTGA.abroadPath : specificMaterial.maleBody.dTGA.domesticPath, | ||
type: 'png' | ||
}), | ||
loadFile({ | ||
url: process.env.VUE_APP_NAME == "abroad" ? specificMaterial.maleBody.nTGA.abroadPath : specificMaterial.maleBody.nTGA.domesticPath, | ||
type: 'png' | ||
}), | ||
loadFile({ | ||
url: process.env.VUE_APP_NAME == "abroad" ? specificMaterial.maleBody.srmTGA.abroadPath : specificMaterial.maleBody.srmTGA.domesticPath, | ||
type: 'png' | ||
}), | ||
]); | ||
material.map = files[0]; | ||
material.normalMap = files[1]; | ||
material.clearcoatRoughnessMap = files[2]; // g | ||
material.needsUpdate = true; | ||
material.needsUpdate = true; | ||
return material; | ||
} | ||
} | ||
updateModelMaterialType(channel, type) { | ||
this.model.traverse(child => { | ||
this.model.traverse(async child => { | ||
if (child.material) { | ||
const material = Array.isArray(child.material) ? child.material[channel] : child.material; | ||
// 玻璃材质特殊处理 | ||
if (type === 4 && !material.isMeshPhysicalMaterial) { | ||
const glassParams = { | ||
color: 0xffffff, | ||
metalness: 0, | ||
roughness: 0, | ||
ior: 4, | ||
envMapIntensity: 1, | ||
transmission: 1, // use material.transmission for glass materials | ||
specularIntensity: 1, | ||
specularColor: 0xffffff, | ||
opacity: 1, | ||
side: THREE.DoubleSide, | ||
transparent: true | ||
}; | ||
if (material.materialType) { | ||
material.dispose(); | ||
if (Array.isArray(child.material)) { | ||
child.material[channel] = this.createStandardMaterial(); | ||
child.material[channel].needsUpdate = true; | ||
} else { | ||
child.material = this.createStandardMaterial(); | ||
child.material.needsUpdate = true; | ||
} | ||
} | ||
if (type === GLASS_MATERIAL_KEY || type === FEMALE_BODY_MATERIAL_KEY || type === MALE_BODY_MATERIAL_KEY || type === FEMALE_HEAD_MATERIAL_KEY || type === MALE_HEAD_MATERIAL_KEY) { | ||
material.dispose(); | ||
if (Array.isArray(child.material)) { | ||
child.material[channel] = new THREE.MeshPhysicalMaterial(glassParams); | ||
child.material[channel] = await this.createSpecificMaterial(type); | ||
child.material[channel].needsUpdate = true; | ||
} else { | ||
child.material = new THREE.MeshPhysicalMaterial(glassParams); | ||
child.material = await this.createSpecificMaterial(type); | ||
child.material.needsUpdate = true; | ||
} | ||
} else { | ||
if (material.isMeshPhysicalMaterial) { | ||
material.dispose(); | ||
child.material = this.createStandardMaterial(); | ||
} | ||
} | ||
@@ -169,0 +254,0 @@ } |
{ | ||
"name": "star_mod_renderer", | ||
"version": "1.0.28", | ||
"version": "1.0.29", | ||
"description": "star mod project render auxiliary ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -93,6 +93,2 @@ import * as THREE from 'star_mod_custom_three'; | ||
}); | ||
this.renderer.shadowMap.enabled = true; | ||
this.renderer.toneMapping = THREE.ACESFilmicToneMapping; | ||
this.renderer.toneMappingExposure = 1; | ||
this.renderer.domElement.style = "width: 100%; height: 100%;"; | ||
@@ -99,0 +95,0 @@ // TODO: 这里有点问题,之后再改 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
279293
7688
8