1d653e67ea800b73dcab4b6b15c1da92fd8be8bc536bc595584a164f2e5c5071.json 16 KB

1
  1. {"ast":null,"code":"import { WebXRExperienceHelper } from \"./webXRExperienceHelper.js\";\nimport { WebXRInput } from \"./webXRInput.js\";\nimport { WebXRControllerPointerSelection } from \"./features/WebXRControllerPointerSelection.js\";\nimport { WebXRNearInteraction } from \"./features/WebXRNearInteraction.js\";\nimport { WebXREnterExitUI } from \"./webXREnterExitUI.js\";\nimport { WebXRHandTracking } from \"./features/WebXRHandTracking.js\";\nimport { WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation.js\";\nimport { Logger } from \"../Misc/logger.js\";\n/**\n * Options for the default xr helper\n */\nexport class WebXRDefaultExperienceOptions {}\n/**\n * Default experience for webxr\n */\nexport class WebXRDefaultExperience {\n constructor() {}\n /**\n * Creates the default xr experience\n * @param scene scene\n * @param options options for basic configuration\n * @returns resulting WebXRDefaultExperience\n */\n static CreateAsync(scene, options = {}) {\n const result = new WebXRDefaultExperience();\n scene.onDisposeObservable.addOnce(() => {\n result.dispose();\n });\n // init the UI right after construction\n if (!options.disableDefaultUI) {\n const uiOptions = {\n renderTarget: result.renderTarget,\n ...(options.uiOptions || {})\n };\n if (options.optionalFeatures) {\n if (typeof options.optionalFeatures === \"boolean\") {\n uiOptions.optionalFeatures = [\"hit-test\", \"anchors\", \"plane-detection\", \"hand-tracking\"];\n } else {\n uiOptions.optionalFeatures = options.optionalFeatures;\n }\n }\n result.enterExitUI = new WebXREnterExitUI(scene, uiOptions);\n }\n // Create base experience\n return WebXRExperienceHelper.CreateAsync(scene).then(xrHelper => {\n result.baseExperience = xrHelper;\n if (options.ignoreNativeCameraTransformation) {\n result.baseExperience.camera.compensateOnFirstFrame = false;\n }\n // Add controller support\n result.input = new WebXRInput(xrHelper.sessionManager, xrHelper.camera, {\n controllerOptions: {\n renderingGroupId: options.renderingGroupId\n },\n ...(options.inputOptions || {})\n });\n if (!options.disablePointerSelection) {\n // Add default pointer selection\n const pointerSelectionOptions = {\n ...options.pointerSelectionOptions,\n xrInput: result.input,\n renderingGroupId: options.renderingGroupId\n };\n result.pointerSelection = result.baseExperience.featuresManager.enableFeature(WebXRControllerPointerSelection.Name, options.useStablePlugins ? \"stable\" : \"latest\", pointerSelectionOptions);\n if (!options.disableTeleportation) {\n // Add default teleportation, including rotation\n result.teleportation = result.baseExperience.featuresManager.enableFeature(WebXRMotionControllerTeleportation.Name, options.useStablePlugins ? \"stable\" : \"latest\", {\n floorMeshes: options.floorMeshes,\n xrInput: result.input,\n renderingGroupId: options.renderingGroupId,\n ...options.teleportationOptions\n });\n result.teleportation.setSelectionFeature(result.pointerSelection);\n }\n }\n if (!options.disableNearInteraction) {\n // Add default pointer selection\n result.nearInteraction = result.baseExperience.featuresManager.enableFeature(WebXRNearInteraction.Name, options.useStablePlugins ? \"stable\" : \"latest\", {\n xrInput: result.input,\n farInteractionFeature: result.pointerSelection,\n renderingGroupId: options.renderingGroupId,\n useUtilityLayer: true,\n enableNearInteractionOnAllControllers: true,\n ...options.nearInteractionOptions\n });\n }\n if (!options.disableHandTracking) {\n // Add default hand tracking\n result.baseExperience.featuresManager.enableFeature(WebXRHandTracking.Name, options.useStablePlugins ? \"stable\" : \"latest\", {\n xrInput: result.input,\n ...options.handSupportOptions\n }, undefined, false);\n }\n // Create the WebXR output target\n result.renderTarget = result.baseExperience.sessionManager.getWebXRRenderTarget(options.outputCanvasOptions);\n if (!options.disableDefaultUI) {\n // Create ui for entering/exiting xr\n return result.enterExitUI.setHelperAsync(result.baseExperience, result.renderTarget);\n } else {\n return;\n }\n }).then(() => {\n return result;\n }).catch(error => {\n Logger.Error(\"Error initializing XR\");\n Logger.Error(error);\n return result;\n });\n }\n /**\n * Disposes of the experience helper\n */\n dispose() {\n if (this.baseExperience) {\n this.baseExperience.dispose();\n }\n if (this.input) {\n this.input.dispose();\n }\n if (this.enterExitUI) {\n this.enterExitUI.dispose();\n }\n if (this.renderTarget) {\n this.renderTarget.dispose();\n }\n }\n}","map":{"version":3,"names":["WebXRExperienceHelper","WebXRInput","WebXRControllerPointerSelection","WebXRNearInteraction","WebXREnterExitUI","WebXRHandTracking","WebXRMotionControllerTeleportation","Logger","WebXRDefaultExperienceOptions","WebXRDefaultExperience","constructor","CreateAsync","scene","options","result","onDisposeObservable","addOnce","dispose","disableDefaultUI","uiOptions","renderTarget","optionalFeatures","enterExitUI","then","xrHelper","baseExperience","ignoreNativeCameraTransformation","camera","compensateOnFirstFrame","input","sessionManager","controllerOptions","renderingGroupId","inputOptions","disablePointerSelection","pointerSelectionOptions","xrInput","pointerSelection","featuresManager","enableFeature","Name","useStablePlugins","disableTeleportation","teleportation","floorMeshes","teleportationOptions","setSelectionFeature","disableNearInteraction","nearInteraction","farInteractionFeature","useUtilityLayer","enableNearInteractionOnAllControllers","nearInteractionOptions","disableHandTracking","handSupportOptions","undefined","getWebXRRenderTarget","outputCanvasOptions","setHelperAsync","catch","error","Error"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/XR/webXRDefaultExperience.js"],"sourcesContent":["import { WebXRExperienceHelper } from \"./webXRExperienceHelper.js\";\nimport { WebXRInput } from \"./webXRInput.js\";\nimport { WebXRControllerPointerSelection } from \"./features/WebXRControllerPointerSelection.js\";\nimport { WebXRNearInteraction } from \"./features/WebXRNearInteraction.js\";\nimport { WebXREnterExitUI } from \"./webXREnterExitUI.js\";\nimport { WebXRHandTracking } from \"./features/WebXRHandTracking.js\";\nimport { WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation.js\";\nimport { Logger } from \"../Misc/logger.js\";\n/**\n * Options for the default xr helper\n */\nexport class WebXRDefaultExperienceOptions {\n}\n/**\n * Default experience for webxr\n */\nexport class WebXRDefaultExperience {\n constructor() { }\n /**\n * Creates the default xr experience\n * @param scene scene\n * @param options options for basic configuration\n * @returns resulting WebXRDefaultExperience\n */\n static CreateAsync(scene, options = {}) {\n const result = new WebXRDefaultExperience();\n scene.onDisposeObservable.addOnce(() => {\n result.dispose();\n });\n // init the UI right after construction\n if (!options.disableDefaultUI) {\n const uiOptions = {\n renderTarget: result.renderTarget,\n ...(options.uiOptions || {}),\n };\n if (options.optionalFeatures) {\n if (typeof options.optionalFeatures === \"boolean\") {\n uiOptions.optionalFeatures = [\"hit-test\", \"anchors\", \"plane-detection\", \"hand-tracking\"];\n }\n else {\n uiOptions.optionalFeatures = options.optionalFeatures;\n }\n }\n result.enterExitUI = new WebXREnterExitUI(scene, uiOptions);\n }\n // Create base experience\n return WebXRExperienceHelper.CreateAsync(scene)\n .then((xrHelper) => {\n result.baseExperience = xrHelper;\n if (options.ignoreNativeCameraTransformation) {\n result.baseExperience.camera.compensateOnFirstFrame = false;\n }\n // Add controller support\n result.input = new WebXRInput(xrHelper.sessionManager, xrHelper.camera, {\n controllerOptions: {\n renderingGroupId: options.renderingGroupId,\n },\n ...(options.inputOptions || {}),\n });\n if (!options.disablePointerSelection) {\n // Add default pointer selection\n const pointerSelectionOptions = {\n ...options.pointerSelectionOptions,\n xrInput: result.input,\n renderingGroupId: options.renderingGroupId,\n };\n result.pointerSelection = (result.baseExperience.featuresManager.enableFeature(WebXRControllerPointerSelection.Name, options.useStablePlugins ? \"stable\" : \"latest\", pointerSelectionOptions));\n if (!options.disableTeleportation) {\n // Add default teleportation, including rotation\n result.teleportation = result.baseExperience.featuresManager.enableFeature(WebXRMotionControllerTeleportation.Name, options.useStablePlugins ? \"stable\" : \"latest\", {\n floorMeshes: options.floorMeshes,\n xrInput: result.input,\n renderingGroupId: options.renderingGroupId,\n ...options.teleportationOptions,\n });\n result.teleportation.setSelectionFeature(result.pointerSelection);\n }\n }\n if (!options.disableNearInteraction) {\n // Add default pointer selection\n result.nearInteraction = result.baseExperience.featuresManager.enableFeature(WebXRNearInteraction.Name, options.useStablePlugins ? \"stable\" : \"latest\", {\n xrInput: result.input,\n farInteractionFeature: result.pointerSelection,\n renderingGroupId: options.renderingGroupId,\n useUtilityLayer: true,\n enableNearInteractionOnAllControllers: true,\n ...options.nearInteractionOptions,\n });\n }\n if (!options.disableHandTracking) {\n // Add default hand tracking\n result.baseExperience.featuresManager.enableFeature(WebXRHandTracking.Name, options.useStablePlugins ? \"stable\" : \"latest\", {\n xrInput: result.input,\n ...options.handSupportOptions,\n }, undefined, false);\n }\n // Create the WebXR output target\n result.renderTarget = result.baseExperience.sessionManager.getWebXRRenderTarget(options.outputCanvasOptions);\n if (!options.disableDefaultUI) {\n // Create ui for entering/exiting xr\n return result.enterExitUI.setHelperAsync(result.baseExperience, result.renderTarget);\n }\n else {\n return;\n }\n })\n .then(() => {\n return result;\n })\n .catch((error) => {\n Logger.Error(\"Error initializing XR\");\n Logger.Error(error);\n return result;\n });\n }\n /**\n * Disposes of the experience helper\n */\n dispose() {\n if (this.baseExperience) {\n this.baseExperience.dispose();\n }\n if (this.input) {\n this.input.dispose();\n }\n if (this.enterExitUI) {\n this.enterExitUI.dispose();\n }\n if (this.renderTarget) {\n this.renderTarget.dispose();\n }\n }\n}\n"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,+BAA+B,QAAQ,+CAA+C;AAC/F,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,iBAAiB,QAAQ,iCAAiC;AACnE,SAASC,kCAAkC,QAAQ,4CAA4C;AAC/F,SAASC,MAAM,QAAQ,mBAAmB;AAC1C;AACA;AACA;AACA,OAAO,MAAMC,6BAA6B,CAAC;AAE3C;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,CAAC;EAChCC,WAAWA,CAAA,EAAG,CAAE;EAChB;AACJ;AACA;AACA;AACA;AACA;EACI,OAAOC,WAAWA,CAACC,KAAK,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;IACpC,MAAMC,MAAM,GAAG,IAAIL,sBAAsB,CAAC,CAAC;IAC3CG,KAAK,CAACG,mBAAmB,CAACC,OAAO,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