refactoring
This commit is contained in:
+16
-16
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user