0

I use three.js with jsmodeler to load model from obj. Everything works fine but problem is in custom things.

I have list of buttons clicking on each I can select mesh and highlight it, it's working.

var new_material = new THREE.MeshBasicMaterial( { color: color, wireframe: false, opacity:0.5, transparent:true, side: THREE.BackSide } );
mesh.material = new_material;   

But I also need to view this selected mesh, somehow to rotate all to turn into view this. I tried some options without luck.

 viewer.camera.position.set(mesh);
 viewer.camera.lookAt(new THREE.Vector3());
 viewer.camera.lookAt(mesh.matrixWorld);

I found example with mouse coordinates but it's not the same. Author of jsmodeler did not respond in 2 weeks so I think I cannot wait for help there.

This is my rough example http://jsfiddle.net/536yb7kg/19/

There is a model. We want to select different parts of it by buttons. I added one button. After selection it highlights one mesh - make it semitransparent black. But we do not see this until we manually rotate this model. I need that it's not only highlighted but also rotates so we can see what we selected by button

  • Can you view the source code of jsmodeler and determine what's happening in a trace? – TinkerTenorSoftwareGuy Dec 11 '17 at 18:11
  • As I see this.viewer.camera.lookAt is just a normal three.js camera. But mesh.position is always (0,0,0). I tired all answers about getting mesh position but it didn't help. – Olga Koryakova Dec 11 '17 at 18:17
  • Did you try changing the values in the mesh manually during your trace and if so, did that solve the problem? If not, did you try rotating the mesh first, and passing it in to the camera? Just basic troubleshooting - not much else I can help with. – TinkerTenorSoftwareGuy Dec 11 '17 at 18:20
  • `this.viewer.camera.position.set(mesh);` That `.set()` method takes three parameters of `float`, `mesh` is not of that type. Maybe `this.viewer.camera.lookAt(mesh.position);` will help? – prisoner849 Dec 11 '17 at 18:35
  • I tried `this.viewer.camera.lookAt(mesh.position);` - nothing happens. position is always 0,0,0. For the same reason even if put floats in first call - nothing happened. I tried also `this.viewer.camera.rotateOnAxis(rotationAxis, angle);`. The only things which changes something is ` eye = new JSM.Coord(0.0, 0.0, -1.0); center = new JSM.Coord(0.0, 0.0, 0.0); up = new JSM.Coord(-1.0, 0.0, 0.0); this.viewer.cameraMove.Set(eye, center, up);` – Olga Koryakova Dec 11 '17 at 18:48
  • Just out of cusiousity, have you had a look at examples of this modeler? There are many of them in its distibutive from Git, and you can rotate objects (or camera around objects) easy in them. – prisoner849 Dec 11 '17 at 19:14
  • thanks for mentioning, I looked at all of them with cameras:( I easily can click on button with another camera like with code in my previous comment. But nothing that can connect selected mesh with camera. – Olga Koryakova Dec 11 '17 at 19:16
  • @OlgaKoryakova Could you create a live code example of what you're trying to achieve? – prisoner849 Dec 11 '17 at 19:21
  • @prisoner849 Added fiddle example in question description – Olga Koryakova Dec 12 '17 at 15:24
  • Are you trying to just rotate a mesh? – HariV Dec 12 '17 at 20:52
  • @HariV, I'm trying to turn into view selected mesh. Just like you do this with mouse. – Olga Koryakova Dec 13 '17 at 09:44

0 Answers0