Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
8546eb7b
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,发现更多精彩内容 >>
提交
8546eb7b
编写于
12月 12, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CanvasRenderer/SVGRenderer/SoftwareRenderer: Added basic scene.background support.
上级
8382c998
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
22 deletion
+59
-22
examples/js/renderers/CanvasRenderer.js
examples/js/renderers/CanvasRenderer.js
+12
-1
examples/js/renderers/SVGRenderer.js
examples/js/renderers/SVGRenderer.js
+19
-3
examples/js/renderers/SoftwareRenderer.js
examples/js/renderers/SoftwareRenderer.js
+28
-18
未找到文件。
examples/js/renderers/CanvasRenderer.js
浏览文件 @
8546eb7b
...
...
@@ -319,7 +319,18 @@ THREE.CanvasRenderer = function ( parameters ) {
}
if
(
this
.
autoClear
===
true
)
this
.
clear
();
var
background
=
scene
.
background
;
if
(
background
&&
background
.
isColor
)
{
setFillStyle
(
'
rgb(
'
+
Math
.
floor
(
background
.
r
*
255
)
+
'
,
'
+
Math
.
floor
(
background
.
g
*
255
)
+
'
,
'
+
Math
.
floor
(
background
.
b
*
255
)
+
'
)
'
);
_context
.
fillRect
(
0
,
0
,
_canvasWidth
,
_canvasHeight
);
}
else
if
(
this
.
autoClear
===
true
)
{
this
.
clear
();
}
_this
.
info
.
render
.
vertices
=
0
;
_this
.
info
.
render
.
faces
=
0
;
...
...
examples/js/renderers/SVGRenderer.js
浏览文件 @
8546eb7b
...
...
@@ -104,7 +104,7 @@ THREE.SVGRenderer = function () {
};
this
.
clear
=
function
()
{
function
removeChildNodes
()
{
_pathCount
=
0
;
_lineCount
=
0
;
...
...
@@ -116,7 +116,12 @@ THREE.SVGRenderer = function () {
}
_svg
.
style
.
backgroundColor
=
'
rgba(
'
+
(
(
_clearColor
.
r
*
255
)
|
0
)
+
'
,
'
+
(
(
_clearColor
.
g
*
255
)
|
0
)
+
'
,
'
+
(
(
_clearColor
.
b
*
255
)
|
0
)
+
'
,
'
+
_clearAlpha
+
'
)
'
;
}
this
.
clear
=
function
()
{
removeChildNodes
();
_svg
.
style
.
backgroundColor
=
'
rgba(
'
+
Math
.
floor
(
_clearColor
.
r
*
255
)
+
'
,
'
+
Math
.
floor
(
_clearColor
.
g
*
255
)
+
'
,
'
+
Math
.
floor
(
_clearColor
.
b
*
255
)
+
'
,
'
+
_clearAlpha
+
'
)
'
;
};
...
...
@@ -129,7 +134,18 @@ THREE.SVGRenderer = function () {
}
if
(
this
.
autoClear
===
true
)
this
.
clear
();
var
background
=
scene
.
background
;
if
(
background
&&
background
.
isColor
)
{
removeChildNodes
();
_svg
.
style
.
backgroundColor
=
'
rgb(
'
+
Math
.
floor
(
background
.
r
*
255
)
+
'
,
'
+
Math
.
floor
(
background
.
g
*
255
)
+
'
,
'
+
Math
.
floor
(
background
.
b
*
255
)
+
'
)
'
;
}
else
if
(
this
.
autoClear
===
true
)
{
this
.
clear
();
}
_this
.
info
.
render
.
vertices
=
0
;
_this
.
info
.
render
.
faces
=
0
;
...
...
examples/js/renderers/SoftwareRenderer.js
浏览文件 @
8546eb7b
...
...
@@ -18,7 +18,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
var
context
=
canvas
.
getContext
(
'
2d
'
,
{
alpha
:
parameters
.
alpha
===
true
}
);
var
alpha
=
parameters
.
alpha
;
var
shaders
=
{};
...
...
@@ -81,7 +81,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
this
.
setClearColor
=
function
(
color
,
alpha
)
{
clearColor
.
set
(
color
);
clea
nColorBuffer
(
);
clea
rColorBuffer
(
clearColor
);
};
...
...
@@ -131,7 +131,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
}
clea
nColorBuffer
(
);
clea
rColorBuffer
(
clearColor
);
};
...
...
@@ -156,10 +156,19 @@ THREE.SoftwareRenderer = function ( parameters ) {
};
// TODO: Check why autoClear can't be false.
this
.
render
=
function
(
scene
,
camera
)
{
if
(
this
.
autoClear
===
true
)
this
.
clear
();
// TODO: Check why autoClear can't be false.
this
.
clear
();
var
background
=
scene
.
background
;
if
(
background
&&
background
.
isColor
)
{
clearColorBuffer
(
background
);
}
var
renderData
=
projector
.
projectScene
(
scene
,
camera
,
false
,
false
);
var
elements
=
renderData
.
elements
;
...
...
@@ -362,23 +371,24 @@ THREE.SoftwareRenderer = function ( parameters ) {
}
cleanColorBuffer
();
clearColorBuffer
(
clearColor
);
}
function
clea
nColorBuffer
(
)
{
function
clea
rColorBuffer
(
color
)
{
var
size
=
canvasWidth
*
canvasHeight
*
4
;
for
(
var
i
=
0
;
i
<
size
;
i
+=
4
)
{
data
[
i
]
=
c
learC
olor
.
r
*
255
|
0
;
data
[
i
+
1
]
=
c
learC
olor
.
g
*
255
|
0
;
data
[
i
+
2
]
=
c
learC
olor
.
b
*
255
|
0
;
data
[
i
]
=
color
.
r
*
255
|
0
;
data
[
i
+
1
]
=
color
.
g
*
255
|
0
;
data
[
i
+
2
]
=
color
.
b
*
255
|
0
;
data
[
i
+
3
]
=
alpha
?
0
:
255
;
}
context
.
fillStyle
=
alpha
?
"
rgba(0, 0, 0, 0)
"
:
c
learC
olor
.
getStyle
();
context
.
fillStyle
=
alpha
?
"
rgba(0, 0, 0, 0)
"
:
color
.
getStyle
();
context
.
fillRect
(
0
,
0
,
canvasWidth
,
canvasHeight
);
}
...
...
@@ -461,7 +471,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
var
destR
=
buffer
[
colorOffset
];
var
destG
=
buffer
[
colorOffset
+
1
];
var
destB
=
buffer
[
colorOffset
+
2
];
buffer
[
colorOffset
]
=
(
srcR
*
opaci
+
destR
*
(
1
-
opaci
)
);
buffer
[
colorOffset
+
1
]
=
(
srcG
*
opaci
+
destG
*
(
1
-
opaci
)
);
buffer
[
colorOffset
+
2
]
=
(
srcB
*
opaci
+
destB
*
(
1
-
opaci
)
);
...
...
@@ -707,7 +717,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
Math
.
sqrt
(
(
x3
-
x1
)
*
(
x3
-
x1
)
+
(
y3
-
y1
)
*
(
y3
-
y1
)
)
);
if
(
!
(
face
instanceof
THREE
.
RenderableSprite
)
if
(
!
(
face
instanceof
THREE
.
RenderableSprite
)
&&
(
longestSide
>
100
*
fixscale
)
)
{
// 1
...
...
@@ -718,7 +728,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
// |b\|d\
// |__\__\
// 2 3
var
tempFace
=
{
vertexNormalsModel
:
[],
var
tempFace
=
{
vertexNormalsModel
:
[],
color
:
face
.
color
};
var
mpUV12
,
mpUV23
,
mpUV31
;
if
(
bHasUV
)
{
...
...
@@ -736,7 +746,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
++
mpUVPoolCount
;
}
else
{
mpUV12
=
mpUVPool
[
mpUVPoolCount
];
++
mpUVPoolCount
;
++
mpUVPoolCount
;
mpUV23
=
mpUVPool
[
mpUVPoolCount
];
++
mpUVPoolCount
;
mpUV31
=
mpUVPool
[
mpUVPoolCount
];
...
...
@@ -752,7 +762,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
weight
=
(
1
+
v1
.
z
)
*
(
v1
.
w
/
v3
.
w
)
/
(
1
+
v3
.
z
);
mpUV31
.
copy
(
uv3
).
multiplyScalar
(
weight
).
add
(
uv1
).
multiplyScalar
(
1
/
(
weight
+
1
)
);
}
var
mpV12
,
mpV23
,
mpV31
;
if
(
mpVPoolCount
===
mpVPool
.
length
)
{
mpV12
=
new
THREE
.
Vector4
();
...
...
@@ -768,7 +778,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
++
mpVPoolCount
;
}
else
{
mpV12
=
mpVPool
[
mpVPoolCount
];
++
mpVPoolCount
;
++
mpVPoolCount
;
mpV23
=
mpVPool
[
mpVPoolCount
];
++
mpVPoolCount
;
mpV31
=
mpVPool
[
mpVPoolCount
];
...
...
@@ -795,7 +805,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
++
mpNPoolCount
;
}
else
{
mpN12
=
mpNPool
[
mpNPoolCount
];
++
mpNPoolCount
;
++
mpNPoolCount
;
mpN23
=
mpNPool
[
mpNPoolCount
];
++
mpNPoolCount
;
mpN31
=
mpNPool
[
mpNPoolCount
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录