From 6d3a3b0cc5c0039fa0ca1fbb569b557c0c7b89df Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 5 May 2016 10:37:32 -0700 Subject: [PATCH] cleanup comments, semicolons --- .../Home/dressingRoom/transformer.js | 45 +++++++++---------- .../Home/dressingRoom/wrapper.js | 11 +++-- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/unpublishedScripts/DomainContent/Home/dressingRoom/transformer.js b/unpublishedScripts/DomainContent/Home/dressingRoom/transformer.js index df8fdf0644..78caec3d80 100644 --- a/unpublishedScripts/DomainContent/Home/dressingRoom/transformer.js +++ b/unpublishedScripts/DomainContent/Home/dressingRoom/transformer.js @@ -25,14 +25,15 @@ x: 1.8838, y: 1.7865, z: 0.2955 - } + }; var ROBOT_DIMENSIONS = { //robot x: 1.4439, y: 0.6224, z: 0.4998 - } + }; + var WILL_DIMENSIONS = { x: 1.6326, y: 1.6764, @@ -51,14 +52,14 @@ x: 1.8722, y: 1.8197, z: 0.3666 - } + }; var _this; function Transformer() { _this = this; return this; - } + }; Transformer.prototype = { locked: false, @@ -74,11 +75,11 @@ var otherProps = Entities.getEntityProperties(otherID); if (otherProps.name === "hifi-home-dressing-room-transformer-collider" && _this.locked === false) { - print('UNLOCKED TRANSFORMER COLLIDED WITH BASE!! THE AVATAR WHO SIMULATED THIS COLLISION IS:: ' + MyAvatar.sessionUUID); _this.locked = true; _this.findRotatorBlock(); } else { var transformerProps = Entities.getEntityProperties(_this.entityID, ["rotation", "position"]); + var eulerRotation = Quat.safeEulerAngles(transformerProps.rotation); eulerRotation.x = 0; eulerRotation.z = 0; @@ -98,14 +99,15 @@ z: 0 } }); + return; } }, findRotatorBlock: function() { - print('transformer should find rotator block') var myProps = Entities.getEntityProperties(_this.entityID); var results = Entities.findEntities(myProps.position, 10); + results.forEach(function(result) { var resultProps = Entities.getEntityProperties(result); if (resultProps.name === "hifi-home-dressing-room-rotator-block") { @@ -117,10 +119,10 @@ }, removeCurrentBigVersion: function(rotatorBlock) { - print('transformer should remove big version') var blacklistKey = 'Hifi-Hand-RayPick-Blacklist'; var myProps = Entities.getEntityProperties(_this.entityID); var results = Entities.findEntities(myProps.position, 10); + results.forEach(function(result) { var resultProps = Entities.getEntityProperties(result); if (resultProps.name === "hifi-home-dressing-room-big-transformer") { @@ -134,36 +136,35 @@ return; } }); + _this.createBigVersion(); }, createBigVersion: function() { var smallProps = Entities.getEntityProperties(_this.entityID); - print('transformer should create big version!!' + smallProps.modelURL); - print('transformer has rotatorBlock??' + _this.rotatorBlock); var rotatorProps = Entities.getEntityProperties(_this.rotatorBlock); var dimensions; if (smallProps.modelURL.indexOf('will') > -1) { - print('TRANSFORMER IS WILL') + // print('TRANSFORMER IS WILL'); dimensions = WILL_DIMENSIONS; } else if (smallProps.modelURL.indexOf('being_of_light') > -1) { - print('TRANSFORMER IS BEING OF LIGHT') + // print('TRANSFORMER IS BEING OF LIGHT'); dimensions = BEING_OF_LIGHT_DIMENSIONS; } else if (smallProps.modelURL.indexOf('stylized_female') > -1) { - print('TRANSFORMER IS ARTEMIS') + // print('TRANSFORMER IS ARTEMIS'); dimensions = STYLIZED_FEMALE_DIMENSIONS; } else if (smallProps.modelURL.indexOf('simple_robot') > -1) { - print('TRANSFORMER IS A ROBOT') + // print('TRANSFORMER IS A ROBOT'); dimensions = ROBOT_DIMENSIONS; } else if (smallProps.modelURL.indexOf('priscilla') > -1) { - print('TRANSFORMER IS PRISCILLA') + // print('TRANSFORMER IS PRISCILLA'); dimensions = PRISCILLA_DIMENSIONS; } else if (smallProps.modelURL.indexOf('matthew') > -1) { - print('TRANSFORMER IS MATTHEW') + // print('TRANSFORMER IS MATTHEW'); dimensions = MATTHEW_DIMENSIONS; } else { - print('TRANSFORMER IS SOME OTHER'); + // print('TRANSFORMER IS SOME OTHER'); dimensions = smallProps.naturalDimensions; } @@ -183,14 +184,13 @@ 'reset': true } }), - } + }; if (bigVersionProps.modelURL.indexOf('simple_robot') > -1) { bigVersionProps.position.y += 0.5; } var bigVersion = Entities.addEntity(bigVersionProps); - print('transformer created big version: ' + bigVersion); var blacklistKey = 'Hifi-Hand-RayPick-Blacklist'; Messages.sendMessage(blacklistKey, JSON.stringify({ @@ -202,12 +202,10 @@ }, putTransformerOnRotatorBlock: function(blockPosition) { - print('transformer should get set on rotator block') - return blockPosition + return blockPosition; }, putNewVersionOnShelf: function() { - print('transformer should out a new version of itself on the shelf') var littleVersionProps = Entities.getEntityProperties(_this.entityID); delete littleVersionProps.id; delete littleVersionProps.created; @@ -218,23 +216,24 @@ delete littleVersionProps.localPosition; delete littleVersionProps.localRotation; delete littleVersionProps.naturalPosition; - // delete littleVersionProps.script; littleVersionProps.gravity = { x: 0, y: -10, z: 0 }; var userData = JSON.parse(littleVersionProps.userData); + var basePosition = userData["hifiHomeTransformerKey"].basePosition; var baseRotation = userData["hifiHomeTransformerKey"].baseRotation; + littleVersionProps.position = basePosition; littleVersionProps.rotation = baseRotation; var littleTransformer = Entities.addEntity(littleVersionProps); + _this.removeSelf(); }, removeSelf: function() { - print('transformer should remove itself') var success = Entities.deleteEntity(_this.entityID); }, }; diff --git a/unpublishedScripts/DomainContent/Home/dressingRoom/wrapper.js b/unpublishedScripts/DomainContent/Home/dressingRoom/wrapper.js index 570b326183..4b2793966a 100644 --- a/unpublishedScripts/DomainContent/Home/dressingRoom/wrapper.js +++ b/unpublishedScripts/DomainContent/Home/dressingRoom/wrapper.js @@ -13,8 +13,9 @@ var TRANSFORMER_SCRIPT = Script.resolvePath('transformer.js'); var AVATAR_COLLISION_HULL = 'atp:/dressingRoom/Avatar-Hull-6.obj'; var ROBOT_COLLISION_HULL = 'atp:/dressingRoom/robot_hull.obj'; + TransformerDoll = function(modelURL, spawnPosition, spawnRotation, dimensions) { - print('SCRIPT REF AT TRANSFORMER CREATE::' + TRANSFORMER_SCRIPT); + var transformerProps = { name: 'hifi-home-dressing-room-little-transformer', type: 'Model', @@ -48,15 +49,13 @@ TransformerDoll = function(modelURL, spawnPosition, spawnRotation, dimensions) { density: 7500, dimensions: dimensions, script: TRANSFORMER_SCRIPT - } + }; if (modelURL.indexOf('robot') > -1) { - print('THIS IS A ROBOT, GIVE IT A DIFFERENT SHAPE TYPE') - transformerProps.compoundShapeURL =ROBOT_COLLISION_HULL; + transformerProps.compoundShapeURL = ROBOT_COLLISION_HULL; } - var transformer = Entities.addEntity(transformerProps); - print('CREATED TRANSFORMER' + transformer); + var transformer = Entities.addEntity(transformerProps); return this; } \ No newline at end of file