Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
a1dae33e
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a1dae33e
编写于
11月 18, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
1900b262
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
269 addition
and
269 deletion
+269
-269
build/three.js
build/three.js
+142
-142
build/three.min.js
build/three.min.js
+127
-127
未找到文件。
build/three.js
浏览文件 @
a1dae33e
...
@@ -36176,7 +36176,7 @@ THREE.ShadowMapPlugin.__projector = new THREE.Projector();
...
@@ -36176,7 +36176,7 @@ THREE.ShadowMapPlugin.__projector = new THREE.Projector();
THREE.SpritePlugin = function () {
THREE.SpritePlugin = function () {
var _gl, _renderer, _
precision
;
var _gl, _renderer, _
texture
;
var vertices, faces, vertexBuffer, elementBuffer;
var vertices, faces, vertexBuffer, elementBuffer;
var program, attributes, uniforms;
var program, attributes, uniforms;
...
@@ -36186,8 +36186,6 @@ THREE.SpritePlugin = function () {
...
@@ -36186,8 +36186,6 @@ THREE.SpritePlugin = function () {
_gl = renderer.context;
_gl = renderer.context;
_renderer = renderer;
_renderer = renderer;
_precision = renderer.getPrecision();
vertices = new Float32Array( [
vertices = new Float32Array( [
- 0.5, - 0.5, 0, 0,
- 0.5, - 0.5, 0, 0,
0.5, - 0.5, 1, 0,
0.5, - 0.5, 1, 0,
...
@@ -36209,7 +36207,7 @@ THREE.SpritePlugin = function () {
...
@@ -36209,7 +36207,7 @@ THREE.SpritePlugin = function () {
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, elementBuffer );
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, elementBuffer );
_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, faces, _gl.STATIC_DRAW );
_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, faces, _gl.STATIC_DRAW );
program = createProgram(
THREE.ShaderSprite[ 'sprite' ], _precision
);
program = createProgram();
attributes = {
attributes = {
position: _gl.getAttribLocation ( program, 'position' ),
position: _gl.getAttribLocation ( program, 'position' ),
...
@@ -36231,15 +36229,26 @@ THREE.SpritePlugin = function () {
...
@@ -36231,15 +36229,26 @@ THREE.SpritePlugin = function () {
modelViewMatrix: _gl.getUniformLocation( program, 'modelViewMatrix' ),
modelViewMatrix: _gl.getUniformLocation( program, 'modelViewMatrix' ),
projectionMatrix: _gl.getUniformLocation( program, 'projectionMatrix' ),
projectionMatrix: _gl.getUniformLocation( program, 'projectionMatrix' ),
fogType:
_gl.getUniformLocation( program, 'fogType' ),
fogType: _gl.getUniformLocation( program, 'fogType' ),
fogDensity:
_gl.getUniformLocation( program, 'fogDensity' ),
fogDensity:
_gl.getUniformLocation( program, 'fogDensity' ),
fogNear:
_gl.getUniformLocation( program, 'fogNear' ),
fogNear: _gl.getUniformLocation( program, 'fogNear' ),
fogFar:
_gl.getUniformLocation( program, 'fogFar' ),
fogFar:
_gl.getUniformLocation( program, 'fogFar' ),
fogColor:
_gl.getUniformLocation( program, 'fogColor' ),
fogColor: _gl.getUniformLocation( program, 'fogColor' ),
alphaTest:
_gl.getUniformLocation( program, 'alphaTest' )
alphaTest: _gl.getUniformLocation( program, 'alphaTest' )
};
};
var canvas = document.createElement( 'canvas' );
canvas.width = 8;
canvas.height = 8;
var context = canvas.getContext( '2d' );
context.fillStyle = '#ffffff';
context.fillRect( 0, 0, canvas.width, canvas.height );
_texture = new THREE.Texture( canvas );
_texture.needsUpdate = true;
};
};
this.render = function ( scene, camera, viewportWidth, viewportHeight ) {
this.render = function ( scene, camera, viewportWidth, viewportHeight ) {
...
@@ -36332,54 +36341,60 @@ THREE.SpritePlugin = function () {
...
@@ -36332,54 +36341,60 @@ THREE.SpritePlugin = function () {
for( i = 0; i < nSprites; i ++ ) {
for( i = 0; i < nSprites; i ++ ) {
sprite = sprites[ i ];
sprite = sprites[ i ];
if ( sprite.visible === false ) continue;
material = sprite.material;
material = sprite.material;
if ( ! sprite.visible || material.opacity === 0 ) continue;
_gl.uniform1f( uniforms.alphaTest, material.alphaTest );
_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, sprite._modelViewMatrix.elements );
if ( material.map && material.map.image && material.map.image.width ) {
scale[ 0 ] = sprite.scale.x;
scale[ 1 ] = sprite.scale.y;
_gl.uniform1f( uniforms.alphaTest, material.alphaTest );
if ( scene.fog && material.fog ) {
_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, sprite._modelViewMatrix.elements );
scale[ 0 ] = sprite.scale.x;
fogType = sceneFogType;
scale[ 1 ] = sprite.scale.y;
if ( scene.fog && material.fog )
{
} else
{
fogType = sceneFogType
;
fogType = 0
;
} else {
}
fogType = 0;
if ( oldFogType !== fogType ) {
}
_gl.uniform1i( uniforms.fogType, fogType );
oldFogType = fogType;
if ( oldFogType !== fogType ) {
}
_gl.uniform1i( uniforms.fogType, fogType
);
_gl.uniform2f( uniforms.uvScale, material.uvScale.x, material.uvScale.y
);
oldFogType = fogType
;
_gl.uniform2f( uniforms.uvOffset, material.uvOffset.x, material.uvOffset.y )
;
}
_gl.uniform1f( uniforms.opacity, material.opacity );
_gl.uniform3f( uniforms.color, material.color.r, material.color.g, material.color.b );
_gl.uniform2f( uniforms.uvScale, material.uvScale.x, material.uvScale.y );
_gl.uniform1f( uniforms.rotation, material.rotation );
_gl.uniform2f( uniforms.uvOffset, material.uvOffset.x, material.uvOffset.y );
_gl.uniform2fv( uniforms.scale, scale );
_gl.uniform2f( uniforms.halfViewport, halfViewportWidth, halfViewportHeight );
_gl.uniform1f( uniforms.opacity, material.opacity );
_renderer.setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst );
_gl.uniform3f( uniforms.color, material.color.r, material.color.g, material.color.b );
_renderer.setDepthTest( material.depthTest );
_renderer.setDepthWrite( material.depthWrite );
_gl.uniform1f( uniforms.rotation, material.rotation );
if ( material.map && material.map.image && material.map.image.width ) {
_gl.uniform2fv( uniforms.scale, scale );
_gl.uniform2f( uniforms.halfViewport, halfViewportWidth, halfViewportHeight );
_renderer.setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst );
_renderer.setDepthTest( material.depthTest );
_renderer.setDepthWrite( material.depthWrite );
_renderer.setTexture( material.map, 0 );
_renderer.setTexture( material.map, 0 );
_gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 );
} else {
_renderer.setTexture( _texture, 0 );
}
}
_gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 );
}
}
// restore gl
// restore gl
...
@@ -36388,23 +36403,107 @@ THREE.SpritePlugin = function () {
...
@@ -36388,23 +36403,107 @@ THREE.SpritePlugin = function () {
};
};
function createProgram (
shader, precision
) {
function createProgram () {
var program = _gl.createProgram();
var program = _gl.createProgram();
var fragmentShader = _gl.createShader( _gl.FRAGMENT_SHADER );
var vertexShader = _gl.createShader( _gl.VERTEX_SHADER );
var vertexShader = _gl.createShader( _gl.VERTEX_SHADER );
var fragmentShader = _gl.createShader( _gl.FRAGMENT_SHADER );
var prefix = 'precision ' + precision + ' float;\n';
_gl.shaderSource( vertexShader, [
_gl.shaderSource( fragmentShader, prefix + shader.fragmentShader );
'precision ' + _renderer.getPrecision() + ' float;',
_gl.shaderSource( vertexShader, prefix + shader.vertexShader );
'uniform mat4 modelViewMatrix;',
'uniform mat4 projectionMatrix;',
'uniform float rotation;',
'uniform vec2 scale;',
'uniform vec2 uvOffset;',
'uniform vec2 uvScale;',
'uniform vec2 halfViewport;',
'attribute vec2 position;',
'attribute vec2 uv;',
'varying vec2 vUV;',
'void main() {',
'vUV = uvOffset + uv * uvScale;',
'vec2 alignedPosition = position * scale;',
'vec2 rotatedPosition;',
'rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;',
'rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;',
'vec4 finalPosition;',
'finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );',
'finalPosition.xy += rotatedPosition;',
'finalPosition = projectionMatrix * finalPosition;',
'gl_Position = finalPosition;',
'}'
].join( '\n' ) );
_gl.shaderSource( fragmentShader, [
'precision ' + _renderer.getPrecision() + ' float;',
'uniform vec3 color;',
'uniform sampler2D map;',
'uniform float opacity;',
'uniform int fogType;',
'uniform vec3 fogColor;',
'uniform float fogDensity;',
'uniform float fogNear;',
'uniform float fogFar;',
'uniform float alphaTest;',
'varying vec2 vUV;',
'void main() {',
'vec4 texture = texture2D( map, vUV );',
'if ( texture.a < alphaTest ) discard;',
'gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );',
'if ( fogType > 0 ) {',
'float depth = gl_FragCoord.z / gl_FragCoord.w;',
'float fogFactor = 0.0;',
'if ( fogType == 1 ) {',
'fogFactor = smoothstep( fogNear, fogFar, depth );',
'} else {',
'const float LOG2 = 1.442695;',
'float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );',
'fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );',
'}',
'gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );',
'}',
'}'
].join( '\n' ) );
_gl.compileShader( fragmentShader );
_gl.compileShader( vertexShader );
_gl.compileShader( vertexShader );
_gl.compileShader( fragmentShader );
_gl.attachShader( program, fragmentShader );
_gl.attachShader( program, vertexShader );
_gl.attachShader( program, vertexShader );
_gl.attachShader( program, fragmentShader );
_gl.linkProgram( program );
_gl.linkProgram( program );
...
@@ -36815,102 +36914,3 @@ THREE.ShaderFlares = {
...
@@ -36815,102 +36914,3 @@ THREE.ShaderFlares = {
};
};
/**
* @author mikael emtinger / http://gomo.se/
* @author alteredq / http://alteredqualia.com/
*
*/
THREE.ShaderSprite = {
'sprite': {
vertexShader: [
"uniform mat4 modelViewMatrix;",
"uniform mat4 projectionMatrix;",
"uniform float rotation;",
"uniform vec2 scale;",
"uniform vec2 uvOffset;",
"uniform vec2 uvScale;",
"uniform vec2 halfViewport;",
"attribute vec2 position;",
"attribute vec2 uv;",
"varying vec2 vUV;",
"void main() {",
"vUV = uvOffset + uv * uvScale;",
"vec2 alignedPosition = position * scale;",
"vec2 rotatedPosition;",
"rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;",
"rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;",
"vec4 finalPosition;",
"finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );",
"finalPosition.xy += rotatedPosition;",
"finalPosition = projectionMatrix * finalPosition;",
"gl_Position = finalPosition;",
"}"
].join( "\n" ),
fragmentShader: [
"uniform vec3 color;",
"uniform sampler2D map;",
"uniform float opacity;",
"uniform int fogType;",
"uniform vec3 fogColor;",
"uniform float fogDensity;",
"uniform float fogNear;",
"uniform float fogFar;",
"uniform float alphaTest;",
"varying vec2 vUV;",
"void main() {",
"vec4 texture = texture2D( map, vUV );",
"if ( texture.a < alphaTest ) discard;",
"gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );",
"if ( fogType > 0 ) {",
"float depth = gl_FragCoord.z / gl_FragCoord.w;",
"float fogFactor = 0.0;",
"if ( fogType == 1 ) {",
"fogFactor = smoothstep( fogNear, fogFar, depth );",
"} else {",
"const float LOG2 = 1.442695;",
"float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );",
"fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );",
"}",
"gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );",
"}",
"}"
].join( "\n" )
}
};
build/three.min.js
浏览文件 @
a1dae33e
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录