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
b9ba1073
Commit
b9ba1073
authored
Sep 23, 2022
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WEB-WORKER] [WIP] Events handling (works!)
parent
d6ce1354
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
8 deletions
+101
-8
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_game_manager_js.js
...eItem/web_page_module/drone_web_worker_game_manager_js.js
+9
-3
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_game_manager_js.xml
...Item/web_page_module/drone_web_worker_game_manager_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
+88
-1
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_game_manager_js.js
View file @
b9ba1073
...
...
@@ -230,14 +230,17 @@ var GameManager = /** @class */ (function () {
var
canvas
=
this
.
_canvas
;
// Create the Babylon engine
this
.
_engine
=
new
BABYLON
.
Engine
(
canvas
,
true
,
{
//options for event handling
stencil
:
true
,
disableWebGL2Support
:
false
,
audioEngine
:
false
});
this
.
_engine
.
enableOfflineSupport
=
false
;
//removed for event handling
//this._engine.enableOfflineSupport = false;
this
.
_scene
=
new
BABYLON
.
Scene
(
this
.
_engine
);
this
.
_scene
.
clearColor
=
new
BABYLON
.
Color4
(
88
/
255
,
171
/
255
,
217
/
255
,
255
/
255
);
this
.
_scene
.
collisionsEnabled
=
true
;
//removed for event handling
//this._scene.collisionsEnabled = true;
// Lights
var
hemi_north
=
new
BABYLON
.
HemisphericLight
(
"
hemiN
"
,
new
BABYLON
.
Vector3
(
1
,
-
1
,
1
),
this
.
_scene
);
...
...
@@ -274,9 +277,12 @@ var GameManager = /** @class */ (function () {
camera
=
new
BABYLON
.
ArcRotateCamera
(
"
camera
"
,
x_rotation
,
1.25
,
radius
,
target
,
this
.
_scene
);
camera
.
wheelPrecision
=
10
;
camera
.
attachControl
(
this
.
_scene
.
getEngine
().
getRenderingCanvas
());
//changed for event handling
//camera.attachControl(this._scene.getEngine().getRenderingCanvas()); //original
camera
.
attachControl
(
canvas
,
true
);
camera
.
maxz
=
40000
;
this
.
_camera
=
camera
;
// Render loop
this
.
_engine
.
runRenderLoop
(
function
()
{
_this
.
_scene
.
render
();
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_game_manager_js.xml
View file @
b9ba1073
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.1
0032.46857.65518
</string>
</value>
<value>
<string>
1003.1
4332.42567.56439
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
166
3944101.22
</float>
<float>
166
4202073.56
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.js
View file @
b9ba1073
...
...
@@ -4,6 +4,89 @@
DroneGameManager*/
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/*************************************************************************/
/**************************** ROQUE WW EVENTS ****************************/
/*************************************************************************/
console
.
log
(
"
WITH EVENTS
"
);
self
.
window
=
{
addEventListener
:
function
(
event
,
fn
,
opt
)
{
bindHandler
(
'
window
'
,
event
,
fn
,
opt
);
},
setTimeout
:
self
.
setTimeout
.
bind
(
self
),
PointerEvent
:
true
};
self
.
document
=
{
addEventListener
:
function
(
event
,
fn
,
opt
)
{
bindHandler
(
'
document
'
,
event
,
fn
,
opt
);
},
// Uses to detect wheel event like at src/Inputs/scene.inputManager.ts:797
createElement
:
function
()
{
return
{
onwheel
:
true
};
},
defaultView
:
self
.
window
,
};
importScripts
(
'
babylon.js
'
,
'
babylon.gui.js
'
);
importScripts
(
'
rsvp.js
'
,
'
GameManager.js
'
,
'
DroneManager.js
'
,
'
MapManager.js
'
,
'
ObstacleManager.js
'
,
'
DroneAaileFixeAPI.js
'
,
'
DroneLogAPI.js
'
,
'
DroneAPI.js
'
,
'
gadget_erp5_page_game_logic.js
'
);
function
mainToWorker
(
evt
)
{
switch
(
evt
.
data
.
type
)
{
case
'
start
'
:
var
offscreen_canvas
=
prepareCanvas
(
evt
.
data
);
RSVP
=
window
.
RSVP
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
runGame
(
offscreen_canvas
,
evt
.
data
.
script
,
evt
.
data
.
game_parameters_json
,
evt
.
data
.
log
);
})
.
push
(
function
()
{
return
postMessage
({
'
type
'
:
'
started
'
});
});
break
;
case
'
update
'
:
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
updateGame
();
})
.
push
(
function
()
{
return
postMessage
({
'
type
'
:
'
updated
'
});
});
break
;
case
'
event
'
:
handleEvent
(
evt
.
data
);
break
;
default
:
throw
new
Error
(
'
Unsupported message
'
+
JSON
.
stringify
(
evt
.
data
));
}
};
/*****************************************************************************/
/************************************************************************/
/***************************** WORKING GAME *****************************/
/************************************************************************/
/*console.log("WORKING GAME WITH NO EVENTS");
var document = {
addEventListener: function () {},
createElement: function () {}
...
...
@@ -79,7 +162,11 @@ function mainToWorker(evt) {
default:
throw new Error('Unsupported message ' + JSON.stringify(evt.data));
}
};
};*/
/*****************************************************************************/
// Doesn't work without it
class
HTMLElement
{}
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.xml
View file @
b9ba1073
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.1
0284.59408.13346
</string>
</value>
<value>
<string>
1003.1
4300.40470.3601
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
166
3959195.15
</float>
<float>
166
4202107.66
</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