@babylonjs/core 6.4.1 → 6.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/Animations/animation.d.ts +4 -0
  2. package/Animations/animation.js +13 -1
  3. package/Animations/animation.js.map +1 -1
  4. package/Animations/runtimeAnimation.js +9 -1
  5. package/Animations/runtimeAnimation.js.map +1 -1
  6. package/Audio/sound.js +3 -1
  7. package/Audio/sound.js.map +1 -1
  8. package/Bones/boneLookController.d.ts +5 -0
  9. package/Bones/boneLookController.js +17 -3
  10. package/Bones/boneLookController.js.map +1 -1
  11. package/Engines/Processors/iShaderProcessor.d.ts +1 -0
  12. package/Engines/Processors/iShaderProcessor.js.map +1 -1
  13. package/Engines/Processors/shaderCodeNode.js +3 -2
  14. package/Engines/Processors/shaderCodeNode.js.map +1 -1
  15. package/Engines/Processors/shaderProcessor.d.ts +1 -0
  16. package/Engines/Processors/shaderProcessor.js +45 -44
  17. package/Engines/Processors/shaderProcessor.js.map +1 -1
  18. package/Engines/WebGL/webGL2ShaderProcessors.d.ts +1 -0
  19. package/Engines/WebGL/webGL2ShaderProcessors.js +4 -0
  20. package/Engines/WebGL/webGL2ShaderProcessors.js.map +1 -1
  21. package/Engines/WebGPU/webgpuDrawContext.js +1 -1
  22. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  23. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.d.ts +1 -0
  24. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +16 -7
  25. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  26. package/Engines/engine.js +4 -4
  27. package/Engines/engine.js.map +1 -1
  28. package/Engines/thinEngine.js +2 -2
  29. package/Engines/thinEngine.js.map +1 -1
  30. package/Layers/layer.d.ts +5 -0
  31. package/Layers/layer.js +16 -6
  32. package/Layers/layer.js.map +1 -1
  33. package/Lights/Shadows/cascadedShadowGenerator.js +14 -2
  34. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  35. package/Lights/Shadows/shadowGenerator.js +1 -0
  36. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  37. package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +4 -0
  38. package/Materials/Node/Blocks/PBR/anisotropyBlock.js +10 -0
  39. package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
  40. package/Materials/Node/Blocks/curveBlock.d.ts +97 -0
  41. package/Materials/Node/Blocks/curveBlock.js +287 -0
  42. package/Materials/Node/Blocks/curveBlock.js.map +1 -0
  43. package/Materials/Node/Blocks/index.d.ts +1 -0
  44. package/Materials/Node/Blocks/index.js +1 -0
  45. package/Materials/Node/Blocks/index.js.map +1 -1
  46. package/Materials/PBR/pbrAnisotropicConfiguration.d.ts +26 -0
  47. package/Materials/PBR/pbrAnisotropicConfiguration.js +47 -0
  48. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  49. package/Materials/Textures/multiRenderTarget.js +1 -2
  50. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  51. package/Materials/Textures/renderTargetTexture.d.ts +6 -1
  52. package/Materials/Textures/renderTargetTexture.js +5 -3
  53. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  54. package/Materials/materialDefines.js +1 -0
  55. package/Materials/materialDefines.js.map +1 -1
  56. package/Meshes/Builders/textBuilder.d.ts +2 -1
  57. package/Meshes/Builders/textBuilder.js +14 -2
  58. package/Meshes/Builders/textBuilder.js.map +1 -1
  59. package/Meshes/WebGPU/webgpuDataBuffer.d.ts +1 -1
  60. package/Meshes/WebGPU/webgpuDataBuffer.js +2 -1
  61. package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
  62. package/Meshes/mesh.js +10 -8
  63. package/Meshes/mesh.js.map +1 -1
  64. package/Meshes/transformNode.js +4 -0
  65. package/Meshes/transformNode.js.map +1 -1
  66. package/Misc/assetsManager.d.ts +78 -0
  67. package/Misc/assetsManager.js +60 -1
  68. package/Misc/assetsManager.js.map +1 -1
  69. package/Misc/filesInput.d.ts +1 -1
  70. package/Misc/filesInput.js +5 -5
  71. package/Misc/filesInput.js.map +1 -1
  72. package/Physics/v2/Plugins/havokPlugin.js +2 -2
  73. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  74. package/Physics/v2/physicsAggregate.d.ts +1 -0
  75. package/Physics/v2/physicsAggregate.js +6 -5
  76. package/Physics/v2/physicsAggregate.js.map +1 -1
  77. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +10 -1
  78. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +77 -10
  79. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  80. package/Rendering/depthRenderer.js +1 -0
  81. package/Rendering/depthRenderer.js.map +1 -1
  82. package/Rendering/prePassRenderer.d.ts +4 -0
  83. package/Rendering/prePassRenderer.js +14 -1
  84. package/Rendering/prePassRenderer.js.map +1 -1
  85. package/Shaders/ShadersInclude/pbrBlockAnisotropic.js +6 -3
  86. package/Shaders/ShadersInclude/pbrBlockAnisotropic.js.map +1 -1
  87. package/Shaders/ShadersInclude/pbrHelperFunctions.js +4 -1
  88. package/Shaders/ShadersInclude/pbrHelperFunctions.js.map +1 -1
  89. package/Shaders/ShadersInclude/screenSpaceRayTrace.js +4 -1
  90. package/Shaders/ShadersInclude/screenSpaceRayTrace.js.map +1 -1
  91. package/Shaders/glowMapGeneration.fragment.js +1 -1
  92. package/Shaders/glowMapGeneration.fragment.js.map +1 -1
  93. package/Shaders/pbr.fragment.js +1 -1
  94. package/Shaders/pbr.fragment.js.map +1 -1
  95. package/Shaders/screenSpaceReflection2.fragment.d.ts +1 -0
  96. package/Shaders/screenSpaceReflection2.fragment.js +16 -10
  97. package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
  98. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.d.ts +2 -0
  99. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
  100. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
  101. package/package.json +1 -1
  102. package/scene.js +24 -13
  103. package/scene.js.map +1 -1
@@ -54,6 +54,10 @@ export declare class AnisotropyBlock extends NodeMaterialBlock {
54
54
  * Gets the TBN input component
55
55
  */
56
56
  get TBN(): NodeMaterialConnectionPoint;
57
+ /**
58
+ * Gets the roughness input component
59
+ */
60
+ get roughness(): NodeMaterialConnectionPoint;
57
61
  /**
58
62
  * Gets the anisotropy object output component
59
63
  */
@@ -22,6 +22,7 @@ export class AnisotropyBlock extends NodeMaterialBlock {
22
22
  this.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, true); // need this property and the next one in case there's no PerturbNormal block connected to the main PBR block
23
23
  this.registerInput("worldTangent", NodeMaterialBlockConnectionPointTypes.Vector4, true);
24
24
  this.registerInput("TBN", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("TBN", this, NodeMaterialConnectionPointDirection.Input, TBNBlock, "TBNBlock"));
25
+ this.registerInput("roughness", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);
25
26
  this.registerOutput("anisotropy", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("anisotropy", this, NodeMaterialConnectionPointDirection.Output, AnisotropyBlock, "AnisotropyBlock"));
26
27
  }
27
28
  /**
@@ -70,6 +71,12 @@ export class AnisotropyBlock extends NodeMaterialBlock {
70
71
  get TBN() {
71
72
  return this._inputs[4];
72
73
  }
74
+ /**
75
+ * Gets the roughness input component
76
+ */
77
+ get roughness() {
78
+ return this._inputs[5];
79
+ }
73
80
  /**
74
81
  * Gets the anisotropy object output component
75
82
  */
@@ -129,9 +136,11 @@ export class AnisotropyBlock extends NodeMaterialBlock {
129
136
  }
130
137
  const intensity = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.0";
131
138
  const direction = this.direction.isConnected ? this.direction.associatedVariableName : "vec2(1., 0.)";
139
+ const roughness = this.roughness.isConnected ? this.roughness.associatedVariableName : "0.";
132
140
  code += `anisotropicOutParams anisotropicOut;
133
141
  anisotropicBlock(
134
142
  vec3(${direction}, ${intensity}),
143
+ ${roughness},
135
144
  #ifdef ANISOTROPIC_TEXTURE
136
145
  vec3(0.),
137
146
  #endif
@@ -146,6 +155,7 @@ export class AnisotropyBlock extends NodeMaterialBlock {
146
155
  super.prepareDefines(mesh, nodeMaterial, defines);
147
156
  defines.setValue("ANISOTROPIC", true);
148
157
  defines.setValue("ANISOTROPIC_TEXTURE", false, true);
158
+ defines.setValue("ANISOTROPIC_LEGACY", !this.roughness.isConnected);
149
159
  }
150
160
  bind(effect, nodeMaterial, mesh) {
151
161
  super.bind(effect, nodeMaterial, mesh);
@@ -1 +1 @@
1
- {"version":3,"file":"anisotropyBlock.js","sourceRoot":"","sources":["../../../../../../../lts/core/generated/Materials/Node/Blocks/PBR/anisotropyBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAG1G,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAclD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAlB3C,iCAA4B,GAAG,EAAE,CAAC;QAoBtC,IAAI,CAAC,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terial, NodeMaterialDefines } from \"../../nodeMaterial\";\r\nimport { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialConnectionPointDirection } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { AbstractMesh } from \"../../../../Meshes/abstractMesh\";\r\nimport { NodeMaterialConnectionPointCustomObject } from \"../../nodeMaterialConnectionPointCustomObject\";\r\nimport { TBNBlock } from \"../Fragment/TBNBlock\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport type { Effect } from \"../../../effect\";\r\n\r\n/**\r\n * Block used to implement the anisotropy module of the PBR material\r\n */\r\nexport class AnisotropyBlock extends NodeMaterialBlock {\r\n private _tangentCorrectionFactorName = \"\";\r\n\r\n /**\r\n * The two properties below are set by the main PBR block prior to calling methods of this class.\r\n * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.\r\n * It's less burden on the user side in the editor part.\r\n */\r\n\r\n /** @internal */\r\n public worldPositionConnectionPoint: NodeMaterialConnectionPoint;\r\n /** @internal */\r\n public worldNormalConnectionPoint: NodeMaterialConnectionPoint;\r\n\r\n /**\r\n * Create a new AnisotropyBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this._isUnique = true;\r\n\r\n this.registerInput(\"intensity\", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"direction\", NodeMaterialBlockConnectionPointTypes.Vector2, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"uv\", NodeMaterialBlockConnectionPointTypes.Vector2, true); // need this property and the next one in case there's no PerturbNormal block connected to the main PBR block\r\n this.registerInput(\"worldTangent\", NodeMaterialBlockConnectionPointTypes.Vector4, true);\r\n this.registerInput(\r\n \"TBN\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n true,\r\n NodeMaterialBlockTargets.VertexAndFragment,\r\n new NodeMaterialConnectionPointCustomObject(\"TBN\", this, NodeMaterialConnectionPointDirection.Input, TBNBlock, \"TBNBlock\")\r\n );\r\n\r\n this.registerOutput(\r\n \"anisotropy\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n NodeMaterialBlockTargets.Fragment,\r\n new NodeMaterialConnectionPointCustomObject(\"anisotropy\", this, NodeMaterialConnectionPointDirection.Output, AnisotropyBlock, \"AnisotropyBlock\")\r\n );\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"anisotropicOut\");\r\n state._excludeVariableName(\"TBN\");\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"AnisotropyBlock\";\r\n }\r\n\r\n /**\r\n * Gets the intensity input component\r\n */\r\n public get intensity(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction input component\r\n */\r\n public get direction(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the uv input component\r\n */\r\n public get uv(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the worldTangent input component\r\n */\r\n public get worldTangent(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the TBN input component\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get TBN(): NodeMaterialConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the anisotropy object output component\r\n */\r\n public get anisotropy(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private _generateTBNSpace(state: NodeMaterialBuildState) {\r\n let code = \"\";\r\n\r\n const comments = `//${this.name}`;\r\n const uv = this.uv;\r\n const worldPosition = this.worldPositionConnectionPoint;\r\n const worldNormal = this.worldNormalConnectionPoint;\r\n const worldTangent = this.worldTangent;\r\n\r\n if (!uv.isConnected) {\r\n // we must set the uv input as optional because we may not end up in this method (in case a PerturbNormal block is linked to the PBR material)\r\n // in which case uv is not required. But if we do come here, we do need the uv, so we have to raise an error but not with throw, else\r\n // it will stop the building of the node material and will lead to errors in the editor!\r\n console.error(\"You must connect the 'uv' input of the Anisotropy block!\");\r\n }\r\n\r\n state._emitExtension(\"derivatives\", \"#extension GL_OES_standard_derivatives : enable\");\r\n\r\n const tangentReplaceString = { search: /defined\\(TANGENT\\)/g, replace: worldTangent.isConnected ? \"defined(TANGENT)\" : \"defined(IGNORE)\" };\r\n\r\n const TBN = this.TBN;\r\n if (TBN.isConnected) {\r\n state.compilationString += `\r\n #ifdef TBNBLOCK\r\n mat3 vTBN = ${TBN.associatedVariableName};\r\n #endif\r\n `;\r\n } else if (worldTangent.isConnected) {\r\n code += `vec3 tbnNormal = normalize(${worldNormal.associatedVariableName}.xyz);\\r\\n`;\r\n code += `vec3 tbnTangent = normalize(${worldTangent.associatedVariableName}.xyz);\\r\\n`;\r\n code += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * ${this._tangentCorrectionFactorName};\\r\\n`;\r\n code += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\\r\\n`;\r\n }\r\n\r\n code += `\r\n #if defined(${worldTangent.isConnected ? \"TANGENT\" : \"IGNORE\"}) && defined(NORMAL)\r\n mat3 TBN = vTBN;\r\n #else\r\n mat3 TBN = cotangent_frame(${worldNormal.associatedVariableName + \".xyz\"}, ${\"v_\" + worldPosition.associatedVariableName + \".xyz\"}, ${\r\n uv.isConnected ? uv.associatedVariableName : \"vec2(0.)\"\r\n }, vec2(1., 1.));\r\n #endif\\r\\n`;\r\n\r\n state._emitFunctionFromInclude(\"bumpFragmentMainFunctions\", comments, {\r\n replaceStrings: [tangentReplaceString],\r\n });\r\n\r\n return code;\r\n }\r\n\r\n /**\r\n * Gets the main code of the block (fragment side)\r\n * @param state current state of the node material building\r\n * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated\r\n * @returns the shader code\r\n */\r\n public getCode(state: NodeMaterialBuildState, generateTBNSpace = false): string {\r\n let code = \"\";\r\n\r\n if (generateTBNSpace) {\r\n code += this._generateTBNSpace(state);\r\n }\r\n\r\n const intensity = this.intensity.isConnected ? this.intensity.associatedVariableName : \"1.0\";\r\n const direction = this.direction.isConnected ? this.direction.associatedVariableName : \"vec2(1., 0.)\";\r\n\r\n code += `anisotropicOutParams anisotropicOut;\r\n anisotropicBlock(\r\n vec3(${direction}, ${intensity}),\r\n #ifdef ANISOTROPIC_TEXTURE\r\n vec3(0.),\r\n #endif\r\n TBN,\r\n normalW,\r\n viewDirectionW,\r\n anisotropicOut\r\n );\\r\\n`;\r\n\r\n return code;\r\n }\r\n\r\n public prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {\r\n super.prepareDefines(mesh, nodeMaterial, defines);\r\n\r\n defines.setValue(\"ANISOTROPIC\", true);\r\n defines.setValue(\"ANISOTROPIC_TEXTURE\", false, true);\r\n }\r\n\r\n public bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {\r\n super.bind(effect, nodeMaterial, mesh);\r\n\r\n if (mesh) {\r\n effect.setFloat(this._tangentCorrectionFactorName, mesh.getWorldMatrix().determinant() < 0 ? -1 : 1);\r\n }\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n if (state.target === NodeMaterialBlockTargets.Fragment) {\r\n state.sharedData.blocksWithDefines.push(this);\r\n state.sharedData.bindableBlocks.push(this);\r\n\r\n this._tangentCorrectionFactorName = state._getFreeDefineName(\"tangentCorrectionFactor\");\r\n state._emitUniformFromString(this._tangentCorrectionFactorName, \"float\");\r\n }\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.AnisotropyBlock\", AnisotropyBlock);\r\n"]}
1
+ {"version":3,"file":"anisotropyBlock.js","sourceRoot":"","sources":["../../../../../../../lts/core/generated/Materials/Node/Blocks/PBR/anisotropyBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAG1G,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAclD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAlB3C,iCAA4B,GAAG,EAAE,CAAC;QAoBtC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACtH,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACxH,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI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,CAAC;SAC5E;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import type { NodeMaterial, NodeMaterialDefines } from \"../../nodeMaterial\";\r\nimport { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialConnectionPointDirection } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { AbstractMesh } from \"../../../../Meshes/abstractMesh\";\r\nimport { NodeMaterialConnectionPointCustomObject } from \"../../nodeMaterialConnectionPointCustomObject\";\r\nimport { TBNBlock } from \"../Fragment/TBNBlock\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport type { Effect } from \"../../../effect\";\r\n\r\n/**\r\n * Block used to implement the anisotropy module of the PBR material\r\n */\r\nexport class AnisotropyBlock extends NodeMaterialBlock {\r\n private _tangentCorrectionFactorName = \"\";\r\n\r\n /**\r\n * The two properties below are set by the main PBR block prior to calling methods of this class.\r\n * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.\r\n * It's less burden on the user side in the editor part.\r\n */\r\n\r\n /** @internal */\r\n public worldPositionConnectionPoint: NodeMaterialConnectionPoint;\r\n /** @internal */\r\n public worldNormalConnectionPoint: NodeMaterialConnectionPoint;\r\n\r\n /**\r\n * Create a new AnisotropyBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this._isUnique = true;\r\n\r\n this.registerInput(\"intensity\", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"direction\", NodeMaterialBlockConnectionPointTypes.Vector2, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"uv\", NodeMaterialBlockConnectionPointTypes.Vector2, true); // need this property and the next one in case there's no PerturbNormal block connected to the main PBR block\r\n this.registerInput(\"worldTangent\", NodeMaterialBlockConnectionPointTypes.Vector4, true);\r\n this.registerInput(\r\n \"TBN\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n true,\r\n NodeMaterialBlockTargets.VertexAndFragment,\r\n new NodeMaterialConnectionPointCustomObject(\"TBN\", this, NodeMaterialConnectionPointDirection.Input, TBNBlock, \"TBNBlock\")\r\n );\r\n this.registerInput(\"roughness\", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerOutput(\r\n \"anisotropy\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n NodeMaterialBlockTargets.Fragment,\r\n new NodeMaterialConnectionPointCustomObject(\"anisotropy\", this, NodeMaterialConnectionPointDirection.Output, AnisotropyBlock, \"AnisotropyBlock\")\r\n );\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"anisotropicOut\");\r\n state._excludeVariableName(\"TBN\");\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"AnisotropyBlock\";\r\n }\r\n\r\n /**\r\n * Gets the intensity input component\r\n */\r\n public get intensity(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction input component\r\n */\r\n public get direction(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the uv input component\r\n */\r\n public get uv(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the worldTangent input component\r\n */\r\n public get worldTangent(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the TBN input component\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get TBN(): NodeMaterialConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the roughness input component\r\n */\r\n public get roughness(): NodeMaterialConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the anisotropy object output component\r\n */\r\n public get anisotropy(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private _generateTBNSpace(state: NodeMaterialBuildState) {\r\n let code = \"\";\r\n\r\n const comments = `//${this.name}`;\r\n const uv = this.uv;\r\n const worldPosition = this.worldPositionConnectionPoint;\r\n const worldNormal = this.worldNormalConnectionPoint;\r\n const worldTangent = this.worldTangent;\r\n\r\n if (!uv.isConnected) {\r\n // we must set the uv input as optional because we may not end up in this method (in case a PerturbNormal block is linked to the PBR material)\r\n // in which case uv is not required. But if we do come here, we do need the uv, so we have to raise an error but not with throw, else\r\n // it will stop the building of the node material and will lead to errors in the editor!\r\n console.error(\"You must connect the 'uv' input of the Anisotropy block!\");\r\n }\r\n\r\n state._emitExtension(\"derivatives\", \"#extension GL_OES_standard_derivatives : enable\");\r\n\r\n const tangentReplaceString = { search: /defined\\(TANGENT\\)/g, replace: worldTangent.isConnected ? \"defined(TANGENT)\" : \"defined(IGNORE)\" };\r\n\r\n const TBN = this.TBN;\r\n if (TBN.isConnected) {\r\n state.compilationString += `\r\n #ifdef TBNBLOCK\r\n mat3 vTBN = ${TBN.associatedVariableName};\r\n #endif\r\n `;\r\n } else if (worldTangent.isConnected) {\r\n code += `vec3 tbnNormal = normalize(${worldNormal.associatedVariableName}.xyz);\\r\\n`;\r\n code += `vec3 tbnTangent = normalize(${worldTangent.associatedVariableName}.xyz);\\r\\n`;\r\n code += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent) * ${this._tangentCorrectionFactorName};\\r\\n`;\r\n code += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\\r\\n`;\r\n }\r\n\r\n code += `\r\n #if defined(${worldTangent.isConnected ? \"TANGENT\" : \"IGNORE\"}) && defined(NORMAL)\r\n mat3 TBN = vTBN;\r\n #else\r\n mat3 TBN = cotangent_frame(${worldNormal.associatedVariableName + \".xyz\"}, ${\"v_\" + worldPosition.associatedVariableName + \".xyz\"}, ${\r\n uv.isConnected ? uv.associatedVariableName : \"vec2(0.)\"\r\n }, vec2(1., 1.));\r\n #endif\\r\\n`;\r\n\r\n state._emitFunctionFromInclude(\"bumpFragmentMainFunctions\", comments, {\r\n replaceStrings: [tangentReplaceString],\r\n });\r\n\r\n return code;\r\n }\r\n\r\n /**\r\n * Gets the main code of the block (fragment side)\r\n * @param state current state of the node material building\r\n * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated\r\n * @returns the shader code\r\n */\r\n public getCode(state: NodeMaterialBuildState, generateTBNSpace = false): string {\r\n let code = \"\";\r\n\r\n if (generateTBNSpace) {\r\n code += this._generateTBNSpace(state);\r\n }\r\n\r\n const intensity = this.intensity.isConnected ? this.intensity.associatedVariableName : \"1.0\";\r\n const direction = this.direction.isConnected ? this.direction.associatedVariableName : \"vec2(1., 0.)\";\r\n const roughness = this.roughness.isConnected ? this.roughness.associatedVariableName : \"0.\";\r\n\r\n code += `anisotropicOutParams anisotropicOut;\r\n anisotropicBlock(\r\n vec3(${direction}, ${intensity}),\r\n ${roughness},\r\n #ifdef ANISOTROPIC_TEXTURE\r\n vec3(0.),\r\n #endif\r\n TBN,\r\n normalW,\r\n viewDirectionW,\r\n anisotropicOut\r\n );\\r\\n`;\r\n\r\n return code;\r\n }\r\n\r\n public prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {\r\n super.prepareDefines(mesh, nodeMaterial, defines);\r\n\r\n defines.setValue(\"ANISOTROPIC\", true);\r\n defines.setValue(\"ANISOTROPIC_TEXTURE\", false, true);\r\n defines.setValue(\"ANISOTROPIC_LEGACY\", !this.roughness.isConnected);\r\n }\r\n\r\n public bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {\r\n super.bind(effect, nodeMaterial, mesh);\r\n\r\n if (mesh) {\r\n effect.setFloat(this._tangentCorrectionFactorName, mesh.getWorldMatrix().determinant() < 0 ? -1 : 1);\r\n }\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n if (state.target === NodeMaterialBlockTargets.Fragment) {\r\n state.sharedData.blocksWithDefines.push(this);\r\n state.sharedData.bindableBlocks.push(this);\r\n\r\n this._tangentCorrectionFactorName = state._getFreeDefineName(\"tangentCorrectionFactor\");\r\n state._emitUniformFromString(this._tangentCorrectionFactorName, \"float\");\r\n }\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.AnisotropyBlock\", AnisotropyBlock);\r\n"]}
@@ -0,0 +1,97 @@
1
+ import { NodeMaterialBlock } from "../nodeMaterialBlock";
2
+ import type { NodeMaterialBuildState } from "../nodeMaterialBuildState";
3
+ import type { NodeMaterialConnectionPoint } from "../nodeMaterialBlockConnectionPoint";
4
+ import type { Scene } from "../../../scene";
5
+ /**
6
+ * Types of curves supported by the Curve block
7
+ */
8
+ export declare enum CurveBlockTypes {
9
+ /** EaseInSine */
10
+ EaseInSine = 0,
11
+ /** EaseOutSine */
12
+ EaseOutSine = 1,
13
+ /** EaseInOutSine */
14
+ EaseInOutSine = 2,
15
+ /** EaseInQuad */
16
+ EaseInQuad = 3,
17
+ /** EaseOutQuad */
18
+ EaseOutQuad = 4,
19
+ /** EaseInOutQuad */
20
+ EaseInOutQuad = 5,
21
+ /** EaseInCubic */
22
+ EaseInCubic = 6,
23
+ /** EaseOutCubic */
24
+ EaseOutCubic = 7,
25
+ /** EaseInOutCubic */
26
+ EaseInOutCubic = 8,
27
+ /** EaseInQuart */
28
+ EaseInQuart = 9,
29
+ /** EaseOutQuart */
30
+ EaseOutQuart = 10,
31
+ /** EaseInOutQuart */
32
+ EaseInOutQuart = 11,
33
+ /** EaseInQuint */
34
+ EaseInQuint = 12,
35
+ /** EaseOutQuint */
36
+ EaseOutQuint = 13,
37
+ /** EaseInOutQuint */
38
+ EaseInOutQuint = 14,
39
+ /** EaseInExpo */
40
+ EaseInExpo = 15,
41
+ /** EaseOutExpo */
42
+ EaseOutExpo = 16,
43
+ /** EaseInOutExpo */
44
+ EaseInOutExpo = 17,
45
+ /** EaseInCirc */
46
+ EaseInCirc = 18,
47
+ /** EaseOutCirc */
48
+ EaseOutCirc = 19,
49
+ /** EaseInOutCirc */
50
+ EaseInOutCirc = 20,
51
+ /** EaseInBack */
52
+ EaseInBack = 21,
53
+ /** EaseOutBack */
54
+ EaseOutBack = 22,
55
+ /** EaseInOutBack */
56
+ EaseInOutBack = 23,
57
+ /** EaseInElastic */
58
+ EaseInElastic = 24,
59
+ /** EaseOutElastic */
60
+ EaseOutElastic = 25,
61
+ /** EaseInOutElastic */
62
+ EaseInOutElastic = 26
63
+ }
64
+ /**
65
+ * Block used to apply curve operation
66
+ */
67
+ export declare class CurveBlock extends NodeMaterialBlock {
68
+ /**
69
+ * Gets or sets the type of the curve applied by the block
70
+ */
71
+ type: CurveBlockTypes;
72
+ /**
73
+ * Creates a new CurveBlock
74
+ * @param name defines the block name
75
+ */
76
+ constructor(name: string);
77
+ /**
78
+ * Gets the current class name
79
+ * @returns the class name
80
+ */
81
+ getClassName(): string;
82
+ /**
83
+ * Gets the input component
84
+ */
85
+ get input(): NodeMaterialConnectionPoint;
86
+ /**
87
+ * Gets the output component
88
+ */
89
+ get output(): NodeMaterialConnectionPoint;
90
+ private _duplicateEntry;
91
+ private _duplicateEntryDirect;
92
+ private _duplicateVector;
93
+ protected _buildBlock(state: NodeMaterialBuildState): this;
94
+ serialize(): any;
95
+ _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
96
+ protected _dumpPropertiesCode(): string;
97
+ }
@@ -0,0 +1,287 @@
1
+ import { NodeMaterialBlock } from "../nodeMaterialBlock.js";
2
+ import { NodeMaterialBlockConnectionPointTypes } from "../Enums/nodeMaterialBlockConnectionPointTypes.js";
3
+ import { NodeMaterialBlockTargets } from "../Enums/nodeMaterialBlockTargets.js";
4
+ import { RegisterClass } from "../../../Misc/typeStore.js";
5
+ /**
6
+ * Types of curves supported by the Curve block
7
+ */
8
+ export var CurveBlockTypes;
9
+ (function (CurveBlockTypes) {
10
+ /** EaseInSine */
11
+ CurveBlockTypes[CurveBlockTypes["EaseInSine"] = 0] = "EaseInSine";
12
+ /** EaseOutSine */
13
+ CurveBlockTypes[CurveBlockTypes["EaseOutSine"] = 1] = "EaseOutSine";
14
+ /** EaseInOutSine */
15
+ CurveBlockTypes[CurveBlockTypes["EaseInOutSine"] = 2] = "EaseInOutSine";
16
+ /** EaseInQuad */
17
+ CurveBlockTypes[CurveBlockTypes["EaseInQuad"] = 3] = "EaseInQuad";
18
+ /** EaseOutQuad */
19
+ CurveBlockTypes[CurveBlockTypes["EaseOutQuad"] = 4] = "EaseOutQuad";
20
+ /** EaseInOutQuad */
21
+ CurveBlockTypes[CurveBlockTypes["EaseInOutQuad"] = 5] = "EaseInOutQuad";
22
+ /** EaseInCubic */
23
+ CurveBlockTypes[CurveBlockTypes["EaseInCubic"] = 6] = "EaseInCubic";
24
+ /** EaseOutCubic */
25
+ CurveBlockTypes[CurveBlockTypes["EaseOutCubic"] = 7] = "EaseOutCubic";
26
+ /** EaseInOutCubic */
27
+ CurveBlockTypes[CurveBlockTypes["EaseInOutCubic"] = 8] = "EaseInOutCubic";
28
+ /** EaseInQuart */
29
+ CurveBlockTypes[CurveBlockTypes["EaseInQuart"] = 9] = "EaseInQuart";
30
+ /** EaseOutQuart */
31
+ CurveBlockTypes[CurveBlockTypes["EaseOutQuart"] = 10] = "EaseOutQuart";
32
+ /** EaseInOutQuart */
33
+ CurveBlockTypes[CurveBlockTypes["EaseInOutQuart"] = 11] = "EaseInOutQuart";
34
+ /** EaseInQuint */
35
+ CurveBlockTypes[CurveBlockTypes["EaseInQuint"] = 12] = "EaseInQuint";
36
+ /** EaseOutQuint */
37
+ CurveBlockTypes[CurveBlockTypes["EaseOutQuint"] = 13] = "EaseOutQuint";
38
+ /** EaseInOutQuint */
39
+ CurveBlockTypes[CurveBlockTypes["EaseInOutQuint"] = 14] = "EaseInOutQuint";
40
+ /** EaseInExpo */
41
+ CurveBlockTypes[CurveBlockTypes["EaseInExpo"] = 15] = "EaseInExpo";
42
+ /** EaseOutExpo */
43
+ CurveBlockTypes[CurveBlockTypes["EaseOutExpo"] = 16] = "EaseOutExpo";
44
+ /** EaseInOutExpo */
45
+ CurveBlockTypes[CurveBlockTypes["EaseInOutExpo"] = 17] = "EaseInOutExpo";
46
+ /** EaseInCirc */
47
+ CurveBlockTypes[CurveBlockTypes["EaseInCirc"] = 18] = "EaseInCirc";
48
+ /** EaseOutCirc */
49
+ CurveBlockTypes[CurveBlockTypes["EaseOutCirc"] = 19] = "EaseOutCirc";
50
+ /** EaseInOutCirc */
51
+ CurveBlockTypes[CurveBlockTypes["EaseInOutCirc"] = 20] = "EaseInOutCirc";
52
+ /** EaseInBack */
53
+ CurveBlockTypes[CurveBlockTypes["EaseInBack"] = 21] = "EaseInBack";
54
+ /** EaseOutBack */
55
+ CurveBlockTypes[CurveBlockTypes["EaseOutBack"] = 22] = "EaseOutBack";
56
+ /** EaseInOutBack */
57
+ CurveBlockTypes[CurveBlockTypes["EaseInOutBack"] = 23] = "EaseInOutBack";
58
+ /** EaseInElastic */
59
+ CurveBlockTypes[CurveBlockTypes["EaseInElastic"] = 24] = "EaseInElastic";
60
+ /** EaseOutElastic */
61
+ CurveBlockTypes[CurveBlockTypes["EaseOutElastic"] = 25] = "EaseOutElastic";
62
+ /** EaseInOutElastic */
63
+ CurveBlockTypes[CurveBlockTypes["EaseInOutElastic"] = 26] = "EaseInOutElastic";
64
+ })(CurveBlockTypes || (CurveBlockTypes = {}));
65
+ /**
66
+ * Block used to apply curve operation
67
+ */
68
+ export class CurveBlock extends NodeMaterialBlock {
69
+ /**
70
+ * Creates a new CurveBlock
71
+ * @param name defines the block name
72
+ */
73
+ constructor(name) {
74
+ super(name, NodeMaterialBlockTargets.Neutral);
75
+ /**
76
+ * Gets or sets the type of the curve applied by the block
77
+ */
78
+ this.type = CurveBlockTypes.EaseInOutSine;
79
+ this.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect);
80
+ this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput);
81
+ this._outputs[0]._typeConnectionSource = this._inputs[0];
82
+ this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix);
83
+ this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Object);
84
+ this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Int);
85
+ }
86
+ /**
87
+ * Gets the current class name
88
+ * @returns the class name
89
+ */
90
+ getClassName() {
91
+ return "CurveBlock";
92
+ }
93
+ /**
94
+ * Gets the input component
95
+ */
96
+ get input() {
97
+ return this._inputs[0];
98
+ }
99
+ /**
100
+ * Gets the output component
101
+ */
102
+ get output() {
103
+ return this._outputs[0];
104
+ }
105
+ _duplicateEntry(entry, component) {
106
+ return `ret.${component} = ${entry.replace(/VAL/g, "v." + component)}`;
107
+ }
108
+ _duplicateEntryDirect(entry) {
109
+ return `return ${entry.replace(/VAL/g, "v")}`;
110
+ }
111
+ _duplicateVector(entry, inputType) {
112
+ if (inputType === "float") {
113
+ return this._duplicateEntryDirect(entry);
114
+ }
115
+ const size = parseInt(inputType.replace("vec", ""));
116
+ let code = `
117
+ vec${size} ret = vec${size}(0.0);
118
+ `;
119
+ for (let i = 1; i <= size; i++) {
120
+ code += this._duplicateEntry(entry, i === 1 ? "x" : i === 2 ? "y" : i === 3 ? "z" : "w") + ";\r\n";
121
+ }
122
+ code += "return ret;\r\n";
123
+ return code;
124
+ }
125
+ _buildBlock(state) {
126
+ super._buildBlock(state);
127
+ const output = this._outputs[0];
128
+ let registeredFunction = "";
129
+ let registeredFunctionName = "";
130
+ let inputType = "";
131
+ switch (this.input.type) {
132
+ case NodeMaterialBlockConnectionPointTypes.Float:
133
+ inputType = "float";
134
+ break;
135
+ case NodeMaterialBlockConnectionPointTypes.Vector2:
136
+ inputType = "vec2";
137
+ break;
138
+ case NodeMaterialBlockConnectionPointTypes.Vector3:
139
+ case NodeMaterialBlockConnectionPointTypes.Color3:
140
+ inputType = "vec3";
141
+ break;
142
+ case NodeMaterialBlockConnectionPointTypes.Vector4:
143
+ case NodeMaterialBlockConnectionPointTypes.Color4:
144
+ inputType = "vec4";
145
+ break;
146
+ }
147
+ registeredFunctionName = CurveBlockTypes[this.type] + "_" + inputType;
148
+ switch (this.type) {
149
+ case CurveBlockTypes.EaseInSine:
150
+ registeredFunction = `return 1.0 - cos((v * 3.1415) / 2.0)`;
151
+ break;
152
+ case CurveBlockTypes.EaseOutSine:
153
+ registeredFunction = `return sin((v * 3.1415) / 2.0)`;
154
+ break;
155
+ case CurveBlockTypes.EaseInOutSine:
156
+ registeredFunction = `return -(cos(v * 3.1415) - 1.0) / 2.0`;
157
+ break;
158
+ case CurveBlockTypes.EaseInQuad:
159
+ registeredFunction = `return v * v`;
160
+ break;
161
+ case CurveBlockTypes.EaseOutQuad:
162
+ registeredFunction = `return (1.0 - v) * (1.0 - v)`;
163
+ break;
164
+ case CurveBlockTypes.EaseInOutQuad: {
165
+ const entry = "VAL < 0.5 ? 2.0 * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 2.0) / 2.0";
166
+ registeredFunction = this._duplicateVector(entry, inputType);
167
+ break;
168
+ }
169
+ case CurveBlockTypes.EaseInCubic:
170
+ registeredFunction = `return v * v * v`;
171
+ break;
172
+ case CurveBlockTypes.EaseOutCubic: {
173
+ const entry = "1.0 - pow(1.0 - VAL, 3.0)";
174
+ registeredFunction = this._duplicateVector(entry, inputType);
175
+ break;
176
+ }
177
+ case CurveBlockTypes.EaseInOutCubic: {
178
+ const entry = "VAL < 0.5 ? 4.0 * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 3.0) / 2.0";
179
+ registeredFunction = this._duplicateVector(entry, inputType);
180
+ break;
181
+ }
182
+ case CurveBlockTypes.EaseInQuart:
183
+ registeredFunction = `return v * v * v * v`;
184
+ break;
185
+ case CurveBlockTypes.EaseOutQuart: {
186
+ const entry = "1.0 - pow(1.0 - VAL, 4.0)";
187
+ registeredFunction = this._duplicateVector(entry, inputType);
188
+ break;
189
+ }
190
+ case CurveBlockTypes.EaseInOutQuart: {
191
+ const entry = "VAL < 0.5 ? 8.0 * VAL * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 4.0) / 2.0";
192
+ registeredFunction = this._duplicateVector(entry, inputType);
193
+ break;
194
+ }
195
+ case CurveBlockTypes.EaseInQuint:
196
+ registeredFunction = `return v * v * v * v * v`;
197
+ break;
198
+ case CurveBlockTypes.EaseOutQuint: {
199
+ const entry = "1.0 - pow(1.0 - VAL, 5.0)";
200
+ registeredFunction = this._duplicateVector(entry, inputType);
201
+ break;
202
+ }
203
+ case CurveBlockTypes.EaseInOutQuint: {
204
+ const entry = "VAL < 0.5 ? 16.0 * VAL * VAL * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 5.0) / 2.0";
205
+ registeredFunction = this._duplicateVector(entry, inputType);
206
+ break;
207
+ }
208
+ case CurveBlockTypes.EaseInExpo: {
209
+ const entry = "VAL == 0.0 ? 0.0 : pow(2.0, 10.0 * VAL - 10.0)";
210
+ registeredFunction = this._duplicateVector(entry, inputType);
211
+ break;
212
+ }
213
+ case CurveBlockTypes.EaseOutExpo: {
214
+ const entry = "VAL == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * VAL)";
215
+ registeredFunction = this._duplicateVector(entry, inputType);
216
+ break;
217
+ }
218
+ case CurveBlockTypes.EaseInOutExpo: {
219
+ const entry = "VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : VAL < 0.5 ? pow(2.0, 20.0 * VAL - 10.0) / 2.0 : (2.0 - pow(2.0, -20.0 * VAL + 10.0)) / 2.0";
220
+ registeredFunction = this._duplicateVector(entry, inputType);
221
+ break;
222
+ }
223
+ case CurveBlockTypes.EaseInCirc: {
224
+ const entry = "1.0 - sqrt(1.0 - pow(VAL, 2.0))";
225
+ registeredFunction = this._duplicateVector(entry, inputType);
226
+ break;
227
+ }
228
+ case CurveBlockTypes.EaseOutCirc: {
229
+ const entry = "sqrt(1.0 - pow(VAL - 1.0, 2.0))";
230
+ registeredFunction = this._duplicateVector(entry, inputType);
231
+ break;
232
+ }
233
+ case CurveBlockTypes.EaseInOutCirc: {
234
+ const entry = "VAL < 0.5 ? (1.0 - sqrt(1.0 - pow(2.0 * VAL, 2.0))) / 2.0 : (sqrt(1.0 - pow(-2.0 * VAL + 2.0, 2.0)) + 1.0) / 2.0";
235
+ registeredFunction = this._duplicateVector(entry, inputType);
236
+ break;
237
+ }
238
+ case CurveBlockTypes.EaseInBack: {
239
+ registeredFunction = "return 2.70158 * v * v * v - 1.70158 * v * v";
240
+ break;
241
+ }
242
+ case CurveBlockTypes.EaseOutBack: {
243
+ const entry = "2.70158 * pow(VAL - 1.0, 3.0) + 1.70158 * pow(VAL - 1.0, 2.0)";
244
+ registeredFunction = this._duplicateVector(entry, inputType);
245
+ break;
246
+ }
247
+ case CurveBlockTypes.EaseInOutBack: {
248
+ const entry = "VAL < 0.5 ? (pow(2.0 * VAL, 2.0) * ((3.5949095) * 2.0 * VAL - 2.5949095)) / 2.0 : (pow(2.0 * VAL - 2.0, 2.0) * (3.5949095 * (VAL * 2.0 - 2.0) + 3.5949095) + 2.0) / 2.0";
249
+ registeredFunction = this._duplicateVector(entry, inputType);
250
+ break;
251
+ }
252
+ case CurveBlockTypes.EaseInElastic: {
253
+ const entry = "VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : -pow(2.0, 10.0 * VAL - 10.0) * sin((VAL * 10.0 - 10.75) * ((2.0 * 3.1415) / 3.0))";
254
+ registeredFunction = this._duplicateVector(entry, inputType);
255
+ break;
256
+ }
257
+ case CurveBlockTypes.EaseOutElastic: {
258
+ const entry = "VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : pow(2.0, -10.0 * VAL) * sin((VAL * 10.0 - 0.75) * ((2.0 * 3.1415) / 3.0)) + 1.0";
259
+ registeredFunction = this._duplicateVector(entry, inputType);
260
+ break;
261
+ }
262
+ case CurveBlockTypes.EaseInOutElastic: {
263
+ const entry = "VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : VAL < 0.5 ? -(pow(2.0, 20.0 * VAL - 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0 : (pow(2.0, -20.0 * VAL + 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0 + 1.0";
264
+ registeredFunction = this._duplicateVector(entry, inputType);
265
+ break;
266
+ }
267
+ }
268
+ state._emitFunction(registeredFunctionName, `${inputType} ${registeredFunctionName}(${inputType} v) {${registeredFunction};}\r\n`, "");
269
+ state.compilationString += this._declareOutput(output, state) + ` = ${registeredFunctionName}(${this.input.associatedVariableName});\r\n`;
270
+ return this;
271
+ }
272
+ serialize() {
273
+ const serializationObject = super.serialize();
274
+ serializationObject.curveType = this.type;
275
+ return serializationObject;
276
+ }
277
+ _deserialize(serializationObject, scene, rootUrl) {
278
+ super._deserialize(serializationObject, scene, rootUrl);
279
+ this.type = serializationObject.curveType;
280
+ }
281
+ _dumpPropertiesCode() {
282
+ const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.type = BABYLON.CurveBlockTypes.${CurveBlockTypes[this.type]};\r\n`;
283
+ return codeString;
284
+ }
285
+ }
286
+ RegisterClass("BABYLON.CurveBlock", CurveBlock);
287
+ //# sourceMappingURL=curveBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curveBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/curveBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD;;GAEG;AACH,MAAM,CAAN,IAAY,eAuDX;AAvDD,WAAY,eAAe;IACvB,iBAAiB;IACjB,iEAAU,CAAA;IACV,kBAAkB;IAClB,mEAAW,CAAA;IACX,oBAAoB;IACpB,uEAAa,CAAA;IACb,iBAAiB;IACjB,iEAAU,CAAA;IACV,kBAAkB;IAClB,mEAAW,CAAA;IACX,oBAAoB;IACpB,uEAAa,CAAA;IACb,kBAAkB;IAClB,mEAAW,CAAA;IACX,mBAAmB;IACnB,qEAAY,CAAA;IACZ,qBAAqB;IACrB,yEAAc,CAAA;IACd,kBAAkB;IAClB,mEAAW,CAAA;IACX,mBAAmB;IACnB,sEAAY,CAAA;IACZ,qBAAqB;IACrB,0EAAc,CAAA;IACd,kBAAkB;IAClB,oEAAW,CAAA;IACX,mBAAmB;IACnB,sEAAY,CAAA;IACZ,qBAAqB;IACrB,0EAAc,CAAA;IACd,iBAAiB;IACjB,kEAAU,CAAA;IACV,kBAAkB;IAClB,oEAAW,CAAA;IACX,oBAAoB;IACpB,wEAAa,CAAA;IACb,iBAAiB;IACjB,kEAAU,CAAA;IACV,kBAAkB;IAClB,oEAAW,CAAA;IACX,oBAAoB;IACpB,wEAAa,CAAA;IACb,iBAAiB;IACjB,kEAAU,CAAA;IACV,kBAAkB;IAClB,oEAAW,CAAA;IACX,oBAAoB;IACpB,wEAAa,CAAA;IACb,oBAAoB;IACpB,wEAAa,CAAA;IACb,qBAAqB;IACrB,0EAAc,CAAA;IAC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EM,YAAY,CAAC,mBAAwB,EAAE,KAAY,EAAE,OAAe;QACvE,KAAK,CAAC,YAAY,CAAC,mBAAmB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAExD,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC,SAAS,CAAC;IAC9C,CAAC;IAES,mBAAmB;QACzB,MAAM,UAAU,GAAG,KAAK,CAAC,mBAAmB,EAAE,GAAG,GAAG,IAAI,CAAC,iBAAiB,mCAAmC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QAC/I,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAED,aAAa,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { Scene } from \"../../../scene\";\r\n\r\n/**\r\n * Types of curves supported by the Curve block\r\n */\r\nexport enum CurveBlockTypes {\r\n /** EaseInSine */\r\n EaseInSine,\r\n /** EaseOutSine */\r\n EaseOutSine,\r\n /** EaseInOutSine */\r\n EaseInOutSine,\r\n /** EaseInQuad */\r\n EaseInQuad,\r\n /** EaseOutQuad */\r\n EaseOutQuad,\r\n /** EaseInOutQuad */\r\n EaseInOutQuad,\r\n /** EaseInCubic */\r\n EaseInCubic,\r\n /** EaseOutCubic */\r\n EaseOutCubic,\r\n /** EaseInOutCubic */\r\n EaseInOutCubic,\r\n /** EaseInQuart */\r\n EaseInQuart,\r\n /** EaseOutQuart */\r\n EaseOutQuart,\r\n /** EaseInOutQuart */\r\n EaseInOutQuart,\r\n /** EaseInQuint */\r\n EaseInQuint,\r\n /** EaseOutQuint */\r\n EaseOutQuint,\r\n /** EaseInOutQuint */\r\n EaseInOutQuint,\r\n /** EaseInExpo */\r\n EaseInExpo,\r\n /** EaseOutExpo */\r\n EaseOutExpo,\r\n /** EaseInOutExpo */\r\n EaseInOutExpo,\r\n /** EaseInCirc */\r\n EaseInCirc,\r\n /** EaseOutCirc */\r\n EaseOutCirc,\r\n /** EaseInOutCirc */\r\n EaseInOutCirc,\r\n /** EaseInBack */\r\n EaseInBack,\r\n /** EaseOutBack */\r\n EaseOutBack,\r\n /** EaseInOutBack */\r\n EaseInOutBack,\r\n /** EaseInElastic */\r\n EaseInElastic,\r\n /** EaseOutElastic */\r\n EaseOutElastic,\r\n /** EaseInOutElastic */\r\n EaseInOutElastic,\r\n}\r\n\r\n/**\r\n * Block used to apply curve operation\r\n */\r\nexport class CurveBlock extends NodeMaterialBlock {\r\n /**\r\n * Gets or sets the type of the curve applied by the block\r\n */\r\n public type = CurveBlockTypes.EaseInOutSine;\r\n\r\n /**\r\n * Creates a new CurveBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"input\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Object);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Int);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"CurveBlock\";\r\n }\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private _duplicateEntry(entry: string, component: string) {\r\n return `ret.${component} = ${entry.replace(/VAL/g, \"v.\" + component)}`;\r\n }\r\n\r\n private _duplicateEntryDirect(entry: string) {\r\n return `return ${entry.replace(/VAL/g, \"v\")}`;\r\n }\r\n\r\n private _duplicateVector(entry: string, inputType: string) {\r\n if (inputType === \"float\") {\r\n return this._duplicateEntryDirect(entry);\r\n }\r\n\r\n const size = parseInt(inputType.replace(\"vec\", \"\"));\r\n let code = `\r\n vec${size} ret = vec${size}(0.0);\r\n `;\r\n\r\n for (let i = 1; i <= size; i++) {\r\n code += this._duplicateEntry(entry, i === 1 ? \"x\" : i === 2 ? \"y\" : i === 3 ? \"z\" : \"w\") + \";\\r\\n\";\r\n }\r\n\r\n code += \"return ret;\\r\\n\";\r\n return code;\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n let registeredFunction = \"\";\r\n let registeredFunctionName = \"\";\r\n\r\n let inputType = \"\";\r\n\r\n switch (this.input.type) {\r\n case NodeMaterialBlockConnectionPointTypes.Float:\r\n inputType = \"float\";\r\n break;\r\n case NodeMaterialBlockConnectionPointTypes.Vector2:\r\n inputType = \"vec2\";\r\n break;\r\n case NodeMaterialBlockConnectionPointTypes.Vector3:\r\n case NodeMaterialBlockConnectionPointTypes.Color3:\r\n inputType = \"vec3\";\r\n break;\r\n case NodeMaterialBlockConnectionPointTypes.Vector4:\r\n case NodeMaterialBlockConnectionPointTypes.Color4:\r\n inputType = \"vec4\";\r\n break;\r\n }\r\n\r\n registeredFunctionName = CurveBlockTypes[this.type] + \"_\" + inputType;\r\n\r\n switch (this.type) {\r\n case CurveBlockTypes.EaseInSine:\r\n registeredFunction = `return 1.0 - cos((v * 3.1415) / 2.0)`;\r\n break;\r\n case CurveBlockTypes.EaseOutSine:\r\n registeredFunction = `return sin((v * 3.1415) / 2.0)`;\r\n break;\r\n case CurveBlockTypes.EaseInOutSine:\r\n registeredFunction = `return -(cos(v * 3.1415) - 1.0) / 2.0`;\r\n break;\r\n case CurveBlockTypes.EaseInQuad:\r\n registeredFunction = `return v * v`;\r\n break;\r\n case CurveBlockTypes.EaseOutQuad:\r\n registeredFunction = `return (1.0 - v) * (1.0 - v)`;\r\n break;\r\n case CurveBlockTypes.EaseInOutQuad: {\r\n const entry = \"VAL < 0.5 ? 2.0 * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 2.0) / 2.0\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInCubic:\r\n registeredFunction = `return v * v * v`;\r\n break;\r\n case CurveBlockTypes.EaseOutCubic: {\r\n const entry = \"1.0 - pow(1.0 - VAL, 3.0)\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInOutCubic: {\r\n const entry = \"VAL < 0.5 ? 4.0 * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 3.0) / 2.0\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInQuart:\r\n registeredFunction = `return v * v * v * v`;\r\n break;\r\n case CurveBlockTypes.EaseOutQuart: {\r\n const entry = \"1.0 - pow(1.0 - VAL, 4.0)\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInOutQuart: {\r\n const entry = \"VAL < 0.5 ? 8.0 * VAL * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 4.0) / 2.0\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInQuint:\r\n registeredFunction = `return v * v * v * v * v`;\r\n break;\r\n case CurveBlockTypes.EaseOutQuint: {\r\n const entry = \"1.0 - pow(1.0 - VAL, 5.0)\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInOutQuint: {\r\n const entry = \"VAL < 0.5 ? 16.0 * VAL * VAL * VAL * VAL * VAL : 1.0 - pow(-2.0 * VAL + 2.0, 5.0) / 2.0\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInExpo: {\r\n const entry = \"VAL == 0.0 ? 0.0 : pow(2.0, 10.0 * VAL - 10.0)\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseOutExpo: {\r\n const entry = \"VAL == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * VAL)\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInOutExpo: {\r\n const entry = \"VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : VAL < 0.5 ? pow(2.0, 20.0 * VAL - 10.0) / 2.0 : (2.0 - pow(2.0, -20.0 * VAL + 10.0)) / 2.0\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInCirc: {\r\n const entry = \"1.0 - sqrt(1.0 - pow(VAL, 2.0))\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseOutCirc: {\r\n const entry = \"sqrt(1.0 - pow(VAL - 1.0, 2.0))\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInOutCirc: {\r\n const entry = \"VAL < 0.5 ? (1.0 - sqrt(1.0 - pow(2.0 * VAL, 2.0))) / 2.0 : (sqrt(1.0 - pow(-2.0 * VAL + 2.0, 2.0)) + 1.0) / 2.0\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInBack: {\r\n registeredFunction = \"return 2.70158 * v * v * v - 1.70158 * v * v\";\r\n break;\r\n }\r\n case CurveBlockTypes.EaseOutBack: {\r\n const entry = \"2.70158 * pow(VAL - 1.0, 3.0) + 1.70158 * pow(VAL - 1.0, 2.0)\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInOutBack: {\r\n const entry =\r\n \"VAL < 0.5 ? (pow(2.0 * VAL, 2.0) * ((3.5949095) * 2.0 * VAL - 2.5949095)) / 2.0 : (pow(2.0 * VAL - 2.0, 2.0) * (3.5949095 * (VAL * 2.0 - 2.0) + 3.5949095) + 2.0) / 2.0\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInElastic: {\r\n const entry = \"VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : -pow(2.0, 10.0 * VAL - 10.0) * sin((VAL * 10.0 - 10.75) * ((2.0 * 3.1415) / 3.0))\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseOutElastic: {\r\n const entry = \"VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : pow(2.0, -10.0 * VAL) * sin((VAL * 10.0 - 0.75) * ((2.0 * 3.1415) / 3.0)) + 1.0\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n case CurveBlockTypes.EaseInOutElastic: {\r\n const entry =\r\n \"VAL == 0.0 ? 0.0 : VAL == 1.0 ? 1.0 : VAL < 0.5 ? -(pow(2.0, 20.0 * VAL - 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0 : (pow(2.0, -20.0 * VAL + 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0 + 1.0\";\r\n registeredFunction = this._duplicateVector(entry, inputType);\r\n break;\r\n }\r\n }\r\n\r\n state._emitFunction(registeredFunctionName, `${inputType} ${registeredFunctionName}(${inputType} v) {${registeredFunction};}\\r\\n`, \"\");\r\n\r\n state.compilationString += this._declareOutput(output, state) + ` = ${registeredFunctionName}(${this.input.associatedVariableName});\\r\\n`;\r\n\r\n return this;\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.curveType = this.type;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this.type = serializationObject.curveType;\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.type = BABYLON.CurveBlockTypes.${CurveBlockTypes[this.type]};\\r\\n`;\r\n return codeString;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CurveBlock\", CurveBlock);\r\n"]}
@@ -59,3 +59,4 @@ export * from "./biPlanarBlock";
59
59
  export * from "./matrixDeterminantBlock";
60
60
  export * from "./matrixTransposeBlock";
61
61
  export * from "./meshAttributeExistsBlock";
62
+ export * from "./curveBlock";
@@ -60,4 +60,5 @@ export * from "./biPlanarBlock.js";
60
60
  export * from "./matrixDeterminantBlock.js";
61
61
  export * from "./matrixTransposeBlock.js";
62
62
  export * from "./meshAttributeExistsBlock.js";
63
+ export * from "./curveBlock.js";
63
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc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AAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./Vertex/index\";\r\nexport * from \"./Fragment/index\";\r\nexport * from \"./Dual/index\";\r\nexport * from \"./Input/index\";\r\nexport * from \"./multiplyBlock\";\r\nexport * from \"./addBlock\";\r\nexport * from \"./scaleBlock\";\r\nexport * from \"./clampBlock\";\r\nexport * from \"./crossBlock\";\r\nexport * from \"./customBlock\";\r\nexport * from \"./dotBlock\";\r\nexport * from \"./transformBlock\";\r\nexport * from \"./remapBlock\";\r\nexport * from \"./normalizeBlock\";\r\nexport * from \"./trigonometryBlock\";\r\nexport * from \"./colorMergerBlock\";\r\nexport * from \"./vectorMergerBlock\";\r\nexport * from \"./colorSplitterBlock\";\r\nexport * from \"./vectorSplitterBlock\";\r\nexport * from \"./lerpBlock\";\r\nexport * from \"./divideBlock\";\r\nexport * from \"./subtractBlock\";\r\nexport * from \"./stepBlock\";\r\nexport * from \"./oneMinusBlock\";\r\nexport * from \"./viewDirectionBlock\";\r\nexport * from \"./fresnelBlock\";\r\nexport * from \"./maxBlock\";\r\nexport * from \"./minBlock\";\r\nexport * from \"./distanceBlock\";\r\nexport * from \"./lengthBlock\";\r\nexport * from \"./negateBlock\";\r\nexport * from \"./powBlock\";\r\nexport * from \"./randomNumberBlock\";\r\nexport * from \"./arcTan2Block\";\r\nexport * from \"./smoothStepBlock\";\r\nexport * from \"./reciprocalBlock\";\r\nexport * from \"./replaceColorBlock\";\r\nexport * from \"./posterizeBlock\";\r\nexport * from \"./waveBlock\";\r\nexport * from \"./gradientBlock\";\r\nexport * from \"./nLerpBlock\";\r\nexport * from \"./worleyNoise3DBlock\";\r\nexport * from \"./simplexPerlin3DBlock\";\r\nexport * from \"./normalBlendBlock\";\r\nexport * from \"./rotate2dBlock\";\r\nexport * from \"./reflectBlock\";\r\nexport * from \"./refractBlock\";\r\nexport * from \"./desaturateBlock\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./Particle/index\";\r\nexport * from \"./modBlock\";\r\nexport * from \"./matrixBuilderBlock\";\r\nexport * from \"./conditionalBlock\";\r\nexport * from \"./cloudBlock\";\r\nexport * from \"./voronoiNoiseBlock\";\r\nexport * from \"./elbowBlock\";\r\nexport * from \"./triPlanarBlock\";\r\nexport * from \"./biPlanarBlock\";\r\nexport * from \"./matrixDeterminantBlock\";\r\nexport * from \"./matrixTransposeBlock\";\r\nexport * from \"./meshAttributeExistsBlock\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./Vertex/index\";\r\nexport * from \"./Fragment/index\";\r\nexport * from \"./Dual/index\";\r\nexport * from \"./Input/index\";\r\nexport * from \"./multiplyBlock\";\r\nexport * from \"./addBlock\";\r\nexport * from \"./scaleBlock\";\r\nexport * from \"./clampBlock\";\r\nexport * from \"./crossBlock\";\r\nexport * from \"./customBlock\";\r\nexport * from \"./dotBlock\";\r\nexport * from \"./transformBlock\";\r\nexport * from \"./remapBlock\";\r\nexport * from \"./normalizeBlock\";\r\nexport * from \"./trigonometryBlock\";\r\nexport * from \"./colorMergerBlock\";\r\nexport * from \"./vectorMergerBlock\";\r\nexport * from \"./colorSplitterBlock\";\r\nexport * from \"./vectorSplitterBlock\";\r\nexport * from \"./lerpBlock\";\r\nexport * from \"./divideBlock\";\r\nexport * from \"./subtractBlock\";\r\nexport * from \"./stepBlock\";\r\nexport * from \"./oneMinusBlock\";\r\nexport * from \"./viewDirectionBlock\";\r\nexport * from \"./fresnelBlock\";\r\nexport * from \"./maxBlock\";\r\nexport * from \"./minBlock\";\r\nexport * from \"./distanceBlock\";\r\nexport * from \"./lengthBlock\";\r\nexport * from \"./negateBlock\";\r\nexport * from \"./powBlock\";\r\nexport * from \"./randomNumberBlock\";\r\nexport * from \"./arcTan2Block\";\r\nexport * from \"./smoothStepBlock\";\r\nexport * from \"./reciprocalBlock\";\r\nexport * from \"./replaceColorBlock\";\r\nexport * from \"./posterizeBlock\";\r\nexport * from \"./waveBlock\";\r\nexport * from \"./gradientBlock\";\r\nexport * from \"./nLerpBlock\";\r\nexport * from \"./worleyNoise3DBlock\";\r\nexport * from \"./simplexPerlin3DBlock\";\r\nexport * from \"./normalBlendBlock\";\r\nexport * from \"./rotate2dBlock\";\r\nexport * from \"./reflectBlock\";\r\nexport * from \"./refractBlock\";\r\nexport * from \"./desaturateBlock\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./Particle/index\";\r\nexport * from \"./modBlock\";\r\nexport * from \"./matrixBuilderBlock\";\r\nexport * from \"./conditionalBlock\";\r\nexport * from \"./cloudBlock\";\r\nexport * from \"./voronoiNoiseBlock\";\r\nexport * from \"./elbowBlock\";\r\nexport * from \"./triPlanarBlock\";\r\nexport * from \"./biPlanarBlock\";\r\nexport * from \"./matrixDeterminantBlock\";\r\nexport * from \"./matrixTransposeBlock\";\r\nexport * from \"./meshAttributeExistsBlock\";\r\nexport * from \"./curveBlock\";\r\n"]}