1 |
- {"ast":null,"code":"import { __decorate } from \"../../tslib.es6.js\";\nimport { serialize } from \"../../Misc/decorators.js\";\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager.js\";\nimport { PointerEventTypes } from \"../../Events/pointerEvents.js\";\nimport { Tools } from \"../../Misc/tools.js\";\nimport { Logger } from \"../../Misc/logger.js\";\n/**\n * Manage the mouse wheel inputs to control a follow camera.\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\n */\nexport class FollowCameraMouseWheelInput {\n constructor() {\n /**\n * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)\n */\n this.axisControlRadius = true;\n /**\n * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)\n */\n this.axisControlHeight = false;\n /**\n * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)\n */\n this.axisControlRotation = false;\n /**\n * Gets or Set the mouse wheel precision or how fast is the camera moves in\n * relation to mouseWheel events.\n */\n this.wheelPrecision = 3.0;\n /**\n * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.\n * It defines the percentage of current camera.radius to use as delta when wheel is used.\n */\n this.wheelDeltaPercentage = 0;\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 should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\n */\n attachControl(noPreventDefault) {\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\n this._wheel = p => {\n // sanity check - this should be a PointerWheel event.\n if (p.type !== PointerEventTypes.POINTERWHEEL) {\n return;\n }\n const event = p.event;\n let delta = 0;\n const wheelDelta = Math.max(-1, Math.min(1, event.deltaY));\n if (this.wheelDeltaPercentage) {\n if (+this.axisControlRadius + +this.axisControlHeight + +this.axisControlRotation) {\n Logger.Warn(\"wheelDeltaPercentage only usable when mouse wheel \" + \"controls ONE axis. \" + \"Currently enabled: \" + \"axisControlRadius: \" + this.axisControlRadius + \", axisControlHeightOffset: \" + this.axisControlHeight + \", axisControlRotationOffset: \" + this.axisControlRotation);\n }\n if (this.axisControlRadius) {\n delta = wheelDelta * 0.01 * this.wheelDeltaPercentage * this.camera.radius;\n } else if (this.axisControlHeight) {\n delta = wheelDelta * 0.01 * this.wheelDeltaPercentage * this.camera.heightOffset;\n } else if (this.axisControlRotation) {\n delta = wheelDelta * 0.01 * this.wheelDeltaPercentage * this.camera.rotationOffset;\n }\n } else {\n delta = wheelDelta * this.wheelPrecision;\n }\n if (delta) {\n if (this.axisControlRadius) {\n this.camera.radius += delta;\n } else if (this.axisControlHeight) {\n this.camera.heightOffset -= delta;\n } else if (this.axisControlRotation) {\n this.camera.rotationOffset -= delta;\n }\n }\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 }\n /**\n * Gets the class name of the current input.\n * @returns the class name\n */\n getClassName() {\n return \"ArcRotateCameraMouseWheelInput\";\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()], FollowCameraMouseWheelInput.prototype, \"axisControlRadius\", void 0);\n__decorate([serialize()], FollowCameraMouseWheelInput.prototype, \"axisControlHeight\", void 0);\n__decorate([serialize()], FollowCameraMouseWheelInput.prototype, \"axisControlRotation\", void 0);\n__decorate([serialize()], FollowCameraMouseWheelInput.prototype, \"wheelPrecision\", void 0);\n__decorate([serialize()], FollowCameraMouseWheelInput.prototype, \"wheelDeltaPercentage\", void 0);\nCameraInputTypes[\"FollowCameraMouseWheelInput\"] = FollowCameraMouseWheelInput;","map":{"version":3,"names":["__decorate","serialize","CameraInputTypes","PointerEventTypes","Tools","Logger","FollowCameraMouseWheelInput","constructor","axisControlRadius","axisControlHeight","axisControlRotation","wheelPrecision","wheelDeltaPercentage","attachControl","noPreventDefault","BackCompatCameraNoPreventDefault","arguments","_wheel","p","type","POINTERWHEEL","event","delta","wheelDelta","Math","max","min","deltaY","Warn","camera","radius","heightOffset","rotationOffset","preventDefault","_observer","getScene","_inputManager","_addCameraPointerObserver","detachControl","_removeCameraPointerObserver","getClassName","getSimpleName","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Cameras/Inputs/followCameraMouseWheelInput.js"],"sourcesContent":["import { __decorate } from \"../../tslib.es6.js\";\nimport { serialize } from \"../../Misc/decorators.js\";\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager.js\";\nimport { PointerEventTypes } from \"../../Events/pointerEvents.js\";\nimport { Tools } from \"../../Misc/tools.js\";\nimport { Logger } from \"../../Misc/logger.js\";\n/**\n * Manage the mouse wheel inputs to control a follow camera.\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\n */\nexport class FollowCameraMouseWheelInput {\n constructor() {\n /**\n * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)\n */\n this.axisControlRadius = true;\n /**\n * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)\n */\n this.axisControlHeight = false;\n /**\n * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)\n */\n this.axisControlRotation = false;\n /**\n * Gets or Set the mouse wheel precision or how fast is the camera moves in\n * relation to mouseWheel events.\n */\n this.wheelPrecision = 3.0;\n /**\n * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.\n * It defines the percentage of current camera.radius to use as delta when wheel is used.\n */\n this.wheelDeltaPercentage = 0;\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 should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\n */\n attachControl(noPreventDefault) {\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\n this._wheel = (p) => {\n // sanity check - this should be a PointerWheel event.\n if (p.type !== PointerEventTypes.POINTERWHEEL) {\n return;\n }\n const event = p.event;\n let delta = 0;\n const wheelDelta = Math.max(-1, Math.min(1, event.deltaY));\n if (this.wheelDeltaPercentage) {\n if (+this.axisControlRadius + +this.axisControlHeight + +this.axisControlRotation) {\n Logger.Warn(\"wheelDeltaPercentage only usable when mouse wheel \" +\n \"controls ONE axis. \" +\n \"Currently enabled: \" +\n \"axisControlRadius: \" +\n this.axisControlRadius +\n \", axisControlHeightOffset: \" +\n this.axisControlHeight +\n \", axisControlRotationOffset: \" +\n this.axisControlRotation);\n }\n if (this.axisControlRadius) {\n delta = wheelDelta * 0.01 * this.wheelDeltaPercentage * this.camera.radius;\n }\n else if (this.axisControlHeight) {\n delta = wheelDelta * 0.01 * this.wheelDeltaPercentage * this.camera.heightOffset;\n }\n else if (this.axisControlRotation) {\n delta = wheelDelta * 0.01 * this.wheelDeltaPercentage * this.camera.rotationOffset;\n }\n }\n else {\n delta = wheelDelta * this.wheelPrecision;\n }\n if (delta) {\n if (this.axisControlRadius) {\n this.camera.radius += delta;\n }\n else if (this.axisControlHeight) {\n this.camera.heightOffset -= delta;\n }\n else if (this.axisControlRotation) {\n this.camera.rotationOffset -= delta;\n }\n }\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 }\n /**\n * Gets the class name of the current input.\n * @returns the class name\n */\n getClassName() {\n return \"ArcRotateCameraMouseWheelInput\";\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], FollowCameraMouseWheelInput.prototype, \"axisControlRadius\", void 0);\n__decorate([\n serialize()\n], FollowCameraMouseWheelInput.prototype, \"axisControlHeight\", void 0);\n__decorate([\n serialize()\n], FollowCameraMouseWheelInput.prototype, \"axisControlRotation\", void 0);\n__decorate([\n serialize()\n], FollowCameraMouseWheelInput.prototype, \"wheelPrecision\", void 0);\n__decorate([\n serialize()\n], FollowCameraMouseWheelInput.prototype, \"wheelDeltaPercentage\", void 0);\nCameraInputTypes[\"FollowCameraMouseWheelInput\"] = FollowCameraMouseWheelInput;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,SAAS,QAAQ,0BAA0B;AACpD,SAASC,gBAAgB,QAAQ,sCAAsC;AACvE,SAASC,iBAAiB,QAAQ,+BAA+B;AACjE,SAASC,KAAK,QAAQ,qBAAqB;AAC3C,SAASC,MAAM,QAAQ,sBAAsB;AAC7C;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,CAAC;EACrCC,WAAWA,CAAA,EAAG;IACV;AACR;AACA;IACQ,IAAI,CAACC,iBAAiB,GAAG,IAAI;IAC7B;AACR;AACA;IACQ,IAAI,CAACC,iBAAiB,GAAG,KAAK;IAC9B;AACR;AACA;IACQ,IAAI,CAACC,mBAAmB,GAAG,KAAK;IAChC;AACR;AACA;AACA;IACQ,IAAI,CAACC,cAAc,GAAG,GAAG;IACzB;AACR;AACA;AACA;IACQ,IAAI,CAACC,oBAAoB,GAAG,CAAC;EACjC;EACA;AACJ;AACA;AACA;EACIC,aAAaA,CAACC,gBAAgB,EAAE;IAC5BA,gBAAgB,GAAGV,KAAK,CAACW,gCAAgC,CAACC,SAAS,CAAC;IACpE,IAAI,CAACC,MAAM,GAAIC,CAAC,IAAK;MACjB;MACA,IAAIA,CAAC,CAACC,IAAI,KAAKhB,iBAAiB,CAACiB,YAAY,EAAE;QAC3C;MACJ;MACA,MAAMC,KAAK,GAAGH,CAAC,CAACG,KAAK;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