Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about missing dependency, but only once #14477

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/dev/core/src/Misc/devTools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
const warnedMap: { [key: string]: boolean } = {};
/**
* @internal
*/
export function _WarnImport(name: string) {
export function _WarnImport(name: string, warnOnce = false) {
if (warnOnce && warnedMap[name]) {
return;
}
warnedMap[name] = true;
return `${name} needs to be imported before as it contains a side-effect required by your code.`;
}
9 changes: 9 additions & 0 deletions packages/dev/core/src/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import type { Animation } from "./Animations/animation";
import type { Animatable } from "./Animations/animatable";
import type { Texture } from "./Materials/Textures/texture";
import { PointerPickingConfiguration } from "./Inputs/pointerPickingConfiguration";
import { Logger } from "./Misc/logger";

/**
* Define an interface for all classes that will hold resources
Expand Down Expand Up @@ -5094,6 +5095,10 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
camera?: Nullable<Camera>,
trianglePredicate?: TrianglePickingPredicate
): PickingInfo {
const warn = _WarnImport("Ray", true);
if (warn) {
Logger.Warn(warn);
}
// Dummy info if picking as not been imported
return new PickingInfo();
}
Expand All @@ -5107,6 +5112,10 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold
* @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
*/
public pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo> {
const warn = _WarnImport("Ray", true);
if (warn) {
Logger.Warn(warn);
}
// Dummy info if picking as not been imported
return new PickingInfo();
}
Expand Down