Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

injection to webXR apps built by various game engines #3

Open
cyberfoxmeow opened this issue Jul 16, 2024 · 6 comments
Open

injection to webXR apps built by various game engines #3

cyberfoxmeow opened this issue Jul 16, 2024 · 6 comments

Comments

@cyberfoxmeow
Copy link

Injection to some webXR apps has failed maybe because there is existing webXR runtime attached to the build.

The webXR apps I failed to inject are built by Needle Engine with Unity and Wonderland .

Is there any solution for injection to the apps built by these two engines?

Thanks.

@cyberfoxmeow cyberfoxmeow changed the title injection to builds of webXR apps from various game engines injection to webXR apps built by various game engines Jul 16, 2024
@felixtrz
Copy link
Contributor

I have a patch for Wonderland coming out soon. Still need to look into Needle Tools

@cyberfoxmeow
Copy link
Author

ok. thanks.
I will also have a look at Needle. Hope I can give a help.

@felixtrz
Copy link
Contributor

I've just released version 1.0.1 on NPM, which you can find here: iwer package. This update addresses the issue affecting both Wonderland and Needle Tools.

The root of the problem was in how I managed the updateRenderState method. Originally, I set up a pending render state to be applied on the next device frame. However, I overlooked the scenario where updateRenderState could be invoked multiple times before the next frame, causing only the last state to be recorded and previous updates to be lost. Since updateRenderState allows for partial updates, this oversight led to the loss of crucial information.

To resolve this, I implemented a fix in commit d45bd66 that compounds any pending updates whenever updateRenderState is called and a pending state already exists. This solution has resolved the integration issues with both Wonderland and Needle Tools.

@cyberfoxmeow
Copy link
Author

Thanks.

It works for Wonderland.

But It does not work for Needle on my side.........

I tried injection in two methods:
For the first method, I directly inject the .js scripts into the <head> of dist/index.html, just like what I did for Wonderland.
For the second method, I establish a new .ts script under src/scripts folder, and inside the .ts I put the xrDevice position keyboard control inside the update() loop. (for example, I press ArrowLeft, and xrDevice.position.x -= 0.1;)

For both two methods above, after I click enter VR, the screen gets freezed. There is no error shown in the console of my browser.
I put console log for debug the second method, and I find that, if I press a key ArrowLeft once, the console log shows that the script xrDevice.position.x -= 0.1; is run for many times.
image

@felixtrz
Copy link
Contributor

@cyberfoxmeow that is strange, any chance you can provide a test link for me to try and repro this on my side?

@cyberfoxmeow
Copy link
Author

sure.

The Needle I am using is a Unity plugin . I just use the scene template, and add one cube.

The build web src is: dist.zip . According to Needle policy, it only supports HTTPS.

#!/usr/bin/python3

# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes

from http.server import HTTPServer, SimpleHTTPRequestHandler
import ssl,sys,os

context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(certfile='server.pem', keyfile='server.pem')
context.check_hostname = False

if len(sys.argv) > 1:
    os.chdir(sys.argv[1])

with HTTPServer(("0.0.0.0", 14443), SimpleHTTPRequestHandler) as httpd:
    httpd.socket = context.wrap_socket(httpd.socket, server_side=True)
    httpd.serve_forever()

# python https_server.py '.\Needle 3D example\Needle\newProject\dist'

I have commented out IWER injection in index.html.

For your reference, the whole Unity project file is: https://drive.google.com/file/d/1dnpYj3GmFWoFp9j4hhxtfj_rHjYDufwn/view?usp=sharing
In this Unity project, I also tried to import IWER in Needle/newProject/src/scripts/iwerControl.ts. Also, it does not work, and only with a freeze screen after clicking Enter VR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants