diff --git a/examples/libraries/entityList.js b/examples/libraries/entityList.js index 65c06c8cea..eb01295d97 100644 --- a/examples/libraries/entityList.js +++ b/examples/libraries/entityList.js @@ -33,12 +33,11 @@ EntityListTool = function(opts) { var ids = data.entityIds; var entityIDs = []; for (var i = 0; i < ids.length; i++) { - var entityID = Entities.getEntityItemID(ids[i]); - if (entityID.isKnownID) { - entityIDs.push(entityID); - } else { - print("Tried to select invalid entity: " + ids[i]); - } + entityIDs.push({ + id: ids[i], + isKnownID: true, + creatorTokenID: 0, + }); } selectionManager.setSelections(entityIDs); if (data.focus) { diff --git a/examples/libraries/gridTool.js b/examples/libraries/gridTool.js index eb2a227248..de4fd7b8d4 100644 --- a/examples/libraries/gridTool.js +++ b/examples/libraries/gridTool.js @@ -53,11 +53,31 @@ Grid = function(opts) { } } - that.snapToGrid = function(position, majorOnly) { + that.snapToSurface = function(position, dimensions) { if (!snapToGrid) { return position; } + if (dimensions === undefined) { + dimensions = { x: 0, y: 0, z: 0 }; + } + + return { + x: position.x, + y: origin.y + (dimensions.y / 2), + z: position.z + }; + } + + that.snapToGrid = function(position, majorOnly, dimensions) { + if (!snapToGrid) { + return position; + } + + if (dimensions === undefined) { + dimensions = { x: 0, y: 0, z: 0 }; + } + var spacing = majorOnly ? (minorGridSpacing * majorGridEvery) : minorGridSpacing; position = Vec3.subtract(position, origin); @@ -66,7 +86,7 @@ Grid = function(opts) { position.y = Math.round(position.y / spacing) * spacing; position.z = Math.round(position.z / spacing) * spacing; - return Vec3.sum(position, origin); + return Vec3.sum(Vec3.sum(position, Vec3.multiply(0.5, dimensions)), origin); } that.snapToSpacing = function(delta, majorOnly) { diff --git a/examples/newEditEntities.js b/examples/newEditEntities.js index 27a3e8a9d2..bc2d87259e 100644 --- a/examples/newEditEntities.js +++ b/examples/newEditEntities.js @@ -61,6 +61,12 @@ var DEFAULT_TEXT_DIMENSION_X = 1.0; var DEFAULT_TEXT_DIMENSION_Y = 1.0; var DEFAULT_TEXT_DIMENSION_Z = 0.01; +var DEFAULT_DIMENSIONS = { + x: DEFAULT_DIMENSION, + y: DEFAULT_DIMENSION, + z: DEFAULT_DIMENSION +}; + var MENU_INSPECT_TOOL_ENABLED = "Inspect Tool"; var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus"; @@ -220,8 +226,8 @@ var toolBar = (function () { if (position.x > 0 && position.y > 0 && position.z > 0) { var entityId = Entities.addEntity({ type: "Model", - position: position, - dimensions: { x: DEFAULT_DIMENSION, y: DEFAULT_DIMENSION, z: DEFAULT_DIMENSION }, + position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), + dimensions: DEFAULT_DIMENSIONS, modelURL: url }); print("Model added: " + url); @@ -345,8 +351,8 @@ var toolBar = (function () { if (position.x > 0 && position.y > 0 && position.z > 0) { Entities.addEntity({ type: "Box", - position: position, - dimensions: { x: DEFAULT_DIMENSION, y: DEFAULT_DIMENSION, z: DEFAULT_DIMENSION }, + position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), + dimensions: DEFAULT_DIMENSIONS, color: { red: 255, green: 0, blue: 0 } }); @@ -362,8 +368,8 @@ var toolBar = (function () { if (position.x > 0 && position.y > 0 && position.z > 0) { Entities.addEntity({ type: "Sphere", - position: position, - dimensions: { x: DEFAULT_DIMENSION, y: DEFAULT_DIMENSION, z: DEFAULT_DIMENSION }, + position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), + dimensions: DEFAULT_DIMENSIONS, color: { red: 255, green: 0, blue: 0 } }); } else { @@ -378,8 +384,8 @@ var toolBar = (function () { if (position.x > 0 && position.y > 0 && position.z > 0) { Entities.addEntity({ type: "Light", - position: position, - dimensions: { x: DEFAULT_DIMENSION, y: DEFAULT_DIMENSION, z: DEFAULT_DIMENSION }, + position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), + dimensions: DEFAULT_DIMENSIONS, isSpotlight: false, diffuseColor: { red: 255, green: 255, blue: 255 }, ambientColor: { red: 255, green: 255, blue: 255 }, @@ -403,8 +409,8 @@ var toolBar = (function () { if (position.x > 0 && position.y > 0 && position.z > 0) { Entities.addEntity({ type: "Text", - position: position, - dimensions: { x: DEFAULT_TEXT_DIMENSION_X, y: DEFAULT_TEXT_DIMENSION_Y, z: DEFAULT_TEXT_DIMENSION_Z }, + position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), + dimensions: DEFAULT_DIMENSIONS, backgroundColor: { red: 0, green: 0, blue: 0 }, textColor: { red: 255, green: 255, blue: 255 }, text: "some text", diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index e66da97390..29c4a8b19a 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -44,20 +44,6 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro return id; } -EntityItemID EntityScriptingInterface::getEntityItemID(const QString& uuid) { - EntityItemID entityID = EntityItemID(QUuid(uuid), UNKNOWN_ENTITY_TOKEN, false); - - _entityTree->lockForRead(); - EntityItem* entity = const_cast(_entityTree->findEntityByEntityItemID(entityID)); - _entityTree->unlock(); - - if (entity) { - return entity->getEntityItemID(); - } - - return entityID; -} - EntityItemID EntityScriptingInterface::identifyEntity(EntityItemID entityID) { EntityItemID actualID = entityID; diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index 7269579ab0..2150fa51da 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -64,9 +64,6 @@ public slots: /// adds a model with the specific properties Q_INVOKABLE EntityItemID addEntity(const EntityItemProperties& properties); - // Get EntityItemID from uuid string - Q_INVOKABLE EntityItemID getEntityItemID(const QString& entityID); - /// identify a recently created model to determine its true ID Q_INVOKABLE EntityItemID identifyEntity(EntityItemID entityID);