@next2d/display 1.16.0 → 1.17.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/Shape.js CHANGED
@@ -3,7 +3,7 @@ import { Graphics } from "./Graphics";
3
3
  import { BitmapData } from "./BitmapData";
4
4
  import { Rectangle } from "@next2d/geom";
5
5
  import { Event } from "@next2d/events";
6
- import { $MATRIX_HIT_ARRAY_IDENTITY, $rendererWorker } from "@next2d/util";
6
+ import { $MATRIX_HIT_ARRAY_IDENTITY, $getRenderBufferArray, $getRenderMessageObject, $poolRenderMessageObject, $rendererWorker } from "@next2d/util";
7
7
  import { $getArray, $poolArray, $getFloat32Array6, $getBoundsObject, $poolBoundsObject, $multiplicationMatrix, $boundsMatrix, $poolFloat32Array6, $multiplicationColor, $clamp, $poolFloat32Array8, $Math, $COLOR_ARRAY_IDENTITY } from "@next2d/share";
8
8
  /**
9
9
  * Shape クラスには、Graphics クラスからメソッドにアクセスできる graphics プロパティがあります。
@@ -255,57 +255,6 @@ export class Shape extends DisplayObject {
255
255
  this._$createWorkerInstance();
256
256
  }
257
257
  }
258
- /**
259
- * @return {void}
260
- * @method
261
- * @private
262
- */
263
- _$createWorkerInstance() {
264
- if (this._$created || !$rendererWorker) {
265
- return;
266
- }
267
- this._$created = true;
268
- const options = $getArray();
269
- const bounds = this._$getBounds();
270
- const message = {
271
- "command": "createShape",
272
- "instanceId": this._$instanceId,
273
- "parentId": this._$parent ? this._$parent._$instanceId : -1,
274
- "maxAlpha": 0,
275
- "canDraw": false,
276
- "xMin": bounds.xMin,
277
- "yMin": bounds.yMin,
278
- "xMax": bounds.xMax,
279
- "yMax": bounds.yMax
280
- };
281
- const graphics = this._$graphics;
282
- if (graphics) {
283
- const recodes = graphics._$getRecodes();
284
- if (recodes.length
285
- && graphics._$maxAlpha > 0
286
- && graphics._$canDraw) {
287
- message.maxAlpha = graphics._$maxAlpha;
288
- message.canDraw = graphics._$canDraw;
289
- message.recodes = recodes;
290
- options.push(recodes.buffer);
291
- }
292
- }
293
- if (this._$characterId > -1) {
294
- message.characterId = this._$characterId;
295
- }
296
- if (this._$loaderInfo) {
297
- message.loaderInfoId = this._$loaderInfo._$id;
298
- }
299
- if (this._$scale9Grid) {
300
- message.grid = {
301
- "x": this._$scale9Grid.x,
302
- "y": this._$scale9Grid.y,
303
- "w": this._$scale9Grid.width,
304
- "h": this._$scale9Grid.height
305
- };
306
- }
307
- $rendererWorker.postMessage(message, options);
308
- }
309
258
  /**
310
259
  * @param {object} character
311
260
  * @return {void}
@@ -475,18 +424,75 @@ export class Shape extends DisplayObject {
475
424
  }
476
425
  return hit;
477
426
  }
427
+ /**
428
+ * @return {void}
429
+ * @method
430
+ * @private
431
+ */
432
+ _$createWorkerInstance() {
433
+ if (this._$created || !$rendererWorker) {
434
+ return;
435
+ }
436
+ // update flag
437
+ this._$created = true;
438
+ this._$posted = true;
439
+ this._$updated = false;
440
+ const buffer = $getRenderBufferArray();
441
+ let index = 0;
442
+ buffer[index++] = this._$instanceId;
443
+ buffer[index++] = this._$parent ? this._$parent._$instanceId : -1;
444
+ buffer[index++] = 0; // maxAlpha
445
+ buffer[index++] = 0; // canDraw
446
+ // graphics
447
+ const graphics = this._$graphics;
448
+ if (graphics
449
+ && !graphics._$posted
450
+ && graphics._$maxAlpha > 0
451
+ && graphics._$canDraw) {
452
+ graphics._$posted = true;
453
+ const message = $getRenderMessageObject();
454
+ const recodes = graphics._$getRecodes();
455
+ message.command = `shapeRecodes@${this._$instanceId}`;
456
+ message.buffer = recodes;
457
+ const options = $getArray(recodes.buffer);
458
+ $rendererWorker.postMessage(message, options);
459
+ $poolRenderMessageObject(message);
460
+ $poolArray(options);
461
+ buffer[2] = graphics._$maxAlpha;
462
+ buffer[3] = +graphics._$canDraw;
463
+ }
464
+ // bounds
465
+ const bounds = this._$getBounds();
466
+ buffer[index++] = bounds.xMin;
467
+ buffer[index++] = bounds.yMin;
468
+ buffer[index++] = bounds.xMax;
469
+ buffer[index++] = bounds.yMax;
470
+ // characterId
471
+ buffer[index++] = this._$characterId > -1 ? this._$characterId : -1;
472
+ // loaderInfoId
473
+ buffer[index++] = this._$loaderInfo ? this._$loaderInfo._$id : -1;
474
+ // property
475
+ this._$registerProperty(buffer, index);
476
+ const message = $getRenderMessageObject();
477
+ message.command = "createShape";
478
+ message.buffer = buffer;
479
+ const options = $getArray(buffer.buffer);
480
+ $rendererWorker.postMessage(message, options);
481
+ $poolRenderMessageObject(message);
482
+ $poolArray(options);
483
+ }
478
484
  /**
479
485
  * @return {void}
480
486
  * @method
481
487
  * @private
482
488
  */
483
489
  _$postProperty() {
484
- if (!$rendererWorker) {
490
+ if (!this._$created || !$rendererWorker) {
485
491
  return;
486
492
  }
487
493
  const message = this._$createMessage();
488
494
  const graphics = this._$graphics;
489
- if (graphics && !graphics._$buffer) {
495
+ if (graphics && !graphics._$posted) {
490
496
  message.maxAlpha = graphics._$maxAlpha;
491
497
  message.canDraw = graphics._$canDraw;
492
498
  const recodes = graphics._$getRecodes();
package/dist/Sprite.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { DisplayObjectContainer } from "./DisplayObjectContainer";
2
- import { Graphics } from "./Graphics";
3
2
  import { SoundTransform } from "@next2d/media";
4
3
  import type { Rectangle, Point } from "@next2d/geom";
5
4
  import type { SpriteImpl, DropTargetImpl, DictionaryTagImpl, ParentImpl, MovieClipCharacterImpl } from "@next2d/interface";
@@ -18,7 +17,6 @@ export declare class Sprite extends DisplayObjectContainer {
18
17
  protected _$buttonMode: boolean;
19
18
  protected _$hitArea: SpriteImpl<any> | null;
20
19
  protected _$soundTransform: SoundTransform | null;
21
- protected _$graphics: Graphics | null;
22
20
  protected _$useHandCursor: boolean;
23
21
  /**
24
22
  * @constructor
@@ -85,16 +83,6 @@ export declare class Sprite extends DisplayObjectContainer {
85
83
  * @public
86
84
  */
87
85
  get dropTarget(): DropTargetImpl;
88
- /**
89
- * @description ベクターの描画コマンドが発生するこのスプライトに属する Graphics オブジェクトを指定します。
90
- * Specifies the Graphics object that belongs to this sprite
91
- * where vector drawing commands can occur.
92
- *
93
- * @member {Graphics}
94
- * @readonly
95
- * @public
96
- */
97
- get graphics(): Graphics;
98
86
  /**
99
87
  * @description スプライトのヒット領域となる別のスプライトを指定します。
100
88
  * Designates another sprite to serve as the hit area for a sprite.
package/dist/Sprite.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { DisplayObjectContainer } from "./DisplayObjectContainer";
2
- import { Graphics } from "./Graphics";
3
2
  import { SoundTransform } from "@next2d/media";
4
3
  import { $currentMousePoint, $dragRules, $dropTarget, $rendererWorker, $setDropTarget } from "@next2d/util";
5
4
  /**
@@ -44,12 +43,6 @@ export class Sprite extends DisplayObjectContainer {
44
43
  * @private
45
44
  */
46
45
  this._$useHandCursor = true;
47
- /**
48
- * @type {Graphics|null}
49
- * @default null
50
- * @private
51
- */
52
- this._$graphics = null;
53
46
  }
54
47
  /**
55
48
  * @description 指定されたクラスのストリングを返します。
@@ -125,21 +118,6 @@ export class Sprite extends DisplayObjectContainer {
125
118
  get dropTarget() {
126
119
  return $dropTarget;
127
120
  }
128
- /**
129
- * @description ベクターの描画コマンドが発生するこのスプライトに属する Graphics オブジェクトを指定します。
130
- * Specifies the Graphics object that belongs to this sprite
131
- * where vector drawing commands can occur.
132
- *
133
- * @member {Graphics}
134
- * @readonly
135
- * @public
136
- */
137
- get graphics() {
138
- if (!this._$graphics) {
139
- this._$graphics = new Graphics(this);
140
- }
141
- return this._$graphics;
142
- }
143
121
  /**
144
122
  * @description スプライトのヒット領域となる別のスプライトを指定します。
145
123
  * Designates another sprite to serve as the hit area for a sprite.
package/dist/Stage.js CHANGED
@@ -245,6 +245,8 @@ export class Stage extends DisplayObjectContainer {
245
245
  _$addChild(child) {
246
246
  child._$stage = this;
247
247
  child._$root = child;
248
+ // worker flag updated
249
+ this._$created = true;
248
250
  return super._$addChild(child);
249
251
  }
250
252
  }