refactoring

This commit is contained in:
2024-01-10 17:58:35 +05:00
parent 79cb86998a
commit ebd240cb7a
+16 -16
View File
@@ -163,7 +163,21 @@ function createButton(title, x, y, z) {
return btn;
}
function createButtons(directions, nodes) {
const onCompleteCallback = (texture, material, dir) => {
selectLocation(texture, material);
//Удаление текущих кнопок
removeButtons(currentButtons);
// поиск ноды, на которую будет переход после клика
const currentNode = nodes.find((node) => node.id === dir.nodeId);
if (currentNode) {
createButtons(currentNode.directions);
}
};
function createButtons(directions) {
const buttons = [];
directions.forEach((dir) => {
const cords = dir.gps;
@@ -173,22 +187,8 @@ function createButtons(directions, nodes) {
const texture = new THREE.TextureLoader().load(dir.panorama);
const material = new THREE.MeshBasicMaterial({ map: texture });
const onCompleteCallback = () => {
selectLocation(texture, material);
//Удаление текущих кнопок
removeButtons(currentButtons);
// поиск ноды, на которую будет переход после клика
const currentNode = nodes.find((node) => node.id === dir.nodeId);
if (currentNode) {
createButtons(currentNode.directions, nodes);
}
};
createSphere(5, 60, 40, texture, material);
animateTransition(onCompleteCallback);
animateTransition(() => onCompleteCallback(texture, material, dir));
currentButtons = buttons;
});