language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
mrdoob
three.js
edd804017ab5c7f4bf86c3283fb981563dfe1be1.json
Set animation context only if window is available
src/renderers/WebGLRenderer.js
@@ -1029,7 +1029,8 @@ function WebGLRenderer( parameters ) { var animation = new WebGLAnimation(); animation.setAnimationLoop( onAnimationFrame ); - animation.setContext( typeof window !== 'undefined' ? window : null ); + + if ( typeof window !== 'undefined' ) animation.setContext( window ); this.setAnimationLoop = function ( callback ) {
false
Other
mrdoob
three.js
dc6dc5a1ab9fa598ba5e5f81789bedcd796aedd0.json
Add docs for Box3Helper and PlaneHelper
docs/api/helpers/Box3Helper.html
@@ -0,0 +1,63 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8" /> + <base href="../../" /> + <script src="list.js"></script> + <script src="page.js"></script> + <link type="text/css" rel="stylesheet" href="page.css" /> + </head> + <body> + [page:LineSegments] &rarr; + + <h1>[name]</h1> + + <div class="desc"> + Helper object to visualize a [page:Box3]. + </div> + + + <h2>Example</h2> + + <code> + var box = new THREE.Box3(); + // Initialize the box somehow: + box.setFromCenterAndSize( new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 2, 1, 3 ) ); + var helper = new THREE.Box3Helper( box, 0xffff00 ); + scene.add( helper ); + </code> + + + <h2>Constructor</h2> + + + <h3>[name]( [page:Box3 box], [page:Color color] )</h3> + <div> + [page:Box3 box] -- the Box3 to show.<br /> + [page:Color color] -- (optional) the box's color. Default is 0xffff00.<br /><br /> + + Creates a new wireframe box that represents the passed Box3. + </div> + + <h2>Properties</h2> + <div>See the base [page:LineSegments] class for common properties.</div> + + <h3>[property:Box3 box]</h3> + <div>The Box3 being visualized.</div> + + + <h2>Methods</h2> + <div>See the base [page:LineSegments] class for common methods.</div> + + + <h3>[method:void updateMatrixWorld]( force )</h3> + <div> + Overridden to also update the wireframe box to the extent of the passed + [page:Box3Helper.box]. + </div> + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + </body> +</html>
true
Other
mrdoob
three.js
dc6dc5a1ab9fa598ba5e5f81789bedcd796aedd0.json
Add docs for Box3Helper and PlaneHelper
docs/api/helpers/PlaneHelper.html
@@ -0,0 +1,64 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8" /> + <base href="../../" /> + <script src="list.js"></script> + <script src="page.js"></script> + <link type="text/css" rel="stylesheet" href="page.css" /> + </head> + <body> + [page:LineSegments] &rarr; + + <h1>[name]</h1> + + <div class="desc"> + Helper object to visualize a [page:Plane]. + </div> + + + <h2>Example</h2> + + <code> + var plane = new THREE.Plane(new THREE.Vector3(1, 1, 0.2), 3); + helper = new THREE.PlaneHelper( plane, 1, 0xffff00 ); + scene.add( helper ); + </code> + + + <h2>Constructor</h2> + + + <h3>[name]( [page:Plane plane], [page:Float size], [page:Color hex] )</h3> + <div> + [page:Plane plane] -- the plane to visualize.<br /> + [page:Float size] -- (optional) side length of plane helper. Default is 1. + [page:Color color] -- (optional) the color of the helper. Default is 0xffff00.<br /><br /> + + Creates a new wireframe representation of the passed plane. + </div> + + <h2>Properties</h2> + <div>See the base [page:LineSegments] class for common properties.</div> + + <h3>[property:Plane plane]</h3> + <div>The [page:Plane plane] being visualized.</div> + + <h3>[property:Float size]</h3> + <div>The side lengths of plane helper.</div> + + + <h2>Methods</h2> + <div>See the base [page:LineSegments] class for common methods.</div> + + <h3>[method:void updateMatrixWorld]( force )</h3> + <div> + Overridden to also update the helper size and location according to passed + [page:PlaneHelper.plane] and the [page:PlaneHelper.size] property. + </div> + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + </body> +</html>
true
Other
mrdoob
three.js
20b800c303fe1b949971f4114730873c095816f9.json
Add viewOffset.enabled flag
src/cameras/OrthographicCamera.js
@@ -56,6 +56,7 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), if ( this.view === null ) { this.view = { + enabled: true, fullWidth: 1, fullHeight: 1, offsetX: 0, @@ -66,6 +67,7 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), } + this.view.enabled = true; this.view.fullWidth = fullWidth; this.view.fullHeight = fullHeight; this.view.offsetX = x; @@ -79,7 +81,12 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), clearViewOffset: function () { - this.view = null; + if ( this.view !== null ) { + + this.view.enabled = false; + + } + this.updateProjectionMatrix(); }, @@ -96,7 +103,7 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), var top = cy + dy; var bottom = cy - dy; - if ( this.view !== null ) { + if ( this.view !== null && this.view.enabled ) { var zoomW = this.zoom / ( this.view.width / this.view.fullWidth ); var zoomH = this.zoom / ( this.view.height / this.view.fullHeight );
true
Other
mrdoob
three.js
20b800c303fe1b949971f4114730873c095816f9.json
Add viewOffset.enabled flag
src/cameras/PerspectiveCamera.js
@@ -151,6 +151,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), if ( this.view === null ) { this.view = { + enabled: true, fullWidth: 1, fullHeight: 1, offsetX: 0, @@ -161,6 +162,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), } + this.view.enabled = true; this.view.fullWidth = fullWidth; this.view.fullHeight = fullHeight; this.view.offsetX = x; @@ -174,7 +176,12 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), clearViewOffset: function () { - this.view = null; + if ( this.view !== null ) { + + this.view.enabled = false; + + } + this.updateProjectionMatrix(); }, @@ -189,7 +196,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), left = - 0.5 * width, view = this.view; - if ( view !== null ) { + if ( this.view !== null && this.view.enabled ) { var fullWidth = view.fullWidth, fullHeight = view.fullHeight;
true
Other
mrdoob
three.js
33ecb129e2193b9f56c93cacabe20dc01b00167d.json
Hold maxMipMapLevel in textureProperties
src/renderers/WebGLRenderer.js
@@ -1975,7 +1975,7 @@ function WebGLRenderer( parameters ) { uniforms.reflectivity.value = material.reflectivity; uniforms.refractionRatio.value = material.refractionRatio; - uniforms.maxMipLevel.value = material.envMap.maxMipLevel; + uniforms.maxMipLevel.value = properties.get( material.envMap ).__maxMipLevel; }
true
Other
mrdoob
three.js
33ecb129e2193b9f56c93cacabe20dc01b00167d.json
Hold maxMipMapLevel in textureProperties
src/renderers/webgl/WebGLTextures.js
@@ -86,7 +86,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _gl.generateMipmap( target ); var image = Array.isArray( texture.image ) ? texture.image[ 0 ] : texture.image; - texture.maxMipLevel = Math.max( Math.log2( Math.max( image.width, image.height ) ), texture.maxMipLevel ); + var textureProperties = properties.get( texture ); + textureProperties.__maxMipLevel = Math.max( Math.log2( Math.max( image.width, image.height ) ), textureProperties.__maxMipLevel ); } @@ -336,11 +337,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( ! isCompressed ) { - texture.maxMipLevel = 0; + textureProperties.__maxMipLevel = 0; } else { - texture.maxMipLevel = mipmaps.length - 1; + textureProperties.__maxMipLevel = mipmaps.length - 1; } @@ -533,12 +534,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } texture.generateMipmaps = false; - texture.maxMipLevel = mipmaps.length - 1; + textureProperties.__maxMipLevel = mipmaps.length - 1; } else { state.texImage2D( _gl.TEXTURE_2D, 0, glFormat, image.width, image.height, 0, glFormat, glType, image.data ); - texture.maxMipLevel = 0; + textureProperties.__maxMipLevel = 0; } @@ -568,7 +569,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - texture.maxMipLevel = mipmaps.length - 1; + textureProperties.__maxMipLevel = mipmaps.length - 1; } else { @@ -588,12 +589,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } texture.generateMipmaps = false; - texture.maxMipLevel = mipmaps.length - 1; + textureProperties.__maxMipLevel = mipmaps.length - 1; } else { state.texImage2D( _gl.TEXTURE_2D, 0, glFormat, glFormat, glType, image ); - texture.maxMipLevel = 0; + textureProperties.__maxMipLevel = 0; }
true
Other
mrdoob
three.js
447130ed160595cc72167db1ed1cd5f4da656b1b.json
Add a PLY Exporter
examples/js/exporters/PLYExporter.js
@@ -0,0 +1,233 @@ +/** + * @author Garrett Johnson / http://gkjohnson.github.io/ + * https://github.com/gkjohnson/ply-exporter-js + * + * Usage: + * var exporter = new THREE.PLYExporter(); + * + * // second argument is an array of attributes to + * // exclude from the format ('color', 'uv', 'normal') + * var data = exporter.parse(mesh, [ 'color' ]); + * + * Format Definition: + * http://paulbourke.net/dataformats/ply/ + */ + +THREE.PLYExporter = function () {}; + +THREE.PLYExporter.prototype = { + + constructor: THREE.PLYExporter, + + parse: function ( object, excludeProperties ) { + + if ( Array.isArray( excludeProperties ) !== true ) { + + excludeProperties = []; + + } + + var includeNormals = excludeProperties.indexOf( 'normal' ) === - 1; + var includeColors = excludeProperties.indexOf( 'color' ) === - 1; + var includeUVs = excludeProperties.indexOf( 'uv' ) === - 1; + + // count the number of vertices + var vertexCount = 0; + var faceCount = 0; + var vertexList = ''; + var faceList = ''; + + var vertex = new THREE.Vector3(); + var normalMatrixWorld = new THREE.Matrix3(); + object.traverse( function ( child ) { + + if ( child instanceof THREE.Mesh ) { + + var mesh = child; + var geometry = mesh.geometry; + + if ( geometry instanceof THREE.Geometry ) { + + geometry = new THREE.BufferGeometry().setFromObject( mesh ); + + } + + if ( geometry instanceof THREE.BufferGeometry ) { + + var vertices = geometry.getAttribute( 'position' ); + var normals = geometry.getAttribute( 'normal' ); + var uvs = geometry.getAttribute( 'uv' ); + var colors = geometry.getAttribute( 'color' ); + var indices = geometry.getIndex(); + + normalMatrixWorld.getNormalMatrix( mesh.matrixWorld ); + + if ( vertices === undefined ) { + + return; + + } + + // form each line + for ( i = 0, l = vertices.count; i < l; i ++ ) { + + vertex.x = vertices.getX( i ); + vertex.y = vertices.getY( i ); + vertex.z = vertices.getZ( i ); + + vertex.applyMatrix4( mesh.matrixWorld ); + + + // Position information + var line = + vertex.x + ' ' + + vertex.y + ' ' + + vertex.z; + + // Normal information + if ( includeNormals === true ) { + + if ( normals !== undefined ) { + + vertex.x = normals.getX( i ); + vertex.y = normals.getY( i ); + vertex.z = normals.getZ( i ); + + vertex.applyMatrix3( normalMatrixWorld ); + + line += ' ' + + vertex.x + ' ' + + vertex.y + ' ' + + vertex.z; + + } else { + + line += ' 0 0 0'; + + } + + } + + // UV information + if ( includeUVs === true ) { + + if ( uvs !== undefined ) { + + line += ' ' + + uvs.getX( i ) + ' ' + + uvs.getY( i ); + + } else if ( includeUVs !== false ) { + + line += ' 0 0'; + + } + + } + + // Color information + if ( includeColors === true ) { + + if ( colors !== undefined ) { + + line += ' ' + + Math.floor( colors.getX( i ) ) + ' ' + + Math.floor( colors.getY( i ) ) + ' ' + + Math.floor( colors.getZ( i ) ); + + } else { + + line += ' 255 255 255'; + + } + + } + + vertexList += line + '\n'; + + } + + + // Create the face list + if ( indices !== null ) { + + for ( i = 0, l = indices.count; i < l; i += 3 ) { + + faceList += `3 ${ indices.getX( i + 0 ) + vertexCount }`; + faceList += ` ${ indices.getX( i + 1 ) + vertexCount }`; + faceList += ` ${ indices.getX( i + 2 ) + vertexCount }\n`; + + } + + } else { + + for ( var i = 0, l = vertices.count; i < l; i += 3 ) { + + faceList += `3 ${ vertexCount + i } ${ vertexCount + i + 1 } ${ vertexCount + i + 2 }\n`; + + } + + } + + vertexCount += vertices.count; + faceCount += indices ? indices.count / 3 : vertices.count / 3; + + } + + } + + } ); + + var output = + 'ply\n' + + 'format ascii 1.0\n' + + `element vertex ${vertexCount}\n` + + + // position + 'property float x\n' + + 'property float y\n' + + 'property float z\n'; + + if ( includeNormals === true ) { + + // normal + output += + 'property float nx\n' + + 'property float ny\n' + + 'property float nz\n'; + + } + + if ( includeUVs === true ) { + + // uvs + output += + 'property float s\n' + + 'property float t\n'; + + } + + if ( includeColors === true ) { + + // colors + output += + 'property uchar red\n' + + 'property uchar green\n' + + 'property uchar blue\n'; + + } + + // faces + output += + `element face ${faceCount}\n` + + 'property list uchar int vertex_index\n' + + 'end_header\n' + + + `${vertexList}\n` + + `${faceList}\n`; + + return output; + + } + +};
false
Other
mrdoob
three.js
abf100836dfd4a8612fd28346f21264bb4d910b2.json
Update FileLoader doc
docs/api/loaders/FileLoader.html
@@ -24,7 +24,7 @@ <h2>Example</h2> <code> var loader = new THREE.FileLoader(); - //load a text file a output the result to the console + //load a text file and output the result to the console loader.load( // resource URL 'example.txt', @@ -47,27 +47,25 @@ <h2>Example</h2> ); </code> - <h2>Constructor</h2> - - <h3>[name]( [param:LoadingManager manager] )</h3> <div> - [page:LoadingManager manager] β€” The [page:LoadingManager loadingManager] for the loader to use. - Default is [page:DefaultLoadingManager]. + <em>Note:</em> The cache must be enabled using + <code>THREE.Cache.enabled = true;</code> + This is a global property and only needs to be set once to be used by all loaders that use FileLoader internally. + [page:Cache Cache] is a cache module that holds the response from each request made through this loader, so each file is requested once. </div> - <h2>Properties</h2> + <h2>Constructor</h2> - <h3>[property:Cache cache]</h3> + <h3>[name] ( [param:LoadingManager manager] )</h3> <div> - A reference to [page:Cache Cache] that hold the response from each request made - through this loader, so each file is requested once.<br /><br /> - - <em>Note:</em>The cache must be enabled using - <code>THREE.Cache.enabled = true.</code> - This is a global property and only needs to be set once to be used by all loaders that use FileLoader internally. + [page:LoadingManager manager] β€” The [page:LoadingManager loadingManager] for the loader to use. + Default is [page:DefaultLoadingManager]. </div> + + <h2>Properties</h2> + <h3>[property:LoadingManager manager]</h3> <div> The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager]. @@ -82,29 +80,31 @@ <h3>[property:String mimeType]</h3> <h3>[property:String path]</h3> <div>The base path from which files will be loaded. See [page:.setPath]. Default is *undefined*.</div> + <h3>[property:object requestHeader]</h3> + <div>The [link:https://developer.mozilla.org/en-US/docs/Glossary/Request_header request header] used in HTTP request. See [page:.setRequestHeader]. Default is *undefined*.</div> + <h3>[property:String responseType]</h3> <div>The expected response type. See [page:.setResponseType]. Default is *undefined*.</div> <h3>[property:String withCredentials]</h3> <div> - Whether the XMLHttpRequest uses credentials - see [page:.setWithCredentials]. + Whether the XMLHttpRequest uses credentials. See [page:.setWithCredentials]. Default is *undefined*. </div> - <h2>Methods</h2> <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3> <div> - [page:String url] β€” the path or URL to the file. This can also be a - [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br /> - [page:Function onLoad] β€” Will be called when loading completes. The argument will be the loaded response.<br /> - [page:Function onProgress] β€” Will be called while load progresses. The argument will be the XMLHttpRequest instance, - which contains .[page:Integer total] and .[page:Integer loaded] bytes.<br /> - [page:Function onError] β€” Will be called if an error occurs.<br /><br /> - - Load the URL and pass the response to the onLoad function. + [page:String url] β€” the path or URL to the file. This can also be a + [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br /> + [page:Function onLoad] (optional) β€” Will be called when loading completes. The argument will be the loaded response.<br /> + [page:Function onProgress] (optional) β€” Will be called while load progresses. The argument will be the XMLHttpRequest instance, + which contains .[page:Integer total] and .[page:Integer loaded] bytes.<br /> + [page:Function onError] (optional) β€” Will be called if an error occurs.<br /><br /> + + Load the URL and pass the response to the onLoad function. </div> <h3>[method:FileLoader setMimeType]( [param:String mimeType] )</h3> @@ -119,28 +119,31 @@ <h3>[method:FileLoader setPath]( [param:String path] )</h3> you are loading many models from the same directory. </div> - <h3>[method:FileLoader setResponseType]( [param:String responseType] )</h3> + <h3>[method:FileLoader setRequestHeader]( [param:object requestHeader] )</h3> <div> - [page:String responseType] β€” Default is '' (empty string).<br /><br /> + [page:object requestHeader] - key: The name of the header whose value is to be set. value: The value to set as the body of the header.<br /><br /> - Change the response type. Valid values are:<br /> - [page:String text], empty string (default), or any other value. Any file type, returns the unprocessed file data.<br /> - [page:String arraybuffer] - loads the data into a [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer ArrayBuffer] and returns that.<br /> - [page:String blob] - returns the data as a [link:https://developer.mozilla.org/en/docs/Web/API/Blob Blob].<br /> - [page:String document] - parse the file using the [link:https://developer.mozilla.org/en-US/docs/Web/API/DOMParser DOMParser].<br /> - [page:String json] - parse the file using [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse JSON.parse].<br /> + Set the [link:https://developer.mozilla.org/en-US/docs/Glossary/Request_header request header] used in HTTP request. + </div> + <h3>[method:FileLoader setResponseType]( [param:String responseType] )</h3> + <div> + Change the response type. Valid values are:<br /> + [page:String text] or empty string (default) - returns the data as [page:String string].<br /> + [page:String arraybuffer] - loads the data into a [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer ArrayBuffer] and returns that.<br /> + [page:String blob] - returns the data as a [link:https://developer.mozilla.org/en/docs/Web/API/Blob Blob].<br /> + [page:String document] - parses the file using the [link:https://developer.mozilla.org/en-US/docs/Web/API/DOMParser DOMParser].<br /> + [page:String json] - parses the file using [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse JSON.parse].<br /> </div> <h3>[method:FileLoader setWithCredentials]( [param:Boolean value] )</h3> - Whether the XMLHttpRequest uses credentials such as cookies, authorization headers or - TLS client certificates. See - [link:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials XMLHttpRequest.withCredentials].<br /> - Note that this has no effect if you are loading files locally or from the same domain. <div> - + Whether the XMLHttpRequest uses credentials such as cookies, authorization headers or + TLS client certificates. See [link:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials XMLHttpRequest.withCredentials].<br /> + Note that this has no effect if you are loading files locally or from the same domain. </div> + <h2>Source</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
false
Other
mrdoob
three.js
e73f4549ecc3978099d8a29c62f8c168887248f2.json
Remove redundant code getWireframeAttribute is only called with a bufferGeometry.
src/renderers/webgl/WebGLGeometries.js
@@ -32,17 +32,6 @@ function WebGLGeometries( gl, attributes, info ) { delete geometries[ geometry.id ]; - // TODO Remove duplicate code - - var attribute = wireframeAttributes[ geometry.id ]; - - if ( attribute ) { - - attributes.remove( attribute ); - delete wireframeAttributes[ geometry.id ]; - - } - attribute = wireframeAttributes[ buffergeometry.id ]; if ( attribute ) {
false
Other
mrdoob
three.js
869cd160f56a46d1ae22b973c107bcc08f79ce0f.json
Add missing default 'binary' option to GLTFLoader
examples/js/exporters/GLTFExporter.js
@@ -66,6 +66,7 @@ THREE.GLTFExporter.prototype = { parse: function ( input, onDone, options ) { var DEFAULT_OPTIONS = { + binary: false, trs: false, onlyVisible: true, truncateDrawRange: true,
false
Other
mrdoob
three.js
c11662b22ffb2babba1754854f0449f956411188.json
Fix inaccurate comments in Matrix4 These weren't really correct, since Matrix4 elements are stored in column-major order.
src/math/Matrix4.js
@@ -263,12 +263,12 @@ Object.assign( Matrix4.prototype, { } - // last column + // bottom row te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; - // bottom row + // last column te[ 12 ] = 0; te[ 13 ] = 0; te[ 14 ] = 0; @@ -752,12 +752,12 @@ Object.assign( Matrix4.prototype, { te[ 6 ] = ( yz + wx ) * sy; te[ 10 ] = ( 1 - ( xx + yy ) ) * sz; - // last column + // bottom row te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; - // bottom row + // last column te[ 12 ] = position.x; te[ 13 ] = position.y; te[ 14 ] = position.z;
false
Other
mrdoob
three.js
30f103f0044d881d0c00166e58c80b770514d224.json
Update error message
src/geometries/ParametricGeometry.js
@@ -65,7 +65,7 @@ function ParametricBufferGeometry( func, slices, stacks ) { if ( func.length < 3 ) { - console.error( 'THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.' ); + console.error( 'THREE.ParametricGeometry: "func" now has a third mandatory parameter, the result vector of the surface equation.' ); }
false
Other
mrdoob
three.js
03cdce01084b325f2ed061d4fe027dd160dd48a5.json
Add error message
src/core/DirectGeometry.js
@@ -139,6 +139,12 @@ Object.assign( DirectGeometry.prototype, { var hasSkinWeights = skinWeights.length === vertices.length; // + + if ( faces.length === 0 ) { + + console.error( 'THREE.DirectGeometry: Faceless geometries are not supported.' ); + + } for ( var i = 0; i < faces.length; i ++ ) {
false
Other
mrdoob
three.js
b55743ebcde87751606933bdbd6d45b25eb3a8be.json
Update error message
examples/js/exporters/PLYBinaryExporter.js
@@ -94,9 +94,8 @@ THREE.PLYBinaryExporter.prototype = { // as triangles) console.error( - 'PLYExporter: Failed to generate a valid PLY file because the ' + - 'number of faces is not divisible by 3. This can be caused by ' + - 'exporting a mix of triangle and non-triangle mesh types.' + 'PLYBinaryExporter: Failed to generate a valid PLY file with triangle indices because the ' + + 'number of faces is not divisible by 3.' );
true
Other
mrdoob
three.js
b55743ebcde87751606933bdbd6d45b25eb3a8be.json
Update error message
examples/js/exporters/PLYExporter.js
@@ -240,9 +240,8 @@ THREE.PLYExporter.prototype = { // as triangles) console.error( - 'PLYExporter: Failed to generate a valid PLY file because the ' + - 'number of faces is not divisible by 3. This can be caused by ' + - 'exporting a mix of triangle and non-triangle mesh types.' + 'PLYExporter: Failed to generate a valid PLY file with triangle indices because the ' + + 'number of faces is not divisible by 3.' );
true
Other
mrdoob
three.js
707d575b446a38f4971238ad6a74bb597fb2046c.json
MMDLoader doc: Minor update
docs/examples/loaders/MMDLoader.html
@@ -13,7 +13,7 @@ <h1>[name]</h1> <p class="desc"> A loader for <a href="http://www.geocities.jp/higuchuu4/index_e.htm"><em>MMD</em></a> resources. <br /><br /> [name] creates Three.js Objects from MMD resources as PMD, PMX, VMD, and VPD files. - You can easily handle MMD special features, as IK, Grant, and Physics, with [page:MMDAnimationHelper].<br /><br /> + See [page:MMDAnimationHelper] for MMD animation handling as IK, Grant, and Physics.<br /><br /> If you want raw content of MMD resources, use .loadPMD/PMX/VMD/VPD methods.
false
Other
mrdoob
three.js
2df38a25db138dad149ddf7e9c8dbae4f9c8e872.json
Remove unused shadowmap chunks
src/renderers/shaders/ShaderLib/points_frag.glsl
@@ -6,7 +6,6 @@ uniform float opacity; #include <color_pars_fragment> #include <map_particle_pars_fragment> #include <fog_pars_fragment> -#include <shadowmap_pars_fragment> #include <logdepthbuf_pars_fragment> #include <clipping_planes_pars_fragment>
true
Other
mrdoob
three.js
2df38a25db138dad149ddf7e9c8dbae4f9c8e872.json
Remove unused shadowmap chunks
src/renderers/shaders/ShaderLib/points_vert.glsl
@@ -4,7 +4,6 @@ uniform float scale; #include <common> #include <color_pars_vertex> #include <fog_pars_vertex> -#include <shadowmap_pars_vertex> #include <logdepthbuf_pars_vertex> #include <clipping_planes_pars_vertex> @@ -23,7 +22,6 @@ void main() { #include <logdepthbuf_vertex> #include <clipping_planes_vertex> #include <worldpos_vertex> - #include <shadowmap_vertex> #include <fog_vertex> }
true
Other
mrdoob
three.js
0b39b0995b3688bfbef088ce3c3df98d4f447a6f.json
Update error message
src/geometries/ParametricGeometry.js
@@ -65,7 +65,7 @@ function ParametricBufferGeometry( func, slices, stacks ) { if ( func.length < 3 ) { - console.error( 'Parametric geometries now require modification of a third THREE.Vector3 argument.' ); + console.error( 'THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.' ); }
false
Other
mrdoob
three.js
7851e77cefefdb589b3f844b23a73366e3488f64.json
Add error for new behavior
src/geometries/ParametricGeometry.js
@@ -63,6 +63,12 @@ function ParametricBufferGeometry( func, slices, stacks ) { var i, j; + if ( func.length < 3 ) { + + console.error( 'Parametric geometries now require modification of a third THREE.Vector3 argument.' ); + + } + // generate vertices, normals and uvs var sliceCount = slices + 1;
false
Other
mrdoob
three.js
fe78029f10ea7f29e096863ceedd030b0fef16fa.json
Fix typo in documentation
docs/api/cameras/OrthographicCamera.html
@@ -59,7 +59,7 @@ <h3>[name]( [page:Number left], [page:Number right], [page:Number top], [page:Nu <h2>Properties</h2> <div> See the base [page:Camera] class for common properties.<br> - Note that after making changes to most of these poperties you will have to call + Note that after making changes to most of these properties you will have to call [page:OrthographicCamera.updateProjectionMatrix .updateProjectionMatrix] for the changes to take effect. </div>
false
Other
mrdoob
three.js
9ed629301d0200448f335ce38b95a95c6a5f7363.json
Check parent of poseObject instead of camera
src/renderers/webvr/WebVRManager.js
@@ -147,7 +147,7 @@ function WebVRManager( renderer ) { cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix ); cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix ); - var parent = camera.parent; + var parent = poseObject.parent; if ( parent !== null ) {
false
Other
mrdoob
three.js
6d9c22a3bc346f34ad779bada397db6f5c691760.json
Update uniforms only when onWindowResize
examples/webgl_raymarching_reflect.html
@@ -345,8 +345,6 @@ if ( camera.position.y < 0 ) camera.position.y = 0; - material.uniforms.resolution.value.set( canvas.width, canvas.height ); - material.uniforms.cameraProjectionMatrixInverse.value.getInverse( camera.projectionMatrix ); renderer.render( scene, camera ); @@ -377,6 +375,9 @@ camera.aspect = canvas.width / canvas.height; camera.updateProjectionMatrix(); + material.uniforms.resolution.value.set( canvas.width, canvas.height ); + material.uniforms.cameraProjectionMatrixInverse.value.getInverse( camera.projectionMatrix ); + } </script>
false
Other
mrdoob
three.js
881b25b58d0c07324f6fb182bca520d8ec60ffc7.json
Update ProjectionMatrix on change aspect
examples/webgl_raymarching_reflect.html
@@ -202,10 +202,13 @@ void main(void) { // screen position - vec2 screenPos = ( gl_FragCoord.xy * 2.0 - resolution ) / min( resolution.x, resolution.y ); + vec2 screenPos = ( gl_FragCoord.xy * 2.0 - resolution ) / resolution; - // convert ray direction from screen coordinate to world coordinate - vec3 ray = (cameraWorldMatrix * cameraProjectionMatrixInverse * vec4( screenPos.xy, 1.0, 1.0 )).xyz; + // ray direction in normalized device coordinate + vec4 ndcRay = vec4( screenPos.xy, 1.0, 1.0 ); + + // convert ray direction from normalized device coordinate to world coordinate + vec3 ray = ( cameraWorldMatrix * cameraProjectionMatrixInverse * ndcRay ).xyz; ray = normalize( ray ); // camera position @@ -371,6 +374,9 @@ } + camera.aspect = canvas.width / canvas.height; + camera.updateProjectionMatrix(); + } </script>
false
Other
mrdoob
three.js
5aea41dfaa236eaf74f95479f714e6ebbf648774.json
Use negative scale to mirror model
examples/webgl_loader_x.html
@@ -163,17 +163,22 @@ //download Model file - loader.load( [ 'models/xfile/SSR06_model.x', { zflag: true } ], function ( object ) { + loader.load( [ 'models/xfile/SSR06_model.x', { zflag: false } ], function ( object ) { for ( var i = 0; i < object.models.length; i ++ ) { - Models.push( object.models[ i ] ); + var model = object.models[ i ]; + + model.scale.x *= - 1; + + Models.push( model ); } loadAnimation( 'stand', 0, () => { scene.add( Models[ 0 ] ); + if ( Models[ 0 ] instanceof THREE.SkinnedMesh ) { skeletonHelper = new THREE.SkeletonHelper( Models[ 0 ] ); @@ -240,7 +245,7 @@ } else { var loader2 = new THREE.XLoader( manager, Texloader ); - loader2.load( [ 'models/xfile/' + animeName + '.x', { zflag: true, putPos: false, putScl: false } ], function () { + loader2.load( [ 'models/xfile/' + animeName + '.x', { zflag: false, putPos: false, putScl: false } ], function () { // !! important! // associate divided model and animation.
false
Other
mrdoob
three.js
fd01184c9415a3f2f54dec29adf918ac53ec0ade.json
Rename some glsl variables and functions
examples/webgl_raymarching_reflect.html
@@ -58,7 +58,7 @@ const vec3 lightDir = vec3( -0.48666426339228763, 0.8111071056538127, -0.3244428422615251 ); // distance functions - vec3 onRep( vec3 p, float interval ) { + vec3 opRep( vec3 p, float interval ) { vec2 q = mod( p.xz, interval ) - interval * 0.5; return vec3( q.x, p.y, q.y ); @@ -67,7 +67,7 @@ float sphereDist( vec3 p, float r ) { - return length( onRep( p, 3.0 ) ) - r; + return length( opRep( p, 3.0 ) ) - r; } @@ -159,18 +159,18 @@ } - vec3 getRayColor( vec3 origin, vec3 ray, out vec3 p, out vec3 normal, out bool hit ) { + vec3 getRayColor( vec3 origin, vec3 ray, out vec3 pos, out vec3 normal, out bool hit ) { // marching loop float dist; float depth = 0.0; - p = origin; + pos = origin; for ( int i = 0; i < 64; i++ ){ - dist = sceneDist( p ); + dist = sceneDist( pos ); depth += dist; - p = origin + depth * ray; + pos = origin + depth * ray; if ( abs(dist) < EPS ) break; @@ -181,11 +181,11 @@ if ( abs(dist) < EPS ) { - normal = getNormal(p); + normal = getNormal(pos); float diffuse = clamp( dot( lightDir, normal ), 0.1, 1.0 ); float specular = pow( clamp( dot( reflect( lightDir, normal ), ray ), 0.0, 1.0 ), 10.0 ); - float shadow = getShadow( p + normal * OFFSET, lightDir ); - color = ( sceneColor( p ).rgb * diffuse + vec3( 0.8 ) * specular ) * max( 0.5, shadow ); + float shadow = getShadow( pos + normal * OFFSET, lightDir ); + color = ( sceneColor( pos ).rgb * diffuse + vec3( 0.8 ) * specular ) * max( 0.5, shadow ); hit = true; @@ -212,16 +212,16 @@ vec3 cPos = cameraPosition; vec3 color = vec3( 0.0 ); - vec3 p, normal; + vec3 pos, normal; bool hit; float alpha = 1.0; for ( int i = 0; i < 3; i++ ) { - color += alpha * getRayColor( cPos, ray, p, normal, hit ); + color += alpha * getRayColor( cPos, ray, pos, normal, hit ); alpha *= 0.3; ray = normalize( reflect( ray, normal ) ); - cPos = p + normal * OFFSET; + cPos = pos + normal * OFFSET; if ( !hit ) break;
false
Other
mrdoob
three.js
29b1e20fa36ff70da3d121f2b16d6b616b02ae2c.json
Get ray by decomposing the camera matrix
examples/webgl_raymarching_reflect.html
@@ -46,8 +46,12 @@ precision highp float; uniform vec2 resolution; - uniform vec3 cameraPos; - uniform vec3 cameraDir; + + uniform mat4 viewMatrix; + uniform vec3 cameraPosition; + + uniform mat4 cameraWorldMatrix; + uniform mat4 cameraProjectionMatrixInverse; const float EPS = 0.01; const float OFFSET = EPS * 100.0; @@ -198,33 +202,32 @@ void main(void) { // fragment position - vec2 p = ( gl_FragCoord.xy * 2.0 - resolution ) / min( resolution.x, resolution.y ); + vec2 screenPos = ( gl_FragCoord.xy * 2.0 - resolution ) / min( resolution.x, resolution.y ); + + // convert ray direction from screen coordinate to world coordinate + vec3 ray = (cameraWorldMatrix * cameraProjectionMatrixInverse * vec4( screenPos.xy, 1.0, 1.0 )).xyz; + ray = normalize( ray ); - // camera and ray - vec3 cPos = cameraPos; - vec3 cDir = cameraDir; - vec3 cSide = normalize( cross( cDir, vec3( 0.0, 1.0 ,0.0 ) ) ); - vec3 cUp = normalize( cross( cSide, cDir ) ); - float targetDepth = 1.3; - vec3 ray = normalize( cSide * p.x + cUp * p.y + cDir * targetDepth ); + // camera position + vec3 cPos = cameraPosition; vec3 color = vec3( 0.0 ); - vec3 q, normal; + vec3 p, normal; bool hit; float alpha = 1.0; for ( int i = 0; i < 3; i++ ) { - color += alpha * getRayColor( cPos, ray, q, normal, hit ); + color += alpha * getRayColor( cPos, ray, p, normal, hit ); alpha *= 0.3; ray = normalize( reflect( ray, normal ) ); - cPos = q + normal * OFFSET; + cPos = p + normal * OFFSET; if ( !hit ) break; } - gl_FragColor = vec4(color, 1.0); + gl_FragColor = vec4( color, 1.0 ); } @@ -250,7 +253,7 @@ <script> - var camera, dummyCamera, scene, controls, renderer; + var camera, scene, controls, renderer; var geometry, material, mesh; var mouse = new THREE.Vector2( 0.5, 0.5 ); var canvas; @@ -261,7 +264,7 @@ var config = { saveImage: function() { - renderer.render( scene, dummyCamera ); + renderer.render( scene, camera ); window.open( canvas.toDataURL() ); }, @@ -274,40 +277,42 @@ function init() { + renderer = new THREE.WebGLRenderer(); + renderer.setPixelRatio( window.devicePixelRatio ); + renderer.setSize( 512, 512 ); + + canvas = renderer.domElement; + canvas.addEventListener( 'mousemove', onMouseMove ); + window.addEventListener( 'resize', onWindowResize ); + document.body.appendChild( canvas ); + + // Scene scene = new THREE.Scene(); - camera = new THREE.Camera(); - dummyCamera = new THREE.Camera(); + camera = new THREE.PerspectiveCamera( 60, canvas.width / canvas.height, 1, 2000 ); camera.lookAt( new THREE.Vector3( 0.0, -0.3, 1.0 ) ); geometry = new THREE.PlaneBufferGeometry( 2.0, 2.0 ); material = new THREE.RawShaderMaterial( { uniforms: { resolution: { value: new THREE.Vector2( 512, 512 ) }, - cameraPos: { value: camera.getWorldPosition() }, - cameraDir: { value: camera.getWorldDirection() } + cameraWorldMatrix: { value: camera.matrixWorld }, + cameraProjectionMatrixInverse: { value: new THREE.Matrix4().getInverse( camera.projectionMatrix ) } }, vertexShader: document.getElementById( 'vertex_shader' ).textContent, fragmentShader: document.getElementById( 'fragment_shader' ).textContent } ); mesh = new THREE.Mesh( geometry, material ); + mesh.frustumCulled = false; scene.add( mesh ); - renderer = new THREE.WebGLRenderer(); - renderer.setPixelRatio( window.devicePixelRatio ); - renderer.setSize( 512, 512 ); - - canvas = renderer.domElement; - canvas.addEventListener( 'mousemove', onMouseMove ); - window.addEventListener( 'resize', onWindowResize ); - document.body.appendChild( canvas ); - + // Controls controls = new THREE.FlyControls( camera, canvas ); - controls.autoForward = true; controls.dragToLook = false; controls.rollSpeed = Math.PI / 12; controls.movementSpeed = 0.5; + // GUI var gui = new dat.GUI(); gui.add( config, 'saveImage' ).name( 'Save Image' ); gui.add( config, 'freeCamera' ).name( 'Free Camera' ); @@ -348,9 +353,11 @@ if ( camera.position.y < 0 ) camera.position.y = 0; material.uniforms.resolution.value = new THREE.Vector2( canvas.width, canvas.height ); - material.uniforms.cameraPos.value = camera.getWorldPosition(); - material.uniforms.cameraDir.value = camera.getWorldDirection(); - renderer.render( scene, dummyCamera ); + + material.uniforms.cameraWorldMatrix.value = camera.matrixWorld; + material.uniforms.cameraProjectionMatrixInverse.value = new THREE.Matrix4().getInverse( camera.projectionMatrix ); + + renderer.render( scene, camera ); stats.end(); requestAnimationFrame( render );
false
Other
mrdoob
three.js
0ed66f033eb830d1bce2ddd460842aa6b2b5a615.json
Fix import spacing as requested in #12781
test/unit/src/geometries/ShapeGeometry.tests.js
@@ -8,7 +8,7 @@ import { ShapeBufferGeometry } from '../../../../src/geometries/ShapeGeometry'; -import {Shape} from '../../../../src/extras/core/Shape'; +import { Shape } from '../../../../src/extras/core/Shape'; export default QUnit.module( 'Geometries', () => {
true
Other
mrdoob
three.js
0ed66f033eb830d1bce2ddd460842aa6b2b5a615.json
Fix import spacing as requested in #12781
test/unit/src/geometries/TubeGeometry.tests.js
@@ -8,8 +8,8 @@ import { TubeBufferGeometry } from '../../../../src/geometries/TubeGeometry'; -import {LineCurve3} from '../../../../src/extras/curves/LineCurve3' -import {Vector3} from '../../../../src/math/Vector3' +import { LineCurve3 } from '../../../../src/extras/curves/LineCurve3' +import { Vector3 } from '../../../../src/math/Vector3' export default QUnit.module( 'Geometries', () => {
true
Other
mrdoob
three.js
f5417fac65c89ee5ef52ebbea21e38dbbc782fe0.json
Apply the review comment
examples/js/loaders/GLTFLoader.js
@@ -1083,7 +1083,7 @@ THREE.GLTFLoader = ( function () { * @param {THREE.Mesh} mesh * @param {GLTF.Mesh} meshDef * @param {GLTF.Primitive} primitiveDef - * @param {Array} accessors + * @param {Array<THREE.BufferAttribute>} accessors */ function addMorphTargets( mesh, meshDef, primitiveDef, accessors ) { @@ -1371,7 +1371,7 @@ THREE.GLTFLoader = ( function () { GLTFParser.prototype.getMultiDependencies = function ( types ) { var results = {}; - var fns = []; + var pendings = []; for ( var i = 0, il = types.length; i < il; i ++ ) { @@ -1384,11 +1384,11 @@ THREE.GLTFLoader = ( function () { }.bind( this, type + ( type === 'mesh' ? 'es' : 's' ) ) ); - fns.push( value ); + pendings.push( value ); } - return Promise.all( fns ).then( function () { + return Promise.all( pendings ).then( function () { return results; @@ -1455,7 +1455,7 @@ THREE.GLTFLoader = ( function () { /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors * @param {number} accessorIndex - * @return {Promise<THREE.(Interleaved)BufferAttribute>} + * @return {Promise<THREE.BufferAttribute|THREE.InterleavedBufferAttribute>} */ GLTFParser.prototype.loadAccessor = function ( accessorIndex ) { @@ -1943,7 +1943,7 @@ THREE.GLTFLoader = ( function () { /** * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes * @param {number} meshIndex - * @return {Promise<THREE.(Skinned)Material>} + * @return {Promise<THREE.Mesh|THREE.SkinnedMesh>} */ GLTFParser.prototype.loadMesh = function ( meshIndex ) {
false
Other
mrdoob
three.js
1ef8062877113d4e2c7b473368d2f93536e49359.json
Fix intersect test parameters to translate.
src/math/Box3.js
@@ -468,6 +468,12 @@ Object.assign( Box3.prototype, { translate: function ( offset ) { + if ( ! offset.isVector3 ) { + + throw new Error( 'THREE.Box3: .translate() expects a Vector3.' ); + + } + this.min.add( offset ); this.max.add( offset );
true
Other
mrdoob
three.js
1ef8062877113d4e2c7b473368d2f93536e49359.json
Fix intersect test parameters to translate.
test/unit/src/math/Frustum.tests.js
@@ -13,7 +13,7 @@ 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 { zero3, one3 } from './Constants.tests'; +import { zero3, one3, eps } from './Constants.tests'; const unit3 = new Vector3( 1, 0, 0 ); @@ -262,7 +262,8 @@ export default QUnit.module( 'Maths', () => { intersects = a.intersectsBox( box ); assert.notOk( intersects, "No intersection" ); - box.translate( - 1, - 1, - 1 ); + // add eps so that we prevent box touching the frustum, which might intersect depending on floating point numerics + box.translate( new Vector3( - 1 - eps, - 1 - eps, - 1 - eps ) ); intersects = a.intersectsBox( box ); assert.ok( intersects, "Successful intersection" );
true
Other
mrdoob
three.js
e1174d34fae5eaf3a6429698e53416f946972db2.json
Provide shape necessary for ShapeGeometry.
test/unit/src/geometries/ShapeGeometry.tests.js
@@ -8,17 +8,22 @@ import { ShapeBufferGeometry } from '../../../../src/geometries/ShapeGeometry'; +import {Shape} from '../../../../src/extras/core/Shape'; + export default QUnit.module( 'Geometries', () => { QUnit.module( 'ShapeGeometry', ( hooks ) => { var geometries = undefined; hooks.beforeEach( function () { - const parameters = {}; + var triangleShape = new Shape(); + triangleShape.moveTo( 0, -1 ); + triangleShape.lineTo( 1, 1 ); + triangleShape.lineTo( -1, 1 ); geometries = [ - new ShapeGeometry() + new ShapeGeometry(triangleShape) ]; } ); @@ -51,10 +56,13 @@ export default QUnit.module( 'Geometries', () => { var geometries = undefined; hooks.beforeEach( function () { - const parameters = {}; + var triangleShape = new Shape(); + triangleShape.moveTo( 0, -1 ); + triangleShape.lineTo( 1, 1 ); + triangleShape.lineTo( -1, 1 ); geometries = [ - new ShapeBufferGeometry() + new ShapeBufferGeometry(triangleShape) ]; } );
false
Other
mrdoob
three.js
58f9d1b8dc6e1c2536828a1540e173f472c72780.json
Provide path necessary for TubeGeometry tests.
test/unit/src/geometries/TubeGeometry.tests.js
@@ -8,17 +8,20 @@ import { TubeBufferGeometry } from '../../../../src/geometries/TubeGeometry'; +import {LineCurve3} from '../../../../src/extras/curves/LineCurve3' +import {Vector3} from '../../../../src/math/Vector3' + export default QUnit.module( 'Geometries', () => { QUnit.module( 'TubeGeometry', ( hooks ) => { var geometries = undefined; hooks.beforeEach( function () { - const parameters = {}; + var path = new LineCurve3(new Vector3(0, 0, 0), new Vector3(0, 1, 0)); geometries = [ - new TubeGeometry() + new TubeGeometry(path) ]; } ); @@ -50,11 +53,10 @@ export default QUnit.module( 'Geometries', () => { var geometries = undefined; hooks.beforeEach( function () { - - const parameters = {}; + var path = new LineCurve3(new Vector3(0, 0, 0), new Vector3(0, 1, 0)); geometries = [ - new TubeBufferGeometry() + new TubeBufferGeometry(path) ]; } );
false
Other
mrdoob
three.js
f9cfac468aefcc815a41fa0a4f619d42431cbd9f.json
separate the logic of touchevent and mouse event
examples/js/controls/DragControls.js
@@ -30,15 +30,23 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) { _domElement.addEventListener( 'mousemove', onDocumentMouseMove, false ); _domElement.addEventListener( 'mousedown', onDocumentMouseDown, false ); - _domElement.addEventListener( 'mouseup', onDocumentMouseUp, false ); + _domElement.addEventListener( 'mouseup', onDocumentMouseCancel, false ); + _domElement.addEventListener( 'mouseleave', onDocumentMouseCancel, false ); + _domElement.addEventListener( 'touchmove', onDocumentTouchMove, false ); + _domElement.addEventListener( 'touchstart', onDocumentTouchStart, false ); + _domElement.addEventListener( 'touchend', onDocumentTouchEnd, false ); } function deactivate() { _domElement.removeEventListener( 'mousemove', onDocumentMouseMove, false ); _domElement.removeEventListener( 'mousedown', onDocumentMouseDown, false ); - _domElement.removeEventListener( 'mouseup', onDocumentMouseUp, false ); + _domElement.removeEventListener( 'mouseup', onDocumentMouseCancel, false ); + _domElement.removeEventListener( 'mouseleave', onDocumentMouseCancel, false ); + _domElement.removeEventListener( 'touchmove', onDocumentTouchMove, false ); + _domElement.removeEventListener( 'touchstart', onDocumentTouchStart, false ); + _domElement.removeEventListener( 'touchend', onDocumentTouchEnd, false ); } @@ -54,8 +62,8 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) { var rect = _domElement.getBoundingClientRect(); - _mouse.x = ( (event.clientX - rect.left) / rect.width ) * 2 - 1; - _mouse.y = - ( (event.clientY - rect.top) / rect.height ) * 2 + 1; + _mouse.x = ( ( event.clientX - rect.left ) / rect.width ) * 2 - 1; + _mouse.y = - ( ( event.clientY - rect.top ) / rect.height ) * 2 + 1; _raycaster.setFromCamera( _mouse, _camera ); @@ -134,7 +142,86 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) { } - function onDocumentMouseUp( event ) { + function onDocumentMouseCancel( event ) { + + event.preventDefault(); + + if ( _selected ) { + + scope.dispatchEvent( { type: 'dragend', object: _selected } ); + + _selected = null; + + } + + _domElement.style.cursor = 'auto'; + + } + + function onDocumentTouchMove( event ) { + + event.preventDefault(); + event = event.changedTouches[ 0 ]; + + var rect = _domElement.getBoundingClientRect(); + + _mouse.x = ( ( event.clientX - rect.left ) / rect.width ) * 2 - 1; + _mouse.y = - ( ( event.clientY - rect.top ) / rect.height ) * 2 + 1; + + _raycaster.setFromCamera( _mouse, _camera ); + + if ( _selected && scope.enabled ) { + + if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) { + + _selected.position.copy( _intersection.sub( _offset ) ); + + } + + scope.dispatchEvent( { type: 'drag', object: _selected } ); + + return; + + } + + } + + function onDocumentTouchStart( event ) { + + event.preventDefault(); + event = event.changedTouches[ 0 ]; + + var rect = _domElement.getBoundingClientRect(); + + _mouse.x = ( ( event.clientX - rect.left ) / rect.width ) * 2 - 1; + _mouse.y = - ( ( event.clientY - rect.top ) / rect.height ) * 2 + 1; + + _raycaster.setFromCamera( _mouse, _camera ); + + var intersects = _raycaster.intersectObjects( _objects ); + + if ( intersects.length > 0 ) { + + _selected = intersects[ 0 ].object; + + _plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _selected.position ); + + if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) { + + _offset.copy( _intersection ).sub( _selected.position ); + + } + + _domElement.style.cursor = 'move'; + + scope.dispatchEvent( { type: 'dragstart', object: _selected } ); + + } + + + } + + function onDocumentTouchEnd( event ) { event.preventDefault();
false
Other
mrdoob
three.js
35b6ee854445852ed80c1b7dc16768fc49f8a16e.json
Add material attributes and maps
examples/gltf_exporter.html
@@ -52,7 +52,7 @@ var container, stats; - var camera, scene, renderer; + var camera, scene1, renderer; init(); animate(); @@ -65,16 +65,16 @@ camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 ); camera.position.y = 400; - scene = new THREE.Scene(); - scene.name = 'Scene1'; + scene1 = new THREE.Scene(); + scene1.name = 'Scene1'; var light, object; - scene.add( new THREE.AmbientLight( 0xffffff ) ); + scene1.add( new THREE.AmbientLight( 0xffffff ) ); light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 1, 0 ); - scene.add( light ); + scene1.add( light ); var map = new THREE.TextureLoader().load( 'textures/UV_Grid_Sm.jpg' ); map.wrapS = map.wrapT = THREE.RepeatWrapping; @@ -87,21 +87,21 @@ object = new THREE.Mesh( new THREE.IcosahedronGeometry( 75, 1 ), material ); object.position.set( -200, 0, 200 ); - scene.add( object ); + scene1.add( object ); object = new THREE.Mesh( new THREE.OctahedronGeometry( 75, 2 ), material ); object.position.set( 0, 0, 200 ); - scene.add( object ); + scene1.add( object ); object = new THREE.Mesh( new THREE.TetrahedronGeometry( 75, 0 ), material ); object.position.set( 200, 0, 200 ); - scene.add( object ); + scene1.add( object ); // object = new THREE.Mesh( new THREE.PlaneGeometry( 100, 100, 4, 4 ), material ); object.position.set( -400, 0, 0 ); - scene.add( object ); + scene1.add( object ); */ var map2 = new THREE.TextureLoader().load( 'textures/hardwood2_diffuse.jpg' ); @@ -111,11 +111,11 @@ metalness: 0.5, roughness: 1.0 } ); - +/* object = new THREE.Mesh( new THREE.SphereBufferGeometry( 100, 32, 32 ), material ); object.position.set( 0, 0, 0 ); object.name = "Sphere"; - scene.add(object); + scene1.add(object); /* var material = new THREE.MeshStandardMaterial( { color: 0xff0000, @@ -131,38 +131,49 @@ object3 = new THREE.Mesh( new THREE.CylinderBufferGeometry( 100, 100, 100 ), material ); object3.position.set( 200, 0, 0 ); object3.name = "Cube"; - scene.add(object3); + scene1.add(object3); */ +/* object = new THREE.Mesh( new THREE.BoxBufferGeometry( 100, 100, 100 ), material ); object.position.set( -200, 0, 0 ); object.name = "Cube"; + scene1.add( object ); object2 = new THREE.Mesh( new THREE.BoxBufferGeometry( 40, 10, 80, 2, 2, 2 ), material ); object2.position.set( 0, 0, 50 ); object2.rotation.set( 0, 45, 0 ); object2.name = "SubCube"; object.add( object2 ); +*/ + + object = new THREE.Group(); + object.name = "Group"; + scene1.add( object ); + + object2 = new THREE.Mesh( new THREE.BoxBufferGeometry( 30, 30, 30 ), material ); + object2.name = "Cube in group"; + object2.position.set( 0, 100, 100 ); + object.add( object2 ); - scene.add( object ); - scene.add( camera ); + scene1.add( camera ); var cameraOrtho = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10, 10 ); - scene.add( cameraOrtho ); + scene1.add( cameraOrtho ); /* object = new THREE.Mesh( new THREE.CircleGeometry( 50, 20, 0, Math.PI * 2 ), material ); object.position.set( 0, 0, 0 ); - scene.add( object ); + scene1.add( object ); object = new THREE.Mesh( new THREE.RingGeometry( 10, 50, 20, 5, 0, Math.PI * 2 ), material ); object.position.set( 200, 0, 0 ); - scene.add( object ); + scene1.add( object ); object = new THREE.Mesh( new THREE.CylinderGeometry( 25, 75, 100, 40, 5 ), material ); object.position.set( 400, 0, 0 ); - scene.add( object ); + scene1.add( object ); */ // /* @@ -176,23 +187,23 @@ object = new THREE.Mesh( new THREE.LatheGeometry( points, 20 ), material ); object.position.set( -400, 0, -200 ); - scene.add( object ); + scene1.add( object ); object = new THREE.Mesh( new THREE.TorusGeometry( 50, 20, 20, 20 ), material ); object.position.set( -200, 0, -200 ); - scene.add( object ); + scene1.add( object ); object = new THREE.Mesh( new THREE.TorusKnotGeometry( 50, 10, 50, 20 ), material ); object.position.set( 0, 0, -200 ); - scene.add( object ); + scene1.add( object ); object = new THREE.AxisHelper( 50 ); object.position.set( 200, 0, -200 ); - scene.add( object ); + scene1.add( object ); object = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50 ); object.position.set( 400, 0, -200 ); - scene.add( object ); + scene1.add( object ); */ var scene2 = new THREE.Scene(); @@ -218,8 +229,8 @@ window.addEventListener( 'resize', onWindowResize, false ); var gltfExporter = new THREE.GLTFExporter( renderer ); - gltfExporter.parse( [scene, scene2], function( result ) { - console.log( JSON.stringify( result, null, 2 ) ); + gltfExporter.parse( [ scene1 ], function( result ) { + console.log( JSON.stringify( result, null, 2 ) ); } ); } @@ -250,8 +261,8 @@ camera.position.x = Math.cos( timer ) * 800; camera.position.z = Math.sin( timer ) * 800; - camera.lookAt( scene.position ); - renderer.render( scene, camera ); + camera.lookAt( scene1.position ); + renderer.render( scene1, camera ); }
true
Other
mrdoob
three.js
35b6ee854445852ed80c1b7dc16768fc49f8a16e.json
Add material attributes and maps
examples/js/exporters/GLTFExporter.js
@@ -40,7 +40,7 @@ THREE.GLTFExporter.prototype = { /** * Compare two arrays */ - function sameArray ( array1, array2 ) { + function equalArray ( array1, array2 ) { return ( array1.length === array2.length ) && array1.every( function( element, index ) { return element === array2[ index ]; }); @@ -275,32 +275,118 @@ THREE.GLTFExporter.prototype = { } // @QUESTION Should we avoid including any attribute that has the default value? - var gltfMaterial = { - pbrMetallicRoughness: { + var gltfMaterial = {}; + + if ( material instanceof THREE.MeshStandardMaterial ) { + + gltfMaterial.pbrMetallicRoughness = { baseColorFactor: material.color.toArray().concat( [ material.opacity ] ), metallicFactor: material.metalness, roughnessFactor: material.roughness + }; + + } + + if ( material instanceof THREE.MeshBasicMaterial ) { + + // emissiveFactor + var color = material.color.toArray(); + if ( !equalArray( color, [ 0, 0, 0 ] ) ) { + + gltfMaterial.emissiveFactor = color; + } - }; - if ( material.map ) { - gltfMaterial.pbrMetallicRoughness.baseColorTexture = { - index: processTexture(Β material.map ), - texCoord: 0 // @FIXME + // emissiveTexture + if ( material.map ) { + + gltfMaterial.emissiveTexture = { + + index: processTexture(Β material.map ), + texCoord: 0 // @FIXME + + }; + + } + + } else { + + // emissiveFactor + var emissive = material.emissive.toArray(); + if ( !equalArray( emissive, [ 0, 0, 0 ] ) ) { + + gltfMaterial.emissiveFactor = emissive; + } + + // pbrMetallicRoughness.baseColorTexture + if ( material.map ) { + + gltfMaterial.pbrMetallicRoughness.baseColorTexture = { + index: processTexture(Β material.map ), + texCoord: 0 // @FIXME + }; + + } + + // emissiveTexture + if ( material.emissiveMap ) { + + gltfMaterial.emissiveTexture = { + + index: processTexture(Β material.emissiveMap ), + texCoord: 0 // @FIXME + + }; + + } + + } + + // normalTexture + if ( material.normalMap ) { + + gltfMaterial.normalTexture = { + index: processTexture(Β material.normalMap ), + texCoord: 0 // @FIXME + }; + } + // occlusionTexture + if ( material.aoMap ) { + + gltfMaterial.occlusionTexture = { + index: processTexture(Β material.aoMap ), + texCoord: 0 // @FIXME + }; + + } + + // alphaMode + if ( material.transparent ) { + + gltfMaterial.alphaMode = 'BLEND'; // @FIXME We should detect MASK or BLEND + + } + + // doubleSided if ( material.side === THREE.DoubleSide ) { + gltfMaterial.doubleSided = true; + } - if ( material.name ) { + if ( material.name !== undefined ) { + gltfMaterial.name = material.name; + } outputJSON.materials.push( gltfMaterial ); return outputJSON.materials.length - 1; + } /** @@ -397,7 +483,7 @@ THREE.GLTFExporter.prototype = { } - if ( camera.name ) { + if ( camera.name !== undefined ) { gltfCamera.name = camera.type; } @@ -424,26 +510,26 @@ THREE.GLTFExporter.prototype = { var position = object.position.toArray(); var scale = object.scale.toArray(); - if ( !sameArray( rotation, [ 0, 0, 0, 1 ] ) ) { + if ( !equalArray( rotation, [ 0, 0, 0, 1 ] ) ) { gltfNode.rotation = rotation; } - if ( !sameArray( position, [ 0, 0, 0 ] ) ) { + if ( !equalArray( position, [ 0, 0, 0 ] ) ) { gltfNode.position = position; } - if ( !sameArray( scale, [ 1, 1, 1 ] ) ) { + if ( !equalArray( scale, [ 1, 1, 1 ] ) ) { gltfNode.scale = scale; } } else { object.updateMatrix(); - if (! sameArray( object.matrix.elements, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ] ) ) { + if (! equalArray( object.matrix.elements, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ] ) ) { gltfNode.matrix = object.matrix.elements; } }; - if ( object.name ) { + if ( object.name !== undefined ) { gltfNode.name = object.name; } @@ -484,7 +570,7 @@ THREE.GLTFExporter.prototype = { nodes: [] }; - if ( scene.name ) { + if ( scene.name !== undefined ) { gltfScene.name = scene.name; } @@ -514,15 +600,19 @@ THREE.GLTFExporter.prototype = { var blob = new Blob( dataViews, { type: 'application/octet-binary' } ); // Update the bytlength of the only main buffer and update the uri with the base64 representation of it - outputJSON.buffers[ 0 ].byteLength = blob.size; - objectURL = URL.createObjectURL( blob ); - - var reader = new window.FileReader(); - reader.readAsDataURL( blob ); - reader.onloadend = function() { - base64data = reader.result; - outputJSON.buffers[ 0 ].uri = base64data; - onDone( outputJSON ); - } + if ( outputJSON.buffers && outputJSON.buffers.length > 0 ) { + outputJSON.buffers[ 0 ].byteLength = blob.size; + objectURL = URL.createObjectURL( blob ); + + var reader = new window.FileReader(); + reader.readAsDataURL( blob ); + reader.onloadend = function() { + base64data = reader.result; + outputJSON.buffers[ 0 ].uri = base64data; + onDone( outputJSON ); + } + } else { + onDone ( outputJSON ); + } } };
true
Other
mrdoob
three.js
1f2c1d86a956bb494c63e27853f34fc55333ee59.json
Add support for cameras
examples/gltf_exporter.html
@@ -142,12 +142,15 @@ object2.position.set( 0, 0, 50 ); object2.rotation.set( 0, 45, 0 ); object2.name = "SubCube"; - object.add(object2); + object.add( object2 ); scene.add( object ); scene.add( camera ); + var cameraOrtho = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10, 10 ); + scene.add( cameraOrtho ); + /* object = new THREE.Mesh( new THREE.CircleGeometry( 50, 20, 0, Math.PI * 2 ), material ); object.position.set( 0, 0, 0 );
true
Other
mrdoob
three.js
1f2c1d86a956bb494c63e27853f34fc55333ee59.json
Add support for cameras
examples/js/exporters/GLTFExporter.js
@@ -403,6 +403,55 @@ THREE.GLTFExporter.prototype = { return outputJSON.meshes.length - 1; } + /** + * Process camera + * @param {THREE.Camera} camera Camera to process + * @return {Integer} Index of the processed mesh in the "camera" array + */ + function processCamera( camera ) { + if ( !outputJSON.cameras ) { + outputJSON.cameras = []; + } + + var isOrtho = camera instanceof THREE.OrthographicCamera; + + var gltfCamera = { + type: isOrtho ? 'orthographic' : 'perspective' + }; + + if ( isOrtho ) { + + gltfCamera.orthographic = { + + xmag: camera.right * 2, + ymag: camera.top * 2, + zfar: camera.far, + znear: camera.near + + } + + } else { + + gltfCamera.perspective = { + + aspectRatio: camera.aspect, + yfov: THREE.Math.degToRad( camera.fov ) / camera.aspect, + zfar: camera.far, + znear: camera.near + + }; + + } + + if ( camera.name ) { + gltfCamera.name = camera.type; + } + + outputJSON.cameras.push( gltfCamera ); + + return outputJSON.cameras.length - 1; + } + /** * Process Object3D node * @param {THREE.Object3D} node Object3D to processNode @@ -446,6 +495,8 @@ THREE.GLTFExporter.prototype = { if ( object instanceof THREE.Mesh ) { gltfNode.mesh = processMesh( object ); + } else if ( object instanceof THREE.Camera ) { + gltfNode.camera = processCamera( object ); } if ( object.children.length > 0 ) {
true
Other
mrdoob
three.js
c71735635ce996c42446bc48024efa4a211e2c1d.json
Fix usage in the editor
editor/js/Menubar.File.js
@@ -204,9 +204,11 @@ Menubar.File = function ( editor ) { var exporter = new THREE.GLTFExporter(); - exporter.parse(editor.scene, function(result){ - saveString( JSON.stringify(result,null, 2), 'scene.gltf' ); - }); + exporter.parse( editor.scene, function ( result ) { + + saveString( JSON.stringify( result, null, 2 ), 'scene.gltf' ); + + } ); } );
true
Other
mrdoob
three.js
c71735635ce996c42446bc48024efa4a211e2c1d.json
Fix usage in the editor
examples/gltf_exporter.html
@@ -187,12 +187,11 @@ object.position.set( 400, 0, -200 ); scene.add( object ); */ + var gltfExporter = new THREE.GLTFExporter(); - // gltfExporter.parse(scene); - //console.log(JSON.stringify(gltfExporter.parse(scene), null, 2)); - gltfExporter.parse(scene, function(result){ - saveString( JSON.stringify(result,null, 2), 'scene.gltf' ); - }); + gltfExporter.parse( scene, function( result ) { + console.log( JSON.stringify( result, null, 2 ) ); + } ); //
true
Other
mrdoob
three.js
c71735635ce996c42446bc48024efa4a211e2c1d.json
Fix usage in the editor
examples/js/exporters/GLTFExporter.js
@@ -2,7 +2,6 @@ * @author fernandojsg / http://fernandojsg.com */ - // @TODO Should be accessible from the renderer itself instead of duplicating it here function paramThreeToGL( p ) { @@ -56,20 +55,20 @@ THREE.GLTFExporter.prototype = { constructor: THREE.GLTFExporter, - parse: function ( input, options, onDone ) { + parse: function ( input, onDone, options) { options = options || {}; var outputJSON = { asset: { version: "2.0", generator: "THREE.JS GLTFExporter" // @QUESTION Does it support spaces? } - // extensionsUsed : ['KHR_materials_common'], + // extensionsUsed : ['KHR_materials_common'], // @TODO }; var byteOffset = 0; var dataViews = []; - + /** * Get the min and he max vectors from the given attribute * @param {THREE.WebGLAttribute} attribute Attribute to find the min/max @@ -82,8 +81,8 @@ THREE.GLTFExporter.prototype = { }; for ( var i = 0; i < attribute.count; i++ ) { - for (var a = 0; a < attribute.itemSize; a++ ) { - var value = attribute.array[i * attribute.itemSize + a]; + for ( var a = 0; a < attribute.itemSize; a++ ) { + var value = attribute.array[ i * attribute.itemSize + a ]; output.min[ a ] = Math.min( output.min[ a ], value ); output.max[ a ] = Math.max( output.max[ a ], value ); } @@ -99,7 +98,7 @@ THREE.GLTFExporter.prototype = { * @return {Integer} Index of the buffer created (Currently always 0) */ function processBuffer ( attribute, componentType ) { - if (!outputJSON.buffers) { + if ( !outputJSON.buffers ) { outputJSON.buffers = [ { byteLength: 0, @@ -116,20 +115,20 @@ THREE.GLTFExporter.prototype = { for ( var i = 0; i < attribute.count; i++ ) { for (var a = 0; a < attribute.itemSize; a++ ) { - var value = attribute.array[i * attribute.itemSize + a]; - if (componentType === WebGLConstants.FLOAT) { - dataView.setFloat32(offset, value, true); - } else if (componentType === WebGLConstants.UNSIGNED_INT) { - dataView.setUint8(offset, value, true); - } else if (componentType === WebGLConstants.UNSIGNED_SHORT) { - dataView.setUint16(offset, value, true); + var value = attribute.array[ i * attribute.itemSize + a ]; + if ( componentType === WebGLConstants.FLOAT ) { + dataView.setFloat32( offset, value, true ); + } else if ( componentType === WebGLConstants.UNSIGNED_INT ) { + dataView.setUint8( offset, value, true ); + } else if ( componentType === WebGLConstants.UNSIGNED_SHORT ) { + dataView.setUint16( offset, value, true ); } offset += offsetInc; } } // We just use one buffer - dataViews.push(dataView); + dataViews.push( dataView ); return 0; } @@ -141,21 +140,21 @@ THREE.GLTFExporter.prototype = { */ function processBufferView ( data, componentType ) { var isVertexAttributes = componentType === WebGLConstants.FLOAT; - if (!outputJSON.bufferViews) { + if ( !outputJSON.bufferViews ) { outputJSON.bufferViews = []; } var gltfBufferView = { buffer: processBuffer( data, componentType ), byteOffset: byteOffset, byteLength: data.array.byteLength, - byteStride: data.itemSize * (componentType === WebGLConstants.UNSIGNED_SHORT ? 2 : 4), + byteStride: data.itemSize * ( componentType === WebGLConstants.UNSIGNED_SHORT ? 2 : 4 ), target: isVertexAttributes ? WebGLConstants.ARRAY_BUFFER : WebGLConstants.ELEMENT_ARRAY_BUFFER }; byteOffset += data.array.byteLength; - outputJSON.bufferViews.push(gltfBufferView); + outputJSON.bufferViews.push( gltfBufferView ); // @TODO Ideally we'll have just two bufferviews: 0 is for vertex attributes, 1 for indices var output = { @@ -171,7 +170,7 @@ THREE.GLTFExporter.prototype = { * @return {Integer} Index of the processed accessor on the "accessors" array */ function processAccessor ( attribute ) { - if (!outputJSON.accessors) { + if ( !outputJSON.accessors ) { outputJSON.accessors = []; } @@ -184,7 +183,7 @@ THREE.GLTFExporter.prototype = { // Detect the component type of the attribute array (float, uint or ushort) var componentType = attribute instanceof THREE.Float32BufferAttribute ? WebGLConstants.FLOAT : - (attribute instanceof THREE.Uint32BufferAttribute ? WebGLConstants.UNSIGNED_INT : WebGLConstants.UNSIGNED_SHORT); + ( attribute instanceof THREE.Uint32BufferAttribute ? WebGLConstants.UNSIGNED_INT : WebGLConstants.UNSIGNED_SHORT ); var minMax = getMinMax( attribute ); var bufferView = processBufferView( attribute, componentType ); @@ -196,7 +195,7 @@ THREE.GLTFExporter.prototype = { count: attribute.count, max: minMax.max, min: minMax.min, - type: types[ attribute.itemSize - 1] + type: types[ attribute.itemSize - 1 ] }; outputJSON.accessors.push( gltfAccessor ); @@ -210,13 +209,13 @@ THREE.GLTFExporter.prototype = { * @return {Integer} Index of the processed texture in the "images" array */ function processImage ( map ) { - if (!outputJSON.images) { + if ( !outputJSON.images ) { outputJSON.images = []; } var gltfImage = {}; - if (options.embedImages) { + if ( options.embedImages ) { // @TODO { bufferView, mimeType } } else { // @TODO base64 based on options @@ -234,15 +233,15 @@ THREE.GLTFExporter.prototype = { * @return {Integer} Index of the processed texture in the "samplers" array */ function processSampler ( map ) { - if (!outputJSON.samplers) { + if ( !outputJSON.samplers ) { outputJSON.samplers = []; } var gltfSampler = { - magFilter: paramThreeToGL(map.magFilter), - minFilter: paramThreeToGL(map.minFilter), - wrapS: paramThreeToGL(map.wrapS), - wrapT: paramThreeToGL(map.wrapT) + magFilter: paramThreeToGL( map.magFilter ), + minFilter: paramThreeToGL( map.minFilter ), + wrapS: paramThreeToGL( map.wrapS ), + wrapT: paramThreeToGL( map.wrapT ) }; outputJSON.samplers.push( gltfSampler ); @@ -261,8 +260,8 @@ THREE.GLTFExporter.prototype = { } var gltfTexture = { - sampler: processSampler(map), - source: processImage(map) + sampler: processSampler( map ), + source: processImage( map ) }; outputJSON.textures.push( gltfTexture ); @@ -349,7 +348,8 @@ THREE.GLTFExporter.prototype = { ] }; - var gltfAttributes = gltfMesh.primitives[0].attributes; + // We've just one primitive per mesh + var gltfAttributes = gltfMesh.primitives[ 0 ].attributes; var attributes = geometry.attributes; // Conversion between attributes names in threejs and gltf spec @@ -360,10 +360,10 @@ THREE.GLTFExporter.prototype = { }; // For every attribute create an accessor - for (attributeName in geometry.attributes) { + for ( attributeName in geometry.attributes ) { var attribute = geometry.attributes[ attributeName ]; - attributeName = nameConversion[attributeName] || attributeName.toUpperCase() - gltfAttributes[attributeName] = processAccessor( attribute ); + attributeName = nameConversion[ attributeName ] || attributeName.toUpperCase() + gltfAttributes[ attributeName ] = processAccessor( attribute ); } // @todo Not really necessary, isn't it? @@ -383,7 +383,7 @@ THREE.GLTFExporter.prototype = { */ function processNode ( object ) { - if (!outputJSON.nodes) { + if ( !outputJSON.nodes ) { outputJSON.nodes = []; } @@ -422,7 +422,7 @@ THREE.GLTFExporter.prototype = { * @param {THREE.Scene} node Scene to process */ function processScene( scene ) { - if (!outputJSON.scene) { + if ( !outputJSON.scene ) { outputJSON.scenes = []; outputJSON.scene = 0; } @@ -435,7 +435,7 @@ THREE.GLTFExporter.prototype = { gltfScene.name = scene.name; } - outputJSON.scenes.push(gltfScene); + outputJSON.scenes.push( gltfScene ); for ( var i = 0, l = scene.children.length; i < l; i ++ ) { var child = scene.children[ i ]; @@ -457,17 +457,19 @@ THREE.GLTFExporter.prototype = { } // Generate buffer - var blob = new Blob(dataViews, {type: 'application/octet-binary'}); - outputJSON.buffers[0].byteLength = blob.size; - objectURL = URL.createObjectURL(blob); + // Create a new blob with all the dataviews from the buffers + var blob = new Blob( dataViews, { type: 'application/octet-binary' } ); + + // Update the bytlength of the only main buffer and update the uri with the base64 representation of it + outputJSON.buffers[ 0 ].byteLength = blob.size; + objectURL = URL.createObjectURL( blob ); var reader = new window.FileReader(); - reader.readAsDataURL(blob); + reader.readAsDataURL( blob ); reader.onloadend = function() { base64data = reader.result; - outputJSON.buffers[0].uri = base64data; - console.log(JSON.stringify(outputJSON, null, 2)); - onDone(outputJSON); + outputJSON.buffers[ 0 ].uri = base64data; + onDone( outputJSON ); } } };
true
Other
mrdoob
three.js
2d115090ce2bbfb04303fcce59206d40872f6bd0.json
Update innerRadius defaults in RingGeometry docs
docs/api/geometries/RingBufferGeometry.html
@@ -44,7 +44,7 @@ <h2>Constructor</h2> <h3>[name]([page:Float innerRadius], [page:Float outerRadius], [page:Integer thetaSegments], [page:Integer phiSegments], [page:Float thetaStart], [page:Float thetaLength])</h3> <div> - innerRadius β€” Default is 0, but it doesn't work right when innerRadius is set to 0.<br /> + innerRadius β€” Default is 20. <br /> outerRadius β€” Default is 50. <br /> thetaSegments β€” Number of segments. A higher number means the ring will be more round. Minimum is 3. Default is 8. <br /> phiSegments β€” Minimum is 1. Default is 8.<br />
true
Other
mrdoob
three.js
2d115090ce2bbfb04303fcce59206d40872f6bd0.json
Update innerRadius defaults in RingGeometry docs
docs/api/geometries/RingGeometry.html
@@ -44,7 +44,7 @@ <h2>Constructor</h2> <h3>[name]([page:Float innerRadius], [page:Float outerRadius], [page:Integer thetaSegments], [page:Integer phiSegments], [page:Float thetaStart], [page:Float thetaLength])</h3> <div> - innerRadius β€” Default is 0, but it doesn't work right when innerRadius is set to 0.<br /> + innerRadius β€” Default is 20. <br /> outerRadius β€” Default is 50. <br /> thetaSegments β€” Number of segments. A higher number means the ring will be more round. Minimum is 3. Default is 8. <br /> phiSegments β€” Minimum is 1. Default is 8.<br />
true
Other
mrdoob
three.js
842cd215710551ffa753340fdf27475fc16d5ab8.json
remove unused variables
examples/js/controls/TransformControls.js
@@ -439,13 +439,6 @@ THREE.TransformGizmo.prototype.update.apply( this, arguments ); - var group = { - - handles: this[ "handles" ], - pickers: this[ "pickers" ] - - }; - var tempMatrix = new THREE.Matrix4(); var worldRotation = new THREE.Euler( 0, 0, 1 ); var tempQuaternion = new THREE.Quaternion(); @@ -623,7 +616,6 @@ var _mode = "translate"; var _dragging = false; - var _plane = "XY"; var _gizmo = { "translate": new THREE.TransformGizmoTranslate(),
false
Other
mrdoob
three.js
370b0e859821621b890b12bc8016b073d7a29789.json
convert preRotations with builtin function
examples/js/loaders/FBXLoader.js
@@ -1821,7 +1821,7 @@ if ( 'PreRotation' in node.properties ) { - var preRotations = new THREE.Euler().setFromVector3( parseVector3( node.properties.PreRotation ).multiplyScalar( Math.PI / 180 ), 'ZYX' ); + var preRotations = new THREE.Euler().fromArray( node.properties.PreRotation.value.map( THREE.Math.degToRad ), 'ZYX' ); preRotations = new THREE.Quaternion().setFromEuler( preRotations ); var currentRotation = new THREE.Quaternion().setFromEuler( model.rotation ); preRotations.multiply( currentRotation );
false
Other
mrdoob
three.js
524f3f91b03e6ed853c31903513107133501a683.json
reset example more
examples/webgl_loader_fbx.html
@@ -182,4 +182,4 @@ </script> </body> -</html> \ No newline at end of file +</html>
false
Other
mrdoob
three.js
7f79277e62ed6acd3f1feb640481f35280803de2.json
update the doc
docs/examples/renderers/CSS3DRenderer.html
@@ -16,7 +16,6 @@ <h1>[name]</h1> <ul> <li>It's not possible to use the material system of *three.js*.</li> <li>It's also not possible to use geometries.</li> - <li>Only [page:PerspectiveCamera] is supported right now.</li> </ul> So [name] is just focused on ordinary DOM elements. These elements are wrapped into special objects (*CSS3DObject* or *CSS3DSprite*) and then added to the scene graph. </div> @@ -44,6 +43,7 @@ <h2>Examples</h2> [example:css3d_panorama panorama]<br /> [example:css3d_periodictable periodictable]<br /> [example:css3d_sprites sprites]<br /> + [example:css3d_orthographic orthographic camera]<br /> </div> <h2>Constructor</h2>
false
Other
mrdoob
three.js
dc11dedc4b06760b3046191e1c5e079a3404837e.json
Revert the change of WebGLRenderer.setRenderTarget
src/renderers/WebGLRenderer.js
@@ -2436,7 +2436,7 @@ function WebGLRenderer( parameters ) { }; - this.setRenderTarget = function ( renderTarget, optType ) { + this.setRenderTarget = function ( renderTarget ) { _currentRenderTarget = renderTarget; @@ -2478,7 +2478,7 @@ function WebGLRenderer( parameters ) { if ( _currentFramebuffer !== framebuffer ) { - _gl.bindFramebuffer( optType || _gl.FRAMEBUFFER, framebuffer ); + _gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer ); _currentFramebuffer = framebuffer; }
false
Other
mrdoob
three.js
325d8e9c371332f5695e56318f0098655f38e619.json
Add webgl2 option to WebGLRenderer
src/renderers/WebGLRenderer.js
@@ -66,6 +66,7 @@ function WebGLRenderer( parameters ) { _premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true, _preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false, _powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default', + _webgl2 = parameters.webgl2 !== undefined ? parameters.webgl2 : false, _autoWebgl2 = parameters.autoWebgl2 !== undefined ? parameters.autoWebgl2 : false; var currentRenderList = null; @@ -191,7 +192,7 @@ function WebGLRenderer( parameters ) { _canvas.addEventListener( 'webglcontextlost', onContextLost, false ); _canvas.addEventListener( 'webglcontextrestored', onContextRestore, false ); - var webglVersion = _autoWebgl2 && typeof WebGL2RenderingContext !== 'undefined' ? 'webgl2' : 'webgl'; + var webglVersion = _webgl2 || ( _autoWebgl2 && typeof WebGL2RenderingContext !== 'undefined' ) ? 'webgl2' : 'webgl'; _gl = _context || _canvas.getContext( webglVersion, contextAttributes );
false
Other
mrdoob
three.js
9145b2a3411377fecef33ef2311730cfcc709a88.json
Fix a broken link in WebGLRenderer
docs/api/renderers/WebGLRenderer.html
@@ -245,7 +245,7 @@ <h3>[property:Boolean shadowMap.needsUpdate]</h3> <h3>[property:Integer shadowMap.type]</h3> <div>Defines shadow map type (unfiltered, percentage close filtering, percentage close filtering with bilinear filtering in shader)</div> - <div>Options are THREE.BasicShadowMap, THREE.PCFShadowMap (default), THREE.PCFSoftShadowMap. See [page:WebGLRenderer WebGLRenderer constants] for details.</div> + <div>Options are THREE.BasicShadowMap, THREE.PCFShadowMap (default), THREE.PCFSoftShadowMap. See [page:Renderer Renderer constants] for details.</div> <h3>[property:Boolean sortObjects]</h3> <div>
false
Other
mrdoob
three.js
d4f3a388f79123f7221e6ff08d2454c73f5d4e8e.json
Reduce memory usage
examples/js/pmrem/PMREMCubeUVPacker.js
@@ -40,13 +40,14 @@ THREE.PMREMCubeUVPacker = function ( cubeTextureLods, numLods ) { this.CubeUVRenderTarget = new THREE.WebGLRenderTarget( size, size, params ); this.CubeUVRenderTarget.texture.name = "PMREMCubeUVPacker.cubeUv"; this.CubeUVRenderTarget.texture.mapping = THREE.CubeUVReflectionMapping; - this.camera = new THREE.OrthographicCamera( - size * 0.5, size * 0.5, - size * 0.5, size * 0.5, 0.0, 1000 ); + this.camera = new THREE.OrthographicCamera( - size * 0.5, size * 0.5, - size * 0.5, size * 0.5, 0, 1 ); // top and bottom are swapped for some reason? this.scene = new THREE.Scene(); - this.scene.add( this.camera ); this.objects = []; + var geometry = new THREE.PlaneBufferGeometry( 1, 1 ); + var faceOffsets = []; faceOffsets.push( new THREE.Vector2( 0, 0 ) ); faceOffsets.push( new THREE.Vector2( 1, 0 ) ); @@ -81,12 +82,12 @@ THREE.PMREMCubeUVPacker = function ( cubeTextureLods, numLods ) { material.envMap = this.cubeLods[ i ].texture; material.uniforms[ 'faceIndex' ].value = k; material.uniforms[ 'mapSize' ].value = mipSize; - var planeMesh = new THREE.Mesh( - new THREE.PlaneGeometry( mipSize, mipSize, 0 ), - material ); + + var planeMesh = new THREE.Mesh( geometry, material ); planeMesh.position.x = faceOffsets[ k ].x * mipSize - offset1 + mipOffsetX; planeMesh.position.y = faceOffsets[ k ].y * mipSize - offset1 + offset2 + mipOffsetY; - planeMesh.material.side = THREE.DoubleSide; + planeMesh.material.side = THREE.BackSide; + planeMesh.scale.set( mipSize, mipSize ); this.scene.add( planeMesh ); this.objects.push( planeMesh );
false
Other
mrdoob
three.js
3f0dfd9f1f78af1f3be23c61cd3d4ec8574560dd.json
Add webgl2 to Detector
examples/js/Detector.js
@@ -18,6 +18,19 @@ var Detector = { } + } )(), + webgl2: ( function () { + + try { + + var canvas = document.createElement( 'canvas' ); return !! ( window.WebGL2RenderingContext && ( canvas.getContext( 'webgl2' ) ) ); + + } catch ( e ) { + + return false; + + } + } )(), workers: !! window.Worker, fileapi: window.File && window.FileReader && window.FileList && window.Blob,
false
Other
mrdoob
three.js
5219c0f1207c67495c146fe36f90c9b224801f85.json
Save isWebGL2 to WebGL context object
src/renderers/WebGLRenderer.js
@@ -211,6 +211,8 @@ function WebGLRenderer( parameters ) { } + _gl.isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext; + // Some experimental-webgl implementations do not have getShaderPrecisionFormat if ( _gl.getShaderPrecisionFormat === undefined ) {
true
Other
mrdoob
three.js
5219c0f1207c67495c146fe36f90c9b224801f85.json
Save isWebGL2 to WebGL context object
src/renderers/webgl/WebGLBufferRenderer.js
@@ -4,8 +4,6 @@ function WebGLBufferRenderer( gl, extensions, info ) { - var isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext; - var mode; function setMode( value ) { @@ -39,11 +37,11 @@ function WebGLBufferRenderer( gl, extensions, info ) { count = position.data.count; - extension[ isWebGL2 ? 'drawArraysInstanced' : 'drawArraysInstancedANGLE' ]( mode, 0, count, geometry.maxInstancedCount ); + extension[ gl.isWebGL2 ? 'drawArraysInstanced' : 'drawArraysInstancedANGLE' ]( mode, 0, count, geometry.maxInstancedCount ); } else { - extension[ isWebGL2 ? 'drawArraysInstanced' : 'drawArraysInstancedANGLE' ]( mode, start, count, geometry.maxInstancedCount ); + extension[ gl.isWebGL2 ? 'drawArraysInstanced' : 'drawArraysInstancedANGLE' ]( mode, start, count, geometry.maxInstancedCount ); }
true
Other
mrdoob
three.js
5219c0f1207c67495c146fe36f90c9b224801f85.json
Save isWebGL2 to WebGL context object
src/renderers/webgl/WebGLExtensions.js
@@ -6,8 +6,6 @@ function WebGLExtensions( gl ) { var extensions = {}; - var isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ); - return { get: function ( name ) { @@ -24,7 +22,7 @@ function WebGLExtensions( gl ) { case 'WEBGL_depth_texture': - if ( isWebGL2 ) { + if ( gl.isWebGL2 ) { extension = gl; @@ -54,7 +52,7 @@ function WebGLExtensions( gl ) { default: - if ( isWebGL2 && + if ( gl.isWebGL2 && [ 'ANGLE_instanced_arrays', 'OES_texture_float', 'OES_texture_half_float',
true
Other
mrdoob
three.js
5219c0f1207c67495c146fe36f90c9b224801f85.json
Save isWebGL2 to WebGL context object
src/renderers/webgl/WebGLIndexedBufferRenderer.js
@@ -4,8 +4,6 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) { - var isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext; - var mode; function setMode( value ) { @@ -42,7 +40,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) { } - extension[ isWebGL2 ? 'drawElementsInstanced' : 'drawElementsInstancedANGLE' ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount ); + extension[ gl.isWebGL2 ? 'drawElementsInstanced' : 'drawElementsInstancedANGLE' ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount ); info.update( count, mode, geometry.maxInstancedCount );
true
Other
mrdoob
three.js
5219c0f1207c67495c146fe36f90c9b224801f85.json
Save isWebGL2 to WebGL context object
src/renderers/webgl/WebGLProgram.js
@@ -206,8 +206,6 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters var gl = renderer.context; - var isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext; - var defines = material.defines; var vertexShader = shader.vertexShader; @@ -287,7 +285,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters // - var customExtensions = isWebGL2 ? '' : generateExtensions( material.extensions, parameters, extensions ); + var customExtensions = gl.isWebGL2 ? '' : generateExtensions( material.extensions, parameters, extensions ); var customDefines = generateDefines( defines ); @@ -516,7 +514,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters vertexShader = unrollLoops( vertexShader ); fragmentShader = unrollLoops( fragmentShader ); - if ( isWebGL2 && ! material.isRawShaderMaterial ) { + if ( gl.isWebGL2 && ! material.isRawShaderMaterial ) { var isGLSL3ShaderMaterial = material.isShaderMaterial && material.isGLSL3;
true
Other
mrdoob
three.js
5219c0f1207c67495c146fe36f90c9b224801f85.json
Save isWebGL2 to WebGL context object
src/renderers/webgl/WebGLState.js
@@ -7,8 +7,6 @@ import { Vector4 } from '../../math/Vector4.js'; function WebGLState( gl, extensions, utils ) { - var isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext; - function ColorBuffer() { var locked = false; @@ -432,7 +430,7 @@ function WebGLState( gl, extensions, utils ) { var extension = extensions.get( 'ANGLE_instanced_arrays' ); - extension[ isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, 0 ); + extension[ gl.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, 0 ); attributeDivisors[ attribute ] = 0; } @@ -454,7 +452,7 @@ function WebGLState( gl, extensions, utils ) { var extension = extensions.get( 'ANGLE_instanced_arrays' ); - extension[ isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute ); + extension[ gl.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute ); attributeDivisors[ attribute ] = meshPerAttribute; }
true
Other
mrdoob
three.js
5219c0f1207c67495c146fe36f90c9b224801f85.json
Save isWebGL2 to WebGL context object
src/renderers/webgl/WebGLTextures.js
@@ -7,7 +7,6 @@ import { _Math } from '../../math/Math.js'; function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) { - var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext ); /* global WebGL2RenderingContext */ var _videoTextures = {}; var _canvas; @@ -76,7 +75,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, function textureNeedsPowerOfTwo( texture ) { - if ( _isWebGL2 ) return false; + if ( _gl.isWebGL2 ) return false; return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) || ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ); @@ -101,7 +100,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, function getInternalFormat( glFormat, glType ) { - if ( ! _isWebGL2 ) return glFormat; + if ( ! _gl.isWebGL2 ) return glFormat; if ( glFormat === _gl.RGB ) { @@ -505,10 +504,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( texture.type === FloatType ) { - if ( ! _isWebGL2 ) throw new Error( 'Float Depth Texture only supported in WebGL2.0' ); + if ( ! _gl.isWebGL2 ) throw new Error( 'Float Depth Texture only supported in WebGL2.0' ); glInternalFormat = _gl.DEPTH_COMPONENT32F; - } else if ( _isWebGL2 ) { + } else if ( _gl.isWebGL2 ) { // WebGL 2.0 requires signed internalformat for glTexImage2D glInternalFormat = _gl.DEPTH_COMPONENT16; @@ -655,7 +654,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, var glFormat = utils.convert( renderTarget.texture.format ); var glType = utils.convert( renderTarget.texture.type ); var glInternalFormat = getInternalFormat( glFormat, glType ); - var array = ( _isWebGL2 ) ? new Uint8Array( renderTarget.width * renderTarget.height * 4 ) : null; + var array = ( _gl.isWebGL2 ) ? new Uint8Array( renderTarget.width * renderTarget.height * 4 ) : null; state.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, array ); _gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer ); _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );
true
Other
mrdoob
three.js
5219c0f1207c67495c146fe36f90c9b224801f85.json
Save isWebGL2 to WebGL context object
src/renderers/webgl/WebGLUtils.js
@@ -6,8 +6,6 @@ import { MaxEquation, MinEquation, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, R function WebGLUtils( gl, extensions ) { - var isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ); - function convert( p ) { var extension; @@ -38,7 +36,7 @@ function WebGLUtils( gl, extensions ) { if ( p === HalfFloatType ) { - if ( isWebGL2 ) return gl.HALF_FLOAT; + if ( gl.isWebGL2 ) return gl.HALF_FLOAT; extension = extensions.get( 'OES_texture_half_float' ); @@ -129,7 +127,7 @@ function WebGLUtils( gl, extensions ) { if ( p === MinEquation || p === MaxEquation ) { - if ( isWebGL2 ) { + if ( gl.isWebGL2 ) { if ( p === MinEquation ) return gl.MIN; if ( p === MaxEquation ) return gl.MAX; @@ -149,7 +147,7 @@ function WebGLUtils( gl, extensions ) { if ( p === UnsignedInt248Type ) { - if ( isWebGL2 ) return gl.UNSIGNED_INT_24_8; + if ( gl.isWebGL2 ) return gl.UNSIGNED_INT_24_8; extension = extensions.get( 'WEBGL_depth_texture' );
true
Other
mrdoob
three.js
4ec384f36981a9e5e4b4104f5e3e729be9123a60.json
Remove trailing space
src/renderers/webgl/WebGLExtensions.js
@@ -54,7 +54,7 @@ function WebGLExtensions( gl ) { default: - if ( isWebGL2 && + if ( isWebGL2 && [ 'ANGLE_instanced_arrays', 'OES_texture_float', 'OES_texture_half_float',
false
Other
mrdoob
three.js
ddc4893e3951c91f0120158bd44079fbacb92d56.json
Enable webgl2_sandbox example
examples/files.js
@@ -303,11 +303,9 @@ var files = { "webgl deferred": [ "webgldeferred_animation" ], - /* "webgl2": [ "webgl2_sandbox" ], - */ "webaudio": [ "webaudio_sandbox", "webaudio_timing",
true
Other
mrdoob
three.js
ddc4893e3951c91f0120158bd44079fbacb92d56.json
Enable webgl2_sandbox example
examples/webgl2_sandbox.html
@@ -34,17 +34,8 @@ <body> <div id="info"><a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - webgl2 sandbox.</div> - <script type="module"> - - import { PerspectiveCamera } from '../src/cameras/PerspectiveCamera.js'; - import { SphereBufferGeometry } from '../src/geometries/SphereGeometry.js'; - import { MeshNormalMaterial } from '../src/materials/MeshNormalMaterial.js'; - import { PointLight } from '../src/lights/PointLight.js'; - import { Color } from '../src/math/Color.js'; - import { Mesh } from '../src/objects/Mesh.js'; - import { Fog } from '../src/scenes/Fog.js'; - import { Scene } from '../src/scenes/Scene.js'; - import { WebGL2Renderer } from '../src/renderers/WebGL2Renderer.js'; + <script src="../build/three.js"></script> + <script> // @@ -60,22 +51,22 @@ function init() { - camera = new PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 20000 ); + camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 20000 ); camera.position.z = 3200; - scene = new Scene(); - scene.background = new Color( 0, 0, 0.5 ); - scene.fog = new Fog( 0x000000, 1, 20000 ); + scene = new THREE.Scene(); + scene.background = new THREE.Color( 0, 0, 0.5 ); + scene.fog = new THREE.Fog( 0x000000, 1, 20000 ); - var light = new PointLight( 0xffffff ); + var light = new THREE.PointLight( 0xffffff ); scene.add( light ); - var geometry = new SphereBufferGeometry( 50, 32, 16 ); - var material = new MeshNormalMaterial(); + var geometry = new THREE.SphereBufferGeometry( 50, 32, 16 ); + var material = new THREE.MeshNormalMaterial(); for ( var i = 0; i < 5000; i ++ ) { - var mesh = new Mesh( geometry, material ); + var mesh = new THREE.Mesh( geometry, material ); mesh.position.x = Math.random() * 10000 - 5000; mesh.position.y = Math.random() * 10000 - 5000; @@ -89,7 +80,7 @@ } - renderer = new WebGL2Renderer(); + renderer = new THREE.WebGLRenderer( { webgl2: true } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement );
true
Other
mrdoob
three.js
f069efb0d79b7b9adadc30005d7c832543a68db5.json
Fix cinematic camera example
examples/js/cameras/CinematicCamera.js
@@ -151,7 +151,8 @@ THREE.CinematicCamera.prototype.initPostProcessing = function () { fragmentShader: bokeh_shader.fragmentShader, defines: { RINGS: this.shaderSettings.rings, - SAMPLES: this.shaderSettings.samples + SAMPLES: this.shaderSettings.samples, + DEPTH_PACKING: this.material_depth.depthPacking } } );
false
Other
mrdoob
three.js
51dad3fe3899b3d463b3d6f765a4412833c618f3.json
Fix HalfFloatType bug in WebGLUtils
src/renderers/webgl/WebGLUtils.js
@@ -38,9 +38,11 @@ function WebGLUtils( gl, extensions ) { if ( p === HalfFloatType ) { + if ( isWebGL2 ) return gl.HALF_FLOAT; + extension = extensions.get( 'OES_texture_half_float' ); - return isWebGL2 ? gl.HALF_FLOAT : extension.HALF_FLOAT_OES; + if ( extension !== null ) return extension.HALF_FLOAT_OES; }
false
Other
mrdoob
three.js
89c1738ac98a96bfdfdb299c5ec85f464a6a8889.json
Update WebGLTextures for gl.RGB
src/renderers/webgl/WebGLTextures.js
@@ -101,8 +101,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( ! _isWebGL2 ) return glFormat; - if ( glFormat === _gl.RGBA && glType === _gl.FLOAT ) return _gl.RGBA32F; - if ( glFormat === _gl.RGBA && glType === _gl.HALF_FLOAT ) return _gl.RGBA16F; + if ( glFormat === _gl.RGB || glFormat === _gl.RGBA ) { + + if ( glType === _gl.FLOAT ) return _gl.RGBA32F; + if ( glType === _gl.HALF_FLOAT ) return _gl.RGBA16F; + + } return glFormat;
false
Other
mrdoob
three.js
cda93373717896d805eaceffb277a0c8d7357cb5.json
Add test/unit/three.*.unit.js to .gitignore
.gitignore
@@ -7,3 +7,4 @@ node_modules npm-debug.log .jshintrc .vs/ +test/unit/three.*.unit.js
false
Other
mrdoob
three.js
667bd407af6b7b1142137f8098b9e99eb8e35964.json
move empty callbacks to prototype
src/core/InterleavedBuffer.js
@@ -12,8 +12,6 @@ function InterleavedBuffer( array, stride ) { this.dynamic = false; this.updateRange = { offset: 0, count: - 1 }; - this.onUploadCallback = function () {}; - this.version = 0; } @@ -32,6 +30,8 @@ Object.assign( InterleavedBuffer.prototype, { isInterleavedBuffer: true, + onUploadCallback: function () {}, + setArray: function ( array ) { if ( Array.isArray( array ) ) {
true
Other
mrdoob
three.js
667bd407af6b7b1142137f8098b9e99eb8e35964.json
move empty callbacks to prototype
src/loaders/Loader.js
@@ -24,13 +24,7 @@ import { Color } from '../math/Color.js'; * @author alteredq / http://alteredqualia.com/ */ -function Loader() { - - this.onLoadStart = function () {}; - this.onLoadProgress = function () {}; - this.onLoadComplete = function () {}; - -} +function Loader() {} Loader.Handlers = { @@ -69,6 +63,12 @@ Object.assign( Loader.prototype, { crossOrigin: undefined, + onLoadStart: function () {}, + + onLoadProgress: function () {}, + + onLoadComplete: function () {}, + initMaterials: function ( materials, texturePath, crossOrigin ) { var array = [];
true
Other
mrdoob
three.js
366450a2e98642a1bb8362eee4dcc9ae9743b27c.json
remove uuid from BufferAttribute etc.
src/core/BufferAttribute.js
@@ -2,7 +2,6 @@ import { Vector4 } from '../math/Vector4.js'; import { Vector3 } from '../math/Vector3.js'; import { Vector2 } from '../math/Vector2.js'; import { Color } from '../math/Color.js'; -import { _Math } from '../math/Math.js'; /** * @author mrdoob / http://mrdoob.com/ @@ -16,7 +15,6 @@ function BufferAttribute( array, itemSize, normalized ) { } - this.uuid = _Math.generateUUID(); this.name = ''; this.array = array;
true
Other
mrdoob
three.js
366450a2e98642a1bb8362eee4dcc9ae9743b27c.json
remove uuid from BufferAttribute etc.
src/core/InterleavedBuffer.js
@@ -1,13 +1,10 @@ -import { _Math } from '../math/Math.js'; /** * @author benaadams / https://twitter.com/ben_a_adams */ function InterleavedBuffer( array, stride ) { - this.uuid = _Math.generateUUID(); - this.array = array; this.stride = stride; this.count = array !== undefined ? array.length / stride : 0;
true
Other
mrdoob
three.js
366450a2e98642a1bb8362eee4dcc9ae9743b27c.json
remove uuid from BufferAttribute etc.
src/core/InterleavedBufferAttribute.js
@@ -1,13 +1,10 @@ -import { _Math } from '../math/Math.js'; /** * @author benaadams / https://twitter.com/ben_a_adams */ function InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, normalized ) { - this.uuid = _Math.generateUUID(); - this.data = interleavedBuffer; this.itemSize = itemSize; this.offset = offset;
true
Other
mrdoob
three.js
01cae4ee609016d45e2842595502fa28331fd5d0.json
remove uuid from WebGLRenderTarget
src/renderers/WebGLRenderTarget.js
@@ -2,7 +2,6 @@ import { EventDispatcher } from '../core/EventDispatcher.js'; import { Texture } from '../textures/Texture.js'; import { LinearFilter } from '../constants.js'; import { Vector4 } from '../math/Vector4.js'; -import { _Math } from '../math/Math.js'; /** * @author szimek / https://github.com/szimek/ @@ -17,8 +16,6 @@ import { _Math } from '../math/Math.js'; */ function WebGLRenderTarget( width, height, options ) { - this.uuid = _Math.generateUUID(); - this.width = width; this.height = height;
false
Other
mrdoob
three.js
775c192b588bb4c6a3cd5b5b127346135af34c8f.json
Update Vector3.html to be in alphabetical order. "N" comes after "M"
docs/api/math/Vector3.html
@@ -273,15 +273,6 @@ <h3>[method:Vector3 lerpVectors]( [param:Vector3 v1], [param:Vector3 v2], [param - alpha = 0 will be [page:Vector3 v1], and alpha = 1 will be [page:Vector3 v2]. </div> - <h3>[method:Vector3 negate]()</h3> - <div>Inverts this vector - i.e. sets x = -x, y = -y and z = -z.</div> - - <h3>[method:Vector3 normalize]()</h3> - <div> - Convert this vector to a [link:https://en.wikipedia.org/wiki/Unit_vector unit vector] - that is, sets it equal to the vector with the same direction - as this one, but [page:.length length] 1. - </div> - <h3>[method:Vector3 max]( [param:Vector3 v] )</h3> <div> If this vector's x, y or z value is less than [page:Vector3 v]'s x, y or z value, replace @@ -303,6 +294,15 @@ <h3>[method:Vector3 multiplyScalar]( [param:Float s] )</h3> <h3>[method:Vector3 multiplyVectors]( [param:Vector3 a], [param:Vector3 b] )</h3> <div>Sets this vector equal to [page:Vector3 a] * [page:Vector3 b], component-wise.</div> + <h3>[method:Vector3 negate]()</h3> + <div>Inverts this vector - i.e. sets x = -x, y = -y and z = -z.</div> + + <h3>[method:Vector3 normalize]()</h3> + <div> + Convert this vector to a [link:https://en.wikipedia.org/wiki/Unit_vector unit vector] - that is, sets it equal to the vector with the same direction + as this one, but [page:.length length] 1. + </div> + <h3>[method:Vector3 project]( [param:Camera camera] )</h3> <div> [page:Camera camera] β€” camera to use in the projection.<br /><br />
false
Other
mrdoob
three.js
b9d316dfe8bec5f0a009f4a0b4a63d312082b523.json
Add physicallyCorrectLights = true
examples/webgl_loader_gltf_extensions.html
@@ -174,6 +174,7 @@ renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.gammaOutput = true; + renderer.physicallyCorrectLights = true; if (sceneInfo.shadows) { renderer.shadowMap.enabled = true;
false
Other
mrdoob
three.js
090ce2f6d60d66efd947f371b6ac239d6ca1dc76.json
add special case for uInt8Array for extra speed
examples/js/loaders/EXRLoader.js
@@ -134,9 +134,9 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { } } - function getBits(nBits, c, lc, inDataView, inOffset) { + function getBits(nBits, c, lc, uInt8Array, inOffset) { while (lc < nBits) { - c = (c << 8) | parseUint8(inDataView, inOffset); + c = (c << 8) | parseUint8Array(uInt8Array, inOffset); lc += 8; } @@ -167,7 +167,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { } } - function hufUnpackEncTable(inDataView, inOffset, ni, im, iM, hcode) { + function hufUnpackEncTable(uInt8Array, inDataView, inOffset, ni, im, iM, hcode) { var p = inOffset; var c = 0; var lc = 0; @@ -177,7 +177,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { return false; } - var bits = getBits(6, c, lc, inDataView, p); + var bits = getBits(6, c, lc, uInt8Array, p); var l = bits.l; c = bits.c; lc = bits.lc; @@ -188,7 +188,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { throw 'Something wrong with hufUnpackEncTable'; } - var bits = getBits(8, c, lc, inDataView, p); + var bits = getBits(8, c, lc, uInt8Array, p); var zerun = bits.l + SHORTEST_LONG_RUN; c = bits.c; lc = bits.lc; @@ -271,17 +271,17 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { return true; } - function getChar(c, lc, inDataView, inOffset) { - c = (c << 8) | parseUint8(inDataView, inOffset); + function getChar(c, lc, uInt8Array, inOffset) { + c = (c << 8) | parseUint8Array(uInt8Array, inOffset); lc += 8; return { c: c, lc: lc }; } - function getCode(po, rlc, c, lc, inDataView, inOffset, outBuffer, outBufferOffset, outBufferEndOffset) { + function getCode(po, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outBufferOffset, outBufferEndOffset) { if (po == rlc) { if (lc < 8) { - var temp = getChar(c, lc, inDataView, inOffset); + var temp = getChar(c, lc, uInt8Array, inOffset); c = temp.c; lc = temp.lc; } @@ -414,14 +414,14 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { return py; } - function hufDecode(encodingTable, decodingTable, inDataView, inOffset, ni, rlc, no, outBuffer, outOffset) { + function hufDecode(encodingTable, decodingTable, uInt8Array, inDataView, inOffset, ni, rlc, no, outBuffer, outOffset) { var c = 0; var lc = 0; var outBufferEndOffset = no; var inOffsetEnd = parseInt(inOffset.value + (ni + 7) / 8); while (inOffset.value < inOffsetEnd) { - var temp = getChar(c, lc, inDataView, inOffset); + var temp = getChar(c, lc, uInt8Array, inOffset); c = temp.c; lc = temp.lc; @@ -431,7 +431,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { if (pl.len) { lc -= pl.len; - var temp = getCode(pl.lit, rlc, c, lc, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset); + var temp = getCode(pl.lit, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset); c = temp.c; lc = temp.lc; } else { @@ -445,7 +445,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { var l = hufLength(encodingTable[pl.p[j]]); while (lc < l && inOffset.value < inOffsetEnd) { - var temp = getChar(c, lc, inDataView, inOffset); + var temp = getChar(c, lc, uInt8Array, inOffset); c = temp.c; lc = temp.lc; } @@ -455,7 +455,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { ((c >> (lc - l)) & ((1 << l) - 1))) { lc -= l; - var temp = getCode(pl.p[j], rlc, c, lc, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset); + var temp = getCode(pl.p[j], rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset); c = temp.c; lc = temp.lc; break; @@ -479,7 +479,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { if (pl.len) { lc -= pl.len; - var temp = getCode(pl.lit, rlc, c, lc, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset); + var temp = getCode(pl.lit, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset); c = temp.c; lc = temp.lc; } else { @@ -490,7 +490,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { return true; } - function hufUncompress(inDataView, inOffset, nCompressed, outBuffer, outOffset, nRaw) { + function hufUncompress(uInt8Array, inDataView, inOffset, nCompressed, outBuffer, outOffset, nRaw) { var initialInOffset = inOffset.value; var im = parseUint32(inDataView, inOffset); @@ -510,15 +510,15 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { var ni = nCompressed - (inOffset.value - initialInOffset); - hufUnpackEncTable(inDataView, inOffset, ni, im, iM, freq); + hufUnpackEncTable(uInt8Array, inDataView, inOffset, ni, im, iM, freq); if (nBits > 8 * (nCompressed - (inOffset.value - initialInOffset))) { throw 'Something wrong with hufUncompress'; } hufBuildDecTable(freq, im, iM, hdec); - hufDecode(freq, hdec, inDataView, inOffset, nBits, iM, nRaw, outBuffer, outOffset); + hufDecode(freq, hdec, uInt8Array, inDataView, inOffset, nBits, iM, nRaw, outBuffer, outOffset); } function applyLut(lut, data, nData) { @@ -527,7 +527,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { } } - function decompressPIZ(outBuffer, outOffset, inDataView, inOffset, tmpBufSize, num_channels, exrChannelInfos, dataWidth, num_lines) { + function decompressPIZ(outBuffer, outOffset, uInt8Array, inDataView, inOffset, tmpBufSize, num_channels, exrChannelInfos, dataWidth, num_lines) { var bitmap = new Uint8Array(BITMAP_SIZE); var minNonZero = parseUint16(inDataView, inOffset); @@ -548,7 +548,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { var length = parseUint32(inDataView, inOffset); - hufUncompress(inDataView, inOffset, length, outBuffer, outOffset, tmpBufSize); + hufUncompress(uInt8Array, inDataView, inOffset, length, outBuffer, outOffset, tmpBufSize); var pizChannelData = new Array(num_channels); @@ -643,6 +643,16 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { } + function parseUint8Array( uInt8Array, offset ) { + + var Uint8 = uInt8Array[offset.value]; + + offset.value = offset.value + INT8_SIZE; + + return Uint8; + + } + function parseUint8( dataView, offset ) { var Uint8 = dataView.getUint8(offset.value); @@ -833,6 +843,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { } var bufferDataView = new DataView(buffer); + var uInt8Array = new Uint8Array(buffer); var EXRHeader = {}; @@ -937,9 +948,9 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { var tmpBufferSize = width * scanlineBlockSize * (EXRHeader.channels.length * BYTES_PER_HALF); var tmpBuffer = new Uint16Array(tmpBufferSize); - var tmpOffset = { value: 0 }; + var tmpOffset = { value: 0 }; - decompressPIZ(tmpBuffer, tmpOffset, bufferDataView, offset, tmpBufferSize, numChannels, EXRHeader.channels, width, scanlineBlockSize); + decompressPIZ(tmpBuffer, tmpOffset, uInt8Array, bufferDataView, offset, tmpBufferSize, numChannels, EXRHeader.channels, width, scanlineBlockSize); for ( var line_y = 0; line_y < scanlineBlockSize; line_y ++ ) {
false
Other
mrdoob
three.js
552d0ed3ffcb75d639ac334d95b19da4058babc1.json
cache new DataView to increase performance
examples/js/loaders/EXRLoader.js
@@ -262,17 +262,17 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { return true; } - function getChar(c, lc, inBuffer, inOffset) { - c = (c << 8) | parseUint8(inBuffer, inOffset); + function getChar(c, lc, inDataView, inOffset) { + c = (c << 8) | parseUint8DataView(inDataView, inOffset); lc += 8; return { c: c, lc: lc }; } - function getCode(po, rlc, c, lc, inBuffer, inOffset, outBuffer, outBufferOffset, outBufferEndOffset) { + function getCode(po, rlc, c, lc, inDataView, inOffset, outBuffer, outBufferOffset, outBufferEndOffset) { if (po == rlc) { if (lc < 8) { - var temp = getChar(c, lc, inBuffer, inOffset); + var temp = getChar(c, lc, inDataView, inOffset); c = temp.c; lc = temp.lc; } @@ -304,9 +304,18 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { var M_OFFSET = 1 << (NBITS - 1); var MOD_MASK = (1 << NBITS) - 1; + function UInt16(value) { + return (value & 0xFFFF); + }; + + function Int16(value) { + var ref = UInt16(value); + return (ref > 0x7FFF) ? ref - 0x10000 : ref; + }; + function wdec14(l, h) { - var ls = (new Int16Array([l]))[0]; - var hs = (new Int16Array([h]))[0]; + var ls = Int16(l); + var hs = Int16(h); var hi = hs; var ai = ls + (hi & 1) + (hi >> 1); @@ -402,8 +411,10 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { var outBufferEndOffset = no; var inOffsetEnd = parseInt(inOffset.value + (ni + 7) / 8); + var dataView = new DataView(inBuffer); + while (inOffset.value < inOffsetEnd) { - var temp = getChar(c, lc, inBuffer, inOffset); + var temp = getChar(c, lc, dataView, inOffset); c = temp.c; lc = temp.lc; @@ -413,7 +424,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { if (pl.len) { lc -= pl.len; - var temp = getCode(pl.lit, rlc, c, lc, inBuffer, inOffset, outBuffer, outOffset, outBufferEndOffset); + var temp = getCode(pl.lit, rlc, c, lc, dataView, inOffset, outBuffer, outOffset, outBufferEndOffset); c = temp.c; lc = temp.lc; } else { @@ -427,7 +438,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { var l = hufLength(encodingTable[pl.p[j]]); while (lc < l && inOffset.value < inOffsetEnd) { - var temp = getChar(c, lc, inBuffer, inOffset); + var temp = getChar(c, lc, dataView, inOffset); c = temp.c; lc = temp.lc; } @@ -437,7 +448,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { ((c >> (lc - l)) & ((1 << l) - 1))) { lc -= l; - var temp = getCode(pl.p[j], rlc, c, lc, inBuffer, inOffset, outBuffer, outOffset, outBufferEndOffset); + var temp = getCode(pl.p[j], rlc, c, lc, dataView, inOffset, outBuffer, outOffset, outBufferEndOffset); c = temp.c; lc = temp.lc; break; @@ -461,7 +472,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { if (pl.len) { lc -= pl.len; - var temp = getCode(pl.lit, rlc, c, lc, inBuffer, inOffset, outBuffer, outOffset, outBufferEndOffset); + var temp = getCode(pl.lit, rlc, c, lc, dataView, inOffset, outBuffer, outOffset, outBufferEndOffset); c = temp.c; lc = temp.lc; } else { @@ -501,13 +512,13 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { hufBuildDecTable(freq, im, iM, hdec); hufDecode(freq, hdec, inBuffer, inOffset, nBits, iM, nRaw, outBuffer, outOffset); - } + } - function applyLut(lut, data, nData) { - for (var i = 0; i < nData; ++i) { - data[i] = lut[data[i]]; - } + function applyLut(lut, data, nData) { + for (var i = 0; i < nData; ++i) { + data[i] = lut[data[i]]; } + } function decompressPIZ(outBuffer, outOffset, inBuffer, inOffset, tmpBufSize, num_channels, exrChannelInfos, dataWidth, num_lines) { var bitmap = new Uint8Array(BITMAP_SIZE); @@ -625,6 +636,15 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { } + function parseUint8DataView( dataView, offset ) { + + var Uint8 = dataView.getUint8(offset.value, true); + + offset.value = offset.value + 1; + + return Uint8; + } + function parseUint8( buffer, offset ) { var Uint8 = new DataView( buffer.slice( offset.value, offset.value + 1 ) ).getUint8( 0, true ); @@ -885,13 +905,14 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { for ( var channelID = 0; channelID < EXRHeader.channels.length; channelID ++ ) { + var cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ]; + if ( EXRHeader.channels[ channelID ].pixelType == 1 ) { // HALF for ( var x = 0; x < width; x ++ ) { var val = parseFloat16( buffer, offset ); - var cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ]; byteArray[ ( ( ( width - y_scanline ) * ( height * numChannels ) ) + ( x * numChannels ) ) + cOff ] = val; @@ -924,12 +945,13 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) { for ( var channelID = 0; channelID < EXRHeader.channels.length; channelID ++ ) { + var cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ]; + if ( EXRHeader.channels[ channelID ].pixelType == 1 ) { // HALF for ( var x = 0; x < width; x ++ ) { - var cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ]; var val = decodeFloat16(tmpBuffer[ (channelID * (scanlineBlockSize * width)) + (line_y * width) + x ]); var true_y = line_y + (scanlineBlockIdx * scanlineBlockSize);
false
Other
mrdoob
three.js
a4b8c30be485b4ff661c60151f84ecb57e441227.json
add renderer prop in onBeforeCompile
src/renderers/WebGLRenderer.js
@@ -1522,7 +1522,8 @@ function WebGLRenderer( parameters ) { name: material.type, uniforms: UniformsUtils.clone( shader.uniforms ), vertexShader: shader.vertexShader, - fragmentShader: shader.fragmentShader + fragmentShader: shader.fragmentShader, + renderer: _this }; } else { @@ -1531,7 +1532,8 @@ function WebGLRenderer( parameters ) { name: material.type, uniforms: material.uniforms, vertexShader: material.vertexShader, - fragmentShader: material.fragmentShader + fragmentShader: material.fragmentShader, + renderer: _this }; }
false
Other
mrdoob
three.js
e03835d1f2ad4eedeada071fd57aa2ce6e9e487d.json
fix normal_fragment_* examples
examples/js/nodes/materials/PhongNode.js
@@ -152,7 +152,7 @@ THREE.PhongNode.prototype.build = function ( builder ) { var output = [ // prevent undeclared normal - "#include <normal_fragment>", + "#include <normal_fragment_begin>", // prevent undeclared material " BlinnPhongMaterial material;",
true
Other
mrdoob
three.js
e03835d1f2ad4eedeada071fd57aa2ce6e9e487d.json
fix normal_fragment_* examples
examples/js/nodes/materials/StandardNode.js
@@ -191,7 +191,7 @@ THREE.StandardNode.prototype.build = function ( builder ) { var output = [ // prevent undeclared normal - " #include <normal_fragment>", + " #include <normal_fragment_begin>", // prevent undeclared material " PhysicalMaterial material;",
true
Other
mrdoob
three.js
e9c7f2d74d66e785337b72e95ad90b485b68231f.json
Update GLTFLoader doc for Draco
docs/examples/loaders/GLTFLoader.html
@@ -49,7 +49,7 @@ <h2>Example</h2> var loader = new THREE.GLTFLoader(); // Optional: Provide a DRACOLoader instance to decode compressed mesh data - THREE.DRACOLoader.setDecoderPath( '/examples/js/loaders/draco' ); + THREE.DRACOLoader.setDecoderPath( '/examples/js/libs/draco' ); loader.setDRACOLoader( new THREE.DRACOLoader() ); // Load a glTF resource @@ -137,6 +137,9 @@ <h3>[method:null setDRACOLoader]( [param:DRACOLoader dracoLoader] )</h3> <div> [page:DRACOLoader dracoLoader] β€” Instance of THREE.DRACOLoader, to be used for decoding assets compressed with the KHR_draco_mesh_compression extension. </div> + <div> + Refer to this [link:https://github.com/mrdoob/three.js/tree/dev/examples/js/libs/draco#readme page] for the details of Draco and its decoder. + </div> <h3>[method:null parse]( [param:ArrayBuffer data], [param:String path], [param:Function onLoad], [param:Function onError] )</h3> <div>
false
Other
mrdoob
three.js
19456c6b7e939b32f2953efe9687bdd98dbc6f74.json
Add description of .asset into GLTFLoader doc
docs/examples/loaders/GLTFLoader.html
@@ -65,6 +65,7 @@ <h2>Example</h2> gltf.scene; // THREE.Scene gltf.scenes; // Array&lt;THREE.Scene&gt; gltf.cameras; // Array&lt;THREE.Camera&gt; + gltf.asset; // Object }, // called when loading is in progresses @@ -146,7 +147,7 @@ <h3>[method:null parse]( [param:ArrayBuffer data], [param:String path], [param:F [page:Function onError] β€” (optional) A function to be called if an error occurs during parsing. The function receives error as an argument.<br /> </div> <div> - Parse a glTF-based ArrayBuffer or <em>JSON</em> String and fire [page:Function onLoad] callback when complete. The argument to [page:Function onLoad] will be an [page:object] that contains loaded parts: .[page:Scene scene], .[page:Array scenes], .[page:Array cameras], and .[page:Array animations]. + Parse a glTF-based ArrayBuffer or <em>JSON</em> String and fire [page:Function onLoad] callback when complete. The argument to [page:Function onLoad] will be an [page:object] that contains loaded parts: .[page:Scene scene], .[page:Array scenes], .[page:Array cameras], .[page:Array animations], and .[page:Object asset]. </div> <h2>Source</h2>
false
Other
mrdoob
three.js
05437e236ed552fc42fef12cea69bb35ce2dd818.json
Update Lensflare.js to properly dispose textures Update Lensflare.js so to be able to properly dispose the textures otherwise we have memory issues... In order to properly dispose the textures added into the Lensflare ( new THREE.Lensflare() ) by the ( new THREE.LensflareElement() ) we must place them into the object. So then we can do for example: for( var i = scene.children.length - 1; i >= 0; i-- ) { for( var j = 0, n = scene.children[i].elements.length; j <n; j++ ){ scene.children[i].elements[m].texture.dispose(); } }
examples/js/objects/Lensflare.js
@@ -127,7 +127,7 @@ THREE.Lensflare = function () { // - var elements = []; + this.elements = []; var shader = THREE.LensflareElement.Shader; @@ -150,7 +150,7 @@ THREE.Lensflare = function () { this.addElement = function ( element ) { - elements.push( element ); + this.elements.push( element ); }; @@ -220,9 +220,9 @@ THREE.Lensflare = function () { var vecX = - positionScreen.x * 2; var vecY = - positionScreen.y * 2; - for ( var i = 0, l = elements.length; i < l; i ++ ) { + for ( var i = 0, l = this.elements.length; i < l; i ++ ) { - var element = elements[ i ]; + var element = this.elements[ i ]; var uniforms = material2.uniforms;
false
Other
mrdoob
three.js
1f6eaf8b1c2d50e60bb2c4c7dff2164a5d310d1f.json
Fix first empty line on RawShaderMaterial shaders
src/renderers/webgl/WebGLProgram.js
@@ -291,21 +291,29 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters prefixVertex = [ - customDefines, - - '\n' + customDefines ].filter( filterEmptyLine ).join( '\n' ); + if ( prefixVertex.length > 0 ) { + + prefixVertex += '\n'; + + } + prefixFragment = [ customExtensions, - customDefines, - - '\n' + customDefines ].filter( filterEmptyLine ).join( '\n' ); + if ( prefixFragment.length > 0 ) { + + prefixFragment += '\n'; + + } + } else { prefixVertex = [
false
Other
mrdoob
three.js
698cab2bc7a7e5957188583f4924ce6e404c4ba4.json
Fix remaining text examples
examples/webgl_geometry_text.html
@@ -363,7 +363,7 @@ function createText() { - textGeo = new THREE.TextBufferGeometry( text, { + textGeo = new THREE.TextGeometry( text, { font: font,
true
Other
mrdoob
three.js
698cab2bc7a7e5957188583f4924ce6e404c4ba4.json
Fix remaining text examples
examples/webgl_geometry_text_pnltri.html
@@ -393,7 +393,7 @@ function createText() { - textGeo = new THREE.TextBufferGeometry( text, { + textGeo = new THREE.TextGeometry( text, { font: font,
true
Other
mrdoob
three.js
2b60027164865774024c2070179aecd33fb08bc3.json
Fix earcut example
examples/webgl_geometry_text_earcut.html
@@ -97,7 +97,7 @@ return grouped; }; - + </script> <script> @@ -421,7 +421,7 @@ function createText() { - textGeo = new THREE.TextBufferGeometry( text, { + textGeo = new THREE.TextGeometry( text, { font: font,
false
Other
mrdoob
three.js
d5e3cb3fab32b07d7f369e80fe67c4019b1ea4d3.json
Use un-minified three.js in fiddles
.github/CONTRIBUTING.md
@@ -14,7 +14,7 @@ 1. Specify the revision number of the three.js library where the bug occurred. 2. Specify your browser version, operating system, and graphics card. (for example, Chrome 23.0.1271.95, Windows 7, Nvidia Quadro 2000M) 3. Describe the problem in detail. Explain what happened, and what you expected would happen. -4. Provide a small test-case (http://jsfiddle.net). [Here is a fiddle](http://jsfiddle.net/akmcv7Lh/) you can edit that runs the current version. [And here is a fiddle](http://jsfiddle.net/hw9rcLL8/) that uses the dev branch. If a test-case is not possible, provide a link to a live version of your application. +4. Provide a small test-case (http://jsfiddle.net). [Here is a fiddle](https://jsfiddle.net/3foLr7sn/) you can edit that runs the current version. [And here is a fiddle](https://jsfiddle.net/qgu17w5o/) that uses the dev branch. If a test-case is not possible, provide a link to a live version of your application. 5. If helpful, include a screenshot. Annotate the screenshot for clarity. ---
true
Other
mrdoob
three.js
d5e3cb3fab32b07d7f369e80fe67c4019b1ea4d3.json
Use un-minified three.js in fiddles
.github/ISSUE_TEMPLATE.md
@@ -11,8 +11,8 @@ Always include a code snippet, screenshots, and any relevant models or textures Please also include a live example if possible. You can start from these templates: -* [jsfiddle](https://jsfiddle.net/s3rjfcc3/) (latest release branch) -* [jsfiddle](https://jsfiddle.net/ptgwhemb/) (dev branch) +* [jsfiddle](https://jsfiddle.net/3foLr7sn/) (latest release branch) +* [jsfiddle](https://jsfiddle.net/qgu17w5o/) (dev branch) * [codepen](https://codepen.io/anon/pen/aEBKxR) (latest release branch) * [codepen](https://codepen.io/anon/pen/BJWzaN) (dev branch)
true
Other
mrdoob
three.js
1d192327f1a032dd022e1314386adfee777caad5.json
Remove unnecessary instantiations
examples/js/controls/EditorControls.js
@@ -21,6 +21,8 @@ THREE.EditorControls = function ( object, domElement ) { var scope = this; var vector = new THREE.Vector3(); + var delta = new THREE.Vector3(); + var box = new THREE.Box3(); var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2 }; var state = STATE.NONE; @@ -37,10 +39,10 @@ THREE.EditorControls = function ( object, domElement ) { this.focus = function ( target ) { - var box = new THREE.Box3().setFromObject( target ); - var distance; + box.setFromObject( target ); + if ( box.isEmpty() === false ) { center.copy( box.getCenter() ); @@ -55,7 +57,7 @@ THREE.EditorControls = function ( object, domElement ) { } - var delta = new THREE.Vector3( 0, 0, 1 ); + delta.set( 0, 0, 1 ); delta.applyQuaternion( object.quaternion ); delta.multiplyScalar( distance * 4 ); @@ -156,15 +158,15 @@ THREE.EditorControls = function ( object, domElement ) { if ( state === STATE.ROTATE ) { - scope.rotate( new THREE.Vector3( - movementX * scope.rotationSpeed, - movementY * scope.rotationSpeed, 0 ) ); + scope.rotate( delta.set( - movementX * scope.rotationSpeed, - movementY * scope.rotationSpeed, 0 ) ); } else if ( state === STATE.ZOOM ) { - scope.zoom( new THREE.Vector3( 0, 0, movementY ) ); + scope.zoom( delta.set( 0, 0, movementY ) ); } else if ( state === STATE.PAN ) { - scope.pan( new THREE.Vector3( - movementX, movementY, 0 ) ); + scope.pan( delta.set( - movementX, movementY, 0 ) ); } @@ -188,7 +190,7 @@ THREE.EditorControls = function ( object, domElement ) { event.preventDefault(); // Normalize deltaY due to https://bugzilla.mozilla.org/show_bug.cgi?id=1392460 - scope.zoom( new THREE.Vector3( 0, 0, event.deltaY > 0 ? 1 : - 1 ) ); + scope.zoom( delta.set( 0, 0, event.deltaY > 0 ? 1 : - 1 ) ); } @@ -283,7 +285,7 @@ THREE.EditorControls = function ( object, domElement ) { touches[ 0 ].set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, 0 ); touches[ 1 ].set( event.touches[ 1 ].pageX, event.touches[ 1 ].pageY, 0 ); var distance = touches[ 0 ].distanceTo( touches[ 1 ] ); - scope.zoom( new THREE.Vector3( 0, 0, prevDistance - distance ) ); + scope.zoom( delta.set( 0, 0, prevDistance - distance ) ); prevDistance = distance;
false
Other
mrdoob
three.js
ac1c328b8769f7dcf462219b9f1ed0147081b70f.json
simplify morph target parsing
examples/js/loaders/FBXLoader.js
@@ -733,35 +733,7 @@ targetRelationships.children.forEach( function ( child ) { - - if ( child.relationship === 'DeformPercent' ) { // animation info for morph target - - var animConnections = connections.get( child.ID ); - // parent relationship 'DeformPercent' === morphTargetNode /2605340465664 - // parent relationship 'undefined' === AnimationLayer /2606600117184 - // child relationship 'd|DeformPercent' === AnimationCurve /2606284032736 - - rawMorphTarget.weightCurveID = child.ID; - - animConnections.parents.forEach( function ( parent ) { - - if ( parent.relationship === undefined ) { - - // assuming each morph target is in a single animation layer for now - rawMorphTarget.animationLayerID = parent.ID; - - } - - } ); - - // assuming each morph target has a single animation curve for now - rawMorphTarget.animationCurveID = animConnections.children[ 0 ].ID; - - } else { - - rawMorphTarget.geoID = child.ID; - - } + if ( child.relationship === undefined ) rawMorphTarget.geoID = child.ID; } );
false
Other
mrdoob
three.js
2eb9a128e2aded663f3b68f89bf3666cc317dad2.json
Fix a tiny typo
test/benchmark/core/TriangleClosestPoint.js
@@ -52,7 +52,7 @@ s.add('9^3 points, 20 triangles', function() { var target = new THREE.Vector3(); for (var tidx = 0; tidx < triangles.length; tidx++) { - triangle = triangles[tidx]; + var triangle = triangles[tidx]; for (var pidx = 0; pidx < testPoints.length; pidx++) { triangle.closestPointToPoint(testPoints[pidx], target); }
false
Other
mrdoob
three.js
14a57e4c8588189480f74e040130ca6b14695e68.json
Fix typo and markup Fix typo that crept in while the div -> p cleanup was being done in https://github.com/mrdoob/three.js/commit/0992e6b30f3f3b2814bb094e73c3fbe00744dcdf#diff-9afe4f32e3fc42b230a087b60624fca6
docs/manual/introduction/Creating-a-scene.html
@@ -113,8 +113,7 @@ <h2>Animating the cube</h2> cube.rotation.y += 0.01; </code> - <p>This will be run every frame (normally 60 times per second), and give the cube a nice rotation animation. Basically, anything you want to move or change while the app is running has to go through the animate loop. You can of course call other functions from there, so that you don't end up with a <strong>animate</strong> function that's hundreds of p. - </div> + <p>This will be run every frame (normally 60 times per second), and give the cube a nice rotation animation. Basically, anything you want to move or change while the app is running has to go through the animate loop. You can of course call other functions from there, so that you don't end up with a <strong>animate</strong> function that's hundreds of lines.</p> <h2>The result</h2> <p>Congratulations! You have now completed your first three.js application. It's simple, you have to start somewhere.</p>
false
Other
mrdoob
three.js
b3c37c589fc81781babc4d576ff512de5b97c8f8.json
add BufferGeometry de-duplication to GLTF parser
examples/js/loaders/GLTFLoader.js
@@ -1298,6 +1298,60 @@ THREE.GLTFLoader = ( function () { } + function isPrimitiveEqual ( a, b ) { + + if ( a.indices !== b.indices ) { + + return false; + + } + + var attribA = a.attributes || {}; + var attribB = b.attributes || {}; + var keysA = Object.keys(attribA); + var keysB = Object.keys(attribB); + var i; + + for ( i = 0; i < keysA.length; i++ ) { + + var key = keysA[i]; + + if ( attribA[key] !== attribB[key] ) { + + return false; + + } + } + + for ( i = 0; i < keysB.length; i++ ) { + + var key = keysB[i]; + + if ( attribA[key] !== attribB[key] ) { + + return false; + + } + } + + return true; + } + + function getCachedGeometry ( cache, newPrimitive ) { + + for ( var i = 0; i < cache.length; i++ ) { + var cached = cache[i]; + + if ( isPrimitiveEqual( cached.primitive, newPrimitive ) ) { + + return cached.geometry; + + } + } + + return null; + } + /* GLTF PARSER */ function GLTFParser( json, extensions, options ) { @@ -1309,6 +1363,9 @@ THREE.GLTFLoader = ( function () { // loader object cache this.cache = new GLTFRegistry(); + // BufferGeometry caching + this.primitiveCache = []; + this.textureLoader = new THREE.TextureLoader( this.options.manager ); this.textureLoader.setCrossOrigin( this.options.crossOrigin ); @@ -1817,6 +1874,8 @@ THREE.GLTFLoader = ( function () { GLTFParser.prototype.loadGeometries = function ( primitives ) { + var cache = this.primitiveCache; + return this._withDependencies( [ 'accessors', @@ -1825,6 +1884,15 @@ THREE.GLTFLoader = ( function () { return _each( primitives, function ( primitive ) { + // See if we've already created this geometry + var cached = getCachedGeometry( cache, primitive ); + + if (cached) { + + return cached; + + } + var geometry = new THREE.BufferGeometry(); var attributes = primitive.attributes; @@ -1890,6 +1958,14 @@ THREE.GLTFLoader = ( function () { } + // Cache this geometry + cache.push( { + + primitive: primitive, + geometry: geometry + + } ); + return geometry; } );
false
Other
mrdoob
three.js
a400150ede2af942095d33eeb4243fc1c00a49a5.json
Update VectorKeyframeTrack inheritance
src/animation/tracks/VectorKeyframeTrack.js
@@ -1,5 +1,4 @@ -import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype.js'; -import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor.js'; +import { KeyframeTrack } from '../KeyframeTrack.js'; /** * @@ -13,11 +12,11 @@ import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor.js'; function VectorKeyframeTrack( name, times, values, interpolation ) { - KeyframeTrackConstructor.call( this, name, times, values, interpolation ); + KeyframeTrack.call( this, name, times, values, interpolation ); } -VectorKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrackPrototype ), { +VectorKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { constructor: VectorKeyframeTrack,
false
Other
mrdoob
three.js
26d773c88cc1f40acd638dcf787346d83b36ae87.json
Update StringKeyframeTrack inheritance
src/animation/tracks/StringKeyframeTrack.js
@@ -1,6 +1,5 @@ import { InterpolateDiscrete } from '../../constants.js'; -import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype.js'; -import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor.js'; +import { KeyframeTrack } from '../KeyframeTrack.js'; /** * @@ -14,11 +13,11 @@ import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor.js'; function StringKeyframeTrack( name, times, values, interpolation ) { - KeyframeTrackConstructor.call( this, name, times, values, interpolation ); + KeyframeTrack.call( this, name, times, values, interpolation ); } -StringKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrackPrototype ), { +StringKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { constructor: StringKeyframeTrack,
false
Other
mrdoob
three.js
319f2156a699f3bde9d70ebb6b2cff3b74639971.json
Update QuaternionKeyframeTrack inheritance
src/animation/tracks/QuaternionKeyframeTrack.js
@@ -1,7 +1,6 @@ import { InterpolateLinear } from '../../constants.js'; -import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype.js'; +import { KeyframeTrack } from '../KeyframeTrack.js'; import { QuaternionLinearInterpolant } from '../../math/interpolants/QuaternionLinearInterpolant.js'; -import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor.js'; /** * @@ -14,11 +13,11 @@ import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor.js'; function QuaternionKeyframeTrack( name, times, values, interpolation ) { - KeyframeTrackConstructor.call( this, name, times, values, interpolation ); + KeyframeTrack.call( this, name, times, values, interpolation ); } -QuaternionKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrackPrototype ), { +QuaternionKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { constructor: QuaternionKeyframeTrack,
false
Other
mrdoob
three.js
aaf9f49525dd42599b8729564691923749fc6d55.json
Update NumberKeyframeTrack inheritance
src/animation/tracks/NumberKeyframeTrack.js
@@ -1,5 +1,4 @@ -import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype.js'; -import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor.js'; +import { KeyframeTrack } from '../KeyframeTrack.js'; /** * @@ -12,11 +11,11 @@ import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor.js'; function NumberKeyframeTrack( name, times, values, interpolation ) { - KeyframeTrackConstructor.call( this, name, times, values, interpolation ); + KeyframeTrack.call( this, name, times, values, interpolation ); } -NumberKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrackPrototype ), { +NumberKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { constructor: NumberKeyframeTrack,
false