Jump to content

babylon viewer


AhmadAli
 Share

Recommended Posts

Hello guys,

I made a viewer using babylon, my viewer is support .babylon and .obj and everything is good. but i have an issue:

- the babylon file have scale 1 but it so small in scene

- the obj file has the same scale but it so big in scene

I need the same size for all model that i view.

please help

Link to comment
Share on other sites

The only way you can do it is by creating an invisible mesh parent which will hold the loaded obj models, since there are some obj models out there that contain more that one mesh, and often they do not have the same scaling factor. After that you should set the scaling of each mesh to  :

parent.getBoundingInfo().boundingBox.extendSize;

Here is an example :

var container = BABYLON.Mesh.CreateBox("ObjParent", 1, scene);
container.position = new BABYLON.Vector3(myposZ,myposY,myposZ);
container.rotation = new BABYLON.Vector3(0,0,0);
container.scaling = new BABYLON.Vector3(myscalingX,myscalingY,myscalingZ);


var OBJ = loader.addMeshTask("ObjLoader", "", "", "batman.obj");
OBJ.onSuccess = function (t) {

	t.loadedMeshes.forEach(function (m, i) {
		m.parent = container;
		m.scaling = container.getBoundingInfo().boundingBox.extendSize;
		m.position = new BABYLON.Vector3(0,0,0); // Put at the origin of the parent

	});
};

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...