@zephyr3d/scene 0.7.0 → 0.7.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 (319) hide show
  1. package/dist/animation/animation.js +4 -15
  2. package/dist/animation/animation.js.map +1 -1
  3. package/dist/animation/animationset.js +22 -9
  4. package/dist/animation/animationset.js.map +1 -1
  5. package/dist/animation/animationtrack.js +1 -0
  6. package/dist/animation/animationtrack.js.map +1 -1
  7. package/dist/animation/eulerrotationtrack.js +0 -1
  8. package/dist/animation/eulerrotationtrack.js.map +1 -1
  9. package/dist/animation/morphtarget.js +7 -1
  10. package/dist/animation/morphtarget.js.map +1 -1
  11. package/dist/animation/morphtrack.js +3 -3
  12. package/dist/animation/morphtrack.js.map +1 -1
  13. package/dist/animation/proptrack.js +37 -41
  14. package/dist/animation/proptrack.js.map +1 -1
  15. package/dist/animation/rotationtrack.js +0 -1
  16. package/dist/animation/rotationtrack.js.map +1 -1
  17. package/dist/animation/scaletrack.js +0 -1
  18. package/dist/animation/scaletrack.js.map +1 -1
  19. package/dist/animation/skeleton.js +7 -14
  20. package/dist/animation/skeleton.js.map +1 -1
  21. package/dist/animation/translationtrack.js +0 -1
  22. package/dist/animation/translationtrack.js.map +1 -1
  23. package/dist/app/api.js +13 -4
  24. package/dist/app/api.js.map +1 -1
  25. package/dist/app/app.js +13 -1
  26. package/dist/app/app.js.map +1 -1
  27. package/dist/app/engine.js +33 -45
  28. package/dist/app/engine.js.map +1 -1
  29. package/dist/app/inputmgr.js.map +1 -1
  30. package/dist/app/runtimescript.js.map +1 -1
  31. package/dist/app/screen.js +318 -0
  32. package/dist/app/screen.js.map +1 -0
  33. package/dist/app/scriptingsystem.js +10 -6
  34. package/dist/app/scriptingsystem.js.map +1 -1
  35. package/dist/app/scriptregistry.js +11 -22
  36. package/dist/app/scriptregistry.js.map +1 -1
  37. package/dist/asset/assetmanager.js +79 -58
  38. package/dist/asset/assetmanager.js.map +1 -1
  39. package/dist/asset/builtin.js +5 -5
  40. package/dist/asset/builtin.js.map +1 -1
  41. package/dist/asset/loaders/dds/dds.js +6 -2
  42. package/dist/asset/loaders/dds/dds.js.map +1 -1
  43. package/dist/asset/loaders/dds/dds_loader.js +1 -1
  44. package/dist/asset/loaders/dds/dds_loader.js.map +1 -1
  45. package/dist/asset/loaders/gltf/gltf_loader.js +14 -6
  46. package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
  47. package/dist/asset/loaders/gltf/helpers.js +6 -2
  48. package/dist/asset/loaders/gltf/helpers.js.map +1 -1
  49. package/dist/asset/loaders/hdr/hdr.js +22 -15
  50. package/dist/asset/loaders/hdr/hdr.js.map +1 -1
  51. package/dist/asset/loaders/image/tga_Loader.js +2 -1
  52. package/dist/asset/loaders/image/tga_Loader.js.map +1 -1
  53. package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
  54. package/dist/asset/loaders/loader.js +2 -2
  55. package/dist/asset/loaders/loader.js.map +1 -1
  56. package/dist/asset/model.js +2 -2
  57. package/dist/asset/model.js.map +1 -1
  58. package/dist/blitter/bilateralblur.js.map +1 -1
  59. package/dist/blitter/blitter.js +9 -11
  60. package/dist/blitter/blitter.js.map +1 -1
  61. package/dist/blitter/box.js +0 -1
  62. package/dist/blitter/box.js.map +1 -1
  63. package/dist/blitter/copy.js.map +1 -1
  64. package/dist/blitter/gaussianblur.js.map +1 -1
  65. package/dist/camera/base.js +1 -3
  66. package/dist/camera/base.js.map +1 -1
  67. package/dist/camera/camera.js +121 -37
  68. package/dist/camera/camera.js.map +1 -1
  69. package/dist/camera/fps.js +19 -17
  70. package/dist/camera/fps.js.map +1 -1
  71. package/dist/camera/orbit.js +45 -43
  72. package/dist/camera/orbit.js.map +1 -1
  73. package/dist/camera/orthocamera.js +27 -21
  74. package/dist/camera/orthocamera.js.map +1 -1
  75. package/dist/camera/perspectivecamera.js +26 -17
  76. package/dist/camera/perspectivecamera.js.map +1 -1
  77. package/dist/index.d.ts +14453 -15609
  78. package/dist/index.js +17 -11
  79. package/dist/index.js.map +1 -1
  80. package/dist/material/blinn.js.map +1 -1
  81. package/dist/material/grassmaterial.js.map +1 -1
  82. package/dist/material/lambert.js.map +1 -1
  83. package/dist/material/material.js +11 -5
  84. package/dist/material/material.js.map +1 -1
  85. package/dist/material/meshmaterial.js +10 -9
  86. package/dist/material/meshmaterial.js.map +1 -1
  87. package/dist/material/mixins/albedocolor.js.map +1 -1
  88. package/dist/material/mixins/foliage.js.map +1 -1
  89. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  90. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  91. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +7 -0
  92. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
  93. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  94. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  95. package/dist/material/mixins/lit.js +3 -3
  96. package/dist/material/mixins/lit.js.map +1 -1
  97. package/dist/material/mixins/pbr/brdf.js.map +1 -1
  98. package/dist/material/mixins/pbr/common.js.map +1 -1
  99. package/dist/material/mixins/texture.js +3 -0
  100. package/dist/material/mixins/texture.js.map +1 -1
  101. package/dist/material/mixins/vertexcolor.js.map +1 -1
  102. package/dist/material/particle.js.map +1 -1
  103. package/dist/material/pbrblueprint.js +180 -22
  104. package/dist/material/pbrblueprint.js.map +1 -1
  105. package/dist/material/pbrmr.js.map +1 -1
  106. package/dist/material/pbrsg.js.map +1 -1
  107. package/dist/material/shader/helper.js +36 -53
  108. package/dist/material/shader/helper.js.map +1 -1
  109. package/dist/material/sprite.js +301 -0
  110. package/dist/material/sprite.js.map +1 -0
  111. package/dist/material/sprite3d.js +301 -0
  112. package/dist/material/sprite3d.js.map +1 -0
  113. package/dist/material/sprite3d_std.js +116 -0
  114. package/dist/material/sprite3d_std.js.map +1 -0
  115. package/dist/material/sprite3dblueprint.js +235 -0
  116. package/dist/material/sprite3dblueprint.js.map +1 -0
  117. package/dist/material/sprite_std.js +116 -0
  118. package/dist/material/sprite_std.js.map +1 -0
  119. package/dist/material/spriteblueprint.js +235 -0
  120. package/dist/material/spriteblueprint.js.map +1 -0
  121. package/dist/material/terrain-cm.js +0 -1
  122. package/dist/material/terrain-cm.js.map +1 -1
  123. package/dist/material/unlit.js.map +1 -1
  124. package/dist/material/water.js.map +1 -1
  125. package/dist/posteffect/bloom.js.map +1 -1
  126. package/dist/posteffect/compositor.js.map +1 -1
  127. package/dist/posteffect/fxaa.js.map +1 -1
  128. package/dist/posteffect/grayscale.js.map +1 -1
  129. package/dist/posteffect/motionblur.js.map +1 -1
  130. package/dist/posteffect/posteffect.js.map +1 -1
  131. package/dist/posteffect/sao.js.map +1 -1
  132. package/dist/posteffect/ssr.js +7 -5
  133. package/dist/posteffect/ssr.js.map +1 -1
  134. package/dist/posteffect/taa.js.map +1 -1
  135. package/dist/posteffect/tonemap.js.map +1 -1
  136. package/dist/render/abuffer_oit.js +8 -6
  137. package/dist/render/abuffer_oit.js.map +1 -1
  138. package/dist/render/clipmap.js +0 -10
  139. package/dist/render/clipmap.js.map +1 -1
  140. package/dist/render/cluster_light.js +4 -4
  141. package/dist/render/cluster_light.js.map +1 -1
  142. package/dist/render/cull_visitor.js +15 -17
  143. package/dist/render/cull_visitor.js.map +1 -1
  144. package/dist/render/depthpass.js +3 -4
  145. package/dist/render/depthpass.js.map +1 -1
  146. package/dist/render/drawable.js +15 -0
  147. package/dist/render/drawable.js.map +1 -0
  148. package/dist/render/drawable_mixin.js +8 -4
  149. package/dist/render/drawable_mixin.js.map +1 -1
  150. package/dist/render/envlight.js.map +1 -1
  151. package/dist/render/fbm_wavegenerator.js +3 -1
  152. package/dist/render/fbm_wavegenerator.js.map +1 -1
  153. package/dist/render/fft_wavegenerator.js +67 -64
  154. package/dist/render/fft_wavegenerator.js.map +1 -1
  155. package/dist/render/fullscreenquad.js.map +1 -1
  156. package/dist/render/gerstner_wavegenerator.js +3 -1
  157. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  158. package/dist/render/globalbindgroup_allocator.js +3 -1
  159. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  160. package/dist/render/hzb.js +1 -2
  161. package/dist/render/hzb.js.map +1 -1
  162. package/dist/render/lightpass.js +13 -13
  163. package/dist/render/lightpass.js.map +1 -1
  164. package/dist/render/objectcolorpass.js +4 -7
  165. package/dist/render/objectcolorpass.js.map +1 -1
  166. package/dist/render/primitive.js +4 -5
  167. package/dist/render/primitive.js.map +1 -1
  168. package/dist/render/render_queue.js +10 -5
  169. package/dist/render/render_queue.js.map +1 -1
  170. package/dist/render/renderer.js +16 -22
  171. package/dist/render/renderer.js.map +1 -1
  172. package/dist/render/renderpass.js +27 -52
  173. package/dist/render/renderpass.js.map +1 -1
  174. package/dist/render/rendertarget.js +5 -0
  175. package/dist/render/rendertarget.js.map +1 -0
  176. package/dist/render/screenrendertarget.js +56 -0
  177. package/dist/render/screenrendertarget.js.map +1 -0
  178. package/dist/render/shadowmap_pass.js +4 -5
  179. package/dist/render/shadowmap_pass.js.map +1 -1
  180. package/dist/render/sky.js +16 -14
  181. package/dist/render/sky.js.map +1 -1
  182. package/dist/render/weightedblended_oit.js.map +1 -1
  183. package/dist/scene/basesprite.js +296 -0
  184. package/dist/scene/basesprite.js.map +1 -0
  185. package/dist/scene/batchgroup.js +4 -2
  186. package/dist/scene/batchgroup.js.map +1 -1
  187. package/dist/scene/environment.js +9 -10
  188. package/dist/scene/environment.js.map +1 -1
  189. package/dist/scene/graph_node.js.map +1 -1
  190. package/dist/scene/light.js +22 -4
  191. package/dist/scene/light.js.map +1 -1
  192. package/dist/scene/mesh.js +93 -15
  193. package/dist/scene/mesh.js.map +1 -1
  194. package/dist/scene/octree.js.map +1 -1
  195. package/dist/scene/particlesys.js +25 -22
  196. package/dist/scene/particlesys.js.map +1 -1
  197. package/dist/scene/raycast_visitor.js +0 -16
  198. package/dist/scene/raycast_visitor.js.map +1 -1
  199. package/dist/scene/scene.js +7 -4
  200. package/dist/scene/scene.js.map +1 -1
  201. package/dist/scene/scene_node.js +20 -35
  202. package/dist/scene/scene_node.js.map +1 -1
  203. package/dist/scene/sprite.js +18 -0
  204. package/dist/scene/sprite.js.map +1 -0
  205. package/dist/scene/sprite3d.js +18 -0
  206. package/dist/scene/sprite3d.js.map +1 -0
  207. package/dist/scene/terrain-cm/grass.js +5 -4
  208. package/dist/scene/terrain-cm/grass.js.map +1 -1
  209. package/dist/scene/terrain-cm/grassmaterial.js +3 -1
  210. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  211. package/dist/scene/terrain-cm/terrain-cm.js +65 -48
  212. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  213. package/dist/scene/water.js +35 -30
  214. package/dist/scene/water.js.map +1 -1
  215. package/dist/shaders/atmosphere.js +17 -29
  216. package/dist/shaders/atmosphere.js.map +1 -1
  217. package/dist/shaders/fog.js.map +1 -1
  218. package/dist/shaders/misc.js.map +1 -1
  219. package/dist/shaders/noise.js.map +1 -1
  220. package/dist/shaders/pbr.js.map +1 -1
  221. package/dist/shaders/shadow.js.map +1 -1
  222. package/dist/shaders/ssr.js.map +1 -1
  223. package/dist/shaders/temporal.js.map +1 -1
  224. package/dist/shaders/water.js.map +1 -1
  225. package/dist/shadow/esm.js +1 -1
  226. package/dist/shadow/esm.js.map +1 -1
  227. package/dist/shadow/pcf_opt.js.map +1 -1
  228. package/dist/shadow/pcf_pd.js.map +1 -1
  229. package/dist/shadow/shader.js +3 -1
  230. package/dist/shadow/shader.js.map +1 -1
  231. package/dist/shadow/shadow_impl.js.map +1 -1
  232. package/dist/shadow/shadowmapper.js +6 -18
  233. package/dist/shadow/shadowmapper.js.map +1 -1
  234. package/dist/shadow/ssm.js.map +1 -1
  235. package/dist/shadow/vsm.js.map +1 -1
  236. package/dist/shapes/box.js +9 -3
  237. package/dist/shapes/box.js.map +1 -1
  238. package/dist/shapes/cylinder.js +2 -2
  239. package/dist/shapes/cylinder.js.map +1 -1
  240. package/dist/shapes/plane.js +2 -2
  241. package/dist/shapes/plane.js.map +1 -1
  242. package/dist/shapes/shape.js +2 -1
  243. package/dist/shapes/shape.js.map +1 -1
  244. package/dist/shapes/sphere.js +2 -2
  245. package/dist/shapes/sphere.js.map +1 -1
  246. package/dist/shapes/tetrahedron.js +5 -6
  247. package/dist/shapes/tetrahedron.js.map +1 -1
  248. package/dist/shapes/torus.js +2 -2
  249. package/dist/shapes/torus.js.map +1 -1
  250. package/dist/utility/aabbtree.js +1 -1
  251. package/dist/utility/aabbtree.js.map +1 -1
  252. package/dist/utility/blueprint/common/constants.js +578 -104
  253. package/dist/utility/blueprint/common/constants.js.map +1 -1
  254. package/dist/utility/blueprint/common/math.js +471 -9
  255. package/dist/utility/blueprint/common/math.js.map +1 -1
  256. package/dist/utility/blueprint/common.js +1 -1
  257. package/dist/utility/blueprint/common.js.map +1 -1
  258. package/dist/utility/blueprint/material/func.js +9 -5
  259. package/dist/utility/blueprint/material/func.js.map +1 -1
  260. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  261. package/dist/utility/blueprint/material/ir.js +288 -80
  262. package/dist/utility/blueprint/material/ir.js.map +1 -1
  263. package/dist/utility/blueprint/material/pbr.js +92 -4
  264. package/dist/utility/blueprint/material/pbr.js.map +1 -1
  265. package/dist/utility/blueprint/material/texture.js +62 -45
  266. package/dist/utility/blueprint/material/texture.js.map +1 -1
  267. package/dist/utility/blueprint/node.js +28 -1
  268. package/dist/utility/blueprint/node.js.map +1 -1
  269. package/dist/utility/bounding_volume.js.map +1 -1
  270. package/dist/utility/debug.js.map +1 -1
  271. package/dist/utility/draco/decoder.js.map +1 -1
  272. package/dist/utility/misc.js +1 -1
  273. package/dist/utility/misc.js.map +1 -1
  274. package/dist/utility/panorama.js.map +1 -1
  275. package/dist/utility/pmrem.js.map +1 -1
  276. package/dist/utility/rendermipmap.js.map +1 -1
  277. package/dist/utility/serialization/json.js +19 -15
  278. package/dist/utility/serialization/json.js.map +1 -1
  279. package/dist/utility/serialization/manager.js +89 -22
  280. package/dist/utility/serialization/manager.js.map +1 -1
  281. package/dist/utility/serialization/scene/animation.js +23 -21
  282. package/dist/utility/serialization/scene/animation.js.map +1 -1
  283. package/dist/utility/serialization/scene/batch.js +4 -3
  284. package/dist/utility/serialization/scene/batch.js.map +1 -1
  285. package/dist/utility/serialization/scene/camera.js +97 -9
  286. package/dist/utility/serialization/scene/camera.js.map +1 -1
  287. package/dist/utility/serialization/scene/common.js +102 -28
  288. package/dist/utility/serialization/scene/common.js.map +1 -1
  289. package/dist/utility/serialization/scene/light.js +14 -12
  290. package/dist/utility/serialization/scene/light.js.map +1 -1
  291. package/dist/utility/serialization/scene/material.js +154 -26
  292. package/dist/utility/serialization/scene/material.js.map +1 -1
  293. package/dist/utility/serialization/scene/mesh.js +71 -100
  294. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  295. package/dist/utility/serialization/scene/misc.js +3 -2
  296. package/dist/utility/serialization/scene/misc.js.map +1 -1
  297. package/dist/utility/serialization/scene/node.js +42 -9
  298. package/dist/utility/serialization/scene/node.js.map +1 -1
  299. package/dist/utility/serialization/scene/particle.js +7 -5
  300. package/dist/utility/serialization/scene/particle.js.map +1 -1
  301. package/dist/utility/serialization/scene/primitive.js +18 -15
  302. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  303. package/dist/utility/serialization/scene/scene.js +3 -2
  304. package/dist/utility/serialization/scene/scene.js.map +1 -1
  305. package/dist/utility/serialization/scene/sprite.js +164 -0
  306. package/dist/utility/serialization/scene/sprite.js.map +1 -0
  307. package/dist/utility/serialization/scene/terrain.js +8 -6
  308. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  309. package/dist/utility/serialization/scene/water.js +11 -9
  310. package/dist/utility/serialization/scene/water.js.map +1 -1
  311. package/dist/utility/serialization/types.js +6 -0
  312. package/dist/utility/serialization/types.js.map +1 -0
  313. package/dist/utility/shprojector.js.map +1 -1
  314. package/dist/utility/textures/ggxlut.js.map +1 -1
  315. package/dist/utility/textures/gradientnoise.js.map +1 -1
  316. package/dist/utility/textures/randomnoise.js.map +1 -1
  317. package/dist/values.js +14 -14
  318. package/dist/values.js.map +1 -1
  319. package/package.json +80 -80
@@ -1,8 +1,8 @@
1
1
  import { PBShaderExp } from '@zephyr3d/device';
2
- import { ConstantScalarNode, ConstantVec2Node, ConstantVec3Node, ConstantVec4Node } from '../common/constants.js';
2
+ import { ConstantScalarNode, ConstantVec2Node, ConstantVec3Node, ConstantVec4Node, ConstantBooleanNode, ConstantBVec2Node, ConstantBVec3Node, ConstantBVec4Node } from '../common/constants.js';
3
3
  import { ASSERT } from '@zephyr3d/base';
4
4
  import { BaseTextureNode, TextureSampleNode } from './texture.js';
5
- import { MakeVectorNode, SwizzleNode, Hash1Node, Hash2Node, Hash3Node, SimplexNoise2DNode, PerlinNoise2DNode, GenericMathNode, TransformNode } from '../common/math.js';
5
+ import { MakeVectorNode, SwizzleNode, CompComparisonNode, AnyConditionNode, AllConditionNode, SelectionNode, Hash1Node, Hash2Node, Hash3Node, SimplexNoise2DNode, PerlinNoise2DNode, GenericMathNode, TransformNode } from '../common/math.js';
6
6
  import { ResolveVertexPositionNode, ResolveVertexNormalNode, ResolveVertexTangentNode, VertexColorNode, VertexUVNode, VertexPositionNode, VertexNormalNode, VertexTangentNode, VertexBinormalNode, ViewMatrixNode, ProjectionMatrixNode, ViewProjMatrixNode, InvProjMatrixNode, InvViewProjMatrixNode, BillboardMatrixNode, CameraPositionNode, CameraNearFarNode, SkyEnvTextureNode, ElapsedTimeNode } from './inputs.js';
7
7
  import { ShaderHelper } from '../../../material/shader/helper.js';
8
8
  import { FunctionCallNode, FunctionInputNode, FunctionOutputNode } from './func.js';
@@ -96,19 +96,6 @@ import { VertexBlockNode } from './pbr.js';
96
96
  /**
97
97
  * IR expression for a constant scalar (float) value
98
98
  *
99
- * @remarks
100
- * Represents either a literal constant or a uniform parameter.
101
- * If a parameter name is provided, generates a uniform; otherwise, uses a literal.
102
- *
103
- * @example
104
- * ```typescript
105
- * // Literal constant
106
- * const literal = new IRConstantf(1.5, '');
107
- *
108
- * // Uniform parameter
109
- * const uniform = new IRConstantf(1.0, 'u_roughness');
110
- * ```
111
- *
112
99
  * @public
113
100
  */ class IRConstantf extends IRExpression {
114
101
  /** The constant float value */ value;
@@ -157,20 +144,30 @@ import { VertexBlockNode } from './pbr.js';
157
144
  }
158
145
  }
159
146
  /**
160
- * IR expression for a constant vector value
161
- *
162
- * @remarks
163
- * Represents vec2, vec3, or vec4 constants.
164
- * Can be either literals or uniform parameters.
147
+ * IR expression for a constant scalar (boolean) value
165
148
  *
166
- * @example
167
- * ```typescript
168
- * // Literal vec3
169
- * const color = new IRConstantfv([1.0, 0.0, 0.0], '');
170
- *
171
- * // Uniform vec2
172
- * const param = new IRConstantfv([0.5, 0.5], 'u_offset');
173
- * ```
149
+ * @public
150
+ */ class IRConstantb extends IRExpression {
151
+ /** The constant boolean value */ value;
152
+ /**
153
+ * Creates a constant boolean expression
154
+ *
155
+ * @param value - The boolean value
156
+ */ constructor(value){
157
+ super();
158
+ this.value = value;
159
+ }
160
+ /**
161
+ * Generates shader code for this constant
162
+ *
163
+ * @returns The literal boolean value
164
+ *
165
+ */ create() {
166
+ return this.value;
167
+ }
168
+ }
169
+ /**
170
+ * IR expression for a constant vector value
174
171
  *
175
172
  * @public
176
173
  */ class IRConstantfv extends IRExpression {
@@ -200,11 +197,13 @@ import { VertexBlockNode } from './pbr.js';
200
197
  */ create(pb) {
201
198
  if (this.name) {
202
199
  if (!pb.getGlobalScope()[this.name]) {
200
+ // @ts-ignore
203
201
  pb.getGlobalScope()[this.name] = pb[`vec${this.value.length}`]().uniform(2);
204
202
  }
205
203
  return pb.getGlobalScope()[this.name];
206
204
  }
207
- return Array.isArray(this.value) ? pb[`vec${this.value.length}`](...this.value) : this.value;
205
+ return(// @ts-ignore
206
+ Array.isArray(this.value) ? pb[`vec${this.value.length}`](...this.value) : this.value);
208
207
  }
209
208
  /**
210
209
  * Converts to a uniform value descriptor
@@ -219,6 +218,31 @@ import { VertexBlockNode } from './pbr.js';
219
218
  } : null;
220
219
  }
221
220
  }
221
+ /**
222
+ * IR expression for a constant boolean vector value
223
+ *
224
+ * @public
225
+ */ class IRConstantbv extends IRExpression {
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)
231
+ */ constructor(value){
232
+ super();
233
+ this.value = value;
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
241
+ */ create(pb) {
242
+ // @ts-ignore
243
+ return pb[`bvec${this.value.length}`](...this.value);
244
+ }
245
+ }
222
246
  /**
223
247
  * IR expression for shader input variables
224
248
  *
@@ -306,10 +330,11 @@ import { VertexBlockNode } from './pbr.js';
306
330
  */ create(pb) {
307
331
  if (this.tmpName) {
308
332
  const exp = pb.getCurrentScope()[this.tmpName];
309
- ASSERT(exp, 'expression not exists');
333
+ ASSERT(!!exp, 'expression not exists');
310
334
  return exp;
311
335
  }
312
336
  const params = this.params.map((param)=>param instanceof IRExpression ? param.create(pb) : param);
337
+ // @ts-ignore
313
338
  const exp = typeof this.func === 'string' ? pb[this.func](...params) : this.func(pb, ...params);
314
339
  if (this._ref === 1) {
315
340
  return exp;
@@ -420,10 +445,12 @@ import { VertexBlockNode } from './pbr.js';
420
445
  }
421
446
  const that = this;
422
447
  const ir = this.node.IR;
448
+ // @ts-ignore
423
449
  const params = this.node.args.map((v)=>pb[v.type](v.name));
424
450
  pb.func(this.node.name, params, function() {
425
451
  const outputs = ir.create(pb);
426
452
  const rettype = pb.defineStruct(that.node.outputs.map((output, index)=>{
453
+ // @ts-ignore
427
454
  return pb[that.node.outs[index].type](output.swizzle);
428
455
  }));
429
456
  this.$return(rettype(...outputs.map((output)=>{
@@ -441,6 +468,143 @@ import { VertexBlockNode } from './pbr.js';
441
468
  }
442
469
  }
443
470
  }
471
+ class IRSelection extends IRExpression {
472
+ a;
473
+ b;
474
+ cond;
475
+ tmpName;
476
+ constructor(a, b, cond){
477
+ super();
478
+ this.a = a.addRef();
479
+ this.b = b.addRef();
480
+ this.cond = cond.addRef();
481
+ this.tmpName = '';
482
+ }
483
+ reset() {
484
+ this.tmpName = '';
485
+ }
486
+ create(pb) {
487
+ if (this.tmpName) {
488
+ return pb.getCurrentScope()[this.tmpName];
489
+ }
490
+ const a = this.a.create(pb);
491
+ const b = this.b.create(pb);
492
+ const c = this.cond.create(pb);
493
+ const exp = pb.select(a, b, typeof c === 'number' ? c !== 0 : c);
494
+ if (this._ref === 1) {
495
+ return exp;
496
+ } else {
497
+ this.tmpName = this.getTmpName(pb.getCurrentScope());
498
+ pb.getCurrentScope()[this.tmpName] = exp;
499
+ return pb.getCurrentScope()[this.tmpName];
500
+ }
501
+ }
502
+ }
503
+ class IRAny extends IRExpression {
504
+ src;
505
+ tmpName;
506
+ constructor(src){
507
+ super();
508
+ this.src = src.addRef();
509
+ this.tmpName = '';
510
+ }
511
+ reset() {
512
+ this.tmpName = '';
513
+ }
514
+ create(pb) {
515
+ if (this.tmpName) {
516
+ return pb.getCurrentScope()[this.tmpName];
517
+ }
518
+ const src = this.src.create(pb);
519
+ const exp = pb.any(src);
520
+ if (this._ref === 1) {
521
+ return exp;
522
+ } else {
523
+ this.tmpName = this.getTmpName(pb.getCurrentScope());
524
+ pb.getCurrentScope()[this.tmpName] = exp;
525
+ return pb.getCurrentScope()[this.tmpName];
526
+ }
527
+ }
528
+ }
529
+ class IRAll extends IRExpression {
530
+ src;
531
+ tmpName;
532
+ constructor(src){
533
+ super();
534
+ this.src = src.addRef();
535
+ this.tmpName = '';
536
+ }
537
+ reset() {
538
+ this.tmpName = '';
539
+ }
540
+ create(pb) {
541
+ if (this.tmpName) {
542
+ return pb.getCurrentScope()[this.tmpName];
543
+ }
544
+ const src = this.src.create(pb);
545
+ const exp = pb.all(src);
546
+ if (this._ref === 1) {
547
+ return exp;
548
+ } else {
549
+ this.tmpName = this.getTmpName(pb.getCurrentScope());
550
+ pb.getCurrentScope()[this.tmpName] = exp;
551
+ return pb.getCurrentScope()[this.tmpName];
552
+ }
553
+ }
554
+ }
555
+ class IRComparison extends IRExpression {
556
+ a;
557
+ b;
558
+ mode;
559
+ tmpName;
560
+ constructor(a, b, mode){
561
+ super();
562
+ this.a = a.addRef();
563
+ this.b = b.addRef();
564
+ this.mode = mode;
565
+ this.tmpName = '';
566
+ }
567
+ /** Reset for next creation */ reset() {
568
+ this.tmpName = '';
569
+ }
570
+ create(pb) {
571
+ if (this.tmpName) {
572
+ return pb.getCurrentScope()[this.tmpName];
573
+ }
574
+ const a = this.a.create(pb);
575
+ const b = this.b.create(pb);
576
+ let exp;
577
+ switch(this.mode){
578
+ case 'eq':
579
+ exp = pb.compEqual(a, b);
580
+ break;
581
+ case 'ne':
582
+ exp = pb.compNotEqual(a, b);
583
+ break;
584
+ case 'lt':
585
+ exp = pb.lessThan(a, b);
586
+ break;
587
+ case 'le':
588
+ exp = pb.lessThanEqual(a, b);
589
+ break;
590
+ case 'gt':
591
+ exp = pb.greaterThan(a, b);
592
+ break;
593
+ case 'ge':
594
+ exp = pb.greaterThanEqual(a, b);
595
+ break;
596
+ default:
597
+ throw new Error(`Invalid comparison mode: ${this.mode}`);
598
+ }
599
+ if (this._ref === 1) {
600
+ return exp;
601
+ } else {
602
+ this.tmpName = this.getTmpName(pb.getCurrentScope());
603
+ pb.getCurrentScope()[this.tmpName] = exp;
604
+ return pb.getCurrentScope()[this.tmpName];
605
+ }
606
+ }
607
+ }
444
608
  /**
445
609
  * IR expression for vector component swizzling
446
610
  *
@@ -485,6 +649,7 @@ import { VertexBlockNode } from './pbr.js';
485
649
  * Otherwise, applies the swizzle notation to the source expression.
486
650
  */ create(pb) {
487
651
  const src = this.src.create(pb);
652
+ // @ts-ignore
488
653
  return typeof src === 'number' ? pb[`vec${this.hash.length}`](src) : src[this.hash];
489
654
  }
490
655
  }
@@ -507,6 +672,7 @@ import { VertexBlockNode } from './pbr.js';
507
672
  * @public
508
673
  */ class IRCast extends IRExpression {
509
674
  /** The source expression to cast */ src;
675
+ /** The values to be filled */ fill;
510
676
  /** The target type name (e.g., 'vec2', 'vec3', 'vec4') */ type;
511
677
  /** Number of zero components to append */ cast;
512
678
  /**
@@ -515,10 +681,11 @@ import { VertexBlockNode } from './pbr.js';
515
681
  * @param src - The source expression
516
682
  * @param type - The target type name
517
683
  * @param cast - Number of zero components to append
518
- */ constructor(src, type, cast){
684
+ */ constructor(src, type, cast, fill){
519
685
  super();
520
686
  this.src = src.addRef();
521
687
  this.cast = cast;
688
+ this.fill = fill?.slice() ?? null;
522
689
  this.type = type;
523
690
  }
524
691
  /**
@@ -531,7 +698,8 @@ import { VertexBlockNode } from './pbr.js';
531
698
  * Creates a vector constructor with the source value followed by zeros.
532
699
  * Example: vec4(src, 0, 0) for casting vec2 to vec4.
533
700
  */ create(pb) {
534
- return pb[this.type](this.src.create(pb), ...Array.from({
701
+ // @ts-ignore
702
+ return pb[this.type](this.src.create(pb), ...this.fill ?? Array.from({
535
703
  length: this.cast
536
704
  }).fill(0));
537
705
  }
@@ -597,6 +765,7 @@ import { VertexBlockNode } from './pbr.js';
597
765
  if (coord instanceof PBShaderExp) {
598
766
  coordExp = coord;
599
767
  } else if (Array.isArray(coord)) {
768
+ // @ts-ignore
600
769
  coordExp = pb[`vec${coord.length}`](...coord);
601
770
  } else {
602
771
  throw new Error('Invalid texture coordinate');
@@ -681,6 +850,7 @@ import { VertexBlockNode } from './pbr.js';
681
850
  * Creates the uniform declaration in the global scope if not already present.
682
851
  */ create(pb) {
683
852
  if (!pb.getGlobalScope()[this.name]) {
853
+ // @ts-ignore
684
854
  pb.getGlobalScope()[this.name] = pb[this.type]().uniform(2);
685
855
  }
686
856
  return pb.getGlobalScope()[this.name];
@@ -721,24 +891,11 @@ import { VertexBlockNode } from './pbr.js';
721
891
  * 3. Track uniforms and behaviors
722
892
  * 4. Generate optimized shader code from the IR
723
893
  *
724
- * @example
725
- * ```typescript
726
- * const ir = new MaterialBlueprintIR(dag, materialHash);
727
- * if (ir.ok) {
728
- * // Generate shader code
729
- * const outputs = ir.create(programBuilder);
730
- *
731
- * // Apply uniforms at runtime
732
- * for (const uniform of ir.uniformValues) {
733
- * material.setUniform(uniform.name, uniform.value);
734
- * }
735
- * }
736
- * ```
737
- *
738
894
  * @public
739
895
  */ class MaterialBlueprintIR {
740
896
  /** The directed acyclic graph of material nodes */ _dag;
741
897
  /** Unique hash identifying this material configuration */ _hash;
898
+ /** Editor state snapshot at time of compilation */ _editorState;
742
899
  /** Array of all IR expressions in the graph */ _expressions;
743
900
  /** Map from graph node to IR expression index */ _expressionMap;
744
901
  /** Array of uniform scalar/vector values to be set at runtime */ _uniformValues;
@@ -750,11 +907,12 @@ import { VertexBlockNode } from './pbr.js';
750
907
  *
751
908
  * @param dag - The material node graph DAG
752
909
  * @param hash - Unique identifier for this material
910
+ * @param editorState - Editor state snapshot
753
911
  *
754
912
  * @remarks
755
913
  * Automatically compiles the DAG during construction.
756
914
  * Check the `ok` property to verify successful compilation.
757
- */ constructor(dag, hash){
915
+ */ constructor(dag, hash, editorState){
758
916
  this._dag = dag ?? {
759
917
  nodeMap: {},
760
918
  roots: [],
@@ -765,6 +923,7 @@ import { VertexBlockNode } from './pbr.js';
765
923
  order: []
766
924
  };
767
925
  this._hash = hash;
926
+ this._editorState = editorState;
768
927
  this.compile();
769
928
  }
770
929
  /**
@@ -772,11 +931,14 @@ import { VertexBlockNode } from './pbr.js';
772
931
  *
773
932
  * @returns True if compilation produced valid outputs
774
933
  */ get ok() {
775
- return this._outputs?.length > 0;
934
+ return this._outputs ? this._outputs.length > 0 : false;
776
935
  }
777
936
  /** Gets the unique hash for this material */ get hash() {
778
937
  return this._hash;
779
938
  }
939
+ /** Gets the editor state snapshot */ get editorState() {
940
+ return this._editorState;
941
+ }
780
942
  /** Gets the behavior flags indicating shader requirements */ get behaviors() {
781
943
  return this._behaviors;
782
944
  }
@@ -813,18 +975,20 @@ import { VertexBlockNode } from './pbr.js';
813
975
  if (input.inputNode) {
814
976
  this._outputs.push({
815
977
  name,
816
- expr: this.ir(input.inputNode, input.inputId, input.originType).addRef()
817
- });
818
- } else if (typeof input.defaultValue === 'number') {
819
- this._outputs.push({
820
- name,
821
- expr: new IRConstantf(input.defaultValue, '').addRef()
978
+ expr: this.ir(input).addRef()
822
979
  });
823
980
  } else if (Array.isArray(input.defaultValue)) {
824
- this._outputs.push({
825
- name,
826
- expr: new IRConstantfv(input.defaultValue, '', `vec${input.defaultValue.length}`).addRef()
827
- });
981
+ if (input.defaultValue.length === 1) {
982
+ this._outputs.push({
983
+ name,
984
+ expr: new IRConstantf(input.defaultValue[0], '').addRef()
985
+ });
986
+ } else {
987
+ this._outputs.push({
988
+ name,
989
+ expr: new IRConstantfv(input.defaultValue, '', `vec${input.defaultValue.length}`).addRef()
990
+ });
991
+ }
828
992
  } else if (input.required) {
829
993
  this._outputs = null;
830
994
  return false;
@@ -904,12 +1068,20 @@ import { VertexBlockNode } from './pbr.js';
904
1068
  * Handles automatic type casting when originType differs from node output type.
905
1069
  *
906
1070
  * @throws Error if type casting is invalid
907
- */ ir(node, output, originType) {
1071
+ */ ir(inputNode) {
1072
+ const node = inputNode.inputNode;
1073
+ const output = inputNode.inputId;
1074
+ const originType = inputNode.originType;
1075
+ const defaultValue = inputNode.defaultValue;
908
1076
  let expr = null;
909
1077
  if (node instanceof ConstantScalarNode) {
910
1078
  expr = this.constantf(node, output);
911
1079
  } else if (node instanceof ConstantVec2Node || node instanceof ConstantVec3Node || node instanceof ConstantVec4Node) {
912
1080
  expr = this.constantfv(node, output);
1081
+ } else if (node instanceof ConstantBooleanNode) {
1082
+ expr = this.constantb(node, output);
1083
+ } else if (node instanceof ConstantBVec2Node || node instanceof ConstantBVec3Node || node instanceof ConstantBVec4Node) {
1084
+ expr = this.constantbv(node, output);
913
1085
  } else if (node instanceof BaseTextureNode) {
914
1086
  expr = this.constantTexture(node, output);
915
1087
  } else if (node instanceof TextureSampleNode) {
@@ -918,6 +1090,14 @@ import { VertexBlockNode } from './pbr.js';
918
1090
  expr = this.makeVector(node, output);
919
1091
  } else if (node instanceof SwizzleNode) {
920
1092
  expr = this.swizzle(node, output);
1093
+ } else if (node instanceof CompComparisonNode) {
1094
+ expr = this.comparison(node, output);
1095
+ } else if (node instanceof AnyConditionNode) {
1096
+ expr = this.any(node, output);
1097
+ } else if (node instanceof AllConditionNode) {
1098
+ expr = this.all(node, output);
1099
+ } else if (node instanceof SelectionNode) {
1100
+ expr = this.selection(node, output);
921
1101
  } else if (node instanceof ResolveVertexPositionNode) {
922
1102
  expr = this.resolveVertexPosition(node, output);
923
1103
  } else if (node instanceof ResolveVertexNormalNode) {
@@ -996,7 +1176,7 @@ import { VertexBlockNode } from './pbr.js';
996
1176
  if (nOut > nOrg) {
997
1177
  return new IRSwizzle(expr, 'xyzw'.slice(0, nOrg));
998
1178
  } else {
999
- return new IRCast(expr, originType, nOrg - nOut);
1179
+ return new IRCast(expr, originType, nOrg - nOut, defaultValue?.slice(nOut - nOrg));
1000
1180
  }
1001
1181
  } else {
1002
1182
  throw new Error(`Cannot cast type \`${outputType}\` to \`${originType}`);
@@ -1038,9 +1218,6 @@ import { VertexBlockNode } from './pbr.js';
1038
1218
  if (!ir.outputs[outputId]) {
1039
1219
  const output = node.outputs.find((v)=>v.id === outputId);
1040
1220
  ir.outputs[outputId] = ir;
1041
- if (typeof output.cast === 'number') {
1042
- ir.outputs[outputId] = new IRCast(ir, node.getOutputType(outputId), output.cast);
1043
- }
1044
1221
  if (output.swizzle) {
1045
1222
  ir.outputs[outputId] = new IRSwizzle(ir.outputs[outputId], output.swizzle);
1046
1223
  }
@@ -1051,20 +1228,32 @@ import { VertexBlockNode } from './pbr.js';
1051
1228
  const params = [];
1052
1229
  for (const input of node.inputs){
1053
1230
  if (input.inputNode) {
1054
- params.push(this.ir(input.inputNode, input.inputId, input.originType));
1231
+ params.push(this.ir(input));
1055
1232
  }
1056
1233
  }
1057
1234
  const funcName = node.getOutputType(output);
1058
1235
  return this.getOrCreateIRExpression(node, output, IRFunc, params, funcName);
1059
1236
  }
1060
1237
  /** Converts a swizzle node to IR */ swizzle(node, output) {
1061
- return this.getOrCreateIRExpression(node, output, IRSwizzle, this.ir(node.inputs[0].inputNode, node.inputs[0].inputId, node.inputs[0].originType), node.swizzle);
1238
+ return this.getOrCreateIRExpression(node, output, IRSwizzle, this.ir(node.inputs[0]), node.swizzle);
1239
+ }
1240
+ /** Converts a comparison node to IR */ comparison(node, output) {
1241
+ return this.getOrCreateIRExpression(node, output, IRComparison, this.ir(node.inputs[0]), this.ir(node.inputs[1]), node.mode);
1242
+ }
1243
+ /** Converts an any-condition node to IR */ any(node, output) {
1244
+ return this.getOrCreateIRExpression(node, output, IRAny, this.ir(node.inputs[0]));
1245
+ }
1246
+ /** Converts an all-condition node to IR */ all(node, output) {
1247
+ return this.getOrCreateIRExpression(node, output, IRAll, this.ir(node.inputs[0]));
1248
+ }
1249
+ /** Converts a selection node to IR */ selection(node, output) {
1250
+ return this.getOrCreateIRExpression(node, output, IRSelection, this.ir(node.inputs[0]), this.ir(node.inputs[1]), this.ir(node.inputs[2]));
1062
1251
  }
1063
1252
  /** Converts a Transform node to IR */ transform(node, output) {
1064
1253
  const params = [];
1065
1254
  for (const input of node.inputs){
1066
1255
  if (input.inputNode) {
1067
- params.push(this.ir(input.inputNode, input.inputId, input.originType));
1256
+ params.push(this.ir(input));
1068
1257
  }
1069
1258
  }
1070
1259
  return this.getOrCreateIRExpression(node, output, IRFunc, params, 'mul');
@@ -1073,31 +1262,31 @@ import { VertexBlockNode } from './pbr.js';
1073
1262
  const params = [];
1074
1263
  for (const input of node.inputs){
1075
1264
  if (input.inputNode) {
1076
- params.push(this.ir(input.inputNode, input.inputId, input.originType));
1265
+ params.push(this.ir(input));
1077
1266
  }
1078
1267
  }
1079
1268
  const funcName = node.func;
1080
1269
  return this.getOrCreateIRExpression(node, output, IRFunc, params, funcName);
1081
1270
  }
1082
1271
  /** Converts a function output node to IR */ functionOutput(node, output) {
1083
- const input = this.ir(node.inputs[0].inputNode, node.inputs[0].inputId, node.inputs[0].originType);
1272
+ const input = this.ir(node.inputs[0]);
1084
1273
  return this.getOrCreateIRExpression(node, output, IRFunctionOutput, input);
1085
1274
  }
1086
1275
  /** Converts a vertex color input node to IR */ vertexColor(node, output) {
1087
1276
  this._behaviors.useVertexColor = true;
1088
- return this.getOrCreateIRExpression(node, output, IRInput, (scope)=>scope.$inputs.zVertexColor);
1277
+ return this.getOrCreateIRExpression(node, output, IRInput, (scope)=>scope.zVertexColor);
1089
1278
  }
1090
1279
  /** Converts a vertex UV input node to IR */ vertexUV(node, output) {
1091
1280
  this._behaviors.useVertexUV = true;
1092
1281
  return this.getOrCreateIRExpression(node, output, IRInput, (scope)=>{
1093
- return scope.$inputs.zVertexUV;
1282
+ return scope.zVertexUV;
1094
1283
  });
1095
1284
  }
1096
1285
  /** Converts a vertex normal input node to IR */ vertexNormal(node, output) {
1097
- return this.getOrCreateIRExpression(node, output, IRInput, (scope)=>scope.$builder.getDevice().type === 'vertex' ? scope.$getVertexAttrib('normal') ?? ShaderHelper.resolveVertexNormal(scope) : scope.$inputs.zVertexNormal);
1286
+ return this.getOrCreateIRExpression(node, output, IRInput, (scope)=>scope.$builder.getDevice().type === 'vertex' ? scope.$getVertexAttrib('normal') ?? ShaderHelper.resolveVertexNormal(scope) : scope.zVertexNormal);
1098
1287
  }
1099
1288
  /** Converts a vertex tangent input node to IR */ vertexTangent(node, output) {
1100
- return this.getOrCreateIRExpression(node, output, IRInput, (scope)=>scope.$builder.getDevice().type === 'vertex' ? scope.$getVertexAttrib('tangent') ?? ShaderHelper.resolveVertexTangent(scope) : scope.$inputs.zVertexTangent);
1289
+ return this.getOrCreateIRExpression(node, output, IRInput, (scope)=>scope.$builder.getDevice().type === 'vertex' ? scope.$getVertexAttrib('tangent') ?? ShaderHelper.resolveVertexTangent(scope) : scope.zVertexTangent);
1101
1290
  }
1102
1291
  /** Converts a vertex binormal input node to IR */ vertexBinormal(node, output) {
1103
1292
  return this.getOrCreateIRExpression(node, output, IRInput, 'zVertexBinormal');
@@ -1174,7 +1363,7 @@ import { VertexBlockNode } from './pbr.js';
1174
1363
  ASSERT(!!input.inputNode);
1175
1364
  const type = input.inputNode.getOutputType(input.inputId);
1176
1365
  ASSERT(type === 'float' || type === 'vec2' || type === 'vec3');
1177
- params.push(this.ir(input.inputNode, input.inputId, input.originType));
1366
+ params.push(this.ir(input));
1178
1367
  return this.getOrCreateIRExpression(node, output, IRFunc, params, (pb, ...params)=>{
1179
1368
  const scope = pb.getCurrentScope();
1180
1369
  const seed = params[0];
@@ -1187,7 +1376,7 @@ import { VertexBlockNode } from './pbr.js';
1187
1376
  ASSERT(!!input.inputNode);
1188
1377
  const type = input.inputNode.getOutputType(input.inputId);
1189
1378
  ASSERT(type === 'float' || type === 'vec2' || type === 'vec3');
1190
- params.push(this.ir(input.inputNode, input.inputId, input.originType));
1379
+ params.push(this.ir(input));
1191
1380
  return this.getOrCreateIRExpression(node, output, IRFunc, params, (pb, ...params)=>{
1192
1381
  const scope = pb.getCurrentScope();
1193
1382
  const seed = params[0];
@@ -1200,7 +1389,7 @@ import { VertexBlockNode } from './pbr.js';
1200
1389
  ASSERT(!!input.inputNode);
1201
1390
  const type = input.inputNode.getOutputType(input.inputId);
1202
1391
  ASSERT(type === 'float' || type === 'vec2' || type === 'vec3');
1203
- params.push(this.ir(input.inputNode, input.inputId, input.originType));
1392
+ params.push(this.ir(input));
1204
1393
  return this.getOrCreateIRExpression(node, output, IRFunc, params, (pb, ...params)=>{
1205
1394
  const scope = pb.getCurrentScope();
1206
1395
  const seed = params[0];
@@ -1211,7 +1400,7 @@ import { VertexBlockNode } from './pbr.js';
1211
1400
  const params = [];
1212
1401
  for (const input of node.inputs){
1213
1402
  if (input.inputNode) {
1214
- params.push(this.ir(input.inputNode, input.inputId, input.originType));
1403
+ params.push(this.ir(input));
1215
1404
  }
1216
1405
  }
1217
1406
  return this.getOrCreateIRExpression(node, output, IRFunc, params, (pb, ...params)=>{
@@ -1238,7 +1427,7 @@ import { VertexBlockNode } from './pbr.js';
1238
1427
  const params = [];
1239
1428
  for (const input of node.inputs){
1240
1429
  if (input.inputNode) {
1241
- params.push(this.ir(input.inputNode, input.inputId, input.originType));
1430
+ params.push(this.ir(input));
1242
1431
  }
1243
1432
  }
1244
1433
  return this.getOrCreateIRExpression(node, output, IRFunc, params, (pb, ...params)=>{
@@ -1274,7 +1463,7 @@ import { VertexBlockNode } from './pbr.js';
1274
1463
  }
1275
1464
  /** Converts a function call node to IR */ functionCall(node, output) {
1276
1465
  const args = node.inputs.map((input)=>{
1277
- return this.ir(input.inputNode, input.inputId, input.originType);
1466
+ return this.ir(input);
1278
1467
  });
1279
1468
  return this.getOrCreateIRExpression(node, output, IRCallFunc, node, args);
1280
1469
  }
@@ -1297,12 +1486,31 @@ import { VertexBlockNode } from './pbr.js';
1297
1486
  ];
1298
1487
  return this.getOrCreateIRExpression(node, output, IRConstantfv, value, node.paramName, `vec${value.length}`);
1299
1488
  }
1489
+ /** Converts a scalar boolean constant node to IR */ constantb(node, output) {
1490
+ return this.getOrCreateIRExpression(node, output, IRConstantb, node.x);
1491
+ }
1492
+ /** Converts a boolean vector constant node to IR */ constantbv(node, output) {
1493
+ const value = node instanceof ConstantBVec2Node ? [
1494
+ node.x,
1495
+ node.y
1496
+ ] : node instanceof ConstantBVec3Node ? [
1497
+ node.x,
1498
+ node.y,
1499
+ node.z
1500
+ ] : [
1501
+ node.x,
1502
+ node.y,
1503
+ node.z,
1504
+ node.w
1505
+ ];
1506
+ return this.getOrCreateIRExpression(node, output, IRConstantbv, value);
1507
+ }
1300
1508
  /** Converts a texture constant node to IR */ constantTexture(node, output) {
1301
1509
  return this.getOrCreateIRExpression(node, output, IRConstantTexture, node.paramName, node.textureId, node.getOutputType(1), node.sRGB, node.addressU, node.addressV, node.filterMin, node.filterMag, node.filterMip);
1302
1510
  }
1303
1511
  /** Converts a texture sample node to IR */ textureSample(node, output) {
1304
- const tex = this.ir(node.inputs[0].inputNode, node.inputs[0].inputId);
1305
- const coord = this.ir(node.inputs[1].inputNode, node.inputs[1].inputId);
1512
+ const tex = this.ir(node.inputs[0]);
1513
+ const coord = this.ir(node.inputs[1]);
1306
1514
  return this.getOrCreateIRExpression(node, output, IRSampleTexture, tex, coord, node.samplerType);
1307
1515
  }
1308
1516
  }