Stuck on finding the correct orientation of a mesh lookAt() and mesh disappearing when approaching it


Playground link:

Really have trouble understanding on how to orient my meshes so I won’t have to fiddle with the lookAt() yay,pitch and roll corrections which I can’t figure again.

Also the mesh disappears when the camera approaches it.

So your mesh disappears because the skeleton moves the vertices from their original place:

Skeleton are computed on GPU side, so the CPU has no idea where the vertices will end up being. It uses bounding boxes to eliminate hidden faces.

I highly recommend that your skeleton let the vertices unchanged from a position standpoint (ie. you should not have to do skull.position.y = -8)

Other option (not recommender) is to callmesh.refreshBoundingInfo(true) on all meshes so the CPU is aware of where the vertices are

1 Like

This model and others I have are created by someone else since I don’t possess modeling skills.

So I guess I am out of lack since I don’t get exactly what you mean.

At least what about the look.At() function. Any idea about the suitable corrections ?

Can you ask them to center the models?

1 Like

Hmm I’m afraid this is not possible as I downloaded them from a random website.

I tried something different though as seen in the following playground :

I used the root node of the glb file and everything works nicely.

Though because of the skeleton being a part of an actual bigger scene in my real project I can’t use root directly cause it’s gonna affect all the other meshes that are submeshes of the root node.

So I’m thinking I could do it with one of the following two ways:

  1. Make the Skeleton node parentless. Create new parent that is more suitable for it, which I don’t know right now what properties it would have. At first I thought that I could clone the already present root node, make skeleton node parentless(detach from the original root node) and make the cloned one it’s parent but that probably not gonna work correctly.

  2. Import the Skeleton glb as a separate file from my whole other scene. That is gonna work alright BUT that creates the problem of me not being able to create my scene freely positioning enemies however I want them with blender since I will load the separate scene files via code like :

    assetsManager.addMeshTask("task2", "", "../assets/models/", "scene.glb");
    assetsManager.addMeshTask("task3", "", "../assets/models/", "Skeleton.glb"); 

Any input will be so valuable.


Loading the Skeleton.glb file separately from the rest of the scene/level and then adjusting its position manually with code using its root for all the transformations etc works perfectly but adjusting the position on the scene manually is a really pain in the ass since I have to “guess” where to place it.

If there are any other ways to do this please care to mention it. Right now I’m thinking to place empty meshes in blender with names like “Skeleton1” “Skeleton2” etc and when I load the Skeleton.glb file Ι will instance the mesh in said empty mesh’ position, but I don’t know if this is the most efficient way to do it.

scene.getTransformNodeByName(“SkeletonArmature”).parent.position.x = 18;
scene.getTransformNodeByName(“SkeletonArmature”).parent.position.y = 0;
scene.getTransformNodeByName(“SkeletonArmature”).parent.position.z = 1.5;

it is definitely a good idea. Also I recommend you to use the Inspector to help place your meshes with the gizmos :wink:

1 Like

Correct me if I’m wrong but these changes with the gizmos won’t carry to live version or when the the browser is reloaded. Except if I export the scene again via the inspector but then the animations won’t be exported too.

Right, I was more saying that from a placement standpoint . but you are right, you need them to report the changes in your code

1 Like

I guess I can hack something like export the positions of them in the inspector in a txt file(or just manually write them down) that the code will read OR just do it in the Blender way I described.

I chose the later and it works. Feels weird and like I’m doing something that is not supposed to be done but works.

1 Like

That’s the problem when we don’t have an artist (I’m lucky to have the almighty @PatrickRyan) :smiley:


@HappyDev I would always suggest going into a DCC tool (Blender, Maya, Max, Modo, etc.) to make corrections in your meshes in terms of position or scale. When you are working on a complex project with a lot of assets, making corrections to these types of problems in code will bloat your project and become untenable at some point. And when you come back to this six months later, you will have to unwind why you are doing all of this extra work until you remember that you had problems in the source file.

Granted, making changes in DCC tools isn’t always straight forward, especially when you have a rigged model that you did not make or have access to the author. You can spend a lot of cycles unwinding how a rig works and what can break when making changes. If you have budget, I would always suggest hiring an artist to fix the assets for you. If not, there are a lot of tutorials for Blender that can help you do some of this work, but it is a lot of new context to take on so I would suggest starting small and working up to being comfortable with more complex and rigged assets. Hope this helps in some way.

1 Like