Commit 37d0a9bd authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

erp5_officejs_drone_capture_flag: fix projection proportionality

See merge request nexedi/erp5!1959
parents 40aad952 3c4eeac8
......@@ -524,14 +524,11 @@ var MapManager = /** @class */ (function () {
_this.map_info.initial_position.longitude,
_this.map_info.initial_position.altitude
);
max = _this.map_info.width;
if (_this.map_info.depth > max) {
max = _this.map_info.depth;
}
if (_this.map_info.height > max) {
max = _this.map_info.height;
}
max = max < _this.map_info.depth ? _this.map_info.depth : max;
max = Math.max(
_this.map_info.depth,
_this.map_info.height,
_this.map_info.width
);
// Skybox
max_sky = (max * 15 < 20000) ? max * 15 : 20000; //skybox scene limit
skybox = BABYLON.MeshBuilder.CreateBox("skyBox", { size: max_sky }, scene);
......@@ -558,13 +555,13 @@ var MapManager = /** @class */ (function () {
largeGroundBottom.renderingGroupId = 1;
// Terrain
// Give map some margin from the flight limits
width = _this.map_info.width * 1.10;
depth = _this.map_info.depth * 1.10;
width = _this.map_info.width * 1.30;
depth = _this.map_info.depth * 1.30;
//height = _this.map_info.height;
terrain = scene.getMeshByName("terrain001");
terrain.isVisible = true;
terrain.position = BABYLON.Vector3.Zero();
terrain.scaling = new BABYLON.Vector3(depth / 50000, depth / 50000,
terrain.scaling = new BABYLON.Vector3(depth / 50000, _this.map_info.height / 50000,
width / 50000);
// Enemies
_this._enemy_list = [];
......@@ -697,12 +694,6 @@ var MapManager = /** @class */ (function () {
MapManager.prototype.latLonDistance = function (c1, c2) {
return this.mapUtils.latLonDistance(c1, c2);
};
MapManager.prototype.longitudToX = function (lon) {
return this.mapUtils.longitudToX(lon);
};
MapManager.prototype.latitudeToY = function (lat) {
return this.mapUtils.latitudeToY(lat);
};
MapManager.prototype.convertToLocalCoordinates =
function (latitude, longitude, altitude) {
return this.mapUtils.convertToLocalCoordinates(
......@@ -862,12 +853,14 @@ var GameManager = /** @class */ (function () {
GameManager.prototype._checkDroneOut = function (drone) {
if (drone.position) {
var map_limit = this._mapManager.getMapInfo().map_size / 2;
return (drone.position.z > this._mapManager.getMapInfo().height) ||
(drone.position.x < -map_limit) ||
(drone.position.x > map_limit) ||
(drone.position.y < -map_limit) ||
(drone.position.y > map_limit);
var map_info = this._mapManager.getMapInfo(),
width_limit = map_info.width / 2,
depth_limit = map_info.depth / 2;
return (drone.position.z > map_info.height) ||
(drone.position.x < -width_limit) ||
(drone.position.x > width_limit) ||
(drone.position.y < -depth_limit) ||
(drone.position.y > depth_limit);
}
};
......@@ -1159,7 +1152,12 @@ var GameManager = /** @class */ (function () {
GameManager.prototype._init = function () {
var _this = this, canvas, hemi_north, hemi_south, camera, cam_radius,
on3DmodelsReady, map_size = 900; //GAMEPARAMETERS.map.map_size
on3DmodelsReady, mapUtils = new MapUtils(GAMEPARAMETERS.map),
map_size = Math.max(
mapUtils.map_info.depth,
mapUtils.map_info.height,
mapUtils.map_info.width
);
canvas = this._canvas;
this._delayed_defer_list = [];
this._dispose();
......@@ -1196,9 +1194,11 @@ var GameManager = /** @class */ (function () {
this._scene
);
hemi_south.intensity = 0.75;
//HARDCODE camera to a hardcoded map_size
//skybox scene limit
cam_radius = (map_size * 1.10 < 6000) ? map_size * 1.10 : 6000;
cam_radius = Math.min(
1.10 * Math.sqrt(mapUtils.map_info.width * mapUtils.map_info.depth),
6000
);
camera = new BABYLON.ArcRotateCamera("camera", 0, 1.25, cam_radius,
BABYLON.Vector3.Zero(), this._scene);
camera.wheelPrecision = 10;
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1016.21978.22579.46609</string> </value>
<value> <string>1017.22735.36044.31948</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1714742387.62</float>
<float>1718719762.65</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1011.57448.22674.29627</string> </value>
<value> <string>1017.22488.12960.6280</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1697557365.44</float>
<float>1718708011.02</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -44,11 +44,6 @@
<td>//div[contains(text(), 'CONSOLE LOG ENTRIES:')]</td>
<td></td>
<tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(text(), 'Simulation finished')]</td>
<td></td>
<tr>
<tr>
<td>assertElementPresent</td>
<td>//div[contains(text(), 'Initial speed: OK')]</td>
......@@ -84,6 +79,11 @@
<td>//div[contains(text(), 'Altitude: OK')]</td>
<td></td>
<tr>
<tr>
<td>assertElementPresent</td>
<td>//div[contains(text(), 'Timeout: OK')]</td>
<td></td>
<tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1016.21987.28184.16844</string> </value>
<value> <string>1017.22776.49981.4147</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1714742619.34</float>
<float>1718722284.77</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -54,11 +54,6 @@
<td>//div[contains(text(), 'CONSOLE LOG ENTRIES:')]</td>
<td></td>
<tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(text(), 'Simulation finished')]</td>
<td></td>
<tr>
<tr>
<td>assertElementPresent</td>
<td>//div[contains(text(), 'Initial speed: OK')]</td>
......@@ -94,6 +89,11 @@
<td>//div[contains(text(), 'Altitude: OK')]</td>
<td></td>
<tr>
<tr>
<td>assertElementPresent</td>
<td>//div[contains(text(), 'Timeout: OK')]</td>
<td></td>
<tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment