Hey all.
I’ve been trying to get going with the webXR using the default experience setup.
A problem I’m having is the request to the controller profiles being blocked by CORS.
The setup makes a call to (https://immersive-web.github.io/) for controller profiles.
I got around this by using a local profiles list, but the setup still then makes calls to (controllers.babylonjs.com/vive/wand.babylon) or whatever device is selected in my debugger.
At a bit of a loss now… I’ve tried tons of different ways.
Am I doing something silly? I’ve tried running my local server over https, disabling browser security to test.
Are you saying that the controllers’ repository has disabled CORS?! That should not happen. First, you can host the entire controllers package locally if you want but using the online cdn is the recommended way if you are an online website.
Can you share the failed request from the network debugging tab? I wonder what the issue is. Is it possible the URL is blocked locally on your device? I checked with a few devices and the cdn seems to be working correctly.
Thanks for getting back to me
I see! It’s probably a localhost thing then…
The request: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://controllers.babylonjs.com/vive/wand.babylon. (Reason: CORS request did not succeed). Status code: (null).
I can get through fine if I disable attempt to load the controller models…
let opts:IWebXRInputOptions = {
disableOnlineControllerRepository:true,
customControllersRepositoryURL:profilesList,
doNotLoadControllerMeshes:true,
}
I’ve tried loading them manually through the ‘profilesList’ above with the folder structure, the Json file which references individual controller profiles.
Also tried a custom assetPath on profile.json, but can’t get it to reference, always defaults to the babylon cdn.
Yeh the access is very likely an issue on my end.
I’ll try with the default repository in the morning, I found WebXRMotionControllerManager.BaseRepositoryUrl from another forum post which I hadn’t come across, hopefully that sorts it!
I can’t reproduce in playground because I’m not sure how to manage imports on the playground, sorry! But at the last point I was following:
import { WebXRMicrosoftMixedRealityController } from "@babylonjs/core/XR/motionController/webXRMicrosoftMixedRealityController";
// or disable the online repository
WebXRMotionControllerManager.UseOnlineRepository = false;
// now, if loading a microsoft motion controller it will use the local class
from webXRInputControllerSupport.
Not sure if I was missing something as part of that setup, but switching back to the local repo and using the BaseRepositoryUrl might hopefully do the trick
Thanks for your time!
I am still trying to understand if you are trying to avoid using the online repository, or you are using the local ones because the online is not working
The online repository is a npm package and can be installed along your other project’s files or hosted anywhere else you want (like a local server) - @webxr-input-profiles/motion-controllers - npm
We kept the motion controllers we had because of backwards compatibility and are always recommending to use the motion controllers provided by the webxr team, because they are simply better (and include the animation definitions).
Update: The Cors issue was due to using custom request headers in my modified Babylon runtime, so I’m now able to access the repos! Phew.
There was no success on hosting the profiles locally which would be ideal, since Parcel bundles the files it would take some working around…