074b51d8627916358877f1ccd1be09ffe9c42e6d3046aadf16575950e42e831d.json 14 KB

1
  1. {"ast":null,"code":"import { __decorate } from \"../../tslib.es6.js\";\nimport { serialize } from \"../../Misc/decorators.js\";\nimport { Observable } from \"../../Misc/observable.js\";\nimport { PointerEventTypes } from \"../../Events/pointerEvents.js\";\nimport { EventConstants } from \"../../Events/deviceInputEvents.js\";\nimport { Tools } from \"../../Misc/tools.js\";\n/**\n * Base class for mouse wheel input..\n * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts\n * for example usage.\n */\nexport class BaseCameraMouseWheelInput {\n constructor() {\n /**\n * How fast is the camera moves in relation to X axis mouseWheel events.\n * Use negative value to reverse direction.\n */\n this.wheelPrecisionX = 3.0;\n /**\n * How fast is the camera moves in relation to Y axis mouseWheel events.\n * Use negative value to reverse direction.\n */\n this.wheelPrecisionY = 3.0;\n /**\n * How fast is the camera moves in relation to Z axis mouseWheel events.\n * Use negative value to reverse direction.\n */\n this.wheelPrecisionZ = 3.0;\n /**\n * Observable for when a mouse wheel move event occurs.\n */\n this.onChangedObservable = new Observable();\n /**\n * Incremental value of multiple mouse wheel movements of the X axis.\n * Should be zero-ed when read.\n */\n this._wheelDeltaX = 0;\n /**\n * Incremental value of multiple mouse wheel movements of the Y axis.\n * Should be zero-ed when read.\n */\n this._wheelDeltaY = 0;\n /**\n * Incremental value of multiple mouse wheel movements of the Z axis.\n * Should be zero-ed when read.\n */\n this._wheelDeltaZ = 0;\n /**\n * Firefox uses a different scheme to report scroll distances to other\n * browsers. Rather than use complicated methods to calculate the exact\n * multiple we need to apply, let's just cheat and use a constant.\n * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode\n * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line\n */\n this._ffMultiplier = 12;\n /**\n * Different event attributes for wheel data fall into a few set ranges.\n * Some relevant but dated date here:\n * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers\n */\n this._normalize = 120;\n }\n /**\n * Attach the input controls to a specific dom element to get the input from.\n * @param noPreventDefault Defines whether event caught by the controls\n * should call preventdefault().\n * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\n */\n attachControl(noPreventDefault) {\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\n this._wheel = pointer => {\n // sanity check - this should be a PointerWheel event.\n if (pointer.type !== PointerEventTypes.POINTERWHEEL) {\n return;\n }\n const event = pointer.event;\n const platformScale = event.deltaMode === EventConstants.DOM_DELTA_LINE ? this._ffMultiplier : 1; // If this happens to be set to DOM_DELTA_LINE, adjust accordingly\n this._wheelDeltaX += this.wheelPrecisionX * platformScale * event.deltaX / this._normalize;\n this._wheelDeltaY -= this.wheelPrecisionY * platformScale * event.deltaY / this._normalize;\n this._wheelDeltaZ += this.wheelPrecisionZ * platformScale * event.deltaZ / this._normalize;\n if (event.preventDefault) {\n if (!noPreventDefault) {\n event.preventDefault();\n }\n }\n };\n this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel, PointerEventTypes.POINTERWHEEL);\n }\n /**\n * Detach the current controls from the specified dom element.\n */\n detachControl() {\n if (this._observer) {\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\n this._observer = null;\n this._wheel = null;\n }\n if (this.onChangedObservable) {\n this.onChangedObservable.clear();\n }\n }\n /**\n * Called for each rendered frame.\n */\n checkInputs() {\n this.onChangedObservable.notifyObservers({\n wheelDeltaX: this._wheelDeltaX,\n wheelDeltaY: this._wheelDeltaY,\n wheelDeltaZ: this._wheelDeltaZ\n });\n // Clear deltas.\n this._wheelDeltaX = 0;\n this._wheelDeltaY = 0;\n this._wheelDeltaZ = 0;\n }\n /**\n * Gets the class name of the current input.\n * @returns the class name\n */\n getClassName() {\n return \"BaseCameraMouseWheelInput\";\n }\n /**\n * Get the friendly name associated with the input class.\n * @returns the input friendly name\n */\n getSimpleName() {\n return \"mousewheel\";\n }\n}\n__decorate([serialize()], BaseCameraMouseWheelInput.prototype, \"wheelPrecisionX\", void 0);\n__decorate([serialize()], BaseCameraMouseWheelInput.prototype, \"wheelPrecisionY\", void 0);\n__decorate([serialize()], BaseCameraMouseWheelInput.prototype, \"wheelPrecisionZ\", void 0);","map":{"version":3,"names":["__decorate","serialize","Observable","PointerEventTypes","EventConstants","Tools","BaseCameraMouseWheelInput","constructor","wheelPrecisionX","wheelPrecisionY","wheelPrecisionZ","onChangedObservable","_wheelDeltaX","_wheelDeltaY","_wheelDeltaZ","_ffMultiplier","_normalize","attachControl","noPreventDefault","BackCompatCameraNoPreventDefault","arguments","_wheel","pointer","type","POINTERWHEEL","event","platformScale","deltaMode","DOM_DELTA_LINE","deltaX","deltaY","deltaZ","preventDefault","_observer","camera","getScene","_inputManager","_addCameraPointerObserver","detachControl","_removeCameraPointerObserver","clear","checkInputs","notifyObservers","wheelDeltaX","wheelDeltaY","wheelDeltaZ","getClassName","getSimpleName","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Cameras/Inputs/BaseCameraMouseWheelInput.js"],"sourcesContent":["import { __decorate } from \"../../tslib.es6.js\";\nimport { serialize } from \"../../Misc/decorators.js\";\nimport { Observable } from \"../../Misc/observable.js\";\nimport { PointerEventTypes } from \"../../Events/pointerEvents.js\";\nimport { EventConstants } from \"../../Events/deviceInputEvents.js\";\nimport { Tools } from \"../../Misc/tools.js\";\n/**\n * Base class for mouse wheel input..\n * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts\n * for example usage.\n */\nexport class BaseCameraMouseWheelInput {\n constructor() {\n /**\n * How fast is the camera moves in relation to X axis mouseWheel events.\n * Use negative value to reverse direction.\n */\n this.wheelPrecisionX = 3.0;\n /**\n * How fast is the camera moves in relation to Y axis mouseWheel events.\n * Use negative value to reverse direction.\n */\n this.wheelPrecisionY = 3.0;\n /**\n * How fast is the camera moves in relation to Z axis mouseWheel events.\n * Use negative value to reverse direction.\n */\n this.wheelPrecisionZ = 3.0;\n /**\n * Observable for when a mouse wheel move event occurs.\n */\n this.onChangedObservable = new Observable();\n /**\n * Incremental value of multiple mouse wheel movements of the X axis.\n * Should be zero-ed when read.\n */\n this._wheelDeltaX = 0;\n /**\n * Incremental value of multiple mouse wheel movements of the Y axis.\n * Should be zero-ed when read.\n */\n this._wheelDeltaY = 0;\n /**\n * Incremental value of multiple mouse wheel movements of the Z axis.\n * Should be zero-ed when read.\n */\n this._wheelDeltaZ = 0;\n /**\n * Firefox uses a different scheme to report scroll distances to other\n * browsers. Rather than use complicated methods to calculate the exact\n * multiple we need to apply, let's just cheat and use a constant.\n * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode\n * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line\n */\n this._ffMultiplier = 12;\n /**\n * Different event attributes for wheel data fall into a few set ranges.\n * Some relevant but dated date here:\n * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers\n */\n this._normalize = 120;\n }\n /**\n * Attach the input controls to a specific dom element to get the input from.\n * @param noPreventDefault Defines whether event caught by the controls\n * should call preventdefault().\n * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\n */\n attachControl(noPreventDefault) {\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\n this._wheel = (pointer) => {\n // sanity check - this should be a PointerWheel event.\n if (pointer.type !== PointerEventTypes.POINTERWHEEL) {\n return;\n }\n const event = pointer.event;\n const platformScale = event.deltaMode === EventConstants.DOM_DELTA_LINE ? this._ffMultiplier : 1; // If this happens to be set to DOM_DELTA_LINE, adjust accordingly\n this._wheelDeltaX += (this.wheelPrecisionX * platformScale * event.deltaX) / this._normalize;\n this._wheelDeltaY -= (this.wheelPrecisionY * platformScale * event.deltaY) / this._normalize;\n this._wheelDeltaZ += (this.wheelPrecisionZ * platformScale * event.deltaZ) / this._normalize;\n if (event.preventDefault) {\n if (!noPreventDefault) {\n event.preventDefault();\n }\n }\n };\n this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel, PointerEventTypes.POINTERWHEEL);\n }\n /**\n * Detach the current controls from the specified dom element.\n */\n detachControl() {\n if (this._observer) {\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\n this._observer = null;\n this._wheel = null;\n }\n if (this.onChangedObservable) {\n this.onChangedObservable.clear();\n }\n }\n /**\n * Called for each rendered frame.\n */\n checkInputs() {\n this.onChangedObservable.notifyObservers({\n wheelDeltaX: this._wheelDeltaX,\n wheelDeltaY: this._wheelDeltaY,\n wheelDeltaZ: this._wheelDeltaZ,\n });\n // Clear deltas.\n this._wheelDeltaX = 0;\n this._wheelDeltaY = 0;\n this._wheelDeltaZ = 0;\n }\n /**\n * Gets the class name of the current input.\n * @returns the class name\n */\n getClassName() {\n return \"BaseCameraMouseWheelInput\";\n }\n /**\n * Get the friendly name associated with the input class.\n * @returns the input friendly name\n */\n getSimpleName() {\n return \"mousewheel\";\n }\n}\n__decorate([\n serialize()\n], BaseCameraMouseWheelInput.prototype, \"wheelPrecisionX\", void 0);\n__decorate([\n serialize()\n], BaseCameraMouseWheelInput.prototype, \"wheelPrecisionY\", void 0);\n__decorate([\n serialize()\n], BaseCameraMouseWheelInput.prototype, \"wheelPrecisionZ\", void 0);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,SAAS,QAAQ,0BAA0B;AACpD,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,iBAAiB,QAAQ,+BAA+B;AACjE,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,KAAK,QAAQ,qBAAqB;AAC3C;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,CAAC;EACnCC,WAAWA,CAAA,EAAG;IACV;AACR;AACA;AACA;IACQ,IAAI,CAACC,eAAe,GAAG,GAAG;IAC1B;AACR;AACA;AACA;IACQ,IAAI,CAACC,eAAe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