Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Shortcut method ml5.setP5(p5)
  • Loading branch information
lindapaiste committed Mar 2, 2024
commit 74bc791c5dc72ebdba2d6b5973a6e293cea10a9d
29 changes: 13 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,21 @@ import communityStatement from "./utils/communityStatement";
import imageClassifier from "./ImageClassifier";

const withPreload = {
bodyPix,
bodyPose,
faceMesh,
handPose,
imageClassifier,
neuralNetwork,
sentiment,
bodyPix,
bodyPose,
faceMesh,
handPose,
imageClassifier,
neuralNetwork,
sentiment,
};

const ml5 = Object.assign(
{ p5Utils },
withPreload,
{
tf,
tfvis,
setBackend,
}
);
const ml5 = Object.assign({ p5Utils }, withPreload, {
tf,
tfvis,
setBackend,
setP5: p5Utils.setP5.bind(p5Utils),
});

p5Utils.shouldPreload(ml5, Object.keys(withPreload));

Expand Down
8 changes: 3 additions & 5 deletions src/utils/p5Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT


function isP5Constructor(source) {
return Boolean(
source &&
typeof source === "function" &&
source.prototype &&
source.prototype.registerMethod
typeof source === "function" &&
source.prototype &&
source.prototype.registerMethod
);
}

Expand Down Expand Up @@ -46,7 +45,6 @@ class P5Util {
this.findAndSetP5();
}


/**
* @private
* Check the window or globalThis for p5.
Expand Down