<commit_before>module BABYLON {
    export interface VRTeleportationOptions {
        floorMeshName?: string; // If you'd like to provide a mesh acting as the floor
    }

    export class VRExperienceHelper {
        private _scene: BABYLON.Scene;
        private _position: Vector3;
        private _btnVR: HTMLButtonElement;

        // Can the system support WebVR, even if a headset isn't plugged in?
        private _webVRsupported = false;
        // If WebVR is supported, is a headset plugged in and are we ready to present?
        private _webVRready = false;
        // Are we waiting for the requestPresent callback to complete?
        private _webVRrequesting = false;
        // Are we presenting to the headset right now?
        private _webVRpresenting = false;

        // Are we presenting in the fullscreen fallback?
        private _fullscreenVRpresenting = false;

        private _canvas: Nullable<HTMLCanvasElement>;
        private _webVRCamera: WebVRFreeCamera;
        private _vrDeviceOrientationCamera: VRDeviceOrientationFreeCamera;
        private _deviceOrientationCamera: DeviceOrientationCamera;
        
        private _onKeyDown: (event: KeyboardEvent) => void;
        private _onVrDisplayPresentChange: any;
        private _onVRDisplayChanged: (eventArgs:IDisplayChangedEventArgs) => void;
        private _onVRRequestPresentStart: () => void;
        private _onVRRequestPresentComplete: (success: boolean) => void;
        
        public onEnteringVR: () => void;
        public onExitingVR: () => void;
        public onControllerMeshLoaded: (controller: WebVRController) => void;

        private _useCustomVRButton: boolean = false;
        private _teleportationRequested: boolean = false;
        private _teleportationEnabledOnLeftController: boolean = false;
        private _teleportationEnabledOnRightController: boolean = false;
        private _leftControllerReady: boolean = false;
        private _rightControllerReady: boolean = false;
        private _floorMeshName: string;
        private _teleportationAllowed: boolean = false;
        private _rotationAllowed: boolean = true;
        private _teleportationRequestInitiated = false;
        private _rotationRightAsked = false;
        private _rotationLeftAsked = false;
        private _teleportationCircle: Mesh;
        private _postProcessMove: ImageProcessingPostProcess;
        private _passProcessMove: PassPostProcess;
        private _teleportationFillColor: string = "#444444";
        private _teleportationBorderColor: string = "#FFFFFF";
        private _rotationAngle: number = 0;
        private _haloCenter = new Vector3(0, 0, 0);
        private _gazeTracker: BABYLON.Mesh;
        private _padSensibilityUp = 0.7;
        private _padSensibilityDown = 0.3;
        private _leftLaserPointer: Mesh;
        private _rightLaserPointer: Mesh;
        private _currentMeshSelected: Nullable<AbstractMesh>;
        public onNewMeshSelected = new Observable<AbstractMesh>();

        private _meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
        public meshSelectionPredicate: (mesh: AbstractMesh) => boolean;

        public get deviceOrientationCamera(): DeviceOrientationCamera {
            return this._deviceOrientationCamera;
        }

        // Based on the current WebVR support, returns the current VR camera used
        public get currentVRCamera(): FreeCamera {
            if (this._webVRready) {
                return this._webVRCamera;
            }
            else {
                return this._vrDeviceOrientationCamera;
            }
        }

        public get webVRCamera(): WebVRFreeCamera {
            return this._webVRCamera;
        }

        public get vrDeviceOrientationCamera(): VRDeviceOrientationFreeCamera {
            return this._vrDeviceOrientationCamera;
        }
                
        constructor(scene: Scene, public webVROptions: WebVROptions = {}) {
            this._scene = scene;

            if (!this._scene.activeCamera || isNaN(this._scene.activeCamera.position.x)) {
                this._position = new BABYLON.Vector3(0, 2, 0);
                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 2, 0), scene);
            }
            else {
                this._position = this._scene.activeCamera.position.clone();
                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, scene);
                this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
                this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
            }
            this._scene.activeCamera = this._deviceOrientationCamera;
            this._canvas = scene.getEngine().getRenderingCanvas();
            if (this._canvas) {
                this._scene.activeCamera.attachControl(this._canvas);
            }

            if (webVROptions) {
                if (webVROptions.useCustomVRButton) {<commit_msg>Have initial created camera oriented like the previous camera<commit_after>module BABYLON {
    export interface VRTeleportationOptions {
        floorMeshName?: string; // If you'd like to provide a mesh acting as the floor
    }

    export class VRExperienceHelper {
        private _scene: BABYLON.Scene;
        private _position: Vector3;
        private _btnVR: HTMLButtonElement;

        // Can the system support WebVR, even if a headset isn't plugged in?
        private _webVRsupported = false;
        // If WebVR is supported, is a headset plugged in and are we ready to present?
        private _webVRready = false;
        // Are we waiting for the requestPresent callback to complete?
        private _webVRrequesting = false;
        // Are we presenting to the headset right now?
        private _webVRpresenting = false;

        // Are we presenting in the fullscreen fallback?
        private _fullscreenVRpresenting = false;

        private _canvas: Nullable<HTMLCanvasElement>;
        private _webVRCamera: WebVRFreeCamera;
        private _vrDeviceOrientationCamera: VRDeviceOrientationFreeCamera;
        private _deviceOrientationCamera: DeviceOrientationCamera;
        
        private _onKeyDown: (event: KeyboardEvent) => void;
        private _onVrDisplayPresentChange: any;
        private _onVRDisplayChanged: (eventArgs:IDisplayChangedEventArgs) => void;
        private _onVRRequestPresentStart: () => void;
        private _onVRRequestPresentComplete: (success: boolean) => void;
        
        public onEnteringVR: () => void;
        public onExitingVR: () => void;
        public onControllerMeshLoaded: (controller: WebVRController) => void;

        private _useCustomVRButton: boolean = false;
        private _teleportationRequested: boolean = false;
        private _teleportationEnabledOnLeftController: boolean = false;
        private _teleportationEnabledOnRightController: boolean = false;
        private _leftControllerReady: boolean = false;
        private _rightControllerReady: boolean = false;
        private _floorMeshName: string;
        private _teleportationAllowed: boolean = false;
        private _rotationAllowed: boolean = true;
        private _teleportationRequestInitiated = false;
        private _rotationRightAsked = false;
        private _rotationLeftAsked = false;
        private _teleportationCircle: Mesh;
        private _postProcessMove: ImageProcessingPostProcess;
        private _passProcessMove: PassPostProcess;
        private _teleportationFillColor: string = "#444444";
        private _teleportationBorderColor: string = "#FFFFFF";
        private _rotationAngle: number = 0;
        private _haloCenter = new Vector3(0, 0, 0);
        private _gazeTracker: BABYLON.Mesh;
        private _padSensibilityUp = 0.7;
        private _padSensibilityDown = 0.3;
        private _leftLaserPointer: Mesh;
        private _rightLaserPointer: Mesh;
        private _currentMeshSelected: Nullable<AbstractMesh>;
        public onNewMeshSelected = new Observable<AbstractMesh>();

        private _meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
        public meshSelectionPredicate: (mesh: AbstractMesh) => boolean;

        public get deviceOrientationCamera(): DeviceOrientationCamera {
            return this._deviceOrientationCamera;
        }

        // Based on the current WebVR support, returns the current VR camera used
        public get currentVRCamera(): FreeCamera {
            if (this._webVRready) {
                return this._webVRCamera;
            }
            else {
                return this._vrDeviceOrientationCamera;
            }
        }

        public get webVRCamera(): WebVRFreeCamera {
            return this._webVRCamera;
        }

        public get vrDeviceOrientationCamera(): VRDeviceOrientationFreeCamera {
            return this._vrDeviceOrientationCamera;
        }
                
        constructor(scene: Scene, public webVROptions: WebVROptions = {}) {
            this._scene = scene;

            if (!this._scene.activeCamera || isNaN(this._scene.activeCamera.position.x)) {
                this._position = new BABYLON.Vector3(0, 2, 0);
                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 2, 0), scene);
            }
            else {
                this._position = this._scene.activeCamera.position.clone();
                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, scene);
                this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
                this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
                // Set rotation from previous camera
                if(this._scene.activeCamera instanceof TargetCamera){
                    var targetCamera = this._scene.activeCamera;
                    if(targetCamera.rotationQuaternion && targetCamera.rotation){
                        this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
                        this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
                    }else if(targetCamera.rotation){
                        this._deviceOrientationCamera.rotationQuaternion.copyFrom(Quaternion.RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
                        this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
                    }
                }
            }
            this._scene.activeCamera = this._deviceOrientationCamera;
            this._canvas = scene.getEngine().getRenderingCanvas();
            if (this._canvas) {
                this._scene.activeCamera.attachControl(this._canvas);
            }

            if (webVROptions) {
                if (webVROptions.useCustomVRButton) {
{'fraction_non_alphanumeric': 0.07131206959043132, 'fraction_numerical': 0.004349401957230881, 'mean_word_length': 2.5488745980707397, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5926842', 'n_tokens_mistral': 2846, 'n_tokens_neox': 2637, 'n_words': 689}