mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 20:33:09 +02:00
should work multiuser now
This commit is contained in:
parent
24bf4f851f
commit
668894b3e0
2 changed files with 34 additions and 40 deletions
|
@ -23,22 +23,34 @@
|
||||||
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";
|
||||||
this.strokeForwardOffset = 0.0001;
|
_this.strokeForwardOffset = 0.0001;
|
||||||
this.STROKE_FORWARD_OFFSET_INCRERMENT = 0.00001;
|
_this.STROKE_FORWARD_OFFSET_INCRERMENT = 0.00001;
|
||||||
this.STROKE_WIDTH = 0.003
|
_this.STROKE_WIDTH = 0.003
|
||||||
_this.MAX_MARKER_TO_BOARD_DISTANCE = 1.4;
|
_this.MAX_MARKER_TO_BOARD_DISTANCE = 1.4;
|
||||||
_this.MIN_DISTANCE_BETWEEN_POINTS = 0.002;
|
_this.MIN_DISTANCE_BETWEEN_POINTS = 0.002;
|
||||||
_this.MAX_DISTANCE_BETWEEN_POINTS = 0.1;
|
_this.MAX_DISTANCE_BETWEEN_POINTS = 0.1;
|
||||||
_this.strokes = [];
|
_this.strokes = [];
|
||||||
_this.PAINTING_TRIGGER_THRESHOLD = 0.2;
|
_this.PAINTING_TRIGGER_THRESHOLD = 0.2;
|
||||||
this.STROKE_NAME = "hifi-marker-stroke";
|
_this.STROKE_NAME = "hifi-marker-stroke";
|
||||||
|
_this.WHITEBOARD_SURFACE_NAME = "hifi-whiteboardDrawingSurface";
|
||||||
};
|
};
|
||||||
|
|
||||||
MarkerTip.prototype = {
|
MarkerTip.prototype = {
|
||||||
|
|
||||||
startEquip: function(id, params) {
|
startEquip: function(id, params) {
|
||||||
|
_this.whiteboards = [];
|
||||||
_this.equipped = true;
|
_this.equipped = true;
|
||||||
_this.hand = params[0] == "left" ? 0 : 1;
|
_this.hand = params[0] == "left" ? 0 : 1;
|
||||||
|
_this.markerColor = getEntityUserData(_this.entityID).markerColor;
|
||||||
|
// search for whiteboards
|
||||||
|
var markerPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||||
|
var entities = Entities.findEntities(markerPosition, 10);
|
||||||
|
entities.forEach(function(entity) {
|
||||||
|
var entityName = Entities.getEntityProperties(entity, "name").name;
|
||||||
|
if (entityName === _this.WHITEBOARD_SURFACE_NAME) {
|
||||||
|
_this.whiteboards.push(entity);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseEquip: function() {
|
releaseEquip: function() {
|
||||||
|
@ -57,12 +69,14 @@
|
||||||
origin: markerProps.position,
|
origin: markerProps.position,
|
||||||
direction: Quat.getFront(markerProps.rotation)
|
direction: Quat.getFront(markerProps.rotation)
|
||||||
}
|
}
|
||||||
var intersection = Entities.findRayIntersectionBlocking(pickRay, true, [_this.whiteboard]);
|
var intersection = Entities.findRayIntersectionBlocking(pickRay, true, _this.whiteboards);
|
||||||
|
_this.whiteboardNormal = Quat.getFront(intersection.properties.rotation);
|
||||||
if (intersection.intersects && Vec3.distance(intersection.intersection, markerProps.position) < _this.MAX_MARKER_TO_BOARD_DISTANCE) {
|
if (intersection.intersects && Vec3.distance(intersection.intersection, markerProps.position) < _this.MAX_MARKER_TO_BOARD_DISTANCE) {
|
||||||
|
print("EBL HIT")
|
||||||
Overlays.editOverlay(_this.laserPointer, {
|
Overlays.editOverlay(_this.laserPointer, {
|
||||||
visible: true,
|
visible: true,
|
||||||
position: intersection.intersection
|
position: intersection.intersection,
|
||||||
|
rotation: intersection.properties.rotation
|
||||||
})
|
})
|
||||||
_this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[_this.hand]);
|
_this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[_this.hand]);
|
||||||
if (_this.triggerValue > _this.PAINTING_TRIGGER_THRESHOLD) {
|
if (_this.triggerValue > _this.PAINTING_TRIGGER_THRESHOLD) {
|
||||||
|
@ -71,8 +85,8 @@
|
||||||
_this.resetStroke();
|
_this.resetStroke();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_this.resetStroke();
|
_this.resetStroke();
|
||||||
|
|
||||||
Overlays.editOverlay(_this.laserPointer, {
|
Overlays.editOverlay(_this.laserPointer, {
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
@ -145,22 +159,6 @@
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
unload: function() {
|
|
||||||
Overlays.deleteOverlay(_this.laserPointer);
|
|
||||||
_this.strokes.forEach( function(stroke) {
|
|
||||||
Entities.deleteEntity(stroke);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
setProperties: function(myId, data) {
|
|
||||||
var data = JSON.parse(data);
|
|
||||||
|
|
||||||
_this.whiteboard = data.whiteboard;
|
|
||||||
var whiteboardProps = Entities.getEntityProperties(_this.whiteboard, ["rotation"]);
|
|
||||||
_this.whiteboardNormal = Quat.getFront(whiteboardProps.rotation);
|
|
||||||
_this.laserPointer = Overlays.addOverlay("circle3d", {
|
_this.laserPointer = Overlays.addOverlay("circle3d", {
|
||||||
color: {
|
color: {
|
||||||
red: 220,
|
red: 220,
|
||||||
|
@ -169,9 +167,15 @@
|
||||||
},
|
},
|
||||||
solid: true,
|
solid: true,
|
||||||
size: 0.01,
|
size: 0.01,
|
||||||
rotation: whiteboardProps.rotation
|
|
||||||
});
|
});
|
||||||
_this.markerColor = data.markerColor;
|
|
||||||
|
},
|
||||||
|
|
||||||
|
unload: function() {
|
||||||
|
Overlays.deleteOverlay(_this.laserPointer);
|
||||||
|
_this.strokes.forEach(function(stroke) {
|
||||||
|
Entities.deleteEntity(stroke);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ var whiteboardSurfacePosition = Vec3.sum(whiteboardPosition, {
|
||||||
whiteboardSurfacePosition = Vec3.sum(whiteboardSurfacePosition, Vec3.multiply(-0.02, Quat.getRight(orientation)));
|
whiteboardSurfacePosition = Vec3.sum(whiteboardSurfacePosition, Vec3.multiply(-0.02, Quat.getRight(orientation)));
|
||||||
var whiteboardDrawingSurface = Entities.addEntity({
|
var whiteboardDrawingSurface = Entities.addEntity({
|
||||||
type: "Box",
|
type: "Box",
|
||||||
name: "whiteboardDrawingSurface",
|
name: "hifi-whiteboardDrawingSurface",
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 1.82,
|
x: 1.82,
|
||||||
y: 1.8,
|
y: 1.8,
|
||||||
|
@ -166,7 +166,7 @@ function createMarkers() {
|
||||||
|
|
||||||
|
|
||||||
function createMarker(modelURL, markerPosition, markerColor) {
|
function createMarker(modelURL, markerPosition, markerColor) {
|
||||||
var MARKER_SCRIPT_URL = Script.resolvePath("markerEntityScript.js");
|
var MARKER_SCRIPT_URL = Script.resolvePath("markerEntityScript.js?v1" + Math.random());
|
||||||
var marker = Entities.addEntity({
|
var marker = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
modelURL: modelURL,
|
modelURL: modelURL,
|
||||||
|
@ -193,6 +193,7 @@ function createMarker(modelURL, markerPosition, markerColor) {
|
||||||
name: "marker",
|
name: "marker",
|
||||||
script: MARKER_SCRIPT_URL,
|
script: MARKER_SCRIPT_URL,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
|
markerColor: markerColor,
|
||||||
wearable: {
|
wearable: {
|
||||||
joints: {
|
joints: {
|
||||||
RightHand: [{
|
RightHand: [{
|
||||||
|
@ -222,17 +223,6 @@ function createMarker(modelURL, markerPosition, markerColor) {
|
||||||
|
|
||||||
markers.push(marker);
|
markers.push(marker);
|
||||||
|
|
||||||
Script.setTimeout(function() {
|
|
||||||
var data = {
|
|
||||||
whiteboard: whiteboardDrawingSurface,
|
|
||||||
markerColor: markerColor
|
|
||||||
}
|
|
||||||
var modelURL = Entities.getEntityProperties(marker, "modelURL").modelURL;
|
|
||||||
|
|
||||||
Entities.callEntityMethod(marker, "setProperties", [JSON.stringify(data)]);
|
|
||||||
}, 5000)
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue