Fixes in Create App

This commit is contained in:
ksuprynowicz 2023-03-08 00:45:14 +01:00
parent 41760ee3ac
commit 3e7bdad500
4 changed files with 108 additions and 107 deletions

View file

@ -16,8 +16,7 @@
/* global Script, SelectionDisplay, LightOverlayManager, CameraManager, Grid, GridTool, EditTools, EditVoxels, EntityListTool, Vec3, SelectionManager, /* global Script, SelectionDisplay, LightOverlayManager, CameraManager, Grid, GridTool, EditTools, EditVoxels, EntityListTool, Vec3, SelectionManager,
Overlays, OverlayWebWindow, UserActivityLogger, Settings, Entities, Tablet, Toolbars, Messages, Menu, Camera, Overlays, OverlayWebWindow, UserActivityLogger, Settings, Entities, Tablet, Toolbars, Messages, Menu, Camera,
progressDialog, tooltip, MyAvatar, Quat, Controller, Clipboard, HMD, UndoStack, OverlaySystemWindow, progressDialog, tooltip, MyAvatar, Quat, Controller, Clipboard, HMD, UndoStack, OverlaySystemWindow */
keyUpEventFromUIWindow:true */
(function() { // BEGIN LOCAL_SCOPE (function() { // BEGIN LOCAL_SCOPE
//var CreateApp = function() { // BEGIN LOCAL_SCOPE //var CreateApp = function() { // BEGIN LOCAL_SCOPE
@ -132,6 +131,7 @@
shouldUseEditTabletApp: shouldUseEditTabletApp shouldUseEditTabletApp: shouldUseEditTabletApp
}); });
gridTool.selectionDisplay = selectionDisplay; gridTool.selectionDisplay = selectionDisplay;
gridTool.createApp = createApp;
gridTool.setVisible(false); gridTool.setVisible(false);
var editTools = new EditTools({ var editTools = new EditTools({
@ -149,8 +149,10 @@
var EntityShapeVisualizer = Script.require('./modules/entityShapeVisualizer.js'); var EntityShapeVisualizer = Script.require('./modules/entityShapeVisualizer.js');
var entityShapeVisualizer = new EntityShapeVisualizer(["Zone"], entityShapeVisualizerSessionName); var entityShapeVisualizer = new EntityShapeVisualizer(["Zone"], entityShapeVisualizerSessionName);
var entityListTool = new EntityListTool(shouldUseEditTabletApp); var entityListTool = new EntityListTool(shouldUseEditTabletApp, selectionManager);
entityListTool.createApp = createApp; entityListTool.createApp = createApp;
entityListTool.cameraManager = cameraManager;
entityListTool.selectionDisplay = selectionDisplay;
selectionManager.addEventListener(function () { selectionManager.addEventListener(function () {
selectionDisplay.updateHandles(); selectionDisplay.updateHandles();
@ -192,9 +194,9 @@
var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect"; var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect";
var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus"; var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus";
var SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "showLightsAndParticlesInEditMode"; var SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "showLightsAndParticlesInEditMode";
var SETTING_SHOW_ZONES_IN_EDIT_MODE = "showZonesInEditMode"; createApp.SETTING_SHOW_ZONES_IN_EDIT_MODE = "showZonesInEditMode";
var SETTING_EDITOR_COLUMNS_SETUP = "editorColumnsSetup"; createApp.SETTING_EDITOR_COLUMNS_SETUP = "editorColumnsSetup";
var SETTING_ENTITY_LIST_DEFAULT_RADIUS = "entityListDefaultRadius"; createApp.SETTING_ENTITY_LIST_DEFAULT_RADIUS = "entityListDefaultRadius";
var SETTING_EDIT_PREFIX = "Edit/"; var SETTING_EDIT_PREFIX = "Edit/";
@ -1004,11 +1006,11 @@
}); });
addButton("importEntitiesButton", function() { addButton("importEntitiesButton", function() {
importEntitiesFromFile(); createApp.importEntitiesFromFile();
}); });
addButton("importEntitiesFromUrlButton", function() { addButton("importEntitiesFromUrlButton", function() {
importEntitiesFromUrl(); createApp.importEntitiesFromUrl();
}); });
addButton("openAssetBrowserButton", function() { addButton("openAssetBrowserButton", function() {
@ -1134,7 +1136,7 @@
print("Setting isActive: " + active); print("Setting isActive: " + active);
isActive = active; isActive = active;
activeButton.editProperties({isActive: isActive}); activeButton.editProperties({isActive: isActive});
undoHistory.setEnabled(isActive); createApp.undoHistory.setEnabled(isActive);
editVoxels.setActive(active); editVoxels.setActive(active);
@ -1722,7 +1724,7 @@
(Math.abs(point.z - center.z) <= (dimensions.z / 2.0)); (Math.abs(point.z - center.z) <= (dimensions.z / 2.0));
} }
function selectAllEntitiesInCurrentSelectionBox(keepIfTouching) { createApp.selectAllEntitiesInCurrentSelectionBox = function(keepIfTouching) {
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
// Get all entities touching the bounding box of the current selection // Get all entities touching the bounding box of the current selection
var boundingBoxCorner = Vec3.subtract(selectionManager.worldPosition, var boundingBoxCorner = Vec3.subtract(selectionManager.worldPosition,
@ -1814,7 +1816,7 @@
} }
} }
function unparentSelectedEntities() { createApp.unparentSelectedEntities = function() {
if (SelectionManager.hasSelection() && SelectionManager.hasUnlockedSelection()) { if (SelectionManager.hasSelection() && SelectionManager.hasUnlockedSelection()) {
var selectedEntities = selectionManager.selections; var selectedEntities = selectionManager.selections;
var parentCheck = false; var parentCheck = false;
@ -1855,7 +1857,7 @@
Window.notifyEditError("You have nothing selected or the selection has locked entities."); Window.notifyEditError("You have nothing selected or the selection has locked entities.");
} }
} }
function parentSelectedEntities() { createApp.parentSelectedEntities = function() {
if (SelectionManager.hasSelection() && SelectionManager.hasUnlockedSelection()) { if (SelectionManager.hasSelection() && SelectionManager.hasUnlockedSelection()) {
var selectedEntities = selectionManager.selections; var selectedEntities = selectionManager.selections;
if (selectedEntities.length <= 1) { if (selectedEntities.length <= 1) {
@ -1890,7 +1892,7 @@
Window.notifyEditError("You have nothing selected or the selection has locked entities."); Window.notifyEditError("You have nothing selected or the selection has locked entities.");
} }
} }
function deleteSelectedEntities() { createApp.deleteSelectedEntities = function() {
if (SelectionManager.hasSelection() && SelectionManager.hasUnlockedSelection()) { if (SelectionManager.hasSelection() && SelectionManager.hasUnlockedSelection()) {
var deletedIDs = []; var deletedIDs = [];
@ -1928,7 +1930,7 @@
} }
} }
function toggleSelectedEntitiesLocked() { createApp.toggleSelectedEntitiesLocked = function() {
if (SelectionManager.hasSelection()) { if (SelectionManager.hasSelection()) {
var locked = !Entities.getEntityProperties(SelectionManager.selections[0], ["locked"]).locked; var locked = !Entities.getEntityProperties(SelectionManager.selections[0], ["locked"]).locked;
for (var i = 0; i < selectionManager.selections.length; i++) { for (var i = 0; i < selectionManager.selections.length; i++) {
@ -1942,7 +1944,7 @@
} }
} }
function toggleSelectedEntitiesVisible() { createApp.toggleSelectedEntitiesVisible = function() {
if (SelectionManager.hasSelection()) { if (SelectionManager.hasSelection()) {
var visible = !Entities.getEntityProperties(SelectionManager.selections[0], ["visible"]).visible; var visible = !Entities.getEntityProperties(SelectionManager.selections[0], ["visible"]).visible;
for (var i = 0; i < selectionManager.selections.length; i++) { for (var i = 0; i < selectionManager.selections.length; i++) {
@ -2007,7 +2009,7 @@
if (radius < 0 || isNaN(radius)){ if (radius < 0 || isNaN(radius)){
radius = 100; radius = 100;
} }
Settings.setValue(SETTING_ENTITY_LIST_DEFAULT_RADIUS, radius); Settings.setValue(createApp.SETTING_ENTITY_LIST_DEFAULT_RADIUS, radius);
} }
} }
@ -2019,22 +2021,22 @@
} else if (menuItem === MENU_ALLOW_SELECTION_LIGHTS) { } else if (menuItem === MENU_ALLOW_SELECTION_LIGHTS) {
Entities.setLightsArePickable(Menu.isOptionChecked(MENU_ALLOW_SELECTION_LIGHTS)); Entities.setLightsArePickable(Menu.isOptionChecked(MENU_ALLOW_SELECTION_LIGHTS));
} else if (menuItem === "Delete") { } else if (menuItem === "Delete") {
deleteSelectedEntities(); createApp.deleteSelectedEntities();
} else if (menuItem === "Undo") { } else if (menuItem === "Undo") {
undoHistory.undo(); createApp.undoHistory.undo();
} else if (menuItem === "Redo") { } else if (menuItem === "Redo") {
undoHistory.redo(); createApp.undoHistory.redo();
} else if (menuItem === MENU_SHOW_ICONS_IN_CREATE_MODE) { } else if (menuItem === MENU_SHOW_ICONS_IN_CREATE_MODE) {
entityIconOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_ICONS_IN_CREATE_MODE)); entityIconOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_ICONS_IN_CREATE_MODE));
} else if (menuItem === MENU_CREATE_ENTITIES_GRABBABLE) { } else if (menuItem === MENU_CREATE_ENTITIES_GRABBABLE) {
Settings.setValue(SETTING_EDIT_PREFIX + menuItem, Menu.isOptionChecked(menuItem)); Settings.setValue(SETTING_EDIT_PREFIX + menuItem, Menu.isOptionChecked(menuItem));
} else if (menuItem === MENU_ENTITY_LIST_DEFAULT_RADIUS) { } else if (menuItem === MENU_ENTITY_LIST_DEFAULT_RADIUS) {
Window.promptTextChanged.connect(onPromptTextChangedDefaultRadiusUserPref); Window.promptTextChanged.connect(onPromptTextChangedDefaultRadiusUserPref);
Window.promptAsync("Entity List Default Radius (in meters)", "" + Settings.getValue(SETTING_ENTITY_LIST_DEFAULT_RADIUS, 100)); Window.promptAsync("Entity List Default Radius (in meters)", "" + Settings.getValue(createApp.SETTING_ENTITY_LIST_DEFAULT_RADIUS, 100));
} else if (menuItem === MENU_IMPORT_FROM_FILE) { } else if (menuItem === MENU_IMPORT_FROM_FILE) {
importEntitiesFromFile(); createApp.importEntitiesFromFile();
} else if (menuItem === MENU_IMPORT_FROM_URL) { } else if (menuItem === MENU_IMPORT_FROM_URL) {
importEntitiesFromUrl(); createApp.importEntitiesFromUrl();
} }
tooltip.show(false); tooltip.show(false);
} }
@ -2177,7 +2179,7 @@
function deleteKey(value) { function deleteKey(value) {
if (value === 0) { // on release if (value === 0) { // on release
deleteSelectedEntities(); createApp.deleteSelectedEntities();
} }
} }
function deselectKey(value) { function deselectKey(value) {
@ -2192,17 +2194,17 @@
} }
function focusKey(value) { function focusKey(value) {
if (value === 0) { // on release if (value === 0) { // on release
setCameraFocusToSelection(); createApp.setCameraFocusToSelection();
} }
} }
function gridKey(value) { function gridKey(value) {
if (value === 0) { // on release if (value === 0) { // on release
alignGridToSelection(); createApp.alignGridToSelection();
} }
} }
function viewGridKey(value) { function viewGridKey(value) {
if (value === 0) { // on release if (value === 0) { // on release
toggleGridVisibility(); createApp.toggleGridVisibility();
} }
} }
function snapKey(value) { function snapKey(value) {
@ -2212,12 +2214,12 @@
} }
function gridToAvatarKey(value) { function gridToAvatarKey(value) {
if (value === 0) { // on release if (value === 0) { // on release
alignGridToAvatar(); createApp.alignGridToAvatar();
} }
} }
function rotateAsNextClickedSurfaceKey(value) { createApp.rotateAsNextClickedSurfaceKey = function(value) {
if (value === 0) { // on release if (value === 0) { // on release
rotateAsNextClickedSurface(); createApp.rotateAsNextClickedSurface();
} }
} }
function quickRotate90xKey(value) { function quickRotate90xKey(value) {
@ -2321,10 +2323,10 @@
}; };
function updateUndoRedoMenuItems() { function updateUndoRedoMenuItems() {
Menu.setMenuEnabled("Edit > Undo", undoHistory.canUndo()); Menu.setMenuEnabled("Edit > Undo", createApp.undoHistory.canUndo());
Menu.setMenuEnabled("Edit > Redo", undoHistory.canRedo()); Menu.setMenuEnabled("Edit > Redo", createApp.undoHistory.canRedo());
} }
var undoHistory = new UndoHistory(updateUndoRedoMenuItems); createApp.undoHistory = new UndoHistory(updateUndoRedoMenuItems);
updateUndoRedoMenuItems(); updateUndoRedoMenuItems();
// When an entity has been deleted we need a way to "undo" this deletion. Because it's not currently // When an entity has been deleted we need a way to "undo" this deletion. Because it's not currently
@ -2421,7 +2423,7 @@
properties: currentProperties properties: currentProperties
}); });
} }
undoHistory.pushCommand(applyEntityProperties, undoData, applyEntityProperties, redoData); createApp.undoHistory.pushCommand(applyEntityProperties, undoData, applyEntityProperties, redoData);
} }
var ServerScriptStatusMonitor = function(entityID, statusCallback) { var ServerScriptStatusMonitor = function(entityID, statusCallback) {
@ -3060,7 +3062,7 @@
mapping.from([Controller.Hardware.Keyboard.G]).to(viewGridKey); mapping.from([Controller.Hardware.Keyboard.G]).to(viewGridKey);
mapping.from([Controller.Hardware.Keyboard.H]).to(snapKey); mapping.from([Controller.Hardware.Keyboard.H]).to(snapKey);
mapping.from([Controller.Hardware.Keyboard.K]).to(gridToAvatarKey); mapping.from([Controller.Hardware.Keyboard.K]).to(gridToAvatarKey);
mapping.from([Controller.Hardware.Keyboard["0"]]).to(rotateAsNextClickedSurfaceKey); mapping.from([Controller.Hardware.Keyboard["0"]]).to(createApp.rotateAsNextClickedSurfaceKey);
mapping.from([Controller.Hardware.Keyboard["7"]]).to(quickRotate90xKey); mapping.from([Controller.Hardware.Keyboard["7"]]).to(quickRotate90xKey);
mapping.from([Controller.Hardware.Keyboard["8"]]).to(quickRotate90yKey); mapping.from([Controller.Hardware.Keyboard["8"]]).to(quickRotate90yKey);
mapping.from([Controller.Hardware.Keyboard["9"]]).to(quickRotate90zKey); mapping.from([Controller.Hardware.Keyboard["9"]]).to(quickRotate90zKey);
@ -3080,18 +3082,18 @@
// Bind undo to ctrl-shift-z to maintain backwards-compatibility // Bind undo to ctrl-shift-z to maintain backwards-compatibility
mapping.from([Controller.Hardware.Keyboard.Z]) mapping.from([Controller.Hardware.Keyboard.Z])
.when([Controller.Hardware.Keyboard.Control, Controller.Hardware.Keyboard.Shift]) .when([Controller.Hardware.Keyboard.Control, Controller.Hardware.Keyboard.Shift])
.to(whenPressed(function() { undoHistory.redo() })); .to(whenPressed(function() { createApp.undoHistory.redo() }));
mapping.from([Controller.Hardware.Keyboard.P]) mapping.from([Controller.Hardware.Keyboard.P])
.when([Controller.Hardware.Keyboard.Control, Controller.Hardware.Keyboard.Shift]) .when([Controller.Hardware.Keyboard.Control, Controller.Hardware.Keyboard.Shift])
.to(whenReleased(function() { unparentSelectedEntities(); })); .to(whenReleased(function() { createApp.unparentSelectedEntities(); }));
mapping.from([Controller.Hardware.Keyboard.P]) mapping.from([Controller.Hardware.Keyboard.P])
.when([Controller.Hardware.Keyboard.Control, !Controller.Hardware.Keyboard.Shift]) .when([Controller.Hardware.Keyboard.Control, !Controller.Hardware.Keyboard.Shift])
.to(whenReleased(function() { parentSelectedEntities(); })); .to(whenReleased(function() { createApp.parentSelectedEntities(); }));
var keyUpEventFromUIWindow = function(keyUpEvent) { createApp.keyUpEventFromUIWindow = function(keyUpEvent) {
var WANT_DEBUG_MISSING_SHORTCUTS = false; var WANT_DEBUG_MISSING_SHORTCUTS = false;
var pressedValue = 0.0; var pressedValue = 0.0;
@ -3113,7 +3115,7 @@
} else if (keyUpEvent.keyCodeString === "K") { } else if (keyUpEvent.keyCodeString === "K") {
gridToAvatarKey(pressedValue); gridToAvatarKey(pressedValue);
} else if (keyUpEvent.keyCodeString === "0") { } else if (keyUpEvent.keyCodeString === "0") {
rotateAsNextClickedSurfaceKey(pressedValue); createApp.rotateAsNextClickedSurfaceKey(pressedValue);
} else if (keyUpEvent.keyCodeString === "7") { } else if (keyUpEvent.keyCodeString === "7") {
quickRotate90xKey(pressedValue); quickRotate90xKey(pressedValue);
} else if (keyUpEvent.keyCodeString === "8") { } else if (keyUpEvent.keyCodeString === "8") {
@ -3129,15 +3131,15 @@
} else if (keyUpEvent.controlKey && keyUpEvent.keyCodeString === "D") { } else if (keyUpEvent.controlKey && keyUpEvent.keyCodeString === "D") {
selectionManager.duplicateSelection(); selectionManager.duplicateSelection();
} else if (!isOnMacPlatform && keyUpEvent.controlKey && !keyUpEvent.shiftKey && keyUpEvent.keyCodeString === "Z") { } else if (!isOnMacPlatform && keyUpEvent.controlKey && !keyUpEvent.shiftKey && keyUpEvent.keyCodeString === "Z") {
undoHistory.undo(); // undo is only handled via handleMenuItem on Mac createApp.undoHistory.undo(); // undo is only handled via handleMenuItem on Mac
} else if (keyUpEvent.controlKey && !keyUpEvent.shiftKey && keyUpEvent.keyCodeString === "P") { } else if (keyUpEvent.controlKey && !keyUpEvent.shiftKey && keyUpEvent.keyCodeString === "P") {
parentSelectedEntities(); createApp.parentSelectedEntities();
} else if (keyUpEvent.controlKey && keyUpEvent.shiftKey && keyUpEvent.keyCodeString === "P") { } else if (keyUpEvent.controlKey && keyUpEvent.shiftKey && keyUpEvent.keyCodeString === "P") {
unparentSelectedEntities(); createApp.unparentSelectedEntities();
} else if (!isOnMacPlatform && } else if (!isOnMacPlatform &&
((keyUpEvent.controlKey && keyUpEvent.shiftKey && keyUpEvent.keyCodeString === "Z") || ((keyUpEvent.controlKey && keyUpEvent.shiftKey && keyUpEvent.keyCodeString === "Z") ||
(keyUpEvent.controlKey && keyUpEvent.keyCodeString === "Y"))) { (keyUpEvent.controlKey && keyUpEvent.keyCodeString === "Y"))) {
undoHistory.redo(); // redo is only handled via handleMenuItem on Mac createApp.undoHistory.redo(); // redo is only handled via handleMenuItem on Mac
} else if (WANT_DEBUG_MISSING_SHORTCUTS) { } else if (WANT_DEBUG_MISSING_SHORTCUTS) {
console.warn("unhandled key event: " + JSON.stringify(keyUpEvent)) console.warn("unhandled key event: " + JSON.stringify(keyUpEvent))
} }
@ -3230,17 +3232,17 @@
return realChildren; return realChildren;
} }
function importEntitiesFromFile() { createApp.importEntitiesFromFile = function() {
Window.browseChanged.connect(onFileOpenChanged); Window.browseChanged.connect(onFileOpenChanged);
Window.browseAsync("Select .json to Import", "", "*.json"); Window.browseAsync("Select .json to Import", "", "*.json");
} }
function importEntitiesFromUrl() { createApp.importEntitiesFromUrl = function() {
Window.promptTextChanged.connect(onPromptTextChanged); Window.promptTextChanged.connect(onPromptTextChanged);
Window.promptAsync("URL of a .json to import", ""); Window.promptAsync("URL of a .json to import", "");
} }
function setCameraFocusToSelection() { createApp.setCameraFocusToSelection = function() {
cameraManager.enable(); cameraManager.enable();
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
cameraManager.focus(selectionManager.worldPosition, selectionManager.worldDimensions, cameraManager.focus(selectionManager.worldPosition, selectionManager.worldDimensions,
@ -3248,7 +3250,7 @@
} }
} }
function alignGridToSelection() { createApp.alignGridToSelection = function() {
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
if (!grid.getVisible()) { if (!grid.getVisible()) {
grid.setVisible(true, true); grid.setVisible(true, true);
@ -3257,14 +3259,14 @@
} }
} }
function alignGridToAvatar() { createApp.alignGridToAvatar = function() {
if (!grid.getVisible()) { if (!grid.getVisible()) {
grid.setVisible(true, true); grid.setVisible(true, true);
} }
grid.moveToAvatar(); grid.moveToAvatar();
} }
function toggleGridVisibility() { createApp.toggleGridVisibility = function() {
if (!grid.getVisible()) { if (!grid.getVisible()) {
grid.setVisible(true, true); grid.setVisible(true, true);
} else { } else {
@ -3272,7 +3274,7 @@
} }
} }
function rotateAsNextClickedSurface() { createApp.rotateAsNextClickedSurface = function() {
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) { if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
audioFeedback.rejection(); audioFeedback.rejection();
Window.notifyEditError("You have nothing selected, or the selection is locked."); Window.notifyEditError("You have nothing selected, or the selection is locked.");

View file

@ -11,9 +11,9 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
/* global EntityListTool, Tablet, selectionManager, Entities, Camera, MyAvatar, Vec3, Menu, Messages, /* global EntityListTool, Tablet, Entities, Camera, MyAvatar, Vec3, Menu, Messages,
cameraManager, MENU_EASE_ON_FOCUS, deleteSelectedEntities, toggleSelectedEntitiesLocked, toggleSelectedEntitiesVisible, MENU_EASE_ON_FOCUS,
keyUpEventFromUIWindow, Script, SelectionDisplay, SelectionManager, Clipboard */ Script, Clipboard */
var PROFILING_ENABLED = false; var PROFILING_ENABLED = false;
var profileIndent = ''; var profileIndent = '';
@ -32,8 +32,9 @@ const PROFILE = !PROFILING_ENABLED ? PROFILE_NOOP : function(name, fn, args) {
console.log("PROFILE-Script " + profileIndent + "(" + name + ") End " + delta + "ms"); console.log("PROFILE-Script " + profileIndent + "(" + name + ") End " + delta + "ms");
}; };
var EntityListTool = function(shouldUseEditTabletApp) { var EntityListTool = function(shouldUseEditTabletApp, selectionManager) {
var that = {}; var that = {};
that.selectionManager = selectionManager;
var CreateWindow = Script.require('../modules/createWindow.js'); var CreateWindow = Script.require('../modules/createWindow.js');
@ -110,8 +111,8 @@ var EntityListTool = function(shouldUseEditTabletApp) {
} }
var selectedIDs = []; var selectedIDs = [];
for (var i = 0; i < selectionManager.selections.length; i++) { for (var i = 0; i < that.selectionManager.selections.length; i++) {
selectedIDs.push(selectionManager.selections[i]); selectedIDs.push(that.selectionManager.selections[i]);
} }
emitJSONScriptEvent({ emitJSONScriptEvent({
@ -259,8 +260,8 @@ var EntityListTool = function(shouldUseEditTabletApp) {
}); });
var selectedIDs = []; var selectedIDs = [];
for (var j = 0; j < selectionManager.selections.length; j++) { for (var j = 0; j < that.selectionManager.selections.length; j++) {
selectedIDs.push(selectionManager.selections[j]); selectedIDs.push(that.selectionManager.selections[j]);
} }
emitJSONScriptEvent({ emitJSONScriptEvent({
@ -291,7 +292,7 @@ var EntityListTool = function(shouldUseEditTabletApp) {
function onFileSaveChanged(filename) { function onFileSaveChanged(filename) {
Window.saveFileChanged.disconnect(onFileSaveChanged); Window.saveFileChanged.disconnect(onFileSaveChanged);
if (filename !== "") { if (filename !== "") {
var success = Clipboard.exportEntities(filename, selectionManager.selections); var success = Clipboard.exportEntities(filename, that.selectionManager.selections);
if (!success) { if (!success) {
Window.notifyEditError("Export failed."); Window.notifyEditError("Export failed.");
} }
@ -313,113 +314,113 @@ var EntityListTool = function(shouldUseEditTabletApp) {
for (var i = 0; i < ids.length; i++) { for (var i = 0; i < ids.length; i++) {
entityIDs.push(ids[i]); entityIDs.push(ids[i]);
} }
selectionManager.setSelections(entityIDs, that); that.selectionManager.setSelections(entityIDs, that);
if (data.focus) { if (data.focus) {
cameraManager.enable(); that.cameraManager.enable();
cameraManager.focus(selectionManager.worldPosition, that.cameraManager.focus(that.selectionManager.worldPosition,
selectionManager.worldDimensions, that.selectionManager.worldDimensions,
Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
} }
} else if (data.type === "refresh") { } else if (data.type === "refresh") {
that.sendUpdate(); that.sendUpdate();
} else if (data.type === "teleport") { } else if (data.type === "teleport") {
if (selectionManager.hasSelection()) { if (that.selectionManager.hasSelection()) {
MyAvatar.position = selectionManager.worldPosition; MyAvatar.position = that.selectionManager.worldPosition;
} }
} else if (data.type === "export") { } else if (data.type === "export") {
if (!selectionManager.hasSelection()) { if (!that.selectionManager.hasSelection()) {
Window.notifyEditError("No entities have been selected."); Window.notifyEditError("No entities have been selected.");
} else { } else {
Window.saveFileChanged.connect(onFileSaveChanged); Window.saveFileChanged.connect(onFileSaveChanged);
Window.saveAsync("Select Where to Save", "", "*.json"); Window.saveAsync("Select Where to Save", "", "*.json");
} }
} else if (data.type === "delete") { } else if (data.type === "delete") {
deleteSelectedEntities(); that.createApp.deleteSelectedEntities();
} else if (data.type === "toggleLocked") { } else if (data.type === "toggleLocked") {
toggleSelectedEntitiesLocked(); that.createApp.toggleSelectedEntitiesLocked();
} else if (data.type === "toggleVisible") { } else if (data.type === "toggleVisible") {
toggleSelectedEntitiesVisible(); that.createApp.toggleSelectedEntitiesVisible();
} else if (data.type === "filterInView") { } else if (data.type === "filterInView") {
filterInView = data.filterInView === true; filterInView = data.filterInView === true;
} else if (data.type === "radius") { } else if (data.type === "radius") {
searchRadius = data.radius; searchRadius = data.radius;
} else if (data.type === "cut") { } else if (data.type === "cut") {
SelectionManager.cutSelectedEntities(); that.selectionManager.cutSelectedEntities();
} else if (data.type === "copy") { } else if (data.type === "copy") {
SelectionManager.copySelectedEntities(); that.selectionManager.copySelectedEntities();
} else if (data.type === "paste") { } else if (data.type === "paste") {
SelectionManager.pasteEntities(); that.selectionManager.pasteEntities();
} else if (data.type === "duplicate") { } else if (data.type === "duplicate") {
SelectionManager.duplicateSelection(); that.selectionManager.duplicateSelection();
that.sendUpdate(); that.sendUpdate();
} else if (data.type === "rename") { } else if (data.type === "rename") {
Entities.editEntity(data.entityID, {name: data.name}); Entities.editEntity(data.entityID, {name: data.name});
// make sure that the name also gets updated in the properties window // make sure that the name also gets updated in the properties window
SelectionManager._update(); that.selectionManager._update();
} else if (data.type === "toggleSpaceMode") { } else if (data.type === "toggleSpaceMode") {
SelectionDisplay.toggleSpaceMode(); SelectionDisplay.toggleSpaceMode();
} else if (data.type === 'keyUpEvent') { } else if (data.type === 'keyUpEvent') {
keyUpEventFromUIWindow(data.keyUpEvent); that.createApp.keyUpEventFromUIWindow(data.keyUpEvent);
} else if (data.type === 'undo') { } else if (data.type === 'undo') {
undoHistory.undo(); that.createApp.undoHistory.undo();
} else if (data.type === 'redo') { } else if (data.type === 'redo') {
undoHistory.redo(); that.createApp.undoHistory.redo();
} else if (data.type === 'parent') { } else if (data.type === 'parent') {
parentSelectedEntities(); that.createApp.parentSelectedEntities();
} else if (data.type === 'unparent') { } else if (data.type === 'unparent') {
unparentSelectedEntities(); that.createApp.unparentSelectedEntities();
} else if (data.type === 'hmdMultiSelectMode') { } else if (data.type === 'hmdMultiSelectMode') {
hmdMultiSelectMode = data.value; hmdMultiSelectMode = data.value;
} else if (data.type === 'selectAllInBox') { } else if (data.type === 'selectAllInBox') {
selectAllEntitiesInCurrentSelectionBox(false); that.createApp.selectAllEntitiesInCurrentSelectionBox(false);
} else if (data.type === 'selectAllTouchingBox') { } else if (data.type === 'selectAllTouchingBox') {
selectAllEntitiesInCurrentSelectionBox(true); that.createApp.selectAllEntitiesInCurrentSelectionBox(true);
} else if (data.type === 'selectParent') { } else if (data.type === 'selectParent') {
SelectionManager.selectParent(); that.selectionManager.selectParent();
} else if (data.type === 'selectTopParent') { } else if (data.type === 'selectTopParent') {
SelectionManager.selectTopParent(); that.selectionManager.selectTopParent();
} else if (data.type === 'addChildrenToSelection') { } else if (data.type === 'addChildrenToSelection') {
SelectionManager.addChildrenToSelection(); that.selectionManager.addChildrenToSelection();
} else if (data.type === 'selectFamily') { } else if (data.type === 'selectFamily') {
SelectionManager.selectFamily(); that.selectionManager.selectFamily();
} else if (data.type === 'selectTopFamily') { } else if (data.type === 'selectTopFamily') {
SelectionManager.selectTopFamily(); that.selectionManager.selectTopFamily();
} else if (data.type === 'teleportToEntity') { } else if (data.type === 'teleportToEntity') {
SelectionManager.teleportToEntity(); that.selectionManager.teleportToEntity();
} else if (data.type === 'rotateAsTheNextClickedSurface') { } else if (data.type === 'rotateAsTheNextClickedSurface') {
rotateAsNextClickedSurface(); that.createApp.rotateAsNextClickedSurface();
} else if (data.type === 'quickRotate90x') { } else if (data.type === 'quickRotate90x') {
selectionDisplay.rotate90degreeSelection("X"); that.selectionDisplay.rotate90degreeSelection("X");
} else if (data.type === 'quickRotate90y') { } else if (data.type === 'quickRotate90y') {
selectionDisplay.rotate90degreeSelection("Y"); that.selectionDisplay.rotate90degreeSelection("Y");
} else if (data.type === 'quickRotate90z') { } else if (data.type === 'quickRotate90z') {
selectionDisplay.rotate90degreeSelection("Z"); that.selectionDisplay.rotate90degreeSelection("Z");
} else if (data.type === 'moveEntitySelectionToAvatar') { } else if (data.type === 'moveEntitySelectionToAvatar') {
SelectionManager.moveEntitiesSelectionToAvatar(); that.selectionManager.moveEntitiesSelectionToAvatar();
} else if (data.type === 'loadConfigSetting') { } else if (data.type === 'loadConfigSetting') {
var columnsData = Settings.getValue(SETTING_EDITOR_COLUMNS_SETUP, "NO_DATA"); var columnsData = Settings.getValue(that.createApp.SETTING_EDITOR_COLUMNS_SETUP, "NO_DATA");
var defaultRadius = Settings.getValue(SETTING_ENTITY_LIST_DEFAULT_RADIUS, 100); var defaultRadius = Settings.getValue(that.createApp.SETTING_ENTITY_LIST_DEFAULT_RADIUS, 100);
emitJSONScriptEvent({ emitJSONScriptEvent({
"type": "loadedConfigSetting", "type": "loadedConfigSetting",
"columnsData": columnsData, "columnsData": columnsData,
"defaultRadius": defaultRadius "defaultRadius": defaultRadius
}); });
} else if (data.type === 'saveColumnsConfigSetting') { } else if (data.type === 'saveColumnsConfigSetting') {
Settings.setValue(SETTING_EDITOR_COLUMNS_SETUP, data.columnsData); Settings.setValue(that.createApp.SETTING_EDITOR_COLUMNS_SETUP, data.columnsData);
} else if (data.type === 'importFromFile') { } else if (data.type === 'importFromFile') {
importEntitiesFromFile(); that.createApp.importEntitiesFromFile();
} else if (data.type === 'importFromUrl') { } else if (data.type === 'importFromUrl') {
importEntitiesFromUrl(); that.createApp.importEntitiesFromUrl();
} else if (data.type === 'setCameraFocusToSelection') { } else if (data.type === 'setCameraFocusToSelection') {
setCameraFocusToSelection(); that.createApp.setCameraFocusToSelection();
} else if (data.type === 'alignGridToSelection') { } else if (data.type === 'alignGridToSelection') {
alignGridToSelection(); that.createApp.alignGridToSelection();
} else if (data.type === 'alignGridToAvatar') { } else if (data.type === 'alignGridToAvatar') {
alignGridToAvatar(); that.createApp.alignGridToAvatar();
} else if (data.type === 'brokenURLReport') { } else if (data.type === 'brokenURLReport') {
brokenURLReport(selectionManager.selections); brokenURLReport(that.selectionManager.selections);
} else if (data.type === 'toggleGridVisibility') { } else if (data.type === 'toggleGridVisibility') {
toggleGridVisibility(); that.createApp.toggleGridVisibility();
} else if (data.type === 'toggleSnapToGrid') { } else if (data.type === 'toggleSnapToGrid') {
that.toggleSnapToGrid(); that.toggleSnapToGrid();
} }

View file

@ -495,7 +495,7 @@ SelectionManager = (function() {
that.cutSelectedEntities = function() { that.cutSelectedEntities = function() {
that.copySelectedEntities(); that.copySelectedEntities();
deleteSelectedEntities(); that.createApp.deleteSelectedEntities();
}; };
that.copySelectedEntities = function() { that.copySelectedEntities = function() {
@ -624,7 +624,7 @@ SelectionManager = (function() {
} }
redo(copiedProperties); redo(copiedProperties);
undoHistory.pushCommand(undo, copiedProperties, redo, copiedProperties); that.createApp.undoHistory.pushCommand(undo, copiedProperties, redo, copiedProperties);
}; };
that._update = function(selectionUpdated, caller) { that._update = function(selectionUpdated, caller) {

View file

@ -10,8 +10,6 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
/* global keyUpEventFromUIWindow */
var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html'); var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html');
Grid = function() { Grid = function() {
@ -321,7 +319,7 @@ GridTool = function(opts) {
horizontalGrid.moveToSelection(); horizontalGrid.moveToSelection();
} }
} else if (data.type === 'keyUpEvent') { } else if (data.type === 'keyUpEvent') {
keyUpEventFromUIWindow(data.keyUpEvent); that.createApp.keyUpEventFromUIWindow(data.keyUpEvent);
} }
}; };