@forgeax/engine-pack 0.1.33 → 0.1.35

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.
@@ -4,6 +4,7 @@ import type {
4
4
  MaterialPass,
5
5
  MaterialProgramAbi,
6
6
  MaterialProgramAddress,
7
+ MaterialSurfaceDeclaration,
7
8
  MaterialTextureReference,
8
9
  MaterialTextureValue,
9
10
  MaterialValue,
@@ -13,6 +14,7 @@ import {
13
14
  deriveStandardLayerPlan,
14
15
  err,
15
16
  isMaterialProgramAbi,
17
+ isMaterialSurfaceDeclaration,
16
18
  MATERIAL_TEXTURE_SLOTS,
17
19
  ok,
18
20
  } from '@forgeax/engine-types';
@@ -120,6 +122,7 @@ export interface CookedMaterialRecord {
120
122
  readonly passes: readonly MaterialPass[];
121
123
  readonly parameters: readonly MaterialParameter[];
122
124
  readonly values: Readonly<Record<string, MaterialValue | null>>;
125
+ readonly surface?: MaterialSurfaceDeclaration;
123
126
  };
124
127
  readonly refs: MaterialCookRefs;
125
128
  readonly receipt: MaterialCookReceipt;
@@ -231,7 +234,10 @@ export function collectMaterialCookRefs(material: Partial<MaterialAsset>): Mater
231
234
  return guid === undefined ? [] : [guid];
232
235
  }),
233
236
  ),
234
- modules: unique((material.passes ?? []).map((pass) => pass.program.module)),
237
+ modules: unique([
238
+ ...(material.passes ?? []).map((pass) => pass.program.module),
239
+ ...(material.surface === undefined ? [] : [material.surface.module]),
240
+ ]),
235
241
  };
236
242
  }
237
243
 
@@ -476,6 +482,8 @@ export function validateCookedMaterialRecord(
476
482
  Array.isArray(resolved.values)
477
483
  )
478
484
  return invalid('resolved.values', resolved.values);
485
+ if (resolved.surface !== undefined && !isMaterialSurfaceDeclaration(resolved.surface))
486
+ return invalid('resolved.surface', resolved.surface);
479
487
  const passes = resolved.passes as MaterialPass[];
480
488
  const passNames = new Set<string>();
481
489
  for (const [index, pass] of passes.entries()) {
@@ -256,8 +256,10 @@ function parameterValueError(
256
256
  propertyPath: string,
257
257
  ): PackAuthoringError | undefined {
258
258
  const { type } = parameter;
259
- if (type === 'bool' && typeof value !== 'boolean') {
260
- return parameterFailure(propertyPath, 'a boolean', value, 'bool value has the wrong type');
259
+ if (type === 'bool') {
260
+ return typeof value === 'boolean'
261
+ ? undefined
262
+ : parameterFailure(propertyPath, 'a boolean', value, 'bool value has the wrong type');
261
263
  }
262
264
  if (numericType(type)) {
263
265
  if (typeof value !== 'number' || !Number.isFinite(value)) {
@@ -318,8 +320,10 @@ function parameterValueError(
318
320
  }
319
321
  return undefined;
320
322
  }
321
- if (type === 'string' && typeof value !== 'string') {
322
- return parameterFailure(propertyPath, 'a string', value, 'string parameter has the wrong type');
323
+ if (type === 'string') {
324
+ return typeof value === 'string'
325
+ ? undefined
326
+ : parameterFailure(propertyPath, 'a string', value, 'string parameter has the wrong type');
323
327
  }
324
328
  if (type === 'enum') {
325
329
  if (typeof value !== 'string') {
@@ -52,7 +52,80 @@
52
52
  },
53
53
  "resolved": {
54
54
  "type": "object",
55
- "required": ["passes", "parameters", "values"]
55
+ "required": ["passes", "parameters", "values"],
56
+ "properties": {
57
+ "surface": {
58
+ "type": "object",
59
+ "required": ["model", "module"],
60
+ "properties": {
61
+ "model": {
62
+ "enum": ["standard", "single-layer-medium"]
63
+ },
64
+ "module": {
65
+ "type": "string",
66
+ "minLength": 1
67
+ },
68
+ "dynamicInput": {
69
+ "type": "object",
70
+ "required": [
71
+ "name",
72
+ "fields",
73
+ "maxRecords",
74
+ "maxDomains",
75
+ "maxPageBytes",
76
+ "maxBindings",
77
+ "maxEventsPerSample"
78
+ ],
79
+ "properties": {
80
+ "name": {
81
+ "type": "string",
82
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
83
+ },
84
+ "fields": {
85
+ "type": "array",
86
+ "minItems": 1,
87
+ "items": {
88
+ "type": "object",
89
+ "required": ["name", "type"],
90
+ "properties": {
91
+ "name": {
92
+ "type": "string",
93
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
94
+ },
95
+ "type": {
96
+ "enum": ["f32", "u32", "vec2<f32>", "vec3<f32>", "vec4<f32>"]
97
+ }
98
+ },
99
+ "additionalProperties": false
100
+ }
101
+ },
102
+ "maxRecords": {
103
+ "type": "integer",
104
+ "minimum": 1
105
+ },
106
+ "maxDomains": {
107
+ "type": "integer",
108
+ "minimum": 1
109
+ },
110
+ "maxPageBytes": {
111
+ "type": "integer",
112
+ "minimum": 1
113
+ },
114
+ "maxBindings": {
115
+ "type": "integer",
116
+ "minimum": 1
117
+ },
118
+ "maxEventsPerSample": {
119
+ "type": "integer",
120
+ "minimum": 1
121
+ }
122
+ },
123
+ "additionalProperties": false
124
+ }
125
+ },
126
+ "additionalProperties": false
127
+ }
128
+ }
56
129
  },
57
130
  "refs": {
58
131
  "type": "object",