1 |
- {"ast":null,"code":"import { AbstractMesh } from \"../../../Meshes/abstractMesh.js\";\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock.js\";\nimport { PointerEventTypes } from \"../../../Events/pointerEvents.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { _isADescendantOf } from \"../../utils.js\";\n/**\n * @experimental\n * A block that activates when a mesh is picked.\n */\nexport class FlowGraphMeshPickEventBlock extends FlowGraphEventBlock {\n constructor(\n /**\n * the configuration of the block\n */\n config) {\n super(config);\n this.config = config;\n }\n _getReferencedMesh() {\n const iAccessor = this.config.pathConverter.convert(this.config.path);\n const mesh = iAccessor.info.getObject(iAccessor.object);\n if (!mesh || !(mesh instanceof AbstractMesh)) {\n throw new Error(\"Mesh pick event block requires a valid mesh\");\n }\n return mesh;\n }\n /**\n * @internal\n */\n _preparePendingTasks(context) {\n let pickObserver = context._getExecutionVariable(this, \"meshPickObserver\");\n if (!pickObserver) {\n const mesh = this._getReferencedMesh();\n context._setExecutionVariable(this, \"mesh\", mesh);\n pickObserver = mesh.getScene().onPointerObservable.add(pointerInfo => {\n var _pointerInfo$pickInfo, _pointerInfo$pickInfo2, _pointerInfo$pickInfo3;\n if (pointerInfo.type === PointerEventTypes.POINTERPICK && (_pointerInfo$pickInfo = pointerInfo.pickInfo) !== null && _pointerInfo$pickInfo !== void 0 && _pointerInfo$pickInfo.pickedMesh && (((_pointerInfo$pickInfo2 = pointerInfo.pickInfo) === null || _pointerInfo$pickInfo2 === void 0 ? void 0 : _pointerInfo$pickInfo2.pickedMesh) === mesh || _isADescendantOf((_pointerInfo$pickInfo3 = pointerInfo.pickInfo) === null || _pointerInfo$pickInfo3 === void 0 ? void 0 : _pointerInfo$pickInfo3.pickedMesh, mesh))) {\n this._execute(context);\n }\n });\n const disposeObserver = mesh.onDisposeObservable.add(() => this._onDispose);\n context._setExecutionVariable(this, \"meshPickObserver\", pickObserver);\n context._setExecutionVariable(this, \"meshDisposeObserver\", disposeObserver);\n }\n }\n _onDispose(context) {\n this._cancelPendingTasks(context);\n context._removePendingBlock(this);\n }\n /**\n * @internal\n */\n _cancelPendingTasks(context) {\n const mesh = context._getExecutionVariable(this, \"mesh\");\n const pickObserver = context._getExecutionVariable(this, \"meshPickObserver\");\n const disposeObserver = context._getExecutionVariable(this, \"meshDisposeObserver\");\n mesh.getScene().onPointerObservable.remove(pickObserver);\n mesh.onDisposeObservable.remove(disposeObserver);\n context._deleteExecutionVariable(this, \"mesh\");\n context._deleteExecutionVariable(this, \"meshPickObserver\");\n context._deleteExecutionVariable(this, \"meshDisposeObserver\");\n }\n /**\n * @returns class name of the block.\n */\n getClassName() {\n return FlowGraphMeshPickEventBlock.ClassName;\n }\n /**\n * Serializes the block to a JSON object.\n * @param serializationObject the object to serialize to.\n */\n serialize(serializationObject) {\n super.serialize(serializationObject);\n serializationObject.config.path = this.config.path;\n }\n}\n/**\n * Class name of the block.\n */\nFlowGraphMeshPickEventBlock.ClassName = \"FGMeshPickEventBlock\";\nRegisterClass(FlowGraphMeshPickEventBlock.ClassName, FlowGraphMeshPickEventBlock);","map":{"version":3,"names":["AbstractMesh","FlowGraphEventBlock","PointerEventTypes","RegisterClass","_isADescendantOf","FlowGraphMeshPickEventBlock","constructor","config","_getReferencedMesh","iAccessor","pathConverter","convert","path","mesh","info","getObject","object","Error","_preparePendingTasks","context","pickObserver","_getExecutionVariable","_setExecutionVariable","getScene","onPointerObservable","add","pointerInfo","_pointerInfo$pickInfo","_pointerInfo$pickInfo2","_pointerInfo$pickInfo3","type","POINTERPICK","pickInfo","pickedMesh","_execute","disposeObserver","onDisposeObservable","_onDispose","_cancelPendingTasks","_removePendingBlock","remove","_deleteExecutionVariable","getClassName","ClassName","serialize","serializationObject"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js"],"sourcesContent":["import { AbstractMesh } from \"../../../Meshes/abstractMesh.js\";\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock.js\";\nimport { PointerEventTypes } from \"../../../Events/pointerEvents.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { _isADescendantOf } from \"../../utils.js\";\n/**\n * @experimental\n * A block that activates when a mesh is picked.\n */\nexport class FlowGraphMeshPickEventBlock extends FlowGraphEventBlock {\n constructor(\n /**\n * the configuration of the block\n */\n config) {\n super(config);\n this.config = config;\n }\n _getReferencedMesh() {\n const iAccessor = this.config.pathConverter.convert(this.config.path);\n const mesh = iAccessor.info.getObject(iAccessor.object);\n if (!mesh || !(mesh instanceof AbstractMesh)) {\n throw new Error(\"Mesh pick event block requires a valid mesh\");\n }\n return mesh;\n }\n /**\n * @internal\n */\n _preparePendingTasks(context) {\n let pickObserver = context._getExecutionVariable(this, \"meshPickObserver\");\n if (!pickObserver) {\n const mesh = this._getReferencedMesh();\n context._setExecutionVariable(this, \"mesh\", mesh);\n pickObserver = mesh.getScene().onPointerObservable.add((pointerInfo) => {\n if (pointerInfo.type === PointerEventTypes.POINTERPICK &&\n pointerInfo.pickInfo?.pickedMesh &&\n (pointerInfo.pickInfo?.pickedMesh === mesh || _isADescendantOf(pointerInfo.pickInfo?.pickedMesh, mesh))) {\n this._execute(context);\n }\n });\n const disposeObserver = mesh.onDisposeObservable.add(() => this._onDispose);\n context._setExecutionVariable(this, \"meshPickObserver\", pickObserver);\n context._setExecutionVariable(this, \"meshDisposeObserver\", disposeObserver);\n }\n }\n _onDispose(context) {\n this._cancelPendingTasks(context);\n context._removePendingBlock(this);\n }\n /**\n * @internal\n */\n _cancelPendingTasks(context) {\n const mesh = context._getExecutionVariable(this, \"mesh\");\n const pickObserver = context._getExecutionVariable(this, \"meshPickObserver\");\n const disposeObserver = context._getExecutionVariable(this, \"meshDisposeObserver\");\n mesh.getScene().onPointerObservable.remove(pickObserver);\n mesh.onDisposeObservable.remove(disposeObserver);\n context._deleteExecutionVariable(this, \"mesh\");\n context._deleteExecutionVariable(this, \"meshPickObserver\");\n context._deleteExecutionVariable(this, \"meshDisposeObserver\");\n }\n /**\n * @returns class name of the block.\n */\n getClassName() {\n return FlowGraphMeshPickEventBlock.ClassName;\n }\n /**\n * Serializes the block to a JSON object.\n * @param serializationObject the object to serialize to.\n */\n serialize(serializationObject) {\n super.serialize(serializationObject);\n serializationObject.config.path = this.config.path;\n }\n}\n/**\n * Class name of the block.\n */\nFlowGraphMeshPickEventBlock.ClassName = \"FGMeshPickEventBlock\";\nRegisterClass(FlowGraphMeshPickEventBlock.ClassName, FlowGraphMeshPickEventBlock);\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iCAAiC;AAC9D,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,gBAAgB,QAAQ,gBAAgB;AACjD;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,SAASJ,mBAAmB,CAAC;EACjEK,WAAWA;EACX;AACJ;AACA;EACIC,MAAM,EAAE;IACJ,KAAK,CAACA,MAAM,CAAC;IACb,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EACAC,kBAAkBA,CAAA,EAAG;IACjB,MAAMC,SAAS,GAAG,IAAI,CAACF,MAAM,CAACG,aAAa,CAACC,OAAO,CAAC,IAAI,CAACJ,MAAM,CAACK,IAAI,CAAC;IACrE,MAAMC,IAAI,GAAGJ,SAAS,CAACK,IAAI,CAACC,SAAS,CAACN,SAAS,CAACO,MAAM,CAAC;IACvD,IAAI,CAACH,IAAI,IAAI,EAAEA,IAAI,YAAYb,YAAY,CAAC,EAAE;MAC1C,MAAM,IAAIiB,KAAK,CAAC,6CAA6C,CAAC;IAClE;IACA,OAAOJ,IAAI;EACf;EACA;AACJ;AACA;EACIK,oBAAoBA,CAACC,OAAO,EAAE;IAC1B,IAAIC,YAAY,GAAGD,OAAO,CAACE,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAC1E,IAAI,C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AqB,CAAC,IAAI,EAAE,MAAM,CAAC;IACxD,MAAMD,YAAY,GAAGD,OAAO,CAACE,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAC5E,MAAMc,eAAe,GAAGhB,OAAO,CAACE,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,CAAC;IAClFR,IAAI,CAACU,QAAQ,CAAC,CAAC,CAACC,mBAAmB,CAACgB,MAAM,CAACpB,YAAY,CAAC;IACxDP,IAAI,CAACuB,mBAAmB,CAACI,MAAM,CAACL,eAAe,CAAC;IAChDhB,OAAO,CAACsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC;IAC9CtB,OAAO,CAACsB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAC1DtB,OAAO,CAACsB,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,CAAC;EACjE;EACA;AACJ;AACA;EACIC,YAAYA,CAAA,EAAG;IACX,OAAOrC,2BAA2B,CAACsC,SAAS;EAChD;EACA;AACJ;AACA;AACA;EACIC,SAASA,CAACC,mBAAmB,EAAE;IAC3B,KAAK,CAACD,SAAS,CAACC,mBAAmB,CAAC;IACpCA,mBAAmB,CAACtC,MAAM,CAACK,IAAI,GAAG,IAAI,CAACL,MAAM,CAACK,IAAI;EACtD;AACJ;AACA;AACA;AACA;AACAP,2BAA2B,CAACsC,SAAS,GAAG,sBAAsB;AAC9DxC,aAAa,CAACE,2BAA2B,CAACsC,SAAS,EAAEtC,2BAA2B,CAAC","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}
|