@awayjs/scene 0.13.264 → 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.
Files changed (268) hide show
  1. package/.eslintrc +100 -100
  2. package/README.md +61 -61
  3. package/bundle/awayjs-scene.umd.js +2 -2
  4. package/bundle/awayjs-scene.umd.js.map +1 -1
  5. package/copyVersionToIndex.js +23 -23
  6. package/dist/index.d.ts +76 -75
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +67 -66
  9. package/dist/lib/Scene.d.ts +84 -84
  10. package/dist/lib/Scene.js +288 -288
  11. package/dist/lib/Settings.d.ts +16 -16
  12. package/dist/lib/Settings.js +60 -60
  13. package/dist/lib/adapters/IDisplayObjectAdapter.d.ts +13 -13
  14. package/dist/lib/adapters/IDisplayObjectAdapter.js +1 -1
  15. package/dist/lib/adapters/IFilter.d.ts +24 -24
  16. package/dist/lib/adapters/IFilter.js +1 -1
  17. package/dist/lib/adapters/IMovieClipAdapter.d.ts +14 -14
  18. package/dist/lib/adapters/IMovieClipAdapter.js +1 -1
  19. package/dist/lib/adapters/ITextfieldAdapter.d.ts +4 -4
  20. package/dist/lib/adapters/ITextfieldAdapter.js +1 -1
  21. package/dist/lib/base/IBitmapDrawable.d.ts +11 -11
  22. package/dist/lib/base/IBitmapDrawable.js +1 -1
  23. package/dist/lib/base/IFrameLabel.d.ts +4 -4
  24. package/dist/lib/base/IFrameLabel.js +1 -1
  25. package/dist/lib/base/IFrameScript.d.ts +5 -5
  26. package/dist/lib/base/IFrameScript.js +1 -1
  27. package/dist/lib/base/MouseButtons.d.ts +26 -22
  28. package/dist/lib/base/MouseButtons.d.ts.map +1 -1
  29. package/dist/lib/base/MouseButtons.js +1 -1
  30. package/dist/lib/base/Timeline.d.ts +148 -148
  31. package/dist/lib/base/Timeline.js +535 -535
  32. package/dist/lib/base/TimelineActionType.d.ts +18 -18
  33. package/dist/lib/base/TimelineActionType.js +1 -1
  34. package/dist/lib/controllers/ControllerBase.d.ts +14 -14
  35. package/dist/lib/controllers/ControllerBase.js +60 -60
  36. package/dist/lib/controllers/FirstPersonController.d.ts +78 -78
  37. package/dist/lib/controllers/FirstPersonController.js +228 -228
  38. package/dist/lib/controllers/FollowController.d.ts +12 -12
  39. package/dist/lib/controllers/FollowController.js +27 -27
  40. package/dist/lib/controllers/HoverController.d.ts +105 -105
  41. package/dist/lib/controllers/HoverController.js +302 -302
  42. package/dist/lib/controllers/LookAtController.d.ts +14 -14
  43. package/dist/lib/controllers/LookAtController.js +68 -68
  44. package/dist/lib/controllers/SpringController.d.ts +38 -38
  45. package/dist/lib/controllers/SpringController.js +59 -59
  46. package/dist/lib/display/Billboard.d.ts +147 -147
  47. package/dist/lib/display/Billboard.js +426 -426
  48. package/dist/lib/display/Camera.d.ts +40 -40
  49. package/dist/lib/display/Camera.js +90 -90
  50. package/dist/lib/display/DisplayObject.d.ts +938 -938
  51. package/dist/lib/display/DisplayObject.js +1641 -1641
  52. package/dist/lib/display/DisplayObjectContainer.d.ts +325 -325
  53. package/dist/lib/display/DisplayObjectContainer.js +480 -480
  54. package/dist/lib/display/LineSegment.d.ts +84 -84
  55. package/dist/lib/display/LineSegment.js +215 -215
  56. package/dist/lib/display/LoaderContainer.d.ts +504 -504
  57. package/dist/lib/display/LoaderContainer.js +603 -603
  58. package/dist/lib/display/MorphSprite.d.ts +20 -20
  59. package/dist/lib/display/MorphSprite.js +254 -254
  60. package/dist/lib/display/MovieClip.d.ts +152 -152
  61. package/dist/lib/display/MovieClip.js +735 -735
  62. package/dist/lib/display/SimpleButton.d.ts +158 -158
  63. package/dist/lib/display/SimpleButton.js +228 -228
  64. package/dist/lib/display/Skybox.d.ts +156 -156
  65. package/dist/lib/display/Skybox.js +309 -309
  66. package/dist/lib/display/Sprite.d.ts +70 -70
  67. package/dist/lib/display/Sprite.js +144 -144
  68. package/dist/lib/display/TextField.d.ts +1109 -1109
  69. package/dist/lib/display/TextField.js +3109 -3109
  70. package/dist/lib/display/TextSprite.d.ts +10 -10
  71. package/dist/lib/display/TextSprite.js +25 -25
  72. package/dist/lib/elements/SkyboxElements.d.ts +29 -29
  73. package/dist/lib/elements/SkyboxElements.js +127 -127
  74. package/dist/lib/errors/CastError.d.ts +4 -4
  75. package/dist/lib/errors/CastError.js +10 -10
  76. package/dist/lib/events/CameraEvent.d.ts +16 -16
  77. package/dist/lib/events/CameraEvent.js +30 -30
  78. package/dist/lib/events/FocusEvent.d.ts +42 -42
  79. package/dist/lib/events/FocusEvent.js +43 -43
  80. package/dist/lib/events/KeyboardEvent.d.ts +21 -21
  81. package/dist/lib/events/KeyboardEvent.js +43 -43
  82. package/dist/lib/events/MouseEvent.d.ts +91 -184
  83. package/dist/lib/events/MouseEvent.d.ts.map +1 -1
  84. package/dist/lib/events/MouseEvent.js +122 -191
  85. package/dist/lib/events/PointerEvent.d.ts +94 -0
  86. package/dist/lib/events/PointerEvent.d.ts.map +1 -0
  87. package/dist/lib/events/PointerEvent.js +73 -0
  88. package/dist/lib/events/ResizeEvent.d.ts +15 -15
  89. package/dist/lib/events/ResizeEvent.js +38 -38
  90. package/dist/lib/events/TextfieldEvent.d.ts +19 -19
  91. package/dist/lib/events/TextfieldEvent.js +28 -28
  92. package/dist/lib/events/TouchEvent.d.ts +51 -0
  93. package/dist/lib/events/TouchEvent.d.ts.map +1 -0
  94. package/dist/lib/events/TouchEvent.js +83 -0
  95. package/dist/lib/factories/DefaultSceneGraphFactory.d.ts +26 -26
  96. package/dist/lib/factories/DefaultSceneGraphFactory.js +54 -54
  97. package/dist/lib/factories/ISceneGraphFactory.d.ts +20 -20
  98. package/dist/lib/factories/ISceneGraphFactory.js +1 -1
  99. package/dist/lib/image/SceneImage2D.d.ts +236 -236
  100. package/dist/lib/image/SceneImage2D.js +687 -687
  101. package/dist/lib/managers/DefaultFontManager.d.ts +14 -14
  102. package/dist/lib/managers/DefaultFontManager.js +101 -101
  103. package/dist/lib/managers/DeviceFontManager.d.ts +8 -8
  104. package/dist/lib/managers/DeviceFontManager.js +44 -44
  105. package/dist/lib/managers/FrameScriptManager.d.ts +36 -36
  106. package/dist/lib/managers/FrameScriptManager.js +377 -377
  107. package/dist/lib/managers/IInputRecorder.d.ts +3 -3
  108. package/dist/lib/managers/IInputRecorder.js +1 -1
  109. package/dist/lib/managers/MouseManager.d.ts +76 -89
  110. package/dist/lib/managers/MouseManager.d.ts.map +1 -1
  111. package/dist/lib/managers/MouseManager.js +809 -759
  112. package/dist/lib/prefabs/PrefabBase.d.ts +19 -19
  113. package/dist/lib/prefabs/PrefabBase.js +42 -42
  114. package/dist/lib/prefabs/PrimitiveCapsulePrefab.d.ts +56 -56
  115. package/dist/lib/prefabs/PrimitiveCapsulePrefab.js +269 -269
  116. package/dist/lib/prefabs/PrimitiveConePrefab.d.ts +21 -21
  117. package/dist/lib/prefabs/PrimitiveConePrefab.js +43 -43
  118. package/dist/lib/prefabs/PrimitiveCubePrefab.d.ts +74 -74
  119. package/dist/lib/prefabs/PrimitiveCubePrefab.js +545 -545
  120. package/dist/lib/prefabs/PrimitiveCylinderPrefab.d.ts +79 -79
  121. package/dist/lib/prefabs/PrimitiveCylinderPrefab.js +584 -584
  122. package/dist/lib/prefabs/PrimitivePlanePrefab.d.ts +65 -65
  123. package/dist/lib/prefabs/PrimitivePlanePrefab.js +300 -300
  124. package/dist/lib/prefabs/PrimitivePolygonPrefab.d.ts +29 -29
  125. package/dist/lib/prefabs/PrimitivePolygonPrefab.js +64 -64
  126. package/dist/lib/prefabs/PrimitivePrefabBase.d.ts +67 -67
  127. package/dist/lib/prefabs/PrimitivePrefabBase.js +158 -158
  128. package/dist/lib/prefabs/PrimitiveSpherePrefab.d.ts +48 -48
  129. package/dist/lib/prefabs/PrimitiveSpherePrefab.js +294 -294
  130. package/dist/lib/prefabs/PrimitiveTorusPrefab.d.ts +55 -55
  131. package/dist/lib/prefabs/PrimitiveTorusPrefab.js +260 -260
  132. package/dist/lib/text/AntiAliasType.d.ts +24 -24
  133. package/dist/lib/text/AntiAliasType.js +28 -28
  134. package/dist/lib/text/BitmapFontChar.d.ts +39 -39
  135. package/dist/lib/text/BitmapFontChar.js +42 -42
  136. package/dist/lib/text/BitmapFontTable.d.ts +80 -80
  137. package/dist/lib/text/BitmapFontTable.js +203 -203
  138. package/dist/lib/text/FNTGenerator.d.ts +10 -10
  139. package/dist/lib/text/FNTGenerator.js +74 -74
  140. package/dist/lib/text/FNTGeneratorCanvas.d.ts +22 -22
  141. package/dist/lib/text/FNTGeneratorCanvas.js +205 -205
  142. package/dist/lib/text/FNTGeneratrorBase.d.ts +7 -7
  143. package/dist/lib/text/FNTGeneratrorBase.js +7 -7
  144. package/dist/lib/text/Font.d.ts +38 -38
  145. package/dist/lib/text/Font.js +109 -109
  146. package/dist/lib/text/FontLookUpMode.d.ts +5 -5
  147. package/dist/lib/text/FontLookUpMode.js +7 -7
  148. package/dist/lib/text/FontStyleName.d.ts +6 -6
  149. package/dist/lib/text/FontStyleName.js +7 -7
  150. package/dist/lib/text/GridFitType.d.ts +31 -31
  151. package/dist/lib/text/GridFitType.js +35 -35
  152. package/dist/lib/text/HTMLTextProcessor.d.ts +8 -8
  153. package/dist/lib/text/HTMLTextProcessor.js +423 -423
  154. package/dist/lib/text/IFontTable.d.ts +16 -16
  155. package/dist/lib/text/IFontTable.js +1 -1
  156. package/dist/lib/text/TesselatedFontChar.d.ts +58 -58
  157. package/dist/lib/text/TesselatedFontChar.js +66 -66
  158. package/dist/lib/text/TesselatedFontTable.d.ts +95 -95
  159. package/dist/lib/text/TesselatedFontTable.js +992 -992
  160. package/dist/lib/text/TextFieldAutoSize.d.ts +28 -28
  161. package/dist/lib/text/TextFieldAutoSize.js +32 -32
  162. package/dist/lib/text/TextFieldType.d.ts +20 -20
  163. package/dist/lib/text/TextFieldType.js +24 -24
  164. package/dist/lib/text/TextFormat.d.ts +273 -273
  165. package/dist/lib/text/TextFormat.js +440 -440
  166. package/dist/lib/text/TextFormatAlign.d.ts +26 -26
  167. package/dist/lib/text/TextFormatAlign.js +30 -30
  168. package/dist/lib/text/TextInteractionMode.d.ts +21 -21
  169. package/dist/lib/text/TextInteractionMode.js +25 -25
  170. package/dist/lib/text/TextLineMetrics.d.ts +61 -61
  171. package/dist/lib/text/TextLineMetrics.js +42 -42
  172. package/dist/lib/text/TextShape.d.ts +20 -20
  173. package/dist/lib/text/TextShape.js +75 -75
  174. package/dist/lib/tools/Merge.d.ts +81 -81
  175. package/dist/lib/tools/Merge.js +266 -266
  176. package/dist/lib/utils/Cast.d.ts +20 -20
  177. package/dist/lib/utils/Cast.js +271 -271
  178. package/index.ts +92 -91
  179. package/lib/Scene.ts +343 -343
  180. package/lib/Settings.ts +83 -83
  181. package/lib/adapters/IDisplayObjectAdapter.ts +23 -23
  182. package/lib/adapters/IFilter.ts +25 -25
  183. package/lib/adapters/IMovieClipAdapter.ts +24 -24
  184. package/lib/adapters/ITextfieldAdapter.ts +6 -6
  185. package/lib/base/IBitmapDrawable.ts +13 -13
  186. package/lib/base/IFrameLabel.ts +3 -3
  187. package/lib/base/IFrameScript.ts +4 -4
  188. package/lib/base/MouseButtons.ts +31 -26
  189. package/lib/base/Timeline.ts +727 -727
  190. package/lib/base/TimelineActionType.ts +18 -18
  191. package/lib/controllers/ControllerBase.ts +66 -66
  192. package/lib/controllers/FirstPersonController.ts +241 -241
  193. package/lib/controllers/FollowController.ts +22 -22
  194. package/lib/controllers/HoverController.ts +304 -304
  195. package/lib/controllers/LookAtController.ts +75 -75
  196. package/lib/controllers/SpringController.ts +91 -91
  197. package/lib/display/Billboard.ts +504 -504
  198. package/lib/display/Camera.ts +89 -89
  199. package/lib/display/DisplayObject.ts +1893 -1893
  200. package/lib/display/DisplayObjectContainer.ts +538 -538
  201. package/lib/display/LineSegment.ts +248 -248
  202. package/lib/display/LoaderContainer.ts +651 -651
  203. package/lib/display/MorphSprite.ts +347 -347
  204. package/lib/display/MovieClip.ts +879 -879
  205. package/lib/display/SimpleButton.ts +224 -224
  206. package/lib/display/Skybox.ts +379 -379
  207. package/lib/display/Sprite.ts +165 -165
  208. package/lib/display/TextField.ts +3958 -3958
  209. package/lib/display/TextSprite.ts +22 -22
  210. package/lib/elements/SkyboxElements.ts +141 -141
  211. package/lib/errors/CastError.ts +6 -6
  212. package/lib/events/CameraEvent.ts +29 -29
  213. package/lib/events/FocusEvent.ts +69 -69
  214. package/lib/events/KeyboardEvent.ts +40 -40
  215. package/lib/events/MouseEvent.ts +147 -287
  216. package/lib/events/PointerEvent.ts +146 -0
  217. package/lib/events/ResizeEvent.ts +31 -31
  218. package/lib/events/TextfieldEvent.ts +28 -28
  219. package/lib/events/TouchEvent.ts +101 -0
  220. package/lib/factories/DefaultSceneGraphFactory.ts +56 -56
  221. package/lib/factories/ISceneGraphFactory.ts +28 -28
  222. package/lib/image/SceneImage2D.ts +1020 -1020
  223. package/lib/managers/DefaultFontManager.ts +124 -124
  224. package/lib/managers/DeviceFontManager.ts +55 -55
  225. package/lib/managers/FrameScriptManager.ts +431 -431
  226. package/lib/managers/IInputRecorder.ts +2 -2
  227. package/lib/managers/MouseManager.ts +944 -882
  228. package/lib/prefabs/PrefabBase.ts +47 -47
  229. package/lib/prefabs/PrimitiveCapsulePrefab.ts +286 -286
  230. package/lib/prefabs/PrimitiveConePrefab.ts +37 -37
  231. package/lib/prefabs/PrimitiveCubePrefab.ts +630 -630
  232. package/lib/prefabs/PrimitiveCylinderPrefab.ts +657 -657
  233. package/lib/prefabs/PrimitivePlanePrefab.ts +352 -352
  234. package/lib/prefabs/PrimitivePolygonPrefab.ts +53 -53
  235. package/lib/prefabs/PrimitivePrefabBase.ts +177 -177
  236. package/lib/prefabs/PrimitiveSpherePrefab.ts +336 -336
  237. package/lib/prefabs/PrimitiveTorusPrefab.ts +282 -282
  238. package/lib/text/AntiAliasType.ts +24 -24
  239. package/lib/text/BitmapFontChar.ts +53 -53
  240. package/lib/text/BitmapFontTable.ts +232 -232
  241. package/lib/text/FNTGenerator.ts +100 -100
  242. package/lib/text/FNTGeneratorCanvas.ts +287 -287
  243. package/lib/text/FNTGeneratrorBase.ts +10 -10
  244. package/lib/text/Font.ts +114 -114
  245. package/lib/text/FontLookUpMode.ts +5 -5
  246. package/lib/text/FontStyleName.ts +6 -6
  247. package/lib/text/GridFitType.ts +32 -32
  248. package/lib/text/HTMLTextProcessor.ts +418 -418
  249. package/lib/text/IFontTable.ts +17 -17
  250. package/lib/text/TesselatedFontChar.ts +80 -80
  251. package/lib/text/TesselatedFontTable.ts +1221 -1221
  252. package/lib/text/TextFieldAutoSize.ts +30 -30
  253. package/lib/text/TextFieldType.ts +21 -21
  254. package/lib/text/TextFormat.ts +601 -601
  255. package/lib/text/TextFormatAlign.ts +28 -28
  256. package/lib/text/TextInteractionMode.ts +21 -21
  257. package/lib/text/TextLineMetrics.ts +74 -74
  258. package/lib/text/TextShape.ts +90 -90
  259. package/lib/tools/Merge.ts +311 -311
  260. package/lib/utils/Cast.ts +304 -304
  261. package/package.json +74 -74
  262. package/rollup.config.js +33 -33
  263. package/scripts/build.sh +2 -2
  264. package/scripts/gendocs.sh +14 -14
  265. package/scripts/genexamples.sh +14 -14
  266. package/scripts/genfull.sh +14 -14
  267. package/system.config.js +51 -51
  268. package/tsconfig.json +18 -18
@@ -1,1894 +1,1894 @@
1
- import {
2
- Transform,
3
- TransformEvent,
4
- Sphere,
5
- MathConsts,
6
- Matrix3D,
7
- Rectangle,
8
- Vector3D,
9
- AssetBase,
10
- Loader,
11
- } from '@awayjs/core';
12
-
13
- import { BlendMode } from '@awayjs/stage';
14
-
15
- import {
16
- BoundingBox,
17
- BoundingSphere,
18
- BoundingVolumeType,
19
- IPartitionEntity,
20
- BoundsPicker,
21
- HeirarchicalEvent,
22
- HierarchicalProperty,
23
- AlignmentMode,
24
- OrientationMode,
25
- BasicPartition,
26
- IPartitionContainer,
27
- ContainerNode
28
- } from '@awayjs/view';
29
-
30
- import {
31
- IMaterial,
32
- Style,
33
- StyleEvent,
34
- RenderableEvent,
35
- ElementsType,
36
- } from '@awayjs/renderer';
37
-
38
- import { DisplayObjectContainer } from './DisplayObjectContainer';
39
- import { ControllerBase } from '../controllers/ControllerBase';
40
- import { IBitmapDrawable } from '../base/IBitmapDrawable';
41
-
42
- import { PrimitiveCubePrefab } from '../prefabs/PrimitiveCubePrefab';
43
- import { PrimitiveSpherePrefab } from '../prefabs/PrimitiveSpherePrefab';
44
- import { PrimitivePrefabBase } from '../prefabs/PrimitivePrefabBase';
45
- import { IFilter } from '../adapters/IFilter';
46
- import { IPartitionClass } from '@awayjs/view';
47
- import { Sprite } from './Sprite';
48
- import { Settings } from '../Settings';
49
-
50
- /**
51
- * The DisplayObject class is the base class for all objects that can be
52
- * placed on the display list. The display list manages all objects displayed
53
- * in flash. Use the DisplayObjectContainer class to arrange the
54
- * display objects in the display list. DisplayObjectContainer objects can
55
- * have child display objects, while other display objects, such as Shape and
56
- * TextField objects, are "leaf" nodes that have only parents and siblings, no
57
- * children.
58
- *
59
- * <p>The DisplayObject class supports fbasic functionality like the <i>x</i>
60
- * and <i>y</i> position of an object, as well as more advanced properties of
61
- * the object such as its transformation matrix. </p>
62
- *
63
- * <p>DisplayObject is an abstract base class; therefore, you cannot call
64
- * DisplayObject directly. Invoking <code>new DisplayObject()</code> throws an
65
- * <code>ArgumentError</code> exception. </p>
66
- *
67
- * <p>All display objects inherit from the DisplayObject class.</p>
68
- *
69
- * <p>The DisplayObject class itself does not include any APIs for rendering
70
- * content onscreen. For that reason, if you want create a custom subclass of
71
- * the DisplayObject class, you will want to extend one of its subclasses that
72
- * do have APIs for rendering content onscreen, such as the Shape, Sprite,
73
- * Bitmap, SimpleButton, TextField, or MovieClip class.</p>
74
- *
75
- * <p>The DisplayObject class contains several broadcast events. Normally, the
76
- * target of any particular event is a specific DisplayObject instance. For
77
- * example, the target of an <code>added</code> event is the specific
78
- * DisplayObject instance that was added to the display list. Having a single
79
- * target restricts the placement of event listeners to that target and in
80
- * some cases the target's ancestors on the display list. With broadcast
81
- * events, however, the target is not a specific DisplayObject instance, but
82
- * rather all DisplayObject instances, including those that are not on the
83
- * display list. This means that you can add a listener to any DisplayObject
84
- * instance to listen for broadcast events. In addition to the broadcast
85
- * events listed in the DisplayObject class's Events table, the DisplayObject
86
- * class also inherits two broadcast events from the EventDispatcher class:
87
- * <code>activate</code> and <code>deactivate</code>.</p>
88
- *
89
- * <p>Some properties previously used in the ActionScript 1.0 and 2.0
90
- * MovieClip, TextField, and Button classes(such as <code>_alpha</code>,
91
- * <code>_height</code>, <code>_pName</code>, <code>_width</code>,
92
- * <code>_x</code>, <code>_y</code>, and others) have equivalents in the
93
- * ActionScript 3.0 DisplayObject class that are renamed so that they no
94
- * longer begin with the underscore(_) character.</p>
95
- *
96
- * <p>For more information, see the "Display Programming" chapter of the
97
- * <i>ActionScript 3.0 Developer's Guide</i>.</p>
98
- *
99
- * @event added Dispatched when a display object is added to the
100
- * display list. The following methods trigger this
101
- * event:
102
- * <code>DisplayObjectContainer.addChild()</code>,
103
- * <code>DisplayObjectContainer.addChildAt()</code>.
104
- * @event addedToScene Dispatched when a display object is added to the on
105
- * scene display list, either directly or through the
106
- * addition of a sub tree in which the display object
107
- * is contained. The following methods trigger this
108
- * event:
109
- * <code>DisplayObjectContainer.addChild()</code>,
110
- * <code>DisplayObjectContainer.addChildAt()</code>.
111
- * @event enterFrame [broadcast event] Dispatched when the playhead is
112
- * entering a new frame. If the playhead is not
113
- * moving, or if there is only one frame, this event
114
- * is dispatched continuously in conjunction with the
115
- * frame rate. This event is a broadcast event, which
116
- * means that it is dispatched by all display objects
117
- * with a listener registered for this event.
118
- * @event exitFrame [broadcast event] Dispatched when the playhead is
119
- * exiting the current frame. All frame scripts have
120
- * been run. If the playhead is not moving, or if
121
- * there is only one frame, this event is dispatched
122
- * continuously in conjunction with the frame rate.
123
- * This event is a broadcast event, which means that
124
- * it is dispatched by all display objects with a
125
- * listener registered for this event.
126
- * @event frameConstructed [broadcast event] Dispatched after the constructors
127
- * of frame display objects have run but before frame
128
- * scripts have run. If the playhead is not moving, or
129
- * if there is only one frame, this event is
130
- * dispatched continuously in conjunction with the
131
- * frame rate. This event is a broadcast event, which
132
- * means that it is dispatched by all display objects
133
- * with a listener registered for this event.
134
- * @event removed Dispatched when a display object is about to be
135
- * removed from the display list. Two methods of the
136
- * DisplayObjectContainer class generate this event:
137
- * <code>removeChild()</code> and
138
- * <code>removeChildAt()</code>.
139
- *
140
- * <p>The following methods of a
141
- * DisplayObjectContainer object also generate this
142
- * event if an object must be removed to make room for
143
- * the new object: <code>addChild()</code>,
144
- * <code>addChildAt()</code>, and
145
- * <code>setChildIndex()</code>. </p>
146
- * @event removedFromScene Dispatched when a display object is about to be
147
- * removed from the display list, either directly or
148
- * through the removal of a sub tree in which the
149
- * display object is contained. Two methods of the
150
- * DisplayObjectContainer class generate this event:
151
- * <code>removeChild()</code> and
152
- * <code>removeChildAt()</code>.
153
- *
154
- * <p>The following methods of a
155
- * DisplayObjectContainer object also generate this
156
- * event if an object must be removed to make room for
157
- * the new object: <code>addChild()</code>,
158
- * <code>addChildAt()</code>, and
159
- * <code>setChildIndex()</code>. </p>
160
- * @event render [broadcast event] Dispatched when the display list
161
- * is about to be updated and rendered. This event
162
- * provides the last opportunity for objects listening
163
- * for this event to make changes before the display
164
- * list is rendered. You must call the
165
- * <code>invalidate()</code> method of the Scene
166
- * object each time you want a <code>render</code>
167
- * event to be dispatched. <code>Render</code> events
168
- * are dispatched to an object only if there is mutual
169
- * trust between it and the object that called
170
- * <code>Scene.invalidate()</code>. This event is a
171
- * broadcast event, which means that it is dispatched
172
- * by all display objects with a listener registered
173
- * for this event.
174
- *
175
- * <p><b>Note: </b>This event is not dispatched if the
176
- * display is not rendering. This is the case when the
177
- * content is either minimized or obscured. </p>
178
- */
179
- export class DisplayObject extends AssetBase implements IBitmapDrawable, IPartitionContainer {
180
-
181
- private _mouseChildren: boolean = true;
182
- public _material: IMaterial;
183
- public _style: Style;
184
- private _loader: Loader;
185
- private _mouseX: number;
186
- private _mouseY: number;
187
- private _root: DisplayObjectContainer;
188
- private _boundsVisible: boolean;
189
- private _boundsPrefab: PrimitivePrefabBase;
190
- private _boundsPrefabDirty: boolean;
191
- private _boundsPrimitive: DisplayObject;
192
- private _pName: string;
193
-
194
- private _scrollRect: Rectangle;
195
- private _scrollRectPrimitive: Sprite;
196
- private _scrollRectPrimitiveDirty: boolean;
197
-
198
- protected _parent: DisplayObjectContainer;
199
- public _sessionID: number = -1;
200
- public _avmDepthID: number = -1;
201
-
202
- public pickObjectFromTimeline: boolean;
203
-
204
- //public _implicitPartition: PartitionBase;
205
-
206
- private _alignmentMode: AlignmentMode = AlignmentMode.REGISTRATION_POINT;
207
- private _scale9Grid: Rectangle;
208
- protected _transform: Transform;
209
- private _visible: boolean = true;
210
- private _maskId: number = -1;
211
-
212
- protected _masks: Array<DisplayObject>;
213
- protected _scriptMask: DisplayObject;
214
-
215
- private _mouseEnabled: boolean = true;
216
-
217
- private _eulers: Vector3D;
218
-
219
- public _registrationMatrix3D: Matrix3D;
220
- private _defaultBoundingVolume: BoundingVolumeType;
221
-
222
- public cursorType: string;
223
-
224
- protected _isInFocus: boolean;
225
- protected _tabEnabled: boolean;
226
- protected _tabIndex: number;
227
-
228
- private _maskMode: boolean = false;
229
- private _pickObject: DisplayObjectContainer;
230
-
231
- public _hierarchicalPropsDirty: number;
232
-
233
- private _onInvalidatePropertiesDelegate: (event: StyleEvent) => void;
234
- private _onInvalidateImagesDelegate: (event: StyleEvent) => void;
235
-
236
- public isSlice9ScaledMC: boolean=false;
237
- public isSlice9ScaledSprite: boolean=false;
238
- public avm1Symbol: any;
239
- public isAVMScene: boolean=false;
240
-
241
- public partitionClass: IPartitionClass;
242
-
243
- // this is needed for AVM1 - todo: maybe do this on adapters ?
244
- public placeObjectTag: any=null;
245
- public getScriptPrecedence(): number[] {
246
- if (!this._parent) {
247
- return [];
248
- }
249
- const result = this._parent.getScriptPrecedence();
250
- if (this.placeObjectTag) {
251
- result.push(this.placeObjectTag.actionBlocksPrecedence);
252
- }
253
- return result;
254
- }
255
-
256
- public getMouseCursor(): string {
257
- return 'initial';
258
- }
259
-
260
- public get tabEnabled(): boolean {
261
- return this._tabEnabled;
262
- }
263
-
264
- public set tabEnabled(value: boolean) {
265
- this._tabEnabled = value;
266
- }
267
-
268
- public get tabIndex(): number {
269
- return this._tabIndex;
270
- }
271
-
272
- public set tabIndex(value: number) {
273
- this._tabIndex = value;
274
- }
275
-
276
- public get isInFocus(): boolean {
277
- return this._isInFocus;
278
- }
279
-
280
- public set isInFocus(value: boolean) {
281
- this._isInFocus = value;
282
- }
283
-
284
- public setFocus(value: boolean, fromMouseDown: boolean = false, sendSoftKeyEvent: boolean = true) {
285
- if (this._isInFocus == value)
286
- return;
287
- this._isInFocus = value;
288
- }
289
-
290
- /**
291
- *
292
- */
293
- public get alignmentMode(): AlignmentMode {
294
- return this._alignmentMode;
295
- }
296
-
297
- public set alignmentMode(value: AlignmentMode) {
298
- if (this._alignmentMode == value)
299
- return;
300
-
301
- this._alignmentMode = value;
302
-
303
- this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
304
- }
305
-
306
- /**
307
- * Indicates the alpha transparency value of the object specified. Valid
308
- * values are 0(fully transparent) to 1(fully opaque). The default value is
309
- * 1. Display objects with <code>alpha</code> set to 0 <i>are</i> active,
310
- * even though they are invisible.
311
- */
312
- public get alpha(): number {
313
- return this._transform.colorTransform.alphaMultiplier;
314
- }
315
-
316
- public set alpha(value: number) {
317
- this._transform.colorTransform.alphaMultiplier = value;
318
-
319
- this._transform.invalidateColorTransform();
320
- }
321
-
322
- /**
323
- * A value from the BlendMode class that specifies which blend mode to use. A
324
- * bitmap can be drawn internally in two ways. If you have a blend mode
325
- * enabled or an external clipping mask, the bitmap is drawn by adding a
326
- * bitmap-filled square shape to the vector render. If you attempt to set
327
- * this property to an invalid value, Flash runtimes set the value to
328
- * <code>BlendMode.NORMAL</code>.
329
- *
330
- * <p>The <code>blendMode</code> property affects each pixel of the display
331
- * object. Each pixel is composed of three constituent colors(red, green,
332
- * and blue), and each constituent color has a value between 0x00 and 0xFF.
333
- * Flash Player or Adobe AIR compares each constituent color of one pixel in
334
- * the movie clip with the corresponding color of the pixel in the
335
- * background. For example, if <code>blendMode</code> is set to
336
- * <code>BlendMode.LIGHTEN</code>, Flash Player or Adobe AIR compares the red
337
- * value of the display object with the red value of the background, and uses
338
- * the lighter of the two as the value for the red component of the displayed
339
- * color.</p>
340
- *
341
- * <p>The following table describes the <code>blendMode</code> settings. The
342
- * BlendMode class defines string values you can use. The illustrations in
343
- * the table show <code>blendMode</code> values applied to a circular display
344
- * object(2) superimposed on another display object(1).</p>
345
- */
346
-
347
- public _blendMode: BlendMode = BlendMode.LAYER;
348
-
349
- public set blendMode(v: BlendMode) {
350
- if (this._blendMode === v) {
351
- return;
352
- }
353
-
354
- this._blendMode = v;
355
- if (v === BlendMode.OVERLAY) {
356
- this._transform.invalidateColorTransform();
357
- }
358
- }
359
-
360
- public get blendMode() {
361
- if (!Settings.USE_UNSAFE_BLENDS) {
362
- return '';
363
- }
364
-
365
- if (Settings.REMAP_BLEND_MODE) {
366
- return Settings.BLEND_MODE_REMAP_TABLE[<string> this._blendMode] || this._blendMode;
367
- }
368
-
369
- return this._blendMode;
370
- }
371
-
372
- /**
373
- *
374
- */
375
- public get defaultBoundingVolume(): BoundingVolumeType {
376
- return this._defaultBoundingVolume;
377
- }
378
-
379
- public set defaultBoundingVolume(value: BoundingVolumeType) {
380
- if (this._defaultBoundingVolume == value)
381
- return;
382
-
383
- this._defaultBoundingVolume = value;
384
-
385
- if (this._boundsPrimitive) {
386
- this._boundsPrimitive.dispose();
387
- this._boundsPrimitive = null;
388
- }
389
-
390
- this.invalidate();
391
- }
392
-
393
- /**
394
- * If set to <code>true</code>, NME will use the software renderer to cache
395
- * an internal bitmap representation of the display object. For native targets,
396
- * this is often much slower than the default hardware renderer. When you
397
- * are using the Flash target, this caching may increase performance for display
398
- * objects that contain complex vector content.
399
- *
400
- * <p>All vector data for a display object that has a cached bitmap is drawn
401
- * to the bitmap instead of the main display. If
402
- * <code>cacheAsBitmapMatrix</code> is null or unsupported, the bitmap is
403
- * then copied to the main display as unstretched, unrotated pixels snapped
404
- * to the nearest pixel boundaries. Pixels are mapped 1 to 1 with the parent
405
- * object. If the bounds of the bitmap change, the bitmap is recreated
406
- * instead of being stretched.</p>
407
- *
408
- * <p>If <code>cacheAsBitmapMatrix</code> is non-null and supported, the
409
- * object is drawn to the off-screen bitmap using that matrix and the
410
- * stretched and/or rotated results of that rendering are used to draw the
411
- * object to the main display.</p>
412
- *
413
- * <p>No internal bitmap is created unless the <code>BBitmap</code>
414
- * property is set to <code>true</code>.</p>
415
- *
416
- * <p>After you set the <code>cacheAsBitmap</code> property to
417
- * <code>true</code>, the rendering does not change, however the display
418
- * object performs pixel snapping automatically. The animation speed can be
419
- * significantly faster depending on the complexity of the vector content.
420
- * </p>
421
- *
422
- * <p>The <code>cacheAsBitmap</code> property is automatically set to
423
- * <code>true</code> whenever you apply a filter to a display object(when
424
- * its <code>filter</code> array is not empty), and if a display object has a
425
- * filter applied to it, <code>cacheAsBitmap</code> is reported as
426
- * <code>true</code> for that display object, even if you set the property to
427
- * <code>false</code>. If you clear all filters for a display object, the
428
- * <code>cacheAsBitmap</code> setting changes to what it was last set to.</p>
429
- *
430
- * <p>A display object does not use a bitmap even if the
431
- * <code>cacheAsBitmap</code> property is set to <code>true</code> and
432
- * instead renders from vector data in the following cases:</p>
433
- *
434
- * <ul>
435
- * <li>The bitmap is too large. In AIR 1.5 and Flash Player 10, the maximum
436
- * size for a bitmap image is 8,191 pixels in width or height, and the total
437
- * number of pixels cannot exceed 16,777,215 pixels.(So, if a bitmap image
438
- * is 8,191 pixels wide, it can only be 2,048 pixels high.) In Flash Player 9
439
- * and earlier, the limitation is is 2880 pixels in height and 2,880 pixels
440
- * in width.</li>
441
- * <li>The bitmap fails to allocate(out of memory error). </li>
442
- * </ul>
443
- *
444
- * <p>The <code>cacheAsBitmap</code> property is best used with movie clips
445
- * that have mostly static content and that do not scale and rotate
446
- * frequently. With such movie clips, <code>cacheAsBitmap</code> can lead to
447
- * performance increases when the movie clip is translated(when its <i>x</i>
448
- * and <i>y</i> position is changed).</p>
449
- */
450
- private _bitmapCache: boolean;
451
- public get cacheAsBitmap() {
452
- return this._bitmapCache;
453
- }
454
-
455
- public set cacheAsBitmap(v: boolean) {
456
- if (v === this._bitmapCache) {
457
- return;
458
- }
459
-
460
- if (!Settings.USE_UNSAFE_CACHE_AS_BITMAP) {
461
- return;
462
- }
463
-
464
- v && console.warn(
465
- '[@scene/DisplayObject] Unsafe cacheAsBitmap is enabled!' +
466
- 'You can disable it by `Settings.USE_UNSAFE_CACHE_AS_BITMAP = false`'
467
- ,this.id
468
- );
469
-
470
- this._bitmapCache = v;
471
- }
472
-
473
- /**
474
- *
475
- */
476
- public castsShadows: boolean = true;
477
-
478
- /**
479
- * Defines the rotation of the 3d object as a <code>Vector3D</code>
480
- * object containing euler angles for rotation around x, y and z axis.
481
- */
482
- public get eulers(): Vector3D {
483
- if (!this._eulers)
484
- this._eulers = new Vector3D();
485
-
486
- this._eulers.x = this.rotationX;
487
- this._eulers.y = this.rotationY;
488
- this._eulers.z = this.rotationZ;
489
-
490
- return this._eulers;
491
- }
492
-
493
- public set eulers(value: Vector3D) {
494
- // previously this was using the setters for rotationX etc
495
- // but because this will convert from radians to degree, i changed it to update directly
496
- this._transform.rotation.x = value.x;
497
- this._transform.rotation.y = value.y;
498
- this._transform.rotation.z = value.z;
499
-
500
- this._transform.invalidateMatrix3D();
501
- }
502
-
503
- /**
504
- * An object that can contain any extra data.
505
- */
506
- public extra: Object;
507
-
508
- /**
509
- * An indexed array that contains each filter object currently associated
510
- * with the display object. The flash.filters package contains several
511
- * classes that define specific filters you can use.
512
- *
513
- * <p>Filters can be applied in Flash Professional at design time, or at run
514
- * time by using ActionScript code. To apply a filter by using ActionScript,
515
- * you must make a temporary copy of the entire <code>filters</code> array,
516
- * modify the temporary array, then assign the value of the temporary array
517
- * back to the <code>filters</code> array. You cannot directly add a new
518
- * filter object to the <code>filters</code> array.</p>
519
- *
520
- * <p>To add a filter by using ActionScript, perform the following steps
521
- * (assume that the target display object is named
522
- * <code>myDisplayObject</code>):</p>
523
- *
524
- * <ol>
525
- * <li>Create a new filter object by using the constructor method of your
526
- * chosen filter class.</li>
527
- * <li>Assign the value of the <code>myDisplayObject.filters</code> array
528
- * to a temporary array, such as one named <code>myFilters</code>.</li>
529
- * <li>Add the new filter object to the <code>myFilters</code> temporary
530
- * array.</li>
531
- * <li>Assign the value of the temporary array to the
532
- * <code>myDisplayObject.filters</code> array.</li>
533
- * </ol>
534
- *
535
- * <p>If the <code>filters</code> array is undefined, you do not need to use
536
- * a temporary array. Instead, you can directly assign an array literal that
537
- * contains one or more filter objects that you create. The first example in
538
- * the Examples section adds a drop shadow filter by using code that handles
539
- * both defined and undefined <code>filters</code> arrays.</p>
540
- *
541
- * <p>To modify an existing filter object, you must use the technique of
542
- * modifying a copy of the <code>filters</code> array:</p>
543
- *
544
- * <ol>
545
- * <li>Assign the value of the <code>filters</code> array to a temporary
546
- * array, such as one named <code>myFilters</code>.</li>
547
- * <li>Modify the property by using the temporary array,
548
- * <code>myFilters</code>. For example, to set the quality property of the
549
- * first filter in the array, you could use the following code:
550
- * <code>myFilters[0].quality = 1;</code></li>
551
- * <li>Assign the value of the temporary array to the <code>filters</code>
552
- * array.</li>
553
- * </ol>
554
- *
555
- * <p>At load time, if a display object has an associated filter, it is
556
- * marked to cache itself as a transparent bitmap. From this point forward,
557
- * as long as the display object has a valid filter list, the player caches
558
- * the display object as a bitmap. This source bitmap is used as a source
559
- * image for the filter effects. Each display object usually has two bitmaps:
560
- * one with the original unfiltered source display object and another for the
561
- * final image after filtering. The final image is used when rendering. As
562
- * long as the display object does not change, the final image does not need
563
- * updating.</p>
564
- *
565
- * <p>The flash.filters package includes classes for filters. For example, to
566
- * create a DropShadow filter, you would write:</p>
567
- *
568
- * @throws ArgumentError When <code>filters</code> includes a ShaderFilter
569
- * and the shader output type is not compatible with
570
- * this operation(the shader must specify a
571
- * <code>pixel4</code> output).
572
- * @throws ArgumentError When <code>filters</code> includes a ShaderFilter
573
- * and the shader doesn't specify any image input or
574
- * the first input is not an <code>image4</code> input.
575
- * @throws ArgumentError When <code>filters</code> includes a ShaderFilter
576
- * and the shader specifies an image input that isn't
577
- * provided.
578
- * @throws ArgumentError When <code>filters</code> includes a ShaderFilter, a
579
- * ByteArray or Vector.<Number> instance as a shader
580
- * input, and the <code>width</code> and
581
- * <code>height</code> properties aren't specified for
582
- * the ShaderInput object, or the specified values
583
- * don't match the amount of data in the input data.
584
- * See the <code>ShaderInput.input</code> property for
585
- * more information.
586
- */
587
-
588
- private _filters: Array<IFilter> = null;
589
-
590
- public set filters(v: Array<IFilter>) {
591
- if (!Settings.USE_UNSAFE_FILTERS) {
592
- return;
593
- }
594
-
595
- this._filters = v;
596
- this._invalidateStyle();
597
- }
598
-
599
- public get filters() {
600
- return this._filters;
601
- }
602
-
603
- public updateFilters(_newFilters: IFilter[]) {
604
- console.warn('[scene/DisplayObject] - updateFilters is just a stub');
605
- }
606
-
607
- /**
608
- * Indicates the instance container index of the DisplayObject. The object can be
609
- * identified in the child list of its parent display object container by
610
- * calling the <code>getChildByIndex()</code> method of the display object
611
- * container.
612
- *
613
- * <p>If the DisplayObject has no parent container, index defaults to 0.</p>
614
- */
615
- public get index(): number {
616
- if (this._parent)
617
- return this._parent.getChildIndex(this);
618
-
619
- return 0;
620
- }
621
-
622
- /**
623
- * Returns a LoaderInfo object containing information about loading the file
624
- * to which this display object belongs. The <code>loaderInfo</code> property
625
- * is defined only for the root display object of a SWF file or for a loaded
626
- * Bitmap(not for a Bitmap that is drawn with ActionScript). To find the
627
- * <code>loaderInfo</code> object associated with the SWF file that contains
628
- * a display object named <code>myDisplayObject</code>, use
629
- * <code>myDisplayObject.root.loaderInfo</code>.
630
- *
631
- * <p>A large SWF file can monitor its download by calling
632
- * <code>this.root.loaderInfo.addEventListener(Event.COMPLETE,
633
- * func)</code>.</p>
634
- */
635
- public get loader(): Loader {
636
- return this._loader;
637
- }
638
-
639
- /**
640
- * The calling display object is masked by the specified <code>mask</code>
641
- * object. To ensure that masking works when the Stage is scaled, the
642
- * <code>mask</code> display object must be in an active part of the display
643
- * list. The <code>mask</code> object itself is not drawn. Set
644
- * <code>mask</code> to <code>null</code> to remove the mask.
645
- *
646
- * <p>To be able to scale a mask object, it must be on the display list. To
647
- * be able to drag a mask Sprite object(by calling its
648
- * <code>startDrag()</code> method), it must be on the display list. To call
649
- * the <code>startDrag()</code> method for a mask sprite based on a
650
- * <code>mouseDown</code> event being dispatched by the sprite, set the
651
- * sprite's <code>buttonMode</code> property to <code>true</code>.</p>
652
- *
653
- * <p>When display objects are cached by setting the
654
- * <code>cacheAsBitmap</code> property to <code>true</code> an the
655
- * <code>cacheAsBitmapMatrix</code> property to a Matrix object, both the
656
- * mask and the display object being masked must be part of the same cached
657
- * bitmap. Thus, if the display object is cached, then the mask must be a
658
- * child of the display object. If an ancestor of the display object on the
659
- * display list is cached, then the mask must be a child of that ancestor or
660
- * one of its descendents. If more than one ancestor of the masked object is
661
- * cached, then the mask must be a descendent of the cached container closest
662
- * to the masked object in the display list.</p>
663
- *
664
- * <p><b>Note:</b> A single <code>mask</code> object cannot be used to mask
665
- * more than one calling display object. When the <code>mask</code> is
666
- * assigned to a second display object, it is removed as the mask of the
667
- * first object, and that object's <code>mask</code> property becomes
668
- * <code>null</code>.</p>
669
- */
670
- public set mask(value: DisplayObject) {
671
- this.scriptMask = value;
672
- }
673
-
674
- public get maskMode(): boolean {
675
- return this._maskMode;
676
- }
677
-
678
- public set maskMode(value: boolean) {
679
- if (this._maskMode == value)
680
- return;
681
-
682
- this._maskMode = value;
683
-
684
- this._maskId = value ? this.id : -1;
685
-
686
- this._updateMaskMode();
687
- }
688
-
689
- public get pickObject(): DisplayObjectContainer {
690
- return this._pickObject;
691
- }
692
-
693
- public set pickObject(value: DisplayObjectContainer) {
694
- if (this._pickObject == value)
695
- return;
696
-
697
- this._pickObject = value.pickObjectFromTimeline ? value.clone() : value;
698
-
699
- if (this._pickObject) {
700
- this._pickObject.mouseChildren = false;
701
- this._pickObject.mouseEnabled = false;
702
- }
703
- }
704
-
705
- /**
706
- * Specifies whether this object receives mouse, or other user input,
707
- * messages. The default value is <code>true</code>, which means that by
708
- * default any InteractiveObject instance that is on the display list
709
- * receives mouse events or other user input events. If
710
- * <code>mouseEnabled</code> is set to <code>false</code>, the instance does
711
- * not receive any mouse events(or other user input events like keyboard
712
- * events). Any children of this instance on the display list are not
713
- * affected. To change the <code>mouseEnabled</code> behavior for all
714
- * children of an object on the display list, use
715
- * <code>flash.display.DisplayObjectContainer.mouseChildren</code>.
716
- *
717
- * <p> No event is dispatched by setting this property. You must use the
718
- * <code>addEventListener()</code> method to create interactive
719
- * functionality.</p>
720
- */
721
- public get mouseEnabled(): boolean {
722
- return this._mouseEnabled;
723
- }
724
-
725
- public set mouseEnabled(value: boolean) {
726
- if (this._mouseEnabled == value)
727
- return;
728
-
729
- this._mouseEnabled = value;
730
- }
731
-
732
- /**
733
- * Indicates the x coordinate of the mouse or user input device position, in
734
- * pixels.
735
- *
736
- * <p><b>Note</b>: For a DisplayObject that has been rotated, the returned x
737
- * coordinate will reflect the non-rotated object.</p>
738
- */
739
- public get mouseX(): number {
740
- return this._mouseX;
741
- }
742
-
743
- /**
744
- * Indicates the y coordinate of the mouse or user input device position, in
745
- * pixels.
746
- *
747
- * <p><b>Note</b>: For a DisplayObject that has been rotated, the returned y
748
- * coordinate will reflect the non-rotated object.</p>
749
- */
750
- public get mouseY(): number {
751
- return this._mouseY;
752
- }
753
-
754
- /**
755
- * Indicates the instance name of the DisplayObject. The object can be
756
- * identified in the child list of its parent display object container by
757
- * calling the <code>getChildByName()</code> method of the display object
758
- * container.
759
- *
760
- * @throws IllegalOperationError If you are attempting to set this property
761
- * on an object that was placed on the timeline
762
- * in the Flash authoring tool.
763
- */
764
- public get name(): string {
765
- return this._pName ? this._pName : '';
766
- }
767
-
768
- public set name(value: string) {
769
- this._pName = value;
770
- }
771
-
772
- /**
773
- *
774
- */
775
- public orientationMode: OrientationMode = OrientationMode.DEFAULT;
776
-
777
- /**
778
- * Indicates the DisplayObjectContainer object that contains this display
779
- * object. Use the <code>parent</code> property to specify a relative path to
780
- * display objects that are above the current display object in the display
781
- * list hierarchy.
782
- *
783
- * <p>You can use <code>parent</code> to move up multiple levels in the
784
- * display list as in the following:</p>
785
- *
786
- * @throws SecurityError The parent display object belongs to a security
787
- * sandbox to which you do not have access. You can
788
- * avoid this situation by having the parent movie call
789
- * the <code>Security.allowDomain()</code> method.
790
- */
791
- public get parent(): DisplayObjectContainer {
792
- return this._parent;
793
- }
794
-
795
- /**
796
- * Defines the local point around which the object rotates.
797
- */
798
- public get registrationPoint(): Vector3D {
799
- if (this._registrationMatrix3D)
800
- return new Vector3D(
801
- -this._registrationMatrix3D._rawData[12] * this.scaleX,
802
- -this._registrationMatrix3D._rawData[13] * this.scaleY,
803
- -this._registrationMatrix3D._rawData[14] * this.scaleZ);
804
-
805
- return null;
806
- }
807
-
808
- public set registrationPoint(value: Vector3D) {
809
- if (!value) {
810
- if (!this._registrationMatrix3D)
811
- return;
812
-
813
- this._registrationMatrix3D._rawData[12] = 0;
814
- this._registrationMatrix3D._rawData[13] = 0;
815
- this._registrationMatrix3D._rawData[14] = 0;
816
-
817
- if (this._registrationMatrix3D.isIdentity())
818
- this._registrationMatrix3D = null;
819
- } else {
820
- if (!this._registrationMatrix3D)
821
- this._registrationMatrix3D = new Matrix3D();
822
-
823
- this._registrationMatrix3D._rawData[12] = -value.x / this._transform.scale.x;
824
- this._registrationMatrix3D._rawData[13] = -value.y / this._transform.scale.y;
825
- this._registrationMatrix3D._rawData[14] = -value.z / this._transform.scale.z;
826
- }
827
-
828
- this._registrationMatrix3D!.invalidatePosition();
829
-
830
- this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
831
- }
832
-
833
- /**
834
- * Defines the local scale.
835
- */
836
- public get registrationScale(): Vector3D {
837
- if (this._registrationMatrix3D)
838
- return new Vector3D(
839
- this._registrationMatrix3D._rawData[0],
840
- this._registrationMatrix3D._rawData[5],
841
- this._registrationMatrix3D._rawData[10]);
842
-
843
- return null;
844
- }
845
-
846
- public set registrationScale(value: Vector3D) {
847
- if (!value) {
848
- if (!this._registrationMatrix3D)
849
- return;
850
-
851
- this._registrationMatrix3D._rawData[0] = 1;
852
- this._registrationMatrix3D._rawData[5] = 1;
853
- this._registrationMatrix3D._rawData[10] = 1;
854
-
855
- if (this._registrationMatrix3D.isIdentity())
856
- this._registrationMatrix3D = null;
857
- } else {
858
- if (!this._registrationMatrix3D)
859
- this._registrationMatrix3D = new Matrix3D();
860
-
861
- this._registrationMatrix3D._rawData[0] = value.x;
862
- this._registrationMatrix3D._rawData[5] = value.y;
863
- this._registrationMatrix3D._rawData[10] = value.z;
864
- }
865
-
866
- this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
867
- }
868
-
869
- /**
870
- * For a display object in a loaded SWF file, the <code>root</code> property
871
- * is the top-most display object in the portion of the display list's tree
872
- * structure represented by that SWF file. For a Bitmap object representing a
873
- * loaded image file, the <code>root</code> property is the Bitmap object
874
- * itself. For the instance of the main class of the first SWF file loaded,
875
- * the <code>root</code> property is the display object itself. The
876
- * <code>root</code> property of the Scene object is the Scene object itself.
877
- * The <code>root</code> property is set to <code>null</code> for any display
878
- * object that has not been added to the display list, unless it has been
879
- * added to a display object container that is off the display list but that
880
- * is a child of the top-most display object in a loaded SWF file.
881
- *
882
- * <p>For example, if you create a new Sprite object by calling the
883
- * <code>Sprite()</code> constructor method, its <code>root</code> property
884
- * is <code>null</code> until you add it to the display list(or to a display
885
- * object container that is off the display list but that is a child of the
886
- * top-most display object in a SWF file).</p>
887
- *
888
- * <p>For a loaded SWF file, even though the Loader object used to load the
889
- * file may not be on the display list, the top-most display object in the
890
- * SWF file has its <code>root</code> property set to itself. The Loader
891
- * object does not have its <code>root</code> property set until it is added
892
- * as a child of a display object for which the <code>root</code> property is
893
- * set.</p>
894
- */
895
- public get root(): DisplayObjectContainer {
896
- return this._root;
897
- }
898
-
899
- /**
900
- * Indicates the rotation of the DisplayObject instance, in degrees, from its
901
- * original orientation. Values from 0 to 180 represent clockwise rotation;
902
- * values from 0 to -180 represent counterclockwise rotation. Values outside
903
- * this range are added to or subtracted from 360 to obtain a value within
904
- * the range. For example, the statement <code>my_video.rotation = 450</code>
905
- * is the same as <code> my_video.rotation = 90</code>.
906
- */
907
- public rotation: number; //TODO
908
-
909
- /**
910
- * Indicates the x-axis rotation of the DisplayObject instance, in degrees,
911
- * from its original orientation relative to the 3D parent container. Values
912
- * from 0 to 180 represent clockwise rotation; values from 0 to -180
913
- * represent counterclockwise rotation. Values outside this range are added
914
- * to or subtracted from 360 to obtain a value within the range.
915
- */
916
- public get rotationX(): number {
917
- return this._transform.rotation.x * MathConsts.RADIANS_TO_DEGREES;
918
- }
919
-
920
- public set rotationX(val: number) {
921
- if (this.rotationX == val)
922
- return;
923
-
924
- this._transform.rotation.x = val * MathConsts.DEGREES_TO_RADIANS;
925
-
926
- this._transform.invalidateMatrix3D();
927
- }
928
-
929
- /**
930
- * Indicates the y-axis rotation of the DisplayObject instance, in degrees,
931
- * from its original orientation relative to the 3D parent container. Values
932
- * from 0 to 180 represent clockwise rotation; values from 0 to -180
933
- * represent counterclockwise rotation. Values outside this range are added
934
- * to or subtracted from 360 to obtain a value within the range.
935
- */
936
- public get rotationY(): number {
937
- return this._transform.rotation.y * MathConsts.RADIANS_TO_DEGREES;
938
- }
939
-
940
- public set rotationY(val: number) {
941
- if (this.rotationY == val)
942
- return;
943
-
944
- this._transform.rotation.y = val * MathConsts.DEGREES_TO_RADIANS;
945
-
946
- this._transform.invalidateMatrix3D();
947
- }
948
-
949
- /**
950
- * Indicates the z-axis rotation of the DisplayObject instance, in degrees,
951
- * from its original orientation relative to the 3D parent container. Values
952
- * from 0 to 180 represent clockwise rotation; values from 0 to -180
953
- * represent counterclockwise rotation. Values outside this range are added
954
- * to or subtracted from 360 to obtain a value within the range.
955
- */
956
- public get rotationZ(): number {
957
- return this._transform.rotation.z * MathConsts.RADIANS_TO_DEGREES;
958
- }
959
-
960
- public set rotationZ(val: number) {
961
- if (this.rotationZ == val)
962
- return;
963
-
964
- this._transform.rotation.z = val * MathConsts.DEGREES_TO_RADIANS;
965
-
966
- this._transform.invalidateMatrix3D();
967
- }
968
-
969
- /**
970
- * The current scaling grid that is in effect. If set to <code>null</code>,
971
- * the entire display object is scaled normally when any scale transformation
972
- * is applied.
973
- *
974
- * <p>When you define the <code>scale9Grid</code> property, the display
975
- * object is divided into a grid with nine regions based on the
976
- * <code>scale9Grid</code> rectangle, which defines the center region of the
977
- * grid. The eight other regions of the grid are the following areas: </p>
978
- *
979
- * <ul>
980
- * <li>The upper-left corner outside of the rectangle</li>
981
- * <li>The area above the rectangle </li>
982
- * <li>The upper-right corner outside of the rectangle</li>
983
- * <li>The area to the left of the rectangle</li>
984
- * <li>The area to the right of the rectangle</li>
985
- * <li>The lower-left corner outside of the rectangle</li>
986
- * <li>The area below the rectangle</li>
987
- * <li>The lower-right corner outside of the rectangle</li>
988
- * </ul>
989
- *
990
- * <p>You can think of the eight regions outside of the center(defined by
991
- * the rectangle) as being like a picture frame that has special rules
992
- * applied to it when scaled.</p>
993
- *
994
- * <p>When the <code>scale9Grid</code> property is set and a display object
995
- * is scaled, all text and gradients are scaled normally; however, for other
996
- * types of objects the following rules apply:</p>
997
- *
998
- * <ul>
999
- * <li>Content in the center region is scaled normally. </li>
1000
- * <li>Content in the corners is not scaled. </li>
1001
- * <li>Content in the top and bottom regions is scaled horizontally only.
1002
- * Content in the left and right regions is scaled vertically only.</li>
1003
- * <li>All fills(including bitmaps, video, and gradients) are stretched to
1004
- * fit their shapes.</li>
1005
- * </ul>
1006
- *
1007
- * <p>If a display object is rotated, all subsequent scaling is normal(and
1008
- * the <code>scale9Grid</code> property is ignored).</p>
1009
- *
1010
- * <p>For example, consider the following display object and a rectangle that
1011
- * is applied as the display object's <code>scale9Grid</code>:</p>
1012
- *
1013
- * <p>A common use for setting <code>scale9Grid</code> is to set up a display
1014
- * object to be used as a component, in which edge regions retain the same
1015
- * width when the component is scaled.</p>
1016
- *
1017
- * @throws ArgumentError If you pass an invalid argument to the method.
1018
- */
1019
- public get scale9Grid(): Rectangle {
1020
- return this._scale9Grid;
1021
- }
1022
-
1023
- public set scale9Grid(value: Rectangle) {
1024
- this._scale9Grid = value;
1025
-
1026
- this._invalidateHierarchicalProperty(HierarchicalProperty.SCALE9);
1027
- }
1028
-
1029
- /**
1030
- * Indicates the horizontal scale(percentage) of the object as applied from
1031
- * the registration point. The default registration point is(0,0). 1.0
1032
- * equals 100% scale.
1033
- *
1034
- * <p>Scaling the local coordinate system changes the <code>x</code> and
1035
- * <code>y</code> property values, which are defined in whole pixels. </p>
1036
- */
1037
- public get scaleX(): number {
1038
- return this._transform.scale.x;
1039
- }
1040
-
1041
- public set scaleX(val: number) {
1042
- //this._updateAbsoluteDimension();
1043
-
1044
- this._setScaleX(val);
1045
- }
1046
-
1047
- /**
1048
- * Indicates the vertical scale(percentage) of an object as applied from the
1049
- * registration point of the object. The default registration point is(0,0).
1050
- * 1.0 is 100% scale.
1051
- *
1052
- * <p>Scaling the local coordinate system changes the <code>x</code> and
1053
- * <code>y</code> property values, which are defined in whole pixels. </p>
1054
- */
1055
- public get scaleY(): number {
1056
- return this._transform.scale.y;
1057
- }
1058
-
1059
- public set scaleY(val: number) {
1060
- //this._updateAbsoluteDimension();
1061
-
1062
- this._setScaleY(val);
1063
- }
1064
-
1065
- /**
1066
- * Indicates the depth scale(percentage) of an object as applied from the
1067
- * registration point of the object. The default registration point is(0,0).
1068
- * 1.0 is 100% scale.
1069
- *
1070
- * <p>Scaling the local coordinate system changes the <code>x</code>,
1071
- * <code>y</code> and <code>z</code> property values, which are defined in
1072
- * whole pixels. </p>
1073
- */
1074
- public get scaleZ(): number {
1075
- return this._transform.scale.z;
1076
- }
1077
-
1078
- public set scaleZ(val: number) {
1079
- //this._updateAbsoluteDimension();
1080
-
1081
- this._setScaleZ(val);
1082
- }
1083
-
1084
- /**
1085
- * Indicates the horizontal skew(angle) of the object as applied from
1086
- * the registration point. The default registration point is(0,0).
1087
- */
1088
- public get skewX(): number {
1089
- return this._transform.skew.x;
1090
- }
1091
-
1092
- public set skewX(val: number) {
1093
- if (this.skewX == val)
1094
- return;
1095
-
1096
- this._transform.skew.x = val;
1097
-
1098
- this._transform.invalidateMatrix3D();
1099
- }
1100
-
1101
- /**
1102
- * Indicates the vertical skew(angle) of an object as applied from the
1103
- * registration point of the object. The default registration point is(0,0).
1104
- */
1105
- public get skewY(): number {
1106
- return this._transform.skew.y;
1107
- }
1108
-
1109
- public set skewY(val: number) {
1110
- if (this.skewY == val)
1111
- return;
1112
-
1113
- this._transform.skew.y = val;
1114
-
1115
- this._transform.invalidateMatrix3D();
1116
- }
1117
-
1118
- /**
1119
- * Indicates the depth skew(angle) of an object as applied from the
1120
- * registration point of the object. The default registration point is(0,0).
1121
- */
1122
- public get skewZ(): number {
1123
- return this._transform.skew.z;
1124
- }
1125
-
1126
- public set skewZ(val: number) {
1127
- if (this.skewZ == val)
1128
- return;
1129
-
1130
- this._transform.skew.z = val;
1131
-
1132
- this._transform.invalidateMatrix3D();
1133
- }
1134
-
1135
- /**
1136
- * The scroll rectangle bounds of the display object. The display object is
1137
- * cropped to the size defined by the rectangle, and it scrolls within the
1138
- * rectangle when you change the <code>x</code> and <code>y</code> properties
1139
- * of the <code>scrollRect</code> object.
1140
- *
1141
- * <p>The properties of the <code>scrollRect</code> Rectangle object use the
1142
- * display object's coordinate space and are scaled just like the overall
1143
- * display object. The corner bounds of the cropped window on the scrolling
1144
- * display object are the origin of the display object(0,0) and the point
1145
- * defined by the width and height of the rectangle. They are not centered
1146
- * around the origin, but use the origin to define the upper-left corner of
1147
- * the area. A scrolled display object always scrolls in whole pixel
1148
- * increments. </p>
1149
- *
1150
- * <p>You can scroll an object left and right by setting the <code>x</code>
1151
- * property of the <code>scrollRect</code> Rectangle object. You can scroll
1152
- * an object up and down by setting the <code>y</code> property of the
1153
- * <code>scrollRect</code> Rectangle object. If the display object is rotated
1154
- * 90° and you scroll it left and right, the display object actually scrolls
1155
- * up and down.</p>
1156
- */
1157
- public get scrollRect(): Rectangle {
1158
- return this._scrollRect;
1159
- }
1160
-
1161
- public set scrollRect(value: Rectangle) {
1162
- // @todo: check if rectangle has same values as previous
1163
- //if (this._scrollRect == value)
1164
- // return;
1165
-
1166
- this._scrollRect = value;
1167
-
1168
- if (!value && this._scrollRectPrimitive) {
1169
- const idx = this.masks.indexOf(this._scrollRectPrimitive);
1170
- this.masks.splice(idx, 1);
1171
- this._scrollRectPrimitive = null;
1172
- }
1173
-
1174
- this._transform.invalidatePosition();
1175
- this._scrollRectPrimitiveDirty = true;
1176
- }
1177
-
1178
- /**
1179
- *
1180
- */
1181
- public get material(): IMaterial {
1182
- return this._material;
1183
- }
1184
-
1185
- public set material(value: IMaterial) {
1186
- if (this._material == value)
1187
- return;
1188
-
1189
- this._material = value;
1190
-
1191
- this._invalidateMaterial();
1192
- }
1193
-
1194
- /**
1195
- *
1196
- */
1197
- public get style(): Style {
1198
- return this._style;
1199
- }
1200
-
1201
- public set style(value: Style) {
1202
- if (this._style == value)
1203
- return;
1204
-
1205
- if (this._style) {
1206
- this._style.removeEventListener(StyleEvent.INVALIDATE_PROPERTIES, this._onInvalidatePropertiesDelegate);
1207
- this._style.removeEventListener(StyleEvent.INVALIDATE_IMAGES, this._onInvalidateImagesDelegate);
1208
- }
1209
-
1210
- this._style = value;
1211
-
1212
- if (this._style) {
1213
- this._style.addEventListener(StyleEvent.INVALIDATE_PROPERTIES, this._onInvalidatePropertiesDelegate);
1214
- this._style.addEventListener(StyleEvent.INVALIDATE_IMAGES, this._onInvalidateImagesDelegate);
1215
- }
1216
-
1217
- this._invalidateStyle();
1218
- }
1219
-
1220
- /**
1221
- *
1222
- */
1223
- public get boundsVisible(): boolean {
1224
- return this._boundsVisible;
1225
- }
1226
-
1227
- public set boundsVisible(value: boolean) {
1228
- if (value == this._boundsVisible)
1229
- return;
1230
-
1231
- this._boundsVisible = value;
1232
-
1233
- // if (this._boundsVisible && !this.partition)
1234
- // this.partition = BasicPartition.getRootPartition(this);
1235
-
1236
- this.invalidate();
1237
- }
1238
-
1239
- public getScrollRectPrimitive(): IPartitionContainer {
1240
- if (this._scrollRectPrimitiveDirty) {
1241
- this._scrollRectPrimitiveDirty = false;
1242
-
1243
- if (!this._scrollRectPrimitive) {
1244
- this._scrollRectPrimitive = new Sprite();
1245
- this._scrollRectPrimitive.maskMode = true;
1246
- if (!this.masks)
1247
- this.masks = [];
1248
- this.masks.push(this._scrollRectPrimitive);
1249
- }
1250
-
1251
- this._scrollRectPrimitive.graphics.clear();
1252
- this._scrollRectPrimitive.graphics.beginFill(0x0000ff, 1);
1253
- this._scrollRectPrimitive.graphics.drawRect(0,0,this._scrollRect.width,this._scrollRect.height);
1254
- this._scrollRectPrimitive.graphics.endFill();
1255
- }
1256
-
1257
- return this._scrollRectPrimitive;
1258
- }
1259
-
1260
- public getBoundsPrimitive(picker: BoundsPicker): IPartitionContainer {
1261
- if (this._boundsPrimitive == null) {
1262
- switch (this._defaultBoundingVolume) {
1263
- case BoundingVolumeType.BOX:
1264
- case BoundingVolumeType.BOX_BOUNDS:
1265
- case BoundingVolumeType.BOX_BOUNDS_FAST:
1266
- case BoundingVolumeType.BOX_FAST:
1267
- this._boundsPrefab = new PrimitiveCubePrefab(null, ElementsType.LINE);
1268
- this._boundsPrimitive = this._boundsPrefab.getNewObject();
1269
- break;
1270
- case BoundingVolumeType.SPHERE:
1271
- case BoundingVolumeType.SPHERE_BOUNDS:
1272
- case BoundingVolumeType.SPHERE_BOUNDS_FAST:
1273
- case BoundingVolumeType.SPHERE_FAST:
1274
- this._boundsPrefab = new PrimitiveSpherePrefab(null, ElementsType.LINE);
1275
- this._boundsPrimitive = this._boundsPrefab.getNewObject();
1276
- break;
1277
- default:
1278
- }
1279
-
1280
- this._boundsPrefabDirty = true;
1281
- }
1282
-
1283
- if (this._boundsPrefabDirty)
1284
- this._updateBoundsPrefab(picker);
1285
-
1286
- return this._boundsPrimitive;
1287
- }
1288
-
1289
- /**
1290
- * An object with properties pertaining to a display object's matrix, color
1291
- * transform, and pixel bounds. The specific properties - matrix,
1292
- * colorTransform, and three read-only properties
1293
- * (<code>concatenatedMatrix</code>, <code>concatenatedColorTransform</code>,
1294
- * and <code>pixelBounds</code>) - are described in the entry for the
1295
- * Transform class.
1296
- *
1297
- * <p>Each of the transform object's properties is itself an object. This
1298
- * concept is important because the only way to set new values for the matrix
1299
- * or colorTransform objects is to create a new object and copy that object
1300
- * into the transform.matrix or transform.colorTransform property.</p>
1301
- *
1302
- * <p>For example, to increase the <code>tx</code> value of a display
1303
- * object's matrix, you must make a copy of the entire matrix object, then
1304
- * copy the new object into the matrix property of the transform object:</p>
1305
- * <pre xml:space="preserve"><code> public myMatrix:Matrix =
1306
- * myDisplayObject.transform.matrix; myMatrix.tx += 10;
1307
- * myDisplayObject.transform.matrix = myMatrix; </code></pre>
1308
- *
1309
- * <p>You cannot directly set the <code>tx</code> property. The following
1310
- * code has no effect on <code>myDisplayObject</code>: </p>
1311
- * <pre xml:space="preserve"><code> myDisplayObject.transform.matrix.tx +=
1312
- * 10; </code></pre>
1313
- *
1314
- * <p>You can also copy an entire transform object and assign it to another
1315
- * display object's transform property. For example, the following code
1316
- * copies the entire transform object from <code>myOldDisplayObj</code> to
1317
- * <code>myNewDisplayObj</code>:</p>
1318
- * <code>myNewDisplayObj.transform = myOldDisplayObj.transform;</code>
1319
- *
1320
- * <p>The resulting display object, <code>myNewDisplayObj</code>, now has the
1321
- * same values for its matrix, color transform, and pixel bounds as the old
1322
- * display object, <code>myOldDisplayObj</code>.</p>
1323
- *
1324
- * <p>Note that AIR for TV devices use hardware acceleration, if it is
1325
- * available, for color transforms.</p>
1326
- */
1327
- public get transform(): Transform {
1328
- return this._transform;
1329
- }
1330
-
1331
- /**
1332
- * Whether or not the display object is visible. Display objects that are not
1333
- * visible are disabled. For example, if <code>visible=false</code> for an
1334
- * InteractiveObject instance, it cannot be clicked.
1335
- */
1336
- public get visible(): boolean {
1337
- return this._visible;
1338
- }
1339
-
1340
- public set visible(value: boolean) {
1341
- if (this._visible == value)
1342
- return;
1343
-
1344
- this._visible = value;
1345
-
1346
- this._invalidateHierarchicalProperty(HierarchicalProperty.VISIBLE);
1347
- }
1348
-
1349
- private _mergeMasks(timeline: Array<DisplayObject> | null, script: DisplayObject | null): Array<DisplayObject> {
1350
- if (!timeline && !script)
1351
- return;
1352
-
1353
- // we can not have mask array, create it
1354
- if (!timeline && script)
1355
- return [script];
1356
-
1357
- // and make sure that we not have same script mask in it
1358
- if (script && !timeline.includes(script))
1359
- timeline.push(script);
1360
-
1361
- return timeline;
1362
- }
1363
-
1364
- private _setMasks(masks: Array<DisplayObject> | null): void {
1365
- const oldMasks: Array<DisplayObject> = this._masks ? this._masks : [];
1366
-
1367
- if (masks) {
1368
-
1369
- // and make sure that mask mode enabled if not already
1370
- for (let i = masks.length - 1; i >= 0 ; i--) {
1371
- const mask = masks[i];
1372
-
1373
- if (!mask) {
1374
- console.warn('[DisplayObject] Timeline mask has null value, skipping it');
1375
- masks.splice(i, 1);
1376
- } else {
1377
- const index = oldMasks.indexOf(mask);
1378
- if (index != -1) {
1379
- oldMasks.splice(index, 1);
1380
- } else {
1381
- mask.maskMode = true;
1382
- }
1383
- }
1384
- }
1385
- }
1386
-
1387
- //set mask mode to false for old masks
1388
- for (let i = oldMasks.length - 1; i >= 0 ; i--)
1389
- oldMasks[i].maskMode = false;
1390
-
1391
- this._masks = masks;
1392
- }
1393
-
1394
- /**
1395
- *
1396
- * @param mask Masked element, that can be used from script without corruption of timeline mask
1397
- */
1398
- public set scriptMask(mask: DisplayObject | null) {
1399
- if (mask === this._scriptMask)
1400
- return;
1401
-
1402
- // remove older script mask, _mask array for this case can't be null
1403
- if (this._scriptMask) {
1404
- const index = this._masks.indexOf(this._scriptMask);
1405
-
1406
- if (index !== -1) {
1407
- this._masks.splice(index, 1);
1408
- this._scriptMask.maskMode = false;
1409
- }
1410
- }
1411
-
1412
- this._scriptMask = mask;
1413
-
1414
- this._masks = this._mergeMasks(this._masks, mask);
1415
-
1416
- if (mask)
1417
- mask.maskMode = true;
1418
-
1419
- this._invalidateHierarchicalProperty(HierarchicalProperty.MASKS);
1420
- }
1421
-
1422
- public get scriptMask() {
1423
- return this._scriptMask;
1424
- }
1425
-
1426
- /**
1427
- * Update mask from timeline and take account that can be a scriptMask
1428
- *
1429
- * @param masks Masks from timeline
1430
- */
1431
- public updateTimelineMask(masks: DisplayObject[] | null) {
1432
- this._setMasks(this._mergeMasks(masks, this._scriptMask));
1433
-
1434
- this._invalidateHierarchicalProperty(HierarchicalProperty.MASKS);
1435
- }
1436
-
1437
- public get masks(): Array<DisplayObject> {
1438
- return this._masks;
1439
- }
1440
-
1441
- /**
1442
- * @dangerous Note that we should not use this setter, right way to use `scriptMask` and `updateTimelineMask`
1443
- * @param value
1444
- */
1445
- public set masks(value: Array<DisplayObject>) {
1446
- if (this._masks == value)
1447
- return;
1448
-
1449
- // this is edge case, if we set masks direct,
1450
- // this means that we should reset _scriptMask when it not present in input mask
1451
- if (!value || !value.length) {
1452
- this._scriptMask = null;
1453
- } else {
1454
- const len = value.length;
1455
- let hasScriptMask = false;
1456
-
1457
- for (let i = 0; i < len; i++)
1458
- hasScriptMask = hasScriptMask || (value[i] === this._scriptMask);
1459
-
1460
- //if we had a script mask set but it wasn't present in the new masks value, remove it
1461
- if (this._scriptMask && !hasScriptMask)
1462
- this._scriptMask = null;
1463
- }
1464
-
1465
- this._setMasks(value);
1466
-
1467
- this._invalidateHierarchicalProperty(HierarchicalProperty.MASKS);
1468
- }
1469
-
1470
- /**
1471
- * Determines whether or not the children of the object are mouse, or user
1472
- * input device, enabled. If an object is enabled, a user can interact with
1473
- * it by using a mouse or user input device. The default is
1474
- * <code>true</code>.
1475
- *
1476
- * <p>This property is useful when you create a button with an instance of
1477
- * the Sprite class(instead of using the SimpleButton class). When you use a
1478
- * Sprite instance to create a button, you can choose to decorate the button
1479
- * by using the <code>addChild()</code> method to add additional Sprite
1480
- * instances. This process can cause unexpected behavior with mouse events
1481
- * because the Sprite instances you add as children can become the target
1482
- * object of a mouse event when you expect the parent instance to be the
1483
- * target object. To ensure that the parent instance serves as the target
1484
- * objects for mouse events, you can set the <code>mouseChildren</code>
1485
- * property of the parent instance to <code>false</code>.</p>
1486
- *
1487
- * <p> No event is dispatched by setting this property. You must use the
1488
- * <code>addEventListener()</code> method to create interactive
1489
- * functionality.</p>
1490
- */
1491
- public get mouseChildren(): boolean {
1492
- return this._mouseChildren;
1493
- }
1494
-
1495
- public set mouseChildren(value: boolean) {
1496
- if (this._mouseChildren == value)
1497
- return;
1498
-
1499
- this._mouseChildren = value;
1500
-
1501
- this._invalidateHierarchicalProperty(HierarchicalProperty.MOUSE_ENABLED);
1502
- }
1503
-
1504
- /**
1505
- * Indicates the <i>x</i> coordinate of the DisplayObject instance relative
1506
- * to the local coordinates of the parent DisplayObjectContainer. If the
1507
- * object is inside a DisplayObjectContainer that has transformations, it is
1508
- * in the local coordinate system of the enclosing DisplayObjectContainer.
1509
- * Thus, for a DisplayObjectContainer rotated 90° counterclockwise, the
1510
- * DisplayObjectContainer's children inherit a coordinate system that is
1511
- * rotated 90° counterclockwise. The object's coordinates refer to the
1512
- * registration point position.
1513
- */
1514
- public get x(): number {
1515
- return this._transform.position.x;
1516
- }
1517
-
1518
- public set x(val: number) {
1519
- if (this._transform.position.x == val)
1520
- return;
1521
-
1522
- this._transform.matrix3D._rawData[12] = val;
1523
-
1524
- this._transform.invalidatePosition();
1525
- }
1526
-
1527
- /**
1528
- * Indicates the <i>y</i> coordinate of the DisplayObject instance relative
1529
- * to the local coordinates of the parent DisplayObjectContainer. If the
1530
- * object is inside a DisplayObjectContainer that has transformations, it is
1531
- * in the local coordinate system of the enclosing DisplayObjectContainer.
1532
- * Thus, for a DisplayObjectContainer rotated 90° counterclockwise, the
1533
- * DisplayObjectContainer's children inherit a coordinate system that is
1534
- * rotated 90° counterclockwise. The object's coordinates refer to the
1535
- * registration point position.
1536
- */
1537
- public get y(): number {
1538
- return this._transform.position.y;
1539
- }
1540
-
1541
- public set y(val: number) {
1542
- if (this._transform.position.y == val)
1543
- return;
1544
-
1545
- this._transform.matrix3D._rawData[13] = val;
1546
-
1547
- this._transform.invalidatePosition();
1548
- }
1549
-
1550
- /**
1551
- * Indicates the z coordinate position along the z-axis of the DisplayObject
1552
- * instance relative to the 3D parent container. The z property is used for
1553
- * 3D coordinates, not screen or pixel coordinates.
1554
- *
1555
- * <p>When you set a <code>z</code> property for a display object to
1556
- * something other than the default value of <code>0</code>, a corresponding
1557
- * Matrix3D object is automatically created. for adjusting a display object's
1558
- * position and orientation in three dimensions. When working with the
1559
- * z-axis, the existing behavior of x and y properties changes from screen or
1560
- * pixel coordinates to positions relative to the 3D parent container.</p>
1561
- *
1562
- * <p>For example, a child of the <code>_root</code> at position x = 100, y =
1563
- * 100, z = 200 is not drawn at pixel location(100,100). The child is drawn
1564
- * wherever the 3D projection calculation puts it. The calculation is:</p>
1565
- *
1566
- * <p><code>(x~~cameraFocalLength/cameraRelativeZPosition,
1567
- * y~~cameraFocalLength/cameraRelativeZPosition)</code></p>
1568
- */
1569
- public get z(): number {
1570
- return this._transform.position.z;
1571
- }
1572
-
1573
- public set z(val: number) {
1574
- if (this._transform.position.z == val)
1575
- return;
1576
-
1577
- this._transform.matrix3D._rawData[14] = val;
1578
-
1579
- this._transform.invalidatePosition();
1580
- }
1581
-
1582
- /**
1583
- *
1584
- */
1585
- public zOffset: number = 0;
1586
-
1587
- /**
1588
- * Creates a new <code>DisplayObject</code> instance.
1589
- */
1590
- constructor() {
1591
- super();
1592
-
1593
- this.cursorType = '';
1594
- this._isInFocus = false;
1595
- this._tabEnabled = false;
1596
- this._tabIndex = -1;
1597
- this._avmDepthID = -1;
1598
- //global debug bounding boxes:
1599
- //this._boundsVisible=true;
1600
- this._onInvalidatePropertiesDelegate = (event: StyleEvent) => this._onInvalidateProperties(event);
1601
- this._onInvalidateImagesDelegate = (event: StyleEvent) => this._onInvalidateImages(event);
1602
-
1603
- //creation of associated transform object
1604
- this._transform = new Transform(null);
1605
-
1606
- //setup transform listeners
1607
- this._transform.addEventListener(
1608
- TransformEvent.INVALIDATE_MATRIX3D,
1609
- (_event: TransformEvent) => this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM)
1610
- );
1611
-
1612
- this._transform.addEventListener(
1613
- TransformEvent.INVALIDATE_COLOR_TRANSFORM,
1614
- (_event: TransformEvent) => this._invalidateHierarchicalProperty(HierarchicalProperty.COLOR_TRANSFORM)
1615
- );
1616
-
1617
- //bounding volume dictonary
1618
-
1619
- //default bounds type
1620
- this._defaultBoundingVolume = this._getDefaultBoundingVolume();
1621
- }
1622
-
1623
- public advanceFrame(): void {
1624
- //default to do nothing
1625
- }
1626
-
1627
- public getEntity(): IPartitionEntity {
1628
- return;
1629
- }
1630
-
1631
- public _initNode(node: ContainerNode): void {}
1632
-
1633
- /**
1634
- *
1635
- */
1636
- public clone(): DisplayObject {
1637
- const newInstance: DisplayObject = new DisplayObject();
1638
-
1639
- this.copyTo(newInstance);
1640
-
1641
- return newInstance;
1642
- }
1643
-
1644
- public copyTo(displayObject: DisplayObject): void {
1645
- displayObject.defaultBoundingVolume = this._defaultBoundingVolume;
1646
-
1647
- if (this._registrationMatrix3D)
1648
- displayObject._registrationMatrix3D = this._registrationMatrix3D.clone();
1649
-
1650
- displayObject.mouseChildren = this._mouseChildren;
1651
- displayObject.material = this._material;
1652
- displayObject.style = this._style;
1653
- displayObject.pickObject = this._pickObject;
1654
- displayObject.pickObjectFromTimeline = this.pickObjectFromTimeline;
1655
-
1656
- displayObject.boundsVisible = this._boundsVisible;
1657
- displayObject.name = this._pName;
1658
- displayObject.mouseEnabled = this._mouseEnabled;
1659
- displayObject.extra = this.extra;
1660
- displayObject.maskMode = this._maskMode;
1661
- displayObject.castsShadows = this.castsShadows;
1662
- displayObject.assetNamespace = this.assetNamespace;
1663
- displayObject._symbol = this._symbol;
1664
- displayObject.avm1Symbol = this.avm1Symbol;
1665
- displayObject.isAVMScene = this.isAVMScene;
1666
-
1667
- displayObject.isSlice9ScaledMC = this.isSlice9ScaledMC;
1668
- displayObject.scale9Grid = this.scale9Grid?.clone();
1669
-
1670
- if (this._masks) {
1671
- // clone mask tree, to avoid corruption
1672
- // if _scriptMask is presented, it already was exist in _mask array
1673
- displayObject._masks = this._masks.slice();
1674
- displayObject._scriptMask = this._scriptMask;
1675
- // manually call invalidation
1676
- displayObject._invalidateHierarchicalProperty(HierarchicalProperty.MASKS);
1677
- }
1678
-
1679
- this._transform.copyRawDataTo(displayObject._transform);
1680
- }
1681
-
1682
- /**
1683
- *
1684
- */
1685
- public dispose(): void {
1686
- this.disposeValues();
1687
- }
1688
-
1689
- public disposeValues(): void {
1690
- if (this._parent)
1691
- this._parent.removeChild(this);
1692
-
1693
- this.material = null;
1694
-
1695
- if (this._adapter) {
1696
- this._adapter.dispose();
1697
- this._adapter = null;
1698
- }
1699
-
1700
- this._pickObject = null;
1701
-
1702
- this._masks = null;
1703
- this._scriptMask = null;
1704
- }
1705
-
1706
- /**
1707
- * Rotates the 3d object around to face a point defined relative
1708
- * to the local coordinates of the parent <code>ObjectContainer3D</code>.
1709
- *
1710
- * @param scenePosition The vector defining the point to be looked at
1711
- * @param upAxis An optional vector used to define the desired
1712
- * up orientation of the 3d object after rotation has occurred
1713
- */
1714
- public lookAt(scenePosition: Vector3D, upAxis: Vector3D = null): void {
1715
- this.transform.lookAt(scenePosition, upAxis);
1716
- }
1717
-
1718
- /**
1719
- * Moves the local point around which the object rotates.
1720
- *
1721
- * @param dx The amount of movement along the local x axis.
1722
- * @param dy The amount of movement along the local y axis.
1723
- * @param dz The amount of movement along the local z axis.
1724
- */
1725
- public movePivot(dx: number, dy: number, dz: number): void {
1726
- if (dx == 0 && dy == 0 && dz == 0)
1727
- return;
1728
-
1729
- if (!this._registrationMatrix3D)
1730
- this._registrationMatrix3D = new Matrix3D();
1731
-
1732
- this._registrationMatrix3D._rawData[12] -= dx / this._transform.scale.x;
1733
- this._registrationMatrix3D._rawData[13] -= dy / this._transform.scale.y;
1734
- this._registrationMatrix3D._rawData[14] -= dz / this._transform.scale.z;
1735
-
1736
- this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
1737
- }
1738
-
1739
- public reset(): void {
1740
- this.visible = true;
1741
- if (!(<any> this).noTimelineUpdate)
1742
- this._transform.clearMatrix3D();
1743
-
1744
- this._transform.clearColorTransform();
1745
-
1746
- //this.name="";
1747
- this.masks = null;
1748
-
1749
- this.maskMode = false;
1750
- }
1751
-
1752
- /**
1753
- * @internal
1754
- */
1755
- public _iController: ControllerBase;
1756
-
1757
- public hasDispatchedAddedToStage: boolean=false;
1758
- /*
1759
- this checks if the mc is part of the displaylist (child of the stage)
1760
- todo: probably not the best way to do this
1761
- probably better to get this info by looking at root
1762
- */
1763
- public isOnDisplayList(): boolean {
1764
- let parent: DisplayObject = this;
1765
- while (parent) {
1766
- if (parent.isAVMScene)
1767
- return true;
1768
- parent = parent.parent;
1769
- }
1770
- return false;
1771
- }
1772
-
1773
- /**
1774
- * @internal
1775
- */
1776
- public _setParent(parent: DisplayObjectContainer): void {
1777
- this._parent = parent;
1778
- }
1779
-
1780
- public _invalidateHierarchicalProperty(propDirty: HierarchicalProperty): void {
1781
- this.dispatchEvent(new HeirarchicalEvent(HeirarchicalEvent.INVALIDATE_PROPERTY, propDirty));
1782
- }
1783
-
1784
- /**
1785
- *
1786
- */
1787
- public _iInternalUpdate(): void {
1788
- if (this._iController)
1789
- this._iController.update();
1790
- }
1791
-
1792
- /**
1793
- * @internal
1794
- */
1795
- public get maskId(): number {
1796
- return this._maskId;
1797
- }
1798
-
1799
- protected _setScaleX(val: number): void {
1800
- if (this.scaleX == val)
1801
- return;
1802
-
1803
- this._transform.scale.x = val;
1804
-
1805
- this._transform.invalidateMatrix3D();
1806
- }
1807
-
1808
- protected _setScaleY(val: number): void {
1809
- if (this.scaleY == val)
1810
- return;
1811
-
1812
- this._transform.scale.y = val;
1813
-
1814
- this._transform.invalidateMatrix3D();
1815
- }
1816
-
1817
- protected _setScaleZ(val: number): void {
1818
- if (this.scaleZ == val)
1819
- return;
1820
-
1821
- this._transform.scale.z = val;
1822
-
1823
- this._transform.invalidateMatrix3D();
1824
- }
1825
-
1826
- private _updateBoundsPrefab(picker: BoundsPicker): void {
1827
- if (this._boundsPrefab instanceof PrimitiveCubePrefab) {
1828
- const box = (<BoundingBox> picker.getBoundingVolume(null, this._defaultBoundingVolume)).getBox();
1829
-
1830
- //TODO: if box is null, no prefab should be visible
1831
- if (box == null)
1832
- return;
1833
-
1834
- this._boundsPrefab.width = box.width;
1835
- this._boundsPrefab.height = box.height;
1836
- this._boundsPrefab.depth = box.depth;
1837
-
1838
- this._boundsPrimitive.registrationPoint = new Vector3D(
1839
- -(box.x + box.width / 2) * this._boundsPrimitive.transform.scale.x,
1840
- -(box.y + box.height / 2) * this._boundsPrimitive.transform.scale.y,
1841
- -(box.z + box.depth / 2) * this._boundsPrimitive.transform.scale.z);
1842
-
1843
- } else if (this._boundsPrefab instanceof PrimitiveSpherePrefab) {
1844
-
1845
- const sphere: Sphere = (<BoundingSphere> picker.getBoundingVolume(
1846
- null,
1847
- this._defaultBoundingVolume)).getSphere();
1848
-
1849
- //console.log(sphere);
1850
- if (sphere == null)
1851
- return;
1852
-
1853
- this._boundsPrefab.radius = sphere.radius;
1854
-
1855
- this._boundsPrimitive.registrationPoint = new Vector3D(
1856
- -sphere.x * this._boundsPrimitive.transform.scale.x,
1857
- -sphere.y * this._boundsPrimitive.transform.scale.y,
1858
- -sphere.z * this._boundsPrimitive.transform.scale.z);
1859
- }
1860
- }
1861
-
1862
- protected _updateMaskMode(): void {
1863
- if (this._maskMode) {
1864
- this._mouseEnabled = false;
1865
- this.partitionClass = BasicPartition;
1866
- }
1867
-
1868
- this._invalidateHierarchicalProperty(HierarchicalProperty.MASK_ID);
1869
- }
1870
-
1871
- public _invalidateMaterial(): void {
1872
- this.dispatchEvent(new RenderableEvent(RenderableEvent.INVALIDATE_MATERIAL, this));
1873
- }
1874
-
1875
- private _invalidateStyle(): void {
1876
- this.dispatchEvent(new RenderableEvent(RenderableEvent.INVALIDATE_STYLE, this));
1877
- }
1878
-
1879
- public invalidateElements(): void {
1880
- this.dispatchEvent(new RenderableEvent(RenderableEvent.INVALIDATE_ELEMENTS, this));
1881
- }
1882
-
1883
- protected _onInvalidateProperties(_event: StyleEvent = null): void {
1884
- this._invalidateStyle();
1885
- }
1886
-
1887
- protected _onInvalidateImages(_event: StyleEvent = null): void {
1888
- this.invalidate();
1889
- }
1890
-
1891
- protected _getDefaultBoundingVolume(): BoundingVolumeType {
1892
- return BoundingVolumeType.BOX_BOUNDS_FAST;
1893
- }
1
+ import {
2
+ Transform,
3
+ TransformEvent,
4
+ Sphere,
5
+ MathConsts,
6
+ Matrix3D,
7
+ Rectangle,
8
+ Vector3D,
9
+ AssetBase,
10
+ Loader,
11
+ } from '@awayjs/core';
12
+
13
+ import { BlendMode } from '@awayjs/stage';
14
+
15
+ import {
16
+ BoundingBox,
17
+ BoundingSphere,
18
+ BoundingVolumeType,
19
+ IPartitionEntity,
20
+ BoundsPicker,
21
+ HeirarchicalEvent,
22
+ HierarchicalProperty,
23
+ AlignmentMode,
24
+ OrientationMode,
25
+ BasicPartition,
26
+ IPartitionContainer,
27
+ ContainerNode
28
+ } from '@awayjs/view';
29
+
30
+ import {
31
+ IMaterial,
32
+ Style,
33
+ StyleEvent,
34
+ RenderableEvent,
35
+ ElementsType,
36
+ } from '@awayjs/renderer';
37
+
38
+ import { DisplayObjectContainer } from './DisplayObjectContainer';
39
+ import { ControllerBase } from '../controllers/ControllerBase';
40
+ import { IBitmapDrawable } from '../base/IBitmapDrawable';
41
+
42
+ import { PrimitiveCubePrefab } from '../prefabs/PrimitiveCubePrefab';
43
+ import { PrimitiveSpherePrefab } from '../prefabs/PrimitiveSpherePrefab';
44
+ import { PrimitivePrefabBase } from '../prefabs/PrimitivePrefabBase';
45
+ import { IFilter } from '../adapters/IFilter';
46
+ import { IPartitionClass } from '@awayjs/view';
47
+ import { Sprite } from './Sprite';
48
+ import { Settings } from '../Settings';
49
+
50
+ /**
51
+ * The DisplayObject class is the base class for all objects that can be
52
+ * placed on the display list. The display list manages all objects displayed
53
+ * in flash. Use the DisplayObjectContainer class to arrange the
54
+ * display objects in the display list. DisplayObjectContainer objects can
55
+ * have child display objects, while other display objects, such as Shape and
56
+ * TextField objects, are "leaf" nodes that have only parents and siblings, no
57
+ * children.
58
+ *
59
+ * <p>The DisplayObject class supports fbasic functionality like the <i>x</i>
60
+ * and <i>y</i> position of an object, as well as more advanced properties of
61
+ * the object such as its transformation matrix. </p>
62
+ *
63
+ * <p>DisplayObject is an abstract base class; therefore, you cannot call
64
+ * DisplayObject directly. Invoking <code>new DisplayObject()</code> throws an
65
+ * <code>ArgumentError</code> exception. </p>
66
+ *
67
+ * <p>All display objects inherit from the DisplayObject class.</p>
68
+ *
69
+ * <p>The DisplayObject class itself does not include any APIs for rendering
70
+ * content onscreen. For that reason, if you want create a custom subclass of
71
+ * the DisplayObject class, you will want to extend one of its subclasses that
72
+ * do have APIs for rendering content onscreen, such as the Shape, Sprite,
73
+ * Bitmap, SimpleButton, TextField, or MovieClip class.</p>
74
+ *
75
+ * <p>The DisplayObject class contains several broadcast events. Normally, the
76
+ * target of any particular event is a specific DisplayObject instance. For
77
+ * example, the target of an <code>added</code> event is the specific
78
+ * DisplayObject instance that was added to the display list. Having a single
79
+ * target restricts the placement of event listeners to that target and in
80
+ * some cases the target's ancestors on the display list. With broadcast
81
+ * events, however, the target is not a specific DisplayObject instance, but
82
+ * rather all DisplayObject instances, including those that are not on the
83
+ * display list. This means that you can add a listener to any DisplayObject
84
+ * instance to listen for broadcast events. In addition to the broadcast
85
+ * events listed in the DisplayObject class's Events table, the DisplayObject
86
+ * class also inherits two broadcast events from the EventDispatcher class:
87
+ * <code>activate</code> and <code>deactivate</code>.</p>
88
+ *
89
+ * <p>Some properties previously used in the ActionScript 1.0 and 2.0
90
+ * MovieClip, TextField, and Button classes(such as <code>_alpha</code>,
91
+ * <code>_height</code>, <code>_pName</code>, <code>_width</code>,
92
+ * <code>_x</code>, <code>_y</code>, and others) have equivalents in the
93
+ * ActionScript 3.0 DisplayObject class that are renamed so that they no
94
+ * longer begin with the underscore(_) character.</p>
95
+ *
96
+ * <p>For more information, see the "Display Programming" chapter of the
97
+ * <i>ActionScript 3.0 Developer's Guide</i>.</p>
98
+ *
99
+ * @event added Dispatched when a display object is added to the
100
+ * display list. The following methods trigger this
101
+ * event:
102
+ * <code>DisplayObjectContainer.addChild()</code>,
103
+ * <code>DisplayObjectContainer.addChildAt()</code>.
104
+ * @event addedToScene Dispatched when a display object is added to the on
105
+ * scene display list, either directly or through the
106
+ * addition of a sub tree in which the display object
107
+ * is contained. The following methods trigger this
108
+ * event:
109
+ * <code>DisplayObjectContainer.addChild()</code>,
110
+ * <code>DisplayObjectContainer.addChildAt()</code>.
111
+ * @event enterFrame [broadcast event] Dispatched when the playhead is
112
+ * entering a new frame. If the playhead is not
113
+ * moving, or if there is only one frame, this event
114
+ * is dispatched continuously in conjunction with the
115
+ * frame rate. This event is a broadcast event, which
116
+ * means that it is dispatched by all display objects
117
+ * with a listener registered for this event.
118
+ * @event exitFrame [broadcast event] Dispatched when the playhead is
119
+ * exiting the current frame. All frame scripts have
120
+ * been run. If the playhead is not moving, or if
121
+ * there is only one frame, this event is dispatched
122
+ * continuously in conjunction with the frame rate.
123
+ * This event is a broadcast event, which means that
124
+ * it is dispatched by all display objects with a
125
+ * listener registered for this event.
126
+ * @event frameConstructed [broadcast event] Dispatched after the constructors
127
+ * of frame display objects have run but before frame
128
+ * scripts have run. If the playhead is not moving, or
129
+ * if there is only one frame, this event is
130
+ * dispatched continuously in conjunction with the
131
+ * frame rate. This event is a broadcast event, which
132
+ * means that it is dispatched by all display objects
133
+ * with a listener registered for this event.
134
+ * @event removed Dispatched when a display object is about to be
135
+ * removed from the display list. Two methods of the
136
+ * DisplayObjectContainer class generate this event:
137
+ * <code>removeChild()</code> and
138
+ * <code>removeChildAt()</code>.
139
+ *
140
+ * <p>The following methods of a
141
+ * DisplayObjectContainer object also generate this
142
+ * event if an object must be removed to make room for
143
+ * the new object: <code>addChild()</code>,
144
+ * <code>addChildAt()</code>, and
145
+ * <code>setChildIndex()</code>. </p>
146
+ * @event removedFromScene Dispatched when a display object is about to be
147
+ * removed from the display list, either directly or
148
+ * through the removal of a sub tree in which the
149
+ * display object is contained. Two methods of the
150
+ * DisplayObjectContainer class generate this event:
151
+ * <code>removeChild()</code> and
152
+ * <code>removeChildAt()</code>.
153
+ *
154
+ * <p>The following methods of a
155
+ * DisplayObjectContainer object also generate this
156
+ * event if an object must be removed to make room for
157
+ * the new object: <code>addChild()</code>,
158
+ * <code>addChildAt()</code>, and
159
+ * <code>setChildIndex()</code>. </p>
160
+ * @event render [broadcast event] Dispatched when the display list
161
+ * is about to be updated and rendered. This event
162
+ * provides the last opportunity for objects listening
163
+ * for this event to make changes before the display
164
+ * list is rendered. You must call the
165
+ * <code>invalidate()</code> method of the Scene
166
+ * object each time you want a <code>render</code>
167
+ * event to be dispatched. <code>Render</code> events
168
+ * are dispatched to an object only if there is mutual
169
+ * trust between it and the object that called
170
+ * <code>Scene.invalidate()</code>. This event is a
171
+ * broadcast event, which means that it is dispatched
172
+ * by all display objects with a listener registered
173
+ * for this event.
174
+ *
175
+ * <p><b>Note: </b>This event is not dispatched if the
176
+ * display is not rendering. This is the case when the
177
+ * content is either minimized or obscured. </p>
178
+ */
179
+ export class DisplayObject extends AssetBase implements IBitmapDrawable, IPartitionContainer {
180
+
181
+ private _mouseChildren: boolean = true;
182
+ public _material: IMaterial;
183
+ public _style: Style;
184
+ private _loader: Loader;
185
+ private _mouseX: number;
186
+ private _mouseY: number;
187
+ private _root: DisplayObjectContainer;
188
+ private _boundsVisible: boolean;
189
+ private _boundsPrefab: PrimitivePrefabBase;
190
+ private _boundsPrefabDirty: boolean;
191
+ private _boundsPrimitive: DisplayObject;
192
+ private _pName: string;
193
+
194
+ private _scrollRect: Rectangle;
195
+ private _scrollRectPrimitive: Sprite;
196
+ private _scrollRectPrimitiveDirty: boolean;
197
+
198
+ protected _parent: DisplayObjectContainer;
199
+ public _sessionID: number = -1;
200
+ public _avmDepthID: number = -1;
201
+
202
+ public pickObjectFromTimeline: boolean;
203
+
204
+ //public _implicitPartition: PartitionBase;
205
+
206
+ private _alignmentMode: AlignmentMode = AlignmentMode.REGISTRATION_POINT;
207
+ private _scale9Grid: Rectangle;
208
+ protected _transform: Transform;
209
+ private _visible: boolean = true;
210
+ private _maskId: number = -1;
211
+
212
+ protected _masks: Array<DisplayObject>;
213
+ protected _scriptMask: DisplayObject;
214
+
215
+ private _mouseEnabled: boolean = true;
216
+
217
+ private _eulers: Vector3D;
218
+
219
+ public _registrationMatrix3D: Matrix3D;
220
+ private _defaultBoundingVolume: BoundingVolumeType;
221
+
222
+ public cursorType: string;
223
+
224
+ protected _isInFocus: boolean;
225
+ protected _tabEnabled: boolean;
226
+ protected _tabIndex: number;
227
+
228
+ private _maskMode: boolean = false;
229
+ private _pickObject: DisplayObjectContainer;
230
+
231
+ public _hierarchicalPropsDirty: number;
232
+
233
+ private _onInvalidatePropertiesDelegate: (event: StyleEvent) => void;
234
+ private _onInvalidateImagesDelegate: (event: StyleEvent) => void;
235
+
236
+ public isSlice9ScaledMC: boolean=false;
237
+ public isSlice9ScaledSprite: boolean=false;
238
+ public avm1Symbol: any;
239
+ public isAVMScene: boolean=false;
240
+
241
+ public partitionClass: IPartitionClass;
242
+
243
+ // this is needed for AVM1 - todo: maybe do this on adapters ?
244
+ public placeObjectTag: any=null;
245
+ public getScriptPrecedence(): number[] {
246
+ if (!this._parent) {
247
+ return [];
248
+ }
249
+ const result = this._parent.getScriptPrecedence();
250
+ if (this.placeObjectTag) {
251
+ result.push(this.placeObjectTag.actionBlocksPrecedence);
252
+ }
253
+ return result;
254
+ }
255
+
256
+ public getMouseCursor(): string {
257
+ return 'initial';
258
+ }
259
+
260
+ public get tabEnabled(): boolean {
261
+ return this._tabEnabled;
262
+ }
263
+
264
+ public set tabEnabled(value: boolean) {
265
+ this._tabEnabled = value;
266
+ }
267
+
268
+ public get tabIndex(): number {
269
+ return this._tabIndex;
270
+ }
271
+
272
+ public set tabIndex(value: number) {
273
+ this._tabIndex = value;
274
+ }
275
+
276
+ public get isInFocus(): boolean {
277
+ return this._isInFocus;
278
+ }
279
+
280
+ public set isInFocus(value: boolean) {
281
+ this._isInFocus = value;
282
+ }
283
+
284
+ public setFocus(value: boolean, fromMouseDown: boolean = false, sendSoftKeyEvent: boolean = true) {
285
+ if (this._isInFocus == value)
286
+ return;
287
+ this._isInFocus = value;
288
+ }
289
+
290
+ /**
291
+ *
292
+ */
293
+ public get alignmentMode(): AlignmentMode {
294
+ return this._alignmentMode;
295
+ }
296
+
297
+ public set alignmentMode(value: AlignmentMode) {
298
+ if (this._alignmentMode == value)
299
+ return;
300
+
301
+ this._alignmentMode = value;
302
+
303
+ this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
304
+ }
305
+
306
+ /**
307
+ * Indicates the alpha transparency value of the object specified. Valid
308
+ * values are 0(fully transparent) to 1(fully opaque). The default value is
309
+ * 1. Display objects with <code>alpha</code> set to 0 <i>are</i> active,
310
+ * even though they are invisible.
311
+ */
312
+ public get alpha(): number {
313
+ return this._transform.colorTransform.alphaMultiplier;
314
+ }
315
+
316
+ public set alpha(value: number) {
317
+ this._transform.colorTransform.alphaMultiplier = value;
318
+
319
+ this._transform.invalidateColorTransform();
320
+ }
321
+
322
+ /**
323
+ * A value from the BlendMode class that specifies which blend mode to use. A
324
+ * bitmap can be drawn internally in two ways. If you have a blend mode
325
+ * enabled or an external clipping mask, the bitmap is drawn by adding a
326
+ * bitmap-filled square shape to the vector render. If you attempt to set
327
+ * this property to an invalid value, Flash runtimes set the value to
328
+ * <code>BlendMode.NORMAL</code>.
329
+ *
330
+ * <p>The <code>blendMode</code> property affects each pixel of the display
331
+ * object. Each pixel is composed of three constituent colors(red, green,
332
+ * and blue), and each constituent color has a value between 0x00 and 0xFF.
333
+ * Flash Player or Adobe AIR compares each constituent color of one pixel in
334
+ * the movie clip with the corresponding color of the pixel in the
335
+ * background. For example, if <code>blendMode</code> is set to
336
+ * <code>BlendMode.LIGHTEN</code>, Flash Player or Adobe AIR compares the red
337
+ * value of the display object with the red value of the background, and uses
338
+ * the lighter of the two as the value for the red component of the displayed
339
+ * color.</p>
340
+ *
341
+ * <p>The following table describes the <code>blendMode</code> settings. The
342
+ * BlendMode class defines string values you can use. The illustrations in
343
+ * the table show <code>blendMode</code> values applied to a circular display
344
+ * object(2) superimposed on another display object(1).</p>
345
+ */
346
+
347
+ public _blendMode: BlendMode = BlendMode.LAYER;
348
+
349
+ public set blendMode(v: BlendMode) {
350
+ if (this._blendMode === v) {
351
+ return;
352
+ }
353
+
354
+ this._blendMode = v;
355
+ if (v === BlendMode.OVERLAY) {
356
+ this._transform.invalidateColorTransform();
357
+ }
358
+ }
359
+
360
+ public get blendMode() {
361
+ if (!Settings.USE_UNSAFE_BLENDS) {
362
+ return '';
363
+ }
364
+
365
+ if (Settings.REMAP_BLEND_MODE) {
366
+ return Settings.BLEND_MODE_REMAP_TABLE[<string> this._blendMode] || this._blendMode;
367
+ }
368
+
369
+ return this._blendMode;
370
+ }
371
+
372
+ /**
373
+ *
374
+ */
375
+ public get defaultBoundingVolume(): BoundingVolumeType {
376
+ return this._defaultBoundingVolume;
377
+ }
378
+
379
+ public set defaultBoundingVolume(value: BoundingVolumeType) {
380
+ if (this._defaultBoundingVolume == value)
381
+ return;
382
+
383
+ this._defaultBoundingVolume = value;
384
+
385
+ if (this._boundsPrimitive) {
386
+ this._boundsPrimitive.dispose();
387
+ this._boundsPrimitive = null;
388
+ }
389
+
390
+ this.invalidate();
391
+ }
392
+
393
+ /**
394
+ * If set to <code>true</code>, NME will use the software renderer to cache
395
+ * an internal bitmap representation of the display object. For native targets,
396
+ * this is often much slower than the default hardware renderer. When you
397
+ * are using the Flash target, this caching may increase performance for display
398
+ * objects that contain complex vector content.
399
+ *
400
+ * <p>All vector data for a display object that has a cached bitmap is drawn
401
+ * to the bitmap instead of the main display. If
402
+ * <code>cacheAsBitmapMatrix</code> is null or unsupported, the bitmap is
403
+ * then copied to the main display as unstretched, unrotated pixels snapped
404
+ * to the nearest pixel boundaries. Pixels are mapped 1 to 1 with the parent
405
+ * object. If the bounds of the bitmap change, the bitmap is recreated
406
+ * instead of being stretched.</p>
407
+ *
408
+ * <p>If <code>cacheAsBitmapMatrix</code> is non-null and supported, the
409
+ * object is drawn to the off-screen bitmap using that matrix and the
410
+ * stretched and/or rotated results of that rendering are used to draw the
411
+ * object to the main display.</p>
412
+ *
413
+ * <p>No internal bitmap is created unless the <code>BBitmap</code>
414
+ * property is set to <code>true</code>.</p>
415
+ *
416
+ * <p>After you set the <code>cacheAsBitmap</code> property to
417
+ * <code>true</code>, the rendering does not change, however the display
418
+ * object performs pixel snapping automatically. The animation speed can be
419
+ * significantly faster depending on the complexity of the vector content.
420
+ * </p>
421
+ *
422
+ * <p>The <code>cacheAsBitmap</code> property is automatically set to
423
+ * <code>true</code> whenever you apply a filter to a display object(when
424
+ * its <code>filter</code> array is not empty), and if a display object has a
425
+ * filter applied to it, <code>cacheAsBitmap</code> is reported as
426
+ * <code>true</code> for that display object, even if you set the property to
427
+ * <code>false</code>. If you clear all filters for a display object, the
428
+ * <code>cacheAsBitmap</code> setting changes to what it was last set to.</p>
429
+ *
430
+ * <p>A display object does not use a bitmap even if the
431
+ * <code>cacheAsBitmap</code> property is set to <code>true</code> and
432
+ * instead renders from vector data in the following cases:</p>
433
+ *
434
+ * <ul>
435
+ * <li>The bitmap is too large. In AIR 1.5 and Flash Player 10, the maximum
436
+ * size for a bitmap image is 8,191 pixels in width or height, and the total
437
+ * number of pixels cannot exceed 16,777,215 pixels.(So, if a bitmap image
438
+ * is 8,191 pixels wide, it can only be 2,048 pixels high.) In Flash Player 9
439
+ * and earlier, the limitation is is 2880 pixels in height and 2,880 pixels
440
+ * in width.</li>
441
+ * <li>The bitmap fails to allocate(out of memory error). </li>
442
+ * </ul>
443
+ *
444
+ * <p>The <code>cacheAsBitmap</code> property is best used with movie clips
445
+ * that have mostly static content and that do not scale and rotate
446
+ * frequently. With such movie clips, <code>cacheAsBitmap</code> can lead to
447
+ * performance increases when the movie clip is translated(when its <i>x</i>
448
+ * and <i>y</i> position is changed).</p>
449
+ */
450
+ private _bitmapCache: boolean;
451
+ public get cacheAsBitmap() {
452
+ return this._bitmapCache;
453
+ }
454
+
455
+ public set cacheAsBitmap(v: boolean) {
456
+ if (v === this._bitmapCache) {
457
+ return;
458
+ }
459
+
460
+ if (!Settings.USE_UNSAFE_CACHE_AS_BITMAP) {
461
+ return;
462
+ }
463
+
464
+ v && console.warn(
465
+ '[@scene/DisplayObject] Unsafe cacheAsBitmap is enabled!' +
466
+ 'You can disable it by `Settings.USE_UNSAFE_CACHE_AS_BITMAP = false`'
467
+ ,this.id
468
+ );
469
+
470
+ this._bitmapCache = v;
471
+ }
472
+
473
+ /**
474
+ *
475
+ */
476
+ public castsShadows: boolean = true;
477
+
478
+ /**
479
+ * Defines the rotation of the 3d object as a <code>Vector3D</code>
480
+ * object containing euler angles for rotation around x, y and z axis.
481
+ */
482
+ public get eulers(): Vector3D {
483
+ if (!this._eulers)
484
+ this._eulers = new Vector3D();
485
+
486
+ this._eulers.x = this.rotationX;
487
+ this._eulers.y = this.rotationY;
488
+ this._eulers.z = this.rotationZ;
489
+
490
+ return this._eulers;
491
+ }
492
+
493
+ public set eulers(value: Vector3D) {
494
+ // previously this was using the setters for rotationX etc
495
+ // but because this will convert from radians to degree, i changed it to update directly
496
+ this._transform.rotation.x = value.x;
497
+ this._transform.rotation.y = value.y;
498
+ this._transform.rotation.z = value.z;
499
+
500
+ this._transform.invalidateMatrix3D();
501
+ }
502
+
503
+ /**
504
+ * An object that can contain any extra data.
505
+ */
506
+ public extra: Object;
507
+
508
+ /**
509
+ * An indexed array that contains each filter object currently associated
510
+ * with the display object. The flash.filters package contains several
511
+ * classes that define specific filters you can use.
512
+ *
513
+ * <p>Filters can be applied in Flash Professional at design time, or at run
514
+ * time by using ActionScript code. To apply a filter by using ActionScript,
515
+ * you must make a temporary copy of the entire <code>filters</code> array,
516
+ * modify the temporary array, then assign the value of the temporary array
517
+ * back to the <code>filters</code> array. You cannot directly add a new
518
+ * filter object to the <code>filters</code> array.</p>
519
+ *
520
+ * <p>To add a filter by using ActionScript, perform the following steps
521
+ * (assume that the target display object is named
522
+ * <code>myDisplayObject</code>):</p>
523
+ *
524
+ * <ol>
525
+ * <li>Create a new filter object by using the constructor method of your
526
+ * chosen filter class.</li>
527
+ * <li>Assign the value of the <code>myDisplayObject.filters</code> array
528
+ * to a temporary array, such as one named <code>myFilters</code>.</li>
529
+ * <li>Add the new filter object to the <code>myFilters</code> temporary
530
+ * array.</li>
531
+ * <li>Assign the value of the temporary array to the
532
+ * <code>myDisplayObject.filters</code> array.</li>
533
+ * </ol>
534
+ *
535
+ * <p>If the <code>filters</code> array is undefined, you do not need to use
536
+ * a temporary array. Instead, you can directly assign an array literal that
537
+ * contains one or more filter objects that you create. The first example in
538
+ * the Examples section adds a drop shadow filter by using code that handles
539
+ * both defined and undefined <code>filters</code> arrays.</p>
540
+ *
541
+ * <p>To modify an existing filter object, you must use the technique of
542
+ * modifying a copy of the <code>filters</code> array:</p>
543
+ *
544
+ * <ol>
545
+ * <li>Assign the value of the <code>filters</code> array to a temporary
546
+ * array, such as one named <code>myFilters</code>.</li>
547
+ * <li>Modify the property by using the temporary array,
548
+ * <code>myFilters</code>. For example, to set the quality property of the
549
+ * first filter in the array, you could use the following code:
550
+ * <code>myFilters[0].quality = 1;</code></li>
551
+ * <li>Assign the value of the temporary array to the <code>filters</code>
552
+ * array.</li>
553
+ * </ol>
554
+ *
555
+ * <p>At load time, if a display object has an associated filter, it is
556
+ * marked to cache itself as a transparent bitmap. From this point forward,
557
+ * as long as the display object has a valid filter list, the player caches
558
+ * the display object as a bitmap. This source bitmap is used as a source
559
+ * image for the filter effects. Each display object usually has two bitmaps:
560
+ * one with the original unfiltered source display object and another for the
561
+ * final image after filtering. The final image is used when rendering. As
562
+ * long as the display object does not change, the final image does not need
563
+ * updating.</p>
564
+ *
565
+ * <p>The flash.filters package includes classes for filters. For example, to
566
+ * create a DropShadow filter, you would write:</p>
567
+ *
568
+ * @throws ArgumentError When <code>filters</code> includes a ShaderFilter
569
+ * and the shader output type is not compatible with
570
+ * this operation(the shader must specify a
571
+ * <code>pixel4</code> output).
572
+ * @throws ArgumentError When <code>filters</code> includes a ShaderFilter
573
+ * and the shader doesn't specify any image input or
574
+ * the first input is not an <code>image4</code> input.
575
+ * @throws ArgumentError When <code>filters</code> includes a ShaderFilter
576
+ * and the shader specifies an image input that isn't
577
+ * provided.
578
+ * @throws ArgumentError When <code>filters</code> includes a ShaderFilter, a
579
+ * ByteArray or Vector.<Number> instance as a shader
580
+ * input, and the <code>width</code> and
581
+ * <code>height</code> properties aren't specified for
582
+ * the ShaderInput object, or the specified values
583
+ * don't match the amount of data in the input data.
584
+ * See the <code>ShaderInput.input</code> property for
585
+ * more information.
586
+ */
587
+
588
+ private _filters: Array<IFilter> = null;
589
+
590
+ public set filters(v: Array<IFilter>) {
591
+ if (!Settings.USE_UNSAFE_FILTERS) {
592
+ return;
593
+ }
594
+
595
+ this._filters = v;
596
+ this._invalidateStyle();
597
+ }
598
+
599
+ public get filters() {
600
+ return this._filters;
601
+ }
602
+
603
+ public updateFilters(_newFilters: IFilter[]) {
604
+ console.warn('[scene/DisplayObject] - updateFilters is just a stub');
605
+ }
606
+
607
+ /**
608
+ * Indicates the instance container index of the DisplayObject. The object can be
609
+ * identified in the child list of its parent display object container by
610
+ * calling the <code>getChildByIndex()</code> method of the display object
611
+ * container.
612
+ *
613
+ * <p>If the DisplayObject has no parent container, index defaults to 0.</p>
614
+ */
615
+ public get index(): number {
616
+ if (this._parent)
617
+ return this._parent.getChildIndex(this);
618
+
619
+ return 0;
620
+ }
621
+
622
+ /**
623
+ * Returns a LoaderInfo object containing information about loading the file
624
+ * to which this display object belongs. The <code>loaderInfo</code> property
625
+ * is defined only for the root display object of a SWF file or for a loaded
626
+ * Bitmap(not for a Bitmap that is drawn with ActionScript). To find the
627
+ * <code>loaderInfo</code> object associated with the SWF file that contains
628
+ * a display object named <code>myDisplayObject</code>, use
629
+ * <code>myDisplayObject.root.loaderInfo</code>.
630
+ *
631
+ * <p>A large SWF file can monitor its download by calling
632
+ * <code>this.root.loaderInfo.addEventListener(Event.COMPLETE,
633
+ * func)</code>.</p>
634
+ */
635
+ public get loader(): Loader {
636
+ return this._loader;
637
+ }
638
+
639
+ /**
640
+ * The calling display object is masked by the specified <code>mask</code>
641
+ * object. To ensure that masking works when the Stage is scaled, the
642
+ * <code>mask</code> display object must be in an active part of the display
643
+ * list. The <code>mask</code> object itself is not drawn. Set
644
+ * <code>mask</code> to <code>null</code> to remove the mask.
645
+ *
646
+ * <p>To be able to scale a mask object, it must be on the display list. To
647
+ * be able to drag a mask Sprite object(by calling its
648
+ * <code>startDrag()</code> method), it must be on the display list. To call
649
+ * the <code>startDrag()</code> method for a mask sprite based on a
650
+ * <code>mouseDown</code> event being dispatched by the sprite, set the
651
+ * sprite's <code>buttonMode</code> property to <code>true</code>.</p>
652
+ *
653
+ * <p>When display objects are cached by setting the
654
+ * <code>cacheAsBitmap</code> property to <code>true</code> an the
655
+ * <code>cacheAsBitmapMatrix</code> property to a Matrix object, both the
656
+ * mask and the display object being masked must be part of the same cached
657
+ * bitmap. Thus, if the display object is cached, then the mask must be a
658
+ * child of the display object. If an ancestor of the display object on the
659
+ * display list is cached, then the mask must be a child of that ancestor or
660
+ * one of its descendents. If more than one ancestor of the masked object is
661
+ * cached, then the mask must be a descendent of the cached container closest
662
+ * to the masked object in the display list.</p>
663
+ *
664
+ * <p><b>Note:</b> A single <code>mask</code> object cannot be used to mask
665
+ * more than one calling display object. When the <code>mask</code> is
666
+ * assigned to a second display object, it is removed as the mask of the
667
+ * first object, and that object's <code>mask</code> property becomes
668
+ * <code>null</code>.</p>
669
+ */
670
+ public set mask(value: DisplayObject) {
671
+ this.scriptMask = value;
672
+ }
673
+
674
+ public get maskMode(): boolean {
675
+ return this._maskMode;
676
+ }
677
+
678
+ public set maskMode(value: boolean) {
679
+ if (this._maskMode == value)
680
+ return;
681
+
682
+ this._maskMode = value;
683
+
684
+ this._maskId = value ? this.id : -1;
685
+
686
+ this._updateMaskMode();
687
+ }
688
+
689
+ public get pickObject(): DisplayObjectContainer {
690
+ return this._pickObject;
691
+ }
692
+
693
+ public set pickObject(value: DisplayObjectContainer) {
694
+ if (this._pickObject == value)
695
+ return;
696
+
697
+ this._pickObject = value.pickObjectFromTimeline ? value.clone() : value;
698
+
699
+ if (this._pickObject) {
700
+ this._pickObject.mouseChildren = false;
701
+ this._pickObject.mouseEnabled = false;
702
+ }
703
+ }
704
+
705
+ /**
706
+ * Specifies whether this object receives mouse, or other user input,
707
+ * messages. The default value is <code>true</code>, which means that by
708
+ * default any InteractiveObject instance that is on the display list
709
+ * receives mouse events or other user input events. If
710
+ * <code>mouseEnabled</code> is set to <code>false</code>, the instance does
711
+ * not receive any mouse events(or other user input events like keyboard
712
+ * events). Any children of this instance on the display list are not
713
+ * affected. To change the <code>mouseEnabled</code> behavior for all
714
+ * children of an object on the display list, use
715
+ * <code>flash.display.DisplayObjectContainer.mouseChildren</code>.
716
+ *
717
+ * <p> No event is dispatched by setting this property. You must use the
718
+ * <code>addEventListener()</code> method to create interactive
719
+ * functionality.</p>
720
+ */
721
+ public get mouseEnabled(): boolean {
722
+ return this._mouseEnabled;
723
+ }
724
+
725
+ public set mouseEnabled(value: boolean) {
726
+ if (this._mouseEnabled == value)
727
+ return;
728
+
729
+ this._mouseEnabled = value;
730
+ }
731
+
732
+ /**
733
+ * Indicates the x coordinate of the mouse or user input device position, in
734
+ * pixels.
735
+ *
736
+ * <p><b>Note</b>: For a DisplayObject that has been rotated, the returned x
737
+ * coordinate will reflect the non-rotated object.</p>
738
+ */
739
+ public get mouseX(): number {
740
+ return this._mouseX;
741
+ }
742
+
743
+ /**
744
+ * Indicates the y coordinate of the mouse or user input device position, in
745
+ * pixels.
746
+ *
747
+ * <p><b>Note</b>: For a DisplayObject that has been rotated, the returned y
748
+ * coordinate will reflect the non-rotated object.</p>
749
+ */
750
+ public get mouseY(): number {
751
+ return this._mouseY;
752
+ }
753
+
754
+ /**
755
+ * Indicates the instance name of the DisplayObject. The object can be
756
+ * identified in the child list of its parent display object container by
757
+ * calling the <code>getChildByName()</code> method of the display object
758
+ * container.
759
+ *
760
+ * @throws IllegalOperationError If you are attempting to set this property
761
+ * on an object that was placed on the timeline
762
+ * in the Flash authoring tool.
763
+ */
764
+ public get name(): string {
765
+ return this._pName ? this._pName : '';
766
+ }
767
+
768
+ public set name(value: string) {
769
+ this._pName = value;
770
+ }
771
+
772
+ /**
773
+ *
774
+ */
775
+ public orientationMode: OrientationMode = OrientationMode.DEFAULT;
776
+
777
+ /**
778
+ * Indicates the DisplayObjectContainer object that contains this display
779
+ * object. Use the <code>parent</code> property to specify a relative path to
780
+ * display objects that are above the current display object in the display
781
+ * list hierarchy.
782
+ *
783
+ * <p>You can use <code>parent</code> to move up multiple levels in the
784
+ * display list as in the following:</p>
785
+ *
786
+ * @throws SecurityError The parent display object belongs to a security
787
+ * sandbox to which you do not have access. You can
788
+ * avoid this situation by having the parent movie call
789
+ * the <code>Security.allowDomain()</code> method.
790
+ */
791
+ public get parent(): DisplayObjectContainer {
792
+ return this._parent;
793
+ }
794
+
795
+ /**
796
+ * Defines the local point around which the object rotates.
797
+ */
798
+ public get registrationPoint(): Vector3D {
799
+ if (this._registrationMatrix3D)
800
+ return new Vector3D(
801
+ -this._registrationMatrix3D._rawData[12] * this.scaleX,
802
+ -this._registrationMatrix3D._rawData[13] * this.scaleY,
803
+ -this._registrationMatrix3D._rawData[14] * this.scaleZ);
804
+
805
+ return null;
806
+ }
807
+
808
+ public set registrationPoint(value: Vector3D) {
809
+ if (!value) {
810
+ if (!this._registrationMatrix3D)
811
+ return;
812
+
813
+ this._registrationMatrix3D._rawData[12] = 0;
814
+ this._registrationMatrix3D._rawData[13] = 0;
815
+ this._registrationMatrix3D._rawData[14] = 0;
816
+
817
+ if (this._registrationMatrix3D.isIdentity())
818
+ this._registrationMatrix3D = null;
819
+ } else {
820
+ if (!this._registrationMatrix3D)
821
+ this._registrationMatrix3D = new Matrix3D();
822
+
823
+ this._registrationMatrix3D._rawData[12] = -value.x / this._transform.scale.x;
824
+ this._registrationMatrix3D._rawData[13] = -value.y / this._transform.scale.y;
825
+ this._registrationMatrix3D._rawData[14] = -value.z / this._transform.scale.z;
826
+ }
827
+
828
+ this._registrationMatrix3D!.invalidatePosition();
829
+
830
+ this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
831
+ }
832
+
833
+ /**
834
+ * Defines the local scale.
835
+ */
836
+ public get registrationScale(): Vector3D {
837
+ if (this._registrationMatrix3D)
838
+ return new Vector3D(
839
+ this._registrationMatrix3D._rawData[0],
840
+ this._registrationMatrix3D._rawData[5],
841
+ this._registrationMatrix3D._rawData[10]);
842
+
843
+ return null;
844
+ }
845
+
846
+ public set registrationScale(value: Vector3D) {
847
+ if (!value) {
848
+ if (!this._registrationMatrix3D)
849
+ return;
850
+
851
+ this._registrationMatrix3D._rawData[0] = 1;
852
+ this._registrationMatrix3D._rawData[5] = 1;
853
+ this._registrationMatrix3D._rawData[10] = 1;
854
+
855
+ if (this._registrationMatrix3D.isIdentity())
856
+ this._registrationMatrix3D = null;
857
+ } else {
858
+ if (!this._registrationMatrix3D)
859
+ this._registrationMatrix3D = new Matrix3D();
860
+
861
+ this._registrationMatrix3D._rawData[0] = value.x;
862
+ this._registrationMatrix3D._rawData[5] = value.y;
863
+ this._registrationMatrix3D._rawData[10] = value.z;
864
+ }
865
+
866
+ this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
867
+ }
868
+
869
+ /**
870
+ * For a display object in a loaded SWF file, the <code>root</code> property
871
+ * is the top-most display object in the portion of the display list's tree
872
+ * structure represented by that SWF file. For a Bitmap object representing a
873
+ * loaded image file, the <code>root</code> property is the Bitmap object
874
+ * itself. For the instance of the main class of the first SWF file loaded,
875
+ * the <code>root</code> property is the display object itself. The
876
+ * <code>root</code> property of the Scene object is the Scene object itself.
877
+ * The <code>root</code> property is set to <code>null</code> for any display
878
+ * object that has not been added to the display list, unless it has been
879
+ * added to a display object container that is off the display list but that
880
+ * is a child of the top-most display object in a loaded SWF file.
881
+ *
882
+ * <p>For example, if you create a new Sprite object by calling the
883
+ * <code>Sprite()</code> constructor method, its <code>root</code> property
884
+ * is <code>null</code> until you add it to the display list(or to a display
885
+ * object container that is off the display list but that is a child of the
886
+ * top-most display object in a SWF file).</p>
887
+ *
888
+ * <p>For a loaded SWF file, even though the Loader object used to load the
889
+ * file may not be on the display list, the top-most display object in the
890
+ * SWF file has its <code>root</code> property set to itself. The Loader
891
+ * object does not have its <code>root</code> property set until it is added
892
+ * as a child of a display object for which the <code>root</code> property is
893
+ * set.</p>
894
+ */
895
+ public get root(): DisplayObjectContainer {
896
+ return this._root;
897
+ }
898
+
899
+ /**
900
+ * Indicates the rotation of the DisplayObject instance, in degrees, from its
901
+ * original orientation. Values from 0 to 180 represent clockwise rotation;
902
+ * values from 0 to -180 represent counterclockwise rotation. Values outside
903
+ * this range are added to or subtracted from 360 to obtain a value within
904
+ * the range. For example, the statement <code>my_video.rotation = 450</code>
905
+ * is the same as <code> my_video.rotation = 90</code>.
906
+ */
907
+ public rotation: number; //TODO
908
+
909
+ /**
910
+ * Indicates the x-axis rotation of the DisplayObject instance, in degrees,
911
+ * from its original orientation relative to the 3D parent container. Values
912
+ * from 0 to 180 represent clockwise rotation; values from 0 to -180
913
+ * represent counterclockwise rotation. Values outside this range are added
914
+ * to or subtracted from 360 to obtain a value within the range.
915
+ */
916
+ public get rotationX(): number {
917
+ return this._transform.rotation.x * MathConsts.RADIANS_TO_DEGREES;
918
+ }
919
+
920
+ public set rotationX(val: number) {
921
+ if (this.rotationX == val)
922
+ return;
923
+
924
+ this._transform.rotation.x = val * MathConsts.DEGREES_TO_RADIANS;
925
+
926
+ this._transform.invalidateMatrix3D();
927
+ }
928
+
929
+ /**
930
+ * Indicates the y-axis rotation of the DisplayObject instance, in degrees,
931
+ * from its original orientation relative to the 3D parent container. Values
932
+ * from 0 to 180 represent clockwise rotation; values from 0 to -180
933
+ * represent counterclockwise rotation. Values outside this range are added
934
+ * to or subtracted from 360 to obtain a value within the range.
935
+ */
936
+ public get rotationY(): number {
937
+ return this._transform.rotation.y * MathConsts.RADIANS_TO_DEGREES;
938
+ }
939
+
940
+ public set rotationY(val: number) {
941
+ if (this.rotationY == val)
942
+ return;
943
+
944
+ this._transform.rotation.y = val * MathConsts.DEGREES_TO_RADIANS;
945
+
946
+ this._transform.invalidateMatrix3D();
947
+ }
948
+
949
+ /**
950
+ * Indicates the z-axis rotation of the DisplayObject instance, in degrees,
951
+ * from its original orientation relative to the 3D parent container. Values
952
+ * from 0 to 180 represent clockwise rotation; values from 0 to -180
953
+ * represent counterclockwise rotation. Values outside this range are added
954
+ * to or subtracted from 360 to obtain a value within the range.
955
+ */
956
+ public get rotationZ(): number {
957
+ return this._transform.rotation.z * MathConsts.RADIANS_TO_DEGREES;
958
+ }
959
+
960
+ public set rotationZ(val: number) {
961
+ if (this.rotationZ == val)
962
+ return;
963
+
964
+ this._transform.rotation.z = val * MathConsts.DEGREES_TO_RADIANS;
965
+
966
+ this._transform.invalidateMatrix3D();
967
+ }
968
+
969
+ /**
970
+ * The current scaling grid that is in effect. If set to <code>null</code>,
971
+ * the entire display object is scaled normally when any scale transformation
972
+ * is applied.
973
+ *
974
+ * <p>When you define the <code>scale9Grid</code> property, the display
975
+ * object is divided into a grid with nine regions based on the
976
+ * <code>scale9Grid</code> rectangle, which defines the center region of the
977
+ * grid. The eight other regions of the grid are the following areas: </p>
978
+ *
979
+ * <ul>
980
+ * <li>The upper-left corner outside of the rectangle</li>
981
+ * <li>The area above the rectangle </li>
982
+ * <li>The upper-right corner outside of the rectangle</li>
983
+ * <li>The area to the left of the rectangle</li>
984
+ * <li>The area to the right of the rectangle</li>
985
+ * <li>The lower-left corner outside of the rectangle</li>
986
+ * <li>The area below the rectangle</li>
987
+ * <li>The lower-right corner outside of the rectangle</li>
988
+ * </ul>
989
+ *
990
+ * <p>You can think of the eight regions outside of the center(defined by
991
+ * the rectangle) as being like a picture frame that has special rules
992
+ * applied to it when scaled.</p>
993
+ *
994
+ * <p>When the <code>scale9Grid</code> property is set and a display object
995
+ * is scaled, all text and gradients are scaled normally; however, for other
996
+ * types of objects the following rules apply:</p>
997
+ *
998
+ * <ul>
999
+ * <li>Content in the center region is scaled normally. </li>
1000
+ * <li>Content in the corners is not scaled. </li>
1001
+ * <li>Content in the top and bottom regions is scaled horizontally only.
1002
+ * Content in the left and right regions is scaled vertically only.</li>
1003
+ * <li>All fills(including bitmaps, video, and gradients) are stretched to
1004
+ * fit their shapes.</li>
1005
+ * </ul>
1006
+ *
1007
+ * <p>If a display object is rotated, all subsequent scaling is normal(and
1008
+ * the <code>scale9Grid</code> property is ignored).</p>
1009
+ *
1010
+ * <p>For example, consider the following display object and a rectangle that
1011
+ * is applied as the display object's <code>scale9Grid</code>:</p>
1012
+ *
1013
+ * <p>A common use for setting <code>scale9Grid</code> is to set up a display
1014
+ * object to be used as a component, in which edge regions retain the same
1015
+ * width when the component is scaled.</p>
1016
+ *
1017
+ * @throws ArgumentError If you pass an invalid argument to the method.
1018
+ */
1019
+ public get scale9Grid(): Rectangle {
1020
+ return this._scale9Grid;
1021
+ }
1022
+
1023
+ public set scale9Grid(value: Rectangle) {
1024
+ this._scale9Grid = value;
1025
+
1026
+ this._invalidateHierarchicalProperty(HierarchicalProperty.SCALE9);
1027
+ }
1028
+
1029
+ /**
1030
+ * Indicates the horizontal scale(percentage) of the object as applied from
1031
+ * the registration point. The default registration point is(0,0). 1.0
1032
+ * equals 100% scale.
1033
+ *
1034
+ * <p>Scaling the local coordinate system changes the <code>x</code> and
1035
+ * <code>y</code> property values, which are defined in whole pixels. </p>
1036
+ */
1037
+ public get scaleX(): number {
1038
+ return this._transform.scale.x;
1039
+ }
1040
+
1041
+ public set scaleX(val: number) {
1042
+ //this._updateAbsoluteDimension();
1043
+
1044
+ this._setScaleX(val);
1045
+ }
1046
+
1047
+ /**
1048
+ * Indicates the vertical scale(percentage) of an object as applied from the
1049
+ * registration point of the object. The default registration point is(0,0).
1050
+ * 1.0 is 100% scale.
1051
+ *
1052
+ * <p>Scaling the local coordinate system changes the <code>x</code> and
1053
+ * <code>y</code> property values, which are defined in whole pixels. </p>
1054
+ */
1055
+ public get scaleY(): number {
1056
+ return this._transform.scale.y;
1057
+ }
1058
+
1059
+ public set scaleY(val: number) {
1060
+ //this._updateAbsoluteDimension();
1061
+
1062
+ this._setScaleY(val);
1063
+ }
1064
+
1065
+ /**
1066
+ * Indicates the depth scale(percentage) of an object as applied from the
1067
+ * registration point of the object. The default registration point is(0,0).
1068
+ * 1.0 is 100% scale.
1069
+ *
1070
+ * <p>Scaling the local coordinate system changes the <code>x</code>,
1071
+ * <code>y</code> and <code>z</code> property values, which are defined in
1072
+ * whole pixels. </p>
1073
+ */
1074
+ public get scaleZ(): number {
1075
+ return this._transform.scale.z;
1076
+ }
1077
+
1078
+ public set scaleZ(val: number) {
1079
+ //this._updateAbsoluteDimension();
1080
+
1081
+ this._setScaleZ(val);
1082
+ }
1083
+
1084
+ /**
1085
+ * Indicates the horizontal skew(angle) of the object as applied from
1086
+ * the registration point. The default registration point is(0,0).
1087
+ */
1088
+ public get skewX(): number {
1089
+ return this._transform.skew.x;
1090
+ }
1091
+
1092
+ public set skewX(val: number) {
1093
+ if (this.skewX == val)
1094
+ return;
1095
+
1096
+ this._transform.skew.x = val;
1097
+
1098
+ this._transform.invalidateMatrix3D();
1099
+ }
1100
+
1101
+ /**
1102
+ * Indicates the vertical skew(angle) of an object as applied from the
1103
+ * registration point of the object. The default registration point is(0,0).
1104
+ */
1105
+ public get skewY(): number {
1106
+ return this._transform.skew.y;
1107
+ }
1108
+
1109
+ public set skewY(val: number) {
1110
+ if (this.skewY == val)
1111
+ return;
1112
+
1113
+ this._transform.skew.y = val;
1114
+
1115
+ this._transform.invalidateMatrix3D();
1116
+ }
1117
+
1118
+ /**
1119
+ * Indicates the depth skew(angle) of an object as applied from the
1120
+ * registration point of the object. The default registration point is(0,0).
1121
+ */
1122
+ public get skewZ(): number {
1123
+ return this._transform.skew.z;
1124
+ }
1125
+
1126
+ public set skewZ(val: number) {
1127
+ if (this.skewZ == val)
1128
+ return;
1129
+
1130
+ this._transform.skew.z = val;
1131
+
1132
+ this._transform.invalidateMatrix3D();
1133
+ }
1134
+
1135
+ /**
1136
+ * The scroll rectangle bounds of the display object. The display object is
1137
+ * cropped to the size defined by the rectangle, and it scrolls within the
1138
+ * rectangle when you change the <code>x</code> and <code>y</code> properties
1139
+ * of the <code>scrollRect</code> object.
1140
+ *
1141
+ * <p>The properties of the <code>scrollRect</code> Rectangle object use the
1142
+ * display object's coordinate space and are scaled just like the overall
1143
+ * display object. The corner bounds of the cropped window on the scrolling
1144
+ * display object are the origin of the display object(0,0) and the point
1145
+ * defined by the width and height of the rectangle. They are not centered
1146
+ * around the origin, but use the origin to define the upper-left corner of
1147
+ * the area. A scrolled display object always scrolls in whole pixel
1148
+ * increments. </p>
1149
+ *
1150
+ * <p>You can scroll an object left and right by setting the <code>x</code>
1151
+ * property of the <code>scrollRect</code> Rectangle object. You can scroll
1152
+ * an object up and down by setting the <code>y</code> property of the
1153
+ * <code>scrollRect</code> Rectangle object. If the display object is rotated
1154
+ * 90° and you scroll it left and right, the display object actually scrolls
1155
+ * up and down.</p>
1156
+ */
1157
+ public get scrollRect(): Rectangle {
1158
+ return this._scrollRect;
1159
+ }
1160
+
1161
+ public set scrollRect(value: Rectangle) {
1162
+ // @todo: check if rectangle has same values as previous
1163
+ //if (this._scrollRect == value)
1164
+ // return;
1165
+
1166
+ this._scrollRect = value;
1167
+
1168
+ if (!value && this._scrollRectPrimitive) {
1169
+ const idx = this.masks.indexOf(this._scrollRectPrimitive);
1170
+ this.masks.splice(idx, 1);
1171
+ this._scrollRectPrimitive = null;
1172
+ }
1173
+
1174
+ this._transform.invalidatePosition();
1175
+ this._scrollRectPrimitiveDirty = true;
1176
+ }
1177
+
1178
+ /**
1179
+ *
1180
+ */
1181
+ public get material(): IMaterial {
1182
+ return this._material;
1183
+ }
1184
+
1185
+ public set material(value: IMaterial) {
1186
+ if (this._material == value)
1187
+ return;
1188
+
1189
+ this._material = value;
1190
+
1191
+ this._invalidateMaterial();
1192
+ }
1193
+
1194
+ /**
1195
+ *
1196
+ */
1197
+ public get style(): Style {
1198
+ return this._style;
1199
+ }
1200
+
1201
+ public set style(value: Style) {
1202
+ if (this._style == value)
1203
+ return;
1204
+
1205
+ if (this._style) {
1206
+ this._style.removeEventListener(StyleEvent.INVALIDATE_PROPERTIES, this._onInvalidatePropertiesDelegate);
1207
+ this._style.removeEventListener(StyleEvent.INVALIDATE_IMAGES, this._onInvalidateImagesDelegate);
1208
+ }
1209
+
1210
+ this._style = value;
1211
+
1212
+ if (this._style) {
1213
+ this._style.addEventListener(StyleEvent.INVALIDATE_PROPERTIES, this._onInvalidatePropertiesDelegate);
1214
+ this._style.addEventListener(StyleEvent.INVALIDATE_IMAGES, this._onInvalidateImagesDelegate);
1215
+ }
1216
+
1217
+ this._invalidateStyle();
1218
+ }
1219
+
1220
+ /**
1221
+ *
1222
+ */
1223
+ public get boundsVisible(): boolean {
1224
+ return this._boundsVisible;
1225
+ }
1226
+
1227
+ public set boundsVisible(value: boolean) {
1228
+ if (value == this._boundsVisible)
1229
+ return;
1230
+
1231
+ this._boundsVisible = value;
1232
+
1233
+ // if (this._boundsVisible && !this.partition)
1234
+ // this.partition = BasicPartition.getRootPartition(this);
1235
+
1236
+ this.invalidate();
1237
+ }
1238
+
1239
+ public getScrollRectPrimitive(): IPartitionContainer {
1240
+ if (this._scrollRectPrimitiveDirty) {
1241
+ this._scrollRectPrimitiveDirty = false;
1242
+
1243
+ if (!this._scrollRectPrimitive) {
1244
+ this._scrollRectPrimitive = new Sprite();
1245
+ this._scrollRectPrimitive.maskMode = true;
1246
+ if (!this.masks)
1247
+ this.masks = [];
1248
+ this.masks.push(this._scrollRectPrimitive);
1249
+ }
1250
+
1251
+ this._scrollRectPrimitive.graphics.clear();
1252
+ this._scrollRectPrimitive.graphics.beginFill(0x0000ff, 1);
1253
+ this._scrollRectPrimitive.graphics.drawRect(0,0,this._scrollRect.width,this._scrollRect.height);
1254
+ this._scrollRectPrimitive.graphics.endFill();
1255
+ }
1256
+
1257
+ return this._scrollRectPrimitive;
1258
+ }
1259
+
1260
+ public getBoundsPrimitive(picker: BoundsPicker): IPartitionContainer {
1261
+ if (this._boundsPrimitive == null) {
1262
+ switch (this._defaultBoundingVolume) {
1263
+ case BoundingVolumeType.BOX:
1264
+ case BoundingVolumeType.BOX_BOUNDS:
1265
+ case BoundingVolumeType.BOX_BOUNDS_FAST:
1266
+ case BoundingVolumeType.BOX_FAST:
1267
+ this._boundsPrefab = new PrimitiveCubePrefab(null, ElementsType.LINE);
1268
+ this._boundsPrimitive = this._boundsPrefab.getNewObject();
1269
+ break;
1270
+ case BoundingVolumeType.SPHERE:
1271
+ case BoundingVolumeType.SPHERE_BOUNDS:
1272
+ case BoundingVolumeType.SPHERE_BOUNDS_FAST:
1273
+ case BoundingVolumeType.SPHERE_FAST:
1274
+ this._boundsPrefab = new PrimitiveSpherePrefab(null, ElementsType.LINE);
1275
+ this._boundsPrimitive = this._boundsPrefab.getNewObject();
1276
+ break;
1277
+ default:
1278
+ }
1279
+
1280
+ this._boundsPrefabDirty = true;
1281
+ }
1282
+
1283
+ if (this._boundsPrefabDirty)
1284
+ this._updateBoundsPrefab(picker);
1285
+
1286
+ return this._boundsPrimitive;
1287
+ }
1288
+
1289
+ /**
1290
+ * An object with properties pertaining to a display object's matrix, color
1291
+ * transform, and pixel bounds. The specific properties - matrix,
1292
+ * colorTransform, and three read-only properties
1293
+ * (<code>concatenatedMatrix</code>, <code>concatenatedColorTransform</code>,
1294
+ * and <code>pixelBounds</code>) - are described in the entry for the
1295
+ * Transform class.
1296
+ *
1297
+ * <p>Each of the transform object's properties is itself an object. This
1298
+ * concept is important because the only way to set new values for the matrix
1299
+ * or colorTransform objects is to create a new object and copy that object
1300
+ * into the transform.matrix or transform.colorTransform property.</p>
1301
+ *
1302
+ * <p>For example, to increase the <code>tx</code> value of a display
1303
+ * object's matrix, you must make a copy of the entire matrix object, then
1304
+ * copy the new object into the matrix property of the transform object:</p>
1305
+ * <pre xml:space="preserve"><code> public myMatrix:Matrix =
1306
+ * myDisplayObject.transform.matrix; myMatrix.tx += 10;
1307
+ * myDisplayObject.transform.matrix = myMatrix; </code></pre>
1308
+ *
1309
+ * <p>You cannot directly set the <code>tx</code> property. The following
1310
+ * code has no effect on <code>myDisplayObject</code>: </p>
1311
+ * <pre xml:space="preserve"><code> myDisplayObject.transform.matrix.tx +=
1312
+ * 10; </code></pre>
1313
+ *
1314
+ * <p>You can also copy an entire transform object and assign it to another
1315
+ * display object's transform property. For example, the following code
1316
+ * copies the entire transform object from <code>myOldDisplayObj</code> to
1317
+ * <code>myNewDisplayObj</code>:</p>
1318
+ * <code>myNewDisplayObj.transform = myOldDisplayObj.transform;</code>
1319
+ *
1320
+ * <p>The resulting display object, <code>myNewDisplayObj</code>, now has the
1321
+ * same values for its matrix, color transform, and pixel bounds as the old
1322
+ * display object, <code>myOldDisplayObj</code>.</p>
1323
+ *
1324
+ * <p>Note that AIR for TV devices use hardware acceleration, if it is
1325
+ * available, for color transforms.</p>
1326
+ */
1327
+ public get transform(): Transform {
1328
+ return this._transform;
1329
+ }
1330
+
1331
+ /**
1332
+ * Whether or not the display object is visible. Display objects that are not
1333
+ * visible are disabled. For example, if <code>visible=false</code> for an
1334
+ * InteractiveObject instance, it cannot be clicked.
1335
+ */
1336
+ public get visible(): boolean {
1337
+ return this._visible;
1338
+ }
1339
+
1340
+ public set visible(value: boolean) {
1341
+ if (this._visible == value)
1342
+ return;
1343
+
1344
+ this._visible = value;
1345
+
1346
+ this._invalidateHierarchicalProperty(HierarchicalProperty.VISIBLE);
1347
+ }
1348
+
1349
+ private _mergeMasks(timeline: Array<DisplayObject> | null, script: DisplayObject | null): Array<DisplayObject> {
1350
+ if (!timeline && !script)
1351
+ return;
1352
+
1353
+ // we can not have mask array, create it
1354
+ if (!timeline && script)
1355
+ return [script];
1356
+
1357
+ // and make sure that we not have same script mask in it
1358
+ if (script && !timeline.includes(script))
1359
+ timeline.push(script);
1360
+
1361
+ return timeline;
1362
+ }
1363
+
1364
+ private _setMasks(masks: Array<DisplayObject> | null): void {
1365
+ const oldMasks: Array<DisplayObject> = this._masks ? this._masks : [];
1366
+
1367
+ if (masks) {
1368
+
1369
+ // and make sure that mask mode enabled if not already
1370
+ for (let i = masks.length - 1; i >= 0 ; i--) {
1371
+ const mask = masks[i];
1372
+
1373
+ if (!mask) {
1374
+ console.warn('[DisplayObject] Timeline mask has null value, skipping it');
1375
+ masks.splice(i, 1);
1376
+ } else {
1377
+ const index = oldMasks.indexOf(mask);
1378
+ if (index != -1) {
1379
+ oldMasks.splice(index, 1);
1380
+ } else {
1381
+ mask.maskMode = true;
1382
+ }
1383
+ }
1384
+ }
1385
+ }
1386
+
1387
+ //set mask mode to false for old masks
1388
+ for (let i = oldMasks.length - 1; i >= 0 ; i--)
1389
+ oldMasks[i].maskMode = false;
1390
+
1391
+ this._masks = masks;
1392
+ }
1393
+
1394
+ /**
1395
+ *
1396
+ * @param mask Masked element, that can be used from script without corruption of timeline mask
1397
+ */
1398
+ public set scriptMask(mask: DisplayObject | null) {
1399
+ if (mask === this._scriptMask)
1400
+ return;
1401
+
1402
+ // remove older script mask, _mask array for this case can't be null
1403
+ if (this._scriptMask) {
1404
+ const index = this._masks.indexOf(this._scriptMask);
1405
+
1406
+ if (index !== -1) {
1407
+ this._masks.splice(index, 1);
1408
+ this._scriptMask.maskMode = false;
1409
+ }
1410
+ }
1411
+
1412
+ this._scriptMask = mask;
1413
+
1414
+ this._masks = this._mergeMasks(this._masks, mask);
1415
+
1416
+ if (mask)
1417
+ mask.maskMode = true;
1418
+
1419
+ this._invalidateHierarchicalProperty(HierarchicalProperty.MASKS);
1420
+ }
1421
+
1422
+ public get scriptMask() {
1423
+ return this._scriptMask;
1424
+ }
1425
+
1426
+ /**
1427
+ * Update mask from timeline and take account that can be a scriptMask
1428
+ *
1429
+ * @param masks Masks from timeline
1430
+ */
1431
+ public updateTimelineMask(masks: DisplayObject[] | null) {
1432
+ this._setMasks(this._mergeMasks(masks, this._scriptMask));
1433
+
1434
+ this._invalidateHierarchicalProperty(HierarchicalProperty.MASKS);
1435
+ }
1436
+
1437
+ public get masks(): Array<DisplayObject> {
1438
+ return this._masks;
1439
+ }
1440
+
1441
+ /**
1442
+ * @dangerous Note that we should not use this setter, right way to use `scriptMask` and `updateTimelineMask`
1443
+ * @param value
1444
+ */
1445
+ public set masks(value: Array<DisplayObject>) {
1446
+ if (this._masks == value)
1447
+ return;
1448
+
1449
+ // this is edge case, if we set masks direct,
1450
+ // this means that we should reset _scriptMask when it not present in input mask
1451
+ if (!value || !value.length) {
1452
+ this._scriptMask = null;
1453
+ } else {
1454
+ const len = value.length;
1455
+ let hasScriptMask = false;
1456
+
1457
+ for (let i = 0; i < len; i++)
1458
+ hasScriptMask = hasScriptMask || (value[i] === this._scriptMask);
1459
+
1460
+ //if we had a script mask set but it wasn't present in the new masks value, remove it
1461
+ if (this._scriptMask && !hasScriptMask)
1462
+ this._scriptMask = null;
1463
+ }
1464
+
1465
+ this._setMasks(value);
1466
+
1467
+ this._invalidateHierarchicalProperty(HierarchicalProperty.MASKS);
1468
+ }
1469
+
1470
+ /**
1471
+ * Determines whether or not the children of the object are mouse, or user
1472
+ * input device, enabled. If an object is enabled, a user can interact with
1473
+ * it by using a mouse or user input device. The default is
1474
+ * <code>true</code>.
1475
+ *
1476
+ * <p>This property is useful when you create a button with an instance of
1477
+ * the Sprite class(instead of using the SimpleButton class). When you use a
1478
+ * Sprite instance to create a button, you can choose to decorate the button
1479
+ * by using the <code>addChild()</code> method to add additional Sprite
1480
+ * instances. This process can cause unexpected behavior with mouse events
1481
+ * because the Sprite instances you add as children can become the target
1482
+ * object of a mouse event when you expect the parent instance to be the
1483
+ * target object. To ensure that the parent instance serves as the target
1484
+ * objects for mouse events, you can set the <code>mouseChildren</code>
1485
+ * property of the parent instance to <code>false</code>.</p>
1486
+ *
1487
+ * <p> No event is dispatched by setting this property. You must use the
1488
+ * <code>addEventListener()</code> method to create interactive
1489
+ * functionality.</p>
1490
+ */
1491
+ public get mouseChildren(): boolean {
1492
+ return this._mouseChildren;
1493
+ }
1494
+
1495
+ public set mouseChildren(value: boolean) {
1496
+ if (this._mouseChildren == value)
1497
+ return;
1498
+
1499
+ this._mouseChildren = value;
1500
+
1501
+ this._invalidateHierarchicalProperty(HierarchicalProperty.MOUSE_ENABLED);
1502
+ }
1503
+
1504
+ /**
1505
+ * Indicates the <i>x</i> coordinate of the DisplayObject instance relative
1506
+ * to the local coordinates of the parent DisplayObjectContainer. If the
1507
+ * object is inside a DisplayObjectContainer that has transformations, it is
1508
+ * in the local coordinate system of the enclosing DisplayObjectContainer.
1509
+ * Thus, for a DisplayObjectContainer rotated 90° counterclockwise, the
1510
+ * DisplayObjectContainer's children inherit a coordinate system that is
1511
+ * rotated 90° counterclockwise. The object's coordinates refer to the
1512
+ * registration point position.
1513
+ */
1514
+ public get x(): number {
1515
+ return this._transform.position.x;
1516
+ }
1517
+
1518
+ public set x(val: number) {
1519
+ if (this._transform.position.x == val)
1520
+ return;
1521
+
1522
+ this._transform.matrix3D._rawData[12] = val;
1523
+
1524
+ this._transform.invalidatePosition();
1525
+ }
1526
+
1527
+ /**
1528
+ * Indicates the <i>y</i> coordinate of the DisplayObject instance relative
1529
+ * to the local coordinates of the parent DisplayObjectContainer. If the
1530
+ * object is inside a DisplayObjectContainer that has transformations, it is
1531
+ * in the local coordinate system of the enclosing DisplayObjectContainer.
1532
+ * Thus, for a DisplayObjectContainer rotated 90° counterclockwise, the
1533
+ * DisplayObjectContainer's children inherit a coordinate system that is
1534
+ * rotated 90° counterclockwise. The object's coordinates refer to the
1535
+ * registration point position.
1536
+ */
1537
+ public get y(): number {
1538
+ return this._transform.position.y;
1539
+ }
1540
+
1541
+ public set y(val: number) {
1542
+ if (this._transform.position.y == val)
1543
+ return;
1544
+
1545
+ this._transform.matrix3D._rawData[13] = val;
1546
+
1547
+ this._transform.invalidatePosition();
1548
+ }
1549
+
1550
+ /**
1551
+ * Indicates the z coordinate position along the z-axis of the DisplayObject
1552
+ * instance relative to the 3D parent container. The z property is used for
1553
+ * 3D coordinates, not screen or pixel coordinates.
1554
+ *
1555
+ * <p>When you set a <code>z</code> property for a display object to
1556
+ * something other than the default value of <code>0</code>, a corresponding
1557
+ * Matrix3D object is automatically created. for adjusting a display object's
1558
+ * position and orientation in three dimensions. When working with the
1559
+ * z-axis, the existing behavior of x and y properties changes from screen or
1560
+ * pixel coordinates to positions relative to the 3D parent container.</p>
1561
+ *
1562
+ * <p>For example, a child of the <code>_root</code> at position x = 100, y =
1563
+ * 100, z = 200 is not drawn at pixel location(100,100). The child is drawn
1564
+ * wherever the 3D projection calculation puts it. The calculation is:</p>
1565
+ *
1566
+ * <p><code>(x~~cameraFocalLength/cameraRelativeZPosition,
1567
+ * y~~cameraFocalLength/cameraRelativeZPosition)</code></p>
1568
+ */
1569
+ public get z(): number {
1570
+ return this._transform.position.z;
1571
+ }
1572
+
1573
+ public set z(val: number) {
1574
+ if (this._transform.position.z == val)
1575
+ return;
1576
+
1577
+ this._transform.matrix3D._rawData[14] = val;
1578
+
1579
+ this._transform.invalidatePosition();
1580
+ }
1581
+
1582
+ /**
1583
+ *
1584
+ */
1585
+ public zOffset: number = 0;
1586
+
1587
+ /**
1588
+ * Creates a new <code>DisplayObject</code> instance.
1589
+ */
1590
+ constructor() {
1591
+ super();
1592
+
1593
+ this.cursorType = '';
1594
+ this._isInFocus = false;
1595
+ this._tabEnabled = false;
1596
+ this._tabIndex = -1;
1597
+ this._avmDepthID = -1;
1598
+ //global debug bounding boxes:
1599
+ //this._boundsVisible=true;
1600
+ this._onInvalidatePropertiesDelegate = (event: StyleEvent) => this._onInvalidateProperties(event);
1601
+ this._onInvalidateImagesDelegate = (event: StyleEvent) => this._onInvalidateImages(event);
1602
+
1603
+ //creation of associated transform object
1604
+ this._transform = new Transform(null);
1605
+
1606
+ //setup transform listeners
1607
+ this._transform.addEventListener(
1608
+ TransformEvent.INVALIDATE_MATRIX3D,
1609
+ (_event: TransformEvent) => this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM)
1610
+ );
1611
+
1612
+ this._transform.addEventListener(
1613
+ TransformEvent.INVALIDATE_COLOR_TRANSFORM,
1614
+ (_event: TransformEvent) => this._invalidateHierarchicalProperty(HierarchicalProperty.COLOR_TRANSFORM)
1615
+ );
1616
+
1617
+ //bounding volume dictonary
1618
+
1619
+ //default bounds type
1620
+ this._defaultBoundingVolume = this._getDefaultBoundingVolume();
1621
+ }
1622
+
1623
+ public advanceFrame(): void {
1624
+ //default to do nothing
1625
+ }
1626
+
1627
+ public getEntity(): IPartitionEntity {
1628
+ return;
1629
+ }
1630
+
1631
+ public _initNode(node: ContainerNode): void {}
1632
+
1633
+ /**
1634
+ *
1635
+ */
1636
+ public clone(): DisplayObject {
1637
+ const newInstance: DisplayObject = new DisplayObject();
1638
+
1639
+ this.copyTo(newInstance);
1640
+
1641
+ return newInstance;
1642
+ }
1643
+
1644
+ public copyTo(displayObject: DisplayObject): void {
1645
+ displayObject.defaultBoundingVolume = this._defaultBoundingVolume;
1646
+
1647
+ if (this._registrationMatrix3D)
1648
+ displayObject._registrationMatrix3D = this._registrationMatrix3D.clone();
1649
+
1650
+ displayObject.mouseChildren = this._mouseChildren;
1651
+ displayObject.material = this._material;
1652
+ displayObject.style = this._style;
1653
+ displayObject.pickObject = this._pickObject;
1654
+ displayObject.pickObjectFromTimeline = this.pickObjectFromTimeline;
1655
+
1656
+ displayObject.boundsVisible = this._boundsVisible;
1657
+ displayObject.name = this._pName;
1658
+ displayObject.mouseEnabled = this._mouseEnabled;
1659
+ displayObject.extra = this.extra;
1660
+ displayObject.maskMode = this._maskMode;
1661
+ displayObject.castsShadows = this.castsShadows;
1662
+ displayObject.assetNamespace = this.assetNamespace;
1663
+ displayObject._symbol = this._symbol;
1664
+ displayObject.avm1Symbol = this.avm1Symbol;
1665
+ displayObject.isAVMScene = this.isAVMScene;
1666
+
1667
+ displayObject.isSlice9ScaledMC = this.isSlice9ScaledMC;
1668
+ displayObject.scale9Grid = this.scale9Grid?.clone();
1669
+
1670
+ if (this._masks) {
1671
+ // clone mask tree, to avoid corruption
1672
+ // if _scriptMask is presented, it already was exist in _mask array
1673
+ displayObject._masks = this._masks.slice();
1674
+ displayObject._scriptMask = this._scriptMask;
1675
+ // manually call invalidation
1676
+ displayObject._invalidateHierarchicalProperty(HierarchicalProperty.MASKS);
1677
+ }
1678
+
1679
+ this._transform.copyRawDataTo(displayObject._transform);
1680
+ }
1681
+
1682
+ /**
1683
+ *
1684
+ */
1685
+ public dispose(): void {
1686
+ this.disposeValues();
1687
+ }
1688
+
1689
+ public disposeValues(): void {
1690
+ if (this._parent)
1691
+ this._parent.removeChild(this);
1692
+
1693
+ this.material = null;
1694
+
1695
+ if (this._adapter) {
1696
+ this._adapter.dispose();
1697
+ this._adapter = null;
1698
+ }
1699
+
1700
+ this._pickObject = null;
1701
+
1702
+ this._masks = null;
1703
+ this._scriptMask = null;
1704
+ }
1705
+
1706
+ /**
1707
+ * Rotates the 3d object around to face a point defined relative
1708
+ * to the local coordinates of the parent <code>ObjectContainer3D</code>.
1709
+ *
1710
+ * @param scenePosition The vector defining the point to be looked at
1711
+ * @param upAxis An optional vector used to define the desired
1712
+ * up orientation of the 3d object after rotation has occurred
1713
+ */
1714
+ public lookAt(scenePosition: Vector3D, upAxis: Vector3D = null): void {
1715
+ this.transform.lookAt(scenePosition, upAxis);
1716
+ }
1717
+
1718
+ /**
1719
+ * Moves the local point around which the object rotates.
1720
+ *
1721
+ * @param dx The amount of movement along the local x axis.
1722
+ * @param dy The amount of movement along the local y axis.
1723
+ * @param dz The amount of movement along the local z axis.
1724
+ */
1725
+ public movePivot(dx: number, dy: number, dz: number): void {
1726
+ if (dx == 0 && dy == 0 && dz == 0)
1727
+ return;
1728
+
1729
+ if (!this._registrationMatrix3D)
1730
+ this._registrationMatrix3D = new Matrix3D();
1731
+
1732
+ this._registrationMatrix3D._rawData[12] -= dx / this._transform.scale.x;
1733
+ this._registrationMatrix3D._rawData[13] -= dy / this._transform.scale.y;
1734
+ this._registrationMatrix3D._rawData[14] -= dz / this._transform.scale.z;
1735
+
1736
+ this._invalidateHierarchicalProperty(HierarchicalProperty.SCENE_TRANSFORM);
1737
+ }
1738
+
1739
+ public reset(): void {
1740
+ this.visible = true;
1741
+ if (!(<any> this).noTimelineUpdate)
1742
+ this._transform.clearMatrix3D();
1743
+
1744
+ this._transform.clearColorTransform();
1745
+
1746
+ //this.name="";
1747
+ this.masks = null;
1748
+
1749
+ this.maskMode = false;
1750
+ }
1751
+
1752
+ /**
1753
+ * @internal
1754
+ */
1755
+ public _iController: ControllerBase;
1756
+
1757
+ public hasDispatchedAddedToStage: boolean=false;
1758
+ /*
1759
+ this checks if the mc is part of the displaylist (child of the stage)
1760
+ todo: probably not the best way to do this
1761
+ probably better to get this info by looking at root
1762
+ */
1763
+ public isOnDisplayList(): boolean {
1764
+ let parent: DisplayObject = this;
1765
+ while (parent) {
1766
+ if (parent.isAVMScene)
1767
+ return true;
1768
+ parent = parent.parent;
1769
+ }
1770
+ return false;
1771
+ }
1772
+
1773
+ /**
1774
+ * @internal
1775
+ */
1776
+ public _setParent(parent: DisplayObjectContainer): void {
1777
+ this._parent = parent;
1778
+ }
1779
+
1780
+ public _invalidateHierarchicalProperty(propDirty: HierarchicalProperty): void {
1781
+ this.dispatchEvent(new HeirarchicalEvent(HeirarchicalEvent.INVALIDATE_PROPERTY, propDirty));
1782
+ }
1783
+
1784
+ /**
1785
+ *
1786
+ */
1787
+ public _iInternalUpdate(): void {
1788
+ if (this._iController)
1789
+ this._iController.update();
1790
+ }
1791
+
1792
+ /**
1793
+ * @internal
1794
+ */
1795
+ public get maskId(): number {
1796
+ return this._maskId;
1797
+ }
1798
+
1799
+ protected _setScaleX(val: number): void {
1800
+ if (this.scaleX == val)
1801
+ return;
1802
+
1803
+ this._transform.scale.x = val;
1804
+
1805
+ this._transform.invalidateMatrix3D();
1806
+ }
1807
+
1808
+ protected _setScaleY(val: number): void {
1809
+ if (this.scaleY == val)
1810
+ return;
1811
+
1812
+ this._transform.scale.y = val;
1813
+
1814
+ this._transform.invalidateMatrix3D();
1815
+ }
1816
+
1817
+ protected _setScaleZ(val: number): void {
1818
+ if (this.scaleZ == val)
1819
+ return;
1820
+
1821
+ this._transform.scale.z = val;
1822
+
1823
+ this._transform.invalidateMatrix3D();
1824
+ }
1825
+
1826
+ private _updateBoundsPrefab(picker: BoundsPicker): void {
1827
+ if (this._boundsPrefab instanceof PrimitiveCubePrefab) {
1828
+ const box = (<BoundingBox> picker.getBoundingVolume(null, this._defaultBoundingVolume)).getBox();
1829
+
1830
+ //TODO: if box is null, no prefab should be visible
1831
+ if (box == null)
1832
+ return;
1833
+
1834
+ this._boundsPrefab.width = box.width;
1835
+ this._boundsPrefab.height = box.height;
1836
+ this._boundsPrefab.depth = box.depth;
1837
+
1838
+ this._boundsPrimitive.registrationPoint = new Vector3D(
1839
+ -(box.x + box.width / 2) * this._boundsPrimitive.transform.scale.x,
1840
+ -(box.y + box.height / 2) * this._boundsPrimitive.transform.scale.y,
1841
+ -(box.z + box.depth / 2) * this._boundsPrimitive.transform.scale.z);
1842
+
1843
+ } else if (this._boundsPrefab instanceof PrimitiveSpherePrefab) {
1844
+
1845
+ const sphere: Sphere = (<BoundingSphere> picker.getBoundingVolume(
1846
+ null,
1847
+ this._defaultBoundingVolume)).getSphere();
1848
+
1849
+ //console.log(sphere);
1850
+ if (sphere == null)
1851
+ return;
1852
+
1853
+ this._boundsPrefab.radius = sphere.radius;
1854
+
1855
+ this._boundsPrimitive.registrationPoint = new Vector3D(
1856
+ -sphere.x * this._boundsPrimitive.transform.scale.x,
1857
+ -sphere.y * this._boundsPrimitive.transform.scale.y,
1858
+ -sphere.z * this._boundsPrimitive.transform.scale.z);
1859
+ }
1860
+ }
1861
+
1862
+ protected _updateMaskMode(): void {
1863
+ if (this._maskMode) {
1864
+ this._mouseEnabled = false;
1865
+ this.partitionClass = BasicPartition;
1866
+ }
1867
+
1868
+ this._invalidateHierarchicalProperty(HierarchicalProperty.MASK_ID);
1869
+ }
1870
+
1871
+ public _invalidateMaterial(): void {
1872
+ this.dispatchEvent(new RenderableEvent(RenderableEvent.INVALIDATE_MATERIAL, this));
1873
+ }
1874
+
1875
+ private _invalidateStyle(): void {
1876
+ this.dispatchEvent(new RenderableEvent(RenderableEvent.INVALIDATE_STYLE, this));
1877
+ }
1878
+
1879
+ public invalidateElements(): void {
1880
+ this.dispatchEvent(new RenderableEvent(RenderableEvent.INVALIDATE_ELEMENTS, this));
1881
+ }
1882
+
1883
+ protected _onInvalidateProperties(_event: StyleEvent = null): void {
1884
+ this._invalidateStyle();
1885
+ }
1886
+
1887
+ protected _onInvalidateImages(_event: StyleEvent = null): void {
1888
+ this.invalidate();
1889
+ }
1890
+
1891
+ protected _getDefaultBoundingVolume(): BoundingVolumeType {
1892
+ return BoundingVolumeType.BOX_BOUNDS_FAST;
1893
+ }
1894
1894
  }