@galacean/effects-core 2.0.0-alpha.6 → 2.0.0-alpha.8

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.
@@ -1,5 +1,5 @@
1
1
  import type { Matrix3, Matrix4, Quaternion, Vector2, Vector3, Vector4 } from '@galacean/effects-math/es/core/index';
2
- import type { GlobalUniforms, Renderer, ShaderWithSource } from '../render';
2
+ import type { GlobalUniforms, Renderer, Shader, ShaderWithSource } from '../render';
3
3
  import type { Texture } from '../texture';
4
4
  import type { DestroyOptions, Disposable } from '../utils';
5
5
  import type { UniformSemantic, UniformValue } from './types';
@@ -55,7 +55,9 @@ export interface MaterialProps {
55
55
  * Material 抽象类
56
56
  */
57
57
  export declare abstract class Material extends EffectsObject implements Disposable {
58
+ shader: Shader;
58
59
  shaderSource: ShaderWithSource;
60
+ stringTags: Record<string, string>;
59
61
  readonly uniformSemantics: Record<string, UniformSemantic>;
60
62
  readonly renderType: MaterialRenderType;
61
63
  readonly name: string;
@@ -320,7 +322,7 @@ export declare abstract class Material extends EffectsObject implements Disposab
320
322
  */
321
323
  abstract hasUniform(name: string): boolean;
322
324
  /******** 预留接口,暂时不用实现 ***********************/
323
- abstract enableMacro(keyword: string): void;
325
+ abstract enableMacro(keyword: string, value?: boolean | number): void;
324
326
  abstract disableMacro(keyword: string): void;
325
327
  abstract isMacroEnabled(keyword: string): boolean;
326
328
  /***************************************************/
@@ -33,11 +33,6 @@ export interface MaterialStates extends MaterialBlendingStates, MaterialStencilS
33
33
  polygonOffset?: [factor: number, units: number];
34
34
  polygonOffsetFill?: boolean;
35
35
  }
36
- export interface FilterMaterialStates extends MaterialStates {
37
- blendMode?: spec.BlendingMode;
38
- side?: spec.SideMode;
39
- maskMode?: spec.MaskMode;
40
- }
41
36
  export interface MaterialDataBlockDestroyOptions {
42
37
  textures?: DestroyOptions;
43
38
  }
@@ -14,4 +14,4 @@ export declare function getPreMultiAlpha(blending?: number): number;
14
14
  export declare function createShaderWithMarcos(marcos: ShaderMarcos, shader: string, shaderType: ShaderType, level: number): string;
15
15
  export declare function setBlendMode(material: Material, blendMode?: number): void;
16
16
  export declare function setSideMode(material: Material, side: spec.SideMode): void;
17
- export declare function setMaskMode(material: Material, maskMode: number): void;
17
+ export declare function setMaskMode(material: Material, maskMode: spec.MaskMode): void;
@@ -1,5 +1,5 @@
1
1
  import { Euler, Vector3 } from '@galacean/effects-math/es/core/index';
2
- import type * as spec from '@galacean/effects-specification';
2
+ import * as spec from '@galacean/effects-specification';
3
3
  import { ItemBehaviour } from '../../components';
4
4
  import type { Engine } from '../../engine';
5
5
  export declare class CameraController extends ItemBehaviour {
@@ -66,7 +66,6 @@ export interface ParticleMeshProps extends ParticleMeshData {
66
66
  mask: number;
67
67
  maskMode: number;
68
68
  side: number;
69
- filter?: spec.FilterParams;
70
69
  transparentOcclusion?: boolean;
71
70
  matrix?: Matrix4;
72
71
  sprite?: {
@@ -23,9 +23,6 @@ export interface SpriteItemProps extends Omit<spec.SpriteContent, 'renderer'> {
23
23
  shape: GeometryFromShape;
24
24
  texture: Texture;
25
25
  } & Omit<spec.RendererOptions, 'texture'>;
26
- filter?: {
27
- feather: number | spec.FunctionExpression;
28
- } & Omit<spec.FilterParams, 'feather'>;
29
26
  }
30
27
  /**
31
28
  * 图层元素基础属性, 经过处理后的 spec.SpriteContent.options
@@ -2,5 +2,5 @@ import type { SharedShaderWithSource } from './shader';
2
2
  export declare const EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
3
3
  export declare const COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
4
4
  export declare const COPY_VERTEX_SHADER = "\n#ifdef WEBGL2\n#define vsIn in\n#define vsOut out\n#else\n#define vsIn attribute\n#define vsOut varying\n#endif\nprecision highp float;\nvsIn vec2 aPos;\nvsOut vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}";
5
- export declare const COPY_FRAGMENT_SHADER: string;
5
+ export declare const COPY_FRAGMENT_SHADER = "precision mediump float;\n#ifdef WEBGL2\n#define fsIn in\n#define fsOut out\n#define texture2D texture\n#else\n#define fsIn varying\n#endif\nfsIn vec2 vTex;\n#ifdef WEBGL2\nlayout (location = 0) out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#ifndef WEBGL2\n#extension GL_EXT_frag_depth : enable\n#define gl_FragDepth gl_FragDepthEXT\n#endif\n#endif\nvoid main(){\n #ifdef DEPTH_TEXTURE\n gl_FragDepth = texture2D(uDepth,vTex).r;\n #endif\n}\n";
6
6
  export declare function createCopyShader(level: number, writeDepth?: boolean): SharedShaderWithSource;
@@ -10,6 +10,9 @@ export interface GlobalVolume {
10
10
  brightness: number;
11
11
  saturation: number;
12
12
  contrast: number;
13
+ vignetteIntensity: number;
14
+ vignetteSmoothness: number;
15
+ vignetteRoundness: number;
13
16
  useToneMapping: number;
14
17
  }
15
18
  export declare const defaultGlobalVolume: GlobalVolume;
@@ -1,4 +1,4 @@
1
- import type { ShaderData } from '../asset-loader';
1
+ import type * as spec from '@galacean/effects-specification';
2
2
  import { EffectsObject } from '../effects-object';
3
3
  import type { Engine } from '../engine';
4
4
  export type ShaderMarcos = [key: string, value: string | number | boolean][];
@@ -85,9 +85,9 @@ export declare abstract class ShaderVariant extends EffectsObject {
85
85
  constructor(engine: Engine, source: ShaderWithSource);
86
86
  }
87
87
  export declare class Shader extends EffectsObject {
88
- shaderData: ShaderData;
88
+ shaderData: spec.ShaderData;
89
89
  createVariant(macros?: Record<string, number | boolean>): ShaderVariant;
90
- fromData(data: ShaderData): void;
90
+ fromData(data: spec.ShaderData): void;
91
91
  }
92
92
  export interface ShaderLibrary {
93
93
  readonly shaderResults: {
@@ -8,7 +8,7 @@ export declare class SemanticMap implements Disposable {
8
8
  constructor(semantics?: Record<string, SemanticGetter>);
9
9
  toObject(): Record<string, SemanticGetter>;
10
10
  setSemantic(name: string, value?: SemanticGetter): void;
11
- getSemanticValue(name: string, state: RenderingData): number | Float32Array | Int32Array | Float64Array | Uint8Array | Uint32Array | Uint16Array | Int8Array | Int16Array | number[] | number[][] | import("@galacean/effects-math/es/core").Vector3 | import("@galacean/effects-core").Texture | import("@galacean/effects-math/es/core").Vector2 | import("@galacean/effects-math/es/core").Vector4 | import("@galacean/effects-math/es/core").Matrix3 | import("@galacean/effects-math/es/core").Matrix4 | import("@galacean/effects-core").Texture[] | import("packages/effects-core/src/material/types").UniformStruct | import("packages/effects-core/src/material/types").UniformStruct[] | SemanticFunc | undefined;
11
+ getSemanticValue(name: string, state: RenderingData): number | Float32Array | Int32Array | Float64Array | Uint8Array | Uint32Array | Uint16Array | Int8Array | Int16Array | number[] | number[][] | import("@galacean/effects-core").Texture | import("@galacean/effects-math/es/core").Vector2 | import("@galacean/effects-math/es/core").Vector3 | import("@galacean/effects-math/es/core").Vector4 | import("@galacean/effects-math/es/core").Matrix3 | import("@galacean/effects-math/es/core").Matrix4 | import("@galacean/effects-core").Texture[] | import("packages/effects-core/src/material/types").UniformStruct | import("packages/effects-core/src/material/types").UniformStruct[] | SemanticFunc | undefined;
12
12
  hasSemanticValue(name: string): boolean;
13
13
  dispose(): void;
14
14
  }
@@ -11,16 +11,6 @@ export { default as particleVert } from './particle.vert.glsl';
11
11
  export { default as trailVert } from './trail.vert.glsl';
12
12
  export { default as value } from './value.glsl';
13
13
  export { default as valueDefine } from './value-define.glsl';
14
- export { default as copyFrag } from './adjust/copy.frag.glsl';
15
- export { default as alphaFrameFrag } from './adjust/alpha-frame.frag.glsl';
16
- export { default as alphaMaskFrag } from './adjust/alpha-mask.frag.glsl';
17
- export { default as cameraMoveFrag } from './adjust/camera-move.frag.glsl';
18
- export { default as cameraMoveVert } from './adjust/camera-move.vert.glsl';
19
- export { default as delayFrag } from './adjust/delay.frag.glsl';
20
- export { default as distortionFrag } from './adjust/distortion.frag.glsl';
21
- export { default as distortionVert } from './adjust/distortion.vert.glsl';
22
- export { default as bloomMixVert } from './adjust/bloom-mix.frag.glsl';
23
- export { default as bloomThresholdVert } from './adjust/bloom-threshold.frag.glsl';
24
14
  export { default as screenMeshVert } from './post-processing/screen-mesh.vert.glsl';
25
15
  export { default as colorGradingFrag } from './post-processing/color-grading.frag.glsl';
26
16
  export { default as gaussianDownFrag } from './post-processing/gaussian-down.frag.glsl';
@@ -0,0 +1,21 @@
1
+ import type { TemplateContent } from '@galacean/effects-specification';
2
+ export declare const DEFAULT_FONTS: string[];
3
+ declare class CanvasPool {
4
+ readonly elements: HTMLCanvasElement[];
5
+ constructor();
6
+ dispose(): void;
7
+ getCanvas(): HTMLCanvasElement;
8
+ saveCanvas(cvs: HTMLCanvasElement): void;
9
+ }
10
+ export declare const canvasPool: CanvasPool;
11
+ export declare function getDefaultTemplateCanvasPool(): CanvasPool;
12
+ export declare function getBackgroundImage(template: TemplateContent, variables?: Record<string, number | string | string[]>): string | number | string[] | undefined;
13
+ /**
14
+ * @param url
15
+ * @param template
16
+ * @param variables
17
+ * @param options
18
+ * @returns
19
+ */
20
+ export declare function combineImageTemplate(url: string | HTMLImageElement, template?: TemplateContent, variables?: Record<string, number | string>): Promise<number | HTMLImageElement | string[]>;
21
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { Vector3 } from '@galacean/effects-math/es/core/vector3';
2
2
  import * as spec from '@galacean/effects-specification';
3
- import { type VFXItemData } from './asset-loader';
3
+ import type { VFXItemData } from './asset-loader';
4
4
  import { RendererComponent } from './components';
5
5
  import type { Component } from './components/component';
6
6
  import { ItemBehaviour } from './components/component';
@@ -258,7 +258,6 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
258
258
  }
259
259
  export declare namespace Item {
260
260
  function is<T extends spec.Item>(item: spec.Item, type: spec.ItemType): item is T;
261
- function isFilter(item: spec.Item): item is spec.FilterItem;
262
261
  function isComposition(item: spec.Item): item is spec.CompositionItem;
263
262
  function isParticle(item: spec.Item): item is spec.ParticleItem;
264
263
  function isNull(item: spec.Item): item is spec.NullItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/effects-core",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.8",
4
4
  "description": "Galacean Effects runtime core for the web",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -42,7 +42,7 @@
42
42
  "registry": "https://registry.npmjs.org"
43
43
  },
44
44
  "dependencies": {
45
- "@galacean/effects-specification": "2.0.0-alpha.5",
45
+ "@galacean/effects-specification": "2.0.0-alpha.8",
46
46
  "@galacean/effects-math": "1.1.0-alpha.0",
47
47
  "uuid": "9.0.1"
48
48
  },
@@ -1,68 +0,0 @@
1
- import type { TemplateContentV1, TemplateContentV2 } from '@galacean/effects-specification';
2
- export * from './qcanvas-viewer';
3
- export * from './qtext';
4
- export * from './template-v1';
5
- export declare const DEFAULT_FONTS: string[];
6
- export interface TextLayout {
7
- x: number;
8
- y: number;
9
- width: number;
10
- height: number;
11
- }
12
- export interface TemplateOptions {
13
- templateScale?: number;
14
- canvas?: HTMLCanvasElement;
15
- textLayouts?: TextLayout[];
16
- debug?: boolean;
17
- borderColor?: string;
18
- borderWidth?: number;
19
- flipY?: boolean;
20
- scaleX?: number;
21
- scaleY?: number;
22
- toData?: boolean;
23
- }
24
- declare class CanvasPool {
25
- readonly elements: HTMLCanvasElement[];
26
- constructor();
27
- dispose(): void;
28
- getCanvas(): HTMLCanvasElement;
29
- saveCanvas(cvs: HTMLCanvasElement): void;
30
- }
31
- export declare const canvasPool: CanvasPool;
32
- export declare function getDefaultTemplateCanvasPool(): CanvasPool;
33
- export declare function getBackgroundImage(template: TemplateContentV2, variables?: Record<string, number | string | string[]>): string | string[];
34
- export declare function loadMedia(url: string | string[], loadFn: (url: string) => Promise<any>): Promise<any>;
35
- /**
36
- * @param {string|HTMLImageElement} url
37
- * @param {TemplateContentV2} [template]
38
- * @param {Record<string, number | string>} [variables]
39
- * @param {TemplateOptions} [opts]
40
- * @param {boolean} [flipY]
41
- * @returns
42
- */
43
- export declare function combineImageTemplate2(url: string | HTMLImageElement, template?: TemplateContentV2, variables?: Record<string, number | string>, opts?: TemplateOptions, flipY?: boolean): Promise<HTMLCanvasElement>;
44
- /**
45
- * @internal
46
- * @deprecated since 2.0.0 - use `combineImageTemplate2` instead
47
- */
48
- export declare function combineImageTemplate2Async(url: string | HTMLImageElement, template?: TemplateContentV2, variables?: Record<string, number | string>, opts?: TemplateOptions, flipY?: boolean): Promise<HTMLCanvasElement | ImageData>;
49
- /**
50
- * @param url
51
- * @param template
52
- * @param variables
53
- * @param opts
54
- * @param flipY
55
- * @returns
56
- */
57
- export declare function combineImageTemplate(url: string | HTMLImageElement, template: TemplateContentV1 | TemplateContentV2, variables: Record<string, number | string>, opts?: {
58
- templateScale?: number;
59
- canvas?: HTMLCanvasElement;
60
- }, flipY?: boolean): Promise<HTMLCanvasElement>;
61
- /**
62
- * @internal
63
- * @deprecated since 2.0.0 - use `combineImageTemplate` instead
64
- */
65
- export declare function combineImageTemplateAsync(url: string | HTMLImageElement, template: TemplateContentV1 | TemplateContentV2, variables: Record<string, number | string>, opts?: {
66
- templateScale?: number;
67
- canvas?: HTMLCanvasElement;
68
- }, flipY?: boolean): Promise<HTMLCanvasElement | HTMLImageElement | ImageData>;
@@ -1,21 +0,0 @@
1
- import type { QText } from './qtext';
2
- declare class QCanvasViewer {
3
- width: number;
4
- height: number;
5
- background: HTMLImageElement;
6
- scaleX: number;
7
- scaleY: number;
8
- renderCanvas: HTMLCanvasElement;
9
- renderContext: CanvasRenderingContext2D;
10
- textList: QText[];
11
- devicePixelRatio: number;
12
- flipY: boolean;
13
- constructor(canvas: string | HTMLCanvasElement, width: number, height: number, scaleX?: number, scaleY?: number, flipY?: boolean);
14
- initDimension(width: number, height: number, scaleX?: number, scaleY?: number): void;
15
- clearText(): void;
16
- clearCanvasWithContext(ctx: CanvasRenderingContext2D): void;
17
- clearCanvas(): void;
18
- addObject(text: QText): void;
19
- render(): void;
20
- }
21
- export { QCanvasViewer };
@@ -1,96 +0,0 @@
1
- import type { QCanvasViewer } from './qcanvas-viewer';
2
- import type { IFontMetrics } from './text-metrics';
3
- declare enum QTextWrapMode {
4
- Default = 0,
5
- Clip = 1,
6
- Ellipsis = 2
7
- }
8
- interface QTextOptions {
9
- left?: number;
10
- top?: number;
11
- maxWidth?: number;
12
- fontFamily?: string;
13
- fontSize?: number;
14
- fontWeight?: string;
15
- align?: string;
16
- verticalAlign?: string;
17
- padding?: number;
18
- letterSpacing?: number;
19
- wrap?: QTextWrapMode;
20
- color?: string;
21
- fontStyle?: string;
22
- angle?: number;
23
- name?: string;
24
- }
25
- interface QChar {
26
- left: number;
27
- top: number;
28
- char: string;
29
- width: number;
30
- heigh: number;
31
- font: string;
32
- fontSize: number;
33
- isEllipsis: boolean;
34
- scale: number;
35
- index: number;
36
- }
37
- declare class QText {
38
- left: number;
39
- top: number;
40
- width?: number;
41
- height?: number;
42
- text: string;
43
- name: string;
44
- fontSize: number;
45
- fontFamily: string;
46
- color: string;
47
- letterSpacing: number;
48
- maxLineWidth: number;
49
- wrap: QTextWrapMode;
50
- fontStyle: 'normal' | 'italic' | 'oblique' | 'initial' | 'inherit';
51
- textAlign: 'center' | 'end' | 'left' | 'right' | 'start';
52
- textBaseline: 'alphabetic' | 'bottom' | 'hanging' | 'ideographic' | 'middle' | 'top';
53
- scaleX: number;
54
- scaleY: number;
55
- angle: number;
56
- active: boolean;
57
- padding: number;
58
- fontWeight: string;
59
- chars: QChar[];
60
- borderColor: string;
61
- borderWidth: number;
62
- fontProperties: IFontMetrics;
63
- fontVariant: string;
64
- private viewer;
65
- private originX;
66
- private originY;
67
- private ellipsis;
68
- constructor(text: string, options: QTextOptions);
69
- update(): void;
70
- render(): void;
71
- init(viewer: QCanvasViewer): void;
72
- getLayout(): {
73
- x: number;
74
- y: number;
75
- width: number;
76
- height: number;
77
- };
78
- private updateDimension;
79
- private configTextStyle;
80
- private getFontDesc;
81
- private configTextLayout;
82
- private setRenderTransform;
83
- private renderText;
84
- private drawCharsInTextBox;
85
- private addEllipsisToChars;
86
- private createCharsFromText;
87
- private addOffsetToChars;
88
- private clipCharsWithTextBox;
89
- private cloneChars;
90
- private replaceCharWithEllipsis;
91
- private findEllipsisPositionAndReplaceCharsFromLeft;
92
- private findEllipsisPositionAndReplaceCharsFromRight;
93
- private drawCharsFromLeft;
94
- private drawBorders;
95
- }
96
- export { QText, QTextOptions, QTextWrapMode };
@@ -1,27 +0,0 @@
1
- import type { TemplateContentV1 } from '@galacean/effects-specification';
2
- export declare function requestAsync(url: string, opt?: {
3
- responseType?: XMLHttpRequestResponseType;
4
- method?: string;
5
- data?: Document | XMLHttpRequestBodyInit | null;
6
- }): Promise<unknown>;
7
- /**
8
- *
9
- * @param url
10
- * @param template
11
- * @param variables
12
- * @param opts
13
- * @param flipY
14
- * @returns
15
- */
16
- export declare function combineImageTemplate1(url: string | HTMLImageElement, template: TemplateContentV1, variables: Record<string, number | string | HTMLImageElement>, opts?: {
17
- templateScale?: number;
18
- canvas?: HTMLCanvasElement;
19
- }, flipY?: boolean): Promise<HTMLCanvasElement>;
20
- /**
21
- * @internal
22
- * @deprecated since 2.0.0 - use `combineImageTemplate1` instead
23
- */
24
- export declare function combineImageTemplate1Async(url: string | HTMLImageElement, template: TemplateContentV1, variables: Record<string, number | string | HTMLImageElement>, opts?: {
25
- templateScale?: number;
26
- canvas?: HTMLCanvasElement;
27
- }, flipY?: boolean): Promise<HTMLCanvasElement>;
@@ -1,18 +0,0 @@
1
- export interface IFontMetrics {
2
- ascent: number;
3
- descent: number;
4
- fontSize: number;
5
- }
6
- export declare class TextMetrics {
7
- static _fonts: {
8
- [font: string]: IFontMetrics;
9
- };
10
- static METRICS_STRING: string;
11
- static BASELINE_SYMBOL: string;
12
- static BASELINE_MULTIPLIER: number;
13
- static HEIGHT_MULTIPLIER: number;
14
- private static __canvas;
15
- private static __context;
16
- static measureFont(font: string): IFontMetrics;
17
- static get _canvas(): HTMLCanvasElement;
18
- }