Skip to content

Commit c18eaf4

Browse files
authored
Fix Webcam Texture Size (#46)
1 parent 7bf4fb3 commit c18eaf4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/demo/src/configuration/blocks/inputs/webCamSession.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,21 @@ export class WebCamSession implements IDisposable {
6464
hiddenVideo.width = width;
6565
hiddenVideo.height = height;
6666

67-
const internalVideoTexture = this._engine.createDynamicTexture(
68-
hiddenVideo.videoWidth,
69-
hiddenVideo.videoHeight,
70-
false,
71-
2
72-
);
73-
this._internalVideoTexture = internalVideoTexture;
74-
this._videoTexture = new ThinTexture(internalVideoTexture);
75-
7667
hiddenVideo.onerror = () => {
7768
throw "Failed to load WebCam";
7869
};
7970

8071
hiddenVideo.onloadeddata = () => {
72+
const internalVideoTexture = this._engine.createDynamicTexture(
73+
hiddenVideo.videoWidth,
74+
hiddenVideo.videoHeight,
75+
false,
76+
2
77+
);
78+
this._internalVideoTexture = internalVideoTexture;
79+
this._videoTexture = new ThinTexture(internalVideoTexture);
80+
this._textureOutput.value = this._videoTexture;
81+
8182
const update = () => {
8283
if (this._isDisposed) {
8384
return;
@@ -94,7 +95,6 @@ export class WebCamSession implements IDisposable {
9495
};
9596

9697
hiddenVideo.srcObject = stream;
97-
this._textureOutput.value = this._videoTexture;
9898
}
9999

100100
public dispose(): void {

0 commit comments

Comments
 (0)