mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:47:30 +02:00
update javascript to use relative-to-entity line-point ends
This commit is contained in:
parent
a24fd13665
commit
d44bb1a0d8
1 changed files with 41 additions and 56 deletions
|
@ -65,70 +65,55 @@ function removeLine() {
|
||||||
|
|
||||||
|
|
||||||
function createOrUpdateLine(event) {
|
function createOrUpdateLine(event) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking
|
var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking
|
||||||
var props = Entities.getEntityProperties(intersection.entityID);
|
var props = Entities.getEntityProperties(intersection.entityID);
|
||||||
|
|
||||||
if (intersection.intersects && userCanPoint) {
|
if (intersection.intersects && userCanPoint) {
|
||||||
var points = [nearLinePoint(intersection.intersection), intersection.intersection]
|
var points = [Vec3.subtract(nearLinePoint(intersection.intersection), MyAvatar.position),
|
||||||
if (lineIsRezzed) {
|
Vec3.subtract(intersection.intersection, MyAvatar.position)];
|
||||||
Entities.editEntity(lineEntityID, {
|
if (lineIsRezzed) {
|
||||||
position: nearLinePoint(intersection.intersection),
|
Entities.editEntity(lineEntityID, {
|
||||||
linePoints: points,
|
linePoints: points,
|
||||||
dimensions: {
|
position: MyAvatar.position,
|
||||||
x: 1,
|
lifetime: 15 + props.lifespan // renew lifetime
|
||||||
y: 1,
|
});
|
||||||
z: 1
|
// Entities.setAllPoints(lineEntityID, points);
|
||||||
},
|
} else {
|
||||||
lifetime: 15 + props.lifespan // renew lifetime
|
lineIsRezzed = true;
|
||||||
});
|
lineEntityID = Entities.addEntity({
|
||||||
|
type: "Line",
|
||||||
|
position: MyAvatar.position,
|
||||||
|
linePoints: points,
|
||||||
|
dimensions: { x: 100, y: 100, z: 100 },
|
||||||
|
color: { red: 255, green: 255, blue: 255 },
|
||||||
|
lifetime: 15 // if someone crashes while pointing, don't leave the line there forever.
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
lineIsRezzed = true;
|
removeLine();
|
||||||
lineEntityID = Entities.addEntity({
|
|
||||||
type: "Line",
|
|
||||||
position: nearLinePoint(intersection.intersection),
|
|
||||||
linePoints: points,
|
|
||||||
dimensions: {
|
|
||||||
x: 1,
|
|
||||||
y: 1,
|
|
||||||
z: 1
|
|
||||||
},
|
|
||||||
color: {
|
|
||||||
red: 255,
|
|
||||||
green: 255,
|
|
||||||
blue: 255
|
|
||||||
},
|
|
||||||
lifetime: 15 // if someone crashes while pointing, don't leave the line there forever.
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
removeLine();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
if (!event.isLeftButton) {
|
if (!event.isLeftButton) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
createOrUpdateLine(event);
|
var clickedOverlay = Overlays.getOverlayAtPoint({
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({
|
x: event.x,
|
||||||
x: event.x,
|
y: event.y
|
||||||
y: event.y
|
});
|
||||||
});
|
|
||||||
if (clickedOverlay == pointerButton) {
|
if (clickedOverlay == pointerButton) {
|
||||||
userCanPoint = !userCanPoint;
|
userCanPoint = !userCanPoint;
|
||||||
if (userCanPoint === true) {
|
if (userCanPoint === true) {
|
||||||
Overlays.editOverlay(pointerButton, {
|
Overlays.editOverlay(pointerButton, { color: buttonOnColor });
|
||||||
color: buttonOnColor
|
} else {
|
||||||
});
|
Overlays.editOverlay(pointerButton, { color: buttonOffColor });
|
||||||
} else {
|
}
|
||||||
Overlays.editOverlay(pointerButton, {
|
|
||||||
color: buttonOffColor
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue