@awayjs/scene 0.13.247 → 0.13.249

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 (45) hide show
  1. package/bundle/awayjs-scene.umd.js +70 -196
  2. package/bundle/awayjs-scene.umd.js.map +1 -1
  3. package/bundle/awayjs-scene.umd.min.js.map +1 -1
  4. package/bundle/awayjs-scene.umd.min.js.map.map +1 -1
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/lib/base/MouseButtons.d.ts +23 -0
  9. package/dist/lib/base/MouseButtons.d.ts.map +1 -0
  10. package/dist/lib/base/MouseButtons.js +0 -0
  11. package/dist/lib/display/DisplayObject.d.ts +1 -3
  12. package/dist/lib/display/DisplayObject.d.ts.map +1 -1
  13. package/dist/lib/display/DisplayObject.js +1 -5
  14. package/dist/lib/display/MorphSprite.d.ts +0 -1
  15. package/dist/lib/display/MorphSprite.d.ts.map +1 -1
  16. package/dist/lib/display/MorphSprite.js +1 -17
  17. package/dist/lib/display/MovieClip.d.ts +1 -2
  18. package/dist/lib/display/MovieClip.d.ts.map +1 -1
  19. package/dist/lib/display/MovieClip.js +9 -18
  20. package/dist/lib/display/Sprite.d.ts +1 -18
  21. package/dist/lib/display/Sprite.d.ts.map +1 -1
  22. package/dist/lib/display/Sprite.js +23 -57
  23. package/dist/lib/display/TextField.d.ts +1 -15
  24. package/dist/lib/display/TextField.d.ts.map +1 -1
  25. package/dist/lib/display/TextField.js +12 -64
  26. package/dist/lib/display/TextSprite.d.ts +1 -2
  27. package/dist/lib/display/TextSprite.d.ts.map +1 -1
  28. package/dist/lib/display/TextSprite.js +2 -2
  29. package/dist/lib/events/MouseEvent.d.ts +3 -2
  30. package/dist/lib/events/MouseEvent.d.ts.map +1 -1
  31. package/dist/lib/events/MouseEvent.js +4 -4
  32. package/dist/lib/managers/MouseManager.d.ts +0 -1
  33. package/dist/lib/managers/MouseManager.d.ts.map +1 -1
  34. package/dist/lib/managers/MouseManager.js +17 -33
  35. package/index.ts +2 -1
  36. package/lib/base/MouseButtons.ts +27 -0
  37. package/lib/display/DisplayObject.ts +0 -9
  38. package/lib/display/MorphSprite.ts +1 -22
  39. package/lib/display/MovieClip.ts +11 -20
  40. package/lib/display/Sprite.ts +16 -59
  41. package/lib/display/TextField.ts +17 -72
  42. package/lib/display/TextSprite.ts +3 -4
  43. package/lib/events/MouseEvent.ts +6 -5
  44. package/lib/managers/MouseManager.ts +18 -36
  45. package/package.json +1 -1
@@ -8,6 +8,7 @@ import { FrameScriptManager } from '../managers/FrameScriptManager';
8
8
  import { DisplayObject } from './DisplayObject';
9
9
  import { Sprite } from './Sprite';
10
10
  import { DisplayObjectContainer } from './DisplayObjectContainer';
11
+ import { MouseButtons } from '../base/MouseButtons';
11
12
  interface IScene {
12
13
  offset: number;
13
14
  name: string;
@@ -43,7 +44,6 @@ export class MovieClip extends Sprite {
43
44
  if (MovieClip._movieClips.length) {
44
45
  const movieClip: MovieClip = MovieClip._movieClips.pop();
45
46
  movieClip.timeline = timeline;
46
- movieClip.graphics = Graphics.getGraphics();
47
47
  return movieClip;
48
48
  }
49
49
 
@@ -68,10 +68,9 @@ export class MovieClip extends Sprite {
68
68
 
69
69
  private _onMouseOver: (event: MouseEvent) => void;
70
70
  private _onMouseOut: (event: MouseEvent) => void;
71
- private _onDragOver: (event: MouseEvent) => void;
72
- private _onDragOut: (event: MouseEvent) => void;
73
71
  private _onMouseDown: (event: MouseEvent) => void;
74
72
  private _onMouseUp: (event: MouseEvent) => void;
73
+ private _onMouseUpOutside: (event: MouseEvent) => void;
75
74
 
76
75
  private _time: number = 0;// the current time inside the animation
77
76
 
@@ -169,13 +168,13 @@ export class MovieClip extends Sprite {
169
168
 
170
169
  this._onMouseOver = (_event: MouseEvent) => {
171
170
  if (this.buttonEnabled)
172
- this.currentFrameIndex = 1;
171
+ this.currentFrameIndex = (_event.buttons & MouseButtons.PRIMARY_BUTTON) ? this.currentFrameIndex == 0 ? 0 : 2 : 1;
173
172
  else
174
173
  this.currentFrameIndex = 0;
175
174
  };
176
175
 
177
176
  this._onMouseOut = (_event: MouseEvent) => {
178
- this.currentFrameIndex = 0;
177
+ this.currentFrameIndex = (_event.buttons & MouseButtons.PRIMARY_BUTTON && this.currentFrameIndex != 0) ? 1 : 0;
179
178
  };
180
179
 
181
180
  this._onMouseDown = (_event: MouseEvent) => {
@@ -186,18 +185,11 @@ export class MovieClip extends Sprite {
186
185
  };
187
186
 
188
187
  this._onMouseUp = (_event: MouseEvent) => {
189
- this.currentFrameIndex = this.currentFrameIndex == 0 ? 0 : 1;
190
- };
191
-
192
- this._onDragOver = (_event: MouseEvent) => {
193
- if (this.buttonEnabled)
194
- this.currentFrameIndex = 2;
195
- else
196
- this.currentFrameIndex = 0;
188
+ this.currentFrameIndex = 1;
197
189
  };
198
190
 
199
- this._onDragOut = (_event: MouseEvent) => {
200
- this.currentFrameIndex = 1;
191
+ this._onMouseUpOutside = (_event: MouseEvent) => {
192
+ this.currentFrameIndex = 0;
201
193
  };
202
194
 
203
195
  this._timeline = timeline;
@@ -580,7 +572,8 @@ export class MovieClip extends Sprite {
580
572
  for (let i: number = this.numChildren - 1; i >= 0; i--)
581
573
  this.removeChildAt(i);
582
574
 
583
- this.graphics.clear();
575
+ if (this._graphics)
576
+ this._graphics.clear();
584
577
 
585
578
  if (fireScripts) {
586
579
  const numFrames: number = this._timeline.keyframe_indices.length;
@@ -695,8 +688,7 @@ export class MovieClip extends Sprite {
695
688
  this.addEventListener(MouseEvent.MOUSE_OUT, this._onMouseOut);
696
689
  this.addEventListener(MouseEvent.MOUSE_DOWN, this._onMouseDown);
697
690
  this.addEventListener(MouseEvent.MOUSE_UP, this._onMouseUp);
698
- this.addEventListener(MouseEvent.DRAG_OVER, this._onDragOver);
699
- this.addEventListener(MouseEvent.DRAG_OUT, this._onDragOut);
691
+ this.addEventListener(MouseEvent.MOUSE_UP_OUTSIDE, this._onMouseUpOutside);
700
692
 
701
693
  this.mouseChildren = false;
702
694
  }
@@ -706,8 +698,7 @@ export class MovieClip extends Sprite {
706
698
  this.removeEventListener(MouseEvent.MOUSE_OUT, this._onMouseOut);
707
699
  this.removeEventListener(MouseEvent.MOUSE_DOWN, this._onMouseDown);
708
700
  this.removeEventListener(MouseEvent.MOUSE_UP, this._onMouseUp);
709
- this.removeEventListener(MouseEvent.DRAG_OVER, this._onDragOver);
710
- this.removeEventListener(MouseEvent.DRAG_OUT, this._onDragOut);
701
+ this.removeEventListener(MouseEvent.MOUSE_UP_OUTSIDE, this._onMouseUpOutside);
711
702
  }
712
703
 
713
704
  public getTimelineChildAtSessionID(sessionID: number): DisplayObject {
@@ -21,7 +21,7 @@ export class Sprite extends DisplayObjectContainer {
21
21
  public static getNewSprite(graphics: Graphics = null, material: IMaterial = null): Sprite {
22
22
  if (Sprite._sprites.length) {
23
23
  const sprite: Sprite = Sprite._sprites.pop();
24
- sprite.graphics = graphics || Graphics.getGraphics();
24
+ sprite.graphics = graphics;
25
25
  sprite.material = material;
26
26
  return sprite;
27
27
  }
@@ -35,7 +35,6 @@ export class Sprite extends DisplayObjectContainer {
35
35
 
36
36
  private _center: Vector3D;
37
37
  public _graphics: Graphics;
38
- protected _onGraphicsInvalidateDelegate: (event: AssetEvent) => void;
39
38
 
40
39
  /**
41
40
  *
@@ -49,24 +48,20 @@ export class Sprite extends DisplayObjectContainer {
49
48
  * drawing commands can occur.
50
49
  */
51
50
  public get graphics(): Graphics {
52
- if (this._iSourcePrefab)
53
- this._iSourcePrefab._iValidate();
51
+ //create new graphics object if none exists
52
+ if (!this._graphics) {
53
+ this.graphics = Graphics.getGraphics();
54
+ this.invalidate();
55
+ }
56
+
54
57
  return this._graphics;
55
58
  }
56
59
 
57
60
  public set graphics(value: Graphics) {
58
- if (value == null)
59
- throw new Error('Cannot have graphics set to null');
60
-
61
- this._setGraphics(value);
62
- }
63
-
64
- protected _setGraphics(value: Graphics): void {
65
61
  if (this._graphics == value)
66
62
  return;
67
63
 
68
64
  if (this._graphics) {
69
- this._graphics.removeEventListener(AssetEvent.INVALIDATE, this._onGraphicsInvalidateDelegate);
70
65
  this._graphics.usages--;
71
66
 
72
67
  //if (!this._graphics.usages)
@@ -75,7 +70,8 @@ export class Sprite extends DisplayObjectContainer {
75
70
 
76
71
  this._graphics = value;
77
72
 
78
- this._graphics.usages++;
73
+ if (this._graphics)
74
+ this._graphics.usages++;
79
75
 
80
76
  this.invalidate();
81
77
  }
@@ -88,33 +84,15 @@ export class Sprite extends DisplayObjectContainer {
88
84
  constructor(graphics: Graphics = null, material: IMaterial = null) {
89
85
  super();
90
86
 
91
- this._onGraphicsInvalidateDelegate = (event: AssetEvent) => this._onGraphicsInvalidate(event);
92
-
93
- this.graphics = graphics || Graphics.getGraphics();
87
+ this.graphics = graphics;
94
88
  this.material = material;
95
89
 
96
90
  // this.dropBitmapCache = this.dropBitmapCache.bind(this);
97
91
  // this.generateBitmapCache = this.generateBitmapCache.bind(this);
98
92
  }
99
93
 
100
- public _setParent(parent: DisplayObjectContainer): void {
101
- super._setParent(parent);
102
-
103
- if (parent)
104
- this._graphics.addEventListener(AssetEvent.INVALIDATE, this._onGraphicsInvalidateDelegate);
105
- else
106
- this._graphics.removeEventListener(AssetEvent.INVALIDATE, this._onGraphicsInvalidateDelegate);
107
-
108
- // if (this._requestCacheAsBitmap) {
109
-
110
- // this.set_cacheAsBitmapInternal(true);
111
-
112
- // console.log('Restore cache');
113
- // }
114
- }
115
-
116
94
  public getEntity(): IPartitionEntity {
117
- return (this._graphics.count > 0) ? this : null;
95
+ return this._graphics;
118
96
  }
119
97
 
120
98
  /**
@@ -162,7 +140,8 @@ export class Sprite extends DisplayObjectContainer {
162
140
 
163
141
  sprite._iSourcePrefab = this._iSourcePrefab;
164
142
 
165
- this._graphics.copyTo(sprite._graphics, cloneShapes);
143
+ if (this._graphics)
144
+ this._graphics.copyTo(sprite.graphics, cloneShapes);
166
145
  }
167
146
 
168
147
  /**
@@ -171,28 +150,8 @@ export class Sprite extends DisplayObjectContainer {
171
150
  public _iInternalUpdate(): void {
172
151
  super._iInternalUpdate();
173
152
 
174
- // if(this.parent)
175
- // this._graphics.updateScale(view);
176
- }
177
-
178
- /**
179
- * //TODO
180
- *
181
- * @private
182
- */
183
- protected _onGraphicsInvalidate(_event: AssetEvent): void {
184
- this.invalidate();
185
- }
186
-
187
- /**
188
- *
189
- * @param renderer
190
- *
191
- * @internal
192
- */
193
- public _acceptTraverser(traverser: IEntityTraverser): void {
194
- super._acceptTraverser(traverser);
195
- this.graphics._acceptTraverser(traverser);
153
+ if (this._iSourcePrefab)
154
+ this._iSourcePrefab._iValidate();
196
155
  }
197
156
 
198
157
  /**
@@ -202,6 +161,4 @@ export class Sprite extends DisplayObjectContainer {
202
161
  this._graphics.applyTransformation(this.transform.matrix3D);
203
162
  this.transform.clearMatrix3D();
204
163
  }
205
- }
206
-
207
- PartitionBase.registerAbstraction(EntityNode, Sprite);
164
+ }
@@ -204,7 +204,6 @@ const MNEMOS = [
204
204
  * options
205
205
  */
206
206
  export class TextField extends DisplayObjectContainer {
207
- private _onGraphicsInvalidateDelegate: (event: AssetEvent) => void;
208
207
  private _onClipboardPasteDelegate: (event: ClipboardEvent) => void;
209
208
 
210
209
  private static _textFields: Array<TextField> = [];
@@ -422,7 +421,8 @@ export class TextField extends DisplayObjectContainer {
422
421
  this.setSelection(0, 0);
423
422
 
424
423
  this._glyphsDirty = true;
425
- this._updateEntity();
424
+
425
+ this.invalidate();
426
426
  }
427
427
 
428
428
  private enableInput(enable: boolean = true) {
@@ -911,16 +911,6 @@ export class TextField extends DisplayObjectContainer {
911
911
 
912
912
  }
913
913
 
914
- /**
915
- * //TODO
916
- *
917
- * @private
918
- */
919
- private _onGraphicsInvalidate(event: AssetEvent): void {
920
-
921
- this.invalidate();
922
- }
923
-
924
914
  /**
925
915
  *
926
916
  * @returns {string}
@@ -1191,13 +1181,10 @@ export class TextField extends DisplayObjectContainer {
1191
1181
  this._iTextWoLineBreaks = processedText.replace(/(\r\n|\n|\\n|\r)/gm,'');
1192
1182
  this._textDirty = true;
1193
1183
  //console.log("set text", value, "on" , this);
1194
- if (this._autoSize != TextFieldAutoSize.NONE)
1195
- this.invalidate();
1196
- else
1197
- this._updateEntity();
1198
1184
 
1199
1185
  this.newTextFormat = this._textFormats[this._textFormats.length - 1];
1200
1186
 
1187
+ this.invalidate();
1201
1188
  }
1202
1189
 
1203
1190
  /**
@@ -1585,11 +1572,7 @@ export class TextField extends DisplayObjectContainer {
1585
1572
  this._textDirty = true;
1586
1573
 
1587
1574
  //console.log("set text", value, "on" , this);
1588
- if (this._autoSize != TextFieldAutoSize.NONE)
1589
- this.invalidate();
1590
- else
1591
- this._updateEntity();
1592
-
1575
+ this.invalidate();
1593
1576
  }
1594
1577
 
1595
1578
  public setLabelData(labelData: any) {
@@ -1602,11 +1585,7 @@ export class TextField extends DisplayObjectContainer {
1602
1585
  this._positionsDirty = false;
1603
1586
  this._glyphsDirty = true;
1604
1587
 
1605
- if (this._autoSize != TextFieldAutoSize.NONE)
1606
- this.invalidate();
1607
- else
1608
- this._updateEntity();
1609
-
1588
+ this.invalidate();
1610
1589
  }
1611
1590
 
1612
1591
  public get newTextFormat(): TextFormat {
@@ -1645,31 +1624,7 @@ export class TextField extends DisplayObjectContainer {
1645
1624
  this._textDirty = true;
1646
1625
  //this.reConstruct();
1647
1626
 
1648
- if (this._autoSize != TextFieldAutoSize.NONE)
1649
- this.invalidate();
1650
- else
1651
- this._updateEntity();
1652
- }
1653
-
1654
- /**
1655
- *
1656
- * @param renderer
1657
- *
1658
- * @internal
1659
- */
1660
- public _acceptTraverser(traverser: IEntityTraverser): void {
1661
- if (!this.maskMode) {
1662
- //if(!this.cursorBlinking && this._isInFocus && this.cursorShape && this._type==TextFieldType.INPUT){
1663
- // traverser[this.cursorShape.elements.traverseName](this.cursorShape);
1664
- //}
1665
- this._graphics._acceptTraverser(traverser);
1666
- //if(this.showSelection && this._isInFocus && this.bgShapeSelect){
1667
- // traverser[this.bgShapeSelect.elements.traverseName](this.bgShapeSelect);
1668
- //}
1669
- //if(this.bgShape){// && this.background){
1670
- // traverser[this.bgShape.elements.traverseName](this.bgShape);
1671
- //}
1672
- }
1627
+ this.invalidate();
1673
1628
  }
1674
1629
 
1675
1630
  /**
@@ -1759,7 +1714,7 @@ export class TextField extends DisplayObjectContainer {
1759
1714
 
1760
1715
  this._glyphsDirty = true;
1761
1716
 
1762
- this._updateEntity();
1717
+ this.invalidate();
1763
1718
  }
1764
1719
 
1765
1720
  private getTextColorForTextFormat(format: TextFormat) {
@@ -1834,14 +1789,12 @@ export class TextField extends DisplayObjectContainer {
1834
1789
  }
1835
1790
 
1836
1791
  public set type(value: TextFieldType) {
1837
- if (this._type == value) {
1792
+ if (this._type == value)
1838
1793
  return;
1839
- }
1794
+
1840
1795
  this._type = value;
1841
1796
  this._textDirty = true;
1842
1797
 
1843
- this._updateEntity();
1844
-
1845
1798
  if (value == TextFieldType.INPUT) {
1846
1799
  //this._selectable=true;
1847
1800
  this.enableInput(true);
@@ -1850,6 +1803,8 @@ export class TextField extends DisplayObjectContainer {
1850
1803
  this.enableInput(false);
1851
1804
  this.removeEventListener(KeyboardEvent.KEYDOWN, this.onKeyDelegate);
1852
1805
  }
1806
+
1807
+ this.invalidate();
1853
1808
  }
1854
1809
 
1855
1810
  /**
@@ -1951,7 +1906,6 @@ export class TextField extends DisplayObjectContainer {
1951
1906
  this.stopSelectionByMouseDelegate = (event: any) => this.stopSelectionByMouse(event);
1952
1907
  this.updateSelectionByMouseDelegate = (event: any) => this.updateSelectionByMouse(event);
1953
1908
 
1954
- this._onGraphicsInvalidateDelegate = (event: AssetEvent) => this._onGraphicsInvalidate(event);
1955
1909
  this._onClipboardPasteDelegate = (event: ClipboardEvent) => this.onClipboardPaste(event);
1956
1910
 
1957
1911
  this.cursorIntervalID = -1;
@@ -1985,7 +1939,6 @@ export class TextField extends DisplayObjectContainer {
1985
1939
  this._textFormats = [];
1986
1940
 
1987
1941
  this._graphics = Graphics.getGraphics(); //unique graphics object for each TextField
1988
- this._graphics.addEventListener(AssetEvent.INVALIDATE, this._onGraphicsInvalidateDelegate);
1989
1942
 
1990
1943
  this.mouseEnabled = this._selectable;
1991
1944
  }
@@ -1995,7 +1948,7 @@ export class TextField extends DisplayObjectContainer {
1995
1948
  }
1996
1949
 
1997
1950
  public getEntity(): IPartitionEntity {
1998
- return this;
1951
+ return this._graphics;
1999
1952
  }
2000
1953
 
2001
1954
  public clear(): void {
@@ -2745,8 +2698,6 @@ export class TextField extends DisplayObjectContainer {
2745
2698
  }
2746
2699
 
2747
2700
  }
2748
- this.updateMaskMode();
2749
-
2750
2701
  }
2751
2702
 
2752
2703
  public staticMatrix: any;
@@ -3078,10 +3029,8 @@ export class TextField extends DisplayObjectContainer {
3078
3029
 
3079
3030
  this._iText += newText;
3080
3031
  this._textDirty = true;
3081
- if (this._autoSize != TextFieldAutoSize.NONE)
3082
- this.invalidate();
3083
- else
3084
- this._updateEntity();
3032
+
3033
+ this.invalidate();
3085
3034
  }
3086
3035
 
3087
3036
  /**
@@ -3091,10 +3040,8 @@ export class TextField extends DisplayObjectContainer {
3091
3040
  public closeParagraph(): void {
3092
3041
  this._iText += '\n';
3093
3042
  this._textDirty = true;
3094
- if (this._autoSize != TextFieldAutoSize.NONE)
3095
- this.invalidate();
3096
- else
3097
- this._updateEntity();
3043
+
3044
+ this.invalidate();
3098
3045
  }
3099
3046
 
3100
3047
  /**
@@ -3994,6 +3941,4 @@ export class TextField extends DisplayObjectContainer {
3994
3941
  }
3995
3942
  }
3996
3943
 
3997
- }
3998
-
3999
- PartitionBase.registerAbstraction(EntityNode, TextField);
3944
+ }
@@ -1,7 +1,7 @@
1
1
  import { Sprite } from './Sprite';
2
2
  import { TextField } from './TextField';
3
3
  import { TesselatedFontTable } from '../text/TesselatedFontTable';
4
- import { HierarchicalProperty, IEntityTraverser } from '@awayjs/view';
4
+ import { HierarchicalProperty } from '@awayjs/view';
5
5
 
6
6
  /**
7
7
  * TextSprite is used for masked text.
@@ -10,7 +10,8 @@ import { HierarchicalProperty, IEntityTraverser } from '@awayjs/view';
10
10
  export class TextSprite extends Sprite {
11
11
  public parentTextField: TextField;
12
12
 
13
- public _acceptTraverser(traverser: IEntityTraverser): void {
13
+ public _iInternalUpdate(): void {
14
+ super._iInternalUpdate();
14
15
  const tf: TextField = this.parentTextField;
15
16
  //tf.reConstruct(true);
16
17
 
@@ -18,7 +19,5 @@ export class TextSprite extends Sprite {
18
19
  this.transform.colorTransform.color = (tf.textColor != null) ? tf.textColor : tf._textFormat.color;
19
20
  this._invalidateHierarchicalProperty(HierarchicalProperty.COLOR_TRANSFORM);
20
21
  }
21
-
22
- this._graphics._acceptTraverser(traverser);
23
22
  }
24
23
  }
@@ -1,9 +1,10 @@
1
1
  import { Point, Vector3D, EventBase } from '@awayjs/core';
2
2
 
3
- import { EntityNode, ContainerNode, INode, ITraversable, View, IPartitionContainer } from '@awayjs/view';
3
+ import { ContainerNode, INode, ITraversable, View, IPartitionContainer } from '@awayjs/view';
4
4
 
5
5
  import { IMaterial } from '@awayjs/renderer';
6
6
  import FrameScriptManager from '../managers/FrameScriptManager';
7
+ import { MouseButtons } from '../base/MouseButtons';
7
8
 
8
9
  /**
9
10
  * A MouseEvent is dispatched when a mouse event occurs over a mouseEnabled object in View.
@@ -181,9 +182,9 @@ export class MouseEvent extends EventBase {
181
182
  public delta: number;
182
183
 
183
184
  /**
184
- * Current button that fire event
185
+ * Current buttons status
185
186
  */
186
- public button: 0 | 1 | 2 | 3 = 0;
187
+ public buttons: MouseButtons = 0;
187
188
 
188
189
  /**
189
190
  * Create a new MouseEvent object.
@@ -256,7 +257,7 @@ export class MouseEvent extends EventBase {
256
257
 
257
258
  result._iParentEvent = this;
258
259
  result._iAllowedToPropagate = this._iAllowedToPropagate;
259
- result.button = this.button;
260
+ result.buttons = this.buttons;
260
261
 
261
262
  return result;
262
263
  }
@@ -279,7 +280,7 @@ export class MouseEvent extends EventBase {
279
280
  }
280
281
 
281
282
  public _dispatchEvent(dispatcher: ContainerNode, target: IPartitionContainer) {
282
- if (!dispatcher.isMouseDisabled()) {
283
+ if (!dispatcher.isMouseDisabled() || this.type == MouseEvent.MOUSE_OUT || this.type == MouseEvent.ROLL_OUT) {
283
284
  dispatcher.container.dispatchEvent(this, target);
284
285
  FrameScriptManager.execute_queue();
285
286
  }
@@ -112,7 +112,6 @@ export class MouseManager {
112
112
  */
113
113
  constructor(stage: Stage) {
114
114
  this._stage = stage;
115
- this.onClick = this.onClick.bind(this);
116
115
  this.onDoubleClick = this.onDoubleClick.bind(this);
117
116
  this.onMouseDown = this.onMouseDown.bind(this);
118
117
  this.onMouseMove = this.onMouseMove.bind(this);
@@ -130,8 +129,6 @@ export class MouseManager {
130
129
 
131
130
  //register stage
132
131
  const container = this._stage.container;
133
- container.addEventListener('click', this.onClick);
134
- container.addEventListener('dblclick', this.onClick);
135
132
  container.addEventListener('touchstart', this.onMouseDown);
136
133
  container.addEventListener('mousedown', this.onMouseDown);
137
134
 
@@ -140,7 +137,6 @@ export class MouseManager {
140
137
  window.addEventListener('mouseup', this.onMouseUp);
141
138
 
142
139
  container.addEventListener('touchend', this.onMouseUp);
143
- container.addEventListener('touchend', this.onClick);
144
140
  container.addEventListener('mousewheel', this.onMouseWheel);
145
141
  container.addEventListener('mouseover', this.onMouseOver);
146
142
  container.addEventListener('mouseout', this.onMouseOut);
@@ -174,7 +170,6 @@ export class MouseManager {
174
170
  public dispose() {
175
171
  //unregister stage
176
172
  const container = this._stage.container;
177
- container.removeEventListener('click', this.onClick);
178
173
  container.removeEventListener('dblclick', this.onDoubleClick);
179
174
  container.removeEventListener('touchstart', this.onMouseDown);
180
175
  container.removeEventListener('mousedown', this.onMouseDown);
@@ -182,7 +177,6 @@ export class MouseManager {
182
177
  window.removeEventListener('mousemove', this.onMouseMove);
183
178
  window.removeEventListener('mouseup', this.onMouseUp);
184
179
  container.removeEventListener('touchend', this.onMouseUp);
185
- container.removeEventListener('touchend', this.onClick);
186
180
  container.removeEventListener('wheel', this.onMouseWheel);
187
181
  container.removeEventListener('mouseover', this.onMouseOver);
188
182
  container.removeEventListener('mouseout', this.onMouseOut);
@@ -279,6 +273,7 @@ export class MouseManager {
279
273
  event.ctrlKey = sourceEvent.ctrlKey;
280
274
  event.altKey = sourceEvent.altKey;
281
275
  event.shiftKey = sourceEvent.shiftKey;
276
+ event.buttons = sourceEvent.buttons;
282
277
  }
283
278
 
284
279
  event = this.setUpEvent(event, collision, commonAncestor);
@@ -358,27 +353,16 @@ export class MouseManager {
358
353
  && this._mouseDragCollision.rootNode != dispatcher) {
359
354
  // no avm1dragging is in process, but current collision
360
355
  // is not the same as collision that appeared on mouse-down,
361
- // need to dispatch a MOUSE_UP_OUTSIDE on _mouseDragEntity
362
- if ((<any> this._mouseDragCollision.rootNode).buttonEnabled)
363
- this.setupAndDispatchEvent(this._mouseOut, event, this._mouseDragCollision);
364
- if (!this._eventBubbling) {
365
- this.setupAndDispatchEvent(this._mouseUpOutside, event, this._mouseDragCollision);
366
- }
356
+ // need to dispatch a MOUSE_UP_OUTSIDE after mouse up
367
357
  } else if (this._mouseDragging && this._mouseDragCollision
368
358
  && this._mouseDragCollision.rootNode == dispatcher) {
369
359
  // no avm1dragging is in process,
370
- // but current collision is not the same as collision that appeared on mouse-down,
371
- // need to dispatch a MOUSE_UP_OUTSIDE on _mouseDragEntity
360
+ // current collision is the same as collision that appeared on
361
+ // mouse-down, need to dispatch a MOUSE_CLICK event after mouse up
372
362
  upRootNode = this._mouseDragCollision.rootNode;
373
363
  upContainerNode = this._mouseDragCollision.containerNode;
374
364
  }
375
365
 
376
- if (this._mouseDragging && dispatcher)
377
- this.setupAndDispatchEvent(this._mouseOver, event, collision);
378
-
379
- if (this._isTouch && upContainerNode)
380
- this.setupAndDispatchEvent(this._mouseOut, this._mouseMoveEvent, this._mouseDragCollision);
381
-
382
366
  if (upRootNode) {
383
367
  //console.log("onRelease", upRootNode)
384
368
  this.dispatchEvent(event, upRootNode);
@@ -387,8 +371,13 @@ export class MouseManager {
387
371
  else if (this._eventBubbling)
388
372
  this._stage.dispatchEvent(event);
389
373
 
390
- if (upContainerNode)
374
+ if (upContainerNode) {
375
+ if (!this._isAVM1Dragging)
376
+ this.setupAndDispatchEvent(this._mouseClick, this._isTouch ? this._mouseMoveEvent : event, this._mouseDragCollision);
391
377
  this.setupAndDispatchEvent(this._dragStop, event, this._mouseDragCollision);
378
+ } else if (this._mouseDragging && this._mouseDragCollision) {
379
+ this.setupAndDispatchEvent(this._mouseUpOutside, event, this._mouseDragCollision);
380
+ }
392
381
 
393
382
  this._mouseDragCollision = null;
394
383
  this._mouseDragging = false;
@@ -432,16 +421,16 @@ export class MouseManager {
432
421
  if (collisionNode != prevCollisionNode) {
433
422
 
434
423
  // If colliding object has changed, queue OVER and OUT events.
435
- // If the mouse is dragged (mouse-down is hold), use DRAG_OVER and DRAG_OUT instead of MOUSE_OVER MOUSE_OUT
424
+ // If the mouse is dragged (mouse-down is hold), use DRAG_OVER and DRAG_OUT as well as MOUSE_OVER MOUSE_OUT
436
425
  // DRAG_OVER and DRAG_OUT are only dispatched on the object that was hit on the mouse-down
437
426
  // (_mouseDragEntity)
438
427
 
439
428
  // Store the info if the collision is a enabled Button (_collisionIsEnabledButton)
440
429
 
441
430
  if (prevCollisionNode) {
442
- if (!this._isTouch && !this._mouseDragging)
443
- this.setupAndDispatchEvent(this._mouseOut, this._mouseMoveEvent, this._prevCollision);
444
- else if (this._mouseDragging && this._mouseDragCollision
431
+ this.setupAndDispatchEvent(this._mouseOut, this._mouseMoveEvent, this._prevCollision);
432
+
433
+ if (this._mouseDragging && this._mouseDragCollision
445
434
  && this._mouseDragCollision.rootNode == prevCollisionNode)
446
435
  this.setupAndDispatchEvent(this._dragOut, this._mouseMoveEvent, this._prevCollision);
447
436
  }
@@ -487,10 +476,9 @@ export class MouseManager {
487
476
  this._collisionIsEnabledButton = collisionNode ? (<any> collisionNode).buttonEnabled : false;
488
477
 
489
478
  if (collisionNode) {
490
- if (!this._isTouch && !this._mouseDragging)
491
- this.setupAndDispatchEvent(this._mouseOver, this._mouseMoveEvent, collision);
492
- else if (this._mouseDragging && this._mouseDragCollision &&
493
- this._mouseDragCollision.rootNode == collisionNode)
479
+ this.setupAndDispatchEvent(this._mouseOver, this._mouseMoveEvent, collision);
480
+
481
+ if (this._mouseDragging)
494
482
  this.setupAndDispatchEvent(this._dragOver, this._mouseMoveEvent, collision);
495
483
  }
496
484
 
@@ -721,7 +709,7 @@ export class MouseManager {
721
709
  event.ctrlKey = sourceEvent.ctrlKey;
722
710
  event.altKey = sourceEvent.altKey;
723
711
  event.shiftKey = sourceEvent.shiftKey;
724
- event.button = (sourceEvent instanceof MouseEvent) ? <0> sourceEvent.button : 0;
712
+ event.buttons = (sourceEvent instanceof MouseEvent) ? <0> sourceEvent.buttons : 0;
725
713
 
726
714
  this._queuedEvents.push(event);
727
715
  }
@@ -816,12 +804,6 @@ export class MouseManager {
816
804
  this.queueDispatch(this._mouseOver, event);
817
805
  }
818
806
 
819
- public onClick(event: MouseEvent): void {
820
- !MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
821
- this.updateColliders(event);
822
- this.queueDispatch(this._mouseClick, event);
823
- }
824
-
825
807
  public onDoubleClick(event: MouseEvent): void {
826
808
  !MouseManager.inputRecorder || MouseManager.inputRecorder.recordEvent(event);
827
809
  this.updateColliders(event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awayjs/scene",
3
- "version": "0.13.247",
3
+ "version": "0.13.249",
4
4
  "description": "AwayJS scene classes",
5
5
  "main": "bundle/awayjs-scene.umd.js",
6
6
  "module": "dist/index.js",