From 355f25bb8f97d7503639ebb9bb6135c15f619e81 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 16 Feb 2016 17:25:56 -0800 Subject: [PATCH] updatez --- .../Home/tiltMaze/ballDetector.js | 16 ++--- .../Home/tiltMaze/createTiltMaze.js | 65 ++++++++++++++----- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/unpublishedScripts/DomainContent/Home/tiltMaze/ballDetector.js b/unpublishedScripts/DomainContent/Home/tiltMaze/ballDetector.js index 4c7e7b9653..37c3add03e 100644 --- a/unpublishedScripts/DomainContent/Home/tiltMaze/ballDetector.js +++ b/unpublishedScripts/DomainContent/Home/tiltMaze/ballDetector.js @@ -14,7 +14,7 @@ // (function() { - var _this; + var _this; function BallDetctor() { _this = this; @@ -22,15 +22,15 @@ } BallDetctor.prototype = { - enterEntity:function(){ - print('BALL ENTERED BALL DETECTOR!!') - }, - destroyBall:function(){ + enterEntity: function() { + print('BALL ENTERED BALL DETECTOR!!') + }, + destroyBall: function() { - } - createNewBall:function(){ + } + createNewBall: function() { - } + } }; return new BallDetctor(); diff --git a/unpublishedScripts/DomainContent/Home/tiltMaze/createTiltMaze.js b/unpublishedScripts/DomainContent/Home/tiltMaze/createTiltMaze.js index c96e2c1cdf..0905068511 100644 --- a/unpublishedScripts/DomainContent/Home/tiltMaze/createTiltMaze.js +++ b/unpublishedScripts/DomainContent/Home/tiltMaze/createTiltMaze.js @@ -1,6 +1,6 @@ var ball, ballDetector, tiltMaze; var MAZE_MODEL_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/tiltMaze/MAZE2.fbx"; - var MAZE_COLLISION_HULL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/tiltMaze/MAZE_COLLISION_HULL.obj"; + var MAZE_COLLISION_HULL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/tiltMaze/MAZE_COLLISION_HULL3.obj"; var BALL_DETECTOR_SCRIPT = Script.resolvePath('ballDetector.js?' + Math.random()) @@ -11,9 +11,9 @@ }; var BALL_DIMENSIONS = { - x: 0.1, - y: 0.1, - z: 0.1 + x: 0.025, + y: 0.025, + z: 0.025 } var BALL_COLOR = { red: 255, @@ -27,64 +27,97 @@ blue: 0 } + var center = Vec3.sum(Vec3.sum(MyAvatar.position, { + x: 0, + y: 0.5, + z: 0 + }), Vec3.multiply(1.5, Quat.getFront(Camera.getOrientation()))); + + var CLEANUP = true; var createBall = function(position) { + var mazeProps = Entities.getEntityProperties(tiltMaze); + var right = Quat.getRight(mazeProps.rotation); + var front = Quat.getFront(mazeProps.rotation); + var offset = { + x:0, + y:0.02, + z:0 + }; + + var finalOffset = Vec3.sum(offset,Vec3.multiply(right,-0.4)); + finalOffset = Vec3.sum(finalOffset,Vec3.multiply(front,-0.2)); + var properties = { - name: 'Hifi Tilt Maze Ball' + name: 'Hifi Tilt Maze Ball', type: 'Sphere', shapeType: 'sphere', dimensions: BALL_DIMENSIONS, color: BALL_COLOR, - position: position + position: Vec3.sum(position,finalOffset), dynamic: true, + collisionless:false, + damping:0.6, + }; ball = Entities.addEntity(properties); }; - var createBallSpawningAnchor: function() { + var createBallSpawningAnchor = function(position) { var properties = { - name: 'Hifi Tilt Maze Ball Detector' + name: 'Hifi Tilt Maze Ball Detector', parentID: tiltMaze, type: 'Box', + color: DEBUG_COLOR, dimensions: BALL_DETECTOR_DIMENSIONS, - position: position, - rotiation: rotation, + position: center, collisionless: true, + visible: true, script: BALL_DETECTOR_SCRIPT }; } var createBallDetector = function(position, rotation) { var properties = { - name: 'Hifi Tilt Maze Ball Detector' + name: 'Hifi Tilt Maze Ball Detector', parentID: tiltMaze, type: 'Box', + color: DEBUG_COLOR, dimensions: BALL_DETECTOR_DIMENSIONS, position: position, rotiation: rotation, collisionless: true, + visible: true, script: BALL_DETECTOR_SCRIPT }; ballDetector = Entities.addEntity(properties); }; - var createTiltMaze: function(position, rotation) { + var createTiltMaze = function(position) { var properties = { name: 'Hifi Tilt Maze', type: 'Model', + modelURL: MAZE_MODEL_URL, compoundShapeURL: MAZE_COLLISION_HULL, dimensions: MAZE_DIMENSIONS, position: position, - rotation: rotation, + rotation: Quat.fromPitchYawRollDegrees(0, 0, 180), dynamic: true, } tiltMaze = Entities.addEntity(properties) } var createAll = function() { - createTiltMaze(); + createTiltMaze(center); // createBallDetector(); - // createBall(); + createBall(center); } - createAll(); \ No newline at end of file + createAll(); + + if (CLEANUP === true) { + Script.scriptEnding.connect(function() { + Entities.deleteEntity(tiltMaze); + Entities.deleteEntity(ball); + }) + } \ No newline at end of file