55d4ade328d14b7606a6ddc0b4fc2ef94dbbbc600ac6f89f53191e5ec79e65fb.json 8.8 KB

1
  1. {"ast":null,"code":"import { TmpVectors, Vector3 } from \"../Maths/math.vector.js\";\nimport { SubMesh } from \"./subMesh.js\";\n/**\n * @internal\n */\nSubMesh.prototype._projectOnTrianglesToRef = function (vector, positions, indices, step, checkStopper, ref) {\n // Triangles test\n const proj = TmpVectors.Vector3[0];\n const tmp = TmpVectors.Vector3[1];\n let distance = +Infinity;\n for (let index = this.indexStart; index < this.indexStart + this.indexCount - (3 - step); index += step) {\n const indexA = indices[index];\n const indexB = indices[index + 1];\n const indexC = indices[index + 2];\n if (checkStopper && indexC === 0xffffffff) {\n index += 2;\n continue;\n }\n const p0 = positions[indexA];\n const p1 = positions[indexB];\n const p2 = positions[indexC];\n // stay defensive and don't check against undefined positions.\n if (!p0 || !p1 || !p2) {\n continue;\n }\n const tmpDist = Vector3.ProjectOnTriangleToRef(vector, p0, p1, p2, tmp);\n if (tmpDist < distance) {\n proj.copyFrom(tmp);\n distance = tmpDist;\n }\n }\n ref.copyFrom(proj);\n return distance;\n};\n/**\n * @internal\n */\nSubMesh.prototype._projectOnUnIndexedTrianglesToRef = function (vector, positions, indices, ref) {\n // Triangles test\n const proj = TmpVectors.Vector3[0];\n const tmp = TmpVectors.Vector3[1];\n let distance = +Infinity;\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {\n const p0 = positions[index];\n const p1 = positions[index + 1];\n const p2 = positions[index + 2];\n const tmpDist = Vector3.ProjectOnTriangleToRef(vector, p0, p1, p2, tmp);\n if (tmpDist < distance) {\n proj.copyFrom(tmp);\n distance = tmpDist;\n }\n }\n ref.copyFrom(proj);\n return distance;\n};\nSubMesh.prototype.projectToRef = function (vector, positions, indices, ref) {\n const material = this.getMaterial();\n if (!material) {\n return -1;\n }\n let step = 3;\n let checkStopper = false;\n switch (material.fillMode) {\n case 3:\n case 5:\n case 6:\n case 8:\n return -1;\n case 7:\n step = 1;\n checkStopper = true;\n break;\n default:\n break;\n }\n // LineMesh first as it's also a Mesh...\n if (material.fillMode === 4) {\n return -1;\n } else {\n // Check if mesh is unindexed\n if (!indices.length && this._mesh._unIndexed) {\n return this._projectOnUnIndexedTrianglesToRef(vector, positions, indices, ref);\n }\n return this._projectOnTrianglesToRef(vector, positions, indices, step, checkStopper, ref);\n }\n};","map":{"version":3,"names":["TmpVectors","Vector3","SubMesh","prototype","_projectOnTrianglesToRef","vector","positions","indices","step","checkStopper","ref","proj","tmp","distance","Infinity","index","indexStart","indexCount","indexA","indexB","indexC","p0","p1","p2","tmpDist","ProjectOnTriangleToRef","copyFrom","_projectOnUnIndexedTrianglesToRef","verticesStart","verticesCount","projectToRef","material","getMaterial","fillMode","length","_mesh","_unIndexed"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/subMesh.project.js"],"sourcesContent":["\nimport { TmpVectors, Vector3 } from \"../Maths/math.vector.js\";\nimport { SubMesh } from \"./subMesh.js\";\n/**\n * @internal\n */\nSubMesh.prototype._projectOnTrianglesToRef = function (vector, positions, indices, step, checkStopper, ref) {\n // Triangles test\n const proj = TmpVectors.Vector3[0];\n const tmp = TmpVectors.Vector3[1];\n let distance = +Infinity;\n for (let index = this.indexStart; index < this.indexStart + this.indexCount - (3 - step); index += step) {\n const indexA = indices[index];\n const indexB = indices[index + 1];\n const indexC = indices[index + 2];\n if (checkStopper && indexC === 0xffffffff) {\n index += 2;\n continue;\n }\n const p0 = positions[indexA];\n const p1 = positions[indexB];\n const p2 = positions[indexC];\n // stay defensive and don't check against undefined positions.\n if (!p0 || !p1 || !p2) {\n continue;\n }\n const tmpDist = Vector3.ProjectOnTriangleToRef(vector, p0, p1, p2, tmp);\n if (tmpDist < distance) {\n proj.copyFrom(tmp);\n distance = tmpDist;\n }\n }\n ref.copyFrom(proj);\n return distance;\n};\n/**\n * @internal\n */\nSubMesh.prototype._projectOnUnIndexedTrianglesToRef = function (vector, positions, indices, ref) {\n // Triangles test\n const proj = TmpVectors.Vector3[0];\n const tmp = TmpVectors.Vector3[1];\n let distance = +Infinity;\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {\n const p0 = positions[index];\n const p1 = positions[index + 1];\n const p2 = positions[index + 2];\n const tmpDist = Vector3.ProjectOnTriangleToRef(vector, p0, p1, p2, tmp);\n if (tmpDist < distance) {\n proj.copyFrom(tmp);\n distance = tmpDist;\n }\n }\n ref.copyFrom(proj);\n return distance;\n};\nSubMesh.prototype.projectToRef = function (vector, positions, indices, ref) {\n const material = this.getMaterial();\n if (!material) {\n return -1;\n }\n let step = 3;\n let checkStopper = false;\n switch (material.fillMode) {\n case 3:\n case 5:\n case 6:\n case 8:\n return -1;\n case 7:\n step = 1;\n checkStopper = true;\n break;\n default:\n break;\n }\n // LineMesh first as it's also a Mesh...\n if (material.fillMode === 4) {\n return -1;\n }\n else {\n // Check if mesh is unindexed\n if (!indices.length && this._mesh._unIndexed) {\n return this._projectOnUnIndexedTrianglesToRef(vector, positions, indices, ref);\n }\n return this._projectOnTrianglesToRef(vector, positions, indices, step, checkStopper, ref);\n }\n};\n"],"mappings":"AACA,SAASA,UAAU,EAAEC,OAAO,QAAQ,yBAAyB;AAC7D,SAASC,OAAO,QAAQ,cAAc;AACtC;AACA;AACA;AACAA,OAAO,CAACC,SAAS,CAACC,wBAAwB,GAAG,UAAUC,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,EAAEC,YAAY,EAAEC,GAAG,EAAE;EACxG;EACA,MAAMC,IAAI,GAAGX,UAAU,CAACC,OAAO,CAAC,CAAC,CAAC;EAClC,MAAMW,GAAG,GAAGZ,UAAU,CAACC,OAAO,CAAC,CAAC,CAAC;EACjC,IAAIY,QAAQ,GAAG,CAACC,QAAQ;EACxB,KAAK,IAAIC,KAAK,GAAG,IAAI,CAACC,UAAU,EAAED,KAAK,GAAG,IAAI,CAACC,UAAU,GAAG,IAAI,CAACC,UAAU,IAAI,CAAC,GA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