working reset and ping pong

This commit is contained in:
James B. Pollack 2016-03-17 09:18:12 -07:00
parent ed1913e58d
commit c35e4bc78a
6 changed files with 43 additions and 18 deletions

View file

@ -445,10 +445,19 @@
var userData = JSON.parse(_this.currentProperties.userData); var userData = JSON.parse(_this.currentProperties.userData);
var innerContainer = userData['hifi-home-fishtank']['innerContainer']; var innerContainer = userData['hifi-home-fishtank']['innerContainer'];
var bounds = Entities.getEntityProperties(innerContainer, "boundingBox").boundingBox; var props = Entities.getEntityProperties(innerContainer, "boundingBox");
lowerCorner = bounds.brn; var bounds = null;
upperCorner = bounds.tfl; if (props.hasOwnProperty('boundingBox') === true) {
var bounds = props.boundingBox;
}
if (bounds !== null) {
lowerCorner = bounds.brn;
upperCorner = bounds.tfl;
}
else{
print('NO BOUNDS FOR TANK, returning!!')
return;
}
// First pre-load an array with properties on all the other fish so our per-fish loop // First pre-load an array with properties on all the other fish so our per-fish loop
// isn't doing it. // isn't doing it.
var flockProperties = []; var flockProperties = [];

View file

@ -404,8 +404,8 @@ FishTank = function(spawnPosition, spawnRotation) {
Entities.deleteEntity(upperCorner); Entities.deleteEntity(upperCorner);
Entities.deleteEntity(urchin); Entities.deleteEntity(urchin);
Entities.deleteEntity(rocks); Entities.deleteEntity(rocks);
bubbleInjector.stop(); // bubbleInjector.stop();
bubbleInjector = null; // bubbleInjector = null;
} }
@ -453,5 +453,5 @@ FishTank = function(spawnPosition, spawnRotation) {
} }
this.cleanup = cleanup; this.cleanup = cleanup;
return this;
} }

View file

@ -11,7 +11,7 @@
/*global print, 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 */ /*global print, 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() { (function() {
Script.include("../../libraries/utils.js"); Script.include("../utils.js");
var SHOOTING_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/ping_pong_gun/pong_sound.wav'; var SHOOTING_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/ping_pong_gun/pong_sound.wav';
var PING_PONG_BALL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_ball.fbx'; var PING_PONG_BALL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_ball.fbx';

View file

@ -15,7 +15,7 @@ var MODEL_URL = 'http://hifi-content.s3.amazonaws.com/alan/dev/Pingpong-Gun-New.
var COLLISION_HULL_URL = 'http://hifi-content.s3.amazonaws.com/alan/dev/Pingpong-Gun-New.obj'; var COLLISION_HULL_URL = 'http://hifi-content.s3.amazonaws.com/alan/dev/Pingpong-Gun-New.obj';
var COLLISION_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/Collisions-otherorganic/plastic_impact.L.wav'; var COLLISION_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/Collisions-otherorganic/plastic_impact.L.wav';
PingPingGun = function(spawnPosition, spawnRotation) { _PingPongGun = function(spawnPosition, spawnRotation) {
var pingPongGun = Entities.addEntity({ var pingPongGun = Entities.addEntity({
type: "Model", type: "Model",
modelURL: MODEL_URL, modelURL: MODEL_URL,
@ -28,6 +28,7 @@ PingPingGun = function(spawnPosition, spawnRotation) {
y: 0.3875, y: 0.3875,
z: 0.9931 z: 0.9931
}, },
rotation:Quat.fromPitchYawRollDegrees(spawnRotation.x,spawnRotation.y,spawnRotation.z),
dynamic: true, dynamic: true,
collisionSoundURL: COLLISION_SOUND_URL, collisionSoundURL: COLLISION_SOUND_URL,
userData: JSON.stringify({ userData: JSON.stringify({
@ -61,7 +62,9 @@ PingPingGun = function(spawnPosition, spawnRotation) {
}) })
}); });
function cleanUp() { function cleanup() {
Entities.deleteEntity(pingPongGun); Entities.deleteEntity(pingPongGun);
} }
this.cleanup = cleanup;
} }

View file

@ -31,7 +31,7 @@
var plantPath = Script.resolvePath("growingPlant/wrapper.js?" + Math.random()); var plantPath = Script.resolvePath("growingPlant/wrapper.js?" + Math.random());
var pingPingGunPath = Script.resolvePath("pingPingGun/wrapper.js?" + Math.random()); var pingPongGunPath = Script.resolvePath("pingPongGun/wrapper.js?" + Math.random());
var kineticPath = Script.resolvePath("kineticObjects/wrapper.js?" + Math.random()); var kineticPath = Script.resolvePath("kineticObjects/wrapper.js?" + Math.random());
@ -109,6 +109,7 @@
Script.include(tiltMazePath); Script.include(tiltMazePath);
Script.include(whiteboardPath); Script.include(whiteboardPath);
Script.include(plantPath); Script.include(plantPath);
Script.include(pingPongGunPath);
var fishTank = new FishTank({ var fishTank = new FishTank({
x: 1098.9254, x: 1098.9254,
@ -128,21 +129,31 @@
z: -77 z: -77
}); });
//var myPlant = new Plant(center); var myPlant = new Plant({
x: 1099.8785,
y: 460.3115,
z: -84.7736
});
var pingPongGun = new PingPongGun({ var pingPongGun = new _PingPongGun({
x: 1101.2123, x: 1101.2123,
y: 460.2328, y: 460.2328,
z: -65.8513 z: -65.8513
}, {
x: 97.3683,
y: 179.0293,
z: 89.9698
}); });
dynamicEntities.push(pingPongGun);
dynamicEntities.push(fishTank); dynamicEntities.push(fishTank);
dynamicEntities.push(tiltMaze); dynamicEntities.push(tiltMaze);
dynamicEntities.push(whiteboard); dynamicEntities.push(whiteboard);
// dynamicEntities.push(myPlant); dynamicEntities.push(myPlant);
//v2.0 //v2.0
dynamicEntities.push(pingPongGun);
// var musicBox = new MusicBox(); // var musicBox = new MusicBox();
// var cuckooClock = new CuckooClock(); // var cuckooClock = new CuckooClock();
@ -211,11 +222,13 @@
y: 459.7251, y: 459.7251,
z: -79.8097 z: -79.8097
}); });
var trashcan = new Trashcan({ var trashcan = new Trashcan({
x: 1104.0031, x: 1104.0031,
y: 459.4355, y: 459.4355,
z: -82.7294 z: -82.7294
}); });
var books = new Books({ var books = new Books({
x: 1101.2123, x: 1101.2123,
y: 460.2328, y: 460.2328,

View file

@ -33,7 +33,7 @@ Whiteboard = function(spawnPosition, spawnRotation) {
var markers = []; var markers = [];
var whiteboardPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(orientation))); var whiteboardPosition = spawnPosition;
var WHITEBOARD_MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Whiteboard-4.fbx"; var WHITEBOARD_MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Whiteboard-4.fbx";
var WHITEBOARD_COLLISION_HULL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/whiteboardCollisionHull.obj"; var WHITEBOARD_COLLISION_HULL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/whiteboardCollisionHull.obj";
var whiteboard = Entities.addEntity({ var whiteboard = Entities.addEntity({
@ -92,7 +92,7 @@ Whiteboard = function(spawnPosition, spawnRotation) {
var ERASER_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/eraser-2.fbx"; var ERASER_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/eraser-2.fbx";
var eraserPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(WHITEBOARD_RACK_DEPTH, Quat.getFront(whiteboardRotation))); var eraserPosition = Vec3.sum(spawnPosition, Vec3.multiply(WHITEBOARD_RACK_DEPTH, Quat.getFront(whiteboardRotation)));
eraserPosition = Vec3.sum(eraserPosition, Vec3.multiply(-0.5, Quat.getRight(whiteboardRotation))); eraserPosition = Vec3.sum(eraserPosition, Vec3.multiply(-0.5, Quat.getRight(whiteboardRotation)));
var eraserRotation = markerRotation; var eraserRotation = markerRotation;
@ -158,7 +158,7 @@ Whiteboard = function(spawnPosition, spawnRotation) {
"https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/marker-black.fbx", "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/marker-black.fbx",
]; ];
var markerPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(WHITEBOARD_RACK_DEPTH, Quat.getFront(orientation))); var markerPosition = Vec3.sum(spawnPosition, Vec3.multiply(WHITEBOARD_RACK_DEPTH, Quat.getFront(orientation)));
createMarker(modelURLS[0], markerPosition, { createMarker(modelURLS[0], markerPosition, {
red: 10, red: 10,