Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
899179ea
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,发现更多精彩内容 >>
提交
899179ea
编写于
12月 13, 2016
作者:
S
sunag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
embed offset in object3d, fix destroy, fix initial position
上级
6d9478df
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
22 deletion
+75
-22
examples/js/loaders/sea3d/physics/SEA3DAmmo.js
examples/js/loaders/sea3d/physics/SEA3DAmmo.js
+20
-16
examples/js/loaders/sea3d/physics/SEA3DAmmoLoader.js
examples/js/loaders/sea3d/physics/SEA3DAmmoLoader.js
+36
-3
examples/js/loaders/sea3d/physics/SEA3DRigidBody.js
examples/js/loaders/sea3d/physics/SEA3DRigidBody.js
+19
-3
未找到文件。
examples/js/loaders/sea3d/physics/SEA3DAmmo.js
浏览文件 @
899179ea
...
...
@@ -11,12 +11,15 @@
'
use strict
'
;
SEA3D
.
AMMO
=
{
world
:
null
,
rigidBodies
:
[],
rigidBodiesTarget
:
[],
rigidBodiesOffset
:
[],
rigidBodiesEnabled
:
[],
constraints
:
[],
vehicles
:
[],
vehiclesWheels
:
[],
...
...
@@ -89,26 +92,29 @@ SEA3D.AMMO = {
setEnabledRigidBody
:
function
(
rb
,
enabled
)
{
if
(
this
.
getEnabledRigidBody
(
rb
)
==
enabled
)
return
;
var
index
=
this
.
rigidBodies
.
indexOf
(
rb
);
if
(
this
.
rigidBodiesEnabled
[
index
]
==
enabled
)
return
;
if
(
enabled
)
this
.
world
.
addRigidBody
(
rb
);
else
this
.
world
.
removeRigidBody
(
rb
);
this
.
rigidBodiesEnabled
[
index
]
=
true
;
return
this
;
},
getEnabledRigidBody
:
function
(
rb
)
{
return
this
.
rigidBodiesEnabled
[
this
.
rigidBodies
.
indexOf
(
rb
)
]
===
true
;
return
this
.
rigidBodiesEnabled
[
this
.
rigidBodies
.
indexOf
(
rb
)
];
},
addRigidBody
:
function
(
rb
,
target
,
offset
,
enabled
)
{
addRigidBody
:
function
(
rb
,
target
,
enabled
)
{
enabled
=
enabled
!==
undefined
?
enabled
:
true
;
this
.
rigidBodies
.
push
(
rb
);
this
.
rigidBodiesTarget
.
push
(
target
);
this
.
rigidBodiesOffset
.
push
(
offset
);
this
.
rigidBodiesEnabled
.
push
(
false
);
this
.
setEnabledRigidBody
(
rb
,
enabled
);
...
...
@@ -124,7 +130,6 @@ SEA3D.AMMO = {
this
.
rigidBodies
.
splice
(
index
,
1
);
this
.
rigidBodiesTarget
.
splice
(
index
,
1
);
this
.
rigidBodiesOffset
.
splice
(
index
,
1
);
this
.
rigidBodiesEnabled
.
splice
(
index
,
1
);
if
(
destroy
)
Ammo
.
destroy
(
rb
);
...
...
@@ -332,12 +337,7 @@ SEA3D.AMMO = {
var
pos
=
transform
.
getOrigin
(),
quat
=
transform
.
getRotation
();
if
(
offset
==
undefined
)
{
obj3d
.
position
.
set
(
pos
.
x
(),
pos
.
y
(),
pos
.
z
()
);
obj3d
.
quaternion
.
set
(
quat
.
x
(),
quat
.
y
(),
quat
.
z
(),
quat
.
w
()
);
}
else
{
if
(
offset
)
{
position
.
set
(
pos
.
x
(),
pos
.
y
(),
pos
.
z
()
);
quaternion
.
set
(
quat
.
x
(),
quat
.
y
(),
quat
.
z
(),
quat
.
w
()
);
...
...
@@ -349,6 +349,11 @@ SEA3D.AMMO = {
obj3d
.
position
.
setFromMatrixPosition
(
matrix
);
obj3d
.
quaternion
.
setFromRotationMatrix
(
matrix
);
}
else
{
obj3d
.
position
.
set
(
pos
.
x
(),
pos
.
y
(),
pos
.
z
()
);
obj3d
.
quaternion
.
set
(
quat
.
x
(),
quat
.
y
(),
quat
.
z
(),
quat
.
w
()
);
}
return
this
;
...
...
@@ -377,7 +382,7 @@ SEA3D.AMMO = {
if
(
wheelTarget
)
{
this
.
updateTargetTransform
(
wheelTarget
,
wheelsTransform
);
this
.
updateTargetTransform
(
wheelTarget
,
wheelsTransform
,
wheelTarget
.
physics
?
wheelTarget
.
physics
.
offset
:
null
);
}
...
...
@@ -388,12 +393,11 @@ SEA3D.AMMO = {
for
(
i
=
0
;
i
<
this
.
rigidBodies
.
length
;
i
++
)
{
var
rb
=
this
.
rigidBodies
[
i
],
target
=
this
.
rigidBodiesTarget
[
i
],
offset
=
this
.
rigidBodiesOffset
[
i
];
target
=
this
.
rigidBodiesTarget
[
i
];
if
(
target
&&
rb
.
isActive
()
)
{
this
.
updateTargetTransform
(
target
,
rb
.
getWorldTransform
(),
offset
);
this
.
updateTargetTransform
(
target
,
rb
.
getWorldTransform
(),
target
.
physics
?
target
.
physics
.
offset
:
null
);
}
...
...
examples/js/loaders/sea3d/physics/SEA3DAmmoLoader.js
浏览文件 @
899179ea
...
...
@@ -146,10 +146,15 @@ THREE.SEA3D.prototype.readCompound = function ( sea ) {
THREE
.
SEA3D
.
prototype
.
readRigidBodyBase
=
function
(
sea
)
{
var
shape
=
sea
.
shape
.
tag
,
transform
;
transform
,
target
;
if
(
sea
.
target
)
{
target
=
sea
.
target
.
tag
;
target
.
physics
=
{
enabled
:
true
};
target
.
updateMatrix
();
transform
=
SEA3D
.
AMMO
.
getTransformFromMatrix
(
sea
.
target
.
tag
.
matrix
);
}
else
{
...
...
@@ -173,6 +178,23 @@ THREE.SEA3D.prototype.readRigidBodyBase = function ( sea ) {
var
rb
=
new
Ammo
.
btRigidBody
(
info
);
if
(
target
)
{
target
.
physics
.
rigidBody
=
rb
;
if
(
sea
.
offset
)
{
var
offset
=
new
THREE
.
Matrix4
();
offset
.
elements
.
set
(
sea
.
offset
);
target
.
physics
.
offset
=
offset
;
}
}
Ammo
.
destroy
(
info
);
this
.
domain
.
rigidBodies
=
this
.
rigidBodies
=
this
.
rigidBodies
||
[];
this
.
rigidBodies
.
push
(
this
.
objects
[
"
rb/
"
+
sea
.
name
]
=
sea
.
tag
=
rb
);
...
...
@@ -188,7 +210,7 @@ THREE.SEA3D.prototype.readRigidBody = function ( sea ) {
var
rb
=
this
.
readRigidBodyBase
(
sea
);
SEA3D
.
AMMO
.
addRigidBody
(
rb
,
sea
.
target
?
sea
.
target
.
tag
:
undefined
,
sea
.
offset
?
new
THREE
.
Matrix4
().
elements
.
set
(
sea
.
offset
)
:
undefined
,
this
.
config
.
enabledPhysics
);
SEA3D
.
AMMO
.
addRigidBody
(
rb
,
sea
.
target
?
sea
.
target
.
tag
:
undefined
,
this
.
config
.
enabledPhysics
);
};
...
...
@@ -238,6 +260,17 @@ THREE.SEA3D.prototype.readCarController = function ( sea ) {
if
(
target
)
{
target
.
physics
=
{
enabled
:
true
,
rigidBody
:
wheelInfo
};
if
(
wheel
.
offset
)
{
var
offset
=
new
THREE
.
Matrix4
();
offset
.
elements
.
set
(
wheel
.
offset
);
target
.
physics
.
offset
=
offset
;
}
if
(
target
.
parent
)
{
target
.
parent
.
remove
(
target
);
...
...
@@ -260,7 +293,7 @@ THREE.SEA3D.prototype.readCarController = function ( sea ) {
}
SEA3D
.
AMMO
.
addVehicle
(
vehicle
,
wheels
);
SEA3D
.
AMMO
.
addRigidBody
(
body
,
sea
.
target
?
sea
.
target
.
tag
:
undefined
,
sea
.
offset
?
new
THREE
.
Matrix4
().
elements
.
set
(
sea
.
offset
)
:
undefined
,
this
.
config
.
enabledPhysics
);
SEA3D
.
AMMO
.
addRigidBody
(
body
,
sea
.
target
?
sea
.
target
.
tag
:
undefined
,
this
.
config
.
enabledPhysics
);
this
.
domain
.
vehicles
=
this
.
vehicles
=
this
.
vehicles
||
[];
this
.
vehicles
.
push
(
this
.
objects
[
"
vhc/
"
+
sea
.
name
]
=
sea
.
tag
=
vehicle
);
...
...
examples/js/loaders/sea3d/physics/SEA3DRigidBody.js
浏览文件 @
899179ea
...
...
@@ -168,6 +168,12 @@ SEA3D.Physics = function ( name, data, sea3d ) {
if
(
this
.
attrib
&
1
)
this
.
target
=
sea3d
.
getObject
(
data
.
readUInt
()
);
else
this
.
transform
=
data
.
readMatrix
();
if
(
this
.
attrib
&
2
)
this
.
offset
=
data
.
readMatrix
();
if
(
this
.
attrib
&
4
)
this
.
scripts
=
data
.
readScriptList
(
sea3d
);
if
(
this
.
attrib
&
16
)
this
.
attributes
=
sea3d
.
getObject
(
data
.
readUInt
()
);
};
SEA3D
.
Physics
.
prototype
.
readTag
=
function
(
kind
,
data
,
size
)
{
...
...
@@ -257,11 +263,21 @@ SEA3D.CarController.Wheel = function ( data, sea3d ) {
this
.
data
=
data
;
this
.
sea3d
=
sea3d
;
var
attrib
=
data
.
readUShort
();
this
.
attrib
=
data
.
readUShort
();
this
.
isFront
=
(
this
.
attrib
&
1
)
!=
0
;
if
(
this
.
attrib
&
2
)
{
this
.
isFront
=
(
attrib
&
1
)
!=
0
,
this
.
target
=
sea3d
.
getObject
(
data
.
readUInt
()
);
this
.
target
=
sea3d
.
getObject
(
data
.
readUInt
()
);
}
if
(
this
.
attrib
&
4
)
{
this
.
offset
=
data
.
readMatrix
();
}
this
.
pos
=
data
.
readVector3
();
this
.
dir
=
data
.
readVector3
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录