mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 02:42:52 +02:00
can erase any stroke at any time
This commit is contained in:
parent
ddae2d4f74
commit
24bf4f851f
1 changed files with 13 additions and 29 deletions
|
@ -24,7 +24,6 @@
|
||||||
_this.ERASER_TRIGGER_THRESHOLD = 0.2;
|
_this.ERASER_TRIGGER_THRESHOLD = 0.2;
|
||||||
_this.STROKE_NAME = "hifi-marker-stroke";
|
_this.STROKE_NAME = "hifi-marker-stroke";
|
||||||
_this.ERASER_TO_STROKE_SEARCH_RADIUS = 0.7;
|
_this.ERASER_TO_STROKE_SEARCH_RADIUS = 0.7;
|
||||||
_this.strokeMap = [];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Eraser.prototype = {
|
Eraser.prototype = {
|
||||||
|
@ -33,43 +32,28 @@
|
||||||
_this.equipped = true;
|
_this.equipped = true;
|
||||||
_this.hand = params[0] == "left" ? 0 : 1;
|
_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
|
// 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
|
||||||
|
|
||||||
|
},
|
||||||
|
continueEquip: function() {
|
||||||
|
this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[_this.hand]);
|
||||||
|
if (_this.triggerValue > _this.ERASER_TRIGGER_THRESHOLD) {
|
||||||
|
_this.continueHolding();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
continueHolding: function() {
|
||||||
var eraserPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
var eraserPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||||
var strokeIDs = Entities.findEntities(eraserPosition, _this.ERASER_TO_STROKE_SEARCH_RADIUS);
|
var strokeIDs = Entities.findEntities(eraserPosition, _this.ERASER_TO_STROKE_SEARCH_RADIUS);
|
||||||
// Create a map of stroke entities and their positions
|
// Create a map of stroke entities and their positions
|
||||||
|
|
||||||
strokeIDs.forEach(function(strokeID) {
|
strokeIDs.forEach(function(strokeID) {
|
||||||
var strokeProps = Entities.getEntityProperties(strokeID, ["position", "name"]);
|
var strokeProps = Entities.getEntityProperties(strokeID, ["position", "name"]);
|
||||||
if (strokeProps.name === _this.STROKE_NAME) {
|
if (strokeProps.name === _this.STROKE_NAME && Vec3.distance(eraserPosition, strokeProps.position) < _this.ERASER_TO_STROKE_SEARCH_RADIUS) {
|
||||||
_this.strokeMap.push({
|
Entities.deleteEntity(strokeID);
|
||||||
strokeID: strokeID,
|
|
||||||
strokePosition: strokeProps.position
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
continueEquip: function() {
|
|
||||||
this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[_this.hand]);
|
|
||||||
if (_this.triggerValue > _this.ERASER_TRIGGER_THRESHOLD) {
|
|
||||||
_this.continueHolding();
|
|
||||||
} else {}
|
|
||||||
},
|
|
||||||
|
|
||||||
releaseEquip: function() {
|
|
||||||
_this.strokeMap = [];
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
continueHolding: function() {
|
|
||||||
// search for marker strokes within certain radius of eraser
|
|
||||||
var eraserPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
|
||||||
_this.strokeMap.forEach(function(strokeData, index) {
|
|
||||||
if (Vec3.distance(eraserPosition, strokeData.strokePosition) < _this.ERASER_TO_STROKE_SEARCH_RADIUS) {
|
|
||||||
Entities.deleteEntity(strokeData.strokeID);
|
|
||||||
_this.strokeMap.splice(index, 1);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
|
|
Loading…
Reference in a new issue