Create app fixes

This commit is contained in:
ksuprynowicz 2023-04-23 22:50:03 +02:00
parent 56c3bad002
commit f016a19b4d
2 changed files with 12 additions and 11 deletions

View file

@ -185,6 +185,7 @@
var SUBMENU_ENTITY_EDITOR_PREFERENCES = "Edit > Preferences"; var SUBMENU_ENTITY_EDITOR_PREFERENCES = "Edit > Preferences";
var MENU_AUTO_FOCUS_ON_SELECT = "Auto Focus on Select"; var MENU_AUTO_FOCUS_ON_SELECT = "Auto Focus on Select";
var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus"; var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus";
createApp.MENU_EASE_ON_FOCUS = MENU_EASE_ON_FOCUS;
var MENU_SHOW_ICONS_IN_CREATE_MODE = "Show Icons in Create Mode"; var MENU_SHOW_ICONS_IN_CREATE_MODE = "Show Icons in Create Mode";
var MENU_CREATE_ENTITIES_GRABBABLE = "Create Entities As Grabbable (except Zones, Particles, and Lights)"; var MENU_CREATE_ENTITIES_GRABBABLE = "Create Entities As Grabbable (except Zones, Particles, and Lights)";
var MENU_ALLOW_SELECTION_LARGE = "Allow Selecting of Large Models"; var MENU_ALLOW_SELECTION_LARGE = "Allow Selecting of Large Models";
@ -539,7 +540,7 @@
function createNewEntity(requestedProperties) { function createNewEntity(requestedProperties) {
var dimensions = requestedProperties.dimensions ? requestedProperties.dimensions : DEFAULT_DIMENSIONS; var dimensions = requestedProperties.dimensions ? requestedProperties.dimensions : DEFAULT_DIMENSIONS;
var position = getPositionToCreateEntity(); var position = createApp.getPositionToCreateEntity();
var entityID = null; var entityID = null;
var properties = {}; var properties = {};
@ -1858,7 +1859,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.");
} }
} }
createApp.parentSelectedEntities = function() { 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) {
@ -2044,7 +2045,7 @@
var HALF_TREE_SCALE = 16384; var HALF_TREE_SCALE = 16384;
function getPositionToCreateEntity(extra) { createApp.getPositionToCreateEntity = function(extra) {
var CREATE_DISTANCE = 2; var CREATE_DISTANCE = 2;
var position; var position;
var delta = extra !== undefined ? extra : 0; var delta = extra !== undefined ? extra : 0;
@ -2081,7 +2082,7 @@
var isLargeImport = Clipboard.getClipboardContentsLargestDimension() >= VERY_LARGE; var isLargeImport = Clipboard.getClipboardContentsLargestDimension() >= VERY_LARGE;
var position = Vec3.ZERO; var position = Vec3.ZERO;
if (!isLargeImport) { if (!isLargeImport) {
position = getPositionToCreateEntity(Clipboard.getClipboardContentsLargestDimension() / 2); position = createApp.getPositionToCreateEntity(Clipboard.getClipboardContentsLargestDimension() / 2);
} }
if (position !== null && position !== undefined) { if (position !== null && position !== undefined) {
var pastedEntityIDs = Clipboard.pasteEntities(position); var pastedEntityIDs = Clipboard.pasteEntities(position);
@ -2104,7 +2105,7 @@
} }
targetDirection = Vec3.multiplyQbyV(targetDirection, Vec3.UNIT_Z); targetDirection = Vec3.multiplyQbyV(targetDirection, Vec3.UNIT_Z);
var targetPosition = getPositionToCreateEntity(); var targetPosition = createApp.getPositionToCreateEntity();
var deltaParallel = HALF_TREE_SCALE; // Distance to move entities parallel to targetDirection. var deltaParallel = HALF_TREE_SCALE; // Distance to move entities parallel to targetDirection.
var deltaPerpendicular = Vec3.ZERO; // Distance to move entities perpendicular to targetDirection. var deltaPerpendicular = Vec3.ZERO; // Distance to move entities perpendicular to targetDirection.
for (var i = 0, length = pastedEntityIDs.length; i < length; i++) { for (var i = 0, length = pastedEntityIDs.length; i < length; i++) {
@ -3203,7 +3204,7 @@
createApp.getParentState = function(id) { createApp.getParentState = function(id) {
var state = "NONE"; var state = "NONE";
var properties = Entities.getEntityProperties(id, ["parentID"]); var properties = Entities.getEntityProperties(id, ["parentID"]);
var children = getDomainOnlyChildrenIDs(id); var children = createApp.getDomainOnlyChildrenIDs(id);
if (properties.parentID !== Uuid.NULL) { if (properties.parentID !== Uuid.NULL) {
if (children.length > 0) { if (children.length > 0) {
state = "PARENT_CHILDREN"; state = "PARENT_CHILDREN";
@ -3220,7 +3221,7 @@
//print("Global object after getParentState" + JSON.stringify(globalThis)); //print("Global object after getParentState" + JSON.stringify(globalThis));
function getDomainOnlyChildrenIDs(id) { createApp.getDomainOnlyChildrenIDs = function(id) {
var allChildren = Entities.getChildrenIDs(id); var allChildren = Entities.getChildrenIDs(id);
var realChildren = []; var realChildren = [];
var properties; var properties;
@ -3233,7 +3234,7 @@
return realChildren; return realChildren;
} }
createApp.importEntitiesFromFile = function() { 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");
} }

View file

@ -585,7 +585,7 @@ SelectionManager = (function() {
that.pasteEntities = function() { that.pasteEntities = function() {
var dimensions = entityClipboard.dimensions; var dimensions = entityClipboard.dimensions;
var maxDimension = Math.max(dimensions.x, dimensions.y, dimensions.z); var maxDimension = Math.max(dimensions.x, dimensions.y, dimensions.z);
var pastePosition = getPositionToCreateEntity(maxDimension); var pastePosition = that.createApp.getPositionToCreateEntity(maxDimension);
var deltaPosition = Vec3.subtract(pastePosition, entityClipboard.position); var deltaPosition = Vec3.subtract(pastePosition, entityClipboard.position);
var copiedProperties = []; var copiedProperties = [];
@ -783,12 +783,12 @@ SelectionManager = (function() {
that.addChildrenToSelection = function() { that.addChildrenToSelection = function() {
if (that.hasSelection()) { if (that.hasSelection()) {
for (var i = 0; i < that.selections.length; i++) { for (var i = 0; i < that.selections.length; i++) {
var childrenIDs = getDomainOnlyChildrenIDs(that.selections[i]); var childrenIDs = that.createApp.getDomainOnlyChildrenIDs(that.selections[i]);
var collectNewChildren; var collectNewChildren;
var j; var j;
var k = 0; var k = 0;
do { do {
collectNewChildren = getDomainOnlyChildrenIDs(childrenIDs[k]); collectNewChildren = that.createApp.getDomainOnlyChildrenIDs(childrenIDs[k]);
if (collectNewChildren.length > 0) { if (collectNewChildren.length > 0) {
for (j = 0; j < collectNewChildren.length; j++) { for (j = 0; j < collectNewChildren.length; j++) {
childrenIDs.push(collectNewChildren[j]); childrenIDs.push(collectNewChildren[j]);