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
bc4fd08b2128b0f1cfe4d6d0282faa902d4398ce.json
Shortcut descriptions (#9062) * adds shortcut key to buttons and menu * revert bad formatting * reverts UI.Button changes and inlines the button shortcut key in the description text * removes unintentional whitespaces
editor/js/Menubar.Edit.js
@@ -104,7 +104,7 @@ Menubar.Edit = function ( editor ) { var option = new UI.Row(); option.setClass( 'option' ); - option.setTextContent( 'Delete' ); + option.setTextContent( 'Delete (Del)' ); option.onClick( function () { var object = editor.selected;
true
Other
mrdoob
three.js
bc4fd08b2128b0f1cfe4d6d0282faa902d4398ce.json
Shortcut descriptions (#9062) * adds shortcut key to buttons and menu * revert bad formatting * reverts UI.Button changes and inlines the button shortcut key in the description text * removes unintentional whitespaces
editor/js/Toolbar.js
@@ -14,21 +14,21 @@ var Toolbar = function ( editor ) { // translate / rotate / scale - var translate = new UI.Button( 'translate' ).onClick( function () { + var translate = new UI.Button( 'translate ( e )' ).onClick( function () { signals.transformModeChanged.dispatch( 'translate' ); } ); buttons.add( translate ); - var rotate = new UI.Button( 'rotate' ).onClick( function () { + var rotate = new UI.Button( 'rotate ( w )' ).onClick( function () { signals.transformModeChanged.dispatch( 'rotate' ); } ); buttons.add( rotate ); - var scale = new UI.Button( 'scale' ).onClick( function () { + var scale = new UI.Button( 'scale ( r )' ).onClick( function () { signals.transformModeChanged.dispatch( 'scale' );
true
Other
mrdoob
three.js
bc4fd08b2128b0f1cfe4d6d0282faa902d4398ce.json
Shortcut descriptions (#9062) * adds shortcut key to buttons and menu * revert bad formatting * reverts UI.Button changes and inlines the button shortcut key in the description text * removes unintentional whitespaces
editor/js/libs/ui.js
@@ -1045,8 +1045,6 @@ UI.Button = function ( value ) { UI.Element.call( this ); - var scope = this; - var dom = document.createElement( 'button' ); dom.className = 'Button';
true
Other
mrdoob
three.js
d2933332783b3b0d113f048dfb8dd7cc5999320b.json
Fix Skeleton.pose() bug (#8976) * Fix Skeleton.pose() bug * Clean up THREE.Skeleton
src/objects/Skeleton.js
@@ -123,7 +123,7 @@ Object.assign( THREE.Skeleton.prototype, { if ( bone ) { - if ( bone.parent ) { + if ( bone.parent instanceof THREE.Bone ) { bone.matrix.getInverse( bone.parent.matrixWorld ); bone.matrix.multiply( bone.matrixWorld );
false
Other
mrdoob
three.js
3d01a17385df25ee4d92b0501f0b80b3744f22a0.json
Update CinematicCamera.js (#8873) remove console message
examples/js/cameras/CinematicCamera.js
@@ -135,7 +135,7 @@ THREE.CinematicCamera.prototype.initPostProcessing = function () { this.postprocessing.bokeh_uniforms[ "focalDepth" ].value = 0.1; - console.log( this.postprocessing.bokeh_uniforms[ "focalDepth" ].value ); + //console.log( this.postprocessing.bokeh_uniforms[ "focalDepth" ].value ); this.postprocessing.bokeh_uniforms[ "znear" ].value = this.near; this.postprocessing.bokeh_uniforms[ "zfar" ].value = this.near;
false
Other
mrdoob
three.js
5797cf55a68703bb0272d82d205c3a26f90aae42.json
remove warnings. (#8877) # Conflicts: # src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
@@ -1,6 +1,6 @@ #ifdef ENVMAP_TYPE_CUBE_UV -const float cubeUV_textureSize = 1024.0; +#define cubeUV_textureSize (1024.0) int getFaceFromDirection(vec3 direction) { vec3 absDirection = abs(direction); @@ -19,8 +19,8 @@ int getFaceFromDirection(vec3 direction) { } return face; } -float cubeUV_maxLods1 = log2(cubeUV_textureSize*0.25) - 1.0; -float cubeUV_rangeClamp = exp2((6.0 - 1.0) * 2.0); +#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0) +#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0)) vec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) { float scale = exp2(cubeUV_maxLods1 - roughnessLevel); @@ -35,8 +35,8 @@ vec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) { return vec2(floor(mipLevel), fract(mipLevel)); } -float cubeUV_maxLods2 = log2(cubeUV_textureSize*0.25) - 2.0; -const float cubeUV_rcpTextureSize = 1.0 / cubeUV_textureSize; +#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0) +#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize) vec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) { mipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel; @@ -97,7 +97,7 @@ vec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) { return base + s * ( scale - 2.0 * texelOffset ); } -float cubeUV_maxLods3 = log2(cubeUV_textureSize*0.25) - 3.0; +#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0) vec4 textureCubeUV(vec3 reflectedDirection, float roughness ) { float roughnessVal = roughness* cubeUV_maxLods3;
false
Other
mrdoob
three.js
f39fee8eaf049994c7df25173425d83a108b40fe.json
fix legacy redirect (#8879)
examples/js/controls/OrbitControls.js
@@ -1003,14 +1003,14 @@ Object.defineProperties( THREE.OrbitControls.prototype, { get: function () { console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); - return ! this.constraint.enableDamping; + return ! this.enableDamping; }, set: function ( value ) { console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); - this.constraint.enableDamping = ! value; + this.enableDamping = ! value; } @@ -1021,14 +1021,14 @@ Object.defineProperties( THREE.OrbitControls.prototype, { get: function () { console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); - return this.constraint.dampingFactor; + return this.dampingFactor; }, set: function ( value ) { console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); - this.constraint.dampingFactor = value; + this.dampingFactor = value; }
false
Other
mrdoob
three.js
8fe367d9221852c63cd9058453684c4b8e58b8b6.json
Fix GridHelper API change (#8812)
examples/misc_sound.html
@@ -156,9 +156,7 @@ // ground - var helper = new THREE.GridHelper( 500, 10 ); - helper.color1.setHex( 0x444444 ); - helper.color2.setHex( 0x444444 ); + var helper = new THREE.GridHelper( 500, 10, 0x444444, 0x444444 ); helper.position.y = 0.1; scene.add( helper );
false
Other
mrdoob
three.js
5a7a681011bfcbb76a3e9264f923e4b59718db38.json
Change .drawcalls to .groups
src/extras/geometries/WireframeGeometry.js
@@ -77,10 +77,10 @@ THREE.WireframeGeometry = function ( geometry ) { var indices = geometry.index.array; var vertices = geometry.attributes.position; - var drawcalls = geometry.drawcalls; + var groups = geometry.groups; var numEdges = 0; - if ( drawcalls.length === 0 ) { + if ( groups.length === 0 ) { geometry.addGroup( 0, indices.length ); @@ -89,12 +89,12 @@ THREE.WireframeGeometry = function ( geometry ) { // allocate maximal size var edges = new Uint32Array( 2 * indices.length ); - for ( var o = 0, ol = drawcalls.length; o < ol; ++ o ) { + for ( var o = 0, ol = groups.length; o < ol; ++ o ) { - var drawcall = drawcalls[ o ]; + var group = groups[ o ]; - var start = drawcall.start; - var count = drawcall.count; + var start = group.start; + var count = group.count; for ( var i = start, il = start + count; i < il; i += 3 ) {
false
Other
mrdoob
three.js
e1a2ad2e5ed2f78beb86f0ea95d44cea7089527d.json
Use updated OBJ Loader in OBJ_MTL example This requires loading the MTL first with an instance of `MTLLoader`, and passing the resulting `materialCreator` to an instance of `OBJLoader`
examples/webgl_loader_obj_mtl.html
@@ -34,7 +34,7 @@ <script src="js/loaders/DDSLoader.js"></script> <script src="js/loaders/MTLLoader.js"></script> - <script src="js/loaders/OBJMTLLoader.js"></script> + <script src="js/loaders/OBJLoader.js"></script> <script src="js/Detector.js"></script> <script src="js/libs/stats.min.js"></script> @@ -83,19 +83,31 @@ } }; - var onError = function ( xhr ) { - }; - - + var onError = function ( xhr ) { }; + THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() ); - - var loader = new THREE.OBJMTLLoader(); - loader.load( 'obj/male02/male02.obj', 'obj/male02/male02_dds.mtl', function ( object ) { - - object.position.y = - 80; - scene.add( object ); - - }, onProgress, onError ); + + var objLoader = new THREE.OBJLoader(); + var mtlLoader = new THREE.MTLLoader(objLoader.manager); + + var mtlUrl = 'obj/male02/male02_dds.mtl'; + var objUrl = 'obj/male02/male02.obj'; + + mtlLoader.setBaseUrl( objUrl.substr( 0, objUrl.lastIndexOf( "/" ) + 1 ) ); + + mtlLoader.load( mtlUrl, function( materials ) { + + materials.preload(); + objLoader.setMaterials( materials ); + + objLoader.load( objUrl, function ( object ) { + + object.position.y = - 80; + scene.add( object ); + + }, onProgress, onError ); + + }); //
false
Other
mrdoob
three.js
ef1073ecb632f3e06c9312201c055e2fe0a0bd50.json
add comments on indirect diffuse cubemap.
src/renderers/shaders/ShaderChunk/lights_pars.glsl
@@ -126,12 +126,16 @@ uniform vec3 ambientLightColor; vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz ); + // TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level + // of a specular cubemap, or just the default level of a specially created irradiance cubemap. + #if defined( TEXTURE_CUBE_LOD_EXT ) vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) ); #else + // force the bias high to get the last LOD level as it is the most blurred. vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) ); #endif
false
Other
mrdoob
three.js
0dd332ed4bfe289361a37db7177aa7a1d24567ee.json
Add ETC1 compressed texture support.
examples/js/loaders/DDSLoader.js
@@ -102,6 +102,7 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) { var FOURCC_DXT1 = fourCCToInt32( "DXT1" ); var FOURCC_DXT3 = fourCCToInt32( "DXT3" ); var FOURCC_DXT5 = fourCCToInt32( "DXT5" ); + var FOURCC_ETC1 = fourCCToInt32( "ETC1" ); var headerLengthInt = 31; // The header length in 32 bit ints @@ -173,6 +174,12 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) { dds.format = THREE.RGBA_S3TC_DXT5_Format; break; + case FOURCC_ETC1: + + blockBytes = 8; + dds.format = THREE.RGB_ETC1_Format; + break; + default: if ( header[ off_RGBBitCount ] === 32
true
Other
mrdoob
three.js
0dd332ed4bfe289361a37db7177aa7a1d24567ee.json
Add ETC1 compressed texture support.
src/Three.js
@@ -352,6 +352,10 @@ THREE.RGB_PVRTC_2BPPV1_Format = 2101; THREE.RGBA_PVRTC_4BPPV1_Format = 2102; THREE.RGBA_PVRTC_2BPPV1_Format = 2103; +// ETC compressed texture formats + +THREE.RGB_ETC1_Format = 2151; + // Loop styles for AnimationAction THREE.LoopOnce = 2200;
true
Other
mrdoob
three.js
0dd332ed4bfe289361a37db7177aa7a1d24567ee.json
Add ETC1 compressed texture support.
src/renderers/WebGLRenderer.js
@@ -3624,6 +3624,14 @@ THREE.WebGLRenderer = function ( parameters ) { } + extension = extensions.get( 'WEBGL_compressed_texture_etc1' ); + + if ( extension !== null ) { + + if ( p === THREE.RGB_ETC1_Format ) return extension.COMPRESSED_RGB_ETC1_WEBGL; + + } + extension = extensions.get( 'EXT_blend_minmax' ); if ( extension !== null ) {
true
Other
mrdoob
three.js
0dd332ed4bfe289361a37db7177aa7a1d24567ee.json
Add ETC1 compressed texture support.
src/renderers/webgl/WebGLExtensions.js
@@ -30,6 +30,10 @@ THREE.WebGLExtensions = function ( gl ) { extension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' ); break; + case 'WEBGL_compressed_texture_etc1': + extension = gl.getExtension( 'WEBGL_compressed_texture_etc1' ); + break; + default: extension = gl.getExtension( name );
true
Other
mrdoob
three.js
0dd332ed4bfe289361a37db7177aa7a1d24567ee.json
Add ETC1 compressed texture support.
src/renderers/webgl/WebGLState.js
@@ -167,7 +167,8 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) { compressedTextureFormats = []; if ( extensions.get( 'WEBGL_compressed_texture_pvrtc' ) || - extensions.get( 'WEBGL_compressed_texture_s3tc' ) ) { + extensions.get( 'WEBGL_compressed_texture_s3tc' ) || + extensions.get( 'WEBGL_compressed_texture_etc1' )) { var formats = gl.getParameter( gl.COMPRESSED_TEXTURE_FORMATS );
true
Other
mrdoob
three.js
cd80a94cdb501660c6ff96da41d2b30e54db027b.json
fix use with operator and share to optimize
examples/js/nodes/accessors/ScreenUVNode.js
@@ -4,7 +4,7 @@ THREE.ScreenUVNode = function( resolution ) { - THREE.TempNode.call( this, 'v2', { shared: false } ); + THREE.TempNode.call( this, 'v2' ); this.resolution = resolution; @@ -20,7 +20,7 @@ THREE.ScreenUVNode.prototype.generate = function( builder, output ) { if ( builder.isShader( 'fragment' ) ) { - result = 'gl_FragCoord.xy/' + this.resolution.build( builder, 'v2' ); + result = '(gl_FragCoord.xy/' + this.resolution.build( builder, 'v2' ) + ')'; } else {
false
Other
mrdoob
three.js
2f61147d63ac92d4dd43b87fc2ad44252e1d044d.json
fix float input, auto joint or split node
examples/js/nodes/utils/SwitchNode.js
@@ -4,7 +4,7 @@ THREE.SwitchNode = function( node, components ) { - THREE.GLNode.call( this, 'fv1' ); + THREE.GLNode.call( this ); this.node = node; this.components = components || 'x'; @@ -42,24 +42,28 @@ THREE.SwitchNode.prototype.generate = function( builder, output ) { if ( outputLength > inputLength ) outputLength = inputLength; - // build switch + if ( inputLength > 0 ) { - node += '.'; + // split - for ( i = 0; i < len; i ++ ) { + node += '.'; - var elm = components.charAt( i ); - var idx = builder.getIndexByElement( components.charAt( i ) ); + for ( i = 0; i < len; i ++ ) { - if ( idx > outputLength ) idx = outputLength; + var elm = components.charAt( i ); + var idx = builder.getIndexByElement( components.charAt( i ) ); - if ( builder.getElementByIndex( idx ) == undefined ) { + if ( idx > outputLength ) idx = outputLength; - console.log( builder.getElementByIndex( idx ) ); + node += builder.getElementByIndex( idx ); } - node += builder.getElementByIndex( idx ); + } else { + + // join + + node = builder.format( node, type, this.getType( builder ) ) }
false
Other
mrdoob
three.js
46dfb3990aa247d9406704d13f2d6734d7d31a72.json
add sqrt and fix getType
examples/js/nodes/math/Math1Node.js
@@ -18,7 +18,8 @@ THREE.Math1Node.EXP = 'exp'; THREE.Math1Node.EXP2 = 'exp2'; THREE.Math1Node.LOG = 'log'; THREE.Math1Node.LOG2 = 'log2'; -THREE.Math1Node.INVERSE_SQRT = 'inversesqrt'; +THREE.Math1Node.SQRT = 'sqrt'; +THREE.Math1Node.INV_SQRT = 'inversesqrt'; THREE.Math1Node.FLOOR = 'floor'; THREE.Math1Node.CEIL = 'ceil'; THREE.Math1Node.NORMALIZE = 'normalize'; @@ -42,7 +43,7 @@ THREE.Math1Node.prototype.constructor = THREE.Math1Node; THREE.Math1Node.prototype.getType = function( builder ) { switch ( this.method ) { - case THREE.Math1Node.DISTANCE: + case THREE.Math1Node.LENGTH: return 'fv1'; }
false
Other
mrdoob
three.js
3d0dc519c6a888fe521907cf54c84e4cd821ba29.json
StereoEffect set eye separation (#9432)
examples/js/effects/StereoEffect.js
@@ -16,6 +16,12 @@ THREE.StereoEffect = function ( renderer ) { }; + this.setEyeSep = function ( eyeSep ) { + + _stereo.eyeSep = eyeSep; + + }; + this.render = function ( scene, camera ) { scene.updateMatrixWorld();
true
Other
mrdoob
three.js
3d0dc519c6a888fe521907cf54c84e4cd821ba29.json
StereoEffect set eye separation (#9432)
src/cameras/StereoCamera.js
@@ -12,6 +12,8 @@ function StereoCamera() { this.aspect = 1; + this.eyeSep = 0.064; + this.cameraL = new PerspectiveCamera(); this.cameraL.layers.enable( 1 ); this.cameraL.matrixAutoUpdate = false; @@ -49,7 +51,7 @@ Object.assign( StereoCamera.prototype, { // http://paulbourke.net/stereographics/stereorender/ var projectionMatrix = camera.projectionMatrix.clone(); - var eyeSep = 0.064 / 2; + var eyeSep = this.eyeSep / 2; var eyeSepOnProjection = eyeSep * near / focus; var ymax = near * Math.tan( _Math.DEG2RAD * fov * 0.5 ); var xmin, xmax;
true
Other
mrdoob
three.js
2ee2d33965d9f6cef67b05177f6b66677b6d7e6e.json
Clarify the explanation (#9422) First usage of `updateStyle` with now indication of what or where it came from.
docs/manual/introduction/Creating-a-scene.html
@@ -61,7 +61,7 @@ <h2>Creating the scene</h2> <div>In addition to creating the renderer instance, we also need to set the size at which we want it to render our app. It's a good idea to use the width and height of the area we want to fill with our app - in this case, the width and height of the browser window. For performance intensive apps, you can also give <strong>setSize</strong> smaller values, like <strong>window.innerWidth/2</strong> and <strong>window.innerHeight/2</strong>, which will make the app render at half size.</div> - <div>If you wish to keep the size of your app but render it at a lower resolution, you can do so by calling <strong>setSize</strong> with false as <strong>updateStyle</strong>. For example, <strong>setSize(window.innerWidth/2, window.innerHeight/2, false)</strong> will render your app at half resolution, given that your &lt;canvas&gt; has 100% width and height.</div> + <div>If you wish to keep the size of your app but render it at a lower resolution, you can do so by calling <strong>setSize</strong> with false as <strong>updateStyle</strong> (the third arugment). For example, <strong>setSize(window.innerWidth/2, window.innerHeight/2, false)</strong> will render your app at half resolution, given that your &lt;canvas&gt; has 100% width and height.</div> <div>Last but not least, we add the <strong>renderer</strong> element to our HTML document. This is a &lt;canvas&gt; element the renderer uses to display the scene to us.</div>
false
Other
mrdoob
three.js
bf50f022aa2d209070e1d50801c8534c9553b3da.json
Update ExtrudeGeometry.js (#9409) Changed the bevel so that it is elliptical instead of sinusoidal. Formatted both areas the same with the linear option in the comments.
src/extras/geometries/ExtrudeGeometry.js
@@ -361,10 +361,10 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { //for ( b = bevelSegments; b > 0; b -- ) { t = b / bevelSegments; - z = bevelThickness * ( 1 - t ); + z = bevelThickness * Math.cos ( t * Math.PI / 2 ); // curved + //z = bevelThickness * ( 1 - t ); //linear - //z = bevelThickness * t; - bs = bevelSize * ( Math.sin ( t * Math.PI / 2 ) ); // curved + bs = bevelSize * Math.sin ( t * Math.PI / 2 ); // curved //bs = bevelSize * t; // linear // contract shape @@ -462,9 +462,11 @@ ExtrudeGeometry.prototype.addShape = function ( shape, options ) { for ( b = bevelSegments - 1; b >= 0; b -- ) { t = b / bevelSegments; - z = bevelThickness * ( 1 - t ); - //bs = bevelSize * ( 1-Math.sin ( ( 1 - t ) * Math.PI/2 ) ); + z = bevelThickness * Math.cos ( t * Math.PI / 2 ); // curved + //z = bevelThickness * ( 1 - t ); //linear + bs = bevelSize * Math.sin ( t * Math.PI / 2 ); + //bs = bevelSize * t; // linear // contract shape
false
Other
mrdoob
three.js
5ddf8219864e2f014ecdda19203847d5497f5f81.json
Add Raycaster returned UV property to docs (#9329)
docs/api/core/Raycaster.html
@@ -59,7 +59,8 @@ <h2>Example</h2> [example:webgl_interactive_raycasting_points Raycasting to Points], [example:webgl_geometry_terrain_raycast Terrain raycasting], [example:webgl_octree_raycasting Raycasting using an octree], - [example:webgl_interactive_voxelpainter Raycasting to paint voxels]</div> + [example:webgl_interactive_voxelpainter Raycasting to paint voxels], + [example:webgl_raycast_texture Raycast to a Texture]</div> <div> @@ -144,6 +145,7 @@ <h3>[method:Array intersectObject]( [page:Object3D object], [page:Boolean recurs [page:Integer faceIndex] – index of the intersected face<br /> [page:Array indices] – indices of vertices comprising the intersected face<br /> [page:Object3D object] – the intersected object + [page:Vector2 uv] - U,V coordinates at point of intersection </p> <p> When intersecting a [page:Mesh] with a [page:BufferGeometry], the *faceIndex* will be *undefined*, and *indices* will be set; when intersecting a [page:Mesh] with a [page:Geometry], *indices* will be *undefined*.
false
Other
mrdoob
three.js
4d8a7d7c62c1f99154556f8c2e5d0aa1fc2dae46.json
Build three.js too when running build_debug.sh
utils/build/build_debug.sh
@@ -1,4 +1,5 @@ #!/bin/sh cd "$(dirname "$0")" +python build.py --include common --include extras --output ../../build/three.js python build.py --include common --include extras --output ../../build/three.min.js
false
Other
mrdoob
three.js
bb5600fd89325e7f953996bf0fd6b45e3655e6a8.json
add unbiased mode to the MSAA render pass. (#8930) * add unbiased mode to the MSAA render pass. * clearer code. * better comment. * cleanup code. fix bug of using "camera", instead of "this.camera" * fix more places were "camera" is used instad of "this.camera" -- it worked because example declared "camera" as a global. * reduce light intensity. * add PerspectiveCamera.clearViewOffset() per @mrdoob's recommendation.
examples/files.js
@@ -189,6 +189,7 @@ var files = { "webgl_postprocessing_godrays", "webgl_postprocessing_masking", "webgl_postprocessing_msaa", + "webgl_postprocessing_msaa_unbiased", "webgl_postprocessing_nodes", "webgl_postprocessing_procedural", "webgl_postprocessing_smaa",
true
Other
mrdoob
three.js
bb5600fd89325e7f953996bf0fd6b45e3655e6a8.json
add unbiased mode to the MSAA render pass. (#8930) * add unbiased mode to the MSAA render pass. * clearer code. * better comment. * cleanup code. fix bug of using "camera", instead of "this.camera" * fix more places were "camera" is used instad of "this.camera" -- it worked because example declared "camera" as a global. * reduce light intensity. * add PerspectiveCamera.clearViewOffset() per @mrdoob's recommendation.
examples/js/postprocessing/ManualMSAARenderPass.js
@@ -18,6 +18,7 @@ THREE.ManualMSAARenderPass = function ( scene, camera ) { this.camera = camera; this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16. + this.unbiased = true; if ( THREE.CopyShader === undefined ) console.error( "THREE.ManualMSAARenderPass relies on THREE.CopyShader" ); @@ -77,27 +78,39 @@ Object.assign( THREE.ManualMSAARenderPass.prototype, { var autoClear = renderer.autoClear; renderer.autoClear = false; - this.copyUniforms[ "opacity" ].value = 1.0 / jitterOffsets.length; + var baseSampleWeight = 1.0 / jitterOffsets.length; + var roundingRange = 1 / 32; this.copyUniforms[ "tDiffuse" ].value = this.sampleRenderTarget.texture; + var width = readBuffer.width, height = readBuffer.height; + // render the scene multiple times, each slightly jitter offset from the last and accumulate the results. for ( var i = 0; i < jitterOffsets.length; i ++ ) { - // only jitters perspective cameras. TODO: add support for jittering orthogonal cameras var jitterOffset = jitterOffsets[i]; - if ( camera.setViewOffset ) { - camera.setViewOffset( readBuffer.width, readBuffer.height, + if ( this.camera.setViewOffset ) { + this.camera.setViewOffset( width, height, jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16 - readBuffer.width, readBuffer.height ); + width, height ); + } + + var sampleWeight = baseSampleWeight; + if( this.unbiased ) { + // the theory is that equal weights for each sample lead to an accumulation of rounding errors. + // The following equation varies the sampleWeight per sample so that it is uniformly distributed + // across a range of values whose rounding errors cancel each other out. + var uniformCenteredDistribution = ( -0.5 + ( i + 0.5 ) / jitterOffsets.length ); + sampleWeight += roundingRange * uniformCenteredDistribution; } + this.copyUniforms[ "opacity" ].value = sampleWeight; + renderer.render( this.scene, this.camera, this.sampleRenderTarget, true ); renderer.render( this.scene2, this.camera2, writeBuffer, (i === 0) ); } - // reset jitter to nothing. TODO: add support for orthogonal cameras - if ( camera.setViewOffset ) camera.setViewOffset( undefined, undefined, undefined, undefined, undefined, undefined ); + if ( this.camera.clearViewOffset ) this.camera.clearViewOffset(); renderer.autoClear = autoClear;
true
Other
mrdoob
three.js
bb5600fd89325e7f953996bf0fd6b45e3655e6a8.json
add unbiased mode to the MSAA render pass. (#8930) * add unbiased mode to the MSAA render pass. * clearer code. * better comment. * cleanup code. fix bug of using "camera", instead of "this.camera" * fix more places were "camera" is used instad of "this.camera" -- it worked because example declared "camera" as a global. * reduce light intensity. * add PerspectiveCamera.clearViewOffset() per @mrdoob's recommendation.
examples/js/postprocessing/TAARenderPass.js
@@ -45,8 +45,6 @@ Object.assign( THREE.TAARenderPass.prototype, { var jitterOffsets = THREE.TAARenderPass.JitterVectors[ 5 ]; - var camera = ( this.camera || this.scene.camera ); - if ( ! this.sampleRenderTarget ) { this.sampleRenderTarget = new THREE.WebGLRenderTarget( readBuffer.width, readBuffer.height, this.params ); @@ -82,10 +80,9 @@ Object.assign( THREE.TAARenderPass.prototype, { for ( var i = 0; i < numSamplesPerFrame; i ++ ) { var j = this.accumulateIndex; - // only jitters perspective cameras. TODO: add support for jittering orthogonal cameras var jitterOffset = jitterOffsets[j]; - if ( camera.setViewOffset ) { - camera.setViewOffset( readBuffer.width, readBuffer.height, + if ( this.camera.setViewOffset ) { + this.camera.setViewOffset( readBuffer.width, readBuffer.height, jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16 readBuffer.width, readBuffer.height ); } @@ -97,9 +94,8 @@ Object.assign( THREE.TAARenderPass.prototype, { if( this.accumulateIndex >= jitterOffsets.length ) break; } - // reset jitter to nothing. TODO: add support for orthogonal cameras - if ( camera.setViewOffset ) camera.setViewOffset( undefined, undefined, undefined, undefined, undefined, undefined ); - + if ( this.camera.clearViewOffset ) this.camera.clearViewOffset(); + } var accumulationWeight = this.accumulateIndex * sampleWeight;
true
Other
mrdoob
three.js
bb5600fd89325e7f953996bf0fd6b45e3655e6a8.json
add unbiased mode to the MSAA render pass. (#8930) * add unbiased mode to the MSAA render pass. * clearer code. * better comment. * cleanup code. fix bug of using "camera", instead of "this.camera" * fix more places were "camera" is used instad of "this.camera" -- it worked because example declared "camera" as a global. * reduce light intensity. * add PerspectiveCamera.clearViewOffset() per @mrdoob's recommendation.
examples/webgl_postprocessing_msaa.html
@@ -53,7 +53,9 @@ var camera, scene, renderer, composer, copyPass, msaaRenderPass; var gui, stats, texture; - var param = { MSAASampleLevel: 2 }; + var param = { + sampleLevel: 2 + }; init(); animate(); @@ -66,19 +68,13 @@ gui = new dat.GUI(); - var example = gui.add( param, 'MSAASampleLevel', { + gui.add( param, 'sampleLevel', { 'Level 0: 1 Sample': 0, 'Level 1: 2 Samples': 1, 'Level 2: 4 Samples': 2, 'Level 3: 8 Samples': 3, 'Level 4: 16 Samples': 4, 'Level 5: 32 Samples': 5 - } ).onFinishChange( function() { - - if( msaaRenderPass ) { - msaaRenderPass.sampleLevel = param.MSAASampleLevel; - } - } ); gui.open(); @@ -128,7 +124,7 @@ composer = new THREE.EffectComposer( renderer ); msaaRenderPass = new THREE.ManualMSAARenderPass( scene, camera ); - msaaRenderPass.sampleLevel = param.MSAASampleLevel; + msaaRenderPass.unbiased = false; composer.addPass( msaaRenderPass ); copyPass = new THREE.ShaderPass( THREE.CopyShader ); @@ -171,6 +167,8 @@ } + msaaRenderPass.sampleLevel = param.sampleLevel; + composer.render(); stats.end();
true
Other
mrdoob
three.js
bb5600fd89325e7f953996bf0fd6b45e3655e6a8.json
add unbiased mode to the MSAA render pass. (#8930) * add unbiased mode to the MSAA render pass. * clearer code. * better comment. * cleanup code. fix bug of using "camera", instead of "this.camera" * fix more places were "camera" is used instad of "this.camera" -- it worked because example declared "camera" as a global. * reduce light intensity. * add PerspectiveCamera.clearViewOffset() per @mrdoob's recommendation.
examples/webgl_postprocessing_msaa_unbiased.html
@@ -0,0 +1,211 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <title>three.js webgl - postprocessing manual msaa</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> + <style> + body { + margin: 0px; + background-color: #000; + overflow: hidden; + font-family:Monospace; + font-size:13px; + margin: 0px; + text-align:center; + overflow: hidden; + } + + #info { + color: #fff; + position: absolute; + top: 10px; + width: 100%; + text-align: center; + display:block; + } + </style> + </head> + <body> + <div id="info"> + <a href="http://threejs.org" target="_blank">three.js</a> - Unbiased Manual Multi-Sample Anti-Aliasing (MSAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a><br/><br/> + This example shows how to unbias the rounding errors accumulated using high number of MSAA samples on a 8-bit per channel buffer.<br/><br/> + Turn off the "unbiased" feature to see the banding that results from accumulated rounding errors. + </div> + + <div id="container"></div> + + <script src="../build/three.js"></script> + <script src="js/libs/stats.min.js"></script> + <script src="js/libs/dat.gui.min.js"></script> + + <script src="js/shaders/CopyShader.js"></script> + + <script src="js/postprocessing/EffectComposer.js"></script> + <script src="js/postprocessing/ManualMSAARenderPass.js"></script> + <script src="js/postprocessing/RenderPass.js"></script> + <script src="js/postprocessing/MaskPass.js"></script> + <script src="js/postprocessing/ShaderPass.js"></script> + + + <script> + + var camera, scene, renderer, composer, copyPass, msaaRenderPass; + var gui, stats, texture; + + var param = { + sampleLevel: 4, + unbiased: true + }; + + init(); + animate(); + + clearGui(); + + function clearGui() { + + if ( gui ) gui.destroy(); + + gui = new dat.GUI(); + + gui.add( param, "unbiased" ); + gui.add( param, 'sampleLevel', { + 'Level 0: 1 Sample': 0, + 'Level 1: 2 Samples': 1, + 'Level 2: 4 Samples': 2, + 'Level 3: 8 Samples': 3, + 'Level 4: 16 Samples': 4, + 'Level 5: 32 Samples': 5 + } ); + + gui.open(); + + } + + function init() { + + container = document.getElementById( "container" ); + + var width = window.innerWidth || 1; + var height = window.innerHeight || 1; + var devicePixelRatio = window.devicePixelRatio || 1; + + renderer = new THREE.WebGLRenderer( { antialias: false } ); + renderer.setPixelRatio( devicePixelRatio ); + renderer.setSize( width, height ); + document.body.appendChild( renderer.domElement ); + + stats = new Stats(); + container.appendChild( stats.dom ); + + // + + camera = new THREE.PerspectiveCamera( 65, width / height, 3, 10 ); + camera.position.z = 7; + + scene = new THREE.Scene(); + + group = new THREE.Object3D(); + scene.add( group ); + + var light = new THREE.PointLight( 0xddffdd, 1.0 ); + light.position.z = 70; + light.position.y = -70; + light.position.x = -70; + scene.add( light ); + + var light2 = new THREE.PointLight( 0xffdddd, 1.0 ); + light2.position.z = 70; + light2.position.x = -70; + light2.position.y = 70; + scene.add( light2 ); + + var light3 = new THREE.PointLight( 0xddddff, 1.0 ); + light3.position.z = 70; + light3.position.x = 70; + light3.position.y = -70; + scene.add( light3 ); + + var light3 = new THREE.AmbientLight( 0xffffff, 0.05 ); + scene.add( light3 ); + + var geometry = new THREE.SphereBufferGeometry( 3, 48, 24 ); + for ( var i = 0; i < 120; i ++ ) { + + var material = new THREE.MeshStandardMaterial(); + material.roughness = 0.5 * Math.random() + 0.25; + material.metalness = 0; + material.color.setHSL( Math.random(), 1.0, 0.3 ); + + var mesh = new THREE.Mesh( geometry, material ); + mesh.position.x = Math.random() * 4 - 2; + mesh.position.y = Math.random() * 4 - 2; + mesh.position.z = Math.random() * 4 - 2; + mesh.rotation.x = Math.random(); + mesh.rotation.y = Math.random(); + mesh.rotation.z = Math.random(); + + mesh.scale.x = mesh.scale.y = mesh.scale.z = Math.random() * 0.2 + 0.05; + group.add( mesh ); + } + + // postprocessing + + composer = new THREE.EffectComposer( renderer ); + + msaaRenderPass = new THREE.ManualMSAARenderPass( scene, camera ); + composer.addPass( msaaRenderPass ); + + copyPass = new THREE.ShaderPass( THREE.CopyShader ); + copyPass.renderToScreen = true; + composer.addPass( copyPass ); + + window.addEventListener( 'resize', onWindowResize, false ); + + } + + function onWindowResize() { + + var width = window.innerWidth; + var height = window.innerHeight; + + camera.aspect = width / height; + camera.updateProjectionMatrix(); + + renderer.setSize( width, height ); + + var pixelRatio = renderer.getPixelRatio(); + var newWidth = Math.floor( width / pixelRatio ) || 1; + var newHeight = Math.floor( height / pixelRatio ) || 1; + composer.setSize( newWidth, newHeight ); + + } + + function animate() { + + requestAnimationFrame( animate ); + + stats.begin(); + + for ( var i = 0; i < scene.children.length; i ++ ) { + + var child = scene.children[ i ]; + + child.rotation.x += 0.005; + child.rotation.y += 0.01; + + } + + msaaRenderPass.sampleLevel = param.sampleLevel; + msaaRenderPass.unbiased = param.unbiased; + + composer.render(); + stats.end(); + + } + + </script> + <div> + </body> +</html>
true
Other
mrdoob
three.js
bb5600fd89325e7f953996bf0fd6b45e3655e6a8.json
add unbiased mode to the MSAA render pass. (#8930) * add unbiased mode to the MSAA render pass. * clearer code. * better comment. * cleanup code. fix bug of using "camera", instead of "this.camera" * fix more places were "camera" is used instad of "this.camera" -- it worked because example declared "camera" as a global. * reduce light intensity. * add PerspectiveCamera.clearViewOffset() per @mrdoob's recommendation.
examples/webgl_postprocessing_taa.html
@@ -144,6 +144,7 @@ composer = new THREE.EffectComposer( renderer ); taaRenderPass = new THREE.TAARenderPass( scene, camera ); + taaRenderPass.unbiased = false; composer.addPass( taaRenderPass ); renderPass = new THREE.RenderPass( scene, camera );
true
Other
mrdoob
three.js
bb5600fd89325e7f953996bf0fd6b45e3655e6a8.json
add unbiased mode to the MSAA render pass. (#8930) * add unbiased mode to the MSAA render pass. * clearer code. * better comment. * cleanup code. fix bug of using "camera", instead of "this.camera" * fix more places were "camera" is used instad of "this.camera" -- it worked because example declared "camera" as a global. * reduce light intensity. * add PerspectiveCamera.clearViewOffset() per @mrdoob's recommendation.
src/cameras/PerspectiveCamera.js
@@ -155,6 +155,13 @@ THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.p }, + clearViewOffset: function() { + + this.view = null; + this.updateProjectionMatrix(); + + }, + updateProjectionMatrix: function () { var near = this.near,
true
Other
mrdoob
three.js
318c4ccfe77a2ac6541145f7491a95d5f37105ae.json
Fix tga parsing bug of horizontal origin.
examples/js/loaders/TGALoader.js
@@ -390,36 +390,36 @@ THREE.TGALoader.prototype._parser = function ( buffer ) { x_start = 0; x_step = 1; x_end = width; - y_start = 0; - y_step = 1; - y_end = height; + y_start = height - 1; + y_step = -1; + y_end = -1; break; case TGA_ORIGIN_BL: x_start = 0; x_step = 1; x_end = width; - y_start = height - 1; - y_step = - 1; - y_end = - 1; + y_start = 0; + y_step = 1; + y_end = height; break; case TGA_ORIGIN_UR: x_start = width - 1; x_step = - 1; x_end = - 1; - y_start = 0; - y_step = 1; - y_end = height; + y_start = height - 1; + y_step = -1; + y_end = -1; break; case TGA_ORIGIN_BR: x_start = width - 1; x_step = - 1; x_end = - 1; - y_start = height - 1; - y_step = - 1; - y_end = - 1; + y_start = 0; + y_step = 1; + y_end = height; break; }
false
Other
mrdoob
three.js
9f6ff08c78daf2bda2f66f7ed856b6906d11b307.json
use vector operations and pre-optimize
src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
@@ -94,18 +94,9 @@ vec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) { } r = normalize(r); float texelOffset = 0.5 * cubeUV_rcpTextureSize; - float s1 = (r.y/abs(r.x) + 1.0)*0.5; - float s2 = (r.z/abs(r.x) + 1.0)*0.5; - vec2 uv = offset + vec2(s1, s2) * scale; - float min_x = offset.x + texelOffset; - float max_x = offset.x + scale - texelOffset; - float min_y = offset.y + texelOffset; - float max_y = offset.y + scale - texelOffset; - float delx = max_x - min_x; - float dely = max_y - min_y; - uv.x = min_x + s1*delx; - uv.y = min_y + s2*dely; - return uv; + vec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5; + vec2 base = offset + vec2( texelOffset ); + return base + s * ( scale - 2.0 * texelOffset ); } const float cubeUV_maxLods3 = log2(float(CUBE_UV_TEXTURE_SIZE)*0.25) - 3.0;
false
Other
mrdoob
three.js
2ba3e37476013604b660b5da0f7af05aead04f76.json
Add getShaderPrecisionFormat polyfill
src/renderers/WebGLRenderer.js
@@ -221,6 +221,20 @@ THREE.WebGLRenderer = function ( parameters ) { } + if ( _gl.getShaderPrecisionFormat === undefined ) { + + _gl.getShaderPrecisionFormat = function () { + + return { + 'rangeMin': 1, + 'rangeMax': 1, + 'precision': 1 + }; + + } + + } + var capabilities = new THREE.WebGLCapabilities( _gl, extensions, parameters ); var state = new THREE.WebGLState( _gl, extensions, paramThreeToGL );
false
Other
mrdoob
three.js
08055e6a1ac5889a8b639463840ffbaa9bbdfc43.json
add light.power to docs.
docs/api/lights/PointLight.html
@@ -59,6 +59,13 @@ <h3>[property:Float intensity]</h3> Default - *1.0*. </div> + <h3>[property:Float power]</h3> + <div> + Light's power.<br /> + In "physical lights" mode, the luminous power of the light measured in lumens.<br/> + Default - *4PI*. + </div> + <h3>[property:Float distance]</h3> <div> If non-zero, light will attenuate linearly from maximum intensity at light *position* down to zero at *distance*.<br />
true
Other
mrdoob
three.js
08055e6a1ac5889a8b639463840ffbaa9bbdfc43.json
add light.power to docs.
docs/api/lights/SpotLight.html
@@ -81,6 +81,13 @@ <h3>[property:Float intensity]</h3> Default — *1.0*. </div> + <h3>[property:Float power]</h3> + <div> + Light's power.<br /> + In "physical lights" mode, the luminous power of the light measured in lumens.<br/> + Default - *4PI*. + </div> + <h3>[property:Float distance]</h3> <div> If non-zero, light will attenuate linearly from maximum intensity at light *position* down to zero at *distance*.<br />
true
Other
mrdoob
three.js
5d86e3a81722c64305301f34b90513a1712e5a6f.json
add ref for lumens.
examples/webgl_lights_physical.html
@@ -54,10 +54,13 @@ bulbLight, bulbMat, object, loader, stats; + // ref for lumens: http://www.power-sure.com/lumens.htm var lightTypes = { - "60W Bulb (450 cd)": 450, - "40W Bulb (300 cd)": 300, - "20W Bulb (150 cd)": 120 + "100W Bulb (1700 lumen)": 1700, + "60W Bulb (800 lumen)": 800, + "40W Bulb (400 lumen)": 400, + "25W Bulb (180 lumen)": 180, + "4W Bulb (20 lumen)": 20, }; var params = { @@ -196,7 +199,7 @@ var gui = new dat.GUI(); gui.add( params, 'lightType', Object.keys( lightTypes ) ); - gui.add( params, 'exposure', 0, 1 ); + gui.add( params, 'exposure', 0, 3 ); gui.open(); } @@ -228,7 +231,7 @@ var time = Date.now() * 0.0005; var delta = clock.getDelta(); - bulbLight.position.y = Math.cos( time ) * 0.99 + 1.0; + bulbLight.position.y = Math.cos( time ) * 0.75 + 1.25; renderer.render( scene, camera );
false
Other
mrdoob
three.js
450ab30cb89448cbe48b9094fc3e900023966a70.json
fix compatibility issues between PRs.
examples/webgl_tonemapping.html
@@ -39,7 +39,7 @@ <script src="../examples/js/libs/dat.gui.min.js"></script> <script src="../src/loaders/BinaryTextureLoader.js"></script> <script src="../examples/js/loaders/RGBELoader.js"></script> - <script src="../examples/js/loaders/HDRCubeMapLoader.js"></script> + <script src="../examples/js/loaders/HDRCubeTextureLoader.js"></script> <script src="../examples/js/Half.js"></script> <script src="../examples/js/Encodings.js"></script> <script src="../examples/js/pmrem/PMREMGenerator.js"></script> @@ -165,7 +165,7 @@ hdrpath + 'pz' + hdrformat, hdrpath + 'nz' + hdrformat ]; - var hdrCubeMap = new THREE.HDRCubeMapLoader().load( THREE.UnsignedByteType, hdrurls, function ( hdrCubeMap ) { + var hdrCubeMap = new THREE.HDRCubeTextureLoader().load( THREE.UnsignedByteType, hdrurls, function ( hdrCubeMap ) { var pmremGenerator = new THREE.PMREMGenerator( hdrCubeMap ); pmremGenerator.update( renderer );
false
Other
mrdoob
three.js
a30f4d290caf065429cce468463bdba39af0b2d2.json
Fix broken external link
examples/obj/male02/readme.txt
@@ -1,3 +1,3 @@ Model by Reallusion iClone from Google 3d Warehouse: -http://sketchup.google.com/3dwarehouse/details?mid=f526cc4abf7cb68d76cab47c765b7255 \ No newline at end of file +https://3dwarehouse.sketchup.com/user.html?id=0122725873552223594220183
false
Other
mrdoob
three.js
5e44a0e7dbcdebe4b7ef65ad8684d9d1bb8ae463.json
add variable decls yup
examples/js/modifiers/SubdivisionModifier.js
@@ -325,7 +325,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) { newVertices = newSourceVertices.concat( newEdgeVertices ); var sl = newSourceVertices.length, edge1, edge2, edge3; newFaces = []; - + var uv, x0, x1, x2; var x3 = new THREE.Vector2(0, 0); var x4 = new THREE.Vector2(0, 0); var x5 = new THREE.Vector2(0, 0);
false
Other
mrdoob
three.js
8ab4529129cfb80afdc35f18db505fc404ecca87.json
Avoid multiple textureLoaders in for-loops
examples/js/MD2Character.js
@@ -223,13 +223,13 @@ THREE.MD2Character = function () { function loadTextures( baseUrl, textureUrls ) { - var mapping = THREE.UVMapping; + var textureLoader = new THREE.TextureLoader(); var textures = []; for ( var i = 0; i < textureUrls.length; i ++ ) { - textures[ i ] = new THREE.TextureLoader().load( baseUrl + textureUrls[ i ], checkLoadingComplete ); - textures[ i ].mapping = mapping; + textures[ i ] = textureLoader.load( baseUrl + textureUrls[ i ], checkLoadingComplete ); + textures[ i ].mapping = THREE.UVMapping; textures[ i ].name = textureUrls[ i ]; }
true
Other
mrdoob
three.js
8ab4529129cfb80afdc35f18db505fc404ecca87.json
Avoid multiple textureLoaders in for-loops
examples/js/MD2CharacterComplex.js
@@ -506,13 +506,13 @@ THREE.MD2CharacterComplex = function () { function loadTextures( baseUrl, textureUrls ) { - var mapping = THREE.UVMapping; + var textureLoader = new THREE.TextureLoader(); var textures = []; for ( var i = 0; i < textureUrls.length; i ++ ) { - - textures[ i ] = new THREE.TextureLoader().load( baseUrl + textureUrls[ i ], checkLoadingComplete ); - textures[ i ].mapping = mapping; + + textures[ i ] = textureLoader.load( baseUrl + textureUrls[ i ], checkLoadingComplete ); + textures[ i ].mapping = THREE.UVMapping; textures[ i ].name = textureUrls[ i ]; }
true
Other
mrdoob
three.js
8ab4529129cfb80afdc35f18db505fc404ecca87.json
Avoid multiple textureLoaders in for-loops
examples/js/UCSCharacter.js
@@ -91,13 +91,13 @@ THREE.UCSCharacter = function() { function loadTextures( baseUrl, textureUrls ) { - var mapping = THREE.UVMapping; + var textureLoader = new THREE.TextureLoader(); var textures = []; for ( var i = 0; i < textureUrls.length; i ++ ) { - textures[ i ] = new THREE.TextureLoader().load( baseUrl + textureUrls[ i ], scope.checkLoadingComplete ); - textures[ i ].mapping = mapping; + textures[ i ] = textureLoader.load( baseUrl + textureUrls[ i ], scope.checkLoadingComplete ); + textures[ i ].mapping = THREE.UVMapping; textures[ i ].name = textureUrls[ i ]; }
true
Other
mrdoob
three.js
c49ac0847bb1ade3b0efd931c6f97aca064ab889.json
fix statistics calculation for instanced geometry
src/renderers/webgl/WebGLBufferRenderer.js
@@ -37,11 +37,23 @@ THREE.WebGLBufferRenderer = function ( _gl, extensions, _infoRender ) { if ( position instanceof THREE.InterleavedBufferAttribute ) { - extension.drawArraysInstancedANGLE( mode, 0, position.data.count, geometry.maxInstancedCount ); + var count = position.data.count; + + extension.drawArraysInstancedANGLE( mode, 0, count, geometry.maxInstancedCount ); + + _infoRender.calls ++; + _infoRender.vertices += count * geometry.maxInstancedCount; + if ( mode === _gl.TRIANGLES ) _infoRender.faces += geometry.maxInstancedCount * count / 3; } else { - extension.drawArraysInstancedANGLE( mode, 0, position.count, geometry.maxInstancedCount ); + var count = position.count; + + extension.drawArraysInstancedANGLE( mode, 0, count, geometry.maxInstancedCount ); + + _infoRender.calls ++; + _infoRender.vertices += count * geometry.maxInstancedCount; + if ( mode === _gl.TRIANGLES ) _infoRender.faces += geometry.maxInstancedCount * count / 3; }
true
Other
mrdoob
three.js
c49ac0847bb1ade3b0efd931c6f97aca064ab889.json
fix statistics calculation for instanced geometry
src/renderers/webgl/WebGLIndexedBufferRenderer.js
@@ -53,6 +53,9 @@ THREE.WebGLIndexedBufferRenderer = function ( _gl, extensions, _infoRender ) { extension.drawElementsInstancedANGLE( mode, count, type, start * size, geometry.maxInstancedCount ); + _infoRender.calls ++; + _infoRender.vertices += count * geometry.maxInstancedCount; + if ( mode === _gl.TRIANGLES ) _infoRender.faces += geometry.maxInstancedCount * count / 3; } this.setMode = setMode;
true
Other
mrdoob
three.js
1e99bc45784a60784b396f0e86681505594d18f1.json
fix VRControls onError
examples/js/controls/VRControls.js
@@ -21,7 +21,11 @@ THREE.VRControls = function ( object, onError ) { } - if ( onError ) onError( 'HMD not available' ); + if ( vrInputs.length === 0 ) { + + if ( onError ) onError( 'PositionSensorVRDevice not available' ); + + } }
false
Other
mrdoob
three.js
21d8d2781d1451f40b7ee91e6539c3b7a3ee6e5c.json
remove GeometryUtils documenation
docs/api/extras/GeometryUtils.html
@@ -1,60 +0,0 @@ -<!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> - <h1>[name]</h1> - - <div class="desc">Contains handy functions geometry manipulations.</div> - - - <h2>Methods</h2> - - <h3> .merge( [page:Geometry geometry1] , [page:Geometry geometry2], [page:Integer materialIndexOffset] )</h3> - <div> - geometry1 — Parent geometry element <br /> - geometry2 — Geometry that need to be added in parent <br /> - materialIndexOffset — Offset applied to the materialIndex of all the new faces in the merged geometry. Default : 0 <br /> - </div> - - <h3> .randomPointInTriangle( [page:Vector VectorA] , [page:Vector VectorB] , [page:Vector VectorC])</h3> - <div> - VectorA — Vector <br /> - VectorB — Vector <br /> - VectorC — Vector <br /> - - returns [page:Int Point] - - </div> - - - <h3> .center ( [page:Vector VectorA] , [page:Vector VectorB] , [page:Vector VectorC]) </h3> - - <div> - VectorA — Vector <br /> - VectorB — Vector <br /> - VectorC — Vector <br /> - - returns [page:Int Area] - - </div> - - <h3> .center ( [page:Geometry geometry] ) </h3> - - <div> - - Geometry — Geometry to Center position - - </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
21d8d2781d1451f40b7ee91e6539c3b7a3ee6e5c.json
remove GeometryUtils documenation
docs/list.js
@@ -161,7 +161,6 @@ var list = { ], "Extras": [ - [ "GeometryUtils", "api/extras/GeometryUtils" ], [ "SceneUtils", "api/extras/SceneUtils" ] ],
true
Other
mrdoob
three.js
2abf3765ec6e92d8e1540994b31b36a4704ebc72.json
revert empty texture (#8578)
src/renderers/webgl/WebGLState.js
@@ -60,11 +60,6 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) { var currentScissor = new THREE.Vector4(); var currentViewport = new THREE.Vector4(); - var emptyTexture = gl.createTexture(); - gl.bindTexture( gl.TEXTURE_2D, emptyTexture ); - gl.texParameteri( gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR ); - gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, new Uint8Array( 3 ) ); - this.init = function () { this.clearColor( 0, 0, 0, 1 ); @@ -591,7 +586,7 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) { if ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) { - gl.bindTexture( webglType, webglTexture || emptyTexture ); + gl.bindTexture( webglType, webglTexture ); boundTexture.type = webglType; boundTexture.texture = webglTexture;
false
Other
mrdoob
three.js
3cfd6e80f0d52e85367353bc72b8e5b682de9937.json
add method docs intersectsBox method not documented.
docs/api/math/Frustum.html
@@ -81,6 +81,14 @@ <h3>[method:Boolean containsPoint]([page:Vector3 point])</h3> Checks to see if the frustum contains the point. </div> + <h3>[method:Boolean intersectsBox]([page:Box3 box])</h3> + <div> + box -- [page:Box3] + </div> + <div> + Check to see if the box intersects with the frustum. + </div> + <h3>[method:Boolean intersectsSphere]([page:Sphere sphere])</h3> <div> sphere -- [page:Sphere]
false
Other
mrdoob
three.js
3db3411c9d86e0b54cc40c41079c693b4553e17f.json
fix capitalization of "UVGenerator" The docs list it as "uvGenerator" instead of "UVGenerator", took me a while to spot why it wasn't working...
docs/api/extras/geometries/ExtrudeGeometry.html
@@ -1,99 +1,99 @@ -<!DOCTYPE html> -<html lang="en"> - <head> +<!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:Geometry] &rarr; - - <h1>[name]</h1> - - <div class="desc">Creates extruded geometry from a path shape</div> - - - <h2>Constructor</h2> - - - <h3>[name]([page:Array shapes], [page:Object options])</h3> - <div> - shapes — Shape or an array of shapes. <br /> - options — Object that can contain the following parameters. - - <ul> -<li>curveSegments — int. number of points on the curves</li> -<li>steps — int. number of points used for subdividing segements of extrude spline</li> -<li>amount — int. Depth to extrude the shape</li> -<li>bevelEnabled — bool. turn on bevel</li> -<li>bevelThickness — float. how deep into the original shape bevel goes</li> -<li>bevelSize — float. how far from shape outline is bevel</li> -<li>bevelSegments — int. number of bevel layers</li> -<li>extrudePath — THREE.CurvePath. 3d spline path to extrude shape along. (creates Frames if (frames aren't defined)</li> -<li>frames — THREE.TubeGeometry.FrenetFrames. containing arrays of tangents, normals, binormals</li> -<li>material — int. material index for front and back faces</li> -<li>extrudeMaterial — int. material index for extrusion and beveled faces</li> -<li>uvGenerator — Object. object that provides UV generator functions</li> - </ul> - - </div> - <div> - This object extrudes an 2D shape to an 3D geometry. - </div> - - - <h2>Properties</h2> - - - <h2>Methods</h2> - - <h3>[method:null addShapeList]([page:Array shapes], [page:Object options])</h3> - <div> - shapes — An Array of shapes to add. <br /> - options — Object that can contain the following parameters. - <ul> -<li>curveSegments — int. number of points on the curves</li> -<li>steps — int. number of points used for subdividing segements of extrude spline</li> -<li>amount — int. Depth to extrude the shape</li> -<li>bevelEnabled — bool. turn on bevel</li> -<li>bevelThickness — float. how deep into the original shape bevel goes</li> -<li>bevelSize — float. how far from shape outline is bevel</li> -<li>bevelSegments — int. number of bevel layers</li> -<li>extrudePath — THREE.CurvePath. 3d spline path to extrude shape along. (creates Frames if (frames aren't defined)</li> -<li>frames — THREE.TubeGeometry.FrenetFrames. containing arrays of tangents, normals, binormals</li> -<li>material — int. material index for front and back faces</li> -<li>extrudeMaterial — int. material index for extrusion and beveled faces</li> -<li>uvGenerator — Object. object that provides UV generator functions</li> - </ul> - </div> - <div>Adds the shapes to the list to extrude.</div> - - <h3>[method:null addShape]([page:Shape shape], [page:Object options])</h3> - <div> - shape — A shape to add. <br /> - options — Object that can contain the following parameters. - <ul> -<li>curveSegments — int. number of points on the curves</li> -<li>steps — int. number of points used for subdividing segements of extrude spline</li> -<li>amount — int. Depth to extrude the shape</li> -<li>bevelEnabled — bool. turn on bevel</li> -<li>bevelThickness — float. how deep into the original shape bevel goes</li> -<li>bevelSize — float. how far from shape outline is bevel</li> -<li>bevelSegments — int. number of bevel layers</li> -<li>extrudePath — THREE.CurvePath. 3d spline path to extrude shape along. (creates Frames if (frames aren't defined)</li> -<li>frames — THREE.TubeGeometry.FrenetFrames. containing arrays of tangents, normals, binormals</li> -<li>material — int. material index for front and back faces</li> -<li>extrudeMaterial — int. material index for extrusion and beveled faces</li> -<li>uvGenerator — Object. object that provides UV generator functions</li> - </ul> - </div> - <div>Add the shape to the list to extrude.</div> - - - <h2>Source</h2> - - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] - </body> -</html> + <base href="../../../" /> + <script src="list.js"></script> + <script src="page.js"></script> + <link type="text/css" rel="stylesheet" href="page.css" /> + </head> + <body> + [page:Geometry] &rarr; + + <h1>[name]</h1> + + <div class="desc">Creates extruded geometry from a path shape</div> + + + <h2>Constructor</h2> + + + <h3>[name]([page:Array shapes], [page:Object options])</h3> + <div> + shapes — Shape or an array of shapes. <br /> + options — Object that can contain the following parameters. + + <ul> +<li>curveSegments — int. number of points on the curves</li> +<li>steps — int. number of points used for subdividing segements of extrude spline</li> +<li>amount — int. Depth to extrude the shape</li> +<li>bevelEnabled — bool. turn on bevel</li> +<li>bevelThickness — float. how deep into the original shape bevel goes</li> +<li>bevelSize — float. how far from shape outline is bevel</li> +<li>bevelSegments — int. number of bevel layers</li> +<li>extrudePath — THREE.CurvePath. 3d spline path to extrude shape along. (creates Frames if (frames aren't defined)</li> +<li>frames — THREE.TubeGeometry.FrenetFrames. containing arrays of tangents, normals, binormals</li> +<li>material — int. material index for front and back faces</li> +<li>extrudeMaterial — int. material index for extrusion and beveled faces</li> +<li>UVGenerator — Object. object that provides UV generator functions</li> + </ul> + + </div> + <div> + This object extrudes an 2D shape to an 3D geometry. + </div> + + + <h2>Properties</h2> + + + <h2>Methods</h2> + + <h3>[method:null addShapeList]([page:Array shapes], [page:Object options])</h3> + <div> + shapes — An Array of shapes to add. <br /> + options — Object that can contain the following parameters. + <ul> +<li>curveSegments — int. number of points on the curves</li> +<li>steps — int. number of points used for subdividing segements of extrude spline</li> +<li>amount — int. Depth to extrude the shape</li> +<li>bevelEnabled — bool. turn on bevel</li> +<li>bevelThickness — float. how deep into the original shape bevel goes</li> +<li>bevelSize — float. how far from shape outline is bevel</li> +<li>bevelSegments — int. number of bevel layers</li> +<li>extrudePath — THREE.CurvePath. 3d spline path to extrude shape along. (creates Frames if (frames aren't defined)</li> +<li>frames — THREE.TubeGeometry.FrenetFrames. containing arrays of tangents, normals, binormals</li> +<li>material — int. material index for front and back faces</li> +<li>extrudeMaterial — int. material index for extrusion and beveled faces</li> +<li>UVGenerator — Object. object that provides UV generator functions</li> + </ul> + </div> + <div>Adds the shapes to the list to extrude.</div> + + <h3>[method:null addShape]([page:Shape shape], [page:Object options])</h3> + <div> + shape — A shape to add. <br /> + options — Object that can contain the following parameters. + <ul> +<li>curveSegments — int. number of points on the curves</li> +<li>steps — int. number of points used for subdividing segements of extrude spline</li> +<li>amount — int. Depth to extrude the shape</li> +<li>bevelEnabled — bool. turn on bevel</li> +<li>bevelThickness — float. how deep into the original shape bevel goes</li> +<li>bevelSize — float. how far from shape outline is bevel</li> +<li>bevelSegments — int. number of bevel layers</li> +<li>extrudePath — THREE.CurvePath. 3d spline path to extrude shape along. (creates Frames if (frames aren't defined)</li> +<li>frames — THREE.TubeGeometry.FrenetFrames. containing arrays of tangents, normals, binormals</li> +<li>material — int. material index for front and back faces</li> +<li>extrudeMaterial — int. material index for extrusion and beveled faces</li> +<li>UVGenerator — Object. object that provides UV generator functions</li> + </ul> + </div> + <div>Add the shape to the list to extrude.</div> + + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + </body> +</html>
false
Other
mrdoob
three.js
6dd16bf1c5d030e00ea7036b6b8ef4aeca5366b4.json
add reflectivity example.
examples/files.js
@@ -129,6 +129,7 @@ var files = { "webgl_materials_nodes", "webgl_materials_normalmap", "webgl_materials_parallaxmap", + "webgl_materials_reflectivity", "webgl_materials_shaders_fresnel", "webgl_materials_skin", "webgl_materials_standard",
true
Other
mrdoob
three.js
6dd16bf1c5d030e00ea7036b6b8ef4aeca5366b4.json
add reflectivity example.
examples/models/obj/emerald.obj
@@ -0,0 +1,312 @@ +# Blender v2.74 (sub 0) OBJ File: '' +# www.blender.org +mtllib diamond-for-threejs.mtl +o emerald_obj_1 +v -3.292856 5.746839 5.366825 +v -4.692856 5.043496 4.000000 +v -4.692857 -5.043496 4.000000 +v -3.292857 -5.746839 5.366825 +v -4.692856 5.043496 -4.000000 +v -3.292856 5.746839 -5.366825 +v -3.292857 -5.746839 -5.366825 +v -4.692857 -5.043496 -4.000000 +v -3.292858 -8.649050 3.181548 +v -4.692858 -7.590510 2.371271 +v -4.692858 -7.590510 -2.371271 +v -3.292858 -8.649050 -3.181548 +v -3.292856 8.649050 -3.181548 +v -4.692856 7.590510 -2.371271 +v -4.692856 7.590510 2.371271 +v -3.292856 8.649050 3.181548 +v 4.739632 7.649404 2.869210 +v 4.739632 5.082627 4.839954 +v 4.739630 -5.082630 4.839954 +v 4.739630 -7.649406 2.869211 +v 4.739630 -7.649406 -2.869211 +v 4.739630 -5.082630 -4.839954 +v 4.739632 5.082627 -4.839954 +v 4.739632 7.649404 -2.869210 +v -5.038335 4.756373 -0.096954 +v -5.038335 3.439395 -0.163548 +v -5.038336 -3.439395 -0.163548 +v -5.038337 -4.756373 -0.096954 +v -5.038337 -4.756373 0.096954 +v -5.038336 -3.439395 0.163548 +v -5.038335 3.439395 0.163548 +v -5.038335 4.756373 0.096954 +v -1.570719 6.404040 7.078050 +v -1.570719 9.638143 4.195993 +v -1.570721 -6.404041 7.078050 +v -1.570721 -9.638143 4.195993 +v -1.570721 -9.638143 -4.195993 +v -1.570721 -6.404041 -7.078050 +v -1.570719 6.404040 -7.078050 +v -1.570719 9.638143 -4.195993 +v 1.184699 7.289807 8.431552 +v 1.184699 10.971231 4.998373 +v 1.184697 -7.289809 8.431552 +v 1.184696 -10.971232 4.998374 +v 1.184696 -10.971232 -4.998374 +v 1.184697 -7.289809 -8.431552 +v 1.184699 7.289807 -8.431552 +v 1.184699 10.971231 -4.998373 +v 1.676783 7.289807 8.431552 +v 1.676784 10.971231 4.998373 +v 1.676781 -7.289809 8.431552 +v 1.676781 -10.971232 4.998374 +v 1.676781 -10.971232 -4.998374 +v 1.676781 -7.289809 -8.431552 +v 1.676783 7.289807 -8.431552 +v 1.676784 10.971231 -4.998373 +v 2.759176 6.861979 7.557796 +v 2.759176 10.327344 4.480395 +v 2.759174 -6.861980 7.557796 +v 2.759173 -10.327346 4.480397 +v 2.759173 -10.327346 -4.480397 +v 2.759174 -6.861980 -7.557796 +v 2.759176 6.861979 -7.557796 +v 2.759176 10.327344 -4.480395 +v 4.050778 5.880537 6.214112 +v 4.050778 8.850266 3.683835 +v 4.050776 -5.880539 6.214112 +v 4.050776 -8.850267 3.683837 +v 4.050776 -8.850267 -3.683837 +v 4.050776 -5.880539 -6.214112 +v 4.050778 5.880537 -6.214112 +v 4.050778 8.850266 -3.683835 +vn -0.698600 0.000000 0.715500 +vn -0.698600 0.000000 -0.715500 +vn -0.603100 -0.797700 0.000000 +vn -0.603100 0.797700 0.000000 +vn 1.000000 -0.000000 -0.000000 +vn -1.000000 0.000000 -0.000000 +vn -0.737800 0.363600 0.568600 +vn -0.675900 0.443300 0.588700 +vn -0.666900 -0.401400 0.627800 +vn -0.734400 -0.408200 0.542200 +vn -0.734400 0.408200 -0.542200 +vn -0.666900 0.401400 -0.627800 +vn -0.675900 -0.443300 -0.588700 +vn -0.737800 -0.363600 -0.568600 +vn -0.715200 0.420400 0.558300 +vn -0.635000 0.514000 0.576800 +vn -0.704900 0.000000 0.709400 +vn -0.632200 -0.466000 0.618900 +vn -0.705600 -0.471400 0.529000 +vn -0.498000 -0.867200 0.000000 +vn -0.715200 -0.420400 -0.558300 +vn -0.635000 -0.514000 -0.576800 +vn -0.704900 0.000000 -0.709400 +vn -0.632200 0.466000 -0.618900 +vn -0.705600 0.471400 -0.529000 +vn -0.498000 0.867200 0.000000 +vn -0.502100 0.575400 0.645600 +vn -0.477100 0.599400 0.642700 +vn -0.440900 0.000000 0.897600 +vn -0.474700 -0.585600 0.657100 +vn -0.500700 -0.590400 0.633000 +vn -0.435500 -0.900200 0.000000 +vn -0.502100 -0.575400 -0.645600 +vn -0.477100 -0.599400 -0.642700 +vn -0.440900 0.000000 -0.897600 +vn -0.474700 0.585600 -0.657100 +vn -0.500700 0.590400 -0.633000 +vn -0.435500 0.900200 0.000000 +vn 0.000000 0.682000 0.731300 +vn 0.000000 0.000000 1.000000 +vn 0.000000 -0.682000 0.731300 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -0.682000 -0.731300 +vn 0.000000 0.000000 -1.000000 +vn 0.000000 0.682000 -0.731300 +vn 0.000000 1.000000 0.000000 +vn 0.652000 0.517100 0.554500 +vn 0.601400 0.530500 0.597400 +vn 0.628100 -0.000000 0.778100 +vn 0.602900 -0.544100 0.583500 +vn 0.654700 -0.501900 0.565200 +vn 0.511300 -0.859400 0.000000 +vn 0.652000 -0.517100 -0.554500 +vn 0.601400 -0.530500 -0.597400 +vn 0.628100 -0.000000 -0.778100 +vn 0.602900 0.544100 -0.583500 +vn 0.654700 0.501900 -0.565200 +vn 0.511300 0.859400 0.000000 +vn 0.788600 0.408300 0.459800 +vn 0.771100 0.412900 0.484600 +vn 0.720900 -0.000000 0.693000 +vn 0.773500 -0.420800 0.473900 +vn 0.789100 -0.398400 0.467600 +vn 0.752800 -0.658300 0.000000 +vn 0.788600 -0.408300 -0.459800 +vn 0.771100 -0.412900 -0.484600 +vn 0.720900 -0.000000 -0.693000 +vn 0.773500 0.420800 -0.473900 +vn 0.789100 0.398400 -0.467600 +vn 0.752800 0.658300 0.000000 +vn 0.915100 0.261500 0.306900 +vn 0.894400 0.272400 0.354800 +vn 0.894000 -0.000000 0.448100 +vn 0.897100 -0.286500 0.336300 +vn 0.916300 -0.243900 0.317700 +vn 0.867400 -0.497600 0.000000 +vn 0.915100 -0.261500 -0.306900 +vn 0.894400 -0.272400 -0.354800 +vn 0.894000 -0.000000 -0.448100 +vn 0.897100 0.286500 -0.336300 +vn 0.916300 0.243900 -0.317700 +vn 0.867400 0.497600 0.000000 +vn -0.996500 0.045300 -0.070800 +vn -0.989900 0.007200 -0.141500 +vn -0.996000 0.000000 -0.089700 +vn -0.995000 -0.053800 -0.084100 +vn -0.996100 -0.004400 -0.087800 +vn -0.992700 -0.121000 0.000000 +vn -0.996500 -0.045300 0.070800 +vn -0.989900 -0.007200 0.141500 +vn -0.996000 0.000000 0.089700 +vn -0.995000 0.053800 0.084100 +vn -0.996100 0.004400 0.087800 +vn -0.992700 0.121000 0.000000 +usemtl emerald_obj_1Default +s off +f 1//1 2//1 3//1 +f 1//1 3//1 4//1 +f 5//2 6//2 7//2 +f 5//2 7//2 8//2 +f 9//3 10//3 11//3 +f 9//3 11//3 12//3 +f 13//4 14//4 15//4 +f 13//4 15//4 16//4 +f 17//5 18//5 19//5 +f 17//5 19//5 20//5 +f 17//5 20//5 21//5 +f 17//5 21//5 22//5 +f 17//5 22//5 23//5 +f 17//5 23//5 24//5 +f 25//6 26//6 27//6 +f 25//6 27//6 28//6 +f 25//6 28//6 29//6 +f 25//6 29//6 30//6 +f 25//6 30//6 31//6 +f 25//6 31//6 32//6 +f 15//7 2//7 1//7 +f 15//8 1//8 16//8 +f 3//9 10//9 9//9 +f 3//10 9//10 4//10 +f 13//11 6//11 5//11 +f 13//12 5//12 14//12 +f 7//13 12//13 11//13 +f 7//14 11//14 8//14 +f 16//15 1//15 33//15 +f 16//16 33//16 34//16 +f 1//17 4//17 35//17 +f 1//17 35//17 33//17 +f 4//18 9//18 36//18 +f 4//19 36//19 35//19 +f 9//20 12//20 37//20 +f 9//20 37//20 36//20 +f 12//21 7//21 38//21 +f 12//22 38//22 37//22 +f 7//23 6//23 39//23 +f 7//23 39//23 38//23 +f 6//24 13//24 40//24 +f 6//25 40//25 39//25 +f 13//26 16//26 34//26 +f 13//26 34//26 40//26 +f 34//27 33//27 41//27 +f 34//28 41//28 42//28 +f 33//29 35//29 43//29 +f 33//29 43//29 41//29 +f 35//30 36//30 44//30 +f 35//31 44//31 43//31 +f 36//32 37//32 45//32 +f 36//32 45//32 44//32 +f 37//33 38//33 46//33 +f 37//34 46//34 45//34 +f 38//35 39//35 47//35 +f 38//35 47//35 46//35 +f 39//36 40//36 48//36 +f 39//37 48//37 47//37 +f 40//38 34//38 42//38 +f 40//38 42//38 48//38 +f 42//39 41//39 49//39 +f 42//39 49//39 50//39 +f 41//40 43//40 51//40 +f 41//40 51//40 49//40 +f 43//41 44//41 52//41 +f 43//41 52//41 51//41 +f 44//42 45//42 53//42 +f 44//42 53//42 52//42 +f 45//43 46//43 54//43 +f 45//43 54//43 53//43 +f 46//44 47//44 55//44 +f 46//44 55//44 54//44 +f 47//45 48//45 56//45 +f 47//45 56//45 55//45 +f 48//46 42//46 50//46 +f 48//46 50//46 56//46 +f 50//47 49//47 57//47 +f 50//48 57//48 58//48 +f 49//49 51//49 59//49 +f 49//49 59//49 57//49 +f 51//50 52//50 60//50 +f 51//51 60//51 59//51 +f 52//52 53//52 61//52 +f 52//52 61//52 60//52 +f 53//53 54//53 62//53 +f 53//54 62//54 61//54 +f 54//55 55//55 63//55 +f 54//55 63//55 62//55 +f 55//56 56//56 64//56 +f 55//57 64//57 63//57 +f 56//58 50//58 58//58 +f 56//58 58//58 64//58 +f 58//59 57//59 65//59 +f 58//60 65//60 66//60 +f 57//61 59//61 67//61 +f 57//61 67//61 65//61 +f 59//62 60//62 68//62 +f 59//63 68//63 67//63 +f 60//64 61//64 69//64 +f 60//64 69//64 68//64 +f 61//65 62//65 70//65 +f 61//66 70//66 69//66 +f 62//67 63//67 71//67 +f 62//67 71//67 70//67 +f 63//68 64//68 72//68 +f 63//69 72//69 71//69 +f 64//70 58//70 66//70 +f 64//70 66//70 72//70 +f 66//71 65//71 18//71 +f 66//72 18//72 17//72 +f 65//73 67//73 19//73 +f 65//73 19//73 18//73 +f 67//74 68//74 20//74 +f 67//75 20//75 19//75 +f 68//76 69//76 21//76 +f 68//76 21//76 20//76 +f 69//77 70//77 22//77 +f 69//78 22//78 21//78 +f 70//79 71//79 23//79 +f 70//79 23//79 22//79 +f 71//80 72//80 24//80 +f 71//81 24//81 23//81 +f 72//82 66//82 17//82 +f 72//82 17//82 24//82 +f 14//83 5//83 26//83 +f 14//84 26//84 25//84 +f 5//85 8//85 27//85 +f 5//85 27//85 26//85 +f 8//86 11//86 28//86 +f 8//87 28//87 27//87 +f 11//88 10//88 29//88 +f 11//88 29//88 28//88 +f 10//89 3//89 30//89 +f 10//90 30//90 29//90 +f 3//91 2//91 31//91 +f 3//91 31//91 30//91 +f 2//92 15//92 32//92 +f 2//93 32//93 31//93 +f 15//94 14//94 25//94 +f 15//94 25//94 32//94
true
Other
mrdoob
three.js
6dd16bf1c5d030e00ea7036b6b8ef4aeca5366b4.json
add reflectivity example.
examples/webgl_materials_reflectivity.html
@@ -0,0 +1,291 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <title>threejs webgl - materials - hdr environment mapping</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> + <style> + body { + color: #fff; + font-family:Monospace; + font-size:13px; + text-align:center; + + background-color: #000; + + margin: 0px; + overflow: hidden; + } + a { color: #88f } + + #info { + position: absolute; + top: 0px; width: 100%; + padding: 5px; + } + </style> + </head> + <body> + + <div id="container"></div> + <div id="info"><a href="http://threejs.org" target="_blank">threejs</a> - Standard Material Reflectivity (reflectance at F0) example by <a href="http://clara.io/" target="_blank">Ben Houston</a>.</div> + + <script src="../build/three.js"></script> + <script src="js/controls/OrbitControls.js"></script> + <script src="js/loaders/RGBELoader.js"></script> + <script src="js/loaders/HDRCubeTextureLoader.js"></script> + + <script src="js/Detector.js"></script> + <script src="js/libs/stats.min.js"></script> + + <script src="js/Half.js"></script> + <script src="js/Encodings.js"></script> + <script src="js/pmrem/PMREMGenerator.js"></script> + <script src="js/pmrem/PMREMCubeUVPacker.js"></script> + <script src="js/libs/dat.gui.min.js"></script> + + <script src="js/postprocessing/EffectComposer.js"></script> + <script src="js/postprocessing/RenderPass.js"></script> + <script src="js/postprocessing/MaskPass.js"></script> + <script src="js/postprocessing/ShaderPass.js"></script> + <script src="js/shaders/CopyShader.js"></script> + <script src="js/shaders/FXAAShader.js"></script> + <script src="js/postprocessing/BloomPass.js"></script> + <script src="js/shaders/ConvolutionShader.js"></script> + + <script src="js/loaders/OBJLoader.js"></script> + <script> + + if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); + + var container, stats; + var params = { + projection: 'normal', + autoRotate: true, + reflectivity: 1.0, + background: false, + exposure: 1.0, + gemColor: 'Green' + }; + var camera, scene, renderer, controls, objects = []; + var hdrCubeMap; + var composer; + var gemBackMaterial, gemFrontMaterial; + var hdrCubeRenderTarget; + + init(); + animate(); + + function init() { + + container = document.createElement( 'div' ); + document.body.appendChild( container ); + + camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 2000 ); + camera.position.set( 0.0, -10, 20 * 3.5 ); + + scene = new THREE.Scene(); + + renderer = new THREE.WebGLRenderer( { antialias: true } ); + renderer.setClearColor( new THREE.Color( 0x000000 ) ); + + gemBackMaterial = new THREE.MeshPhysicalMaterial( { + map: null, + color: 0x0000ff, + metalness: 1.0, + roughness: 0, + opacity: 0.5, + side: THREE.BackSide, + transparent: true, + shading: THREE.SmoothShading, + envMapIntensity: 5, + premultipliedAlpha: true + // TODO: Add custom blend mode that modulates background color by this materials color. + } ); + + gemFrontMaterial = new THREE.MeshPhysicalMaterial( { + map: null, + color: 0x0000ff, + metalness: 0.0, + roughness: 0, + opacity: 0.15, + side: THREE.FrontSide, + transparent: true, + shading: THREE.SmoothShading, + envMapIntensity: 5, + premultipliedAlpha: true + } ); + + var manager = new THREE.LoadingManager(); + manager.onProgress = function ( item, loaded, total ) { + + console.log( item, loaded, total ); + + }; + + var loader = new THREE.OBJLoader( manager ); + loader.load( 'models/obj/emerald.obj', function ( object ) { + + object.traverse( function ( child ) { + + if ( child instanceof THREE.Mesh ) { + + child.material = gemBackMaterial; + var second = child.clone(); + second.material = gemFrontMaterial; + + var parent = new THREE.Group(); + parent.add( second ); + parent.add( child ); + scene.add( parent ); + + objects.push( parent ); + + } + + } ); + + + } ); + + var genCubeUrls = function( prefix, postfix ) { + return [ + prefix + 'px' + postfix, prefix + 'nx' + postfix, + prefix + 'py' + postfix, prefix + 'ny' + postfix, + prefix + 'pz' + postfix, prefix + 'nz' + postfix + ]; + }; + + var hdrUrls = genCubeUrls( "./textures/cube/pisaHDR/", ".hdr" ); + new THREE.HDRCubeTextureLoader().load( THREE.UnsignedByteType, hdrUrls, function ( hdrCubeMap ) { + + var pmremGenerator = new THREE.PMREMGenerator( hdrCubeMap ); + pmremGenerator.update( renderer ); + + var pmremCubeUVPacker = new THREE.PMREMCubeUVPacker( pmremGenerator.cubeLods ); + pmremCubeUVPacker.update( renderer ); + + hdrCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget; + + gemFrontMaterial.envMap = gemBackMaterial.envMap = hdrCubeRenderTarget; + gemFrontMaterial.needsUpdate = gemBackMaterial.needsUpdate = true; + } ); + + + // Lights + + scene.add( new THREE.AmbientLight( 0x222222 ) ); + + var pointLight1 = new THREE.PointLight( 0xffffff ); + pointLight1.position.set( 150, 10, 0 ); + pointLight1.castShadow = false; + scene.add( pointLight1 ); + + var pointLight2 = new THREE.PointLight( 0xffffff ); + pointLight2.position.set( -150, 0, 0 ); + scene.add( pointLight2 ); + + var pointLight3 = new THREE.PointLight( 0xffffff ); + pointLight3.position.set( 0, -10, -150 ); + scene.add( pointLight3 ); + + var pointLight4 = new THREE.PointLight( 0xffffff ); + pointLight4.position.set( 0, 0, 150 ); + scene.add( pointLight4 ); + + renderer.setPixelRatio( window.devicePixelRatio ); + renderer.setSize( window.innerWidth, window.innerHeight ); + renderer.shadowMap.enabled = true; + container.appendChild( renderer.domElement ); + + renderer.gammaInput = true; + renderer.gammaOutput = true; + + stats = new Stats(); + stats.domElement.style.position = 'absolute'; + stats.domElement.style.top = '0px'; + + container.appendChild( stats.domElement ); + + controls = new THREE.OrbitControls( camera, renderer.domElement ); + controls.target.set( 0, 0, 0 ); + controls.update(); + + window.addEventListener( 'resize', onWindowResize, false ); + + var gui = new dat.GUI(); + + gui.add( params, 'reflectivity', 0, 1 ); + gui.add( params, 'exposure', 0.1, 2 ); + gui.add( params, 'autoRotate' ); + gui.add( params, 'gemColor', [ 'Blue', 'Green', 'Red', 'White', 'Black' ] ); + gui.open(); + + } + + function onWindowResize() { + + var width = window.innerWidth; + var height = window.innerHeight; + + camera.aspect = width / height; + camera.updateProjectionMatrix(); + + renderer.setSize( width, height ); + + } + + // + + function animate() { + + requestAnimationFrame( animate ); + + stats.begin(); + render(); + stats.end(); + + } + + function render() { + + if ( gemBackMaterial !== undefined && gemFrontMaterial !== undefined ) { + + gemFrontMaterial.reflectivity = gemBackMaterial.reflectivity = params.reflectivity; + + var newColor = gemBackMaterial.color; + switch( params.gemColor ) { + case 'Blue': newColor = new THREE.Color( 0x000088 ); break; + case 'Red': newColor = new THREE.Color( 0x880000 ); break; + case 'Green': newColor = new THREE.Color( 0x008800 ); break; + case 'White': newColor = new THREE.Color( 0x888888 ); break; + case 'Black': newColor = new THREE.Color( 0x0f0f0f ); break; + } + gemBackMaterial.color = gemFrontMaterial.color = newColor; + + + } + + renderer.toneMappingExposure = params.exposure; + + var timer = Date.now() * 0.00025; + + camera.lookAt( scene.position ); + + if( params.autoRotate ) { + for ( var i = 0, l = objects.length; i < l; i ++ ) { + + var object = objects[ i ]; + object.rotation.y += 0.005; + + } + } + + renderer.render( scene, camera ); + + } + + </script> + + </body> +</html>
true
Other
mrdoob
three.js
c290352133019105f3be6232db0ecf1f16f591de.json
simplify light factories.
src/renderers/shaders/ShaderChunk/lights.glsl
@@ -10,11 +10,14 @@ uniform vec3 ambientLightColor; uniform DirectionalLight directionalLights[ MAX_DIR_LIGHTS ]; - void getDirectionalDirectLight( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) { + IncidentLight getDirectionalDirectLight( const in DirectionalLight directionalLight, const in GeometricContext geometry ) { + + IncidentLight directLight; directLight.color = directionalLight.color; directLight.direction = directionalLight.direction; + return directLight; } #endif @@ -31,8 +34,10 @@ uniform vec3 ambientLightColor; uniform PointLight pointLights[ MAX_POINT_LIGHTS ]; - void getPointDirectLight( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) { + IncidentLight getPointDirectLight( const in PointLight pointLight, const in GeometricContext geometry ) { + IncidentLight directLight; + vec3 lightPosition = pointLight.position; vec3 lVector = lightPosition - geometry.position; @@ -41,6 +46,7 @@ uniform vec3 ambientLightColor; directLight.color = pointLight.color; directLight.color *= calcLightAttenuation( length( lVector ), pointLight.distance, pointLight.decay ); + return directLight; } #endif @@ -60,8 +66,10 @@ uniform vec3 ambientLightColor; uniform SpotLight spotLights[ MAX_SPOT_LIGHTS ]; - void getSpotDirectLight( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) { + IncidentLight getSpotDirectLight( const in SpotLight spotLight, const in GeometricContext geometry ) { + IncidentLight directLight; + vec3 lightPosition = spotLight.position; vec3 lVector = lightPosition - geometry.position; @@ -73,6 +81,7 @@ uniform vec3 ambientLightColor; directLight.color = spotLight.color; directLight.color *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) ); + return directLight; } #endif @@ -88,14 +97,17 @@ uniform vec3 ambientLightColor; uniform HemisphereLight hemisphereLights[ MAX_HEMI_LIGHTS ]; - void getHemisphereIndirectLight( const in HemisphereLight hemiLight, const in GeometricContext geometry, out IncidentLight indirectLight ) { + IncidentLight getHemisphereIndirectLight( const in HemisphereLight hemiLight, const in GeometricContext geometry ) { + IncidentLight directLight; + float dotNL = dot( geometry.normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; indirectLight.color = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); indirectLight.direction = geometry.normal; + return indirectLight; } #endif
true
Other
mrdoob
three.js
c290352133019105f3be6232db0ecf1f16f591de.json
simplify light factories.
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
@@ -10,9 +10,7 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) ); for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) { - IncidentLight directLight; - - getPointDirectLight( pointLights[ i ], geometry, directLight ); + IncidentLight directLight = getPointDirectLight( pointLights[ i ], geometry ); BRDF_Lambert( directLight, geometry, diffuse, frontReflectedLight ); @@ -30,9 +28,7 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) ); for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) { - IncidentLight directLight; - - getSpotDirectLight( spotLights[ i ], geometry, directLight ); + IncidentLight directLight = getSpotDirectLight( spotLights[ i ], geometry ); BRDF_Lambert( directLight, geometry, diffuse, frontReflectedLight ); @@ -50,9 +46,7 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) ); for ( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) { - IncidentLight directLight; - - getDirectionalDirectLight( directionalLights[ i ], geometry, directLight ); + IncidentLight directLight = getDirectionalDirectLight( directionalLights[ i ], geometry ); BRDF_Lambert( directLight, geometry, diffuse, frontReflectedLight ); @@ -70,9 +64,7 @@ ReflectedLight backReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) ); for ( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) { - IncidentLight indirectLight; - - getHemisphereIndirectLight( hemisphereLights[ i ], geometry, indirectLight ); + IncidentLight indirectLight = getHemisphereIndirectLight( hemisphereLights[ i ], geometry ); BRDF_Lambert( indirectLight, geometry, diffuse, frontReflectedLight );
true
Other
mrdoob
three.js
c290352133019105f3be6232db0ecf1f16f591de.json
simplify light factories.
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
@@ -25,9 +25,7 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) { - IncidentLight directLight; - - getPointDirectLight( pointLights[ i ], geometry, directLight ); + IncidentLight directLight = getPointDirectLight( pointLights[ i ], geometry ); BRDF_Lambert( directLight, geometry, diffuse, directReflectedLight ); //BRDF_OrenNayar( directLight, geometry, diffuse, 0.5, directReflectedLight ); @@ -42,9 +40,7 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) { - IncidentLight directLight; - - getSpotDirectLight( spotLights[ i ], geometry, directLight ); + IncidentLight directLight = getSpotDirectLight( spotLights[ i ], geometry ); BRDF_Lambert( directLight, geometry, diffuse, directReflectedLight ); //BRDF_OrenNayar( directLight, geometry, diffuse, 0.5, directReflectedLight ); @@ -59,9 +55,7 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) { - IncidentLight directLight; - - getDirectionalDirectLight( directionalLights[ i ], geometry, directLight ); + IncidentLight directLight = getDirectionalDirectLight( directionalLights[ i ], geometry ); BRDF_Lambert( directLight, geometry, diffuse, directReflectedLight ); //BRDF_OrenNayar( directLight, geometry, diffuse, 0.5, directReflectedLight ); @@ -76,9 +70,7 @@ ReflectedLight indirectReflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ) for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) { - IncidentLight indirectLight; - - getHemisphereIndirectLight( hemisphereLights[ i ], geometry, indirectLight ); + IncidentLight indirectLight = getHemisphereIndirectLight( hemisphereLights[ i ], geometry ); BRDF_Lambert( indirectLight, geometry, diffuse, indirectReflectedLight ); //BRDF_OrenNayar( indirectLight, geometry, diffuse, 0.5, indirectReflectedLight );
true
Other
mrdoob
three.js
0287cab597c854f48b859cbf7eeb5f8b995d6314.json
remove unused code from broken ShaderSkin.js
examples/js/ShaderSkin.js
@@ -455,12 +455,11 @@ THREE.ShaderSkin = { "#if MAX_POINT_LIGHTS > 0", "for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {", - + "vec3 pointVector = normalize( pointLights[ i ].direction );", + "float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );", "float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );", - - "float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );", "totalDiffuseLight += pointLightColor[ i ] * ( pointDiffuseWeight * attenuation );", @@ -577,7 +576,6 @@ THREE.ShaderSkin = { "varying vec3 vViewPosition;", THREE.ShaderChunk[ "common" ], - THREE.ShaderChunk[ "lights" ], "void main() {", @@ -591,24 +589,6 @@ THREE.ShaderSkin = { "vUv = uv;", - // point lights - - "#if MAX_POINT_LIGHTS > 0", - - "for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {", - - "vec3 lVector = pointLights[ i ].position - vViewPosition;", - - "float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );", - - "lVector = normalize( lVector );", - - "vPointLight[ i ] = vec4( lVector, attenuation );", - - "}", - - "#endif", - // displacement mapping "#ifdef VERTEX_TEXTURES", @@ -636,7 +616,6 @@ THREE.ShaderSkin = { "varying vec3 vViewPosition;", THREE.ShaderChunk[ "common" ], - THREE.ShaderChunk[ "lights" ], "void main() {", @@ -650,24 +629,6 @@ THREE.ShaderSkin = { "vUv = uv;", - // point lights - - "#if MAX_POINT_LIGHTS > 0", - - "for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {", - - "vec3 lVector = pointLights[ i ].position - vViewPosition;", - - "float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );", - - "lVector = normalize( lVector );", - - "vPointLight[ i ] = vec4( lVector, attenuation );", - - "}", - - "#endif", - "gl_Position = vec4( uv.x * 2.0 - 1.0, uv.y * 2.0 - 1.0, 0.0, 1.0 );", "}"
false
Other
mrdoob
three.js
c21a28c4b1155b9d95fe91ea9dc6669ec30aa075.json
put isIntersectionSphere inside a closure
src/math/Box3.js
@@ -247,15 +247,23 @@ THREE.Box3.prototype = { }, - isIntersectionSphere: function ( sphere ) { + isIntersectionSphere: function () { - // Find the point on the AABB closest to the sphere center. - var closestPoint = this.clampPoint( sphere.center ); + var closestPoint; - // If that point is inside the sphere, the AABB and sphere intersect. - return closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ) + return function isIntersectionSphere( sphere ) { - }, + if ( closestPoint === undefined ) closestPoint = new THREE.Vector3(); + + // Find the point on the AABB closest to the sphere center. + this.clampPoint( sphere.center, closestPoint ); + + // If that point is inside the sphere, the AABB and sphere intersect. + return closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ); + + }; + + }(), clampPoint: function ( point, optionalTarget ) {
false
Other
mrdoob
three.js
d31d47352a0febb4540a26e916c26324a0189382.json
remove colorAmbient from Blender exporter
utils/exporters/blender/addons/io_three/constants.py
@@ -272,7 +272,6 @@ TIME = 'time' KEYS = 'keys' -AMBIENT = 'ambient' COLOR = 'color' EMISSIVE = 'emissive' SPECULAR = 'specular' @@ -352,7 +351,6 @@ SHADING = 'shading' COLOR_DIFFUSE = 'colorDiffuse' -COLOR_AMBIENT = 'colorAmbient' COLOR_EMISSIVE = 'colorEmissive' COLOR_SPECULAR = 'colorSpecular' DBG_NAME = 'DbgName'
true
Other
mrdoob
three.js
d31d47352a0febb4540a26e916c26324a0189382.json
remove colorAmbient from Blender exporter
utils/exporters/blender/addons/io_three/exporter/api/material.py
@@ -30,22 +30,6 @@ def inner(name, *args, **kwargs): return inner -@_material -def ambient_color(material): - """ - - :param material: - :return: rgb value - :rtype: tuple - - """ - logger.debug("material.ambient_color(%s)", material) - diffuse = diffuse_color(material) - return (material.ambient * diffuse[0], - material.ambient * diffuse[1], - material.ambient * diffuse[2]) - - @_material def blending(material): """
true
Other
mrdoob
three.js
d31d47352a0febb4540a26e916c26324a0189382.json
remove colorAmbient from Blender exporter
utils/exporters/blender/addons/io_three/exporter/api/mesh.py
@@ -527,7 +527,6 @@ def materials(mesh, options): logger.info("Compiling attributes for %s", mat.name) attributes = { - constants.COLOR_AMBIENT: material.ambient_color(mat), constants.COLOR_EMISSIVE: material.emissive_color(mat), constants.SHADING: material.shading(mat), constants.OPACITY: material.opacity(mat),
true
Other
mrdoob
three.js
d31d47352a0febb4540a26e916c26324a0189382.json
remove colorAmbient from Blender exporter
utils/exporters/blender/addons/io_three/exporter/material.py
@@ -32,9 +32,6 @@ def _common_attributes(self): self[constants.COLOR] = utilities.rgb2int(diffuse) if self[constants.TYPE] != constants.THREE_BASIC: - ambient = api.material.ambient_color(self.node) - self[constants.AMBIENT] = utilities.rgb2int(ambient) - emissive = api.material.emissive_color(self.node) self[constants.EMISSIVE] = utilities.rgb2int(emissive)
true
Other
mrdoob
three.js
da582107010e26768fec37ff0347431963546b59.json
Add earcut library to examples
examples/js/libs/earcut.js
@@ -0,0 +1,674 @@ +/** + * + * Earcut https://github.com/mapbox/earcut + * + * Copyright (c) 2015, Mapbox + * + * Permission to use, copy, modify, and/or distribute this software for any purpose + * with or without fee is hereby granted, provided that the above copyright notice + * and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + * THIS SOFTWARE. + */ +'use strict'; + +module.exports = earcut; + +function earcut(data, holeIndices, dim) { + + dim = dim || 2; + + var hasHoles = holeIndices && holeIndices.length, + outerLen = hasHoles ? holeIndices[0] * dim : data.length, + outerNode = filterPoints(data, linkedList(data, 0, outerLen, dim, true)), + triangles = []; + + if (!outerNode) return triangles; + + var minX, minY, maxX, maxY, x, y, size; + + if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); + + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; + + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + } + + // minX, minY and size are later used to transform coords into integers for z-order calculation + size = Math.max(maxX - minX, maxY - minY); + } + + earcutLinked(data, outerNode, triangles, dim, minX, minY, size); + + return triangles; +} + +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList(data, start, end, dim, clockwise) { + var sum = 0, + i, j, last; + + // calculate original winding order of a polygon ring + for (i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + + // link points into circular doubly-linked list in the specified winding order + if (clockwise === (sum > 0)) { + for (i = start; i < end; i += dim) last = insertNode(i, last); + } else { + for (i = end - dim; i >= start; i -= dim) last = insertNode(i, last); + } + + return last; +} + +// eliminate colinear or duplicate points +function filterPoints(data, start, end) { + if (!start) return start; + if (!end) end = start; + + var node = start, + again; + do { + again = false; + + if (!node.steiner && (equals(data, node.i, node.next.i) || orient(data, node.prev.i, node.i, node.next.i) === 0)) { + removeNode(node); + node = end = node.prev; + if (node === node.next) return null; + again = true; + + } else { + node = node.next; + } + } while (again || node !== end); + + return end; +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked(data, ear, triangles, dim, minX, minY, size, pass) { + if (!ear) return; + + // interlink polygon nodes in z-order + if (!pass && minX !== undefined) indexCurve(data, ear, minX, minY, size); + + var stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (isEar(data, ear, minX, minY, size)) { + // cut off the triangle + triangles.push(prev.i / dim); + triangles.push(ear.i / dim); + triangles.push(next.i / dim); + + removeNode(ear); + + // skipping the next vertice leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(data, filterPoints(data, ear), triangles, dim, minX, minY, size, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(data, ear, triangles, dim); + earcutLinked(data, ear, triangles, dim, minX, minY, size, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(data, ear, triangles, dim, minX, minY, size); + } + + break; + } + } +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar(data, ear, minX, minY, size) { + + var a = ear.prev.i, + b = ear.i, + c = ear.next.i, + + ax = data[a], ay = data[a + 1], + bx = data[b], by = data[b + 1], + cx = data[c], cy = data[c + 1], + + abd = ax * by - ay * bx, + acd = ax * cy - ay * cx, + cbd = cx * by - cy * bx, + A = abd - acd - cbd; + + if (A <= 0) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear; + // the code below is a bit verbose and repetitive but this is done for performance + + var cay = cy - ay, + acx = ax - cx, + aby = ay - by, + bax = bx - ax, + i, px, py, s, t, k, node; + + // if we use z-order curve hashing, iterate through the curve + if (minX !== undefined) { + + // triangle bbox; min & max are calculated like this for speed + var minTX = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx), + minTY = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy), + maxTX = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx), + maxTY = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy), + + // z-order range for the current triangle bbox; + minZ = zOrder(minTX, minTY, minX, minY, size), + maxZ = zOrder(maxTX, maxTY, minX, minY, size); + + // first look for points inside the triangle in increasing z-order + node = ear.nextZ; + + while (node && node.z <= maxZ) { + i = node.i; + node = node.nextZ; + if (i === a || i === c) continue; + + px = data[i]; + py = data[i + 1]; + + s = cay * px + acx * py - acd; + if (s >= 0) { + t = aby * px + bax * py + abd; + if (t >= 0) { + k = A - s - t; + if ((k >= 0) && ((s && t) || (s && k) || (t && k))) return false; + } + } + } + + // then look for points in decreasing z-order + node = ear.prevZ; + + while (node && node.z >= minZ) { + i = node.i; + node = node.prevZ; + if (i === a || i === c) continue; + + px = data[i]; + py = data[i + 1]; + + s = cay * px + acx * py - acd; + if (s >= 0) { + t = aby * px + bax * py + abd; + if (t >= 0) { + k = A - s - t; + if ((k >= 0) && ((s && t) || (s && k) || (t && k))) return false; + } + } + } + + // if we don't use z-order curve hash, simply iterate through all other points + } else { + node = ear.next.next; + + while (node !== ear.prev) { + i = node.i; + node = node.next; + + px = data[i]; + py = data[i + 1]; + + s = cay * px + acx * py - acd; + if (s >= 0) { + t = aby * px + bax * py + abd; + if (t >= 0) { + k = A - s - t; + if ((k >= 0) && ((s && t) || (s && k) || (t && k))) return false; + } + } + } + } + + return true; +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections(data, start, triangles, dim) { + var node = start; + do { + var a = node.prev, + b = node.next.next; + + // a self-intersection where edge (v[i-1],v[i]) intersects (v[i+1],v[i+2]) + if (a.i !== b.i && intersects(data, a.i, node.i, node.next.i, b.i) && + locallyInside(data, a, b) && locallyInside(data, b, a) && + orient(data, a.i, node.i, b.i) && orient(data, a.i, node.next.i, b.i)) { + + triangles.push(a.i / dim); + triangles.push(node.i / dim); + triangles.push(b.i / dim); + + // remove two nodes involved + removeNode(node); + removeNode(node.next); + + node = start = b; + } + node = node.next; + } while (node !== start); + + return node; +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut(data, start, triangles, dim, minX, minY, size) { + // look for a valid diagonal that divides the polygon into two + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(data, a, b)) { + // split the polygon in two by the diagonal + var c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(data, a, a.next); + c = filterPoints(data, c, c.next); + + // run earcut on each half + earcutLinked(data, a, triangles, dim, minX, minY, size); + earcutLinked(data, c, triangles, dim, minX, minY, size); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], + i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) list.steiner = true; + list = filterPoints(data, list); + if (list) queue.push(getLeftmost(data, list)); + } + + queue.sort(function (a, b) { + return data[a.i] - data[b.i]; + }); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + eliminateHole(data, queue[i], outerNode); + outerNode = filterPoints(data, outerNode, outerNode.next); + } + + return outerNode; +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole(data, holeNode, outerNode) { + outerNode = findHoleBridge(data, holeNode, outerNode); + if (outerNode) { + var b = splitPolygon(outerNode, holeNode); + filterPoints(data, b, b.next); + } +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge(data, holeNode, outerNode) { + var node = outerNode, + i = holeNode.i, + px = data[i], + py = data[i + 1], + qMax = -Infinity, + mNode, a, b; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + a = node.i; + b = node.next.i; + + if (py <= data[a + 1] && py >= data[b + 1]) { + var qx = data[a] + (py - data[a + 1]) * (data[b] - data[a]) / (data[b + 1] - data[a + 1]); + if (qx <= px && qx > qMax) { + qMax = qx; + mNode = data[a] < data[b] ? node : node.next; + } + } + node = node.next; + } while (node !== outerNode); + + if (!mNode) return null; + + // look for points strictly inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + var bx = data[mNode.i], + by = data[mNode.i + 1], + pbd = px * by - py * bx, + pcd = px * py - py * qMax, + cpy = py - py, + pcx = px - qMax, + pby = py - by, + bpx = bx - px, + A = pbd - pcd - (qMax * by - py * bx), + sign = A <= 0 ? -1 : 1, + stop = mNode, + tanMin = Infinity, + mx, my, amx, s, t, tan; + + node = mNode.next; + + while (node !== stop) { + + mx = data[node.i]; + my = data[node.i + 1]; + amx = px - mx; + + if (amx >= 0 && mx >= bx) { + s = (cpy * mx + pcx * my - pcd) * sign; + if (s >= 0) { + t = (pby * mx + bpx * my + pbd) * sign; + + if (t >= 0 && A * sign - s - t >= 0) { + tan = Math.abs(py - my) / amx; // tangential + if ((tan < tanMin || (tan === tanMin && mx > bx)) && + locallyInside(data, node, holeNode)) { + mNode = node; + tanMin = tan; + } + } + } + } + + node = node.next; + } + + return mNode; +} + +// interlink polygon nodes in z-order +function indexCurve(data, start, minX, minY, size) { + var node = start; + + do { + if (node.z === null) node.z = zOrder(data[node.i], data[node.i + 1], minX, minY, size); + node.prevZ = node.prev; + node.nextZ = node.next; + node = node.next; + } while (node !== start); + + node.prevZ.nextZ = null; + node.prevZ = null; + + sortLinked(node); +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + + if (pSize === 0) { + e = q; + q = q.nextZ; + qSize--; + } else if (qSize === 0 || !q) { + e = p; + p = p.nextZ; + pSize--; + } else if (p.z <= q.z) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + + } while (numMerges > 1); + + return list; +} + +// z-order of a point given coords and size of the data bounding box +function zOrder(x, y, minX, minY, size) { + // coords are transformed into non-negative 15-bit integer range + x = 32767 * (x - minX) / size; + y = 32767 * (y - minY) / size; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); +} + +// find the leftmost node of a polygon ring +function getLeftmost(data, start) { + var node = start, + leftmost = start; + do { + if (data[node.i] < data[leftmost.i]) leftmost = node; + node = node.next; + } while (node !== start); + + return leftmost; +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal(data, a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && + !intersectsPolygon(data, a, a.i, b.i) && + locallyInside(data, a, b) && locallyInside(data, b, a) && + middleInside(data, a, a.i, b.i); +} + +// winding order of triangle formed by 3 given points +function orient(data, p, q, r) { + var o = (data[q + 1] - data[p + 1]) * (data[r] - data[q]) - (data[q] - data[p]) * (data[r + 1] - data[q + 1]); + return o > 0 ? 1 : + o < 0 ? -1 : 0; +} + +// check if two points are equal +function equals(data, p1, p2) { + return data[p1] === data[p2] && data[p1 + 1] === data[p2 + 1]; +} + +// check if two segments intersect +function intersects(data, p1, q1, p2, q2) { + return orient(data, p1, q1, p2) !== orient(data, p1, q1, q2) && + orient(data, p2, q2, p1) !== orient(data, p2, q2, q1); +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon(data, start, a, b) { + var node = start; + do { + var p1 = node.i, + p2 = node.next.i; + + if (p1 !== a && p2 !== a && p1 !== b && p2 !== b && intersects(data, p1, p2, a, b)) return true; + + node = node.next; + } while (node !== start); + + return false; +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside(data, a, b) { + return orient(data, a.prev.i, a.i, a.next.i) === -1 ? + orient(data, a.i, b.i, a.next.i) !== -1 && orient(data, a.i, a.prev.i, b.i) !== -1 : + orient(data, a.i, b.i, a.prev.i) === -1 || orient(data, a.i, a.next.i, b.i) === -1; +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside(data, start, a, b) { + var node = start, + inside = false, + px = (data[a] + data[b]) / 2, + py = (data[a + 1] + data[b + 1]) / 2; + do { + var p1 = node.i, + p2 = node.next.i; + + if (((data[p1 + 1] > py) !== (data[p2 + 1] > py)) && + (px < (data[p2] - data[p1]) * (py - data[p1 + 1]) / (data[p2 + 1] - data[p1 + 1]) + data[p1])) + inside = !inside; + + node = node.next; + } while (node !== start); + + return inside; +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon(a, b) { + var a2 = new Node(a.i), + b2 = new Node(b.i), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode(i, last) { + var node = new Node(i); + + if (!last) { + node.prev = node; + node.next = node; + + } else { + node.next = last.next; + node.prev = last; + last.next.prev = node; + last.next = node; + } + return node; +} + +function removeNode(node) { + node.next.prev = node.prev; + node.prev.next = node.next; + + if (node.prevZ) node.prevZ.nextZ = node.nextZ; + if (node.nextZ) node.nextZ.prevZ = node.prevZ; +} + +function Node(i) { + // vertex coordinates + this.i = i; + + // previous and next vertice nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = null; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; +}
false
Other
mrdoob
three.js
fc1a3b24cb5c96ef4847b84aa2fe441bd2c28769.json
update support properties transparency => opacity remove colorAmbient, https://github.com/mrdoob/three.js/pull/7374
utils/exporters/maya/plug-ins/threeJsFileTranslator.py
@@ -233,11 +233,10 @@ def _exportMaterial(self, mat): "DbgName": mat.name(), "blending": "NormalBlending", "colorDiffuse": map(lambda i: i * mat.getDiffuseCoeff(), mat.getColor().rgb), - "colorAmbient": mat.getAmbientColor().rgb, "depthTest": True, "depthWrite": True, "shading": mat.__class__.__name__, - "transparency": mat.getTransparency().a, + "opacity": mat.getTransparency().a, "transparent": mat.getTransparency().a != 1.0, "vertexColors": False }
false
Other
mrdoob
three.js
91370c6e097227812732fc9809e272046123333b.json
Ignore empty entries in MTL files
examples/js/loaders/MTLLoader.js
@@ -311,6 +311,10 @@ THREE.MTLLoader.MaterialCreator.prototype = { var value = mat[ prop ]; + if ( value === '' ) { + continue; + } + switch ( prop.toLowerCase() ) { // Ns is material specular exponent
false
Other
mrdoob
three.js
3b10641e4c87531725a28e0edb5173a472577839.json
add addExtension method
examples/js/loaders/3MFLoader.js
@@ -1,16 +1,7 @@ -THREE.ThreeMFLoader = function ( manager, extensions ) { +THREE.ThreeMFLoader = function ( manager ) { - if ( manager instanceof Array ) { - - this.manager = THREE.DefaultLoadingManager; - this.availableExtensions = manager; - - } else { - - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; - this.availableExtensions = extensions || []; - - } + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + this.availableExtensions = []; }; @@ -151,8 +142,6 @@ THREE.ThreeMFLoader.prototype = { var texturesPartName = texturesPartNames[ i ]; texturesParts[ texturesPartName ] = zip.file( texturesPartName ).asBinary(); - //var img = document.createElement('img'); - //img.src = 'data:image/png;,' + btoa(texturesParts[ texturesPartName ]); } @@ -235,11 +224,11 @@ THREE.ThreeMFLoader.prototype = { meshData[ 'vertices' ] = new Float32Array( vertices.length ); - for ( var i = 0; i < vertices.length; i++ ) { + for ( var i = 0; i < vertices.length; i++ ) { - meshData[ 'vertices' ][ i ] = vertices[ i ]; + meshData[ 'vertices' ][ i ] = vertices[ i ]; - } + } var triangleProperties = []; var triangles = []; @@ -294,11 +283,11 @@ THREE.ThreeMFLoader.prototype = { meshData[ 'triangleProperties' ] = triangleProperties; meshData[ 'triangles' ] = new Uint32Array( triangles.length ); - for ( var i = 0; i < triangles.length; i++ ) { + for ( var i = 0; i < triangles.length; i++ ) { - meshData[ 'triangles' ][ i ] = triangles[ i ]; + meshData[ 'triangles' ][ i ] = triangles[ i ]; - } + } return meshData; @@ -385,9 +374,7 @@ THREE.ThreeMFLoader.prototype = { function parseResourcesNode( resourcesNode ) { var resourcesData = {}; - var geometry, material; - var basematerialsNode = resourcesNode.querySelector( 'basematerials' ); if ( basematerialsNode ) { @@ -417,6 +404,7 @@ THREE.ThreeMFLoader.prototype = { var itemNodes = buildNode.querySelectorAll( 'item' ); for ( var i = 0; i < itemNodes.length; i++ ) { + var itemNode = itemNodes[ i ]; var buildItem = { objectid: itemNode.getAttribute( 'objectid' ) @@ -598,6 +586,7 @@ THREE.ThreeMFLoader.prototype = { } return group; + } var data3mf = loadDocument( data ); @@ -607,4 +596,10 @@ THREE.ThreeMFLoader.prototype = { }, + addExtension: function( extension ) { + + this.availableExtensions.push( extension ); + + } + };
false
Other
mrdoob
three.js
991b8fa7c3a1303df69fa8c447e4d021f06751a8.json
return this on copy
src/lights/LightShadow.js
@@ -29,6 +29,8 @@ THREE.LightShadow.prototype = { this.mapSize.copy( source.mapSize ); + return this; + }, clone: function () {
false
Other
mrdoob
three.js
635b3e274d097244ae2c0e9e021e2e07f851bcde.json
Fix bower.json ignores
bower.json
@@ -14,13 +14,13 @@ "ignore": [ "**/.*", "*.md", - "docs", - "editor", - "examples/*", - "!examples/js", - "src", - "test", - "utils", - "LICENSE" + "/docs", + "/editor", + "/examples/*", + "!/examples/js", + "/src", + "/test", + "/utils", + "/LICENSE" ] }
false
Other
mrdoob
three.js
447d4fcce879e0570721ed5e7aa784b65b4f3625.json
convert whitespaces into tab
examples/webgl_loader_fbx.html
@@ -31,9 +31,9 @@ <script src="../build/three.min.js"></script> - <script src="js/controls/OrbitControls.js"></script> + <script src="js/controls/OrbitControls.js"></script> - <script src="js/loaders/FBXLoader.js"></script> + <script src="js/loaders/FBXLoader.js"></script> <script src="js/Detector.js"></script> <script src="js/libs/stats.min.js"></script> @@ -45,9 +45,9 @@ var container, stats, controls; var camera, scene, renderer; - var clock = new THREE.Clock(); + var clock = new THREE.Clock(); - var mixers = []; + var mixers = []; init(); @@ -61,7 +61,7 @@ scene = new THREE.Scene(); - ////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////// // Grid var size = 14, step = 1; @@ -82,19 +82,19 @@ var line = new THREE.LineSegments( geometry, material ); scene.add( line ); - ////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////// // Lights - scene.add( new THREE.AmbientLight( 0xcccccc ) ); + scene.add( new THREE.AmbientLight( 0xcccccc ) ); - ////////////////////////////////////////////////////////////// - // stats + ////////////////////////////////////////////////////////////// + // stats stats = new Stats(); stats.domElement.style.position = 'absolute'; stats.domElement.style.top = '0px'; - container.appendChild( stats.domElement ); + container.appendChild( stats.domElement ); - ////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////// // model var manager = new THREE.LoadingManager(); manager.onProgress = function ( item, loaded, total ) { @@ -113,7 +113,7 @@ var onError = function ( xhr ) { }; - var loader = new THREE.FBXLoader( manager ); + var loader = new THREE.FBXLoader( manager ); loader.load( 'models/fbx/xsi_man_skinning.fbx', function ( object ) { object.traverse( function ( child ) { @@ -122,47 +122,47 @@ // pass - } + } if ( child instanceof THREE.SkinnedMesh ) { - if ( child.geometry.animations !== undefined || child.geometry.morphAnimations !== undefined ) { + if ( child.geometry.animations !== undefined || child.geometry.morphAnimations !== undefined ) { - child.mixer = new THREE.AnimationMixer( child ); - mixers.push( child.mixer ); + child.mixer = new THREE.AnimationMixer( child ); + mixers.push( child.mixer ); - var action = child.mixer.clipAction( child.geometry.animations[0] ); - action.play(); + var action = child.mixer.clipAction( child.geometry.animations[0] ); + action.play(); - } + } - } + } } ); - scene.add( object ); + scene.add( object ); - }, onProgress, onError ); + }, onProgress, onError ); - ////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////// renderer = new THREE.WebGLRenderer(); renderer.setPixelRatio( window.devicePixelRatio ); - renderer.setSize( window.innerWidth, window.innerHeight ); + renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setClearColor( 0x000000 ); - container.appendChild( renderer.domElement ); + container.appendChild( renderer.domElement ); - ////////////////////////////////////////////////////////////// - // controls, camera - controls = new THREE.OrbitControls( camera, renderer.domElement ); - controls.target.set( 0, 12, 0 ); + ////////////////////////////////////////////////////////////// + // controls, camera + controls = new THREE.OrbitControls( camera, renderer.domElement ); + controls.target.set( 0, 12, 0 ); camera.position.set( 2, 18, 28 ); camera.lookAt( new THREE.Vector3( 0, 15, 0 ) ); window.addEventListener( 'resize', onWindowResize, false ); - animate(); + animate(); } function onWindowResize() { @@ -175,20 +175,20 @@ } // - function animate() { + function animate() { - requestAnimationFrame( animate ); + requestAnimationFrame( animate ); - if( mixers.length > 0 ){ - for ( var i=0; i < mixers.length; i++ ){ - mixers[i].update( clock.getDelta() ); + if( mixers.length > 0 ){ + for ( var i=0; i < mixers.length; i++ ){ + mixers[i].update( clock.getDelta() ); - } + } - } + } controls.update(); - stats.update(); + stats.update(); render(); }
false
Other
mrdoob
three.js
720bb21c91b3b964d1bd58a23a6cf3bc6aead903.json
fix abc to abs
examples/js/nodes/math/Math1Node.js
@@ -30,7 +30,7 @@ THREE.Math1Node.TAN = 'tan'; THREE.Math1Node.ASIN = 'asin'; THREE.Math1Node.ACOS = 'acos'; THREE.Math1Node.ARCTAN = 'atan'; -THREE.Math1Node.ABS = 'abc'; +THREE.Math1Node.ABS = 'abs'; THREE.Math1Node.SIGN = 'sign'; THREE.Math1Node.LENGTH = 'length'; THREE.Math1Node.NEGATE = 'negate';
false
Other
mrdoob
three.js
0c52b0c1887b21b2ad8af5f0bb6bda99bc455d90.json
fix mod function
examples/js/nodes/math/Math2Node.js
@@ -79,7 +79,7 @@ THREE.Math2Node.prototype.generate = function( builder, output ) { case THREE.Math2Node.MIN: case THREE.Math2Node.MAX: - case THREE.Math2Node.MODULO: + case THREE.Math2Node.MOD: a = this.a.build( builder, type ); b = this.b.build( builder, bl == 1 ? 'fv1' : type ); break;
false
Other
mrdoob
three.js
0e1a70097f027a536c0d51a4c1cb808093459e8a.json
Give unified name to VMD Animation
examples/js/loaders/MMDLoader.js
@@ -221,13 +221,13 @@ THREE.MMDLoader.prototype.mergeVmds = function ( vmds ) { }; -THREE.MMDLoader.prototype.pourVmdIntoModel = function ( mesh, vmd ) { +THREE.MMDLoader.prototype.pourVmdIntoModel = function ( mesh, vmd, name ) { - this.createAnimation( mesh, vmd ); + this.createAnimation( mesh, vmd, name ); }; -THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd ) { +THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd, name ) { var helper = new THREE.MMDLoader.DataCreationHelper(); @@ -295,7 +295,7 @@ THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd ) { } - camera.animations.push( new THREE.AnimationClip( 'cameraAnimation', -1, tracks ) ); + camera.animations.push( new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name, -1, tracks ) ); }; @@ -2598,7 +2598,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress }; -THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd ) { +THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) { var scope = this; @@ -2610,7 +2610,7 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd ) { var orderedMotions = helper.createOrderedMotionArrays( bones, vmd.motions, 'boneName' ); var animation = { - name: 'Action', + name: name === undefined ? THREE.Math.generateUUID() : name, fps: 30, length: 0.0, hierarchy: [] @@ -2746,7 +2746,7 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd ) { } - mesh.geometry.morphAnimations.push( new THREE.AnimationClip( 'morphAnimation', -1, tracks ) ); + mesh.geometry.morphAnimations.push( new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name + 'Morph', -1, tracks ) ); }; @@ -4039,13 +4039,33 @@ THREE.MMDHelper.prototype = { if ( mesh.geometry.animations !== undefined ) { - mesh.mixer.clipAction( mesh.geometry.animations[ 0 ] ).play(); + for ( var i = 0; i < mesh.geometry.animations.length; i++ ) { + + var action = mesh.mixer.clipAction( mesh.geometry.animations[ i ] ); + + if ( i === 0 ) { + + action.play(); + + } + + } } if ( mesh.geometry.morphAnimations !== undefined ) { - mesh.mixer.clipAction( mesh.geometry.morphAnimations[ 0 ] ).play() ; + for ( var i = 0; i < mesh.geometry.morphAnimations.length; i++ ) { + + var action = mesh.mixer.clipAction( mesh.geometry.morphAnimations[ i ] ); + + if ( i === 0 ) { + + action.play(); + + } + + } }
false
Other
mrdoob
three.js
0fe5f5e49aa85056d89ead51e299a269fe3a4f06.json
fix alert name
examples/js/nodes/utils/NormalMapNode.js
@@ -34,7 +34,7 @@ THREE.NormalMapNode.prototype.generate = function( builder, output ) { } else { - console.warn( "THREE.NormalMap is not compatible with " + builder.shader + " shader." ); + console.warn( "THREE.NormalMapNode is not compatible with " + builder.shader + " shader." ); return builder.format( 'vec3( 0.0 )', this.type, output );
false
Other
mrdoob
three.js
43b81cc674c342a6da127675d6516c98c012eab6.json
Clarify .clone() action
docs/api/core/Geometry.html
@@ -278,6 +278,8 @@ <h3>[method:Geometry clone]()</h3> <div> Creates a new clone of the Geometry. </div> + + <div>This method copies only vertices, faces and uvs. It does not copy any other properties of the geometry.</div> <h3>[method:null dispose]()</h3> <div>
false
Other
mrdoob
three.js
80bfa452412ab24774c9268fb3f71fa9408586cc.json
Mover Vector3 legacy code.
src/Three.Legacy.js
@@ -26,6 +26,41 @@ Object.defineProperties( THREE.Box3.prototype, { } } ); +// + +Object.defineProperties( THREE.Vector3.prototype, { + setEulerFromRotationMatrix: { + value: function () { + console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' ); + } + }, + setEulerFromQuaternion: { + value: function () { + console.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' ); + } + }, + getPositionFromMatrix: { + value: function ( m ) { + console.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' ); + return this.setFromMatrixPosition( m ); + } + }, + getScaleFromMatrix: { + value: function ( m ) { + console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' ); + return this.setFromMatrixScale( m ); + } + }, + getColumnFromMatrix: { + value: function ( index, matrix ) { + console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' ); + return this.setFromMatrixColumn( index, matrix ); + } + } +} ); + +// + Object.defineProperties( THREE.Light.prototype, { onlyShadow: { set: function ( value ) {
true
Other
mrdoob
three.js
80bfa452412ab24774c9268fb3f71fa9408586cc.json
Mover Vector3 legacy code.
src/math/Vector3.js
@@ -679,42 +679,6 @@ THREE.Vector3.prototype = { }, - setEulerFromRotationMatrix: function ( m, order ) { - - console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' ); - - }, - - setEulerFromQuaternion: function ( q, order ) { - - console.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' ); - - }, - - getPositionFromMatrix: function ( m ) { - - console.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' ); - - return this.setFromMatrixPosition( m ); - - }, - - getScaleFromMatrix: function ( m ) { - - console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' ); - - return this.setFromMatrixScale( m ); - - }, - - getColumnFromMatrix: function ( index, matrix ) { - - console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' ); - - return this.setFromMatrixColumn( index, matrix ); - - }, - setFromMatrixPosition: function ( m ) { this.x = m.elements[ 12 ];
true
Other
mrdoob
three.js
2321132bf8fccb1b93e7df1053352191810b31db.json
build three.js with CinematicCamera
build/three.js
@@ -17126,7 +17126,7 @@ THREE.PerspectiveCamera.prototype.toJSON = function ( meta ) { * @author mrdoob / http://mrdoob.com/ * @author greggman / http://games.greggman.com/ * @author zz85 / http://www.lab4games.net/zz85/blog - * @author kaypikun + * @author kaypiKun */ //Inheriting PerspectiveCamera
true
Other
mrdoob
three.js
2321132bf8fccb1b93e7df1053352191810b31db.json
build three.js with CinematicCamera
src/cameras/CinematicCamera.js
@@ -2,7 +2,7 @@ * @author mrdoob / http://mrdoob.com/ * @author greggman / http://games.greggman.com/ * @author zz85 / http://www.lab4games.net/zz85/blog - * @author kaypikun + * @author kaypiKun */ //Inheriting PerspectiveCamera
true
Other
mrdoob
three.js
f757eaf28fd8cf6726d1a92d694645c131cd0d36.json
Shader Clean Up
src/renderers/shaders/ShaderChunk/common.glsl
@@ -31,16 +31,16 @@ struct GeometricContext { }; -vec3 transformDirection( in vec3 normal, in mat4 matrix ) { +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( matrix * vec4( normal, 0.0 ) ).xyz ); + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } // http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations -vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) { +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz ); + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); }
true
Other
mrdoob
three.js
f757eaf28fd8cf6726d1a92d694645c131cd0d36.json
Shader Clean Up
src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl
@@ -14,13 +14,15 @@ varying vec3 vViewPosition; struct BlinnPhongMaterial { + vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; + }; -void BlinnPhongMaterial_RE_DirectLight( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); @@ -31,13 +33,13 @@ void BlinnPhongMaterial_RE_DirectLight( const in IncidentLight directLight, cons } -void BlinnPhongMaterial_RE_IndirectDiffuseLight( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } -#define Material_RE_DirectLight BlinnPhongMaterial_RE_DirectLight -#define Material_RE_IndirectDiffuseLight BlinnPhongMaterial_RE_IndirectDiffuseLight +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong -#define Material_LightProbeLOD( material ) (0) +#define Material_LightProbeLOD( material ) (0)
true
Other
mrdoob
three.js
f757eaf28fd8cf6726d1a92d694645c131cd0d36.json
Shader Clean Up
src/renderers/shaders/ShaderChunk/lights_phong_pars_vertex.glsl
@@ -3,9 +3,3 @@ varying vec3 vWorldPosition; #endif - -#if NUM_POINT_LIGHTS > 0 - - uniform vec3 pointLightPosition[ NUM_POINT_LIGHTS ]; - -#endif
true
Other
mrdoob
three.js
f757eaf28fd8cf6726d1a92d694645c131cd0d36.json
Shader Clean Up
src/renderers/shaders/ShaderChunk/lights_standard_fragment.glsl
@@ -1,4 +1,4 @@ -PhysicalMaterial material; +StandardMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); -material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 ); // disney's remapping of [ 0, 1 ] roughness to [ 0.04, 1 ] +material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 ); material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
true
Other
mrdoob
three.js
f757eaf28fd8cf6726d1a92d694645c131cd0d36.json
Shader Clean Up
src/renderers/shaders/ShaderChunk/lights_standard_pars_fragment.glsl
@@ -1,36 +1,37 @@ -struct PhysicalMaterial { +struct StandardMaterial { + vec3 diffuseColor; float specularRoughness; vec3 specularColor; - float clearCoatWeight; - float clearCoatRoughness; + }; -void PhysicalMaterial_RE_DirectLight( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { +void RE_Direct_Standard( const in IncidentLight directLight, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * PI * directLight.color; // punctual light reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness ); } -void PhysicalMaterial_RE_DiffuseIndirectLight( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { +void RE_IndirectDiffuse_Standard( const in vec3 irradiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); } -void PhysicalMaterial_RE_SpecularIndirectLight( const in vec3 radiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { +void RE_IndirectSpecular_Standard( const in vec3 radiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectSpecular += radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness ); } -#define Material_RE_DirectLight PhysicalMaterial_RE_DirectLight -#define Material_RE_IndirectDiffuseLight PhysicalMaterial_RE_DiffuseIndirectLight -#define Material_RE_IndirectSpecularLight PhysicalMaterial_RE_SpecularIndirectLight +#define RE_Direct RE_Direct_Standard +#define RE_IndirectDiffuse RE_IndirectDiffuse_Standard +#define RE_IndirectSpecular RE_IndirectSpecular_Standard #define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )
true
Other
mrdoob
three.js
f757eaf28fd8cf6726d1a92d694645c131cd0d36.json
Shader Clean Up
src/renderers/shaders/ShaderChunk/lights_template.glsl
@@ -3,8 +3,8 @@ // for specific lighting scenarios. // // Instructions for use: -// - Ensure that both Material_RE_DirectLight, Material_RE_IndirectDiffuseLight and Material_RE_IndirectSpecularLight are defined -// - If you have defined a Material_RE_IndirectSpecularLight, you need to also provide a Material_LightProbeLOD. +// - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined +// - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ??? // - Create a material parameter that is to be passed as the third parameter to your lighting functions. // // TODO: @@ -14,11 +14,12 @@ // GeometricContext geometry; -geometry.position = -vViewPosition; + +geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = normalize( vViewPosition ); -#if ( NUM_POINT_LIGHTS > 0 ) && defined( Material_RE_DirectLight ) +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { @@ -36,13 +37,13 @@ geometry.viewDir = normalize( vViewPosition ); } #endif - Material_RE_DirectLight( directLight, geometry, material, reflectedLight ); + RE_Direct( directLight, geometry, material, reflectedLight ); } #endif -#if ( NUM_SPOT_LIGHTS > 0 ) && defined( Material_RE_DirectLight ) +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { @@ -60,13 +61,13 @@ geometry.viewDir = normalize( vViewPosition ); } #endif - Material_RE_DirectLight( directLight, geometry, material, reflectedLight ); + RE_Direct( directLight, geometry, material, reflectedLight ); } #endif -#if ( NUM_DIR_LIGHTS > 0 ) && defined( Material_RE_DirectLight ) +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { @@ -84,29 +85,29 @@ geometry.viewDir = normalize( vViewPosition ); } #endif - Material_RE_DirectLight( directLight, geometry, material, reflectedLight ); + RE_Direct( directLight, geometry, material, reflectedLight ); } #endif -#if defined( Material_RE_IndirectDiffuseLight ) +#if defined( RE_IndirectDiffuse ) { - vec3 indirectDiffuseIrradiance = getAmbientLightIrradiance( ambientLightColor ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #ifdef USE_LIGHTMAP - indirectDiffuseIrradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage + irradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage #endif #if ( NUM_HEMI_LIGHTS > 0 ) for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { - indirectDiffuseIrradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry ); + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry ); } @@ -115,24 +116,24 @@ geometry.viewDir = normalize( vViewPosition ); // #if defined( USE_ENVMAP ) && defined( STANDARD ) // TODO, replace 8 with the real maxMIPLevel - // indirectDiffuseIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, 8 ); // comment out until seams are fixed + // irradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, 8 ); // comment out until seams are fixed // #endif - Material_RE_IndirectDiffuseLight( indirectDiffuseIrradiance, geometry, material, reflectedLight ); + RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); } #endif -#if defined( USE_ENVMAP ) && defined( Material_RE_IndirectSpecularLight ) +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) { // TODO, replace 8 with the real maxMIPLevel - vec3 indirectSpecularRadiance = getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_BlinnShininessExponent( material ), 8 ); + vec3 radiance = getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_BlinnShininessExponent( material ), 8 ); - Material_RE_IndirectSpecularLight( indirectSpecularRadiance, geometry, material, reflectedLight ); + RE_IndirectSpecular( radiance, geometry, material, reflectedLight ); }
true
Other
mrdoob
three.js
f757eaf28fd8cf6726d1a92d694645c131cd0d36.json
Shader Clean Up
src/renderers/shaders/ShaderLib.js
@@ -452,7 +452,6 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "uv2_pars_vertex" ], THREE.ShaderChunk[ "displacementmap_pars_vertex" ], THREE.ShaderChunk[ "envmap_pars_vertex" ], - THREE.ShaderChunk[ "lights_phong_pars_vertex" ], // use phong chunk for now THREE.ShaderChunk[ "color_pars_vertex" ], THREE.ShaderChunk[ "morphtarget_pars_vertex" ], THREE.ShaderChunk[ "skinning_pars_vertex" ], @@ -489,7 +488,6 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "worldpos_vertex" ], THREE.ShaderChunk[ "envmap_vertex" ], - THREE.ShaderChunk[ "lights_phong_vertex" ], // use phong chunk for now THREE.ShaderChunk[ "shadowmap_vertex" ], "}"
true
Other
mrdoob
three.js
ec6b4b4dd53615f66e1c50d4ebd44e6e2d35144f.json
remove lodash dependency
package.json
@@ -31,7 +31,6 @@ "devDependencies": { "argparse": "^1.0.3", "jscs": "^1.13.1", - "lodash": "^3.10.0", "uglify-js": "^2.6.0" } }
true
Other
mrdoob
three.js
ec6b4b4dd53615f66e1c50d4ebd44e6e2d35144f.json
remove lodash dependency
test/unit/unittests_three.html
@@ -7,7 +7,6 @@ </head> <body> <div id="qunit"></div> - <script src="../../node_modules/lodash/index.js"></script> <script src="qunit-1.18.0.js"></script> <script src="qunit-utils.js"></script> <script src="SmartComparer.js"></script>
true
Other
mrdoob
three.js
244b9529cb2a037f831f32ac0c0496916b2192ad.json
add test to html file
test/unit/unittests_three.html
@@ -28,6 +28,7 @@ <script src="core/InterleavedBuffer.js"></script> <script src="core/InterleavedBufferAttribute.js"></script> + <script src="core/Raycaster.js"></script> <script src="core/Face3.js"></script> <script src="core/Geometry.js"></script> <script src="core/BufferAttribute.js"></script>
false
Other
mrdoob
three.js
7961f3a999a330276ff55e4183765cd31c07f345.json
add unit tests for raycaster
test/unit/core/Raycaster.js
@@ -0,0 +1,105 @@ +/** + * @author simonThiele / https://github.com/simonThiele + */ + +module( "Raycaster" ); + +test( "intersectObjects", function() { + var raycaster = getRaycaster(); + var objectsToCheck = getObjectsToCheck(); + + ok ( raycaster.intersectObjects(objectsToCheck).length === 1, + "no recursive search should lead to one hit" ); + + ok ( raycaster.intersectObjects(objectsToCheck, true).length === 3, + "recursive search should lead to two hits" ); + + var intersections = raycaster.intersectObjects(objectsToCheck, true); + for (var i = 0; i < intersections.length - 1; i++) { + ok( intersections[i].distance <= intersections[i + 1].distance, "intersections are sorted" ); + } +}); + +test( "intersectObject", function() { + var raycaster = getRaycaster(); + var objectsToCheck = getObjectsToCheck(); + + ok ( raycaster.intersectObject(objectsToCheck[0]).length === 1, + "no recursive search should lead to one hit" ); + + ok ( raycaster.intersectObject(objectsToCheck[0], true).length === 3, + "recursive search should lead to two hits" ); + + var intersections = raycaster.intersectObject(objectsToCheck[0], true); + for (var i = 0; i < intersections.length - 1; i++) { + ok( intersections[i].distance <= intersections[i + 1].distance, "intersections are sorted" ); + } +}); + +test( "setFromCamera", function() { + var raycaster = new THREE.Raycaster(); + var rayDirection = raycaster.ray.direction; + var camera = new THREE.PerspectiveCamera( 90, 1, 1, 1000 ); + + raycaster.setFromCamera( { x : 0, y: 0 }, camera ); + ok( rayDirection.x === 0, rayDirection.y === 0, rayDirection.z === -1, + "camera is looking straight to -z and so does the ray in the middle of the screen" ); + + var step = 0.1; + for (var x = -1; x <= 1; x+=step) { + for (var y = -1; y <= 1; y+=step) { + raycaster.setFromCamera( { x, y }, camera ); + var refVector = new THREE.Vector3(x, y, -1).normalize(); + checkRayDirectionAgainstReferenceVector(rayDirection, refVector); + } + } +}); + +function checkRayDirectionAgainstReferenceVector(rayDirection, refVector) { + ok( refVector.x - rayDirection.x <= Number.EPSILON && + refVector.y - rayDirection.y <= Number.EPSILON && + refVector.z - rayDirection.z <= Number.EPSILON, + "camera is pointing to the same direction as expected" ); +} + +function getRaycaster() { + return raycaster = new THREE.Raycaster( + new THREE.Vector3( 0, 0, 0 ), + new THREE.Vector3( 0, 0, -1 ), + 1, + 100 + ); +} + +function getObjectsToCheck() { + var objects = []; + + var sphere1 = getSphere(); + sphere1.position.set(0, 0, -10); + sphere1.name = 1; + objects.push(sphere1); + + var sphere11 = getSphere(); + sphere11.position.set(0, 0, 1); + sphere11.name = 11; + sphere1.add(sphere11); + + var sphere12 = getSphere(); + sphere12.position.set(0, 0, -1); + sphere12.name = 12; + sphere1.add(sphere12); + + var sphere2 = getSphere(); + sphere2.position.set(-5, 0, -5); + sphere2.name = 2; + objects.push(sphere2); + + for (var i = 0; i < objects.length; i++) { + objects[i].updateMatrixWorld(); + } + return objects; +} + +function getSphere() { + return new THREE.Mesh(new THREE.SphereGeometry(1, 100, 100)); +}
false
Other
mrdoob
three.js
1ac1fa92d6c3f8db60b98eb5ceee7adc7d3af359.json
add test to html file
test/unit/unittests_three.html
@@ -28,6 +28,7 @@ <script src="core/InterleavedBuffer.js"></script> <script src="core/InterleavedBufferAttribute.js"></script> + <script src="core/Face3.js"></script> <script src="core/Geometry.js"></script> <script src="core/BufferAttribute.js"></script> <script src="core/BufferGeometry.js"></script>
false
Other
mrdoob
three.js
0e886bf700f880b25f956eda49150fb8c384e5aa.json
add unit test for face3
test/unit/core/Face3.js
@@ -0,0 +1,58 @@ +/** + * @author simonThiele / https://github.com/simonThiele + */ + +module( "Face3" ); + +test( "copy", function() { + var instance = new THREE.Face3(0, 1, 2, new THREE.Vector3(0, 1, 0), new THREE.Color(0.25, 0.5, 0.75), 2); + var copiedInstance = instance.copy(instance); + + checkCopy(copiedInstance); + checkVertexAndColors(copiedInstance); +}); + +test( "copy", function() { + var instance = new THREE.Face3(0, 1, 2, + [new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 0, 1)], + [new THREE.Color(0.25, 0.5, 0.75), new THREE.Color(1, 0, 0.4)], + 2); + var copiedInstance = instance.copy(instance); + + checkCopy(copiedInstance); + checkVertexAndColorArrays(copiedInstance); +}); + +test( "clone", function() { + var instance = new THREE.Face3(0, 1, 2, new THREE.Vector3(0, 1, 0), new THREE.Color(0.25, 0.5, 0.75), 2); + var copiedInstance = instance.clone(); + + checkCopy(copiedInstance); + checkVertexAndColors(copiedInstance); +}); + +function checkCopy(copiedInstance) { + ok( copiedInstance instanceof THREE.Face3, "copy created the correct type" ); + ok( + copiedInstance.a === 0 && + copiedInstance.b === 1 && + copiedInstance.c === 2 && + copiedInstance.materialIndex === 2 + ,"properties where copied" ); +} + +function checkVertexAndColors(copiedInstance) { + ok( + copiedInstance.normal.x === 0 && copiedInstance.normal.y === 1 && copiedInstance.normal.z === 0 && + copiedInstance.color.r === 0.25 && copiedInstance.color.g === 0.5 && copiedInstance.color.b === 0.75 + ,"properties where copied" ); +} + +function checkVertexAndColorArrays(copiedInstance) { + ok( + copiedInstance.vertexNormals[0].x === 0 && copiedInstance.vertexNormals[0].y === 1 && copiedInstance.vertexNormals[0].z === 0 && + copiedInstance.vertexNormals[1].x === 1 && copiedInstance.vertexNormals[1].y === 0 && copiedInstance.vertexNormals[1].z === 1 && + copiedInstance.vertexColors[0].r === 0.25 && copiedInstance.vertexColors[0].g === 0.5 && copiedInstance.vertexColors[0].b === 0.75 && + copiedInstance.vertexColors[1].r === 1 && copiedInstance.vertexColors[1].g === 0 && copiedInstance.vertexColors[1].b === 0.4 + ,"properties where copied" ); +}
false
Other
mrdoob
three.js
97374fdcbbd34e07cfb949ee8108ae03cc17fc68.json
add spacings to InterleavedBuffer
test/unit/core/InterleavedBuffer.js
@@ -4,10 +4,10 @@ module( "InterleavedBuffer" ); -function checkInstanceAgainstCopy(instance, copiedInstance) { +function checkInstanceAgainstCopy( instance, copiedInstance ) { ok( copiedInstance instanceof THREE.InterleavedBuffer, "the clone has the correct type" ); - for (var i = 0; i < instance.array.length; i++) { + for ( var i = 0; i < instance.array.length; i++ ) { ok( copiedInstance.array[i] === instance.array[i], "array was copied" ); }
false
Other
mrdoob
three.js
41789c1aef9c89a01af1a74b41346de103b03a93.json
add spacings to InstancedBufferGeometry
test/unit/core/InstancedBufferGeometry.js
@@ -7,8 +7,10 @@ module( "InstancedBufferGeometry" ); function createClonableMock() { return { callCount: 0, + clone: function() { this.callCount++; + return this; } } @@ -23,13 +25,13 @@ test( "copy", function() { var instance = new THREE.InstancedBufferGeometry(); - instance.addGroup(0, 10, instanceMock1); - instance.addGroup(10, 5, instanceMock2); - instance.setIndex(indexMock); - instance.addAttribute('attributeMock1', attributeMock1); - instance.addAttribute('attributeMock2', attributeMock2); + instance.addGroup( 0, 10, instanceMock1 ); + instance.addGroup( 10, 5, instanceMock2 ); + instance.setIndex( indexMock ); + instance.addAttribute( 'attributeMock1', attributeMock1 ); + instance.addAttribute( 'attributeMock2', attributeMock2 ); - var copiedInstance = instance.copy(instance); + var copiedInstance = instance.copy( instance ); ok( copiedInstance instanceof THREE.InstancedBufferGeometry, "the clone has the correct type" );
false
Other
mrdoob
three.js
2ac769af22f3f0c74b212a67ec977c2b20c46cc0.json
add spacings to InstancedBufferAttribute
test/unit/core/InstancedBufferAttribute.js
@@ -14,9 +14,9 @@ test( "can be created", function() { }); test( "copy", function() { - var array = new Float32Array([1, 2, 3, 7, 8, 9]); - var instance = new THREE.InstancedBufferAttribute(array, 2, 123); - var copiedInstance = instance.copy(instance); + var array = new Float32Array( [1, 2, 3, 7, 8, 9] ); + var instance = new THREE.InstancedBufferAttribute( array, 2, 123 ); + var copiedInstance = instance.copy( instance ); ok( copiedInstance instanceof THREE.InstancedBufferAttribute, "the clone has the correct type" ); ok( copiedInstance.itemSize === 2, "itemSize was copied" );
false
Other
mrdoob
three.js
7db944e26fcff4c522fd3170d0320ec5e43e6a14.json
add tests to html
test/unit/unittests_three.html
@@ -28,6 +28,7 @@ <script src="core/InterleavedBuffer.js"></script> <script src="core/InterleavedBufferAttribute.js"></script> + <script src="core/Geometry.js"></script> <script src="core/BufferAttribute.js"></script> <script src="core/BufferGeometry.js"></script> <script src="core/Clock.js"></script>
false
Other
mrdoob
three.js
5bf7d23f30e21caf0da337e3e84edd71c868e6ba.json
add first bunch of unit tests for geometry
test/unit/core/Geometry.js
@@ -0,0 +1,107 @@ +/** + * @author simonThiele / https://github.com/simonThiele + */ + +module( "Geometry" ); + +test( "rotateX", function() { + var geometry = getGeometry(); + + var matrix = new THREE.Matrix4(); + matrix.makeRotationX( Math.PI / 2 ); // 90 degree + + geometry.applyMatrix( matrix ); + + var v0 = geometry.vertices[0], v1 = geometry.vertices[1], v2 = geometry.vertices[2]; + ok ( v0.x === -0.5 && v0.y === 0 && v0.z === 0, "first vertex was rotated" ); + ok ( v1.x === 0.5 && v1.y === 0 && v1.z === 0, "second vertex was rotated" ); + ok ( v2.x === 0 && v2.y < Number.EPSILON && v2.z === 1, "third vertex was rotated" ); +}); + + +test( "rotateY", function() { + var geometry = getGeometry(); + + var matrix = new THREE.Matrix4(); + matrix.makeRotationY( Math.PI ); // 180 degrees + + geometry.applyMatrix( matrix ); + + var v0 = geometry.vertices[0], v1 = geometry.vertices[1], v2 = geometry.vertices[2]; + ok ( v0.x === 0.5 && v0.y === 0 && v0.z < Number.EPSILON, "first vertex was rotated" ); + ok ( v1.x === -0.5 && v1.y === 0 && v1.z < Number.EPSILON, "second vertex was rotated" ); + ok ( v2.x === 0 && v2.y === 1 && v2.z === 0, "third vertex was rotated" ); +}); + +test( "rotateZ", function() { + var geometry = getGeometry(); + + var matrix = new THREE.Matrix4(); + matrix.makeRotationZ( Math.PI / 2 * 3 ); // 270 degrees + + geometry.applyMatrix( matrix ); + + var v0 = geometry.vertices[0], v1 = geometry.vertices[1], v2 = geometry.vertices[2]; + ok ( v0.x < Number.EPSILON && v0.y === 0.5 && v0.z === 0, "first vertex was rotated" ); + ok ( v1.x < Number.EPSILON && v1.y === -0.5 && v1.z === 0, "second vertex was rotated" ); + ok ( v2.x === 1 && v2.y < Number.EPSILON && v2.z === 0, "third vertex was rotated" ); +}); + +test( "fromBufferGeometry", function() { + var bufferGeometry = new THREE.BufferGeometry(); + bufferGeometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9]), 3)); + bufferGeometry.addAttribute('color', new THREE.BufferAttribute(new Float32Array([0, 0, 0, 0.5, 0.5, 0.5, 1, 1, 1]), 3)); + bufferGeometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array([0, 1, 0, 1, 0, 1, 1, 1, 0]), 3)); + bufferGeometry.addAttribute('uv', new THREE.BufferAttribute(new Float32Array([0, 0, 0, 1, 1, 1]), 2)); + bufferGeometry.addAttribute('uv2', new THREE.BufferAttribute(new Float32Array([0, 0, 0, 1, 1, 1]), 2)); + + var geometry = new THREE.Geometry().fromBufferGeometry(bufferGeometry); + + var colors = geometry.colors; + ok ( + colors[0].r === 0 && colors[0].g === 0 && colors[0].b === 0 && + colors[1].r === 0.5 && colors[1].g === 0.5 && colors[1].b === 0.5 && + colors[2].r === 1 && colors[2].g === 1 && colors[2].b === 1 + , "colors were created well" ); + + var vertices = geometry.vertices; + ok ( + vertices[0].x === 1 && vertices[0].y === 2 && vertices[0].z === 3 && + vertices[1].x === 4 && vertices[1].y === 5 && vertices[1].z === 6 && + vertices[2].x === 7 && vertices[2].y === 8 && vertices[2].z === 9 + , "vertices were created well" ); + + var vNormals = geometry.faces[0].vertexNormals; + ok ( + vNormals[0].x === 0 && vNormals[0].y === 1 && vNormals[0].z === 0 && + vNormals[1].x === 1 && vNormals[1].y === 0 && vNormals[1].z === 1 && + vNormals[2].x === 1 && vNormals[2].y === 1 && vNormals[2].z === 0 + , "vertex normals were created well" ); +}); + +test( "normalize", function() { + var geometry = getGeometry(); + geometry.computeLineDistances(); + + var distances = geometry.lineDistances; + ok( distances[0] === 0, "distance to the 1st point is 0" ); + ok( distances[1] === 1 + distances[0], "distance from the 1st to the 2nd is sqrt(2nd - 1st) + distance - 1" ); + ok( distances[2] === Math.sqrt(0.5 * 0.5 + 1) + distances[1], "distance from the 1st to the 3nd is sqrt(3rd - 2nd) + distance - 1" ); +}); + +function getGeometryByParams( x1, y1, z1, x2, y2, z2, x3, y3, z3 ) { + var geometry = new THREE.Geometry(); + + // a triangle + geometry.vertices = [ + new THREE.Vector3( x1, y1, z1 ), + new THREE.Vector3( x2, y2, z2 ), + new THREE.Vector3( x3, y3, z3 ) + ]; + + return geometry; +} + +function getGeometry() { + return getGeometryByParams(-0.5, 0, 0, 0.5, 0, 0, 0, 1, 0); +}
false
Other
mrdoob
three.js
8d5fca0a266b8440062de3823a9624dacc7d9a25.json
Add Support for Reflectivity in Maya Exporter https://github.com/mrdoob/three.js/issues/7634 https://github.com/mrdoob/three.js/issues/7632
utils/exporters/maya/plug-ins/threeJsFileTranslator.py
@@ -241,6 +241,7 @@ def _exportMaterial(self, mat): "vertexColors": False } if isinstance(mat, nodetypes.Phong): + result["reflectivity"] = mat.getReflectivity() result["colorSpecular"] = mat.getSpecularColor().rgb result["specularCoef"] = mat.getCosPower() if self.options["specularMaps"]:
false
Other
mrdoob
three.js
04658393de0f78dc8d537c9409c0bb78c9a060ec.json
Add Support for Reflectivity in Loader.js https://github.com/mrdoob/three.js/issues/7632 https://github.com/mrdoob/three.js/issues/7634
src/loaders/Loader.js
@@ -240,6 +240,9 @@ THREE.Loader.prototype = { if ( value === true ) json.vertexColors = THREE.VertexColors; if ( value === 'face' ) json.vertexColors = THREE.FaceColors; break; + case 'reflectivity': + json.reflectivity = value; + break; default: console.error( 'THREE.Loader.createMaterial: Unsupported', name, value ); break;
false