浏览代码

Removed RaytracingRenderer.

Mr.doob 5 年之前
父节点
当前提交
c018e62b6e

+ 1 - 10
editor/js/Sidebar.Project.js

@@ -5,7 +5,6 @@
 import * as THREE from '../../build/three.module.js';
 
 import { SVGRenderer } from '../../examples/jsm/renderers/SVGRenderer.js';
-import { RaytracingRenderer } from '../../examples/jsm/renderers/RaytracingRenderer.js';
 
 import { UIPanel, UIRow, UIInput, UICheckbox, UISelect, UIText, UIListbox, UISpan, UIButton } from './libs/ui.js';
 import { UIBoolean } from './libs/ui.three.js';
@@ -21,8 +20,7 @@ var SidebarProject = function ( editor ) {
 	var rendererTypes = {
 
 		'WebGLRenderer': THREE.WebGLRenderer,
-		'SVGRenderer': SVGRenderer,
-		'RaytracingRenderer': RaytracingRenderer
+		'SVGRenderer': SVGRenderer
 
 	};
 
@@ -140,13 +138,6 @@ var SidebarProject = function ( editor ) {
 				parameters.antialias = antialias;
 				break;
 
-			case 'RaytracingRenderer':
-				parameters.workers = navigator.hardwareConcurrency || 4;
-				parameters.workerPath = '../examples/js/renderers/RaytracingWorker.js';
-				parameters.randomize = true;
-				parameters.blockSize = 64;
-				break;
-
 		}
 
 		var renderer = new rendererTypes[ type ]( parameters );

+ 3 - 8
editor/js/Viewport.js

@@ -5,7 +5,6 @@
 import * as THREE from '../../build/three.module.js';
 
 import { TransformControls } from '../../examples/jsm/controls/TransformControls.js';
-import { RaytracingRenderer } from '../../examples/jsm/renderers/RaytracingRenderer.js';
 
 import { UIPanel } from './libs/ui.js';
 
@@ -591,14 +590,10 @@ var Viewport = function ( editor ) {
 		scene.updateMatrixWorld();
 		renderer.render( scene, camera );
 
-		if ( renderer instanceof RaytracingRenderer === false ) {
+		if ( camera === editor.camera ) {
 
-			if ( camera === editor.camera ) {
-
-				sceneHelpers.updateMatrixWorld();
-				renderer.render( sceneHelpers, camera );
-
-			}
+			sceneHelpers.updateMatrixWorld();
+			renderer.render( sceneHelpers, camera );
 
 		}
 

+ 0 - 1
editor/sw.js

@@ -44,7 +44,6 @@ const assets = [
 	'../examples/jsm/exporters/STLExporter.js',
 
 	'../examples/jsm/renderers/Projector.js',
-	'../examples/jsm/renderers/RaytracingRenderer.js',
 	'../examples/jsm/renderers/SVGRenderer.js',
 
 	'../examples/jsm/geometries/TeapotBufferGeometry.js',

+ 0 - 3
examples/files.js

@@ -377,9 +377,6 @@ var files = {
 		"css3d_sprites",
 		"css3d_youtube"
 	],
-	"raytracing": [
-		"raytracing_sandbox"
-	],
 	"svg": [
 		"svg_lines",
 		"svg_sandbox"

+ 0 - 284
examples/js/renderers/RaytracingRenderer.js

@@ -1,284 +0,0 @@
-/**
- * RaytracingRenderer renders by raytracing it's scene. However, it does not
- * compute the pixels itself but it hands off and coordinates the tasks for workers.
- * The workers compute the pixel values and this renderer simply paints it to the Canvas.
- *
- * @author zz85 / http://github.com/zz85
- */
-
-THREE.RaytracingRenderer = function ( parameters ) {
-
-	parameters = parameters || {};
-
-	var scope = this;
-	var pool = [];
-	var renderering = false;
-
-	var canvas = document.createElement( 'canvas' );
-	var context = canvas.getContext( '2d', {
-		alpha: parameters.alpha === true
-	} );
-
-	var canvasWidth, canvasHeight;
-
-	var clearColor = new THREE.Color( 0x000000 );
-
-	this.domElement = canvas;
-
-	this.autoClear = true;
-
-	var workers = parameters.workers;
-	var blockSize = parameters.blockSize || 64;
-	this.randomize = parameters.randomize;
-
-	var toRender = [], workerId = 0, sceneId = 0;
-
-	console.log( '%cSpinning off ' + workers + ' Workers ', 'font-size: 20px; background: black; color: white; font-family: monospace;' );
-
-	this.setWorkers = function ( w ) {
-
-		workers = w || navigator.hardwareConcurrency || 4;
-
-		while ( pool.length < workers ) {
-
-			var worker = new Worker( parameters.workerPath );
-			worker.id = workerId ++;
-
-			worker.onmessage = function ( e ) {
-
-				var data = e.data;
-
-				if ( ! data ) return;
-
-				if ( data.blockSize && sceneId == data.sceneId ) { // we match sceneId here to be sure
-
-					var imagedata = new ImageData( new Uint8ClampedArray( data.data ), data.blockSize, data.blockSize );
-					context.putImageData( imagedata, data.blockX, data.blockY );
-
-					// completed
-
-					console.log( 'Worker ' + this.id, data.time / 1000, ( Date.now() - reallyThen ) / 1000 + ' s' );
-
-					if ( pool.length > workers ) {
-
-						pool.splice( pool.indexOf( this ), 1 );
-						return this.terminate();
-
-					}
-
-					renderNext( this );
-
-				}
-
-			};
-
-			worker.color = new THREE.Color().setHSL( Math.random(), 0.8, 0.8 ).getHexString();
-			pool.push( worker );
-
-			updateSettings( worker );
-
-			if ( renderering ) {
-
-				worker.postMessage( {
-					scene: sceneJSON,
-					camera: cameraJSON,
-					annex: materials,
-					sceneId: sceneId
-				} );
-
-				renderNext( worker );
-
-			}
-
-		}
-
-		if ( ! renderering ) {
-
-			while ( pool.length > workers ) {
-
-				pool.pop().terminate();
-
-			}
-
-		}
-
-	};
-
-	this.setWorkers( workers );
-
-	this.setClearColor = function ( color /*, alpha */ ) {
-
-		clearColor.set( color );
-
-	};
-
-	this.setPixelRatio = function () {};
-
-	this.setSize = function ( width, height ) {
-
-		canvas.width = width;
-		canvas.height = height;
-
-		canvasWidth = canvas.width;
-		canvasHeight = canvas.height;
-
-		pool.forEach( updateSettings );
-
-	};
-
-	this.setSize( canvas.width, canvas.height );
-
-	this.clear = function () {
-
-	};
-
-	//
-
-	var totalBlocks, xblocks, yblocks;
-
-	function updateSettings( worker ) {
-
-		worker.postMessage( {
-
-			init: [ canvasWidth, canvasHeight ],
-			worker: worker.id,
-			// workers: pool.length,
-			blockSize: blockSize
-
-		} );
-
-	}
-
-	function renderNext( worker ) {
-
-		if ( ! toRender.length ) {
-
-			renderering = false;
-			return scope.dispatchEvent( { type: "complete" } );
-
-		}
-
-		var current = toRender.pop();
-
-		var blockX = ( current % xblocks ) * blockSize;
-		var blockY = ( current / xblocks | 0 ) * blockSize;
-
-		worker.postMessage( {
-			render: true,
-			x: blockX,
-			y: blockY,
-			sceneId: sceneId
-		} );
-
-		context.fillStyle = '#' + worker.color;
-		context.fillRect( blockX, blockY, blockSize, blockSize );
-
-	}
-
-	var materials = {};
-
-	var sceneJSON, cameraJSON, reallyThen;
-
-	// additional properties that were not serialize automatically
-
-	var _annex = {
-
-		mirror: 1,
-		reflectivity: 1,
-		refractionRatio: 1,
-		glass: 1
-
-	};
-
-	function serializeObject( o ) {
-
-		var mat = o.material;
-
-		if ( ! mat || mat.uuid in materials ) return;
-
-		var props = {};
-		for ( var m in _annex ) {
-
-			if ( mat[ m ] !== undefined ) {
-
-				props[ m ] = mat[ m ];
-
-			}
-
-		}
-
-		materials[ mat.uuid ] = props;
-
-	}
-
-	this.render = function ( scene, camera ) {
-
-		renderering = true;
-
-		// update scene graph
-
-		if ( scene.autoUpdate === true ) scene.updateMatrixWorld();
-
-		// update camera matrices
-
-		if ( camera.parent === null ) camera.updateMatrixWorld();
-
-
-		sceneJSON = scene.toJSON();
-		cameraJSON = camera.toJSON();
-		++ sceneId;
-
-		scene.traverse( serializeObject );
-
-		pool.forEach( function ( worker ) {
-
-			worker.postMessage( {
-				scene: sceneJSON,
-				camera: cameraJSON,
-				annex: materials,
-				sceneId: sceneId
-			} );
-
-		} );
-
-		context.fillStyle = clearColor.getStyle();
-		context.fillRect( 0, 0, canvasWidth, canvasHeight );
-
-		reallyThen = Date.now();
-
-		xblocks = Math.ceil( canvasWidth / blockSize );
-		yblocks = Math.ceil( canvasHeight / blockSize );
-		totalBlocks = xblocks * yblocks;
-
-		toRender = [];
-
-		for ( var i = 0; i < totalBlocks; i ++ ) {
-
-			toRender.push( i );
-
-		}
-
-
-		// Randomize painting :)
-
-		if ( scope.randomize ) {
-
-			for ( var i = 0; i < totalBlocks; i ++ ) {
-
-				var swap = Math.random() * totalBlocks | 0;
-				var tmp = toRender[ swap ];
-				toRender[ swap ] = toRender[ i ];
-				toRender[ i ] = tmp;
-
-			}
-
-		}
-
-
-		pool.forEach( renderNext );
-
-	};
-
-};
-
-Object.assign( THREE.RaytracingRenderer.prototype, THREE.EventDispatcher.prototype );

+ 0 - 544
examples/js/renderers/RaytracingWorker.js

@@ -1,544 +0,0 @@
-var BLOCK = 128;
-var startX, startY;
-
-var scene, camera, renderer, loader, sceneId;
-
-importScripts( '../../../build/three.js' );
-
-
-self.onmessage = function ( e ) {
-
-	var data = e.data;
-	if ( ! data ) return;
-
-	if ( data.init ) {
-
-		var
-			width = data.init[ 0 ],
-			height = data.init[ 1 ];
-
-		BLOCK = data.blockSize;
-
-		if ( ! renderer ) renderer = new THREE.RaytracingRendererWorker();
-		if ( ! loader ) loader = new THREE.ObjectLoader();
-
-		renderer.setSize( width, height );
-
-		// TODO fix passing maxRecursionDepth as parameter.
-		// if (data.maxRecursionDepth) maxRecursionDepth = data.maxRecursionDepth;
-
-	}
-
-	if ( data.scene ) {
-
-		scene = loader.parse( data.scene );
-		camera = loader.parse( data.camera );
-
-		var meta = data.annex;
-		scene.traverse( function ( o ) {
-
-			if ( o.isPointLight ) {
-
-				o.physicalAttenuation = true;
-
-			}
-
-			var mat = o.material;
-
-			if ( ! mat ) return;
-
-			var material = meta[ mat.uuid ];
-
-			for ( var m in material ) {
-
-				mat[ m ] = material[ m ];
-
-			}
-
-		} );
-
-		sceneId = data.sceneId;
-
-	}
-
-	if ( data.render && scene && camera ) {
-
-		startX = data.x;
-		startY = data.y;
-		renderer.render( scene, camera );
-
-	}
-
-};
-
-/**
- * DOM-less version of Raytracing Renderer
- * @author mrdoob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- * @author zz95 / http://github.com/zz85
- */
-
-THREE.RaytracingRendererWorker = function () {
-
-	var maxRecursionDepth = 3;
-
-	var canvasWidth, canvasHeight;
-	var canvasWidthHalf, canvasHeightHalf;
-	var origin = new THREE.Vector3();
-	var direction = new THREE.Vector3();
-
-	var cameraPosition = new THREE.Vector3();
-
-	var raycaster = new THREE.Raycaster( origin, direction );
-	var ray = raycaster.ray;
-
-	var raycasterLight = new THREE.Raycaster();
-	var rayLight = raycasterLight.ray;
-
-	var perspective;
-	var cameraNormalMatrix = new THREE.Matrix3();
-
-	var objects;
-	var lights = [];
-	var cache = {};
-
-	this.setSize = function ( width, height ) {
-
-		canvasWidth = width;
-		canvasHeight = height;
-
-		canvasWidthHalf = Math.floor( canvasWidth / 2 );
-		canvasHeightHalf = Math.floor( canvasHeight / 2 );
-
-	};
-
-	//
-
-	var spawnRay = ( function () {
-
-		var diffuseColor = new THREE.Color();
-		var specularColor = new THREE.Color();
-		var lightColor = new THREE.Color();
-		var schlick = new THREE.Color();
-
-		var lightContribution = new THREE.Color();
-
-		var eyeVector = new THREE.Vector3();
-		var lightVector = new THREE.Vector3();
-		var normalVector = new THREE.Vector3();
-		var halfVector = new THREE.Vector3();
-
-		var localPoint = new THREE.Vector3();
-		var reflectionVector = new THREE.Vector3();
-
-		var tmpVec = new THREE.Vector3();
-
-		var tmpColor = [];
-
-		for ( var i = 0; i < maxRecursionDepth; i ++ ) {
-
-			tmpColor[ i ] = new THREE.Color();
-
-		}
-
-		return function spawnRay( rayOrigin, rayDirection, outputColor, recursionDepth ) {
-
-			outputColor.setRGB( 0, 0, 0 );
-
-			//
-
-			ray.origin = rayOrigin;
-			ray.direction = rayDirection;
-
-			var intersections = raycaster.intersectObjects( objects, true );
-
-			// ray didn't find anything
-			// (here should come setting of background color?)
-
-			if ( intersections.length === 0 ) return;
-
-			// ray hit
-
-			var intersection = intersections[ 0 ];
-
-			var point = intersection.point;
-			var object = intersection.object;
-			var material = object.material;
-			var face = intersection.face;
-
-			var geometry = object.geometry;
-
-			//
-
-			var _object = cache[ object.id ];
-
-			eyeVector.subVectors( ray.origin, point ).normalize();
-
-			// resolve pixel diffuse color
-
-			if ( material.isMeshLambertMaterial ||
-				 material.isMeshPhongMaterial ||
-				 material.isMeshBasicMaterial ) {
-
-				diffuseColor.copyGammaToLinear( material.color );
-
-			} else {
-
-				diffuseColor.setRGB( 1, 1, 1 );
-
-			}
-
-			if ( material.vertexColors === THREE.FaceColors ) {
-
-				diffuseColor.multiply( face.color );
-
-			}
-
-			// compute light shading
-
-			rayLight.origin.copy( point );
-
-			if ( material.isMeshBasicMaterial ) {
-
-				for ( var i = 0, l = lights.length; i < l; i ++ ) {
-
-					var light = lights[ i ];
-
-					lightVector.setFromMatrixPosition( light.matrixWorld );
-					lightVector.sub( point );
-
-					rayLight.direction.copy( lightVector ).normalize();
-
-					var intersections = raycasterLight.intersectObjects( objects, true );
-
-					// point in shadow
-
-					if ( intersections.length > 0 ) continue;
-
-					// point visible
-
-					outputColor.add( diffuseColor );
-
-				}
-
-			} else if ( material.isMeshLambertMaterial || material.isMeshPhongMaterial ) {
-
-				var normalComputed = false;
-
-				for ( var i = 0, l = lights.length; i < l; i ++ ) {
-
-					var light = lights[ i ];
-
-					lightVector.setFromMatrixPosition( light.matrixWorld );
-					lightVector.sub( point );
-
-					rayLight.direction.copy( lightVector ).normalize();
-
-					var intersections = raycasterLight.intersectObjects( objects, true );
-
-					// point in shadow
-
-					if ( intersections.length > 0 ) continue;
-
-					// point lit
-
-					if ( normalComputed === false ) {
-
-						// the same normal can be reused for all lights
-						// (should be possible to cache even more)
-
-						localPoint.copy( point ).applyMatrix4( _object.inverseMatrix );
-						computePixelNormal( normalVector, localPoint, material.flatShading, face, geometry );
-						normalVector.applyMatrix3( _object.normalMatrix ).normalize();
-
-						normalComputed = true;
-
-					}
-
-					lightColor.copyGammaToLinear( light.color );
-
-					// compute attenuation
-
-					var attenuation = 1.0;
-
-					if ( light.physicalAttenuation === true ) {
-
-						attenuation = lightVector.length();
-						attenuation = 1.0 / ( attenuation * attenuation );
-
-					}
-
-					lightVector.normalize();
-
-					// compute diffuse
-
-					var dot = Math.max( normalVector.dot( lightVector ), 0 );
-					var diffuseIntensity = dot * light.intensity;
-
-					lightContribution.copy( diffuseColor );
-					lightContribution.multiply( lightColor );
-					lightContribution.multiplyScalar( diffuseIntensity * attenuation );
-
-					outputColor.add( lightContribution );
-
-					// compute specular
-
-					if ( material.isMeshPhongMaterial ) {
-
-						halfVector.addVectors( lightVector, eyeVector ).normalize();
-
-						var dotNormalHalf = Math.max( normalVector.dot( halfVector ), 0.0 );
-						var specularIntensity = Math.max( Math.pow( dotNormalHalf, material.shininess ), 0.0 ) * diffuseIntensity;
-
-						var specularNormalization = ( material.shininess + 2.0 ) / 8.0;
-
-						specularColor.copyGammaToLinear( material.specular );
-
-						var alpha = Math.pow( Math.max( 1.0 - lightVector.dot( halfVector ), 0.0 ), 5.0 );
-
-						schlick.r = specularColor.r + ( 1.0 - specularColor.r ) * alpha;
-						schlick.g = specularColor.g + ( 1.0 - specularColor.g ) * alpha;
-						schlick.b = specularColor.b + ( 1.0 - specularColor.b ) * alpha;
-
-						lightContribution.copy( schlick );
-						lightContribution.multiply( lightColor );
-						lightContribution.multiplyScalar( specularNormalization * specularIntensity * attenuation );
-
-						outputColor.add( lightContribution );
-
-					}
-
-				}
-
-			}
-
-			// reflection / refraction
-
-			var reflectivity = material.reflectivity;
-
-			if ( ( material.mirror || material.glass ) && reflectivity > 0 && recursionDepth < maxRecursionDepth ) {
-
-				if ( material.mirror ) {
-
-					reflectionVector.copy( rayDirection );
-					reflectionVector.reflect( normalVector );
-
-				} else if ( material.glass ) {
-
-					var eta = material.refractionRatio;
-
-					var dotNI = rayDirection.dot( normalVector );
-					var k = 1.0 - eta * eta * ( 1.0 - dotNI * dotNI );
-
-					if ( k < 0.0 ) {
-
-						reflectionVector.set( 0, 0, 0 );
-
-					} else {
-
-						reflectionVector.copy( rayDirection );
-						reflectionVector.multiplyScalar( eta );
-
-						var alpha = eta * dotNI + Math.sqrt( k );
-						tmpVec.copy( normalVector );
-						tmpVec.multiplyScalar( alpha );
-						reflectionVector.sub( tmpVec );
-
-					}
-
-				}
-
-				var theta = Math.max( eyeVector.dot( normalVector ), 0.0 );
-				var rf0 = reflectivity;
-				var fresnel = rf0 + ( 1.0 - rf0 ) * Math.pow( ( 1.0 - theta ), 5.0 );
-
-				var weight = fresnel;
-
-				var zColor = tmpColor[ recursionDepth ];
-
-				spawnRay( point, reflectionVector, zColor, recursionDepth + 1 );
-
-				if ( material.specular !== undefined ) {
-
-					zColor.multiply( material.specular );
-
-				}
-
-				zColor.multiplyScalar( weight );
-				outputColor.multiplyScalar( 1 - weight );
-				outputColor.add( zColor );
-
-			}
-
-		};
-
-	}() );
-
-	var computePixelNormal = ( function () {
-
-		var vA = new THREE.Vector3();
-		var vB = new THREE.Vector3();
-		var vC = new THREE.Vector3();
-
-		var tmpVec1 = new THREE.Vector3();
-		var tmpVec2 = new THREE.Vector3();
-		var tmpVec3 = new THREE.Vector3();
-
-		return function computePixelNormal( outputVector, point, flatShading, face, geometry ) {
-
-			var faceNormal = face.normal;
-
-			if ( flatShading === true ) {
-
-				outputVector.copy( faceNormal );
-
-			} else {
-
-				var positions = geometry.attributes.position;
-				var normals = geometry.attributes.normal;
-
-				vA.fromBufferAttribute( positions, face.a );
-				vB.fromBufferAttribute( positions, face.b );
-				vC.fromBufferAttribute( positions, face.c );
-
-				// compute barycentric coordinates
-
-				tmpVec3.crossVectors( tmpVec1.subVectors( vB, vA ), tmpVec2.subVectors( vC, vA ) );
-				var areaABC = faceNormal.dot( tmpVec3 );
-
-				tmpVec3.crossVectors( tmpVec1.subVectors( vB, point ), tmpVec2.subVectors( vC, point ) );
-				var areaPBC = faceNormal.dot( tmpVec3 );
-				var a = areaPBC / areaABC;
-
-				tmpVec3.crossVectors( tmpVec1.subVectors( vC, point ), tmpVec2.subVectors( vA, point ) );
-				var areaPCA = faceNormal.dot( tmpVec3 );
-				var b = areaPCA / areaABC;
-
-				var c = 1.0 - a - b;
-
-				// compute interpolated vertex normal
-
-				tmpVec1.fromBufferAttribute( normals, face.a );
-				tmpVec2.fromBufferAttribute( normals, face.b );
-				tmpVec3.fromBufferAttribute( normals, face.c );
-
-				tmpVec1.multiplyScalar( a );
-				tmpVec2.multiplyScalar( b );
-				tmpVec3.multiplyScalar( c );
-
-				outputVector.addVectors( tmpVec1, tmpVec2 );
-				outputVector.add( tmpVec3 );
-
-			}
-
-		};
-
-	}() );
-
-	var renderBlock = ( function () {
-
-		var blockSize = BLOCK;
-
-		var data = new Uint8ClampedArray( blockSize * blockSize * 4 );
-
-		var pixelColor = new THREE.Color();
-
-		return function renderBlock( blockX, blockY ) {
-
-			var index = 0;
-
-			for ( var y = 0; y < blockSize; y ++ ) {
-
-				for ( var x = 0; x < blockSize; x ++, index += 4 ) {
-
-					// spawn primary ray at pixel position
-
-					origin.copy( cameraPosition );
-
-					direction.set( x + blockX - canvasWidthHalf, - ( y + blockY - canvasHeightHalf ), - perspective );
-					direction.applyMatrix3( cameraNormalMatrix ).normalize();
-
-					spawnRay( origin, direction, pixelColor, 0 );
-
-					// convert from linear to gamma
-
-					data[ index + 0 ] = Math.sqrt( pixelColor.r ) * 255;
-					data[ index + 1 ] = Math.sqrt( pixelColor.g ) * 255;
-					data[ index + 2 ] = Math.sqrt( pixelColor.b ) * 255;
-					data[ index + 3 ] = 255;
-
-				}
-
-			}
-
-			// Use transferable objects! :)
-			self.postMessage( {
-				data: data.buffer,
-				blockX: blockX,
-				blockY: blockY,
-				blockSize: blockSize,
-				sceneId: sceneId,
-				time: Date.now(), // time for this renderer
-			}, [ data.buffer ] );
-
-			data = new Uint8ClampedArray( blockSize * blockSize * 4 );
-
-		};
-
-	}() );
-
-	this.render = function ( scene, camera ) {
-
-		// update scene graph
-
-		if ( scene.autoUpdate === true ) scene.updateMatrixWorld();
-
-		// update camera matrices
-
-		if ( camera.parent === null ) camera.updateMatrixWorld();
-
-		cameraPosition.setFromMatrixPosition( camera.matrixWorld );
-
-		//
-
-		cameraNormalMatrix.getNormalMatrix( camera.matrixWorld );
-
-		perspective = 0.5 / Math.tan( THREE.MathUtils.degToRad( camera.fov * 0.5 ) ) * canvasHeight;
-
-		objects = scene.children;
-
-		// collect lights and set up object matrices
-
-		lights.length = 0;
-
-		scene.traverse( function ( object ) {
-
-			if ( object.isPointLight ) {
-
-				lights.push( object );
-
-			}
-
-			if ( cache[ object.id ] === undefined ) {
-
-				cache[ object.id ] = {
-					normalMatrix: new THREE.Matrix3(),
-					inverseMatrix: new THREE.Matrix4()
-				};
-
-			}
-
-			var _object = cache[ object.id ];
-
-			_object.normalMatrix.getNormalMatrix( object.matrixWorld );
-			_object.inverseMatrix.getInverse( object.matrixWorld );
-
-		} );
-
-		renderBlock( startX, startY );
-
-	};
-
-};
-
-Object.assign( THREE.RaytracingRendererWorker.prototype, THREE.EventDispatcher.prototype );

+ 0 - 30
examples/jsm/renderers/RaytracingRenderer.d.ts

@@ -1,30 +0,0 @@
-import {
-	EventDispatcher,
-	Color,
-	Scene,
-	Camera
-} from '../../../src/Three';
-
-export interface RaytracingRendererParameters {
-	alpha?: boolean;
-	blockSize?: number;
-	randomize: boolean;
-	workerPath: string;
-	workers: number;
-}
-
-export class RaytracingRenderer extends EventDispatcher {
-
-	constructor( parameters: RaytracingRendererParameters );
-	domElement: HTMLElement;
-	autoClear: boolean;
-	randomize: boolean;
-
-	setWorkers( w: number ): void;
-	setClearColor( color: Color, alpha: number ): void;
-	setPixelRatio(): void;
-	setSize( width: number, height: number ): void;
-	clear(): void;
-	render( scene: Scene, camera: Camera ): void;
-
-}

+ 0 - 291
examples/jsm/renderers/RaytracingRenderer.js

@@ -1,291 +0,0 @@
-/**
- * RaytracingRenderer renders by raytracing it's scene. However, it does not
- * compute the pixels itself but it hands off and coordinates the tasks for workers.
- * The workers compute the pixel values and this renderer simply paints it to the Canvas.
- *
- * @author zz85 / http://github.com/zz85
- */
-
-import {
-	Color,
-	EventDispatcher
-} from "../../../build/three.module.js";
-
-var RaytracingRenderer = function ( parameters ) {
-
-	parameters = parameters || {};
-
-	var scope = this;
-	var pool = [];
-	var renderering = false;
-
-	var canvas = document.createElement( 'canvas' );
-	var context = canvas.getContext( '2d', {
-		alpha: parameters.alpha === true
-	} );
-
-	var canvasWidth, canvasHeight;
-
-	var clearColor = new Color( 0x000000 );
-
-	this.domElement = canvas;
-
-	this.autoClear = true;
-
-	var workers = parameters.workers;
-	var blockSize = parameters.blockSize || 64;
-	this.randomize = parameters.randomize;
-
-	var toRender = [], workerId = 0, sceneId = 0;
-
-	console.log( '%cSpinning off ' + workers + ' Workers ', 'font-size: 20px; background: black; color: white; font-family: monospace;' );
-
-	this.setWorkers = function ( w ) {
-
-		workers = w || navigator.hardwareConcurrency || 4;
-
-		while ( pool.length < workers ) {
-
-			var worker = new Worker( parameters.workerPath );
-			worker.id = workerId ++;
-
-			worker.onmessage = function ( e ) {
-
-				var data = e.data;
-
-				if ( ! data ) return;
-
-				if ( data.blockSize && sceneId == data.sceneId ) { // we match sceneId here to be sure
-
-					var imagedata = new ImageData( new Uint8ClampedArray( data.data ), data.blockSize, data.blockSize );
-					context.putImageData( imagedata, data.blockX, data.blockY );
-
-					// completed
-
-					console.log( 'Worker ' + this.id, data.time / 1000, ( Date.now() - reallyThen ) / 1000 + ' s' );
-
-					if ( pool.length > workers ) {
-
-						pool.splice( pool.indexOf( this ), 1 );
-						return this.terminate();
-
-					}
-
-					renderNext( this );
-
-				}
-
-			};
-
-			worker.color = new Color().setHSL( Math.random(), 0.8, 0.8 ).getHexString();
-			pool.push( worker );
-
-			updateSettings( worker );
-
-			if ( renderering ) {
-
-				worker.postMessage( {
-					scene: sceneJSON,
-					camera: cameraJSON,
-					annex: materials,
-					sceneId: sceneId
-				} );
-
-				renderNext( worker );
-
-			}
-
-		}
-
-		if ( ! renderering ) {
-
-			while ( pool.length > workers ) {
-
-				pool.pop().terminate();
-
-			}
-
-		}
-
-	};
-
-	this.setWorkers( workers );
-
-	this.setClearColor = function ( color /*, alpha */ ) {
-
-		clearColor.set( color );
-
-	};
-
-	this.setPixelRatio = function () {};
-
-	this.setSize = function ( width, height ) {
-
-		canvas.width = width;
-		canvas.height = height;
-
-		canvasWidth = canvas.width;
-		canvasHeight = canvas.height;
-
-		pool.forEach( updateSettings );
-
-	};
-
-	this.setSize( canvas.width, canvas.height );
-
-	this.clear = function () {
-
-	};
-
-	//
-
-	var totalBlocks, xblocks, yblocks;
-
-	function updateSettings( worker ) {
-
-		worker.postMessage( {
-
-			init: [ canvasWidth, canvasHeight ],
-			worker: worker.id,
-			// workers: pool.length,
-			blockSize: blockSize
-
-		} );
-
-	}
-
-	function renderNext( worker ) {
-
-		if ( ! toRender.length ) {
-
-			renderering = false;
-			return scope.dispatchEvent( { type: "complete" } );
-
-		}
-
-		var current = toRender.pop();
-
-		var blockX = ( current % xblocks ) * blockSize;
-		var blockY = ( current / xblocks | 0 ) * blockSize;
-
-		worker.postMessage( {
-			render: true,
-			x: blockX,
-			y: blockY,
-			sceneId: sceneId
-		} );
-
-		context.fillStyle = '#' + worker.color;
-		context.fillRect( blockX, blockY, blockSize, blockSize );
-
-	}
-
-	var materials = {};
-
-	var sceneJSON, cameraJSON, reallyThen;
-
-	// additional properties that were not serialize automatically
-
-	var _annex = {
-
-		mirror: 1,
-		reflectivity: 1,
-		refractionRatio: 1,
-		glass: 1
-
-	};
-
-	function serializeObject( o ) {
-
-		var mat = o.material;
-
-		if ( ! mat || mat.uuid in materials ) return;
-
-		var props = {};
-		for ( var m in _annex ) {
-
-			if ( mat[ m ] !== undefined ) {
-
-				props[ m ] = mat[ m ];
-
-			}
-
-		}
-
-		materials[ mat.uuid ] = props;
-
-	}
-
-	this.render = function ( scene, camera ) {
-
-		renderering = true;
-
-		// update scene graph
-
-		if ( scene.autoUpdate === true ) scene.updateMatrixWorld();
-
-		// update camera matrices
-
-		if ( camera.parent === null ) camera.updateMatrixWorld();
-
-
-		sceneJSON = scene.toJSON();
-		cameraJSON = camera.toJSON();
-		++ sceneId;
-
-		scene.traverse( serializeObject );
-
-		pool.forEach( function ( worker ) {
-
-			worker.postMessage( {
-				scene: sceneJSON,
-				camera: cameraJSON,
-				annex: materials,
-				sceneId: sceneId
-			} );
-
-		} );
-
-		context.fillStyle = clearColor.getStyle();
-		context.fillRect( 0, 0, canvasWidth, canvasHeight );
-
-		reallyThen = Date.now();
-
-		xblocks = Math.ceil( canvasWidth / blockSize );
-		yblocks = Math.ceil( canvasHeight / blockSize );
-		totalBlocks = xblocks * yblocks;
-
-		toRender = [];
-
-		for ( var i = 0; i < totalBlocks; i ++ ) {
-
-			toRender.push( i );
-
-		}
-
-
-		// Randomize painting :)
-
-		if ( scope.randomize ) {
-
-			for ( var i = 0; i < totalBlocks; i ++ ) {
-
-				var swap = Math.random() * totalBlocks | 0;
-				var tmp = toRender[ swap ];
-				toRender[ swap ] = toRender[ i ];
-				toRender[ i ] = tmp;
-
-			}
-
-		}
-
-
-		pool.forEach( renderNext );
-
-	};
-
-};
-
-Object.assign( RaytracingRenderer.prototype, EventDispatcher.prototype );
-
-export { RaytracingRenderer };

+ 0 - 320
examples/raytracing_sandbox.html

@@ -1,320 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<title>three.js - raytracing renderer with web workers</title>
-		<meta charset="utf-8">
-		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
-		<link type="text/css" rel="stylesheet" href="main.css">
-	</head>
-	<body>
-
-		<div id="info">
-			<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - raytracing renderer (using <span id="workers"></span>
-			<button id="removeWorker">-</button><button id="addWorker">+</button> web workers) <br/>
-			<button id="rearrange">Rearrange</button><button id="render">Render</button>
-		</div>
-
-		<script type="module">
-
-			import * as THREE from '../build/three.module.js';
-
-			import { RaytracingRenderer } from './jsm/renderers/RaytracingRenderer.js';
-
-			var hash = location.hash ? location.hash.substring( 1 ) : '3';
-
-			var WORKERS = + hash || navigator.hardwareConcurrency || 3;
-
-			var camera, scene, renderer;
-			var group;
-
-			init();
-			render();
-
-			function initScene( width, height ) {
-
-				camera = new THREE.PerspectiveCamera( 60, width / height, 1, 1000 );
-				camera.position.z = 600;
-
-				scene = new THREE.Scene();
-				scene.background = new THREE.Color( 0xf0f0f0 );
-
-				// materials
-
-				var phongMaterial = new THREE.MeshPhongMaterial( {
-					color: 0xffffff,
-					specular: 0x222222,
-					shininess: 150,
-					vertexColors: THREE.NoColors,
-					flatShading: false
-				} );
-
-				var phongMaterialBox = new THREE.MeshPhongMaterial( {
-					color: 0xffffff,
-					specular: 0x111111,
-					shininess: 100,
-					vertexColors: THREE.NoColors,
-					flatShading: true
-				} );
-
-				var phongMaterialBoxBottom = new THREE.MeshPhongMaterial( {
-					color: 0x666666,
-					specular: 0x111111,
-					shininess: 100,
-					vertexColors: THREE.NoColors,
-					flatShading: true
-				} );
-
-				var phongMaterialBoxLeft = new THREE.MeshPhongMaterial( {
-					color: 0x990000,
-					specular: 0x111111,
-					shininess: 100,
-					vertexColors: THREE.NoColors,
-					flatShading: true
-				} );
-
-				var phongMaterialBoxRight = new THREE.MeshPhongMaterial( {
-					color: 0x0066ff,
-					specular: 0x111111,
-					shininess: 100,
-					vertexColors: THREE.NoColors,
-					flatShading: true
-				} );
-
-				var mirrorMaterialFlat = new THREE.MeshPhongMaterial( {
-					color: 0x000000,
-					specular: 0xff8888,
-					shininess: 10000,
-					vertexColors: THREE.NoColors,
-					flatShading: true
-				} );
-				mirrorMaterialFlat.mirror = true;
-				mirrorMaterialFlat.reflectivity = 1;
-
-				var mirrorMaterialFlatDark = new THREE.MeshPhongMaterial( {
-					color: 0x000000,
-					specular: 0xaaaaaa,
-					shininess: 10000,
-					vertexColors: THREE.NoColors,
-					flatShading: true
-				} );
-				mirrorMaterialFlatDark.mirror = true;
-				mirrorMaterialFlatDark.reflectivity = 1;
-
-				var mirrorMaterialSmooth = new THREE.MeshPhongMaterial( {
-					color: 0xffaa00,
-					specular: 0x222222,
-					shininess: 10000,
-					vertexColors: THREE.NoColors,
-					flatShading: false
-				} );
-				mirrorMaterialSmooth.mirror = true;
-				mirrorMaterialSmooth.reflectivity = 0.3;
-
-				var glassMaterialFlat = new THREE.MeshPhongMaterial( {
-					color: 0x000000,
-					specular: 0x00ff00,
-					shininess: 10000,
-					vertexColors: THREE.NoColors,
-					flatShading: true
-				} );
-				glassMaterialFlat.glass = true;
-				glassMaterialFlat.reflectivity = 0.5;
-
-				var glassMaterialSmooth = new THREE.MeshPhongMaterial( {
-					color: 0x000000,
-					specular: 0xffaa55,
-					shininess: 10000,
-					vertexColors: THREE.NoColors,
-					flatShading: false
-				} );
-				glassMaterialSmooth.glass = true;
-				glassMaterialSmooth.reflectivity = 0.25;
-				glassMaterialSmooth.refractionRatio = 0.6;
-
-				//
-
-				group = new THREE.Group();
-				scene.add( group );
-
-				// geometries
-
-				var sphereGeometry = new THREE.SphereBufferGeometry( 100, 16, 8 );
-				var planeGeometry = new THREE.BoxBufferGeometry( 600, 5, 600 );
-				var boxGeometry = new THREE.BoxBufferGeometry( 100, 100, 100 );
-
-				// Sphere
-
-				var sphere = new THREE.Mesh( sphereGeometry, phongMaterial );
-				sphere.scale.multiplyScalar( 0.5 );
-				sphere.position.set( - 50, - 250 + 5, - 50 );
-				group.add( sphere );
-
-				var sphere2 = new THREE.Mesh( sphereGeometry, mirrorMaterialSmooth );
-				sphere2.scale.multiplyScalar( 0.5 );
-				sphere2.position.set( 175, - 250 + 5, - 150 );
-				group.add( sphere2 );
-
-				// Box
-
-				var box = new THREE.Mesh( boxGeometry, mirrorMaterialFlat );
-				box.position.set( - 175, - 250 + 2.5, - 150 );
-				box.rotation.y = 0.5;
-				group.add( box );
-
-				// Glass
-
-				var glass = new THREE.Mesh( sphereGeometry, glassMaterialSmooth );
-				glass.scale.multiplyScalar( 0.5 );
-				glass.position.set( 75, - 250 + 5, - 75 );
-				glass.rotation.y = 0.5;
-				scene.add( glass );
-
-				// bottom
-
-				var plane = new THREE.Mesh( planeGeometry, phongMaterialBoxBottom );
-				plane.position.set( 0, - 300 + 2.5, - 300 );
-				scene.add( plane );
-
-				// top
-
-				var plane = new THREE.Mesh( planeGeometry, phongMaterialBox );
-				plane.position.set( 0, 300 - 2.5, - 300 );
-				scene.add( plane );
-
-				// back
-
-				var plane = new THREE.Mesh( planeGeometry, phongMaterialBox );
-				plane.rotation.x = 1.57;
-				plane.position.set( 0, 0, - 300 );
-				scene.add( plane );
-
-				var plane = new THREE.Mesh( planeGeometry, mirrorMaterialFlatDark );
-				plane.rotation.x = 1.57;
-				plane.position.set( 0, 0, - 300 + 10 );
-				plane.scale.multiplyScalar( 0.85 );
-				scene.add( plane );
-
-				// left
-
-				var plane = new THREE.Mesh( planeGeometry, phongMaterialBoxLeft );
-				plane.rotation.z = 1.57;
-				plane.position.set( - 300, 0, - 300 );
-				scene.add( plane );
-
-				// right
-
-				var plane = new THREE.Mesh( planeGeometry, phongMaterialBoxRight );
-				plane.rotation.z = 1.57;
-				plane.position.set( 300, 0, - 300 );
-				scene.add( plane );
-
-				// light
-
-				var intensity = 70000;
-
-				var light = new THREE.PointLight( 0xffaa55, intensity );
-				light.position.set( - 200, 100, 100 );
-				light.physicalAttenuation = true;
-				scene.add( light );
-
-				var light = new THREE.PointLight( 0x55aaff, intensity );
-				light.position.set( 200, 100, 100 );
-				light.physicalAttenuation = true;
-				scene.add( light );
-
-				var light = new THREE.PointLight( 0xffffff, intensity * 1.5 );
-				light.position.set( 0, 0, 300 );
-				light.physicalAttenuation = true;
-				scene.add( light );
-
-			}
-
-			function init() {
-
-				var buttonRearrange = document.getElementById( 'rearrange' );
-				buttonRearrange.addEventListener( 'click', rearrange );
-
-				var buttonRender = document.getElementById( 'render' );
-				buttonRender.addEventListener( 'click', render );
-
-				var buttonRemoveWorker = document.getElementById( 'removeWorker' );
-				buttonRemoveWorker.addEventListener( 'click', removeWorker );
-
-				var buttonAddWorker = document.getElementById( 'addWorker' );
-				buttonAddWorker.addEventListener( 'click', addWorker );
-
-				updateWorkers();
-
-				//
-
-				initScene( window.innerWidth, window.innerHeight );
-
-				//
-
-				renderer = new RaytracingRenderer( {
-					workers: WORKERS,
-					workerPath: 'js/renderers/RaytracingWorker.js',
-					randomize: true,
-					blockSize: 64
-				} );
-				renderer.setSize( window.innerWidth, window.innerHeight );
-				document.body.appendChild( renderer.domElement );
-
-
-				window.addEventListener( 'resize', function () {
-
-					renderer.setSize( innerWidth, innerHeight );
-
-				} );
-
-			}
-
-			function addWorker() {
-
-				updateWorkers( 1 );
-
-			}
-
-			function removeWorker() {
-
-				updateWorkers( - 1 );
-
-			}
-
-			function updateWorkers( x ) {
-
-				if ( x ) {
-
-					WORKERS = Math.max( 1, WORKERS + x );
-					renderer.setWorkers( WORKERS );
-
-				}
-
-				var labelWorkers = document.getElementById( 'workers' );
-				labelWorkers.textContent = WORKERS;
-
-			}
-
-			function rearrange() {
-
-				group.children.forEach( function ( o ) {
-
- 					o.position.y += ( Math.random() - 0.5 ) * 100;
-					o.position.x += ( Math.random() - 0.5 ) * 400;
-					o.position.z += ( Math.random() - 0.5 ) * 400;
-
-				} );
-
- 			}
-
-			function render() {
-
-				renderer.render( scene, camera );
-
-			}
-
-
-		</script>
-
-	</body>
-</html>

+ 0 - 1
utils/modularize.js

@@ -169,7 +169,6 @@ var files = [
 	{ path: 'renderers/CSS2DRenderer.js', dependencies: [], ignoreList: [] },
 	{ path: 'renderers/CSS3DRenderer.js', dependencies: [], ignoreList: [] },
 	{ path: 'renderers/Projector.js', dependencies: [], ignoreList: [] },
-	{ path: 'renderers/RaytracingRenderer.js', dependencies: [], ignoreList: [] },
 	{ path: 'renderers/SVGRenderer.js', dependencies: [ { name: 'Projector', path: 'renderers/Projector.js' }, { name: 'RenderableFace', path: 'renderers/Projector.js' }, { name: 'RenderableLine', path: 'renderers/Projector.js' }, { name: 'RenderableSprite', path: 'renderers/Projector.js' } ], ignoreList: [] },
 	{ path: 'renderers/WebGLDeferredRenderer.js', dependencies: [ { name: 'EffectComposer', path: 'postprocessing/EffectComposer.js' }, { name: 'ShaderPass', path: 'postprocessing/ShaderPass.js' }, { name: 'RenderPass', path: 'postprocessing/RenderPass.js' }, { name: 'FXAAShader', path: 'shaders/FXAAShader.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' } ], ignoreList: [] },