enthought / enthought/mayavi

Mayavi camera clipping

Open
#1,227 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
316
Avg merge
7h 44m
Merged PRs (30d)
5

Description

I'm using Mayavi in a Python script to ingest an STL CAD file. Although the CAD file renders correctly, I experience odd clipping effects when I zoom in too far on the object or when I rotate the scene when I'm zoomed in quite a bit. Although not verbatim, my current code is something like this:

from stl import mesh
from mayavi import mlab

# Create Mayavi figure
f = mlab.figure(size=(500,500),bgcolor=(0.,0.,0.))
visual.set_viewer(f)

# Ingest CAD model
sat_body =
body_mesh = mesh.Mesh.from_file(sat_body)
bx,by,bz = body_mesh.x, body_mesh.y, body_mesh.z
s1 = mlab.mesh(bx,by,bz,colormap="Greys",representation="surface")

# Position camera
mlab.view(focalpoint=[0,0,0],distance=200)
mlab.show()

However, when I rotate the scene, a part of the CAD model disappears. Similarly, when I zoom in without rotation, the CAD model disappears. What can I do to fix this? It's severely limiting me being able to resolve small features on the CAD model. Evidence of the clipping is illustrated in the three figures below:

(left) The normally rendered scene, no zoom, no rotation
(center) The same zoom, but with added scene rotation
(right) No scene rotation, but with increased zoom

![image](https://user-images.githubusercontent.com/114947258/230090966-4149b730-1c98-4d4e-acb8-2b31022d4f93.png)

The issue seems to be similar to that of camera clipping in Blender, which is solved by changing the clip plane of the camera. It is also addressed in [this issue](https://stackoverflow.com/questions/9744324/mayavi-how-to-zoom-in-very-very-close-change-near-clipping-distance) with less detail.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.