Threejs 创建玻璃 Refractor WaterRefractionShader

引入两个文件 

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);

猜你喜欢

转载自blog.csdn.net/weixin_41111068/article/details/83149373