@threenative/ueformat 0.1.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.
@@ -0,0 +1,187 @@
1
+ import * as three from 'three';
2
+ import { Material, Group, LOD, Object3D, BufferGeometry, Loader, LoadingManager } from 'three';
3
+
4
+ interface IVector2 {
5
+ u: number;
6
+ v: number;
7
+ }
8
+ interface IVector3 {
9
+ x: number;
10
+ y: number;
11
+ z: number;
12
+ }
13
+ interface IQuaternion extends IVector3 {
14
+ w: number;
15
+ }
16
+ interface IUEFormatCompression {
17
+ format: "GZIP" | "ZSTD";
18
+ uncompressedSize: number;
19
+ compressedSize: number;
20
+ }
21
+ interface IUEFormatHeader {
22
+ magic: "UEFORMAT";
23
+ identifier: "UEMODEL";
24
+ fileVersion: 10;
25
+ objectName: string;
26
+ objectPath: string;
27
+ compression: IUEFormatCompression | null;
28
+ }
29
+ interface IUEModelNormal extends IVector3 {
30
+ binormalSign: number;
31
+ }
32
+ interface IUEModelTexCoord {
33
+ name: string;
34
+ uvs: IVector2[];
35
+ }
36
+ interface IUEModelVertexColor {
37
+ name: string;
38
+ colors: Array<{
39
+ r: number;
40
+ g: number;
41
+ b: number;
42
+ a: number;
43
+ }>;
44
+ }
45
+ interface IUEModelMaterial {
46
+ materialName: string;
47
+ materialPath: string;
48
+ firstIndex: number;
49
+ numFaces: number;
50
+ }
51
+ interface IUEModelWeight {
52
+ boneIndex: number;
53
+ vertexIndex: number;
54
+ weight: number;
55
+ }
56
+ interface IUEModelMorphDelta {
57
+ positionDelta: IVector3;
58
+ tangentZDelta: IVector3;
59
+ vertexIndex: number;
60
+ }
61
+ interface IUEModelMorphTarget {
62
+ name: string;
63
+ deltas: IUEModelMorphDelta[];
64
+ }
65
+ interface IUEModelLOD {
66
+ name: string;
67
+ vertices: IVector3[];
68
+ normals: IUEModelNormal[];
69
+ tangents: IVector3[];
70
+ texCoords: IUEModelTexCoord[];
71
+ indices: number[];
72
+ vertexColors: IUEModelVertexColor[];
73
+ materials: IUEModelMaterial[];
74
+ weights: IUEModelWeight[];
75
+ morphTargets: IUEModelMorphTarget[];
76
+ unknownAttributes: string[];
77
+ }
78
+ interface IUEModelBone {
79
+ name: string;
80
+ parentIndex: number;
81
+ position: IVector3;
82
+ orientation: IQuaternion;
83
+ scale: IVector3;
84
+ }
85
+ interface IUEModelSocket {
86
+ name: string;
87
+ boneName: string;
88
+ relativeLocation: IVector3;
89
+ relativeRotation: IQuaternion;
90
+ relativeScale: IVector3;
91
+ }
92
+ interface IUEModelVirtualBone {
93
+ sourceBoneName: string;
94
+ targetBoneName: string;
95
+ virtualBoneName: string;
96
+ }
97
+ interface IUEModelSkeleton {
98
+ metadata: string;
99
+ bones: IUEModelBone[];
100
+ sockets: IUEModelSocket[];
101
+ virtualBones: IUEModelVirtualBone[];
102
+ unknownAttributes: string[];
103
+ }
104
+ interface IUEModelCollision {
105
+ name: string;
106
+ vertices: IVector3[];
107
+ indices: number[];
108
+ }
109
+ interface IUEModelData {
110
+ header: IUEFormatHeader;
111
+ lods: IUEModelLOD[];
112
+ skeleton: IUEModelSkeleton | null;
113
+ collision: IUEModelCollision[];
114
+ unknownAttributes: string[];
115
+ }
116
+ type ZstdDecoder = (compressed: Uint8Array, uncompressedSize: number) => Uint8Array;
117
+ interface IParseUEModelOptions {
118
+ zstdDecoder?: ZstdDecoder;
119
+ maxStringBytes?: number;
120
+ maxArrayElements?: number;
121
+ maxAttributes?: number;
122
+ }
123
+
124
+ declare function parseUEModel(input: ArrayBuffer | ArrayBufferView, options?: IParseUEModelOptions): IUEModelData;
125
+
126
+ type UECoordinateSystem = "three-y-up" | "unreal-z-up";
127
+ type WindingRepair = "auto" | "always" | "never";
128
+ interface IThreeAdapterOptions {
129
+ coordinateSystem?: UECoordinateSystem;
130
+ unitScale?: number;
131
+ flipV?: boolean;
132
+ repairWinding?: WindingRepair;
133
+ lodDistances?: readonly number[];
134
+ materialFactory?: (slot: IUEModelMaterial, materialIndex: number, lod: IUEModelLOD) => Material;
135
+ }
136
+ declare function createThreeGeometry(lod: IUEModelLOD, adapterOptions?: IThreeAdapterOptions): BufferGeometry;
137
+ declare function createThreeObject(model: IUEModelData, adapterOptions?: IThreeAdapterOptions): Group | LOD;
138
+ type UEFormatThreeObject = Group | LOD | Object3D;
139
+
140
+ interface IUEFormatLoaderOptions {
141
+ parse?: IParseUEModelOptions;
142
+ three?: IThreeAdapterOptions;
143
+ }
144
+ declare class UEFormatLoader extends Loader {
145
+ readonly options: IUEFormatLoaderOptions;
146
+ constructor(manager?: LoadingManager, options?: IUEFormatLoaderOptions);
147
+ parse(data: ArrayBuffer | ArrayBufferView): three.Group<three.Object3DEventMap> | three.LOD<three.Object3DEventMap>;
148
+ load(url: string, onLoad: (object: ReturnType<UEFormatLoader["parse"]>) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): this;
149
+ }
150
+
151
+ interface IUEModelSummary {
152
+ objectName: string;
153
+ objectPath: string;
154
+ formatVersion: number;
155
+ compression: string | null;
156
+ lods: Array<{
157
+ name: string;
158
+ vertices: number;
159
+ triangles: number;
160
+ materials: string[];
161
+ uvChannels: string[];
162
+ vertexColorChannels: string[];
163
+ weights: number;
164
+ morphTargets: string[];
165
+ }>;
166
+ skeleton: {
167
+ bones: number;
168
+ sockets: number;
169
+ virtualBones: number;
170
+ } | null;
171
+ collisionMeshes: Array<{
172
+ name: string;
173
+ vertices: number;
174
+ triangles: number;
175
+ }>;
176
+ unknownAttributes: string[];
177
+ }
178
+ declare function summarizeUEModel(model: IUEModelData): IUEModelSummary;
179
+
180
+ type UEFormatErrorCode = "TRUNCATED_FILE" | "INVALID_MAGIC" | "INVALID_IDENTIFIER" | "UNSUPPORTED_VERSION" | "INVALID_LENGTH" | "INVALID_COUNT" | "INVALID_COMPRESSION" | "DECOMPRESSION_FAILED" | "SIZE_MISMATCH" | "ATTRIBUTE_SIZE_MISMATCH" | "INVALID_GEOMETRY";
181
+ declare class UEFormatError extends Error {
182
+ readonly code: UEFormatErrorCode;
183
+ readonly offset: number;
184
+ constructor(code: UEFormatErrorCode, message: string, offset?: number, cause?: unknown);
185
+ }
186
+
187
+ export { type IParseUEModelOptions, type IQuaternion, type IThreeAdapterOptions, type IUEFormatCompression, type IUEFormatHeader, type IUEFormatLoaderOptions, type IUEModelBone, type IUEModelCollision, type IUEModelData, type IUEModelLOD, type IUEModelMaterial, type IUEModelMorphDelta, type IUEModelMorphTarget, type IUEModelNormal, type IUEModelSkeleton, type IUEModelSocket, type IUEModelSummary, type IUEModelTexCoord, type IUEModelVertexColor, type IUEModelVirtualBone, type IUEModelWeight, type IVector2, type IVector3, type UECoordinateSystem, UEFormatError, type UEFormatErrorCode, UEFormatLoader, type UEFormatThreeObject, type WindingRepair, type ZstdDecoder, createThreeGeometry, createThreeObject, parseUEModel, summarizeUEModel };