я написал код, можно ли его сократить, используя object3D..traverse()?
код:
import { WebGL1Renderer, Scene, PerspectiveCamera, DirectionalLight, DoubleSide, ShaderMaterial, Clock, AnimationMixer, PointLight, PCFSoftShadowMap, ACESFilmicToneMapping } from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { gsap } from 'gsap';

const model = 'card-animation.glb';

const renderer = new WebGL1Renderer({ antialias: true, alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = PCFSoftShadowMap;
renderer.toneMapping = ACESFilmicToneMapping;
document.body.appendChild(renderer.domElement);

const scene = new Scene();
const camera = new PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 1000 );
camera.position.set(7,3.4,0);

function addLight(light) {
  light.shadow.mapSize.width = 1000;
  light.shadow.mapSize.height = 1000;
  light.shadow.blurSamples = 25; 
  scene.add(light);
}

const directionalLight = new DirectionalLight(0x807F8A, 15);
directionalLight.position.set(-3, 7, 5);
directionalLight.castShadow = true;  
addLight(directionalLight);

const directionalLight2 = new DirectionalLight(0x807F8A, 5);
directionalLight2.position.set(6, 2, 3);
addLight(directionalLight2);

const pointLight = new PointLight(0xffffff, 25);
pointLight.position.set(7,6,0);

const lightArr = [directionalLight, directionalLight2, pointLight];
lightArr.forEach(element => {
  addLight(element);
});

let modelWithCard;
new GLTFLoader().load( model, ( gltf ) => {
  modelWithCard = gltf.scene;
  const animations = gltf.animations;
  const mixer = new AnimationMixer(modelWithCard);
  let realTime = 0;
  let arrLastFrame = [];

  for (let i = 0; i < animations.length; i++) {
    const clip = animations[i];
    const clipTracks = clip.tracks;
    for (let j = 0; j < clipTracks.length; j++) {
      const clipLength = clip.tracks[j].times.length-1;
      const lastFrame = clip.tracks[j].times[clipLength];
      arrLastFrame.push(lastFrame);
    }
  }
  
  let maxLastFrame = 0;
  arrLastFrame.forEach(element => {
    if (element > maxLastFrame) {
      maxLastFrame = element;
    }
  });

  function animationPlay(targetAction, realTime, clip) {
    mixer.clipAction(clip).play();
    gsap.to(targetAction, {
      time: realTime,
      duration: 0.7,
      ease: 'power5.Out'
    });
    targetAction.paused = true;
  }

  function onMouseWheel(event) {
    realTime += 0.2*Math.sign(event.deltaY);
    for (let i = 0; i < animations.length; i++) {
      const clip = animations[i];
      for (let j = 0; j < clip.tracks.length; j++) {
        const targetAction = mixer.clipAction(clip);
        if (realTime > maxLastFrame) {
          realTime = maxLastFrame;
        } else if (realTime < 0) {
          realTime = 0;
        }
        animationPlay(targetAction, realTime, clip);
      }
    }
  }
  
  window.addEventListener('wheel', onMouseWheel, false);
  const array = modelWithCard.children;
  for (let i = 0; i < array.length; i++) {
    if (modelWithCard.children[i].type == 'Mesh') {
      modelWithCard.children[i].material.side = DoubleSide;
      modelWithCard.children[i].castShadow = true;
      modelWithCard.children[i].receiveShadow = true;
    }
    if (modelWithCard.children[i].name == 'Cube001') {
      modelWithCard.children[i].material = new ShaderMaterial({
        fragmentShader: `
        void main() {
          gl_FragColor = vec4(1.0);
        }`
      });
    }
  }
  scene.add( modelWithCard );
  
  const clock = new Clock();
  function render() {
    const deltaTime = clock.getDelta();
    mixer.update(deltaTime/10);

    if (resizeRendererToDisplaySize(renderer)) {
      canvas = renderer.domElement;
      camera.aspect = canvas.clientWidth / canvas.clientHeight;
      camera.updateProjectionMatrix();
    }
    camera.lookAt(0,4.5,0);
    renderer.render( scene, camera );
    requestAnimationFrame(render);
  }
  render();
});

function resizeRendererToDisplaySize(renderer) {
  const canvas = renderer.domElement;
  const width = canvas.clientWidth;
  const height = canvas.clientHeight;
  const needResize = canvas.width !== width || canvas.height !== height;
  if (needResize) {
    renderer.setSize(width, height, false);
  }
  return needResize;
}