Last active
November 15, 2022 03:43
-
-
Save yadav-arun/5455959525ce186b2135ae08b668c32e to your computer and use it in GitHub Desktop.
Conversion of Cesium's 3D tiles' geolocation transform to Readable data!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cesium = require("cesium") | |
var tileset1 = { | |
"asset": { | |
"version": "1.0", | |
"extras": { | |
"ion": { | |
"georeferenced": true, | |
"movable": true, | |
"terrainId": 1 | |
} | |
} | |
}, | |
"geometricError": 9266.661987012843, | |
"root": { | |
"children": [ | |
{ | |
"boundingVolume": { | |
"box": [ | |
-53041.489788538776, | |
41981.809324547416, | |
841.7423570559286, | |
2538.5896952077746, | |
0, | |
0, | |
0, | |
3705.2761340748984, | |
0, | |
0, | |
0, | |
1137.6498692599025 | |
] | |
}, | |
"geometricError": 49.75228617113487, | |
"content": { | |
"uri": "0/0.b3dm" | |
}, | |
"children": [ | |
{ | |
"boundingVolume": { | |
"box": [ | |
-53041.489788538776, | |
43395.207901428636, | |
841.7423570559286, | |
2538.5896952077746, | |
0, | |
0, | |
0, | |
2291.8775571936785, | |
0, | |
0, | |
0, | |
1137.6498692599025 | |
] | |
}, | |
"geometricError": 49.75228617113487, | |
"content": { | |
"uri": "1/00.b3dm" | |
}, | |
"children": [ | |
{ | |
"boundingVolume": { | |
"box": [ | |
-54311.161078317535, | |
43395.207901428636, | |
841.7423570559286, | |
1268.9184054290163, | |
0, | |
0, | |
0, | |
2291.8775571936785, | |
0, | |
0, | |
0, | |
1137.6498692599025 | |
] | |
}, | |
"geometricError": 0, | |
"content": { | |
"uri": "2/000.b3dm" | |
} | |
}, | |
{ | |
"boundingVolume": { | |
"box": [ | |
-51772.57138310976, | |
43395.207901428636, | |
841.7423570559286, | |
1269.6712897787584, | |
0, | |
0, | |
0, | |
2291.8775571936785, | |
0, | |
0, | |
0, | |
1137.6498692599025 | |
] | |
}, | |
"geometricError": 0, | |
"content": { | |
"uri": "2/001.b3dm" | |
} | |
} | |
] | |
}, | |
{ | |
"boundingVolume": { | |
"box": [ | |
-53041.489788538776, | |
39689.93176735374, | |
841.7423570559286, | |
2538.5896952077746, | |
0, | |
0, | |
0, | |
1413.39857688122, | |
0, | |
0, | |
0, | |
1137.6498692599025 | |
] | |
}, | |
"geometricError": 0, | |
"content": { | |
"uri": "1/01.b3dm" | |
} | |
} | |
], | |
"transform": [ | |
1, | |
0, | |
0, | |
0, | |
0, | |
1, | |
0, | |
0, | |
0, | |
0, | |
1, | |
0, | |
53041.489788538776, | |
-41981.809324547416, | |
295.90751220397397, | |
1 | |
] | |
} | |
], | |
"refine": "REPLACE", | |
"boundingVolume": { | |
"box": [ | |
0, | |
0, | |
1137.6498692599025, | |
2538.5896952077746, | |
0, | |
0, | |
0, | |
3705.2761340748984, | |
0, | |
0, | |
0, | |
1137.6498692599025 | |
] | |
}, | |
"geometricError": 9266.661987012843, | |
"transform": [ | |
-0.008993544815786991, | |
-0.00032500738052799034, | |
0.004360105715351338, | |
0, | |
0.0039705626290462695, | |
-0.004782249422879397, | |
0.007833563867499687, | |
0, | |
0.0018305146968156797, | |
0.008776358052175071, | |
0.004429983666422475, | |
0, | |
1168320.9177234021, | |
5601486.134814035, | |
2808496.9071573685, | |
1 | |
] | |
} | |
} | |
computeTransforms(tileset1); | |
function computeTransforms(tileset) { | |
var t = tileset.root; | |
var transformToRoot = cesium.defined(t.transform) ? cesium.Matrix4.fromArray(t.transform) : cesium.Matrix4.IDENTITY; | |
var abc = new cesium.Cartesian3(); | |
cesium.Matrix4.getTranslation(transformToRoot, abc) | |
var cartographic = cesium.Cartographic.fromCartesian(abc); | |
console.log( | |
'lon ' + cesium.Math.toDegrees(cartographic.longitude) + ', ' + | |
'lat ' + cesium.Math.toDegrees(cartographic.latitude) + ', ' + | |
'alt ' + cartographic.height); | |
var resp = cesium.Transforms.fixedFrameToHeadingPitchRoll(transformToRoot, cesium.Ellipsoid.WGS84, cesium.Transforms.eastNorthUpToFixedFrame); | |
console.log("HEADING PITCH ROLL below : ") | |
console.log(cesium.Math.toDegrees(resp.heading)); | |
console.log(cesium.Math.toDegrees(resp.pitch)); | |
console.log(cesium.Math.toDegrees(resp.roll)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment