Doubt about viewer.camera.set

My problem is that when adding another position the camera does not execute anything for me.

image

Hello @Jose_Antonio_Ordoñez

Can you check the data that you receive from the output? Maybe there is something wrong with it.

I just created an example and from my side it seems to work.

Cheers, Michael

Hello @MajorMeerkatThe3rd

This first function works for me.

var puertas = session.getOutputByName("puertas").find((o) => o.material !== undefined);
  var vec = [];
  vec[0] =  puertas.node.children[1].boundingBox.max[0];
  vec[1] = puertas.node.children[1].boundingBox.max[1];
  vec[2] = puertas.node.children[1].boundingBox.max[2];
  var cam = vec;
viewer.camera.set([ puertas.node.children[1].boundingBox.max[0],-3562+1500,1240-700],vec,{duration:2000});

But not this second:

var casco = session.getOutputByName("casco").find((o) => o.material !== undefined);
var opc = viewer.camera.calculateZoomTo(casco.node.boundingBox);
opc.position[1]=opc.position[1]-1000;
viewer.camera.set(opc.position,opc.target,{duration:2000});

Hello @Jose_Antonio_Ordoñez,
can you specify what doesn’t work for you?
Cheers

The first function that makes the camera move works for me but the second one returns a promise false and does not execute it.

Hello @Jose_Antonio_Ordoñez,

I don’t know about you data, therefore it is hard for me to evaluate what went wrong. What you can check is if the bounding box has valid data in it. If it doesn’t, call api.update() in between and see if that works. Maybe a render call has to be done before the data is correct, but again, hard to evaluate from my side.

Cheers, Michael

Hello @MajorMeerkatThe3rd
I don’t know how to show you the problem, it doesn’t let me execute any camera function, nor reset, zoomTo…
Always returns the same:
viewer.camera.reset() Promise {<fulfilled>: false}

Hello @Jose_Antonio_Ordoñez,
unfortunately there is no way for us to reproduce this issue like that. Please provide a code example (with codesandbox, codepen or something similar) with the model in question so that we can reproduce this issue.
Cheers, Michael