Why do objects in the virtual scene move with me for hololens 2?

<html>
<head>
    <script src="https://cdn.babylonjs.com/babylon.js"></script>
    <style>
        body,#renderCanvas { width: 100%; height: 100%;}
    </style>
</head>
<body>
    <canvas id="renderCanvas"></canvas>
    <script>
        const canvas = document.getElementById("renderCanvas");
        const engine = new BABYLON.Engine(canvas, true);

        const createScene = function() {
            const scene = new BABYLON.Scene(engine);
            scene.clearColor = new BABYLON.Color3.Black;

            const alpha =  Math.PI/4;
            const beta = Math.PI/3;
            const radius = 8;
            const target = new BABYLON.Vector3(0, 0, 0);

            const camera = new BABYLON.ArcRotateCamera("Camera", alpha, beta, radius, target, scene);
            camera.attachControl(canvas, true);

            const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(1, 1, 0));

            const box = BABYLON.MeshBuilder.CreateBox("box", {});
            box.position.x = 0.5;
            box.position.y = 1;

            const boxMaterial = new BABYLON.StandardMaterial("material", scene);
            boxMaterial.diffuseColor = BABYLON.Color3.Random();
            box.material = boxMaterial;

            box.actionManager = new BABYLON.ActionManager(scene);
            box.actionManager.registerAction(
                new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, 
                function (evt) {
                    const sourceBox = evt.meshUnderPointer;
                    sourceBox.position.x += 0.1;
                    sourceBox.position.y += 0.1;

                    boxMaterial.diffuseColor = BABYLON.Color3.Random();
                }));

            const ground = BABYLON.MeshBuilder.CreateGround("ground", {width: 4, height: 4});

            const xrPromise = scene.createDefaultXRExperienceAsync({
                floorMeshes: [ground]
            });

            return xrPromise.then((xrExperience) => {
                console.log("Done, WebXR is enabled.");
                return scene;
            });
        };

        createScene().then(sceneToRender => {
            engine.runRenderLoop(() => sceneToRender.render());
        });
    </script>
</body>
</html>

I used the edge of HoloLens, but the models move with my head.

How can I keep the models fixed in the real world?

I searched the forum but found nothing. Thanks.

?? How can I keep the models fixed in the real world?

cc @RaananW

A few things to note here -

  1. You are creating a VR immersive session, you might want to create an ar session
  2. Nonetheless, this should work when you enter the session. Are you entering the immersive session using the VR button on the bottom right corner?

Would you be able to create a playground reproducing the issue? This way I can test it directly and tell you what is the cause of the issue.

OK, Thanks

Would you be able to create a playground reproducing the issue? This way I can test it directly and tell you what is the cause of the issue.

20241008_225653

This is the record of video.

I just checked the same scene on my hololens, and it is working correctly. What version of edge are you currently running on your device? I am a bit behind on updates (using edge 127), so I wonder if some update has caused an issue with tracking

I used the default one(13…) and I used the last update also fail .Become a Microsoft Edge Insider | Microsoft Edge

But I can succesful run the demo of webxr–Immersive VR Session (Maybe there some update for babylon for webxr?)

And I don’t know, how to back to the old version(127…) edge. Would you like to share one(127 version .msix file) with me?Thanks.

I updated to 130 and it is completely broken. Same behavior as what you showed.
Babylon didn’t change anything and is fully compliant with the webxr specs, so there shouldn’t be any issue. I can try debugging the issue, but it is not the simplest with the hololens.
As the controllers are working correctly, I am a bit puzzled as to what could cause this apart from a bug in edge that delivers us the wrong data. The slight difference between what we are doing and what the immersive VR demo is doing is that we are using the vector3/quaternion for positioning as opposed to using the transformation matrix directly, when processing the view.

Can’t promise any timeline here.

2 Likes

Thanks
Can you share a Edge installer for 127…version?

Sorry, won’t be possible because my version was also auto- updated.