0

i am newbie to 3D Polygonal modelling and to three.js. I wrote an exporter to convert 3d model data from propritary format (cpixml) to the specified three.js json format and could load my model in the browser using the JsonLoader. I want to ask if someone could put some sample code or examples of how to set the camera so that i can display the hole model.

Best regards and thx in advance for ur help.

WestLangley
  • 102,557
  • 10
  • 276
  • 276

1 Answers1

0

I am not sure if I understand your question. Supposed you just want to inspect your loaded model the best option is probably to use FirstPersonControls.js - https://github.com/mrdoob/three.js/blob/master/examples/js/controls/FirstPersonControls.js

or any other type of controls from the same directory

if you want something more fitting your needs, try to play with camera object - set its rotation and position so it is to your liking.

position it like this:

camera.position.set( x, y, z );

and rotate like this:

camera.rotation.set( x, y, z );

or make it look to certain object:

camera.lookAt( myObject.position );

If you want some universal solution that will always place your camera in a good position, you will have to write some code that will find this position for you. That for sure is not a trivial thing and you should try to do it yourself. Just imagine how many possibilities there are - you might want to see it from top or from a side or somewhere in between, you might want to be right next to your objects or you might want to be relatively far from them. Then also aspect of your camera plays a big role in what actually be visible and what will not.

lot
  • 1,434
  • 18
  • 23
  • my problem is that the 3d model´s dimensions are too big, and i am seeing only a part of the model in the screen. When i zoon out several times with the mouse, the model get smaller and i can see the hole model displayed in the screen.I am acctually trying to figure it out how to adjust that so i can see the hole model at the begin when i load it and not have to zoom out... – Mehdi Foudhaili Jan 22 '14 at 15:26
  • acctually i would like to do something like this https://github.com/mrdoob/three.js/issues/1095 but i dont know exactly how ... – Mehdi Foudhaili Jan 22 '14 at 16:01
  • well, for a specific scene just set camera's position manually to some place from which your model is nicely visible (i.e. is distant enough, but not too much). You will achieve this by two lines of code from my answer. This perfect camera position will of course be different for different scenes/models. – lot Jan 22 '14 at 16:29