Created
August 8, 2017 11:58
-
-
Save tobiasWenger/70fcf110ceec3cd39b77cb9c8915f762 to your computer and use it in GitHub Desktop.
three.js - memory leak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| didInsertElement() { | |
| this._super(...arguments); | |
| const container = this.$('.webgl-container'); | |
| const renderer = new THREE.WebGLRenderer( { antialias: true, alpha: true } ); | |
| renderer.setSize( container.width(), container.height() ); | |
| container.append( renderer.domElement ); | |
| this.set('webGLRenderer', renderer); | |
| const camera = new THREE.PerspectiveCamera(); | |
| const scene = new THREE.Scene(); | |
| renderer.render( scene, camera ); | |
| }, | |
| willDestroyElement() { | |
| const renderer = this.get('webGLRenderer'); | |
| renderer.forceContextLoss(); | |
| renderer.context = null; | |
| renderer.domElement = null; | |
| this._super(...arguments); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| showChild: false, | |
| actions: { | |
| start() { | |
| const interval = setInterval(() => { | |
| this.toggleProperty('showChild'); | |
| }, 200); | |
| this.set('interval', interval); | |
| }, | |
| stop() { | |
| clearInterval(this.get('interval')); | |
| } | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| margin: 12px 16px; | |
| font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
| font-size: 12pt; | |
| } | |
| .webgl-container { | |
| width: 200px; | |
| height: 200px; | |
| border: 1px solid black; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "0.12.1", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": false, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "threejs": "https://cdnjs.cloudflare.com/ajax/libs/three.js/86/three.js", | |
| "ember": "2.12.0", | |
| "ember-template-compiler": "2.12.0", | |
| "ember-testing": "2.12.0" | |
| }, | |
| "addons": { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment