我知道ModelVisual3D
可以通过AxisAngleRotation3D
绕任何轴旋转,但是是否可以对包含 9 ModelVisual3D
s 的 Viewport3D 执行相同的操作,因此它们一起旋转,就好像它们是一个对象一样.. 例如,我可以用 ModelVisual3D
做到这一点:
<Viewport3D.Triggers>
<EventTrigger RoutedEvent="Viewport3D.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="myVerticalRotation"
Storyboard.TargetProperty="Angle"
From="0" To="360" Duration="0:0:10"
RepeatBehavior="Forever" />
<DoubleAnimation
Storyboard.TargetName="myHorizontalRotation"
Storyboard.TargetProperty="Angle"
From="0" To="360" Duration="0:0:9"
RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Viewport3D.Triggers>
但这假定Viewport3D
只包含一个ModelVisual3D
是的,可以通过将所有GeometryModel3D
对象包含在Model3DGroup
内ModelUIElement3D
ContainerUIElement3D
内,然后我们能够在ContainerUIElement3D.Transform
中定义RotateTransform3D
:
<ContainerUIElement3D>
<ModelUIElement3D>
<Model3DGroup>
<GeometryModel3D>...</GeometryModel3D>
<GeometryModel3D>...</GeometryModel3D>
<GeometryModel3D>...</GeometryModel3D>
</Model3DGroup>
</ModelUIElement3D>
<ContainerUIElement3D.Transform>
<Transform3DGroup>
<RotateTransform3D >
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="myHorizontalRotation" Angle="142.884" Axis="0 1 0"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Transform3DGroup>
</ContainerUIElement3D.Transform>
</ContainerUIElement3D>