question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clipping with orthographic camera in HelixViewport3D

See original GitHub issue

Hi, I’ve been using the HelixViewPort3D with a perspective camera and it worked really well, but lately I had to change the camera to an orthographic one.

When using the HelixViewPort3D with an orthographic camera (Orthographic Property set to true), the 3D model is clipping as you can see on the bottom right picture below. It’s like the view is based on the perspective mode and only shows what is visible with a perspective camera even though it uses an orthographic camera.

View of the entire 3D model View of the entire 3D model

Perspective view (Orthographic = False) & Orthographic view (Orthographic = True) Perspective view (Orthographic = False) & Orthographic view (Orthographic = True)

Used code to generate pictures above (toggling Orthographic to True/False)

<Window x:Class="HelixToolkitTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:helix="http://helix-toolkit.org/wpf"
    Title="MainWindow" Height="350" Width="525">
    <helix:HelixViewport3D Background="White" Orthographic="True">
        <helix:CoordinateSystemVisual3D/>
    <ModelVisual3D>
        <ModelVisual3D.Content>
            <DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
        </ModelVisual3D.Content>
    </ModelVisual3D>
    <ModelVisual3D>
        <ModelVisual3D.Content>
            <GeometryModel3D>

                <GeometryModel3D.Geometry>
                    <MeshGeometry3D
                 TriangleIndices="0,1,2 3,4,5 "
                 Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
                 TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
                 Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
                </GeometryModel3D.Geometry>

                <GeometryModel3D.Material>
                    <MaterialGroup>
                        <DiffuseMaterial>
                            <DiffuseMaterial.Brush>
                                <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="Yellow" Offset="0" />
                                        <GradientStop Color="Red" Offset="0.25" />
                                        <GradientStop Color="Blue" Offset="0.75" />
                                        <GradientStop Color="LimeGreen" Offset="1" />
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </DiffuseMaterial.Brush>
                        </DiffuseMaterial>
                    </MaterialGroup>
                </GeometryModel3D.Material>

                <GeometryModel3D.Transform>
                    <ScaleTransform3D ScaleX="50" ScaleY="1" ScaleZ="1"/>
                </GeometryModel3D.Transform>
            </GeometryModel3D>
        </ModelVisual3D.Content>
    </ModelVisual3D>
</helix:HelixViewport3D>
</Window>

Any idea on how to resolve this problem?

Thanks,

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
MoSkinnycommented, May 28, 2015

Unless there is another side effect that I haven’t discovered yet. I think I was just able to get it to work. As my comment said above when I use -Infinity and Infinity something happens and we get some NaN values. So next I tried to use Double.MinValue (-1.7976931348623157E+308) and Double.MaxValue (1.7976931348623157E+308). These values did not produce any NaN values but the ViewPort still refeused to Pan. …so I kept stepping the values down until the following value didn’t produce the clipping effect but still allowed me to Pan. Hopefully that helps someone else or leads to a permanente fix.

<Helix:HelixViewport3D.Camera>
    <OrthographicCamera NearPlaneDistance="-1.7976931348623157E+8" FarPlaneDistance="1.7976931348623157E+8" />
</Helix:HelixViewport3D.Camera>'
0reactions
miloushcommented, Oct 27, 2021

@dmackersie OrthographicCamera.NearPlaneDistance=-Infinity is a valid scenario. The fact that the model completely disappears when trying to pan (but not rotate, same for 0) feels like a bug. Why would panning an orthographic camera need to rely on NearPlaneDistance?

The other problem is that while setting <= 0 near plane on a perspective camera makes terrible things happen, it is happily copied over from an orthographic DefaultCamera. I would suggest that on reset of/switch to perspective camera, the NearPlaneDistance is copied from a default orthographic camera only if > 0. The CameraHelper.Copy method already allows to not copy planes, so perhaps this could be used when the default camera does not match the target camera. Alternatively, there could be separate default orthographic and default perspective camera.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Viewport3D with orthographic camera clipping
When using the ViewPort3D with an orthographic camera, the 3D model is clipping as you can see on the 2nd link below. It's...
Read more >
Orthographic Camera - Undesired Clipping on Zoom In (Near ...
It happens with both zoom and rotation. To reproduce, open the Camera demo, then switch to the Orthographic mode. Do some random zooming...
Read more >
Orthographic camera: make clipping occur? : r/blenderhelp
I don't think there's any way to get clipping on an orthographic camera. Clipping is there so perspective doesn't divide by zero or...
Read more >
OrthographicCamera, System.Windows.Media.Media3D ...
Media3D OrthographicCamera - 22 examples found. These are the top rated real world C# (CSharp) examples of System.Windows.Media.Media3D.
Read more >
Jins/helix-toolkit
Allows to use orthographic camera for screen space group under RelativeScreenSpaced ... SharpDX/UWP/Core); Supports up to 8 clipping planes(cross section).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found