Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
0b66525b
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,发现更多精彩内容 >>
提交
0b66525b
编写于
6月 29, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Projector: Switch to object.traverseVisible and code clean up.
上级
b66072d6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
73 deletion
+58
-73
src/core/Projector.js
src/core/Projector.js
+58
-73
未找到文件。
src/core/Projector.js
浏览文件 @
0b66525b
...
...
@@ -80,65 +80,6 @@ THREE.Projector = function () {
};
var
projectObject
=
function
(
object
)
{
if
(
object
.
visible
===
false
)
return
;
if
(
object
instanceof
THREE
.
Light
)
{
_renderData
.
lights
.
push
(
object
);
}
else
if
(
object
instanceof
THREE
.
Mesh
||
object
instanceof
THREE
.
Line
||
object
instanceof
THREE
.
Sprite
)
{
if
(
object
.
frustumCulled
===
false
||
_frustum
.
intersectsObject
(
object
)
===
true
)
{
_object
=
getNextObjectInPool
();
_object
.
id
=
object
.
id
;
_object
.
object
=
object
;
if
(
object
.
renderDepth
!==
null
)
{
_object
.
z
=
object
.
renderDepth
;
}
else
{
_vector3
.
setFromMatrixPosition
(
object
.
matrixWorld
);
_vector3
.
applyProjection
(
_viewProjectionMatrix
);
_object
.
z
=
_vector3
.
z
;
}
_renderData
.
objects
.
push
(
_object
);
}
}
for
(
var
i
=
0
,
l
=
object
.
children
.
length
;
i
<
l
;
i
++
)
{
projectObject
(
object
.
children
[
i
]
);
}
};
var
projectGraph
=
function
(
root
,
sortObjects
)
{
_objectCount
=
0
;
_renderData
.
objects
.
length
=
0
;
_renderData
.
lights
.
length
=
0
;
projectObject
(
root
);
if
(
sortObjects
===
true
)
{
_renderData
.
objects
.
sort
(
painterSort
);
}
};
var
RenderList
=
function
()
{
var
normals
=
[];
...
...
@@ -303,9 +244,6 @@ THREE.Projector = function () {
this
.
projectScene
=
function
(
scene
,
camera
,
sortObjects
,
sortElements
)
{
var
object
,
geometry
,
vertices
,
faces
,
face
,
faceVertexNormals
,
faceVertexUvs
,
isFaceMaterial
,
objectMaterials
;
_faceCount
=
0
;
_lineCount
=
0
;
_spriteCount
=
0
;
...
...
@@ -320,12 +258,59 @@ THREE.Projector = function () {
_frustum
.
setFromMatrix
(
_viewProjectionMatrix
);
projectGraph
(
scene
,
sortObjects
);
//
_objectCount
=
0
;
_renderData
.
objects
.
length
=
0
;
_renderData
.
lights
.
length
=
0
;
scene
.
traverseVisible
(
function
(
object
)
{
if
(
object
instanceof
THREE
.
Light
)
{
_renderData
.
lights
.
push
(
object
);
}
else
if
(
object
instanceof
THREE
.
Mesh
||
object
instanceof
THREE
.
Line
||
object
instanceof
THREE
.
Sprite
)
{
if
(
object
.
frustumCulled
===
false
||
_frustum
.
intersectsObject
(
object
)
===
true
)
{
_object
=
getNextObjectInPool
();
_object
.
id
=
object
.
id
;
_object
.
object
=
object
;
if
(
object
.
renderDepth
!==
null
)
{
_object
.
z
=
object
.
renderDepth
;
}
else
{
_vector3
.
setFromMatrixPosition
(
object
.
matrixWorld
);
_vector3
.
applyProjection
(
_viewProjectionMatrix
);
_object
.
z
=
_vector3
.
z
;
}
_renderData
.
objects
.
push
(
_object
);
}
}
}
);
if
(
sortObjects
===
true
)
{
_renderData
.
objects
.
sort
(
painterSort
);
}
//
for
(
var
o
=
0
,
ol
=
_renderData
.
objects
.
length
;
o
<
ol
;
o
++
)
{
object
=
_renderData
.
objects
[
o
].
object
;
geometry
=
object
.
geometry
;
var
object
=
_renderData
.
objects
[
o
].
object
;
var
geometry
=
object
.
geometry
;
renderList
.
setObject
(
object
);
...
...
@@ -415,14 +400,14 @@ THREE.Projector = function () {
}
else
if
(
geometry
instanceof
THREE
.
Geometry
)
{
vertices
=
geometry
.
vertices
;
faces
=
geometry
.
faces
;
faceVertexUvs
=
geometry
.
faceVertexUvs
[
0
];
v
ar
v
ertices
=
geometry
.
vertices
;
var
faces
=
geometry
.
faces
;
var
faceVertexUvs
=
geometry
.
faceVertexUvs
[
0
];
_normalMatrix
.
getNormalMatrix
(
_modelMatrix
);
isFaceMaterial
=
object
.
material
instanceof
THREE
.
MeshFaceMaterial
;
objectMaterials
=
isFaceMaterial
===
true
?
object
.
material
:
null
;
var
isFaceMaterial
=
object
.
material
instanceof
THREE
.
MeshFaceMaterial
;
var
objectMaterials
=
isFaceMaterial
===
true
?
object
.
material
:
null
;
for
(
var
v
=
0
,
vl
=
vertices
.
length
;
v
<
vl
;
v
++
)
{
...
...
@@ -433,7 +418,7 @@ THREE.Projector = function () {
for
(
var
f
=
0
,
fl
=
faces
.
length
;
f
<
fl
;
f
++
)
{
face
=
faces
[
f
];
var
face
=
faces
[
f
];
var
material
=
isFaceMaterial
===
true
?
objectMaterials
.
materials
[
face
.
materialIndex
]
...
...
@@ -518,7 +503,7 @@ THREE.Projector = function () {
_face
.
normalModel
.
applyMatrix3
(
_normalMatrix
).
normalize
();
faceVertexNormals
=
face
.
vertexNormals
;
var
faceVertexNormals
=
face
.
vertexNormals
;
for
(
var
n
=
0
,
nl
=
Math
.
min
(
faceVertexNormals
.
length
,
3
);
n
<
nl
;
n
++
)
{
...
...
@@ -604,7 +589,7 @@ THREE.Projector = function () {
_modelViewProjectionMatrix
.
multiplyMatrices
(
_viewProjectionMatrix
,
_modelMatrix
);
vertices
=
object
.
geometry
.
vertices
;
v
ar
v
ertices
=
object
.
geometry
.
vertices
;
if
(
vertices
.
length
===
0
)
continue
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录