|
@@ -1,17 +1,15 @@
|
|
import {
|
|
import {
|
|
- Camera,
|
|
|
|
ClampToEdgeWrapping,
|
|
ClampToEdgeWrapping,
|
|
DataTexture,
|
|
DataTexture,
|
|
FloatType,
|
|
FloatType,
|
|
- Mesh,
|
|
|
|
NearestFilter,
|
|
NearestFilter,
|
|
- PlaneGeometry,
|
|
|
|
RGBAFormat,
|
|
RGBAFormat,
|
|
- Scene,
|
|
|
|
ShaderMaterial,
|
|
ShaderMaterial,
|
|
WebGLRenderTarget
|
|
WebGLRenderTarget
|
|
} from 'three';
|
|
} from 'three';
|
|
|
|
|
|
|
|
+import { FullScreenQuad } from '../postprocessing/Pass.js';
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* GPUComputationRenderer, based on SimulationRenderer by zz85
|
|
* GPUComputationRenderer, based on SimulationRenderer by zz85
|
|
*
|
|
*
|
|
@@ -119,20 +117,13 @@ class GPUComputationRenderer {
|
|
|
|
|
|
let dataType = FloatType;
|
|
let dataType = FloatType;
|
|
|
|
|
|
- const scene = new Scene();
|
|
|
|
-
|
|
|
|
- const camera = new Camera();
|
|
|
|
- camera.position.z = 1;
|
|
|
|
-
|
|
|
|
const passThruUniforms = {
|
|
const passThruUniforms = {
|
|
passThruTexture: { value: null }
|
|
passThruTexture: { value: null }
|
|
};
|
|
};
|
|
|
|
|
|
const passThruShader = createShaderMaterial( getPassThroughFragmentShader(), passThruUniforms );
|
|
const passThruShader = createShaderMaterial( getPassThroughFragmentShader(), passThruUniforms );
|
|
|
|
|
|
- const mesh = new Mesh( new PlaneGeometry( 2, 2 ), passThruShader );
|
|
|
|
- scene.add( mesh );
|
|
|
|
-
|
|
|
|
|
|
+ const quad = new FullScreenQuad( passThruShader );
|
|
|
|
|
|
this.setDataType = function ( type ) {
|
|
this.setDataType = function ( type ) {
|
|
|
|
|
|
@@ -284,8 +275,7 @@ class GPUComputationRenderer {
|
|
|
|
|
|
this.dispose = function () {
|
|
this.dispose = function () {
|
|
|
|
|
|
- mesh.geometry.dispose();
|
|
|
|
- mesh.material.dispose();
|
|
|
|
|
|
+ quad.dispose();
|
|
|
|
|
|
const variables = this.variables;
|
|
const variables = this.variables;
|
|
|
|
|
|
@@ -395,10 +385,10 @@ class GPUComputationRenderer {
|
|
|
|
|
|
renderer.xr.enabled = false; // Avoid camera modification
|
|
renderer.xr.enabled = false; // Avoid camera modification
|
|
renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
|
|
renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
|
|
- mesh.material = material;
|
|
|
|
|
|
+ quad.material = material;
|
|
renderer.setRenderTarget( output );
|
|
renderer.setRenderTarget( output );
|
|
- renderer.render( scene, camera );
|
|
|
|
- mesh.material = passThruShader;
|
|
|
|
|
|
+ quad.render( renderer );
|
|
|
|
+ quad.material = passThruShader;
|
|
|
|
|
|
renderer.xr.enabled = currentXrEnabled;
|
|
renderer.xr.enabled = currentXrEnabled;
|
|
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|