@zephyr3d/editor 0.3.0 → 0.3.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 (48) hide show
  1. package/README.md +143 -0
  2. package/dist/assets/{index-BaUzUcND.js → index-IISR7uQv.js} +1 -1
  3. package/dist/assistant/zephyr-types-index.json +1 -1
  4. package/dist/index.html +2 -2
  5. package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
  6. package/dist/modules/zephyr3d_imgui.js +3 -3
  7. package/dist/modules/zephyr3d_imgui.js.map +1 -1
  8. package/dist/modules/zephyr3d_scene.js +1439 -1439
  9. package/dist/modules/zephyr3d_scene.js.map +1 -1
  10. package/dist/vendor/zephyr3d/backend-webgpu/dist/bindgroup_webgpu.js.map +1 -1
  11. package/dist/vendor/zephyr3d/backend-webgpu/dist/buffer_webgpu.js.map +1 -1
  12. package/dist/vendor/zephyr3d/backend-webgpu/dist/commandqueue.js.map +1 -1
  13. package/dist/vendor/zephyr3d/backend-webgpu/dist/uploadringbuffer.js.map +1 -1
  14. package/dist/vendor/zephyr3d/imgui/dist/imgui_impl.js.map +1 -1
  15. package/dist/vendor/zephyr3d/imgui/dist/renderer.js +3 -3
  16. package/dist/vendor/zephyr3d/imgui/dist/renderer.js.map +1 -1
  17. package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +135 -135
  18. package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
  19. package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/controller.js +146 -146
  20. package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/controller.js.map +1 -1
  21. package/dist/vendor/zephyr3d/scene/dist/animation/spring/spring_system.js +75 -75
  22. package/dist/vendor/zephyr3d/scene/dist/animation/spring/spring_system.js.map +1 -1
  23. package/dist/vendor/zephyr3d/scene/dist/camera/camera.js +184 -184
  24. package/dist/vendor/zephyr3d/scene/dist/camera/camera.js.map +1 -1
  25. package/dist/vendor/zephyr3d/scene/dist/material/material.js +288 -288
  26. package/dist/vendor/zephyr3d/scene/dist/material/material.js.map +1 -1
  27. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resource_manager.js +93 -93
  28. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  29. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resources.js +3 -3
  30. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resources.js.map +1 -1
  31. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/types.js +22 -22
  32. package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/types.js.map +1 -1
  33. package/dist/vendor/zephyr3d/scene/dist/utility/blueprint/material/ir.js +489 -489
  34. package/dist/vendor/zephyr3d/scene/dist/utility/blueprint/material/ir.js.map +1 -1
  35. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js.map +1 -1
  36. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
  37. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/common.js.map +1 -1
  38. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/light.js.map +1 -1
  39. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/material.js.map +1 -1
  40. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js.map +1 -1
  41. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/node.js.map +1 -1
  42. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/particle.js.map +1 -1
  43. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/primitive.js.map +1 -1
  44. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/scene.js.map +1 -1
  45. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/terrain.js.map +1 -1
  46. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/types.js +4 -4
  47. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/types.js.map +1 -1
  48. package/package.json +1 -1
@@ -9,26 +9,26 @@ import { FunctionCallNode, FunctionInputNode, FunctionOutputNode } from './func.
9
9
  import { hash11, hash21, hash31, hash12, hash22, hash32, hash13, hash23, hash33, valueNoise } from '../../../shaders/noise.js';
10
10
  import { VertexBlockNode } from './pbr.js';
11
11
 
12
- /**
13
- * Abstract base class for intermediate representation expressions
14
- *
15
- * @remarks
16
- * Represents a node in the IR tree that can be compiled to shader code.
17
- * Uses reference counting to determine if intermediate variables are needed.
18
- * Each expression can be referenced multiple times in the final shader code.
19
- *
20
- * The IR expression tree is built during compilation and then translated
21
- * to actual shader code via the `create()` method.
22
- *
23
- * @public
12
+ /**
13
+ * Abstract base class for intermediate representation expressions
14
+ *
15
+ * @remarks
16
+ * Represents a node in the IR tree that can be compiled to shader code.
17
+ * Uses reference counting to determine if intermediate variables are needed.
18
+ * Each expression can be referenced multiple times in the final shader code.
19
+ *
20
+ * The IR expression tree is built during compilation and then translated
21
+ * to actual shader code via the `create()` method.
22
+ *
23
+ * @public
24
24
  */ class IRExpression {
25
25
  /** Reference count for this expression (number of times it's used) */ _ref;
26
26
  /** Cached output expressions for each output slot */ _outputs;
27
- /**
28
- * Creates a new IR expression
29
- *
30
- * @remarks
31
- * Initializes reference count to 0 and empty outputs array.
27
+ /**
28
+ * Creates a new IR expression
29
+ *
30
+ * @remarks
31
+ * Initializes reference count to 0 and empty outputs array.
32
32
  */ constructor(){
33
33
  this._ref = 0;
34
34
  this._outputs = [];
@@ -36,26 +36,26 @@ import { VertexBlockNode } from './pbr.js';
36
36
  /** Gets the array of output expressions */ get outputs() {
37
37
  return this._outputs;
38
38
  }
39
- /**
40
- * Increments the reference count
41
- *
42
- * @returns This expression for method chaining
43
- *
44
- * @remarks
45
- * Called when this expression is referenced by another expression.
46
- * Reference count is used to determine if a temporary variable is needed.
39
+ /**
40
+ * Increments the reference count
41
+ *
42
+ * @returns This expression for method chaining
43
+ *
44
+ * @remarks
45
+ * Called when this expression is referenced by another expression.
46
+ * Reference count is used to determine if a temporary variable is needed.
47
47
  */ addRef() {
48
48
  this._ref++;
49
49
  return this;
50
50
  }
51
- /**
52
- * Generates a unique temporary variable name
53
- *
54
- * @param scope - The shader scope to check for name conflicts
55
- * @returns A unique temporary variable name (e.g., 'tmp0', 'tmp1')
56
- *
57
- * @remarks
58
- * Ensures the generated name doesn't conflict with existing variables in the scope.
51
+ /**
52
+ * Generates a unique temporary variable name
53
+ *
54
+ * @param scope - The shader scope to check for name conflicts
55
+ * @returns A unique temporary variable name (e.g., 'tmp0', 'tmp1')
56
+ *
57
+ * @remarks
58
+ * Ensures the generated name doesn't conflict with existing variables in the scope.
59
59
  */ getTmpName(scope) {
60
60
  let tmp = 0;
61
61
  for(;;){
@@ -65,60 +65,60 @@ import { VertexBlockNode } from './pbr.js';
65
65
  }
66
66
  }
67
67
  }
68
- /**
69
- * Converts this expression to a uniform value if applicable
70
- *
71
- * @param _node - The graph node associated with this expression
72
- * @returns The uniform value descriptor, or null if not a uniform
73
- *
74
- * @remarks
75
- * Only constant expressions can be converted to uniforms.
76
- * Returns null by default; overridden by constant expression types.
68
+ /**
69
+ * Converts this expression to a uniform value if applicable
70
+ *
71
+ * @param _node - The graph node associated with this expression
72
+ * @returns The uniform value descriptor, or null if not a uniform
73
+ *
74
+ * @remarks
75
+ * Only constant expressions can be converted to uniforms.
76
+ * Returns null by default; overridden by constant expression types.
77
77
  */ asUniformValue(_node) {
78
78
  return null;
79
79
  }
80
- /**
81
- * Converts this expression to a uniform texture if applicable
82
- *
83
- * @param _node - The graph node associated with this expression
84
- * @returns The uniform texture descriptor, or null if not a texture uniform
85
- *
86
- * @remarks
87
- * Only texture constant expressions can be converted to texture uniforms.
88
- * Returns null by default; overridden by texture constant expression types.
80
+ /**
81
+ * Converts this expression to a uniform texture if applicable
82
+ *
83
+ * @param _node - The graph node associated with this expression
84
+ * @returns The uniform texture descriptor, or null if not a texture uniform
85
+ *
86
+ * @remarks
87
+ * Only texture constant expressions can be converted to texture uniforms.
88
+ * Returns null by default; overridden by texture constant expression types.
89
89
  */ asUniformTexture(_node) {
90
90
  return null;
91
91
  }
92
- /**
93
- * Reset state for creation
92
+ /**
93
+ * Reset state for creation
94
94
  */ reset() {}
95
95
  }
96
- /**
97
- * IR expression for a constant scalar (float) value
98
- *
99
- * @public
96
+ /**
97
+ * IR expression for a constant scalar (float) value
98
+ *
99
+ * @public
100
100
  */ class IRConstantf extends IRExpression {
101
101
  /** The constant float value */ value;
102
102
  /** The uniform parameter name, or empty string for literals */ name;
103
- /**
104
- * Creates a constant float expression
105
- *
106
- * @param value - The float value
107
- * @param paramName - The uniform parameter name, or empty string for literals
103
+ /**
104
+ * Creates a constant float expression
105
+ *
106
+ * @param value - The float value
107
+ * @param paramName - The uniform parameter name, or empty string for literals
108
108
  */ constructor(value, paramName){
109
109
  super();
110
110
  this.value = value;
111
111
  this.name = paramName;
112
112
  }
113
- /**
114
- * Generates shader code for this constant
115
- *
116
- * @param pb - The program builder
117
- * @returns A uniform reference or literal number
118
- *
119
- * @remarks
120
- * If a parameter name exists, creates a uniform in the global scope.
121
- * Otherwise, returns the literal value.
113
+ /**
114
+ * Generates shader code for this constant
115
+ *
116
+ * @param pb - The program builder
117
+ * @returns A uniform reference or literal number
118
+ *
119
+ * @remarks
120
+ * If a parameter name exists, creates a uniform in the global scope.
121
+ * Otherwise, returns the literal value.
122
122
  */ create(pb) {
123
123
  if (this.name) {
124
124
  if (!pb.getGlobalScope()[this.name]) {
@@ -128,11 +128,11 @@ import { VertexBlockNode } from './pbr.js';
128
128
  }
129
129
  return this.value;
130
130
  }
131
- /**
132
- * Converts to a uniform value descriptor
133
- *
134
- * @param node - The graph node
135
- * @returns Uniform value descriptor if this is a uniform parameter, null otherwise
131
+ /**
132
+ * Converts to a uniform value descriptor
133
+ *
134
+ * @param node - The graph node
135
+ * @returns Uniform value descriptor if this is a uniform parameter, null otherwise
136
136
  */ asUniformValue() {
137
137
  return this.name ? {
138
138
  name: this.name,
@@ -143,57 +143,57 @@ import { VertexBlockNode } from './pbr.js';
143
143
  } : null;
144
144
  }
145
145
  }
146
- /**
147
- * IR expression for a constant scalar (boolean) value
148
- *
149
- * @public
146
+ /**
147
+ * IR expression for a constant scalar (boolean) value
148
+ *
149
+ * @public
150
150
  */ class IRConstantb extends IRExpression {
151
151
  /** The constant boolean value */ value;
152
- /**
153
- * Creates a constant boolean expression
154
- *
155
- * @param value - The boolean value
152
+ /**
153
+ * Creates a constant boolean expression
154
+ *
155
+ * @param value - The boolean value
156
156
  */ constructor(value){
157
157
  super();
158
158
  this.value = value;
159
159
  }
160
- /**
161
- * Generates shader code for this constant
162
- *
163
- * @returns The literal boolean value
164
- *
160
+ /**
161
+ * Generates shader code for this constant
162
+ *
163
+ * @returns The literal boolean value
164
+ *
165
165
  */ create() {
166
166
  return this.value;
167
167
  }
168
168
  }
169
- /**
170
- * IR expression for a constant vector value
171
- *
172
- * @public
169
+ /**
170
+ * IR expression for a constant vector value
171
+ *
172
+ * @public
173
173
  */ class IRConstantfv extends IRExpression {
174
174
  /** The constant vector value as an array of floats */ value;
175
175
  /** The uniform parameter name, or empty string for literals */ name;
176
176
  /** vector type */ type;
177
- /**
178
- * Creates a constant vector expression
179
- *
180
- * @param value - The vector value as an array (length 2-4)
181
- * @param paramName - The uniform parameter name, or empty string for literals
177
+ /**
178
+ * Creates a constant vector expression
179
+ *
180
+ * @param value - The vector value as an array (length 2-4)
181
+ * @param paramName - The uniform parameter name, or empty string for literals
182
182
  */ constructor(value, paramName, type){
183
183
  super();
184
184
  this.value = value;
185
185
  this.name = paramName;
186
186
  this.type = type;
187
187
  }
188
- /**
189
- * Generates shader code for this constant vector
190
- *
191
- * @param pb - The program builder
192
- * @returns A uniform reference or vector constructor expression
193
- *
194
- * @remarks
195
- * If a parameter name exists, creates a uniform in the global scope.
196
- * The vector size is determined by the array length (vec2/vec3/vec4).
188
+ /**
189
+ * Generates shader code for this constant vector
190
+ *
191
+ * @param pb - The program builder
192
+ * @returns A uniform reference or vector constructor expression
193
+ *
194
+ * @remarks
195
+ * If a parameter name exists, creates a uniform in the global scope.
196
+ * The vector size is determined by the array length (vec2/vec3/vec4).
197
197
  */ create(pb) {
198
198
  if (this.name) {
199
199
  if (!pb.getGlobalScope()[this.name]) {
@@ -205,11 +205,11 @@ import { VertexBlockNode } from './pbr.js';
205
205
  return(// @ts-ignore
206
206
  Array.isArray(this.value) ? pb[`vec${this.value.length}`](...this.value) : this.value);
207
207
  }
208
- /**
209
- * Converts to a uniform value descriptor
210
- *
211
- * @param node - The graph node
212
- * @returns Uniform value descriptor if this is a uniform parameter, null otherwise
208
+ /**
209
+ * Converts to a uniform value descriptor
210
+ *
211
+ * @param node - The graph node
212
+ * @returns Uniform value descriptor if this is a uniform parameter, null otherwise
213
213
  */ asUniformValue() {
214
214
  return this.name ? {
215
215
  name: this.name,
@@ -218,97 +218,97 @@ import { VertexBlockNode } from './pbr.js';
218
218
  } : null;
219
219
  }
220
220
  }
221
- /**
222
- * IR expression for a constant boolean vector value
223
- *
224
- * @public
221
+ /**
222
+ * IR expression for a constant boolean vector value
223
+ *
224
+ * @public
225
225
  */ class IRConstantbv extends IRExpression {
226
226
  /** The constant vector value as an array of booleans */ value;
227
- /**
228
- * Creates a constant boolean vector expression
229
- *
230
- * @param value - The vector value as an array (length 2-4)
227
+ /**
228
+ * Creates a constant boolean vector expression
229
+ *
230
+ * @param value - The vector value as an array (length 2-4)
231
231
  */ constructor(value){
232
232
  super();
233
233
  this.value = value;
234
234
  }
235
- /**
236
- * Generates shader code for this constant vector
237
- *
238
- * @param pb - The program builder
239
- *
240
- * @returns A boolean vector constructor expression
235
+ /**
236
+ * Generates shader code for this constant vector
237
+ *
238
+ * @param pb - The program builder
239
+ *
240
+ * @returns A boolean vector constructor expression
241
241
  */ create(pb) {
242
242
  // @ts-ignore
243
243
  return pb[`bvec${this.value.length}`](...this.value);
244
244
  }
245
245
  }
246
- /**
247
- * IR expression for shader input variables
248
- *
249
- * @remarks
250
- * Represents variables that are passed into the shader from the vertex stage
251
- * or defined in the current scope. Examples include vertex attributes,
252
- * varyings, and built-in variables.
253
- *
254
- * @example
255
- * ```typescript
256
- * // Reference to vertex color
257
- * const vertexColor = new IRInput('zVertexColor');
258
- *
259
- * // Reference via function
260
- * const worldPos = new IRInput((scope) => scope.zWorldPos);
261
- * ```
262
- *
263
- * @public
246
+ /**
247
+ * IR expression for shader input variables
248
+ *
249
+ * @remarks
250
+ * Represents variables that are passed into the shader from the vertex stage
251
+ * or defined in the current scope. Examples include vertex attributes,
252
+ * varyings, and built-in variables.
253
+ *
254
+ * @example
255
+ * ```typescript
256
+ * // Reference to vertex color
257
+ * const vertexColor = new IRInput('zVertexColor');
258
+ *
259
+ * // Reference via function
260
+ * const worldPos = new IRInput((scope) => scope.zWorldPos);
261
+ * ```
262
+ *
263
+ * @public
264
264
  */ class IRInput extends IRExpression {
265
265
  /** The variable name or a function that retrieves the variable from scope */ func;
266
- /**
267
- * Creates an input variable expression
268
- *
269
- * @param func - Variable name string or function to retrieve the variable
266
+ /**
267
+ * Creates an input variable expression
268
+ *
269
+ * @param func - Variable name string or function to retrieve the variable
270
270
  */ constructor(func){
271
271
  super();
272
272
  this.func = func;
273
273
  }
274
- /**
275
- * Generates shader code for this input variable
276
- *
277
- * @param pb - The program builder
278
- * @returns The shader expression referencing the input variable
274
+ /**
275
+ * Generates shader code for this input variable
276
+ *
277
+ * @param pb - The program builder
278
+ * @returns The shader expression referencing the input variable
279
279
  */ create(pb) {
280
280
  return typeof this.func === 'string' ? pb.getCurrentScope()[this.func] : this.func(pb.getCurrentScope());
281
281
  }
282
282
  }
283
- /**
284
- * IR expression for function calls and operations
285
- *
286
- * @remarks
287
- * Represents built-in shader functions (add, mul, sin, etc.) or vector constructors.
288
- * Uses reference counting to determine if result should be stored in a temporary variable.
289
- *
290
- * @example
291
- * ```typescript
292
- * // Addition: a + b
293
- * const add = new IRFunc([exprA, exprB], 'add');
294
- *
295
- * // Vector constructor: vec3(x, y, z)
296
- * const vec = new IRFunc([x, y, z], 'vec3');
297
- * ```
298
- *
299
- * @public
283
+ /**
284
+ * IR expression for function calls and operations
285
+ *
286
+ * @remarks
287
+ * Represents built-in shader functions (add, mul, sin, etc.) or vector constructors.
288
+ * Uses reference counting to determine if result should be stored in a temporary variable.
289
+ *
290
+ * @example
291
+ * ```typescript
292
+ * // Addition: a + b
293
+ * const add = new IRFunc([exprA, exprB], 'add');
294
+ *
295
+ * // Vector constructor: vec3(x, y, z)
296
+ * const vec = new IRFunc([x, y, z], 'vec3');
297
+ * ```
298
+ *
299
+ * @public
300
300
  */ class IRFunc extends IRExpression {
301
301
  /** Array of parameters (can be expressions or literal numbers) */ params;
302
302
  /** The function name (e.g., 'add', 'mul', 'sin', 'vec3') */ func;
303
303
  /** Cached temporary variable name if expression is referenced multiple times */ tmpName;
304
- /**
305
- * Creates a function call expression
306
- *
307
- * @param params - Array of parameters for the function
308
- * @param func - The function name or function implementation
309
- *
310
- * @remarks
311
- * Increments reference count for all expression parameters.
304
+ /**
305
+ * Creates a function call expression
306
+ *
307
+ * @param params - Array of parameters for the function
308
+ * @param func - The function name or function implementation
309
+ *
310
+ * @remarks
311
+ * Increments reference count for all expression parameters.
312
312
  */ constructor(params, func){
313
313
  super();
314
314
  this.params = params.map((param)=>param instanceof IRExpression ? param.addRef() : param);
@@ -318,15 +318,15 @@ import { VertexBlockNode } from './pbr.js';
318
318
  /** Reset for next creation */ reset() {
319
319
  this.tmpName = '';
320
320
  }
321
- /**
322
- * Generates shader code for this function call
323
- *
324
- * @param pb - The program builder
325
- * @returns The shader expression for the function result
326
- *
327
- * @remarks
328
- * If referenced multiple times (_ref > 1), stores result in a temporary variable.
329
- * Otherwise, generates the function call inline.
321
+ /**
322
+ * Generates shader code for this function call
323
+ *
324
+ * @param pb - The program builder
325
+ * @returns The shader expression for the function result
326
+ *
327
+ * @remarks
328
+ * If referenced multiple times (_ref > 1), stores result in a temporary variable.
329
+ * Otherwise, generates the function call inline.
330
330
  */ create(pb) {
331
331
  if (this.tmpName) {
332
332
  const exp = pb.getCurrentScope()[this.tmpName];
@@ -348,27 +348,27 @@ import { VertexBlockNode } from './pbr.js';
348
348
  }
349
349
  }
350
350
  }
351
- /**
352
- * IR expression for function output values
353
- *
354
- * @remarks
355
- * Represents the output of a material function (subgraph).
356
- * Handles caching of output values when referenced multiple times.
357
- *
358
- * @example
359
- * ```typescript
360
- * // Function returns a processed color value
361
- * const output = new IRFunctionOutput(colorExpression);
362
- * ```
363
- *
364
- * @public
351
+ /**
352
+ * IR expression for function output values
353
+ *
354
+ * @remarks
355
+ * Represents the output of a material function (subgraph).
356
+ * Handles caching of output values when referenced multiple times.
357
+ *
358
+ * @example
359
+ * ```typescript
360
+ * // Function returns a processed color value
361
+ * const output = new IRFunctionOutput(colorExpression);
362
+ * ```
363
+ *
364
+ * @public
365
365
  */ class IRFunctionOutput extends IRExpression {
366
366
  /** Cached temporary variable name for the output */ tmpName;
367
367
  /** The input expression to output */ input;
368
- /**
369
- * Creates a function output expression
370
- *
371
- * @param input - The expression or value to output
368
+ /**
369
+ * Creates a function output expression
370
+ *
371
+ * @param input - The expression or value to output
372
372
  */ constructor(input){
373
373
  super();
374
374
  this.input = input;
@@ -377,14 +377,14 @@ import { VertexBlockNode } from './pbr.js';
377
377
  /** Reset for next creation */ reset() {
378
378
  this.tmpName = '';
379
379
  }
380
- /**
381
- * Generates shader code for this function output
382
- *
383
- * @param pb - The program builder
384
- * @returns The shader expression or value
385
- *
386
- * @remarks
387
- * If referenced multiple times, stores result in a temporary variable.
380
+ /**
381
+ * Generates shader code for this function output
382
+ *
383
+ * @param pb - The program builder
384
+ * @returns The shader expression or value
385
+ *
386
+ * @remarks
387
+ * If referenced multiple times, stores result in a temporary variable.
388
388
  */ create(pb) {
389
389
  if (this.tmpName) {
390
390
  return pb.getCurrentScope()[this.tmpName];
@@ -399,30 +399,30 @@ import { VertexBlockNode } from './pbr.js';
399
399
  }
400
400
  }
401
401
  }
402
- /**
403
- * IR expression for calling user-defined material functions
404
- *
405
- * @remarks
406
- * Represents a call to a material function (subgraph) with parameters.
407
- * Generates both the function definition and the call site.
408
- * Uses a struct return type to return multiple outputs from the function.
409
- *
410
- * @example
411
- * ```typescript
412
- * // Call to a custom "calculateLighting" function
413
- * const call = new IRCallFunc(functionNode, [normalExpr, lightDirExpr]);
414
- * ```
415
- *
416
- * @public
402
+ /**
403
+ * IR expression for calling user-defined material functions
404
+ *
405
+ * @remarks
406
+ * Represents a call to a material function (subgraph) with parameters.
407
+ * Generates both the function definition and the call site.
408
+ * Uses a struct return type to return multiple outputs from the function.
409
+ *
410
+ * @example
411
+ * ```typescript
412
+ * // Call to a custom "calculateLighting" function
413
+ * const call = new IRCallFunc(functionNode, [normalExpr, lightDirExpr]);
414
+ * ```
415
+ *
416
+ * @public
417
417
  */ class IRCallFunc extends IRExpression {
418
418
  /** The function call node from the graph */ node;
419
419
  /** Array of argument expressions */ args;
420
420
  /** Cached temporary variable name if result is referenced multiple times */ tmpName;
421
- /**
422
- * Creates a function call expression
423
- *
424
- * @param node - The function call node
425
- * @param args - Array of argument expressions
421
+ /**
422
+ * Creates a function call expression
423
+ *
424
+ * @param node - The function call node
425
+ * @param args - Array of argument expressions
426
426
  */ constructor(node, args){
427
427
  super();
428
428
  this.node = node;
@@ -432,16 +432,16 @@ import { VertexBlockNode } from './pbr.js';
432
432
  /** Reset for next creation */ reset() {
433
433
  this.tmpName = '';
434
434
  }
435
- /**
436
- * Generates shader code for the function definition and call
437
- *
438
- * @param pb - The program builder
439
- * @returns The shader expression for the function result
440
- *
441
- * @remarks
442
- * First generates the function definition (if not already defined),
443
- * then generates the function call with the provided arguments.
444
- * The function returns a struct containing all output values.
435
+ /**
436
+ * Generates shader code for the function definition and call
437
+ *
438
+ * @param pb - The program builder
439
+ * @returns The shader expression for the function result
440
+ *
441
+ * @remarks
442
+ * First generates the function definition (if not already defined),
443
+ * then generates the function call with the provided arguments.
444
+ * The function returns a struct containing all output values.
445
445
  */ create(pb) {
446
446
  if (this.tmpName) {
447
447
  return pb.getCurrentScope()[this.tmpName];
@@ -608,82 +608,82 @@ class IRComparison extends IRExpression {
608
608
  }
609
609
  }
610
610
  }
611
- /**
612
- * IR expression for vector component swizzling
613
- *
614
- * @remarks
615
- * Extracts specific components from a vector using swizzle notation.
616
- * For scalar sources, constructs a vector with replicated values.
617
- *
618
- * @example
619
- * ```typescript
620
- * // Extract xyz from vec4
621
- * const xyz = new IRSwizzle(vec4Expr, 'xyz');
622
- *
623
- * // Extract single component
624
- * const x = new IRSwizzle(vec3Expr, 'x');
625
- *
626
- * // Swizzle and reorder
627
- * const bgr = new IRSwizzle(rgbExpr, 'bgr');
628
- * ```
629
- *
630
- * @public
611
+ /**
612
+ * IR expression for vector component swizzling
613
+ *
614
+ * @remarks
615
+ * Extracts specific components from a vector using swizzle notation.
616
+ * For scalar sources, constructs a vector with replicated values.
617
+ *
618
+ * @example
619
+ * ```typescript
620
+ * // Extract xyz from vec4
621
+ * const xyz = new IRSwizzle(vec4Expr, 'xyz');
622
+ *
623
+ * // Extract single component
624
+ * const x = new IRSwizzle(vec3Expr, 'x');
625
+ *
626
+ * // Swizzle and reorder
627
+ * const bgr = new IRSwizzle(rgbExpr, 'bgr');
628
+ * ```
629
+ *
630
+ * @public
631
631
  */ class IRSwizzle extends IRExpression {
632
632
  /** The source expression to swizzle */ src;
633
633
  /** The swizzle pattern (e.g., 'xyz', 'rgb', 'x', 'yzw') */ hash;
634
- /**
635
- * Creates a swizzle expression
636
- *
637
- * @param src - The source vector expression
638
- * @param hash - The swizzle pattern using xyzw or rgba notation
634
+ /**
635
+ * Creates a swizzle expression
636
+ *
637
+ * @param src - The source vector expression
638
+ * @param hash - The swizzle pattern using xyzw or rgba notation
639
639
  */ constructor(src, hash){
640
640
  super();
641
641
  this.src = src.addRef();
642
642
  this.hash = hash;
643
643
  }
644
- /**
645
- * Generates shader code for the swizzle operation
646
- *
647
- * @param pb - The program builder
648
- * @returns The swizzled shader expression
649
- *
650
- * @remarks
651
- * If source is a scalar number, creates a vector with that value repeated.
652
- * Otherwise, applies the swizzle notation to the source expression.
644
+ /**
645
+ * Generates shader code for the swizzle operation
646
+ *
647
+ * @param pb - The program builder
648
+ * @returns The swizzled shader expression
649
+ *
650
+ * @remarks
651
+ * If source is a scalar number, creates a vector with that value repeated.
652
+ * Otherwise, applies the swizzle notation to the source expression.
653
653
  */ create(pb) {
654
654
  const src = this.src.create(pb);
655
655
  // @ts-ignore
656
656
  return typeof src === 'number' ? pb[`vec${this.hash.length}`](src) : src[this.hash];
657
657
  }
658
658
  }
659
- /**
660
- * IR expression for type casting with padding
661
- *
662
- * @remarks
663
- * Converts a value to a different vector type by padding with zeros.
664
- * Used when a smaller vector needs to be converted to a larger one.
665
- *
666
- * @example
667
- * ```typescript
668
- * // Cast float to vec3: vec3(value, 0, 0)
669
- * const vec3 = new IRCast(floatExpr, 'vec3', 2);
670
- *
671
- * // Cast vec2 to vec4: vec4(value.xy, 0, 0)
672
- * const vec4 = new IRCast(vec2Expr, 'vec4', 2);
673
- * ```
674
- *
675
- * @public
659
+ /**
660
+ * IR expression for type casting with padding
661
+ *
662
+ * @remarks
663
+ * Converts a value to a different vector type by padding with zeros.
664
+ * Used when a smaller vector needs to be converted to a larger one.
665
+ *
666
+ * @example
667
+ * ```typescript
668
+ * // Cast float to vec3: vec3(value, 0, 0)
669
+ * const vec3 = new IRCast(floatExpr, 'vec3', 2);
670
+ *
671
+ * // Cast vec2 to vec4: vec4(value.xy, 0, 0)
672
+ * const vec4 = new IRCast(vec2Expr, 'vec4', 2);
673
+ * ```
674
+ *
675
+ * @public
676
676
  */ class IRCast extends IRExpression {
677
677
  /** The source expression to cast */ src;
678
678
  /** The values to be filled */ fill;
679
679
  /** The target type name (e.g., 'vec2', 'vec3', 'vec4') */ type;
680
680
  /** Number of zero components to append */ cast;
681
- /**
682
- * Creates a type cast expression
683
- *
684
- * @param src - The source expression
685
- * @param type - The target type name
686
- * @param cast - Number of zero components to append
681
+ /**
682
+ * Creates a type cast expression
683
+ *
684
+ * @param src - The source expression
685
+ * @param type - The target type name
686
+ * @param cast - Number of zero components to append
687
687
  */ constructor(src, type, cast, fill){
688
688
  super();
689
689
  this.src = src.addRef();
@@ -691,15 +691,15 @@ class IRComparison extends IRExpression {
691
691
  this.fill = fill?.slice() ?? null;
692
692
  this.type = type;
693
693
  }
694
- /**
695
- * Generates shader code for the type cast
696
- *
697
- * @param pb - The program builder
698
- * @returns The casted shader expression
699
- *
700
- * @remarks
701
- * Creates a vector constructor with the source value followed by zeros.
702
- * Example: vec4(src, 0, 0) for casting vec2 to vec4.
694
+ /**
695
+ * Generates shader code for the type cast
696
+ *
697
+ * @param pb - The program builder
698
+ * @returns The casted shader expression
699
+ *
700
+ * @remarks
701
+ * Creates a vector constructor with the source value followed by zeros.
702
+ * Example: vec4(src, 0, 0) for casting vec2 to vec4.
703
703
  */ create(pb) {
704
704
  // @ts-ignore
705
705
  return pb[this.type](this.src.create(pb), ...this.fill ?? Array.from({
@@ -707,35 +707,35 @@ class IRComparison extends IRExpression {
707
707
  }).fill(0));
708
708
  }
709
709
  }
710
- /**
711
- * IR expression for texture sampling
712
- *
713
- * @remarks
714
- * Represents a texture lookup operation with optional normal map decoding.
715
- * Handles both color and normal map sampling with appropriate transformations.
716
- * Uses reference counting to cache the sampled result if used multiple times.
717
- *
718
- * @example
719
- * ```typescript
720
- * // Sample color texture
721
- * const color = new IRSampleTexture(texExpr, uvExpr, 'Color');
722
- *
723
- * // Sample normal map (automatically decodes from [0,1] to [-1,1])
724
- * const normal = new IRSampleTexture(texExpr, uvExpr, 'Normal');
725
- * ```
726
- *
727
- * @public
710
+ /**
711
+ * IR expression for texture sampling
712
+ *
713
+ * @remarks
714
+ * Represents a texture lookup operation with optional normal map decoding.
715
+ * Handles both color and normal map sampling with appropriate transformations.
716
+ * Uses reference counting to cache the sampled result if used multiple times.
717
+ *
718
+ * @example
719
+ * ```typescript
720
+ * // Sample color texture
721
+ * const color = new IRSampleTexture(texExpr, uvExpr, 'Color');
722
+ *
723
+ * // Sample normal map (automatically decodes from [0,1] to [-1,1])
724
+ * const normal = new IRSampleTexture(texExpr, uvExpr, 'Normal');
725
+ * ```
726
+ *
727
+ * @public
728
728
  */ class IRSampleTexture extends IRExpression {
729
729
  /** The texture expression */ tex;
730
730
  /** The texture coordinate expression */ coord;
731
731
  /** The sampler type determining how to interpret the sampled value */ samplerType;
732
732
  /** Cached temporary variable name if result is referenced multiple times */ tmpName;
733
- /**
734
- * Creates a texture sample expression
735
- *
736
- * @param tex - The texture to sample from
737
- * @param coord - The texture coordinates
738
- * @param samplerType - How to interpret the sampled value ('Color' or 'Normal')
733
+ /**
734
+ * Creates a texture sample expression
735
+ *
736
+ * @param tex - The texture to sample from
737
+ * @param coord - The texture coordinates
738
+ * @param samplerType - How to interpret the sampled value ('Color' or 'Normal')
739
739
  */ constructor(tex, coord, samplerType){
740
740
  super();
741
741
  this.tex = tex.addRef();
@@ -746,18 +746,18 @@ class IRComparison extends IRExpression {
746
746
  /** Reset for next creation */ reset() {
747
747
  this.tmpName = '';
748
748
  }
749
- /**
750
- * Generates shader code for the texture sample operation
751
- *
752
- * @param pb - The program builder
753
- * @returns The sampled color value
754
- *
755
- * @remarks
756
- * For normal maps, applies the transformation: normal * 2 - 1 to convert
757
- * from [0,1] texture space to [-1,1] tangent space.
758
- * Caches result in a temporary variable if referenced multiple times.
759
- *
760
- * @throws Error if texture coordinate is not a valid expression or array
749
+ /**
750
+ * Generates shader code for the texture sample operation
751
+ *
752
+ * @param pb - The program builder
753
+ * @returns The sampled color value
754
+ *
755
+ * @remarks
756
+ * For normal maps, applies the transformation: normal * 2 - 1 to convert
757
+ * from [0,1] texture space to [-1,1] tangent space.
758
+ * Caches result in a temporary variable if referenced multiple times.
759
+ *
760
+ * @throws Error if texture coordinate is not a valid expression or array
761
761
  */ create(pb) {
762
762
  if (this.tmpName) {
763
763
  return pb.getCurrentScope()[this.tmpName];
@@ -792,27 +792,27 @@ class IRComparison extends IRExpression {
792
792
  }
793
793
  }
794
794
  }
795
- /**
796
- * IR expression for texture uniform constants
797
- *
798
- * @remarks
799
- * Represents a texture parameter that will be bound as a uniform.
800
- * Includes sampler configuration for texture filtering and addressing modes.
801
- *
802
- * @example
803
- * ```typescript
804
- * const tex = new IRConstantTexture(
805
- * 'u_baseColorMap',
806
- * 'tex2d',
807
- * 'repeat',
808
- * 'repeat',
809
- * 'linear',
810
- * 'linear',
811
- * 'linear'
812
- * );
813
- * ```
814
- *
815
- * @public
795
+ /**
796
+ * IR expression for texture uniform constants
797
+ *
798
+ * @remarks
799
+ * Represents a texture parameter that will be bound as a uniform.
800
+ * Includes sampler configuration for texture filtering and addressing modes.
801
+ *
802
+ * @example
803
+ * ```typescript
804
+ * const tex = new IRConstantTexture(
805
+ * 'u_baseColorMap',
806
+ * 'tex2d',
807
+ * 'repeat',
808
+ * 'repeat',
809
+ * 'linear',
810
+ * 'linear',
811
+ * 'linear'
812
+ * );
813
+ * ```
814
+ *
815
+ * @public
816
816
  */ class IRConstantTexture extends IRExpression {
817
817
  /** The uniform texture variable name */ name;
818
818
  /** The texture id */ id;
@@ -824,18 +824,18 @@ class IRComparison extends IRExpression {
824
824
  /** Magnification filter mode */ filterMag;
825
825
  /** Mipmap filter mode */ filterMip;
826
826
  /** Whether texture params is used */ useParams;
827
- /**
828
- * Creates a texture constant expression
829
- *
830
- * @param name - The uniform variable name
831
- * @param id - The texture id
832
- * @param type - The texture type
833
- * @param sRGB - Whether this texture should be loaded in sRGB color space
834
- * @param addressU - Horizontal addressing mode
835
- * @param addressV - Vertical addressing mode
836
- * @param minFilter - Minification filter
837
- * @param magFilter - Magnification filter
838
- * @param mipFilter - Mipmap filter
827
+ /**
828
+ * Creates a texture constant expression
829
+ *
830
+ * @param name - The uniform variable name
831
+ * @param id - The texture id
832
+ * @param type - The texture type
833
+ * @param sRGB - Whether this texture should be loaded in sRGB color space
834
+ * @param addressU - Horizontal addressing mode
835
+ * @param addressV - Vertical addressing mode
836
+ * @param minFilter - Minification filter
837
+ * @param magFilter - Magnification filter
838
+ * @param mipFilter - Mipmap filter
839
839
  */ constructor(name, id, type, sRGB, addressU, addressV, minFilter, magFilter, mipFilter){
840
840
  super();
841
841
  this.name = name;
@@ -849,14 +849,14 @@ class IRComparison extends IRExpression {
849
849
  this.filterMip = mipFilter;
850
850
  this.useParams = false;
851
851
  }
852
- /**
853
- * Generates shader code for the texture uniform
854
- *
855
- * @param pb - The program builder
856
- * @returns The texture uniform reference
857
- *
858
- * @remarks
859
- * Creates the uniform declaration in the global scope if not already present.
852
+ /**
853
+ * Generates shader code for the texture uniform
854
+ *
855
+ * @param pb - The program builder
856
+ * @returns The texture uniform reference
857
+ *
858
+ * @remarks
859
+ * Creates the uniform declaration in the global scope if not already present.
860
860
  */ create(pb) {
861
861
  if (!pb.getGlobalScope()[this.name]) {
862
862
  // @ts-ignore
@@ -864,11 +864,11 @@ class IRComparison extends IRExpression {
864
864
  }
865
865
  return pb.getGlobalScope()[this.name];
866
866
  }
867
- /**
868
- * Converts to a uniform texture descriptor
869
- *
870
- * @param node - The texture node
871
- * @returns Uniform texture descriptor with texture and sampler references
867
+ /**
868
+ * Converts to a uniform texture descriptor
869
+ *
870
+ * @param node - The texture node
871
+ * @returns Uniform texture descriptor with texture and sampler references
872
872
  */ asUniformTexture() {
873
873
  return {
874
874
  name: this.name,
@@ -883,24 +883,24 @@ class IRComparison extends IRExpression {
883
883
  };
884
884
  }
885
885
  }
886
- /**
887
- * Material Blueprint Intermediate Representation
888
- *
889
- * @remarks
890
- * The IR is a compiled representation of the material node graph that can be
891
- * efficiently translated to shader code. It performs:
892
- * - Type checking and validation
893
- * - Expression optimization (common subexpression elimination via reference counting)
894
- * - Uniform extraction (constants become shader uniforms)
895
- * - Dependency analysis (determines required vertex attributes)
896
- *
897
- * The compilation process:
898
- * 1. Traverse the DAG in topological order
899
- * 2. Build an IR expression tree
900
- * 3. Track uniforms and behaviors
901
- * 4. Generate optimized shader code from the IR
902
- *
903
- * @public
886
+ /**
887
+ * Material Blueprint Intermediate Representation
888
+ *
889
+ * @remarks
890
+ * The IR is a compiled representation of the material node graph that can be
891
+ * efficiently translated to shader code. It performs:
892
+ * - Type checking and validation
893
+ * - Expression optimization (common subexpression elimination via reference counting)
894
+ * - Uniform extraction (constants become shader uniforms)
895
+ * - Dependency analysis (determines required vertex attributes)
896
+ *
897
+ * The compilation process:
898
+ * 1. Traverse the DAG in topological order
899
+ * 2. Build an IR expression tree
900
+ * 3. Track uniforms and behaviors
901
+ * 4. Generate optimized shader code from the IR
902
+ *
903
+ * @public
904
904
  */ class MaterialBlueprintIR {
905
905
  /** The directed acyclic graph of material nodes */ _dag;
906
906
  /** Unique hash identifying this material configuration */ _hash;
@@ -912,16 +912,16 @@ class IRComparison extends IRExpression {
912
912
  /** Fallback texture uniforms generated for TextureSample nodes without texture input */ _textureSampleFallbackMap;
913
913
  /** Flags indicating which shader features are used */ _behaviors;
914
914
  /** Array of named output expressions (e.g., baseColor, normal, metallic) */ _outputs;
915
- /**
916
- * Creates and compiles a material blueprint IR
917
- *
918
- * @param dag - The material node graph DAG
919
- * @param hash - Unique identifier for this material
920
- * @param editorState - Editor state snapshot
921
- *
922
- * @remarks
923
- * Automatically compiles the DAG during construction.
924
- * Check the `ok` property to verify successful compilation.
915
+ /**
916
+ * Creates and compiles a material blueprint IR
917
+ *
918
+ * @param dag - The material node graph DAG
919
+ * @param hash - Unique identifier for this material
920
+ * @param editorState - Editor state snapshot
921
+ *
922
+ * @remarks
923
+ * Automatically compiles the DAG during construction.
924
+ * Check the `ok` property to verify successful compilation.
925
925
  */ constructor(dag, hash, editorState){
926
926
  this._dag = dag ?? {
927
927
  nodeMap: {},
@@ -936,10 +936,10 @@ class IRComparison extends IRExpression {
936
936
  this._editorState = editorState;
937
937
  this.compile();
938
938
  }
939
- /**
940
- * Whether the IR compiled successfully
941
- *
942
- * @returns True if compilation produced valid outputs
939
+ /**
940
+ * Whether the IR compiled successfully
941
+ *
942
+ * @returns True if compilation produced valid outputs
943
943
  */ get ok() {
944
944
  return this._outputs ? this._outputs.length > 0 : false;
945
945
  }
@@ -964,17 +964,17 @@ class IRComparison extends IRExpression {
964
964
  /** Gets the array of uniform textures to bind at runtime */ get uniformTextures() {
965
965
  return this._uniformTextures;
966
966
  }
967
- /**
968
- * Compiles the material node graph to IR
969
- *
970
- * @returns True if compilation succeeded, false otherwise
971
- *
972
- * @remarks
973
- * Processes all root nodes (typically a single material output node)
974
- * and builds IR expressions for all connected inputs.
975
- * Collects all required uniforms and sets behavior flags.
976
- *
977
- * Compilation fails if any required input is missing.
967
+ /**
968
+ * Compiles the material node graph to IR
969
+ *
970
+ * @returns True if compilation succeeded, false otherwise
971
+ *
972
+ * @remarks
973
+ * Processes all root nodes (typically a single material output node)
974
+ * and builds IR expressions for all connected inputs.
975
+ * Collects all required uniforms and sets behavior flags.
976
+ *
977
+ * Compilation fails if any required input is missing.
978
978
  */ compile() {
979
979
  this.reset();
980
980
  this._outputs = [];
@@ -1014,24 +1014,24 @@ class IRComparison extends IRExpression {
1014
1014
  }
1015
1015
  return true;
1016
1016
  }
1017
- /**
1018
- * Generates shader code from the IR
1019
- *
1020
- * @param pb - The program builder to generate code with
1021
- * @returns Array of named shader expressions, or null if IR is invalid
1022
- *
1023
- * @remarks
1024
- * Translates all IR expressions to actual shader code.
1025
- * Should be called within a shader function scope.
1026
- *
1027
- * @example
1028
- * ```typescript
1029
- * pb.fragmentShader(function() {
1030
- * const outputs = ir.create(this);
1031
- * this.baseColor = outputs.find(o => o.name === 'baseColor').exp;
1032
- * this.normal = outputs.find(o => o.name === 'normal').exp;
1033
- * });
1034
- * ```
1017
+ /**
1018
+ * Generates shader code from the IR
1019
+ *
1020
+ * @param pb - The program builder to generate code with
1021
+ * @returns Array of named shader expressions, or null if IR is invalid
1022
+ *
1023
+ * @remarks
1024
+ * Translates all IR expressions to actual shader code.
1025
+ * Should be called within a shader function scope.
1026
+ *
1027
+ * @example
1028
+ * ```typescript
1029
+ * pb.fragmentShader(function() {
1030
+ * const outputs = ir.create(this);
1031
+ * this.baseColor = outputs.find(o => o.name === 'baseColor').exp;
1032
+ * this.normal = outputs.find(o => o.name === 'normal').exp;
1033
+ * });
1034
+ * ```
1035
1035
  */ create(pb) {
1036
1036
  if (!this._outputs) {
1037
1037
  return null;
@@ -1048,12 +1048,12 @@ class IRComparison extends IRExpression {
1048
1048
  }
1049
1049
  return outputs;
1050
1050
  }
1051
- /**
1052
- * Resets the IR state for recompilation
1053
- *
1054
- * @remarks
1055
- * Clears all compiled data including expressions, uniforms, and behaviors.
1056
- * Called at the start of compilation.
1051
+ /**
1052
+ * Resets the IR state for recompilation
1053
+ *
1054
+ * @remarks
1055
+ * Clears all compiled data including expressions, uniforms, and behaviors.
1056
+ * Called at the start of compilation.
1057
1057
  */ reset() {
1058
1058
  this._expressions = [];
1059
1059
  this._expressionMap = new Map();
@@ -1066,19 +1066,19 @@ class IRComparison extends IRExpression {
1066
1066
  useVertexUV: false
1067
1067
  };
1068
1068
  }
1069
- /**
1070
- * Converts a graph node to an IR expression
1071
- *
1072
- * @param node - The graph node to convert
1073
- * @param output - The output slot ID
1074
- * @param originType - Optional type override for type casting
1075
- * @returns The corresponding IR expression
1076
- *
1077
- * @remarks
1078
- * Main dispatch method that routes to specific converters based on node type.
1079
- * Handles automatic type casting when originType differs from node output type.
1080
- *
1081
- * @throws Error if type casting is invalid
1069
+ /**
1070
+ * Converts a graph node to an IR expression
1071
+ *
1072
+ * @param node - The graph node to convert
1073
+ * @param output - The output slot ID
1074
+ * @param originType - Optional type override for type casting
1075
+ * @returns The corresponding IR expression
1076
+ *
1077
+ * @remarks
1078
+ * Main dispatch method that routes to specific converters based on node type.
1079
+ * Handles automatic type casting when originType differs from node output type.
1080
+ *
1081
+ * @throws Error if type casting is invalid
1082
1082
  */ ir(inputNode) {
1083
1083
  const node = inputNode.inputNode;
1084
1084
  const output = inputNode.inputId;
@@ -1206,19 +1206,19 @@ class IRComparison extends IRExpression {
1206
1206
  }
1207
1207
  return expr;
1208
1208
  }
1209
- /**
1210
- * Gets or creates an IR expression for a graph node
1211
- *
1212
- * @param node - The graph node
1213
- * @param outputId - The output slot ID
1214
- * @param ctor - The IR expression constructor
1215
- * @param args - Constructor arguments
1216
- * @returns The cached or newly created IR expression
1217
- *
1218
- * @remarks
1219
- * Implements common subexpression elimination by caching expressions per node.
1220
- * Handles output slot swizzling and type casting.
1221
- * Collects uniform values and textures.
1209
+ /**
1210
+ * Gets or creates an IR expression for a graph node
1211
+ *
1212
+ * @param node - The graph node
1213
+ * @param outputId - The output slot ID
1214
+ * @param ctor - The IR expression constructor
1215
+ * @param args - Constructor arguments
1216
+ * @returns The cached or newly created IR expression
1217
+ *
1218
+ * @remarks
1219
+ * Implements common subexpression elimination by caching expressions per node.
1220
+ * Handles output slot swizzling and type casting.
1221
+ * Collects uniform values and textures.
1222
1222
  */ getOrCreateIRExpression(node, outputId, ctor, ...args) {
1223
1223
  let ir;
1224
1224
  if (!this._expressionMap.has(node)) {
@@ -1473,11 +1473,11 @@ class IRComparison extends IRExpression {
1473
1473
  this.$l.objUp = pb.normalize(pb.div(pb.mul(this.cameraUp, this.rotation), this.objScale));
1474
1474
  this.$l.objRight = pb.normalize(pb.div(pb.mul(this.cameraRight, this.rotation), this.objScale));
1475
1475
  // make ortho
1476
- /*
1477
- this.objRight = pb.normalize(
1478
- pb.sub(this.objRight, pb.mul(this.objUp, pb.dot(this.objRight, this.objUp)))
1479
- );
1480
- this.objForward = pb.cross(this.objUp, this.objRight);
1476
+ /*
1477
+ this.objRight = pb.normalize(
1478
+ pb.sub(this.objRight, pb.mul(this.objUp, pb.dot(this.objRight, this.objUp)))
1479
+ );
1480
+ this.objForward = pb.cross(this.objUp, this.objRight);
1481
1481
  */ // make rotation matrix
1482
1482
  this.$l.billboardMatrix = pb.mat3(this.objRight.x, this.objUp.x, this.objForward.x, this.objRight.y, this.objUp.y, this.objForward.y, this.objRight.z, this.objUp.z, this.objForward.z);
1483
1483
  this.$return(pb.transpose(this.billboardMatrix));