From c35e4bc78a8f9d0e1ed5208d612c4d486ef88c42 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 17 Mar 2016 09:18:12 -0700 Subject: [PATCH] working reset and ping pong --- .../DomainContent/Home/fishTank/tank.js | 17 ++++++++++---- .../DomainContent/Home/fishTank/wrapper.js | 6 ++--- .../pingPongGun.js | 2 +- .../{pingPingGun => pingPongGun}/wrapper.js | 7 ++++-- .../DomainContent/Home/reset.js | 23 +++++++++++++++---- .../DomainContent/Home/whiteboard/wrapper.js | 6 ++--- 6 files changed, 43 insertions(+), 18 deletions(-) rename unpublishedScripts/DomainContent/Home/{pingPingGun => pingPongGun}/pingPongGun.js (99%) rename unpublishedScripts/DomainContent/Home/{pingPingGun => pingPongGun}/wrapper.js (90%) diff --git a/unpublishedScripts/DomainContent/Home/fishTank/tank.js b/unpublishedScripts/DomainContent/Home/fishTank/tank.js index 206a3fec12..73e2cbcf1f 100644 --- a/unpublishedScripts/DomainContent/Home/fishTank/tank.js +++ b/unpublishedScripts/DomainContent/Home/fishTank/tank.js @@ -445,10 +445,19 @@ var userData = JSON.parse(_this.currentProperties.userData); var innerContainer = userData['hifi-home-fishtank']['innerContainer']; - var bounds = Entities.getEntityProperties(innerContainer, "boundingBox").boundingBox; - lowerCorner = bounds.brn; - upperCorner = bounds.tfl; - + var props = Entities.getEntityProperties(innerContainer, "boundingBox"); + var bounds = null; + 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 // isn't doing it. var flockProperties = []; diff --git a/unpublishedScripts/DomainContent/Home/fishTank/wrapper.js b/unpublishedScripts/DomainContent/Home/fishTank/wrapper.js index 31de973852..86ae55db13 100644 --- a/unpublishedScripts/DomainContent/Home/fishTank/wrapper.js +++ b/unpublishedScripts/DomainContent/Home/fishTank/wrapper.js @@ -404,8 +404,8 @@ FishTank = function(spawnPosition, spawnRotation) { Entities.deleteEntity(upperCorner); Entities.deleteEntity(urchin); Entities.deleteEntity(rocks); - bubbleInjector.stop(); - bubbleInjector = null; + // bubbleInjector.stop(); + // bubbleInjector = null; } @@ -453,5 +453,5 @@ FishTank = function(spawnPosition, spawnRotation) { } this.cleanup = cleanup; - return this; + } \ No newline at end of file diff --git a/unpublishedScripts/DomainContent/Home/pingPingGun/pingPongGun.js b/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js similarity index 99% rename from unpublishedScripts/DomainContent/Home/pingPingGun/pingPongGun.js rename to unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js index 415913ea6d..c77671d478 100644 --- a/unpublishedScripts/DomainContent/Home/pingPingGun/pingPongGun.js +++ b/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js @@ -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 */ (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 PING_PONG_BALL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_ball.fbx'; diff --git a/unpublishedScripts/DomainContent/Home/pingPingGun/wrapper.js b/unpublishedScripts/DomainContent/Home/pingPongGun/wrapper.js similarity index 90% rename from unpublishedScripts/DomainContent/Home/pingPingGun/wrapper.js rename to unpublishedScripts/DomainContent/Home/pingPongGun/wrapper.js index 5c601f0b66..9cf1b78d99 100644 --- a/unpublishedScripts/DomainContent/Home/pingPingGun/wrapper.js +++ b/unpublishedScripts/DomainContent/Home/pingPongGun/wrapper.js @@ -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_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({ type: "Model", modelURL: MODEL_URL, @@ -28,6 +28,7 @@ PingPingGun = function(spawnPosition, spawnRotation) { y: 0.3875, z: 0.9931 }, + rotation:Quat.fromPitchYawRollDegrees(spawnRotation.x,spawnRotation.y,spawnRotation.z), dynamic: true, collisionSoundURL: COLLISION_SOUND_URL, userData: JSON.stringify({ @@ -61,7 +62,9 @@ PingPingGun = function(spawnPosition, spawnRotation) { }) }); - function cleanUp() { + function cleanup() { Entities.deleteEntity(pingPongGun); } + + this.cleanup = cleanup; } \ No newline at end of file diff --git a/unpublishedScripts/DomainContent/Home/reset.js b/unpublishedScripts/DomainContent/Home/reset.js index d2684b4b16..b3eebd887a 100644 --- a/unpublishedScripts/DomainContent/Home/reset.js +++ b/unpublishedScripts/DomainContent/Home/reset.js @@ -31,7 +31,7 @@ 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()); @@ -109,6 +109,7 @@ Script.include(tiltMazePath); Script.include(whiteboardPath); Script.include(plantPath); + Script.include(pingPongGunPath); var fishTank = new FishTank({ x: 1098.9254, @@ -128,21 +129,31 @@ 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, y: 460.2328, z: -65.8513 + }, { + x: 97.3683, + y: 179.0293, + z: 89.9698 }); - dynamicEntities.push(pingPongGun); + + dynamicEntities.push(fishTank); dynamicEntities.push(tiltMaze); dynamicEntities.push(whiteboard); - // dynamicEntities.push(myPlant); + dynamicEntities.push(myPlant); //v2.0 + dynamicEntities.push(pingPongGun); // var musicBox = new MusicBox(); // var cuckooClock = new CuckooClock(); @@ -211,11 +222,13 @@ y: 459.7251, z: -79.8097 }); + var trashcan = new Trashcan({ x: 1104.0031, y: 459.4355, z: -82.7294 }); + var books = new Books({ x: 1101.2123, y: 460.2328, diff --git a/unpublishedScripts/DomainContent/Home/whiteboard/wrapper.js b/unpublishedScripts/DomainContent/Home/whiteboard/wrapper.js index 5079f51aa4..8e839c3ffb 100644 --- a/unpublishedScripts/DomainContent/Home/whiteboard/wrapper.js +++ b/unpublishedScripts/DomainContent/Home/whiteboard/wrapper.js @@ -33,7 +33,7 @@ Whiteboard = function(spawnPosition, spawnRotation) { 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_COLLISION_HULL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/whiteboardCollisionHull.obj"; 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 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))); 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", ]; - 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, { red: 10,