babylon.pickingInfo.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var BABYLON;
  2. (function (BABYLON) {
  3. var PickingInfo = (function () {
  4. function PickingInfo() {
  5. this.hit = false;
  6. this.distance = 0;
  7. this.pickedPoint = null;
  8. this.pickedMesh = null;
  9. this.bu = 0;
  10. this.bv = 0;
  11. this.faceId = -1;
  12. }
  13. // Methods
  14. PickingInfo.prototype.getNormal = function () {
  15. if (!this.pickedMesh) {
  16. return null;
  17. }
  18. var indices = this.pickedMesh.getIndices();
  19. var normals = this.pickedMesh.getVerticesData(BABYLON.VertexBuffer.NormalKind);
  20. var normal0 = BABYLON.Vector3.FromArray(normals, indices[this.faceId * 3] * 3);
  21. var normal1 = BABYLON.Vector3.FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  22. var normal2 = BABYLON.Vector3.FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23. normal0 = normal0.scale(this.bu);
  24. normal1 = normal1.scale(this.bv);
  25. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  26. return new BABYLON.Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
  27. };
  28. return PickingInfo;
  29. })();
  30. BABYLON.PickingInfo = PickingInfo;
  31. })(BABYLON || (BABYLON = {}));
  32. //# sourceMappingURL=babylon.pickingInfo.js.map