瀏覽代碼

Updated builds.

Mugen87 2 年之前
父節點
當前提交
ad2d035aba
共有 4 個文件被更改,包括 202 次插入116 次删除
  1. 61 38
      build/three.cjs
  2. 61 38
      build/three.js
  3. 0 0
      build/three.min.js
  4. 80 40
      build/three.module.js

+ 61 - 38
build/three.cjs

@@ -14099,7 +14099,7 @@ function WebGLState(gl, extensions, capabilities) {
 	const depthBuffer = new DepthBuffer();
 	const stencilBuffer = new StencilBuffer();
 	const uboBindings = new WeakMap();
-	const uboProgamMap = new WeakMap();
+	const uboProgramMap = new WeakMap();
 	let enabledCapabilities = {};
 	let currentBoundFramebuffers = {};
 	let currentDrawbuffers = new WeakMap();
@@ -14560,10 +14560,10 @@ function WebGLState(gl, extensions, capabilities) {
 		}
 	}
 	function updateUBOMapping(uniformsGroup, program) {
-		let mapping = uboProgamMap.get(program);
+		let mapping = uboProgramMap.get(program);
 		if (mapping === undefined) {
 			mapping = new WeakMap();
-			uboProgamMap.set(program, mapping);
+			uboProgramMap.set(program, mapping);
 		}
 		let blockIndex = mapping.get(uniformsGroup);
 		if (blockIndex === undefined) {
@@ -14572,13 +14572,12 @@ function WebGLState(gl, extensions, capabilities) {
 		}
 	}
 	function uniformBlockBinding(uniformsGroup, program) {
-		const mapping = uboProgamMap.get(program);
+		const mapping = uboProgramMap.get(program);
 		const blockIndex = mapping.get(uniformsGroup);
-		if (uboBindings.get(uniformsGroup) !== blockIndex) {
+		if (uboBindings.get(program) !== blockIndex) {
 			// bind shader specific block index to global block point
-
 			gl.uniformBlockBinding(program, blockIndex, uniformsGroup.__bindingPointIndex);
-			uboBindings.set(uniformsGroup, blockIndex);
+			uboBindings.set(program, blockIndex);
 		}
 	}
 
@@ -17242,32 +17241,36 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
 			// partly update the buffer if necessary
 
 			if (hasUniformChanged(uniform, i, cache) === true) {
-				const value = uniform.value;
 				const offset = uniform.__offset;
-				if (typeof value === 'number') {
-					uniform.__data[0] = value;
-					gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
-				} else {
-					if (uniform.value.isMatrix3) {
+				const values = Array.isArray(uniform.value) ? uniform.value : [uniform.value];
+				let arrayOffset = 0;
+				for (let i = 0; i < values.length; i++) {
+					const value = values[i];
+					const info = getUniformSize(value);
+					if (typeof value === 'number') {
+						uniform.__data[0] = value;
+						gl.bufferSubData(gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data);
+					} else if (value.isMatrix3) {
 						// manually converting 3x3 to 3x4
 
-						uniform.__data[0] = uniform.value.elements[0];
-						uniform.__data[1] = uniform.value.elements[1];
-						uniform.__data[2] = uniform.value.elements[2];
-						uniform.__data[3] = uniform.value.elements[0];
-						uniform.__data[4] = uniform.value.elements[3];
-						uniform.__data[5] = uniform.value.elements[4];
-						uniform.__data[6] = uniform.value.elements[5];
-						uniform.__data[7] = uniform.value.elements[0];
-						uniform.__data[8] = uniform.value.elements[6];
-						uniform.__data[9] = uniform.value.elements[7];
-						uniform.__data[10] = uniform.value.elements[8];
-						uniform.__data[11] = uniform.value.elements[0];
+						uniform.__data[0] = value.elements[0];
+						uniform.__data[1] = value.elements[1];
+						uniform.__data[2] = value.elements[2];
+						uniform.__data[3] = value.elements[0];
+						uniform.__data[4] = value.elements[3];
+						uniform.__data[5] = value.elements[4];
+						uniform.__data[6] = value.elements[5];
+						uniform.__data[7] = value.elements[0];
+						uniform.__data[8] = value.elements[6];
+						uniform.__data[9] = value.elements[7];
+						uniform.__data[10] = value.elements[8];
+						uniform.__data[11] = value.elements[0];
 					} else {
-						value.toArray(uniform.__data);
+						value.toArray(uniform.__data, arrayOffset);
+						arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
 					}
-					gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
 				}
+				gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
 			}
 		}
 		gl.bindBuffer(gl.UNIFORM_BUFFER, null);
@@ -17280,7 +17283,12 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
 			if (typeof value === 'number') {
 				cache[index] = value;
 			} else {
-				cache[index] = value.clone();
+				const values = Array.isArray(value) ? value : [value];
+				const tempValues = [];
+				for (let i = 0; i < values.length; i++) {
+					tempValues.push(values[i].clone());
+				}
+				cache[index] = tempValues;
 			}
 			return true;
 		} else {
@@ -17292,10 +17300,14 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
 					return true;
 				}
 			} else {
-				const cachedObject = cache[index];
-				if (cachedObject.equals(value) === false) {
-					cachedObject.copy(value);
-					return true;
+				const cachedObjects = Array.isArray(cache[index]) ? cache[index] : [cache[index]];
+				const values = Array.isArray(value) ? value : [value];
+				for (let i = 0; i < cachedObjects.length; i++) {
+					const cachedObject = cachedObjects[i];
+					if (cachedObject.equals(values[i]) === false) {
+						cachedObject.copy(values[i]);
+						return true;
+					}
 				}
 			}
 		}
@@ -17312,11 +17324,23 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
 
 		for (let i = 0, l = uniforms.length; i < l; i++) {
 			const uniform = uniforms[i];
-			const info = getUniformSize(uniform);
+			const infos = {
+				boundary: 0,
+				// bytes
+				storage: 0 // bytes
+			};
+
+			const values = Array.isArray(uniform.value) ? uniform.value : [uniform.value];
+			for (let j = 0, jl = values.length; j < jl; j++) {
+				const value = values[j];
+				const info = getUniformSize(value);
+				infos.boundary += info.boundary;
+				infos.storage += info.storage;
+			}
 
 			// the following two properties will be used for partial buffer updates
 
-			uniform.__data = new Float32Array(info.storage / Float32Array.BYTES_PER_ELEMENT);
+			uniform.__data = new Float32Array(infos.storage / Float32Array.BYTES_PER_ELEMENT);
 			uniform.__offset = offset;
 
 			//
@@ -17327,14 +17351,14 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
 
 				// check for chunk overflow
 
-				if (chunkOffset !== 0 && remainingSizeInChunk - info.boundary < 0) {
+				if (chunkOffset !== 0 && remainingSizeInChunk - infos.boundary < 0) {
 					// add padding and adjust offset
 
 					offset += chunkSize - chunkOffset;
 					uniform.__offset = offset;
 				}
 			}
-			offset += info.storage;
+			offset += infos.storage;
 		}
 
 		// ensure correct final padding
@@ -17348,8 +17372,7 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
 		uniformsGroup.__cache = {};
 		return this;
 	}
-	function getUniformSize(uniform) {
-		const value = uniform.value;
+	function getUniformSize(value) {
 		const info = {
 			boundary: 0,
 			// bytes

+ 61 - 38
build/three.js

@@ -14101,7 +14101,7 @@
 		const depthBuffer = new DepthBuffer();
 		const stencilBuffer = new StencilBuffer();
 		const uboBindings = new WeakMap();
-		const uboProgamMap = new WeakMap();
+		const uboProgramMap = new WeakMap();
 		let enabledCapabilities = {};
 		let currentBoundFramebuffers = {};
 		let currentDrawbuffers = new WeakMap();
@@ -14562,10 +14562,10 @@
 			}
 		}
 		function updateUBOMapping(uniformsGroup, program) {
-			let mapping = uboProgamMap.get(program);
+			let mapping = uboProgramMap.get(program);
 			if (mapping === undefined) {
 				mapping = new WeakMap();
-				uboProgamMap.set(program, mapping);
+				uboProgramMap.set(program, mapping);
 			}
 			let blockIndex = mapping.get(uniformsGroup);
 			if (blockIndex === undefined) {
@@ -14574,13 +14574,12 @@
 			}
 		}
 		function uniformBlockBinding(uniformsGroup, program) {
-			const mapping = uboProgamMap.get(program);
+			const mapping = uboProgramMap.get(program);
 			const blockIndex = mapping.get(uniformsGroup);
-			if (uboBindings.get(uniformsGroup) !== blockIndex) {
+			if (uboBindings.get(program) !== blockIndex) {
 				// bind shader specific block index to global block point
-
 				gl.uniformBlockBinding(program, blockIndex, uniformsGroup.__bindingPointIndex);
-				uboBindings.set(uniformsGroup, blockIndex);
+				uboBindings.set(program, blockIndex);
 			}
 		}
 
@@ -17244,32 +17243,36 @@
 				// partly update the buffer if necessary
 
 				if (hasUniformChanged(uniform, i, cache) === true) {
-					const value = uniform.value;
 					const offset = uniform.__offset;
-					if (typeof value === 'number') {
-						uniform.__data[0] = value;
-						gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
-					} else {
-						if (uniform.value.isMatrix3) {
+					const values = Array.isArray(uniform.value) ? uniform.value : [uniform.value];
+					let arrayOffset = 0;
+					for (let i = 0; i < values.length; i++) {
+						const value = values[i];
+						const info = getUniformSize(value);
+						if (typeof value === 'number') {
+							uniform.__data[0] = value;
+							gl.bufferSubData(gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data);
+						} else if (value.isMatrix3) {
 							// manually converting 3x3 to 3x4
 
-							uniform.__data[0] = uniform.value.elements[0];
-							uniform.__data[1] = uniform.value.elements[1];
-							uniform.__data[2] = uniform.value.elements[2];
-							uniform.__data[3] = uniform.value.elements[0];
-							uniform.__data[4] = uniform.value.elements[3];
-							uniform.__data[5] = uniform.value.elements[4];
-							uniform.__data[6] = uniform.value.elements[5];
-							uniform.__data[7] = uniform.value.elements[0];
-							uniform.__data[8] = uniform.value.elements[6];
-							uniform.__data[9] = uniform.value.elements[7];
-							uniform.__data[10] = uniform.value.elements[8];
-							uniform.__data[11] = uniform.value.elements[0];
+							uniform.__data[0] = value.elements[0];
+							uniform.__data[1] = value.elements[1];
+							uniform.__data[2] = value.elements[2];
+							uniform.__data[3] = value.elements[0];
+							uniform.__data[4] = value.elements[3];
+							uniform.__data[5] = value.elements[4];
+							uniform.__data[6] = value.elements[5];
+							uniform.__data[7] = value.elements[0];
+							uniform.__data[8] = value.elements[6];
+							uniform.__data[9] = value.elements[7];
+							uniform.__data[10] = value.elements[8];
+							uniform.__data[11] = value.elements[0];
 						} else {
-							value.toArray(uniform.__data);
+							value.toArray(uniform.__data, arrayOffset);
+							arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
 						}
-						gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
 					}
+					gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
 				}
 			}
 			gl.bindBuffer(gl.UNIFORM_BUFFER, null);
@@ -17282,7 +17285,12 @@
 				if (typeof value === 'number') {
 					cache[index] = value;
 				} else {
-					cache[index] = value.clone();
+					const values = Array.isArray(value) ? value : [value];
+					const tempValues = [];
+					for (let i = 0; i < values.length; i++) {
+						tempValues.push(values[i].clone());
+					}
+					cache[index] = tempValues;
 				}
 				return true;
 			} else {
@@ -17294,10 +17302,14 @@
 						return true;
 					}
 				} else {
-					const cachedObject = cache[index];
-					if (cachedObject.equals(value) === false) {
-						cachedObject.copy(value);
-						return true;
+					const cachedObjects = Array.isArray(cache[index]) ? cache[index] : [cache[index]];
+					const values = Array.isArray(value) ? value : [value];
+					for (let i = 0; i < cachedObjects.length; i++) {
+						const cachedObject = cachedObjects[i];
+						if (cachedObject.equals(values[i]) === false) {
+							cachedObject.copy(values[i]);
+							return true;
+						}
 					}
 				}
 			}
@@ -17314,11 +17326,23 @@
 
 			for (let i = 0, l = uniforms.length; i < l; i++) {
 				const uniform = uniforms[i];
-				const info = getUniformSize(uniform);
+				const infos = {
+					boundary: 0,
+					// bytes
+					storage: 0 // bytes
+				};
+
+				const values = Array.isArray(uniform.value) ? uniform.value : [uniform.value];
+				for (let j = 0, jl = values.length; j < jl; j++) {
+					const value = values[j];
+					const info = getUniformSize(value);
+					infos.boundary += info.boundary;
+					infos.storage += info.storage;
+				}
 
 				// the following two properties will be used for partial buffer updates
 
-				uniform.__data = new Float32Array(info.storage / Float32Array.BYTES_PER_ELEMENT);
+				uniform.__data = new Float32Array(infos.storage / Float32Array.BYTES_PER_ELEMENT);
 				uniform.__offset = offset;
 
 				//
@@ -17329,14 +17353,14 @@
 
 					// check for chunk overflow
 
-					if (chunkOffset !== 0 && remainingSizeInChunk - info.boundary < 0) {
+					if (chunkOffset !== 0 && remainingSizeInChunk - infos.boundary < 0) {
 						// add padding and adjust offset
 
 						offset += chunkSize - chunkOffset;
 						uniform.__offset = offset;
 					}
 				}
-				offset += info.storage;
+				offset += infos.storage;
 			}
 
 			// ensure correct final padding
@@ -17350,8 +17374,7 @@
 			uniformsGroup.__cache = {};
 			return this;
 		}
-		function getUniformSize(uniform) {
-			const value = uniform.value;
+		function getUniformSize(value) {
 			const info = {
 				boundary: 0,
 				// bytes

文件差異過大導致無法顯示
+ 0 - 0
build/three.min.js


+ 80 - 40
build/three.module.js

@@ -21462,7 +21462,7 @@ function WebGLState( gl, extensions, capabilities ) {
 	const stencilBuffer = new StencilBuffer();
 
 	const uboBindings = new WeakMap();
-	const uboProgamMap = new WeakMap();
+	const uboProgramMap = new WeakMap();
 
 	let enabledCapabilities = {};
 
@@ -22259,13 +22259,13 @@ function WebGLState( gl, extensions, capabilities ) {
 
 	function updateUBOMapping( uniformsGroup, program ) {
 
-		let mapping = uboProgamMap.get( program );
+		let mapping = uboProgramMap.get( program );
 
 		if ( mapping === undefined ) {
 
 			mapping = new WeakMap();
 
-			uboProgamMap.set( program, mapping );
+			uboProgramMap.set( program, mapping );
 
 		}
 
@@ -22283,16 +22283,15 @@ function WebGLState( gl, extensions, capabilities ) {
 
 	function uniformBlockBinding( uniformsGroup, program ) {
 
-		const mapping = uboProgamMap.get( program );
+		const mapping = uboProgramMap.get( program );
 		const blockIndex = mapping.get( uniformsGroup );
 
-		if ( uboBindings.get( uniformsGroup ) !== blockIndex ) {
+		if ( uboBindings.get( program ) !== blockIndex ) {
 
 			// bind shader specific block index to global block point
-
 			gl.uniformBlockBinding( program, blockIndex, uniformsGroup.__bindingPointIndex );
 
-			uboBindings.set( uniformsGroup, blockIndex );
+			uboBindings.set( program, blockIndex );
 
 		}
 
@@ -26651,43 +26650,52 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
 
 			if ( hasUniformChanged( uniform, i, cache ) === true ) {
 
-				const value = uniform.value;
 				const offset = uniform.__offset;
 
-				if ( typeof value === 'number' ) {
+				const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
 
-					uniform.__data[ 0 ] = value;
-					gl.bufferSubData( 35345, offset, uniform.__data );
+				let arrayOffset = 0;
 
-				} else {
+				for ( let i = 0; i < values.length; i ++ ) {
+
+					const value = values[ i ];
 
-					if ( uniform.value.isMatrix3 ) {
+					const info = getUniformSize( value );
+
+					if ( typeof value === 'number' ) {
+
+						uniform.__data[ 0 ] = value;
+						gl.bufferSubData( 35345, offset + arrayOffset, uniform.__data );
+
+					} else if ( value.isMatrix3 ) {
 
 						// manually converting 3x3 to 3x4
 
-						uniform.__data[ 0 ] = uniform.value.elements[ 0 ];
-						uniform.__data[ 1 ] = uniform.value.elements[ 1 ];
-						uniform.__data[ 2 ] = uniform.value.elements[ 2 ];
-						uniform.__data[ 3 ] = uniform.value.elements[ 0 ];
-						uniform.__data[ 4 ] = uniform.value.elements[ 3 ];
-						uniform.__data[ 5 ] = uniform.value.elements[ 4 ];
-						uniform.__data[ 6 ] = uniform.value.elements[ 5 ];
-						uniform.__data[ 7 ] = uniform.value.elements[ 0 ];
-						uniform.__data[ 8 ] = uniform.value.elements[ 6 ];
-						uniform.__data[ 9 ] = uniform.value.elements[ 7 ];
-						uniform.__data[ 10 ] = uniform.value.elements[ 8 ];
-						uniform.__data[ 11 ] = uniform.value.elements[ 0 ];
+						uniform.__data[ 0 ] = value.elements[ 0 ];
+						uniform.__data[ 1 ] = value.elements[ 1 ];
+						uniform.__data[ 2 ] = value.elements[ 2 ];
+						uniform.__data[ 3 ] = value.elements[ 0 ];
+						uniform.__data[ 4 ] = value.elements[ 3 ];
+						uniform.__data[ 5 ] = value.elements[ 4 ];
+						uniform.__data[ 6 ] = value.elements[ 5 ];
+						uniform.__data[ 7 ] = value.elements[ 0 ];
+						uniform.__data[ 8 ] = value.elements[ 6 ];
+						uniform.__data[ 9 ] = value.elements[ 7 ];
+						uniform.__data[ 10 ] = value.elements[ 8 ];
+						uniform.__data[ 11 ] = value.elements[ 0 ];
 
 					} else {
 
-						value.toArray( uniform.__data );
+						value.toArray( uniform.__data, arrayOffset );
 
-					}
+						arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
 
-					gl.bufferSubData( 35345, offset, uniform.__data );
+					}
 
 				}
 
+				gl.bufferSubData( 35345, offset, uniform.__data );
+
 			}
 
 		}
@@ -26710,7 +26718,17 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
 
 			} else {
 
-				cache[ index ] = value.clone();
+				const values = Array.isArray( value ) ? value : [ value ];
+
+				const tempValues = [];
+
+				for ( let i = 0; i < values.length; i ++ ) {
+
+					tempValues.push( values[ i ].clone() );
+
+				}
+
+				cache[ index ] = tempValues;
 
 			}
 
@@ -26731,12 +26749,19 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
 
 			} else {
 
-				const cachedObject = cache[ index ];
+				const cachedObjects = Array.isArray( cache[ index ] ) ? cache[ index ] : [ cache[ index ] ];
+				const values = Array.isArray( value ) ? value : [ value ];
 
-				if ( cachedObject.equals( value ) === false ) {
+				for ( let i = 0; i < cachedObjects.length; i ++ ) {
 
-					cachedObject.copy( value );
-					return true;
+					const cachedObject = cachedObjects[ i ];
+
+					if ( cachedObject.equals( values[ i ] ) === false ) {
+
+						cachedObject.copy( values[ i ] );
+						return true;
+
+					}
 
 				}
 
@@ -26762,11 +26787,28 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
 		for ( let i = 0, l = uniforms.length; i < l; i ++ ) {
 
 			const uniform = uniforms[ i ];
-			const info = getUniformSize( uniform );
+
+			const infos = {
+				boundary: 0, // bytes
+				storage: 0 // bytes
+			};
+
+			const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
+
+			for ( let j = 0, jl = values.length; j < jl; j ++ ) {
+
+				const value = values[ j ];
+
+				const info = getUniformSize( value );
+
+				infos.boundary += info.boundary;
+				infos.storage += info.storage;
+
+			}
 
 			// the following two properties will be used for partial buffer updates
 
-			uniform.__data = new Float32Array( info.storage / Float32Array.BYTES_PER_ELEMENT );
+			uniform.__data = new Float32Array( infos.storage / Float32Array.BYTES_PER_ELEMENT );
 			uniform.__offset = offset;
 
 			//
@@ -26779,7 +26821,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
 
 				// check for chunk overflow
 
-				if ( chunkOffset !== 0 && ( remainingSizeInChunk - info.boundary ) < 0 ) {
+				if ( chunkOffset !== 0 && ( remainingSizeInChunk - infos.boundary ) < 0 ) {
 
 					// add padding and adjust offset
 
@@ -26790,7 +26832,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
 
 			}
 
-			offset += info.storage;
+			offset += infos.storage;
 
 		}
 
@@ -26809,9 +26851,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
 
 	}
 
-	function getUniformSize( uniform ) {
-
-		const value = uniform.value;
+	function getUniformSize( value ) {
 
 		const info = {
 			boundary: 0, // bytes

部分文件因文件數量過多而無法顯示