simen-andresen
simen-andresen

Reputation: 2337

Forge Viewer - Cannot view multiple different models properly

I'm having trouble loading different models in the viewer. I suspect the problem comes from mixing up different units (meters and millimeters) in the models.

So I have 3 Models:

In order to load the models with the right coordinates I use the following options:

IFC 1 and 2:

{
    globalOffset: {x: 1000000, y: 100000, z: 7000},
    sharedPropertyDbPath: doc.getPropertyDbPath(),
}

Obj:

let mat = new THREE.Matrix4();
mat.makeTranslation(1000000, 100000,7000);

{
    placementTransform: mat,
    sharedPropertyDbPath: doc.getPropertyDbPath(),
}

The rationale here is that the IFC models are located far away from the origin, while the Obj model is located at origin. Using globalOffset for the IFCs seems necessary to get them to align in the viewer, using placementTransform is necessary to put the Obj close to the IFC models.

I'm struggling with the following problems here:

EDIT 1:

Looks like making the Obj cube the same size as the other models fixes the zooming problem. Also, if loading the IFC files first, the orientation navigation is right. It's only when loading the OBJ file first that we get the "y-up orientation" problem

Edit 2:

The orientation navigation problem can be fixed with viewer.navigation.setWorldUpVector(new THREE.Vector3(0,0,1), false);. Is it possible to also control behavior like this globally instead always letting the different models set the behavior?

Upvotes: 0

Views: 264

Answers (1)

Petr Broz
Petr Broz

Reputation: 9942

I think the last loaded model will always have precedence over any previously set world-up vector. So if you want to control the world-up globally, you'll need to use the viewer.navigation.setWorldUpVector method manually after all the models have been loaded.

Upvotes: 1

Related Questions