Explorar o código

Merge remote-tracking branch 'upstream/dev' into dev11

Mugen87 %!s(int64=7) %!d(string=hai) anos
pai
achega
455ff3664c

+ 11 - 11
examples/js/controls/DeviceOrientationControls.js

@@ -5,12 +5,12 @@
  * W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)
  */
 
-THREE.DeviceOrientationControls = function( object ) {
+THREE.DeviceOrientationControls = function ( object ) {
 
 	var scope = this;
 
 	this.object = object;
-	this.object.rotation.reorder( "YXZ" );
+	this.object.rotation.reorder( 'YXZ' );
 
 	this.enabled = true;
 
@@ -19,13 +19,13 @@ THREE.DeviceOrientationControls = function( object ) {
 
 	this.alphaOffset = 0; // radians
 
-	var onDeviceOrientationChangeEvent = function( event ) {
+	var onDeviceOrientationChangeEvent = function ( event ) {
 
 		scope.deviceOrientation = event;
 
 	};
 
-	var onScreenOrientationChangeEvent = function() {
+	var onScreenOrientationChangeEvent = function () {
 
 		scope.screenOrientation = window.orientation || 0;
 
@@ -33,7 +33,7 @@ THREE.DeviceOrientationControls = function( object ) {
 
 	// The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''
 
-	var setObjectQuaternion = function() {
+	var setObjectQuaternion = function () {
 
 		var zee = new THREE.Vector3( 0, 0, 1 );
 
@@ -43,7 +43,7 @@ THREE.DeviceOrientationControls = function( object ) {
 
 		var q1 = new THREE.Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis
 
-		return function( quaternion, alpha, beta, gamma, orient ) {
+		return function ( quaternion, alpha, beta, gamma, orient ) {
 
 			euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us
 
@@ -53,11 +53,11 @@ THREE.DeviceOrientationControls = function( object ) {
 
 			quaternion.multiply( q0.setFromAxisAngle( zee, - orient ) ); // adjust for screen orientation
 
-		}
+		};
 
 	}();
 
-	this.connect = function() {
+	this.connect = function () {
 
 		onScreenOrientationChangeEvent(); // run once on load
 
@@ -68,7 +68,7 @@ THREE.DeviceOrientationControls = function( object ) {
 
 	};
 
-	this.disconnect = function() {
+	this.disconnect = function () {
 
 		window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
 		window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
@@ -77,7 +77,7 @@ THREE.DeviceOrientationControls = function( object ) {
 
 	};
 
-	this.update = function() {
+	this.update = function () {
 
 		if ( scope.enabled === false ) return;
 
@@ -100,7 +100,7 @@ THREE.DeviceOrientationControls = function( object ) {
 
 	};
 
-	this.dispose = function() {
+	this.dispose = function () {
 
 		scope.disconnect();
 

+ 165 - 104
examples/js/exporters/GLTFExporter.js

@@ -98,8 +98,9 @@ THREE.GLTFExporter.prototype = {
 		var byteOffset = 0;
 		var buffers = [];
 		var pending = [];
-		var nodeMap = {};
+		var nodeMap = new Map();
 		var skins = [];
+		var extensionsUsed = {};
 		var cachedData = {
 
 			materials: new Map(),
@@ -133,18 +134,7 @@ THREE.GLTFExporter.prototype = {
 		 * @param  {string} text
 		 * @return {ArrayBuffer}
 		 */
-		function stringToArrayBuffer( text, padded ) {
-			if ( padded ) {
-
-				var pad = getPaddedBufferSize( text.length ) - text.length;
-
-				for ( var i = 0; i < pad; i++ ) {
-
-					text += ' ';
-
-				}
-
-			}
+		function stringToArrayBuffer( text ) {
 
 			if ( window.TextEncoder !== undefined ) {
 
@@ -152,26 +142,29 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			var buffer = new ArrayBuffer( text.length );
+			var array = new Uint8Array( new ArrayBuffer( text.length ) );
 
-			var bufferView = new Uint8Array( buffer );
+			for ( var i = 0, il = text.length; i < il; i ++ ) {
 
-			for ( var i = 0; i < text.length; ++ i ) {
+				var value = text.charCodeAt( i );
 
-				bufferView[ i ] = text.charCodeAt( i );
+				// Replacing multi-byte character with space(0x20).
+				array[ i ] = value > 0xFF ? 0x20 : value
 
 			}
 
-			return buffer;
+			return array.buffer;
 
 		}
 
 		/**
 		 * Get the min and max vectors from the given attribute
-		 * @param  {THREE.BufferAttribute} attribute Attribute to find the min/max
+		 * @param  {THREE.BufferAttribute} attribute Attribute to find the min/max in range from start to start + count
+		 * @param  {Integer} start
+		 * @param  {Integer} count
 		 * @return {Object} Object containing the `min` and `max` values (As an array of attribute.itemSize components)
 		 */
-		function getMinMax( attribute ) {
+		function getMinMax( attribute, start, count ) {
 
 			var output = {
 
@@ -180,7 +173,7 @@ THREE.GLTFExporter.prototype = {
 
 			};
 
-			for ( var i = 0; i < attribute.count; i ++ ) {
+			for ( var i = start; i < start + count; i ++ ) {
 
 				for ( var a = 0; a < attribute.itemSize; a ++ ) {
 
@@ -227,17 +220,31 @@ THREE.GLTFExporter.prototype = {
 		 * Returns a buffer aligned to 4-byte boundary.
 		 *
 		 * @param {ArrayBuffer} arrayBuffer Buffer to pad
+		 * @param {Integer} paddingByte (Optional)
 		 * @returns {ArrayBuffer} The same buffer if it's already aligned to 4-byte boundary or a new buffer
 		 */
-		function getPaddedArrayBuffer( arrayBuffer ) {
+		function getPaddedArrayBuffer( arrayBuffer, paddingByte ) {
+
+			paddingByte = paddingByte || 0;
 
 			var paddedLength = getPaddedBufferSize( arrayBuffer.byteLength );
 
-			if (paddedLength !== arrayBuffer.byteLength ) {
+			if ( paddedLength !== arrayBuffer.byteLength ) {
+
+				var array = new Uint8Array( paddedLength );
+				array.set( new Uint8Array( arrayBuffer ) );
+
+				if ( paddingByte !== 0 ) {
+
+					for ( var i = arrayBuffer.byteLength; i < paddedLength; i ++ ) {
 
-				var paddedBuffer = new ArrayBuffer( paddedLength );
-				new Uint8Array( paddedBuffer ).set(new Uint8Array(arrayBuffer));
-				return paddedBuffer;
+						array[ i ] = paddingByte;
+
+					}
+
+				}
+
+				return array.buffer;
 
 			}
 
@@ -392,9 +399,11 @@ THREE.GLTFExporter.prototype = {
 		 * Process attribute to generate an accessor
 		 * @param  {THREE.BufferAttribute} attribute Attribute to process
 		 * @param  {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range
+		 * @param  {Integer} start (Optional)
+		 * @param  {Integer} count (Optional)
 		 * @return {Integer}           Index of the processed accessor on the "accessors" array
 		 */
-		function processAccessor( attribute, geometry ) {
+		function processAccessor( attribute, geometry, start, count ) {
 
 			if ( ! outputJSON.accessors ) {
 
@@ -433,27 +442,33 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			var minMax = getMinMax( attribute );
-
-			var start = 0;
-			var count = attribute.count;
+			if ( start === undefined ) start = 0;
+			if ( count === undefined ) count = attribute.count;
 
 			// @TODO Indexed buffer geometry with drawRange not supported yet
 			if ( options.truncateDrawRange && geometry !== undefined && geometry.index === null ) {
 
-				start = geometry.drawRange.start;
-				count = geometry.drawRange.count !== Infinity ? geometry.drawRange.count : attribute.count;
+				var end = start + count;
+				var end2 = geometry.drawRange.count === Infinity
+						? attribute.count
+						: geometry.drawRange.start + geometry.drawRange.count;
+
+				start = Math.max( start, geometry.drawRange.start );
+				count = Math.min( end, end2 ) - start;
+
+				if ( count < 0 ) count = 0;
 
 			}
 
+			var minMax = getMinMax( attribute, start, count );
+
 			var bufferViewTarget;
 
 			// If geometry isn't provided, don't infer the target usage of the bufferView. For
 			// animation samplers, target must not be set.
 			if ( geometry !== undefined ) {
 
-				var isVertexAttributes = componentType === WEBGL_CONSTANTS.FLOAT;
-				bufferViewTarget = isVertexAttributes ? WEBGL_CONSTANTS.ARRAY_BUFFER : WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER;
+				bufferViewTarget = attribute === geometry.index ? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER : WEBGL_CONSTANTS.ARRAY_BUFFER;
 
 			}
 
@@ -640,20 +655,13 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			if ( material instanceof THREE.ShaderMaterial ) {
+			if ( material.isShaderMaterial ) {
 
 				console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' );
 				return null;
 
 			}
 
-
-			if ( ! ( material instanceof THREE.MeshStandardMaterial ) ) {
-
-				console.warn( 'GLTFExporter: Currently just THREE.MeshStandardMaterial is supported. Material conversion may lose information.' );
-
-			}
-
 			// @QUESTION Should we avoid including any attribute that has the default value?
 			var gltfMaterial = {
 
@@ -661,6 +669,18 @@ THREE.GLTFExporter.prototype = {
 
 			};
 
+			if ( material.isMeshBasicMaterial ) {
+
+				gltfMaterial.extensions = { KHR_materials_unlit: {} };
+
+				extensionsUsed[ 'KHR_materials_unlit' ] = true;
+
+			} else if ( ! material.isMeshStandardMaterial ) {
+
+				console.warn( 'GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.' );
+
+			}
+
 			// pbrMetallicRoughness.baseColorFactor
 			var color = material.color.toArray().concat( [ material.opacity ] );
 
@@ -670,11 +690,16 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			if ( material instanceof THREE.MeshStandardMaterial ) {
+			if ( material.isMeshStandardMaterial ) {
 
 				gltfMaterial.pbrMetallicRoughness.metallicFactor = material.metalness;
 				gltfMaterial.pbrMetallicRoughness.roughnessFactor = material.roughness;
 
+			} else if ( material.isMeshBasicMaterial ) {
+
+				gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.0;
+				gltfMaterial.pbrMetallicRoughness.roughnessFactor = 0.9;
+
 			} else {
 
 				gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.5;
@@ -712,9 +737,9 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			if ( material instanceof THREE.MeshBasicMaterial ||
-				material instanceof THREE.LineBasicMaterial ||
-				material instanceof THREE.PointsMaterial ) {
+			if ( material.isMeshBasicMaterial ||
+				material.isLineBasicMaterial ||
+				material.isPointsMaterial ) {
 
 			} else {
 
@@ -834,19 +859,19 @@ THREE.GLTFExporter.prototype = {
 			var mode;
 
 			// Use the correct mode
-			if ( mesh instanceof THREE.LineSegments ) {
+			if ( mesh.isLineSegments ) {
 
 				mode = WEBGL_CONSTANTS.LINES;
 
-			} else if ( mesh instanceof THREE.LineLoop ) {
+			} else if ( mesh.isLineLoop ) {
 
 				mode = WEBGL_CONSTANTS.LINE_LOOP;
 
-			} else if ( mesh instanceof THREE.Line ) {
+			} else if ( mesh.isLine ) {
 
 				mode = WEBGL_CONSTANTS.LINE_STRIP;
 
-			} else if ( mesh instanceof THREE.Points ) {
+			} else if ( mesh.isPoints ) {
 
 				mode = WEBGL_CONSTANTS.POINTS;
 
@@ -877,43 +902,11 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			var gltfMesh = {
-				primitives: [
-					{
-						mode: mode,
-						attributes: {},
-					}
-				]
-			};
-
-			var material = processMaterial( mesh.material );
-			if ( material !== null ) {
-
-				gltfMesh.primitives[ 0 ].material = material;
-
-			}
-
-
-			if ( geometry.index ) {
-
-				gltfMesh.primitives[ 0 ].indices = processAccessor( geometry.index, geometry );
-
-			} else if ( options.forceIndices ) {
-
-				var numFaces = geometry.attributes.position.count;
-				var indices = new Uint32Array( numFaces );
-				for ( var i = 0; i < numFaces; i ++ ) {
-
-					indices[ i ] = i;
-
-				}
-
-				gltfMesh.primitives[ 0 ].indices = processAccessor( new THREE.Uint32BufferAttribute( indices, 1 ), geometry );
-
-			}
+			var gltfMesh = {};
 
-			// We've just one primitive per mesh
-			var gltfAttributes = gltfMesh.primitives[ 0 ].attributes;
+			var attributes = {};
+			var primitives = [];
+			var targets = [];
 
 			// Conversion between attributes names in threejs and gltf spec
 			var nameConversion = {
@@ -935,7 +928,7 @@ THREE.GLTFExporter.prototype = {
 
 				if ( attributeName.substr( 0, 5 ) !== 'MORPH' ) {
 
-					gltfAttributes[ attributeName ] = processAccessor( attribute, geometry );
+					attributes[ attributeName ] = processAccessor( attribute, geometry );
 
 				}
 
@@ -958,8 +951,6 @@ THREE.GLTFExporter.prototype = {
 
 				}
 
-				gltfMesh.primitives[ 0 ].targets = [];
-
 				for ( var i = 0; i < mesh.morphTargetInfluences.length; ++ i ) {
 
 					var target = {};
@@ -1010,7 +1001,7 @@ THREE.GLTFExporter.prototype = {
 
 					}
 
-					gltfMesh.primitives[ 0 ].targets.push( target );
+					targets.push( target );
 
 					weights.push( mesh.morphTargetInfluences[ i ] );
 					if ( mesh.morphTargetDictionary !== undefined ) targetNames.push( reverseDictionary[ i ] );
@@ -1028,6 +1019,73 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
+			var forceIndices = options.forceIndices;
+			var isMultiMaterial = Array.isArray( mesh.material );
+
+			if ( ! forceIndices && geometry.index === null && isMultiMaterial ) {
+
+				// temporal workaround.
+				console.warn( 'THREE.GLTFExporter: Creating index for non-indexed multi-material mesh.' );
+				forceIndices = true;
+
+			}
+
+			var didForceIndices = false;
+
+			if ( geometry.index === null && forceIndices ) {
+
+				var indices = [];
+
+				for ( var i = 0, il = geometry.attributes.position.count; i < il; i ++ ) {
+
+					indices[ i ] = i;
+
+				}
+
+				geometry.setIndex( indices );
+
+				didForceIndices = true;
+
+			}
+
+			var materials = isMultiMaterial ? mesh.material : [ mesh.material ] ;
+			var groups = isMultiMaterial ? mesh.geometry.groups : [ { materialIndex: 0, start: undefined, count: undefined } ];
+
+			for ( var i = 0, il = groups.length; i < il; i ++ ) {
+
+				var primitive = {
+					mode: mode,
+					attributes: attributes,
+				};
+
+				if ( targets.length > 0 ) primitive.targets = targets;
+
+				var material = processMaterial( materials[ groups[ i ].materialIndex ] );
+
+				if ( material !== null ) {
+
+					primitive.material = material;
+
+				}
+
+				if ( geometry.index !== null ) {
+
+					primitive.indices = processAccessor( geometry.index, geometry, groups[ i ].start, groups[ i ].count );
+
+				}
+
+				primitives.push( primitive );
+
+			}
+
+			if ( didForceIndices ) {
+
+				geometry.setIndex( null );
+
+			}
+
+			gltfMesh.primitives = primitives;
+
 			outputJSON.meshes.push( gltfMesh );
 
 			return outputJSON.meshes.length - 1;
@@ -1047,7 +1105,7 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			var isOrtho = camera instanceof THREE.OrthographicCamera;
+			var isOrtho = camera.isOrthographicCamera;
 
 			var gltfCamera = {
 
@@ -1187,7 +1245,7 @@ THREE.GLTFExporter.prototype = {
 
 					sampler: samplers.length - 1,
 					target: {
-						node: nodeMap[ trackNode.uuid ],
+						node: nodeMap.get( trackNode ),
 						path: trackProperty
 					}
 
@@ -1209,7 +1267,7 @@ THREE.GLTFExporter.prototype = {
 
 		function processSkin( object ) {
 
-			var node = outputJSON.nodes[ nodeMap[ object.uuid ] ];
+			var node = outputJSON.nodes[ nodeMap.get( object ) ];
 
 			var skeleton = object.skeleton;
 			var rootJoint = object.skeleton.bones[ 0 ];
@@ -1221,7 +1279,7 @@ THREE.GLTFExporter.prototype = {
 
 			for ( var i = 0; i < skeleton.bones.length; ++ i ) {
 
-				joints.push( nodeMap[ skeleton.bones[ i ].uuid ] );
+				joints.push( nodeMap.get( skeleton.bones[ i ] ) );
 
 				skeleton.boneInverses[ i ].toArray( inverseBindMatrices, i * 16 );
 
@@ -1237,7 +1295,7 @@ THREE.GLTFExporter.prototype = {
 
 				inverseBindMatrices: processAccessor( new THREE.BufferAttribute( inverseBindMatrices, 16 ) ),
 				joints: joints,
-				skeleton: nodeMap[ rootJoint.uuid ]
+				skeleton: nodeMap.get( rootJoint )
 
 			} );
 
@@ -1254,7 +1312,7 @@ THREE.GLTFExporter.prototype = {
 		 */
 		function processNode( object ) {
 
-			if ( object instanceof THREE.Light ) {
+			if ( object.isLight ) {
 
 				console.warn( 'GLTFExporter: Unsupported node type:', object.constructor.name );
 				return null;
@@ -1325,19 +1383,17 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			if ( object instanceof THREE.Mesh ||
-				object instanceof THREE.Line ||
-				object instanceof THREE.Points ) {
+			if ( object.isMesh || object.isLine || object.isPoints ) {
 
 				gltfNode.mesh = processMesh( object );
 
-			} else if ( object instanceof THREE.Camera ) {
+			} else if ( object.isCamera ) {
 
 				gltfNode.camera = processCamera( object );
 
 			}
 
-			if ( object instanceof THREE.SkinnedMesh ) {
+			if ( object.isSkinnedMesh ) {
 
 				skins.push( object );
 
@@ -1376,7 +1432,8 @@ THREE.GLTFExporter.prototype = {
 
 			outputJSON.nodes.push( gltfNode );
 
-			var nodeIndex = nodeMap[ object.uuid ] = outputJSON.nodes.length - 1;
+			var nodeIndex = outputJSON.nodes.length - 1;
+			nodeMap.set( object, nodeIndex );
 
 			return nodeIndex;
 
@@ -1505,6 +1562,10 @@ THREE.GLTFExporter.prototype = {
 			// Merge buffers.
 			var blob = new Blob( buffers, { type: 'application/octet-stream' } );
 
+			// Declare extensions.
+			var extensionsUsedList = Object.keys( extensionsUsed );
+			if ( extensionsUsedList.length > 0 ) outputJSON.extensionsUsed = extensionsUsedList;
+
 			if ( outputJSON.buffers && outputJSON.buffers.length > 0 ) {
 
 				// Update bytelength of the single buffer.
@@ -1534,7 +1595,7 @@ THREE.GLTFExporter.prototype = {
 						binaryChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_BIN, true );
 
 						// JSON chunk.
-						var jsonChunk = stringToArrayBuffer( JSON.stringify( outputJSON ), true );
+						var jsonChunk = getPaddedArrayBuffer( stringToArrayBuffer( JSON.stringify( outputJSON ) ), 0x20 );
 						var jsonChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
 						jsonChunkPrefix.setUint32( 0, jsonChunk.byteLength, true );
 						jsonChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_JSON, true );

+ 99 - 2
examples/js/lines/LineMaterial.js

@@ -4,6 +4,10 @@
  * parameters = {
  *  color: <hex>,
  *  linewidth: <float>,
+ *  dashed: <boolean>,
+ *  dashScale: <float>,
+ *  dashSize: <float>,
+ *  gapSize: <float>,
  *  resolution: <Vector2>, // to be set by renderer
  * }
  */
@@ -11,7 +15,10 @@
 THREE.UniformsLib.line = {
 
 	linewidth: { value: 1 },
-	resolution: { value: new THREE.Vector2( 1, 1 ) }
+	resolution: { value: new THREE.Vector2( 1, 1 ) },
+	dashScale: { value: 1 },
+	dashSize: { value: 1 },
+	gapSize: { value: 1 } // todo FIX - maybe change to totalSize
 
 };
 
@@ -42,6 +49,15 @@ THREE.ShaderLib[ 'line' ] = {
 
 		varying vec2 vUv;
 
+		#ifdef USE_DASH
+
+			uniform float dashScale;
+			attribute float instanceDistanceStart;
+			attribute float instanceDistanceEnd;
+			varying float vLineDistance;
+
+		#endif
+
 		void trimSegment( const in vec4 start, inout vec4 end ) {
 
 			// trim end segment so it terminates between the camera plane and the near plane
@@ -60,7 +76,15 @@ THREE.ShaderLib[ 'line' ] = {
 		void main() {
 
 			#ifdef USE_COLOR
+
 				vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
+
+			#endif
+
+			#ifdef USE_DASH
+
+				vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
+
 			#endif
 
 			float aspect = resolution.x / resolution.y;
@@ -158,18 +182,35 @@ THREE.ShaderLib[ 'line' ] = {
 		uniform vec3 diffuse;
 		uniform float opacity;
 
+		#ifdef USE_DASH
+
+			uniform float dashSize;
+			uniform float gapSize;
+
+		#endif
+
+		varying float vLineDistance;
+
 		#include <common>
 		#include <color_pars_fragment>
 		#include <fog_pars_fragment>
 		#include <logdepthbuf_pars_fragment>
 		#include <clipping_planes_pars_fragment>
 
-			varying vec2 vUv;
+		varying vec2 vUv;
 
 		void main() {
 
 			#include <clipping_planes_fragment>
 
+			#ifdef USE_DASH
+
+				if ( vUv.y < 0.5 || vUv.y > 0.5 ) discard; // discard endcaps
+
+				if ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
+
+			#endif
+
 			if ( vUv.y < 0.5 || vUv.y > 0.5 ) {
 
 				float a = vUv.x - 0.5;
@@ -209,6 +250,8 @@ THREE.LineMaterial = function ( parameters ) {
 
 	} );
 
+	this.dashed = false;
+
 	Object.defineProperties( this, {
 
 		color: {
@@ -247,6 +290,60 @@ THREE.LineMaterial = function ( parameters ) {
 
 		},
 
+		dashScale: {
+
+			enumerable: true,
+
+			get: function () {
+
+				return this.uniforms.dashScale.value;
+
+			},
+
+			set: function ( value ) {
+
+				this.uniforms.dashScale.value = value;
+
+			}
+
+		},
+
+		dashSize: {
+
+			enumerable: true,
+
+			get: function () {
+
+				return this.uniforms.dashSize.value;
+
+			},
+
+			set: function ( value ) {
+
+				this.uniforms.dashSize.value = value;
+
+			}
+
+		},
+
+		gapSize: {
+
+			enumerable: true,
+
+			get: function () {
+
+				return this.uniforms.gapSize.value;
+
+			},
+
+			set: function ( value ) {
+
+				this.uniforms.gapSize.value = value;
+
+			}
+
+		},
+
 		resolution: {
 
 			enumerable: true,

+ 34 - 0
examples/js/lines/LineSegments2.js

@@ -20,6 +20,40 @@ THREE.LineSegments2.prototype = Object.assign( Object.create( THREE.Mesh.prototy
 
 	isLineSegments2: true,
 
+	computeLineDistances: ( function () { // for backwards-compatability, but could be a method of LineSegmentsGeometry...
+
+		var start = new THREE.Vector3();
+		var end = new THREE.Vector3();
+
+		return function computeLineDistances() {
+
+			var geometry = this.geometry;
+
+			var instanceStart = geometry.attributes.instanceStart;
+			var instanceEnd = geometry.attributes.instanceEnd;
+			var lineDistances = new Float32Array( 2 * instanceStart.data.count );
+
+			for ( var i = 0, j = 0, l = instanceStart.data.count; i < l; i ++, j += 2 ) {
+
+				start.fromBufferAttribute( instanceStart, i );
+				end.fromBufferAttribute( instanceEnd, i );
+
+				lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
+				lineDistances[ j + 1 ] = lineDistances[ j ] + start.distanceTo( end );
+
+			}
+
+			var instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
+
+			geometry.addAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
+			geometry.addAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
+
+			return this;
+
+		};
+
+	}() ),
+
 	copy: function ( source ) {
 
 		// todo

+ 34 - 0
examples/js/lines/Wireframe.js

@@ -20,6 +20,40 @@ THREE.Wireframe.prototype = Object.assign( Object.create( THREE.Mesh.prototype )
 
 	isWireframe: true,
 
+	computeLineDistances: ( function () { // for backwards-compatability, but could be a method of LineSegmentsGeometry...
+
+		var start = new THREE.Vector3();
+		var end = new THREE.Vector3();
+
+		return function computeLineDistances() {
+
+			var geometry = this.geometry;
+
+			var instanceStart = geometry.attributes.instanceStart;
+			var instanceEnd = geometry.attributes.instanceEnd;
+			var lineDistances = new Float32Array( 2 * instanceStart.data.count );
+
+			for ( var i = 0, j = 0, l = instanceStart.data.count; i < l; i ++, j += 2 ) {
+
+				start.fromBufferAttribute( instanceStart, i );
+				end.fromBufferAttribute( instanceEnd, i );
+
+				lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
+				lineDistances[ j + 1 ] = lineDistances[ j ] + start.distanceTo( end );
+
+			}
+
+			var instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
+
+			geometry.addAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
+			geometry.addAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
+
+			return this;
+
+		};
+
+	}() ),
+
 	copy: function ( source ) {
 
 		// todo

+ 58 - 0
examples/js/utils/MathUtils.js

@@ -0,0 +1,58 @@
+/**
+ * @author WestLangley
+ * @author thezwap 
+ */
+
+THREE.MathUtils = {
+    setQuaternionFromProperEuler: function (q, a, b, c, order) {
+
+        var cos = Math.cos;
+        var sin = Math.sin;
+
+        var c2 = cos(b / 2);
+
+        var s2 = sin(b / 2);
+
+        var c13 = cos((a + c) / 2);
+        var s13 = sin((a + c) / 2);
+
+        var c1_3 = cos((a - c) / 2);
+        var s1_3 = sin((a - c) / 2);
+
+        var c3_1 = cos((c - a) / 2);
+        var s3_1 = sin((c - a) / 2);
+
+        if (order === 'XYX') {
+
+            q.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13);
+
+        } else if (order === 'YZY') {
+
+            q.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13);
+
+        } else if (order === 'ZXZ') {
+
+            q.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13);
+
+        } else if (order === 'XZX') {
+
+            q.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13);
+
+        } else if (order === 'YXY') {
+
+            q.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13);
+
+        } else if (order === 'ZYZ') {
+
+            q.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13);
+
+        }
+
+        else {
+
+            console.warn('THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.');
+
+        }
+
+    }
+}

+ 0 - 8
examples/models/gltf/RiggedSimple/README.md

@@ -1,8 +0,0 @@
-# Rigged Simple
-## Screenshot
-
-![screenshot](screenshot/screenshot.gif)
-
-## License Information
-
-Donated by [Cesium](http://cesiumjs.org/) for glTF testing.

BIN=BIN
examples/models/gltf/RiggedSimple/glTF-Binary/RiggedSimple.glb


BIN=BIN
examples/models/gltf/RiggedSimple/glTF-Draco/0.bin


+ 0 - 518
examples/models/gltf/RiggedSimple/glTF-Draco/RiggedSimple.gltf

@@ -1,518 +0,0 @@
-{
-  "asset": {
-    "generator": "COLLADA2GLTF",
-    "version": "2.0"
-  },
-  "scene": 0,
-  "scenes": [
-    {
-      "nodes": [
-        0
-      ]
-    }
-  ],
-  "nodes": [
-    {
-      "children": [
-        4,
-        1
-      ],
-      "matrix": [
-        1,
-        0,
-        0,
-        0,
-        0,
-        0,
-        -1,
-        0,
-        0,
-        1,
-        0,
-        0,
-        0,
-        0,
-        0,
-        1
-      ]
-    },
-    {
-      "mesh": 0,
-      "skin": 0
-    },
-    {
-      "children": [
-        3
-      ],
-      "translation": [
-        0,
-        -3.156060017772689e-7,
-        -4.1803297996521
-      ],
-      "rotation": [
-        -0.7047404050827026,
-        0,
-        0,
-        -0.7094652056694031
-      ],
-      "scale": [
-        1,
-        0.9999998807907104,
-        0.9999998807907104
-      ]
-    },
-    {
-      "translation": [
-        0,
-        4.18717098236084,
-        0
-      ],
-      "rotation": [
-        -0.0020521103870123625,
-        -9.947898149675895e-8,
-        -0.00029137087403796613,
-        -0.999997854232788
-      ],
-      "scale": [
-        1,
-        1,
-        1.0000001192092896
-      ]
-    },
-    {
-      "children": [
-        2
-      ]
-    }
-  ],
-  "meshes": [
-    {
-      "primitives": [
-        {
-          "attributes": {
-            "JOINTS_0": 10,
-            "NORMAL": 11,
-            "POSITION": 12,
-            "WEIGHTS_0": 13
-          },
-          "indices": 9,
-          "mode": 4,
-          "material": 0,
-          "extensions": {
-            "KHR_draco_mesh_compression": {
-              "bufferView": 4,
-              "attributes": {
-                "JOINTS_0": 0,
-                "NORMAL": 1,
-                "POSITION": 2,
-                "WEIGHTS_0": 3
-              }
-            }
-          }
-        }
-      ],
-      "name": "Cylinder"
-    }
-  ],
-  "animations": [
-    {
-      "channels": [
-        {
-          "sampler": 0,
-          "target": {
-            "node": 2,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 1,
-          "target": {
-            "node": 2,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 2,
-          "target": {
-            "node": 2,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 3,
-          "target": {
-            "node": 3,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 4,
-          "target": {
-            "node": 3,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 5,
-          "target": {
-            "node": 3,
-            "path": "scale"
-          }
-        }
-      ],
-      "samplers": [
-        {
-          "input": 0,
-          "interpolation": "LINEAR",
-          "output": 1
-        },
-        {
-          "input": 0,
-          "interpolation": "LINEAR",
-          "output": 2
-        },
-        {
-          "input": 0,
-          "interpolation": "LINEAR",
-          "output": 3
-        },
-        {
-          "input": 4,
-          "interpolation": "LINEAR",
-          "output": 5
-        },
-        {
-          "input": 4,
-          "interpolation": "LINEAR",
-          "output": 6
-        },
-        {
-          "input": 4,
-          "interpolation": "LINEAR",
-          "output": 7
-        }
-      ]
-    }
-  ],
-  "skins": [
-    {
-      "inverseBindMatrices": 8,
-      "skeleton": 2,
-      "joints": [
-        2,
-        3
-      ],
-      "name": "Armature"
-    }
-  ],
-  "accessors": [
-    {
-      "bufferView": 0,
-      "byteOffset": 0,
-      "componentType": 5126,
-      "count": 3,
-      "max": [
-        2.083333015441895
-      ],
-      "min": [
-        0.04166661947965622
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 1,
-      "byteOffset": 0,
-      "componentType": 5126,
-      "count": 3,
-      "max": [
-        0,
-        -3.156060017772689e-7,
-        -4.1803297996521
-      ],
-      "min": [
-        0,
-        -3.156060017772689e-7,
-        -4.1803297996521
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 0,
-      "componentType": 5126,
-      "count": 3,
-      "max": [
-        -0.7047404050827026,
-        0,
-        0,
-        -0.7094652056694031
-      ],
-      "min": [
-        -0.7047404050827026,
-        0,
-        0,
-        -0.7094652056694031
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 1,
-      "byteOffset": 36,
-      "componentType": 5126,
-      "count": 3,
-      "max": [
-        1,
-        0.9999998807907104,
-        0.9999998807907104
-      ],
-      "min": [
-        1,
-        0.9999998807907104,
-        0.9999998807907104
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 12,
-      "componentType": 5126,
-      "count": 3,
-      "max": [
-        2.083333015441895
-      ],
-      "min": [
-        0.04166661947965622
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 1,
-      "byteOffset": 72,
-      "componentType": 5126,
-      "count": 3,
-      "max": [
-        0,
-        4.18717098236084,
-        0
-      ],
-      "min": [
-        0,
-        4.18717098236084,
-        0
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 48,
-      "componentType": 5126,
-      "count": 3,
-      "max": [
-        0.2933785021305084,
-        -9.947898149675895e-8,
-        -0.0002783441450446844,
-        -0.9559963345527648
-      ],
-      "min": [
-        -0.0020521103870123625,
-        -0.00008614854596089572,
-        -0.00029137087403796613,
-        -0.999997854232788
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 1,
-      "byteOffset": 108,
-      "componentType": 5126,
-      "count": 3,
-      "max": [
-        1,
-        1,
-        1.0000001192092896
-      ],
-      "min": [
-        1,
-        1,
-        1.0000001192092896
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 3,
-      "byteOffset": 0,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        1,
-        0,
-        0.0000013948100558991428,
-        0,
-        0.000002896920022976701,
-        0.006681859027594328,
-        -0.9999778270721436,
-        0,
-        0.0005827349959872663,
-        0.9999966025352478,
-        0.006681739818304777,
-        0,
-        0,
-        4.18023681640625,
-        0.02795993909239769,
-        1
-      ],
-      "min": [
-        0.9999998807907104,
-        -0.0005827400018461049,
-        0,
-        0,
-        0,
-        0.002577662002295256,
-        -0.9999967217445374,
-        0,
-        0,
-        0.999977707862854,
-        0.002577601931989193,
-        0,
-        -0.000004012620138382772,
-        -0.006818830035626888,
-        0.027931740507483482,
-        1
-      ],
-      "type": "MAT4"
-    },
-    {
-      "componentType": 5123,
-      "count": 564,
-      "max": [
-        95
-      ],
-      "min": [
-        0
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "componentType": 5123,
-      "count": 96,
-      "max": [
-        1,
-        1,
-        0,
-        0
-      ],
-      "min": [
-        0,
-        0,
-        0,
-        0
-      ],
-      "type": "VEC4"
-    },
-    {
-      "componentType": 5126,
-      "count": 96,
-      "max": [
-        0.998198390007019,
-        0.998198390007019,
-        0.6888381242752075
-      ],
-      "min": [
-        -0.998198390007019,
-        -0.998198390007019,
-        -0.6444730758666992
-      ],
-      "type": "VEC3"
-    },
-    {
-      "componentType": 5126,
-      "count": 96,
-      "max": [
-        1,
-        1,
-        4.575077056884766
-      ],
-      "min": [
-        -1,
-        -0.9999995827674866,
-        -4.575077056884766
-      ],
-      "type": "VEC3"
-    },
-    {
-      "componentType": 5126,
-      "count": 96,
-      "max": [
-        1,
-        0.26139819622039795,
-        0,
-        0
-      ],
-      "min": [
-        0.738601803779602,
-        0,
-        0,
-        0
-      ],
-      "type": "VEC4"
-    }
-  ],
-  "materials": [
-    {
-      "pbrMetallicRoughness": {
-        "baseColorFactor": [
-          0.27963539958000183,
-          0.6399999856948853,
-          0.21094389259815216,
-          1
-        ],
-        "metallicFactor": 0
-      },
-      "emissiveFactor": [
-        0,
-        0,
-        0
-      ],
-      "name": "Material_001-effect"
-    }
-  ],
-  "bufferViews": [
-    {
-      "buffer": 0,
-      "byteOffset": 0,
-      "byteLength": 24
-    },
-    {
-      "buffer": 0,
-      "byteOffset": 24,
-      "byteLength": 144
-    },
-    {
-      "buffer": 0,
-      "byteOffset": 168,
-      "byteLength": 96
-    },
-    {
-      "buffer": 0,
-      "byteOffset": 264,
-      "byteLength": 128
-    },
-    {
-      "buffer": 0,
-      "byteOffset": 392,
-      "byteLength": 1008
-    }
-  ],
-  "buffers": [
-    {
-      "byteLength": 1400,
-      "uri": "0.bin"
-    }
-  ],
-  "extensionsRequired": [
-    "KHR_draco_mesh_compression"
-  ],
-  "extensionsUsed": [
-    "KHR_draco_mesh_compression"
-  ]
-}

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 535
examples/models/gltf/RiggedSimple/glTF-Embedded/RiggedSimple.gltf


+ 0 - 539
examples/models/gltf/RiggedSimple/glTF/RiggedSimple.gltf

@@ -1,539 +0,0 @@
-{
-    "asset": {
-        "generator": "COLLADA2GLTF",
-        "version": "2.0"
-    },
-    "scene": 0,
-    "scenes": [
-        {
-            "nodes": [
-                0
-            ]
-        }
-    ],
-    "nodes": [
-        {
-            "children": [
-                4,
-                1
-            ],
-            "matrix": [
-                1.0,
-                0.0,
-                0.0,
-                0.0,
-                0.0,
-                0.0,
-                -1.0,
-                0.0,
-                0.0,
-                1.0,
-                0.0,
-                0.0,
-                0.0,
-                0.0,
-                0.0,
-                1.0
-            ]
-        },
-        {
-            "mesh": 0,
-            "skin": 0
-        },
-        {
-            "children": [
-                3
-            ],
-            "translation": [
-                0.0,
-                -3.156060017772689e-7,
-                -4.1803297996521
-            ],
-            "rotation": [
-                -0.7047404050827026,
-                -0.0,
-                -0.0,
-                -0.7094652056694031
-            ],
-            "scale": [
-                1.0,
-                0.9999998807907105,
-                0.9999998807907105
-            ]
-        },
-        {
-            "translation": [
-                0.0,
-                4.18717098236084,
-                0.0
-            ],
-            "rotation": [
-                -0.0020521103870123626,
-                -9.94789530750495e-8,
-                -0.00029137087403796613,
-                -0.999997854232788
-            ],
-            "scale": [
-                1.0,
-                1.0,
-                1.0000001192092896
-            ]
-        },
-        {
-            "children": [
-                2
-            ]
-        }
-    ],
-    "meshes": [
-        {
-            "primitives": [
-                {
-                    "attributes": {
-                        "JOINTS_0": 1,
-                        "NORMAL": 2,
-                        "POSITION": 3,
-                        "WEIGHTS_0": 4
-                    },
-                    "indices": 0,
-                    "mode": 4,
-                    "material": 0
-                }
-            ],
-            "name": "Cylinder"
-        }
-    ],
-    "animations": [
-        {
-            "channels": [
-                {
-                    "sampler": 0,
-                    "target": {
-                        "node": 2,
-                        "path": "translation"
-                    }
-                },
-                {
-                    "sampler": 1,
-                    "target": {
-                        "node": 2,
-                        "path": "rotation"
-                    }
-                },
-                {
-                    "sampler": 2,
-                    "target": {
-                        "node": 2,
-                        "path": "scale"
-                    }
-                }
-            ],
-            "samplers": [
-                {
-                    "input": 5,
-                    "interpolation": "LINEAR",
-                    "output": 6
-                },
-                {
-                    "input": 5,
-                    "interpolation": "LINEAR",
-                    "output": 7
-                },
-                {
-                    "input": 5,
-                    "interpolation": "LINEAR",
-                    "output": 8
-                }
-            ]
-        },
-        {
-            "channels": [
-                {
-                    "sampler": 0,
-                    "target": {
-                        "node": 3,
-                        "path": "translation"
-                    }
-                },
-                {
-                    "sampler": 1,
-                    "target": {
-                        "node": 3,
-                        "path": "rotation"
-                    }
-                },
-                {
-                    "sampler": 2,
-                    "target": {
-                        "node": 3,
-                        "path": "scale"
-                    }
-                }
-            ],
-            "samplers": [
-                {
-                    "input": 9,
-                    "interpolation": "LINEAR",
-                    "output": 10
-                },
-                {
-                    "input": 9,
-                    "interpolation": "LINEAR",
-                    "output": 11
-                },
-                {
-                    "input": 9,
-                    "interpolation": "LINEAR",
-                    "output": 12
-                }
-            ]
-        }
-    ],
-    "skins": [
-        {
-            "inverseBindMatrices": 13,
-            "skeleton": 2,
-            "joints": [
-                2,
-                3
-            ],
-            "name": "Armature"
-        }
-    ],
-    "accessors": [
-        {
-            "bufferView": 0,
-            "byteOffset": 0,
-            "componentType": 5123,
-            "count": 564,
-            "max": [
-                95
-            ],
-            "min": [
-                0
-            ],
-            "type": "SCALAR"
-        },
-        {
-            "bufferView": 1,
-            "byteOffset": 0,
-            "componentType": 5123,
-            "count": 96,
-            "max": [
-                1,
-                1,
-                0,
-                0
-            ],
-            "min": [
-                0,
-                0,
-                0,
-                0
-            ],
-            "type": "VEC4"
-        },
-        {
-            "bufferView": 2,
-            "byteOffset": 0,
-            "componentType": 5126,
-            "count": 96,
-            "max": [
-                0.998198390007019,
-                0.998198390007019,
-                0.6888381242752075
-            ],
-            "min": [
-                -0.998198390007019,
-                -0.998198390007019,
-                -0.644473135471344
-            ],
-            "type": "VEC3"
-        },
-        {
-            "bufferView": 2,
-            "byteOffset": 1152,
-            "componentType": 5126,
-            "count": 96,
-            "max": [
-                1.0,
-                1.0,
-                4.575077056884766
-            ],
-            "min": [
-                -1.0,
-                -0.9999995827674866,
-                -4.575077056884766
-            ],
-            "type": "VEC3"
-        },
-        {
-            "bufferView": 3,
-            "byteOffset": 0,
-            "componentType": 5126,
-            "count": 96,
-            "max": [
-                1.0,
-                0.261398196220398,
-                0.0,
-                0.0
-            ],
-            "min": [
-                0.738601803779602,
-                0.0,
-                0.0,
-                0.0
-            ],
-            "type": "VEC4"
-        },
-        {
-            "bufferView": 4,
-            "byteOffset": 0,
-            "componentType": 5126,
-            "count": 3,
-            "max": [
-                2.083333015441895
-            ],
-            "min": [
-                0.04166661947965622
-            ],
-            "type": "SCALAR"
-        },
-        {
-            "bufferView": 5,
-            "byteOffset": 0,
-            "componentType": 5126,
-            "count": 3,
-            "max": [
-                0.0,
-                -3.156060017772689e-7,
-                -4.1803297996521
-            ],
-            "min": [
-                0.0,
-                -3.156060017772689e-7,
-                -4.1803297996521
-            ],
-            "type": "VEC3"
-        },
-        {
-            "bufferView": 6,
-            "byteOffset": 0,
-            "componentType": 5126,
-            "count": 3,
-            "max": [
-                -0.7047404050827026,
-                -0.0,
-                -0.0,
-                -0.7094652056694031
-            ],
-            "min": [
-                -0.7047404050827026,
-                -0.0,
-                -0.0,
-                -0.7094652056694031
-            ],
-            "type": "VEC4"
-        },
-        {
-            "bufferView": 5,
-            "byteOffset": 36,
-            "componentType": 5126,
-            "count": 3,
-            "max": [
-                1.0,
-                0.9999998807907105,
-                0.9999998807907105
-            ],
-            "min": [
-                1.0,
-                0.9999998807907105,
-                0.9999998807907105
-            ],
-            "type": "VEC3"
-        },
-        {
-            "bufferView": 4,
-            "byteOffset": 12,
-            "componentType": 5126,
-            "count": 3,
-            "max": [
-                2.083333015441895
-            ],
-            "min": [
-                0.04166661947965622
-            ],
-            "type": "SCALAR"
-        },
-        {
-            "bufferView": 5,
-            "byteOffset": 72,
-            "componentType": 5126,
-            "count": 3,
-            "max": [
-                0.0,
-                4.18717098236084,
-                0.0
-            ],
-            "min": [
-                0.0,
-                4.18717098236084,
-                0.0
-            ],
-            "type": "VEC3"
-        },
-        {
-            "bufferView": 6,
-            "byteOffset": 48,
-            "componentType": 5126,
-            "count": 3,
-            "max": [
-                0.2933785021305084,
-                -9.94789530750495e-8,
-                -0.0002783441450446844,
-                -0.9559963345527648
-            ],
-            "min": [
-                -0.0020521103870123626,
-                -0.00008614854596089572,
-                -0.00029137087403796613,
-                -0.999997854232788
-            ],
-            "type": "VEC4"
-        },
-        {
-            "bufferView": 5,
-            "byteOffset": 108,
-            "componentType": 5126,
-            "count": 3,
-            "max": [
-                1.0,
-                1.0,
-                1.0000001192092896
-            ],
-            "min": [
-                1.0,
-                1.0,
-                1.0000001192092896
-            ],
-            "type": "VEC3"
-        },
-        {
-            "bufferView": 7,
-            "byteOffset": 0,
-            "componentType": 5126,
-            "count": 2,
-            "max": [
-                1.0,
-                0.0,
-                0.000001394809942212305,
-                0.0,
-                0.000002896920022976701,
-                0.006681859027594328,
-                -0.9999778270721436,
-                0.0,
-                0.0005827349959872663,
-                0.9999966025352478,
-                0.006681739818304777,
-                0.0,
-                0.0,
-                4.18023681640625,
-                0.02795993909239769,
-                1.0
-            ],
-            "min": [
-                0.9999999403953552,
-                -0.0005827400018461049,
-                0.0,
-                0.0,
-                0.0,
-                0.002577662002295256,
-                -0.9999967217445374,
-                0.0,
-                0.0,
-                0.999977707862854,
-                0.002577601931989193,
-                0.0,
-                -0.000004012620138382772,
-                -0.006818830035626888,
-                0.027931740507483484,
-                1.0
-            ],
-            "type": "MAT4"
-        }
-    ],
-    "materials": [
-        {
-            "pbrMetallicRoughness": {
-                "baseColorFactor": [
-                    0.27963539958000185,
-                    0.6399999856948853,
-                    0.21094390749931336,
-                    1.0
-                ],
-                "metallicFactor": 0.0
-            },
-            "emissiveFactor": [
-                0.0,
-                0.0,
-                0.0
-            ],
-            "name": "Material_001-effect"
-        }
-    ],
-    "bufferViews": [
-        {
-            "buffer": 0,
-            "byteOffset": 5000,
-            "byteLength": 1128,
-            "target": 34963
-        },
-        {
-            "buffer": 0,
-            "byteOffset": 4208,
-            "byteLength": 768,
-            "byteStride": 8,
-            "target": 34962
-        },
-        {
-            "buffer": 0,
-            "byteOffset": 1904,
-            "byteLength": 2304,
-            "byteStride": 12,
-            "target": 34962
-        },
-        {
-            "buffer": 0,
-            "byteOffset": 224,
-            "byteLength": 1536,
-            "byteStride": 16,
-            "target": 34962
-        },
-        {
-            "buffer": 0,
-            "byteOffset": 4976,
-            "byteLength": 24
-        },
-        {
-            "buffer": 0,
-            "byteOffset": 1760,
-            "byteLength": 144
-        },
-        {
-            "buffer": 0,
-            "byteOffset": 128,
-            "byteLength": 96
-        },
-        {
-            "buffer": 0,
-            "byteOffset": 0,
-            "byteLength": 128
-        }
-    ],
-    "buffers": [
-        {
-            "byteLength": 6128,
-            "uri": "RiggedSimple0.bin"
-        }
-    ]
-}

BIN=BIN
examples/models/gltf/RiggedSimple/glTF/RiggedSimple0.bin


BIN=BIN
examples/models/gltf/RiggedSimple/screenshot/screenshot.gif


+ 0 - 2
examples/webgl_geometry_extrude_shapes.html

@@ -159,8 +159,6 @@
 				var extrudeSettings = {
 					amount: 20,
 					steps: 1,
-					material: 1,
-					extrudeMaterial: 0,
 					bevelEnabled: true,
 					bevelThickness : 2,
 					bevelSize: 4,

+ 1 - 4
examples/webgl_geometry_text.html

@@ -373,10 +373,7 @@
 
 					bevelThickness: bevelThickness,
 					bevelSize: bevelSize,
-					bevelEnabled: bevelEnabled,
-
-					material: 0,
-					extrudeMaterial: 1
+					bevelEnabled: bevelEnabled
 
 				});
 

+ 77 - 54
examples/webgl_lines_fat.html

@@ -57,8 +57,9 @@
 
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 
-			var line, wireframe, renderer, scene, camera, controls;
-			var line1, wireframe1;
+			var line, renderer, scene, camera, controls;
+			var line1;
+			var matLine, matLineBasic, matLineDashed;
 			var stats;
 			var gui;
 
@@ -80,7 +81,7 @@
 				scene = new THREE.Scene();
 
 				camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 1000 );
-				camera.position.set( -40, 0, 60 );
+				camera.position.set( - 40, 0, 60 );
 
 				controls = new THREE.OrbitControls( camera, renderer.domElement );
 				controls.minDistance = 10;
@@ -115,16 +116,18 @@
 				geometry.setPositions( positions );
 				geometry.setColors( colors );
 
-				var material = new THREE.LineMaterial( {
+				matLine = new THREE.LineMaterial( {
 
 					color: 0xffffff,
-					linewidth: 10, // in pixels
+					linewidth: 5, // in pixels
 					vertexColors: THREE.VertexColors,
 					//resolution:  // to be set by renderer, eventually
+					dashed: false
 
 				} );
 
-				line = new THREE.Line2( geometry, material );
+				line = new THREE.Line2( geometry, matLine );
+				line.computeLineDistances();
 				line.scale.set( 1, 1, 1 );
 				scene.add( line );
 
@@ -135,44 +138,14 @@
 				geo.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
 				geo.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) );
 
-				var mat = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
+				matLineBasic = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
+				matLineDashed = new THREE.LineDashedMaterial( { vertexColors: THREE.VertexColors, scale: 2, dashSize: 1, gapSize: 1 } );
 
-				line1 = new THREE.Line( geo, mat );
+				line1 = new THREE.Line( geo, matLineBasic );
+				line1.computeLineDistances();
 				line1.visible = false;
 				scene.add( line1 );
 
-
-				// THREE.Wireframe ( WireframeGeometry2, LineMaterial )
-
-				//var geo = new THREE.BoxBufferGeometry( 16, 16, 4, 2, 2, 1 );
-				//var geo = new THREE.IcosahedronBufferGeometry( 8, 0 );
-				var geo = new THREE.PlaneBufferGeometry( 16, 16, 2, 2 );
-
-				var geometry = new THREE.WireframeGeometry2( geo );
-
-				var material = new THREE.LineMaterial( {
-
-					color: 0x4080ff,
-					linewidth: 10, // in pixels
-					//resolution:  // to be set by renderer, eventually
-
-				} );
-
-				wireframe = new THREE.Wireframe( geometry, material );
-				wireframe.scale.set( 1, 1, 1 );
-				scene.add( wireframe );
-
-
-				// THREE.Line ( WireframeGeometry, LineBasicMaterial ) - rendered with gl.LINE
-
-				geo = new THREE.WireframeGeometry( geo );
-
-				var mat = new THREE.LineBasicMaterial( { color: 0x4080ff } );
-
-				wireframe1 = new THREE.LineSegments( geo, mat );
-				wireframe1.visible = false;
-				scene.add( wireframe1 );
-
 				//
 
 				window.addEventListener( 'resize', onWindowResize, false );
@@ -203,13 +176,10 @@
 
 				stats.update();
 
-				wireframe.geometry.maxInstancedCount = Math.floor( Date.now() / 1000 ) % wireframe.geometry.index.count - 1; // why - 1 needed ?
-
 				// main scene
 
 				// renderer will set this eventually
-				line.material.resolution.set( window.innerWidth, window.innerHeight );
-				wireframe.material.resolution.set( window.innerWidth, window.innerHeight );
+				matLine.resolution.set( window.innerWidth, window.innerHeight );
 
 				renderer.setViewport( 0, 0, window.innerWidth, window.innerHeight );
 
@@ -218,8 +188,7 @@
 				// inset scene
 
 				// renderer will set this eventually
-				//line.material.resolution.set( insetWidth, insetHeight );
-				//wireframe.material.resolution.set( insetWidth, insetHeight );
+				//matLine.resolution.set( insetWidth, insetHeight ); // not sure what behavior we want here...
 
 				renderer.clearDepth(); // important!
 
@@ -243,7 +212,10 @@
 
 				var param = {
 					'line type': 0,
-					'line width': 10
+					'width (px)': 5,
+					'dashed': false,
+					'dash scale': 1,
+					'dash / gap': 1
 				};
 
 
@@ -253,19 +225,15 @@
 
 						case '0':
 							line.visible = true;
-							wireframe.visible = true;
 
 							line1.visible = false;
-							wireframe1.visible = false;
 
 							break;
 
 						case '1':
 							line.visible = false;
-							wireframe.visible = false;
 
 							line1.visible = true;
-							wireframe1.visible = true;
 
 							break;
 
@@ -273,10 +241,65 @@
 
 				} );
 
-				gui.add( param, 'line width', 1, 40, 1 ).onChange( function ( val ) {
+				gui.add( param, 'width (px)', 1, 10, 1 ).onChange( function ( val ) {
+
+					matLine.linewidth = val;
+
+				} );
+
+				gui.add( param, 'dashed' ).onChange( function ( val ) {
+
+					matLine.dashed = val;
 
-					line.material.linewidth = val;
-					wireframe.material.linewidth = val;
+					// dashed is implemented as a defines -- not as a uniform. this could be changed.
+					// ... or LineDashedMaterial could be implemented as a separate material
+					// temporary hack - renderer should do this eventually
+					if ( val ) matLine.defines.USE_DASH = ""; else delete matLine.defines.USE_DASH;
+					matLine.needsUpdate = true;
+
+					line1.material = val ? matLineDashed : matLineBasic;
+
+				} );
+
+				gui.add( param, 'dash scale', 0.5, 2, 0.1 ).onChange( function ( val ) {
+
+					matLine.dashScale = val;
+					matLineDashed.scale = val;
+
+				} );
+
+				gui.add( param, 'dash / gap', { '2 : 1': 0, '1 : 1': 1, '1 : 2': 2 } ).onChange( function ( val ) {
+
+					switch ( val ) {
+
+						case '0':
+							matLine.dashSize = 2;
+							matLine.gapSize = 1;
+
+							matLineDashed.dashSize = 2;
+							matLineDashed.gapSize = 1;
+
+							break;
+
+						case '1':
+							matLine.dashSize = 1;
+							matLine.gapSize = 1;
+
+							matLineDashed.dashSize = 1;
+							matLineDashed.gapSize = 1;
+
+							break;
+
+						case '2':
+							matLine.dashSize = 1;
+							matLine.gapSize = 2;
+
+							matLineDashed.dashSize = 1;
+							matLineDashed.gapSize = 2;
+
+							break;
+
+					}
 
 				} );
 

+ 0 - 9
examples/webgl_loader_gltf_extensions.html

@@ -495,15 +495,6 @@
 					shadows:true,
 					extensions: ['glTF', 'glTF-Embedded', 'glTF-Binary', 'glTF-Draco']
 				},
-				{
-					name : "Rigged Simple",
-					url : "./models/gltf/RiggedSimple/%s/RiggedSimple.gltf",
-					cameraPos: new THREE.Vector3(0, 5, 15),
-					objectRotation: new THREE.Euler(0, 90, 0),
-					addLights:true,
-					shadows:true,
-					extensions: ['glTF', 'glTF-Embedded', 'glTF-Binary', 'glTF-Draco']
-				},
 				{
 					name : 'Outlined Box',
 					url : './models/gltf/OutlinedBox/OutlinedBox.gltf',

+ 1 - 4
examples/webgl_loader_ttf.html

@@ -213,10 +213,7 @@
 
 					bevelThickness: bevelThickness,
 					bevelSize: bevelSize,
-					bevelEnabled: true,
-
-					material: 0,
-					extrudeMaterial: 1
+					bevelEnabled: true
 
 				});
 

+ 2 - 2
src/geometries/ExtrudeGeometry.js

@@ -615,7 +615,7 @@ ExtrudeBufferGeometry.prototype.addShape = function ( shape, options ) {
 
 		}
 
-		scope.addGroup( start, verticesArray.length / 3 - start, options.material !== undefined ? options.material : 0 );
+		scope.addGroup( start, verticesArray.length / 3 - start, 0 );
 
 	}
 
@@ -639,7 +639,7 @@ ExtrudeBufferGeometry.prototype.addShape = function ( shape, options ) {
 		}
 
 
-		scope.addGroup( start, verticesArray.length / 3 - start, options.extrudeMaterial !== undefined ? options.extrudeMaterial : 1 );
+		scope.addGroup( start, verticesArray.length / 3 - start, 1 );
 
 
 	}

+ 1 - 1
src/renderers/webgl/WebGLTextures.js

@@ -7,7 +7,7 @@ import { _Math } from '../../math/Math.js';
 
 function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
 
-	var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext );
+	var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext ); /* global WebGL2RenderingContext */
 	var _videoTextures = {};
 	var _canvas;
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio