@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
115 lines (114 loc) • 6.45 kB
TypeScript
/**
* Creates a virtual joystick for mobile first person controls
*
* @remarks
* Ensure to have the following tag in your html `<head>`:
*
* `<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />`
*
* as this will prevent the screen from zooming in and out when using a finger to translate and another to rotate.
*
* And if you are using an iphone, you may need to also add the following css:
* - to prevent page reload when swiping down:
*
* ``` css
*body {
* overscroll-behavior-y: none;
* position: fixed;
* overflow: hidden;
*}
*```
*
* - and to disable page zoom from double tap or when using 2 fingers:
*
*``` css
*body {
* touch-action: none;
*}
*```
*
*/
import { Camera } from 'three';
import { TypedCameraControlsEventNode } from './_BaseCameraControls';
import { NodeParamsConfig } from '../utils/params/ParamsConfig';
import { MobileJoystickControls } from '../../../modules/core/controls/MobileJoystickControls';
import { CameraControlsNodeType } from '../../poly/NodeContext';
import { CorePlayer } from '../../../core/player/Player';
import { CollisionController } from './collision/CollisionController';
declare class MobileJoystickEventParamsConfig extends NodeParamsConfig {
main: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FOLDER>;
/** @param collider object */
colliderObject: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.NODE_PATH>;
/** @param collision Capsule Radius */
capsuleRadius: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FLOAT>;
/** @param collision Capsule Height */
capsuleHeight: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FLOAT>;
physics: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FOLDER>;
/** @param physics Steps */
physicsSteps: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.INTEGER>;
/** @param gravity */
gravity: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.VECTOR3>;
/** @param translation speed */
translateSpeed: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FLOAT>;
/** @param rotation speed */
rotateSpeed: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FLOAT>;
/** @param specify a custom HTML element */
customTranslateElement: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.BOOLEAN>;
/** @param jump HTML element selector */
translateElementSelector: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.STRING>;
/** @param jump Allowed */
jumpAllowed: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.BOOLEAN>;
/** @param jump Force */
jumpStrength: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FLOAT>;
/** @param specify a custom HTML element */
customJumpElement: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.BOOLEAN>;
/** @param jump HTML element selector */
jumpElementSelector: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.STRING>;
/** @param run Allowed */
runAllowed: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.BOOLEAN>;
/** @param run speed mult */
runSpeedMult: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FLOAT>;
/** @param specify a custom HTML element */
customRunElement: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.BOOLEAN>;
/** @param jump HTML element selector */
runElementSelector: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.STRING>;
/** @param recompute colliding geo */
updateCollider: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.BUTTON>;
init: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FOLDER>;
/** @param start Position */
startPosition: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.VECTOR3>;
/** @param start Position */
startRotation: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.VECTOR3>;
/** @param reset */
reset: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.BUTTON>;
/** @param min polar angle */
minPolarAngle: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FLOAT>;
/** @param max polar angle */
maxPolarAngle: import("../utils/params/ParamsConfig").ParamTemplate<import("../../index_all").ParamType.FLOAT>;
}
export declare class MobileJoystickControlsEventNode extends TypedCameraControlsEventNode<MobileJoystickEventParamsConfig> {
paramsConfig: MobileJoystickEventParamsConfig;
static type(): CameraControlsNodeType;
endEventName(): string;
static readonly INPUT_UPDATE_COLLIDER = "updateCollider";
private _collisionController;
collisionController(): CollisionController;
initializeNode(): void;
private _controls_by_element_id;
private _player;
createControlsInstance(camera: Camera, element: HTMLElement): Promise<MobileJoystickControls>;
private _initPlayer;
private _playerOptions;
player(): CorePlayer | undefined;
private _updatePlayerParams;
private _resetPlayer;
private _updateCollider;
protected _bind_listeners_to_controls_instance(controls: MobileJoystickControls): void;
updateRequired(): boolean;
setupControls(controls: MobileJoystickControls): void;
disposeControlsForHtmlElementId(html_element_id: string): void;
static PARAM_CALLBACK_updateCollider(node: MobileJoystickControlsEventNode): void;
static PARAM_CALLBACK_updatePlayerParams(node: MobileJoystickControlsEventNode): void;
static PARAM_CALLBACK_resetPlayer(node: MobileJoystickControlsEventNode): void;
}
export {};