mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:58:09 +02:00
Merge pull request #3026 from Atlante45/model_support_for_inspect_js
Model support for inspect js
This commit is contained in:
commit
e8a7c5dbb4
2 changed files with 57 additions and 16 deletions
|
@ -691,6 +691,10 @@ function rayPlaneIntersection(pickRay, point, normal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
|
if (altIsPressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mouseLastPosition = { x: event.x, y: event.y };
|
mouseLastPosition = { x: event.x, y: event.y };
|
||||||
modelSelected = false;
|
modelSelected = false;
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||||
|
@ -790,6 +794,10 @@ var oldModifier = 0;
|
||||||
var modifier = 0;
|
var modifier = 0;
|
||||||
var wasShifted = false;
|
var wasShifted = false;
|
||||||
function mouseMoveEvent(event) {
|
function mouseMoveEvent(event) {
|
||||||
|
if (altIsPressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
|
||||||
if (!modelSelected) {
|
if (!modelSelected) {
|
||||||
|
@ -894,6 +902,10 @@ function mouseMoveEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mouseReleaseEvent(event) {
|
function mouseReleaseEvent(event) {
|
||||||
|
if (altIsPressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
modelSelected = false;
|
modelSelected = false;
|
||||||
|
|
||||||
glowedModelID.id = -1;
|
glowedModelID.id = -1;
|
||||||
|
@ -962,4 +974,16 @@ Menu.menuItemEvent.connect(function(menuItem){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// handling of inspect.js concurrence
|
||||||
|
altIsPressed = false;
|
||||||
|
Controller.keyPressEvent.connect(function(event) {
|
||||||
|
if (event.text == "ALT") {
|
||||||
|
altIsPressed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Controller.keyReleaseEvent.connect(function(event) {
|
||||||
|
if (event.text == "ALT") {
|
||||||
|
altIsPressed = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
@ -177,30 +177,45 @@ function keyReleaseEvent(event) {
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
if (alt && !isActive) {
|
if (alt && !isActive) {
|
||||||
isActive = true;
|
|
||||||
mouseLastX = event.x;
|
mouseLastX = event.x;
|
||||||
mouseLastY = event.y;
|
mouseLastY = event.y;
|
||||||
|
|
||||||
// Compute trajectories related values
|
// Compute trajectories related values
|
||||||
var pickRay = Camera.computePickRay(mouseLastX, mouseLastY);
|
var pickRay = Camera.computePickRay(mouseLastX, mouseLastY);
|
||||||
var intersection = Voxels.findRayIntersection(pickRay);
|
var voxelIntersection = Voxels.findRayIntersection(pickRay);
|
||||||
|
var modelIntersection = Models.findRayIntersection(pickRay);
|
||||||
|
|
||||||
position = Camera.getPosition();
|
position = Camera.getPosition();
|
||||||
|
|
||||||
avatarTarget = MyAvatar.getTargetAvatarPosition();
|
var avatarTarget = MyAvatar.getTargetAvatarPosition();
|
||||||
voxelTarget = intersection.intersection;
|
var voxelTarget = voxelIntersection.intersection;
|
||||||
if (Vec3.length(Vec3.subtract(avatarTarget, position)) < Vec3.length(Vec3.subtract(voxelTarget, position))) {
|
|
||||||
if (avatarTarget.x != 0 || avatarTarget.y != 0 || avatarTarget.z != 0) {
|
|
||||||
center = avatarTarget;
|
var distance = -1;
|
||||||
} else {
|
var string;
|
||||||
center = voxelTarget;
|
|
||||||
}
|
if (modelIntersection.intersects && modelIntersection.accurate) {
|
||||||
} else {
|
distance = modelIntersection.distance;
|
||||||
if (voxelTarget.x != 0 || voxelTarget.y != 0 || voxelTarget.z != 0) {
|
center = modelIntersection.modelProperties.position;
|
||||||
center = voxelTarget;
|
string = "Inspecting model";
|
||||||
} else {
|
}
|
||||||
center = avatarTarget;
|
|
||||||
}
|
if ((distance == -1 || Vec3.length(Vec3.subtract(avatarTarget, position)) < distance) &&
|
||||||
|
(avatarTarget.x != 0 || avatarTarget.y != 0 || avatarTarget.z != 0)) {
|
||||||
|
distance = Vec3.length(Vec3.subtract(avatarTarget, position));
|
||||||
|
center = avatarTarget;
|
||||||
|
string = "Inspecting avatar";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((distance == -1 || Vec3.length(Vec3.subtract(voxelTarget, position)) < distance) &&
|
||||||
|
(voxelTarget.x != 0 || voxelTarget.y != 0 || voxelTarget.z != 0)) {
|
||||||
|
distance = Vec3.length(Vec3.subtract(voxelTarget, position));
|
||||||
|
center = voxelTarget;
|
||||||
|
string = "Inspecting voxel";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distance == -1) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector = Vec3.subtract(position, center);
|
vector = Vec3.subtract(position, center);
|
||||||
|
@ -209,6 +224,8 @@ function mousePressEvent(event) {
|
||||||
altitude = Math.asin(vector.y / Vec3.length(vector));
|
altitude = Math.asin(vector.y / Vec3.length(vector));
|
||||||
|
|
||||||
Camera.keepLookingAt(center);
|
Camera.keepLookingAt(center);
|
||||||
|
print(string);
|
||||||
|
isActive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue