mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:18:52 +02:00
marker only draws when equipped and held down
This commit is contained in:
parent
69dc9ef68f
commit
b5ec79fd6d
1 changed files with 19 additions and 12 deletions
|
@ -13,9 +13,12 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
var TRIGGER_CONTROLS = [
|
||||||
|
Controller.Standard.LT,
|
||||||
|
Controller.Standard.RT,
|
||||||
|
];
|
||||||
var MAX_POINTS_PER_STROKE = 40;
|
var MAX_POINTS_PER_STROKE = 40;
|
||||||
var _this;
|
var _this;
|
||||||
MarkerTip = function() {
|
MarkerTip = function() {
|
||||||
_this = this;
|
_this = this;
|
||||||
_this.MARKER_TEXTURE_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/textures/markerStroke.png";
|
_this.MARKER_TEXTURE_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/textures/markerStroke.png";
|
||||||
|
@ -30,21 +33,25 @@ var _this;
|
||||||
|
|
||||||
MarkerTip.prototype = {
|
MarkerTip.prototype = {
|
||||||
|
|
||||||
continueNearGrab: function() {
|
startEquip: function(id, params) {
|
||||||
|
_this.equipped = true;
|
||||||
_this.continueHolding();
|
_this.hand = params[0] == "left" ? 0 : 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
continueEquip: function() {
|
continueEquip: function() {
|
||||||
_this.continueHolding();
|
this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[_this.hand]);
|
||||||
|
if (_this.triggerValue > 0.2) {
|
||||||
|
print("EBL PAINZT");
|
||||||
|
_this.continueHolding();
|
||||||
|
} else {
|
||||||
|
_this.currentStroke = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
continueHolding: function() {
|
continueHolding: function() {
|
||||||
// cast a ray from marker and see if it hits anything
|
// cast a ray from marker and see if it hits anything
|
||||||
|
|
||||||
var markerProps = Entities.getEntityProperties(_this.entityID, ["position", "rotation"]);
|
var markerProps = Entities.getEntityProperties(_this.entityID, ["position", "rotation"]);
|
||||||
|
|
||||||
|
|
||||||
var pickRay = {
|
var pickRay = {
|
||||||
origin: markerProps.position,
|
origin: markerProps.position,
|
||||||
direction: Quat.getFront(markerProps.rotation)
|
direction: Quat.getFront(markerProps.rotation)
|
||||||
|
@ -87,7 +94,7 @@ var _this;
|
||||||
if (_this.oldPosition) {
|
if (_this.oldPosition) {
|
||||||
basePosition = _this.oldPosition;
|
basePosition = _this.oldPosition;
|
||||||
}
|
}
|
||||||
_this.newStroke(basePosition);
|
_this.newStroke(basePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
var localPoint = Vec3.subtract(basePosition, this.strokeBasePosition);
|
var localPoint = Vec3.subtract(basePosition, this.strokeBasePosition);
|
||||||
|
@ -95,7 +102,7 @@ var _this;
|
||||||
// _this.strokeForwardOffset += _this.STROKE_FORWARD_OFFSET_INCRERMENT;
|
// _this.strokeForwardOffset += _this.STROKE_FORWARD_OFFSET_INCRERMENT;
|
||||||
|
|
||||||
if (_this.linePoints.length > 0) {
|
if (_this.linePoints.length > 0) {
|
||||||
var distance = Vec3.distance(localPoint, _this.linePoints[_this.linePoints.length-1]);
|
var distance = Vec3.distance(localPoint, _this.linePoints[_this.linePoints.length - 1]);
|
||||||
if (distance < _this.MIN_DISTANCE_BETWEEN_POINTS) {
|
if (distance < _this.MIN_DISTANCE_BETWEEN_POINTS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +126,7 @@ var _this;
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setProperties: function(myId, data) {
|
setProperties: function(myId, data) {
|
||||||
|
|
Loading…
Reference in a new issue