Threejs 创建玻璃 Refractor WaterRefractionShader
程序员文章站
2022-03-26 19:33:52
...
引入两个文件
import Refractor from 'three/examples/js/objects/Refractor';
import WaterRefractionShader from 'three/examples/js/shaders/WaterRefractionShader';
let refractorGeometry = new THREE.PlaneBufferGeometry(1000, 1000);
let refractor = new Refractor(refractorGeometry, {
color: 0x999999,
textureWidth: 1024,
textureHeight: 1024,
shader: WaterRefractionShader
});
refractor.position.set(0, 0, 5);
this.scene.add(refractor);
let d = new THREE.PlaneBufferGeometry(1000, 1000);
let c = new Refractor(d, {
color: 0x999999,
textureWidth: 1024,
textureHeight: 1024,
shader: WaterRefractionShader
});
c.position.set(0, 0, -5);
c.rotation.y = -Math.PI;
this.scene.add(c);