Skip to content

Commit 11ee7ff

Browse files
fixed quite bad gltf loading issue, where deeply nested meshes would have parents overriden. Added possibility to disable cookies via query param on docs.
1 parent d8cfe6a commit 11ee7ff

File tree

2 files changed

+33
-29
lines changed
  • docs/src/theme/Layout
  • packages/dev/babylonjs/lib/api/bitbybit/babylon

2 files changed

+33
-29
lines changed

docs/src/theme/Layout/index.tsx

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export default function LayoutWrapper(props: Props): ReactNode {
1111

1212
const [trackingInitialized, setTrackingInitialized] = useState(false);
1313

14+
// Check if cookies are disabled via query parameter
15+
const isCookieDisabled = ExecutionEnvironment.canUseDOM &&
16+
new URLSearchParams(window.location.search).get("cookies") === "disabled";
17+
1418
const initializeGATracking = () => {
1519
if (ExecutionEnvironment.canUseDOM && !window.gtag) {
1620
const script = document.createElement("script");
@@ -33,39 +37,41 @@ export default function LayoutWrapper(props: Props): ReactNode {
3337

3438
const cookieConsent = Cookies.get("bitbybit-docs-cookie-consent");
3539

36-
if (cookieConsent === "true" && trackingInitialized === false) {
40+
if (cookieConsent === "true" && trackingInitialized === false && !isCookieDisabled) {
3741
initializeGATracking();
3842
setTrackingInitialized(true);
3943
}
4044

4145
return (
4246
<>
4347
<Layout {...props} />
44-
<CookieConsent
45-
location="bottom"
46-
buttonText="ACCEPT COOKIES ❤️"
47-
declineButtonText="DECLINE"
48-
cookieName="bitbybit-docs-cookie-consent"
49-
style={{ background: "#2B373B" }}
50-
enableDeclineButton
51-
overlay
52-
flipButtons
53-
buttonStyle={{ backgroundColor: "#f0cebb", color: "#1a1c1f", fontWeight: "bold", fontSize: "13px", borderRadius: "5px", padding: "10px 20px" }}
54-
declineButtonStyle={{ backgroundColor: "#1a1c1f", color: "#f0cebb", fontWeight: "bold", fontSize: "13px", borderRadius: "5px", padding: "10px 20px" }}
48+
{!isCookieDisabled && (
49+
<CookieConsent
50+
location="bottom"
51+
buttonText="ACCEPT COOKIES ❤️"
52+
declineButtonText="DECLINE"
53+
cookieName="bitbybit-docs-cookie-consent"
54+
style={{ background: "#2B373B" }}
55+
enableDeclineButton
56+
overlay
57+
flipButtons
58+
buttonStyle={{ backgroundColor: "#f0cebb", color: "#1a1c1f", fontWeight: "bold", fontSize: "13px", borderRadius: "5px", padding: "10px 20px" }}
59+
declineButtonStyle={{ backgroundColor: "#1a1c1f", color: "#f0cebb", fontWeight: "bold", fontSize: "13px", borderRadius: "5px", padding: "10px 20px" }}
5560

56-
onAccept={(acceptedByScrolling) => {
57-
if (acceptedByScrolling) {
58-
// triggered if user scrolls past threshold
59-
} else {
60-
initializeGATracking();
61-
}
62-
}}
63-
>
64-
<h2>Help us improve Bitbybit</h2>
65-
<p>
66-
To help us improve Bitbybit and its documentation, we’d like to use Google Analytics, which requires setting cookies. Do you consent to this?
67-
</p>
68-
</CookieConsent>
61+
onAccept={(acceptedByScrolling) => {
62+
if (acceptedByScrolling) {
63+
// triggered if user scrolls past threshold
64+
} else {
65+
initializeGATracking();
66+
}
67+
}}
68+
>
69+
<h2>Help us improve Bitbybit</h2>
70+
<p>
71+
To help us improve Bitbybit and its documentation, we’d like to use Google Analytics, which requires setting cookies. Do you consent to this?
72+
</p>
73+
</CookieConsent>
74+
)}
6975
</>
7076
);
7177
}

packages/dev/babylonjs/lib/api/bitbybit/babylon/io.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ export class BabylonIO {
180180
return Promise.resolve({});
181181
}
182182

183-
184183
private async loadAsset(meshNames: any, rootUrl: string, fileOrName: string | File, importHidden: boolean): Promise<BABYLON.Mesh> {
185184
const res = await BABYLON.SceneLoader.ImportMeshAsync("", rootUrl, fileOrName, this.context.scene);
186185
const sgs = this.context.scene.metadata.shadowGenerators as BABYLON.ShadowGenerator[];
@@ -217,9 +216,8 @@ export class BabylonIO {
217216
}
218217
});
219218
}
220-
res.meshes.forEach(mesh => {
221-
mesh.parent = container;
222-
});
219+
const root = res.meshes.find(m => m.name === "__root__");
220+
root.parent = container;
223221
return container;
224222
}
225223

0 commit comments

Comments
 (0)