Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
3fea7a65
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,体验更适合开发者的 AI 搜索 >>
提交
3fea7a65
编写于
12月 23, 2020
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TiltLoader: Join strokes by brush type.
上级
72730a56
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
67 addition
and
43 deletion
+67
-43
examples/jsm/loaders/TiltLoader.js
examples/jsm/loaders/TiltLoader.js
+67
-43
未找到文件。
examples/jsm/loaders/TiltLoader.js
浏览文件 @
3fea7a65
...
@@ -76,6 +76,8 @@ class TiltLoader extends Loader {
...
@@ -76,6 +76,8 @@ class TiltLoader extends Loader {
const
num_strokes
=
data
.
getInt32
(
16
,
true
);
const
num_strokes
=
data
.
getInt32
(
16
,
true
);
const
brushes
=
{};
let
offset
=
20
;
let
offset
=
20
;
for
(
let
i
=
0
;
i
<
num_strokes
;
i
++
)
{
for
(
let
i
=
0
;
i
<
num_strokes
;
i
++
)
{
...
@@ -134,14 +136,23 @@ class TiltLoader extends Loader {
...
@@ -134,14 +136,23 @@ class TiltLoader extends Loader {
}
}
// console.log( positions, quaternions );
if
(
brush_index
in
brushes
===
false
)
{
brushes
[
brush_index
]
=
[];
}
brushes
[
brush_index
].
push
(
[
positions
,
quaternions
,
brush_size
,
brush_color
]
);
}
for
(
const
brush_index
in
brushes
)
{
const
geometry
=
new
StrokeGeometry
(
positions
,
quaternions
,
brush_size
,
brush_color
);
const
geometry
=
new
StrokeGeometry
(
brushes
[
brush_index
]
);
const
material
=
getMaterial
(
metadata
.
BrushIndex
[
brush_index
]
);
const
material
=
getMaterial
(
metadata
.
BrushIndex
[
brush_index
]
);
group
.
add
(
new
Mesh
(
geometry
,
material
)
);
group
.
add
(
new
Mesh
(
geometry
,
material
)
);
}
}
return
group
;
return
group
;
...
@@ -152,7 +163,7 @@ class TiltLoader extends Loader {
...
@@ -152,7 +163,7 @@ class TiltLoader extends Loader {
class
StrokeGeometry
extends
BufferGeometry
{
class
StrokeGeometry
extends
BufferGeometry
{
constructor
(
positions
,
quaternions
,
size
,
color
)
{
constructor
(
strokes
)
{
super
();
super
();
...
@@ -161,10 +172,10 @@ class StrokeGeometry extends BufferGeometry {
...
@@ -161,10 +172,10 @@ class StrokeGeometry extends BufferGeometry {
const
uvs
=
[];
const
uvs
=
[];
const
position
=
new
Vector3
();
const
position
=
new
Vector3
();
const
prevPosition
=
new
Vector3
()
.
fromArray
(
positions
,
0
)
;
const
prevPosition
=
new
Vector3
();
const
quaternion
=
new
Quaternion
();
const
quaternion
=
new
Quaternion
();
const
prevQuaternion
=
new
Quaternion
()
.
fromArray
(
quaternions
,
0
)
;
const
prevQuaternion
=
new
Quaternion
();
const
vector1
=
new
Vector3
();
const
vector1
=
new
Vector3
();
const
vector2
=
new
Vector3
();
const
vector2
=
new
Vector3
();
...
@@ -173,7 +184,18 @@ class StrokeGeometry extends BufferGeometry {
...
@@ -173,7 +184,18 @@ class StrokeGeometry extends BufferGeometry {
// size = size / 2;
// size = size / 2;
for
(
let
i
=
0
,
j
=
0
,
l
=
positions
.
length
;
i
<
l
;
i
+=
3
,
j
+=
4
)
{
for
(
const
k
in
strokes
)
{
const
stroke
=
strokes
[
k
];
const
positions
=
stroke
[
0
];
const
quaternions
=
stroke
[
1
];
const
size
=
stroke
[
2
];
const
color
=
stroke
[
3
];
prevPosition
.
fromArray
(
positions
,
0
);
prevQuaternion
.
fromArray
(
quaternions
,
0
);
for
(
let
i
=
3
,
j
=
4
,
l
=
positions
.
length
;
i
<
l
;
i
+=
3
,
j
+=
4
)
{
position
.
fromArray
(
positions
,
i
);
position
.
fromArray
(
positions
,
i
);
quaternion
.
fromArray
(
quaternions
,
j
);
quaternion
.
fromArray
(
quaternions
,
j
);
...
@@ -226,6 +248,8 @@ class StrokeGeometry extends BufferGeometry {
...
@@ -226,6 +248,8 @@ class StrokeGeometry extends BufferGeometry {
}
}
}
this
.
setAttribute
(
'
position
'
,
new
BufferAttribute
(
new
Float32Array
(
vertices
),
3
)
);
this
.
setAttribute
(
'
position
'
,
new
BufferAttribute
(
new
Float32Array
(
vertices
),
3
)
);
this
.
setAttribute
(
'
color
'
,
new
BufferAttribute
(
new
Float32Array
(
colors
),
4
)
);
this
.
setAttribute
(
'
color
'
,
new
BufferAttribute
(
new
Float32Array
(
colors
),
4
)
);
this
.
setAttribute
(
'
uv
'
,
new
BufferAttribute
(
new
Float32Array
(
uvs
),
2
)
);
this
.
setAttribute
(
'
uv
'
,
new
BufferAttribute
(
new
Float32Array
(
uvs
),
2
)
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录