| | |
| | | import { RenderPass } from './lib/postprocessing/RenderPass.js'; |
| | | import { ShaderPass } from './lib/postprocessing/ShaderPass.js'; |
| | | import { OutlinePass } from './lib/postprocessing/OutlinePass.js'; |
| | | import { FXAAShader } from './lib/postprocessing/FXAAShader.js'; |
| | | import {MTLLoader} from './lib/MTLLoader.js'; |
| | | import {OBJLoader} from './lib/OBJLoader.js'; |
| | | import {StoreShelf} from './object/StoreShelf.js'; |
| | |
| | | this.initLight(); |
| | | this.initReSize(this); |
| | | this.initOutLine(); |
| | | this.initComposer(); |
| | | // this.initComposer(); |
| | | this.initObjectSelect(); |
| | | this.initPointLockControl(this); |
| | | this.initFloor(); |
| | |
| | | this.animate = function () { |
| | | requestAnimationFrame(this.animate.bind(this)); |
| | | this.stats.begin(); |
| | | this.renderer.render(this.scene, this.camera); |
| | | if (this.composer) { |
| | | this.composer.render(); |
| | | } else { |
| | | this.renderer.render(this.scene, this.camera); |
| | | } |
| | | this.firstPersonMove(); |
| | | this.initStoreObjects(this); |
| | | this.stats.end(); |
| | |
| | | // this.renderer.toneMapping = THREE.CineonToneMapping; // 色调 |
| | | this.renderer.setSize(window.innerWidth, window.innerHeight); |
| | | this.renderer.setPixelRatio( window.devicePixelRatio ); |
| | | this.renderer.shadowMap.enabled = false; |
| | | this.renderer.shadowMap.enabled = true; |
| | | this.renderer.shadowMap.type = THREE.BasicShadowMap; |
| | | this.dom = document.getElementById("container"); |
| | | this.dom.appendChild(this.renderer.domElement); |
| | |
| | | } |
| | | this.initOutLine = function(){ |
| | | this.outlinePass = new OutlinePass( new THREE.Vector2( window.innerWidth, window.innerHeight ), this.scene, this.camera ) |
| | | this.outlinePass.edgeStrength = 10;//包围线浓度 |
| | | this.outlinePass.edgeGlow = 0.1;//边缘线范围 |
| | | this.outlinePass.edgeThickness = 1;//边缘线浓度 |
| | | this.outlinePass.pulsePeriod = 2;//包围线闪烁评率 |
| | | this.outlinePass.visibleEdgeColor.set('#B31985');//包围线颜色 |
| | | this.outlinePass.hiddenEdgeColor.set('#190a05');//被遮挡的边界线颜色 |
| | | // this.outlinePass.edgeStrength = 1;//包围线浓度 |
| | | // this.outlinePass.edgeGlow = 0.1;//边缘线范围 |
| | | // this.outlinePass.edgeThickness = 1;//边缘线浓度 |
| | | // this.outlinePass.pulsePeriod = 2;//包围线闪烁评率 |
| | | // this.outlinePass.visibleEdgeColor.set('#B31985');//包围线颜色 |
| | | // this.outlinePass.hiddenEdgeColor.set('#190a05');//被遮挡的边界线颜色 |
| | | } |
| | | this.initComposer = function(){ |
| | | this.composer = new EffectComposer(this.renderer); |
| | | const renderPass = new RenderPass( this.scene, this.camera ); |
| | | this.composer.addPass( renderPass ); |
| | | this.composer.addPass(this.outlinePass); |
| | | |
| | | const pixelRatio = this.renderer.getPixelRatio(); |
| | | this.fxaaPass = new ShaderPass( FXAAShader ); |
| | | this.fxaaPass.material.uniforms[ 'resolution' ].value.x = 1 / ( this.dom.offsetWidth * pixelRatio ); |
| | | this.fxaaPass.material.uniforms[ 'resolution' ].value.y = 1 / ( this.dom.offsetHeight * pixelRatio ); |
| | | this.composer.addPass( this.fxaaPass ); |
| | | } |
| | | this.initObjectSelect = function(){ |
| | | new ObjectSelect(this.scene, this.camera, this.outlinePass); |