modern-canvas 0.24.13 → 0.25.1
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/core/index.d.ts +1 -0
- package/dist/core/reactivity.d.ts +1 -0
- package/dist/index.js +500 -498
- package/dist/render.d.ts +3 -0
- package/dist/scene/2d/element/Element2DFill.d.ts +4 -4
- package/dist/scene/2d/element/imagePipeline.d.ts +5 -6
- package/dist/scene/main/SceneTree.d.ts +7 -0
- package/package.json +2 -2
package/dist/render.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Fonts } from 'modern-font';
|
|
2
2
|
import type { EngineData, EngineProperties } from './Engine';
|
|
3
|
+
import type { ImagePipelineResolver } from './scene/2d/element/imagePipeline';
|
|
3
4
|
import { Engine } from './Engine';
|
|
4
5
|
export interface RenderOptions extends Partial<EngineProperties> {
|
|
5
6
|
data: EngineData;
|
|
@@ -8,6 +9,8 @@ export interface RenderOptions extends Partial<EngineProperties> {
|
|
|
8
9
|
debug?: boolean;
|
|
9
10
|
fonts?: Fonts;
|
|
10
11
|
keyframes?: number[];
|
|
12
|
+
/** 图片处理管线解析器:设到渲染引擎实例,使带 imagePipelines 的图片填充在渲染时烘焙。 */
|
|
13
|
+
imagePipelineResolver?: ImagePipelineResolver;
|
|
11
14
|
onBefore?: (engine: Engine) => void | Promise<void>;
|
|
12
15
|
onKeyframe?: (frame: Uint8ClampedArray<ArrayBuffer>, ctx: {
|
|
13
16
|
currentTime: number;
|
|
@@ -19,7 +19,7 @@ export declare class Element2DFill extends CoreObject implements NormalizedFill
|
|
|
19
19
|
tile?: NormalizedFill['tile'];
|
|
20
20
|
opacity?: NormalizedFill['opacity'];
|
|
21
21
|
/** 图片处理管线;图片加载后交由注入的解析器烘焙到运行时纹理,不持久化 */
|
|
22
|
-
|
|
22
|
+
imagePipelines?: NormalizedFill['imagePipelines'];
|
|
23
23
|
texture?: Texture2D;
|
|
24
24
|
animatedTexture?: AnimatedTexture;
|
|
25
25
|
constructor(_parent: Element2D);
|
|
@@ -28,12 +28,12 @@ export declare class Element2DFill extends CoreObject implements NormalizedFill
|
|
|
28
28
|
protected _updateProperty(key: string, value: any, oldValue: any): void;
|
|
29
29
|
loadTexture(): Promise<void>;
|
|
30
30
|
/**
|
|
31
|
-
* 把原图经 `
|
|
31
|
+
* 把原图经 `imagePipelines` 烘焙成一张运行时纹理(无管线 / 无解析器 / gif 时跳过)。
|
|
32
32
|
* 始终从 image 独立解码像素喂给管线,不读 `this.texture.source`(那张 ImageBitmap
|
|
33
33
|
* 由纹理管线持有、会经 premultiply 上传/GC 而被消费)。结果按 `url + 管线` 缓存复用。
|
|
34
34
|
*/
|
|
35
|
-
protected
|
|
36
|
-
protected
|
|
35
|
+
protected _applyImagePipelines(url: string): Promise<void>;
|
|
36
|
+
protected _imagePipelineKey(imagePipelines: NonNullable<NormalizedFill['imagePipelines']>): string;
|
|
37
37
|
/** 从 image 独立解码为中立像素结构(不读 GPU 纹理 source) */
|
|
38
38
|
protected _decodePipelineSource(url: string): Promise<PipelineImage | undefined>;
|
|
39
39
|
protected _pipelineImageToCanvas(image: PipelineImage): HTMLCanvasElement | undefined;
|
|
@@ -2,10 +2,9 @@ import type { ImagePipeline, PipelineImage } from 'modern-idoc';
|
|
|
2
2
|
/**
|
|
3
3
|
* 图片处理管线解析器:给定管线步骤与原图像素,返回处理后的像素。
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* 引擎本身不认识任何具名管线,图片填充加载时把 `imagePipelines + 像素` 交给解析器烘焙。
|
|
6
|
+
* 解析器挂在引擎实例上(`SceneTree.imagePipelineResolver`,Engine 继承),由宿主
|
|
7
|
+
* 按实例注入——不走全局,多引擎实例互不影响。
|
|
8
|
+
* 返回 `undefined` 表示放弃处理、沿用原图。
|
|
8
9
|
*/
|
|
9
|
-
export type ImagePipelineResolver = (
|
|
10
|
-
export declare function setImagePipelineResolver(resolver: ImagePipelineResolver | undefined): void;
|
|
11
|
-
export declare function getImagePipelineResolver(): ImagePipelineResolver | undefined;
|
|
10
|
+
export type ImagePipelineResolver = (imagePipelines: ImagePipeline[], image: PipelineImage) => Promise<PipelineImage | undefined>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Fonts } from 'modern-font';
|
|
2
2
|
import type { Hex8Color } from 'modern-idoc';
|
|
3
|
+
import type { ImagePipelineResolver } from '../2d/element/imagePipeline';
|
|
3
4
|
import type { InputEvents, MainLoopEvents, MainLoopProperties, WebGLRenderer } from '../../core';
|
|
4
5
|
import type { Node } from './Node';
|
|
5
6
|
import type { Viewport } from './Viewport';
|
|
@@ -45,6 +46,12 @@ export declare class SceneTree extends MainLoop {
|
|
|
45
46
|
readonly renderStack: RenderStack;
|
|
46
47
|
readonly root: Window;
|
|
47
48
|
timeline: Timeline;
|
|
49
|
+
/**
|
|
50
|
+
* 图片处理管线解析器(实例级,非全局)。图片填充带 `imagePipelines` 时,
|
|
51
|
+
* 子节点经 `this.tree?.imagePipelineResolver` 取用,把图片烘焙到运行时纹理。
|
|
52
|
+
* 由宿主按引擎实例注入;未注入则不处理、沿用原图。
|
|
53
|
+
*/
|
|
54
|
+
imagePipelineResolver?: ImagePipelineResolver;
|
|
48
55
|
readonly nodeMap: Map<string, Node>;
|
|
49
56
|
/** 已订阅 load 事件的 fonts 实例,用于在 fonts 切换 / 销毁时解绑。 */
|
|
50
57
|
protected _boundFonts?: Fonts;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-canvas",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.25.1",
|
|
5
5
|
"packageManager": "pnpm@10.19.0",
|
|
6
6
|
"description": "A JavaScript WebGL rendering engine. only the ESM.",
|
|
7
7
|
"author": "wxm",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"colord": "^2.9.3",
|
|
64
64
|
"earcut": "^3.0.2",
|
|
65
65
|
"modern-font": "^0.6.1",
|
|
66
|
-
"modern-idoc": "^0.12.
|
|
66
|
+
"modern-idoc": "^0.12.3",
|
|
67
67
|
"modern-path2d": "^1.8.5",
|
|
68
68
|
"modern-text": "^2.0.9"
|
|
69
69
|
},
|