在我的网站中,它允许用户上传 3D 模型文件(.stl、.obj),并且网站会为其生成缩略图。它在我的本地电脑上运行良好,但在天蓝色下不起作用,只生成了一个空图像,没有任何异常(可以绘制背景,但无法渲染对象)。网站应用程序有什么限制吗?
public static void Export(Model3DGroup model, string outputFileName)
{
var viewport = new Viewport3D();
viewport.Measure(new Size(320, 240));
viewport.Arrange(new Rect(0, 0, 320, 240));
var root = new ModelVisual3D();
viewport.Children.Add(root);
var camera = new PerspectiveCamera();
camera.Position = new Point3D(2, 16, 20);
camera.LookDirection = new Vector3D(-2, -16, -20);
camera.UpDirection = new Vector3D(0, 0, 1);
camera.FieldOfView = 45;
camera.NearPlaneDistance = 0.1;
camera.FarPlaneDistance = double.PositiveInfinity;
viewport.Camera = camera;
root.Children.Add(new DefaultLights());
root.Content = model;
CameraHelper.ZoomExtents(camera, viewport);
Viewport3DHelper.Export(viewport, outputFileName, Brushes.WhiteSmoke);
}