bg2e-js 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/bg2e-js.js +11005 -0
  2. package/dist/bg2e-js.js.map +1 -0
  3. package/package.json +17 -6
  4. package/app/AppController.d.ts +0 -37
  5. package/app/AppController.js +0 -32
  6. package/app/Canvas.d.ts +0 -42
  7. package/app/Canvas.js +0 -98
  8. package/app/EventBase.js +0 -8
  9. package/app/KeyboardEvent.js +0 -51
  10. package/app/MainLoop.d.ts +0 -245
  11. package/app/MainLoop.js +0 -251
  12. package/app/MouseEvent.js +0 -77
  13. package/app/TouchEvent.js +0 -15
  14. package/base/Color.js +0 -131
  15. package/base/Environment.js +0 -78
  16. package/base/Light.js +0 -176
  17. package/base/Material.js +0 -619
  18. package/base/PolyList.js +0 -336
  19. package/base/Texture.js +0 -545
  20. package/db/Bg2LoaderPlugin.js +0 -113
  21. package/db/DBPluginApi.js +0 -40
  22. package/db/Loader.js +0 -91
  23. package/db/LoaderPlugin.js +0 -26
  24. package/db/MtlParser.js +0 -7
  25. package/db/ObjLoaderPlugin.js +0 -51
  26. package/db/ObjParser.js +0 -233
  27. package/db/ObjWriterPlugin.js +0 -18
  28. package/db/VitscnjLoaderPlugin.js +0 -87
  29. package/db/Writer.js +0 -49
  30. package/db/WriterPlugin.js +0 -20
  31. package/debug/DebugRenderer.js +0 -138
  32. package/debug/WebGLTextureViewer.js +0 -67
  33. package/manipulation/SelectionBuffer.js +0 -65
  34. package/manipulation/SelectionHighlight.js +0 -69
  35. package/manipulation/SelectionIdAssignVisitor.js +0 -86
  36. package/manipulation/SelectionManager.js +0 -134
  37. package/manipulation/SelectionMode.js +0 -6
  38. package/math/Mat3.js +0 -248
  39. package/math/Mat4.js +0 -694
  40. package/math/MatrixStrategy.js +0 -23
  41. package/math/Quat.js +0 -60
  42. package/math/Vec.js +0 -728
  43. package/math/constants.js +0 -44
  44. package/math/functions.js +0 -104
  45. package/math/index.js +0 -74
  46. package/phsics/joint.js +0 -124
  47. package/primitives/arrow.js +0 -58
  48. package/primitives/cone.js +0 -137
  49. package/primitives/cube.js +0 -59
  50. package/primitives/cylinder.js +0 -215
  51. package/primitives/index.js +0 -13
  52. package/primitives/plane.js +0 -31
  53. package/primitives/sphere.js +0 -808
  54. package/render/BRDFIntegrationMap.js +0 -4
  55. package/render/Environment.js +0 -105
  56. package/render/EnvironmentRenderer.js +0 -12
  57. package/render/FrameBuffer.js +0 -26
  58. package/render/MaterialRenderer.js +0 -28
  59. package/render/Pipeline.js +0 -83
  60. package/render/PolyListRenderer.js +0 -42
  61. package/render/RenderBuffer.js +0 -189
  62. package/render/RenderQueue.js +0 -162
  63. package/render/RenderState.js +0 -82
  64. package/render/Renderer.js +0 -202
  65. package/render/SceneAppController.js +0 -208
  66. package/render/SceneRenderer.js +0 -310
  67. package/render/Shader.js +0 -21
  68. package/render/ShadowRenderer.js +0 -159
  69. package/render/SkyCube.js +0 -77
  70. package/render/SkySphere.js +0 -94
  71. package/render/TextureMergerRenderer.js +0 -58
  72. package/render/TextureRenderer.js +0 -29
  73. package/render/webgl/FrameBuffer.js +0 -9
  74. package/render/webgl/MaterialRenderer.js +0 -99
  75. package/render/webgl/Pipeline.js +0 -82
  76. package/render/webgl/PolyListRenderer.js +0 -224
  77. package/render/webgl/RenderBuffer.js +0 -244
  78. package/render/webgl/Renderer.js +0 -239
  79. package/render/webgl/SceneRenderer.js +0 -43
  80. package/render/webgl/ShaderProgram.js +0 -350
  81. package/render/webgl/ShadowRenderer.js +0 -6
  82. package/render/webgl/SkyCube.js +0 -15
  83. package/render/webgl/SkySphere.js +0 -14
  84. package/render/webgl/State.js +0 -149
  85. package/render/webgl/TextureRenderer.js +0 -167
  86. package/render/webgl/VertexBuffer.js +0 -128
  87. package/scene/Camera.js +0 -378
  88. package/scene/Chain.js +0 -43
  89. package/scene/ChainJoint.js +0 -55
  90. package/scene/Component.js +0 -146
  91. package/scene/ComponentMap.js +0 -99
  92. package/scene/Drawable.js +0 -130
  93. package/scene/EnvironmentComponent.js +0 -123
  94. package/scene/FindNodeVisitor.js +0 -55
  95. package/scene/LightComponent.js +0 -146
  96. package/scene/MatrixState.js +0 -39
  97. package/scene/Node.js +0 -300
  98. package/scene/NodeVisitor.js +0 -12
  99. package/scene/OrbitCameraController.js +0 -407
  100. package/scene/SmoothOrbitCameraController.js +0 -92
  101. package/scene/Transform.js +0 -74
  102. package/scene/index.js +0 -24
  103. package/shaders/BasicDiffuseColorShader.js +0 -91
  104. package/shaders/BasicPBRLightShader.js +0 -238
  105. package/shaders/DebugRenderShader.js +0 -79
  106. package/shaders/DepthRenderShader.js +0 -69
  107. package/shaders/IrradianceMapCubeShader.js +0 -99
  108. package/shaders/PBRLightIBLShader.js +0 -380
  109. package/shaders/PickSelectionShader.js +0 -75
  110. package/shaders/PresentDebugFramebufferShader.js +0 -90
  111. package/shaders/PresentTextureShader.js +0 -73
  112. package/shaders/SelectionHighlightShader.js +0 -98
  113. package/shaders/ShaderFunction.js +0 -72
  114. package/shaders/SkyCubeShader.js +0 -78
  115. package/shaders/SkySphereShader.js +0 -77
  116. package/shaders/SpecularMapCubeShader.js +0 -145
  117. package/shaders/TextureMergerShader.js +0 -127
  118. package/shaders/webgl_shader_lib.js +0 -187
  119. package/tools/BinaryResourceProvider.js +0 -15
  120. package/tools/ImageResourceProvider.js +0 -65
  121. package/tools/MaterialModifier.js +0 -228
  122. package/tools/Resource.js +0 -177
  123. package/tools/ResourceProvider.js +0 -56
  124. package/tools/TextResourceProvider.js +0 -24
  125. package/tools/TextureCache.js +0 -44
  126. package/tools/TextureResourceDatabase.js +0 -87
  127. package/tools/UserAgent.js +0 -294
  128. package/tools/VideoResourceProvider.js +0 -51
  129. package/tools/WriteStrategy.js +0 -22
  130. package/tools/base64.js +0 -15
  131. package/tools/crypto.js +0 -15
  132. package/tools/endiantess.js +0 -15
  133. package/tools/image.js +0 -15
  134. package/tools/index.js +0 -33
  135. package/tools/processType.js +0 -56
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "bg2e-js",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "a graphics engine for productivity applications",
5
- "main": "index.js",
5
+ "main": "./dist/bg2e-js.js",
6
+ "files": [
7
+ "dist/bg2e-js.js",
8
+ "dist/bg2e-js.js.map"
9
+ ],
10
+ "module": "./dist/bg2e-js.js",
6
11
  "type": "module",
7
- "dependencies": {
8
- "bg2io": "^1.0.7"
12
+ "scripts": {
13
+ "dev": "vite build --watch --emptyOutDir",
14
+ "build": "vite build --emptyOutDir"
9
15
  },
10
- "scripts": {},
11
16
  "repository": {
12
17
  "type": "git",
13
18
  "url": "git+https://github.com/ferserc1/bg2e-js.git"
@@ -23,5 +28,11 @@
23
28
  "bugs": {
24
29
  "url": "https://github.com/ferserc1/bg2e-js/issues"
25
30
  },
26
- "homepage": "https://github.com/ferserc1/bg2e-js#readme"
31
+ "homepage": "https://github.com/ferserc1/bg2e-js#readme",
32
+ "dependencies": {
33
+ "bg2io": "^1.0.7"
34
+ },
35
+ "devDependencies": {
36
+ "vite": "^7.1.5"
37
+ }
27
38
  }
@@ -1,37 +0,0 @@
1
-
2
- import MainLoop from './MainLoop';
3
- import Canvas from './Canvas';
4
- import MouseEvent from './MouseEvent';
5
- import TouchEvent from './TouchEvent';
6
- import KeyboardEvent from './KeyboardEvent';
7
- import Renderer from '../render/Renderer';
8
-
9
- export default class AppController {
10
- constructor();
11
-
12
- get mainLoop() ; MainLoop;
13
- set mainLoop(ml: MainLoop);
14
-
15
- get canvas() : Canvas;
16
-
17
- get renderer() : Renderer;
18
-
19
- get viewport() : { width: number, height: number, aspectRatio: number };
20
-
21
- async init();
22
- reshape(width: number, height: number);
23
- async frame(delta: number);
24
- display();
25
- destroy();
26
- keyDown(evt: KeyboardEvent);
27
- keyUp(evt: KeyboardEvent);
28
- mouseUp(evt: MouseEvent);
29
- mouseDown(evt: MouseEvent);
30
- mouseMove(evt: MouseEvent);
31
- mouseOut(evt: MouseEvent);
32
- mouseDrag(evt: MouseEvent);
33
- mouseWheel(evt: MouseEvent);
34
- touchStart(evt: TouchEvent);
35
- touchMove(evt: TouchEvent);
36
- touchEnd(evt: TouchEvent);
37
- }
@@ -1,32 +0,0 @@
1
-
2
- export default class AppController {
3
- constructor() {
4
- this._mainLoop = null;
5
- }
6
-
7
- get mainLoop() { return this._mainLoop; }
8
- set mainLoop(ml) { this._mainLoop = ml; }
9
-
10
- get canvas() { return this._mainLoop?.canvas; }
11
-
12
- get renderer() { return this._mainLoop?.canvas?.renderer; }
13
-
14
- get viewport() { return this.canvas?.viewport || { width: 0, height: 0, aspectRatio: 0 }; }
15
-
16
- async init() {}
17
- reshape(width,height) {}
18
- async frame(delta) {}
19
- display() {}
20
- destroy() {}
21
- keyDown(evt) {}
22
- keyUp(evt) {}
23
- mouseUp(evt) {}
24
- mouseDown(evt) {}
25
- mouseMove(evt) {}
26
- mouseOut(evt) {}
27
- mouseDrag(evt) {}
28
- mouseWheel(evt) {}
29
- touchStart(evt) {}
30
- touchMove(evt) {}
31
- touchEnd(evt) {}
32
- }
package/app/Canvas.d.ts DELETED
@@ -1,42 +0,0 @@
1
-
2
- import { MainLoop } from './MainLoop';
3
-
4
- export type Touch = {
5
- identifier: number
6
- x: number
7
- y: number
8
- force: number
9
- rotationAngle: number
10
- radiusX: number
11
- radiusY: number
12
- }
13
-
14
- export declare function getMouseEventOffset(evt: any, canvas: Canvas) : { x: number, y: number };
15
-
16
- export declare function getEventTouches(evt: any, canvas: Canvas) : Touch[];
17
-
18
- export default class Canvas {
19
- static FirstCanvas() : Canvas;
20
-
21
- constructor(domElement: HTMLElement, renderer: any);
22
-
23
- get id() : string;
24
-
25
- async init() : Promise<void>;
26
-
27
- get mainLoop() : MainLoop;
28
-
29
- get renderer() { return this._renderer; }
30
-
31
- get domElement() { return this._domElement; }
32
-
33
- get width() { return this._domElement.clientWidth; }
34
-
35
- get height() { return this._domElement.clientHeight; }
36
-
37
- get viewport() { return { width: this.width, height: this.height, aspectRatio: this.width / this.height }; }
38
-
39
- updateViewportSize() : void;
40
-
41
- screenshot(format: string, width: number, height: number);
42
- }
package/app/Canvas.js DELETED
@@ -1,98 +0,0 @@
1
- import { generateUUID } from "../tools/crypto";
2
-
3
- export const getMouseEventOffset = (evt,canvas) => {
4
- const offset = canvas.domElement.getBoundingClientRect();
5
- return {
6
- x: evt.clientX - offset.left,
7
- y: evt.clientY - offset.top
8
- };
9
- }
10
-
11
- export const getEventTouches = (evt,canvas) => {
12
- const offset = canvas.domElement.getBoundingClientRect();
13
- const touches = Array.from(evt.touches).map(touch => {
14
- return {
15
- identifier: touch.identifier,
16
- x: touch.clientX - offset.left,
17
- y: touch.clientY - offset.top,
18
- force: touch.force,
19
- rotationAngle: touch.rotationAngle,
20
- radiusX: touch.radiusX,
21
- radiusY: touch.radiusY
22
- };
23
- });
24
- return touches;
25
- }
26
-
27
- let g_firstCanvas = null;
28
-
29
- export default class Canvas {
30
- static FirstCanvas() {
31
- return g_firstCanvas;
32
- }
33
-
34
- constructor(domElement,renderer) {
35
- this._renderer = renderer;
36
- this._domElement = domElement;
37
- this._domElement._bg2e_id = generateUUID();
38
-
39
- g_firstCanvas = g_firstCanvas || this;
40
-
41
- // Initialized in mainLoop constructor
42
- this._mainLoop = null;
43
- }
44
-
45
- get id() {
46
- return this._domElement._bg2e_id;
47
- }
48
-
49
- async init() {
50
- await this._renderer.init(this);
51
- }
52
-
53
- get mainLoop() { return this._mainLoop; }
54
-
55
- get renderer() { return this._renderer; }
56
-
57
- get domElement() { return this._domElement; }
58
-
59
- get width() { return this._domElement.clientWidth; }
60
-
61
- get height() { return this._domElement.clientHeight; }
62
-
63
- get viewport() { return { width: this.width, height: this.height, aspectRatio: this.width / this.height }; }
64
-
65
- updateViewportSize() {
66
- const sizeInPx = { w: this.domElement.clientWidth, h: this.domElement.clientHeight };
67
- this.domElement.width = sizeInPx.w * window.devicePixelRatio;
68
- this.domElement.height = sizeInPx.h * window.devicePixelRatio;
69
- }
70
-
71
- screenshot(format, width, height) {
72
- let canvasStyle = "";
73
- const prevSize = {};
74
-
75
- if (width) {
76
- height = height ? height : width;
77
- canvasStyle = this.domElement.style.cssText;
78
- prevSize.width = this.domElement.width;
79
- prevSize.height = this.domElement.height;
80
-
81
- this.domElement.style.cssText = `top:auto;left:auto;bottom:auto;right:auto;width:${width}px;height:${height}px;`;
82
- this.domElement.width = width;
83
- this.domElement.height = height;
84
- this.mainLoop.appController.reshape(width,height);
85
- this.mainLoop.appController.display();
86
- }
87
-
88
- const data = this.domElement.toDataURL(format);
89
- if (width) {
90
- this.domElement.cssText = canvasStyle;
91
- this.domElement.width = prevSize.width;
92
- this.domElement.height = prevSize.height;
93
- this.mainLoop.appController.reshape(prevSize.width, prevSize.heigth);
94
- this.mainLoop.appController.display();
95
- }
96
- return data;
97
- }
98
- }
package/app/EventBase.js DELETED
@@ -1,8 +0,0 @@
1
-
2
- export default class EventBase {
3
- stopPropagation() {
4
- this._stopPropagation = true;
5
- }
6
-
7
- get isEventPropagationStopped() { return this._stopPropagation; }
8
- }
@@ -1,51 +0,0 @@
1
- import EventBase from "./EventBase";
2
-
3
- export const SpecialKey = {
4
- BACKSPACE: "Backspace",
5
- TAB: "Tab",
6
- ENTER: "Enter",
7
- SHIFT: "Shift",
8
- SHIFT_LEFT: "ShiftLeft",
9
- SHIFT_RIGHT: "ShiftRight",
10
- CTRL: "Control",
11
- CTRL_LEFT: "ControlLeft",
12
- CTRL_LEFT: "ControlRight",
13
- ALT: "Alt",
14
- ALT_LEFT: "AltLeft",
15
- ALT_RIGHT: "AltRight",
16
- PAUSE: "Pause",
17
- CAPS_LOCK: "CapsLock",
18
- ESCAPE: "Escape",
19
- PAGE_UP: "PageUp",
20
- PAGEDOWN: "PageDown",
21
- END: "End",
22
- HOME: "Home",
23
- LEFT_ARROW: "ArrowLeft",
24
- UP_ARROW: "ArrowUp",
25
- RIGHT_ARROW: "ArrowRight",
26
- DOWN_ARROW: "ArrowDown",
27
- INSERT: "Insert",
28
- DELETE: "Delete",
29
- SPACE: "Space"
30
- };
31
-
32
- export const createKeyboardEvent = (evt) => {
33
- const code = SpecialKey[evt.code] != null ? evt.keyCode : evt.code;
34
- return new KeyboardEvent(code, evt);
35
- }
36
-
37
- export default class KeyboardEvent extends EventBase {
38
- static IsSpecialKey(event) {
39
- return SpecialKey[event.code]!=null;
40
- }
41
-
42
- constructor(key,event) {
43
- super();
44
- this.key = key;
45
- this.event = event;
46
- }
47
-
48
- get isSpecialKey() {
49
- return KeyboardEvent.IsSpecialKey(this.event);
50
- }
51
- }
package/app/MainLoop.d.ts DELETED
@@ -1,245 +0,0 @@
1
-
2
- import { Canvas } from "./Canvas";
3
- import { AppController } from "./AppController";
4
-
5
- import {
6
- MouseButtonEventType,
7
- createMouseEvent,
8
- leftMouseButton,
9
- middleMouseButton,
10
- clearMouseButtons,
11
- setMouseButton
12
- } from "./MouseEvent";
13
- import { createTouchEvent } from "./TouchEvent";
14
- import { createKeyboardEvent } from "./KeyboardEvent";
15
-
16
- export const FrameUpdate = {
17
- AUTO: 0,
18
- MANUAL: 1
19
- };
20
-
21
- const g_animationLoop = {
22
- lastTime: 0,
23
- mainLoop: []
24
- };
25
-
26
- async function animationLoop(totalTime) {
27
- totalTime = totalTime || 0;
28
- requestAnimationFrame(animationLoop);
29
- const elapsed = totalTime - g_animationLoop.lastTime;
30
- g_animationLoop.lastTime = totalTime;
31
- for (const ml of g_animationLoop.mainLoop) {
32
- await onUpdate(ml, elapsed);
33
- }
34
- }
35
-
36
- class MouseStatus {
37
- constructor() {
38
- this.pos = {x: 0, y: 0};
39
- this.leftButton = false;
40
- this.middleButton = false;
41
- this.rightButton = false;
42
- }
43
-
44
- get anyButton() { return this.leftButton || this.middleButton || this.rightButton; }
45
- }
46
-
47
- export default class MainLoop {
48
- constructor(canvas: Canvas, appController: AppController);
49
-
50
- get canvas() : Canvas;
51
- get appController() : AppController;
52
- get renderer() { return this._canvas?.renderer; }
53
-
54
- get updateMode() { return this._updateMode; }
55
- set updateMode(um) { this._updateMode = um; }
56
-
57
- get mouseStatus() { return this._mouseStatus; }
58
-
59
- get redisplay() { return this._redisplayFrames>0; }
60
-
61
- async run() {
62
- await this.canvas.init();
63
- await this.appController.init();
64
- initEvents(this);
65
- g_animationLoop.mainLoop.push(this);
66
- animationLoop();
67
- }
68
-
69
- exit() {
70
- this.appController.destroy();
71
- const i = g_animationLoop.mainLoop.indexOf(this);
72
- if (i!==-1) {
73
- g_animationLoop.mainLoop.splice(i,1);
74
- }
75
- }
76
-
77
- postReshape() {
78
- onResize(this);
79
- }
80
-
81
- postRedisplay({ frames=2,timeout=10 } = {}) {
82
- if (timeout <= 0) {
83
- this._redisplayFrames = frames;
84
- }
85
- else {
86
- setTimeout(() => this._redisplayFrames = frames, timeout);
87
- }
88
- }
89
- }
90
-
91
-
92
- function initEvents(mainLoop) {
93
- onResize(mainLoop);
94
-
95
- const handlePropagation = (bgEvt,evt) => {
96
- if (bgEvt.isEventPropagationStopped) {
97
- evt.stopPropagation();
98
- evt.preventDefault();
99
- return false;
100
- }
101
- return true;
102
- }
103
-
104
- const c = mainLoop.canvas.domElement;
105
- c.__mainLoop = mainLoop;
106
- c.addEventListener("mousedown", evt => {
107
- return handlePropagation(onMouseDown(evt, evt.target.__mainLoop), evt);
108
- });
109
- c.addEventListener("mousemove", evt => {
110
- return handlePropagation(onMouseMove(evt, evt.target.__mainLoop), evt);
111
- });
112
- c.addEventListener("mouseout", evt => {
113
- return handlePropagation(onMouseOut(evt, evt.target.__mainLoop), evt);
114
- });
115
-
116
- c.addEventListener("mouseover", evt => {
117
- return handlePropagation(onMouseOver(evt, evt.target.__mainLoop), evt);
118
- });
119
-
120
- c.addEventListener("mouseup", evt => {
121
- return handlePropagation(onMouseUp(evt, evt.target.__mainLoop), evt);
122
- });
123
-
124
- c.addEventListener("touchstart", evt => {
125
- return handlePropagation(onTouchStart(evt, evt.target.__mainLoop), evt);
126
- });
127
-
128
- c.addEventListener("touchmove", evt => {
129
- return handlePropagation(onTouchMove(evt, evt.target.__mainLoop), evt);
130
- });
131
-
132
- c.addEventListener("touchend", evt => {
133
- return handlePropagation(onTouchEnd(evt, evt.target.__mainLoop), evt);
134
- });
135
-
136
- const mouseWheelEvt = (/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
137
- c.addEventListener(mouseWheelEvt, evt => {
138
- return handlePropagation(onMouseWheel(evt, evt.target.__mainLoop), evt);
139
- });
140
-
141
- window.addEventListener("keydown", evt => {
142
- g_animationLoop.mainLoop.forEach(ml => onKeyDown(evt, ml));
143
- });
144
-
145
- window.addEventListener("keyup", evt => {
146
- g_animationLoop.mainLoop.forEach(ml => onKeyUp(evt, ml));
147
- });
148
-
149
- window.addEventListener("resize", evt => {
150
- onResize(mainLoop);
151
- });
152
-
153
- c.oncontextmenu = evt => false;
154
- }
155
-
156
- function onResize(mainLoop) {
157
- const dpi = window.devicePixelRatio;
158
- mainLoop.appController.reshape(mainLoop.canvas.width * dpi, mainLoop.canvas.height * dpi);
159
- }
160
-
161
- async function onUpdate(mainLoop, elapsed) {
162
- if (mainLoop.redisplay) {
163
- if (mainLoop.updateMode === FrameUpdate.AUTO) {
164
- mainLoop._redisplayFrames = 1;
165
- }
166
- else {
167
- mainLoop._redisplayFrames--;
168
- }
169
- if (mainLoop._redisplayFrames > 0) {
170
- await mainLoop.appController.frame(elapsed);
171
- mainLoop.appController.display();
172
- }
173
- }
174
- }
175
-
176
- function onMouseDown(evt,mainLoop) {
177
- const bg2Event = createMouseEvent(evt, mainLoop, MouseButtonEventType.DOWN);
178
- setMouseButton(bg2Event, true);
179
- mainLoop.appController.mouseDown(bg2Event);
180
- return bg2Event;
181
- }
182
-
183
- function onMouseMove(evt,mainLoop) {
184
- const bg2Event = createMouseEvent(evt, mainLoop, MouseButtonEventType.NONE);
185
- mainLoop.appController.mouseMove(bg2Event);
186
- if (mainLoop.mouseStatus.anyButton) {
187
- mainLoop.appController.mouseDrag(bg2Event);
188
- }
189
- return bg2Event;
190
- }
191
-
192
- function onMouseOut(evt,mainLoop) {
193
- const bg2Event = createMouseEvent(evt, mainLoop, MouseButtonEventType.NONE);
194
- clearMouseButtons();
195
- mainLoop.appController.mouseOut(bg2Event);
196
- return bg2Event;
197
- }
198
-
199
- function onMouseOver(evt,mainLoop) {
200
- return onMouseMove(evt,mainLoop)
201
- }
202
-
203
- function onMouseUp(evt,mainLoop) {
204
- const bg2Event = createMouseEvent(evt, mainLoop, MouseButtonEventType.UP);
205
- setMouseButton(bg2Event, false);
206
- mainLoop.appController.mouseUp(bg2Event);
207
- return bg2Event;
208
- }
209
-
210
- function onMouseWheel(evt,mainLoop) {
211
- const bg2Event = createMouseEvent(evt, mainLoop, MouseButtonEventType.NONE);
212
- bg2Event.delta = evt.wheelDelta ? evt.wheelDelta * -1 : evt.detail * 10;
213
- mainLoop.appController.mouseWheel(bg2Event);
214
- return bg2Event;
215
- }
216
-
217
- function onTouchStart(evt,mainLoop) {
218
- const bgEvent = createTouchEvent(evt,mainLoop);
219
- mainLoop.appController.touchStart(bgEvent);
220
- return bgEvent;
221
- }
222
-
223
- function onTouchMove(evt,mainLoop) {
224
- const bgEvent = createTouchEvent(evt,mainLoop);
225
- mainLoop.appController.touchMove(bgEvent);
226
- return bgEvent;
227
- }
228
-
229
- function onTouchEnd(evt,mainLoop) {
230
- const bgEvent = createTouchEvent(evt,mainLoop);
231
- mainLoop.appController.touchEnd(bgEvent);
232
- return bgEvent;
233
- }
234
-
235
- function onKeyDown(evt,mainLoop) {
236
- const bgEvent = createKeyboardEvent(evt);
237
- mainLoop.appController.keyDown(bgEvent);
238
- return bgEvent;
239
- }
240
-
241
- function onKeyUp(evt,mainLoop) {
242
- const bgEvent = createKeyboardEvent(evt);
243
- mainLoop.appController.keyUp(bgEvent);
244
- return bgEvent;
245
- }