From dce706a16f9422b59475c84eb13c8fcd663cc1a7 Mon Sep 17 00:00:00 2001 From: Raanan Weber Date: Tue, 31 Oct 2023 13:02:57 +0100 Subject: [PATCH] Warn about missing Ray, but only once (#14477) --- packages/dev/core/src/Misc/devTools.ts | 7 ++++++- packages/dev/core/src/scene.ts | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/dev/core/src/Misc/devTools.ts b/packages/dev/core/src/Misc/devTools.ts index 0ee2ae78cdb..dfe871644c0 100644 --- a/packages/dev/core/src/Misc/devTools.ts +++ b/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.`; } diff --git a/packages/dev/core/src/scene.ts b/packages/dev/core/src/scene.ts index bac90e1887a..cf37c72df6f 100644 --- a/packages/dev/core/src/scene.ts +++ b/packages/dev/core/src/scene.ts @@ -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 @@ -5094,6 +5095,10 @@ export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHold camera?: Nullable, trianglePredicate?: TrianglePickingPredicate ): PickingInfo { + const warn = _WarnImport("Ray", true); + if (warn) { + Logger.Warn(warn); + } // Dummy info if picking as not been imported return new PickingInfo(); } @@ -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): Nullable { + const warn = _WarnImport("Ray", true); + if (warn) { + Logger.Warn(warn); + } // Dummy info if picking as not been imported return new PickingInfo(); }