Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
b2600a27
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,发现更多精彩内容 >>
提交
b2600a27
编写于
11月 22, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added computing of normals also for non-indexed BufferGeometry.
Goes with #2657
上级
3d4b2c95
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
273 addition
and
181 deletion
+273
-181
build/three.js
build/three.js
+76
-30
build/three.min.js
build/three.min.js
+121
-121
src/core/BufferGeometry.js
src/core/BufferGeometry.js
+76
-30
未找到文件。
build/three.js
浏览文件 @
b2600a27
...
...
@@ -5952,7 +5952,7 @@ THREE.BufferGeometry.prototype = {
computeVertexNormals: function () {
if ( this.attributes[ "position" ]
&& this.attributes[ "index" ]
) {
if ( this.attributes[ "position" ] ) {
var i, il;
var j, jl;
...
...
@@ -5981,9 +5981,6 @@ THREE.BufferGeometry.prototype = {
}
var offsets = this.offsets;
var indices = this.attributes[ "index" ].array;
var positions = this.attributes[ "position" ].array;
var normals = this.attributes[ "normal" ].array;
...
...
@@ -5996,48 +5993,97 @@ THREE.BufferGeometry.prototype = {
cb = new THREE.Vector3(),
ab = new THREE.Vector3();
for ( j = 0, jl = offsets.length; j < jl; ++ j ) {
// indexed elements
if ( this.attributes[ "index" ] ) {
var indices = this.attributes[ "index" ].array;
var offsets = this.offsets;
for ( j = 0, jl = offsets.length; j < jl; ++ j ) {
var start = offsets[ j ].start;
var count = offsets[ j ].count;
var index = offsets[ j ].index;
for ( i = start, il = start + count; i < il; i += 3 ) {
vA = index + indices[ i ];
vB = index + indices[ i + 1 ];
vC = index + indices[ i + 2 ];
x = positions[ vA * 3 ];
y = positions[ vA * 3 + 1 ];
z = positions[ vA * 3 + 2 ];
pA.set( x, y, z );
x = positions[ vB * 3 ];
y = positions[ vB * 3 + 1 ];
z = positions[ vB * 3 + 2 ];
pB.set( x, y, z );
var start = offsets[ j ].start;
var count = offsets[ j ].count;
var index = offsets[ j ].index;
x = positions[ vC * 3 ];
y = positions[ vC * 3 + 1 ];
z = positions[ vC * 3 + 2 ];
pC.set( x, y, z );
for ( i = start, il = start + count; i < il; i += 3 ) {
cb.sub( pC, pB );
ab.sub( pA, pB );
cb.crossSelf( ab );
normals[ vA * 3 ] += cb.x;
normals[ vA * 3 + 1 ] += cb.y;
normals[ vA * 3 + 2 ] += cb.z;
normals[ vB * 3 ] += cb.x;
normals[ vB * 3 + 1 ] += cb.y;
normals[ vB * 3 + 2 ] += cb.z;
normals[ vC * 3 ] += cb.x;
normals[ vC * 3 + 1 ] += cb.y;
normals[ vC * 3 + 2 ] += cb.z;
}
}
// non-indexed elements (unconnected triangle soup)
} else {
vA = index + indices[ i ];
vB = index + indices[ i + 1 ];
vC = index + indices[ i + 2 ];
for ( i = 0, il = positions.length; i < il; i += 9 ) {
x = positions[
vA * 3
];
y = positions[
vA * 3
+ 1 ];
z = positions[
vA * 3
+ 2 ];
x = positions[
i
];
y = positions[
i
+ 1 ];
z = positions[
i
+ 2 ];
pA.set( x, y, z );
x = positions[
vB *
3 ];
y = positions[
vB * 3 + 1
];
z = positions[
vB * 3 + 2
];
x = positions[
i +
3 ];
y = positions[
i + 4
];
z = positions[
i + 5
];
pB.set( x, y, z );
x = positions[
vC * 3
];
y = positions[
vC * 3 + 1
];
z = positions[
vC * 3 + 2
];
x = positions[
i + 6
];
y = positions[
i + 7
];
z = positions[
i + 8
];
pC.set( x, y, z );
cb.sub( pC, pB );
ab.sub( pA, pB );
cb.crossSelf( ab );
normals[
vA * 3 ] +
= cb.x;
normals[
vA * 3 + 1 ] +
= cb.y;
normals[
vA * 3 + 2 ] +
= cb.z;
normals[
i ]
= cb.x;
normals[
i + 1 ]
= cb.y;
normals[
i + 2 ]
= cb.z;
normals[
vB * 3 ] +
= cb.x;
normals[
vB * 3 + 1 ] +
= cb.y;
normals[
vB * 3 + 2 ] +
= cb.z;
normals[
i + 3 ]
= cb.x;
normals[
i + 4 ]
= cb.y;
normals[
i + 5 ]
= cb.z;
normals[
vC * 3 ] +
= cb.x;
normals[
vC * 3 + 1 ] +
= cb.y;
normals[
vC * 3 + 2 ] +
= cb.z;
normals[
i + 6 ]
= cb.x;
normals[
i + 7 ]
= cb.y;
normals[
i + 8 ]
= cb.z;
}
...
...
build/three.min.js
浏览文件 @
b2600a27
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
src/core/BufferGeometry.js
浏览文件 @
b2600a27
...
...
@@ -168,7 +168,7 @@ THREE.BufferGeometry.prototype = {
computeVertexNormals
:
function
()
{
if
(
this
.
attributes
[
"
position
"
]
&&
this
.
attributes
[
"
index
"
]
)
{
if
(
this
.
attributes
[
"
position
"
]
)
{
var
i
,
il
;
var
j
,
jl
;
...
...
@@ -197,9 +197,6 @@ THREE.BufferGeometry.prototype = {
}
var
offsets
=
this
.
offsets
;
var
indices
=
this
.
attributes
[
"
index
"
].
array
;
var
positions
=
this
.
attributes
[
"
position
"
].
array
;
var
normals
=
this
.
attributes
[
"
normal
"
].
array
;
...
...
@@ -212,48 +209,97 @@ THREE.BufferGeometry.prototype = {
cb
=
new
THREE
.
Vector3
(),
ab
=
new
THREE
.
Vector3
();
for
(
j
=
0
,
jl
=
offsets
.
length
;
j
<
jl
;
++
j
)
{
// indexed elements
if
(
this
.
attributes
[
"
index
"
]
)
{
var
indices
=
this
.
attributes
[
"
index
"
].
array
;
var
offsets
=
this
.
offsets
;
for
(
j
=
0
,
jl
=
offsets
.
length
;
j
<
jl
;
++
j
)
{
var
start
=
offsets
[
j
].
start
;
var
count
=
offsets
[
j
].
count
;
var
index
=
offsets
[
j
].
index
;
for
(
i
=
start
,
il
=
start
+
count
;
i
<
il
;
i
+=
3
)
{
vA
=
index
+
indices
[
i
];
vB
=
index
+
indices
[
i
+
1
];
vC
=
index
+
indices
[
i
+
2
];
x
=
positions
[
vA
*
3
];
y
=
positions
[
vA
*
3
+
1
];
z
=
positions
[
vA
*
3
+
2
];
pA
.
set
(
x
,
y
,
z
);
x
=
positions
[
vB
*
3
];
y
=
positions
[
vB
*
3
+
1
];
z
=
positions
[
vB
*
3
+
2
];
pB
.
set
(
x
,
y
,
z
);
var
start
=
offsets
[
j
].
start
;
var
count
=
offsets
[
j
].
count
;
var
index
=
offsets
[
j
].
index
;
x
=
positions
[
vC
*
3
];
y
=
positions
[
vC
*
3
+
1
];
z
=
positions
[
vC
*
3
+
2
];
pC
.
set
(
x
,
y
,
z
);
for
(
i
=
start
,
il
=
start
+
count
;
i
<
il
;
i
+=
3
)
{
cb
.
sub
(
pC
,
pB
);
ab
.
sub
(
pA
,
pB
);
cb
.
crossSelf
(
ab
);
normals
[
vA
*
3
]
+=
cb
.
x
;
normals
[
vA
*
3
+
1
]
+=
cb
.
y
;
normals
[
vA
*
3
+
2
]
+=
cb
.
z
;
normals
[
vB
*
3
]
+=
cb
.
x
;
normals
[
vB
*
3
+
1
]
+=
cb
.
y
;
normals
[
vB
*
3
+
2
]
+=
cb
.
z
;
normals
[
vC
*
3
]
+=
cb
.
x
;
normals
[
vC
*
3
+
1
]
+=
cb
.
y
;
normals
[
vC
*
3
+
2
]
+=
cb
.
z
;
}
}
// non-indexed elements (unconnected triangle soup)
}
else
{
vA
=
index
+
indices
[
i
];
vB
=
index
+
indices
[
i
+
1
];
vC
=
index
+
indices
[
i
+
2
];
for
(
i
=
0
,
il
=
positions
.
length
;
i
<
il
;
i
+=
9
)
{
x
=
positions
[
vA
*
3
];
y
=
positions
[
vA
*
3
+
1
];
z
=
positions
[
vA
*
3
+
2
];
x
=
positions
[
i
];
y
=
positions
[
i
+
1
];
z
=
positions
[
i
+
2
];
pA
.
set
(
x
,
y
,
z
);
x
=
positions
[
vB
*
3
];
y
=
positions
[
vB
*
3
+
1
];
z
=
positions
[
vB
*
3
+
2
];
x
=
positions
[
i
+
3
];
y
=
positions
[
i
+
4
];
z
=
positions
[
i
+
5
];
pB
.
set
(
x
,
y
,
z
);
x
=
positions
[
vC
*
3
];
y
=
positions
[
vC
*
3
+
1
];
z
=
positions
[
vC
*
3
+
2
];
x
=
positions
[
i
+
6
];
y
=
positions
[
i
+
7
];
z
=
positions
[
i
+
8
];
pC
.
set
(
x
,
y
,
z
);
cb
.
sub
(
pC
,
pB
);
ab
.
sub
(
pA
,
pB
);
cb
.
crossSelf
(
ab
);
normals
[
vA
*
3
]
+
=
cb
.
x
;
normals
[
vA
*
3
+
1
]
+
=
cb
.
y
;
normals
[
vA
*
3
+
2
]
+
=
cb
.
z
;
normals
[
i
]
=
cb
.
x
;
normals
[
i
+
1
]
=
cb
.
y
;
normals
[
i
+
2
]
=
cb
.
z
;
normals
[
vB
*
3
]
+
=
cb
.
x
;
normals
[
vB
*
3
+
1
]
+
=
cb
.
y
;
normals
[
vB
*
3
+
2
]
+
=
cb
.
z
;
normals
[
i
+
3
]
=
cb
.
x
;
normals
[
i
+
4
]
=
cb
.
y
;
normals
[
i
+
5
]
=
cb
.
z
;
normals
[
vC
*
3
]
+
=
cb
.
x
;
normals
[
vC
*
3
+
1
]
+
=
cb
.
y
;
normals
[
vC
*
3
+
2
]
+
=
cb
.
z
;
normals
[
i
+
6
]
=
cb
.
x
;
normals
[
i
+
7
]
=
cb
.
y
;
normals
[
i
+
8
]
=
cb
.
z
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录