@babylonjs/loaders 7.34.3 → 7.35.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/OBJ/mtlFileLoader.js.map +1 -1
  2. package/OBJ/objFileLoader.js.map +1 -1
  3. package/OBJ/solidParser.js +2 -2
  4. package/OBJ/solidParser.js.map +1 -1
  5. package/SPLAT/splatFileLoader.js.map +1 -1
  6. package/STL/stlFileLoader.js.map +1 -1
  7. package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
  8. package/glTF/1.0/glTFLoader.js.map +1 -1
  9. package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
  10. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
  11. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  12. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  13. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  14. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
  15. package/glTF/2.0/Extensions/KHR_animation_pointer.data.js.map +1 -1
  16. package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
  17. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  18. package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -1
  19. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  20. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
  21. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  22. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
  23. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
  24. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  25. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  26. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  27. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  28. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  29. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  30. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  31. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  32. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  33. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  34. package/glTF/2.0/Extensions/KHR_node_visibility.js.map +1 -1
  35. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  36. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
  37. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  38. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  39. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
  40. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  41. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -1
  42. package/glTF/2.0/Extensions/interactivityFunctions.js +2 -2
  43. package/glTF/2.0/Extensions/interactivityFunctions.js.map +1 -1
  44. package/glTF/2.0/glTFLoader.js.map +1 -1
  45. package/glTF/2.0/glTFLoaderAnimation.js.map +1 -1
  46. package/glTF/2.0/glTFLoaderExtensionRegistry.js.map +1 -1
  47. package/glTF/glTFFileLoader.js.map +1 -1
  48. package/glTF/glTFValidation.js.map +1 -1
  49. package/legacy/legacy-glTF.js.map +1 -1
  50. package/legacy/legacy-glTF1.js.map +1 -1
  51. package/legacy/legacy-glTF2.js.map +1 -1
  52. package/legacy/legacy-objFileLoader.js.map +1 -1
  53. package/legacy/legacy-stlFileLoader.js.map +1 -1
  54. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"gltfPathToObjectConverter.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts"],"names":[],"mappings":"AAGA;;;;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";\r\nimport type { IGLTF } from \"../glTFLoaderInterfaces\";\r\n\r\n/**\r\n * A converter that takes a glTF Object Model JSON Pointer\r\n * and transforms it into an ObjectAccessorContainer, allowing\r\n * objects referenced in the glTF to be associated with their\r\n * respective Babylon.js objects.\r\n */\r\nexport class GLTFPathToObjectConverter<T> implements IPathToObjectConverter<T> {\r\n public constructor(\r\n private _gltf: IGLTF,\r\n private _infoTree: any\r\n ) {}\r\n\r\n /**\r\n * The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901).\r\n * <animationPointer> := /<rootNode>/<assetIndex>/<propertyPath>\r\n * <rootNode> := \"nodes\" | \"materials\" | \"meshes\" | \"cameras\" | \"extensions\"\r\n * <assetIndex> := <digit> | <name>\r\n * <propertyPath> := <extensionPath> | <standardPath>\r\n * <extensionPath> := \"extensions\"/<name>/<standardPath>\r\n * <standardPath> := <name> | <name>/<standardPath>\r\n * <name> := W+\r\n * <digit> := D+\r\n *\r\n * Examples:\r\n * - \"/nodes/0/rotation\"\r\n * - \"/materials/2/emissiveFactor\"\r\n * - \"/materials/2/pbrMetallicRoughness/baseColorFactor\"\r\n * - \"/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength\"\r\n *\r\n * @param path The path to convert\r\n * @returns The object and info associated with the path\r\n */\r\n public convert(path: string): IObjectInfo<T> {\r\n let objectTree: any = this._gltf;\r\n let infoTree: any = this._infoTree;\r\n let target: any = undefined;\r\n\r\n if (!path.startsWith(\"/\")) {\r\n throw new Error(\"Path must start with a /\");\r\n }\r\n const parts = path.split(\"/\");\r\n parts.shift();\r\n\r\n for (const part of parts) {\r\n if (infoTree.__array__) {\r\n infoTree = infoTree.__array__;\r\n } else {\r\n infoTree = infoTree[part];\r\n if (!infoTree) {\r\n throw new Error(`Path ${path} is invalid`);\r\n }\r\n }\r\n if (objectTree === undefined) {\r\n throw new Error(`Path ${path} is invalid`);\r\n }\r\n objectTree = objectTree[part];\r\n\r\n if (infoTree.__target__) {\r\n target = objectTree;\r\n }\r\n }\r\n\r\n return {\r\n object: target,\r\n info: infoTree,\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"gltfPathToObjectConverter.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,OAAO,yBAAyB;IAClC,YACY,KAAY,EACZ,SAAc;QADd,UAAK,GAAL,KAAK,CAAO;QACZ,cAAS,GAAT,SAAS,CAAK;IACvB,CAAC;IAEJ;;;;;;;;;;;;;;;;;;;OAmBG;IACI,OAAO,CAAC,IAAY;QACvB,IAAI,UAAU,GAAQ,IAAI,CAAC,KAAK,CAAC;QACjC,IAAI,QAAQ,GAAQ,IAAI,CAAC,SAAS,CAAC;QACnC,IAAI,MAAM,GAAQ,SAAS,CAAC;QAE5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,KAAK,CAAC,KAAK,EAAE,CAAC;QAEd,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;gBACrB,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACJ,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAC1B,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACZ,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,aAAa,CAAC,CAAC;gBAC/C,CAAC;YACL,CAAC;YACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,aAAa,CAAC,CAAC;YAC/C,CAAC;YACD,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;YAE9B,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACtB,MAAM,GAAG,UAAU,CAAC;YACxB,CAAC;QACL,CAAC;QAED,OAAO;YACH,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,QAAQ;SACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { IObjectInfo, IPathToObjectConverter } from \"core/ObjectModel/objectModelInterfaces\";\r\nimport type { IGLTF } from \"../glTFLoaderInterfaces\";\r\n\r\n/**\r\n * A converter that takes a glTF Object Model JSON Pointer\r\n * and transforms it into an ObjectAccessorContainer, allowing\r\n * objects referenced in the glTF to be associated with their\r\n * respective Babylon.js objects.\r\n */\r\nexport class GLTFPathToObjectConverter<T> implements IPathToObjectConverter<T> {\r\n public constructor(\r\n private _gltf: IGLTF,\r\n private _infoTree: any\r\n ) {}\r\n\r\n /**\r\n * The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901).\r\n * <animationPointer> := /<rootNode>/<assetIndex>/<propertyPath>\r\n * <rootNode> := \"nodes\" | \"materials\" | \"meshes\" | \"cameras\" | \"extensions\"\r\n * <assetIndex> := <digit> | <name>\r\n * <propertyPath> := <extensionPath> | <standardPath>\r\n * <extensionPath> := \"extensions\"/<name>/<standardPath>\r\n * <standardPath> := <name> | <name>/<standardPath>\r\n * <name> := W+\r\n * <digit> := D+\r\n *\r\n * Examples:\r\n * - \"/nodes/0/rotation\"\r\n * - \"/materials/2/emissiveFactor\"\r\n * - \"/materials/2/pbrMetallicRoughness/baseColorFactor\"\r\n * - \"/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength\"\r\n *\r\n * @param path The path to convert\r\n * @returns The object and info associated with the path\r\n */\r\n public convert(path: string): IObjectInfo<T> {\r\n let objectTree: any = this._gltf;\r\n let infoTree: any = this._infoTree;\r\n let target: any = undefined;\r\n\r\n if (!path.startsWith(\"/\")) {\r\n throw new Error(\"Path must start with a /\");\r\n }\r\n const parts = path.split(\"/\");\r\n parts.shift();\r\n\r\n for (const part of parts) {\r\n if (infoTree.__array__) {\r\n infoTree = infoTree.__array__;\r\n } else {\r\n infoTree = infoTree[part];\r\n if (!infoTree) {\r\n throw new Error(`Path ${path} is invalid`);\r\n }\r\n }\r\n if (objectTree === undefined) {\r\n throw new Error(`Path ${path} is invalid`);\r\n }\r\n objectTree = objectTree[part];\r\n\r\n if (infoTree.__target__) {\r\n target = objectTree;\r\n }\r\n }\r\n\r\n return {\r\n object: target,\r\n info: infoTree,\r\n };\r\n }\r\n}\r\n"]}
@@ -108,7 +108,7 @@ export function convertGLTFToSerializedFlowGraph(gltf) {
108
108
  const socketOut = {
109
109
  uniqueId: RandomGUID(),
110
110
  name: socketOutName,
111
- _connectionType: 1 /* FlowGraphConnectionType.Output */,
111
+ _connectionType: 1 /* FlowGraphConnectionType.Output */, // Output
112
112
  connectedPointIds: [],
113
113
  };
114
114
  fgBlock.signalOutputs.push(socketOut);
@@ -127,7 +127,7 @@ export function convertGLTFToSerializedFlowGraph(gltf) {
127
127
  socketIn = {
128
128
  uniqueId: RandomGUID(),
129
129
  name: nodeInSocketName,
130
- _connectionType: 0 /* FlowGraphConnectionType.Input */,
130
+ _connectionType: 0 /* FlowGraphConnectionType.Input */, // Input
131
131
  connectedPointIds: [],
132
132
  };
133
133
  nodeIn.signalInputs.push(socketIn);
@@ -1 +1 @@
1
- {"version":3,"file":"interactivityFunctions.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,qCAAuB;AAC5C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGrF,SAAS,oBAAoB,CAAC,YAA6C,EAAE,UAA6B,EAAE,OAAe;IACvH,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,EAAE;QACjC,sCAAsC;QACtC,MAAM,IAAI,G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AC/C,iBAAiB,EAAE,EAAE;qBACxB,CAAC;oBACF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBACvC;gBACD,sBAAsB;gBACtB,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;gBACpD,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;aACvD;iBAAM;gBACH,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,oBAAoB,YAAY,YAAY,CAAC,EAAE,CAAC,CAAC;aAC5G;SACJ;KACJ;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACvC,kBAAkB;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,MAAM,QAAQ,GAA+B,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,oBAAoB,CAAC,QAA2C,EAAE,IAAI,EAAE,2CAA2C,CAAC,EAAE,CAAC,CAAC;KAClK;IAED,OAAO;QACH,SAAS,EAAE,mBAAmB;QAC9B,iBAAiB;KACpB,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IKHRInteractivity, IKHRInteractivity_Configuration, IKHRInteractivity_Node, IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\r\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\r\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphConnection, ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\r\nimport { RandomGUID } from \"core/Misc/guid\";\r\nimport { gltfToFlowGraphTypeMap, gltfTypeToBabylonType } from \"./interactivityUtils\";\r\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\r\n\r\nfunction convertValueWithType(configObject: IKHRInteractivity_Configuration, definition: IKHRInteractivity, context: string) {\r\n if (configObject.type !== undefined) {\r\n // get the type on the gltf definition\r\n const type = definition.types && definition.types[configObject.type];\r\n if (!type) {\r\n throw new Error(`${context}: Unknown type: ${configObject.type}`);\r\n }\r\n const signature = type.signature;\r\n if (!signature) {\r\n throw new Error(`${context}: Type ${configObject.type} has no signature`);\r\n }\r\n const convertedType = gltfTypeToBabylonType[signature];\r\n return {\r\n value: configObject.value,\r\n className: convertedType,\r\n };\r\n } else {\r\n return configObject.value;\r\n }\r\n}\r\n\r\nfunction convertConfiguration(gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity, id: string): IFlowGraphBlockConfiguration {\r\n const converted: IFlowGraphBlockConfiguration = {};\r\n const configurationList: IKHRInteractivity_Configuration[] = gltfBlock.configuration ?? [];\r\n for (const configObject of configurationList) {\r\n if (configObject.id === \"customEvent\") {\r\n const customEvent = definition.customEvents && definition.customEvents[configObject.value];\r\n if (!customEvent) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown custom event: ${configObject.value}`);\r\n }\r\n converted.eventId = customEvent.id;\r\n converted.eventData = customEvent.values.map((v) => v.id);\r\n } else if (configObject.id === \"variable\") {\r\n const variable = definition.variables && definition.variables[configObject.value];\r\n if (!variable) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown variable: ${configObject.value}`);\r\n }\r\n converted.variableName = variable.id;\r\n } else if (configObject.id === \"path\") {\r\n // Convert from a GLTF path to a reference to the Babylon.js object\r\n const pathValue = configObject.value as string;\r\n converted.path = pathValue;\r\n } else {\r\n converted[configObject.id] = convertValueWithType(configObject, definition, `/extensions/KHR_interactivity/nodes/${id}`);\r\n }\r\n }\r\n return converted;\r\n}\r\n\r\nfunction convertBlock(id: number, gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity): ISerializedFlowGraphBlock {\r\n const className = gltfToFlowGraphTypeMap[gltfBlock.type];\r\n if (!className) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown block type: ${gltfBlock.type}`);\r\n }\r\n const uniqueId = id.toString();\r\n const config = convertConfiguration(gltfBlock, definition, uniqueId);\r\n const metadata = gltfBlock.metadata;\r\n const dataInputs: ISerializedFlowGraphConnection[] = [];\r\n const dataOutputs: ISerializedFlowGraphConnection[] = [];\r\n const signalInputs: ISerializedFlowGraphConnection[] = [];\r\n const signalOutputs: ISerializedFlowGraphConnection[] = [];\r\n return {\r\n className,\r\n config,\r\n uniqueId,\r\n metadata,\r\n dataInputs,\r\n dataOutputs,\r\n signalInputs,\r\n signalOutputs,\r\n };\r\n}\r\n\r\n/**\r\n * @internal\r\n * Converts a glTF Interactivity Extension to a serialized flow graph.\r\n * @param gltf the interactivity data\r\n * @returns a serialized flow graph\r\n */\r\nexport function convertGLTFToSerializedFlowGraph(gltf: IKHRInteractivity): ISerializedFlowGraph {\r\n // create an empty serialized context to store the values of the connections\r\n const context: ISerializedFlowGraphContext = {\r\n uniqueId: RandomGUID(),\r\n _userVariables: {},\r\n _connectionValues: {},\r\n };\r\n const executionContexts = [context];\r\n\r\n // Blocks converted to the flow graph json format\r\n const flowGraphJsonBlocks: ISerializedFlowGraphBlock[] = [];\r\n\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n const flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf);\r\n flowGraphJsonBlocks.push(flowGraphJsonBlock);\r\n }\r\n\r\n // Parse the connections\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n // get the block that was created in the previous step\r\n const fgBlock = flowGraphJsonBlocks[i];\r\n const gltfFlows = gltfBlock.flows ?? [];\r\n // for each output flow of the gltf block\r\n for (const flow of gltfFlows) {\r\n const socketOutName = flow.id;\r\n // create an output connection for the flow graph block\r\n const socketOut: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketOutName,\r\n _connectionType: FlowGraphConnectionType.Output, // Output\r\n connectedPointIds: [],\r\n };\r\n fgBlock.signalOutputs.push(socketOut);\r\n // get the input node of this flow\r\n const nodeInId = flow.node;\r\n const nodeInSocketName = flow.socket;\r\n // find the corresponding flow graph node\r\n const nodeIn = flowGraphJsonBlocks[nodeInId];\r\n if (!nodeIn) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeInId} that connects its input with with node ${i}'s output ${socketOutName}`\r\n );\r\n }\r\n // in all of the flow graph input connections, find the one with the same name as the socket\r\n let socketIn = nodeIn.signalInputs.find((s) => s.name === nodeInSocketName);\r\n // if the socket doesn't exist, create the input socket for the connection\r\n if (!socketIn) {\r\n socketIn = {\r\n uniqueId: RandomGUID(),\r\n name: nodeInSocketName,\r\n _connectionType: FlowGraphConnectionType.Input, // Input\r\n connectedPointIds: [],\r\n };\r\n nodeIn.signalInputs.push(socketIn);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n }\r\n // for each input value of the gltf block\r\n const gltfValues = gltfBlock.values ?? [];\r\n for (const value of gltfValues) {\r\n const socketInName = value.id;\r\n // create an input data connection for the flow graph block\r\n const socketIn: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketInName,\r\n _connectionType: FlowGraphConnectionType.Input,\r\n connectedPointIds: [],\r\n };\r\n fgBlock.dataInputs.push(socketIn);\r\n if (value.value !== undefined) {\r\n // if the value is set on the socket itself, store it in the context\r\n const convertedValue = convertValueWithType(value as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/nodes/${i}`);\r\n // convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`);\r\n context._connectionValues[socketIn.uniqueId] = convertedValue;\r\n } else if (value.node !== undefined && value.socket !== undefined) {\r\n // if the value is connected with the output data of another socket, connect the two\r\n const nodeOutId = value.node;\r\n const nodeOutSocketName = value.socket;\r\n // find the flow graph node that owns that output socket\r\n const nodeOut = flowGraphJsonBlocks[nodeOutId];\r\n if (!nodeOut) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeOutId} that connects its output with node${i}'s input ${socketInName}`\r\n );\r\n }\r\n let socketOut = nodeOut.dataOutputs.find((s) => s.name === nodeOutSocketName);\r\n // if the socket doesn't exist, create it\r\n if (!socketOut) {\r\n socketOut = {\r\n uniqueId: RandomGUID(),\r\n name: nodeOutSocketName,\r\n _connectionType: FlowGraphConnectionType.Output,\r\n connectedPointIds: [],\r\n };\r\n nodeOut.dataOutputs.push(socketOut);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n } else {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Invalid socket ${socketInName} in node ${i}`);\r\n }\r\n }\r\n }\r\n\r\n const variables = gltf.variables ?? [];\r\n // Parse variables\r\n for (let i = 0; i < variables.length; i++) {\r\n const variable: IKHRInteractivity_Variable = variables[i];\r\n const variableName = variable.id;\r\n context._userVariables[variableName] = convertValueWithType(variable as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/variables/${i}`);\r\n }\r\n\r\n return {\r\n allBlocks: flowGraphJsonBlocks,\r\n executionContexts,\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"interactivityFunctions.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,qCAAuB;AAC5C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGrF,SAAS,oBAAoB,CAAC,YAA6C,EAAE,UAA6B,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AE,mBAAmB;QAC9B,iBAAiB;KACpB,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IKHRInteractivity, IKHRInteractivity_Configuration, IKHRInteractivity_Node, IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\r\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\r\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphConnection, ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\r\nimport { RandomGUID } from \"core/Misc/guid\";\r\nimport { gltfToFlowGraphTypeMap, gltfTypeToBabylonType } from \"./interactivityUtils\";\r\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\r\n\r\nfunction convertValueWithType(configObject: IKHRInteractivity_Configuration, definition: IKHRInteractivity, context: string) {\r\n if (configObject.type !== undefined) {\r\n // get the type on the gltf definition\r\n const type = definition.types && definition.types[configObject.type];\r\n if (!type) {\r\n throw new Error(`${context}: Unknown type: ${configObject.type}`);\r\n }\r\n const signature = type.signature;\r\n if (!signature) {\r\n throw new Error(`${context}: Type ${configObject.type} has no signature`);\r\n }\r\n const convertedType = gltfTypeToBabylonType[signature];\r\n return {\r\n value: configObject.value,\r\n className: convertedType,\r\n };\r\n } else {\r\n return configObject.value;\r\n }\r\n}\r\n\r\nfunction convertConfiguration(gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity, id: string): IFlowGraphBlockConfiguration {\r\n const converted: IFlowGraphBlockConfiguration = {};\r\n const configurationList: IKHRInteractivity_Configuration[] = gltfBlock.configuration ?? [];\r\n for (const configObject of configurationList) {\r\n if (configObject.id === \"customEvent\") {\r\n const customEvent = definition.customEvents && definition.customEvents[configObject.value];\r\n if (!customEvent) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown custom event: ${configObject.value}`);\r\n }\r\n converted.eventId = customEvent.id;\r\n converted.eventData = customEvent.values.map((v) => v.id);\r\n } else if (configObject.id === \"variable\") {\r\n const variable = definition.variables && definition.variables[configObject.value];\r\n if (!variable) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown variable: ${configObject.value}`);\r\n }\r\n converted.variableName = variable.id;\r\n } else if (configObject.id === \"path\") {\r\n // Convert from a GLTF path to a reference to the Babylon.js object\r\n const pathValue = configObject.value as string;\r\n converted.path = pathValue;\r\n } else {\r\n converted[configObject.id] = convertValueWithType(configObject, definition, `/extensions/KHR_interactivity/nodes/${id}`);\r\n }\r\n }\r\n return converted;\r\n}\r\n\r\nfunction convertBlock(id: number, gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity): ISerializedFlowGraphBlock {\r\n const className = gltfToFlowGraphTypeMap[gltfBlock.type];\r\n if (!className) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown block type: ${gltfBlock.type}`);\r\n }\r\n const uniqueId = id.toString();\r\n const config = convertConfiguration(gltfBlock, definition, uniqueId);\r\n const metadata = gltfBlock.metadata;\r\n const dataInputs: ISerializedFlowGraphConnection[] = [];\r\n const dataOutputs: ISerializedFlowGraphConnection[] = [];\r\n const signalInputs: ISerializedFlowGraphConnection[] = [];\r\n const signalOutputs: ISerializedFlowGraphConnection[] = [];\r\n return {\r\n className,\r\n config,\r\n uniqueId,\r\n metadata,\r\n dataInputs,\r\n dataOutputs,\r\n signalInputs,\r\n signalOutputs,\r\n };\r\n}\r\n\r\n/**\r\n * @internal\r\n * Converts a glTF Interactivity Extension to a serialized flow graph.\r\n * @param gltf the interactivity data\r\n * @returns a serialized flow graph\r\n */\r\nexport function convertGLTFToSerializedFlowGraph(gltf: IKHRInteractivity): ISerializedFlowGraph {\r\n // create an empty serialized context to store the values of the connections\r\n const context: ISerializedFlowGraphContext = {\r\n uniqueId: RandomGUID(),\r\n _userVariables: {},\r\n _connectionValues: {},\r\n };\r\n const executionContexts = [context];\r\n\r\n // Blocks converted to the flow graph json format\r\n const flowGraphJsonBlocks: ISerializedFlowGraphBlock[] = [];\r\n\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n const flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf);\r\n flowGraphJsonBlocks.push(flowGraphJsonBlock);\r\n }\r\n\r\n // Parse the connections\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n // get the block that was created in the previous step\r\n const fgBlock = flowGraphJsonBlocks[i];\r\n const gltfFlows = gltfBlock.flows ?? [];\r\n // for each output flow of the gltf block\r\n for (const flow of gltfFlows) {\r\n const socketOutName = flow.id;\r\n // create an output connection for the flow graph block\r\n const socketOut: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketOutName,\r\n _connectionType: FlowGraphConnectionType.Output, // Output\r\n connectedPointIds: [],\r\n };\r\n fgBlock.signalOutputs.push(socketOut);\r\n // get the input node of this flow\r\n const nodeInId = flow.node;\r\n const nodeInSocketName = flow.socket;\r\n // find the corresponding flow graph node\r\n const nodeIn = flowGraphJsonBlocks[nodeInId];\r\n if (!nodeIn) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeInId} that connects its input with with node ${i}'s output ${socketOutName}`\r\n );\r\n }\r\n // in all of the flow graph input connections, find the one with the same name as the socket\r\n let socketIn = nodeIn.signalInputs.find((s) => s.name === nodeInSocketName);\r\n // if the socket doesn't exist, create the input socket for the connection\r\n if (!socketIn) {\r\n socketIn = {\r\n uniqueId: RandomGUID(),\r\n name: nodeInSocketName,\r\n _connectionType: FlowGraphConnectionType.Input, // Input\r\n connectedPointIds: [],\r\n };\r\n nodeIn.signalInputs.push(socketIn);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n }\r\n // for each input value of the gltf block\r\n const gltfValues = gltfBlock.values ?? [];\r\n for (const value of gltfValues) {\r\n const socketInName = value.id;\r\n // create an input data connection for the flow graph block\r\n const socketIn: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketInName,\r\n _connectionType: FlowGraphConnectionType.Input,\r\n connectedPointIds: [],\r\n };\r\n fgBlock.dataInputs.push(socketIn);\r\n if (value.value !== undefined) {\r\n // if the value is set on the socket itself, store it in the context\r\n const convertedValue = convertValueWithType(value as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/nodes/${i}`);\r\n // convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`);\r\n context._connectionValues[socketIn.uniqueId] = convertedValue;\r\n } else if (value.node !== undefined && value.socket !== undefined) {\r\n // if the value is connected with the output data of another socket, connect the two\r\n const nodeOutId = value.node;\r\n const nodeOutSocketName = value.socket;\r\n // find the flow graph node that owns that output socket\r\n const nodeOut = flowGraphJsonBlocks[nodeOutId];\r\n if (!nodeOut) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeOutId} that connects its output with node${i}'s input ${socketInName}`\r\n );\r\n }\r\n let socketOut = nodeOut.dataOutputs.find((s) => s.name === nodeOutSocketName);\r\n // if the socket doesn't exist, create it\r\n if (!socketOut) {\r\n socketOut = {\r\n uniqueId: RandomGUID(),\r\n name: nodeOutSocketName,\r\n _connectionType: FlowGraphConnectionType.Output,\r\n connectedPointIds: [],\r\n };\r\n nodeOut.dataOutputs.push(socketOut);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n } else {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Invalid socket ${socketInName} in node ${i}`);\r\n }\r\n }\r\n }\r\n\r\n const variables = gltf.variables ?? [];\r\n // Parse variables\r\n for (let i = 0; i < variables.length; i++) {\r\n const variable: IKHRInteractivity_Variable = variables[i];\r\n const variableName = variable.id;\r\n context._userVariables[variableName] = convertValueWithType(variable as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/variables/${i}`);\r\n }\r\n\r\n return {\r\n allBlocks: flowGraphJsonBlocks,\r\n executionContexts,\r\n };\r\n}\r\n"]}