Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
ThreeJS: al hacer clic en mover la cámara no funciona

Soy nuevo con ThreeJS, así que espero que alguien pueda ayudar.

Estoy tratando de mover mi cámara cuando hago clic en el botón, pero no pasa nada y no tengo errores.

Esta es la función que tengo que debería mover la cámara 200 en todas las direcciones, pero no tiene ese efecto:

 var button = document.getElementById("button"); button.addEventListener("click", function() { var tween1 = new TWEEN.Tween(camera.position) .to({ x : 200, y : 200, z : 200 } , 1000) .easing(TWEEN.Easing.Linear.None) .start(); });

¿Qué estoy haciendo mal?

Aquí está el script completo de ThreeJS para un mejor contexto:

 var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 ); camera.position.z = 4; var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); var controls = new THREE.OrbitControls(camera, renderer.domElement); controls.enableDamping = true; controls.dampingFactor = 0.25; controls.enableZoom = true; var keyLight = new THREE.DirectionalLight(new THREE.Color('hsl(30, 100%, 75%)'), 1.0); keyLight.position.set(-100, 0, 100); var fillLight = new THREE.DirectionalLight(new THREE.Color('hsl(240, 100%, 75%)'), 0.75); fillLight.position.set(100, 0, 100); var backLight = new THREE.DirectionalLight(0xffffff, 1.0); backLight.position.set(100, 0, -100).normalize(); scene.add(keyLight); scene.add(fillLight); scene.add(backLight); var mtlLoader = new THREE.MTLLoader(); mtlLoader.setTexturePath('assets/'); mtlLoader.setPath('assets/'); mtlLoader.load('r2-d2.mtl', function (materials) { materials.preload(); var objLoader = new THREE.OBJLoader(); objLoader.setMaterials(materials); objLoader.setPath('assets/'); objLoader.load('object.obj', function (object) { scene.add(object); object.position.y -= 0; }); }); var animate = function () { requestAnimationFrame( animate ); controls.update(); renderer.render(scene, camera); }; animate(); var button = document.getElementById("button"); button.addEventListener("click", function() { var tween1 = new TWEEN.Tween(camera.position) .to({ x : 200, y : 200, z : 200 } , 1000) .easing(TWEEN.Easing.Linear.None) .start(); });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Lo primero que debe hacer, cuando trabaja con Tween.js, es agregar

TWEEN.update()

a su bucle de animación.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda