1 |
- {"ast":null,"code":"import { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets.js\";\nimport { NodeMaterialBlock } from \"../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes.js\";\n/**\n * Block used to perform a mathematical operation on 2 values\n */\nexport class BaseMathBlock extends NodeMaterialBlock {\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"left\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"right\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.BasedOnInput);\n this.output._typeConnectionSource = this.left;\n this._linkConnectionTypes(0, 1, true);\n this.left.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);\n this.right.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);\n this._connectionObservers = [this.left.onTypeChangedObservable.add(() => this._updateInputOutputTypes()), this.right.onTypeChangedObservable.add(() => this._updateInputOutputTypes())];\n }\n /**\n * Gets the left operand input component\n */\n get left() {\n return this._inputs[0];\n }\n /**\n * Gets the right operand input component\n */\n get right() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _updateInputOutputTypes() {\n // First update the output type with the initial assumption that we'll base it on the left input.\n this.output._typeConnectionSource = this.left;\n if (this.left.isConnected && this.right.isConnected) {\n // Both inputs are connected, so we need to determine the output type based on the input types.\n if (this.left.type === NodeMaterialBlockConnectionPointTypes.Int || this.left.type === NodeMaterialBlockConnectionPointTypes.Float && this.right.type !== NodeMaterialBlockConnectionPointTypes.Int) {\n this.output._typeConnectionSource = this.right;\n }\n } else if (this.left.isConnected !== this.right.isConnected) {\n // Only one input is connected, so we need to determine the output type based on the connected input.\n this.output._typeConnectionSource = this.left.isConnected ? this.left : this.right;\n }\n // Next update the accepted connection point types for the inputs based on the current input connection state.\n if (this.left.isConnected || this.right.isConnected) {\n for (const [first, second] of [[this.left, this.right], [this.right, this.left]]) {\n // Always allow Ints and Floats.\n first.acceptedConnectionPointTypes = [NodeMaterialBlockConnectionPointTypes.Int, NodeMaterialBlockConnectionPointTypes.Float];\n if (second.isConnected) {\n // The same types as the connected input are always allowed.\n first.acceptedConnectionPointTypes.push(second.type);\n // If the other input is a scalar, then we also allow Vector/Color/Matrix types.\n if (second.type === NodeMaterialBlockConnectionPointTypes.Int || second.type === NodeMaterialBlockConnectionPointTypes.Float) {\n first.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2, NodeMaterialBlockConnectionPointTypes.Vector3, NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockConnectionPointTypes.Matrix);\n }\n }\n }\n }\n }\n /**\n * Release resources\n */\n dispose() {\n super.dispose();\n this._connectionObservers.forEach(observer => observer.remove());\n this._connectionObservers.length = 0;\n }\n}","map":{"version":3,"names":["NodeMaterialBlockTargets","NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","BaseMathBlock","constructor","name","Neutral","registerInput","AutoDetect","registerOutput","BasedOnInput","output","_typeConnectionSource","left","_linkConnectionTypes","acceptedConnectionPointTypes","push","Float","right","_connectionObservers","onTypeChangedObservable","add","_updateInputOutputTypes","_inputs","_outputs","isConnected","type","Int","first","second","Vector2","Vector3","Vector4","Color3","Color4","Matrix","dispose","forEach","observer","remove","length"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/baseMathBlock.js"],"sourcesContent":["import { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets.js\";\nimport { NodeMaterialBlock } from \"../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes.js\";\n/**\n * Block used to perform a mathematical operation on 2 values\n */\nexport class BaseMathBlock extends NodeMaterialBlock {\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"left\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"right\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.BasedOnInput);\n this.output._typeConnectionSource = this.left;\n this._linkConnectionTypes(0, 1, true);\n this.left.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);\n this.right.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);\n this._connectionObservers = [\n this.left.onTypeChangedObservable.add(() => this._updateInputOutputTypes()),\n this.right.onTypeChangedObservable.add(() => this._updateInputOutputTypes()),\n ];\n }\n /**\n * Gets the left operand input component\n */\n get left() {\n return this._inputs[0];\n }\n /**\n * Gets the right operand input component\n */\n get right() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _updateInputOutputTypes() {\n // First update the output type with the initial assumption that we'll base it on the left input.\n this.output._typeConnectionSource = this.left;\n if (this.left.isConnected && this.right.isConnected) {\n // Both inputs are connected, so we need to determine the output type based on the input types.\n if (this.left.type === NodeMaterialBlockConnectionPointTypes.Int ||\n (this.left.type === NodeMaterialBlockConnectionPointTypes.Float && this.right.type !== NodeMaterialBlockConnectionPointTypes.Int)) {\n this.output._typeConnectionSource = this.right;\n }\n }\n else if (this.left.isConnected !== this.right.isConnected) {\n // Only one input is connected, so we need to determine the output type based on the connected input.\n this.output._typeConnectionSource = this.left.isConnected ? this.left : this.right;\n }\n // Next update the accepted connection point types for the inputs based on the current input connection state.\n if (this.left.isConnected || this.right.isConnected) {\n for (const [first, second] of [\n [this.left, this.right],\n [this.right, this.left],\n ]) {\n // Always allow Ints and Floats.\n first.acceptedConnectionPointTypes = [NodeMaterialBlockConnectionPointTypes.Int, NodeMaterialBlockConnectionPointTypes.Float];\n if (second.isConnected) {\n // The same types as the connected input are always allowed.\n first.acceptedConnectionPointTypes.push(second.type);\n // If the other input is a scalar, then we also allow Vector/Color/Matrix types.\n if (second.type === NodeMaterialBlockConnectionPointTypes.Int || second.type === NodeMaterialBlockConnectionPointTypes.Float) {\n first.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2, NodeMaterialBlockConnectionPointTypes.Vector3, NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockConnectionPointTypes.Matrix);\n }\n }\n }\n }\n }\n /**\n * Release resources\n */\n dispose() {\n super.dispose();\n this._connectionObservers.forEach((observer) => observer.remove());\n this._connectionObservers.length = 0;\n }\n}\n"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,qCAAqC,QAAQ,mDAAmD;AACzG;AACA;AACA;AACA,OAAO,MAAMC,aAAa,SAASF,iBAAiB,CAAC;EACjDG,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,EAAEL,wBAAwB,CAACM,OAAO,CAAC;IAC7C,IAAI,CAACC,aAAa,CAAC,MAAM,EAAEL,qCAAqC,CAACM,UAAU,CAAC;IAC5E,IAAI,CAACD,aAAa,CAAC,OAAO,EAAEL,qCAAqC,CAACM,UAAU,CAAC;IAC7E,IAAI,CAACC,cAAc,CAAC,QAAQ,EAAEP,qCAAqC,CAACQ,YAAY,CAAC;IACjF,IAAI,CAACC,MAAM,CAACC,qBAAqB,GAAG,IAAI,CAACC,IAAI;IAC7C,IAAI,CAACC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;IACrC,IAAI,CAACD,IAAI,CAACE,4BAA4B,CAACC,IAAI,CAACd,qCAAqC,CAACe,KAAK,CAAC;IACxF,IAAI,CAACC,KAAK,CAACH,4BAA4B,CAACC,IAAI,CAACd,qCAAqC,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