diff --git a/CMakeLists.txt b/CMakeLists.txt index 47c4271815..fe7aad8939 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,4 +183,4 @@ endif () if (ANDROID OR DESKTOP_GVR) add_subdirectory(gvr-interface) -endif () \ No newline at end of file +endif () diff --git a/examples/controllers/hydra/toyball.js b/examples/controllers/hydra/toyball.js index 5306769e95..89085fad19 100644 --- a/examples/controllers/hydra/toyball.js +++ b/examples/controllers/hydra/toyball.js @@ -92,7 +92,6 @@ function checkControllerSide(whichSide) { Vec3.multiply(1.0 - AVERAGE_FACTOR, averageLinearVelocity[0])); linearVelocity = averageLinearVelocity[0]; angularVelocity = Vec3.multiplyQbyV(MyAvatar.orientation, Controller.getSpatialControlRawAngularVelocity(LEFT_TIP)); - angularVelocity = Vec3.multiply(180.0 / Math.PI, angularVelocity); } else { BUTTON_FWD = RIGHT_BUTTON_FWD; BUTTON_3 = RIGHT_BUTTON_3; @@ -104,7 +103,6 @@ function checkControllerSide(whichSide) { Vec3.multiply(1.0 - AVERAGE_FACTOR, averageLinearVelocity[1])); linearVelocity = averageLinearVelocity[1]; angularVelocity = Vec3.multiplyQbyV(MyAvatar.orientation, Controller.getSpatialControlRawAngularVelocity(RIGHT_TIP)); - angularVelocity = Vec3.multiply(180.0 / Math.PI, angularVelocity); handMessage = "RIGHT"; } diff --git a/examples/dice.js b/examples/dice.js index 1205f38ee1..b0021ecebb 100644 --- a/examples/dice.js +++ b/examples/dice.js @@ -53,7 +53,9 @@ function shootDice(position, velocity) { position: position, velocity: velocity, rotation: Quat.fromPitchYawRollDegrees(Math.random() * 360, Math.random() * 360, Math.random() * 360), - angularVelocity: { x: Math.random() * 100, y: Math.random() * 100, z: Math.random() * 100 }, + // NOTE: angularVelocity is in radians/sec + var maxAngularSpeed = Math.PI; + angularVelocity: { x: Math.random() * maxAngularSpeed, y: Math.random() * maxAngularSpeed, z: Math.random() * maxAngularSpeed }, lifetime: LIFETIME, gravity: { x: 0, y: GRAVITY, z: 0 }, shapeType: "box", @@ -108,4 +110,4 @@ function scriptEnding() { Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity); Controller.mousePressEvent.connect(mousePressEvent); -Script.scriptEnding.connect(scriptEnding); \ No newline at end of file +Script.scriptEnding.connect(scriptEnding); diff --git a/examples/editEntities.js b/examples/editEntities.js index a0f3cdc167..e6d4534b86 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -22,9 +22,7 @@ Script.include([ "libraries/progressDialog.js", "libraries/entitySelectionTool.js", - "libraries/ModelImporter.js", - "libraries/ExportMenu.js", "libraries/ToolTip.js", "libraries/entityPropertyDialogBox.js", @@ -35,7 +33,6 @@ Script.include([ var selectionDisplay = SelectionDisplay; var selectionManager = SelectionManager; -var modelImporter = new ModelImporter(); var entityPropertyDialogBox = EntityPropertyDialogBox; var cameraManager = new CameraManager(); @@ -420,8 +417,6 @@ var toolBar = (function () { }()); -var exportMenu = null; - function isLocked(properties) { // special case to lock the ground plane model in hq. if (location.hostname == "hq.highfidelity.io" && @@ -694,17 +689,16 @@ function setupModelMenus() { } Menu.addMenuItem({ menuName: "Edit", menuItemName: "Entity List...", shortcutKey: "CTRL+META+L", afterItem: "Models" }); - Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste Models", shortcutKey: "CTRL+META+V", afterItem: "Entity List..." }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Large Models", shortcutKey: "CTRL+META+L", - afterItem: "Paste Models", isCheckable: true, isChecked: true }); + afterItem: "Entity List...", isCheckable: true, isChecked: true }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Small Models", shortcutKey: "CTRL+META+S", afterItem: "Allow Selecting of Large Models", isCheckable: true, isChecked: true }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Lights", shortcutKey: "CTRL+SHIFT+META+L", afterItem: "Allow Selecting of Small Models", isCheckable: true }); Menu.addMenuItem({ menuName: "File", menuItemName: "Models", isSeparator: true, beforeItem: "Settings" }); - Menu.addMenuItem({ menuName: "File", menuItemName: "Export Models", shortcutKey: "CTRL+META+E", afterItem: "Models" }); - Menu.addMenuItem({ menuName: "File", menuItemName: "Import Models", shortcutKey: "CTRL+META+I", afterItem: "Export Models" }); + Menu.addMenuItem({ menuName: "File", menuItemName: "Export Entities", shortcutKey: "CTRL+META+E", afterItem: "Models" }); + Menu.addMenuItem({ menuName: "File", menuItemName: "Import Entities", shortcutKey: "CTRL+META+I", afterItem: "Export Entities" }); Menu.addMenuItem({ menuName: "View", menuItemName: MENU_AUTO_FOCUS_ON_SELECT, afterItem: MENU_INSPECT_TOOL_ENABLED, @@ -725,14 +719,13 @@ function cleanupModelMenus() { } Menu.removeMenuItem("Edit", "Entity List..."); - Menu.removeMenuItem("Edit", "Paste Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Large Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Small Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Lights"); Menu.removeSeparator("File", "Models"); - Menu.removeMenuItem("File", "Export Models"); - Menu.removeMenuItem("File", "Import Models"); + Menu.removeMenuItem("File", "Export Entities"); + Menu.removeMenuItem("File", "Import Entities"); Menu.removeMenuItem("View", MENU_INSPECT_TOOL_ENABLED); Menu.removeMenuItem("View", MENU_AUTO_FOCUS_ON_SELECT); @@ -747,11 +740,7 @@ Script.scriptEnding.connect(function() { toolBar.cleanup(); cleanupModelMenus(); tooltip.cleanup(); - modelImporter.cleanup(); selectionDisplay.cleanup(); - if (exportMenu) { - exportMenu.close(); - } Entities.setLightsArePickable(originalLightsArePickable); }); @@ -793,18 +782,41 @@ function handeMenuEvent(menuItem) { Entities.setLightsArePickable(Menu.isOptionChecked("Allow Selecting of Lights")); } else if (menuItem == "Delete") { deleteSelectedEntities(); - } else if (menuItem == "Paste Models") { - modelImporter.paste(); - } else if (menuItem == "Export Models") { - if (!exportMenu) { - exportMenu = new ExportMenu({ - onClose: function () { - exportMenu = null; + } else if (menuItem == "Export Entities") { + if (!selectionManager.hasSelection()) { + Window.alert("No entities have been selected."); + } else { + var filename = "models__" + Window.location.hostname + "__.svo"; + filename = Window.save("Select where to save", filename, "*.svo") + if (filename) { + var success = Clipboard.exportEntities(filename, selectionManager.selections); + if (!success) { + Window.alert("Export failed."); } - }); + } + } + } else if (menuItem == "Import Entities") { + var filename = Window.browse("Select models to import", "", "*.svo") + if (filename) { + var success = Clipboard.importEntities(filename); + + if (success) { + var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE; + var direction = Quat.getFront(Camera.orientation); + var offset = Vec3.multiply(distance, direction); + var position = Vec3.sum(Camera.position, offset); + + position.x = Math.max(0, position.x); + position.y = Math.max(0, position.y); + position.z = Math.max(0, position.z); + + var pastedEntityIDs = Clipboard.pasteEntities(position); + + selectionManager.setSelections(pastedEntityIDs); + } else { + Window.alert("There was an error importing the entity file."); + } } - } else if (menuItem == "Import Models") { - modelImporter.doImport(); } else if (menuItem == "Entity List...") { entityListTool.toggleVisible(); } diff --git a/examples/example/entities/spotlightExample.js b/examples/example/entities/spotlightExample.js index 5eb5432f3f..80c89926a3 100644 --- a/examples/example/entities/spotlightExample.js +++ b/examples/example/entities/spotlightExample.js @@ -11,11 +11,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +var DEGREES_TO_RADIANS = Math.PI / 180.0; + var lightProperties = { type: "Light", position: { x: 0, y: 0, z: 0 }, dimensions: { x: 1000, y: 1000, z: 1000 }, - angularVelocity: { x: 0, y: 10, z: 0 }, + angularVelocity: { x: 0, y: 10 * DEGREES_TO_RADIANS, z: 0 }, angularDamping: 0, isSpotlight: true, diff --git a/examples/hmdDefaults.js b/examples/hmdDefaults.js new file mode 100644 index 0000000000..0096b11777 --- /dev/null +++ b/examples/hmdDefaults.js @@ -0,0 +1,16 @@ +// +// hmdDefaults.js +// examples +// +// Created by David Rowe on 6 Mar 2015. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +Script.load("progress.js"); +Script.load("lobby.js"); +Script.load("notifications.js"); +Script.load("controllers/oculus/goTo.js"); +//Script.load("scripts.js"); // Not created yet diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index fd1a4e3821..cb49b86975 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -2,6 +2,10 @@
- \ No newline at end of file +