mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
rotation
This commit is contained in:
parent
25a2d1eb93
commit
c81f3256dd
3 changed files with 27 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue