mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into equip-via-parenting
This commit is contained in:
commit
9a4431560f
5 changed files with 143 additions and 14 deletions
103
examples/acScripts/entitySpawnerAC.js
Normal file
103
examples/acScripts/entitySpawnerAC.js
Normal file
|
@ -0,0 +1,103 @@
|
|||
// entitySpawnerAC
|
||||
//
|
||||
// Created by James B. Pollack @imgntn on 1/29/2016
|
||||
//
|
||||
// This script shows how to use an AC to create entities, and delete and recreate those entities if the AC gets restarted.
|
||||
// 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
|
||||
|
||||
var basePosition = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
};
|
||||
|
||||
var NUMBER_OF_BOXES = 4;
|
||||
Agent.isAvatar = true;
|
||||
|
||||
function makeBoxes() {
|
||||
var i;
|
||||
for (i = 0; i < NUMBER_OF_BOXES; i++) {
|
||||
createBox();
|
||||
}
|
||||
Script.clearInterval(octreeQueryInterval);
|
||||
}
|
||||
|
||||
function createBox() {
|
||||
var boxProps = {
|
||||
dimensions: {
|
||||
x: 1,
|
||||
y: 1,
|
||||
z: 1
|
||||
},
|
||||
color: {
|
||||
red: 0,
|
||||
green: 255,
|
||||
blue: 0
|
||||
},
|
||||
type: 'Box',
|
||||
name: 'TestBox',
|
||||
position: {
|
||||
x: basePosition.x + Math.random() * 5,
|
||||
y: basePosition.y + Math.random() * 5,
|
||||
z: basePosition.z + Math.random() * 5
|
||||
}
|
||||
}
|
||||
Entities.addEntity(boxProps)
|
||||
}
|
||||
|
||||
var secondaryInit = false;
|
||||
|
||||
function deleteBoxes() {
|
||||
if (secondaryInit === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityViewer.getOctreeElementsCount() <= 1) {
|
||||
Script.setTimeout(function() {
|
||||
deleteBoxes();
|
||||
}, 1000)
|
||||
return;
|
||||
}
|
||||
|
||||
var results = Entities.findEntities(basePosition, 2000);
|
||||
results.forEach(function(r) {
|
||||
var name = Entities.getEntityProperties(r, 'name').name;
|
||||
if (name === "TestBox") {
|
||||
Entities.deleteEntity(r);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
makeBoxes();
|
||||
secondaryInit = true;
|
||||
}
|
||||
|
||||
var initialized = false;
|
||||
|
||||
function update(deltaTime) {
|
||||
if (!initialized) {
|
||||
if (Entities.serversExist() && Entities.canRez()) {
|
||||
Entities.setPacketsPerSecond(6000);
|
||||
deleteBoxes()
|
||||
initialized = true;
|
||||
Script.update.disconnect(update);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EntityViewer.setPosition({
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
});
|
||||
EntityViewer.setKeyholeRadius(60000);
|
||||
var octreeQueryInterval = Script.setInterval(function() {
|
||||
EntityViewer.queryOctree();
|
||||
}, 1000);
|
||||
|
||||
Script.update.connect(update);
|
|
@ -13,12 +13,11 @@
|
|||
//
|
||||
// Goes into "paused" when the '.' key (and automatically when started in HMD), and normal when pressing any key.
|
||||
// See MAIN CONTROL, below, for what "paused" actually does.
|
||||
|
||||
var OVERLAY_RATIO = 1920 / 1080;
|
||||
var OVERLAY_DATA = {
|
||||
text: "Paused:\npress any key to continue",
|
||||
font: {size: 75},
|
||||
color: {red: 200, green: 255, blue: 255},
|
||||
alpha: 0.9
|
||||
imageURL: "http://hifi-content.s3.amazonaws.com/alan/production/images/images/Overlay-Viz-blank.png",
|
||||
color: {red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
};
|
||||
|
||||
// ANIMATION
|
||||
|
@ -64,10 +63,24 @@ function stopAwayAnimation() {
|
|||
}
|
||||
|
||||
// OVERLAY
|
||||
var overlay = Overlays.addOverlay("text", OVERLAY_DATA);
|
||||
var overlay = Overlays.addOverlay("image", OVERLAY_DATA);
|
||||
function showOverlay() {
|
||||
var screen = Controller.getViewportDimensions();
|
||||
Overlays.editOverlay(overlay, {visible: true, x: screen.x / 4, y: screen.y / 4});
|
||||
var properties = {visible: true},
|
||||
// Update for current screen size, keeping overlay proportions constant.
|
||||
screen = Controller.getViewportDimensions(),
|
||||
screenRatio = screen.x / screen.y;
|
||||
if (screenRatio < OVERLAY_RATIO) {
|
||||
properties.width = screen.x;
|
||||
properties.height = screen.x / OVERLAY_RATIO;
|
||||
properties.x = 0;
|
||||
properties.y = (screen.y - properties.height) / 2;
|
||||
} else {
|
||||
properties.height = screen.y;
|
||||
properties.width = screen.y * OVERLAY_RATIO;
|
||||
properties.y = 0;
|
||||
properties.x = (screen.x - properties.width) / 2;
|
||||
}
|
||||
Overlays.editOverlay(overlay, properties);
|
||||
}
|
||||
function hideOverlay() {
|
||||
Overlays.editOverlay(overlay, {visible: false});
|
||||
|
|
|
@ -1277,9 +1277,12 @@ function handeMenuEvent(menuItem) {
|
|||
}
|
||||
} else if (menuItem == "Import Entities" || menuItem == "Import Entities from URL") {
|
||||
|
||||
var importURL;
|
||||
var importURL = null;
|
||||
if (menuItem == "Import Entities") {
|
||||
importURL = "file:///" + Window.browse("Select models to import", "", "*.json");
|
||||
var fullPath = Window.browse("Select models to import", "", "*.json");
|
||||
if (fullPath) {
|
||||
importURL = "file:///" + fullPath;
|
||||
}
|
||||
} else {
|
||||
importURL = Window.prompt("URL of SVO to import", "");
|
||||
}
|
||||
|
|
|
@ -1695,9 +1695,8 @@ void Application::resizeGL() {
|
|||
}
|
||||
|
||||
bool Application::importSVOFromURL(const QString& urlString) {
|
||||
QUrl url(urlString);
|
||||
emit svoImportRequested(url.url());
|
||||
return true; // assume it's accepted
|
||||
emit svoImportRequested(urlString);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Application::event(QEvent* event) {
|
||||
|
|
|
@ -34,8 +34,19 @@ WindowScriptingInterface::WindowScriptingInterface() :
|
|||
{
|
||||
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
||||
connect(qApp, &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested);
|
||||
connect(qApp, &Application::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused);
|
||||
|
||||
connect(qApp, &Application::svoImportRequested, [this](const QString& urlString) {
|
||||
static const QMetaMethod svoImportRequestedSignal =
|
||||
QMetaMethod::fromSignal(&WindowScriptingInterface::svoImportRequested);
|
||||
|
||||
if (isSignalConnected(svoImportRequestedSignal)) {
|
||||
QUrl url(urlString);
|
||||
emit svoImportRequested(url.url());
|
||||
} else {
|
||||
OffscreenUi::warning("Import SVO Error", "You need to be running edit.js to import entities.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title, const QString& url, int width, int height) {
|
||||
|
|
Loading…
Reference in a new issue