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