@babylonjs/core 9.3.1 → 9.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.d.ts +1 -0
- package/Lights/Clustered/clusteredLightContainer.js +19 -0
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
- package/Lights/light.d.ts +6 -0
- package/Lights/light.js +8 -0
- package/Lights/light.js.map +1 -1
- package/Lights/spotLight.d.ts +2 -0
- package/Lights/spotLight.js +10 -0
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +4 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +6 -2
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.d.ts +8 -0
- package/Materials/Node/Blocks/Dual/lightBlock.js +16 -0
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +3 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +4 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.js +4 -1
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +4 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +12 -0
- package/Materials/materialHelper.functions.js +24 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.js +4 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +13 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +26 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.d.ts +3 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +113 -10
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -1
- package/Misc/tools.js +1 -1
- package/Misc/tools.js.map +1 -1
- package/Rendering/depthRenderer.d.ts +8 -0
- package/Rendering/depthRenderer.js +48 -13
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/depthRendererSceneComponent.d.ts +1 -0
- package/Rendering/depthRendererSceneComponent.js +26 -0
- package/Rendering/depthRendererSceneComponent.js.map +1 -1
- package/XR/features/WebXRBodyTracking.d.ts +952 -0
- package/XR/features/WebXRBodyTracking.js +2221 -0
- package/XR/features/WebXRBodyTracking.js.map +1 -0
- package/XR/features/index.d.ts +1 -0
- package/XR/features/index.js +1 -0
- package/XR/features/index.js.map +1 -1
- package/XR/webXRFeaturesManager.d.ts +7 -0
- package/XR/webXRFeaturesManager.js +4 -0
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/package.json +1 -1
- package/sceneComponent.d.ts +1 -0
- package/sceneComponent.js +1 -0
- package/sceneComponent.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRFeaturesManager.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRFeaturesManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AA4FtC;;GAEG;AACH,MAAM,OAAO,gBAAgB;;AACzB;;GAEG;AACoB,8BAAa,GAAG,kBAA2B,CAAC;AACnE;;GAEG;AACoB,mCAAkB,GAAG,uBAAgC,CAAC;AAC7E;;GAEG;AACoB,yBAAQ,GAAG,aAAsB,CAAC;AACzD;;GAEG;AACoB,+BAAc,GAAG,mBAA4B,CAAC;AACrE;;GAEG;AACoB,oCAAmB,GAAG,uBAAgC,CAAC;AAC9E;;GAEG;AACoB,gCA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;CAC9D,AAH2C,CAG1C","sourcesContent":["import { type Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport { type IDisposable } from \"../scene\";\r\nimport { type IWebXRAnchorSystemOptions, type WebXRAnchorSystem } from \"./features/WebXRAnchorSystem\";\r\nimport { type IWebXRBackgroundRemoverOptions, type WebXRBackgroundRemover } from \"./features/WebXRBackgroundRemover\";\r\nimport { type IWebXRControllerMovementOptions, type WebXRControllerMovement } from \"./features/WebXRControllerMovement\";\r\nimport { type IWebXRControllerPhysicsOptions, type WebXRControllerPhysics } from \"./features/WebXRControllerPhysics\";\r\nimport { type IWebXRControllerPointerSelectionOptions, type WebXRControllerPointerSelection } from \"./features/WebXRControllerPointerSelection\";\r\nimport { type IWebXRTeleportationOptions, type WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation\";\r\nimport { type IWebXRDepthSensingOptions, type WebXRDepthSensing } from \"./features/WebXRDepthSensing\";\r\nimport { type IWebXRDomOverlayOptions, type WebXRDomOverlay } from \"./features/WebXRDOMOverlay\";\r\nimport { type WebXREyeTracking } from \"./features/WebXREyeTracking\";\r\nimport { type WebXRFeaturePointSystem } from \"./features/WebXRFeaturePointSystem\";\r\nimport { type IWebXRHandTrackingOptions, type WebXRHandTracking } from \"./features/WebXRHandTracking\";\r\nimport { type IWebXRHitTestOptions, type WebXRHitTest } from \"./features/WebXRHitTest\";\r\nimport { type IWebXRImageTrackingOptions, type WebXRImageTracking } from \"./features/WebXRImageTracking\";\r\nimport { type IWebXRLayersOptions, type WebXRLayers } from \"./features/WebXRLayers\";\r\nimport { type IWebXRLightEstimationOptions, type WebXRLightEstimation } from \"./features/WebXRLightEstimation\";\r\nimport { type IWebXRMeshDetectorOptions, type WebXRMeshDetector } from \"./features/WebXRMeshDetector\";\r\nimport { type IWebXRNearInteractionOptions, type WebXRNearInteraction } from \"./features/WebXRNearInteraction\";\r\nimport { type IWebXRPlaneDetectorOptions, type WebXRPlaneDetector } from \"./features/WebXRPlaneDetector\";\r\nimport { type IWebXRRawCameraAccessOptions, type WebXRRawCameraAccess } from \"./features/WebXRRawCameraAccess\";\r\nimport { type WebXRSpaceWarp } from \"./features/WebXRSpaceWarp\";\r\nimport { type IWebXRWalkingLocomotionOptions, type WebXRWalkingLocomotion } from \"./features/WebXRWalkingLocomotion\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\n\r\n/**\r\n * Defining the interface required for a (webxr) feature\r\n */\r\nexport interface IWebXRFeature extends IDisposable {\r\n /**\r\n * Is this feature attached\r\n */\r\n attached: boolean;\r\n /**\r\n * Should auto-attach be disabled?\r\n */\r\n disableAutoAttach: boolean;\r\n\r\n /**\r\n * Attach the feature to the session\r\n * Will usually be called by the features manager\r\n *\r\n * @param force should attachment be forced (even when already attached)\r\n * @returns true if successful.\r\n */\r\n attach(force?: boolean): boolean;\r\n /**\r\n * Detach the feature from the session\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n detach(): boolean;\r\n\r\n /**\r\n * This function will be executed during before enabling the feature and can be used to not-allow enabling it.\r\n * Note that at this point the session has NOT started, so this is purely checking if the browser supports it\r\n *\r\n * @returns whether or not the feature is compatible in this environment\r\n */\r\n isCompatible(): boolean;\r\n\r\n /**\r\n * Was this feature disposed;\r\n */\r\n isDisposed: boolean;\r\n\r\n /**\r\n * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)\r\n */\r\n xrNativeFeatureName?: string;\r\n\r\n /**\r\n * A list of (Babylon WebXR) features this feature depends on\r\n */\r\n dependsOn?: string[];\r\n\r\n /**\r\n * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object\r\n */\r\n getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;\r\n\r\n /**\r\n * Triggered when the feature is attached\r\n */\r\n onFeatureAttachObservable: Observable<IWebXRFeature>;\r\n /**\r\n * Triggered when the feature is detached\r\n */\r\n onFeatureDetachObservable: Observable<IWebXRFeature>;\r\n}\r\n\r\n/**\r\n * A list of the currently available features without referencing them\r\n */\r\nexport class WebXRFeatureName {\r\n /**\r\n * The name of the anchor system feature\r\n */\r\n public static readonly ANCHOR_SYSTEM = \"xr-anchor-system\" as const;\r\n /**\r\n * The name of the background remover feature\r\n */\r\n public static readonly BACKGROUND_REMOVER = \"xr-background-remover\" as const;\r\n /**\r\n * The name of the hit test feature\r\n */\r\n public static readonly HIT_TEST = \"xr-hit-test\" as const;\r\n /**\r\n * The name of the mesh detection feature\r\n */\r\n public static readonly MESH_DETECTION = \"xr-mesh-detection\" as const;\r\n /**\r\n * physics impostors for xr controllers feature\r\n */\r\n public static readonly PHYSICS_CONTROLLERS = \"xr-physics-controller\" as const;\r\n /**\r\n * The name of the plane detection feature\r\n */\r\n public static readonly PLANE_DETECTION = \"xr-plane-detection\" as const;\r\n /**\r\n * The name of the pointer selection feature\r\n */\r\n public static readonly POINTER_SELECTION = \"xr-controller-pointer-selection\" as const;\r\n /**\r\n * The name of the teleportation feature\r\n */\r\n public static readonly TELEPORTATION = \"xr-controller-teleportation\" as const;\r\n /**\r\n * The name of the feature points feature.\r\n */\r\n public static readonly FEATURE_POINTS = \"xr-feature-points\" as const;\r\n /**\r\n * The name of the hand tracking feature.\r\n */\r\n public static readonly HAND_TRACKING = \"xr-hand-tracking\" as const;\r\n /**\r\n * The name of the image tracking feature\r\n */\r\n public static readonly IMAGE_TRACKING = \"xr-image-tracking\" as const;\r\n /**\r\n * The name of the near interaction feature\r\n */\r\n public static readonly NEAR_INTERACTION = \"xr-near-interaction\" as const;\r\n /**\r\n * The name of the DOM overlay feature\r\n */\r\n public static readonly DOM_OVERLAY = \"xr-dom-overlay\" as const;\r\n /**\r\n * The name of the movement feature\r\n */\r\n public static readonly MOVEMENT = \"xr-controller-movement\" as const;\r\n /**\r\n * The name of the light estimation feature\r\n */\r\n public static readonly LIGHT_ESTIMATION = \"xr-light-estimation\" as const;\r\n /**\r\n * The name of the eye tracking feature\r\n */\r\n public static readonly EYE_TRACKING = \"xr-eye-tracking\" as const;\r\n /**\r\n * The name of the walking locomotion feature\r\n */\r\n public static readonly WALKING_LOCOMOTION = \"xr-walking-locomotion\" as const;\r\n /**\r\n * The name of the composition layers feature\r\n */\r\n public static readonly LAYERS = \"xr-layers\" as const;\r\n /**\r\n * The name of the depth sensing feature\r\n */\r\n public static readonly DEPTH_SENSING = \"xr-depth-sensing\" as const;\r\n /**\r\n * The name of the WebXR Space Warp feature\r\n */\r\n public static readonly SPACE_WARP = \"xr-space-warp\" as const;\r\n /**\r\n * The name of the WebXR Raw Camera Access feature\r\n */\r\n public static readonly RAW_CAMERA_ACCESS = \"xr-raw-camera-access\" as const;\r\n}\r\n\r\nexport type WebXRFeatureNameType = (typeof WebXRFeatureName)[Exclude<keyof typeof WebXRFeatureName, \"prototype\">];\r\n\r\nexport interface IWebXRFeatureNameTypeMap {\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: WebXRAnchorSystem;\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: WebXRBackgroundRemover;\r\n [WebXRFeatureName.DEPTH_SENSING]: WebXRDepthSensing;\r\n [WebXRFeatureName.DOM_OVERLAY]: WebXRDomOverlay;\r\n [WebXRFeatureName.EYE_TRACKING]: WebXREyeTracking;\r\n [WebXRFeatureName.FEATURE_POINTS]: WebXRFeaturePointSystem;\r\n [WebXRFeatureName.HAND_TRACKING]: WebXRHandTracking;\r\n [WebXRFeatureName.HIT_TEST]: WebXRHitTest;\r\n [WebXRFeatureName.IMAGE_TRACKING]: WebXRImageTracking;\r\n [WebXRFeatureName.LAYERS]: WebXRLayers;\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: WebXRLightEstimation;\r\n [WebXRFeatureName.MESH_DETECTION]: WebXRMeshDetector;\r\n [WebXRFeatureName.MOVEMENT]: WebXRControllerMovement;\r\n [WebXRFeatureName.NEAR_INTERACTION]: WebXRNearInteraction;\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: WebXRControllerPhysics;\r\n [WebXRFeatureName.PLANE_DETECTION]: WebXRPlaneDetector;\r\n [WebXRFeatureName.POINTER_SELECTION]: WebXRControllerPointerSelection;\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: WebXRRawCameraAccess;\r\n [WebXRFeatureName.SPACE_WARP]: WebXRSpaceWarp;\r\n [WebXRFeatureName.TELEPORTATION]: WebXRMotionControllerTeleportation;\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: WebXRWalkingLocomotion;\r\n}\r\n\r\n/**\r\n * Maps feature names to their corresponding options interfaces.\r\n */\r\nexport interface IWebXRFeatureNameOptionsMap {\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: IWebXRAnchorSystemOptions;\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: IWebXRBackgroundRemoverOptions;\r\n [WebXRFeatureName.DEPTH_SENSING]: IWebXRDepthSensingOptions;\r\n [WebXRFeatureName.DOM_OVERLAY]: IWebXRDomOverlayOptions;\r\n [WebXRFeatureName.EYE_TRACKING]: undefined;\r\n [WebXRFeatureName.FEATURE_POINTS]: undefined;\r\n [WebXRFeatureName.HAND_TRACKING]: IWebXRHandTrackingOptions;\r\n [WebXRFeatureName.HIT_TEST]: IWebXRHitTestOptions;\r\n [WebXRFeatureName.IMAGE_TRACKING]: IWebXRImageTrackingOptions;\r\n [WebXRFeatureName.LAYERS]: IWebXRLayersOptions;\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: IWebXRLightEstimationOptions;\r\n [WebXRFeatureName.MESH_DETECTION]: IWebXRMeshDetectorOptions;\r\n [WebXRFeatureName.MOVEMENT]: IWebXRControllerMovementOptions;\r\n [WebXRFeatureName.NEAR_INTERACTION]: IWebXRNearInteractionOptions;\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: IWebXRControllerPhysicsOptions;\r\n [WebXRFeatureName.PLANE_DETECTION]: IWebXRPlaneDetectorOptions;\r\n [WebXRFeatureName.POINTER_SELECTION]: IWebXRControllerPointerSelectionOptions;\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: IWebXRRawCameraAccessOptions;\r\n [WebXRFeatureName.SPACE_WARP]: undefined;\r\n [WebXRFeatureName.TELEPORTATION]: IWebXRTeleportationOptions;\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: IWebXRWalkingLocomotionOptions;\r\n}\r\n\r\n/**\r\n * Helper type that expands/flattens a type to show its properties inline in IntelliSense\r\n */\r\ntype Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;\r\n\r\n/**\r\n * Helper type to resolve the specific feature type based on the feature name,\r\n * or fallback to IWebXRFeature if the feature name is not in the type map.\r\n */\r\nexport type ResolveWebXRFeature<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameTypeMap ? IWebXRFeatureNameTypeMap[T] : IWebXRFeature;\r\n\r\n/**\r\n * Helper type to resolve the options type for a specific feature based on the feature name,\r\n * or fallback to any if the feature name is not in the type map.\r\n * The Expand utility type flattens the interface to show properties inline in IntelliSense.\r\n */\r\nexport type ResolveWebXRFeatureOptions<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameOptionsMap\r\n ? IWebXRFeatureNameOptionsMap[T] extends undefined\r\n ? undefined\r\n : Expand<IWebXRFeatureNameOptionsMap[T]>\r\n : any;\r\n\r\n/**\r\n * Defining the constructor of a feature. Used to register the modules.\r\n */\r\nexport type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;\r\n\r\n/**\r\n * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.\r\n * It is mainly used in AR sessions.\r\n *\r\n * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).\r\n */\r\nexport class WebXRFeaturesManager implements IDisposable {\r\n private static readonly _AvailableFeatures: {\r\n [name: string]: {\r\n stable: number;\r\n latest: number;\r\n [version: number]: WebXRFeatureConstructor;\r\n };\r\n } = {};\r\n\r\n private _features: {\r\n [name: string]: {\r\n featureImplementation: IWebXRFeature;\r\n version: number;\r\n enabled: boolean;\r\n required: boolean;\r\n };\r\n } = {};\r\n\r\n /**\r\n * The key is the feature to check and the value is the feature that conflicts.\r\n */\r\n private static readonly _ConflictingFeatures: { [key: string]: string } = {\r\n [WebXRFeatureName.TELEPORTATION]: WebXRFeatureName.MOVEMENT,\r\n [WebXRFeatureName.MOVEMENT]: WebXRFeatureName.TELEPORTATION,\r\n };\r\n\r\n /**\r\n * constructs a new features manages.\r\n *\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n */\r\n constructor(private _xrSessionManager: WebXRSessionManager) {\r\n // when session starts / initialized - attach\r\n this._xrSessionManager.onXRSessionInit.add(() => {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && !feature.featureImplementation.attached && !feature.featureImplementation.disableAutoAttach) {\r\n this.attachFeature(featureName);\r\n }\r\n }\r\n });\r\n\r\n // when session ends - detach\r\n this._xrSessionManager.onXRSessionEnded.add(() => {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && feature.featureImplementation.attached) {\r\n // detach, but don't disable!\r\n this.detachFeature(featureName);\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Used to register a module. After calling this function a developer can use this feature in the scene.\r\n * Mainly used internally.\r\n *\r\n * @param featureName the name of the feature to register\r\n * @param constructorFunction the function used to construct the module\r\n * @param version the (babylon) version of the module\r\n * @param stable is that a stable version of this module\r\n */\r\n public static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version: number = 1, stable: boolean = false) {\r\n this._AvailableFeatures[featureName] = this._AvailableFeatures[featureName] || { latest: version };\r\n if (version > this._AvailableFeatures[featureName].latest) {\r\n this._AvailableFeatures[featureName].latest = version;\r\n }\r\n if (stable) {\r\n this._AvailableFeatures[featureName].stable = version;\r\n }\r\n this._AvailableFeatures[featureName][version] = constructorFunction;\r\n }\r\n\r\n /**\r\n * Returns a constructor of a specific feature.\r\n *\r\n * @param featureName the name of the feature to construct\r\n * @param version the version of the feature to load\r\n * @param xrSessionManager the xrSessionManager. Used to construct the module\r\n * @param options optional options provided to the module.\r\n * @returns a function that, when called, will return a new instance of this feature\r\n */\r\n public static ConstructFeature(featureName: string, version: number = 1, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature {\r\n const constructorFunction = this._AvailableFeatures[featureName][version];\r\n if (!constructorFunction) {\r\n // throw an error? return nothing?\r\n throw new Error(\"feature not found\");\r\n }\r\n\r\n return constructorFunction(xrSessionManager, options);\r\n }\r\n\r\n /**\r\n * Can be used to return the list of features currently registered\r\n *\r\n * @returns an Array of available features\r\n */\r\n public static GetAvailableFeatures() {\r\n return Object.keys(this._AvailableFeatures);\r\n }\r\n\r\n /**\r\n * Gets the versions available for a specific feature\r\n * @param featureName the name of the feature\r\n * @returns an array with the available versions\r\n */\r\n public static GetAvailableVersions(featureName: string) {\r\n return Object.keys(this._AvailableFeatures[featureName]);\r\n }\r\n\r\n /**\r\n * Return the latest unstable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetLatestVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].latest) || -1;\r\n }\r\n\r\n /**\r\n * Return the latest stable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetStableVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].stable) || -1;\r\n }\r\n\r\n /**\r\n * Attach a feature to the current session. Mainly used when session started to start the feature effect.\r\n * Can be used during a session to start a feature\r\n * @param featureName the name of feature to attach\r\n */\r\n public attachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.enabled && !feature.featureImplementation.attached) {\r\n const attached = feature.featureImplementation.attach();\r\n if (!attached) {\r\n Tools.Warn(`Feature ${featureName} failed to attach`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Can be used inside a session or when the session ends to detach a specific feature\r\n * @param featureName the name of the feature to detach\r\n */\r\n public detachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.featureImplementation.attached) {\r\n const detached = feature.featureImplementation.detach();\r\n if (!detached) {\r\n Tools.Warn(`Feature ${featureName} failed to detach`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Used to disable an already-enabled feature\r\n * The feature will be disposed and will be recreated once enabled.\r\n * @param featureName the feature to disable\r\n * @returns true if disable was successful\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public disableFeature(featureName: string | { Name: string }): boolean {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n const feature = this._features[name];\r\n if (feature && feature.enabled) {\r\n feature.enabled = false;\r\n this.detachFeature(name);\r\n feature.featureImplementation.dispose();\r\n delete this._features[name];\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * dispose this features manager\r\n */\r\n public dispose(): void {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n this.disableFeature(featureName);\r\n }\r\n }\r\n\r\n /**\r\n * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.\r\n * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.\r\n *\r\n * @param featureName the name of the feature to load or the class of the feature\r\n * @param version optional version to load. if not provided the latest version will be enabled\r\n * @param moduleOptions options provided to the module. Ses the module documentation / constructor\r\n * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible\r\n * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.\r\n * @returns a new constructed feature or throws an error if feature not found or conflicts with another enabled feature.\r\n */\r\n public enableFeature<T extends WebXRFeatureNameType>(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n featureName: T | { Name: T },\r\n version: number | string = \"latest\",\r\n moduleOptions: ResolveWebXRFeatureOptions<T> = {} as ResolveWebXRFeatureOptions<T>,\r\n attachIfPossible: boolean = true,\r\n required: boolean = true\r\n ): ResolveWebXRFeature<T> {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n let versionToLoad: number;\r\n if (typeof version === \"string\") {\r\n if (!version) {\r\n throw new Error(`Error in provided version - ${name} (${version})`);\r\n }\r\n if (version === \"stable\") {\r\n versionToLoad = WebXRFeaturesManager.GetStableVersionOfFeature(name);\r\n } else if (version === \"latest\") {\r\n versionToLoad = WebXRFeaturesManager.GetLatestVersionOfFeature(name);\r\n } else {\r\n // try loading the number the string represents\r\n versionToLoad = +version;\r\n }\r\n if (versionToLoad === -1 || isNaN(versionToLoad)) {\r\n throw new Error(`feature not found - ${name} (${version})`);\r\n }\r\n } else {\r\n versionToLoad = version;\r\n }\r\n\r\n // check if there is a feature conflict\r\n const conflictingFeature = WebXRFeaturesManager._ConflictingFeatures[name];\r\n if (conflictingFeature !== undefined && this.getEnabledFeatures().indexOf(conflictingFeature) !== -1) {\r\n throw new Error(`Feature ${name} cannot be enabled while ${conflictingFeature} is enabled.`);\r\n }\r\n\r\n // check if already initialized\r\n const feature = this._features[name];\r\n const constructFunction = WebXRFeaturesManager.ConstructFeature(name, versionToLoad, this._xrSessionManager, moduleOptions);\r\n if (!constructFunction) {\r\n // report error?\r\n throw new Error(`feature not found - ${name}`);\r\n }\r\n\r\n /* If the feature is already enabled, detach and dispose it, and create a new one */\r\n if (feature) {\r\n this.disableFeature(name);\r\n }\r\n\r\n const constructed = constructFunction();\r\n if (constructed.dependsOn) {\r\n const dependentsFound = constructed.dependsOn.every((featureName) => !!this._features[featureName]);\r\n if (!dependentsFound) {\r\n throw new Error(`Dependant features missing. Make sure the following features are enabled - ${constructed.dependsOn.join(\", \")}`);\r\n }\r\n }\r\n if (constructed.isCompatible()) {\r\n this._features[name] = {\r\n featureImplementation: constructed,\r\n enabled: true,\r\n version: versionToLoad,\r\n required,\r\n };\r\n\r\n if (attachIfPossible) {\r\n // if session started already, request and enable\r\n if (this._xrSessionManager.session && !this._features[name].featureImplementation.attached) {\r\n // enable feature\r\n this.attachFeature(name);\r\n }\r\n } else {\r\n // disable auto-attach when session starts\r\n this._features[name].featureImplementation.disableAutoAttach = true;\r\n }\r\n\r\n return this._features[name].featureImplementation as ResolveWebXRFeature<T>;\r\n } else {\r\n if (required) {\r\n throw new Error(\"required feature not compatible\");\r\n } else {\r\n Tools.Warn(`Feature ${name} not compatible with the current environment/browser and was not enabled.`);\r\n return constructed as ResolveWebXRFeature<T>;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * get the implementation of an enabled feature.\r\n * @param featureName the name of the feature to load\r\n * @returns the feature class, if found\r\n */\r\n public getEnabledFeature<T extends WebXRFeatureNameType>(featureName: T): ResolveWebXRFeature<T> {\r\n return this._features[featureName] && (this._features[featureName].featureImplementation as ResolveWebXRFeature<T>);\r\n }\r\n\r\n /**\r\n * Get the list of enabled features\r\n * @returns an array of enabled features\r\n */\r\n public getEnabledFeatures() {\r\n return Object.keys(this._features);\r\n }\r\n\r\n /**\r\n * This function will extend the session creation configuration object with enabled features.\r\n * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,\r\n * according to the defined \"required\" variable, provided during enableFeature call\r\n * @param xrSessionInit the xr Session init object to extend\r\n *\r\n * @returns an extended XRSessionInit object\r\n */\r\n public async _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit> {\r\n const enabledFeatures = this.getEnabledFeatures();\r\n for (const featureName of enabledFeatures) {\r\n const feature = this._features[featureName];\r\n const nativeName = feature.featureImplementation.xrNativeFeatureName;\r\n if (nativeName) {\r\n if (feature.required) {\r\n xrSessionInit.requiredFeatures = xrSessionInit.requiredFeatures || [];\r\n if (xrSessionInit.requiredFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.requiredFeatures.push(nativeName);\r\n }\r\n } else {\r\n xrSessionInit.optionalFeatures = xrSessionInit.optionalFeatures || [];\r\n if (xrSessionInit.optionalFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.optionalFeatures.push(nativeName);\r\n }\r\n }\r\n }\r\n if (feature.featureImplementation.getXRSessionInitExtension) {\r\n // eslint-disable-next-line no-await-in-loop\r\n const extended = await feature.featureImplementation.getXRSessionInitExtension();\r\n xrSessionInit = {\r\n ...xrSessionInit,\r\n ...extended,\r\n };\r\n }\r\n }\r\n return xrSessionInit;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRFeaturesManager.js","sourceRoot":"","sources":["../../../../dev/core/src/XR/webXRFeaturesManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AA6FtC;;GAEG;AACH,MAAM,OAAO,gBAAgB;;AACzB;;GAEG;AACoB,8BAAa,GAAG,kBAA2B,CAAC;AACnE;;GAEG;AACoB,mCAAkB,GAAG,uBAAgC,CAAC;AAC7E;;GAEG;AACoB,yBAAQ,GAAG,aAAsB,CAAC;AACzD;;GAEG;AACoB,+BAAc,GAAG,mBAA4B,CAAC;AACrE;;GAEG;AACoB,oCAAmB,GAAG,uBAAgC,CAAC;AAC9E;;GAEG;AACoB,gCAAe,GAAG,oBAA6B,CAAC;AACvE;;GAEG;AACoB,kCAAiB,GAAG,iCAA0C,CAAC;AACtF;;GAEG;AACoB,8BAAa,GAAG,6BAAsC,CAAC;AAC9E;;GAEG;AACoB,+BAAc,GAAG,mBAA4B,CAAC;AACrE;;GAEG;AACoB,8BAAa,GAAG,kBAA2B,CAAC;AACnE;;GAEG;AACoB,+BAAc,GAAG,mBAA4B,CAAC;AACrE;;GAEG;AACoB,iCAAgB,GAAG,qBAA8B,CAAC;AACzE;;GAEG;AACoB,4BAAW,GAAG,gBAAyB,CAAC;AAC/D;;GAEG;AACoB,yBAAQ,GAAG,wBAAiC,CAAC;AACpE;;GAEG;AACoB,iCAAgB,GAAG,qBAA8B,CAAC;AACzE;;GAEG;AACoB,6BAAY,GAAG,iBAA0B,CAAC;AACjE;;GAEG;AACoB,mCAAkB,GAAG,uBAAgC,CAAC;AAC7E;;GAEG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C,gBAAgB,IAAI,EAAE,CAAC;oBACtE,IAAI,aAAa,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;wBAC5D,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBACpD,CAAC;gBACL,CAAC;YACL,CAAC;YACD,IAAI,OAAO,CAAC,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;gBAC1D,4CAA4C;gBAC5C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;gBACjF,aAAa,GAAG;oBACZ,GAAG,aAAa;oBAChB,GAAG,QAAQ;iBACd,CAAC;YACN,CAAC;QACL,CAAC;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;;AAlVuB,uCAAkB,GAMtC,EAAE,AANoC,CAMnC;AAWP;;GAEG;AACqB,yCAAoB,GAA8B;IACtE,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB,CAAC,QAAQ;IAC3D,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,aAAa;CAC9D,AAH2C,CAG1C","sourcesContent":["import { type Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport { type IDisposable } from \"../scene\";\r\nimport { type IWebXRAnchorSystemOptions, type WebXRAnchorSystem } from \"./features/WebXRAnchorSystem\";\r\nimport { type IWebXRBackgroundRemoverOptions, type WebXRBackgroundRemover } from \"./features/WebXRBackgroundRemover\";\r\nimport { type IWebXRBodyTrackingOptions, type WebXRBodyTracking } from \"./features/WebXRBodyTracking\";\r\nimport { type IWebXRControllerMovementOptions, type WebXRControllerMovement } from \"./features/WebXRControllerMovement\";\r\nimport { type IWebXRControllerPhysicsOptions, type WebXRControllerPhysics } from \"./features/WebXRControllerPhysics\";\r\nimport { type IWebXRControllerPointerSelectionOptions, type WebXRControllerPointerSelection } from \"./features/WebXRControllerPointerSelection\";\r\nimport { type IWebXRTeleportationOptions, type WebXRMotionControllerTeleportation } from \"./features/WebXRControllerTeleportation\";\r\nimport { type IWebXRDepthSensingOptions, type WebXRDepthSensing } from \"./features/WebXRDepthSensing\";\r\nimport { type IWebXRDomOverlayOptions, type WebXRDomOverlay } from \"./features/WebXRDOMOverlay\";\r\nimport { type WebXREyeTracking } from \"./features/WebXREyeTracking\";\r\nimport { type WebXRFeaturePointSystem } from \"./features/WebXRFeaturePointSystem\";\r\nimport { type IWebXRHandTrackingOptions, type WebXRHandTracking } from \"./features/WebXRHandTracking\";\r\nimport { type IWebXRHitTestOptions, type WebXRHitTest } from \"./features/WebXRHitTest\";\r\nimport { type IWebXRImageTrackingOptions, type WebXRImageTracking } from \"./features/WebXRImageTracking\";\r\nimport { type IWebXRLayersOptions, type WebXRLayers } from \"./features/WebXRLayers\";\r\nimport { type IWebXRLightEstimationOptions, type WebXRLightEstimation } from \"./features/WebXRLightEstimation\";\r\nimport { type IWebXRMeshDetectorOptions, type WebXRMeshDetector } from \"./features/WebXRMeshDetector\";\r\nimport { type IWebXRNearInteractionOptions, type WebXRNearInteraction } from \"./features/WebXRNearInteraction\";\r\nimport { type IWebXRPlaneDetectorOptions, type WebXRPlaneDetector } from \"./features/WebXRPlaneDetector\";\r\nimport { type IWebXRRawCameraAccessOptions, type WebXRRawCameraAccess } from \"./features/WebXRRawCameraAccess\";\r\nimport { type WebXRSpaceWarp } from \"./features/WebXRSpaceWarp\";\r\nimport { type IWebXRWalkingLocomotionOptions, type WebXRWalkingLocomotion } from \"./features/WebXRWalkingLocomotion\";\r\nimport { type WebXRSessionManager } from \"./webXRSessionManager\";\r\n\r\n/**\r\n * Defining the interface required for a (webxr) feature\r\n */\r\nexport interface IWebXRFeature extends IDisposable {\r\n /**\r\n * Is this feature attached\r\n */\r\n attached: boolean;\r\n /**\r\n * Should auto-attach be disabled?\r\n */\r\n disableAutoAttach: boolean;\r\n\r\n /**\r\n * Attach the feature to the session\r\n * Will usually be called by the features manager\r\n *\r\n * @param force should attachment be forced (even when already attached)\r\n * @returns true if successful.\r\n */\r\n attach(force?: boolean): boolean;\r\n /**\r\n * Detach the feature from the session\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n detach(): boolean;\r\n\r\n /**\r\n * This function will be executed during before enabling the feature and can be used to not-allow enabling it.\r\n * Note that at this point the session has NOT started, so this is purely checking if the browser supports it\r\n *\r\n * @returns whether or not the feature is compatible in this environment\r\n */\r\n isCompatible(): boolean;\r\n\r\n /**\r\n * Was this feature disposed;\r\n */\r\n isDisposed: boolean;\r\n\r\n /**\r\n * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)\r\n */\r\n xrNativeFeatureName?: string;\r\n\r\n /**\r\n * A list of (Babylon WebXR) features this feature depends on\r\n */\r\n dependsOn?: string[];\r\n\r\n /**\r\n * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object\r\n */\r\n getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;\r\n\r\n /**\r\n * Triggered when the feature is attached\r\n */\r\n onFeatureAttachObservable: Observable<IWebXRFeature>;\r\n /**\r\n * Triggered when the feature is detached\r\n */\r\n onFeatureDetachObservable: Observable<IWebXRFeature>;\r\n}\r\n\r\n/**\r\n * A list of the currently available features without referencing them\r\n */\r\nexport class WebXRFeatureName {\r\n /**\r\n * The name of the anchor system feature\r\n */\r\n public static readonly ANCHOR_SYSTEM = \"xr-anchor-system\" as const;\r\n /**\r\n * The name of the background remover feature\r\n */\r\n public static readonly BACKGROUND_REMOVER = \"xr-background-remover\" as const;\r\n /**\r\n * The name of the hit test feature\r\n */\r\n public static readonly HIT_TEST = \"xr-hit-test\" as const;\r\n /**\r\n * The name of the mesh detection feature\r\n */\r\n public static readonly MESH_DETECTION = \"xr-mesh-detection\" as const;\r\n /**\r\n * physics impostors for xr controllers feature\r\n */\r\n public static readonly PHYSICS_CONTROLLERS = \"xr-physics-controller\" as const;\r\n /**\r\n * The name of the plane detection feature\r\n */\r\n public static readonly PLANE_DETECTION = \"xr-plane-detection\" as const;\r\n /**\r\n * The name of the pointer selection feature\r\n */\r\n public static readonly POINTER_SELECTION = \"xr-controller-pointer-selection\" as const;\r\n /**\r\n * The name of the teleportation feature\r\n */\r\n public static readonly TELEPORTATION = \"xr-controller-teleportation\" as const;\r\n /**\r\n * The name of the feature points feature.\r\n */\r\n public static readonly FEATURE_POINTS = \"xr-feature-points\" as const;\r\n /**\r\n * The name of the hand tracking feature.\r\n */\r\n public static readonly HAND_TRACKING = \"xr-hand-tracking\" as const;\r\n /**\r\n * The name of the image tracking feature\r\n */\r\n public static readonly IMAGE_TRACKING = \"xr-image-tracking\" as const;\r\n /**\r\n * The name of the near interaction feature\r\n */\r\n public static readonly NEAR_INTERACTION = \"xr-near-interaction\" as const;\r\n /**\r\n * The name of the DOM overlay feature\r\n */\r\n public static readonly DOM_OVERLAY = \"xr-dom-overlay\" as const;\r\n /**\r\n * The name of the movement feature\r\n */\r\n public static readonly MOVEMENT = \"xr-controller-movement\" as const;\r\n /**\r\n * The name of the light estimation feature\r\n */\r\n public static readonly LIGHT_ESTIMATION = \"xr-light-estimation\" as const;\r\n /**\r\n * The name of the eye tracking feature\r\n */\r\n public static readonly EYE_TRACKING = \"xr-eye-tracking\" as const;\r\n /**\r\n * The name of the walking locomotion feature\r\n */\r\n public static readonly WALKING_LOCOMOTION = \"xr-walking-locomotion\" as const;\r\n /**\r\n * The name of the composition layers feature\r\n */\r\n public static readonly LAYERS = \"xr-layers\" as const;\r\n /**\r\n * The name of the depth sensing feature\r\n */\r\n public static readonly DEPTH_SENSING = \"xr-depth-sensing\" as const;\r\n /**\r\n * The name of the WebXR Space Warp feature\r\n */\r\n public static readonly SPACE_WARP = \"xr-space-warp\" as const;\r\n /**\r\n * The name of the WebXR Raw Camera Access feature\r\n */\r\n public static readonly RAW_CAMERA_ACCESS = \"xr-raw-camera-access\" as const;\r\n /**\r\n * The name of the body tracking feature\r\n */\r\n public static readonly BODY_TRACKING = \"xr-body-tracking\" as const;\r\n}\r\n\r\nexport type WebXRFeatureNameType = (typeof WebXRFeatureName)[Exclude<keyof typeof WebXRFeatureName, \"prototype\">];\r\n\r\nexport interface IWebXRFeatureNameTypeMap {\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: WebXRAnchorSystem;\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: WebXRBackgroundRemover;\r\n [WebXRFeatureName.DEPTH_SENSING]: WebXRDepthSensing;\r\n [WebXRFeatureName.DOM_OVERLAY]: WebXRDomOverlay;\r\n [WebXRFeatureName.EYE_TRACKING]: WebXREyeTracking;\r\n [WebXRFeatureName.FEATURE_POINTS]: WebXRFeaturePointSystem;\r\n [WebXRFeatureName.HAND_TRACKING]: WebXRHandTracking;\r\n [WebXRFeatureName.HIT_TEST]: WebXRHitTest;\r\n [WebXRFeatureName.IMAGE_TRACKING]: WebXRImageTracking;\r\n [WebXRFeatureName.LAYERS]: WebXRLayers;\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: WebXRLightEstimation;\r\n [WebXRFeatureName.MESH_DETECTION]: WebXRMeshDetector;\r\n [WebXRFeatureName.MOVEMENT]: WebXRControllerMovement;\r\n [WebXRFeatureName.NEAR_INTERACTION]: WebXRNearInteraction;\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: WebXRControllerPhysics;\r\n [WebXRFeatureName.PLANE_DETECTION]: WebXRPlaneDetector;\r\n [WebXRFeatureName.POINTER_SELECTION]: WebXRControllerPointerSelection;\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: WebXRRawCameraAccess;\r\n [WebXRFeatureName.SPACE_WARP]: WebXRSpaceWarp;\r\n [WebXRFeatureName.TELEPORTATION]: WebXRMotionControllerTeleportation;\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: WebXRWalkingLocomotion;\r\n [WebXRFeatureName.BODY_TRACKING]: WebXRBodyTracking;\r\n}\r\n\r\n/**\r\n * Maps feature names to their corresponding options interfaces.\r\n */\r\nexport interface IWebXRFeatureNameOptionsMap {\r\n [WebXRFeatureName.ANCHOR_SYSTEM]: IWebXRAnchorSystemOptions;\r\n [WebXRFeatureName.BACKGROUND_REMOVER]: IWebXRBackgroundRemoverOptions;\r\n [WebXRFeatureName.DEPTH_SENSING]: IWebXRDepthSensingOptions;\r\n [WebXRFeatureName.DOM_OVERLAY]: IWebXRDomOverlayOptions;\r\n [WebXRFeatureName.EYE_TRACKING]: undefined;\r\n [WebXRFeatureName.FEATURE_POINTS]: undefined;\r\n [WebXRFeatureName.HAND_TRACKING]: IWebXRHandTrackingOptions;\r\n [WebXRFeatureName.HIT_TEST]: IWebXRHitTestOptions;\r\n [WebXRFeatureName.IMAGE_TRACKING]: IWebXRImageTrackingOptions;\r\n [WebXRFeatureName.LAYERS]: IWebXRLayersOptions;\r\n [WebXRFeatureName.LIGHT_ESTIMATION]: IWebXRLightEstimationOptions;\r\n [WebXRFeatureName.MESH_DETECTION]: IWebXRMeshDetectorOptions;\r\n [WebXRFeatureName.MOVEMENT]: IWebXRControllerMovementOptions;\r\n [WebXRFeatureName.NEAR_INTERACTION]: IWebXRNearInteractionOptions;\r\n [WebXRFeatureName.PHYSICS_CONTROLLERS]: IWebXRControllerPhysicsOptions;\r\n [WebXRFeatureName.PLANE_DETECTION]: IWebXRPlaneDetectorOptions;\r\n [WebXRFeatureName.POINTER_SELECTION]: IWebXRControllerPointerSelectionOptions;\r\n [WebXRFeatureName.RAW_CAMERA_ACCESS]: IWebXRRawCameraAccessOptions;\r\n [WebXRFeatureName.SPACE_WARP]: undefined;\r\n [WebXRFeatureName.TELEPORTATION]: IWebXRTeleportationOptions;\r\n [WebXRFeatureName.WALKING_LOCOMOTION]: IWebXRWalkingLocomotionOptions;\r\n [WebXRFeatureName.BODY_TRACKING]: IWebXRBodyTrackingOptions;\r\n}\r\n\r\n/**\r\n * Helper type that expands/flattens a type to show its properties inline in IntelliSense\r\n */\r\ntype Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;\r\n\r\n/**\r\n * Helper type to resolve the specific feature type based on the feature name,\r\n * or fallback to IWebXRFeature if the feature name is not in the type map.\r\n */\r\nexport type ResolveWebXRFeature<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameTypeMap ? IWebXRFeatureNameTypeMap[T] : IWebXRFeature;\r\n\r\n/**\r\n * Helper type to resolve the options type for a specific feature based on the feature name,\r\n * or fallback to any if the feature name is not in the type map.\r\n * The Expand utility type flattens the interface to show properties inline in IntelliSense.\r\n */\r\nexport type ResolveWebXRFeatureOptions<T extends WebXRFeatureNameType> = T extends keyof IWebXRFeatureNameOptionsMap\r\n ? IWebXRFeatureNameOptionsMap[T] extends undefined\r\n ? undefined\r\n : Expand<IWebXRFeatureNameOptionsMap[T]>\r\n : any;\r\n\r\n/**\r\n * Defining the constructor of a feature. Used to register the modules.\r\n */\r\nexport type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;\r\n\r\n/**\r\n * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.\r\n * It is mainly used in AR sessions.\r\n *\r\n * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).\r\n */\r\nexport class WebXRFeaturesManager implements IDisposable {\r\n private static readonly _AvailableFeatures: {\r\n [name: string]: {\r\n stable: number;\r\n latest: number;\r\n [version: number]: WebXRFeatureConstructor;\r\n };\r\n } = {};\r\n\r\n private _features: {\r\n [name: string]: {\r\n featureImplementation: IWebXRFeature;\r\n version: number;\r\n enabled: boolean;\r\n required: boolean;\r\n };\r\n } = {};\r\n\r\n /**\r\n * The key is the feature to check and the value is the feature that conflicts.\r\n */\r\n private static readonly _ConflictingFeatures: { [key: string]: string } = {\r\n [WebXRFeatureName.TELEPORTATION]: WebXRFeatureName.MOVEMENT,\r\n [WebXRFeatureName.MOVEMENT]: WebXRFeatureName.TELEPORTATION,\r\n };\r\n\r\n /**\r\n * constructs a new features manages.\r\n *\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n */\r\n constructor(private _xrSessionManager: WebXRSessionManager) {\r\n // when session starts / initialized - attach\r\n this._xrSessionManager.onXRSessionInit.add(() => {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && !feature.featureImplementation.attached && !feature.featureImplementation.disableAutoAttach) {\r\n this.attachFeature(featureName);\r\n }\r\n }\r\n });\r\n\r\n // when session ends - detach\r\n this._xrSessionManager.onXRSessionEnded.add(() => {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && feature.featureImplementation.attached) {\r\n // detach, but don't disable!\r\n this.detachFeature(featureName);\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Used to register a module. After calling this function a developer can use this feature in the scene.\r\n * Mainly used internally.\r\n *\r\n * @param featureName the name of the feature to register\r\n * @param constructorFunction the function used to construct the module\r\n * @param version the (babylon) version of the module\r\n * @param stable is that a stable version of this module\r\n */\r\n public static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version: number = 1, stable: boolean = false) {\r\n this._AvailableFeatures[featureName] = this._AvailableFeatures[featureName] || { latest: version };\r\n if (version > this._AvailableFeatures[featureName].latest) {\r\n this._AvailableFeatures[featureName].latest = version;\r\n }\r\n if (stable) {\r\n this._AvailableFeatures[featureName].stable = version;\r\n }\r\n this._AvailableFeatures[featureName][version] = constructorFunction;\r\n }\r\n\r\n /**\r\n * Returns a constructor of a specific feature.\r\n *\r\n * @param featureName the name of the feature to construct\r\n * @param version the version of the feature to load\r\n * @param xrSessionManager the xrSessionManager. Used to construct the module\r\n * @param options optional options provided to the module.\r\n * @returns a function that, when called, will return a new instance of this feature\r\n */\r\n public static ConstructFeature(featureName: string, version: number = 1, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature {\r\n const constructorFunction = this._AvailableFeatures[featureName][version];\r\n if (!constructorFunction) {\r\n // throw an error? return nothing?\r\n throw new Error(\"feature not found\");\r\n }\r\n\r\n return constructorFunction(xrSessionManager, options);\r\n }\r\n\r\n /**\r\n * Can be used to return the list of features currently registered\r\n *\r\n * @returns an Array of available features\r\n */\r\n public static GetAvailableFeatures() {\r\n return Object.keys(this._AvailableFeatures);\r\n }\r\n\r\n /**\r\n * Gets the versions available for a specific feature\r\n * @param featureName the name of the feature\r\n * @returns an array with the available versions\r\n */\r\n public static GetAvailableVersions(featureName: string) {\r\n return Object.keys(this._AvailableFeatures[featureName]);\r\n }\r\n\r\n /**\r\n * Return the latest unstable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetLatestVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].latest) || -1;\r\n }\r\n\r\n /**\r\n * Return the latest stable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetStableVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].stable) || -1;\r\n }\r\n\r\n /**\r\n * Attach a feature to the current session. Mainly used when session started to start the feature effect.\r\n * Can be used during a session to start a feature\r\n * @param featureName the name of feature to attach\r\n */\r\n public attachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.enabled && !feature.featureImplementation.attached) {\r\n const attached = feature.featureImplementation.attach();\r\n if (!attached) {\r\n Tools.Warn(`Feature ${featureName} failed to attach`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Can be used inside a session or when the session ends to detach a specific feature\r\n * @param featureName the name of the feature to detach\r\n */\r\n public detachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.featureImplementation.attached) {\r\n const detached = feature.featureImplementation.detach();\r\n if (!detached) {\r\n Tools.Warn(`Feature ${featureName} failed to detach`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Used to disable an already-enabled feature\r\n * The feature will be disposed and will be recreated once enabled.\r\n * @param featureName the feature to disable\r\n * @returns true if disable was successful\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public disableFeature(featureName: string | { Name: string }): boolean {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n const feature = this._features[name];\r\n if (feature && feature.enabled) {\r\n feature.enabled = false;\r\n this.detachFeature(name);\r\n feature.featureImplementation.dispose();\r\n delete this._features[name];\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * dispose this features manager\r\n */\r\n public dispose(): void {\r\n const features = this.getEnabledFeatures();\r\n for (const featureName of features) {\r\n this.disableFeature(featureName);\r\n }\r\n }\r\n\r\n /**\r\n * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.\r\n * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.\r\n *\r\n * @param featureName the name of the feature to load or the class of the feature\r\n * @param version optional version to load. if not provided the latest version will be enabled\r\n * @param moduleOptions options provided to the module. Ses the module documentation / constructor\r\n * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible\r\n * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.\r\n * @returns a new constructed feature or throws an error if feature not found or conflicts with another enabled feature.\r\n */\r\n public enableFeature<T extends WebXRFeatureNameType>(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n featureName: T | { Name: T },\r\n version: number | string = \"latest\",\r\n moduleOptions: ResolveWebXRFeatureOptions<T> = {} as ResolveWebXRFeatureOptions<T>,\r\n attachIfPossible: boolean = true,\r\n required: boolean = true\r\n ): ResolveWebXRFeature<T> {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n let versionToLoad: number;\r\n if (typeof version === \"string\") {\r\n if (!version) {\r\n throw new Error(`Error in provided version - ${name} (${version})`);\r\n }\r\n if (version === \"stable\") {\r\n versionToLoad = WebXRFeaturesManager.GetStableVersionOfFeature(name);\r\n } else if (version === \"latest\") {\r\n versionToLoad = WebXRFeaturesManager.GetLatestVersionOfFeature(name);\r\n } else {\r\n // try loading the number the string represents\r\n versionToLoad = +version;\r\n }\r\n if (versionToLoad === -1 || isNaN(versionToLoad)) {\r\n throw new Error(`feature not found - ${name} (${version})`);\r\n }\r\n } else {\r\n versionToLoad = version;\r\n }\r\n\r\n // check if there is a feature conflict\r\n const conflictingFeature = WebXRFeaturesManager._ConflictingFeatures[name];\r\n if (conflictingFeature !== undefined && this.getEnabledFeatures().indexOf(conflictingFeature) !== -1) {\r\n throw new Error(`Feature ${name} cannot be enabled while ${conflictingFeature} is enabled.`);\r\n }\r\n\r\n // check if already initialized\r\n const feature = this._features[name];\r\n const constructFunction = WebXRFeaturesManager.ConstructFeature(name, versionToLoad, this._xrSessionManager, moduleOptions);\r\n if (!constructFunction) {\r\n // report error?\r\n throw new Error(`feature not found - ${name}`);\r\n }\r\n\r\n /* If the feature is already enabled, detach and dispose it, and create a new one */\r\n if (feature) {\r\n this.disableFeature(name);\r\n }\r\n\r\n const constructed = constructFunction();\r\n if (constructed.dependsOn) {\r\n const dependentsFound = constructed.dependsOn.every((featureName) => !!this._features[featureName]);\r\n if (!dependentsFound) {\r\n throw new Error(`Dependant features missing. Make sure the following features are enabled - ${constructed.dependsOn.join(\", \")}`);\r\n }\r\n }\r\n if (constructed.isCompatible()) {\r\n this._features[name] = {\r\n featureImplementation: constructed,\r\n enabled: true,\r\n version: versionToLoad,\r\n required,\r\n };\r\n\r\n if (attachIfPossible) {\r\n // if session started already, request and enable\r\n if (this._xrSessionManager.session && !this._features[name].featureImplementation.attached) {\r\n // enable feature\r\n this.attachFeature(name);\r\n }\r\n } else {\r\n // disable auto-attach when session starts\r\n this._features[name].featureImplementation.disableAutoAttach = true;\r\n }\r\n\r\n return this._features[name].featureImplementation as ResolveWebXRFeature<T>;\r\n } else {\r\n if (required) {\r\n throw new Error(\"required feature not compatible\");\r\n } else {\r\n Tools.Warn(`Feature ${name} not compatible with the current environment/browser and was not enabled.`);\r\n return constructed as ResolveWebXRFeature<T>;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * get the implementation of an enabled feature.\r\n * @param featureName the name of the feature to load\r\n * @returns the feature class, if found\r\n */\r\n public getEnabledFeature<T extends WebXRFeatureNameType>(featureName: T): ResolveWebXRFeature<T> {\r\n return this._features[featureName] && (this._features[featureName].featureImplementation as ResolveWebXRFeature<T>);\r\n }\r\n\r\n /**\r\n * Get the list of enabled features\r\n * @returns an array of enabled features\r\n */\r\n public getEnabledFeatures() {\r\n return Object.keys(this._features);\r\n }\r\n\r\n /**\r\n * This function will extend the session creation configuration object with enabled features.\r\n * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,\r\n * according to the defined \"required\" variable, provided during enableFeature call\r\n * @param xrSessionInit the xr Session init object to extend\r\n *\r\n * @returns an extended XRSessionInit object\r\n */\r\n public async _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit> {\r\n const enabledFeatures = this.getEnabledFeatures();\r\n for (const featureName of enabledFeatures) {\r\n const feature = this._features[featureName];\r\n const nativeName = feature.featureImplementation.xrNativeFeatureName;\r\n if (nativeName) {\r\n if (feature.required) {\r\n xrSessionInit.requiredFeatures = xrSessionInit.requiredFeatures || [];\r\n if (xrSessionInit.requiredFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.requiredFeatures.push(nativeName);\r\n }\r\n } else {\r\n xrSessionInit.optionalFeatures = xrSessionInit.optionalFeatures || [];\r\n if (xrSessionInit.optionalFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.optionalFeatures.push(nativeName);\r\n }\r\n }\r\n }\r\n if (feature.featureImplementation.getXRSessionInitExtension) {\r\n // eslint-disable-next-line no-await-in-loop\r\n const extended = await feature.featureImplementation.getXRSessionInitExtension();\r\n xrSessionInit = {\r\n ...xrSessionInit,\r\n ...extended,\r\n };\r\n }\r\n }\r\n return xrSessionInit;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
package/sceneComponent.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export declare class SceneComponentConstants {
|
|
|
39
39
|
static readonly NAME_IBLCDFGENERATOR = "iblCDFGenerator";
|
|
40
40
|
static readonly NAME_CLUSTEREDLIGHTING = "ClusteredLighting";
|
|
41
41
|
static readonly STEP_ISREADYFORMESH_EFFECTLAYER = 0;
|
|
42
|
+
static readonly STEP_ISREADYFORMESH_DEPTHRENDERER = 1;
|
|
42
43
|
static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
|
|
43
44
|
static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
|
|
44
45
|
static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0;
|
package/sceneComponent.js
CHANGED
|
@@ -28,6 +28,7 @@ SceneComponentConstants.NAME_FLUIDRENDERER = "FluidRenderer";
|
|
|
28
28
|
SceneComponentConstants.NAME_IBLCDFGENERATOR = "iblCDFGenerator";
|
|
29
29
|
SceneComponentConstants.NAME_CLUSTEREDLIGHTING = "ClusteredLighting";
|
|
30
30
|
SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
|
|
31
|
+
SceneComponentConstants.STEP_ISREADYFORMESH_DEPTHRENDERER = 1;
|
|
31
32
|
SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
|
|
32
33
|
SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
|
|
33
34
|
SceneComponentConstants.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0;
|
package/sceneComponent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sceneComponent.js","sourceRoot":"","sources":["../../../dev/core/src/sceneComponent.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,OAAO,uBAAuB;;AACT,wCAAgB,GAAG,aAAa,CAAC;AACjC,kCAAU,GAAG,OAAO,CAAC;AACrB,4CAAoB,GAAG,iBAAiB,CAAC;AACzC,g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C,EAAE,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC;YACtB,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;gBACnB,MAAM;YACV,CAAC;QACL,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import { type Scene } from \"./scene\";\r\nimport { type SmartArrayNoDuplicate } from \"./Misc/smartArray\";\r\nimport { type Nullable } from \"./types\";\r\nimport { type PickingInfo } from \"./Collisions/pickingInfo\";\r\nimport { type IPointerEvent } from \"./Events/deviceInputEvents\";\r\n\r\nimport { type Mesh } from \"./Meshes/mesh\";\r\nimport { type Effect } from \"./Materials/effect\";\r\nimport { type Camera } from \"./Cameras/camera\";\r\nimport { type AbstractMesh } from \"./Meshes/abstractMesh\";\r\nimport { type SubMesh } from \"./Meshes/subMesh\";\r\nimport { type RenderTargetTexture } from \"./Materials/Textures/renderTargetTexture\";\r\nimport { type IAssetContainer } from \"./IAssetContainer\";\r\n\r\n/**\r\n * Groups all the scene component constants in one place to ease maintenance.\r\n * @internal\r\n */\r\nexport class SceneComponentConstants {\r\n public static readonly NAME_EFFECTLAYER = \"EffectLayer\";\r\n public static readonly NAME_LAYER = \"Layer\";\r\n public static readonly NAME_LENSFLARESYSTEM = \"LensFlareSystem\";\r\n public static readonly NAME_BOUNDINGBOXRENDERER = \"BoundingBoxRenderer\";\r\n public static readonly NAME_PARTICLESYSTEM = \"ParticleSystem\";\r\n public static readonly NAME_GAMEPAD = \"Gamepad\";\r\n public static readonly NAME_SIMPLIFICATIONQUEUE = \"SimplificationQueue\";\r\n public static readonly NAME_GEOMETRYBUFFERRENDERER = \"GeometryBufferRenderer\";\r\n public static readonly NAME_PREPASSRENDERER = \"PrePassRenderer\";\r\n public static readonly NAME_DEPTHRENDERER = \"DepthRenderer\";\r\n public static readonly NAME_DEPTHPEELINGRENDERER = \"DepthPeelingRenderer\";\r\n public static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER = \"PostProcessRenderPipelineManager\";\r\n public static readonly NAME_SPRITE = \"Sprite\";\r\n public static readonly NAME_SUBSURFACE = \"SubSurface\";\r\n public static readonly NAME_OUTLINERENDERER = \"Outline\";\r\n public static readonly NAME_PROCEDURALTEXTURE = \"ProceduralTexture\";\r\n public static readonly NAME_SHADOWGENERATOR = \"ShadowGenerator\";\r\n public static readonly NAME_OCTREE = \"Octree\";\r\n public static readonly NAME_PHYSICSENGINE = \"PhysicsEngine\";\r\n public static readonly NAME_AUDIO = \"Audio\";\r\n public static readonly NAME_FLUIDRENDERER = \"FluidRenderer\";\r\n public static readonly NAME_IBLCDFGENERATOR = \"iblCDFGenerator\";\r\n public static readonly NAME_CLUSTEREDLIGHTING = \"ClusteredLighting\";\r\n\r\n public static readonly STEP_ISREADYFORMESH_EFFECTLAYER = 0;\r\n\r\n public static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;\r\n\r\n public static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;\r\n\r\n public static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0;\r\n\r\n public static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;\r\n\r\n public static readonly STEP_BEFORECAMERADRAW_PREPASS = 0;\r\n public static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER = 1;\r\n public static readonly STEP_BEFORECAMERADRAW_LAYER = 2;\r\n\r\n public static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS = 0;\r\n public static readonly STEP_BEFORERENDERTARGETDRAW_LAYER = 1;\r\n\r\n public static readonly STEP_BEFORERENDERINGMESH_PREPASS = 0;\r\n public static readonly STEP_BEFORERENDERINGMESH_OUTLINE = 1;\r\n\r\n public static readonly STEP_AFTERRENDERINGMESH_PREPASS = 0;\r\n public static readonly STEP_AFTERRENDERINGMESH_OUTLINE = 1;\r\n\r\n public static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;\r\n public static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;\r\n\r\n public static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;\r\n\r\n public static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;\r\n public static readonly STEP_BEFORECLEAR_PREPASS = 1;\r\n\r\n public static readonly STEP_BEFORERENDERTARGETCLEAR_PREPASS = 0;\r\n\r\n public static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS = 0;\r\n public static readonly STEP_AFTERRENDERTARGETDRAW_LAYER = 1;\r\n\r\n public static readonly STEP_AFTERCAMERADRAW_PREPASS = 0;\r\n public static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER = 1;\r\n public static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2;\r\n public static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3;\r\n public static readonly STEP_AFTERCAMERADRAW_LAYER = 4;\r\n public static readonly STEP_AFTERCAMERADRAW_FLUIDRENDERER = 5;\r\n\r\n public static readonly STEP_AFTERCAMERAPOSTPROCESS_LAYER = 0;\r\n\r\n public static readonly STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER = 0;\r\n\r\n public static readonly STEP_AFTERRENDER_AUDIO = 0;\r\n\r\n public static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0;\r\n public static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;\r\n public static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2;\r\n public static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;\r\n\r\n public static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;\r\n public static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER = 1;\r\n public static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_CLUSTEREDLIGHTING = 2;\r\n\r\n public static readonly STEP_POINTERMOVE_SPRITE = 0;\r\n public static readonly STEP_POINTERDOWN_SPRITE = 0;\r\n public static readonly STEP_POINTERUP_SPRITE = 0;\r\n}\r\n\r\n/**\r\n * This represents a scene component.\r\n *\r\n * This is used to decouple the dependency the scene is having on the different workloads like\r\n * layers, post processes...\r\n */\r\nexport interface ISceneComponent {\r\n /**\r\n * The name of the component. Each component must have a unique name.\r\n */\r\n name: string;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n scene: Scene;\r\n\r\n /**\r\n * Register the component to one instance of a scene.\r\n */\r\n register(): void;\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n rebuild(): void;\r\n\r\n /**\r\n * Disposes the component and the associated resources.\r\n */\r\n dispose(): void;\r\n}\r\n\r\n/**\r\n * This represents a SERIALIZABLE scene component.\r\n *\r\n * This extends Scene Component to add Serialization methods on top.\r\n */\r\nexport interface ISceneSerializableComponent extends ISceneComponent {\r\n /**\r\n * Adds all the elements from the container to the scene\r\n * @param container the container holding the elements\r\n */\r\n addFromContainer(container: IAssetContainer): void;\r\n\r\n /**\r\n * Removes all the elements in the container from the scene\r\n * @param container contains the elements to remove\r\n * @param dispose if the removed element should be disposed (default: false)\r\n */\r\n removeFromContainer(container: IAssetContainer, dispose?: boolean): void;\r\n\r\n /**\r\n * Serializes the component data to the specified json object\r\n * @param serializationObject The object to serialize to\r\n */\r\n serialize(serializationObject: any): void;\r\n}\r\n\r\n/**\r\n * Strong typing of a Mesh related stage step action\r\n */\r\nexport type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;\r\n\r\n/**\r\n * Strong typing of a Evaluate Sub Mesh related stage step action\r\n */\r\nexport type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;\r\n\r\n/**\r\n * Strong typing of a pre active Mesh related stage step action\r\n */\r\nexport type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;\r\n\r\n/**\r\n * Strong typing of a Camera related stage step action\r\n */\r\nexport type CameraStageAction = (camera: Camera) => void;\r\n\r\n/**\r\n * Strong typing of a Camera Frame buffer related stage step action\r\n */\r\nexport type CameraStageFrameBufferAction = (camera: Camera) => boolean;\r\n\r\n/**\r\n * Strong typing of a Render Target related stage step action\r\n */\r\nexport type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;\r\n\r\n/**\r\n * Strong typing of a RenderingGroup related stage step action\r\n */\r\nexport type RenderingGroupStageAction = (renderingGroupId: number) => void;\r\n\r\n/**\r\n * Strong typing of a Mesh Render related stage step action\r\n */\r\nexport type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: any, effect: Nullable<Effect>) => void;\r\n\r\n/**\r\n * Strong typing of a simple stage step action\r\n */\r\nexport type SimpleStageAction = () => void;\r\n\r\n/**\r\n * Strong typing of a render target action.\r\n */\r\nexport type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;\r\n\r\n/**\r\n * Strong typing of a pointer move action.\r\n */\r\nexport type PointerMoveStageAction = (\r\n unTranslatedPointerX: number,\r\n unTranslatedPointerY: number,\r\n pickResult: Nullable<PickingInfo>,\r\n isMeshPicked: boolean,\r\n element: Nullable<HTMLElement>\r\n) => Nullable<PickingInfo>;\r\n\r\n/**\r\n * Strong typing of a pointer up/down action.\r\n */\r\nexport type PointerUpDownStageAction = (\r\n unTranslatedPointerX: number,\r\n unTranslatedPointerY: number,\r\n pickResult: Nullable<PickingInfo>,\r\n evt: IPointerEvent,\r\n doubleClick: boolean\r\n) => Nullable<PickingInfo>;\r\n\r\n/**\r\n * Representation of a stage in the scene (Basically a list of ordered steps)\r\n * @internal\r\n */\r\nexport class Stage<T extends Function> extends Array<{ index: number; component: ISceneComponent; action: T }> {\r\n /**\r\n * Hide ctor from the rest of the world.\r\n * @param items The items to add.\r\n */\r\n private constructor(items?: { index: number; component: ISceneComponent; action: T }[]) {\r\n super(...(<any>items));\r\n }\r\n\r\n /**\r\n * Creates a new Stage.\r\n * @returns A new instance of a Stage\r\n */\r\n static Create<T extends Function>(): Stage<T> {\r\n return Object.create(Stage.prototype) as Stage<T>;\r\n }\r\n\r\n /**\r\n * Registers a step in an ordered way in the targeted stage.\r\n * @param index Defines the position to register the step in\r\n * @param component Defines the component attached to the step\r\n * @param action Defines the action to launch during the step\r\n */\r\n public registerStep(index: number, component: ISceneComponent, action: T): void {\r\n let i = 0;\r\n let maxIndex: number;\r\n for (; i < this.length; i++) {\r\n const step = this[i];\r\n maxIndex = step.index;\r\n if (index < maxIndex) {\r\n break;\r\n }\r\n }\r\n this.splice(i, 0, { index, component, action: action.bind(component) });\r\n }\r\n\r\n /**\r\n * Clears all the steps from the stage.\r\n */\r\n public clear(): void {\r\n this.length = 0;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"sceneComponent.js","sourceRoot":"","sources":["../../../dev/core/src/sceneComponent.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,OAAO,uBAAuB;;AACT,wCAAgB,GAAG,aAAa,CAAC;AACjC,kCAAU,GAAG,OAAO,CAAC;AACrB,4CAAoB,GAAG,iBAAiB,CAAC;AACzC,gDAAwB,GAAG,qBAAqB,CAAC;AACjD,2CAAmB,GAAG,gBAAgB,CAAC;AACvC,oCAAY,GAAG,SAAS,CAAC;AACzB,gDAAwB,GAAG,qBAAqB,CAAC;AACjD,mDAA2B,GAAG,wBAAwB,CAAC;AACvD,4CAAoB,GAAG,iBAAiB,CAAC;AACzC,0CAAkB,GAAG,eAAe,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AAC;QACD,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import { type Scene } from \"./scene\";\r\nimport { type SmartArrayNoDuplicate } from \"./Misc/smartArray\";\r\nimport { type Nullable } from \"./types\";\r\nimport { type PickingInfo } from \"./Collisions/pickingInfo\";\r\nimport { type IPointerEvent } from \"./Events/deviceInputEvents\";\r\n\r\nimport { type Mesh } from \"./Meshes/mesh\";\r\nimport { type Effect } from \"./Materials/effect\";\r\nimport { type Camera } from \"./Cameras/camera\";\r\nimport { type AbstractMesh } from \"./Meshes/abstractMesh\";\r\nimport { type SubMesh } from \"./Meshes/subMesh\";\r\nimport { type RenderTargetTexture } from \"./Materials/Textures/renderTargetTexture\";\r\nimport { type IAssetContainer } from \"./IAssetContainer\";\r\n\r\n/**\r\n * Groups all the scene component constants in one place to ease maintenance.\r\n * @internal\r\n */\r\nexport class SceneComponentConstants {\r\n public static readonly NAME_EFFECTLAYER = \"EffectLayer\";\r\n public static readonly NAME_LAYER = \"Layer\";\r\n public static readonly NAME_LENSFLARESYSTEM = \"LensFlareSystem\";\r\n public static readonly NAME_BOUNDINGBOXRENDERER = \"BoundingBoxRenderer\";\r\n public static readonly NAME_PARTICLESYSTEM = \"ParticleSystem\";\r\n public static readonly NAME_GAMEPAD = \"Gamepad\";\r\n public static readonly NAME_SIMPLIFICATIONQUEUE = \"SimplificationQueue\";\r\n public static readonly NAME_GEOMETRYBUFFERRENDERER = \"GeometryBufferRenderer\";\r\n public static readonly NAME_PREPASSRENDERER = \"PrePassRenderer\";\r\n public static readonly NAME_DEPTHRENDERER = \"DepthRenderer\";\r\n public static readonly NAME_DEPTHPEELINGRENDERER = \"DepthPeelingRenderer\";\r\n public static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER = \"PostProcessRenderPipelineManager\";\r\n public static readonly NAME_SPRITE = \"Sprite\";\r\n public static readonly NAME_SUBSURFACE = \"SubSurface\";\r\n public static readonly NAME_OUTLINERENDERER = \"Outline\";\r\n public static readonly NAME_PROCEDURALTEXTURE = \"ProceduralTexture\";\r\n public static readonly NAME_SHADOWGENERATOR = \"ShadowGenerator\";\r\n public static readonly NAME_OCTREE = \"Octree\";\r\n public static readonly NAME_PHYSICSENGINE = \"PhysicsEngine\";\r\n public static readonly NAME_AUDIO = \"Audio\";\r\n public static readonly NAME_FLUIDRENDERER = \"FluidRenderer\";\r\n public static readonly NAME_IBLCDFGENERATOR = \"iblCDFGenerator\";\r\n public static readonly NAME_CLUSTEREDLIGHTING = \"ClusteredLighting\";\r\n\r\n public static readonly STEP_ISREADYFORMESH_EFFECTLAYER = 0;\r\n public static readonly STEP_ISREADYFORMESH_DEPTHRENDERER = 1;\r\n\r\n public static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;\r\n\r\n public static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;\r\n\r\n public static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0;\r\n\r\n public static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;\r\n\r\n public static readonly STEP_BEFORECAMERADRAW_PREPASS = 0;\r\n public static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER = 1;\r\n public static readonly STEP_BEFORECAMERADRAW_LAYER = 2;\r\n\r\n public static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS = 0;\r\n public static readonly STEP_BEFORERENDERTARGETDRAW_LAYER = 1;\r\n\r\n public static readonly STEP_BEFORERENDERINGMESH_PREPASS = 0;\r\n public static readonly STEP_BEFORERENDERINGMESH_OUTLINE = 1;\r\n\r\n public static readonly STEP_AFTERRENDERINGMESH_PREPASS = 0;\r\n public static readonly STEP_AFTERRENDERINGMESH_OUTLINE = 1;\r\n\r\n public static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;\r\n public static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;\r\n\r\n public static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;\r\n\r\n public static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;\r\n public static readonly STEP_BEFORECLEAR_PREPASS = 1;\r\n\r\n public static readonly STEP_BEFORERENDERTARGETCLEAR_PREPASS = 0;\r\n\r\n public static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS = 0;\r\n public static readonly STEP_AFTERRENDERTARGETDRAW_LAYER = 1;\r\n\r\n public static readonly STEP_AFTERCAMERADRAW_PREPASS = 0;\r\n public static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER = 1;\r\n public static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2;\r\n public static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3;\r\n public static readonly STEP_AFTERCAMERADRAW_LAYER = 4;\r\n public static readonly STEP_AFTERCAMERADRAW_FLUIDRENDERER = 5;\r\n\r\n public static readonly STEP_AFTERCAMERAPOSTPROCESS_LAYER = 0;\r\n\r\n public static readonly STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER = 0;\r\n\r\n public static readonly STEP_AFTERRENDER_AUDIO = 0;\r\n\r\n public static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0;\r\n public static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;\r\n public static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2;\r\n public static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;\r\n\r\n public static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;\r\n public static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER = 1;\r\n public static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_CLUSTEREDLIGHTING = 2;\r\n\r\n public static readonly STEP_POINTERMOVE_SPRITE = 0;\r\n public static readonly STEP_POINTERDOWN_SPRITE = 0;\r\n public static readonly STEP_POINTERUP_SPRITE = 0;\r\n}\r\n\r\n/**\r\n * This represents a scene component.\r\n *\r\n * This is used to decouple the dependency the scene is having on the different workloads like\r\n * layers, post processes...\r\n */\r\nexport interface ISceneComponent {\r\n /**\r\n * The name of the component. Each component must have a unique name.\r\n */\r\n name: string;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n scene: Scene;\r\n\r\n /**\r\n * Register the component to one instance of a scene.\r\n */\r\n register(): void;\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n rebuild(): void;\r\n\r\n /**\r\n * Disposes the component and the associated resources.\r\n */\r\n dispose(): void;\r\n}\r\n\r\n/**\r\n * This represents a SERIALIZABLE scene component.\r\n *\r\n * This extends Scene Component to add Serialization methods on top.\r\n */\r\nexport interface ISceneSerializableComponent extends ISceneComponent {\r\n /**\r\n * Adds all the elements from the container to the scene\r\n * @param container the container holding the elements\r\n */\r\n addFromContainer(container: IAssetContainer): void;\r\n\r\n /**\r\n * Removes all the elements in the container from the scene\r\n * @param container contains the elements to remove\r\n * @param dispose if the removed element should be disposed (default: false)\r\n */\r\n removeFromContainer(container: IAssetContainer, dispose?: boolean): void;\r\n\r\n /**\r\n * Serializes the component data to the specified json object\r\n * @param serializationObject The object to serialize to\r\n */\r\n serialize(serializationObject: any): void;\r\n}\r\n\r\n/**\r\n * Strong typing of a Mesh related stage step action\r\n */\r\nexport type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;\r\n\r\n/**\r\n * Strong typing of a Evaluate Sub Mesh related stage step action\r\n */\r\nexport type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;\r\n\r\n/**\r\n * Strong typing of a pre active Mesh related stage step action\r\n */\r\nexport type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;\r\n\r\n/**\r\n * Strong typing of a Camera related stage step action\r\n */\r\nexport type CameraStageAction = (camera: Camera) => void;\r\n\r\n/**\r\n * Strong typing of a Camera Frame buffer related stage step action\r\n */\r\nexport type CameraStageFrameBufferAction = (camera: Camera) => boolean;\r\n\r\n/**\r\n * Strong typing of a Render Target related stage step action\r\n */\r\nexport type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;\r\n\r\n/**\r\n * Strong typing of a RenderingGroup related stage step action\r\n */\r\nexport type RenderingGroupStageAction = (renderingGroupId: number) => void;\r\n\r\n/**\r\n * Strong typing of a Mesh Render related stage step action\r\n */\r\nexport type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: any, effect: Nullable<Effect>) => void;\r\n\r\n/**\r\n * Strong typing of a simple stage step action\r\n */\r\nexport type SimpleStageAction = () => void;\r\n\r\n/**\r\n * Strong typing of a render target action.\r\n */\r\nexport type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;\r\n\r\n/**\r\n * Strong typing of a pointer move action.\r\n */\r\nexport type PointerMoveStageAction = (\r\n unTranslatedPointerX: number,\r\n unTranslatedPointerY: number,\r\n pickResult: Nullable<PickingInfo>,\r\n isMeshPicked: boolean,\r\n element: Nullable<HTMLElement>\r\n) => Nullable<PickingInfo>;\r\n\r\n/**\r\n * Strong typing of a pointer up/down action.\r\n */\r\nexport type PointerUpDownStageAction = (\r\n unTranslatedPointerX: number,\r\n unTranslatedPointerY: number,\r\n pickResult: Nullable<PickingInfo>,\r\n evt: IPointerEvent,\r\n doubleClick: boolean\r\n) => Nullable<PickingInfo>;\r\n\r\n/**\r\n * Representation of a stage in the scene (Basically a list of ordered steps)\r\n * @internal\r\n */\r\nexport class Stage<T extends Function> extends Array<{ index: number; component: ISceneComponent; action: T }> {\r\n /**\r\n * Hide ctor from the rest of the world.\r\n * @param items The items to add.\r\n */\r\n private constructor(items?: { index: number; component: ISceneComponent; action: T }[]) {\r\n super(...(<any>items));\r\n }\r\n\r\n /**\r\n * Creates a new Stage.\r\n * @returns A new instance of a Stage\r\n */\r\n static Create<T extends Function>(): Stage<T> {\r\n return Object.create(Stage.prototype) as Stage<T>;\r\n }\r\n\r\n /**\r\n * Registers a step in an ordered way in the targeted stage.\r\n * @param index Defines the position to register the step in\r\n * @param component Defines the component attached to the step\r\n * @param action Defines the action to launch during the step\r\n */\r\n public registerStep(index: number, component: ISceneComponent, action: T): void {\r\n let i = 0;\r\n let maxIndex: number;\r\n for (; i < this.length; i++) {\r\n const step = this[i];\r\n maxIndex = step.index;\r\n if (index < maxIndex) {\r\n break;\r\n }\r\n }\r\n this.splice(i, 0, { index, component, action: action.bind(component) });\r\n }\r\n\r\n /**\r\n * Clears all the steps from the stage.\r\n */\r\n public clear(): void {\r\n this.length = 0;\r\n }\r\n}\r\n"]}
|