@babylonjs/core 8.17.0 → 8.17.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/Audio/audioEngine.d.ts +11 -16
- package/Audio/audioEngine.js +79 -189
- package/Audio/audioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +15 -1
- package/AudioV2/webAudio/webAudioEngine.js +25 -1
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioMainOut.d.ts +4 -2
- package/AudioV2/webAudio/webAudioMainOut.js +19 -5
- package/AudioV2/webAudio/webAudioMainOut.js.map +1 -1
- package/AudioV2/webAudio/webAudioUnmuteUI.d.ts +6 -0
- package/AudioV2/webAudio/webAudioUnmuteUI.js +30 -2
- package/AudioV2/webAudio/webAudioUnmuteUI.js.map +1 -1
- package/Culling/Helper/computeShaderBoundingHelper.js +1 -1
- package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Layers/effectLayer.d.ts +4 -0
- package/Layers/effectLayer.js +7 -5
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/effectLayerSceneComponent.d.ts +1 -17
- package/Layers/effectLayerSceneComponent.js +0 -11
- package/Layers/effectLayerSceneComponent.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +14 -0
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/ktx2decoderTypes.d.ts +1 -0
- package/Materials/Textures/ktx2decoderTypes.js +2 -0
- package/Materials/Textures/ktx2decoderTypes.js.map +1 -1
- package/Materials/materialHelper.functions.js +1 -2
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +1 -1
- package/Materials/uniformBuffer.js +2 -2
- package/Materials/uniformBuffer.js.map +1 -1
- package/Meshes/trailMesh.js +2 -2
- package/Meshes/trailMesh.js.map +1 -1
- package/Morph/morphTargetManager.js +3 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/IShapeBlock.d.ts +14 -0
- package/Particles/Node/Blocks/Emitters/IShapeBlock.js +2 -0
- package/Particles/Node/Blocks/Emitters/IShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +2 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.d.ts +2 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +2 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +2 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +4 -3
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +4 -4
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.js +0 -1
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/index.d.ts +1 -0
- package/Particles/Node/index.js +1 -0
- package/Particles/Node/index.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.d.ts +34 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +10 -0
- package/Particles/Node/nodeParticleSystemSet.helper.js +90 -0
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -0
- package/Particles/Node/nodeParticleSystemSet.js +64 -1
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/particleSystem.d.ts +4 -6
- package/Particles/particleSystem.js +6 -8
- package/Particles/particleSystem.js.map +1 -1
- package/Physics/v2/characterController.d.ts +1 -1
- package/Physics/v2/characterController.js +1 -1
- package/Physics/v2/characterController.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +1 -1
- package/Physics/v2/physicsBody.js +2 -2
- package/Physics/v2/physicsBody.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.js +2 -2
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.js.map +1 -1
- package/Shaders/ShadersInclude/imageProcessingFunctions.js +1 -0
- package/Shaders/ShadersInclude/imageProcessingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertex.js +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js +1 -0
- package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/boundingInfo.compute.js +2 -2
- package/ShadersWGSL/boundingInfo.compute.js.map +1 -1
- package/XR/features/WebXRControllerMovement.js +1 -1
- package/XR/features/WebXRControllerMovement.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +23 -4
- package/scene.js +38 -4
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXRControllerMovement.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/features/WebXRControllerMov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e,EAAE,wBAAwB,CAAC,aAAa,CAAC;YACzG,eAAe,EAAE,OAAO;YACxB,kBAAkB,EAAE,CAAC,IAAqC,EAAE,aAA2C,EAAE,cAAqD,EAAE,EAAE;gBAC9J,aAAa,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvF,aAAa,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3F,CAAC;SACJ;KACJ;CACJ,AAnBmC,CAmBlC;AAEF;;;;GAIG;AACoB,+BAAO,GAAG,CAAC,AAAJ,CAAK;AA6VvC,oBAAoB,CAAC,eAAe,CAChC,uBAAuB,CAAC,IAAI,EAC5B,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE;IAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,uBAAuB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC,EACD,uBAAuB,CAAC,OAAO,EAC/B,IAAI,CACP,CAAC","sourcesContent":["import { WebXRFeaturesManager, WebXRFeatureName } from \"../webXRFeaturesManager\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { WebXRInput } from \"../webXRInput\";\r\nimport type { WebXRInputSource } from \"../webXRInputSource\";\r\nimport type { IWebXRMotionControllerAxesValue, IWebXRMotionControllerComponentChangesValues } from \"../motionController/webXRControllerComponent\";\r\nimport { WebXRControllerComponent } from \"../motionController/webXRControllerComponent\";\r\nimport { Matrix, Quaternion, Vector3 } from \"../../Maths/math.vector\";\r\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\nimport type { MotionControllerComponentType } from \"../motionController/webXRAbstractMotionController\";\r\nimport { Tools } from \"../../Misc/tools\";\r\n\r\n/**\r\n * The options container for the controller movement module\r\n */\r\nexport interface IWebXRControllerMovementOptions {\r\n /**\r\n * Override default behaviour and provide your own movement controls\r\n */\r\n customRegistrationConfigurations?: WebXRControllerMovementRegistrationConfiguration[];\r\n /**\r\n * Is movement enabled\r\n */\r\n movementEnabled?: boolean;\r\n /**\r\n * Camera direction follows view pose and movement by default will move independently of the viewer's pose.\r\n */\r\n movementOrientationFollowsViewerPose: boolean;\r\n /**\r\n * Movement speed factor (default is 1.0)\r\n */\r\n movementSpeed?: number;\r\n /**\r\n * Minimum threshold the controller's thumbstick/touchpad must pass before being recognized for movement (avoids jitter/unintentional movement)\r\n */\r\n movementThreshold?: number;\r\n /**\r\n * Is rotation enabled\r\n */\r\n rotationEnabled?: boolean;\r\n /**\r\n * Minimum threshold the controller's thumstick/touchpad must pass before being recognized for rotation (avoids jitter/unintentional rotation)\r\n */\r\n rotationThreshold?: number;\r\n /**\r\n * Movement speed factor (default is 1.0)\r\n */\r\n rotationSpeed?: number;\r\n /**\r\n * Babylon XR Input class for controller\r\n */\r\n xrInput: WebXRInput;\r\n\r\n /**\r\n * If movement orientation should follow controller orientation instead of viewer pose.\r\n * Make sure to set movementOrientationFollowsViewerPose to false, otherwise it will be ignored.\r\n */\r\n movementOrientationFollowsController: boolean;\r\n\r\n /**\r\n * If orientation follows the controller, this is the preferred handedness to use for forward movement.\r\n * If not set (or handedness not found), the handedness will be selected by the controller triggering the movement.\r\n * Note that this only works if movementOrientationFollowsController is true.\r\n */\r\n orientationPreferredHandedness?: XRHandedness;\r\n}\r\n\r\n/**\r\n * Feature context is used in handlers and on each XR frame to control the camera movement/direction.\r\n */\r\nexport type WebXRControllerMovementFeatureContext = {\r\n movementEnabled: boolean;\r\n movementOrientationFollowsViewerPose: boolean;\r\n movementOrientationFollowsController: boolean;\r\n orientationPreferredHandedness?: XRHandedness;\r\n movementSpeed: number;\r\n movementThreshold: number;\r\n rotationEnabled: boolean;\r\n rotationSpeed: number;\r\n rotationThreshold: number;\r\n};\r\n\r\n/**\r\n * Current state of Movements shared across components and handlers.\r\n */\r\nexport type WebXRControllerMovementState = {\r\n moveX: number;\r\n moveY: number;\r\n rotateX: number;\r\n rotateY: number;\r\n};\r\n\r\n/**\r\n * Button of Axis Handler must be specified.\r\n */\r\nexport type WebXRControllerMovementRegistrationConfiguration = {\r\n /**\r\n * handlers are filtered to these types only\r\n */\r\n allowedComponentTypes?: MotionControllerComponentType[];\r\n /**\r\n * For registering movement to specific hand only. Useful if your app has a \"main hand\" and \"off hand\" for determining the functionality of a controller.\r\n */\r\n forceHandedness?: XRHandedness;\r\n /**\r\n * For main component only (useful for buttons and may not trigger axis changes).\r\n */\r\n mainComponentOnly?: boolean;\r\n /**\r\n * Additional predicate to apply to controllers to restrict a handler being added.\r\n */\r\n componentSelectionPredicate?: (xrController: WebXRInputSource) => Nullable<WebXRControllerComponent>;\r\n} & (\r\n | {\r\n /**\r\n * Called when axis changes occur.\r\n */\r\n axisChangedHandler: (\r\n axes: IWebXRMotionControllerAxesValue,\r\n movementState: WebXRControllerMovementState,\r\n featureContext: WebXRControllerMovementFeatureContext,\r\n xrInput: WebXRInput\r\n ) => void;\r\n }\r\n | {\r\n /**\r\n * Called when the button state changes.\r\n */\r\n buttonChangedHandler: (\r\n pressed: IWebXRMotionControllerComponentChangesValues<boolean>,\r\n movementState: WebXRControllerMovementState,\r\n featureContext: WebXRControllerMovementFeatureContext,\r\n xrInput: WebXRInput\r\n ) => void;\r\n }\r\n);\r\n\r\ntype RegisteredComponent = {\r\n registrationConfiguration: WebXRControllerMovementRegistrationConfiguration;\r\n component: WebXRControllerComponent;\r\n onAxisChangedObserver?: Nullable<Observer<IWebXRMotionControllerAxesValue>>;\r\n onButtonChangedObserver?: Nullable<Observer<WebXRControllerComponent>>;\r\n};\r\n\r\n/**\r\n * This is a movement feature to be used with WebXR-enabled motion controllers.\r\n * When enabled and attached, the feature will allow a user to move around and rotate in the scene using\r\n * the input of the attached controllers.\r\n */\r\nexport class WebXRControllerMovement extends WebXRAbstractFeature {\r\n private _controllers: {\r\n [controllerUniqueId: string]: {\r\n xrController: WebXRInputSource;\r\n registeredComponents: RegisteredComponent[];\r\n };\r\n } = {};\r\n\r\n private _currentRegistrationConfigurations: WebXRControllerMovementRegistrationConfiguration[] = [];\r\n // Feature configuration is synchronized - this is passed to all handlers (reduce GC pressure).\r\n private _featureContext: WebXRControllerMovementFeatureContext;\r\n // forward direction for movement, which may differ from viewer pose.\r\n private _movementDirection: Quaternion = new Quaternion();\r\n private _movementState: WebXRControllerMovementState;\r\n private _xrInput: WebXRInput;\r\n\r\n // unused\r\n private _tmpRotationMatrix: Matrix = Matrix.Identity();\r\n private _tmpTranslationDirection: Vector3 = new Vector3();\r\n private _tmpMovementTranslation: Vector3 = new Vector3();\r\n private _tempCacheQuaternion: Quaternion = new Quaternion();\r\n\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.MOVEMENT;\r\n\r\n /**\r\n * Standard controller configurations.\r\n */\r\n public static readonly REGISTRATIONS: { [key: string]: WebXRControllerMovementRegistrationConfiguration[] } = {\r\n default: [\r\n {\r\n allowedComponentTypes: [WebXRControllerComponent.THUMBSTICK_TYPE, WebXRControllerComponent.TOUCHPAD_TYPE],\r\n forceHandedness: \"left\",\r\n axisChangedHandler: (axes: IWebXRMotionControllerAxesValue, movementState: WebXRControllerMovementState, featureContext: WebXRControllerMovementFeatureContext) => {\r\n movementState.rotateX = Math.abs(axes.x) > featureContext.rotationThreshold ? axes.x : 0;\r\n movementState.rotateY = Math.abs(axes.y) > featureContext.rotationThreshold ? axes.y : 0;\r\n },\r\n },\r\n {\r\n allowedComponentTypes: [WebXRControllerComponent.THUMBSTICK_TYPE, WebXRControllerComponent.TOUCHPAD_TYPE],\r\n forceHandedness: \"right\",\r\n axisChangedHandler: (axes: IWebXRMotionControllerAxesValue, movementState: WebXRControllerMovementState, featureContext: WebXRControllerMovementFeatureContext) => {\r\n movementState.moveX = Math.abs(axes.x) > featureContext.movementThreshold ? axes.x : 0;\r\n movementState.moveY = Math.abs(axes.y) > featureContext.movementThreshold ? axes.y : 0;\r\n },\r\n },\r\n ],\r\n };\r\n\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the webxr specs version\r\n */\r\n public static readonly Version = 1;\r\n\r\n /**\r\n * Current movement direction. Will be null before XR Frames have been processed.\r\n */\r\n public get movementDirection(): Quaternion {\r\n return this._movementDirection;\r\n }\r\n\r\n /**\r\n * Is movement enabled\r\n */\r\n public get movementEnabled(): boolean {\r\n return this._featureContext.movementEnabled;\r\n }\r\n\r\n /**\r\n * Sets whether movement is enabled or not\r\n * @param enabled is movement enabled\r\n */\r\n public set movementEnabled(enabled: boolean) {\r\n this._featureContext.movementEnabled = enabled;\r\n }\r\n\r\n /**\r\n * If movement follows viewer pose\r\n */\r\n public get movementOrientationFollowsViewerPose(): boolean {\r\n return this._featureContext.movementOrientationFollowsViewerPose;\r\n }\r\n\r\n /**\r\n * Sets whether movement follows viewer pose\r\n * @param followsPose is movement should follow viewer pose\r\n */\r\n public set movementOrientationFollowsViewerPose(followsPose: boolean) {\r\n this._featureContext.movementOrientationFollowsViewerPose = followsPose;\r\n }\r\n\r\n /**\r\n * Gets movement speed\r\n */\r\n public get movementSpeed(): number {\r\n return this._featureContext.movementSpeed;\r\n }\r\n\r\n /**\r\n * Sets movement speed\r\n * @param movementSpeed movement speed\r\n */\r\n public set movementSpeed(movementSpeed: number) {\r\n this._featureContext.movementSpeed = movementSpeed;\r\n }\r\n\r\n /**\r\n * Gets minimum threshold the controller's thumbstick/touchpad must pass before being recognized for movement (avoids jitter/unintentional movement)\r\n */\r\n public get movementThreshold(): number {\r\n return this._featureContext.movementThreshold;\r\n }\r\n\r\n /**\r\n * Sets minimum threshold the controller's thumbstick/touchpad must pass before being recognized for movement (avoids jitter/unintentional movement)\r\n * @param movementThreshold new threshold\r\n */\r\n public set movementThreshold(movementThreshold: number) {\r\n this._featureContext.movementThreshold = movementThreshold;\r\n }\r\n\r\n /**\r\n * Is rotation enabled\r\n */\r\n public get rotationEnabled(): boolean {\r\n return this._featureContext.rotationEnabled;\r\n }\r\n\r\n /**\r\n * Sets whether rotation is enabled or not\r\n * @param enabled is rotation enabled\r\n */\r\n public set rotationEnabled(enabled: boolean) {\r\n this._featureContext.rotationEnabled = enabled;\r\n }\r\n\r\n /**\r\n * Gets rotation speed factor\r\n */\r\n public get rotationSpeed(): number {\r\n return this._featureContext.rotationSpeed;\r\n }\r\n\r\n /**\r\n * Sets rotation speed factor (1.0 is default)\r\n * @param rotationSpeed new rotation speed factor\r\n */\r\n public set rotationSpeed(rotationSpeed: number) {\r\n this._featureContext.rotationSpeed = rotationSpeed;\r\n }\r\n\r\n /**\r\n * Gets minimum threshold the controller's thumbstick/touchpad must pass before being recognized for rotation (avoids jitter/unintentional rotation)\r\n */\r\n public get rotationThreshold(): number {\r\n return this._featureContext.rotationThreshold;\r\n }\r\n\r\n /**\r\n * Sets minimum threshold the controller's thumbstick/touchpad must pass before being recognized for rotation (avoids jitter/unintentional rotation)\r\n * @param threshold new threshold\r\n */\r\n public set rotationThreshold(threshold: number) {\r\n this._featureContext.rotationThreshold = threshold;\r\n }\r\n /**\r\n * constructs a new movement controller system\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n * @param options configuration object for this feature\r\n */\r\n constructor(_xrSessionManager: WebXRSessionManager, options: IWebXRControllerMovementOptions) {\r\n super(_xrSessionManager);\r\n\r\n if (!options || options.xrInput === undefined) {\r\n Tools.Error('WebXRControllerMovement feature requires \"xrInput\" option.');\r\n return;\r\n }\r\n\r\n if (Array.isArray(options.customRegistrationConfigurations)) {\r\n this._currentRegistrationConfigurations = options.customRegistrationConfigurations;\r\n } else {\r\n this._currentRegistrationConfigurations = WebXRControllerMovement.REGISTRATIONS.default;\r\n }\r\n\r\n // synchronized from feature setter properties\r\n this._featureContext = {\r\n movementEnabled: options.movementEnabled || true,\r\n movementOrientationFollowsViewerPose: options.movementOrientationFollowsViewerPose ?? true,\r\n movementOrientationFollowsController: options.movementOrientationFollowsController ?? false,\r\n orientationPreferredHandedness: options.orientationPreferredHandedness,\r\n movementSpeed: options.movementSpeed ?? 1,\r\n movementThreshold: options.movementThreshold ?? 0.25,\r\n rotationEnabled: options.rotationEnabled ?? true,\r\n rotationSpeed: options.rotationSpeed ?? 1.0,\r\n rotationThreshold: options.rotationThreshold ?? 0.25,\r\n };\r\n\r\n this._movementState = {\r\n moveX: 0,\r\n moveY: 0,\r\n rotateX: 0,\r\n rotateY: 0,\r\n };\r\n\r\n this._xrInput = options.xrInput;\r\n }\r\n\r\n public override attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n for (const controller of this._xrInput.controllers) {\r\n this._attachController(controller);\r\n }\r\n this._addNewAttachObserver(this._xrInput.onControllerAddedObservable, this._attachController);\r\n this._addNewAttachObserver(this._xrInput.onControllerRemovedObservable, (controller: WebXRInputSource) => {\r\n // REMOVE the controller\r\n this._detachController(controller.uniqueId);\r\n });\r\n\r\n return true;\r\n }\r\n\r\n public override detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n const keys = Object.keys(this._controllers);\r\n\r\n for (const controllerId of keys) {\r\n this._detachController(controllerId);\r\n }\r\n\r\n this._controllers = {};\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Occurs on every XR frame.\r\n * @param _xrFrame\r\n */\r\n protected _onXRFrame(_xrFrame: XRFrame) {\r\n if (!this.attached) {\r\n return;\r\n }\r\n\r\n if (this._movementState.rotateX !== 0 && this._featureContext.rotationEnabled) {\r\n // smooth rotation\r\n const deltaMillis = this._xrSessionManager.scene.getEngine().getDeltaTime();\r\n const rotationY = deltaMillis * 0.001 * this._featureContext.rotationSpeed * this._movementState.rotateX * (this._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);\r\n\r\n if (this._featureContext.movementOrientationFollowsViewerPose) {\r\n this._xrInput.xrCamera.cameraRotation.y += rotationY;\r\n Quaternion.RotationYawPitchRollToRef(rotationY, 0, 0, this._tempCacheQuaternion);\r\n this._xrInput.xrCamera.rotationQuaternion.multiplyToRef(this._tempCacheQuaternion, this._movementDirection);\r\n } else if (this._featureContext.movementOrientationFollowsController) {\r\n this._xrInput.xrCamera.cameraRotation.y += rotationY;\r\n // get the correct controller\r\n const handedness = this._featureContext.orientationPreferredHandedness || \"right\";\r\n const key =\r\n Object.keys(this._controllers).find((key) => this._controllers[key]?.xrController?.inputSource.handedness === handedness) || Object.keys(this._controllers)[0];\r\n const controller = this._controllers[key];\r\n Quaternion.RotationYawPitchRollToRef(rotationY, 0, 0, this._tempCacheQuaternion);\r\n (controller?.xrController.pointer.rotationQuaternion || Quaternion.Identity()).multiplyToRef(this._tempCacheQuaternion, this._movementDirection);\r\n } else {\r\n // movement orientation direction does not affect camera. We use rotation speed multiplier\r\n // otherwise need to implement inertia and constraints for same feel as TargetCamera.\r\n\r\n Quaternion.RotationYawPitchRollToRef(rotationY * 3.0, 0, 0, this._tempCacheQuaternion);\r\n this._movementDirection.multiplyInPlace(this._tempCacheQuaternion);\r\n }\r\n } else if (this._featureContext.movementOrientationFollowsViewerPose) {\r\n this._movementDirection.copyFrom(this._xrInput.xrCamera.rotationQuaternion);\r\n } else if (this._featureContext.movementOrientationFollowsController) {\r\n // get the correct controller\r\n const handedness = this._featureContext.orientationPreferredHandedness || \"right\";\r\n const key =\r\n Object.keys(this._controllers).find((key) => this._controllers[key]?.xrController.inputSource.handedness === handedness) || Object.keys(this._controllers)[0];\r\n const controller = this._controllers[key];\r\n this._movementDirection.copyFrom(controller?.xrController.pointer.rotationQuaternion || Quaternion.Identity());\r\n }\r\n\r\n if ((this._movementState.moveX || this._movementState.moveY) && this._featureContext.movementEnabled) {\r\n Matrix.FromQuaternionToRef(this._movementDirection, this._tmpRotationMatrix);\r\n this._tmpTranslationDirection.set(this._movementState.moveX, 0, this._movementState.moveY * (this._xrSessionManager.scene.useRightHandedSystem ? 1.0 : -1.0));\r\n // move according to forward direction based on camera speed\r\n Vector3.TransformCoordinatesToRef(this._tmpTranslationDirection, this._tmpRotationMatrix, this._tmpMovementTranslation);\r\n this._tmpMovementTranslation.scaleInPlace(this._xrInput.xrCamera._computeLocalCameraSpeed() * this._featureContext.movementSpeed);\r\n\r\n this._xrInput.xrCamera.cameraDirection.addInPlace(this._tmpMovementTranslation);\r\n }\r\n }\r\n\r\n private _attachController = (xrController: WebXRInputSource) => {\r\n if (this._controllers[xrController.uniqueId]) {\r\n // already attached\r\n return;\r\n }\r\n\r\n this._controllers[xrController.uniqueId] = {\r\n xrController,\r\n registeredComponents: [],\r\n };\r\n const controllerData = this._controllers[xrController.uniqueId];\r\n\r\n // movement controller only available to gamepad-enabled input sources.\r\n if (controllerData.xrController.inputSource.targetRayMode === \"tracked-pointer\" && controllerData.xrController.inputSource.gamepad) {\r\n // motion controller support\r\n const initController = () => {\r\n if (xrController.motionController) {\r\n for (const registration of this._currentRegistrationConfigurations) {\r\n let component: Nullable<WebXRControllerComponent> = null;\r\n\r\n if (registration.allowedComponentTypes) {\r\n for (const componentType of registration.allowedComponentTypes) {\r\n const componentOfType = xrController.motionController.getComponentOfType(componentType);\r\n if (componentOfType !== null) {\r\n component = componentOfType;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (registration.mainComponentOnly) {\r\n const mainComponent = xrController.motionController.getMainComponent();\r\n if (mainComponent === null) {\r\n continue;\r\n }\r\n component = mainComponent;\r\n }\r\n\r\n if (typeof registration.componentSelectionPredicate === \"function\") {\r\n // if does not match we do want to ignore a previously found component\r\n component = registration.componentSelectionPredicate(xrController);\r\n }\r\n\r\n if (component && registration.forceHandedness) {\r\n if (xrController.inputSource.handedness !== registration.forceHandedness) {\r\n continue; // do not register\r\n }\r\n }\r\n\r\n if (component === null) {\r\n continue; // do not register\r\n }\r\n\r\n const registeredComponent: RegisteredComponent = {\r\n registrationConfiguration: registration,\r\n component,\r\n };\r\n controllerData.registeredComponents.push(registeredComponent);\r\n\r\n if (\"axisChangedHandler\" in registration) {\r\n registeredComponent.onAxisChangedObserver = component.onAxisValueChangedObservable.add((axesData) => {\r\n registration.axisChangedHandler(axesData, this._movementState, this._featureContext, this._xrInput);\r\n });\r\n }\r\n\r\n if (\"buttonChangedHandler\" in registration) {\r\n registeredComponent.onButtonChangedObserver = component.onButtonStateChangedObservable.add((component) => {\r\n if (component.changes.pressed) {\r\n registration.buttonChangedHandler(component.changes.pressed, this._movementState, this._featureContext, this._xrInput);\r\n }\r\n });\r\n }\r\n }\r\n }\r\n };\r\n\r\n if (xrController.motionController) {\r\n initController();\r\n } else {\r\n xrController.onMotionControllerInitObservable.addOnce(() => {\r\n initController();\r\n });\r\n }\r\n }\r\n };\r\n\r\n private _detachController(xrControllerUniqueId: string) {\r\n const controllerData = this._controllers[xrControllerUniqueId];\r\n if (!controllerData) {\r\n return;\r\n }\r\n\r\n for (const registeredComponent of controllerData.registeredComponents) {\r\n if (registeredComponent.onAxisChangedObserver) {\r\n registeredComponent.component.onAxisValueChangedObservable.remove(registeredComponent.onAxisChangedObserver);\r\n }\r\n if (registeredComponent.onButtonChangedObserver) {\r\n registeredComponent.component.onButtonStateChangedObservable.remove(registeredComponent.onButtonChangedObserver);\r\n }\r\n }\r\n\r\n // remove from the map\r\n delete this._controllers[xrControllerUniqueId];\r\n }\r\n}\r\n\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRControllerMovement.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRControllerMovement(xrSessionManager, options);\r\n },\r\n WebXRControllerMovement.Version,\r\n true\r\n);\r\n"]}
|
|
1
|
+
{"version":3,"file":"WebXRControllerMovement.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/features/WebXRControllerMovement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,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xB,kBAAkB,EAAE,CAAC,IAAqC,EAAE,aAA2C,EAAE,cAAqD,EAAE,EAAE;gBAC9J,aAAa,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvF,aAAa,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3F,CAAC;SACJ;KACJ;CACJ,AAnBmC,CAmBlC;AAEF;;;;GAIG;AACoB,+BAAO,GAAG,CAAC,AAAJ,CAAK;AA6VvC,oBAAoB,CAAC,eAAe,CAChC,uBAAuB,CAAC,IAAI,EAC5B,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE;IAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,uBAAuB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC,EACD,uBAAuB,CAAC,OAAO,EAC/B,IAAI,CACP,CAAC","sourcesContent":["import { WebXRFeaturesManager, WebXRFeatureName } from \"../webXRFeaturesManager\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { WebXRInput } from \"../webXRInput\";\r\nimport type { WebXRInputSource } from \"../webXRInputSource\";\r\nimport type { IWebXRMotionControllerAxesValue, IWebXRMotionControllerComponentChangesValues } from \"../motionController/webXRControllerComponent\";\r\nimport { WebXRControllerComponent } from \"../motionController/webXRControllerComponent\";\r\nimport { Matrix, Quaternion, Vector3 } from \"../../Maths/math.vector\";\r\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\nimport type { MotionControllerComponentType } from \"../motionController/webXRAbstractMotionController\";\r\nimport { Tools } from \"../../Misc/tools\";\r\n\r\n/**\r\n * The options container for the controller movement module\r\n */\r\nexport interface IWebXRControllerMovementOptions {\r\n /**\r\n * Override default behaviour and provide your own movement controls\r\n */\r\n customRegistrationConfigurations?: WebXRControllerMovementRegistrationConfiguration[];\r\n /**\r\n * Is movement enabled\r\n */\r\n movementEnabled?: boolean;\r\n /**\r\n * Camera direction follows view pose and movement by default will move independently of the viewer's pose.\r\n */\r\n movementOrientationFollowsViewerPose: boolean;\r\n /**\r\n * Movement speed factor (default is 1.0)\r\n */\r\n movementSpeed?: number;\r\n /**\r\n * Minimum threshold the controller's thumbstick/touchpad must pass before being recognized for movement (avoids jitter/unintentional movement)\r\n */\r\n movementThreshold?: number;\r\n /**\r\n * Is rotation enabled\r\n */\r\n rotationEnabled?: boolean;\r\n /**\r\n * Minimum threshold the controller's thumstick/touchpad must pass before being recognized for rotation (avoids jitter/unintentional rotation)\r\n */\r\n rotationThreshold?: number;\r\n /**\r\n * Movement speed factor (default is 1.0)\r\n */\r\n rotationSpeed?: number;\r\n /**\r\n * Babylon XR Input class for controller\r\n */\r\n xrInput: WebXRInput;\r\n\r\n /**\r\n * If movement orientation should follow controller orientation instead of viewer pose.\r\n * Make sure to set movementOrientationFollowsViewerPose to false, otherwise it will be ignored.\r\n */\r\n movementOrientationFollowsController: boolean;\r\n\r\n /**\r\n * If orientation follows the controller, this is the preferred handedness to use for forward movement.\r\n * If not set (or handedness not found), the handedness will be selected by the controller triggering the movement.\r\n * Note that this only works if movementOrientationFollowsController is true.\r\n */\r\n orientationPreferredHandedness?: XRHandedness;\r\n}\r\n\r\n/**\r\n * Feature context is used in handlers and on each XR frame to control the camera movement/direction.\r\n */\r\nexport type WebXRControllerMovementFeatureContext = {\r\n movementEnabled: boolean;\r\n movementOrientationFollowsViewerPose: boolean;\r\n movementOrientationFollowsController: boolean;\r\n orientationPreferredHandedness?: XRHandedness;\r\n movementSpeed: number;\r\n movementThreshold: number;\r\n rotationEnabled: boolean;\r\n rotationSpeed: number;\r\n rotationThreshold: number;\r\n};\r\n\r\n/**\r\n * Current state of Movements shared across components and handlers.\r\n */\r\nexport type WebXRControllerMovementState = {\r\n moveX: number;\r\n moveY: number;\r\n rotateX: number;\r\n rotateY: number;\r\n};\r\n\r\n/**\r\n * Button of Axis Handler must be specified.\r\n */\r\nexport type WebXRControllerMovementRegistrationConfiguration = {\r\n /**\r\n * handlers are filtered to these types only\r\n */\r\n allowedComponentTypes?: MotionControllerComponentType[];\r\n /**\r\n * For registering movement to specific hand only. Useful if your app has a \"main hand\" and \"off hand\" for determining the functionality of a controller.\r\n */\r\n forceHandedness?: XRHandedness;\r\n /**\r\n * For main component only (useful for buttons and may not trigger axis changes).\r\n */\r\n mainComponentOnly?: boolean;\r\n /**\r\n * Additional predicate to apply to controllers to restrict a handler being added.\r\n */\r\n componentSelectionPredicate?: (xrController: WebXRInputSource) => Nullable<WebXRControllerComponent>;\r\n} & (\r\n | {\r\n /**\r\n * Called when axis changes occur.\r\n */\r\n axisChangedHandler: (\r\n axes: IWebXRMotionControllerAxesValue,\r\n movementState: WebXRControllerMovementState,\r\n featureContext: WebXRControllerMovementFeatureContext,\r\n xrInput: WebXRInput\r\n ) => void;\r\n }\r\n | {\r\n /**\r\n * Called when the button state changes.\r\n */\r\n buttonChangedHandler: (\r\n pressed: IWebXRMotionControllerComponentChangesValues<boolean>,\r\n movementState: WebXRControllerMovementState,\r\n featureContext: WebXRControllerMovementFeatureContext,\r\n xrInput: WebXRInput\r\n ) => void;\r\n }\r\n);\r\n\r\ntype RegisteredComponent = {\r\n registrationConfiguration: WebXRControllerMovementRegistrationConfiguration;\r\n component: WebXRControllerComponent;\r\n onAxisChangedObserver?: Nullable<Observer<IWebXRMotionControllerAxesValue>>;\r\n onButtonChangedObserver?: Nullable<Observer<WebXRControllerComponent>>;\r\n};\r\n\r\n/**\r\n * This is a movement feature to be used with WebXR-enabled motion controllers.\r\n * When enabled and attached, the feature will allow a user to move around and rotate in the scene using\r\n * the input of the attached controllers.\r\n */\r\nexport class WebXRControllerMovement extends WebXRAbstractFeature {\r\n private _controllers: {\r\n [controllerUniqueId: string]: {\r\n xrController: WebXRInputSource;\r\n registeredComponents: RegisteredComponent[];\r\n };\r\n } = {};\r\n\r\n private _currentRegistrationConfigurations: WebXRControllerMovementRegistrationConfiguration[] = [];\r\n // Feature configuration is synchronized - this is passed to all handlers (reduce GC pressure).\r\n private _featureContext: WebXRControllerMovementFeatureContext;\r\n // forward direction for movement, which may differ from viewer pose.\r\n private _movementDirection: Quaternion = new Quaternion();\r\n private _movementState: WebXRControllerMovementState;\r\n private _xrInput: WebXRInput;\r\n\r\n // unused\r\n private _tmpRotationMatrix: Matrix = Matrix.Identity();\r\n private _tmpTranslationDirection: Vector3 = new Vector3();\r\n private _tmpMovementTranslation: Vector3 = new Vector3();\r\n private _tempCacheQuaternion: Quaternion = new Quaternion();\r\n\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.MOVEMENT;\r\n\r\n /**\r\n * Standard controller configurations.\r\n */\r\n public static readonly REGISTRATIONS: { [key: string]: WebXRControllerMovementRegistrationConfiguration[] } = {\r\n default: [\r\n {\r\n allowedComponentTypes: [WebXRControllerComponent.THUMBSTICK_TYPE, WebXRControllerComponent.TOUCHPAD_TYPE],\r\n forceHandedness: \"left\",\r\n axisChangedHandler: (axes: IWebXRMotionControllerAxesValue, movementState: WebXRControllerMovementState, featureContext: WebXRControllerMovementFeatureContext) => {\r\n movementState.rotateX = Math.abs(axes.x) > featureContext.rotationThreshold ? axes.x : 0;\r\n movementState.rotateY = Math.abs(axes.y) > featureContext.rotationThreshold ? axes.y : 0;\r\n },\r\n },\r\n {\r\n allowedComponentTypes: [WebXRControllerComponent.THUMBSTICK_TYPE, WebXRControllerComponent.TOUCHPAD_TYPE],\r\n forceHandedness: \"right\",\r\n axisChangedHandler: (axes: IWebXRMotionControllerAxesValue, movementState: WebXRControllerMovementState, featureContext: WebXRControllerMovementFeatureContext) => {\r\n movementState.moveX = Math.abs(axes.x) > featureContext.movementThreshold ? axes.x : 0;\r\n movementState.moveY = Math.abs(axes.y) > featureContext.movementThreshold ? axes.y : 0;\r\n },\r\n },\r\n ],\r\n };\r\n\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the webxr specs version\r\n */\r\n public static readonly Version = 1;\r\n\r\n /**\r\n * Current movement direction. Will be null before XR Frames have been processed.\r\n */\r\n public get movementDirection(): Quaternion {\r\n return this._movementDirection;\r\n }\r\n\r\n /**\r\n * Is movement enabled\r\n */\r\n public get movementEnabled(): boolean {\r\n return this._featureContext.movementEnabled;\r\n }\r\n\r\n /**\r\n * Sets whether movement is enabled or not\r\n * @param enabled is movement enabled\r\n */\r\n public set movementEnabled(enabled: boolean) {\r\n this._featureContext.movementEnabled = enabled;\r\n }\r\n\r\n /**\r\n * If movement follows viewer pose\r\n */\r\n public get movementOrientationFollowsViewerPose(): boolean {\r\n return this._featureContext.movementOrientationFollowsViewerPose;\r\n }\r\n\r\n /**\r\n * Sets whether movement follows viewer pose\r\n * @param followsPose is movement should follow viewer pose\r\n */\r\n public set movementOrientationFollowsViewerPose(followsPose: boolean) {\r\n this._featureContext.movementOrientationFollowsViewerPose = followsPose;\r\n }\r\n\r\n /**\r\n * Gets movement speed\r\n */\r\n public get movementSpeed(): number {\r\n return this._featureContext.movementSpeed;\r\n }\r\n\r\n /**\r\n * Sets movement speed\r\n * @param movementSpeed movement speed\r\n */\r\n public set movementSpeed(movementSpeed: number) {\r\n this._featureContext.movementSpeed = movementSpeed;\r\n }\r\n\r\n /**\r\n * Gets minimum threshold the controller's thumbstick/touchpad must pass before being recognized for movement (avoids jitter/unintentional movement)\r\n */\r\n public get movementThreshold(): number {\r\n return this._featureContext.movementThreshold;\r\n }\r\n\r\n /**\r\n * Sets minimum threshold the controller's thumbstick/touchpad must pass before being recognized for movement (avoids jitter/unintentional movement)\r\n * @param movementThreshold new threshold\r\n */\r\n public set movementThreshold(movementThreshold: number) {\r\n this._featureContext.movementThreshold = movementThreshold;\r\n }\r\n\r\n /**\r\n * Is rotation enabled\r\n */\r\n public get rotationEnabled(): boolean {\r\n return this._featureContext.rotationEnabled;\r\n }\r\n\r\n /**\r\n * Sets whether rotation is enabled or not\r\n * @param enabled is rotation enabled\r\n */\r\n public set rotationEnabled(enabled: boolean) {\r\n this._featureContext.rotationEnabled = enabled;\r\n }\r\n\r\n /**\r\n * Gets rotation speed factor\r\n */\r\n public get rotationSpeed(): number {\r\n return this._featureContext.rotationSpeed;\r\n }\r\n\r\n /**\r\n * Sets rotation speed factor (1.0 is default)\r\n * @param rotationSpeed new rotation speed factor\r\n */\r\n public set rotationSpeed(rotationSpeed: number) {\r\n this._featureContext.rotationSpeed = rotationSpeed;\r\n }\r\n\r\n /**\r\n * Gets minimum threshold the controller's thumbstick/touchpad must pass before being recognized for rotation (avoids jitter/unintentional rotation)\r\n */\r\n public get rotationThreshold(): number {\r\n return this._featureContext.rotationThreshold;\r\n }\r\n\r\n /**\r\n * Sets minimum threshold the controller's thumbstick/touchpad must pass before being recognized for rotation (avoids jitter/unintentional rotation)\r\n * @param threshold new threshold\r\n */\r\n public set rotationThreshold(threshold: number) {\r\n this._featureContext.rotationThreshold = threshold;\r\n }\r\n /**\r\n * constructs a new movement controller system\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n * @param options configuration object for this feature\r\n */\r\n constructor(_xrSessionManager: WebXRSessionManager, options: IWebXRControllerMovementOptions) {\r\n super(_xrSessionManager);\r\n\r\n if (!options || options.xrInput === undefined) {\r\n Tools.Error('WebXRControllerMovement feature requires \"xrInput\" option.');\r\n return;\r\n }\r\n\r\n if (Array.isArray(options.customRegistrationConfigurations)) {\r\n this._currentRegistrationConfigurations = options.customRegistrationConfigurations;\r\n } else {\r\n this._currentRegistrationConfigurations = WebXRControllerMovement.REGISTRATIONS.default;\r\n }\r\n\r\n // synchronized from feature setter properties\r\n this._featureContext = {\r\n movementEnabled: options.movementEnabled ?? true,\r\n movementOrientationFollowsViewerPose: options.movementOrientationFollowsViewerPose ?? true,\r\n movementOrientationFollowsController: options.movementOrientationFollowsController ?? false,\r\n orientationPreferredHandedness: options.orientationPreferredHandedness,\r\n movementSpeed: options.movementSpeed ?? 1,\r\n movementThreshold: options.movementThreshold ?? 0.25,\r\n rotationEnabled: options.rotationEnabled ?? true,\r\n rotationSpeed: options.rotationSpeed ?? 1.0,\r\n rotationThreshold: options.rotationThreshold ?? 0.25,\r\n };\r\n\r\n this._movementState = {\r\n moveX: 0,\r\n moveY: 0,\r\n rotateX: 0,\r\n rotateY: 0,\r\n };\r\n\r\n this._xrInput = options.xrInput;\r\n }\r\n\r\n public override attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n for (const controller of this._xrInput.controllers) {\r\n this._attachController(controller);\r\n }\r\n this._addNewAttachObserver(this._xrInput.onControllerAddedObservable, this._attachController);\r\n this._addNewAttachObserver(this._xrInput.onControllerRemovedObservable, (controller: WebXRInputSource) => {\r\n // REMOVE the controller\r\n this._detachController(controller.uniqueId);\r\n });\r\n\r\n return true;\r\n }\r\n\r\n public override detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n const keys = Object.keys(this._controllers);\r\n\r\n for (const controllerId of keys) {\r\n this._detachController(controllerId);\r\n }\r\n\r\n this._controllers = {};\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Occurs on every XR frame.\r\n * @param _xrFrame\r\n */\r\n protected _onXRFrame(_xrFrame: XRFrame) {\r\n if (!this.attached) {\r\n return;\r\n }\r\n\r\n if (this._movementState.rotateX !== 0 && this._featureContext.rotationEnabled) {\r\n // smooth rotation\r\n const deltaMillis = this._xrSessionManager.scene.getEngine().getDeltaTime();\r\n const rotationY = deltaMillis * 0.001 * this._featureContext.rotationSpeed * this._movementState.rotateX * (this._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);\r\n\r\n if (this._featureContext.movementOrientationFollowsViewerPose) {\r\n this._xrInput.xrCamera.cameraRotation.y += rotationY;\r\n Quaternion.RotationYawPitchRollToRef(rotationY, 0, 0, this._tempCacheQuaternion);\r\n this._xrInput.xrCamera.rotationQuaternion.multiplyToRef(this._tempCacheQuaternion, this._movementDirection);\r\n } else if (this._featureContext.movementOrientationFollowsController) {\r\n this._xrInput.xrCamera.cameraRotation.y += rotationY;\r\n // get the correct controller\r\n const handedness = this._featureContext.orientationPreferredHandedness || \"right\";\r\n const key =\r\n Object.keys(this._controllers).find((key) => this._controllers[key]?.xrController?.inputSource.handedness === handedness) || Object.keys(this._controllers)[0];\r\n const controller = this._controllers[key];\r\n Quaternion.RotationYawPitchRollToRef(rotationY, 0, 0, this._tempCacheQuaternion);\r\n (controller?.xrController.pointer.rotationQuaternion || Quaternion.Identity()).multiplyToRef(this._tempCacheQuaternion, this._movementDirection);\r\n } else {\r\n // movement orientation direction does not affect camera. We use rotation speed multiplier\r\n // otherwise need to implement inertia and constraints for same feel as TargetCamera.\r\n\r\n Quaternion.RotationYawPitchRollToRef(rotationY * 3.0, 0, 0, this._tempCacheQuaternion);\r\n this._movementDirection.multiplyInPlace(this._tempCacheQuaternion);\r\n }\r\n } else if (this._featureContext.movementOrientationFollowsViewerPose) {\r\n this._movementDirection.copyFrom(this._xrInput.xrCamera.rotationQuaternion);\r\n } else if (this._featureContext.movementOrientationFollowsController) {\r\n // get the correct controller\r\n const handedness = this._featureContext.orientationPreferredHandedness || \"right\";\r\n const key =\r\n Object.keys(this._controllers).find((key) => this._controllers[key]?.xrController.inputSource.handedness === handedness) || Object.keys(this._controllers)[0];\r\n const controller = this._controllers[key];\r\n this._movementDirection.copyFrom(controller?.xrController.pointer.rotationQuaternion || Quaternion.Identity());\r\n }\r\n\r\n if ((this._movementState.moveX || this._movementState.moveY) && this._featureContext.movementEnabled) {\r\n Matrix.FromQuaternionToRef(this._movementDirection, this._tmpRotationMatrix);\r\n this._tmpTranslationDirection.set(this._movementState.moveX, 0, this._movementState.moveY * (this._xrSessionManager.scene.useRightHandedSystem ? 1.0 : -1.0));\r\n // move according to forward direction based on camera speed\r\n Vector3.TransformCoordinatesToRef(this._tmpTranslationDirection, this._tmpRotationMatrix, this._tmpMovementTranslation);\r\n this._tmpMovementTranslation.scaleInPlace(this._xrInput.xrCamera._computeLocalCameraSpeed() * this._featureContext.movementSpeed);\r\n\r\n this._xrInput.xrCamera.cameraDirection.addInPlace(this._tmpMovementTranslation);\r\n }\r\n }\r\n\r\n private _attachController = (xrController: WebXRInputSource) => {\r\n if (this._controllers[xrController.uniqueId]) {\r\n // already attached\r\n return;\r\n }\r\n\r\n this._controllers[xrController.uniqueId] = {\r\n xrController,\r\n registeredComponents: [],\r\n };\r\n const controllerData = this._controllers[xrController.uniqueId];\r\n\r\n // movement controller only available to gamepad-enabled input sources.\r\n if (controllerData.xrController.inputSource.targetRayMode === \"tracked-pointer\" && controllerData.xrController.inputSource.gamepad) {\r\n // motion controller support\r\n const initController = () => {\r\n if (xrController.motionController) {\r\n for (const registration of this._currentRegistrationConfigurations) {\r\n let component: Nullable<WebXRControllerComponent> = null;\r\n\r\n if (registration.allowedComponentTypes) {\r\n for (const componentType of registration.allowedComponentTypes) {\r\n const componentOfType = xrController.motionController.getComponentOfType(componentType);\r\n if (componentOfType !== null) {\r\n component = componentOfType;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (registration.mainComponentOnly) {\r\n const mainComponent = xrController.motionController.getMainComponent();\r\n if (mainComponent === null) {\r\n continue;\r\n }\r\n component = mainComponent;\r\n }\r\n\r\n if (typeof registration.componentSelectionPredicate === \"function\") {\r\n // if does not match we do want to ignore a previously found component\r\n component = registration.componentSelectionPredicate(xrController);\r\n }\r\n\r\n if (component && registration.forceHandedness) {\r\n if (xrController.inputSource.handedness !== registration.forceHandedness) {\r\n continue; // do not register\r\n }\r\n }\r\n\r\n if (component === null) {\r\n continue; // do not register\r\n }\r\n\r\n const registeredComponent: RegisteredComponent = {\r\n registrationConfiguration: registration,\r\n component,\r\n };\r\n controllerData.registeredComponents.push(registeredComponent);\r\n\r\n if (\"axisChangedHandler\" in registration) {\r\n registeredComponent.onAxisChangedObserver = component.onAxisValueChangedObservable.add((axesData) => {\r\n registration.axisChangedHandler(axesData, this._movementState, this._featureContext, this._xrInput);\r\n });\r\n }\r\n\r\n if (\"buttonChangedHandler\" in registration) {\r\n registeredComponent.onButtonChangedObserver = component.onButtonStateChangedObservable.add((component) => {\r\n if (component.changes.pressed) {\r\n registration.buttonChangedHandler(component.changes.pressed, this._movementState, this._featureContext, this._xrInput);\r\n }\r\n });\r\n }\r\n }\r\n }\r\n };\r\n\r\n if (xrController.motionController) {\r\n initController();\r\n } else {\r\n xrController.onMotionControllerInitObservable.addOnce(() => {\r\n initController();\r\n });\r\n }\r\n }\r\n };\r\n\r\n private _detachController(xrControllerUniqueId: string) {\r\n const controllerData = this._controllers[xrControllerUniqueId];\r\n if (!controllerData) {\r\n return;\r\n }\r\n\r\n for (const registeredComponent of controllerData.registeredComponents) {\r\n if (registeredComponent.onAxisChangedObserver) {\r\n registeredComponent.component.onAxisValueChangedObservable.remove(registeredComponent.onAxisChangedObserver);\r\n }\r\n if (registeredComponent.onButtonChangedObserver) {\r\n registeredComponent.component.onButtonStateChangedObservable.remove(registeredComponent.onButtonChangedObserver);\r\n }\r\n }\r\n\r\n // remove from the map\r\n delete this._controllers[xrControllerUniqueId];\r\n }\r\n}\r\n\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRControllerMovement.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRControllerMovement(xrSessionManager, options);\r\n },\r\n WebXRControllerMovement.Version,\r\n true\r\n);\r\n"]}
|
package/package.json
CHANGED
package/scene.d.ts
CHANGED
|
@@ -594,10 +594,6 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
|
|
|
594
594
|
* An event triggered when a multi material is created
|
|
595
595
|
*/
|
|
596
596
|
onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
|
|
597
|
-
/**
|
|
598
|
-
* An event triggered when a post process is created
|
|
599
|
-
*/
|
|
600
|
-
onNewPostProcessAddedObservable: Observable<PostProcess>;
|
|
601
597
|
/**
|
|
602
598
|
* An event triggered when a material is removed
|
|
603
599
|
*/
|
|
@@ -622,10 +618,22 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
|
|
|
622
618
|
* An event triggered when a frame graph is removed
|
|
623
619
|
*/
|
|
624
620
|
onFrameGraphRemovedObservable: Observable<FrameGraph>;
|
|
621
|
+
/**
|
|
622
|
+
* An event triggered when a post process is created
|
|
623
|
+
*/
|
|
624
|
+
onNewPostProcessAddedObservable: Observable<PostProcess>;
|
|
625
625
|
/**
|
|
626
626
|
* An event triggered when a post process is removed
|
|
627
627
|
*/
|
|
628
628
|
onPostProcessRemovedObservable: Observable<PostProcess>;
|
|
629
|
+
/**
|
|
630
|
+
* An event triggered when an effect layer is created
|
|
631
|
+
*/
|
|
632
|
+
onNewEffectLayerAddedObservable: Observable<EffectLayer>;
|
|
633
|
+
/**
|
|
634
|
+
* An event triggered when an effect layer is removed
|
|
635
|
+
*/
|
|
636
|
+
onEffectLayerRemovedObservable: Observable<EffectLayer>;
|
|
629
637
|
/**
|
|
630
638
|
* An event triggered when render targets are about to be rendered
|
|
631
639
|
* Can happen multiple times per frame.
|
|
@@ -1673,6 +1681,12 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
|
|
|
1673
1681
|
* @returns The index of the removed post-process
|
|
1674
1682
|
*/
|
|
1675
1683
|
removePostProcess(toRemove: PostProcess): number;
|
|
1684
|
+
/**
|
|
1685
|
+
* Removes the given layer from this scene.
|
|
1686
|
+
* @param toRemove The layer to remove
|
|
1687
|
+
* @returns The index of the removed layer
|
|
1688
|
+
*/
|
|
1689
|
+
removeEffectLayer(toRemove: EffectLayer): number;
|
|
1676
1690
|
/**
|
|
1677
1691
|
* Adds the given light to this scene
|
|
1678
1692
|
* @param newLight The light to add
|
|
@@ -1748,6 +1762,11 @@ export declare class Scene implements IAnimatable, IClipPlanesHolder, IAssetCont
|
|
|
1748
1762
|
* @param newPostProcess The post process to add
|
|
1749
1763
|
*/
|
|
1750
1764
|
addPostProcess(newPostProcess: PostProcess): void;
|
|
1765
|
+
/**
|
|
1766
|
+
* Adds the given effect layer to this scene.
|
|
1767
|
+
* @param newEffectLayer The effect layer to add
|
|
1768
|
+
*/
|
|
1769
|
+
addEffectLayer(newEffectLayer: EffectLayer): void;
|
|
1751
1770
|
/**
|
|
1752
1771
|
* Switch active camera
|
|
1753
1772
|
* @param newCamera defines the new active camera
|
package/scene.js
CHANGED
|
@@ -1007,10 +1007,6 @@ export class Scene {
|
|
|
1007
1007
|
* An event triggered when a multi material is created
|
|
1008
1008
|
*/
|
|
1009
1009
|
this.onNewMultiMaterialAddedObservable = new Observable();
|
|
1010
|
-
/**
|
|
1011
|
-
* An event triggered when a post process is created
|
|
1012
|
-
*/
|
|
1013
|
-
this.onNewPostProcessAddedObservable = new Observable();
|
|
1014
1010
|
/**
|
|
1015
1011
|
* An event triggered when a material is removed
|
|
1016
1012
|
*/
|
|
@@ -1035,10 +1031,22 @@ export class Scene {
|
|
|
1035
1031
|
* An event triggered when a frame graph is removed
|
|
1036
1032
|
*/
|
|
1037
1033
|
this.onFrameGraphRemovedObservable = new Observable();
|
|
1034
|
+
/**
|
|
1035
|
+
* An event triggered when a post process is created
|
|
1036
|
+
*/
|
|
1037
|
+
this.onNewPostProcessAddedObservable = new Observable();
|
|
1038
1038
|
/**
|
|
1039
1039
|
* An event triggered when a post process is removed
|
|
1040
1040
|
*/
|
|
1041
1041
|
this.onPostProcessRemovedObservable = new Observable();
|
|
1042
|
+
/**
|
|
1043
|
+
* An event triggered when an effect layer is created
|
|
1044
|
+
*/
|
|
1045
|
+
this.onNewEffectLayerAddedObservable = new Observable();
|
|
1046
|
+
/**
|
|
1047
|
+
* An event triggered when an effect layer is removed
|
|
1048
|
+
*/
|
|
1049
|
+
this.onEffectLayerRemovedObservable = new Observable();
|
|
1042
1050
|
/**
|
|
1043
1051
|
* An event triggered when render targets are about to be rendered
|
|
1044
1052
|
* Can happen multiple times per frame.
|
|
@@ -2427,6 +2435,19 @@ export class Scene {
|
|
|
2427
2435
|
this.onPostProcessRemovedObservable.notifyObservers(toRemove);
|
|
2428
2436
|
return index;
|
|
2429
2437
|
}
|
|
2438
|
+
/**
|
|
2439
|
+
* Removes the given layer from this scene.
|
|
2440
|
+
* @param toRemove The layer to remove
|
|
2441
|
+
* @returns The index of the removed layer
|
|
2442
|
+
*/
|
|
2443
|
+
removeEffectLayer(toRemove) {
|
|
2444
|
+
const index = this.effectLayers.indexOf(toRemove);
|
|
2445
|
+
if (index !== -1) {
|
|
2446
|
+
this.effectLayers.splice(index, 1);
|
|
2447
|
+
}
|
|
2448
|
+
this.onEffectLayerRemovedObservable.notifyObservers(toRemove);
|
|
2449
|
+
return index;
|
|
2450
|
+
}
|
|
2430
2451
|
/**
|
|
2431
2452
|
* Adds the given light to this scene
|
|
2432
2453
|
* @param newLight The light to add
|
|
@@ -2620,6 +2641,19 @@ export class Scene {
|
|
|
2620
2641
|
this.onNewPostProcessAddedObservable.notifyObservers(newPostProcess);
|
|
2621
2642
|
});
|
|
2622
2643
|
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Adds the given effect layer to this scene.
|
|
2646
|
+
* @param newEffectLayer The effect layer to add
|
|
2647
|
+
*/
|
|
2648
|
+
addEffectLayer(newEffectLayer) {
|
|
2649
|
+
if (this._blockEntityCollection) {
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
this.effectLayers.push(newEffectLayer);
|
|
2653
|
+
Tools.SetImmediate(() => {
|
|
2654
|
+
this.onNewEffectLayerAddedObservable.notifyObservers(newEffectLayer);
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2623
2657
|
/**
|
|
2624
2658
|
* Switch active camera
|
|
2625
2659
|
* @param newCamera defines the new active camera
|