Skip to content

Commit

Permalink
Merge pull request #248 from LearnHub/media-frame-alignment
Browse files Browse the repository at this point in the history
Alignment and scale options for media frames
  • Loading branch information
keianhzo authored Dec 1, 2023
2 parents 6cf55d4 + 924843f commit 28756f2
Showing 1 changed file with 47 additions and 8 deletions.
55 changes: 47 additions & 8 deletions addons/io_hubs_addon/components/definitions/media_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ class MediaFrame(HubsComponent):
'version': (1, 0, 0)
}

bounds: FloatVectorProperty(
name="Bounds",
description="Bounding box to fit objects into when they are snapped into the media frame",
unit='LENGTH',
subtype="XYZ",
default=(1.0, 1.0, 1.0))

mediaType: EnumProperty(
name="Media Type",
description="Limit what type of media this frame will capture",
Expand All @@ -77,6 +70,43 @@ class MediaFrame(HubsComponent):
("pdf", "Only PDFs", "Allow only PDFs")],
default="all-2d")

bounds: FloatVectorProperty(
name="Bounds",
description="Bounding box to fit objects into when they are snapped into the media frame",
unit='LENGTH',
subtype="XYZ",
default=(1.0, 1.0, 1.0))

alignX: EnumProperty(
name="Align X",
description="Media alignment along the X axis",
items=[("min", "Min", "Align minimum X bounds of media and frame"),
("center", "Center", "Align X centers of media and frame"),
("max", "Max", "Align maximum X bounds of media and frame")],
default="center")

alignY: EnumProperty(
name="Align Y",
description="Media alignment along the Y axis",
items=[("min", "Min", "Align minimum Y bounds of media and frame"),
("center", "Center", "Align Y centers of media and frame"),
("max", "Max", "Align maximum Y bounds of media and frame")],
default="center")

alignZ: EnumProperty(
name="Align Z",
description="Media alignment along the Z axis",
items=[("min", "Min", "Align minimum Z bounds of media and frame"),
("center", "Center", "Align Z centers of media and frame"),
("max", "Max", "Align maximum Z bounds of media and frame")],
default="center")

scaleToBounds: BoolProperty(
name="Scale To Bounds",
description="Scale the media to fit within the bounds of the media frame",
default=True
)

snapToCenter: BoolProperty(
name="Snap To Center",
description="Snap the media to the center of the media frame when capturing. If set to false the object will just remain in the place it was dropped but still be considered \"captured\" by the media frame",
Expand Down Expand Up @@ -151,10 +181,19 @@ def gather(self, export_settings, object):
if export_settings['gltf_yup']:
bounds['y'] = self.bounds.z
bounds['z'] = self.bounds.y

align = {
'x': self.alignX,
'y': self.alignY,
'z': self.alignZ
}
if export_settings['gltf_yup']:
align['y'] = self.alignZ
align['z'] = "min" if self.alignY == "max" else "max" if self.alignY == "min" else self.alignY
return {
'bounds': bounds,
'mediaType': self.mediaType,
'align': align,
'scaleToBounds': self.scaleToBounds,
'snapToCenter': self.snapToCenter
}

Expand Down

0 comments on commit 28756f2

Please sign in to comment.