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