@awayjs/scene 0.13.265 → 0.13.267

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