Skip to content

Commit

Permalink
Examples: Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Jul 29, 2020
1 parent f5ffedb commit 9006b83
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
13 changes: 10 additions & 3 deletions examples/js/misc/GPUComputationRenderer.js
@@ -1,7 +1,5 @@
console.warn( "THREE.GPUComputationRenderer: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation." );
/**
* @author yomboprime https://github.com/yomboprime
*
* GPUComputationRenderer, based on SimulationRenderer by zz85
*
* The GPUComputationRenderer uses the concept of variables. These variables are RGBA float textures that hold 4 floats
Expand Down Expand Up @@ -104,6 +102,8 @@ THREE.GPUComputationRenderer = function ( sizeX, sizeY, renderer ) {

this.currentTextureIndex = 0;

var dataType = THREE.FloatType;

var scene = new THREE.Scene();

var camera = new THREE.Camera();
Expand All @@ -119,6 +119,13 @@ THREE.GPUComputationRenderer = function ( sizeX, sizeY, renderer ) {
scene.add( mesh );


this.setDataType = function ( type ) {

dataType = type;
return this;

};

this.addVariable = function ( variableName, computeFragmentShader, initialValueTexture ) {

var material = this.createShaderMaterial( computeFragmentShader );
Expand Down Expand Up @@ -311,7 +318,7 @@ THREE.GPUComputationRenderer = function ( sizeX, sizeY, renderer ) {
minFilter: minFilter,
magFilter: magFilter,
format: THREE.RGBAFormat,
type: ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) ? THREE.HalfFloatType : THREE.FloatType,
type: dataType,
stencilBuffer: false,
depthBuffer: false
} );
Expand Down
2 changes: 0 additions & 2 deletions examples/jsm/misc/GPUComputationRenderer.js
@@ -1,6 +1,4 @@
/**
* @author yomboprime https://github.com/yomboprime
*
* GPUComputationRenderer, based on SimulationRenderer by zz85
*
* The GPUComputationRenderer uses the concept of variables. These variables are RGBA float textures that hold 4 floats
Expand Down
9 changes: 7 additions & 2 deletions examples/webgl_gpgpu_birds.html
Expand Up @@ -484,7 +484,9 @@
gpuCompute = new GPUComputationRenderer( WIDTH, WIDTH, renderer );

if ( isSafari() ) {

gpuCompute.setDataType( THREE.HalfFloatType );

}

var dtPosition = gpuCompute.createTexture();
Expand Down Expand Up @@ -519,16 +521,19 @@
positionVariable.wrapT = THREE.RepeatWrapping;

var error = gpuCompute.init();

if ( error !== null ) {

console.error( error );
console.error( error );

}

}

function isSafari() {
return !!navigator.userAgent.match(/Safari/i) && !navigator.userAgent.match(/Chrome/i);

return !! navigator.userAgent.match( /Safari/i ) && ! navigator.userAgent.match( /Chrome/i );

}

function initBirds() {
Expand Down
6 changes: 5 additions & 1 deletion examples/webgl_gpgpu_birds_gltf.html
Expand Up @@ -432,7 +432,9 @@
gpuCompute = new GPUComputationRenderer( WIDTH, WIDTH, renderer );

if ( isSafari() ) {

gpuCompute.setDataType( THREE.HalfFloatType );

}

var dtPosition = gpuCompute.createTexture();
Expand Down Expand Up @@ -477,7 +479,9 @@
}

function isSafari() {
return !!navigator.userAgent.match(/Safari/i) && !navigator.userAgent.match(/Chrome/i);

return !! navigator.userAgent.match( /Safari/i ) && ! navigator.userAgent.match( /Chrome/i );

}

function initBirds() {
Expand Down
6 changes: 5 additions & 1 deletion examples/webgl_gpgpu_protoplanet.html
Expand Up @@ -317,7 +317,9 @@
gpuCompute = new GPUComputationRenderer( WIDTH, WIDTH, renderer );

if ( isSafari() ) {

gpuCompute.setDataType( THREE.HalfFloatType );

}

var dtPosition = gpuCompute.createTexture();
Expand Down Expand Up @@ -347,7 +349,9 @@
}

function isSafari() {
return !!navigator.userAgent.match(/Safari/i) && !navigator.userAgent.match(/Chrome/i);

return !! navigator.userAgent.match( /Safari/i ) && ! navigator.userAgent.match( /Chrome/i );

}

function restartSimulation() {
Expand Down
7 changes: 6 additions & 1 deletion examples/webgl_gpgpu_water.html
Expand Up @@ -445,7 +445,9 @@
gpuCompute = new GPUComputationRenderer( WIDTH, WIDTH, renderer );

if ( isSafari() ) {

gpuCompute.setDataType( THREE.HalfFloatType );

}

var heightmap0 = gpuCompute.createTexture();
Expand Down Expand Up @@ -497,7 +499,9 @@
}

function isSafari() {
return !!navigator.userAgent.match(/Safari/i) && !navigator.userAgent.match(/Chrome/i);

return !! navigator.userAgent.match( /Safari/i ) && ! navigator.userAgent.match( /Chrome/i );

}

function fillTexture( texture ) {
Expand All @@ -516,6 +520,7 @@
mult *= 1.25;

}

return r;

}
Expand Down

0 comments on commit 9006b83

Please sign in to comment.