@next2d/display 1.15.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/Loader.js CHANGED
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { DisplayObjectContainer } from "./DisplayObjectContainer";
11
2
  import { LoaderInfo } from "./LoaderInfo";
12
3
  import { MovieClip } from "./MovieClip";
@@ -148,6 +139,33 @@ export class Loader extends DisplayObjectContainer {
148
139
  }
149
140
  });
150
141
  }
142
+ /**
143
+ * @description NoCodeToolのJSONを直接読み込む
144
+ * Read JSON directly from NoCodeTool
145
+ *
146
+ * @param {string} json
147
+ * @return {void}
148
+ * @method
149
+ * @public
150
+ */
151
+ loadJSON(json) {
152
+ if (json.type === "zlib") {
153
+ if ($useUnzipWorker()) {
154
+ $unzipQueues.push(json);
155
+ return;
156
+ }
157
+ $updateUnzipWorkerStatus(true);
158
+ const unzipWorker = $getUnzipWorker();
159
+ const buffer = new Uint8Array(json.buffer);
160
+ unzipWorker.onmessage = (event) => {
161
+ this._$unzipHandler(event);
162
+ };
163
+ unzipWorker.postMessage(buffer, [buffer.buffer]);
164
+ }
165
+ else {
166
+ this._$build(json);
167
+ }
168
+ }
151
169
  /**
152
170
  * @param {ProgressEvent} event
153
171
  * @return {void}
@@ -174,29 +192,12 @@ export class Loader extends DisplayObjectContainer {
174
192
  }
175
193
  if (199 < target.status && 400 > target.status) {
176
194
  if (loaderInfo.format === "json") {
177
- const json = target.response;
178
- if (json.type === "zlib") {
179
- if ($useUnzipWorker()) {
180
- $unzipQueues.push({
181
- "json": json,
182
- "scope": this
183
- });
184
- return;
185
- }
186
- $updateUnzipWorkerStatus(true);
187
- const unzipWorker = $getUnzipWorker();
188
- const buffer = new Uint8Array(json.buffer);
189
- unzipWorker.onmessage = (event) => __awaiter(this, void 0, void 0, function* () {
190
- this._$unzipHandler(event);
191
- });
192
- unzipWorker.postMessage(buffer, [buffer.buffer]);
193
- }
194
- else {
195
- this._$build(json);
196
- }
195
+ this.loadJSON(target.response);
197
196
  }
198
197
  else {
199
- throw new Error("LoaderInfo format is `json`");
198
+ if (loaderInfo.willTrigger(IOErrorEvent.IO_ERROR)) {
199
+ loaderInfo.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "LoaderInfo format is `json`"));
200
+ }
200
201
  }
201
202
  }
202
203
  else {
@@ -218,10 +219,10 @@ export class Loader extends DisplayObjectContainer {
218
219
  if (!object) {
219
220
  return;
220
221
  }
221
- const buffer = new Uint8Array(object.json.buffer);
222
+ const buffer = new Uint8Array(object.buffer);
222
223
  const unzipWorker = $getUnzipWorker();
223
224
  unzipWorker.onmessage = (event) => {
224
- object.scope._$unzipHandler(event);
225
+ this._$unzipHandler(event);
225
226
  };
226
227
  unzipWorker.postMessage(buffer, [buffer.buffer]);
227
228
  }
package/dist/MovieClip.js CHANGED
@@ -249,7 +249,7 @@ export class MovieClip extends Sprite {
249
249
  if (this._$loopConfig) {
250
250
  return this._$loopConfig;
251
251
  }
252
- const place = this._$getPlaceObject();
252
+ const place = this._$placeObject || this._$getPlaceObject();
253
253
  if (!place || !place.loop) {
254
254
  return null;
255
255
  }
package/dist/Shape.d.ts CHANGED
@@ -15,8 +15,6 @@ import type { BoundsImpl, ShapeCharacterImpl, ParentImpl, DictionaryTagImpl, Pla
15
15
  */
16
16
  export declare class Shape extends DisplayObject {
17
17
  private _$graphics;
18
- private _$bounds;
19
- private _$bitmapId;
20
18
  private _$src;
21
19
  /**
22
20
  * @constructor
@@ -91,12 +89,6 @@ export declare class Shape extends DisplayObject {
91
89
  * @private
92
90
  */
93
91
  _$buildCharacter(character: Character<ShapeCharacterImpl>, loaderInfo: LoaderInfo): void;
94
- /**
95
- * @return {void}
96
- * @method
97
- * @private
98
- */
99
- _$createWorkerInstance(): void;
100
92
  /**
101
93
  * @param {object} character
102
94
  * @return {void}
@@ -155,6 +147,12 @@ export declare class Shape extends DisplayObject {
155
147
  * @private
156
148
  */
157
149
  _$hit(context: CanvasRenderingContext2D, matrix: Float32Array, options: PlayerHitObjectImpl, is_clip?: boolean): boolean;
150
+ /**
151
+ * @return {void}
152
+ * @method
153
+ * @private
154
+ */
155
+ _$createWorkerInstance(): void;
158
156
  /**
159
157
  * @return {void}
160
158
  * @method
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 プロパティがあります。
@@ -28,18 +28,6 @@ export class Shape extends DisplayObject {
28
28
  * @private
29
29
  */
30
30
  this._$graphics = null;
31
- /**
32
- * @type {object}
33
- * @default null
34
- * @private
35
- */
36
- this._$bounds = null;
37
- /**
38
- * @type {number}
39
- * @default 0
40
- * @private
41
- */
42
- this._$bitmapId = 0;
43
31
  /**
44
32
  * @type {string}
45
33
  * @default ""
@@ -122,6 +110,9 @@ export class Shape extends DisplayObject {
122
110
  return this._$src;
123
111
  }
124
112
  set src(src) {
113
+ if (!src) {
114
+ return;
115
+ }
125
116
  const image = new Image();
126
117
  image.addEventListener("load", () => {
127
118
  const width = image.width;
@@ -137,6 +128,7 @@ export class Shape extends DisplayObject {
137
128
  }
138
129
  });
139
130
  this._$src = image.src = src;
131
+ this.graphics._$mode = "bitmap";
140
132
  }
141
133
  /**
142
134
  * @param {object} character
@@ -154,7 +146,6 @@ export class Shape extends DisplayObject {
154
146
  switch (true) {
155
147
  case character.bitmapId > 0:
156
148
  {
157
- this._$bitmapId = character.bitmapId;
158
149
  const bitmap = loaderInfo
159
150
  ._$data
160
151
  .characters[character.bitmapId];
@@ -172,6 +163,11 @@ export class Shape extends DisplayObject {
172
163
  bitmapData.buffer = bitmap._$buffer.slice();
173
164
  // setup
174
165
  graphics._$recode = $getArray();
166
+ if (width === character.bounds.xMax - character.bounds.xMin
167
+ && height === character.bounds.yMax - character.bounds.yMin) {
168
+ graphics._$bitmapId = character.bitmapId;
169
+ graphics._$mode = "bitmap";
170
+ }
175
171
  // clone
176
172
  const recodes = character.recodes;
177
173
  if (recodes[recodes.length - 1] === Graphics.END_FILL) {
@@ -214,6 +210,11 @@ export class Shape extends DisplayObject {
214
210
  graphics._$recode[idx++] = bitmapData;
215
211
  const matrix = recodes[idx];
216
212
  graphics._$recode[idx] = $getFloat32Array6(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
213
+ if (value.width === character.bounds.xMax - character.bounds.xMin
214
+ && value.height === character.bounds.yMax - character.bounds.yMin) {
215
+ graphics._$bitmapId = character.bitmapId;
216
+ graphics._$mode = "bitmap";
217
+ }
217
218
  }
218
219
  }
219
220
  break;
@@ -223,6 +224,7 @@ export class Shape extends DisplayObject {
223
224
  }
224
225
  }
225
226
  else {
227
+ graphics._$mode = "bitmap";
226
228
  const width = $Math.abs(character.bounds.xMax - character.bounds.xMin);
227
229
  const height = $Math.abs(character.bounds.yMax - character.bounds.yMin);
228
230
  const bitmapData = new BitmapData(width, height);
@@ -253,57 +255,6 @@ export class Shape extends DisplayObject {
253
255
  this._$createWorkerInstance();
254
256
  }
255
257
  }
256
- /**
257
- * @return {void}
258
- * @method
259
- * @private
260
- */
261
- _$createWorkerInstance() {
262
- if (this._$created || !$rendererWorker) {
263
- return;
264
- }
265
- this._$created = true;
266
- const options = $getArray();
267
- const bounds = this._$getBounds();
268
- const message = {
269
- "command": "createShape",
270
- "instanceId": this._$instanceId,
271
- "parentId": this._$parent ? this._$parent._$instanceId : -1,
272
- "maxAlpha": 0,
273
- "canDraw": false,
274
- "xMin": bounds.xMin,
275
- "yMin": bounds.yMin,
276
- "xMax": bounds.xMax,
277
- "yMax": bounds.yMax
278
- };
279
- const graphics = this._$graphics;
280
- if (graphics) {
281
- const recodes = graphics._$getRecodes();
282
- if (recodes.length
283
- && graphics._$maxAlpha > 0
284
- && graphics._$canDraw) {
285
- message.maxAlpha = graphics._$maxAlpha;
286
- message.canDraw = graphics._$canDraw;
287
- message.recodes = recodes;
288
- options.push(recodes.buffer);
289
- }
290
- }
291
- if (this._$characterId > -1) {
292
- message.characterId = this._$characterId;
293
- }
294
- if (this._$loaderInfo) {
295
- message.loaderInfoId = this._$loaderInfo._$id;
296
- }
297
- if (this._$scale9Grid) {
298
- message.grid = {
299
- "x": this._$scale9Grid.x,
300
- "y": this._$scale9Grid.y,
301
- "w": this._$scale9Grid.width,
302
- "h": this._$scale9Grid.height
303
- };
304
- }
305
- $rendererWorker.postMessage(message, options);
306
- }
307
258
  /**
308
259
  * @param {object} character
309
260
  * @return {void}
@@ -473,18 +424,75 @@ export class Shape extends DisplayObject {
473
424
  }
474
425
  return hit;
475
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
+ }
476
484
  /**
477
485
  * @return {void}
478
486
  * @method
479
487
  * @private
480
488
  */
481
489
  _$postProperty() {
482
- if (!$rendererWorker) {
490
+ if (!this._$created || !$rendererWorker) {
483
491
  return;
484
492
  }
485
493
  const message = this._$createMessage();
486
494
  const graphics = this._$graphics;
487
- if (graphics && !graphics._$buffer) {
495
+ if (graphics && !graphics._$posted) {
488
496
  message.maxAlpha = graphics._$maxAlpha;
489
497
  message.canDraw = graphics._$canDraw;
490
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
@@ -1,6 +1,5 @@
1
1
  import { DisplayObjectContainer } from "./DisplayObjectContainer";
2
- import { $devicePixelRatio } from "@next2d/util";
3
- import { $clamp, $toColorInt, $uintToRGBA } from "@next2d/share";
2
+ import { $clamp, $toColorInt, $uintToRGBA, $devicePixelRatio } from "@next2d/share";
4
3
  /**
5
4
  * Stage クラスはメイン描画領域を表します。
6
5
  * The Stage class represents the main drawing area.
@@ -246,6 +245,8 @@ export class Stage extends DisplayObjectContainer {
246
245
  _$addChild(child) {
247
246
  child._$stage = this;
248
247
  child._$root = child;
248
+ // worker flag updated
249
+ this._$created = true;
249
250
  return super._$addChild(child);
250
251
  }
251
252
  }