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 | 8d0d3cfc4fad36071d624f5cabb2424f3c02a8c7.json | Ignore case on name match | src/extras/objects/MorphBlendMesh.js | @@ -62,7 +62,7 @@ THREE.MorphBlendMesh.prototype.createAnimation = function ( name, start, end, fp
THREE.MorphBlendMesh.prototype.autoCreateAnimations = function ( fps ) {
- var pattern = /([a-z]+)_?(\d+)/;
+ var pattern = /([a-z]+)_?(\d+)/i;
var firstAnimation, frameRanges = {};
| false |
Other | mrdoob | three.js | d443359764e0f5b4596756426613c1730f8e3c2c.json | remove unused code. | src/renderers/shaders/ShaderChunk/light_pars.glsl | @@ -1,111 +0,0 @@
-
-#if MAX_DIR_LIGHTS > 0
-
- //uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
- //uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
-
- struct DirectionalLight {
- vec3 color;
- vec3 direction;
- };
-
- uniform DirectionalLight directionalLights[ MAX_DIR_LIGHTS ];
-
- void getDirLight( const in DirectionalLight directionalLight, out vec3 lightDir, out vec3 lightColor ) {
-
- lightDir = directionalLight.direction;
- lightColor = directionalLight.color;
-
- }
-
-#endif
-
-#if MAX_HEMI_LIGHTS > 0
-
- //uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
- //uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
- //uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
-
- struct HemisphereLight {
- vec3 skyColor;
- vec3 groundColor;
- vec3 direction;
- };
-
- uniform HemisphereLight hemisphereLights[ MAX_HEMI_LIGHTS ];
-
-#endif
-
-#if MAX_POINT_LIGHTS > 0
-
- //uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
- //uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
- //uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
- //uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
-
- struct PointLight {
- vec3 color;
- vec3 position;
- float decay;
- float cutoffDistance;
- };
-
- uniform PointLight pointLights[ MAX_POINT_LIGHTS ];
-
- void getPointLight( const in pointLight, out vec3 lightDir, out vec3 lightColor ) {
-
- vec3 lightPosition = pointLight.position;
-
- vec3 lVector = lightPosition + vViewPosition.xyz;
- lightDir = normalize( lVector );
-
- lightColor = pointLight.color[ pointIndex ];
- lightColor *= calcLightAttenuation( length( lVector ), pointLight.cutoffDistance, pointLight.decay );
-
- }
-
-#endif
-
-#if MAX_SPOT_LIGHTS > 0
-
- //uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
- //uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
- //uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
- //uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
- //uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
- //uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
- //uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];
-
- struct SpotLight {
- vec3 color;
- vec3 position;
- vec3 direction;
- float angleCos;
- float exponent;
- float cutoffDistance;
- float decay;
- };
-
- uniform SpotLight spotLights[ MAX_SPOT_LIGHTS ];
-
- void getSpotLight( const in SpotLight spotLight, out vec3 lightDir, out vec3 lightColor ) {
-
- vec3 lightPosition = spotLight.position;
-
- vec3 lVector = lightPosition + vViewPosition.xyz;
- lightDir = normalize( lVector );
-
- float spotEffect = dot( spotLight.direction, lightDir );
- spotEffect = saturate( pow( saturate( spotEffect ), spotLight.exponent ) );
-
- lightColor = spotLight.color;
- lightColor *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) );
-
- }
-
-#endif
-
-
-
-
- | false |
Other | mrdoob | three.js | 223c383b1456bc49c1f422d397a5288d099c35cc.json | reduce the need for temporaries, cleanup code. | src/renderers/WebGLRenderer.js | @@ -2470,12 +2470,11 @@ THREE.WebGLRenderer = function ( parameters ) {
continue;
}
- _direction.setFromMatrixPosition( light.matrixWorld );
+ lightUniforms.direction.setFromMatrixPosition( light.matrixWorld );
_vector3.setFromMatrixPosition( light.target.matrixWorld );
- _direction.sub( _vector3 );
- _direction.transformDirection( viewMatrix );
+ lightUniforms.direction.sub( _vector3 );
+ lightUniforms.direction.transformDirection( viewMatrix );
- lightUniforms.position.copy( _direction );
lightUniforms.color.copy( color ).multiplyScalar( intensity );
lightUniforms.distance = distance;
@@ -2497,10 +2496,9 @@ THREE.WebGLRenderer = function ( parameters ) {
continue;
}
- _vector3.setFromMatrixPosition( light.matrixWorld );
- _vector3.applyMatrix4( viewMatrix );
+ lightUniforms.position.setFromMatrixPosition( light.matrixWorld );
+ lightUniforms.position.applyMatrix4( viewMatrix );
- lightUniforms.position.copy( _vector3 );
lightUniforms.color.copy( color ).multiplyScalar( intensity );
lightUniforms.distance = distance;
lightUniforms.decay = ( light.distance === 0 ) ? 0.0 : light.decay;
@@ -2525,18 +2523,17 @@ THREE.WebGLRenderer = function ( parameters ) {
continue;
}
- _direction.setFromMatrixPosition( light.matrixWorld );
- _vector3.copy( _direction ).applyMatrix4( viewMatrix );
+ lightUniforms.position.setFromMatrixPosition( light.matrixWorld );
+ lightUniforms.position.applyMatrix4( viewMatrix );
- lightUniforms.position.copy( _vector3 );
lightUniforms.color.copy( color ).multiplyScalar( intensity );
lightUniforms.distance = distance;
+ lightUniforms.direction.setFromMatrixPosition( light.matrixWorld );
_vector3.setFromMatrixPosition( light.target.matrixWorld );
- _direction.sub( _vector3 );
- _direction.transformDirection( viewMatrix );
+ lightUniforms.direction.sub( _vector3 );
+ lightUniforms.direction.transformDirection( viewMatrix );
- lightUniforms.direction.copy( _direction);
lightUniforms.angleCos = Math.cos( light.angle );
lightUniforms.exponent = light.exponent;
lightUniforms.decay = ( light.distance === 0 ) ? 0.0 : light.decay;
@@ -2558,10 +2555,9 @@ THREE.WebGLRenderer = function ( parameters ) {
continue;
}
- _direction.setFromMatrixPosition( light.matrixWorld );
- _direction.transformDirection( viewMatrix );
+ lightUniforms.position.setFromMatrixPosition( light.matrixWorld );
+ lightUniforms.position.transformDirection( viewMatrix );
- lightUniforms.position.copy( _direction);
lightUniforms.skyColor.copy( light.color ).multiplyScalar( intensity );
lightUniforms.groundColor.copy( groundColor ).multiplyScalar( intensity );
| true |
Other | mrdoob | three.js | 223c383b1456bc49c1f422d397a5288d099c35cc.json | reduce the need for temporaries, cleanup code. | src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl | @@ -17,12 +17,9 @@ varying vec3 vViewPosition;
#if MAX_DIR_LIGHTS > 0
- //uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
- //uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
-
struct DirectionalLight {
- vec3 color;
vec3 direction;
+ vec3 color;
};
uniform DirectionalLight singleTestDirLight;
@@ -40,14 +37,10 @@ varying vec3 vViewPosition;
#if MAX_HEMI_LIGHTS > 0
- //uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
- //uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
- //uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
-
struct HemisphereLight {
+ vec3 direction;
vec3 skyColor;
vec3 groundColor;
- vec3 direction;
};
uniform HemisphereLight hemisphereLights[ MAX_HEMI_LIGHTS ];
@@ -56,19 +49,13 @@ varying vec3 vViewPosition;
#if MAX_POINT_LIGHTS > 0
- //uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
- //uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
- //uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
- //uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
-
struct PointLight {
- vec3 color;
vec3 position;
- float decay;
+ vec3 color;
float distance;
+ float decay;
};
-
uniform PointLight singleTestPointLight;
uniform PointLight pointLights[ MAX_POINT_LIGHTS ];
@@ -89,22 +76,14 @@ varying vec3 vViewPosition;
#if MAX_SPOT_LIGHTS > 0
- //uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
- //uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
- //uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
- //uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
- //uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
- //uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
- //uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];
-
struct SpotLight {
- vec3 color;
vec3 position;
vec3 direction;
- float angleCos;
- float exponent;
+ vec3 color;
float distance;
float decay;
+ float angleCos;
+ float exponent;
};
uniform SpotLight spotLights[ MAX_SPOT_LIGHTS ]; | true |
Other | mrdoob | three.js | 74d3aa3f12120c906d190e621cb1260e88932757.json | parse arrays of struct uniforms, code cleanup. | src/renderers/shaders/ShaderChunk/light_pars.glsl | @@ -26,13 +26,13 @@
//uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
//uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
- struct HemisphericLight {
+ struct HemisphereLight {
vec3 skyColor;
vec3 groundColor;
vec3 direction;
};
- uniform HemisphericLight hemisphericLights[ MAX_HEMI_LIGHTS ];
+ uniform HemisphereLight hemisphereLights[ MAX_HEMI_LIGHTS ];
#endif
| true |
Other | mrdoob | three.js | 74d3aa3f12120c906d190e621cb1260e88932757.json | parse arrays of struct uniforms, code cleanup. | src/renderers/shaders/ShaderChunk/lights_lambert_pars_vertex.glsl | @@ -1 +1,113 @@
uniform vec3 ambientLightColor;
+
+
+#if MAX_DIR_LIGHTS > 0
+
+ //uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
+ //uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
+
+ struct DirectionalLight {
+ vec3 color;
+ vec3 direction;
+ };
+
+ uniform DirectionalLight directionalLights[ MAX_DIR_LIGHTS ];
+
+ void getDirLight( const in DirectionalLight directionalLight, out vec3 lightDir, out vec3 lightColor ) {
+
+ lightDir = directionalLight.direction;
+ lightColor = directionalLight.color;
+
+ }
+
+#endif
+
+#if MAX_HEMI_LIGHTS > 0
+
+ //uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
+ //uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
+ //uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
+
+ struct HemisphereLight {
+ vec3 skyColor;
+ vec3 groundColor;
+ vec3 direction;
+ };
+
+ uniform HemisphereLight hemisphereLights[ MAX_HEMI_LIGHTS ];
+
+#endif
+
+#if MAX_POINT_LIGHTS > 0
+
+ //uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
+ //uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
+ //uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
+ //uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
+
+ struct PointLight {
+ vec3 color;
+ vec3 position;
+ float decay;
+ float distance;
+ };
+
+ uniform PointLight pointLights[ MAX_POINT_LIGHTS ];
+
+ void getPointLight( const in PointLight pointLight, out vec3 lightDir, out vec3 lightColor ) {
+
+ vec3 lightPosition = pointLight.position;
+
+ vec3 lVector = lightPosition + vViewPosition.xyz;
+ lightDir = normalize( lVector );
+
+ lightColor = pointLight.color;
+ lightColor *= calcLightAttenuation( length( lVector ), pointLight.distance, pointLight.decay );
+
+ }
+
+#endif
+
+#if MAX_SPOT_LIGHTS > 0
+
+ //uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
+ //uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
+ //uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
+ //uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
+ //uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
+ //uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
+ //uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];
+
+ struct SpotLight {
+ vec3 color;
+ vec3 position;
+ vec3 direction;
+ float angleCos;
+ float exponent;
+ float distance;
+ float decay;
+ };
+
+ uniform SpotLight spotLights[ MAX_SPOT_LIGHTS ];
+
+ void getSpotLight( const in SpotLight spotLight, out vec3 lightDir, out vec3 lightColor ) {
+
+ vec3 lightPosition = spotLight.position;
+
+ vec3 lVector = lightPosition + vViewPosition.xyz;
+ lightDir = normalize( lVector );
+
+ float spotEffect = dot( spotLight.direction, lightDir );
+ spotEffect = saturate( pow( saturate( spotEffect ), spotLight.exponent ) );
+
+ lightColor = spotLight.color;
+ lightColor *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) );
+
+ }
+
+#endif
+
+
+
+
+ | true |
Other | mrdoob | three.js | 74d3aa3f12120c906d190e621cb1260e88932757.json | parse arrays of struct uniforms, code cleanup. | src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl | @@ -2,7 +2,7 @@ vec3 viewDir = normalize( vViewPosition );
vec3 totalReflectedLight = vec3( 0.0 );
-var diffuse = diffuseColor.rgb;
+vec3 diffuse = diffuseColor.rgb;
#ifdef METAL
@@ -15,7 +15,7 @@ var diffuse = diffuseColor.rgb;
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
vec3 lightDir, lightIntensity;
- getSpotLight( i, lightDir, lightIntensity );
+ getPointLight( pointLights[i], lightDir, lightIntensity );
if( dot( lightIntensity, lightIntensity ) > 0.0 ) {
@@ -40,7 +40,7 @@ var diffuse = diffuseColor.rgb;
for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {
vec3 lightDir, lightIntensity;
- getSpotLight( i, lightDir, lightIntensity );
+ getSpotLight( spotLights[i], lightDir, lightIntensity );
if( dot( lightIntensity, lightIntensity ) > 0.0 ) {
@@ -65,7 +65,7 @@ var diffuse = diffuseColor.rgb;
for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
vec3 lightDir, lightIntensity;
- getDirLight( i, lightDir, lightIntensity );
+ getDirLight( directionalLights[i], lightDir, lightIntensity );
if( dot( lightIntensity, lightIntensity ) > 0.0 ) {
| true |
Other | mrdoob | three.js | 74d3aa3f12120c906d190e621cb1260e88932757.json | parse arrays of struct uniforms, code cleanup. | src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl | @@ -13,3 +13,115 @@ varying vec3 vViewPosition;
varying vec3 vNormal;
#endif
+
+
+#if MAX_DIR_LIGHTS > 0
+
+ //uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
+ //uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
+
+ struct DirectionalLight {
+ vec3 color;
+ vec3 direction;
+ };
+
+ uniform DirectionalLight directionalLights[ MAX_DIR_LIGHTS ];
+
+ void getDirLight( const in DirectionalLight directionalLight, out vec3 lightDir, out vec3 lightColor ) {
+
+ lightDir = directionalLight.direction;
+ lightColor = directionalLight.color;
+
+ }
+
+#endif
+
+#if MAX_HEMI_LIGHTS > 0
+
+ //uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
+ //uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
+ //uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
+
+ struct HemisphereLight {
+ vec3 skyColor;
+ vec3 groundColor;
+ vec3 direction;
+ };
+
+ uniform HemisphereLight hemisphereLights[ MAX_HEMI_LIGHTS ];
+
+#endif
+
+#if MAX_POINT_LIGHTS > 0
+
+ //uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
+ //uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
+ //uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
+ //uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
+
+ struct PointLight {
+ vec3 color;
+ vec3 position;
+ float decay;
+ float distance;
+ };
+
+ uniform PointLight pointLights[ MAX_POINT_LIGHTS ];
+
+ void getPointLight( const in PointLight pointLight, out vec3 lightDir, out vec3 lightColor ) {
+
+ vec3 lightPosition = pointLight.position;
+
+ vec3 lVector = lightPosition + vViewPosition.xyz;
+ lightDir = normalize( lVector );
+
+ lightColor = pointLight.color;
+ lightColor *= calcLightAttenuation( length( lVector ), pointLight.distance, pointLight.decay );
+
+ }
+
+#endif
+
+#if MAX_SPOT_LIGHTS > 0
+
+ //uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
+ //uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
+ //uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
+ //uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
+ //uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
+ //uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
+ //uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];
+
+ struct SpotLight {
+ vec3 color;
+ vec3 position;
+ vec3 direction;
+ float angleCos;
+ float exponent;
+ float distance;
+ float decay;
+ };
+
+ uniform SpotLight spotLights[ MAX_SPOT_LIGHTS ];
+
+ void getSpotLight( const in SpotLight spotLight, out vec3 lightDir, out vec3 lightColor ) {
+
+ vec3 lightPosition = spotLight.position;
+
+ vec3 lVector = lightPosition + vViewPosition.xyz;
+ lightDir = normalize( lVector );
+
+ float spotEffect = dot( spotLight.direction, lightDir );
+ spotEffect = saturate( pow( saturate( spotEffect ), spotLight.exponent ) );
+
+ lightColor = spotLight.color;
+ lightColor *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) );
+
+ }
+
+#endif
+
+
+
+
+ | true |
Other | mrdoob | three.js | 74d3aa3f12120c906d190e621cb1260e88932757.json | parse arrays of struct uniforms, code cleanup. | src/renderers/shaders/ShaderLib.js | @@ -143,6 +143,7 @@ THREE.ShaderLib = {
THREE.ShaderChunk[ "uv2_pars_vertex" ],
THREE.ShaderChunk[ "envmap_pars_vertex" ],
THREE.ShaderChunk[ "lights_lambert_pars_vertex" ],
+ THREE.ShaderChunk[ "lights_pars" ],
THREE.ShaderChunk[ "color_pars_vertex" ],
THREE.ShaderChunk[ "morphtarget_pars_vertex" ],
THREE.ShaderChunk[ "skinning_pars_vertex" ],
@@ -347,6 +348,7 @@ THREE.ShaderLib = {
THREE.ShaderChunk[ "envmap_pars_fragment" ],
THREE.ShaderChunk[ "fog_pars_fragment" ],
THREE.ShaderChunk[ "lights_phong_pars_fragment" ],
+ THREE.ShaderChunk[ "lights_pars" ],
THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
THREE.ShaderChunk[ "bumpmap_pars_fragment" ],
THREE.ShaderChunk[ "normalmap_pars_fragment" ], | true |
Other | mrdoob | three.js | 74d3aa3f12120c906d190e621cb1260e88932757.json | parse arrays of struct uniforms, code cleanup. | src/renderers/webgl/WebGLProgram.js | @@ -25,26 +25,53 @@ THREE.WebGLProgram = ( function () {
var uniforms = {};
var n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );
+
+ var arrayStructRe = /^([\w\d_]+)\[(\d+)\]\.([\w\d_]+)$/;
+ var arrayRe = /^([\w\d_]+)\[0\]$/;
for ( var i = 0; i < n; i ++ ) {
var info = gl.getActiveUniform( program, i );
var name = info.name;
var location = gl.getUniformLocation( program, name );
- // console.log("THREE.WebGLProgram: ACTIVE UNIFORM:", name);
+ console.log("THREE.WebGLProgram: ACTIVE UNIFORM:", name);
- var suffixPos = name.lastIndexOf( '[0]' );
- if ( suffixPos !== - 1 && suffixPos === name.length - 3 ) {
+ var matches = arrayStructRe.exec(name);
+ if( matches ) {
- uniforms[ name.substr( 0, suffixPos ) ] = location;
+ var arrayName = matches[1];
+ var arrayIndex = matches[2];
+ var arrayProperty = matches[3];
+ var uniformsArray = uniforms[ arrayName ];
+ if( ! uniformsArray ) {
+ uniformsArray = uniforms[ arrayName ] = [];
+ }
+ var uniformsArrayIndex = uniformsArray[ arrayIndex ];
+ if( ! uniformsArrayIndex ) {
+ uniformsArrayIndex = uniformsArray[ arrayIndex ] = {};
+ }
+ uniformsArrayIndex[ arrayProperty ] = location;
+
+ continue;
+ }
+
+ matches = arrayRe.exec(name)
+ if( matches ) {
+
+ var arrayName = matches[1];
+
+ uniforms[ arrayName ] = location;
+
+ continue;
}
uniforms[ name ] = location;
}
+ console.log("uniforms", uniforms);
return uniforms;
} | true |
Other | mrdoob | three.js | eb3dfab0bb313ca2059b33b6e57c0eeae02a7bc2.json | Fix null pointer err for some collada models
For some collada models, the parent of bone might be null instead of -1. | src/objects/SkinnedMesh.js | @@ -43,7 +43,7 @@ THREE.SkinnedMesh = function ( geometry, material, useVertexTexture ) {
gbone = this.geometry.bones[ b ];
- if ( gbone.parent !== - 1 ) {
+ if ( gbone.parent !== - 1 && gbone.parent !== null) {
bones[ gbone.parent ].add( bones[ b ] );
| false |
Other | mrdoob | three.js | 6d64a0616e2223061010ef7c771b7d6843e3e35c.json | Remove Line Breaks at function calls | src/objects/Mesh.js | @@ -211,8 +211,7 @@ THREE.Mesh.prototype.raycast = ( function () {
b = indices[ i + 1 ];
c = indices[ i + 2 ];
- intersection = checkBufferGeometryIntersection( this, raycaster, ray,
- positions, uvs, a, b, c );
+ intersection = checkBufferGeometryIntersection( this, raycaster, ray, positions, uvs, a, b, c );
if( intersection ){
@@ -233,8 +232,7 @@ THREE.Mesh.prototype.raycast = ( function () {
b = a + 1;
c = a + 2;
- intersection = checkBufferGeometryIntersection( this, raycaster, ray,
- positions, uvs, a, b, c );
+ intersection = checkBufferGeometryIntersection( this, raycaster, ray, positions, uvs, a, b, c );
if( intersection ){
| false |
Other | mrdoob | three.js | 6dffe4a2bf5213b4eb29d50b92f59f6d7656c3d5.json | Fix intersection uv for non-indexed BufferGeometry | src/objects/Mesh.js | @@ -218,22 +218,22 @@ THREE.Mesh.prototype.raycast = ( function () {
if ( distance < raycaster.near || distance > raycaster.far ) continue;
+ a = i / 3;
+ b = a + 1;
+ c = a + 2;
+
var uv;
if ( attributes.uv !== undefined ) {
var uvs = attributes.uv.array;
- uvA.fromArray( uvs, i );
- uvB.fromArray( uvs, i + 2 );
- uvC.fromArray( uvs, i + 4 );
+ uvA.fromArray( uvs, a * 2 );
+ uvB.fromArray( uvs, b * 2 );
+ uvC.fromArray( uvs, c * 2 );
uv = uvIntersection( intersectionPoint, vA, vB, vC, uvA, uvB, uvC );
}
- a = i / 3;
- b = a + 1;
- c = a + 2;
-
intersects.push( {
distance: distance, | false |
Other | mrdoob | three.js | 1fa269150d403793d4fb236b8681c2018fc5c472.json | add indirect diffuse lighting. | src/renderers/shaders/ShaderChunk/lights_pars.glsl | @@ -107,6 +107,46 @@ uniform vec3 ambientLightColor;
#if defined( USE_ENVMAP ) && defined( PHYSICAL )
+
+ vec3 getDiffuseLightProbeIndirectLightColor( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {
+
+ #ifdef DOUBLE_SIDED
+
+ float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
+
+ #else
+
+ float flipNormal = 1.0;
+
+ #endif
+
+ vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
+
+ #ifdef ENVMAP_TYPE_CUBE
+
+ vec3 queryVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
+
+ #if defined( TEXTURE_CUBE_LOD_EXT )
+
+ vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
+
+ #else
+
+ vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
+
+ #endif
+ #else
+
+ vec4 envMapColor = vec3( 0.0 );
+
+ #endif
+
+ envMapColor.rgb = inputToLinear( envMapColor.rgb );
+
+ return envMapColor.rgb;
+
+ }
+
// taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html
float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {
| true |
Other | mrdoob | three.js | 1fa269150d403793d4fb236b8681c2018fc5c472.json | add indirect diffuse lighting. | src/renderers/shaders/ShaderChunk/lights_template.glsl | @@ -71,6 +71,13 @@ GeometricContext geometry = GeometricContext( -vViewPosition, normalize( normal
}
+#endif
+
+#if defined( USE_ENVMAP ) && defined( PHYSICAL )
+
+ // TODO, replace 8 with the real maxMIPLevel
+ indirectDiffuseColor += getDiffuseLightProbeIndirectLightColor( /*lightProbe,*/ geometry, 8 );
+
#endif
Material_RE_IndirectDiffuseLight( indirectDiffuseColor, geometry, material, reflectedLight ); | true |
Other | mrdoob | three.js | 348c706a4679e52eaf1a0646e18636abfa9509e6.json | Keep TrackballControls from consuming all events. | examples/js/controls/TrackballControls.js | @@ -356,8 +356,6 @@ THREE.TrackballControls = function ( object, domElement ) {
if ( _this.enabled === false ) return;
- window.removeEventListener( 'keydown', keydown );
-
_prevState = _state;
if ( _state !== STATE.NONE ) {
@@ -386,17 +384,12 @@ THREE.TrackballControls = function ( object, domElement ) {
_state = _prevState;
- window.addEventListener( 'keydown', keydown, false );
-
}
function mousedown( event ) {
if ( _this.enabled === false ) return;
- event.preventDefault();
- event.stopPropagation();
-
if ( _state === STATE.NONE ) {
_state = event.button;
@@ -431,9 +424,6 @@ THREE.TrackballControls = function ( object, domElement ) {
if ( _this.enabled === false ) return;
- event.preventDefault();
- event.stopPropagation();
-
if ( _state === STATE.ROTATE && ! _this.noRotate ) {
_movePrev.copy( _moveCurr );
@@ -455,9 +445,6 @@ THREE.TrackballControls = function ( object, domElement ) {
if ( _this.enabled === false ) return;
- event.preventDefault();
- event.stopPropagation();
-
_state = STATE.NONE;
document.removeEventListener( 'mousemove', mousemove );
@@ -470,9 +457,6 @@ THREE.TrackballControls = function ( object, domElement ) {
if ( _this.enabled === false ) return;
- event.preventDefault();
- event.stopPropagation();
-
var delta = 0;
if ( event.wheelDelta ) {
@@ -529,9 +513,6 @@ THREE.TrackballControls = function ( object, domElement ) {
if ( _this.enabled === false ) return;
- event.preventDefault();
- event.stopPropagation();
-
switch ( event.touches.length ) {
case 1: | false |
Other | mrdoob | three.js | 6e3c2e88ebe0ed51f9800dfdae9d60fddd29452a.json | remove diffuse light probe for now. | src/renderers/shaders/ShaderChunk/lights_pars.glsl | @@ -107,44 +107,6 @@ uniform vec3 ambientLightColor;
#if defined( USE_ENVMAP ) && defined( PHYSICAL )
-
- vec3 getDiffuseLightProbeIndirectLightColor( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in float maxLodLevel ) {
-
- #ifdef DOUBLE_SIDED
-
- float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
-
- #else
-
- float flipNormal = 1.0;
-
- #endif
-
- vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
-
- #ifdef ENVMAP_TYPE_CUBE
-
- #if defined( TEXTURE_CUBE_LOD_EXT )
-
- vec4 envMapColor = textureCubeLodEXT( envMap, flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz ), maxLodLevel );
-
- #else
-
- vec4 envMapColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz ), maxLodLevel );
-
- #endif
- #else
-
- vec4 envMapColor = vec3( 0.0 );
-
- #endif
-
- envMapColor.rgb = inputToLinear( envMapColor.rgb );
-
- return envMapColor.rgb;
-
- }
-
// taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html
float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {
| false |
Other | mrdoob | three.js | 9a32595d57f7dfb9292db4d2bff7a63bdab40995.json | add more "const" and "in" qualifiers to functions. | src/renderers/shaders/ShaderChunk/bsdfs.glsl | @@ -1,4 +1,4 @@
-float calcLightAttenuation( float lightDistance, float cutoffDistance, float decayExponent ) {
+float calcLightAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
if ( decayExponent > 0.0 ) {
@@ -36,7 +36,7 @@ vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
// Microfacet Models for Refraction through Rough Surfaces - equation (34)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disney’s reparameterization
-float G_GGX_Smith( in float alpha, in float dotNL, in float dotNV ) {
+float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
// geometry term = G(l)⋅G(v) / 4(n⋅l)(n⋅v)
@@ -54,7 +54,7 @@ float G_GGX_Smith( in float alpha, in float dotNL, in float dotNV ) {
// Microfacet Models for Refraction through Rough Surfaces - equation (33)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disney’s reparameterization
-float D_GGX( in float alpha, in float dotNH ) {
+float D_GGX( const in float alpha, const in float dotNH ) {
// factor of 1/PI in distribution term omitted as incoming light intensity is scaled up by PI because it is considered a punctual light source
@@ -93,7 +93,7 @@ vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in Geometric
// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile
-vec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, vec3 specularColor, float roughness ) {
+vec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
@@ -112,7 +112,7 @@ vec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, vec3 spe
} // validated
-float G_BlinnPhong_Implicit( /* in float dotNL, in float dotNV */ ) {
+float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {
// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)
return 0.25; | false |
Other | mrdoob | three.js | 67d35df4f026e78723951d0842514eaedf02f73e.json | fix Sea3DLoader for new simplified lighting model. | examples/js/loaders/sea3d/SEA3DLoader.js | @@ -84,14 +84,15 @@ THREE.SEA3D.ShaderLib.replaceCode = function( src, target, replace ) {
THREE.SEA3D.ShaderLib.fragStdMtl = THREE.SEA3D.ShaderLib.replaceCode( THREE.ShaderLib.phong.fragmentShader, [
// Target
- 'outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight ) * specular + totalSpecularLight + totalEmissiveLight;', // METAL
- 'outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight ) + totalSpecularLight + totalEmissiveLight;'
+ 'vec3 outgoingLight = ( reflectedLight.directDiffuse + reflectedLight.indirectDiffuse ) * specular + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;', // METAL
+ 'vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;'
], [
// Replace To
- 'outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight + totalEmissiveLight ) * specular + totalSpecularLight;', // METAL
- 'outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight + totalEmissiveLight ) + totalSpecularLight;'
+ 'vec3 outgoingLight = ( reflectedLight.directDiffuse + reflectedLight.indirectDiffuse ) * specular + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight * specular;', // METAL
+ 'vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight * diffuse;'
] );
+
//
// Standard Material
// | false |
Other | mrdoob | three.js | b64a4386b4388a0913c139473b047ff59c915329.json | remove struct initializers in vertex lambert. | src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl | @@ -1,7 +1,14 @@
vec3 diffuse = vec3( 1.0 );
-GeometricContext geometry = GeometricContext( mvPosition.xyz, normalize( transformedNormal ), normalize( -mvPosition.xyz ) );
-GeometricContext backGeometry = GeometricContext( geometry.position, -geometry.normal, geometry.viewDir );
+GeometricContext geometry;
+geometry.position = mvPosition.xyz;
+geometry.normal = normalize( transformedNormal );
+geometry.viewDir = normalize( -mvPosition.xyz );
+
+GeometricContext backGeometry;
+backGeometry.position = geometry.position;
+backGeometry.normal = -geometry.normal;
+backGeometry.viewDir = geometry.viewDir;
vLightFront = vec3( 0.0 );
| false |
Other | mrdoob | three.js | 206a7d0d4b012be1d79fbccfa38c332279a343c3.json | parse materialIndex when adding groups | src/loaders/BufferGeometryLoader.js | @@ -64,7 +64,7 @@ THREE.BufferGeometryLoader.prototype = {
var group = groups[ i ];
- geometry.addGroup( group.start, group.count );
+ geometry.addGroup( group.start, group.count, group.materialIndex );
}
| false |
Other | mrdoob | three.js | 02888c4051d3f2b42c3e3e8334f406064777bf3d.json | Add support for BufferGeometry | examples/js/exporters/OBJExporter.js | @@ -23,7 +23,9 @@ THREE.OBJExporter.prototype = {
var nbNormals = 0;
var geometry = mesh.geometry;
-
+ if ( geometry instanceof THREE.BufferGeometry ) {
+ geometry = new THREE.Geometry().fromBufferGeometry(geometry);
+ }
if ( geometry instanceof THREE.Geometry ) {
output += 'o ' + mesh.name + '\n'; | false |
Other | mrdoob | three.js | ee11d86d08c2de3278f7b0c9538635c6f9a0a28a.json | Fix constant used in fresnel approximation | src/renderers/shaders/ShaderChunk/bsdfs.glsl | @@ -24,7 +24,7 @@ vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
//;float fresnel = pow( 1.0 - dotLH, 5.0 );
// Optimized variant (presented by Epic at SIGGRAPH '13)
- float fresnel = exp2( ( -5.55437 * dotLH - 6.98316 ) * dotLH );
+ float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
return ( 1.0 - specularColor ) * fresnel + specularColor;
| false |
Other | mrdoob | three.js | f0823390a8e7e0da84735b1b83c94ad54f4c0e6f.json | Clarify area definition for setViewport/setScissor | docs/api/renderers/WebGLRenderer.html | @@ -178,6 +178,8 @@ <h3>[method:null setViewport]( [page:Integer x], [page:Integer y], [page:Integer
<h3>[method:null setScissor]( [page:Integer x], [page:Integer y], [page:Integer width], [page:Integer height] )</h3>
<div>Sets the scissor area from (x, y) to (x + width, y + height).</div>
+
+ <div>NOTE: The point (x, y) is the lower left corner of the area to be set for both of these methods. The area is defined from left to right in width but bottom to top in height. The sense of the vertical definition is opposite to the fill direction of an HTML canvas element.</div>
<h3>[method:null enableScissorTest]( [page:Boolean enable] )</h3>
<div>Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions.</div> | false |
Other | mrdoob | three.js | 6b958991dc755f3feef4fa304e8aab0d8a3d4e5f.json | Remove unused variable | examples/webgl_multiple_elements.html | @@ -87,7 +87,7 @@
var canvas;
- var scenes = [], camera, renderer, emptyScene;
+ var scenes = [], camera, renderer;
init();
animate();
@@ -109,8 +109,6 @@
var template = document.getElementById("template").text;
var content = document.getElementById("content");
- var emptyScene = new THREE.Scene();
-
for ( var i = 0; i < 100; i ++ ) {
var scene = new THREE.Scene(); | false |
Other | mrdoob | three.js | ee1e677ba3bf150ff5f241579dfc77f71c5d6f0d.json | remove unused code. | utils/exporters/blender/addons/io_three/exporter/geometry.py | @@ -565,7 +565,6 @@ def _parse_geometry(self):
mt = api.mesh.blend_shapes(self.node, self.options) or []
self[constants.MORPH_TARGETS] = mt
if len(mt) > 0 and self._scene: # there's blend shapes, let check for animation
- #self[constants.CLIPS] = api.mesh.animated_blend_shapes(self.node, self.options) or []
tracks = api.mesh.animated_blend_shapes(self.node, self[constants.NAME], self.options) or []
merge = self._scene[constants.ANIMATION][0][constants.KEYFRAMES]
for track in tracks: | false |
Other | mrdoob | three.js | d848e13d346c5087d09b579066e241268d0ca6d0.json | add decayExponent support to lights. | utils/exporters/blender/addons/io_three/constants.py | @@ -113,6 +113,7 @@
WARNING = 'warning'
INFO = 'info'
DEBUG = 'debug'
+DISABLED = 'disabled'
NONE = 'None'
MSGPACK = 'msgpack'
@@ -338,6 +339,7 @@
DISTANCE = 'distance'
ASPECT = 'aspect'
ANGLE = 'angle'
+DECAY = 'decayExponent'
FOV = 'fov'
ASPECT = 'aspect' | true |
Other | mrdoob | three.js | d848e13d346c5087d09b579066e241268d0ca6d0.json | add decayExponent support to lights. | utils/exporters/blender/addons/io_three/exporter/api/light.py | @@ -75,3 +75,23 @@ def intensity(lamp):
"""
logger.debug("light.intensity(%s)", lamp)
return round(lamp.energy, 2)
+
+# mapping enum values to decay exponent
+__FALLOFF_TO_EXP = {
+ 'CONSTANT': 0,
+ 'INVERSE_LINEAR': 1,
+ 'INVERSE_SQUARE': 2,
+ 'CUSTOM_CURVE': 0,
+ 'LINEAR_QUADRATIC_WEIGHTED': 2
+}
+
+@_lamp
+def falloff(lamp):
+ """
+
+ :param lamp:
+ :rtype: float
+
+ """
+ logger.debug("light.falloff(%s)", lamp)
+ return __FALLOFF_TO_EXP[lamp.falloff_type] | true |
Other | mrdoob | three.js | d848e13d346c5087d09b579066e241268d0ca6d0.json | add decayExponent support to lights. | utils/exporters/blender/addons/io_three/exporter/object.py | @@ -51,8 +51,12 @@ def _init_light(self):
# self[constants.DISTANCE] = api.light.distance(self.data)
self[constants.DISTANCE] = 0;
- if self[constants.TYPE] == constants.SPOT_LIGHT:
+ lightType = self[constants.TYPE]
+ if lightType == constants.SPOT_LIGHT:
self[constants.ANGLE] = api.light.angle(self.data)
+ self[constants.DECAY] = api.light.falloff(self.data)
+ elif lightType == constants.POINT_LIGHT:
+ self[constants.DECAY] = api.light.falloff(self.data)
def _init_mesh(self):
"""Initialize mesh attributes""" | true |
Other | mrdoob | three.js | 412044d236d99b97ba23f83cc541fad31bd7e706.json | fix bad names in animation tracks on geometries. | utils/exporters/blender/addons/io_three/exporter/api/mesh.py | @@ -465,6 +465,11 @@ def animated_blend_shapes(mesh, name, options):
:param options:
"""
+
+ # let filter the name to only keep the node's name
+ # the two cases are '%sGeometry' and '%sGeometry.%d', and we want %s
+ name = re.search("^(.*)Geometry(\..*)?$", name).group(1)
+
logger.debug("mesh.animated_blend_shapes(%s, %s)", mesh, options)
tracks = []
shp = mesh.shape_keys | false |
Other | mrdoob | three.js | 2d3f69905f8f426fdc43c1c082cac6b56bd54713.json | fix double application of ambient light. | src/renderers/shaders/ShaderLib.js | @@ -230,13 +230,13 @@ THREE.ShaderLib = {
" #ifdef DOUBLE_SIDED",
" if ( gl_FrontFacing )",
- " outgoingLight += diffuseColor.rgb * ( vLightFront * shadowMask + totalAmbientLight ) + emissive;",
+ " outgoingLight += diffuseColor.rgb * ( vLightFront * shadowMask ) + emissive;",
" else",
- " outgoingLight += diffuseColor.rgb * ( vLightBack * shadowMask + totalAmbientLight ) + emissive;",
+ " outgoingLight += diffuseColor.rgb * ( vLightBack * shadowMask ) + emissive;",
" #else",
- " outgoingLight += diffuseColor.rgb * ( vLightFront * shadowMask + totalAmbientLight ) + emissive;",
+ " outgoingLight += diffuseColor.rgb * ( vLightFront * shadowMask ) + emissive;",
" #endif",
| false |
Other | mrdoob | three.js | 73cb6b483afb981d5408d389e7bd7f66c9cef0b5.json | add variations with cubeMap on phong. | examples/webgl_materials_phong_variations.html | @@ -81,8 +81,7 @@
var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
reflectionCube.format = THREE.RGBFormat;
- reflectionCube = null;
-
+
var cubeWidth = 400;
var numberOfSphersPerSide = 5;
var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;
@@ -91,20 +90,30 @@
var geometry = new THREE.SphereBufferGeometry( sphereRadius, 32, 16 );
- for( var alpha = 0; alpha <= 1.0; alpha += stepSize ) {
+ var localReflectionCube;
+
+ for( var alpha = 0, alphaIndex = 0; alpha <= 1.0; alpha += stepSize, alphaIndex ++ ) {
+
+ if( alphaIndex % 2 === 0 ) {
+ localReflectionCube = null;
+ }
+ else {
+ localReflectionCube = reflectionCube;
+ }
var specularShininess = Math.pow( 2, alpha * 10 );
for( var beta = 0; beta <= 1.0; beta += stepSize ) {
var specularColor = new THREE.Color( beta * 0.2, beta * 0.2, beta * 0.2 );
+ var reflectivity = beta;
for( var gamma = 0; gamma <= 1.0; gamma += stepSize ) {
// basic monochromatic energy preservation
var diffuseColor = new THREE.Color( 0, 0, gamma ).multiplyScalar( 1 - beta * 0.2 );
- var material = new THREE.MeshPhongMaterial( { map: imgTexture, bumpMap: imgTexture, bumpScale: bumpScale, color: diffuseColor, specular: specularColor, shininess: specularShininess, shading: THREE.SmoothShading, envMap: reflectionCube, } )
+ var material = new THREE.MeshPhongMaterial( { map: imgTexture, bumpMap: imgTexture, bumpScale: bumpScale, color: diffuseColor, specular: specularColor, reflectivity: reflectivity, shininess: specularShininess, shading: THREE.SmoothShading, envMap: localReflectionCube } )
var mesh = new THREE.Mesh( geometry, material );
@@ -145,8 +154,8 @@
addLabel( "-shininess", new THREE.Vector3( -350, 0, 0 ) );
addLabel( "+shininess", new THREE.Vector3( 350, 0, 0 ) );
- addLabel( "-specular", new THREE.Vector3( 0, -300, 0 ) );
- addLabel( "+specular", new THREE.Vector3( 0, 300, 0 ) );
+ addLabel( "-specular, -reflectivity", new THREE.Vector3( 0, -300, 0 ) );
+ addLabel( "+specular, +reflectivity", new THREE.Vector3( 0, 300, 0 ) );
addLabel( "-diffuse", new THREE.Vector3( 0, 0, -300 ) );
addLabel( "+diffuse", new THREE.Vector3( 0, 0, 300 ) ); | false |
Other | mrdoob | three.js | 61aa1f739fad60b41d91c87f535b951988b46ef6.json | add lambert variations. | examples/webgl_materials_lambert_variations.html | @@ -0,0 +1,248 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>three.js webgl - materials</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+ <style>
+ body {
+ color: #fff;
+ font-family:Monospace;
+ font-size:13px;
+ text-align:center;
+
+ background-color: #fff;
+ margin: 0px;
+ overflow: hidden;
+ }
+
+ #info {
+ position: absolute;
+ top: 0px; width: 100%;
+ padding: 5px;
+ }
+ </style>
+ </head>
+ <body>
+
+ <div id="container"></div>
+ <div id="info"><a href="http://threejs.org" target="_blank">three.js</a> - Lambert Material Variantions by <a href="http://clara.io/" target="_blank">Ben Houston</a>.</div>
+
+ <script src="../build/three.min.js"></script>
+ <script src="js/controls/OrbitControls.js"></script>
+ <script src="js/geometries/TextGeometry.js"></script>
+ <script src="js/utils/FontUtils.js"></script>
+ <script src="fonts/gentilis_regular.typeface.js"></script>
+
+ <script src="js/Detector.js"></script>
+ <script src="js/libs/stats.min.js"></script>
+
+ <script>
+
+ if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+
+ var container, stats;
+
+ var camera, scene, renderer, controls, objects = [];
+ var particleLight;
+
+ init();
+ animate();
+
+ function init() {
+
+ container = document.createElement( 'div' );
+ document.body.appendChild( container );
+
+ camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 2000 );
+ camera.position.set( 0.0, 400, 400 * 3.5 );
+
+ scene = new THREE.Scene();
+
+ // Materials
+
+ var imgTexture = THREE.ImageUtils.loadTexture( "textures/planets/moon_1024.jpg" );
+ imgTexture.wrapS = imgTexture.wrapT = THREE.RepeatWrapping;
+ imgTexture.anisotropy = 16;
+ imgTexture = null;
+
+ var shininess = 50, specular = 0x333333, shading = THREE.SmoothShading;
+
+ var materials = [];
+
+ var path = "textures/cube/SwedishRoyalCastle/";
+ var format = '.jpg';
+ var urls = [
+ path + 'px' + format, path + 'nx' + format,
+ path + 'py' + format, path + 'ny' + format,
+ path + 'pz' + format, path + 'nz' + format
+ ];
+
+ var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
+ reflectionCube.format = THREE.RGBFormat;
+
+ var cubeWidth = 400;
+ var numberOfSphersPerSide = 5;
+ var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;
+ var stepSize = 1.0 / numberOfSphersPerSide;
+
+ var geometry = new THREE.SphereBufferGeometry( sphereRadius, 32, 16 );
+
+
+ for( var alpha = 0; alpha <= 1.0; alpha += stepSize ) {
+
+ var baseColor = new THREE.Color().setHSL( alpha, 0.5, 0.5 );
+
+ if( alpha >= 0.5 ) {
+ reflectionCube = null;
+ }
+
+ for( var beta = 0; beta <= 1.0; beta += stepSize ) {
+
+ var reflectivity = beta;
+
+ for( var gamma = 0; gamma <= 1.0; gamma += stepSize ) {
+
+ var diffuseColor = baseColor.clone().multiplyScalar( gamma );
+
+ var material = new THREE.MeshLambertMaterial( { map: imgTexture, color: diffuseColor, reflectivity: reflectivity, shading: THREE.SmoothShading, envMap: reflectionCube } )
+
+ var mesh = new THREE.Mesh( geometry, material );
+
+ mesh.position.x = alpha * 400 - 200;
+ mesh.position.y = beta * 400 - 200;
+ mesh.position.z = gamma * 400 - 200;
+
+ objects.push( mesh );
+
+ scene.add( mesh );
+ }
+ }
+ }
+
+ function addLabel( name, location ) {
+ var textGeo = new THREE.TextGeometry( name, {
+
+ size: 20,
+ height: 5,
+ curveSegments: 10,
+
+ font: 'gentilis',
+ weight: 'normal',
+ style: 'normal',
+
+ material: 0,
+ extrudeMaterial: 1
+
+ });
+
+ var textMaterial = new THREE.MeshBasicMaterial( { color: 0xffffff } );
+ var textMesh = new THREE.Mesh( textGeo, textMaterial );
+ textMesh.position.copy( location );
+ scene.add( textMesh );
+ }
+
+ addLabel( "+hue", new THREE.Vector3( -350, 0, 0 ) );
+ addLabel( "-hue", new THREE.Vector3( 350, 0, 0 ) );
+
+ addLabel( "-reflectivity", new THREE.Vector3( 0, -300, 0 ) );
+ addLabel( "+reflectivity", new THREE.Vector3( 0, 300, 0 ) );
+
+ addLabel( "-diffuse", new THREE.Vector3( 0, 0, -300 ) );
+ addLabel( "+diffuse", new THREE.Vector3( 0, 0, 300 ) );
+
+ addLabel( "envMap", new THREE.Vector3( -350, 300, 0 ) );
+ addLabel( "no envMap", new THREE.Vector3( 350, 300, 0 ) );
+
+ particleLight = new THREE.Mesh( new THREE.SphereBufferGeometry( 4, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0xffffff } ) );
+ scene.add( particleLight );
+
+ // Lights
+
+ scene.add( new THREE.AmbientLight( 0x222222 ) );
+
+ var directionalLight = new THREE.DirectionalLight( 0xffffff, 1 );
+ directionalLight.position.set( 1, 1, 1 ).normalize();
+ scene.add( directionalLight );
+
+ var pointLight = new THREE.PointLight( 0xffffff, 2, 800 );
+ particleLight.add( pointLight );
+
+ //
+
+ renderer = new THREE.WebGLRenderer( { antialias: true } );
+ renderer.setClearColor( 0x0a0a0a );
+ renderer.setPixelRatio( window.devicePixelRatio );
+ renderer.setSize( window.innerWidth, window.innerHeight );
+ renderer.sortObjects = true;
+
+ container.appendChild( renderer.domElement );
+
+ renderer.gammaInput = true;
+ renderer.gammaOutput = true;
+
+ //
+
+ stats = new Stats();
+ stats.domElement.style.position = 'absolute';
+ stats.domElement.style.top = '0px';
+
+ container.appendChild( stats.domElement );
+
+ controls = new THREE.OrbitControls( camera );
+ controls.target.set( 0, 0, 0 );
+ controls.update();
+
+ window.addEventListener( 'resize', onWindowResize, false );
+
+ }
+
+ function onWindowResize() {
+
+ camera.aspect = window.innerWidth / window.innerHeight;
+ camera.updateProjectionMatrix();
+
+ renderer.setSize( window.innerWidth, window.innerHeight );
+
+ }
+
+ //
+
+ function animate() {
+
+ requestAnimationFrame( animate );
+
+ render();
+ stats.update();
+
+ }
+
+ function render() {
+
+ var timer = Date.now() * 0.00025;
+
+ //camera.position.x = Math.cos( timer ) * 800;
+ //camera.position.z = Math.sin( timer ) * 800;
+
+ camera.lookAt( scene.position );
+
+ for ( var i = 0, l = objects.length; i < l; i ++ ) {
+
+ var object = objects[ i ];
+
+ object.rotation.y += 0.005;
+
+ }
+
+ particleLight.position.x = Math.sin( timer * 7 ) * 300;
+ particleLight.position.y = Math.cos( timer * 5 ) * 400;
+ particleLight.position.z = Math.cos( timer * 3 ) * 300;
+
+ renderer.render( scene, camera );
+
+ }
+
+ </script>
+
+ </body>
+</html> | false |
Other | mrdoob | three.js | ca484bfd8ac073250548995ecd12722e983ec6cd.json | add basic variations. | examples/webgl_materials_basic_variations.html | @@ -0,0 +1,247 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>three.js webgl - materials</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+ <style>
+ body {
+ color: #fff;
+ font-family:Monospace;
+ font-size:13px;
+ text-align:center;
+
+ background-color: #fff;
+ margin: 0px;
+ overflow: hidden;
+ }
+
+ #info {
+ position: absolute;
+ top: 0px; width: 100%;
+ padding: 5px;
+ }
+ </style>
+ </head>
+ <body>
+
+ <div id="container"></div>
+ <div id="info"><a href="http://threejs.org" target="_blank">three.js</a> - Basic Material Variantions by <a href="http://clara.io/" target="_blank">Ben Houston</a>.</div>
+
+ <script src="../build/three.min.js"></script>
+ <script src="js/controls/OrbitControls.js"></script>
+ <script src="js/geometries/TextGeometry.js"></script>
+ <script src="js/utils/FontUtils.js"></script>
+ <script src="fonts/gentilis_regular.typeface.js"></script>
+
+ <script src="js/Detector.js"></script>
+ <script src="js/libs/stats.min.js"></script>
+
+ <script>
+
+ if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+
+ var container, stats;
+
+ var camera, scene, renderer, controls, objects = [];
+ var particleLight;
+
+ init();
+ animate();
+
+ function init() {
+
+ container = document.createElement( 'div' );
+ document.body.appendChild( container );
+
+ camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 2000 );
+ camera.position.set( 0.0, 400, 400 * 3.5 );
+
+ scene = new THREE.Scene();
+
+ // Materials
+
+ var imgTexture = THREE.ImageUtils.loadTexture( "textures/planets/moon_1024.jpg" );
+ imgTexture.wrapS = imgTexture.wrapT = THREE.RepeatWrapping;
+ imgTexture.anisotropy = 16;
+ imgTexture = null;
+
+ var shininess = 50, specular = 0x333333, shading = THREE.SmoothShading;
+
+ var materials = [];
+
+ var path = "textures/cube/SwedishRoyalCastle/";
+ var format = '.jpg';
+ var urls = [
+ path + 'px' + format, path + 'nx' + format,
+ path + 'py' + format, path + 'ny' + format,
+ path + 'pz' + format, path + 'nz' + format
+ ];
+
+ var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
+ reflectionCube.format = THREE.RGBFormat;
+
+ var cubeWidth = 400;
+ var numberOfSphersPerSide = 5;
+ var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;
+ var stepSize = 1.0 / numberOfSphersPerSide;
+
+ var geometry = new THREE.SphereBufferGeometry( sphereRadius, 32, 16 );
+
+ for( var alpha = 0; alpha <= 1.0; alpha += stepSize ) {
+
+ var baseColor = new THREE.Color().setHSL( alpha, 0.5, 0.5 );
+
+ if( alpha >= 0.5 ) {
+ reflectionCube = null;
+ }
+
+ for( var beta = 0; beta <= 1.0; beta += stepSize ) {
+
+ var reflectivity = beta;
+
+ for( var gamma = 0; gamma <= 1.0; gamma += stepSize ) {
+
+ var diffuseColor = baseColor.clone().multiplyScalar( gamma );
+
+ var material = new THREE.MeshBasicMaterial( { map: imgTexture, color: diffuseColor, reflectivity: reflectivity, shading: THREE.SmoothShading, envMap: reflectionCube } )
+
+ var mesh = new THREE.Mesh( geometry, material );
+
+ mesh.position.x = alpha * 400 - 200;
+ mesh.position.y = beta * 400 - 200;
+ mesh.position.z = gamma * 400 - 200;
+
+ objects.push( mesh );
+
+ scene.add( mesh );
+ }
+ }
+ }
+
+ function addLabel( name, location ) {
+ var textGeo = new THREE.TextGeometry( name, {
+
+ size: 20,
+ height: 5,
+ curveSegments: 10,
+
+ font: 'gentilis',
+ weight: 'normal',
+ style: 'normal',
+
+ material: 0,
+ extrudeMaterial: 1
+
+ });
+
+ var textMaterial = new THREE.MeshBasicMaterial( { color: 0xffffff } );
+ var textMesh = new THREE.Mesh( textGeo, textMaterial );
+ textMesh.position.copy( location );
+ scene.add( textMesh );
+ }
+
+ addLabel( "+hue", new THREE.Vector3( -350, 0, 0 ) );
+ addLabel( "-hue", new THREE.Vector3( 350, 0, 0 ) );
+
+ addLabel( "-reflectivity", new THREE.Vector3( 0, -300, 0 ) );
+ addLabel( "+reflectivity", new THREE.Vector3( 0, 300, 0 ) );
+
+ addLabel( "-diffuse", new THREE.Vector3( 0, 0, -300 ) );
+ addLabel( "+diffuse", new THREE.Vector3( 0, 0, 300 ) );
+
+ addLabel( "envMap", new THREE.Vector3( -350, 300, 0 ) );
+ addLabel( "no envMap", new THREE.Vector3( 350, 300, 0 ) );
+
+ particleLight = new THREE.Mesh( new THREE.SphereBufferGeometry( 4, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0xffffff } ) );
+ scene.add( particleLight );
+
+ // Lights
+
+ scene.add( new THREE.AmbientLight( 0x222222 ) );
+
+ var directionalLight = new THREE.DirectionalLight( 0xffffff, 1 );
+ directionalLight.position.set( 1, 1, 1 ).normalize();
+ scene.add( directionalLight );
+
+ var pointLight = new THREE.PointLight( 0xffffff, 2, 800 );
+ particleLight.add( pointLight );
+
+ //
+
+ renderer = new THREE.WebGLRenderer( { antialias: true } );
+ renderer.setClearColor( 0x0a0a0a );
+ renderer.setPixelRatio( window.devicePixelRatio );
+ renderer.setSize( window.innerWidth, window.innerHeight );
+ renderer.sortObjects = true;
+
+ container.appendChild( renderer.domElement );
+
+ renderer.gammaInput = true;
+ renderer.gammaOutput = true;
+
+ //
+
+ stats = new Stats();
+ stats.domElement.style.position = 'absolute';
+ stats.domElement.style.top = '0px';
+
+ container.appendChild( stats.domElement );
+
+ controls = new THREE.OrbitControls( camera );
+ controls.target.set( 0, 0, 0 );
+ controls.update();
+
+ window.addEventListener( 'resize', onWindowResize, false );
+
+ }
+
+ function onWindowResize() {
+
+ camera.aspect = window.innerWidth / window.innerHeight;
+ camera.updateProjectionMatrix();
+
+ renderer.setSize( window.innerWidth, window.innerHeight );
+
+ }
+
+ //
+
+ function animate() {
+
+ requestAnimationFrame( animate );
+
+ render();
+ stats.update();
+
+ }
+
+ function render() {
+
+ var timer = Date.now() * 0.00025;
+
+ //camera.position.x = Math.cos( timer ) * 800;
+ //camera.position.z = Math.sin( timer ) * 800;
+
+ camera.lookAt( scene.position );
+
+ for ( var i = 0, l = objects.length; i < l; i ++ ) {
+
+ var object = objects[ i ];
+
+ object.rotation.y += 0.005;
+
+ }
+
+ particleLight.position.x = Math.sin( timer * 7 ) * 300;
+ particleLight.position.y = Math.cos( timer * 5 ) * 400;
+ particleLight.position.z = Math.cos( timer * 3 ) * 300;
+
+ renderer.render( scene, camera );
+
+ }
+
+ </script>
+
+ </body>
+</html> | false |
Other | mrdoob | three.js | 89b3dac2dce16c25076e1cc23a0107d7eb56ca13.json | remove energy conserving mode. | editor/js/Sidebar.Material.js | @@ -163,16 +163,6 @@ Sidebar.Material = function ( editor ) {
container.add( materialVertexColorsRow );
- // energy conserving
-
- var materialEnergyConservingRow = new UI.Panel();
- var materialEnergyConserving = new UI.Checkbox( false ).onChange( update );
-
- materialEnergyConservingRow.add( new UI.Text( 'EnergyConserving' ).setWidth( '90px' ) );
- materialEnergyConservingRow.add( materialEnergyConserving );
-
- container.add( materialEnergyConservingRow );
-
// skinning
var materialSkinningRow = new UI.Panel();
@@ -472,12 +462,6 @@ Sidebar.Material = function ( editor ) {
}
- if ( material.energyConserving !== undefined ) {
-
- material.energyConserving = materialEnergyConserving.getValue();
-
- }
-
if ( material.map !== undefined ) {
var mapEnabled = materialMapEnabled.getValue() === true;
@@ -703,7 +687,6 @@ Sidebar.Material = function ( editor ) {
'vertexShader': materialProgramRow,
'vertexColors': materialVertexColorsRow,
'skinning': materialSkinningRow,
- 'energyConserving': materialEnergyConservingRow,
'map': materialMapRow,
'alphaMap': materialAlphaMapRow,
'bumpMap': materialBumpMapRow,
@@ -787,12 +770,6 @@ Sidebar.Material = function ( editor ) {
}
- if ( material.energyConserving !== undefined ) {
-
- materialEnergyConserving.setValue( material.energyConserving );
-
- }
-
if ( material.map !== undefined ) {
materialMapEnabled.setValue( material.map !== null ); | true |
Other | mrdoob | three.js | 89b3dac2dce16c25076e1cc23a0107d7eb56ca13.json | remove energy conserving mode. | src/materials/MeshPhongMaterial.js | @@ -11,8 +11,6 @@
*
* map: new THREE.Texture( <Image> ),
*
- * energyConverving: false
- *
* lightMap: new THREE.Texture( <Image> ),
* lightMapIntensity: <float>
*
@@ -73,8 +71,6 @@ THREE.MeshPhongMaterial = function ( parameters ) {
this.map = null;
- this.energyConserving = false;
-
this.lightMap = null;
this.lightMapIntensity = 1.0;
@@ -137,8 +133,6 @@ THREE.MeshPhongMaterial.prototype.copy = function ( source ) {
this.map = source.map;
- this.energyConserving = source.energyConserving;
-
this.lightMap = source.lightMap;
this.lightMapIntensity = source.lightMapIntensity;
| true |
Other | mrdoob | three.js | 89b3dac2dce16c25076e1cc23a0107d7eb56ca13.json | remove energy conserving mode. | src/renderers/shaders/ShaderChunk/bsdfs.glsl | @@ -1,6 +1,3 @@
-//#define ENERGY_PRESERVING_MONOCHROME
-
-
float calcLightAttenuation( float lightDistance, float cutoffDistance, float decayExponent ) {
if ( decayExponent > 0.0 ) { | true |
Other | mrdoob | three.js | 89b3dac2dce16c25076e1cc23a0107d7eb56ca13.json | remove energy conserving mode. | src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl | @@ -7,14 +7,4 @@ material.diffuseColor = diffuseColor.rgb;
material.diffuseColor = vec3( 0.0 );
-#endif
-
-#if defined( ENERGY_PRESERVING_RGB )
-
- material.diffuseColor *= whiteCompliment( specular );
-
-#elif defined( ENERGY_PRESERVING_MONOCHROME )
-
- material.diffuseColor *= whiteCompliment( luminance( specular ) );
-
-#endif
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 89b3dac2dce16c25076e1cc23a0107d7eb56ca13.json | remove energy conserving mode. | src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl | @@ -2,13 +2,3 @@ PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.specularRoughness = roughnessFactor * 0.5 + 0.5; // disney's remapping of [ 0, 1 ] roughness to [ 0.5, 1 ]
material.specularColor = mix( vec3( 0.04 ) * reflectivity, diffuseColor.rgb, metalnessFactor );
-
-#if defined( ENERGY_PRESERVING_RGB )
-
- material.diffuseColor *= whiteCompliment( specularColor );
-
-#elif defined( ENERGY_PRESERVING_MONOCHROME )
-
- material.diffuseColor *= whiteCompliment( luminance( specularColor ) );
-
-#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 89b3dac2dce16c25076e1cc23a0107d7eb56ca13.json | remove energy conserving mode. | src/renderers/webgl/WebGLProgram.js | @@ -252,10 +252,6 @@ THREE.WebGLProgram = ( function () {
parameters.alphaMap ? '#define USE_ALPHAMAP' : '',
parameters.vertexColors ? '#define USE_COLOR' : '',
- parameters.energyConserving ? '#define ENERGY_PRESERVING_MONOCHROME' : '',
-
-
-
parameters.flatShading ? '#define FLAT_SHADED' : '',
parameters.skinning ? '#define USE_SKINNING' : '', | true |
Other | mrdoob | three.js | 89b3dac2dce16c25076e1cc23a0107d7eb56ca13.json | remove energy conserving mode. | src/renderers/webgl/WebGLPrograms.js | @@ -160,8 +160,6 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
specularMap: !! material.specularMap,
alphaMap: !! material.alphaMap,
- energyConserving: !! material.energyConserving,
-
combine: material.combine,
vertexColors: material.vertexColors, | true |
Other | mrdoob | three.js | 8610ef32210a5426aedd4ecd29c3ba4c0f2ff3c0.json | remove unneeded function. | src/renderers/shaders/ShaderChunk/common.glsl | @@ -21,13 +21,6 @@ struct ReflectedLight {
vec3 diffuse;
};
-void accumulateReflectedLight( inout ReflectedLight accumulator, const in ReflectedLight item ) {
-
- accumulator.diffuse += item.diffuse;
- accumulator.specular += item.specular;
-
-}
-
struct GeometricContext {
vec3 position;
vec3 normal; | false |
Other | mrdoob | three.js | d8552f349f65d79e2fcfe644ffb54328010ee949.json | introduce IncidentLight struct | src/renderers/shaders/ShaderChunk/common.glsl | @@ -82,9 +82,15 @@ vec3 linearToOutput( in vec3 a ) {
}
-vec3 BRDF_Lambert( const in vec3 lightColor, const in vec3 lightDir, const in vec3 normal, const in vec3 diffuseColor ) {
+struct IncidentLight {
+ vec3 color;
+ vec3 direction;
+};
- return lightColor * diffuseColor * ( saturate( dot( normal, lightDir ) ) );
+
+vec3 BRDF_Lambert( const in IncidentLight incidentLight, const in vec3 normal, const in vec3 diffuseColor ) {
+
+ return incidentLight.color * diffuseColor * ( saturate( dot( normal, incidentLight.direction ) ) );
// the above should be scaled by '' * RECIPROCAL_PI'
}
@@ -117,17 +123,17 @@ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
}
-vec3 BRDF_BlinnPhong( const in vec3 lightColor, const in vec3 lightDir, const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float shininess ) {
+vec3 BRDF_BlinnPhong( const in IncidentLight incidentLight, const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
+ vec3 halfDir = normalize( incidentLight.direction + viewDir );
float dotNH = saturate( dot( normal, halfDir ) );
- float dotLH = saturate( dot( lightDir, halfDir ) );
+ float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
vec3 F = F_Schlick( specularColor, dotLH );
float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );
float D = D_BlinnPhong( shininess, dotNH );
- return lightColor * F * ( G * D );
+ return incidentLight.color * F * ( G * D );
}
@@ -142,10 +148,10 @@ vec3 BRDF_BlinnPhong( const in vec3 lightColor, const in vec3 lightDir, const in
uniform DirectionalLight directionalLights[ MAX_DIR_LIGHTS ];
- void getDirLightDirect( const in DirectionalLight directionalLight, out vec3 lightColor, out vec3 lightDir ) {
+ void getDirLightDirect( const in DirectionalLight directionalLight, out IncidentLight incidentLight ) {
- lightDir = directionalLight.direction;
- lightColor = directionalLight.color;
+ incidentLight.color = directionalLight.color;
+ incidentLight.direction = directionalLight.direction;
}
@@ -162,15 +168,15 @@ vec3 BRDF_BlinnPhong( const in vec3 lightColor, const in vec3 lightDir, const in
uniform PointLight pointLights[ MAX_POINT_LIGHTS ];
- void getPointLightDirect( const in PointLight pointLight, const in vec3 position, out vec3 lightColor, out vec3 lightDir ) {
+ void getPointLightDirect( const in PointLight pointLight, const in vec3 position, out IncidentLight incidentLight ) {
vec3 lightPosition = pointLight.position;
vec3 lVector = lightPosition - position;
- lightDir = normalize( lVector );
+ incidentLight.direction = normalize( lVector );
- lightColor = pointLight.color;
- lightColor *= calcLightAttenuation( length( lVector ), pointLight.distance, pointLight.decay );
+ incidentLight.color = pointLight.color;
+ incidentLight.color *= calcLightAttenuation( length( lVector ), pointLight.distance, pointLight.decay );
}
@@ -190,18 +196,18 @@ vec3 BRDF_BlinnPhong( const in vec3 lightColor, const in vec3 lightDir, const in
uniform SpotLight spotLights[ MAX_SPOT_LIGHTS ];
- void getSpotLightDirect( const in SpotLight spotLight, const in vec3 position, out vec3 lightColor, out vec3 lightDir ) {
+ void getSpotLightDirect( const in SpotLight spotLight, const in vec3 position, out IncidentLight incidentLight ) {
vec3 lightPosition = spotLight.position;
vec3 lVector = lightPosition - position;
- lightDir = normalize( lVector );
+ incidentLight.direction = normalize( lVector );
- float spotEffect = dot( spotLight.direction, lightDir );
+ float spotEffect = dot( spotLight.direction, incidentLight.direction );
spotEffect = saturate( pow( saturate( spotEffect ), spotLight.exponent ) );
- lightColor = spotLight.color;
- lightColor *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) );
+ incidentLight.color = spotLight.color;
+ incidentLight.color *= ( spotEffect * calcLightAttenuation( length( lVector ), spotLight.distance, spotLight.decay ) );
}
@@ -218,15 +224,15 @@ vec3 BRDF_BlinnPhong( const in vec3 lightColor, const in vec3 lightDir, const in
uniform HemisphereLight hemisphereLights[ MAX_HEMI_LIGHTS ];
- void getHemisphereLightIndirect( const in HemisphereLight hemiLight, const in vec3 normal, out vec3 lightColor, out vec3 lightDir ) {
+ void getHemisphereLightIndirect( const in HemisphereLight hemiLight, const in vec3 normal, out IncidentLight incidentLight ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- lightColor = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
+ incidentLight.color = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- lightDir = normal;
+ incidentLight.direction = normal;
}
| true |
Other | mrdoob | three.js | d8552f349f65d79e2fcfe644ffb54328010ee949.json | introduce IncidentLight struct | src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl | @@ -13,14 +13,14 @@ vec3 diffuse = vec3( 1.0 );
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
- vec3 lightColor, lightDir;
- getPointLightDirect( pointLights[i], mvPosition.xyz, lightColor, lightDir );
+ IncidentLight incidentLight;
+ getPointLightDirect( pointLights[ i ], mvPosition.xyz, incidentLight );
- vLightFront += BRDF_Lambert( lightColor, lightDir, normal, diffuse );
+ vLightFront += BRDF_Lambert( incidentLight, normal, diffuse );
#ifdef DOUBLE_SIDED
- vLightBack += BRDF_Lambert( lightColor, lightDir, -normal, diffuse );
+ vLightBack += BRDF_Lambert( incidentLight, -normal, diffuse );
#endif
@@ -32,14 +32,14 @@ vec3 diffuse = vec3( 1.0 );
for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {
- vec3 lightColor, lightDir;
- getSpotLightDirect( spotLights[i], mvPosition.xyz, lightColor, lightDir );
+ IncidentLight incidentLight;
+ getSpotLightDirect( spotLights[ i ], mvPosition.xyz, incidentLight );
- vLightFront += BRDF_Lambert( lightColor, lightDir, normal, diffuse );
+ vLightFront += BRDF_Lambert( incidentLight, normal, diffuse );
#ifdef DOUBLE_SIDED
- vLightBack += BRDF_Lambert( lightColor, lightDir, -normal, diffuse );
+ vLightBack += BRDF_Lambert( incidentLight, -normal, diffuse );
#endif
@@ -51,14 +51,14 @@ vec3 diffuse = vec3( 1.0 );
for ( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
- vec3 lightColor, lightDir;
- getDirLightDirect( directionalLights[i], lightColor, lightDir );
+ IncidentLight incidentLight;
+ getDirLightDirect( directionalLights[ i ], incidentLight );
- vLightFront += BRDF_Lambert( lightColor, lightDir, normal, diffuse );
+ vLightFront += BRDF_Lambert( incidentLight, normal, diffuse );
#ifdef DOUBLE_SIDED
- vLightBack += BRDF_Lambert( lightColor, lightDir, -normal, diffuse );
+ vLightBack += BRDF_Lambert( incidentLight, -normal, diffuse );
#endif
@@ -70,16 +70,16 @@ vec3 diffuse = vec3( 1.0 );
for ( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
- vec3 lightColor, lightDir;
- getHemisphereLightIndirect( hemisphereLights[ i ], normal, lightColor, lightDir );
+ IncidentLight incidentLight;
+ getHemisphereLightIndirect( hemisphereLights[ i ], normal, incidentLight );
- vLightFront += BRDF_Lambert( lightColor, lightDir, normal, diffuse );
+ vLightFront += BRDF_Lambert( incidentLight, normal, diffuse );
#ifdef DOUBLE_SIDED
- getHemisphereLightIndirect( hemisphereLights[ i ], -normal, lightColor, lightDir );
+ incidentLight = getHemisphereLightIndirect( hemisphereLights[ i ], -normal );
- vLightBack += BRDF_Lambert( lightColor, lightDir, -normal, diffuse );
+ vLightBack += BRDF_Lambert( incidentLight, -normal, diffuse );
#endif
| true |
Other | mrdoob | three.js | d8552f349f65d79e2fcfe644ffb54328010ee949.json | introduce IncidentLight struct | src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl | @@ -17,14 +17,14 @@ vec3 diffuse = diffuseColor.rgb;
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
- vec3 lightColor, lightDir;
- getPointLightDirect( pointLights[i], -vViewPosition, lightColor, lightDir );
+ IncidentLight incidentLight;
+ getPointLightDirect( pointLights[ i ], -vViewPosition, incidentLight );
totalDirectReflectedDiffuse +=
- BRDF_Lambert( lightColor, lightDir, normal, diffuse );
+ BRDF_Lambert( incidentLight, normal, diffuse );
totalDirectReflectedSpecular +=
- BRDF_BlinnPhong( lightColor, lightDir, normal, viewDir, specular, shininess );
+ BRDF_BlinnPhong( incidentLight, normal, viewDir, specular, shininess );
}
@@ -34,14 +34,14 @@ vec3 diffuse = diffuseColor.rgb;
for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {
- vec3 lightColor, lightDir;
- getSpotLightDirect( spotLights[i], -vViewPosition, lightColor, lightDir );
+ IncidentLight incidentLight;
+ getSpotLightDirect( spotLights[ i ], -vViewPosition, incidentLight );
totalDirectReflectedDiffuse +=
- BRDF_Lambert( lightColor, lightDir, normal, diffuse );
+ BRDF_Lambert( incidentLight, normal, diffuse );
totalDirectReflectedSpecular +=
- BRDF_BlinnPhong( lightColor, lightDir, normal, viewDir, specular, shininess );
+ BRDF_BlinnPhong( incidentLight, normal, viewDir, specular, shininess );
}
@@ -51,14 +51,14 @@ vec3 diffuse = diffuseColor.rgb;
for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
- vec3 lightColor, lightDir;
- getDirLightDirect( directionalLights[i], lightColor, lightDir );
+ IncidentLight incidentLight;
+ getDirLightDirect( directionalLights[ i ], incidentLight );
totalDirectReflectedDiffuse +=
- BRDF_Lambert( lightColor, lightDir, normal, diffuse );
+ BRDF_Lambert( incidentLight, normal, diffuse );
totalDirectReflectedSpecular +=
- BRDF_BlinnPhong( lightColor, lightDir, normal, viewDir, specular, shininess );
+ BRDF_BlinnPhong( incidentLight, normal, viewDir, specular, shininess );
}
@@ -68,11 +68,11 @@ vec3 diffuse = diffuseColor.rgb;
for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
- vec3 lightColor, lightDir;
- getHemisphereLightIndirect( hemisphereLights[ i ], normal, lightColor, lightDir );
+ IncidentLight incidentLight;
+ getHemisphereLightIndirect( hemisphereLights[ i ], normal, incidentLight );
totalIndirectReflectedDiffuse +=
- BRDF_Lambert( lightColor, lightDir, normal, diffuse );
+ BRDF_Lambert( incidentLight, normal, diffuse );
}
| true |
Other | mrdoob | three.js | 89af64638fff208c8947f37deb2181c7d77b4933.json | adjust formatting of clampLength | src/math/Vector2.js | @@ -292,17 +292,17 @@ THREE.Vector2.prototype = {
clampLength: function ( min, max ) {
- var oldLength = this.length();
+ var oldLength = this.length();
- var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
+ var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
- if ( newLength !== oldLength ) {
+ if ( newLength !== oldLength ) {
- this.divideScalar( oldLength ).multiplyScalar( newLength );
+ this.divideScalar( oldLength ).multiplyScalar( newLength );
- }
+ }
- return this;
+ return this;
},
| true |
Other | mrdoob | three.js | 89af64638fff208c8947f37deb2181c7d77b4933.json | adjust formatting of clampLength | src/math/Vector3.js | @@ -522,17 +522,17 @@ THREE.Vector3.prototype = {
clampLength: function ( min, max ) {
- var oldLength = this.length();
+ var oldLength = this.length();
- var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
+ var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
- if ( newLength !== oldLength ) {
+ if ( newLength !== oldLength ) {
- this.divideScalar( oldLength ).multiplyScalar( newLength );
+ this.divideScalar( oldLength ).multiplyScalar( newLength );
- }
+ }
- return this;
+ return this;
},
| true |
Other | mrdoob | three.js | 525b9c672db3f051b6b47033a1c5e436efe1b4f2.json | remove closure of clampLength | src/math/Vector2.js | @@ -290,15 +290,11 @@ THREE.Vector2.prototype = {
}(),
- clampLength: function () {
+ clampLength: function ( min, max ) {
- var oldLength, newLength;
+ var oldLength = this.length();
- return function clampLength( min, max ) {
-
- oldLength = this.length();
-
- newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
+ var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
if ( newLength !== oldLength ) {
@@ -308,9 +304,7 @@ THREE.Vector2.prototype = {
return this;
- };
-
- }(),
+ },
floor: function () {
| true |
Other | mrdoob | three.js | 525b9c672db3f051b6b47033a1c5e436efe1b4f2.json | remove closure of clampLength | src/math/Vector3.js | @@ -520,15 +520,11 @@ THREE.Vector3.prototype = {
}(),
- clampLength: function () {
+ clampLength: function ( min, max ) {
- var oldLength, newLength;
+ var oldLength = this.length();
- return function clampLength( min, max ) {
-
- oldLength = this.length();
-
- newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
+ var newLength = ( oldLength < min ) ? min : ( ( oldLength > max ) ? max : oldLength );
if ( newLength !== oldLength ) {
@@ -538,9 +534,7 @@ THREE.Vector3.prototype = {
return this;
- };
-
- }(),
+ },
floor: function () {
| true |
Other | mrdoob | three.js | 2125b9b995d7bbfad829c204a293930db2a9c96a.json | Move `vertices` outside of the faces loop | examples/js/exporters/OBJExporter.js | @@ -114,13 +114,13 @@ THREE.OBJExporter.prototype = {
}
}
-
+
// faces
+ var indices = [];
for ( var i = 0, j = 1, l = faces.length; i < l; i ++, j += 3 ) {
var face = faces[ i ];
- var indices = [];
for ( var m = 0; m < 3; m ++ ) {
| false |
Other | mrdoob | three.js | 349d5056fc008ba5938169c542757a919a3fb5db.json | Pass world units to OrthographicCamera constructor | examples/webgl_camera.html | @@ -48,12 +48,14 @@
var SCREEN_WIDTH = window.innerWidth;
var SCREEN_HEIGHT = window.innerHeight;
+ var aspect = SCREEN_WIDTH / SCREEN_HEIGHT;
var container, stats;
var camera, scene, renderer, mesh;
var cameraRig, activeCamera, activeHelper;
var cameraPerspective, cameraOrtho;
var cameraPerspectiveHelper, cameraOrthoHelper;
+ var frustumSize = 600;
init();
animate();
@@ -67,17 +69,16 @@
//
- camera = new THREE.PerspectiveCamera( 50, 0.5 * SCREEN_WIDTH / SCREEN_HEIGHT, 1, 10000 );
+ camera = new THREE.PerspectiveCamera( 50, 0.5 * aspect, 1, 10000 );
camera.position.z = 2500;
- cameraPerspective = new THREE.PerspectiveCamera( 50, 0.5 * SCREEN_WIDTH / SCREEN_HEIGHT, 150, 1000 );
+ cameraPerspective = new THREE.PerspectiveCamera( 50, 0.5 * aspect, 150, 1000 );
cameraPerspectiveHelper = new THREE.CameraHelper( cameraPerspective );
scene.add( cameraPerspectiveHelper );
//
-
- cameraOrtho = new THREE.OrthographicCamera( 0.5 * SCREEN_WIDTH / - 2, 0.5 * SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, 150, 1000 );
+ cameraOrtho = new THREE.OrthographicCamera( 0.5 * frustumSize * aspect / - 2, 0.5 * frustumSize * aspect / 2, frustumSize / 2, frustumSize / - 2, 150, 1000 );
cameraOrthoHelper = new THREE.CameraHelper( cameraOrtho );
scene.add( cameraOrthoHelper );
@@ -193,19 +194,20 @@
SCREEN_WIDTH = window.innerWidth;
SCREEN_HEIGHT = window.innerHeight;
+ aspect = SCREEN_WIDTH / SCREEN_HEIGHT;
renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
- camera.aspect = 0.5 * SCREEN_WIDTH / SCREEN_HEIGHT;
+ camera.aspect = 0.5 * aspect;
camera.updateProjectionMatrix();
- cameraPerspective.aspect = 0.5 * SCREEN_WIDTH / SCREEN_HEIGHT;
+ cameraPerspective.aspect = 0.5 * aspect;
cameraPerspective.updateProjectionMatrix();
- cameraOrtho.left = - 0.5 * SCREEN_WIDTH / 2;
- cameraOrtho.right = 0.5 * SCREEN_WIDTH / 2;
- cameraOrtho.top = SCREEN_HEIGHT / 2;
- cameraOrtho.bottom = - SCREEN_HEIGHT / 2;
+ cameraOrtho.left = - 0.5 * frustumSize * aspect / 2;
+ cameraOrtho.right = 0.5 * frustumSize * aspect / 2;
+ cameraOrtho.top = frustumSize / 2;
+ cameraOrtho.bottom = - frustumSize / 2;
cameraOrtho.updateProjectionMatrix();
} | false |
Other | mrdoob | three.js | 9197b1b929847cb9e8148612693220603a9f8832.json | remove console in matrix4 | test/unit/math/Matrix4.js | @@ -167,7 +167,7 @@ test( "getInverse", function() {
b.getInverse( a, false );
ok( matrixEquals4( b, new THREE.Matrix4() ), "Passed!" );
- try {
+ try {
b.getInverse( c, true );
ok( false, "Passed!" ); // should never get here.
}
@@ -225,8 +225,7 @@ test( "makeBasis/extractBasis", function() {
b.extractBasis( outBasis[0], outBasis[1], outBasis[2] );
// check what goes in, is what comes out.
for( var j = 0; j < outBasis.length; j ++ ) {
- console.log( outBasis[j], testBasis[j] );
- ok( outBasis[j].equals( testBasis[j] ), "Passed!" );
+ ok( outBasis[j].equals( testBasis[j] ), "Passed!" );
}
// get the basis out the hard war
@@ -236,9 +235,9 @@ test( "makeBasis/extractBasis", function() {
}
// did the multiply method of basis extraction work?
for( var j = 0; j < outBasis.length; j ++ ) {
- ok( outBasis[j].equals( testBasis[j] ), "Passed!" );
+ ok( outBasis[j].equals( testBasis[j] ), "Passed!" );
}
- }
+ }
});
test( "transpose", function() {
@@ -248,9 +247,9 @@ test( "transpose", function() {
b = new THREE.Matrix4().set( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
var c = b.clone().transpose();
- ok( ! matrixEquals4( b, c ), "Passed!" );
+ ok( ! matrixEquals4( b, c ), "Passed!" );
c.transpose();
- ok( matrixEquals4( b, c ), "Passed!" );
+ ok( matrixEquals4( b, c ), "Passed!" );
});
test( "clone", function() {
@@ -313,7 +312,7 @@ test( "compose/decompose", function() {
m.decompose( t2, r2, s2 );
var m2 = new THREE.Matrix4().compose( t2, r2, s2 );
-
+
var matrixIsSame = matrixEquals4( m, m2 );
/* debug code
if( ! matrixIsSame ) {
@@ -326,4 +325,4 @@ test( "compose/decompose", function() {
}
}
}
-});
\ No newline at end of file
+}); | false |
Other | mrdoob | three.js | 72f72f4dc9c693305e29d5692dfe9ffeed6b5495.json | remove console in quaternion | test/unit/math/Quaternion.js | @@ -334,9 +334,6 @@ function slerpTestSkeleton( doSlerp, maxError ) {
result = doSlerp( [ 0, D, 0, D ], [ 0, -D, 0, D ], 0.5 );
ok( result.equals( 0, 0, 0, 1 ), "W-Unit from diagonals" );
ok( isNormal( result ), "Approximately normal (W-Unit)" );
-
- console.log( "maxNormError", maxNormError );
-
}
| false |
Other | mrdoob | three.js | 24f427a54b5dd312978c1e75cdd4262e076159c4.json | remove console in euler | test/unit/math/Euler.js | @@ -7,7 +7,7 @@ module( "Euler" );
var eulerZero = new THREE.Euler( 0, 0, 0, "XYZ" );
var eulerAxyz = new THREE.Euler( 1, 0, 0, "XYZ" );
var eulerAzyx = new THREE.Euler( 0, 1, 0, "ZYX" );
-
+
var matrixEquals4 = function( a, b, tolerance ) {
tolerance = tolerance || 0.0001;
if( a.elements.length != b.elements.length ) {
@@ -24,14 +24,14 @@ var matrixEquals4 = function( a, b, tolerance ) {
var eulerEquals = function( a, b, tolerance ) {
tolerance = tolerance || 0.0001;
- var diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z );
+ var diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z );
return ( diff < tolerance );
};
var quatEquals = function( a, b, tolerance ) {
tolerance = tolerance || 0.0001;
- var diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z ) + Math.abs( a.w - b.w );
+ var diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z ) + Math.abs( a.w - b.w );
return ( diff < tolerance );
};
@@ -66,11 +66,9 @@ test( "set/setFromVector3/toVector3", function() {
var vec = new THREE.Vector3( 0, 1, 0 );
var b = new THREE.Euler().setFromVector3( vec, "ZYX" );
- console.log( a, b );
ok( a.equals( b ), "Passed!" );
var c = b.toVector3();
- console.log( c, vec );
ok( c.equals( vec ), "Passed!" );
});
@@ -82,7 +80,7 @@ test( "Quaternion.setFromEuler/Euler.fromQuaternion", function() {
var v2 = new THREE.Euler().setFromQuaternion( q, v.order );
var q2 = new THREE.Quaternion().setFromEuler( v2 );
- ok( eulerEquals( q, q2 ), "Passed!" );
+ ok( eulerEquals( q, q2 ), "Passed!" );
}
});
@@ -95,7 +93,7 @@ test( "Matrix4.setFromEuler/Euler.fromRotationMatrix", function() {
var v2 = new THREE.Euler().setFromRotationMatrix( m, v.order );
var m2 = new THREE.Matrix4().makeRotationFromEuler( v2 );
- ok( matrixEquals4( m, m2, 0.0001 ), "Passed!" );
+ ok( matrixEquals4( m, m2, 0.0001 ), "Passed!" );
}
});
@@ -105,13 +103,13 @@ test( "reorder", function() {
var v = testValues[i];
var q = new THREE.Quaternion().setFromEuler( v );
- v.reorder( 'YZX' );
+ v.reorder( 'YZX' );
var q2 = new THREE.Quaternion().setFromEuler( v );
- ok( quatEquals( q, q2 ), "Passed!" );
+ ok( quatEquals( q, q2 ), "Passed!" );
v.reorder( 'ZXY' );
var q3 = new THREE.Quaternion().setFromEuler( v );
- ok( quatEquals( q, q3 ), "Passed!" );
+ ok( quatEquals( q, q3 ), "Passed!" );
}
});
@@ -133,4 +131,4 @@ test( "gimbalLocalQuat", function() {
// the results here are different
ok( eulerEquals( eViaQ1, eViaMViaQ1 ), "Passed!" ); // this result is correct
-});
\ No newline at end of file
+}); | false |
Other | mrdoob | three.js | d6fbddeed3b9265283bbcd51aedfe140bbc1b5c5.json | remove unused test | test/unit/core/BufferGeometry.js | @@ -184,8 +184,6 @@ test( "computeBoundingBox", function() {
ok( bb.min.x === bb.max.x && bb.min.y === bb.max.y && bb.min.z === bb.max.z, "since there is only one vertex, max and min are equal" );
ok( bb.min.x === -1 && bb.min.y === -1 && bb.min.z === -1, "since there is only one vertex, min and max are this vertex" );
-
- bb = getBBForVertices( [-1] );
});
test( "computeBoundingSphere", function() { | false |
Other | mrdoob | three.js | a71785d0d3db2b2d86cb0f6a68a4d7a832382c2c.json | use BufferAttribute as mock to supress warnings | test/unit/core/InstancedBufferGeometry.js | @@ -20,16 +20,16 @@ test( "copy", function() {
var instanceMock1 = {};
var instanceMock2 = {};
var indexMock = createClonableMock();
- var attributeMock1 = {};
- var attributeMock2 = {};
+ var defaultAttribute1 = new THREE.BufferAttribute([1]);
+ var defaultAttribute2 = new THREE.BufferAttribute([2]);
var instance = new THREE.InstancedBufferGeometry();
instance.addGroup( 0, 10, instanceMock1 );
instance.addGroup( 10, 5, instanceMock2 );
instance.setIndex( indexMock );
- instance.addAttribute( 'attributeMock1', attributeMock1 );
- instance.addAttribute( 'attributeMock2', attributeMock2 );
+ instance.addAttribute( 'defaultAttribute1', defaultAttribute1 );
+ instance.addAttribute( 'defaultAttribute2', defaultAttribute2 );
var copiedInstance = instance.copy( instance );
@@ -38,10 +38,10 @@ test( "copy", function() {
ok( copiedInstance.index === indexMock, "index was copied" );
ok( copiedInstance.index.callCount === 1, "index.clone was called once" );
- ok( copiedInstance.attributes['attributeMock1'] instanceof THREE.BufferAttribute, "attribute was created" );
+ ok( copiedInstance.attributes['defaultAttribute1'] instanceof THREE.BufferAttribute, "attribute was created" );
// the given attribute mock was passed to the array property of the created buffer attribute
- ok( copiedInstance.attributes['attributeMock1'].array === attributeMock1, "attribute was copied" );
- ok( copiedInstance.attributes['attributeMock2'].array === attributeMock2, "attribute was copied" );
+ ok( copiedInstance.attributes['defaultAttribute1'].array[0] === defaultAttribute1.array, "attribute was copied" );
+ ok( copiedInstance.attributes['defaultAttribute2'].array[0] === defaultAttribute2.array, "attribute was copied" );
ok( copiedInstance.groups[0].start === 0, "group was copied" );
ok( copiedInstance.groups[0].count === 10, "group was copied" ); | false |
Other | mrdoob | three.js | 7360ed9c5ec5cb45fd13701587ef87e92512c333.json | Simplify faces creation with for loop | examples/js/exporters/OBJExporter.js | @@ -15,6 +15,8 @@ THREE.OBJExporter.prototype = {
var indexVertex = 0;
var indexVertexUvs = 0;
var indexNormals = 0;
+
+ var faceVertexKeys = ["a", "b", "c"];
var parseMesh = function ( mesh ) {
@@ -112,18 +114,19 @@ THREE.OBJExporter.prototype = {
}
}
-
+
// faces
-
-
+
for ( var i = 0, j = 1, l = faces.length; i < l; i ++, j += 3 ) {
var face = faces[ i ];
output += 'f ';
- output += ( indexVertex + face.a + 1 ) + '/' + ( hasVertexUvs ? ( indexVertexUvs + j + 0 + 1 ) : '' ) + '/' + ( indexNormals + j + 0 + 1 ) + ' ';
- output += ( indexVertex + face.b + 1 ) + '/' + ( hasVertexUvs ? ( indexVertexUvs + j + 1 + 1 ) : '' ) + '/' + ( indexNormals + j + 1 + 1 ) + ' ';
- output += ( indexVertex + face.c + 1 ) + '/' + ( hasVertexUvs ? ( indexVertexUvs + j + 2 + 1 ) : '' ) + '/' + ( indexNormals + j + 2 + 1 ) + '\n';
+
+ for ( var m = 0; m < 3; m ++ ) {
+ output += ( indexVertex + face[ faceVertexKeys[ m ] ] + 1 ) + '/' + ( hasVertexUvs ? ( indexVertexUvs + j + m + 1 ) : '' ) + '/' + ( indexNormals + j + m + 1 );
+ output += m === 2 ? "\n" : " ";
+ }
}
| false |
Other | mrdoob | three.js | 0bfe511c9102c2cb8e6c2b334e210e017a2c8489.json | use texture loader to load textures in test | test/unit/extras/ImageUtils.test.js | @@ -17,33 +17,36 @@ QUnit.test( "test load handler", function( assert ) {
var done = assert.async();
- THREE.ImageUtils.loadTexture( good_url, undefined, function ( tex ) {
+ new THREE.TextureLoader().load(good_url, function ( tex ) {
assert.success( "load handler should be called" );
assert.ok( tex, "texture is defined" );
assert.ok( tex.image, "texture.image is defined" );
done();
- }, function () {
+ }, undefined, function () {
assert.fail( "error handler should not be called" );
done();
});
-
});
QUnit.test( "test error handler", function( assert ) {
var done = assert.async();
- THREE.ImageUtils.loadTexture( bad_url, undefined, function () {
+ new THREE.TextureLoader().load(bad_url, function () {
assert.fail( "load handler should not be called" );
done();
- }, function ( event ) {
+ },
+
+ undefined,
+
+ function ( event ) {
assert.success( "error handler should be called" );
assert.ok( event.type === 'error', "should have error event" );
@@ -59,12 +62,12 @@ QUnit.test( "test cached texture", function( assert ) {
var done = assert.async();
- var rtex1 = THREE.ImageUtils.loadTexture( good_url, undefined, function ( tex1 ) {
+ var rtex1 = new THREE.TextureLoader().load(good_url, function ( tex1 ) {
assert.ok( rtex1.image !== undefined, "texture 1 image is loaded" );
assert.equal( rtex1, tex1, "texture 1 callback is equal to return" );
- var rtex2 = THREE.ImageUtils.loadTexture( good_url, undefined, function ( tex2 ) {
+ var rtex2 = new THREE.TextureLoader().load(good_url, function ( tex2 ) {
assert.ok( rtex2 !== undefined, "cached callback is async" );
assert.ok( rtex2.image !== undefined, "texture 2 image is loaded" );
@@ -82,4 +85,3 @@ QUnit.test( "test cached texture", function( assert ) {
assert.ok( rtex1.image === undefined, "texture 1 image is not loaded" );
});
- | false |
Other | mrdoob | three.js | 6d5d6f8b74a23f3deffb25b0d014b495d6b36b13.json | use addgroup for adding draw calls in test | test/unit/geometry/EdgesGeometry.js | @@ -171,8 +171,7 @@ function addDrawCalls ( geometry ) {
var start = i * 3;
var count = 3;
- geometry.addDrawCall ( start, count, offset );
-
+ geometry.addGroup( start, count );
}
return geometry; | false |
Other | mrdoob | three.js | 0d760a26b368f0fc4e81834975862e4c66cf26cf.json | use setIndex for index attributes in test | test/unit/geometry/EdgesGeometry.js | @@ -152,7 +152,7 @@ function createIndexedBufferGeometry ( vertList, idxList ) {
vertices = vertices.subarray( 0, 3 * numVerts );
- geom.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ) );
+ geom.setIndex( new THREE.BufferAttribute( indices, 1 ) );
geom.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
geom.computeFaceNormals(); | false |
Other | mrdoob | three.js | eb1314e77ec307c56d834e323bb26e8157de73bf.json | Add camera controller to each element | examples/webgl_multiple_elements.html | @@ -74,6 +74,7 @@
</div>
<script src="../build/three.min.js"></script>
+ <script src="../examples/js/controls/OrbitControls.js"></script>
<script src="js/Detector.js"></script>
@@ -87,7 +88,7 @@
var canvas;
- var scenes = [], camera, renderer;
+ var scenes = [], renderer;
init();
animate();
@@ -96,41 +97,58 @@
canvas = document.getElementById( "c" );
- camera = new THREE.PerspectiveCamera( 50, 1, 0.1, 100 );
- camera.position.z = 2;
-
var geometries = [
new THREE.BoxGeometry( 1, 1, 1 ),
- new THREE.SphereGeometry( 0.5, 12, 12 ),
+ new THREE.SphereGeometry( 0.5, 12, 8 ),
new THREE.DodecahedronGeometry( 0.5 ),
new THREE.CylinderGeometry( 0.5, 0.5, 1, 12 ),
];
- var template = document.getElementById("template").text;
- var content = document.getElementById("content");
+ var template = document.getElementById( "template" ).text;
+ var content = document.getElementById( "content" );
- for ( var i = 0; i < 100; i ++ ) {
+ for ( var i = 0; i < 10; i ++ ) {
var scene = new THREE.Scene();
// make a list item
var element = document.createElement( "div" );
element.className = "list-item";
- element.innerHTML = template.replace('$', i + 1 );
+ element.innerHTML = template.replace( '$', i + 1 );
// Look up the element that represents the area
// we want to render the scene
- scene.element = element.querySelector(".scene");
+ scene.userData.element = element.querySelector( ".scene" );
content.appendChild( element );
+ var camera = new THREE.PerspectiveCamera( 50, 1, 1, 10 );
+ camera.position.z = 2;
+ scene.userData.camera = camera;
+
+ var controls = new THREE.OrbitControls( scene.userData.camera, scene.userData.element );
+ controls.minDistance = 2;
+ controls.maxDistance = 5;
+ controls.enablePan = false;
+ scene.userData.controls = controls;
+
// add one random mesh to each scene
var geometry = geometries[ geometries.length * Math.random() | 0 ];
- var material = new THREE.MeshLambertMaterial( { color: 0xffffff * Math.random() } );
+
+ var material = new THREE.MeshStandardMaterial( {
+
+ color: new THREE.Color().setHSL( Math.random(), 1, 0.75 ),
+ roughness: 0.5,
+ metalness: 0,
+ shading: THREE.FlatShading
+
+ } );
scene.add( new THREE.Mesh( geometry, material ) );
- light = new THREE.HemisphereLight( 0xffbbbb, 0x444488 );
- light.position.set( - 0.5, 0.8, 1 );
+ scene.add( new THREE.HemisphereLight( 0xaaaaaa, 0x444444 ) );
+
+ var light = new THREE.DirectionalLight( 0xffffff, 0.5 );
+ light.position.set( 1, 1, 1 );
scene.add( light );
scenes.push( scene );
@@ -139,7 +157,7 @@
renderer = new THREE.WebGLRenderer( { canvas: canvas, antialias: true } );
- renderer.setClearColor( 0xFFFFFF );
+ renderer.setClearColor( 0xffffff, 1 );
}
@@ -167,27 +185,27 @@
updateSize();
- renderer.setClearColor( 0xFFFFFF );
- renderer.clear( true );
- renderer.setClearColor( 0xE0E0E0 );
+ renderer.setClearColor( 0xffffff );
+ renderer.clear();
+ renderer.setClearColor( 0xe0e0e0 );
renderer.enableScissorTest( true );
+
scenes.forEach( function( scene ) {
- // so something moves
- scene.children[0].rotation.x = Date.now() * 0.00111;
- scene.children[0].rotation.z = Date.now() * 0.001;
// get the element that is a place holder for where we want to
// draw the scene
- var element = scene.element;
+ var element = scene.userData.element;
// get its position relative to the page's viewport
var rect = element.getBoundingClientRect();
// check if it's offscreen. If so skip it
if ( rect.bottom < 0 || rect.top > renderer.domElement.clientHeight ||
rect.right < 0 || rect.left > renderer.domElement.clientWidth ) {
- return; // it's off screen
+
+ return; // it's off screen
+
}
// set the viewport
@@ -196,13 +214,17 @@
var left = rect.left;
var bottom = renderer.domElement.clientHeight - rect.bottom;
- camera.aspect = width / height;
- camera.updateProjectionMatrix();
+ var camera = scene.userData.camera;
+
+ //scene.userData.controls.update();
+
renderer.setViewport( left, bottom, width, height );
renderer.setScissor( left, bottom, width, height );
+
renderer.render( scene, camera );
} );
+
renderer.enableScissorTest( false );
} | false |
Other | mrdoob | three.js | b89da830de87fabcecde1842f0d82e36b8a413c7.json | fix light json check | test/unit/qunit-utils.js | @@ -207,9 +207,11 @@ function checkLightClone( light ) {
function checkLightJsonWriting( light, json ) {
QUnit.assert.equal( json.metadata.version, "4.4", "check metadata version" );
- QUnit.assert.equalKey( light, json, 'type' );
- QUnit.assert.equalKey( light, json, 'uuid' );
- QUnit.assert.equal( json.id, undefined, "should not persist id" );
+
+ var object = json.object;
+ QUnit.assert.equalKey( light, object, 'type' );
+ QUnit.assert.equalKey( light, object, 'uuid' );
+ QUnit.assert.equal( object.id, undefined, "should not persist id" );
}
@@ -227,7 +229,7 @@ function checkLightJsonReading( json, light ) {
function checkLightJsonRoundtrip( light ) {
var json = light.toJSON();
- checkLightJsonWriting( light, json.object );
+ checkLightJsonWriting( light, json );
checkLightJsonReading( json, light );
} | false |
Other | mrdoob | three.js | f058021ec1272d2376677debeb11d711e01e6f61.json | Add test for CatmullRomCurve3 | test/unit/extras/curves/CatmullRomCurve3.js | @@ -0,0 +1,97 @@
+/**
+ * @author zz85 / http://joshuakoo.com
+ */
+
+module( "CatmullRomCurve3" );
+
+var positions = [
+ new THREE.Vector3( -60, -100, 60 ),
+ new THREE.Vector3( -60, 20, 60 ),
+ new THREE.Vector3( -60, 120, 60 ),
+ new THREE.Vector3( 60, 20, -60 ),
+ new THREE.Vector3( 60, -100, -60 )
+];
+
+test( "catmullrom check", function() {
+
+ var curve = new THREE.CatmullRomCurve3( positions );
+ curve.type = 'catmullrom';
+
+ var catmullPoints = [
+
+ new THREE.Vector3(-60,-100,60),
+ new THREE.Vector3(-60,-51.04,60),
+ new THREE.Vector3(-60,-2.7199999999999998,60),
+ new THREE.Vector3(-61.92,44.48,61.92),
+ new THREE.Vector3(-68.64,95.36000000000001,68.64),
+ new THREE.Vector3(-60,120,60),
+ new THREE.Vector3(-14.880000000000017,95.36000000000001,14.880000000000017),
+ new THREE.Vector3(41.75999999999997,44.48000000000003,-41.75999999999997),
+ new THREE.Vector3(67.68,-4.640000000000025,-67.68),
+ new THREE.Vector3(65.75999999999999,-59.68000000000002,-65.75999999999999),
+ new THREE.Vector3(60,-100,-60)
+
+ ];
+
+ var getPoints = curve.getPoints(10);
+ var error = vectorsAreEqual( getPoints , catmullPoints );
+ ok( getPoints.length == 11, 'getPoints should be equal.');
+ var desc = error ? ' ' + error : '';
+ ok( !error, 'Lists of Vectors3 should be equal.' + desc );
+
+});
+
+test( "chordal basic check", function() {
+
+ var curve = new THREE.CatmullRomCurve3( positions );
+
+ curve.type = 'chordal';
+
+ var chordalPoints = [
+ new THREE.Vector3(-60,-100,60),
+ new THREE.Vector3(-60,-52,60),
+ new THREE.Vector3(-60,-4,60),
+ new THREE.Vector3(-60.656435889910924,41.62455386421379,60.656435889910924),
+ new THREE.Vector3(-62.95396150459915,87.31049238896205,62.95396150459915),
+ new THREE.Vector3(-60,120,60),
+ new THREE.Vector3(-16.302568199486444,114.1500463116312,16.302568199486444),
+ new THREE.Vector3(42.998098664956586,54.017050116427455,-42.998098664956586),
+ new THREE.Vector3(63.542500175682434,-3.0571533975463856,-63.542500175682434),
+ new THREE.Vector3(62.65687513176183,-58.49286504815978,-62.65687513176183),
+ new THREE.Vector3(60.00000000000001,-100,-60.00000000000001)
+ ];
+
+ var getPoints = curve.getPoints(10);
+ var error = vectorsAreEqual( getPoints , chordalPoints );
+ ok( getPoints.length == 11, 'getPoints should be equal.');
+ var desc = error ? ' ' + error : '';
+ ok( !error, 'Lists of Vectors3 should be equal.' + desc );
+
+});
+
+test( "centripetal basic check", function() {
+
+ var curve = new THREE.CatmullRomCurve3( positions );
+ curve.type = 'centripetal';
+
+ var centripetalPoints = [
+ new THREE.Vector3(-60,-100,60),
+ new THREE.Vector3(-60,-51.47527724919028,60),
+ new THREE.Vector3(-60,-3.300369665587032,60),
+ new THREE.Vector3(-61.13836565863938,42.86306307781241,61.13836565863938),
+ new THREE.Vector3(-65.1226454638772,90.69743905511538,65.1226454638772),
+ new THREE.Vector3(-60,120,60),
+ new THREE.Vector3(-15.620412575504497,103.10790870179872,15.620412575504497),
+ new THREE.Vector3(42.384384731047874,48.35477686933143,-42.384384731047874),
+ new THREE.Vector3(65.25545512241153,-3.5662509660683424,-65.25545512241153),
+ new THREE.Vector3(63.94159134180865,-58.87468822455125,-63.94159134180865),
+ new THREE.Vector3(59.99999999999999,-100,-59.99999999999999),
+ ];
+
+ var getPoints = curve.getPoints(10);
+ var error = vectorsAreEqual( getPoints , centripetalPoints );
+ ok( getPoints.length == 11, 'getPoints should be equal.');
+ var desc = error ? ' ' + error : '';
+ ok( !error, 'Lists of Vectors3 should be equal.' + desc );
+
+});
\ No newline at end of file | true |
Other | mrdoob | three.js | f058021ec1272d2376677debeb11d711e01e6f61.json | Add test for CatmullRomCurve3 | test/unit/extras/curves/ClosedSplineCurve3.js | @@ -13,8 +13,6 @@ function vectorsAreEqual( check, that ) {
for ( var i = 0; i < check.length; i ++ ) {
var a = check[ i ], b = that[ i ];
- console.log( a.distanceToSquared( b ) )
-
if ( a.distanceToSquared( b ) > threshold ) {
return 'Vector differs at index ' + i +
@@ -53,6 +51,7 @@ test( "basic check", function() {
var getPoints = closedSpline.getPoints(10);
var error = vectorsAreEqual( getPoints , closedSplinePoints );
ok( getPoints.length == 11, 'getPoints should be equal.');
- ok( !error, 'Lists of Vectors3 should be equal.' + error );
+ var desc = error ? ' ' + error : '';
+ ok( !error, 'Lists of Vectors3 should be equal.' + desc );
});
\ No newline at end of file | true |
Other | mrdoob | three.js | f058021ec1272d2376677debeb11d711e01e6f61.json | Add test for CatmullRomCurve3 | test/unit/unittests_sources.html | @@ -36,6 +36,7 @@
<script src="../../src/extras/core/Curve.js"></script>
<script src="../../src/extras/CurveUtils.js"></script>
<script src="../../src/extras/curves/ClosedSplineCurve3.js"></script>
+ <script src="../../src/extras/curves/CatmullRomCurve3.js"></script>
<!-- add class-based unit tests below -->
@@ -60,6 +61,7 @@
<script src="math/Interpolant.js"></script>
<script src="extras/curves/ClosedSplineCurve3.js"></script>
+ <script src="extras/curves/CatmullRomCurve3.js"></script>
</body>
</html> | true |
Other | mrdoob | three.js | c6c305a39de6cebb5c0d5a5ca3a5481603556247.json | Add attributeDivisors to state | src/renderers/webgl/WebGLState.js | @@ -8,6 +8,7 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
var newAttributes = new Uint8Array( 16 );
var enabledAttributes = new Uint8Array( 16 );
+ var attributeDivisors = new Uint8Array( 16 );
var capabilities = {};
| false |
Other | mrdoob | three.js | 761f98dd5b79868d75468a7388a0cd83c74c4d09.json | add tests for camera | test/unit/cameras/Camera.js | @@ -5,8 +5,18 @@
module( "Camera" );
test( "lookAt", function() {
- var obj = new THREE.Camera();
- obj.lookAt(new THREE.Vector3(0, 1, -1));
+ var cam = new THREE.Camera();
+ cam.lookAt(new THREE.Vector3(0, 1, -1));
- ok( obj.rotation.x * (180 / Math.PI) === 45 , "x is equal" );
+ ok( cam.rotation.x * (180 / Math.PI) === 45 , "x is equal" );
+});
+
+test( "clone", function() {
+ var cam = new THREE.Camera();
+ cam.lookAt(new THREE.Vector3(1, 2, 3));
+
+ var clonedCam = cam.clone();
+
+ ok( cam.matrixWorldInverse.equals(clonedCam.matrixWorldInverse) , "matrixWorldInverse is equal" );
+ ok( cam.projectionMatrix.equals(clonedCam.projectionMatrix) , "projectionMatrix is equal" );
}); | false |
Other | mrdoob | three.js | 71daf959eaf3c85dbb9c2323b0c07fe8bca49a7c.json | Improve HemisphereLight illumination model | src/renderers/shaders/ShaderChunk/hemilight_fragment.glsl | @@ -0,0 +1,18 @@
+#if MAX_HEMI_LIGHTS > 0
+
+ for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
+
+ vec3 lightDir = hemisphereLightDirection[ i ];
+
+ float dotProduct = dot( normal, lightDir );
+
+ float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;
+
+ vec3 lightColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );
+
+ totalAmbientLight += lightColor;
+
+ }
+
+#endif
+ | true |
Other | mrdoob | three.js | 71daf959eaf3c85dbb9c2323b0c07fe8bca49a7c.json | Improve HemisphereLight illumination model | src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl | @@ -1,31 +1,3 @@
-#ifndef FLAT_SHADED
-
- vec3 normal = normalize( vNormal );
-
- #ifdef DOUBLE_SIDED
-
- normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );
-
- #endif
-
-#else
-
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
-
-#endif
-
-#ifdef USE_NORMALMAP
-
- normal = perturbNormal2Arb( -vViewPosition, normal );
-
-#elif defined( USE_BUMPMAP )
-
- normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
-
-#endif
-
vec3 viewDir = normalize( vViewPosition );
vec3 totalDiffuseLight = vec3( 0.0 );
@@ -126,32 +98,6 @@ vec3 totalSpecularLight = vec3( 0.0 );
#endif
-#if MAX_HEMI_LIGHTS > 0
-
- for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
-
- vec3 lightDir = hemisphereLightDirection[ i ];
-
- // diffuse
-
- float dotProduct = dot( normal, lightDir );
-
- float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;
-
- vec3 lightColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );
-
- totalDiffuseLight += lightColor;
-
- // specular (sky term only)
-
- vec3 brdf = BRDF_BlinnPhong( specular, shininess, normal, lightDir, viewDir );
-
- totalSpecularLight += brdf * specularStrength * lightColor * max( dotProduct, 0.0 );
-
- }
-
-#endif
-
#ifdef METAL
outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + totalAmbientLight ) * specular + totalSpecularLight + totalEmissiveLight; | true |
Other | mrdoob | three.js | 71daf959eaf3c85dbb9c2323b0c07fe8bca49a7c.json | Improve HemisphereLight illumination model | src/renderers/shaders/ShaderChunk/normal_phong_fragment.glsl | @@ -0,0 +1,28 @@
+#ifndef FLAT_SHADED
+
+ vec3 normal = normalize( vNormal );
+
+ #ifdef DOUBLE_SIDED
+
+ normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );
+
+ #endif
+
+#else
+
+ vec3 fdx = dFdx( vViewPosition );
+ vec3 fdy = dFdy( vViewPosition );
+ vec3 normal = normalize( cross( fdx, fdy ) );
+
+#endif
+
+#ifdef USE_NORMALMAP
+
+ normal = perturbNormal2Arb( -vViewPosition, normal );
+
+#elif defined( USE_BUMPMAP )
+
+ normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
+
+#endif
+ | true |
Other | mrdoob | three.js | 71daf959eaf3c85dbb9c2323b0c07fe8bca49a7c.json | Improve HemisphereLight illumination model | src/renderers/shaders/ShaderLib.js | @@ -366,7 +366,9 @@ THREE.ShaderLib = {
THREE.ShaderChunk[ "alphamap_fragment" ],
THREE.ShaderChunk[ "alphatest_fragment" ],
THREE.ShaderChunk[ "specularmap_fragment" ],
+ THREE.ShaderChunk[ "normal_phong_fragment" ],
THREE.ShaderChunk[ "lightmap_fragment" ],
+ THREE.ShaderChunk[ "hemilight_fragment" ],
THREE.ShaderChunk[ "aomap_fragment" ],
THREE.ShaderChunk[ "emissivemap_fragment" ],
| true |
Other | mrdoob | three.js | 71daf959eaf3c85dbb9c2323b0c07fe8bca49a7c.json | Improve HemisphereLight illumination model | utils/build/includes/common.json | @@ -114,6 +114,7 @@
"src/renderers/shaders/ShaderChunk/envmap_vertex.glsl",
"src/renderers/shaders/ShaderChunk/fog_fragment.glsl",
"src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/hemilight_fragment.glsl",
"src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl",
"src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl",
"src/renderers/shaders/ShaderChunk/lights_lambert_pars_vertex.glsl",
@@ -134,6 +135,7 @@
"src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl",
"src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl",
"src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/normal_phong_fragment.glsl",
"src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl",
"src/renderers/shaders/ShaderChunk/project_vertex.glsl",
"src/renderers/shaders/ShaderChunk/shadowmap_fragment.glsl", | true |
Other | mrdoob | three.js | ef42280373467e7e0b5f600b84d73ac881a915d0.json | simplify AnimationMixer to prevent bugs. | src/animation/AnimationMixer.js | @@ -13,8 +13,7 @@ THREE.AnimationMixer = function( root ) {
this.time = 0;
this.timeScale = 1.0;
this.actions = [];
- this.propertyBindings = [];
- this.propertyBindingNamesToIndex = {};
+ this.propertyBindingMap = {};
};
@@ -38,20 +37,15 @@ THREE.AnimationMixer.prototype = {
var track = tracks[ i ];
- var j = this.getPropertyBindingIndex( root, track.name )
+ var propertyBindingKey = root.uuid + '-' + track.name;
+ var propertyBinding = this.propertyBindingMap[ propertyBindingKey ];
- var propertyBinding;
-
- if( j < 0 ) {
+ if( propertyBinding === undefined ) {
propertyBinding = new THREE.PropertyBinding( root, track.name );
- this.propertyBindings.push( propertyBinding );
- this.propertyBindingNamesToIndex[ root.uuid + '-' + track.name ] = this.propertyBindings.length - 1;
+ this.propertyBindingMap[ propertyBindingKey ] = propertyBinding;
}
- else {
- propertyBinding = this.propertyBindings[ j ];
- }
// push in the same order as the tracks.
action.propertyBindings.push( propertyBinding );
@@ -63,13 +57,6 @@ THREE.AnimationMixer.prototype = {
},
- getPropertyBindingIndex: function( rootNode, trackName ) {
-
- var index = this.propertyBindingNamesToIndex[ rootNode.uuid + '-' + trackName ];
- return ( index !== undefined ) ? index : -1;
-
- },
-
removeAllActions: function() {
for( var i = 0; i < this.actions.length; i ++ ) {
@@ -79,15 +66,14 @@ THREE.AnimationMixer.prototype = {
}
// unbind all property bindings
- for( var i = 0; i < this.propertyBindings.length; i ++ ) {
+ for( var properyBindingKey in this.propertyBindingMap ) {
- this.propertyBindings[i].unbind();
+ this.propertyBindingMap[ properyBindingKey ].unbind();
}
this.actions = [];
- this.propertyBindings = [];
- this.propertyBindingNamesToIndex = {};
+ this.propertyBindingMap = {};
return this;
@@ -112,16 +98,17 @@ THREE.AnimationMixer.prototype = {
for( var i = 0; i < tracks.length; i ++ ) {
var track = tracks[ i ];
- var propertyBindingIndex = this.getPropertyBindingIndex( root, track.name );
- var propertyBinding = this.propertyBindings[ propertyBindingIndex ];
+ var propertyBindingKey = root.uuid + '-' + track.name;
+ var propertyBinding = this.propertyBindingMap[ propertyBindingKey ];
+
propertyBinding.referenceCount -= 1;
if( propertyBinding.referenceCount <= 0 ) {
propertyBinding.unbind();
- this.propertyBindings.splice( this.propertyBindings.indexOf( propertyBinding ), 1 );
+ delete this.propertyBindingMap[ propertyBindingKey ];
}
}
@@ -239,9 +226,9 @@ THREE.AnimationMixer.prototype = {
}
// apply to nodes
- for ( var i = 0; i < this.propertyBindings.length; i ++ ) {
+ for( var propertyBindingKey in this.propertyBindingMap ) {
- this.propertyBindings[ i ].apply();
+ this.propertyBindingMap[ propertyBindingKey ].apply();
}
| false |
Other | mrdoob | three.js | 63414e3323ee994ca410bf629d5303f3dd3d2846.json | remove debug comment. | examples/js/BlendCharacter.js | @@ -22,9 +22,7 @@ THREE.BlendCharacter = function () {
scope.mixer = new THREE.AnimationMixer( scope );
- // Create the animations
- console.log( geometry );
-
+ // Create the animations
for ( var i = 0; i < geometry.clips.length; ++ i ) {
var animName = geometry.clips[ i ].name; | false |
Other | mrdoob | three.js | 94478be299e4f98e923bae54ed0233c3463b79e7.json | simplify Action propertyBinding caches. | src/animation/AnimationAction.js | @@ -21,7 +21,7 @@ THREE.AnimationAction = function ( clip, startTime, timeScale, weight, loop ) {
this.actionTime = - this.startTime;
this.clipTime = 0;
- this.propertyBindingIndices = [];
+ this.propertyBindings = [];
};
/* | true |
Other | mrdoob | three.js | 94478be299e4f98e923bae54ed0233c3463b79e7.json | simplify Action propertyBinding caches. | src/animation/AnimationMixer.js | @@ -52,14 +52,15 @@ THREE.AnimationMixer.prototype = {
else {
propertyBinding = this.propertyBindings[ j ];
}
+
+ // push in the same order as the tracks.
+ action.propertyBindings.push( propertyBinding );
// track usages of shared property bindings, because if we leave too many around, the mixer can get slow
propertyBinding.referenceCount += 1;
}
- this.propertyBindingIndicesDirty = true;
-
},
getPropertyBindingIndex: function( rootNode, trackName ) {
@@ -69,33 +70,6 @@ THREE.AnimationMixer.prototype = {
},
- updatePropertyBindingIndices: function() {
-
- if( this.propertyBindingIndicesDirty ) {
-
- for( var i = 0; i < this.actions.length; i++ ) {
-
- var action = this.actions[i];
-
- var root = action.localRoot || this.root;
-
- var propertyBindingIndices = [];
-
- for( var j = 0; j < action.clip.tracks.length; j ++ ) {
-
- var trackName = action.clip.tracks[j].name;
- propertyBindingIndices.push( this.getPropertyBindingIndex( root, trackName ) );
-
- }
-
- action.propertyBindingIndices = propertyBindingIndices;
- }
-
- this.propertyBindingIndicesDirty = false;
-
- }
- },
-
removeAllActions: function() {
for( var i = 0; i < this.actions.length; i ++ ) {
@@ -152,9 +126,6 @@ THREE.AnimationMixer.prototype = {
}
}
-
- this.propertyBindingIndicesDirty = true;
-
return this;
},
@@ -241,8 +212,6 @@ THREE.AnimationMixer.prototype = {
update: function( deltaTime ) {
- this.updatePropertyBindingIndices();
-
var mixerDeltaTime = deltaTime * this.timeScale;
this.time += mixerDeltaTime;
@@ -263,7 +232,7 @@ THREE.AnimationMixer.prototype = {
var name = action.clip.tracks[j].name;
- this.propertyBindings[ action.propertyBindingIndices[ j ] ].accumulate( actionResults[j], weight );
+ action.propertyBindings[ j ].accumulate( actionResults[j], weight );
}
| true |
Other | mrdoob | three.js | 281f51051c30a1d9ceb6cc120a9bf0e695d1a724.json | avoid clones while interpolating values. | src/animation/AnimationUtils.js | @@ -19,6 +19,19 @@
},
+ clone: function( exemplarValue ) {
+
+ var typeName = typeof exemplarValue;
+ if( typeName === "object" ) {
+ if( exemplarValue.clone ) {
+ return exemplarValue.clone();
+ }
+ console.error( "can not figure out how to copy exemplarValue", exemplarValue );
+ }
+
+ return exemplarValue;
+
+ },
lerp: function( a, b, alpha, interTrack ) {
@@ -41,15 +54,15 @@
return function( a, b, alpha ) {
//console.log( a, b );
- return a.clone().lerp( b, alpha );
+ return a.lerp( b, alpha );
}
}
if( exemplarValue.slerp ) {
return function( a, b, alpha ) {
//console.log( a, b );
- return a.clone().slerp( b, alpha );
+ return a.slerp( b, alpha );
}
} | true |
Other | mrdoob | three.js | 281f51051c30a1d9ceb6cc120a9bf0e695d1a724.json | avoid clones while interpolating values. | src/animation/KeyframeTrack.js | @@ -11,7 +11,11 @@
THREE.KeyframeTrack = function ( name, keys ) {
this.name = name;
- this.keys = keys || []; // time in seconds, value as value
+ this.keys = keys; // time in seconds, value as value
+
+ // local cache of value type to avoid allocations during runtime.
+ this.result = THREE.AnimationUtils.clone( this.keys[0].value );
+ //console.log( 'constructor result', this.result )
this.sort();
this.validate();
@@ -22,6 +26,8 @@ THREE.KeyframeTrack.prototype = {
constructor: THREE.KeyframeTrack,
+ // TODO: this is a straight forward linear search for the key that corresponds to this time, this
+ // should be optimized.
getAt: function( time ) {
//console.log( 'KeyframeTrack[' + this.name + '].getAt( ' + time + ' )' );
@@ -32,28 +38,39 @@ THREE.KeyframeTrack.prototype = {
if( this.keys[0].time >= time ) {
//console.log( ' before: ' + this.keys[0].value );
- return this.keys[0].value;
+ this.setResult( this.keys[0].value );
+
+ //console.log( 'first result', this.result )
+
+ return this.result;
}
// past the end of the track, return the last key value
if( this.keys[ this.keys.length - 1 ].time <= time ) {
//console.log( ' after: ' + this.keys[ this.keys.length - 1 ].value );
- return this.keys[ this.keys.length - 1 ].value;
+ this.setResult( this.keys[ this.keys.length - 1 ].value );
+
+ //console.log( 'last result', this.result )
+
+ return this.result;
}
// interpolate to the required time
+ // TODO: Optimize this better than a linear search for each key.
for( var i = 1; i < this.keys.length; i ++ ) {
if( time <= this.keys[ i ].time ) {
// linear interpolation to start with
var alpha = ( time - this.keys[ i - 1 ].time ) / ( this.keys[ i ].time - this.keys[ i - 1 ].time );
- var interpolatedValue = this.lerp( this.keys[ i - 1 ].value, this.keys[ i ].value, alpha );
+ this.setResult( this.keys[ i - 1 ].value );
+ this.result = this.lerp( this.result, this.keys[ i ].value, alpha );
+ //console.log( 'lerp result', this.result )
/*console.log( ' interpolated: ', {
value: interpolatedValue,
alpha: alpha,
@@ -63,14 +80,22 @@ THREE.KeyframeTrack.prototype = {
value1: this.keys[ i ].value
} );*/
- return interpolatedValue;
+ return this.result;
}
}
throw new Error( "should never get here." );
},
+ setResult: function( value ) {
+ if( this.result.copy ) {
+ this.result.copy( value );
+ }
+ else {
+ this.result = value;
+ }
+ },
// memoization of the lerp function for speed.
// NOTE: Do not optimize as a prototype initialization closure, as value0 will be different on a per class basis. | true |
Other | mrdoob | three.js | 281f51051c30a1d9ceb6cc120a9bf0e695d1a724.json | avoid clones while interpolating values. | src/animation/PropertyBinding.js | @@ -46,15 +46,19 @@ THREE.PropertyBinding.prototype = {
if( this.cumulativeWeight === 0 ) {
- this.cumulativeValue = value;
+ if( this.cumulativeValue === null ) {
+ this.cumulativeValue = THREE.AnimationUtils.clone( value );
+ }
this.cumulativeWeight = weight;
-
+ //console.log( this );
+
}
else {
var lerpAlpha = weight / ( this.cumulativeWeight + weight );
this.cumulativeValue = lerp( this.cumulativeValue, value, lerpAlpha );
this.cumulativeWeight += weight;
+ //console.log( this );
}
} | true |
Other | mrdoob | three.js | 0dac7b9c20a73a2cd82495de5ff041de637ec2dd.json | fix copy material | src/materials/MeshPhongMaterial.js | @@ -112,59 +112,64 @@ THREE.MeshPhongMaterial = function ( parameters ) {
THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype );
THREE.MeshPhongMaterial.prototype.constructor = THREE.MeshPhongMaterial;
-THREE.MeshPhongMaterial.prototype.clone = function () {
+THREE.MeshPhongMaterial.prototype.copy = function ( source ) {
- var material = new THREE.MeshPhongMaterial();
+ THREE.Material.prototype.copy.call( this, source );
- THREE.Material.prototype.clone.call( this, material );
+ this.color.copy( source.color );
+ this.emissive.copy( source.emissive );
+ this.specular.copy( source.specular );
+ this.shininess = source.shininess;
- material.color.copy( this.color );
- material.emissive.copy( this.emissive );
- material.specular.copy( this.specular );
- material.shininess = this.shininess;
+ this.metal = source.metal;
- material.metal = this.metal;
+ this.map = source.map;
- material.map = this.map;
+ this.lightMap = source.lightMap;
+ this.lightMapIntensity = source.lightMapIntensity;
- material.lightMap = this.lightMap;
- material.lightMapIntensity = this.lightMapIntensity;
+ this.aoMap = source.aoMap;
+ this.aoMapIntensity = source.aoMapIntensity;
- material.aoMap = this.aoMap;
- material.aoMapIntensity = this.aoMapIntensity;
+ this.emissiveMap = source.emissiveMap;
- material.emissiveMap = this.emissiveMap;
+ this.bumpMap = source.bumpMap;
+ this.bumpScale = source.bumpScale;
- material.bumpMap = this.bumpMap;
- material.bumpScale = this.bumpScale;
+ this.normalMap = source.normalMap;
+ this.normalScale.copy( source.normalScale );
- material.normalMap = this.normalMap;
- material.normalScale.copy( this.normalScale );
+ this.specularMap = source.specularMap;
- material.specularMap = this.specularMap;
+ this.alphaMap = source.alphaMap;
- material.alphaMap = this.alphaMap;
+ this.envMap = source.envMap;
+ this.combine = source.combine;
+ this.reflectivity = source.reflectivity;
+ this.refractionRatio = source.refractionRatio;
- material.envMap = this.envMap;
- material.combine = this.combine;
- material.reflectivity = this.reflectivity;
- material.refractionRatio = this.refractionRatio;
+ this.fog = source.fog;
- material.fog = this.fog;
+ this.shading = source.shading;
- material.shading = this.shading;
+ this.wireframe = source.wireframe;
+ this.wireframeLinewidth = source.wireframeLinewidth;
+ this.wireframeLinecap = source.wireframeLinecap;
+ this.wireframeLinejoin = source.wireframeLinejoin;
- material.wireframe = this.wireframe;
- material.wireframeLinewidth = this.wireframeLinewidth;
- material.wireframeLinecap = this.wireframeLinecap;
- material.wireframeLinejoin = this.wireframeLinejoin;
+ this.vertexColors = source.vertexColors;
- material.vertexColors = this.vertexColors;
+ this.skinning = source.skinning;
+ this.morphTargets = source.morphTargets;
+ this.morphNormals = source.morphNormals;
- material.skinning = this.skinning;
- material.morphTargets = this.morphTargets;
- material.morphNormals = this.morphNormals;
+ return this;
+
+};
- return material;
+THREE.MeshPhongMaterial.prototype.clone = function () {
+
+ var material = new THREE.MeshPhongMaterial();
+ return material.copy( this );
}; | false |
Other | mrdoob | three.js | 2d0a1ee70acc22222bfaf08c7a502249b6ed9859.json | correct key value for num- | examples/misc_controls_transform.html | @@ -98,7 +98,7 @@
control.setSize( control.size + 0.1 );
break;
case 189:
- case 10: // -,_,num-
+ case 109: // -,_,num-
control.setSize( Math.max(control.size - 0.1, 0.1 ) );
break;
} | false |
Other | mrdoob | three.js | 1e219a674a7e9a8e001e5b643b1848a8b130b098.json | add support for binding to materials. | src/animation/PropertyBinding.js | @@ -15,6 +15,7 @@ THREE.PropertyBinding = function ( rootNode, trackName ) {
this.directoryName = parseResults.directoryName || null;
this.nodeName = parseResults.nodeName;
+ this.material = parseResults.material;
this.propertyName = parseResults.propertyName || null;
this.propertyArrayIndex = parseResults.propertyArrayIndex || -1;
@@ -30,14 +31,20 @@ THREE.PropertyBinding.prototype = {
console.log( "PropertyBinding.set( " + value + ")" );
+ var targetObject = this.node;
+
// ensure there is a value node
- if( ! this.node ) {
+ if( ! targetObject ) {
console.log( " trying to update node for track: " + this.trackName + " but it wasn't found." );
return;
}
+ if( this.material ) {
+ targetObject = targetObject.material;
+ }
+
// ensure there is a value property on the node
- var nodeProperty = this.node[ this.propertyName ];
+ var nodeProperty = targetObject[ this.propertyName ];
if( ! nodeProperty ) {
console.log( " trying to update property for track: " + this.nodeName + '.' + this.propertyName + " but it wasn't found.", this );
return;
@@ -56,17 +63,17 @@ THREE.PropertyBinding.prototype = {
// otherwise just set the property directly on the node (do not use nodeProperty as it may not be a reference object)
else {
console.log( ' update property ' + this.name + '.' + this.propertyName + ' via assignment.' );
- this.node[ this.propertyName ] = value;
+ targetObject[ this.propertyName ] = value;
}
// trigger node dirty
- if( this.node.needsUpdate !== undefined ) { // material
+ if( targetObject.needsUpdate !== undefined ) { // material
console.log( ' triggering material as dirty' );
this.node.needsUpdate = true;
}
- if( this.node.matrixWorldNeedsUpdate !== undefined ) { // node transform
+ if( targetObject.matrixWorldNeedsUpdate !== undefined ) { // node transform
console.log( ' triggering node as dirty' );
- this.node.matrixWorldNeedsUpdate = true;
+ targetObject.matrixWorldNeedsUpdate = true;
}
},
@@ -85,12 +92,14 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) {
// matches strings in the form of:
// nodeName.property
// nodeName.property[accessor]
+ // nodeName.material.property[accessor]
// uuid.property[accessor]
+ // uuid.material.property[accessor]
// parentName/nodeName.property
// parentName/parentName/nodeName.property[index]
// created and tested via https://regex101.com/#javascript
- var re = /^(([\w]+\/)*)([\w-]+)?(\.([\w]+)(\[([\w]+)\])?)?$/;
+ var re = /^(([\w]+\/)*)([\w-]+)?(\.material)?(\.([\w]+)(\[([\w]+)\])?)?$/;
var matches = re.exec(trackName);
if( ! matches ) {
@@ -104,8 +113,9 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) {
var results = {
directoryName: matches[0],
nodeName: matches[3], // allowed to be null, specified root node.
- propertyName: matches[5],
- propertySubElement: matches[7] // allowed to be null, specifies that the whole property is set.
+ material: ( matches[4] && matches[4].length > 0 ),
+ propertyName: matches[6],
+ propertySubElement: matches[8] // allowed to be null, specifies that the whole property is set.
};
console.log( "PropertyBinding.parseTrackName", trackName, results, matches ); | false |
Other | mrdoob | three.js | 633e071ae1d83db3c6ab390a7dad564990505b66.json | add new animation classes to common includes. | utils/build/includes/common.json | @@ -34,6 +34,12 @@
"src/core/DirectGeometry.js",
"src/core/BufferGeometry.js",
"src/core/InstancedBufferGeometry.js",
+ "src/animation/AnimationAction.js",
+ "src/animation/AnimationClip.js",
+ "src/animation/AnimationMixer.js",
+ "src/animation/AnimationUtils.js",
+ "src/animation/KeyframeTrack.js",
+ "src/animation/PropertyBinding.js",
"src/cameras/Camera.js",
"src/cameras/CubeCamera.js",
"src/cameras/OrthographicCamera.js", | false |
Other | mrdoob | three.js | 87b5f7e9bdc2de3b9e41e9f117d04f079bb73b7e.json | remove three-math from npm build, never used. | utils/npm/build.js | @@ -106,5 +106,4 @@ buildAll.stderr.on('data', function (data) {
buildAll.on( 'exit', function ( exitCode ) {
console.log( "exitCode: " + exitCode );
buildModule( "three" );
- buildModule( "three-math" );
}); | false |
Other | mrdoob | three.js | d0148758941fe5b20368ef22c53c197d7959cd9a.json | Set better defaults for DataTexture | examples/js/Ocean.js | @@ -248,8 +248,6 @@ THREE.Ocean.prototype.generateSeedPhaseTexture = function() {
}
this.pingPhaseTexture = new THREE.DataTexture( phaseArray, this.resolution, this.resolution, THREE.RGBAFormat );
- this.pingPhaseTexture.minFilter = THREE.NearestFilter;
- this.pingPhaseTexture.magFilter = THREE.NearestFilter;
this.pingPhaseTexture.wrapS = THREE.ClampToEdgeWrapping;
this.pingPhaseTexture.wrapT = THREE.ClampToEdgeWrapping;
this.pingPhaseTexture.type = THREE.FloatType; | true |
Other | mrdoob | three.js | d0148758941fe5b20368ef22c53c197d7959cd9a.json | Set better defaults for DataTexture | examples/js/SimulationRenderer.js | @@ -206,7 +206,6 @@ function SimulationRenderer( WIDTH, renderer ) {
texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.NearestFilter;
texture.needsUpdate = true;
- texture.flipY = false;
return texture;
@@ -232,7 +231,6 @@ function SimulationRenderer( WIDTH, renderer ) {
texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.NearestFilter;
texture.needsUpdate = true;
- texture.flipY = false;
return texture;
| true |
Other | mrdoob | three.js | d0148758941fe5b20368ef22c53c197d7959cd9a.json | Set better defaults for DataTexture | examples/js/postprocessing/GlitchPass.js | @@ -113,7 +113,6 @@ THREE.GlitchPass.prototype = {
texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.NearestFilter;
texture.needsUpdate = true;
- texture.flipY = false;
return texture;
} | true |
Other | mrdoob | three.js | d0148758941fe5b20368ef22c53c197d7959cd9a.json | Set better defaults for DataTexture | src/objects/Skeleton.js | @@ -38,10 +38,6 @@ THREE.Skeleton = function ( bones, boneInverses, useVertexTexture ) {
this.boneMatrices = new Float32Array( this.boneTextureWidth * this.boneTextureHeight * 4 ); // 4 floats per RGBA pixel
this.boneTexture = new THREE.DataTexture( this.boneMatrices, this.boneTextureWidth, this.boneTextureHeight, THREE.RGBAFormat, THREE.FloatType );
- this.boneTexture.minFilter = THREE.NearestFilter;
- this.boneTexture.magFilter = THREE.NearestFilter;
- this.boneTexture.generateMipmaps = false;
- this.boneTexture.flipY = false;
} else {
| true |
Other | mrdoob | three.js | d0148758941fe5b20368ef22c53c197d7959cd9a.json | Set better defaults for DataTexture | src/textures/DataTexture.js | @@ -3,10 +3,25 @@
*/
THREE.DataTexture = function ( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy ) {
+
+ if ( magFilter === undefined ) {
+
+ magFilter = THREE.NearestFilter;
+
+ }
+
+ if ( minFilter === undefined ) {
+
+ minFilter = THREE.NearestFilter;
+
+ }
THREE.Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.image = { data: data, width: width, height: height };
+
+ this.flipY = false;
+ this.generateMipmaps = false;
};
| true |
Other | mrdoob | three.js | 1cefeae8a1939f71f24c80e6e3017a9f1eda1a27.json | fix potential null reference. | src/loaders/ObjectLoader.js | @@ -627,7 +627,7 @@ THREE.ObjectLoader.prototype = {
}
- if( data.animations ) {
+ if( data.animations && data.animations.tracks ) {
var dataTracks = data.animations.tracks;
| false |
Other | mrdoob | three.js | dfde145893cc33b7b8a987de95b6250614a5f3e6.json | Add ellipse rotation angle to THREE.Path docs. | docs/api/extras/core/Path.html | @@ -1,123 +1,125 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
+<!DOCTYPE html>
+<html lang="en">
+ <head>
<meta charset="utf-8" />
- <base href="../../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- [page:CurvePath] →
-
- <h1>[name]</h1>
-
- <div class="desc">
- A 2d path representation, comprising of points, lines, and cubes, similar to the html5 2d canvas api.
- It extends [page:CurvePath].
- </div>
-
-
- <h2>Constructor</h2>
-
-
- <h3>[name]([page:Array points])</h3>
- <div>
- points -- array of Vector2
- </div>
- <div>
- Creates a Path from the points. The first vector defines the offset. After that the lines get defined.
- </div>
-
-
- <h2>Properties</h2>
-
-
- <h3>[property:array actions]</h3>
- <div>
- The possible actions that define the path.
- </div>
-
- <h2>Methods</h2>
-
- <h3>[method:null fromPoints]( [page:Array vector2s] )</h3>
- <div>
- Adds to the Path from the points. The first vector defines the offset. After that the lines get defined.
- </div>
-
- <h3>[method:null moveTo]( [page:Float x], [page:Float y] )</h3>
- <div>This moves the offset to x and y</div>
-
- <h3>[method:null lineTo]( [page:Float x], [page:Float y] )</h3>
- <div>This creates a line from the offset to X and Y and updates the offset to X and Y.</div>
-
- <h3>[method:null quadraticCurveTo]( [page:Float cpX], [page:Float cpY], [page:Float x], [page:Float y] )</h3>
- <div>This creates a quadratic curve from the offset to x and y with cpX and cpY as control point and updates the offset to x and y.</div>
-
- <h3>[method:null bezierCurveTo]( [page:Float cp1X], [page:Float cp1Y], [page:Float cp2X], [page:Float cp2Y], [page:Float x], [page:Float y] )</h3>
- <div>This creates a bezier curve from the last offset to x and y with cp1X, cp1Y and cp1X, cp1Y as control points and updates the offset to x and y.</div>
-
- <h3>[method:null splineThru] ( [page:Array points] ) </h3>
- <div>points - An array of [page:Vector2]s</div>
- <div>Connects a new [page:SplineCurve] onto the path.</div>
-
- <h3>[method:null arc]( [page:Float x], [page:Float y], [page:Float radius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )</h3>
- <div>
- x, y -- The center of the arc offset from the last call
- radius -- The radius of the arc
- startAngle -- The start angle in radians
- endAngle -- The end angle in radians
- clockwise -- Sweep the arc clockwise. Defaults to false
- </div>
- <div>Draw an arc offset from the last call</div>
-
- <h3>[method:null absarc]( [page:Float x], [page:Float y], [page:Float radius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )</h3>
- <div>
- x, y -- The absolute center of the arc
- radius -- The radius of the arc
- startAngle -- The start angle in radians
- endAngle -- The end angle in radians
- clockwise -- Sweep the arc clockwise. Defaults to false
- </div>
- <div>Draw an arc absolutely positioned</div>
-
- <h3>[method:null ellipse]( [page:Float x], [page:Float y], [page:Float xRadius], [page:Float yRadius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )</h3>
- <div>
- x, y -- The center of the ellipse offset from the last call
- xRadius -- The radius of the ellipse in the x axis
- yRadius -- The radius of the ellipse in the y axis
- startAngle -- The start angle in radians
- endAngle -- The end angle in radians
- clockwise -- Sweep the ellipse clockwise. Defaults to false
- </div>
- <div>Draw an ellipse offset from the last call</div>
-
- <h3>[method:null absellipse]( [page:Float x], [page:Float y], [page:Float xRadius], [page:Float yRadius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )</h3>
- <div>
- x, y -- The absolute center of the ellipse
- xRadius -- The radius of the ellipse in the x axis
- yRadius -- The radius of the ellipse in the y axis
- startAngle -- The start angle in radians
- endAngle -- The end angle in radians
- clockwise -- Sweep the ellipse clockwise. Defaults to false
- </div>
- <div>Draw an ellipse absolutely positioned</div>
-
- <h3>[method:Array toShapes]( [page:Boolean isCCW], [page:Boolean noHoles] )</h3>
- <div>
- isCCW -- Changes how solids and holes are generated<br/>
- noHoles -- Whether or not to generate holes
- </div>
- <div>
- Converts the Path into an array of Shapes. By default solid shapes are defined clockwise (CW) and holes are defined counterclockwise (CCW). If isCCW is set to true,
- then those are flipped. If the paramater noHoles is set to true then all paths are set as solid shapes and isCCW is ignored.
- <br/>
-
- </div>
-
-
- <h2>Source</h2>
-
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
-</html>
+ <base href="../../../" />
+ <script src="list.js"></script>
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:CurvePath] →
+
+ <h1>[name]</h1>
+
+ <div class="desc">
+ A 2d path representation, comprising of points, lines, and cubes, similar to the html5 2d canvas api.
+ It extends [page:CurvePath].
+ </div>
+
+
+ <h2>Constructor</h2>
+
+
+ <h3>[name]([page:Array points])</h3>
+ <div>
+ points -- array of Vector2
+ </div>
+ <div>
+ Creates a Path from the points. The first vector defines the offset. After that the lines get defined.
+ </div>
+
+
+ <h2>Properties</h2>
+
+
+ <h3>[property:array actions]</h3>
+ <div>
+ The possible actions that define the path.
+ </div>
+
+ <h2>Methods</h2>
+
+ <h3>[method:null fromPoints]( [page:Array vector2s] )</h3>
+ <div>
+ Adds to the Path from the points. The first vector defines the offset. After that the lines get defined.
+ </div>
+
+ <h3>[method:null moveTo]( [page:Float x], [page:Float y] )</h3>
+ <div>This moves the offset to x and y</div>
+
+ <h3>[method:null lineTo]( [page:Float x], [page:Float y] )</h3>
+ <div>This creates a line from the offset to X and Y and updates the offset to X and Y.</div>
+
+ <h3>[method:null quadraticCurveTo]( [page:Float cpX], [page:Float cpY], [page:Float x], [page:Float y] )</h3>
+ <div>This creates a quadratic curve from the offset to x and y with cpX and cpY as control point and updates the offset to x and y.</div>
+
+ <h3>[method:null bezierCurveTo]( [page:Float cp1X], [page:Float cp1Y], [page:Float cp2X], [page:Float cp2Y], [page:Float x], [page:Float y] )</h3>
+ <div>This creates a bezier curve from the last offset to x and y with cp1X, cp1Y and cp1X, cp1Y as control points and updates the offset to x and y.</div>
+
+ <h3>[method:null splineThru] ( [page:Array points] ) </h3>
+ <div>points - An array of [page:Vector2]s</div>
+ <div>Connects a new [page:SplineCurve] onto the path.</div>
+
+ <h3>[method:null arc]( [page:Float x], [page:Float y], [page:Float radius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )</h3>
+ <div>
+ x, y -- The center of the arc offset from the last call
+ radius -- The radius of the arc
+ startAngle -- The start angle in radians
+ endAngle -- The end angle in radians
+ clockwise -- Sweep the arc clockwise. Defaults to false
+ </div>
+ <div>Draw an arc offset from the last call</div>
+
+ <h3>[method:null absarc]( [page:Float x], [page:Float y], [page:Float radius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )</h3>
+ <div>
+ x, y -- The absolute center of the arc
+ radius -- The radius of the arc
+ startAngle -- The start angle in radians
+ endAngle -- The end angle in radians
+ clockwise -- Sweep the arc clockwise. Defaults to false
+ </div>
+ <div>Draw an arc absolutely positioned</div>
+
+ <h3>[method:null ellipse]( [page:Float x], [page:Float y], [page:Float xRadius], [page:Float yRadius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise], [page:Float rotation] )</h3>
+ <div>
+ x, y -- The center of the ellipse offset from the last call
+ xRadius -- The radius of the ellipse in the x axis
+ yRadius -- The radius of the ellipse in the y axis
+ startAngle -- The start angle in radians
+ endAngle -- The end angle in radians
+ clockwise -- Sweep the ellipse clockwise. Defaults to false
+ rotation -- The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, defaults to 0
+ </div>
+ <div>Draw an ellipse offset from the last call</div>
+
+ <h3>[method:null absellipse]( [page:Float x], [page:Float y], [page:Float xRadius], [page:Float yRadius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise], [page:Float rotation] )</h3>
+ <div>
+ x, y -- The absolute center of the ellipse
+ xRadius -- The radius of the ellipse in the x axis
+ yRadius -- The radius of the ellipse in the y axis
+ startAngle -- The start angle in radians
+ endAngle -- The end angle in radians
+ clockwise -- Sweep the ellipse clockwise. Defaults to false
+ rotation -- The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, defaults to 0
+ </div>
+ <div>Draw an ellipse absolutely positioned</div>
+
+ <h3>[method:Array toShapes]( [page:Boolean isCCW], [page:Boolean noHoles] )</h3>
+ <div>
+ isCCW -- Changes how solids and holes are generated<br/>
+ noHoles -- Whether or not to generate holes
+ </div>
+ <div>
+ Converts the Path into an array of Shapes. By default solid shapes are defined clockwise (CW) and holes are defined counterclockwise (CCW). If isCCW is set to true,
+ then those are flipped. If the paramater noHoles is set to true then all paths are set as solid shapes and isCCW is ignored.
+ <br/>
+
+ </div>
+
+
+ <h2>Source</h2>
+
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </body>
+</html>
| false |
Other | mrdoob | three.js | c2b42fd10002738f49004d40e017e57636d4c3a2.json | Add ellipse rotation (optional) to THREE.Path.
Adds an optional rotation parameter to THREE.Path.ellipse and THREE.Path.absellipse. | src/extras/core/Path.js | @@ -153,24 +153,24 @@ THREE.Path.prototype.arc = function ( aX, aY, aRadius,
};
THREE.Path.prototype.ellipse = function ( aX, aY, xRadius, yRadius,
- aStartAngle, aEndAngle, aClockwise ) {
+ aStartAngle, aEndAngle, aClockwise, aRotation ) {
var lastargs = this.actions[ this.actions.length - 1 ].args;
var x0 = lastargs[ lastargs.length - 2 ];
var y0 = lastargs[ lastargs.length - 1 ];
this.absellipse( aX + x0, aY + y0, xRadius, yRadius,
- aStartAngle, aEndAngle, aClockwise );
+ aStartAngle, aEndAngle, aClockwise, aRotation );
};
THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius,
- aStartAngle, aEndAngle, aClockwise ) {
+ aStartAngle, aEndAngle, aClockwise, aRotation ) {
var args = Array.prototype.slice.call( arguments );
var curve = new THREE.EllipseCurve( aX, aY, xRadius, yRadius,
- aStartAngle, aEndAngle, aClockwise );
+ aStartAngle, aEndAngle, aClockwise, aRotation );
this.curves.push( curve );
var lastPoint = curve.getPoint( 1 );
@@ -386,13 +386,22 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
xRadius = args[ 2 ],
yRadius = args[ 3 ],
aStartAngle = args[ 4 ], aEndAngle = args[ 5 ],
- aClockwise = !! args[ 6 ];
+ aClockwise = !! args[ 6 ],
+ aRotation = args[ 7 ] || 0;
var deltaAngle = aEndAngle - aStartAngle;
var angle;
var tdivisions = divisions * 2;
+ var cos, sin;
+ if ( aRotation ) {
+
+ cos = Math.cos( aRotation );
+ sin = Math.sin( aRotation );
+
+ }
+
for ( j = 1; j <= tdivisions; j ++ ) {
t = j / tdivisions;
@@ -408,6 +417,14 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
tx = aX + xRadius * Math.cos( angle );
ty = aY + yRadius * Math.sin( angle );
+ if ( aRotation ) {
+
+ // Rotate the point about the center of the ellipse.
+ tx = ( tx - aX ) * cos - ( ty - aY ) * sin + aX;
+ ty = ( tx - aX ) * sin + ( ty - aY ) * cos + aY;
+
+ }
+
//console.log('t', t, 'angle', angle, 'tx', tx, 'ty', ty);
points.push( new THREE.Vector2( tx, ty ) ); | false |
Other | mrdoob | three.js | e16a8b4a6b4e8595e00bbf2681f18f1d0d0d5d43.json | Add rotation angle to THREE.EllipseCurve docs. | docs/api/extras/curves/EllipseCurve.html | @@ -1,70 +1,73 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
+<!DOCTYPE html>
+<html lang="en">
+ <head>
<meta charset="utf-8" />
- <base href="../../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- [page:Curve] →
-
- <h1>[name]</h1>
-
- <div class="desc">Creates a 2d curve in the shape of an ellipse.</div>
-
- <h2>Example</h2>
-
-<code>
-var curve = new THREE.EllipseCurve(
- 0, 0, // ax, aY
- 10, 10, // xRadius, yRadius
- 0, 2 * Math.PI, // aStartAngle, aEndAngle
- false // aClockwise
-);
-
-var path = new THREE.Path( curve.getPoints( 50 ) );
-var geometry = path.createPointsGeometry( 50 );
-var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
-
-// Create the final Object3d to add to the scene
-var ellipse = new THREE.Line( geometry, material );
-</code>
-
- <h2>Constructor</h2>
-
-
- <h3>[name]( [page:Float aX], [page:Float aY], [page:Float xRadius], [page:Float yRadius], [page:Radians aStartAngle], [page:Radians aEndAngle], [page:Boolean aClockwise] )</h3>
- <div>
- aX – The X center of the ellipse<br/>
- aY – The Y center of the ellipse<br/>
- xRadius – The radius of the ellipse in the x direction<br/>
- yRadius – The radius of the ellipse in the y direction<br/>
- aStartAngle – The start angle of the curve in radians starting from the middle right side<br/>
- aEndAngle – The end angle of the curve in radians starting from the middle right side<br/>
- aClockwise – Whether the ellipse is clockwise<br/><br/>
-
- <strong>Note:</strong> When going clockwise it's best to set the start angle to (Math.PI * 2) and then work towards lower numbers.
- </div>
-
-
- <h2>Properties</h2>
-
- <h3>[property:Float aX]</h3>
- <h3>[property:Float aY]</h3>
- <h3>[property:Radians xRadius]</h3>
- <h3>[property:Radians yRadius]</h3>
- <h3>[property:Float aStartAngle]</h3>
- <h3>[property:Float aEndAngle]</h3>
- <h3>[property:Boolean aClockwise]</h3>
-
- <h2>Methods</h2>
-
- <h3>See [page:Curve] for inherited methods</h3>
-
- <h2>Source</h2>
-
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
-</html>
+ <base href="../../../" />
+ <script src="list.js"></script>
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Curve] →
+
+ <h1>[name]</h1>
+
+ <div class="desc">Creates a 2d curve in the shape of an ellipse.</div>
+
+ <h2>Example</h2>
+
+<code>
+var curve = new THREE.EllipseCurve(
+ 0, 0, // ax, aY
+ 10, 10, // xRadius, yRadius
+ 0, 2 * Math.PI, // aStartAngle, aEndAngle
+ false, // aClockwise
+ 0 // aRotation
+);
+
+var path = new THREE.Path( curve.getPoints( 50 ) );
+var geometry = path.createPointsGeometry( 50 );
+var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
+
+// Create the final Object3d to add to the scene
+var ellipse = new THREE.Line( geometry, material );
+</code>
+
+ <h2>Constructor</h2>
+
+
+ <h3>[name]( [page:Float aX], [page:Float aY], [page:Float xRadius], [page:Float yRadius], [page:Radians aStartAngle], [page:Radians aEndAngle], [page:Boolean aClockwise], [page:Radians aRotation] )</h3>
+ <div>
+ aX – The X center of the ellipse<br/>
+ aY – The Y center of the ellipse<br/>
+ xRadius – The radius of the ellipse in the x direction<br/>
+ yRadius – The radius of the ellipse in the y direction<br/>
+ aStartAngle – The start angle of the curve in radians starting from the middle right side<br/>
+ aEndAngle – The end angle of the curve in radians starting from the middle right side<br/>
+ aClockwise – Whether the ellipse is clockwise<br/>
+ aRotation – The rotation angle of the ellipse in radians, counterclockwise from the positive X axis (optional)<br/><br/>
+
+ <strong>Note:</strong> When going clockwise it's best to set the start angle to (Math.PI * 2) and then work towards lower numbers.
+ </div>
+
+
+ <h2>Properties</h2>
+
+ <h3>[property:Float aX]</h3>
+ <h3>[property:Float aY]</h3>
+ <h3>[property:Radians xRadius]</h3>
+ <h3>[property:Radians yRadius]</h3>
+ <h3>[property:Float aStartAngle]</h3>
+ <h3>[property:Float aEndAngle]</h3>
+ <h3>[property:Boolean aClockwise]</h3>
+ <h3>[property:Radians aRotation]</h3>
+
+ <h2>Methods</h2>
+
+ <h3>See [page:Curve] for inherited methods</h3>
+
+ <h2>Source</h2>
+
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </body>
+</html>
| false |
Other | mrdoob | three.js | 26e3f30e387fa5f8d512e45e7865cb82561637f2.json | Add rotation (optional) to THREE.EllipseCurve. | src/extras/curves/EllipseCurve.js | @@ -2,7 +2,7 @@
* Ellipse curve
**************************************************************/
-THREE.EllipseCurve = function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise ) {
+THREE.EllipseCurve = function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
this.aX = aX;
this.aY = aY;
@@ -14,6 +14,8 @@ THREE.EllipseCurve = function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle
this.aEndAngle = aEndAngle;
this.aClockwise = aClockwise;
+
+ this.aRotation = aRotation || 0;
};
@@ -39,11 +41,20 @@ THREE.EllipseCurve.prototype.getPoint = function ( t ) {
}
- var vector = new THREE.Vector2();
+ var x = this.aX + this.xRadius * Math.cos( angle );
+ var y = this.aY + this.yRadius * Math.sin( angle );
+
+ if ( this.aRotation ) {
+
+ var cos = Math.cos( this.aRotation );
+ var sin = Math.sin( this.aRotation );
- vector.x = this.aX + this.xRadius * Math.cos( angle );
- vector.y = this.aY + this.yRadius * Math.sin( angle );
+ // Rotate the point about the center of the ellipse.
+ x = ( x - this.aX ) * cos - ( y - this.aY ) * sin + this.aX;
+ y = ( x - this.aX ) * sin + ( y - this.aY ) * cos + this.aY;
+
+ }
- return vector;
+ return new THREE.Vector2( x, y );
}; | false |
Other | mrdoob | three.js | 6e44ac297047fa01382f66eb0cfebc0e3e8bd1c6.json | Add dispose() to WebGLRenderer | src/renderers/WebGLRenderer.js | @@ -183,17 +183,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- _canvas.addEventListener( 'webglcontextlost', function ( event ) {
-
- event.preventDefault();
-
- resetGLState();
- setDefaultGLState();
-
- objects.clear();
- properties.clear();
-
- }, false );
+ _canvas.addEventListener( 'webglcontextlost', onContextLost, false );
} catch ( error ) {
@@ -617,8 +607,26 @@ THREE.WebGLRenderer = function ( parameters ) {
this.resetGLState = resetGLState;
+ this.dispose = function() {
+
+ _canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
+
+ };
+
// Events
+ function onContextLost( event ) {
+
+ event.preventDefault();
+
+ resetGLState();
+ setDefaultGLState();
+
+ objects.clear();
+ properties.clear();
+
+ };
+
function onTextureDispose( event ) {
var texture = event.target; | false |
Other | mrdoob | three.js | e3604c6e538f138c05e2ca2051b44468ab10d58d.json | fix obvious bugs. | src/animation/AnimationMixer.js | @@ -13,8 +13,7 @@ THREE.AnimationMixer = function( root ) {
this.time = 0;
this.timeScale = 1.0;
this.actions = [];
- this.propertyBindings = {};
- this.propertyBindingsArray = [];
+ this.propertyBindings = [];
};
@@ -33,15 +32,20 @@ THREE.AnimationMixer.prototype = {
var track = tracks[ i ];
- var propertyBinding = this.propertyBindings[ track.name ];
+ var j = this.getPropertyBindingIndex( track.name )
- if( ! this.propertyBindings[ track.name ] ) {
+ var propertyBinding;
+
+ if( j < 0 ) {
propertyBinding = new THREE.PropertyBinding( this.root, track.name );
- this.propertyBindingsArray.push( propertyBinding );
+ this.propertyBindings.push( propertyBinding );
}
-
+ else {
+ propertyBinding = this.propertyBindings[ j ];
+ }
+
// track usages of shared property bindings, because if we leave too many around, the mixer can get slow
propertyBinding.referenceCount += 1;
@@ -92,7 +96,7 @@ THREE.AnimationMixer.prototype = {
}
// unbind all property bindings
- for( var i = 0; i < this.propertyBindingsArray.length; i ++ ) {
+ for( var i = 0; i < this.propertyBindings.length; i ++ ) {
this.propertyBindings[i].unbind();
| false |
Other | mrdoob | three.js | 8bfe403c00b09093bcf7082888696e371671a789.json | Add dispose method to all controls | examples/js/controls/DeviceOrientationControls.js | @@ -88,6 +88,12 @@ THREE.DeviceOrientationControls = function ( object ) {
};
+ this.dispose = function () {
+
+ this.disconnect();
+
+ };
+
this.connect();
}; | true |
Other | mrdoob | three.js | 8bfe403c00b09093bcf7082888696e371671a789.json | Add dispose method to all controls | examples/js/controls/DragControls.js | @@ -96,6 +96,12 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
};
+ this.dispose = function() {
+
+ me.deactivate();
+
+ };
+
this.activate();
function onDocumentMouseMove( event ) { | true |
Other | mrdoob | three.js | 8bfe403c00b09093bcf7082888696e371671a789.json | Add dispose method to all controls | examples/js/controls/EditorControls.js | @@ -203,11 +203,30 @@ THREE.EditorControls = function ( object, domElement ) {
}
- domElement.addEventListener( 'contextmenu', function ( event ) {
+ function contextmenu( event ) {
event.preventDefault();
- }, false );
+ }
+
+ this.dispose = function() {
+
+ domElement.removeEventListener( 'contextmenu', contextmenu, false );
+ domElement.removeEventListener( 'mousedown', onMouseDown, false );
+ domElement.removeEventListener( 'mousewheel', onMouseWheel, false );
+ domElement.removeEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
+
+ domElement.removeEventListener( 'mousemove', onMouseMove, false );
+ domElement.removeEventListener( 'mouseup', onMouseUp, false );
+ domElement.removeEventListener( 'mouseout', onMouseUp, false );
+ domElement.removeEventListener( 'dblclick', onMouseUp, false );
+
+ domElement.removeEventListener( 'touchstart', touchStart, false );
+ domElement.removeEventListener( 'touchmove', touchMove, false );
+
+ }
+
+ domElement.addEventListener( 'contextmenu', contextmenu, false );
domElement.addEventListener( 'mousedown', onMouseDown, false );
domElement.addEventListener( 'mousewheel', onMouseWheel, false );
domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox | true |
Other | mrdoob | three.js | 8bfe403c00b09093bcf7082888696e371671a789.json | Add dispose method to all controls | examples/js/controls/FirstPersonControls.js | @@ -253,19 +253,37 @@ THREE.FirstPersonControls = function ( object, domElement ) {
};
-
- this.domElement.addEventListener( 'contextmenu', function ( event ) {
+ function contextmenu( event ) {
event.preventDefault();
- }, false );
+ }
+
+ this.dispose = function() {
+
+ this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
+ this.domElement.removeEventListener( 'mousedown', _onMouseDown, false );
+ this.domElement.removeEventListener( 'mousemove', _onMouseMove, false );
+ this.domElement.removeEventListener( 'mouseup', _onMouseUp, false );
+
+ window.removeEventListener( 'keydown', _onKeyDown, false );
+ window.removeEventListener( 'keyup', _onKeyUp, false );
+
+ }
+
+ var _onMouseMove = bind( this, this.onMouseMove );
+ var _onMouseDown = bind( this, this.onMouseDown );
+ var _onMouseUp = bind( this, this.onMouseUp );
+ var _onKeyDown = bind( this, this.onKeyDown );
+ var _onKeyUp = bind( this, this.onKeyUp );
- this.domElement.addEventListener( 'mousemove', bind( this, this.onMouseMove ), false );
- this.domElement.addEventListener( 'mousedown', bind( this, this.onMouseDown ), false );
- this.domElement.addEventListener( 'mouseup', bind( this, this.onMouseUp ), false );
+ this.domElement.addEventListener( 'contextmenu', contextmenu, false );
+ this.domElement.addEventListener( 'mousemove', _onMouseMove, false );
+ this.domElement.addEventListener( 'mousedown', _onMouseDown, false );
+ this.domElement.addEventListener( 'mouseup', _onMouseUp, false );
- window.addEventListener( 'keydown', bind( this, this.onKeyDown ), false );
- window.addEventListener( 'keyup', bind( this, this.onKeyUp ), false );
+ window.addEventListener( 'keydown', _onKeyDown, false );
+ window.addEventListener( 'keyup', _onKeyUp, false );
function bind( scope, fn ) {
| true |