unconed / MathBox.js

MathBox is a (work in progress) library for making presentation-quality math diagrams in WebGL.
MIT License
1.94k stars 127 forks source link

How to use an orthographic camera instead of the default perspective camera #30

Closed glepretre closed 10 years ago

glepretre commented 10 years ago

Hello,

We are currently trying to master MathBox to represent a 3D path (measurement of a borehole deviation) and we would need to use an orthographic camera in order not to distort the representation depending on the viewpoint.

We tried to override the default perspective camera using:

var mathbox = window.mathbox = mathBox({
  cameraControls: true,
  cursor:         true,
  controlClass:   ThreeBox.OrbitControls,
  elementResize:  true,
  fullscreen:     true,
  screenshot:     true,
  stats:          true,
  scale:          1,

  // see line below
  camera: new THREE.OrthographicCamera(-50, 50, 50, -50, 0.01, 10000)
}).start();

But it seems that this camera is not added to the scene/stage.

Do you know how could we achieve that? I have to say I do not know very well ThreeJS and I would like to keep the abstraction layer brought by MathBox as much as possible because I intend to wrap it into an Angular directive to generate my representations.

unconed commented 10 years ago

This was never properly supported, I don't use orthographic to be honest, I find it ugly and unnatural.

I patched up the bug though, so it seems to work now: http://acko.net/files/mathbox/MathBox.js/examples/Orthographic.html

No guarantees though.

Also, there's already the MathTag directive, although it's not a 1-to-1 mapping: https://github.com/csicar/MathTag

glepretre commented 10 years ago

Wow that's a great patch! Did you have this on a branch or did you write it from scratch in 2 hours? I agree with you, orthographic is ugly but we have to use it to render a correct technical drawing.

It's working as expected for now, thank you very much. :wink:

I saw that there were some issues and requests about custom labels (primitives). I must admit that it would also interest us. What do you advise me to do to annotate axes / vectors / points?

unconed commented 10 years ago

I don't need them, definitely not going to add them to v1.

glepretre commented 10 years ago

I did not mean you should add them, just asking how could I do that, on my own. I think I found a way.

May I ask you what you have in mind about v2?