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

227
Views
threejs cargando múltiples modelos GLTF con sus propias animaciones

Estoy tratando de recrear un salón de clases con estudiantes y muebles individuales. Debe ser un grupo individual de modelos que luego se pueden asignar a una base de datos para activar y desactivar a voluntad para simular quién asiste y quién falta en clase. Este es mi bloque de código para cargar un modelo de tres js nativo llamado "escritorio" y un modelo GLTF animado en la escena:

 import {GLTFLoader} from "./GLTFLoader.js" import * as THREE from 'three' var unit = new THREE.Group(); var deskGeometry = new THREE.BoxBufferGeometry(10, 2, 50 ); var deskMaterial = new THREE.MeshPhongMaterial({ color: 0x49311c, side: THREE.DoubleSide }); var desk = new THREE.Mesh(deskGeometry, deskMaterial); unit.add(desk); //IMPORT GLTF MODEL var loader = new GLTFLoader(); var clock, mixer; clock = new THREE.Clock(); loader.load("./models/salary/scene.gltf", function(gltf){ gltf.scene.traverse( function( node ){ if(node.isMesh){node.castShadow = true, node.receiveShadow = false;} }); //add and position the GLTF model var obj = gltf.scene; gltf.scene.scale.set( 8, 8, 8 ); gltf.scene.position.x = -10; gltf.scene.position.y = -5; gltf.scene.position.z = 3; gltf.scene.rotation.y = 1.07; scene.add(obj); unit.add(obj); // unit is part of an array that the model is nested in, //to create a THREE.group consisted of the student's desk, pc and the student //Playing Animation mixer = new THREE.AnimationMixer( gltf.scene ); console.log( gltf.animations ); mixer.clipAction( gltf.animations[ 0 ] ).play(); }); return unit; } function animate(){ requestAnimationFrame(animate); renderer.setAnimationLoop(()=>renderer.tick()); //for GLTF if ( mixer ) mixer.update( clock.getDelta() ); }

El código anterior también implica que el modelo GLTF es parte de un grupo de modelos llamado "unidad", y que hay modelos de tres js nativos mezclados. En un futuro cercano, deseo reemplazar "escritorio" con un modelo GLTF adecuado. Así que intenté usar la promesa para cargar varios modelos como este https://redstapler.co/load-multiple-model-three-js-promise/ , sin embargo, solo mostraba cómo importar modelos estáticos sin animaciones.

¿Cómo debo usar la promesa para cargar varias animaciones también, mientras están anidadas dentro de un grupo TRES?

about 4 years ago · Santiago Trujillo
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!