@awayjs/scene 0.13.265 → 0.13.266
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.
- package/.eslintrc +100 -100
- package/README.md +61 -61
- package/bundle/awayjs-scene.umd.js +2 -2
- package/bundle/awayjs-scene.umd.js.map +1 -1
- package/copyVersionToIndex.js +23 -23
- package/dist/index.d.ts +76 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -66
- package/dist/lib/Scene.d.ts +84 -84
- package/dist/lib/Scene.js +288 -288
- package/dist/lib/Settings.d.ts +16 -16
- package/dist/lib/Settings.js +60 -60
- package/dist/lib/adapters/IDisplayObjectAdapter.d.ts +13 -13
- package/dist/lib/adapters/IDisplayObjectAdapter.js +1 -1
- package/dist/lib/adapters/IFilter.d.ts +24 -24
- package/dist/lib/adapters/IFilter.js +1 -1
- package/dist/lib/adapters/IMovieClipAdapter.d.ts +14 -14
- package/dist/lib/adapters/IMovieClipAdapter.js +1 -1
- package/dist/lib/adapters/ITextfieldAdapter.d.ts +4 -4
- package/dist/lib/adapters/ITextfieldAdapter.js +1 -1
- package/dist/lib/base/IBitmapDrawable.d.ts +11 -11
- package/dist/lib/base/IBitmapDrawable.js +1 -1
- package/dist/lib/base/IFrameLabel.d.ts +4 -4
- package/dist/lib/base/IFrameLabel.js +1 -1
- package/dist/lib/base/IFrameScript.d.ts +5 -5
- package/dist/lib/base/IFrameScript.js +1 -1
- package/dist/lib/base/MouseButtons.d.ts +26 -22
- package/dist/lib/base/MouseButtons.d.ts.map +1 -1
- package/dist/lib/base/MouseButtons.js +1 -1
- package/dist/lib/base/Timeline.d.ts +148 -148
- package/dist/lib/base/Timeline.js +535 -535
- package/dist/lib/base/TimelineActionType.d.ts +18 -18
- package/dist/lib/base/TimelineActionType.js +1 -1
- package/dist/lib/controllers/ControllerBase.d.ts +14 -14
- package/dist/lib/controllers/ControllerBase.js +60 -60
- package/dist/lib/controllers/FirstPersonController.d.ts +78 -78
- package/dist/lib/controllers/FirstPersonController.js +228 -228
- package/dist/lib/controllers/FollowController.d.ts +12 -12
- package/dist/lib/controllers/FollowController.js +27 -27
- package/dist/lib/controllers/HoverController.d.ts +105 -105
- package/dist/lib/controllers/HoverController.js +302 -302
- package/dist/lib/controllers/LookAtController.d.ts +14 -14
- package/dist/lib/controllers/LookAtController.js +68 -68
- package/dist/lib/controllers/SpringController.d.ts +38 -38
- package/dist/lib/controllers/SpringController.js +59 -59
- package/dist/lib/display/Billboard.d.ts +147 -147
- package/dist/lib/display/Billboard.js +426 -426
- package/dist/lib/display/Camera.d.ts +40 -40
- package/dist/lib/display/Camera.js +90 -90
- package/dist/lib/display/DisplayObject.d.ts +938 -938
- package/dist/lib/display/DisplayObject.js +1641 -1641
- package/dist/lib/display/DisplayObjectContainer.d.ts +325 -325
- package/dist/lib/display/DisplayObjectContainer.js +480 -480
- package/dist/lib/display/LineSegment.d.ts +84 -84
- package/dist/lib/display/LineSegment.js +215 -215
- package/dist/lib/display/LoaderContainer.d.ts +504 -504
- package/dist/lib/display/LoaderContainer.js +603 -603
- package/dist/lib/display/MorphSprite.d.ts +20 -20
- package/dist/lib/display/MorphSprite.js +254 -254
- package/dist/lib/display/MovieClip.d.ts +152 -152
- package/dist/lib/display/MovieClip.js +735 -735
- package/dist/lib/display/SimpleButton.d.ts +158 -158
- package/dist/lib/display/SimpleButton.js +228 -228
- package/dist/lib/display/Skybox.d.ts +156 -156
- package/dist/lib/display/Skybox.js +309 -309
- package/dist/lib/display/Sprite.d.ts +70 -70
- package/dist/lib/display/Sprite.js +144 -144
- package/dist/lib/display/TextField.d.ts +1109 -1109
- package/dist/lib/display/TextField.js +3109 -3109
- package/dist/lib/display/TextSprite.d.ts +10 -10
- package/dist/lib/display/TextSprite.js +25 -25
- package/dist/lib/elements/SkyboxElements.d.ts +29 -29
- package/dist/lib/elements/SkyboxElements.js +127 -127
- package/dist/lib/errors/CastError.d.ts +4 -4
- package/dist/lib/errors/CastError.js +10 -10
- package/dist/lib/events/CameraEvent.d.ts +16 -16
- package/dist/lib/events/CameraEvent.js +30 -30
- package/dist/lib/events/FocusEvent.d.ts +42 -42
- package/dist/lib/events/FocusEvent.js +43 -43
- package/dist/lib/events/KeyboardEvent.d.ts +21 -21
- package/dist/lib/events/KeyboardEvent.js +43 -43
- package/dist/lib/events/MouseEvent.d.ts +91 -184
- package/dist/lib/events/MouseEvent.d.ts.map +1 -1
- package/dist/lib/events/MouseEvent.js +122 -191
- package/dist/lib/events/PointerEvent.d.ts +94 -0
- package/dist/lib/events/PointerEvent.d.ts.map +1 -0
- package/dist/lib/events/PointerEvent.js +73 -0
- package/dist/lib/events/ResizeEvent.d.ts +15 -15
- package/dist/lib/events/ResizeEvent.js +38 -38
- package/dist/lib/events/TextfieldEvent.d.ts +19 -19
- package/dist/lib/events/TextfieldEvent.js +28 -28
- package/dist/lib/events/TouchEvent.d.ts +51 -0
- package/dist/lib/events/TouchEvent.d.ts.map +1 -0
- package/dist/lib/events/TouchEvent.js +83 -0
- package/dist/lib/factories/DefaultSceneGraphFactory.d.ts +26 -26
- package/dist/lib/factories/DefaultSceneGraphFactory.js +54 -54
- package/dist/lib/factories/ISceneGraphFactory.d.ts +20 -20
- package/dist/lib/factories/ISceneGraphFactory.js +1 -1
- package/dist/lib/image/SceneImage2D.d.ts +236 -236
- package/dist/lib/image/SceneImage2D.js +687 -687
- package/dist/lib/managers/DefaultFontManager.d.ts +14 -14
- package/dist/lib/managers/DefaultFontManager.js +101 -101
- package/dist/lib/managers/DeviceFontManager.d.ts +8 -8
- package/dist/lib/managers/DeviceFontManager.js +44 -44
- package/dist/lib/managers/FrameScriptManager.d.ts +36 -36
- package/dist/lib/managers/FrameScriptManager.js +377 -377
- package/dist/lib/managers/IInputRecorder.d.ts +3 -3
- package/dist/lib/managers/IInputRecorder.js +1 -1
- package/dist/lib/managers/MouseManager.d.ts +76 -89
- package/dist/lib/managers/MouseManager.d.ts.map +1 -1
- package/dist/lib/managers/MouseManager.js +809 -761
- package/dist/lib/prefabs/PrefabBase.d.ts +19 -19
- package/dist/lib/prefabs/PrefabBase.js +42 -42
- package/dist/lib/prefabs/PrimitiveCapsulePrefab.d.ts +56 -56
- package/dist/lib/prefabs/PrimitiveCapsulePrefab.js +269 -269
- package/dist/lib/prefabs/PrimitiveConePrefab.d.ts +21 -21
- package/dist/lib/prefabs/PrimitiveConePrefab.js +43 -43
- package/dist/lib/prefabs/PrimitiveCubePrefab.d.ts +74 -74
- package/dist/lib/prefabs/PrimitiveCubePrefab.js +545 -545
- package/dist/lib/prefabs/PrimitiveCylinderPrefab.d.ts +79 -79
- package/dist/lib/prefabs/PrimitiveCylinderPrefab.js +584 -584
- package/dist/lib/prefabs/PrimitivePlanePrefab.d.ts +65 -65
- package/dist/lib/prefabs/PrimitivePlanePrefab.js +300 -300
- package/dist/lib/prefabs/PrimitivePolygonPrefab.d.ts +29 -29
- package/dist/lib/prefabs/PrimitivePolygonPrefab.js +64 -64
- package/dist/lib/prefabs/PrimitivePrefabBase.d.ts +67 -67
- package/dist/lib/prefabs/PrimitivePrefabBase.js +158 -158
- package/dist/lib/prefabs/PrimitiveSpherePrefab.d.ts +48 -48
- package/dist/lib/prefabs/PrimitiveSpherePrefab.js +294 -294
- package/dist/lib/prefabs/PrimitiveTorusPrefab.d.ts +55 -55
- package/dist/lib/prefabs/PrimitiveTorusPrefab.js +260 -260
- package/dist/lib/text/AntiAliasType.d.ts +24 -24
- package/dist/lib/text/AntiAliasType.js +28 -28
- package/dist/lib/text/BitmapFontChar.d.ts +39 -39
- package/dist/lib/text/BitmapFontChar.js +42 -42
- package/dist/lib/text/BitmapFontTable.d.ts +80 -80
- package/dist/lib/text/BitmapFontTable.js +203 -203
- package/dist/lib/text/FNTGenerator.d.ts +10 -10
- package/dist/lib/text/FNTGenerator.js +74 -74
- package/dist/lib/text/FNTGeneratorCanvas.d.ts +22 -22
- package/dist/lib/text/FNTGeneratorCanvas.js +205 -205
- package/dist/lib/text/FNTGeneratrorBase.d.ts +7 -7
- package/dist/lib/text/FNTGeneratrorBase.js +7 -7
- package/dist/lib/text/Font.d.ts +38 -38
- package/dist/lib/text/Font.js +109 -109
- package/dist/lib/text/FontLookUpMode.d.ts +5 -5
- package/dist/lib/text/FontLookUpMode.js +7 -7
- package/dist/lib/text/FontStyleName.d.ts +6 -6
- package/dist/lib/text/FontStyleName.js +7 -7
- package/dist/lib/text/GridFitType.d.ts +31 -31
- package/dist/lib/text/GridFitType.js +35 -35
- package/dist/lib/text/HTMLTextProcessor.d.ts +8 -8
- package/dist/lib/text/HTMLTextProcessor.js +423 -423
- package/dist/lib/text/IFontTable.d.ts +16 -16
- package/dist/lib/text/IFontTable.js +1 -1
- package/dist/lib/text/TesselatedFontChar.d.ts +58 -58
- package/dist/lib/text/TesselatedFontChar.js +66 -66
- package/dist/lib/text/TesselatedFontTable.d.ts +95 -95
- package/dist/lib/text/TesselatedFontTable.js +992 -992
- package/dist/lib/text/TextFieldAutoSize.d.ts +28 -28
- package/dist/lib/text/TextFieldAutoSize.js +32 -32
- package/dist/lib/text/TextFieldType.d.ts +20 -20
- package/dist/lib/text/TextFieldType.js +24 -24
- package/dist/lib/text/TextFormat.d.ts +273 -273
- package/dist/lib/text/TextFormat.js +440 -440
- package/dist/lib/text/TextFormatAlign.d.ts +26 -26
- package/dist/lib/text/TextFormatAlign.js +30 -30
- package/dist/lib/text/TextInteractionMode.d.ts +21 -21
- package/dist/lib/text/TextInteractionMode.js +25 -25
- package/dist/lib/text/TextLineMetrics.d.ts +61 -61
- package/dist/lib/text/TextLineMetrics.js +42 -42
- package/dist/lib/text/TextShape.d.ts +20 -20
- package/dist/lib/text/TextShape.js +75 -75
- package/dist/lib/tools/Merge.d.ts +81 -81
- package/dist/lib/tools/Merge.js +266 -266
- package/dist/lib/utils/Cast.d.ts +20 -20
- package/dist/lib/utils/Cast.js +271 -271
- package/index.ts +92 -91
- package/lib/Scene.ts +343 -343
- package/lib/Settings.ts +83 -83
- package/lib/adapters/IDisplayObjectAdapter.ts +23 -23
- package/lib/adapters/IFilter.ts +25 -25
- package/lib/adapters/IMovieClipAdapter.ts +24 -24
- package/lib/adapters/ITextfieldAdapter.ts +6 -6
- package/lib/base/IBitmapDrawable.ts +13 -13
- package/lib/base/IFrameLabel.ts +3 -3
- package/lib/base/IFrameScript.ts +4 -4
- package/lib/base/MouseButtons.ts +31 -26
- package/lib/base/Timeline.ts +727 -727
- package/lib/base/TimelineActionType.ts +18 -18
- package/lib/controllers/ControllerBase.ts +66 -66
- package/lib/controllers/FirstPersonController.ts +241 -241
- package/lib/controllers/FollowController.ts +22 -22
- package/lib/controllers/HoverController.ts +304 -304
- package/lib/controllers/LookAtController.ts +75 -75
- package/lib/controllers/SpringController.ts +91 -91
- package/lib/display/Billboard.ts +504 -504
- package/lib/display/Camera.ts +89 -89
- package/lib/display/DisplayObject.ts +1893 -1893
- package/lib/display/DisplayObjectContainer.ts +538 -538
- package/lib/display/LineSegment.ts +248 -248
- package/lib/display/LoaderContainer.ts +651 -651
- package/lib/display/MorphSprite.ts +347 -347
- package/lib/display/MovieClip.ts +879 -879
- package/lib/display/SimpleButton.ts +224 -224
- package/lib/display/Skybox.ts +379 -379
- package/lib/display/Sprite.ts +165 -165
- package/lib/display/TextField.ts +3958 -3958
- package/lib/display/TextSprite.ts +22 -22
- package/lib/elements/SkyboxElements.ts +141 -141
- package/lib/errors/CastError.ts +6 -6
- package/lib/events/CameraEvent.ts +29 -29
- package/lib/events/FocusEvent.ts +69 -69
- package/lib/events/KeyboardEvent.ts +40 -40
- package/lib/events/MouseEvent.ts +147 -287
- package/lib/events/PointerEvent.ts +146 -0
- package/lib/events/ResizeEvent.ts +31 -31
- package/lib/events/TextfieldEvent.ts +28 -28
- package/lib/events/TouchEvent.ts +101 -0
- package/lib/factories/DefaultSceneGraphFactory.ts +56 -56
- package/lib/factories/ISceneGraphFactory.ts +28 -28
- package/lib/image/SceneImage2D.ts +1020 -1020
- package/lib/managers/DefaultFontManager.ts +124 -124
- package/lib/managers/DeviceFontManager.ts +55 -55
- package/lib/managers/FrameScriptManager.ts +431 -431
- package/lib/managers/IInputRecorder.ts +2 -2
- package/lib/managers/MouseManager.ts +944 -884
- package/lib/prefabs/PrefabBase.ts +47 -47
- package/lib/prefabs/PrimitiveCapsulePrefab.ts +286 -286
- package/lib/prefabs/PrimitiveConePrefab.ts +37 -37
- package/lib/prefabs/PrimitiveCubePrefab.ts +630 -630
- package/lib/prefabs/PrimitiveCylinderPrefab.ts +657 -657
- package/lib/prefabs/PrimitivePlanePrefab.ts +352 -352
- package/lib/prefabs/PrimitivePolygonPrefab.ts +53 -53
- package/lib/prefabs/PrimitivePrefabBase.ts +177 -177
- package/lib/prefabs/PrimitiveSpherePrefab.ts +336 -336
- package/lib/prefabs/PrimitiveTorusPrefab.ts +282 -282
- package/lib/text/AntiAliasType.ts +24 -24
- package/lib/text/BitmapFontChar.ts +53 -53
- package/lib/text/BitmapFontTable.ts +232 -232
- package/lib/text/FNTGenerator.ts +100 -100
- package/lib/text/FNTGeneratorCanvas.ts +287 -287
- package/lib/text/FNTGeneratrorBase.ts +10 -10
- package/lib/text/Font.ts +114 -114
- package/lib/text/FontLookUpMode.ts +5 -5
- package/lib/text/FontStyleName.ts +6 -6
- package/lib/text/GridFitType.ts +32 -32
- package/lib/text/HTMLTextProcessor.ts +418 -418
- package/lib/text/IFontTable.ts +17 -17
- package/lib/text/TesselatedFontChar.ts +80 -80
- package/lib/text/TesselatedFontTable.ts +1221 -1221
- package/lib/text/TextFieldAutoSize.ts +30 -30
- package/lib/text/TextFieldType.ts +21 -21
- package/lib/text/TextFormat.ts +601 -601
- package/lib/text/TextFormatAlign.ts +28 -28
- package/lib/text/TextInteractionMode.ts +21 -21
- package/lib/text/TextLineMetrics.ts +74 -74
- package/lib/text/TextShape.ts +90 -90
- package/lib/tools/Merge.ts +311 -311
- package/lib/utils/Cast.ts +304 -304
- package/package.json +74 -74
- package/rollup.config.js +33 -33
- package/scripts/build.sh +2 -2
- package/scripts/gendocs.sh +14 -14
- package/scripts/genexamples.sh +14 -14
- package/scripts/genfull.sh +14 -14
- package/system.config.js +51 -51
- package/tsconfig.json +18 -18
|
@@ -1,761 +1,809 @@
|
|
|
1
|
-
import { Vector3D } from '@awayjs/core';
|
|
2
|
-
import { FocusEvent } from '../events/FocusEvent';
|
|
3
|
-
import { KeyboardEvent } from '../events/KeyboardEvent';
|
|
4
|
-
import { MouseEvent as AwayMouseEvent } from '../events/MouseEvent';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
79
|
-
MouseManager.prototype
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
173
|
-
MouseManager.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
MouseManager.prototype.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
var
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (!
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
this.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
//
|
|
260
|
-
if (this.
|
|
261
|
-
this.
|
|
262
|
-
this
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
this._stage.dispatchEvent(event);
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
this.
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
this.setupAndDispatchEvent(this.
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
this.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
this.
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if (prevCollisionNode) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
//
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
if (
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
event.
|
|
592
|
-
event.
|
|
593
|
-
|
|
594
|
-
event.
|
|
595
|
-
|
|
596
|
-
event.
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
//
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
this.
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
this.queueDispatch(
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
1
|
+
import { Vector3D } from '@awayjs/core';
|
|
2
|
+
import { FocusEvent } from '../events/FocusEvent';
|
|
3
|
+
import { KeyboardEvent } from '../events/KeyboardEvent';
|
|
4
|
+
import { MouseEvent as AwayMouseEvent } from '../events/MouseEvent';
|
|
5
|
+
import { TouchEvent as AwayTouchEvent } from '../events/TouchEvent';
|
|
6
|
+
/**
|
|
7
|
+
* MouseManager enforces a singleton pattern and is not intended to be instanced.
|
|
8
|
+
* it provides a manager class for detecting mouse hits on scene objects and sending out mouse events.
|
|
9
|
+
*/
|
|
10
|
+
var MouseManager = /** @class */ (function () {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new <code>MouseManager</code> object.
|
|
13
|
+
*/
|
|
14
|
+
function MouseManager(stage) {
|
|
15
|
+
this._pickerLookup = new Array();
|
|
16
|
+
this._pointerDataArray = {};
|
|
17
|
+
this.allowKeyInput = true;
|
|
18
|
+
this._eventBubbling = true; // should events bubble up
|
|
19
|
+
this._allowFocusOnUnfocusable = true; // should unfocus-able object steal focus ?
|
|
20
|
+
this._cursorType = 'auto';
|
|
21
|
+
this._nullVector = new Vector3D();
|
|
22
|
+
this._dragOut = new AwayMouseEvent(AwayMouseEvent.DRAG_OUT);
|
|
23
|
+
this._dragOver = new AwayMouseEvent(AwayMouseEvent.DRAG_OVER);
|
|
24
|
+
this._dragMove = new AwayMouseEvent(AwayMouseEvent.DRAG_MOVE);
|
|
25
|
+
this._dragStart = new AwayMouseEvent(AwayMouseEvent.DRAG_START);
|
|
26
|
+
this._dragStop = new AwayMouseEvent(AwayMouseEvent.DRAG_STOP);
|
|
27
|
+
this._focusIn = new FocusEvent(FocusEvent.FOCUS_IN);
|
|
28
|
+
this._focusOut = new FocusEvent(FocusEvent.FOCUS_OUT);
|
|
29
|
+
this._useSoftkeyboard = false;
|
|
30
|
+
this._isAVM1Dragging = false;
|
|
31
|
+
this._stage = stage;
|
|
32
|
+
this.onDoubleClick = this.onDoubleClick.bind(this);
|
|
33
|
+
this.onMouseDown = this.onMouseDown.bind(this);
|
|
34
|
+
this.onMouseMove = this.onMouseMove.bind(this);
|
|
35
|
+
this.onMouseUp = this.onMouseUp.bind(this);
|
|
36
|
+
this.onMouseWheel = this.onMouseWheel.bind(this);
|
|
37
|
+
this.onMouseOver = this.onMouseOver.bind(this);
|
|
38
|
+
this.onMouseOut = this.onMouseOut.bind(this);
|
|
39
|
+
this.onKeyDown = this.onKeyDown.bind(this);
|
|
40
|
+
this.onKeyUp = this.onKeyUp.bind(this);
|
|
41
|
+
this._showCursor = true;
|
|
42
|
+
this._mouseDragging = false;
|
|
43
|
+
//register stage
|
|
44
|
+
var container = this._stage.container;
|
|
45
|
+
container.addEventListener('touchstart', this.onMouseDown);
|
|
46
|
+
container.addEventListener('mousedown', this.onMouseDown);
|
|
47
|
+
window.addEventListener('touchmove', this.onMouseMove);
|
|
48
|
+
window.addEventListener('mousemove', this.onMouseMove);
|
|
49
|
+
window.addEventListener('mouseup', this.onMouseUp);
|
|
50
|
+
container.addEventListener('touchend', this.onMouseUp);
|
|
51
|
+
container.addEventListener('mousewheel', this.onMouseWheel);
|
|
52
|
+
container.addEventListener('mouseover', this.onMouseOver);
|
|
53
|
+
container.addEventListener('mouseout', this.onMouseOut);
|
|
54
|
+
window.addEventListener('keydown', this.onKeyDown);
|
|
55
|
+
window.addEventListener('keyup', this.onKeyUp);
|
|
56
|
+
// supress context menu
|
|
57
|
+
container.addEventListener('contextmenu', function (e) { return e.preventDefault(); });
|
|
58
|
+
}
|
|
59
|
+
MouseManager.prototype.startDragObject = function (collision) {
|
|
60
|
+
this._isAVM1Dragging = true;
|
|
61
|
+
// we MUST overrider collision target if present, because draggable !== drag emitter
|
|
62
|
+
if (collision)
|
|
63
|
+
this._mouseDragCollision = collision;
|
|
64
|
+
};
|
|
65
|
+
MouseManager.prototype.stopDragObject = function () {
|
|
66
|
+
this._isAVM1Dragging = false;
|
|
67
|
+
};
|
|
68
|
+
Object.defineProperty(MouseManager.prototype, "showCursor", {
|
|
69
|
+
get: function () {
|
|
70
|
+
return this._showCursor;
|
|
71
|
+
},
|
|
72
|
+
set: function (value) {
|
|
73
|
+
this._showCursor = value;
|
|
74
|
+
this.cursorType = this._cursorType;
|
|
75
|
+
},
|
|
76
|
+
enumerable: false,
|
|
77
|
+
configurable: true
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(MouseManager.prototype, "cursorType", {
|
|
80
|
+
get: function () {
|
|
81
|
+
return this._cursorType;
|
|
82
|
+
},
|
|
83
|
+
set: function (t) {
|
|
84
|
+
this._cursorType = t;
|
|
85
|
+
this._stage.container.style.cursor = this._showCursor ? t : 'none';
|
|
86
|
+
},
|
|
87
|
+
enumerable: false,
|
|
88
|
+
configurable: true
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(MouseManager.prototype, "eventBubbling", {
|
|
91
|
+
get: function () {
|
|
92
|
+
return this._eventBubbling;
|
|
93
|
+
},
|
|
94
|
+
set: function (value) {
|
|
95
|
+
this._eventBubbling = value;
|
|
96
|
+
},
|
|
97
|
+
enumerable: false,
|
|
98
|
+
configurable: true
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(MouseManager.prototype, "useSoftkeyboard", {
|
|
101
|
+
get: function () {
|
|
102
|
+
return this._useSoftkeyboard;
|
|
103
|
+
},
|
|
104
|
+
set: function (value) {
|
|
105
|
+
this._useSoftkeyboard = value;
|
|
106
|
+
// todo: improve this, so that we can
|
|
107
|
+
// - use device-softkeyboard on tablet / mobide
|
|
108
|
+
// - optionally use a custom softkeyboard
|
|
109
|
+
if (!value) {
|
|
110
|
+
window.addEventListener('keydown', this.onKeyDown);
|
|
111
|
+
window.addEventListener('keyup', this.onKeyUp);
|
|
112
|
+
}
|
|
113
|
+
else if (value) {
|
|
114
|
+
window.removeEventListener('keydown', this.onKeyDown);
|
|
115
|
+
window.removeEventListener('keyup', this.onKeyUp);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
enumerable: false,
|
|
119
|
+
configurable: true
|
|
120
|
+
});
|
|
121
|
+
MouseManager.prototype.dispose = function () {
|
|
122
|
+
//unregister stage
|
|
123
|
+
var container = this._stage.container;
|
|
124
|
+
container.removeEventListener('dblclick', this.onDoubleClick);
|
|
125
|
+
container.removeEventListener('touchstart', this.onMouseDown);
|
|
126
|
+
container.removeEventListener('mousedown', this.onMouseDown);
|
|
127
|
+
window.removeEventListener('touchmove', this.onMouseMove);
|
|
128
|
+
window.removeEventListener('mousemove', this.onMouseMove);
|
|
129
|
+
window.removeEventListener('mouseup', this.onMouseUp);
|
|
130
|
+
container.removeEventListener('touchend', this.onMouseUp);
|
|
131
|
+
container.removeEventListener('wheel', this.onMouseWheel);
|
|
132
|
+
container.removeEventListener('mouseover', this.onMouseOver);
|
|
133
|
+
container.removeEventListener('mouseout', this.onMouseOut);
|
|
134
|
+
window.removeEventListener('keydown', this.onKeyDown);
|
|
135
|
+
window.removeEventListener('keyup', this.onKeyUp);
|
|
136
|
+
this._stage = null;
|
|
137
|
+
this._dragOut = null;
|
|
138
|
+
this._dragOver = null;
|
|
139
|
+
this._dragMove = null;
|
|
140
|
+
this._dragStart = null;
|
|
141
|
+
this._dragStop = null;
|
|
142
|
+
};
|
|
143
|
+
MouseManager.clearInstance = function (stage) {
|
|
144
|
+
if (this._instancePool[stage.id]) {
|
|
145
|
+
this._instancePool[stage.id].dispose();
|
|
146
|
+
delete this._instancePool[stage.id];
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
MouseManager.getInstance = function (stage) {
|
|
150
|
+
return this._instancePool[stage.id]
|
|
151
|
+
|| (this._instancePool[stage.id] = new MouseManager(stage));
|
|
152
|
+
};
|
|
153
|
+
MouseManager.prototype.setFocus = function (node) {
|
|
154
|
+
if (this._focusNode == node)
|
|
155
|
+
return;
|
|
156
|
+
// in FP6, a mouseclick on non focus-able object still steal the focus
|
|
157
|
+
// in newer FP they only steal the focus if the the new hit is focusable
|
|
158
|
+
if (this._allowFocusOnUnfocusable || this._focusNode.container.tabEnabled) {
|
|
159
|
+
if (this._focusNode) {
|
|
160
|
+
this.dispatchEvent(this._focusOut, this._focusNode);
|
|
161
|
+
this._focusNode.container.setFocus(false, true);
|
|
162
|
+
}
|
|
163
|
+
this._focusNode = node;
|
|
164
|
+
if (this._focusNode) {
|
|
165
|
+
this.dispatchEvent(this._focusIn, this._focusNode);
|
|
166
|
+
this._focusNode.container.setFocus(true, true);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
MouseManager.prototype.getFocus = function () {
|
|
171
|
+
return this._focusNode;
|
|
172
|
+
};
|
|
173
|
+
MouseManager.prototype.dispatchEvent = function (event, dispatcher) {
|
|
174
|
+
if (!this._eventBubbling) {
|
|
175
|
+
if (dispatcher) {
|
|
176
|
+
event._dispatchEvent(dispatcher, dispatcher.container);
|
|
177
|
+
}
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
var target = dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.container;
|
|
181
|
+
while (dispatcher) {
|
|
182
|
+
if (event.commonAncestor && dispatcher == event.commonAncestor) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
event._dispatchEvent(dispatcher, target);
|
|
186
|
+
if (!event._iAllowedToPropagate) {
|
|
187
|
+
dispatcher = null;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
dispatcher = dispatcher.parent;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
MouseManager.prototype.setupAndDispatchEvent = function (event, sourceEvent, collision, commonAncestor) {
|
|
195
|
+
if (commonAncestor === void 0) { commonAncestor = null; }
|
|
196
|
+
if (sourceEvent) {
|
|
197
|
+
if (event instanceof AwayMouseEvent) {
|
|
198
|
+
event.delta = sourceEvent.wheelDelta;
|
|
199
|
+
event.buttons = sourceEvent.buttons;
|
|
200
|
+
}
|
|
201
|
+
event.ctrlKey = sourceEvent.ctrlKey;
|
|
202
|
+
event.altKey = sourceEvent.altKey;
|
|
203
|
+
event.shiftKey = sourceEvent.shiftKey;
|
|
204
|
+
}
|
|
205
|
+
event = this.setUpEvent(event, collision, commonAncestor);
|
|
206
|
+
this.dispatchEvent(event, event.rootNode);
|
|
207
|
+
};
|
|
208
|
+
MouseManager.prototype.fireMouseEvents = function (forcePicker) {
|
|
209
|
+
if (forcePicker === void 0) { forcePicker = null; }
|
|
210
|
+
//if theres nothing to update, return
|
|
211
|
+
if (!forcePicker && !this._updateDirty)
|
|
212
|
+
return;
|
|
213
|
+
for (var key in this._pointerDataArray) {
|
|
214
|
+
this._fireMouseEventsInternal(this._pointerDataArray[key], forcePicker);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
MouseManager.prototype._fireMouseEventsInternal = function (pointerData, forcePicker) {
|
|
218
|
+
var _a, _b;
|
|
219
|
+
if (forcePicker === void 0) { forcePicker = null; }
|
|
220
|
+
var collision;
|
|
221
|
+
if (forcePicker) {
|
|
222
|
+
collision = forcePicker.getViewCollision(pointerData.screenX, pointerData.screenY);
|
|
223
|
+
}
|
|
224
|
+
else if (this._updateDirty) {
|
|
225
|
+
for (var i = 0; i < this._pickerLookup.length; i++)
|
|
226
|
+
if (!collision || this._pickerLookup[i].layeredView)
|
|
227
|
+
collision = this._pickerLookup[i].getViewCollision(pointerData.screenX, pointerData.screenY, false, collision);
|
|
228
|
+
}
|
|
229
|
+
var event;
|
|
230
|
+
var dispatcher;
|
|
231
|
+
var len = pointerData.queuedEvents.length;
|
|
232
|
+
for (var i = 0; i < len; ++i) {
|
|
233
|
+
event = pointerData.queuedEvents[i];
|
|
234
|
+
dispatcher = collision === null || collision === void 0 ? void 0 : collision.rootNode;
|
|
235
|
+
this.setUpEvent(event, collision);
|
|
236
|
+
if (event.type == pointerData.down.type) {
|
|
237
|
+
this._mouseDragging = true;
|
|
238
|
+
// no event-bubbling. dispatch on stage first
|
|
239
|
+
if (!this._eventBubbling)
|
|
240
|
+
this._stage.dispatchEvent(event);
|
|
241
|
+
// @todo: at this point the object under the mouse might have been changed,
|
|
242
|
+
// so we need to recheck the collision ?
|
|
243
|
+
// on Touch dispatch mouseOver Command
|
|
244
|
+
if (!pointerData.isMouse)
|
|
245
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData.sourceEvent, collision);
|
|
246
|
+
this._mouseDragCollision = collision;
|
|
247
|
+
if (dispatcher) {
|
|
248
|
+
//console.log("onPress", dispatcher)
|
|
249
|
+
this.dispatchEvent(event, dispatcher);
|
|
250
|
+
}
|
|
251
|
+
else if (this._eventBubbling)
|
|
252
|
+
this._stage.dispatchEvent(event);
|
|
253
|
+
if (this._mouseDragCollision) {
|
|
254
|
+
this.setFocus((_a = this._mouseDragCollision) === null || _a === void 0 ? void 0 : _a.rootNode);
|
|
255
|
+
this.setupAndDispatchEvent(this._dragStart, event, this._mouseDragCollision);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else if (event.type == pointerData.up.type) {
|
|
259
|
+
// no event-bubbling. dispatch on stage first
|
|
260
|
+
if (!this._eventBubbling)
|
|
261
|
+
this._stage.dispatchEvent(event);
|
|
262
|
+
// @todo: at this point the object under the mouse might have been changed,
|
|
263
|
+
// so we need to recheck the collision ?
|
|
264
|
+
var upContainerNode = null;
|
|
265
|
+
var upRootNode = null;
|
|
266
|
+
if (this._isAVM1Dragging && this._mouseDragCollision) {
|
|
267
|
+
// avm1dragging is in process, dispatch the mouse-up on this.
|
|
268
|
+
// mouseDragEntity instead of the current collision
|
|
269
|
+
upRootNode = this._mouseDragCollision.rootNode;
|
|
270
|
+
upContainerNode = this._mouseDragCollision.containerNode;
|
|
271
|
+
}
|
|
272
|
+
else if (this._mouseDragging && this._mouseDragCollision
|
|
273
|
+
&& this._mouseDragCollision.rootNode != dispatcher) {
|
|
274
|
+
// no avm1dragging is in process, but current collision
|
|
275
|
+
// is not the same as collision that appeared on mouse-down,
|
|
276
|
+
// need to dispatch a MOUSE_UP_OUTSIDE after mouse up
|
|
277
|
+
}
|
|
278
|
+
else if (this._mouseDragging && this._mouseDragCollision
|
|
279
|
+
&& this._mouseDragCollision.rootNode == dispatcher) {
|
|
280
|
+
// no avm1dragging is in process,
|
|
281
|
+
// current collision is the same as collision that appeared on
|
|
282
|
+
// mouse-down, need to dispatch a MOUSE_CLICK event after mouse up
|
|
283
|
+
upRootNode = this._mouseDragCollision.rootNode;
|
|
284
|
+
upContainerNode = this._mouseDragCollision.containerNode;
|
|
285
|
+
}
|
|
286
|
+
if (upRootNode) {
|
|
287
|
+
//console.log("onRelease", upRootNode)
|
|
288
|
+
this.dispatchEvent(event, upRootNode);
|
|
289
|
+
}
|
|
290
|
+
else if (this._eventBubbling && dispatcher)
|
|
291
|
+
this.dispatchEvent(event, dispatcher);
|
|
292
|
+
else if (this._eventBubbling)
|
|
293
|
+
this._stage.dispatchEvent(event);
|
|
294
|
+
if (upContainerNode) {
|
|
295
|
+
if (!this._isAVM1Dragging)
|
|
296
|
+
this.setupAndDispatchEvent(pointerData.click, pointerData.isMouse ? event : pointerData.sourceEvent, this._mouseDragCollision);
|
|
297
|
+
this.setupAndDispatchEvent(this._dragStop, event, this._mouseDragCollision);
|
|
298
|
+
}
|
|
299
|
+
else if (this._mouseDragging && this._mouseDragCollision) {
|
|
300
|
+
this.setupAndDispatchEvent(pointerData.upOutside, event, this._mouseDragCollision);
|
|
301
|
+
}
|
|
302
|
+
this._mouseDragCollision = null;
|
|
303
|
+
this._mouseDragging = false;
|
|
304
|
+
this._isAVM1Dragging = false;
|
|
305
|
+
}
|
|
306
|
+
else if (event.type == pointerData.move.type) {
|
|
307
|
+
// no event-bubbling. dispatch on stage first
|
|
308
|
+
if (!this._eventBubbling) {
|
|
309
|
+
this._stage.dispatchEvent(event);
|
|
310
|
+
}
|
|
311
|
+
// fire to picker
|
|
312
|
+
if (event.rootNode) {
|
|
313
|
+
this.dispatchEvent(event, event.rootNode);
|
|
314
|
+
}
|
|
315
|
+
if (this._mouseDragCollision) {
|
|
316
|
+
this.setupAndDispatchEvent(this._dragMove, event, this._mouseDragCollision);
|
|
317
|
+
}
|
|
318
|
+
// if bubling is exist, fire to stage late
|
|
319
|
+
if (this._eventBubbling) {
|
|
320
|
+
this._stage.dispatchEvent(event);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
// MouseEvent.MOUSE_OVER / MouseEvent.MOUSE_OUT / MouseEvent.DRAG_OVER / MouseEvent.DRAG_OUT
|
|
325
|
+
this.dispatchEvent(event, dispatcher);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
pointerData.queuedEvents.length = 0;
|
|
329
|
+
pointerData.rollOut.commonAncestor = null;
|
|
330
|
+
pointerData.rollOver.commonAncestor = null;
|
|
331
|
+
var collisionNode = collision === null || collision === void 0 ? void 0 : collision.rootNode;
|
|
332
|
+
var prevCollisionNode = (_b = pointerData.prevCollision) === null || _b === void 0 ? void 0 : _b.rootNode;
|
|
333
|
+
if (collisionNode != prevCollisionNode) {
|
|
334
|
+
// If colliding object has changed, queue OVER and OUT events.
|
|
335
|
+
// If the mouse is dragged (mouse-down is hold), use DRAG_OVER and DRAG_OUT as well as MOUSE_OVER MOUSE_OUT
|
|
336
|
+
// DRAG_OVER and DRAG_OUT are only dispatched on the object that was hit on the mouse-down
|
|
337
|
+
// (_mouseDragEntity)
|
|
338
|
+
// Store the info if the collision is a enabled Button (_collisionIsEnabledButton)
|
|
339
|
+
if (prevCollisionNode) {
|
|
340
|
+
this.setupAndDispatchEvent(pointerData.out, pointerData.sourceEvent, pointerData.prevCollision);
|
|
341
|
+
if (this._mouseDragging && this._mouseDragCollision
|
|
342
|
+
&& this._mouseDragCollision.rootNode == prevCollisionNode)
|
|
343
|
+
this.setupAndDispatchEvent(this._dragOut, pointerData.sourceEvent, pointerData.prevCollision);
|
|
344
|
+
}
|
|
345
|
+
if (!prevCollisionNode && collisionNode) {
|
|
346
|
+
// rollout / rollover easy case, can just bubble up
|
|
347
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData.sourceEvent, pointerData.prevCollision);
|
|
348
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData.sourceEvent, collision);
|
|
349
|
+
}
|
|
350
|
+
if (prevCollisionNode && !collisionNode) {
|
|
351
|
+
// rollout / rollover easy case, can just bubble up
|
|
352
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData.sourceEvent, pointerData.prevCollision);
|
|
353
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData.sourceEvent, collision);
|
|
354
|
+
}
|
|
355
|
+
if (prevCollisionNode && collisionNode) {
|
|
356
|
+
// rollout / rollover find common ancester and only bubble up to that point
|
|
357
|
+
var parentsPrev = [];
|
|
358
|
+
var parent_1 = prevCollisionNode;
|
|
359
|
+
while (parent_1 && !parent_1.container.isAVMScene) {
|
|
360
|
+
parentsPrev.push(parent_1);
|
|
361
|
+
parent_1 = parent_1.parent;
|
|
362
|
+
}
|
|
363
|
+
var commonAncestor = null;
|
|
364
|
+
parent_1 = collisionNode;
|
|
365
|
+
while (parent_1 && !parent_1.container.isAVMScene) {
|
|
366
|
+
var oldParentIdx = parentsPrev.indexOf(parent_1);
|
|
367
|
+
if (oldParentIdx == -1) {
|
|
368
|
+
parent_1 = parent_1.parent;
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
commonAncestor = parent_1;
|
|
372
|
+
parent_1 = null;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (commonAncestor != prevCollisionNode)
|
|
376
|
+
this.setupAndDispatchEvent(pointerData.rollOut, pointerData.sourceEvent, pointerData.prevCollision, commonAncestor);
|
|
377
|
+
if (commonAncestor != collisionNode)
|
|
378
|
+
this.setupAndDispatchEvent(pointerData.rollOver, pointerData.sourceEvent, collision, commonAncestor);
|
|
379
|
+
}
|
|
380
|
+
pointerData.collisionIsEnabledButton = collisionNode ? collisionNode.buttonEnabled : false;
|
|
381
|
+
if (collisionNode) {
|
|
382
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData.sourceEvent, collision);
|
|
383
|
+
if (this._mouseDragging)
|
|
384
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData.sourceEvent, collision);
|
|
385
|
+
}
|
|
386
|
+
pointerData.prevCollision = collision;
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
// colliding object has not changed
|
|
390
|
+
// Check if we need to send any MOUSE_OVER/DRAG_OVER event to handle the case
|
|
391
|
+
// when a Button has become active while under the mouse.
|
|
392
|
+
var isActiveButton = collisionNode ? collisionNode.buttonEnabled : false;
|
|
393
|
+
if (pointerData.collisionIsEnabledButton != isActiveButton && isActiveButton) {
|
|
394
|
+
if (pointerData.isMouse)
|
|
395
|
+
this.setupAndDispatchEvent(pointerData.over, pointerData.sourceEvent, collision);
|
|
396
|
+
else if (this._mouseDragCollision && this._mouseDragCollision.rootNode == collisionNode)
|
|
397
|
+
this.setupAndDispatchEvent(this._dragOver, pointerData.sourceEvent, collision);
|
|
398
|
+
}
|
|
399
|
+
pointerData.collisionIsEnabledButton = isActiveButton;
|
|
400
|
+
}
|
|
401
|
+
// set cursor if not dragging mouse ???
|
|
402
|
+
if (!this._mouseDragging) {
|
|
403
|
+
this.cursorType = collisionNode ? collisionNode.container.getMouseCursor() : 'auto';
|
|
404
|
+
}
|
|
405
|
+
this._updateDirty = false;
|
|
406
|
+
};
|
|
407
|
+
MouseManager.prototype.registerPicker = function (picker) {
|
|
408
|
+
this._pickerLookup.push(picker);
|
|
409
|
+
};
|
|
410
|
+
MouseManager.prototype.unregisterPicker = function (picker) {
|
|
411
|
+
this._pickerLookup.splice(this._pickerLookup.indexOf(picker), 1);
|
|
412
|
+
};
|
|
413
|
+
MouseManager.prototype.addEventsForSceneBinary = function (touchMessage, sceneIdx) {
|
|
414
|
+
if (sceneIdx === void 0) { sceneIdx = 0; }
|
|
415
|
+
var newTouchEvent = {};
|
|
416
|
+
newTouchEvent.clientX = null; // we get the x position from the active touch
|
|
417
|
+
newTouchEvent.clientY = null; // we get the y position from the active touch
|
|
418
|
+
newTouchEvent.touches = [];
|
|
419
|
+
newTouchEvent.changedTouches = [];
|
|
420
|
+
newTouchEvent.preventDefault = function () { };
|
|
421
|
+
var messageScene = new Float32Array(touchMessage);
|
|
422
|
+
// transfer touches to event
|
|
423
|
+
var i = 0;
|
|
424
|
+
var cnt = 0;
|
|
425
|
+
var touchCnt = 0;
|
|
426
|
+
cnt++; //we temporary added 1 float to transfer fps from java to js. skip this
|
|
427
|
+
var numTouches = messageScene[cnt++];
|
|
428
|
+
var touchtype = messageScene[cnt++];
|
|
429
|
+
var activeTouchID = messageScene[cnt++];
|
|
430
|
+
if ((touchtype != 1) && (touchtype != 6) && (touchtype != 12) && (touchtype != 262) && (touchtype != 518)) {
|
|
431
|
+
// if this is not a UP command, we add all touches
|
|
432
|
+
for (i = 0; i < numTouches; i++) {
|
|
433
|
+
var newTouch = {};
|
|
434
|
+
newTouch.identifier = messageScene[cnt++];
|
|
435
|
+
newTouch.clientX = messageScene[cnt++];
|
|
436
|
+
newTouch.clientY = messageScene[cnt++];
|
|
437
|
+
newTouchEvent.touches[i] = newTouch;
|
|
438
|
+
//newTouchEvent.changedTouches[i] = newTouch;
|
|
439
|
+
}
|
|
440
|
+
newTouchEvent.changedTouches[0] = newTouchEvent.touches[activeTouchID];
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
// if this is a UP command, we add all touches, except the active one
|
|
444
|
+
if (numTouches == 1) {
|
|
445
|
+
var newTouch = {};
|
|
446
|
+
newTouch.identifier = messageScene[cnt++];
|
|
447
|
+
newTouch.clientX = messageScene[cnt++];
|
|
448
|
+
newTouch.clientY = messageScene[cnt++];
|
|
449
|
+
newTouchEvent.clientX = newTouch.clientX;
|
|
450
|
+
newTouchEvent.clientY = newTouch.clientY;
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
for (i = 0; i < numTouches; i++) {
|
|
454
|
+
var newTouch = {};
|
|
455
|
+
newTouch.identifier = messageScene[cnt++];
|
|
456
|
+
newTouch.clientX = messageScene[cnt++];
|
|
457
|
+
newTouch.clientY = messageScene[cnt++];
|
|
458
|
+
if (i != activeTouchID) {
|
|
459
|
+
newTouchEvent.touches[touchCnt] = newTouch;
|
|
460
|
+
//newTouchEvent.changedTouches[touchCnt++] = newTouch;
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
newTouchEvent.clientX = newTouch.clientX;
|
|
464
|
+
newTouchEvent.clientY = newTouch.clientY;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
//console.log("Touch ID:"+touchtype+" activeTouchID "+activeTouchID+" numTouches "+numTouches+" x"+x+" y"+y);
|
|
470
|
+
/*
|
|
471
|
+
public static final int ACTION_DOWN = 0;
|
|
472
|
+
public static final int ACTION_POINTER_1_DOWN = 5;
|
|
473
|
+
public static final int ACTION_POINTER_DOWN = 5;
|
|
474
|
+
public static final int ACTION_BUTTON_PRESS = 11;
|
|
475
|
+
public static final int ACTION_POINTER_2_DOWN = 261;
|
|
476
|
+
public static final int ACTION_POINTER_3_DOWN = 517;
|
|
477
|
+
|
|
478
|
+
public static final int ACTION_UP = 1;
|
|
479
|
+
public static final int ACTION_POINTER_1_UP = 6;
|
|
480
|
+
public static final int ACTION_POINTER_UP = 6;
|
|
481
|
+
public static final int ACTION_BUTTON_RELEASE = 12;
|
|
482
|
+
public static final int ACTION_POINTER_2_UP = 262;
|
|
483
|
+
public static final int ACTION_POINTER_3_UP = 518;
|
|
484
|
+
|
|
485
|
+
public static final int ACTION_MOVE = 2;
|
|
486
|
+
|
|
487
|
+
*/
|
|
488
|
+
if ((touchtype == 0) || (touchtype == 5) || (touchtype == 11) || (touchtype == 261) || (touchtype == 517)) {
|
|
489
|
+
this.onMouseDown(newTouchEvent);
|
|
490
|
+
}
|
|
491
|
+
else if ((touchtype == 1) || (touchtype == 6)
|
|
492
|
+
|| (touchtype == 12) || (touchtype == 262) || (touchtype == 518)) {
|
|
493
|
+
this.onMouseUp(newTouchEvent);
|
|
494
|
+
}
|
|
495
|
+
else if (touchtype == 2) {
|
|
496
|
+
this.onMouseMove(newTouchEvent);
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
console.log('recieved unknown touch event-type: ' + touchtype);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
MouseManager.prototype.fireEventsForSceneFromString = function (touchMessage, _sceneIdx) {
|
|
503
|
+
if (_sceneIdx === void 0) { _sceneIdx = 0; }
|
|
504
|
+
var newTouchEvent = {};
|
|
505
|
+
newTouchEvent.clientX = null; // set the x position from the active touch
|
|
506
|
+
newTouchEvent.clientY = null; // set the y position from the active touch
|
|
507
|
+
newTouchEvent.preventDefault = function () { };
|
|
508
|
+
var touchesFromMessage = touchMessage.split(',');
|
|
509
|
+
// transfer touches to event
|
|
510
|
+
var i = 0;
|
|
511
|
+
var cnt = 0;
|
|
512
|
+
var numTouches = parseInt(touchesFromMessage[cnt++]);
|
|
513
|
+
var touchtype = parseInt(touchesFromMessage[cnt++]);
|
|
514
|
+
var activeTouch = parseInt(touchesFromMessage[cnt++]);
|
|
515
|
+
newTouchEvent.touches = [];
|
|
516
|
+
newTouchEvent.changedTouches = [];
|
|
517
|
+
if ((touchtype != 1) && (touchtype != 6)) {
|
|
518
|
+
for (i = 0; i < numTouches; i++) {
|
|
519
|
+
var newTouch = {};
|
|
520
|
+
newTouch.identifier = touchesFromMessage[cnt++];
|
|
521
|
+
newTouch.clientX = touchesFromMessage[cnt++];
|
|
522
|
+
newTouch.clientY = touchesFromMessage[cnt++];
|
|
523
|
+
newTouchEvent.touches[i] = newTouch;
|
|
524
|
+
newTouchEvent.changedTouches[i] = newTouch;
|
|
525
|
+
}
|
|
526
|
+
newTouchEvent.changedTouches[i] = newTouchEvent.touches[activeTouch];
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
for (i = 0; i < numTouches; i++) {
|
|
530
|
+
if (i != activeTouch) {
|
|
531
|
+
var newTouch = {};
|
|
532
|
+
newTouch.identifier = touchesFromMessage[cnt++];
|
|
533
|
+
newTouch.clientX = touchesFromMessage[cnt++];
|
|
534
|
+
newTouch.clientY = touchesFromMessage[cnt++];
|
|
535
|
+
newTouchEvent.touches[i] = newTouch;
|
|
536
|
+
newTouchEvent.changedTouches[i] = newTouch;
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
newTouchEvent.clientX = touchesFromMessage[cnt++];
|
|
540
|
+
newTouchEvent.clientY = touchesFromMessage[cnt++];
|
|
541
|
+
cnt++;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
if (touchtype == 0) { //mousedown
|
|
546
|
+
this.onMouseDown(newTouchEvent);
|
|
547
|
+
}
|
|
548
|
+
else if (touchtype == 1) { //mouseup
|
|
549
|
+
this.onMouseUp(newTouchEvent);
|
|
550
|
+
}
|
|
551
|
+
else if (touchtype == 2) { //mousemove
|
|
552
|
+
this.onMouseMove(newTouchEvent);
|
|
553
|
+
}
|
|
554
|
+
else if (touchtype == 261) { //mousedownPointer
|
|
555
|
+
this.onMouseDown(newTouchEvent);
|
|
556
|
+
}
|
|
557
|
+
else if (touchtype == 6) { //mouseupPointer
|
|
558
|
+
this.onMouseUp(newTouchEvent);
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
// ---------------------------------------------------------------------
|
|
562
|
+
// Private.
|
|
563
|
+
// ---------------------------------------------------------------------
|
|
564
|
+
MouseManager.prototype.setUpEvent = function (event, collision, commonAncestor) {
|
|
565
|
+
var _a, _b;
|
|
566
|
+
if (commonAncestor === void 0) { commonAncestor = null; }
|
|
567
|
+
event._iAllowedToImmediatlyPropagate = true;
|
|
568
|
+
event._iAllowedToPropagate = true;
|
|
569
|
+
// 2D properties.
|
|
570
|
+
event.screenX = this._stage.screenX;
|
|
571
|
+
event.screenY = this._stage.screenY;
|
|
572
|
+
//console.log("event", event, collisionNode, collisionNode);
|
|
573
|
+
// 3D properties.
|
|
574
|
+
if (collision) {
|
|
575
|
+
event.containerNode = collision.containerNode;
|
|
576
|
+
event.rootNode = collision.rootNode;
|
|
577
|
+
// Object.
|
|
578
|
+
event.traversable = collision.traversable;
|
|
579
|
+
// UV.
|
|
580
|
+
event.uv = collision.uv;
|
|
581
|
+
// Position.
|
|
582
|
+
event.position = (_a = collision.position) === null || _a === void 0 ? void 0 : _a.clone();
|
|
583
|
+
// Normal.
|
|
584
|
+
event.normal = (_b = collision.normal) === null || _b === void 0 ? void 0 : _b.clone();
|
|
585
|
+
// Face index.
|
|
586
|
+
event.elementIndex = collision.elementIndex;
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
// Set all to null.
|
|
590
|
+
event.containerNode = null;
|
|
591
|
+
event.rootNode = null;
|
|
592
|
+
event.traversable = null;
|
|
593
|
+
event.uv = null;
|
|
594
|
+
event.position = this._nullVector;
|
|
595
|
+
event.normal = this._nullVector;
|
|
596
|
+
event.elementIndex = 0;
|
|
597
|
+
}
|
|
598
|
+
event.commonAncestor = commonAncestor;
|
|
599
|
+
return event;
|
|
600
|
+
};
|
|
601
|
+
MouseManager.prototype.queueDispatch = function (pointerData, event, sourceEvent) {
|
|
602
|
+
// Store event to be dispatched later.
|
|
603
|
+
if (event instanceof AwayMouseEvent) {
|
|
604
|
+
event.delta = (sourceEvent instanceof WheelEvent) ? -3 * sourceEvent.deltaY / 100 : 0;
|
|
605
|
+
event.buttons = (sourceEvent instanceof MouseEvent) ? sourceEvent.buttons : 0 /* MouseButtons.NO_BUTTON */;
|
|
606
|
+
}
|
|
607
|
+
event.ctrlKey = sourceEvent.ctrlKey;
|
|
608
|
+
event.altKey = sourceEvent.altKey;
|
|
609
|
+
event.shiftKey = sourceEvent.shiftKey;
|
|
610
|
+
pointerData.queuedEvents.push(event);
|
|
611
|
+
pointerData.sourceEvent = sourceEvent;
|
|
612
|
+
};
|
|
613
|
+
// ---------------------------------------------------------------------
|
|
614
|
+
// Listeners.
|
|
615
|
+
// ---------------------------------------------------------------------
|
|
616
|
+
MouseManager.prototype.onKeyDown = function (event) {
|
|
617
|
+
!MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
|
|
618
|
+
//console.log("Keydown", event);
|
|
619
|
+
if (this.allowKeyInput) {
|
|
620
|
+
switch (event.keyCode) {
|
|
621
|
+
case 32: // spacebar
|
|
622
|
+
case 37: // left
|
|
623
|
+
case 39: // right
|
|
624
|
+
case 38: // up
|
|
625
|
+
case 40: // down
|
|
626
|
+
event.preventDefault();
|
|
627
|
+
break;
|
|
628
|
+
default:
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
if (this._focusNode || this._stage) {
|
|
632
|
+
//console.log("dispatch keydown on ", this._focusNode);
|
|
633
|
+
var newEvent = new KeyboardEvent(KeyboardEvent.KEYDOWN, event.key, event.code);
|
|
634
|
+
newEvent.isShift = event.shiftKey;
|
|
635
|
+
newEvent.isCTRL = event.ctrlKey;
|
|
636
|
+
newEvent.isAlt = event.altKey;
|
|
637
|
+
newEvent.keyCode = event.keyCode;
|
|
638
|
+
if (this._focusNode)
|
|
639
|
+
this._focusNode.container.dispatchEvent(newEvent);
|
|
640
|
+
if (this._stage)
|
|
641
|
+
this._stage.dispatchEvent(newEvent);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
MouseManager.prototype.onKeyUp = function (event) {
|
|
646
|
+
!MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
|
|
647
|
+
//console.log("Keyup", event);
|
|
648
|
+
if (this.allowKeyInput) {
|
|
649
|
+
switch (event.keyCode) {
|
|
650
|
+
case 32: // spacebar
|
|
651
|
+
case 37: // left
|
|
652
|
+
case 39: // right
|
|
653
|
+
case 38: // up
|
|
654
|
+
case 40: // down
|
|
655
|
+
event.preventDefault();
|
|
656
|
+
break;
|
|
657
|
+
default:
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
if (this._focusNode || this._stage) {
|
|
661
|
+
//console.log("dispatch keydown on ", this._focusNode);
|
|
662
|
+
var newEvent = new KeyboardEvent(KeyboardEvent.KEYUP, event.key, event.code);
|
|
663
|
+
newEvent.isShift = event.shiftKey;
|
|
664
|
+
newEvent.isCTRL = event.ctrlKey;
|
|
665
|
+
newEvent.isAlt = event.altKey;
|
|
666
|
+
newEvent.keyCode = event.keyCode;
|
|
667
|
+
if (this._focusNode)
|
|
668
|
+
this._focusNode.container.dispatchEvent(newEvent);
|
|
669
|
+
if (this._stage)
|
|
670
|
+
this._stage.dispatchEvent(newEvent);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
MouseManager.prototype.onMouseMove = function (event) {
|
|
675
|
+
!MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
|
|
676
|
+
this.updateColliders(event);
|
|
677
|
+
};
|
|
678
|
+
MouseManager.prototype.onMouseOut = function (event) {
|
|
679
|
+
!MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
|
|
680
|
+
this.updateColliders(event);
|
|
681
|
+
};
|
|
682
|
+
MouseManager.prototype.onMouseOver = function (event) {
|
|
683
|
+
!MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
|
|
684
|
+
this.updateColliders(event);
|
|
685
|
+
};
|
|
686
|
+
MouseManager.prototype.onDoubleClick = function (event) {
|
|
687
|
+
!MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
|
|
688
|
+
this.updateColliders(event);
|
|
689
|
+
// prevent middle and second button
|
|
690
|
+
if (event instanceof MouseEvent && event.buttons & 6) {
|
|
691
|
+
event.preventDefault();
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
MouseManager.prototype.onMouseDown = function (event) {
|
|
695
|
+
!MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
|
|
696
|
+
this.updateColliders(event);
|
|
697
|
+
var prevent = (event.type !== 'mousedown');
|
|
698
|
+
// prevent middle and second button
|
|
699
|
+
if (event instanceof MouseEvent && event.buttons & 6) {
|
|
700
|
+
prevent = true;
|
|
701
|
+
}
|
|
702
|
+
if (prevent) {
|
|
703
|
+
event.preventDefault();
|
|
704
|
+
this._stage.container.focus();
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
MouseManager.prototype.onMouseUp = function (event) {
|
|
708
|
+
!MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
|
|
709
|
+
this.updateColliders(event);
|
|
710
|
+
var prevent = event.type !== 'mouseup';
|
|
711
|
+
// prevent middle and second button
|
|
712
|
+
if (event instanceof MouseEvent && event.button === 1) {
|
|
713
|
+
prevent = true;
|
|
714
|
+
}
|
|
715
|
+
if (prevent) {
|
|
716
|
+
event.preventDefault();
|
|
717
|
+
this._stage.container.focus();
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
MouseManager.prototype.onMouseWheel = function (event) {
|
|
721
|
+
!MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
|
|
722
|
+
this.updateColliders(event);
|
|
723
|
+
};
|
|
724
|
+
MouseManager.prototype.updateColliders = function (event) {
|
|
725
|
+
this._stage.interactionHandler(event);
|
|
726
|
+
this._updateDirty = true;
|
|
727
|
+
var mouseData = this._pointerDataArray[0] || (this._pointerDataArray[0] = new PointerData(0, true));
|
|
728
|
+
var type = (event instanceof MouseEvent) ? event.type : MouseManager._touchToMouseDict[event.type];
|
|
729
|
+
this.queueDispatch(mouseData, MouseManager._pointerDict[type], event);
|
|
730
|
+
mouseData.screenX = this._stage.screenX;
|
|
731
|
+
mouseData.screenY = this._stage.screenY;
|
|
732
|
+
var touchPoints = this._stage.touchPoints;
|
|
733
|
+
for (var _i = 0, touchPoints_1 = touchPoints; _i < touchPoints_1.length; _i++) {
|
|
734
|
+
var touchPoint = touchPoints_1[_i];
|
|
735
|
+
var touchData = this._pointerDataArray[touchPoint.id] || (this._pointerDataArray[touchPoint.id] = new PointerData(touchPoint.id));
|
|
736
|
+
touchData.screenX = touchPoint.x;
|
|
737
|
+
touchData.screenY = touchPoint.y;
|
|
738
|
+
}
|
|
739
|
+
if (event.changedTouches) {
|
|
740
|
+
for (var i = 0; i < event.changedTouches.length; i++) {
|
|
741
|
+
var touch = event.changedTouches[i];
|
|
742
|
+
var touchData = this._pointerDataArray[touch.identifier];
|
|
743
|
+
this.queueDispatch(touchData, MouseManager._pointerDict[event.type], event);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
MouseManager._instancePool = {};
|
|
748
|
+
MouseManager._touchToMouseDict = {
|
|
749
|
+
touchstart: 'mousedown',
|
|
750
|
+
touchend: 'mouseup',
|
|
751
|
+
touchmove: 'mousemove',
|
|
752
|
+
};
|
|
753
|
+
MouseManager._pointerDict = {
|
|
754
|
+
mouseup: new AwayMouseEvent(AwayMouseEvent.MOUSE_UP),
|
|
755
|
+
mouseupoutside: new AwayMouseEvent(AwayMouseEvent.MOUSE_UP_OUTSIDE),
|
|
756
|
+
click: new AwayMouseEvent(AwayMouseEvent.CLICK),
|
|
757
|
+
mouseout: new AwayMouseEvent(AwayMouseEvent.MOUSE_OUT),
|
|
758
|
+
mousedown: new AwayMouseEvent(AwayMouseEvent.MOUSE_DOWN),
|
|
759
|
+
mousemove: new AwayMouseEvent(AwayMouseEvent.MOUSE_MOVE),
|
|
760
|
+
mouseover: new AwayMouseEvent(AwayMouseEvent.MOUSE_OVER),
|
|
761
|
+
mousewheel: new AwayMouseEvent(AwayMouseEvent.MOUSE_WHEEL),
|
|
762
|
+
dblclick: new AwayMouseEvent(AwayMouseEvent.DOUBLE_CLICK),
|
|
763
|
+
rollover: new AwayMouseEvent(AwayMouseEvent.ROLL_OVER),
|
|
764
|
+
rollout: new AwayMouseEvent(AwayMouseEvent.ROLL_OUT),
|
|
765
|
+
touchend: new AwayTouchEvent(AwayTouchEvent.TOUCH_END),
|
|
766
|
+
touchtap: new AwayTouchEvent(AwayTouchEvent.TOUCH_TAP),
|
|
767
|
+
touchout: new AwayTouchEvent(AwayTouchEvent.TOUCH_OUT),
|
|
768
|
+
touchstart: new AwayTouchEvent(AwayTouchEvent.TOUCH_BEGIN),
|
|
769
|
+
touchmove: new AwayTouchEvent(AwayTouchEvent.TOUCH_MOVE),
|
|
770
|
+
touchover: new AwayTouchEvent(AwayTouchEvent.TOUCH_OVER),
|
|
771
|
+
touchrollover: new AwayTouchEvent(AwayTouchEvent.TOUCH_ROLL_OVER),
|
|
772
|
+
touchrollout: new AwayTouchEvent(AwayTouchEvent.TOUCH_ROLL_OUT),
|
|
773
|
+
};
|
|
774
|
+
return MouseManager;
|
|
775
|
+
}());
|
|
776
|
+
export { MouseManager };
|
|
777
|
+
var PointerData = /** @class */ (function () {
|
|
778
|
+
function PointerData(id, isMouse) {
|
|
779
|
+
if (isMouse === void 0) { isMouse = false; }
|
|
780
|
+
this.id = id;
|
|
781
|
+
this.isMouse = isMouse;
|
|
782
|
+
this.collisionIsEnabledButton = false;
|
|
783
|
+
this.queuedEvents = new Array();
|
|
784
|
+
if (isMouse) {
|
|
785
|
+
this.up = MouseManager._pointerDict.mouseup;
|
|
786
|
+
this.upOutside = MouseManager._pointerDict.mouseupoutside;
|
|
787
|
+
this.click = MouseManager._pointerDict.click;
|
|
788
|
+
this.out = MouseManager._pointerDict.mouseout;
|
|
789
|
+
this.down = MouseManager._pointerDict.mousedown;
|
|
790
|
+
this.move = MouseManager._pointerDict.mousemove;
|
|
791
|
+
this.over = MouseManager._pointerDict.mouseover;
|
|
792
|
+
this.wheel = MouseManager._pointerDict.mousewheel;
|
|
793
|
+
this.doubleClick = MouseManager._pointerDict.dblclick;
|
|
794
|
+
this.rollOver = MouseManager._pointerDict.rollover;
|
|
795
|
+
this.rollOut = MouseManager._pointerDict.rollout;
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
this.up = MouseManager._pointerDict.touchend;
|
|
799
|
+
this.click = MouseManager._pointerDict.touchtap;
|
|
800
|
+
this.out = MouseManager._pointerDict.touchout;
|
|
801
|
+
this.down = MouseManager._pointerDict.touchstart;
|
|
802
|
+
this.move = MouseManager._pointerDict.touchmove;
|
|
803
|
+
this.over = MouseManager._pointerDict.touchover;
|
|
804
|
+
this.rollOver = MouseManager._pointerDict.touchrollover;
|
|
805
|
+
this.rollOut = MouseManager._pointerDict.touchrollout;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return PointerData;
|
|
809
|
+
}());
|