<Viewport3D> <src:SolidText Text="中国" FontSize="0.5" FontFamily="Times New Roman" FontWeight="Bold" Origin="-1.1 0.5" Depth="0.3"> <src:SolidText.Material> <MaterialGroup> <DiffuseMaterial Brush="Blue" /> <SpecularMaterial Brush="White" /> </MaterialGroup> </src:SolidText.Material> <src:SolidText.BackMaterial> <MaterialGroup> <DiffuseMaterial Brush="Red" /> <SpecularMaterial Brush="White" /> </MaterialGroup> </src:SolidText.BackMaterial> <src:SolidText.SideMaterial> <MaterialGroup> <DiffuseMaterial> <DiffuseMaterial.Brush> <LinearGradientBrush StartPoint="0 0" EndPoint="0 1"> <GradientStop Offset="0" Color="Blue" /> <GradientStop Offset="1" Color="Red" /> </LinearGradientBrush> </DiffuseMaterial.Brush> </DiffuseMaterial> <SpecularMaterial Brush="White" /> </MaterialGroup> </src:SolidText.SideMaterial> <!-- Transform. --> <src:SolidText.Transform> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="rotate" Axis="1 1 0" /> </RotateTransform3D.Rotation> </RotateTransform3D> </src:SolidText.Transform> </src:SolidText> <!-- Lights. --> <ModelVisual3D> <ModelVisual3D.Content> <Model3DGroup> <AmbientLight Color="#404040" /> <DirectionalLight Color="#C0C0C0" Direction="2 -3 -1" /> </Model3DGroup> </ModelVisual3D.Content> </ModelVisual3D> <!-- Camera. --> <Viewport3D.Camera> <PerspectiveCamera Position="0 0 8" UpDirection="0 1 0" LookDirection="0 0 -1" FieldOfView="45" /> </Viewport3D.Camera> </Viewport3D>
<Page.Triggers> <EventTrigger RoutedEvent="Page.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="rotate" Storyboard.TargetProperty="Angle" From="0" To="360" Duration="0:0:15" RepeatBehavior="Forever" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Page.Triggers>
3d的本身放入window标签中就可以运行,但是放入canvas中后,需要有执行的rotate代码;
其中,viewport3d可以x:Name="引用"