Skip to content

Inputs overhaul (CameraControls updated) #7779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 385 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
385 commits
Select commit Hold shift + click to select a range
b71e876
Added in attributes and descriptions
kpal81xd Mar 11, 2025
4255451
Updated keyboard input to use codes
kpal81xd Mar 11, 2025
b651a6e
Removed manual update and destroy in example
kpal81xd Mar 11, 2025
e139b59
Added back arrow keys
kpal81xd Mar 11, 2025
abf4787
Padded out example for new camera controls with attributes and UI
kpal81xd Mar 11, 2025
0f80a28
Converted gamepad dead zone to vec2
kpal81xd Mar 11, 2025
234ae12
Merge branch 'main' into camera-controls
kpal81xd Mar 11, 2025
065aeb6
Ensure enable fly/orbit toggled modes
kpal81xd Mar 11, 2025
ed1411e
Fold init into initialize again
kpal81xd Mar 12, 2025
11b6250
Fixed ranges to be of the same type
kpal81xd Mar 12, 2025
d597a1b
Replaced old multi camera example with new
kpal81xd Mar 12, 2025
680607c
Replaced fly and orbit with new camera controls
kpal81xd Mar 12, 2025
951a4fe
hoisted out reattach and fixed useVirtualGamepad
kpal81xd Mar 12, 2025
7e697ac
Merge branch 'main' into camera-controls
kpal81xd Mar 12, 2025
9f095ed
removed unsed import
kpal81xd Mar 12, 2025
bd70ace
Merge branch 'camera-controls' of https://github.com/playcanvas/engin…
kpal81xd Mar 12, 2025
e56f93e
Added space to keys
kpal81xd Mar 12, 2025
37d56b7
WIP: fps controller update
kpal81xd Mar 12, 2025
48fdcbe
Made update controller priv
kpal81xd Mar 12, 2025
ac0dede
WIP: fps controlle rework
kpal81xd Mar 12, 2025
6a24658
Merge branch 'main' into camera-controls
kpal81xd Mar 13, 2025
75e3ff6
Removed controller for now and embedded directly into controls
kpal81xd Mar 13, 2025
29f592e
Merge branch 'main' into camera-controls
kpal81xd Mar 24, 2025
3f6d70d
Merge branch 'main' into camera-controls
kpal81xd Apr 15, 2025
a4ba1e4
Merge branch 'main' into camera-controls
kpal81xd Apr 15, 2025
5b7f46a
Merge branch 'main' into camera-controls
kpal81xd Apr 24, 2025
e25bfb4
Removed first person controls to merge existing work first
kpal81xd Apr 24, 2025
3009b93
Removed export for first person model
kpal81xd Apr 24, 2025
982824f
Merge branch 'main' into camera-controls
kpal81xd Apr 24, 2025
5273cd5
Hoisted out clear buttons
kpal81xd Apr 24, 2025
bb61a4d
Updated Editor example to use new camera controls
kpal81xd Apr 24, 2025
9817e75
Replaced old camera controls script with new one
kpal81xd Apr 24, 2025
b84855a
Merge branch 'main' into camera-controls
kpal81xd Apr 25, 2025
90a1fc6
Fixed typings for events
kpal81xd Apr 25, 2025
64caadf
Fixed tag ordering
kpal81xd Apr 25, 2025
3089219
Merge branch 'main' into camera-controls
kpal81xd Apr 28, 2025
76f0f3d
Added in pointercancel event
kpal81xd Apr 28, 2025
75aa12e
Merge branch 'main' into camera-controls
kpal81xd May 15, 2025
db6cd3b
[Refactor] Replace Delta with InputDelta in input handling classes
kpal81xd May 15, 2025
03f2dc0
[Refactor] Replace mode property with _switchMode method in CameraCon…
kpal81xd May 15, 2025
e3e178f
Typedoc ignore WIP extras for now
kpal81xd May 15, 2025
240014f
Merge branch 'main' into camera-controls
kpal81xd May 16, 2025
f08f016
Exposed input devices and controllers with alpha typedoc flag
kpal81xd May 19, 2025
a40144e
Refactored Controller name to Transformer to better describe classes
kpal81xd May 19, 2025
e937a5c
Refactor CameraControls: rename controller variables to transformer f…
kpal81xd May 19, 2025
9356617
Alphabetized imports in camera-controls
kpal81xd May 19, 2025
8c1714a
Clarify damping descriptions in CameraControls documentation to speci…
kpal81xd May 19, 2025
87aef23
Clarify damping descriptions in FlyTransformer and OrbitTransformer t…
kpal81xd May 19, 2025
242c792
Clarify pitch and yaw range descriptions to specify the range and the…
kpal81xd May 19, 2025
b8a89bb
Enhance documentation for InputDelta and InputDevice classes with cat…
kpal81xd May 19, 2025
58b2694
Add a blank line for improved readability in KeyboardMouseInputDevice…
kpal81xd May 19, 2025
5aa52f5
Merge branch 'main' into camera-controls
kpal81xd May 19, 2025
25da749
Merge branch 'main' into camera-controls
kpal81xd May 19, 2025
823094b
Merge branch 'main' into camera-controls
kpal81xd May 20, 2025
69d5b5f
Refactor input device classes and add new input sources for enhanced …
kpal81xd May 20, 2025
f681eb6
Reorganised inputs
kpal81xd May 20, 2025
a7b84d5
renamed joystick to virtual joystick
kpal81xd May 20, 2025
f219526
Replaced joystick touch with dual touch
kpal81xd May 20, 2025
d419d02
Removed joystick touch refe
kpal81xd May 20, 2025
a045e9c
Refactor input handling: remove DoubleJoystick, update to DualTouch, …
kpal81xd May 20, 2025
eec8e59
Refactor DualTouch input handling: update layout management and simpl…
kpal81xd May 20, 2025
3163148
Rename Joystick class to VirtualJoystick and update event firing refe…
kpal81xd May 20, 2025
4d2ac72
Refactor input handling: update mobile input layout references and re…
kpal81xd May 20, 2025
887c324
Merge branch 'main' into camera-controls
kpal81xd May 20, 2025
4986cb8
Update category annotations for input controllers and sources
kpal81xd May 20, 2025
39a0dae
Refactor input sources: rename classes and update imports for consist…
kpal81xd May 20, 2025
3ef563e
Update documentation for DualTouchSource layout and fix delta handling
kpal81xd May 20, 2025
43321b7
Add SingleTouchSource input source implementation and update exports
kpal81xd May 20, 2025
90738fb
Remove unused _camera property from detach method in DualTouchSource …
kpal81xd May 20, 2025
16a1f08
Add layout documentation for CameraControls and remove redundant layo…
kpal81xd May 20, 2025
95df438
Update category annotations for InputDelta, InputSource, and InputCon…
kpal81xd May 20, 2025
fd367c6
Refactor DualTouchSource and SingleTouchSource constructors to remove…
kpal81xd May 20, 2025
050c678
Rename DualTouchSource to DualGuestureSource and add SingleGuestureSo…
kpal81xd May 20, 2025
b68ff80
Fix typos in gesture source names and add SingleGestureSource impleme…
kpal81xd May 20, 2025
89dd77b
Merge branch 'main' into camera-controls
kpal81xd May 21, 2025
3a8166d
Merge branch 'main' into camera-controls
kpal81xd May 21, 2025
010935d
Merge branch 'main' into camera-controls
kpal81xd May 21, 2025
3f327f0
Merge branch 'main' into camera-controls
kpal81xd May 22, 2025
bf8a269
Merge branch 'main' into camera-controls
kpal81xd May 28, 2025
0323c04
Fix: Correct dual gesture source layout and enhance constructor flexi…
kpal81xd May 29, 2025
386cc28
Fix: Correct input order in desktop controls for better navigation
kpal81xd May 29, 2025
2ead45b
Fix: Correct zoom property to return the current zoom distance
kpal81xd May 30, 2025
2d349b8
Merge branch 'main' into camera-controls
kpal81xd May 30, 2025
8fec706
Merge branch 'main' into camera-controls
kpal81xd May 30, 2025
d7d80b7
Refactor: Rename lerpRate function to damp for clarity
kpal81xd Jun 2, 2025
22387f0
Merge branch 'main' into camera-controls
kpal81xd Jun 2, 2025
8053136
Merge branch 'camera-controls' of https://github.com/playcanvas/engin…
kpal81xd Jun 2, 2025
389dfcd
Enhance camera controls: integrate orbit controller with camera and s…
kpal81xd Jun 2, 2025
76f8e44
Refactor: Rename mobile input properties for clarity in DualGestureSo…
kpal81xd Jun 2, 2025
a1c4120
Refactor: Update input handling to use InputDelta for movement and ro…
kpal81xd Jun 2, 2025
c20d938
Refactor: Simplify movement scaling in CameraControls and improve inp…
kpal81xd Jun 2, 2025
cb6a5d6
Refactor: Streamline mobile input handling and consolidate input accu…
kpal81xd Jun 2, 2025
fb6d714
Refactor: Restrict joystick event handling to fly mode and streamline…
kpal81xd Jun 2, 2025
e2a77e2
Refactor: Replace length calculation with Math.sqrt for improved clar…
kpal81xd Jun 2, 2025
1bf5cc9
Refactor: Enhance clarity and organization in CameraControls class st…
kpal81xd Jun 2, 2025
62a1d7e
Refactor: Replace drag input handling with rotate input in CameraCont…
kpal81xd Jun 2, 2025
810f185
Refactor: Simplify input handling in OrbitController and CameraContro…
kpal81xd Jun 2, 2025
5f6781f
Fixed pan
kpal81xd Jun 2, 2025
6418758
Refactor: Adjust rotate input handling in CameraControls to improve c…
kpal81xd Jun 2, 2025
cec10b7
Refactor: Consolidate dead zone logic for gamepad input in CameraCont…
kpal81xd Jun 2, 2025
ae18fdd
Refactor: Streamline input handling for orbit and fly modes in Camera…
kpal81xd Jun 2, 2025
5ee5b2b
Refactor: Consolidate look, pan, and zoom logic in FlyController and …
kpal81xd Jun 3, 2025
ede196a
Refactor: Introduce Pose class and update input controllers to use Po…
kpal81xd Jun 3, 2025
b0d5601
Refactor: Update FlyController to use local rotation for movement cal…
kpal81xd Jun 3, 2025
5d832ee
Refactor: Update pose handling in FlyController and OrbitController t…
kpal81xd Jun 3, 2025
37086bd
Refactor: Enhance Pose class with pitch and yaw range management, and…
kpal81xd Jun 3, 2025
1192063
Fix: Ensure detach is called in InputController destroy method
kpal81xd Jun 3, 2025
b8e813f
Refactor: Update FlyController to use Pose for target position and an…
kpal81xd Jun 3, 2025
9043b84
Refactor: Update pan condition in CameraControls to depend on orbit mode
kpal81xd Jun 3, 2025
e9dea4b
Refactor: Replace angle clamping with rotation and movement methods i…
kpal81xd Jun 3, 2025
372f44c
Refactor: Simplify angle handling in Pose class and update FlyControl…
kpal81xd Jun 3, 2025
7312fbd
Refactor: Optimize angle setting in Pose class to handle zero rotatio…
kpal81xd Jun 3, 2025
5139a6c
Refactor: Remove redundant pitch and yaw range properties in FlyContr…
kpal81xd Jun 3, 2025
1f9868f
Refactor: Update OrbitController to use focusPoint instead of point a…
kpal81xd Jun 3, 2025
263baf1
Refactor: Simplify pitch and yaw range handling in OrbitController an…
kpal81xd Jun 3, 2025
da91ccd
Refactor: Introduce distance method in Pose class and simplify focus …
kpal81xd Jun 3, 2025
48446ed
Refactor: Adjust damping values in FlyController for improved movemen…
kpal81xd Jun 3, 2025
482f6e1
Fixed typo in lerp
kpal81xd Jun 3, 2025
884b6cd
Refactor: Use rotateDamping for rotation dampening in FlyController u…
kpal81xd Jun 3, 2025
3757989
Refactor: Improve focus interrupt logic in OrbitController by using s…
kpal81xd Jun 3, 2025
07babc9
Refactor: Simplify position update logic in OrbitController by using …
kpal81xd Jun 3, 2025
5044933
Refactor: Enhance focus end check in OrbitController by separating mo…
kpal81xd Jun 3, 2025
a2a7011
Refactor: Add _pan method to OrbitController for improved rotation in…
kpal81xd Jun 3, 2025
4f00502
Refactor: Replace _position getter with _getPosition method in OrbitC…
kpal81xd Jun 3, 2025
4febc8d
Refactor: Update _getPosition method in OrbitController to improve po…
kpal81xd Jun 3, 2025
1285472
Refactor: Update attach method in FlyController to improve pose handl…
kpal81xd Jun 3, 2025
20cf32f
Refactor: Simplify attach method in FlyController for improved clarit…
kpal81xd Jun 3, 2025
393b489
Refactor: Simplify attach method in FlyController and enhance look me…
kpal81xd Jun 3, 2025
6b29c53
Fix: Correct elevation calculation in look method for accurate pose d…
kpal81xd Jun 3, 2025
e0dc291
Refactored look method
kpal81xd Jun 3, 2025
6a57352
Refactor: Update look method to improve direction handling and clarif…
kpal81xd Jun 3, 2025
6ba171b
Refactor: Remove unused temporary variables in Pose class for improve…
kpal81xd Jun 3, 2025
7827e17
Refactor: Add distance and zoomRange properties to Pose class and upd…
kpal81xd Jun 3, 2025
c092fd7
Refactor: Simplify zoom handling by integrating zoom logic into targe…
kpal81xd Jun 3, 2025
4ec7231
Refactor: Replace _zoomDist with direct access to rootPose.distance f…
kpal81xd Jun 3, 2025
740e77b
Refactor: Remove unused math import in orbit-controller for improved …
kpal81xd Jun 4, 2025
1a2a22d
Refactor: Rename focusPoint getter to focus and update focus method t…
kpal81xd Jun 4, 2025
3f2eab1
Refactor: Rename _targetPose to _targetRootPose and _targetChildPose …
kpal81xd Jun 4, 2025
c9adde0
Refactor: Remove unused variables and implement pose multiplication m…
kpal81xd Jun 4, 2025
328cc39
Refactor: Simplify controller attachment by removing unnecessary zero…
kpal81xd Jun 4, 2025
9a3b11f
Refactor: Simplify move and zoom multipliers for improved readability…
kpal81xd Jun 4, 2025
9301f93
Refactor: Update mode switching logic to default to orbit mode and st…
kpal81xd Jun 4, 2025
f166949
Refactor: Update input controller to include focus parameter in attac…
kpal81xd Jun 4, 2025
6ae06c9
Refactor: Add TypeScript ignore comments for camera, controller, and …
kpal81xd Jun 4, 2025
f3faee3
Refactor: Rename mode switching method from _switchMode to _setMode f…
kpal81xd Jun 4, 2025
5279123
Refactor: Update mode initialization to default to orbit mode for imp…
kpal81xd Jun 4, 2025
fcb6de3
Refactor: Update attach methods in input controllers to use position …
kpal81xd Jun 4, 2025
d4631ad
Refactor: Update parameter names in attach and reset methods for impr…
kpal81xd Jun 4, 2025
31bfb00
Refactor: Clarify comment for switchToFly condition to specify moveme…
kpal81xd Jun 4, 2025
228b906
Refactor: Update parameters in attach method for improved clarity
kpal81xd Jun 4, 2025
858d6c7
Refactor: Remove unused temporary Pose variable for improved clarity
kpal81xd Jun 4, 2025
1727f8e
Refactor: Update variable names in reset method for improved clarity
kpal81xd Jun 4, 2025
a6741ed
Added header for pose class
kpal81xd Jun 4, 2025
270ab77
Refactor: Update orbit controller comment and set zoom range defaults
kpal81xd Jun 4, 2025
c8d4053
Refactor: Remove old controller detachment logic for improved clarity
kpal81xd Jun 4, 2025
552e9fe
Refactor: Simplify pitch, yaw, and zoom range setters for improved cl…
kpal81xd Jun 4, 2025
9fd29f3
Moved pan from rotate to move input
kpal81xd Jun 4, 2025
ba3e86e
Refactor: Enhance mobile and gamepad input sensitivity calculations f…
kpal81xd Jun 4, 2025
91b6bcb
Refactor: Update pan method to normalize deltas and improve perspecti…
kpal81xd Jun 5, 2025
e333cb0
Refactor: Update _pan method to include zoom delta and improve perspe…
kpal81xd Jun 5, 2025
5dae6eb
Refactor: Update camera properties handling in OrbitController for im…
kpal81xd Jun 5, 2025
da16194
Refactor: Enhance perspective calculations in OrbitController and Cam…
kpal81xd Jun 5, 2025
7392e21
Refactor: Simplify movement and rotation handling in OrbitController …
kpal81xd Jun 5, 2025
eeabc4a
Refactor: Remove unused pan input delta from update method in OrbitCo…
kpal81xd Jun 5, 2025
4591b8f
Refactor: Update view frustum size calculation and streamline control…
kpal81xd Jun 5, 2025
230072c
Refactor: Streamline input handling in CameraControls by consolidatin…
kpal81xd Jun 5, 2025
9c7f7f8
Refactor: Remove unused variable tmpV2 from OrbitController
kpal81xd Jun 5, 2025
d87b2e4
Refactor: Replace new InputDelta instances with InputDelta.alloc for …
kpal81xd Jun 5, 2025
da8ce5e
Refactor: Update _screenToWorld method to use this.app for accessing …
kpal81xd Jun 5, 2025
35d6666
Refactor: Simplify input handling in CameraControls and enhance Input…
kpal81xd Jun 6, 2025
42c5bdc
Removed unused sub and flush methods on input delta class
kpal81xd Jun 6, 2025
bda055c
Refactored input delta add
kpal81xd Jun 6, 2025
4e30a1a
Refactor: Consolidate input delta handling in CameraControls for impr…
kpal81xd Jun 6, 2025
d850eac
Refactor: Replace InputDelta.alloc with new InputDelta for improved c…
kpal81xd Jun 6, 2025
80bf01b
Added new InputFrame class for managing multiple input deltas
kpal81xd Jun 6, 2025
ca45c69
Refactor: Replace frame methods with flush in input sources for consi…
kpal81xd Jun 6, 2025
cbcdc2c
Add InputConsumer class and update exports for input handling
kpal81xd Jun 6, 2025
6b225f0
Refactor: Reorganize InputConsumer class definition and update export…
kpal81xd Jun 6, 2025
7b9bf15
Refactor: Remove unused camera property from OrbitController for clarity
kpal81xd Jun 6, 2025
958c2d8
Refactor: Clarify comment on controller update in CameraControls class
kpal81xd Jun 6, 2025
a8ad99b
Refactor: Rename input delta methods for consistency and clarity
kpal81xd Jun 6, 2025
2092523
Add static parse method to InputFrame for processing raw input values
kpal81xd Jun 6, 2025
830934f
Refactor: Rename orbitMove to flyMove for clarity in movement calcula…
kpal81xd Jun 6, 2025
ad8f767
Refactor: Rename joystick event names for clarity and consistency
kpal81xd Jun 9, 2025
3dc1a63
Refactor: Simplify joystick UI show/hide logic and remove unused move…
kpal81xd Jun 9, 2025
894a3fc
Refactor: Consolidate joystick event handling into a single event for…
kpal81xd Jun 9, 2025
43a4a1f
Refactor: Rename slice variable to halfSlice for clarity in view frus…
kpal81xd Jun 10, 2025
b63e3b7
Refactor: Update InputFrame and related classes to use arrays for mov…
kpal81xd Jun 10, 2025
3c62196
Refactor: Remove unused getter for current delta value in InputDelta …
kpal81xd Jun 10, 2025
083a2ca
Refactor: Rename _instance to _value in InputDelta class for clarity
kpal81xd Jun 10, 2025
df22cd4
Refactor: Rename flush methods to read for consistency in input handling
kpal81xd Jun 10, 2025
e41b4ec
Merge branch 'main' into camera-controls
kpal81xd Jun 10, 2025
57010d5
Refactor: Rename reset methods to attach for consistency in controlle…
kpal81xd Jun 10, 2025
33e4b2f
Refactor: Replace new Array() with Array() for consistency in array i…
kpal81xd Jun 10, 2025
361bf73
Refactor: Update _screenToWorld method to use system.app.graphicsDevi…
kpal81xd Jun 16, 2025
b5a071b
Refactor: Update attach and look methods for improved pose handling a…
kpal81xd Jun 17, 2025
7dcc124
Refactor: Improve distance calculations in OrbitController and Pose c…
kpal81xd Jun 17, 2025
0fb6ee2
Refactor: Update attach method in FlyController to copy position for …
kpal81xd Jun 17, 2025
ba7957e
Refactor: Update look method in Pose class to improve parameter namin…
kpal81xd Jun 17, 2025
7cef935
Refactor: Update Pose class constructor and methods to include distan…
kpal81xd Jun 17, 2025
542cf63
Use pose for attach
kpal81xd Jun 17, 2025
170dce4
Refactor: Optimize vector calculations in FlyController for improved …
kpal81xd Jun 17, 2025
3fbd6ec
Refactor: Replace temporary variables with class properties in OrbitC…
kpal81xd Jun 17, 2025
ea2a824
Refactor: Replace manual distance calculations with utility functions…
kpal81xd Jun 17, 2025
97e2e3c
Refactor: Simplify movement and rotation input handling in CameraCont…
kpal81xd Jun 17, 2025
55ef3a3
Refactor: Move screenToWorld function outside of CameraControls class…
kpal81xd Jun 17, 2025
e615679
Refactor: Consolidate state reset logic in CameraControls for improve…
kpal81xd Jun 17, 2025
fdefb0a
Refactor: Replace temporary variable with new instance of Vec3 for im…
kpal81xd Jun 17, 2025
65f3e06
Refactor: Inline movement and zoom multipliers in CameraControls for …
kpal81xd Jun 17, 2025
b617960
Refactor: Replace orbit controller zoom with pose distance for improv…
kpal81xd Jun 17, 2025
c71b94b
Refactor: Add spacing for improved readability in CameraControls class
kpal81xd Jun 17, 2025
4eeb0b8
Refactor: Remove redundant state reset logic in CameraControls for im…
kpal81xd Jun 17, 2025
07bdad9
Refactor: Optimize layout setter in gesture sources to prevent unnece…
kpal81xd Jun 17, 2025
3b88324
Refactor: Simplify mobile input layout assignment in CameraControls f…
kpal81xd Jun 17, 2025
83fd881
Refactor: Clarify documentation for angles in Pose class to specify c…
kpal81xd Jun 17, 2025
8e6a122
Refactor: Remove unused rotation2 variable in OrbitController for imp…
kpal81xd Jun 17, 2025
eef673a
Refactor: Introduce getFocus method in Pose class for improved clarit…
kpal81xd Jun 17, 2025
cc64821
Refactor: Rename offset variable to position in OrbitController for i…
kpal81xd Jun 17, 2025
763b2a8
Refactor: Move set method to the end of the Pose class for improved o…
kpal81xd Jun 18, 2025
1a02fb5
Refactor: Update lerp method in Pose class to include distance interp…
kpal81xd Jun 18, 2025
56f4bfe
Refactor: Update pose calculation in CameraControls for improved focu…
kpal81xd Jun 18, 2025
1fb7d85
Refactor: Enhance focus handling in OrbitController and add length me…
kpal81xd Jun 18, 2025
e06e04f
Refactor: Move damp function to math.js for improved organization and…
kpal81xd Jun 18, 2025
a72ddbc
Refactor: Replace static mode constants in CameraControls with string…
kpal81xd Jun 18, 2025
4a03b31
Refactor: Replace almostEqualPose function with equalsApprox method f…
kpal81xd Jun 18, 2025
adbcc4c
Refactor: Simplify focus handling in CameraControls and OrbitControll…
kpal81xd Jun 18, 2025
a6e5e05
WIP: added focus controller
kpal81xd Jun 18, 2025
b5ff4bf
Refactor: Enhance CameraControls to support 'focus' mode and streamli…
kpal81xd Jun 18, 2025
16db821
Refactor: Simplify focusPoint setter in CameraControls by removing un…
kpal81xd Jun 18, 2025
1f0444c
Refactor: Remove unused _prevMode property from CameraControls and se…
kpal81xd Jun 18, 2025
7075058
Refactor: Add clone method to Pose class for creating a new instance …
kpal81xd Jun 18, 2025
32d5407
Refactor: Rename position variable to offset in OrbitController for c…
kpal81xd Jun 18, 2025
3c92be4
Moved all scaling inside camera controls
kpal81xd Jun 18, 2025
5b7b1b2
Merge branch 'main' into inputs
kpal81xd Jun 18, 2025
1fc93e6
Refactor: Discard frame by default in InputConsumer and call super in…
kpal81xd Jun 18, 2025
f978aa7
Added enum for keycode ids in the input delta for key
kpal81xd Jun 19, 2025
8501fed
Merge branch 'main' into inputs
kpal81xd Jun 19, 2025
81bbb8f
Refactor: Simplify pointer event handling in DualGestureSource
kpal81xd Jun 19, 2025
3f02e6b
Refactor: Simplify pointer event handling in SingleGestureSource
kpal81xd Jun 19, 2025
8a45bee
Refactor: Optimize pointer event handling in MultiTouchSource
kpal81xd Jun 19, 2025
651c737
Refactor: Improve pointer event handling by using target property in …
kpal81xd Jun 19, 2025
f198894
feat: Add event handling capabilities to InputSource class
kpal81xd Jun 19, 2025
40790fd
Merge branch 'inputs' of https://github.com/playcanvas/engine into in…
kpal81xd Jun 19, 2025
39d2dc1
Refactor: Update VirtualJoystick to use _base and _stick for position…
kpal81xd Jun 19, 2025
232dba2
Merge branch 'main' into inputs
kpal81xd Jun 19, 2025
e8ba4ad
refactor: Simplify joystick event handling and improve code readability
kpal81xd Jun 19, 2025
650bdd7
refactor: Eliminate unnecessary Vec2 instance and streamline move met…
kpal81xd Jun 19, 2025
4366ce0
fix: Handle cases with fewer than two pointer events in mid point and…
kpal81xd Jun 19, 2025
f34717a
Snap internal pose when setting focusPoint
kpal81xd Jun 20, 2025
596d4d7
refactor: Optimize move method by reusing Vec2 instance for calculations
kpal81xd Jun 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 54 additions & 16 deletions examples/src/examples/camera/fly.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export const controls = ({ observer, ReactPCUI, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, SliderInput, VectorInput } = ReactPCUI;
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, SliderInput, VectorInput, TextInput } = ReactPCUI;

return fragment(
jsx(
Panel,
{ headerText: 'Attributes' },
jsx(
LabelGroup,
{ text: 'Pitch range' },
jsx(VectorInput, {
binding: new BindingTwoWay(),
link: { observer, path: 'attr.pitchRange' },
dimensions: 2
})
),
jsx(
LabelGroup,
{ text: 'Rotate speed' },
Expand All @@ -31,14 +22,14 @@ export const controls = ({ observer, ReactPCUI, jsx, fragment }) => {
),
jsx(
LabelGroup,
{ text: 'Rotate damping' },
{ text: 'Rotate joystick sensitivity' },
jsx(SliderInput, {
binding: new BindingTwoWay(),
link: { observer, path: 'attr.rotateDamping' },
link: { observer, path: 'attr.rotateJoystickSens' },
min: 0,
max: 0.999,
step: 0.001,
precision: 3
max: 10,
step: 0.01,
precision: 2
})
),
jsx(
Expand Down Expand Up @@ -71,6 +62,18 @@ export const controls = ({ observer, ReactPCUI, jsx, fragment }) => {
max: 10
})
),
jsx(
LabelGroup,
{ text: 'Rotate damping' },
jsx(SliderInput, {
binding: new BindingTwoWay(),
link: { observer, path: 'attr.rotateDamping' },
min: 0,
max: 0.999,
step: 0.001,
precision: 3
})
),
jsx(
LabelGroup,
{ text: 'Move damping' },
Expand All @@ -82,6 +85,41 @@ export const controls = ({ observer, ReactPCUI, jsx, fragment }) => {
step: 0.001,
precision: 3
})
),
jsx(
LabelGroup,
{ text: 'Pitch range' },
jsx(VectorInput, {
binding: new BindingTwoWay(),
link: { observer, path: 'attr.pitchRange' },
dimensions: 2
})
),
jsx(
LabelGroup,
{ text: 'Yaw range' },
jsx(VectorInput, {
binding: new BindingTwoWay(),
link: { observer, path: 'attr.yawRange' },
dimensions: 2
})
),
jsx(
LabelGroup,
{ text: 'Gamepad deadzone' },
jsx(VectorInput, {
binding: new BindingTwoWay(),
link: { observer, path: 'attr.gamepadDeadZone' },
dimensions: 2
})
),
jsx(
LabelGroup,
{ text: 'Mobile input layout' },
jsx(TextInput, {
binding: new BindingTwoWay(),
link: { observer, path: 'attr.mobileInputLayout' }
})
)
)
);
Expand Down
157 changes: 107 additions & 50 deletions examples/src/examples/camera/fly.example.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @config DESCRIPTION <div style='text-align:center'><div>(<b>LMB</b>) Fly</div><div>(<b>WASDQE</b>) Move</div></div>
// @config DESCRIPTION <div style='text-align:center'><div>(<b>WASDQE</b>) Move </div><div>(<b>Hold Shift</b>) Move Fast (<b>Hold Ctrl</b>) Move Slow</div><div>(<b>LMB / RMB </b>) Fly</div></div>
import { data } from 'examples/observer';
import { deviceType, rootPath, fileImport } from 'examples/utils';
import * as pc from 'playcanvas';

const { CameraControls } = await fileImport(`${rootPath}/static/scripts/esm/camera-controls.mjs`);

const tmpVa = new pc.Vec2();

const canvas = document.getElementById('application-canvas');
if (!(canvas instanceof HTMLCanvasElement)) {
throw new Error('No canvas found');
Expand Down Expand Up @@ -59,6 +61,24 @@ await new Promise((resolve) => {
new pc.AssetListLoader(Object.values(assets), app.assets).load(resolve);
});

app.start();

app.scene.ambientLight.set(0.4, 0.4, 0.4);

app.scene.skyboxMip = 1;
app.scene.skyboxIntensity = 0.4;
app.scene.envAtlas = assets.helipad.resource;

// Create a directional light
const light = new pc.Entity();
light.addComponent('light');
light.setLocalEulerAngles(45, 30, 0);
app.root.addChild(light);

const statue = assets.statue.resource.instantiateRenderEntity();
statue.setLocalPosition(0, -0.5, 0);
app.root.addChild(statue);

/**
* Calculate the bounding box of an entity.
*
Expand All @@ -77,92 +97,129 @@ const calcEntityAABB = (bbox, entity) => {
return bbox;
};

const start = new pc.Vec3(0, 20, 30);
const bbox = calcEntityAABB(new pc.BoundingBox(), statue);

const camera = new pc.Entity();
camera.addComponent('camera');
camera.addComponent('script');
camera.setPosition(start);
app.root.addChild(camera);
const cc = /** @type { CameraControls} */ (camera.script.create(CameraControls));
Object.assign(cc, {
sceneSize: bbox.halfExtents.length(),
focusPoint: bbox.center,
enableOrbit: false,
enablePan: false
});

/**
* @param {pc.Entity} focus - The entity to focus the camera on.
* @returns {CameraControls} The camera-controls script.
* @param {string} side - The name.
* @param {number} baseSize - The base size.
* @param {number} stickSize - The stick size.
*/
const createFlyCamera = (focus) => {
const start = new pc.Vec3(0, 20, 30);

const camera = new pc.Entity();
camera.addComponent('camera');
camera.addComponent('script');
camera.setPosition(start);
app.root.addChild(camera);

const bbox = calcEntityAABB(new pc.BoundingBox(), focus);

/** @type {CameraControls} */
const script = camera.script.create(CameraControls, {
properties: {
enableOrbit: false,
enablePan: false,
focusPoint: bbox.center,
sceneSize: bbox.halfExtents.length(),
pitchRange: new pc.Vec2(-90, 90)
}
const createJoystickUI = (side, baseSize = 100, stickSize = 60) => {
const base = document.createElement('div');
Object.assign(base.style, {
display: 'none',
position: 'absolute',
width: `${baseSize}px`,
height: `${baseSize}px`,
borderRadius: '50%',
backgroundColor: 'rgba(50, 50, 50, 0.5)',
boxShadow: 'inset 0 0 20px rgba(0, 0, 0, 0.5)'
});

return script;
};

app.start();

app.scene.ambientLight.set(0.4, 0.4, 0.4);
const stick = document.createElement('div');
Object.assign(stick.style, {
display: 'none',
position: 'absolute',
width: `${stickSize}px`,
height: `${stickSize}px`,
borderRadius: '50%',
backgroundColor: 'rgba(255, 255, 255, 0.5)',
boxShadow: 'inset 0 0 10px rgba(0, 0, 0, 0.5)'
});

app.scene.skyboxMip = 1;
app.scene.skyboxIntensity = 0.4;
app.scene.envAtlas = assets.helipad.resource;
/**
* @param {HTMLElement} el - The element to set position for.
* @param {number} size - The size of the element.
* @param {number} x - The x position.
* @param {number} y - The y position.
*/
const show = (el, size, x, y) => {
el.style.display = 'block';
el.style.left = `${x - size * 0.5}px`;
el.style.top = `${y - size * 0.5}px`;
};

/**
* @param {HTMLElement} el - The element to hide.
*/
const hide = (el) => {
el.style.display = 'none';
};

app.on(`${cc.joystickEventName}:${side}`, (bx, by, sx, sy) => {
if (bx < 0 || by < 0 || sx < 0 || sy < 0) {
hide(base);
hide(stick);
return;
}

// Create a directional light
const light = new pc.Entity();
light.addComponent('light');
light.setLocalEulerAngles(45, 30, 0);
app.root.addChild(light);
show(base, baseSize, bx, by);
show(stick, stickSize, sx, sy);
});

const statue = assets.statue.resource.instantiateRenderEntity();
statue.setLocalPosition(0, -0.5, 0);
app.root.addChild(statue);
document.body.append(base, stick);
};

const multiCameraScript = createFlyCamera(statue);
// Create joystick UI
createJoystickUI('left');
createJoystickUI('right');

// Bind controls to camera attributes
data.set('attr', [
'pitchRange',
'rotateSpeed',
'rotateDamping',
'rotateJoystickSens',
'moveSpeed',
'moveFastSpeed',
'moveSlowSpeed',
'moveDamping'
'rotateDamping',
'moveDamping',
'pitchRange',
'yawRange',
'gamepadDeadZone',
'mobileInputLayout'
].reduce((/** @type {Record<string, any>} */ obj, key) => {
const value = multiCameraScript[key];
const value = cc[key];

if (value instanceof pc.Vec2) {
obj[key] = [value.x, value.y];
return obj;
}

obj[key] = multiCameraScript[key];
obj[key] = cc[key];
return obj;
}, {}));

const tmpVa = new pc.Vec2();
data.on('*:set', (/** @type {string} */ path, /** @type {any} */ value) => {
const [category, key, index] = path.split('.');
if (category !== 'attr') {
return;
}

if (Array.isArray(value)) {
multiCameraScript[key] = tmpVa.set(value[0], value[1]);
cc[key] = tmpVa.set(value[0], value[1]);
return;
}
if (index !== undefined) {
const arr = data.get(`${category}.${key}`);
multiCameraScript[key] = tmpVa.set(arr[0], arr[1]);
cc[key] = tmpVa.set(arr[0], arr[1]);
return;
}
multiCameraScript[key] = value;

cc[key] = value;
});

export { app };
Loading