Explorar o código

Merge remote-tracking branch 'mrdoob/dev' into csm-update-cache-objects

Garrett Johnson %!s(int64=5) %!d(string=hai) anos
pai
achega
d04851b993

+ 3 - 1
examples/js/objects/Reflector.js

@@ -18,6 +18,7 @@ THREE.Reflector = function ( geometry, options ) {
 	var clipBias = options.clipBias || 0;
 	var shader = options.shader || THREE.Reflector.ReflectorShader;
 	var recursion = options.recursion !== undefined ? options.recursion : 0;
+	var encoding = options.encoding !== undefined ? options.encoding : THREE.LinearEncoding;
 
 	//
 
@@ -40,7 +41,8 @@ THREE.Reflector = function ( geometry, options ) {
 		minFilter: THREE.LinearFilter,
 		magFilter: THREE.LinearFilter,
 		format: THREE.RGBFormat,
-		stencilBuffer: false
+		stencilBuffer: false,
+		encoding: encoding
 	};
 
 	var renderTarget = new THREE.WebGLRenderTarget( textureWidth, textureHeight, parameters );

+ 3 - 1
examples/js/objects/Refractor.js

@@ -18,6 +18,7 @@ THREE.Refractor = function ( geometry, options ) {
 	var textureHeight = options.textureHeight || 512;
 	var clipBias = options.clipBias || 0;
 	var shader = options.shader || THREE.Refractor.RefractorShader;
+	var encoding = options.encoding !== undefined ? options.encoding : THREE.LinearEncoding;
 
 	//
 
@@ -36,7 +37,8 @@ THREE.Refractor = function ( geometry, options ) {
 		minFilter: THREE.LinearFilter,
 		magFilter: THREE.LinearFilter,
 		format: THREE.RGBFormat,
-		stencilBuffer: false
+		stencilBuffer: false,
+		encoding: encoding
 	};
 
 	var renderTarget = new THREE.WebGLRenderTarget( textureWidth, textureHeight, parameters );

+ 2 - 0
examples/jsm/objects/Reflector.d.ts

@@ -2,6 +2,7 @@ import {
 	Mesh,
 	BufferGeometry,
 	Color,
+	TextureEncoding,
 	WebGLRenderTarget
 } from '../../../src/Three';
 
@@ -12,6 +13,7 @@ export interface ReflectorOptions {
 	clipBias?: number;
 	shader?: object;
 	recursion?: number;
+	encoding?: TextureEncoding;
 }
 
 export class Reflector extends Mesh {

+ 4 - 1
examples/jsm/objects/Reflector.js

@@ -4,6 +4,7 @@
 
 import {
 	Color,
+	LinearEncoding,
 	LinearFilter,
 	MathUtils,
 	Matrix4,
@@ -34,6 +35,7 @@ var Reflector = function ( geometry, options ) {
 	var clipBias = options.clipBias || 0;
 	var shader = options.shader || Reflector.ReflectorShader;
 	var recursion = options.recursion !== undefined ? options.recursion : 0;
+	var encoding = options.encoding !== undefined ? options.encoding : LinearEncoding;
 
 	//
 
@@ -56,7 +58,8 @@ var Reflector = function ( geometry, options ) {
 		minFilter: LinearFilter,
 		magFilter: LinearFilter,
 		format: RGBFormat,
-		stencilBuffer: false
+		stencilBuffer: false,
+		encoding: encoding
 	};
 
 	var renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, parameters );

+ 2 - 0
examples/jsm/objects/Refractor.d.ts

@@ -2,6 +2,7 @@ import {
 	Mesh,
 	BufferGeometry,
 	Color,
+	TextureEncoding,
 	WebGLRenderTarget
 } from '../../../src/Three';
 
@@ -11,6 +12,7 @@ export interface RefractorOptions {
 	textureHeight?: number;
 	clipBias?: number;
 	shader?: object;
+	encoding?: TextureEncoding;
 }
 
 export class Refractor extends Mesh {

+ 4 - 1
examples/jsm/objects/Refractor.js

@@ -5,6 +5,7 @@
 
 import {
 	Color,
+	LinearEncoding,
 	LinearFilter,
 	MathUtils,
 	Matrix4,
@@ -35,6 +36,7 @@ var Refractor = function ( geometry, options ) {
 	var textureHeight = options.textureHeight || 512;
 	var clipBias = options.clipBias || 0;
 	var shader = options.shader || Refractor.RefractorShader;
+	var encoding = options.encoding !== undefined ? options.encoding : LinearEncoding;
 
 	//
 
@@ -53,7 +55,8 @@ var Refractor = function ( geometry, options ) {
 		minFilter: LinearFilter,
 		magFilter: LinearFilter,
 		format: RGBFormat,
-		stencilBuffer: false
+		stencilBuffer: false,
+		encoding: encoding
 	};
 
 	var renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, parameters );

+ 3 - 1
examples/jsm/postprocessing/OutlinePass.d.ts

@@ -8,7 +8,8 @@ import {
 	MeshBasicMaterial,
 	MeshDepthMaterial,
 	ShaderMaterial,
-	WebGLRenderTarget
+	WebGLRenderTarget,
+	Texture
 } from '../../../src/Three';
 
 import { Pass } from './Pass';
@@ -28,6 +29,7 @@ export class OutlinePass extends Pass {
 	downSampleRatio: number;
 	pulsePeriod: number;
 	resolution: Vector2;
+	patternTexture: Texture;
 
 	maskBufferMaterial: MeshBasicMaterial;
 	renderTargetMaskBuffer: WebGLRenderTarget;

+ 18 - 13
test/diff/deterministic-injection.js

@@ -2,15 +2,14 @@
  * @author munrocket / https://github.com/munrocket
  */
 
-( function() {
-
+( function () {
 
 	/* Deterministic random */
 
 	let seed = Math.PI / 4;
-	window.Math.random = function() {
+	window.Math.random = function () {
 
-		const x = Math.sin( seed++ ) * 10000;
+		const x = Math.sin( seed ++ ) * 10000;
 		return x - Math.floor( x );
 
 	};
@@ -18,7 +17,11 @@
 
 	/* Deterministic timer */
 
-	const now = function() { return frameId * 16; };
+	const now = function () {
+
+		return frameId * 16;
+
+	};
 	window.Date.now = now;
 	window.Date.prototype.getTime = now;
 	window.performance.wow = performance.now;
@@ -32,11 +35,11 @@
 	window.chromeRenderStarted = false;
 	window.chromeRenderFinished = false;
 	const RAF = window.requestAnimationFrame;
-	window.requestAnimationFrame = function( cb ) {
+	window.requestAnimationFrame = function ( cb ) {
 
-		if ( !chromeRenderStarted ) {
+		if ( ! chromeRenderStarted ) {
 
-			setTimeout( function() {
+			setTimeout( function () {
 
 				requestAnimationFrame( cb );
 
@@ -44,9 +47,9 @@
 
 		} else {
 
-			RAF( function() {
+			RAF( function () {
 
-				if ( frameId++ < chromeMaxFrameId ) {
+				if ( frameId ++ < chromeMaxFrameId ) {
 
 					cb( now() );
 
@@ -60,24 +63,26 @@
 
 		}
 
-	}
+	};
 
 
 	/* Semi-determitistic video */
 
 	let play = HTMLVideoElement.prototype.play;
-	HTMLVideoElement.prototype.play = async function() {
+	HTMLVideoElement.prototype.play = async function () {
 
 		play.call( this );
 		this.addEventListener( 'timeupdate', () => this.pause() );
 
 		function renew() {
+
 			this.load();
 			play.call( this );
 			RAF( renew );
+
 		}
 		RAF( renew );
 
-	}
+	};
 
 }() );

+ 24 - 22
test/diff/puppeteer.js

@@ -11,34 +11,34 @@ const png = require( 'pngjs' ).PNG;
 const fs = require( 'fs' );
 
 const port = 1234;
-const pixelThreshold = 0.2;                // threshold error in one pixel
-const maxFailedPixels = 0.05;              // total failed pixels
+const pixelThreshold = 0.2; // threshold error in one pixel
+const maxFailedPixels = 0.05; // total failed pixels
 
 const exceptionList = [
 
 	'index',
-	'webgl_loader_texture_pvrtc',            // not supported in CI, useless
+	'webgl_loader_texture_pvrtc', // not supported in CI, useless
 	'webgl_materials_envmaps_parallax',
-	'webgl_test_memory2',                    // gives fatal error in puppeteer
-	'webgl_worker_offscreencanvas',          // in a worker, not robust
+	'webgl_test_memory2', // gives fatal error in puppeteer
+	'webgl_worker_offscreencanvas' // in a worker, not robust
 
 ].concat( ( process.platform === "win32" ) ? [
 
-	'webgl_effects_ascii'                    // windows fonts not supported
+	'webgl_effects_ascii' // windows fonts not supported
 
 ] : [] );
 
 const networkTimeout = 600;
-const networkTax = 2000;                   // additional timeout for resources size
-const pageSizeMinTax = 1.0;                // in mb, when networkTax = 0
-const pageSizeMaxTax = 5.0;                // in mb, when networkTax = networkTax
+const networkTax = 2000; // additional timeout for resources size
+const pageSizeMinTax = 1.0; // in mb, when networkTax = 0
+const pageSizeMaxTax = 5.0; // in mb, when networkTax = networkTax
 const renderTimeout = 1200;
-const maxAttemptId = 3;                    // progresseve attempts
+const maxAttemptId = 3; // progresseve attempts
 const progressFunc = n => 1 + n;
 
 console.green = ( msg ) => console.log( `\x1b[32m${ msg }\x1b[37m` );
 console.red = ( msg ) => console.log( `\x1b[31m${ msg }\x1b[37m` );
-console.null = ( msg ) => {};
+console.null = () => {};
 
 
 /* Launch server */
@@ -71,7 +71,7 @@ server.on( 'SIGINT', () => process.exit( 1 ) );
 /* Launch puppeteer with WebGL support in Linux */
 
 const pup = puppeteer.launch( {
-	headless: !process.env.VISIBLE,
+	headless: ! process.env.VISIBLE,
 	args: [
 		'--use-gl=egl',
 		'--no-sandbox',
@@ -106,12 +106,12 @@ const pup = puppeteer.launch( {
 
 	/* Find files */
 
-	const exactList = process.argv.slice(2).map( f => f.replace( '.html', '' ) );
+	const exactList = process.argv.slice( 2 ).map( f => f.replace( '.html', '' ) );
 
 	const files = fs.readdirSync( './examples' )
 		.filter( s => s.slice( - 5 ) === '.html' )
 		.map( s => s.slice( 0, s.length - 5 ) )
-		.filter( f => ( process.argv.length > 2 ) ? exactList.includes( f ) : !exceptionList.includes( f ) );
+		.filter( f => ( process.argv.length > 2 ) ? exactList.includes( f ) : ! exceptionList.includes( f ) );
 
 
 	/* Loop for each file, with CI parallelism */
@@ -182,9 +182,9 @@ const pup = puppeteer.launch( {
 					let canvas = document.getElementsByTagName( 'canvas' );
 					for ( let i = 0; i < canvas.length; ++ i ) {
 
-						if ( canvas[i].height === 48 ) {
+						if ( canvas[ i ].height === 48 ) {
 
-							canvas[i].style.display = 'none';
+							canvas[ i ].style.display = 'none';
 
 						}
 
@@ -197,15 +197,17 @@ const pup = puppeteer.launch( {
 					/* Resolve render promise */
 
 					window.chromeRenderStarted = true;
-					await new Promise( function( resolve ) {
+					await new Promise( function ( resolve ) {
 
 						if ( typeof performance.wow === 'undefined' ) {
+
 							performance.wow = performance.now;
+
 						}
 						let renderStart = performance.wow();
-						let waitingLoop = setInterval( function() {
+						let waitingLoop = setInterval( function () {
 
-							let renderEcceded = ( performance.wow() - renderStart > renderTimeout * window.chromeMaxFrameId  * attemptProgress );
+							let renderEcceded = ( performance.wow() - renderStart > renderTimeout * window.chromeMaxFrameId * attemptProgress );
 							if ( window.chromeRenderFinished || renderEcceded ) {
 
 								if ( renderEcceded ) {
@@ -270,7 +272,7 @@ const pup = puppeteer.launch( {
 						threshold: pixelThreshold,
 						alpha: 0.2,
 						diffMask: process.env.FORCE_COLOR === '0',
-						diffColor: process.env.FORCE_COLOR === '0' ? [255, 255, 255] : [255, 0, 0]
+						diffColor: process.env.FORCE_COLOR === '0' ? [ 255, 255, 255 ] : [ 255, 0, 0 ]
 					} );
 
 				} catch {
@@ -295,7 +297,7 @@ const pup = puppeteer.launch( {
 
 					if ( ++ attemptId === maxAttemptId ) {
 
-						printImage(diff, console);
+						printImage( diff, console );
 						console.red( `ERROR! Diff wrong in ${ numFailedPixels.toFixed( 3 ) } of pixels in file: ${ file }` );
 						++ failedScreenshots;
 						continue;
@@ -329,7 +331,7 @@ const pup = puppeteer.launch( {
 		console.red( `TEST FAILED! ${ failedScreenshots } from ${ endId - beginId } screenshots not pass.` );
 		process.exit( 1 );
 
-	} else if ( !process.env.MAKE ) {
+	} else if ( ! process.env.MAKE ) {
 
 		console.green( `TEST PASSED! ${ endId - beginId } screenshots correctly rendered.` );