@galacean/effects-core 2.3.3 → 2.4.0-beta.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.
@@ -2,3 +2,4 @@ export * from './types';
2
2
  export * from './utils';
3
3
  export * from './material-data-block';
4
4
  export * from './material';
5
+ export * from './mask-ref-manager';
@@ -0,0 +1,15 @@
1
+ import type { Engine } from '../engine';
2
+ import type { MaskProps } from './types';
3
+ import { MaskMode } from './types';
4
+ export declare class MaskRefManager {
5
+ currentRef: number;
6
+ constructor(initRef?: number);
7
+ distributeRef(): number;
8
+ }
9
+ export declare class MaskProcessor {
10
+ engine: Engine;
11
+ maskRef: number;
12
+ constructor(engine: Engine);
13
+ getRefValue(): number;
14
+ getMaskMode(data: MaskProps): MaskMode;
15
+ }
@@ -2,6 +2,7 @@ import type * as spec from '@galacean/effects-specification';
2
2
  import type { Matrix3, Matrix4, Vector2, Vector3, Vector4 } from '@galacean/effects-math/es/core/index';
3
3
  import type { Texture } from '../texture';
4
4
  import type { DestroyOptions } from '../utils';
5
+ import type { MaskProcessor } from './mask-ref-manager';
5
6
  export type UniformSemantic = 'VIEW' | 'MODEL' | 'MODELVIEW' | 'PROJECTION' | 'VIEWPROJECTION' | 'VIEWINVERSE' | 'EDITOR_TRANSFORM' | 'MODELVIEWPROJECTION';
6
7
  export interface MaterialBlendingStates {
7
8
  blending?: boolean;
@@ -59,3 +60,34 @@ export declare enum ShaderType {
59
60
  vertex = 0,
60
61
  fragment = 1
61
62
  }
63
+ export interface MaskProps {
64
+ mask?: {
65
+ mask?: boolean;
66
+ mode?: spec.ObscuredMode;
67
+ ref?: Maskable;
68
+ };
69
+ }
70
+ /**
71
+ *
72
+ */
73
+ export interface Maskable {
74
+ readonly maskManager: MaskProcessor;
75
+ }
76
+ export declare enum MaskMode {
77
+ /**
78
+ * 无
79
+ */
80
+ NONE = 0,
81
+ /**
82
+ * 蒙版
83
+ */
84
+ MASK = 1,
85
+ /**
86
+ * 被遮挡
87
+ */
88
+ OBSCURED = 2,
89
+ /**
90
+ * 被反向遮挡
91
+ */
92
+ REVERSE_OBSCURED = 3
93
+ }
@@ -1,7 +1,8 @@
1
1
  import * as spec from '@galacean/effects-specification';
2
+ import { MaskMode } from './types';
2
3
  import type { Material } from './material';
3
4
  export declare function valIfUndefined<T>(val: any, def: T): T;
4
- export declare function getPreMultiAlpha(blending?: number): number;
5
+ export declare function getPreMultiAlpha(blending?: spec.BlendingMode): number;
5
6
  export declare function setBlendMode(material: Material, blendMode?: number): void;
6
7
  export declare function setSideMode(material: Material, side: spec.SideMode): void;
7
- export declare function setMaskMode(material: Material, maskMode: spec.MaskMode): void;
8
+ export declare function setMaskMode(material: Material, maskMode: MaskMode, colorMask?: boolean): void;
@@ -19,5 +19,11 @@ export * from './particle/particle-system-renderer';
19
19
  export * from './cal/calculate-loader';
20
20
  export * from './cal/calculate-vfx-item';
21
21
  export * from './cal/calculate-item';
22
+ export * from './shape/build-line';
23
+ export * from './shape/graphics-path';
24
+ export * from './shape/ellipse';
25
+ export * from './shape/poly-star';
26
+ export * from './shape/polygon';
27
+ export * from './shape/shape-path';
22
28
  export * from './timeline';
23
29
  export * from './text';
@@ -1,17 +1,17 @@
1
+ import { Matrix4 } from '@galacean/effects-math/es/core/matrix4';
1
2
  import type { Geometry } from '../../render/geometry';
2
3
  import type { BoundingBoxTriangle } from './click-handler';
3
- import { Matrix4 } from '@galacean/effects-math/es/core/matrix4';
4
4
  /**
5
5
  *
6
6
  */
7
7
  export declare class MeshCollider {
8
8
  private boundingBoxData;
9
- private geometry;
10
9
  private triangles;
11
10
  private worldMatrix;
12
11
  getBoundingBoxData(): BoundingBoxTriangle;
13
12
  getBoundingBox(): BoundingBoxTriangle;
14
13
  setGeometry(geometry: Geometry, worldMatrix?: Matrix4): void;
15
14
  private geometryToTriangles;
15
+ private assemblyTriangles;
16
16
  private applyWorldMatrix;
17
17
  }
@@ -6,6 +6,8 @@ import { Component } from '../../components';
6
6
  import type { Engine } from '../../engine';
7
7
  import type { ValueGetter } from '../../math';
8
8
  import type { Mesh } from '../../render';
9
+ import type { Maskable } from '../../material';
10
+ import { MaskMode, MaskProcessor } from '../../material';
9
11
  import type { ShapeGenerator, ShapeParticle } from '../../shape';
10
12
  import { Texture } from '../../texture';
11
13
  import { Transform } from '../../transform';
@@ -114,23 +116,30 @@ type ParticleInteraction = {
114
116
  export interface ParticleSystemOptions extends spec.ParticleOptions {
115
117
  meshSlots?: number[];
116
118
  }
117
- export interface ParticleSystemProps extends Omit<spec.ParticleContent, 'options' | 'renderer' | 'trails'> {
119
+ export interface ParticleSystemProps extends Omit<spec.ParticleContent, 'options' | 'renderer' | 'trails' | 'mask'> {
118
120
  options: ParticleSystemOptions;
119
121
  renderer: ParticleSystemRendererOptions;
120
122
  trails?: ParticleTrailProps;
123
+ mask?: {
124
+ mode: MaskMode;
125
+ ref: Maskable;
126
+ };
121
127
  }
122
128
  export interface ParticleSystemRendererOptions extends Required<Omit<spec.RendererOptions, 'texture' | 'anchor' | 'particleOrigin'>> {
123
- mask: number;
124
129
  texture: Texture;
125
130
  anchor?: vec2;
126
131
  particleOrigin?: spec.ParticleOrigin;
127
132
  }
128
- export interface ParticleTrailProps extends Omit<spec.ParticleTrail, 'texture'> {
133
+ export interface ParticleTrailProps extends Omit<spec.ParticleTrail, 'texture' | 'mask'> {
129
134
  texture: Texture;
130
135
  textureMap: vec4;
136
+ mask?: {
137
+ mode: MaskMode;
138
+ ref: Maskable;
139
+ };
131
140
  }
132
141
  export type ParticleContent = [number, number, number, Point];
133
- export declare class ParticleSystem extends Component {
142
+ export declare class ParticleSystem extends Component implements Maskable {
134
143
  renderer: ParticleSystemRenderer;
135
144
  options: ParticleOptions;
136
145
  shape: ShapeGenerator;
@@ -142,6 +151,7 @@ export declare class ParticleSystem extends Component {
142
151
  emissionStopped: boolean;
143
152
  destroyed: boolean;
144
153
  props: ParticleSystemProps;
154
+ readonly maskManager: MaskProcessor;
145
155
  private generatedCount;
146
156
  private lastUpdate;
147
157
  private loopStartTime;
@@ -207,5 +217,9 @@ export declare class ParticleSystem extends Component {
207
217
  getBoundingBox(): void | BoundingBoxSphere;
208
218
  getHitTestParams: (force?: boolean) => void | HitTestCustomParams;
209
219
  fromData(data: unknown): void;
220
+ getMaskOptions(data: ParticleSystemProps | ParticleTrailProps): {
221
+ maskMode: MaskMode;
222
+ maskRef: number;
223
+ };
210
224
  }
211
225
  export {};
@@ -1,20 +1,19 @@
1
1
  import * as spec from '@galacean/effects-specification';
2
+ import type { ColorPlayableAssetData } from '../../animation';
3
+ import { BaseRenderComponent } from '../../components';
2
4
  import type { Engine } from '../../engine';
3
- import type { GeometryDrawMode } from '../../render';
4
- import { Geometry } from '../../render';
5
- import type { GeometryFromShape } from '../../shape';
5
+ import type { MaskProps } from '../../material';
6
+ import type { Geometry } from '../../render';
7
+ import { type GeometryFromShape } from '../../shape';
6
8
  import { type Texture } from '../../texture';
7
- import type { PlayableGraph, Playable } from '../cal/playable-graph';
9
+ import type { Playable, PlayableGraph } from '../cal/playable-graph';
8
10
  import { PlayableAsset } from '../cal/playable-graph';
9
- import type { ColorPlayableAssetData } from '../../animation';
10
- import { BaseRenderComponent } from '../../components/base-render-component';
11
11
  /**
12
12
  * 用于创建 spriteItem 的数据类型, 经过处理后的 spec.SpriteContent
13
13
  */
14
- export interface SpriteItemProps extends Omit<spec.SpriteContent, 'renderer'> {
14
+ export interface SpriteItemProps extends Omit<spec.SpriteContent, 'renderer' | 'mask'>, MaskProps {
15
15
  listIndex?: number;
16
16
  renderer: {
17
- mask: number;
18
17
  shape: GeometryFromShape;
19
18
  texture: Texture;
20
19
  } & Omit<spec.RendererOptions, 'texture'>;
@@ -39,8 +38,7 @@ export declare class SpriteComponent extends BaseRenderComponent {
39
38
  constructor(engine: Engine, props?: SpriteItemProps);
40
39
  onUpdate(dt: number): void;
41
40
  onDestroy(): void;
42
- createGeometry(mode: GeometryDrawMode): Geometry;
43
- getItemGeometryData(): {
41
+ getItemGeometryData(geometry: Geometry): {
44
42
  index: number[];
45
43
  atlasOffset: number[];
46
44
  };
@@ -1,8 +1,7 @@
1
1
  import type { Vector3 } from '@galacean/effects-math/es/core/vector3';
2
2
  import type * as spec from '@galacean/effects-specification';
3
- import type { GPUCapabilityDetail, SharedShaderWithSource } from '../../render';
3
+ import type { GPUCapabilityDetail } from '../../render';
4
4
  import type { Transform } from '../../transform';
5
- import type { ItemRenderInfo } from '../../components';
6
5
  export type SpriteRenderData = {
7
6
  life: number;
8
7
  transform: Transform;
@@ -21,10 +20,4 @@ export type SpriteRegionData = {
21
20
  };
22
21
  export declare let maxSpriteMeshItemCount: number;
23
22
  export declare function setSpriteMeshMaxItemCountByGPU(gpuCapability: GPUCapabilityDetail): 16 | 32 | undefined;
24
- export declare function spriteMeshShaderFromFilter(level: number, options?: {
25
- wireframe?: boolean;
26
- env?: string;
27
- }): SharedShaderWithSource;
28
- export declare function spriteMeshShaderIdFromRenderInfo(renderInfo: ItemRenderInfo, count: number): string;
29
- export declare function spriteMeshShaderFromRenderInfo(renderInfo: ItemRenderInfo, count: number, level: number, env?: string): SharedShaderWithSource;
30
23
  export declare function setMaxSpriteMeshItemCount(count: number): void;
@@ -1,19 +1,18 @@
1
1
  import * as spec from '@galacean/effects-specification';
2
+ import type { ItemRenderer } from '../../components';
3
+ import { BaseRenderComponent } from '../../components';
2
4
  import type { Engine } from '../../engine';
5
+ import type { MaskProps, Material } from '../../material';
3
6
  import { Texture } from '../../texture';
7
+ import type { VFXItem } from '../../vfx-item';
4
8
  import { TextLayout } from './text-layout';
5
9
  import { TextStyle } from './text-style';
6
- import type { Material } from '../../material';
7
- import type { VFXItem } from '../../vfx-item';
8
- import type { ItemRenderer } from '../../components';
9
- import { BaseRenderComponent } from '../../components';
10
10
  /**
11
11
  * 用于创建 textItem 的数据类型, 经过处理后的 spec.TextContentOptions
12
12
  */
13
- export interface TextItemProps extends Omit<spec.TextContent, 'renderer'> {
13
+ export interface TextItemProps extends Omit<spec.TextContent, 'renderer' | 'mask'>, MaskProps {
14
14
  listIndex?: number;
15
15
  renderer: {
16
- mask: number;
17
16
  texture: Texture;
18
17
  } & Omit<spec.RendererOptions, 'texture'>;
19
18
  }
@@ -19,32 +19,6 @@ export declare enum GLSLVersion {
19
19
  'GLSL1' = "100",
20
20
  'GLSL3' = "300 es"
21
21
  }
22
- export interface InstancedShaderWithSource {
23
- /**
24
- * fragment shader字符串
25
- */
26
- fragment: string;
27
- /**
28
- * vertex shader字符串
29
- */
30
- vertex: string;
31
- /**
32
- * shader 字符串的版本,用于添加版本头
33
- */
34
- glslVersion?: GLSLVersion;
35
- /**
36
- * shader的name
37
- */
38
- name?: string;
39
- /**
40
- * shader的宏定义
41
- */
42
- macros?: ShaderMacros;
43
- /**
44
- * shader是否共享
45
- */
46
- shared?: boolean;
47
- }
48
22
  export interface SharedShaderWithSource {
49
23
  /**
50
24
  * fragment shader字符串
@@ -78,7 +52,7 @@ export interface SharedShaderWithSource {
78
52
  */
79
53
  cacheId?: string;
80
54
  }
81
- export type ShaderWithSource = InstancedShaderWithSource | SharedShaderWithSource;
55
+ export type ShaderWithSource = SharedShaderWithSource;
82
56
  export declare abstract class ShaderVariant extends EffectsObject {
83
57
  readonly source: ShaderWithSource;
84
58
  shader: Shader;
@@ -2,7 +2,7 @@ import { Vector3 } from '@galacean/effects-math/es/core/vector3';
2
2
  import * as spec from '@galacean/effects-specification';
3
3
  import type { Component } from './components';
4
4
  import { RendererComponent } from './components';
5
- import type { Composition } from './composition';
5
+ import { type Composition } from './composition';
6
6
  import { EffectsObject } from './effects-object';
7
7
  import type { Engine } from './engine';
8
8
  import type { EventEmitterListener, EventEmitterOptions, ItemEvent } from './events';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/effects-core",
3
- "version": "2.3.3",
3
+ "version": "2.4.0-beta.0",
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.2.0",
45
+ "@galacean/effects-specification": "2.3.0",
46
46
  "@galacean/effects-math": "1.1.0",
47
47
  "flatbuffers": "24.3.25",
48
48
  "uuid": "9.0.1",
@@ -1,40 +0,0 @@
1
- import * as spec from '@galacean/effects-specification';
2
- import type { SceneBindingData } from './comp-vfx-item';
3
- import type { Engine } from './engine';
4
- import type { Scene, SceneRenderLevel } from './scene';
5
- import type { Texture } from './texture';
6
- import type { Disposable } from './utils';
7
- export interface ContentOptions {
8
- id: string;
9
- duration: number;
10
- name: string;
11
- endBehavior: spec.EndBehavior;
12
- items: spec.DataPath[];
13
- camera: spec.CameraOptions;
14
- startTime: number;
15
- timelineAsset: spec.DataPath;
16
- sceneBindings: SceneBindingData[];
17
- }
18
- /**
19
- * 合成资源管理
20
- */
21
- export declare class CompositionSourceManager implements Disposable {
22
- engine: Engine;
23
- sourceContent?: spec.CompositionData;
24
- renderLevel?: SceneRenderLevel;
25
- imgUsage: Record<string, number>;
26
- textures: Texture[];
27
- jsonScene?: spec.JSONScene;
28
- mask: number;
29
- constructor(scene: Scene, engine: Engine);
30
- private getContent;
31
- private assembleItems;
32
- private preProcessItemContent;
33
- private changeTex;
34
- private addTextureUsage;
35
- /**
36
- * 处理蒙版和遮挡关系写入 stencil 的 ref 值
37
- */
38
- private processMask;
39
- dispose(): void;
40
- }