Skip to content

Commit

Permalink
fix camera transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsx-dev committed Mar 29, 2021
1 parent d6bccd2 commit 62da325
Show file tree
Hide file tree
Showing 4 changed files with 312 additions and 1 deletion.
Binary file added blender/lightCameraAnimations.bin
Binary file not shown.
Binary file added blender/lightCameraAnimations.blend
Binary file not shown.
311 changes: 311 additions & 0 deletions blender/lightCameraAnimations.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
{
"asset" : {
"copyright" : "mgsx",
"generator" : "Khronos glTF Blender I/O v1.2.75",
"version" : "2.0"
},
"extensionsUsed" : [
"KHR_lights_punctual"
],
"extensionsRequired" : [
"KHR_lights_punctual"
],
"extensions" : {
"KHR_lights_punctual" : {
"lights" : [
{
"color" : [
1,
1,
1
],
"intensity" : 1000,
"type" : "point",
"name" : "Light"
}
]
}
},
"scene" : 0,
"scenes" : [
{
"name" : "Scene",
"nodes" : [
0,
2,
4
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Cube"
},
{
"extensions" : {
"KHR_lights_punctual" : {
"light" : 0
}
},
"name" : "Light_Orientation",
"rotation" : [
-0.7071067690849304,
0,
0,
0.7071067690849304
]
},
{
"children" : [
1
],
"name" : "Light",
"rotation" : [
0.16907575726509094,
0.7558803558349609,
-0.27217137813568115,
0.570947527885437
],
"translation" : [
5.641557216644287,
1.2456636428833008,
-5.643415451049805
]
},
{
"camera" : 0,
"name" : "Camera_Orientation",
"rotation" : [
-0.7071067690849304,
0,
0,
0.7071067690849304
]
},
{
"children" : [
3
],
"name" : "Camera",
"rotation" : [
0.483536034822464,
0.33687159419059753,
-0.20870360732078552,
0.7804827094078064
],
"translation" : [
21.92418670654297,
14.912154197692871,
20.655296325683594
]
}
],
"cameras" : [
{
"name" : "Camera",
"perspective" : {
"yfov" : 0.39959652046304894,
"zfar" : 100,
"znear" : 0.10000000149011612
},
"type" : "perspective"
}
],
"animations" : [
{
"channels" : [
{
"sampler" : 0,
"target" : {
"node" : 2,
"path" : "translation"
}
},
{
"sampler" : 1,
"target" : {
"node" : 4,
"path" : "translation"
}
},
{
"sampler" : 2,
"target" : {
"node" : 4,
"path" : "rotation"
}
}
],
"name" : "Animation",
"samplers" : [
{
"input" : 4,
"interpolation" : "LINEAR",
"output" : 5
},
{
"input" : 4,
"interpolation" : "LINEAR",
"output" : 6
},
{
"input" : 4,
"interpolation" : "LINEAR",
"output" : 7
}
]
}
],
"materials" : [
{
"doubleSided" : true,
"emissiveFactor" : [
0,
0,
0
],
"name" : "Material",
"pbrMetallicRoughness" : {
"baseColorFactor" : [
0.800000011920929,
0.800000011920929,
0.800000011920929,
1
],
"metallicFactor" : 0,
"roughnessFactor" : 0.4000000059604645
}
}
],
"meshes" : [
{
"name" : "Cube",
"primitives" : [
{
"attributes" : {
"POSITION" : 0,
"NORMAL" : 1,
"TEXCOORD_0" : 2
},
"indices" : 3,
"material" : 0
}
]
}
],
"accessors" : [
{
"bufferView" : 0,
"componentType" : 5126,
"count" : 24,
"max" : [
6.7014641761779785,
0.3685208559036255,
6.7014641761779785
],
"min" : [
-6.7014641761779785,
-0.3685208559036255,
-6.7014641761779785
],
"type" : "VEC3"
},
{
"bufferView" : 1,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 2,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 3,
"componentType" : 5123,
"count" : 36,
"type" : "SCALAR"
},
{
"bufferView" : 4,
"componentType" : 5126,
"count" : 90,
"max" : [
3.75
],
"min" : [
0.041666666666666664
],
"type" : "SCALAR"
},
{
"bufferView" : 5,
"componentType" : 5126,
"count" : 90,
"type" : "VEC3"
},
{
"bufferView" : 6,
"componentType" : 5126,
"count" : 90,
"type" : "VEC3"
},
{
"bufferView" : 7,
"componentType" : 5126,
"count" : 90,
"type" : "VEC4"
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 0
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 288
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 576
},
{
"buffer" : 0,
"byteLength" : 72,
"byteOffset" : 768
},
{
"buffer" : 0,
"byteLength" : 360,
"byteOffset" : 840
},
{
"buffer" : 0,
"byteLength" : 1080,
"byteOffset" : 1200
},
{
"buffer" : 0,
"byteLength" : 1080,
"byteOffset" : 2280
},
{
"buffer" : 0,
"byteLength" : 1440,
"byteOffset" : 3360
}
],
"buffers" : [
{
"byteLength" : 4800,
"uri" : "lightCameraAnimations.bin"
}
]
}
2 changes: 1 addition & 1 deletion gltf/src/net/mgsx/gltf/scene3d/scene/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void syncCameras(){
for(Entry<Node, Camera> e : cameras){
Node node = e.key;
Camera camera = e.value;
transform.set(node.globalTransform).mul(modelInstance.transform);
transform.set(modelInstance.transform).mul(node.globalTransform);
camera.position.setZero().mul(transform);
camera.direction.set(0,0,-1).rot(transform);
camera.up.set(Vector3.Y).rot(transform);
Expand Down

0 comments on commit 62da325

Please sign in to comment.