protosprite-geom 0.2.1 → 0.2.2

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 { ProtoSpriteSheet } from "protosprite-core";
2
- import { SpriteGeometryData } from "./data.js";
2
+ import { ConvexDecompositionData, PolygonData, SpriteGeometryData, SpriteGeometryEntryData } from "./data.js";
3
3
  export declare class ProtoSpriteGeometry {
4
4
  data: SpriteGeometryData;
5
5
  constructor(data?: SpriteGeometryData);
@@ -9,4 +9,20 @@ export declare class ProtoSpriteGeometry {
9
9
  getSpriteSheet(): ProtoSpriteSheet;
10
10
  embedSpriteSheet(sheet: ProtoSpriteSheet): void;
11
11
  referenceSpriteSheet(fileNameOrUrl: string): void;
12
+ getEntry(spriteName: string): SpriteGeometryEntryData | undefined;
13
+ getFrameGeometry(spriteName: string, frameIndex: number): ResolvedFrameGeometry | undefined;
14
+ }
15
+ export interface ResolvedLayerGeometry {
16
+ layerIndex: number;
17
+ polygons: PolygonData[];
18
+ convexDecompositions: ConvexDecompositionData[];
19
+ }
20
+ export interface ResolvedCompositeGeometry {
21
+ polygons: PolygonData[];
22
+ convexDecompositions: ConvexDecompositionData[];
23
+ }
24
+ export interface ResolvedFrameGeometry {
25
+ frameIndex: number;
26
+ layers: ResolvedLayerGeometry[];
27
+ composite?: ResolvedCompositeGeometry;
12
28
  }
@@ -1,7 +1,7 @@
1
1
  import { fromBinary, toBinary, toJson } from '@bufbuild/protobuf';
2
2
  import { ProtoSpriteSheet } from 'protosprite-core';
3
3
  import { SpriteGeometrySchema } from '../../proto_dist/sprite_geometry_pb.js';
4
- import { SpriteGeometryData } from './data.js';
4
+ import { SpriteGeometryData, ConvexDecompositionData, PolygonData } from './data.js';
5
5
  import fs from 'fs';
6
6
 
7
7
  class ProtoSpriteGeometry {
@@ -57,6 +57,59 @@ class ProtoSpriteGeometry {
57
57
  };
58
58
  }
59
59
  }
60
+ getEntry(spriteName) {
61
+ return this.data.entries.find((e) => e.spriteName === spriteName);
62
+ }
63
+ getFrameGeometry(spriteName, frameIndex) {
64
+ const entry = this.getEntry(spriteName);
65
+ if (!entry)
66
+ return undefined;
67
+ const frameGeom = entry.frames.find((f) => f.frameIndex === frameIndex);
68
+ if (!frameGeom)
69
+ return undefined;
70
+ const shapePool = entry.shapePool;
71
+ const vertexPool = entry.vertexPool;
72
+ const resolveIndexedPolygon = (indexed) => {
73
+ const poly = new PolygonData();
74
+ poly.vertices = indexed.vertexIndices.map((vi) => vertexPool[vi]);
75
+ return poly;
76
+ };
77
+ const resolveShape = (idx) => {
78
+ const shape = shapePool[idx];
79
+ if (!shape)
80
+ return undefined;
81
+ const polygon = resolveIndexedPolygon(shape.polygon);
82
+ const decomposition = new ConvexDecompositionData();
83
+ decomposition.components = shape.convexDecompositionComponents.map(resolveIndexedPolygon);
84
+ return { polygon, decomposition };
85
+ };
86
+ const layers = frameGeom.layers.map((layer) => {
87
+ const polygons = [];
88
+ const convexDecompositions = [];
89
+ for (const idx of layer.shapeIndices) {
90
+ const resolved = resolveShape(idx);
91
+ if (resolved) {
92
+ polygons.push(resolved.polygon);
93
+ convexDecompositions.push(resolved.decomposition);
94
+ }
95
+ }
96
+ return { layerIndex: layer.layerIndex, polygons, convexDecompositions };
97
+ });
98
+ let composite;
99
+ if (frameGeom.composite) {
100
+ const polygons = [];
101
+ const convexDecompositions = [];
102
+ for (const idx of frameGeom.composite.shapeIndices) {
103
+ const resolved = resolveShape(idx);
104
+ if (resolved) {
105
+ polygons.push(resolved.polygon);
106
+ convexDecompositions.push(resolved.decomposition);
107
+ }
108
+ }
109
+ composite = { polygons, convexDecompositions };
110
+ }
111
+ return { frameIndex: frameGeom.frameIndex, layers, composite };
112
+ }
60
113
  }
61
114
 
62
115
  export { ProtoSpriteGeometry };
@@ -1 +1 @@
1
- {"version":3,"file":"protosprite-geom.js","sources":["../../../src/core/protosprite-geom.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;MAM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';
2
2
  import { Jimp } from 'jimp';
3
3
  import { ProtoSpriteInstance, Data } from 'protosprite-core';
4
4
  import { renderSpriteInstance } from 'protosprite-core/transform';
5
- import { SpriteGeometryEntryData, FrameGeometryData, FrameLayerGeometryData, CompositeFrameGeometryData, SpriteGeometryData, PolygonData, ConvexDecompositionData } from './src/core/data.js';
5
+ import { SpriteGeometryEntryData, FrameGeometryData, FrameLayerGeometryData, CompositeFrameGeometryData, SpriteGeometryData, PolygonData, ConvexDecompositionData, IndexedPolygonData, ShapePoolEntryData } from './src/core/data.js';
6
6
  import { decomposeConvex } from './src/trace/convex.js';
7
7
  import { simplifyPolygon } from './src/trace/simplify.js';
8
8
  import { traceContours } from './src/trace/trace.js';
@@ -45,6 +45,58 @@ function traceAndProcess(imageData, tolerance, alphaThreshold, highQuality) {
45
45
  }
46
46
  return { polygons, convexDecompositions };
47
47
  }
48
+ class VertexPoolBuilder {
49
+ pool = [];
50
+ hashMap = new Map();
51
+ addVertex(v) {
52
+ const key = `${v.x},${v.y}`;
53
+ const existing = this.hashMap.get(key);
54
+ if (existing !== undefined) {
55
+ return existing;
56
+ }
57
+ const index = this.pool.length;
58
+ this.pool.push(v);
59
+ this.hashMap.set(key, index);
60
+ return index;
61
+ }
62
+ getPool() {
63
+ return this.pool;
64
+ }
65
+ }
66
+ class ShapePoolBuilder {
67
+ pool = [];
68
+ hashMap = new Map();
69
+ vertexBuilder;
70
+ constructor(vertexBuilder) {
71
+ this.vertexBuilder = vertexBuilder;
72
+ }
73
+ indexPolygon(polygon) {
74
+ const indexed = new IndexedPolygonData();
75
+ indexed.vertexIndices = polygon.vertices.map((v) => this.vertexBuilder.addVertex(v));
76
+ return indexed;
77
+ }
78
+ hashIndexedPolygon(indexed) {
79
+ return indexed.vertexIndices.join(";");
80
+ }
81
+ addShape(polygon, decomposition) {
82
+ const indexedPolygon = this.indexPolygon(polygon);
83
+ const key = this.hashIndexedPolygon(indexedPolygon);
84
+ const existing = this.hashMap.get(key);
85
+ if (existing !== undefined) {
86
+ return existing;
87
+ }
88
+ const index = this.pool.length;
89
+ const entry = new ShapePoolEntryData();
90
+ entry.polygon = indexedPolygon;
91
+ entry.convexDecompositionComponents = decomposition.components.map((c) => this.indexPolygon(c));
92
+ this.pool.push(entry);
93
+ this.hashMap.set(key, index);
94
+ return index;
95
+ }
96
+ getPool() {
97
+ return this.pool;
98
+ }
99
+ }
48
100
  async function traceSpriteSheet(sheet, options) {
49
101
  const { tolerance, alphaThreshold = 1, highQuality = true, composite = true, perLayer = false } = options;
50
102
  const result = new SpriteGeometryData();
@@ -57,6 +109,8 @@ async function traceSpriteSheet(sheet, options) {
57
109
  const entry = new SpriteGeometryEntryData();
58
110
  entry.spriteName = sprite.data.name;
59
111
  entry.simplifyTolerance = tolerance;
112
+ const vertexBuilder = new VertexPoolBuilder();
113
+ const poolBuilder = new ShapePoolBuilder(vertexBuilder);
60
114
  // Try sprite-level pixel source, fall back to sheet image.
61
115
  let spriteImg = sheetImg;
62
116
  if (sprite.data.pixelSource) {
@@ -107,8 +161,11 @@ async function traceSpriteSheet(sheet, options) {
107
161
  }
108
162
  }
109
163
  }
110
- layerGeom.polygons = polygons;
111
- layerGeom.convexDecompositions = convexDecompositions;
164
+ const shapeIndices = [];
165
+ for (let i = 0; i < polygons.length; i++) {
166
+ shapeIndices.push(poolBuilder.addShape(polygons[i], convexDecompositions[i]));
167
+ }
168
+ layerGeom.shapeIndices = shapeIndices;
112
169
  frameGeom.layers.push(layerGeom);
113
170
  }
114
171
  }
@@ -124,12 +181,17 @@ async function traceSpriteSheet(sheet, options) {
124
181
  };
125
182
  const { polygons, convexDecompositions } = traceAndProcess(compositeImageData, tolerance, alphaThreshold, highQuality);
126
183
  const compositeGeom = new CompositeFrameGeometryData();
127
- compositeGeom.polygons = polygons;
128
- compositeGeom.convexDecompositions = convexDecompositions;
184
+ const shapeIndices = [];
185
+ for (let i = 0; i < polygons.length; i++) {
186
+ shapeIndices.push(poolBuilder.addShape(polygons[i], convexDecompositions[i]));
187
+ }
188
+ compositeGeom.shapeIndices = shapeIndices;
129
189
  frameGeom.composite = compositeGeom;
130
190
  }
131
191
  entry.frames.push(frameGeom);
132
192
  }
193
+ entry.shapePool = poolBuilder.getPool();
194
+ entry.vertexPool = vertexBuilder.getPool();
133
195
  result.entries.push(entry);
134
196
  }
135
197
  return result;
package/dist/trace.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"trace.js","sources":["../src/trace/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAwCA,eAAe,eAAe,CAC5B,WAAwB,EAAA;AAExB,IAAA,IAAI,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC,EAAE;AAC/C,QAAA,IAAI,WAAW,CAAC,OAAO,EAAE;AACvB,YAAA,MAAM,GAAG,GAAG,CAAA,sBAAA,EAAyB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;AAC1F,YAAA,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;QAC5C;AACA,QAAA,OAAO,IAAI;IACb;AACA,IAAA,IAAI,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC,EAAE;QAC/C,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,IAAI,WAAW,CAAC,QAAQ;AAC7D,QAAA,IAAI,CAAC,aAAa;AAAE,YAAA,OAAO,IAAI;AAC/B,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACtD;AACA,IAAA,OAAO,IAAI;AACb;AAEA,SAAS,eAAe,CACtB,SAAuE,EACvE,SAAiB,EACjB,cAAsB,EACtB,WAAoB,EAAA;IAKpB,MAAM,WAAW,GAAG,aAAa,CAAC,SAAS,EAAE,cAAc,CAAC;IAC5D,MAAM,QAAQ,GAAkB,EAAE;IAClC,MAAM,oBAA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AACzC,gBAAA,SAAS,CAAC,SAAS,GAAG,aAAa;YACrC;AAEA,YAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;QAC9B;AAEA,QAAA,KAAK,CAAC,SAAS,GAAG,WAAW,CAAC,OAAO,EAAE;AACvC,QAAA,KAAK,CAAC,UAAU,GAAG,aAAa,CAAC,OAAO,EAAE;AAC1C,QAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;IAC5B;AAEA,IAAA,OAAO,MAAM;AACf;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "protosprite-geom",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "description": "Polygon geometry tracing and encoding for protosprite",
6
6
  "main": "dist/core.js",
7
7
  "types": "dist/src/core/index.d.ts",
@@ -48,7 +48,7 @@
48
48
  "jimp": "^1.6.0",
49
49
  "marchingsquares": "^1.3.3",
50
50
  "poly-decomp": "^0.3.0",
51
- "protosprite-core": "^0.2.1",
51
+ "protosprite-core": "^0.2.2",
52
52
  "simplify-js": "^1.2.4",
53
53
  "tslib": "^2.8.1",
54
54
  "typescript": "^5.9.2"
@@ -57,5 +57,5 @@
57
57
  "@rollup/plugin-typescript": "^12.1.4",
58
58
  "rollup": "^4.48.1"
59
59
  },
60
- "gitHead": "a7f24c356afc5fb28bc5cacc3d0ecc18ac67b5fb"
60
+ "gitHead": "842676edbb77aff985b2d3acd67324be4cecd753"
61
61
  }
@@ -10,7 +10,7 @@ import type { Message } from "@bufbuild/protobuf";
10
10
  * Describes the file sprite_geometry.proto.
11
11
  */
12
12
  export const file_sprite_geometry: GenFile = /*@__PURE__*/
13
- fileDesc("ChVzcHJpdGVfZ2VvbWV0cnkucHJvdG8SC3Byb3Rvc3ByaXRlIhwKBFZlYzISCQoBeBgBIAEoAhIJCgF5GAIgASgCIi4KB1BvbHlnb24SIwoIdmVydGljZXMYASADKAsyES5wcm90b3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LlZlYzIipQEKDlNwcml0ZUdlb21ldHJ5EjEKB2VudHJpZXMYASADKAsyIC5wcm90b3Nwcml0ZS5TcHJpdGVHZW9tZXRyeUVudHJ5EhYKDGVtYmVkZGVkX3BycxgCIAEoDEgAEhsKEWV4dGVybmFsX3Byc19maWxlGAMgASgJSAASGgoQZXh0ZXJuYWxfcHJzX3VybBgEIAEoCUgAQg8KDXNwcml0ZV9zb3VyY2ViBnByb3RvMw");
14
14
 
15
15
  /**
16
16
  * A 2D point with float precision (polygon vertices need sub-pixel accuracy
@@ -117,6 +117,80 @@ export type ConvexDecompositionJson = {
117
117
  export const ConvexDecompositionSchema: GenMessage<ConvexDecomposition, {jsonType: ConvexDecompositionJson}> = /*@__PURE__*/
118
118
  messageDesc(file_sprite_geometry, 2);
119
119
 
120
+ /**
121
+ * A polygon represented as indices into a vertex pool.
122
+ *
123
+ * @generated from message protosprite.IndexedPolygon
124
+ */
125
+ export type IndexedPolygon = Message<"protosprite.IndexedPolygon"> & {
126
+ /**
127
+ * @generated from field: repeated int32 vertex_indices = 1;
128
+ */
129
+ vertexIndices: number[];
130
+ };
131
+
132
+ /**
133
+ * A polygon represented as indices into a vertex pool.
134
+ *
135
+ * @generated from message protosprite.IndexedPolygon
136
+ */
137
+ export type IndexedPolygonJson = {
138
+ /**
139
+ * @generated from field: repeated int32 vertex_indices = 1;
140
+ */
141
+ vertexIndices?: number[];
142
+ };
143
+
144
+ /**
145
+ * Describes the message protosprite.IndexedPolygon.
146
+ * Use `create(IndexedPolygonSchema)` to create a new message.
147
+ */
148
+ export const IndexedPolygonSchema: GenMessage<IndexedPolygon, {jsonType: IndexedPolygonJson}> = /*@__PURE__*/
149
+ messageDesc(file_sprite_geometry, 3);
150
+
151
+ /**
152
+ * A de-duplicated (polygon, convex decomposition) pair stored in the shape pool.
153
+ * Vertices are referenced by index into the parent SpriteGeometryEntry.vertex_pool.
154
+ *
155
+ * @generated from message protosprite.ShapePoolEntry
156
+ */
157
+ export type ShapePoolEntry = Message<"protosprite.ShapePoolEntry"> & {
158
+ /**
159
+ * @generated from field: protosprite.IndexedPolygon polygon = 1;
160
+ */
161
+ polygon?: IndexedPolygon;
162
+
163
+ /**
164
+ * @generated from field: repeated protosprite.IndexedPolygon convex_decomposition_components = 2;
165
+ */
166
+ convexDecompositionComponents: IndexedPolygon[];
167
+ };
168
+
169
+ /**
170
+ * A de-duplicated (polygon, convex decomposition) pair stored in the shape pool.
171
+ * Vertices are referenced by index into the parent SpriteGeometryEntry.vertex_pool.
172
+ *
173
+ * @generated from message protosprite.ShapePoolEntry
174
+ */
175
+ export type ShapePoolEntryJson = {
176
+ /**
177
+ * @generated from field: protosprite.IndexedPolygon polygon = 1;
178
+ */
179
+ polygon?: IndexedPolygonJson;
180
+
181
+ /**
182
+ * @generated from field: repeated protosprite.IndexedPolygon convex_decomposition_components = 2;
183
+ */
184
+ convexDecompositionComponents?: IndexedPolygonJson[];
185
+ };
186
+
187
+ /**
188
+ * Describes the message protosprite.ShapePoolEntry.
189
+ * Use `create(ShapePoolEntrySchema)` to create a new message.
190
+ */
191
+ export const ShapePoolEntrySchema: GenMessage<ShapePoolEntry, {jsonType: ShapePoolEntryJson}> = /*@__PURE__*/
192
+ messageDesc(file_sprite_geometry, 4);
193
+
120
194
  /**
121
195
  * Traced geometry for one layer within one frame.
122
196
  *
@@ -129,18 +203,12 @@ export type FrameLayerGeometry = Message<"protosprite.FrameLayerGeometry"> & {
129
203
  layerIndex: number;
130
204
 
131
205
  /**
132
- * The raw traced & simplified outer polygon(s) one per disjoint region.
133
- *
134
- * @generated from field: repeated protosprite.Polygon polygons = 2;
135
- */
136
- polygons: Polygon[];
137
-
138
- /**
139
- * Convex decompositions corresponding 1:1 to `polygons`.
206
+ * Fields 2 and 3 removed (previously polygons / convex_decompositions).
207
+ * Indices into the parent SpriteGeometryEntry.shape_pool.
140
208
  *
141
- * @generated from field: repeated protosprite.ConvexDecomposition convex_decompositions = 3;
209
+ * @generated from field: repeated int32 shape_indices = 4;
142
210
  */
143
- convexDecompositions: ConvexDecomposition[];
211
+ shapeIndices: number[];
144
212
  };
145
213
 
146
214
  /**
@@ -155,18 +223,12 @@ export type FrameLayerGeometryJson = {
155
223
  layerIndex?: number;
156
224
 
157
225
  /**
158
- * The raw traced & simplified outer polygon(s) one per disjoint region.
226
+ * Fields 2 and 3 removed (previously polygons / convex_decompositions).
227
+ * Indices into the parent SpriteGeometryEntry.shape_pool.
159
228
  *
160
- * @generated from field: repeated protosprite.Polygon polygons = 2;
229
+ * @generated from field: repeated int32 shape_indices = 4;
161
230
  */
162
- polygons?: PolygonJson[];
163
-
164
- /**
165
- * Convex decompositions corresponding 1:1 to `polygons`.
166
- *
167
- * @generated from field: repeated protosprite.ConvexDecomposition convex_decompositions = 3;
168
- */
169
- convexDecompositions?: ConvexDecompositionJson[];
231
+ shapeIndices?: number[];
170
232
  };
171
233
 
172
234
  /**
@@ -174,7 +236,7 @@ export type FrameLayerGeometryJson = {
174
236
  * Use `create(FrameLayerGeometrySchema)` to create a new message.
175
237
  */
176
238
  export const FrameLayerGeometrySchema: GenMessage<FrameLayerGeometry, {jsonType: FrameLayerGeometryJson}> = /*@__PURE__*/
177
- messageDesc(file_sprite_geometry, 3);
239
+ messageDesc(file_sprite_geometry, 5);
178
240
 
179
241
  /**
180
242
  * Composite geometry for the entire frame (all layers flattened).
@@ -184,18 +246,12 @@ export const FrameLayerGeometrySchema: GenMessage<FrameLayerGeometry, {jsonType:
184
246
  */
185
247
  export type CompositeFrameGeometry = Message<"protosprite.CompositeFrameGeometry"> & {
186
248
  /**
187
- * Traced & simplified polygons for the composited frame image.
249
+ * Fields 1 and 2 removed (previously polygons / convex_decompositions).
250
+ * Indices into the parent SpriteGeometryEntry.shape_pool.
188
251
  *
189
- * @generated from field: repeated protosprite.Polygon polygons = 1;
252
+ * @generated from field: repeated int32 shape_indices = 3;
190
253
  */
191
- polygons: Polygon[];
192
-
193
- /**
194
- * Convex decompositions corresponding 1:1 to `polygons`.
195
- *
196
- * @generated from field: repeated protosprite.ConvexDecomposition convex_decompositions = 2;
197
- */
198
- convexDecompositions: ConvexDecomposition[];
254
+ shapeIndices: number[];
199
255
  };
200
256
 
201
257
  /**
@@ -206,18 +262,12 @@ export type CompositeFrameGeometry = Message<"protosprite.CompositeFrameGeometry
206
262
  */
207
263
  export type CompositeFrameGeometryJson = {
208
264
  /**
209
- * Traced & simplified polygons for the composited frame image.
210
- *
211
- * @generated from field: repeated protosprite.Polygon polygons = 1;
212
- */
213
- polygons?: PolygonJson[];
214
-
215
- /**
216
- * Convex decompositions corresponding 1:1 to `polygons`.
265
+ * Fields 1 and 2 removed (previously polygons / convex_decompositions).
266
+ * Indices into the parent SpriteGeometryEntry.shape_pool.
217
267
  *
218
- * @generated from field: repeated protosprite.ConvexDecomposition convex_decompositions = 2;
268
+ * @generated from field: repeated int32 shape_indices = 3;
219
269
  */
220
- convexDecompositions?: ConvexDecompositionJson[];
270
+ shapeIndices?: number[];
221
271
  };
222
272
 
223
273
  /**
@@ -225,7 +275,7 @@ export type CompositeFrameGeometryJson = {
225
275
  * Use `create(CompositeFrameGeometrySchema)` to create a new message.
226
276
  */
227
277
  export const CompositeFrameGeometrySchema: GenMessage<CompositeFrameGeometry, {jsonType: CompositeFrameGeometryJson}> = /*@__PURE__*/
228
- messageDesc(file_sprite_geometry, 4);
278
+ messageDesc(file_sprite_geometry, 6);
229
279
 
230
280
  /**
231
281
  * Geometry for an entire frame.
@@ -282,7 +332,7 @@ export type FrameGeometryJson = {
282
332
  * Use `create(FrameGeometrySchema)` to create a new message.
283
333
  */
284
334
  export const FrameGeometrySchema: GenMessage<FrameGeometry, {jsonType: FrameGeometryJson}> = /*@__PURE__*/
285
- messageDesc(file_sprite_geometry, 5);
335
+ messageDesc(file_sprite_geometry, 7);
286
336
 
287
337
  /**
288
338
  * Top-level geometry container for one sprite.
@@ -306,6 +356,20 @@ export type SpriteGeometryEntry = Message<"protosprite.SpriteGeometryEntry"> & {
306
356
  * @generated from field: float simplify_tolerance = 3;
307
357
  */
308
358
  simplifyTolerance: number;
359
+
360
+ /**
361
+ * De-duplicated shape pool. Frames reference shapes by index into this pool.
362
+ *
363
+ * @generated from field: repeated protosprite.ShapePoolEntry shape_pool = 4;
364
+ */
365
+ shapePool: ShapePoolEntry[];
366
+
367
+ /**
368
+ * De-duplicated vertex pool. ShapePoolEntry indices reference vertices here.
369
+ *
370
+ * @generated from field: repeated protosprite.Vec2 vertex_pool = 5;
371
+ */
372
+ vertexPool: Vec2[];
309
373
  };
310
374
 
311
375
  /**
@@ -330,6 +394,20 @@ export type SpriteGeometryEntryJson = {
330
394
  * @generated from field: float simplify_tolerance = 3;
331
395
  */
332
396
  simplifyTolerance?: number | "NaN" | "Infinity" | "-Infinity";
397
+
398
+ /**
399
+ * De-duplicated shape pool. Frames reference shapes by index into this pool.
400
+ *
401
+ * @generated from field: repeated protosprite.ShapePoolEntry shape_pool = 4;
402
+ */
403
+ shapePool?: ShapePoolEntryJson[];
404
+
405
+ /**
406
+ * De-duplicated vertex pool. ShapePoolEntry indices reference vertices here.
407
+ *
408
+ * @generated from field: repeated protosprite.Vec2 vertex_pool = 5;
409
+ */
410
+ vertexPool?: Vec2Json[];
333
411
  };
334
412
 
335
413
  /**
@@ -337,7 +415,7 @@ export type SpriteGeometryEntryJson = {
337
415
  * Use `create(SpriteGeometryEntrySchema)` to create a new message.
338
416
  */
339
417
  export const SpriteGeometryEntrySchema: GenMessage<SpriteGeometryEntry, {jsonType: SpriteGeometryEntryJson}> = /*@__PURE__*/
340
- messageDesc(file_sprite_geometry, 6);
418
+ messageDesc(file_sprite_geometry, 8);
341
419
 
342
420
  /**
343
421
  * Root message serialized into .prsg files.
@@ -420,5 +498,5 @@ export type SpriteGeometryJson = {
420
498
  * Use `create(SpriteGeometrySchema)` to create a new message.
421
499
  */
422
500
  export const SpriteGeometrySchema: GenMessage<SpriteGeometry, {jsonType: SpriteGeometryJson}> = /*@__PURE__*/
423
- messageDesc(file_sprite_geometry, 7);
501
+ messageDesc(file_sprite_geometry, 9);
424
502