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

185
Views
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
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!