@hology/core 0.0.212 → 0.0.213

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 (135) hide show
  1. package/dist/effects/sequence/index.d.ts +1 -0
  2. package/dist/effects/sequence/index.js +1 -1
  3. package/dist/effects/sequence/sequence-action.d.ts +5 -0
  4. package/dist/effects/sequence/sequence-actor.d.ts +7 -0
  5. package/dist/effects/sequence/sequence-actor.js +1 -1
  6. package/dist/effects/sequence/sequence-animation-retiming.js +1 -1
  7. package/dist/effects/sequence/sequence-data.d.ts +9 -0
  8. package/dist/effects/sequence/sequence-data.js +1 -1
  9. package/dist/effects/sequence/sequence-player.d.ts +12 -1
  10. package/dist/effects/sequence/sequence-player.js +1 -1
  11. package/dist/effects/sequence/sequence-transform.d.ts +10 -0
  12. package/dist/effects/sequence/sequence-transform.js +4 -0
  13. package/dist/effects/sequence/sequence-value-lane.d.ts +2 -0
  14. package/dist/effects/sequence/sequence-value-lane.js +1 -1
  15. package/dist/effects/vfx/vfx-actor.d.ts +5 -0
  16. package/dist/effects/vfx/vfx-actor.js +1 -1
  17. package/dist/effects/vfx/vfx-asset.d.ts +2 -1
  18. package/dist/effects/vfx/vfx-asset.js +1 -1
  19. package/dist/effects/vfx/vfx-materializer.js +1 -1
  20. package/dist/effects/vfx/vfx-renderers.d.ts +1 -0
  21. package/dist/effects/vfx/vfx-renderers.js +1 -1
  22. package/dist/gameplay/actors/actor.d.ts +3 -5
  23. package/dist/gameplay/actors/actor.js +1 -1
  24. package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -0
  25. package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
  26. package/dist/gameplay/actors/builtin/components/character/character-movement-like.d.ts +2 -0
  27. package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +13 -0
  28. package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
  29. package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.d.ts +4 -1
  30. package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.js +1 -1
  31. package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +1 -0
  32. package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
  33. package/dist/gameplay/actors/builtin/components/tween-component.js +1 -1
  34. package/dist/gameplay/actors/builtin/navmesh-actor.d.ts +2 -0
  35. package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
  36. package/dist/gameplay/actors/builtin/trigger-volume.d.ts +3 -3
  37. package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
  38. package/dist/gameplay/actors/camera/camera-component.d.ts +1 -3
  39. package/dist/gameplay/actors/camera/camera-component.js +1 -1
  40. package/dist/gameplay/actors/component.d.ts +3 -0
  41. package/dist/gameplay/actors/component.js +1 -1
  42. package/dist/gameplay/actors/type-registry.d.ts +10 -0
  43. package/dist/gameplay/actors/type-registry.js +4 -0
  44. package/dist/gameplay/animation/retarget.d.ts +50 -0
  45. package/dist/gameplay/animation/retarget.js +4 -0
  46. package/dist/gameplay/animation/root-motion.js +1 -1
  47. package/dist/gameplay/event-graph/actor-transform-properties.d.ts +6 -0
  48. package/dist/gameplay/event-graph/actor-transform-properties.js +4 -0
  49. package/dist/gameplay/event-graph/asset-actor-types.d.ts +3 -0
  50. package/dist/gameplay/event-graph/asset-actor-types.js +4 -0
  51. package/dist/gameplay/event-graph/asset-references.d.ts +12 -0
  52. package/dist/gameplay/event-graph/asset-references.js +4 -0
  53. package/dist/gameplay/event-graph/compiler.d.ts +107 -0
  54. package/dist/gameplay/event-graph/compiler.js +4 -0
  55. package/dist/gameplay/event-graph/decorators.d.ts +74 -0
  56. package/dist/gameplay/event-graph/decorators.js +4 -0
  57. package/dist/gameplay/event-graph/document-compiler.d.ts +107 -0
  58. package/dist/gameplay/event-graph/document-compiler.js +4 -0
  59. package/dist/gameplay/event-graph/event-graph-demo.d.ts +2 -0
  60. package/dist/gameplay/event-graph/event-graph-demo.js +4 -0
  61. package/dist/gameplay/event-graph/graph.d.ts +106 -0
  62. package/dist/gameplay/event-graph/graph.js +4 -0
  63. package/dist/gameplay/event-graph/index.d.ts +13 -0
  64. package/dist/gameplay/event-graph/index.js +4 -0
  65. package/dist/gameplay/event-graph/model.d.ts +71 -0
  66. package/dist/gameplay/event-graph/model.js +4 -0
  67. package/dist/gameplay/event-graph/nodes/execution-nodes.d.ts +115 -0
  68. package/dist/gameplay/event-graph/nodes/execution-nodes.js +4 -0
  69. package/dist/gameplay/event-graph/nodes/gameplay-nodes.d.ts +208 -0
  70. package/dist/gameplay/event-graph/nodes/gameplay-nodes.js +4 -0
  71. package/dist/gameplay/event-graph/nodes/index.d.ts +4 -0
  72. package/dist/gameplay/event-graph/nodes/index.js +4 -0
  73. package/dist/gameplay/event-graph/nodes/value-nodes.d.ts +53 -0
  74. package/dist/gameplay/event-graph/nodes/value-nodes.js +4 -0
  75. package/dist/gameplay/event-graph/registry.d.ts +33 -0
  76. package/dist/gameplay/event-graph/registry.js +4 -0
  77. package/dist/gameplay/event-graph/runtime-assets.d.ts +21 -0
  78. package/dist/gameplay/event-graph/runtime-assets.js +4 -0
  79. package/dist/gameplay/event-graph/runtime.d.ts +160 -0
  80. package/dist/gameplay/event-graph/runtime.js +4 -0
  81. package/dist/gameplay/event-graph/type-inference.d.ts +41 -0
  82. package/dist/gameplay/event-graph/type-inference.js +4 -0
  83. package/dist/gameplay/event-graph/types.d.ts +77 -0
  84. package/dist/gameplay/event-graph/types.js +4 -0
  85. package/dist/gameplay/index.d.ts +15 -2
  86. package/dist/gameplay/index.js +1 -1
  87. package/dist/gameplay/initiate.js +1 -1
  88. package/dist/gameplay/input/input.d.ts +22 -17
  89. package/dist/gameplay/input/input.js +1 -1
  90. package/dist/gameplay/net/service/net-decorator.d.ts +1 -1
  91. package/dist/gameplay/net/service/net-decorator.js +1 -1
  92. package/dist/gameplay/net/service/net-serializer.js +1 -1
  93. package/dist/gameplay/net/service/net-service.d.ts +6 -6
  94. package/dist/gameplay/net/service/net-service.js +1 -1
  95. package/dist/gameplay/net/service/rpc-decorator.js +1 -1
  96. package/dist/gameplay/services/asset-loader.d.ts +7 -0
  97. package/dist/gameplay/services/asset-loader.js +1 -1
  98. package/dist/gameplay/services/physics/physics-system.d.ts +14 -0
  99. package/dist/gameplay/services/physics/physics-system.js +1 -1
  100. package/dist/gameplay/services/world.d.ts +12 -0
  101. package/dist/gameplay/services/world.js +1 -1
  102. package/dist/rendering.js +1 -1
  103. package/dist/scene/asset-resource-loader.d.ts +7 -1
  104. package/dist/scene/asset-resource-loader.js +1 -1
  105. package/dist/scene/custom-param-deserialize.js +1 -1
  106. package/dist/scene/custom-param-runtime-types.js +1 -1
  107. package/dist/scene/materializer.d.ts +25 -0
  108. package/dist/scene/materializer.js +1 -1
  109. package/dist/scene/model.d.ts +114 -2
  110. package/dist/scene/model.js +1 -1
  111. package/dist/scene/objects/prefab.js +1 -1
  112. package/dist/shader/graph/compiler.d.ts +3 -0
  113. package/dist/shader/graph/compiler.js +1 -1
  114. package/dist/shader/graph/model.d.ts +1 -1
  115. package/dist/shader/graph/registry.js +1 -1
  116. package/dist/test/animation-retarget.test.d.ts +2 -0
  117. package/dist/test/animation-retarget.test.js +4 -0
  118. package/dist/test/event-graph-generated-code.test.d.ts +2 -0
  119. package/dist/test/event-graph-generated-code.test.js +4 -0
  120. package/dist/test/event-graph-types.test.d.ts +2 -0
  121. package/dist/test/event-graph-types.test.js +4 -0
  122. package/dist/test/event-graph.test.d.ts +2 -0
  123. package/dist/test/event-graph.test.js +4 -0
  124. package/dist/test/input.test.d.ts +2 -0
  125. package/dist/test/input.test.js +4 -0
  126. package/dist/test/net-character-movement.test.js +1 -1
  127. package/dist/test/prefab-instance-params.test.js +1 -1
  128. package/dist/test/sequence-camera-control.test.js +1 -1
  129. package/dist/test/sequence-scene-binding.test.d.ts +2 -0
  130. package/dist/test/sequence-scene-binding.test.js +4 -0
  131. package/dist/test/sequence-transform.test.d.ts +2 -0
  132. package/dist/test/sequence-transform.test.js +4 -0
  133. package/dist/test/shader-graph.test.js +1 -1
  134. package/package.json +10 -2
  135. package/tsconfig.tsbuildinfo +1 -1
@@ -2,9 +2,10 @@ import { EulerOrder, Side } from 'three';
2
2
  import type { SequenceData } from '../effects/sequence/sequence-data.js';
3
3
  import type { BlendingMode, VfxAssetData } from '../effects/vfx/vfx-asset.js';
4
4
  import type { ShaderGraphDocument, ShaderGraphMaterialReference } from '../shader/graph/model.js';
5
+ import type { EventGraphDocument } from '../gameplay/event-graph/model.js';
5
6
  import type { AttachedComponent, SceneObject } from './materializer.js';
6
7
  import type { LibraryShapeType } from './objects/shapes.js';
7
- export type AssetType = 'mesh' | 'material' | 'shape' | 'particles' | 'light' | 'texture' | 'actor' | 'audio' | 'prefab' | 'vfx' | 'animationclip' | 'sequence' | 'shaderGraph' | 'data';
8
+ export type AssetType = 'mesh' | 'material' | 'shape' | 'particles' | 'light' | 'texture' | 'actor' | 'audio' | 'prefab' | 'vfx' | 'animationclip' | 'animationRig' | 'animationRetargeter' | 'sequence' | 'shaderGraph' | 'data';
8
9
  export type ShapeType = LibraryShapeType | 'landscape';
9
10
  export type LightType = 'point' | 'spot' | 'directional' | 'ambient' | 'rectArea';
10
11
  /**
@@ -48,7 +49,8 @@ export declare enum SerializedParamType {
48
49
  AnimationClip = 27,
49
50
  Sequence = 28,
50
51
  Struct = 29,
51
- DataAsset = 30
52
+ DataAsset = 30,
53
+ SequenceData = 31
52
54
  }
53
55
  export type VfxInputBinding = {
54
56
  type: 'vfxInput';
@@ -169,6 +171,104 @@ export type TextureSettings = {
169
171
  */
170
172
  textureArrayFileKey?: string;
171
173
  };
174
+ export type AnimationRigBone = {
175
+ /** Stable hierarchy path. Bone names alone are not guaranteed to be unique. */
176
+ id: string;
177
+ name: string;
178
+ parentIndex: number;
179
+ position: [number, number, number];
180
+ quaternion: [number, number, number, number];
181
+ scale: [number, number, number];
182
+ inverseBindMatrix: number[];
183
+ };
184
+ export type AnimationRigChainRole = 'root' | 'spine' | 'neck' | 'head' | 'leftArm' | 'rightArm' | 'leftLeg' | 'rightLeg' | 'leftHand' | 'rightHand' | 'leftFoot' | 'rightFoot' | 'leftFingers' | 'rightFingers' | string;
185
+ export type AnimationRigChain = {
186
+ id: string;
187
+ name: string;
188
+ role: AnimationRigChainRole;
189
+ startBoneId: string;
190
+ endBoneId: string;
191
+ };
192
+ export type AnimationRetargetPose = {
193
+ id: string;
194
+ name: string;
195
+ /** Sparse local-space quaternion offsets keyed by rig bone id. */
196
+ rotationOffsets: Record<string, [number, number, number, number]>;
197
+ rootOffset?: [number, number, number];
198
+ };
199
+ export type AnimationRigData = {
200
+ version: 1;
201
+ previewMeshId: AssetId;
202
+ /**
203
+ * Coordinate-basis correction applied around the imported rig. This does
204
+ * not change bone-local animation data or rig compatibility fingerprints.
205
+ */
206
+ basisPreset?: 'auto' | 'yUp' | 'unrealZUp' | 'custom';
207
+ basisYawDegrees?: number;
208
+ basisRotation?: [number, number, number, number];
209
+ /** Identifies the characterized skeleton when a model contains more than one. */
210
+ skinnedMeshName?: string;
211
+ bones: AnimationRigBone[];
212
+ topologyFingerprint: string;
213
+ bindPoseFingerprint: string;
214
+ retargetRootBoneId?: string;
215
+ pelvisBoneId?: string;
216
+ leftHandBoneId?: string;
217
+ rightHandBoneId?: string;
218
+ chains: AnimationRigChain[];
219
+ poses: AnimationRetargetPose[];
220
+ defaultPoseId?: string;
221
+ };
222
+ export type AnimationRetargetChainMapping = {
223
+ sourceChainId: string;
224
+ targetChainId: string;
225
+ enabled?: boolean;
226
+ rotationMode?: 'copy' | 'interpolated';
227
+ translationMode?: 'none' | 'scaled';
228
+ /** Reserved for the follow-up limb IK pass. */
229
+ ik?: {
230
+ enabled?: boolean;
231
+ poleBoneId?: string;
232
+ };
233
+ };
234
+ export type AnimationRetargeterData = {
235
+ version: 1;
236
+ solverVersion: number;
237
+ sourceRigId: AssetId;
238
+ targetRigId: AssetId;
239
+ sourceRigFingerprint: {
240
+ topology: string;
241
+ bindPose: string;
242
+ };
243
+ targetRigFingerprint: {
244
+ topology: string;
245
+ bindPose: string;
246
+ };
247
+ sourcePoseId?: string;
248
+ targetPoseId?: string;
249
+ chainMappings: AnimationRetargetChainMapping[];
250
+ rootSettings: {
251
+ scaleTranslation: boolean;
252
+ translationAxes: [boolean, boolean, boolean];
253
+ /**
254
+ * Target X/Y/Z source-axis mapping. 1/2/3 mean +X/+Y/+Z and negative
255
+ * values invert the selected source axis.
256
+ */
257
+ translationAxisMap: [number, number, number];
258
+ scaleMultiplier: number;
259
+ };
260
+ bakeSettings: {
261
+ framesPerSecond: number;
262
+ };
263
+ /** Source animation asset id -> generated target animation asset id. */
264
+ generatedOutputs: Record<AssetId, AssetId>;
265
+ };
266
+ export type GeneratedAnimationClipInfo = {
267
+ sourceClipId: AssetId;
268
+ retargeterId: AssetId;
269
+ generatorVersion: number;
270
+ inputHash: string;
271
+ };
172
272
  export type Asset = {
173
273
  id: string;
174
274
  /** A name of the asset. By default derived from the imported asset's file name. Should be unique. */
@@ -262,6 +362,8 @@ export type Asset = {
262
362
  shapeType?: CollisionShapeType;
263
363
  };
264
364
  colliders?: ModelColliderData[];
365
+ /** Animation rig this mesh is compatible with. */
366
+ animationRigId?: AssetId;
265
367
  };
266
368
  /** Prefab settings only for asset type prefab */
267
369
  prefab?: {
@@ -287,6 +389,8 @@ export type Asset = {
287
389
  * instance returns the exposed actor instance inside the prefab.
288
390
  */
289
391
  mainActorId?: string;
392
+ /** Optional gameplay event graph instantiated once for each prefab instance. */
393
+ eventGraph?: EventGraphDocument;
290
394
  };
291
395
  components?: AttachedComponent[];
292
396
  /** Texture settings only for asset type texture */
@@ -301,7 +405,15 @@ export type Asset = {
301
405
  anim?: {
302
406
  /** The name of the animation clip */
303
407
  clip: string;
408
+ /** Rig whose bone names and bind pose this clip targets. */
409
+ rigId?: AssetId;
410
+ /** Present when this is a replaceable editor-generated retarget output. */
411
+ generatedFrom?: GeneratedAnimationClipInfo;
304
412
  };
413
+ /** Animation rig settings only for asset type animationRig. */
414
+ animationRig?: AnimationRigData;
415
+ /** Animation retargeter settings only for asset type animationRetargeter. */
416
+ animationRetargeter?: AnimationRetargeterData;
305
417
  /** Sequence settings only for asset type sequence */
306
418
  sequence?: SequenceData;
307
419
  /** Shader graph settings only for asset type shaderGraph */
@@ -1,4 +1,4 @@
1
- export var DetailTier;!function(e){e[e.low=0]="low",e[e.medium=1]="medium",e[e.high=2]="high"}(DetailTier||(DetailTier={}));export var SerializedParamType;!function(e){e[e.FloatNode=0]="FloatNode",e[e.Number=1]="Number",e[e.Texture=2]="Texture",e[e.Sampler2DNode=3]="Sampler2DNode",e[e.Boolean=4]="Boolean",e[e.BooleanNode=5]="BooleanNode",e[e.Vector2=6]="Vector2",e[e.Vec2Node=7]="Vec2Node",e[e.Vector3=8]="Vector3",e[e.Vec3Node=9]="Vec3Node",e[e.Color=10]="Color",e[e.RgbNode=11]="RgbNode",e[e.String=12]="String",e[e.BaseActor=13]="BaseActor",e[e.Euler=14]="Euler",e[e.Object3D=15]="Object3D",e[e.Material=16]="Material",e[e.AudioBuffer=17]="AudioBuffer",e[e.Vector4=18]="Vector4",e[e.Vec4Node=19]="Vec4Node",e[e.VisualEffect=20]="VisualEffect",e[e.Array=21]="Array",e[e.Curve=22]="Curve",e[e.ColorLayer=23]="ColorLayer",e[e.MaskLayer=24]="MaskLayer",e[e.Prefab=25]="Prefab",e[e.PrefabActor=26]="PrefabActor",e[e.AnimationClip=27]="AnimationClip",e[e.Sequence=28]="Sequence",e[e.Struct=29]="Struct",e[e.DataAsset=30]="DataAsset"}(SerializedParamType||(SerializedParamType={}));/*
1
+ export var DetailTier;!function(e){e[e.low=0]="low",e[e.medium=1]="medium",e[e.high=2]="high"}(DetailTier||(DetailTier={}));export var SerializedParamType;!function(e){e[e.FloatNode=0]="FloatNode",e[e.Number=1]="Number",e[e.Texture=2]="Texture",e[e.Sampler2DNode=3]="Sampler2DNode",e[e.Boolean=4]="Boolean",e[e.BooleanNode=5]="BooleanNode",e[e.Vector2=6]="Vector2",e[e.Vec2Node=7]="Vec2Node",e[e.Vector3=8]="Vector3",e[e.Vec3Node=9]="Vec3Node",e[e.Color=10]="Color",e[e.RgbNode=11]="RgbNode",e[e.String=12]="String",e[e.BaseActor=13]="BaseActor",e[e.Euler=14]="Euler",e[e.Object3D=15]="Object3D",e[e.Material=16]="Material",e[e.AudioBuffer=17]="AudioBuffer",e[e.Vector4=18]="Vector4",e[e.Vec4Node=19]="Vec4Node",e[e.VisualEffect=20]="VisualEffect",e[e.Array=21]="Array",e[e.Curve=22]="Curve",e[e.ColorLayer=23]="ColorLayer",e[e.MaskLayer=24]="MaskLayer",e[e.Prefab=25]="Prefab",e[e.PrefabActor=26]="PrefabActor",e[e.AnimationClip=27]="AnimationClip",e[e.Sequence=28]="Sequence",e[e.Struct=29]="Struct",e[e.DataAsset=30]="DataAsset",e[e.SequenceData=31]="SequenceData"}(SerializedParamType||(SerializedParamType={}));/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
1
- export class Prefab{constructor(s){this.asset=s}}export class PrefabInstance{}export class PrefabOf{constructor(s){this.prefab=s}}/*
1
+ export class Prefab{constructor(s){this.asset=s}}export class PrefabInstance{constructor(){this.destroyed=!1}}export class PrefabOf{constructor(s){this.prefab=s}}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -43,10 +43,12 @@ export declare class ShaderGraphCompiler {
43
43
  private readonly options;
44
44
  private readonly nodesById;
45
45
  private readonly compiled;
46
+ private readonly compiling;
46
47
  constructor(graph: ShaderGraphDocument, options?: ShaderGraphCompileOptions);
47
48
  validate(): void;
48
49
  compile(): ShaderGraphCompileResult;
49
50
  private validateEdges;
51
+ private validateNamedReroutes;
50
52
  private compileOutput;
51
53
  private compilePostProcessOutput;
52
54
  private applyShadingModel;
@@ -60,6 +62,7 @@ export declare class ShaderGraphCompiler {
60
62
  private compileBinaryFunction;
61
63
  private compilePaintedLayerMix;
62
64
  private defaultUV;
65
+ private namedRerouteDeclaration;
63
66
  private input;
64
67
  private optionalInput;
65
68
  private floatInput;
@@ -1,4 +1,4 @@
1
- import{BackSide as t,Color as e,DataTexture as a,DoubleSide as r,FrontSide as u,Matrix4 as i,RGBAFormat as o,Texture as n,Vector2 as s,Vector3 as l,Vector4 as p}from"three";import{BooleanNode as c,FloatNode as h,Mat4Node as v,NodeShaderMaterial as y,RgbNode as d,RgbaNode as m,Sampler2DNode as f,Texture2dLookupNode as g,UniformFloatNode as b,Vec2Node as x,Vec3Node as w,Vec4Node as T,abs as S,acos as I,asin as O,attributes as M,atan as C,atan2 as N,autoVarying as E,bulge as G,bool as U,ceil as B,clamp as $,colorToNormal as z,cos as k,cross as V,degrees as P,distance as A,dot as j,exp as D,exp2 as L,float as q,floor as F,fract as R,inversesqrt as _,batchingMatrix as W,colorGradientSampler as H,curveSampler as Y,ifDefApply as J,sampleNamedEasingCurve as K,length as Q,LayerMixMode as X,log as Z,log2 as tt,mat4 as et,max as at,min as rt,mix as ut,mixColorsByLayer as it,particleUniforms as ot,mod as nt,normalize as st,pow as lt,radians as pt,rgba as ct,rgb as ht,saturate as vt,select as yt,sign as dt,sin as mt,smoothstep as ft,sqrt as gt,standardMaterial as bt,scaleTransform as xt,step as wt,tan as Tt,textureSampler2d as St,timeUniforms as It,toonMaterial as Ot,translate as Mt,transformed as Ct,triplanarMapping as Nt,twirl as Et,uniformFloat as Gt,uniforms as Ut,varyingAttributes as Bt,vec2 as $t,vec3 as zt,vec4 as kt,getPaintedMaterialLayerWeight as Vt}from"../../shader-nodes/index.js";import{SpriteNodeShaderMaterial as Pt,getSpritePosition as At}from"../sprite-shader.js";import{oneMinus as jt}from"../../shader-nodes/index.js";import{vectorToRadial as Dt,remap as Lt,hueShift as qt,blendColor as Ft,desaturateColor as Rt}from"../../shader-nodes/math.js";import{rectangleFloat as _t,roundedRectangleFloat as Wt}from"../../shader-nodes/shapes.js";import{edgeDepthEffect as Ht,fresnelEffect as Yt,depthFadeEffect as Jt}from"../../shader-nodes/effects.js";import{fragmentLinearEyeDepth as Kt,sampleSceneDepth as Qt,sampleSceneLinearEyeDepth as Xt,screenUV as Zt,nearUniformName as te,farUniformName as ee}from"../../shader-nodes/depth.js";import{sampleSceneColor as ae}from"../../shader-nodes/scene-sample.js";import{decalDiscard as re,decalUV as ue}from"../../shader-nodes/decal.js";import{Trail as ie,trailUV as oe}from"../../effects/vfx/trail-renderer.js";import{SimplexNoiseNode as ne,Voronoi2d as se,rotateAxis as le}from"../../shader-nodes/index.js";import{flipbookUv as pe}from"../../shader-nodes/texture-sequence.js";import{parallaxOcclusionMapping as ce}from"../../shader-nodes/pom.js";import{defaultInlineLiteralValueForPort as he,inlineLiteralTypeForPort as ve,SHADER_GRAPH_NODE_DEFINITIONS as ye}from"./registry.js";import{shaderGraphParameterTypeToValueType as de}from"./parameters.js";import{varying as me,reflect as fe,refract as ge,dFdx as be,dFdy as xe,fwidth as we}from"three-shader-graph";import{decalNormal as Te}from"../../shader-nodes/decal.js";import{Curve2 as Se}from"../../utils/curve.js";const Ie=(()=>{const t=new a(new Uint8Array([255,255,255,255]),1,1,o);return t.name="Missing shader graph texture parameter fallback",t.needsUpdate=!0,t})(),Oe=new Set;export class ShaderGraphCompileError extends Error{constructor(t,e,a){super(t),this.nodeId=e,this.port=a,this.name="ShaderGraphCompileError"}}export const shaderGraphPostProcessWeightUniformName="hology_post_process_weight";export class ShaderGraphCompiler{constructor(t,e={}){this.graph=t,this.options=e,this.compiled=new Map,this.nodesById=new Map((t.nodes??[]).map(t=>[t.id,t]))}validate(){this.compile()}compile(){if(1!==this.graph.version)throw new ShaderGraphCompileError(`Unsupported shader graph version ${this.graph.version}`);return this.validateEdges(),{output:this.compileOutput(),nodes:this.compiled}}validateEdges(){for(const t of this.graph.edges??[]){if(!this.nodesById.has(t.from.nodeId))throw new ShaderGraphCompileError(`Edge references missing source node "${t.from.nodeId}"`,t.from.nodeId,t.from.port);if(!this.nodesById.has(t.to.nodeId))throw new ShaderGraphCompileError(`Edge references missing target node "${t.to.nodeId}"`,t.to.nodeId,t.to.port)}}compileOutput(){if("postProcess"===this.graph.target)return this.compilePostProcessOutput();const t=this.graph.outputs?.color,e={color:null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):ct("#ffffff",1),transparent:Ne(this.graph)},a=this.graph.outputs?.opacity;null!=a&&(e.opacity=this.expectType(this.resolveOutputBinding(a,"opacity"),["float"],"opacity").value);const r=this.graph.outputs?.roughness;null!=r&&(e.roughness=this.expectType(this.resolveOutputBinding(r,"roughness"),["float"],"roughness").value);const u=this.graph.outputs?.metalness;null!=u&&(e.metalness=this.floatOutput(u,"metalness"));const i=this.graph.outputs?.normal;null!=i&&(e.normal=this.toVec3Output(this.resolveOutputBinding(i,"normal"),"normal"));const o=this.graph.outputs?.emissive;null!=o&&(e.emissive=this.toVec3Output(this.resolveOutputBinding(o,"emissive"),"emissive"));const n=this.graph.outputs?.ambientOcclusion;null!=n&&(e.ambientOcclusion=this.floatOutput(n,"ambientOcclusion"));const s=this.graph.outputs?.ambientOcclusionIntensity;null!=s&&(e.ambientOcclusionIntensity=this.floatOutput(s,"ambientOcclusionIntensity"));const l=this.graph.outputs?.sheenColor;null!=l&&(e.sheenColor=this.toVec3Output(this.resolveOutputBinding(l,"sheenColor"),"sheenColor"));const p=this.graph.outputs?.sheenRoughness;null!=p&&(e.sheenRoughness=this.floatOutput(p,"sheenRoughness"));const c=this.graph.outputs?.anisotropy;null!=c&&(e.anisotropy=this.floatOutput(c,"anisotropy"));const h=this.graph.outputs?.anisotropyDirection;null!=h&&(e.anisotropyDirection=this.expectType(this.resolveOutputBinding(h,"anisotropyDirection"),["vec2"],"anisotropyDirection").value);const v=this.graph.outputs?.bakedLight;null!=v&&(e.bakedLight=this.toVec3Output(this.resolveOutputBinding(v,"bakedLight"),"bakedLight"));const y=this.graph.outputs?.transform;null!=y&&"decal"!==this.graph.target&&(e.transform=this.toMat4Output(this.resolveOutputBinding(y,"transform"),"transform"));const d=this.graph.outputs?.discard;null!=d&&(e.discard=this.expectType(this.resolveOutputBinding(d,"discard"),["boolean"],"discard").value);const m=this.graph.outputs?.transparent;null!=m&&null!=m.value&&(e.transparent=Boolean(m.value));const f=this.graph.outputs?.alphaTest;return null!=f&&null!=f.value?e.alphaTest=Number(f.value):null!=this.graph.materialOptions?.alphaTest&&(e.alphaTest=this.graph.materialOptions.alphaTest),this.applyShadingModel(e)}compilePostProcessOutput(){const t=this.graph.outputs?.color,e=null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):ae(Zt),a=this.graph.outputs?.opacity;return Me(e,null!=a?this.expectType(this.resolveOutputBinding(a,"opacity"),["float"],"opacity").value:void 0)}applyShadingModel(t){const e=null!=t.opacity?function(t,e){if(t instanceof h)return ct(zt(t,t,t),e);if(t instanceof x)return ct(zt(t.x,t.y,0),e);if(t instanceof T)return ct(t.rgb,t.w.multiply(e));return ct(t,e)}(t.color,t.opacity):t.color;switch(this.graph.shadingModel??"standard"){case"standard":{const a={color:Be(e),roughness:t.roughness??q(.5),...null!=t.metalness?{metalness:t.metalness}:{},..."decal"===this.graph.target?{normal:st(me(Ut.normalMatrix).multiplyVec(Te))}:{},...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:$e(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.sheenColor?{sheenColor:t.sheenColor.rgb}:{},...null!=t.sheenRoughness?{sheenRoughness:t.sheenRoughness}:{},...null!=t.anisotropy?{anisotropy:t.anisotropy}:{},...null!=t.anisotropyDirection?{anisotropyDirection:t.anisotropyDirection}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:bt(a)}}case"toon":{const a={color:Be(e),...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:$e(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:Ot(a)}}case"unlit":return{...t,color:e}}}compileNode(t){const e=this.compiled.get(t);if(null!=e)return e;const a=this.nodesById.get(t);if(null==a)throw new ShaderGraphCompileError(`Missing shader graph node "${t}"`,t);if(null==ye[a.kind])throw new ShaderGraphCompileError(`Unsupported shader graph node "${a.kind}"`,a.id);const r=this.compileNodeInternal(a);return this.compiled.set(t,r),r}compileNodeInternal(t){switch(t.kind){case"input.parameter":return this.output(t,this.compileParameterNode(t));case"input.slider":return this.output(t,{value:{type:"float",value:q(Fe(ke(t,"value",.5)))}});case"constant.boolean":return this.output(t,{value:{type:"boolean",value:U(Boolean(ze(t,"value",!1)))}});case"constant.float":return this.output(t,{value:{type:"float",value:q(ke(t,"value",0))}});case"constant.vec2":return this.output(t,{value:{type:"vec2",value:We(ze(t,"value",[0,0]))}});case"constant.vec3":return this.output(t,{value:{type:"vec3",value:He(ze(t,"value",[0,0,0]))}});case"constant.rgba":return this.output(t,{value:{type:"rgba",value:Ye(ze(t,"value","#ffffff"),ke(t,"alpha",1))}});case"builtin.uv":{const e=this.defaultUV();return this.output(t,{value:{type:"vec2",value:!0===ze(t,"flipY",!1)?$t(e.x,jt(e.y)):e},u:{type:"float",value:e.x},v:{type:"float",value:e.y}})}case"builtin.screenUv":return this.output(t,{value:{type:"vec2",value:Zt}});case"builtin.color":{const e=E(M.color);return this.output(t,{value:{type:"rgba",value:e},rgb:{type:"rgb",value:e.rgb},r:{type:"float",value:e.r},g:{type:"float",value:e.g},b:{type:"float",value:e.b},a:{type:"float",value:e.a}})}case"builtin.position":{const e=E(M.position);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.worldPosition":{const e=E(Ct.worldPosition);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.objectPosition":{let e=Ut.instanceMatrix.multiplyVec(kt(0,0,0,1));e=J("USE_BATCHING",e,t=>W.multiplyVec(t));const a=E(Ut.modelMatrix.multiplyVec(e).xyz);return this.output(t,{value:{type:"vec3",value:a},x:{type:"float",value:a.x},y:{type:"float",value:a.y},z:{type:"float",value:a.z}})}case"builtin.viewDir":{const e=E(Ct.viewDir);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.normal":{const e=E(M.normal);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.time":return this.output(t,{value:{type:"float",value:It.elapsed}});case"builtin.camera":{const e=Gt(te),a=Gt(ee),r=Ut.cameraPosition;return this.output(t,{position:{type:"vec3",value:r},x:{type:"float",value:r.x},y:{type:"float",value:r.y},z:{type:"float",value:r.z},near:{type:"float",value:e},far:{type:"float",value:a}})}case"builtin.viewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.viewMatrix}});case"builtin.projectionMatrix":return this.output(t,{value:{type:"mat4",value:Ut.projectionMatrix}});case"builtin.modelViewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.modelViewMatrix}});case"builtin.particle":return this.output(t,{energy:{type:"float",value:ot.energy},color:{type:"rgb",value:ot.color},opacity:{type:"float",value:ot.opacity},time:{type:"float",value:ot.time}});case"math.add":case"math.subtract":case"math.multiply":case"math.divide":return this.output(t,{value:this.compileBinaryMath(t)});case"math.oneMinus":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:e.type,value:jt(e.value)}})}case"math.abs":return this.output(t,{value:this.compileUnaryMath(t,S)});case"math.sign":return this.output(t,{value:this.compileUnaryMath(t,dt)});case"math.floor":return this.output(t,{value:this.compileUnaryMath(t,F)});case"math.ceil":return this.output(t,{value:this.compileUnaryMath(t,B)});case"math.fract":return this.output(t,{value:this.compileUnaryMath(t,R)});case"math.sin":return this.output(t,{value:this.compileUnaryMath(t,mt)});case"math.cos":return this.output(t,{value:this.compileUnaryMath(t,k)});case"math.tan":return this.output(t,{value:this.compileUnaryMath(t,Tt)});case"math.asin":return this.output(t,{value:this.compileUnaryMath(t,O)});case"math.acos":return this.output(t,{value:this.compileUnaryMath(t,I)});case"math.atan":return this.output(t,{value:this.compileUnaryMath(t,C)});case"math.atan2":return this.output(t,{value:this.compileAtan2(t)});case"math.radians":return this.output(t,{value:this.compileUnaryMath(t,pt)});case"math.degrees":return this.output(t,{value:this.compileUnaryMath(t,P)});case"math.sqrt":return this.output(t,{value:this.compileUnaryMath(t,gt)});case"math.inverseSqrt":return this.output(t,{value:this.compileUnaryMath(t,_)});case"math.exp":return this.output(t,{value:this.compileUnaryMath(t,D)});case"math.exp2":return this.output(t,{value:this.compileUnaryMath(t,L)});case"math.log":return this.output(t,{value:this.compileUnaryMath(t,Z)});case"math.log2":return this.output(t,{value:this.compileUnaryMath(t,tt)});case"math.saturate":return this.output(t,{value:this.compileUnaryMath(t,vt)});case"math.length":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:"float",value:Q(e.value)}})}case"math.normalize":return this.output(t,{value:this.compileUnaryMath(t,st)});case"math.clamp":{const e=this.expectNumeric(this.input(t,"value")),a=this.expectNumeric(this.input(t,"min",{type:"float",value:q(0)})),r=this.expectNumeric(this.input(t,"max",{type:"float",value:q(1)}));return this.output(t,{value:{type:e.type,value:$(e.value,a.value,r.value)}})}case"math.min":return this.output(t,{value:this.compileBinaryFunction(t,rt)});case"math.max":return this.output(t,{value:this.compileBinaryFunction(t,at)});case"math.pow":return this.output(t,{value:this.compileBinaryFunction(t,lt)});case"math.mod":return this.output(t,{value:this.compileBinaryFunction(t,nt)});case"math.step":return this.output(t,{value:this.compileBinaryFunction(t,wt,!0)});case"math.smoothstep":{const e=this.expectNumeric(this.input(t,"edge0",{type:"float",value:q(0)})),a=this.expectNumeric(this.input(t,"edge1",{type:"float",value:q(1)})),r=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:r.type,value:ft(e.value,a.value,r.value)}})}case"math.mix":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b")),r=this.expectNumeric(this.input(t,"t",{type:"float",value:q(.5)})),u=je(e.type,a.type,t.id);return this.output(t,{value:{type:u,value:ut(e.value,a.value,r.value)}})}case"math.remap":{const e=this.expectType(this.input(t,"value"),["float"],t.id,"value").value,a=this.floatInput(t,"inMin",-1),r=this.floatInput(t,"inMax",1),u=this.floatInput(t,"outMin",0),i=this.floatInput(t,"outMax",1);return this.output(t,{value:{type:"float",value:Lt(e,a,r,u,i)}})}case"math.select":{const e=this.boolInput(t,"condition",!1),a=this.expectNumeric(this.input(t,"a")),r=this.expectNumeric(this.input(t,"b")),u=je(a.type,r.type,t.id);return this.output(t,{value:{type:u,value:yt(e,a.value,r.value)}})}case"math.reflect":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal");return this.output(t,{value:{type:e.type,value:fe(e.value,a.value)}})}case"math.refract":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal"),r=this.floatInput(t,"ior",1.5);return this.output(t,{value:{type:e.type,value:ge(e.value,a.value,r)}})}case"math.derivative":{const e=this.expectNumeric(this.input(t,"value")),a=String(ze(t,"mode","fwidth"));let r;return r="dFdx"===a?be(e.value):"dFdy"===a?xe(e.value):we(e.value),this.output(t,{value:{type:e.type,value:r}})}case"layer.mixPainted":return this.output(t,{value:this.compilePaintedLayerMix(t)});case"math.dot":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return je(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:j(e.value,a.value)}})}case"math.distance":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return je(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:A(e.value,a.value)}})}case"math.cross":{const e=this.expectType(this.input(t,"a"),["vec3","rgb"],t.id,"a"),a=this.expectType(this.input(t,"b"),["vec3","rgb"],t.id,"b");return this.output(t,{value:{type:"vec3",value:V(e.value,a.value)}})}case"compare.greaterThan":case"compare.greaterThanOrEqual":case"compare.lessThan":case"compare.lessThanOrEqual":case"compare.equal":case"compare.notEqual":return this.output(t,{value:{type:"boolean",value:this.compileComparison(t)}});case"boolean.not":{const e=this.boolInput(t,"value",!1);return this.output(t,{value:{type:"boolean",value:yt(e,U(!1),U(!0))}})}case"boolean.and":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"and")}});case"boolean.or":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"or")}});case"compose.vec2":return this.output(t,{value:{type:"vec2",value:$t(this.floatInput(t,"x",0),this.floatInput(t,"y",0))}});case"compose.vec3":return this.output(t,{value:{type:"vec3",value:zt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0))}});case"compose.vec4":return this.output(t,{value:{type:"vec4",value:kt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0),this.floatInput(t,"w",0))}});case"compose.rgba":return this.output(t,{value:{type:"rgba",value:kt(this.floatInput(t,"r",1),this.floatInput(t,"g",1),this.floatInput(t,"b",1),this.floatInput(t,"a",1))}});case"decompose.component":{const e=this.expectNumeric(this.input(t,"value")),a=String(ze(t,"component","x"));return this.output(t,{value:{type:"float",value:Le(e,a,t.id)}})}case"decompose.split":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,function(t,e){const a={},r=(r,u)=>{a[r]={type:"float",value:Le(t,u,e)}};switch(t.type){case"vec2":return r("x","x"),r("y","y"),r("u","x"),r("v","y"),a;case"vec3":return r("x","x"),r("y","y"),r("z","z"),a;case"rgb":return r("r","r"),r("g","g"),r("b","b"),r("x","x"),r("y","y"),r("z","z"),a;case"vec4":return r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"rgba":return r("r","r"),r("g","g"),r("b","b"),r("a","a"),r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"float":return a.x={type:"float",value:t.value},a}}(e,t.id))}case"color.gradient":{const e=this.expectType(this.input(t,"t",{type:"float",value:q(.5)}),["float"],t.id,"t"),a=H(function(t){const e=ze(t,"stops",[]);if(!Array.isArray(e))return[];const a=e.map((t,a)=>{if(null==t||"object"!=typeof t||Array.isArray(t))return;const r=t,u="string"==typeof r.color?r.color:"#ffffff";return{position:Re(r.position,Je(a,e.length)),color:u,alpha:Re(r.alpha,1)}}).filter(t=>null!=t);return a.length>0?a:[]}(t)).sample(e.value);return this.output(t,{value:{type:"rgba",value:a}})}case"utility.curve":{const e=this.expectType(this.input(t,"t",{type:"float",value:q(.5)}),["float"],t.id,"t"),a=ze(t,"curve","Linear"),r=K(a,e.value)??Y(Se.decode(a)).sample(e.value);return this.output(t,{value:{type:"float",value:r}})}case"color.hueShift":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"shift",0),i=qt(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:kt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.blend":{const e=this.expectType(this.input(t,"base"),["rgba","rgb","vec4","vec3"],t.id,"base"),a=this.expectType(this.input(t,"blend"),["rgba","rgb","vec4","vec3"],t.id,"blend"),r=String(ze(t,"mode","multiply")),u=e.value,i=a.value,o="rgba"===e.type||"vec4"===e.type?u.rgb??u.xyz:u,n="rgba"===a.type||"vec4"===a.type?i.rgb??i.xyz:i;let s=Ft(o,n,r);if("rgba"===a.type||"vec4"===a.type){const t=i.a??i.w;s=ut(o,s,t)}if("rgba"===e.type||"vec4"===e.type){const a=u.a??u.w;return this.output(t,{value:{type:e.type,value:kt(s,a)}})}return this.output(t,{value:{type:e.type,value:s}})}case"color.desaturate":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"fraction",1),i=Rt(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:kt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.unpackNormal":{const e=this.expectType(this.input(t,"color"),["vec3","vec4","rgb","rgba"],t.id,"color"),a=this.floatInput(t,"scale",1),r=this.optionalInput(t,"normal");return this.output(t,{value:{type:"vec3",value:z(e.value,a,r?this.expectType(r,["vec3"],t.id,"normal").value:void 0)}})}case"texture.sampler2d":{const e=this.input(t,"texture");return this.output(t,{value:this.toSampler(e,t.id)})}case"texture.sample2d":{const e=this.toSampler(this.input(t,"sampler"),t.id),a=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),r=e.value.sample(a.value);return this.output(t,{rgba:{type:"rgba",value:r},rgb:{type:"rgb",value:r.rgb},r:{type:"float",value:r.r},g:{type:"float",value:r.g},b:{type:"float",value:r.b},a:{type:"float",value:r.a}})}case"texture.triplanarMapping":{const e=this.input(t,"sampler"),a=this.toSampler(e,t.id),r=this.expectType(this.input(t,"scale",{type:"float",value:q(1)}),["float"],t.id,"scale"),u=this.expectType(this.input(t,"normal",{type:"vec3",value:Bt.normal}),["vec3"],t.id,"normal"),i=this.expectType(this.input(t,"position",{type:"vec3",value:Bt.position}),["vec3"],t.id,"position"),o=Nt(a.value,r.value,u.value,i.value);return this.output(t,{rgba:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a}})}case"scene.sampleColor":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:Zt}),["vec2"],t.id,"uv"),a=ae(e.value);return this.output(t,{rgba:{type:"rgba",value:a},rgb:{type:"rgb",value:a.rgb},r:{type:"float",value:a.r},g:{type:"float",value:a.g},b:{type:"float",value:a.b},a:{type:"float",value:a.a}})}case"scene.sampleDepth":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:Zt}),["vec2"],t.id,"uv");return this.output(t,{depth:{type:"float",value:Qt(e.value)},linearEyeDepth:{type:"float",value:Xt(e.value)}})}case"scene.fragmentDepth":return this.output(t,{linearEyeDepth:{type:"float",value:Kt}});case"transform.translate":{const e=this.expectType(this.input(t,"offset",{type:"vec3",value:zt(0,0,0)}),["vec3","rgb"],t.id,"offset");return this.output(t,{value:{type:"mat4",value:Mt(e.value)}})}case"transform.scale":{const e=this.expectType(this.input(t,"scale",{type:"vec3",value:zt(1,1,1)}),["vec3","rgb"],t.id,"scale").value;return this.output(t,{value:{type:"mat4",value:xt(e.x,e.y,e.z)}})}case"transform.rotateAxis":{const e=this.expectType(this.input(t,"axis",{type:"vec3",value:zt(0,1,0)}),["vec3","rgb"],t.id,"axis"),a=this.expectType(this.input(t,"angle",{type:"float",value:q(0)}),["float"],t.id,"angle");return this.output(t,{value:{type:"mat4",value:le(e.value,a.value)}})}case"uv.rotate":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"angle",{type:"float",value:q(0)}),["float"],t.id,"angle").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value;return this.output(t,{value:{type:"vec2",value:De(e,a,r)}})}case"uv.twirl":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"strength",{type:"float",value:q(1)}),["float"],t.id,"strength").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,u=this.expectType(this.input(t,"offset",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"offset").value;return this.output(t,{value:{type:"vec2",value:Et(e,a,r,u)}})}case"uv.radial":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=Dt(e.subtractScalar(.5));return this.output(t,{coords:{type:"vec2",value:a.coords},radius:{type:"float",value:a.radius},angle:{type:"float",value:a.angle}})}case"uv.bulge":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,r=this.expectType(this.input(t,"power",{type:"float",value:q(1)}),["float"],t.id,"power").value;return this.output(t,{value:{type:"vec2",value:G(e,a,r)}})}case"uv.flipbook":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"columns",ke(t,"columns",1)),r=this.floatInput(t,"rows",ke(t,"rows",1)),u=this.floatInput(t,"fps",ke(t,"fps",60)),i=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time").value,o=String(ze(t,"mode","clamp"));return this.output(t,{value:{type:"vec2",value:pe(e,a,r,i,u,o)}})}case"uv.pom":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.input(t,"heightMap"),r=this.toSampler(a,t.id).value,u=this.floatInput(t,"heightScale",.05),i=ke(t,"minLayers",8),o=ke(t,"maxLayers",24);return this.output(t,{value:{type:"vec2",value:ce(e,r,u,i,o)}})}case"shape.rectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:_t(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5))}})}case"shape.roundedRectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:Wt(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5),this.floatInput(t,"radius",.1))}})}case"noise.simplex":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new ne(e.multiplyScalar(a))}})}case"noise.voronoi2d":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new se(e.multiplyScalar(a))}})}case"effect.fresnel":return this.output(t,{value:{type:"float",value:E(Yt(this.floatInput(t,"power",1)))}});case"effect.edgeDepth":{const e=this.floatInput(t,"power",1);return this.output(t,{value:{type:"float",value:Ht(e)}})}case"effect.depthFade":{const e=this.floatInput(t,"distance",1);return this.output(t,{value:{type:"float",value:Jt(e)}})}case"util.panner":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"coord"),a=this.expectType(this.input(t,"speed",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"speed"),r=this.expectType(this.input(t,"tile",{type:"vec2",value:$t(1,1)}),["vec2"],t.id,"tile"),u=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time");return this.output(t,{value:{type:"vec2",value:e.value.multiply(r.value).add(a.value.multiplyScalar(u.value))}})}}}compileParameterNode(t){const e=String(ze(t,"parameter","")),a=this.graph.parameters?.find(t=>t.name===e||t.id===e);if(null==a)throw new ShaderGraphCompileError(`Parameter "${e}" does not exist`,t.id);const r=de(a.type),u={type:r,value:Pe(this.options.parameters?.[a.name]??a.defaultValue,r,a.name)};if("sampler2d"!==r)return{value:u};const i=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),o=u.value.sample(i.value);return{value:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a},sampler:u}}compileBinaryMath(t){const e=this.expectBinaryMathValue(this.input(t,"a")),a=this.expectBinaryMathValue(this.input(t,"b")),r=t.kind.split(".")[1];if("mat4"===e.type||"mat4"===a.type)return function(t,e,a,r){if("mat4"===t.type&&"mat4"===e.type&&"divide"!==a)return{type:"mat4",value:Ae(t.value,e.value,a,r)};if("mat4"===t.type&&"float"===e.type&&("multiply"===a||"divide"===a))return{type:"mat4",value:Ae(t.value,e.value,a,r)};if("float"===t.type&&"mat4"===e.type&&"multiply"===a)return{type:"mat4",value:Ae(e.value,t.value,a,r)};if("mat4"===t.type&&"vec4"===e.type&&"multiply"===a)return{type:"vec4",value:t.value.multiplyVec(e.value)};throw new ShaderGraphCompileError(`Cannot ${a} ${t.type} and ${e.type}`,r)}(e,a,r,t.id);if(e.type===a.type)return{type:e.type,value:Ae(e.value,a.value,r,t.id)};if("float"===e.type&&"float"!==a.type&&"multiply"===r)return{type:a.type,value:Ae(a.value,e.value,r,t.id)};if("float"!==e.type&&"float"===a.type)return{type:e.type,value:Ae(e.value,a.value,r,t.id)};throw new ShaderGraphCompileError(`Cannot ${r} ${e.type} and ${a.type}`,t.id)}expectBinaryMathValue(t){if(!qe(t.type)&&"mat4"!==t.type)throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}compileUnaryMath(t,e){const a=this.expectNumeric(this.input(t,"value"));return{type:a.type,value:e(a.value)}}compileAtan2(t){const e=this.expectNumeric(this.input(t,"y")),a=this.expectNumeric(this.input(t,"x"));return{type:function(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}(e.type,a.type,t.id),value:N(e.value,a.value)}}compileBinaryFunction(t,e,a=!1){const r=this.expectNumeric(this.input(t,"a")),u=this.expectNumeric(this.input(t,"b"));return{type:a&&"float"===u.type?r.type:je(r.type,u.type,t.id),value:e(r.value,u.value)}}compilePaintedLayerMix(t){const e=this.expectNumeric(this.input(t,"base")),a=[e.value],r=[Vt(0)];let u=e.type;for(let e=1;e<=8;e++){const i=this.optionalInput(t,`layer${e}`);if(null==i)continue;const o=this.expectNumeric(i);u=je(u,o.type,t.id),a.push(o.value),r.push(Vt(e))}return 1===a.length?e:{type:u,value:it({layerColors:a,layerWeights:r,enableNoise:Boolean(ze(t,"enableNoise",!0)),noiseScale:this.floatInput(t,"noiseScale",ke(t,"noiseScale",.1)),noiseAmount:this.floatInput(t,"noiseAmount",ke(t,"noiseAmount",.5)),decay:this.floatInput(t,"softness",ke(t,"softness",.3)),mode:"hard"===String(ze(t,"mode","soft"))?X.hard:X.soft})}}defaultUV(){return"trail"===this.graph.target?oe:"decal"===this.graph.target?ue:E(M.uv)}input(t,e,a){const r=t.inputs?.[e];if(null!=r)return this.resolveInput(r,t.id,e);const u=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);if(null!=u)return this.resolveSocket(u.from,t.id,e);if(null!=a)return a;const i=this.inlineLiteralFallback(t,e);if(null!=i)return i;throw new ShaderGraphCompileError(`Missing input "${e}"`,t.id,e)}optionalInput(t,e){const a=t.inputs?.[e];if(null!=a)return this.resolveInput(a,t.id,e);const r=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);return null!=r?this.resolveSocket(r.from,t.id,e):void 0}floatInput(t,e,a){return this.expectType(this.input(t,e,{type:"float",value:q(a)}),["float"],t.id,e).value}boolInput(t,e,a){return this.expectType(this.input(t,e,{type:"boolean",value:U(a)}),["boolean"],t.id,e).value}compileComparison(t){const e=this.expectType(this.input(t,"a"),["float"],t.id,"a").value,a=this.expectType(this.input(t,"b"),["float"],t.id,"b").value;switch(t.kind){case"compare.greaterThan":return e.gt(a);case"compare.greaterThanOrEqual":return e.gte(a);case"compare.lessThan":return e.lt(a);case"compare.lessThanOrEqual":return e.lte(a);case"compare.equal":return e.equals(a);case"compare.notEqual":return e.notEquals(a)}throw new ShaderGraphCompileError(`Unsupported comparison node "${t.kind}"`,t.id)}compileBooleanBinary(t,e){const a=this.boolInput(t,"a",!1),r=this.boolInput(t,"b",!1);return"and"===e?a.and(r):a.or(r)}resolveOutputBinding(t,e){if(null!=t.input)return this.resolveSocket(t.input,void 0,e);if(void 0!==t.value)return Ve(t.value);throw new ShaderGraphCompileError(`Output "${e}" is missing an input or value`)}floatOutput(t,e){return this.expectType(this.resolveOutputBinding(t,e),["float"],e).value}resolveInput(t,e,a){return function(t){return null!=t.nodeId}(t)?this.resolveSocket(t,e,a):Ve(t.value,t.valueType)}inlineLiteralFallback(t,e){const a=ye[t.kind]?.inputs.find(t=>t.name===e);if(null==a)return;const r=ve(t.kind,a),u=he(t.kind,a);return null!=r&&void 0!==u?Ve(u,r):void 0}resolveSocket(t,e,a){const r=this.compileNode(t.nodeId).outputs[t.port];if(null==r)throw new ShaderGraphCompileError(`Node "${t.nodeId}" does not have output "${t.port}"`,e??t.nodeId,a??t.port);return r}expectType(t,e,a,r){if(!e.includes(t.type))throw new ShaderGraphCompileError(`Expected ${e.join(" or ")} but got ${t.type}`,a,r);return t}expectNumeric(t){if(!qe(t.type))throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}toSampler(t,e){if("sampler2d"===t.type)return t;if("texture2d"===t.type){const a=t.value;if(null==a)throw new ShaderGraphCompileError("Texture input is empty",e);return{type:"sampler2d",value:St(a)}}throw new ShaderGraphCompileError(`Expected texture2d or sampler2d but got ${t.type}`,e)}toColorOutput(t){switch(t.type){case"float":case"vec2":case"vec3":case"vec4":case"rgb":case"rgba":return t.value;case"boolean":{const e=yt(t.value,q(1),q(0));return ct(zt(e,e,e),1)}case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be used as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} must be sampled before it can be used as color`)}}toVec3Output(t,e){if("vec3"===t.type||"rgb"===t.type)return t.value;if("vec4"===t.type||"rgba"===t.type)return t.value.xyz;throw new ShaderGraphCompileError(`Output "${e}" expects vec3/rgb but got ${t.type}`)}toMat4Output(t,e){if("mat4"===t.type)return t.value;throw new ShaderGraphCompileError(`Output "${e}" expects mat4 but got ${t.type}`)}output(t,e){return{node:t,outputs:e}}}export function compileShaderGraph(t,e={}){return new ShaderGraphCompiler(t,e).compile()}export function compileShaderGraphPreview(t,e,a={}){if(null==e)return compileShaderGraph(t,a).output;const r=new ShaderGraphCompiler(t,a).compileNode(e),u=Object.values(r.outputs)[0];if(null==u)throw new ShaderGraphCompileError(`Node "${e}" has no previewable output`,e);return{color:Ge(u),transparent:"rgba"===u.type||"vec4"===u.type}}export function buildShaderGraphMaterial(t,a={}){if("postProcess"===t.target)return buildShaderGraphPostProcessMaterial(t,a);const r=function(t,e,a){const r=a.alphaTest??t.alphaTest??e.materialOptions?.alphaTest;return null!=r?{...t,alphaTest:r}:t}(null!=a.previewNodeId?compileShaderGraphPreview(t,a.previewNodeId,a):compileShaderGraph(t,a).output,t,a);if("sprite"===t.target)return new Pt({color:r.color,discard:r.discard,alphaTest:r.alphaTest,transparent:r.transparent??!0,position:At(new b("rotation",0),new b("screenSpaceSize",0)),uniforms:{color:{value:new e(16777215)}}});if("trail"===t.target){const{position:e}=ie.getTrailShaderNodes(a.trailBillboard??!1),u=new y({...r,position:e});return ie.applyTrailShaderParameters(u),Ee(u,t),u}if("decal"===t.target){const e=null!=r.discard?re.or(r.discard):re,a=new y({...r,transparent:!1,discard:e});return a.userData.isDecal=!0,Ee(a,t),a}const u=new y({transparent:!1,...r});return Ee(u,t),u}export function buildShaderGraphPostProcessMaterial(t,e={}){const a=null!=e.previewNodeId?Me(compileShaderGraphPreview(t,e.previewNodeId,e).color):compileShaderGraph(t,e).output,r=new y({color:a.color,transparent:!1,fog:!1,lights:!1,outputEncoding:!1});return r.depthWrite=!1,r.depthTest=!1,r.toneMapped=!1,r.userData.isPostProcessShaderGraph=!0,r}export function buildShaderGraphInlinePreviewMaterial(t,e,a={}){const r=compileShaderGraphPreview({...t,target:"surface"},e,a),u=new y({color:r.color,transparent:r.transparent??!1,fog:!1,lights:!1});return u.depthWrite=!1,u.depthTest=!1,u.toneMapped=!1,u}function Me(t,e){const a=ae(Zt),r=Gt("hology_post_process_weight",1),u=vt(null!=e?r.multiply(e):r);return{color:ut(a.rgb,Ce(t),u),transparent:!1,...null!=e?{opacity:e}:{}}}function Ce(t){return t instanceof h?zt(t,t,t):t instanceof x?zt(t.x,t.y,0):t instanceof T?t.xyz:t}export function shaderGraphMaterialSideToThree(e){switch(e){case"back":return t;case"double":return r;default:return u}}function Ne(t){return"decal"!==t.target&&(t.materialOptions?.transparent??"sprite"===t.target)}function Ee(t,e){"surface"===e.target&&(t.side=shaderGraphMaterialSideToThree(e.materialOptions?.side)),null!=e.materialOptions?.transparent&&(t.transparent=e.materialOptions.transparent),null!=e.materialOptions?.bloom&&(t.userData.hasBloom=e.materialOptions.bloom)}function Ge(t){switch(t.type){case"float":return Ue(t.value);case"vec2":{const e=t.value;return ct(zt(e.x,e.y,0),1)}case"vec3":case"rgb":return ct(t.value,1);case"vec4":case"rgba":return t.value;case"boolean":return Ue(yt(t.value,q(1),q(0)));case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be previewed as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} nodes require a sampled output to preview`)}}function Ue(t){return ct(zt(t,t,t),1)}function Be(t){return t instanceof h?zt(t,t,t).rgb:t instanceof x?zt(t.x,t.y,0).rgb:t}function $e(t){return t.rgb}function ze(t,e,a){const r=t.params?.[e];return void 0===r?a:r}function ke(t,e,a){const r=ze(t,e,a);return"number"==typeof r?r:Number(r??a)}function Ve(t,e){if(null!=(a=t)&&"object"==typeof a&&!Array.isArray(a)&&"value"in a)return Ve(t.value,t.valueType??e);var a;const r=e??function(t){if("boolean"==typeof t)return"boolean";if("number"==typeof t)return"float";if(Array.isArray(t))return 2===t.length?"vec2":3===t.length?"vec3":16===t.length?"mat4":"vec4";return"string"==typeof t?"rgb":"float"}(t);return{type:r,value:Pe(t,r,"literal")}}function Pe(t,a,r){switch(a){case"boolean":return t instanceof c?t:U(Boolean(t));case"float":return t instanceof h?t:q(Re(t,0));case"vec2":return t instanceof x?t:We(t);case"vec3":return t instanceof w?t:He(t);case"vec4":return t instanceof T?t:function(t){const[e,a,r,u]=_e(t,4,1);return kt(e,a,r,u)}(t);case"mat4":return t instanceof v?t:function(t){if(t instanceof i)return et(t);const e=new i;Array.isArray(t)&&16===t.length&&e.fromArray(t.map(t=>Re(t,0)));return et(e)}(t);case"rgb":return t instanceof d?t:function(t){if("string"==typeof t||"number"==typeof t||t instanceof e)return ht(t);const[a,r,u]=_e(t,3);return zt(a,r,u).rgb}(t);case"rgba":return t instanceof m||t instanceof T?t:Ye(t);case"texture2d":return t;case"sampler2d":return function(t){const e=t;return t instanceof f||t instanceof g||"function"==typeof e?.isSampler2D||!0===e?.isSampler2D}(t)?t:t instanceof n||!0===t?.isTexture?St(t):(Oe.has(r)||(Oe.add(r),console.warn(`Shader graph parameter "${r}" is missing a texture value; using a 1x1 white fallback texture.`)),St(Ie))}}function Ae(t,e,a,r){const u=`${a}Scalar`;if(e instanceof h&&"function"==typeof t[u])return t[u](e);if("function"==typeof t[a])return t[a](e);throw new ShaderGraphCompileError(`Node does not support ${a}`,r)}function je(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";if("float"===t&&qe(e))return e;if("float"===e&&qe(t))return t;throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}function De(t,e,a){const r=t.subtract(a),u=mt(e),i=k(e);return $t(i.multiply(r.x).subtract(u.multiply(r.y)).add(a.x),u.multiply(r.x).add(i.multiply(r.y)).add(a.y))}function Le(t,e,a){const r=t.value["u"===e?"x":"v"===e?"y":e];if(r instanceof h)return r;throw new ShaderGraphCompileError(`Component "${e}" is not available on ${t.type}`,a)}function qe(t){return"float"===t||"vec2"===t||"vec3"===t||"vec4"===t||"rgb"===t||"rgba"===t}function Fe(t){return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function Re(t,e){if("number"==typeof t)return t;if("string"==typeof t){const a=parseFloat(t);return Number.isFinite(a)?a:e}return"boolean"==typeof t?t?1:0:e}function _e(t,a,r=0){if(Array.isArray(t))return Array.from({length:a},(e,a)=>Re(t[a],r));if(t instanceof s||t instanceof l||t instanceof p)return Array.from({length:a},(e,a)=>t.toArray()[a]??r);if(t instanceof e){const e=t.toArray();return Array.from({length:a},(t,a)=>e[a]??(3===a?1:r))}if(null!=t&&"object"==typeof t){const e=t,u=["x","y","z","w"];if(u.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>Re(e[u[a]],r));const i=["r","g","b","a"];if(i.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>Re(e[i[a]],3===a?1:r))}return Array.from({length:a},()=>Re(t,r))}function We(t){const[e,a]=_e(t,2);return $t(e,a)}function He(t){const[e,a,r]=_e(t,3);return zt(e,a,r)}function Ye(t,a=1){if("string"==typeof t||"number"==typeof t||t instanceof e)return ct(t,a);if(t instanceof w)return ct(t,a);const[r,u,i,o]=_e(t,4,a);return kt(r,u,i,o)}function Je(t,e){return e<=1?0:t/(e-1)}/*
1
+ import{BackSide as t,Color as e,DataTexture as a,DoubleSide as r,FrontSide as u,Matrix4 as i,RGBAFormat as o,Texture as n,Vector2 as s,Vector3 as l,Vector4 as p}from"three";import{BooleanNode as c,FloatNode as h,Mat4Node as v,NodeShaderMaterial as y,RgbNode as d,RgbaNode as m,Sampler2DNode as f,Texture2dLookupNode as g,UniformFloatNode as b,Vec2Node as x,Vec3Node as w,Vec4Node as S,abs as T,acos as I,asin as O,attributes as M,atan as N,atan2 as C,autoVarying as E,bulge as G,bool as U,ceil as B,clamp as $,colorToNormal as k,cos as z,cross as V,degrees as P,distance as A,dot as j,exp as D,exp2 as L,float as R,floor as q,fract as F,inversesqrt as _,batchingMatrix as W,colorGradientSampler as H,curveSampler as Y,ifDefApply as J,sampleNamedEasingCurve as K,length as Q,LayerMixMode as X,log as Z,log2 as tt,mat4 as et,max as at,min as rt,mix as ut,mixColorsByLayer as it,particleUniforms as ot,mod as nt,normalize as st,pow as lt,radians as pt,rgba as ct,rgb as ht,saturate as vt,select as yt,sign as dt,sin as mt,smoothstep as ft,sqrt as gt,standardMaterial as bt,scaleTransform as xt,step as wt,tan as St,textureSampler2d as Tt,timeUniforms as It,toonMaterial as Ot,translate as Mt,transformed as Nt,triplanarMapping as Ct,twirl as Et,uniformFloat as Gt,uniforms as Ut,varyingAttributes as Bt,vec2 as $t,vec3 as kt,vec4 as zt,getPaintedMaterialLayerWeight as Vt}from"../../shader-nodes/index.js";import{SpriteNodeShaderMaterial as Pt,getSpritePosition as At}from"../sprite-shader.js";import{oneMinus as jt}from"../../shader-nodes/index.js";import{vectorToRadial as Dt,remap as Lt,hueShift as Rt,blendColor as qt,desaturateColor as Ft}from"../../shader-nodes/math.js";import{rectangleFloat as _t,roundedRectangleFloat as Wt}from"../../shader-nodes/shapes.js";import{edgeDepthEffect as Ht,fresnelEffect as Yt,depthFadeEffect as Jt}from"../../shader-nodes/effects.js";import{fragmentLinearEyeDepth as Kt,sampleSceneDepth as Qt,sampleSceneLinearEyeDepth as Xt,screenUV as Zt,nearUniformName as te,farUniformName as ee}from"../../shader-nodes/depth.js";import{sampleSceneColor as ae}from"../../shader-nodes/scene-sample.js";import{decalDiscard as re,decalUV as ue}from"../../shader-nodes/decal.js";import{Trail as ie,trailUV as oe}from"../../effects/vfx/trail-renderer.js";import{SimplexNoiseNode as ne,Voronoi2d as se,rotateAxis as le}from"../../shader-nodes/index.js";import{flipbookUv as pe}from"../../shader-nodes/texture-sequence.js";import{parallaxOcclusionMapping as ce}from"../../shader-nodes/pom.js";import{defaultInlineLiteralValueForPort as he,inlineLiteralTypeForPort as ve,SHADER_GRAPH_NODE_DEFINITIONS as ye}from"./registry.js";import{shaderGraphParameterTypeToValueType as de}from"./parameters.js";import{varying as me,reflect as fe,refract as ge,dFdx as be,dFdy as xe,fwidth as we}from"three-shader-graph";import{decalNormal as Se}from"../../shader-nodes/decal.js";import{Curve2 as Te}from"../../utils/curve.js";const Ie=(()=>{const t=new a(new Uint8Array([255,255,255,255]),1,1,o);return t.name="Missing shader graph texture parameter fallback",t.needsUpdate=!0,t})(),Oe=new Set;export class ShaderGraphCompileError extends Error{constructor(t,e,a){super(t),this.nodeId=e,this.port=a,this.name="ShaderGraphCompileError"}}export const shaderGraphPostProcessWeightUniformName="hology_post_process_weight";export class ShaderGraphCompiler{constructor(t,e={}){this.graph=t,this.options=e,this.compiled=new Map,this.compiling=new Set,this.nodesById=new Map((t.nodes??[]).map(t=>[t.id,t]))}validate(){this.compile()}compile(){if(1!==this.graph.version)throw new ShaderGraphCompileError(`Unsupported shader graph version ${this.graph.version}`);return this.validateEdges(),this.validateNamedReroutes(),{output:this.compileOutput(),nodes:this.compiled}}validateEdges(){for(const t of this.graph.edges??[]){if(!this.nodesById.has(t.from.nodeId))throw new ShaderGraphCompileError(`Edge references missing source node "${t.from.nodeId}"`,t.from.nodeId,t.from.port);if(!this.nodesById.has(t.to.nodeId))throw new ShaderGraphCompileError(`Edge references missing target node "${t.to.nodeId}"`,t.to.nodeId,t.to.port)}}validateNamedReroutes(){for(const t of this.graph.nodes??[])"utility.namedRerouteUsage"===t.kind&&this.namedRerouteDeclaration(t)}compileOutput(){if("postProcess"===this.graph.target)return this.compilePostProcessOutput();const t=this.graph.outputs?.color,e={color:null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):ct("#ffffff",1),transparent:Ce(this.graph)},a=this.graph.outputs?.opacity;null!=a&&(e.opacity=this.expectType(this.resolveOutputBinding(a,"opacity"),["float"],"opacity").value);const r=this.graph.outputs?.roughness;null!=r&&(e.roughness=this.expectType(this.resolveOutputBinding(r,"roughness"),["float"],"roughness").value);const u=this.graph.outputs?.metalness;null!=u&&(e.metalness=this.floatOutput(u,"metalness"));const i=this.graph.outputs?.normal;null!=i&&(e.normal=this.toVec3Output(this.resolveOutputBinding(i,"normal"),"normal"));const o=this.graph.outputs?.emissive;null!=o&&(e.emissive=this.toVec3Output(this.resolveOutputBinding(o,"emissive"),"emissive"));const n=this.graph.outputs?.ambientOcclusion;null!=n&&(e.ambientOcclusion=this.floatOutput(n,"ambientOcclusion"));const s=this.graph.outputs?.ambientOcclusionIntensity;null!=s&&(e.ambientOcclusionIntensity=this.floatOutput(s,"ambientOcclusionIntensity"));const l=this.graph.outputs?.sheenColor;null!=l&&(e.sheenColor=this.toVec3Output(this.resolveOutputBinding(l,"sheenColor"),"sheenColor"));const p=this.graph.outputs?.sheenRoughness;null!=p&&(e.sheenRoughness=this.floatOutput(p,"sheenRoughness"));const c=this.graph.outputs?.anisotropy;null!=c&&(e.anisotropy=this.floatOutput(c,"anisotropy"));const h=this.graph.outputs?.anisotropyDirection;null!=h&&(e.anisotropyDirection=this.expectType(this.resolveOutputBinding(h,"anisotropyDirection"),["vec2"],"anisotropyDirection").value);const v=this.graph.outputs?.bakedLight;null!=v&&(e.bakedLight=this.toVec3Output(this.resolveOutputBinding(v,"bakedLight"),"bakedLight"));const y=this.graph.outputs?.transform;null!=y&&"decal"!==this.graph.target&&(e.transform=this.toMat4Output(this.resolveOutputBinding(y,"transform"),"transform"));const d=this.graph.outputs?.discard;null!=d&&(e.discard=this.expectType(this.resolveOutputBinding(d,"discard"),["boolean"],"discard").value);const m=this.graph.outputs?.transparent;null!=m&&null!=m.value&&(e.transparent=Boolean(m.value));const f=this.graph.outputs?.alphaTest;return null!=f&&null!=f.value?e.alphaTest=Number(f.value):null!=this.graph.materialOptions?.alphaTest&&(e.alphaTest=this.graph.materialOptions.alphaTest),this.applyShadingModel(e)}compilePostProcessOutput(){const t=this.graph.outputs?.color,e=null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):ae(Zt),a=this.graph.outputs?.opacity;return Me(e,null!=a?this.expectType(this.resolveOutputBinding(a,"opacity"),["float"],"opacity").value:void 0)}applyShadingModel(t){const e=null!=t.opacity?function(t,e){if(t instanceof h)return ct(kt(t,t,t),e);if(t instanceof x)return ct(kt(t.x,t.y,0),e);if(t instanceof S)return ct(t.rgb,t.w.multiply(e));return ct(t,e)}(t.color,t.opacity):t.color;switch(this.graph.shadingModel??"standard"){case"standard":{const a={color:Be(e),roughness:t.roughness??R(.5),...null!=t.metalness?{metalness:t.metalness}:{},..."decal"===this.graph.target?{normal:st(me(Ut.normalMatrix).multiplyVec(Se))}:{},...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:$e(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.sheenColor?{sheenColor:t.sheenColor.rgb}:{},...null!=t.sheenRoughness?{sheenRoughness:t.sheenRoughness}:{},...null!=t.anisotropy?{anisotropy:t.anisotropy}:{},...null!=t.anisotropyDirection?{anisotropyDirection:t.anisotropyDirection}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:bt(a)}}case"toon":{const a={color:Be(e),...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:$e(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:Ot(a)}}case"unlit":return{...t,color:e}}}compileNode(t){const e=this.compiled.get(t);if(null!=e)return e;const a=this.nodesById.get(t);if(null==a)throw new ShaderGraphCompileError(`Missing shader graph node "${t}"`,t);if(null==ye[a.kind])throw new ShaderGraphCompileError(`Unsupported shader graph node "${a.kind}"`,a.id);if(this.compiling.has(t))throw new ShaderGraphCompileError(`Shader graph contains a cycle involving node "${t}"`,t);this.compiling.add(t);try{const e=this.compileNodeInternal(a);return this.compiled.set(t,e),e}finally{this.compiling.delete(t)}}compileNodeInternal(t){switch(t.kind){case"input.parameter":return this.output(t,this.compileParameterNode(t));case"input.slider":return this.output(t,{value:{type:"float",value:R(qe(ze(t,"value",.5)))}});case"constant.boolean":return this.output(t,{value:{type:"boolean",value:U(Boolean(ke(t,"value",!1)))}});case"constant.float":return this.output(t,{value:{type:"float",value:R(ze(t,"value",0))}});case"constant.vec2":return this.output(t,{value:{type:"vec2",value:We(ke(t,"value",[0,0]))}});case"constant.vec3":return this.output(t,{value:{type:"vec3",value:He(ke(t,"value",[0,0,0]))}});case"constant.rgba":return this.output(t,{value:{type:"rgba",value:Ye(ke(t,"value","#ffffff"),ze(t,"alpha",1))}});case"builtin.uv":{const e=this.defaultUV();return this.output(t,{value:{type:"vec2",value:!0===ke(t,"flipY",!1)?$t(e.x,jt(e.y)):e},u:{type:"float",value:e.x},v:{type:"float",value:e.y}})}case"builtin.screenUv":return this.output(t,{value:{type:"vec2",value:Zt}});case"builtin.color":{const e=E(M.color);return this.output(t,{value:{type:"rgba",value:e},rgb:{type:"rgb",value:e.rgb},r:{type:"float",value:e.r},g:{type:"float",value:e.g},b:{type:"float",value:e.b},a:{type:"float",value:e.a}})}case"builtin.position":{const e=E(M.position);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.worldPosition":{const e=E(Nt.worldPosition);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.objectPosition":{let e=Ut.instanceMatrix.multiplyVec(zt(0,0,0,1));e=J("USE_BATCHING",e,t=>W.multiplyVec(t));const a=E(Ut.modelMatrix.multiplyVec(e).xyz);return this.output(t,{value:{type:"vec3",value:a},x:{type:"float",value:a.x},y:{type:"float",value:a.y},z:{type:"float",value:a.z}})}case"builtin.viewDir":{const e=E(Nt.viewDir);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.normal":{const e=E(M.normal);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.time":return this.output(t,{value:{type:"float",value:It.elapsed}});case"builtin.camera":{const e=Gt(te),a=Gt(ee),r=Ut.cameraPosition;return this.output(t,{position:{type:"vec3",value:r},x:{type:"float",value:r.x},y:{type:"float",value:r.y},z:{type:"float",value:r.z},near:{type:"float",value:e},far:{type:"float",value:a}})}case"builtin.viewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.viewMatrix}});case"builtin.projectionMatrix":return this.output(t,{value:{type:"mat4",value:Ut.projectionMatrix}});case"builtin.modelViewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.modelViewMatrix}});case"builtin.particle":return this.output(t,{energy:{type:"float",value:ot.energy},color:{type:"rgb",value:ot.color},opacity:{type:"float",value:ot.opacity},time:{type:"float",value:ot.time}});case"math.add":case"math.subtract":case"math.multiply":case"math.divide":return this.output(t,{value:this.compileBinaryMath(t)});case"math.oneMinus":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:e.type,value:jt(e.value)}})}case"math.abs":return this.output(t,{value:this.compileUnaryMath(t,T)});case"math.sign":return this.output(t,{value:this.compileUnaryMath(t,dt)});case"math.floor":return this.output(t,{value:this.compileUnaryMath(t,q)});case"math.ceil":return this.output(t,{value:this.compileUnaryMath(t,B)});case"math.fract":return this.output(t,{value:this.compileUnaryMath(t,F)});case"math.sin":return this.output(t,{value:this.compileUnaryMath(t,mt)});case"math.cos":return this.output(t,{value:this.compileUnaryMath(t,z)});case"math.tan":return this.output(t,{value:this.compileUnaryMath(t,St)});case"math.asin":return this.output(t,{value:this.compileUnaryMath(t,O)});case"math.acos":return this.output(t,{value:this.compileUnaryMath(t,I)});case"math.atan":return this.output(t,{value:this.compileUnaryMath(t,N)});case"math.atan2":return this.output(t,{value:this.compileAtan2(t)});case"math.radians":return this.output(t,{value:this.compileUnaryMath(t,pt)});case"math.degrees":return this.output(t,{value:this.compileUnaryMath(t,P)});case"math.sqrt":return this.output(t,{value:this.compileUnaryMath(t,gt)});case"math.inverseSqrt":return this.output(t,{value:this.compileUnaryMath(t,_)});case"math.exp":return this.output(t,{value:this.compileUnaryMath(t,D)});case"math.exp2":return this.output(t,{value:this.compileUnaryMath(t,L)});case"math.log":return this.output(t,{value:this.compileUnaryMath(t,Z)});case"math.log2":return this.output(t,{value:this.compileUnaryMath(t,tt)});case"math.saturate":return this.output(t,{value:this.compileUnaryMath(t,vt)});case"math.length":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:"float",value:Q(e.value)}})}case"math.normalize":return this.output(t,{value:this.compileUnaryMath(t,st)});case"math.clamp":{const e=this.expectNumeric(this.input(t,"value")),a=this.expectNumeric(this.input(t,"min",{type:"float",value:R(0)})),r=this.expectNumeric(this.input(t,"max",{type:"float",value:R(1)}));return this.output(t,{value:{type:e.type,value:$(e.value,a.value,r.value)}})}case"math.min":return this.output(t,{value:this.compileBinaryFunction(t,rt)});case"math.max":return this.output(t,{value:this.compileBinaryFunction(t,at)});case"math.pow":return this.output(t,{value:this.compileBinaryFunction(t,lt)});case"math.mod":return this.output(t,{value:this.compileBinaryFunction(t,nt)});case"math.step":return this.output(t,{value:this.compileBinaryFunction(t,wt,!0)});case"math.smoothstep":{const e=this.expectNumeric(this.input(t,"edge0",{type:"float",value:R(0)})),a=this.expectNumeric(this.input(t,"edge1",{type:"float",value:R(1)})),r=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:r.type,value:ft(e.value,a.value,r.value)}})}case"math.mix":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b")),r=this.expectNumeric(this.input(t,"t",{type:"float",value:R(.5)})),u=je(e.type,a.type,t.id);return this.output(t,{value:{type:u,value:ut(e.value,a.value,r.value)}})}case"math.remap":{const e=this.expectType(this.input(t,"value"),["float"],t.id,"value").value,a=this.floatInput(t,"inMin",-1),r=this.floatInput(t,"inMax",1),u=this.floatInput(t,"outMin",0),i=this.floatInput(t,"outMax",1);return this.output(t,{value:{type:"float",value:Lt(e,a,r,u,i)}})}case"math.select":{const e=this.boolInput(t,"condition",!1),a=this.expectNumeric(this.input(t,"a")),r=this.expectNumeric(this.input(t,"b")),u=je(a.type,r.type,t.id);return this.output(t,{value:{type:u,value:yt(e,a.value,r.value)}})}case"math.reflect":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal");return this.output(t,{value:{type:e.type,value:fe(e.value,a.value)}})}case"math.refract":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal"),r=this.floatInput(t,"ior",1.5);return this.output(t,{value:{type:e.type,value:ge(e.value,a.value,r)}})}case"math.derivative":{const e=this.expectNumeric(this.input(t,"value")),a=String(ke(t,"mode","fwidth"));let r;return r="dFdx"===a?be(e.value):"dFdy"===a?xe(e.value):we(e.value),this.output(t,{value:{type:e.type,value:r}})}case"layer.mixPainted":return this.output(t,{value:this.compilePaintedLayerMix(t)});case"math.dot":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return je(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:j(e.value,a.value)}})}case"math.distance":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return je(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:A(e.value,a.value)}})}case"math.cross":{const e=this.expectType(this.input(t,"a"),["vec3","rgb"],t.id,"a"),a=this.expectType(this.input(t,"b"),["vec3","rgb"],t.id,"b");return this.output(t,{value:{type:"vec3",value:V(e.value,a.value)}})}case"compare.greaterThan":case"compare.greaterThanOrEqual":case"compare.lessThan":case"compare.lessThanOrEqual":case"compare.equal":case"compare.notEqual":return this.output(t,{value:{type:"boolean",value:this.compileComparison(t)}});case"boolean.not":{const e=this.boolInput(t,"value",!1);return this.output(t,{value:{type:"boolean",value:yt(e,U(!1),U(!0))}})}case"boolean.and":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"and")}});case"boolean.or":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"or")}});case"compose.vec2":return this.output(t,{value:{type:"vec2",value:$t(this.floatInput(t,"x",0),this.floatInput(t,"y",0))}});case"compose.vec3":return this.output(t,{value:{type:"vec3",value:kt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0))}});case"compose.vec4":return this.output(t,{value:{type:"vec4",value:zt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0),this.floatInput(t,"w",0))}});case"compose.rgba":return this.output(t,{value:{type:"rgba",value:zt(this.floatInput(t,"r",1),this.floatInput(t,"g",1),this.floatInput(t,"b",1),this.floatInput(t,"a",1))}});case"decompose.component":{const e=this.expectNumeric(this.input(t,"value")),a=String(ke(t,"component","x"));return this.output(t,{value:{type:"float",value:Le(e,a,t.id)}})}case"decompose.split":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,function(t,e){const a={},r=(r,u)=>{a[r]={type:"float",value:Le(t,u,e)}};switch(t.type){case"vec2":return r("x","x"),r("y","y"),r("u","x"),r("v","y"),a;case"vec3":return r("x","x"),r("y","y"),r("z","z"),a;case"rgb":return r("r","r"),r("g","g"),r("b","b"),r("x","x"),r("y","y"),r("z","z"),a;case"vec4":return r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"rgba":return r("r","r"),r("g","g"),r("b","b"),r("a","a"),r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"float":return a.x={type:"float",value:t.value},a}}(e,t.id))}case"color.gradient":{const e=this.expectType(this.input(t,"t",{type:"float",value:R(.5)}),["float"],t.id,"t"),a=H(function(t){const e=ke(t,"stops",[]);if(!Array.isArray(e))return[];const a=e.map((t,a)=>{if(null==t||"object"!=typeof t||Array.isArray(t))return;const r=t,u="string"==typeof r.color?r.color:"#ffffff";return{position:Fe(r.position,Je(a,e.length)),color:u,alpha:Fe(r.alpha,1)}}).filter(t=>null!=t);return a.length>0?a:[]}(t)).sample(e.value);return this.output(t,{value:{type:"rgba",value:a}})}case"utility.curve":{const e=this.expectType(this.input(t,"t",{type:"float",value:R(.5)}),["float"],t.id,"t"),a=ke(t,"curve","Linear"),r=K(a,e.value)??Y(Te.decode(a)).sample(e.value);return this.output(t,{value:{type:"float",value:r}})}case"utility.namedRerouteDeclaration":return this.output(t,{value:this.input(t,"value")});case"utility.namedRerouteUsage":{const e=this.compileNode(this.namedRerouteDeclaration(t).id);return this.output(t,{value:e.outputs.value})}case"color.hueShift":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"shift",0),i=Rt(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:zt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.blend":{const e=this.expectType(this.input(t,"base"),["rgba","rgb","vec4","vec3"],t.id,"base"),a=this.expectType(this.input(t,"blend"),["rgba","rgb","vec4","vec3"],t.id,"blend"),r=String(ke(t,"mode","multiply")),u=e.value,i=a.value,o="rgba"===e.type||"vec4"===e.type?u.rgb??u.xyz:u,n="rgba"===a.type||"vec4"===a.type?i.rgb??i.xyz:i;let s=qt(o,n,r);if("rgba"===a.type||"vec4"===a.type){const t=i.a??i.w;s=ut(o,s,t)}if("rgba"===e.type||"vec4"===e.type){const a=u.a??u.w;return this.output(t,{value:{type:e.type,value:zt(s,a)}})}return this.output(t,{value:{type:e.type,value:s}})}case"color.desaturate":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"fraction",1),i=Ft(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:zt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.unpackNormal":{const e=this.expectType(this.input(t,"color"),["vec3","vec4","rgb","rgba"],t.id,"color"),a=this.floatInput(t,"scale",1),r=this.optionalInput(t,"normal");return this.output(t,{value:{type:"vec3",value:k(e.value,a,r?this.expectType(r,["vec3"],t.id,"normal").value:void 0)}})}case"texture.sampler2d":{const e=this.input(t,"texture");return this.output(t,{value:this.toSampler(e,t.id)})}case"texture.sample2d":{const e=this.toSampler(this.input(t,"sampler"),t.id),a=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),r=e.value.sample(a.value);return this.output(t,{rgba:{type:"rgba",value:r},rgb:{type:"rgb",value:r.rgb},r:{type:"float",value:r.r},g:{type:"float",value:r.g},b:{type:"float",value:r.b},a:{type:"float",value:r.a}})}case"texture.triplanarMapping":{const e=this.input(t,"sampler"),a=this.toSampler(e,t.id),r=this.expectType(this.input(t,"scale",{type:"float",value:R(1)}),["float"],t.id,"scale"),u=this.expectType(this.input(t,"normal",{type:"vec3",value:Bt.normal}),["vec3"],t.id,"normal"),i=this.expectType(this.input(t,"position",{type:"vec3",value:Bt.position}),["vec3"],t.id,"position"),o=Ct(a.value,r.value,u.value,i.value);return this.output(t,{rgba:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a}})}case"scene.sampleColor":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:Zt}),["vec2"],t.id,"uv"),a=ae(e.value);return this.output(t,{rgba:{type:"rgba",value:a},rgb:{type:"rgb",value:a.rgb},r:{type:"float",value:a.r},g:{type:"float",value:a.g},b:{type:"float",value:a.b},a:{type:"float",value:a.a}})}case"scene.sampleDepth":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:Zt}),["vec2"],t.id,"uv");return this.output(t,{depth:{type:"float",value:Qt(e.value)},linearEyeDepth:{type:"float",value:Xt(e.value)}})}case"scene.fragmentDepth":return this.output(t,{linearEyeDepth:{type:"float",value:Kt}});case"transform.translate":{const e=this.expectType(this.input(t,"offset",{type:"vec3",value:kt(0,0,0)}),["vec3","rgb"],t.id,"offset");return this.output(t,{value:{type:"mat4",value:Mt(e.value)}})}case"transform.scale":{const e=this.expectType(this.input(t,"scale",{type:"vec3",value:kt(1,1,1)}),["vec3","rgb"],t.id,"scale").value;return this.output(t,{value:{type:"mat4",value:xt(e.x,e.y,e.z)}})}case"transform.rotateAxis":{const e=this.expectType(this.input(t,"axis",{type:"vec3",value:kt(0,1,0)}),["vec3","rgb"],t.id,"axis"),a=this.expectType(this.input(t,"angle",{type:"float",value:R(0)}),["float"],t.id,"angle");return this.output(t,{value:{type:"mat4",value:le(e.value,a.value)}})}case"uv.rotate":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"angle",{type:"float",value:R(0)}),["float"],t.id,"angle").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value;return this.output(t,{value:{type:"vec2",value:De(e,a,r)}})}case"uv.twirl":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"strength",{type:"float",value:R(1)}),["float"],t.id,"strength").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,u=this.expectType(this.input(t,"offset",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"offset").value;return this.output(t,{value:{type:"vec2",value:Et(e,a,r,u)}})}case"uv.radial":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=Dt(e.subtractScalar(.5));return this.output(t,{coords:{type:"vec2",value:a.coords},radius:{type:"float",value:a.radius},angle:{type:"float",value:a.angle}})}case"uv.bulge":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,r=this.expectType(this.input(t,"power",{type:"float",value:R(1)}),["float"],t.id,"power").value;return this.output(t,{value:{type:"vec2",value:G(e,a,r)}})}case"uv.flipbook":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"columns",ze(t,"columns",1)),r=this.floatInput(t,"rows",ze(t,"rows",1)),u=this.floatInput(t,"fps",ze(t,"fps",60)),i=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time").value,o=String(ke(t,"mode","clamp"));return this.output(t,{value:{type:"vec2",value:pe(e,a,r,i,u,o)}})}case"uv.pom":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.input(t,"heightMap"),r=this.toSampler(a,t.id).value,u=this.floatInput(t,"heightScale",.05),i=ze(t,"minLayers",8),o=ze(t,"maxLayers",24);return this.output(t,{value:{type:"vec2",value:ce(e,r,u,i,o)}})}case"shape.rectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:_t(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5))}})}case"shape.roundedRectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:Wt(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5),this.floatInput(t,"radius",.1))}})}case"noise.simplex":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new ne(e.multiplyScalar(a))}})}case"noise.voronoi2d":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new se(e.multiplyScalar(a))}})}case"effect.fresnel":return this.output(t,{value:{type:"float",value:E(Yt(this.floatInput(t,"power",1)))}});case"effect.edgeDepth":{const e=this.floatInput(t,"power",1);return this.output(t,{value:{type:"float",value:Ht(e)}})}case"effect.depthFade":{const e=this.floatInput(t,"distance",1);return this.output(t,{value:{type:"float",value:Jt(e)}})}case"util.panner":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"coord"),a=this.expectType(this.input(t,"speed",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"speed"),r=this.expectType(this.input(t,"tile",{type:"vec2",value:$t(1,1)}),["vec2"],t.id,"tile"),u=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time");return this.output(t,{value:{type:"vec2",value:e.value.multiply(r.value).add(a.value.multiplyScalar(u.value))}})}}}compileParameterNode(t){const e=String(ke(t,"parameter","")),a=this.graph.parameters?.find(t=>t.name===e||t.id===e);if(null==a)throw new ShaderGraphCompileError(`Parameter "${e}" does not exist`,t.id);const r=de(a.type),u={type:r,value:Pe(this.options.parameters?.[a.name]??a.defaultValue,r,a.name)};if("sampler2d"!==r)return{value:u};const i=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),o=u.value.sample(i.value);return{value:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a},sampler:u}}compileBinaryMath(t){const e=this.expectBinaryMathValue(this.input(t,"a")),a=this.expectBinaryMathValue(this.input(t,"b")),r=t.kind.split(".")[1];if("mat4"===e.type||"mat4"===a.type)return function(t,e,a,r){if("mat4"===t.type&&"mat4"===e.type&&"divide"!==a)return{type:"mat4",value:Ae(t.value,e.value,a,r)};if("mat4"===t.type&&"float"===e.type&&("multiply"===a||"divide"===a))return{type:"mat4",value:Ae(t.value,e.value,a,r)};if("float"===t.type&&"mat4"===e.type&&"multiply"===a)return{type:"mat4",value:Ae(e.value,t.value,a,r)};if("mat4"===t.type&&"vec4"===e.type&&"multiply"===a)return{type:"vec4",value:t.value.multiplyVec(e.value)};throw new ShaderGraphCompileError(`Cannot ${a} ${t.type} and ${e.type}`,r)}(e,a,r,t.id);if(e.type===a.type)return{type:e.type,value:Ae(e.value,a.value,r,t.id)};if("float"===e.type&&"float"!==a.type&&"multiply"===r)return{type:a.type,value:Ae(a.value,e.value,r,t.id)};if("float"!==e.type&&"float"===a.type)return{type:e.type,value:Ae(e.value,a.value,r,t.id)};throw new ShaderGraphCompileError(`Cannot ${r} ${e.type} and ${a.type}`,t.id)}expectBinaryMathValue(t){if(!Re(t.type)&&"mat4"!==t.type)throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}compileUnaryMath(t,e){const a=this.expectNumeric(this.input(t,"value"));return{type:a.type,value:e(a.value)}}compileAtan2(t){const e=this.expectNumeric(this.input(t,"y")),a=this.expectNumeric(this.input(t,"x"));return{type:function(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}(e.type,a.type,t.id),value:C(e.value,a.value)}}compileBinaryFunction(t,e,a=!1){const r=this.expectNumeric(this.input(t,"a")),u=this.expectNumeric(this.input(t,"b"));return{type:a&&"float"===u.type?r.type:je(r.type,u.type,t.id),value:e(r.value,u.value)}}compilePaintedLayerMix(t){const e=this.expectNumeric(this.input(t,"base")),a=[e.value],r=[Vt(0)];let u=e.type;for(let e=1;e<=8;e++){const i=this.optionalInput(t,`layer${e}`);if(null==i)continue;const o=this.expectNumeric(i);u=je(u,o.type,t.id),a.push(o.value),r.push(Vt(e))}return 1===a.length?e:{type:u,value:it({layerColors:a,layerWeights:r,enableNoise:Boolean(ke(t,"enableNoise",!0)),noiseScale:this.floatInput(t,"noiseScale",ze(t,"noiseScale",.1)),noiseAmount:this.floatInput(t,"noiseAmount",ze(t,"noiseAmount",.5)),decay:this.floatInput(t,"softness",ze(t,"softness",.3)),mode:"hard"===String(ke(t,"mode","soft"))?X.hard:X.soft})}}defaultUV(){return"trail"===this.graph.target?oe:"decal"===this.graph.target?ue:E(M.uv)}namedRerouteDeclaration(t){const e=String(t.params?.declarationId??"");if(0===e.length)throw new ShaderGraphCompileError("Named reroute usage is missing a declaration",t.id);const a=this.nodesById.get(e);if(null==a)throw new ShaderGraphCompileError(`Named reroute declaration "${e}" does not exist`,t.id);if("utility.namedRerouteDeclaration"!==a.kind)throw new ShaderGraphCompileError(`Node "${e}" is not a named reroute declaration`,t.id);return a}input(t,e,a){const r=t.inputs?.[e];if(null!=r)return this.resolveInput(r,t.id,e);const u=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);if(null!=u)return this.resolveSocket(u.from,t.id,e);if(null!=a)return a;const i=this.inlineLiteralFallback(t,e);if(null!=i)return i;throw new ShaderGraphCompileError(`Missing input "${e}"`,t.id,e)}optionalInput(t,e){const a=t.inputs?.[e];if(null!=a)return this.resolveInput(a,t.id,e);const r=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);return null!=r?this.resolveSocket(r.from,t.id,e):void 0}floatInput(t,e,a){return this.expectType(this.input(t,e,{type:"float",value:R(a)}),["float"],t.id,e).value}boolInput(t,e,a){return this.expectType(this.input(t,e,{type:"boolean",value:U(a)}),["boolean"],t.id,e).value}compileComparison(t){const e=this.expectType(this.input(t,"a"),["float"],t.id,"a").value,a=this.expectType(this.input(t,"b"),["float"],t.id,"b").value;switch(t.kind){case"compare.greaterThan":return e.gt(a);case"compare.greaterThanOrEqual":return e.gte(a);case"compare.lessThan":return e.lt(a);case"compare.lessThanOrEqual":return e.lte(a);case"compare.equal":return e.equals(a);case"compare.notEqual":return e.notEquals(a)}throw new ShaderGraphCompileError(`Unsupported comparison node "${t.kind}"`,t.id)}compileBooleanBinary(t,e){const a=this.boolInput(t,"a",!1),r=this.boolInput(t,"b",!1);return"and"===e?a.and(r):a.or(r)}resolveOutputBinding(t,e){if(null!=t.input)return this.resolveSocket(t.input,void 0,e);if(void 0!==t.value)return Ve(t.value);throw new ShaderGraphCompileError(`Output "${e}" is missing an input or value`)}floatOutput(t,e){return this.expectType(this.resolveOutputBinding(t,e),["float"],e).value}resolveInput(t,e,a){return function(t){return null!=t.nodeId}(t)?this.resolveSocket(t,e,a):Ve(t.value,t.valueType)}inlineLiteralFallback(t,e){const a=ye[t.kind]?.inputs.find(t=>t.name===e);if(null==a)return;const r=ve(t.kind,a),u=he(t.kind,a);return null!=r&&void 0!==u?Ve(u,r):void 0}resolveSocket(t,e,a){const r=this.compileNode(t.nodeId).outputs[t.port];if(null==r)throw new ShaderGraphCompileError(`Node "${t.nodeId}" does not have output "${t.port}"`,e??t.nodeId,a??t.port);return r}expectType(t,e,a,r){if(!e.includes(t.type))throw new ShaderGraphCompileError(`Expected ${e.join(" or ")} but got ${t.type}`,a,r);return t}expectNumeric(t){if(!Re(t.type))throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}toSampler(t,e){if("sampler2d"===t.type)return t;if("texture2d"===t.type){const a=t.value;if(null==a)throw new ShaderGraphCompileError("Texture input is empty",e);return{type:"sampler2d",value:Tt(a)}}throw new ShaderGraphCompileError(`Expected texture2d or sampler2d but got ${t.type}`,e)}toColorOutput(t){switch(t.type){case"float":case"vec2":case"vec3":case"vec4":case"rgb":case"rgba":return t.value;case"boolean":{const e=yt(t.value,R(1),R(0));return ct(kt(e,e,e),1)}case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be used as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} must be sampled before it can be used as color`)}}toVec3Output(t,e){if("vec3"===t.type||"rgb"===t.type)return t.value;if("vec4"===t.type||"rgba"===t.type)return t.value.xyz;throw new ShaderGraphCompileError(`Output "${e}" expects vec3/rgb but got ${t.type}`)}toMat4Output(t,e){if("mat4"===t.type)return t.value;throw new ShaderGraphCompileError(`Output "${e}" expects mat4 but got ${t.type}`)}output(t,e){return{node:t,outputs:e}}}export function compileShaderGraph(t,e={}){return new ShaderGraphCompiler(t,e).compile()}export function compileShaderGraphPreview(t,e,a={}){if(null==e)return compileShaderGraph(t,a).output;const r=new ShaderGraphCompiler(t,a).compileNode(e),u=Object.values(r.outputs)[0];if(null==u)throw new ShaderGraphCompileError(`Node "${e}" has no previewable output`,e);return{color:Ge(u),transparent:"rgba"===u.type||"vec4"===u.type}}export function buildShaderGraphMaterial(t,a={}){if("postProcess"===t.target)return buildShaderGraphPostProcessMaterial(t,a);const r=function(t,e,a){const r=a.alphaTest??t.alphaTest??e.materialOptions?.alphaTest;return null!=r?{...t,alphaTest:r}:t}(null!=a.previewNodeId?compileShaderGraphPreview(t,a.previewNodeId,a):compileShaderGraph(t,a).output,t,a);if("sprite"===t.target)return new Pt({color:r.color,discard:r.discard,alphaTest:r.alphaTest,transparent:r.transparent??!0,position:At(new b("rotation",0),new b("screenSpaceSize",0)),uniforms:{color:{value:new e(16777215)}}});if("trail"===t.target){const{position:e}=ie.getTrailShaderNodes(a.trailBillboard??!1),u=new y({...r,position:e});return ie.applyTrailShaderParameters(u),Ee(u,t),u}if("decal"===t.target){const e=null!=r.discard?re.or(r.discard):re,a=new y({...r,transparent:!1,discard:e});return a.userData.isDecal=!0,Ee(a,t),a}const u=new y({transparent:!1,...r});return Ee(u,t),u}export function buildShaderGraphPostProcessMaterial(t,e={}){const a=null!=e.previewNodeId?Me(compileShaderGraphPreview(t,e.previewNodeId,e).color):compileShaderGraph(t,e).output,r=new y({color:a.color,transparent:!1,fog:!1,lights:!1,outputEncoding:!1});return r.depthWrite=!1,r.depthTest=!1,r.toneMapped=!1,r.userData.isPostProcessShaderGraph=!0,r}export function buildShaderGraphInlinePreviewMaterial(t,e,a={}){const r=compileShaderGraphPreview({...t,target:"surface"},e,a),u=new y({color:r.color,transparent:r.transparent??!1,fog:!1,lights:!1});return u.depthWrite=!1,u.depthTest=!1,u.toneMapped=!1,u}function Me(t,e){const a=ae(Zt),r=Gt("hology_post_process_weight",1),u=vt(null!=e?r.multiply(e):r);return{color:ut(a.rgb,Ne(t),u),transparent:!1,...null!=e?{opacity:e}:{}}}function Ne(t){return t instanceof h?kt(t,t,t):t instanceof x?kt(t.x,t.y,0):t instanceof S?t.xyz:t}export function shaderGraphMaterialSideToThree(e){switch(e){case"back":return t;case"double":return r;default:return u}}function Ce(t){return"decal"!==t.target&&(t.materialOptions?.transparent??"sprite"===t.target)}function Ee(t,e){"surface"===e.target&&(t.side=shaderGraphMaterialSideToThree(e.materialOptions?.side)),null!=e.materialOptions?.transparent&&(t.transparent=e.materialOptions.transparent),null!=e.materialOptions?.bloom&&(t.userData.hasBloom=e.materialOptions.bloom)}function Ge(t){switch(t.type){case"float":return Ue(t.value);case"vec2":{const e=t.value;return ct(kt(e.x,e.y,0),1)}case"vec3":case"rgb":return ct(t.value,1);case"vec4":case"rgba":return t.value;case"boolean":return Ue(yt(t.value,R(1),R(0)));case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be previewed as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} nodes require a sampled output to preview`)}}function Ue(t){return ct(kt(t,t,t),1)}function Be(t){return t instanceof h?kt(t,t,t).rgb:t instanceof x?kt(t.x,t.y,0).rgb:t}function $e(t){return t.rgb}function ke(t,e,a){const r=t.params?.[e];return void 0===r?a:r}function ze(t,e,a){const r=ke(t,e,a);return"number"==typeof r?r:Number(r??a)}function Ve(t,e){if(null!=(a=t)&&"object"==typeof a&&!Array.isArray(a)&&"value"in a)return Ve(t.value,t.valueType??e);var a;const r=e??function(t){if("boolean"==typeof t)return"boolean";if("number"==typeof t)return"float";if(Array.isArray(t))return 2===t.length?"vec2":3===t.length?"vec3":16===t.length?"mat4":"vec4";return"string"==typeof t?"rgb":"float"}(t);return{type:r,value:Pe(t,r,"literal")}}function Pe(t,a,r){switch(a){case"boolean":return t instanceof c?t:U(Boolean(t));case"float":return t instanceof h?t:R(Fe(t,0));case"vec2":return t instanceof x?t:We(t);case"vec3":return t instanceof w?t:He(t);case"vec4":return t instanceof S?t:function(t){const[e,a,r,u]=_e(t,4,1);return zt(e,a,r,u)}(t);case"mat4":return t instanceof v?t:function(t){if(t instanceof i)return et(t);const e=new i;Array.isArray(t)&&16===t.length&&e.fromArray(t.map(t=>Fe(t,0)));return et(e)}(t);case"rgb":return t instanceof d?t:function(t){if("string"==typeof t||"number"==typeof t||t instanceof e)return ht(t);const[a,r,u]=_e(t,3);return kt(a,r,u).rgb}(t);case"rgba":return t instanceof m||t instanceof S?t:Ye(t);case"texture2d":return t;case"sampler2d":return function(t){const e=t;return t instanceof f||t instanceof g||"function"==typeof e?.isSampler2D||!0===e?.isSampler2D}(t)?t:t instanceof n||!0===t?.isTexture?Tt(t):(Oe.has(r)||(Oe.add(r),console.warn(`Shader graph parameter "${r}" is missing a texture value; using a 1x1 white fallback texture.`)),Tt(Ie))}}function Ae(t,e,a,r){const u=`${a}Scalar`;if(e instanceof h&&"function"==typeof t[u])return t[u](e);if("function"==typeof t[a])return t[a](e);throw new ShaderGraphCompileError(`Node does not support ${a}`,r)}function je(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";if("float"===t&&Re(e))return e;if("float"===e&&Re(t))return t;throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}function De(t,e,a){const r=t.subtract(a),u=mt(e),i=z(e);return $t(i.multiply(r.x).subtract(u.multiply(r.y)).add(a.x),u.multiply(r.x).add(i.multiply(r.y)).add(a.y))}function Le(t,e,a){const r=t.value["u"===e?"x":"v"===e?"y":e];if(r instanceof h)return r;throw new ShaderGraphCompileError(`Component "${e}" is not available on ${t.type}`,a)}function Re(t){return"float"===t||"vec2"===t||"vec3"===t||"vec4"===t||"rgb"===t||"rgba"===t}function qe(t){return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function Fe(t,e){if("number"==typeof t)return t;if("string"==typeof t){const a=parseFloat(t);return Number.isFinite(a)?a:e}return"boolean"==typeof t?t?1:0:e}function _e(t,a,r=0){if(Array.isArray(t))return Array.from({length:a},(e,a)=>Fe(t[a],r));if(t instanceof s||t instanceof l||t instanceof p)return Array.from({length:a},(e,a)=>t.toArray()[a]??r);if(t instanceof e){const e=t.toArray();return Array.from({length:a},(t,a)=>e[a]??(3===a?1:r))}if(null!=t&&"object"==typeof t){const e=t,u=["x","y","z","w"];if(u.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>Fe(e[u[a]],r));const i=["r","g","b","a"];if(i.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>Fe(e[i[a]],3===a?1:r))}return Array.from({length:a},()=>Fe(t,r))}function We(t){const[e,a]=_e(t,2);return $t(e,a)}function He(t){const[e,a,r]=_e(t,3);return kt(e,a,r)}function Ye(t,a=1){if("string"==typeof t||"number"==typeof t||t instanceof e)return ct(t,a);if(t instanceof w)return ct(t,a);const[r,u,i,o]=_e(t,4,a);return zt(r,u,i,o)}function Je(t,e){return e<=1?0:t/(e-1)}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -4,7 +4,7 @@ export type ShaderGraphMaterialSide = 'front' | 'back' | 'double';
4
4
  export type ShaderGraphValueType = 'boolean' | 'float' | 'vec2' | 'vec3' | 'vec4' | 'mat4' | 'rgb' | 'rgba' | 'texture2d' | 'sampler2d';
5
5
  export declare const ShaderGraphParameterTypes: readonly ["float", "boolean", "vec2", "vec3", "vec4", "color", "texture"];
6
6
  export type ShaderGraphParameterType = (typeof ShaderGraphParameterTypes)[number];
7
- export type ShaderGraphNodeKind = 'input.parameter' | 'input.slider' | 'constant.boolean' | 'constant.float' | 'constant.vec2' | 'constant.vec3' | 'constant.rgba' | 'builtin.uv' | 'builtin.screenUv' | 'builtin.color' | 'builtin.position' | 'builtin.worldPosition' | 'builtin.objectPosition' | 'builtin.normal' | 'builtin.time' | 'builtin.camera' | 'builtin.viewMatrix' | 'builtin.projectionMatrix' | 'builtin.modelViewMatrix' | 'builtin.particle' | 'math.add' | 'math.subtract' | 'math.multiply' | 'math.divide' | 'math.oneMinus' | 'math.abs' | 'math.sign' | 'math.floor' | 'math.ceil' | 'math.fract' | 'math.sin' | 'math.cos' | 'math.tan' | 'math.asin' | 'math.acos' | 'math.atan' | 'math.atan2' | 'math.radians' | 'math.degrees' | 'math.sqrt' | 'math.inverseSqrt' | 'math.exp' | 'math.exp2' | 'math.log' | 'math.log2' | 'math.saturate' | 'math.length' | 'math.normalize' | 'math.clamp' | 'math.min' | 'math.max' | 'math.pow' | 'math.mod' | 'math.step' | 'math.smoothstep' | 'math.mix' | 'math.select' | 'layer.mixPainted' | 'math.dot' | 'math.distance' | 'math.cross' | 'compare.greaterThan' | 'compare.greaterThanOrEqual' | 'compare.lessThan' | 'compare.lessThanOrEqual' | 'compare.equal' | 'compare.notEqual' | 'boolean.not' | 'boolean.and' | 'boolean.or' | 'compose.vec2' | 'compose.vec3' | 'compose.vec4' | 'compose.rgba' | 'decompose.component' | 'decompose.split' | 'texture.sampler2d' | 'texture.sample2d' | 'texture.triplanarMapping' | 'scene.sampleColor' | 'scene.sampleDepth' | 'scene.fragmentDepth' | 'color.gradient' | 'utility.curve' | 'transform.translate' | 'transform.scale' | 'transform.rotateAxis' | 'uv.rotate' | 'uv.twirl' | 'uv.radial' | 'uv.bulge' | 'shape.rectangle' | 'shape.roundedRectangle' | 'noise.simplex' | 'noise.voronoi2d' | 'effect.fresnel' | 'effect.edgeDepth' | 'effect.depthFade' | 'util.panner' | 'uv.flipbook' | 'math.remap' | 'color.hueShift' | 'color.blend' | 'color.blend' | 'color.desaturate' | 'builtin.viewDir' | 'uv.pom' | 'math.reflect' | 'math.refract' | 'math.derivative' | 'color.unpackNormal';
7
+ export type ShaderGraphNodeKind = 'input.parameter' | 'input.slider' | 'constant.boolean' | 'constant.float' | 'constant.vec2' | 'constant.vec3' | 'constant.rgba' | 'builtin.uv' | 'builtin.screenUv' | 'builtin.color' | 'builtin.position' | 'builtin.worldPosition' | 'builtin.objectPosition' | 'builtin.normal' | 'builtin.time' | 'builtin.camera' | 'builtin.viewMatrix' | 'builtin.projectionMatrix' | 'builtin.modelViewMatrix' | 'builtin.particle' | 'math.add' | 'math.subtract' | 'math.multiply' | 'math.divide' | 'math.oneMinus' | 'math.abs' | 'math.sign' | 'math.floor' | 'math.ceil' | 'math.fract' | 'math.sin' | 'math.cos' | 'math.tan' | 'math.asin' | 'math.acos' | 'math.atan' | 'math.atan2' | 'math.radians' | 'math.degrees' | 'math.sqrt' | 'math.inverseSqrt' | 'math.exp' | 'math.exp2' | 'math.log' | 'math.log2' | 'math.saturate' | 'math.length' | 'math.normalize' | 'math.clamp' | 'math.min' | 'math.max' | 'math.pow' | 'math.mod' | 'math.step' | 'math.smoothstep' | 'math.mix' | 'math.select' | 'layer.mixPainted' | 'math.dot' | 'math.distance' | 'math.cross' | 'compare.greaterThan' | 'compare.greaterThanOrEqual' | 'compare.lessThan' | 'compare.lessThanOrEqual' | 'compare.equal' | 'compare.notEqual' | 'boolean.not' | 'boolean.and' | 'boolean.or' | 'compose.vec2' | 'compose.vec3' | 'compose.vec4' | 'compose.rgba' | 'decompose.component' | 'decompose.split' | 'texture.sampler2d' | 'texture.sample2d' | 'texture.triplanarMapping' | 'scene.sampleColor' | 'scene.sampleDepth' | 'scene.fragmentDepth' | 'color.gradient' | 'utility.curve' | 'utility.namedRerouteDeclaration' | 'utility.namedRerouteUsage' | 'transform.translate' | 'transform.scale' | 'transform.rotateAxis' | 'uv.rotate' | 'uv.twirl' | 'uv.radial' | 'uv.bulge' | 'shape.rectangle' | 'shape.roundedRectangle' | 'noise.simplex' | 'noise.voronoi2d' | 'effect.fresnel' | 'effect.edgeDepth' | 'effect.depthFade' | 'util.panner' | 'uv.flipbook' | 'math.remap' | 'color.hueShift' | 'color.blend' | 'color.blend' | 'color.desaturate' | 'builtin.viewDir' | 'uv.pom' | 'math.reflect' | 'math.refract' | 'math.derivative' | 'color.unpackNormal';
8
8
  export type ShaderGraphSerializableValue = null | boolean | number | string | ShaderGraphSerializableValue[] | {
9
9
  [key: string]: ShaderGraphSerializableValue;
10
10
  };
@@ -1,4 +1,4 @@
1
- export const SHADER_GRAPH_NODE_DEFINITIONS={"input.parameter":{kind:"input.parameter",label:"Parameter",category:"Inputs",inputs:[],outputs:[{name:"value",type:"dynamic"}]},"input.slider":{kind:"input.slider",label:"Slider",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.boolean":{kind:"constant.boolean",label:"Boolean",category:"Inputs",inputs:[],outputs:[{name:"value",type:"boolean"}]},"constant.float":{kind:"constant.float",label:"Float",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.vec2":{kind:"constant.vec2",label:"Vec2",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec2"}]},"constant.vec3":{kind:"constant.vec3",label:"Vec3",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec3"}]},"constant.rgba":{kind:"constant.rgba",label:"Color",category:"Inputs",inputs:[],outputs:[{name:"value",type:"rgba"}]},"builtin.uv":{kind:"builtin.uv",label:"UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"},{name:"u",type:"float"},{name:"v",type:"float"}]},"builtin.screenUv":{kind:"builtin.screenUv",label:"Screen UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"}]},"builtin.color":{kind:"builtin.color",label:"Color Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"builtin.position":{kind:"builtin.position",label:"Position Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.worldPosition":{kind:"builtin.worldPosition",label:"World Position",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.objectPosition":{kind:"builtin.objectPosition",label:"Object Position",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.normal":{kind:"builtin.normal",label:"Normal Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.particle":{kind:"builtin.particle",label:"Particle",category:"Attributes",inputs:[],outputs:[{name:"energy",type:"float"},{name:"color",type:"rgb"},{name:"opacity",type:"float"},{name:"time",type:"float"}]},"builtin.time":{kind:"builtin.time",label:"Time",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"builtin.viewDir":{kind:"builtin.viewDir",label:"View Direction",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.camera":{kind:"builtin.camera",label:"Camera",category:"Inputs",inputs:[],outputs:[{name:"position",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"near",type:"float"},{name:"far",type:"float"}]},"builtin.viewMatrix":{kind:"builtin.viewMatrix",label:"View Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"builtin.projectionMatrix":{kind:"builtin.projectionMatrix",label:"Projection Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"builtin.modelViewMatrix":{kind:"builtin.modelViewMatrix",label:"Model View Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"math.add":{kind:"math.add",label:"Add",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.subtract":{kind:"math.subtract",label:"Subtract",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.multiply":{kind:"math.multiply",label:"Multiply",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.divide":{kind:"math.divide",label:"Divide",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.oneMinus":{kind:"math.oneMinus",label:"One Minus",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.abs":e("math.abs","Abs","Math"),"math.sign":e("math.sign","Sign","Math"),"math.floor":e("math.floor","Floor","Math"),"math.ceil":e("math.ceil","Ceil","Math"),"math.fract":e("math.fract","Fract","Math"),"math.sin":e("math.sin","Sine","Trigonometry"),"math.cos":e("math.cos","Cosine","Trigonometry"),"math.tan":e("math.tan","Tangent","Trigonometry"),"math.asin":e("math.asin","Arc Sine","Trigonometry"),"math.acos":e("math.acos","Arc Cosine","Trigonometry"),"math.atan":e("math.atan","Arc Tangent","Trigonometry"),"math.atan2":{kind:"math.atan2",label:"Arc Tangent 2",category:"Trigonometry",inputs:[{name:"y",type:"dynamic"},{name:"x",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.radians":e("math.radians","Radians","Trigonometry"),"math.degrees":e("math.degrees","Degrees","Trigonometry"),"math.sqrt":e("math.sqrt","Square Root","Math"),"math.inverseSqrt":e("math.inverseSqrt","Inverse Square Root","Math"),"math.exp":e("math.exp","Exp","Math"),"math.exp2":e("math.exp2","Exp2","Math"),"math.log":e("math.log","Log","Math"),"math.log2":e("math.log2","Log2","Math"),"math.saturate":e("math.saturate","Saturate","Math"),"math.length":{kind:"math.length",label:"Length",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.normalize":e("math.normalize","Normalize","Vectors"),"math.clamp":{kind:"math.clamp",label:"Clamp",category:"Math",inputs:[{name:"value",type:"dynamic"},{name:"min",type:"dynamic",defaultValue:0},{name:"max",type:"dynamic",defaultValue:1}],outputs:[{name:"value",type:"dynamic"}]},"math.min":t("math.min","Min"),"math.max":t("math.max","Max"),"math.pow":t("math.pow","Power"),"math.mod":t("math.mod","Modulo"),"math.step":t("math.step","Step"),"math.smoothstep":{kind:"math.smoothstep",label:"Smoothstep",category:"Math",inputs:[{name:"edge0",type:"dynamic",defaultValue:0},{name:"edge1",type:"dynamic",defaultValue:1},{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.mix":{kind:"math.mix",label:"Mix",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"},{name:"t",type:"dynamic",defaultValue:.5}],outputs:[{name:"value",type:"dynamic"}]},"math.remap":{kind:"math.remap",label:"Remap",category:"Math",inputs:[{name:"value",type:"float"},{name:"inMin",type:"float",defaultValue:-1},{name:"inMax",type:"float",defaultValue:1},{name:"outMin",type:"float",defaultValue:0},{name:"outMax",type:"float",defaultValue:1}],outputs:[{name:"value",type:"float"}]},"math.reflect":{kind:"math.reflect",label:"Reflect",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.refract":{kind:"math.refract",label:"Refract",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"},{name:"ior",type:"float",defaultValue:1.5}],outputs:[{name:"value",type:"dynamic"}]},"math.derivative":{kind:"math.derivative",label:"Derivative",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.select":{kind:"math.select",label:"Select",category:"Math",inputs:[{name:"condition",type:"boolean"},{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"layer.mixPainted":{kind:"layer.mixPainted",label:"Mix Painted Layers",category:"Layers",inputs:[{name:"base",type:"dynamic"},...Array.from({length:8},(e,t)=>({name:`layer${t+1}`,label:`Layer ${t+1}`,type:"dynamic",optional:!0})),{name:"softness",type:"float",optional:!0},{name:"noiseScale",label:"Noise Scale",type:"float",optional:!0},{name:"noiseAmount",label:"Noise Amount",type:"float",optional:!0}],outputs:[{name:"value",type:"dynamic"}]},"math.dot":{kind:"math.dot",label:"Dot Product",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.distance":{kind:"math.distance",label:"Distance",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.cross":{kind:"math.cross",label:"Cross Product",category:"Vectors",inputs:[{name:"a",type:"vec3"},{name:"b",type:"vec3"}],outputs:[{name:"value",type:"vec3"}]},"compare.greaterThan":a("compare.greaterThan","Greater Than"),"compare.greaterThanOrEqual":a("compare.greaterThanOrEqual","Greater Than Or Equal"),"compare.lessThan":a("compare.lessThan","Less Than"),"compare.lessThanOrEqual":a("compare.lessThanOrEqual","Less Than Or Equal"),"compare.equal":a("compare.equal","Equal"),"compare.notEqual":a("compare.notEqual","Not Equal"),"boolean.not":{kind:"boolean.not",label:"Not",category:"Boolean",inputs:[{name:"value",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]},"boolean.and":n("boolean.and","And"),"boolean.or":n("boolean.or","Or"),"compose.vec2":{kind:"compose.vec2",label:"Compose Vec2",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"}],outputs:[{name:"value",type:"vec2"}]},"compose.vec3":{kind:"compose.vec3",label:"Compose Vec3",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}],outputs:[{name:"value",type:"vec3"}]},"compose.vec4":{kind:"compose.vec4",label:"Compose Vec4",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"w",type:"float"}],outputs:[{name:"value",type:"vec4"}]},"compose.rgba":{kind:"compose.rgba",label:"Compose RGBA",category:"Color",inputs:[{name:"r",type:"float",defaultValue:1},{name:"g",type:"float",defaultValue:1},{name:"b",type:"float",defaultValue:1},{name:"a",type:"float",defaultValue:1}],outputs:[{name:"value",type:"rgba"}]},"decompose.component":{kind:"decompose.component",label:"Component",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"decompose.split":{kind:"decompose.split",label:"Split Components",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"w",type:"float"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"},{name:"u",type:"float"},{name:"v",type:"float"}]},"color.gradient":{kind:"color.gradient",label:"Gradient",category:"Color",inputs:[{name:"t",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"rgba"}]},"utility.curve":{kind:"utility.curve",label:"Curve",category:"Utilities",inputs:[{name:"t",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"float"}]},"color.hueShift":{kind:"color.hueShift",label:"Hue Shift",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"shift",type:"float"}],outputs:[{name:"value",type:"dynamic"}]},"color.blend":{kind:"color.blend",label:"Blend Colors",category:"Color",inputs:[{name:"base",type:"dynamic"},{name:"blend",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"color.desaturate":{kind:"color.desaturate",label:"Desaturate",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"fraction",type:"float",defaultValue:1}],outputs:[{name:"value",type:"dynamic"}]},"color.unpackNormal":{kind:"color.unpackNormal",label:"Unpack Normal",category:"Textures",inputs:[{name:"color",type:"dynamic"},{name:"scale",type:"float",defaultValue:1},{name:"normal",type:"vec3",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec3"}]},"texture.sampler2d":{kind:"texture.sampler2d",label:"Sampler 2D",category:"Texture",inputs:[{name:"texture",type:"texture2d"}],outputs:[{name:"value",type:"sampler2d"}]},"texture.sample2d":{kind:"texture.sample2d",label:"Sample Texture 2D",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"texture.triplanarMapping":{kind:"texture.triplanarMapping",label:"Triplanar Mapping",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"scale",type:"float",defaultValue:1},{name:"normal",type:"vec3",inlineLiteral:!1},{name:"position",type:"vec3",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleColor":{kind:"scene.sampleColor",label:"Sample Scene Color",category:"Texture",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleDepth":{kind:"scene.sampleDepth",label:"Sample Scene Depth",category:"Texture",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"depth",type:"float"},{name:"linearEyeDepth",type:"float"}]},"scene.fragmentDepth":{kind:"scene.fragmentDepth",label:"Fragment Depth",category:"Texture",inputs:[],outputs:[{name:"linearEyeDepth",type:"float"}]},"transform.translate":{kind:"transform.translate",label:"Translate",category:"Transform",inputs:[{name:"offset",type:"vec3",defaultValue:[0,0,0]}],outputs:[{name:"value",type:"mat4"}]},"transform.scale":{kind:"transform.scale",label:"Scale",category:"Transform",inputs:[{name:"scale",type:"vec3",defaultValue:[1,1,1]}],outputs:[{name:"value",type:"mat4"}]},"transform.rotateAxis":{kind:"transform.rotateAxis",label:"Rotate Axis",category:"Transform",inputs:[{name:"axis",type:"vec3",defaultValue:[0,1,0]},{name:"angle",type:"float",defaultValue:0}],outputs:[{name:"value",type:"mat4"}]},"uv.rotate":{kind:"uv.rotate",label:"Rotate UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"angle",type:"float",defaultValue:0},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]}],outputs:[{name:"value",type:"vec2"}]},"uv.twirl":{kind:"uv.twirl",label:"Twirl UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"strength",type:"float",defaultValue:1},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]},{name:"offset",type:"vec2",optional:!0,defaultValue:[0,0]}],outputs:[{name:"value",type:"vec2"}]},"uv.radial":{kind:"uv.radial",label:"Radial UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"coords",type:"vec2"},{name:"radius",type:"float"},{name:"angle",type:"float"}]},"uv.bulge":{kind:"uv.bulge",label:"Bulge UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]},{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"vec2"}]},"uv.flipbook":{kind:"uv.flipbook",label:"Flipbook UV",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0,inlineLiteral:!1},{name:"columns",type:"float",optional:!0,defaultValue:1},{name:"rows",type:"float",optional:!0,defaultValue:1},{name:"fps",type:"float",optional:!0,defaultValue:60},{name:"time",type:"float",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec2"}]},"uv.pom":{kind:"uv.pom",label:"Parallax Occlusion",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0,inlineLiteral:!1},{name:"heightMap",type:"sampler2d"},{name:"heightScale",type:"float",optional:!0,defaultValue:.05}],outputs:[{name:"value",type:"vec2"}]},"shape.rectangle":{kind:"shape.rectangle",label:"Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"width",type:"float",defaultValue:.5},{name:"height",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"float"}]},"shape.roundedRectangle":{kind:"shape.roundedRectangle",label:"Rounded Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"width",type:"float",defaultValue:.5},{name:"height",type:"float",defaultValue:.5},{name:"radius",type:"float",defaultValue:.1}],outputs:[{name:"value",type:"float"}]},"noise.simplex":{kind:"noise.simplex",label:"Simplex Noise",category:"Noise",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"scale",type:"float",optional:!0,defaultValue:8}],outputs:[{name:"value",type:"float"}]},"noise.voronoi2d":{kind:"noise.voronoi2d",label:"Voronoi",category:"Noise",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"scale",type:"float",optional:!0,defaultValue:8}],outputs:[{name:"value",type:"float"}]},"effect.fresnel":{kind:"effect.fresnel",label:"Fresnel",category:"Effects",inputs:[{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"effect.edgeDepth":{kind:"effect.edgeDepth",label:"Edge Depth",category:"Effects",inputs:[{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"effect.depthFade":{kind:"effect.depthFade",label:"Depth Fade",category:"Effects",inputs:[{name:"distance",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"util.panner":{kind:"util.panner",label:"Panner",category:"Utilities",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"speed",type:"vec2",defaultValue:[0,0]},{name:"tile",type:"vec2",defaultValue:[1,1]},{name:"time",type:"float",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec2"}]}};export const SHADER_GRAPH_NODE_KINDS=Object.keys(SHADER_GRAPH_NODE_DEFINITIONS);function e(e,t,a){return{kind:e,label:t,category:a,inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function t(e,t){return{kind:e,label:t,category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function a(e,t){return{kind:e,label:t,category:"Comparison",inputs:[{name:"a",type:"float"},{name:"b",type:"float"}],outputs:[{name:"value",type:"boolean"}]}}function n(e,t){return{kind:e,label:t,category:"Boolean",inputs:[{name:"a",type:"boolean"},{name:"b",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]}}export function inlineLiteralTypeForPort(e,t){if(!1!==t.inlineLiteral)return"float"===t.type||"vec2"===t.type||"vec3"===t.type||"vec4"===t.type?t.type:"dynamic"===t.type&&function(e){return e.startsWith("math.")&&"math.reflect"!==e&&"math.refract"!==e}(e)?"float":void 0}export function defaultInlineLiteralValueForPort(e,t){const a=inlineLiteralTypeForPort(e,t);if(null!=a){if(void 0!==t.defaultValue)return l(t.defaultValue);if("math.multiply"===e)return 1;switch(a){case"float":return 0;case"vec2":return[0,0];case"vec3":return[0,0,0];case"vec4":return[0,0,0,1]}}}function l(e){return Array.isArray(e)?e.map(e=>l(e)):null!=e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,l(t)])):e}/*
1
+ export const SHADER_GRAPH_NODE_DEFINITIONS={"input.parameter":{kind:"input.parameter",label:"Parameter",category:"Inputs",inputs:[],outputs:[{name:"value",type:"dynamic"}]},"input.slider":{kind:"input.slider",label:"Slider",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.boolean":{kind:"constant.boolean",label:"Boolean",category:"Inputs",inputs:[],outputs:[{name:"value",type:"boolean"}]},"constant.float":{kind:"constant.float",label:"Float",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.vec2":{kind:"constant.vec2",label:"Vec2",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec2"}]},"constant.vec3":{kind:"constant.vec3",label:"Vec3",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec3"}]},"constant.rgba":{kind:"constant.rgba",label:"Color",category:"Inputs",inputs:[],outputs:[{name:"value",type:"rgba"}]},"builtin.uv":{kind:"builtin.uv",label:"UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"},{name:"u",type:"float"},{name:"v",type:"float"}]},"builtin.screenUv":{kind:"builtin.screenUv",label:"Screen UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"}]},"builtin.color":{kind:"builtin.color",label:"Color Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"builtin.position":{kind:"builtin.position",label:"Position Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.worldPosition":{kind:"builtin.worldPosition",label:"World Position",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.objectPosition":{kind:"builtin.objectPosition",label:"Object Position",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.normal":{kind:"builtin.normal",label:"Normal Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.particle":{kind:"builtin.particle",label:"Particle",category:"Attributes",inputs:[],outputs:[{name:"energy",type:"float"},{name:"color",type:"rgb"},{name:"opacity",type:"float"},{name:"time",type:"float"}]},"builtin.time":{kind:"builtin.time",label:"Time",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"builtin.viewDir":{kind:"builtin.viewDir",label:"View Direction",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.camera":{kind:"builtin.camera",label:"Camera",category:"Inputs",inputs:[],outputs:[{name:"position",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"near",type:"float"},{name:"far",type:"float"}]},"builtin.viewMatrix":{kind:"builtin.viewMatrix",label:"View Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"builtin.projectionMatrix":{kind:"builtin.projectionMatrix",label:"Projection Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"builtin.modelViewMatrix":{kind:"builtin.modelViewMatrix",label:"Model View Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"math.add":{kind:"math.add",label:"Add",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.subtract":{kind:"math.subtract",label:"Subtract",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.multiply":{kind:"math.multiply",label:"Multiply",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.divide":{kind:"math.divide",label:"Divide",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.oneMinus":{kind:"math.oneMinus",label:"One Minus",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.abs":e("math.abs","Abs","Math"),"math.sign":e("math.sign","Sign","Math"),"math.floor":e("math.floor","Floor","Math"),"math.ceil":e("math.ceil","Ceil","Math"),"math.fract":e("math.fract","Fract","Math"),"math.sin":e("math.sin","Sine","Trigonometry"),"math.cos":e("math.cos","Cosine","Trigonometry"),"math.tan":e("math.tan","Tangent","Trigonometry"),"math.asin":e("math.asin","Arc Sine","Trigonometry"),"math.acos":e("math.acos","Arc Cosine","Trigonometry"),"math.atan":e("math.atan","Arc Tangent","Trigonometry"),"math.atan2":{kind:"math.atan2",label:"Arc Tangent 2",category:"Trigonometry",inputs:[{name:"y",type:"dynamic"},{name:"x",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.radians":e("math.radians","Radians","Trigonometry"),"math.degrees":e("math.degrees","Degrees","Trigonometry"),"math.sqrt":e("math.sqrt","Square Root","Math"),"math.inverseSqrt":e("math.inverseSqrt","Inverse Square Root","Math"),"math.exp":e("math.exp","Exp","Math"),"math.exp2":e("math.exp2","Exp2","Math"),"math.log":e("math.log","Log","Math"),"math.log2":e("math.log2","Log2","Math"),"math.saturate":e("math.saturate","Saturate","Math"),"math.length":{kind:"math.length",label:"Length",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.normalize":e("math.normalize","Normalize","Vectors"),"math.clamp":{kind:"math.clamp",label:"Clamp",category:"Math",inputs:[{name:"value",type:"dynamic"},{name:"min",type:"dynamic",defaultValue:0},{name:"max",type:"dynamic",defaultValue:1}],outputs:[{name:"value",type:"dynamic"}]},"math.min":t("math.min","Min"),"math.max":t("math.max","Max"),"math.pow":t("math.pow","Power"),"math.mod":t("math.mod","Modulo"),"math.step":t("math.step","Step"),"math.smoothstep":{kind:"math.smoothstep",label:"Smoothstep",category:"Math",inputs:[{name:"edge0",type:"dynamic",defaultValue:0},{name:"edge1",type:"dynamic",defaultValue:1},{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.mix":{kind:"math.mix",label:"Mix",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"},{name:"t",type:"dynamic",defaultValue:.5}],outputs:[{name:"value",type:"dynamic"}]},"math.remap":{kind:"math.remap",label:"Remap",category:"Math",inputs:[{name:"value",type:"float"},{name:"inMin",type:"float",defaultValue:-1},{name:"inMax",type:"float",defaultValue:1},{name:"outMin",type:"float",defaultValue:0},{name:"outMax",type:"float",defaultValue:1}],outputs:[{name:"value",type:"float"}]},"math.reflect":{kind:"math.reflect",label:"Reflect",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.refract":{kind:"math.refract",label:"Refract",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"},{name:"ior",type:"float",defaultValue:1.5}],outputs:[{name:"value",type:"dynamic"}]},"math.derivative":{kind:"math.derivative",label:"Derivative",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.select":{kind:"math.select",label:"Select",category:"Math",inputs:[{name:"condition",type:"boolean"},{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"layer.mixPainted":{kind:"layer.mixPainted",label:"Mix Painted Layers",category:"Layers",inputs:[{name:"base",type:"dynamic"},...Array.from({length:8},(e,t)=>({name:`layer${t+1}`,label:`Layer ${t+1}`,type:"dynamic",optional:!0})),{name:"softness",type:"float",optional:!0},{name:"noiseScale",label:"Noise Scale",type:"float",optional:!0},{name:"noiseAmount",label:"Noise Amount",type:"float",optional:!0}],outputs:[{name:"value",type:"dynamic"}]},"math.dot":{kind:"math.dot",label:"Dot Product",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.distance":{kind:"math.distance",label:"Distance",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.cross":{kind:"math.cross",label:"Cross Product",category:"Vectors",inputs:[{name:"a",type:"vec3"},{name:"b",type:"vec3"}],outputs:[{name:"value",type:"vec3"}]},"compare.greaterThan":a("compare.greaterThan","Greater Than"),"compare.greaterThanOrEqual":a("compare.greaterThanOrEqual","Greater Than Or Equal"),"compare.lessThan":a("compare.lessThan","Less Than"),"compare.lessThanOrEqual":a("compare.lessThanOrEqual","Less Than Or Equal"),"compare.equal":a("compare.equal","Equal"),"compare.notEqual":a("compare.notEqual","Not Equal"),"boolean.not":{kind:"boolean.not",label:"Not",category:"Boolean",inputs:[{name:"value",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]},"boolean.and":n("boolean.and","And"),"boolean.or":n("boolean.or","Or"),"compose.vec2":{kind:"compose.vec2",label:"Compose Vec2",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"}],outputs:[{name:"value",type:"vec2"}]},"compose.vec3":{kind:"compose.vec3",label:"Compose Vec3",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}],outputs:[{name:"value",type:"vec3"}]},"compose.vec4":{kind:"compose.vec4",label:"Compose Vec4",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"w",type:"float"}],outputs:[{name:"value",type:"vec4"}]},"compose.rgba":{kind:"compose.rgba",label:"Compose RGBA",category:"Color",inputs:[{name:"r",type:"float",defaultValue:1},{name:"g",type:"float",defaultValue:1},{name:"b",type:"float",defaultValue:1},{name:"a",type:"float",defaultValue:1}],outputs:[{name:"value",type:"rgba"}]},"decompose.component":{kind:"decompose.component",label:"Component",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"decompose.split":{kind:"decompose.split",label:"Split Components",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"w",type:"float"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"},{name:"u",type:"float"},{name:"v",type:"float"}]},"color.gradient":{kind:"color.gradient",label:"Gradient",category:"Color",inputs:[{name:"t",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"rgba"}]},"utility.curve":{kind:"utility.curve",label:"Curve",category:"Utilities",inputs:[{name:"t",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"float"}]},"utility.namedRerouteDeclaration":{kind:"utility.namedRerouteDeclaration",label:"Named Reroute Declaration",category:"Utilities",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"utility.namedRerouteUsage":{kind:"utility.namedRerouteUsage",label:"Named Reroute Usage",category:"Utilities",inputs:[],outputs:[{name:"value",type:"dynamic"}]},"color.hueShift":{kind:"color.hueShift",label:"Hue Shift",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"shift",type:"float"}],outputs:[{name:"value",type:"dynamic"}]},"color.blend":{kind:"color.blend",label:"Blend Colors",category:"Color",inputs:[{name:"base",type:"dynamic"},{name:"blend",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"color.desaturate":{kind:"color.desaturate",label:"Desaturate",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"fraction",type:"float",defaultValue:1}],outputs:[{name:"value",type:"dynamic"}]},"color.unpackNormal":{kind:"color.unpackNormal",label:"Unpack Normal",category:"Textures",inputs:[{name:"color",type:"dynamic"},{name:"scale",type:"float",defaultValue:1},{name:"normal",type:"vec3",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec3"}]},"texture.sampler2d":{kind:"texture.sampler2d",label:"Sampler 2D",category:"Texture",inputs:[{name:"texture",type:"texture2d"}],outputs:[{name:"value",type:"sampler2d"}]},"texture.sample2d":{kind:"texture.sample2d",label:"Sample Texture 2D",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"texture.triplanarMapping":{kind:"texture.triplanarMapping",label:"Triplanar Mapping",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"scale",type:"float",defaultValue:1},{name:"normal",type:"vec3",inlineLiteral:!1},{name:"position",type:"vec3",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleColor":{kind:"scene.sampleColor",label:"Sample Scene Color",category:"Texture",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleDepth":{kind:"scene.sampleDepth",label:"Sample Scene Depth",category:"Texture",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"depth",type:"float"},{name:"linearEyeDepth",type:"float"}]},"scene.fragmentDepth":{kind:"scene.fragmentDepth",label:"Fragment Depth",category:"Texture",inputs:[],outputs:[{name:"linearEyeDepth",type:"float"}]},"transform.translate":{kind:"transform.translate",label:"Translate",category:"Transform",inputs:[{name:"offset",type:"vec3",defaultValue:[0,0,0]}],outputs:[{name:"value",type:"mat4"}]},"transform.scale":{kind:"transform.scale",label:"Scale",category:"Transform",inputs:[{name:"scale",type:"vec3",defaultValue:[1,1,1]}],outputs:[{name:"value",type:"mat4"}]},"transform.rotateAxis":{kind:"transform.rotateAxis",label:"Rotate Axis",category:"Transform",inputs:[{name:"axis",type:"vec3",defaultValue:[0,1,0]},{name:"angle",type:"float",defaultValue:0}],outputs:[{name:"value",type:"mat4"}]},"uv.rotate":{kind:"uv.rotate",label:"Rotate UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"angle",type:"float",defaultValue:0},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]}],outputs:[{name:"value",type:"vec2"}]},"uv.twirl":{kind:"uv.twirl",label:"Twirl UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"strength",type:"float",defaultValue:1},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]},{name:"offset",type:"vec2",optional:!0,defaultValue:[0,0]}],outputs:[{name:"value",type:"vec2"}]},"uv.radial":{kind:"uv.radial",label:"Radial UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"coords",type:"vec2"},{name:"radius",type:"float"},{name:"angle",type:"float"}]},"uv.bulge":{kind:"uv.bulge",label:"Bulge UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]},{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"vec2"}]},"uv.flipbook":{kind:"uv.flipbook",label:"Flipbook UV",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0,inlineLiteral:!1},{name:"columns",type:"float",optional:!0,defaultValue:1},{name:"rows",type:"float",optional:!0,defaultValue:1},{name:"fps",type:"float",optional:!0,defaultValue:60},{name:"time",type:"float",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec2"}]},"uv.pom":{kind:"uv.pom",label:"Parallax Occlusion",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0,inlineLiteral:!1},{name:"heightMap",type:"sampler2d"},{name:"heightScale",type:"float",optional:!0,defaultValue:.05}],outputs:[{name:"value",type:"vec2"}]},"shape.rectangle":{kind:"shape.rectangle",label:"Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"width",type:"float",defaultValue:.5},{name:"height",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"float"}]},"shape.roundedRectangle":{kind:"shape.roundedRectangle",label:"Rounded Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"width",type:"float",defaultValue:.5},{name:"height",type:"float",defaultValue:.5},{name:"radius",type:"float",defaultValue:.1}],outputs:[{name:"value",type:"float"}]},"noise.simplex":{kind:"noise.simplex",label:"Simplex Noise",category:"Noise",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"scale",type:"float",optional:!0,defaultValue:8}],outputs:[{name:"value",type:"float"}]},"noise.voronoi2d":{kind:"noise.voronoi2d",label:"Voronoi",category:"Noise",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"scale",type:"float",optional:!0,defaultValue:8}],outputs:[{name:"value",type:"float"}]},"effect.fresnel":{kind:"effect.fresnel",label:"Fresnel",category:"Effects",inputs:[{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"effect.edgeDepth":{kind:"effect.edgeDepth",label:"Edge Depth",category:"Effects",inputs:[{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"effect.depthFade":{kind:"effect.depthFade",label:"Depth Fade",category:"Effects",inputs:[{name:"distance",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"util.panner":{kind:"util.panner",label:"Panner",category:"Utilities",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"speed",type:"vec2",defaultValue:[0,0]},{name:"tile",type:"vec2",defaultValue:[1,1]},{name:"time",type:"float",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec2"}]}};export const SHADER_GRAPH_NODE_KINDS=Object.keys(SHADER_GRAPH_NODE_DEFINITIONS);function e(e,t,a){return{kind:e,label:t,category:a,inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function t(e,t){return{kind:e,label:t,category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function a(e,t){return{kind:e,label:t,category:"Comparison",inputs:[{name:"a",type:"float"},{name:"b",type:"float"}],outputs:[{name:"value",type:"boolean"}]}}function n(e,t){return{kind:e,label:t,category:"Boolean",inputs:[{name:"a",type:"boolean"},{name:"b",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]}}export function inlineLiteralTypeForPort(e,t){if(!1!==t.inlineLiteral)return"float"===t.type||"vec2"===t.type||"vec3"===t.type||"vec4"===t.type?t.type:"dynamic"===t.type&&function(e){return e.startsWith("math.")&&"math.reflect"!==e&&"math.refract"!==e}(e)?"float":void 0}export function defaultInlineLiteralValueForPort(e,t){const a=inlineLiteralTypeForPort(e,t);if(null!=a){if(void 0!==t.defaultValue)return l(t.defaultValue);if("math.multiply"===e)return 1;switch(a){case"float":return 0;case"vec2":return[0,0];case"vec3":return[0,0,0];case"vec4":return[0,0,0,1]}}}function l(e){return Array.isArray(e)?e.map(e=>l(e)):null!=e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,l(t)])):e}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=animation-retarget.test.d.ts.map