mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:41:20 +02:00
Make particle / light icon translate x-z when inside bounding box
This commit is contained in:
parent
801a4b9aba
commit
6c3174ccf1
1 changed files with 48 additions and 2 deletions
|
@ -200,6 +200,8 @@ SelectionManager = (function() {
|
||||||
that.worldPosition = properties.boundingBox.center;
|
that.worldPosition = properties.boundingBox.center;
|
||||||
that.worldRotation = properties.boundingBox.rotation;
|
that.worldRotation = properties.boundingBox.rotation;
|
||||||
|
|
||||||
|
that.entityType = properties.type;
|
||||||
|
|
||||||
SelectionDisplay.setSpaceMode(SPACE_LOCAL);
|
SelectionDisplay.setSpaceMode(SPACE_LOCAL);
|
||||||
} else {
|
} else {
|
||||||
that.localRotation = null;
|
that.localRotation = null;
|
||||||
|
@ -208,6 +210,8 @@ SelectionManager = (function() {
|
||||||
|
|
||||||
properties = Entities.getEntityProperties(that.selections[0]);
|
properties = Entities.getEntityProperties(that.selections[0]);
|
||||||
|
|
||||||
|
that.entityType = properties.type;
|
||||||
|
|
||||||
var brn = properties.boundingBox.brn;
|
var brn = properties.boundingBox.brn;
|
||||||
var tfl = properties.boundingBox.tfl;
|
var tfl = properties.boundingBox.tfl;
|
||||||
|
|
||||||
|
@ -537,6 +541,17 @@ SelectionDisplay = (function() {
|
||||||
dashed: false
|
dashed: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle for x-z translation of particle effect and light entities while inside the bounding box.
|
||||||
|
// Limitation: If multiple entities are selected, only the first entity's icon translates the selection.
|
||||||
|
var iconSelectionBox = Overlays.addOverlay("cube", {
|
||||||
|
size: 0.3, // Match entity icon size.
|
||||||
|
color: COLOR_RED,
|
||||||
|
alpha: 0,
|
||||||
|
solid: false,
|
||||||
|
visible: false,
|
||||||
|
dashed: false
|
||||||
|
});
|
||||||
|
|
||||||
var allOverlays = [
|
var allOverlays = [
|
||||||
handleTranslateXCone,
|
handleTranslateXCone,
|
||||||
handleTranslateXCylinder,
|
handleTranslateXCylinder,
|
||||||
|
@ -576,7 +591,8 @@ SelectionDisplay = (function() {
|
||||||
handleScaleFREdge,
|
handleScaleFREdge,
|
||||||
handleScaleFLEdge,
|
handleScaleFLEdge,
|
||||||
handleCloner,
|
handleCloner,
|
||||||
selectionBox
|
selectionBox,
|
||||||
|
iconSelectionBox
|
||||||
];
|
];
|
||||||
|
|
||||||
overlayNames[handleTranslateXCone] = "handleTranslateXCone";
|
overlayNames[handleTranslateXCone] = "handleTranslateXCone";
|
||||||
|
@ -623,6 +639,7 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
overlayNames[handleCloner] = "handleCloner";
|
overlayNames[handleCloner] = "handleCloner";
|
||||||
overlayNames[selectionBox] = "selectionBox";
|
overlayNames[selectionBox] = "selectionBox";
|
||||||
|
overlayNames[iconSelectionBox] = "iconSelectionBox";
|
||||||
|
|
||||||
var activeTool = null;
|
var activeTool = null;
|
||||||
var handleTools = {};
|
var handleTools = {};
|
||||||
|
@ -1321,9 +1338,22 @@ SelectionDisplay = (function() {
|
||||||
rotation: rotation,
|
rotation: rotation,
|
||||||
dimensions: dimensions
|
dimensions: dimensions
|
||||||
};
|
};
|
||||||
selectionBoxGeometry.visible = !inModeRotate && !isPointInsideBox(Camera.position, selectionBoxGeometry);
|
var isCameraInsideBox = isPointInsideBox(Camera.position, selectionBoxGeometry);
|
||||||
|
selectionBoxGeometry.visible = !inModeRotate && !isCameraInsideBox;
|
||||||
Overlays.editOverlay(selectionBox, selectionBoxGeometry);
|
Overlays.editOverlay(selectionBox, selectionBoxGeometry);
|
||||||
|
|
||||||
|
// UPDATE ICON TRANSLATE HANDLE
|
||||||
|
if (SelectionManager.entityType === "ParticleEffect" || SelectionManager.entityType === "Light") {
|
||||||
|
var iconSelectionBoxGeometry = {
|
||||||
|
position: position,
|
||||||
|
rotation: rotation
|
||||||
|
};
|
||||||
|
iconSelectionBoxGeometry.visible = !inModeRotate && isCameraInsideBox;
|
||||||
|
Overlays.editOverlay(iconSelectionBox, iconSelectionBoxGeometry);
|
||||||
|
} else {
|
||||||
|
Overlays.editOverlay(iconSelectionBox, { visible: false });
|
||||||
|
}
|
||||||
|
|
||||||
// UPDATE CLONER (CURRENTLY HIDDEN FOR NOW)
|
// UPDATE CLONER (CURRENTLY HIDDEN FOR NOW)
|
||||||
var handleClonerOffset = {
|
var handleClonerOffset = {
|
||||||
x:CLONER_OFFSET.x * dimensions.x,
|
x:CLONER_OFFSET.x * dimensions.x,
|
||||||
|
@ -2407,6 +2437,22 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addHandleTool(iconSelectionBox, {
|
||||||
|
mode: "TRANSLATE_XZ",
|
||||||
|
onBegin: function (event, pickRay, pickResult) {
|
||||||
|
translateXZTool.onBegin(event, pickRay, pickResult, false);
|
||||||
|
},
|
||||||
|
elevation: function (event) {
|
||||||
|
translateXZTool.elevation(event);
|
||||||
|
},
|
||||||
|
onEnd: function (event) {
|
||||||
|
translateXZTool.onEnd(event);
|
||||||
|
},
|
||||||
|
onMove: function (event) {
|
||||||
|
translateXZTool.onMove(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
addHandleTranslateTool(handleTranslateXCone, "TRANSLATE_X", TRANSLATE_DIRECTION.X);
|
addHandleTranslateTool(handleTranslateXCone, "TRANSLATE_X", TRANSLATE_DIRECTION.X);
|
||||||
addHandleTranslateTool(handleTranslateXCylinder, "TRANSLATE_X", TRANSLATE_DIRECTION.X);
|
addHandleTranslateTool(handleTranslateXCylinder, "TRANSLATE_X", TRANSLATE_DIRECTION.X);
|
||||||
addHandleTranslateTool(handleTranslateYCone, "TRANSLATE_Y", TRANSLATE_DIRECTION.Y);
|
addHandleTranslateTool(handleTranslateYCone, "TRANSLATE_Y", TRANSLATE_DIRECTION.Y);
|
||||||
|
|
Loading…
Reference in a new issue