mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
Update handles when scale
This commit is contained in:
parent
718d7a1120
commit
485190456d
1 changed files with 59 additions and 4 deletions
|
@ -207,9 +207,11 @@
|
||||||
Handles = function () {
|
Handles = function () {
|
||||||
var boundingBoxOverlay,
|
var boundingBoxOverlay,
|
||||||
boundingBoxDimensions,
|
boundingBoxDimensions,
|
||||||
|
boundingBoxLocalCenter,
|
||||||
cornerIndexes = [],
|
cornerIndexes = [],
|
||||||
cornerHandleOverlays = [],
|
cornerHandleOverlays = [],
|
||||||
faceHandleOverlays = [],
|
faceHandleOverlays = [],
|
||||||
|
faceHandleOffsets,
|
||||||
BOUNDING_BOX_COLOR = { red: 0, green: 240, blue: 240 },
|
BOUNDING_BOX_COLOR = { red: 0, green: 240, blue: 240 },
|
||||||
BOUNDING_BOX_ALPHA = 0.8,
|
BOUNDING_BOX_ALPHA = 0.8,
|
||||||
HANDLE_NORMAL_COLOR = { red: 0, green: 240, blue: 240 },
|
HANDLE_NORMAL_COLOR = { red: 0, green: 240, blue: 240 },
|
||||||
|
@ -228,6 +230,11 @@
|
||||||
ZERO_ROTATION = Quat.fromVec3Radians(Vec3.ZERO),
|
ZERO_ROTATION = Quat.fromVec3Radians(Vec3.ZERO),
|
||||||
DISTANCE_MULTIPLIER_MULTIPLIER = 0.5,
|
DISTANCE_MULTIPLIER_MULTIPLIER = 0.5,
|
||||||
hoveredOverlayID = null,
|
hoveredOverlayID = null,
|
||||||
|
|
||||||
|
// Scaling.
|
||||||
|
scalingBoundingBoxDimensions,
|
||||||
|
scalingBoundingBoxLocalCenter,
|
||||||
|
|
||||||
i;
|
i;
|
||||||
|
|
||||||
CORNER_HANDLE_OVERLAY_AXES = [
|
CORNER_HANDLE_OVERLAY_AXES = [
|
||||||
|
@ -336,7 +343,6 @@
|
||||||
|
|
||||||
function display(rootEntityID, boundingBox, isMultiple) {
|
function display(rootEntityID, boundingBox, isMultiple) {
|
||||||
var boundingBoxCenter,
|
var boundingBoxCenter,
|
||||||
boundingBoxLocalCenter,
|
|
||||||
boundingBoxOrientation,
|
boundingBoxOrientation,
|
||||||
cameraPosition,
|
cameraPosition,
|
||||||
boundingBoxVector,
|
boundingBoxVector,
|
||||||
|
@ -350,7 +356,6 @@
|
||||||
leftCornerIndex,
|
leftCornerIndex,
|
||||||
cornerHandleDimensions,
|
cornerHandleDimensions,
|
||||||
faceHandleDimensions,
|
faceHandleDimensions,
|
||||||
faceHandleOffsets,
|
|
||||||
i;
|
i;
|
||||||
|
|
||||||
boundingBoxDimensions = boundingBox.dimensions;
|
boundingBoxDimensions = boundingBox.dimensions;
|
||||||
|
@ -427,6 +432,45 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function startScaling() {
|
||||||
|
// Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
|
function scale(scale3D) {
|
||||||
|
// Scale relative to dimensions and positions at start of scaling.
|
||||||
|
|
||||||
|
// Selection bounding box.
|
||||||
|
scalingBoundingBoxDimensions = Vec3.multiplyVbyV(scale3D, boundingBoxLocalCenter);
|
||||||
|
scalingBoundingBoxLocalCenter = Vec3.multiplyVbyV(scale3D, boundingBoxDimensions);
|
||||||
|
Overlays.editOverlay(boundingBoxOverlay, {
|
||||||
|
localPosition: scalingBoundingBoxDimensions,
|
||||||
|
dimensions: scalingBoundingBoxLocalCenter
|
||||||
|
});
|
||||||
|
|
||||||
|
// Corner scale handles.
|
||||||
|
for (i = 0; i < NUM_CORNER_HANDLES; i += 1) {
|
||||||
|
Overlays.editOverlay(cornerHandleOverlays[i], {
|
||||||
|
localPosition: Vec3.sum(scalingBoundingBoxDimensions,
|
||||||
|
Vec3.multiplyVbyV(CORNER_HANDLE_OVERLAY_AXES[cornerIndexes[i]], scalingBoundingBoxLocalCenter))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Face scale handles.
|
||||||
|
for (i = 0; i < NUM_FACE_HANDLES; i += 1) {
|
||||||
|
Overlays.editOverlay(faceHandleOverlays[i], {
|
||||||
|
localPosition: Vec3.sum(scalingBoundingBoxDimensions,
|
||||||
|
Vec3.multiplyVbyV(FACE_HANDLE_OVERLAY_AXES[i],
|
||||||
|
Vec3.sum(scalingBoundingBoxLocalCenter, faceHandleOffsets)))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishScaling() {
|
||||||
|
// Adopt final scale.
|
||||||
|
boundingBoxLocalCenter = scalingBoundingBoxDimensions;
|
||||||
|
boundingBoxDimensions = scalingBoundingBoxLocalCenter;
|
||||||
|
}
|
||||||
|
|
||||||
function hover(overlayID) {
|
function hover(overlayID) {
|
||||||
if (overlayID !== hoveredOverlayID) {
|
if (overlayID !== hoveredOverlayID) {
|
||||||
if (hoveredOverlayID !== null) {
|
if (hoveredOverlayID !== null) {
|
||||||
|
@ -492,6 +536,9 @@
|
||||||
isHandle: isHandle,
|
isHandle: isHandle,
|
||||||
scalingAxis: scalingAxis,
|
scalingAxis: scalingAxis,
|
||||||
scalingDirections: scalingDirections,
|
scalingDirections: scalingDirections,
|
||||||
|
startScaling: startScaling,
|
||||||
|
scale: scale,
|
||||||
|
finishScaling: finishScaling,
|
||||||
hover: hover,
|
hover: hover,
|
||||||
grab: grab,
|
grab: grab,
|
||||||
clear: clear,
|
clear: clear,
|
||||||
|
@ -728,6 +775,10 @@
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function finishHandleScaling() {
|
||||||
|
select(selectedEntityID); // Refresh.
|
||||||
|
}
|
||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
selection = [];
|
selection = [];
|
||||||
selectedEntityID = null;
|
selectedEntityID = null;
|
||||||
|
@ -754,6 +805,7 @@
|
||||||
directScale: directScale,
|
directScale: directScale,
|
||||||
startHandleScaling: startHandleScaling,
|
startHandleScaling: startHandleScaling,
|
||||||
handleScale: handleScale,
|
handleScale: handleScale,
|
||||||
|
finishHandleScaling: finishHandleScaling,
|
||||||
clear: clear,
|
clear: clear,
|
||||||
destroy: destroy
|
destroy: destroy
|
||||||
};
|
};
|
||||||
|
@ -1285,6 +1337,7 @@
|
||||||
handleHandOffset = handDistance - initialHandleDistance;
|
handleHandOffset = handDistance - initialHandleDistance;
|
||||||
|
|
||||||
selection.startHandleScaling();
|
selection.startHandleScaling();
|
||||||
|
handles.startScaling();
|
||||||
isHandleScaling = true;
|
isHandleScaling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,8 +1346,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopHandleScaling() {
|
function stopHandleScaling() {
|
||||||
// Stop highlighting grabbed handle and resume displaying all handles.
|
handles.finishScaling();
|
||||||
handles.grab(null);
|
selection.finishHandleScaling();
|
||||||
|
handles.grab(null); // Stop highlighting grabbed handle and resume displaying all handles.
|
||||||
isHandleScaling = false;
|
isHandleScaling = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1366,6 +1420,7 @@
|
||||||
y: scale3D.y !== 0 ? scale3D.y : 1,
|
y: scale3D.y !== 0 ? scale3D.y : 1,
|
||||||
z: scale3D.z !== 0 ? scale3D.z : 1
|
z: scale3D.z !== 0 ? scale3D.z : 1
|
||||||
};
|
};
|
||||||
|
handles.scale(scale3D);
|
||||||
selection.handleScale(scale3D);
|
selection.handleScale(scale3D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue