summaryrefslogtreecommitdiff
path: root/platform/javascript
AgeCommit message (Collapse)Author
2020-05-01Merge pull request #37414 from Schroedi/fix_html_mouse_inputFabio Alessandrelli
Move wheel handlers from window to canvas element in HTML
2020-04-28Rename InputFilter back to InputRémi Verschelde
It changed name as part of the DisplayServer and input refactoring in #37317, with the rationale that input no longer goes through the main loop, so the previous Input singleton now only does filtering. But the gains in consistency are quite limited in the renaming, and it breaks compatibility for all scripts and tutorials that access the Input singleton via the scripting language. A temporary option was suggested to keep the scripting singleton named `Input` even if its type is `InputFilter`, but that adds inconsistency and breaks C#. Fixes godotengine/godot-proposals#639. Fixes #37319. Fixes #37690.
2020-04-28Move mouse wheel handler from window to canvas element in HTMLChristoph Schröder
Similar to https://github.com/godotengine/godot/pull/36557 At least in chrome, the following error is printed for each mouse wheel rotation: [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312 This PR moves the handler to the canvas and thereby fixes the error. Tested on: Chrome and Firefox (MacOS), Firefox, Chrome(Android), Safari (IPad + MacOS)
2020-04-22Set the `title` tag in the HTML5 export immediatelyHugo Locurcio
This makes the project title display without having to wait for the project to finish loading.
2020-04-02Replace NULL with nullptrlupoDharkael
2020-03-30SCons: Format buildsystem files with psf/blackRémi Verschelde
Configured for a max line length of 120 characters. psf/black is very opinionated and purposely doesn't leave much room for configuration. The output is mostly OK so that should be fine for us, but some things worth noting: - Manually wrapped strings will be reflowed, so by using a line length of 120 for the sake of preserving readability for our long command calls, it also means that some manually wrapped strings are back on the same line and should be manually merged again. - Code generators using string concatenation extensively look awful, since black puts each operand on a single line. We need to refactor these generators to use more pythonic string formatting, for which many options are available (`%`, `format` or f-strings). - CI checks and a pre-commit hook will be added to ensure that future buildsystem changes are well-formatted.
2020-03-27Renaming of servers for coherency.Juan Linietsky
VisualServer -> RenderingServer PhysicsServer -> PhysicsServer3D Physics2DServer -> PhysicsServer2D NavigationServer -> NavigationServer3D Navigation2DServer -> NavigationServer2D Also renamed corresponding files.
2020-03-26Refactored input, goes all via windows now.Juan Linietsky
Also renamed Input to InputFilter because all it does is filter events.
2020-03-26Refactored Input, create DisplayServer and DisplayServerX11Juan Linietsky
2020-03-23Adding missing include guards to header files identified by LGTM.Rajat Goswami
This addresses the issue godotengine/godot#37143
2020-03-17Style: Set clang-format Standard to Cpp11Rémi Verschelde
For us, it practically only changes the fact that `A<A<int>>` is now used instead of the C++03 compatible `A<A<int> >`. Note: clang-format 10+ changed the `Standard` arguments to fully specified `c++11`, `c++14`, etc. versions, but we can't use `c++17` now if we want to preserve compatibility with clang-format 8 and 9. `Cpp11` is still supported as deprecated alias for `Latest`.
2020-03-11[HTML5] Refactor JS, threads support, closures.Fabio Alessandrelli
- Refactored the Engine code, splitted across files. - Use MODULARIZE option to build emscripten code into it's own closure. - Enable lto support (saves ~2MiB in release). - Enable optional closure compiler pass for JS and generated code. - Enable optional pthreads support. - Can now build with tools=yes (not much to see yet). - Dropped some deprecated code for older toolchains.
2020-03-11AudioDriverJavascript uses IDHandler.Fabio Alessandrelli
This makes closure compiler happy, avoiding globals and potentially undefined variables.
2020-03-08OS_Javascript temporarly uses dummy rasterizer.Fabio Alessandrelli
2020-03-08Fix Javascript platform after PoolVector removal.Fabio Alessandrelli
Eval should be rechecked.
2020-03-03Merge pull request #36557 from Schroedi/fix_html_touchFabio Alessandrelli
Fixes touch events for HTML
2020-03-01Merge pull request #18020 from bruvzg/input_fix_non_latin_and_add_hw_scancodesRémi Verschelde
Fix non-latin layout scancodes on Linux, adds access to physical scancodes.
2020-02-26Reimplement Mutex with C++'s <mutex>Pedro J. Estébanez
Main: - It's now implemented thanks to `<mutex>`. No more platform-specific implementations. - `BinaryMutex` (non-recursive) is added, as an alternative for special cases. - Doesn't need allocation/deallocation anymore. It can live in the stack and be part of other classes. - Because of that, it's methods are now `const` and the inner mutex is `mutable` so it can be easily used in `const` contexts. - A no-op implementation is provided if `NO_THREADS` is defined. No more need to add `#ifdef NO_THREADS` just for this. - `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`. - Thread-safe utilities are therefore simpler now. Misc.: - `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same. - Every case of lock, do-something, unlock is replaced by `MutexLock` (complex cases where it's not straightfoward are kept as as explicit lock and unlock). - `ShaderRD` contained an `std::mutex`, which has been replaced by `Mutex`.
2020-02-26Fixes touch events for HTMLChristoph Schroeder
Without this patch, the following exception is thrown when the touch screen is used: TypeError: e.getBoundingClientRect is not a function. No touch events arrive in the engine. From my testing, this PR fixes the issue and behaves as expected. Tested with godot-demo-projects/misc/multitouch_view/, emscripten 1.39.8 and Firefox mobile emulator as well as FF on Android
2020-02-25Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.Juan Linietsky
- Renames PackedIntArray to PackedInt32Array. - Renames PackedFloatArray to PackedFloat32Array. - Adds PackedInt64Array and PackedFloat64Array. - Renames Variant::REAL to Variant::FLOAT for consistency. Packed arrays are for storing large amount of data and creating stuff like meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of memory. That said, many users requested the ability to have 64 bits packed arrays for their games, so this is just an optional added type. For Variant, the float datatype is always 64 bits, and exposed as `float`. We still have `real_t` which is the datatype that can change from 32 to 64 bits depending on a compile flag (not entirely working right now, but that's the idea). It affects math related datatypes and code only. Neither Variant nor PackedArray make use of real_t, which is only intended for math precision, so the term is removed from there to keep only float.
2020-02-25Rename `scancode` to `keycode`.bruvzg
Add `physical_keycode` (keyboard layout independent keycodes) to InputEventKey and InputMap. Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
2020-02-18PoolVector is gone, replaced by VectorJuan Linietsky
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
2020-02-14Remove incomplete battery status/power APIRémi Verschelde
It was initially implemented in #5871 for Godot 3.0, but never really completed or thoroughly tested for most platforms. It then stayed in limbo and nobody seems really keen to finish it, so it's better to remove it in 4.0, and re-add eventually (possibly with a different API) if there's demand and an implementation confirmed working on all platforms. Closes #8770.
2020-02-13Remove obsolete GLES3 backendRémi Verschelde
Due to the port to Vulkan and complete redesign of the rendering backend, the `drivers/gles3` code is no longer usable in this state and is not planned to be ported to the new architecture. The GLES2 backend is kept (while still disabled and non-working) as it will eventually be ported to serve as the low-end renderer for Godot 4.0. Some GLES3 features might be selectively ported to the updated GLES2 backend if there's a need for them, and extensions we can use for that. So long, OpenGL driver bugs!
2020-02-12Fix startGame's logic in engine.js.Relintai
2020-02-11Custom material support seems complete.Juan Linietsky
2020-02-11Texture refactorJuan Linietsky
-Texture renamed to Texture2D -TextureLayered as base now inherits 2Darray, cubemap and cubemap array -Removed all references to flags in textures (they will go in the shader) -Texture3D gone for now (will come back later done properly) -Create base rasterizer for RenderDevice, RasterizerRD
2020-02-10Allow per pixel transparency in javascript platformmuiroc
2020-02-08Merge pull request #35381 from Calinou/html5-export-faviconFabio Alessandrelli
Export and reference the icon as favicon when exporting to HTML5
2020-02-07Fix javascript platform buildmuiroc
2020-02-05Remove duplicate ERR_PRINT macro.Marcel Admiraal
2020-02-01Export and reference the icon as favicon when exporting to HTML5Hugo Locurcio
This makes the project icon display immediately as a favicon when opening the page, without having to wait for the project to finish loading.
2020-01-31Merge pull request #35451 from Calinou/html5-web-environment-onlyRémi Verschelde
Only emit the JavaScript support code for Web when building for HTML5
2020-01-31Only emit the JavaScript support code for Web when building for HTML5Hugo Locurcio
Excluding other unused environments like Node.js makes the support code about 4 KB smaller.
2020-01-29Fix some URLs to use HTTPS when availableRémi Verschelde
2020-01-23Make `OS.execute()` blocking by default if not specifiedHugo Locurcio
This makes `OS.execute()` calls quicker to set up when calling programs in a blocking fashion.
2020-01-20Revert "Fix audio capture naming in Javascript"Rémi Verschelde
This reverts commit 69f7263cd8990b39e4c1cc678b2d0f57686b07b7. Follow-up to #35359.
2020-01-17HTML5 callbacks rework.Fabio Alessandrelli
Fixes compatibility with emscripten 1.39.5+ . Most input callbacks now require a target and no longer support NULL defaults. This commit changes all required null targets to the expected default in the binding phase. Since for canvas-related callbacks there is no default, the "#canvas" selector is used instead. Additionally, since canvasX and canvasY event properties are no longer supported, event positions are computed from "clientX" and "clientY" and the "#canvas" bounding client rect.
2020-01-17HTML5: Address removal of 'timestamp' in Emscripten 1.39.5Rémi Verschelde
It was removed as noted in the changelog: https://github.com/emscripten-core/emscripten/blob/1.39.5/ChangeLog.md#v1395-12202019 > Removed `timestamp` field from mouse, wheel, devicemotion and > deviceorientation events. The presence of a `timestamp` on these > events was slightly arbitrary, and populating this field caused > a small profileable overhead that all users might not care about. > It is easy to get a timestamp of an event by calling > `emscripten_get_now()` or `emscripten_performance_now()` inside > the event handler function of any event. Fixes #34648.
2020-01-14Properly close files served by debug HTTP server.Fabio Alessandrelli
2020-01-14Add mime type to responses from debug HTTP server.Fabio Alessandrelli
Get rid of warnings in firefox mentioning performance loss when no mime type is given for wasm files.
2020-01-07Export: Improve usability of command line interfaceRémi Verschelde
I'm barely scratching the surface of the changes needed to make the --export command line interface easy to use, but this should already improve things somewhat. - Streamline `can_export()` templates check in all platforms, checking first for the presence of official templates, then of any defined custom template, and reporting on the absence of any. Shouldn't change the actual return value much which is still true if either release or debug is usable - we might want to change that eventually and better validate against the requested target. - Fix discrepancy between platforms using `custom_package/debug` and `custom_template/debug` (resp. `release`). All now use `custom_template`, which will break compatibility for `export_presets.cfg` with earlier projects (but is easy to fix). - Use `can_export()` when attempting a command line export and report the same errors that would be shown in the editor. - Improve error reporting after a failed export attempt, handling missing template and invalid path more gracefully. - Cleanup of unused stuff in EditorNode around the export workflow. - Improve --export documentation in --help a bit. Fixes #16949 (at least many of the misunderstandings listed there). Fixes #18470.
2020-01-01Update copyright statements to 2020Rémi Verschelde
Happy new year to the wonderful Godot community! We're starting a new decade with a well-established, non-profit, free and open source game engine, and tons of further improvements in the pipeline from hundreds of contributors. Godot will keep getting better, and we're looking forward to all the games that the community will keep developing and releasing with it.
2019-12-03Emscripten: Re-add BINARYEN_TRAP_MODE='clamp' for fastcompRémi Verschelde
The option is needed when using the 'fastcomp' backend (default before 1.39.0), and must not be defined when using 'upstream' (new default). So we define it conditionally to support both backends. Follow-up to #30751.
2019-12-01iOS modular build and export implementation.bruvzg
2019-11-24Add download_chunk_size property to HTTPRequest.Fabio Alessandrelli
This allows setting the `read_chunk_size` of the internal HTTPClient. This is important to reduce the allocation overhead and number of file writes when downloading large files, allowing for better download speed.
2019-11-20pcre2: Use scons option to disable JIT on some platformsRémi Verschelde
Third-party platforms (e.g. console ports) need to be able to disable JIT support in the regex module too, so it can't be hardcoded in the module SCsub. This is cleaner this way anyway. Fixes #19316.
2019-11-19HTML5: Explicitly link idbfs.js for IDBFS supportRémi Verschelde
Upstream Emscripten changed this in 1.39.1+, so IDBFS is no longer included by default and has to be linked manually. The explicit linking doesn't seem to be problematic on earlier versions (tested `1.38.47-upstream`). Fixes #33724.
2019-11-15HTML5: Fix support for Emscripten 1.39.1+Rémi Verschelde
A change in upstream Emscripten 1.39.1+ made our buildsystem error out where it was previously only issuing a warning: ``` [ 5%] Linking Static Library ==> main/libmain.javascript.opt.bc shared:WARNING: Assuming object file output in the absence of `-c`, based on output filename. Please add with `-c` or `-r` to avoid this warning Ranlib Library ==> main/libmain.javascript.opt.bc /opt/emsdk/upstream/bin/llvm-ranlib: error: unable to load 'main/libmain.javascript.opt.bc': file too small to be an archive ``` As advised on emscripten-core/emscripten#9806, we should be using `emar` here to create the static library and not `emcc`. This was apparently done to workaround Emscripten issues in the past, but evidently this is no longer necessary. The rest of the `env` redefinitions should probably be re-assessed against the current state of Emscripten. Fixes #33374.
2019-10-24Remove ECMAScript 6 "arrow operator".Fabio Alessandrelli
We don't need it, it's not well supported by compilers, and it was a mistake in the first place.