# Code debug with gsap

**URL:** <https://discourse.threejs.org/t/code-debug-with-gsap/25313>\
**Category:** Questions\
**Tags:** gsap\
**Created:** [April 13, 2021, 10:46am UTC](https://discourse.threejs.org/t/code-debug-with-gsap/25313 "2021-04-13T10:46:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![innovate](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@innovate](https://discourse.threejs.org/u/innovate)\
**Post date:** [April 13, 2021, 10:46am UTC](https://discourse.threejs.org/t/code-debug-with-gsap/25313/1 "2021-04-13T10:46:50Z")

</div>

Hello Folks,

need some debugging,  
trying to make the code as compact as it can,  
it complains about gsap not finding the 0 object,  
and my intuition tells me its the way i am allocating the meshes ,  
so any help would be appreciated

```javascript
let sTex =[],geometryM = [],materialM = [],sMeshes=[];

```

```javascript
  sTex.push(new THREE.TextureLoader().load("../images/100.png"));
  sTex.push(new THREE.TextureLoader().load("../images/200.png"));
  sTex.push(new THREE.TextureLoader().load("../images/300.png"));
  sTex.push(new THREE.TextureLoader().load("../images/400.png"));
  sTex.push(new THREE.TextureLoader().load("../images/500.png"));
  sTex.push(new THREE.TextureLoader().load("./images/600.png"));
  sTex.push(new THREE.TextureLoader().load("../images/700.png"));
  
  for (let sNum = 1; sNum < 7; sNum++) {

    geometryM.push(new THREE.PlaneBufferGeometry());
    materialM.push(new THREE.MeshLambertMaterial({ color: 0x37383b, map: sTex[sloshNum], transparent: true }));
    sMeshes.push(new THREE.Mesh(geometryM[sNum], materialM[sNum]));
    sMeshes.position = (0, -50, 0);
    scene.add(sMeshes);
  }

```

and here is the gsap method

```javascript
  for (let mLen = 1; mLen < 7; mLen++) {

    gsap.to(sMeshes.position, {
      duration: 1 ,
      x: 0,
      y: 0,
      z: -1
    });

```

---

<div class="post-metadata">

**Author:** ![mjurczyk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mjurczyk/32/10995_2.png) [@mjurczyk](https://discourse.threejs.org/u/mjurczyk)\
**Post date:** [April 13, 2021, 11:33pm UTC](https://discourse.threejs.org/t/code-debug-with-gsap/25313/2 "2021-04-13T23:33:41Z")

</div>

> [@innovate](#):
>
> `sMeshes.position`

Since meshes is an array, not a single `Three.Mesh` - isn’t `.position` simply undefined 🤔 ?  
On the other hand, `sMeshes[mLen].position` might be what you’re looking for.

---

<div class="post-metadata">

**Author:** ![innovate](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@innovate](https://discourse.threejs.org/u/innovate)\
**Post date:** [April 14, 2021, 11:00am UTC](https://discourse.threejs.org/t/code-debug-with-gsap/25313/3 "2021-04-14T11:00:30Z")

</div>

Hi mjurczyk,

thanks for that ,

there were several issues with the code that i wrote earlier ,  
there were the mighty typos in the texture names ,

secondly i was trying to access a non instanced geometry ,  
and accessing this is the gsap module, which you had aptly pointed out ,

all fixed and its working as it should ,

```javascript
let meshArray = [], sTex =[] ,geometryM , materialM , sMeshes;

```

```javascript
  sTex.push(new THREE.TextureLoader().load("../images/100.png"));
  sTex.push(new THREE.TextureLoader().load("../images/200.png"));
  sTex.push(new THREE.TextureLoader().load("../images/300.png"));
  sTex.push(new THREE.TextureLoader().load("../images/400.png"));
  sTex.push(new THREE.TextureLoader().load("../images/500.png"));
  sTex.push(new THREE.TextureLoader().load("./images/600.png"));
  sTex.push(new THREE.TextureLoader().load("../images/700.png"));
  
  for (let sNum = 0; sNum < 6; sNum++) {

    geometryM = new THREE.PlaneBufferGeometry();
    materialM = new THREE.MeshLambertMaterial({ color: 0x37383b, map: sTex[sloshNum], 
     transparent: true });
    sMeshes = new THREE.Mesh(geometryM[sNum], materialM[sNum]);
    sMeshes.position.set(0, -50, 0);
    meshArray.push(sMeshes);
    scene.add(sMeshes);
  }

```

and i access meshArray.foreach() loop and set the position for the required using gsap.to,

works fine

thanks,
