@babylonjs/core 5.28.0 → 5.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/Actions/actionManager.js +2 -0
  2. package/Actions/actionManager.js.map +1 -1
  3. package/Cameras/camera.js +4 -4
  4. package/Cameras/camera.js.map +1 -1
  5. package/Collisions/pickingInfo.d.ts +0 -2
  6. package/Collisions/pickingInfo.js +0 -2
  7. package/Collisions/pickingInfo.js.map +1 -1
  8. package/Culling/ray.js +5 -0
  9. package/Culling/ray.js.map +1 -1
  10. package/Engines/Extensions/engine.videoTexture.js +6 -3
  11. package/Engines/Extensions/engine.videoTexture.js.map +1 -1
  12. package/Engines/renderTargetWrapper.d.ts +2 -1
  13. package/Engines/renderTargetWrapper.js +1 -0
  14. package/Engines/renderTargetWrapper.js.map +1 -1
  15. package/Engines/thinEngine.js +2 -2
  16. package/Engines/thinEngine.js.map +1 -1
  17. package/Events/pointerEvents.d.ts +11 -6
  18. package/Events/pointerEvents.js +24 -6
  19. package/Events/pointerEvents.js.map +1 -1
  20. package/Inputs/scene.inputManager.d.ts +9 -1
  21. package/Inputs/scene.inputManager.js +76 -37
  22. package/Inputs/scene.inputManager.js.map +1 -1
  23. package/Layers/effectLayer.js +2 -6
  24. package/Layers/effectLayer.js.map +1 -1
  25. package/Materials/PBR/pbrMetallicRoughnessMaterial.d.ts +1 -1
  26. package/Materials/PBR/pbrMetallicRoughnessMaterial.js +1 -1
  27. package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
  28. package/Materials/Textures/htmlElementTexture.d.ts +5 -0
  29. package/Materials/Textures/htmlElementTexture.js +4 -1
  30. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  31. package/Materials/Textures/renderTargetTexture.d.ts +1 -1
  32. package/Materials/Textures/renderTargetTexture.js +2 -2
  33. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  34. package/Materials/Textures/videoTexture.d.ts +6 -1
  35. package/Materials/Textures/videoTexture.js +7 -2
  36. package/Materials/Textures/videoTexture.js.map +1 -1
  37. package/Maths/math.vector.d.ts +390 -319
  38. package/Maths/math.vector.js +298 -153
  39. package/Maths/math.vector.js.map +1 -1
  40. package/Meshes/Builders/decalBuilder.d.ts +8 -0
  41. package/Meshes/Builders/decalBuilder.js +270 -51
  42. package/Meshes/Builders/decalBuilder.js.map +1 -1
  43. package/Meshes/mesh.js +40 -0
  44. package/Meshes/mesh.js.map +1 -1
  45. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.d.ts +14 -8
  46. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +16 -6
  47. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  48. package/PostProcesses/blurPostProcess.d.ts +2 -1
  49. package/PostProcesses/blurPostProcess.js +3 -2
  50. package/PostProcesses/blurPostProcess.js.map +1 -1
  51. package/PostProcesses/circleOfConfusionPostProcess.js +2 -1
  52. package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
  53. package/PostProcesses/depthOfFieldBlurPostProcess.d.ts +2 -1
  54. package/PostProcesses/depthOfFieldBlurPostProcess.js +3 -5
  55. package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
  56. package/PostProcesses/depthOfFieldEffect.js +9 -4
  57. package/PostProcesses/depthOfFieldEffect.js.map +1 -1
  58. package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
  59. package/PostProcesses/volumetricLightScatteringPostProcess.js +2 -6
  60. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  61. package/Rendering/depthRenderer.js +2 -6
  62. package/Rendering/depthRenderer.js.map +1 -1
  63. package/Rendering/geometryBufferRenderer.js +2 -6
  64. package/Rendering/geometryBufferRenderer.js.map +1 -1
  65. package/Rendering/renderingGroup.d.ts +4 -0
  66. package/Rendering/renderingGroup.js +7 -1
  67. package/Rendering/renderingGroup.js.map +1 -1
  68. package/Rendering/renderingManager.d.ts +5 -0
  69. package/Rendering/renderingManager.js +15 -0
  70. package/Rendering/renderingManager.js.map +1 -1
  71. package/Shaders/circleOfConfusion.fragment.js +1 -1
  72. package/Shaders/circleOfConfusion.fragment.js.map +1 -1
  73. package/Shaders/depthOfFieldMerge.fragment.js +1 -1
  74. package/Shaders/depthOfFieldMerge.fragment.js.map +1 -1
  75. package/Shaders/kernelBlur.fragment.js +2 -2
  76. package/Shaders/kernelBlur.fragment.js.map +1 -1
  77. package/XR/webXRRenderTargetTextureProvider.js +1 -0
  78. package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
  79. package/package.json +1 -1
  80. package/scene.d.ts +5 -0
  81. package/scene.js +10 -6
  82. package/scene.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ray.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Culling/ray.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD;;GAEG;AACH,MAAM,OAAO,GAAG;IAKZ;;;;;OAKG;IACH;IACI,mBAAmB;IACZ,MAAe;IACtB,gBAAgB;IACT,SAAkB;IACzB,wBAAwB;IACjB,SAAiB,MAAM,CAAC,SAAS;QAJjC,WAAM,GAAN,MAAM,CAAS;QAEf,cAAS,GAAT,SAAS,CAAS;QAElB,WAAM,GAAN,MAAM,CAA2B;IACzC,CAAC;IAEJ,UAAU;IAEV;;;OAGG;IACI,KAAK;QACR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EAAE;QACT,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KACzC;SAAM;QACH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KAClC;IACD,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtF,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAEhE,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import type { DeepImmutable, Nullable, float } from \"../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { PickingInfo } from \"../Collisions/pickingInfo\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { BoundingBox } from \"./boundingBox\";\r\nimport type { BoundingSphere } from \"./boundingSphere\";\r\nimport { Scene } from \"../scene\";\r\nimport { Camera } from \"../Cameras/camera\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\ndeclare type Mesh = import(\"../Meshes/mesh\").Mesh;\r\n\r\n/**\r\n * Class representing a ray with position and direction\r\n */\r\nexport class Ray {\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(6, Vector3.Zero);\r\n private static _RayDistant = Ray.Zero();\r\n private _tmpRay: Ray;\r\n\r\n /**\r\n * Creates a new ray\r\n * @param origin origin point\r\n * @param direction direction\r\n * @param length length of the ray\r\n */\r\n constructor(\r\n /** origin point */\r\n public origin: Vector3,\r\n /** direction */\r\n public direction: Vector3,\r\n /** length of the ray */\r\n public length: number = Number.MAX_VALUE\r\n ) {}\r\n\r\n // Methods\r\n\r\n /**\r\n * Clone the current ray\r\n * @returns a new ray\r\n */\r\n public clone(): Ray {\r\n return new Ray(this.origin.clone(), this.direction.clone(), this.length);\r\n }\r\n\r\n /**\r\n * Checks if the ray intersects a box\r\n * This does not account for the ray length by design to improve perfs.\r\n * @param minimum bound of the box\r\n * @param maximum bound of the box\r\n * @param intersectionTreshold extra extend to be added to the box in all direction\r\n * @returns if the box was hit\r\n */\r\n public intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold: number = 0): boolean {\r\n const newMinimum = Ray._TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);\r\n const newMaximum = Ray._TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);\r\n let d = 0.0;\r\n let maxValue = Number.MAX_VALUE;\r\n let inv: number;\r\n let min: number;\r\n let max: number;\r\n let temp: number;\r\n if (Math.abs(this.direction.x) < 0.0000001) {\r\n if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.x;\r\n min = (newMinimum.x - this.origin.x) * inv;\r\n max = (newMaximum.x - this.origin.x) * inv;\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n\r\n if (Math.abs(this.direction.y) < 0.0000001) {\r\n if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.y;\r\n min = (newMinimum.y - this.origin.y) * inv;\r\n max = (newMaximum.y - this.origin.y) * inv;\r\n\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n\r\n if (Math.abs(this.direction.z) < 0.0000001) {\r\n if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.z;\r\n min = (newMinimum.z - this.origin.z) * inv;\r\n max = (newMaximum.z - this.origin.z) * inv;\r\n\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks if the ray intersects a box\r\n * This does not account for the ray lenght by design to improve perfs.\r\n * @param box the bounding box to check\r\n * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction\r\n * @returns if the box was hit\r\n */\r\n public intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold: number = 0): boolean {\r\n return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);\r\n }\r\n\r\n /**\r\n * If the ray hits a sphere\r\n * @param sphere the bounding sphere to check\r\n * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction\r\n * @returns true if it hits the sphere\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold: number = 0): boolean {\r\n const x = sphere.center.x - this.origin.x;\r\n const y = sphere.center.y - this.origin.y;\r\n const z = sphere.center.z - this.origin.z;\r\n const pyth = x * x + y * y + z * z;\r\n const radius = sphere.radius + intersectionTreshold;\r\n const rr = radius * radius;\r\n\r\n if (pyth <= rr) {\r\n return true;\r\n }\r\n\r\n const dot = x * this.direction.x + y * this.direction.y + z * this.direction.z;\r\n if (dot < 0.0) {\r\n return false;\r\n }\r\n\r\n const temp = pyth - dot * dot;\r\n\r\n return temp <= rr;\r\n }\r\n\r\n /**\r\n * If the ray hits a triange\r\n * @param vertex0 triangle vertex\r\n * @param vertex1 triangle vertex\r\n * @param vertex2 triangle vertex\r\n * @returns intersection information if hit\r\n */\r\n public intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo> {\r\n const edge1 = Ray._TmpVector3[0];\r\n const edge2 = Ray._TmpVector3[1];\r\n const pvec = Ray._TmpVector3[2];\r\n const tvec = Ray._TmpVector3[3];\r\n const qvec = Ray._TmpVector3[4];\r\n\r\n vertex1.subtractToRef(vertex0, edge1);\r\n vertex2.subtractToRef(vertex0, edge2);\r\n Vector3.CrossToRef(this.direction, edge2, pvec);\r\n const det = Vector3.Dot(edge1, pvec);\r\n\r\n if (det === 0) {\r\n return null;\r\n }\r\n\r\n const invdet = 1 / det;\r\n\r\n this.origin.subtractToRef(vertex0, tvec);\r\n\r\n const bv = Vector3.Dot(tvec, pvec) * invdet;\r\n\r\n if (bv < 0 || bv > 1.0) {\r\n return null;\r\n }\r\n\r\n Vector3.CrossToRef(tvec, edge1, qvec);\r\n\r\n const bw = Vector3.Dot(this.direction, qvec) * invdet;\r\n\r\n if (bw < 0 || bv + bw > 1.0) {\r\n return null;\r\n }\r\n\r\n //check if the distance is longer than the predefined length.\r\n const distance = Vector3.Dot(edge2, qvec) * invdet;\r\n if (distance > this.length) {\r\n return null;\r\n }\r\n\r\n return new IntersectionInfo(1 - bv - bw, bv, distance);\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a plane\r\n * @param plane the plane to check\r\n * @returns the distance away it was hit\r\n */\r\n public intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number> {\r\n let distance: number;\r\n const result1 = Vector3.Dot(plane.normal, this.direction);\r\n if (Math.abs(result1) < 9.99999997475243e-7) {\r\n return null;\r\n } else {\r\n const result2 = Vector3.Dot(plane.normal, this.origin);\r\n distance = (-plane.d - result2) / result1;\r\n if (distance < 0.0) {\r\n if (distance < -9.99999997475243e-7) {\r\n return null;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n return distance;\r\n }\r\n }\r\n /**\r\n * Calculate the intercept of a ray on a given axis\r\n * @param axis to check 'x' | 'y' | 'z'\r\n * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)\r\n * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.\r\n */\r\n public intersectsAxis(axis: string, offset: number = 0): Nullable<Vector3> {\r\n switch (axis) {\r\n case \"y\": {\r\n const t = (this.origin.y - offset) / this.direction.y;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(this.origin.x + this.direction.x * -t, offset, this.origin.z + this.direction.z * -t);\r\n }\r\n case \"x\": {\r\n const t = (this.origin.x - offset) / this.direction.x;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(offset, this.origin.y + this.direction.y * -t, this.origin.z + this.direction.z * -t);\r\n }\r\n case \"z\": {\r\n const t = (this.origin.z - offset) / this.direction.z;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(this.origin.x + this.direction.x * -t, this.origin.y + this.direction.y * -t, offset);\r\n }\r\n default:\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a mesh\r\n * @param mesh the mesh to check\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @returns picking info of the intersection\r\n */\r\n public intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo {\r\n const tm = TmpVectors.Matrix[0];\r\n\r\n mesh.getWorldMatrix().invertToRef(tm);\r\n\r\n if (this._tmpRay) {\r\n Ray.TransformToRef(this, tm, this._tmpRay);\r\n } else {\r\n this._tmpRay = Ray.Transform(this, tm);\r\n }\r\n\r\n return mesh.intersects(this._tmpRay, fastCheck);\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a mesh\r\n * @param meshes the meshes to check\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param results array to store result in\r\n * @returns Array of picking infos\r\n */\r\n public intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo> {\r\n if (results) {\r\n results.length = 0;\r\n } else {\r\n results = [];\r\n }\r\n\r\n for (let i = 0; i < meshes.length; i++) {\r\n const pickInfo = this.intersectsMesh(meshes[i], fastCheck);\r\n\r\n if (pickInfo.hit) {\r\n results.push(pickInfo);\r\n }\r\n }\r\n\r\n results.sort(this._comparePickingInfo);\r\n\r\n return results;\r\n }\r\n\r\n private _comparePickingInfo(pickingInfoA: DeepImmutable<PickingInfo>, pickingInfoB: DeepImmutable<PickingInfo>): number {\r\n if (pickingInfoA.distance < pickingInfoB.distance) {\r\n return -1;\r\n } else if (pickingInfoA.distance > pickingInfoB.distance) {\r\n return 1;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n private static _Smallnum = 0.00000001;\r\n private static _Rayl = 10e8;\r\n\r\n /**\r\n * Intersection test between the ray and a given segment within a given tolerance (threshold)\r\n * @param sega the first point of the segment to test the intersection against\r\n * @param segb the second point of the segment to test the intersection against\r\n * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful\r\n * @returns the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection\r\n */\r\n intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number {\r\n const o = this.origin;\r\n const u = TmpVectors.Vector3[0];\r\n const rsegb = TmpVectors.Vector3[1];\r\n const v = TmpVectors.Vector3[2];\r\n const w = TmpVectors.Vector3[3];\r\n\r\n segb.subtractToRef(sega, u);\r\n\r\n this.direction.scaleToRef(Ray._Rayl, v);\r\n o.addToRef(v, rsegb);\r\n\r\n sega.subtractToRef(o, w);\r\n\r\n const a = Vector3.Dot(u, u); // always >= 0\r\n const b = Vector3.Dot(u, v);\r\n const c = Vector3.Dot(v, v); // always >= 0\r\n const d = Vector3.Dot(u, w);\r\n const e = Vector3.Dot(v, w);\r\n const D = a * c - b * b; // always >= 0\r\n let sN: number,\r\n sD = D; // sc = sN / sD, default sD = D >= 0\r\n let tN: number,\r\n tD = D; // tc = tN / tD, default tD = D >= 0\r\n\r\n // compute the line parameters of the two closest points\r\n if (D < Ray._Smallnum) {\r\n // the lines are almost parallel\r\n sN = 0.0; // force using point P0 on segment S1\r\n sD = 1.0; // to prevent possible division by 0.0 later\r\n tN = e;\r\n tD = c;\r\n } else {\r\n // get the closest points on the infinite lines\r\n sN = b * e - c * d;\r\n tN = a * e - b * d;\r\n if (sN < 0.0) {\r\n // sc < 0 => the s=0 edge is visible\r\n sN = 0.0;\r\n tN = e;\r\n tD = c;\r\n } else if (sN > sD) {\r\n // sc > 1 => the s=1 edge is visible\r\n sN = sD;\r\n tN = e + b;\r\n tD = c;\r\n }\r\n }\r\n\r\n if (tN < 0.0) {\r\n // tc < 0 => the t=0 edge is visible\r\n tN = 0.0;\r\n // recompute sc for this edge\r\n if (-d < 0.0) {\r\n sN = 0.0;\r\n } else if (-d > a) {\r\n sN = sD;\r\n } else {\r\n sN = -d;\r\n sD = a;\r\n }\r\n } else if (tN > tD) {\r\n // tc > 1 => the t=1 edge is visible\r\n tN = tD;\r\n // recompute sc for this edge\r\n if (-d + b < 0.0) {\r\n sN = 0;\r\n } else if (-d + b > a) {\r\n sN = sD;\r\n } else {\r\n sN = -d + b;\r\n sD = a;\r\n }\r\n }\r\n // finally do the division to get sc and tc\r\n const sc = Math.abs(sN) < Ray._Smallnum ? 0.0 : sN / sD;\r\n const tc = Math.abs(tN) < Ray._Smallnum ? 0.0 : tN / tD;\r\n\r\n // get the difference of the two closest points\r\n const qtc = TmpVectors.Vector3[4];\r\n v.scaleToRef(tc, qtc);\r\n const qsc = TmpVectors.Vector3[5];\r\n u.scaleToRef(sc, qsc);\r\n qsc.addInPlace(w);\r\n const dP = TmpVectors.Vector3[6];\r\n qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)\r\n\r\n const isIntersected = tc > 0 && tc <= this.length && dP.lengthSquared() < threshold * threshold; // return intersection result\r\n\r\n if (isIntersected) {\r\n return qsc.length();\r\n }\r\n return -1;\r\n }\r\n\r\n /**\r\n * Update the ray from viewport position\r\n * @param x position\r\n * @param y y position\r\n * @param viewportWidth viewport width\r\n * @param viewportHeight viewport height\r\n * @param world world matrix\r\n * @param view view matrix\r\n * @param projection projection matrix\r\n * @param enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)\r\n * @returns this ray updated\r\n */\r\n public update(\r\n x: number,\r\n y: number,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>,\r\n enableDistantPicking: boolean = false\r\n ): Ray {\r\n if (enableDistantPicking) {\r\n // With world matrices having great values (like 8000000000 on 1 or more scaling or position axis),\r\n // multiplying view/projection/world and doing invert will result in loss of float precision in the matrix.\r\n // One way to fix it is to compute the ray with world at identity then transform the ray in object space.\r\n // This is slower (2 matrix inverts instead of 1) but precision is preserved.\r\n // This is hidden behind `EnableDistantPicking` flag (default is false)\r\n if (!Ray._RayDistant) {\r\n Ray._RayDistant = Ray.Zero();\r\n }\r\n\r\n Ray._RayDistant.unprojectRayToRef(x, y, viewportWidth, viewportHeight, Matrix.IdentityReadOnly, view, projection);\r\n\r\n const tm = TmpVectors.Matrix[0];\r\n world.invertToRef(tm);\r\n Ray.TransformToRef(Ray._RayDistant, tm, this);\r\n } else {\r\n this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a ray with origin and direction of 0,0,0\r\n * @returns the new ray\r\n */\r\n public static Zero(): Ray {\r\n return new Ray(Vector3.Zero(), Vector3.Zero());\r\n }\r\n\r\n /**\r\n * Creates a new ray from screen space and viewport\r\n * @param x position\r\n * @param y y position\r\n * @param viewportWidth viewport width\r\n * @param viewportHeight viewport height\r\n * @param world world matrix\r\n * @param view view matrix\r\n * @param projection projection matrix\r\n * @returns new ray\r\n */\r\n public static CreateNew(\r\n x: number,\r\n y: number,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>\r\n ): Ray {\r\n const result = Ray.Zero();\r\n\r\n return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);\r\n }\r\n\r\n /**\r\n * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be\r\n * transformed to the given world matrix.\r\n * @param origin The origin point\r\n * @param end The end point\r\n * @param world a matrix to transform the ray to. Default is the identity matrix.\r\n * @returns the new ray\r\n */\r\n public static CreateNewFromTo(origin: Vector3, end: Vector3, world: DeepImmutable<Matrix> = Matrix.IdentityReadOnly): Ray {\r\n const direction = end.subtract(origin);\r\n const length = Math.sqrt(direction.x * direction.x + direction.y * direction.y + direction.z * direction.z);\r\n direction.normalize();\r\n\r\n return Ray.Transform(new Ray(origin, direction, length), world);\r\n }\r\n\r\n /**\r\n * Transforms a ray by a matrix\r\n * @param ray ray to transform\r\n * @param matrix matrix to apply\r\n * @returns the resulting new ray\r\n */\r\n public static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray {\r\n const result = new Ray(new Vector3(0, 0, 0), new Vector3(0, 0, 0));\r\n Ray.TransformToRef(ray, matrix, result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Transforms a ray by a matrix\r\n * @param ray ray to transform\r\n * @param matrix matrix to apply\r\n * @param result ray to store result in\r\n */\r\n public static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void {\r\n Vector3.TransformCoordinatesToRef(ray.origin, matrix, result.origin);\r\n Vector3.TransformNormalToRef(ray.direction, matrix, result.direction);\r\n result.length = ray.length;\r\n\r\n const dir = result.direction;\r\n const len = dir.length();\r\n\r\n if (!(len === 0 || len === 1)) {\r\n const num = 1.0 / len;\r\n dir.x *= num;\r\n dir.y *= num;\r\n dir.z *= num;\r\n result.length *= len;\r\n }\r\n }\r\n\r\n /**\r\n * Unproject a ray from screen space to object space\r\n * @param sourceX defines the screen space x coordinate to use\r\n * @param sourceY defines the screen space y coordinate to use\r\n * @param viewportWidth defines the current width of the viewport\r\n * @param viewportHeight defines the current height of the viewport\r\n * @param world defines the world matrix to use (can be set to Identity to go to world space)\r\n * @param view defines the view matrix to use\r\n * @param projection defines the projection matrix to use\r\n */\r\n public unprojectRayToRef(\r\n sourceX: float,\r\n sourceY: float,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>\r\n ): void {\r\n const matrix = TmpVectors.Matrix[0];\r\n world.multiplyToRef(view, matrix);\r\n matrix.multiplyToRef(projection, matrix);\r\n matrix.invert();\r\n\r\n const nearScreenSource = TmpVectors.Vector3[0];\r\n nearScreenSource.x = (sourceX / viewportWidth) * 2 - 1;\r\n nearScreenSource.y = -((sourceY / viewportHeight) * 2 - 1);\r\n nearScreenSource.z = EngineStore.LastCreatedEngine?.isNDCHalfZRange ? 0 : -1;\r\n\r\n // far Z need to be close but < to 1 or camera projection matrix with maxZ = 0 will NaN\r\n const farScreenSource = TmpVectors.Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0 - 1e-8);\r\n const nearVec3 = TmpVectors.Vector3[2];\r\n const farVec3 = TmpVectors.Vector3[3];\r\n Vector3._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);\r\n Vector3._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);\r\n\r\n this.origin.copyFrom(nearVec3);\r\n farVec3.subtractToRef(nearVec3, this.direction);\r\n this.direction.normalize();\r\n }\r\n}\r\n\r\n// Picking\r\n/**\r\n * Type used to define predicate used to select faces when a mesh intersection is detected\r\n */\r\nexport type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /** @internal */\r\n _tempPickingRay: Nullable<Ray>;\r\n\r\n /** @internal */\r\n _cachedRayForTransform: Ray;\r\n\r\n /** @internal */\r\n _pickWithRayInverseMatrix: Matrix;\r\n\r\n /** @internal */\r\n _internalPick(\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<PickingInfo>;\r\n\r\n /** @internal */\r\n _internalMultiPick(\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<PickingInfo[]>;\r\n\r\n /** @internal */\r\n _internalPickForMesh(\r\n pickingInfo: Nullable<PickingInfo>,\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n mesh: AbstractMesh,\r\n world: Matrix,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n skipBoundingInfo?: boolean\r\n ): Nullable<PickingInfo>;\r\n }\r\n}\r\n\r\nScene.prototype.createPickingRay = function (x: number, y: number, world: Nullable<Matrix>, camera: Nullable<Camera>, cameraViewSpace = false): Ray {\r\n const result = Ray.Zero();\r\n\r\n this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype.createPickingRayToRef = function (\r\n x: number,\r\n y: number,\r\n world: Nullable<Matrix>,\r\n result: Ray,\r\n camera: Nullable<Camera>,\r\n cameraViewSpace = false,\r\n enableDistantPicking = false\r\n): Scene {\r\n const engine = this.getEngine();\r\n\r\n if (!camera) {\r\n if (!this.activeCamera) {\r\n return this;\r\n }\r\n\r\n camera = this.activeCamera;\r\n }\r\n\r\n const cameraViewport = camera.viewport;\r\n const viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());\r\n\r\n // Moving coordinates to local viewport world\r\n x = x / engine.getHardwareScalingLevel() - viewport.x;\r\n y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);\r\n\r\n result.update(\r\n x,\r\n y,\r\n viewport.width,\r\n viewport.height,\r\n world ? world : Matrix.IdentityReadOnly,\r\n cameraViewSpace ? Matrix.IdentityReadOnly : camera.getViewMatrix(),\r\n camera.getProjectionMatrix(),\r\n enableDistantPicking\r\n );\r\n return this;\r\n};\r\n\r\nScene.prototype.createPickingRayInCameraSpace = function (x: number, y: number, camera?: Camera): Ray {\r\n const result = Ray.Zero();\r\n\r\n this.createPickingRayInCameraSpaceToRef(x, y, result, camera);\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype.createPickingRayInCameraSpaceToRef = function (x: number, y: number, result: Ray, camera?: Camera): Scene {\r\n if (!PickingInfo) {\r\n return this;\r\n }\r\n\r\n const engine = this.getEngine();\r\n\r\n if (!camera) {\r\n if (!this.activeCamera) {\r\n throw new Error(\"Active camera not set\");\r\n }\r\n\r\n camera = this.activeCamera;\r\n }\r\n\r\n const cameraViewport = camera.viewport;\r\n const viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());\r\n const identity = Matrix.Identity();\r\n\r\n // Moving coordinates to local viewport world\r\n x = x / engine.getHardwareScalingLevel() - viewport.x;\r\n y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);\r\n result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());\r\n return this;\r\n};\r\n\r\nScene.prototype._internalPickForMesh = function (\r\n pickingInfo: Nullable<PickingInfo>,\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n mesh: AbstractMesh,\r\n world: Matrix,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n skipBoundingInfo?: boolean\r\n) {\r\n const ray = rayFunction(world, mesh.enableDistantPicking);\r\n\r\n const result = mesh.intersects(ray, fastCheck, trianglePredicate, onlyBoundingInfo, world, skipBoundingInfo);\r\n if (!result || !result.hit) {\r\n return null;\r\n }\r\n\r\n if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {\r\n return null;\r\n }\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype._internalPick = function (\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n\r\n let pickingInfo = null;\r\n\r\n for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {\r\n const mesh = this.meshes[meshIndex];\r\n\r\n if (predicate) {\r\n if (!predicate(mesh)) {\r\n continue;\r\n }\r\n } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {\r\n continue;\r\n }\r\n\r\n const world = mesh.getWorldMatrix();\r\n\r\n if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {\r\n // first check if the ray intersects the whole bounding box/sphere of the mesh\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, true, true, trianglePredicate);\r\n if (result) {\r\n if (onlyBoundingInfo) {\r\n // the user only asked for a bounding info check so we can return\r\n return result;\r\n }\r\n const tmpMatrix = TmpVectors.Matrix[1];\r\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\r\n for (let index = 0; index < thinMatrices.length; index++) {\r\n const thinMatrix = thinMatrices[index];\r\n thinMatrix.multiplyToRef(world, tmpMatrix);\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, tmpMatrix, fastCheck, onlyBoundingInfo, trianglePredicate, true);\r\n\r\n if (result) {\r\n pickingInfo = result;\r\n pickingInfo.thinInstanceIndex = index;\r\n\r\n if (fastCheck) {\r\n return pickingInfo;\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, fastCheck, onlyBoundingInfo, trianglePredicate);\r\n\r\n if (result) {\r\n pickingInfo = result;\r\n\r\n if (fastCheck) {\r\n return pickingInfo;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return pickingInfo || new PickingInfo();\r\n};\r\n\r\nScene.prototype._internalMultiPick = function (\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo[]> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const pickingInfos = new Array<PickingInfo>();\r\n\r\n for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {\r\n const mesh = this.meshes[meshIndex];\r\n\r\n if (predicate) {\r\n if (!predicate(mesh)) {\r\n continue;\r\n }\r\n } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {\r\n continue;\r\n }\r\n\r\n const world = mesh.getWorldMatrix();\r\n\r\n if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, world, true, true, trianglePredicate);\r\n if (result) {\r\n const tmpMatrix = TmpVectors.Matrix[1];\r\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\r\n for (let index = 0; index < thinMatrices.length; index++) {\r\n const thinMatrix = thinMatrices[index];\r\n thinMatrix.multiplyToRef(world, tmpMatrix);\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, tmpMatrix, false, false, trianglePredicate, true);\r\n\r\n if (result) {\r\n result.thinInstanceIndex = index;\r\n pickingInfos.push(result);\r\n }\r\n }\r\n }\r\n } else {\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, world, false, false, trianglePredicate);\r\n\r\n if (result) {\r\n pickingInfos.push(result);\r\n }\r\n }\r\n }\r\n\r\n return pickingInfos;\r\n};\r\n\r\nScene.prototype.pickWithBoundingInfo = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n camera?: Nullable<Camera>\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const result = this._internalPick(\r\n (world) => {\r\n if (!this._tempPickingRay) {\r\n this._tempPickingRay = Ray.Zero();\r\n }\r\n\r\n this.createPickingRayToRef(x, y, world, this._tempPickingRay, camera || null);\r\n return this._tempPickingRay;\r\n },\r\n predicate,\r\n fastCheck,\r\n true\r\n );\r\n if (result) {\r\n result.ray = this.createPickingRay(x, y, Matrix.Identity(), camera || null);\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.pick = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n camera?: Nullable<Camera>,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n _enableDistantPicking = false\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const result = this._internalPick(\r\n (world, enableDistantPicking) => {\r\n if (!this._tempPickingRay) {\r\n this._tempPickingRay = Ray.Zero();\r\n }\r\n\r\n this.createPickingRayToRef(x, y, world, this._tempPickingRay, camera || null, false, enableDistantPicking);\r\n return this._tempPickingRay;\r\n },\r\n predicate,\r\n fastCheck,\r\n false,\r\n trianglePredicate\r\n );\r\n if (result) {\r\n result.ray = this.createPickingRay(x, y, Matrix.Identity(), camera || null);\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.pickWithRay = function (\r\n ray: Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo> {\r\n const result = this._internalPick(\r\n (world) => {\r\n if (!this._pickWithRayInverseMatrix) {\r\n this._pickWithRayInverseMatrix = Matrix.Identity();\r\n }\r\n world.invertToRef(this._pickWithRayInverseMatrix);\r\n\r\n if (!this._cachedRayForTransform) {\r\n this._cachedRayForTransform = Ray.Zero();\r\n }\r\n\r\n Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);\r\n return this._cachedRayForTransform;\r\n },\r\n predicate,\r\n fastCheck,\r\n false,\r\n trianglePredicate\r\n );\r\n if (result) {\r\n result.ray = ray;\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.multiPick = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n camera?: Camera,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo[]> {\r\n return this._internalMultiPick((world) => this.createPickingRay(x, y, world, camera || null), predicate, trianglePredicate);\r\n};\r\n\r\nScene.prototype.multiPickWithRay = function (ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]> {\r\n return this._internalMultiPick(\r\n (world) => {\r\n if (!this._pickWithRayInverseMatrix) {\r\n this._pickWithRayInverseMatrix = Matrix.Identity();\r\n }\r\n world.invertToRef(this._pickWithRayInverseMatrix);\r\n\r\n if (!this._cachedRayForTransform) {\r\n this._cachedRayForTransform = Ray.Zero();\r\n }\r\n\r\n Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);\r\n return this._cachedRayForTransform;\r\n },\r\n predicate,\r\n trianglePredicate\r\n );\r\n};\r\n\r\nCamera.prototype.getForwardRay = function (length = 100, transform?: Matrix, origin?: Vector3): Ray {\r\n return this.getForwardRayToRef(new Ray(Vector3.Zero(), Vector3.Zero(), length), length, transform, origin);\r\n};\r\n\r\nCamera.prototype.getForwardRayToRef = function (refRay: Ray, length = 100, transform?: Matrix, origin?: Vector3): Ray {\r\n if (!transform) {\r\n transform = this.getWorldMatrix();\r\n }\r\n refRay.length = length;\r\n\r\n if (!origin) {\r\n refRay.origin.copyFrom(this.position);\r\n } else {\r\n refRay.origin.copyFrom(origin);\r\n }\r\n TmpVectors.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1);\r\n Vector3.TransformNormalToRef(TmpVectors.Vector3[2], transform, TmpVectors.Vector3[3]);\r\n\r\n Vector3.NormalizeToRef(TmpVectors.Vector3[3], refRay.direction);\r\n\r\n return refRay;\r\n};\r\n"]}
1
+ {"version":3,"file":"ray.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Culling/ray.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD;;GAEG;AACH,MAAM,OAAO,GAAG;IAKZ;;;;;OAKG;IACH;IACI,mBAAmB;IACZ,MAAe;IACtB,gBAAgB;IACT,SAAkB;IACzB,wBAAwB;IACjB,SAAiB,MAAM,CAAC,SAAS;QAJjC,WAAM,G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SAAS,EAAE,MAAM,CAAC,CAAC;AAC/G,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAU,MAAW,EAAE,MAAM,GAAG,GAAG,EAAE,SAAkB,EAAE,MAAgB;IAC3G,IAAI,CAAC,SAAS,EAAE;QACZ,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;KACrC;IACD,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IAEvB,IAAI,CAAC,MAAM,EAAE;QACT,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KACzC;SAAM;QACH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KAClC;IACD,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtF,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAEhE,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import type { DeepImmutable, Nullable, float } from \"../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { PickingInfo } from \"../Collisions/pickingInfo\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { BoundingBox } from \"./boundingBox\";\r\nimport type { BoundingSphere } from \"./boundingSphere\";\r\nimport { Scene } from \"../scene\";\r\nimport { Camera } from \"../Cameras/camera\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\ndeclare type Mesh = import(\"../Meshes/mesh\").Mesh;\r\n\r\n/**\r\n * Class representing a ray with position and direction\r\n */\r\nexport class Ray {\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(6, Vector3.Zero);\r\n private static _RayDistant = Ray.Zero();\r\n private _tmpRay: Ray;\r\n\r\n /**\r\n * Creates a new ray\r\n * @param origin origin point\r\n * @param direction direction\r\n * @param length length of the ray\r\n */\r\n constructor(\r\n /** origin point */\r\n public origin: Vector3,\r\n /** direction */\r\n public direction: Vector3,\r\n /** length of the ray */\r\n public length: number = Number.MAX_VALUE\r\n ) {}\r\n\r\n // Methods\r\n\r\n /**\r\n * Clone the current ray\r\n * @returns a new ray\r\n */\r\n public clone(): Ray {\r\n return new Ray(this.origin.clone(), this.direction.clone(), this.length);\r\n }\r\n\r\n /**\r\n * Checks if the ray intersects a box\r\n * This does not account for the ray length by design to improve perfs.\r\n * @param minimum bound of the box\r\n * @param maximum bound of the box\r\n * @param intersectionTreshold extra extend to be added to the box in all direction\r\n * @returns if the box was hit\r\n */\r\n public intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold: number = 0): boolean {\r\n const newMinimum = Ray._TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);\r\n const newMaximum = Ray._TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);\r\n let d = 0.0;\r\n let maxValue = Number.MAX_VALUE;\r\n let inv: number;\r\n let min: number;\r\n let max: number;\r\n let temp: number;\r\n if (Math.abs(this.direction.x) < 0.0000001) {\r\n if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.x;\r\n min = (newMinimum.x - this.origin.x) * inv;\r\n max = (newMaximum.x - this.origin.x) * inv;\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n\r\n if (Math.abs(this.direction.y) < 0.0000001) {\r\n if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.y;\r\n min = (newMinimum.y - this.origin.y) * inv;\r\n max = (newMaximum.y - this.origin.y) * inv;\r\n\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n\r\n if (Math.abs(this.direction.z) < 0.0000001) {\r\n if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {\r\n return false;\r\n }\r\n } else {\r\n inv = 1.0 / this.direction.z;\r\n min = (newMinimum.z - this.origin.z) * inv;\r\n max = (newMaximum.z - this.origin.z) * inv;\r\n\r\n if (max === -Infinity) {\r\n max = Infinity;\r\n }\r\n\r\n if (min > max) {\r\n temp = min;\r\n min = max;\r\n max = temp;\r\n }\r\n\r\n d = Math.max(min, d);\r\n maxValue = Math.min(max, maxValue);\r\n\r\n if (d > maxValue) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks if the ray intersects a box\r\n * This does not account for the ray lenght by design to improve perfs.\r\n * @param box the bounding box to check\r\n * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction\r\n * @returns if the box was hit\r\n */\r\n public intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold: number = 0): boolean {\r\n return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);\r\n }\r\n\r\n /**\r\n * If the ray hits a sphere\r\n * @param sphere the bounding sphere to check\r\n * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction\r\n * @returns true if it hits the sphere\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold: number = 0): boolean {\r\n const x = sphere.center.x - this.origin.x;\r\n const y = sphere.center.y - this.origin.y;\r\n const z = sphere.center.z - this.origin.z;\r\n const pyth = x * x + y * y + z * z;\r\n const radius = sphere.radius + intersectionTreshold;\r\n const rr = radius * radius;\r\n\r\n if (pyth <= rr) {\r\n return true;\r\n }\r\n\r\n const dot = x * this.direction.x + y * this.direction.y + z * this.direction.z;\r\n if (dot < 0.0) {\r\n return false;\r\n }\r\n\r\n const temp = pyth - dot * dot;\r\n\r\n return temp <= rr;\r\n }\r\n\r\n /**\r\n * If the ray hits a triange\r\n * @param vertex0 triangle vertex\r\n * @param vertex1 triangle vertex\r\n * @param vertex2 triangle vertex\r\n * @returns intersection information if hit\r\n */\r\n public intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo> {\r\n const edge1 = Ray._TmpVector3[0];\r\n const edge2 = Ray._TmpVector3[1];\r\n const pvec = Ray._TmpVector3[2];\r\n const tvec = Ray._TmpVector3[3];\r\n const qvec = Ray._TmpVector3[4];\r\n\r\n vertex1.subtractToRef(vertex0, edge1);\r\n vertex2.subtractToRef(vertex0, edge2);\r\n Vector3.CrossToRef(this.direction, edge2, pvec);\r\n const det = Vector3.Dot(edge1, pvec);\r\n\r\n if (det === 0) {\r\n return null;\r\n }\r\n\r\n const invdet = 1 / det;\r\n\r\n this.origin.subtractToRef(vertex0, tvec);\r\n\r\n const bv = Vector3.Dot(tvec, pvec) * invdet;\r\n\r\n if (bv < 0 || bv > 1.0) {\r\n return null;\r\n }\r\n\r\n Vector3.CrossToRef(tvec, edge1, qvec);\r\n\r\n const bw = Vector3.Dot(this.direction, qvec) * invdet;\r\n\r\n if (bw < 0 || bv + bw > 1.0) {\r\n return null;\r\n }\r\n\r\n //check if the distance is longer than the predefined length.\r\n const distance = Vector3.Dot(edge2, qvec) * invdet;\r\n if (distance > this.length) {\r\n return null;\r\n }\r\n\r\n return new IntersectionInfo(1 - bv - bw, bv, distance);\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a plane\r\n * @param plane the plane to check\r\n * @returns the distance away it was hit\r\n */\r\n public intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number> {\r\n let distance: number;\r\n const result1 = Vector3.Dot(plane.normal, this.direction);\r\n if (Math.abs(result1) < 9.99999997475243e-7) {\r\n return null;\r\n } else {\r\n const result2 = Vector3.Dot(plane.normal, this.origin);\r\n distance = (-plane.d - result2) / result1;\r\n if (distance < 0.0) {\r\n if (distance < -9.99999997475243e-7) {\r\n return null;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n return distance;\r\n }\r\n }\r\n /**\r\n * Calculate the intercept of a ray on a given axis\r\n * @param axis to check 'x' | 'y' | 'z'\r\n * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)\r\n * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.\r\n */\r\n public intersectsAxis(axis: string, offset: number = 0): Nullable<Vector3> {\r\n switch (axis) {\r\n case \"y\": {\r\n const t = (this.origin.y - offset) / this.direction.y;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(this.origin.x + this.direction.x * -t, offset, this.origin.z + this.direction.z * -t);\r\n }\r\n case \"x\": {\r\n const t = (this.origin.x - offset) / this.direction.x;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(offset, this.origin.y + this.direction.y * -t, this.origin.z + this.direction.z * -t);\r\n }\r\n case \"z\": {\r\n const t = (this.origin.z - offset) / this.direction.z;\r\n if (t > 0) {\r\n return null;\r\n }\r\n return new Vector3(this.origin.x + this.direction.x * -t, this.origin.y + this.direction.y * -t, offset);\r\n }\r\n default:\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a mesh\r\n * @param mesh the mesh to check\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @returns picking info of the intersection\r\n */\r\n public intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo {\r\n const tm = TmpVectors.Matrix[0];\r\n\r\n mesh.getWorldMatrix().invertToRef(tm);\r\n\r\n if (this._tmpRay) {\r\n Ray.TransformToRef(this, tm, this._tmpRay);\r\n } else {\r\n this._tmpRay = Ray.Transform(this, tm);\r\n }\r\n\r\n return mesh.intersects(this._tmpRay, fastCheck);\r\n }\r\n\r\n /**\r\n * Checks if ray intersects a mesh\r\n * @param meshes the meshes to check\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param results array to store result in\r\n * @returns Array of picking infos\r\n */\r\n public intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo> {\r\n if (results) {\r\n results.length = 0;\r\n } else {\r\n results = [];\r\n }\r\n\r\n for (let i = 0; i < meshes.length; i++) {\r\n const pickInfo = this.intersectsMesh(meshes[i], fastCheck);\r\n\r\n if (pickInfo.hit) {\r\n results.push(pickInfo);\r\n }\r\n }\r\n\r\n results.sort(this._comparePickingInfo);\r\n\r\n return results;\r\n }\r\n\r\n private _comparePickingInfo(pickingInfoA: DeepImmutable<PickingInfo>, pickingInfoB: DeepImmutable<PickingInfo>): number {\r\n if (pickingInfoA.distance < pickingInfoB.distance) {\r\n return -1;\r\n } else if (pickingInfoA.distance > pickingInfoB.distance) {\r\n return 1;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n private static _Smallnum = 0.00000001;\r\n private static _Rayl = 10e8;\r\n\r\n /**\r\n * Intersection test between the ray and a given segment within a given tolerance (threshold)\r\n * @param sega the first point of the segment to test the intersection against\r\n * @param segb the second point of the segment to test the intersection against\r\n * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful\r\n * @returns the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection\r\n */\r\n intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number {\r\n const o = this.origin;\r\n const u = TmpVectors.Vector3[0];\r\n const rsegb = TmpVectors.Vector3[1];\r\n const v = TmpVectors.Vector3[2];\r\n const w = TmpVectors.Vector3[3];\r\n\r\n segb.subtractToRef(sega, u);\r\n\r\n this.direction.scaleToRef(Ray._Rayl, v);\r\n o.addToRef(v, rsegb);\r\n\r\n sega.subtractToRef(o, w);\r\n\r\n const a = Vector3.Dot(u, u); // always >= 0\r\n const b = Vector3.Dot(u, v);\r\n const c = Vector3.Dot(v, v); // always >= 0\r\n const d = Vector3.Dot(u, w);\r\n const e = Vector3.Dot(v, w);\r\n const D = a * c - b * b; // always >= 0\r\n let sN: number,\r\n sD = D; // sc = sN / sD, default sD = D >= 0\r\n let tN: number,\r\n tD = D; // tc = tN / tD, default tD = D >= 0\r\n\r\n // compute the line parameters of the two closest points\r\n if (D < Ray._Smallnum) {\r\n // the lines are almost parallel\r\n sN = 0.0; // force using point P0 on segment S1\r\n sD = 1.0; // to prevent possible division by 0.0 later\r\n tN = e;\r\n tD = c;\r\n } else {\r\n // get the closest points on the infinite lines\r\n sN = b * e - c * d;\r\n tN = a * e - b * d;\r\n if (sN < 0.0) {\r\n // sc < 0 => the s=0 edge is visible\r\n sN = 0.0;\r\n tN = e;\r\n tD = c;\r\n } else if (sN > sD) {\r\n // sc > 1 => the s=1 edge is visible\r\n sN = sD;\r\n tN = e + b;\r\n tD = c;\r\n }\r\n }\r\n\r\n if (tN < 0.0) {\r\n // tc < 0 => the t=0 edge is visible\r\n tN = 0.0;\r\n // recompute sc for this edge\r\n if (-d < 0.0) {\r\n sN = 0.0;\r\n } else if (-d > a) {\r\n sN = sD;\r\n } else {\r\n sN = -d;\r\n sD = a;\r\n }\r\n } else if (tN > tD) {\r\n // tc > 1 => the t=1 edge is visible\r\n tN = tD;\r\n // recompute sc for this edge\r\n if (-d + b < 0.0) {\r\n sN = 0;\r\n } else if (-d + b > a) {\r\n sN = sD;\r\n } else {\r\n sN = -d + b;\r\n sD = a;\r\n }\r\n }\r\n // finally do the division to get sc and tc\r\n const sc = Math.abs(sN) < Ray._Smallnum ? 0.0 : sN / sD;\r\n const tc = Math.abs(tN) < Ray._Smallnum ? 0.0 : tN / tD;\r\n\r\n // get the difference of the two closest points\r\n const qtc = TmpVectors.Vector3[4];\r\n v.scaleToRef(tc, qtc);\r\n const qsc = TmpVectors.Vector3[5];\r\n u.scaleToRef(sc, qsc);\r\n qsc.addInPlace(w);\r\n const dP = TmpVectors.Vector3[6];\r\n qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)\r\n\r\n const isIntersected = tc > 0 && tc <= this.length && dP.lengthSquared() < threshold * threshold; // return intersection result\r\n\r\n if (isIntersected) {\r\n return qsc.length();\r\n }\r\n return -1;\r\n }\r\n\r\n /**\r\n * Update the ray from viewport position\r\n * @param x position\r\n * @param y y position\r\n * @param viewportWidth viewport width\r\n * @param viewportHeight viewport height\r\n * @param world world matrix\r\n * @param view view matrix\r\n * @param projection projection matrix\r\n * @param enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)\r\n * @returns this ray updated\r\n */\r\n public update(\r\n x: number,\r\n y: number,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>,\r\n enableDistantPicking: boolean = false\r\n ): Ray {\r\n if (enableDistantPicking) {\r\n // With world matrices having great values (like 8000000000 on 1 or more scaling or position axis),\r\n // multiplying view/projection/world and doing invert will result in loss of float precision in the matrix.\r\n // One way to fix it is to compute the ray with world at identity then transform the ray in object space.\r\n // This is slower (2 matrix inverts instead of 1) but precision is preserved.\r\n // This is hidden behind `EnableDistantPicking` flag (default is false)\r\n if (!Ray._RayDistant) {\r\n Ray._RayDistant = Ray.Zero();\r\n }\r\n\r\n Ray._RayDistant.unprojectRayToRef(x, y, viewportWidth, viewportHeight, Matrix.IdentityReadOnly, view, projection);\r\n\r\n const tm = TmpVectors.Matrix[0];\r\n world.invertToRef(tm);\r\n Ray.TransformToRef(Ray._RayDistant, tm, this);\r\n } else {\r\n this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a ray with origin and direction of 0,0,0\r\n * @returns the new ray\r\n */\r\n public static Zero(): Ray {\r\n return new Ray(Vector3.Zero(), Vector3.Zero());\r\n }\r\n\r\n /**\r\n * Creates a new ray from screen space and viewport\r\n * @param x position\r\n * @param y y position\r\n * @param viewportWidth viewport width\r\n * @param viewportHeight viewport height\r\n * @param world world matrix\r\n * @param view view matrix\r\n * @param projection projection matrix\r\n * @returns new ray\r\n */\r\n public static CreateNew(\r\n x: number,\r\n y: number,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>\r\n ): Ray {\r\n const result = Ray.Zero();\r\n\r\n return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);\r\n }\r\n\r\n /**\r\n * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be\r\n * transformed to the given world matrix.\r\n * @param origin The origin point\r\n * @param end The end point\r\n * @param world a matrix to transform the ray to. Default is the identity matrix.\r\n * @returns the new ray\r\n */\r\n public static CreateNewFromTo(origin: Vector3, end: Vector3, world: DeepImmutable<Matrix> = Matrix.IdentityReadOnly): Ray {\r\n const direction = end.subtract(origin);\r\n const length = Math.sqrt(direction.x * direction.x + direction.y * direction.y + direction.z * direction.z);\r\n direction.normalize();\r\n\r\n return Ray.Transform(new Ray(origin, direction, length), world);\r\n }\r\n\r\n /**\r\n * Transforms a ray by a matrix\r\n * @param ray ray to transform\r\n * @param matrix matrix to apply\r\n * @returns the resulting new ray\r\n */\r\n public static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray {\r\n const result = new Ray(new Vector3(0, 0, 0), new Vector3(0, 0, 0));\r\n Ray.TransformToRef(ray, matrix, result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Transforms a ray by a matrix\r\n * @param ray ray to transform\r\n * @param matrix matrix to apply\r\n * @param result ray to store result in\r\n */\r\n public static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void {\r\n Vector3.TransformCoordinatesToRef(ray.origin, matrix, result.origin);\r\n Vector3.TransformNormalToRef(ray.direction, matrix, result.direction);\r\n result.length = ray.length;\r\n\r\n const dir = result.direction;\r\n const len = dir.length();\r\n\r\n if (!(len === 0 || len === 1)) {\r\n const num = 1.0 / len;\r\n dir.x *= num;\r\n dir.y *= num;\r\n dir.z *= num;\r\n result.length *= len;\r\n }\r\n }\r\n\r\n /**\r\n * Unproject a ray from screen space to object space\r\n * @param sourceX defines the screen space x coordinate to use\r\n * @param sourceY defines the screen space y coordinate to use\r\n * @param viewportWidth defines the current width of the viewport\r\n * @param viewportHeight defines the current height of the viewport\r\n * @param world defines the world matrix to use (can be set to Identity to go to world space)\r\n * @param view defines the view matrix to use\r\n * @param projection defines the projection matrix to use\r\n */\r\n public unprojectRayToRef(\r\n sourceX: float,\r\n sourceY: float,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n world: DeepImmutable<Matrix>,\r\n view: DeepImmutable<Matrix>,\r\n projection: DeepImmutable<Matrix>\r\n ): void {\r\n const matrix = TmpVectors.Matrix[0];\r\n world.multiplyToRef(view, matrix);\r\n matrix.multiplyToRef(projection, matrix);\r\n matrix.invert();\r\n\r\n const nearScreenSource = TmpVectors.Vector3[0];\r\n nearScreenSource.x = (sourceX / viewportWidth) * 2 - 1;\r\n nearScreenSource.y = -((sourceY / viewportHeight) * 2 - 1);\r\n nearScreenSource.z = EngineStore.LastCreatedEngine?.isNDCHalfZRange ? 0 : -1;\r\n\r\n // far Z need to be close but < to 1 or camera projection matrix with maxZ = 0 will NaN\r\n const farScreenSource = TmpVectors.Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0 - 1e-8);\r\n const nearVec3 = TmpVectors.Vector3[2];\r\n const farVec3 = TmpVectors.Vector3[3];\r\n Vector3._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);\r\n Vector3._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);\r\n\r\n this.origin.copyFrom(nearVec3);\r\n farVec3.subtractToRef(nearVec3, this.direction);\r\n this.direction.normalize();\r\n }\r\n}\r\n\r\n// Picking\r\n/**\r\n * Type used to define predicate used to select faces when a mesh intersection is detected\r\n */\r\nexport type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /** @internal */\r\n _tempPickingRay: Nullable<Ray>;\r\n\r\n /** @internal */\r\n _cachedRayForTransform: Ray;\r\n\r\n /** @internal */\r\n _pickWithRayInverseMatrix: Matrix;\r\n\r\n /** @internal */\r\n _internalPick(\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<PickingInfo>;\r\n\r\n /** @internal */\r\n _internalMultiPick(\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<PickingInfo[]>;\r\n\r\n /** @internal */\r\n _internalPickForMesh(\r\n pickingInfo: Nullable<PickingInfo>,\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n mesh: AbstractMesh,\r\n world: Matrix,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n skipBoundingInfo?: boolean\r\n ): Nullable<PickingInfo>;\r\n }\r\n}\r\n\r\nScene.prototype.createPickingRay = function (x: number, y: number, world: Nullable<Matrix>, camera: Nullable<Camera>, cameraViewSpace = false): Ray {\r\n const result = Ray.Zero();\r\n\r\n this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype.createPickingRayToRef = function (\r\n x: number,\r\n y: number,\r\n world: Nullable<Matrix>,\r\n result: Ray,\r\n camera: Nullable<Camera>,\r\n cameraViewSpace = false,\r\n enableDistantPicking = false\r\n): Scene {\r\n const engine = this.getEngine();\r\n\r\n if (!camera) {\r\n if (!this.activeCamera) {\r\n return this;\r\n }\r\n\r\n camera = this.activeCamera;\r\n }\r\n\r\n const cameraViewport = camera.viewport;\r\n const viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());\r\n\r\n // Moving coordinates to local viewport world\r\n x = x / engine.getHardwareScalingLevel() - viewport.x;\r\n y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);\r\n\r\n result.update(\r\n x,\r\n y,\r\n viewport.width,\r\n viewport.height,\r\n world ? world : Matrix.IdentityReadOnly,\r\n cameraViewSpace ? Matrix.IdentityReadOnly : camera.getViewMatrix(),\r\n camera.getProjectionMatrix(),\r\n enableDistantPicking\r\n );\r\n return this;\r\n};\r\n\r\nScene.prototype.createPickingRayInCameraSpace = function (x: number, y: number, camera?: Camera): Ray {\r\n const result = Ray.Zero();\r\n\r\n this.createPickingRayInCameraSpaceToRef(x, y, result, camera);\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype.createPickingRayInCameraSpaceToRef = function (x: number, y: number, result: Ray, camera?: Camera): Scene {\r\n if (!PickingInfo) {\r\n return this;\r\n }\r\n\r\n const engine = this.getEngine();\r\n\r\n if (!camera) {\r\n if (!this.activeCamera) {\r\n throw new Error(\"Active camera not set\");\r\n }\r\n\r\n camera = this.activeCamera;\r\n }\r\n\r\n const cameraViewport = camera.viewport;\r\n const viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());\r\n const identity = Matrix.Identity();\r\n\r\n // Moving coordinates to local viewport world\r\n x = x / engine.getHardwareScalingLevel() - viewport.x;\r\n y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);\r\n result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());\r\n return this;\r\n};\r\n\r\nScene.prototype._internalPickForMesh = function (\r\n pickingInfo: Nullable<PickingInfo>,\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n mesh: AbstractMesh,\r\n world: Matrix,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n skipBoundingInfo?: boolean\r\n) {\r\n const ray = rayFunction(world, mesh.enableDistantPicking);\r\n\r\n const result = mesh.intersects(ray, fastCheck, trianglePredicate, onlyBoundingInfo, world, skipBoundingInfo);\r\n if (!result || !result.hit) {\r\n return null;\r\n }\r\n\r\n if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {\r\n return null;\r\n }\r\n\r\n return result;\r\n};\r\n\r\nScene.prototype._internalPick = function (\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n onlyBoundingInfo?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n\r\n let pickingInfo = null;\r\n\r\n for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {\r\n const mesh = this.meshes[meshIndex];\r\n\r\n if (predicate) {\r\n if (!predicate(mesh)) {\r\n continue;\r\n }\r\n } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {\r\n continue;\r\n }\r\n\r\n const world = mesh.getWorldMatrix();\r\n\r\n if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {\r\n // first check if the ray intersects the whole bounding box/sphere of the mesh\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, true, true, trianglePredicate);\r\n if (result) {\r\n if (onlyBoundingInfo) {\r\n // the user only asked for a bounding info check so we can return\r\n return result;\r\n }\r\n const tmpMatrix = TmpVectors.Matrix[1];\r\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\r\n for (let index = 0; index < thinMatrices.length; index++) {\r\n const thinMatrix = thinMatrices[index];\r\n thinMatrix.multiplyToRef(world, tmpMatrix);\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, tmpMatrix, fastCheck, onlyBoundingInfo, trianglePredicate, true);\r\n\r\n if (result) {\r\n pickingInfo = result;\r\n pickingInfo.thinInstanceIndex = index;\r\n\r\n if (fastCheck) {\r\n return pickingInfo;\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, fastCheck, onlyBoundingInfo, trianglePredicate);\r\n\r\n if (result) {\r\n pickingInfo = result;\r\n\r\n if (fastCheck) {\r\n return pickingInfo;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return pickingInfo || new PickingInfo();\r\n};\r\n\r\nScene.prototype._internalMultiPick = function (\r\n rayFunction: (world: Matrix, enableDistantPicking: boolean) => Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo[]> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const pickingInfos = new Array<PickingInfo>();\r\n\r\n for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {\r\n const mesh = this.meshes[meshIndex];\r\n\r\n if (predicate) {\r\n if (!predicate(mesh)) {\r\n continue;\r\n }\r\n } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {\r\n continue;\r\n }\r\n\r\n const world = mesh.getWorldMatrix();\r\n\r\n if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, world, true, true, trianglePredicate);\r\n if (result) {\r\n const tmpMatrix = TmpVectors.Matrix[1];\r\n const thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();\r\n for (let index = 0; index < thinMatrices.length; index++) {\r\n const thinMatrix = thinMatrices[index];\r\n thinMatrix.multiplyToRef(world, tmpMatrix);\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, tmpMatrix, false, false, trianglePredicate, true);\r\n\r\n if (result) {\r\n result.thinInstanceIndex = index;\r\n pickingInfos.push(result);\r\n }\r\n }\r\n }\r\n } else {\r\n const result = this._internalPickForMesh(null, rayFunction, mesh, world, false, false, trianglePredicate);\r\n\r\n if (result) {\r\n pickingInfos.push(result);\r\n }\r\n }\r\n }\r\n\r\n return pickingInfos;\r\n};\r\n\r\nScene.prototype.pickWithBoundingInfo = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n camera?: Nullable<Camera>\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const result = this._internalPick(\r\n (world) => {\r\n if (!this._tempPickingRay) {\r\n this._tempPickingRay = Ray.Zero();\r\n }\r\n\r\n this.createPickingRayToRef(x, y, world, this._tempPickingRay, camera || null);\r\n return this._tempPickingRay;\r\n },\r\n predicate,\r\n fastCheck,\r\n true\r\n );\r\n if (result) {\r\n result.ray = this.createPickingRay(x, y, Matrix.Identity(), camera || null);\r\n }\r\n return result;\r\n};\r\n\r\nObject.defineProperty(Scene.prototype, \"_pickingAvailable\", {\r\n get: () => true,\r\n enumerable: false,\r\n configurable: false,\r\n});\r\n\r\nScene.prototype.pick = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n camera?: Nullable<Camera>,\r\n trianglePredicate?: TrianglePickingPredicate,\r\n _enableDistantPicking = false\r\n): Nullable<PickingInfo> {\r\n if (!PickingInfo) {\r\n return null;\r\n }\r\n const result = this._internalPick(\r\n (world, enableDistantPicking) => {\r\n if (!this._tempPickingRay) {\r\n this._tempPickingRay = Ray.Zero();\r\n }\r\n\r\n this.createPickingRayToRef(x, y, world, this._tempPickingRay, camera || null, false, enableDistantPicking);\r\n return this._tempPickingRay;\r\n },\r\n predicate,\r\n fastCheck,\r\n false,\r\n trianglePredicate\r\n );\r\n if (result) {\r\n result.ray = this.createPickingRay(x, y, Matrix.Identity(), camera || null);\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.pickWithRay = function (\r\n ray: Ray,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo> {\r\n const result = this._internalPick(\r\n (world) => {\r\n if (!this._pickWithRayInverseMatrix) {\r\n this._pickWithRayInverseMatrix = Matrix.Identity();\r\n }\r\n world.invertToRef(this._pickWithRayInverseMatrix);\r\n\r\n if (!this._cachedRayForTransform) {\r\n this._cachedRayForTransform = Ray.Zero();\r\n }\r\n\r\n Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);\r\n return this._cachedRayForTransform;\r\n },\r\n predicate,\r\n fastCheck,\r\n false,\r\n trianglePredicate\r\n );\r\n if (result) {\r\n result.ray = ray;\r\n }\r\n return result;\r\n};\r\n\r\nScene.prototype.multiPick = function (\r\n x: number,\r\n y: number,\r\n predicate?: (mesh: AbstractMesh) => boolean,\r\n camera?: Camera,\r\n trianglePredicate?: TrianglePickingPredicate\r\n): Nullable<PickingInfo[]> {\r\n return this._internalMultiPick((world) => this.createPickingRay(x, y, world, camera || null), predicate, trianglePredicate);\r\n};\r\n\r\nScene.prototype.multiPickWithRay = function (ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]> {\r\n return this._internalMultiPick(\r\n (world) => {\r\n if (!this._pickWithRayInverseMatrix) {\r\n this._pickWithRayInverseMatrix = Matrix.Identity();\r\n }\r\n world.invertToRef(this._pickWithRayInverseMatrix);\r\n\r\n if (!this._cachedRayForTransform) {\r\n this._cachedRayForTransform = Ray.Zero();\r\n }\r\n\r\n Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);\r\n return this._cachedRayForTransform;\r\n },\r\n predicate,\r\n trianglePredicate\r\n );\r\n};\r\n\r\nCamera.prototype.getForwardRay = function (length = 100, transform?: Matrix, origin?: Vector3): Ray {\r\n return this.getForwardRayToRef(new Ray(Vector3.Zero(), Vector3.Zero(), length), length, transform, origin);\r\n};\r\n\r\nCamera.prototype.getForwardRayToRef = function (refRay: Ray, length = 100, transform?: Matrix, origin?: Vector3): Ray {\r\n if (!transform) {\r\n transform = this.getWorldMatrix();\r\n }\r\n refRay.length = length;\r\n\r\n if (!origin) {\r\n refRay.origin.copyFrom(this.position);\r\n } else {\r\n refRay.origin.copyFrom(origin);\r\n }\r\n TmpVectors.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1);\r\n Vector3.TransformNormalToRef(TmpVectors.Vector3[2], transform, TmpVectors.Vector3[3]);\r\n\r\n Vector3.NormalizeToRef(TmpVectors.Vector3[3], refRay.direction);\r\n\r\n return refRay;\r\n};\r\n"]}
@@ -1,8 +1,11 @@
1
1
  import { ThinEngine } from "../../Engines/thinEngine.js";
2
+
2
3
  ThinEngine.prototype.updateVideoTexture = function (texture, video, invertY) {
3
4
  if (!texture || texture._isDisabled) {
4
5
  return;
5
6
  }
7
+ const glformat = this._getInternalFormat(texture.format);
8
+ const internalFormat = this._getRGBABufferInternalSizedFormat(0, texture.format);
6
9
  const wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
7
10
  this._unpackFlipY(!invertY); // Video are upside down by default
8
11
  try {
@@ -10,7 +13,7 @@ ThinEngine.prototype.updateVideoTexture = function (texture, video, invertY) {
10
13
  if (this._videoTextureSupported === undefined) {
11
14
  // clear old errors just in case.
12
15
  this._gl.getError();
13
- this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
16
+ this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, video);
14
17
  if (this._gl.getError() !== 0) {
15
18
  this._videoTextureSupported = false;
16
19
  }
@@ -32,10 +35,10 @@ ThinEngine.prototype.updateVideoTexture = function (texture, video, invertY) {
32
35
  }
33
36
  texture._workingContext.clearRect(0, 0, texture.width, texture.height);
34
37
  texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
35
- this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
38
+ this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
36
39
  }
37
40
  else {
38
- this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
41
+ this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, video);
39
42
  }
40
43
  if (texture.generateMipMaps) {
41
44
  this._gl.generateMipmap(this._gl.TEXTURE_2D);
@@ -1 +1 @@
1
- {"version":3,"file":"engine.videoTexture.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/Extensions/engine.videoTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAg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EAAE,IAAI,CAAC,CAAC;SACxD;QACD,+BAA+B;QAC/B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;KAC1B;IAAC,OAAO,EAAE,EAAE;QACT,uBAAuB;QACvB,4BAA4B;QAC5B,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;KAC9B;AACL,CAAC,CAAC","sourcesContent":["import { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\ndeclare module \"../../Engines/thinEngine\" {\r\n export interface ThinEngine {\r\n /**\r\n * Update a video texture\r\n * @param texture defines the texture to update\r\n * @param video defines the video element to use\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n }\r\n}\r\n\r\nThinEngine.prototype.updateVideoTexture = function (texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void {\r\n if (!texture || texture._isDisabled) {\r\n return;\r\n }\r\n\r\n const wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);\r\n this._unpackFlipY(!invertY); // Video are upside down by default\r\n\r\n try {\r\n // Testing video texture support\r\n if (this._videoTextureSupported === undefined) {\r\n // clear old errors just in case.\r\n this._gl.getError();\r\n\r\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);\r\n\r\n if (this._gl.getError() !== 0) {\r\n this._videoTextureSupported = false;\r\n } else {\r\n this._videoTextureSupported = true;\r\n }\r\n }\r\n\r\n // Copy video through the current working canvas if video texture is not supported\r\n if (!this._videoTextureSupported) {\r\n if (!texture._workingCanvas) {\r\n texture._workingCanvas = this.createCanvas(texture.width, texture.height);\r\n const context = texture._workingCanvas.getContext(\"2d\");\r\n\r\n if (!context) {\r\n throw new Error(\"Unable to get 2d context\");\r\n }\r\n\r\n texture._workingContext = context;\r\n texture._workingCanvas.width = texture.width;\r\n texture._workingCanvas.height = texture.height;\r\n }\r\n\r\n texture._workingContext!.clearRect(0, 0, texture.width, texture.height);\r\n texture._workingContext!.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);\r\n\r\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas as TexImageSource);\r\n } else {\r\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);\r\n }\r\n\r\n if (texture.generateMipMaps) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_2D);\r\n }\r\n\r\n if (!wasPreviouslyBound) {\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\r\n }\r\n // this.resetTextureCache();\r\n texture.isReady = true;\r\n } catch (ex) {\r\n // Something unexpected\r\n // Let's disable the texture\r\n texture._isDisabled = true;\r\n }\r\n};\r\n"]}
1
+ {"version":3,"file":"engine.videoTexture.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/Extensions/engine.videoTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAczC,UAAU,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAU,OAAkC,EAAE,KAAuB,EAAE,OAAgB;IAC7H,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,WAAW,EAAE;QACjC,OAAO;KACV;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,cAAc,GAAG,IAAI,CAAC,iCAAiC,CAAC,SAAS,CAAC,yBAAyB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnH,MAAM,kBAAkB,GAAG,IAA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AAC,eAAgB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACxE,OAAO,CAAC,eAAgB,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAE1H,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,cAAgC,CAAC,CAAC;SAC3I;aAAM;YACH,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;SACxG;QAED,IAAI,OAAO,CAAC,eAAe,EAAE;YACzB,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;SAChD;QAED,IAAI,CAAC,kBAAkB,EAAE;YACrB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;SACxD;QACD,+BAA+B;QAC/B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;KAC1B;IAAC,OAAO,EAAE,EAAE;QACT,uBAAuB;QACvB,4BAA4B;QAC5B,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;KAC9B;AACL,CAAC,CAAC","sourcesContent":["import { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\n\r\ndeclare module \"../../Engines/thinEngine\" {\r\n export interface ThinEngine {\r\n /**\r\n * Update a video texture\r\n * @param texture defines the texture to update\r\n * @param video defines the video element to use\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n }\r\n}\r\n\r\nThinEngine.prototype.updateVideoTexture = function (texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void {\r\n if (!texture || texture._isDisabled) {\r\n return;\r\n }\r\n\r\n const glformat = this._getInternalFormat(texture.format);\r\n const internalFormat = this._getRGBABufferInternalSizedFormat(Constants.TEXTURETYPE_UNSIGNED_BYTE, texture.format);\r\n\r\n const wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);\r\n this._unpackFlipY(!invertY); // Video are upside down by default\r\n\r\n try {\r\n // Testing video texture support\r\n if (this._videoTextureSupported === undefined) {\r\n // clear old errors just in case.\r\n this._gl.getError();\r\n\r\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, video);\r\n\r\n if (this._gl.getError() !== 0) {\r\n this._videoTextureSupported = false;\r\n } else {\r\n this._videoTextureSupported = true;\r\n }\r\n }\r\n\r\n // Copy video through the current working canvas if video texture is not supported\r\n if (!this._videoTextureSupported) {\r\n if (!texture._workingCanvas) {\r\n texture._workingCanvas = this.createCanvas(texture.width, texture.height);\r\n const context = texture._workingCanvas.getContext(\"2d\");\r\n\r\n if (!context) {\r\n throw new Error(\"Unable to get 2d context\");\r\n }\r\n\r\n texture._workingContext = context;\r\n texture._workingCanvas.width = texture.width;\r\n texture._workingCanvas.height = texture.height;\r\n }\r\n\r\n texture._workingContext!.clearRect(0, 0, texture.width, texture.height);\r\n texture._workingContext!.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);\r\n\r\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, texture._workingCanvas as TexImageSource);\r\n } else {\r\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, video);\r\n }\r\n\r\n if (texture.generateMipMaps) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_2D);\r\n }\r\n\r\n if (!wasPreviouslyBound) {\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\r\n }\r\n // this.resetTextureCache();\r\n texture.isReady = true;\r\n } catch (ex) {\r\n // Something unexpected\r\n // Let's disable the texture\r\n texture._isDisabled = true;\r\n }\r\n};\r\n"]}
@@ -20,7 +20,8 @@ export declare class RenderTargetWrapper {
20
20
  private _isCube;
21
21
  private _isMulti;
22
22
  private _textures;
23
- private _samples;
23
+ /** @internal */
24
+ _samples: number;
24
25
  /** @internal */
25
26
  _attachments: Nullable<number[]>;
26
27
  /** @internal */
@@ -13,6 +13,7 @@ export class RenderTargetWrapper {
13
13
  */
14
14
  constructor(isMulti, isCube, size, engine) {
15
15
  this._textures = null;
16
+ /** @internal */
16
17
  this._samples = 1;
17
18
  /** @internal */
18
19
  this._attachments = null;
@@ -1 +1 @@
1
- {"version":3,"file":"renderTargetWrapper.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/renderTargetWrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAaxC;;GAEG;AACH,MAAM,OAAO,mBAAmB;IA2H5B;;;;;;OAMG;IACH,YAAY,OAAgB,EAAE,MAAe,EAAE,IAAiB,EAAE,MAAkB;QA7H5E,cAAS,GAAgC,IAAI,CAAC;QAC9C,aAAQ,GAAG,CAAC,CAAC;QAErB,gBAAgB;QACT,iBAAY,GAAuB,IAAI,CAAC;QAC/C,gBAAgB;QACT,2BAAsB,GAAY,KAAK,CAA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C;SAChC;QAED,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QACnC,GAAG,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,eAAe;;QAClB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAA,CAAC,IAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,MAAM,CAAA,mCAAI,CAAC,EAAE,EAAE,CAAC,EAAE;gBAClD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;aAC/B;SACJ;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,uBAAuB,GAAG,KAAK;;QAC1C,IAAI,CAAC,uBAAuB,EAAE;YAC1B,MAAA,IAAI,CAAC,oBAAoB,0CAAE,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,eAAe,EAAE,CAAC;SAC1B;QAED,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Constants } from \"./constants\";\r\nimport type { ThinEngine } from \"./thinEngine\";\r\n\r\n/**\r\n * An interface enforcing the renderTarget accessor to used by render target textures.\r\n */\r\nexport interface IRenderTargetTexture {\r\n /**\r\n * Entry point to access the wrapper on a texture.\r\n */\r\n renderTarget: Nullable<RenderTargetWrapper>;\r\n}\r\n\r\n/**\r\n * Wrapper around a render target (either single or multi textures)\r\n */\r\nexport class RenderTargetWrapper {\r\n protected _engine: ThinEngine;\r\n private _size: TextureSize;\r\n private _isCube: boolean;\r\n private _isMulti: boolean;\r\n private _textures: Nullable<InternalTexture[]> = null;\r\n private _samples = 1;\r\n\r\n /** @internal */\r\n public _attachments: Nullable<number[]> = null;\r\n /** @internal */\r\n public _generateStencilBuffer: boolean = false;\r\n /** @internal */\r\n public _generateDepthBuffer: boolean = false;\r\n\r\n /** @internal */\r\n public _depthStencilTexture: Nullable<InternalTexture>;\r\n /** @internal */\r\n public _depthStencilTextureWithStencil: boolean = false;\r\n\r\n /**\r\n * Gets the depth/stencil texture (if created by a createDepthStencilTexture() call)\r\n */\r\n public get depthStencilTexture() {\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Indicates if the depth/stencil texture has a stencil aspect\r\n */\r\n public get depthStencilTextureWithStencil() {\r\n return this._depthStencilTextureWithStencil;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a cube texture or if false a 2d texture\r\n */\r\n public get isCube(): boolean {\r\n return this._isCube;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or multi target render wrapper\r\n */\r\n public get isMulti(): boolean {\r\n return this._isMulti;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or an array of textures\r\n */\r\n public get is2DArray(): boolean {\r\n return this.layers > 0;\r\n }\r\n\r\n /**\r\n * Gets the size of the render target wrapper (used for cubes, as width=height in this case)\r\n */\r\n public get size(): number {\r\n return this.width;\r\n }\r\n\r\n /**\r\n * Gets the width of the render target wrapper\r\n */\r\n public get width(): number {\r\n return (<{ width: number; height: number }>this._size).width || <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the height of the render target wrapper\r\n */\r\n public get height(): number {\r\n return (<{ width: number; height: number }>this._size).height || <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the number of layers of the render target wrapper (only used if is2DArray is true)\r\n */\r\n public get layers(): number {\r\n return (<{ width: number; height: number; layers?: number }>this._size).layers || 0;\r\n }\r\n\r\n /**\r\n * Gets the render texture. If this is a multi render target, gets the first texture\r\n */\r\n public get texture(): Nullable<InternalTexture> {\r\n return this._textures?.[0] ?? null;\r\n }\r\n\r\n /**\r\n * Gets the list of render textures. If we are not in a multi render target, the list will be null (use the texture getter instead)\r\n */\r\n public get textures(): Nullable<InternalTexture[]> {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the sample count of the render target\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n /**\r\n * Sets the sample count of the render target\r\n * @param value sample count\r\n * @param initializeBuffers If set to true, the engine will make an initializing call to drawBuffers (only used when isMulti=true).\r\n * @param force true to force calling the update sample count engine function even if the current sample count is equal to value\r\n * @returns the sample count that has been set\r\n */\r\n public setSamples(value: number, initializeBuffers = true, force = false): number {\r\n if (this.samples === value && !force) {\r\n return value;\r\n }\r\n\r\n const result = this._isMulti\r\n ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, value, initializeBuffers)\r\n : this._engine.updateRenderTargetTextureSampleCount(this, value);\r\n this._samples = value;\r\n return result;\r\n }\r\n\r\n /**\r\n * Initializes the render target wrapper\r\n * @param isMulti true if the wrapper is a multi render target\r\n * @param isCube true if the wrapper should render to a cube texture\r\n * @param size size of the render target (width/height/layers)\r\n * @param engine engine used to create the render target\r\n */\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: ThinEngine) {\r\n this._isMulti = isMulti;\r\n this._isCube = isCube;\r\n this._size = size;\r\n this._engine = engine;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /**\r\n * Sets the render target texture(s)\r\n * @param textures texture(s) to set\r\n */\r\n public setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void {\r\n if (Array.isArray(textures)) {\r\n this._textures = textures;\r\n } else if (textures) {\r\n this._textures = [textures];\r\n } else {\r\n this._textures = null;\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture the texture to set\r\n * @param index the index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true): void {\r\n if (!this._textures) {\r\n this._textures = [];\r\n }\r\n if (this._textures[index] && disposePrevious) {\r\n this._textures[index].dispose();\r\n }\r\n\r\n this._textures[index] = texture;\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil true if the stencil aspect should also be created\r\n * @param samples sample count to use when creating the texture\r\n * @param format format of the depth texture\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT\r\n ): InternalTexture {\r\n this._depthStencilTexture?.dispose();\r\n\r\n this._depthStencilTextureWithStencil = generateStencil;\r\n this._depthStencilTexture = this._engine.createDepthStencilTexture(\r\n this._size,\r\n {\r\n bilinearFiltering,\r\n comparisonFunction,\r\n generateStencil,\r\n isCube: this._isCube,\r\n samples,\r\n depthTextureFormat: format,\r\n },\r\n this\r\n );\r\n\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @internal\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: RenderTargetWrapper): void {\r\n if (this._depthStencilTexture) {\r\n if (renderTarget._depthStencilTexture) {\r\n renderTarget._depthStencilTexture.dispose();\r\n }\r\n\r\n renderTarget._depthStencilTexture = this._depthStencilTexture;\r\n this._depthStencilTexture.incrementReferences();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture): void {\r\n if (this.texture) {\r\n this.texture._swapAndDie(target);\r\n }\r\n this._textures = null;\r\n this.dispose(true);\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._isMulti) {\r\n const textureArray = this.textures;\r\n if (textureArray && textureArray.length > 0) {\r\n let generateDepthTexture = false;\r\n let textureCount = textureArray.length;\r\n\r\n const lastTextureSource = textureArray[textureArray.length - 1]._source;\r\n if (lastTextureSource === InternalTextureSource.Depth || lastTextureSource === InternalTextureSource.DepthStencil) {\r\n generateDepthTexture = true;\r\n textureCount--;\r\n }\r\n\r\n const samplingModes: number[] = [];\r\n const types: number[] = [];\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n\r\n samplingModes.push(texture.samplingMode);\r\n types.push(texture.type);\r\n }\r\n\r\n const optionsMRT = {\r\n samplingModes,\r\n generateMipMaps: textureArray[0].generateMipMaps,\r\n generateDepthBuffer: this._generateDepthBuffer,\r\n generateStencilBuffer: this._generateStencilBuffer,\r\n generateDepthTexture,\r\n types,\r\n textureCount,\r\n };\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n };\r\n\r\n rtw = this._engine.createMultipleRenderTarget(size, optionsMRT);\r\n }\r\n } else {\r\n const options: RenderTargetCreationOptions = {};\r\n\r\n options.generateDepthBuffer = this._generateDepthBuffer;\r\n options.generateMipMaps = this.texture?.generateMipMaps ?? false;\r\n options.generateStencilBuffer = this._generateStencilBuffer;\r\n options.samplingMode = this.texture?.samplingMode;\r\n options.type = this.texture?.type;\r\n options.format = this.texture?.format;\r\n\r\n if (this.isCube) {\r\n rtw = this._engine.createRenderTargetCubeTexture(this.width, options);\r\n } else {\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray ? this.texture?.depth : undefined,\r\n };\r\n\r\n rtw = this._engine.createRenderTargetTexture(size, options);\r\n }\r\n rtw.texture!.isReady = true;\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: RenderTargetWrapper): void {\r\n if (this._textures && target._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i]._swapAndDie(target._textures[i], false);\r\n target._textures[i].isReady = true;\r\n }\r\n }\r\n if (this._depthStencilTexture && target._depthStencilTexture) {\r\n this._depthStencilTexture._swapAndDie(target._depthStencilTexture);\r\n target._depthStencilTexture.isReady = true;\r\n }\r\n\r\n this._textures = null;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const rtw = this._cloneRenderTargetWrapper();\r\n if (!rtw) {\r\n return;\r\n }\r\n\r\n if (this._depthStencilTexture) {\r\n const samplingMode = this._depthStencilTexture.samplingMode;\r\n const bilinear =\r\n samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST;\r\n rtw.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, bilinear, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples);\r\n }\r\n\r\n if (this.samples > 1) {\r\n rtw.setSamples(this.samples);\r\n }\r\n\r\n rtw._swapRenderTargetWrapper(this);\r\n rtw.dispose();\r\n }\r\n\r\n /**\r\n * Releases the internal render textures\r\n */\r\n public releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures?.length ?? 0; ++i) {\r\n this._textures[i].dispose();\r\n }\r\n }\r\n this._textures = null;\r\n }\r\n\r\n /**\r\n * Disposes the whole render target wrapper\r\n * @param disposeOnlyFramebuffers true if only the frame buffers should be released (used for the WebGL engine). If false, all the textures will also be released\r\n */\r\n public dispose(disposeOnlyFramebuffers = false): void {\r\n if (!disposeOnlyFramebuffers) {\r\n this._depthStencilTexture?.dispose();\r\n this._depthStencilTexture = null;\r\n this.releaseTextures();\r\n }\r\n\r\n this._engine._releaseRenderTargetWrapper(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"renderTargetWrapper.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/renderTargetWrapper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D,MAAM,QAAQ,GACV,YAAY,KAAK,SAAS,CAAC,6BAA6B;gBACxD,YAAY,KAAK,SAAS,CAAC,8BAA8B;gBACzD,YAAY,KAAK,SAAS,CAAC,gCAAgC,CAAC;YAChE,GAAG,CAAC,yBAAyB,CAAC,IAAI,CAAC,oBAAoB,CAAC,mBAAmB,EAAE,QAAQ,EAAE,IAAI,CAAC,+BAA+B,EAAE,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;SACnK;QAED,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE;YAClB,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAChC;QAED,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QACnC,GAAG,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,eAAe;;QAClB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAA,CAAC,IAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,MAAM,CAAA,mCAAI,CAAC,EAAE,EAAE,CAAC,EAAE;gBAClD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;aAC/B;SACJ;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,uBAAuB,GAAG,KAAK;;QAC1C,IAAI,CAAC,uBAAuB,EAAE;YAC1B,MAAA,IAAI,CAAC,oBAAoB,0CAAE,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,eAAe,EAAE,CAAC;SAC1B;QAED,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Constants } from \"./constants\";\r\nimport type { ThinEngine } from \"./thinEngine\";\r\n\r\n/**\r\n * An interface enforcing the renderTarget accessor to used by render target textures.\r\n */\r\nexport interface IRenderTargetTexture {\r\n /**\r\n * Entry point to access the wrapper on a texture.\r\n */\r\n renderTarget: Nullable<RenderTargetWrapper>;\r\n}\r\n\r\n/**\r\n * Wrapper around a render target (either single or multi textures)\r\n */\r\nexport class RenderTargetWrapper {\r\n protected _engine: ThinEngine;\r\n private _size: TextureSize;\r\n private _isCube: boolean;\r\n private _isMulti: boolean;\r\n private _textures: Nullable<InternalTexture[]> = null;\r\n /** @internal */\r\n public _samples = 1;\r\n\r\n /** @internal */\r\n public _attachments: Nullable<number[]> = null;\r\n /** @internal */\r\n public _generateStencilBuffer: boolean = false;\r\n /** @internal */\r\n public _generateDepthBuffer: boolean = false;\r\n\r\n /** @internal */\r\n public _depthStencilTexture: Nullable<InternalTexture>;\r\n /** @internal */\r\n public _depthStencilTextureWithStencil: boolean = false;\r\n\r\n /**\r\n * Gets the depth/stencil texture (if created by a createDepthStencilTexture() call)\r\n */\r\n public get depthStencilTexture() {\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Indicates if the depth/stencil texture has a stencil aspect\r\n */\r\n public get depthStencilTextureWithStencil() {\r\n return this._depthStencilTextureWithStencil;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a cube texture or if false a 2d texture\r\n */\r\n public get isCube(): boolean {\r\n return this._isCube;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or multi target render wrapper\r\n */\r\n public get isMulti(): boolean {\r\n return this._isMulti;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or an array of textures\r\n */\r\n public get is2DArray(): boolean {\r\n return this.layers > 0;\r\n }\r\n\r\n /**\r\n * Gets the size of the render target wrapper (used for cubes, as width=height in this case)\r\n */\r\n public get size(): number {\r\n return this.width;\r\n }\r\n\r\n /**\r\n * Gets the width of the render target wrapper\r\n */\r\n public get width(): number {\r\n return (<{ width: number; height: number }>this._size).width || <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the height of the render target wrapper\r\n */\r\n public get height(): number {\r\n return (<{ width: number; height: number }>this._size).height || <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the number of layers of the render target wrapper (only used if is2DArray is true)\r\n */\r\n public get layers(): number {\r\n return (<{ width: number; height: number; layers?: number }>this._size).layers || 0;\r\n }\r\n\r\n /**\r\n * Gets the render texture. If this is a multi render target, gets the first texture\r\n */\r\n public get texture(): Nullable<InternalTexture> {\r\n return this._textures?.[0] ?? null;\r\n }\r\n\r\n /**\r\n * Gets the list of render textures. If we are not in a multi render target, the list will be null (use the texture getter instead)\r\n */\r\n public get textures(): Nullable<InternalTexture[]> {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the sample count of the render target\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n /**\r\n * Sets the sample count of the render target\r\n * @param value sample count\r\n * @param initializeBuffers If set to true, the engine will make an initializing call to drawBuffers (only used when isMulti=true).\r\n * @param force true to force calling the update sample count engine function even if the current sample count is equal to value\r\n * @returns the sample count that has been set\r\n */\r\n public setSamples(value: number, initializeBuffers = true, force = false): number {\r\n if (this.samples === value && !force) {\r\n return value;\r\n }\r\n\r\n const result = this._isMulti\r\n ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, value, initializeBuffers)\r\n : this._engine.updateRenderTargetTextureSampleCount(this, value);\r\n this._samples = value;\r\n return result;\r\n }\r\n\r\n /**\r\n * Initializes the render target wrapper\r\n * @param isMulti true if the wrapper is a multi render target\r\n * @param isCube true if the wrapper should render to a cube texture\r\n * @param size size of the render target (width/height/layers)\r\n * @param engine engine used to create the render target\r\n */\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: ThinEngine) {\r\n this._isMulti = isMulti;\r\n this._isCube = isCube;\r\n this._size = size;\r\n this._engine = engine;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /**\r\n * Sets the render target texture(s)\r\n * @param textures texture(s) to set\r\n */\r\n public setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void {\r\n if (Array.isArray(textures)) {\r\n this._textures = textures;\r\n } else if (textures) {\r\n this._textures = [textures];\r\n } else {\r\n this._textures = null;\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture the texture to set\r\n * @param index the index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true): void {\r\n if (!this._textures) {\r\n this._textures = [];\r\n }\r\n if (this._textures[index] && disposePrevious) {\r\n this._textures[index].dispose();\r\n }\r\n\r\n this._textures[index] = texture;\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil true if the stencil aspect should also be created\r\n * @param samples sample count to use when creating the texture\r\n * @param format format of the depth texture\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT\r\n ): InternalTexture {\r\n this._depthStencilTexture?.dispose();\r\n\r\n this._depthStencilTextureWithStencil = generateStencil;\r\n this._depthStencilTexture = this._engine.createDepthStencilTexture(\r\n this._size,\r\n {\r\n bilinearFiltering,\r\n comparisonFunction,\r\n generateStencil,\r\n isCube: this._isCube,\r\n samples,\r\n depthTextureFormat: format,\r\n },\r\n this\r\n );\r\n\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @internal\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: RenderTargetWrapper): void {\r\n if (this._depthStencilTexture) {\r\n if (renderTarget._depthStencilTexture) {\r\n renderTarget._depthStencilTexture.dispose();\r\n }\r\n\r\n renderTarget._depthStencilTexture = this._depthStencilTexture;\r\n this._depthStencilTexture.incrementReferences();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture): void {\r\n if (this.texture) {\r\n this.texture._swapAndDie(target);\r\n }\r\n this._textures = null;\r\n this.dispose(true);\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._isMulti) {\r\n const textureArray = this.textures;\r\n if (textureArray && textureArray.length > 0) {\r\n let generateDepthTexture = false;\r\n let textureCount = textureArray.length;\r\n\r\n const lastTextureSource = textureArray[textureArray.length - 1]._source;\r\n if (lastTextureSource === InternalTextureSource.Depth || lastTextureSource === InternalTextureSource.DepthStencil) {\r\n generateDepthTexture = true;\r\n textureCount--;\r\n }\r\n\r\n const samplingModes: number[] = [];\r\n const types: number[] = [];\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n\r\n samplingModes.push(texture.samplingMode);\r\n types.push(texture.type);\r\n }\r\n\r\n const optionsMRT = {\r\n samplingModes,\r\n generateMipMaps: textureArray[0].generateMipMaps,\r\n generateDepthBuffer: this._generateDepthBuffer,\r\n generateStencilBuffer: this._generateStencilBuffer,\r\n generateDepthTexture,\r\n types,\r\n textureCount,\r\n };\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n };\r\n\r\n rtw = this._engine.createMultipleRenderTarget(size, optionsMRT);\r\n }\r\n } else {\r\n const options: RenderTargetCreationOptions = {};\r\n\r\n options.generateDepthBuffer = this._generateDepthBuffer;\r\n options.generateMipMaps = this.texture?.generateMipMaps ?? false;\r\n options.generateStencilBuffer = this._generateStencilBuffer;\r\n options.samplingMode = this.texture?.samplingMode;\r\n options.type = this.texture?.type;\r\n options.format = this.texture?.format;\r\n\r\n if (this.isCube) {\r\n rtw = this._engine.createRenderTargetCubeTexture(this.width, options);\r\n } else {\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray ? this.texture?.depth : undefined,\r\n };\r\n\r\n rtw = this._engine.createRenderTargetTexture(size, options);\r\n }\r\n rtw.texture!.isReady = true;\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: RenderTargetWrapper): void {\r\n if (this._textures && target._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i]._swapAndDie(target._textures[i], false);\r\n target._textures[i].isReady = true;\r\n }\r\n }\r\n if (this._depthStencilTexture && target._depthStencilTexture) {\r\n this._depthStencilTexture._swapAndDie(target._depthStencilTexture);\r\n target._depthStencilTexture.isReady = true;\r\n }\r\n\r\n this._textures = null;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const rtw = this._cloneRenderTargetWrapper();\r\n if (!rtw) {\r\n return;\r\n }\r\n\r\n if (this._depthStencilTexture) {\r\n const samplingMode = this._depthStencilTexture.samplingMode;\r\n const bilinear =\r\n samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST;\r\n rtw.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, bilinear, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples);\r\n }\r\n\r\n if (this.samples > 1) {\r\n rtw.setSamples(this.samples);\r\n }\r\n\r\n rtw._swapRenderTargetWrapper(this);\r\n rtw.dispose();\r\n }\r\n\r\n /**\r\n * Releases the internal render textures\r\n */\r\n public releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures?.length ?? 0; ++i) {\r\n this._textures[i].dispose();\r\n }\r\n }\r\n this._textures = null;\r\n }\r\n\r\n /**\r\n * Disposes the whole render target wrapper\r\n * @param disposeOnlyFramebuffers true if only the frame buffers should be released (used for the WebGL engine). If false, all the textures will also be released\r\n */\r\n public dispose(disposeOnlyFramebuffers = false): void {\r\n if (!disposeOnlyFramebuffers) {\r\n this._depthStencilTexture?.dispose();\r\n this._depthStencilTexture = null;\r\n this.releaseTextures();\r\n }\r\n\r\n this._engine._releaseRenderTargetWrapper(this);\r\n }\r\n}\r\n"]}
@@ -401,13 +401,13 @@ export class ThinEngine {
401
401
  */
402
402
  // Not mixed with Version for tooling purpose.
403
403
  static get NpmPackage() {
404
- return "babylonjs@5.28.0";
404
+ return "babylonjs@5.29.0";
405
405
  }
406
406
  /**
407
407
  * Returns the current version of the framework
408
408
  */
409
409
  static get Version() {
410
- return "5.28.0";
410
+ return "5.29.0";
411
411
  }
412
412
  /**
413
413
  * Returns a string describing the current engine