Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
7300fbb0
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,发现更多精彩内容 >>
提交
7300fbb0
编写于
8月 11, 2017
作者:
F
Fernando Serrano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add triangle strip and line loop example and fix bufferAttribute componentType detection
上级
f3524521
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
101 addition
and
12 deletion
+101
-12
examples/321103__nsstudios__blip1.wav
examples/321103__nsstudios__blip1.wav
+0
-0
examples/gltf_exporter.html
examples/gltf_exporter.html
+86
-7
examples/js/exporters/GLTFExporter.js
examples/js/exporters/GLTFExporter.js
+15
-5
未找到文件。
examples/321103__nsstudios__blip1.wav
已删除
100644 → 0
浏览文件 @
f3524521
文件已删除
examples/gltf_exporter.html
浏览文件 @
7300fbb0
...
...
@@ -150,7 +150,7 @@
group1
=
new
THREE
.
Group
();
group1
.
name
=
"
Group
"
;
scene1
.
add
(
group1
);
//
scene1.add( group1 );
group2
=
new
THREE
.
Group
();
group2
.
name
=
"
subGroup
"
;
...
...
@@ -159,14 +159,96 @@
object2
=
new
THREE
.
Mesh
(
new
THREE
.
BoxBufferGeometry
(
30
,
30
,
30
),
material
);
object2
.
name
=
"
Cube in group
"
;
object2
.
position
.
set
(
0
,
100
,
100
);
// group2.add( object2 );
group2
.
add
(
object2
);
// ---------------------------------
// Triangle Strip
// ---------------------------------
var
geometry
=
new
THREE
.
BufferGeometry
();
var
positions
=
new
Float32Array
(
6
*
3
);
positions
[
0
]
=
0
;
positions
[
1
]
=
0
;
positions
[
2
]
=
0
;
positions
[
3
]
=
0
;
positions
[
4
]
=
100
;
positions
[
5
]
=
0
;
positions
[
6
]
=
100
;
positions
[
7
]
=
0
;
positions
[
8
]
=
0
;
positions
[
9
]
=
100
;
positions
[
10
]
=
100
;
positions
[
11
]
=
0
;
positions
[
12
]
=
100
;
positions
[
13
]
=
0
;
positions
[
14
]
=
100
;
positions
[
15
]
=
100
;
positions
[
16
]
=
100
;
positions
[
17
]
=
100
;
geometry
.
addAttribute
(
'
position
'
,
new
THREE
.
BufferAttribute
(
positions
,
3
)
);
object
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshStandardMaterial
(
{
color
:
0xff00ff
,
side
:
THREE
.
DoubleSide
}
)
);
object
.
position
.
x
=
150
;
object
.
setDrawMode
(
THREE
.
TriangleStripDrawMode
);
console
.
log
(
object
);
console
.
log
(
'
>>>>
'
,
JSON
.
stringify
(
object
));
scene1
.
add
(
object
);
// ---------------------------------
// Line Strip
// ---------------------------------
var
geometry
=
new
THREE
.
BufferGeometry
();
var
numPoints
=
100
;
var
positions
=
new
Float32Array
(
numPoints
*
3
);
for
(
var
i
=
0
;
i
<
numPoints
;
i
++
)
{
positions
[
i
*
3
]
=
i
;
positions
[
i
*
3
+
1
]
=
Math
.
sin
(
i
/
2
)
*
20
;
positions
[
i
*
3
+
2
]
=
0
;
}
geometry
.
addAttribute
(
'
position
'
,
new
THREE
.
BufferAttribute
(
positions
,
3
)
);
object
=
new
THREE
.
Line
(
geometry
,
new
THREE
.
LineBasicMaterial
(
{
color
:
0xffff00
}
)
);
object
.
position
.
x
=
-
150
;
scene1
.
add
(
object
);
// ---------------------------------
// Line Loop
// ---------------------------------
var
geometry
=
new
THREE
.
BufferGeometry
();
var
numPoints
=
5
;
var
radius
=
100
;
var
positions
=
new
Float32Array
(
numPoints
*
3
);
for
(
var
i
=
0
;
i
<
numPoints
;
i
++
)
{
var
s
=
i
*
Math
.
PI
*
2
/
numPoints
;
positions
[
i
*
3
]
=
radius
*
Math
.
sin
(
s
);
positions
[
i
*
3
+
1
]
=
radius
*
Math
.
cos
(
s
);
positions
[
i
*
3
+
2
]
=
0
;
}
geometry
.
addAttribute
(
'
position
'
,
new
THREE
.
BufferAttribute
(
positions
,
3
)
);
object
=
new
THREE
.
LineLoop
(
geometry
,
new
THREE
.
LineBasicMaterial
(
{
color
:
0xffff00
}
)
);
object
.
position
.
x
=
-
100
;
scene1
.
add
(
object
);
// ---------------------------------
// Axis
// ---------------------------------
var
axis
=
new
THREE
.
AxisHelper
(
100
);
axis
.
name
=
"
AxisHelper
"
;
//
scene1.add( axis );
//scene1.add( axis );
// ---------------------------------
// Points
...
...
@@ -185,10 +267,7 @@
var
pointsMaterial
=
new
THREE
.
PointsMaterial
(
{
color
:
0xffff00
}
);
var
points
=
new
THREE
.
Points
(
pointsGeo
,
pointsMaterial
);
points
.
name
=
"
Points
"
;
scene1
.
add
(
points
);
// scene1.add( points );
scene1
.
add
(
camera
);
...
...
examples/js/exporters/GLTFExporter.js
浏览文件 @
7300fbb0
...
...
@@ -172,9 +172,18 @@ THREE.GLTFExporter.prototype = {
'
VEC4
'
];
var
componentType
;
// Detect the component type of the attribute array (float, uint or ushort)
var
componentType
=
attribute
instanceof
THREE
.
Float32BufferAttribute
?
gl
.
FLOAT
:
(
attribute
instanceof
THREE
.
Uint32BufferAttribute
?
gl
.
UNSIGNED_INT
:
gl
.
UNSIGNED_SHORT
);
if
(
attribute
.
array
.
constructor
===
Float32Array
)
{
componentType
=
gl
.
FLOAT
;
}
else
if
(
attribute
.
array
.
constructor
===
Uint32Array
)
{
componentType
=
gl
.
UNSIGNED_INT
;
}
else
if
(
attribute
.
array
.
constructor
===
Uint16Array
)
{
componentType
=
gl
.
UNSIGNED_SHORT
;
}
else
{
throw
new
Error
(
'
THREE.GLTF2Exporter: Unsupported bufferAttribute component type.
'
);
}
var
minMax
=
getMinMax
(
attribute
);
var
bufferView
=
processBufferView
(
attribute
,
componentType
);
...
...
@@ -421,15 +430,16 @@ THREE.GLTFExporter.prototype = {
mode
=
gl
.
POINTS
;
}
else
{
console
.
log
(
mesh
.
drawMode
,
THREE
.
TrianglesDrawMode
,
THREE
.
TriangleStripDrawMode
,
THREE
.
TriangleFanDrawMode
,
gl
.
TRIANGLE_STRIP
);
// @QUESTION Set mode = gl.LINES if material.wireframe = true ?
if
(
mesh
.
drawMode
===
THREE
.
TriangleFanDrawMode
)
{
mode
=
gl
.
TRIANGLE
S
_FAN
;
mode
=
gl
.
TRIANGLE_FAN
;
}
else
if
(
mesh
.
drawMode
===
THREE
.
TriangleStripDrawMode
)
{
mode
=
gl
.
TRIANGLE
S
_STRIP
;
mode
=
gl
.
TRIANGLE_STRIP
;
}
else
{
...
...
@@ -572,7 +582,7 @@ THREE.GLTFExporter.prototype = {
}
if
(
object
instanceof
THREE
.
Mesh
||
object
instanceof
THREE
.
Line
||
object
instanceof
THREE
.
Line
||
object
instanceof
THREE
.
Points
)
{
gltfNode
.
mesh
=
processMesh
(
object
);
}
else
if
(
object
instanceof
THREE
.
Camera
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录