| | |
| | | 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; |
| | |
| | | |
| | | initLight = () => { |
| | | const hemiLight = new THREE.HemisphereLight(0xffffff, 0xffffff, 6); |
| | | hemiLight.color.setHSL(0.6, 1, 0.6); |
| | | hemiLight.groundColor.setHSL(0.095, 1, 0.75); |
| | | hemiLight.color.setHSL(0.6, 1, 0.75); |
| | | hemiLight.groundColor.setHSL(0.095, 1, 0.85); |
| | | hemiLight.position.set(0, 1500, 0); |
| | | this.scene.add(hemiLight); |
| | | |
| | | const dirLight = new THREE.DirectionalLight(0xffffff, 2.5); |
| | | dirLight.color.setHSL(0.1, 1, 0.95); |
| | | dirLight.position.set(-10, 10, 10); |
| | | dirLight.position.multiplyScalar(30); |
| | | const dirLight = new THREE.DirectionalLight(0xffffff, 4); |
| | | dirLight.color.setHSL(0.1, 1, 1.0); |
| | | dirLight.position.set(-300, 300, 300); |
| | | this.scene.add(dirLight); |
| | | |
| | | const dirLight1 = new THREE.DirectionalLight(0xffffff, 2.5); |
| | | dirLight1.color.setHSL(0.1, 1, 0.95); |
| | | dirLight1.position.set(10, 10, -10); |
| | | const dirLight1 = new THREE.DirectionalLight(0xffffff, 4); |
| | | dirLight1.color.setHSL(0.1, 1, 1.0); |
| | | dirLight1.position.set(300, 300, -300); |
| | | dirLight1.position.multiplyScalar(30); |
| | | this.scene.add(dirLight1); |
| | | } |
| | | |
| | | const ambient = new THREE.AmbientLight(0xffffff, 1.0); |
| | | // this.scene.add(ambient); |
| | | } |
| | | |
| | | generateMesh = (fn) => { |
| | | const loader = new FBXLoader(); |
| | |
| | | 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; |
| | | } |
| | | 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 = []; |
| | | while (this.dom?.firstChild) { |
| | | this.dom.removeChild(this.dom.firstChild); |
| | | } |
| | | } |
| | | |
| | | removeEntity = (object) => { |