@babylonjs/core 5.45.1 → 5.45.2

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 (36) hide show
  1. package/Engines/thinEngine.js +2 -2
  2. package/Engines/thinEngine.js.map +1 -1
  3. package/Inputs/scene.inputManager.js +12 -1
  4. package/Inputs/scene.inputManager.js.map +1 -1
  5. package/Materials/Textures/videoTexture.d.ts +1 -0
  6. package/Materials/Textures/videoTexture.js +19 -8
  7. package/Materials/Textures/videoTexture.js.map +1 -1
  8. package/Physics/index.d.ts +1 -0
  9. package/Physics/index.js +1 -0
  10. package/Physics/index.js.map +1 -1
  11. package/Physics/physicsHelper.d.ts +452 -1
  12. package/Physics/physicsHelper.js +877 -2
  13. package/Physics/physicsHelper.js.map +1 -1
  14. package/Physics/v1/index.d.ts +0 -1
  15. package/Physics/v1/index.js +0 -1
  16. package/Physics/v1/index.js.map +1 -1
  17. package/Physics/v2/IPhysicsEnginePlugin.d.ts +2 -1
  18. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  19. package/Physics/v2/index.d.ts +1 -0
  20. package/Physics/v2/index.js +1 -0
  21. package/Physics/v2/index.js.map +1 -1
  22. package/Physics/v2/physicsAggregate.d.ts +18 -0
  23. package/Physics/v2/physicsAggregate.js +44 -2
  24. package/Physics/v2/physicsAggregate.js.map +1 -1
  25. package/Physics/v2/physicsBody.d.ts +22 -1
  26. package/Physics/v2/physicsBody.js +54 -1
  27. package/Physics/v2/physicsBody.js.map +1 -1
  28. package/Physics/v2/physicsEngine.d.ts +7 -2
  29. package/Physics/v2/physicsEngine.js +9 -2
  30. package/Physics/v2/physicsEngine.js.map +1 -1
  31. package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js +4 -1
  32. package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
  33. package/package.json +1 -1
  34. package/Physics/v1/physicsHelper.d.ts +0 -411
  35. package/Physics/v1/physicsHelper.js +0 -709
  36. package/Physics/v1/physicsHelper.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"videoTexture.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Materials/Textures/videoTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,8CAA8C,CAAC;AACtD,OAAO,gDAAgD,CAAC;AAExD,SAAS,YAAY,CAAC,KAAuB;IACzC,qCAAqC;IACrC,OAAO,KAAK,CAAC,UAAU,EAAE;QACrB,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;KACvC;IAED,mBAAmB;IACnB,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAEvB,sHAAsH;IACtH,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;IAEf,8FAA8F;IAC9F,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AA2CD;;;;GAIG;AACH,MAAM,OAAO,YAAa,SAAQ,OAAO;IAkErC;;;;;;;;;;;;;;OAcG;IACH,YACI,IAAsB,EACtB,GAAyC,EACzC,KAAsB,EACtB,eAAe,GAAG,KAAK,EACvB,OAAO,GAAG,KAAK,EACf,eAAuB,OAAO,CAAC,sBAAsB,EACrD,WAA0C,EAAE,EAC5C,OAA+D,EAC/D,SAAiB,SAAS,CAAC,kBAAkB;;QAE7C,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAhF1C,qCAAgC,GAAkC,IAAI,CAAC;QAcvE,wBAAmB,GAAG,KAAK,CAAC;QAC5B,6BAAwB,GAAG,KA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EAAE,eAAe;aACzB,CAAC,CAAC;YAEH,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;YAC3F,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE;gBAC1C,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;oBACjC,KAAK,CAAC,IAAI,EAAE,CAAC;gBACjB,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;YAEH,OAAO,YAAY,CAAC;SACvB;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,gBAAgB,CAC1B,KAAY,EACZ,OAA6C,EAC7C,WAMyB,EACzB,kBAAmD,KAAK,EACxD,OAAO,GAAG,IAAI;QAEd,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,CAAC;aACnE,IAAI,CAAC,UAAU,YAAY;YACxB,IAAI,OAAO,EAAE;gBACT,OAAO,CAAC,YAAY,CAAC,CAAC;aACzB;QACL,CAAC,CAAC;aACD,KAAK,CAAC,UAAU,GAAG;YAChB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACX,CAAC;CACJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { ExternalTexture } from \"./externalTexture\";\r\n\r\nimport \"../../Engines/Extensions/engine.videoTexture\";\r\nimport \"../../Engines/Extensions/engine.dynamicTexture\";\r\n\r\nfunction removeSource(video: HTMLVideoElement): void {\r\n // Remove any <source> elements, etc.\r\n while (video.firstChild) {\r\n video.removeChild(video.firstChild);\r\n }\r\n\r\n // detach srcObject\r\n video.srcObject = null;\r\n\r\n // Set a blank src (https://html.spec.whatwg.org/multipage/media.html#best-practices-for-authors-using-media-elements)\r\n video.src = \"\";\r\n\r\n // Prevent non-important errors maybe (https://twitter.com/beraliv/status/1205214277956775936)\r\n video.removeAttribute(\"src\");\r\n}\r\n\r\n/**\r\n * Settings for finer control over video usage\r\n */\r\nexport interface VideoTextureSettings {\r\n /**\r\n * Applies `autoplay` to video, if specified\r\n */\r\n autoPlay?: boolean;\r\n\r\n /**\r\n * Applies `muted` to video, if specified\r\n */\r\n muted?: boolean;\r\n\r\n /**\r\n * Applies `loop` to video, if specified\r\n */\r\n loop?: boolean;\r\n\r\n /**\r\n * Automatically updates internal texture from video at every frame in the render loop\r\n */\r\n autoUpdateTexture: boolean;\r\n\r\n /**\r\n * Image src displayed during the video loading or until the user interacts with the video.\r\n */\r\n poster?: string;\r\n\r\n /**\r\n * Defines the associated texture format.\r\n */\r\n format?: number;\r\n\r\n /**\r\n * Notify babylon to not modify any video settings and not control the video's playback.\r\n * Set this to true if you are controlling the way the video is being played, stopped and paused.\r\n */\r\n independentVideoSource?: boolean;\r\n}\r\n\r\n/**\r\n * If you want to display a video in your scene, this is the special texture for that.\r\n * This special texture works similar to other textures, with the exception of a few parameters.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/videoTexture\r\n */\r\nexport class VideoTexture extends Texture {\r\n /**\r\n * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually\r\n */\r\n public readonly autoUpdateTexture: boolean;\r\n\r\n /**\r\n * The video instance used by the texture internally\r\n */\r\n public readonly video: HTMLVideoElement;\r\n\r\n private _externalTexture: Nullable<ExternalTexture>;\r\n private _onUserActionRequestedObservable: Nullable<Observable<Texture>> = null;\r\n\r\n /**\r\n * Event triggered when a dom action is required by the user to play the video.\r\n * This happens due to recent changes in browser policies preventing video to auto start.\r\n */\r\n public get onUserActionRequestedObservable(): Observable<Texture> {\r\n if (!this._onUserActionRequestedObservable) {\r\n this._onUserActionRequestedObservable = new Observable<Texture>();\r\n }\r\n return this._onUserActionRequestedObservable;\r\n }\r\n\r\n private _generateMipMaps: boolean;\r\n private _stillImageCaptured = false;\r\n private _displayingPosterTexture = false;\r\n private _settings: VideoTextureSettings;\r\n private _createInternalTextureOnEvent: string;\r\n private _frameId = -1;\r\n private _currentSrc: Nullable<string | string[] | HTMLVideoElement> = null;\r\n private _onError?: Nullable<(message?: string, exception?: any) => void>;\r\n private _errorFound = false;\r\n\r\n private _processError(reason: any) {\r\n this._errorFound = true;\r\n if (this._onError) {\r\n this._onError(reason?.message);\r\n } else {\r\n Logger.Error(reason?.message);\r\n }\r\n }\r\n\r\n private _handlePlay() {\r\n this._errorFound = false;\r\n this.video.play().catch((reason) => {\r\n if (reason?.name === \"NotAllowedError\") {\r\n if (this._onUserActionRequestedObservable && this._onUserActionRequestedObservable.hasObservers()) {\r\n this._onUserActionRequestedObservable.notifyObservers(this);\r\n return;\r\n } else if (!this.video.muted) {\r\n Logger.Warn(\"Unable to autoplay a video with sound. Trying again with muted turned true\");\r\n this.video.muted = true;\r\n this._errorFound = false;\r\n this.video.play().catch((otherReason) => {\r\n this._processError(otherReason);\r\n });\r\n return;\r\n }\r\n }\r\n\r\n this._processError(reason);\r\n });\r\n }\r\n\r\n /**\r\n * Creates a video texture.\r\n * If you want to display a video in your scene, this is the special texture for that.\r\n * This special texture works similar to other textures, with the exception of a few parameters.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/videoTexture\r\n * @param name optional name, will detect from video source, if not defined\r\n * @param src can be used to provide an url, array of urls or an already setup HTML video element.\r\n * @param scene is obviously the current scene.\r\n * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).\r\n * @param invertY is false by default but can be used to invert video on Y axis\r\n * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default\r\n * @param settings allows finer control over video usage\r\n * @param onError defines a callback triggered when an error occurred during the loading session\r\n * @param format defines the texture format to use (Engine.TEXTUREFORMAT_RGBA by default)\r\n */\r\n constructor(\r\n name: Nullable<string>,\r\n src: string | string[] | HTMLVideoElement,\r\n scene: Nullable<Scene>,\r\n generateMipMaps = false,\r\n invertY = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n settings: Partial<VideoTextureSettings> = {},\r\n onError?: Nullable<(message?: string, exception?: any) => void>,\r\n format: number = Constants.TEXTUREFORMAT_RGBA\r\n ) {\r\n super(null, scene, !generateMipMaps, invertY);\r\n\r\n this._settings = {\r\n autoPlay: true,\r\n loop: true,\r\n autoUpdateTexture: true,\r\n ...settings,\r\n };\r\n\r\n this._onError = onError;\r\n\r\n this._generateMipMaps = generateMipMaps;\r\n this._initialSamplingMode = samplingMode;\r\n this.autoUpdateTexture = this._settings.autoUpdateTexture;\r\n\r\n this._currentSrc = src;\r\n this.name = name || this._getName(src);\r\n this.video = this._getVideo(src);\r\n this._externalTexture = this._engine?.createExternalTexture(this.video) ?? null;\r\n if (!this._settings.independentVideoSource) {\r\n if (this._settings.poster) {\r\n this.video.poster = this._settings.poster;\r\n }\r\n if (this._settings.autoPlay !== undefined) {\r\n this.video.autoplay = this._settings.autoPlay;\r\n }\r\n if (this._settings.loop !== undefined) {\r\n this.video.loop = this._settings.loop;\r\n }\r\n if (this._settings.muted !== undefined) {\r\n this.video.muted = this._settings.muted;\r\n }\r\n\r\n this.video.setAttribute(\"playsinline\", \"\");\r\n this.video.addEventListener(\"paused\", this._updateInternalTexture);\r\n this.video.addEventListener(\"seeked\", this._updateInternalTexture);\r\n this.video.addEventListener(\"emptied\", this._reset);\r\n\r\n if (this._settings.autoPlay) {\r\n this._handlePlay();\r\n }\r\n }\r\n\r\n this._createInternalTextureOnEvent = this._settings.poster && !this._settings.autoPlay ? \"play\" : \"canplay\";\r\n this.video.addEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);\r\n this._format = format;\r\n\r\n const videoHasEnoughData = this.video.readyState >= this.video.HAVE_CURRENT_DATA;\r\n if (this._settings.poster && (!this._settings.autoPlay || !videoHasEnoughData)) {\r\n this._texture = this._getEngine()!.createTexture(this._settings.poster!, false, !this.invertY, scene);\r\n this._displayingPosterTexture = true;\r\n } else if (videoHasEnoughData) {\r\n this._createInternalTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Get the current class name of the video texture useful for serialization or dynamic coding.\r\n * @returns \"VideoTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"VideoTexture\";\r\n }\r\n\r\n private _getName(src: string | string[] | HTMLVideoElement): string {\r\n if (src instanceof HTMLVideoElement) {\r\n return src.currentSrc;\r\n }\r\n\r\n if (typeof src === \"object\") {\r\n return src.toString();\r\n }\r\n\r\n return src;\r\n }\r\n\r\n private _getVideo(src: string | string[] | HTMLVideoElement): HTMLVideoElement {\r\n if ((<any>src).isNative) {\r\n return <HTMLVideoElement>src;\r\n }\r\n if (src instanceof HTMLVideoElement) {\r\n Tools.SetCorsBehavior(src.currentSrc, src);\r\n return src;\r\n }\r\n const video: HTMLVideoElement = document.createElement(\"video\");\r\n if (typeof src === \"string\") {\r\n Tools.SetCorsBehavior(src, video);\r\n video.src = src;\r\n } else {\r\n Tools.SetCorsBehavior(src[0], video);\r\n src.forEach((url) => {\r\n const source = document.createElement(\"source\");\r\n source.src = url;\r\n video.appendChild(source);\r\n });\r\n }\r\n\r\n this.onDisposeObservable.addOnce(() => {\r\n removeSource(video);\r\n });\r\n\r\n return video;\r\n }\r\n\r\n private _createInternalTexture = (): void => {\r\n if (this._texture != null) {\r\n if (this._displayingPosterTexture) {\r\n this._texture.dispose();\r\n this._displayingPosterTexture = false;\r\n } else {\r\n return;\r\n }\r\n }\r\n\r\n if (!this._getEngine()!.needPOTTextures || (Tools.IsExponentOfTwo(this.video.videoWidth) && Tools.IsExponentOfTwo(this.video.videoHeight))) {\r\n this.wrapU = Texture.WRAP_ADDRESSMODE;\r\n this.wrapV = Texture.WRAP_ADDRESSMODE;\r\n } else {\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n this._generateMipMaps = false;\r\n }\r\n\r\n this._texture = this._getEngine()!.createDynamicTexture(this.video.videoWidth, this.video.videoHeight, this._generateMipMaps, this.samplingMode);\r\n this._texture.format = this._format ?? Constants.TEXTUREFORMAT_RGBA;\r\n\r\n if (!this.video.autoplay && !this._settings.poster && !this._settings.independentVideoSource) {\r\n const oldHandler = this.video.onplaying;\r\n const oldMuted = this.video.muted;\r\n this.video.muted = true;\r\n this.video.onplaying = () => {\r\n this.video.muted = oldMuted;\r\n this.video.onplaying = oldHandler;\r\n this._updateInternalTexture();\r\n if (!this._errorFound) {\r\n this.video.pause();\r\n }\r\n if (this.onLoadObservable.hasObservers()) {\r\n this.onLoadObservable.notifyObservers(this);\r\n }\r\n };\r\n this._handlePlay();\r\n } else {\r\n this._updateInternalTexture();\r\n if (this.onLoadObservable.hasObservers()) {\r\n this.onLoadObservable.notifyObservers(this);\r\n }\r\n }\r\n };\r\n\r\n private _reset = (): void => {\r\n if (this._texture == null) {\r\n return;\r\n }\r\n\r\n if (!this._displayingPosterTexture) {\r\n this._texture.dispose();\r\n this._texture = null;\r\n }\r\n };\r\n\r\n /**\r\n * @internal Internal method to initiate `update`.\r\n */\r\n public _rebuild(): void {\r\n this.update();\r\n }\r\n\r\n /**\r\n * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.\r\n */\r\n public update(): void {\r\n if (!this.autoUpdateTexture) {\r\n // Expecting user to call `updateTexture` manually\r\n return;\r\n }\r\n\r\n this.updateTexture(true);\r\n }\r\n\r\n /**\r\n * Update Texture in `manual` mode. Does not do anything if not visible or paused.\r\n * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.\r\n */\r\n public updateTexture(isVisible: boolean): void {\r\n if (!isVisible) {\r\n return;\r\n }\r\n if (this.video.paused && this._stillImageCaptured) {\r\n return;\r\n }\r\n this._stillImageCaptured = true;\r\n this._updateInternalTexture();\r\n }\r\n\r\n protected _updateInternalTexture = (): void => {\r\n if (this._texture == null) {\r\n return;\r\n }\r\n if (this.video.readyState < this.video.HAVE_CURRENT_DATA) {\r\n return;\r\n }\r\n if (this._displayingPosterTexture) {\r\n return;\r\n }\r\n\r\n const frameId = this.getScene()!.getFrameId();\r\n if (this._frameId === frameId) {\r\n return;\r\n }\r\n\r\n this._frameId = frameId;\r\n\r\n this._getEngine()!.updateVideoTexture(this._texture, this._externalTexture ? this._externalTexture : this.video, this._invertY);\r\n };\r\n\r\n /**\r\n * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.\r\n * @param url New url.\r\n */\r\n public updateURL(url: string): void {\r\n this.video.src = url;\r\n this._currentSrc = url;\r\n }\r\n\r\n /**\r\n * Clones the texture.\r\n * @returns the cloned texture\r\n */\r\n public clone(): VideoTexture {\r\n return new VideoTexture(this.name, this._currentSrc!, this.getScene(), this._generateMipMaps, this.invertY, this.samplingMode, this._settings);\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public dispose(): void {\r\n super.dispose();\r\n\r\n this._currentSrc = null;\r\n\r\n if (this._onUserActionRequestedObservable) {\r\n this._onUserActionRequestedObservable.clear();\r\n this._onUserActionRequestedObservable = null;\r\n }\r\n\r\n this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);\r\n if (!this._settings.independentVideoSource) {\r\n this.video.removeEventListener(\"paused\", this._updateInternalTexture);\r\n this.video.removeEventListener(\"seeked\", this._updateInternalTexture);\r\n this.video.removeEventListener(\"emptied\", this._reset);\r\n this.video.pause();\r\n }\r\n\r\n this._externalTexture?.dispose();\r\n }\r\n\r\n /**\r\n * Creates a video texture straight from a stream.\r\n * @param scene Define the scene the texture should be created in\r\n * @param stream Define the stream the texture should be created from\r\n * @param constraints video constraints\r\n * @param invertY Defines if the video should be stored with invert Y set to true (true by default)\r\n * @returns The created video texture as a promise\r\n */\r\n public static CreateFromStreamAsync(scene: Scene, stream: MediaStream, constraints: any, invertY = true): Promise<VideoTexture> {\r\n const video = scene.getEngine().createVideoElement(constraints);\r\n\r\n if (scene.getEngine()._badOS) {\r\n // Yes... I know and I hope to remove it soon...\r\n document.body.appendChild(video);\r\n video.style.transform = \"scale(0.0001, 0.0001)\";\r\n video.style.opacity = \"0\";\r\n video.style.position = \"fixed\";\r\n video.style.bottom = \"0px\";\r\n video.style.right = \"0px\";\r\n }\r\n\r\n video.setAttribute(\"autoplay\", \"\");\r\n video.setAttribute(\"muted\", \"true\");\r\n video.setAttribute(\"playsinline\", \"\");\r\n video.muted = true;\r\n\r\n if (video.isNative) {\r\n // No additional configuration needed for native\r\n } else if (video.mozSrcObject !== undefined) {\r\n // hack for Firefox < 19\r\n video.mozSrcObject = stream;\r\n } else {\r\n if (typeof video.srcObject == \"object\") {\r\n video.srcObject = stream;\r\n } else {\r\n // older API. See https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL#using_object_urls_for_media_streams\r\n video.src = window.URL && window.URL.createObjectURL(stream as any);\r\n }\r\n }\r\n\r\n return new Promise<VideoTexture>((resolve) => {\r\n const onPlaying = () => {\r\n const videoTexture = new VideoTexture(\"video\", video, scene, true, invertY, undefined, undefined, undefined, Constants.TEXTUREFORMAT_RGB);\r\n if (scene.getEngine()._badOS) {\r\n videoTexture.onDisposeObservable.addOnce(() => {\r\n video.remove();\r\n });\r\n }\r\n videoTexture.onDisposeObservable.addOnce(() => {\r\n removeSource(video);\r\n });\r\n\r\n resolve(videoTexture);\r\n video.removeEventListener(\"playing\", onPlaying);\r\n };\r\n\r\n video.addEventListener(\"playing\", onPlaying);\r\n video.play();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a video texture straight from your WebCam video feed.\r\n * @param scene Define the scene the texture should be created in\r\n * @param constraints Define the constraints to use to create the web cam feed from WebRTC\r\n * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC\r\n * @param invertY Defines if the video should be stored with invert Y set to true (true by default)\r\n * @returns The created video texture as a promise\r\n */\r\n public static async CreateFromWebCamAsync(\r\n scene: Scene,\r\n constraints: {\r\n minWidth: number;\r\n maxWidth: number;\r\n minHeight: number;\r\n maxHeight: number;\r\n deviceId: string;\r\n } & MediaTrackConstraints,\r\n audioConstaints: boolean | MediaTrackConstraints = false,\r\n invertY = true\r\n ): Promise<VideoTexture> {\r\n if (navigator.mediaDevices) {\r\n const stream = await navigator.mediaDevices.getUserMedia({\r\n video: constraints,\r\n audio: audioConstaints,\r\n });\r\n\r\n const videoTexture = await this.CreateFromStreamAsync(scene, stream, constraints, invertY);\r\n videoTexture.onDisposeObservable.addOnce(() => {\r\n stream.getTracks().forEach((track) => {\r\n track.stop();\r\n });\r\n });\r\n\r\n return videoTexture;\r\n }\r\n\r\n return Promise.reject(\"No support for userMedia on this device\");\r\n }\r\n\r\n /**\r\n * Creates a video texture straight from your WebCam video feed.\r\n * @param scene Defines the scene the texture should be created in\r\n * @param onReady Defines a callback to triggered once the texture will be ready\r\n * @param constraints Defines the constraints to use to create the web cam feed from WebRTC\r\n * @param audioConstaints Defines the audio constraints to use to create the web cam feed from WebRTC\r\n * @param invertY Defines if the video should be stored with invert Y set to true (true by default)\r\n */\r\n public static CreateFromWebCam(\r\n scene: Scene,\r\n onReady: (videoTexture: VideoTexture) => void,\r\n constraints: {\r\n minWidth: number;\r\n maxWidth: number;\r\n minHeight: number;\r\n maxHeight: number;\r\n deviceId: string;\r\n } & MediaTrackConstraints,\r\n audioConstaints: boolean | MediaTrackConstraints = false,\r\n invertY = true\r\n ): void {\r\n this.CreateFromWebCamAsync(scene, constraints, audioConstaints, invertY)\r\n .then(function (videoTexture) {\r\n if (onReady) {\r\n onReady(videoTexture);\r\n }\r\n })\r\n .catch(function (err) {\r\n Logger.Error(err.name);\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"videoTexture.js","sourceRoot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C;QAC3B,CAAC,CAAC,CAAC;IACX,CAAC;CACJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { ExternalTexture } from \"./externalTexture\";\r\n\r\nimport \"../../Engines/Extensions/engine.videoTexture\";\r\nimport \"../../Engines/Extensions/engine.dynamicTexture\";\r\n\r\nfunction removeSource(video: HTMLVideoElement): void {\r\n // Remove any <source> elements, etc.\r\n while (video.firstChild) {\r\n video.removeChild(video.firstChild);\r\n }\r\n\r\n // detach srcObject\r\n video.srcObject = null;\r\n\r\n // Set a blank src (https://html.spec.whatwg.org/multipage/media.html#best-practices-for-authors-using-media-elements)\r\n video.src = \"\";\r\n\r\n // Prevent non-important errors maybe (https://twitter.com/beraliv/status/1205214277956775936)\r\n video.removeAttribute(\"src\");\r\n}\r\n\r\n/**\r\n * Settings for finer control over video usage\r\n */\r\nexport interface VideoTextureSettings {\r\n /**\r\n * Applies `autoplay` to video, if specified\r\n */\r\n autoPlay?: boolean;\r\n\r\n /**\r\n * Applies `muted` to video, if specified\r\n */\r\n muted?: boolean;\r\n\r\n /**\r\n * Applies `loop` to video, if specified\r\n */\r\n loop?: boolean;\r\n\r\n /**\r\n * Automatically updates internal texture from video at every frame in the render loop\r\n */\r\n autoUpdateTexture: boolean;\r\n\r\n /**\r\n * Image src displayed during the video loading or until the user interacts with the video.\r\n */\r\n poster?: string;\r\n\r\n /**\r\n * Defines the associated texture format.\r\n */\r\n format?: number;\r\n\r\n /**\r\n * Notify babylon to not modify any video settings and not control the video's playback.\r\n * Set this to true if you are controlling the way the video is being played, stopped and paused.\r\n */\r\n independentVideoSource?: boolean;\r\n}\r\n\r\n/**\r\n * If you want to display a video in your scene, this is the special texture for that.\r\n * This special texture works similar to other textures, with the exception of a few parameters.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/videoTexture\r\n */\r\nexport class VideoTexture extends Texture {\r\n /**\r\n * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually\r\n */\r\n public readonly autoUpdateTexture: boolean;\r\n\r\n /**\r\n * The video instance used by the texture internally\r\n */\r\n public readonly video: HTMLVideoElement;\r\n\r\n private _externalTexture: Nullable<ExternalTexture>;\r\n private _onUserActionRequestedObservable: Nullable<Observable<Texture>> = null;\r\n\r\n /**\r\n * Event triggered when a dom action is required by the user to play the video.\r\n * This happens due to recent changes in browser policies preventing video to auto start.\r\n */\r\n public get onUserActionRequestedObservable(): Observable<Texture> {\r\n if (!this._onUserActionRequestedObservable) {\r\n this._onUserActionRequestedObservable = new Observable<Texture>();\r\n }\r\n return this._onUserActionRequestedObservable;\r\n }\r\n\r\n private _generateMipMaps: boolean;\r\n private _stillImageCaptured = false;\r\n private _displayingPosterTexture = false;\r\n private _settings: VideoTextureSettings;\r\n private _createInternalTextureOnEvent: string;\r\n private _frameId = -1;\r\n private _currentSrc: Nullable<string | string[] | HTMLVideoElement> = null;\r\n private _onError?: Nullable<(message?: string, exception?: any) => void>;\r\n private _errorFound = false;\r\n\r\n private _processError(reason: any) {\r\n this._errorFound = true;\r\n if (this._onError) {\r\n this._onError(reason?.message);\r\n } else {\r\n Logger.Error(reason?.message);\r\n }\r\n }\r\n\r\n private _handlePlay() {\r\n this._errorFound = false;\r\n this.video.play().catch((reason) => {\r\n if (reason?.name === \"NotAllowedError\") {\r\n if (this._onUserActionRequestedObservable && this._onUserActionRequestedObservable.hasObservers()) {\r\n this._onUserActionRequestedObservable.notifyObservers(this);\r\n return;\r\n } else if (!this.video.muted) {\r\n Logger.Warn(\"Unable to autoplay a video with sound. Trying again with muted turned true\");\r\n this.video.muted = true;\r\n this._errorFound = false;\r\n this.video.play().catch((otherReason) => {\r\n this._processError(otherReason);\r\n });\r\n return;\r\n }\r\n }\r\n\r\n this._processError(reason);\r\n });\r\n }\r\n\r\n /**\r\n * Creates a video texture.\r\n * If you want to display a video in your scene, this is the special texture for that.\r\n * This special texture works similar to other textures, with the exception of a few parameters.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/videoTexture\r\n * @param name optional name, will detect from video source, if not defined\r\n * @param src can be used to provide an url, array of urls or an already setup HTML video element.\r\n * @param scene is obviously the current scene.\r\n * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).\r\n * @param invertY is false by default but can be used to invert video on Y axis\r\n * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default\r\n * @param settings allows finer control over video usage\r\n * @param onError defines a callback triggered when an error occurred during the loading session\r\n * @param format defines the texture format to use (Engine.TEXTUREFORMAT_RGBA by default)\r\n */\r\n constructor(\r\n name: Nullable<string>,\r\n src: string | string[] | HTMLVideoElement,\r\n scene: Nullable<Scene>,\r\n generateMipMaps = false,\r\n invertY = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n settings: Partial<VideoTextureSettings> = {},\r\n onError?: Nullable<(message?: string, exception?: any) => void>,\r\n format: number = Constants.TEXTUREFORMAT_RGBA\r\n ) {\r\n super(null, scene, !generateMipMaps, invertY);\r\n\r\n this._settings = {\r\n autoPlay: true,\r\n loop: true,\r\n autoUpdateTexture: true,\r\n ...settings,\r\n };\r\n\r\n this._onError = onError;\r\n\r\n this._generateMipMaps = generateMipMaps;\r\n this._initialSamplingMode = samplingMode;\r\n this.autoUpdateTexture = this._settings.autoUpdateTexture;\r\n\r\n this._currentSrc = src;\r\n this.name = name || this._getName(src);\r\n this.video = this._getVideo(src);\r\n this._externalTexture = this._engine?.createExternalTexture(this.video) ?? null;\r\n if (!this._settings.independentVideoSource) {\r\n if (this._settings.poster) {\r\n this.video.poster = this._settings.poster;\r\n }\r\n if (this._settings.autoPlay !== undefined) {\r\n this.video.autoplay = this._settings.autoPlay;\r\n }\r\n if (this._settings.loop !== undefined) {\r\n this.video.loop = this._settings.loop;\r\n }\r\n if (this._settings.muted !== undefined) {\r\n this.video.muted = this._settings.muted;\r\n }\r\n\r\n this.video.setAttribute(\"playsinline\", \"\");\r\n this.video.addEventListener(\"paused\", this._updateInternalTexture);\r\n this.video.addEventListener(\"seeked\", this._updateInternalTexture);\r\n this.video.addEventListener(\"emptied\", this._reset);\r\n this.video.addEventListener(\"resize\", this._resizeInternalTexture);\r\n\r\n if (this._settings.autoPlay) {\r\n this._handlePlay();\r\n }\r\n }\r\n\r\n this._createInternalTextureOnEvent = this._settings.poster && !this._settings.autoPlay ? \"play\" : \"canplay\";\r\n this.video.addEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);\r\n this._format = format;\r\n\r\n const videoHasEnoughData = this.video.readyState >= this.video.HAVE_CURRENT_DATA;\r\n if (this._settings.poster && (!this._settings.autoPlay || !videoHasEnoughData)) {\r\n this._texture = this._getEngine()!.createTexture(this._settings.poster!, false, !this.invertY, scene);\r\n this._displayingPosterTexture = true;\r\n } else if (videoHasEnoughData) {\r\n this._createInternalTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Get the current class name of the video texture useful for serialization or dynamic coding.\r\n * @returns \"VideoTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"VideoTexture\";\r\n }\r\n\r\n private _getName(src: string | string[] | HTMLVideoElement): string {\r\n if (src instanceof HTMLVideoElement) {\r\n return src.currentSrc;\r\n }\r\n\r\n if (typeof src === \"object\") {\r\n return src.toString();\r\n }\r\n\r\n return src;\r\n }\r\n\r\n private _getVideo(src: string | string[] | HTMLVideoElement): HTMLVideoElement {\r\n if ((<any>src).isNative) {\r\n return <HTMLVideoElement>src;\r\n }\r\n if (src instanceof HTMLVideoElement) {\r\n Tools.SetCorsBehavior(src.currentSrc, src);\r\n return src;\r\n }\r\n const video: HTMLVideoElement = document.createElement(\"video\");\r\n if (typeof src === \"string\") {\r\n Tools.SetCorsBehavior(src, video);\r\n video.src = src;\r\n } else {\r\n Tools.SetCorsBehavior(src[0], video);\r\n src.forEach((url) => {\r\n const source = document.createElement(\"source\");\r\n source.src = url;\r\n video.appendChild(source);\r\n });\r\n }\r\n\r\n this.onDisposeObservable.addOnce(() => {\r\n removeSource(video);\r\n });\r\n\r\n return video;\r\n }\r\n\r\n private _resizeInternalTexture = (): void => {\r\n // Cleanup the old texture before replacing it\r\n if (this._texture != null) {\r\n this._texture.dispose();\r\n }\r\n\r\n if (!this._getEngine()!.needPOTTextures || (Tools.IsExponentOfTwo(this.video.videoWidth) && Tools.IsExponentOfTwo(this.video.videoHeight))) {\r\n this.wrapU = Texture.WRAP_ADDRESSMODE;\r\n this.wrapV = Texture.WRAP_ADDRESSMODE;\r\n } else {\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n this._generateMipMaps = false;\r\n }\r\n\r\n this._texture = this._getEngine()!.createDynamicTexture(this.video.videoWidth, this.video.videoHeight, this._generateMipMaps, this.samplingMode);\r\n this._texture.format = this._format ?? Constants.TEXTUREFORMAT_RGBA;\r\n\r\n // Reset the frame ID and update the new texture to ensure it pulls in the current video frame\r\n this._frameId = -1;\r\n this._updateInternalTexture();\r\n };\r\n\r\n private _createInternalTexture = (): void => {\r\n if (this._texture != null) {\r\n if (this._displayingPosterTexture) {\r\n this._displayingPosterTexture = false;\r\n } else {\r\n return;\r\n }\r\n }\r\n\r\n this._resizeInternalTexture();\r\n\r\n if (!this.video.autoplay && !this._settings.poster && !this._settings.independentVideoSource) {\r\n const oldHandler = this.video.onplaying;\r\n const oldMuted = this.video.muted;\r\n this.video.muted = true;\r\n this.video.onplaying = () => {\r\n this.video.muted = oldMuted;\r\n this.video.onplaying = oldHandler;\r\n this._updateInternalTexture();\r\n if (!this._errorFound) {\r\n this.video.pause();\r\n }\r\n if (this.onLoadObservable.hasObservers()) {\r\n this.onLoadObservable.notifyObservers(this);\r\n }\r\n };\r\n this._handlePlay();\r\n } else {\r\n this._updateInternalTexture();\r\n if (this.onLoadObservable.hasObservers()) {\r\n this.onLoadObservable.notifyObservers(this);\r\n }\r\n }\r\n };\r\n\r\n private _reset = (): void => {\r\n if (this._texture == null) {\r\n return;\r\n }\r\n\r\n if (!this._displayingPosterTexture) {\r\n this._texture.dispose();\r\n this._texture = null;\r\n }\r\n };\r\n\r\n /**\r\n * @internal Internal method to initiate `update`.\r\n */\r\n public _rebuild(): void {\r\n this.update();\r\n }\r\n\r\n /**\r\n * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.\r\n */\r\n public update(): void {\r\n if (!this.autoUpdateTexture) {\r\n // Expecting user to call `updateTexture` manually\r\n return;\r\n }\r\n\r\n this.updateTexture(true);\r\n }\r\n\r\n /**\r\n * Update Texture in `manual` mode. Does not do anything if not visible or paused.\r\n * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.\r\n */\r\n public updateTexture(isVisible: boolean): void {\r\n if (!isVisible) {\r\n return;\r\n }\r\n if (this.video.paused && this._stillImageCaptured) {\r\n return;\r\n }\r\n this._stillImageCaptured = true;\r\n this._updateInternalTexture();\r\n }\r\n\r\n protected _updateInternalTexture = (): void => {\r\n if (this._texture == null) {\r\n return;\r\n }\r\n if (this.video.readyState < this.video.HAVE_CURRENT_DATA) {\r\n return;\r\n }\r\n if (this._displayingPosterTexture) {\r\n return;\r\n }\r\n\r\n const frameId = this.getScene()!.getFrameId();\r\n if (this._frameId === frameId) {\r\n return;\r\n }\r\n\r\n this._frameId = frameId;\r\n\r\n this._getEngine()!.updateVideoTexture(this._texture, this._externalTexture ? this._externalTexture : this.video, this._invertY);\r\n };\r\n\r\n /**\r\n * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.\r\n * @param url New url.\r\n */\r\n public updateURL(url: string): void {\r\n this.video.src = url;\r\n this._currentSrc = url;\r\n }\r\n\r\n /**\r\n * Clones the texture.\r\n * @returns the cloned texture\r\n */\r\n public clone(): VideoTexture {\r\n return new VideoTexture(this.name, this._currentSrc!, this.getScene(), this._generateMipMaps, this.invertY, this.samplingMode, this._settings);\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public dispose(): void {\r\n super.dispose();\r\n\r\n this._currentSrc = null;\r\n\r\n if (this._onUserActionRequestedObservable) {\r\n this._onUserActionRequestedObservable.clear();\r\n this._onUserActionRequestedObservable = null;\r\n }\r\n\r\n this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);\r\n if (!this._settings.independentVideoSource) {\r\n this.video.removeEventListener(\"paused\", this._updateInternalTexture);\r\n this.video.removeEventListener(\"seeked\", this._updateInternalTexture);\r\n this.video.removeEventListener(\"emptied\", this._reset);\r\n this.video.removeEventListener(\"resize\", this._resizeInternalTexture);\r\n this.video.pause();\r\n }\r\n\r\n this._externalTexture?.dispose();\r\n }\r\n\r\n /**\r\n * Creates a video texture straight from a stream.\r\n * @param scene Define the scene the texture should be created in\r\n * @param stream Define the stream the texture should be created from\r\n * @param constraints video constraints\r\n * @param invertY Defines if the video should be stored with invert Y set to true (true by default)\r\n * @returns The created video texture as a promise\r\n */\r\n public static CreateFromStreamAsync(scene: Scene, stream: MediaStream, constraints: any, invertY = true): Promise<VideoTexture> {\r\n const video = scene.getEngine().createVideoElement(constraints);\r\n\r\n if (scene.getEngine()._badOS) {\r\n // Yes... I know and I hope to remove it soon...\r\n document.body.appendChild(video);\r\n video.style.transform = \"scale(0.0001, 0.0001)\";\r\n video.style.opacity = \"0\";\r\n video.style.position = \"fixed\";\r\n video.style.bottom = \"0px\";\r\n video.style.right = \"0px\";\r\n }\r\n\r\n video.setAttribute(\"autoplay\", \"\");\r\n video.setAttribute(\"muted\", \"true\");\r\n video.setAttribute(\"playsinline\", \"\");\r\n video.muted = true;\r\n\r\n if (video.isNative) {\r\n // No additional configuration needed for native\r\n } else if (video.mozSrcObject !== undefined) {\r\n // hack for Firefox < 19\r\n video.mozSrcObject = stream;\r\n } else {\r\n if (typeof video.srcObject == \"object\") {\r\n video.srcObject = stream;\r\n } else {\r\n // older API. See https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL#using_object_urls_for_media_streams\r\n video.src = window.URL && window.URL.createObjectURL(stream as any);\r\n }\r\n }\r\n\r\n return new Promise<VideoTexture>((resolve) => {\r\n const onPlaying = () => {\r\n const videoTexture = new VideoTexture(\"video\", video, scene, true, invertY, undefined, undefined, undefined, Constants.TEXTUREFORMAT_RGB);\r\n if (scene.getEngine()._badOS) {\r\n videoTexture.onDisposeObservable.addOnce(() => {\r\n video.remove();\r\n });\r\n }\r\n videoTexture.onDisposeObservable.addOnce(() => {\r\n removeSource(video);\r\n });\r\n\r\n resolve(videoTexture);\r\n video.removeEventListener(\"playing\", onPlaying);\r\n };\r\n\r\n video.addEventListener(\"playing\", onPlaying);\r\n video.play();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a video texture straight from your WebCam video feed.\r\n * @param scene Define the scene the texture should be created in\r\n * @param constraints Define the constraints to use to create the web cam feed from WebRTC\r\n * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC\r\n * @param invertY Defines if the video should be stored with invert Y set to true (true by default)\r\n * @returns The created video texture as a promise\r\n */\r\n public static async CreateFromWebCamAsync(\r\n scene: Scene,\r\n constraints: {\r\n minWidth: number;\r\n maxWidth: number;\r\n minHeight: number;\r\n maxHeight: number;\r\n deviceId: string;\r\n } & MediaTrackConstraints,\r\n audioConstaints: boolean | MediaTrackConstraints = false,\r\n invertY = true\r\n ): Promise<VideoTexture> {\r\n if (navigator.mediaDevices) {\r\n const stream = await navigator.mediaDevices.getUserMedia({\r\n video: constraints,\r\n audio: audioConstaints,\r\n });\r\n\r\n const videoTexture = await this.CreateFromStreamAsync(scene, stream, constraints, invertY);\r\n videoTexture.onDisposeObservable.addOnce(() => {\r\n stream.getTracks().forEach((track) => {\r\n track.stop();\r\n });\r\n });\r\n\r\n return videoTexture;\r\n }\r\n\r\n return Promise.reject(\"No support for userMedia on this device\");\r\n }\r\n\r\n /**\r\n * Creates a video texture straight from your WebCam video feed.\r\n * @param scene Defines the scene the texture should be created in\r\n * @param onReady Defines a callback to triggered once the texture will be ready\r\n * @param constraints Defines the constraints to use to create the web cam feed from WebRTC\r\n * @param audioConstaints Defines the audio constraints to use to create the web cam feed from WebRTC\r\n * @param invertY Defines if the video should be stored with invert Y set to true (true by default)\r\n */\r\n public static CreateFromWebCam(\r\n scene: Scene,\r\n onReady: (videoTexture: VideoTexture) => void,\r\n constraints: {\r\n minWidth: number;\r\n maxWidth: number;\r\n minHeight: number;\r\n maxHeight: number;\r\n deviceId: string;\r\n } & MediaTrackConstraints,\r\n audioConstaints: boolean | MediaTrackConstraints = false,\r\n invertY = true\r\n ): void {\r\n this.CreateFromWebCamAsync(scene, constraints, audioConstaints, invertY)\r\n .then(function (videoTexture) {\r\n if (onReady) {\r\n onReady(videoTexture);\r\n }\r\n })\r\n .catch(function (err) {\r\n Logger.Error(err.name);\r\n });\r\n }\r\n}\r\n"]}
@@ -2,3 +2,4 @@ export * from "./v1/index";
2
2
  export * from "./v2/index";
3
3
  export * from "./physicsEngineComponent";
4
4
  export * from "./v1/physicsEngineComponent";
5
+ export * from "./physicsHelper";
package/Physics/index.js CHANGED
@@ -3,4 +3,5 @@ export * from "./v1/index.js";
3
3
  export * from "./v2/index.js";
4
4
  export * from "./physicsEngineComponent.js";
5
5
  export * from "./v1/physicsEngineComponent.js";
6
+ export * from "./physicsHelper.js";
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lts/core/generated/Physics/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./v1/index\";\r\nexport * from \"./v2/index\";\r\nexport * from \"./physicsEngineComponent\";\r\nexport * from \"./v1/physicsEngineComponent\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lts/core/generated/Physics/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./v1/index\";\r\nexport * from \"./v2/index\";\r\nexport * from \"./physicsEngineComponent\";\r\nexport * from \"./v1/physicsEngineComponent\";\r\nexport * from \"./physicsHelper\";\r\n"]}
@@ -1 +1,452 @@
1
- export * from "./v1/physicsHelper";
1
+ import type { Nullable } from "../types";
2
+ import { Vector3 } from "../Maths/math.vector";
3
+ import type { Mesh } from "../Meshes/mesh";
4
+ import type { Scene } from "../scene";
5
+ import type { PhysicsImpostor } from "./v1/physicsImpostor";
6
+ import type { PhysicsBody } from "./v2/physicsBody";
7
+ /**
8
+ * A helper for physics simulations
9
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
10
+ */
11
+ export declare class PhysicsHelper {
12
+ private _scene;
13
+ private _physicsEngine;
14
+ private _hitData;
15
+ /**
16
+ * Initializes the Physics helper
17
+ * @param scene Babylon.js scene
18
+ */
19
+ constructor(scene: Scene);
20
+ /**
21
+ * Applies a radial explosion impulse
22
+ * @param origin the origin of the explosion
23
+ * @param radiusOrEventOptions the radius or the options of radial explosion
24
+ * @param strength the explosion strength
25
+ * @param falloff possible options: Constant & Linear. Defaults to Constant
26
+ * @returns A physics radial explosion event, or null
27
+ */
28
+ applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
29
+ /**
30
+ * Applies a radial explosion force
31
+ * @param origin the origin of the explosion
32
+ * @param radiusOrEventOptions the radius or the options of radial explosion
33
+ * @param strength the explosion strength
34
+ * @param falloff possible options: Constant & Linear. Defaults to Constant
35
+ * @returns A physics radial explosion event, or null
36
+ */
37
+ applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
38
+ /**
39
+ * Creates a gravitational field
40
+ * @param origin the origin of the gravitational field
41
+ * @param radiusOrEventOptions the radius or the options of radial gravitational field
42
+ * @param strength the gravitational field strength
43
+ * @param falloff possible options: Constant & Linear. Defaults to Constant
44
+ * @returns A physics gravitational field event, or null
45
+ */
46
+ gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
47
+ /**
48
+ * Creates a physics updraft event
49
+ * @param origin the origin of the updraft
50
+ * @param radiusOrEventOptions the radius or the options of the updraft
51
+ * @param strength the strength of the updraft
52
+ * @param height the height of the updraft
53
+ * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
54
+ * @returns A physics updraft event, or null
55
+ */
56
+ updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
57
+ /**
58
+ * Creates a physics vortex event
59
+ * @param origin the of the vortex
60
+ * @param radiusOrEventOptions the radius or the options of the vortex
61
+ * @param strength the strength of the vortex
62
+ * @param height the height of the vortex
63
+ * @returns a Physics vortex event, or null
64
+ * A physics vortex event or null
65
+ */
66
+ vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
67
+ private _copyPhysicsHitData;
68
+ }
69
+ /**
70
+ * Represents a physics radial explosion event
71
+ */
72
+ declare class PhysicsRadialExplosionEvent {
73
+ private _scene;
74
+ private _options;
75
+ private _sphere;
76
+ private _dataFetched;
77
+ /**
78
+ * Initializes a radial explosion event
79
+ * @param _scene BabylonJS scene
80
+ * @param _options The options for the vortex event
81
+ */
82
+ constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
83
+ /**
84
+ * Returns the data related to the radial explosion event (sphere).
85
+ * @returns The radial explosion event data
86
+ */
87
+ getData(): PhysicsRadialExplosionEventData;
88
+ private _getHitData;
89
+ /**
90
+ * Returns the force and contact point of the body or false, if the body is not affected by the force/impulse.
91
+ * @param body A physics body
92
+ * @param origin the origin of the explosion
93
+ * @returns A physics force and contact point, or null
94
+ */
95
+ getBodyHitData(body: PhysicsBody, origin: Vector3, data: PhysicsHitData): boolean;
96
+ /**
97
+ * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
98
+ * @param impostor A physics imposter
99
+ * @param origin the origin of the explosion
100
+ * @returns A physics force and contact point, or null
101
+ */
102
+ getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3, data: PhysicsHitData): boolean;
103
+ /**
104
+ * Triggers affected impostors callbacks
105
+ * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
106
+ */
107
+ triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
108
+ /**
109
+ * Triggers affected bodies callbacks
110
+ * @param affectedBodiesWithData defines the list of affected bodies (including associated data)
111
+ */
112
+ triggerAffectedBodiesCallback(affectedBodiesWithData: Array<PhysicsAffectedBodyWithData>): void;
113
+ /**
114
+ * Disposes the sphere.
115
+ * @param force Specifies if the sphere should be disposed by force
116
+ */
117
+ dispose(force?: boolean): void;
118
+ /*** Helpers ***/
119
+ private _prepareSphere;
120
+ private _intersectsWithSphere;
121
+ }
122
+ /**
123
+ * Represents a gravitational field event
124
+ */
125
+ declare class PhysicsGravitationalFieldEvent {
126
+ private _physicsHelper;
127
+ private _scene;
128
+ private _origin;
129
+ private _options;
130
+ private _tickCallback;
131
+ private _sphere;
132
+ private _dataFetched;
133
+ /**
134
+ * Initializes the physics gravitational field event
135
+ * @param _physicsHelper A physics helper
136
+ * @param _scene BabylonJS scene
137
+ * @param _origin The origin position of the gravitational field event
138
+ * @param _options The options for the vortex event
139
+ */
140
+ constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
141
+ /**
142
+ * Returns the data related to the gravitational field event (sphere).
143
+ * @returns A gravitational field event
144
+ */
145
+ getData(): PhysicsGravitationalFieldEventData;
146
+ /**
147
+ * Enables the gravitational field.
148
+ */
149
+ enable(): void;
150
+ /**
151
+ * Disables the gravitational field.
152
+ */
153
+ disable(): void;
154
+ /**
155
+ * Disposes the sphere.
156
+ * @param force The force to dispose from the gravitational field event
157
+ */
158
+ dispose(force?: boolean): void;
159
+ private _tick;
160
+ }
161
+ /**
162
+ * Represents a physics updraft event
163
+ */
164
+ declare class PhysicsUpdraftEvent {
165
+ private _scene;
166
+ private _origin;
167
+ private _options;
168
+ private _physicsEngine;
169
+ private _originTop;
170
+ private _originDirection;
171
+ private _tickCallback;
172
+ private _cylinder;
173
+ private _cylinderPosition;
174
+ private _dataFetched;
175
+ private static hitData;
176
+ /**
177
+ * Initializes the physics updraft event
178
+ * @param _scene BabylonJS scene
179
+ * @param _origin The origin position of the updraft
180
+ * @param _options The options for the updraft event
181
+ */
182
+ constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
183
+ /**
184
+ * Returns the data related to the updraft event (cylinder).
185
+ * @returns A physics updraft event
186
+ */
187
+ getData(): PhysicsUpdraftEventData;
188
+ /**
189
+ * Enables the updraft.
190
+ */
191
+ enable(): void;
192
+ /**
193
+ * Disables the updraft.
194
+ */
195
+ disable(): void;
196
+ /**
197
+ * Disposes the cylinder.
198
+ * @param force Specifies if the updraft should be disposed by force
199
+ */
200
+ dispose(force?: boolean): void;
201
+ private _getHitData;
202
+ private _getBodyHitData;
203
+ private _getImpostorHitData;
204
+ private _tick;
205
+ /*** Helpers ***/
206
+ private _prepareCylinder;
207
+ private _intersectsWithCylinder;
208
+ }
209
+ /**
210
+ * Represents a physics vortex event
211
+ */
212
+ declare class PhysicsVortexEvent {
213
+ private _scene;
214
+ private _origin;
215
+ private _options;
216
+ private _physicsEngine;
217
+ private _originTop;
218
+ private _tickCallback;
219
+ private _cylinder;
220
+ private _cylinderPosition;
221
+ private _dataFetched;
222
+ private static originOnPlane;
223
+ private static hitData;
224
+ /**
225
+ * Initializes the physics vortex event
226
+ * @param _scene The BabylonJS scene
227
+ * @param _origin The origin position of the vortex
228
+ * @param _options The options for the vortex event
229
+ */
230
+ constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
231
+ /**
232
+ * Returns the data related to the vortex event (cylinder).
233
+ * @returns The physics vortex event data
234
+ */
235
+ getData(): PhysicsVortexEventData;
236
+ /**
237
+ * Enables the vortex.
238
+ */
239
+ enable(): void;
240
+ /**
241
+ * Disables the cortex.
242
+ */
243
+ disable(): void;
244
+ /**
245
+ * Disposes the sphere.
246
+ * @param force
247
+ */
248
+ dispose(force?: boolean): void;
249
+ private _getHitData;
250
+ private _getBodyHitData;
251
+ private _getImpostorHitData;
252
+ private _tick;
253
+ /*** Helpers ***/
254
+ private _prepareCylinder;
255
+ private _intersectsWithCylinder;
256
+ }
257
+ /**
258
+ * Options fot the radial explosion event
259
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
260
+ */
261
+ export declare class PhysicsRadialExplosionEventOptions {
262
+ /**
263
+ * The radius of the sphere for the radial explosion.
264
+ */
265
+ radius: number;
266
+ /**
267
+ * The strength of the explosion.
268
+ */
269
+ strength: number;
270
+ /**
271
+ * The strength of the force in correspondence to the distance of the affected object
272
+ */
273
+ falloff: PhysicsRadialImpulseFalloff;
274
+ /**
275
+ * Sphere options for the radial explosion.
276
+ */
277
+ sphere: {
278
+ segments: number;
279
+ diameter: number;
280
+ };
281
+ /**
282
+ * Sphere options for the radial explosion.
283
+ */
284
+ affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
285
+ /**
286
+ * Sphere options for the radial explosion.
287
+ */
288
+ affectedBodiesCallback: (affectedBodiesWithData: Array<PhysicsAffectedBodyWithData>) => void;
289
+ }
290
+ /**
291
+ * Options fot the updraft event
292
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
293
+ */
294
+ export declare class PhysicsUpdraftEventOptions {
295
+ /**
296
+ * The radius of the cylinder for the vortex
297
+ */
298
+ radius: number;
299
+ /**
300
+ * The strength of the updraft.
301
+ */
302
+ strength: number;
303
+ /**
304
+ * The height of the cylinder for the updraft.
305
+ */
306
+ height: number;
307
+ /**
308
+ * The mode for the the updraft.
309
+ */
310
+ updraftMode: PhysicsUpdraftMode;
311
+ }
312
+ /**
313
+ * Options fot the vortex event
314
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
315
+ */
316
+ export declare class PhysicsVortexEventOptions {
317
+ /**
318
+ * The radius of the cylinder for the vortex
319
+ */
320
+ radius: number;
321
+ /**
322
+ * The strength of the vortex.
323
+ */
324
+ strength: number;
325
+ /**
326
+ * The height of the cylinder for the vortex.
327
+ */
328
+ height: number;
329
+ /**
330
+ * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
331
+ */
332
+ centripetalForceThreshold: number;
333
+ /**
334
+ * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
335
+ */
336
+ centripetalForceMultiplier: number;
337
+ /**
338
+ * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
339
+ */
340
+ centrifugalForceMultiplier: number;
341
+ /**
342
+ * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
343
+ */
344
+ updraftForceMultiplier: number;
345
+ }
346
+ /**
347
+ * The strength of the force in correspondence to the distance of the affected object
348
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
349
+ */
350
+ export declare enum PhysicsRadialImpulseFalloff {
351
+ /** Defines that impulse is constant in strength across it's whole radius */
352
+ Constant = 0,
353
+ /** Defines that impulse gets weaker if it's further from the origin */
354
+ Linear = 1
355
+ }
356
+ /**
357
+ * The strength of the force in correspondence to the distance of the affected object
358
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
359
+ */
360
+ export declare enum PhysicsUpdraftMode {
361
+ /** Defines that the upstream forces will pull towards the top center of the cylinder */
362
+ Center = 0,
363
+ /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
364
+ Perpendicular = 1
365
+ }
366
+ /**
367
+ * Interface for a physics hit data
368
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
369
+ */
370
+ export interface PhysicsHitData {
371
+ /**
372
+ * The force applied at the contact point
373
+ */
374
+ force: Vector3;
375
+ /**
376
+ * The contact point
377
+ */
378
+ contactPoint: Vector3;
379
+ /**
380
+ * The distance from the origin to the contact point
381
+ */
382
+ distanceFromOrigin: number;
383
+ }
384
+ /**
385
+ * Interface for radial explosion event data
386
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
387
+ */
388
+ export interface PhysicsRadialExplosionEventData {
389
+ /**
390
+ * A sphere used for the radial explosion event
391
+ */
392
+ sphere: Mesh;
393
+ }
394
+ /**
395
+ * Interface for gravitational field event data
396
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
397
+ */
398
+ export interface PhysicsGravitationalFieldEventData {
399
+ /**
400
+ * A sphere mesh used for the gravitational field event
401
+ */
402
+ sphere: Mesh;
403
+ }
404
+ /**
405
+ * Interface for updraft event data
406
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
407
+ */
408
+ export interface PhysicsUpdraftEventData {
409
+ /**
410
+ * A cylinder used for the updraft event
411
+ */
412
+ cylinder: Mesh;
413
+ }
414
+ /**
415
+ * Interface for vortex event data
416
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
417
+ */
418
+ export interface PhysicsVortexEventData {
419
+ /**
420
+ * A cylinder used for the vortex event
421
+ */
422
+ cylinder: Mesh;
423
+ }
424
+ /**
425
+ * Interface for an affected physics impostor
426
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
427
+ */
428
+ export interface PhysicsAffectedImpostorWithData {
429
+ /**
430
+ * The impostor affected by the effect
431
+ */
432
+ impostor: PhysicsImpostor;
433
+ /**
434
+ * The data about the hit/force from the explosion
435
+ */
436
+ hitData: PhysicsHitData;
437
+ }
438
+ /**
439
+ * Interface for an affected physics body
440
+ * @see
441
+ */
442
+ export interface PhysicsAffectedBodyWithData {
443
+ /**
444
+ * The impostor affected by the effect
445
+ */
446
+ body: PhysicsBody;
447
+ /**
448
+ * The data about the hit/force from the explosion
449
+ */
450
+ hitData: PhysicsHitData;
451
+ }
452
+ export {};