Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
09ba6f69
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,发现更多精彩内容 >>
提交
09ba6f69
编写于
5月 10, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More clean up.
上级
a84fccd7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
12 deletion
+34
-12
examples/webgl_interactive_raycasting_pointcloud.html
examples/webgl_interactive_raycasting_pointcloud.html
+34
-12
未找到文件。
examples/webgl_interactive_raycasting_pointcloud.html
浏览文件 @
09ba6f69
...
...
@@ -68,8 +68,11 @@
var
colors
=
new
Float32Array
(
numPoints
*
3
);
var
k
=
0
;
for
(
var
i
=
0
;
i
<
width
;
i
++
)
{
for
(
var
i
=
0
;
i
<
width
;
i
++
)
{
for
(
var
j
=
0
;
j
<
length
;
j
++
)
{
var
u
=
i
/
width
;
var
v
=
j
/
length
;
var
x
=
u
-
0.5
;
...
...
@@ -84,16 +87,19 @@
colors
[
3
*
k
]
=
color
.
r
*
intensity
;
colors
[
3
*
k
+
1
]
=
color
.
g
*
intensity
;
colors
[
3
*
k
+
2
]
=
color
.
b
*
intensity
;
k
++
;
}
}
geometry
.
addAttribute
(
'
position
'
,
new
THREE
.
Float32
Attribute
(
positions
,
3
)
);
geometry
.
addAttribute
(
'
color
'
,
new
THREE
.
Float32
Attribute
(
colors
,
3
)
);
geometry
.
addAttribute
(
'
position
'
,
new
THREE
.
Buffer
Attribute
(
positions
,
3
)
);
geometry
.
addAttribute
(
'
color
'
,
new
THREE
.
Buffer
Attribute
(
colors
,
3
)
);
geometry
.
computeBoundingBox
();
return
geometry
;
}
function
generatePointcloud
(
color
,
width
,
length
)
{
...
...
@@ -114,14 +120,19 @@
var
indices
=
new
Uint16Array
(
numPoints
);
var
k
=
0
;
for
(
var
i
=
0
;
i
<
width
;
i
++
)
{
for
(
var
j
=
0
;
j
<
length
;
j
++
)
{
indices
[
k
]
=
k
;
k
++
;
}
}
geometry
.
addAttribute
(
'
index
'
,
new
THREE
.
Uint16
Attribute
(
indices
,
1
)
);
geometry
.
addAttribute
(
'
index
'
,
new
THREE
.
Buffer
Attribute
(
indices
,
1
)
);
var
material
=
new
THREE
.
PointCloudMaterial
(
{
size
:
pointSize
,
vertexColors
:
true
}
);
var
pointcloud
=
new
THREE
.
PointCloud
(
geometry
,
material
);
...
...
@@ -137,14 +148,19 @@
var
indices
=
new
Uint16Array
(
numPoints
);
var
k
=
0
;
for
(
var
i
=
0
;
i
<
width
;
i
++
){
for
(
var
j
=
0
;
j
<
length
;
j
++
)
{
indices
[
k
]
=
k
;
k
++
;
}
}
geometry
.
addAttribute
(
'
index
'
,
new
THREE
.
Uint16
Attribute
(
indices
,
1
)
);
geometry
.
addAttribute
(
'
index
'
,
new
THREE
.
Buffer
Attribute
(
indices
,
1
)
);
var
offset
=
{
start
:
0
,
count
:
indices
.
length
,
index
:
0
};
geometry
.
offsets
.
push
(
offset
);
...
...
@@ -153,7 +169,7 @@
var
pointcloud
=
new
THREE
.
PointCloud
(
geometry
,
material
);
return
pointcloud
;
}
function
generateRegularPointcloud
(
color
,
width
,
length
)
{
...
...
@@ -164,8 +180,11 @@
var
colors
=
[];
var
k
=
0
;
for
(
var
i
=
0
;
i
<
width
;
i
++
)
{
for
(
var
j
=
0
;
j
<
length
;
j
++
)
{
var
u
=
i
/
width
;
var
v
=
j
/
length
;
var
x
=
u
-
0.5
;
...
...
@@ -182,7 +201,9 @@
colors
[
k
]
=
(
color
.
clone
().
multiplyScalar
(
intensity
)
);
k
++
;
}
}
geometry
.
colors
=
colors
;
...
...
@@ -192,7 +213,7 @@
var
pointcloud
=
new
THREE
.
PointCloud
(
geometry
,
material
);
return
pointcloud
;
}
function
init
()
{
...
...
@@ -228,7 +249,7 @@
pcRegular
.
scale
.
set
(
10
,
10
,
10
);
pcRegular
.
position
.
set
(
-
5
,
0
,
-
5
);
scene
.
add
(
pcRegular
);
pointclouds
=
[
pcBuffer
,
pcIndexed
,
pcIndexedOffset
,
pcRegular
];
//
...
...
@@ -268,7 +289,7 @@
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
}
function
onDocumentMouseMove
(
event
)
{
...
...
@@ -310,12 +331,12 @@
projector
.
unprojectVector
(
vector
,
camera
);
raycaster
.
ray
.
set
(
camera
.
position
,
vector
.
sub
(
camera
.
position
).
normalize
()
);
var
intersections
=
raycaster
.
intersectObjects
(
pointclouds
);
intersection
=
(
intersections
.
length
)
>
0
?
intersections
[
0
]
:
null
;
if
(
toggle
>
0.02
&&
intersection
!==
null
)
{
spheres
[
spheresIndex
].
position
.
copy
(
intersection
.
point
);
spheres
[
spheresIndex
].
scale
.
set
(
1
,
1
,
1
);
spheresIndex
=
(
spheresIndex
+
1
)
%
spheres
.
length
;
...
...
@@ -335,6 +356,7 @@
toggle
+=
clock
.
getDelta
();
renderer
.
render
(
scene
,
camera
);
}
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录