@babylonjs/core 7.54.0 → 7.54.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.
- package/AudioV2/abstractAudio/abstractAudioBus.d.ts +2 -3
- package/AudioV2/abstractAudio/abstractAudioBus.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.d.ts +2 -3
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +2 -2
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +7 -7
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.d.ts +2 -2
- package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.js +7 -7
- package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.d.ts +2 -2
- package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.js +7 -7
- package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.d.ts +1 -1
- package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js +2 -2
- package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.d.ts +3 -3
- package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js +9 -9
- package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js.map +1 -1
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.d.ts +2 -2
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +11 -11
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioBus.d.ts +6 -6
- package/AudioV2/webAudio/webAudioBus.js +27 -8
- package/AudioV2/webAudio/webAudioBus.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +7 -7
- package/AudioV2/webAudio/webAudioEngine.js +27 -27
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioMainBus.d.ts +3 -5
- package/AudioV2/webAudio/webAudioMainBus.js +11 -12
- package/AudioV2/webAudio/webAudioMainBus.js.map +1 -1
- package/AudioV2/webAudio/webAudioMainOut.d.ts +1 -1
- package/AudioV2/webAudio/webAudioMainOut.js +2 -2
- package/AudioV2/webAudio/webAudioMainOut.js.map +1 -1
- package/AudioV2/webAudio/webAudioNode.d.ts +2 -2
- package/AudioV2/webAudio/webAudioNode.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +7 -7
- package/AudioV2/webAudio/webAudioStaticSound.js +27 -27
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.d.ts +6 -6
- package/AudioV2/webAudio/webAudioStreamingSound.js +27 -27
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioUnmuteUI.js +3 -2
- package/AudioV2/webAudio/webAudioUnmuteUI.js.map +1 -1
- package/Engines/abstractEngine.js +5 -11
- package/Engines/abstractEngine.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +6 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +6 -6
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +31 -4
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +21 -1
- package/FlowGraph/flowGraphCoordinator.js +51 -2
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +3 -0
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +4 -0
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +4 -3
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +26 -17
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js +8 -0
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -0
- package/Materials/Node/nodeMaterial.js +6 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.js +11 -2
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +41 -13
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +11 -1
- package/Materials/Node/nodeMaterialBuildStateSharedData.js +11 -1
- package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Misc/sceneSerializer.js +2 -0
- package/Misc/sceneSerializer.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/imageProcessing.fragment.js +1 -1
- package/Shaders/imageProcessing.fragment.js.map +1 -1
- package/Shaders/motionBlur.fragment.js +1 -1
- package/Shaders/motionBlur.fragment.js.map +1 -1
- package/Shaders/screenSpaceReflection2.fragment.js +1 -1
- package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
- package/ShadersWGSL/imageProcessing.fragment.js +1 -1
- package/ShadersWGSL/imageProcessing.fragment.js.map +1 -1
- package/ShadersWGSL/motionBlur.fragment.js +1 -1
- package/ShadersWGSL/motionBlur.fragment.js.map +1 -1
- package/ShadersWGSL/screenSpaceReflection2.fragment.js +1 -1
- package/ShadersWGSL/screenSpaceReflection2.fragment.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +9 -2
- package/scene.js +9 -2
- package/scene.js.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FlowGraphEventBlock } from "../../flowGraphEventBlock.js";
|
|
2
2
|
import { Tools } from "../../../Misc/tools.js";
|
|
3
3
|
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
4
|
+
import { FlowGraphCoordinator } from "../../flowGraphCoordinator.js";
|
|
4
5
|
/**
|
|
5
6
|
* A block that receives a custom event.
|
|
6
7
|
* It saves the event data in the data outputs, based on the provided eventData in the configuration. For example, if the event data is
|
|
@@ -22,6 +23,11 @@ export class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {
|
|
|
22
23
|
}
|
|
23
24
|
_preparePendingTasks(context) {
|
|
24
25
|
const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);
|
|
26
|
+
// check if we are not exceeding the max number of events
|
|
27
|
+
if (observable && observable.hasObservers() && observable.observers.length > FlowGraphCoordinator.MaxEventsPerType) {
|
|
28
|
+
this._reportError(context, `FlowGraphReceiveCustomEventBlock: Too many observers for event ${this.config.eventId}. Max is ${FlowGraphCoordinator.MaxEventsPerType}.`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
25
31
|
const eventObserver = observable.add((eventData) => {
|
|
26
32
|
Object.keys(eventData).forEach((key) => {
|
|
27
33
|
this.getDataOutput(key)?.setValue(eventData[key], context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphReceiveCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"flowGraphReceiveCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,sCAA4C;AAiB3E;;;;GAIG;AACH,MAAM,OAAO,gCAAiC,SAAQ,mBAAmB;IAGrE;IACI;;OAEG;IACa,MAAsD;QAEtE,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAAgD;QAN1D,iBAAY,GAAW,CAAC,CAAC;QASrC,0CAA0C;QAC1C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QAClE,CAA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AAM,CAAC;YACJ,KAAK,CAAC,IAAI,CAAC,kEAAkE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACxG,CAAC;IACL,CAAC;IAEe,aAAa,CAAC,QAA0B,EAAE,QAAa;QACnE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,uFAA8C;IAClD,CAAC;CACJ;AACD,aAAa,kFAAyC,gCAAgC,CAAC,CAAC","sourcesContent":["import type { Observer } from \"../../../Misc/observable\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Tools } from \"../../../Misc/tools\";\r\nimport type { RichType } from \"../../flowGraphRichTypes\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\r\nimport { FlowGraphCoordinator } from \"core/FlowGraph/flowGraphCoordinator\";\r\n/**\r\n * Parameters used to create a FlowGraphReceiveCustomEventBlock.\r\n */\r\nexport interface IFlowGraphReceiveCustomEventBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The id of the event to receive.\r\n * This event id is unique to the environment (not the context).\r\n */\r\n eventId: string;\r\n /**\r\n * The names of the data outputs for that event. Should be in the same order as the event data in\r\n * SendCustomEvent\r\n */\r\n eventData: { [key: string]: { type: RichType<any> } };\r\n}\r\n\r\n/**\r\n * A block that receives a custom event.\r\n * It saves the event data in the data outputs, based on the provided eventData in the configuration. For example, if the event data is\r\n * `{ x: { type: RichTypeNumber }, y: { type: RichTypeNumber } }`, the block will have two data outputs: x and y.\r\n */\r\nexport class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {\r\n public override initPriority: number = 1;\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphReceiveCustomEventBlockConfiguration\r\n ) {\r\n super(config);\r\n // use event data to register data outputs\r\n for (const key in this.config.eventData) {\r\n this.registerDataOutput(key, this.config.eventData[key].type);\r\n }\r\n }\r\n\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);\r\n // check if we are not exceeding the max number of events\r\n if (observable && observable.hasObservers() && observable.observers.length > FlowGraphCoordinator.MaxEventsPerType) {\r\n this._reportError(context, `FlowGraphReceiveCustomEventBlock: Too many observers for event ${this.config.eventId}. Max is ${FlowGraphCoordinator.MaxEventsPerType}.`);\r\n return;\r\n }\r\n\r\n const eventObserver = observable.add((eventData: { [key: string]: any }) => {\r\n Object.keys(eventData).forEach((key) => {\r\n this.getDataOutput(key)?.setValue(eventData[key], context);\r\n });\r\n this._execute(context);\r\n });\r\n context._setExecutionVariable(this, \"_eventObserver\", eventObserver);\r\n }\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);\r\n if (observable) {\r\n const eventObserver = context._getExecutionVariable<Nullable<Observer<any[]>>>(this, \"_eventObserver\", null);\r\n observable.remove(eventObserver);\r\n } else {\r\n Tools.Warn(`FlowGraphReceiveCustomEventBlock: Missing observable for event ${this.config.eventId}`);\r\n }\r\n }\r\n\r\n public override _executeEvent(_context: FlowGraphContext, _payload: any): boolean {\r\n return true;\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.ReceiveCustomEvent;\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.ReceiveCustomEvent, FlowGraphReceiveCustomEventBlock);\r\n"]}
|
|
@@ -49,7 +49,7 @@ export class FlowGraphConsoleLogBlock extends FlowGraphExecutionBlockWithOutSign
|
|
|
49
49
|
const value = this.getDataInput(match)?.getValue(context);
|
|
50
50
|
if (value !== undefined) {
|
|
51
51
|
// replace all
|
|
52
|
-
template = template.replace(new RegExp(
|
|
52
|
+
template = template.replace(new RegExp(`\\{${match}\\}`, "g"), value.toString());
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
return template;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphConsoleLogBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,gCAAyB;AAgB1C;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,oCAAoC;IAY9E,YAAmB,MAA+C;QAC9D,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;QACrE,IAAI,MAAM,EAAE,eAAe,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YACjE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC1B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YAC/C,CAAC;QACL,CAAC;IACL,CAAC;IAED;;OAEG;IACI,QAAQ,CAAC,OAAyB;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,SAAS,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C;YAC/B,IAAI,QAAQ,GAAW,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;YACnD,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YACnD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;gBAC1D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACtB,cAAc;oBACd,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACrF,CAAC;YACL,CAAC;YACD,OAAO,QAAQ,CAAC;QACpB,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAEO,mBAAmB,CAAC,QAAgB;QACxC,MAAM,KAAK,GAAG,cAAc,CAAC;QAC7B,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,KAAK,CAAC;QACV,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAED,aAAa,kEAAiC,wBAAwB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../flowGraphExecutionBlockWithOutSignal\";\r\nimport { RichTypeAny } from \"../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\r\n\r\n/**\r\n * Configuration for the console log block.\r\n */\r\nexport interface IFlowGraphConsoleLogBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * An optional message template to use for the log message.\r\n * If provided, the template can hold placeholders for the message value.\r\n * For example, if the template is \"The message is: \\{data\\}\", a new data input called \"data\" will be created.\r\n * The value of the message input will be used to replace the placeholder in the template.\r\n */\r\n messageTemplate?: string;\r\n}\r\n\r\n/**\r\n * Block that logs a message to the console.\r\n */\r\nexport class FlowGraphConsoleLogBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Input connection: The message to log.\r\n * Will be ignored if a message template is provided.\r\n */\r\n public readonly message: FlowGraphDataConnection<any>;\r\n\r\n /**\r\n * Input connection: The log type.\r\n */\r\n public readonly logType: FlowGraphDataConnection<\"log\" | \"warn\" | \"error\">;\r\n\r\n public constructor(config?: IFlowGraphConsoleLogBlockConfiguration) {\r\n super(config);\r\n this.message = this.registerDataInput(\"message\", RichTypeAny);\r\n this.logType = this.registerDataInput(\"logType\", RichTypeAny, \"log\");\r\n if (config?.messageTemplate) {\r\n const matches = this._getTemplateMatches(config.messageTemplate);\r\n for (const match of matches) {\r\n this.registerDataInput(match, RichTypeAny);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _execute(context: FlowGraphContext): void {\r\n const typeValue = this.logType.getValue(context);\r\n const messageValue = this._getMessageValue(context);\r\n if (typeValue === \"warn\") {\r\n Logger.Warn(messageValue);\r\n } else if (typeValue === \"error\") {\r\n Logger.Error(messageValue);\r\n } else {\r\n Logger.Log(messageValue);\r\n }\r\n // activate the output flow block\r\n this.out._activateSignal(context);\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.ConsoleLog;\r\n }\r\n\r\n private _getMessageValue(context: FlowGraphContext): string {\r\n if (this.config?.messageTemplate) {\r\n let template: string = this.config.messageTemplate;\r\n const matches = this._getTemplateMatches(template);\r\n for (const match of matches) {\r\n const value = this.getDataInput(match)?.getValue(context);\r\n if (value !== undefined) {\r\n // replace all\r\n template = template.replace(new RegExp(`\\\\{${match}\\\\}`, \"g\"), value.toString());\r\n }\r\n }\r\n return template;\r\n } else {\r\n return this.message.getValue(context);\r\n }\r\n }\r\n\r\n private _getTemplateMatches(template: string): string[] {\r\n const regex = /\\{([^}]+)\\}/g;\r\n const matches: string[] = [];\r\n let match;\r\n while ((match = regex.exec(template)) !== null) {\r\n matches.push(match[1]);\r\n }\r\n return matches;\r\n }\r\n}\r\n\r\nRegisterClass(FlowGraphBlockNames.ConsoleLog, FlowGraphConsoleLogBlock);\r\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { IFlowGraphBlockConfiguration } from "../../flowGraphBlock";
|
|
2
2
|
import type { FlowGraphContext } from "../../flowGraphContext";
|
|
3
|
-
import type { FlowGraphDataConnection } from "../../flowGraphDataConnection";
|
|
4
3
|
import { FlowGraphExecutionBlockWithOutSignal } from "../../flowGraphExecutionBlockWithOutSignal";
|
|
5
4
|
import type { FlowGraphSignalConnection } from "../../flowGraphSignalConnection";
|
|
6
5
|
/**
|
|
@@ -10,18 +9,19 @@ export interface IFlowGraphSetVariableBlockConfiguration extends IFlowGraphBlock
|
|
|
10
9
|
/**
|
|
11
10
|
* The name of the variable to set.
|
|
12
11
|
*/
|
|
13
|
-
variable
|
|
12
|
+
variable?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The name of the variables to set.
|
|
15
|
+
*/
|
|
16
|
+
variables?: string[];
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* This block will set a variable on the context.
|
|
17
20
|
*/
|
|
18
21
|
export declare class FlowGraphSetVariableBlock<T> extends FlowGraphExecutionBlockWithOutSignal {
|
|
19
|
-
/**
|
|
20
|
-
* Input connection: The value to set.
|
|
21
|
-
*/
|
|
22
|
-
readonly value: FlowGraphDataConnection<T>;
|
|
23
22
|
constructor(config: IFlowGraphSetVariableBlockConfiguration);
|
|
24
23
|
_execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void;
|
|
24
|
+
private _saveVariable;
|
|
25
25
|
getClassName(): string;
|
|
26
26
|
serialize(serializationObject?: any): void;
|
|
27
27
|
}
|
|
@@ -7,9 +7,36 @@ import { RichTypeAny } from "../../flowGraphRichTypes.js";
|
|
|
7
7
|
export class FlowGraphSetVariableBlock extends FlowGraphExecutionBlockWithOutSignal {
|
|
8
8
|
constructor(config) {
|
|
9
9
|
super(config);
|
|
10
|
-
|
|
10
|
+
// check if the variable is defined
|
|
11
|
+
if (!config.variable && !config.variables) {
|
|
12
|
+
throw new Error("FlowGraphSetVariableBlock: variable/variables is not defined");
|
|
13
|
+
}
|
|
14
|
+
// check if the variable is an array
|
|
15
|
+
if (config.variables && config.variable) {
|
|
16
|
+
throw new Error("FlowGraphSetVariableBlock: variable and variables are both defined");
|
|
17
|
+
}
|
|
18
|
+
// check if we have either a variable or variables. If we have variables, set the inputs correctly
|
|
19
|
+
if (config.variables) {
|
|
20
|
+
for (const variable of config.variables) {
|
|
21
|
+
this.registerDataInput(variable, RichTypeAny);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.registerDataInput("value", RichTypeAny);
|
|
26
|
+
}
|
|
11
27
|
}
|
|
12
28
|
_execute(context, _callingSignal) {
|
|
29
|
+
if (this.config?.variables) {
|
|
30
|
+
for (const variable of this.config.variables) {
|
|
31
|
+
this._saveVariable(context, variable);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this._saveVariable(context, this.config?.variable, "value");
|
|
36
|
+
}
|
|
37
|
+
this.out._activateSignal(context);
|
|
38
|
+
}
|
|
39
|
+
_saveVariable(context, variableName, inputName) {
|
|
13
40
|
// check if there is an animation(group) running on this variable. If there is, stop the animation - a value was force-set.
|
|
14
41
|
const currentlyRunningAnimationGroups = context._getGlobalContextVariable("currentlyRunningAnimationGroups", []);
|
|
15
42
|
for (const animationUniqueId of currentlyRunningAnimationGroups) {
|
|
@@ -20,7 +47,7 @@ export class FlowGraphSetVariableBlock extends FlowGraphExecutionBlockWithOutSig
|
|
|
20
47
|
// check if the target property is the variable we are setting
|
|
21
48
|
if (targetAnimation.target === context) {
|
|
22
49
|
// check the variable name
|
|
23
|
-
if (targetAnimation.animation.targetProperty ===
|
|
50
|
+
if (targetAnimation.animation.targetProperty === variableName) {
|
|
24
51
|
// stop the animation
|
|
25
52
|
animation.stop();
|
|
26
53
|
// remove the animation from the currently running animations
|
|
@@ -35,8 +62,8 @@ export class FlowGraphSetVariableBlock extends FlowGraphExecutionBlockWithOutSig
|
|
|
35
62
|
}
|
|
36
63
|
}
|
|
37
64
|
}
|
|
38
|
-
|
|
39
|
-
|
|
65
|
+
const value = this.getDataInput(inputName || variableName)?.getValue(context);
|
|
66
|
+
context.setVariable(variableName, value);
|
|
40
67
|
}
|
|
41
68
|
getClassName() {
|
|
42
69
|
return "FlowGraphSetVariableBlock" /* FlowGraphBlockNames.SetVariable */;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphSetVariableBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mCAA4B;
|
|
1
|
+
{"version":3,"file":"flowGraphSetVariableBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mCAA4B;AAGpD,OAAO,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAC;AAGlG,OAAO,EAAE,WAAW,EAAE,oCAA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CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC;IAChE,CAAC;CACJ;AAED,aAAa,oEAAkC,yBAAyB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"core/Misc/typeStore\";\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../flowGraphExecutionBlockWithOutSignal\";\nimport type { FlowGraphSignalConnection } from \"../../flowGraphSignalConnection\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\n\n/**\n * The configuration of the FlowGraphGetVariableBlock.\n */\nexport interface IFlowGraphSetVariableBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The name of the variable to set.\n */\n variable?: string;\n\n /**\n * The name of the variables to set.\n */\n variables?: string[];\n}\n\n/**\n * This block will set a variable on the context.\n */\nexport class FlowGraphSetVariableBlock<T> extends FlowGraphExecutionBlockWithOutSignal {\n constructor(config: IFlowGraphSetVariableBlockConfiguration) {\n super(config);\n // check if the variable is defined\n if (!config.variable && !config.variables) {\n throw new Error(\"FlowGraphSetVariableBlock: variable/variables is not defined\");\n }\n // check if the variable is an array\n if (config.variables && config.variable) {\n throw new Error(\"FlowGraphSetVariableBlock: variable and variables are both defined\");\n }\n // check if we have either a variable or variables. If we have variables, set the inputs correctly\n if (config.variables) {\n for (const variable of config.variables) {\n this.registerDataInput(variable, RichTypeAny);\n }\n } else {\n this.registerDataInput(\"value\", RichTypeAny);\n }\n }\n\n public override _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\n if (this.config?.variables) {\n for (const variable of this.config.variables) {\n this._saveVariable(context, variable);\n }\n } else {\n this._saveVariable(context, this.config?.variable!, \"value\");\n }\n this.out._activateSignal(context);\n }\n\n private _saveVariable(context: FlowGraphContext, variableName: string, inputName?: string): void {\n // check if there is an animation(group) running on this variable. If there is, stop the animation - a value was force-set.\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\n for (const animationUniqueId of currentlyRunningAnimationGroups) {\n const animation = context.assetsContext.animationGroups[animationUniqueId];\n // check if there is a target animation that has the target set to be the context\n for (const targetAnimation of animation.targetedAnimations) {\n if (targetAnimation.target === context) {\n // check if the target property is the variable we are setting\n if (targetAnimation.target === context) {\n // check the variable name\n if (targetAnimation.animation.targetProperty === variableName) {\n // stop the animation\n animation.stop();\n // remove the animation from the currently running animations\n const index = currentlyRunningAnimationGroups.indexOf(animationUniqueId);\n if (index > -1) {\n currentlyRunningAnimationGroups.splice(index, 1);\n }\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\n break;\n }\n }\n }\n }\n }\n const value = this.getDataInput(inputName || variableName)?.getValue(context);\n context.setVariable(variableName, value);\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.SetVariable;\n }\n\n public override serialize(serializationObject?: any): void {\n super.serialize(serializationObject);\n serializationObject.config.variable = this.config?.variable;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.SetVariable, FlowGraphSetVariableBlock);\n"]}
|
|
@@ -44,13 +44,32 @@ export declare class FlowGraphCoordinator {
|
|
|
44
44
|
* the configuration of the block
|
|
45
45
|
*/
|
|
46
46
|
config: IFlowGraphCoordinatorConfiguration;
|
|
47
|
+
/**
|
|
48
|
+
* The maximum number of events per type.
|
|
49
|
+
* This is used to limit the number of events that can be created in a single scene.
|
|
50
|
+
* This is to prevent infinite loops.
|
|
51
|
+
*/
|
|
52
|
+
static MaxEventsPerType: number;
|
|
53
|
+
/**
|
|
54
|
+
* The maximum number of execution of a specific event in a single frame.
|
|
55
|
+
*/
|
|
56
|
+
static MaxEventTypeExecutionPerFrame: number;
|
|
47
57
|
/**
|
|
48
58
|
* @internal
|
|
49
59
|
* A list of all the coordinators per scene. Will be used by the inspector
|
|
50
60
|
*/
|
|
51
61
|
static readonly SceneCoordinators: Map<Scene, FlowGraphCoordinator[]>;
|
|
62
|
+
/**
|
|
63
|
+
* When set to true (default) custom events will be dispatched synchronously.
|
|
64
|
+
* This means that the events will be dispatched immediately when they are triggered.
|
|
65
|
+
*/
|
|
66
|
+
dispatchEventsSynchronously: boolean;
|
|
52
67
|
private readonly _flowGraphs;
|
|
53
68
|
private _customEventsMap;
|
|
69
|
+
private _eventExecutionCounter;
|
|
70
|
+
private _disposeObserver;
|
|
71
|
+
private _onBeforeRenderObserver;
|
|
72
|
+
private _executeOnNextFrame;
|
|
54
73
|
constructor(
|
|
55
74
|
/**
|
|
56
75
|
* the configuration of the block
|
|
@@ -94,6 +113,7 @@ export declare class FlowGraphCoordinator {
|
|
|
94
113
|
* Notifies the observable for the given event id with the given data.
|
|
95
114
|
* @param id the id of the event
|
|
96
115
|
* @param data the data to send with the event
|
|
116
|
+
* @param async if true, the event will be dispatched asynchronously
|
|
97
117
|
*/
|
|
98
|
-
notifyCustomEvent(id: string, data: any): void;
|
|
118
|
+
notifyCustomEvent(id: string, data: any, async?: boolean): void;
|
|
99
119
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Observable } from "../Misc/observable.js";
|
|
2
2
|
import { FlowGraph } from "./flowGraph.js";
|
|
3
|
+
import { Logger } from "../Misc/logger.js";
|
|
3
4
|
/**
|
|
4
5
|
* This class holds all of the existing flow graphs and is responsible for creating new ones.
|
|
5
6
|
* It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator
|
|
@@ -13,12 +14,30 @@ export class FlowGraphCoordinator {
|
|
|
13
14
|
*/
|
|
14
15
|
config) {
|
|
15
16
|
this.config = config;
|
|
17
|
+
/**
|
|
18
|
+
* When set to true (default) custom events will be dispatched synchronously.
|
|
19
|
+
* This means that the events will be dispatched immediately when they are triggered.
|
|
20
|
+
*/
|
|
21
|
+
this.dispatchEventsSynchronously = true;
|
|
16
22
|
this._flowGraphs = [];
|
|
17
23
|
this._customEventsMap = new Map();
|
|
24
|
+
this._eventExecutionCounter = new Map();
|
|
25
|
+
this._executeOnNextFrame = [];
|
|
18
26
|
// When the scene is disposed, dispose all graphs currently running on it.
|
|
19
|
-
this.config.scene.onDisposeObservable.add(() => {
|
|
27
|
+
this._disposeObserver = this.config.scene.onDisposeObservable.add(() => {
|
|
20
28
|
this.dispose();
|
|
21
29
|
});
|
|
30
|
+
this._onBeforeRenderObserver = this.config.scene.onBeforeRenderObservable.add(() => {
|
|
31
|
+
// Reset the event execution counter at the beginning of each frame.
|
|
32
|
+
this._eventExecutionCounter.clear();
|
|
33
|
+
if (this._executeOnNextFrame.length) {
|
|
34
|
+
// Execute the events that were triggered on the next frame.
|
|
35
|
+
this._executeOnNextFrame.forEach((event) => {
|
|
36
|
+
this.notifyCustomEvent(event.id, event.data, false);
|
|
37
|
+
});
|
|
38
|
+
this._executeOnNextFrame.length = 0;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
22
41
|
// Add itself to the SceneCoordinators list for the Inspector.
|
|
23
42
|
const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];
|
|
24
43
|
coordinators.push(this);
|
|
@@ -55,6 +74,8 @@ export class FlowGraphCoordinator {
|
|
|
55
74
|
dispose() {
|
|
56
75
|
this._flowGraphs.forEach((graph) => graph.dispose());
|
|
57
76
|
this._flowGraphs.length = 0;
|
|
77
|
+
this._disposeObserver?.remove();
|
|
78
|
+
this._onBeforeRenderObserver?.remove();
|
|
58
79
|
// Remove itself from the SceneCoordinators list for the Inspector.
|
|
59
80
|
const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];
|
|
60
81
|
const index = coordinators.indexOf(this);
|
|
@@ -74,6 +95,7 @@ export class FlowGraphCoordinator {
|
|
|
74
95
|
graph.serialize(serializedGraph, valueSerializeFunction);
|
|
75
96
|
serializationObject._flowGraphs.push(serializedGraph);
|
|
76
97
|
});
|
|
98
|
+
serializationObject.dispatchEventsSynchronously = this.dispatchEventsSynchronously;
|
|
77
99
|
}
|
|
78
100
|
/**
|
|
79
101
|
* Gets the list of flow graphs
|
|
@@ -99,14 +121,41 @@ export class FlowGraphCoordinator {
|
|
|
99
121
|
* Notifies the observable for the given event id with the given data.
|
|
100
122
|
* @param id the id of the event
|
|
101
123
|
* @param data the data to send with the event
|
|
124
|
+
* @param async if true, the event will be dispatched asynchronously
|
|
102
125
|
*/
|
|
103
|
-
notifyCustomEvent(id, data) {
|
|
126
|
+
notifyCustomEvent(id, data, async = !this.dispatchEventsSynchronously) {
|
|
127
|
+
if (async) {
|
|
128
|
+
this._executeOnNextFrame.push({ id, data });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// check if we are not exceeding the max number of events
|
|
132
|
+
if (this._eventExecutionCounter.has(id)) {
|
|
133
|
+
const count = this._eventExecutionCounter.get(id);
|
|
134
|
+
this._eventExecutionCounter.set(id, count + 1);
|
|
135
|
+
if (count >= FlowGraphCoordinator.MaxEventTypeExecutionPerFrame) {
|
|
136
|
+
count === FlowGraphCoordinator.MaxEventTypeExecutionPerFrame && Logger.Warn(`FlowGraphCoordinator: Too many executions of event "${id}".`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this._eventExecutionCounter.set(id, 1);
|
|
142
|
+
}
|
|
104
143
|
const observable = this._customEventsMap.get(id);
|
|
105
144
|
if (observable) {
|
|
106
145
|
observable.notifyObservers(data);
|
|
107
146
|
}
|
|
108
147
|
}
|
|
109
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* The maximum number of events per type.
|
|
151
|
+
* This is used to limit the number of events that can be created in a single scene.
|
|
152
|
+
* This is to prevent infinite loops.
|
|
153
|
+
*/
|
|
154
|
+
FlowGraphCoordinator.MaxEventsPerType = 30;
|
|
155
|
+
/**
|
|
156
|
+
* The maximum number of execution of a specific event in a single frame.
|
|
157
|
+
*/
|
|
158
|
+
FlowGraphCoordinator.MaxEventTypeExecutionPerFrame = 30;
|
|
110
159
|
/**
|
|
111
160
|
* @internal
|
|
112
161
|
* A list of all the coordinators per scene. Will be used by the inspector
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAmCxC;;;;;GAKG;AACH,MAAM,OAAO,oBAAoB;IAW7B;IACI;;OAEG;IACI,MAA0C;QAA1C,WAAM,GAAN,MAAM,CAAoC;QARpC,gBAAW,GAAgB,EAAE,CAAC;QAEvC,qBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;QAQ/D,0EAA0E;QAC1E,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;QAEH,8DAA8D;QAC9D,MAAM,YAAY,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACzF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,WAAW;QACd,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7E,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,KAAgB;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;Q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jB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,wBAAwB,CAAC,EAAU;QACtC,IAAI,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,oGAAoG;YACpG,UAAU,GAAG,IAAI,UAAU,EAAM,mBAAmB,CAAC,CAAC;YACtD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,iBAAiB,CAAC,EAAU,EAAE,IAAS;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,UAAU,EAAE,CAAC;YACb,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;;AApHD;;;GAGG;AACoB,sCAAiB,GAAuC,IAAI,GAAG,EAAE,AAAhD,CAAiD","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { Scene } from \"../scene\";\r\nimport { FlowGraph } from \"./flowGraph\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport type { IObjectAccessor } from \"./typeDefinitions\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\n\r\n/**\r\n * Parameters used to create a flow graph engine.\r\n */\r\nexport interface IFlowGraphCoordinatorConfiguration {\r\n /**\r\n * The scene that the flow graph engine belongs to.\r\n */\r\n scene: Scene;\r\n}\r\n\r\n/**\r\n * Parameters used to parse a flow graph coordinator.\r\n */\r\nexport interface FlowGraphCoordinatorParseOptions {\r\n /**\r\n * A function that will be called to parse the value of a property.\r\n * @param key the key of the property\r\n * @param serializationObject the serialization object where the property is located\r\n * @param scene the scene that the block is being parsed in\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The path converter to use to convert the path to an object accessor.\r\n */\r\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\r\n /**\r\n * The scene that the flow graph coordinator belongs to.\r\n */\r\n scene: Scene;\r\n}\r\n/**\r\n * This class holds all of the existing flow graphs and is responsible for creating new ones.\r\n * It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator\r\n * This is the entry point for the flow graph system.\r\n * @experimental This class is still in development and is subject to change.\r\n */\r\nexport class FlowGraphCoordinator {\r\n /**\r\n * @internal\r\n * A list of all the coordinators per scene. Will be used by the inspector\r\n */\r\n public static readonly SceneCoordinators: Map<Scene, FlowGraphCoordinator[]> = new Map();\r\n\r\n private readonly _flowGraphs: FlowGraph[] = [];\r\n\r\n private _customEventsMap: Map<string, Observable<any>> = new Map();\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphCoordinatorConfiguration\r\n ) {\r\n // When the scene is disposed, dispose all graphs currently running on it.\r\n this.config.scene.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n // Add itself to the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n coordinators.push(this);\r\n }\r\n\r\n /**\r\n * Creates a new flow graph and adds it to the list of existing flow graphs\r\n * @returns a new flow graph\r\n */\r\n public createGraph(): FlowGraph {\r\n const graph = new FlowGraph({ scene: this.config.scene, coordinator: this });\r\n this._flowGraphs.push(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Removes a flow graph from the list of existing flow graphs and disposes it\r\n * @param graph the graph to remove\r\n */\r\n public removeGraph(graph: FlowGraph) {\r\n const index = this._flowGraphs.indexOf(graph);\r\n if (index !== -1) {\r\n graph.dispose();\r\n this._flowGraphs.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Starts all graphs\r\n */\r\n public start() {\r\n this._flowGraphs.forEach((graph) => graph.start());\r\n }\r\n\r\n /**\r\n * Disposes all graphs\r\n */\r\n public dispose() {\r\n this._flowGraphs.forEach((graph) => graph.dispose());\r\n this._flowGraphs.length = 0;\r\n\r\n // Remove itself from the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n const index = coordinators.indexOf(this);\r\n if (index !== -1) {\r\n coordinators.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Serializes this coordinator to a JSON object.\r\n * @param serializationObject the object to serialize to\r\n * @param valueSerializeFunction the function to use to serialize the value\r\n */\r\n public serialize(serializationObject: any, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject._flowGraphs = [];\r\n this._flowGraphs.forEach((graph) => {\r\n const serializedGraph = {};\r\n graph.serialize(serializedGraph, valueSerializeFunction);\r\n serializationObject._flowGraphs.push(serializedGraph);\r\n });\r\n }\r\n\r\n /**\r\n * Gets the list of flow graphs\r\n */\r\n public get flowGraphs() {\r\n return this._flowGraphs;\r\n }\r\n\r\n /**\r\n * Get an observable that will be notified when the event with the given id is fired.\r\n * @param id the id of the event\r\n * @returns the observable for the event\r\n */\r\n public getCustomEventObservable(id: string): Observable<any> {\r\n let observable = this._customEventsMap.get(id);\r\n if (!observable) {\r\n // receive event is initialized before scene start, so no need to notify if triggered. but possible!\r\n observable = new Observable<any>(/*undefined, true*/);\r\n this._customEventsMap.set(id, observable);\r\n }\r\n return observable;\r\n }\r\n\r\n /**\r\n * Notifies the observable for the given event id with the given data.\r\n * @param id the id of the event\r\n * @param data the data to send with the event\r\n */\r\n public notifyCustomEvent(id: string, data: any) {\r\n const observable = this._customEventsMap.get(id);\r\n if (observable) {\r\n observable.notifyObservers(data);\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":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EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5C,OAAO;QACX,CAAC;QACD,yDAAyD;QACzD,IAAI,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC;YACnD,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC/C,IAAI,KAAK,IAAI,oBAAoB,CAAC,6BAA6B,EAAE,CAAC;gBAC9D,KAAK,KAAK,oBAAoB,CAAC,6BAA6B,IAAI,MAAM,CAAC,IAAI,CAAC,uDAAuD,EAAE,IAAI,CAAC,CAAC;gBAC3I,OAAO;YACX,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,UAAU,EAAE,CAAC;YACb,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;;AA1KD;;;;GAIG;AACW,qCAAgB,GAAW,EAAE,AAAb,CAAc;AAE5C;;GAEG;AACW,kDAA6B,GAAW,EAAE,AAAb,CAAc;AACzD;;;GAGG;AACoB,sCAAiB,GAAuC,IAAI,GAAG,EAAE,AAAhD,CAAiD","sourcesContent":["import type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport type { Scene } from \"../scene\";\r\nimport { FlowGraph } from \"./flowGraph\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport type { IObjectAccessor } from \"./typeDefinitions\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Parameters used to create a flow graph engine.\r\n */\r\nexport interface IFlowGraphCoordinatorConfiguration {\r\n /**\r\n * The scene that the flow graph engine belongs to.\r\n */\r\n scene: Scene;\r\n}\r\n\r\n/**\r\n * Parameters used to parse a flow graph coordinator.\r\n */\r\nexport interface FlowGraphCoordinatorParseOptions {\r\n /**\r\n * A function that will be called to parse the value of a property.\r\n * @param key the key of the property\r\n * @param serializationObject the serialization object where the property is located\r\n * @param scene the scene that the block is being parsed in\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The path converter to use to convert the path to an object accessor.\r\n */\r\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\r\n /**\r\n * The scene that the flow graph coordinator belongs to.\r\n */\r\n scene: Scene;\r\n}\r\n/**\r\n * This class holds all of the existing flow graphs and is responsible for creating new ones.\r\n * It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator\r\n * This is the entry point for the flow graph system.\r\n * @experimental This class is still in development and is subject to change.\r\n */\r\nexport class FlowGraphCoordinator {\r\n /**\r\n * The maximum number of events per type.\r\n * This is used to limit the number of events that can be created in a single scene.\r\n * This is to prevent infinite loops.\r\n */\r\n public static MaxEventsPerType: number = 30;\r\n\r\n /**\r\n * The maximum number of execution of a specific event in a single frame.\r\n */\r\n public static MaxEventTypeExecutionPerFrame: number = 30;\r\n /**\r\n * @internal\r\n * A list of all the coordinators per scene. Will be used by the inspector\r\n */\r\n public static readonly SceneCoordinators: Map<Scene, FlowGraphCoordinator[]> = new Map();\r\n\r\n /**\r\n * When set to true (default) custom events will be dispatched synchronously.\r\n * This means that the events will be dispatched immediately when they are triggered.\r\n */\r\n public dispatchEventsSynchronously: boolean = true;\r\n\r\n private readonly _flowGraphs: FlowGraph[] = [];\r\n\r\n private _customEventsMap: Map<string, Observable<any>> = new Map();\r\n\r\n private _eventExecutionCounter: Map<string, number> = new Map();\r\n\r\n private _disposeObserver: Observer<Scene>;\r\n private _onBeforeRenderObserver: Observer<Scene>;\r\n private _executeOnNextFrame: { id: string; data?: any }[] = [];\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphCoordinatorConfiguration\r\n ) {\r\n // When the scene is disposed, dispose all graphs currently running on it.\r\n this._disposeObserver = this.config.scene.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n this._onBeforeRenderObserver = this.config.scene.onBeforeRenderObservable.add(() => {\r\n // Reset the event execution counter at the beginning of each frame.\r\n this._eventExecutionCounter.clear();\r\n if (this._executeOnNextFrame.length) {\r\n // Execute the events that were triggered on the next frame.\r\n this._executeOnNextFrame.forEach((event) => {\r\n this.notifyCustomEvent(event.id, event.data, false);\r\n });\r\n this._executeOnNextFrame.length = 0;\r\n }\r\n });\r\n\r\n // Add itself to the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n coordinators.push(this);\r\n }\r\n\r\n /**\r\n * Creates a new flow graph and adds it to the list of existing flow graphs\r\n * @returns a new flow graph\r\n */\r\n public createGraph(): FlowGraph {\r\n const graph = new FlowGraph({ scene: this.config.scene, coordinator: this });\r\n this._flowGraphs.push(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Removes a flow graph from the list of existing flow graphs and disposes it\r\n * @param graph the graph to remove\r\n */\r\n public removeGraph(graph: FlowGraph) {\r\n const index = this._flowGraphs.indexOf(graph);\r\n if (index !== -1) {\r\n graph.dispose();\r\n this._flowGraphs.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Starts all graphs\r\n */\r\n public start() {\r\n this._flowGraphs.forEach((graph) => graph.start());\r\n }\r\n\r\n /**\r\n * Disposes all graphs\r\n */\r\n public dispose() {\r\n this._flowGraphs.forEach((graph) => graph.dispose());\r\n this._flowGraphs.length = 0;\r\n this._disposeObserver?.remove();\r\n this._onBeforeRenderObserver?.remove();\r\n\r\n // Remove itself from the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n const index = coordinators.indexOf(this);\r\n if (index !== -1) {\r\n coordinators.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Serializes this coordinator to a JSON object.\r\n * @param serializationObject the object to serialize to\r\n * @param valueSerializeFunction the function to use to serialize the value\r\n */\r\n public serialize(serializationObject: any, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject._flowGraphs = [];\r\n this._flowGraphs.forEach((graph) => {\r\n const serializedGraph = {};\r\n graph.serialize(serializedGraph, valueSerializeFunction);\r\n serializationObject._flowGraphs.push(serializedGraph);\r\n });\r\n serializationObject.dispatchEventsSynchronously = this.dispatchEventsSynchronously;\r\n }\r\n\r\n /**\r\n * Gets the list of flow graphs\r\n */\r\n public get flowGraphs() {\r\n return this._flowGraphs;\r\n }\r\n\r\n /**\r\n * Get an observable that will be notified when the event with the given id is fired.\r\n * @param id the id of the event\r\n * @returns the observable for the event\r\n */\r\n public getCustomEventObservable(id: string): Observable<any> {\r\n let observable = this._customEventsMap.get(id);\r\n if (!observable) {\r\n // receive event is initialized before scene start, so no need to notify if triggered. but possible!\r\n observable = new Observable<any>(/*undefined, true*/);\r\n this._customEventsMap.set(id, observable);\r\n }\r\n return observable;\r\n }\r\n\r\n /**\r\n * Notifies the observable for the given event id with the given data.\r\n * @param id the id of the event\r\n * @param data the data to send with the event\r\n * @param async if true, the event will be dispatched asynchronously\r\n */\r\n public notifyCustomEvent(id: string, data: any, async: boolean = !this.dispatchEventsSynchronously) {\r\n if (async) {\r\n this._executeOnNextFrame.push({ id, data });\r\n return;\r\n }\r\n // check if we are not exceeding the max number of events\r\n if (this._eventExecutionCounter.has(id)) {\r\n const count = this._eventExecutionCounter.get(id)!;\r\n this._eventExecutionCounter.set(id, count + 1);\r\n if (count >= FlowGraphCoordinator.MaxEventTypeExecutionPerFrame) {\r\n count === FlowGraphCoordinator.MaxEventTypeExecutionPerFrame && Logger.Warn(`FlowGraphCoordinator: Too many executions of event \"${id}\".`);\r\n return;\r\n }\r\n } else {\r\n this._eventExecutionCounter.set(id, 1);\r\n }\r\n const observable = this._customEventsMap.get(id);\r\n if (observable) {\r\n observable.notifyObservers(data);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -47,6 +47,9 @@ export function GetSignalInConnectionByUniqueId(blocks, uniqueId) {
|
|
|
47
47
|
export async function ParseCoordinatorAsync(serializedObject, options) {
|
|
48
48
|
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
49
49
|
const coordinator = new FlowGraphCoordinator({ scene: options.scene });
|
|
50
|
+
if (serializedObject.dispatchEventsSynchronously) {
|
|
51
|
+
coordinator.dispatchEventsSynchronously = serializedObject.dispatchEventsSynchronously;
|
|
52
|
+
}
|
|
50
53
|
await options.scene.whenReadyAsync();
|
|
51
54
|
// if custom default values are defined, set them in the global context
|
|
52
55
|
if (serializedObject._defaultValues) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphParser.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAM9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGhF,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG5E;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAwB,EAAE,QAAgB;IACrF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,KAAK,MAAM,OAAO,IA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AAU,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,mBAAwB;IAC3C,OAAO,IAAI,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import type { IAssetContainer } from \"core/IAssetContainer\";\nimport { blockFactory } from \"./Blocks/flowGraphBlockFactory\";\nimport type { FlowGraphBlockNames } from \"./Blocks/flowGraphBlockNames\";\nimport type { FlowGraph, IFlowGraphParseOptions } from \"./flowGraph\";\nimport type { FlowGraphBlock, IFlowGraphBlockParseOptions } from \"./flowGraphBlock\";\nimport type { FlowGraphContext, IFlowGraphContextParseOptions } from \"./flowGraphContext\";\nimport type { FlowGraphCoordinatorParseOptions } from \"./flowGraphCoordinator\";\nimport { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\nimport { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\nimport { defaultValueParseFunction, needsPathConverter } from \"./serialization\";\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphContext } from \"./typeDefinitions\";\nimport type { Node } from \"core/node\";\nimport { getRichTypeByFlowGraphType, RichType } from \"./flowGraphRichTypes\";\nimport type { FlowGraphConnection } from \"./flowGraphConnection\";\n\n/**\n * Given a list of blocks, find an output data connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetDataOutConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphDataConnection<any> {\n for (const block of blocks) {\n for (const dataOut of block.dataOutputs) {\n if (dataOut.uniqueId === uniqueId) {\n return dataOut;\n }\n }\n }\n throw new Error(\"Could not find data out connection with unique id \" + uniqueId);\n}\n\n/**\n * Given a list of blocks, find an input signal connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetSignalInConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphSignalConnection {\n for (const block of blocks) {\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalIn of block.signalInputs) {\n if (signalIn.uniqueId === uniqueId) {\n return signalIn;\n }\n }\n }\n }\n throw new Error(\"Could not find signal in connection with unique id \" + uniqueId);\n}\n\n/**\n * Parses a serialized coordinator.\n * @param serializedObject the object to parse\n * @param options the options to use when parsing\n * @returns the parsed coordinator\n */\nexport async function ParseCoordinatorAsync(serializedObject: any, options: FlowGraphCoordinatorParseOptions) {\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n const coordinator = new FlowGraphCoordinator({ scene: options.scene });\n\n await options.scene.whenReadyAsync();\n // if custom default values are defined, set them in the global context\n if (serializedObject._defaultValues) {\n for (const key in serializedObject._defaultValues) {\n // key is the FlowGraphType, value is the default value\n const value = serializedObject._defaultValues[key];\n getRichTypeByFlowGraphType(key).defaultValue = value;\n }\n }\n // async-parse the flow graphs. This can be done in parallel\n await Promise.all(\n serializedObject._flowGraphs?.map((serializedGraph: any) => ParseFlowGraphAsync(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter }))\n );\n return coordinator;\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @returns the parsed graph\n */\nexport async function ParseFlowGraphAsync(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions): Promise<FlowGraph> {\n // get all classes types needed for the blocks using the block factory\n const resolvedClasses = await Promise.all(\n serializationObject.allBlocks.map(async (serializedBlock) => {\n const classFactory = blockFactory(serializedBlock.className as FlowGraphBlockNames);\n return classFactory();\n })\n );\n // async will be used when we start using the block async factory\n return ParseFlowGraph(serializationObject, options, resolvedClasses);\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @param resolvedClasses the resolved classes for the blocks\n * @returns the parsed graph\n */\nexport function ParseFlowGraph(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions, resolvedClasses: (typeof FlowGraphBlock)[]) {\n const graph = options.coordinator.createGraph();\n const blocks: FlowGraphBlock[] = [];\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n // Parse all blocks\n // for (const serializedBlock of serializationObject.allBlocks) {\n for (let i = 0; i < serializationObject.allBlocks.length; i++) {\n const serializedBlock = serializationObject.allBlocks[i];\n const block = ParseFlowGraphBlockWithClassType(\n serializedBlock,\n { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, assetsContainer: options.coordinator.config.scene, valueParseFunction },\n resolvedClasses[i]\n );\n blocks.push(block);\n if (block instanceof FlowGraphEventBlock) {\n graph.addEventBlock(block);\n }\n }\n // After parsing all blocks, connect them\n for (const block of blocks) {\n for (const dataIn of block.dataInputs) {\n for (const serializedConnection of dataIn.connectedPointIds) {\n const connection = GetDataOutConnectionByUniqueId(blocks, serializedConnection);\n dataIn.connectTo(connection);\n }\n }\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalOut of block.signalOutputs) {\n for (const serializedConnection of signalOut.connectedPointIds) {\n const connection = GetSignalInConnectionByUniqueId(blocks, serializedConnection);\n signalOut.connectTo(connection);\n }\n }\n }\n }\n for (const serializedContext of serializationObject.executionContexts) {\n ParseFlowGraphContext(serializedContext, { graph, valueParseFunction }, serializationObject.rightHanded);\n }\n return graph;\n}\n\n/**\n * Parses a context\n * @param serializationObject the object containing the context serialization values\n * @param options the options for parsing the context\n * @param rightHanded whether the serialized data is right handed\n * @returns\n */\nexport function ParseFlowGraphContext(serializationObject: ISerializedFlowGraphContext, options: IFlowGraphContextParseOptions, rightHanded?: boolean): FlowGraphContext {\n const result = options.graph.createContext();\n if (serializationObject.enableLogging) {\n result.enableLogging = true;\n }\n result.treatDataAsRightHanded = rightHanded || false;\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n result.uniqueId = serializationObject.uniqueId;\n const scene = result.getScene();\n // check if assets context is available\n if (serializationObject._assetsContext) {\n const ac = serializationObject._assetsContext;\n const assetsContext: IAssetContainer = {\n meshes: ac.meshes?.map((m: string) => scene.getMeshById(m)),\n lights: ac.lights?.map((l: string) => scene.getLightByName(l)),\n cameras: ac.cameras?.map((c: string) => scene.getCameraByName(c)),\n materials: ac.materials?.map((m: string) => scene.getMaterialById(m)),\n textures: ac.textures?.map((t: string) => scene.getTextureByName(t)),\n animations: ac.animations?.map((a: string) => scene.animations.find((anim) => anim.name === a)),\n skeletons: ac.skeletons?.map((s: string) => scene.getSkeletonByName(s)),\n particleSystems: ac.particleSystems?.map((ps: string) => scene.getParticleSystemById(ps)),\n animationGroups: ac.animationGroups?.map((ag: string) => scene.getAnimationGroupByName(ag)),\n transformNodes: ac.transformNodes?.map((tn: string) => scene.getTransformNodeById(tn)),\n rootNodes: [],\n multiMaterials: [],\n morphTargetManagers: [],\n geometries: [],\n actionManagers: [],\n environmentTexture: null,\n postProcesses: [],\n sounds: null,\n effectLayers: [],\n layers: [],\n reflectionProbes: [],\n lensFlareSystems: [],\n proceduralTextures: [],\n getNodes: function (): Array<Node> {\n throw new Error(\"Function not implemented.\");\n },\n };\n result.assetsContext = assetsContext;\n }\n for (const key in serializationObject._userVariables) {\n const value = valueParseFunction(key, serializationObject._userVariables, result.assetsContext, scene);\n result.userVariables[key] = value;\n }\n for (const key in serializationObject._connectionValues) {\n const value = valueParseFunction(key, serializationObject._connectionValues, result.assetsContext, scene);\n result._setConnectionValueByKey(key, value);\n }\n\n return result;\n}\n\n/**\n * Parses a block from a serialization object\n * This function is async due to the factory method that is used to create the block's class. If you load the class externally use ParseBlockWithClassType\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @returns the parsed block\n */\nexport async function ParseBlockAsync(serializationObject: ISerializedFlowGraphBlock, parseOptions: IFlowGraphBlockParseOptions): Promise<FlowGraphBlock> {\n const classFactory = blockFactory(serializationObject.className as FlowGraphBlockNames);\n const classType = await classFactory();\n return ParseFlowGraphBlockWithClassType(serializationObject, parseOptions, classType);\n}\n\n/**\n * Parses a block from a serialization object\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @param classType the class type of the block. This is used when the class is not loaded asynchronously\n * @returns the parsed block\n */\nexport function ParseFlowGraphBlockWithClassType(\n serializationObject: ISerializedFlowGraphBlock,\n parseOptions: IFlowGraphBlockParseOptions,\n classType: typeof FlowGraphBlock\n): FlowGraphBlock {\n const parsedConfig: any = {};\n const valueParseFunction = parseOptions.valueParseFunction ?? defaultValueParseFunction;\n if (serializationObject.config) {\n for (const key in serializationObject.config) {\n parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.assetsContainer || parseOptions.scene, parseOptions.scene);\n }\n }\n if (needsPathConverter(serializationObject.className)) {\n if (!parseOptions.pathConverter) {\n throw new Error(\"Path converter is required for this block\");\n }\n parsedConfig.pathConverter = parseOptions.pathConverter;\n }\n const obj = new classType(parsedConfig);\n obj.uniqueId = serializationObject.uniqueId;\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\n const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);\n if (dataInput) {\n dataInput.deserialize(serializationObject.dataInputs[i]);\n } else {\n throw new Error(\"Could not find data input with name \" + serializationObject.dataInputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\n const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);\n if (dataOutput) {\n dataOutput.deserialize(serializationObject.dataOutputs[i]);\n } else {\n throw new Error(\"Could not find data output with name \" + serializationObject.dataOutputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n obj.metadata = serializationObject.metadata;\n obj.deserialize && obj.deserialize(serializationObject);\n return obj;\n}\n\n/**\n * Parses a connection from an object\n * @param serializationObject the object to parse from.\n * @param ownerBlock the block that owns the connection.\n * @param classType the class type of the connection.\n * @returns the parsed connection.\n */\nexport function ParseGraphConnectionWithClassType<BlockT extends FlowGraphBlock>(serializationObject: any = {}, ownerBlock: BlockT, classType: typeof FlowGraphConnection) {\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a data connection from a serialized object.\n * @param serializationObject the object to parse from\n * @param ownerBlock the block that owns the connection\n * @param classType the class type of the data connection\n * @returns the parsed connection\n */\nexport function ParseGraphDataConnection(serializationObject: any, ownerBlock: FlowGraphBlock, classType: typeof FlowGraphDataConnection): FlowGraphDataConnection<any> {\n const richType = ParseRichType(serializationObject.richType);\n const defaultValue = serializationObject.defaultValue;\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock, richType, defaultValue, !!serializationObject._optional);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a rich type from a serialization object.\n * @param serializationObject a serialization object\n * @returns the parsed rich type\n */\nfunction ParseRichType(serializationObject: any): RichType<any> {\n return new RichType(serializationObject.typeName, serializationObject.defaultValue);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphParser.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAM9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGhF,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG5E;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAwB,E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S,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACrK,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,mBAAwB;IAC3C,OAAO,IAAI,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import type { IAssetContainer } from \"core/IAssetContainer\";\nimport { blockFactory } from \"./Blocks/flowGraphBlockFactory\";\nimport type { FlowGraphBlockNames } from \"./Blocks/flowGraphBlockNames\";\nimport type { FlowGraph, IFlowGraphParseOptions } from \"./flowGraph\";\nimport type { FlowGraphBlock, IFlowGraphBlockParseOptions } from \"./flowGraphBlock\";\nimport type { FlowGraphContext, IFlowGraphContextParseOptions } from \"./flowGraphContext\";\nimport type { FlowGraphCoordinatorParseOptions } from \"./flowGraphCoordinator\";\nimport { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\nimport { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\nimport { defaultValueParseFunction, needsPathConverter } from \"./serialization\";\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphContext } from \"./typeDefinitions\";\nimport type { Node } from \"core/node\";\nimport { getRichTypeByFlowGraphType, RichType } from \"./flowGraphRichTypes\";\nimport type { FlowGraphConnection } from \"./flowGraphConnection\";\n\n/**\n * Given a list of blocks, find an output data connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetDataOutConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphDataConnection<any> {\n for (const block of blocks) {\n for (const dataOut of block.dataOutputs) {\n if (dataOut.uniqueId === uniqueId) {\n return dataOut;\n }\n }\n }\n throw new Error(\"Could not find data out connection with unique id \" + uniqueId);\n}\n\n/**\n * Given a list of blocks, find an input signal connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetSignalInConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphSignalConnection {\n for (const block of blocks) {\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalIn of block.signalInputs) {\n if (signalIn.uniqueId === uniqueId) {\n return signalIn;\n }\n }\n }\n }\n throw new Error(\"Could not find signal in connection with unique id \" + uniqueId);\n}\n\n/**\n * Parses a serialized coordinator.\n * @param serializedObject the object to parse\n * @param options the options to use when parsing\n * @returns the parsed coordinator\n */\nexport async function ParseCoordinatorAsync(serializedObject: any, options: FlowGraphCoordinatorParseOptions) {\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n const coordinator = new FlowGraphCoordinator({ scene: options.scene });\n\n if (serializedObject.dispatchEventsSynchronously) {\n coordinator.dispatchEventsSynchronously = serializedObject.dispatchEventsSynchronously;\n }\n\n await options.scene.whenReadyAsync();\n // if custom default values are defined, set them in the global context\n if (serializedObject._defaultValues) {\n for (const key in serializedObject._defaultValues) {\n // key is the FlowGraphType, value is the default value\n const value = serializedObject._defaultValues[key];\n getRichTypeByFlowGraphType(key).defaultValue = value;\n }\n }\n // async-parse the flow graphs. This can be done in parallel\n await Promise.all(\n serializedObject._flowGraphs?.map((serializedGraph: any) => ParseFlowGraphAsync(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter }))\n );\n return coordinator;\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @returns the parsed graph\n */\nexport async function ParseFlowGraphAsync(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions): Promise<FlowGraph> {\n // get all classes types needed for the blocks using the block factory\n const resolvedClasses = await Promise.all(\n serializationObject.allBlocks.map(async (serializedBlock) => {\n const classFactory = blockFactory(serializedBlock.className as FlowGraphBlockNames);\n return classFactory();\n })\n );\n // async will be used when we start using the block async factory\n return ParseFlowGraph(serializationObject, options, resolvedClasses);\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @param resolvedClasses the resolved classes for the blocks\n * @returns the parsed graph\n */\nexport function ParseFlowGraph(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions, resolvedClasses: (typeof FlowGraphBlock)[]) {\n const graph = options.coordinator.createGraph();\n const blocks: FlowGraphBlock[] = [];\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n // Parse all blocks\n // for (const serializedBlock of serializationObject.allBlocks) {\n for (let i = 0; i < serializationObject.allBlocks.length; i++) {\n const serializedBlock = serializationObject.allBlocks[i];\n const block = ParseFlowGraphBlockWithClassType(\n serializedBlock,\n { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, assetsContainer: options.coordinator.config.scene, valueParseFunction },\n resolvedClasses[i]\n );\n blocks.push(block);\n if (block instanceof FlowGraphEventBlock) {\n graph.addEventBlock(block);\n }\n }\n // After parsing all blocks, connect them\n for (const block of blocks) {\n for (const dataIn of block.dataInputs) {\n for (const serializedConnection of dataIn.connectedPointIds) {\n const connection = GetDataOutConnectionByUniqueId(blocks, serializedConnection);\n dataIn.connectTo(connection);\n }\n }\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalOut of block.signalOutputs) {\n for (const serializedConnection of signalOut.connectedPointIds) {\n const connection = GetSignalInConnectionByUniqueId(blocks, serializedConnection);\n signalOut.connectTo(connection);\n }\n }\n }\n }\n for (const serializedContext of serializationObject.executionContexts) {\n ParseFlowGraphContext(serializedContext, { graph, valueParseFunction }, serializationObject.rightHanded);\n }\n return graph;\n}\n\n/**\n * Parses a context\n * @param serializationObject the object containing the context serialization values\n * @param options the options for parsing the context\n * @param rightHanded whether the serialized data is right handed\n * @returns\n */\nexport function ParseFlowGraphContext(serializationObject: ISerializedFlowGraphContext, options: IFlowGraphContextParseOptions, rightHanded?: boolean): FlowGraphContext {\n const result = options.graph.createContext();\n if (serializationObject.enableLogging) {\n result.enableLogging = true;\n }\n result.treatDataAsRightHanded = rightHanded || false;\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n result.uniqueId = serializationObject.uniqueId;\n const scene = result.getScene();\n // check if assets context is available\n if (serializationObject._assetsContext) {\n const ac = serializationObject._assetsContext;\n const assetsContext: IAssetContainer = {\n meshes: ac.meshes?.map((m: string) => scene.getMeshById(m)),\n lights: ac.lights?.map((l: string) => scene.getLightByName(l)),\n cameras: ac.cameras?.map((c: string) => scene.getCameraByName(c)),\n materials: ac.materials?.map((m: string) => scene.getMaterialById(m)),\n textures: ac.textures?.map((t: string) => scene.getTextureByName(t)),\n animations: ac.animations?.map((a: string) => scene.animations.find((anim) => anim.name === a)),\n skeletons: ac.skeletons?.map((s: string) => scene.getSkeletonByName(s)),\n particleSystems: ac.particleSystems?.map((ps: string) => scene.getParticleSystemById(ps)),\n animationGroups: ac.animationGroups?.map((ag: string) => scene.getAnimationGroupByName(ag)),\n transformNodes: ac.transformNodes?.map((tn: string) => scene.getTransformNodeById(tn)),\n rootNodes: [],\n multiMaterials: [],\n morphTargetManagers: [],\n geometries: [],\n actionManagers: [],\n environmentTexture: null,\n postProcesses: [],\n sounds: null,\n effectLayers: [],\n layers: [],\n reflectionProbes: [],\n lensFlareSystems: [],\n proceduralTextures: [],\n getNodes: function (): Array<Node> {\n throw new Error(\"Function not implemented.\");\n },\n };\n result.assetsContext = assetsContext;\n }\n for (const key in serializationObject._userVariables) {\n const value = valueParseFunction(key, serializationObject._userVariables, result.assetsContext, scene);\n result.userVariables[key] = value;\n }\n for (const key in serializationObject._connectionValues) {\n const value = valueParseFunction(key, serializationObject._connectionValues, result.assetsContext, scene);\n result._setConnectionValueByKey(key, value);\n }\n\n return result;\n}\n\n/**\n * Parses a block from a serialization object\n * This function is async due to the factory method that is used to create the block's class. If you load the class externally use ParseBlockWithClassType\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @returns the parsed block\n */\nexport async function ParseBlockAsync(serializationObject: ISerializedFlowGraphBlock, parseOptions: IFlowGraphBlockParseOptions): Promise<FlowGraphBlock> {\n const classFactory = blockFactory(serializationObject.className as FlowGraphBlockNames);\n const classType = await classFactory();\n return ParseFlowGraphBlockWithClassType(serializationObject, parseOptions, classType);\n}\n\n/**\n * Parses a block from a serialization object\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @param classType the class type of the block. This is used when the class is not loaded asynchronously\n * @returns the parsed block\n */\nexport function ParseFlowGraphBlockWithClassType(\n serializationObject: ISerializedFlowGraphBlock,\n parseOptions: IFlowGraphBlockParseOptions,\n classType: typeof FlowGraphBlock\n): FlowGraphBlock {\n const parsedConfig: any = {};\n const valueParseFunction = parseOptions.valueParseFunction ?? defaultValueParseFunction;\n if (serializationObject.config) {\n for (const key in serializationObject.config) {\n parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.assetsContainer || parseOptions.scene, parseOptions.scene);\n }\n }\n if (needsPathConverter(serializationObject.className)) {\n if (!parseOptions.pathConverter) {\n throw new Error(\"Path converter is required for this block\");\n }\n parsedConfig.pathConverter = parseOptions.pathConverter;\n }\n const obj = new classType(parsedConfig);\n obj.uniqueId = serializationObject.uniqueId;\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\n const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);\n if (dataInput) {\n dataInput.deserialize(serializationObject.dataInputs[i]);\n } else {\n throw new Error(\"Could not find data input with name \" + serializationObject.dataInputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\n const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);\n if (dataOutput) {\n dataOutput.deserialize(serializationObject.dataOutputs[i]);\n } else {\n throw new Error(\"Could not find data output with name \" + serializationObject.dataOutputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n obj.metadata = serializationObject.metadata;\n obj.deserialize && obj.deserialize(serializationObject);\n return obj;\n}\n\n/**\n * Parses a connection from an object\n * @param serializationObject the object to parse from.\n * @param ownerBlock the block that owns the connection.\n * @param classType the class type of the connection.\n * @returns the parsed connection.\n */\nexport function ParseGraphConnectionWithClassType<BlockT extends FlowGraphBlock>(serializationObject: any = {}, ownerBlock: BlockT, classType: typeof FlowGraphConnection) {\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a data connection from a serialized object.\n * @param serializationObject the object to parse from\n * @param ownerBlock the block that owns the connection\n * @param classType the class type of the data connection\n * @returns the parsed connection\n */\nexport function ParseGraphDataConnection(serializationObject: any, ownerBlock: FlowGraphBlock, classType: typeof FlowGraphDataConnection): FlowGraphDataConnection<any> {\n const richType = ParseRichType(serializationObject.richType);\n const defaultValue = serializationObject.defaultValue;\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock, richType, defaultValue, !!serializationObject._optional);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a rich type from a serialization object.\n * @param serializationObject a serialization object\n * @returns the parsed rich type\n */\nfunction ParseRichType(serializationObject: any): RichType<any> {\n return new RichType(serializationObject.typeName, serializationObject.defaultValue);\n}\n"]}
|
|
@@ -188,6 +188,10 @@ const loadAssetContainer = (scene, data, rootUrl, onError, addToScene = false) =
|
|
|
188
188
|
if (parsedData.environmentIntensity !== undefined && parsedData.environmentIntensity !== null) {
|
|
189
189
|
scene.environmentIntensity = parsedData.environmentIntensity;
|
|
190
190
|
}
|
|
191
|
+
// IBL Intensity
|
|
192
|
+
if (parsedData.iblIntensity !== undefined && parsedData.iblIntensity !== null) {
|
|
193
|
+
scene.iblIntensity = parsedData.iblIntensity;
|
|
194
|
+
}
|
|
191
195
|
// Lights
|
|
192
196
|
if (parsedData.lights !== undefined && parsedData.lights !== null) {
|
|
193
197
|
for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
|