069a426c6031de48e560f4eb6639cefef3ac8f0f12a7388a1deb6153290b87f0.json 15 KB

1
  1. {"ast":null,"code":"import { Plane } from \"./math.plane.js\";\n/**\n * Represents a camera frustum\n */\nexport class Frustum {\n /**\n * Gets the planes representing the frustum\n * @param transform matrix to be applied to the returned planes\n * @returns a new array of 6 Frustum planes computed by the given transformation matrix.\n */\n static GetPlanes(transform) {\n const frustumPlanes = [];\n for (let index = 0; index < 6; index++) {\n frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));\n }\n Frustum.GetPlanesToRef(transform, frustumPlanes);\n return frustumPlanes;\n }\n /**\n * Gets the near frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetNearPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] + m[2];\n frustumPlane.normal.y = m[7] + m[6];\n frustumPlane.normal.z = m[11] + m[10];\n frustumPlane.d = m[15] + m[14];\n frustumPlane.normalize();\n }\n /**\n * Gets the far frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetFarPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] - m[2];\n frustumPlane.normal.y = m[7] - m[6];\n frustumPlane.normal.z = m[11] - m[10];\n frustumPlane.d = m[15] - m[14];\n frustumPlane.normalize();\n }\n /**\n * Gets the left frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetLeftPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] + m[0];\n frustumPlane.normal.y = m[7] + m[4];\n frustumPlane.normal.z = m[11] + m[8];\n frustumPlane.d = m[15] + m[12];\n frustumPlane.normalize();\n }\n /**\n * Gets the right frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetRightPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] - m[0];\n frustumPlane.normal.y = m[7] - m[4];\n frustumPlane.normal.z = m[11] - m[8];\n frustumPlane.d = m[15] - m[12];\n frustumPlane.normalize();\n }\n /**\n * Gets the top frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetTopPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] - m[1];\n frustumPlane.normal.y = m[7] - m[5];\n frustumPlane.normal.z = m[11] - m[9];\n frustumPlane.d = m[15] - m[13];\n frustumPlane.normalize();\n }\n /**\n * Gets the bottom frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetBottomPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] + m[1];\n frustumPlane.normal.y = m[7] + m[5];\n frustumPlane.normal.z = m[11] + m[9];\n frustumPlane.d = m[15] + m[13];\n frustumPlane.normalize();\n }\n /**\n * Sets the given array \"frustumPlanes\" with the 6 Frustum planes computed by the given transformation matrix.\n * @param transform transformation matrix to be applied to the resulting frustum planes\n * @param frustumPlanes the resulting frustum planes\n */\n static GetPlanesToRef(transform, frustumPlanes) {\n // Near\n Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);\n // Far\n Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);\n // Left\n Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);\n // Right\n Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);\n // Top\n Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);\n // Bottom\n Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);\n }\n /**\n * Tests if a point is located between the frustum planes.\n * @param point defines the point to test\n * @param frustumPlanes defines the frustum planes to test\n * @returns true if the point is located between the frustum planes\n */\n static IsPointInFrustum(point, frustumPlanes) {\n for (let i = 0; i < 6; i++) {\n if (frustumPlanes[i].dotCoordinate(point) < 0) {\n return false;\n }\n }\n return true;\n }\n}","map":{"version":3,"names":["Plane","Frustum","GetPlanes","transform","frustumPlanes","index","push","GetPlanesToRef","GetNearPlaneToRef","frustumPlane","m","normal","x","y","z","d","normalize","GetFarPlaneToRef","GetLeftPlaneToRef","GetRightPlaneToRef","GetTopPlaneToRef","GetBottomPlaneToRef","IsPointInFrustum","point","i","dotCoordinate"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Maths/math.frustum.js"],"sourcesContent":["import { Plane } from \"./math.plane.js\";\n/**\n * Represents a camera frustum\n */\nexport class Frustum {\n /**\n * Gets the planes representing the frustum\n * @param transform matrix to be applied to the returned planes\n * @returns a new array of 6 Frustum planes computed by the given transformation matrix.\n */\n static GetPlanes(transform) {\n const frustumPlanes = [];\n for (let index = 0; index < 6; index++) {\n frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));\n }\n Frustum.GetPlanesToRef(transform, frustumPlanes);\n return frustumPlanes;\n }\n /**\n * Gets the near frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetNearPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] + m[2];\n frustumPlane.normal.y = m[7] + m[6];\n frustumPlane.normal.z = m[11] + m[10];\n frustumPlane.d = m[15] + m[14];\n frustumPlane.normalize();\n }\n /**\n * Gets the far frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetFarPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] - m[2];\n frustumPlane.normal.y = m[7] - m[6];\n frustumPlane.normal.z = m[11] - m[10];\n frustumPlane.d = m[15] - m[14];\n frustumPlane.normalize();\n }\n /**\n * Gets the left frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetLeftPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] + m[0];\n frustumPlane.normal.y = m[7] + m[4];\n frustumPlane.normal.z = m[11] + m[8];\n frustumPlane.d = m[15] + m[12];\n frustumPlane.normalize();\n }\n /**\n * Gets the right frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetRightPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] - m[0];\n frustumPlane.normal.y = m[7] - m[4];\n frustumPlane.normal.z = m[11] - m[8];\n frustumPlane.d = m[15] - m[12];\n frustumPlane.normalize();\n }\n /**\n * Gets the top frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetTopPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] - m[1];\n frustumPlane.normal.y = m[7] - m[5];\n frustumPlane.normal.z = m[11] - m[9];\n frustumPlane.d = m[15] - m[13];\n frustumPlane.normalize();\n }\n /**\n * Gets the bottom frustum plane transformed by the transform matrix\n * @param transform transformation matrix to be applied to the resulting frustum plane\n * @param frustumPlane the resulting frustum plane\n */\n static GetBottomPlaneToRef(transform, frustumPlane) {\n const m = transform.m;\n frustumPlane.normal.x = m[3] + m[1];\n frustumPlane.normal.y = m[7] + m[5];\n frustumPlane.normal.z = m[11] + m[9];\n frustumPlane.d = m[15] + m[13];\n frustumPlane.normalize();\n }\n /**\n * Sets the given array \"frustumPlanes\" with the 6 Frustum planes computed by the given transformation matrix.\n * @param transform transformation matrix to be applied to the resulting frustum planes\n * @param frustumPlanes the resulting frustum planes\n */\n static GetPlanesToRef(transform, frustumPlanes) {\n // Near\n Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);\n // Far\n Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);\n // Left\n Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);\n // Right\n Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);\n // Top\n Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);\n // Bottom\n Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);\n }\n /**\n * Tests if a point is located between the frustum planes.\n * @param point defines the point to test\n * @param frustumPlanes defines the frustum planes to test\n * @returns true if the point is located between the frustum planes\n */\n static IsPointInFrustum(point, frustumPlanes) {\n for (let i = 0; i < 6; i++) {\n if (frustumPlanes[i].dotCoordinate(point) < 0) {\n return false;\n }\n }\n return true;\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,iBAAiB;AACvC;AACA;AACA;AACA,OAAO,MAAMC,OAAO,CAAC;EACjB;AACJ;AACA;AACA;AACA;EACI,OAAOC,SAASA,CAACC,SAAS,EAAE;IACxB,MAAMC,aAAa,GAAG,EAAE;IACxB,KAAK,IAAIC,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAG,CAAC,EAAEA,KAAK,EAAE,EAAE;MACpCD,aAAa,CAACE,IAAI,CAAC,IAAIN,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACrD;IACAC,OAAO,CAACM,cAAc,CAACJ,SAAS,EAAEC,aAAa,CAAC;IAChD,OAAOA,aAAa;EACxB;EACA;AACJ;AACA;AACA;AACA;EACI,OAAOI,iBAAiBA,CAACL,SAAS,EAAEM,YAAY,EAAE;IAC9C,MAAMC,CAAC,GAAGP,SAAS,CAACO,CAAC;IACrBD,YAAY,CAACE,MAAM,CAACC,CAAC,GAAGF,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC;IACnCD,YAAY,CAACE,MAAM,CAACE,CAAC,GAAGH,CAAC,CAAC,CAAC,CAAC,GAAGA,CAA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