2024-03-16 20:30:12 +00:00
|
|
|
import { getScene, getSceneElement, getCategory, getCookie } from "./api";
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
import { populateDestinationDropdown } from "./editor/teleport";
|
2024-03-11 14:56:03 +00:00
|
|
|
|
2024-03-27 18:54:48 +00:00
|
|
|
import registerClickDrag from "@kumitterer/aframe-click-drag-component";
|
|
|
|
|
|
|
|
registerClickDrag(window.aframe);
|
|
|
|
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
import "../css/editor.css";
|
2024-03-11 14:56:03 +00:00
|
|
|
|
|
|
|
let clickTimestamp = 0;
|
|
|
|
|
|
|
|
// Find parent quackscape-scene for ID
|
|
|
|
function findParentScene(element) {
|
|
|
|
var parent = element.parentElement;
|
|
|
|
|
|
|
|
while (parent.tagName != "QUACKSCAPE-SCENE") {
|
|
|
|
parent = parent.parentElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Distinguishing clicks from drags based on duration.
|
|
|
|
// TODO: Find a better way to distinguish these.
|
|
|
|
function addEventListeners(element) {
|
|
|
|
element.addEventListener("mousedown", function (event) {
|
|
|
|
clickTimestamp = event.timeStamp;
|
|
|
|
});
|
|
|
|
|
|
|
|
element.addEventListener("mouseup", function (event) {
|
|
|
|
if (event.timeStamp - clickTimestamp > 200) {
|
|
|
|
// Ignoring this, we only handle regular short clicks.
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
handleClick(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Right-clicks are definitely intentional.
|
|
|
|
element.addEventListener("contextmenu", function (event) {
|
|
|
|
handleClick(event);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open a modal for creating a new Element
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
function startCreateElement(event) {
|
|
|
|
var propertiesTitle = document.getElementById("propertiesTitle");
|
2024-03-27 09:16:14 +00:00
|
|
|
propertiesTitle.textContent = "Create Element";
|
2024-03-11 14:56:03 +00:00
|
|
|
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
var propertiesContent = document.getElementById("propertiesContent");
|
2024-03-11 14:56:03 +00:00
|
|
|
|
|
|
|
var thetaStart = cartesianToTheta(
|
|
|
|
event.detail.intersection.point.x,
|
|
|
|
event.detail.intersection.point.z
|
|
|
|
);
|
|
|
|
|
2024-03-28 10:33:34 +00:00
|
|
|
propertiesContent.innerHTML = `
|
|
|
|
<div class="hide" id="propertiesDebug">
|
|
|
|
<b>Creating element at:</b><br/>
|
|
|
|
X: ${event.detail.intersection.point.x}<br/>
|
|
|
|
Y: ${event.detail.intersection.point.y}<br/>
|
|
|
|
Z: ${event.detail.intersection.point.z}<br/>
|
|
|
|
Calculated Theta: ${thetaStart}<br/>
|
|
|
|
|
|
|
|
Parent Element Type: ${event.srcElement.tagName}<br/>
|
|
|
|
<hr/>
|
|
|
|
</div>
|
|
|
|
|
2024-03-11 14:56:03 +00:00
|
|
|
<form id="newElementForm">
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
<label for="resourcetype" class="form-label">Element Type</label>
|
|
|
|
<select class="form-control" aria-label="Element Type" id="resourcetype">
|
|
|
|
<option selected>Select Element Type</option>
|
|
|
|
<option value="MarkerElement">Marker</option>
|
|
|
|
<option value="ImageElement">Image</option>
|
2024-03-28 11:27:10 +00:00
|
|
|
<option value="TeleportElement">Teleport</option>
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
</select>
|
2024-03-27 09:16:14 +00:00
|
|
|
<input type="hidden" id="csrfmiddlewaretoken" value="${getCookie(
|
|
|
|
"csrftoken"
|
|
|
|
)}">
|
2024-03-27 09:51:05 +00:00
|
|
|
<div id="elementProperties"></div>
|
2024-03-11 14:56:03 +00:00
|
|
|
</form>
|
|
|
|
`;
|
2024-03-27 09:16:14 +00:00
|
|
|
|
2024-03-28 11:27:10 +00:00
|
|
|
var scene = findParentScene(event.target);
|
|
|
|
var scene_data_request = getScene(scene.getAttribute("id"));
|
|
|
|
|
2024-03-28 10:15:36 +00:00
|
|
|
document.getElementById("resetButton").classList.remove("hide");
|
|
|
|
document.getElementById("buttons").classList.remove("hide");
|
2024-03-27 09:16:14 +00:00
|
|
|
|
2024-03-28 10:06:14 +00:00
|
|
|
document
|
|
|
|
.getElementById("resourcetype")
|
|
|
|
.addEventListener("change", function () {
|
|
|
|
var selectedType = document.getElementById("resourcetype").value;
|
|
|
|
createElementPropertiesForm(selectedType, event, thetaStart);
|
2024-03-28 11:27:10 +00:00
|
|
|
|
|
|
|
scene_data_request.then((scene_data) => {
|
|
|
|
var category_data_request = getCategory(scene_data.obj.category);
|
|
|
|
|
|
|
|
category_data_request.then((category_data) => {
|
|
|
|
populateDestinationDropdown(null, category_data);
|
|
|
|
});
|
|
|
|
});
|
2024-03-28 10:06:14 +00:00
|
|
|
});
|
2024-03-11 14:56:03 +00:00
|
|
|
}
|
|
|
|
|
2024-03-28 10:26:24 +00:00
|
|
|
function createElementPropertiesForm(elementType) {
|
2024-03-28 10:06:14 +00:00
|
|
|
const elementProperties = document.getElementById("elementProperties");
|
|
|
|
let inputFields = "";
|
|
|
|
|
|
|
|
switch (elementType) {
|
|
|
|
case "MarkerElement":
|
|
|
|
case "ImageElement":
|
|
|
|
case "TeleportElement":
|
|
|
|
inputFields = `
|
|
|
|
<div class="mb-2">
|
|
|
|
<label for="title" class="form-label">Title</label>
|
|
|
|
<input type="text" class="form-control" id="title" placeholder="Title">
|
2024-03-28 10:26:24 +00:00
|
|
|
</div>
|
|
|
|
<div class="mb-2">
|
|
|
|
<label for="position_x" class="form-label">Position</label>
|
|
|
|
<div class="row g-2">
|
|
|
|
<div class="col">
|
|
|
|
<input type="number" class="form-control" id="position_x" name="position_x" min="0" max="360" placeholder="X">
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<input type="number" class="form-control" id="position_y" name="position_y" min="0" max="360" placeholder="Y">
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<input type="number" class="form-control" id="position_z" name="position_z" min="0" max="360" placeholder="Z">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
2024-03-28 10:06:14 +00:00
|
|
|
if (elementType !== "MarkerElement") {
|
|
|
|
inputFields += `
|
|
|
|
<div class="mb-2">
|
|
|
|
<label for="elementUpload" class="form-label">Image</label>
|
|
|
|
<input id="elementUpload" type="file" class="form-control">
|
|
|
|
</div>`;
|
|
|
|
}
|
|
|
|
if (elementType === "TeleportElement") {
|
|
|
|
inputFields += `
|
2024-03-28 11:27:10 +00:00
|
|
|
<div class="dropdown mb-2">
|
|
|
|
<label for="destinationDropdownSearch" class="form-label">Teleport Destination</label>
|
|
|
|
<input class="form-control" autocomplete="off" id="destinationDropdownSearch" type="text" placeholder="Search...">
|
|
|
|
<input type="hidden" id="destination">
|
|
|
|
<div class="dropdown-menu" id="destinationDropdownMenu">
|
|
|
|
<!-- Dropdown items will be populated here by JavaScript -->
|
|
|
|
</div>
|
2024-03-28 10:06:14 +00:00
|
|
|
</div>
|
2024-03-27 09:51:05 +00:00
|
|
|
|
2024-03-28 11:27:10 +00:00
|
|
|
<div class="mb-2">
|
|
|
|
<label for="destination_x" class="form-label">Destination X/Y/Z Rotation</label>
|
|
|
|
<div class="row g-2">
|
|
|
|
<div class="col">
|
|
|
|
<input type="number" class="form-control" id="destination_x" name="destination_x" min="0" max="360" placeholder="X">
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<input type="number" class="form-control" id="destination_y" name="destination_y" min="0" max="360" placeholder="Y">
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<input type="number" class="form-control" id="destination_z" name="destination_z" min="0" max="360" placeholder="Z">
|
|
|
|
</div>
|
2024-03-28 10:06:14 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2024-03-28 10:26:24 +00:00
|
|
|
// TODO: Handle unknown element type
|
2024-03-28 10:06:14 +00:00
|
|
|
}
|
2024-03-27 09:51:05 +00:00
|
|
|
|
2024-03-28 10:06:14 +00:00
|
|
|
elementProperties.innerHTML = inputFields;
|
2024-03-27 09:51:05 +00:00
|
|
|
}
|
|
|
|
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
function startModifyElement(event) {
|
2024-03-28 09:22:42 +00:00
|
|
|
// Make the element draggable for positioning
|
|
|
|
event.target.setAttribute("click-drag", "enabled: true;");
|
|
|
|
|
|
|
|
// Listen for "dragend" event to update the element's position
|
|
|
|
event.target.addEventListener("dragend", function (event) {
|
2024-03-28 12:09:48 +00:00
|
|
|
updateElementLocation(event);
|
2024-03-28 09:22:42 +00:00
|
|
|
});
|
|
|
|
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
var propertiesTitle = document.getElementById("propertiesTitle");
|
|
|
|
propertiesTitle.textContent = "Modify Element";
|
2024-03-11 14:56:03 +00:00
|
|
|
|
|
|
|
// Get element from API
|
|
|
|
var scene = findParentScene(event.target);
|
|
|
|
|
|
|
|
var element_data_request = getSceneElement(
|
|
|
|
scene.getAttribute("id"),
|
|
|
|
event.target.getAttribute("id")
|
|
|
|
);
|
|
|
|
|
|
|
|
element_data_request.then((element_data) => {
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
var propertiesContent = document.getElementById("propertiesContent");
|
2024-03-11 14:56:03 +00:00
|
|
|
|
2024-03-28 10:33:34 +00:00
|
|
|
propertiesContent.innerHTML = `
|
|
|
|
<div class="hide" id="propertiesDebug">
|
|
|
|
<b>Modifying element:</b><br/>
|
|
|
|
Element Type: ${event.srcElement.tagName}<br/>
|
|
|
|
Element ID: ${event.target.getAttribute("id")}<br/>
|
|
|
|
Element data: ${JSON.stringify(element_data.obj)}<br/>
|
|
|
|
<hr/>
|
|
|
|
</div>
|
2024-03-11 14:56:03 +00:00
|
|
|
|
|
|
|
<form id="modifyElementForm">
|
2024-03-15 14:06:15 +00:00
|
|
|
<input type="hidden" id="csrfmiddlewaretoken" value="${getCookie(
|
|
|
|
"csrftoken"
|
|
|
|
)}">
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
<input type="hidden" id="id" value="${event.target.getAttribute("id")}">
|
2024-03-28 10:06:14 +00:00
|
|
|
<div id="elementProperties"></div>
|
2024-03-11 14:56:03 +00:00
|
|
|
</form>
|
|
|
|
`;
|
|
|
|
|
2024-03-28 10:26:24 +00:00
|
|
|
createElementPropertiesForm(element_data.obj.resourcetype);
|
2024-03-28 10:06:14 +00:00
|
|
|
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
var scene_data_request = getScene(scene.getAttribute("id"));
|
|
|
|
scene_data_request.then((scene_data) => {
|
|
|
|
var category_data_request = getCategory(scene_data.obj.category);
|
|
|
|
|
|
|
|
category_data_request.then((category_data) => {
|
|
|
|
populateDestinationDropdown(
|
|
|
|
element_data.obj.destination,
|
|
|
|
category_data
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
document
|
|
|
|
.getElementById("elementUpload")
|
|
|
|
.addEventListener("change", function () {
|
|
|
|
if (this.files && this.files[0]) {
|
|
|
|
var reader = new FileReader();
|
|
|
|
|
|
|
|
reader.onload = function (e) {
|
|
|
|
// Set the image to the file contents
|
|
|
|
if (event.target.getAttribute("data-original-src") == undefined) {
|
2024-03-15 14:06:15 +00:00
|
|
|
event.target.setAttribute(
|
|
|
|
"data-original-src",
|
|
|
|
event.target.getAttribute("src")
|
|
|
|
);
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
}
|
|
|
|
event.target.setAttribute("src", e.target.result);
|
|
|
|
};
|
|
|
|
reader.readAsDataURL(this.files[0]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (element_data.obj.destination_x != -1) {
|
|
|
|
document.getElementById("destination_x").value =
|
|
|
|
element_data.obj.destination_x;
|
|
|
|
}
|
|
|
|
if (element_data.obj.destination_y != -1) {
|
|
|
|
document.getElementById("destination_y").value =
|
|
|
|
element_data.obj.destination_y;
|
|
|
|
}
|
|
|
|
if (element_data.obj.destination_z != -1) {
|
|
|
|
document.getElementById("destination_z").value =
|
|
|
|
element_data.obj.destination_z;
|
|
|
|
}
|
|
|
|
|
2024-03-28 10:15:36 +00:00
|
|
|
document.getElementById("resetButton").classList.remove("hide");
|
|
|
|
document.getElementById("buttons").classList.remove("hide");
|
2024-03-11 14:56:03 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function cartesianToTheta(x, z) {
|
|
|
|
// Calculate the angle in radians
|
|
|
|
let angleRadians = Math.atan2(z, x);
|
|
|
|
|
|
|
|
// Convert to degrees
|
|
|
|
let angleDegrees = angleRadians * (180 / Math.PI);
|
|
|
|
|
|
|
|
// A-Frame's thetaStart is measured from the positive X-axis ("right" direction)
|
|
|
|
// and goes counter-clockwise, so this should directly give us the thetaStart value.
|
|
|
|
let thetaStart = 90 - angleDegrees;
|
|
|
|
|
|
|
|
// Since atan2 returns values from -180 to 180, let's normalize this to 0 - 360
|
|
|
|
thetaStart = thetaStart < 0 ? thetaStart + 360 : thetaStart;
|
|
|
|
|
|
|
|
return thetaStart;
|
|
|
|
}
|
|
|
|
|
2024-03-28 11:27:10 +00:00
|
|
|
function thetaToCartesian(thetaStart, radius = 1) {
|
|
|
|
// Convert thetaStart back to the angle in degrees as used in standard Cartesian coordinates.
|
|
|
|
let angleDegrees = 90 - thetaStart;
|
|
|
|
|
|
|
|
// Normalize the angle to be within the range of 0 to 360 degrees
|
|
|
|
angleDegrees = angleDegrees % 360;
|
|
|
|
if (angleDegrees < 0) {
|
|
|
|
angleDegrees += 360;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert the angle back to radians
|
|
|
|
let angleRadians = angleDegrees * (Math.PI / 180);
|
|
|
|
|
|
|
|
// Calculate the Cartesian coordinates using the angle and radius
|
|
|
|
// x = r * cos(θ)
|
|
|
|
let x = radius * Math.cos(angleRadians);
|
|
|
|
// z = r * sin(θ)
|
|
|
|
let z = radius * Math.sin(angleRadians);
|
|
|
|
|
|
|
|
return { x, z };
|
|
|
|
}
|
|
|
|
|
2024-03-11 14:56:03 +00:00
|
|
|
function latLonToXYZ(lat, lon, radius = 5) {
|
|
|
|
// Convert lat/lon to X/Y/Z coordinates on the sphere
|
|
|
|
const phi = (90 - lat) * (Math.PI / 180);
|
|
|
|
const theta = (lon + 180) * (Math.PI / 180);
|
|
|
|
|
|
|
|
const x = -(radius * Math.sin(phi) * Math.cos(theta));
|
|
|
|
const y = radius * Math.cos(phi);
|
|
|
|
const z = radius * Math.sin(phi) * Math.sin(theta);
|
|
|
|
|
|
|
|
return { x, y, z };
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleClick(event) {
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
// If clicked on the sky, start creating a new element
|
2024-03-11 14:56:03 +00:00
|
|
|
if (event.target.tagName == "A-SKY") {
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
startCreateElement(event);
|
2024-03-11 14:56:03 +00:00
|
|
|
} else {
|
Enhance editor UI and user content management
Introduced significant updates to the user interface for editing VR
scenes, adding new CSS styles for a coherent and modern look.
Implemented data tables for robust content management in the user area,
now users can easily navigate through scenes and media with DataTables
integration. Expanded the API with category retrieval capabilities,
enabling dynamic content categorization.
The editor now seamlessly integrates into the UI with a sidebar for
properties editing, improving usability. The teleportation element
creation and modification logic has been significantly refined,
including a search-enabled dropdown for destination selection, making it
more user-friendly. Added thumbnail display for scenes and media in the
user area, enhancing content overview.
This update also introduced user area templates and routes, providing a
foundational structure for user content management functionality,
including categories and individual category views.
Refactored JavaScript imports to align with the new editor CSS and
adjusted scene loading to support embedded scenes, improving the
flexibility and usability of scene components.
2024-03-14 16:28:14 +00:00
|
|
|
// Else we are modifying an existing element
|
|
|
|
startModifyElement(event);
|
2024-03-11 14:56:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("loadedQuackscapeScene", function (event) {
|
|
|
|
// Get the scene
|
|
|
|
var scene = document.querySelector("a-scene");
|
|
|
|
|
|
|
|
// Get all children
|
|
|
|
var children = scene.children;
|
|
|
|
|
|
|
|
for (var i = 0; i < children.length; i++) {
|
|
|
|
var child = children[i];
|
|
|
|
|
|
|
|
if (child.tagName.startsWith("A-")) {
|
|
|
|
// Remove original onclick events
|
|
|
|
if (child.hasAttribute("onclick")) {
|
|
|
|
child.removeAttribute("onclick");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add new event listeners
|
|
|
|
addEventListeners(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2024-03-28 10:33:34 +00:00
|
|
|
|
2024-03-28 12:09:48 +00:00
|
|
|
function updateElementLocation(event) {
|
|
|
|
const theta = cartesianToTheta(event.detail.offset.x, event.detail.offset.z);
|
|
|
|
event.target.setAttribute("theta-start", theta);
|
|
|
|
}
|
|
|
|
|
2024-03-28 10:33:34 +00:00
|
|
|
function toggleDebugVisibility() {
|
|
|
|
const debugElement = document.getElementById("propertiesDebug");
|
|
|
|
debugElement.classList.toggle("hide");
|
|
|
|
}
|
|
|
|
|
2024-03-28 11:27:10 +00:00
|
|
|
document.addEventListener("keydown", function (event) {
|
|
|
|
if (event.ctrlKey && event.shiftKey && event.key === "Q") {
|
2024-03-28 10:33:34 +00:00
|
|
|
toggleDebugVisibility();
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2024-03-28 11:27:10 +00:00
|
|
|
});
|