@hology/core 0.0.211 → 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.
- package/dist/effects/sequence/index.d.ts +1 -0
- package/dist/effects/sequence/index.js +1 -1
- package/dist/effects/sequence/sequence-action.d.ts +5 -0
- package/dist/effects/sequence/sequence-actor.d.ts +7 -0
- package/dist/effects/sequence/sequence-actor.js +1 -1
- package/dist/effects/sequence/sequence-animation-retiming.js +1 -1
- package/dist/effects/sequence/sequence-data.d.ts +9 -0
- package/dist/effects/sequence/sequence-data.js +1 -1
- package/dist/effects/sequence/sequence-player.d.ts +12 -1
- package/dist/effects/sequence/sequence-player.js +1 -1
- package/dist/effects/sequence/sequence-transform.d.ts +10 -0
- package/dist/effects/sequence/sequence-transform.js +4 -0
- package/dist/effects/sequence/sequence-value-lane.d.ts +2 -0
- package/dist/effects/sequence/sequence-value-lane.js +1 -1
- package/dist/effects/vfx/initializsers.d.ts +8 -1
- package/dist/effects/vfx/initializsers.js +1 -1
- package/dist/effects/vfx/vfx-actor.d.ts +5 -0
- package/dist/effects/vfx/vfx-actor.js +1 -1
- package/dist/effects/vfx/vfx-asset.d.ts +2 -1
- package/dist/effects/vfx/vfx-asset.js +1 -1
- package/dist/effects/vfx/vfx-collision-behaviour.js +1 -1
- package/dist/effects/vfx/vfx-defs.d.ts +10 -1
- package/dist/effects/vfx/vfx-defs.js +1 -1
- package/dist/effects/vfx/vfx-materializer.js +1 -1
- package/dist/effects/vfx/vfx-renderers.d.ts +2 -0
- package/dist/effects/vfx/vfx-renderers.js +1 -1
- package/dist/gameplay/actors/actor.d.ts +21 -1
- package/dist/gameplay/actors/actor.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -0
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-movement-like.d.ts +25 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement-like.js +4 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement-policy.d.ts +26 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement-policy.js +4 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +158 -55
- package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.d.ts +128 -0
- package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.js +4 -0
- package/dist/gameplay/actors/builtin/components/character/old-character-movement.d.ts +100 -0
- package/dist/gameplay/actors/builtin/components/character/old-character-movement.js +4 -0
- package/dist/gameplay/actors/builtin/components/index.d.ts +2 -0
- package/dist/gameplay/actors/builtin/components/index.js +1 -1
- package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +1 -0
- package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
- package/dist/gameplay/actors/builtin/components/tween-component.js +1 -1
- package/dist/gameplay/actors/builtin/navmesh-actor.d.ts +2 -0
- package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
- package/dist/gameplay/actors/builtin/trigger-volume.d.ts +3 -3
- package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
- package/dist/gameplay/actors/camera/camera-component.d.ts +1 -3
- package/dist/gameplay/actors/camera/camera-component.js +1 -1
- package/dist/gameplay/actors/camera/third-person-camera-component.d.ts +3 -0
- package/dist/gameplay/actors/camera/third-person-camera-component.js +1 -1
- package/dist/gameplay/actors/component.d.ts +3 -0
- package/dist/gameplay/actors/component.js +1 -1
- package/dist/gameplay/actors/controller/actor-controller.d.ts +16 -0
- package/dist/gameplay/actors/controller/actor-controller.js +4 -0
- package/dist/gameplay/actors/factory.d.ts +3 -0
- package/dist/gameplay/actors/factory.js +1 -1
- package/dist/gameplay/actors/index.d.ts +4 -0
- package/dist/gameplay/actors/index.js +1 -1
- package/dist/gameplay/actors/internal/component-init.js +1 -1
- package/dist/gameplay/actors/type-registry.d.ts +10 -0
- package/dist/gameplay/actors/type-registry.js +4 -0
- package/dist/gameplay/ai/behavior-tree/move.d.ts +2 -2
- package/dist/gameplay/animation/retarget.d.ts +50 -0
- package/dist/gameplay/animation/retarget.js +4 -0
- package/dist/gameplay/animation/root-motion.js +1 -1
- package/dist/gameplay/event-graph/actor-transform-properties.d.ts +6 -0
- package/dist/gameplay/event-graph/actor-transform-properties.js +4 -0
- package/dist/gameplay/event-graph/asset-actor-types.d.ts +3 -0
- package/dist/gameplay/event-graph/asset-actor-types.js +4 -0
- package/dist/gameplay/event-graph/asset-references.d.ts +12 -0
- package/dist/gameplay/event-graph/asset-references.js +4 -0
- package/dist/gameplay/event-graph/compiler.d.ts +107 -0
- package/dist/gameplay/event-graph/compiler.js +4 -0
- package/dist/gameplay/event-graph/decorators.d.ts +74 -0
- package/dist/gameplay/event-graph/decorators.js +4 -0
- package/dist/gameplay/event-graph/document-compiler.d.ts +107 -0
- package/dist/gameplay/event-graph/document-compiler.js +4 -0
- package/dist/gameplay/event-graph/event-graph-demo.d.ts +2 -0
- package/dist/gameplay/event-graph/event-graph-demo.js +4 -0
- package/dist/gameplay/event-graph/graph.d.ts +106 -0
- package/dist/gameplay/event-graph/graph.js +4 -0
- package/dist/gameplay/event-graph/index.d.ts +13 -0
- package/dist/gameplay/event-graph/index.js +4 -0
- package/dist/gameplay/event-graph/model.d.ts +71 -0
- package/dist/gameplay/event-graph/model.js +4 -0
- package/dist/gameplay/event-graph/nodes/execution-nodes.d.ts +115 -0
- package/dist/gameplay/event-graph/nodes/execution-nodes.js +4 -0
- package/dist/gameplay/event-graph/nodes/gameplay-nodes.d.ts +208 -0
- package/dist/gameplay/event-graph/nodes/gameplay-nodes.js +4 -0
- package/dist/gameplay/event-graph/nodes/index.d.ts +4 -0
- package/dist/gameplay/event-graph/nodes/index.js +4 -0
- package/dist/gameplay/event-graph/nodes/value-nodes.d.ts +53 -0
- package/dist/gameplay/event-graph/nodes/value-nodes.js +4 -0
- package/dist/gameplay/event-graph/registry.d.ts +33 -0
- package/dist/gameplay/event-graph/registry.js +4 -0
- package/dist/gameplay/event-graph/runtime-assets.d.ts +21 -0
- package/dist/gameplay/event-graph/runtime-assets.js +4 -0
- package/dist/gameplay/event-graph/runtime.d.ts +160 -0
- package/dist/gameplay/event-graph/runtime.js +4 -0
- package/dist/gameplay/event-graph/type-inference.d.ts +41 -0
- package/dist/gameplay/event-graph/type-inference.js +4 -0
- package/dist/gameplay/event-graph/types.d.ts +77 -0
- package/dist/gameplay/event-graph/types.js +4 -0
- package/dist/gameplay/index.d.ts +17 -2
- package/dist/gameplay/index.js +1 -1
- package/dist/gameplay/initiate.d.ts +4 -0
- package/dist/gameplay/initiate.js +1 -1
- package/dist/gameplay/input/input.d.ts +22 -17
- package/dist/gameplay/input/input.js +1 -1
- package/dist/gameplay/net/browser/index.d.ts +147 -0
- package/dist/gameplay/net/browser/index.js +4 -0
- package/dist/gameplay/net/index.d.ts +7 -0
- package/dist/gameplay/net/index.js +4 -0
- package/dist/gameplay/net/net-connection.d.ts +25 -0
- package/dist/gameplay/net/net-connection.js +4 -0
- package/dist/gameplay/net/net-session.d.ts +70 -0
- package/dist/gameplay/net/net-session.js +4 -0
- package/dist/gameplay/net/service/net-actor-role.d.ts +12 -0
- package/dist/gameplay/net/service/net-actor-role.js +4 -0
- package/dist/gameplay/net/service/net-decorator.d.ts +29 -0
- package/dist/gameplay/net/service/net-decorator.js +4 -0
- package/dist/gameplay/net/service/net-serializer.d.ts +15 -0
- package/dist/gameplay/net/service/net-serializer.js +4 -0
- package/dist/gameplay/net/service/net-service.d.ts +171 -0
- package/dist/gameplay/net/service/net-service.js +4 -0
- package/dist/gameplay/net/service/net-utils.d.ts +8 -0
- package/dist/gameplay/net/service/net-utils.js +4 -0
- package/dist/gameplay/net/service/replication.d.ts +31 -0
- package/dist/gameplay/net/service/replication.js +4 -0
- package/dist/gameplay/net/service/rpc-decorator.d.ts +21 -0
- package/dist/gameplay/net/service/rpc-decorator.js +4 -0
- package/dist/gameplay/net/service/rpc.d.ts +35 -0
- package/dist/gameplay/net/service/rpc.js +4 -0
- package/dist/gameplay/services/asset-loader.d.ts +10 -2
- package/dist/gameplay/services/asset-loader.js +1 -1
- package/dist/gameplay/services/physics/physics-system.d.ts +16 -1
- package/dist/gameplay/services/physics/physics-system.js +1 -1
- package/dist/gameplay/services/world.d.ts +25 -2
- package/dist/gameplay/services/world.js +1 -1
- package/dist/rendering/color-pass.js +1 -1
- package/dist/rendering.d.ts +2 -0
- package/dist/rendering.js +1 -1
- package/dist/scene/asset-resource-loader.d.ts +7 -1
- package/dist/scene/asset-resource-loader.js +1 -1
- package/dist/scene/batched-mesh-2.d.ts +9 -0
- package/dist/scene/batched-mesh-2.js +1 -1
- package/dist/scene/bootstrap.d.ts +2 -0
- package/dist/scene/bootstrap.js +1 -1
- package/dist/scene/custom-param-deserialize.js +1 -1
- package/dist/scene/custom-param-runtime-types.js +1 -1
- package/dist/scene/materializer.d.ts +29 -0
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/model.d.ts +114 -2
- package/dist/scene/model.js +1 -1
- package/dist/scene/objects/prefab.js +1 -1
- package/dist/scene/storage/storage.d.ts +1 -1
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/builtin/standard-shader.js +1 -1
- package/dist/shader/builtin/toon-shader.js +1 -1
- package/dist/shader/builtin/unlit-shader.js +1 -1
- package/dist/shader/color-layer.js +1 -1
- package/dist/shader/graph/compiler.d.ts +3 -0
- package/dist/shader/graph/compiler.js +1 -1
- package/dist/shader/graph/model.d.ts +1 -1
- package/dist/shader/graph/registry.js +1 -1
- package/dist/shader/parameter.d.ts +1 -1
- package/dist/shader/parameter.js +1 -1
- package/dist/shader-nodes/depth.js +1 -1
- package/dist/shader-nodes/scene-sample.js +1 -1
- package/dist/test/animation-retarget.test.d.ts +2 -0
- package/dist/test/animation-retarget.test.js +4 -0
- package/dist/test/batched-mesh-2.test.d.ts +2 -0
- package/dist/test/batched-mesh-2.test.js +4 -0
- package/dist/test/browser-net-session.test.d.ts +2 -0
- package/dist/test/browser-net-session.test.js +4 -0
- package/dist/test/event-graph-generated-code.test.d.ts +2 -0
- package/dist/test/event-graph-generated-code.test.js +4 -0
- package/dist/test/event-graph-types.test.d.ts +2 -0
- package/dist/test/event-graph-types.test.js +4 -0
- package/dist/test/event-graph.test.d.ts +2 -0
- package/dist/test/event-graph.test.js +4 -0
- package/dist/test/first-person-camera-component.test.js +1 -1
- package/dist/test/input.test.d.ts +2 -0
- package/dist/test/input.test.js +4 -0
- package/dist/test/net-character-movement.test.d.ts +2 -0
- package/dist/test/net-character-movement.test.js +4 -0
- package/dist/test/net-property-snapshot.test.d.ts +2 -0
- package/dist/test/net-property-snapshot.test.js +4 -0
- package/dist/test/prefab-instance-params.test.js +1 -1
- package/dist/test/sequence-animation-retiming.test.js +1 -1
- package/dist/test/sequence-camera-control.test.js +1 -1
- package/dist/test/sequence-scene-binding.test.d.ts +2 -0
- package/dist/test/sequence-scene-binding.test.js +4 -0
- package/dist/test/sequence-transform.test.d.ts +2 -0
- package/dist/test/sequence-transform.test.js +4 -0
- package/dist/test/shader-graph.test.js +1 -1
- package/dist/test/vfx-random-color-initializer.test.d.ts +2 -0
- package/dist/test/vfx-random-color-initializer.test.js +4 -0
- package/dist/test/world-prefab-spawn.test.d.ts +2 -0
- package/dist/test/world-prefab-spawn.test.js +4 -0
- package/dist/utils/three/placeholder-texture.d.ts +3 -0
- package/dist/utils/three/placeholder-texture.js +4 -0
- package/package.json +18 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -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
|
*/
|
|
@@ -122,6 +122,6 @@ export declare function getDataAssetDefinitionId(type: ParameterType | undefined
|
|
|
122
122
|
export declare function getParameterDefinitionInfo(type: ParameterType | undefined | null): ParameterDefinitionInfo | undefined;
|
|
123
123
|
export declare function resolveParameterType(type: ParameterOptions['type']): ParameterType | undefined;
|
|
124
124
|
export declare function getDataAssetDefinitionInfo(type: ParameterType | undefined | null): DataAssetDefinitionInfo | undefined;
|
|
125
|
-
export declare function Parameter(options?: ParameterOptions):
|
|
125
|
+
export declare function Parameter(options?: ParameterOptions): any;
|
|
126
126
|
export declare function ParameterCategory(name: string): void;
|
|
127
127
|
//# sourceMappingURL=parameter.d.ts.map
|
package/dist/shader/parameter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"reflect-metadata";import{reflect as e,decorateProperty as t}from"@plumier/reflect";import{ArrayMap as n}from"../utils/collections.js";Symbol("format");const r=Symbol("parameterDefinition"),a=Symbol("dataAssetDefinition");export function shaderParameterUniformName(e){return`pu_${e}`}class i{constructor(e){this.options=e,this.isParameterDecorator=!0}}new Map;const o=new n,s=new Map,f=new Map,l=new WeakMap,p=new Map,u=new Map,c=new WeakMap;export function ParameterDefinition(e,t={}){return function(n){registerParameterDefinition(e??n.name,n,t)}}export function DataAssetDefinition(e,t={}){return function(n){registerDataAssetDefinition(e??n.name,n,t)}}export function registerParameterDefinition(e,t,n={}){if(null==e||""===e.trim())throw new Error("Parameter definition id must be a non-empty string");const a=s.get(e);null!=a&&a!==t&&console.warn(`Replacing parameter definition "${e}"`,{existing:a,type:t}),s.set(e,t),f.set(e,{id:e,type:t,...!0===n.abstract?{abstract:!0}:{}}),l.set(t,e),Reflect.defineMetadata(r,f.get(e),t)}export function getParameterDefinitionType(e){return s.get(e)}export function registerDataAssetDefinition(e,t,n={}){if(null==e||""===e.trim())throw new Error("Data asset definition id must be a non-empty string");const r=p.get(e);null!=r&&r!==t&&console.warn(`Replacing data asset definition "${e}"`,{existing:r,type:t}),p.set(e,t),u.set(e,{id:e,type:t,...!0===n.abstract?{abstract:!0}:{}}),c.set(t,e),Reflect.defineMetadata(a,u.get(e),t)}export function getDataAssetDefinitionType(e){return p.get(e)}export function getAssignableDataAssetDefinitions(e,t={}){if(null==e)return[];const n=getDataAssetDefinitionId(e);return Array.from(p.entries()).filter(([,t])=>isParameterDefinitionAssignableTo(t,e)).filter(([e])=>!0===t.includeAbstract||!isDataAssetDefinitionAbstract(e)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.id===n?-1:t.id===n?1:e.label.localeCompare(t.label))}export function getDataAssetDefinitions(e={}){return Array.from(p.entries()).filter(([t])=>!0===e.includeAbstract||!isDataAssetDefinitionAbstract(t)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.label.localeCompare(t.label))}export function getAssignableParameterDefinitions(e,t={}){if(null==e)return[];const n=getParameterDefinitionId(e);return Array.from(s.entries()).filter(([,t])=>isParameterDefinitionAssignableTo(t,e)).filter(([e])=>!0===t.includeAbstract||!isParameterDefinitionAbstract(e)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.id===n?-1:t.id===n?1:e.label.localeCompare(t.label))}export function isParameterDefinitionAssignableTo(e,t){return null!=e&&null!=t&&(e===t||e.prototype instanceof t)}export function isParameterDefinitionStructAssignableTo(e,t){return null!=e&&null!=t&&(e===t||isParameterDefinitionAssignableTo(getParameterDefinitionType(e),getParameterDefinitionType(t)))}export function isParameterDefinitionAbstract(e){if(null==e)return!1;const t="string"==typeof e?f.get(e):getParameterDefinitionInfo(e);return!0===t?.abstract}export function isDataAssetDefinitionAbstract(e){if(null==e)return!1;const t="string"==typeof e?u.get(e):getDataAssetDefinitionInfo(e);return!0===t?.abstract}export function getParameterDefinitionDisplayName(e){return("string"==typeof e?e:e.name).replace(/Definition$/,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[_-]+/g," ").trim().split(/\s+/).filter(e=>e.length>0).map(e=>e.length<=2&&e===e.toUpperCase()?e:e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}export function getParameterDefinitionId(e){if(null!=e)return l.get(e)??Reflect.getMetadata(r,e)?.id}export function getDataAssetDefinitionId(e){if(null!=e)return c.get(e)??Reflect.getMetadata(a,e)?.id}export function getParameterDefinitionInfo(e){if(null==e)return;const t=getParameterDefinitionId(e);return null!=t?f.get(t)??Reflect.getMetadata(r,e)??{id:t,type:e}:void 0}export function resolveParameterType(e){if(null!=e)return"function"==typeof e&&null==e.prototype?e():e}function m(e,t){const{enum:n,...r}=e,a=n??t;if(null==a||r.options?.length>0)return r;const i=function(e){return Object.entries(e).filter(([e])=>!function(e){return""!==e.trim()&&String(Number(e))===e}(e)).map(([e,t])=>({name:getParameterDefinitionDisplayName(e),value:t}))}(a);return{...r,type:r.type??g(i),defaultValue:void 0!==r.defaultValue?r.defaultValue:i[0]?.value,options:i}}function g(e){const t=new Set(e.map(e=>typeof e.value));if(1===t.size)return t.has("number")?Number:t.has("string")?String:void 0}export function getDataAssetDefinitionInfo(e){if(null==e)return;const t=getDataAssetDefinitionId(e);return null!=t?u.get(t)??Reflect.getMetadata(a,e)??{id:t,type:e}:void 0}export function Parameter(e){return function(n,r,a){if(null!=n){o.push(n.constructor,{name:r,options:e??{}});try{t(new i(e))(n,r,a)}catch(e){console.warn("Failed to decorate method ",n,r,a)}}}}export function extractShaderParameters(e){if(null==e)return[];const t=o.get(e).map(({name:t,options:n})=>{const r=Reflect.getMetadata("parameter:enum",e.prototype,t),a=Reflect.getMetadata("parameter:array",e.prototype,t),i=Reflect.getMetadata("parameter:arrayElementType",e.prototype,t),o=Reflect.getMetadata("parameter:dataAssetOf",e.prototype,t),s=m(n,r),f=Reflect.getMetadata("design:type",e.prototype,t),l=!0===s.array||!0===a||f===Array,p=resolveParameterType(s.type)??(l?i:void 0)??f,u=Reflect.getMetadata("prefab:type",e.prototype,t);return s.prefabOf??(s.prefabOf=u),s.dataAssetOf??(s.dataAssetOf=o),s.array=l,{name:t,type:p,options:s,definition:getParameterDefinitionInfo(p)}});return[...extractShaderParameters(Object.getPrototypeOf(e)).filter(e=>t.every(t=>t.name!==e.name)),...t]}export function ParameterCategory(e){}/*
|
|
1
|
+
import"reflect-metadata";import{reflect as e,decorateProperty as t}from"@plumier/reflect";import{ArrayMap as n}from"../utils/collections.js";Symbol("format");const r=Symbol("parameterDefinition"),a=Symbol("dataAssetDefinition");export function shaderParameterUniformName(e){return`pu_${e}`}class i{constructor(e){this.options=e,this.isParameterDecorator=!0}}new Map;const o=new n,s=new Map,f=new Map,l=new WeakMap,p=new Map,u=new Map,c=new WeakMap;export function ParameterDefinition(e,t={}){return function(n){registerParameterDefinition(e??n.name,n,t)}}export function DataAssetDefinition(e,t={}){return function(n){registerDataAssetDefinition(e??n.name,n,t)}}export function registerParameterDefinition(e,t,n={}){if(null==e||""===e.trim())throw new Error("Parameter definition id must be a non-empty string");const a=s.get(e);null!=a&&a!==t&&console.warn(`Replacing parameter definition "${e}"`,{existing:a,type:t}),s.set(e,t),f.set(e,{id:e,type:t,...!0===n.abstract?{abstract:!0}:{}}),l.set(t,e),Reflect.defineMetadata(r,f.get(e),t)}export function getParameterDefinitionType(e){return s.get(e)}export function registerDataAssetDefinition(e,t,n={}){if(null==e||""===e.trim())throw new Error("Data asset definition id must be a non-empty string");const r=p.get(e);null!=r&&r!==t&&console.warn(`Replacing data asset definition "${e}"`,{existing:r,type:t}),p.set(e,t),u.set(e,{id:e,type:t,...!0===n.abstract?{abstract:!0}:{}}),c.set(t,e),Reflect.defineMetadata(a,u.get(e),t)}export function getDataAssetDefinitionType(e){return p.get(e)}export function getAssignableDataAssetDefinitions(e,t={}){if(null==e)return[];const n=getDataAssetDefinitionId(e);return Array.from(p.entries()).filter(([,t])=>isParameterDefinitionAssignableTo(t,e)).filter(([e])=>!0===t.includeAbstract||!isDataAssetDefinitionAbstract(e)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.id===n?-1:t.id===n?1:e.label.localeCompare(t.label))}export function getDataAssetDefinitions(e={}){return Array.from(p.entries()).filter(([t])=>!0===e.includeAbstract||!isDataAssetDefinitionAbstract(t)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.label.localeCompare(t.label))}export function getAssignableParameterDefinitions(e,t={}){if(null==e)return[];const n=getParameterDefinitionId(e);return Array.from(s.entries()).filter(([,t])=>isParameterDefinitionAssignableTo(t,e)).filter(([e])=>!0===t.includeAbstract||!isParameterDefinitionAbstract(e)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.id===n?-1:t.id===n?1:e.label.localeCompare(t.label))}export function isParameterDefinitionAssignableTo(e,t){return null!=e&&null!=t&&(e===t||e.prototype instanceof t)}export function isParameterDefinitionStructAssignableTo(e,t){return null!=e&&null!=t&&(e===t||isParameterDefinitionAssignableTo(getParameterDefinitionType(e),getParameterDefinitionType(t)))}export function isParameterDefinitionAbstract(e){if(null==e)return!1;const t="string"==typeof e?f.get(e):getParameterDefinitionInfo(e);return!0===t?.abstract}export function isDataAssetDefinitionAbstract(e){if(null==e)return!1;const t="string"==typeof e?u.get(e):getDataAssetDefinitionInfo(e);return!0===t?.abstract}export function getParameterDefinitionDisplayName(e){return("string"==typeof e?e:e.name).replace(/Definition$/,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[_-]+/g," ").trim().split(/\s+/).filter(e=>e.length>0).map(e=>e.length<=2&&e===e.toUpperCase()?e:e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}export function getParameterDefinitionId(e){if(null!=e)return l.get(e)??Reflect.getMetadata(r,e)?.id}export function getDataAssetDefinitionId(e){if(null!=e)return c.get(e)??Reflect.getMetadata(a,e)?.id}export function getParameterDefinitionInfo(e){if(null==e)return;const t=getParameterDefinitionId(e);return null!=t?f.get(t)??Reflect.getMetadata(r,e)??{id:t,type:e}:void 0}export function resolveParameterType(e){if(null!=e)return"function"==typeof e&&null==e.prototype?e():e}function m(e,t){const{enum:n,...r}=e,a=n??t;if(null==a||r.options?.length>0)return r;const i=function(e){return Object.entries(e).filter(([e])=>!function(e){return""!==e.trim()&&String(Number(e))===e}(e)).map(([e,t])=>({name:getParameterDefinitionDisplayName(e),value:t}))}(a);return{...r,type:r.type??g(i),defaultValue:void 0!==r.defaultValue?r.defaultValue:i[0]?.value,options:i}}function g(e){const t=new Set(e.map(e=>typeof e.value));if(1===t.size)return t.has("number")?Number:t.has("string")?String:void 0}export function getDataAssetDefinitionInfo(e){if(null==e)return;const t=getDataAssetDefinitionId(e);return null!=t?u.get(t)??Reflect.getMetadata(a,e)??{id:t,type:e}:void 0}export function Parameter(e){return function(n,r,a){if(a&&"object"==typeof a&&"field"===a.kind)return o.push(n,{name:r,options:e??{}}),a.addInitializer&&a.addInitializer(function(){}),Reflect.defineMetadata("isParameterDecorator",!0,n,r),void Reflect.defineMetadata("parameterOptions",e,n,r);if(null!=n){o.push(n.constructor,{name:r,options:e??{}});try{t(new i(e))(n,r,a)}catch(e){console.warn("Failed to decorate method ",n,r,a)}}}}export function extractShaderParameters(e){if(null==e)return[];const t=o.get(e).map(({name:t,options:n})=>{const r=Reflect.getMetadata("parameter:enum",e.prototype,t),a=Reflect.getMetadata("parameter:array",e.prototype,t),i=Reflect.getMetadata("parameter:arrayElementType",e.prototype,t),o=Reflect.getMetadata("parameter:dataAssetOf",e.prototype,t),s=m(n,r),f=Reflect.getMetadata("design:type",e.prototype,t),l=!0===s.array||!0===a||f===Array,p=resolveParameterType(s.type)??(l?i:void 0)??f,u=Reflect.getMetadata("prefab:type",e.prototype,t);return s.prefabOf??(s.prefabOf=u),s.dataAssetOf??(s.dataAssetOf=o),s.array=l,{name:t,type:p,options:s,definition:getParameterDefinitionInfo(p)}});return[...extractShaderParameters(Object.getPrototypeOf(e)).filter(e=>t.every(t=>t.name!==e.name)),...t]}export function ParameterCategory(e){}/*
|
|
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
|
-
import*as e from"three";import{Vector2 as t}from"three";import{cross as o,dot as r,float as n,FloatExpressionNode as
|
|
1
|
+
import*as e from"three";import{Vector2 as t}from"three";import{cross as o,dot as r,float as n,FloatExpressionNode as s,FloatNode as c,inverse as a,normalize as i,texture2d as p,transformed as l,uniformFloat as m,uniforms as h,uniformSampler2d as u,uniformVec2 as d,unpackRGBToNormal as x,varying as f,vec2 as y,Vec2ExpressionNode as _,vec4 as U,Vec4Node as g}from"three-shader-graph";import{createPlaceholderTexture as k}from"../utils/three/placeholder-texture.js";export function supportsDepthTextureExtension(e){return!0}export const depthUniformName="hology_depth_map";export const resolutionUniformName="hology_resolution";export const nearUniformName="hology_camera_near";export const farUniformName="hology_camera_far";export const sceneNormalUniformName="hology_scene_normal_map";export const depthSampler=u(depthUniformName,new e.DepthTexture(1,1));const $=m(nearUniformName,.5),N=m(farUniformName,500);class v extends c{compile(e){const t=e.variable();var o=e.get($),r=e.get(N);return{chunk:`\n float depth_${t} = 2.0 * ${o} * ${r} / (${r} + ${o} - (2.0 * ${e.get(this.depth)} - 1.0) * (${r} - ${o}));\n `,out:`depth_${t}`}}constructor(e){super(),this.depth=e}}function w(e){return new v(e)}new class extends g{constructor(){super(...arguments),this.k="31u50"}compile(e){return{pars:`\n const float UnpackDownscale_${this.k} = 255. / 256.; // 0..1 -> fraction (excluding 1)\n const vec4 PackFactors_${this.k} = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\n const vec4 UnpackFactors_${this.k} = vec4( UnpackDownscale_${this.k} / PackFactors_${this.k}.rgb, 1.0 / PackFactors_${this.k}.a );\n `,out:`UnpackFactors_${this.k}`}}};function V(e){return p(depthSampler,e).r}export function sampleSceneDepth(e){return V(e)}export function sampleSceneLinearEyeDepth(e){return w(V(e))}const D=f(h.projectionMatrix.multiplyVec(l.mvPosition).zw);export const highPrecisionEyeDepth=D.x.multiply(.5).divide(D.y).add(.5);const S=new s("gl_FragCoord.z");export const fragmentLinearEyeDepth=w(S);export const resolution=d("hology_resolution",new t(250,1e3));export const screenUV=new _("gl_FragCoord.xy").divide(resolution);export const linearEyeDepth=w(V(screenUV));const P=f(a(h.projectionMatrix)),b=f(a(h.viewMatrix));function F(e=screenUV){const t=V(e).multiply(2).subtract(1),o=e.multiplyScalar(2).subtractScalar(1),r=U(o.x,o.y,t,1),n=P.multiplyVec(r),s=n.xyz.divideScalar(n.w);return b.multiplyVec(U(s,1)).xyz}export const depthWorldPosition=F(screenUV);const E=n(1).divide(resolution.x),z=n(1).divide(resolution.y),j=F(screenUV.add(y(E,n(0)))),M=F(screenUV.add(y(n(0),z)));export const depthNormal=i(o(j.subtract(depthWorldPosition),M.subtract(depthWorldPosition)));export const sceneNormalSampler=u(sceneNormalUniformName,k(128,128,255));export const sceneNormal=x(sceneNormalSampler.sample(screenUV).rgb);/*
|
|
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
|
-
import{float as o,ifDefApply as e,uniformSampler2d as r,Vec3ExpressionNode as
|
|
1
|
+
import{float as o,ifDefApply as e,uniformSampler2d as r,Vec3ExpressionNode as p}from"three-shader-graph";import{screenUV as a}from"./depth.js";import{createPlaceholderTexture as t}from"../utils/three/placeholder-texture.js";export const sceneMapUniformName="hology_scene_map";export const sceneColorSampler=r("hology_scene_map",t());export function sampleSceneColor(o){return sceneColorSampler.sample(o)}export const fragCoord=new p("gl_FragCoord");export const aoMapUniformName="hology_ao_map";export const aoColorSampler=r("hology_ao_map",t());export function sampleScreenAO(r=a){return e("USE_SSAO_MAP",o(1),()=>aoColorSampler.sample(r).r)}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{describe as e,expect as t,it as n}from"vitest";import{Bone as o,AnimationClip as r,BufferGeometry as a,Group as s,MeshBasicMaterial as i,Quaternion as g,QuaternionKeyframeTrack as c,Skeleton as d,SkinnedMesh as p,Vector3 as l,VectorKeyframeTrack as u}from"three";import{areAnimationRigsCompatible as m,bakeRetargetedAnimationClip as f,createAutoAlignedRetargetPose as b,createDefaultAnimationRetargeter as h,extractAnimationRigs as w,findGeneratedAnimationOutput as B,getAnimationRigChainBoneNames as y,isAnimationClipCompatibleWithRig as L,resolveAnimationRigBasisRotation as k,resolveAnimationClipAssetForTarget as v,validateAnimationRetargeter as R,validateAnimationRig as A}from"../gameplay/animation/retarget.js";function T(e,t=!1){const n=["Root","Hips","Spine","Chest","Neck","Head","LeftUpperArm",...t?["LeftArmTwist"]:[],"LeftHand","RightUpperArm","RightHand","LeftUpLeg","LeftLeg","LeftFoot","RightUpLeg","RightLeg","RightFoot"],o=new Map(n.map(e=>[e,x(e)]));o.get("Root").add(o.get("Hips")),o.get("Hips").add(o.get("Spine"),o.get("LeftUpLeg"),o.get("RightUpLeg")),o.get("Spine").add(o.get("Chest")),o.get("Chest").add(o.get("Neck"),o.get("LeftUpperArm"),o.get("RightUpperArm")),o.get("Neck").add(o.get("Head")),t?(o.get("LeftUpperArm").add(o.get("LeftArmTwist")),o.get("LeftArmTwist").add(o.get("LeftHand"))):o.get("LeftUpperArm").add(o.get("LeftHand")),o.get("RightUpperArm").add(o.get("RightHand")),o.get("LeftUpLeg").add(o.get("LeftLeg")),o.get("LeftLeg").add(o.get("LeftFoot")),o.get("RightUpLeg").add(o.get("RightLeg")),o.get("RightLeg").add(o.get("RightFoot"));const r=new p(new a,new i);return r.name=e,r.add(o.get("Root")),r.bind(new d([...o.values()])),r}function x(e){const t=new o;return t.name=e,t.position.y="Root"===e?0:1,t}function U(e){const t=[...T("Canonical").skeleton.bones],n=new Map(t.map((e,t)=>[e,t])),r=t.map(e=>e.parent instanceof o?n.get(e.parent)??-1:-1);for(const e of t)e.removeFromParent();const s=t.map(e=>{const t=new o;return t.name=e.name,t}),g=new p(new a,new i);g.name=e;for(let e=0;e<t.length;e++){const n=r[e];n<0?g.add(t[e]):s[n].add(t[e]),t[e].add(s[e])}return g.updateMatrixWorld(!0),g.bind(new d(s)),g}function P(e,t){let n=H(e,"LeftHand");for(const o of t){const t=x(o);n.add(t),e.skeleton.bones.push(t),n=t}e.updateMatrixWorld(!0),e.skeleton.calculateInverses()}function H(e,t){const n=e.skeleton.getBoneByName(t);if(null==n)throw new Error(`Missing test bone ${t}`);return n}function M(e,t){return{...e,previewMeshId:t}}e("animation retargeting assets",()=>{n("extracts stable hierarchy and bind-pose fingerprints",()=>{const e=w(T("Body")).rigs[0],n=w(T("Body")).rigs[0];t(e.topologyFingerprint).toBe(n.topologyFingerprint),t(e.bindPoseFingerprint).toBe(n.bindPoseFingerprint),t(e.skinnedMeshName).toBe("Body"),t(e.chains.map(e=>e.role)).toEqual(t.arrayContaining(["spine","leftArm","rightArm","leftLeg","rightLeg"]));const o=T("Body");H(o,"LeftHand").position.x+=.25;const r=w(o).rigs[0];t(r.topologyFingerprint).toBe(e.topologyFingerprint),t(r.bindPoseFingerprint).not.toBe(e.bindPoseFingerprint)}),n("extracts each distinct skeleton and reuses compatible rigs",()=>{const e=new s;e.add(T("BodyA"),T("BodyB")),t(w(e).rigs).toHaveLength(1);const n=T("BodyC");H(n,"LeftHand").position.x+=.1,e.add(n);const o=w(e).rigs;t(o).toHaveLength(2),t(m(M(o[0],"mesh-a"),M(o[0],"mesh-b"))).toBe(!0),t(m(M(o[0],"mesh-a"),M(o[1],"mesh-c"))).toBe(!1)}),n("extracts a rig from a standalone bone hierarchy",()=>{const e=new s,n=new o;n.name="Hips";const r=new o;r.name="Spine",r.position.y=1,n.add(r),e.add(n);const a=w(e);t(a.rigs).toHaveLength(1),t(a.skinnedMeshNames).toEqual(["Hips"]),t(a.rigs[0].skinnedMeshName).toBeUndefined(),t(a.rigs[0].bones.map(e=>e.name)).toEqual(["Hips","Spine"]),t(a.rigs[0].bones[1].parentIndex).toBe(0),t(a.rigs[0].bones[1].inverseBindMatrix).toHaveLength(16)}),n("canonicalizes same-named FBX bone wrappers and prefers a direct skinned hierarchy",()=>{const e=new s,n=U("WrappedLOD"),o=T("DirectLOD");e.add(n,o);const a=w(e),i=w(T("AnimationSource")).rigs[0];t(a.rigs).toHaveLength(1),t(a.skinnedMeshNames).toEqual(["DirectLOD"]),t(a.rigs[0].bones).toHaveLength(i.bones.length),t(a.rigs[0].topologyFingerprint).toBe(i.topologyFingerprint),t(a.rigs[0].bindPoseFingerprint).toBe(i.bindPoseFingerprint),t(A(M(a.rigs[0],"direct"))).toEqual([]);const g=M(a.rigs[0],"source"),d=M(i,"target");g.skinnedMeshName=void 0,g.basisPreset="yUp",d.basisPreset="yUp";const p=f({sourceRig:g,targetRig:d,retargeter:h("source-rig","target-rig",g,d),sourceObject:e,targetObject:T("AnimationTarget"),clip:new r("Wrapped source",1,[new c("Spine.quaternion",[0,1],[0,0,0,1,0,.3826834,0,.9238795])])}).tracks.find(e=>e.name.includes("[Spine]"));t(p).toBeDefined(),t(Array.from(p?.createInterpolant().evaluate(1)??[])).toEqual(t.arrayContaining([t.closeTo(0,5),t.closeTo(.3826834,5),t.closeTo(0,5),t.closeTo(.9238795,5)]));const l=U("StandaloneWrapped"),u=new s;for(;l.children.length>0;)u.add(l.children[0]);const m=w(u).rigs[0];t(m.bones).toHaveLength(i.bones.length),t(m.topologyFingerprint).toBe(i.topologyFingerprint),t(m.bindPoseFingerprint).toBe(i.bindPoseFingerprint)}),n("reports duplicate bone names and stale rig fingerprints",()=>{const e=w(T("Body")).rigs[0],n=M(e,"source-mesh"),o=M(e,"target-mesh"),r=h("source-rig","target-rig",n,o);o.bones[1].name=o.bones[0].name,o.bindPoseFingerprint="changed",t(A(o).map(e=>e.code)).toContain("duplicate-bone-names"),t(R(r,n,o).map(e=>e.code)).toContain("target-rig-changed")}),n("resolves semantic chain bones and generated output indexes",()=>{const e=M(w(T("Body")).rigs[0],"mesh");t(y(e,"leftLeg")).toEqual(["LeftUpLeg","LeftLeg","LeftFoot"]);const n=[{id:"retargeter",name:"A to B",type:"animationRetargeter",animationRetargeter:{...h("a","b",e,e),generatedOutputs:{walk:"walk-b"}}},{id:"walk-b",name:"Walk B",type:"animationclip",anim:{clip:"Walk",rigId:"b"}}];t(B(n,"walk","b")?.id).toBe("walk-b"),t(B(n,"walk","other")).toBeUndefined();const o={id:"walk",name:"Walk",type:"animationclip",anim:{clip:"Walk",rigId:"a"}};t(v(o,n,"b").id).toBe("walk-b"),t(()=>v(o,n,"missing")).toThrow(/Generate this source\/target output/);const a={...o,id:"legacy-walk",anim:{clip:"Walk"}};t(v(a,n,"b")).toBe(a),t(L(new r("Known",1,[new c(".bones[LeftHand].quaternion",[0],[0,0,0,1])]),e)).toBe(!0),t(L(new r("Other",1,[new c(".bones[Tail].quaternion",[0],[0,0,0,1])]),e)).toBe(!1)}),n("bakes target-named tracks at a minimum 60 Hz and maps root axes",()=>{const e=T("SourceBody"),n=T("TargetBody"),o=M(w(e).rigs[0],"source"),a=M(w(n).rigs[0],"target");o.basisPreset="yUp",a.basisPreset="yUp";const s=h("source-rig","target-rig",o,a);s.bakeSettings.framesPerSecond=10,s.rootSettings.translationAxisMap=[3,2,-1];const i=new r("Move",1,[new u(".bones[Root].position",[0,1],[0,0,0,2,0,4]),new c(".bones[Spine].quaternion",[0,1],[0,0,0,1,0,0,0,1])]),g=f({sourceRig:o,targetRig:a,retargeter:s,sourceObject:e,targetObject:n,clip:i});t(g.name).toBe("Move"),t(g.tracks.some(e=>e.name.includes("Spine"))).toBe(!0),t(Math.max(...g.tracks.map(e=>e.times.length))).toBeGreaterThanOrEqual(2);const d=g.tracks.find(e=>e instanceof u);t(d).toBeInstanceOf(u),t(d?.name).toContain("Root"),t(d?.values.at(-3)).toBeCloseTo(4),t(d?.values.at(-1)).toBeCloseTo(-2)}),n("detects a Z-up rig basis and converts root motion into target Y-up space",()=>{const e=T("ZUpSource");for(const t of e.skeleton.bones)t.position.set(t.position.x,0,t.position.y);e.updateMatrixWorld(!0),e.skeleton.calculateInverses();const n=T("YUpTarget"),o=M(w(e).rigs[0],"source"),a=M(w(n).rigs[0],"target"),s=new l(0,0,1).applyQuaternion(k(o));t(s.angleTo(new l(0,1,0))).toBeLessThan(1e-6);const i=h("source-rig","target-rig",o,a),c=b(o,a,i).rotationOffsets[a.retargetRootBoneId];t((new g).fromArray(c).angleTo(new g)).toBeLessThan(1e-6);const d=f({sourceRig:o,targetRig:a,retargeter:i,sourceObject:e,targetObject:n,clip:new r("Vertical",1,[new u(".bones[Root].position",[0,1],[0,0,0,0,0,1])])}).tracks.find(e=>e instanceof u);t(d?.values.at(-2)).toBeCloseTo(1),t(d?.values.at(-1)).toBeCloseTo(0)}),n("combines source pelvis height with root motion when the target pelvis is its root",()=>{const e=T("SourceBody"),n=T("TargetBody"),o=M(w(e).rigs[0],"source"),a=M(w(n).rigs[0],"target");o.basisPreset="yUp",a.basisPreset="yUp",a.retargetRootBoneId=a.pelvisBoneId;const s=h("source-rig","target-rig",o,a),i=f({sourceRig:o,targetRig:a,retargeter:s,sourceObject:e,targetObject:n,clip:new r("Crouch forward",1,[new u(".bones[Root].position",[0,1],[0,0,0,2,0,0]),new u(".bones[Hips].position",[0,1],[0,1,0,0,.6,0])])}).tracks.find(e=>e instanceof u&&e.name.includes("[Hips]"));t(i?.values.at(-3)).toBeCloseTo(2),t(i?.values.at(-2)).toBeCloseTo(.6),t(i?.values.at(-1)).toBeCloseTo(0)}),n("maps semantic chain position when target limb bone counts differ",()=>{const e=T("SourceBody"),n=T("TargetBody",!0),o=M(w(e).rigs[0],"source"),a=M(w(n).rigs[0],"target");o.basisPreset="yUp",a.basisPreset="yUp";const s=h("source-rig","target-rig",o,a),i=new r("Wave",1,[new c(".bones[LeftUpperArm].quaternion",[0,1],[0,0,0,1,0,.3826834,0,.9238795])]),g=f({sourceRig:o,targetRig:a,retargeter:s,sourceObject:e,targetObject:n,clip:i});t(g.tracks.some(e=>e.name.includes("LeftArmTwist"))).toBe(!0),t(g.tracks.every(e=>!1===e.name.includes("Target"))).toBe(!0)}),n("transfers bind-relative rotation across different root coordinate bases",()=>{const e=T("SourceBody"),n=T("TargetBody");H(n,"Root").quaternion.setFromAxisAngle(new l(1,0,0),Math.PI/2),e.updateMatrixWorld(!0),n.updateMatrixWorld(!0),n.skeleton.calculateInverses();const o=M(w(e).rigs[0],"source"),a=M(w(n).rigs[0],"target");o.basisPreset="yUp",a.basisPreset="yUp";const s=h("source-rig","target-rig",o,a),i=(new g).setFromAxisAngle(new l(0,1,0),Math.PI/3),d=new r("Turn",1,[new c(".bones[Spine].quaternion",[0,1],[0,0,0,1,...i.toArray()])]),p=H(e,"Spine"),u=H(n,"Spine"),m=p.getWorldQuaternion(new g),b=u.getWorldQuaternion(new g);p.quaternion.copy(i),e.updateMatrixWorld(!0);const B=p.getWorldQuaternion(new g).multiply(m.clone().invert()).multiply(b),y=f({sourceRig:o,targetRig:a,retargeter:s,sourceObject:e,targetObject:n,clip:d}).tracks.find(e=>e.name.includes("[Spine]"));t(y).toBeInstanceOf(c),u.quaternion.fromArray(y.values,y.values.length-4),n.updateMatrixWorld(!0),t(u.getWorldQuaternion(new g).angleTo(B)).toBeLessThan(1e-5)}),n("transfers root displacement through the target root parent basis",()=>{const e=T("SourceBody"),n=T("TargetBody");n.quaternion.setFromAxisAngle(new l(1,0,0),-Math.PI/2),H(n,"Root").quaternion.setFromAxisAngle(new l(1,0,0),Math.PI/2),e.updateMatrixWorld(!0),n.updateMatrixWorld(!0),n.skeleton.calculateInverses();const o=M(w(e).rigs[0],"source"),a=M(w(n).rigs[0],"target");o.basisPreset="yUp",a.basisPreset="yUp";const s=h("source-rig","target-rig",o,a),i=new r("Move forward",1,[new u(".bones[Root].position",[0,1],[0,0,0,0,0,2])]),g=f({sourceRig:o,targetRig:a,retargeter:s,sourceObject:e,targetObject:n,clip:i}).tracks.find(e=>e instanceof u);t(g?.values.at(-3)).toBeCloseTo(0),t(g?.values.at(-2)).toBeCloseTo(-2),t(g?.values.at(-1)).toBeCloseTo(0)}),n("maps finger segments with different humanoid naming conventions",()=>{const e=T("SourceBody"),n=T("TargetBody");P(e,["mixamorigLeftHandIndex1","mixamorigLeftHandIndex2"]),P(n,["index1l","index2l"]);const o=M(w(e).rigs[0],"source"),a=M(w(n).rigs[0],"target"),s=h("source-rig","target-rig",o,a),i=(new g).setFromAxisAngle(new l(1,0,0),Math.PI/3),d=new r("Grip",1,[new c(".bones[mixamorigLeftHandIndex1].quaternion",[0,1],[0,0,0,1,...i.toArray()])]),p=f({sourceRig:o,targetRig:a,retargeter:s,sourceObject:e,targetObject:n,clip:d});t(p.tracks.some(e=>e.name.includes("[index1l]"))).toBe(!0),t(p.tracks.some(e=>e.name.includes("[index2l]"))).toBe(!0)}),n("creates a target pose that aligns mapped limb directions",()=>{const e=T("SourceBody"),n=T("TargetBody");H(n,"LeftUpperArm").quaternion.setFromAxisAngle(new l(0,0,1),Math.PI/4),n.updateMatrixWorld(!0),n.skeleton.calculateInverses();const o=M(w(e).rigs[0],"source"),r=M(w(n).rigs[0],"target"),a=h("source-rig","target-rig",o,r),s=b(o,r,a),i=H(n,"LeftUpperArm");i.quaternion.fromArray(r.bones.find(e=>"LeftUpperArm"===e.name).quaternion).multiply((new g).fromArray(s.rotationOffsets[r.bones.find(e=>"LeftUpperArm"===e.name).id])),n.updateMatrixWorld(!0);const c=H(n,"LeftHand").getWorldPosition(new l).sub(i.getWorldPosition(new l)).normalize(),d=H(e,"LeftHand").getWorldPosition(new l).sub(H(e,"LeftUpperArm").getWorldPosition(new l)).normalize();t(c.angleTo(d)).toBeLessThan(1e-5)})});/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{describe as t,expect as e,it as s}from"vitest";import{BoxGeometry as o,MeshBasicMaterial as a,PerspectiveCamera as n,Scene as d}from"three";import{BatchedMesh2 as r}from"../scene/batched-mesh-2.js";function i(){const t=new o,e=t.getAttribute("position").count,s=t.index?.count??e,n=new r(3,e,s,new a),d=n.addGeometry(t);return n.perObjectFrustumCulled=!1,n.sortObjects=!1,{mesh:n,instanceIds:[n.addInstance(d),n.addInstance(d),n.addInstance(d)]}}function c(t){const e=t._multiDrawCount,s=t._indirectTexture.image.data;return Array.from(s.slice(0,e))}t("BatchedMesh2",()=>{s("filters non-casting instances only while building the shadow draw list",()=>{const{mesh:t,instanceIds:s}=i(),o=new d,a=new n,r=t.material;t.setCastShadowAt(s[0],!1),t.setCastShadowAt(s[1],!0),t.setCastShadowAt(s[2],!1),t.receiveShadow=!1,t.onBeforeShadow({},o,a,a,t.geometry,r,null),e(t.receiveShadow).toBe(!1),e(t._multiDrawCount).toBe(1),e(c(t)).toEqual([s[1]]),e(s.map(e=>t.getVisibleAt(e))).toEqual([!0,!0,!0]),t.onBeforeRender({},o,a,t.geometry,r,null),e(t._multiDrawCount).toBe(3),e(c(t)).toEqual(s)}),s("keeps the object out of shadow passes when no instances cast shadows",()=>{const{mesh:t,instanceIds:s}=i();t.setCastShadowAt(s[0],!0),e(t.castShadow).toBe(!0),t.setCastShadowAt(s[0],!1),e(t.castShadow).toBe(!1),t.setCastShadowAt(s[1],!0),t.deleteInstance(s[1]),e(t.castShadow).toBe(!1)})});/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{afterEach as e,beforeEach as s,expect as t,test as a,vi as r}from"vitest";import{BrowserNetSession as n}from"../gameplay/net/browser/index.js";import{NetMode as o}from"../gameplay/net/net-session.js";class l{constructor(e){this.name=e,this.listeners=new Set,this.closed=!1;const s=l.channels.get(e)??new Set;s.add(this),l.channels.set(e,s)}postMessage(e){const s=l.channels.get(this.name);if(null!=s)for(const t of s)t===this||t.closed||t.dispatch({data:e})}addEventListener(e,s){"message"===e&&this.listeners.add(s)}removeEventListener(e,s){"message"===e&&this.listeners.delete(s)}close(){this.closed=!0,l.channels.get(this.name)?.delete(this)}dispatch(e){for(const s of this.listeners)"function"==typeof s?s.call(this,e):s.handleEvent(e)}static reset(){l.channels.clear()}}l.channels=new Map;let i=[];function c(e){return i.push(e),e}function d(e){return Array.from(new Uint8Array(e))}s(()=>{l.reset(),r.stubGlobal("BroadcastChannel",l),Object.defineProperty(window,"BroadcastChannel",{configurable:!0,writable:!0,value:l}),localStorage.clear()}),e(()=>{i.forEach(e=>e.disconnect()),i=[],localStorage.clear(),r.useRealTimers(),r.unstubAllGlobals()}),a("sends raw buffers over BroadcastChannel without using localStorage as a message queue",()=>{const e=c(new n(o.listenServer,"room",1,{heartbeatIntervalMs:0})),s=c(new n(o.client,"room",2,{heartbeatIntervalMs:0})),a=[];e.playerJoined.subscribe(e=>a.push(Number(e.id))),e.connect(),s.connect(),t(a).toEqual([2]),t(e.clients.map(e=>e.id)).toEqual([2]),t(s.server?.id).toBe(1),s.sendMessage(s.server,!0,Uint8Array.of(7,8,9).buffer),t(e.hasMessage()).toBe(1);const r=e.readMessage();t(r?.from.id).toBe(2),t(d(r.buffer)).toEqual([7,8,9]),t(e.hasMessage()).toBe(0);const l=JSON.parse(localStorage.getItem("net_session_room"));t(l.members.map(e=>e.connectionId)).toEqual([1,2]),t(l.messages).toBeUndefined()}),a("emits playerLeft when a member disconnects",()=>{const e=c(new n(o.listenServer,"leave-room",1,{heartbeatIntervalMs:0})),s=c(new n(o.client,"leave-room",2,{heartbeatIntervalMs:0})),a=[];e.playerLeft.subscribe(e=>a.push(Number(e.id))),e.connect(),s.connect(),s.disconnect(),t(a).toEqual([2]),t(e.clients).toEqual([])}),a("applies latency and packet loss to unreliable messages",()=>{r.useFakeTimers();const e=c(new n(o.listenServer,"sim-room",1,{heartbeatIntervalMs:0})),s=c(new n(o.client,"sim-room",2,{heartbeatIntervalMs:0,latencyMs:25,packetLoss:1}));e.connect(),s.connect(),s.sendMessage(s.server,!1,Uint8Array.of(1).buffer),r.advanceTimersByTime(100),t(e.hasMessage()).toBe(0),s.configureNetworkSimulation({packetLoss:0}),s.sendMessage(s.server,!1,Uint8Array.of(2).buffer),r.advanceTimersByTime(24),t(e.hasMessage()).toBe(0),r.advanceTimersByTime(1),t(e.hasMessage()).toBe(1),t(d(e.readMessage().buffer)).toEqual([2])}),a("keeps reliable messages ordered when jitter would otherwise reorder them",()=>{r.useFakeTimers();r.spyOn(Math,"random").mockReturnValueOnce(1).mockReturnValueOnce(0);const e=c(new n(o.listenServer,"ordered-room",1,{heartbeatIntervalMs:0})),s=c(new n(o.client,"ordered-room",2,{heartbeatIntervalMs:0,jitterMs:10}));e.connect(),s.connect(),s.sendMessage(s.server,!0,Uint8Array.of(1).buffer),s.sendMessage(s.server,!0,Uint8Array.of(2).buffer),r.advanceTimersByTime(10),t(e.hasMessage()).toBe(2),t(d(e.readMessage().buffer)).toEqual([1]),t(d(e.readMessage().buffer)).toEqual([2])});/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|