Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MouseZoom = pc.createScript('mouseZoom');
- MouseZoom.attributes.add('targetFOV', { type: 'number' });
- // initialize code called once per entity
- MouseZoom.prototype.initialize = function() {
- this.originalFOV = this.entity.camera.fov;
- this.pos = new pc.Vec3();
- // Disabling the context menu stops the browser displaying a menu when
- // you right-click the page
- this.app.mouse.disableContextMenu();
- this.app.mouse.on(pc.EVENT_MOUSEDOWN, this.onMouseDown, this);
- this.app.mouse.on(pc.EVENT_MOUSEUP, this.onMouseUp, this);
- };
- MouseZoom.prototype.onMouseDown = function (event) {
- // If the right mouse button is pressed, apply the target FOV
- if (event.button === pc.MOUSEBUTTON_RIGHT) {
- this.entity.camera.fov = this.targetFOV;
- //TODO: Set sensitivity down
- }
- };
- MouseZoom.prototype.onMouseUp = function (event) {
- // If the right mouse button is pressed, return to normal FOV.
- if (event.button === pc.MOUSEBUTTON_RIGHT) {
- this.entity.camera.fov = this.originalFOV;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement