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 | 6c12df36047a7066ee6e29fa5ef942f71a165c7a.json | Update convert_to_threejs.py (#9175)
syntax error for "print" on:
Line 388
Line 2066 | utils/converters/fbx/convert_to_threejs.py | @@ -385,7 +385,7 @@ def generate_material_object(material):
}
else:
- print "Unknown type of Material", getMaterialName(material)
+ print ("Unknown type of Material"), getMaterialName(material)
# default to Lambert Material if the current Material type cannot be handeled
if not material_type:
@@ -2063,7 +2063,7 @@ def copy_textures(textures):
shutil.copyfile(url, saveFilename)
texture_dict[url] = True
except IOError as e:
- print "I/O error({0}): {1} {2}".format(e.errno, e.strerror, url)
+ print ("I/O error({0}): {1} {2}").format(e.errno, e.strerror, url)
def findFilesWithExt(directory, ext, include_path = True):
ext = ext.lower() | false |
Other | mrdoob | three.js | 602f38034351fef9de6159ecce5005129b25a129.json | fix sea3d blending material (#9181) | examples/js/loaders/sea3d/SEA3DLoader.js | @@ -1627,30 +1627,30 @@ THREE.SEA3D.prototype.readContainer3D = function( sea ) {
THREE.SEA3D.prototype.readSprite = function( sea ) {
- var material;
+ var mat;
if ( sea.material ) {
if ( ! sea.material.tag.sprite ) {
- material = sea.material.tag.sprite = new THREE.SpriteMaterial();
+ mat = sea.material.tag.sprite = new THREE.SpriteMaterial();
- this.setBlending( material, sea.blendMode );
+ this.setBlending( mat, sea.blendMode );
- material.map = sea.material.tag.map;
- material.map.flipY = true;
+ mat.map = sea.material.tag.map;
+ mat.map.flipY = true;
- material.color.set( sea.material.tag.color );
- material.opacity = sea.material.tag.opacity;
- material.blending = sea.material.tag.blending;
- material.fog = sea.material.receiveFog;
+ mat.color.set( sea.material.tag.color );
+ mat.opacity = sea.material.tag.opacity;
+ mat.blending = sea.material.tag.blending;
+ mat.fog = sea.material.receiveFog;
}
- else material = sea.material.tag.sprite;
+ else mat = sea.material.tag.sprite;
}
- var sprite = new THREE.Sprite( material );
+ var sprite = new THREE.Sprite( mat );
sprite.name = sea.name;
this.domain.sprites = this.sprites = this.sprites || [];
@@ -2193,7 +2193,7 @@ THREE.SEA3D.prototype.createMaterial = function( sea ) {
};
-THREE.SEA3D.prototype.setBlending = function( material, blendMode ) {
+THREE.SEA3D.prototype.setBlending = function( mat, blendMode ) {
if ( blendMode == "normal" ) return;
| false |
Other | mrdoob | three.js | 3ec88490b2293606bb8aad37e4316e83cf523da3.json | fix physical node material | examples/js/nodes/materials/StandardNode.js | @@ -302,7 +302,7 @@ THREE.StandardNode.prototype.build = function( builder ) {
output.push(
environment.code,
- "RE_IndirectSpecular(" + environment.result + ", geometry, material, reflectedLight );"
+ "RE_IndirectSpecular_Physical(" + environment.result + ", vec3( 0.0 ), geometry, material, reflectedLight );"
);
} | false |
Other | mrdoob | three.js | b39fd5605fd6cea4bf2db315e7dad06ac62b711d.json | Terminate statement in KeyframeTrackPrototype | src/animation/KeyframeTrackPrototype.js | @@ -362,6 +362,6 @@ KeyframeTrackPrototype = {
}
-}
+};
export { KeyframeTrackPrototype }; | false |
Other | mrdoob | three.js | a7a9edc24048078843e35b1d069a77961924a1f8.json | Fix typo in AnimationClip | src/animation/AnimationClip.js | @@ -45,8 +45,7 @@ AnimationClip.prototype = {
var track = this.tracks[ i ];
- duration = Math.max(
- duration, track.times[ track.times.length - 1 ] );
+ duration = Math.max( duration, track.times[ track.times.length - 1 ] );
}
| false |
Other | mrdoob | three.js | 41158b56f3e77d29dfb49faefd554724ef2eadb5.json | Remove unnecessary semi-colon from AnimationAction | src/animation/AnimationAction.js | @@ -74,7 +74,7 @@ function AnimationAction( mixer, clip, localRoot ) {
this.zeroSlopeAtStart = true; // for smooth interpolation w/o separate
this.zeroSlopeAtEnd = true; // clips for start, loop and end
-};
+}
AnimationAction.prototype = {
| false |
Other | mrdoob | three.js | 6404d18493e9d75bd12bf5f7ae787d0ea51dac2b.json | remove THREE prefixes (#10066) | src/renderers/WebGLRenderer.js | @@ -161,8 +161,9 @@ function WebGLRenderer( parameters ) {
_projScreenMatrix = new Matrix4(),
- _vector3 = new THREE.Vector3(),
- _matrix4 = new THREE.Matrix4(), _matrix42 = new THREE.Matrix4(),
+ _vector3 = new Vector3(),
+ _matrix4 = new Matrix4(),
+ _matrix42 = new Matrix4(),
// light arrays cache
| false |
Other | mrdoob | three.js | 4704a6e1480eca02d1a10193f175bd2cde814b70.json | add badging to README.md (#9992) | README.md | @@ -1,6 +1,11 @@
three.js
========
+[![Latest NPM release][npm-badge]][npm-badge-url]
+[![License][license-badge]][license-badge-url]
+[![Dependencies][dependencies-badge]][dependencies-badge-url]
+[![Dev Dependencies][devDependencies-badge]][devDependencies-badge-url]
+
#### JavaScript 3D library ####
The aim of the project is to create an easy to use, lightweight, 3D library. The library provides <canvas>, <svg>, CSS3D and WebGL renderers.
@@ -66,3 +71,14 @@ If everything went well you should see [this](http://jsfiddle.net/hfj7gm6t/).
### Change log ###
[releases](https://github.com/mrdoob/three.js/releases)
+
+
+
+[npm-badge]: https://img.shields.io/npm/v/three.svg
+[npm-badge-url]: https://www.npmjs.com/package/three
+[license-badge]: https://img.shields.io/npm/l/three.svg
+[license-badge-url]: ./LICENSE
+[dependencies-badge]: https://img.shields.io/david/mrdoob/three.js.svg
+[dependencies-badge-url]: https://david-dm.org/mrdoob/three.js
+[devDependencies-badge]: https://img.shields.io/david/dev/mrdoob/three.js.svg
+[devDependencies-badge-url]: https://david-dm.org/mrdoob/three.js#info=devDependencies | false |
Other | mrdoob | three.js | afa1c183fd8840a2600becba41a4411b7fcfb66d.json | Terminate statement in Sphere test | test/unit/math/Sphere.js | @@ -92,7 +92,7 @@ test( "getBoundingBox", function() {
ok( a.getBoundingBox().equals( new THREE.Box3( zero3, two3 ) ), "Passed!" );
- a.set( zero3, 0 )
+ a.set( zero3, 0 );
ok( a.getBoundingBox().equals( new THREE.Box3( zero3, zero3 ) ), "Passed!" );
});
| false |
Other | mrdoob | three.js | 7cdc5db5b137ae4f7c6ae416a98c74aa2085ddae.json | Terminate statement in Matrix4 test | test/unit/math/Matrix4.js | @@ -217,7 +217,7 @@ test( "makeBasis/extractBasis", function() {
var identity = new THREE.Matrix4();
ok( matrixEquals4( a, identity ), "Passed!" );
- var testBases = [ [ new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( -1, 0, 0 ), new THREE.Vector3( 0, 0, 1 ) ] ]
+ var testBases = [ [ new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( -1, 0, 0 ), new THREE.Vector3( 0, 0, 1 ) ] ];
for( var i = 0; i < testBases.length; i ++ ) {
var testBasis = testBases[i];
var b = new THREE.Matrix4().makeBasis( testBasis[0], testBasis[1], testBasis[2] ); | false |
Other | mrdoob | three.js | aa97b2cad4311e7d5ad5e1935e306ca5803ac97d.json | Remove unneeded comma from BoxGeometry test | test/unit/geometries/BoxGeometry.tests.js | @@ -8,7 +8,7 @@
depth: 30,
widthSegments: 2,
heightSegments: 3,
- depthSegments: 4,
+ depthSegments: 4
};
var geometries; | false |
Other | mrdoob | three.js | bdfdbd3dc9bf3f83f7e6c485d63efc9e71acc6b5.json | Remove unneeded comma from BoxHelper test | test/unit/extras/helpers/BoxHelper.tests.js | @@ -3,7 +3,7 @@
'use strict';
var parameters = {
- diameter: 10,
+ diameter: 10
};
var geometries; | false |
Other | mrdoob | three.js | bb01ca7eb6dfab9cca85f440a5dfda292b184c7a.json | Simplify if statement in WebGLTextures | src/renderers/webgl/WebGLTextures.js | @@ -67,11 +67,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
function textureNeedsPowerOfTwo( texture ) {
- if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) return true;
- if ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) return true;
-
- return false;
-
+ return (texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) || ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
+
}
// Fallback filters for non-power-of-2 textures | false |
Other | mrdoob | three.js | b3491e78c1eeb6d8bf88509d6c2bf73774bb268e.json | Remove unneeded comma in WebGLProgram | src/renderers/webgl/WebGLProgram.js | @@ -87,7 +87,7 @@ function generateExtensions( extensions, parameters, rendererExtensions ) {
( extensions.derivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.normalMap || parameters.flatShading ) ? '#extension GL_OES_standard_derivatives : enable' : '',
( extensions.fragDepth || parameters.logarithmicDepthBuffer ) && rendererExtensions.get( 'EXT_frag_depth' ) ? '#extension GL_EXT_frag_depth : enable' : '',
( extensions.drawBuffers ) && rendererExtensions.get( 'WEBGL_draw_buffers' ) ? '#extension GL_EXT_draw_buffers : require' : '',
- ( extensions.shaderTextureLOD || parameters.envMap ) && rendererExtensions.get( 'EXT_shader_texture_lod' ) ? '#extension GL_EXT_shader_texture_lod : enable' : '',
+ ( extensions.shaderTextureLOD || parameters.envMap ) && rendererExtensions.get( 'EXT_shader_texture_lod' ) ? '#extension GL_EXT_shader_texture_lod : enable' : ''
];
return chunks.filter( filterEmptyLine ).join( '\n' ); | false |
Other | mrdoob | three.js | 1de867fae716726511f0f0ab059e14879d16030d.json | Remove unneeded comma in ShaderLib | src/renderers/shaders/ShaderLib.js | @@ -86,7 +86,7 @@ var ShaderLib = {
emissive : { value: new Color( 0x000000 ) },
roughness: { value: 0.5 },
metalness: { value: 0 },
- envMapIntensity : { value: 1 }, // temporary
+ envMapIntensity : { value: 1 } // temporary
}
),
| false |
Other | mrdoob | three.js | 58b05d3ec1e862c17e3aa80d9bae7861fa73eb21.json | Terminate statement in Vector3 | src/math/Vector3.js | @@ -710,7 +710,7 @@ Vector3.prototype = {
if ( typeof m === 'number' ) {
console.warn( 'THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).' );
- var temp = m
+ var temp = m;
m = index;
index = temp;
| false |
Other | mrdoob | three.js | 780dbe8c5dda2149a682bf6687d0732bffaab3cd.json | Remove unneeded comma at the end of Spherical | src/math/Spherical.js | @@ -78,7 +78,7 @@ Spherical.prototype = {
return this;
- },
+ }
};
| false |
Other | mrdoob | three.js | 3abc44cceb5d10905092384b98a6d1c51a267180.json | Remove unneeded comma in AmbiantLight | src/lights/AmbientLight.js | @@ -18,7 +18,7 @@ AmbientLight.prototype = Object.assign( Object.create( Light.prototype ), {
constructor: AmbientLight,
- isAmbientLight: true,
+ isAmbientLight: true
} );
| false |
Other | mrdoob | three.js | ae1573e26cf78e41e9eef5d4afd9111dba20229b.json | Fix typo in AnimationClip | src/animation/AnimationClip.js | @@ -310,8 +310,7 @@ Object.assign( AnimationClip, {
var times = [];
var values = [];
- for ( var m = 0;
- m !== animationKeys[k].morphTargets.length; ++ m ) {
+ for ( var m = 0; m !== animationKeys[k].morphTargets.length; ++ m ) {
var animationKey = animationKeys[k];
@@ -320,8 +319,7 @@ Object.assign( AnimationClip, {
}
- tracks.push( new NumberKeyframeTrack(
- '.morphTargetInfluence[' + morphTargetName + ']', times, values ) );
+ tracks.push( new NumberKeyframeTrack('.morphTargetInfluence[' + morphTargetName + ']', times, values ) );
}
| false |
Other | mrdoob | three.js | 1bfb2a76b4e4e7b05f60197b2b844835dfae0a53.json | Fix bad refactoring of loopCount member | src/animation/AnimationAction.js | @@ -473,7 +473,7 @@ AnimationAction.prototype = {
if ( loopCount === -1 ) {
// just started
- this.loopCount = 0;
+ this._loopCount = 0;
this._setEndings( true, true, false );
} | false |
Other | mrdoob | three.js | 84a68f359a06c33ce5042b8e7c57993cff2d0450.json | Fix comma expression in AnimationAction | src/animation/AnimationAction.js | @@ -273,7 +273,7 @@ AnimationAction.prototype = {
if ( interpolant === null ) {
- interpolant = mixer._lendControlInterpolant(),
+ interpolant = mixer._lendControlInterpolant();
this._timeScaleInterpolant = interpolant;
}
@@ -636,7 +636,7 @@ AnimationAction.prototype = {
if ( interpolant === null ) {
- interpolant = mixer._lendControlInterpolant(),
+ interpolant = mixer._lendControlInterpolant();
this._weightInterpolant = interpolant;
} | false |
Other | mrdoob | three.js | bbf8aa17f24de6016bdbb60735e3027a84c1e774.json | Remove unneeded comma in NumberKeyframeTrack | src/animation/tracks/NumberKeyframeTrack.js | @@ -21,7 +21,7 @@ NumberKeyframeTrack.prototype =
constructor: NumberKeyframeTrack,
- ValueTypeName: 'number',
+ ValueTypeName: 'number'
// ValueBufferType is inherited
| false |
Other | mrdoob | three.js | 607584f62e5cb58f037228a67e0efa69f25e687c.json | improve fbx and maya docs | utils/converters/fbx/README.md | @@ -48,8 +48,22 @@ Don't forget the visit the FBX SDK documentation website:
http://docs.autodesk.com/FBX/2013/ENU/FBX-SDK-Documentation/cpp_ref/index.html
```
+*Note:* If you use the OSX installer, it will install the Python packages into the following folder.
+
+```
+/Applications/Autodesk/FBX Python SDK/[VERSION]/lib/
+```
+
+If the tool still can't find the FBX SDK, you may need to copy the `fbx.so`, `FbxCommon.py` and `sip.so` files into your site_packages folder.
+
+If you don't know your site_packages folder, run `python` from shell and paste this:
+
+```py
+import site; site.getsitepackages()
+```
+
### Python
-* Requires Python 2.6 or 3.1 (The FBX SDK requires one of these versions)
+* Requires Python 2.6, 2.7 or 3.1 (The FBX SDK requires one of these versions)
``` bash
sudo apt-get install build-essential | true |
Other | mrdoob | three.js | 607584f62e5cb58f037228a67e0efa69f25e687c.json | improve fbx and maya docs | utils/exporters/maya/README.md | @@ -19,17 +19,21 @@ Exports Maya models to Three.js' JSON format. Currently supports exporting the
## Installation
-Install [pymel](http://download.autodesk.com/global/docs/maya2014/en_us/PyMel/install.html).
-Though the docs are way out of date, the process described still works as of
-2014.
+(Maya 2016 suggested)
+
+Install [pymel](http://download.autodesk.com/global/docs/maya2014/en_us/PyMel/install.html) if necessary – Maya 2015 and newer will already include this for you. If you need to install PyMel manually, you can clone the latest from the [LumaPictures/pymel](https://github.com/LumaPictures/pymel) repository.
Copy the scripts and plug-ins folders to the appropriate maya folder, where `maya-version` is your current version of Maya (eg. 2013-x64).
- Windows: `C:\Users\username\Documents\maya\maya-version`
- OSX: `~/Library/Preferences/Autodesk/maya/maya-version`
- Linux: `/usr/autodesk/userconfig/maya/maya-version`
-After that, you need to activate the plugin. In Maya, open `Window > Settings/Preferences > Plug-in Manager` and enable the checkboxes next to `threeJsFileTranslator.py`.
+After that, you need to activate the plugin. In Maya, open `Windows > Settings/Preferences > Plug-in Manager` and enable the checkboxes next to `threeJsFileTranslator.py`.
+
+![menu](http://i.imgur.com/XPsq77Q.png)
+
+![plugin](http://i.imgur.com/Bvlj8l6.png)
## Usage
| true |
Other | mrdoob | three.js | 64eb745c3c8bc9f59f681e7cab22bc7f444b9b3b.json | add TAARenderPass and polish MSAA example/code. | examples/js/postprocessing/ManualMSAARenderPass.js | @@ -18,16 +18,16 @@ THREE.ManualMSAARenderPass = function ( scene, camera, params ) {
if ( THREE.CompositeShader === undefined ) {
- console.error( "THREE.MSAAPass relies on THREE.CompositeShader" );
+ console.error( "THREE.ManualMSAARenderPass relies on THREE.CompositeShader" );
}
var compositeShader = THREE.CompositeShader;
- this.uniforms = THREE.UniformsUtils.clone( compositeShader.uniforms );
+ this.compositeUniforms = THREE.UniformsUtils.clone( compositeShader.uniforms );
this.materialComposite = new THREE.ShaderMaterial( {
- uniforms: this.uniforms,
+ uniforms: this.compositeUniforms,
vertexShader: compositeShader.vertexShader,
fragmentShader: compositeShader.fragmentShader,
transparent: true,
@@ -49,6 +49,8 @@ THREE.ManualMSAARenderPass = function ( scene, camera, params ) {
THREE.ManualMSAARenderPass.prototype = {
+ constructor: THREE.ManualMSAARenderPass,
+
dispose: function() {
if ( this.sampleRenderTarget ) {
@@ -88,8 +90,8 @@ THREE.ManualMSAARenderPass.prototype = {
var autoClear = renderer.autoClear;
renderer.autoClear = false;
- this.uniforms[ "scale" ].value = 1.0 / ( jitterOffsets.length );
- this.uniforms[ "tForeground" ].value = this.sampleRenderTarget;
+ this.compositeUniforms[ "scale" ].value = 1.0 / ( jitterOffsets.length );
+ this.compositeUniforms[ "tForeground" ].value = this.sampleRenderTarget;
// render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
for ( var i = 0; i < jitterOffsets.length; i ++ ) { | true |
Other | mrdoob | three.js | 64eb745c3c8bc9f59f681e7cab22bc7f444b9b3b.json | add TAARenderPass and polish MSAA example/code. | examples/js/postprocessing/TAARenderPass.js | @@ -0,0 +1,114 @@
+/**
+ * @author bhouston / http://clara.io/ *
+ */
+
+THREE.TAARenderPass = function ( scene, camera, params ) {
+
+ if ( THREE.ManualMSAARenderPass === undefined ) {
+
+ console.error( "THREE.TAARenderPass relies on THREE.ManualMSAARenderPass" );
+
+ }
+ THREE.ManualMSAARenderPass.call( this, scene, camera, params );
+
+ this.sampleLevel = 1;
+ this.accumulate = false;
+
+ if ( THREE.CompositeShader === undefined ) {
+
+ console.error( "THREE.TAARenderPass relies on THREE.CompositeShader" );
+
+ }
+
+ var accumulateShader = THREE.CompositeShader;
+ this.accumulateUniforms = THREE.UniformsUtils.clone( accumulateShader.uniforms );
+
+ this.materialAccumulate = new THREE.ShaderMaterial( {
+
+ uniforms: this.accumulateUniforms,
+ vertexShader: accumulateShader.vertexShader,
+ fragmentShader: accumulateShader.fragmentShader,
+ transparent: true,
+ blending: THREE.CustomBlending,
+ blendSrc: THREE.OneFactor,
+ blendDst: THREE.OneMinusSrcAlphaFactor,
+ blendEquation: THREE.AddEquation,
+ depthTest: false,
+ depthWrite: false
+
+ } );
+
+ this.camera3 = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
+ this.scene3 = new THREE.Scene();
+ this.quad3 = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), this.materialAccumulate );
+ this.scene3.add( this.quad3 );
+
+};
+
+THREE.TAARenderPass.prototype = Object.create( THREE.ManualMSAARenderPass.prototype );
+THREE.TAARenderPass.prototype.constructor = THREE.TAARenderPass;
+THREE.TAARenderPass.JitterVectors = THREE.ManualMSAARenderPass.JitterVectors;
+
+THREE.TAARenderPass.prototype.render = function ( renderer, writeBuffer, readBuffer, delta ) {
+
+ if( ! this.accumulate ) {
+
+ THREE.ManualMSAARenderPass.prototype.render.call( this, renderer, writeBuffer, readBuffer, delta );
+
+ this.accumulateIndex = 0;
+ return;
+
+ }
+
+ var jitterOffsets = THREE.TAARenderPass.JitterVectors[ 4 ];
+
+ var camera = ( this.camera || this.scene.camera );
+
+ if ( ! this.sampleRenderTarget ) {
+
+ this.sampleRenderTarget = new THREE.WebGLRenderTarget( readBuffer.width, readBuffer.height, this.params );
+
+ }
+
+
+ if( this.accumulateIndex < jitterOffsets.length ) {
+ var autoClear = renderer.autoClear;
+ renderer.autoClear = false;
+
+ this.accumulateUniforms[ "scale" ].value = 1.0 / ( jitterOffsets.length );
+ this.accumulateUniforms[ "tForeground" ].value = writeBuffer;
+
+ // render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
+ var numSamplesPerFrame = Math.pow( 2, this.sampleLevel );
+ 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,
+ jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16
+ readBuffer.width, readBuffer.height );
+ }
+
+ renderer.render( this.scene, this.camera, writeBuffer, true );
+
+ this.accumulateUniforms[ "scale" ].value = 1.0 / ( this.accumulateIndex + 1 );
+ renderer.render( this.scene3, this.camera3, this.sampleRenderTarget, ( this.accumulateIndex == 0 ) );
+
+ this.accumulateIndex ++;
+ 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 );
+
+ renderer.autoClear = true;
+
+ }
+
+ this.accumulateUniforms[ "scale" ].value = 1.0;
+ this.accumulateUniforms[ "tForeground" ].value = this.sampleRenderTarget;
+ renderer.render( this.scene3, this.camera3, writeBuffer );
+
+} | true |
Other | mrdoob | three.js | 64eb745c3c8bc9f59f681e7cab22bc7f444b9b3b.json | add TAARenderPass and polish MSAA example/code. | examples/webgl_postprocessing_msaa.html | @@ -29,6 +29,7 @@
<body>
<div id="info">
<a href="http://threejs.org" target="_blank">three.js</a> - Manual Multi-Sample Anti-Aliasing (MSAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a><br/><br/>
+ This manual approach to MSAA re-renders the scene with camera jitter and accumulates the results. It is a slow approach.<br/><br/>
Texture interpolation, mipmapping and anistropic sampling is disabled to emphasize<br/> the effect MSAA levels have one the resulting render quality.
</div>
@@ -50,7 +51,7 @@
<script>
- var camera, scene, renderer, composer, copyPass, manualMSAARenderPass;
+ var camera, scene, renderer, composer, copyPass, msaaRenderPass;
var gui, stats, texture;
var param = { MSAASampleLevel: 2 };
@@ -74,8 +75,8 @@
'Level 4: 16 Samples': 4
} ).onFinishChange( function() {
- if( manualMSAARenderPass ) {
- manualMSAARenderPass.sampleLevel = param.MSAASampleLevel;
+ if( msaaRenderPass ) {
+ msaaRenderPass.sampleLevel = param.MSAASampleLevel;
}
} );
@@ -128,9 +129,9 @@
composer = new THREE.EffectComposer( renderer );
- manualMSAARenderPass = new THREE.ManualMSAARenderPass( scene, camera );
- manualMSAARenderPass.sampleLevel = param.MSAASampleLevel;
- composer.addPass( manualMSAARenderPass );
+ msaaRenderPass = new THREE.ManualMSAARenderPass( scene, camera );
+ msaaRenderPass.sampleLevel = param.MSAASampleLevel;
+ composer.addPass( msaaRenderPass );
copyPass = new THREE.ShaderPass( THREE.CopyShader );
copyPass.renderToScreen = true;
@@ -154,7 +155,7 @@
var newWidth = Math.floor( width / pixelRatio ) || 1;
var newHeight = Math.floor( height / pixelRatio ) || 1;
composer.setSize( newWidth, newHeight );
- msaaPass.setSize( newWidth, newHeight );
+ msaaRenderPass.setSize( newWidth, newHeight );
}
| true |
Other | mrdoob | three.js | 64eb745c3c8bc9f59f681e7cab22bc7f444b9b3b.json | add TAARenderPass and polish MSAA example/code. | examples/webgl_postprocessing_taa.html | @@ -0,0 +1,213 @@
+<!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> - Temporal Anti-Aliasing (TAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a><br/><br/>
+ When the rotation stops the scene automatically improves its static visual quality by accumulating jittered renders.<br/>
+ This allows for the static quality of a high quality, but slow MSAA shader at the cost of a single render per frame (if sampleLevel = 0).<br/><br/>
+ Texture interpolation, mipmapping and anistropic sampling is disabled to emphasize<br/> the effect MSAA levels have one the resulting render quality.
+ </div>
+
+ <div id="container"></div>
+
+ <script src="../build/three.min.js"></script>
+ <script src="js/libs/stats.min.js"></script>
+ <script src="js/libs/dat.gui.min.js"></script>
+
+ <script src="js/postprocessing/ManualMSAARenderPass.js"></script>
+ <script src="js/postprocessing/TAARenderPass.js"></script>
+ <script src="js/shaders/CopyShader.js"></script>
+ <script src="js/shaders/CompositeShader.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>
+
+ var camera, scene, renderer, composer, copyPass, taaRenderPass, renderPass;
+ var gui, stats, texture;
+
+ var param = { TAAEnabled: "1", TAASampleLevel: 0 };
+
+ init();
+ animate();
+
+ clearGui();
+
+ function clearGui() {
+
+ if ( gui ) gui.destroy();
+
+ gui = new dat.GUI();
+
+ gui.add( param, 'TAAEnabled', {
+ 'Disabled': '0',
+ 'Enabled': '1'
+ } ).onFinishChange( function() {
+
+ if( taaRenderPass ) {
+
+ taaRenderPass.enabled = ( param.TAAEnabled === "1" );
+ renderPass.enabled = ( param.TAAEnabled !== "1" );
+
+ }
+
+ } );
+
+ gui.add( param, 'TAASampleLevel', {
+ '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
+ } ).onFinishChange( function() {
+
+ if( taaRenderPass ) {
+ taaRenderPass.sampleLevel = param.TAASampleLevel;
+ }
+
+ } );
+
+ gui.open();
+
+ }
+
+ function init() {
+
+ container = document.getElementById( "container" );
+
+ renderer = new THREE.WebGLRenderer( { antialias: false } );
+ renderer.setPixelRatio( window.devicePixelRatio );
+ renderer.setSize( window.innerWidth, window.innerHeight );
+ document.body.appendChild( renderer.domElement );
+
+ stats = new Stats();
+ stats.domElement.style.position = 'absolute';
+ stats.domElement.style.top = '0px';
+ container.appendChild( stats.domElement );
+
+ //
+
+ camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
+ camera.position.z = 300;
+
+ scene = new THREE.Scene();
+
+ var geometry = new THREE.BoxGeometry( 120, 120, 120 );
+ var material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
+
+ var mesh = new THREE.Mesh( geometry, material );
+ mesh.position.x = - 100;
+ scene.add( mesh );
+
+ var texture = new THREE.TextureLoader().load( "textures/brick_diffuse.jpg" );
+ texture.minFilter = THREE.NearestFilter;
+ texture.magFilter = THREE.NearestFilter;
+ texture.anisotropy = 1;
+ texture.generateMipmaps = false;
+
+ var material = new THREE.MeshBasicMaterial( { map: texture } );
+
+ var mesh = new THREE.Mesh( geometry, material );
+ mesh.position.x = 100;
+ scene.add( mesh );
+
+ // postprocessing
+
+ composer = new THREE.EffectComposer( renderer );
+
+ taaRenderPass = new THREE.TAARenderPass( scene, camera );
+ composer.addPass( taaRenderPass );
+
+ renderPass = new THREE.RenderPass( scene, camera );
+ renderPass.enabled = false;
+ composer.addPass( renderPass );
+
+ 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 );
+ taaRenderPass.setSize( newWidth, newHeight );
+
+ }
+
+ function animate() {
+
+ this.index = this.index || 0;
+
+ requestAnimationFrame( animate );
+
+ this.index ++;
+
+ if( Math.round( this.index / 200 ) % 2 === 0 ) {
+ for ( var i = 0; i < scene.children.length; i ++ ) {
+
+ var child = scene.children[ i ];
+
+ child.rotation.x += 0.005;
+ child.rotation.y += 0.01;
+
+ }
+ if( taaRenderPass ) taaRenderPass.accumulate = false;
+ }
+ else {
+ if( taaRenderPass ) taaRenderPass.accumulate = true;
+ }
+
+ composer.render();
+
+ stats.update();
+
+ }
+
+ </script>
+ <div>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 9e625f42488260f19d7a1af768b0312bfdc17e6c.json | fix weight accumulation. | examples/js/postprocessing/MSAAPass.js | @@ -92,7 +92,7 @@ THREE.MSAAPass.prototype = {
// this accumulation strategy is used to prevent decimation at low bit depths with lots of samples.
this.uniforms[ "scale" ].value = weight;
- weight *= 0.5;
+ weight = 1.0 / (i+1);
// clear on the first render, accumulate the others
var autoClear = renderer.autoClear; | false |
Other | mrdoob | three.js | 134f99d3cafec9d8798070339ab9e63d1c6307d0.json | add msaa to example files.js | examples/files.js | @@ -177,6 +177,7 @@ var files = {
"webgl_postprocessing_glitch",
"webgl_postprocessing_godrays",
"webgl_postprocessing_masking",
+ "webgl_postprocessing_msaa",
"webgl_postprocessing_nodes",
"webgl_postprocessing_smaa",
"webgl_postprocessing_ssao", | false |
Other | mrdoob | three.js | 4acd477f17a70bfef88b7e9c5411a5c4925c6f88.json | add stats to SMAA example. | examples/webgl_postprocessing_smaa.html | @@ -14,7 +14,10 @@
</head>
<body>
+ <div id="container"></div>
+
<script src="../build/three.min.js"></script>
+ <script src="js/libs/stats.min.js"></script>
<script src="js/postprocessing/SMAAPass.js"></script>
<script src="js/shaders/CopyShader.js"></script>
@@ -28,11 +31,18 @@
<script>
- var camera, scene, renderer, composer, pass;
+ var camera, scene, renderer, composer, pass, stats;
var geometry, material, object;
var textureLoader = new THREE.TextureLoader();
+ container = document.getElementById( "container" );
+
+ stats = new Stats();
+ stats.domElement.style.position = 'absolute';
+ stats.domElement.style.top = '0px';
+ container.appendChild( stats.domElement );
+
textureLoader.load( "./textures/brick_diffuse.jpg", function( meshTexture ) {
init( meshTexture );
animate();
@@ -100,9 +110,11 @@
composer.render();
+ stats.update();
+
}
</script>
-
+ </div>
</body>
</html>
| false |
Other | mrdoob | three.js | 0548de58d6f2c57891c9802e859b509dcba4b7a5.json | add resizing support to MSAA example. | examples/js/postprocessing/MSAAPass.js | @@ -69,6 +69,13 @@ THREE.MSAAPass.prototype = {
},
+
+ setSize: function ( width, height ) {
+
+ this.sampleRenderTarget.setSize( width, height );
+
+ },
+
render: function ( renderer, writeBuffer, readBuffer, delta ) {
if( ! this.sampleRenderTarget ) { | true |
Other | mrdoob | three.js | 0548de58d6f2c57891c9802e859b509dcba4b7a5.json | add resizing support to MSAA example. | examples/webgl_postprocessing_msaa.html | @@ -50,14 +50,11 @@
<script>
- var camera, scene, renderer, composer, pass;
- var geometry, material, gui, object, msaaPass, stats;
+ var camera, scene, renderer, composer, copyPass, msaaPass;
+ var geometry, material, gui, object, stats;
var param = { MSAASampleLevel: 2 };
-
- var clock = new THREE.Clock();
-
var textureLoader = new THREE.TextureLoader();
container = document.getElementById( "container" );
@@ -129,7 +126,7 @@
massPass.sampleLevel = param.MSAASampleLevel;
composer.addPass( massPass );
- var copyPass = new THREE.ShaderPass( THREE.CopyShader );
+ copyPass = new THREE.ShaderPass( THREE.CopyShader );
copyPass.renderToScreen = true;
composer.addPass( copyPass );
@@ -151,7 +148,7 @@
var newWidth = Math.floor( width / pixelRatio ) || 1;
var newHeight = Math.floor( height / pixelRatio ) || 1;
composer.setSize( newWidth, newHeight );
- pass.setSize( newWidth, newHeight );
+ if( msaaPass ) msaaPass.setSize( newWidth, newHeight );
}
| true |
Other | mrdoob | three.js | badfaad725177fbe522d3649a703f77dc0687a62.json | fix msaa pass, improve example. | examples/js/postprocessing/MSAAPass.js | @@ -1,5 +1,10 @@
/**
* @author bhouston / http://clara.io/
+ *
+ * NOTE: Accumulating a lot of samples with a 8-bit-per-channel RGB/RGBA buffer will
+ * lead to discretization effects. For accurate sample accumulation use a floating
+ * point buffer.
+ *
*/
THREE.MSAAPass = function ( scene, camera, params ) {
@@ -83,7 +88,10 @@ THREE.MSAAPass.prototype = {
renderer.render( this.scene, camera, this.sampleRenderTarget, true );
// clear on the first render, accumulate the others
+ var autoClear = renderer.autoClear;
+ renderer.autoClear = false;
renderer.render( this.scene2, this.camera2, writeBuffer, i === 0 );
+ renderer.autoClear = true;
}
| true |
Other | mrdoob | three.js | badfaad725177fbe522d3649a703f77dc0687a62.json | fix msaa pass, improve example. | examples/webgl_postprocessing_msaa.html | @@ -7,17 +7,36 @@
<style>
body {
margin: 0px;
- background-color: #000000;
+ 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="container"></div>
<div id="info">
- <a href="http://threejs.org" target="_blank">three.js</a> - Manual Multi-Sample Anti-Aliasing (MSAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a>
+ <a href="http://threejs.org" target="_blank">three.js</a> - Manual Multi-Sample Anti-Aliasing (MSAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a></br></br>
+ WARNING: High MSAA samples count will lead</br>to discretization effects when used with 8-bit per channel Render Buffers.
</div>
+
+ <div id="container"></div>
+
<script src="../build/three.min.js"></script>
+ <script src="js/libs/stats.min.js"></script>
+ <script src="js/libs/dat.gui.min.js"></script>
<script src="js/postprocessing/MSAAPass.js"></script>
<script src="js/shaders/CopyShader.js"></script>
@@ -32,15 +51,56 @@
<script>
var camera, scene, renderer, composer, pass;
- var geometry, material, object;
+ var geometry, material, gui, object, msaaPass, stats;
+
+ var param = { MSAASampleLevel: 2 };
+
+
+ var clock = new THREE.Clock();
var textureLoader = new THREE.TextureLoader();
+ container = document.getElementById( "container" );
+
+ stats = new Stats();
+ stats.domElement.style.position = 'absolute';
+ stats.domElement.style.top = '0px';
+ container.appendChild( stats.domElement );
+
textureLoader.load( "textures/brick_diffuse.jpg", function( meshTexture ) {
init( meshTexture );
animate();
+ clearGui();
+
+
});
+
+ function clearGui() {
+
+ if ( gui ) gui.destroy();
+
+ gui = new dat.GUI();
+
+ var example = gui.add( param, 'MSAASampleLevel', {
+ '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( massPass ) {
+ massPass.sampleLevel = param.MSAASampleLevel;
+ }
+
+ } );
+
+ gui.open();
+
+ }
+
function init( meshTexture ) {
renderer = new THREE.WebGLRenderer( { antialias: false } );
@@ -65,8 +125,8 @@
composer = new THREE.EffectComposer( renderer );
- var massPass = new THREE.MSAAPass( scene, camera );
- massPass.sampleLevel = 1;
+ massPass = new THREE.MSAAPass( scene, camera );
+ massPass.sampleLevel = param.MSAASampleLevel;
composer.addPass( massPass );
var copyPass = new THREE.ShaderPass( THREE.CopyShader );
@@ -104,9 +164,11 @@
composer.render();
+ stats.update();
+
}
</script>
-
+ <div>
</body>
</html> | true |
Other | mrdoob | three.js | 3c8cb97f516f2c29bc78224f2bce58ab9e7934a5.json | add link to reference for the sample patterns. | examples/js/postprocessing/MSAAPass.js | @@ -111,6 +111,8 @@ THREE.MSAAPass.normalizedJitterOffsets = function( jitterVectors ) {
// These jitter vectors are specified in integers because it is easier.
// I am assuming a [-8,8] integer grid, but it needs to be mapped onto [-0.5,0.5]
// before being used, thus these integers need to be scaled by 1/16.
+//
+// Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
THREE.MSAAPass.JitterVectors = [
THREE.MSAAPass.normalizedJitterOffsets( [
[ 0, 0 ] | false |
Other | mrdoob | three.js | 246d92bae8ca3ffb1e46cc52d600006e8764ab4f.json | remove debug comment. | examples/js/postprocessing/MSAAPass.js | @@ -39,8 +39,6 @@ THREE.MSAAPass = function ( scene, camera, params ) {
} );
- console.log( 'this.materialComposite', this.materialComposite );
-
this.camera2 = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
this.scene2 = new THREE.Scene();
this.quad2 = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), this.materialComposite ); | false |
Other | mrdoob | three.js | f787058cee5922066998072f706bd5697df76b45.json | Add missing semicolon in simplehttpserver.js | utils/servers/simplehttpserver.js | @@ -95,7 +95,7 @@ http.createServer(handleRequest).listen(port);
require('dns').lookup(require('os').hostname(), function (err, addr, fam) {
console.log('Running at http://' + addr + ((port === 80) ? '' : ':') + port + '/');
-})
+});
console.log('Three.js server has started...');
-console.log('Base directory at ' + currentDir);
\ No newline at end of file
+console.log('Base directory at ' + currentDir); | false |
Other | mrdoob | three.js | ac465dc48faad9d8b02818d57378311b78c315da.json | Remove unneeded comma in geometry.js | docs/scenes/js/geometry.js | @@ -205,7 +205,7 @@ var guis = {
heightSegments : 1,
openEnded : false,
thetaStart : 0,
- thetaLength : twoPi,
+ thetaLength : twoPi
};
function generateGeometry() {
@@ -251,7 +251,7 @@ var guis = {
heightSegments : 1,
openEnded : false,
thetaStart : 0,
- thetaLength : twoPi,
+ thetaLength : twoPi
};
function generateGeometry() {
@@ -296,7 +296,7 @@ var guis = {
heightSegments : 1,
openEnded : false,
thetaStart : 0,
- thetaLength : twoPi,
+ thetaLength : twoPi
};
function generateGeometry() {
@@ -339,7 +339,7 @@ var guis = {
heightSegments : 1,
openEnded : false,
thetaStart : 0,
- thetaLength : twoPi,
+ thetaLength : twoPi
};
function generateGeometry() {
@@ -380,7 +380,7 @@ var guis = {
radius : 10,
segments : 32,
thetaStart : 0,
- thetaLength : twoPi,
+ thetaLength : twoPi
};
function generateGeometry() {
@@ -410,7 +410,7 @@ var guis = {
radius : 10,
segments : 32,
thetaStart : 0,
- thetaLength : twoPi,
+ thetaLength : twoPi
};
function generateGeometry() {
@@ -438,7 +438,7 @@ var guis = {
var data = {
radius : 10,
- detail : 0,
+ detail : 0
};
function generateGeometry() {
@@ -464,7 +464,7 @@ var guis = {
var data = {
radius : 10,
- detail : 0,
+ detail : 0
};
function generateGeometry() {
@@ -490,7 +490,7 @@ var guis = {
var data = {
radius : 10,
- detail : 0,
+ detail : 0
};
function generateGeometry() {
@@ -516,7 +516,7 @@ var guis = {
var data = {
radius : 10,
- detail : 0,
+ detail : 0
};
function generateGeometry() {
@@ -551,7 +551,7 @@ var guis = {
var data = {
segments : 12,
phiStart : 0,
- phiLength : twoPi,
+ phiLength : twoPi
};
function generateGeometry() {
@@ -587,7 +587,7 @@ var guis = {
var data = {
segments : 12,
phiStart : 0,
- phiLength : twoPi,
+ phiLength : twoPi
};
function generateGeometry() {
@@ -614,7 +614,7 @@ var guis = {
var data = {
radius : 10,
- detail : 0,
+ detail : 0
};
function generateGeometry() {
@@ -640,7 +640,7 @@ var guis = {
var data = {
radius : 10,
- detail : 0,
+ detail : 0
};
function generateGeometry() {
@@ -730,7 +730,7 @@ var guis = {
thetaSegments : 8,
phiSegments : 8,
thetaStart : 0,
- thetaLength : twoPi,
+ thetaLength : twoPi
};
function generateGeometry() {
@@ -764,7 +764,7 @@ var guis = {
thetaSegments : 8,
phiSegments : 8,
thetaStart : 0,
- thetaLength : twoPi,
+ thetaLength : twoPi
};
function generateGeometry() {
@@ -799,7 +799,7 @@ var guis = {
phiStart : 0,
phiLength : twoPi,
thetaStart : 0,
- thetaLength : Math.PI,
+ thetaLength : Math.PI
};
function generateGeometry() {
@@ -835,7 +835,7 @@ var guis = {
phiStart : 0,
phiLength : twoPi,
thetaStart : 0,
- thetaLength : Math.PI,
+ thetaLength : Math.PI
};
function generateGeometry() {
@@ -866,7 +866,7 @@ var guis = {
var data = {
radius : 10,
- detail : 0,
+ detail : 0
};
function generateGeometry() {
@@ -892,7 +892,7 @@ var guis = {
var data = {
radius : 10,
- detail : 0,
+ detail : 0
};
function generateGeometry() { | false |
Other | mrdoob | three.js | 82c381cdac83888684eaa84505ffaf4540017099.json | Add missing closing tag in WebGLProgram.html | docs/api/renderers/webgl/WebGLProgram.html | @@ -55,6 +55,7 @@ <h3>Vertex shader (unconditional):</h3>
</div>
<h3>Vertex shader (conditional):</h3>
+ <div>
<code>
#ifdef USE_COLOR
// vertex color attribute | false |
Other | mrdoob | three.js | c722d4a41984f9fd76108afecf9b25959e3051ee.json | Add missing closing tag in BoxHelper.html | docs/api/extras/helpers/BoxHelper.html | @@ -40,8 +40,7 @@ <h2>Properties</h2>
<h2>Methods</h2>
<h3>[method:null update]( [page:Object3D object] )</h3>
- <div>
- Updates the helper's geometry to match the dimensions of the [page:Geometry.boundingBox bounding box] of the passed object's geometry.
+ <div>Updates the helper's geometry to match the dimensions of the [page:Geometry.boundingBox bounding box] of the passed object's geometry.</div>
<h2>Source</h2>
| false |
Other | mrdoob | three.js | 5c7a0202f000c89946300e7bff733893f6368a89.json | Fix missing closing tag in Curve.html | docs/api/extras/core/Curve.html | @@ -17,7 +17,7 @@ <h1>[name]</h1>
<h2>Examples</h2>
- <h3>[example:webgl_geometry_extrude_splines geometry / extrude / splines ]
+ <h3>[example:webgl_geometry_extrude_splines geometry / extrude / splines ]</h3>
<h2>Constructor</h2>
| false |
Other | mrdoob | three.js | 66e479edd3a46a7a44413c48f4a8beb16f8836bc.json | Fix uncorrect closing tags in Uniform.html | docs/api/core/Uniform.html | @@ -104,11 +104,11 @@ <h3>Uniform types</h3>
<tr>
<td>mat2</td>
<td>[page:Float32Array Float32Array] (*)</td>
- </td>
+ </tr>
<tr>
<td>mat2</td>
<td>[page:Array Array] (*)</td>
- </td>
+ </tr>
<tr>
<td>mat3</td>
<td>[page:Matrix3 THREE.Matrix3]</td>
@@ -165,12 +165,12 @@ <h3>Uniform types</h3>
</tr>
<tr>
<td>samplerCube</td>
- <td>[page:CubeTexture THREE.CubeTexture]</tr>
+ <td>[page:CubeTexture THREE.CubeTexture]</td>
</tr>
</tbody>
</table>
- </p>
+
<p>
(*) Same for an (innermost) array (dimension) of the same GLSL type, containing the components of all vectors or matrices in the array.
</p> | false |
Other | mrdoob | three.js | 5eaf62d2faa263161dc67b3d7db8bc1f91aad82d.json | Fix incorrect emphasis tag in BufferGeometry.html | docs/api/core/BufferGeometry.html | @@ -47,7 +47,7 @@ <h3>Example</h3>
<h3>Accessing attributes</h3>
<p>
- WebGL stores data associated with individual vertices of a geometry in <emph>attributes</emph>.
+ WebGL stores data associated with individual vertices of a geometry in <em>attributes</em>.
Examples include the position of the vertex, the normal vector for the vertex, the vertex color,
and so on. When using [page:Geometry], the [page:WebGLRenderer renderer] takes care of wrapping
up this information into typed array buffers and sending this data to the shader. With
| false |
Other | mrdoob | three.js | e496dd255b259a256d89100f731632b9d04fe4e1.json | Remove unneeded comma in list.js | docs/list.js | @@ -202,7 +202,7 @@ var list = {
[ "Loader", "api/loaders/Loader" ],
[ "MaterialLoader", "api/loaders/MaterialLoader" ],
[ "ObjectLoader", "api/loaders/ObjectLoader" ],
- [ "TextureLoader", "api/loaders/TextureLoader" ],
+ [ "TextureLoader", "api/loaders/TextureLoader" ]
],
"Loaders / Managers": [
@@ -349,7 +349,7 @@ var list = {
[ "CanvasRenderer", "examples/renderers/CanvasRenderer" ]
]
- },
+ }
};
| false |
Other | mrdoob | three.js | 55a697a86d6febe44d03ac740592abd3f5e293fc.json | Terminate statement in page.js | docs/page.js | @@ -104,7 +104,7 @@ var onDocumentLoad = function ( event ) {
prettyPrint();
- }
+ };
document.head.appendChild( prettify );
| false |
Other | mrdoob | three.js | 6a551f5261ef79098d51e669710341b354972ba7.json | Add link from MMD examples to MMD assets license | examples/models/mmd/Readme.txt | @@ -1,6 +1,6 @@
The files under this directory are NOT under MIT license, but other licenses.
-If you want to use them in your work, get original data, read readme, and follow
-their licenses.
+If you want to use them in your work, get original archive file, read readme,
+and follow their licenses.
1. Vocaloid stuffs
@@ -14,17 +14,17 @@ For detail, see http://piapro.net/en_for_creators.html
2. MMD stuffs
-In MMD, there is no unified license. If you want to use MMD works (models,
-songs, dances, and so on), read readme included in archive file and follow the
-license the author set.
+In MMD, there is no unified license. If you want to use MMD assets (models,
+songs, dances, and so on), read readme included in the original archive file
+and follow the license the author set.
-If the works are fan works, you must follow the original work's license. (For
+If the assets are fan works, you must follow the original work's license. (For
example, you also need to follow the license set by Crypton, not only the
-license the author set, to use a Miku MMD model)
+license the author set, to use a fan Miku MMD model)
-For your information, generally MMD works are very restricted to use.
+For your information, generally MMD assets are very restricted to use.
-Most MMD works are NOT allowed for
+Most MMD assets are NOT allowed for
- redistribution
- porn use
- commercial use | true |
Other | mrdoob | three.js | 6a551f5261ef79098d51e669710341b354972ba7.json | Add link from MMD examples to MMD assets license | examples/webgl_loader_mmd.html | @@ -28,6 +28,7 @@
<body>
<div id="info">
<a href="http://threejs.org" target="_blank">three.js</a> - MMDLoader test<br />
+ <a href="https://github.com/mrdoob/three.js/tree/master/examples/models/mmd#readme">MMD Assets license</a><br />
Copyright
<a href="http://www.geocities.jp/higuchuu4/index_e.htm" target="_blank">Model Data</a>
<a href="http://www.nicovideo.jp/watch/sm13147122" target="_blank">Dance Data</a> | true |
Other | mrdoob | three.js | 6a551f5261ef79098d51e669710341b354972ba7.json | Add link from MMD examples to MMD assets license | examples/webgl_loader_mmd_audio.html | @@ -28,6 +28,7 @@
<body>
<div id="info">
<a href="http://threejs.org" target="_blank">three.js</a> - MMDLoader test<br />
+ <a href="https://github.com/mrdoob/three.js/tree/master/examples/models/mmd#readme">MMD Assets license</a><br />
Copyright
<a href="http://www.geocities.jp/higuchuu4/index_e.htm" target="_blank">Model Data</a>
<a href="http://www.nicovideo.jp/watch/sm13147122" target="_blank">Dance Data</a> | true |
Other | mrdoob | three.js | 6a551f5261ef79098d51e669710341b354972ba7.json | Add link from MMD examples to MMD assets license | examples/webgl_loader_mmd_pose.html | @@ -28,6 +28,7 @@
<body>
<div id="info">
<a href="http://threejs.org" target="_blank">three.js</a> - MMDLoader test<br />
+ <a href="https://github.com/mrdoob/three.js/tree/master/examples/models/mmd#readme">MMD Assets license</a><br />
Copyright
<a href="http://www.geocities.jp/higuchuu4/index_e.htm" target="_blank">Model Data</a>
<a href="http://seiga.nicovideo.jp/seiga/im5162984" target="_blank">Pose Data</a> | true |
Other | mrdoob | three.js | 62923d60fdfed65dad7486fca25bc799d9ce8e60.json | Add type check to DepthTexture (#9774)
* Add type check to DepthTexture
* Move check logic of DepthTexture type to WebGLTextures.
* Add internalFormat check for DepthFormat type check | src/renderers/webgl/WebGLTextures.js | @@ -2,7 +2,7 @@
* @author mrdoob / http://mrdoob.com/
*/
-import { LinearFilter, NearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, FloatType, HalfFloatType, ClampToEdgeWrapping, NearestMipMapLinearFilter, NearestMipMapNearestFilter } from '../../constants';
+import { LinearFilter, NearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, ClampToEdgeWrapping, NearestMipMapLinearFilter, NearestMipMapNearestFilter } from '../../constants';
import { _Math } from '../../math/Math';
function WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, info ) {
@@ -446,12 +446,40 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
}
+ if ( texture.format === DepthFormat && internalFormat === _gl.DEPTH_COMPONENT ) {
+
+ // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
+ // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
+ // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
+ if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
+
+ console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
+
+ texture.type = UnsignedShortType;
+ glType = paramThreeToGL( texture.type );
+
+ }
+
+ }
+
// Depth stencil textures need the DEPTH_STENCIL internal format
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
if ( texture.format === DepthStencilFormat ) {
internalFormat = _gl.DEPTH_STENCIL;
+ // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
+ // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
+ // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
+ if ( texture.type !== UnsignedInt248Type ) {
+
+ console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );
+
+ texture.type = UnsignedInt248Type;
+ glType = paramThreeToGL( texture.type );
+
+ }
+
}
state.texImage2D( _gl.TEXTURE_2D, 0, internalFormat, image.width, image.height, 0, glFormat, glType, null ); | true |
Other | mrdoob | three.js | 62923d60fdfed65dad7486fca25bc799d9ce8e60.json | Add type check to DepthTexture (#9774)
* Add type check to DepthTexture
* Move check logic of DepthTexture type to WebGLTextures.
* Add internalFormat check for DepthFormat type check | src/textures/DepthTexture.js | @@ -1,5 +1,5 @@
import { Texture } from './Texture';
-import { NearestFilter, UnsignedShortType, DepthFormat, DepthStencilFormat } from '../constants';
+import { NearestFilter, UnsignedShortType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants';
/**
* @author Matt DesLauriers / @mattdesl
@@ -16,12 +16,13 @@ function DepthTexture( width, height, type, mapping, wrapS, wrapT, magFilter, mi
}
+ if ( type === undefined && format === DepthFormat ) type = UnsignedShortType;
+ if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
+
Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.image = { width: width, height: height };
- this.type = type !== undefined ? type : UnsignedShortType;
-
this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
| true |
Other | mrdoob | three.js | 21cb28d077c166f25aa4d462b673e25073ea02bb.json | remove obsolete elements and comments | src/renderers/shaders/UniformsLib.js | @@ -147,19 +147,12 @@ var UniformsLib = {
} },
// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
- rectAreaLights: { type: "sa", value: [], properties: {
- color: { type: "c" },
- position: { type: "v3" },
- width: { type: "v3" },
- height: { type: "v3" },
+ rectAreaLights: { value: [], properties: {
+ color: {},
+ position: {},
+ width: {},
+ height: {},
} }
- // rectAreaLights: { type: "sa", value: [], properties: {
- // color: { type: "c" },
- // position: { type: "v3" },
- // width: { type: "1f" },
- // height: { type: "1f" },
- // rotationMatrix: { type: "m4" }
- // } },
},
| false |
Other | mrdoob | three.js | 86748161b2b9f641d7d4cc9e10b96c172ad88e2a.json | Update color settings of MMD (#10083) | examples/js/loaders/MMDLoader.js | @@ -581,7 +581,7 @@ THREE.MMDLoader.prototype.parsePmd = function ( buffer ) {
p.diffuse = dv.getFloat32Array( 4 );
p.shininess = dv.getFloat32();
p.specular = dv.getFloat32Array( 3 );
- p.emissive = dv.getFloat32Array( 3 );
+ p.ambient = dv.getFloat32Array( 3 );
p.toonIndex = dv.getInt8();
p.edgeFlag = dv.getUint8();
p.faceCount = dv.getUint32() / 3;
@@ -1163,7 +1163,7 @@ THREE.MMDLoader.prototype.parsePmx = function ( buffer ) {
p.diffuse = dv.getFloat32Array( 4 );
p.specular = dv.getFloat32Array( 3 );
p.shininess = dv.getFloat32();
- p.emissive = dv.getFloat32Array( 3 );
+ p.ambient = dv.getFloat32Array( 3 );
p.flag = dv.getUint8();
p.edgeColor = dv.getFloat32Array( 4 );
p.edgeSize = dv.getFloat32();
@@ -1379,7 +1379,7 @@ THREE.MMDLoader.prototype.parsePmx = function ( buffer ) {
m.diffuse = dv.getFloat32Array( 4 );
m.specular = dv.getFloat32Array( 3 );
m.shininess = dv.getFloat32();
- m.emissive = dv.getFloat32Array( 3 );
+ m.ambient = dv.getFloat32Array( 3 );
m.edgeColor = dv.getFloat32Array( 4 );
m.edgeSize = dv.getFloat32();
m.textureColor = dv.getFloat32Array( 4 );
@@ -2198,7 +2198,6 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
var textures = [];
var textureLoader = new THREE.TextureLoader( this.manager );
var tgaLoader = new THREE.TGALoader( this.manager );
- var color = new THREE.Color();
var offset = 0;
var materialParams = [];
@@ -2294,9 +2293,22 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
offset += m.faceCount;
params.name = m.name;
- params.color = color.fromArray( [ m.diffuse[ 0 ], m.diffuse[ 1 ], m.diffuse[ 2 ] ] ).clone();
+
+ /*
+ * Color
+ *
+ * MMD MeshPhongMaterial
+ * diffuse - color
+ * specular - specular
+ * ambient - emissive * a
+ * (a = 1.0 without map texture or 0.2 with map texture)
+ *
+ * MeshPhongMaterial doesn't have ambient. Set it to emissive instead.
+ * It'll be too bright if material has map texture so using coef 0.2.
+ */
+ params.color = new THREE.Color( m.diffuse[ 0 ], m.diffuse[ 1 ], m.diffuse[ 2 ] );
params.opacity = m.diffuse[ 3 ];
- params.specular = color.fromArray( [ m.specular[ 0 ], m.specular[ 1 ], m.specular[ 2 ] ] ).clone();
+ params.specular = new THREE.Color( m.specular[ 0 ], m.specular[ 1 ], m.specular[ 2 ] );
params.shininess = m.shininess;
if ( params.opacity === 1.0 ) {
@@ -2388,12 +2400,8 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
}
- // TODO: check if this logic is right
- if ( params.map === undefined /* && params.envMap === undefined */ ) {
-
- params.emissive = color.fromArray( [ m.emissive[ 0 ], m.emissive[ 1 ], m.emissive[ 2 ] ] ).clone();
-
- }
+ var coef = ( params.map === undefined ) ? 1.0 : 0.2;
+ params.emissive = new THREE.Color( m.ambient[ 0 ] * coef, m.ambient[ 1 ] * coef, m.ambient[ 2 ] * coef );
materialParams.push( params );
| false |
Other | mrdoob | three.js | 1e38c130146e858d27c63b41259f1eec3dc5fed8.json | Update UCSCharacter.js (#8662) | examples/js/UCSCharacter.js | @@ -96,7 +96,7 @@ THREE.UCSCharacter = function() {
for ( var i = 0; i < textureUrls.length; i ++ ) {
- textures[ i ] = textureLoader.load( baseUrl + textureUrls[ i ], scope.checkLoadingComplete );
+ textures[ i ] = textureLoader.load( baseUrl + textureUrls[ i ], scope.checkLoadComplete );
textures[ i ].mapping = THREE.UVMapping;
textures[ i ].name = textureUrls[ i ];
| false |
Other | mrdoob | three.js | 508e4d63146888e20580e62dfe4e291bbc41785f.json | add jump action and update instructions (#8654) | examples/misc_fps.html | @@ -30,7 +30,7 @@
<body>
<div id="container"></div>
- <div id="info"><a href="http://threejs.org" target="_blank">three.js</a> - platformer demo. cubemap by <a href="http://www.zfight.com/" target="_blank">Jochum Skoglund</a>.<br />Use arrow keys to look around and WASD to move.</div>
+ <div id="info"><a href="http://threejs.org" target="_blank">three.js</a> - platformer demo. cubemap by <a href="http://www.zfight.com/" target="_blank">Jochum Skoglund</a>.<br />Use arrow keys to look around, WASD to move and SPACE to jump.</div>
<script src="../build/three.js"></script>
@@ -101,6 +101,10 @@
if( Math.abs( combined.x ) >= Math.abs( motion.velocity.x ) ) motion.velocity.x = combined.x;
if( Math.abs( combined.y ) >= Math.abs( motion.velocity.y ) ) motion.velocity.y = combined.y;
if( Math.abs( combined.z ) >= Math.abs( motion.velocity.z ) ) motion.velocity.z = combined.z;
+
+ //jump
+ var vy = keysPressed[keys.SP] ? 0.7 : 0;
+ motion.velocity.y += vy;
}
};
})(); | false |
Other | mrdoob | three.js | a58012bf39cfb602007d868505e5b271164379c9.json | Allow zooming while rotating (#8634) | examples/js/controls/OrbitControls.js | @@ -756,7 +756,7 @@ THREE.OrbitControls = function ( object, domElement ) {
function onMouseWheel( event ) {
- if ( scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE ) return;
+ if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return;
event.preventDefault();
event.stopPropagation(); | false |
Other | mrdoob | three.js | 5d892789529562f2ab8f8f540ab6ca481aabe172.json | allow THREE.Box3 as an input of Boxhelper (#8609)
This helps when when the bounding box is not computed from an object, but comes from elsewhere | src/extras/helpers/BoxHelper.js | @@ -30,7 +30,15 @@ THREE.BoxHelper.prototype.update = ( function () {
return function ( object ) {
- box.setFromObject( object );
+ if ( object instanceof THREE.Box3 ) {
+
+ box.copy( object );
+
+ } else {
+
+ box.setFromObject( object );
+
+ }
if ( box.isEmpty() ) return;
| false |
Other | mrdoob | three.js | 86cc5819dc6fe8e80b3119ab6c529e38693adde3.json | fix bug in invClipZ unpacking glsl code. (#8600) | examples/webgl_depth_texture.html | @@ -35,7 +35,7 @@
padding: 5px;
display: inline-block;
}
-
+
#error {
margin: auto;
margin-top: 40px;
@@ -45,7 +45,7 @@
background: #CE0808;
}
</style>
-
+
<script id="post-vert" type="x-shader/x-vertex">
varying vec2 vUv;
@@ -56,24 +56,20 @@
</script>
<script id="post-frag" type="x-shader/x-fragment">
#include <packing>
-
+
varying vec2 vUv;
uniform sampler2D tDiffuse;
uniform sampler2D tDepth;
uniform float cameraNear;
uniform float cameraFar;
+
float readDepth (sampler2D depthSampler, vec2 coord) {
- float cameraFarPlusNear = cameraFar + cameraNear;
- float cameraFarMinusNear = cameraFar - cameraNear;
- float cameraCoef = 2.0 * cameraNear;
- return cameraCoef / (cameraFarPlusNear - texture2D(depthSampler, coord).x * cameraFarMinusNear);
+ float fragCoordZ = texture2D(depthSampler, coord).x;
+ float viewZ = invClipZToViewZ( fragCoordZ, cameraNear, cameraFar );
+ return viewZToLinearClipZ( viewZ, cameraNear, cameraFar );
}
- // float depthTexel = texture2D(tDepth, vUv).x;
- // float depth = invClipZToViewZ(depthTexel, cameraNear, cameraFar);
- // float linearClipZ = viewZToLinearClipZ(depth, cameraNear, cameraFar);
-
void main() {
vec3 diffuse = texture2D(tDiffuse, vUv).rgb;
float depth = readDepth(tDepth, vUv); | true |
Other | mrdoob | three.js | 86cc5819dc6fe8e80b3119ab6c529e38693adde3.json | fix bug in invClipZ unpacking glsl code. (#8600) | src/renderers/shaders/ShaderChunk/packing.glsl | @@ -32,5 +32,5 @@ float viewZToInvClipZ( const in float viewZ, const in float near, const in float
return (( near + viewZ ) * far ) / (( far - near ) * viewZ );
}
float invClipZToViewZ( const in float invClipZ, const in float near, const in float far ) {
- return ( near * far ) / ( ( near - far ) * invClipZ - far );
+ return ( near * far ) / ( ( far - near ) * invClipZ - far );
} | true |
Other | mrdoob | three.js | f52454cd75246c0cfed5616ef6dd72d95438dd7f.json | add comment in docs. | docs/api/textures/Texture.html | @@ -128,6 +128,11 @@ <h3>[property:boolean premultiplyAlpha]</h3>
False by default, which is the norm for PNG images. Set to true if the RGB values have been stored premultiplied by alpha.
</div>
+ <h3>[property:number encoding]</h3>
+ <div>
+ Set to THREE.LinearEncoding by default, but supports sRGB, RGBE, RGBM, RGBD, LogLuv and Gamma corrected encodings. IMPORTANT: If this value is changed on a texture after the material has been used, it is necessary to trigger a Material.needsUpdate for this value to be realized in the shader.
+ </div>
+
<h3>[property:object onUpdate]</h3>
<div>
A callback function, called when the texture is updated (e.g., when needsUpdate has been set to true and then the texture is used). | false |
Other | mrdoob | three.js | 524f7112de67060e2bcf2a1d57a358c404ced14a.json | Add additional params to gui controls | examples/webgl_materials_displacementmap.html | @@ -66,14 +66,16 @@
var settings = {
metalness: 1.0,
roughness: 0.4,
+ ambientIntensity: 0.2,
aoMapIntensity: 1.0,
- displacementScale: 1.0,
+ envMapIntensity: 1.0,
+ displacementScale: 2.436143, // from original model
normalScale: 1.0
};
var mesh, material;
- var pointLight;
+ var pointLight, ambientLight;
var mouseX = 0;
var mouseY = 0;
@@ -112,6 +114,18 @@
} );
+ gui.add( settings, "ambientIntensity" ).min( 0 ).max( 1 ).onChange( function( value ) {
+
+ ambientLight.intensity = value;
+
+ } );
+
+ gui.add( settings, "envMapIntensity" ).min( 0 ).max( 3 ).onChange( function( value ) {
+
+ material.envMapIntensity = value;
+
+ } );
+
gui.add( settings, "displacementScale" ).min( 0 ).max( 3.0 ).onChange( function( value ) {
material.displacementScale = value;
@@ -120,7 +134,7 @@
gui.add( settings, "normalScale" ).min( - 1 ).max( 1 ).onChange( function( value ) {
- material.normalScale = new THREE.Vector2( 1, - 1 ).multiplyScalar( value );
+ material.normalScale.set( 1, - 1 ).multiplyScalar( value );
} );
@@ -154,7 +168,7 @@
// lights
- var ambientLight = new THREE.AmbientLight( 0x111111 );
+ ambientLight = new THREE.AmbientLight( 0xffffff, settings.ambientIntensity );
scene.add( ambientLight );
pointLight = new THREE.PointLight( 0xff0000, 0.5 );
@@ -206,10 +220,11 @@
aoMapIntensity: 1,
displacementMap: displacementMap,
- displacementScale: 2.436143,
- displacementBias: - 0.428408,
+ displacementScale: settings.displacementScale,
+ displacementBias: - 0.428408, // from original model
envMap: reflectionCube,
+ envMapIntensity: settings.envMapIntensity,
side: THREE.DoubleSide
| false |
Other | mrdoob | three.js | 15311e6b8f67ae37f5e5edd98be7506a7049b82a.json | add true sRGB support for texture.encodings. | src/Three.js | @@ -309,9 +309,10 @@ THREE.TriangleFanDrawMode = 2;
// Texture Encodings
THREE.LinearEncoding = 3000; // No encoding at all.
-THREE.sRGBEncoding = 3001; // AKA gamma 2.2.
+THREE.sRGBEncoding = 3001;
THREE.RGBEEncoding = 3002; // AKA Radiance
THREE.LogLuvEncoding = 3003;
THREE.RGBM7Encoding = 3004;
THREE.RGBM16Encoding = 3005;
THREE.RGBDEncoding = 3006; // MaxRange is 256
+THREE.GammaEncoding = 3007; // uses GAMMA_FACTOR | true |
Other | mrdoob | three.js | 15311e6b8f67ae37f5e5edd98be7506a7049b82a.json | add true sRGB support for texture.encodings. | src/renderers/shaders/ShaderChunk/encoding_template.glsl | @@ -17,6 +17,8 @@
return RGBMToLinear( value, 16.0 );
#elif ( MACRO_DECODE == ENCODING_RGBD )
return RGBDToLinear( value, 256.0 );
+ #elif ( MACRO_DECODE == ENCODING_Gamma )
+ return GammaToLinear( value, float( GAMMA_FACTOR ) );
#else
return vec4( 1.0, 0.0, 0.0, 1.0 );
#endif
@@ -37,6 +39,8 @@
return LinearToRGBM( value, 16.0 );
#elif ( MACRO_ENCODE == ENCODING_RGBD )
return LinearToRGBD( value, 256.0 );
+ #elif ( MACRO_ENCODE == ENCODING_Gamma )
+ return LinearToGamma( value, float( GAMMA_FACTOR ) );
#else
return vec4( 1.0, 0.0, 0.0, 1.0 );
#endif | true |
Other | mrdoob | three.js | 15311e6b8f67ae37f5e5edd98be7506a7049b82a.json | add true sRGB support for texture.encodings. | src/renderers/shaders/ShaderChunk/encodings.glsl | @@ -8,16 +8,31 @@
#define ENCODING_RGBM7 3004
#define ENCODING_RGBM16 3005
#define ENCODING_RGBD 3006
+#define ENCODING_Gamma 3007
vec4 LinearToLinear( in vec4 value ) {
return value;
}
+vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
+ return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );
+}
+vec4 LinearTosGamma( in vec4 value, in float gammaFactor ) {
+ return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );
+}
+
+float sRGBToLinear_Component( float c ) {
+ return ( c <= 0.04045 ) ? ( c * 0.0773993808 ) : pow( c * 0.9478672986 + 0.0521327014, 2.4 );
+}
+float LinearTosRGB_Component( float c ) {
+ return ( c <= 0.0031308 ) ? ( c * 12.92 ) : ( pow( c, 0.41666 ) - 0.055 );
+}
+
vec4 sRGBToLinear( in vec4 value ) {
- return vec4( pow( value.xyz, vec3( float( GAMMA_FACTOR ) ) ), value.w );
+ return vec4( sRGBToLinear_Component( value.r ), sRGBToLinear_Component( value.g ), sRGBToLinear_Component( value.b ), value.w );
}
vec4 LinearTosRGB( in vec4 value ) {
- return vec4( pow( value.xyz, vec3( 1.0 / float( GAMMA_FACTOR ) ) ), value.w );
+ return vec4( LinearTosRGB_Component( value.r ), LinearTosRGB_Component( value.g ), LinearTosRGB_Component( value.b ), value.w );
}
vec4 RGBEToLinear( in vec4 value ) { | true |
Other | mrdoob | three.js | 44708dd3b9ba40a0dcb2d3709e33bcf24d336060.json | Remove Geometry.__tmpVertices from examples | examples/js/modifiers/ExplodeModifier.js | @@ -38,6 +38,5 @@ THREE.ExplodeModifier.prototype.modify = function ( geometry ) {
}
geometry.vertices = vertices;
- delete geometry.__tmpVertices;
}; | true |
Other | mrdoob | three.js | 44708dd3b9ba40a0dcb2d3709e33bcf24d336060.json | Remove Geometry.__tmpVertices from examples | examples/js/modifiers/SubdivisionModifier.js | @@ -31,8 +31,6 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
}
- delete geometry.__tmpVertices;
-
geometry.computeFaceNormals();
geometry.computeVertexNormals();
| true |
Other | mrdoob | three.js | ffea217069b6bddbec2bc2e7048f59f4158f0560.json | replace \w with [^\s]
because people keep using characters that do not match \w | examples/js/loaders/VRMLLoader.js | @@ -573,7 +573,7 @@ THREE.VRMLLoader.prototype = {
if ( /USE/.exec( data ) ) {
- var defineKey = /USE\s+?(\w+)/.exec( data )[ 1 ];
+ var defineKey = /USE\s+?([^\s]+)/.exec( data )[ 1 ];
if ( undefined == defines[ defineKey ] ) {
@@ -620,7 +620,7 @@ THREE.VRMLLoader.prototype = {
if ( /DEF/.exec( data.string ) ) {
- object.name = /DEF\s+(\w+)/.exec( data.string )[ 1 ];
+ object.name = /DEF\s+([^\s]+)/.exec( data.string )[ 1 ];
defines[ object.name ] = object;
}
@@ -657,7 +657,7 @@ THREE.VRMLLoader.prototype = {
if ( /DEF/.exec( data.string ) ) {
- object.name = /DEF\s+(\w+)/.exec( data.string )[ 1 ];
+ object.name = /DEF\s+([^\s]+)/.exec( data.string )[ 1 ];
defines[ object.name ] = object;
@@ -763,15 +763,15 @@ THREE.VRMLLoader.prototype = {
if ( child.string.indexOf ( 'DEF' ) > -1 ) {
- var name = /DEF\s+(\w+)/.exec( child.string )[ 1 ];
+ var name = /DEF\s+([^\s]+)/.exec( child.string )[ 1 ];
defines[ name ] = geometry.vertices;
}
if ( child.string.indexOf ( 'USE' ) > -1 ) {
- var defineKey = /USE\s+(\w+)/.exec( child.string )[ 1 ];
+ var defineKey = /USE\s+([^\s]+)/.exec( child.string )[ 1 ];
geometry.vertices = defines[ defineKey ];
}
@@ -853,7 +853,7 @@ THREE.VRMLLoader.prototype = {
// see if it's a define
if ( /DEF/.exec( data.string ) ) {
- geometry.name = /DEF (\w+)/.exec( data.string )[ 1 ];
+ geometry.name = /DEF ([^\s]+)/.exec( data.string )[ 1 ];
defines[ geometry.name ] = geometry;
}
@@ -911,7 +911,7 @@ THREE.VRMLLoader.prototype = {
if ( /DEF/.exec( data.string ) ) {
- material.name = /DEF (\w+)/.exec( data.string )[ 1 ];
+ material.name = /DEF ([^\s]+)/.exec( data.string )[ 1 ];
defines[ material.name ] = material;
| false |
Other | mrdoob | three.js | a4c5926c3454790826dcd2a6f815523ca2f5e958.json | remove unused encoding functions. | src/renderers/shaders/ShaderChunk/encodings.glsl | @@ -38,68 +38,3 @@ vec4 LinearToRGBE( in vec4 value ) {
float fExp = ceil( log2(maxComponent) );
return vec4( value.rgb / exp2(fExp), (fExp + 128.0) / 255.0 );
}
-/*
-vec4 EncodingToLinear( in vec4 value, in int fromEncoding ) {
-
- switch( fromEncoding ) {
-
- case ENCODING_Linear:
- return value;
-
- case ENCODING_sRGB:
- return LinearTosRGB( value );
-
- //case ENCODING_LogLuv:
- // return LinearToLogLuv( value );
-
- case ENCODING_RGBE:
- return LinearToRGBE( value );
-
- case ENCODING_RGBM7:
- return LinearToRGBM7( value );
-
- case ENCODING_RGBM16:
- return LinearToRGBM16( value );
-
- //case ENCODING_RGBD:
- // return LinearToRGBD( value );
-
- default:
- return vec4( 1.0, 0.0, 0.0, 1.0 );
-
- }
-
-}
-
-vec4 LinearToEncoding( in vec4 value, in int toEncoding )
-{
- switch( toEncoding ) {
-
- case ENCODING_Linear:
- return value;
-
- case ENCODING_sRGB:
- return sRGBToLinear( value );
-
- //case ENCODING_LogLuv:
- // return LogLuvToLinear( value );
-
- case ENCODING_RGBE:
- return RGBEToLinear( value );
-
- //case ENCODING_RGBM7:
- // return RGBM7ToLinear( value );
-
- //case ENCODING_RGBM16:
- // return RGBM16ToLinear( value );
-
- //case ENCODING_RGBD:
- // return RGBDToLinear( value );
-
- default:
- return vec4( 1.0, 0.0, 0.0, 1.0 );
-
- }
-
-}
-*/ | false |
Other | mrdoob | three.js | 3ca76ecd4c2a784a1b7b38795f6f40d1c8b7d148.json | make encodings.glsl more reusable. | src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl | @@ -2,7 +2,7 @@
vec4 emissiveColor = texture2D( emissiveMap, vUv );
- emissiveColor.rgb = texelDecode( emissiveColor, emissiveMapEncoding ).rgb;
+ emissiveColor.rgb = EncodingToLinear( emissiveColor, emissiveMapEncoding ).rgb;
totalEmissiveLight *= emissiveColor.rgb;
| true |
Other | mrdoob | three.js | 3ca76ecd4c2a784a1b7b38795f6f40d1c8b7d148.json | make encodings.glsl more reusable. | src/renderers/shaders/ShaderChunk/encodings.glsl | @@ -9,79 +9,96 @@
#define ENCODING_RGBM16 3005
//#define ENCODING_RGBM16 3007
-vec4 texelDecode( in vec4 encodedTexel, in int encoding ) {
+vec4 LinearToLinear( in vec4 value ) {
+ return value;
+}
- // Q: should we use a switch statement here instead of a set of ifs?
+vec4 sRGBToLinear( in vec4 value ) {
+ return vec4( pow( value.xyz, vec3( float( GAMMA_FACTOR ) ) ), value.w );
+}
- if( encoding == ENCODING_Linear ) {
- return encodedTexel;
- }
+vec4 RGBEToLinear( in vec4 value ) {
+ return vec4( value.xyz * exp2( value.w*256.0 - 128.0 ), 1.0 );
+}
- if( encoding == ENCODING_sRGB ) {
- return vec4( pow( encodedTexel.xyz, vec3( float( GAMMA_FACTOR ) ) ), encodedTexel.w );
- }
+vec4 RGBM7ToLinear( in vec4 value ) {
+ return vec4( value.xyz * value.w * 7.0, 1.0 );
+}
- if( encoding == ENCODING_RGBE ) {
- return vec4( encodedTexel.xyz * exp2( encodedTexel.w*256.0 - 128.0 ), 1.0 );
- }
+vec4 RGBM16ToLinear( in vec4 value ) {
+ return vec4( value.xyz * value.w * 16.0, 1.0 );
+}
- // TODO, see here http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html
- //if( encoding == ENCODING_LogLuv ) {
- //}
+vec4 LinearTosRGB( in vec4 value ) {
+ return vec4( pow( value.xyz, vec3( 1.0 / float( GAMMA_FACTOR ) ) ), value.w );
+}
- if( encoding == ENCODING_RGBM7 ) {
- return vec4( encodedTexel.xyz * encodedTexel.w * 7.0, 1.0 );
- }
+vec4 LinearToRGBE( in vec4 value ) {
+ float maxComponent = max(max(value.r, value.g), value.b );
+ float fExp = ceil( log2(maxComponent) );
+ return vec4( value.rgb / exp2(fExp), (fExp + 128.0) / 255.0 );
+}
- if( encoding == ENCODING_RGBM16 ) {
- return vec4( encodedTexel.xyz * encodedTexel.w * 16.0, 1.0 );
- }
+vec4 EncodingToLinear( in vec4 value, in int fromEncoding ) {
+
+ switch( fromEncoding ) {
- // TODO
- //if( encoding == ENCODING_RGBD ) {
- //}
+ case ENCODING_Linear:
+ return value;
- // return red when encoding not supported
- return vec4( 1.0, 0.0, 0.0, 1.0 );
+ case ENCODING_sRGB:
+ return LinearTosRGB( value );
+
+ //case ENCODING_LogLuv:
+ // return LinearToLogLuv( value );
+
+ case ENCODING_RGBE:
+ return LinearToRGBE( value );
+
+ case ENCODING_RGBM7:
+ return LinearToRGBM7( value );
+
+ case ENCODING_RGBM16:
+ return LinearToRGBM16( value );
+
+ //case ENCODING_RGBD:
+ // return LinearToRGBD( value );
+
+ default:
+ return vec4( 1.0, 0.0, 0.0, 1.0 );
+
+ }
}
-vec4 texelEncode( in vec4 linearRgba, in int encoding )
+vec4 LinearToEncoding( in vec4 value, in int toEncoding )
{
+ switch( toEncoding ) {
- // Q: should we use a switch statement here instead of a set of ifs?
+ case ENCODING_Linear:
+ return value;
- if( encoding == ENCODING_Linear ) {
- return linearRgba;
- }
+ case ENCODING_sRGB:
+ return sRGBToLinear( value );
- if( encoding == ENCODING_sRGB ) {
- return vec4( pow( linearRgba.xyz, vec3( 1.0 / float( GAMMA_FACTOR ) ) ), linearRgba.w );
- }
+ //case ENCODING_LogLuv:
+ // return LogLuvToLinear( value );
- if( encoding == ENCODING_RGBE ) {
- float maxComponent = max(max(linearRgba.r, linearRgba.g), linearRgba.b );
- float fExp = ceil( log2(maxComponent) );
- return vec4( linearRgba.rgb / exp2(fExp), (fExp + 128.0) / 255.0 );
- }
+ case ENCODING_RGBE:
+ return RGBEToLinear( value );
- // TODO, see here http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html
- //if( encoding == ENCODING_LogLuv ) {
- //}
+ //case ENCODING_RGBM7:
+ // return RGBM7ToLinear( value );
- // TODO
- //if( encoding == ENCODING_RGBM7 ) {
- //}
+ //case ENCODING_RGBM16:
+ // return RGBM16ToLinear( value );
- // TODO
- //if( encoding == ENCODING_RGBM16 ) {
- //}
+ //case ENCODING_RGBD:
+ // return RGBDToLinear( value );
- // TODO
- //if( encoding == ENCODING_RGBD ) {
- //}
+ default:
+ return vec4( 1.0, 0.0, 0.0, 1.0 );
- // return red when encoding not supported
- return vec4( 1.0, 0.0, 0.0, 1.0 );
+ }
} | true |
Other | mrdoob | three.js | 3ca76ecd4c2a784a1b7b38795f6f40d1c8b7d148.json | make encodings.glsl more reusable. | src/renderers/shaders/ShaderChunk/envmap_fragment.glsl | @@ -43,7 +43,7 @@
vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );
#endif
- envColor = texelDecode( envColor, envMapEncoding );
+ envColor = EncodingToLinear( envColor, envMapEncoding );
#ifdef ENVMAP_BLENDING_MULTIPLY
| true |
Other | mrdoob | three.js | 3ca76ecd4c2a784a1b7b38795f6f40d1c8b7d148.json | make encodings.glsl more reusable. | src/renderers/shaders/ShaderChunk/lights_pars.glsl | @@ -186,7 +186,7 @@
#endif
- envMapColor.rgb = texelDecode( envMapColor, envMapEncoding ).rgb;
+ envMapColor.rgb = EncodingToLinear( envMapColor, envMapEncoding ).rgb;
return PI * envMapColor.rgb * envMapIntensity;
@@ -278,7 +278,7 @@
#endif
- envMapColor.rgb = texelDecode( envMapColor, envMapEncoding ).rgb;
+ envMapColor.rgb = EncodingToLinear( envMapColor, envMapEncoding ).rgb;
return envMapColor.rgb * envMapIntensity;
| true |
Other | mrdoob | three.js | 3ca76ecd4c2a784a1b7b38795f6f40d1c8b7d148.json | make encodings.glsl more reusable. | src/renderers/shaders/ShaderChunk/map_fragment.glsl | @@ -2,7 +2,7 @@
vec4 texelColor = texture2D( map, vUv );
- texelColor = texelDecode( texelColor, mapEncoding );
+ texelColor = EncodingToLinear( texelColor, mapEncoding );
diffuseColor *= texelColor;
#endif | true |
Other | mrdoob | three.js | 15e08c1327f439b397c4f074da3f17ff10e13568.json | add support for Texture.encoding to Material.map | src/Three.js | @@ -315,3 +315,4 @@ THREE.RGBEEncoding = 3002; // AKA Radiance
THREE.RGBM7Encoding = 3004;
THREE.RGBM16Encoding = 3005;
//THREE.RGBDEncoding = 3006; TODO
+THREE.DefaultEncoding = 3007; // Use sRGB or Linear as appropriate. | true |
Other | mrdoob | three.js | 15e08c1327f439b397c4f074da3f17ff10e13568.json | add support for Texture.encoding to Material.map | src/renderers/WebGLRenderer.js | @@ -1888,6 +1888,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
uniforms.map.value = material.map;
+ uniforms.mapEncoding.value = (( material.map && material.map.encoding !== THREE.DefaultEncoding ) ? material.map.encoding : THREE.sRGBEncoding );
uniforms.specularMap.value = material.specularMap;
uniforms.alphaMap.value = material.alphaMap;
@@ -1962,7 +1963,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
uniforms.envMap.value = material.envMap;
- uniforms.envMapEncoding.value = ( material.envMap ? material.envMap.encoding : THREE.LinearEncoding );
+ uniforms.envMapEncoding.value = (( material.envMap && material.envMap.encoding !== THREE.DefaultEncoding )? material.envMap.encoding : THREE.LinearEncoding );
uniforms.flipEnvMap.value = ( material.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : - 1;
uniforms.reflectivity.value = material.reflectivity;
@@ -2034,7 +2035,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( material.emissiveMap ) {
uniforms.emissiveMap.value = material.emissiveMap;
- uniforms.emissiveMapEncoding.value = material.emissiveMap.encoding;
+ uniforms.emissiveMapEncoding.value = ( material.emissiveMap.encoding !== THREE.DefaultEncoding ) ? material.emissiveMap.encoding : THREE.LinearEncoding;
}
@@ -2055,7 +2056,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( material.emissiveMap ) {
uniforms.emissiveMap.value = material.emissiveMap;
- uniforms.emissiveMapEncoding.value = material.emissiveMap.encoding;
+ uniforms.emissiveMapEncoding.value = ( material.emissiveMap.encoding !== THREE.DefaultEncoding ) ? material.emissiveMap.encoding : THREE.LinearEncoding;
}
@@ -2110,7 +2111,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( material.emissiveMap ) {
uniforms.emissiveMap.value = material.emissiveMap;
- uniforms.emissiveMapEncoding.value = material.emissiveMap.encoding;
+ uniforms.emissiveMapEncoding.value = ( material.emissiveMap.encoding !== THREE.DefaultEncoding ) ? material.emissiveMap.encoding : THREE.LinearEncoding;
}
| true |
Other | mrdoob | three.js | 15e08c1327f439b397c4f074da3f17ff10e13568.json | add support for Texture.encoding to Material.map | src/renderers/shaders/ShaderChunk/encodings.glsl | @@ -18,7 +18,7 @@ vec4 texelDecode( in vec4 encodedTexel, in int encoding ) {
}
if( encoding == ENCODING_sRGB ) {
- return vec4( pow( encodedTexel.xyz, vec3( GAMMA_FACTOR ) ), encodedTexel.w );
+ return vec4( pow( encodedTexel.xyz, vec3( float( GAMMA_FACTOR ) ) ), encodedTexel.w );
}
if( encoding == ENCODING_RGBE ) {
@@ -56,7 +56,7 @@ vec4 texelEncode( in vec4 linearRgba, in int encoding )
}
if( encoding == ENCODING_sRGB ) {
- return vec4( pow( linearRgba.xyz, vec3( 1.0 / GAMMA_FACTOR ) ), linearRgba.w );
+ return vec4( pow( linearRgba.xyz, vec3( 1.0 / float( GAMMA_FACTOR ) ) ), linearRgba.w );
}
if( encoding == ENCODING_RGBE ) { | true |
Other | mrdoob | three.js | 15e08c1327f439b397c4f074da3f17ff10e13568.json | add support for Texture.encoding to Material.map | src/renderers/shaders/ShaderChunk/map_fragment.glsl | @@ -2,8 +2,7 @@
vec4 texelColor = texture2D( map, vUv );
- texelColor.xyz = inputToLinear( texelColor.xyz );
-
+ texelColor = texelDecode( texelColor, mapEncoding );
diffuseColor *= texelColor;
#endif | true |
Other | mrdoob | three.js | 15e08c1327f439b397c4f074da3f17ff10e13568.json | add support for Texture.encoding to Material.map | src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl | @@ -1,5 +1,6 @@
#ifdef USE_MAP
uniform sampler2D map;
+ uniform int mapEncoding;
-#endif
\ No newline at end of file
+#endif | true |
Other | mrdoob | three.js | 15e08c1327f439b397c4f074da3f17ff10e13568.json | add support for Texture.encoding to Material.map | src/renderers/shaders/UniformsLib.js | @@ -10,6 +10,7 @@ THREE.UniformsLib = {
"opacity": { type: "f", value: 1.0 },
"map": { type: "t", value: null },
+ "mapEncoding" : { type: "i", value: THREE.sRGBEncoding },
"offsetRepeat": { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) },
"specularMap": { type: "t", value: null }, | true |
Other | mrdoob | three.js | 15e08c1327f439b397c4f074da3f17ff10e13568.json | add support for Texture.encoding to Material.map | src/textures/Texture.js | @@ -36,7 +36,7 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, f
this.premultiplyAlpha = false;
this.flipY = true;
this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
- this.encoding = THREE.LinearEncoding; // Values !== THREE.LinearEncoding only supported on envMap and emissiveMap (as these maps regularly have unbounded intensity values, i.e. via an *.hdr or *.exr image.)
+ this.encoding = THREE.DefaultEncoding; // Values !== THREE.LinearEncoding only supported on map, envMap and emissiveMap (as these maps regularly have unbounded intensity values, i.e. via an *.hdr or *.exr image.)
this.version = 0;
this.onUpdate = null; | true |
Other | mrdoob | three.js | 6ccf94aa390b2a30f31e2c38b8d816ad766f1659.json | add taa to example files listing. | examples/files.js | @@ -181,6 +181,7 @@ var files = {
"webgl_postprocessing_nodes",
"webgl_postprocessing_smaa",
"webgl_postprocessing_ssao",
+ "webgl_postprocessing_taa",
"webgl_raycast_texture",
"webgl_read_float_buffer",
"webgl_rtt", | false |
Other | mrdoob | three.js | a66afc819c5e12747d136496ee5f68a54ebf4ff1.json | remove subdivisions of box. | examples/webgl_postprocessing_taa.html | @@ -122,7 +122,7 @@
scene = new THREE.Scene();
- var geometry = new THREE.BoxGeometry( 120, 120, 120, 20, 5, 3 );
+ var geometry = new THREE.BoxGeometry( 120, 120, 120 );
var material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
var mesh = new THREE.Mesh( geometry, material ); | false |
Other | mrdoob | three.js | b4ea42b634bff4578913eae75968564eaa49a210.json | Return geometry after calling applyMatrix()
Return geometry (`this`) after calling `applyMatrix()` also in `THREE.BufferGeometry` | src/core/BufferGeometry.js | @@ -142,6 +142,8 @@ THREE.BufferGeometry.prototype = {
}
+ return this;
+
},
rotateX: function () { | false |
Other | mrdoob | three.js | a266e460f4184a173df677aa3b80dfc98c530d10.json | Return geometry after calling applyMatrix()
Return geometry (`this`) after calling `applyMatrix():` | src/core/Geometry.js | @@ -87,6 +87,8 @@ THREE.Geometry.prototype = {
this.verticesNeedUpdate = true;
this.normalsNeedUpdate = true;
+ return this;
+
},
rotateX: function () { | false |
Other | mrdoob | three.js | 91f913dc4e1dd7d7998d1ad9e3e2796c0678e8df.json | Fix VREffect handling of full screen state (#8788)
- Use unprefixed Fullscreen API in `VREffect` if available #8568
- Prevent over-writing of backup value for pixel ratio #8776 | examples/js/effects/VREffect.js | @@ -98,11 +98,19 @@ THREE.VREffect = function ( renderer, onError ) {
// fullscreen
var canvas = renderer.domElement;
- var fullscreenchange = canvas.mozRequestFullScreen ? 'mozfullscreenchange' : 'webkitfullscreenchange';
+ var requestFullscreen;
+ var fullscreenElement;
- document.addEventListener( fullscreenchange, function () {
+ function onFullscreenChange() {
- isPresenting = vrHMD !== undefined && ( vrHMD.isPresenting || ( isDeprecatedAPI && ( document.mozFullScreenElement || document.webkitFullscreenElement ) !== undefined ) );
+ var wasPresenting = isPresenting;
+ isPresenting = vrHMD !== undefined && ( vrHMD.isPresenting || ( isDeprecatedAPI && document[fullscreenElement] instanceof window.HTMLElement ) );
+
+ if ( wasPresenting === isPresenting ) {
+
+ return;
+
+ }
if ( isPresenting ) {
@@ -134,29 +142,29 @@ THREE.VREffect = function ( renderer, onError ) {
}
- }, false );
-
- window.addEventListener( 'vrdisplaypresentchange', function () {
+ }
- isPresenting = vrHMD && vrHMD.isPresenting;
+ if ( canvas.requestFullscreen ) {
- if ( isPresenting ) {
+ requestFullscreen = 'requestFullscreen';
+ fullscreenElement = 'fullscreenElement';
- rendererPixelRatio = renderer.getPixelRatio();
- rendererSize = renderer.getSize();
+ } else if ( canvas.mozRequestFullScreen ) {
- var eyeParamsL = vrHMD.getEyeParameters( 'left' );
- renderer.setPixelRatio( 1 );
- renderer.setSize( eyeParamsL.renderWidth * 2, eyeParamsL.renderHeight, false );
+ requestFullscreen = 'mozRequestFullScreen';
+ fullscreenElement = 'mozFullScreenElement'
+ document.addEventListener( 'mozfullscreenchange', onFullscreenChange, false );
- } else {
+ } else {
- renderer.setPixelRatio( rendererPixelRatio );
- renderer.setSize( rendererSize.width, rendererSize.height );
+ requestFullscreen = 'webkitRequestFullscreen';
+ fullscreenElement = 'webkitFullscreenElement';
+ document.addEventListener( 'webkitfullscreenchange', onFullscreenChange, false );
- }
+ }
- }, false );
+ document.addEventListener( 'fullscreenchange', onFullscreenChange, false );
+ window.addEventListener( 'vrdisplaypresentchange', onFullscreenChange, false );
this.setFullScreen = function ( boolean ) {
@@ -189,14 +197,9 @@ THREE.VREffect = function ( renderer, onError ) {
} else {
- if ( canvas.mozRequestFullScreen ) {
-
- canvas.mozRequestFullScreen( { vrDisplay: vrHMD } );
- resolve();
-
- } else if ( canvas.webkitRequestFullscreen ) {
+ if ( canvas[requestFullscreen] ) {
- canvas.webkitRequestFullscreen( { vrDisplay: vrHMD } );
+ canvas[requestFullscreen]( { vrDisplay: vrHMD } );
resolve();
} else { | false |
Other | mrdoob | three.js | 421f52b4b8736a08d4f055d74ff15566c0ae7a08.json | Fix docs for Object3D.traverseAncestors | docs/api/core/Object3D.html | @@ -230,7 +230,7 @@ <h3>[method:null traverse]( [page:Function callback] )</h3>
<div>
Executes the callback on this object and all descendants.
</div>
-
+
<h3>[method:null traverseVisible]( [page:Function callback] )</h3>
<div>
callback - A function with as first argument an object3D object.<br />
@@ -239,13 +239,13 @@ <h3>[method:null traverseVisible]( [page:Function callback] )</h3>
Like traverse, but the callback will only be executed for visible objects.
Descendants of invisible objects are not traversed.
</div>
-
+
<h3>[method:null traverseAncestors]( [page:Function callback] )</h3>
<div>
callback - A function with as first argument an object3D object.<br />
</div>
<div>
- Executes the callback on this object and all ancestors.
+ Executes the callback on all ancestors.
</div>
<h3>[method:null updateMatrix]()</h3> | false |
Other | mrdoob | three.js | 7ff4c74c81ac79cebfe506eee234d6bef14f6f7f.json | improve draggable cubes example
* no more limitation on dragging area
* drag cubes // to camera front/back planes | examples/webgl_interactive_draggablecubes.html | @@ -25,11 +25,12 @@
var container, stats;
var camera, controls, scene, renderer;
- var objects = [], plane;
-
+ var objects = [];
+ var plane = new THREE.Plane();
var raycaster = new THREE.Raycaster();
var mouse = new THREE.Vector2(),
offset = new THREE.Vector3(),
+ intersection = new THREE.Vector3(),
INTERSECTED, SELECTED;
init();
@@ -95,12 +96,6 @@
}
- plane = new THREE.Mesh(
- new THREE.PlaneBufferGeometry( 2000, 2000, 8, 8 ),
- new THREE.MeshBasicMaterial( { visible: false } )
- );
- scene.add( plane );
-
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setClearColor( 0xf0f0f0 );
renderer.setPixelRatio( window.devicePixelRatio );
@@ -149,17 +144,13 @@
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
- //
-
raycaster.setFromCamera( mouse, camera );
if ( SELECTED ) {
- var intersects = raycaster.intersectObject( plane );
+ if ( raycaster.ray.intersectPlane( plane, intersection ) ) {
- if ( intersects.length > 0 ) {
-
- SELECTED.position.copy( intersects[ 0 ].point.sub( offset ) );
+ SELECTED.position.copy( intersection.sub( offset ) );
}
@@ -178,8 +169,9 @@
INTERSECTED = intersects[ 0 ].object;
INTERSECTED.currentHex = INTERSECTED.material.color.getHex();
- plane.position.copy( INTERSECTED.position );
- plane.lookAt( camera.position );
+ plane.setFromNormalAndCoplanarPoint(
+ camera.getWorldDirection( plane.normal ),
+ INTERSECTED.position );
}
@@ -211,11 +203,9 @@
SELECTED = intersects[ 0 ].object;
- var intersects = raycaster.intersectObject( plane );
-
- if ( intersects.length > 0 ) {
+ if ( raycaster.ray.intersectPlane( plane, intersection ) ) {
- offset.copy( intersects[ 0 ].point ).sub( plane.position );
+ offset.copy( intersection ).sub( SELECTED.position );
}
@@ -233,8 +223,6 @@
if ( INTERSECTED ) {
- plane.position.copy( INTERSECTED.position );
-
SELECTED = null;
} | false |
Other | mrdoob | three.js | bc6bc544491269bb0d864954d2d01e4dd45e850c.json | Remove arguments to allow optimalisations
* Remove arguments to allow optimalisations
* Change constructor based on @mrdoob's argument
* Fix issue with renaming of argument
* convert space to tabs
* cleanup docs
* don't forget the linefeed in docs
* docs cleanup
* Update Color.html | docs/api/math/Color.html | @@ -27,9 +27,31 @@ <h2>Example</h2>
<h2>Constructor</h2>
- <h3>[name]( value )</h3>
- <div>
- value — optional argument that sets initial color. Can be a hexadecimal or a CSS-style string, for example, "rgb(250, 0,0)", "rgb(100%,0%,0%)", "hsl(0, 100%, 50%)", "#ff0000", "#f00", or "red", or three arguments that represent color channels.
+ <h3>[name]( r, g, b )</h3>
+ <div>
+ r - the red component of the color if arguments g and b are defined. If they are not defined, it can be a hexadecimal or a CSS-style string or a Color instance.<br />
+ g - The green component of the color if it is defined.<br />
+ b - The blue component of the color if it is defined.
+ </div>
+ <div>
+ All arguments are optional. The default color is White.<br />
+ When all arguments are defined then r is the red component, g is the green component and b is the blue component of the color.<br />
+ When only r is defined:<br />
+ <ul>
+ <li>It can be a hexadecimal of the color.</li>
+ <li>It can be an another color instance.</li>
+ <li>It can be a CSS style. For Instance:
+ <ul>
+ <li>rgb(250, 0,0)</li>
+ <li>rgb(100%,0%,0%)</li>
+ <li>hsl(0, 100%, 50%)</li>
+ <li>#ff0000</li>
+ <li>#f00</li>
+ <li>red</li>
+ </ul>
+
+ </li>
+ </ul>
</div>
<h2>Properties</h2> | true |
Other | mrdoob | three.js | bc6bc544491269bb0d864954d2d01e4dd45e850c.json | Remove arguments to allow optimalisations
* Remove arguments to allow optimalisations
* Change constructor based on @mrdoob's argument
* Fix issue with renaming of argument
* convert space to tabs
* cleanup docs
* don't forget the linefeed in docs
* docs cleanup
* Update Color.html | src/math/Color.js | @@ -2,15 +2,16 @@
* @author mrdoob / http://mrdoob.com/
*/
-THREE.Color = function ( color ) {
+THREE.Color = function ( r, g, b ) {
- if ( arguments.length === 3 ) {
+ if ( g === undefined && b === undefined ) {
- return this.fromArray( arguments );
+ // r is THREE.Color, hex or string
+ return this.set( r );
}
- return this.set( color );
+ return this.setRGB( r, g, b );
};
| true |
Other | mrdoob | three.js | c184493e3cf4fb22f50ed330a6456fd705052def.json | Remove legacy warning in KeyFrameTrack
It became unnessecary. | src/animation/KeyframeTrack.js | @@ -386,8 +386,6 @@ Object.assign( THREE.KeyframeTrack, {
if ( json.times === undefined ) {
- console.warn( "legacy JSON format detected, converting" );
-
var times = [], values = [];
THREE.AnimationUtils.flattenJSON( json.keys, times, values, 'value' ); | false |
Other | mrdoob | three.js | 65a16691beded6282cdaee55d94584c8d86bf872.json | Fix VREffect support for webvr-polyfill
* Fix VREffect support for webvr-polyfill (#8712)
- correctly set `isPresenting` in full screen mode
- webvr-polyfill fires fullscreenchange in VR mode
- fix needed for setting main window to full screen while presenting
* Code clean-up (#8748, #8712)
- Added parentheses to clarify per @mrdoob
- More spaces
- cast `isPresenting` to boolean
* Check if vrHMD is undefined (#8748, #8712) | examples/js/effects/VREffect.js | @@ -102,16 +102,30 @@ THREE.VREffect = function ( renderer, onError ) {
document.addEventListener( fullscreenchange, function () {
- isPresenting = isDeprecatedAPI && vrHMD && ( document.mozFullScreenElement || document.webkitFullscreenElement ) !== undefined;
+ isPresenting = vrHMD !== undefined && ( vrHMD.isPresenting || ( isDeprecatedAPI && ( document.mozFullScreenElement || document.webkitFullscreenElement ) !== undefined ) );
if ( isPresenting ) {
rendererPixelRatio = renderer.getPixelRatio();
rendererSize = renderer.getSize();
var eyeParamsL = vrHMD.getEyeParameters( 'left' );
+ var eyeWidth, eyeHeight;
+
+ if ( isDeprecatedAPI ) {
+
+ eyeWidth = eyeParamsL.renderRect.width;
+ eyeHeight = eyeParamsL.renderRect.height;
+
+ } else {
+
+ eyeWidth = eyeParamsL.renderWidth;
+ eyeHeight = eyeParamsL.renderHeight;
+
+ }
+
renderer.setPixelRatio( 1 );
- renderer.setSize( eyeParamsL.renderRect.width * 2, eyeParamsL.renderRect.height, false );
+ renderer.setSize( eyeWidth * 2, eyeHeight, false );
} else {
| false |
Other | mrdoob | three.js | a9c64beaf3b745de8cb4f3bb961b95e6e4cabb25.json | Fix variable typo. (I think.) (#8706) | examples/js/effects/VREffect.js | @@ -68,7 +68,7 @@ THREE.VREffect = function ( renderer, onError ) {
this.setSize = function ( width, height ) {
- renderSize = { width: width, height: height };
+ rendererSize = { width: width, height: height };
if ( isPresenting ) {
| false |
Other | mrdoob | three.js | d75cd5f3d273cc9beca0130d9d394f3f49d2f80c.json | Update MMDMaterial Shader | examples/js/loaders/MMDLoader.js | @@ -3636,6 +3636,7 @@ THREE.ShaderLib[ 'mmd' ] = {
THREE.UniformsLib[ "fog" ],
THREE.UniformsLib[ "ambient" ],
THREE.UniformsLib[ "lights" ],
+ THREE.UniformsLib[ "shadowmap" ],
{
"emissive" : { type: "c", value: new THREE.Color( 0x000000 ) },
@@ -3824,7 +3825,6 @@ THREE.ShaderLib[ 'mmd' ] = {
// accumulation
THREE.ShaderChunk[ "lights_phong_fragment" ],
THREE.ShaderChunk[ "lights_template" ],
- THREE.ShaderChunk[ "lightmap_fragment" ],
// modulation
THREE.ShaderChunk[ "aomap_fragment" ], | false |
Other | mrdoob | three.js | 77a3f6dc13de12fea9f31eaba7452b0e655dc593.json | Add more samples for software sandbox. | examples/software_sandbox.html | @@ -16,21 +16,18 @@
<body>
<script src="../build/three.min.js"></script>
-
+ <script src="js/geometries/hilbert3D.js"></script>
<script src="js/controls/TrackballControls.js"></script>
-
<script src="js/renderers/Projector.js"></script>
<script src="js/renderers/SoftwareRenderer.js"></script>
-
<script src="js/libs/stats.min.js"></script>
-
<script>
var container, stats;
var camera, controls, scene, renderer;
- var torus, cube;
+ var torus, cube, texCube;
var start = Date.now();
@@ -50,13 +47,14 @@
info.innerHTML = '<a href="http://threejs.org" target="_blank">three.js<a/> - software renderer<br/>drag to change the point of view';
container.appendChild( info );
- camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
+ camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.z = 600;
controls = new THREE.TrackballControls( camera );
scene = new THREE.Scene();
+ // Torus
var geometry = new THREE.TorusKnotGeometry( 150 );
for ( var i = 0, j = geometry.faces.length; i < j; i ++ ) {
@@ -68,8 +66,7 @@
torus = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x0000ff, vertexColors: THREE.FaceColors } ) );
scene.add( torus );
- // Plane
-
+ // Cube
var geometry = new THREE.BoxGeometry( 200, 200, 200 );
for ( var i = 0, j = geometry.faces.length; i < j; i ++ ) {
@@ -79,8 +76,55 @@
}
cube = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x00ff00, vertexColors: THREE.FaceColors } ) );
+ scene.position.set( 100, 0, 0 );
scene.add( cube );
+ // Cube with texture
+ var loader = new THREE.TextureLoader();
+ var map = loader.load( 'textures/brick_diffuse.jpg' );
+ texCube = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { map: map, overdraw: 0.5 } ) );
+ texCube.position.set( -300, 0, 0 );
+ scene.add( texCube );
+
+ // Sprite
+ var sprite = new THREE.Sprite( new THREE.SpriteMaterial( { color: 0xff0040 } ) );
+ sprite.scale.set( 100, 100, 1 );
+ sprite.position.set( -100, 200, 0 );
+ scene.add( sprite );
+
+ // Sprite with texture
+ var texLoader = new THREE.TextureLoader();
+ map = texLoader.load( 'textures/sprite1.png' );
+ var texSprite = new THREE.Sprite( new THREE.SpriteMaterial( { map: map,transparent: true } ) );
+ texSprite.scale.set( 100, 100, 1 );
+ texSprite.position.set( 100, 200, 0 );
+ scene.add( texSprite );
+
+ // Line
+ var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 200.0, 1, 0, 1, 2, 3, 4, 5, 6, 7 );
+ var spline = new THREE.Spline( points );
+ var n_sub = 6, colors = [], line;
+ var lineGeometry = new THREE.Geometry()
+
+ for ( i = 0; i < points.length * n_sub; i ++ ) {
+
+ index = i / ( points.length * n_sub );
+ position = spline.getPoint( index );
+
+ lineGeometry.vertices[ i ] = new THREE.Vector3( position.x, position.y, position.z );
+
+ colors[ i ] = new THREE.Color( 0x88aaff );
+
+ }
+
+ lineGeometry.colors = colors;
+
+ material = new THREE.LineBasicMaterial( { opacity: 1, linewidth: 3, vertexColors: THREE.VertexColors } );
+ line = new THREE.Line( lineGeometry, material );
+ line.scale.set( 0.5, 0.5, 0.5 );
+ line.position.set( 0, -200, 0);
+ scene.add( line );
+
renderer = new THREE.SoftwareRenderer();
renderer.setClearColor( 0xf0f0f0 );
renderer.setSize( window.innerWidth, window.innerHeight );
@@ -129,6 +173,8 @@
cube.rotation.x = timer * 0.0002;
cube.rotation.z = timer * 0.0003;
+ texCube.rotation.x = timer * 0.0002;
+ texCube.rotation.z = timer * 0.0003;
controls.update();
| false |
Other | mrdoob | three.js | 8cd22a6a79bcf668d2b5c40e92f1613afce0b2dc.json | fix the MMDMaterial shader | examples/js/loaders/MMDLoader.js | @@ -3422,6 +3422,7 @@ THREE.ShaderLib[ 'mmd' ] = {
THREE.UniformsLib[ "normalmap" ],
THREE.UniformsLib[ "displacementmap" ],
THREE.UniformsLib[ "fog" ],
+ THREE.UniformsLib[ "ambient" ],
THREE.UniformsLib[ "lights" ],
THREE.UniformsLib[ "shadowmap" ],
@@ -3542,6 +3543,7 @@ THREE.ShaderLib[ 'mmd' ] = {
THREE.ShaderChunk[ "envmap_pars_fragment" ],
THREE.ShaderChunk[ "fog_pars_fragment" ],
THREE.ShaderChunk[ "bsdfs" ],
+ THREE.ShaderChunk[ "ambient_pars" ],
THREE.ShaderChunk[ "lights_pars" ],
THREE.ShaderChunk[ "lights_phong_pars_fragment" ],
THREE.ShaderChunk[ "shadowmap_pars_fragment" ], | false |
Other | mrdoob | three.js | 086eab8ccd0b0d178a3d0817d92132fe1c4dfd64.json | enable MMDLoader to support more various models | examples/js/loaders/MMDLoader.js | @@ -1998,21 +1998,28 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
}
- var isSphericalReflectionMapping = params.sphericalReflectionMapping;
var texture = loader.load( fullPath, function ( t ) {
t.flipY = false;
t.wrapS = THREE.RepeatWrapping;
t.wrapT = THREE.RepeatWrapping;
- if ( isSphericalReflectionMapping === true ) {
+ if ( params.sphericalReflectionMapping === true ) {
t.mapping = THREE.SphericalReflectionMapping;
}
+ for ( var i = 0; i < texture.readyCallbacks.length; i++ ) {
+
+ texture.readyCallbacks[ i ]( texture );
+
+ }
+
} );
+ texture.readyCallbacks = [];
+
var uuid = THREE.Math.generateUUID();
textures[ uuid ] = texture;
@@ -2037,6 +2044,9 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
};
+ params.faceOffset = offset;
+ params.faceNum = m.faceCount;
+
for ( var j = 0; j < m.faceCount; j++ ) {
geometry.faces[ offset ].materialIndex = i;
@@ -2062,12 +2072,17 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
params.specular = color.fromArray( [ m.specular[ 0 ], m.specular[ 1 ], m.specular[ 2 ] ] ).getHex();
params.shininess = m.shininess;
- // Note: always transparent so far.
- //if ( params.opacity < 1 ) {
+ if ( params.opacity === 1.0 ) {
+
+ params.side = THREE.FrontSide;
+ params.transparent = false;
+ } else {
+
+ params.side = THREE.DoubleSide;
params.transparent = true;
- //}
+ }
if ( model.metadata.format === 'pmd' ) {
@@ -2146,7 +2161,8 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
}
- if ( params.map === undefined ) {
+ // TODO: check if this logic is right
+ if ( params.map === undefined /* && params.envMap === undefined */ ) {
params.emissive = color.fromArray( [ m.emissive[ 0 ], m.emissive[ 1 ], m.emissive[ 2 ] ] ).getHex();
@@ -2169,8 +2185,11 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
var p2 = model.materials[ i ];
var m = materialLoader.parse( p );
- m.skinning = true;
- m.morphTargets = true;
+ m.faceOffset = p.faceOffset;
+ m.faceNum = p.faceNum;
+
+ m.skinning = geometry.bones.length > 0 ? true : false;
+ m.morphTargets = geometry.morphTargets.length > 0 ? true : false;
m.lights = true;
m.blending = THREE.CustomBlending;
@@ -2179,9 +2198,135 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
m.blendSrcAlpha = THREE.SrcAlphaFactor;
m.blendDstAlpha = THREE.DstAlphaFactor;
- if ( p.envMap !== undefined ) {
+ if ( m.map !== null ) {
+
+ function checkTextureTransparency ( m ) {
+
+ m.map.readyCallbacks.push( function ( t ) {
+
+ // Is there any efficient ways?
+ function createImageData ( image ) {
+
+ var c = document.createElement( 'canvas' );
+ c.width = image.width;
+ c.height = image.height;
+
+ var ctx = c.getContext( '2d' );
+ ctx.drawImage( image, 0, 0 );
+
+ return ctx.getImageData( 0, 0, c.width, c.height );
+
+ };
+
+ function detectTextureTransparency ( image, uvs ) {
+
+ var width = image.width;
+ var height = image.height;
+ var data = image.data;
+ var threshold = 253;
+
+ if ( data.length / ( width * height ) !== 4 ) {
+
+ return false;
+
+ }
+
+ for ( var i = 0; i < uvs.length; i++ ) {
+
+ var centerUV = { x: 0.0, y: 0.0 };
+
+ for ( var j = 0; j < 3; j++ ) {
+
+ var uv = uvs[ i ][ j ];
+
+ if ( getAlphaByUv( image, uv ) < threshold ) {
+
+ return true;
+
+ }
+
+ centerUV.x += uv.x;
+ centerUV.y += uv.y;
+
+ }
+
+ centerUV.x /= 3;
+ centerUV.y /= 3;
+
+
+ if ( getAlphaByUv( image, centerUV ) < threshold ) {
+
+ return true;
+
+ }
+
+ }
+
+ return false;
+
+ };
+
+ /*
+ * This method expects
+ * t.flipY = false
+ * t.wrapS = THREE.RepeatWrapping
+ * t.wrapT = THREE.RepeatWrapping
+ * TODO: more precise
+ */
+ function getAlphaByUv ( image, uv ) {
+
+ var width = image.width;
+ var height = image.height;
+
+ var x = Math.round( uv.x * width ) % width;
+ var y = Math.round( uv.y * height ) % height;
+
+ if ( x < 0 ) {
+
+ x += width;
+
+ }
+
+ if ( y < 0 ) {
+
+ y += height;
+
+ }
+
+ var index = y * width + x;
+
+ return image.data[ index * 4 + 3 ];
+
+ };
+
+ var imageData = t.image.data !== undefined ? t.image : createImageData( t.image );
+ var uvs = geometry.faceVertexUvs[ 0 ].slice( m.faceOffset, m.faceOffset + m.faceNum );
+
+ m.textureTransparency = detectTextureTransparency( imageData, uvs );
+
+ } );
+
+ }
+
+ checkTextureTransparency( m );
+
+ }
+
+ if ( m.envMap !== null ) {
+
+ // TODO: WebGLRenderer should automatically update?
+ function updateMaterialWhenTextureIsReady ( m ) {
+
+ m.envMap.readyCallbacks.push( function ( t ) {
+
+ m.needsUpdate = true;
+
+ } );
+
+ }
m.combine = p.envMapType;
+ updateMaterialWhenTextureIsReady( m );
}
@@ -2219,11 +2364,17 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
m.uniforms.toonMap.value = textures[ p2.toonIndex ];
m.uniforms.celShading.value = 1;
- // temporal workaround
- // TODO: handle correctly
- var n = model.toonTextures[ p2.toonIndex === -1 ? 0 : p2.toonIndex ].fileName;
- var uuid = loadTexture( n, { defaultTexturePath: isDefaultToonTexture( n ) } );
- m.uniforms.toonMap.value = textures[ uuid ];
+ if ( p2.toonIndex === -1 ) {
+
+ m.uniforms.hasToonTexture.value = 0;
+
+ } else {
+
+ var n = model.toonTextures[ p2.toonIndex ].fileName;
+ var uuid = loadTexture( n, { defaultTexturePath: isDefaultToonTexture( n ) } );
+ m.uniforms.toonMap.value = textures[ uuid ];
+ m.uniforms.hasToonTexture.value = 1;
+ }
} else {
@@ -2232,23 +2383,28 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
m.uniforms.outlineAlpha.value = p2.edgeColor[ 3 ];
m.uniforms.celShading.value = 1;
- // temporal workaround
- // TODO: handle correctly
- var index = p2.toonIndex === -1 ? -1 : p2.toonIndex;
- var flag = p2.toonIndex === -1 ? 1 : p2.toonFlag;
+ if ( p2.toonIndex === -1 ) {
- if ( flag === 0 ) {
-
- var n = model.textures[ index ];
- var uuid = loadTexture( n );
- m.uniforms.toonMap.value = textures[ uuid ];
+ m.uniforms.hasToonTexture.value = 0;
} else {
- var num = index + 1;
- var fileName = 'toon' + ( num < 10 ? '0' + num : num ) + '.bmp';
- var uuid = loadTexture( fileName, { defaultTexturePath: true } );
- m.uniforms.toonMap.value = textures[ uuid ];
+ if ( p2.toonFlag === 0 ) {
+
+ var n = model.textures[ p2.toonIndex ];
+ var uuid = loadTexture( n );
+ m.uniforms.toonMap.value = textures[ uuid ];
+
+ } else {
+
+ var num = p2.toonIndex + 1;
+ var fileName = 'toon' + ( num < 10 ? '0' + num : num ) + '.bmp';
+ var uuid = loadTexture( fileName, { defaultTexturePath: true } );
+ m.uniforms.toonMap.value = textures[ uuid ];
+
+ }
+
+ m.uniforms.hasToonTexture.value = 1;
}
@@ -2258,6 +2414,64 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
}
+ if ( model.metadata.format === 'pmx' ) {
+
+ function checkAlphaMorph ( morph, elements ) {
+
+ if ( morph.type !== 8 ) {
+
+ return;
+
+ }
+
+ for ( var i = 0; i < elements.length; i++ ) {
+
+ var e = elements[ i ];
+
+ if ( e.index === -1 ) {
+
+ continue;
+
+ }
+
+ var m = material.materials[ e.index ];
+
+ if ( m.opacity !== e.diffuse[ 3 ] ) {
+
+ m.morphTransparency = true;
+
+ }
+
+ }
+
+ }
+
+ for ( var i = 0; i < model.morphs.length; i++ ) {
+
+ var morph = model.morphs[ i ];
+ var elements = morph.elements;
+
+ if ( morph.type === 0 ) {
+
+ for ( var j = 0; j < elements.length; j++ ) {
+
+ var morph2 = model.morphs[ elements[ j ].index ];
+ var elements2 = morph2.elements;
+
+ checkAlphaMorph( morph2, elements2 );
+
+ }
+
+ } else {
+
+ checkAlphaMorph( morph, elements );
+
+ }
+
+ }
+
+ }
+
};
var initPhysics = function () {
@@ -3349,6 +3563,11 @@ THREE.MMDMaterial = function ( parameters ) {
// this.type = 'MMDMaterial';
+ this.faceOffset = null;
+ this.faceNum = null;
+ this.textureTransparency = false;
+ this.morphTransparency = false;
+
// the followings are copied from MeshPhongMaterial
this.color = new THREE.Color( 0xffffff ); // diffuse
this.emissive = new THREE.Color( 0x000000 );
@@ -3438,7 +3657,8 @@ THREE.ShaderLib[ 'mmd' ] = {
"outlineColor" : { type: "c", value: new THREE.Color( 0x000000 ) },
"outlineAlpha" : { type: "f", value: 1.0 },
"celShading" : { type: "i", value: 0 },
- "toonMap" : { type: "t", value: null }
+ "toonMap" : { type: "t", value: null },
+ "hasToonTexture" : { type: "i", value: 0 }
}
// ---- MMD specific for cel shading(outline drawing and toon mapping)
@@ -3556,8 +3776,12 @@ THREE.ShaderLib[ 'mmd' ] = {
" uniform float outlineAlpha;",
" uniform bool celShading;",
" uniform sampler2D toonMap;",
+ " uniform bool hasToonTexture;",
" vec3 toon ( vec3 lightDirection, vec3 norm ) {",
+ " if ( ! hasToonTexture ) {",
+ " return vec3( 1.0 );",
+ " }",
" vec2 coord = vec2( 0.0, 0.5 * ( 1.0 - dot( lightDirection, norm ) ) );",
" return texture2D( toonMap, coord ).rgb;",
" }",
@@ -4067,7 +4291,25 @@ THREE.MMDHelper.prototype = {
var m = mesh.material.materials[ i ];
m.uniforms.outlineDrawing.value = 0;
- m.side = THREE.DoubleSide;
+ m.visible = true;
+
+ if ( m.opacity === 1.0 ) {
+
+ m.side = THREE.FrontSide;
+ m.transparent = false;
+
+ } else {
+
+ m.side = THREE.DoubleSide;
+ m.transparent = true;
+
+ }
+
+ if ( m.textureTransparency === true || m.morphTransparency === true ) {
+
+ m.transparent = true;
+
+ }
}
@@ -4081,8 +4323,6 @@ THREE.MMDHelper.prototype = {
}
- this.renderer.state.setBlending( THREE.NoBlending );
-
},
setupOutlineRenderingOneMesh: function ( mesh ) {
@@ -4093,6 +4333,18 @@ THREE.MMDHelper.prototype = {
m.uniforms.outlineDrawing.value = 1;
m.side = THREE.BackSide;
+ if ( m.uniforms.outlineAlpha.value < 1.0 ) {
+
+ m.transparent = true;
+
+ }
+
+ if ( m.uniforms.outlineThickness.value === 0.0 ) {
+
+ m.visible = false;
+
+ }
+
}
}, | false |
Other | mrdoob | three.js | 48123a33b10f51729cdd86ac63605409e09e2811.json | Fix vertex shader bug. | src/renderers/shaders/ShaderLib.js | @@ -598,17 +598,15 @@ THREE.ShaderLib = {
"void main() {",
THREE.ShaderChunk[ "color_vertex" ],
-
- " vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+ THREE.ShaderChunk[ "begin_vertex" ],
+ THREE.ShaderChunk[ "project_vertex" ],
" #ifdef USE_SIZEATTENUATION",
- " gl_PointSize = size * ( scale / -mvPosition.z );",
+ " gl_PointSize = size * ( scale / - mvPosition.z );",
" #else",
" gl_PointSize = size;",
" #endif",
- " gl_Position = projectionMatrix * mvPosition;",
-
THREE.ShaderChunk[ "logdepthbuf_vertex" ],
THREE.ShaderChunk[ "worldpos_vertex" ],
THREE.ShaderChunk[ "shadowmap_vertex" ], | false |
Other | mrdoob | three.js | 9c872b1cab3daed5cb6c564fbe5af836ec22feea.json | Fix THREE.SkinnedMesh.clone() bug (#9082) | src/objects/SkinnedMesh.js | @@ -172,7 +172,7 @@ THREE.SkinnedMesh.prototype = Object.assign( Object.create( THREE.Mesh.prototype
clone: function() {
- return new this.constructor( this.geometry, this.material, this.useVertexTexture ).copy( this );
+ return new this.constructor( this.geometry, this.material, this.skeleton.useVertexTexture ).copy( this );
}
| false |
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/index.html | @@ -285,9 +285,10 @@
switch ( event.keyCode ) {
case 8: // backspace
+
event.preventDefault(); // prevent browser back
-
- case 46: // delete
+
+ case 46: // delete
var object = editor.selected;
@@ -313,16 +314,19 @@
break;
case 87: // Register W for translation transform mode
+
editor.signals.transformModeChanged.dispatch( 'translate' );
break;
case 69: // Register E for rotation transform mode
+
editor.signals.transformModeChanged.dispatch( 'rotate' );
break;
case 82: // Register R for scaling transform mode
+
editor.signals.transformModeChanged.dispatch( 'scale' );
break; | true |