GUI3D NearMenu - missing constructor ^4.2.0

Hi all,

Wanted to try out using the NearMenu in an XR/VR environment, and ran into this. This is also a problem for me when trying to create a TouchHolographicButton. Is this possibly a version issue? I believe I have installed the es5 packages for Babylon, babylonjs and babylonjs-gui.

It seems to work fine in playground (other than properly positioning the menu, that’s next)

But when in my dev environment, I get

Unhandled Rejection (TypeError):
babylonjs_gui__WEBPACK_IMPORTED_MODULE_1__.NearMenu is not a constructor

You should use our preview version of both babylonjs and babylonjs-gui. This was not available in 4.2

Wonderful, thanks.

Follow-up question: how would you modify the distance the menu sits from the camera? I tried modifying the nearMenu’s default/min distance in it’s follow behavior, not sure if it’s working properly

something like

var near = new BABYLON.GUI.NearMenu("near");
manager.addControl(near);
let follower = near.behaviors //returns the followbehavior created by the constructor
follower.defaultDistance = 5;

you would probably also need to change the min and max distance

@CraigFeldspar who implemented it might have more info.

you would probably also need to change the min and max distance

Yes, exactly. Just finished figuring it out. However, it’s probably better to access the behavior from defaultBehavior.followBehavior (you can also grab any other behaviors)

here’s my updated playground: https://playground.babylonjs.com/#Z85RH8#1

Important to know is that when maxDistance is the smallest number, it overrides any larger numbers in default or min distance.

NearMenu by default makes the distances quite small (something like 0.5) by default, which basically locks it inside the camera

1 Like

arriving late to the party, but do you still have an issue with this ? seems that you figured it out

2 Likes

Hey Craig, thanks for checking in. Everything seems figured out - the version update to 5.0 was what I needed. The API/typedoc for NearMenu says ‘since 5.0.0’, but I think that’s the only place you can currently find it, so it is easy to overlook (as I did). I’d suggest making that info more visible, not sure how useful that is since it is a preview version though.