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 {
const
num_strokes
=
data
.
getInt32
(
16
,
true
);
const
brushes
=
{};
let
offset
=
20
;
for
(
let
i
=
0
;
i
<
num_strokes
;
i
++
)
{
...
...
@@ -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
]
);
group
.
add
(
new
Mesh
(
geometry
,
material
)
);
}
return
group
;
...
...
@@ -152,7 +163,7 @@ class TiltLoader extends Loader {
class
StrokeGeometry
extends
BufferGeometry
{
constructor
(
positions
,
quaternions
,
size
,
color
)
{
constructor
(
strokes
)
{
super
();
...
...
@@ -161,10 +172,10 @@ class StrokeGeometry extends BufferGeometry {
const
uvs
=
[];
const
position
=
new
Vector3
();
const
prevPosition
=
new
Vector3
()
.
fromArray
(
positions
,
0
)
;
const
prevPosition
=
new
Vector3
();
const
quaternion
=
new
Quaternion
();
const
prevQuaternion
=
new
Quaternion
()
.
fromArray
(
quaternions
,
0
)
;
const
prevQuaternion
=
new
Quaternion
();
const
vector1
=
new
Vector3
();
const
vector2
=
new
Vector3
();
...
...
@@ -173,56 +184,69 @@ class StrokeGeometry extends BufferGeometry {
// 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
);
position
.
fromArray
(
positions
,
i
);
quaternion
.
fromArray
(
quaternions
,
j
);
for
(
let
i
=
3
,
j
=
4
,
l
=
positions
.
length
;
i
<
l
;
i
+=
3
,
j
+=
4
)
{
vector1
.
set
(
-
size
,
0
,
0
);
vector1
.
applyQuaternion
(
quaternion
);
vector1
.
add
(
position
);
position
.
fromArray
(
positions
,
i
);
quaternion
.
fromArray
(
quaternions
,
j
);
vector2
.
set
(
size
,
0
,
0
);
vector2
.
applyQuaternion
(
quaternion
);
vector2
.
add
(
position
);
vector1
.
set
(
-
size
,
0
,
0
);
vector1
.
applyQuaternion
(
quaternion
);
vector1
.
add
(
position
);
vector3
.
set
(
size
,
0
,
0
);
vector3
.
applyQuaternion
(
prevQ
uaternion
);
vector3
.
add
(
prevP
osition
);
vector2
.
set
(
size
,
0
,
0
);
vector2
.
applyQuaternion
(
q
uaternion
);
vector2
.
add
(
p
osition
);
vector4
.
set
(
-
size
,
0
,
0
);
vector4
.
applyQuaternion
(
prevQuaternion
);
vector4
.
add
(
prevPosition
);
vector3
.
set
(
size
,
0
,
0
);
vector3
.
applyQuaternion
(
prevQuaternion
);
vector3
.
add
(
prevPosition
);
vertices
.
push
(
vector1
.
x
,
vector1
.
y
,
-
vector1
.
z
);
vertices
.
push
(
vector2
.
x
,
vector2
.
y
,
-
vector2
.
z
);
vertices
.
push
(
vector4
.
x
,
vector4
.
y
,
-
vector4
.
z
);
vector4
.
set
(
-
size
,
0
,
0
);
vector4
.
applyQuaternion
(
prevQuaternion
);
vector4
.
add
(
prevPosition
);
vertices
.
push
(
vector2
.
x
,
vector2
.
y
,
-
vector2
.
z
);
vertices
.
push
(
vector3
.
x
,
vector3
.
y
,
-
vector3
.
z
);
vertices
.
push
(
vector4
.
x
,
vector4
.
y
,
-
vector4
.
z
);
vertices
.
push
(
vector1
.
x
,
vector1
.
y
,
-
vector1
.
z
);
vertices
.
push
(
vector2
.
x
,
vector2
.
y
,
-
vector2
.
z
);
vertices
.
push
(
vector4
.
x
,
vector4
.
y
,
-
vector4
.
z
);
prevPosition
.
copy
(
position
);
prevQuaternion
.
copy
(
quaternion
);
vertices
.
push
(
vector2
.
x
,
vector2
.
y
,
-
vector2
.
z
);
vertices
.
push
(
vector3
.
x
,
vector3
.
y
,
-
vector3
.
z
);
vertices
.
push
(
vector4
.
x
,
vector4
.
y
,
-
vector4
.
z
);
colors
.
push
(
...
color
);
colors
.
push
(
...
color
);
colors
.
push
(
...
color
);
prevPosition
.
copy
(
position
);
prevQuaternion
.
copy
(
quaternion
);
colors
.
push
(
...
color
);
colors
.
push
(
...
color
);
colors
.
push
(
...
color
);
colors
.
push
(
...
color
);
colors
.
push
(
...
color
);
colors
.
push
(
...
color
);
const
p1
=
i
/
l
;
const
p2
=
(
i
-
3
)
/
l
;
colors
.
push
(
...
color
);
colors
.
push
(
...
color
);
colors
.
push
(
...
color
);
uvs
.
push
(
p1
,
0
);
uvs
.
push
(
p1
,
1
);
uvs
.
push
(
p2
,
0
);
const
p1
=
i
/
l
;
const
p2
=
(
i
-
3
)
/
l
;
uvs
.
push
(
p1
,
1
);
uvs
.
push
(
p2
,
1
);
uvs
.
push
(
p2
,
0
);
uvs
.
push
(
p1
,
0
);
uvs
.
push
(
p1
,
1
);
uvs
.
push
(
p2
,
0
);
uvs
.
push
(
p1
,
1
);
uvs
.
push
(
p2
,
1
);
uvs
.
push
(
p2
,
0
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录