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

210
Views
(Threejs Model Project) Cómo activar la animación sin hacer clic

Actualmente tiene modelo de coche three.js. Las puertas del coche se abren al hacer clic. Mi objetivo es cambiar esta función a donde se abren en función de una declaración verdadera o falsa. 'Si es verdadero, comienza la animación de apertura de la puerta'. Si es falso, comienza la animación de cierre de la puerta'. ¿Cómo hago para cambiar la forma en que funciona esta función?

Esto es lo que tengo ahora mismo. Se dispara cuando se hace clic.

 const MOVABLE_PARTS = { bonnet_ok_primary_0: { isOpen: false, type: 'rotation', axis: 'x', offset: Math.PI / 3, }, boot_dummy: { isOpen: false, type: 'rotation', axis: 'x', offset: -Math.PI / 6, }, door_lf: { isOpen: false, type: 'rotation', axis: 'z', offset: -Math.PI / 3, }, door_lr: { isOpen: false, type: 'rotation', axis: 'z', offset: -Math.PI / 3, }, door_rf: { isOpen: false, type: 'rotation', axis: 'z', offset: Math.PI / 3, }, door_rr: { isOpen: false, type: 'rotation', axis: 'z', offset: Math.PI / 3, }, door_lf_glass0_0: { isOpen: false, type: 'position', axis: 'z', offset: -0.2, }, door_lr_glass0_0: { isOpen: false, type: 'position', axis: 'z', offset: -0.2, }, door_rf_glass0_0: { isOpen: false, type: 'position', axis: 'z', offset: -0.2, }, door_rr_glass0_0: { isOpen: false, type: 'position', axis: 'z', offset: -0.2, }, }; type MovablePartName = keyof typeof MOVABLE_PARTS; const MOVABLE_PART_NAMES = Object.keys(MOVABLE_PARTS); const selectControls = new SelectControls( [this.model], this.camera, this.canvas ); selectControls.addEventListener('select', (event) => { const e = event as SelectEvent; if (e.object) { const obj = e.object; this.model.handleClick(obj); const pos = new Vector3(); obj.getWorldPosition(pos); // eslint-disable-next-line no-console console.info(obj.name, obj.position.toArray(), pos.toArray(), obj); } }); selectControls.activate(); togglePart(name: MovablePartName) { const part = this._movableParts[name]; const target = this._root?.getObjectByName(name); if (part && target) { if (!part.isOpen) { part.isOpen = true; new Tween(target) .to({ [part.type]: { [part.axis]: part.offset } }, 500) .start(); } else { part.isOpen = false; new Tween(target).to({ [part.type]: { [part.axis]: 0 } }, 500).start(); } } } handleClick(obj: Object3D) { let target: Object3D | null = obj; while (target !== null && !MOVABLE_PART_NAMES.includes(target.name)) { if (target.parent) { target = target.parent; } else { target = null; break; } } if (target) { const name = target.name as MovablePartName; this.togglePart(name); } }
about 4 years ago · Juan Pablo Isaza
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!