Skip to content

Commit

Permalink
add rotation to content configs
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaSloboda committed Nov 20, 2023
1 parent e7cdce0 commit 22a444c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public static LayoutInstantiated InstantiateLayoutByFit(SpaceConfiguration confi
layoutInstantiated.ConfigName = key;
break;
}
else if (config.AllowRotatation && config.CellBoundary.Depth < width + 0.01 && config.CellBoundary.Width < length + 0.01)
{
layoutInstantiated.Config = GetRotatedConfig(config, -90);
layoutInstantiated.ConfigName = key;
break;
}
}
if (layoutInstantiated.Config == null)
{
Expand Down Expand Up @@ -849,5 +855,33 @@ public static void SetLevelVolume(ComponentInstance componentInstance, Guid? lev
}
}
}

private static ContentConfiguration GetRotatedConfig(ContentConfiguration config, double degrees)
{
var transform = new Transform().Rotated(Vector3.ZAxis, degrees);
var box = new BBox3(new List<Vector3> { transform.OfPoint(config.CellBoundary.Min), transform.OfPoint(config.CellBoundary.Max) });

// Create new config
var newConfig = new ContentConfiguration()
{
CellBoundary = new ContentConfiguration.BoundaryDefinition() { Min = box.Min, Max = box.Max, },
ContentItems = new List<ContentConfiguration.ContentItem>()
};

foreach (var item in config.ContentItems)
{
var newItem = new ContentConfiguration.ContentItem()
{
Url = item.Url,
Name = item.Name,
Transform = item.Transform.Concatenated(transform),
Anchor = transform.OfPoint(item.Anchor)
};

newConfig.ContentItems.Add(newItem);
}

return newConfig;
}
}
}

0 comments on commit 22a444c

Please sign in to comment.