Something very interesting is happening (I can post the code if necessary). Here’s what’s going on.
I loaded a very high poly crazy 3D scan into my babylon VR environment. When I look at the scan, there is terrible frame-lagging. OK, I thought to myself; damn it, we’re in that situation where I have to make my object look bad by reducing it’s polygons. BUT THEN, I noticed that when I touched the joystick and created the blue teleport donate, I had zero frame lag.
Alright, I thought, maybe this is a picking problem? So I disabled this:
// let observers = {};
// let meshesUnderPointer = {};
// const tmpVec = new BABYLON.Vector3();
// const tmpRay = new BABYLON.Ray();
// tmpRay.origin = new BABYLON.Vector3();
// tmpRay.direction = new BABYLON.Vector3();
// let lastTimestamp = 0;
// const oldPos = new BABYLON.Vector3();
// const bullets = [];
But, still the same problem remains. So, my question is how do I discover what is killing the frame rate? Is it still trying to “pick” meshes somehow? There must be a way to do high polygon meshes in the quest. I am using the babylonjsvr physics example; I hacked and modded it.
I could imagine a scenario where I have some high poly mesh areas and I disable picking, and I have other low poly mesh areas, where I enable picking. <-- if I’m right.
I can only assume that it is the pointer selection feature that’s causing this, since it runs the pointer move (and picking) on each frame on each hand.
Try disabling the pointer selection (xrHelper.pointerSelection.detach() would be the quickest way) and see if it helps. I doubt it’s the physics, unless you - (1) enabled it and (2) set the mesh to have a MeshImpostor
xr.baseExperience.sessionManager.onXRSessionInit.add(initHelper);
async function initHelper(){
var xrHelper = await scene.createDefaultXRExperienceAsync();
xrHelper.pointerSelection.detach()
}
I think I used this correctly, yes?
I just checked it an it still gets way laggy when I go “inside” my big complicated mesh… But, when I put my thumb down and create the teleport donut, I can see everything with zero lag.
Any other insights about what to check on, try out?
This is the pointer selection for sure. Try disabling it completely (featuresManager.disableFeature), or detach it right after the scene is initialized. the teleportation detaches and and reattaches during its operation
chrome has some very powerful profiling tools, if you’re unsure where the time is being used I would start with those (it’s not particularly easy to use, but there are a number of online tutorials to take you through enough of the basics to get an accurate accounting of where the time is spent).
(1.) I know that it is the behavior of the pointer selection mechanism that is causing the lag.
(2.) I know that I disable the pointer selection mechanism on XRframeinit
(3.) When I load into the space I see no rays popping out from my controllers; however,
(4.) After I teleport, the rays come back, and I think I’m lagging again because of this.
So, to summarize, I know the pointer selection mechanism is causing the problem; it appears to be disabled on start, but re-enabled by teleportation. How do I tell it to be permanently off?
Here’s my code:
xr.baseExperience.sessionManager.onXRSessionInit.add(initHelper);
function initHelper(){
const fm = xr.baseExperience.featuresManager;
fm.disableFeature(BABYLON.WebXRFeatureName.POINTER_SELECTION);
fm.disableFeature(BABYLON.WebXRFeatureName.PHYSICS_CONTROLLERS);
console.log(fm)
}
(Oh, you can see in the terminal print out that it is definitely off on start).
(And, as before, whenever I hold the joystick and make the teleport ray, there’s no lag).
“https://preview.babylonjs.com/babylon.js” <-- I’m pulling in from here; I’m not sure what version this is. Is there a way to search source code like this for a version?
I am using the physics VR sketch; I hacked that example, so I was experimenting with turning physics on and off, but I don’t think it makes a difference for my problem.
If you disable a feature it will be set as disposed and will not re-attach. You can also set the selection feature to null (was only possible in javascript so far due to TS - type-safety)
So, I just went inside and I did not see the rays. I also changed meshes to a medium poly mesh (rather than an insane hyper high poly mesh); so, everything is working. Right now, I’m exploring how large/vast I can make the world. Right now, the buildings look a couple “miles” away from each other, but you can wander to them (pretty wild)!