Repository navigation
Feat/trajectory simplify - #10
Merged
Merged
Conversation
- 字体数据加载拆分为 loadFontFromPath / loadFontFromUrl - SimulationOptions.fontPath 改为 font,支持路径、URL 与 Buffer/ArrayBuffer - node 模块改为按需动态加载
- web 端直接调用 gensvg,支持上传字体文件或填写字体 URL - 配置面板移到左侧,预览在右侧,播放条置底 - 默认不自动播放,拖动进度条时暂停 - 修复 SVG 图标 hidden 属性失效导致播放/暂停图标同时显示 - 新增 build:web 静态打包与 Pages 部署工作流 - gensvg 内联 SVG 渲染,贡献数据模块改名并同步测试 mock
- CI 徽章改指向本仓库,不再引用模板仓库 - 新增「在线预览 / Live Preview」章节,引导到 Pages 演示站 - font-path 说明补充支持 http(s) URL - 打包说明区分 Action 产物与网页版静态构建
- main.test.ts 改用 spyOn 替换 gensvg,避免全局 mock.module 泄漏到 integration 测试 - check-dist.yml 去掉 setup-node 的 npm 缓存(仓库只有 bun.lock),依赖改用 bun ci 安装
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
把轨迹采样式压缩换成基于容差的轨迹压缩,并新增一个完全在浏览器里运行的在线预览页面(打包后部署到 GitHub Pages)。同时重构字体加载,使字体可以从本地路径、URL 或内存中的二进制数据加载,为浏览器端复用同一套渲染逻辑铺路。
主要改动
轨迹压缩
sample-rate输入移除,改为两个更可控的参数:compression-tolerance(默认0.5):播放时任一原始时刻的插值位置与真实位置的偏差上限(SVG 像素),0为无损。compression-algorithm(默认Greedy):可选Greedy/DP/RDP。src/utils/simplifyTrajectory.ts,三种算法都通过keyTimes保留每个关键帧的原始时间,反弹、落地、停顿等速度变化按真实节奏播放。scripts/compare.ts(bun run compare)用于对比三种算法的关键帧数量、压缩率与耗时。浏览器端生成与在线预览
src/web改为直接调用gensvg,不再依赖/svg接口在服务端出图;src/app.ts只负责托管页面,原有的/svg路由保留。hidden属性不作用于 SVG 元素)。build:web把页面打成静态资源(dist-web/),产出使用相对路径,可直接部署到项目子路径下。.github/workflows/pages.yml,在src/**、public/**、package.json、bun.lock变更时构建并部署到 GitHub Pages。自定义字体
SimulationOptions.fontPath改为font,支持本地路径、http(s)URL、Buffer/ArrayBuffer(例如files[0].arrayBuffer())。loadFontFromPath/loadFontFromUrl两个方法,getTextPaths改为异步。node:fs/node:path/node:url改为按需动态导入,浏览器打包不会引入 Node 模块。工程与发布
2.0.0;dist/已重新打包。__tests__下的main、parseTextPath、simplify用例;integration.test.ts适配新的压缩与字体行为。font-path支持 URL 的说明,并把打包说明区分为 Action 产物与网页版静态构建。破坏性变更
sample-rate输入移除compression-tolerance/compression-algorithmSimulationOptions.fontPath→fontfont,类型放宽为路径、URL 或二进制数据getTextPaths改为异步await1.0.0→2.0.0@v1的用户不受影响@v2提供测试
bun test:71 个用例全部通过。bun biome check .:无告警。部署须知
pages.yml使用官方 Pages 部署流程,仓库需要在 Settings → Pages → Source 选择 GitHub Actions,否则 deploy job 会在configure-pages阶段失败。部署完成后地址为https://flycran.github.io/github-gravity/。