Conversation
There was a problem hiding this comment.
Pull request overview
マルチ言語(ja/en/cn)の仕様ドキュメントと各パッケージREADMEを更新し、Next2D Player の最新API(PointerEvent / Tween(Job) / WebGPU 等)に合わせた記述へ整備するPRです。あわせてルートのバージョンを 3.0.1 に更新しています。
Changes:
- クリック/マウス系の例を PointerEvent 定数(POINTER_DOWN/UP 等)ベースの例へ更新
- Tweenドキュメントを
Tween.add()とJob中心の記述へ刷新し、Easing一覧も現行命名に追従 - WebGPU/Filters/Display/ルートREADMEや開発ドキュメント(依存関係ルール)を更新、package.json を 3.0.1 に更新
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| specs/ja/video.md | Video例をPointerEvent/VideoEvent(events側)に合わせて更新 |
| specs/ja/tween.md | Tween.add()/Job中心へ刷新、Easing命名更新 |
| specs/ja/sprite.md | ボタン/ドラッグ例をPointerEventへ更新 |
| specs/ja/shape.md | Bitmap Fill例をShape.load()/bitmapData利用へ更新 |
| specs/ja/movie-clip.md | 再生トグル例をPointerEventへ更新 |
| specs/ja/events.md | DOM風3フェーズ記述、Pointer/Keyboard等の定数表を拡充 |
| specs/en/video.md | TypeScript化+PointerEvent/VideoEvent例の追加・整理 |
| specs/en/tween.md | Tween.add()/Job中心へ刷新、Easing説明を拡充 |
| specs/en/sprite.md | 例をTypeScript化+PointerEventへ更新 |
| specs/en/shape.md | Bitmap Fill例をShape.load()/bitmapData利用へ更新 |
| specs/en/movie-clip.md | 例をTypeScript化+PointerEventへ更新 |
| specs/en/events.md | DOM風3フェーズ記述、Pointer/Keyboard等の定数表を拡充 |
| specs/cn/video.md | TypeScript化+PointerEvent/VideoEvent例の追加・整理 |
| specs/cn/tween.md | Tween.add()/Job中心へ刷新、Easing説明を拡充 |
| specs/cn/sprite.md | 例をTypeScript化+PointerEventへ更新 |
| specs/cn/shape.md | Bitmap Fill例をShape.load()/bitmapData利用へ更新 |
| specs/cn/movie-clip.md | 例をTypeScript化+PointerEventへ更新 |
| specs/cn/events.md | DOM风3阶段记述、Pointer/Keyboard等常量表扩充 |
| packages/webgpu/README.md | WebGPUバックエンドREADMEを再構成(概要/構成/パイプライン等) |
| packages/filters/README.md | WebGL/WebGPU両対応の記述に更新 |
| packages/display/README.md | TextField/Videoの所在整理(text/media側に含む旨を明確化) |
| package.json | バージョンを 3.0.1 に更新 |
| README.md | ルートREADMEのWebGL→WebGL/WebGPU記述更新 |
| DEVELOP.md | rendererがimport可能なbackendにwebgpuを追加 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| | `enterFrame` | 每个动画帧触发 | | ||
| | `complete` | 动画完成时触发 | |
There was a problem hiding this comment.
Job 事件表中写了 enterFrame / complete,但 @next2d/events 的 JobEvent 目前只提供 UPDATE("jobupdate")和 STOP("jobstop")等作业事件类型。请将此表更新为实际可订阅的事件。
| | `enterFrame` | 每个动画帧触发 | | |
| | `complete` | 动画完成时触发 | | |
| | `jobupdate` | 每次作业更新时触发(通常为每帧) | | |
| | `jobstop` | 作业停止时触发(包括正常结束或手动停止) | |
| ```typescript | ||
| const { Loader } = next2d.display; | ||
| const { URLRequest } = next2d.net; | ||
|
|
||
| const loader = new Loader(); | ||
|
|
||
| loader.contentLoaderInfo.addEventListener("complete", function(event) { | ||
| const content = event.currentTarget.content; | ||
| stage.addChild(content); | ||
| }); | ||
| // Loading with async/await | ||
| await loader.load(new URLRequest("animation.json")); | ||
| const content = loader.content; | ||
| stage.addChild(content); | ||
|
|
||
| loader.contentLoaderInfo.addEventListener("progress", function(event) { | ||
| // Using progress events | ||
| loader.contentLoaderInfo.addEventListener("progress", (event) => { | ||
| const percent = (event.bytesLoaded / event.bytesTotal) * 100; | ||
| console.log(percent + "% loaded"); | ||
| console.log(`${percent}% loaded`); | ||
| }); |
There was a problem hiding this comment.
In this sample, await loader.load(...) completes before the progress listener is attached, so no progress events can be observed. Either register progress before calling load(), or split this into two separate examples (async/await vs progress events).
| ```typescript | ||
| const { Loader } = next2d.display; | ||
| const { URLRequest } = next2d.net; | ||
|
|
||
| const loader = new Loader(); | ||
|
|
||
| loader.contentLoaderInfo.addEventListener("complete", function(event) { | ||
| const content = event.currentTarget.content; | ||
| stage.addChild(content); | ||
| }); | ||
| // 使用 async/await 加载 | ||
| await loader.load(new URLRequest("animation.json")); | ||
| const content = loader.content; | ||
| stage.addChild(content); | ||
|
|
||
| loader.contentLoaderInfo.addEventListener("progress", function(event) { | ||
| // 使用进度事件 | ||
| loader.contentLoaderInfo.addEventListener("progress", (event) => { | ||
| const percent = (event.bytesLoaded / event.bytesTotal) * 100; | ||
| console.log(percent + "% 已加载"); | ||
| console.log(`${percent}% 已加载`); | ||
| }); |
There was a problem hiding this comment.
该示例中先 await loader.load(...),随后才注册 progress 监听器,因此无法收到进度事件。请在调用 load() 前先注册监听器,或将 async/await 示例与 progress 示例拆分为两个独立示例。
| ```typescript | ||
| const { Video } = next2d.media; | ||
|
|
||
| const video = new Video(640, 360); | ||
| video.src = "video.mp4"; | ||
| video.volume = 0.5; // 50% | ||
| stage.addChild(video); | ||
|
|
||
| // Volume slider | ||
| volumeSlider.addEventListener("change", function(event) { | ||
| video.volume = event.target.value; // 0.0 ~ 1.0 | ||
| }); | ||
| stage.addChild(video); | ||
|
|
||
| // Mute toggle | ||
| let isMuted = false; | ||
| let previousVolume = 0.5; | ||
|
|
||
| muteButton.addEventListener("click", function() { | ||
| isMuted = !isMuted; | ||
| if (isMuted) { | ||
| previousVolume = video.volume; | ||
| video.volume = 0; | ||
| } else { | ||
| video.volume = previousVolume; | ||
| } | ||
| muteButton.addEventListener(PointerEvent.POINTER_DOWN, () => { | ||
| video.muted = !video.muted; | ||
| }); |
There was a problem hiding this comment.
This code block uses PointerEvent.POINTER_DOWN, but PointerEvent is never imported in the block. Add const { PointerEvent } = next2d.events; (or avoid the constant) so the snippet is self-contained TypeScript.
| ```typescript | ||
| const { Video } = next2d.media; | ||
|
|
||
| const video = new Video(640, 360); | ||
| video.src = "video.mp4"; | ||
| video.volume = 0.5; // 50% | ||
| stage.addChild(video); | ||
|
|
||
| // 音量滑块 | ||
| volumeSlider.addEventListener("change", function(event) { | ||
| video.volume = event.target.value; // 0.0 ~ 1.0 | ||
| }); | ||
| stage.addChild(video); | ||
|
|
||
| // 静音切换 | ||
| let isMuted = false; | ||
| let previousVolume = 0.5; | ||
|
|
||
| muteButton.addEventListener("click", function() { | ||
| isMuted = !isMuted; | ||
| if (isMuted) { | ||
| previousVolume = video.volume; | ||
| video.volume = 0; | ||
| } else { | ||
| video.volume = previousVolume; | ||
| } | ||
| muteButton.addEventListener(PointerEvent.POINTER_DOWN, () => { | ||
| video.muted = !video.muted; | ||
| }); |
There was a problem hiding this comment.
该代码块里使用了 PointerEvent.POINTER_DOWN,但没有在同一代码块中引入 PointerEvent。请补充 const { PointerEvent } = next2d.events;,确保示例可直接运行。
| // Per-frame processing | ||
| job.addEventListener("enterFrame", (event) => { | ||
| console.log("Progress:", job.currentTime); | ||
| }); | ||
|
|
||
| setTimeout(shake, 50); | ||
| } | ||
| // On completion | ||
| job.addEventListener("complete", (event) => { | ||
| console.log("Animation complete!"); | ||
| }); |
There was a problem hiding this comment.
This example listens to "enterFrame" and "complete", but Job dispatches job-specific events via JobEvent (e.g., JobEvent.UPDATE, JobEvent.STOP). As written, the snippet won't fire. Please import JobEvent and use those constants (or document the correct emitted event names).
| ```javascript | ||
| const { Sprite } = next2d.display; | ||
| ```typescript | ||
| const { Tween, Easing } = next2d.ui; |
There was a problem hiding this comment.
This example uses new Sprite() but no longer imports Sprite (the snippet only imports Tween/Easing). Add const { Sprite } = next2d.display; (or otherwise define Sprite) so the sample is runnable.
| const { Tween, Easing } = next2d.ui; | |
| const { Tween, Easing } = next2d.ui; | |
| const { Sprite } = next2d.display; |
| ```javascript | ||
| const { Sprite } = next2d.display; | ||
| ```typescript | ||
| const { Tween, Easing } = next2d.ui; |
There was a problem hiding this comment.
该示例中使用了 new Sprite(),但代码块里已不再引入 Sprite(只引入了 Tween/Easing)。请补充 const { Sprite } = next2d.display;(或其他方式定义 Sprite),保证示例可直接运行。
| const { Tween, Easing } = next2d.ui; | |
| const { Tween, Easing } = next2d.ui; | |
| const { Sprite } = next2d.display; |
| ```typescript | ||
| const { Tween, Easing } = next2d.ui; | ||
|
|
||
| const cy = 3 * y1; | ||
| const by = 3 * (y2 - y1) - cy; | ||
| const ay = 1 - cy - by; | ||
| const job = Tween.add( | ||
| sprite, | ||
| { x: 0 }, | ||
| { x: 400 }, | ||
| 0, 2, | ||
| Easing.linear | ||
| ); | ||
|
|
||
| function sampleCurveY(t) { | ||
| return ((ay * t + by) * t + cy) * t; | ||
| } | ||
| job.start(); | ||
|
|
||
| return sampleCurveY(t); | ||
| }; | ||
| } | ||
|
|
||
| // CSS cubic-bezier equivalent | ||
| const customEase = bezierEasing(0.25, 0.1, 0.25, 1.0); | ||
| // Stop midway | ||
| stopButton.addEventListener(PointerEvent.POINTER_DOWN, () => { | ||
| job.stop(); | ||
| }); |
There was a problem hiding this comment.
This snippet uses PointerEvent.POINTER_DOWN, but PointerEvent is not imported in the code block. Add const { PointerEvent } = next2d.events; so the example compiles as TypeScript.
| ```typescript | ||
| const { Tween, Easing } = next2d.ui; | ||
|
|
||
| const cy = 3 * y1; | ||
| const by = 3 * (y2 - y1) - cy; | ||
| const ay = 1 - cy - by; | ||
| const job = Tween.add( | ||
| sprite, | ||
| { x: 0 }, | ||
| { x: 400 }, | ||
| 0, 2, | ||
| Easing.linear | ||
| ); | ||
|
|
||
| function sampleCurveY(t) { | ||
| return ((ay * t + by) * t + cy) * t; | ||
| } | ||
| job.start(); | ||
|
|
||
| return sampleCurveY(t); | ||
| }; | ||
| } | ||
|
|
||
| // CSS cubic-bezier 等效 | ||
| const customEase = bezierEasing(0.25, 0.1, 0.25, 1.0); | ||
| // 中途停止 | ||
| stopButton.addEventListener(PointerEvent.POINTER_DOWN, () => { | ||
| job.stop(); | ||
| }); |
There was a problem hiding this comment.
该示例里使用了 PointerEvent.POINTER_DOWN,但代码块中未引入 PointerEvent。请补充 const { PointerEvent } = next2d.events; 以保证 TypeScript 示例可直接编译运行。
No description provided.