| | |
| | | renderer.setClearAlpha(0); |
| | | renderer.shadowMap.enabled = true; |
| | | renderer.toneMapping = THREE.ACESFilmicToneMapping; |
| | | renderer.setPixelRatio(window.devicePixelRatio); |
| | | renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)); |
| | | renderer.setSize(this.getFullWidth(), this.getFullHeight()); |
| | | this.dom?.appendChild(renderer.domElement); |
| | | return renderer; |
| | |
| | | if (this.renderer) { |
| | | this.renderer.dispose(); |
| | | this.renderer.forceContextLoss(); |
| | | this.renderer.context = null; |
| | | this.renderer.domElement = null; |
| | | if (this.dom && this.renderer.domElement && this.dom.contains(this.renderer.domElement)) { |
| | | try { |
| | | this.dom.removeChild(this.renderer.domElement); |
| | | } catch (error) { |
| | | console.warn('Failed to remove renderer.domElement:', error); |
| | | } |
| | | } |
| | | this.renderer = null; |
| | | } |
| | | if (this.controls) { |
| | | this.controls.dispose(); |
| | | this.controls = null; |
| | | } |
| | | this.camera = null; |
| | | this.objects = []; |
| | | if (this.dom) { |
| | | while (this.dom.firstChild) { |
| | | if (this.dom.contains(this.dom.firstChild)) { |
| | | this.dom.removeChild(this.dom.firstChild); |
| | | } |
| | | if (this.stats && this.stats.domElement && this.dom.contains(this.stats.domElement)) { |
| | | try { |
| | | this.dom.removeChild(this.stats.domElement); |
| | | } catch (error) { |
| | | console.warn('Failed to remove stats.domElement:', error); |
| | | } |
| | | } |
| | | this.camera = null; |
| | | this.objects = []; |
| | | } |
| | | |
| | | removeEntity = (object) => { |