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 | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl | @@ -0,0 +1,5 @@
+#ifdef USE_COLOR
+
+ varying vec3 vColor;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/color_vertex.glsl | @@ -0,0 +1,13 @@
+#ifdef USE_COLOR
+
+ #ifdef GAMMA_INPUT
+
+ vColor = color * color;
+
+ #else
+
+ vColor = color;
+
+ #endif
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/default_vertex.glsl | @@ -0,0 +1,21 @@
+vec4 mvPosition;
+
+#ifdef USE_SKINNING
+
+ mvPosition = modelViewMatrix * skinned;
+
+#endif
+
+#if !defined( USE_SKINNING ) && defined( USE_MORPHTARGETS )
+
+ mvPosition = modelViewMatrix * vec4( morphed, 1.0 );
+
+#endif
+
+#if !defined( USE_SKINNING ) && ! defined( USE_MORPHTARGETS )
+
+ mvPosition = modelViewMatrix * vec4( position, 1.0 );
+
+#endif
+
+gl_Position = projectionMatrix * mvPosition;
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl | @@ -0,0 +1,27 @@
+vec3 objectNormal;
+
+#ifdef USE_SKINNING
+
+ objectNormal = skinnedNormal.xyz;
+
+#endif
+
+#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )
+
+ objectNormal = morphedNormal;
+
+#endif
+
+#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )
+
+ objectNormal = normal;
+
+#endif
+
+#ifdef FLIP_SIDED
+
+ objectNormal = -objectNormal;
+
+#endif
+
+vec3 transformedNormal = normalMatrix * objectNormal;
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/envmap_fragment.glsl | @@ -0,0 +1,61 @@
+#ifdef USE_ENVMAP
+
+ vec3 reflectVec;
+
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
+
+ vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
+
+ // http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations
+ // Transforming Normal Vectors with the Inverse Transformation
+
+ vec3 worldNormal = normalize( vec3( vec4( normal, 0.0 ) * viewMatrix ) );
+
+ if ( useRefract ) {
+
+ reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );
+
+ } else {
+
+ reflectVec = reflect( cameraToVertex, worldNormal );
+
+ }
+
+ #else
+
+ reflectVec = vReflect;
+
+ #endif
+
+ #ifdef DOUBLE_SIDED
+
+ float flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );
+ vec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
+
+ #else
+
+ vec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
+
+ #endif
+
+ #ifdef GAMMA_INPUT
+
+ cubeColor.xyz *= cubeColor.xyz;
+
+ #endif
+
+ if ( combine == 1 ) {
+
+ gl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );
+
+ } else if ( combine == 2 ) {
+
+ gl_FragColor.xyz += cubeColor.xyz * specularStrength * reflectivity;
+
+ } else {
+
+ gl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );
+
+ }
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl | @@ -0,0 +1,19 @@
+#ifdef USE_ENVMAP
+
+ uniform float reflectivity;
+ uniform samplerCube envMap;
+ uniform float flipEnvMap;
+ uniform int combine;
+
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
+
+ uniform bool useRefract;
+ uniform float refractionRatio;
+
+ #else
+
+ varying vec3 vReflect;
+
+ #endif
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl | @@ -0,0 +1,8 @@
+#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )
+
+ varying vec3 vReflect;
+
+ uniform float refractionRatio;
+ uniform bool useRefract;
+
+#endif | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/envmap_vertex.glsl | @@ -0,0 +1,18 @@
+#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )
+
+ vec3 worldNormal = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;
+ worldNormal = normalize( worldNormal );
+
+ vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
+
+ if ( useRefract ) {
+
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
+
+ } else {
+
+ vReflect = reflect( cameraToVertex, worldNormal );
+
+ }
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/fog_fragment.glsl | @@ -0,0 +1,27 @@
+#ifdef USE_FOG
+
+ #ifdef USE_LOGDEPTHBUF_EXT
+
+ float depth = gl_FragDepthEXT / gl_FragCoord.w;
+
+ #else
+
+ float depth = gl_FragCoord.z / gl_FragCoord.w;
+
+ #endif
+
+ #ifdef FOG_EXP2
+
+ const float LOG2 = 1.442695;
+ float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );
+ fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );
+
+ #else
+
+ float fogFactor = smoothstep( fogNear, fogFar, depth );
+
+ #endif
+
+ gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl | @@ -0,0 +1,15 @@
+#ifdef USE_FOG
+
+ uniform vec3 fogColor;
+
+ #ifdef FOG_EXP2
+
+ uniform float fogDensity;
+
+ #else
+
+ uniform float fogNear;
+ uniform float fogFar;
+ #endif
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl | @@ -0,0 +1,5 @@
+#ifdef USE_LIGHTMAP
+
+ gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl | @@ -0,0 +1,6 @@
+#ifdef USE_LIGHTMAP
+
+ varying vec2 vUv2;
+ uniform sampler2D lightMap;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lightmap_pars_vertex.glsl | @@ -0,0 +1,5 @@
+#ifdef USE_LIGHTMAP
+
+ varying vec2 vUv2;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lightmap_vertex.glsl | @@ -0,0 +1,5 @@
+#ifdef USE_LIGHTMAP
+
+ vUv2 = uv2;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lights_lambert_pars_vertex.glsl | @@ -0,0 +1,45 @@
+uniform vec3 ambient;
+uniform vec3 diffuse;
+uniform vec3 emissive;
+
+uniform vec3 ambientLightColor;
+
+#if MAX_DIR_LIGHTS > 0
+
+ uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
+ uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
+
+#endif
+
+#if MAX_HEMI_LIGHTS > 0
+
+ uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
+ uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
+ uniform vec3 hemisphereLightDirection[ 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 ];
+
+#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 spotLightDistance[ MAX_SPOT_LIGHTS ];
+ uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
+ uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
+
+#endif
+
+#ifdef WRAP_AROUND
+
+ uniform vec3 wrapRGB;
+
+#endif | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl | @@ -0,0 +1,202 @@
+vLightFront = vec3( 0.0 );
+
+#ifdef DOUBLE_SIDED
+
+ vLightBack = vec3( 0.0 );
+
+#endif
+
+transformedNormal = normalize( transformedNormal );
+
+#if MAX_DIR_LIGHTS > 0
+
+for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
+
+ vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
+ vec3 dirVector = normalize( lDirection.xyz );
+
+ float dotProduct = dot( transformedNormal, dirVector );
+ vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
+
+ #ifdef DOUBLE_SIDED
+
+ vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );
+
+ #ifdef WRAP_AROUND
+
+ vec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );
+
+ #endif
+
+ #endif
+
+ #ifdef WRAP_AROUND
+
+ vec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );
+ directionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );
+
+ #ifdef DOUBLE_SIDED
+
+ directionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );
+
+ #endif
+
+ #endif
+
+ vLightFront += directionalLightColor[ i ] * directionalLightWeighting;
+
+ #ifdef DOUBLE_SIDED
+
+ vLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;
+
+ #endif
+
+}
+
+#endif
+
+#if MAX_POINT_LIGHTS > 0
+
+ for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
+
+ vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
+ vec3 lVector = lPosition.xyz - mvPosition.xyz;
+
+ float lDistance = 1.0;
+ if ( pointLightDistance[ i ] > 0.0 )
+ lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
+
+ lVector = normalize( lVector );
+ float dotProduct = dot( transformedNormal, lVector );
+
+ vec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );
+
+ #ifdef DOUBLE_SIDED
+
+ vec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );
+
+ #ifdef WRAP_AROUND
+
+ vec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );
+
+ #endif
+
+ #endif
+
+ #ifdef WRAP_AROUND
+
+ vec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );
+ pointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );
+
+ #ifdef DOUBLE_SIDED
+
+ pointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );
+
+ #endif
+
+ #endif
+
+ vLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;
+
+ #ifdef DOUBLE_SIDED
+
+ vLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;
+
+ #endif
+
+ }
+
+#endif
+
+#if MAX_SPOT_LIGHTS > 0
+
+ for( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {
+
+ vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );
+ vec3 lVector = lPosition.xyz - mvPosition.xyz;
+
+ float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - worldPosition.xyz ) );
+
+ if ( spotEffect > spotLightAngleCos[ i ] ) {
+
+ spotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );
+
+ float lDistance = 1.0;
+ if ( spotLightDistance[ i ] > 0.0 )
+ lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );
+
+ lVector = normalize( lVector );
+
+ float dotProduct = dot( transformedNormal, lVector );
+ vec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );
+
+ #ifdef DOUBLE_SIDED
+
+ vec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );
+
+ #ifdef WRAP_AROUND
+
+ vec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );
+
+ #endif
+
+ #endif
+
+ #ifdef WRAP_AROUND
+
+ vec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );
+ spotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );
+
+ #ifdef DOUBLE_SIDED
+
+ spotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );
+
+ #endif
+
+ #endif
+
+ vLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;
+
+ #ifdef DOUBLE_SIDED
+
+ vLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;
+
+ #endif
+
+ }
+
+ }
+
+#endif
+
+#if MAX_HEMI_LIGHTS > 0
+
+ for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
+
+ vec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );
+ vec3 lVector = normalize( lDirection.xyz );
+
+ float dotProduct = dot( transformedNormal, lVector );
+
+ float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;
+ float hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;
+
+ vLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );
+
+ #ifdef DOUBLE_SIDED
+
+ vLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );
+
+ #endif
+
+ }
+
+#endif
+
+vLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;
+
+#ifdef DOUBLE_SIDED
+
+ vLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl | @@ -0,0 +1,278 @@
+vec3 normal = normalize( vNormal );
+vec3 viewPosition = normalize( vViewPosition );
+
+#ifdef DOUBLE_SIDED
+
+ normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );
+
+#endif
+
+#ifdef USE_NORMALMAP
+
+ normal = perturbNormal2Arb( -vViewPosition, normal );
+
+#elif defined( USE_BUMPMAP )
+
+ normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
+
+#endif
+
+#if MAX_POINT_LIGHTS > 0
+
+ vec3 pointDiffuse = vec3( 0.0 );
+ vec3 pointSpecular = vec3( 0.0 );
+
+ for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
+
+ vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
+ vec3 lVector = lPosition.xyz + vViewPosition.xyz;
+
+ float lDistance = 1.0;
+ if ( pointLightDistance[ i ] > 0.0 )
+ lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
+
+ lVector = normalize( lVector );
+
+ // diffuse
+
+ float dotProduct = dot( normal, lVector );
+
+ #ifdef WRAP_AROUND
+
+ float pointDiffuseWeightFull = max( dotProduct, 0.0 );
+ float pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );
+
+ vec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );
+
+ #else
+
+ float pointDiffuseWeight = max( dotProduct, 0.0 );
+
+ #endif
+
+ pointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;
+
+ // specular
+
+ vec3 pointHalfVector = normalize( lVector + viewPosition );
+ float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );
+ float pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );
+
+ float specularNormalization = ( shininess + 2.0 ) / 8.0;
+
+ vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, pointHalfVector ), 0.0 ), 5.0 );
+ pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;
+
+ }
+
+#endif
+
+#if MAX_SPOT_LIGHTS > 0
+
+ vec3 spotDiffuse = vec3( 0.0 );
+ vec3 spotSpecular = vec3( 0.0 );
+
+ for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {
+
+ vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );
+ vec3 lVector = lPosition.xyz + vViewPosition.xyz;
+
+ float lDistance = 1.0;
+ if ( spotLightDistance[ i ] > 0.0 )
+ lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );
+
+ lVector = normalize( lVector );
+
+ float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );
+
+ if ( spotEffect > spotLightAngleCos[ i ] ) {
+
+ spotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );
+
+ // diffuse
+
+ float dotProduct = dot( normal, lVector );
+
+ #ifdef WRAP_AROUND
+
+ float spotDiffuseWeightFull = max( dotProduct, 0.0 );
+ float spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );
+
+ vec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );
+
+ #else
+
+ float spotDiffuseWeight = max( dotProduct, 0.0 );
+
+ #endif
+
+ spotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;
+
+ // specular
+
+ vec3 spotHalfVector = normalize( lVector + viewPosition );
+ float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );
+ float spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );
+
+ float specularNormalization = ( shininess + 2.0 ) / 8.0;
+
+ vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, spotHalfVector ), 0.0 ), 5.0 );
+ spotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;
+
+ }
+
+ }
+
+#endif
+
+#if MAX_DIR_LIGHTS > 0
+
+ vec3 dirDiffuse = vec3( 0.0 );
+ vec3 dirSpecular = vec3( 0.0 ); ,
+
+ for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
+
+ vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
+ vec3 dirVector = normalize( lDirection.xyz );
+
+ // diffuse
+
+ float dotProduct = dot( normal, dirVector );
+
+ #ifdef WRAP_AROUND
+
+ float dirDiffuseWeightFull = max( dotProduct, 0.0 );
+ float dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );
+
+ vec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );
+
+ #else
+
+ float dirDiffuseWeight = max( dotProduct, 0.0 );
+
+ #endif
+
+ dirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;
+
+ // specular
+
+ vec3 dirHalfVector = normalize( dirVector + viewPosition );
+ float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );
+ float dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );
+
+ /*
+ // fresnel term from skin shader
+ const float F0 = 0.128;
+
+ float base = 1.0 - dot( viewPosition, dirHalfVector );
+ float exponential = pow( base, 5.0 );
+
+ float fresnel = exponential + F0 * ( 1.0 - exponential );
+ */
+
+ /*
+ // fresnel term from fresnel shader
+ const float mFresnelBias = 0.08;
+ const float mFresnelScale = 0.3;
+ const float mFresnelPower = 5.0;
+
+ float fresnel = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( -viewPosition ), normal ), mFresnelPower );
+ */
+
+ float specularNormalization = ( shininess + 2.0 ) / 8.0;
+
+ // dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization * fresnel;
+
+ vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( dirVector, dirHalfVector ), 0.0 ), 5.0 );
+ dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;
+
+
+ }
+
+#endif
+
+#if MAX_HEMI_LIGHTS > 0
+
+ vec3 hemiDiffuse = vec3( 0.0 );
+ vec3 hemiSpecular = vec3( 0.0 ); ,
+
+ for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
+
+ vec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );
+ vec3 lVector = normalize( lDirection.xyz );
+
+ // diffuse
+
+ float dotProduct = dot( normal, lVector );
+ float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;
+
+ vec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );
+
+ hemiDiffuse += diffuse * hemiColor;
+
+ // specular (sky light)
+
+ vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );
+ float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;
+ float hemiSpecularWeightSky = specularStrength * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );
+
+ // specular (ground light)
+
+ vec3 lVectorGround = -lVector;
+
+ vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );
+ float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;
+ float hemiSpecularWeightGround = specularStrength * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );
+
+ float dotProductGround = dot( normal, lVectorGround );
+
+ float specularNormalization = ( shininess + 2.0 ) / 8.0;
+
+ vec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );
+ vec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );
+ hemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );
+
+ }
+
+#endif
+
+vec3 totalDiffuse = vec3( 0.0 );
+vec3 totalSpecular = vec3( 0.0 );
+
+#if MAX_DIR_LIGHTS > 0
+
+ totalDiffuse += dirDiffuse;
+ totalSpecular += dirSpecular;
+
+#endif
+
+#if MAX_HEMI_LIGHTS > 0
+
+ totalDiffuse += hemiDiffuse;
+ totalSpecular += hemiSpecular;
+
+#endif
+
+#if MAX_POINT_LIGHTS > 0
+
+ totalDiffuse += pointDiffuse;
+ totalSpecular += pointSpecular;
+
+#endif
+
+#if MAX_SPOT_LIGHTS > 0
+
+ totalDiffuse += spotDiffuse;
+ totalSpecular += spotSpecular;
+
+#endif
+
+#ifdef METAL
+
+ gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );
+
+#else
+
+ gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl | @@ -0,0 +1,52 @@
+uniform vec3 ambientLightColor;
+
+#if MAX_DIR_LIGHTS > 0
+
+ uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
+ uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
+
+#endif
+
+#if MAX_HEMI_LIGHTS > 0
+
+ uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
+ uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
+ uniform vec3 hemisphereLightDirection[ 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 ];
+
+#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 ];
+
+#endif
+
+#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )
+
+ varying vec3 vWorldPosition;
+
+#endif
+
+#ifdef WRAP_AROUND
+
+ uniform vec3 wrapRGB;
+
+#endif
+
+varying vec3 vViewPosition;
+varying vec3 vNormal;
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lights_phong_pars_vertex.glsl | @@ -0,0 +1,5 @@
+#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )
+
+ varying vec3 vWorldPosition;
+
+#endif | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/lights_phong_vertex.glsl | @@ -0,0 +1,5 @@
+#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )
+
+ vWorldPosition = worldPosition.xyz;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/linear_to_gamma_fragment.glsl | @@ -0,0 +1,5 @@
+#ifdef GAMMA_OUTPUT
+
+ gl_FragColor.xyz = sqrt( gl_FragColor.xyz );
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl | @@ -0,0 +1,5 @@
+#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)
+
+ gl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl | @@ -0,0 +1,12 @@
+#ifdef USE_LOGDEPTHBUF
+
+ uniform float logDepthBufFC;
+
+ #ifdef USE_LOGDEPTHBUF_EXT
+
+ #extension GL_EXT_frag_depth : enable
+ varying float vFragDepth;
+
+ #endif
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl | @@ -0,0 +1,11 @@
+#ifdef USE_LOGDEPTHBUF
+
+ #ifdef USE_LOGDEPTHBUF_EXT
+
+ varying float vFragDepth;
+
+ #endif
+
+ uniform float logDepthBufFC;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl | @@ -0,0 +1,15 @@
+#ifdef USE_LOGDEPTHBUF
+
+ gl_Position.z = log2(max(1e-6, gl_Position.w + 1.0)) * logDepthBufFC;
+
+ #ifdef USE_LOGDEPTHBUF_EXT
+
+ vFragDepth = 1.0 + gl_Position.w;
+
+#else
+
+ gl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;
+
+ #endif
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/map_fragment.glsl | @@ -0,0 +1,13 @@
+#ifdef USE_MAP
+
+ vec4 texelColor = texture2D( map, vUv );
+
+ #ifdef GAMMA_INPUT
+
+ texelColor.xyz *= texelColor.xyz;
+
+ #endif
+
+ gl_FragColor = gl_FragColor * texelColor;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl | @@ -0,0 +1,11 @@
+#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )
+
+ varying vec2 vUv;
+
+#endif
+
+#ifdef USE_MAP
+
+ uniform sampler2D map;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/map_pars_vertex.glsl | @@ -0,0 +1,6 @@
+#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )
+
+ varying vec2 vUv;
+ uniform vec4 offsetRepeat;
+
+#endif | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl | @@ -0,0 +1,5 @@
+#ifdef USE_MAP
+
+ gl_FragColor = gl_FragColor * texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl | @@ -0,0 +1,5 @@
+#ifdef USE_MAP
+
+ uniform sampler2D map;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/map_vertex.glsl | @@ -0,0 +1,5 @@
+#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )
+
+ vUv = uv * offsetRepeat.zw + offsetRepeat.xy;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl | @@ -0,0 +1,12 @@
+#ifdef USE_MORPHNORMALS
+
+ vec3 morphedNormal = vec3( 0.0 );
+
+ morphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];
+ morphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];
+ morphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];
+ morphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];
+
+ morphedNormal += normal;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl | @@ -0,0 +1,13 @@
+#ifdef USE_MORPHTARGETS
+
+ #ifndef USE_MORPHNORMALS
+
+ uniform float morphTargetInfluences[ 8 ];
+
+ #else
+
+ uniform float morphTargetInfluences[ 4 ];
+
+ #endif
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl | @@ -0,0 +1,20 @@
+#ifdef USE_MORPHTARGETS
+
+ vec3 morphed = vec3( 0.0 );
+ morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
+ morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
+ morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
+ morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
+
+ #ifndef USE_MORPHNORMALS
+
+ morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];
+ morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];
+ morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];
+ morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];
+
+ #endif
+
+ morphed += position;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl | @@ -0,0 +1,27 @@
+#ifdef USE_NORMALMAP
+
+ uniform sampler2D normalMap;
+ uniform vec2 normalScale;
+
+ // Per-Pixel Tangent Space Normal Mapping
+ // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
+
+ vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {
+
+ vec3 q0 = dFdx( eye_pos.xyz );
+ vec3 q1 = dFdy( eye_pos.xyz );
+ vec2 st0 = dFdx( vUv.st );
+ vec2 st1 = dFdy( vUv.st );
+
+ vec3 S = normalize( q0 * st1.t - q1 * st0.t );
+ vec3 T = normalize( -q0 * st1.s + q1 * st0.s );
+ vec3 N = normalize( surf_norm );
+
+ vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
+ mapN.xy = normalScale * mapN.xy;
+ mat3 tsn = mat3( S, T, N );
+ return normalize( tsn * mapN );
+
+ }
+
+#endif | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/shadowmap_fragment.glsl | @@ -0,0 +1,220 @@
+#ifdef USE_SHADOWMAP
+
+ #ifdef SHADOWMAP_DEBUG
+
+ vec3 frustumColors[3];
+ frustumColors[0] = vec3( 1.0, 0.5, 0.0 );
+ frustumColors[1] = vec3( 0.0, 1.0, 0.8 );
+ frustumColors[2] = vec3( 0.0, 0.5, 1.0 );
+
+ #endif
+
+ #ifdef SHADOWMAP_CASCADE
+
+ int inFrustumCount = 0;
+
+ #endif
+
+ float fDepth;
+ vec3 shadowColor = vec3( 1.0 );
+
+ for( int i = 0; i < MAX_SHADOWS; i ++ ) {
+
+ vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
+
+ // if ( something && something ) breaks ATI OpenGL shader compiler
+ // if ( all( something, something ) ) using this instead
+
+ bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
+ bool inFrustum = all( inFrustumVec );
+
+ // don't shadow pixels outside of light frustum
+ // use just first frustum (for cascades)
+ // don't shadow pixels behind far plane of light frustum
+
+ #ifdef SHADOWMAP_CASCADE
+
+ inFrustumCount += int( inFrustum );
+ bvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );
+
+ #else
+
+ bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
+
+ #endif
+
+ bool frustumTest = all( frustumTestVec );
+
+ if ( frustumTest ) {
+
+ shadowCoord.z += shadowBias[ i ];
+
+ #if defined( SHADOWMAP_TYPE_PCF )
+
+ // Percentage-close filtering
+ // (9 pixel kernel)
+ // http://fabiensanglard.net/shadowmappingPCF/
+
+ float shadow = 0.0;
+
+ /*
+ // nested loops breaks shader compiler / validator on some ATI cards when using OpenGL
+ // must enroll loop manually
+
+ for ( float y = -1.25; y <= 1.25; y += 1.25 )
+ for ( float x = -1.25; x <= 1.25; x += 1.25 ) {
+
+ vec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );
+
+ // doesn't seem to produce any noticeable visual difference compared to simple texture2D lookup
+ //vec4 rgbaDepth = texture2DProj( shadowMap[ i ], vec4( vShadowCoord[ i ].w * ( vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy ), 0.05, vShadowCoord[ i ].w ) );
+
+ float fDepth = unpackDepth( rgbaDepth );
+
+ if ( fDepth < shadowCoord.z )
+ shadow += 1.0;
+
+ }
+
+ shadow /= 9.0;
+
+ */
+
+ const float shadowDelta = 1.0 / 9.0;
+
+ float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
+ float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
+
+ float dx0 = -1.25 * xPixelOffset;
+ float dy0 = -1.25 * yPixelOffset;
+ float dx1 = 1.25 * xPixelOffset;
+ float dy1 = 1.25 * yPixelOffset;
+
+ fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
+ if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
+
+ fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
+ if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
+
+ fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
+ if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
+
+ fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
+ if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
+
+ fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
+ if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
+
+ fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
+ if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
+
+ fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
+ if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
+
+ fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
+ if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
+
+ fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
+ if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
+
+ shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
+
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
+
+ // Percentage-close filtering
+ // (9 pixel kernel)
+ // http://fabiensanglard.net/shadowmappingPCF/
+
+ float shadow = 0.0;
+
+ float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
+ float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
+
+ float dx0 = -1.0 * xPixelOffset;
+ float dy0 = -1.0 * yPixelOffset;
+ float dx1 = 1.0 * xPixelOffset;
+ float dy1 = 1.0 * yPixelOffset;
+
+ mat3 shadowKernel;
+ mat3 depthKernel;
+
+ depthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
+ depthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
+ depthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
+ depthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
+ depthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
+ depthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
+ depthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
+ depthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
+ depthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
+
+ vec3 shadowZ = vec3( shadowCoord.z );
+ shadowKernel[0] = vec3(lessThan(depthKernel[0], shadowZ ));
+ shadowKernel[0] *= vec3(0.25);
+
+ shadowKernel[1] = vec3(lessThan(depthKernel[1], shadowZ ));
+ shadowKernel[1] *= vec3(0.25);
+
+ shadowKernel[2] = vec3(lessThan(depthKernel[2], shadowZ ));
+ shadowKernel[2] *= vec3(0.25);
+
+ vec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );
+
+ shadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );
+ shadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );
+
+ vec4 shadowValues;
+ shadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );
+ shadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );
+ shadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );
+ shadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );
+
+ shadow = dot( shadowValues, vec4( 1.0 ) );
+
+ shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
+
+ #else
+
+ vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );
+ float fDepth = unpackDepth( rgbaDepth );
+
+ if ( fDepth < shadowCoord.z )
+
+ // spot with multiple shadows is darker
+
+ shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
+
+ // spot with multiple shadows has the same color as single shadow spot
+
+ // shadowColor = min( shadowColor, vec3( shadowDarkness[ i ] ) );
+
+ #endif
+
+ }
+
+
+ #ifdef SHADOWMAP_DEBUG
+
+ #ifdef SHADOWMAP_CASCADE
+
+ if ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];
+
+ #else
+
+ if ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];
+
+ #endif
+
+ #endif
+
+ }
+
+ #ifdef GAMMA_OUTPUT
+
+ shadowColor *= shadowColor;
+
+ #endif
+
+ gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;
+
+#endif | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl | @@ -0,0 +1,19 @@
+#ifdef USE_SHADOWMAP
+
+ uniform sampler2D shadowMap[ MAX_SHADOWS ];
+ uniform vec2 shadowMapSize[ MAX_SHADOWS ];
+
+ uniform float shadowDarkness[ MAX_SHADOWS ];
+ uniform float shadowBias[ MAX_SHADOWS ];
+
+ varying vec4 vShadowCoord[ MAX_SHADOWS ];
+
+ float unpackDepth( const in vec4 rgba_depth ) {
+
+ const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );
+ float depth = dot( rgba_depth, bit_shift );
+ return depth;
+
+ }
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl | @@ -0,0 +1,6 @@
+#ifdef USE_SHADOWMAP
+
+ varying vec4 vShadowCoord[ MAX_SHADOWS ];
+ uniform mat4 shadowMatrix[ MAX_SHADOWS ];
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl | @@ -0,0 +1,9 @@
+#ifdef USE_SHADOWMAP
+
+ for( int i = 0; i < MAX_SHADOWS; i ++ ) {
+
+ vShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;
+
+ }
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl | @@ -0,0 +1,8 @@
+#ifdef USE_SKINNING
+
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl | @@ -0,0 +1,44 @@
+#ifdef USE_SKINNING
+
+ #ifdef BONE_TEXTURE
+
+ uniform sampler2D boneTexture;
+ uniform int boneTextureWidth;
+ uniform int boneTextureHeight;
+
+ mat4 getBoneMatrix( const in float i ) {
+
+ float j = i * 4.0;
+ float x = mod( j, float( boneTextureWidth ) );
+ float y = floor( j / float( boneTextureWidth ) );
+
+ float dx = 1.0 / float( boneTextureWidth );
+ float dy = 1.0 / float( boneTextureHeight );
+
+ y = dy * ( y + 0.5 );
+
+ vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
+ vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
+ vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
+ vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
+
+ mat4 bone = mat4( v1, v2, v3, v4 );
+
+ return bone;
+
+ }
+
+ #else
+
+ uniform mat4 boneGlobalMatrices[ MAX_BONES ];
+
+ mat4 getBoneMatrix( const in float i ) {
+
+ mat4 bone = boneGlobalMatrices[ int(i) ];
+ return bone;
+
+ }
+
+ #endif
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/skinning_vertex.glsl | @@ -0,0 +1,19 @@
+#ifdef USE_SKINNING
+
+ #ifdef USE_MORPHTARGETS
+
+ vec4 skinVertex = vec4( morphed, 1.0 );
+
+ #else
+
+ vec4 skinVertex = vec4( position, 1.0 );
+
+ #endif
+
+ vec4 skinned = vec4( 0.0 );
+ skinned += boneMatX * skinVertex * skinWeight.x;
+ skinned += boneMatY * skinVertex * skinWeight.y;
+ skinned += boneMatZ * skinVertex * skinWeight.z;
+ skinned += boneMatW * skinVertex * skinWeight.w;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl | @@ -0,0 +1,19 @@
+#ifdef USE_SKINNING
+
+ mat4 skinMatrix = mat4( 0.0 );
+ skinMatrix += skinWeight.x * boneMatX;
+ skinMatrix += skinWeight.y * boneMatY;
+ skinMatrix += skinWeight.z * boneMatZ;
+ skinMatrix += skinWeight.w * boneMatW;
+
+ #ifdef USE_MORPHNORMALS
+
+ vec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );
+
+ #else
+
+ vec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );
+
+ #endif
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl | @@ -0,0 +1,12 @@
+float specularStrength;
+
+#ifdef USE_SPECULARMAP
+
+ vec4 texelSpecular = texture2D( specularMap, vUv );
+ specularStrength = texelSpecular.r;
+
+#else
+
+ specularStrength = 1.0;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl | @@ -0,0 +1,5 @@
+#ifdef USE_SPECULARMAP
+
+ uniform sampler2D specularMap;
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl | @@ -0,0 +1,21 @@
+#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )
+
+ #ifdef USE_SKINNING
+
+ vec4 worldPosition = modelMatrix * skinned;
+
+ #endif
+
+ #if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )
+
+ vec4 worldPosition = modelMatrix * vec4( morphed, 1.0 );
+
+ #endif
+
+ #if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )
+
+ vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
+
+ #endif
+
+#endif
\ No newline at end of file | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | utils/build/build.py | @@ -60,8 +60,15 @@ def main(argv=None):
filename = '../../' + filename;
sources.append(filename)
with open(filename, 'r') as f:
- tmp.write(f.read())
- tmp.write('\n')
+ if filename.endswith(".glsl"):
+ tmp.write('THREE.ShaderChunk = THREE.ShaderChunk || {};')
+ tmp.write('THREE.ShaderChunk.' + os.path.splitext(os.path.basename(filename))[0] + '= "')
+ tmp.write(f.read().replace('\n','\\n'))
+ tmp.write('";')
+ tmp.write('\n')
+ else:
+ tmp.write(f.read())
+ tmp.write('\n')
if args.amd:
tmp.write('exports.THREE = THREE;\n\n} ) );')
@@ -78,7 +85,7 @@ def main(argv=None):
externs = ' --externs '.join(args.externs)
source = ' '.join(sources)
- cmd = 'java -jar compiler/compiler.jar --warning_level=VERBOSE --jscomp_off=globalThis --externs %s --jscomp_off=checkTypes --language_in=ECMASCRIPT5_STRICT --js %s --js_output_file %s %s' % (externs, source, output, sourcemapargs)
+ cmd = 'java -jar compiler/compiler.jar --warning_level=VERBOSE --jscomp_off=globalThis --externs %s --jscomp_off=checkTypes --language_in=ECMASCRIPT5_STRICT --js %s --js_output_file %s %s' % (externs, path, output, sourcemapargs)
os.system(cmd)
# header | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | utils/build/includes/common.json | @@ -80,7 +80,56 @@
"src/scenes/Fog.js",
"src/scenes/FogExp2.js",
"src/renderers/CanvasRenderer.js",
- "src/renderers/shaders/ShaderChunk.js",
+ "src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/default_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lightmap_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_phong_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_phong_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/lightmap_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/color_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/skinning_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/linear_to_gamma_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_lambert_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/envmap_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/fog_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/color_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/envmap_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/shadowmap_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl",
"src/renderers/shaders/UniformsUtils.js",
"src/renderers/shaders/UniformsLib.js",
"src/renderers/shaders/ShaderLib.js", | true |
Other | mrdoob | three.js | 8fcb3c06165d4616ba960fbfbb9e208fead9d64c.json | add glsl changes | utils/build/includes/webgl.json | @@ -70,7 +70,56 @@
"src/scenes/Scene.js",
"src/scenes/Fog.js",
"src/scenes/FogExp2.js",
- "src/renderers/shaders/ShaderChunk.js",
+ "src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/default_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lightmap_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_phong_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_phong_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/lightmap_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/color_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/skinning_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/linear_to_gamma_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_lambert_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/envmap_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/fog_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/map_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/color_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/envmap_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/shadowmap_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl",
+ "src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl",
+ "src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl",
"src/renderers/shaders/UniformsUtils.js",
"src/renderers/shaders/UniformsLib.js",
"src/renderers/shaders/ShaderLib.js",
@@ -97,3 +146,4 @@
"src/extras/renderers/plugins/SpritePlugin.js",
"src/extras/shaders/ShaderFlares.js"
]
+ | true |
Other | mrdoob | three.js | 011770a86960e456bd64891f0e55149585181997.json | fix the way of removeing a mesh | src/renderers/WebGLRenderer.js | @@ -4030,7 +4030,7 @@ THREE.WebGLRenderer = function ( parameters ) {
function removeInstancesWebglObjects( objlist, object ) {
- delete objlist[object];
+ delete objlist[object.id];
};
| false |
Other | mrdoob | three.js | 953931d101bb4b0e4c82f7e1cd671a145f892c32.json | Fix a small problem in UCSCharacter | examples/js/UCSCharacter.js | @@ -41,7 +41,7 @@ THREE.UCSCharacter = function() {
geometry.computeBoundingBox();
geometry.computeVertexNormals();
- THREE.AnimationHandler.add( geometry.animation );
+ //THREE.AnimationHandler.add( geometry.animation );
mesh = new THREE.SkinnedMesh( geometry, new THREE.MeshFaceMaterial() );
scope.root.add( mesh );
@@ -53,7 +53,7 @@ THREE.UCSCharacter = function() {
mesh.castShadow = true;
mesh.receiveShadow = true;
- animation = new THREE.Animation( mesh, geometry.animation.name );
+ animation = new THREE.Animation( mesh, geometry.animation );
animation.play();
scope.setSkin(0); | false |
Other | mrdoob | three.js | caa4066afb1b2fbda8335aa69c2bffe3a46de8a1.json | fix some issues with the webgl renderer | src/extras/renderers/plugins/DepthPassPlugin.js | @@ -80,36 +80,12 @@ THREE.DepthPassPlugin = function () {
_renderList.length = 0;
projectObject(scene,scene,camera);
-
- /*_renderList = scene.__webglObjects;
-
- for ( j = 0, jl = renderList.length; j < jl; j ++ ) {
-
- webglObject = renderList[ j ];
- object = webglObject.object;
-
- webglObject.render = false;
-
- if ( object.visible ) {
-
- if ( object.frustumCulled === false || _frustum.intersectsObject( object ) === true ) {
-
- object._modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
-
- webglObject.render = true;
-
- }
-
- }
-
- }*/
-
// render regular objects
var objectMaterial, useMorphing, useSkinning;
- for ( j = 0, jl = renderList.length; j < jl; j ++ ) {
+ for ( j = 0, jl = _renderList.length; j < jl; j ++ ) {
webglObject = _renderList[ j ];
| true |
Other | mrdoob | three.js | caa4066afb1b2fbda8335aa69c2bffe3a46de8a1.json | fix some issues with the webgl renderer | src/renderers/WebGLRenderer.js | @@ -222,16 +222,6 @@ THREE.WebGLRenderer = function ( parameters ) {
var _fragmentShaderPrecisionMediumpFloat = _gl.getShaderPrecisionFormat( _gl.FRAGMENT_SHADER, _gl.MEDIUM_FLOAT );
var _fragmentShaderPrecisionLowpFloat = _gl.getShaderPrecisionFormat( _gl.FRAGMENT_SHADER, _gl.LOW_FLOAT );
- /*
- var _vertexShaderPrecisionHighpInt = _gl.getShaderPrecisionFormat( _gl.VERTEX_SHADER, _gl.HIGH_INT );
- var _vertexShaderPrecisionMediumpInt = _gl.getShaderPrecisionFormat( _gl.VERTEX_SHADER, _gl.MEDIUM_INT );
- var _vertexShaderPrecisionLowpInt = _gl.getShaderPrecisionFormat( _gl.VERTEX_SHADER, _gl.LOW_INT );
-
- var _fragmentShaderPrecisionHighpInt = _gl.getShaderPrecisionFormat( _gl.FRAGMENT_SHADER, _gl.HIGH_INT );
- var _fragmentShaderPrecisionMediumpInt = _gl.getShaderPrecisionFormat( _gl.FRAGMENT_SHADER, _gl.MEDIUM_INT );
- var _fragmentShaderPrecisionLowpInt = _gl.getShaderPrecisionFormat( _gl.FRAGMENT_SHADER, _gl.LOW_INT );
- */
-
// clamp precision to maximum available
var highpAvailable = _vertexShaderPrecisionHighpFloat.precision > 0 && _fragmentShaderPrecisionHighpFloat.precision > 0;
@@ -3279,11 +3269,24 @@ THREE.WebGLRenderer = function ( parameters ) {
_frustum.setFromMatrix( _projScreenMatrix );
// update WebGL objects
-
if ( this.autoUpdateObjects ) this.initWebGLObjects( scene );
- // custom render plugins (pre pass)
+ opaqueObjects.length = 0;
+ transparentObjects.length = 0;
+ _sortObjects = this.sortObjects;
+
+ projectObject(scene,scene,camera);
+
+ if ( this.sortObjects ) {
+
+ opaqueObjects.sort( painterSortStable );
+ transparentObjects.sort( reversePainterSortStable );
+
+ }
+
+ // custom render plugins (pre pass)
+
renderPlugins( this.renderPluginsPre, scene, camera );
//
@@ -3304,18 +3307,7 @@ THREE.WebGLRenderer = function ( parameters ) {
// set matrices for regular objects (frustum culled)
- opaqueObjects.length = 0;
- transparentObjects.length = 0;
- _sortObjects = this.sortObjects;
-
- projectObject(scene,scene,camera);
-
- if ( this.sortObjects ) {
-
- opaqueObjects.sort( painterSortStable );
- transparentObjects.sort( reversePainterSortStable );
- }
// set matrices for immediate objects
@@ -3399,14 +3391,11 @@ THREE.WebGLRenderer = function ( parameters ) {
updateObject(scene, object);
- setupMatrices( object, camera );
-
for (var i = 0, l = webglObjects.length; i < l; i++){
var webglObject = webglObjects[i];
unrollBufferMaterial( webglObject );
-
webglObject.render = true;
@@ -3489,6 +3478,8 @@ THREE.WebGLRenderer = function ( parameters ) {
object = webglObject.object;
buffer = webglObject.buffer;
+
+ setupMatrices( object, camera );
if ( overrideMaterial ) {
| true |
Other | mrdoob | three.js | dd52b53039aeca2558495bdc3d02833165be658d.json | fix buffergeometry + remove comments | editor/index.html | @@ -9,7 +9,7 @@
<link href="css/types.css" rel="stylesheet" />
<link id="theme" href="css/light.css" rel="stylesheet" />
- <script src="../build/three.min.js"></script>
+ <script src="../build/three.js"></script>
<script src="../examples/js/libs/system.min.js"></script>
<script src="../examples/js/controls/EditorControls.js"></script> | true |
Other | mrdoob | three.js | dd52b53039aeca2558495bdc3d02833165be658d.json | fix buffergeometry + remove comments | editor/js/Menubar.Edit.js | @@ -47,8 +47,6 @@ Menubar.Edit = function ( editor ) {
if ( confirm( 'Convert ' + object.name + ' to BufferGeometry?' ) === false ) return;
- delete object.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring) This is not yet fixed for buffergeometry
-
object.geometry = new THREE.BufferGeometry().fromGeometry( object.geometry );
editor.signals.objectChanged.dispatch( object );
@@ -65,8 +63,6 @@ Menubar.Edit = function ( editor ) {
if ( confirm( 'Flatten ' + object.name + '?' ) === false ) return;
- //delete object.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring)
-
var geometry = object.geometry.clone();
geometry.applyMatrix( object.matrix );
| true |
Other | mrdoob | three.js | dd52b53039aeca2558495bdc3d02833165be658d.json | fix buffergeometry + remove comments | src/renderers/WebGLRenderer.js | @@ -3690,55 +3690,55 @@ THREE.WebGLRenderer = function ( parameters ) {
object._modelViewMatrix = new THREE.Matrix4();
object._normalMatrix = new THREE.Matrix3();
- geometry = object.geometry;
+ }
+
+ geometry = object.geometry;
+
+ if ( geometry === undefined ) {
- if ( geometry === undefined ) {
+ // ImmediateRenderObject
- // ImmediateRenderObject
+ } else if ( geometry.__webglInit === undefined ) {
- } else if ( geometry.__webglInit === undefined ) {
+ geometry.__webglInit = true;
+ geometry.addEventListener( 'dispose', onGeometryDispose );
- geometry.__webglInit = true;
- geometry.addEventListener( 'dispose', onGeometryDispose );
+ if ( geometry instanceof THREE.BufferGeometry ) {
- if ( geometry instanceof THREE.BufferGeometry ) {
+ initDirectBuffers( geometry );
- initDirectBuffers( geometry );
-
- } else if ( object instanceof THREE.Mesh ) {
-
- if ( object.__webglActive !== undefined ) {
-
- removeObject( object, scene );
+ } else if ( object instanceof THREE.Mesh ) {
+
+ if ( object.__webglActive !== undefined ) {
- }
-
- initGeometryGroups(scene, object, geometry);
+ removeObject( object, scene );
- } else if ( object instanceof THREE.Line ) {
+ }
+
+ initGeometryGroups(scene, object, geometry);
- if ( ! geometry.__webglVertexBuffer ) {
+ } else if ( object instanceof THREE.Line ) {
- createLineBuffers( geometry );
- initLineBuffers( geometry, object );
+ if ( ! geometry.__webglVertexBuffer ) {
- geometry.verticesNeedUpdate = true;
- geometry.colorsNeedUpdate = true;
- geometry.lineDistancesNeedUpdate = true;
+ createLineBuffers( geometry );
+ initLineBuffers( geometry, object );
- }
+ geometry.verticesNeedUpdate = true;
+ geometry.colorsNeedUpdate = true;
+ geometry.lineDistancesNeedUpdate = true;
- } else if ( object instanceof THREE.PointCloud ) {
+ }
- if ( ! geometry.__webglVertexBuffer ) {
+ } else if ( object instanceof THREE.PointCloud ) {
- createParticleBuffers( geometry );
- initParticleBuffers( geometry, object );
+ if ( ! geometry.__webglVertexBuffer ) {
- geometry.verticesNeedUpdate = true;
- geometry.colorsNeedUpdate = true;
+ createParticleBuffers( geometry );
+ initParticleBuffers( geometry, object );
- }
+ geometry.verticesNeedUpdate = true;
+ geometry.colorsNeedUpdate = true;
}
@@ -3806,9 +3806,9 @@ THREE.WebGLRenderer = function ( parameters ) {
// create separate VBOs per geometry chunk
- for ( g in geometry.geometryGroups ) {
+ for ( var i = 0, il = geometry.geometryGroupsList.length; i < il; i ++ ) {
- geometryGroup = geometry.geometryGroups[ g ];
+ geometryGroup = geometry.geometryGroupsList[ i ];
// initialise VBO on the first access
@@ -3886,7 +3886,15 @@ THREE.WebGLRenderer = function ( parameters ) {
// check all geometry groups
if ( geometry.buffersNeedUpdate ) {
- initGeometryGroups(scene, object,geometry);
+ if ( geometry instanceof THREE.BufferGeometry ) {
+
+ initDirectBuffers( geometry );
+
+ } else if ( object instanceof THREE.Mesh ) {
+
+ initGeometryGroups(scene, object,geometry);
+
+ }
}
| true |
Other | mrdoob | three.js | f4884bac7a11d9dcef86921f1e54c99a24fd98e4.json | change usage uuid to id. | src/extras/renderers/plugins/DepthPassPlugin.js | @@ -191,7 +191,7 @@ THREE.DepthPassPlugin = function () {
if ( object.visible ) {
- var webglObjects = scene.__webglObjects[object.uuid];
+ var webglObjects = scene.__webglObjects[object.id];
if (webglObjects && (object.frustumCulled === false || _frustum.intersectsObject( object ) === true) ) {
| true |
Other | mrdoob | three.js | f4884bac7a11d9dcef86921f1e54c99a24fd98e4.json | change usage uuid to id. | src/extras/renderers/plugins/ShadowMapPlugin.js | @@ -333,7 +333,7 @@ THREE.ShadowMapPlugin = function () {
if ( object.visible ) {
- var webglObjects = scene.__webglObjects[object.uuid];
+ var webglObjects = scene.__webglObjects[object.id];
if (webglObjects && object.castShadow && (object.frustumCulled === false || _frustum.intersectsObject( object ) === true) ) {
| true |
Other | mrdoob | three.js | f4884bac7a11d9dcef86921f1e54c99a24fd98e4.json | change usage uuid to id. | src/renderers/WebGLRenderer.js | @@ -3393,7 +3393,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( object.visible ) {
- var webglObjects = scene.__webglObjects[object.uuid];
+ var webglObjects = scene.__webglObjects[object.id];
if (webglObjects && (object.frustumCulled === false || _frustum.intersectsObject( object ) === true) ) {
@@ -3822,7 +3822,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( geometry.geometryGroups === undefined ) {
- delete scene.__webglObjects[object.uuid];
+ delete scene.__webglObjects[object.id];
geometry.makeGroups( material instanceof THREE.MeshFaceMaterial, _glExtensionElementIndexUint ? 4294967296 : 65535 );
}
@@ -3865,9 +3865,9 @@ THREE.WebGLRenderer = function ( parameters ) {
}
function addBuffer( objlist, buffer, object ) {
- var uuid = object.uuid;
- objlist[uuid] = objlist[uuid] || [];
- objlist[uuid].push(
+ var id = object.id;
+ objlist[id] = objlist[id] || [];
+ objlist[id].push(
{
id: null,
buffer: buffer, | true |
Other | mrdoob | three.js | 5a9f8d7b6e5f7f35d208be9e3990ac7d2a4b0160.json | add depth pass plugin fix | src/extras/renderers/plugins/DepthPassPlugin.js | @@ -12,7 +12,8 @@ THREE.DepthPassPlugin = function () {
_depthMaterial, _depthMaterialMorph, _depthMaterialSkin, _depthMaterialMorphSkin,
_frustum = new THREE.Frustum(),
- _projScreenMatrix = new THREE.Matrix4();
+ _projScreenMatrix = new THREE.Matrix4(),
+ _renderList = [];
this.init = function ( renderer ) {
@@ -76,8 +77,11 @@ THREE.DepthPassPlugin = function () {
_renderer.clear();
// set object matrices & frustum culling
-
- renderList = scene.__webglObjects;
+
+ _renderList.length = 0;
+ projectObject(scene,scene,camera);
+
+ /*_renderList = scene.__webglObjects;
for ( j = 0, jl = renderList.length; j < jl; j ++ ) {
@@ -98,62 +102,60 @@ THREE.DepthPassPlugin = function () {
}
- }
+ }*/
+
// render regular objects
var objectMaterial, useMorphing, useSkinning;
for ( j = 0, jl = renderList.length; j < jl; j ++ ) {
- webglObject = renderList[ j ];
-
- if ( webglObject.render ) {
-
- object = webglObject.object;
- buffer = webglObject.buffer;
+ webglObject = _renderList[ j ];
- // todo: create proper depth material for particles
+ object = webglObject.object;
+ buffer = webglObject.buffer;
- if ( object instanceof THREE.PointCloud && ! object.customDepthMaterial ) continue;
+ // todo: create proper depth material for particles
- objectMaterial = getObjectMaterial( object );
+ if ( object instanceof THREE.PointCloud && ! object.customDepthMaterial ) continue;
- if ( objectMaterial ) _renderer.setMaterialFaces( object.material );
+ objectMaterial = getObjectMaterial( object );
- useMorphing = object.geometry.morphTargets !== undefined && object.geometry.morphTargets.length > 0 && objectMaterial.morphTargets;
- useSkinning = object instanceof THREE.SkinnedMesh && objectMaterial.skinning;
+ if ( objectMaterial ) _renderer.setMaterialFaces( object.material );
- if ( object.customDepthMaterial ) {
+ useMorphing = object.geometry.morphTargets !== undefined && object.geometry.morphTargets.length > 0 && objectMaterial.morphTargets;
+ useSkinning = object instanceof THREE.SkinnedMesh && objectMaterial.skinning;
- material = object.customDepthMaterial;
+ if ( object.customDepthMaterial ) {
- } else if ( useSkinning ) {
+ material = object.customDepthMaterial;
- material = useMorphing ? _depthMaterialMorphSkin : _depthMaterialSkin;
+ } else if ( useSkinning ) {
- } else if ( useMorphing ) {
+ material = useMorphing ? _depthMaterialMorphSkin : _depthMaterialSkin;
- material = _depthMaterialMorph;
+ } else if ( useMorphing ) {
- } else {
+ material = _depthMaterialMorph;
- material = _depthMaterial;
+ } else {
- }
+ material = _depthMaterial;
- if ( buffer instanceof THREE.BufferGeometry ) {
+ }
- _renderer.renderBufferDirect( camera, scene.__lights, fog, material, buffer, object );
+ if ( buffer instanceof THREE.BufferGeometry ) {
- } else {
+ _renderer.renderBufferDirect( camera, scene.__lights, fog, material, buffer, object );
- _renderer.renderBuffer( camera, scene.__lights, fog, material, buffer, object );
+ } else {
- }
+ _renderer.renderBuffer( camera, scene.__lights, fog, material, buffer, object );
}
+
}
// set matrices and render immediate objects
@@ -184,6 +186,33 @@ THREE.DepthPassPlugin = function () {
_gl.enable( _gl.BLEND );
};
+
+ function projectObject(scene, object,camera){
+
+ if ( object.visible ) {
+
+ var webglObjects = scene.__webglObjects[object.uuid];
+
+ if (webglObjects && (object.frustumCulled === false || _frustum.intersectsObject( object ) === true) ) {
+
+
+ for (var i = 0, l = webglObjects.length; i < l; i++){
+
+ var webglObject = webglObjects[i];
+
+ object._modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
+ _renderList.push(webglObject);
+
+ }
+ }
+
+ for(var i = 0, l = object.children.length; i < l; i++) {
+
+ projectObject(scene, object.children[i], camera);
+ }
+
+ }
+ }
// For the moment just ignore objects that have multiple materials with different animation methods
// Only the first material will be taken into account for deciding which depth material to use | false |
Other | mrdoob | three.js | 736f30b3f50b783df06c6d96ee8fd9b4354d98df.json | fix naming OpaqueObjects | src/renderers/WebGLRenderer.js | @@ -29,7 +29,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_clearColor = new THREE.Color( 0x000000 ),
_clearAlpha = 0;
- var OpaqueObjects = [];
+ var opaqueObjects = [];
var transparentObjects = [];
var _sortObjects = true;
@@ -3304,15 +3304,15 @@ THREE.WebGLRenderer = function ( parameters ) {
// set matrices for regular objects (frustum culled)
- OpaqueObjects.length = 0;
+ opaqueObjects.length = 0;
transparentObjects.length = 0;
_sortObjects = this.sortObjects;
projectObject(scene,scene,camera);
if ( this.sortObjects ) {
- OpaqueObjects.sort( painterSortStable );
+ opaqueObjects.sort( painterSortStable );
transparentObjects.sort( reversePainterSortStable );
}
@@ -3345,7 +3345,7 @@ THREE.WebGLRenderer = function ( parameters ) {
this.setDepthWrite( material.depthWrite );
setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
- renderObjects( OpaqueObjects, camera, lights, fog, true, material );
+ renderObjects( opaqueObjects, camera, lights, fog, true, material );
renderObjects( transparentObjects, camera, lights, fog, true, material );
renderObjectsImmediate( scene.__webglObjectsImmediate, '', camera, lights, fog, false, material );
@@ -3357,7 +3357,7 @@ THREE.WebGLRenderer = function ( parameters ) {
this.setBlending( THREE.NoBlending );
- renderObjects( OpaqueObjects, camera, lights, fog, false, material );
+ renderObjects( opaqueObjects, camera, lights, fog, false, material );
renderObjectsImmediate( scene.__webglObjectsImmediate, 'opaque', camera, lights, fog, false, material );
// transparent pass (back-to-front order)
@@ -3413,7 +3413,7 @@ THREE.WebGLRenderer = function ( parameters ) {
} else {
- OpaqueObjects.push(webglObject);
+ opaqueObjects.push(webglObject);
}
| false |
Other | mrdoob | three.js | 745502aff3600c884c20b5c2deb8474cbe358a8f.json | Add ambient color for palette | examples/js/renderers/SoftwareRenderer.js | @@ -245,10 +245,10 @@ THREE.SoftwareRenderer = function ( parameters ) {
context.fillRect( 0, 0, canvasWidth, canvasHeight );
}
- function getPalette( color, bSimulateSpecular ) {
- var diffuseR = color.r * 149;
- var diffuseG = color.g * 149;
- var diffuseB = color.b * 149;
+ function getPalette( material, bSimulateSpecular ) {
+ var diffuseR = material.ambient.r + material.color.r * 255;
+ var diffuseG = material.ambient.g + material.color.g * 255;
+ var diffuseB = material.ambient.b + material.color.b * 255;
var palette = new Array(256);
if ( bSimulateSpecular ) {
@@ -399,13 +399,13 @@ THREE.SoftwareRenderer = function ( parameters ) {
if ( material instanceof THREE.MeshLambertMaterial ) {
// Generate color palette
if ( !material.palette ) {
- material.palette = getPalette( material.color, false );
+ material.palette = getPalette( material, false );
}
} else if ( material instanceof THREE.MeshPhongMaterial ) {
// Generate color palette
if ( !material.palette ) {
- material.palette = getPalette( material.color, true );
+ material.palette = getPalette( material, true );
}
}
@@ -523,11 +523,11 @@ THREE.SoftwareRenderer = function ( parameters ) {
// UV values
var tu1 = face.uvs[0].x;
- var tv1 = face.uvs[0].y;
+ var tv1 = 1-face.uvs[0].y;
var tu2 = face.uvs[1].x;
- var tv2 = face.uvs[1].y;
+ var tv2 = 1-face.uvs[1].y;
var tu3 = face.uvs[2].x;
- var tv3 = face.uvs[2].y;
+ var tv3 = 1-face.uvs[2].y;
// Normal values
var n1 = face.vertexNormalsModel[0], n2 = face.vertexNormalsModel[1], n3 = face.vertexNormalsModel[2];
@@ -767,7 +767,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
var u = cx1 * scale;
var v = cx2 * scale;
- shader( data, offset * 4, cxtu, 1-cxtv, cxnz * 255, face, material );
+ shader( data, offset * 4, cxtu, cxtv, cxnz * 255, face, material );
}
cx1 += dy12;
@@ -821,7 +821,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
var v = cx2 * scale;
zbuffer[ offset ] = z;
- shader( data, offset * 4, cxtu, 1-cxtv, cxnz * 255, face, material );
+ shader( data, offset * 4, cxtu, cxtv, cxnz * 255, face, material );
}
| true |
Other | mrdoob | three.js | 745502aff3600c884c20b5c2deb8474cbe358a8f.json | Add ambient color for palette | examples/software_geometry_earth.html | @@ -70,7 +70,7 @@
var geometry = new THREE.SphereGeometry( 200, 20, 20 );
- var material = new THREE.MeshPhongMaterial( { map: texture, overdraw: 0.5 } );
+ var material = new THREE.MeshLambertMaterial( { map: texture, overdraw: 0.5 } );
var mesh = new THREE.Mesh( geometry, material );
group.add( mesh );
| true |
Other | mrdoob | three.js | ab88af6629f07b99ec777b9031c2ff0cfab8d9e9.json | Remove unused variable | examples/js/renderers/SoftwareRenderer.js | @@ -38,7 +38,6 @@ THREE.SoftwareRenderer = function ( parameters ) {
var blockShift = 3;
var blockSize = 1 << blockShift;
var maxZVal = (1 << 24); // Note: You want to size this so you don't get overflows.
- var maxTexCoordVal = 1; // Note: You want to size this so you don't get overflows.
var rectx1 = Infinity, recty1 = Infinity;
var rectx2 = 0, recty2 = 0;
@@ -79,13 +78,11 @@ THREE.SoftwareRenderer = function ( parameters ) {
viewportXScale = fixScale * canvasWidth / 2;
viewportYScale = -fixScale * canvasHeight / 2;
viewportZScale = maxZVal / 2;
- viewportTexCoordScale = maxTexCoordVal;
-
+
viewportXOffs = fixScale * canvasWidth / 2 + 0.5;
viewportYOffs = fixScale * canvasHeight / 2 + 0.5;
viewportZOffs = maxZVal / 2 + 0.5;
- viewportTexCoordOffs = 0;
-
+
canvas.width = canvasWidth;
canvas.height = canvasHeight;
@@ -566,9 +563,12 @@ THREE.SoftwareRenderer = function ( parameters ) {
// Constant part of half-edge functions
- var c1 = dy12 * ((minx << subpixelBits) - x1) + dx12 * ((miny << subpixelBits) - y1);
- var c2 = dy23 * ((minx << subpixelBits) - x2) + dx23 * ((miny << subpixelBits) - y2);
- var c3 = dy31 * ((minx << subpixelBits) - x3) + dx31 * ((miny << subpixelBits) - y3);
+ var minXfixscale = (minx << subpixelBits);
+ var minYfixscale = (miny << subpixelBits);
+
+ var c1 = dy12 * ((minXfixscale) - x1) + dx12 * ((minYfixscale) - y1);
+ var c2 = dy23 * ((minXfixscale) - x2) + dx23 * ((minYfixscale) - y2);
+ var c3 = dy31 * ((minXfixscale) - x3) + dx31 * ((minYfixscale) - y3);
// Correct for fill convention
@@ -591,13 +591,13 @@ THREE.SoftwareRenderer = function ( parameters ) {
// Z at top/left corner of rast area
- var cz = ( z1 + ((minx << subpixelBits) - x1) * dzdx + ((miny << subpixelBits) - y1) * dzdy ) | 0;
+ var cz = ( z1 + ((minXfixscale) - x1) * dzdx + ((minYfixscale) - y1) * dzdy ) | 0;
// Z pixel steps
- var zfixscale = (1 << subpixelBits);
- dzdx = (dzdx * zfixscale) | 0;
- dzdy = (dzdy * zfixscale) | 0;
+ var fixscale = (1 << subpixelBits);
+ dzdx = (dzdx * fixscale) | 0;
+ dzdy = (dzdy * fixscale) | 0;
// UV interpolation setup
@@ -610,19 +610,15 @@ THREE.SoftwareRenderer = function ( parameters ) {
// UV at top/left corner of rast area
- var minXfixscale = (minx << subpixelBits);
- var minYfixscale = (miny << subpixelBits);
var ctu = ( tu1 + (minXfixscale - x1) * dtudx + (minYfixscale - y1) * dtudy );
var ctv = ( tv1 + (minXfixscale - x1) * dtvdx + (minYfixscale - y1) * dtvdy );
// UV pixel steps
-
- var tufixscale = (1 << subpixelBits);
- dtudx = dtudx * tufixscale;
- dtudy = dtudy * tufixscale;
- var tvfixscale = (1 << subpixelBits);
- dtvdx = (dtvdx * tvfixscale);
- dtvdy = (dtvdy * tvfixscale);
+
+ dtudx = dtudx * fixscale;
+ dtudy = dtudy * fixscale;
+ dtvdx = (dtvdx * fixscale);
+ dtvdy = (dtvdy * fixscale);
// Normal interpolation setup
@@ -636,8 +632,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
// UV pixel steps
- dnzdx = (dnzdx * tvfixscale);
- dnzdy = (dnzdy * tvfixscale);
+ dnzdx = (dnzdx * fixscale);
+ dnzdy = (dnzdy * fixscale);
// Set up min/max corners
var qm1 = q - 1; // for convenience | false |
Other | mrdoob | three.js | c1034bc24bf6a36fff9d83e530279c044bb79829.json | Finish the texture mapping implementation. | examples/js/renderers/SoftwareRenderer.js | @@ -425,44 +425,37 @@ THREE.SoftwareRenderer = function ( parameters ) {
// UV interpolation setup
- var dtu12 = tu1 - tu2, dtu23 = tu2 - tu3, dtu31 = tu3 - tu1;
-// var dtudx = (invDet * (dtu12*dy31 - du31*dy12)); // dtu per one subpixel step in x
-// var dtudy = (invDet * (dtu12*dx31 - dx12*du31)); // dtu per one subpixel step in y
- var dtv12 = tv1 - tv2, dtv23 = tv2 - tv3, dtv31 = tv3 - tv1;
-// var dtvdx = (invDet * (dtv12*dy31 - dtv31*dy12)); // dtv per one subpixel step in x
-// var dtvdy = (invDet * (dtv12*dx31 - dx12*dtv31)); // dtv per one subpixel step in y
+ var dtu12 = tu1 - tu2, du31 = tu3 - tu1;
+ var dtudx = (invDet * (dtu12*dy31 - du31*dy12)); // dtu per one subpixel step in x
+ var dtudy = (invDet * (dtu12*dx31 - dx12*du31)); // dtu per one subpixel step in y
+ var dtv12 = tv1 - tv2, dtv31 = tv3 - tv1;
+ var dtvdx = (invDet * (dtv12*dy31 - dtv31*dy12)); // dtv per one subpixel step in x
+ var dtvdy = (invDet * (dtv12*dx31 - dx12*dtv31)); // dtv per one subpixel step in y
- // UV at top/left corner of rast area
-// var minXfixscale = (minx << subpixelBits);
-// var minYfixscale = (miny << subpixelBits);
-// var ctu = ( tu1 + (minXfixscale - x1) * dtudx + (minYfixscale - y1) * dtudy );
-// var ctv = ( tv1 + (minXfixscale - x1) * dtvdx + (minYfixscale - y1) * dtvdy );
- var mintu = Math.min( tu1, tu2, tu3 );
- var maxtu = Math.max( tu1, tu2, tu3 );
- var mintv = Math.min( tv1, tv2, tv3 );
- var maxtv = Math.max( tv1, tv2, tv3 );
-
- var cuv1 = dtv12 * (mintu- tu1) + dtu12 * (mintv - tv1);
- var cuv2 = dtv23 * (mintu - tu2) + dtu23 * (mintv - tv2);
- var cuv3 = dtv31 * (mintu - tu3) + dtu31 * (mintv - tv3);
+ // UV at top/left corner of rast area
+ var minXfixscale = (minx << subpixelBits);
+ var minYfixscale = (miny << subpixelBits);
+ var ctu = ( tu1 + (minXfixscale - x1) * dtudx + (minYfixscale - y1) * dtudy );
+ var ctv = ( tv1 + (minXfixscale - x1) * dtvdx + (minYfixscale - y1) * dtvdy );
+
// UV pixel steps
-// var tufixscale = (1 << subpixelBits);
-// dtudx = dtudx * tufixscale;
-// dtudy = dtudy * tufixscale;
-// var tvfixscale = (1 << subpixelBits);
-// dtvdx = (dtvdx * tvfixscale);
-// dtvdy = (dtvdy * tvfixscale);
+ var tufixscale = (1 << subpixelBits);
+ dtudx = dtudx * tufixscale;
+ dtudy = dtudy * tufixscale;
+ var tvfixscale = (1 << subpixelBits);
+ dtvdx = (dtvdx * tvfixscale);
+ dtvdy = (dtvdy * tvfixscale);
// Set up min/max corners
var qm1 = q - 1; // for convenience
var nmin1 = 0, nmax1 = 0;
var nmin2 = 0, nmax2 = 0;
var nmin3 = 0, nmax3 = 0;
var nminz = 0, nmaxz = 0;
-// var nmintu = 0, nmaxtu = 0;
-// var nmintv = 0, nmaxtv = 0;
+ var nmintu = 0, nmaxtu = 0;
+ var nmintv = 0, nmaxtv = 0;
if (dx12 >= 0) nmax1 -= qm1*dx12; else nmin1 -= qm1*dx12;
if (dy12 >= 0) nmax1 -= qm1*dy12; else nmin1 -= qm1*dy12;
if (dx23 >= 0) nmax2 -= qm1*dx23; else nmin2 -= qm1*dx23;
@@ -471,8 +464,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
if (dy31 >= 0) nmax3 -= qm1*dy31; else nmin3 -= qm1*dy31;
if (dzdx >= 0) nmaxz += qm1*dzdx; else nminz += qm1*dzdx;
if (dzdy >= 0) nmaxz += qm1*dzdy; else nminz += qm1*dzdy;
-// if (dtudx >= 0) nmaxtu += qm1*dtudx; else nmintu += qm1*dtudx;
-// if (dtudy >= 0) nmaxtu += qm1*dtudy; else nmintu += qm1*dtudy;
+ if (dtudx >= 0) nmaxtu += qm1*dtudx; else nmintu += qm1*dtudx;
+ if (dtudy >= 0) nmaxtu += qm1*dtudy; else nmintu += qm1*dtudy;
// Loop through blocks
var linestep = canvasWidth - q;
@@ -482,17 +475,15 @@ THREE.SoftwareRenderer = function ( parameters ) {
var cb2 = c2;
var cb3 = c3;
var cbz = cz;
- var cbtuv1 = cuv1;
- var cbtuv2 = cuv2;
- var cbtuv3 = cuv3;
+ var cbtu = ctu;
+ var cbtv = ctv;
var qstep = -q;
var e1x = qstep * dy12;
var e2x = qstep * dy23;
var e3x = qstep * dy31;
var ezx = qstep * dzdx;
- var e1tu = qstep * dtv12;
- var e2tu = qstep * dtv23;
- var e3tu = qstep * dtv31;
+ var etux = qstep * dtudx;
+ var etvx = qstep * dtvdx;
var x0 = minx;
for ( var y0 = miny; y0 < maxy; y0 += q ) {
@@ -505,9 +496,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
cb2 += e2x;
cb3 += e3x;
cbz += ezx;
- cbtuv1 += e1tu;
- cbtuv2 += e2tu;
- cbtuv3 += e3tu;
+ cbtu += etux;
+ cbtv += etvx;
}
@@ -517,9 +507,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
e2x = -e2x;
e3x = -e3x;
ezx = -ezx;
- e1tu = -e1tu;
- e2tu = -e2tu;
- e3tu = -e3tu;
+ etux = -etux;
+ etvx = -etvx;
while ( 1 ) {
@@ -529,9 +518,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
cb2 += e2x;
cb3 += e3x;
cbz += ezx;
- cbtuv1 += e1tu;
- cbtuv2 += e2tu;
- cbtuv3 += e3tu;
+ cbtu += etux;
+ cbtv += etvx;
// We're done with this block line when at least one edge completely out
// If an edge function is too small and decreasing in the current traversal
@@ -567,59 +555,43 @@ THREE.SoftwareRenderer = function ( parameters ) {
var cy1 = cb1;
var cy2 = cb2;
var cyz = cbz;
- var ctv1 = cbtuv1;
- var ctv2 = cbtuv2;
+ var cytu = cbtu;
+ var cytv = cbtv;
for ( var iy = 0; iy < q; iy ++ ) {
var cx1 = cy1;
var cx2 = cy2;
var cxz = cyz;
- var ctu1 = ctv1;
- var ctu2 = ctv2;
+ var cxtu = cytu;
+ var cxtv = cytv;
for ( var ix = 0; ix < q; ix ++ ) {
var z = cxz;
-
+
if ( z < zbuffer[ offset ] ) {
zbuffer[ offset ] = z;
var u = cx1 * scale;
- var v = cx2 * scale;
-
-// // Compute UV
-// var xPos = x0 + ix;
-// var yPos = y0 + iy;
-// var dist1 = Math.sqrt((xPos-x1)*(xPos-x1)+(yPos-y1)*(yPos-y1));
-// var dist2 = Math.sqrt((xPos-x2)*(xPos-x2)+(yPos-y2)*(yPos-y2));
-// var dist3 = Math.sqrt((xPos-x3)*(xPos-x3)+(yPos-y3)*(yPos-y3));
-// var distTotal = dist1 + dist2 + dist3;
-//
-// var dist1Ratio = dist1 / distTotal;
-// var dist2Ratio = dist2 / distTotal;
-// var dist3Ratio = dist3 / distTotal;
-//
-// u = tu1 * dist1Ratio + tu2 * dist2Ratio + tu3 * dist3Ratio;
-// v = tv1 * dist1Ratio + tv2 * dist2Ratio + tv3 * dist3Ratio;
-//
-
- shader( data, offset * 4, ctu1, ctu2, face, material );
+ var v = cx2 * scale;
+
+ shader( data, offset * 4, cxtu, cxtv, face, material );
}
cx1 += dy12;
cx2 += dy23;
cxz += dzdx;
- ctu1 += dtv12;
- ctu2 += dtv23;
+ cxtu += dtudx;
+ cxtv += dtvdx;
offset++;
}
cy1 += dx12;
cy2 += dx23;
cyz += dzdy;
- ctv1 += dtv12;
- ctv2 += dtv23;
+ cytu += dtudy;
+ cytv += dtvdy;
offset += linestep;
}
@@ -630,48 +602,30 @@ THREE.SoftwareRenderer = function ( parameters ) {
var cy2 = cb2;
var cy3 = cb3;
var cyz = cbz;
- var ctv1 = cbtuv1;
- var ctv2 = cbtuv2;
- var ctv3 = cbtuv3;
+ var cytu = cbtu;
+ var cytv = cbtv;
for ( var iy = 0; iy < q; iy ++ ) {
var cx1 = cy1;
var cx2 = cy2;
var cx3 = cy3;
var cxz = cyz;
- var ctu1 = ctv1;
- var ctu2 = ctv2;
- var ctu3 = ctv3;
+ var cxtu = cytu;
+ var cxtv = cytv;
for ( var ix = 0; ix < q; ix ++ ) {
if ( ( cx1 | cx2 | cx3 ) >= 0 ) {
- var z = cxz;
+ var z = cxz;
if ( z < zbuffer[ offset ] ) {
var u = cx1 * scale;
var v = cx2 * scale;
- zbuffer[ offset ] = z;
-
-// // Compute UV
-// var xPos = x0 + ix;
-// var yPos = y0 + iy;
-// var dist1 = Math.sqrt((xPos-x1)*(xPos-x1)+(yPos-y1)*(yPos-y1));
-// var dist2 = Math.sqrt((xPos-x2)*(xPos-x2)+(yPos-y2)*(yPos-y2));
-// var dist3 = Math.sqrt((xPos-x3)*(xPos-x3)+(yPos-y3)*(yPos-y3));
-// var distTotal = dist1 + dist2 + dist3;
-//
-// var dist1Ratio = dist1 / distTotal;
-// var dist2Ratio = dist2 / distTotal;
-// var dist3Ratio = dist3 / distTotal;
-//
-// u = tu1 * dist1Ratio + tu2 * dist2Ratio + tu3 * dist3Ratio;
-// v = tv1 * dist1Ratio + tv2 * dist2Ratio + tv3 * dist3Ratio;
-//
- shader( data, offset * 4, ctu1, ctu2, face, material );
+ zbuffer[ offset ] = z;
+ shader( data, offset * 4, cxtu, cxtv, face, material );
}
@@ -681,9 +635,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
cx2 += dy23;
cx3 += dy31;
cxz += dzdx;
- ctu1 += dtv12;
- ctu2 += dtv23;
- ctu3 += dtv31;
+ cxtu += dtudx;
+ cxtv += dtvdx;
offset++;
}
@@ -692,9 +645,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
cy2 += dx23;
cy3 += dx31;
cyz += dzdy;
- ctv1 += dtu12;
- ctv2 += dtu23;
- ctv3 += dtu31;
+ cytu += dtudy;
+ cytv += dtvdy;
offset += linestep;
}
@@ -708,9 +660,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
cb2 += q*dx23;
cb3 += q*dx31;
cbz += q*dzdy;
- cbtuv1 += q*dtu12;
- cbtuv2 += q*dtu23;
- cbtuv3 += q*dtu31;
+ cbtu += q*dtudy;
+ cbtv += q*dtvdy;
}
} | false |
Other | mrdoob | three.js | 5e2412d26eac67259879d139683ddad08b6b5181.json | Create texture data and draw texture | examples/js/renderers/SoftwareRenderer.js | @@ -236,26 +236,45 @@ THREE.SoftwareRenderer = function ( parameters ) {
material instanceof THREE.SpriteMaterial ) {
var string;
-
- if ( material.vertexColors === THREE.FaceColors ) {
-
- string = [
- 'buffer[ offset ] = face.color.r * 255;',
- 'buffer[ offset + 1 ] = face.color.g * 255;',
- 'buffer[ offset + 2 ] = face.color.b * 255;',
- 'buffer[ offset + 3 ] = material.opacity * 255;',
- ].join('\n');
-
- } else {
-
- string = [
- 'buffer[ offset ] = material.color.r * 255;',
- 'buffer[ offset + 1 ] = material.color.g * 255;',
- 'buffer[ offset + 2 ] = material.color.b * 255;',
- 'buffer[ offset + 3 ] = material.opacity * 255;',
- ].join('\n');
-
- }
+
+ if ( material.map ) {
+ var texture = new THREE.SoftwareRenderer.Texture();
+ texture.CreateFromImage( material.map.image );
+ material.texture = texture;
+
+ string = [
+ 'var tdim = material.texture.width;',
+ 'var tbound = tdim - 1;',
+ 'var tdata = material.texture.data;',
+ 'var texel = tdata[((v * tdim) & tbound) * tdim + ((u * tdim) & tbound)];',
+ 'buffer[ offset ] = (texel & 0xff0000) >> 16;',
+ 'buffer[ offset + 1 ] = (texel & 0xff00) >> 8;',
+ 'buffer[ offset + 2 ] = (texel & 0xff);',
+ 'buffer[ offset + 3 ] = material.opacity * 255;',
+ ].join('\n');
+
+ } else {
+
+ if ( material.vertexColors === THREE.FaceColors ) {
+
+ string = [
+ 'buffer[ offset ] = face.color.r * 255;',
+ 'buffer[ offset + 1 ] = face.color.g * 255;',
+ 'buffer[ offset + 2 ] = face.color.b * 255;',
+ 'buffer[ offset + 3 ] = material.opacity * 255;',
+ ].join('\n');
+
+ } else {
+
+ string = [
+ 'buffer[ offset ] = material.color.r * 255;',
+ 'buffer[ offset + 1 ] = material.color.g * 255;',
+ 'buffer[ offset + 2 ] = material.color.b * 255;',
+ 'buffer[ offset + 3 ] = material.opacity * 255;',
+ ].join('\n');
+
+ }
+ }
shader = new Function( 'buffer, offset, u, v, face, material', string );
@@ -627,3 +646,74 @@ THREE.SoftwareRenderer = function ( parameters ) {
}
};
+
+THREE.SoftwareRenderer.Texture = function() {
+ var canvas = null;
+
+ this.CreateFromImage = function( image ) {
+
+ if(image.width <=0 || image.height <=0)
+ return;
+
+ var isCanvasClean = false;
+ var canvas = THREE.SoftwareRenderer.Texture.canvas;
+ if ( !canvas ) {
+
+ try {
+
+ canvas = document.createElement('canvas');
+ THREE.SoftwareRenderer.Texture.canvas = canvas;
+ isCanvasClean = true;
+ } catch( e ) {
+ return;
+ }
+
+ }
+
+ var dim = image.width > image.height ? image.width : image.height;
+ if(dim <= 32)
+ dim = 32;
+ else if(dim <= 64)
+ dim = 64;
+ else if(dim <= 128)
+ dim = 128;
+ else if(dim <= 256)
+ dim = 256;
+ else if(dim <= 512)
+ dim = 512;
+ else
+ dim = 1024;
+
+ if(canvas.width != dim || canvas.height != dim) {
+ canvas.width = canvas.height = dim;
+ isCanvasClean = true;
+ }
+
+ var data;
+ try {
+ var ctx = canvas.getContext('2d');
+ if(!isCanvasClean)
+ ctx.clearRect(0, 0, dim, dim);
+ ctx.drawImage(image, 0, 0, dim, dim);
+ var imgData = ctx.getImageData(0, 0, dim, dim);
+ data = imgData.data;
+ }
+ catch(e) {
+ return;
+ }
+
+ var size = data.length / 4;
+ this.data = new Array(size);
+ var alpha;
+ for(var i=0, j=0; i<size; i++, j+=4) {
+ alpha = data[j + 3];
+ this.data[i] = alpha << 24 | data[j] << 16 | data[j+1] << 8 | data[j+2];
+ if(alpha < 255)
+ this.hasTransparency = true;
+ }
+
+ this.width = dim;
+ this.height = dim;
+ this.srcUrl = image.src;
+ };
+}; | true |
Other | mrdoob | three.js | 5e2412d26eac67259879d139683ddad08b6b5181.json | Create texture data and draw texture | examples/software_geometry_earth.html | @@ -0,0 +1,176 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>three.js canvas - geometry - earth</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: #808080;
+ font-family:Monospace;
+ font-size:13px;
+ text-align:center;
+
+ background-color: #ffffff;
+ margin: 0px;
+ overflow: hidden;
+ }
+
+ #info {
+ position: absolute;
+ top: 0px; width: 100%;
+ padding: 5px;
+ }
+
+ a {
+
+ color: #0080ff;
+ }
+
+ </style>
+ </head>
+ <body>
+
+ <div id="container"></div>
+ <div id="info"><a href="http://threejs.org" target="_blank">three.js</a> - earth demo</div>
+
+ <script src="../build/three.min.js"></script>
+ <script src="js/libs/stats.min.js"></script>
+ <script src="js/renderers/SoftwareRenderer.js"></script>
+
+ <script>
+
+ var container, stats;
+ var camera, scene, renderer;
+ var group;
+ var mouseX = 0, mouseY = 0;
+
+ var windowHalfX = window.innerWidth / 2;
+ var windowHalfY = window.innerHeight / 2;
+
+ init();
+ animate();
+
+ function init() {
+
+ container = document.getElementById( 'container' );
+
+ camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 2000 );
+ camera.position.z = 500;
+
+ scene = new THREE.Scene();
+
+ group = new THREE.Object3D();
+ scene.add( group );
+
+ // earth
+
+ var loader = new THREE.TextureLoader();
+ loader.load( 'textures/land_ocean_ice_cloud_2048.jpg', function ( texture ) {
+
+ var geometry = new THREE.SphereGeometry( 200, 20, 20 );
+
+ var material = new THREE.MeshBasicMaterial( { map: texture, overdraw: 0.5 } );
+ var mesh = new THREE.Mesh( geometry, material );
+ group.add( mesh );
+
+ } );
+
+ // shadow
+
+ var canvas = document.createElement( 'canvas' );
+ canvas.width = 128;
+ canvas.height = 128;
+
+ var context = canvas.getContext( '2d' );
+ var gradient = context.createRadialGradient(
+ canvas.width / 2,
+ canvas.height / 2,
+ 0,
+ canvas.width / 2,
+ canvas.height / 2,
+ canvas.width / 2
+ );
+ gradient.addColorStop( 0.1, 'rgba(210,210,210,1)' );
+ gradient.addColorStop( 1, 'rgba(255,255,255,1)' );
+
+ context.fillStyle = gradient;
+ context.fillRect( 0, 0, canvas.width, canvas.height );
+
+ var texture = new THREE.Texture( canvas );
+ texture.needsUpdate = true;
+
+ var geometry = new THREE.PlaneGeometry( 300, 300, 3, 3 );
+ var material = new THREE.MeshBasicMaterial( { map: texture, overdraw: 0.5 } );
+
+ var mesh = new THREE.Mesh( geometry, material );
+ mesh.position.y = - 250;
+ mesh.rotation.x = - Math.PI / 2;
+ group.add( mesh );
+
+ renderer = new THREE.SoftwareRenderer();
+ renderer.setClearColor( 0x000000 );
+ renderer.setSize( window.innerWidth, window.innerHeight );
+
+ container.appendChild( renderer.domElement );
+
+ stats = new Stats();
+ stats.domElement.style.position = 'absolute';
+ stats.domElement.style.top = '0px';
+ container.appendChild( stats.domElement );
+
+ document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+
+ //
+
+ window.addEventListener( 'resize', onWindowResize, false );
+
+ }
+
+ function onWindowResize() {
+
+ windowHalfX = window.innerWidth / 2;
+ windowHalfY = window.innerHeight / 2;
+
+ camera.aspect = window.innerWidth / window.innerHeight;
+ camera.updateProjectionMatrix();
+
+ renderer.setSize( window.innerWidth, window.innerHeight );
+
+ }
+
+ function onDocumentMouseMove( event ) {
+
+ mouseX = ( event.clientX - windowHalfX );
+ mouseY = ( event.clientY - windowHalfY );
+
+ }
+
+ //
+
+ function animate() {
+
+ requestAnimationFrame( animate );
+
+ render();
+ stats.update();
+
+ }
+
+ function render() {
+
+ camera.position.x += ( mouseX - camera.position.x ) * 0.05;
+ camera.position.y += ( - mouseY - camera.position.y ) * 0.05;
+ camera.lookAt( scene.position );
+
+ group.rotation.y -= 0.005;
+
+ renderer.render( scene, camera );
+
+ }
+
+
+ </script>
+
+ </body>
+</html> | true |
Other | mrdoob | three.js | b1673f3716e7b0a7142d2b356c9ad4435ce544fc.json | transmit GLSL "defines" in ShaderPass
Otherwise we can't use defines in post processing shaders | examples/js/postprocessing/ShaderPass.js | @@ -10,6 +10,7 @@ THREE.ShaderPass = function ( shader, textureID ) {
this.material = new THREE.ShaderMaterial( {
+ defines: shader.defines || {},
uniforms: this.uniforms,
vertexShader: shader.vertexShader,
fragmentShader: shader.fragmentShader | false |
Other | mrdoob | three.js | 1729be414207740b8563d5212ee41f042dee4b26.json | reset enabled attributes list | src/renderers/WebGLRenderer.js | @@ -287,6 +287,9 @@ THREE.WebGLRenderer = function ( parameters ) {
_lightsNeedUpdate = true;
+ for ( var i = 0; i < _enabledAttributes.length; i ++ ) {
+ _enabledAttributes[ i ] = 0;
+ }
};
setDefaultGLState(); | false |
Other | mrdoob | three.js | daeac82fdaebc6e2b7b447d09bfa03c01b20e425.json | Change the way the extra info appears | utils/build/build.js | @@ -34,6 +34,9 @@ function main() {
var buffer = [];
var sources = [];
+
+ buffer.push('// You shouldn\'t edit this build file. \n');
+ buffer.push('// The following source code is build from the src folder. \n');
if ( args.amd ){
buffer.push('function ( root, factory ) {\n\n\tif ( typeof define === \'function\' && define.amd ) {\n\n\t\tdefine( [ \'exports\' ], factory );\n\n\t} else if ( typeof exports === \'object\' ) {\n\n\t\tfactory( exports );\n\n\t} else {\n\n\t\tfactory( root );\n\n\t}\n\n}( this, function ( exports ) {\n\n');
@@ -49,9 +52,7 @@ function main() {
var file = '../../' + files[ j ];
sources.push( file );
- buffer.push('// You shouldn\'t edit this build file. \n');
- buffer.push('// The following source code should be edited in \n');
- buffer.push('// ' + files[ j ]);
+ buffer.push('// File:' + files[ j ]);
buffer.push('\n\n');
buffer.push( fs.readFileSync( file, 'utf8' ) );
buffer.push('\n'); | true |
Other | mrdoob | three.js | daeac82fdaebc6e2b7b447d09bfa03c01b20e425.json | Change the way the extra info appears | utils/build/build.py | @@ -5,7 +5,7 @@
if sys.version_info < (2, 7):
print("This script requires at least Python 2.7.")
print("Please, update to a newer version: http://www.python.org/download/releases/")
- exit()
+# exit()
import argparse
import json
@@ -44,17 +44,18 @@ def main(argv=None):
fd, path = tempfile.mkstemp()
tmp = open(path, 'w')
sources = []
-
+
+ tmp.write('// You shouldn\'t edit this build file. \n')
+ tmp.write('// The following source code is build from the src folder. \n')
+
if args.amd:
tmp.write('( function ( root, factory ) {\n\n\tif ( typeof define === \'function\' && define.amd ) {\n\n\t\tdefine( [ \'exports\' ], factory );\n\n\t} else if ( typeof exports === \'object\' ) {\n\n\t\tfactory( exports );\n\n\t} else {\n\n\t\tfactory( root );\n\n\t}\n\n}( this, function ( exports ) {\n\n')
for include in args.include:
with open('includes/' + include + '.json','r') as f:
files = json.load(f)
for filename in files:
- tmp.write('// You shouldn\'t edit this build file. \n')
- tmp.write('// The following source code should be edited in \n')
- tmp.write('// ' + filename)
+ tmp.write('// File:' + filename)
tmp.write('\n\n')
filename = '../../' + filename;
sources.append(filename) | true |
Other | mrdoob | three.js | 40102adda0cccdaf17a5e794e6e6fad0c254d920.json | Throw a decent error on missing font.
It throws an error when the font is missing.
Ex: "The font helvetiker with normal weight and normal style is missing.
Fixes #4923. | src/extras/FontUtils.js | @@ -33,7 +33,15 @@ THREE.FontUtils = {
getFace: function () {
- return this.faces[ this.face ][ this.weight ][ this.style ];
+ try {
+
+ return this.faces[ this.face ][ this.weight ][ this.style ];
+
+ } catch (e) {
+
+ throw "The font " + this.face + " with " + this.weight + " weight and " + this.style + " style is missing."
+
+ };
},
| false |
Other | mrdoob | three.js | ea236d7cedfb8bb1c7bdcb5f360cf6f0062dd9b9.json | Add the file name before the code in Three.js | utils/build/build.py | @@ -52,6 +52,10 @@ def main(argv=None):
with open('includes/' + include + '.json','r') as f:
files = json.load(f)
for filename in files:
+ tmp.write('// You shouldn\'t edit this build file. \n')
+ tmp.write('// The following source code should be edited in \n')
+ tmp.write('// ' + filename)
+ tmp.write('\n\n')
filename = '../../' + filename;
sources.append(filename)
with open(filename, 'r') as f: | false |
Other | mrdoob | three.js | ee6ef689f6520229e6adef7e0f14f4bdc27f7ef2.json | add uuid to docs | docs/api/core/Object3D.html | @@ -25,7 +25,13 @@ <h2>Properties</h2>
<h3>.[page:Integer id]</h3>
<div>
- Unique number of this object instance.
+ Identifier of this object instance.
+ </div>
+
+ <h3>.[page:String uuid]</h3>
+ <div>
+ [link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance.
+ This gets automatically assigned, so this shouldn't be edited.
</div>
<h3>.[page:String name]</h3> | false |
Other | mrdoob | three.js | 86f082b95ca8442dc053dac1d72b4ccd532e180d.json | permute onProgress and onError in TGALoader | examples/js/loaders/TGALoader.js | @@ -9,7 +9,7 @@ THREE.TGALoader.prototype = {
constructor: THREE.TGALoader,
- load: function ( url, onLoad, onError, onProgress ) {
+ load: function ( url, onLoad, onProgress, onError ) {
var scope = this;
| false |
Other | mrdoob | three.js | 0f2e32eddcb18f5afe75b8a25958bd199fa127a6.json | fix coding style | src/extras/helpers/WireframeHelper.js | @@ -74,9 +74,9 @@ THREE.WireframeHelper = function ( object, hex ) {
var offsets = object.geometry.offsets;
var numEdges = 0;
- if (!offsets.length) {
+ if ( offsets.length === 0 ) {
- offsets = [{count : indices.length, index : 0, start : 0}];
+ offsets = [ { count : indices.length, index : 0, start : 0 } ];
}
| false |
Other | mrdoob | three.js | 835f60d8b4b4948c908b10aaafa9828db3c3071a.json | Fix a encoding error
When I use this build tool, it occurs this error:
D:\3rd_projects\three.js-master\utils\build>python build.py --include common --i
nclude extras --output ../../build/three.js
* Building ../../build/three.js
Traceback (most recent call last):
File "build.py", line 106, in <module>
main()
File "build.py", line 65, in main
tmp.write(f.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0x92 in position 5904: illegal
multibyte sequence
It seems that the reason lies in the default encoding of the `open` function. On my computer it's `GBK` rather than `UTF8`. So I add the `encoding` parameter to it, and then it's just all right. | utils/build/build.py | @@ -42,21 +42,21 @@ def main(argv=None):
sourcemap = sourcemapping = sourcemapargs = ''
fd, path = tempfile.mkstemp()
- tmp = open(path, 'w')
+ tmp = open(path, 'w', encoding="utf-8")
sources = []
if args.amd:
tmp.write('( function ( root, factory ) {\n\n\tif ( typeof define === \'function\' && define.amd ) {\n\n\t\tdefine( [ \'exports\' ], factory );\n\n\t} else if ( typeof exports === \'object\' ) {\n\n\t\tfactory( exports );\n\n\t} else {\n\n\t\tfactory( root );\n\n\t}\n\n}( this, function ( exports ) {\n\n')
for include in args.include:
- with open('includes/' + include + '.json','r') as f:
+ with open('includes/' + include + '.json','r', encoding="utf-8") as f:
files = json.load(f)
for filename in files:
tmp.write('// File:' + filename)
tmp.write('\n\n')
filename = '../../' + filename
sources.append(filename)
- with open(filename, 'r') as f:
+ with open(filename, 'r', encoding="utf-8") as f:
if filename.endswith(".glsl"):
tmp.write('THREE.ShaderChunk[ \'' + os.path.splitext(os.path.basename(filename))[0] + '\'] = "')
tmp.write(f.read().replace('\n','\\n'))
@@ -79,7 +79,7 @@ def main(argv=None):
else:
backup = ''
if os.path.exists(output):
- with open(output,'r') as f: backup = f.read()
+ with open(output, 'r', encoding="utf-8") as f: backup = f.read()
os.remove(output)
externs = ' --externs '.join(args.externs)
@@ -90,11 +90,11 @@ def main(argv=None):
# header
if os.path.exists(output):
- with open(output,'r') as f: text = f.read()
- with open(output,'w') as f: f.write('// threejs.org/license\n' + text + sourcemapping)
+ with open(output, 'r', encoding="utf-8") as f: text = f.read()
+ with open(output, 'w', encoding="utf-8") as f: f.write('// threejs.org/license\n' + text + sourcemapping)
else:
print("Minification with Closure compiler failed. Check your Java runtime version.")
- with open(output,'w') as f: f.write(backup)
+ with open(output, 'w', encoding="utf-8") as f: f.write(backup)
os.close(fd)
os.remove(path) | false |
Other | mrdoob | three.js | 03a6f0b8ec04ad1222ec0aae6fda024e335e4f2d.json | Move THREE.MouseUtils.BUTTONS enum to THREE.MOUSE | examples/js/controls/OrbitControls.js | @@ -71,7 +71,7 @@ THREE.OrbitControls = function ( object, domElement ) {
this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
// Mouse buttons
- this.mouseButtons = { ORBIT: THREE.MouseUtils.BUTTONS.LEFT, ZOOM: THREE.MouseUtils.BUTTONS.MIDDLE, PAN: THREE.MouseUtils.BUTTONS.RIGHT };
+ this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
////////////
// internals | true |
Other | mrdoob | three.js | 03a6f0b8ec04ad1222ec0aae6fda024e335e4f2d.json | Move THREE.MouseUtils.BUTTONS enum to THREE.MOUSE | src/Three.js | @@ -158,3 +158,11 @@ THREE.RGB_PVRTC_2BPPV1_Format = 2101;
THREE.RGBA_PVRTC_4BPPV1_Format = 2102;
THREE.RGBA_PVRTC_2BPPV1_Format = 2103;
*/
+
+// MouseEvent.button codes per https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
+
+THREE.MOUSE = {
+ LEFT: 0,
+ MIDDLE: 1,
+ RIGHT: 2
+}; | true |
Other | mrdoob | three.js | 03a6f0b8ec04ad1222ec0aae6fda024e335e4f2d.json | Move THREE.MouseUtils.BUTTONS enum to THREE.MOUSE | src/extras/MouseUtils.js | @@ -1,8 +0,0 @@
-/**
- * @author yangchristian
- */
-
-THREE.MouseUtils = {
- // MouseEvent.button codes per https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
- BUTTONS: { LEFT: 0, MIDDLE: 1, RIGHT: 2 }
-};
\ No newline at end of file | true |
Other | mrdoob | three.js | 03a6f0b8ec04ad1222ec0aae6fda024e335e4f2d.json | Move THREE.MouseUtils.BUTTONS enum to THREE.MOUSE | utils/build/includes/extras.json | @@ -1,7 +1,6 @@
[
"src/extras/GeometryUtils.js",
"src/extras/ImageUtils.js",
- "src/extras/MouseUtils.js",
"src/extras/SceneUtils.js",
"src/extras/FontUtils.js",
"src/extras/core/Curve.js", | true |
Other | mrdoob | three.js | 5d1f736f7ff1fd75545a89b9184ceceab0a7737f.json | Add THREE.MouseUtils with BUTTONS enum | examples/js/controls/OrbitControls.js | @@ -23,9 +23,6 @@
THREE.OrbitControls = function ( object, domElement ) {
- // MouseEvent.button codes per https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
- var MOUSEBUTTONS = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
-
this.object = object;
this.domElement = ( domElement !== undefined ) ? domElement : document;
@@ -74,7 +71,7 @@ THREE.OrbitControls = function ( object, domElement ) {
this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
// Mouse buttons
- this.mouseButtons = { ORBIT: MOUSEBUTTONS.LEFT, ZOOM: MOUSEBUTTONS.MIDDLE, PAN: MOUSEBUTTONS.RIGHT };
+ this.mouseButtons = { ORBIT: THREE.MouseUtils.BUTTONS.LEFT, ZOOM: THREE.MouseUtils.BUTTONS.MIDDLE, PAN: THREE.MouseUtils.BUTTONS.RIGHT };
////////////
// internals | true |
Other | mrdoob | three.js | 5d1f736f7ff1fd75545a89b9184ceceab0a7737f.json | Add THREE.MouseUtils with BUTTONS enum | src/extras/MouseUtils.js | @@ -0,0 +1,8 @@
+/**
+ * @author yangchristian
+ */
+
+THREE.MouseUtils = {
+ // MouseEvent.button codes per https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
+ BUTTONS: { LEFT: 0, MIDDLE: 1, RIGHT: 2 }
+};
\ No newline at end of file | true |
Other | mrdoob | three.js | 5d1f736f7ff1fd75545a89b9184ceceab0a7737f.json | Add THREE.MouseUtils with BUTTONS enum | utils/build/includes/extras.json | @@ -1,6 +1,7 @@
[
"src/extras/GeometryUtils.js",
"src/extras/ImageUtils.js",
+ "src/extras/MouseUtils.js",
"src/extras/SceneUtils.js",
"src/extras/FontUtils.js",
"src/extras/core/Curve.js", | true |
Other | mrdoob | three.js | b17e3a5d557521fa9195267195de4305b276c464.json | Add clone property to BufferAttribute.js
Based off BufferGeometry implementation | src/core/BufferAttribute.js | @@ -100,6 +100,31 @@ THREE.BufferAttribute.prototype = {
return this;
+ },
+
+ clone: function () {
+
+ var attribute = new THREE.BufferAttribute( null, this.itemSize );
+
+ var types = [ Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array ];
+
+ var sourceArray = this.array;
+
+ for ( var i = 0, il = types.length; i < il; i ++ ) {
+
+ var type = types[ i ];
+
+ if ( sourceArray instanceof type ) {
+
+ attribute.array = new type( sourceArray );
+ break;
+
+ }
+
+ }
+
+ return attribute;
+
}
}; | false |
Other | mrdoob | three.js | d45049f2f71b49f1202e9f29642c7473a4450fed.json | Warn user if we change their texture settings.
If the user set a wrapS or wrapT parameter we should warn him if his
texture is not power of two. We should also warn him if his minFilter
is changing. | src/renderers/WebGLRenderer.js | @@ -5752,10 +5752,17 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
+
+ if ( texture.wrapS !== THREE.ClampToEdgeWrapping || texture.wrapT !== THREE.ClampToEdgeWrapping) {
+ console.warn('Texture is not power of two. Texture.wrapS and Texture.wrapT is set to THREE.ClampToEdgeWrapping. ('+texture.sourceFile+')');
+ }
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
+ if ( texture.minFilter !== THREE.NearestFilter && texture.minFilter !== THREE.LinearFilter) {
+ console.warn('Texture is not power of two. Texture.minFilter is set to THREE.LinearFilter or THREE.NearestFilter. ('+texture.sourceFile+')');
+ }
}
extension = extensions.get( 'EXT_texture_filter_anisotropic' ); | false |
Other | mrdoob | three.js | 40bf24157abd4d17555cd9afa49646b3e286d06e.json | add a simple example | docs/api/loaders/OBJLoader.html | @@ -50,6 +50,21 @@ <h3>[method:Object3D parse]( [page:String text] )</h3>
<h2>Example</h2>
+ <code>
+ // instantiate a loader
+ var loader = new THREE.OBJLoader();
+
+ // load a resource
+ loader.load(
+ // resource URL
+ 'models/skinned/UCS_config.json',
+ // Function when resource is loaded
+ function ( object ) {
+ scene.add( object );
+ }
+ );
+ </code>
+
[example:webgl_loader_obj]
| false |
Other | mrdoob | three.js | 6edb6265a3a0cb7791e0d7a805cc05a1f199b2cd.json | add Loader inheritance | docs/api/loaders/glTFLoader.html | @@ -7,7 +7,7 @@
<link type="text/css" rel="stylesheet" href="../../page.css" />
</head>
<body>
-
+ [page:Loader] →
<h1>[name]</h1>
<div class="desc"> | false |
Other | mrdoob | three.js | f1cd7a72fc2e9e191849f63f3246681d5e6fcc1f.json | fix some todos | docs/api/loaders/Loader.html | @@ -59,7 +59,7 @@ <h3>[method:Boolean needsTangents]( [page:Array materials] )</h3>
Checks if the loaded object needs tangents based on its materials.
</div>
- <h3>[method:todo updateProgress]( [page:object progress] )</h3>
+ <h3>[method:null updateProgress]( [page:object progress] )</h3>
<div>
[page:Object progress] — an object containing loaded(contains the amount of bytes loaded) and optionally total (containing the total amount of bytes).
</div>
@@ -85,7 +85,7 @@ <h3>[method:Array initMaterials]( [page:Array materials], [page:string texturePa
Creates an array of [page:Material] based on the array of parameters m. The index of the parameters decide the correct index of the materials.
</div>
- <h3>[method:todo extractUrlBase]( [page:string url] )</h3>
+ <h3>[method:String extractUrlBase]( [page:string url] )</h3>
<div>
[page:String url] — The url to extract the base url from.
</div> | false |
Other | mrdoob | three.js | e2cffeef012628f4ca0eaff42b9d973497f9845f.json | fix indentation in Blender exporter once more | utils/exporters/blender/2.65/scripts/addons/io_mesh_threejs/export_threejs.py | @@ -2181,7 +2181,7 @@ def generate_cameras(data):
"target" : generate_vec3([0, 0, 0])
}
- elif camera.id_data.type == "ORTHO":
+ elif camera.id_data.type == "ORTHO":
camera_string = TEMPLATE_CAMERA_ORTHO % {
"camera_id" : generate_string(camera.name), | false |
Other | mrdoob | three.js | 6ea8cbae63fd643abbaad3e57c0febbb54390c6f.json | remove 3 fingers controls from TrackballControls | examples/js/controls/TrackballControls.js | @@ -6,7 +6,7 @@
THREE.TrackballControls = function ( object, domElement ) {
var _this = this;
- var STATE = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM: 4, TOUCH_PAN: 5 };
+ var STATE = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM: 4 };
this.object = object;
this.domElement = ( domElement !== undefined ) ? domElement : document;
@@ -505,11 +505,6 @@ THREE.TrackballControls = function ( object, domElement ) {
_panStart = _panEnd = _this.getMouseOnScreen(x, y);
break;
- case 3:
- _state = STATE.TOUCH_PAN;
- _panEnd.copy( _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, _panStart ));
- break;
-
default:
_state = STATE.NONE;
@@ -541,10 +536,6 @@ THREE.TrackballControls = function ( object, domElement ) {
_panEnd = _this.getMouseOnScreen(x, y);
break;
- case 3:
- _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, _panEnd );
- break;
-
default:
_state = STATE.NONE;
@@ -569,10 +560,6 @@ THREE.TrackballControls = function ( object, domElement ) {
_panStart = _panEnd = _this.getMouseOnScreen(x, y);
break;
- case 3:
- _panStart.copy( _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY, _panEnd ));
- break;
-
}
_state = STATE.NONE; | false |
Other | mrdoob | three.js | af763d7aaff2f7bbfee4f4621b8d85db8ec759b5.json | Fix package.json to make 'npm install' work. | utils/build/package.json | @@ -1,7 +1,7 @@
{
"name": "three.js",
"description": "JavaScript 3D library",
- "version": "50dev",
+ "version": "0.0.0",
"homepage" : "http://threejs.org/",
"author": "three.js contributors",
"help": { | false |
Other | mrdoob | three.js | a321ba05f02ae3a1586a4060a53f5ad63b90729b.json | handle another case of line continuation | examples/js/loaders/OBJLoader.js | @@ -192,7 +192,7 @@ THREE.OBJLoader.prototype = {
// fixes
- text = text.replace( /\\\r\n/g, '' ); // handles line continuations \
+ text = text.replace( /\\\r?\n/g, '' ); // handles line continuations \
var lines = text.split( '\n' );
| false |
Other | mrdoob | three.js | 17c71cecde70212a2ed2ddb0ab08a258c8e3af12.json | Remove duplicate test distanceToPoint for Box2.js | test/unit/math/Box2.js | @@ -174,21 +174,6 @@ test( "distanceToPoint", function() {
ok( b.distanceToPoint( new THREE.Vector2( -2, -2 ) ) == Math.sqrt( 2 ), "Passed!" );
});
-test( "distanceToPoint", function() {
- var a = new THREE.Box2( zero2.clone(), zero2.clone() );
- var b = new THREE.Box2( one2.clone().negate(), one2.clone() );
-
- ok( a.distanceToPoint( new THREE.Vector2( 0, 0 ) ) == 0, "Passed!" );
- ok( a.distanceToPoint( new THREE.Vector2( 1, 1 ) ) == Math.sqrt( 2 ), "Passed!" );
- ok( a.distanceToPoint( new THREE.Vector2( -1, -1 ) ) == Math.sqrt( 2 ), "Passed!" );
-
- ok( b.distanceToPoint( new THREE.Vector2( 2, 2 ) ) == Math.sqrt( 2 ), "Passed!" );
- ok( b.distanceToPoint( new THREE.Vector2( 1, 1 ) ) == 0, "Passed!" );
- ok( b.distanceToPoint( new THREE.Vector2( 0, 0 ) ) == 0, "Passed!" );
- ok( b.distanceToPoint( new THREE.Vector2( -1, -1 ) ) == 0, "Passed!" );
- ok( b.distanceToPoint( new THREE.Vector2( -2, -2 ) ) == Math.sqrt( 2 ), "Passed!" );
-});
-
test( "isIntersectionBox", function() {
var a = new THREE.Box2( zero2.clone(), zero2.clone() );
var b = new THREE.Box2( zero2.clone(), one2.clone() );
@@ -242,4 +227,4 @@ test( "translate", function() {
ok( a.clone().translate( one2 ).translate( one2.clone().negate() ).equals( a ), "Passed!" );
ok( d.clone().translate( one2 ).equals( b ), "Passed!" );
ok( b.clone().translate( one2.clone().negate() ).equals( d ), "Passed!" );
-});
\ No newline at end of file
+}); | false |
Other | mrdoob | three.js | b632110d2d8ee69194b31ad2022408b1afb44520.json | add License info to minified build | utils/build/build.py | @@ -79,7 +79,7 @@ def main(argv=None):
# header
with open(output,'r') as f: text = f.read()
- with open(output,'w') as f: f.write('// three.js - http://github.com/mrdoob/three.js\n' + text + sourcemapping)
+ with open(output,'w') as f: f.write('// three.js - http://github.com/mrdoob/three.js\n// Released under the MIT license.\n// https://github.com/mrdoob/three.js/blob/master/LICENSE\n' + text + sourcemapping)
os.close(fd)
os.remove(path) | false |
Other | mrdoob | three.js | 85a7725cbafed1d892e156a0570e178198bef26a.json | Add browserify support - Fixes #4777 | src/Three.js | @@ -6,6 +6,11 @@
var THREE = { REVISION: '68dev' };
+// browserify support
+if (typeof module === 'object') {
+ module.exports = THREE;
+}
+
self.console = self.console || {
info: function () {}, | false |
Other | mrdoob | three.js | 3a950516947a41bfaf650a59347d35ebeb38f21a.json | Add a touch of damping to OrbitControls
Inspired by damping in TrackballControls, adds a little bit of kinetic
friction to OrbitControls. This makes the rotation controls feel much
more physical.
Damping is disabled by default, preserving the existing behavior.
Damping is enabled explicitly in the example. | examples/js/controls/OrbitControls.js | @@ -71,6 +71,14 @@ THREE.OrbitControls = function ( object, domElement ) {
// The four arrow keys
this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
+ // A little bit of damping, as if the mouse movement imparts momentum which
+ // is carried away by kinetic friction. On each update, a step is taken
+ // proportional to this factor times the requested angle change.
+ // 0.0: don't move at all
+ // 0.2: feels physically responsive at about 60 FPS
+ // 1.0: track mouse motion immediately
+ this.damping = 1.0;
+
////////////
// internals
@@ -229,6 +237,18 @@ THREE.OrbitControls = function ( object, domElement ) {
};
+ this.getThetaPhi = function() {
+ // angle from z-axis around y-axis
+
+ var theta = Math.atan2( offset.x, offset.z );
+
+ // angle from y-axis
+
+ var phi = Math.atan2( Math.sqrt( offset.x * offset.x + offset.z * offset.z ), offset.y );
+
+ return [theta, phi];
+ }
+
this.update = function () {
var position = this.object.position;
@@ -238,23 +258,21 @@ THREE.OrbitControls = function ( object, domElement ) {
// rotate offset to "y-axis-is-up" space
offset.applyQuaternion( quat );
- // angle from z-axis around y-axis
+ var thetaPhi = this.getThetaPhi();
+ var theta = thetaPhi[0];
+ var phi = thetaPhi[1];
- var theta = Math.atan2( offset.x, offset.z );
-
- // angle from y-axis
-
- var phi = Math.atan2( Math.sqrt( offset.x * offset.x + offset.z * offset.z ), offset.y );
+ theta += this.damping * thetaDelta;
+ phi += this.damping * phiDelta;
+ thetaDelta *= (1 - this.damping);
+ phiDelta *= (1 - this.damping);
if ( this.autoRotate ) {
- this.rotateLeft( getAutoRotationAngle() );
+ theta += getAutoRotationAngle();
}
- theta += thetaDelta;
- phi += phiDelta;
-
// restrict phi to be between desired limits
phi = Math.max( this.minPolarAngle, Math.min( this.maxPolarAngle, phi ) );
@@ -280,8 +298,6 @@ THREE.OrbitControls = function ( object, domElement ) {
this.object.lookAt( this.target );
- thetaDelta = 0;
- phiDelta = 0;
scale = 1;
pan.set( 0, 0, 0 );
| true |
Other | mrdoob | three.js | 3a950516947a41bfaf650a59347d35ebeb38f21a.json | Add a touch of damping to OrbitControls
Inspired by damping in TrackballControls, adds a little bit of kinetic
friction to OrbitControls. This makes the rotation controls feel much
more physical.
Damping is disabled by default, preserving the existing behavior.
Damping is enabled explicitly in the example. | examples/misc_controls_orbit.html | @@ -55,12 +55,20 @@
init();
render();
+ function animate() {
+
+ requestAnimationFrame(animate);
+ controls.update();
+
+ }
+
function init() {
camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.z = 500;
controls = new THREE.OrbitControls( camera );
+ controls.damping = 0.2;
controls.addEventListener( 'change', render );
scene = new THREE.Scene();
@@ -117,6 +125,9 @@
window.addEventListener( 'resize', onWindowResize, false );
+ controls.addEventListener('change', render);
+ animate();
+
}
function onWindowResize() { | true |
Other | mrdoob | three.js | 6f01c2dc4b9c79a555de5e0cadb25f8bc825c7af.json | Add SVGLoader. See #4429 | src/loaders/SVGLoader.js | @@ -0,0 +1,31 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ * @author zz85 / http://joshuakoo.com/
+ */
+
+THREE.SVGLoader = function ( manager ) {
+
+ this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+
+};
+
+THREE.SVGLoader.prototype = {
+
+ constructor: THREE.MaterialLoader,
+
+ load: function ( url, onLoad, onProgress, onError ) {
+
+ var parser = new DOMParser();
+
+ var loader = new THREE.XHRLoader();
+ loader.setCrossOrigin( this.crossOrigin );
+ loader.load( url, function ( svgString ) {
+
+ var doc = parser.parseFromString( svgString, 'image/svg+xml' ); // application/xml
+
+ onLoad( doc.firstChild );
+
+ } );
+
+ }
+};
\ No newline at end of file | false |
Other | mrdoob | three.js | 8375a6f421c3a761b48fa2c26318d92b7fc8fd49.json | Use clamp for clampScalar implementation | src/math/Vector2.js | @@ -226,46 +226,45 @@ THREE.Vector2.prototype = {
return this;
},
- clampScalar: function ( minVal, maxVal ) {
-
- if ( this.x < minVal ) {
- this.x = minVal;
- } else if ( this.x > maxVal ) {
- this.x = maxVal;
- }
-
- if ( this.y < minVal ) {
- this.y = minVal;
- } else if ( this.y > maxVal ) {
- this.y = maxVal;
- }
-
- return this;
- },
-
- floor: function() {
- this.x = Math.floor(this.x);
- this.y = Math.floor(this.y);
- return this;
- },
-
- ceil: function() {
- this.x = Math.ceil(this.x);
- this.y = Math.ceil(this.y);
- return this;
- },
-
- round: function() {
- this.x = Math.round(this.x);
- this.y = Math.round(this.y);
- return this;
- },
-
- roundToZero: function() {
- this.x = (this.x < 0) ? Math.ceil(this.x) : Math.floor(this.x);
- this.y = (this.y < 0) ? Math.ceil(this.y) : Math.floor(this.y);
- return this;
- },
+ clampScalar: ( function () {
+ var min, max;
+
+ return function ( minVal, maxVal ) {
+ if ( !min || !max ) {
+ min = new THREE.Vector2();
+ max = new THREE.Vector2();
+ }
+
+ min.set(minVal, minVal);
+ max.set(maxVal, maxVal);
+ return this.clamp(min, max);
+
+ };
+ } )(),
+
+ floor: function() {
+ this.x = Math.floor(this.x);
+ this.y = Math.floor(this.y);
+ return this;
+ },
+
+ ceil: function() {
+ this.x = Math.ceil(this.x);
+ this.y = Math.ceil(this.y);
+ return this;
+ },
+
+ round: function() {
+ this.x = Math.round(this.x);
+ this.y = Math.round(this.y);
+ return this;
+ },
+
+ roundToZero: function() {
+ this.x = (this.x < 0) ? Math.ceil(this.x) : Math.floor(this.x);
+ this.y = (this.y < 0) ? Math.ceil(this.y) : Math.floor(this.y);
+ return this;
+ },
negate: function() {
| true |