Merge branch 'master' of https://github.com/highfidelity/hifi into moreEraseHistory

This commit is contained in:
Brad Hefta-Gaub 2015-11-11 12:14:03 -08:00
commit 5576cf188e
18 changed files with 306 additions and 22 deletions

View file

@ -0,0 +1,144 @@
var explosionSound = SoundCache.getSound("https://s3.amazonaws.com/hifi-public/eric/sounds/explosion.wav");
var partsURLS = [{
url: "https://s3.amazonaws.com/hifi-public/eric/models/blade.fbx",
dimensions: {
x: 2,
y: 2,
z: 2
}
}, {
url: "https://s3.amazonaws.com/hifi-public/eric/models/body.fbx",
dimensions: {
x: 2.2,
y: 2.98,
z: 7.96
}
}, {
url: "https://s3.amazonaws.com/hifi-public/eric/models/tail.fbx",
dimensions: {
x: 1,
y: 1,
z: 1
}
}];
var parts = [];
var emitters = [];
var explodePosition;
var helicopter;
var entities = Entities.findEntities(MyAvatar.position, 2000);
for (i = 0; i < entities.length; i++) {
var name = Entities.getEntityProperties(entities[i], 'name').name;
if (name === "Helicopter") {
var helicopter = entities[i];
explodeHelicopter(Entities.getEntityProperties(helicopter, 'position').position);
}
}
function explodeHelicopter(explodePosition) {
Audio.playSound(explosionSound, {
position: explodePosition,
volume: 0.5
});
Entities.deleteEntity(helicopter);
for (var i = 0; i < partsURLS.length; i++) {
var position = Vec3.sum(explodePosition, {
x: 1,
y: 1,
z: 1
});
var part = Entities.addEntity({
type: "Model",
modelURL: partsURLS[i].url,
dimensions: partsURLS[i].dimensions,
position: position,
shapeType: "box",
collisionsWillMove: true,
damping: 0,
gravity: {
x: 0,
y: -9.6,
z: 0
},
velocity: {
x: Math.random(),
y: -10,
z: Math.random()
}
});
var emitter = Entities.addEntity({
type: "ParticleEffect",
name: "fire",
isEmitting: true,
textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png",
position: explodePosition,
emitRate: 100,
colorStart: {
red: 70,
green: 70,
blue: 137
},
color: {
red: 200,
green: 99,
blue: 42
},
colorFinish: {
red: 255,
green: 99,
blue: 32
},
radiusSpread: 0.2,
radiusStart: 0.3,
radiusEnd: 0.04,
particleRadius: 0.09,
radiusFinish: 0.0,
emitSpeed: 0.1,
speedSpread: 0.1,
alphaStart: 0.1,
alpha: 0.7,
alphaFinish: 0.1,
emitOrientation: Quat.fromPitchYawRollDegrees(-90, 0, 0),
emitDimensions: {
x: 1,
y: 1,
z: 0.1
},
polarFinish: Math.PI,
polarStart: 0,
accelerationSpread: {
x: 0.1,
y: 0.01,
z: 0.1
},
lifespan: 1,
});
emitters.push(emitter)
parts.push(part);
}
Script.setTimeout(function() {
var pos = Entities.getEntityProperties(parts[1], "position").position;
Entities.editEntity(emitters[0], {position: Vec3.sum(pos, {x: Math.random(), y: Math.random(), z: Math.random()})});
Entities.editEntity(emitters[1], {position: Vec3.sum(pos, {x: Math.random(), y: Math.random(), z: Math.random()})});
Entities.editEntity(emitters[2], {position: Vec3.sum(pos, {x: Math.random(), y: Math.random(), z: Math.random()})});
}, 5000)
}
function cleanup() {
parts.forEach(function(part) {
Entities.deleteEntity(part);
});
emitters.forEach(function(emitter){
Entities.deleteEntity(emitter);
})
}
Script.scriptEnding.connect(cleanup);

View file

@ -0,0 +1,132 @@
var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx?v3";
var animationURL = "https://s3.amazonaws.com/hifi-public/eric/models/bladeAnimation.fbx?v7";
var spawnPosition = {
x: 1031,
y: 145,
z: 1041
};
var speed = 0;
var helicopterSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/ryan/helicopter.L.wav");
var audioInjector = Audio.playSound(helicopterSound, {
volume: 0.3,
loop: true
});
// These constants define the Spotlight position and orientation relative to the model
var MODEL_LIGHT_POSITION = {
x: 2,
y: 0,
z: -5
};
var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, {
x: 1,
y: 0,
z: 0
});
// Evaluate the world light entity positions and orientations from the model ones
function evalLightWorldTransform(modelPos, modelRot) {
return {
p: Vec3.sum(modelPos, Vec3.multiplyQbyV(modelRot, MODEL_LIGHT_POSITION)),
q: Quat.multiply(modelRot, MODEL_LIGHT_ROTATION)
};
}
var helicopter = Entities.addEntity({
type: "Model",
name: "Helicopter",
modelURL: modelURL,
animation: {
url: animationURL,
running: true,
fps: 180
},
dimensions: {
x: 12.13,
y: 3.14,
z: 9.92
},
position: spawnPosition,
});
var spotlight = Entities.addEntity({
type: "Light",
name: "helicopter light",
intensity: 2,
color: {
red: 200,
green: 200,
blue: 255
},
intensity: 1,
dimensions: {
x: 2,
y: 2,
z: 200
},
exponent: 0.01,
cutoff: 10,
isSpotlight: true
});
var debugLight = Entities.addEntity({
type: "Box",
dimensions: {
x: .1,
y: .1,
z: .3
},
color: {
red: 200,
green: 200,
blue: 0
}
});
function cleanup() {
Entities.deleteEntity(debugLight);
Entities.deleteEntity(helicopter);
Entities.deleteEntity(spotlight);
}
function update() {
var modelProperties = Entities.getEntityProperties(helicopter, ['position', 'rotation']);
var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation);
Entities.editEntity(spotlight, {
position: lightTransform.p,
rotation: lightTransform.q
});
Entities.editEntity(debugLight, {
position: lightTransform.p,
rotation: lightTransform.q
});
audioInjector.setOptions({
position: modelProperties.position,
});
//Move forward
var newRotation = Quat.multiply(modelProperties.rotation, {
x: 0,
y: .002,
z: 0,
w: 1
})
var newPosition = Vec3.sum(modelProperties.position, Vec3.multiply(speed, Quat.getFront(modelProperties.rotation)));
Entities.editEntity(helicopter, {
position: newPosition,
rotation: newRotation
})
}
Script.update.connect(update);
Script.scriptEnding.connect(cleanup);

View file

@ -15,7 +15,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
Script.include('../utilities/tools/vector.js');
Script.include('../../utilities/tools/vector.js');
var URL = "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Scripts/planets/";

View file

@ -9,7 +9,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
Script.include("libraries/overlayUtils.js");
Script.include("overlayUtils.js");
var MOUSE_SENSITIVITY = 0.9;
var SCROLL_SENSITIVITY = 0.05;

View file

@ -1,7 +1,9 @@
var ENTITY_LIST_HTML_URL = Script.resolvePath('../html/entityList.html');
EntityListTool = function(opts) {
var that = {};
var url = Script.resolvePath('html/entityList.html');
var url = ENTITY_LIST_HTML_URL;
var webView = new WebWindow('Entities', url, 200, 280, true);
var searchRadius = 100;

View file

@ -1,3 +1,5 @@
var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html');
Grid = function(opts) {
var that = {};
@ -228,7 +230,7 @@ GridTool = function(opts) {
var verticalGrid = opts.verticalGrid;
var listeners = [];
var url = Script.resolvePath('html/gridControls.html');
var url = GRID_CONTROLS_HTML_URL;
var webView = new WebWindow('Grid', url, 200, 280, true);
horizontalGrid.addListener(function(data) {

View file

@ -11,7 +11,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
Script.include("../toys/breakdanceCore.js");
Script.include("../../../breakdanceCore.js");
OmniToolModules.Breakdance = function() {
print("OmniToolModules.Breakdance...");
@ -32,4 +32,4 @@ OmniToolModules.Breakdance.prototype.onUpdate = function(deltaTime) {
breakdanceEnd();
}
OmniToolModuleType = "Breakdance";
OmniToolModuleType = "Breakdance";

View file

@ -1,5 +1,5 @@
Script.include("avatarRelativeOverlays.js");
Script.include("../../avatarRelativeOverlays.js");
OmniToolModules.Test = function(omniTool, activeEntityId) {
this.omniTool = omniTool;

View file

@ -14,7 +14,7 @@
//
// included here to ensure walkApi.js can be used as an API, separate from walk.js
Script.include("./libraries/walkConstants.js");
Script.include("walkConstants.js");
Avatar = function() {
// if Hydras are connected, the only way to enable use is to never set any arm joint rotation

View file

@ -13,6 +13,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var WALK_SETTINGS_HTML_URL = Script.resolvePath('../html/walkSettings.html');
WalkSettings = function() {
var _visible = false;
var _innerWidth = Window.innerWidth;
@ -69,7 +71,7 @@ WalkSettings = function() {
// web window
const PANEL_WIDTH = 200;
const PANEL_HEIGHT = 180;
var _url = Script.resolvePath('html/walkSettings.html');
var _url = WALK_SETTINGS_HTML_URL;
var _webWindow = new WebWindow('Walk Settings', _url, PANEL_WIDTH, PANEL_HEIGHT, false);
_webWindow.setVisible(false);
_webWindow.eventBridge.webEventReceived.connect(function(data) {

View file

@ -7,11 +7,11 @@
//
// FIXME Script paths have to be relative to the caller, in this case libraries/OmniTool.js
Script.include("../magBalls/constants.js");
Script.include("../magBalls/graph.js");
Script.include("../magBalls/edgeSpring.js");
Script.include("../magBalls/magBalls.js");
Script.include("avatarRelativeOverlays.js");
Script.include("magBalls/constants.js");
Script.include("magBalls/graph.js");
Script.include("magBalls/edgeSpring.js");
Script.include("magBalls/magBalls.js");
Script.include("libraries/avatarRelativeOverlays.js");
OmniToolModuleType = "MagBallsController"
@ -34,7 +34,7 @@ MODE_INFO[BALL_EDIT_MODE_ADD] = {
},
colors: [ COLORS.GREEN, COLORS.BLUE ],
// FIXME use an http path or find a way to get the relative path to the file
url: Script.resolvePath('../html/magBalls/addMode.html'),
url: Script.resolvePath('html/magBalls/addMode.html'),
};
MODE_INFO[BALL_EDIT_MODE_DELETE] = {
@ -45,7 +45,7 @@ MODE_INFO[BALL_EDIT_MODE_DELETE] = {
},
colors: [ COLORS.RED, COLORS.BLUE ],
// FIXME use an http path or find a way to get the relative path to the file
url: Script.resolvePath('../html/magBalls/deleteMode.html'),
url: Script.resolvePath('html/magBalls/deleteMode.html'),
};
var UI_POSITION_MODE_LABEL = Vec3.multiply(0.5,

View file

@ -11,7 +11,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
Script.include("libraries/utils.js");
Script.include("../libraries/utils.js");
var RIGHT_HAND = 1;

View file

@ -10,7 +10,6 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
Script.include("../../utilities.js");
Script.include("../../libraries/utils.js");
var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/models/bubblewand/wand.fbx';

View file

@ -14,7 +14,6 @@
(function () {
Script.include("../../utilities.js");
Script.include("../../libraries/utils.js");
var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/models/bubblewand/bubble.fbx";

View file

@ -13,7 +13,6 @@
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
(function() {
Script.include("../../utilities.js");
Script.include("../../libraries/utils.js");
var _this;
// this is the "constructor" for the entity as a JS object we don't do much here

View file

@ -9,7 +9,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
Script.include("../../utilities.js");
Script.include("../../libraries/utils.js");
var scriptURL = Script.resolvePath('pingPongGun.js');

View file

@ -10,7 +10,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
Script.include("../../utilities.js");
Script.include("../../libraries/utils.js");
var scriptURL = Script.resolvePath('wallTarget.js');

View file

@ -902,14 +902,19 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac
BatchLoader* loader = new BatchLoader(urls);
auto evaluateScripts = [=](const QMap<QUrl, QString>& data) {
auto parentURL = _parentURL;
for (QUrl url : urls) {
QString contents = data[url];
if (contents.isNull()) {
qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
} else {
// Set the parent url so that path resolution will be relative
// to this script's url during its initial evaluation
_parentURL = url.toString();
QScriptValue result = evaluate(contents, url.toString());
}
}
_parentURL = parentURL;
if (callback.isFunction()) {
QScriptValue(callback).call();