欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

 

相关标签: threejs