{"ast":null,"code":"import { Vector3, TmpVectors, Matrix } from \"../Maths/math.vector.js\";\nimport { VertexBuffer } from \"../Buffers/buffer.js\";\n\n/**\n * Return a transformed local position from a mesh and vertex index\n * @param mesh mesh used to get vertex array from\n * @param index vertex index\n * @param res resulting local position\n * @returns false if it was not possible to compute the position for that vertex\n */\nexport function GetTransformedPosition(mesh, index, res) {\n const data = mesh.getVerticesData(VertexBuffer.PositionKind);\n if (!data) {\n return false;\n }\n const base = index * 3;\n const values = [data[base + 0], data[base + 1], data[base + 2]];\n if (values.some(value => isNaN(value !== null && value !== void 0 ? value : Number.NaN))) {\n return false;\n }\n if (mesh.morphTargetManager) {\n for (let component = 0; component < 3; component++) {\n let value = values[component];\n for (let targetCount = 0; targetCount < mesh.morphTargetManager.numTargets; targetCount++) {\n const target = mesh.morphTargetManager.getTarget(targetCount);\n const influence = target.influence;\n if (influence !== 0) {\n const targetData = target.getPositions();\n if (targetData) {\n value += (targetData[base + component] - data[base + component]) * influence;\n }\n }\n }\n values[component] = value;\n }\n }\n res.fromArray(values);\n if (mesh.skeleton) {\n const matricesIndicesData = mesh.getVerticesData(VertexBuffer.MatricesIndicesKind);\n const matricesWeightsData = mesh.getVerticesData(VertexBuffer.MatricesWeightsKind);\n if (matricesWeightsData && matricesIndicesData) {\n const needExtras = mesh.numBoneInfluencers > 4;\n const matricesIndicesExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null;\n const matricesWeightsExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;\n const skeletonMatrices = mesh.skeleton.getTransformMatrices(mesh);\n const finalMatrix = TmpVectors.Matrix[0];\n const tempMatrix = TmpVectors.Matrix[1];\n finalMatrix.reset();\n const matWeightIdx = index * 4;\n let inf;\n let weight;\n for (inf = 0; inf < 4; inf++) {\n weight = matricesWeightsData[matWeightIdx + inf];\n if (weight > 0) {\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);\n finalMatrix.addToSelf(tempMatrix);\n }\n }\n if (matricesIndicesExtraData && matricesWeightsExtraData) {\n for (inf = 0; inf < 4; inf++) {\n weight = matricesWeightsExtraData[matWeightIdx + inf];\n if (weight > 0) {\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);\n finalMatrix.addToSelf(tempMatrix);\n }\n }\n }\n Vector3.TransformCoordinatesFromFloatsToRef(values[0], values[1], values[2], finalMatrix, res);\n }\n }\n return true;\n}\n/**\n * Compute a world space hotspot position\n * TmpVectors.Vector3[0..4] are modified by this function. Do not use them as result output.\n * @param mesh mesh used to get hotspot from\n * @param hotSpotQuery point indices and barycentric\n * @param resPosition output world position\n * @param resNormal optional output world normal\n * @returns false if it was not possible to compute the hotspot position\n */\nexport function GetHotSpotToRef(mesh, hotSpotQuery, resPosition, resNormal) {\n resPosition.set(0, 0, 0);\n for (let i = 0; i < 3; i++) {\n const index = hotSpotQuery.pointIndex[i];\n if (!GetTransformedPosition(mesh, index, TmpVectors.Vector3[i])) {\n return false;\n }\n TmpVectors.Vector3[i].scaleAndAddToRef(hotSpotQuery.barycentric[i], resPosition);\n }\n // Convert the result to world space\n Vector3.TransformCoordinatesToRef(resPosition, mesh.getWorldMatrix(), resPosition);\n // compute normal in world space\n if (resNormal) {\n const pointA = TmpVectors.Vector3[0];\n const pointB = TmpVectors.Vector3[1];\n const pointC = TmpVectors.Vector3[2];\n const segmentA = TmpVectors.Vector3[3];\n const segmentB = TmpVectors.Vector3[4];\n segmentA.copyFrom(pointB);\n segmentA.subtractInPlace(pointA);\n segmentB.copyFrom(pointC);\n segmentB.subtractInPlace(pointA);\n segmentA.normalize();\n segmentB.normalize();\n Vector3.CrossToRef(segmentA, segmentB, resNormal);\n // flip normal when face culling is changed\n const flipNormal = mesh.material && mesh.material.sideOrientation === (mesh.getScene().useRightHandedSystem ? 0 : 1);\n if (flipNormal) {\n resNormal.scaleInPlace(-1);\n }\n // Convert the result to world space\n Vector3.TransformNormalToRef(resNormal, mesh.getWorldMatrix(), resNormal);\n resNormal.normalize();\n }\n return true;\n}","map":{"version":3,"names":["Vector3","TmpVectors","Matrix","VertexBuffer","GetTransformedPosition","mesh","index","res","data","getVerticesData","PositionKind","base","values","some","value","isNaN","Number","NaN","morphTargetManager","component","targetCount","numTargets","target","getTarget","influence","targetData","getPositions","fromArray","skeleton","matricesIndicesData","MatricesIndicesKind","matricesWeightsData","MatricesWeightsKind","needExtras","numBoneInfluencers","matricesIndicesExtraData","MatricesIndicesExtraKind","matricesWeightsExtraData","MatricesWeightsExtraKind","skeletonMatrices","getTransformMatrices","finalMatrix","tempMatrix","reset","matWeightIdx","inf","weight","FromFloat32ArrayToRefScaled","Math","floor","addToSelf","TransformCoordinatesFromFloatsToRef","GetHotSpotToRef","hotSpotQuery","resPosition","resNormal","set","i","pointIndex","scaleAndAddToRef","barycentric","TransformCoordinatesToRef","getWorldMatrix","pointA","pointB","pointC","segmentA","segmentB","copyFrom","subtractInPlace","normalize","CrossToRef","flipNormal","material","sideOrientation","getScene","useRightHandedSystem","scaleInPlace","TransformNormalToRef"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/abstractMesh.hotSpot.js"],"sourcesContent":["import { Vector3, TmpVectors, Matrix } from \"../Maths/math.vector.js\";\nimport { VertexBuffer } from \"../Buffers/buffer.js\";\n\n/**\n * Return a transformed local position from a mesh and vertex index\n * @param mesh mesh used to get vertex array from\n * @param index vertex index\n * @param res resulting local position\n * @returns false if it was not possible to compute the position for that vertex\n */\nexport function GetTransformedPosition(mesh, index, res) {\n const data = mesh.getVerticesData(VertexBuffer.PositionKind);\n if (!data) {\n return false;\n }\n const base = index * 3;\n const values = [data[base + 0], data[base + 1], data[base + 2]];\n if (values.some((value) => isNaN(value ?? Number.NaN))) {\n return false;\n }\n if (mesh.morphTargetManager) {\n for (let component = 0; component < 3; component++) {\n let value = values[component];\n for (let targetCount = 0; targetCount < mesh.morphTargetManager.numTargets; targetCount++) {\n const target = mesh.morphTargetManager.getTarget(targetCount);\n const influence = target.influence;\n if (influence !== 0) {\n const targetData = target.getPositions();\n if (targetData) {\n value += (targetData[base + component] - data[base + component]) * influence;\n }\n }\n }\n values[component] = value;\n }\n }\n res.fromArray(values);\n if (mesh.skeleton) {\n const matricesIndicesData = mesh.getVerticesData(VertexBuffer.MatricesIndicesKind);\n const matricesWeightsData = mesh.getVerticesData(VertexBuffer.MatricesWeightsKind);\n if (matricesWeightsData && matricesIndicesData) {\n const needExtras = mesh.numBoneInfluencers > 4;\n const matricesIndicesExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null;\n const matricesWeightsExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;\n const skeletonMatrices = mesh.skeleton.getTransformMatrices(mesh);\n const finalMatrix = TmpVectors.Matrix[0];\n const tempMatrix = TmpVectors.Matrix[1];\n finalMatrix.reset();\n const matWeightIdx = index * 4;\n let inf;\n let weight;\n for (inf = 0; inf < 4; inf++) {\n weight = matricesWeightsData[matWeightIdx + inf];\n if (weight > 0) {\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);\n finalMatrix.addToSelf(tempMatrix);\n }\n }\n if (matricesIndicesExtraData && matricesWeightsExtraData) {\n for (inf = 0; inf < 4; inf++) {\n weight = matricesWeightsExtraData[matWeightIdx + inf];\n if (weight > 0) {\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);\n finalMatrix.addToSelf(tempMatrix);\n }\n }\n }\n Vector3.TransformCoordinatesFromFloatsToRef(values[0], values[1], values[2], finalMatrix, res);\n }\n }\n return true;\n}\n/**\n * Compute a world space hotspot position\n * TmpVectors.Vector3[0..4] are modified by this function. Do not use them as result output.\n * @param mesh mesh used to get hotspot from\n * @param hotSpotQuery point indices and barycentric\n * @param resPosition output world position\n * @param resNormal optional output world normal\n * @returns false if it was not possible to compute the hotspot position\n */\nexport function GetHotSpotToRef(mesh, hotSpotQuery, resPosition, resNormal) {\n resPosition.set(0, 0, 0);\n for (let i = 0; i < 3; i++) {\n const index = hotSpotQuery.pointIndex[i];\n if (!GetTransformedPosition(mesh, index, TmpVectors.Vector3[i])) {\n return false;\n }\n TmpVectors.Vector3[i].scaleAndAddToRef(hotSpotQuery.barycentric[i], resPosition);\n }\n // Convert the result to world space\n Vector3.TransformCoordinatesToRef(resPosition, mesh.getWorldMatrix(), resPosition);\n // compute normal in world space\n if (resNormal) {\n const pointA = TmpVectors.Vector3[0];\n const pointB = TmpVectors.Vector3[1];\n const pointC = TmpVectors.Vector3[2];\n const segmentA = TmpVectors.Vector3[3];\n const segmentB = TmpVectors.Vector3[4];\n segmentA.copyFrom(pointB);\n segmentA.subtractInPlace(pointA);\n segmentB.copyFrom(pointC);\n segmentB.subtractInPlace(pointA);\n segmentA.normalize();\n segmentB.normalize();\n Vector3.CrossToRef(segmentA, segmentB, resNormal);\n // flip normal when face culling is changed\n const flipNormal = mesh.material &&\n mesh.material.sideOrientation ===\n (mesh.getScene().useRightHandedSystem ? 0 : 1);\n if (flipNormal) {\n resNormal.scaleInPlace(-1);\n }\n // Convert the result to world space\n Vector3.TransformNormalToRef(resNormal, mesh.getWorldMatrix(), resNormal);\n resNormal.normalize();\n }\n return true;\n}\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,UAAU,EAAEC,MAAM,QAAQ,yBAAyB;AACrE,SAASC,YAAY,QAAQ,sBAAsB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAACC,IAAI,EAAEC,KAAK,EAAEC,GAAG,EAAE;EACrD,MAAMC,IAAI,GAAGH,IAAI,CAACI,eAAe,CAACN,YAAY,CAACO,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