|
@ -45,7 +45,7 @@ var container = document.getElementById('container'); |
|
|
//创建场景
|
|
|
//创建场景
|
|
|
var scene = new THREE.Scene(); |
|
|
var scene = new THREE.Scene(); |
|
|
|
|
|
|
|
|
var hemiLight = new THREE.HemisphereLight(0xddeeff, 0x0f0e0d, 0.8); |
|
|
|
|
|
|
|
|
var hemiLight = new THREE.HemisphereLight(0xffffff, 0xffffff, 0.8); |
|
|
scene.add(hemiLight); |
|
|
scene.add(hemiLight); |
|
|
|
|
|
|
|
|
var bulbGeometry = new THREE.SphereBufferGeometry(0.22, 16, 8); |
|
|
var bulbGeometry = new THREE.SphereBufferGeometry(0.22, 16, 8); |
|
@ -87,7 +87,7 @@ mtlLoader.load('dimian.mtl', function (materials) { |
|
|
|
|
|
|
|
|
objLoader.setMaterials(materials); |
|
|
objLoader.setMaterials(materials); |
|
|
|
|
|
|
|
|
objLoader.load('ket.obj', function (mesh) { |
|
|
|
|
|
|
|
|
objLoader.load('33.obj', function (mesh) { |
|
|
|
|
|
|
|
|
mesh.scale.set(0.01, 0.01, 0.01); |
|
|
mesh.scale.set(0.01, 0.01, 0.01); |
|
|
scene.add(mesh); |
|
|
scene.add(mesh); |
|
@ -138,19 +138,17 @@ camTarget.position.set(0, 0, 0); |
|
|
|
|
|
|
|
|
//抗锯齿
|
|
|
//抗锯齿
|
|
|
var composer; |
|
|
var composer; |
|
|
var fxaaPass; |
|
|
|
|
|
var renderPass; |
|
|
|
|
|
var pixelRatio; |
|
|
|
|
|
|
|
|
|
|
|
renderPass = new RenderPass(scene, camera); |
|
|
|
|
|
fxaaPass = new ShaderPass(FXAAShader); |
|
|
|
|
|
pixelRatio = renderer.getPixelRatio(); |
|
|
|
|
|
fxaaPass.material.uniforms['resolution'].value.x = 1 / (container.offsetWidth * pixelRatio); |
|
|
|
|
|
fxaaPass.material.uniforms['resolution'].value.y = 1 / (container.offsetHeight * pixelRatio); |
|
|
|
|
|
|
|
|
var ssaaRenderPass; |
|
|
|
|
|
var copyPass; |
|
|
|
|
|
|
|
|
composer = new EffectComposer(renderer); |
|
|
composer = new EffectComposer(renderer); |
|
|
composer.addPass(renderPass); |
|
|
|
|
|
composer.addPass(fxaaPass); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ssaaRenderPass = new SSAARenderPass(scene, camera); |
|
|
|
|
|
ssaaRenderPass.unbiased = true; |
|
|
|
|
|
composer.addPass(ssaaRenderPass); |
|
|
|
|
|
copyPass = new ShaderPass(CopyShader); |
|
|
|
|
|
composer.addPass(copyPass); |
|
|
|
|
|
composer.setSize(window.innerWidth, window.innerHeight); |
|
|
|
|
|
|
|
|
// 渲染函数
|
|
|
// 渲染函数
|
|
|
function render() { |
|
|
function render() { |
|
@ -162,8 +160,9 @@ function render() { |
|
|
hemiLight.intensity = hemiLuminousIrradiances[params.hemiIrradiance]; |
|
|
hemiLight.intensity = hemiLuminousIrradiances[params.hemiIrradiance]; |
|
|
requestAnimationFrame(render); |
|
|
requestAnimationFrame(render); |
|
|
|
|
|
|
|
|
//fxaa
|
|
|
|
|
|
|
|
|
ssaaRenderPass.sampleLevel = 3; |
|
|
composer.render(); |
|
|
composer.render(); |
|
|
|
|
|
|
|
|
//renderer.render(scene, camera); //执行渲染操作
|
|
|
//renderer.render(scene, camera); //执行渲染操作
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -365,8 +364,8 @@ function makeChuangsha() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ret = new MeshStandardMaterial({ |
|
|
var ret = new MeshStandardMaterial({ |
|
|
transparent:true, |
|
|
|
|
|
opacity:0.91, |
|
|
|
|
|
|
|
|
transparent: true, |
|
|
|
|
|
opacity: 1.5, |
|
|
map: diffuseMpa, |
|
|
map: diffuseMpa, |
|
|
bumpMap: bumpMap, |
|
|
bumpMap: bumpMap, |
|
|
metalnessMap: matelMap, |
|
|
metalnessMap: matelMap, |
|
@ -405,7 +404,7 @@ function makeGlass() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ret = new MeshStandardMaterial({ |
|
|
var ret = new MeshStandardMaterial({ |
|
|
transparent:true, |
|
|
|
|
|
|
|
|
transparent: true, |
|
|
alphaMap: diffuseMpa, |
|
|
alphaMap: diffuseMpa, |
|
|
bumpMap: bumpMap, |
|
|
bumpMap: bumpMap, |
|
|
metalnessMap: matelMap, |
|
|
metalnessMap: matelMap, |
|
|