mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
commit
c8ef3489d2
2 changed files with 75 additions and 76 deletions
|
@ -32,8 +32,6 @@ var MIN_PASTE_VOXEL_SCALE = .256;
|
||||||
var zFightingSizeAdjust = 0.002; // used to adjust preview voxels to prevent z fighting
|
var zFightingSizeAdjust = 0.002; // used to adjust preview voxels to prevent z fighting
|
||||||
var previewLineWidth = 1.5;
|
var previewLineWidth = 1.5;
|
||||||
|
|
||||||
var oldMode = Camera.getMode();
|
|
||||||
var trackAsOrbitOrPan = false;
|
|
||||||
var isAdding = false;
|
var isAdding = false;
|
||||||
var isExtruding = false;
|
var isExtruding = false;
|
||||||
var extrudeDirection = { x: 0, y: 0, z: 0 };
|
var extrudeDirection = { x: 0, y: 0, z: 0 };
|
||||||
|
@ -614,8 +612,6 @@ function showPreviewVoxel() {
|
||||||
var guidePosition;
|
var guidePosition;
|
||||||
if (trackAsRecolor || recolorToolSelected || trackAsEyedropper || eyedropperToolSelected) {
|
if (trackAsRecolor || recolorToolSelected || trackAsEyedropper || eyedropperToolSelected) {
|
||||||
Overlays.editOverlay(voxelPreview, { visible: true });
|
Overlays.editOverlay(voxelPreview, { visible: true });
|
||||||
} else if (trackAsOrbitOrPan) {
|
|
||||||
Overlays.editOverlay(voxelPreview, { visible: false });
|
|
||||||
} else if (voxelToolSelected && !isExtruding) {
|
} else if (voxelToolSelected && !isExtruding) {
|
||||||
Overlays.editOverlay(voxelPreview, { visible: true });
|
Overlays.editOverlay(voxelPreview, { visible: true });
|
||||||
} else if (isExtruding) {
|
} else if (isExtruding) {
|
||||||
|
@ -706,15 +702,12 @@ function showPreviewGuides() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function trackMouseEvent(event) {
|
function trackMouseEvent(event) {
|
||||||
if (!trackAsOrbitOrPan) {
|
trackLastMouseX = event.x;
|
||||||
trackLastMouseX = event.x;
|
trackLastMouseY = event.y;
|
||||||
trackLastMouseY = event.y;
|
trackAsDelete = event.isControl;
|
||||||
trackAsDelete = event.isControl;
|
trackAsRecolor = event.isShifted;
|
||||||
trackAsRecolor = event.isShifted;
|
trackAsEyedropper = event.isMeta;
|
||||||
trackAsEyedropper = event.isMeta;
|
showPreviewGuides();
|
||||||
trackAsOrbitOrPan = event.isAlt; // TODO: double check this...??
|
|
||||||
showPreviewGuides();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function trackKeyPressEvent(event) {
|
function trackKeyPressEvent(event) {
|
||||||
|
@ -742,6 +735,7 @@ function trackKeyReleaseEvent(event) {
|
||||||
if (event.text == "TAB") {
|
if (event.text == "TAB") {
|
||||||
editToolsOn = !editToolsOn;
|
editToolsOn = !editToolsOn;
|
||||||
moveTools();
|
moveTools();
|
||||||
|
showPreviewGuides();
|
||||||
Audio.playSound(clickSound, audioOptions);
|
Audio.playSound(clickSound, audioOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,67 +782,64 @@ function mousePressEvent(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no clicking on overlays while in panning mode
|
var clickedOnSomething = false;
|
||||||
if (!trackAsOrbitOrPan) {
|
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||||
var clickedOnSomething = false;
|
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
// If the user clicked on the thumb, handle the slider logic
|
||||||
|
if (clickedOverlay == thumb) {
|
||||||
// If the user clicked on the thumb, handle the slider logic
|
isMovingSlider = true;
|
||||||
if (clickedOverlay == thumb) {
|
thumbClickOffsetX = event.x - (sliderX + thumbX); // this should be the position of the mouse relative to the thumb
|
||||||
isMovingSlider = true;
|
clickedOnSomething = true;
|
||||||
thumbClickOffsetX = event.x - (sliderX + thumbX); // this should be the position of the mouse relative to the thumb
|
|
||||||
clickedOnSomething = true;
|
Overlays.editOverlay(thumb, { imageURL: toolIconUrl + "voxel-size-slider-handle.svg", });
|
||||||
|
|
||||||
Overlays.editOverlay(thumb, { imageURL: toolIconUrl + "voxel-size-slider-handle.svg", });
|
} else if (clickedOverlay == voxelTool) {
|
||||||
|
voxelToolSelected = true;
|
||||||
} else if (clickedOverlay == voxelTool) {
|
recolorToolSelected = false;
|
||||||
voxelToolSelected = true;
|
eyedropperToolSelected = false;
|
||||||
recolorToolSelected = false;
|
moveTools();
|
||||||
eyedropperToolSelected = false;
|
clickedOnSomething = true;
|
||||||
moveTools();
|
} else if (clickedOverlay == recolorTool) {
|
||||||
clickedOnSomething = true;
|
voxelToolSelected = false;
|
||||||
} else if (clickedOverlay == recolorTool) {
|
recolorToolSelected = true;
|
||||||
voxelToolSelected = false;
|
eyedropperToolSelected = false;
|
||||||
recolorToolSelected = true;
|
moveTools();
|
||||||
eyedropperToolSelected = false;
|
clickedOnSomething = true;
|
||||||
moveTools();
|
} else if (clickedOverlay == eyedropperTool) {
|
||||||
clickedOnSomething = true;
|
voxelToolSelected = false;
|
||||||
} else if (clickedOverlay == eyedropperTool) {
|
recolorToolSelected = false;
|
||||||
voxelToolSelected = false;
|
eyedropperToolSelected = true;
|
||||||
recolorToolSelected = false;
|
moveTools();
|
||||||
eyedropperToolSelected = true;
|
clickedOnSomething = true;
|
||||||
moveTools();
|
} else if (clickedOverlay == slider) {
|
||||||
clickedOnSomething = true;
|
|
||||||
} else if (clickedOverlay == slider) {
|
if (event.x < sliderX + minThumbX) {
|
||||||
|
thumbX -= thumbDeltaPerStep;
|
||||||
if (event.x < sliderX + minThumbX) {
|
calcScaleFromThumb(thumbX);
|
||||||
thumbX -= thumbDeltaPerStep;
|
|
||||||
calcScaleFromThumb(thumbX);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.x > sliderX + maxThumbX) {
|
|
||||||
thumbX += thumbDeltaPerStep;
|
|
||||||
calcScaleFromThumb(thumbX);
|
|
||||||
}
|
|
||||||
|
|
||||||
moveTools();
|
|
||||||
clickedOnSomething = true;
|
|
||||||
} else {
|
|
||||||
// if the user clicked on one of the color swatches, update the selectedSwatch
|
|
||||||
for (s = 0; s < numColors; s++) {
|
|
||||||
if (clickedOverlay == swatches[s]) {
|
|
||||||
whichColor = s;
|
|
||||||
moveTools();
|
|
||||||
clickedOnSomething = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (clickedOnSomething) {
|
|
||||||
return; // no further processing
|
if (event.x > sliderX + maxThumbX) {
|
||||||
|
thumbX += thumbDeltaPerStep;
|
||||||
|
calcScaleFromThumb(thumbX);
|
||||||
|
}
|
||||||
|
|
||||||
|
moveTools();
|
||||||
|
clickedOnSomething = true;
|
||||||
|
} else {
|
||||||
|
// if the user clicked on one of the color swatches, update the selectedSwatch
|
||||||
|
for (s = 0; s < numColors; s++) {
|
||||||
|
if (clickedOverlay == swatches[s]) {
|
||||||
|
whichColor = s;
|
||||||
|
moveTools();
|
||||||
|
clickedOnSomething = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (clickedOnSomething) {
|
||||||
|
return; // no further processing
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: does any of this stuff need to execute if we're panning or orbiting?
|
// TODO: does any of this stuff need to execute if we're panning or orbiting?
|
||||||
trackMouseEvent(event); // used by preview support
|
trackMouseEvent(event); // used by preview support
|
||||||
mouseX = event.x;
|
mouseX = event.x;
|
||||||
|
@ -1071,7 +1062,7 @@ function mouseMoveEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!trackAsOrbitOrPan && isMovingSlider) {
|
if (isMovingSlider) {
|
||||||
thumbX = (event.x - thumbClickOffsetX) - sliderX;
|
thumbX = (event.x - thumbClickOffsetX) - sliderX;
|
||||||
if (thumbX < minThumbX) {
|
if (thumbX < minThumbX) {
|
||||||
thumbX = minThumbX;
|
thumbX = minThumbX;
|
||||||
|
@ -1081,7 +1072,7 @@ function mouseMoveEvent(event) {
|
||||||
}
|
}
|
||||||
calcScaleFromThumb(thumbX);
|
calcScaleFromThumb(thumbX);
|
||||||
|
|
||||||
} else if (!trackAsOrbitOrPan && isAdding) {
|
} else if (isAdding) {
|
||||||
// Watch the drag direction to tell which way to 'extrude' this voxel
|
// Watch the drag direction to tell which way to 'extrude' this voxel
|
||||||
if (!isExtruding) {
|
if (!isExtruding) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
// Dragging the mouse will move your camera according to the mode you are in.
|
// Dragging the mouse will move your camera according to the mode you are in.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var PI = 3.14 // No need for something more precise
|
||||||
|
|
||||||
var AZIMUTH_RATE = 90.0;
|
var AZIMUTH_RATE = 90.0;
|
||||||
var ALTITUDE_RATE = 200.0;
|
var ALTITUDE_RATE = 200.0;
|
||||||
var RADIUS_RATE = 20.0;
|
var RADIUS_RATE = 1.0 / 100.0;
|
||||||
var PAN_RATE = 50.0;
|
var PAN_RATE = 50.0;
|
||||||
|
|
||||||
var alt = false;
|
var alt = false;
|
||||||
|
@ -46,7 +48,7 @@ var altitude = 0.0;
|
||||||
|
|
||||||
function handleRadialMode(dx, dy) {
|
function handleRadialMode(dx, dy) {
|
||||||
azimuth += dx / AZIMUTH_RATE;
|
azimuth += dx / AZIMUTH_RATE;
|
||||||
radius += radius * dy / RADIUS_RATE;
|
radius += radius * dy * RADIUS_RATE;
|
||||||
if (radius < 1) {
|
if (radius < 1) {
|
||||||
radius = 1;
|
radius = 1;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +63,12 @@ function handleRadialMode(dx, dy) {
|
||||||
function handleOrbitMode(dx, dy) {
|
function handleOrbitMode(dx, dy) {
|
||||||
azimuth += dx / AZIMUTH_RATE;
|
azimuth += dx / AZIMUTH_RATE;
|
||||||
altitude += dy / ALTITUDE_RATE;
|
altitude += dy / ALTITUDE_RATE;
|
||||||
|
if (altitude > PI / 2.0) {
|
||||||
|
altitude = PI / 2.0;
|
||||||
|
}
|
||||||
|
if (altitude < -PI / 2.0) {
|
||||||
|
altitude = -PI / 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
vector = { x:(Math.cos(altitude) * Math.cos(azimuth)) * radius,
|
vector = { x:(Math.cos(altitude) * Math.cos(azimuth)) * radius,
|
||||||
y:Math.sin(altitude) * radius,
|
y:Math.sin(altitude) * radius,
|
||||||
|
@ -165,7 +173,7 @@ function keyReleaseEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
if (alt) {
|
if (alt && !isActive) {
|
||||||
isActive = true;
|
isActive = true;
|
||||||
mouseLastX = event.x;
|
mouseLastX = event.x;
|
||||||
mouseLastY = event.y;
|
mouseLastY = event.y;
|
||||||
|
|
Loading…
Reference in a new issue