fix: defer xrlayers/xrlayerscene init until XR8 is ready, fix HTML issues#1
Open
tkada wants to merge 1 commit into8thwall:mainfrom
Open
fix: defer xrlayers/xrlayerscene init until XR8 is ready, fix HTML issues#1tkada wants to merge 1 commit into8thwall:mainfrom
tkada wants to merge 1 commit into8thwall:mainfrom
Conversation
…sues xr.js (async) sets window.XR8 AFTER registering A-Frame components: 1. yield Promise.all(...) - async WASM load 2. window.AFRAME && n() - registers components, triggers init() immediately 3. window.XR8 = I - XR8 global set here (too late) Because xrlayers.init() and xrlayerscene.init() reference XR8 directly, they throw "ReferenceError: XR8 is not defined" at step 2. Changes: - Add src/app.js: wrap AFRAME.registerComponent to defer init() of xrlayers and xrlayerscene until the "xrloaded" event fires - Move sky-recenter component from inline <script> in index.html to app.js (loaded via bundle.js) to avoid duplicate registration errors - Fix malformed closing tag </sky-scene> -> </a-entity> Made-with: Cursor
Contributor
|
Hi there, I didn't see this pull request until now. I fixed the build error. Can you give a little more information about how to reproduce the load order issue? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ReferenceError: XR8 is not definedinxrlayers.init()andxrlayerscene.init()sky-recenterfrom an inline<script>inindex.htmltosrc/app.js(bundled viabundle.js) to prevent duplicate component registration errors</sky-scene>→</a-entity>Root Cause
xr.jsis loaded withasync="true"and internally uses an async Promise chain. The critical execution order inside xr.js is:xrlayerscene.init()callsXR8.LayersController.configure(...)andxrlayers.init()callsXR8.GlTextureRenderer.create(...)directly. Since theseinit()calls are triggered at step 2 — beforewindow.XR8is assigned at step 3 — the result is:Fix
src/app.jswrapsAFRAME.registerComponent(executed viabundle.js, which loads synchronously before the asyncxr.js) to intercept the registration ofxrlayersandxrlayerscene. Theirinit()functions are deferred until thexrloadedevent, which is dispatched by xr.js immediately afterwindow.XR8 = Iis set.Test plan
ReferenceError: XR8 is not definedin the browser consolesky-recentercomponent works correctly (no duplicate registration error)Made with Cursor