Skip to content

Commit c5eb586

Browse files
committed
fixes
1 parent 4e4cd0e commit c5eb586

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

src/core/p5.Renderer3D.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -731,27 +731,19 @@ export class Renderer3D extends Renderer {
731731
const a0 = args[0];
732732

733733
const isImageLike =
734-
a0 instanceof p5.Image ||
735-
a0 instanceof p5.Graphics ||
736-
a0 instanceof p5.MediaElement ||
737-
(typeof HTMLImageElement !== 'undefined' && a0 instanceof HTMLImageElement) ||
738-
(typeof HTMLVideoElement !== 'undefined' && a0 instanceof HTMLVideoElement) ||
739-
(typeof HTMLCanvasElement !== 'undefined' && a0 instanceof HTMLCanvasElement);
740-
741-
// WEBGL / 3D: support background(image)
742-
if (args.length > 0 && isImageLike) {
734+
a0 != null &&
735+
typeof a0 === 'object' &&
736+
typeof a0.width === 'number' &&
737+
typeof a0.height === 'number' &&
738+
(a0.canvas != null || a0.elt != null);
739+
740+
// WEBGL / 3D: support background(image-like)
741+
if (isImageLike) {
743742
this._pInst.clear();
744743
this._pInst.push();
745744
this._pInst.resetMatrix();
746-
this._pInst.imageMode(constants.CORNER);
747-
this._pInst.image(
748-
a0,
749-
-this._pInst.width / 2,
750-
-this._pInst.height / 2,
751-
this._pInst.width,
752-
this._pInst.height
753-
);
754-
745+
this._pInst.imageMode(constants.CENTER);
746+
this._pInst.image(a0, 0, 0, this._pInst.width, this._pInst.height);
755747
this._pInst.pop();
756748
return;
757749
}

0 commit comments

Comments
 (0)