9b0c86926f704065ca56e97e93034a44523892761de34574162e2b67cb76b502.json 5.9 KB

1
  1. {"ast":null,"code":"/**\n * A converter that takes a glTF Object Model JSON Pointer\n * and transforms it into an ObjectAccessorContainer, allowing\n * objects referenced in the glTF to be associated with their\n * respective Babylon.js objects.\n */\nexport class GLTFPathToObjectConverter {\n constructor(_gltf, _infoTree) {\n this._gltf = _gltf;\n this._infoTree = _infoTree;\n }\n /**\n * The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901).\n * <animationPointer> := /<rootNode>/<assetIndex>/<propertyPath>\n * <rootNode> := \"nodes\" | \"materials\" | \"meshes\" | \"cameras\" | \"extensions\"\n * <assetIndex> := <digit> | <name>\n * <propertyPath> := <extensionPath> | <standardPath>\n * <extensionPath> := \"extensions\"/<name>/<standardPath>\n * <standardPath> := <name> | <name>/<standardPath>\n * <name> := W+\n * <digit> := D+\n *\n * Examples:\n * - \"/nodes/0/rotation\"\n * - \"/materials/2/emissiveFactor\"\n * - \"/materials/2/pbrMetallicRoughness/baseColorFactor\"\n * - \"/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength\"\n *\n * @param path The path to convert\n * @returns The object and info associated with the path\n */\n convert(path) {\n let objectTree = this._gltf;\n let infoTree = this._infoTree;\n let target = undefined;\n if (!path.startsWith(\"/\")) {\n throw new Error(\"Path must start with a /\");\n }\n const parts = path.split(\"/\");\n parts.shift();\n for (const part of parts) {\n if (infoTree.__array__) {\n infoTree = infoTree.__array__;\n } else {\n infoTree = infoTree[part];\n if (!infoTree) {\n throw new Error(`Path ${path} is invalid`);\n }\n }\n if (objectTree === undefined) {\n throw new Error(`Path ${path} is invalid`);\n }\n objectTree = objectTree[part];\n if (infoTree.__target__) {\n target = objectTree;\n }\n }\n return {\n object: target,\n info: infoTree\n };\n }\n}","map":{"version":3,"names":["GLTFPathToObjectConverter","constructor","_gltf","_infoTree","convert","path","objectTree","infoTree","target","undefined","startsWith","Error","parts","split","shift","part","__array__","__target__","object","info"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/gltfPathToObjectConverter.js"],"sourcesContent":["/**\n * A converter that takes a glTF Object Model JSON Pointer\n * and transforms it into an ObjectAccessorContainer, allowing\n * objects referenced in the glTF to be associated with their\n * respective Babylon.js objects.\n */\nexport class GLTFPathToObjectConverter {\n constructor(_gltf, _infoTree) {\n this._gltf = _gltf;\n this._infoTree = _infoTree;\n }\n /**\n * The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901).\n * <animationPointer> := /<rootNode>/<assetIndex>/<propertyPath>\n * <rootNode> := \"nodes\" | \"materials\" | \"meshes\" | \"cameras\" | \"extensions\"\n * <assetIndex> := <digit> | <name>\n * <propertyPath> := <extensionPath> | <standardPath>\n * <extensionPath> := \"extensions\"/<name>/<standardPath>\n * <standardPath> := <name> | <name>/<standardPath>\n * <name> := W+\n * <digit> := D+\n *\n * Examples:\n * - \"/nodes/0/rotation\"\n * - \"/materials/2/emissiveFactor\"\n * - \"/materials/2/pbrMetallicRoughness/baseColorFactor\"\n * - \"/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength\"\n *\n * @param path The path to convert\n * @returns The object and info associated with the path\n */\n convert(path) {\n let objectTree = this._gltf;\n let infoTree = this._infoTree;\n let target = undefined;\n if (!path.startsWith(\"/\")) {\n throw new Error(\"Path must start with a /\");\n }\n const parts = path.split(\"/\");\n parts.shift();\n for (const part of parts) {\n if (infoTree.__array__) {\n infoTree = infoTree.__array__;\n }\n else {\n infoTree = infoTree[part];\n if (!infoTree) {\n throw new Error(`Path ${path} is invalid`);\n }\n }\n if (objectTree === undefined) {\n throw new Error(`Path ${path} is invalid`);\n }\n objectTree = objectTree[part];\n if (infoTree.__target__) {\n target = objectTree;\n }\n }\n return {\n object: target,\n info: infoTree,\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,yBAAyB,CAAC;EACnCC,W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