Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
be5d5858
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,发现更多精彩内容 >>
提交
be5d5858
编写于
10月 29, 2011
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/dev' into dev
上级
179be338
1ef3d275
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
32 deletion
+56
-32
examples/webgl_geometry_subdivison.html
examples/webgl_geometry_subdivison.html
+56
-32
未找到文件。
examples/webgl_geometry_subdivison.html
浏览文件 @
be5d5858
...
@@ -72,8 +72,8 @@
...
@@ -72,8 +72,8 @@
materials
.
push
(
[
new
THREE
.
MeshBasicMaterial
(
{
color
:
Math
.
random
()
*
0xffffff
,
wireframe
:
false
}
)
]
);
materials
.
push
(
[
new
THREE
.
MeshBasicMaterial
(
{
color
:
Math
.
random
()
*
0xffffff
,
wireframe
:
false
}
)
]
);
}
}
var
geometriesParams
=
[
var
geometriesParams
=
[
...
@@ -87,7 +87,7 @@
...
@@ -87,7 +87,7 @@
{
type
:
'
LatheGeometry
'
,
args
:
[
[
{
type
:
'
LatheGeometry
'
,
args
:
[
[
new
THREE
.
Vector3
(
0
,
0
,
0
),
new
THREE
.
Vector3
(
0
,
0
,
0
),
new
THREE
.
Vector3
(
0
,
50
,
50
),
new
THREE
.
Vector3
(
0
,
50
,
50
),
new
THREE
.
Vector3
(
0
,
0
,
100
),
new
THREE
.
Vector3
(
0
,
1
0
,
100
),
new
THREE
.
Vector3
(
0
,
50
,
150
),
new
THREE
.
Vector3
(
0
,
50
,
150
),
new
THREE
.
Vector3
(
0
,
0
,
200
)
]
]},
new
THREE
.
Vector3
(
0
,
0
,
200
)
]
]},
{
type
:
'
TextGeometry
'
,
args
:
[
'
&
'
,
{
{
type
:
'
TextGeometry
'
,
args
:
[
'
&
'
,
{
...
@@ -98,32 +98,36 @@
...
@@ -98,32 +98,36 @@
}]},
}]},
{
type
:
'
PlaneGeometry
'
,
args
:
[
200
,
200
,
4
,
4
]
}
{
type
:
'
PlaneGeometry
'
,
args
:
[
200
,
200
,
4
,
4
]
}
];
];
if
(
location
.
protocol
!==
"
file:
"
)
{
if
(
location
.
protocol
!==
"
file:
"
)
{
var
loader
=
new
THREE
.
JSONLoader
();
var
loader
=
new
THREE
.
JSONLoader
();
loader
.
load
(
'
obj/WaltHeadLo.js
'
,
function
(
geometry
)
{
loader
.
load
(
'
obj/WaltHeadLo.js
'
,
function
(
geometry
)
{
geometriesParams
.
push
({
type
:
'
WaltHead
'
,
args
:
[
],
meshScale
:
6
});
geometriesParams
.
push
({
type
:
'
WaltHead
'
,
args
:
[
],
meshScale
:
6
});
THREE
.
WaltHead
=
function
()
{
THREE
.
WaltHead
=
function
()
{
return
THREE
.
GeometryUtils
.
clone
(
geometry
);
return
THREE
.
GeometryUtils
.
clone
(
geometry
);
};
};
updateInfo
()
});
});
var
loader2
=
new
THREE
.
JSONLoader
();
var
loader2
=
new
THREE
.
JSONLoader
();
loader2
.
load
(
'
obj/Suzanne.js
'
,
function
(
geometry
)
{
loader2
.
load
(
'
obj/Suzanne.js
'
,
function
(
geometry
)
{
geometriesParams
.
push
({
type
:
'
Suzanne
'
,
args
:
[
],
scale
:
100
,
meshScale
:
2
});
geometriesParams
.
push
({
type
:
'
Suzanne
'
,
args
:
[
],
scale
:
100
,
meshScale
:
2
});
THREE
.
Suzanne
=
function
()
{
THREE
.
Suzanne
=
function
()
{
return
THREE
.
GeometryUtils
.
clone
(
geometry
);
return
THREE
.
GeometryUtils
.
clone
(
geometry
);
};
};
updateInfo
()
}
);
}
);
}
}
...
@@ -157,6 +161,39 @@
...
@@ -157,6 +161,39 @@
}
}
function
switchGeometry
(
i
)
{
geometryIndex
=
i
;
addStuff
();
}
function
updateInfo
()
{
var
params
=
geometriesParams
[
geometryIndex
];
var
dropdown
=
'
<select id="dropdown" onchange="switchGeometry(this.value)">
'
;
for
(
i
=
0
;
i
<
geometriesParams
.
length
;
i
++
)
{
dropdown
+=
'
<option value="
'
+
i
+
'
"
'
;
dropdown
+=
(
geometryIndex
==
i
)
?
'
selected
'
:
''
;
dropdown
+=
'
>
'
+
geometriesParams
[
i
].
type
+
'
</option>
'
;
}
dropdown
+=
'
</select>
'
;
info
.
innerHTML
=
'
Drag to spin THREE.
'
+
params
.
type
+
'
<br/><br/>Subdivisions:
'
+
subdivisions
+
'
<a href="#" onclick="nextSubdivision(1); return false;">more</a>/<a href="#" onclick="nextSubdivision(-1); return false;">less</a>
'
+
'
<br>Geometry:
'
+
dropdown
+
'
<a href="#" onclick="nextGeometry();return false;">next</a>
'
+
'
<br/><br>Vertices count: before
'
+
geometry
.
vertices
.
length
+
'
after
'
+
smooth
.
vertices
.
length
+
'
<br>Face count: before
'
+
geometry
.
faces
.
length
+
'
after
'
+
smooth
.
faces
.
length
;
//+ params.args;
}
function
addStuff
()
{
function
addStuff
()
{
if
(
cube
)
{
if
(
cube
)
{
...
@@ -173,7 +210,7 @@
...
@@ -173,7 +210,7 @@
var
params
=
geometriesParams
[
geometryIndex
];
var
params
=
geometriesParams
[
geometryIndex
];
geometry
=
createSomething
(
THREE
[
params
.
type
],
params
.
args
);
geometry
=
createSomething
(
THREE
[
params
.
type
],
params
.
args
);
// Scale Geometry
// Scale Geometry
if
(
params
.
scale
)
{
if
(
params
.
scale
)
{
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
setScale
(
params
.
scale
,
params
.
scale
,
params
.
scale
)
);
geometry
.
applyMatrix
(
new
THREE
.
Matrix4
().
setScale
(
params
.
scale
,
params
.
scale
,
params
.
scale
)
);
...
@@ -187,14 +224,7 @@
...
@@ -187,14 +224,7 @@
smooth
.
mergeVertices
();
smooth
.
mergeVertices
();
modifier
.
modify
(
smooth
);
modifier
.
modify
(
smooth
);
info
.
innerHTML
=
'
Drag to spin THREE.
'
+
params
.
type
+
updateInfo
();
'
<br/><br/>Subdivisions:
'
+
modifier
.
subdivisions
+
'
<a href="#" onclick="nextSubdivision(1); return false;">more</a>/<a href="#" onclick="nextSubdivision(-1); return false;">less</a>
'
+
'
<br>Geometry: <a href="#" onclick="nextGeometry();return false;">next</a>
'
+
'
<br/><br>Vertices count: before
'
+
geometry
.
vertices
.
length
+
'
after
'
+
smooth
.
vertices
.
length
+
'
<br>Face count: before
'
+
geometry
.
faces
.
length
+
'
after
'
+
smooth
.
faces
.
length
;
//+ params.args;
var
faceABCD
=
"
abcd
"
;
var
faceABCD
=
"
abcd
"
;
var
color
,
f
,
p
,
n
,
vertexIndex
;
var
color
,
f
,
p
,
n
,
vertexIndex
;
...
@@ -284,21 +314,14 @@
...
@@ -284,21 +314,14 @@
var
meshmaterials
=
[
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
.
MeshLambertMaterial
(
{
color
:
0xffffff
,
shading
:
THREE
.
FlatShading
,
vertexColors
:
THREE
.
VertexColors
}
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x405040
,
wireframe
:
true
,
opacity
:
0.8
,
transparent
:
true
}
)
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x405040
,
wireframe
:
true
,
opacity
:
0.8
,
transparent
:
true
}
)
];
];
// new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } ),
// new THREE.MeshBasicMaterial( { color: 0x000000, shading: THREE.FlatShading, wireframe: true } )
// new THREE.MeshFaceMaterial()
// new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } );
// new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } );
cube
=
THREE
.
SceneUtils
.
createMultiMaterialObject
(
smooth
,
meshmaterials
);
cube
=
THREE
.
SceneUtils
.
createMultiMaterialObject
(
smooth
,
meshmaterials
);
var
meshScale
=
params
.
meshScale
?
params
.
meshScale
:
1
;
var
meshScale
=
params
.
meshScale
?
params
.
meshScale
:
1
;
cube
.
scale
.
x
=
meshScale
;
cube
.
scale
.
x
=
meshScale
;
cube
.
scale
.
y
=
meshScale
;
cube
.
scale
.
y
=
meshScale
;
cube
.
scale
.
z
=
meshScale
;
cube
.
scale
.
z
=
meshScale
;
...
@@ -353,7 +376,7 @@
...
@@ -353,7 +376,7 @@
function
onDocumentMouseDown
(
event
)
{
function
onDocumentMouseDown
(
event
)
{
event
.
preventDefault
();
//
event.preventDefault();
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
document
.
addEventListener
(
'
mouseup
'
,
onDocumentMouseUp
,
false
);
document
.
addEventListener
(
'
mouseup
'
,
onDocumentMouseUp
,
false
);
...
@@ -428,7 +451,7 @@
...
@@ -428,7 +451,7 @@
group
.
rotation
.
x
=
cube
.
rotation
.
x
+=
(
targetXRotation
-
cube
.
rotation
.
x
)
*
0.05
;
group
.
rotation
.
x
=
cube
.
rotation
.
x
+=
(
targetXRotation
-
cube
.
rotation
.
x
)
*
0.05
;
group
.
rotation
.
y
=
cube
.
rotation
.
y
+=
(
targetYRotation
-
cube
.
rotation
.
y
)
*
0.05
;
group
.
rotation
.
y
=
cube
.
rotation
.
y
+=
(
targetYRotation
-
cube
.
rotation
.
y
)
*
0.05
;
renderer
.
render
(
scene
,
camera
);
renderer
.
render
(
scene
,
camera
);
}
}
...
@@ -437,3 +460,4 @@
...
@@ -437,3 +460,4 @@
</body>
</body>
</html>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录