Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
a7a0e7c2
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,发现更多精彩内容 >>
未验证
提交
a7a0e7c2
编写于
7月 31, 2018
作者:
M
Mr.doob
提交者:
GitHub
7月 31, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14596 from Mugen87/dev18
Examples: Removed webgl_objects_update.html
上级
5f69e38d
68c61a9e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
0 addition
and
191 deletion
+0
-191
examples/files.js
examples/files.js
+0
-1
examples/webgl_objects_update.html
examples/webgl_objects_update.html
+0
-190
未找到文件。
examples/files.js
浏览文件 @
a7a0e7c2
...
...
@@ -202,7 +202,6 @@ var files = {
"
webgl_multiple_renderers
"
,
"
webgl_multiple_views
"
,
"
webgl_nearestneighbour
"
,
"
webgl_objects_update
"
,
"
webgl_octree
"
,
"
webgl_octree_raycasting
"
,
"
webgl_panorama_cube
"
,
...
...
examples/webgl_objects_update.html
已删除
100644 → 0
浏览文件 @
5f69e38d
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - geometries
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<style>
body
{
font-family
:
Monospace
;
background-color
:
#000
;
margin
:
0px
;
overflow
:
hidden
;
}
</style>
</head>
<body>
<script
src=
"../build/three.js"
></script>
<script
src=
"js/Detector.js"
></script>
<script>
if
(
!
Detector
.
webgl
)
Detector
.
addGetWebGLMessage
();
var
container
;
var
camera
,
scene
,
renderer
;
var
objectNewGeometry
;
var
objectToggleAddRemove
;
var
objectRandomizeFaces
;
var
objectRandomizeMaterialIndices
;
init
();
animate
();
function
init
()
{
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
45
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
2000
);
camera
.
position
.
z
=
600
;
scene
=
new
THREE
.
Scene
();
//
var
object
=
createObject
(
createMaterials
(),
1
);
object
.
position
.
set
(
-
100
,
100
,
0
);
scene
.
add
(
object
);
objectNewGeometry
=
object
;
object
=
createObject
(
createMaterials
(),
1
);
object
.
position
.
set
(
100
,
100
,
0
);
scene
.
add
(
object
);
objectToggleAddRemove
=
object
;
object
=
createObject
(
createMaterials
(),
4
);
object
.
position
.
set
(
-
100
,
-
100
,
0
);
scene
.
add
(
object
);
objectRandomizeFaces
=
object
;
object
=
createObject
(
createMaterials
(),
4
);
object
.
position
.
set
(
100
,
-
100
,
0
);
scene
.
add
(
object
);
objectRandomizeMaterialIndices
=
object
;
//
//
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
//
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
}
function
createObject
(
material
,
segments
){
var
geometry
=
createGeometry
(
segments
);
return
new
THREE
.
Mesh
(
geometry
,
material
);
}
function
createGeometry
(
segments
)
{
var
matrix
=
new
THREE
.
Matrix4
();
var
euler
=
new
THREE
.
Euler
();
var
geometry
=
new
THREE
.
BoxGeometry
(
100
,
100
,
100
,
segments
,
segments
,
segments
);
geometry
.
applyMatrix
(
matrix
.
makeRotationFromEuler
(
euler
.
set
(
Math
.
random
()
*
2
*
Math
.
PI
,
Math
.
random
()
*
2
*
Math
.
PI
,
Math
.
random
()
*
2
*
Math
.
PI
)));
return
geometry
;
}
function
createMaterials
(){
var
materials
=
[
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xff0000
}
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xffff00
}
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x00ff00
}
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x00ffff
}
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x0000ff
}
),
new
THREE
.
MeshBasicMaterial
(
{
color
:
0xff00ff
}
)
];
return
materials
;
}
function
onWindowResize
()
{
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
//
function
animate
()
{
setTimeout
(
animate
,
1000
);
render
();
}
function
randomizeFaces
(
object
)
{
var
geometry
=
object
.
geometry
;
var
faces
=
geometry
.
faces
;
for
(
var
i
=
0
,
l
=
faces
.
length
;
i
<
l
;
i
++
)
{
faces
[
i
].
a
=
Math
.
floor
(
Math
.
random
()
*
geometry
.
vertices
.
length
);
faces
[
i
].
b
=
Math
.
floor
(
Math
.
random
()
*
geometry
.
vertices
.
length
);
faces
[
i
].
c
=
Math
.
floor
(
Math
.
random
()
*
geometry
.
vertices
.
length
);
}
geometry
.
elementsNeedUpdate
=
true
;
}
function
randomizeMaterialIndices
(
object
)
{
var
geometry
=
object
.
geometry
;
var
faces
=
geometry
.
faces
;
for
(
var
i
=
0
,
l
=
faces
.
length
;
i
<
l
;
i
++
)
{
faces
[
i
].
materialIndex
=
Math
.
floor
(
Math
.
random
()
*
6
);
}
geometry
.
groupsNeedUpdate
=
true
;
}
function
render
()
{
objectNewGeometry
.
geometry
=
createGeometry
(
1
);
if
(
scene
.
children
.
indexOf
(
objectToggleAddRemove
)
===
-
1
)
{
scene
.
add
(
objectToggleAddRemove
);
}
else
{
scene
.
remove
(
objectToggleAddRemove
);
}
randomizeFaces
(
objectRandomizeFaces
);
randomizeMaterialIndices
(
objectRandomizeMaterialIndices
);
renderer
.
render
(
scene
,
camera
);
}
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录