@awayjs/scene 0.13.323 → 0.13.324

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