Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
98629744
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,发现更多精彩内容 >>
提交
98629744
编写于
10月 04, 2011
作者:
Z
zz85
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
option to honor old vertex colors with subdivisionModifier.useOldVertexColors = true
上级
f8df3074
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
484 addition
and
485 deletion
+484
-485
build/Three.js
build/Three.js
+459
-467
examples/canvas_geometry_subdivison.html
examples/canvas_geometry_subdivison.html
+4
-4
src/extras/modifiers/SubdivisionModifier.js
src/extras/modifiers/SubdivisionModifier.js
+21
-14
未找到文件。
build/Three.js
浏览文件 @
98629744
此差异已折叠。
点击以展开。
examples/canvas_geometry_subdivison.html
浏览文件 @
98629744
...
...
@@ -230,9 +230,9 @@
var
meshmaterials
=
[
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x000000
,
shading
:
THREE
.
FlatShading
,
wireframe
:
true
}
)
//
new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } ),
//
new THREE.MeshBasicMaterial( { color: 0x405040, wireframe:true, opacity:0.8 } )
//
new THREE.MeshBasicMaterial( { color: 0x000000, shading: THREE.FlatShading, wireframe: true } )
new
THREE
.
MeshLambertMaterial
(
{
color
:
0xffffff
,
shading
:
THREE
.
FlatShading
,
vertexColors
:
THREE
.
VertexColors
}
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x405040
,
wireframe
:
true
,
opacity
:
0.8
}
)
];
// new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } ),
...
...
@@ -253,7 +253,7 @@
cube
.
overdraw
=
true
;
scene
.
add
(
cube
);
renderer
=
new
THREE
.
Canvas
Renderer
();
// WebGLRenderer CanvasRenderer
renderer
=
new
THREE
.
WebGL
Renderer
();
// WebGLRenderer CanvasRenderer
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
...
...
src/extras/modifiers/SubdivisionModifier.js
浏览文件 @
98629744
...
...
@@ -17,6 +17,10 @@ THREE.SubdivisionModifier = function( subdivisions ) {
this
.
subdivisions
=
(
subdivisions
===
undefined
)
?
1
:
subdivisions
;
// Settings
this
.
useOldVertexColors
=
false
;
this
.
supportUVs
=
true
;
};
//THREE.SubdivisionModifier.prototype = new THREE.Modifier();
...
...
@@ -45,12 +49,17 @@ THREE.SubdivisionModifier.prototype.smooth = function ( oldGeometry ) {
function
v
(
x
,
y
,
z
)
{
newVertices
.
push
(
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
x
,
y
,
z
)
)
);
}
var
scope
=
this
;
function
f4
(
a
,
b
,
c
,
d
,
color
,
material
)
{
function
f4
(
a
,
b
,
c
,
d
,
oldFace
)
{
newFaces
.
push
(
new
THREE
.
Face4
(
a
,
b
,
c
,
d
,
null
,
color
,
material
)
);
var
newFace
=
new
THREE
.
Face4
(
a
,
b
,
c
,
d
,
null
,
oldFace
.
color
,
oldFace
.
material
);
if
(
scope
.
useOldVertexColors
)
newFace
.
vertexColors
=
oldFace
.
vertexColors
;
if
(
!
supportUVs
||
uvForVertices
.
length
!=
0
)
{
newFaces
.
push
(
newFace
);
if
(
!
scope
.
supportUVs
||
uvForVertices
.
length
!=
0
)
{
newUVs
.
push
(
[
uvForVertices
[
a
],
uvForVertices
[
b
],
...
...
@@ -150,8 +159,6 @@ THREE.SubdivisionModifier.prototype.smooth = function ( oldGeometry ) {
var
uvForVertices
=
[];
var
supportUVs
=
true
;
// Step 1
// For each face, add a face point
// Set each face point to be the centroid of all original points for the respective face.
...
...
@@ -183,7 +190,7 @@ THREE.SubdivisionModifier.prototype.smooth = function ( oldGeometry ) {
newPoints
.
push
(
new
THREE
.
Vertex
(
face
.
centroid
)
);
if
(
!
supportUVs
||
uvForVertices
.
length
==
0
)
continue
;
if
(
!
s
cope
.
s
upportUVs
||
uvForVertices
.
length
==
0
)
continue
;
// Prepare subdivided uv
...
...
@@ -251,7 +258,7 @@ THREE.SubdivisionModifier.prototype.smooth = function ( oldGeometry ) {
edgeCount
++
;
if
(
!
supportUVs
||
uvForVertices
.
length
==
0
)
continue
;
if
(
!
s
cope
.
s
upportUVs
||
uvForVertices
.
length
==
0
)
continue
;
// Prepare subdivided uv
...
...
@@ -290,9 +297,9 @@ THREE.SubdivisionModifier.prototype.smooth = function ( oldGeometry ) {
hashCA
=
edge_hash
(
face
.
c
,
face
.
a
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashAB
],
face
.
b
,
edgePoints
[
hashBC
],
face
.
color
,
face
.
material
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashBC
],
face
.
c
,
edgePoints
[
hashCA
],
face
.
color
,
face
.
material
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashCA
],
face
.
a
,
edgePoints
[
hashAB
],
face
.
color
,
face
.
material
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashAB
],
face
.
b
,
edgePoints
[
hashBC
],
face
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashBC
],
face
.
c
,
edgePoints
[
hashCA
],
face
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashCA
],
face
.
a
,
edgePoints
[
hashAB
],
face
);
// face subdivide color and materials too?
...
...
@@ -305,10 +312,10 @@ THREE.SubdivisionModifier.prototype.smooth = function ( oldGeometry ) {
hashCD
=
edge_hash
(
face
.
c
,
face
.
d
);
hashDA
=
edge_hash
(
face
.
d
,
face
.
a
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashAB
],
face
.
b
,
edgePoints
[
hashBC
],
face
.
color
,
face
.
material
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashBC
],
face
.
c
,
edgePoints
[
hashCD
],
face
.
color
,
face
.
material
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashCD
],
face
.
d
,
edgePoints
[
hashDA
],
face
.
color
,
face
.
material
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashDA
],
face
.
a
,
edgePoints
[
hashAB
],
face
.
color
,
face
.
material
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashAB
],
face
.
b
,
edgePoints
[
hashBC
],
face
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashBC
],
face
.
c
,
edgePoints
[
hashCD
],
face
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashCD
],
face
.
d
,
edgePoints
[
hashDA
],
face
);
f4
(
currentVerticeIndex
,
edgePoints
[
hashDA
],
face
.
a
,
edgePoints
[
hashAB
],
face
);
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录