bx-1316-refactoring #14

Merged
ksenia_mikhailova merged 46 commits from bx-1316-refactoring into dev 2024-08-28 15:06:52 +03:00
1 changed files with 36 additions and 33 deletions
Showing only changes of commit 36a6c3e690 - Show all commits

View File

@ -131,28 +131,30 @@ const loadModels = async () => {
addTexture = await useTexture(tex) addTexture = await useTexture(tex)
} }
const mesh = { if (!models.value.find(el => el.name == 'ground')) {
color: c.offsetHSL(0, 0.5, -0.33), const mesh = {
displacementScale: envVars.focus * 0.33, color: c.offsetHSL(0, 0.5, -0.33),
roughness: 100, displacementScale: envVars.focus * 0.33,
side: DoubleSide roughness: 100,
} as MeshStandardMaterialParameters side: DoubleSide
if (envVars.env_displacementmap) { } as MeshStandardMaterialParameters
mesh.displacementMap = addTexture.displacementMap if (envVars.env_displacementmap) {
} else { mesh.displacementMap = addTexture.displacementMap
mesh.displacementMap = groundTexture.displacementMap } else {
mesh.displacementMap = groundTexture.displacementMap
}
if (envVars.env_normalmap) {
mesh.normalMap = addTexture.normalMap
}
const ground = new Mesh(
new PlaneGeometry(envVars.focus * 7, envVars.focus * 7, 1024, 1024),
new MeshStandardMaterial(mesh)
)
ground.position.y = -0.33 * envVars.focus
ground.rotateX(-Math.PI / 2)
ground.name = "ground"
models.value.push({ name: 'ground', modelFile: ground })
} }
if (envVars.env_normalmap) {
mesh.normalMap = addTexture.normalMap
}
const ground = new Mesh(
new PlaneGeometry(envVars.focus * 7, envVars.focus * 7, 1024, 1024),
new MeshStandardMaterial(mesh)
)
ground.position.y = -0.33 * envVars.focus
ground.rotateX(-Math.PI / 2)
ground.name = "ground"
models.value.push({ name: 'ground', modelFile: ground })
for (let index = 0; index < clickable.list.length; index++) { for (let index = 0; index < clickable.list.length; index++) {
const element = clickable.list[index]; const element = clickable.list[index];
@ -185,18 +187,19 @@ const loadModels = async () => {
sidebar_scene.name = raw_data.name; sidebar_scene.name = raw_data.name;
sidebar_scene.setData(sidebar_items) sidebar_scene.setData(sidebar_items)
const loaded = seekByName(scene.value, 'loaded') const box = new Box3();
if (loaded) { models.value.forEach(element => {
const box = new Box3(); if (element.name !== 'ground') {
box.expandByObject(loaded); box.expandByObject(element.modelFile.clone());
const box_size = new Vector3(); }
box.getSize(box_size) });
props.loaded_pan( const box_size = new Vector3();
new Vector3(box_size.x * 0.5, box_size.y * 0.5, box_size.z * 0.5), box.getSize(box_size)
new Vector3(box_size.x * -0.5, box_size.y * -0.25, box_size.z * -0.5), props.loaded_pan(
) new Vector3(box_size.x * 0.5, box_size.y * 0.5, box_size.z * 0.5),
} new Vector3(box_size.x * -0.5, box_size.y * -0.25, box_size.z * -0.5),
)
console.log(box_size)
controls.value.enabled = true; controls.value.enabled = true;
props.loaded(false) props.loaded(false)