@babylonjs/core 9.12.1 → 9.14.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.
- package/Animations/runtimeAnimation.js +11 -0
- package/Animations/runtimeAnimation.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.d.ts +2 -1
- package/AudioV2/abstractAudio/abstractSound.js +3 -2
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSoundInstance.d.ts +1 -1
- package/AudioV2/abstractAudio/abstractSoundInstance.js.map +1 -1
- package/AudioV2/abstractAudio/staticSound.d.ts +6 -0
- package/AudioV2/abstractAudio/staticSound.js +9 -1
- package/AudioV2/abstractAudio/staticSound.js.map +1 -1
- package/AudioV2/abstractAudio/streamingSound.d.ts +6 -0
- package/AudioV2/abstractAudio/streamingSound.js +9 -1
- package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +6 -3
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.d.ts +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +7 -4
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Cameras/arcRotateCamera.pure.js +9 -3
- package/Cameras/arcRotateCamera.pure.js.map +1 -1
- package/Cameras/targetCamera.pure.js +18 -18
- package/Cameras/targetCamera.pure.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +111 -4
- package/Collisions/gpuPicker.js +696 -119
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +4 -2
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Native/nativeRenderTargetWrapper.d.ts +3 -0
- package/Engines/Native/nativeRenderTargetWrapper.js +24 -1
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js +16 -3
- package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +8 -1
- package/Engines/abstractEngine.pure.js +4 -3
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/engine.d.ts +113 -0
- package/Engines/nullEngine.pure.js +5 -1
- package/Engines/nullEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +5 -0
- package/Engines/thinNativeEngine.pure.js +158 -13
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/FlowGraph/flowGraph.js +9 -0
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.pure.d.ts +14 -0
- package/FlowGraph/flowGraphDataConnection.pure.js +38 -1
- package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
- package/FlowGraph/serialization.d.ts +11 -0
- package/FlowGraph/serialization.js +11 -1
- package/FlowGraph/serialization.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.d.ts +2 -2
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js +43 -51
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.d.ts +0 -1
- package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js +63 -35
- package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.pure.d.ts +1 -1
- package/Lights/Clustered/clusteredLightContainer.pure.js +2 -2
- package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
- package/Lights/areaLight.pure.js +5 -0
- package/Lights/areaLight.pure.js.map +1 -1
- package/Lights/light.d.ts +4 -2
- package/Lights/light.js +10 -4
- package/Lights/light.js.map +1 -1
- package/Lights/rectAreaLight.pure.d.ts +17 -0
- package/Lights/rectAreaLight.pure.js +67 -0
- package/Lights/rectAreaLight.pure.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.pure.js +1 -1
- package/Loading/Plugins/babylonFileLoader.pure.js.map +1 -1
- package/Loading/sceneLoader.d.ts +5 -1
- package/Loading/sceneLoader.js +298 -401
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.d.ts +15 -0
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +34 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +9 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +26 -2
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +3 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +43 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +64 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -0
- package/Materials/Textures/HTML/htmlInteractionManager.d.ts +69 -0
- package/Materials/Textures/HTML/htmlInteractionManager.js +130 -0
- package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -0
- package/Materials/Textures/HTML/htmlRaycastInteractionManager.d.ts +84 -0
- package/Materials/Textures/HTML/htmlRaycastInteractionManager.js +246 -0
- package/Materials/Textures/HTML/htmlRaycastInteractionManager.js.map +1 -0
- package/Materials/Textures/HTML/htmlTexture.d.ts +148 -0
- package/Materials/Textures/HTML/htmlTexture.js +455 -0
- package/Materials/Textures/HTML/htmlTexture.js.map +1 -0
- package/Materials/Textures/HTML/index.d.ts +4 -0
- package/Materials/Textures/HTML/index.js +5 -0
- package/Materials/Textures/HTML/index.js.map +1 -0
- package/Materials/Textures/HTML/pure.d.ts +5 -0
- package/Materials/Textures/HTML/pure.js +6 -0
- package/Materials/Textures/HTML/pure.js.map +1 -0
- package/Materials/Textures/index.d.ts +1 -0
- package/Materials/Textures/index.js +1 -1
- package/Materials/Textures/index.js.map +1 -1
- package/Materials/Textures/pure.d.ts +1 -0
- package/Materials/Textures/pure.js +1 -0
- package/Materials/Textures/pure.js.map +1 -1
- package/Materials/Textures/videoTexture.pure.d.ts +3 -0
- package/Materials/Textures/videoTexture.pure.js +30 -0
- package/Materials/Textures/videoTexture.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +36 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +56 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.d.ts +3 -1
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +210 -48
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +1 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +34 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +1 -0
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/gaussianSplatting.fragment.js +17 -1
- package/Shaders/gaussianSplatting.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +1 -1
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
- package/Shaders/picking.fragment.js +39 -3
- package/Shaders/picking.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +3 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +4 -3
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js +14 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/picking.fragment.js +22 -1
- package/ShadersWGSL/picking.fragment.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ export * from "./envCubeTexture.pure.js";
|
|
|
11
11
|
export * from "./hdrCubeTexture.pure.js";
|
|
12
12
|
export * from "./exrCubeTexture.pure.js";
|
|
13
13
|
export * from "./htmlElementTexture.pure.js";
|
|
14
|
+
export * from "./HTML/pure.js";
|
|
14
15
|
export * from "./internalTexture.js";
|
|
15
16
|
export * from "./Loaders/pure.js";
|
|
16
17
|
export * from "./mirrorTexture.pure.js";
|
|
@@ -12,6 +12,7 @@ export * from "./envCubeTexture.pure.js";
|
|
|
12
12
|
export * from "./hdrCubeTexture.pure.js";
|
|
13
13
|
export * from "./exrCubeTexture.pure.js";
|
|
14
14
|
export * from "./htmlElementTexture.pure.js";
|
|
15
|
+
export * from "./HTML/pure.js";
|
|
15
16
|
export * from "./internalTexture.js";
|
|
16
17
|
export * from "./Loaders/pure.js";
|
|
17
18
|
export * from "./mirrorTexture.pure.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\n/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./baseTexture.pure\";\nexport * from \"./baseTexture.polynomial.pure\";\nexport * from \"./colorGradingTexture.pure\";\nexport * from \"./cubeTexture.pure\";\nexport * from \"./dynamicTexture.pure\";\nexport * from \"./equiRectangularCubeTexture.pure\";\nexport * from \"./externalTexture\";\nexport * from \"./Filtering/hdrFiltering\";\nexport * from \"./envCubeTexture.pure\";\nexport * from \"./hdrCubeTexture.pure\";\nexport * from \"./exrCubeTexture.pure\";\nexport * from \"./htmlElementTexture.pure\";\nexport * from \"./internalTexture\";\nexport * from \"./Loaders/pure\";\nexport * from \"./mirrorTexture.pure\";\nexport * from \"./multiRenderTarget.pure\";\nexport * from \"./Packer/pure\";\nexport * from \"./Procedurals/pure\";\nexport * from \"./rawCubeTexture\";\nexport * from \"./rawTexture\";\nexport * from \"./rawTexture2DArray\";\nexport * from \"./rawTexture3D\";\nexport * from \"./refractionTexture\";\nexport * from \"./renderTargetTexture.pure\";\nexport * from \"./textureMerger\";\nexport * from \"./textureSampler\";\nexport * from \"./textureProcessor\";\nexport * from \"./texture.pure\";\nexport * from \"./thinTexture\";\nexport * from \"./thinRenderTargetTexture\";\nexport * from \"./videoTexture.pure\";\nexport * from \"./ktx2decoderTypes\";\nexport * from \"./textureCreationOptions\";\n"]}
|
|
1
|
+
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\n/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./baseTexture.pure\";\nexport * from \"./baseTexture.polynomial.pure\";\nexport * from \"./colorGradingTexture.pure\";\nexport * from \"./cubeTexture.pure\";\nexport * from \"./dynamicTexture.pure\";\nexport * from \"./equiRectangularCubeTexture.pure\";\nexport * from \"./externalTexture\";\nexport * from \"./Filtering/hdrFiltering\";\nexport * from \"./envCubeTexture.pure\";\nexport * from \"./hdrCubeTexture.pure\";\nexport * from \"./exrCubeTexture.pure\";\nexport * from \"./htmlElementTexture.pure\";\nexport * from \"./HTML/pure\";\nexport * from \"./internalTexture\";\nexport * from \"./Loaders/pure\";\nexport * from \"./mirrorTexture.pure\";\nexport * from \"./multiRenderTarget.pure\";\nexport * from \"./Packer/pure\";\nexport * from \"./Procedurals/pure\";\nexport * from \"./rawCubeTexture\";\nexport * from \"./rawTexture\";\nexport * from \"./rawTexture2DArray\";\nexport * from \"./rawTexture3D\";\nexport * from \"./refractionTexture\";\nexport * from \"./renderTargetTexture.pure\";\nexport * from \"./textureMerger\";\nexport * from \"./textureSampler\";\nexport * from \"./textureProcessor\";\nexport * from \"./texture.pure\";\nexport * from \"./thinTexture\";\nexport * from \"./thinRenderTargetTexture\";\nexport * from \"./videoTexture.pure\";\nexport * from \"./ktx2decoderTypes\";\nexport * from \"./textureCreationOptions\";\n"]}
|
|
@@ -53,6 +53,7 @@ export declare class VideoTexture extends Texture {
|
|
|
53
53
|
*/
|
|
54
54
|
readonly video: HTMLVideoElement;
|
|
55
55
|
private _externalTexture;
|
|
56
|
+
private _snapshotRenderingObserver;
|
|
56
57
|
private _onUserActionRequestedObservable;
|
|
57
58
|
/**
|
|
58
59
|
* Event triggered when a dom action is required by the user to play the video.
|
|
@@ -113,6 +114,8 @@ export declare class VideoTexture extends Texture {
|
|
|
113
114
|
* @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
|
|
114
115
|
*/
|
|
115
116
|
updateTexture(isVisible: boolean): void;
|
|
117
|
+
private _updateWhileSnapshotRendering;
|
|
118
|
+
private _resetSnapshotRenderingIfFast;
|
|
116
119
|
protected _updateInternalTexture: () => void;
|
|
117
120
|
/**
|
|
118
121
|
* Get the underlying external texture (if supported by the current engine, else null)
|
|
@@ -86,6 +86,7 @@ export class VideoTexture extends Texture {
|
|
|
86
86
|
constructor(name, src, scene, generateMipMaps = false, invertY = false, samplingMode = Texture.TRILINEAR_SAMPLINGMODE, settings = {}, onError, format = 5) {
|
|
87
87
|
super(null, scene, !generateMipMaps, invertY);
|
|
88
88
|
this._externalTexture = null;
|
|
89
|
+
this._snapshotRenderingObserver = null;
|
|
89
90
|
this._onUserActionRequestedObservable = null;
|
|
90
91
|
this._stillImageCaptured = false;
|
|
91
92
|
this._displayingPosterTexture = false;
|
|
@@ -112,6 +113,9 @@ export class VideoTexture extends Texture {
|
|
|
112
113
|
}
|
|
113
114
|
this._texture = this._getEngine().createDynamicTexture(this.video.videoWidth, this.video.videoHeight, this._generateMipMaps, this.samplingMode);
|
|
114
115
|
this._texture.format = this._format ?? 5;
|
|
116
|
+
// The internal texture (bound by materials) was just recreated. A recorded FAST snapshot bundle still
|
|
117
|
+
// references the previous GPU texture, so force a snapshot reset to re-record against the new texture.
|
|
118
|
+
this._resetSnapshotRenderingIfFast();
|
|
115
119
|
// Reset the frame ID and update the new texture to ensure it pulls in the current video frame
|
|
116
120
|
this._frameId = -1;
|
|
117
121
|
this._updateInternalTexture();
|
|
@@ -160,6 +164,12 @@ export class VideoTexture extends Texture {
|
|
|
160
164
|
this._texture = null;
|
|
161
165
|
}
|
|
162
166
|
};
|
|
167
|
+
this._updateWhileSnapshotRendering = () => {
|
|
168
|
+
const engine = this._engine;
|
|
169
|
+
if (engine && engine.snapshotRendering && engine.snapshotRenderingMode === 1) {
|
|
170
|
+
this.update();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
163
173
|
this._updateInternalTexture = () => {
|
|
164
174
|
if (this._texture == null) {
|
|
165
175
|
return;
|
|
@@ -195,6 +205,15 @@ export class VideoTexture extends Texture {
|
|
|
195
205
|
if (createExternalTexture) {
|
|
196
206
|
this._externalTexture = createExternalTexture.call(engineWebGPU, this.video);
|
|
197
207
|
}
|
|
208
|
+
if (this._externalTexture) {
|
|
209
|
+
// Under FAST snapshot rendering the active meshes are not re-evaluated each frame, so materials
|
|
210
|
+
// (and the video textures they bind) are never re-bound and VideoTexture.update() is never called.
|
|
211
|
+
// Drive the per-frame update from a scene hook so the video keeps playing while snapshot rendering is active.
|
|
212
|
+
const ownerScene = this.getScene();
|
|
213
|
+
if (ownerScene) {
|
|
214
|
+
this._snapshotRenderingObserver = ownerScene.onBeforeRenderObservable.add(this._updateWhileSnapshotRendering);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
198
217
|
if (!this._settings.independentVideoSource) {
|
|
199
218
|
if (this._settings.poster) {
|
|
200
219
|
this.video.poster = this._settings.poster;
|
|
@@ -301,6 +320,12 @@ export class VideoTexture extends Texture {
|
|
|
301
320
|
this._stillImageCaptured = true;
|
|
302
321
|
this._updateInternalTexture();
|
|
303
322
|
}
|
|
323
|
+
_resetSnapshotRenderingIfFast() {
|
|
324
|
+
const engine = this._engine;
|
|
325
|
+
if (engine?.snapshotRendering && engine.snapshotRenderingMode === 1) {
|
|
326
|
+
engine.snapshotRenderingReset();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
304
329
|
/**
|
|
305
330
|
* Get the underlying external texture (if supported by the current engine, else null)
|
|
306
331
|
*/
|
|
@@ -326,6 +351,11 @@ export class VideoTexture extends Texture {
|
|
|
326
351
|
* Dispose the texture and release its associated resources.
|
|
327
352
|
*/
|
|
328
353
|
dispose() {
|
|
354
|
+
if (this._snapshotRenderingObserver) {
|
|
355
|
+
// Remove the per-frame snapshot rendering hook before super.dispose() clears the scene reference.
|
|
356
|
+
this.getScene()?.onBeforeRenderObservable.remove(this._snapshotRenderingObserver);
|
|
357
|
+
this._snapshotRenderingObserver = null;
|
|
358
|
+
}
|
|
329
359
|
super.dispose();
|
|
330
360
|
this._currentSrc = null;
|
|
331
361
|
if (this._onUserActionRequestedObservable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoTexture.pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/videoTexture.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,SAAS,YAAY,CAAC,KAAuB;IACzC,qCAAqC;IACrC,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC;QACtB,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,mBAAmB;IACnB,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAEvB,sHAAsH;IACtH,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;IAEf,8FAA8F;IAC9F,KA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AW,EAAE,eAAe,EAAE,OAAO,CAAC;YACpE,0CAA0C;aACzC,IAAI,CAAC,UAAU,YAAY;YACxB,IAAI,OAAO,EAAE,CAAC;gBACV,OAAO,CAAC,YAAY,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC,CAAC;YACF,0CAA0C;aACzC,KAAK,CAAC,UAAU,GAAG;YAChB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AA3eW;IADP,SAAS,CAAC,UAAU,CAAC;+CACkB;AAIhC;IADP,SAAS,CAAC,KAAK,CAAC;iDAC0D;AAQ3D;IADf,SAAS,EAAE;6CACmB;AAienC,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAChC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,OAAO,CAAC,mBAAmB,GAAG,CAC1B,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,EAC/C,EAAE;QACA,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjH,CAAC,CAAC;IAEF,6CAA6C;IAC7C,aAAa,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { Observable } from \"../../Misc/observable.pure\";\r\nimport { Tools } from \"../../Misc/tools.pure\";\r\nimport { IsExponentOfTwo } from \"../../Misc/tools.functions\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { Texture } from \"../../Materials/Textures/texture.pure\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { type ExternalTexture } from \"./externalTexture\";\r\nimport { type WebGPUEngine } from \"core/Engines\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { type Scene } from \"../../scene.pure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\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\n// eslint-disable-next-line @typescript-eslint/naming-convention\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> = null;\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 @serialize(\"settings\")\r\n private _settings: VideoTextureSettings;\r\n private _createInternalTextureOnEvent: string;\r\n private _frameId = -1;\r\n @serialize(\"src\")\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 /**\r\n * Serialize the flag to define this texture as a video texture\r\n */\r\n @serialize()\r\n public readonly isVideo = true;\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 // eslint-disable-next-line github/no-then\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 // eslint-disable-next-line github/no-then\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 const engineWebGPU = this._engine as Nullable<WebGPUEngine>;\r\n const createExternalTexture = engineWebGPU?.createExternalTexture;\r\n if (createExternalTexture) {\r\n this._externalTexture = createExternalTexture.call(engineWebGPU, this.video);\r\n }\r\n\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(\"loadeddata\", 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 override 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 for (const url of src) {\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 || (IsExponentOfTwo(this.video.videoWidth) && 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.video.addEventListener(\"resize\", this._resizeInternalTexture);\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 override _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 * Get the underlying external texture (if supported by the current engine, else null)\r\n */\r\n public get externalTexture(): Nullable<ExternalTexture> {\r\n return this._externalTexture;\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 override 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 override 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 override 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(\"loadeddata\", 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 // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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 {\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 const tracks = stream.getTracks();\r\n for (const track of tracks) {\r\n track.stop();\r\n }\r\n });\r\n\r\n return videoTexture;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/return-await, @typescript-eslint/prefer-promise-reject-errors\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 // eslint-disable-next-line github/no-then\r\n .then(function (videoTexture) {\r\n if (onReady) {\r\n onReady(videoTexture);\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(function (err) {\r\n Logger.Error(err.name);\r\n });\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for videoTexture.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterVideoTexture(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n Texture._CreateVideoTexture = (\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 return new VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings, onError, format);\r\n };\r\n\r\n // Some exporters relies on Tools.Instantiate\r\n RegisterClass(\"BABYLON.VideoTexture\", VideoTexture);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"videoTexture.pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/videoTexture.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;;AAE7D,OAAO,EAAE,UAAU,EAAiB,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,SAAS,YAAY,CAAC,KAAuB;IACzC,qCAAqC;IACrC,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC;QACtB,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,mBAAmB;IACnB,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAEvB,sHAAsH;IACtH,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;IAEf,8FAA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,YAAY,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC,CAAC;YACF,0CAA0C;aACzC,KAAK,CAAC,UAAU,GAAG;YAChB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AA7gBW;IADP,SAAS,CAAC,UAAU,CAAC;+CACkB;AAIhC;IADP,SAAS,CAAC,KAAK,CAAC;iDAC0D;AAQ3D;IADf,SAAS,EAAE;6CACmB;AAmgBnC,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAChC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,OAAO,CAAC,mBAAmB,GAAG,CAC1B,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,EAC/C,EAAE;QACA,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjH,CAAC,CAAC;IAEF,6CAA6C;IAC7C,aAAa,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { Observable, type Observer } from \"../../Misc/observable.pure\";\r\nimport { Tools } from \"../../Misc/tools.pure\";\r\nimport { IsExponentOfTwo } from \"../../Misc/tools.functions\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { Texture } from \"../../Materials/Textures/texture.pure\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { type ExternalTexture } from \"./externalTexture\";\r\nimport { type WebGPUEngine } from \"core/Engines\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { type Scene } from \"../../scene.pure\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\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\n// eslint-disable-next-line @typescript-eslint/naming-convention\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> = null;\r\n private _snapshotRenderingObserver: Nullable<Observer<Scene>> = null;\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 @serialize(\"settings\")\r\n private _settings: VideoTextureSettings;\r\n private _createInternalTextureOnEvent: string;\r\n private _frameId = -1;\r\n @serialize(\"src\")\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 /**\r\n * Serialize the flag to define this texture as a video texture\r\n */\r\n @serialize()\r\n public readonly isVideo = true;\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 // eslint-disable-next-line github/no-then\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 // eslint-disable-next-line github/no-then\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 const engineWebGPU = this._engine as Nullable<WebGPUEngine>;\r\n const createExternalTexture = engineWebGPU?.createExternalTexture;\r\n if (createExternalTexture) {\r\n this._externalTexture = createExternalTexture.call(engineWebGPU, this.video);\r\n }\r\n\r\n if (this._externalTexture) {\r\n // Under FAST snapshot rendering the active meshes are not re-evaluated each frame, so materials\r\n // (and the video textures they bind) are never re-bound and VideoTexture.update() is never called.\r\n // Drive the per-frame update from a scene hook so the video keeps playing while snapshot rendering is active.\r\n const ownerScene = this.getScene();\r\n if (ownerScene) {\r\n this._snapshotRenderingObserver = ownerScene.onBeforeRenderObservable.add(this._updateWhileSnapshotRendering);\r\n }\r\n }\r\n\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(\"loadeddata\", 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 override 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 for (const url of src) {\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 || (IsExponentOfTwo(this.video.videoWidth) && 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 // The internal texture (bound by materials) was just recreated. A recorded FAST snapshot bundle still\r\n // references the previous GPU texture, so force a snapshot reset to re-record against the new texture.\r\n this._resetSnapshotRenderingIfFast();\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.video.addEventListener(\"resize\", this._resizeInternalTexture);\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 override _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 private _updateWhileSnapshotRendering = (): void => {\r\n const engine = this._engine;\r\n if (engine && engine.snapshotRendering && engine.snapshotRenderingMode === Constants.SNAPSHOTRENDERING_FAST) {\r\n this.update();\r\n }\r\n };\r\n\r\n private _resetSnapshotRenderingIfFast(): void {\r\n const engine = this._engine as Nullable<WebGPUEngine>;\r\n if (engine?.snapshotRendering && engine.snapshotRenderingMode === Constants.SNAPSHOTRENDERING_FAST) {\r\n engine.snapshotRenderingReset();\r\n }\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 * Get the underlying external texture (if supported by the current engine, else null)\r\n */\r\n public get externalTexture(): Nullable<ExternalTexture> {\r\n return this._externalTexture;\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 override 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 override 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 override dispose(): void {\r\n if (this._snapshotRenderingObserver) {\r\n // Remove the per-frame snapshot rendering hook before super.dispose() clears the scene reference.\r\n this.getScene()?.onBeforeRenderObservable.remove(this._snapshotRenderingObserver);\r\n this._snapshotRenderingObserver = null;\r\n }\r\n\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(\"loadeddata\", 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 // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\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 {\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 const tracks = stream.getTracks();\r\n for (const track of tracks) {\r\n track.stop();\r\n }\r\n });\r\n\r\n return videoTexture;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/return-await, @typescript-eslint/prefer-promise-reject-errors\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 // eslint-disable-next-line github/no-then\r\n .then(function (videoTexture) {\r\n if (onReady) {\r\n onReady(videoTexture);\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(function (err) {\r\n Logger.Error(err.name);\r\n });\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for videoTexture.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterVideoTexture(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n Texture._CreateVideoTexture = (\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 return new VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings, onError, format);\r\n };\r\n\r\n // Some exporters relies on Tools.Instantiate\r\n RegisterClass(\"BABYLON.VideoTexture\", VideoTexture);\r\n}\r\n"]}
|
|
@@ -259,6 +259,17 @@ export interface PLYHeader {
|
|
|
259
259
|
* @internal Use GaussianSplattingMesh instead; this class is an internal implementation detail.
|
|
260
260
|
*/
|
|
261
261
|
export declare class GaussianSplattingMeshBase extends Mesh {
|
|
262
|
+
/**
|
|
263
|
+
* When true (default), the depth-sort worker uses the fast O(n) counting (radix) sort. Set to false to
|
|
264
|
+
* fall back to the legacy comparison sort (useful for A/B comparison or as a safety fallback). The change
|
|
265
|
+
* takes effect on the next sort.
|
|
266
|
+
*/
|
|
267
|
+
static UseCountingSort: boolean;
|
|
268
|
+
/**
|
|
269
|
+
* When true, the depth-sort worker logs each sort's duration (ms) and active splat count to the console.
|
|
270
|
+
* Off by default; intended for performance investigation only.
|
|
271
|
+
*/
|
|
272
|
+
static LogSortPerformance: boolean;
|
|
262
273
|
/** @internal */
|
|
263
274
|
_vertexCount: number;
|
|
264
275
|
protected _worker: Nullable<Worker>;
|
|
@@ -376,6 +387,15 @@ export declare class GaussianSplattingMeshBase extends Mesh {
|
|
|
376
387
|
*/
|
|
377
388
|
setSplatIndexRanges(ranges: Nullable<readonly IGaussianSplattingSplatRange[]>): void;
|
|
378
389
|
private _setSplatIndexRanges;
|
|
390
|
+
/**
|
|
391
|
+
* Whether the depth sort is settled: a sort computed for the current active ranges and camera has been
|
|
392
|
+
* applied to the rendered index buffer, and no further sort is pending or in flight. For a static camera
|
|
393
|
+
* and a fixed active set this becomes true once the final sort completes. Used by streaming subclasses to
|
|
394
|
+
* detect when rendering is fully up to date (e.g. for deterministic screenshots) and by IBL shadows to
|
|
395
|
+
* avoid voxelizing against an index buffer the worker has not finished (re)building yet.
|
|
396
|
+
* @internal
|
|
397
|
+
*/
|
|
398
|
+
get _isDepthSortSettled(): boolean;
|
|
379
399
|
private _ensureDepthMixSize;
|
|
380
400
|
/**
|
|
381
401
|
* Sends the active source-splat intervals to the sort worker. When no range filter is active,
|
|
@@ -484,6 +504,12 @@ export declare class GaussianSplattingMeshBase extends Mesh {
|
|
|
484
504
|
* Get the compensation state
|
|
485
505
|
*/
|
|
486
506
|
get compensation(): boolean;
|
|
507
|
+
/**
|
|
508
|
+
* Minimum projected splat size, in pixels, below which a splat is discarded (0 = disabled).
|
|
509
|
+
* Applied in real time; no rebuild required.
|
|
510
|
+
*/
|
|
511
|
+
get minPixelSize(): number;
|
|
512
|
+
set minPixelSize(value: number);
|
|
487
513
|
private _loadingPromise;
|
|
488
514
|
/**
|
|
489
515
|
* set rendering material
|
|
@@ -667,6 +693,16 @@ export declare class GaussianSplattingMeshBase extends Mesh {
|
|
|
667
693
|
* Subclasses (e.g. compound) may override to additionally post part-index data.
|
|
668
694
|
*/
|
|
669
695
|
protected _notifyWorkerNewData(): void;
|
|
696
|
+
/**
|
|
697
|
+
* Patches only a contiguous range of source-splat centers in the sort worker, instead of re-copying and
|
|
698
|
+
* transferring the entire position buffer (which is hundreds of MB for large streamed datasets and caused
|
|
699
|
+
* a multi-frame freeze on every LOD decode). The worker must already hold a full-size position buffer (from
|
|
700
|
+
* the initial {@link GaussianSplattingSortWorkerCommand.POSITIONS} message at worker creation). Marks the
|
|
701
|
+
* sort dirty so the new splats are sorted in; the caller is responsible for any interval/range refresh.
|
|
702
|
+
* @param splatOffset first splat index of the updated range
|
|
703
|
+
* @param splatCount number of splats in the updated range
|
|
704
|
+
*/
|
|
705
|
+
protected _postWorkerPositionsRange(splatOffset: number, splatCount: number): void;
|
|
670
706
|
private _updateData;
|
|
671
707
|
/**
|
|
672
708
|
* Update asynchronously the buffer
|
|
@@ -391,6 +391,17 @@ export class GaussianSplattingMeshBase extends Mesh {
|
|
|
391
391
|
this._postToWorker(true);
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Whether the depth sort is settled: a sort computed for the current active ranges and camera has been
|
|
396
|
+
* applied to the rendered index buffer, and no further sort is pending or in flight. For a static camera
|
|
397
|
+
* and a fixed active set this becomes true once the final sort completes. Used by streaming subclasses to
|
|
398
|
+
* detect when rendering is fully up to date (e.g. for deterministic screenshots) and by IBL shadows to
|
|
399
|
+
* avoid voxelizing against an index buffer the worker has not finished (re)building yet.
|
|
400
|
+
* @internal
|
|
401
|
+
*/
|
|
402
|
+
get _isDepthSortSettled() {
|
|
403
|
+
return this._readyToDisplay && !this._sortIsDirty && this._canPostToWorker;
|
|
404
|
+
}
|
|
394
405
|
// (Re)allocates the worker depth buffer to the given padded size. A fresh array is allocated when the
|
|
395
406
|
// size differs or the current buffer is detached (in-flight in the worker), so a queued sort can be
|
|
396
407
|
// re-posted with a correctly-sized buffer without disturbing the in-flight one.
|
|
@@ -641,6 +652,18 @@ export class GaussianSplattingMeshBase extends Mesh {
|
|
|
641
652
|
get compensation() {
|
|
642
653
|
return this._material instanceof GaussianSplattingMaterial ? this._material.compensation : false;
|
|
643
654
|
}
|
|
655
|
+
/**
|
|
656
|
+
* Minimum projected splat size, in pixels, below which a splat is discarded (0 = disabled).
|
|
657
|
+
* Applied in real time; no rebuild required.
|
|
658
|
+
*/
|
|
659
|
+
get minPixelSize() {
|
|
660
|
+
return this._material instanceof GaussianSplattingMaterial ? this._material.minPixelSize : 0;
|
|
661
|
+
}
|
|
662
|
+
set minPixelSize(value) {
|
|
663
|
+
if (this._material instanceof GaussianSplattingMaterial) {
|
|
664
|
+
this._material.minPixelSize = Math.max(0, value);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
644
667
|
/**
|
|
645
668
|
* set rendering material
|
|
646
669
|
*/
|
|
@@ -1040,6 +1063,9 @@ export class GaussianSplattingMeshBase extends Mesh {
|
|
|
1040
1063
|
cameraId: camera.uniqueId,
|
|
1041
1064
|
sortRequestId: cameraViewInfos.sortRequestId,
|
|
1042
1065
|
rangeVersion: this._activeRangeVersion,
|
|
1066
|
+
useCountingSort: GaussianSplattingMeshBase.UseCountingSort,
|
|
1067
|
+
rightHanded: this._scene.useRightHandedSystem,
|
|
1068
|
+
logSortPerformance: GaussianSplattingMeshBase.LogSortPerformance,
|
|
1043
1069
|
}, [this._depthMix.buffer]);
|
|
1044
1070
|
}
|
|
1045
1071
|
else if (Native?.sortSplats) {
|
|
@@ -2216,6 +2242,25 @@ export class GaussianSplattingMeshBase extends Mesh {
|
|
|
2216
2242
|
}
|
|
2217
2243
|
this._sortIsDirty = true;
|
|
2218
2244
|
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Patches only a contiguous range of source-splat centers in the sort worker, instead of re-copying and
|
|
2247
|
+
* transferring the entire position buffer (which is hundreds of MB for large streamed datasets and caused
|
|
2248
|
+
* a multi-frame freeze on every LOD decode). The worker must already hold a full-size position buffer (from
|
|
2249
|
+
* the initial {@link GaussianSplattingSortWorkerCommand.POSITIONS} message at worker creation). Marks the
|
|
2250
|
+
* sort dirty so the new splats are sorted in; the caller is responsible for any interval/range refresh.
|
|
2251
|
+
* @param splatOffset first splat index of the updated range
|
|
2252
|
+
* @param splatCount number of splats in the updated range
|
|
2253
|
+
*/
|
|
2254
|
+
_postWorkerPositionsRange(splatOffset, splatCount) {
|
|
2255
|
+
if (!this._worker || !this._splatPositions || splatCount <= 0) {
|
|
2256
|
+
return;
|
|
2257
|
+
}
|
|
2258
|
+
const floatOffset = splatOffset * 4;
|
|
2259
|
+
// Copy just the changed region (stride 4) so the main thread keeps its own _splatPositions intact.
|
|
2260
|
+
const data = this._splatPositions.slice(floatOffset, floatOffset + splatCount * 4);
|
|
2261
|
+
this._worker.postMessage({ command: GaussianSplattingSortWorkerCommand.POSITIONS_UPDATE, offset: floatOffset, data }, [data.buffer]);
|
|
2262
|
+
this._sortIsDirty = true;
|
|
2263
|
+
}
|
|
2219
2264
|
*_updateData(data, isAsync, sh, partIndices, { flipY = false, previousVertexCount = 0 } = {}, shDegree) {
|
|
2220
2265
|
if (!this._covariancesATexture) {
|
|
2221
2266
|
this._readyToDisplay = false;
|
|
@@ -2727,6 +2772,17 @@ export class GaussianSplattingMeshBase extends Mesh {
|
|
|
2727
2772
|
return this;
|
|
2728
2773
|
}
|
|
2729
2774
|
}
|
|
2775
|
+
/**
|
|
2776
|
+
* When true (default), the depth-sort worker uses the fast O(n) counting (radix) sort. Set to false to
|
|
2777
|
+
* fall back to the legacy comparison sort (useful for A/B comparison or as a safety fallback). The change
|
|
2778
|
+
* takes effect on the next sort.
|
|
2779
|
+
*/
|
|
2780
|
+
GaussianSplattingMeshBase.UseCountingSort = true;
|
|
2781
|
+
/**
|
|
2782
|
+
* When true, the depth-sort worker logs each sort's duration (ms) and active splat count to the console.
|
|
2783
|
+
* Off by default; intended for performance investigation only.
|
|
2784
|
+
*/
|
|
2785
|
+
GaussianSplattingMeshBase.LogSortPerformance = false;
|
|
2730
2786
|
GaussianSplattingMeshBase._RowOutputLength = 3 * 4 + 3 * 4 + 4 + 4; // Vector3 position, Vector3 scale, 1 u8 quaternion, 1 color with alpha
|
|
2731
2787
|
GaussianSplattingMeshBase._SH_C0 = 0.28209479177387814;
|
|
2732
2788
|
// batch size between 2 yield calls. This value is a tradeoff between updates overhead and framerate hiccups
|