@next2d/display 2.13.1 → 3.0.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.
Files changed (27) hide show
  1. package/README.md +388 -5
  2. package/package.json +9 -9
  3. package/src/BitmapData.d.ts +1 -1
  4. package/src/BitmapData.js +1 -16
  5. package/src/DisplayObject/service/DisplayObjectApplyChangesService.js +4 -3
  6. package/src/DisplayObject/service/DisplayObjectGenerateHashService.js +57 -11
  7. package/src/DisplayObject.js +2 -1
  8. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGenerateRenderQueueUseCase.js +147 -4
  9. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGetLayerBoundsUseCase.d.ts +14 -0
  10. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerGetLayerBoundsUseCase.js +65 -0
  11. package/src/Graphics/service/GraphicsToNumberArrayService.js +25 -1
  12. package/src/Shape/usecase/ShapeCalcLayerBoundsUseCase.d.ts +12 -0
  13. package/src/Shape/usecase/ShapeCalcLayerBoundsUseCase.js +32 -0
  14. package/src/Shape/usecase/ShapeGenerateRenderQueueUseCase.js +28 -16
  15. package/src/Shape/usecase/ShapeLoadAsyncUseCase.d.ts +12 -0
  16. package/src/Shape/usecase/ShapeLoadAsyncUseCase.js +21 -0
  17. package/src/Shape.d.ts +10 -0
  18. package/src/Shape.js +13 -0
  19. package/src/Sprite.d.ts +2 -5
  20. package/src/Sprite.js +2 -5
  21. package/src/Stage.js +3 -0
  22. package/src/TextField/usecase/TextFieldCalcLayerBoundsUseCase.d.ts +12 -0
  23. package/src/TextField/usecase/TextFieldCalcLayerBoundsUseCase.js +32 -0
  24. package/src/TextField/usecase/TextFieldGenerateRenderQueueUseCase.js +23 -12
  25. package/src/Video/usecase/VideoCalcLayerBoundsUseCase.d.ts +12 -0
  26. package/src/Video/usecase/VideoCalcLayerBoundsUseCase.js +32 -0
  27. package/src/Video/usecase/VideoGenerateRenderQueueUseCase.js +12 -1
package/README.md CHANGED
@@ -1,11 +1,394 @@
1
- @next2d/display
2
- =============
1
+ # @next2d/display
3
2
 
4
- ## Installation
3
+ Display package for Next2D Player - DisplayObject hierarchy, Graphics drawing API, and content loading capabilities.
5
4
 
6
- ```
5
+ Next2D Player の Display パッケージ - DisplayObject 階層、Graphics 描画 API、およびコンテンツ読み込み機能を提供します。
6
+
7
+ ## Overview / 概要
8
+
9
+ The `@next2d/display` package provides the core visual object model for Next2D Player. It implements the complete DisplayObject hierarchy, a powerful vector graphics drawing API, and content loading capabilities.
10
+
11
+ `@next2d/display` パッケージは Next2D Player のコアとなるビジュアルオブジェクトモデルを提供します。完全な DisplayObject 階層、強力なベクターグラフィックス描画 API、およびコンテンツ読み込み機能を実装しています。
12
+
13
+ ### Key Features / 主な機能
14
+
15
+ - **DisplayObject Hierarchy**: Complete implementation of the display list architecture
16
+ - **DisplayObject 階層**: ディスプレイリストアーキテクチャの完全な実装
17
+ - **Graphics API**: Vector drawing capabilities with fills, strokes, and gradients
18
+ - **Graphics API**: 塗り、線、グラデーションを使ったベクター描画機能
19
+ - **Content Loading**: Dynamic loading of external content and assets
20
+ - **コンテンツ読み込み**: 外部コンテンツとアセットの動的読み込み
21
+ - **Timeline Support**: MovieClip with frame-based animation and scripting
22
+ - **タイムラインサポート**: フレームベースのアニメーションとスクリプティングを持つ MovieClip
23
+
24
+ ## Installation / インストール
25
+
26
+ ```bash
7
27
  npm install @next2d/display
8
28
  ```
9
29
 
10
- ## License
30
+ ## Directory Structure / ディレクトリ構造
31
+
32
+ ```
33
+ src/
34
+ ├── DisplayObject.ts # Base class for all display objects / すべての表示オブジェクトの基底クラス
35
+ ├── DisplayObjectContainer.ts # Container for child display objects / 子表示オブジェクトのコンテナ
36
+ ├── InteractiveObject.ts # Base class for interactive objects / インタラクティブオブジェクトの基底クラス
37
+ ├── Sprite.ts # Basic display object container with graphics / グラフィックスを持つ基本的な表示オブジェクトコンテナ
38
+ ├── MovieClip.ts # Timeline-based animation object / タイムラインベースのアニメーションオブジェクト
39
+ ├── Shape.ts # Lightweight graphics display object / 軽量なグラフィックス表示オブジェクト
40
+ ├── Stage.ts # Root display object / ルート表示オブジェクト
41
+ ├── TextField.ts # Text display and input / テキスト表示と入力
42
+ ├── Video.ts # Video display object / ビデオ表示オブジェクト
43
+
44
+ ├── Graphics.ts # Vector drawing API / ベクター描画 API
45
+ ├── Graphics/ # Graphics implementation details / Graphics 実装の詳細
46
+ │ ├── service/ # Graphics service layer / Graphics サービス層
47
+ │ └── usecase/ # Graphics use cases / Graphics ユースケース
48
+
49
+ ├── Loader.ts # External content loader / 外部コンテンツローダー
50
+ ├── Loader/ # Loader implementation details / Loader 実装の詳細
51
+ │ ├── service/ # Loader service layer / Loader サービス層
52
+ │ ├── usecase/ # Loader use cases / Loader ユースケース
53
+ │ └── worker/ # Loader web workers / Loader ウェブワーカー
54
+
55
+ ├── LoaderInfo.ts # Loader information / ローダー情報
56
+ ├── BitmapData.ts # Bitmap manipulation / ビットマップ操作
57
+ ├── BlendMode.ts # Blend mode constants / ブレンドモード定数
58
+ ├── FrameLabel.ts # Frame label for timeline / タイムライン用フレームラベル
59
+ ├── LoopConfig.ts # Loop configuration / ループ設定
60
+ ├── LoopType.ts # Loop type constants / ループタイプ定数
61
+ ├── DisplayObjectUtil.ts # Display object utilities / 表示オブジェクトユーティリティ
62
+
63
+ ├── GraphicsBitmapFill.ts # Bitmap fill style / ビットマップ塗りスタイル
64
+ ├── GraphicsGradientFill.ts # Gradient fill style / グラデーション塗りスタイル
65
+
66
+ ├── interface/ # TypeScript interfaces / TypeScript インターフェース
67
+ │ ├── IDisplayObject.ts
68
+ │ ├── IBlendMode.ts
69
+ │ ├── IBounds.ts
70
+ │ ├── ICharacter.ts
71
+ │ ├── IMovieClipCharacter.ts
72
+ │ ├── IShapeCharacter.ts
73
+ │ ├── ITextFieldCharacter.ts
74
+ │ ├── IVideoCharacter.ts
75
+ │ ├── ILoaderInfoData.ts
76
+ │ ├── ILoopConfig.ts
77
+ │ ├── ILoopType.ts
78
+ │ ├── IFrameLabel.ts
79
+ │ ├── IPlaceObject.ts
80
+ │ └── ... (40+ interface files)
81
+
82
+ ├── DisplayObject/ # DisplayObject implementation / DisplayObject 実装
83
+ │ ├── service/ # Service layer / サービス層
84
+ │ └── usecase/ # Use case layer / ユースケース層
85
+
86
+ ├── DisplayObjectContainer/ # DisplayObjectContainer implementation / DisplayObjectContainer 実装
87
+ │ ├── service/ # Service layer / サービス層
88
+ │ └── usecase/ # Use case layer / ユースケース層
89
+
90
+ ├── MovieClip/ # MovieClip implementation / MovieClip 実装
91
+ │ ├── service/ # Service layer / サービス層
92
+ │ └── usecase/ # Use case layer / ユースケース層
93
+
94
+ ├── Shape/ # Shape implementation / Shape 実装
95
+ │ └── service/ # Service layer / サービス層
96
+
97
+ ├── Sprite/ # Sprite implementation / Sprite 実装
98
+ │ └── service/ # Service layer / サービス層
99
+
100
+ └── Stage/ # Stage implementation / Stage 実装
101
+ └── usecase/ # Use case layer / ユースケース層
102
+ ```
103
+
104
+ ## Class Hierarchy / クラス階層
105
+
106
+ The display package implements a hierarchical object model where each class extends its parent's functionality.
107
+
108
+ display パッケージは、各クラスが親の機能を拡張する階層的なオブジェクトモデルを実装しています。
109
+
110
+ ```mermaid
111
+ classDiagram
112
+ EventDispatcher <|-- DisplayObject
113
+ DisplayObject <|-- InteractiveObject
114
+ InteractiveObject <|-- DisplayObjectContainer
115
+ DisplayObjectContainer <|-- Sprite
116
+ DisplayObjectContainer <|-- Stage
117
+ Sprite <|-- MovieClip
118
+ DisplayObject <|-- Shape
119
+ DisplayObject <|-- TextField
120
+ DisplayObject <|-- Video
121
+
122
+ class EventDispatcher {
123
+ +addEventListener()
124
+ +removeEventListener()
125
+ +dispatchEvent()
126
+ }
127
+
128
+ class DisplayObject {
129
+ +x: number
130
+ +y: number
131
+ +width: number
132
+ +height: number
133
+ +rotation: number
134
+ +scaleX: number
135
+ +scaleY: number
136
+ +alpha: number
137
+ +visible: boolean
138
+ +blendMode: IBlendMode
139
+ +filters: IFilterArray
140
+ +parent: DisplayObjectContainer
141
+ +stage: Stage
142
+ +getBounds()
143
+ +hitTestObject()
144
+ +hitTestPoint()
145
+ +globalToLocal()
146
+ +localToGlobal()
147
+ }
148
+
149
+ class InteractiveObject {
150
+ +mouseEnabled: boolean
151
+ +doubleClickEnabled: boolean
152
+ +tabEnabled: boolean
153
+ }
154
+
155
+ class DisplayObjectContainer {
156
+ +children: DisplayObject[]
157
+ +numChildren: number
158
+ +mouseChildren: boolean
159
+ +addChild()
160
+ +addChildAt()
161
+ +removeChild()
162
+ +removeChildAt()
163
+ +removeChildren()
164
+ +getChildAt()
165
+ +getChildByName()
166
+ +getChildIndex()
167
+ +setChildIndex()
168
+ +swapChildren()
169
+ +contains()
170
+ }
171
+
172
+ class Sprite {
173
+ +graphics: Graphics
174
+ +buttonMode: boolean
175
+ +useHandCursor: boolean
176
+ +startDrag()
177
+ +stopDrag()
178
+ }
179
+
180
+ class MovieClip {
181
+ +currentFrame: number
182
+ +totalFrames: number
183
+ +currentLabel: string
184
+ +currentLabels: FrameLabel[]
185
+ +isTimelineEnabled: boolean
186
+ +play()
187
+ +stop()
188
+ +gotoAndPlay()
189
+ +gotoAndStop()
190
+ +nextFrame()
191
+ +prevFrame()
192
+ }
193
+
194
+ class Shape {
195
+ +graphics: Graphics
196
+ }
197
+
198
+ class Stage {
199
+ +stageWidth: number
200
+ +stageHeight: number
201
+ +frameRate: number
202
+ +color: number
203
+ }
204
+
205
+ class TextField {
206
+ +text: string
207
+ +htmlText: string
208
+ +textColor: number
209
+ +autoSize: string
210
+ }
211
+
212
+ class Video {
213
+ +videoWidth: number
214
+ +videoHeight: number
215
+ }
216
+ ```
217
+
218
+ ## Graphics API / Graphics API
219
+
220
+ The Graphics class provides a drawing API for creating vector shapes programmatically.
221
+
222
+ Graphics クラスは、ベクター図形をプログラム的に作成するための描画 API を提供します。
223
+
224
+ ### Example Usage / 使用例
225
+
226
+ ```typescript
227
+ import { Sprite, BlendMode } from "@next2d/display";
228
+
229
+ // Create a sprite with graphics
230
+ // グラフィックスを持つスプライトを作成
231
+ const sprite = new Sprite();
232
+
233
+ // Draw a rectangle
234
+ // 矩形を描画
235
+ sprite.graphics.beginFill(0xFF0000);
236
+ sprite.graphics.drawRect(0, 0, 100, 100);
237
+ sprite.graphics.endFill();
238
+
239
+ // Draw a circle with gradient
240
+ // グラデーションを使った円を描画
241
+ sprite.graphics.beginGradientFill(
242
+ "radial",
243
+ [0xFF0000, 0x0000FF],
244
+ [1, 1],
245
+ [0, 255]
246
+ );
247
+ sprite.graphics.drawCircle(50, 50, 40);
248
+ sprite.graphics.endFill();
249
+ ```
250
+
251
+ ### Graphics Methods / Graphics メソッド
252
+
253
+ - **Line Styles / 線スタイル**
254
+ - `lineStyle()` - Set line style / 線スタイルを設定
255
+ - `lineGradientStyle()` - Set gradient line style / グラデーション線スタイルを設定
256
+
257
+ - **Fills / 塗り**
258
+ - `beginFill()` - Begin solid fill / 単色塗りを開始
259
+ - `beginGradientFill()` - Begin gradient fill / グラデーション塗りを開始
260
+ - `beginBitmapFill()` - Begin bitmap fill / ビットマップ塗りを開始
261
+ - `endFill()` - End current fill / 現在の塗りを終了
262
+
263
+ - **Drawing / 描画**
264
+ - `moveTo()` - Move drawing cursor / 描画カーソルを移動
265
+ - `lineTo()` - Draw line / 直線を描画
266
+ - `curveTo()` - Draw quadratic curve / 二次曲線を描画
267
+ - `cubicCurveTo()` - Draw cubic curve / 三次曲線を描画
268
+ - `drawRect()` - Draw rectangle / 矩形を描画
269
+ - `drawRoundRect()` - Draw rounded rectangle / 角丸矩形を描画
270
+ - `drawCircle()` - Draw circle / 円を描画
271
+ - `drawEllipse()` - Draw ellipse / 楕円を描画
272
+ - `clear()` - Clear all graphics / すべてのグラフィックスをクリア
273
+
274
+ ## MovieClip Frame Advance Logic / MovieClip フレーム進行ロジック
275
+
276
+ MovieClip implements timeline-based animation with frame labels, actions, and sounds.
277
+
278
+ MovieClip は、フレームラベル、アクション、サウンドを持つタイムラインベースのアニメーションを実装します。
279
+
280
+ ```mermaid
281
+ flowchart TD
282
+ Start([Start Frame Advance]) --> CheckStop{Stop Flag?}
283
+ CheckStop -->|Yes| End([End - No Advance])
284
+ CheckStop -->|No| CheckWait{Wait Flag?}
285
+ CheckWait -->|Yes| ClearWait[Clear Wait Flag]
286
+ CheckWait -->|No| AdvanceFrame[Increment Current Frame]
287
+
288
+ ClearWait --> ExecuteActions
289
+ AdvanceFrame --> CheckLoop{Current Frame > Total Frames?}
290
+
291
+ CheckLoop -->|Yes| LoopToStart[Current Frame = 1]
292
+ CheckLoop -->|No| ExecuteActions
293
+
294
+ LoopToStart --> ExecuteActions
295
+
296
+ ExecuteActions[Execute Frame Actions] --> PlaySounds[Play Frame Sounds]
297
+ PlaySounds --> UpdateChildren[Update Child Display Objects]
298
+ UpdateChildren --> CheckLabels{Has Frame Label?}
299
+
300
+ CheckLabels -->|Yes| SetLabel[Set Current Label]
301
+ CheckLabels -->|No| CheckStop2
302
+
303
+ SetLabel --> CheckStop2{Check Stop in Actions?}
304
+ CheckStop2 -->|Stop Called| SetStopFlag[Set Stop Flag]
305
+ CheckStop2 -->|Continue| End
306
+
307
+ SetStopFlag --> End
308
+
309
+ style Start fill:#e1f5ff
310
+ style End fill:#e1f5ff
311
+ style AdvanceFrame fill:#ffe1e1
312
+ style ExecuteActions fill:#fff4e1
313
+ style PlaySounds fill:#e1ffe1
314
+ ```
315
+
316
+ ### Frame Control Methods / フレーム制御メソッド
317
+
318
+ - `play()` - Start timeline playback / タイムライン再生を開始
319
+ - `stop()` - Stop timeline playback / タイムライン再生を停止
320
+ - `gotoAndPlay(frame)` - Jump to frame and play / フレームにジャンプして再生
321
+ - `gotoAndStop(frame)` - Jump to frame and stop / フレームにジャンプして停止
322
+ - `nextFrame()` - Advance to next frame / 次のフレームへ進む
323
+ - `prevFrame()` - Go back to previous frame / 前のフレームへ戻る
324
+
325
+ ### Timeline Properties / タイムラインプロパティ
326
+
327
+ - `currentFrame` - Current frame number (1-based) / 現在のフレーム番号(1始まり)
328
+ - `totalFrames` - Total number of frames / フレームの総数
329
+ - `currentLabel` - Current frame label / 現在のフレームラベル
330
+ - `currentLabels` - Array of all frame labels / すべてのフレームラベルの配列
331
+ - `isTimelineEnabled` - Whether timeline is enabled / タイムラインが有効かどうか
332
+
333
+ ## Loader / ローダー
334
+
335
+ The Loader class handles loading JSON files exported from Next2D AnimationTool only. It does not support loading images or other media files directly.
336
+
337
+ Loader クラスは、Next2D AnimationTool で書き出された JSON ファイルの読み込みのみに対応しています。画像やその他のメディアファイルの直接読み込みには対応していません。
338
+
339
+ **Important / 重要:**
340
+ - Only supports JSON files exported from Next2D AnimationTool / Next2D AnimationTool で書き出された JSON ファイルのみ対応
341
+ - Does not support loading images (PNG, JPG, etc.) directly / 画像(PNG、JPGなど)の直接読み込みには非対応
342
+ - Does not support loading videos directly / ビデオの直接読み込みには非対応
343
+
344
+ ```typescript
345
+ import { Loader } from "@next2d/display";
346
+ import { URLRequest } from "@next2d/net";
347
+
348
+ const loader = new Loader();
349
+ loader.contentLoaderInfo.addEventListener("complete", (event) => {
350
+ // JSON content loaded successfully
351
+ // JSONコンテンツの読み込みが成功
352
+ console.log("Loaded:", loader.content);
353
+ });
354
+
355
+ // Load Next2D AnimationTool exported JSON
356
+ // Next2D AnimationTool で書き出した JSON を読み込み
357
+ loader.load(new URLRequest("path/to/animation.json"));
358
+ ```
359
+
360
+ ## Architecture / アーキテクチャ
361
+
362
+ The package follows a clean architecture pattern with separation of concerns:
363
+
364
+ パッケージは、関心の分離を伴うクリーンアーキテクチャパターンに従っています:
365
+
366
+ - **Main Classes** - Public API and core logic / パブリック API とコアロジック
367
+ - **Service Layer** - Reusable business logic / 再利用可能なビジネスロジック
368
+ - **Use Case Layer** - Specific feature implementations / 特定の機能実装
369
+ - **Interface Layer** - TypeScript type definitions / TypeScript 型定義
370
+
371
+ This architecture ensures:
372
+ - Code reusability and maintainability / コードの再利用性と保守性
373
+ - Clear separation between public API and implementation / パブリック API と実装の明確な分離
374
+ - Testability of individual components / 個々のコンポーネントのテスト可能性
375
+
376
+ ## Related Packages / 関連パッケージ
377
+
378
+ - `@next2d/events` - Event system / イベントシステム
379
+ - `@next2d/geom` - Geometric primitives / 幾何プリミティブ
380
+ - `@next2d/filters` - Display filters / 表示フィルター
381
+ - `@next2d/text` - Text rendering / テキストレンダリング
382
+ - `@next2d/media` - Media playback / メディア再生
383
+ - `@next2d/net` - Network communication / ネットワーク通信
384
+ - `@next2d/ui` - User interface components / ユーザーインターフェースコンポーネント
385
+
386
+ ## License / ライセンス
387
+
11
388
  This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.
389
+
390
+ このプロジェクトは [MIT ライセンス](https://opensource.org/licenses/MIT)の下でライセンスされています - 詳細は [LICENSE](LICENSE) ファイルを参照してください。
391
+
392
+ ---
393
+
394
+ Copyright (c) 2021 Next2D
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/display",
3
- "version": "2.13.1",
3
+ "version": "3.0.0",
4
4
  "description": "Next2D Display Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -24,13 +24,13 @@
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
25
  },
26
26
  "dependencies": {
27
- "@next2d/ui": "2.13.1",
28
- "@next2d/text": "2.13.1",
29
- "@next2d/geom": "2.13.1",
30
- "@next2d/media": "2.13.1",
31
- "@next2d/net": "2.13.1",
32
- "@next2d/events": "2.13.1",
33
- "@next2d/filters": "2.13.1",
34
- "@next2d/render-queue": "2.13.1"
27
+ "@next2d/ui": "3.0.0",
28
+ "@next2d/text": "3.0.0",
29
+ "@next2d/geom": "3.0.0",
30
+ "@next2d/media": "3.0.0",
31
+ "@next2d/net": "3.0.0",
32
+ "@next2d/events": "3.0.0",
33
+ "@next2d/filters": "3.0.0",
34
+ "@next2d/render-queue": "3.0.0"
35
35
  }
36
36
  }
@@ -31,7 +31,7 @@ export declare class BitmapData {
31
31
  height: number;
32
32
  /**
33
33
  * @type {Uint8Array | null}
34
- * @private
34
+ * @public
35
35
  */
36
36
  buffer: Uint8Array | null;
37
37
  /**
package/src/BitmapData.js CHANGED
@@ -50,7 +50,7 @@ export class BitmapData {
50
50
  });
51
51
  /**
52
52
  * @type {Uint8Array | null}
53
- * @private
53
+ * @public
54
54
  */
55
55
  Object.defineProperty(this, "buffer", {
56
56
  enumerable: true,
@@ -58,23 +58,8 @@ export class BitmapData {
58
58
  writable: true,
59
59
  value: void 0
60
60
  });
61
- /**
62
- * @type {number}
63
- * @default 0
64
- * @private
65
- */
66
61
  this.width = width | 0;
67
- /**
68
- * @type {number}
69
- * @default 0
70
- * @private
71
- */
72
62
  this.height = height | 0;
73
- /**
74
- * @type {Uint8Array}
75
- * @default null
76
- * @private
77
- */
78
63
  this.buffer = null;
79
64
  }
80
65
  /**
@@ -9,8 +9,9 @@
9
9
  */
10
10
  export const execute = (display_object) => {
11
11
  display_object.changed = true;
12
- const parent = display_object.parent;
13
- if (parent && !parent.changed) {
14
- execute(parent);
12
+ let parent = display_object.parent;
13
+ while (parent && !parent.changed) {
14
+ parent.changed = true;
15
+ parent = parent.parent;
15
16
  }
16
17
  };
@@ -8,17 +8,63 @@
8
8
  * @protected
9
9
  */
10
10
  export const execute = (buffer) => {
11
+ // Float32ArrayのバッファをUint32Arrayとして直接参照(DataView不要)
12
+ const bits = new Uint32Array(buffer.buffer, buffer.byteOffset, buffer.length);
13
+ const len = bits.length;
11
14
  let hash = 2166136261; // FNV-1aオフセット basis
12
- for (let idx = 0; idx < buffer.length; ++idx) {
13
- let num = buffer[idx] | 0; // 整数として扱う
14
- // 32bit整数の各バイトを処理
15
- for (let i = 0; i < 4; i++) {
16
- const byte = num & 0xff;
17
- hash ^= byte;
18
- hash = Math.imul(hash, 16777619); // FNV-1a FNV prime
19
- num >>>= 8;
20
- }
15
+ let idx = 0;
16
+ // 8要素ずつ処理(ループアンローリング)
17
+ const unrolledEnd = len & ~7; // len - (len % 8)
18
+ while (idx < unrolledEnd) {
19
+ let b = bits[idx++];
20
+ hash = Math.imul(hash ^ b & 0xff, 16777619);
21
+ hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
22
+ hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
23
+ hash = Math.imul(hash ^ b >>> 24, 16777619);
24
+ b = bits[idx++];
25
+ hash = Math.imul(hash ^ b & 0xff, 16777619);
26
+ hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
27
+ hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
28
+ hash = Math.imul(hash ^ b >>> 24, 16777619);
29
+ b = bits[idx++];
30
+ hash = Math.imul(hash ^ b & 0xff, 16777619);
31
+ hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
32
+ hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
33
+ hash = Math.imul(hash ^ b >>> 24, 16777619);
34
+ b = bits[idx++];
35
+ hash = Math.imul(hash ^ b & 0xff, 16777619);
36
+ hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
37
+ hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
38
+ hash = Math.imul(hash ^ b >>> 24, 16777619);
39
+ b = bits[idx++];
40
+ hash = Math.imul(hash ^ b & 0xff, 16777619);
41
+ hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
42
+ hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
43
+ hash = Math.imul(hash ^ b >>> 24, 16777619);
44
+ b = bits[idx++];
45
+ hash = Math.imul(hash ^ b & 0xff, 16777619);
46
+ hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
47
+ hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
48
+ hash = Math.imul(hash ^ b >>> 24, 16777619);
49
+ b = bits[idx++];
50
+ hash = Math.imul(hash ^ b & 0xff, 16777619);
51
+ hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
52
+ hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
53
+ hash = Math.imul(hash ^ b >>> 24, 16777619);
54
+ b = bits[idx++];
55
+ hash = Math.imul(hash ^ b & 0xff, 16777619);
56
+ hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
57
+ hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
58
+ hash = Math.imul(hash ^ b >>> 24, 16777619);
21
59
  }
22
- // 32bitの符号なし整数にキャストし、24bitの範囲に収める
23
- return (hash >>> 0) % 16777216;
60
+ // 残り (0〜7要素)
61
+ while (idx < len) {
62
+ const b = bits[idx++];
63
+ hash = Math.imul(hash ^ b & 0xff, 16777619);
64
+ hash = Math.imul(hash ^ b >> 8 & 0xff, 16777619);
65
+ hash = Math.imul(hash ^ b >> 16 & 0xff, 16777619);
66
+ hash = Math.imul(hash ^ b >>> 24, 16777619);
67
+ }
68
+ // 32bitハッシュ値を24bitに圧縮
69
+ return hash >>> 8 ^ hash & 0xff & 0xffffff;
24
70
  };
@@ -834,10 +834,11 @@ export class DisplayObject extends EventDispatcher {
834
834
  return this._$visible;
835
835
  }
836
836
  set visible(visible) {
837
+ visible = !!visible;
837
838
  if (this._$visible === visible) {
838
839
  return;
839
840
  }
840
- this._$visible = !!visible;
841
+ this._$visible = visible;
841
842
  displayObjectApplyChangesService(this);
842
843
  }
843
844
  /**