# Load model via string variable

**URL:** <https://discourse.threejs.org/t/load-model-via-string-variable/15127>\
**Category:** Questions\
**Tags:** loaders\
**Created:** [May 12, 2020, 2:05pm UTC](https://discourse.threejs.org/t/load-model-via-string-variable/15127 "2020-05-12T14:05:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jedinger](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/jedinger/32/11158_2.png) [@jedinger](https://discourse.threejs.org/u/jedinger)\
**Post date:** [May 12, 2020, 2:05pm UTC](https://discourse.threejs.org/t/load-model-via-string-variable/15127/1 "2020-05-12T14:05:53Z")

</div>

Hi there!

I want to load my models in a more dynamically way via a txt file that contains the urls to the models.

So I’m trying to load my models via string variables containing the url that comes from a XMLHttpRequest of the txt file, instead of declaring the actual url in the load function.

Somehow [this](https://jsfiddle.net/ozaud0bp/18/) doesn’t work, can somebody help? 🙂

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [May 12, 2020, 2:34pm UTC](https://discourse.threejs.org/t/load-model-via-string-variable/15127/2 "2020-05-12T14:34:53Z")

</div>

This works:  
`var path = "https://threejs.org/examples/models/fbx/Samba Dancing.fbx";`

---

<div class="post-metadata">

**Author:** ![jedinger](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/jedinger/32/11158_2.png) [@jedinger](https://discourse.threejs.org/u/jedinger)\
**Post date:** [May 13, 2020, 8:32am UTC](https://discourse.threejs.org/t/load-model-via-string-variable/15127/3 "2020-05-13T08:32:01Z")

</div>

Thank you! If I try the [same with GLTF](https://jsfiddle.net/mb3zsLyu/) I get a strange error.

Can you help? 🙂

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [May 13, 2020, 8:46am UTC](https://discourse.threejs.org/t/load-model-via-string-variable/15127/4 "2020-05-13T08:46:34Z")

</div>

These lines will help:

```auto
camera.position.set(0, 0, 10);
camera.lookAt(scene.position);

```

1. Your camera is not looking at the model, which is at the center of the scene. The camera is at [0, 80, 150] and looks at the global direction [0, 0, -1]. It’s far above the object and thus the object is not in the camera view/frustum.
2. Your camera is far from the model, so the model is too small on the screen. Put it closer to the object.

---

<div class="post-metadata">

**Author:** ![jedinger](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/jedinger/32/11158_2.png) [@jedinger](https://discourse.threejs.org/u/jedinger)\
**Post date:** [May 13, 2020, 9:08am UTC](https://discourse.threejs.org/t/load-model-via-string-variable/15127/5 "2020-05-13T09:08:03Z")

</div>

Thank you for this 🙂  
But why do it get this error: ‘THREE.WebGLProgram: gl.getProgramInfoLog() C:\fakepath(246,23-154): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them’?
