mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 18:56:55 +02:00
updated whiteboard to use new controller approach'
This commit is contained in:
parent
eecb5b91b2
commit
08a64f6a6b
1 changed files with 12 additions and 7 deletions
|
@ -20,7 +20,7 @@
|
||||||
var _this;
|
var _this;
|
||||||
var RIGHT_HAND = 1;
|
var RIGHT_HAND = 1;
|
||||||
var LEFT_HAND = 0;
|
var LEFT_HAND = 0;
|
||||||
var MIN_POINT_DISTANCE = 0.01 ;
|
var MIN_POINT_DISTANCE = 0.01;
|
||||||
var MAX_POINT_DISTANCE = 0.5;
|
var MAX_POINT_DISTANCE = 0.5;
|
||||||
var MAX_POINTS_PER_LINE = 40;
|
var MAX_POINTS_PER_LINE = 40;
|
||||||
var MAX_DISTANCE = 5;
|
var MAX_DISTANCE = 5;
|
||||||
|
@ -29,6 +29,11 @@
|
||||||
var MIN_STROKE_WIDTH = 0.0005;
|
var MIN_STROKE_WIDTH = 0.0005;
|
||||||
var MAX_STROKE_WIDTH = 0.03;
|
var MAX_STROKE_WIDTH = 0.03;
|
||||||
|
|
||||||
|
var TRIGGER_CONTROLS = [
|
||||||
|
Controller.Standard.LT,
|
||||||
|
Controller.Standard.RT,
|
||||||
|
];
|
||||||
|
|
||||||
Whiteboard = function() {
|
Whiteboard = function() {
|
||||||
_this = this;
|
_this = this;
|
||||||
};
|
};
|
||||||
|
@ -51,11 +56,9 @@
|
||||||
if (this.hand === RIGHT_HAND) {
|
if (this.hand === RIGHT_HAND) {
|
||||||
this.getHandPosition = MyAvatar.getRightPalmPosition;
|
this.getHandPosition = MyAvatar.getRightPalmPosition;
|
||||||
this.getHandRotation = MyAvatar.getRightPalmRotation;
|
this.getHandRotation = MyAvatar.getRightPalmRotation;
|
||||||
this.triggerAction = Controller.findAction("RIGHT_HAND_CLICK");
|
|
||||||
} else if (this.hand === LEFT_HAND) {
|
} else if (this.hand === LEFT_HAND) {
|
||||||
this.getHandPosition = MyAvatar.getLeftPalmPosition;
|
this.getHandPosition = MyAvatar.getLeftPalmPosition;
|
||||||
this.getHandRotation = MyAvatar.getLeftPalmRotation;
|
this.getHandRotation = MyAvatar.getLeftPalmRotation;
|
||||||
this.triggerAction = Controller.findAction("LEFT_HAND_CLICK");
|
|
||||||
}
|
}
|
||||||
Overlays.editOverlay(this.laserPointer, {
|
Overlays.editOverlay(this.laserPointer, {
|
||||||
visible: true
|
visible: true
|
||||||
|
@ -76,7 +79,7 @@
|
||||||
if (this.intersection.intersects) {
|
if (this.intersection.intersects) {
|
||||||
var distance = Vec3.distance(handPosition, this.intersection.intersection);
|
var distance = Vec3.distance(handPosition, this.intersection.intersection);
|
||||||
if (distance < MAX_DISTANCE) {
|
if (distance < MAX_DISTANCE) {
|
||||||
this.triggerValue = Controller.getActionValue(this.triggerAction);
|
this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[this.hand]);
|
||||||
this.currentStrokeWidth = map(this.triggerValue, 0, 1, MIN_STROKE_WIDTH, MAX_STROKE_WIDTH);
|
this.currentStrokeWidth = map(this.triggerValue, 0, 1, MIN_STROKE_WIDTH, MAX_STROKE_WIDTH);
|
||||||
var displayPoint = this.intersection.intersection;
|
var displayPoint = this.intersection.intersection;
|
||||||
displayPoint = Vec3.sum(displayPoint, Vec3.multiply(this.normal, 0.01));
|
displayPoint = Vec3.sum(displayPoint, Vec3.multiply(this.normal, 0.01));
|
||||||
|
@ -87,7 +90,9 @@
|
||||||
y: this.currentStrokeWidth
|
y: this.currentStrokeWidth
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
print("TRIGGER VALUE " + this.triggerValue);
|
||||||
if (this.triggerValue > PAINT_TRIGGER_THRESHOLD) {
|
if (this.triggerValue > PAINT_TRIGGER_THRESHOLD) {
|
||||||
|
print("PAINT")
|
||||||
this.paint(this.intersection.intersection, this.intersection.surfaceNormal);
|
this.paint(this.intersection.intersection, this.intersection.surfaceNormal);
|
||||||
} else {
|
} else {
|
||||||
this.painting = false;
|
this.painting = false;
|
||||||
|
@ -184,7 +189,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
stopFarTrigger: function() {
|
stopFarTrigger: function() {
|
||||||
if(this.hand !== this.whichHand) {
|
if (this.hand !== this.whichHand) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.stopPainting();
|
this.stopPainting();
|
||||||
|
@ -209,7 +214,7 @@
|
||||||
entities.forEach(function(entity) {
|
entities.forEach(function(entity) {
|
||||||
var props = Entities.getEntityProperties(entity, ["name, userData"]);
|
var props = Entities.getEntityProperties(entity, ["name, userData"]);
|
||||||
var name = props.name;
|
var name = props.name;
|
||||||
if(!props.userData) {
|
if (!props.userData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var whiteboardID = JSON.parse(props.userData).whiteboard;
|
var whiteboardID = JSON.parse(props.userData).whiteboard;
|
||||||
|
@ -249,4 +254,4 @@
|
||||||
|
|
||||||
// entity scripts always need to return a newly constructed object of our type
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
return new Whiteboard();
|
return new Whiteboard();
|
||||||
});
|
});
|
Loading…
Reference in a new issue