From c81f3256ddc2d9376dd134bc531af38ca09a7c68 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Fri, 26 Feb 2016 10:58:22 -0800 Subject: [PATCH] rotation --- .../whiteboardV2/eraserEntityScript.js | 26 +++++++++++++++---- .../whiteboardV2/markerEntityScript.js | 2 +- .../whiteboardV2/whiteboardSpawner.js | 10 +++---- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/examples/homeContent/whiteboardV2/eraserEntityScript.js b/examples/homeContent/whiteboardV2/eraserEntityScript.js index da67288829..86e80659bf 100644 --- a/examples/homeContent/whiteboardV2/eraserEntityScript.js +++ b/examples/homeContent/whiteboardV2/eraserEntityScript.js @@ -32,9 +32,11 @@ _this.equipped = true; _this.hand = params[0] == "left" ? 0 : 1; // We really only need to grab position of marker strokes once, and then just check to see if eraser comes near enough to those strokes - + Overlays.editOverlay(_this.searchSphere, {visible: true}); }, continueEquip: function() { + _this.eraserPosition = Entities.getEntityProperties(_this.entityID, "position").position; + Overlays.editOverlay(_this.searchSphere, {position: _this.eraserPosition}); this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[_this.hand]); if (_this.triggerValue > _this.ERASER_TRIGGER_THRESHOLD) { _this.continueHolding(); @@ -43,22 +45,36 @@ continueHolding: function() { - var eraserPosition = Entities.getEntityProperties(_this.entityID, "position").position; - var strokeIDs = Entities.findEntities(eraserPosition, _this.ERASER_TO_STROKE_SEARCH_RADIUS); + var strokeIDs = Entities.findEntities(_this.eraserPosition, _this.ERASER_TO_STROKE_SEARCH_RADIUS); // Create a map of stroke entities and their positions strokeIDs.forEach(function(strokeID) { var strokeProps = Entities.getEntityProperties(strokeID, ["position", "name"]); - if (strokeProps.name === _this.STROKE_NAME && Vec3.distance(eraserPosition, strokeProps.position) < _this.ERASER_TO_STROKE_SEARCH_RADIUS) { + if (strokeProps.name === _this.STROKE_NAME && Vec3.distance(_this.eraserPosition, strokeProps.position) < _this.ERASER_TO_STROKE_SEARCH_RADIUS) { Entities.deleteEntity(strokeID); } }); }, + releaseEquip: function() { + Overlays.editOverlay(_this.searchSphere, {visible: false}); + }, + preload: function(entityID) { - this.entityID = entityID; + _this.entityID = entityID; + _this.searchSphere = Overlays.addOverlay('sphere', { + size: _this.ERASER_TO_STROKE_SEARCH_RADIUS, + color: {red: 200, green: 10, blue: 10}, + alpha: 0.2, + solid: true, + visible: false + }) }, + + unload: function() { + Overlays.deleteOverlay(_this.searchSphere); + } }; // entity scripts always need to return a newly constructed object of our type diff --git a/examples/homeContent/whiteboardV2/markerEntityScript.js b/examples/homeContent/whiteboardV2/markerEntityScript.js index e6f7e3cf81..e379fac016 100644 --- a/examples/homeContent/whiteboardV2/markerEntityScript.js +++ b/examples/homeContent/whiteboardV2/markerEntityScript.js @@ -73,7 +73,7 @@ } var intersection = Entities.findRayIntersectionBlocking(pickRay, true, _this.whiteboards); if (intersection.intersects && Vec3.distance(intersection.intersection, markerProps.position) < _this.MAX_MARKER_TO_BOARD_DISTANCE) { - _this.whiteboardNormal = Quat.getFront(intersection.properties.rotation); + _this.whiteboardNormal = Quat.getRight(intersection.properties.rotation); Overlays.editOverlay(_this.laserPointer, { visible: true, position: intersection.intersection, diff --git a/examples/homeContent/whiteboardV2/whiteboardSpawner.js b/examples/homeContent/whiteboardV2/whiteboardSpawner.js index 6689672095..8826c8387a 100644 --- a/examples/homeContent/whiteboardV2/whiteboardSpawner.js +++ b/examples/homeContent/whiteboardV2/whiteboardSpawner.js @@ -31,7 +31,7 @@ var markers = []; var whiteboardPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(orientation))); -var WHITEBOARD_MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Whiteboard-3+(1).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 = Entities.addEntity({ type: "Model", @@ -69,7 +69,7 @@ var whiteboardDrawingSurface = Entities.addEntity({ }, position: whiteboardSurfacePosition, rotation: whiteboardRotation, - visible: false, + // visible: false, parentID: whiteboard }); @@ -78,8 +78,8 @@ var WHITEBOARD_RACK_DEPTH = 1.9; var ERASER_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/eraser-2.fbx"; var ERASER_SCRIPT_URL = Script.resolvePath("eraserEntityScript.js"); -var eraserPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(WHITEBOARD_RACK_DEPTH, Quat.getFront(orientation))); -eraserPosition = Vec3.sum(eraserPosition, Vec3.multiply(-0.5, Quat.getFront(whiteboardRotation))); +var eraserPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(WHITEBOARD_RACK_DEPTH, Quat.getFront(whiteboardRotation))); +eraserPosition = Vec3.sum(eraserPosition, Vec3.multiply(-0.5, Quat.getRight(whiteboardRotation))); var eraser = Entities.addEntity({ type: "Model", @@ -92,7 +92,7 @@ var eraser = Entities.addEntity({ y: 0.0393, z: 0.2083 }, - rotation: whiteboardRotation, + rotation: markerRotation, dynamic: true, gravity: { x: 0,