Don't scale z-axis of text and Web entities

This commit is contained in:
David Rowe 2017-09-11 16:38:06 +12:00
parent 18f4a3bf35
commit acf6a433a9
3 changed files with 32 additions and 21 deletions

View file

@ -129,7 +129,7 @@ Handles = function (side) {
return FACE_HANDLE_OVERLAY_SCALE_AXES[faceHandleOverlays.indexOf(overlayID)];
}
function display(rootEntityID, boundingBox, isMultipleEntities) {
function display(rootEntityID, boundingBox, isMultipleEntities, isSuppressZAxis) {
var boundingBoxCenter,
boundingBoxOrientation,
cameraPosition,
@ -217,20 +217,22 @@ Handles = function (side) {
faceHandleDimensions = Vec3.multiply(distanceMultiplier, FACE_HANDLE_OVERLAY_DIMENSIONS);
faceHandleOffsets = Vec3.multiply(distanceMultiplier, FACE_HANDLE_OVERLAY_OFFSETS);
for (i = 0; i < NUM_FACE_HANDLES; i += 1) {
faceHandleOverlays[i] = Overlays.addOverlay("shape", {
parentID: rootEntityID,
localPosition: Vec3.sum(boundingBoxLocalCenter,
Vec3.multiplyVbyV(FACE_HANDLE_OVERLAY_AXES[i], Vec3.sum(boundingBoxDimensions, faceHandleOffsets))),
localRotation: FACE_HANDLE_OVERLAY_ROTATIONS[i],
dimensions: faceHandleDimensions,
shape: "Cone",
color: HANDLE_NORMAL_COLOR,
alpha: HANDLE_NORMAL_ALPHA,
solid: true,
drawInFront: true,
ignoreRayIntersection: false,
visible: true
});
if (!isSuppressZAxis || FACE_HANDLE_OVERLAY_AXES[i].z === 0) {
faceHandleOverlays[i] = Overlays.addOverlay("shape", {
parentID: rootEntityID,
localPosition: Vec3.sum(boundingBoxLocalCenter,
Vec3.multiplyVbyV(FACE_HANDLE_OVERLAY_AXES[i], Vec3.sum(boundingBoxDimensions, faceHandleOffsets))),
localRotation: FACE_HANDLE_OVERLAY_ROTATIONS[i],
dimensions: faceHandleDimensions,
shape: "Cone",
color: HANDLE_NORMAL_COLOR,
alpha: HANDLE_NORMAL_ALPHA,
solid: true,
drawInFront: true,
ignoreRayIntersection: false,
visible: true
});
}
}
} else {
faceHandleOverlays = [];

View file

@ -29,7 +29,8 @@ Selection = function (side) {
scaleRootOffset,
scaleRootOrientation,
ENTITY_TYPE = "entity",
ENTITY_TYPES_WITH_COLOR = ["Box", "Sphere", "Shape", "PolyLine", "PolyVox"];
ENTITY_TYPES_WITH_COLOR = ["Box", "Sphere", "Shape", "PolyLine", "PolyVox"],
ENTITY_TYPES_2D = ["Text", "Web"];
if (!this instanceof Selection) {
@ -41,14 +42,15 @@ Selection = function (side) {
// The root entity is always the first entry.
var children,
properties,
SELECTION_PROPERTIES = ["position", "registrationPoint", "rotation", "dimensions", "parentID", "localPosition",
"dynamic", "collisionless", "userData"],
SELECTION_PROPERTIES = ["type", "position", "registrationPoint", "rotation", "dimensions", "parentID",
"localPosition", "dynamic", "collisionless", "userData"],
i,
length;
properties = Entities.getEntityProperties(id, SELECTION_PROPERTIES);
result.push({
id: id,
type: properties.type,
position: properties.position,
parentID: properties.parentID,
localPosition: properties.localPosition,
@ -190,6 +192,10 @@ Selection = function (side) {
};
}
function is2D() {
return selection.length === 1 && ENTITY_TYPES_2D.indexOf(selection[0].type) !== -1;
}
function doKick(entityID) {
var properties,
NO_KICK_ENTITY_TYPES = ["Text", "Web"], // These entities don't respond to gravity so don't kick them.
@ -278,6 +284,7 @@ Selection = function (side) {
function directScale(factor, rotation, center) {
// Scale, position, and rotate selection.
// We can get away with scaling the z size of 2D entities - incongruities are barely noticeable and things recover.
var i,
length;
@ -308,7 +315,7 @@ Selection = function (side) {
// Update selection with final entity properties.
var i,
length;
// Final scale, position, and orientaation of root.
// Final scale, position, and orientation of root.
rootPosition = Vec3.sum(scaleCenter, Vec3.multiply(scaleFactor, Vec3.multiplyQbyV(scaleRotation, scaleRootOffset)));
rootOrientation = Quat.multiply(scaleRotation, scaleRootOrientation);
selection[0].dimensions = Vec3.multiply(scaleFactor, selection[0].dimensions);
@ -329,6 +336,7 @@ Selection = function (side) {
function handleScale(factor, position, orientation) {
// Scale and reposition and orient selection.
// We can get away with scaling the z size of 2D entities - incongruities are barely noticeable and things recover.
var i,
length;
@ -526,6 +534,7 @@ Selection = function (side) {
intersectedEntityIndex: getIntersectedEntityIndex,
rootEntityID: getRootEntityID,
boundingBox: getBoundingBox,
is2D: is2D,
getPositionAndOrientation: getPositionAndOrientation,
setPositionAndOrientation: setPositionAndOrientation,
startEditing: startEditing,

View file

@ -719,7 +719,7 @@
laser.disable();
}
if (toolSelected === TOOL_SCALE) {
handles.display(rootEntityID, selection.boundingBox(), selection.count() > 1);
handles.display(rootEntityID, selection.boundingBox(), selection.count() > 1, selection.is2D());
otherEditor.setHandleOverlays(handles.overlays());
}
startEditing();
@ -729,7 +729,7 @@
function updateEditorGrabbing() {
selection.select(intersectedEntityID);
if (toolSelected === TOOL_SCALE) {
handles.display(rootEntityID, selection.boundingBox(), selection.count() > 1);
handles.display(rootEntityID, selection.boundingBox(), selection.count() > 1, selection.is2D());
otherEditor.setHandleOverlays(handles.overlays());
} else {
handles.clear();