Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
726f2bb3
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,体验更适合开发者的 AI 搜索 >>
提交
726f2bb3
编写于
11月 27, 2019
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Examples: Improved webgl_instancing_*
上级
66c519c4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
18 deletion
+23
-18
examples/files.js
examples/files.js
+1
-1
examples/webgl_instancing_raycast.html
examples/webgl_instancing_raycast.html
+20
-15
examples/webgl_instancing_suzanne.html
examples/webgl_instancing_suzanne.html
+2
-2
未找到文件。
examples/files.js
浏览文件 @
726f2bb3
...
...
@@ -47,8 +47,8 @@ var files = {
"
webgl_geometry_text_shapes
"
,
"
webgl_geometry_text_stroke
"
,
"
webgl_helpers
"
,
"
webgl_instancing_suzanne
"
,
"
webgl_instancing_raycast
"
,
"
webgl_instancing_suzanne
"
,
"
webgl_interactive_buffergeometry
"
,
"
webgl_interactive_cubes
"
,
"
webgl_interactive_cubes_gpu
"
,
...
...
examples/webgl_instancing_raycast.html
浏览文件 @
726f2bb3
...
...
@@ -17,12 +17,10 @@
var
camera
,
scene
,
renderer
,
stats
;
var
mesh
,
geometry
;
var
amount
=
parseInt
(
window
.
location
.
search
.
substr
(
1
)
)
||
3
;
var
mesh
;
var
amount
=
parseInt
(
window
.
location
.
search
.
substr
(
1
)
)
||
10
;
var
count
=
Math
.
pow
(
amount
,
3
);
var
object
=
new
THREE
.
Object3D
();
var
intersection
;
var
raycaster
=
new
THREE
.
Raycaster
();
var
mouse
=
new
THREE
.
Vector2
(
1
,
1
);
...
...
@@ -36,21 +34,29 @@
function
init
()
{
camera
=
new
THREE
.
PerspectiveCamera
(
60
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
100
0
);
camera
=
new
THREE
.
PerspectiveCamera
(
60
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
100
);
camera
.
position
.
set
(
amount
,
amount
,
amount
);
camera
.
lookAt
(
0
,
0
,
0
);
scene
=
new
THREE
.
Scene
();
geometry
=
new
THREE
.
TorusKnotBufferGeometry
(
0.5
,
0.2
,
16
,
4
,
2
,
3
);
geometry
.
scale
(
0.5
,
0.5
,
0.5
);
var
light
=
new
THREE
.
HemisphereLight
(
0xffffff
,
0x000088
);
light
.
position
.
set
(
-
1
,
1.5
,
1
);
scene
.
add
(
light
);
var
material
=
new
THREE
.
MeshNormalMaterial
(
{
flatShading
:
true
}
);
var
light
=
new
THREE
.
HemisphereLight
(
0xffffff
,
0x880000
,
0.5
);
light
.
position
.
set
(
-
1
,
-
1.5
,
-
1
);
scene
.
add
(
light
);
var
geometry
=
new
THREE
.
SphereBufferGeometry
(
0.5
);
var
material
=
new
THREE
.
MeshPhongMaterial
(
{
flatShading
:
true
}
);
mesh
=
new
THREE
.
InstancedMesh
(
geometry
,
material
,
count
);
var
i
=
0
;
var
offset
=
amount
/
2
;
var
offset
=
(
amount
-
1
)
/
2
;
var
transform
=
new
THREE
.
Object3D
();
for
(
var
x
=
0
;
x
<
amount
;
x
++
)
{
...
...
@@ -58,11 +64,10 @@
for
(
var
z
=
0
;
z
<
amount
;
z
++
)
{
object
.
position
.
set
(
offset
-
x
,
offset
-
y
,
offset
-
z
);
object
.
updateMatrix
();
transform
.
position
.
set
(
offset
-
x
,
offset
-
y
,
offset
-
z
);
transform
.
updateMatrix
();
mesh
.
setMatrixAt
(
i
++
,
object
.
matrix
);
mesh
.
setMatrixAt
(
i
++
,
transform
.
matrix
);
}
...
...
@@ -82,7 +87,7 @@
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
var
orbitControls
=
new
OrbitControls
(
camera
,
renderer
.
domElement
);
new
OrbitControls
(
camera
,
renderer
.
domElement
);
stats
=
new
Stats
();
document
.
body
.
appendChild
(
stats
.
dom
);
...
...
@@ -122,7 +127,7 @@
raycaster
.
setFromCamera
(
mouse
,
camera
);
intersection
=
raycaster
.
intersectObjects
(
scene
.
children
);
var
intersection
=
raycaster
.
intersectObject
(
mesh
);
if
(
intersection
.
length
>
0
)
{
...
...
examples/webgl_instancing_suzanne.html
浏览文件 @
726f2bb3
...
...
@@ -27,7 +27,7 @@
function
init
()
{
camera
=
new
THREE
.
PerspectiveCamera
(
60
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
100
0
);
camera
=
new
THREE
.
PerspectiveCamera
(
60
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
100
);
camera
.
position
.
set
(
amount
*
0.9
,
amount
*
0.9
,
amount
*
0.9
);
camera
.
lookAt
(
0
,
0
,
0
);
...
...
@@ -102,7 +102,7 @@
mesh
.
rotation
.
y
=
Math
.
sin
(
time
/
2
);
var
i
=
0
;
var
offset
=
amount
/
2
;
var
offset
=
(
amount
-
1
)
/
2
;
for
(
var
x
=
0
;
x
<
amount
;
x
++
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录