# Problem Loading Meshes with Textures

**URL:** <https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549>\
**Category:** Questions\
**Tags:** material\
**Created:** [March 28, 2020, 10:12pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549 "2020-03-28T22:12:48Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![aburbanol](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aburbanol/32/7213_2.png) [@aburbanol](https://forum.babylonjs.com/u/aburbanol)\
**Post date:** [March 28, 2020, 10:12pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/1 "2020-03-28T22:12:48Z")

</div>

I downloaded this [mesh (.gltf)](https://sketchfab.com/3d-models/low-poly-tree-wind-82ad872d9b994af9a6b74a453c03e01f) and I’m having problems visualizing it correctly in my game. I tried the following steps in order to understand, but I didn’t find any clue.

1. I used the [https://sandbox.babylonjs.com/](https://sandbox.babylonjs.com/) to check if it was complete.

> **Image .gtlf**
>
> ![Screenshot from 2020-03-28 16-22-06](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/9/9355af0d0634794456e58bc5bce496b628dcc879.png)

1. I exported the file using the sandbox to a .babylon fil, then I use sandbox to visualize the just created .babylon and I got this:

> **mesh .babylon**
>
> ![Screenshot from 2020-03-28 16-08-55](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/2/26cbb933dd0a1ec3c89bf534cfa5da43519c5b9e.png)

Here, you see the mesh in a different position and with a very different size and rotation (is losing some information from one format to another?)  
3. I use the assets manager and the SceneLoader.ImportMesh to import the .gtlf file and I got the mesh all black, with the animation working and I’m able to change the scale and the position.

> **Image loaded mesh from .gltf file**
>
> ![Screenshot from 2020-03-28 23-09-01](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/f/fd8377a66eeb5f91418a0adb6d950c712eaec1da.jpeg)

1. When I load the generated .babylon file, I got a huge mesh that I can not manipulate (change position or scale).

> **Image loaded mesh from .babylon file**
>
> ![Screenshot from 2020-03-28 23-03-39](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/6/60cd56d45bc2887de7eef7e903c9935a8f2a3c18.jpeg)

1. I used a loading example jus to try this mesh and be sure that was not realted with anything else.

> **Isolated load using load mesh example**
>
> ![Screenshot from 2020-03-28 16-07-37](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/7/751963c7f6885bec2d079d1e88f1fd2e3eaacd21.png)

How I can make the mesh has the original textures?  
Why there is strange behavior with the .babylon loaded mesh (position and scaling)?

---

<div class="post-metadata">

**Author:** ![gbz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gbz/32/23780_2.png) [@gbz](https://forum.babylonjs.com/u/gbz)\
**Post date:** [March 28, 2020, 10:51pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/2 "2020-03-28T22:51:47Z")

</div>

I think the unexpected position, rotation, and scaling when exporting to .babylon can be fixed by referring to [Mixamo - Babylon.js Documentation](https://doc.babylonjs.com/resources/mixamo_to_babylon). Search the phrase `Apply` on this linked page (Position, rotation xyz all need to be set to 0, and scaling xyz need to be set to 1).

Edit: Sketchfab allows you to download in .fbx format (as well as .gltf). I’d recommend using the .fbx format. Then you can follow the guide linked above, and you should get the result files below. You can try dragging the .babylon tree in the .zip file below in [https://sandbox.babylonjs.com/](https://sandbox.babylonjs.com/), and you should see your tree animating.

[tree.zip](https://forum.babylonjs.com/uploads/short-url/uF9MZ5Z0J6XW0XZG1QpblfCaZev.zip) (158.4 KB)

---

<div class="post-metadata">

**Author:** ![aburbanol](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aburbanol/32/7213_2.png) [@aburbanol](https://forum.babylonjs.com/u/aburbanol)\
**Post date:** [March 29, 2020, 12:19pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/3 "2020-03-29T12:19:11Z")

</div>

Woww @gbz thanks a lot for the time and effort you took to help me!

---

<div class="post-metadata">

**Author:** ![aburbanol](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aburbanol/32/7213_2.png) [@aburbanol](https://forum.babylonjs.com/u/aburbanol)\
**Post date:** [March 29, 2020, 1:38pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/4 "2020-03-29T13:38:04Z")

</div>

Dear @gbz, I still have problems with the .babylon loaded mesh with position and rotation, that I dont have with the .gltf file:

1. The is placed under the ground and still black:

> **code + image**
>
> > meshTask = assetsManager.addMeshTask(“t02”, “”, “scenes/low\_poly\_tree\_wind/”, “tree.babylon”);  
> > meshTask.onSuccess = function (task) {  
> > console.log(task);  
> > task.loadedMeshes[0].parent = scene.getMeshByName(“ground”);  
> > var x=45;  
> > let z=45;  
> > var y = ground.getHeightAtCoordinates(x, z);  
> > task.loadedMeshes[0].position= new BABYLON.Vector3(x, y, z);  
> > }
> 
> ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/5/50b3fdf20b9ff88d0949fed11633bf93b2dbb700.jpeg)

1. About the files you sent me back, the .babylon is loading in the Sandbox correctly, but when I open it the one on Blender, It has no textures (Is the first time I use Blender), Is it normal?.  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/8/835dd2cb73586874344f94d6e5ea301fd252f77e.jpeg)

---

<div class="post-metadata">

**Author:** ![gbz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gbz/32/23780_2.png) [@gbz](https://forum.babylonjs.com/u/gbz)\
**Post date:** [March 29, 2020, 7:35pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/5 "2020-03-29T19:35:51Z")

</div>

> [@aburbanol](#):
>
> assetsManager

Response to Question 1:  
Could you try creating a Babylon Playground reproducing this issue?

Loading the .babylon file exported from the .fbx file in Blender using AssetManager should load the tree into the scene upright with the tree’s base at (0, 0, 0) I think. And I’d expect setting its position to `new BABYLON.Vector3(x, y, z)` to move it to the desired location…

Answering Question 2:  
The white color in Blender is normal. In the Youtube video sent, I had to change the materials due to a .babylon export error. You can show colors in the `Viewport Display` as shown in the image below:

 ![Screenshot (527) - Copy](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/2/25be2dbddf9ef6986a543f8d29dac5749c761965.jpeg)  
The `Viewport Display` color is not the same as the Material’s `Base Color`. The `Base Color` is exported into the .babylon file. The `Viewport Display` has white color as default.

---

<div class="post-metadata">

**Author:** ![aburbanol](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aburbanol/32/7213_2.png) [@aburbanol](https://forum.babylonjs.com/u/aburbanol)\
**Post date:** [March 31, 2020, 2:42pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/6 "2020-03-31T14:42:29Z")

</div>

Thanks @gbz again. I have been stuck for 5 days to put a simple 3D model. I followed your advice to pass to the PG ([here](https://playground.babylonjs.com/#YB006J#206)) where I could reproduce that the loaded mesh can not be positioned (task02), but an Instance of it can (task1). Does this make sense to you? check out under the terrain that there is this loaded tree of the second task, but not where I placed it.

> **Summary**
>
> ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/e/e4bf939af8030b13ca73af9edf86217f5061af1d.jpeg)

btw, I could not reproduce the black surface as it is happening locally (self-hosted web).

---

<div class="post-metadata">

**Author:** ![gbz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gbz/32/23780_2.png) [@gbz](https://forum.babylonjs.com/u/gbz)\
**Post date:** [March 31, 2020, 10:39pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/7 "2020-03-31T22:39:51Z")

</div>

@aburbanol, I couldn’t figure this out yet, but I added two console.log() statements in [https://playground.babylonjs.com/#YB006J#210](https://playground.babylonjs.com/#YB006J#210).

I hope someone else who has more experience with `.position` and `.absolutePosition` can help out here. I included a comment `// source of problem!` in the above playground.

`newMeshes[0].position` is equal to (45, 1.35, 45) as expected, but `newMeshes[0].absolutePosition` is equal to (0, 0, 0). I tried using `.setAbsolutePosition()`, but didn’t seem to work.

@Deltakosh

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [March 31, 2020, 10:54pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/8 "2020-03-31T22:54:52Z")

</div>

Hey!

absolutePosition is evaluated during mesh.computeWorldMatrix()

So you can either call this function or call getAbsolutePosition() which will do it for you:  
[https://playground.babylonjs.com/#YB006J#211](https://playground.babylonjs.com/#YB006J#211)

---

<div class="post-metadata">

**Author:** ![gbz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gbz/32/23780_2.png) [@gbz](https://forum.babylonjs.com/u/gbz)\
**Post date:** [April 1, 2020, 3:17am UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/9 "2020-04-01T03:17:31Z")

</div>

Thank you, @Deltakosh!

In the playground you provided, `newMeshes[0].position` is equal to (45, 1.35, 45), but `newMeshes[0].getAbsolutePosition()` is equal to (0, 0, 0). We’re hoping to get the absolute position to equal position (45, 1.35, 45).

Edit: Just did `console.log(newMeshes[0])`, and saw these. Not sure if relevant ![Screenshot (574) - Copy](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/5/527a3218cafb1f1e029f7e5a83a95fc069649b3c.png) ![Screenshot (575) - Copy](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/b/bd2e1a7adadcb56d8d4a958749fedbf521d368a2.png)

---

<div class="post-metadata">

**Author:** ![aburbanol](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aburbanol/32/7213_2.png) [@aburbanol](https://forum.babylonjs.com/u/aburbanol)\
**Post date:** [April 1, 2020, 8:27am UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/10 "2020-04-01T08:27:42Z")

</div>

Hi guys,

I dont know if it is relevant or not, but my work around is that the original mesh loaded is not possible to manipulate (Is it a bug?), However, if you create a new instance `var newInstance = newMeshes[0].createInstance("i" + index);` you can manipulate its position and rotation.

> **Image with manipulated .babylon meshes**
>
> ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/8/8af67df8b544e1b8864c2cab59f27e76798ae5c4.jpeg)

Thanks to @gbz explanations, I downloaded a couple of models, edit them in Blender and exported to “.babylon” and I’m able to place them every I want with different positions and scales. What worries me, is if I need to load several models and I have to duplicate them all, is going to deteriorate my apps performance.

On the other hand, the .gtlf behavior is different. You can manipulate the rotation, scale and position, but the material is always black.

---

<div class="post-metadata">

**Author:** ![gbz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gbz/32/23780_2.png) [@gbz](https://forum.babylonjs.com/u/gbz)\
**Post date:** [April 1, 2020, 8:35am UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/11 "2020-04-01T08:35:22Z")

</div>

@aburbanol, have you tried using `BABYLON.SceneLoader.ImportMesh` from this [documentation](https://doc.babylonjs.com/how_to/load_from_any_file_type#sceneloaderimportmesh) instead of `BABYLON.AssetsManager.addMeshTask`? I haven’t had too much issues with `ImportMesh`, and I haven’t used `addMeshTask` before. Also there is `ImportMeshAsync` to [load assets in parallel](https://doc.babylonjs.com/how_to/promises).

Also, I think your approach using `createInstance` is a good idea according to the [documentation](https://doc.babylonjs.com/how_to/how_to_use_instances), since you might be creating many trees.

---

<div class="post-metadata">

**Author:** ![aburbanol](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aburbanol/32/7213_2.png) [@aburbanol](https://forum.babylonjs.com/u/aburbanol)\
**Post date:** [April 1, 2020, 8:40am UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/12 "2020-04-01T08:40:22Z")

</div>

Yes, I tried with both and had the same result, you can’t manipulate the first. I did the experiment in the same scene loading with both approaches.

I prefer to use `BABYLON.AssetsManager`, because it allows me to control the loading, change the message, etc.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 1, 2020, 4:05pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/13 "2020-04-01T16:05:30Z")

</div>

Ok my bad…here is the correct one: [https://playground.babylonjs.com/#YB006J#217](https://playground.babylonjs.com/#YB006J#217)

---

<div class="post-metadata">

**Author:** ![aburbanol](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aburbanol/32/7213_2.png) [@aburbanol](https://forum.babylonjs.com/u/aburbanol)\
**Post date:** [April 1, 2020, 4:51pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/14 "2020-04-01T16:51:34Z")

</div>

@Deltakosh, I’m so sorry but when I see that exxample there is the same problem. The 2 tree you can see are from the other task. The lin 171 `console.log(newMeshes[0].getAbsolutePosition())` still print (0,0,0) and the tree is under the ground.  
@Deltakosh Do you have a different result in your browser? Can you see 3 trees on the ground?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 1, 2020, 5:08pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/15 "2020-04-01T17:08:44Z")

</div>

Ok for some reasons, it works only when you click twice on RUN.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/8/8cb1f7fa567f36f0d521e4a8ff767a013f646c60.png)

---

<div class="post-metadata">

**Author:** ![aburbanol](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aburbanol/32/7213_2.png) [@aburbanol](https://forum.babylonjs.com/u/aburbanol)\
**Post date:** [April 2, 2020, 1:07pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/16 "2020-04-02T13:07:56Z")

</div>

Therefore is a bug? I’m planning to host this page so there will not be a ‘play’ button.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 2, 2020, 3:43pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/17 "2020-04-02T15:43:38Z")

</div>

No I meant: it is probably a cache issue linked to the PG itself. It will work flawlessly locally

---

<div class="post-metadata">

**Author:** ![Amal\_Duriseti](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/amal_duriseti/32/14314_2.png) [@Amal\_Duriseti](https://forum.babylonjs.com/u/Amal_Duriseti)\
**Post date:** [October 8, 2021, 10:52pm UTC](https://forum.babylonjs.com/t/problem-loading-meshes-with-textures/9549/18 "2021-10-08T22:52:10Z")

</div>

@aburbanol - this is probably 2 late for u

but for anyone encountering this problem - the babylon playground default scene spawns with light already constructed - if u are loading a mesh locally it will appear black unless you also spawn a light even if the textures are properly loaded and applied

code:

```auto
var scene = new BABYLON.Scene(engine);
new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), scene);
BABYLON.SceneLoader.ImportMesh(...)

```
