Code debug with gsap

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

let sTex =[],geometryM = [],materialM = [],sMeshes=[];
  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

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

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

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

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 ,

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

  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,