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

180
Vistas
Three js use renderer into data (vue)

I'm trying to mix ThreeJS and Vue2 in order to make something cool

But I'm experiencing a problem, I'll first set up the context.

I have all my ThreeJS instances in the mounted() state, when it's loaded, it's clear and there's no problem, but when I decide to switch to another page, and come back multiple times, it reloads every time the ThreeJS instances, making big memory leaks and eventually, crashing the app.

I founded a way to clean all the mess by cleaning the rendering at the destroyed() Vue state, but here I am :

All my data are stored in mounted, and trying to switch the render variable into the data doesn't work at all, so I just can't call my rendering variables into the destroyed() state, making it impossible to clear the scene.

Is anyone have a clue about how to solve this problem? Thanks a lot ^.^

Here's some code to set up a bit more the context

  data: function(){
      return{
          renderer: "",
      }
  },

  mounted(){

[...]

         function init() {
                
                container = document.querySelector( '#background' );
                this.renderer = new THREE.WebGLRenderer({
                    canvas: document.querySelector("#background")
                }); 

                 // Here is the problem ^

[...]

},

  destroyed(){
      
                console.log('dispose renderer!')
                this.renderer.dispose()
                
                // Can't call this.renderer as it's null or not defined because of the crash in mounted
                [...]

}

about 4 years ago · Juan Pablo Isaza
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