next2d-development-mcp 1.2.0 → 1.4.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.
@@ -1286,6 +1286,69 @@ export class TopBtnMolecule extends ButtonAtom {
1286
1286
  }
1287
1287
  ```
1288
1288
 
1289
+ ### 親 Sprite コンテナの 0,0 中心設計(アニメーション推奨パターン)
1290
+
1291
+ アニメーション用の親 Sprite コンテナは、**0,0 を視覚的コンテンツの中心点に設計する**のが推奨。
1292
+ `rotation` / `scaleX` / `scaleY` はすべて 0,0 を軸に動くため、0,0 が左上だと回転・拡縮が視覚的にズレる。
1293
+
1294
+ ```
1295
+ 0,0(中心点)
1296
+ |
1297
+ ------+------
1298
+ | |
1299
+ | content |
1300
+ | |
1301
+ -------------
1302
+ (-w/2, -h/2) (w/2, -h/2)
1303
+ ```
1304
+
1305
+ #### NG: 0,0 が左上になるパターン(頻出バグ)
1306
+
1307
+ ```typescript
1308
+ // NG: container の 0,0 が左上 → rotation/scale が左上を基点に動く
1309
+ const container = new Sprite();
1310
+ container.x = stageWidth / 2 - contentWidth / 2; // 左上基準で中央に配置しようとする
1311
+ container.y = stageHeight / 2 - contentHeight / 2;
1312
+
1313
+ const child = new YourContent();
1314
+ container.addChild(child); // child の左上が container の 0,0 に来る
1315
+ // → rotation アニメーションが左上を軸に回転してしまう
1316
+ ```
1317
+
1318
+ #### OK: 0,0 が中心点になるパターン(推奨)
1319
+
1320
+ ```typescript
1321
+ // OK: container の 0,0 = 視覚的中心点 → rotation/scale が中心を基点に動く
1322
+ const container = new Sprite();
1323
+ container.x = stageWidth / 2; // 中心座標を設定
1324
+ container.y = stageHeight / 2;
1325
+
1326
+ const child = new YourContent();
1327
+ // child のサイズ確定後にオフセットを計算
1328
+ child.x = -child.width / 2;
1329
+ child.y = -child.height / 2;
1330
+ container.addChild(child);
1331
+ // → rotation / scaleX / scaleY アニメーションが中心を基点に自然に動く
1332
+ ```
1333
+
1334
+ 複数の子オブジェクトを持つ場合も同様に、全ての child を中心基準でオフセット配置する:
1335
+
1336
+ ```typescript
1337
+ const container = new Sprite();
1338
+ container.x = stageWidth / 2;
1339
+ container.y = stageHeight / 2;
1340
+
1341
+ for (const item of items) {
1342
+ const child = new ItemAtom(item);
1343
+ // 各 child も中心基準でオフセット
1344
+ child.x = -child.width / 2;
1345
+ child.y = -child.height / 2 + indexOffset; // 縦並びなどのレイアウト調整
1346
+ container.addChild(child);
1347
+ }
1348
+ ```
1349
+
1350
+ ---
1351
+
1289
1352
  ### DisplayObject の中心点基準配置(scale・rotation アニメーション必須)
1290
1353
 
1291
1354
  `scaleX` / `scaleY` / `rotation` を変更すると `width` / `height` の値が変わる。
@@ -241,6 +241,7 @@ DisplayObjectは、Next2D Playerにおける全ての表示オブジェクトの
241
241
  | `mouseX` | number | 対象のDisplayObjectの基準点からのマウスのX座標(ピクセル) |
242
242
  | `mouseY` | number | 対象のDisplayObjectの基準点からのマウスのY座標(ピクセル) |
243
243
  | `root` | MovieClip \| Sprite \| null | DisplayObjectのルートであるDisplayObjectContainer |
244
+ | `namespace` | string | クラスの空間名(例: `"next2d.display.Sprite"`)を返却。クラス判定に使用する(詳細は[クラス判定](#クラス判定namespace)を参照) |
244
245
 
245
246
  ### 読み書きプロパティ
246
247
 
@@ -480,6 +481,45 @@ sprite.cacheAsBitmap = null;
480
481
  - `stage.rendererScale`が変更されるとキャッシュが自動的に無効化されます
481
482
  - `filter`と`cacheAsBitmap`を同時に設定した場合、`cacheAsBitmap`が優先されます
482
483
 
484
+ ## クラス判定(namespace)
485
+
486
+ クラスの種類を判定する際に `constructor.name` を使用してはいけません。プロダクションビルドでは minify によってクラス名が短縮・変更されるため、開発環境では動作してもビルド後に判定が壊れます。
487
+
488
+ 代わりに `namespace` プロパティを使用します。`namespace` はハードコードされた文字列(例: `"next2d.display.Stage"`)を返すため、minify の影響を受けません。インスタンスの getter と static getter の両方が用意されています。
489
+
490
+ ```typescript
491
+ const { Stage, Sprite } = next2d.display;
492
+
493
+ // ❌ NG: minify でクラス名が変わるため、ビルド後に判定が壊れる
494
+ if (displayObject.constructor.name === "Stage") { /* ... */ }
495
+
496
+ // ✅ OK: インスタンスの namespace で判定
497
+ if (displayObject.namespace === "next2d.display.Stage") { /* ... */ }
498
+
499
+ // ✅ OK: static の namespace と比較するとタイポも防げる
500
+ if (displayObject.namespace === Stage.namespace) { /* ... */ }
501
+
502
+ // ✅ OK: Sprite かどうかの判定
503
+ if (displayObject.namespace === Sprite.namespace) { /* ... */ }
504
+
505
+ // ✅ OK: Stage 判定は isStage フラグも使用可能(Stage のみが持つ readonly プロパティ)
506
+ if (displayObject.isStage) { /* ... */ }
507
+ ```
508
+
509
+ **namespace を持つ主なクラス:**
510
+
511
+ | クラス | namespace の値 |
512
+ |--------|----------------|
513
+ | `Stage` | `"next2d.display.Stage"` |
514
+ | `Sprite` | `"next2d.display.Sprite"` |
515
+ | `MovieClip` | `"next2d.display.MovieClip"` |
516
+ | `Shape` | `"next2d.display.Shape"` |
517
+ | `Loader` | `"next2d.display.Loader"` |
518
+ | `TextField` | `"next2d.display.TextField"` |
519
+ | `Video` | `"next2d.media.Video"` |
520
+
521
+ **補足:** 継承を含めた機能判定(「Sprite の機能を持っているか」など)には `isStage` / `isSprite` / `isShape` / `isText` / `isVideo` / `isContainerEnabled` / `isTimelineEnabled` の各フラグを使用します。`namespace` は完全一致のクラス判定に使用します。
522
+
483
523
  ## 関連項目
484
524
 
485
525
  - [MovieClip](/ja/reference/player/movie-clip)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "next2d-development-mcp",
3
3
  "displayName": "Next2D Development MCP",
4
- "version": "1.2.0",
4
+ "version": "1.4.0",
5
5
  "description": "MCP server for Next2D application development assistance",
6
6
  "type": "module",
7
7
  "author": "Toshiyuki Ienaga <ienaga@next2d.app>",
@@ -52,12 +52,12 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@eslint/js": "^10.0.1",
55
- "@types/node": "^25.9.1",
55
+ "@types/node": "^25.9.3",
56
56
  "@types/vscode": "^1.120.0",
57
- "@typescript-eslint/eslint-plugin": "^8.60.1",
58
- "@typescript-eslint/parser": "^8.60.1",
59
- "@vscode/vsce": "^3.9.1",
60
- "eslint": "^10.4.1",
57
+ "@typescript-eslint/eslint-plugin": "^8.61.0",
58
+ "@typescript-eslint/parser": "^8.61.0",
59
+ "@vscode/vsce": "^3.9.2",
60
+ "eslint": "^10.5.0",
61
61
  "eslint-plugin-unused-imports": "^4.4.1",
62
62
  "globals": "^17.6.0",
63
63
  "typescript": "^6.0.3",