mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 23:29:39 +02:00
Add snapToSpacing functionality
This commit is contained in:
parent
10008cb41f
commit
a4cc12e448
2 changed files with 20 additions and 0 deletions
|
@ -1403,6 +1403,8 @@ SelectionDisplay = (function () {
|
|||
|
||||
vector = vec3Mult(mask, vector);
|
||||
|
||||
vector = grid.snapToSpacing(vector);
|
||||
|
||||
var changeInDimensions = Vec3.multiply(-1, vec3Mult(signs, vector));
|
||||
var newDimensions;
|
||||
if (proportional) {
|
||||
|
|
|
@ -69,6 +69,24 @@ Grid = function(opts) {
|
|||
return Vec3.sum(position, origin);
|
||||
}
|
||||
|
||||
that.snapToSpacing = function(delta, majorOnly) {
|
||||
print('snaptogrid? ' + snapToGrid);
|
||||
if (!snapToGrid) {
|
||||
return delta;
|
||||
}
|
||||
|
||||
var spacing = majorOnly ? (minorGridSpacing * majorGridEvery) : minorGridSpacing;
|
||||
|
||||
var snappedDelta = {
|
||||
x: Math.round(delta.x / spacing) * spacing,
|
||||
y: Math.round(delta.y / spacing) * spacing,
|
||||
z: Math.round(delta.z / spacing) * spacing,
|
||||
};
|
||||
|
||||
return snappedDelta;
|
||||
}
|
||||
|
||||
|
||||
that.setPosition = function(newPosition, noUpdate) {
|
||||
origin = Vec3.subtract(newPosition, { x: 0, y: yOffset, z: 0 });
|
||||
origin.x = 0;
|
||||
|
|
Loading…
Reference in a new issue