@blakron/core 0.5.18 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +29 -30
- package/dist/blakron/benchmark/SceneRegistry.js +13 -13
- package/dist/blakron/benchmark/SceneRegistry.js.map +1 -1
- package/dist/blakron/display/Bitmap.d.ts +4 -4
- package/dist/blakron/display/Bitmap.d.ts.map +1 -1
- package/dist/blakron/display/Bitmap.js +23 -23
- package/dist/blakron/display/Bitmap.js.map +1 -1
- package/dist/blakron/display/DisplayObject.d.ts +82 -86
- package/dist/blakron/display/DisplayObject.d.ts.map +1 -1
- package/dist/blakron/display/DisplayObject.js +293 -331
- package/dist/blakron/display/DisplayObject.js.map +1 -1
- package/dist/blakron/display/DisplayObjectContainer.d.ts +9 -8
- package/dist/blakron/display/DisplayObjectContainer.d.ts.map +1 -1
- package/dist/blakron/display/DisplayObjectContainer.js +86 -101
- package/dist/blakron/display/DisplayObjectContainer.js.map +1 -1
- package/dist/blakron/display/Graphics.d.ts +3 -3
- package/dist/blakron/display/Graphics.d.ts.map +1 -1
- package/dist/blakron/display/Graphics.js +6 -6
- package/dist/blakron/display/Graphics.js.map +1 -1
- package/dist/blakron/display/Mesh.d.ts +1 -1
- package/dist/blakron/display/Mesh.d.ts.map +1 -1
- package/dist/blakron/display/Mesh.js +4 -4
- package/dist/blakron/display/Mesh.js.map +1 -1
- package/dist/blakron/display/Shape.d.ts +3 -3
- package/dist/blakron/display/Shape.d.ts.map +1 -1
- package/dist/blakron/display/Shape.js +10 -10
- package/dist/blakron/display/Shape.js.map +1 -1
- package/dist/blakron/display/Sprite.d.ts +3 -3
- package/dist/blakron/display/Sprite.d.ts.map +1 -1
- package/dist/blakron/display/Sprite.js +10 -10
- package/dist/blakron/display/Sprite.js.map +1 -1
- package/dist/blakron/display/Stage.js +2 -2
- package/dist/blakron/display/Stage.js.map +1 -1
- package/dist/blakron/display/texture/BitmapData.d.ts.map +1 -1
- package/dist/blakron/display/texture/BitmapData.js +13 -26
- package/dist/blakron/display/texture/BitmapData.js.map +1 -1
- package/dist/blakron/display/texture/RenderTexture.js +1 -1
- package/dist/blakron/display/texture/RenderTexture.js.map +1 -1
- package/dist/blakron/events/Event.d.ts.map +1 -1
- package/dist/blakron/events/Event.js +1 -0
- package/dist/blakron/events/Event.js.map +1 -1
- package/dist/blakron/events/EventDispatcher.d.ts.map +1 -1
- package/dist/blakron/events/EventDispatcher.js +13 -12
- package/dist/blakron/events/EventDispatcher.js.map +1 -1
- package/dist/blakron/events/TouchEvent.js +2 -2
- package/dist/blakron/events/TouchEvent.js.map +1 -1
- package/dist/blakron/filters/ColorMatrixFilter.d.ts +1 -1
- package/dist/blakron/filters/ColorMatrixFilter.d.ts.map +1 -1
- package/dist/blakron/filters/ColorMatrixFilter.js +3 -3
- package/dist/blakron/filters/ColorMatrixFilter.js.map +1 -1
- package/dist/blakron/media/Sound.d.ts +1 -0
- package/dist/blakron/media/Sound.d.ts.map +1 -1
- package/dist/blakron/media/Sound.js +23 -5
- package/dist/blakron/media/Sound.js.map +1 -1
- package/dist/blakron/media/Video.d.ts +1 -1
- package/dist/blakron/media/Video.d.ts.map +1 -1
- package/dist/blakron/media/Video.js +5 -5
- package/dist/blakron/media/Video.js.map +1 -1
- package/dist/blakron/net/HttpMethod.d.ts +6 -0
- package/dist/blakron/net/HttpMethod.d.ts.map +1 -1
- package/dist/blakron/net/HttpMethod.js +5 -0
- package/dist/blakron/net/HttpMethod.js.map +1 -1
- package/dist/blakron/net/HttpRequest.d.ts +40 -0
- package/dist/blakron/net/HttpRequest.d.ts.map +1 -1
- package/dist/blakron/net/HttpRequest.js +60 -2
- package/dist/blakron/net/HttpRequest.js.map +1 -1
- package/dist/blakron/net/HttpResponseType.d.ts +6 -0
- package/dist/blakron/net/HttpResponseType.d.ts.map +1 -1
- package/dist/blakron/net/HttpResponseType.js +5 -0
- package/dist/blakron/net/HttpResponseType.js.map +1 -1
- package/dist/blakron/net/ImageLoader.d.ts +18 -0
- package/dist/blakron/net/ImageLoader.d.ts.map +1 -1
- package/dist/blakron/net/ImageLoader.js +26 -4
- package/dist/blakron/net/ImageLoader.js.map +1 -1
- package/dist/blakron/player/Player.d.ts.map +1 -1
- package/dist/blakron/player/Player.js +18 -6
- package/dist/blakron/player/Player.js.map +1 -1
- package/dist/blakron/player/RenderPipe.d.ts +1 -1
- package/dist/blakron/player/SystemTicker.js +2 -2
- package/dist/blakron/player/SystemTicker.js.map +1 -1
- package/dist/blakron/player/TouchHandler.js +1 -1
- package/dist/blakron/player/TouchHandler.js.map +1 -1
- package/dist/blakron/player/canvas/CanvasRenderer.js +52 -52
- package/dist/blakron/player/canvas/CanvasRenderer.js.map +1 -1
- package/dist/blakron/player/canvas/DisplayList.js +1 -1
- package/dist/blakron/player/canvas/DisplayList.js.map +1 -1
- package/dist/blakron/player/webgl/WebGLRenderContext.d.ts +2 -5
- package/dist/blakron/player/webgl/WebGLRenderContext.d.ts.map +1 -1
- package/dist/blakron/player/webgl/WebGLRenderContext.js +3 -11
- package/dist/blakron/player/webgl/WebGLRenderContext.js.map +1 -1
- package/dist/blakron/player/webgl/WebGLRenderer.d.ts +107 -4
- package/dist/blakron/player/webgl/WebGLRenderer.d.ts.map +1 -1
- package/dist/blakron/player/webgl/WebGLRenderer.js +194 -91
- package/dist/blakron/player/webgl/WebGLRenderer.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/FilterPipe.js +7 -7
- package/dist/blakron/player/webgl/pipes/FilterPipe.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/GraphicsPipe.js +1 -1
- package/dist/blakron/player/webgl/pipes/GraphicsPipe.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/MaskPipe.js +12 -12
- package/dist/blakron/player/webgl/pipes/MaskPipe.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/ParticlePipe.js +1 -1
- package/dist/blakron/player/webgl/pipes/ParticlePipe.js.map +1 -1
- package/dist/blakron/player/webgl/pipes/TextPipe.d.ts +3 -1
- package/dist/blakron/player/webgl/pipes/TextPipe.d.ts.map +1 -1
- package/dist/blakron/player/webgl/pipes/TextPipe.js +42 -5
- package/dist/blakron/player/webgl/pipes/TextPipe.js.map +1 -1
- package/dist/blakron/resource/Resource.d.ts +16 -4
- package/dist/blakron/resource/Resource.d.ts.map +1 -1
- package/dist/blakron/resource/Resource.js +30 -20
- package/dist/blakron/resource/Resource.js.map +1 -1
- package/dist/blakron/resource/ResourceLoader.d.ts +20 -0
- package/dist/blakron/resource/ResourceLoader.d.ts.map +1 -1
- package/dist/blakron/resource/ResourceLoader.js +44 -16
- package/dist/blakron/resource/ResourceLoader.js.map +1 -1
- package/dist/blakron/system/Capabilities.d.ts +1 -1
- package/dist/blakron/system/Capabilities.d.ts.map +1 -1
- package/dist/blakron/system/Capabilities.js +1 -1
- package/dist/blakron/system/Capabilities.js.map +1 -1
- package/dist/blakron/text/BitmapText.d.ts +1 -1
- package/dist/blakron/text/BitmapText.d.ts.map +1 -1
- package/dist/blakron/text/BitmapText.js +11 -11
- package/dist/blakron/text/BitmapText.js.map +1 -1
- package/dist/blakron/text/InputController.js +1 -1
- package/dist/blakron/text/InputController.js.map +1 -1
- package/dist/blakron/text/TextField.d.ts +3 -3
- package/dist/blakron/text/TextField.d.ts.map +1 -1
- package/dist/blakron/text/TextField.js +33 -33
- package/dist/blakron/text/TextField.js.map +1 -1
- package/dist/blakron/utils/ByteArray.d.ts +0 -1
- package/dist/blakron/utils/ByteArray.d.ts.map +1 -1
- package/dist/blakron/utils/ByteArray.js +2 -5
- package/dist/blakron/utils/ByteArray.js.map +1 -1
- package/package.json +4 -6
|
@@ -17,108 +17,70 @@ function clampRotation(value) {
|
|
|
17
17
|
export class DisplayObject extends EventDispatcher {
|
|
18
18
|
// ── Static fields ─────────────────────────────────────────────────────────
|
|
19
19
|
static defaultTouchEnabled = false;
|
|
20
|
-
static enterFrameCallBackList = [];
|
|
21
|
-
static renderCallBackList = [];
|
|
22
|
-
static eventAddToStageList = [];
|
|
23
|
-
static eventRemoveFromStageList = [];
|
|
20
|
+
static $enterFrameCallBackList = [];
|
|
21
|
+
static $renderCallBackList = [];
|
|
22
|
+
static $eventAddToStageList = [];
|
|
23
|
+
static $eventRemoveFromStageList = [];
|
|
24
24
|
/**
|
|
25
25
|
* @internal
|
|
26
|
-
* Injected by Player at startup. Called when renderMode changes (visible,
|
|
26
|
+
* Injected by Player at startup. Called when $renderMode changes (visible,
|
|
27
27
|
* filters, mask, blendMode) so the WebGLRenderer can mark its InstructionSet dirty.
|
|
28
|
+
*
|
|
29
|
+
* Single-Player engine: Player assigns this directly in its constructor and
|
|
30
|
+
* clears it in `destroy()`. There is intentionally no registration API.
|
|
28
31
|
*/
|
|
29
|
-
static
|
|
32
|
+
static $onStructureChange;
|
|
30
33
|
/**
|
|
31
34
|
* @internal
|
|
32
35
|
* Injected by Player at startup. Called when a DisplayObject's visual data
|
|
33
36
|
* changes (position, texture, alpha, tint) but the scene structure is unchanged.
|
|
34
37
|
* The renderer uses this to update the transform snapshot in the InstructionSet
|
|
35
38
|
* without doing a full rebuild.
|
|
39
|
+
*
|
|
40
|
+
* Single-Player engine: Player assigns this directly in its constructor and
|
|
41
|
+
* clears it in `destroy()`. There is intentionally no registration API.
|
|
36
42
|
*/
|
|
37
|
-
static
|
|
38
|
-
/**
|
|
39
|
-
* @internal Register a structure-change listener. Returns an unregister function.
|
|
40
|
-
* Using a registration pattern instead of a single static field supports
|
|
41
|
-
* multiple Player instances on the same page.
|
|
42
|
-
*/
|
|
43
|
-
static addStructureChangeListener(fn) {
|
|
44
|
-
const prev = DisplayObject._onStructureChange;
|
|
45
|
-
if (!prev) {
|
|
46
|
-
DisplayObject._onStructureChange = fn;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
DisplayObject._onStructureChange = () => {
|
|
50
|
-
prev();
|
|
51
|
-
fn();
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return () => {
|
|
55
|
-
// Simple removal: if only one listener, clear; otherwise rebuild chain.
|
|
56
|
-
// For the common single-player case this is zero overhead.
|
|
57
|
-
if (DisplayObject._onStructureChange === fn) {
|
|
58
|
-
DisplayObject._onStructureChange = undefined;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* @internal Register a renderable-dirty listener. Returns an unregister function.
|
|
64
|
-
*/
|
|
65
|
-
static addRenderableDirtyListener(fn) {
|
|
66
|
-
const prev = DisplayObject._onRenderableDirty;
|
|
67
|
-
if (!prev) {
|
|
68
|
-
DisplayObject._onRenderableDirty = fn;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
DisplayObject._onRenderableDirty = obj => {
|
|
72
|
-
prev(obj);
|
|
73
|
-
fn(obj);
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
return () => {
|
|
77
|
-
if (DisplayObject._onRenderableDirty === fn) {
|
|
78
|
-
DisplayObject._onRenderableDirty = undefined;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
43
|
+
static $onRenderableDirty;
|
|
82
44
|
// ── Instance fields ───────────────────────────────────────────────────────
|
|
83
45
|
// 场景图
|
|
84
|
-
hasAddToStage = false;
|
|
85
|
-
children;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
nestLevel = 0;
|
|
46
|
+
$hasAddToStage = false;
|
|
47
|
+
$children;
|
|
48
|
+
$parent;
|
|
49
|
+
$stage;
|
|
50
|
+
$nestLevel = 0;
|
|
89
51
|
// 变换
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
explicitWidth = NaN;
|
|
95
|
-
explicitHeight = NaN;
|
|
96
|
-
useTranslate = false;
|
|
52
|
+
$x = 0;
|
|
53
|
+
$y = 0;
|
|
54
|
+
$anchorOffsetX = 0;
|
|
55
|
+
$anchorOffsetY = 0;
|
|
56
|
+
$explicitWidth = NaN;
|
|
57
|
+
$explicitHeight = NaN;
|
|
58
|
+
$useTranslate = false;
|
|
97
59
|
// 外观
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
60
|
+
$visible = true;
|
|
61
|
+
$alpha = 1;
|
|
62
|
+
$blendMode = 0;
|
|
63
|
+
$filters = [];
|
|
64
|
+
$cacheAsBitmap = false;
|
|
65
|
+
$touchEnabled = DisplayObject.defaultTouchEnabled;
|
|
104
66
|
// 遮罩
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
maskedObject;
|
|
67
|
+
$mask;
|
|
68
|
+
$maskRect;
|
|
69
|
+
$scrollRect;
|
|
70
|
+
$maskedObject;
|
|
109
71
|
// 渲染状态
|
|
110
|
-
renderMode;
|
|
111
|
-
renderObjectType = 0 /* RenderObjectType.NONE */;
|
|
112
|
-
renderDirty = false;
|
|
113
|
-
cacheDirty = false;
|
|
114
|
-
displayList;
|
|
115
|
-
//
|
|
116
|
-
worldAlpha = 1;
|
|
117
|
-
worldTint = 0xffffff;
|
|
118
|
-
tintRGB = 0;
|
|
72
|
+
$renderMode;
|
|
73
|
+
$renderObjectType = 0 /* RenderObjectType.NONE */;
|
|
74
|
+
$renderDirty = false;
|
|
75
|
+
$cacheDirty = false;
|
|
76
|
+
$displayList;
|
|
77
|
+
// 世界缓存($markDirty 更新,O(1) 读取)
|
|
78
|
+
$worldAlpha = 1;
|
|
79
|
+
$worldTint = 0xffffff;
|
|
80
|
+
$tintRGB = 0;
|
|
119
81
|
// 排序
|
|
120
|
-
sortDirty = false;
|
|
121
|
-
lastSortedIndex = 0;
|
|
82
|
+
$sortDirty = false;
|
|
83
|
+
$lastSortedIndex = 0;
|
|
122
84
|
// bounds 缓存
|
|
123
85
|
_boundsDirty = true;
|
|
124
86
|
_cachedBounds = new Rectangle();
|
|
@@ -155,153 +117,153 @@ export class DisplayObject extends EventDispatcher {
|
|
|
155
117
|
this._name = value;
|
|
156
118
|
}
|
|
157
119
|
get parent() {
|
|
158
|
-
return this
|
|
120
|
+
return this.$parent;
|
|
159
121
|
}
|
|
160
122
|
get stage() {
|
|
161
|
-
return this
|
|
123
|
+
return this.$stage;
|
|
162
124
|
}
|
|
163
125
|
get matrix() {
|
|
164
|
-
return this
|
|
126
|
+
return this.$getMatrix().clone();
|
|
165
127
|
}
|
|
166
128
|
set matrix(value) {
|
|
167
|
-
this
|
|
129
|
+
this.$setMatrix(value);
|
|
168
130
|
}
|
|
169
131
|
get x() {
|
|
170
|
-
return this
|
|
132
|
+
return this.$x;
|
|
171
133
|
}
|
|
172
134
|
set x(value) {
|
|
173
|
-
this
|
|
135
|
+
this.$setX(value);
|
|
174
136
|
}
|
|
175
137
|
get y() {
|
|
176
|
-
return this
|
|
138
|
+
return this.$y;
|
|
177
139
|
}
|
|
178
140
|
set y(value) {
|
|
179
|
-
this
|
|
141
|
+
this.$setY(value);
|
|
180
142
|
}
|
|
181
143
|
get scaleX() {
|
|
182
144
|
return this._scaleX;
|
|
183
145
|
}
|
|
184
146
|
set scaleX(value) {
|
|
185
|
-
this
|
|
147
|
+
this.$setScaleX(value);
|
|
186
148
|
}
|
|
187
149
|
get scaleY() {
|
|
188
150
|
return this._scaleY;
|
|
189
151
|
}
|
|
190
152
|
set scaleY(value) {
|
|
191
|
-
this
|
|
153
|
+
this.$setScaleY(value);
|
|
192
154
|
}
|
|
193
155
|
get rotation() {
|
|
194
156
|
return this._rotation;
|
|
195
157
|
}
|
|
196
158
|
set rotation(value) {
|
|
197
|
-
this
|
|
159
|
+
this.$setRotation(value);
|
|
198
160
|
}
|
|
199
161
|
get skewX() {
|
|
200
162
|
return this._skewXdeg;
|
|
201
163
|
}
|
|
202
164
|
set skewX(value) {
|
|
203
|
-
this
|
|
165
|
+
this.$setSkewX(value);
|
|
204
166
|
}
|
|
205
167
|
get skewY() {
|
|
206
168
|
return this._skewYdeg;
|
|
207
169
|
}
|
|
208
170
|
set skewY(value) {
|
|
209
|
-
this
|
|
171
|
+
this.$setSkewY(value);
|
|
210
172
|
}
|
|
211
173
|
get width() {
|
|
212
|
-
return isNaN(this
|
|
174
|
+
return isNaN(this.$explicitWidth) ? this.$getOriginalBounds().width : this.$explicitWidth;
|
|
213
175
|
}
|
|
214
176
|
set width(value) {
|
|
215
|
-
this
|
|
177
|
+
this.$explicitWidth = isNaN(value) ? NaN : value;
|
|
216
178
|
}
|
|
217
179
|
get height() {
|
|
218
|
-
return isNaN(this
|
|
180
|
+
return isNaN(this.$explicitHeight) ? this.$getOriginalBounds().height : this.$explicitHeight;
|
|
219
181
|
}
|
|
220
182
|
set height(value) {
|
|
221
|
-
this
|
|
183
|
+
this.$explicitHeight = isNaN(value) ? NaN : value;
|
|
222
184
|
}
|
|
223
185
|
get measuredWidth() {
|
|
224
|
-
return this
|
|
186
|
+
return this.$getOriginalBounds().width;
|
|
225
187
|
}
|
|
226
188
|
get measuredHeight() {
|
|
227
|
-
return this
|
|
189
|
+
return this.$getOriginalBounds().height;
|
|
228
190
|
}
|
|
229
191
|
get anchorOffsetX() {
|
|
230
|
-
return this
|
|
192
|
+
return this.$anchorOffsetX;
|
|
231
193
|
}
|
|
232
194
|
set anchorOffsetX(value) {
|
|
233
|
-
this
|
|
195
|
+
this.$setAnchorOffsetX(value);
|
|
234
196
|
}
|
|
235
197
|
get anchorOffsetY() {
|
|
236
|
-
return this
|
|
198
|
+
return this.$anchorOffsetY;
|
|
237
199
|
}
|
|
238
200
|
set anchorOffsetY(value) {
|
|
239
|
-
this
|
|
201
|
+
this.$setAnchorOffsetY(value);
|
|
240
202
|
}
|
|
241
203
|
get visible() {
|
|
242
|
-
return this
|
|
204
|
+
return this.$visible;
|
|
243
205
|
}
|
|
244
206
|
set visible(value) {
|
|
245
|
-
this
|
|
207
|
+
this.$setVisible(value);
|
|
246
208
|
}
|
|
247
209
|
get cacheAsBitmap() {
|
|
248
|
-
return this
|
|
210
|
+
return this.$cacheAsBitmap;
|
|
249
211
|
}
|
|
250
212
|
set cacheAsBitmap(value) {
|
|
251
|
-
this
|
|
252
|
-
this
|
|
213
|
+
this.$cacheAsBitmap = value;
|
|
214
|
+
this.$setHasDisplayList(value);
|
|
253
215
|
}
|
|
254
216
|
get filters() {
|
|
255
|
-
return this
|
|
217
|
+
return this.$filters;
|
|
256
218
|
}
|
|
257
219
|
set filters(value) {
|
|
258
|
-
this
|
|
259
|
-
this
|
|
260
|
-
this
|
|
220
|
+
this.$filters = value ? [...value] : [];
|
|
221
|
+
this.$updateRenderMode();
|
|
222
|
+
this.$markDirty();
|
|
261
223
|
}
|
|
262
224
|
get alpha() {
|
|
263
|
-
return this
|
|
225
|
+
return this.$alpha;
|
|
264
226
|
}
|
|
265
227
|
set alpha(value) {
|
|
266
|
-
this
|
|
228
|
+
this.$setAlpha(value);
|
|
267
229
|
}
|
|
268
230
|
get touchEnabled() {
|
|
269
|
-
return this
|
|
231
|
+
return this.$touchEnabled;
|
|
270
232
|
}
|
|
271
233
|
set touchEnabled(value) {
|
|
272
|
-
this
|
|
234
|
+
this.$touchEnabled = !!value;
|
|
273
235
|
}
|
|
274
236
|
get scrollRect() {
|
|
275
|
-
return this
|
|
237
|
+
return this.$scrollRect;
|
|
276
238
|
}
|
|
277
239
|
set scrollRect(value) {
|
|
278
|
-
this
|
|
240
|
+
this.$setScrollRect(value);
|
|
279
241
|
}
|
|
280
242
|
get blendMode() {
|
|
281
|
-
return numberToBlendMode(this
|
|
243
|
+
return numberToBlendMode(this.$blendMode);
|
|
282
244
|
}
|
|
283
245
|
set blendMode(value) {
|
|
284
246
|
const mode = blendModeToNumber(value);
|
|
285
|
-
if (this
|
|
247
|
+
if (this.$blendMode === mode) {
|
|
286
248
|
return;
|
|
287
249
|
}
|
|
288
|
-
this
|
|
289
|
-
this
|
|
290
|
-
this
|
|
250
|
+
this.$blendMode = mode;
|
|
251
|
+
this.$updateRenderMode();
|
|
252
|
+
this.$markDirty();
|
|
291
253
|
}
|
|
292
254
|
get mask() {
|
|
293
|
-
return this
|
|
255
|
+
return this.$mask ?? this.$maskRect;
|
|
294
256
|
}
|
|
295
257
|
set mask(value) {
|
|
296
|
-
this
|
|
258
|
+
this.$setMask(value);
|
|
297
259
|
}
|
|
298
260
|
get tint() {
|
|
299
261
|
return this._tint;
|
|
300
262
|
}
|
|
301
263
|
set tint(value) {
|
|
302
264
|
this._tint = typeof value === 'number' && value >= 0 && value <= 0xffffff ? value : 0xffffff;
|
|
303
|
-
this
|
|
304
|
-
this
|
|
265
|
+
this.$tintRGB = (this._tint >> 16) + (this._tint & 0xff00) + ((this._tint & 0xff) << 16);
|
|
266
|
+
this.$markDirty();
|
|
305
267
|
}
|
|
306
268
|
get zIndex() {
|
|
307
269
|
return this._zIndex;
|
|
@@ -309,7 +271,7 @@ export class DisplayObject extends EventDispatcher {
|
|
|
309
271
|
set zIndex(value) {
|
|
310
272
|
this._zIndex = value;
|
|
311
273
|
if (this.parent) {
|
|
312
|
-
this.parent
|
|
274
|
+
this.parent.$sortDirty = true;
|
|
313
275
|
}
|
|
314
276
|
}
|
|
315
277
|
get sortableChildren() {
|
|
@@ -320,58 +282,58 @@ export class DisplayObject extends EventDispatcher {
|
|
|
320
282
|
}
|
|
321
283
|
// ── Public methods ────────────────────────────────────────────────────────
|
|
322
284
|
getBounds(resultRect, calculateAnchor = true) {
|
|
323
|
-
resultRect = this
|
|
285
|
+
resultRect = this.$getTransformedBoundsInternal(this, resultRect);
|
|
324
286
|
if (calculateAnchor) {
|
|
325
|
-
if (this
|
|
326
|
-
resultRect.x -= this
|
|
287
|
+
if (this.$anchorOffsetX !== 0) {
|
|
288
|
+
resultRect.x -= this.$anchorOffsetX;
|
|
327
289
|
}
|
|
328
|
-
if (this
|
|
329
|
-
resultRect.y -= this
|
|
290
|
+
if (this.$anchorOffsetY !== 0) {
|
|
291
|
+
resultRect.y -= this.$anchorOffsetY;
|
|
330
292
|
}
|
|
331
293
|
}
|
|
332
294
|
return resultRect;
|
|
333
295
|
}
|
|
334
296
|
getTransformedBounds(targetCoordinateSpace, resultRect) {
|
|
335
|
-
return this
|
|
297
|
+
return this.$getTransformedBoundsInternal(targetCoordinateSpace ?? this, resultRect);
|
|
336
298
|
}
|
|
337
299
|
globalToLocal(stageX = 0, stageY = 0, resultPoint) {
|
|
338
|
-
return this
|
|
300
|
+
return this.$getInvertedConcatenatedMatrix().transformPoint(stageX, stageY, resultPoint);
|
|
339
301
|
}
|
|
340
302
|
localToGlobal(localX = 0, localY = 0, resultPoint) {
|
|
341
|
-
return this
|
|
303
|
+
return this.$getConcatenatedMatrix().transformPoint(localX, localY, resultPoint);
|
|
342
304
|
}
|
|
343
305
|
hitTestPoint(x, y, shapeFlag) {
|
|
344
306
|
if (this._scaleX === 0 || this._scaleY === 0) {
|
|
345
307
|
return false;
|
|
346
308
|
}
|
|
347
|
-
const m = this
|
|
309
|
+
const m = this.$getInvertedConcatenatedMatrix();
|
|
348
310
|
const bounds = this.getBounds(undefined, false);
|
|
349
311
|
const localX = m.a * x + m.c * y + m.tx;
|
|
350
312
|
const localY = m.b * x + m.d * y + m.ty;
|
|
351
313
|
if (!bounds.contains(localX, localY)) {
|
|
352
314
|
return false;
|
|
353
315
|
}
|
|
354
|
-
const rect = this
|
|
316
|
+
const rect = this.$scrollRect ?? this.$maskRect;
|
|
355
317
|
if (rect && !rect.contains(localX, localY)) {
|
|
356
318
|
return false;
|
|
357
319
|
}
|
|
358
320
|
if (!shapeFlag) {
|
|
359
321
|
return true;
|
|
360
322
|
}
|
|
361
|
-
// Pixel-perfect: delegate to hitTest which Shape/Sprite override
|
|
362
|
-
return this
|
|
323
|
+
// Pixel-perfect: delegate to $hitTest which Shape/Sprite override
|
|
324
|
+
return this.$hitTest(x, y) !== undefined;
|
|
363
325
|
}
|
|
364
326
|
sortChildren() {
|
|
365
|
-
this
|
|
327
|
+
this.$sortDirty = false;
|
|
366
328
|
}
|
|
367
329
|
dispatchEvent(event) {
|
|
368
330
|
if (!event.bubbles) {
|
|
369
331
|
return super.dispatchEvent(event);
|
|
370
332
|
}
|
|
371
|
-
const list = this
|
|
333
|
+
const list = this.$getPropagationList(this);
|
|
372
334
|
const targetIndex = list.length * 0.5;
|
|
373
335
|
event.setDispatchContext(this, 2 /* EventPhase.AT_TARGET */);
|
|
374
|
-
this
|
|
336
|
+
this.$dispatchPropagationEvent(event, list, targetIndex);
|
|
375
337
|
return !event.isDefaultPrevented();
|
|
376
338
|
}
|
|
377
339
|
willTrigger(type) {
|
|
@@ -380,14 +342,14 @@ export class DisplayObject extends EventDispatcher {
|
|
|
380
342
|
if (node.hasEventListener(type)) {
|
|
381
343
|
return true;
|
|
382
344
|
}
|
|
383
|
-
node = node
|
|
345
|
+
node = node.$parent;
|
|
384
346
|
}
|
|
385
347
|
return false;
|
|
386
348
|
}
|
|
387
349
|
addEventListener(type, listener, useCapture, priority) {
|
|
388
350
|
super.addEventListener(type, listener, useCapture, priority);
|
|
389
351
|
if (type === Event.ENTER_FRAME || type === Event.RENDER) {
|
|
390
|
-
const list = type === Event.ENTER_FRAME ? DisplayObject
|
|
352
|
+
const list = type === Event.ENTER_FRAME ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList;
|
|
391
353
|
if (!list.includes(this)) {
|
|
392
354
|
list.push(this);
|
|
393
355
|
}
|
|
@@ -396,7 +358,7 @@ export class DisplayObject extends EventDispatcher {
|
|
|
396
358
|
removeEventListener(type, listener, useCapture) {
|
|
397
359
|
super.removeEventListener(type, listener, useCapture);
|
|
398
360
|
if ((type === Event.ENTER_FRAME || type === Event.RENDER) && !this.hasEventListener(type)) {
|
|
399
|
-
const list = type === Event.ENTER_FRAME ? DisplayObject
|
|
361
|
+
const list = type === Event.ENTER_FRAME ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList;
|
|
400
362
|
const index = list.indexOf(this);
|
|
401
363
|
if (index !== -1) {
|
|
402
364
|
list.splice(index, 1);
|
|
@@ -404,39 +366,39 @@ export class DisplayObject extends EventDispatcher {
|
|
|
404
366
|
}
|
|
405
367
|
}
|
|
406
368
|
// ── Internal methods (used by subclasses and framework) ───────────────────
|
|
407
|
-
setParent(parent) {
|
|
408
|
-
this
|
|
369
|
+
$setParent(parent) {
|
|
370
|
+
this.$parent = parent;
|
|
409
371
|
}
|
|
410
|
-
onAddToStage(stage, nestLevel) {
|
|
411
|
-
this
|
|
412
|
-
this
|
|
413
|
-
this
|
|
414
|
-
DisplayObject
|
|
372
|
+
$onAddToStage(stage, $nestLevel) {
|
|
373
|
+
this.$stage = stage;
|
|
374
|
+
this.$nestLevel = $nestLevel;
|
|
375
|
+
this.$hasAddToStage = true;
|
|
376
|
+
DisplayObject.$eventAddToStageList.push(this);
|
|
415
377
|
}
|
|
416
|
-
onRemoveFromStage() {
|
|
417
|
-
this
|
|
418
|
-
this
|
|
419
|
-
DisplayObject
|
|
378
|
+
$onRemoveFromStage() {
|
|
379
|
+
this.$nestLevel = 0;
|
|
380
|
+
this.$stage = undefined;
|
|
381
|
+
DisplayObject.$eventRemoveFromStageList.push(this);
|
|
420
382
|
}
|
|
421
|
-
getMatrix() {
|
|
383
|
+
$getMatrix() {
|
|
422
384
|
if (this._matrixDirty) {
|
|
423
385
|
this._matrixDirty = false;
|
|
424
386
|
this._matrix.updateScaleAndRotation(this._scaleX, this._scaleY, this._skewX, this._skewY);
|
|
425
387
|
}
|
|
426
|
-
this._matrix.tx = this
|
|
427
|
-
this._matrix.ty = this
|
|
388
|
+
this._matrix.tx = this.$x;
|
|
389
|
+
this._matrix.ty = this.$y;
|
|
428
390
|
return this._matrix;
|
|
429
391
|
}
|
|
430
|
-
setMatrix(matrix, needUpdateProperties = true) {
|
|
392
|
+
$setMatrix(matrix, needUpdateProperties = true) {
|
|
431
393
|
const m = this._matrix;
|
|
432
394
|
m.a = matrix.a;
|
|
433
395
|
m.b = matrix.b;
|
|
434
396
|
m.c = matrix.c;
|
|
435
397
|
m.d = matrix.d;
|
|
436
|
-
this
|
|
437
|
-
this
|
|
398
|
+
this.$x = matrix.tx;
|
|
399
|
+
this.$y = matrix.ty;
|
|
438
400
|
this._matrixDirty = false;
|
|
439
|
-
this
|
|
401
|
+
this.$useTranslate = !(m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1);
|
|
440
402
|
if (needUpdateProperties) {
|
|
441
403
|
this._scaleX = m.getScaleX();
|
|
442
404
|
this._scaleY = m.getScaleY();
|
|
@@ -446,22 +408,22 @@ export class DisplayObject extends EventDispatcher {
|
|
|
446
408
|
this._skewYdeg = clampRotation((this._skewY * 180) / Math.PI);
|
|
447
409
|
this._rotation = clampRotation((this._skewY * 180) / Math.PI);
|
|
448
410
|
}
|
|
449
|
-
this
|
|
411
|
+
this.$markDirty();
|
|
450
412
|
}
|
|
451
|
-
getConcatenatedMatrix() {
|
|
413
|
+
$getConcatenatedMatrix() {
|
|
452
414
|
if (!this._concatenatedMatrix) {
|
|
453
415
|
this._concatenatedMatrix = new Matrix();
|
|
454
416
|
}
|
|
455
417
|
const matrix = this._concatenatedMatrix;
|
|
456
|
-
if (this
|
|
457
|
-
this
|
|
418
|
+
if (this.$parent) {
|
|
419
|
+
this.$parent.$getConcatenatedMatrix().preMultiplyInto(this.$getMatrix(), matrix);
|
|
458
420
|
}
|
|
459
421
|
else {
|
|
460
|
-
matrix.copyFrom(this
|
|
422
|
+
matrix.copyFrom(this.$getMatrix());
|
|
461
423
|
}
|
|
462
|
-
const ox = this
|
|
463
|
-
const oy = this
|
|
464
|
-
const rect = this
|
|
424
|
+
const ox = this.$anchorOffsetX;
|
|
425
|
+
const oy = this.$anchorOffsetY;
|
|
426
|
+
const rect = this.$scrollRect;
|
|
465
427
|
if (rect) {
|
|
466
428
|
matrix.preMultiplyInto(sharedMatrix.setTo(1, 0, 0, 1, -rect.x - ox, -rect.y - oy), matrix);
|
|
467
429
|
}
|
|
@@ -470,48 +432,48 @@ export class DisplayObject extends EventDispatcher {
|
|
|
470
432
|
}
|
|
471
433
|
return matrix;
|
|
472
434
|
}
|
|
473
|
-
getInvertedConcatenatedMatrix() {
|
|
435
|
+
$getInvertedConcatenatedMatrix() {
|
|
474
436
|
if (!this._invertedConcatenatedMatrix) {
|
|
475
437
|
this._invertedConcatenatedMatrix = new Matrix();
|
|
476
438
|
}
|
|
477
|
-
this
|
|
439
|
+
this.$getConcatenatedMatrix().invertInto(this._invertedConcatenatedMatrix);
|
|
478
440
|
return this._invertedConcatenatedMatrix;
|
|
479
441
|
}
|
|
480
|
-
setX(value) {
|
|
481
|
-
if (this
|
|
442
|
+
$setX(value) {
|
|
443
|
+
if (this.$x === value) {
|
|
482
444
|
return false;
|
|
483
445
|
}
|
|
484
|
-
this
|
|
485
|
-
this
|
|
446
|
+
this.$x = value;
|
|
447
|
+
this.$markDirty();
|
|
486
448
|
return true;
|
|
487
449
|
}
|
|
488
|
-
setY(value) {
|
|
489
|
-
if (this
|
|
450
|
+
$setY(value) {
|
|
451
|
+
if (this.$y === value) {
|
|
490
452
|
return false;
|
|
491
453
|
}
|
|
492
|
-
this
|
|
493
|
-
this
|
|
454
|
+
this.$y = value;
|
|
455
|
+
this.$markDirty();
|
|
494
456
|
return true;
|
|
495
457
|
}
|
|
496
|
-
setScaleX(value) {
|
|
458
|
+
$setScaleX(value) {
|
|
497
459
|
if (this._scaleX === value) {
|
|
498
460
|
return;
|
|
499
461
|
}
|
|
500
462
|
this._scaleX = value;
|
|
501
463
|
this._matrixDirty = true;
|
|
502
|
-
this
|
|
503
|
-
this
|
|
464
|
+
this.$updateUseTransform();
|
|
465
|
+
this.$markDirty();
|
|
504
466
|
}
|
|
505
|
-
setScaleY(value) {
|
|
467
|
+
$setScaleY(value) {
|
|
506
468
|
if (this._scaleY === value) {
|
|
507
469
|
return;
|
|
508
470
|
}
|
|
509
471
|
this._scaleY = value;
|
|
510
472
|
this._matrixDirty = true;
|
|
511
|
-
this
|
|
512
|
-
this
|
|
473
|
+
this.$updateUseTransform();
|
|
474
|
+
this.$markDirty();
|
|
513
475
|
}
|
|
514
|
-
setRotation(value) {
|
|
476
|
+
$setRotation(value) {
|
|
515
477
|
value = clampRotation(value);
|
|
516
478
|
if (value === this._rotation) {
|
|
517
479
|
return;
|
|
@@ -521,156 +483,156 @@ export class DisplayObject extends EventDispatcher {
|
|
|
521
483
|
this._skewY += delta;
|
|
522
484
|
this._rotation = value;
|
|
523
485
|
this._matrixDirty = true;
|
|
524
|
-
this
|
|
525
|
-
this
|
|
486
|
+
this.$updateUseTransform();
|
|
487
|
+
this.$markDirty();
|
|
526
488
|
}
|
|
527
|
-
setSkewX(value) {
|
|
489
|
+
$setSkewX(value) {
|
|
528
490
|
if (value === this._skewXdeg) {
|
|
529
491
|
return;
|
|
530
492
|
}
|
|
531
493
|
this._skewXdeg = value;
|
|
532
494
|
this._skewX = (clampRotation(value) / 180) * Math.PI;
|
|
533
495
|
this._matrixDirty = true;
|
|
534
|
-
this
|
|
535
|
-
this
|
|
496
|
+
this.$updateUseTransform();
|
|
497
|
+
this.$markDirty();
|
|
536
498
|
}
|
|
537
|
-
setSkewY(value) {
|
|
499
|
+
$setSkewY(value) {
|
|
538
500
|
if (value === this._skewYdeg) {
|
|
539
501
|
return;
|
|
540
502
|
}
|
|
541
503
|
this._skewYdeg = value;
|
|
542
504
|
this._skewY = ((clampRotation(value) + this._rotation) / 180) * Math.PI;
|
|
543
505
|
this._matrixDirty = true;
|
|
544
|
-
this
|
|
545
|
-
this
|
|
506
|
+
this.$updateUseTransform();
|
|
507
|
+
this.$markDirty();
|
|
546
508
|
}
|
|
547
|
-
setAnchorOffsetX(value) {
|
|
548
|
-
if (this
|
|
509
|
+
$setAnchorOffsetX(value) {
|
|
510
|
+
if (this.$anchorOffsetX === value) {
|
|
549
511
|
return;
|
|
550
512
|
}
|
|
551
|
-
this
|
|
552
|
-
this
|
|
513
|
+
this.$anchorOffsetX = value;
|
|
514
|
+
this.$markDirty();
|
|
553
515
|
}
|
|
554
|
-
setAnchorOffsetY(value) {
|
|
555
|
-
if (this
|
|
516
|
+
$setAnchorOffsetY(value) {
|
|
517
|
+
if (this.$anchorOffsetY === value) {
|
|
556
518
|
return;
|
|
557
519
|
}
|
|
558
|
-
this
|
|
559
|
-
this
|
|
520
|
+
this.$anchorOffsetY = value;
|
|
521
|
+
this.$markDirty();
|
|
560
522
|
}
|
|
561
|
-
setVisible(value) {
|
|
562
|
-
if (this
|
|
523
|
+
$setVisible(value) {
|
|
524
|
+
if (this.$visible === value) {
|
|
563
525
|
return;
|
|
564
526
|
}
|
|
565
|
-
this
|
|
566
|
-
this
|
|
567
|
-
this
|
|
527
|
+
this.$visible = value;
|
|
528
|
+
this.$updateRenderMode();
|
|
529
|
+
this.$markDirty();
|
|
568
530
|
}
|
|
569
|
-
setAlpha(value) {
|
|
570
|
-
if (this
|
|
531
|
+
$setAlpha(value) {
|
|
532
|
+
if (this.$alpha === value) {
|
|
571
533
|
return;
|
|
572
534
|
}
|
|
573
|
-
this
|
|
574
|
-
this
|
|
575
|
-
this
|
|
535
|
+
this.$alpha = value;
|
|
536
|
+
this.$updateRenderMode();
|
|
537
|
+
this.$markDirty();
|
|
576
538
|
}
|
|
577
|
-
setScrollRect(value) {
|
|
578
|
-
if (!value && !this
|
|
539
|
+
$setScrollRect(value) {
|
|
540
|
+
if (!value && !this.$scrollRect) {
|
|
579
541
|
return;
|
|
580
542
|
}
|
|
581
543
|
if (value) {
|
|
582
|
-
if (!this
|
|
583
|
-
this
|
|
544
|
+
if (!this.$scrollRect) {
|
|
545
|
+
this.$scrollRect = new Rectangle();
|
|
584
546
|
}
|
|
585
|
-
this.
|
|
547
|
+
this.$scrollRect.copyFrom(value);
|
|
586
548
|
}
|
|
587
549
|
else {
|
|
588
|
-
this
|
|
550
|
+
this.$scrollRect = undefined;
|
|
589
551
|
}
|
|
590
|
-
this
|
|
591
|
-
this
|
|
552
|
+
this.$updateRenderMode();
|
|
553
|
+
this.$markDirty();
|
|
592
554
|
}
|
|
593
|
-
setHasDisplayList(value) {
|
|
594
|
-
const hasDisplayList = !!this
|
|
555
|
+
$setHasDisplayList(value) {
|
|
556
|
+
const hasDisplayList = !!this.$displayList;
|
|
595
557
|
if (hasDisplayList === value) {
|
|
596
558
|
return;
|
|
597
559
|
}
|
|
598
560
|
if (value) {
|
|
599
561
|
const dl = DisplayList.create(this);
|
|
600
562
|
if (dl) {
|
|
601
|
-
this
|
|
602
|
-
this
|
|
563
|
+
this.$displayList = dl;
|
|
564
|
+
this.$cacheDirty = true;
|
|
603
565
|
}
|
|
604
566
|
}
|
|
605
567
|
else {
|
|
606
|
-
if (this
|
|
607
|
-
DisplayList.release(this
|
|
608
|
-
this
|
|
568
|
+
if (this.$displayList) {
|
|
569
|
+
DisplayList.release(this.$displayList);
|
|
570
|
+
this.$displayList = undefined;
|
|
609
571
|
}
|
|
610
572
|
}
|
|
611
573
|
// cacheAsBitmap toggle changes the instruction set structure:
|
|
612
574
|
// the subtree either collapses to a single displayListCache instruction
|
|
613
575
|
// or expands back to individual leaf instructions.
|
|
614
|
-
DisplayObject
|
|
615
|
-
this
|
|
576
|
+
DisplayObject.$onStructureChange?.();
|
|
577
|
+
this.$markDirty();
|
|
616
578
|
}
|
|
617
|
-
cacheDirtyUp() {
|
|
618
|
-
const p = this
|
|
619
|
-
if (p && !p
|
|
620
|
-
p
|
|
579
|
+
$cacheDirtyUp() {
|
|
580
|
+
const p = this.$parent;
|
|
581
|
+
if (p && !p.$cacheDirty) {
|
|
582
|
+
p.$cacheDirty = true;
|
|
621
583
|
p._boundsDirty = true;
|
|
622
|
-
p
|
|
584
|
+
p.$cacheDirtyUp();
|
|
623
585
|
}
|
|
624
586
|
}
|
|
625
|
-
renderDirtyUp() {
|
|
626
|
-
const p = this
|
|
627
|
-
if (p && !p
|
|
628
|
-
p
|
|
629
|
-
p
|
|
587
|
+
$renderDirtyUp() {
|
|
588
|
+
const p = this.$parent;
|
|
589
|
+
if (p && !p.$renderDirty) {
|
|
590
|
+
p.$renderDirty = true;
|
|
591
|
+
p.$renderDirtyUp();
|
|
630
592
|
}
|
|
631
593
|
}
|
|
632
|
-
updateUseTransform() {
|
|
633
|
-
this
|
|
594
|
+
$updateUseTransform() {
|
|
595
|
+
this.$useTranslate = !(this._scaleX === 1 && this._scaleY === 1 && this._skewX === 0 && this._skewY === 0);
|
|
634
596
|
}
|
|
635
|
-
updateRenderMode() {
|
|
636
|
-
if (!this
|
|
637
|
-
this
|
|
597
|
+
$updateRenderMode() {
|
|
598
|
+
if (!this.$visible || this.$alpha <= 0 || this.$maskedObject) {
|
|
599
|
+
this.$renderMode = 1 /* RenderMode.NONE */;
|
|
638
600
|
}
|
|
639
|
-
else if (this.
|
|
640
|
-
this
|
|
601
|
+
else if (this.$filters.length > 0) {
|
|
602
|
+
this.$renderMode = 2 /* RenderMode.FILTER */;
|
|
641
603
|
}
|
|
642
|
-
else if (this
|
|
643
|
-
this
|
|
604
|
+
else if (this.$blendMode !== 0 || (this.$mask && this.$mask.$stage)) {
|
|
605
|
+
this.$renderMode = 3 /* RenderMode.CLIP */;
|
|
644
606
|
}
|
|
645
|
-
else if (this
|
|
646
|
-
this
|
|
607
|
+
else if (this.$scrollRect || this.$maskRect) {
|
|
608
|
+
this.$renderMode = 4 /* RenderMode.SCROLLRECT */;
|
|
647
609
|
}
|
|
648
610
|
else {
|
|
649
|
-
this
|
|
611
|
+
this.$renderMode = undefined;
|
|
650
612
|
}
|
|
651
613
|
// RenderMode change means the instruction set structure is stale.
|
|
652
|
-
DisplayObject
|
|
614
|
+
DisplayObject.$onStructureChange?.();
|
|
653
615
|
}
|
|
654
|
-
getOriginalBounds() {
|
|
616
|
+
$getOriginalBounds() {
|
|
655
617
|
if (!this._boundsDirty) {
|
|
656
618
|
return this._cachedBounds;
|
|
657
619
|
}
|
|
658
|
-
const bounds = this
|
|
659
|
-
this
|
|
620
|
+
const bounds = this.$getContentBounds();
|
|
621
|
+
this.$measureChildBounds(bounds);
|
|
660
622
|
this._cachedBounds.copyFrom(bounds);
|
|
661
623
|
this._boundsDirty = false;
|
|
662
624
|
return this._cachedBounds;
|
|
663
625
|
}
|
|
664
|
-
measureChildBounds(_bounds) { }
|
|
665
|
-
getContentBounds() {
|
|
626
|
+
$measureChildBounds(_bounds) { }
|
|
627
|
+
$getContentBounds() {
|
|
666
628
|
const bounds = sharedRectangle;
|
|
667
629
|
bounds.setEmpty();
|
|
668
|
-
this
|
|
630
|
+
this.$measureContentBounds(bounds);
|
|
669
631
|
return bounds;
|
|
670
632
|
}
|
|
671
|
-
measureContentBounds(_bounds) { }
|
|
672
|
-
getTransformedBoundsInternal(targetCoordinateSpace, resultRect) {
|
|
673
|
-
const bounds = this
|
|
633
|
+
$measureContentBounds(_bounds) { }
|
|
634
|
+
$getTransformedBoundsInternal(targetCoordinateSpace, resultRect) {
|
|
635
|
+
const bounds = this.$getOriginalBounds();
|
|
674
636
|
if (!resultRect) {
|
|
675
637
|
resultRect = new Rectangle();
|
|
676
638
|
}
|
|
@@ -679,46 +641,46 @@ export class DisplayObject extends EventDispatcher {
|
|
|
679
641
|
return resultRect;
|
|
680
642
|
}
|
|
681
643
|
const m = sharedMatrix;
|
|
682
|
-
targetCoordinateSpace
|
|
644
|
+
targetCoordinateSpace.$getInvertedConcatenatedMatrix().preMultiplyInto(this.$getConcatenatedMatrix(), m);
|
|
683
645
|
m.transformBounds(resultRect);
|
|
684
646
|
return resultRect;
|
|
685
647
|
}
|
|
686
|
-
getConcatenatedMatrixAt(root, matrix) {
|
|
687
|
-
const invertMatrix = root
|
|
648
|
+
$getConcatenatedMatrixAt(root, matrix) {
|
|
649
|
+
const invertMatrix = root.$getInvertedConcatenatedMatrix();
|
|
688
650
|
if ((invertMatrix.a === 0 || invertMatrix.d === 0) && (invertMatrix.b === 0 || invertMatrix.c === 0)) {
|
|
689
651
|
let target = this;
|
|
690
|
-
const rootLevel = root
|
|
652
|
+
const rootLevel = root.$nestLevel;
|
|
691
653
|
matrix.identity();
|
|
692
|
-
while (target
|
|
693
|
-
const rect = target
|
|
654
|
+
while (target.$nestLevel > rootLevel) {
|
|
655
|
+
const rect = target.$scrollRect;
|
|
694
656
|
if (rect)
|
|
695
657
|
matrix.concat(sharedMatrix.setTo(1, 0, 0, 1, -rect.x, -rect.y));
|
|
696
|
-
matrix.concat(target
|
|
697
|
-
target = target
|
|
658
|
+
matrix.concat(target.$getMatrix());
|
|
659
|
+
target = target.$parent;
|
|
698
660
|
}
|
|
699
661
|
}
|
|
700
662
|
else {
|
|
701
663
|
invertMatrix.preMultiplyInto(matrix, matrix);
|
|
702
664
|
}
|
|
703
665
|
}
|
|
704
|
-
hitTest(stageX, stageY) {
|
|
705
|
-
if (!this
|
|
666
|
+
$hitTest(stageX, stageY) {
|
|
667
|
+
if (!this.$visible || this._scaleX === 0 || this._scaleY === 0) {
|
|
706
668
|
return undefined;
|
|
707
669
|
}
|
|
708
|
-
const m = this
|
|
670
|
+
const m = this.$getInvertedConcatenatedMatrix();
|
|
709
671
|
if (m.a === 0 && m.b === 0 && m.c === 0 && m.d === 0) {
|
|
710
672
|
return undefined;
|
|
711
673
|
}
|
|
712
|
-
const bounds = this
|
|
674
|
+
const bounds = this.$getContentBounds();
|
|
713
675
|
const localX = m.a * stageX + m.c * stageY + m.tx;
|
|
714
676
|
const localY = m.b * stageX + m.d * stageY + m.ty;
|
|
715
677
|
if (bounds.contains(localX, localY)) {
|
|
716
|
-
if (!this
|
|
717
|
-
const rect = this
|
|
678
|
+
if (!this.$children) {
|
|
679
|
+
const rect = this.$scrollRect ?? this.$maskRect;
|
|
718
680
|
if (rect && !rect.contains(localX, localY)) {
|
|
719
681
|
return undefined;
|
|
720
682
|
}
|
|
721
|
-
if (this
|
|
683
|
+
if (this.$mask && !this.$mask.$hitTest(stageX, stageY)) {
|
|
722
684
|
return undefined;
|
|
723
685
|
}
|
|
724
686
|
}
|
|
@@ -726,17 +688,17 @@ export class DisplayObject extends EventDispatcher {
|
|
|
726
688
|
}
|
|
727
689
|
return undefined;
|
|
728
690
|
}
|
|
729
|
-
updateRenderNode() { }
|
|
730
|
-
getPropagationList(target) {
|
|
691
|
+
$updateRenderNode() { }
|
|
692
|
+
$getPropagationList(target) {
|
|
731
693
|
const list = [];
|
|
732
694
|
let current = target;
|
|
733
695
|
while (current) {
|
|
734
696
|
list.push(current);
|
|
735
|
-
current = current
|
|
697
|
+
current = current.$parent;
|
|
736
698
|
}
|
|
737
699
|
return [...[...list].reverse(), ...list];
|
|
738
700
|
}
|
|
739
|
-
dispatchPropagationEvent(event, list, targetIndex) {
|
|
701
|
+
$dispatchPropagationEvent(event, list, targetIndex) {
|
|
740
702
|
for (let i = 0; i < list.length; i++) {
|
|
741
703
|
const currentTarget = list[i];
|
|
742
704
|
let phase;
|
|
@@ -758,73 +720,73 @@ export class DisplayObject extends EventDispatcher {
|
|
|
758
720
|
}
|
|
759
721
|
}
|
|
760
722
|
// ── Private methods ───────────────────────────────────────────────────────
|
|
761
|
-
setMask(value) {
|
|
723
|
+
$setMask(value) {
|
|
762
724
|
if (value === this) {
|
|
763
725
|
return;
|
|
764
726
|
}
|
|
765
727
|
if (value instanceof DisplayObject) {
|
|
766
|
-
if (value === this
|
|
728
|
+
if (value === this.$mask) {
|
|
767
729
|
return;
|
|
768
730
|
}
|
|
769
|
-
if (value
|
|
770
|
-
value
|
|
731
|
+
if (value.$maskedObject) {
|
|
732
|
+
value.$maskedObject.mask = undefined;
|
|
771
733
|
}
|
|
772
|
-
value
|
|
773
|
-
this
|
|
774
|
-
this
|
|
734
|
+
value.$maskedObject = this;
|
|
735
|
+
this.$mask = value;
|
|
736
|
+
this.$maskRect = undefined;
|
|
775
737
|
}
|
|
776
738
|
else if (value instanceof Rectangle) {
|
|
777
|
-
if (!this
|
|
778
|
-
this
|
|
739
|
+
if (!this.$maskRect) {
|
|
740
|
+
this.$maskRect = new Rectangle();
|
|
779
741
|
}
|
|
780
|
-
this.
|
|
781
|
-
if (this
|
|
782
|
-
this
|
|
783
|
-
this
|
|
742
|
+
this.$maskRect.copyFrom(value);
|
|
743
|
+
if (this.$mask) {
|
|
744
|
+
this.$mask.$maskedObject = undefined;
|
|
745
|
+
this.$mask = undefined;
|
|
784
746
|
}
|
|
785
747
|
}
|
|
786
748
|
else {
|
|
787
|
-
if (this
|
|
788
|
-
this
|
|
789
|
-
this
|
|
749
|
+
if (this.$mask) {
|
|
750
|
+
this.$mask.$maskedObject = undefined;
|
|
751
|
+
this.$mask = undefined;
|
|
790
752
|
}
|
|
791
|
-
this
|
|
753
|
+
this.$maskRect = undefined;
|
|
792
754
|
}
|
|
793
|
-
this
|
|
794
|
-
this
|
|
755
|
+
this.$updateRenderMode();
|
|
756
|
+
this.$markDirty();
|
|
795
757
|
}
|
|
796
|
-
markDirty() {
|
|
797
|
-
this
|
|
758
|
+
$markDirty() {
|
|
759
|
+
this.$renderDirty = true;
|
|
798
760
|
this._boundsDirty = true;
|
|
799
761
|
// Update cached world alpha and tint so _refreshLeafTransform can read
|
|
800
762
|
// them in O(1) without walking the parent chain.
|
|
801
|
-
let alpha = this
|
|
802
|
-
let tint = this
|
|
803
|
-
let p = this
|
|
763
|
+
let alpha = this.$alpha;
|
|
764
|
+
let tint = this.$tintRGB;
|
|
765
|
+
let p = this.$parent;
|
|
804
766
|
while (p) {
|
|
805
|
-
alpha *= p
|
|
806
|
-
if (p
|
|
807
|
-
tint = p
|
|
767
|
+
alpha *= p.$alpha;
|
|
768
|
+
if (p.$tintRGB !== 0xffffff) {
|
|
769
|
+
tint = p.$tintRGB;
|
|
808
770
|
}
|
|
809
|
-
p = p
|
|
771
|
+
p = p.$parent;
|
|
810
772
|
}
|
|
811
|
-
this
|
|
812
|
-
this
|
|
773
|
+
this.$worldAlpha = alpha;
|
|
774
|
+
this.$worldTint = tint;
|
|
813
775
|
// Notify the renderer that this object's data changed.
|
|
814
|
-
DisplayObject
|
|
815
|
-
const parent = this
|
|
816
|
-
if (parent && !parent
|
|
817
|
-
parent
|
|
818
|
-
parent
|
|
819
|
-
}
|
|
820
|
-
if (parent && !parent
|
|
821
|
-
parent
|
|
822
|
-
parent
|
|
823
|
-
}
|
|
824
|
-
const masked = this
|
|
825
|
-
if (masked && !masked
|
|
826
|
-
masked
|
|
827
|
-
masked
|
|
776
|
+
DisplayObject.$onRenderableDirty?.(this);
|
|
777
|
+
const parent = this.$parent;
|
|
778
|
+
if (parent && !parent.$cacheDirty) {
|
|
779
|
+
parent.$cacheDirty = true;
|
|
780
|
+
parent.$cacheDirtyUp();
|
|
781
|
+
}
|
|
782
|
+
if (parent && !parent.$renderDirty) {
|
|
783
|
+
parent.$renderDirty = true;
|
|
784
|
+
parent.$renderDirtyUp();
|
|
785
|
+
}
|
|
786
|
+
const masked = this.$maskedObject;
|
|
787
|
+
if (masked && !masked.$cacheDirty) {
|
|
788
|
+
masked.$cacheDirty = true;
|
|
789
|
+
masked.$cacheDirtyUp();
|
|
828
790
|
}
|
|
829
791
|
}
|
|
830
792
|
}
|