@babylonjs/core 5.43.2 → 5.45.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 (43) hide show
  1. package/Audio/sound.d.ts +0 -1
  2. package/Audio/sound.js +10 -10
  3. package/Audio/sound.js.map +1 -1
  4. package/Cameras/Inputs/BaseCameraPointersInput.js +7 -0
  5. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  6. package/Culling/ray.js +8 -2
  7. package/Culling/ray.js.map +1 -1
  8. package/Engines/WebGPU/Extensions/engine.renderTarget.js +1 -1
  9. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  10. package/Engines/engine.js +11 -2
  11. package/Engines/engine.js.map +1 -1
  12. package/Engines/thinEngine.js +3 -3
  13. package/Engines/thinEngine.js.map +1 -1
  14. package/Inputs/scene.inputManager.d.ts +1 -0
  15. package/Inputs/scene.inputManager.js +8 -1
  16. package/Inputs/scene.inputManager.js.map +1 -1
  17. package/Loading/Plugins/babylonFileLoader.js +3 -0
  18. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  19. package/Materials/Textures/index.d.ts +1 -0
  20. package/Materials/Textures/index.js +1 -0
  21. package/Materials/Textures/index.js.map +1 -1
  22. package/Materials/Textures/ktx2decoderTypes.d.ts +215 -0
  23. package/Materials/Textures/ktx2decoderTypes.js +35 -0
  24. package/Materials/Textures/ktx2decoderTypes.js.map +1 -0
  25. package/Materials/Textures/texture.d.ts +1 -1
  26. package/Materials/Textures/texture.js.map +1 -1
  27. package/Maths/math.vector.js +155 -120
  28. package/Maths/math.vector.js.map +1 -1
  29. package/Meshes/mesh.js +9 -0
  30. package/Meshes/mesh.js.map +1 -1
  31. package/Meshes/transformNode.d.ts +9 -1
  32. package/Meshes/transformNode.js +22 -7
  33. package/Meshes/transformNode.js.map +1 -1
  34. package/Misc/khronosTextureContainer2.d.ts +68 -2
  35. package/Misc/khronosTextureContainer2.js +149 -1
  36. package/Misc/khronosTextureContainer2.js.map +1 -1
  37. package/Morph/morphTargetManager.d.ts +2 -0
  38. package/Morph/morphTargetManager.js +8 -0
  39. package/Morph/morphTargetManager.js.map +1 -1
  40. package/assetContainer.d.ts +16 -1
  41. package/assetContainer.js +198 -41
  42. package/assetContainer.js.map +1 -1
  43. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"BaseCameraPointersInput.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Cameras/Inputs/BaseCameraPointersInput.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D;;;;GAIG;AACH,MAAM,OAAgB,uBAAuB;IAA7C;QAoBY,yBAAoB,GAAW,CAAC,CAAC,CAAC;QAG1C;;WAEG;QAEI,YAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAiU/B,CAAC;IA/TG;;;OAGG;IACI,aAAa,CAAC,gBAA0B;QAC3C,8CAA8C;QAC9C,gBAAgB,GAAG,KAAK,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC;QACrE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QACzC,IAAI,4BAA4B,GAAG,CAAC,CAAC;QACrC,IAAI,6BAA6B,GAA2B,IAAI,CAAC;QAEjE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAEpB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,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,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;aAC1F;YAED,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,yBAAyB,CAAC;IACrC,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,6DAA6D;IACtD,WAAW,CAAC,IAAY,IAAG,CAAC;IAEnC;;;;;;OAMG;IACH,6DAA6D;IACtD,OAAO,CAAC,KAA6B,EAAE,OAAe,EAAE,OAAe,IAAS,CAAC;IAExF;;;;;;;;;OASG;IACH,6DAA6D;IACtD,YAAY,CACf,OAA+B,EAC/B,OAA+B,EAC/B,4BAAoC,EACpC,oBAA4B,EAC5B,6BAAqD,EACrD,qBAA6C,IACxC,CAAC;IAEV;;;;OAIG;IACI,aAAa,CAAC,GAAiB;QAClC,GAAG,CAAC,cAAc,EAAE,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,6DAA6D;IACtD,YAAY,CAAC,GAAkB,IAAS,CAAC;IAEhD;;;;;OAKG;IACH,6DAA6D;IACtD,UAAU,CAAC,GAAkB,IAAS,CAAC;IAE9C;;;OAGG;IACI,WAAW,KAAU,CAAC;CAOhC;AAjUG;IADC,SAAS,EAAE;wDACe","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Nullable } from \"../../types\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { EventState, Observer } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport type { PointerInfo, PointerTouch } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\n\r\n/**\r\n * Base class for Camera Pointer Inputs.\r\n * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts\r\n * for example usage.\r\n */\r\nexport abstract class BaseCameraPointersInput implements ICameraInput<Camera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public abstract camera: Camera;\r\n\r\n /**\r\n * Whether keyboard modifier keys are pressed at time of last mouse event.\r\n */\r\n protected _altKey: boolean;\r\n protected _ctrlKey: boolean;\r\n protected _metaKey: boolean;\r\n protected _shiftKey: boolean;\r\n\r\n /**\r\n * Which mouse buttons were pressed at time of last mouse event.\r\n * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n */\r\n protected _buttonsPressed: number;\r\n\r\n private _currentActiveButton: number = -1;\r\n private _contextMenuBind: EventListener;\r\n\r\n /**\r\n * Defines the buttons associated with the input to handle camera move.\r\n */\r\n @serialize()\r\n public buttons = [0, 1, 2];\r\n\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public attachControl(noPreventDefault?: boolean): void {\r\n // eslint-disable-next-line prefer-rest-params\r\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n let previousPinchSquaredDistance = 0;\r\n let previousMultiTouchPanPosition: Nullable<PointerTouch> = null;\r\n\r\n this._pointA = null;\r\n this._pointB = null;\r\n\r\n this._altKey = false;\r\n this._ctrlKey = false;\r\n this._metaKey = false;\r\n this._shiftKey = false;\r\n this._buttonsPressed = 0;\r\n\r\n this._pointerInput = (p) => {\r\n const evt = <IPointerEvent>p.event;\r\n const isTouch = evt.pointerType === \"touch\";\r\n\r\n if (engine.isInVRExclusivePointerMode) {\r\n return;\r\n }\r\n\r\n if (p.type !== PointerEventTypes.POINTERMOVE && this.buttons.indexOf(evt.button) === -1) {\r\n return;\r\n }\r\n\r\n const srcElement = <HTMLElement>evt.target;\r\n\r\n this._altKey = evt.altKey;\r\n this._ctrlKey = evt.ctrlKey;\r\n this._metaKey = evt.metaKey;\r\n this._shiftKey = evt.shiftKey;\r\n this._buttonsPressed = evt.buttons;\r\n\r\n if (engine.isPointerLock) {\r\n const offsetX = evt.movementX;\r\n const offsetY = evt.movementY;\r\n\r\n this.onTouch(null, offsetX, offsetY);\r\n this._pointA = null;\r\n this._pointB = null;\r\n } else if (p.type === PointerEventTypes.POINTERDOWN && (this._currentActiveButton === -1 || isTouch)) {\r\n try {\r\n srcElement?.setPointerCapture(evt.pointerId);\r\n } catch (e) {\r\n //Nothing to do with the error. Execution will continue.\r\n }\r\n\r\n if (this._pointA === null) {\r\n this._pointA = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n pointerId: evt.pointerId,\r\n type: evt.pointerType,\r\n };\r\n } else if (this._pointB === null) {\r\n this._pointB = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n pointerId: evt.pointerId,\r\n type: evt.pointerType,\r\n };\r\n }\r\n\r\n if (this._currentActiveButton === -1 && !isTouch) {\r\n this._currentActiveButton = evt.button;\r\n }\r\n this.onButtonDown(evt);\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n element && element.focus();\r\n }\r\n } else if (p.type === PointerEventTypes.POINTERDOUBLETAP) {\r\n this.onDoubleTap(evt.pointerType);\r\n } else if (p.type === PointerEventTypes.POINTERUP && (this._currentActiveButton === evt.button || isTouch)) {\r\n try {\r\n srcElement?.releasePointerCapture(evt.pointerId);\r\n } catch (e) {\r\n //Nothing to do with the error.\r\n }\r\n\r\n if (!isTouch) {\r\n this._pointB = null; // Mouse and pen are mono pointer\r\n }\r\n\r\n //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,\r\n //but emptying completely pointers collection is required to fix a bug on iPhone :\r\n //when changing orientation while pinching camera,\r\n //one pointer stay pressed forever if we don't release all pointers\r\n //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected\r\n if (engine._badOS) {\r\n this._pointA = this._pointB = null;\r\n } else {\r\n //only remove the impacted pointer in case of multitouch allowing on most\r\n //platforms switching from rotate to zoom and pan seamlessly.\r\n if (this._pointB && this._pointA && this._pointA.pointerId == evt.pointerId) {\r\n this._pointA = this._pointB;\r\n this._pointB = null;\r\n } else if (this._pointA && this._pointB && this._pointB.pointerId == evt.pointerId) {\r\n this._pointB = null;\r\n } else {\r\n this._pointA = this._pointB = null;\r\n }\r\n }\r\n\r\n if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {\r\n // Previous pinch data is populated but a button has been lifted\r\n // so pinch has ended.\r\n this.onMultiTouch(\r\n this._pointA,\r\n this._pointB,\r\n previousPinchSquaredDistance,\r\n 0, // pinchSquaredDistance\r\n previousMultiTouchPanPosition,\r\n null // multiTouchPanPosition\r\n );\r\n previousPinchSquaredDistance = 0;\r\n previousMultiTouchPanPosition = null;\r\n }\r\n\r\n this._currentActiveButton = -1;\r\n this.onButtonUp(evt);\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n } else if (p.type === PointerEventTypes.POINTERMOVE) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n // One button down\r\n if (this._pointA && this._pointB === null) {\r\n const offsetX = evt.clientX - this._pointA.x;\r\n const offsetY = evt.clientY - this._pointA.y;\r\n this.onTouch(this._pointA, offsetX, offsetY);\r\n\r\n this._pointA.x = evt.clientX;\r\n this._pointA.y = evt.clientY;\r\n }\r\n // Two buttons down: pinch\r\n else if (this._pointA && this._pointB) {\r\n const ed = this._pointA.pointerId === evt.pointerId ? this._pointA : this._pointB;\r\n ed.x = evt.clientX;\r\n ed.y = evt.clientY;\r\n const distX = this._pointA.x - this._pointB.x;\r\n const distY = this._pointA.y - this._pointB.y;\r\n const pinchSquaredDistance = distX * distX + distY * distY;\r\n const multiTouchPanPosition = {\r\n x: (this._pointA.x + this._pointB.x) / 2,\r\n y: (this._pointA.y + this._pointB.y) / 2,\r\n pointerId: evt.pointerId,\r\n type: p.type,\r\n };\r\n\r\n this.onMultiTouch(this._pointA, this._pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);\r\n\r\n previousMultiTouchPanPosition = multiTouchPanPosition;\r\n previousPinchSquaredDistance = pinchSquaredDistance;\r\n }\r\n }\r\n };\r\n\r\n this._observer = this.camera\r\n .getScene()\r\n ._inputManager._addCameraPointerObserver(\r\n this._pointerInput,\r\n PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE | PointerEventTypes.POINTERDOUBLETAP\r\n );\r\n\r\n this._onLostFocus = () => {\r\n this._pointA = this._pointB = null;\r\n previousPinchSquaredDistance = 0;\r\n previousMultiTouchPanPosition = null;\r\n this.onLostFocus();\r\n };\r\n\r\n this._contextMenuBind = this.onContextMenu.bind(this);\r\n\r\n element && element.addEventListener(\"contextmenu\", this._contextMenuBind, false);\r\n\r\n const hostWindow = this.camera.getScene().getEngine().getHostWindow();\r\n\r\n if (hostWindow) {\r\n Tools.RegisterTopRootEvents(hostWindow, [{ name: \"blur\", handler: this._onLostFocus }]);\r\n }\r\n }\r\n\r\n /**\r\n * Detach the current controls from the specified dom element.\r\n */\r\n public detachControl(): void {\r\n if (this._onLostFocus) {\r\n const hostWindow = this.camera.getScene().getEngine().getHostWindow();\r\n if (hostWindow) {\r\n Tools.UnregisterTopRootEvents(hostWindow, [{ name: \"blur\", handler: this._onLostFocus }]);\r\n }\r\n }\r\n\r\n if (this._observer) {\r\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\r\n this._observer = null;\r\n\r\n if (this._contextMenuBind) {\r\n const inputElement = this.camera.getScene().getEngine().getInputElement();\r\n inputElement && inputElement.removeEventListener(\"contextmenu\", this._contextMenuBind);\r\n }\r\n\r\n this._onLostFocus = null;\r\n }\r\n\r\n this._altKey = false;\r\n this._ctrlKey = false;\r\n this._metaKey = false;\r\n this._shiftKey = false;\r\n this._buttonsPressed = 0;\r\n this._currentActiveButton = -1;\r\n }\r\n\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"BaseCameraPointersInput\";\r\n }\r\n\r\n /**\r\n * Get the friendly name associated with the input class.\r\n * @returns the input friendly name\r\n */\r\n public getSimpleName(): string {\r\n return \"pointers\";\r\n }\r\n\r\n /**\r\n * Called on pointer POINTERDOUBLETAP event.\r\n * Override this method to provide functionality on POINTERDOUBLETAP event.\r\n * @param type\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onDoubleTap(type: string) {}\r\n\r\n /**\r\n * Called on pointer POINTERMOVE event if only a single touch is active.\r\n * Override this method to provide functionality.\r\n * @param point\r\n * @param offsetX\r\n * @param offsetY\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void {}\r\n\r\n /**\r\n * Called on pointer POINTERMOVE event if multiple touches are active.\r\n * Override this method to provide functionality.\r\n * @param _pointA\r\n * @param _pointB\r\n * @param previousPinchSquaredDistance\r\n * @param pinchSquaredDistance\r\n * @param previousMultiTouchPanPosition\r\n * @param multiTouchPanPosition\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onMultiTouch(\r\n _pointA: Nullable<PointerTouch>,\r\n _pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {}\r\n\r\n /**\r\n * Called on JS contextmenu event.\r\n * Override this method to provide functionality.\r\n * @param evt\r\n */\r\n public onContextMenu(evt: PointerEvent): void {\r\n evt.preventDefault();\r\n }\r\n\r\n /**\r\n * Called each time a new POINTERDOWN event occurs. Ie, for each button\r\n * press.\r\n * Override this method to provide functionality.\r\n * @param evt\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onButtonDown(evt: IPointerEvent): void {}\r\n\r\n /**\r\n * Called each time a new POINTERUP event occurs. Ie, for each button\r\n * release.\r\n * Override this method to provide functionality.\r\n * @param evt\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onButtonUp(evt: IPointerEvent): void {}\r\n\r\n /**\r\n * Called when window becomes inactive.\r\n * Override this method to provide functionality.\r\n */\r\n public onLostFocus(): void {}\r\n\r\n private _pointerInput: (p: PointerInfo, s: EventState) => void;\r\n private _observer: Nullable<Observer<PointerInfo>>;\r\n private _onLostFocus: Nullable<(e: FocusEvent) => any>;\r\n private _pointA: Nullable<PointerTouch>;\r\n private _pointB: Nullable<PointerTouch>;\r\n}\r\n"]}
1
+ {"version":3,"file":"BaseCameraPointersInput.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Cameras/Inputs/BaseCameraPointersInput.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D;;;;GAIG;AACH,MAAM,OAAgB,uBAAuB;IAA7C;QAoBY,yBAAoB,GAAW,CAAC,CAAC,CAAC;QAG1C;;WAEG;QAEI,YAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAqU/B,CAAC;IAnUG;;;OAGG;IACI,aAAa,CAAC,gBA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;IACI,YAAY;QACf,OAAO,yBAAyB,CAAC;IACrC,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,6DAA6D;IACtD,WAAW,CAAC,IAAY,IAAG,CAAC;IAEnC;;;;;;OAMG;IACH,6DAA6D;IACtD,OAAO,CAAC,KAA6B,EAAE,OAAe,EAAE,OAAe,IAAS,CAAC;IAExF;;;;;;;;;OASG;IACH,6DAA6D;IACtD,YAAY,CACf,OAA+B,EAC/B,OAA+B,EAC/B,4BAAoC,EACpC,oBAA4B,EAC5B,6BAAqD,EACrD,qBAA6C,IACxC,CAAC;IAEV;;;;OAIG;IACI,aAAa,CAAC,GAAiB;QAClC,GAAG,CAAC,cAAc,EAAE,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,6DAA6D;IACtD,YAAY,CAAC,GAAkB,IAAS,CAAC;IAEhD;;;;;OAKG;IACH,6DAA6D;IACtD,UAAU,CAAC,GAAkB,IAAS,CAAC;IAE9C;;;OAGG;IACI,WAAW,KAAU,CAAC;CAOhC;AArUG;IADC,SAAS,EAAE;wDACe","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Nullable } from \"../../types\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { EventState, Observer } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport type { PointerInfo, PointerTouch } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\n\r\n/**\r\n * Base class for Camera Pointer Inputs.\r\n * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts\r\n * for example usage.\r\n */\r\nexport abstract class BaseCameraPointersInput implements ICameraInput<Camera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public abstract camera: Camera;\r\n\r\n /**\r\n * Whether keyboard modifier keys are pressed at time of last mouse event.\r\n */\r\n protected _altKey: boolean;\r\n protected _ctrlKey: boolean;\r\n protected _metaKey: boolean;\r\n protected _shiftKey: boolean;\r\n\r\n /**\r\n * Which mouse buttons were pressed at time of last mouse event.\r\n * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n */\r\n protected _buttonsPressed: number;\r\n\r\n private _currentActiveButton: number = -1;\r\n private _contextMenuBind: EventListener;\r\n\r\n /**\r\n * Defines the buttons associated with the input to handle camera move.\r\n */\r\n @serialize()\r\n public buttons = [0, 1, 2];\r\n\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public attachControl(noPreventDefault?: boolean): void {\r\n // eslint-disable-next-line prefer-rest-params\r\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n let previousPinchSquaredDistance = 0;\r\n let previousMultiTouchPanPosition: Nullable<PointerTouch> = null;\r\n\r\n this._pointA = null;\r\n this._pointB = null;\r\n\r\n this._altKey = false;\r\n this._ctrlKey = false;\r\n this._metaKey = false;\r\n this._shiftKey = false;\r\n this._buttonsPressed = 0;\r\n\r\n this._pointerInput = (p) => {\r\n const evt = <IPointerEvent>p.event;\r\n const isTouch = evt.pointerType === \"touch\";\r\n\r\n if (engine.isInVRExclusivePointerMode) {\r\n return;\r\n }\r\n\r\n if (p.type !== PointerEventTypes.POINTERMOVE && this.buttons.indexOf(evt.button) === -1) {\r\n return;\r\n }\r\n\r\n const srcElement = <HTMLElement>evt.target;\r\n\r\n this._altKey = evt.altKey;\r\n this._ctrlKey = evt.ctrlKey;\r\n this._metaKey = evt.metaKey;\r\n this._shiftKey = evt.shiftKey;\r\n this._buttonsPressed = evt.buttons;\r\n\r\n if (engine.isPointerLock) {\r\n const offsetX = evt.movementX;\r\n const offsetY = evt.movementY;\r\n\r\n this.onTouch(null, offsetX, offsetY);\r\n this._pointA = null;\r\n this._pointB = null;\r\n } else if (p.type !== PointerEventTypes.POINTERDOWN && isTouch && this._pointA?.pointerId !== evt.pointerId && this._pointB?.pointerId !== evt.pointerId) {\r\n return; // If we get a non-down event for a touch that we're not tracking, ignore it\r\n } else if (p.type === PointerEventTypes.POINTERDOWN && (this._currentActiveButton === -1 || isTouch)) {\r\n try {\r\n srcElement?.setPointerCapture(evt.pointerId);\r\n } catch (e) {\r\n //Nothing to do with the error. Execution will continue.\r\n }\r\n\r\n if (this._pointA === null) {\r\n this._pointA = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n pointerId: evt.pointerId,\r\n type: evt.pointerType,\r\n };\r\n } else if (this._pointB === null) {\r\n this._pointB = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n pointerId: evt.pointerId,\r\n type: evt.pointerType,\r\n };\r\n } else {\r\n return; // We are already tracking two pointers so ignore this one\r\n }\r\n\r\n if (this._currentActiveButton === -1 && !isTouch) {\r\n this._currentActiveButton = evt.button;\r\n }\r\n this.onButtonDown(evt);\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n element && element.focus();\r\n }\r\n } else if (p.type === PointerEventTypes.POINTERDOUBLETAP) {\r\n this.onDoubleTap(evt.pointerType);\r\n } else if (p.type === PointerEventTypes.POINTERUP && (this._currentActiveButton === evt.button || isTouch)) {\r\n try {\r\n srcElement?.releasePointerCapture(evt.pointerId);\r\n } catch (e) {\r\n //Nothing to do with the error.\r\n }\r\n\r\n if (!isTouch) {\r\n this._pointB = null; // Mouse and pen are mono pointer\r\n }\r\n\r\n //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,\r\n //but emptying completely pointers collection is required to fix a bug on iPhone :\r\n //when changing orientation while pinching camera,\r\n //one pointer stay pressed forever if we don't release all pointers\r\n //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected\r\n if (engine._badOS) {\r\n this._pointA = this._pointB = null;\r\n } else {\r\n //only remove the impacted pointer in case of multitouch allowing on most\r\n //platforms switching from rotate to zoom and pan seamlessly.\r\n if (this._pointB && this._pointA && this._pointA.pointerId == evt.pointerId) {\r\n this._pointA = this._pointB;\r\n this._pointB = null;\r\n } else if (this._pointA && this._pointB && this._pointB.pointerId == evt.pointerId) {\r\n this._pointB = null;\r\n } else {\r\n this._pointA = this._pointB = null;\r\n }\r\n }\r\n\r\n if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {\r\n // Previous pinch data is populated but a button has been lifted\r\n // so pinch has ended.\r\n this.onMultiTouch(\r\n this._pointA,\r\n this._pointB,\r\n previousPinchSquaredDistance,\r\n 0, // pinchSquaredDistance\r\n previousMultiTouchPanPosition,\r\n null // multiTouchPanPosition\r\n );\r\n previousPinchSquaredDistance = 0;\r\n previousMultiTouchPanPosition = null;\r\n }\r\n\r\n this._currentActiveButton = -1;\r\n this.onButtonUp(evt);\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n } else if (p.type === PointerEventTypes.POINTERMOVE) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n // One button down\r\n if (this._pointA && this._pointB === null) {\r\n const offsetX = evt.clientX - this._pointA.x;\r\n const offsetY = evt.clientY - this._pointA.y;\r\n this.onTouch(this._pointA, offsetX, offsetY);\r\n\r\n this._pointA.x = evt.clientX;\r\n this._pointA.y = evt.clientY;\r\n }\r\n // Two buttons down: pinch\r\n else if (this._pointA && this._pointB) {\r\n const ed = this._pointA.pointerId === evt.pointerId ? this._pointA : this._pointB;\r\n ed.x = evt.clientX;\r\n ed.y = evt.clientY;\r\n const distX = this._pointA.x - this._pointB.x;\r\n const distY = this._pointA.y - this._pointB.y;\r\n const pinchSquaredDistance = distX * distX + distY * distY;\r\n const multiTouchPanPosition = {\r\n x: (this._pointA.x + this._pointB.x) / 2,\r\n y: (this._pointA.y + this._pointB.y) / 2,\r\n pointerId: evt.pointerId,\r\n type: p.type,\r\n };\r\n\r\n this.onMultiTouch(this._pointA, this._pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);\r\n\r\n previousMultiTouchPanPosition = multiTouchPanPosition;\r\n previousPinchSquaredDistance = pinchSquaredDistance;\r\n }\r\n }\r\n };\r\n\r\n this._observer = this.camera\r\n .getScene()\r\n ._inputManager._addCameraPointerObserver(\r\n this._pointerInput,\r\n PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE | PointerEventTypes.POINTERDOUBLETAP\r\n );\r\n\r\n this._onLostFocus = () => {\r\n this._pointA = this._pointB = null;\r\n previousPinchSquaredDistance = 0;\r\n previousMultiTouchPanPosition = null;\r\n this.onLostFocus();\r\n };\r\n\r\n this._contextMenuBind = this.onContextMenu.bind(this);\r\n\r\n element && element.addEventListener(\"contextmenu\", this._contextMenuBind, false);\r\n\r\n const hostWindow = this.camera.getScene().getEngine().getHostWindow();\r\n\r\n if (hostWindow) {\r\n Tools.RegisterTopRootEvents(hostWindow, [{ name: \"blur\", handler: this._onLostFocus }]);\r\n }\r\n }\r\n\r\n /**\r\n * Detach the current controls from the specified dom element.\r\n */\r\n public detachControl(): void {\r\n if (this._onLostFocus) {\r\n const hostWindow = this.camera.getScene().getEngine().getHostWindow();\r\n if (hostWindow) {\r\n Tools.UnregisterTopRootEvents(hostWindow, [{ name: \"blur\", handler: this._onLostFocus }]);\r\n }\r\n }\r\n\r\n if (this._observer) {\r\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\r\n this._observer = null;\r\n\r\n if (this._contextMenuBind) {\r\n const inputElement = this.camera.getScene().getEngine().getInputElement();\r\n inputElement && inputElement.removeEventListener(\"contextmenu\", this._contextMenuBind);\r\n }\r\n\r\n this._onLostFocus = null;\r\n }\r\n\r\n this._altKey = false;\r\n this._ctrlKey = false;\r\n this._metaKey = false;\r\n this._shiftKey = false;\r\n this._buttonsPressed = 0;\r\n this._currentActiveButton = -1;\r\n }\r\n\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"BaseCameraPointersInput\";\r\n }\r\n\r\n /**\r\n * Get the friendly name associated with the input class.\r\n * @returns the input friendly name\r\n */\r\n public getSimpleName(): string {\r\n return \"pointers\";\r\n }\r\n\r\n /**\r\n * Called on pointer POINTERDOUBLETAP event.\r\n * Override this method to provide functionality on POINTERDOUBLETAP event.\r\n * @param type\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onDoubleTap(type: string) {}\r\n\r\n /**\r\n * Called on pointer POINTERMOVE event if only a single touch is active.\r\n * Override this method to provide functionality.\r\n * @param point\r\n * @param offsetX\r\n * @param offsetY\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void {}\r\n\r\n /**\r\n * Called on pointer POINTERMOVE event if multiple touches are active.\r\n * Override this method to provide functionality.\r\n * @param _pointA\r\n * @param _pointB\r\n * @param previousPinchSquaredDistance\r\n * @param pinchSquaredDistance\r\n * @param previousMultiTouchPanPosition\r\n * @param multiTouchPanPosition\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onMultiTouch(\r\n _pointA: Nullable<PointerTouch>,\r\n _pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {}\r\n\r\n /**\r\n * Called on JS contextmenu event.\r\n * Override this method to provide functionality.\r\n * @param evt\r\n */\r\n public onContextMenu(evt: PointerEvent): void {\r\n evt.preventDefault();\r\n }\r\n\r\n /**\r\n * Called each time a new POINTERDOWN event occurs. Ie, for each button\r\n * press.\r\n * Override this method to provide functionality.\r\n * @param evt\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onButtonDown(evt: IPointerEvent): void {}\r\n\r\n /**\r\n * Called each time a new POINTERUP event occurs. Ie, for each button\r\n * release.\r\n * Override this method to provide functionality.\r\n * @param evt\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public onButtonUp(evt: IPointerEvent): void {}\r\n\r\n /**\r\n * Called when window becomes inactive.\r\n * Override this method to provide functionality.\r\n */\r\n public onLostFocus(): void {}\r\n\r\n private _pointerInput: (p: PointerInfo, s: EventState) => void;\r\n private _observer: Nullable<Observer<PointerInfo>>;\r\n private _onLostFocus: Nullable<(e: FocusEvent) => any>;\r\n private _pointA: Nullable<PointerTouch>;\r\n private _pointB: Nullable<PointerTouch>;\r\n}\r\n"]}
package/Culling/ray.js CHANGED
@@ -593,6 +593,8 @@ Scene.prototype._internalPickForMesh = function (pickingInfo, rayFunction, mesh,
593
593
  };
594
594
  Scene.prototype._internalPick = function (rayFunction, predicate, fastCheck, onlyBoundingInfo, trianglePredicate) {
595
595
  let pickingInfo = null;
596
+ const computeWorldMatrixForCamera = !!(this.activeCameras && this.activeCameras.length > 1 && this.cameraToUseForPointers !== this.activeCamera);
597
+ const currentCamera = this.cameraToUseForPointers || this.activeCamera;
596
598
  for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
597
599
  const mesh = this.meshes[meshIndex];
598
600
  if (predicate) {
@@ -603,7 +605,8 @@ Scene.prototype._internalPick = function (rayFunction, predicate, fastCheck, onl
603
605
  else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
604
606
  continue;
605
607
  }
606
- const world = mesh.getWorldMatrix();
608
+ const forceCompute = computeWorldMatrixForCamera && mesh.isWorldMatrixCameraDependent();
609
+ const world = mesh.computeWorldMatrix(forceCompute, currentCamera);
607
610
  if (mesh.hasThinInstances && mesh.thinInstanceEnablePicking) {
608
611
  // first check if the ray intersects the whole bounding box/sphere of the mesh
609
612
  const result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, true, true, trianglePredicate);
@@ -645,6 +648,8 @@ Scene.prototype._internalMultiPick = function (rayFunction, predicate, triangleP
645
648
  return null;
646
649
  }
647
650
  const pickingInfos = new Array();
651
+ const computeWorldMatrixForCamera = !!(this.activeCameras && this.activeCameras.length > 1 && this.cameraToUseForPointers !== this.activeCamera);
652
+ const currentCamera = this.cameraToUseForPointers || this.activeCamera;
648
653
  for (let meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
649
654
  const mesh = this.meshes[meshIndex];
650
655
  if (predicate) {
@@ -655,7 +660,8 @@ Scene.prototype._internalMultiPick = function (rayFunction, predicate, triangleP
655
660
  else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
656
661
  continue;
657
662
  }
658
- const world = mesh.getWorldMatrix();
663
+ const forceCompute = computeWorldMatrixForCamera && mesh.isWorldMatrixCameraDependent();
664
+ const world = mesh.computeWorldMatrix(forceCompute, currentCamera);
659
665
  if (mesh.hasThinInstances && mesh.thinInstanceEnablePicking) {
660
666
  const result = this._internalPickForMesh(null, rayFunction, mesh, world, true, true, trianglePredicate);
661
667
  if (result) {
@@ -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,M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E,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,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, i0: number, i1: number, i2: number) => 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 ): 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): PickingInfo {\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): PickingInfo {\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,EAA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,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, i0: number, i1: number, i2: number) => 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 ): 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): PickingInfo {\r\n let pickingInfo = null;\r\n\r\n const computeWorldMatrixForCamera = !!(this.activeCameras && this.activeCameras.length > 1 && this.cameraToUseForPointers !== this.activeCamera);\r\n const currentCamera = this.cameraToUseForPointers || this.activeCamera;\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 forceCompute = computeWorldMatrixForCamera && mesh.isWorldMatrixCameraDependent();\r\n const world = mesh.computeWorldMatrix(forceCompute, currentCamera);\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 const computeWorldMatrixForCamera = !!(this.activeCameras && this.activeCameras.length > 1 && this.cameraToUseForPointers !== this.activeCamera);\r\n const currentCamera = this.cameraToUseForPointers || this.activeCamera;\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 forceCompute = computeWorldMatrixForCamera && mesh.isWorldMatrixCameraDependent();\r\n const world = mesh.computeWorldMatrix(forceCompute, currentCamera);\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): PickingInfo {\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"]}
@@ -43,7 +43,7 @@ WebGPUEngine.prototype.createRenderTargetTexture = function (size, options) {
43
43
  fullOptions.samplingMode === 5 ||
44
44
  fullOptions.samplingMode === 6 ||
45
45
  fullOptions.samplingMode === 7 ||
46
- fullOptions.samplingMode === 11), rtWrapper._generateStencilBuffer, rtWrapper.samples);
46
+ fullOptions.samplingMode === 11), rtWrapper._generateStencilBuffer, rtWrapper.samples, fullOptions.generateStencilBuffer ? 13 : 14);
47
47
  }
48
48
  if (texture) {
49
49
  if (options !== undefined && typeof options === "object" && options.createMipMaps && !fullOptions.generateMipMaps) {
@@ -1 +1 @@
1
- {"version":3,"file":"engine.renderTarget.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/WebGPU/Extensions/engine.renderTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAGrG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,YAAY,CAAC,SAAS,CAAC,kCAAkC,GAAG,UAAU,OAAgB,EAAE,MAAe,EAAE,IAAiB;IACtH,MAAM,SAAS,GAAG,IAAI,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7E,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,yBAAyB,GAAG,UAAU,IAAiB,EAAE,OAA8C;;IAC1H,MAAM,SAAS,GAAG,IAAI,CAAC,kCAAkC,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAA8B,CAAC;IAE3G,MAAM,WAAW,GAAgC,EAAE,CAAC;IAEpD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QACtD,WAAW,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QACtD,WAAW,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB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AC7B,SAAS,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAEpC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, DepthTextureCreationOptions, TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\n\r\nWebGPUEngine.prototype._createHardwareRenderTargetWrapper = function (isMulti: boolean, isCube: boolean, size: TextureSize): WebGPURenderTargetWrapper {\r\n const rtWrapper = new WebGPURenderTargetWrapper(isMulti, isCube, size, this);\r\n this._renderTargetWrapperCache.push(rtWrapper);\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.createRenderTargetTexture = function (size: TextureSize, options: boolean | RenderTargetCreationOptions): WebGPURenderTargetWrapper {\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(false, false, size) as WebGPURenderTargetWrapper;\r\n\r\n const fullOptions: RenderTargetCreationOptions = {};\r\n\r\n if (options !== undefined && typeof options === \"object\") {\r\n fullOptions.generateMipMaps = options.generateMipMaps;\r\n fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;\r\n fullOptions.samplingMode = options.samplingMode === undefined ? Constants.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;\r\n fullOptions.creationFlags = options.creationFlags ?? 0;\r\n fullOptions.noColorAttachment = !!options.noColorAttachment;\r\n fullOptions.samples = options.samples;\r\n } else {\r\n fullOptions.generateMipMaps = <boolean>options;\r\n fullOptions.generateDepthBuffer = true;\r\n fullOptions.generateStencilBuffer = false;\r\n fullOptions.samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n fullOptions.creationFlags = 0;\r\n fullOptions.noColorAttachment = false;\r\n }\r\n\r\n const texture = fullOptions.noColorAttachment ? null : this._createInternalTexture(size, options, true, InternalTextureSource.RenderTarget);\r\n\r\n rtWrapper._samples = fullOptions.samples ?? 1;\r\n rtWrapper._generateDepthBuffer = fullOptions.generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;\r\n\r\n rtWrapper.setTextures(texture);\r\n\r\n if (rtWrapper._generateDepthBuffer || rtWrapper._generateStencilBuffer) {\r\n rtWrapper.createDepthStencilTexture(\r\n 0,\r\n this._caps.textureFloatLinearFiltering &&\r\n (fullOptions.samplingMode === undefined ||\r\n fullOptions.samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n fullOptions.samplingMode === Constants.TEXTURE_LINEAR_LINEAR ||\r\n fullOptions.samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n fullOptions.samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR ||\r\n fullOptions.samplingMode === Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST ||\r\n fullOptions.samplingMode === Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR ||\r\n fullOptions.samplingMode === Constants.TEXTURE_NEAREST_LINEAR ||\r\n fullOptions.samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST),\r\n rtWrapper._generateStencilBuffer,\r\n rtWrapper.samples\r\n );\r\n }\r\n\r\n if (texture) {\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = true;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, undefined, undefined, undefined, fullOptions.creationFlags);\r\n\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = false;\r\n }\r\n }\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype._createDepthStencilTexture = function (size: TextureSize, options: DepthTextureCreationOptions): InternalTexture {\r\n const internalTexture = new InternalTexture(this, InternalTextureSource.DepthStencil);\r\n\r\n const internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n samples: 1,\r\n depthTextureFormat: options.generateStencil ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n ...options,\r\n };\r\n\r\n internalTexture.format = internalOptions.depthTextureFormat;\r\n\r\n this._setupDepthStencilTexture(\r\n internalTexture,\r\n size,\r\n internalOptions.generateStencil,\r\n internalOptions.bilinearFiltering,\r\n internalOptions.comparisonFunction,\r\n internalOptions.samples\r\n );\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nWebGPUEngine.prototype._setupDepthStencilTexture = function (\r\n internalTexture: InternalTexture,\r\n size: TextureSize,\r\n generateStencil: boolean,\r\n bilinearFiltering: boolean,\r\n comparisonFunction: number,\r\n samples = 1\r\n): void {\r\n const width = (<{ width: number; height: number; layers?: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number; layers?: number }>size).height || <number>size;\r\n const layers = (<{ width: number; height: number; layers?: number }>size).layers || 0;\r\n\r\n internalTexture.baseWidth = width;\r\n internalTexture.baseHeight = height;\r\n internalTexture.width = width;\r\n internalTexture.height = height;\r\n internalTexture.is2DArray = layers > 0;\r\n internalTexture.depth = layers;\r\n internalTexture.isReady = true;\r\n internalTexture.samples = samples;\r\n internalTexture.generateMipMaps = false;\r\n internalTexture.samplingMode = bilinearFiltering ? Constants.TEXTURE_BILINEAR_SAMPLINGMODE : Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n internalTexture._comparisonFunction = comparisonFunction;\r\n internalTexture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n internalTexture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n};\r\n\r\nWebGPUEngine.prototype.updateRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.texture || rtWrapper.samples === samples) {\r\n return samples;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n this._textureHelper.createMSAATexture(rtWrapper.texture, samples);\r\n\r\n if (rtWrapper._depthStencilTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n rtWrapper._samples = samples;\r\n rtWrapper.texture.samples = samples;\r\n\r\n return samples;\r\n};\r\n"]}
1
+ {"version":3,"file":"engine.renderTarget.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/WebGPU/Extensions/engine.renderTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAGrG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,YAAY,CAAC,SAAS,CAAC,kCAAkC,GAAG,UAAU,OAAgB,EAAE,MAAe,EAAE,IAAiB;IACtH,MAAM,SAAS,GAAG,IAAI,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7E,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,YAAY,CAA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AAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,KAAK,OAAO,EAAE;QACnE,OAAO,OAAO,CAAC;KAClB;IAED,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;IAE3D,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAElE,IAAI,SAAS,CAAC,oBAAoB,EAAE;QAChC,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC/E,SAAS,CAAC,oBAAoB,CAAC,OAAO,GAAG,OAAO,CAAC;KACpD;IAED,SAAS,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAEpC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, DepthTextureCreationOptions, TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\n\r\nWebGPUEngine.prototype._createHardwareRenderTargetWrapper = function (isMulti: boolean, isCube: boolean, size: TextureSize): WebGPURenderTargetWrapper {\r\n const rtWrapper = new WebGPURenderTargetWrapper(isMulti, isCube, size, this);\r\n this._renderTargetWrapperCache.push(rtWrapper);\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.createRenderTargetTexture = function (size: TextureSize, options: boolean | RenderTargetCreationOptions): WebGPURenderTargetWrapper {\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(false, false, size) as WebGPURenderTargetWrapper;\r\n\r\n const fullOptions: RenderTargetCreationOptions = {};\r\n\r\n if (options !== undefined && typeof options === \"object\") {\r\n fullOptions.generateMipMaps = options.generateMipMaps;\r\n fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;\r\n fullOptions.samplingMode = options.samplingMode === undefined ? Constants.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;\r\n fullOptions.creationFlags = options.creationFlags ?? 0;\r\n fullOptions.noColorAttachment = !!options.noColorAttachment;\r\n fullOptions.samples = options.samples;\r\n } else {\r\n fullOptions.generateMipMaps = <boolean>options;\r\n fullOptions.generateDepthBuffer = true;\r\n fullOptions.generateStencilBuffer = false;\r\n fullOptions.samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n fullOptions.creationFlags = 0;\r\n fullOptions.noColorAttachment = false;\r\n }\r\n\r\n const texture = fullOptions.noColorAttachment ? null : this._createInternalTexture(size, options, true, InternalTextureSource.RenderTarget);\r\n\r\n rtWrapper._samples = fullOptions.samples ?? 1;\r\n rtWrapper._generateDepthBuffer = fullOptions.generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;\r\n\r\n rtWrapper.setTextures(texture);\r\n\r\n if (rtWrapper._generateDepthBuffer || rtWrapper._generateStencilBuffer) {\r\n rtWrapper.createDepthStencilTexture(\r\n 0,\r\n this._caps.textureFloatLinearFiltering &&\r\n (fullOptions.samplingMode === undefined ||\r\n fullOptions.samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n fullOptions.samplingMode === Constants.TEXTURE_LINEAR_LINEAR ||\r\n fullOptions.samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n fullOptions.samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR ||\r\n fullOptions.samplingMode === Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST ||\r\n fullOptions.samplingMode === Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR ||\r\n fullOptions.samplingMode === Constants.TEXTURE_NEAREST_LINEAR ||\r\n fullOptions.samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST),\r\n rtWrapper._generateStencilBuffer,\r\n rtWrapper.samples,\r\n fullOptions.generateStencilBuffer ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT\r\n );\r\n }\r\n\r\n if (texture) {\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = true;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, undefined, undefined, undefined, fullOptions.creationFlags);\r\n\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = false;\r\n }\r\n }\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype._createDepthStencilTexture = function (size: TextureSize, options: DepthTextureCreationOptions): InternalTexture {\r\n const internalTexture = new InternalTexture(this, InternalTextureSource.DepthStencil);\r\n\r\n const internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n samples: 1,\r\n depthTextureFormat: options.generateStencil ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n ...options,\r\n };\r\n\r\n internalTexture.format = internalOptions.depthTextureFormat;\r\n\r\n this._setupDepthStencilTexture(\r\n internalTexture,\r\n size,\r\n internalOptions.generateStencil,\r\n internalOptions.bilinearFiltering,\r\n internalOptions.comparisonFunction,\r\n internalOptions.samples\r\n );\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nWebGPUEngine.prototype._setupDepthStencilTexture = function (\r\n internalTexture: InternalTexture,\r\n size: TextureSize,\r\n generateStencil: boolean,\r\n bilinearFiltering: boolean,\r\n comparisonFunction: number,\r\n samples = 1\r\n): void {\r\n const width = (<{ width: number; height: number; layers?: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number; layers?: number }>size).height || <number>size;\r\n const layers = (<{ width: number; height: number; layers?: number }>size).layers || 0;\r\n\r\n internalTexture.baseWidth = width;\r\n internalTexture.baseHeight = height;\r\n internalTexture.width = width;\r\n internalTexture.height = height;\r\n internalTexture.is2DArray = layers > 0;\r\n internalTexture.depth = layers;\r\n internalTexture.isReady = true;\r\n internalTexture.samples = samples;\r\n internalTexture.generateMipMaps = false;\r\n internalTexture.samplingMode = bilinearFiltering ? Constants.TEXTURE_BILINEAR_SAMPLINGMODE : Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n internalTexture._comparisonFunction = comparisonFunction;\r\n internalTexture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n internalTexture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n};\r\n\r\nWebGPUEngine.prototype.updateRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.texture || rtWrapper.samples === samples) {\r\n return samples;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n this._textureHelper.createMSAATexture(rtWrapper.texture, samples);\r\n\r\n if (rtWrapper._depthStencilTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n rtWrapper._samples = samples;\r\n rtWrapper.texture.samples = samples;\r\n\r\n return samples;\r\n};\r\n"]}
package/Engines/engine.js CHANGED
@@ -1447,8 +1447,17 @@ export class Engine extends ThinEngine {
1447
1447
  */
1448
1448
  static _RequestPointerlock(element) {
1449
1449
  if (element.requestPointerLock) {
1450
- element.requestPointerLock();
1451
- element.focus();
1450
+ // In some browsers, requestPointerLock returns a promise.
1451
+ // Handle possible rejections to avoid an unhandled top-level exception.
1452
+ const promise = element.requestPointerLock();
1453
+ if (promise instanceof Promise)
1454
+ promise
1455
+ .then(() => {
1456
+ element.focus();
1457
+ })
1458
+ .catch(() => { });
1459
+ else
1460
+ element.focus();
1452
1461
  }
1453
1462
  }
1454
1463
  /**