Skip to content

Update README.md#160

Merged
sidequestlegend merged 2 commits intomainfrom
sidequestlegend-patch-7
Mar 23, 2026
Merged

Update README.md#160
sidequestlegend merged 2 commits intomainfrom
sidequestlegend-patch-7

Conversation

@sidequestlegend
Copy link
Copy Markdown
Contributor

@sidequestlegend sidequestlegend commented Mar 23, 2026

Summary by CodeRabbit

  • Documentation
    • Updated Quick Start to show browser event–based initialization for scene setup, moving example setup to run only after the page-level load event.
    • Clarified example flow for attaching scene handlers and creating a sample object once initialization completes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e94a0013-1b0f-4120-8969-8763695c1f0b

📥 Commits

Reviewing files that changed from the base of the PR and between 7ab20ea and e0009ad.

📒 Files selected for processing (1)
  • README.md

📝 Walkthrough

Walkthrough

README Quick Start was changed to defer scene acquisition and setup until a browser bs-loaded event fires; the BS.BanterScene.GetInstance() call and the scene.On("unity-loaded", ...) registration are moved inside that event handler. Internal handler logic unchanged.

Changes

Cohort / File(s) Summary
Documentation
README.md
Quick Start example updated to wrap scene retrieval and unity-loaded registration in window.addEventListener("bs-loaded", ...). Scene singleton access and callback setup moved into the event handler; example's internal unity-loaded logic (sphere creation, components, click handler) retained.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • Update README.md #160 — Applies the same README change: moves BS.BanterScene.GetInstance() and scene.On("unity-loaded", ...) calls into a bs-loaded event listener.

Suggested reviewers

  • Ladypoly

Poem

🐰
A small hop for code, a browser-bound cheer,
"bs-loaded" whispers when the scene will appear.
I tuck the GetInstance safe inside the event,
Clicks still log points, just when timing is meant. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Update README.md' is vague and does not convey the meaningful change being made. It only references the file being modified, not the actual content update. Use a more descriptive title that summarizes the actual change, such as 'Update Quick Start to use bs-loaded event listener' or 'Refactor Quick Start initialization to use browser-level event handler'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sidequestlegend-patch-7

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 11-39: Wrap the initialization so it handles events that may have
already fired: call BS.BanterScene.GetInstance() and check scene.unityLoaded
first and run the setup immediately if true; otherwise register
scene.On("unity-loaded", ...) as before; likewise replace the single
window.addEventListener("bs-loaded", ...) usage with code that checks if the
"bs-loaded" event has already occurred (or if the global flag the library
exposes indicates readiness) and runs the same handler immediately, falling back
to window.addEventListener("bs-loaded", ...) when not yet fired—ensure the same
setup logic that creates the GameObject, adds components (BanterSphere,
BanterMaterial, SphereCollider, BanterRigidbody) and the click handler is
extracted to a single function and invoked from both the immediate check and the
event listeners.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 623dbf47-a371-4f68-853f-10666a7cb669

📥 Commits

Reviewing files that changed from the base of the PR and between 8cff56e and 7ab20ea.

📒 Files selected for processing (1)
  • README.md

Comment on lines +11 to 39
window.addEventListener("bs-loaded", ()=> {
const scene = BS.BanterScene.GetInstance();

// Wait for the scene to be ready
scene.On("unity-loaded", () => {

// Create a simple object with a red sphere
const sphere = new BS.GameObject({
name: "MySphere",
layer: BS.L.UI, // Layer 5 for UI.
localPosition: new BS.Vector3(0, 1.5, 2)
});

// Add visual geometry
sphere.AddComponent(new BS.BanterSphere({ radius: 0.5 }));
sphere.AddComponent(new BS.BanterMaterial({
color: new BS.Vector4(1, 0, 0, 1)
}));

// Add physics
sphere.AddComponent(new BS.SphereCollider({ radius: 0.5 }));
sphere.AddComponent(new BS.BanterRigidbody({ mass: 1, useGravity: true }));

// Handle clicks
sphere.On("click", (e) => {
console.log("Clicked at:", e.detail.point);
});
});
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Find bs-loaded/unity-loaded usage and readiness checks =="
rg -n -C2 'bs-loaded|unity-loaded|unityLoaded|BanterScene\.GetInstance\(' README.md
rg -n -C2 'bs-loaded|unity-loaded|unityLoaded|BanterScene\.GetInstance\(' .

Repository: SideQuestVR/BanterSDK

Length of output: 4536


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Check for unityLoaded property usage patterns ==="
rg -n 'unityLoaded' --type md --type js

echo ""
echo "=== Look for resilient initialization patterns ==="
rg -n -B3 -A3 'scene\.On.*unity-loaded' --type md --type js | head -60

echo ""
echo "=== Check for once: true event listeners ==="
rg -n 'once.*true|addEventListener.*once' --type md --type js

Repository: SideQuestVR/BanterSDK

Length of output: 1160


Quick Start example lacks fallback for already-fired bs-loaded and unity-loaded events

The listener-only pattern at lines 11–39 will silently fail if either event fires before the listener is registered. The documented unityLoaded property provides a resilient fallback, but no code examples demonstrate this pattern.

Suggested fix:

Resilient Quick Start initialization
- window.addEventListener("bs-loaded", ()=> {
-     const scene = BS.BanterScene.GetInstance();
-     
-     // Wait for the scene to be ready
-     scene.On("unity-loaded", () => {
+ const init = () => {
+     const scene = BS.BanterScene.GetInstance();
+ 
+     const onUnityReady = () => {
      
         // Create a simple object with a red sphere
         const sphere = new BS.GameObject({
             name: "MySphere",
             layer: BS.L.UI, // Layer 5 for UI.
             localPosition: new BS.Vector3(0, 1.5, 2)
         });
     
         // Add visual geometry
         sphere.AddComponent(new BS.BanterSphere({ radius: 0.5 }));
         sphere.AddComponent(new BS.BanterMaterial({
             color: new BS.Vector4(1, 0, 0, 1)
         }));
     
         // Add physics
         sphere.AddComponent(new BS.SphereCollider({ radius: 0.5 }));
         sphere.AddComponent(new BS.BanterRigidbody({ mass: 1, useGravity: true }));
     
         // Handle clicks
         sphere.On("click", (e) => {
             console.log("Clicked at:", e.detail.point);
         });
-    });
-});
+     };
+ 
+     if (scene.unityLoaded) onUnityReady();
+     else scene.On("unity-loaded", onUnityReady);
+ };
+ 
+ if (window.BS?.BanterScene) init();
+ else window.addEventListener("bs-loaded", init, { once: true });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
window.addEventListener("bs-loaded", ()=> {
const scene = BS.BanterScene.GetInstance();
// Wait for the scene to be ready
scene.On("unity-loaded", () => {
// Create a simple object with a red sphere
const sphere = new BS.GameObject({
name: "MySphere",
layer: BS.L.UI, // Layer 5 for UI.
localPosition: new BS.Vector3(0, 1.5, 2)
});
// Add visual geometry
sphere.AddComponent(new BS.BanterSphere({ radius: 0.5 }));
sphere.AddComponent(new BS.BanterMaterial({
color: new BS.Vector4(1, 0, 0, 1)
}));
// Add physics
sphere.AddComponent(new BS.SphereCollider({ radius: 0.5 }));
sphere.AddComponent(new BS.BanterRigidbody({ mass: 1, useGravity: true }));
// Handle clicks
sphere.On("click", (e) => {
console.log("Clicked at:", e.detail.point);
});
});
});
const init = () => {
const scene = BS.BanterScene.GetInstance();
const onUnityReady = () => {
// Create a simple object with a red sphere
const sphere = new BS.GameObject({
name: "MySphere",
layer: BS.L.UI, // Layer 5 for UI.
localPosition: new BS.Vector3(0, 1.5, 2)
});
// Add visual geometry
sphere.AddComponent(new BS.BanterSphere({ radius: 0.5 }));
sphere.AddComponent(new BS.BanterMaterial({
color: new BS.Vector4(1, 0, 0, 1)
}));
// Add physics
sphere.AddComponent(new BS.SphereCollider({ radius: 0.5 }));
sphere.AddComponent(new BS.BanterRigidbody({ mass: 1, useGravity: true }));
// Handle clicks
sphere.On("click", (e) => {
console.log("Clicked at:", e.detail.point);
});
};
if (scene.unityLoaded) onUnityReady();
else scene.On("unity-loaded", onUnityReady);
};
if (window.BS?.BanterScene) init();
else window.addEventListener("bs-loaded", init, { once: true });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 11 - 39, Wrap the initialization so it handles events
that may have already fired: call BS.BanterScene.GetInstance() and check
scene.unityLoaded first and run the setup immediately if true; otherwise
register scene.On("unity-loaded", ...) as before; likewise replace the single
window.addEventListener("bs-loaded", ...) usage with code that checks if the
"bs-loaded" event has already occurred (or if the global flag the library
exposes indicates readiness) and runs the same handler immediately, falling back
to window.addEventListener("bs-loaded", ...) when not yet fired—ensure the same
setup logic that creates the GameObject, adds components (BanterSphere,
BanterMaterial, SphereCollider, BanterRigidbody) and the click handler is
extracted to a single function and invoked from both the immediate check and the
event listeners.

@sidequestlegend sidequestlegend merged commit f931d0f into main Mar 23, 2026
0 of 2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants