ソースを参照

Merge branch 'dev' into geometry

Mr.doob 4 年 前
コミット
e76995ba35

+ 7 - 8
build/three.js

@@ -18393,7 +18393,11 @@
 			var parameters = programCache.getParameters(material, lights.state, shadowsArray, scene, object);
 			var programCacheKey = programCache.getProgramCacheKey(parameters);
 			var program = materialProperties.program;
-			var programChange = true;
+			var programChange = true; // always update environment and fog - changing these trigger an initMaterial call, but it's possible that the program doesn't change
+
+			materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
+			materialProperties.fog = scene.fog;
+			materialProperties.envMap = cubemaps.get(material.envMap || materialProperties.environment);
 
 			if (program === undefined) {
 				// new material
@@ -18404,9 +18408,7 @@
 			} else if (materialProperties.lightsStateVersion !== lightsStateVersion) {
 				programChange = false;
 			} else if (parameters.shaderID !== undefined) {
-				// same glsl and uniform list, envMap still needs the update here to avoid a frame-late effect
-				var environment = material.isMeshStandardMaterial ? scene.environment : null;
-				materialProperties.envMap = cubemaps.get(material.envMap || environment);
+				// same glsl and uniform list
 				return;
 			} else {
 				// only rebuild uniform list
@@ -18428,11 +18430,8 @@
 				materialProperties.numClippingPlanes = clipping.numPlanes;
 				materialProperties.numIntersection = clipping.numIntersection;
 				uniforms.clippingPlanes = clipping.uniform;
-			}
+			} // store the light setup it was created for
 
-			materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
-			materialProperties.fog = scene.fog;
-			materialProperties.envMap = cubemaps.get(material.envMap || materialProperties.environment); // store the light setup it was created for
 
 			materialProperties.needsLights = materialNeedsLights(material);
 			materialProperties.lightsStateVersion = lightsStateVersion;

ファイルの差分が大きいため隠しています
+ 0 - 0
build/three.min.js


+ 7 - 9
build/three.module.js

@@ -24583,6 +24583,12 @@ function WebGLRenderer( parameters ) {
 		let program = materialProperties.program;
 		let programChange = true;
 
+		// always update environment and fog - changing these trigger an initMaterial call, but it's possible that the program doesn't change
+
+		materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
+		materialProperties.fog = scene.fog;
+		materialProperties.envMap = cubemaps.get( material.envMap || materialProperties.environment );
+
 		if ( program === undefined ) {
 
 			// new material
@@ -24599,11 +24605,7 @@ function WebGLRenderer( parameters ) {
 
 		} else if ( parameters.shaderID !== undefined ) {
 
-			// same glsl and uniform list, envMap still needs the update here to avoid a frame-late effect
-
-			const environment = material.isMeshStandardMaterial ? scene.environment : null;
-			materialProperties.envMap = cubemaps.get( material.envMap || environment );
-
+			// same glsl and uniform list
 			return;
 
 		} else {
@@ -24639,10 +24641,6 @@ function WebGLRenderer( parameters ) {
 
 		}
 
-		materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
-		materialProperties.fog = scene.fog;
-		materialProperties.envMap = cubemaps.get( material.envMap || materialProperties.environment );
-
 		// store the light setup it was created for
 
 		materialProperties.needsLights = materialNeedsLights( material );

+ 1 - 0
docs/list.json

@@ -14,6 +14,7 @@
 				"Drawing lines": "manual/en/introduction/Drawing-lines",
 				"Creating text": "manual/en/introduction/Creating-text",
 				"Loading 3D models": "manual/en/introduction/Loading-3D-models",
+				"Libraries and Plugins": "manual/en/introduction/Libraries-and-Plugins",
 				"FAQ": "manual/en/introduction/FAQ",
 				"Useful links": "manual/en/introduction/Useful-links"
 			},

+ 86 - 0
docs/manual/en/introduction/Libraries-and-Plugins.html

@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<meta charset="utf-8" />
+		<base href="../../../" />
+		<script src="page.js"></script>
+		<link type="text/css" rel="stylesheet" href="page.css" />
+	</head>
+	<body>
+		<h1>[name]</h1>
+
+		<p class="desc">
+			Listed here are externally developed compatible libraries and plugins for three.js. This
+			list and the associated packages are maintained by the community and not guaranteed
+			to be up to date. If you'd like to update this list make PR!
+		</p>
+
+		<h3>Physics</h3>
+
+		<ul>
+			<li>[link:https://github.com/lo-th/Oimo.js/ Oimo.js]</li>
+			<li>[link:https://enable3d.io/ enable3d]</li>
+			<li>[link:https://github.com/kripken/ammo.js/ ammo.js]</li>
+			<li>[link:https://github.com/pmndrs/cannon-es cannon-es]</li>
+		</ul>
+
+		<h3>Postprocessing</h3>
+		
+		<p>
+			In addition to the [link:https://github.com/mrdoob/three.js/tree/dev/examples/jsm/postprocessing official three.js postprocessing effects],
+			support for some additional effects and frameworks are available through external libraries.
+		</p>
+
+		<ul>
+			<li>[link:https://github.com/vanruesc/postprocessing postprocessing]</li>
+		</ul>
+
+		<h3>Intersection and Raycasting Performance</h3>
+		
+		<ul>
+			<li>[link:https://github.com/gkjohnson/three-mesh-bvh three-mesh-bvh]</li>
+		</ul>
+
+		<h3>File Formats</h3>
+
+		<p>
+			In addition to the [link:https://github.com/mrdoob/three.js/tree/dev/examples/jsm/loaders official three.js loaders],
+			support for some additional formats is available through external libraries.
+		</p>
+
+		<ul>
+			<li>[link:https://github.com/gkjohnson/urdf-loaders/tree/master/javascript urdf-loader]</li>
+			<li>[link:https://github.com/NASA-AMMOS/3DTilesRendererJS 3d-tiles-renderer-js]</li>
+			<li>[link:https://github.com/kaisalmen/WWOBJLoader WebWorker OBJLoader]</li>
+		</ul>
+
+		<h3>3D Text and Layout</h3>
+
+		<ul>
+			<li>[link:https://github.com/protectwise/troika/tree/master/packages/troika-three-text troika-three-text]</li>
+			<li>[link:https://github.com/felixmariotto/three-mesh-ui three-mesh-ui]</li>
+		</ul>
+
+		<h3>Particle Systems</h3>
+
+		<ul>
+			<li>[link:https://github.com/creativelifeform/three-nebula three-nebula]</li>
+		</ul>
+
+		<h3>Game AI</h3>
+
+		<ul>
+			<li>[link:https://mugen87.github.io/yuka/ yuka]</li>
+			<li>[link:https://github.com/donmccurdy/three-pathfinding three-pathfinding]</li>
+		</ul>
+
+		<h3>Wrappers and Frameworks</h3>
+		
+		<ul>
+			<li>[link:https://aframe.io/ A-Frame]</li>
+			<li>[link:https://github.com/pmndrs/react-three-fiber react-three-fiber]</li>
+			<li>[link:https://github.com/ecsyjs/ecsy-three ECSY]</li>
+		</ul>
+
+	</body>
+</html>

BIN
examples/screenshots/webgl_geometry_text.jpg


+ 20 - 7
examples/webgl_geometry_convex.html

@@ -16,6 +16,7 @@
 
 			import { OrbitControls } from './jsm/controls/OrbitControls.js';
 			import { ConvexBufferGeometry } from './jsm/geometries/ConvexGeometry.js';
+			import { BufferGeometryUtils } from './jsm/utils/BufferGeometryUtils.js';
 
 			let group, camera, scene, renderer;
 
@@ -43,13 +44,13 @@
 				controls.minDistance = 20;
 				controls.maxDistance = 50;
 				controls.maxPolarAngle = Math.PI / 2;
-				
+
 				// ambient light
-				
+
 				scene.add( new THREE.AmbientLight( 0x222222 ) );
-				
+
 				// point light
-				
+
 				const light = new THREE.PointLight( 0xffffff, 1 );
 				camera.add( light );
 
@@ -67,11 +68,23 @@
 
 				// points
 
-				const vertices = new THREE.DodecahedronGeometry( 10 ).vertices;
+				let dodecahedronGeometry = new THREE.DodecahedronBufferGeometry( 10 );
+
+				// if normal and uv attributes are not removed, mergeVertices() can't consolidate indentical vertices with different normal/uv data
+
+				dodecahedronGeometry.deleteAttribute( 'normal' );
+				dodecahedronGeometry.deleteAttribute( 'uv' );
+
+				dodecahedronGeometry = BufferGeometryUtils.mergeVertices( dodecahedronGeometry );
+
+				const vertices = [];
+				const positionAttribute = dodecahedronGeometry.getAttribute( 'position' );
 
-				for ( let i = 0; i < vertices.length; i ++ ) {
+				for ( let i = 0; i < positionAttribute.count; i ++ ) {
 
-					//vertices[ i ].add( randomPoint().multiplyScalar( 2 ) ); // wiggle the points
+					const vertex = new THREE.Vector3();
+					vertex.fromBufferAttribute( positionAttribute, i );
+					vertices.push( vertex );
 
 				}
 

+ 1 - 48
examples/webgl_geometry_text.html

@@ -339,7 +339,7 @@
 
 			function createText() {
 
-				textGeo = new THREE.TextGeometry( text, {
+				textGeo = new THREE.TextBufferGeometry( text, {
 
 					font: font,
 
@@ -354,56 +354,9 @@
 				} );
 
 				textGeo.computeBoundingBox();
-				textGeo.computeVertexNormals();
-
-				const triangle = new THREE.Triangle();
-
-				// "fix" side normals by removing z-component of normals for side faces
-				// (this doesn't work well for beveled geometry as then we lose nice curvature around z-axis)
-
-				if ( ! bevelEnabled ) {
-
-					const triangleAreaHeuristics = 0.1 * ( height * size );
-
-					for ( let i = 0; i < textGeo.faces.length; i ++ ) {
-
-						const face = textGeo.faces[ i ];
-
-						if ( face.materialIndex == 1 ) {
-
-							for ( let j = 0; j < face.vertexNormals.length; j ++ ) {
-
-								face.vertexNormals[ j ].z = 0;
-								face.vertexNormals[ j ].normalize();
-
-							}
-
-							const va = textGeo.vertices[ face.a ];
-							const vb = textGeo.vertices[ face.b ];
-							const vc = textGeo.vertices[ face.c ];
-
-							const s = triangle.set( va, vb, vc ).getArea();
-
-							if ( s > triangleAreaHeuristics ) {
-
-								for ( let j = 0; j < face.vertexNormals.length; j ++ ) {
-
-									face.vertexNormals[ j ].copy( face.normal );
-
-								}
-
-							}
-
-						}
-
-					}
-
-				}
 
 				const centerOffset = - 0.5 * ( textGeo.boundingBox.max.x - textGeo.boundingBox.min.x );
 
-				textGeo = new THREE.BufferGeometry().fromGeometry( textGeo );
-
 				textMesh1 = new THREE.Mesh( textGeo, materials );
 
 				textMesh1.position.x = centerOffset;

+ 7 - 9
src/renderers/WebGLRenderer.js

@@ -1339,6 +1339,12 @@ function WebGLRenderer( parameters ) {
 		let program = materialProperties.program;
 		let programChange = true;
 
+		// always update environment and fog - changing these trigger an initMaterial call, but it's possible that the program doesn't change
+
+		materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
+		materialProperties.fog = scene.fog;
+		materialProperties.envMap = cubemaps.get( material.envMap || materialProperties.environment );
+
 		if ( program === undefined ) {
 
 			// new material
@@ -1355,11 +1361,7 @@ function WebGLRenderer( parameters ) {
 
 		} else if ( parameters.shaderID !== undefined ) {
 
-			// same glsl and uniform list, envMap still needs the update here to avoid a frame-late effect
-
-			const environment = material.isMeshStandardMaterial ? scene.environment : null;
-			materialProperties.envMap = cubemaps.get( material.envMap || environment );
-
+			// same glsl and uniform list
 			return;
 
 		} else {
@@ -1395,10 +1397,6 @@ function WebGLRenderer( parameters ) {
 
 		}
 
-		materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
-		materialProperties.fog = scene.fog;
-		materialProperties.envMap = cubemaps.get( material.envMap || materialProperties.environment );
-
 		// store the light setup it was created for
 
 		materialProperties.needsLights = materialNeedsLights( material );

+ 2 - 2
test/unit/src/animation/PropertyBinding.tests.js

@@ -1,7 +1,7 @@
 /* global QUnit */
 
 import { PropertyBinding } from '../../../../src/animation/PropertyBinding';
-import { BoxGeometry } from '../../../../src/geometries/BoxGeometry';
+import { BoxBufferGeometry } from '../../../../src/geometries/BoxBufferGeometry';
 import { Mesh } from '../../../../src/objects/Mesh';
 import { MeshBasicMaterial } from '../../../../src/materials/MeshBasicMaterial';
 
@@ -331,7 +331,7 @@ export default QUnit.module( 'Animation', () => {
 				var originalValue = 0;
 				var expectedValue = 1;
 
-				var geometry = new BoxGeometry();
+				var geometry = new BoxBufferGeometry();
 				var material = new MeshBasicMaterial();
 				material.opacity = originalValue;
 				var mesh = new Mesh( geometry, material );

+ 4 - 4
test/unit/src/helpers/BoxHelper.tests.js

@@ -2,8 +2,8 @@
 
 import { runStdGeometryTests } from '../../utils/qunit-utils';
 import { BoxHelper } from '../../../../src/helpers/BoxHelper';
-import { BoxGeometry } from '../../../../src/geometries/BoxGeometry';
-import { SphereGeometry } from '../../../../src/geometries/SphereGeometry';
+import { BoxBufferGeometry } from '../../../../src/geometries/BoxBufferGeometry';
+import { SphereBufferGeometry } from '../../../../src/geometries/SphereBufferGeometry';
 import { Mesh } from '../../../../src/objects/Mesh';
 
 export default QUnit.module( 'Helpers', () => {
@@ -14,12 +14,12 @@ export default QUnit.module( 'Helpers', () => {
 		hooks.beforeEach( function () {
 
 			// Test with a normal cube and a box helper
-			var boxGeometry = new BoxGeometry();
+			var boxGeometry = new BoxBufferGeometry();
 			var box = new Mesh( boxGeometry );
 			var boxHelper = new BoxHelper( box );
 
 			// The same should happen with a comparable sphere
-			var sphereGeometry = new SphereGeometry();
+			var sphereGeometry = new SphereBufferGeometry();
 			var sphere = new Mesh( sphereGeometry );
 			var sphereBoxHelper = new BoxHelper( sphere );
 

+ 3 - 4
test/unit/src/math/Box3.tests.js

@@ -8,7 +8,6 @@ import { Vector3 } from '../../../../src/math/Vector3';
 import { Matrix4 } from '../../../../src/math/Matrix4';
 import { Mesh } from '../../../../src/objects/Mesh';
 import { BufferAttribute } from '../../../../src/core/BufferAttribute';
-import { BoxGeometry } from '../../../../src/geometries/BoxGeometry';
 import { BoxBufferGeometry } from '../../../../src/geometries/BoxBufferGeometry';
 import {
 	negInf3,
@@ -305,9 +304,9 @@ export default QUnit.module( 'Maths', () => {
 
 			var a = new Box3( zero3.clone(), one3.clone() );
 			var b = a.clone();
-			var bigger = new Mesh( new BoxGeometry( 2, 2, 2 ) );
-			var smaller = new Mesh( new BoxGeometry( 0.5, 0.5, 0.5 ) );
-			var child = new Mesh( new BoxGeometry( 1, 1, 1 ) );
+			var bigger = new Mesh( new BoxBufferGeometry( 2, 2, 2 ) );
+			var smaller = new Mesh( new BoxBufferGeometry( 0.5, 0.5, 0.5 ) );
+			var child = new Mesh( new BoxBufferGeometry( 1, 1, 1 ) );
 
 			// just a bigger box to begin with
 			a.expandByObject( bigger );

+ 2 - 2
test/unit/src/math/Frustum.tests.js

@@ -8,7 +8,7 @@ import { Vector3 } from '../../../../src/math/Vector3';
 import { Matrix4 } from '../../../../src/math/Matrix4';
 import { Box3 } from '../../../../src/math/Box3';
 import { Mesh } from '../../../../src/objects/Mesh';
-import { BoxGeometry } from '../../../../src/geometries/BoxGeometry';
+import { BoxBufferGeometry } from '../../../../src/geometries/BoxBufferGeometry';
 import { zero3, one3, eps } from './Constants.tests';
 
 const unit3 = new Vector3( 1, 0, 0 );
@@ -204,7 +204,7 @@ export default QUnit.module( 'Maths', () => {
 
 			var m = new Matrix4().makePerspective( - 1, 1, 1, - 1, 1, 100 );
 			var a = new Frustum().setFromProjectionMatrix( m );
-			var object = new Mesh( new BoxGeometry( 1, 1, 1 ) );
+			var object = new Mesh( new BoxBufferGeometry( 1, 1, 1 ) );
 			var intersects;
 
 			intersects = a.intersectsObject( object );

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません