Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
cómo solucionar este error: no detectado (en promesa) TypeError: no se pueden leer las propiedades de undefined (leyendo 'longitud')

Estoy creando un sitio web cargando modelos gltf 3d. Quiero cargar más modelos usando loop.

 const loader = new GLTFLoader() //.setPath( 'models/gltf/DamagedHelmet/glTF/' ); .setPath( 'resources/' ); const resourceData = ["Learning Bee1","Learning Bee2","Learning Bee3"]; //const l = resourceData.length; for(let i=0; i<resourceData.length;i++){ let oResource = resourceData[i]; let sModelName = oResource + ".gltf"; loader.load( sModelName, function ( gltf ) { gltf.scene.traverse( function ( child ) { if ( child.isMesh ) { roughnessMipmapper.generateMipmaps( child.material ); } }); }); scene.add( gltf.scene ); roughnessMipmapper.dispose(); render(); } });

Cuando ejecuto esto, se muestra a continuación el error. ¿Cómo soluciono esto?

three.module.js:38723 Uncaught (en promesa) TypeError: No se pueden leer las propiedades de undefined (leyendo 'longitud') en three.module.js:38723

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La sangría de su código es un poco descuidada y le hace cometer errores que podrían evitarse con un código más limpio.

  1. Estás llamando a gltf.scene fuera de los corchetes, donde no existe:
 loader.load( sModelName, function ( gltf ) { // gltf exists here }); // gltf does not exist here scene.add( gltf.scene );
  1. Deseche el roughnessMipmapper antes de usarlo. Tenga en cuenta que la función de devolución de llamada en el cargador tarda un tiempo en ejecutarse, ya que está esperando para terminar de cargar su activo.
 loader.load( sModelName, function ( gltf ) { // 2. This happens later, after assets load roughnessMipmapper.generateMipmaps( child.material ); }); // 1. This gets called first roughnessMipmapper.dispose();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!