Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
9b260d89
T
three.js
项目概览
Ablesons
/
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,发现更多精彩内容 >>
提交
9b260d89
编写于
6月 20, 2017
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebGLRenderer: Moved background code to WebGLBackground.
上级
3c4b4b81
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
148 addition
and
121 deletion
+148
-121
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+9
-121
src/renderers/webgl/WebGLBackground.js
src/renderers/webgl/WebGLBackground.js
+139
-0
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
9b260d89
import
{
REVISION
,
MaxEquation
,
MinEquation
,
RGB_ETC1_Format
,
RGBA_PVRTC_2BPPV1_Format
,
RGBA_PVRTC_4BPPV1_Format
,
RGB_PVRTC_2BPPV1_Format
,
RGB_PVRTC_4BPPV1_Format
,
RGBA_S3TC_DXT5_Format
,
RGBA_S3TC_DXT3_Format
,
RGBA_S3TC_DXT1_Format
,
RGB_S3TC_DXT1_Format
,
SrcAlphaSaturateFactor
,
OneMinusDstColorFactor
,
DstColorFactor
,
OneMinusDstAlphaFactor
,
DstAlphaFactor
,
OneMinusSrcAlphaFactor
,
SrcAlphaFactor
,
OneMinusSrcColorFactor
,
SrcColorFactor
,
OneFactor
,
ZeroFactor
,
ReverseSubtractEquation
,
SubtractEquation
,
AddEquation
,
DepthFormat
,
DepthStencilFormat
,
LuminanceAlphaFormat
,
LuminanceFormat
,
RGBAFormat
,
RGBFormat
,
AlphaFormat
,
HalfFloatType
,
FloatType
,
UnsignedIntType
,
IntType
,
UnsignedShortType
,
ShortType
,
ByteType
,
UnsignedInt248Type
,
UnsignedShort565Type
,
UnsignedShort5551Type
,
UnsignedShort4444Type
,
UnsignedByteType
,
LinearMipMapLinearFilter
,
LinearMipMapNearestFilter
,
LinearFilter
,
NearestMipMapLinearFilter
,
NearestMipMapNearestFilter
,
NearestFilter
,
MirroredRepeatWrapping
,
ClampToEdgeWrapping
,
RepeatWrapping
,
FrontFaceDirectionCW
,
NoBlending
,
BackSide
,
TriangleFanDrawMode
,
TriangleStripDrawMode
,
TrianglesDrawMode
,
NoColors
,
FlatShading
,
LinearToneMapping
}
from
'
../constants
'
;
import
{
REVISION
,
MaxEquation
,
MinEquation
,
RGB_ETC1_Format
,
RGBA_PVRTC_2BPPV1_Format
,
RGBA_PVRTC_4BPPV1_Format
,
RGB_PVRTC_2BPPV1_Format
,
RGB_PVRTC_4BPPV1_Format
,
RGBA_S3TC_DXT5_Format
,
RGBA_S3TC_DXT3_Format
,
RGBA_S3TC_DXT1_Format
,
RGB_S3TC_DXT1_Format
,
SrcAlphaSaturateFactor
,
OneMinusDstColorFactor
,
DstColorFactor
,
OneMinusDstAlphaFactor
,
DstAlphaFactor
,
OneMinusSrcAlphaFactor
,
SrcAlphaFactor
,
OneMinusSrcColorFactor
,
SrcColorFactor
,
OneFactor
,
ZeroFactor
,
ReverseSubtractEquation
,
SubtractEquation
,
AddEquation
,
DepthFormat
,
DepthStencilFormat
,
LuminanceAlphaFormat
,
LuminanceFormat
,
RGBAFormat
,
RGBFormat
,
AlphaFormat
,
HalfFloatType
,
FloatType
,
UnsignedIntType
,
IntType
,
UnsignedShortType
,
ShortType
,
ByteType
,
UnsignedInt248Type
,
UnsignedShort565Type
,
UnsignedShort5551Type
,
UnsignedShort4444Type
,
UnsignedByteType
,
LinearMipMapLinearFilter
,
LinearMipMapNearestFilter
,
LinearFilter
,
NearestMipMapLinearFilter
,
NearestMipMapNearestFilter
,
NearestFilter
,
MirroredRepeatWrapping
,
ClampToEdgeWrapping
,
RepeatWrapping
,
FrontFaceDirectionCW
,
NoBlending
,
TriangleFanDrawMode
,
TriangleStripDrawMode
,
TrianglesDrawMode
,
NoColors
,
FlatShading
,
LinearToneMapping
}
from
'
../constants
'
;
import
{
_Math
}
from
'
../math/Math
'
;
import
{
Matrix4
}
from
'
../math/Matrix4
'
;
import
{
DataTexture
}
from
'
../textures/DataTexture
'
;
...
...
@@ -9,14 +9,8 @@ import { ShaderLib } from './shaders/ShaderLib';
import
{
LensFlarePlugin
}
from
'
./webgl/plugins/LensFlarePlugin
'
;
import
{
SpritePlugin
}
from
'
./webgl/plugins/SpritePlugin
'
;
import
{
WebGLShadowMap
}
from
'
./webgl/WebGLShadowMap
'
;
import
{
ShaderMaterial
}
from
'
../materials/ShaderMaterial
'
;
import
{
Mesh
}
from
'
../objects/Mesh
'
;
import
{
BoxBufferGeometry
}
from
'
../geometries/BoxGeometry
'
;
import
{
PlaneBufferGeometry
}
from
'
../geometries/PlaneGeometry
'
;
import
{
MeshBasicMaterial
}
from
'
../materials/MeshBasicMaterial
'
;
import
{
PerspectiveCamera
}
from
'
../cameras/PerspectiveCamera
'
;
import
{
OrthographicCamera
}
from
'
../cameras/OrthographicCamera
'
;
import
{
WebGLAttributes
}
from
'
./webgl/WebGLAttributes
'
;
import
{
WebGLBackground
}
from
'
./webgl/WebGLBackground
'
;
import
{
WebGLRenderLists
}
from
'
./webgl/WebGLRenderLists
'
;
import
{
WebGLIndexedBufferRenderer
}
from
'
./webgl/WebGLIndexedBufferRenderer
'
;
import
{
WebGLBufferRenderer
}
from
'
./webgl/WebGLBufferRenderer
'
;
...
...
@@ -36,7 +30,6 @@ import { Vector3 } from '../math/Vector3';
import
{
WebGLClipping
}
from
'
./webgl/WebGLClipping
'
;
import
{
Frustum
}
from
'
../math/Frustum
'
;
import
{
Vector4
}
from
'
../math/Vector4
'
;
import
{
Color
}
from
'
../math/Color
'
;
/**
* @author supereggbert / http://www.paulbrunt.co.uk/
...
...
@@ -139,9 +132,6 @@ function WebGLRenderer( parameters ) {
//
_clearColor
=
new
Color
(
0x000000
),
_clearAlpha
=
0
,
_width
=
_canvas
.
width
,
_height
=
_canvas
.
height
,
...
...
@@ -298,6 +288,8 @@ function WebGLRenderer( parameters ) {
var
programCache
=
new
WebGLPrograms
(
this
,
capabilities
);
var
lightCache
=
new
WebGLLights
();
var
renderLists
=
new
WebGLRenderLists
();
var
background
=
new
WebGLBackground
(
this
,
state
,
objects
,
_premultipliedAlpha
);
var
vr
=
new
WebVRManager
(
this
);
this
.
info
.
programs
=
programCache
.
programs
;
...
...
@@ -307,11 +299,6 @@ function WebGLRenderer( parameters ) {
//
var
backgroundPlaneCamera
,
backgroundPlaneMesh
;
var
backgroundBoxCamera
,
backgroundBoxMesh
;
//
function
getTargetPixelRatio
()
{
return
_currentRenderTarget
===
null
?
_pixelRatio
:
1
;
...
...
@@ -325,8 +312,6 @@ function WebGLRenderer( parameters ) {
state
.
scissor
(
_currentScissor
.
copy
(
_scissor
).
multiplyScalar
(
_pixelRatio
)
);
state
.
viewport
(
_currentViewport
.
copy
(
_viewport
).
multiplyScalar
(
_pixelRatio
)
);
state
.
buffers
.
color
.
setClear
(
_clearColor
.
r
,
_clearColor
.
g
,
_clearColor
.
b
,
_clearAlpha
,
_premultipliedAlpha
);
}
function
resetGLState
()
{
...
...
@@ -462,35 +447,10 @@ function WebGLRenderer( parameters ) {
// Clearing
this
.
getClearColor
=
function
()
{
return
_clearColor
;
};
this
.
setClearColor
=
function
(
color
,
alpha
)
{
_clearColor
.
set
(
color
);
_clearAlpha
=
alpha
!==
undefined
?
alpha
:
1
;
state
.
buffers
.
color
.
setClear
(
_clearColor
.
r
,
_clearColor
.
g
,
_clearColor
.
b
,
_clearAlpha
,
_premultipliedAlpha
);
};
this
.
getClearAlpha
=
function
()
{
return
_clearAlpha
;
};
this
.
setClearAlpha
=
function
(
alpha
)
{
_clearAlpha
=
alpha
;
state
.
buffers
.
color
.
setClear
(
_clearColor
.
r
,
_clearColor
.
g
,
_clearColor
.
b
,
_clearAlpha
,
_premultipliedAlpha
);
};
this
.
getClearColor
=
background
.
getClearColor
;
this
.
setClearColor
=
background
.
setClearColor
;
this
.
getClearAlpha
=
background
.
getClearAlpha
;
this
.
setClearAlpha
=
background
.
setClearAlpha
;
this
.
clear
=
function
(
color
,
depth
,
stencil
)
{
...
...
@@ -1183,79 +1143,7 @@ function WebGLRenderer( parameters ) {
//
var
background
=
scene
.
background
;
if
(
background
===
null
)
{
state
.
buffers
.
color
.
setClear
(
_clearColor
.
r
,
_clearColor
.
g
,
_clearColor
.
b
,
_clearAlpha
,
_premultipliedAlpha
);
}
else
if
(
background
&&
background
.
isColor
)
{
state
.
buffers
.
color
.
setClear
(
background
.
r
,
background
.
g
,
background
.
b
,
1
,
_premultipliedAlpha
);
forceClear
=
true
;
}
if
(
this
.
autoClear
||
forceClear
)
{
this
.
clear
(
this
.
autoClearColor
,
this
.
autoClearDepth
,
this
.
autoClearStencil
);
}
if
(
background
&&
background
.
isCubeTexture
)
{
if
(
backgroundBoxCamera
===
undefined
)
{
backgroundBoxCamera
=
new
PerspectiveCamera
();
backgroundBoxMesh
=
new
Mesh
(
new
BoxBufferGeometry
(
5
,
5
,
5
),
new
ShaderMaterial
(
{
uniforms
:
ShaderLib
.
cube
.
uniforms
,
vertexShader
:
ShaderLib
.
cube
.
vertexShader
,
fragmentShader
:
ShaderLib
.
cube
.
fragmentShader
,
side
:
BackSide
,
depthTest
:
false
,
depthWrite
:
false
,
fog
:
false
}
)
);
}
backgroundBoxCamera
.
projectionMatrix
.
copy
(
camera
.
projectionMatrix
);
backgroundBoxCamera
.
matrixWorld
.
extractRotation
(
camera
.
matrixWorld
);
backgroundBoxCamera
.
matrixWorldInverse
.
getInverse
(
backgroundBoxCamera
.
matrixWorld
);
backgroundBoxMesh
.
material
.
uniforms
[
"
tCube
"
].
value
=
background
;
backgroundBoxMesh
.
modelViewMatrix
.
multiplyMatrices
(
backgroundBoxCamera
.
matrixWorldInverse
,
backgroundBoxMesh
.
matrixWorld
);
objects
.
update
(
backgroundBoxMesh
);
_this
.
renderBufferDirect
(
backgroundBoxCamera
,
null
,
backgroundBoxMesh
.
geometry
,
backgroundBoxMesh
.
material
,
backgroundBoxMesh
,
null
);
}
else
if
(
background
&&
background
.
isTexture
)
{
if
(
backgroundPlaneCamera
===
undefined
)
{
backgroundPlaneCamera
=
new
OrthographicCamera
(
-
1
,
1
,
1
,
-
1
,
0
,
1
);
backgroundPlaneMesh
=
new
Mesh
(
new
PlaneBufferGeometry
(
2
,
2
),
new
MeshBasicMaterial
(
{
depthTest
:
false
,
depthWrite
:
false
,
fog
:
false
}
)
);
}
backgroundPlaneMesh
.
material
.
map
=
background
;
objects
.
update
(
backgroundPlaneMesh
);
_this
.
renderBufferDirect
(
backgroundPlaneCamera
,
null
,
backgroundPlaneMesh
.
geometry
,
backgroundPlaneMesh
.
material
,
backgroundPlaneMesh
,
null
);
}
background
.
render
(
scene
,
camera
,
forceClear
);
// render scene
...
...
src/renderers/webgl/WebGLBackground.js
0 → 100644
浏览文件 @
9b260d89
/**
* @author mrdoob / http://mrdoob.com/
*/
import
{
BackSide
}
from
'
../../constants
'
;
import
{
OrthographicCamera
}
from
'
../../cameras/OrthographicCamera
'
;
import
{
PerspectiveCamera
}
from
'
../../cameras/PerspectiveCamera
'
;
import
{
BoxBufferGeometry
}
from
'
../../geometries/BoxGeometry
'
;
import
{
PlaneBufferGeometry
}
from
'
../../geometries/PlaneGeometry
'
;
import
{
MeshBasicMaterial
}
from
'
../../materials/MeshBasicMaterial
'
;
import
{
ShaderMaterial
}
from
'
../../materials/ShaderMaterial
'
;
import
{
Color
}
from
'
../../math/Color
'
;
import
{
Mesh
}
from
'
../../objects/Mesh
'
;
import
{
ShaderLib
}
from
'
../shaders/ShaderLib
'
;
function
WebGLBackground
(
renderer
,
state
,
objects
,
premultipliedAlpha
)
{
var
clearColor
=
new
Color
(
0x000000
);
var
clearAlpha
=
0
;
var
planeCamera
,
planeMesh
;
var
boxCamera
,
boxMesh
;
function
render
(
scene
,
camera
,
forceClear
)
{
var
background
=
scene
.
background
;
if
(
background
===
null
)
{
setClear
(
clearColor
,
clearAlpha
);
}
else
if
(
background
&&
background
.
isColor
)
{
setClear
(
background
,
1
);
forceClear
=
true
;
}
if
(
renderer
.
autoClear
||
forceClear
)
{
renderer
.
clear
(
renderer
.
autoClearColor
,
renderer
.
autoClearDepth
,
renderer
.
autoClearStencil
);
}
if
(
background
&&
background
.
isCubeTexture
)
{
if
(
boxCamera
===
undefined
)
{
boxCamera
=
new
PerspectiveCamera
();
boxMesh
=
new
Mesh
(
new
BoxBufferGeometry
(
5
,
5
,
5
),
new
ShaderMaterial
(
{
uniforms
:
ShaderLib
.
cube
.
uniforms
,
vertexShader
:
ShaderLib
.
cube
.
vertexShader
,
fragmentShader
:
ShaderLib
.
cube
.
fragmentShader
,
side
:
BackSide
,
depthTest
:
false
,
depthWrite
:
false
,
fog
:
false
}
)
);
}
boxCamera
.
projectionMatrix
.
copy
(
camera
.
projectionMatrix
);
boxCamera
.
matrixWorld
.
extractRotation
(
camera
.
matrixWorld
);
boxCamera
.
matrixWorldInverse
.
getInverse
(
boxCamera
.
matrixWorld
);
boxMesh
.
material
.
uniforms
[
"
tCube
"
].
value
=
background
;
boxMesh
.
modelViewMatrix
.
multiplyMatrices
(
boxCamera
.
matrixWorldInverse
,
boxMesh
.
matrixWorld
);
objects
.
update
(
boxMesh
);
renderer
.
renderBufferDirect
(
boxCamera
,
null
,
boxMesh
.
geometry
,
boxMesh
.
material
,
boxMesh
,
null
);
}
else
if
(
background
&&
background
.
isTexture
)
{
if
(
planeCamera
===
undefined
)
{
planeCamera
=
new
OrthographicCamera
(
-
1
,
1
,
1
,
-
1
,
0
,
1
);
planeMesh
=
new
Mesh
(
new
PlaneBufferGeometry
(
2
,
2
),
new
MeshBasicMaterial
(
{
depthTest
:
false
,
depthWrite
:
false
,
fog
:
false
}
)
);
}
planeMesh
.
material
.
map
=
background
;
objects
.
update
(
planeMesh
);
renderer
.
renderBufferDirect
(
planeCamera
,
null
,
planeMesh
.
geometry
,
planeMesh
.
material
,
planeMesh
,
null
);
}
}
function
setClear
(
color
,
alpha
)
{
state
.
buffers
.
color
.
setClear
(
color
.
r
,
color
.
g
,
color
.
b
,
alpha
,
premultipliedAlpha
);
}
return
{
getClearColor
:
function
()
{
return
clearColor
;
},
setClearColor
:
function
(
color
,
alpha
)
{
clearColor
.
set
(
color
);
clearAlpha
=
alpha
!==
undefined
?
alpha
:
1
;
setClear
(
clearColor
,
clearAlpha
);
},
getClearAlpha
:
function
()
{
return
clearAlpha
;
},
setClearAlpha
:
function
(
alpha
)
{
clearAlpha
=
alpha
;
setClear
(
clearColor
,
clearAlpha
);
},
render
:
render
};
}
export
{
WebGLBackground
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录