@holoscript/std 7.0.0 → 7.0.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.
Files changed (132) hide show
  1. package/README.md +8 -0
  2. package/dist/chunk-DGUM43GV.js +11 -0
  3. package/dist/{chunk-PFX2JM4X.js → chunk-FAMOLKH3.js} +2 -1
  4. package/dist/{chunk-PFX2JM4X.js.map → chunk-FAMOLKH3.js.map} +1 -1
  5. package/dist/{chunk-DZHAVOCH.js → chunk-SOKH6FJ7.js} +31 -6
  6. package/dist/chunk-SOKH6FJ7.js.map +1 -0
  7. package/dist/collections.cjs +1 -0
  8. package/dist/collections.cjs.map +1 -1
  9. package/dist/collections.js +2 -2
  10. package/dist/fs/fs.d.ts.map +1 -1
  11. package/dist/fs/index.cjs +221 -8510
  12. package/dist/fs/index.cjs.map +1 -1
  13. package/dist/fs/index.js +832 -118
  14. package/dist/fs/index.js.map +1 -1
  15. package/dist/fs/sandbox.d.ts +49 -0
  16. package/dist/fs/sandbox.d.ts.map +1 -0
  17. package/dist/index.cjs +3494 -12672
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +0 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +17 -7
  22. package/dist/index.js.map +1 -1
  23. package/dist/math.cjs +18 -3
  24. package/dist/math.cjs.map +1 -1
  25. package/dist/math.js +2 -2
  26. package/dist/string.js +1 -1
  27. package/dist/time.js +1 -1
  28. package/dist/traits/EconomicPrimitives.js +1 -1
  29. package/dist/traits/EconomicTraits.js +1 -1
  30. package/dist/types.d.ts.map +1 -1
  31. package/package.json +19 -9
  32. package/dist/__tests__/EconomicPrimitives.test.d.ts +0 -2
  33. package/dist/__tests__/EconomicPrimitives.test.d.ts.map +0 -1
  34. package/dist/__tests__/EconomicTraits.test.d.ts +0 -2
  35. package/dist/__tests__/EconomicTraits.test.d.ts.map +0 -1
  36. package/dist/__tests__/SimulationLabPrimitives.test.d.ts +0 -2
  37. package/dist/__tests__/SimulationLabPrimitives.test.d.ts.map +0 -1
  38. package/dist/__tests__/collections.test.d.ts +0 -2
  39. package/dist/__tests__/collections.test.d.ts.map +0 -1
  40. package/dist/__tests__/events.test.d.ts +0 -2
  41. package/dist/__tests__/events.test.d.ts.map +0 -1
  42. package/dist/__tests__/index.test.d.ts +0 -2
  43. package/dist/__tests__/index.test.d.ts.map +0 -1
  44. package/dist/__tests__/materials.test.d.ts +0 -2
  45. package/dist/__tests__/materials.test.d.ts.map +0 -1
  46. package/dist/__tests__/math.test.d.ts +0 -2
  47. package/dist/__tests__/math.test.d.ts.map +0 -1
  48. package/dist/__tests__/physics.test.d.ts +0 -2
  49. package/dist/__tests__/physics.test.d.ts.map +0 -1
  50. package/dist/__tests__/spatial.test.d.ts +0 -2
  51. package/dist/__tests__/spatial.test.d.ts.map +0 -1
  52. package/dist/__tests__/standard-library-fundamentals.test.d.ts +0 -2
  53. package/dist/__tests__/standard-library-fundamentals.test.d.ts.map +0 -1
  54. package/dist/__tests__/string-and-time-utilities.test.d.ts +0 -2
  55. package/dist/__tests__/string-and-time-utilities.test.d.ts.map +0 -1
  56. package/dist/__tests__/string-decoupled.test.d.ts +0 -2
  57. package/dist/__tests__/string-decoupled.test.d.ts.map +0 -1
  58. package/dist/__tests__/string.test.d.ts +0 -2
  59. package/dist/__tests__/string.test.d.ts.map +0 -1
  60. package/dist/__tests__/time.test.d.ts +0 -2
  61. package/dist/__tests__/time.test.d.ts.map +0 -1
  62. package/dist/chunk-DZHAVOCH.js.map +0 -1
  63. package/dist/chunk-PR4QN5HX.js +0 -43
  64. package/dist/chunk-XBA4ARST.js +0 -9313
  65. package/dist/chunk-XBA4ARST.js.map +0 -1
  66. package/dist/fs/__tests__/file-watch-system.test.d.ts +0 -2
  67. package/dist/fs/__tests__/file-watch-system.test.d.ts.map +0 -1
  68. package/dist/fs/__tests__/path-utilities.test.d.ts +0 -2
  69. package/dist/fs/__tests__/path-utilities.test.d.ts.map +0 -1
  70. package/dist/fs/__tests__/path.test.d.ts +0 -2
  71. package/dist/fs/__tests__/path.test.d.ts.map +0 -1
  72. package/dist/string.basic.test.d.ts +0 -5
  73. package/dist/string.basic.test.d.ts.map +0 -1
  74. package/dist/string.test.d.ts +0 -5
  75. package/dist/string.test.d.ts.map +0 -1
  76. package/dist/traits/__tests__/ARTraits.test.d.ts +0 -2
  77. package/dist/traits/__tests__/ARTraits.test.d.ts.map +0 -1
  78. package/dist/traits/__tests__/EconomicPrimitives.test.d.ts +0 -2
  79. package/dist/traits/__tests__/EconomicPrimitives.test.d.ts.map +0 -1
  80. package/dist/traits/__tests__/EconomicTraits.test.d.ts +0 -2
  81. package/dist/traits/__tests__/EconomicTraits.test.d.ts.map +0 -1
  82. package/error-utf8.log +0 -6
  83. package/error.log +0 -0
  84. package/src/__tests__/EconomicPrimitives.test.ts +0 -690
  85. package/src/__tests__/EconomicTraits.test.ts +0 -425
  86. package/src/__tests__/SimulationLabPrimitives.test.ts +0 -415
  87. package/src/__tests__/collections.test.ts +0 -182
  88. package/src/__tests__/events.test.ts +0 -135
  89. package/src/__tests__/index.test.ts +0 -14
  90. package/src/__tests__/materials.test.ts +0 -84
  91. package/src/__tests__/math.test.ts +0 -246
  92. package/src/__tests__/physics.test.ts +0 -83
  93. package/src/__tests__/spatial.test.ts +0 -333
  94. package/src/__tests__/standard-library-fundamentals.test.ts +0 -1318
  95. package/src/__tests__/string-and-time-utilities.test.ts +0 -1070
  96. package/src/__tests__/string-decoupled.test.ts +0 -13
  97. package/src/__tests__/string.test.ts +0 -164
  98. package/src/__tests__/time.test.ts +0 -110
  99. package/src/collections.ts +0 -850
  100. package/src/events.ts +0 -88
  101. package/src/fs/__tests__/file-watch-system.test.ts +0 -675
  102. package/src/fs/__tests__/path-utilities.test.ts +0 -375
  103. package/src/fs/__tests__/path.test.ts +0 -287
  104. package/src/fs/fs.ts +0 -692
  105. package/src/fs/index.ts +0 -194
  106. package/src/fs/path.ts +0 -310
  107. package/src/fs/watch.ts +0 -413
  108. package/src/index.ts +0 -476
  109. package/src/materials.ts +0 -109
  110. package/src/math.ts +0 -674
  111. package/src/physics.ts +0 -141
  112. package/src/spatial.ts +0 -320
  113. package/src/string.basic.test.ts +0 -14
  114. package/src/string.test.ts +0 -335
  115. package/src/string.ts +0 -531
  116. package/src/time.ts +0 -621
  117. package/src/traits/ARTraits.ts +0 -103
  118. package/src/traits/EconomicPrimitives.ts +0 -755
  119. package/src/traits/EconomicTraits.ts +0 -552
  120. package/src/traits/IoTTraits.ts +0 -102
  121. package/src/traits/SimulationLabPrimitives.ts +0 -650
  122. package/src/traits/SimulationLabTraits.ts +0 -191
  123. package/src/traits/VRRTraits.ts +0 -326
  124. package/src/traits/__tests__/ARTraits.test.ts +0 -8
  125. package/src/traits/__tests__/EconomicPrimitives.test.ts +0 -14
  126. package/src/traits/__tests__/EconomicTraits.test.ts +0 -16
  127. package/src/types.ts +0 -418
  128. package/std_error.log +0 -5
  129. package/tsconfig.json +0 -18
  130. package/tsup.config.ts +0 -20
  131. package/vitest.config.ts +0 -10
  132. /package/dist/{chunk-PR4QN5HX.js.map → chunk-DGUM43GV.js.map} +0 -0
package/src/index.ts DELETED
@@ -1,476 +0,0 @@
1
- /**
2
- * @holoscript/std - Standard Library for HoloScript Plus
3
- *
4
- * Provides core types, math utilities, collections, string operations,
5
- * time management, spatial math, physics primitives, materials, and events
6
- * for HoloScript Plus programs.
7
- *
8
- * @example
9
- * ```hsplus
10
- * import { Vec3, createPBRMaterial, EventBus } from "@holoscript/std";
11
- *
12
- * let position = Vec3(0, 1, 0);
13
- * let steel = createPBRMaterial("Steel", "metal");
14
- * let bus = new EventBus();
15
- * ```
16
- */
17
-
18
- // Re-export everything from types.js
19
- export * from './types.js';
20
-
21
- // Spatial math (v4.2)
22
- export {
23
- Vec3,
24
- Quaternion,
25
- Transform,
26
- Ray,
27
- AABB,
28
- distance,
29
- lerp as spatialLerp,
30
- clamp as spatialClamp,
31
- degToRad as spatialDegToRad,
32
- radToDeg as spatialRadToDeg,
33
- } from './spatial.js';
34
-
35
- // Physics primitives (v4.2)
36
- export {
37
- createBoxCollider,
38
- createSphereCollider,
39
- createCapsuleCollider,
40
- createRigidbody,
41
- } from './physics.js';
42
- export type {
43
- ColliderConfig,
44
- ColliderShapeType,
45
- RigidbodyConfig,
46
- ForceFieldConfig,
47
- ForceFieldType,
48
- JointConfig,
49
- JointType,
50
- RaycastHit,
51
- } from './physics.js';
52
-
53
- // Materials (v4.2)
54
- export { MATERIAL_PRESETS, createPBRMaterial } from './materials.js';
55
- export type { PBRMaterial, UnlitMaterial, TextureMapType, TextureConfig } from './materials.js';
56
-
57
- // Events (v4.2)
58
- export { EventBus } from './events.js';
59
- export type { EventHandler } from './events.js';
60
-
61
- // Math utilities - export objects from math.ts
62
- export {
63
- // Constants
64
- PI,
65
- TAU,
66
- HALF_PI,
67
- EPSILON,
68
- DEG_TO_RAD,
69
- RAD_TO_DEG,
70
-
71
- // Basic math functions
72
- clamp,
73
- lerp,
74
- inverseLerp,
75
- remap,
76
- smoothstep,
77
- smootherstep,
78
- sign,
79
- fract,
80
- mod,
81
- step,
82
- degToRad,
83
- radToDeg,
84
-
85
- // Math utility objects (access methods like vec2Math.add(), vec3Math.cross(), etc.)
86
- vec2Math,
87
- vec3Math,
88
- quatMath,
89
- aabbMath,
90
- noise,
91
- random,
92
- } from './math.js';
93
-
94
- // Re-export with alternate names for convenience
95
- export { degToRad as toRadians, radToDeg as toDegrees } from './math.js';
96
-
97
- // Collections
98
- export {
99
- List,
100
- HoloMap,
101
- HoloSet,
102
- HoloMap as Map,
103
- HoloSet as Set,
104
- SpatialGrid,
105
- PriorityQueue,
106
- } from './collections.js';
107
-
108
- // String utilities
109
- export {
110
- isBlank,
111
- isNotBlank,
112
- capitalize,
113
- titleCase,
114
- camelCase,
115
- pascalCase,
116
- snakeCase,
117
- kebabCase,
118
- constantCase,
119
- padLeft,
120
- padRight,
121
- center,
122
- truncate,
123
- truncateMiddle,
124
- repeat,
125
- reverse,
126
- count,
127
- containsIgnoreCase,
128
- startsWithIgnoreCase,
129
- endsWithIgnoreCase,
130
- removeWhitespace,
131
- collapseWhitespace,
132
- removePrefix,
133
- removeSuffix,
134
- wrap as wrapString,
135
- unwrap,
136
- lines,
137
- words,
138
- chars,
139
- join,
140
- format,
141
- formatNumber,
142
- numberWithCommas,
143
- formatBytes,
144
- formatDuration,
145
- escapeHtml,
146
- unescapeHtml,
147
- escapeRegex,
148
- slugify,
149
- isValidIdentifier,
150
- isNumeric,
151
- isAlphanumeric,
152
- isAlpha,
153
- randomString,
154
- uuid,
155
- indent,
156
- dedent,
157
- wordWrap,
158
- levenshtein,
159
- similarity,
160
- extractTraits,
161
- } from './string.js';
162
-
163
- // Economic primitives (v4.3)
164
- export {
165
- // Tradeable
166
- generateTxHash,
167
- executeTrade,
168
- // Depreciation
169
- calculateDepreciation,
170
- depreciatedValue,
171
- isDestroyed,
172
- calculateRepairCost,
173
- DEFAULT_DEPRECIATION,
174
- // Bonding curves
175
- bondingCurvePrice,
176
- bondingCurveBuyCost,
177
- bondingCurveSellRefund,
178
- spatialPrice,
179
- DEFAULT_BONDING_CURVE,
180
- // Wealth taxation
181
- calculateTaxRate,
182
- calculateTaxAmount,
183
- calculateRedistribution,
184
- DEFAULT_WEALTH_TAX,
185
- // PID control
186
- createPIDState,
187
- updatePID,
188
- createDualLoopPIDState,
189
- updateDualLoopPID,
190
- DEFAULT_PID,
191
- // Faucet-sink tracking
192
- createFaucetSinkMetrics,
193
- recordFaucet,
194
- recordSink,
195
- resetMetricsPeriod,
196
- } from './traits/EconomicPrimitives.js';
197
- export type {
198
- Currency,
199
- AgentID,
200
- EconomicResult,
201
- EconomicError,
202
- EconomicPermission,
203
- OwnershipRecord,
204
- TransferRecord,
205
- DepreciationConfig,
206
- BondingCurveType,
207
- BondingCurveConfig,
208
- WealthTaxConfig,
209
- PIDConfig,
210
- PIDState,
211
- DualLoopPIDConfig,
212
- DualLoopPIDState,
213
- FaucetSinkMetrics,
214
- } from './traits/EconomicPrimitives.js';
215
-
216
- // Economic traits (v4.3)
217
- export {
218
- EconomicTraits,
219
- getEconomicTraitNames,
220
- getEconomicTrait,
221
- validateTraitComposition,
222
- getRequiredPermissions,
223
- } from './traits/EconomicTraits.js';
224
- export type { EconomicTraitDefinition } from './traits/EconomicTraits.js';
225
-
226
- // SimulationLab primitives (v4.3)
227
- export {
228
- // Statistics
229
- mean,
230
- variance,
231
- standardDeviation,
232
- standardError,
233
- cohensD,
234
- // Statistical tests
235
- tTest,
236
- oneSampleTTest,
237
- mannWhitneyU,
238
- chiSquaredTest,
239
- // Parameter sweeps
240
- expandSweep,
241
- generateSweepCombinations,
242
- isParameterRange,
243
- // Metric aggregation
244
- extractMetric,
245
- groupByParameter,
246
- summarizeMetrics,
247
- } from './traits/SimulationLabPrimitives.js';
248
- export type {
249
- Hypothesis,
250
- HypothesisDirection,
251
- SimulationStatus,
252
- ParameterRange,
253
- ParameterSet,
254
- ParameterSweep,
255
- SimulationMetrics,
256
- StatisticalResult,
257
- ExperimentResult,
258
- } from './traits/SimulationLabPrimitives.js';
259
-
260
- // SimulationLab traits (v4.3)
261
- export {
262
- SimulationLabTraits,
263
- getSimulationTraitNames,
264
- getSimulationTrait,
265
- } from './traits/SimulationLabTraits.js';
266
- export type { SimulationTraitDefinition } from './traits/SimulationLabTraits.js';
267
-
268
- // Time utilities
269
- export {
270
- now,
271
- hrTime,
272
- sleep,
273
- waitUntil,
274
- withTimeout,
275
- retry,
276
- debounce,
277
- throttle,
278
- measure,
279
- timed,
280
- Stopwatch,
281
- IntervalTimer,
282
- CountdownTimer,
283
- FrameTimer,
284
- schedule,
285
- scheduleInterval,
286
- scheduleFrame,
287
- createTicker,
288
- DateTime,
289
- } from './time.js';
290
-
291
- /**
292
- * Print to console (HoloScript standard output)
293
- */
294
- export function print(...args: unknown[]): void {
295
- console.log(...args);
296
- }
297
-
298
- /**
299
- * Print error to console
300
- */
301
- export function printError(...args: unknown[]): void {
302
- console.error(...args);
303
- }
304
-
305
- /**
306
- * Print warning to console
307
- */
308
- export function printWarn(...args: unknown[]): void {
309
- console.warn(...args);
310
- }
311
-
312
- /**
313
- * Assert a condition is true
314
- */
315
- export function assert(condition: boolean, message?: string): asserts condition {
316
- if (!condition) {
317
- throw new Error(message ?? 'Assertion failed');
318
- }
319
- }
320
-
321
- /**
322
- * Assert a value is not null or undefined
323
- */
324
- export function assertDefined<T>(
325
- value: T | null | undefined,
326
- message?: string
327
- ): asserts value is T {
328
- if (value === null || value === undefined) {
329
- throw new Error(message ?? 'Value is null or undefined');
330
- }
331
- }
332
-
333
- /**
334
- * Unreachable code marker (for exhaustiveness checking)
335
- */
336
- export function unreachable(message?: string): never {
337
- throw new Error(message ?? 'Unreachable code reached');
338
- }
339
-
340
- /**
341
- * Todo marker (throws at runtime)
342
- */
343
- export function todo(message?: string): never {
344
- throw new Error(`Not implemented: ${message ?? 'No details'}`);
345
- }
346
-
347
- /**
348
- * Deep clone an object
349
- */
350
- export function clone<T>(value: T): T {
351
- if (value === null || typeof value !== 'object') {
352
- return value;
353
- }
354
-
355
- if (Array.isArray(value)) {
356
- return value.map(clone) as T;
357
- }
358
-
359
- if (value instanceof Date) {
360
- return new Date(value.getTime()) as T;
361
- }
362
-
363
- if (value instanceof Map) {
364
- return new Map([...value].map(([k, v]) => [clone(k), clone(v)])) as T;
365
- }
366
-
367
- if (value instanceof Set) {
368
- return new Set([...value].map(clone)) as T;
369
- }
370
-
371
- const result: Record<string, unknown> = {};
372
- for (const key in value) {
373
- if (Object.prototype.hasOwnProperty.call(value, key)) {
374
- result[key] = clone((value as Record<string, unknown>)[key]);
375
- }
376
- }
377
- return result as T;
378
- }
379
-
380
- /**
381
- * Deep equality check
382
- */
383
- export function equals(a: unknown, b: unknown): boolean {
384
- if (a === b) return true;
385
- if (a === null || b === null) return false;
386
- if (typeof a !== typeof b) return false;
387
-
388
- if (typeof a !== 'object') return false;
389
-
390
- if (Array.isArray(a) && Array.isArray(b)) {
391
- if (a.length !== b.length) return false;
392
- return a.every((item, i) => equals(item, b[i]));
393
- }
394
-
395
- if (a instanceof Date && b instanceof Date) {
396
- return a.getTime() === b.getTime();
397
- }
398
-
399
- if (a instanceof Map && b instanceof Map) {
400
- if (a.size !== b.size) return false;
401
- for (const [key, value] of a) {
402
- if (!b.has(key) || !equals(value, b.get(key))) return false;
403
- }
404
- return true;
405
- }
406
-
407
- if (a instanceof Set && b instanceof Set) {
408
- if (a.size !== b.size) return false;
409
- for (const value of a) {
410
- if (!b.has(value)) return false;
411
- }
412
- return true;
413
- }
414
-
415
- const keysA = Object.keys(a);
416
- const keysB = Object.keys(b as object);
417
- if (keysA.length !== keysB.length) return false;
418
-
419
- return keysA.every((key) =>
420
- equals((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key])
421
- );
422
- }
423
-
424
- /**
425
- * Pipe a value through a series of functions
426
- */
427
- export function pipe<A>(value: A): A;
428
- export function pipe<A, B>(value: A, fn1: (a: A) => B): B;
429
- export function pipe<A, B, C>(value: A, fn1: (a: A) => B, fn2: (b: B) => C): C;
430
- export function pipe<A, B, C, D>(value: A, fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): D;
431
- export function pipe<A, B, C, D, E>(
432
- value: A,
433
- fn1: (a: A) => B,
434
- fn2: (b: B) => C,
435
- fn3: (c: C) => D,
436
- fn4: (d: D) => E
437
- ): E;
438
- export function pipe(value: unknown, ...fns: ((x: unknown) => unknown)[]): unknown {
439
- return fns.reduce((acc, fn) => fn(acc), value);
440
- }
441
-
442
- /**
443
- * Compose functions right to left
444
- */
445
- export function compose<A>(): (a: A) => A;
446
- export function compose<A, B>(fn1: (a: A) => B): (a: A) => B;
447
- export function compose<A, B, C>(fn2: (b: B) => C, fn1: (a: A) => B): (a: A) => C;
448
- export function compose<A, B, C, D>(
449
- fn3: (c: C) => D,
450
- fn2: (b: B) => C,
451
- fn1: (a: A) => B
452
- ): (a: A) => D;
453
- export function compose(...fns: ((x: unknown) => unknown)[]): (x: unknown) => unknown {
454
- return (value: unknown) => fns.reduceRight((acc, fn) => fn(acc), value);
455
- }
456
-
457
- /**
458
- * Identity function
459
- */
460
- export function identity<T>(value: T): T {
461
- return value;
462
- }
463
-
464
- /**
465
- * No-operation function
466
- */
467
- export function noop(): void {}
468
-
469
- /**
470
- * Create a constant function
471
- */
472
- export function constant<T>(value: T): () => T {
473
- return () => value;
474
- }
475
-
476
-
package/src/materials.ts DELETED
@@ -1,109 +0,0 @@
1
- /**
2
- * @holoscript/std — Materials Module
3
- *
4
- * Provides PBR material types, texture map definitions, and material presets.
5
- * Maps directly to HoloScript material_block grammar constructs.
6
- *
7
- * @version 0.2.0
8
- * @module @holoscript/std/materials
9
- */
10
-
11
- // =============================================================================
12
- // PBR Material
13
- // =============================================================================
14
-
15
- export interface PBRMaterial {
16
- name: string;
17
- baseColor: string; // hex color
18
- roughness: number; // 0.0 - 1.0
19
- metallic: number; // 0.0 - 1.0
20
- emissiveColor?: string;
21
- emissiveIntensity?: number;
22
- opacity?: number; // 0.0 - 1.0
23
- ior?: number; // Index of refraction (glass ~1.5, water ~1.33)
24
- subsurface?: number;
25
- clearcoat?: number;
26
- clearcoatRoughness?: number;
27
- // Texture maps
28
- albedoMap?: string;
29
- normalMap?: string;
30
- roughnessMap?: string;
31
- metallicMap?: string;
32
- emissionMap?: string;
33
- aoMap?: string;
34
- heightMap?: string;
35
- opacityMap?: string;
36
- displacementMap?: string;
37
- }
38
-
39
- export interface UnlitMaterial {
40
- name: string;
41
- color: string;
42
- emissiveColor?: string;
43
- emissiveIntensity?: number;
44
- opacity?: number;
45
- texture?: string;
46
- }
47
-
48
- // =============================================================================
49
- // Material Presets
50
- // =============================================================================
51
-
52
- export const MATERIAL_PRESETS: Record<string, Partial<PBRMaterial>> = {
53
- metal: { roughness: 0.2, metallic: 1.0 },
54
- wood: { roughness: 0.85, metallic: 0.0, baseColor: '#8B6914' },
55
- glass: { roughness: 0.05, metallic: 0.0, opacity: 0.3, ior: 1.5 },
56
- plastic: { roughness: 0.4, metallic: 0.0 },
57
- concrete: { roughness: 0.95, metallic: 0.0, baseColor: '#808080' },
58
- fabric: { roughness: 0.9, metallic: 0.0, subsurface: 0.2 },
59
- water: { roughness: 0.05, metallic: 0.0, opacity: 0.7, ior: 1.33 },
60
- rubber: { roughness: 0.95, metallic: 0.0, baseColor: '#222222' },
61
- marble: { roughness: 0.3, metallic: 0.0, baseColor: '#f0f0f0' },
62
- skin: { roughness: 0.6, metallic: 0.0, subsurface: 0.5 },
63
- foliage: { roughness: 0.8, metallic: 0.0, baseColor: '#2d5a27', subsurface: 0.3 },
64
- chrome: { roughness: 0.05, metallic: 1.0, baseColor: '#cccccc' },
65
- gold: { roughness: 0.2, metallic: 1.0, baseColor: '#ffd700' },
66
- copper: { roughness: 0.3, metallic: 1.0, baseColor: '#b87333' },
67
- ice: { roughness: 0.1, metallic: 0.0, opacity: 0.8, ior: 1.31 },
68
- };
69
-
70
- export function createPBRMaterial(
71
- name: string,
72
- preset?: keyof typeof MATERIAL_PRESETS,
73
- overrides?: Partial<PBRMaterial>
74
- ): PBRMaterial {
75
- const base = preset ? MATERIAL_PRESETS[preset] : {};
76
- return {
77
- name,
78
- baseColor: '#ffffff',
79
- roughness: 0.5,
80
- metallic: 0.0,
81
- ...base,
82
- ...overrides,
83
- };
84
- }
85
-
86
- // =============================================================================
87
- // Texture Map Types
88
- // =============================================================================
89
-
90
- export type TextureMapType =
91
- | 'albedo_map'
92
- | 'normal_map'
93
- | 'roughness_map'
94
- | 'metallic_map'
95
- | 'emission_map'
96
- | 'ao_map'
97
- | 'height_map'
98
- | 'opacity_map'
99
- | 'displacement_map'
100
- | 'specular_map'
101
- | 'clearcoat_map';
102
-
103
- export interface TextureConfig {
104
- source: string;
105
- tiling?: [number, number];
106
- offset?: [number, number];
107
- filter?: 'linear' | 'nearest';
108
- wrap?: 'repeat' | 'clamp' | 'mirror';
109
- }