@@ -227,23 +227,32 @@
|
|
227
227
|
XRState.Global.Set(isVR ? XRStateFlag.VR : XRStateFlag.AR);
|
228
228
|
|
229
229
|
// Handle AR session root
|
230
|
-
if (
|
230
|
+
if (args.xr.isAR) {
|
231
231
|
let sessionroot = GameObject.findObjectOfType(WebARSessionRoot);
|
232
|
+
// Only create a WebARSessionRoot if none is in the scene already
|
232
233
|
if (!sessionroot) {
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
234
|
+
if (this.usePlacementReticle) {
|
235
|
+
const implicitSessionRoot = new Object3D();
|
236
|
+
for (const ch of this.context.scene.children)
|
237
|
+
implicitSessionRoot.add(ch);
|
238
|
+
this.context.scene.add(implicitSessionRoot);
|
239
|
+
sessionroot = GameObject.addComponent(implicitSessionRoot, WebARSessionRoot)!;
|
240
|
+
this._createdComponentsInSession.push(sessionroot);
|
241
|
+
}
|
242
|
+
else if (debug || isDevEnvironment()) {
|
243
|
+
console.warn("WebXR: No WebARSessionRoot found in scene and usePlacementReticle is disabled in WebXR component.")
|
244
|
+
}
|
239
245
|
}
|
240
|
-
|
241
|
-
sessionroot
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
246
|
+
|
247
|
+
if (sessionroot) {
|
248
|
+
// sessionroot.enabled = this.usePlacementReticle; // < not sure if we want to disable the session root when placement reticle if OFF...
|
249
|
+
sessionroot.customReticle = this.customARPlacementReticle;
|
250
|
+
sessionroot.arScale = this.arScale;
|
251
|
+
sessionroot.arTouchTransform = this.usePlacementAdjustment;
|
252
|
+
sessionroot.autoPlace = this.autoPlace;
|
253
|
+
sessionroot.autoCenter = this.autoCenter;
|
254
|
+
sessionroot.useXRAnchor = this.useXRAnchor;
|
255
|
+
}
|
247
256
|
}
|
248
257
|
|
249
258
|
// handle VR controls
|