@galacean/effects-plugin-model 0.0.1-alpha.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.
Files changed (64) hide show
  1. package/README.md +26 -0
  2. package/dist/gesture/controller.d.ts +95 -0
  3. package/dist/gesture/index.d.ts +38 -0
  4. package/dist/gesture/protocol.d.ts +143 -0
  5. package/dist/gltf/index.d.ts +3 -0
  6. package/dist/gltf/loader-ext.d.ts +53 -0
  7. package/dist/gltf/loader-helper.d.ts +18 -0
  8. package/dist/gltf/loader-impl.d.ts +84 -0
  9. package/dist/gltf/protocol.d.ts +90 -0
  10. package/dist/helper/index.d.ts +2 -0
  11. package/dist/index.d.ts +38 -0
  12. package/dist/index.js +16137 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/index.min.js +9 -0
  15. package/dist/index.min.js.map +1 -0
  16. package/dist/index.mjs +16048 -0
  17. package/dist/index.mjs.map +1 -0
  18. package/dist/loader.d.ts +2 -0
  19. package/dist/loader.mjs +12040 -0
  20. package/dist/loader.mjs.map +1 -0
  21. package/dist/math/box3.d.ts +140 -0
  22. package/dist/math/euler.d.ts +139 -0
  23. package/dist/math/index.d.ts +11 -0
  24. package/dist/math/matrix2.d.ts +58 -0
  25. package/dist/math/matrix3.d.ts +113 -0
  26. package/dist/math/matrix4.d.ts +264 -0
  27. package/dist/math/quaternion.d.ts +214 -0
  28. package/dist/math/sphere.d.ts +81 -0
  29. package/dist/math/type.d.ts +29 -0
  30. package/dist/math/utilities/index.d.ts +9 -0
  31. package/dist/math/vector2.d.ts +394 -0
  32. package/dist/math/vector3.d.ts +164 -0
  33. package/dist/math/vector4.d.ts +132 -0
  34. package/dist/plugin/const.d.ts +2 -0
  35. package/dist/plugin/index.d.ts +6 -0
  36. package/dist/plugin/model-plugin.d.ts +48 -0
  37. package/dist/plugin/model-tree-item.d.ts +30 -0
  38. package/dist/plugin/model-tree-plugin.d.ts +13 -0
  39. package/dist/plugin/model-tree-vfx-item.d.ts +15 -0
  40. package/dist/plugin/model-vfx-item.d.ts +25 -0
  41. package/dist/runtime/anim-sampler.d.ts +13 -0
  42. package/dist/runtime/animation.d.ts +189 -0
  43. package/dist/runtime/cache.d.ts +34 -0
  44. package/dist/runtime/camera.d.ts +43 -0
  45. package/dist/runtime/common.d.ts +113 -0
  46. package/dist/runtime/index.d.ts +12 -0
  47. package/dist/runtime/light.d.ts +34 -0
  48. package/dist/runtime/material.d.ts +101 -0
  49. package/dist/runtime/mesh.d.ts +145 -0
  50. package/dist/runtime/object.d.ts +44 -0
  51. package/dist/runtime/scene.d.ts +131 -0
  52. package/dist/runtime/shader-libs/standard-shader-source.d.ts +3 -0
  53. package/dist/runtime/shader-libs/standard-shader.d.ts +6 -0
  54. package/dist/runtime/shader.d.ts +18 -0
  55. package/dist/runtime/shadow.d.ts +227 -0
  56. package/dist/runtime/skybox.d.ts +91 -0
  57. package/dist/utility/debug-helper.d.ts +7 -0
  58. package/dist/utility/hit-test-helper.d.ts +9 -0
  59. package/dist/utility/index.d.ts +6 -0
  60. package/dist/utility/plugin-helper.d.ts +197 -0
  61. package/dist/utility/ri-helper.d.ts +25 -0
  62. package/dist/utility/shader-helper.d.ts +13 -0
  63. package/dist/utility/ts-helper.d.ts +34 -0
  64. package/package.json +56 -0
@@ -0,0 +1,6 @@
1
+ export * from './debug-helper';
2
+ export * from './hit-test-helper';
3
+ export * from './plugin-helper';
4
+ export * from './ri-helper';
5
+ export * from './shader-helper';
6
+ export * from './ts-helper';
@@ -0,0 +1,197 @@
1
+ import type { Scene, Composition, Attribute, GeometryProps, TextureSourceOptions, TextureSourceCubeData, TextureConfigOptions, Engine } from '@galacean/effects';
2
+ import { Player, spec, Transform, Mesh, Texture, Geometry, Renderer, RenderPass } from '@galacean/effects';
3
+ import type { GLTFCamera, GLTFImage, GLTFLight, GLTFTexture } from '@vvfx/resource-detection';
4
+ import type { MarsAnimationOptions, MarsMeshOptions, MarsMaterialOptions, MarsLightOptions, MarsCameraOptions, MarsSkyboxOptions, MarsSkinOptions, MarsPrimitiveOptions, MarsTextureTransform, MarsTreeOptions, MarsAnimTrackOptions } from '../index';
5
+ import type { Box3 } from '../math';
6
+ import { Matrix3, Matrix4, Vector3, Vector4 } from '../math';
7
+ import type { FBOOptions } from './ri-helper';
8
+ import type { PMaterialBase } from '../runtime/material';
9
+ import type { PImageBufferData } from '../runtime/skybox';
10
+ import type { CompositionCache } from '../runtime/cache';
11
+ type MarsRIVertexArray = Float32Array | Int32Array | Int16Array | Int8Array | Uint32Array | Uint16Array | Uint8Array;
12
+ export declare class MarsRIHelper {
13
+ static cubemapTexConfig: TextureConfigOptions;
14
+ static cubemapMipTexConfig: TextureConfigOptions;
15
+ static createTexture2D(engine: Engine, image: GLTFImage, texture: GLTFTexture, isBaseColor?: boolean, tiny3dMode?: boolean): Promise<Texture>;
16
+ static createTextureList(engine: Engine, images: GLTFImage[], textures: GLTFTexture[]): Promise<Texture[]>;
17
+ static getTextureCubeData(images: PImageBufferData[]): Promise<TextureSourceCubeData>;
18
+ static getTextureCubeMipmapData(images: PImageBufferData[][]): Promise<TextureSourceCubeData[]>;
19
+ static createTextureCubeFromURL(engine: Engine, cubeImage: string[]): Promise<Texture>;
20
+ static createTextureCubeMipmapFromURL(engine: Engine, cubeImages: string[][]): Promise<Texture>;
21
+ static createTextureCubeFromBuffer(engine: Engine, cubeImages: PImageBufferData[]): Promise<Texture>;
22
+ static createTextureCubeMipmapFromBuffer(engine: Engine, cubeImages: PImageBufferData[][], level0Size: number): Promise<Texture>;
23
+ static getTexture(index: number, textures: Texture[]): Texture | undefined;
24
+ static createTextureFromImage(engine: Engine, image: HTMLImageElement | HTMLCanvasElement): Texture;
25
+ static createRenderPass(renderer: Renderer, name: string, priority: number, meshData: Mesh | Mesh[], fboOpts: FBOOptions): RenderPass;
26
+ static deleteTexture(texture: Texture): void;
27
+ static deleteMesh(mesh: Mesh): void;
28
+ static deleteGeometry(geometry: Geometry): void;
29
+ static deleteRenderPass(pass: RenderPass): void;
30
+ /**
31
+ * 返回 Mesh 是否半透明
32
+ *
33
+ * @param mesh - gl mesh 对象
34
+ * @return 是否半透明
35
+ */
36
+ static isTransparentMesh(mesh: Mesh): boolean;
37
+ /**
38
+ * renderer 是否支持 Float 纹理
39
+ * @returns
40
+ */
41
+ static isSupportFloatTexture(engine: Engine): boolean;
42
+ /**
43
+ * renderer 是否支持 HalfFloat 纹理
44
+ * @returns
45
+ */
46
+ static isSupportHalfFloatTexture(engine: Engine): boolean;
47
+ static isPow2(v: number): boolean;
48
+ }
49
+ export declare class MeshHelper {
50
+ static createMarsFilterMesh(engine: Engine, name: string, material: PMaterialBase, uniformSemantics: {
51
+ [k: string]: any;
52
+ }): Mesh;
53
+ static getPlaneGeometry(): GeometryProps;
54
+ static getPlaneVertexArray(): Float32Array;
55
+ }
56
+ export interface MarsSceneInfo {
57
+ loadSkybox?: boolean;
58
+ }
59
+ export declare class PluginHelper {
60
+ static createLightOptions(light: GLTFLight): MarsLightOptions;
61
+ static createCameraOptions(camera: GLTFCamera): MarsCameraOptions | undefined;
62
+ static toPlayerColor3(color: spec.vec3): spec.vec3;
63
+ static toPlayerColor4(color: spec.vec4): spec.vec4;
64
+ static toPluginColor3(color: spec.vec3): spec.vec3;
65
+ static toPluginColor4(color: spec.vec4): spec.vec4;
66
+ static createUVTransform(transform?: spec.ModelTextureTransform): Matrix3 | undefined;
67
+ static clamp(val: number, minv: number, maxv: number): number;
68
+ static scaleTo255(val: number): number;
69
+ static scaleTo1(val: number): number;
70
+ static focusOnPoint(cameraPosition: spec.vec3, YRotationAngle: number, targetPoint: spec.vec3): Transform;
71
+ static preprocessMarsScene(scene: Scene, runtimeEnv: string, compatibleMode: string, autoAdjustScene: boolean): MarsSceneInfo;
72
+ static preprocessTextureOptions(index: number, textures: Array<TextureSourceOptions>, isBaseColor: boolean, tiny3dMode: boolean): void;
73
+ static setupItem3DOptions(scene: Scene, cache: CompositionCache, composition: Composition): void;
74
+ static createGeometry(engine: Engine, geomJson: spec.GeometryOptionsJSON, bins: ArrayBuffer[]): Geometry;
75
+ static getIndexArray(type: number, array: spec.TypedArray): Uint32Array | Uint8Array | Uint16Array | undefined;
76
+ static getAttributeName(name: string): string;
77
+ static getTextureObj(textures: Texture[], index?: number): Texture | undefined;
78
+ }
79
+ export declare class WebHelper {
80
+ static getImageFileName(url: string, ext?: string): string;
81
+ static getCurrnetTimeStr(): string;
82
+ static saveFileForURL(url: string, filename: string): void;
83
+ static createPlayer(): Player;
84
+ static sleep(ms: number): Promise<unknown>;
85
+ static loadImageFromGLTFImage(image: GLTFImage): Promise<HTMLImageElement>;
86
+ static loadImageFromImageData(image: PImageBufferData): Promise<HTMLImageElement>;
87
+ static getCanvasArrayBuffer(canvas: HTMLCanvasElement): Promise<ArrayBuffer>;
88
+ static getImageArrayBuffer(image: HTMLImageElement | ImageBitmap | HTMLVideoElement): Promise<ArrayBuffer>;
89
+ static getCanvasImageData(canvas: HTMLCanvasElement): ImageData;
90
+ static flipImageData(imageData: ImageData): ImageData;
91
+ static getImageData(image: HTMLImageElement | ImageBitmap | HTMLVideoElement): ImageData;
92
+ static getWebGLCanvasImageBuffer(canvas: HTMLCanvasElement): Uint8Array;
93
+ }
94
+ export declare class VertexAttribBuffer {
95
+ data: MarsRIVertexArray;
96
+ component: number;
97
+ length: number;
98
+ offset: number;
99
+ stride: number;
100
+ typeSize: number;
101
+ getBoundingBox(box: Box3): Box3;
102
+ }
103
+ declare class AttributeArray {
104
+ data: spec.TypedArray;
105
+ length: number;
106
+ offset: number;
107
+ stride: number;
108
+ typeSize: number;
109
+ compCount: number;
110
+ signed: boolean;
111
+ compressed: boolean;
112
+ compressScale: number;
113
+ create(inAttrib: Attribute, inArray: spec.TypedArray): void;
114
+ getData(index: number): [number, number, number, number] | undefined;
115
+ getLength(): number;
116
+ }
117
+ export declare class GeometryBoxProxy {
118
+ drawStart: number;
119
+ drawCount: number;
120
+ index?: spec.TypedArray;
121
+ position: AttributeArray;
122
+ joint?: AttributeArray;
123
+ weight?: AttributeArray;
124
+ bindMatrices: Matrix4[];
125
+ create(geometry: Geometry, bindMatrices: Matrix4[]): void;
126
+ getBoundingBox(box: Box3): Box3;
127
+ }
128
+ export declare class HitTestingProxy {
129
+ drawStart: number;
130
+ drawCount: number;
131
+ index?: spec.TypedArray;
132
+ position: AttributeArray;
133
+ joint?: AttributeArray;
134
+ weight?: AttributeArray;
135
+ doubleSided: boolean;
136
+ bindMatrices: Matrix4[];
137
+ hasAnimation: boolean;
138
+ skinMatrix: Matrix4;
139
+ create(geometry: Geometry, doubleSided: boolean, bindMatrices: Matrix4[]): void;
140
+ getHitPoint(rayOrigin: Vector3, rayDirection: Vector3): number | undefined;
141
+ getPosition(index: number, vec3: Vector3, vec4: Vector4): Vector3 | undefined;
142
+ }
143
+ export declare class CheckerHelper {
144
+ static checkNumber(v: number): boolean;
145
+ static checkNumberUndef(v: number | undefined): boolean;
146
+ static checkNumber01(v: number): boolean;
147
+ static checkNumber01Undef(v: number | undefined): boolean;
148
+ static checkPositive(v: number): boolean;
149
+ static checkNonnegative(v: number): boolean;
150
+ static checkNonnegativeUndef(v: number | undefined): boolean;
151
+ static checkBoolean(v: boolean): boolean;
152
+ static checkBooleanUndef(v: boolean | undefined): boolean;
153
+ static checkString(v: string): boolean;
154
+ static checkStringUndef(v: string | undefined): boolean;
155
+ static checkFloat32Array(v: Float32Array): boolean;
156
+ static checkFloat32ArrayUndef(v: Float32Array | undefined): boolean;
157
+ static checkParent(v: number | undefined): boolean;
158
+ static checkTexCoord(v: number | undefined): boolean;
159
+ static checkVec2(v: spec.vec2): boolean;
160
+ static checkVec2Undef(v?: spec.vec2): boolean;
161
+ static checkVec3(v: spec.vec3): boolean;
162
+ static checkNonnegative3(v: spec.vec3): boolean;
163
+ static checkVec4(v: spec.vec4): boolean;
164
+ static checkNonnegative4(v: spec.vec4): boolean;
165
+ static checkNumberArray(v: number[]): boolean;
166
+ static checkTexture(v: Texture): boolean;
167
+ static checkTextureUndef(v: Texture | undefined): boolean;
168
+ static checkMarsTexTransform(v: MarsTextureTransform): boolean;
169
+ static checkMarsTexTransformUndef(v: MarsTextureTransform | undefined): boolean;
170
+ static checkMarsMatBlending(v: spec.MaterialBlending | undefined): boolean;
171
+ static checkMarsMatSide(v: spec.SideMode | undefined): boolean;
172
+ static checkAnimPath(v: string): boolean;
173
+ static checkAnimInterp(v: string): boolean;
174
+ static assertGeometry(v: Geometry, s?: MarsSkinOptions): void;
175
+ static assertGeometryBuffer(v: Geometry, name: string, drawCount: number): void;
176
+ static createAttributeArray(v: Geometry, name: string): AttributeArray | undefined;
177
+ static assertMarsSkinOptions(v: MarsSkinOptions): void;
178
+ static assertMarsMatOptions(v: MarsMaterialOptions): void;
179
+ static assertMarsPrimOptions(v: MarsPrimitiveOptions, s?: MarsSkinOptions): boolean;
180
+ static assertMarsMeshOptions(v: MarsMeshOptions): void;
181
+ static assertMarsCameraOptions(v: MarsCameraOptions): void;
182
+ static assertMarsLightOptions(v: MarsLightOptions): void;
183
+ static assertMarsSkyboxOptions(v: MarsSkyboxOptions): void;
184
+ static checkMarsAnimTrackOptions(v: MarsAnimTrackOptions): boolean;
185
+ static assertMarsAnimOptions(v: MarsAnimationOptions): void;
186
+ static assertTreeOptions(v: MarsTreeOptions): void;
187
+ static stringify(object: any): string;
188
+ static pow2(index: number): number;
189
+ }
190
+ export declare class Float16ArrayWrapper {
191
+ size: number;
192
+ data: Uint16Array;
193
+ constructor(size: number);
194
+ set(number: ArrayLike<number>, startIndex: number): void;
195
+ get bytes(): number;
196
+ }
197
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { GeometryProps, Engine } from '@galacean/effects';
2
+ import { Mesh } from '@galacean/effects';
3
+ import type { Matrix4, Vector3 } from '../math';
4
+ import { Vector2 } from '../math';
5
+ export declare class FBOOptions {
6
+ resolution: Vector2;
7
+ colorAttachments: object[];
8
+ depthAttachment?: any;
9
+ constructor(options: Record<string, any>);
10
+ addDepthAttachment(options: Record<string, any>): void;
11
+ addDefaultDepthAttachment(): void;
12
+ deleteDepthAttachment(): void;
13
+ addColorAttachment(options: Record<string, any>): void;
14
+ deleteColorAttachment(target: number): void;
15
+ get viewport(): [number, number, number, number];
16
+ }
17
+ export declare class BoxMesh {
18
+ mesh: Mesh;
19
+ constructor(engine: Engine, priority: number);
20
+ update(modelMatrix: Matrix4, viewProjMatrix: Matrix4, positions: Float32Array, lineColor: Vector3): void;
21
+ dispose(): void;
22
+ get vertexShader(): string;
23
+ get fragmentShader(): string;
24
+ get geometry(): GeometryProps;
25
+ }
@@ -0,0 +1,13 @@
1
+ import type { PShaderContext, PShaderResults } from '../runtime/shader';
2
+ export declare function getPBRPassShaderCode(context: PShaderContext): PShaderResults;
3
+ export declare function getShadowPassShaderCode(context: PShaderContext): PShaderResults;
4
+ export declare function getSkyBoxShaderCode(context: PShaderContext): PShaderResults;
5
+ export declare function getQuadFilterShaderCode(context: PShaderContext): PShaderResults;
6
+ export declare function getNormalVisShaderCode(context: PShaderContext): PShaderResults;
7
+ export declare function getDiffuseOnlyShaderCode(context: PShaderContext): PShaderResults;
8
+ export declare function getKawaseBlurShaderCode(context: PShaderContext): PShaderResults;
9
+ export declare function getSimpleFilterShaderCode(context: PShaderContext): PShaderResults;
10
+ export declare function getGaussianBlurShaderCodeV2(context: PShaderContext): PShaderResults;
11
+ export declare function getGaussianBlurShaderCodeV1(context: PShaderContext): PShaderResults;
12
+ export declare function getTransparecyBaseShader(isVertexShader: boolean): string;
13
+ export declare function getTransparecyFilterShader(isVertexShader: boolean): string;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 双状态 Set,用于保存前一帧和当前帧的信息
3
+ */
4
+ export declare class TwoStatesSet<T> {
5
+ /**
6
+ * 当前帧 Set
7
+ */
8
+ now: Set<T>;
9
+ /**
10
+ * 前一帧 Set
11
+ */
12
+ last: Set<T>;
13
+ constructor();
14
+ /**
15
+ * 清空 last 和 now
16
+ */
17
+ clear(): void;
18
+ /**
19
+ * 状态前进,当前变成 last,now 被清空
20
+ */
21
+ forward(): void;
22
+ /**
23
+ * 遍历当前帧新加的元素
24
+ *
25
+ * @param callbackfn - 增加新元素的回调
26
+ */
27
+ forAddedItem(callbackfn: (value: T) => void): void;
28
+ /**
29
+ * 遍历当前帧删除的元素
30
+ *
31
+ * @param callbackfn - 删除旧元素的回调
32
+ */
33
+ forRemovedItem(callbackfn: (value: T) => void): void;
34
+ }
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@galacean/effects-plugin-model",
3
+ "version": "0.0.1-alpha.0",
4
+ "description": "Galacean Effects player model plugin",
5
+ "module": "./dist/index.mjs",
6
+ "main": "./dist/index.js",
7
+ "brower": "./dist/index.min.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.js",
16
+ "types": "./dist/index.d.ts"
17
+ },
18
+ "./dist/*": {
19
+ "import": "./dist/*.mjs",
20
+ "require": "./dist/*.js",
21
+ "types": "./dist/*.d.ts"
22
+ }
23
+ },
24
+ "contributors": [
25
+ {
26
+ "name": "飂兮"
27
+ }
28
+ ],
29
+ "author": "Ant Group CO., Ltd.",
30
+ "license": "MIT",
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "registry": "https://registry.npmjs.org"
34
+ },
35
+ "dependencies": {
36
+ "@galacean/effects-helper": "0.0.1-alpha.0"
37
+ },
38
+ "devDependencies": {
39
+ "@vvfx/resource-detection": "0.4.2-alpha.22",
40
+ "@types/hammerjs": "^2.0.41",
41
+ "fpsmeter": "^0.3.1",
42
+ "hammerjs": "^2.0.6",
43
+ "@galacean/effects-plugin-editor-gizmo": "0.0.1-alpha.0",
44
+ "@galacean/effects": "0.0.1-alpha.0"
45
+ },
46
+ "scripts": {
47
+ "dev": "vite",
48
+ "preview": "concurrently -k \"vite build -w\" \"sleep 6 && vite preview\"",
49
+ "prebuild": "pnpm clean",
50
+ "build": "pnpm build:declaration && pnpm build:module",
51
+ "build:module": "rollup -c",
52
+ "build:declaration": "tsc -d --declarationDir dist --emitDeclarationOnly",
53
+ "build:demo": "rimraf dist && vite build",
54
+ "clean": "rimraf dist && rimraf '*+(.tsbuildinfo)'"
55
+ }
56
+ }