@babylonjs/core 7.53.1 → 7.53.3

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 (107) hide show
  1. package/AudioV2/abstractAudio/abstractSound.d.ts +1 -1
  2. package/AudioV2/abstractAudio/abstractSound.js +12 -12
  3. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  4. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +15 -8
  5. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +23 -11
  6. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -1
  7. package/AudioV2/abstractAudio/staticSound.js +8 -0
  8. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  9. package/AudioV2/abstractAudio/staticSoundInstance.d.ts +2 -0
  10. package/AudioV2/abstractAudio/staticSoundInstance.js.map +1 -1
  11. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +4 -4
  12. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +3 -3
  13. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
  14. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +23 -16
  15. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +3 -3
  16. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
  17. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +13 -6
  18. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
  19. package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +13 -8
  20. package/AudioV2/abstractAudio/subProperties/spatialAudio.js +18 -14
  21. package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
  22. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +10 -6
  23. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +7 -3
  24. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
  25. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +5 -5
  26. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +9 -9
  27. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
  28. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +4 -4
  29. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
  30. package/AudioV2/webAudio/webAudioStaticSound.d.ts +4 -0
  31. package/AudioV2/webAudio/webAudioStaticSound.js +14 -0
  32. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  33. package/Culling/Helper/boundingInfoHelper.d.ts +2 -2
  34. package/Culling/Helper/boundingInfoHelper.js +2 -2
  35. package/Culling/Helper/boundingInfoHelper.js.map +1 -1
  36. package/Engines/abstractEngine.js +2 -3
  37. package/Engines/abstractEngine.js.map +1 -1
  38. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +1 -1
  39. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  40. package/Lights/IES/iesLoader.d.ts +1 -1
  41. package/Lights/IES/iesLoader.js +1 -1
  42. package/Lights/IES/iesLoader.js.map +1 -1
  43. package/Lights/Shadows/shadowGenerator.d.ts +2 -2
  44. package/Lights/Shadows/shadowGenerator.js +2 -2
  45. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  46. package/Lights/spotLight.d.ts +1 -1
  47. package/Lights/spotLight.js +1 -1
  48. package/Lights/spotLight.js.map +1 -1
  49. package/Materials/Node/Blocks/Fragment/prePassOutputBlock.d.ts +1 -1
  50. package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js +1 -1
  51. package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js.map +1 -1
  52. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +1 -1
  53. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +1 -1
  54. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  55. package/Materials/PBR/pbrBaseMaterial.d.ts +2 -2
  56. package/Materials/PBR/pbrBaseMaterial.js +2 -2
  57. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  58. package/Materials/Textures/Loaders/basisTextureLoader.d.ts +1 -0
  59. package/Materials/Textures/Loaders/basisTextureLoader.js +1 -0
  60. package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
  61. package/Materials/Textures/Loaders/exrTextureLoader.d.ts +5 -4
  62. package/Materials/Textures/Loaders/exrTextureLoader.js +5 -4
  63. package/Materials/Textures/Loaders/exrTextureLoader.js.map +1 -1
  64. package/Materials/Textures/internalTexture.js +2 -2
  65. package/Materials/Textures/internalTexture.js.map +1 -1
  66. package/Materials/material.js +1 -1
  67. package/Materials/material.js.map +1 -1
  68. package/Maths/math.scalar.d.ts +1 -0
  69. package/Maths/math.scalar.functions.d.ts +9 -0
  70. package/Maths/math.scalar.functions.js +11 -0
  71. package/Maths/math.scalar.functions.js.map +1 -1
  72. package/Meshes/Node/Blocks/geometryEaseBlock.d.ts +96 -0
  73. package/Meshes/Node/Blocks/geometryEaseBlock.js +318 -0
  74. package/Meshes/Node/Blocks/geometryEaseBlock.js.map +1 -0
  75. package/Meshes/Node/index.d.ts +1 -0
  76. package/Meshes/Node/index.js +1 -0
  77. package/Meshes/Node/index.js.map +1 -1
  78. package/Meshes/csg2.d.ts +3 -3
  79. package/Meshes/csg2.js +3 -3
  80. package/Meshes/csg2.js.map +1 -1
  81. package/Meshes/lattice.d.ts +2 -2
  82. package/Meshes/lattice.js +5 -4
  83. package/Meshes/lattice.js.map +1 -1
  84. package/Meshes/lattice.material.d.ts +2 -2
  85. package/Meshes/lattice.material.js +2 -2
  86. package/Meshes/lattice.material.js.map +1 -1
  87. package/Meshes/mesh.d.ts +2 -2
  88. package/Meshes/mesh.js +2 -2
  89. package/Meshes/mesh.js.map +1 -1
  90. package/Meshes/subMesh.js +1 -1
  91. package/Meshes/subMesh.js.map +1 -1
  92. package/Misc/fileTools.d.ts +1 -1
  93. package/Misc/fileTools.js +1 -1
  94. package/Misc/fileTools.js.map +1 -1
  95. package/Physics/v2/characterController.d.ts +3 -2
  96. package/Physics/v2/characterController.js +12 -0
  97. package/Physics/v2/characterController.js.map +1 -1
  98. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +4 -0
  99. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +11 -16
  100. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  101. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +6 -1
  102. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +7 -1
  103. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  104. package/package.json +1 -1
  105. package/scene.d.ts +3 -0
  106. package/scene.js +5 -0
  107. package/scene.js.map +1 -1
@@ -68,7 +68,7 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
68
68
  const from = this.from.getValue(context) ?? 0;
69
69
  // not accepting 0
70
70
  const to = this.to.getValue(context) || animationGroupToUse.to;
71
- const loop = this.loop.getValue(context);
71
+ const loop = !isFinite(to) || this.loop.getValue(context);
72
72
  this.currentAnimationGroup.setValue(animationGroupToUse, context);
73
73
  const currentlyRunningAnimationGroups = context._getGlobalContextVariable("currentlyRunningAnimationGroups", []);
74
74
  // check if it already running
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphPlayAnimationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,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AAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;4BACzF,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;wBAC1C,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAEO,mBAAmB,CAAC,OAAyB,EAAE,cAA8B;QACjF,gFAAgF;QAChF,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,cAAc,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC9D,CAAC;IAEO,2BAA2B,CAAC,OAAyB,EAAE,cAA8B;QACzF,MAAM,+BAA+B,GAAG,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,EAAE,CAAa,CAAC;QAC7H,MAAM,GAAG,GAAG,+BAA+B,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC7E,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;YACb,+BAA+B,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC/C,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,+BAA+B,CAAC,CAAC;QAC1G,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,mBAAmB,CAAC,OAAyB;QAChD,MAAM,EAAE,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,EAAE,EAAE,CAAC;YACL,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,6EAAyC;IAC7C,CAAC;CACJ;AAED,aAAa,wEAAoC,2BAA2B,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport type { Animation } from \"core/Animations/animation\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\n\r\n/**\r\n * @experimental\r\n * A block that plays an animation on an animatable object.\r\n */\r\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * Input connection: The speed of the animation.\r\n */\r\n public readonly speed: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Should the animation loop?\r\n * Not in glTF specs, but useful for the engine.\r\n */\r\n public readonly loop: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Input connection: The starting frame of the animation.\r\n */\r\n public readonly from: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The ending frame of the animation.\r\n */\r\n public readonly to: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current frame of the animation.\r\n */\r\n public readonly currentFrame: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current time of the animation.\r\n */\r\n public readonly currentTime: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The animatable that is currently running.\r\n */\r\n public readonly currentAnimationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: Will be initialized if no animation group was provided in the configuration.\r\n */\r\n public readonly animationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: If provided this animation will be used. Priority will be given to the animation group input.\r\n */\r\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\r\n\r\n /**\r\n * Input connection: The target object that will be animated. If animation group is provided this input will be ignored.\r\n */\r\n public readonly object: FlowGraphDataConnection<any>;\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config?: IFlowGraphBlockConfiguration\r\n ) {\r\n super(config, [\"animationLoop\", \"animationEnd\", \"animationGroupLoop\"]);\r\n\r\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\r\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\r\n this.from = this.registerDataInput(\"from\", RichTypeNumber, 0);\r\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\r\n\r\n this.currentFrame = this.registerDataOutput(\"currentFrame\", RichTypeNumber);\r\n this.currentTime = this.registerDataOutput(\"currentTime\", RichTypeNumber);\r\n\r\n this.currentAnimationGroup = this.registerDataOutput(\"currentAnimationGroup\", RichTypeAny);\r\n this.animationGroup = this.registerDataInput(\"animationGroup\", RichTypeAny, config?.animationGroup);\r\n this.animation = this.registerDataInput(\"animation\", RichTypeAny);\r\n this.object = this.registerDataInput(\"object\", RichTypeAny);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n const ag = this.animationGroup.getValue(context);\r\n const animation = this.animation.getValue(context);\r\n if (!ag && !animation) {\r\n return this._reportError(context, \"No animation or animation group provided\");\r\n } else {\r\n // if an animation group was already created, dispose it and create a new one\r\n const currentAnimationGroup = this.currentAnimationGroup.getValue(context);\r\n if (currentAnimationGroup && currentAnimationGroup !== ag) {\r\n currentAnimationGroup.dispose();\r\n }\r\n let animationGroupToUse = ag;\r\n // check which animation to use. If no animationGroup was defined and an animation was provided, use the animation\r\n if (animation && !animationGroupToUse) {\r\n const target = this.object.getValue(context);\r\n if (!target) {\r\n return this._reportError(context, \"No target object provided\");\r\n }\r\n const animationsArray = Array.isArray(animation) ? animation : [animation];\r\n const name = animationsArray[0].name;\r\n animationGroupToUse = new AnimationGroup(\"flowGraphAnimationGroup-\" + name + \"-\" + target.name, context.configuration.scene);\r\n let isInterpolation = false;\r\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\r\n for (const anim of animationsArray) {\r\n animationGroupToUse.addTargetedAnimation(anim, target);\r\n if (interpolationAnimations.indexOf(anim.uniqueId) !== -1) {\r\n isInterpolation = true;\r\n }\r\n }\r\n\r\n if (isInterpolation) {\r\n this._checkInterpolationDuplications(context, animationsArray, target);\r\n }\r\n }\r\n // not accepting 0\r\n const speed = this.speed.getValue(context) || 1;\r\n const from = this.from.getValue(context) ?? 0;\r\n // not accepting 0\r\n const to = this.to.getValue(context) || animationGroupToUse.to;\r\n const loop = this.loop.getValue(context);\r\n this.currentAnimationGroup.setValue(animationGroupToUse, context);\r\n\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n // check if it already running\r\n if (currentlyRunningAnimationGroups.indexOf(animationGroupToUse.uniqueId) !== -1) {\r\n animationGroupToUse.stop();\r\n }\r\n try {\r\n animationGroupToUse.start(loop, speed, from, to);\r\n animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context));\r\n animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs[\"animationEnd\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs[\"animationLoop\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs[\"animationGroupLoop\"]._activateSignal(context));\r\n currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n } catch (e) {\r\n this._reportError(context, e);\r\n }\r\n }\r\n }\r\n\r\n protected override _reportError(context: FlowGraphContext, error: string | Error): void {\r\n super._reportError(context, error);\r\n this.currentFrame.setValue(-1, context);\r\n this.currentTime.setValue(-1, context);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _executeOnTick(_context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(_context);\r\n if (ag) {\r\n this.currentFrame.setValue(ag.getCurrentFrame(), _context);\r\n this.currentTime.setValue(ag.animatables[0]?.elapsedTime ?? 0, _context);\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n this._startPendingTasks(context);\r\n }\r\n\r\n private _onAnimationGroupEnd(context: FlowGraphContext) {\r\n this._removeFromCurrentlyRunning(context, this.currentAnimationGroup.getValue(context));\r\n this._resetAfterCanceled(context);\r\n this.done._activateSignal(context);\r\n }\r\n\r\n /**\r\n * The idea behind this function is to check every running animation group and check if the targeted animations it uses are interpolation animations.\r\n * If they are, we want to see that they don't collide with the current interpolation animations that are starting to play.\r\n * If they do, we want to stop the already-running animation group.\r\n * @internal\r\n */\r\n private _checkInterpolationDuplications(context: FlowGraphContext, animation: Animation[], target: any) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n for (const uniqueId of currentlyRunningAnimationGroups) {\r\n const ag = context.assetsContext.animationGroups.find((ag) => ag.uniqueId === uniqueId);\r\n if (ag) {\r\n for (const anim of ag.targetedAnimations) {\r\n for (const animToCheck of animation) {\r\n if (anim.animation.targetProperty === animToCheck.targetProperty && anim.target === target) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _stopAnimationGroup(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n // stop, while skipping the on AnimationEndObservable to avoid the \"done\" signal\r\n animationGroup.stop(true);\r\n animationGroup.dispose();\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n }\r\n\r\n private _removeFromCurrentlyRunning(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n const idx = currentlyRunningAnimationGroups.indexOf(animationGroup.uniqueId);\r\n if (idx !== -1) {\r\n currentlyRunningAnimationGroups.splice(idx, 1);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Stop any currently running animations.\r\n */\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(context);\r\n if (ag) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.PlayAnimation;\r\n }\r\n}\r\n\r\nRegisterClass(FlowGraphBlockNames.PlayAnimation, FlowGraphPlayAnimationBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphPlayAnimationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,iDAAuC;AAIhE;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,4BAA4B;IAiDzE;IACI;;OAEG;IACa,MAAqC;QAErD,KAAK,CAAC,MAAM,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,oBAAoB,CAAC,CAAC,CAAC;QAFvD,WAAM,GAAN,MAAM,CAA+B;QAIrD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;Q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iCAAiC,EAAE,EAAE,CAAa,CAAC;QAC7H,MAAM,GAAG,GAAG,+BAA+B,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC7E,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;YACb,+BAA+B,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC/C,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,+BAA+B,CAAC,CAAC;QAC1G,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,mBAAmB,CAAC,OAAyB;QAChD,MAAM,EAAE,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,EAAE,EAAE,CAAC;YACL,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,6EAAyC;IAC7C,CAAC;CACJ;AAED,aAAa,wEAAoC,2BAA2B,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport type { Animation } from \"core/Animations/animation\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\n\r\n/**\r\n * @experimental\r\n * A block that plays an animation on an animatable object.\r\n */\r\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * Input connection: The speed of the animation.\r\n */\r\n public readonly speed: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Should the animation loop?\r\n * Not in glTF specs, but useful for the engine.\r\n */\r\n public readonly loop: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Input connection: The starting frame of the animation.\r\n */\r\n public readonly from: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The ending frame of the animation.\r\n */\r\n public readonly to: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current frame of the animation.\r\n */\r\n public readonly currentFrame: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current time of the animation.\r\n */\r\n public readonly currentTime: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The animatable that is currently running.\r\n */\r\n public readonly currentAnimationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: Will be initialized if no animation group was provided in the configuration.\r\n */\r\n public readonly animationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: If provided this animation will be used. Priority will be given to the animation group input.\r\n */\r\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\r\n\r\n /**\r\n * Input connection: The target object that will be animated. If animation group is provided this input will be ignored.\r\n */\r\n public readonly object: FlowGraphDataConnection<any>;\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config?: IFlowGraphBlockConfiguration\r\n ) {\r\n super(config, [\"animationLoop\", \"animationEnd\", \"animationGroupLoop\"]);\r\n\r\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\r\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\r\n this.from = this.registerDataInput(\"from\", RichTypeNumber, 0);\r\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\r\n\r\n this.currentFrame = this.registerDataOutput(\"currentFrame\", RichTypeNumber);\r\n this.currentTime = this.registerDataOutput(\"currentTime\", RichTypeNumber);\r\n\r\n this.currentAnimationGroup = this.registerDataOutput(\"currentAnimationGroup\", RichTypeAny);\r\n this.animationGroup = this.registerDataInput(\"animationGroup\", RichTypeAny, config?.animationGroup);\r\n this.animation = this.registerDataInput(\"animation\", RichTypeAny);\r\n this.object = this.registerDataInput(\"object\", RichTypeAny);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n const ag = this.animationGroup.getValue(context);\r\n const animation = this.animation.getValue(context);\r\n if (!ag && !animation) {\r\n return this._reportError(context, \"No animation or animation group provided\");\r\n } else {\r\n // if an animation group was already created, dispose it and create a new one\r\n const currentAnimationGroup = this.currentAnimationGroup.getValue(context);\r\n if (currentAnimationGroup && currentAnimationGroup !== ag) {\r\n currentAnimationGroup.dispose();\r\n }\r\n let animationGroupToUse = ag;\r\n // check which animation to use. If no animationGroup was defined and an animation was provided, use the animation\r\n if (animation && !animationGroupToUse) {\r\n const target = this.object.getValue(context);\r\n if (!target) {\r\n return this._reportError(context, \"No target object provided\");\r\n }\r\n const animationsArray = Array.isArray(animation) ? animation : [animation];\r\n const name = animationsArray[0].name;\r\n animationGroupToUse = new AnimationGroup(\"flowGraphAnimationGroup-\" + name + \"-\" + target.name, context.configuration.scene);\r\n let isInterpolation = false;\r\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\r\n for (const anim of animationsArray) {\r\n animationGroupToUse.addTargetedAnimation(anim, target);\r\n if (interpolationAnimations.indexOf(anim.uniqueId) !== -1) {\r\n isInterpolation = true;\r\n }\r\n }\r\n\r\n if (isInterpolation) {\r\n this._checkInterpolationDuplications(context, animationsArray, target);\r\n }\r\n }\r\n // not accepting 0\r\n const speed = this.speed.getValue(context) || 1;\r\n const from = this.from.getValue(context) ?? 0;\r\n // not accepting 0\r\n const to = this.to.getValue(context) || animationGroupToUse.to;\r\n const loop = !isFinite(to) || this.loop.getValue(context);\r\n this.currentAnimationGroup.setValue(animationGroupToUse, context);\r\n\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n // check if it already running\r\n if (currentlyRunningAnimationGroups.indexOf(animationGroupToUse.uniqueId) !== -1) {\r\n animationGroupToUse.stop();\r\n }\r\n try {\r\n animationGroupToUse.start(loop, speed, from, to);\r\n animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context));\r\n animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs[\"animationEnd\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs[\"animationLoop\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs[\"animationGroupLoop\"]._activateSignal(context));\r\n currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n } catch (e) {\r\n this._reportError(context, e);\r\n }\r\n }\r\n }\r\n\r\n protected override _reportError(context: FlowGraphContext, error: string | Error): void {\r\n super._reportError(context, error);\r\n this.currentFrame.setValue(-1, context);\r\n this.currentTime.setValue(-1, context);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _executeOnTick(_context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(_context);\r\n if (ag) {\r\n this.currentFrame.setValue(ag.getCurrentFrame(), _context);\r\n this.currentTime.setValue(ag.animatables[0]?.elapsedTime ?? 0, _context);\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n this._startPendingTasks(context);\r\n }\r\n\r\n private _onAnimationGroupEnd(context: FlowGraphContext) {\r\n this._removeFromCurrentlyRunning(context, this.currentAnimationGroup.getValue(context));\r\n this._resetAfterCanceled(context);\r\n this.done._activateSignal(context);\r\n }\r\n\r\n /**\r\n * The idea behind this function is to check every running animation group and check if the targeted animations it uses are interpolation animations.\r\n * If they are, we want to see that they don't collide with the current interpolation animations that are starting to play.\r\n * If they do, we want to stop the already-running animation group.\r\n * @internal\r\n */\r\n private _checkInterpolationDuplications(context: FlowGraphContext, animation: Animation[], target: any) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n for (const uniqueId of currentlyRunningAnimationGroups) {\r\n const ag = context.assetsContext.animationGroups.find((ag) => ag.uniqueId === uniqueId);\r\n if (ag) {\r\n for (const anim of ag.targetedAnimations) {\r\n for (const animToCheck of animation) {\r\n if (anim.animation.targetProperty === animToCheck.targetProperty && anim.target === target) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _stopAnimationGroup(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n // stop, while skipping the on AnimationEndObservable to avoid the \"done\" signal\r\n animationGroup.stop(true);\r\n animationGroup.dispose();\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n }\r\n\r\n private _removeFromCurrentlyRunning(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n const idx = currentlyRunningAnimationGroups.indexOf(animationGroup.uniqueId);\r\n if (idx !== -1) {\r\n currentlyRunningAnimationGroups.splice(idx, 1);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Stop any currently running animations.\r\n */\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(context);\r\n if (ag) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.PlayAnimation;\r\n }\r\n}\r\n\r\nRegisterClass(FlowGraphBlockNames.PlayAnimation, FlowGraphPlayAnimationBlock);\r\n"]}
@@ -14,6 +14,6 @@ export interface IIESTextureData {
14
14
  * @param uint8Array defines the IES data
15
15
  * @returns the IES data buffer
16
16
  * @see https://ieslibrary.com/browse
17
- * #UQGPDT#1
17
+ * @see https://playground.babylonjs.com/#UQGPDT#1
18
18
  */
19
19
  export declare function LoadIESData(uint8Array: Uint8Array): IIESTextureData;
@@ -54,7 +54,7 @@ function interpolateCandelaValues(data, phi, theta) {
54
54
  * @param uint8Array defines the IES data
55
55
  * @returns the IES data buffer
56
56
  * @see https://ieslibrary.com/browse
57
- * #UQGPDT#1
57
+ * @see https://playground.babylonjs.com/#UQGPDT#1
58
58
  */
59
59
  export function LoadIESData(uint8Array) {
60
60
  const decoder = new TextDecoder("utf-8");
@@ -1 +1 @@
1
- {"version":3,"file":"iesLoader.js","sourceRoot":"","sources":["../../../../../dev/core/src/Lights/IES/iesLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,6CAAyC;AA4BxD,SAAS,WAAW,CAAC,IAAY;IAC7B,OAAO,IAAI;SACN,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;SACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,SAAS,CAAC,WAAyB,EAAE,KAAa,EAAE,WAAqB;IAC9E,OAAO,WAAW,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACjE,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC9B,CAAC;AACL,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAc,EAAE,GAAW,EAAE,KAAa;IACxE,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,QAAQ,GAAG,C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AI,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;QAEtC,WAAW;QACX,IAAI,QAAQ,GAAG,UAAU,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,UAAU,IAAI,KAAK,IAAI,QAAQ,CAAC,EAAE,CAAC;YAC3E,KAAK,IAAI,QAAQ,GAAG,CAAC,CAAC;YACtB,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;gBACnB,KAAK,GAAG,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC;YACjC,CAAC;QACL,CAAC;QAED,WAAW,CAAC,GAAG,GAAG,KAAK,GAAG,MAAM,CAAC,GAAG,wBAAwB,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACnF,CAAC;IAED,sJAAsJ;IACtJ,OAAO;QACH,KAAK,EAAE,KAAK,GAAG,CAAC;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,WAAW;KACpB,CAAC;AACN,CAAC","sourcesContent":["import { Lerp } from \"core/Maths/math.scalar.functions\";\r\n\r\ninterface IIESData {\r\n version: string;\r\n tilt?: {};\r\n numberOfLights?: number;\r\n lumensPerLamp?: number;\r\n candelaMultiplier?: number;\r\n numberOfVerticalAngles: number;\r\n numberOfHorizontalAngles: number;\r\n horizontalAngles: number[];\r\n verticalAngles: number[];\r\n photometricType?: number;\r\n unitsType?: number;\r\n width?: number;\r\n length?: number;\r\n height?: number;\r\n ballastFactor?: number;\r\n fileGenerationType?: number;\r\n inputWatts?: number;\r\n candelaValues: number[][];\r\n}\r\n\r\ninterface IDataPointer {\r\n lines: string[];\r\n index: number;\r\n}\r\n\r\nfunction lineToArray(line: string): number[] {\r\n return line\r\n .split(\" \")\r\n .filter((x) => x !== \"\")\r\n .map((x) => parseFloat(x));\r\n}\r\n\r\nfunction readArray(dataPointer: IDataPointer, count: number, targetArray: number[]) {\r\n while (targetArray.length !== count) {\r\n const line = lineToArray(dataPointer.lines[dataPointer.index++]);\r\n targetArray.push(...line);\r\n }\r\n}\r\n\r\nfunction interpolateCandelaValues(data: IIESData, phi: number, theta: number): number {\r\n let phiIndex = 0;\r\n let thetaIndex = 0;\r\n let startTheta = 0;\r\n let endTheta = 0;\r\n let startPhi = 0;\r\n let endPhi = 0;\r\n\r\n // Check if the angle is outside the range\r\n for (let index = 0; index < data.numberOfHorizontalAngles - 1; index++) {\r\n if (theta < data.horizontalAngles[index + 1] || index === data.numberOfHorizontalAngles - 2) {\r\n thetaIndex = index;\r\n startTheta = data.horizontalAngles[index];\r\n endTheta = data.horizontalAngles[index + 1];\r\n\r\n break;\r\n }\r\n }\r\n\r\n for (let index = 0; index < data.numberOfVerticalAngles - 1; index++) {\r\n if (phi < data.verticalAngles[index + 1] || index === data.numberOfVerticalAngles - 2) {\r\n phiIndex = index;\r\n startPhi = data.verticalAngles[index];\r\n endPhi = data.verticalAngles[index + 1];\r\n\r\n break;\r\n }\r\n }\r\n\r\n const deltaTheta = endTheta - startTheta;\r\n const deltaPhi = endPhi - startPhi;\r\n\r\n if (deltaPhi === 0) {\r\n return 0;\r\n }\r\n\r\n // Interpolate\r\n const t1 = deltaTheta === 0 ? 0 : (theta - startTheta) / deltaTheta;\r\n const t2 = (phi - startPhi) / deltaPhi;\r\n\r\n const nextThetaIndex = deltaTheta === 0 ? thetaIndex : thetaIndex + 1;\r\n\r\n const v1 = Lerp(data.candelaValues[thetaIndex][phiIndex], data.candelaValues[nextThetaIndex][phiIndex], t1);\r\n const v2 = Lerp(data.candelaValues[thetaIndex][phiIndex + 1], data.candelaValues[nextThetaIndex][phiIndex + 1], t1);\r\n const v = Lerp(v1, v2, t2);\r\n\r\n return v;\r\n}\r\n/**\r\n * Interface for IES texture data.\r\n */\r\nexport interface IIESTextureData {\r\n /** The width of the texture */\r\n width: number;\r\n /** The height of the texture */\r\n height: number;\r\n /** The data of the texture */\r\n data: Float32Array;\r\n}\r\n\r\n/**\r\n * Generates IES data buffer from a string representing the IES data.\r\n * @param uint8Array defines the IES data\r\n * @returns the IES data buffer\r\n * @see https://ieslibrary.com/browse\r\n * #UQGPDT#1\r\n */\r\nexport function LoadIESData(uint8Array: Uint8Array): IIESTextureData {\r\n const decoder = new TextDecoder(\"utf-8\");\r\n const source = decoder.decode(uint8Array);\r\n\r\n // Read data\r\n const dataPointer: IDataPointer = {\r\n lines: source.split(\"\\n\"),\r\n index: 0,\r\n };\r\n const data: IIESData = { version: dataPointer.lines[0], candelaValues: [], horizontalAngles: [], verticalAngles: [], numberOfHorizontalAngles: 0, numberOfVerticalAngles: 0 };\r\n\r\n // Skip metadata\r\n dataPointer.index = 1;\r\n while (dataPointer.lines.length > 0 && !dataPointer.lines[dataPointer.index].includes(\"TILT=\")) {\r\n dataPointer.index++;\r\n }\r\n\r\n // Process tilt data?\r\n if (dataPointer.lines[dataPointer.index].includes(\"INCLUDE\")) {\r\n // Not supported yet as I did not manage to find an example :)\r\n }\r\n dataPointer.index++;\r\n\r\n // Header\r\n const header = lineToArray(dataPointer.lines[dataPointer.index++]);\r\n data.numberOfLights = header[0];\r\n data.lumensPerLamp = header[1];\r\n data.candelaMultiplier = header[2];\r\n data.numberOfVerticalAngles = header[3];\r\n data.numberOfHorizontalAngles = header[4];\r\n data.photometricType = header[5]; // We ignore cylindrical type for now. Will add support later if needed\r\n data.unitsType = header[6];\r\n data.width = header[7];\r\n data.length = header[8];\r\n data.height = header[9];\r\n\r\n // Additional data\r\n const additionalData = lineToArray(dataPointer.lines[dataPointer.index++]);\r\n data.ballastFactor = additionalData[0];\r\n data.fileGenerationType = additionalData[1];\r\n data.inputWatts = additionalData[2];\r\n\r\n // Prepare arrays\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n data.candelaValues[index] = [];\r\n }\r\n\r\n // Vertical angles\r\n readArray(dataPointer, data.numberOfVerticalAngles, data.verticalAngles);\r\n\r\n // Horizontal angles\r\n readArray(dataPointer, data.numberOfHorizontalAngles, data.horizontalAngles);\r\n\r\n // Candela values\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n readArray(dataPointer, data.numberOfVerticalAngles, data.candelaValues[index]);\r\n }\r\n\r\n // Evaluate candela values\r\n let maxCandela = -1;\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n for (let subIndex = 0; subIndex < data.numberOfVerticalAngles; subIndex++) {\r\n data.candelaValues[index][subIndex] *= data.candelaValues[index][subIndex] * data.candelaMultiplier * data.ballastFactor * data.fileGenerationType;\r\n maxCandela = Math.max(maxCandela, data.candelaValues[index][subIndex]);\r\n }\r\n }\r\n\r\n // Normalize candela values\r\n if (maxCandela > 0) {\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n for (let subIndex = 0; subIndex < data.numberOfVerticalAngles; subIndex++) {\r\n data.candelaValues[index][subIndex] /= maxCandela;\r\n }\r\n }\r\n }\r\n\r\n // Create the cylindrical texture\r\n const height = 180;\r\n const width = height * 2;\r\n const size = width * height;\r\n const arrayBuffer = new Float32Array(width * height);\r\n\r\n // Fill the texture\r\n const startTheta = data.horizontalAngles[0];\r\n const endTheta = data.horizontalAngles[data.numberOfHorizontalAngles - 1];\r\n for (let index = 0; index < size; index++) {\r\n let theta = index % width;\r\n const phi = Math.floor(index / width);\r\n\r\n // Symmetry\r\n if (endTheta - startTheta !== 0 && (theta < startTheta || theta >= endTheta)) {\r\n theta %= endTheta * 2;\r\n if (theta > endTheta) {\r\n theta = endTheta * 2 - theta;\r\n }\r\n }\r\n\r\n arrayBuffer[phi + theta * height] = interpolateCandelaValues(data, phi, theta);\r\n }\r\n\r\n // So far we only need the first half of the first row of the texture as we only support IES for spot light. We can add support for other types later.\r\n return {\r\n width: width / 2,\r\n height: 1,\r\n data: arrayBuffer,\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"iesLoader.js","sourceRoot":"","sources":["../../../../../dev/core/src/Lights/IES/iesLoader.ts"],"names":[],"mappings":"A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AC,GAAG,wBAAwB,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACnF,CAAC;IAED,sJAAsJ;IACtJ,OAAO;QACH,KAAK,EAAE,KAAK,GAAG,CAAC;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,WAAW;KACpB,CAAC;AACN,CAAC","sourcesContent":["import { Lerp } from \"core/Maths/math.scalar.functions\";\r\n\r\ninterface IIESData {\r\n version: string;\r\n tilt?: {};\r\n numberOfLights?: number;\r\n lumensPerLamp?: number;\r\n candelaMultiplier?: number;\r\n numberOfVerticalAngles: number;\r\n numberOfHorizontalAngles: number;\r\n horizontalAngles: number[];\r\n verticalAngles: number[];\r\n photometricType?: number;\r\n unitsType?: number;\r\n width?: number;\r\n length?: number;\r\n height?: number;\r\n ballastFactor?: number;\r\n fileGenerationType?: number;\r\n inputWatts?: number;\r\n candelaValues: number[][];\r\n}\r\n\r\ninterface IDataPointer {\r\n lines: string[];\r\n index: number;\r\n}\r\n\r\nfunction lineToArray(line: string): number[] {\r\n return line\r\n .split(\" \")\r\n .filter((x) => x !== \"\")\r\n .map((x) => parseFloat(x));\r\n}\r\n\r\nfunction readArray(dataPointer: IDataPointer, count: number, targetArray: number[]) {\r\n while (targetArray.length !== count) {\r\n const line = lineToArray(dataPointer.lines[dataPointer.index++]);\r\n targetArray.push(...line);\r\n }\r\n}\r\n\r\nfunction interpolateCandelaValues(data: IIESData, phi: number, theta: number): number {\r\n let phiIndex = 0;\r\n let thetaIndex = 0;\r\n let startTheta = 0;\r\n let endTheta = 0;\r\n let startPhi = 0;\r\n let endPhi = 0;\r\n\r\n // Check if the angle is outside the range\r\n for (let index = 0; index < data.numberOfHorizontalAngles - 1; index++) {\r\n if (theta < data.horizontalAngles[index + 1] || index === data.numberOfHorizontalAngles - 2) {\r\n thetaIndex = index;\r\n startTheta = data.horizontalAngles[index];\r\n endTheta = data.horizontalAngles[index + 1];\r\n\r\n break;\r\n }\r\n }\r\n\r\n for (let index = 0; index < data.numberOfVerticalAngles - 1; index++) {\r\n if (phi < data.verticalAngles[index + 1] || index === data.numberOfVerticalAngles - 2) {\r\n phiIndex = index;\r\n startPhi = data.verticalAngles[index];\r\n endPhi = data.verticalAngles[index + 1];\r\n\r\n break;\r\n }\r\n }\r\n\r\n const deltaTheta = endTheta - startTheta;\r\n const deltaPhi = endPhi - startPhi;\r\n\r\n if (deltaPhi === 0) {\r\n return 0;\r\n }\r\n\r\n // Interpolate\r\n const t1 = deltaTheta === 0 ? 0 : (theta - startTheta) / deltaTheta;\r\n const t2 = (phi - startPhi) / deltaPhi;\r\n\r\n const nextThetaIndex = deltaTheta === 0 ? thetaIndex : thetaIndex + 1;\r\n\r\n const v1 = Lerp(data.candelaValues[thetaIndex][phiIndex], data.candelaValues[nextThetaIndex][phiIndex], t1);\r\n const v2 = Lerp(data.candelaValues[thetaIndex][phiIndex + 1], data.candelaValues[nextThetaIndex][phiIndex + 1], t1);\r\n const v = Lerp(v1, v2, t2);\r\n\r\n return v;\r\n}\r\n/**\r\n * Interface for IES texture data.\r\n */\r\nexport interface IIESTextureData {\r\n /** The width of the texture */\r\n width: number;\r\n /** The height of the texture */\r\n height: number;\r\n /** The data of the texture */\r\n data: Float32Array;\r\n}\r\n\r\n/**\r\n * Generates IES data buffer from a string representing the IES data.\r\n * @param uint8Array defines the IES data\r\n * @returns the IES data buffer\r\n * @see https://ieslibrary.com/browse\r\n * @see https://playground.babylonjs.com/#UQGPDT#1\r\n */\r\nexport function LoadIESData(uint8Array: Uint8Array): IIESTextureData {\r\n const decoder = new TextDecoder(\"utf-8\");\r\n const source = decoder.decode(uint8Array);\r\n\r\n // Read data\r\n const dataPointer: IDataPointer = {\r\n lines: source.split(\"\\n\"),\r\n index: 0,\r\n };\r\n const data: IIESData = { version: dataPointer.lines[0], candelaValues: [], horizontalAngles: [], verticalAngles: [], numberOfHorizontalAngles: 0, numberOfVerticalAngles: 0 };\r\n\r\n // Skip metadata\r\n dataPointer.index = 1;\r\n while (dataPointer.lines.length > 0 && !dataPointer.lines[dataPointer.index].includes(\"TILT=\")) {\r\n dataPointer.index++;\r\n }\r\n\r\n // Process tilt data?\r\n if (dataPointer.lines[dataPointer.index].includes(\"INCLUDE\")) {\r\n // Not supported yet as I did not manage to find an example :)\r\n }\r\n dataPointer.index++;\r\n\r\n // Header\r\n const header = lineToArray(dataPointer.lines[dataPointer.index++]);\r\n data.numberOfLights = header[0];\r\n data.lumensPerLamp = header[1];\r\n data.candelaMultiplier = header[2];\r\n data.numberOfVerticalAngles = header[3];\r\n data.numberOfHorizontalAngles = header[4];\r\n data.photometricType = header[5]; // We ignore cylindrical type for now. Will add support later if needed\r\n data.unitsType = header[6];\r\n data.width = header[7];\r\n data.length = header[8];\r\n data.height = header[9];\r\n\r\n // Additional data\r\n const additionalData = lineToArray(dataPointer.lines[dataPointer.index++]);\r\n data.ballastFactor = additionalData[0];\r\n data.fileGenerationType = additionalData[1];\r\n data.inputWatts = additionalData[2];\r\n\r\n // Prepare arrays\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n data.candelaValues[index] = [];\r\n }\r\n\r\n // Vertical angles\r\n readArray(dataPointer, data.numberOfVerticalAngles, data.verticalAngles);\r\n\r\n // Horizontal angles\r\n readArray(dataPointer, data.numberOfHorizontalAngles, data.horizontalAngles);\r\n\r\n // Candela values\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n readArray(dataPointer, data.numberOfVerticalAngles, data.candelaValues[index]);\r\n }\r\n\r\n // Evaluate candela values\r\n let maxCandela = -1;\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n for (let subIndex = 0; subIndex < data.numberOfVerticalAngles; subIndex++) {\r\n data.candelaValues[index][subIndex] *= data.candelaValues[index][subIndex] * data.candelaMultiplier * data.ballastFactor * data.fileGenerationType;\r\n maxCandela = Math.max(maxCandela, data.candelaValues[index][subIndex]);\r\n }\r\n }\r\n\r\n // Normalize candela values\r\n if (maxCandela > 0) {\r\n for (let index = 0; index < data.numberOfHorizontalAngles; index++) {\r\n for (let subIndex = 0; subIndex < data.numberOfVerticalAngles; subIndex++) {\r\n data.candelaValues[index][subIndex] /= maxCandela;\r\n }\r\n }\r\n }\r\n\r\n // Create the cylindrical texture\r\n const height = 180;\r\n const width = height * 2;\r\n const size = width * height;\r\n const arrayBuffer = new Float32Array(width * height);\r\n\r\n // Fill the texture\r\n const startTheta = data.horizontalAngles[0];\r\n const endTheta = data.horizontalAngles[data.numberOfHorizontalAngles - 1];\r\n for (let index = 0; index < size; index++) {\r\n let theta = index % width;\r\n const phi = Math.floor(index / width);\r\n\r\n // Symmetry\r\n if (endTheta - startTheta !== 0 && (theta < startTheta || theta >= endTheta)) {\r\n theta %= endTheta * 2;\r\n if (theta > endTheta) {\r\n theta = endTheta * 2 - theta;\r\n }\r\n }\r\n\r\n arrayBuffer[phi + theta * height] = interpolateCandelaValues(data, phi, theta);\r\n }\r\n\r\n // So far we only need the first half of the first row of the texture as we only support IES for spot light. We can add support for other types later.\r\n return {\r\n width: width / 2,\r\n height: 1,\r\n data: arrayBuffer,\r\n };\r\n}\r\n"]}
@@ -119,8 +119,8 @@ export interface IShadowGenerator {
119
119
  * Default implementation IShadowGenerator.
120
120
  * This is the main object responsible of generating shadows in the framework.
121
121
  * Documentation: https://doc.babylonjs.com/features/featuresDeepDive/lights/shadows
122
- * #IFYDRS#0: WebGL
123
- * #IFYDRS#835: WebGPU
122
+ * @see [WebGL](https://playground.babylonjs.com/#IFYDRS#0)
123
+ * @see [WebGPU](https://playground.babylonjs.com/#IFYDRS#835)
124
124
  */
125
125
  export declare class ShadowGenerator implements IShadowGenerator {
126
126
  /**
@@ -18,8 +18,8 @@ import { BindMorphTargetParameters, BindSceneUniformBuffer, PrepareDefinesAndAtt
18
18
  * Default implementation IShadowGenerator.
19
19
  * This is the main object responsible of generating shadows in the framework.
20
20
  * Documentation: https://doc.babylonjs.com/features/featuresDeepDive/lights/shadows
21
- * #IFYDRS#0: WebGL
22
- * #IFYDRS#835: WebGPU
21
+ * @see [WebGL](https://playground.babylonjs.com/#IFYDRS#0)
22
+ * @see [WebGPU](https://playground.babylonjs.com/#IFYDRS#835)
23
23
  */
24
24
  export class ShadowGenerator {
25
25
  /**