Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
607cb747
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,发现更多精彩内容 >>
未验证
提交
607cb747
编写于
6月 11, 2019
作者:
M
Michael Herzog
提交者:
GitHub
6月 11, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16760 from Mugen87/dev33
JSM: Added module and TS files for MMD helper classes.
上级
778e227e
601470c2
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
2715 addition
and
35 deletion
+2715
-35
docs/manual/en/introduction/Import-via-modules.html
docs/manual/en/introduction/Import-via-modules.html
+2
-0
examples/js/animation/MMDAnimationHelper.js
examples/js/animation/MMDAnimationHelper.js
+5
-5
examples/js/animation/MMDPhysics.js
examples/js/animation/MMDPhysics.js
+32
-30
examples/jsm/animation/MMDAnimationHelper.d.ts
examples/jsm/animation/MMDAnimationHelper.d.ts
+85
-0
examples/jsm/animation/MMDAnimationHelper.js
examples/jsm/animation/MMDAnimationHelper.js
+1052
-0
examples/jsm/animation/MMDPhysics.d.ts
examples/jsm/animation/MMDPhysics.d.ts
+109
-0
examples/jsm/animation/MMDPhysics.js
examples/jsm/animation/MMDPhysics.js
+1428
-0
utils/modularize.js
utils/modularize.js
+2
-0
未找到文件。
docs/manual/en/introduction/Import-via-modules.html
浏览文件 @
607cb747
...
...
@@ -80,6 +80,8 @@
<ul>
<li>
AnimationClipCreator
</li>
<li>
CCDIKSolver
</li>
<li>
MMDAnimationHelper
</li>
<li>
MMDPhysics
</li>
<li>
TimelinerController
</li>
</ul>
</li>
...
...
examples/js/animation/MMDAnimationHelper.js
浏览文件 @
607cb747
...
...
@@ -19,7 +19,7 @@ THREE.MMDAnimationHelper = ( function () {
* @param {Object} params - (optional)
* @param {boolean} params.sync - Whether animation durations of added objects are synched. Default is true.
* @param {Number} params.afterglow - Default is 0.0.
* @param {boolean} params
resetPhysicsOnLoop - Default is true.
* @param {boolean} params
.
resetPhysicsOnLoop - Default is true.
*/
function
MMDAnimationHelper
(
params
)
{
...
...
@@ -53,7 +53,7 @@ THREE.MMDAnimationHelper = ( function () {
cameraAnimation
:
true
};
this
.
onBeforePhysics
=
function
(
mesh
)
{};
this
.
onBeforePhysics
=
function
(
/* mesh */
)
{};
// experimental
this
.
sharedPhysics
=
false
;
...
...
@@ -239,7 +239,7 @@ THREE.MMDAnimationHelper = ( function () {
* Enabes/Disables an animation feature.
*
* @param {string} key
* @param {boolean} en
e
bled
* @param {boolean} en
a
bled
* @return {THREE.MMDAnimationHelper}
*/
enable
:
function
(
key
,
enabled
)
{
...
...
@@ -488,7 +488,7 @@ THREE.MMDAnimationHelper = ( function () {
var
masterPhysics
=
this
.
_getMasterPhysics
();
if
(
masterPhysics
!==
null
)
world
=
masterPhysics
.
world
;
if
(
masterPhysics
!==
null
)
world
=
masterPhysics
.
world
;
// eslint-disable-line no-undef
}
...
...
@@ -945,7 +945,7 @@ THREE.MMDAnimationHelper = ( function () {
}
if
(
this
.
currentTime
<
this
.
delayTime
)
return
false
;
// 'duration' can be bigger than 'audioDuration + delayTime' because of sync configuration
if
(
(
this
.
currentTime
-
this
.
delayTime
)
>
this
.
audioDuration
)
return
false
;
...
...
examples/js/animation/MMDPhysics.js
浏览文件 @
607cb747
...
...
@@ -11,6 +11,8 @@
* - Physics in Worker
*/
/* global Ammo */
THREE
.
MMDPhysics
=
(
function
()
{
/**
...
...
@@ -137,7 +139,7 @@ THREE.MMDPhysics = ( function () {
*/
reset
:
function
()
{
for
(
var
i
=
0
,
il
=
this
.
bodies
.
length
;
i
<
il
;
i
++
)
{
for
(
var
i
=
0
,
il
=
this
.
bodies
.
length
;
i
<
il
;
i
++
)
{
this
.
bodies
[
i
].
reset
();
...
...
@@ -155,7 +157,7 @@ THREE.MMDPhysics = ( function () {
*/
warmup
:
function
(
cycles
)
{
for
(
var
i
=
0
;
i
<
cycles
;
i
++
)
{
for
(
var
i
=
0
;
i
<
cycles
;
i
++
)
{
this
.
update
(
1
/
60
);
...
...
@@ -258,7 +260,7 @@ THREE.MMDPhysics = ( function () {
_initRigidBodies
:
function
(
rigidBodies
)
{
for
(
var
i
=
0
,
il
=
rigidBodies
.
length
;
i
<
il
;
i
++
)
{
for
(
var
i
=
0
,
il
=
rigidBodies
.
length
;
i
<
il
;
i
++
)
{
this
.
bodies
.
push
(
new
RigidBody
(
this
.
mesh
,
this
.
world
,
rigidBodies
[
i
],
this
.
manager
)
);
...
...
@@ -269,7 +271,7 @@ THREE.MMDPhysics = ( function () {
_initConstraints
:
function
(
constraints
)
{
for
(
var
i
=
0
,
il
=
constraints
.
length
;
i
<
il
;
i
++
)
{
for
(
var
i
=
0
,
il
=
constraints
.
length
;
i
<
il
;
i
++
)
{
var
params
=
constraints
[
i
];
var
bodyA
=
this
.
bodies
[
params
.
rigidBodyIndex1
];
...
...
@@ -307,7 +309,7 @@ THREE.MMDPhysics = ( function () {
_updateRigidBodies
:
function
()
{
for
(
var
i
=
0
,
il
=
this
.
bodies
.
length
;
i
<
il
;
i
++
)
{
for
(
var
i
=
0
,
il
=
this
.
bodies
.
length
;
i
<
il
;
i
++
)
{
this
.
bodies
[
i
].
updateFromBone
();
...
...
@@ -317,7 +319,7 @@ THREE.MMDPhysics = ( function () {
_updateBones
:
function
()
{
for
(
var
i
=
0
,
il
=
this
.
bodies
.
length
;
i
<
il
;
i
++
)
{
for
(
var
i
=
0
,
il
=
this
.
bodies
.
length
;
i
<
il
;
i
++
)
{
this
.
bodies
[
i
].
updateBone
();
...
...
@@ -476,32 +478,32 @@ THREE.MMDPhysics = ( function () {
},
getOrigin
:
function
(
t
)
{
getOrigin
:
function
(
t
)
{
return
t
.
getOrigin
();
},
setOrigin
:
function
(
t
,
v
)
{
setOrigin
:
function
(
t
,
v
)
{
t
.
getOrigin
().
setValue
(
v
.
x
(),
v
.
y
(),
v
.
z
()
);
},
copyOrigin
:
function
(
t1
,
t2
)
{
copyOrigin
:
function
(
t1
,
t2
)
{
var
o
=
t2
.
getOrigin
();
this
.
setOrigin
(
t1
,
o
);
},
setBasis
:
function
(
t
,
q
)
{
setBasis
:
function
(
t
,
q
)
{
t
.
setRotation
(
q
);
},
setBasisFromMatrix3
:
function
(
t
,
m
)
{
setBasisFromMatrix3
:
function
(
t
,
m
)
{
var
q
=
this
.
matrix3ToQuaternion
(
m
);
this
.
setBasis
(
t
,
q
);
...
...
@@ -626,7 +628,7 @@ THREE.MMDPhysics = ( function () {
},
addVector3
:
function
(
v1
,
v2
)
{
addVector3
:
function
(
v1
,
v2
)
{
var
v
=
this
.
allocVector3
();
v
.
setValue
(
v1
.
x
()
+
v2
.
x
(),
v1
.
y
()
+
v2
.
y
(),
v1
.
z
()
+
v2
.
z
()
);
...
...
@@ -634,13 +636,13 @@ THREE.MMDPhysics = ( function () {
},
dotVectors3
:
function
(
v1
,
v2
)
{
dotVectors3
:
function
(
v1
,
v2
)
{
return
v1
.
x
()
*
v2
.
x
()
+
v1
.
y
()
*
v2
.
y
()
+
v1
.
z
()
*
v2
.
z
();
},
rowOfMatrix3
:
function
(
m
,
i
)
{
rowOfMatrix3
:
function
(
m
,
i
)
{
var
v
=
this
.
allocVector3
();
v
.
setValue
(
m
[
i
*
3
+
0
],
m
[
i
*
3
+
1
],
m
[
i
*
3
+
2
]
);
...
...
@@ -648,7 +650,7 @@ THREE.MMDPhysics = ( function () {
},
columnOfMatrix3
:
function
(
m
,
i
)
{
columnOfMatrix3
:
function
(
m
,
i
)
{
var
v
=
this
.
allocVector3
();
v
.
setValue
(
m
[
i
+
0
],
m
[
i
+
3
],
m
[
i
+
6
]
);
...
...
@@ -656,10 +658,10 @@ THREE.MMDPhysics = ( function () {
},
negativeVector3
:
function
(
v
)
{
negativeVector3
:
function
(
v
)
{
var
v2
=
this
.
allocVector3
();
v2
.
setValue
(
-
v
.
x
(),
-
v
.
y
(),
-
v
.
z
()
);
v2
.
setValue
(
-
v
.
x
(),
-
v
.
y
(),
-
v
.
z
()
);
return
v2
;
},
...
...
@@ -685,7 +687,7 @@ THREE.MMDPhysics = ( function () {
},
transposeMatrix3
:
function
(
m
)
{
transposeMatrix3
:
function
(
m
)
{
var
m2
=
[];
m2
[
0
]
=
m
[
0
];
...
...
@@ -736,12 +738,12 @@ THREE.MMDPhysics = ( function () {
},
matrix3ToQuaternion
:
function
(
m
)
{
matrix3ToQuaternion
:
function
(
m
)
{
var
t
=
m
[
0
]
+
m
[
4
]
+
m
[
8
];
var
s
,
x
,
y
,
z
,
w
;
if
(
t
>
0
)
{
if
(
t
>
0
)
{
s
=
Math
.
sqrt
(
t
+
1.0
)
*
2
;
w
=
0.25
*
s
;
...
...
@@ -749,7 +751,7 @@ THREE.MMDPhysics = ( function () {
y
=
(
m
[
2
]
-
m
[
6
]
)
/
s
;
z
=
(
m
[
3
]
-
m
[
1
]
)
/
s
;
}
else
if
(
(
m
[
0
]
>
m
[
4
]
)
&&
(
m
[
0
]
>
m
[
8
]
)
)
{
}
else
if
(
(
m
[
0
]
>
m
[
4
]
)
&&
(
m
[
0
]
>
m
[
8
]
)
)
{
s
=
Math
.
sqrt
(
1.0
+
m
[
0
]
-
m
[
4
]
-
m
[
8
]
)
*
2
;
w
=
(
m
[
7
]
-
m
[
5
]
)
/
s
;
...
...
@@ -757,7 +759,7 @@ THREE.MMDPhysics = ( function () {
y
=
(
m
[
1
]
+
m
[
3
]
)
/
s
;
z
=
(
m
[
2
]
+
m
[
6
]
)
/
s
;
}
else
if
(
m
[
4
]
>
m
[
8
]
)
{
}
else
if
(
m
[
4
]
>
m
[
8
]
)
{
s
=
Math
.
sqrt
(
1.0
+
m
[
4
]
-
m
[
0
]
-
m
[
8
]
)
*
2
;
w
=
(
m
[
2
]
-
m
[
6
]
)
/
s
;
...
...
@@ -794,7 +796,7 @@ THREE.MMDPhysics = ( function () {
*/
function
RigidBody
(
mesh
,
world
,
params
,
manager
)
{
this
.
mesh
=
mesh
;
this
.
mesh
=
mesh
;
this
.
world
=
world
;
this
.
params
=
params
;
this
.
manager
=
manager
;
...
...
@@ -882,7 +884,7 @@ THREE.MMDPhysics = ( function () {
function
generateShape
(
p
)
{
switch
(
p
.
shapeType
)
{
switch
(
p
.
shapeType
)
{
case
0
:
return
new
Ammo
.
btSphereShape
(
p
.
width
);
...
...
@@ -912,7 +914,7 @@ THREE.MMDPhysics = ( function () {
var
localInertia
=
manager
.
allocVector3
();
localInertia
.
setValue
(
0
,
0
,
0
);
if
(
weight
!==
0
)
{
if
(
weight
!==
0
)
{
shape
.
calculateLocalInertia
(
weight
,
localInertia
);
...
...
@@ -1103,7 +1105,7 @@ THREE.MMDPhysics = ( function () {
*/
function
Constraint
(
mesh
,
world
,
bodyA
,
bodyB
,
params
,
manager
)
{
this
.
mesh
=
mesh
;
this
.
mesh
=
mesh
;
this
.
world
=
world
;
this
.
bodyA
=
bodyA
;
this
.
bodyB
=
bodyB
;
...
...
@@ -1171,9 +1173,9 @@ THREE.MMDPhysics = ( function () {
constraint
.
setAngularLowerLimit
(
all
);
constraint
.
setAngularUpperLimit
(
aul
);
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
if
(
params
.
springPosition
[
i
]
!==
0
)
{
if
(
params
.
springPosition
[
i
]
!==
0
)
{
constraint
.
enableSpring
(
i
,
true
);
constraint
.
setStiffness
(
i
,
params
.
springPosition
[
i
]
);
...
...
@@ -1182,9 +1184,9 @@ THREE.MMDPhysics = ( function () {
}
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
if
(
params
.
springRotation
[
i
]
!==
0
)
{
if
(
params
.
springRotation
[
i
]
!==
0
)
{
constraint
.
enableSpring
(
i
+
3
,
true
);
constraint
.
setStiffness
(
i
+
3
,
params
.
springRotation
[
i
]
);
...
...
examples/jsm/animation/MMDAnimationHelper.d.ts
0 → 100644
浏览文件 @
607cb747
import
{
AnimationClip
,
Audio
,
Camera
,
Mesh
,
Object3D
,
SkinnedMesh
}
from
'
../../../src/Three
'
;
export
interface
MMDAnimationHelperParameter
{
sync
?:
boolean
;
afterglow
?:
number
;
resetPhysicsOnLoop
?:
boolean
;
}
export
interface
MMDAnimationHelperAddParameter
{
animation
?:
AnimationClip
|
AnimationClip
[];
physics
?:
boolean
;
warmup
?:
number
;
unitStep
?:
number
;
maxStepNum
?:
number
;
gravity
?:
number
;
delayTime
?:
number
;
}
export
interface
MMDAnimationHelperPoseParameter
{
resetPose
?:
boolean
;
ik
?:
boolean
;
grant
?:
boolean
;
}
export
class
MMDAnimationHelper
{
constructor
(
params
?:
MMDAnimationHelperParameter
);
meshes
:
Mesh
[];
camera
:
Camera
|
null
;
cameraTarget
:
Object3D
;
audio
:
Audio
;
audioManager
:
AudioManager
;
configuration
:
{
sync
:
boolean
;
afterglow
:
number
;
resetPhysicsOnLoop
:
boolean
;
};
enabled
:
{
animation
:
boolean
;
ik
:
boolean
;
grant
:
boolean
;
physics
:
boolean
;
cameraAnimation
:
boolean
;
};
onBeforePhysics
:
(
mesh
:
SkinnedMesh
)
=>
void
;
sharedPhysics
:
boolean
;
masterPhysics
:
null
;
add
(
object
:
SkinnedMesh
|
Camera
|
Audio
,
params
?:
MMDAnimationHelperAddParameter
):
this
;
remove
(
object
:
SkinnedMesh
|
Camera
|
Audio
):
this
;
update
(
delta
:
number
):
this
;
pose
(
mesh
:
SkinnedMesh
,
vpd
:
object
,
params
?:
MMDAnimationHelperPoseParameter
):
this
;
enable
(
key
:
string
,
enabled
:
boolean
):
this
;
createGrantSolver
(
mesh
:
SkinnedMesh
):
GrantSolver
;
}
export
interface
AudioManagerParameter
{
delayTime
?:
number
;
}
export
class
AudioManager
{
constructor
(
audio
:
Audio
,
params
?:
AudioManagerParameter
);
audio
:
Audio
;
elapsedTime
:
number
;
currentTime
:
number
;
delayTime
:
number
;
audioDuration
:
number
;
duration
:
number
;
control
(
delta
:
number
):
this
;
}
export
class
GrantSolver
{
constructor
(
mesh
:
SkinnedMesh
,
grants
:
object
[]);
mesh
:
SkinnedMesh
;
grants
:
object
[];
update
():
this
;
}
examples/jsm/animation/MMDAnimationHelper.js
0 → 100644
浏览文件 @
607cb747
此差异已折叠。
点击以展开。
examples/jsm/animation/MMDPhysics.d.ts
0 → 100644
浏览文件 @
607cb747
import
{
Bone
,
Euler
,
Matrix4
,
Object3D
,
Quaternion
,
SkinnedMesh
,
Vector3
}
from
'
../../../src/Three
'
;
export
interface
MMDPhysicsParameter
{
unitStep
?:
number
;
maxStepNum
?:
number
;
gravity
?:
Vector3
;
}
export
class
MMDPhysics
{
constructor
(
mesh
:
SkinnedMesh
,
rigidBodyParams
:
object
[],
constraintParams
?:
object
[],
params
?:
MMDPhysicsParameter
);
manager
:
ResourceManager
;
mesh
:
SkinnedMesh
;
unitStep
:
number
;
maxStepNum
:
number
;
gravity
:
Vector3
;
world
:
null
;
bodies
:
RigidBody
[];
constraints
:
Constraint
[];
update
(
delta
:
number
):
this
;
reset
():
this
;
warmup
(
cycles
:
number
):
this
;
setGravity
(
gravity
:
Vector3
):
this
;
createHelper
():
MMDPhysicsHelper
;
}
export
class
ResourceManager
{
constructor
();
threeVector3s
:
Vector3
[];
threeMatrix4s
:
Matrix4
[];
threeQuaternions
:
Quaternion
[];
threeEulers
:
Euler
[];
transforms
:
object
[];
quaternions
:
object
[];
vector3s
:
object
[];
allocThreeVector3
():
void
;
freeThreeVector3
(
v
:
Vector3
):
void
;
allocThreeMatrix4
():
void
;
freeThreeMatrix4
(
m
:
Matrix4
):
void
;
allocThreeQuaternion
():
void
;
freeThreeQuaternion
(
q
:
Quaternion
):
void
;
allocThreeEuler
():
void
;
freeThreeEuler
(
e
:
Euler
):
void
;
allocTransform
():
void
;
freeTransform
(
t
:
object
):
void
;
allocQuaternion
():
void
;
freeQuaternion
(
q
:
object
):
void
;
allocVector3
():
void
;
freeVector3
(
v
:
object
):
void
;
setIdentity
():
void
;
getBasis
(
t
:
object
):
object
;
getBasisAsMatrix3
(
t
:
object
):
object
;
getOrigin
(
t
:
object
):
object
;
setOrigin
(
t
:
object
,
v
:
object
):
void
;
copyOrigin
(
t1
:
object
,
t2
:
object
):
void
;
setBasis
(
t
:
object
,
q
:
object
):
void
;
setBasisFromMatrix3
(
t
:
object
,
m
:
object
):
void
;
setOriginFromArray3
(
t
:
object
,
a
:
number
[]):
void
;
setOriginFromThreeVector3
(
t
:
object
,
v
:
Vector3
):
void
;
setBasisFromArray3
(
t
:
object
,
a
:
number
[]):
void
;
setBasisFromThreeQuaternion
(
t
:
object
,
a
:
Quaternion
):
void
;
multiplyTransforms
(
t1
:
object
,
t2
:
object
):
object
;
inverseTransform
(
t
:
object
):
object
;
multiplyMatrices3
(
m1
:
object
,
m2
:
object
):
object
;
addVector3
(
v1
:
object
,
v2
:
object
):
object
;
dotVectors3
(
v1
:
object
,
v2
:
object
):
number
;
rowOfMatrix3
(
m
:
object
,
i
:
number
):
object
;
columnOfMatrix3
(
m
:
object
,
i
:
number
):
object
;
negativeVector3
(
v
:
object
):
object
;
multiplyMatrix3ByVector3
(
m
:
object
,
v
:
object
):
object
;
transposeMatrix3
(
m
:
object
):
object
;
quaternionToMatrix3
(
q
:
object
):
object
;
matrix3ToQuaternion
(
m
:
object
):
object
;
}
export
class
RigidBody
{
constructor
(
mesh
:
SkinnedMesh
,
world
:
object
,
params
:
object
,
manager
:
ResourceManager
);
mesh
:
SkinnedMesh
;
world
:
object
;
params
:
object
;
manager
:
ResourceManager
;
body
:
object
;
bone
:
Bone
;
boneOffsetForm
:
object
;
boneOffsetFormInverse
:
object
;
reset
():
this
;
updateFromBone
():
this
;
updateBone
():
this
;
}
export
class
Constraint
{
constructor
(
mesh
:
SkinnedMesh
,
world
:
object
,
bodyA
:
RigidBody
,
bodyB
:
RigidBody
,
params
:
object
,
manager
:
ResourceManager
);
}
export
class
MMDPhysicsHelper
extends
Object3D
{
constructor
();
}
examples/jsm/animation/MMDPhysics.js
0 → 100644
浏览文件 @
607cb747
此差异已折叠。
点击以展开。
utils/modularize.js
浏览文件 @
607cb747
...
...
@@ -12,6 +12,8 @@ var dstFolder = __dirname + '/../examples/jsm/';
var
files
=
[
{
path
:
'
animation/AnimationClipCreator.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
animation/CCDIKSolver.js
'
,
dependencies
:
[],
ignoreList
:
[
'
SkinnedMesh
'
]
},
{
path
:
'
animation/MMDAnimationHelper.js
'
,
dependencies
:
[
{
name
:
'
CCDIKSolver
'
,
path
:
'
animation/CCDIKSolver.js
'
},
{
name
:
'
MMDPhysics
'
,
path
:
'
animation/MMDPhysics.js
'
}
],
ignoreList
:
[
'
AnimationClip
'
,
'
Audio
'
,
'
Camera
'
,
'
SkinnedMesh
'
]
},
{
path
:
'
animation/MMDPhysics.js
'
,
dependencies
:
[],
ignoreList
:
[
'
SkinnedMesh
'
]
},
{
path
:
'
animation/TimelinerController.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
cameras/CinematicCamera.js
'
,
dependencies
:
[
{
name
:
'
BokehShader
'
,
path
:
'
shaders/BokehShader2.js
'
},
{
name
:
'
BokehDepthShader
'
,
path
:
'
shaders/BokehShader2.js
'
}
],
ignoreList
:
[]
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录