Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit cb818f8

Browse files
committed
Scale clipping planes by overall plot size to accomodate very large/small plots
Kept the same ratio between near and far clipping distances as before to preserve current depth buffer precision, but skewed it bit more toward the near clip plane for better zooming in. Can still zoom out plenty far. By the time you hit the far plane, the plot is so tiny as to be useless anyways.
1 parent 5ec24db commit cb818f8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/sage/ext_data/threejs/threejs_template.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,17 @@
184184

185185
var aspect = window.innerWidth / window.innerHeight;
186186

187+
// Scale the near and far clipping planes along with the overall plot size.
188+
var nearClip = 0.01 * midToCorner;
189+
var farClip = 100 * midToCorner;
190+
187191
if ( options.projection === 'orthographic' ) {
188-
var camera = new THREE.OrthographicCamera( -1, 1, 1, -1, -1000, 1000 );
192+
var camera = new THREE.OrthographicCamera( -1, 1, 1, -1, -farClip, farClip );
189193
updateCameraAspect( camera, aspect );
190194
return camera;
191195
}
192196

193-
return new THREE.PerspectiveCamera( 45, aspect, 0.1, 1000 );
197+
return new THREE.PerspectiveCamera( 45, aspect, nearClip, farClip );
194198

195199
}
196200

0 commit comments

Comments
 (0)