Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
494061f5
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,发现更多精彩内容 >>
未验证
提交
494061f5
编写于
11月 29, 2019
作者:
M
Mr.doob
提交者:
GitHub
11月 29, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17991 from WestLangley/dev_tangents_helper
Added VertexTangentsHelper
上级
4a70b409
86324aa2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
120 addition
and
1 deletion
+120
-1
src/Three.js
src/Three.js
+1
-0
src/helpers/VertexNormalsHelper.d.ts
src/helpers/VertexNormalsHelper.d.ts
+1
-1
src/helpers/VertexTangentsHelper.d.ts
src/helpers/VertexTangentsHelper.d.ts
+18
-0
src/helpers/VertexTangentsHelper.js
src/helpers/VertexTangentsHelper.js
+100
-0
未找到文件。
src/Three.js
浏览文件 @
494061f5
...
...
@@ -131,6 +131,7 @@ export { Color } from './math/Color.js';
export
{
SphericalHarmonics3
}
from
'
./math/SphericalHarmonics3.js
'
;
export
{
ImmediateRenderObject
}
from
'
./extras/objects/ImmediateRenderObject.js
'
;
export
{
VertexNormalsHelper
}
from
'
./helpers/VertexNormalsHelper.js
'
;
export
{
VertexTangentsHelper
}
from
'
./helpers/VertexTangentsHelper.js
'
;
export
{
SpotLightHelper
}
from
'
./helpers/SpotLightHelper.js
'
;
export
{
SkeletonHelper
}
from
'
./helpers/SkeletonHelper.js
'
;
export
{
PointLightHelper
}
from
'
./helpers/PointLightHelper.js
'
;
...
...
src/helpers/VertexNormalsHelper.d.ts
浏览文件 @
494061f5
...
...
@@ -13,6 +13,6 @@ export class VertexNormalsHelper extends LineSegments {
object
:
Object3D
;
size
:
number
;
update
(
object
?:
Object3D
):
void
;
update
():
void
;
}
src/helpers/VertexTangentsHelper.d.ts
0 → 100644
浏览文件 @
494061f5
import
{
Object3D
}
from
'
./../core/Object3D
'
;
import
{
LineSegments
}
from
'
./../objects/LineSegments
'
;
export
class
VertexTangentsHelper
extends
LineSegments
{
constructor
(
object
:
Object3D
,
size
?:
number
,
hex
?:
number
,
linewidth
?:
number
);
object
:
Object3D
;
size
:
number
;
update
():
void
;
}
src/helpers/VertexTangentsHelper.js
0 → 100644
浏览文件 @
494061f5
/**
* @author WestLangley / http://github.com/WestLangley
*/
import
{
Vector3
}
from
'
../math/Vector3.js
'
;
import
{
LineSegments
}
from
'
../objects/LineSegments.js
'
;
import
{
LineBasicMaterial
}
from
'
../materials/LineBasicMaterial.js
'
;
import
{
Float32BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
import
{
BufferGeometry
}
from
'
../core/BufferGeometry.js
'
;
var
_v1
=
new
Vector3
();
var
_v2
=
new
Vector3
();
function
VertexTangentsHelper
(
object
,
size
,
hex
,
linewidth
)
{
this
.
object
=
object
;
this
.
size
=
(
size
!==
undefined
)
?
size
:
1
;
var
color
=
(
hex
!==
undefined
)
?
hex
:
0x00ffff
;
var
width
=
(
linewidth
!==
undefined
)
?
linewidth
:
1
;
//
var
objGeometry
=
this
.
object
.
geometry
;
if
(
!
(
objGeometry
&&
objGeometry
.
isBufferGeometry
)
)
{
console
.
error
(
'
THREE.VertexTangentsHelper: geometry not an instance of THREE.BufferGeometry.
'
,
objGeometry
);
return
;
}
var
nTangents
=
objGeometry
.
attributes
.
tangent
.
count
;
//
var
geometry
=
new
BufferGeometry
();
var
positions
=
new
Float32BufferAttribute
(
nTangents
*
2
*
3
,
3
);
geometry
.
setAttribute
(
'
position
'
,
positions
);
LineSegments
.
call
(
this
,
geometry
,
new
LineBasicMaterial
(
{
color
:
color
,
linewidth
:
width
}
)
);
//
this
.
matrixAutoUpdate
=
false
;
this
.
update
();
}
VertexTangentsHelper
.
prototype
=
Object
.
create
(
LineSegments
.
prototype
);
VertexTangentsHelper
.
prototype
.
constructor
=
VertexTangentsHelper
;
VertexTangentsHelper
.
prototype
.
update
=
function
()
{
this
.
object
.
updateMatrixWorld
(
true
);
var
matrixWorld
=
this
.
object
.
matrixWorld
;
var
position
=
this
.
geometry
.
attributes
.
position
;
//
var
objGeometry
=
this
.
object
.
geometry
;
var
objPos
=
objGeometry
.
attributes
.
position
;
var
objTan
=
objGeometry
.
attributes
.
tangent
;
var
idx
=
0
;
// for simplicity, ignore index and drawcalls, and render every tangent
for
(
var
j
=
0
,
jl
=
objPos
.
count
;
j
<
jl
;
j
++
)
{
_v1
.
set
(
objPos
.
getX
(
j
),
objPos
.
getY
(
j
),
objPos
.
getZ
(
j
)
).
applyMatrix4
(
matrixWorld
);
_v2
.
set
(
objTan
.
getX
(
j
),
objTan
.
getY
(
j
),
objTan
.
getZ
(
j
)
);
_v2
.
transformDirection
(
matrixWorld
).
multiplyScalar
(
this
.
size
).
add
(
_v1
);
position
.
setXYZ
(
idx
,
_v1
.
x
,
_v1
.
y
,
_v1
.
z
);
idx
=
idx
+
1
;
position
.
setXYZ
(
idx
,
_v2
.
x
,
_v2
.
y
,
_v2
.
z
);
idx
=
idx
+
1
;
}
position
.
needsUpdate
=
true
;
};
export
{
VertexTangentsHelper
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录