@awayjs/scene 0.13.285 → 0.13.287
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/bundle/awayjs-scene.umd.js +1 -1
- package/bundle/awayjs-scene.umd.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/image/SceneImage2D.d.ts +0 -17
- package/dist/lib/image/SceneImage2D.d.ts.map +1 -1
- package/dist/lib/image/SceneImage2D.js +5 -102
- package/index.ts +1 -1
- package/lib/image/SceneImage2D.ts +4 -137
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
console.debug('AwayJS - Scene - 0.13.
|
|
1
|
+
console.debug('AwayJS - Scene - 0.13.287');
|
|
2
2
|
export { Timeline } from './lib/base/Timeline';
|
|
3
3
|
export { ControllerBase } from './lib/controllers/ControllerBase';
|
|
4
4
|
export { FirstPersonController } from './lib/controllers/FirstPersonController';
|
|
@@ -17,19 +17,12 @@ export declare class SceneImage2D extends BitmapImage2D {
|
|
|
17
17
|
private static _rootNode;
|
|
18
18
|
private static _billboardRoot;
|
|
19
19
|
private static _billboard;
|
|
20
|
-
private _imageDataDirty;
|
|
21
|
-
private _asyncRead;
|
|
22
|
-
private _initalFillColor;
|
|
23
|
-
private _lastUsedFill;
|
|
24
|
-
private _internalSync;
|
|
25
20
|
protected _msaaNeedDrop: boolean;
|
|
26
21
|
protected _enforceMSAASupport: boolean;
|
|
27
22
|
protected _dropMSAA(): void;
|
|
28
23
|
get canUseMSAAInternaly(): boolean;
|
|
29
24
|
_antialiasQuality: number;
|
|
30
25
|
get antialiasQuality(): number;
|
|
31
|
-
protected syncData(async?: boolean): boolean | Promise<boolean>;
|
|
32
|
-
getDataInternal(constructEmpty?: boolean, skipSync?: boolean): Uint8ClampedArray;
|
|
33
26
|
/**
|
|
34
27
|
*
|
|
35
28
|
* @returns {string}
|
|
@@ -88,16 +81,6 @@ export declare class SceneImage2D extends BitmapImage2D {
|
|
|
88
81
|
dispose(): void;
|
|
89
82
|
unload(): void;
|
|
90
83
|
protected deepClone(from: BitmapImage2D): void;
|
|
91
|
-
/**
|
|
92
|
-
* Fills a rectangular area of pixels with a specified ARGB color.
|
|
93
|
-
*
|
|
94
|
-
* @param rect The rectangular area to fill.
|
|
95
|
-
* @param color The ARGB color value that fills the area. ARGB colors are
|
|
96
|
-
* often specified in hexadecimal format; for example,
|
|
97
|
-
* 0xFF336699.
|
|
98
|
-
* @throws TypeError The rect is null.
|
|
99
|
-
*/
|
|
100
|
-
fillRect(rect: Rectangle, color: number): void;
|
|
101
84
|
/**
|
|
102
85
|
* Provides a fast routine to perform pixel manipulation between images with
|
|
103
86
|
* no stretching, rotation, or color effects. This method copies a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneImage2D.d.ts","sourceRoot":"","sources":["../../../lib/image/SceneImage2D.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAIzD,OAAO,EACN,cAAc,EACd,MAAM,EACN,SAAS,EACT,KAAK,EAML,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EACb,aAAa,EAIb,OAAO,EACP,MAAM,eAAe,CAAC;AAOvB;;GAEG;AACH,qBAAa,YAAa,SAAQ,aAAa;IAC9C,OAAc,SAAS,EAAE,MAAM,CAA0B;WAE3C,QAAQ,CACrB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAE,OAAc,EAC1D,SAAS,GAAE,MAAmB,EAC9B,UAAU,GAAE,OAAc,EAAE,KAAK,GAAE,KAAY,EAAE,IAAI,UAAQ;WAqBhD,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAI/D,OAAO,CAAC,MAAM,CAAC,OAAO;IAOtB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkB;IAC1C,OAAO,CAAC,MAAM,CAAC,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/DisplayObjectContainer';
|
|
|
5
5
|
import { DisplayObject } from '../display/DisplayObject';
|
|
6
6
|
import { Billboard } from '../display/Billboard';
|
|
7
7
|
import { Settings } from '../Settings';
|
|
8
|
-
import { Rectangle, Point, PerspectiveProjection, CoordinateSystem, Vector3D, Transform
|
|
8
|
+
import { Rectangle, Point, PerspectiveProjection, CoordinateSystem, Vector3D, Transform } from '@awayjs/core';
|
|
9
9
|
import { Stage, BitmapImage2D, _Stage_BitmapImage2D, BlendMode } from '@awayjs/stage';
|
|
10
10
|
import { DefaultRenderer, RenderGroup, Style } from '@awayjs/renderer';
|
|
11
11
|
// empty matrix for transform reset
|
|
@@ -48,16 +48,11 @@ var SceneImage2D = /** @class */ (function (_super) {
|
|
|
48
48
|
if (fillColor === void 0) { fillColor = 0xffffffff; }
|
|
49
49
|
if (powerOfTwo === void 0) { powerOfTwo = true; }
|
|
50
50
|
if (stage === void 0) { stage = null; }
|
|
51
|
-
var _this = _super.call(this, width, height, transparent,
|
|
52
|
-
_this._initalFillColor = null;
|
|
53
|
-
_this._lastUsedFill = null;
|
|
54
|
-
_this._internalSync = false;
|
|
51
|
+
var _this = _super.call(this, width, height, transparent, fillColor, powerOfTwo, stage) || this;
|
|
55
52
|
_this._msaaNeedDrop = false;
|
|
56
53
|
_this._enforceMSAASupport = false;
|
|
57
54
|
/*private*/ _this._antialiasQuality = Settings.ALLOW_FORCE_MSAA;
|
|
58
55
|
_this._clearFromDispose = false;
|
|
59
|
-
_this._initalFillColor = fillColor;
|
|
60
|
-
_this._lastUsedFill = fillColor;
|
|
61
56
|
return _this;
|
|
62
57
|
}
|
|
63
58
|
SceneImage2D.getImage = function (width, height, transparent, fillColor, powerOfTwo, stage, msaa) {
|
|
@@ -124,70 +119,6 @@ var SceneImage2D = /** @class */ (function (_super) {
|
|
|
124
119
|
enumerable: false,
|
|
125
120
|
configurable: true
|
|
126
121
|
});
|
|
127
|
-
SceneImage2D.prototype.syncData = function (async) {
|
|
128
|
-
var _this = this;
|
|
129
|
-
if (async === void 0) { async = false; }
|
|
130
|
-
if (async && this._asyncRead) {
|
|
131
|
-
return this._asyncRead;
|
|
132
|
-
}
|
|
133
|
-
if (!async && this._asyncRead) {
|
|
134
|
-
throw '[SceneImage2D] Synced read not allowed while async read is requested!';
|
|
135
|
-
}
|
|
136
|
-
this.applySymbol();
|
|
137
|
-
// update data from pixels from GPU
|
|
138
|
-
if (!this._imageDataDirty) {
|
|
139
|
-
return async ? Promise.resolve(false) : false;
|
|
140
|
-
}
|
|
141
|
-
var context = this._stage.context;
|
|
142
|
-
this._stage.setRenderTarget(this, false);
|
|
143
|
-
// when we call syncData, we already loose other data
|
|
144
|
-
// not require apply symbol etc, because it already should be applied
|
|
145
|
-
if (!this._data) {
|
|
146
|
-
this._data = new Uint8ClampedArray(this.width * this.height * 4);
|
|
147
|
-
}
|
|
148
|
-
// mark that this internal call, avoid reqursion loop
|
|
149
|
-
this._internalSync = true;
|
|
150
|
-
this._asyncRead = context.drawToBitmapImage2D(this, false, async);
|
|
151
|
-
this._internalSync = false;
|
|
152
|
-
this._stage.setRenderTarget(null);
|
|
153
|
-
if (!async) {
|
|
154
|
-
this._imageDataDirty = false;
|
|
155
|
-
// we store pixel buffer already as PMA.
|
|
156
|
-
// we should prevent unpack what already is PMA
|
|
157
|
-
this._unpackPMA = false;
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
return this._asyncRead.then(function (_status) {
|
|
161
|
-
_this._imageDataDirty = false;
|
|
162
|
-
_this._unpackPMA = false;
|
|
163
|
-
_this._asyncRead = null;
|
|
164
|
-
return true;
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
/* overide internal */ SceneImage2D.prototype.getDataInternal = function (constructEmpty, skipSync) {
|
|
168
|
-
if (constructEmpty === void 0) { constructEmpty = true; }
|
|
169
|
-
if (skipSync === void 0) { skipSync = false; }
|
|
170
|
-
// if sync called, check that this is requried
|
|
171
|
-
if (!skipSync && this._imageDataDirty && !this._internalSync) {
|
|
172
|
-
// sync data already should fill _data
|
|
173
|
-
this.syncData(false);
|
|
174
|
-
return this._data;
|
|
175
|
-
}
|
|
176
|
-
if (this._initalFillColor === null) {
|
|
177
|
-
return _super.prototype.getDataInternal.call(this, constructEmpty, true);
|
|
178
|
-
}
|
|
179
|
-
// disable empty buffer filling
|
|
180
|
-
// and check that buffer is empyt (has now symbol or alpha)
|
|
181
|
-
var data = _super.prototype.getDataInternal.call(this, false, true);
|
|
182
|
-
// if it empty, fill with initlal value
|
|
183
|
-
if (!data) {
|
|
184
|
-
// fill rect constuct buffer inside
|
|
185
|
-
_super.prototype.fillRect.call(this, this.rect, this._initalFillColor);
|
|
186
|
-
this._initalFillColor = null;
|
|
187
|
-
return this._data;
|
|
188
|
-
}
|
|
189
|
-
return data;
|
|
190
|
-
};
|
|
191
122
|
Object.defineProperty(SceneImage2D.prototype, "assetType", {
|
|
192
123
|
/**
|
|
193
124
|
*
|
|
@@ -299,28 +230,6 @@ var SceneImage2D = /** @class */ (function (_super) {
|
|
|
299
230
|
SceneImage2D.prototype.deepClone = function (from) {
|
|
300
231
|
this.copyPixels(from, this._rect, new Point(0, 0));
|
|
301
232
|
};
|
|
302
|
-
/**
|
|
303
|
-
* Fills a rectangular area of pixels with a specified ARGB color.
|
|
304
|
-
*
|
|
305
|
-
* @param rect The rectangular area to fill.
|
|
306
|
-
* @param color The ARGB color value that fills the area. ARGB colors are
|
|
307
|
-
* often specified in hexadecimal format; for example,
|
|
308
|
-
* 0xFF336699.
|
|
309
|
-
* @throws TypeError The rect is null.
|
|
310
|
-
*/
|
|
311
|
-
SceneImage2D.prototype.fillRect = function (rect, color) {
|
|
312
|
-
this.dropAllReferences();
|
|
313
|
-
var argb = ColorUtils.float32ColorToARGB(color);
|
|
314
|
-
var alpha = this._transparent ? argb[0] / 255 : 1;
|
|
315
|
-
var isCrop = rect !== this._rect && !this._rect.equals(rect);
|
|
316
|
-
this._stage.setRenderTarget(this, true, 0, 0, true);
|
|
317
|
-
this._stage.setScissor(rect);
|
|
318
|
-
// we shure that color is fully filled when there are not any crops
|
|
319
|
-
this._lastUsedFill = isCrop ? null : color;
|
|
320
|
-
this._stage.clear((argb[1] / 0xff) * alpha, (argb[2] / 0xff) * alpha, (argb[3] / 0xff) * alpha, alpha);
|
|
321
|
-
this._stage.setScissor(null);
|
|
322
|
-
this._imageDataDirty = true;
|
|
323
|
-
};
|
|
324
233
|
/**
|
|
325
234
|
* Provides a fast routine to perform pixel manipulation between images with
|
|
326
235
|
* no stretching, rotation, or color effects. This method copies a
|
|
@@ -395,10 +304,8 @@ var SceneImage2D = /** @class */ (function (_super) {
|
|
|
395
304
|
// because copy by GPU required upload array to VRAM,
|
|
396
305
|
// and games that use set/get pixels and copyPixels only for math process not required use GPU copy
|
|
397
306
|
}
|
|
398
|
-
if (this._initalFillColor !== null)
|
|
307
|
+
if (this._initalFillColor !== null)
|
|
399
308
|
this.fillRect(this._rect, this._initalFillColor);
|
|
400
|
-
this._initalFillColor = null;
|
|
401
|
-
}
|
|
402
309
|
var compositeSource = source;
|
|
403
310
|
// merge alpha with source
|
|
404
311
|
if (alphaBitmapData) {
|
|
@@ -527,10 +434,8 @@ var SceneImage2D = /** @class */ (function (_super) {
|
|
|
527
434
|
if (!SceneImage2D._billboardRenderer) {
|
|
528
435
|
this.createBillboardRenderer();
|
|
529
436
|
}
|
|
530
|
-
if (this._initalFillColor !== null)
|
|
437
|
+
if (this._initalFillColor !== null)
|
|
531
438
|
this.fillRect(this._rect, this._initalFillColor);
|
|
532
|
-
this._initalFillColor = null;
|
|
533
|
-
}
|
|
534
439
|
var stage = this._stage;
|
|
535
440
|
var mappedBlend = SceneImage2D._mapSupportedBlendMode(blendMode);
|
|
536
441
|
var supportNativeBlend = !blendMode || mappedBlend !== BlendMode.LAYER || blendMode == BlendMode.LAYER;
|
|
@@ -599,10 +504,8 @@ var SceneImage2D = /** @class */ (function (_super) {
|
|
|
599
504
|
// lazy filling
|
|
600
505
|
// we require fill image with initial color, because we not doing this immediate
|
|
601
506
|
// and when blend is required, because we should blend with vald color
|
|
602
|
-
if ((!nativeMSAA || useBlend) && this._initalFillColor !== null)
|
|
507
|
+
if ((!nativeMSAA || useBlend) && this._initalFillColor !== null)
|
|
603
508
|
this.fillRect(this._rect, this._initalFillColor);
|
|
604
|
-
this._initalFillColor = null;
|
|
605
|
-
}
|
|
606
509
|
if (useTemp) {
|
|
607
510
|
target = SceneImage2D.getTemp(this.width, this.height, this._stage, nativeMSAA);
|
|
608
511
|
// because target image is stupid filled - it not require merging
|
package/index.ts
CHANGED
|
@@ -81,16 +81,6 @@ export class SceneImage2D extends BitmapImage2D {
|
|
|
81
81
|
private static _billboardRoot: DisplayObjectContainer;
|
|
82
82
|
private static _billboard: Billboard;
|
|
83
83
|
|
|
84
|
-
private _imageDataDirty: boolean;
|
|
85
|
-
|
|
86
|
-
private _asyncRead: Promise<boolean>;
|
|
87
|
-
|
|
88
|
-
private _initalFillColor: number = null;
|
|
89
|
-
|
|
90
|
-
private _lastUsedFill: number = null;
|
|
91
|
-
|
|
92
|
-
private _internalSync: boolean = false;
|
|
93
|
-
|
|
94
84
|
protected _msaaNeedDrop: boolean = false;
|
|
95
85
|
|
|
96
86
|
protected _enforceMSAASupport: boolean = false;
|
|
@@ -141,88 +131,6 @@ export class SceneImage2D extends BitmapImage2D {
|
|
|
141
131
|
return this.canUseMSAAInternaly ? this._antialiasQuality : 0;
|
|
142
132
|
}
|
|
143
133
|
|
|
144
|
-
protected syncData(async = false): boolean | Promise<boolean> {
|
|
145
|
-
|
|
146
|
-
if (async && this._asyncRead) {
|
|
147
|
-
return this._asyncRead;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (!async && this._asyncRead) {
|
|
151
|
-
throw '[SceneImage2D] Synced read not allowed while async read is requested!';
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
this.applySymbol();
|
|
155
|
-
|
|
156
|
-
// update data from pixels from GPU
|
|
157
|
-
if (!this._imageDataDirty) {
|
|
158
|
-
return async ? Promise.resolve(false) : false;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const context = <ContextWebGL> this._stage.context;
|
|
162
|
-
|
|
163
|
-
this._stage.setRenderTarget(this, false);
|
|
164
|
-
|
|
165
|
-
// when we call syncData, we already loose other data
|
|
166
|
-
// not require apply symbol etc, because it already should be applied
|
|
167
|
-
if (!this._data) {
|
|
168
|
-
this._data = new Uint8ClampedArray(this.width * this.height * 4);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// mark that this internal call, avoid reqursion loop
|
|
172
|
-
this._internalSync = true;
|
|
173
|
-
this._asyncRead = context.drawToBitmapImage2D(this, false, async);
|
|
174
|
-
this._internalSync = false;
|
|
175
|
-
|
|
176
|
-
this._stage.setRenderTarget(null);
|
|
177
|
-
|
|
178
|
-
if (!async) {
|
|
179
|
-
this._imageDataDirty = false;
|
|
180
|
-
// we store pixel buffer already as PMA.
|
|
181
|
-
// we should prevent unpack what already is PMA
|
|
182
|
-
this._unpackPMA = false;
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return this._asyncRead.then((_status: boolean) => {
|
|
187
|
-
this._imageDataDirty = false;
|
|
188
|
-
this._unpackPMA = false;
|
|
189
|
-
this._asyncRead = null;
|
|
190
|
-
|
|
191
|
-
return true;
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/* overide internal */getDataInternal (constructEmpty = true, skipSync = false) {
|
|
196
|
-
|
|
197
|
-
// if sync called, check that this is requried
|
|
198
|
-
if (!skipSync && this._imageDataDirty && !this._internalSync) {
|
|
199
|
-
// sync data already should fill _data
|
|
200
|
-
this.syncData(false);
|
|
201
|
-
|
|
202
|
-
return this._data;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (this._initalFillColor === null) {
|
|
206
|
-
return super.getDataInternal(constructEmpty, true);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// disable empty buffer filling
|
|
210
|
-
// and check that buffer is empyt (has now symbol or alpha)
|
|
211
|
-
const data = super.getDataInternal(false, true);
|
|
212
|
-
|
|
213
|
-
// if it empty, fill with initlal value
|
|
214
|
-
if (!data) {
|
|
215
|
-
|
|
216
|
-
// fill rect constuct buffer inside
|
|
217
|
-
super.fillRect(this.rect, this._initalFillColor);
|
|
218
|
-
this._initalFillColor = null;
|
|
219
|
-
|
|
220
|
-
return this._data;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return data;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
134
|
/**
|
|
227
135
|
*
|
|
228
136
|
* @returns {string}
|
|
@@ -263,10 +171,8 @@ export class SceneImage2D extends BitmapImage2D {
|
|
|
263
171
|
width: number, height: number, transparent: boolean = true,
|
|
264
172
|
fillColor: number = 0xffffffff, powerOfTwo: boolean = true, stage: Stage = null) {
|
|
265
173
|
|
|
266
|
-
super(width, height, transparent,
|
|
174
|
+
super(width, height, transparent, fillColor, powerOfTwo, stage);
|
|
267
175
|
|
|
268
|
-
this._initalFillColor = fillColor;
|
|
269
|
-
this._lastUsedFill = fillColor;
|
|
270
176
|
}
|
|
271
177
|
|
|
272
178
|
private createRenderer() {
|
|
@@ -388,39 +294,6 @@ export class SceneImage2D extends BitmapImage2D {
|
|
|
388
294
|
this.copyPixels(from, this._rect, new Point(0,0));
|
|
389
295
|
}
|
|
390
296
|
|
|
391
|
-
/**
|
|
392
|
-
* Fills a rectangular area of pixels with a specified ARGB color.
|
|
393
|
-
*
|
|
394
|
-
* @param rect The rectangular area to fill.
|
|
395
|
-
* @param color The ARGB color value that fills the area. ARGB colors are
|
|
396
|
-
* often specified in hexadecimal format; for example,
|
|
397
|
-
* 0xFF336699.
|
|
398
|
-
* @throws TypeError The rect is null.
|
|
399
|
-
*/
|
|
400
|
-
public fillRect(rect: Rectangle, color: number): void {
|
|
401
|
-
this.dropAllReferences();
|
|
402
|
-
|
|
403
|
-
const argb = ColorUtils.float32ColorToARGB(color);
|
|
404
|
-
const alpha = this._transparent ? argb[0] / 255 : 1;
|
|
405
|
-
const isCrop = rect !== this._rect && !this._rect.equals(rect);
|
|
406
|
-
|
|
407
|
-
this._stage.setRenderTarget(this, true, 0, 0, true);
|
|
408
|
-
this._stage.setScissor(rect);
|
|
409
|
-
|
|
410
|
-
// we shure that color is fully filled when there are not any crops
|
|
411
|
-
this._lastUsedFill = isCrop ? null : color;
|
|
412
|
-
|
|
413
|
-
this._stage.clear(
|
|
414
|
-
(argb[1] / 0xff) * alpha,
|
|
415
|
-
(argb[2] / 0xff) * alpha,
|
|
416
|
-
(argb[3] / 0xff) * alpha,
|
|
417
|
-
alpha
|
|
418
|
-
);
|
|
419
|
-
|
|
420
|
-
this._stage.setScissor(null);
|
|
421
|
-
this._imageDataDirty = true;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
297
|
/**
|
|
425
298
|
* Provides a fast routine to perform pixel manipulation between images with
|
|
426
299
|
* no stretching, rotation, or color effects. This method copies a
|
|
@@ -504,10 +377,8 @@ export class SceneImage2D extends BitmapImage2D {
|
|
|
504
377
|
// and games that use set/get pixels and copyPixels only for math process not required use GPU copy
|
|
505
378
|
}
|
|
506
379
|
|
|
507
|
-
if (this._initalFillColor !== null)
|
|
380
|
+
if (this._initalFillColor !== null)
|
|
508
381
|
this.fillRect(this._rect, this._initalFillColor);
|
|
509
|
-
this._initalFillColor = null;
|
|
510
|
-
}
|
|
511
382
|
|
|
512
383
|
let compositeSource: Image2D = source;
|
|
513
384
|
|
|
@@ -793,10 +664,8 @@ export class SceneImage2D extends BitmapImage2D {
|
|
|
793
664
|
this.createBillboardRenderer();
|
|
794
665
|
}
|
|
795
666
|
|
|
796
|
-
if (this._initalFillColor !== null)
|
|
667
|
+
if (this._initalFillColor !== null)
|
|
797
668
|
this.fillRect(this._rect, this._initalFillColor);
|
|
798
|
-
this._initalFillColor = null;
|
|
799
|
-
}
|
|
800
669
|
|
|
801
670
|
const stage = this._stage;
|
|
802
671
|
const mappedBlend = SceneImage2D._mapSupportedBlendMode(blendMode);
|
|
@@ -899,10 +768,8 @@ export class SceneImage2D extends BitmapImage2D {
|
|
|
899
768
|
// lazy filling
|
|
900
769
|
// we require fill image with initial color, because we not doing this immediate
|
|
901
770
|
// and when blend is required, because we should blend with vald color
|
|
902
|
-
if ((!nativeMSAA || useBlend) && this._initalFillColor !== null)
|
|
771
|
+
if ((!nativeMSAA || useBlend) && this._initalFillColor !== null)
|
|
903
772
|
this.fillRect(this._rect, this._initalFillColor);
|
|
904
|
-
this._initalFillColor = null;
|
|
905
|
-
}
|
|
906
773
|
|
|
907
774
|
if (useTemp) {
|
|
908
775
|
target = SceneImage2D.getTemp(this.width, this.height, this._stage, nativeMSAA);
|