mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 13:44:32 +02:00
add menu item to control grabbable setting on newly created entites
This commit is contained in:
parent
d689a43678
commit
01b11022e3
1 changed files with 19 additions and 1 deletions
|
@ -222,6 +222,21 @@ var toolBar = (function () {
|
||||||
systemToolbar = null,
|
systemToolbar = null,
|
||||||
tablet = null;
|
tablet = null;
|
||||||
|
|
||||||
|
// add a menu item for setting newly created entities as grabbable
|
||||||
|
var GRABBABLEENTITIES_MENU_CATEGORY = "Developer";
|
||||||
|
var GRABBABLEENTITIES_MENU_ITEM = "Create Entities As Grabbable";
|
||||||
|
|
||||||
|
if (Menu.menuExists(GRABBABLEENTITIES_MENU_CATEGORY) &&
|
||||||
|
!Menu.menuItemExists(GRABBABLEENTITIES_MENU_CATEGORY, GRABBABLEENTITIES_MENU_ITEM)) {
|
||||||
|
Menu.addMenuItem({
|
||||||
|
menuName: GRABBABLEENTITIES_MENU_CATEGORY,
|
||||||
|
menuItemName: GRABBABLEENTITIES_MENU_ITEM,
|
||||||
|
isCheckable: true,
|
||||||
|
isChecked: true,
|
||||||
|
grouping: "Advanced"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function createNewEntity(properties) {
|
function createNewEntity(properties) {
|
||||||
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
|
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
|
||||||
var position = getPositionToCreateEntity();
|
var position = getPositionToCreateEntity();
|
||||||
|
@ -229,7 +244,9 @@ var toolBar = (function () {
|
||||||
if (position !== null && position !== undefined) {
|
if (position !== null && position !== undefined) {
|
||||||
position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions);
|
position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions);
|
||||||
properties.position = position;
|
properties.position = position;
|
||||||
properties.userData = JSON.stringify({ grabbableKey: { grabbable: true } });
|
if (Menu.isOptionChecked(GRABBABLEENTITIES_MENU_ITEM)) {
|
||||||
|
properties.userData = JSON.stringify({ grabbableKey: { grabbable: true } });
|
||||||
|
}
|
||||||
entityID = Entities.addEntity(properties);
|
entityID = Entities.addEntity(properties);
|
||||||
if (properties.type == "ParticleEffect") {
|
if (properties.type == "ParticleEffect") {
|
||||||
selectParticleEntity(entityID);
|
selectParticleEntity(entityID);
|
||||||
|
@ -254,6 +271,7 @@ var toolBar = (function () {
|
||||||
if (systemToolbar) {
|
if (systemToolbar) {
|
||||||
systemToolbar.removeButton(EDIT_TOGGLE_BUTTON);
|
systemToolbar.removeButton(EDIT_TOGGLE_BUTTON);
|
||||||
}
|
}
|
||||||
|
Menu.removeMenuItem(GRABBABLEENTITIES_MENU_CATEGORY, GRABBABLEENTITIES_MENU_ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
var buttonHandlers = {}; // only used to tablet mode
|
var buttonHandlers = {}; // only used to tablet mode
|
||||||
|
|
Loading…
Reference in a new issue