Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
erp5
Commits
d08abb4d
Commit
d08abb4d
authored
Sep 28, 2022
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WEB-WORKER] [WIP] move all game logic into one file (WIP)
parent
4a5688e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
14 deletions
+104
-14
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.js
...TemplateItem/web_page_module/drone_web_worker_logic_js.js
+100
-8
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.xml
...emplateItem/web_page_module/drone_web_worker_logic_js.xml
+2
-2
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.js
...ateItem/web_page_module/drone_web_worker_web_worker_js.js
+0
-2
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.xml
...teItem/web_page_module/drone_web_worker_web_worker_js.xml
+2
-2
No files found.
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.js
View file @
d08abb4d
...
...
@@ -195,7 +195,7 @@ var runGame, updateGame, eventGame, game_manager_instance;
converted_log_point_list
:
converted_log_point_list
};
game_parameters_json
.
drone
.
maxSpeed
=
(
flight_dist
/
flight_time
)
*
SPEED_FACTOR
;
game_parameters_json
.
obstacles
=
path_point_list
;
game_parameters_json
.
flight_path_point_list
=
path_point_list
;
/*game_parameters_json.randomSpawn.leftTeam.position.x = start_position[0];
game_parameters_json.randomSpawn.leftTeam.position.y = start_position[1];
game_parameters_json.randomSpawn.leftTeam.position.z = start_position[2];*/
...
...
@@ -576,7 +576,6 @@ var GameManager = /** @class */ (function () {
};
GameManager
.
prototype
.
_load3DModel
=
function
(
callback
)
{
console
.
log
(
"
_load3DModel!
"
);
var
_this
=
this
,
droneTask
,
mapTask
,
obstacleTask
,
assetManager
=
new
BABYLON
.
AssetsManager
(
this
.
_scene
);
assetManager
.
useDefaultLoadingScreen
=
true
;
...
...
@@ -609,7 +608,6 @@ var GameManager = /** @class */ (function () {
return
callback
();
};
assetManager
.
load
();
console
.
log
(
"
asset manager loaded (tasks for map, drones and obstacles)
"
);
};
GameManager
.
prototype
.
_getGameParameter
=
function
()
{
...
...
@@ -624,11 +622,12 @@ var GameManager = /** @class */ (function () {
Object
.
assign
(
parameter
,
this
.
_game_parameters_json
);
this
.
_gameParameter
=
{};
Object
.
assign
(
this
.
_gameParameter
,
this
.
_game_parameters_json
);
//TODO obstacle is kept as real flight log uses for path draw. Refactor this
for
(
i
=
0
;
i
<
parameter
.
obstacles
.
length
;
i
+=
1
)
{
parameter
.
obstacles
[
i
].
position
=
swap
(
parameter
.
obstacles
[
i
].
position
);
if
(
parameter
.
obstacles
[
i
].
scale
)
{
parameter
.
obstacles
[
i
].
scale
=
swap
(
parameter
.
obstacles
[
i
].
scale
);
for
(
i
=
0
;
i
<
parameter
.
flight_path_point_list
.
length
;
i
+=
1
)
{
parameter
.
flight_path_point_list
[
i
].
position
=
swap
(
parameter
.
flight_path_point_list
[
i
].
position
);
if
(
parameter
.
flight_path_point_list
[
i
].
scale
)
{
parameter
.
flight_path_point_list
[
i
].
scale
=
swap
(
parameter
.
flight_path_point_list
[
i
].
scale
);
}
}
return
parameter
;
...
...
@@ -1440,4 +1439,97 @@ var DroneManager = /** @class */ (function () {
DroneManager
.
prototype
.
onGetMsg
=
function
(
msg
)
{
};
;
return
DroneManager
;
}());
/******************************************************************************/
/******************************** MAP MANAGER *********************************/
var
MapManager
=
/** @class */
(
function
()
{
//** CONSTRUCTOR
function
MapManager
(
scene
)
{
var
_this
=
this
;
var
max
=
GAMEPARAMETERS
.
mapSize
.
width
;
if
(
GAMEPARAMETERS
.
mapSize
.
depth
>
max
)
max
=
GAMEPARAMETERS
.
mapSize
.
depth
;
if
(
GAMEPARAMETERS
.
mapSize
.
height
>
max
)
max
=
GAMEPARAMETERS
.
mapSize
.
height
;
max
=
max
<
GAMEPARAMETERS
.
mapSize
.
depth
?
GAMEPARAMETERS
.
mapSize
.
depth
:
max
;
// Skybox
var
max_sky
=
(
max
*
10
<
20000
)
?
max
*
10
:
20000
,
skybox
=
BABYLON
.
Mesh
.
CreateBox
(
"
skyBox
"
,
max_sky
,
scene
);
skybox
.
infiniteDistance
=
true
;
skybox
.
renderingGroupId
=
0
;
var
skyboxMat
=
new
BABYLON
.
StandardMaterial
(
"
skybox
"
,
scene
);
skyboxMat
.
backFaceCulling
=
false
;
skyboxMat
.
disableLighting
=
true
;
skyboxMat
.
reflectionTexture
=
new
BABYLON
.
CubeTexture
(
"
./assets/skybox/sky
"
,
scene
);
skyboxMat
.
reflectionTexture
.
coordinatesMode
=
BABYLON
.
Texture
.
SKYBOX_MODE
;
skyboxMat
.
infiniteDistance
=
true
;
skybox
.
material
=
skyboxMat
;
// Plane from bottom
var
largeGroundMat
=
new
BABYLON
.
StandardMaterial
(
"
largeGroundMat
"
,
scene
);
largeGroundMat
.
specularColor
=
BABYLON
.
Color3
.
Black
();
largeGroundMat
.
alpha
=
0.4
;
var
largeGroundBottom
=
BABYLON
.
Mesh
.
CreatePlane
(
"
largeGroundBottom
"
,
max
*
11
,
scene
);
largeGroundBottom
.
position
.
y
=
-
0.01
;
largeGroundBottom
.
rotation
.
x
=
-
Math
.
PI
/
2
;
largeGroundBottom
.
rotation
.
y
=
Math
.
PI
;
largeGroundBottom
.
material
=
largeGroundMat
;
// Camera
scene
.
activeCamera
.
upperRadiusLimit
=
max
*
4
;
// Terrain
var
width
=
GAMEPARAMETERS
.
mapSize
.
width
,
depth
=
GAMEPARAMETERS
.
mapSize
.
depth
,
height
=
GAMEPARAMETERS
.
mapSize
.
height
,
terrain
=
scene
.
getMeshByName
(
"
terrain001
"
);
terrain
.
isVisible
=
true
;
terrain
.
position
=
BABYLON
.
Vector3
.
Zero
();
terrain
.
scaling
=
new
BABYLON
.
Vector3
(
depth
/
50000
,
depth
/
50000
,
width
/
50000
);
// Flight path point list
var
count
=
0
;
this
.
_flight_path_point_list
=
[];
GAMEPARAMETERS
.
flight_path_point_list
.
forEach
(
function
(
obs
)
{
var
newObj
;
switch
(
obs
.
type
)
{
case
"
box
"
:
newObj
=
BABYLON
.
MeshBuilder
.
CreateBox
(
"
obs_
"
+
count
,
{
'
size
'
:
1
},
scene
);
break
;
case
"
cylinder
"
:
newObj
=
BABYLON
.
MeshBuilder
.
CreateCylinder
(
"
obs_
"
+
count
,
{
'
diameterBottom
'
:
obs
.
diameterBottom
,
'
diameterTop
'
:
obs
.
diameterTop
,
'
height
'
:
1
},
scene
);
break
;
case
"
sphere
"
:
newObj
=
BABYLON
.
MeshBuilder
.
CreateSphere
(
"
obs_
"
+
count
,
{
'
diameterX
'
:
obs
.
scale
.
x
,
'
diameterY
'
:
obs
.
scale
.
y
,
'
diameterZ
'
:
obs
.
scale
.
z
},
scene
);
break
;
default
:
return
;
}
newObj
.
obsType
=
obs
.
type
;
var
convertion
=
Math
.
PI
/
180
;
if
(
"
position
"
in
obs
)
newObj
.
position
=
new
BABYLON
.
Vector3
(
obs
.
position
.
x
,
obs
.
position
.
y
,
obs
.
position
.
z
);
if
(
"
rotation
"
in
obs
)
newObj
.
rotation
=
new
BABYLON
.
Vector3
(
obs
.
rotation
.
x
*
convertion
,
obs
.
rotation
.
y
*
convertion
,
obs
.
rotation
.
z
*
convertion
);
if
(
"
scale
"
in
obs
)
newObj
.
scaling
=
new
BABYLON
.
Vector3
(
obs
.
scale
.
x
,
obs
.
scale
.
y
,
obs
.
scale
.
z
);
if
(
"
color
"
in
obs
)
{
var
material
=
new
BABYLON
.
StandardMaterial
(
scene
);
material
.
alpha
=
1
;
material
.
diffuseColor
=
new
BABYLON
.
Color3
(
obs
.
color
.
r
,
obs
.
color
.
g
,
obs
.
color
.
b
);
newObj
.
material
=
material
;
}
_this
.
_flight_path_point_list
.
push
(
newObj
);
});
}
return
MapManager
;
}());
\ No newline at end of file
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.xml
View file @
d08abb4d
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.17
389.58791.46523
</string>
</value>
<value>
<string>
1003.17
406.3469.33194
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
166438
5697.54
</float>
<float>
166438
6445.46
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.js
View file @
d08abb4d
...
...
@@ -25,8 +25,6 @@ self.document = {
importScripts
(
'
babylon.js
'
,
'
babylon.gui.js
'
);
importScripts
(
'
rsvp.js
'
,
'
MapManager.js
'
,
'
ObstacleManager.js
'
,
'
gadget_erp5_page_game_logic.js
'
);
function
mainToWorker
(
evt
)
{
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.xml
View file @
d08abb4d
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.1606
3.16360.1689
</string>
</value>
<value>
<string>
1003.1606
8.56422.56064
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
16643
06211.61
</float>
<float>
16643
86491.83
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment