Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
d905a219
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,体验更适合开发者的 AI 搜索 >>
提交
d905a219
编写于
8月 10, 2021
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated examples builds.
上级
fd5e6cfb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
143 addition
and
28 deletion
+143
-28
examples/js/curves/NURBSUtils.js
examples/js/curves/NURBSUtils.js
+11
-11
examples/js/utils/SkeletonUtils.js
examples/js/utils/SkeletonUtils.js
+17
-17
examples/js/utils/WorkerPool.js
examples/js/utils/WorkerPool.js
+115
-0
未找到文件。
examples/js/curves/NURBSUtils.js
浏览文件 @
d905a219
...
...
@@ -115,8 +115,8 @@ returns point for given u
function
calcBSplinePoint
(
p
,
U
,
P
,
u
)
{
const
span
=
this
.
findSpan
(
p
,
u
,
U
);
const
N
=
this
.
calcBasisFunctions
(
span
,
u
,
p
,
U
);
const
span
=
findSpan
(
p
,
u
,
U
);
const
N
=
calcBasisFunctions
(
span
,
u
,
p
,
U
);
const
C
=
new
THREE
.
Vector4
(
0
,
0
,
0
,
0
);
for
(
let
j
=
0
;
j
<=
p
;
++
j
)
{
...
...
@@ -279,8 +279,8 @@ returns array[n+1][p+1] with basis functions derivatives
const
du
=
nd
<
p
?
nd
:
p
;
const
CK
=
[];
const
span
=
this
.
findSpan
(
p
,
u
,
U
);
const
nders
=
this
.
calcBasisFunctionDerivatives
(
span
,
u
,
p
,
du
,
U
);
const
span
=
findSpan
(
p
,
u
,
U
);
const
nders
=
calcBasisFunctionDerivatives
(
span
,
u
,
p
,
du
,
U
);
const
Pw
=
[];
for
(
let
i
=
0
;
i
<
P
.
length
;
++
i
)
{
...
...
@@ -382,7 +382,7 @@ returns array with derivatives for rational curve.
for
(
let
i
=
1
;
i
<=
k
;
++
i
)
{
v
.
sub
(
CK
[
k
-
i
].
clone
().
multiplyScalar
(
this
.
calcKoverI
(
k
,
i
)
*
wders
[
i
]
)
);
v
.
sub
(
CK
[
k
-
i
].
clone
().
multiplyScalar
(
calcKoverI
(
k
,
i
)
*
wders
[
i
]
)
);
}
...
...
@@ -408,8 +408,8 @@ returns array with derivatives.
function
calcNURBSDerivatives
(
p
,
U
,
P
,
u
,
nd
)
{
const
Pders
=
this
.
calcBSplineDerivatives
(
p
,
U
,
P
,
u
,
nd
);
return
this
.
calcRationalCurveDerivatives
(
Pders
);
const
Pders
=
calcBSplineDerivatives
(
p
,
U
,
P
,
u
,
nd
);
return
calcRationalCurveDerivatives
(
Pders
);
}
/*
...
...
@@ -426,10 +426,10 @@ returns point for given (u, v)
function
calcSurfacePoint
(
p
,
q
,
U
,
V
,
P
,
u
,
v
,
target
)
{
const
uspan
=
this
.
findSpan
(
p
,
u
,
U
);
const
vspan
=
this
.
findSpan
(
q
,
v
,
V
);
const
Nu
=
this
.
calcBasisFunctions
(
uspan
,
u
,
p
,
U
);
const
Nv
=
this
.
calcBasisFunctions
(
vspan
,
v
,
q
,
V
);
const
uspan
=
findSpan
(
p
,
u
,
U
);
const
vspan
=
findSpan
(
q
,
v
,
V
);
const
Nu
=
calcBasisFunctions
(
uspan
,
u
,
p
,
U
);
const
Nv
=
calcBasisFunctions
(
vspan
,
v
,
q
,
V
);
const
temp
=
[];
for
(
let
l
=
0
;
l
<=
q
;
++
l
)
{
...
...
examples/js/utils/SkeletonUtils.js
浏览文件 @
d905a219
...
...
@@ -14,8 +14,8 @@
options
.
useTargetMatrix
=
options
.
useTargetMatrix
!==
undefined
?
options
.
useTargetMatrix
:
false
;
options
.
hip
=
options
.
hip
!==
undefined
?
options
.
hip
:
'
hip
'
;
options
.
names
=
options
.
names
||
{};
const
sourceBones
=
source
.
isObject3D
?
source
.
skeleton
.
bones
:
this
.
getBones
(
source
),
bones
=
target
.
isObject3D
?
target
.
skeleton
.
bones
:
this
.
getBones
(
target
);
const
sourceBones
=
source
.
isObject3D
?
source
.
skeleton
.
bones
:
getBones
(
source
),
bones
=
target
.
isObject3D
?
target
.
skeleton
.
bones
:
getBones
(
target
);
let
bindBones
,
bone
,
name
,
boneTo
,
bonesPosition
;
// reset bones
if
(
target
.
isObject3D
)
{
...
...
@@ -82,7 +82,7 @@
bone
=
bones
[
i
];
name
=
options
.
names
[
bone
.
name
]
||
bone
.
name
;
boneTo
=
this
.
getBoneByName
(
name
,
sourceBones
);
boneTo
=
getBoneByName
(
name
,
sourceBones
);
globalMatrix
.
copy
(
bone
.
matrixWorld
);
if
(
boneTo
)
{
...
...
@@ -174,7 +174,7 @@
if
(
!
source
.
isObject3D
)
{
source
=
this
.
getHelperFromSkeleton
(
source
);
source
=
getHelperFromSkeleton
(
source
);
}
...
...
@@ -182,7 +182,7 @@
delta
=
1
/
options
.
fps
,
convertedTracks
=
[],
mixer
=
new
THREE
.
AnimationMixer
(
source
),
bones
=
this
.
getBones
(
target
.
skeleton
),
bones
=
getBones
(
target
.
skeleton
),
boneDatas
=
[];
let
positionOffset
,
bone
,
boneTo
,
boneData
,
name
;
mixer
.
clipAction
(
clip
).
play
();
...
...
@@ -192,12 +192,12 @@
for
(
let
i
=
0
;
i
<
numFrames
;
++
i
)
{
const
time
=
i
*
delta
;
this
.
retarget
(
target
,
source
,
options
);
retarget
(
target
,
source
,
options
);
for
(
let
j
=
0
;
j
<
bones
.
length
;
++
j
)
{
name
=
options
.
names
[
bones
[
j
].
name
]
||
bones
[
j
].
name
;
boneTo
=
this
.
getBoneByName
(
name
,
source
.
skeleton
);
boneTo
=
getBoneByName
(
name
,
source
.
skeleton
);
if
(
boneTo
)
{
...
...
@@ -299,14 +299,14 @@
if
(
!
source
.
isObject3D
)
{
source
=
this
.
getHelperFromSkeleton
(
source
);
source
=
getHelperFromSkeleton
(
source
);
}
const
nameKeys
=
Object
.
keys
(
options
.
names
),
nameValues
=
Object
.
values
(
options
.
names
),
sourceBones
=
source
.
isObject3D
?
source
.
skeleton
.
bones
:
this
.
getBones
(
source
),
bones
=
target
.
isObject3D
?
target
.
skeleton
.
bones
:
this
.
getBones
(
target
),
sourceBones
=
source
.
isObject3D
?
source
.
skeleton
.
bones
:
getBones
(
source
),
bones
=
target
.
isObject3D
?
target
.
skeleton
.
bones
:
getBones
(
target
),
offsets
=
[];
let
bone
,
boneTo
,
name
,
i
;
target
.
skeleton
.
pose
();
...
...
@@ -315,12 +315,12 @@
bone
=
bones
[
i
];
name
=
options
.
names
[
bone
.
name
]
||
bone
.
name
;
boneTo
=
this
.
getBoneByName
(
name
,
sourceBones
);
boneTo
=
getBoneByName
(
name
,
sourceBones
);
if
(
boneTo
&&
name
!==
options
.
hip
)
{
const
boneParent
=
this
.
getNearestBone
(
bone
.
parent
,
nameKeys
),
boneToParent
=
this
.
getNearestBone
(
boneTo
.
parent
,
nameValues
);
const
boneParent
=
getNearestBone
(
bone
.
parent
,
nameKeys
),
boneToParent
=
getNearestBone
(
boneTo
.
parent
,
nameValues
);
boneParent
.
updateMatrixWorld
();
boneToParent
.
updateMatrixWorld
();
targetParentPos
.
setFromMatrixPosition
(
boneParent
.
matrixWorld
);
...
...
@@ -346,7 +346,7 @@
function
renameBones
(
skeleton
,
names
)
{
const
bones
=
this
.
getBones
(
skeleton
);
const
bones
=
getBones
(
skeleton
);
for
(
let
i
=
0
;
i
<
bones
.
length
;
++
i
)
{
...
...
@@ -372,7 +372,7 @@
function
getBoneByName
(
name
,
skeleton
)
{
for
(
let
i
=
0
,
bones
=
this
.
getBones
(
skeleton
);
i
<
bones
.
length
;
i
++
)
{
for
(
let
i
=
0
,
bones
=
getBones
(
skeleton
);
i
<
bones
.
length
;
i
++
)
{
if
(
name
===
bones
[
i
].
name
)
return
bones
[
i
];
...
...
@@ -423,8 +423,8 @@
function
getEqualsBonesNames
(
skeleton
,
targetSkeleton
)
{
const
sourceBones
=
this
.
getBones
(
skeleton
),
targetBones
=
this
.
getBones
(
targetSkeleton
),
const
sourceBones
=
getBones
(
skeleton
),
targetBones
=
getBones
(
targetSkeleton
),
bones
=
[];
search
:
for
(
let
i
=
0
;
i
<
sourceBones
.
length
;
i
++
)
{
...
...
examples/js/utils/WorkerPool.js
0 → 100644
浏览文件 @
d905a219
(
function
()
{
/**
* @author Deepkolos / https://github.com/deepkolos
*/
class
WorkerPool
{
constructor
(
pool
=
4
)
{
this
.
pool
=
pool
;
this
.
queue
=
[];
this
.
workers
=
[];
this
.
workersResolve
=
[];
this
.
workerStatus
=
0
;
}
_initWorker
(
workerId
)
{
if
(
!
this
.
workers
[
workerId
]
)
{
const
worker
=
this
.
workerCreator
();
worker
.
addEventListener
(
'
message
'
,
this
.
_onMessage
.
bind
(
this
,
workerId
)
);
this
.
workers
[
workerId
]
=
worker
;
}
}
_getIdleWorker
()
{
for
(
let
i
=
0
;
i
<
this
.
pool
;
i
++
)
if
(
!
(
this
.
workerStatus
&
1
<<
i
)
)
return
i
;
return
-
1
;
}
_onMessage
(
workerId
,
msg
)
{
const
resolve
=
this
.
workersResolve
[
workerId
];
resolve
&&
resolve
(
msg
);
if
(
this
.
queue
.
length
)
{
const
{
resolve
,
msg
,
transfer
}
=
this
.
queue
.
shift
();
this
.
workersResolve
[
workerId
]
=
resolve
;
this
.
workers
[
workerId
].
postMessage
(
msg
,
transfer
);
}
else
{
this
.
workerStatus
^=
1
<<
workerId
;
}
}
setWorkerCreator
(
workerCreator
)
{
this
.
workerCreator
=
workerCreator
;
}
setWorkerLimit
(
pool
)
{
this
.
pool
=
pool
;
}
postMessage
(
msg
,
transfer
)
{
return
new
Promise
(
resolve
=>
{
const
workerId
=
this
.
_getIdleWorker
();
if
(
workerId
!==
-
1
)
{
this
.
_initWorker
(
workerId
);
this
.
workerStatus
|=
1
<<
workerId
;
this
.
workersResolve
[
workerId
]
=
resolve
;
this
.
workers
[
workerId
].
postMessage
(
msg
,
transfer
);
}
else
{
this
.
queue
.
push
(
{
resolve
,
msg
,
transfer
}
);
}
}
);
}
dispose
()
{
this
.
workers
.
forEach
(
worker
=>
worker
.
terminate
()
);
this
.
workersResolve
.
length
=
0
;
this
.
workers
.
length
=
0
;
this
.
queue
.
length
=
0
;
this
.
workerStatus
=
0
;
}
}
THREE
.
WorkerPool
=
WorkerPool
;
}
)();
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录