Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
4d875bbd
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,发现更多精彩内容 >>
未验证
提交
4d875bbd
编写于
6月 04, 2020
作者:
M
Mr.doob
提交者:
GitHub
6月 04, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18783 from Mugen87/dev39
Geometry: Make .fromBufferGeometry() more generic.
上级
95944f9d
8544262f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
70 addition
and
30 deletion
+70
-30
docs/api/en/math/Color.html
docs/api/en/math/Color.html
+8
-0
docs/api/zh/math/Color.html
docs/api/zh/math/Color.html
+8
-0
src/core/Geometry.js
src/core/Geometry.js
+30
-30
src/math/Color.d.ts
src/math/Color.d.ts
+4
-0
src/math/Color.js
src/math/Color.js
+20
-0
未找到文件。
docs/api/en/math/Color.html
浏览文件 @
4d875bbd
...
...
@@ -179,6 +179,14 @@ var color = new THREE.Color( 1, 0, 0 );
Sets this color's components based on an array formatted like [ [page:Float r], [page:Float g], [page:Float b] ].
</p>
<h3>
[method:this fromBufferAttribute]( [param:BufferAttribute attribute], [param:Integer index] )
</h3>
<p>
[page:BufferAttribute attribute] - the source attribute.
<br
/>
[page:Integer index] - index in the attribute.
<br
/><br
/>
Sets this color's components from the [page:BufferAttribute attribute].
</p>
<h3>
[method:Integer getHex]()
</h3>
<p>
Returns the hexadecimal value of this color.
</p>
...
...
docs/api/zh/math/Color.html
浏览文件 @
4d875bbd
...
...
@@ -177,6 +177,14 @@
从格式为[ [page:Float r], [page:Float g], [page:Float b] ]的数组数据中来创建Color对象。
</p>
<h3>
[method:this fromBufferAttribute]( [param:BufferAttribute attribute], [param:Integer index] )
</h3>
<p>
[page:BufferAttribute attribute] - the source attribute.
<br
/>
[page:Integer index] - index in the attribute.
<br
/><br
/>
Sets this color's components from the [page:BufferAttribute attribute].
</p>
<h3>
[method:Integer getHex]()
</h3>
<p>
返回此颜色的十六进制值。
</p>
...
...
src/core/Geometry.js
浏览文件 @
4d875bbd
...
...
@@ -186,7 +186,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
const
scope
=
this
;
const
ind
ices
=
geometry
.
index
!==
null
?
geometry
.
index
.
array
:
undefined
;
const
ind
ex
=
geometry
.
index
!==
null
?
geometry
.
index
:
undefined
;
const
attributes
=
geometry
.
attributes
;
if
(
attributes
.
position
===
undefined
)
{
...
...
@@ -196,21 +196,21 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
}
const
position
s
=
attributes
.
position
.
array
;
const
normal
s
=
attributes
.
normal
!==
undefined
?
attributes
.
normal
.
array
:
undefined
;
const
color
s
=
attributes
.
color
!==
undefined
?
attributes
.
color
.
array
:
undefined
;
const
uv
s
=
attributes
.
uv
!==
undefined
?
attributes
.
uv
.
array
:
undefined
;
const
uv
s2
=
attributes
.
uv2
!==
undefined
?
attributes
.
uv2
.
array
:
undefined
;
const
position
=
attributes
.
position
;
const
normal
=
attributes
.
normal
;
const
color
=
attributes
.
color
;
const
uv
=
attributes
.
uv
;
const
uv
2
=
attributes
.
uv2
;
if
(
uv
s
2
!==
undefined
)
this
.
faceVertexUvs
[
1
]
=
[];
if
(
uv2
!==
undefined
)
this
.
faceVertexUvs
[
1
]
=
[];
for
(
let
i
=
0
;
i
<
position
s
.
length
;
i
+=
3
)
{
for
(
let
i
=
0
;
i
<
position
.
count
;
i
++
)
{
scope
.
vertices
.
push
(
new
Vector3
().
from
Array
(
positions
,
i
)
);
scope
.
vertices
.
push
(
new
Vector3
().
from
BufferAttribute
(
position
,
i
)
);
if
(
color
s
!==
undefined
)
{
if
(
color
!==
undefined
)
{
scope
.
colors
.
push
(
new
Color
().
from
Array
(
colors
,
i
)
);
scope
.
colors
.
push
(
new
Color
().
from
BufferAttribute
(
color
,
i
)
);
}
...
...
@@ -218,37 +218,37 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
function
addFace
(
a
,
b
,
c
,
materialIndex
)
{
const
vertexColors
=
(
color
s
===
undefined
)
?
[]
:
[
const
vertexColors
=
(
color
===
undefined
)
?
[]
:
[
scope
.
colors
[
a
].
clone
(),
scope
.
colors
[
b
].
clone
(),
scope
.
colors
[
c
].
clone
()
];
const
vertexNormals
=
(
normal
s
===
undefined
)
?
[]
:
[
new
Vector3
().
from
Array
(
normals
,
a
*
3
),
new
Vector3
().
from
Array
(
normals
,
b
*
3
),
new
Vector3
().
from
Array
(
normals
,
c
*
3
)
const
vertexNormals
=
(
normal
===
undefined
)
?
[]
:
[
new
Vector3
().
from
BufferAttribute
(
normal
,
a
),
new
Vector3
().
from
BufferAttribute
(
normal
,
b
),
new
Vector3
().
from
BufferAttribute
(
normal
,
c
)
];
const
face
=
new
Face3
(
a
,
b
,
c
,
vertexNormals
,
vertexColors
,
materialIndex
);
scope
.
faces
.
push
(
face
);
if
(
uv
s
!==
undefined
)
{
if
(
uv
!==
undefined
)
{
scope
.
faceVertexUvs
[
0
].
push
(
[
new
Vector2
().
from
Array
(
uvs
,
a
*
2
),
new
Vector2
().
from
Array
(
uvs
,
b
*
2
),
new
Vector2
().
from
Array
(
uvs
,
c
*
2
)
new
Vector2
().
from
BufferAttribute
(
uv
,
a
),
new
Vector2
().
from
BufferAttribute
(
uv
,
b
),
new
Vector2
().
from
BufferAttribute
(
uv
,
c
)
]
);
}
if
(
uv
s
2
!==
undefined
)
{
if
(
uv2
!==
undefined
)
{
scope
.
faceVertexUvs
[
1
].
push
(
[
new
Vector2
().
from
Array
(
uvs2
,
a
*
2
),
new
Vector2
().
from
Array
(
uvs2
,
b
*
2
),
new
Vector2
().
from
Array
(
uvs2
,
c
*
2
)
new
Vector2
().
from
BufferAttribute
(
uv2
,
a
),
new
Vector2
().
from
BufferAttribute
(
uv2
,
b
),
new
Vector2
().
from
BufferAttribute
(
uv2
,
c
)
]
);
}
...
...
@@ -268,9 +268,9 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
for
(
let
j
=
start
,
jl
=
start
+
count
;
j
<
jl
;
j
+=
3
)
{
if
(
ind
ices
!==
undefined
)
{
if
(
ind
ex
!==
undefined
)
{
addFace
(
ind
ices
[
j
],
indices
[
j
+
1
],
indices
[
j
+
2
]
,
group
.
materialIndex
);
addFace
(
ind
ex
.
getX
(
j
),
index
.
getX
(
j
+
1
),
index
.
getX
(
j
+
2
)
,
group
.
materialIndex
);
}
else
{
...
...
@@ -284,17 +284,17 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
}
else
{
if
(
ind
ices
!==
undefined
)
{
if
(
ind
ex
!==
undefined
)
{
for
(
let
i
=
0
;
i
<
ind
ices
.
length
;
i
+=
3
)
{
for
(
let
i
=
0
;
i
<
ind
ex
.
count
;
i
+=
3
)
{
addFace
(
ind
ices
[
i
],
indices
[
i
+
1
],
indices
[
i
+
2
]
);
addFace
(
ind
ex
.
getX
(
i
),
index
.
getX
(
i
+
1
),
index
.
getX
(
i
+
2
)
);
}
}
else
{
for
(
let
i
=
0
;
i
<
position
s
.
length
/
3
;
i
+=
3
)
{
for
(
let
i
=
0
;
i
<
position
.
count
;
i
+=
3
)
{
addFace
(
i
,
i
+
1
,
i
+
2
);
...
...
src/math/Color.d.ts
浏览文件 @
4d875bbd
import
{
BufferAttribute
}
from
'
./../core/BufferAttribute
'
;
/**
* @author Joe Pea / http://github.com/trusktr
*/
...
...
@@ -188,6 +190,8 @@ export class Color {
*/
toArray
(
xyz
:
ArrayLike
<
number
>
,
offset
?:
number
):
ArrayLike
<
number
>
;
fromBufferAttribute
(
attribute
:
BufferAttribute
,
index
:
number
):
this
;
/**
* List of X11 color names.
*/
...
...
src/math/Color.js
浏览文件 @
4d875bbd
...
...
@@ -580,6 +580,26 @@ Object.assign( Color.prototype, {
},
fromBufferAttribute
:
function
(
attribute
,
index
)
{
this
.
r
=
attribute
.
getX
(
index
);
this
.
g
=
attribute
.
getY
(
index
);
this
.
b
=
attribute
.
getZ
(
index
);
if
(
attribute
.
normalized
===
true
)
{
// assuming Uint8Array
this
.
r
/=
255
;
this
.
g
/=
255
;
this
.
b
/=
255
;
}
return
this
;
},
toJSON
:
function
()
{
return
this
.
getHex
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录