From 2c3cd53f8dcbf4eea68e96345827165d931bc148 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 12 Jul 2017 15:30:13 +1200 Subject: [PATCH] Display face scale handles only for single entities --- scripts/vr-edit/vr-edit.js | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/scripts/vr-edit/vr-edit.js b/scripts/vr-edit/vr-edit.js index cdaa793616..47512cc4c3 100644 --- a/scripts/vr-edit/vr-edit.js +++ b/scripts/vr-edit/vr-edit.js @@ -211,7 +211,7 @@ } - function display(rootEntityID, boundingBox) { + function display(rootEntityID, boundingBox, isMultiple) { var boundingBoxDimensions = boundingBox.dimensions, boundingBoxLocalCenter = boundingBox.localCenter, i; @@ -226,15 +226,23 @@ }); // Face scale handles. - for (i = 0; i < NUM_FACE_HANDLES; i += 1) { - Overlays.editOverlay(faceHandleOverlays[i], { - parentID: rootEntityID, - localPosition: Vec3.sum(boundingBoxLocalCenter, - Vec3.multiplyVbyV(FACE_HANDLE_OVERLAY_AXES[i], - Vec3.sum(boundingBoxDimensions, { x: 0.12, y: 0.12, z: 0.12 }))), - localRotation: FACE_HANDLE_OVERLAY_ROTATIONS[i], - visible: true - }); + // Only valid for a single entity because for multiple entities, some may be at an angle relative to the root entity + // which would necessitate a (non-existent) shear transform be applied to them when scaling a face of the set. + if (!isMultiple) { + for (i = 0; i < NUM_FACE_HANDLES; i += 1) { + Overlays.editOverlay(faceHandleOverlays[i], { + parentID: rootEntityID, + localPosition: Vec3.sum(boundingBoxLocalCenter, + Vec3.multiplyVbyV(FACE_HANDLE_OVERLAY_AXES[i], + Vec3.sum(boundingBoxDimensions, { x: 0.12, y: 0.12, z: 0.12 }))), + localRotation: FACE_HANDLE_OVERLAY_ROTATIONS[i], + visible: true + }); + } + } else { + for (i = 0; i < NUM_FACE_HANDLES; i += 1) { + Overlays.editOverlay(faceHandleOverlays[i], { visible: false }); + } } } @@ -332,6 +340,10 @@ return selection; } + function count() { + return selection.length; + } + function getBoundingBox() { var center, localCenter, @@ -478,6 +490,7 @@ return { select: select, selection: getSelection, + count: count, rootEntityID: getRootEntityID, boundingBox: getBoundingBox, getPositionAndOrientation: getPositionAndOrientation, @@ -916,7 +929,7 @@ } startEditing(); if (isScaleWithHandles) { - handles.display(selection.rootEntityID(), selection.boundingBox()); + handles.display(selection.rootEntityID(), selection.boundingBox(), selection.count() > 1); } } } else {