Skip to content

Commit

Permalink
Warn about missing Ray, but only once (#14477)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaananW committed Oct 31, 2023
1 parent 919db41 commit dce706a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/dev/core/src/Misc/devTools.ts
@@ -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
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

0 comments on commit dce706a

Please sign in to comment.