bx-1379-redesign #15

Merged
ksenia_mikhailova merged 124 commits from bx-1379-redesign into dev 2024-09-06 15:39:13 +03:00
3 changed files with 52 additions and 58 deletions
Showing only changes of commit 39f883f6ec - Show all commits

View File

@ -216,7 +216,11 @@ $boxShadow: 0px 0px 8px rgba(0, 0, 0, .25);
input[type=radio],
input[type=checkbox] {
order: 10
order: 10;
&:checked + label {
font-weight: bolder;
}
}
label {

View File

@ -2,14 +2,12 @@
import { onMounted, onUnmounted, reactive, ref, watch } from 'vue';
import {
Box3, Color, Group, Mesh,
MeshStandardMaterial, MeshBasicMaterial,
MeshStandardMaterial,
Vector2, Vector3,
Quaternion, AdditiveBlending,
Euler, SRGBColorSpace, RingGeometry,
CircleGeometry,
Quaternion, Euler, SRGBColorSpace
} from 'three';
import { useTresContext, useSeek, useTexture, useLoop } from '@tresjs/core';
import { useTresContext, useSeek, useLoop } from '@tresjs/core';
// @ts-ignore
import { useGLTF } from '@tresjs/cientos'
@ -25,7 +23,6 @@ import { useTimer } from '../../stores/timer';
import { useRawData } from '../../stores/raw_data';
import { useTimerHome } from '../../stores/timer_home';
import { useItem } from '../../stores/item';
import { hsl } from 'd3';
const props = defineProps(['source', 'loaded_pan', 'push'])
@ -38,7 +35,7 @@ const targetDistance = reactive({ max: 10, min: 0 })
let sidebar_clickable = [] as PromoScene[]
let sidebar_visible = [] as PromoScene[]
const COUNT = 50
const COUNT = 30
type smooth = {
value: Vector3 | Quaternion | undefined,
count: number
@ -272,22 +269,22 @@ watch(() => sidebar.is_open && sidebar.id_clickable, () => {
if (el) {
targetDistance.max = 10
targetDistance.min = 1
const test_euler = new Euler(
-45 * 1 * (Math.PI / 180),
35 * 1 * (Math.PI / 180),
35 * 1 * (Math.PI / 180)
)
const target_vector = new Vector3();
el.getWorldPosition(target_vector);
// target_vector.y = raw_dataStore.data.min_distance > 50 ? raw_dataStore.data.min_distance / 10 : 1;
target_vector.setComponent(1, raw_dataStore.data.min_distance > 50 ? raw_dataStore.data.min_distance / 10 : 1)
// target_vector.setComponent(1, raw_dataStore.data.min_distance > 50 ? raw_dataStore.data.min_distance / 10 : 1)
// const quaternion = new Quaternion();
// quaternion.setFromEuler(new Euler(
// -45 * 1 * (Math.PI / 180),
// 35 * 1 * (Math.PI / 180),
// 35 * 1 * (Math.PI / 180)
// ));
const quaternion = new Quaternion();
quaternion.setFromEuler(test_euler);
set_moveto(smooth_rotate, quaternion)
// set_moveto(smooth_rotate, quaternion)
const d = raw_dataStore.data.max_distance * 0.5;
// const d = raw_dataStore.data.max_distance * 0.5;
const lerp_vector = new Vector3(0, 0, 0)
lerp_vector.lerpVectors(target_vector, camera.value?.position as Vector3, 0.5)
lerp_vector.setComponent(1, raw_dataStore.data.max_distance * 0.5)
@ -295,7 +292,7 @@ watch(() => sidebar.is_open && sidebar.id_clickable, () => {
camera.value?.position && camera.value?.position.distanceTo(lerp_vector) > raw_dataStore.data.max_distance * 0.5 ||
camera.value?.position && camera.value?.position.distanceTo(target_vector) > 10
) {
set_moveto(smooth_target, new Vector3(lerp_vector.x, d, lerp_vector.z))
set_moveto(smooth_target, lerp_vector)
set_moveto(smooth_move, lerp_vector)
set_moveto(temp_smooth_target, target_vector)
@ -324,44 +321,37 @@ onAfterRender(() => {
}
}
})
const koef = (1 / COUNT) * 3
const smoothy = [
{
el: smooth_target,
temp_el: temp_smooth_target,
f: () => {
(controls.value as any).target.lerp(smooth_target.value as Vector3, 1 / smooth_target.count);
},
},
{
el: smooth_move,
temp_el: temp_smooth_move,
f: () => {
camera.value?.position.lerp(smooth_move.value as Vector3, 1 / smooth_move.count);
},
},
{
el: smooth_rotate,
f: () => {
camera.value?.quaternion.slerp(smooth_rotate.value as Quaternion, 1 / smooth_rotate.count);
camera.value?.quaternion.normalize()
}
const koef = 0.2
const threshold = 2
if (smooth_move.value || smooth_target.value || smooth_rotate.value) {
// Плавно изменяем позицию камеры
camera.value?.position.lerp(smooth_target.value as Vector3, koef);
if (smooth_rotate.value) {
const currentRotation = new Quaternion().copy(camera.value.quaternion);
currentRotation.slerp(smooth_rotate.value, 0.5);
camera.value.quaternion.copy(currentRotation);
// camera.value?.quaternion.slerp(smooth_rotate.value as Quaternion, 0.5);
camera.value?.quaternion.normalize()
console.log(camera.value?.quaternion.angleTo(smooth_rotate.value as Quaternion))
}
]
smoothy.forEach(element => {
if (element.el.value) {
timer.resetTimer();
element.f()
element.el.count -= 1
if (element.el.count == 1) {
set_moveto(element.el, undefined)
if (element.temp_el && element.temp_el.value) {
set_moveto(element.el, element.temp_el.value)
set_moveto(element.temp_el, undefined)
}
}
// Плавно изменяем целевую точку контроллера
controls.value.target.lerp(smooth_target.value, koef);
controls.value.update(); // Обновляем контроллер
// Проверка на достижение целевой позиции
if (
camera.value.position.distanceTo(smooth_move.value || smooth_target.value) < threshold
// && camera.value?.quaternion.angleTo(smooth_rotate.value as Quaternion) < Math.PI / 8
) {
smooth_move.value = smooth_target.value = smooth_rotate.value = undefined
if (temp_smooth_move) set_moveto(smooth_move, temp_smooth_move.value)
if (temp_smooth_target) set_moveto(smooth_target, temp_smooth_target.value)
}
});
}
})
const timer = useTimer()

View File

@ -35,7 +35,7 @@ watch(() => sidebar.id_clickable, () => {
<div class="sidebar-accordion-content" v-if="sidebar.isAccOpen('clickable')">
<div class="sidebar-list-item" v-for="(item, index) in sidebar_scene.clickable">
<input type="radio" name="clickable" v-model="clickable_obj" :value="item.id"
:id="item.id.toString()" />
:id="item.id.toString()" />
<label :for="item.id.toString()">{{ index + 1 }} {{ item.name }}</label>
</div>
</div>