1
0
Fork 0
mirror of https://github.com/Reuh/ubiquitousse.git synced 2025-10-27 09:09:30 +00:00

Update and rebuild docs

This commit is contained in:
Étienne Fildadut 2022-09-16 20:07:53 +09:00
parent 21679dde5c
commit 7ad5c2d641
19 changed files with 3026 additions and 949 deletions

View file

@ -1,4 +1,4 @@
Copyright 2021 Étienne "Reuh" Fildadut Copyright 2016-2022 Étienne "Reuh" Fildadut
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

View file

@ -35,6 +35,7 @@
<li><a href="modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="modules/asset.html">asset</a></li> <li><a href="modules/asset.html">asset</a></li>
<li><a href="modules/ecs.html">ecs</a></li> <li><a href="modules/ecs.html">ecs</a></li>
<li><a href="modules/input.html">input</a></li>
<li><a href="modules/ldtk.html">ldtk</a></li> <li><a href="modules/ldtk.html">ldtk</a></li>
<li><a href="modules/scene.html">scene</a></li> <li><a href="modules/scene.html">scene</a></li>
<li><a href="modules/signal.html">signal</a></li> <li><a href="modules/signal.html">signal</a></li>
@ -71,6 +72,10 @@
<td class="name" nowrap><a href="modules/ecs.html">ecs</a></td> <td class="name" nowrap><a href="modules/ecs.html">ecs</a></td>
<td class="summary">ECS (<a href="https://en.wikipedia.org/wiki/Entity_component_system">entity compenent system</a>) library for Lua.</td> <td class="summary">ECS (<a href="https://en.wikipedia.org/wiki/Entity_component_system">entity compenent system</a>) library for Lua.</td>
</tr> </tr>
<tr>
<td class="name" nowrap><a href="modules/input.html">input</a></td>
<td class="summary">Input management facilities.</td>
</tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/ldtk.html">ldtk</a></td> <td class="name" nowrap><a href="modules/ldtk.html">ldtk</a></td>
<td class="summary"><a href="https://ldtk.io/">LDtk</a> level importer for Lua and drawing using LÖVE.</td> <td class="summary"><a href="https://ldtk.io/">LDtk</a> level importer for Lua and drawing using LÖVE.</td>
@ -81,7 +86,7 @@
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/signal.html">signal</a></td> <td class="name" nowrap><a href="modules/signal.html">signal</a></td>
<td class="summary">Signal management for Lua.</td> <td class="summary">Simple signal / observer pattern implementation for Lua.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="modules/timer.html">timer</a></td> <td class="name" nowrap><a href="modules/timer.html">timer</a></td>
@ -108,7 +113,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -43,6 +43,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><strong>asset</strong></li> <li><strong>asset</strong></li>
<li><a href="../modules/ecs.html">ecs</a></li> <li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li> <li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li> <li><a href="../modules/scene.html">scene</a></li>
<li><a href="../modules/signal.html">signal</a></li> <li><a href="../modules/signal.html">signal</a></li>
@ -67,6 +68,8 @@
<p> See the <a href="../modules/asset.html#Asset:__call">Asset:__call</a> method for more details on how assets are loaded. Hopefully this will allow you to use asset which are more game-specific than &ldquo;image&rdquo; or &ldquo;audio&rdquo;.</p> <p> See the <a href="../modules/asset.html#Asset:__call">Asset:__call</a> method for more details on how assets are loaded. Hopefully this will allow you to use asset which are more game-specific than &ldquo;image&rdquo; or &ldquo;audio&rdquo;.</p>
<p> TODO: async loading</p>
<p> No dependencies.</p> <p> No dependencies.</p>
<h3>Usage:</h3> <h3>Usage:</h3>
<ul> <ul>
@ -334,7 +337,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -44,6 +44,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li> <li><a href="../modules/asset.html">asset</a></li>
<li><strong>ecs</strong></li> <li><strong>ecs</strong></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li> <li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li> <li><a href="../modules/scene.html">scene</a></li>
<li><a href="../modules/signal.html">signal</a></li> <li><a href="../modules/signal.html">signal</a></li>
@ -279,6 +280,10 @@ end
<td class="summary">Returns an iterator that iterate through the entties in this system, in order.</td> <td class="summary">Returns an iterator that iterate through the entties in this system, in order.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#System:get">System:get (i)</a></td>
<td class="summary">Get the <code>i</code>th entity in the system.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#System:clear">System:clear ()</a></td> <td class="name" nowrap><a href="#System:clear">System:clear ()</a></td>
<td class="summary">Remove every entity from the system and its subsystems.</td> <td class="summary">Remove every entity from the system and its subsystems.</td>
</tr> </tr>
@ -410,7 +415,15 @@ end
<strong>scene (name[, systems={}[, entities={}]])</strong> <strong>scene (name[, systems={}[, entities={}]])</strong>
</dt> </dt>
<dd> <dd>
If <code>uqt.scene</code> is available, returns a new scene that will consist of a ECS world with the specified systems and entities. If <code>uqt.scene</code> is available, returns a new scene that will consist of a ECS world with the specified systems and entities. </p>
<p> When suspending and resuming the scene, the <code>onSuspend</code> and <code>onResume</code> events will be emitted on the ECS world.</p>
<p> Note that since <code>uqt.scene</code> use <a href="https://www.lua.org/manual/5.1/manual.html#pdf-require">require</a> to load the scenes, the scenes files will be cached &ndash; including variables defined in them.
So if you store the entity list directly in a variable in the scene file, it will be reused every time the scene is entered, and will thus
be shared among the different execution of the scene. This may be problematic if an entity is modified by one scene instance, as it will affect others
(this should not be a problem with systems due to system instanciation). To avoid this issue, instead you would typically define entities through a
function that will recreate the entities on every scene load.
<h3>Requires:</h3> <h3>Requires:</h3>
<ul> <ul>
@ -427,13 +440,13 @@ end
the name of the new scene the name of the new scene
</li> </li>
<li><span class="parameter">systems</span> <li><span class="parameter">systems</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span> <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table/function</a></span>
list of systems to add to the world list of systems to add to the world. If it is a function, it will be executed every time we enter the scene and returns the list of systems.
(<em>default</em> {}) (<em>default</em> {})
</li> </li>
<li><span class="parameter">entities</span> <li><span class="parameter">entities</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span> <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table/function</a></span>
list of entities to add to the world list of entities to add to the world. If it is a function, it will be executed every time we enter the scene and returns the list of entities.
(<em>default</em> {}) (<em>default</em> {})
</li> </li>
</ul> </ul>
@ -1506,6 +1519,39 @@ avoid repeating your filters or allow controlling several system from a single p
</dd>
<dt>
<a name = "System:get"></a>
<strong>System:get (i)</strong>
</dt>
<dd>
Get the <code>i</code>th entity in the system.
This is a simple wrapper around <a href="../modules/ecs.html#System:iter">iter</a>; it <em>will</em> iterate over all the entities in the system in order until we reach the desired one.
Complexity: O(i)
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">i</span>
<span class="types"><span class="type">number</span></span>
the index of the entity
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/ecs.html#Entity_objects">Entity</a></span>
the entity; <code>nil</code> if there is no such entity in the system
</ol>
</dd> </dd>
<dt> <dt>
<a name = "System:clear"></a> <a name = "System:clear"></a>
@ -1683,7 +1729,7 @@ its sibling systems (i.e. completely stop the propagation of the event).</li>
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

706
docs/modules/input.html Normal file
View file

@ -0,0 +1,706 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Ubiquitousse reference</title>
<link rel="stylesheet" href="../ldoc_new.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Ubiquitousse</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Input_objects">Input objects </a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li>
<li><strong>input</strong></li>
<li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li>
<li><a href="../modules/signal.html">signal</a></li>
<li><a href="../modules/timer.html">timer</a></li>
<li><a href="../modules/util.html">util</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../topics/LICENSE.html">LICENSE</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>input</code></h1>
<p>Input management facilities.</p>
<p> The module returns a single function, <a href="../modules/input.html#">input</a>.</p>
<p> <strong>Requires</strong> ubiquitousse.signal.</p>
<h3>Usage:</h3>
<ul>
<pre class="example">TODO
</pre>
</ul>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#input">input ()</a></td>
<td class="summary">Make a new input object.</td>
</tr>
</table>
<h2><a href="#Input_objects">Input objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Input.config">Input.config</a></td>
<td class="summary">Input configuration table.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input.children">Input.children</a></td>
<td class="summary">List and map of children inputs.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input.name">Input.name</a></td>
<td class="summary">Name of the input.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input.grabbed">Input.grabbed</a></td>
<td class="summary">False if the input is currently not grabbed, a subinput otherwise.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input.grabbing">Input.grabbing</a></td>
<td class="summary">False if the input is not a subinput, the input it grabbed otherwise.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input.event">Input.event</a></td>
<td class="summary">Input event registry.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:update">Input:update ()</a></td>
<td class="summary">Update the input and its children.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:clone">Input:clone ()</a></td>
<td class="summary">Create a new input object based on this input <a href="../modules/input.html#Input.config">config</a> data.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:reload">Input:reload ()</a></td>
<td class="summary">Relond the input <a href="../modules/input.html#Input.config">config</a>, and do the same for its children.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:disable">Input:disable ()</a></td>
<td class="summary">Disable the input and its children, preventing further updates and events.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:onNextActiveSource">Input:onNextActiveSource (fn[, filter])</a></td>
<td class="summary">Will call fn(source) on the next activated source (including sources not currently used by this input).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:grab">Input:grab ()</a></td>
<td class="summary">Grab the input and its children input and returns the new subinput.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:release">Input:release ()</a></td>
<td class="summary">Release a subinput and its children.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:neutralize">Input:neutralize ()</a></td>
<td class="summary">Set the state of this input to a neutral position (i.e.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:setJoystick">Input:setJoystick (joystick)</a></td>
<td class="summary">Set the joystick associated with this input.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:getJoystick">Input:getJoystick ()</a></td>
<td class="summary">Returns the currently selected joystick.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:down">Input:down ()</a></td>
<td class="summary">Returns true if the input is currently down.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:pressed">Input:pressed ()</a></td>
<td class="summary">Returns true if the input has just been pressed.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:released">Input:released ()</a></td>
<td class="summary">Returns true if the input has just been released.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:value">Input:value ()</a></td>
<td class="summary">Returns the current value of the input.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:delta">Input:delta ()</a></td>
<td class="summary">Returns the delta value of the input since the last call to <a href="../modules/input.html#Input:update">update</a>.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:pointer">Input:pointer ()</a></td>
<td class="summary">If there is a horizontal and vertical children inputs, this returns the horizontal value and the vertical value.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Input:clamped">Input:clamped ()</a></td>
<td class="summary">Same as <a href="../modules/input.html#Input:pointer">pointer</a>, but normalize the returned vector, i.e.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "input"></a>
<strong>input ()</strong>
</dt>
<dd>
Make a new input object.
t: input configuration table (optional)
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="Input_objects"></a>Input objects </h2>
<div class="section-description">
Input methods.
</div>
<dl class="function">
<dt>
<a name = "Input.config"></a>
<strong>Input.config</strong>
</dt>
<dd>
Input configuration table.
It can be used to recreate this input object later (by passing the table as an argument for the input constructor).
This table does not contain any userdata and should be easily serializable (e.g. to save custom input binding config).
This doesn&rsquo;t include input state, grab state, the event registry and the selected joystick since they may change often during runtime.
Can be changed anytime, but you may need to call <a href="../modules/input.html#Input:reload">reload</a> to apply changes.
</ul>
</ul>
</ul>
</ul>
<h3>Usage:</h3>
<ul>
<pre class="example">player.config = {
<span class="string">"key.a"</span>, <span class="string">"key.d - key.a"</span>, {<span class="string">"key.left + x"</span>, x=<span class="number">0.5</span>}, <span class="comment">-- list of input sources expressions
</span> jump = {...}, <span class="comment">-- children input
</span> deadzone = <span class="number">0.05</span>, <span class="comment">-- The deadzone for analog inputs (e.g. joystick axes): if the input absolute value is strictly below this, it will be considered as 0.
</span> threshold = <span class="number">0.05</span> <span class="comment">-- The pressed threshold: an input is considered down if above or equal to this value.
</span>}</pre>
</ul>
</dd>
<dt>
<a name = "Input.children"></a>
<strong>Input.children</strong>
</dt>
<dd>
List and map of children inputs.
{[child1.name]=child1, [child2.name]=child2, child1, child2&hellip;}
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input.name"></a>
<strong>Input.name</strong>
</dt>
<dd>
Name of the input.
Defined on children inputs only.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input.grabbed"></a>
<strong>Input.grabbed</strong>
</dt>
<dd>
False if the input is currently not grabbed, a subinput otherwise.
This may be different between each subinput.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input.grabbing"></a>
<strong>Input.grabbing</strong>
</dt>
<dd>
False if the input is not a subinput, the input it grabbed otherwise.
This may be different between each subinput.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input.event"></a>
<strong>Input.event</strong>
</dt>
<dd>
Input event registry.
The following events are available:</p>
<ul>
<li><code>&quot;moved&quot;</code>: called when the input value change, with arguments (new value, delta since last event)</li>
<li><code>&quot;pressed&quot;</code>: called when the input is pressed</li>
<li><code>&quot;released&quot;</code>: called when the input is released</li>
</ul>
<p> For pointer inputs (have a &ldquo;horizontal&rdquo; and &ldquo;vertical&rdquo; children inputs) is also avaible:</p>
<ul>
<li><code>&quot;pointer moved&quot;</code>: called when the pointer position change, with arguments (new pointer x, new pointer y, delta x since last event, delta y since last event)</li>
</ul>
<p> Each subinput has a different event registry.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:update"></a>
<strong>Input:update ()</strong>
</dt>
<dd>
Update the input and its children.
Should be called every frame, typically <em>after</em> you've done all your input handling
(otherwise <a href="../modules/input.html#Input:pressed">pressed</a> and <a href="../modules/input.html#Input:released">released</a> may never return true and <a href="../modules/input.html#Input:delta">delta</a> might be wrong).
(Note: this should not be called on subinputs)
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:clone"></a>
<strong>Input:clone ()</strong>
</dt>
<dd>
Create a new input object based on this input <a href="../modules/input.html#Input.config">config</a> data.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:reload"></a>
<strong>Input:reload ()</strong>
</dt>
<dd>
Relond the input <a href="../modules/input.html#Input.config">config</a>, and do the same for its children.
This will reenable the input if it was disabled using <a href="../modules/input.html#Input:disable">disable</a>.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:disable"></a>
<strong>Input:disable ()</strong>
</dt>
<dd>
Disable the input and its children, preventing further updates and events.
The input can be reenabled using <a href="../modules/input.html#Input:reload">reload</a>.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:onNextActiveSource"></a>
<strong>Input:onNextActiveSource (fn[, filter])</strong>
</dt>
<dd>
Will call fn(source) on the next activated source (including sources not currently used by this input).
Typically used to detect an input in your game input binding settings.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">fn</span>
function that will be called on the next activated source matching the filter
</li>
<li><span class="parameter">filter</span>
list of string patterns that sources must start with (example <code>{&quot;button&quot;, &quot;key&quot;}</code> to only get buttons and key sources)
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "Input:grab"></a>
<strong>Input:grab ()</strong>
</dt>
<dd>
Grab the input and its children input and returns the new subinput. </p>
<p> A grabbed input will no longer update and instead pass all new update to the subinput.
This is typically used for contextual action or pause menus: by grabbing the player input, all the direct use of
this input in the game will stop (can&rsquo;t move caracter, &hellip;) and instead you can use the subinput to handle input in the pause menu.
To stop grabbing an input, you will need to <code>:release</code> the subinput.</p>
<p> This will also reset the input to a neutral state. The subinput will share everything with this input, except
<a href="../modules/input.html#Input.grabbed">grabbed</a>, <a href="../modules/input.html#Input.grabbing">grabbing</a>, <a href="../modules/input.html#Input.event">event</a> (a new event registry is created), and of course its current state.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:release"></a>
<strong>Input:release ()</strong>
</dt>
<dd>
Release a subinput and its children.
The parent grabbed input will be updated again. This subinput will be reset to a neutral position and won&rsquo;t be updated further.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:neutralize"></a>
<strong>Input:neutralize ()</strong>
</dt>
<dd>
Set the state of this input to a neutral position (i.e. value = 0).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:setJoystick"></a>
<strong>Input:setJoystick (joystick)</strong>
</dt>
<dd>
Set the joystick associated with this input.
The input will ignore every other joystick.
Set joystick to <code>nil</code> to disable and get input from every connected joystick.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">joystick</span>
LÖVE jostick object to associate
</li>
</ul>
</dd>
<dt>
<a name = "Input:getJoystick"></a>
<strong>Input:getJoystick ()</strong>
</dt>
<dd>
Returns the currently selected joystick.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:down"></a>
<strong>Input:down ()</strong>
</dt>
<dd>
Returns true if the input is currently down.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:pressed"></a>
<strong>Input:pressed ()</strong>
</dt>
<dd>
Returns true if the input has just been pressed.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:released"></a>
<strong>Input:released ()</strong>
</dt>
<dd>
Returns true if the input has just been released.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:value"></a>
<strong>Input:value ()</strong>
</dt>
<dd>
Returns the current value of the input.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:delta"></a>
<strong>Input:delta ()</strong>
</dt>
<dd>
Returns the delta value of the input since the last call to <a href="../modules/input.html#Input:update">update</a>.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:pointer"></a>
<strong>Input:pointer ()</strong>
</dt>
<dd>
If there is a horizontal and vertical children inputs, this returns the horizontal value and the vertical value.
Typically used for movement/axes pairs (e.g. to get x,y of a stick or directional pad).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Input:clamped"></a>
<strong>Input:clamped ()</strong>
</dt>
<dd>
Same as <a href="../modules/input.html#Input:pointer">pointer</a>, but normalize the returned vector, i.e. &ldquo;clamp&rdquo; the returned x,y coordinates into a circle of radius 1.
Typically used to avoid faster movement on diagonals
(as if both horizontal and vertical values are 1, the pointer vector has √2 magnitude, higher than the 1 magnitude of a purely vertical or horizontal movement).
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View file

@ -50,6 +50,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li> <li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li> <li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><strong>ldtk</strong></li> <li><strong>ldtk</strong></li>
<li><a href="../modules/scene.html">scene</a></li> <li><a href="../modules/scene.html">scene</a></li>
<li><a href="../modules/signal.html">signal</a></li> <li><a href="../modules/signal.html">signal</a></li>
@ -68,15 +69,22 @@
<h1>Module <code>ldtk</code></h1> <h1>Module <code>ldtk</code></h1>
<p><a href="https://ldtk.io/">LDtk</a> level importer for Lua and drawing using LÖVE.</p> <p><a href="https://ldtk.io/">LDtk</a> level importer for Lua and drawing using LÖVE.</p>
<p> Support most LDtk features, and allow easy usage in LÖVE projects.</p> <p> Support most LDtk features, and allow easy usage in LÖVE projects.
In particular, this mainly focus only on features and values that are useful for showing the final level &ndash; this does not try, for example, to expose
every internal identfiers or intermediates values that are only relevant for editing.</p>
<p> Currently up-to-date with LDtk 1.1.3.</p>
<p> Every unit is in pixel in the API unless written otherwise. <p> Every unit is in pixel in the API unless written otherwise.
Colors are reprsented as a table <code>{r,g,b}</code> where <code>r</code>,<code>b</code>,<code>g</code> in [0-1].</p> Colors are reprsented as a table <code>{r,g,b}</code> where <code>r</code>,<code>b</code>,<code>g</code> in [0-1].</p>
<p> This modules returns a single function, <a href="../modules/ldtk.html#LDtk">LDtk</a>(path).</p> <p> This modules returns a single function, <a href="../modules/ldtk.html#LDtk">LDtk</a>(path).</p>
<p> No mandatory dependency. <p> This modules requires <a href="https://github.com/rxi/json.lua">json.lua</a>; a copy of it is included with ubiquitousse in the <code>lib</code> directory for simplicity.
Optionally requires LÖVE <code>love.graphics</code> (drawing Image, SpriteBatch, Quad) for drawing only.</p> This module will first try to load a global module named <code>json</code> &ndash; so if you use the same json module in your project ubiquitousse will reuse it.
If it doesn&rsquo;t find it, it will then try to load the copy included with ubiquitousse.</p>
<p> Optionally requires LÖVE <code>love.graphics</code> (drawing Image, SpriteBatch, Quad), for drawing only.</p>
<h3>Usage:</h3> <h3>Usage:</h3>
<ul> <ul>
<pre class="example">local ldtk = require(&quot;ubiquitousse.ldtk&quot;) <pre class="example">local ldtk = require(&quot;ubiquitousse.ldtk&quot;)
@ -116,24 +124,28 @@ end
<td class="summary"><a href="../modules/ldtk.html#Layer_objects">Layer</a> this entity belongs to.</td> <td class="summary"><a href="../modules/ldtk.html#Layer_objects">Layer</a> this entity belongs to.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.iid">Entity.iid</a></td>
<td class="summary">Unique instance identifier for this entity.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.identifier">Entity.identifier</a></td> <td class="name" nowrap><a href="#Entity.identifier">Entity.identifier</a></td>
<td class="summary">The entity name.</td> <td class="summary">The entity name.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.x">Entity.x</a></td> <td class="name" nowrap><a href="#Entity.x">Entity.x</a></td>
<td class="summary">X position of the entity relative to the layer.</td> <td class="summary">X position of the entity relative to the layer, in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.y">Entity.y</a></td> <td class="name" nowrap><a href="#Entity.y">Entity.y</a></td>
<td class="summary">Y position of the entity relative to the layer.</td> <td class="summary">Y position of the entity relative to the layer, in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.width">Entity.width</a></td> <td class="name" nowrap><a href="#Entity.width">Entity.width</a></td>
<td class="summary">The entity width.</td> <td class="summary">The entity width, in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.height">Entity.height</a></td> <td class="name" nowrap><a href="#Entity.height">Entity.height</a></td>
<td class="summary">The entity height.</td> <td class="summary">The entity height, in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.sx">Entity.sx</a></td> <td class="name" nowrap><a href="#Entity.sx">Entity.sx</a></td>
@ -145,11 +157,11 @@ end
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.pivotX">Entity.pivotX</a></td> <td class="name" nowrap><a href="#Entity.pivotX">Entity.pivotX</a></td>
<td class="summary">The entity pivot point x position relative to the entity.</td> <td class="summary">The entity pivot point x position relative to the entity, in pixels..</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.pivotY">Entity.pivotY</a></td> <td class="name" nowrap><a href="#Entity.pivotY">Entity.pivotY</a></td>
<td class="summary">The entity pivot point x position relative to the entity.</td> <td class="summary">The entity pivot point x position relative to the entity, in pixels..</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.color">Entity.color</a></td> <td class="name" nowrap><a href="#Entity.color">Entity.color</a></td>
@ -160,6 +172,10 @@ end
<td class="summary">Tile associated with the entity, if any.</td> <td class="summary">Tile associated with the entity, if any.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Entity.tags">Entity.tags</a></td>
<td class="summary">Tags associated with the entity: can be used either as a list of tags or a map of activated tags tags[name] == true.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.fields">Entity.fields</a></td> <td class="name" nowrap><a href="#Entity.fields">Entity.fields</a></td>
<td class="summary">Map of <a href="../modules/ldtk.html#CustomFields_objects">CustomFields</a> of the entity.</td> <td class="summary">Map of <a href="../modules/ldtk.html#CustomFields_objects">CustomFields</a> of the entity.</td>
</tr> </tr>
@ -174,6 +190,10 @@ end
<td class="name" nowrap><a href="#Tileset.image">Tileset.image</a></td> <td class="name" nowrap><a href="#Tileset.image">Tileset.image</a></td>
<td class="summary">The tileset LÖVE image object.</td> <td class="summary">The tileset LÖVE image object.</td>
</tr> </tr>
<tr>
<td class="name" nowrap><a href="#Tileset.tags">Tileset.tags</a></td>
<td class="summary">Tags associated with the tileset: can be used either as a list of tags or a map of activated tags tags[name] == true.</td>
</tr>
</table> </table>
<h2><a href="#Layer_objects">Layer objects </a></h2> <h2><a href="#Layer_objects">Layer objects </a></h2>
<table class="function_list"> <table class="function_list">
@ -186,6 +206,10 @@ end
<td class="summary"><a href="../modules/ldtk.html#Level_objects">Level</a> this layer belongs to.</td> <td class="summary"><a href="../modules/ldtk.html#Level_objects">Level</a> this layer belongs to.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Layer.iid">Layer.iid</a></td>
<td class="summary">Unique instance identifier for this layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.identifier">Layer.identifier</a></td> <td class="name" nowrap><a href="#Layer.identifier">Layer.identifier</a></td>
<td class="summary">The layer name.</td> <td class="summary">The layer name.</td>
</tr> </tr>
@ -226,6 +250,18 @@ end
<td class="summary">Height of the layer, in grid units.</td> <td class="summary">Height of the layer, in grid units.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Layer.parallaxFactorX">Layer.parallaxFactorX</a></td>
<td class="summary">Parallax horizontal factor (from -1 to 1, defaults to 0) which affects the scrolling speed of this layer, creating a fake 3D (parallax) effect.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.parallaxFactorY">Layer.parallaxFactorY</a></td>
<td class="summary">Parallax vertical factor (from -1 to 1, defaults to 0) which affects the scrolling speed of this layer, creating a fake 3D (parallax) effect.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.parallaxScaling">Layer.parallaxScaling</a></td>
<td class="summary">If true, a layer with a parallax factor will also be scaled up/down accordingly.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.entities">Layer.entities</a></td> <td class="name" nowrap><a href="#Layer.entities">Layer.entities</a></td>
<td class="summary"><em>(Entities layer only)</em> List of <a href="../modules/ldtk.html#Entity_objects">Entity</a> in the layer.</td> <td class="summary"><em>(Entities layer only)</em> List of <a href="../modules/ldtk.html#Entity_objects">Entity</a> in the layer.</td>
</tr> </tr>
@ -254,11 +290,11 @@ end
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Tile.x">Tile.x</a></td> <td class="name" nowrap><a href="#Tile.x">Tile.x</a></td>
<td class="summary">X position of the tile relative to the layer.</td> <td class="summary">X position of the tile relative to the layer, in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Tile.y">Tile.y</a></td> <td class="name" nowrap><a href="#Tile.y">Tile.y</a></td>
<td class="summary">Y position of the tile relative to the layer.</td> <td class="summary">Y position of the tile relative to the layer, in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Tile.flipX">Tile.flipX</a></td> <td class="name" nowrap><a href="#Tile.flipX">Tile.flipX</a></td>
@ -289,11 +325,11 @@ end
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#IntTile.x">IntTile.x</a></td> <td class="name" nowrap><a href="#IntTile.x">IntTile.x</a></td>
<td class="summary">X position of the IntTile relative to the layer.</td> <td class="summary">X position of the IntTile relative to the layer, in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#IntTile.y">IntTile.y</a></td> <td class="name" nowrap><a href="#IntTile.y">IntTile.y</a></td>
<td class="summary">Y position of the IntTile relative to the layer.</td> <td class="summary">Y position of the IntTile relative to the layer, in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#IntTile.identifier">IntTile.identifier</a></td> <td class="name" nowrap><a href="#IntTile.identifier">IntTile.identifier</a></td>
@ -335,16 +371,24 @@ end
<td class="summary">Whether this level is currently loaded or not.</td> <td class="summary">Whether this level is currently loaded or not.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Level.iid">Level.iid</a></td>
<td class="summary">Unique instance identifier for this level.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.identifier">Level.identifier</a></td> <td class="name" nowrap><a href="#Level.identifier">Level.identifier</a></td>
<td class="summary">The level name.</td> <td class="summary">The level name.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Level.depth">Level.depth</a></td>
<td class="summary">Depth of the level in the world, to properly stack overlapping levels when drawing.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.x">Level.x</a></td> <td class="name" nowrap><a href="#Level.x">Level.x</a></td>
<td class="summary">The level x position.</td> <td class="summary">The level x position in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Level.y">Level.y</a></td> <td class="name" nowrap><a href="#Level.y">Level.y</a></td>
<td class="summary">The level y position.</td> <td class="summary">The level y position in pixels.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Level.width">Level.width</a></td> <td class="name" nowrap><a href="#Level.width">Level.width</a></td>
@ -451,6 +495,27 @@ end
</dd>
<dt>
<a name = "Entity.iid"></a>
<strong>Entity.iid</strong>
</dt>
<dd>
Unique instance identifier for this entity.
</ul>
<h3>Type:</h3>
<ul>
<code>string</code>
</ul>
</ul>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "Entity.identifier"></a> <a name = "Entity.identifier"></a>
@ -478,7 +543,7 @@ end
<strong>Entity.x</strong> <strong>Entity.x</strong>
</dt> </dt>
<dd> <dd>
X position of the entity relative to the layer. X position of the entity relative to the layer, in pixels.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -499,7 +564,7 @@ end
<strong>Entity.y</strong> <strong>Entity.y</strong>
</dt> </dt>
<dd> <dd>
Y position of the entity relative to the layer. Y position of the entity relative to the layer, in pixels.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -520,7 +585,7 @@ end
<strong>Entity.width</strong> <strong>Entity.width</strong>
</dt> </dt>
<dd> <dd>
The entity width. The entity width, in pixels.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -541,7 +606,7 @@ end
<strong>Entity.height</strong> <strong>Entity.height</strong>
</dt> </dt>
<dd> <dd>
The entity height. The entity height, in pixels.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -604,7 +669,7 @@ end
<strong>Entity.pivotX</strong> <strong>Entity.pivotX</strong>
</dt> </dt>
<dd> <dd>
The entity pivot point x position relative to the entity. The entity pivot point x position relative to the entity, in pixels..
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -625,7 +690,7 @@ end
<strong>Entity.pivotY</strong> <strong>Entity.pivotY</strong>
</dt> </dt>
<dd> <dd>
The entity pivot point x position relative to the entity. The entity pivot point x position relative to the entity, in pixels..
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -683,6 +748,27 @@ end
</dd>
<dt>
<a name = "Entity.tags"></a>
<strong>Entity.tags</strong>
</dt>
<dd>
Tags associated with the entity: can be used either as a list of tags or a map of activated tags tags[name] == true.
</ul>
<h3>Type:</h3>
<ul>
<code>{"tag",["tag"]=true,...}</code>
</ul>
</ul>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "Entity.fields"></a> <a name = "Entity.fields"></a>
@ -755,6 +841,27 @@ end
</dd>
<dt>
<a name = "Tileset.tags"></a>
<strong>Tileset.tags</strong>
</dt>
<dd>
Tags associated with the tileset: can be used either as a list of tags or a map of activated tags tags[name] == true.
</ul>
<h3>Type:</h3>
<ul>
<code>{"tag",["tag"]=true,...}</code>
</ul>
</ul>
</ul>
</dd> </dd>
</dl> </dl>
<h2 class="section-header has-description"><a name="Layer_objects"></a>Layer objects </h2> <h2 class="section-header has-description"><a name="Layer_objects"></a>Layer objects </h2>
@ -822,6 +929,27 @@ end
</dd>
<dt>
<a name = "Layer.iid"></a>
<strong>Layer.iid</strong>
</dt>
<dd>
Unique instance identifier for this layer.
</ul>
<h3>Type:</h3>
<ul>
<code>string</code>
</ul>
</ul>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "Layer.identifier"></a> <a name = "Layer.identifier"></a>
@ -1032,6 +1160,69 @@ end
</dd>
<dt>
<a name = "Layer.parallaxFactorX"></a>
<strong>Layer.parallaxFactorX</strong>
</dt>
<dd>
Parallax horizontal factor (from -1 to 1, defaults to 0) which affects the scrolling speed of this layer, creating a fake 3D (parallax) effect.
</ul>
<h3>Type:</h3>
<ul>
<code>number</code>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.parallaxFactorY"></a>
<strong>Layer.parallaxFactorY</strong>
</dt>
<dd>
Parallax vertical factor (from -1 to 1, defaults to 0) which affects the scrolling speed of this layer, creating a fake 3D (parallax) effect.
</ul>
<h3>Type:</h3>
<ul>
<code>number</code>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.parallaxScaling"></a>
<strong>Layer.parallaxScaling</strong>
</dt>
<dd>
If true, a layer with a parallax factor will also be scaled up/down accordingly.
</ul>
<h3>Type:</h3>
<ul>
<code>boolean</code>
</ul>
</ul>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "Layer.entities"></a> <a name = "Layer.entities"></a>
@ -1039,6 +1230,7 @@ end
</dt> </dt>
<dd> <dd>
<em>(Entities layer only)</em> List of <a href="../modules/ldtk.html#Entity_objects">Entity</a> in the layer. <em>(Entities layer only)</em> List of <a href="../modules/ldtk.html#Entity_objects">Entity</a> in the layer.
Each entity in the list is also bound to its IID in this table, so if <code>ent = entities[1]</code>, you can also find it at <code>entities[ent.iid]</code>.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -1182,7 +1374,7 @@ end
<strong>Tile.x</strong> <strong>Tile.x</strong>
</dt> </dt>
<dd> <dd>
X position of the tile relative to the layer. X position of the tile relative to the layer, in pixels.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -1203,7 +1395,7 @@ end
<strong>Tile.y</strong> <strong>Tile.y</strong>
</dt> </dt>
<dd> <dd>
Y position of the tile relative to the layer. Y position of the tile relative to the layer, in pixels.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -1362,7 +1554,7 @@ end
<strong>IntTile.x</strong> <strong>IntTile.x</strong>
</dt> </dt>
<dd> <dd>
X position of the IntTile relative to the layer. X position of the IntTile relative to the layer, in pixels.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -1383,7 +1575,7 @@ end
<strong>IntTile.y</strong> <strong>IntTile.y</strong>
</dt> </dt>
<dd> <dd>
Y position of the IntTile relative to the layer. Y position of the IntTile relative to the layer, in pixels.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -1673,6 +1865,27 @@ end
</dd>
<dt>
<a name = "Level.iid"></a>
<strong>Level.iid</strong>
</dt>
<dd>
Unique instance identifier for this level.
</ul>
<h3>Type:</h3>
<ul>
<code>string</code>
</ul>
</ul>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "Level.identifier"></a> <a name = "Level.identifier"></a>
@ -1694,13 +1907,35 @@ end
</dd>
<dt>
<a name = "Level.depth"></a>
<strong>Level.depth</strong>
</dt>
<dd>
Depth of the level in the world, to properly stack overlapping levels when drawing. Default is 0, greater means above, lower means below.
</ul>
<h3>Type:</h3>
<ul>
<code>number</code>
</ul>
</ul>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "Level.x"></a> <a name = "Level.x"></a>
<strong>Level.x</strong> <strong>Level.x</strong>
</dt> </dt>
<dd> <dd>
The level x position. The level x position in pixels.
For Horizontal and Vertical layouts, is always -1.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -1721,7 +1956,8 @@ end
<strong>Level.y</strong> <strong>Level.y</strong>
</dt> </dt>
<dd> <dd>
The level y position. The level y position in pixels.
For Horizontal and Vertical layouts, is always -1.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -1806,6 +2042,7 @@ end
</dt> </dt>
<dd> <dd>
List of <a href="../modules/ldtk.html#Layer_objects">Layer</a>s in the level (table). List of <a href="../modules/ldtk.html#Layer_objects">Layer</a>s in the level (table).
Each layer in the list is also bound to its IID in this table, so if <code>lay = layers[1]</code>, you can also find it at <code>layers[lay.iid]</code>.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -1829,7 +2066,7 @@ end
Level background. </p> Level background. </p>
<p> If there is a background image, <code>background.image</code> contains a table <code>{image=image, x=number, y=number, sx=number, sy=number}</code> <p> If there is a background image, <code>background.image</code> contains a table <code>{image=image, x=number, y=number, sx=number, sy=number}</code>
where <a href="../modules/ldtk.html#Tileset.image">image</a> is the LÖVE image (or image filepath if LÖVE not available) <a href="../modules/ldtk.html#Level.x">x</a> and <a href="../modules/ldtk.html#Level.y">y</a> are the top-left position, where <a href="../modules/ldtk.html#Tileset.image">image</a> is the LÖVE image (or image filepath if LÖVE not available) <a href="../modules/ldtk.html#Entity.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a> are the top-left position,
and <a href="../modules/ldtk.html#Entity.sx">sx</a> and <a href="../modules/ldtk.html#Entity.sy">sy</a> the horizontal and vertical scale factors. and <a href="../modules/ldtk.html#Entity.sx">sx</a> and <a href="../modules/ldtk.html#Entity.sy">sy</a> the horizontal and vertical scale factors.
</ul> </ul>
@ -1867,6 +2104,7 @@ end
</dt> </dt>
<dd> <dd>
List of <a href="../modules/ldtk.html#Level_objects">Level</a>s in this project. List of <a href="../modules/ldtk.html#Level_objects">Level</a>s in this project.
Each level in the list is also bound to its IID in this table, so if <code>lvl = levels[1]</code>, you can also find it at <code>levels[lvl.iid]</code>.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -1904,8 +2142,10 @@ end
<li>Enum are converted into a Lua string giving the currently selected enum value.</li> <li>Enum are converted into a Lua string giving the currently selected enum value.</li>
<li>Filepath are converted into a Lua string giving the file path.</li> <li>Filepath are converted into a Lua string giving the file path.</li>
<li>Arrays are converted into a Lua table with the elements in it as a list.</li> <li>Arrays are converted into a Lua table with the elements in it as a list.</li>
<li>Points are converted into a Lua table with the fields <a href="../modules/ldtk.html#Level.x">x</a> and <a href="../modules/ldtk.html#Level.y">y</a>: <code>{ x=number, y=number }</code>.</li> <li>Points are converted into a Lua table with the fields <a href="../modules/ldtk.html#Entity.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a>, in pixels: <code>{ x=number, y=number }</code>.</li>
<li>Colors are converted into a Lua table with the red, green and blue components in [0-1] as a list: <code>{r,g,b}</code>.</li> <li>Colors are converted into a Lua table with the red, green and blue components in [0-1] as a list: <code>{r,g,b}</code>.</li>
<li>Tiles are converted into a Lua table { tileset = associated tileset object, quad = associated quad } where <a href="../modules/ldtk.html#Tile.quad">quad</a> is a LÖVE Quad if LÖVE is available, otherwise a table <code>{ x, y, width, height }</code>.</li>
<li>EntityRef are converted into a Lua table { level = level, layerIid = layer IID, entityIid = entity IID, entity = see explanation }. If the entity being refernced belongs to another level and this level is not loaded, <code>entity</code> will be nil; otherwise (same level or the other level is also loaded), it will contain the entity.</li>
</ul> </ul>
@ -1930,7 +2170,7 @@ end
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -43,6 +43,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li> <li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li> <li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li> <li><a href="../modules/ldtk.html">ldtk</a></li>
<li><strong>scene</strong></li> <li><strong>scene</strong></li>
<li><a href="../modules/signal.html">signal</a></li> <li><a href="../modules/signal.html">signal</a></li>
@ -702,7 +703,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -35,6 +35,7 @@
<ul> <ul>
<li><a href="#Module">Module </a></li> <li><a href="#Module">Module </a></li>
<li><a href="#SignalRegistry_objects">SignalRegistry objects </a></li> <li><a href="#SignalRegistry_objects">SignalRegistry objects </a></li>
<li><a href="#SignalGroup_objects">SignalGroup objects </a></li>
</ul> </ul>
@ -43,6 +44,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li> <li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li> <li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li> <li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li> <li><a href="../modules/scene.html">scene</a></li>
<li><strong>signal</strong></li> <li><strong>signal</strong></li>
@ -60,12 +62,31 @@
<div id="content"> <div id="content">
<h1>Module <code>signal</code></h1> <h1>Module <code>signal</code></h1>
<p>Signal management for Lua.</p> <p>Simple signal / observer pattern implementation for Lua.</p>
<p>No dependency. <p>No dependency.
Optional dependency: LÖVE to hook into LÖVE events.</p> Optional dependency: LÖVE to hook into LÖVE events.</p>
<p>The returned module also acts as a global <a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a>, so you can call the <code>:bind</code>, <code>:emit</code>, etc. methods directly on the module
if you don&rsquo;t need to isolate your signals in separate registries.</p>
<h3>Usage:</h3> <h3>Usage:</h3>
<ul> <ul>
<pre class="example">TODO <pre class="example">local signal = require(&quot;ubiquitousse.signal&quot;)
-- Bind a function to a &quot;hit&quot; signal
signal:bind(&quot;hit&quot;, function(enemy)
print(enemy..&quot; was hit!&quot;)
end)
-- Somewhere else in your code: will call every function bound to &quot;hit&quot; signal with &quot;invader&quot; argument
signal:emit(&quot;hit&quot;, &quot;invader&quot;)
-- We also provides a predefined SignalRegistry (signal.event) which emit signals on LÖVE callbacks
-- You can initialize it with:
signal.registerEvents()
signal.event:bind(&quot;update&quot;, function(dt) print(&quot;called every update&quot;) end)
signal.event:bind(&quot;keypressed&quot;, function(key, scancode) print(&quot;pressed key &quot;..key) end)
-- etc., for every LÖVE callback
</pre> </pre>
</ul> </ul>
@ -77,8 +98,12 @@
<td class="summary">Creates and return a new SignalRegistry.</td> <td class="summary">Creates and return a new SignalRegistry.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#group">group ()</a></td>
<td class="summary">Creates and return a new SignalGroup.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#event">event</a></td> <td class="name" nowrap><a href="#event">event</a></td>
<td class="summary"><a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry <td class="summary"><a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on LÖVE events; other ubiquitousse modules may bind to this registry
if avaible.</td> if avaible.</td>
</tr> </tr>
<tr> <tr>
@ -93,29 +118,76 @@
<td class="summary">Map of signals to list of listeners.</td> <td class="summary">Map of signals to list of listeners.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#SignalRegistry:bind">SignalRegistry:bind (name, fn, ...)</a></td> <td class="name" nowrap><a href="#SignalRegistry.chained">SignalRegistry.chained</a></td>
<td class="summary">Bind one or several functions to a signal name.</td> <td class="summary">List of registries chained to this registry.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#SignalRegistry:unbind">SignalRegistry:unbind (name, fn, ...)</a></td> <td class="name" nowrap><a href="#SignalRegistry:bind">SignalRegistry:bind (name, fn)</a></td>
<td class="summary">Unbind one or several functions to a signal name.</td> <td class="summary">Bind a function to a signal name.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#SignalRegistry:unbindAll">SignalRegistry:unbindAll (name)</a></td> <td class="name" nowrap><a href="#SignalRegistry:has">SignalRegistry:has (name, fn)</a></td>
<td class="summary">Returns true if fn is bound to the signal.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:unbind">SignalRegistry:unbind (name, fn)</a></td>
<td class="summary">Unbind a function from a signal name.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:unbindPattern">SignalRegistry:unbindPattern (pat, fn)</a></td>
<td class="summary">Unbind a function from every signal whose name match the pattern.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:clear">SignalRegistry:clear (name)</a></td>
<td class="summary">Remove every bound function to a signal name.</td> <td class="summary">Remove every bound function to a signal name.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#SignalRegistry:replace">SignalRegistry:replace (name, sourceFn, destFn)</a></td> <td class="name" nowrap><a href="#SignalRegistry:clearPattern">SignalRegistry:clearPattern (pat)</a></td>
<td class="summary">Replace a bound function with another function.</td> <td class="summary">Remove every bound function to every signal whose name match the pattern.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:clear">SignalRegistry:clear ()</a></td>
<td class="summary">Remove every bound function to every signal.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#SignalRegistry:emit">SignalRegistry:emit (name, ...)</a></td> <td class="name" nowrap><a href="#SignalRegistry:emit">SignalRegistry:emit (name, ...)</a></td>
<td class="summary">Emit a signal, i.e.</td> <td class="summary">Emit a signal, i.e.</td>
</tr> </tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:emitPattern">SignalRegistry:emitPattern (pat, ...)</a></td>
<td class="summary">Emit to every signal whose name match the pattern.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:chain">SignalRegistry:chain (registry)</a></td>
<td class="summary">Chain another regsitry to this registry.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:unchain">SignalRegistry:unchain (registry)</a></td>
<td class="summary">Unchain a specific registry from the registry chaining list.</td>
</tr>
</table>
<h2><a href="#SignalGroup_objects">SignalGroup objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#SignalGroup.paused">SignalGroup.paused</a></td>
<td class="summary">Indicate if the signal group if currently paused or not.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup.binds">SignalGroup.binds</a></td>
<td class="summary">List of triplets in the group.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup:bind">SignalGroup:bind (registry, name, fn)</a></td>
<td class="summary">Bind a function to a signal name in the given registry.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup:clear">SignalGroup:clear ()</a></td>
<td class="summary">Remove every bound triplet in the group.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup:pause">SignalGroup:pause ()</a></td>
<td class="summary">Pause the group.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup:resume">SignalGroup:resume ()</a></td>
<td class="summary">Resume the group.</td>
</tr>
</table> </table>
<br/> <br/>
@ -149,27 +221,53 @@
</dd>
<dt>
<a name = "group"></a>
<strong>group ()</strong>
</dt>
<dd>
Creates and return a new SignalGroup.
</ul>
</ul>
</ul>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/signal.html#SignalGroup_objects">SignalGroup</a></span>
</ol>
</dd> </dd>
<dt> <dt>
<a name = "event"></a> <a name = "event"></a>
<strong>event</strong> <strong>event</strong>
</dt> </dt>
<dd> <dd>
<p><a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry <a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on LÖVE events; other ubiquitousse modules may bind to this registry
if avaible. </p> if avaible. </p>
<p> For example, every ubiquitousse module with a &ldquo;update&rdquo; function will bind it to the &ldquo;update&rdquo; signal in the registry; <p> For example, every ubiquitousse module with a &ldquo;update&rdquo; function will bind it to the &ldquo;update&rdquo; signal in the registry;
you can then call this signal on each game update to update every ubiquitousse module easily.</p> you can then call this signal on each game update to update every ubiquitousse module easily.</p>
<p> Provided signals:</p> <p> You will need to call <a href="../modules/signal.html#registerEvents">registerEvents</a> for the signal to be called on LÖVE callbacks automatically (otherwise you will have to emit the events
from the LÖVE callbacks manually).</p>
<ul>
<li><code>update(dt)</code>, should be called on every game update</li>
<li><code>draw()</code>, should be called on every game draw</li>
<li>for LÖVE, there are callbacks for every LÖVE callback function that need to be called on their corresponding LÖVE callback</li>
</ul>
<p> List of signals available: &ldquo;displayrotated&rdquo;, &ldquo;draw&rdquo;, &ldquo;load&rdquo;, &ldquo;lowmemory&rdquo;, &ldquo;quit&rdquo;, &ldquo;update&rdquo;,
&ldquo;directorydropped&rdquo;, &ldquo;filedropped&rdquo;, &ldquo;focus&rdquo;, &ldquo;mousefocus&rdquo;, &ldquo;resize&rdquo;, &ldquo;visible&rdquo;,
&ldquo;keypressed&rdquo;, &ldquo;keyreleased&rdquo;, &ldquo;textedited&rdquo;, &ldquo;textinput&rdquo;,
&ldquo;mousemoved&rdquo;, &ldquo;mousepressed&rdquo;, &ldquo;mousereleased&rdquo;, &ldquo;wheelmoved&rdquo;,
&ldquo;gamepadaxis&rdquo;, &ldquo;gamepadpressed&rdquo;, &ldquo;gamepadreleased&rdquo;,
&ldquo;joystickadded&rdquo;, &ldquo;joystickaxis&rdquo;, &ldquo;joystickhat&rdquo;, &ldquo;joystickpressed&rdquo;, &ldquo;joystickreleased&rdquo;, &ldquo;joystickremoved&rdquo;,
&ldquo;touchmoved&rdquo;, &ldquo;touchpressed&rdquo;, &ldquo;touchreleased&rdquo;.
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
@ -226,7 +324,28 @@
</ul> </ul>
<h3>Type:</h3> <h3>Type:</h3>
<ul> <ul>
<code>{["name"]={fn,...}}</code> <code>{["name"]={fn,[fn]=1,...}}</code>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalRegistry.chained"></a>
<strong>SignalRegistry.chained</strong>
</dt>
<dd>
List of registries chained to this registry.
</ul>
<h3>Type:</h3>
<ul>
<code>{</code> registry, ... }
</ul> </ul>
</ul> </ul>
</ul> </ul>
@ -239,10 +358,10 @@
</dd> </dd>
<dt> <dt>
<a name = "SignalRegistry:bind"></a> <a name = "SignalRegistry:bind"></a>
<strong>SignalRegistry:bind (name, fn, ...)</strong> <strong>SignalRegistry:bind (name, fn)</strong>
</dt> </dt>
<dd> <dd>
Bind one or several functions to a signal name. Bind a function to a signal name.
</ul> </ul>
</ul> </ul>
@ -259,9 +378,34 @@
<span class="types"><span class="type">function</span></span> <span class="types"><span class="type">function</span></span>
the function to bind to the signal the function to bind to the signal
</li> </li>
<li><span class="parameter">...</span> </ul>
<span class="types"><span class="type">function,...</span></span>
other function to bind to the signal
</dd>
<dt>
<a name = "SignalRegistry:has"></a>
<strong>SignalRegistry:has (name, fn)</strong>
</dt>
<dd>
Returns true if fn is bound to the signal.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li>
<li><span class="parameter">fn</span>
<span class="types"><span class="type">function</span></span>
the function
</li> </li>
</ul> </ul>
@ -272,10 +416,10 @@
</dd> </dd>
<dt> <dt>
<a name = "SignalRegistry:unbind"></a> <a name = "SignalRegistry:unbind"></a>
<strong>SignalRegistry:unbind (name, fn, ...)</strong> <strong>SignalRegistry:unbind (name, fn)</strong>
</dt> </dt>
<dd> <dd>
Unbind one or several functions to a signal name. Unbind a function from a signal name.
</ul> </ul>
</ul> </ul>
@ -292,9 +436,34 @@
<span class="types"><span class="type">function</span></span> <span class="types"><span class="type">function</span></span>
the function to unbind to the signal the function to unbind to the signal
</li> </li>
<li><span class="parameter">...</span> </ul>
<span class="types"><span class="type">function,...</span></span>
other function to unbind to the signal
</dd>
<dt>
<a name = "SignalRegistry:unbindPattern"></a>
<strong>SignalRegistry:unbindPattern (pat, fn)</strong>
</dt>
<dd>
Unbind a function from every signal whose name match the pattern.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pat</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Lua pattern string
</li>
<li><span class="parameter">fn</span>
<span class="types"><span class="type">function</span></span>
the function to unbind to the signals
</li> </li>
</ul> </ul>
@ -304,8 +473,8 @@
</dd> </dd>
<dt> <dt>
<a name = "SignalRegistry:unbindAll"></a> <a name = "SignalRegistry:clear"></a>
<strong>SignalRegistry:unbindAll (name)</strong> <strong>SignalRegistry:clear (name)</strong>
</dt> </dt>
<dd> <dd>
Remove every bound function to a signal name. Remove every bound function to a signal name.
@ -329,11 +498,11 @@
</dd> </dd>
<dt> <dt>
<a name = "SignalRegistry:replace"></a> <a name = "SignalRegistry:clearPattern"></a>
<strong>SignalRegistry:replace (name, sourceFn, destFn)</strong> <strong>SignalRegistry:clearPattern (pat)</strong>
</dt> </dt>
<dd> <dd>
Replace a bound function with another function. Remove every bound function to every signal whose name match the pattern.
</ul> </ul>
</ul> </ul>
@ -342,17 +511,9 @@
<h3>Parameters:</h3> <h3>Parameters:</h3>
<ul> <ul>
<li><span class="parameter">name</span> <li><span class="parameter">pat</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span> <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal Lua string pattern
</li>
<li><span class="parameter">sourceFn</span>
<span class="types"><span class="type">function</span></span>
the function currently bound to the signal
</li>
<li><span class="parameter">destFn</span>
<span class="types"><span class="type">function</span></span>
the function that will replace the previous one
</li> </li>
</ul> </ul>
@ -360,24 +521,6 @@
</dd>
<dt>
<a name = "SignalRegistry:clear"></a>
<strong>SignalRegistry:clear ()</strong>
</dt>
<dd>
Remove every bound function to every signal.
</ul>
</ul>
</ul>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "SignalRegistry:emit"></a> <a name = "SignalRegistry:emit"></a>
@ -406,6 +549,237 @@
</dd>
<dt>
<a name = "SignalRegistry:emitPattern"></a>
<strong>SignalRegistry:emitPattern (pat, ...)</strong>
</dt>
<dd>
Emit to every signal whose name match the pattern.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pat</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Lua pattern string
</li>
<li><span class="parameter">...</span>
arguments to pass to the functions bound to each signal
</li>
</ul>
</dd>
<dt>
<a name = "SignalRegistry:chain"></a>
<strong>SignalRegistry:chain (registry)</strong>
</dt>
<dd>
Chain another regsitry to this registry.
I.e., after an event is emitted in this registry it will be automatically emitted in the other registry.
Several registries can be chained to a single registry.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">registry</span>
<span class="types"><a class="type" href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "SignalRegistry:unchain"></a>
<strong>SignalRegistry:unchain (registry)</strong>
</dt>
<dd>
Unchain a specific registry from the registry chaining list.
Will error if the regsitry is not in the chaining list.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">registry</span>
<span class="types"><a class="type" href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a></span>
</li>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="SignalGroup_objects"></a>SignalGroup objects </h2>
<div class="section-description">
Signal group. </p>
<p> A SignalGroup is a list of (registry, signal name, function) triplets.
When the group is active, all of these triplets will bind the specified signal name to the specified function in the specified registry.
When the group is paused, all of these triplets are unbound.</p>
<p> This can be used to maintain a list of signal bindings where every one should be either disabled or enabled at the same time.
For example you may maintain a signal group of signals you want to be emitted when your game is running, and disabled when the game is paused
(like inputs, update, simulation step, etc. signals).
</div>
<dl class="function">
<dt>
<a name = "SignalGroup.paused"></a>
<strong>SignalGroup.paused</strong>
</dt>
<dd>
Indicate if the signal group if currently paused or not.
</ul>
<h3>Type:</h3>
<ul>
<code>boolean</code>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalGroup.binds"></a>
<strong>SignalGroup.binds</strong>
</dt>
<dd>
List of triplets in the group.
</ul>
<h3>Type:</h3>
<ul>
<code>{</code> {registry, "signal name", function}, ... }
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalGroup:bind"></a>
<strong>SignalGroup:bind (registry, name, fn)</strong>
</dt>
<dd>
Bind a function to a signal name in the given registry.
This handles binding the function on its own; you do not need to call <a href="../modules/signal.html#SignalRegistry:bind">SignalRegistry:bind</a> manually.
If the group is paused, this will not bind the function immediately but only on the next time this group is resumed (as expected).
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">registry</span>
<span class="types"><a class="type" href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a></span>
to bind the signal in
</li>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li>
<li><span class="parameter">fn</span>
<span class="types"><span class="type">function</span></span>
the function to bind to the signal
</li>
</ul>
</dd>
<dt>
<a name = "SignalGroup:clear"></a>
<strong>SignalGroup:clear ()</strong>
</dt>
<dd>
Remove every bound triplet in the group.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalGroup:pause"></a>
<strong>SignalGroup:pause ()</strong>
</dt>
<dd>
Pause the group.
The signals bound to this group will be disabled in their given registries.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalGroup:resume"></a>
<strong>SignalGroup:resume ()</strong>
</dt>
<dd>
Resume the group.
The signals bound to this group will be enabled in their given registries.
</ul>
</ul>
</ul>
</ul>
</dd> </dd>
</dl> </dl>
@ -414,7 +788,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -45,6 +45,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li> <li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li> <li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li> <li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li> <li><a href="../modules/scene.html">scene</a></li>
<li><a href="../modules/signal.html">signal</a></li> <li><a href="../modules/signal.html">signal</a></li>
@ -1153,7 +1154,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -42,6 +42,7 @@
<li><strong>ubiquitousse</strong></li> <li><strong>ubiquitousse</strong></li>
<li><a href="../modules/asset.html">asset</a></li> <li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li> <li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li> <li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li> <li><a href="../modules/scene.html">scene</a></li>
<li><a href="../modules/signal.html">signal</a></li> <li><a href="../modules/signal.html">signal</a></li>
@ -141,6 +142,10 @@ the repository to save you a few seconds.</p>
<td class="summary">LDtk level import, if available.</td> <td class="summary">LDtk level import, if available.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#gltf">gltf</a></td>
<td class="summary">glTF model import, if available.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#scene">scene</a></td> <td class="name" nowrap><a href="#scene">scene</a></td>
<td class="summary">Scene management, if available.</td> <td class="summary">Scene management, if available.</td>
</tr> </tr>
@ -233,7 +238,7 @@ the repository to save you a few seconds.</p>
</dt> </dt>
<dd> <dd>
Input management, if available. Input management, if available.
TODO: not currently generated with LDoc. TODO: documentation not currently generated with LDoc.
</ul> </ul>
</ul> </ul>
@ -245,7 +250,7 @@ the repository to save you a few seconds.</p>
<h3>See also:</h3> <h3>See also:</h3>
<ul> <ul>
<a href="../modules/ubiquitousse.html#input">input</a> <a href="../modules/input.html#">input</a>
</ul> </ul>
@ -271,6 +276,29 @@ the repository to save you a few seconds.</p>
</ul> </ul>
</dd>
<dt>
<a name = "gltf"></a>
<strong>gltf</strong>
</dt>
<dd>
glTF model import, if available.
TODO: documentation not currently generated with LDoc.
</ul>
</ul>
</ul>
</ul>
<h3>See also:</h3>
<ul>
<a href="../modules/ubiquitousse.html#gltf">gltf</a>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "scene"></a> <a name = "scene"></a>
@ -367,7 +395,7 @@ the repository to save you a few seconds.</p>
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -42,6 +42,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li> <li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li> <li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li> <li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li> <li><a href="../modules/scene.html">scene</a></li>
<li><a href="../modules/signal.html">signal</a></li> <li><a href="../modules/signal.html">signal</a></li>
@ -784,7 +785,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -43,6 +43,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li> <li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li> <li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li> <li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li> <li><a href="../modules/scene.html">scene</a></li>
<li><a href="../modules/signal.html">signal</a></li> <li><a href="../modules/signal.html">signal</a></li>
@ -54,7 +55,7 @@
<div id="content"> <div id="content">
Copyright 2021 Étienne &ldquo;Reuh&rdquo; Fildadut</p> Copyright 2016-2022 Étienne &ldquo;Reuh&rdquo; Fildadut</p>
<p>Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.</p> <p>Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.</p>
@ -64,7 +65,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -43,6 +43,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li> <li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li> <li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li> <li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li> <li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li> <li><a href="../modules/scene.html">scene</a></li>
<li><a href="../modules/signal.html">signal</a></li> <li><a href="../modules/signal.html">signal</a></li>
@ -56,7 +57,22 @@
<h1>ubiquitousse</h1> <h1>ubiquitousse</h1>
<p>Set of various libraries I use for game development, mainly with LÖVE. Nothing that hasn&rsquo;t been done before, but these are tailored to what I need. They can be used independently too.</p> <p>Set of various libraries I use for game development, mainly with LÖVE. Most of which has already been done before, but these are tailored to what I need. They can be used independently too (you should be able to only pick the directories of the libraries you need; some modules depends on each other though, see documentation for details).</p>
<p>This provides, sorting the one with the fewest existing alterative as far as I know first:</p>
<ul>
<li><a href="../modules/ldtk.html#">ldtk</a> provides a <a href="https://ldtk.io/">LDtk</a> level importer</li>
<li><code>gltf</code> provides a <a href="https://www.khronos.org/gltf/">glTF</a> model loader</li>
<li><a href="../modules/ecs.html#">ecs</a> provides <a href="https://en.wikipedia.org/wiki/Entity_component_system">ECS</a> facilities</li>
<li><a href="../modules/input.html#">input</a> provides input management facilities</li>
<li><a href="../modules/timer.html#">timer</a> provides time management facilities</li>
<li><a href="../modules/signal.html#">signal</a> provides a simple signal / observer pattern implementation</li>
<li><a href="../modules/asset.html#">asset</a> provides barebones asset loading facilities</li>
<li><a href="../modules/scene.html#">scene</a> provides some scene management facilities</li>
<li><a href="../modules/util.html#">util</a> provides some random, occasionally useful functions</li>
</ul>
<p>You can find the documentation <a href="https://reuh.github.io/ubiquitousse/index.html">here</a> or in the <code>docs/</code> directory.</p> <p>You can find the documentation <a href="https://reuh.github.io/ubiquitousse/index.html">here</a> or in the <code>docs/</code> directory.</p>
@ -64,14 +80,14 @@
<p>Whatever is currently on the master branch should be working and usable. Changelog, including breaking changes, are documented in commit messages.</p> <p>Whatever is currently on the master branch should be working and usable. Changelog, including breaking changes, are documented in commit messages.</p>
<p>Licensed under ISC (equivalent to MIT/Expat/Simplified BSD).</p> <p>Licensed under ISC (equivalent to MIT/Expat/Simplified BSD). Have fun.</p>
</div> <!-- id="content" --> </div> <!-- id="content" -->
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i> <i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -289,206 +289,229 @@ end, -- ./ecs/ecs.can:604
["iter"] = function(self) -- ./ecs/ecs.can:609 ["iter"] = function(self) -- ./ecs/ecs.can:609
return nextEntity, { self["_first"] } -- ./ecs/ecs.can:610 return nextEntity, { self["_first"] } -- ./ecs/ecs.can:610
end, -- ./ecs/ecs.can:610 end, -- ./ecs/ecs.can:610
["clear"] = function(self) -- ./ecs/ecs.can:613 ["get"] = function(self, i) -- ./ecs/ecs.can:617
for e in self:iter() do -- ./ecs/ecs.can:614 local n = 1 -- ./ecs/ecs.can:618
self:remove(e) -- ./ecs/ecs.can:615 for e in self:iter() do -- ./ecs/ecs.can:619
end -- ./ecs/ecs.can:615 if n == i then -- ./ecs/ecs.can:620
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:617 return e -- ./ecs/ecs.can:621
s:clear() -- ./ecs/ecs.can:618 end -- ./ecs/ecs.can:621
end -- ./ecs/ecs.can:618 n = n + (1) -- ./ecs/ecs.can:623
end, -- ./ecs/ecs.can:618 end -- ./ecs/ecs.can:623
["update"] = function(self, dt) -- ./ecs/ecs.can:625 return nil -- ./ecs/ecs.can:625
if self["active"] then -- ./ecs/ecs.can:626 end, -- ./ecs/ecs.can:625
if self["interval"] then -- ./ecs/ecs.can:627 ["clear"] = function(self) -- ./ecs/ecs.can:628
self["_waited"] = self["_waited"] + (dt) -- ./ecs/ecs.can:628 for e in self:iter() do -- ./ecs/ecs.can:629
if self["_waited"] < self["interval"] then -- ./ecs/ecs.can:629 self:remove(e) -- ./ecs/ecs.can:630
return -- ./ecs/ecs.can:630
end -- ./ecs/ecs.can:630 end -- ./ecs/ecs.can:630
end -- ./ecs/ecs.can:630 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:632
self:onUpdate(dt) -- ./ecs/ecs.can:633 s:clear() -- ./ecs/ecs.can:633
if self["process"] ~= system_mt["process"] then -- ./ecs/ecs.can:634 end -- ./ecs/ecs.can:633
for e in self:iter() do -- ./ecs/ecs.can:635 end, -- ./ecs/ecs.can:633
self:process(e, e[self["component"]], dt) -- ./ecs/ecs.can:636 ["update"] = function(self, dt) -- ./ecs/ecs.can:640
end -- ./ecs/ecs.can:636 if self["active"] then -- ./ecs/ecs.can:641
end -- ./ecs/ecs.can:636 if self["interval"] then -- ./ecs/ecs.can:642
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:639 self["_waited"] = self["_waited"] + (dt) -- ./ecs/ecs.can:643
s:update(dt) -- ./ecs/ecs.can:640 if self["_waited"] < self["interval"] then -- ./ecs/ecs.can:644
end -- ./ecs/ecs.can:640 return -- ./ecs/ecs.can:645
self:onUpdateEnd(dt) -- ./ecs/ecs.can:642 end -- ./ecs/ecs.can:645
if self["interval"] then -- ./ecs/ecs.can:643 end -- ./ecs/ecs.can:645
self["_waited"] = self["_waited"] - (self["interval"]) -- ./ecs/ecs.can:644 self:onUpdate(dt) -- ./ecs/ecs.can:648
end -- ./ecs/ecs.can:644 if self["process"] ~= system_mt["process"] then -- ./ecs/ecs.can:649
end -- ./ecs/ecs.can:644 for e in self:iter() do -- ./ecs/ecs.can:650
end, -- ./ecs/ecs.can:644 self:process(e, e[self["component"]], dt) -- ./ecs/ecs.can:651
["draw"] = function(self) -- ./ecs/ecs.can:651 end -- ./ecs/ecs.can:651
if self["visible"] then -- ./ecs/ecs.can:652 end -- ./ecs/ecs.can:651
self:onDraw() -- ./ecs/ecs.can:653 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:654
if self["render"] ~= system_mt["render"] then -- ./ecs/ecs.can:654 s:update(dt) -- ./ecs/ecs.can:655
for e in self:iter() do -- ./ecs/ecs.can:655 end -- ./ecs/ecs.can:655
self:render(e, e[self["component"]]) -- ./ecs/ecs.can:656 self:onUpdateEnd(dt) -- ./ecs/ecs.can:657
end -- ./ecs/ecs.can:656 if self["interval"] then -- ./ecs/ecs.can:658
end -- ./ecs/ecs.can:656 self["_waited"] = self["_waited"] - (self["interval"]) -- ./ecs/ecs.can:659
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:659 end -- ./ecs/ecs.can:659
s:draw() -- ./ecs/ecs.can:660 end -- ./ecs/ecs.can:659
end -- ./ecs/ecs.can:660 end, -- ./ecs/ecs.can:659
self:onDrawEnd() -- ./ecs/ecs.can:662 ["draw"] = function(self) -- ./ecs/ecs.can:666
end -- ./ecs/ecs.can:662 if self["visible"] then -- ./ecs/ecs.can:667
end, -- ./ecs/ecs.can:662 self:onDraw() -- ./ecs/ecs.can:668
["callback"] = function(self, name, e, ...) -- ./ecs/ecs.can:675 if self["render"] ~= system_mt["render"] then -- ./ecs/ecs.can:669
if self["_previous"][e] and self[name] then -- ./ecs/ecs.can:677 for e in self:iter() do -- ./ecs/ecs.can:670
self[name](self, e, e[self["component"]], ...) -- ./ecs/ecs.can:678 self:render(e, e[self["component"]]) -- ./ecs/ecs.can:671
end -- ./ecs/ecs.can:678 end -- ./ecs/ecs.can:671
if self["_previous"][e] then -- ./ecs/ecs.can:681 end -- ./ecs/ecs.can:671
for _, ss in ipairs(self["systems"]) do -- ./ecs/ecs.can:682 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:674
ss:callback(name, e, ...) -- ./ecs/ecs.can:683 s:draw() -- ./ecs/ecs.can:675
end -- ./ecs/ecs.can:683 end -- ./ecs/ecs.can:675
end -- ./ecs/ecs.can:683 self:onDrawEnd() -- ./ecs/ecs.can:677
end, -- ./ecs/ecs.can:683 end -- ./ecs/ecs.can:677
["emit"] = function(self, name, ...) -- ./ecs/ecs.can:708 end, -- ./ecs/ecs.can:677
local status -- ./ecs/ecs.can:710 ["callback"] = function(self, name, e, ...) -- ./ecs/ecs.can:690
if self[name] then -- ./ecs/ecs.can:711 if self["_previous"][e] and self[name] then -- ./ecs/ecs.can:692
status = self[name](self, ...) -- ./ecs/ecs.can:712 self[name](self, e, e[self["component"]], ...) -- ./ecs/ecs.can:693
end -- ./ecs/ecs.can:712 end -- ./ecs/ecs.can:693
if status ~= "stop" and status ~= "capture" then -- ./ecs/ecs.can:715 if self["_previous"][e] then -- ./ecs/ecs.can:696
for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:716 for _, ss in ipairs(self["systems"]) do -- ./ecs/ecs.can:697
status = s:emit(name, ...) -- ./ecs/ecs.can:717 ss:callback(name, e, ...) -- ./ecs/ecs.can:698
if status == "capture" then -- ./ecs/ecs.can:718 end -- ./ecs/ecs.can:698
break -- ./ecs/ecs.can:718 end -- ./ecs/ecs.can:698
end -- ./ecs/ecs.can:718 end, -- ./ecs/ecs.can:698
end -- ./ecs/ecs.can:718 ["emit"] = function(self, name, ...) -- ./ecs/ecs.can:723
end -- ./ecs/ecs.can:718 local status -- ./ecs/ecs.can:725
return status -- ./ecs/ecs.can:721 if self[name] then -- ./ecs/ecs.can:726
end, -- ./ecs/ecs.can:721 status = self[name](self, ...) -- ./ecs/ecs.can:727
["destroy"] = function(self) -- ./ecs/ecs.can:724 end -- ./ecs/ecs.can:727
recCallOnRemoveFromWorld(self["world"], { self }) -- ./ecs/ecs.can:725 if status ~= "stop" and status ~= "capture" then -- ./ecs/ecs.can:730
recDestroySystems({ ["systems"] = { self } }) -- ./ecs/ecs.can:726 for _, s in ipairs(self["systems"]) do -- ./ecs/ecs.can:731
end -- ./ecs/ecs.can:726 status = s:emit(name, ...) -- ./ecs/ecs.can:732
} -- ./ecs/ecs.can:726 if status == "capture" then -- ./ecs/ecs.can:733
local alwaysTrue -- ./ecs/ecs.can:731 break -- ./ecs/ecs.can:733
alwaysTrue = function() -- ./ecs/ecs.can:731 end -- ./ecs/ecs.can:733
return true -- ./ecs/ecs.can:731 end -- ./ecs/ecs.can:733
end -- ./ecs/ecs.can:731 end -- ./ecs/ecs.can:733
local alwaysFalse -- ./ecs/ecs.can:732 return status -- ./ecs/ecs.can:736
alwaysFalse = function() -- ./ecs/ecs.can:732 end, -- ./ecs/ecs.can:736
return false -- ./ecs/ecs.can:732 ["destroy"] = function(self) -- ./ecs/ecs.can:739
end -- ./ecs/ecs.can:732 recCallOnRemoveFromWorld(self["world"], { self }) -- ./ecs/ecs.can:740
local recInstanciateSystems -- ./ecs/ecs.can:737 recDestroySystems({ ["systems"] = { self } }) -- ./ecs/ecs.can:741
recInstanciateSystems = function(world, systems) -- ./ecs/ecs.can:737 end -- ./ecs/ecs.can:741
local t -- ./ecs/ecs.can:738 } -- ./ecs/ecs.can:741
t = {} -- ./ecs/ecs.can:738 local alwaysTrue -- ./ecs/ecs.can:746
for _, s in ipairs(systems) do -- ./ecs/ecs.can:739 alwaysTrue = function() -- ./ecs/ecs.can:746
local system -- ./ecs/ecs.can:740 return true -- ./ecs/ecs.can:746
system = setmetatable({ -- ./ecs/ecs.can:742 end -- ./ecs/ecs.can:746
["systems"] = recInstanciateSystems(world, s["systems"] or {}), -- ./ecs/ecs.can:743 local alwaysFalse -- ./ecs/ecs.can:747
["world"] = world, -- ./ecs/ecs.can:744 alwaysFalse = function() -- ./ecs/ecs.can:747
["w"] = world, -- ./ecs/ecs.can:745 return false -- ./ecs/ecs.can:747
["s"] = world["s"], -- ./ecs/ecs.can:746 end -- ./ecs/ecs.can:747
["_previous"] = {} -- ./ecs/ecs.can:747 local recInstanciateSystems -- ./ecs/ecs.can:752
}, { ["__index"] = function(self, k) -- ./ecs/ecs.can:749 recInstanciateSystems = function(world, systems) -- ./ecs/ecs.can:752
if s[k] ~= nil then -- ./ecs/ecs.can:750 local t -- ./ecs/ecs.can:753
return s[k] -- ./ecs/ecs.can:751 t = {} -- ./ecs/ecs.can:753
else -- ./ecs/ecs.can:751 for _, s in ipairs(systems) do -- ./ecs/ecs.can:754
return system_mt[k] -- ./ecs/ecs.can:753 local system -- ./ecs/ecs.can:755
end -- ./ecs/ecs.can:753 system = setmetatable({ -- ./ecs/ecs.can:757
end }) -- ./ecs/ecs.can:753 ["systems"] = recInstanciateSystems(world, s["systems"] or {}), -- ./ecs/ecs.can:758
if type(s["filter"]) == "string" then -- ./ecs/ecs.can:758 ["world"] = world, -- ./ecs/ecs.can:759
system["filter"] = function(_, e) -- ./ecs/ecs.can:759 ["w"] = world, -- ./ecs/ecs.can:760
return e[s["filter"]] ~= nil -- ./ecs/ecs.can:759 ["s"] = world["s"], -- ./ecs/ecs.can:761
end -- ./ecs/ecs.can:759 ["_previous"] = {} -- ./ecs/ecs.can:762
elseif type(s["filter"]) == "table" then -- ./ecs/ecs.can:760 }, { ["__index"] = function(self, k) -- ./ecs/ecs.can:764
system["filter"] = ecs["all"](unpack(s["filter"])) -- ./ecs/ecs.can:761 if s[k] ~= nil then -- ./ecs/ecs.can:765
elseif type(s["filter"]) == "boolean" then -- ./ecs/ecs.can:762 return s[k] -- ./ecs/ecs.can:766
if s["filter"] then -- ./ecs/ecs.can:763 else -- ./ecs/ecs.can:766
system["filter"] = alwaysTrue -- ./ecs/ecs.can:764 return system_mt[k] -- ./ecs/ecs.can:768
else -- ./ecs/ecs.can:764 end -- ./ecs/ecs.can:768
system["filter"] = alwaysFalse -- ./ecs/ecs.can:766 end }) -- ./ecs/ecs.can:768
end -- ./ecs/ecs.can:766 if type(s["filter"]) == "string" then -- ./ecs/ecs.can:773
end -- ./ecs/ecs.can:766 system["filter"] = function(_, e) -- ./ecs/ecs.can:774
if not s["component"] and s["name"] then -- ./ecs/ecs.can:770 return e[s["filter"]] ~= nil -- ./ecs/ecs.can:774
s["component"] = s["name"] -- ./ecs/ecs.can:771 end -- ./ecs/ecs.can:774
end -- ./ecs/ecs.can:771 elseif type(s["filter"]) == "table" then -- ./ecs/ecs.can:775
table["insert"](t, system) -- ./ecs/ecs.can:774 system["filter"] = ecs["all"](unpack(s["filter"])) -- ./ecs/ecs.can:776
if s["name"] then -- ./ecs/ecs.can:775 elseif type(s["filter"]) == "boolean" then -- ./ecs/ecs.can:777
world["s"][s["name"]] = system -- ./ecs/ecs.can:776 if s["filter"] then -- ./ecs/ecs.can:778
end -- ./ecs/ecs.can:776 system["filter"] = alwaysTrue -- ./ecs/ecs.can:779
system:onInstance() -- ./ecs/ecs.can:778 else -- ./ecs/ecs.can:779
end -- ./ecs/ecs.can:778 system["filter"] = alwaysFalse -- ./ecs/ecs.can:781
return t -- ./ecs/ecs.can:780 end -- ./ecs/ecs.can:781
end -- ./ecs/ecs.can:780 end -- ./ecs/ecs.can:781
local recCallOnAddToWorld -- ./ecs/ecs.can:783 if not s["component"] and s["name"] then -- ./ecs/ecs.can:785
recCallOnAddToWorld = function(world, systems) -- ./ecs/ecs.can:783 s["component"] = s["name"] -- ./ecs/ecs.can:786
for _, s in ipairs(systems) do -- ./ecs/ecs.can:784
recCallOnAddToWorld(world, s["systems"]) -- ./ecs/ecs.can:785
s:onAddToWorld(world) -- ./ecs/ecs.can:786
end -- ./ecs/ecs.can:786 end -- ./ecs/ecs.can:786
end -- ./ecs/ecs.can:786 table["insert"](t, system) -- ./ecs/ecs.can:789
ecs = { -- ./ecs/ecs.can:792 if s["name"] then -- ./ecs/ecs.can:790
["world"] = function(...) -- ./ecs/ecs.can:797 world["s"][s["name"]] = system -- ./ecs/ecs.can:791
local world -- ./ecs/ecs.can:798 end -- ./ecs/ecs.can:791
world = setmetatable({ -- ./ecs/ecs.can:798 system:onInstance() -- ./ecs/ecs.can:793
["filter"] = ecs["all"](), -- ./ecs/ecs.can:799 end -- ./ecs/ecs.can:793
["s"] = {}, -- ./ecs/ecs.can:800 return t -- ./ecs/ecs.can:795
["_previous"] = {} -- ./ecs/ecs.can:801 end -- ./ecs/ecs.can:795
}, { ["__index"] = system_mt }) -- ./ecs/ecs.can:802 local recCallOnAddToWorld -- ./ecs/ecs.can:798
world["world"] = world -- ./ecs/ecs.can:803 recCallOnAddToWorld = function(world, systems) -- ./ecs/ecs.can:798
world["w"] = world -- ./ecs/ecs.can:804 for _, s in ipairs(systems) do -- ./ecs/ecs.can:799
world["systems"] = recInstanciateSystems(world, { ... }) -- ./ecs/ecs.can:805 recCallOnAddToWorld(world, s["systems"]) -- ./ecs/ecs.can:800
recCallOnAddToWorld(world, world["systems"]) -- ./ecs/ecs.can:806 s:onAddToWorld(world) -- ./ecs/ecs.can:801
return world -- ./ecs/ecs.can:807 end -- ./ecs/ecs.can:801
end, -- ./ecs/ecs.can:807 end -- ./ecs/ecs.can:801
["all"] = function(...) -- ./ecs/ecs.can:813 ecs = { -- ./ecs/ecs.can:807
if ... then -- ./ecs/ecs.can:814 ["world"] = function(...) -- ./ecs/ecs.can:812
local l -- ./ecs/ecs.can:815 local world -- ./ecs/ecs.can:813
l = { ... } -- ./ecs/ecs.can:815 world = setmetatable({ -- ./ecs/ecs.can:813
return function(s, e) -- ./ecs/ecs.can:816 ["filter"] = ecs["all"](), -- ./ecs/ecs.can:814
for _, k in ipairs(l) do -- ./ecs/ecs.can:817 ["s"] = {}, -- ./ecs/ecs.can:815
if e[k] == nil then -- ./ecs/ecs.can:818 ["_previous"] = {} -- ./ecs/ecs.can:816
return false -- ./ecs/ecs.can:819 }, { ["__index"] = system_mt }) -- ./ecs/ecs.can:817
end -- ./ecs/ecs.can:819 world["world"] = world -- ./ecs/ecs.can:818
end -- ./ecs/ecs.can:819 world["w"] = world -- ./ecs/ecs.can:819
return true -- ./ecs/ecs.can:822 world["systems"] = recInstanciateSystems(world, { ... }) -- ./ecs/ecs.can:820
end -- ./ecs/ecs.can:822 recCallOnAddToWorld(world, world["systems"]) -- ./ecs/ecs.can:821
else -- ./ecs/ecs.can:822 return world -- ./ecs/ecs.can:822
return alwaysTrue -- ./ecs/ecs.can:825 end, -- ./ecs/ecs.can:822
end -- ./ecs/ecs.can:825 ["all"] = function(...) -- ./ecs/ecs.can:828
end, -- ./ecs/ecs.can:825 if ... then -- ./ecs/ecs.can:829
["any"] = function(...) -- ./ecs/ecs.can:832 local l -- ./ecs/ecs.can:830
if ... then -- ./ecs/ecs.can:833 l = { ... } -- ./ecs/ecs.can:830
local l -- ./ecs/ecs.can:834 return function(s, e) -- ./ecs/ecs.can:831
l = { ... } -- ./ecs/ecs.can:834 for _, k in ipairs(l) do -- ./ecs/ecs.can:832
return function(s, e) -- ./ecs/ecs.can:835 if e[k] == nil then -- ./ecs/ecs.can:833
for _, k in ipairs(l) do -- ./ecs/ecs.can:836 return false -- ./ecs/ecs.can:834
if e[k] ~= nil then -- ./ecs/ecs.can:837 end -- ./ecs/ecs.can:834
return true -- ./ecs/ecs.can:838 end -- ./ecs/ecs.can:834
end -- ./ecs/ecs.can:838 return true -- ./ecs/ecs.can:837
end -- ./ecs/ecs.can:838 end -- ./ecs/ecs.can:837
return false -- ./ecs/ecs.can:841 else -- ./ecs/ecs.can:837
end -- ./ecs/ecs.can:841 return alwaysTrue -- ./ecs/ecs.can:840
else -- ./ecs/ecs.can:841 end -- ./ecs/ecs.can:840
return alwaysFalse -- ./ecs/ecs.can:844 end, -- ./ecs/ecs.can:840
end -- ./ecs/ecs.can:844 ["any"] = function(...) -- ./ecs/ecs.can:847
end, -- ./ecs/ecs.can:844 if ... then -- ./ecs/ecs.can:848
["scene"] = function(name, systems, entities) -- ./ecs/ecs.can:854 local l -- ./ecs/ecs.can:849
if systems == nil then systems = {} end -- ./ecs/ecs.can:854 l = { ... } -- ./ecs/ecs.can:849
if entities == nil then entities = {} end -- ./ecs/ecs.can:854 return function(s, e) -- ./ecs/ecs.can:850
assert(scene, "ubiquitousse.scene unavailable") -- ./ecs/ecs.can:855 for _, k in ipairs(l) do -- ./ecs/ecs.can:851
local s -- ./ecs/ecs.can:856 if e[k] ~= nil then -- ./ecs/ecs.can:852
s = scene["new"](name) -- ./ecs/ecs.can:856 return true -- ./ecs/ecs.can:853
local w -- ./ecs/ecs.can:857 end -- ./ecs/ecs.can:853
s["enter"] = function(self) -- ./ecs/ecs.can:859 end -- ./ecs/ecs.can:853
w = ecs["world"](unpack(systems)) -- ./ecs/ecs.can:860 return false -- ./ecs/ecs.can:856
w:add(unpack(entities)) -- ./ecs/ecs.can:861 end -- ./ecs/ecs.can:856
end -- ./ecs/ecs.can:861 else -- ./ecs/ecs.can:856
s["exit"] = function(self) -- ./ecs/ecs.can:863 return alwaysFalse -- ./ecs/ecs.can:859
w:destroy() -- ./ecs/ecs.can:864 end -- ./ecs/ecs.can:859
end -- ./ecs/ecs.can:864 end, -- ./ecs/ecs.can:859
s["update"] = function(self, dt) -- ./ecs/ecs.can:866 ["scene"] = function(name, systems, entities) -- ./ecs/ecs.can:877
w:update(dt) -- ./ecs/ecs.can:867 if systems == nil then systems = {} end -- ./ecs/ecs.can:877
end -- ./ecs/ecs.can:867 if entities == nil then entities = {} end -- ./ecs/ecs.can:877
s["draw"] = function(self) -- ./ecs/ecs.can:869 assert(scene, "ubiquitousse.scene unavailable") -- ./ecs/ecs.can:878
w:draw() -- ./ecs/ecs.can:870 local s -- ./ecs/ecs.can:879
end -- ./ecs/ecs.can:870 s = scene["new"](name) -- ./ecs/ecs.can:879
return s -- ./ecs/ecs.can:873 local w -- ./ecs/ecs.can:880
end -- ./ecs/ecs.can:873 s["enter"] = function(self) -- ./ecs/ecs.can:882
} -- ./ecs/ecs.can:873 local sys, ent = systems, entities -- ./ecs/ecs.can:883
return ecs -- ./ecs/ecs.can:877 if type(systems) == "function" then -- ./ecs/ecs.can:884
sys = { systems() } -- ./ecs/ecs.can:884
end -- ./ecs/ecs.can:884
if type(entities) == "function" then -- ./ecs/ecs.can:885
ent = { entities() } -- ./ecs/ecs.can:885
end -- ./ecs/ecs.can:885
w = ecs["world"](unpack(sys)) -- ./ecs/ecs.can:886
w:add(unpack(ent)) -- ./ecs/ecs.can:887
end -- ./ecs/ecs.can:887
s["exit"] = function(self) -- ./ecs/ecs.can:889
w:destroy() -- ./ecs/ecs.can:890
end -- ./ecs/ecs.can:890
s["suspend"] = function(self) -- ./ecs/ecs.can:892
w:emit("onSuspend") -- ./ecs/ecs.can:893
end -- ./ecs/ecs.can:893
s["resume"] = function(self) -- ./ecs/ecs.can:895
w:emit("onResume") -- ./ecs/ecs.can:896
end -- ./ecs/ecs.can:896
s["update"] = function(self, dt) -- ./ecs/ecs.can:898
w:update(dt) -- ./ecs/ecs.can:899
end -- ./ecs/ecs.can:899
s["draw"] = function(self) -- ./ecs/ecs.can:901
w:draw() -- ./ecs/ecs.can:902
end -- ./ecs/ecs.can:902
return s -- ./ecs/ecs.can:905
end -- ./ecs/ecs.can:905
} -- ./ecs/ecs.can:905
return ecs -- ./ecs/ecs.can:909

84
gltf/draw.lua Normal file
View file

@ -0,0 +1,84 @@
local whiteTexture -- ./gltf/draw.can:4
whiteTexture = love["graphics"]["newCanvas"](2, 2) -- ./gltf/draw.can:4
whiteTexture:renderTo(function() -- ./gltf/draw.can:5
love["graphics"]["setColor"](1, 1, 1) -- ./gltf/draw.can:6
love["graphics"]["rectangle"]("fill", 0, 0, 2, 2) -- ./gltf/draw.can:7
end) -- ./gltf/draw.can:7
local maybeSend -- ./gltf/draw.can:11
maybeSend = function(s, name, val) -- ./gltf/draw.can:11
if s:hasUniform(name) then -- ./gltf/draw.can:12
s:send(name, val) -- ./gltf/draw.can:13
end -- ./gltf/draw.can:13
end -- ./gltf/draw.can:13
local maybeSendTexture -- ./gltf/draw.can:16
maybeSendTexture = function(s, name, tex) -- ./gltf/draw.can:16
if s:hasUniform(name) then -- ./gltf/draw.can:17
if tex then -- ./gltf/draw.can:18
s:send(name, tex["index"]["image"]) -- ./gltf/draw.can:19
else -- ./gltf/draw.can:19
s:send(name, whiteTexture) -- ./gltf/draw.can:21
end -- ./gltf/draw.can:21
end -- ./gltf/draw.can:21
end -- ./gltf/draw.can:21
local applyMaterial -- ./gltf/draw.can:27
applyMaterial = function(s, mat) -- ./gltf/draw.can:27
maybeSend(s, "baseColorFactor", mat["pbrMetallicRoughness"]["baseColorFactor"]) -- ./gltf/draw.can:28
maybeSendTexture(s, "baseColorTexture", mat["pbrMetallicRoughness"]["baseColorTexture"]) -- ./gltf/draw.can:29
maybeSend(s, "metallicFactor", mat["pbrMetallicRoughness"]["metallicFactor"]) -- ./gltf/draw.can:30
maybeSend(s, "roughnessFactor", mat["pbrMetallicRoughness"]["roughnessFactor"]) -- ./gltf/draw.can:31
maybeSendTexture(s, "metallicRoughnessTexture", mat["pbrMetallicRoughness"]["metallicRoughnessTexture"]) -- ./gltf/draw.can:32
maybeSendTexture(s, "normalTexture", mat["normalTexture"]) -- ./gltf/draw.can:33
maybeSendTexture(s, "occlusionTexture", mat["occlusionTexture"]) -- ./gltf/draw.can:34
if mat["occlusionTexture"] then -- ./gltf/draw.can:35
maybeSend(s, "occlusionTextureStrength", mat["occlusionTexture"]["strength"]) -- ./gltf/draw.can:36
else -- ./gltf/draw.can:36
maybeSend(s, "occlusionTextureStrength", 1) -- ./gltf/draw.can:38
end -- ./gltf/draw.can:38
maybeSendTexture(s, "emissiveTexture", mat["emissiveTexture"]) -- ./gltf/draw.can:40
if mat["emissiveTexture"] then -- ./gltf/draw.can:41
maybeSend(s, "emissiveTextureScale", mat["emissiveTexture"]["scale"]) -- ./gltf/draw.can:42
else -- ./gltf/draw.can:42
maybeSend(s, "emissiveTextureScale", 1) -- ./gltf/draw.can:44
end -- ./gltf/draw.can:44
maybeSend(s, "emissiveFactor", mat["emissiveFactor"]) -- ./gltf/draw.can:46
if mat["alphaMode"] == "BLEND" then -- ./gltf/draw.can:47
love["graphics"]["setBlendMode"]("alpha") -- ./gltf/draw.can:48
maybeSend(s, "alphaCutoff", 0) -- ./gltf/draw.can:49
else -- ./gltf/draw.can:49
love["graphics"]["setBlendMode"]("replace") -- ./gltf/draw.can:51
maybeSend(s, "alphaCutoff", mat["alphaMode"] == "BLEND" and mat["alphaCutoff"] or 0) -- ./gltf/draw.can:52
end -- ./gltf/draw.can:52
if mat["doubleSided"] then -- ./gltf/draw.can:54
love["graphics"]["setMeshCullMode"]("none") -- ./gltf/draw.can:55
else -- ./gltf/draw.can:55
love["graphics"]["setMeshCullMode"]("back") -- ./gltf/draw.can:57
end -- ./gltf/draw.can:57
end -- ./gltf/draw.can:57
local drawNode -- ./gltf/draw.can:62
drawNode = function(node, s) -- ./gltf/draw.can:62
if node["mesh"] then -- ./gltf/draw.can:63
s:send("modelMatrix", "column", node["matrix"]) -- ./gltf/draw.can:64
for _, primitive in ipairs(node["mesh"]["primitives"]) do -- ./gltf/draw.can:65
applyMaterial(s, primitive["material"]) -- ./gltf/draw.can:66
love["graphics"]["draw"](primitive["mesh"]) -- ./gltf/draw.can:67
end -- ./gltf/draw.can:67
end -- ./gltf/draw.can:67
for _, child in ipairs(node["children"]) do -- ./gltf/draw.can:70
drawNode(child, s) -- ./gltf/draw.can:71
end -- ./gltf/draw.can:71
end -- ./gltf/draw.can:71
local drawMainScene -- ./gltf/draw.can:77
drawMainScene = function(gltf, s) -- ./gltf/draw.can:77
love["graphics"]["push"]("all") -- ./gltf/draw.can:78
love["graphics"]["setDepthMode"]("lequal", true) -- ./gltf/draw.can:79
if s then -- ./gltf/draw.can:80
love["graphics"]["setShader"](s) -- ./gltf/draw.can:81
else -- ./gltf/draw.can:81
s = love["graphics"]["getShader"]() -- ./gltf/draw.can:83
end -- ./gltf/draw.can:83
for _, node in ipairs(gltf["scene"]["nodes"]) do -- ./gltf/draw.can:85
drawNode(node, s) -- ./gltf/draw.can:86
end -- ./gltf/draw.can:86
love["graphics"]["pop"]("all") -- ./gltf/draw.can:88
end -- ./gltf/draw.can:88
return drawMainScene -- ./gltf/draw.can:91

15
gltf/gltf.lua Normal file
View file

@ -0,0 +1,15 @@
local loader -- ./gltf/gltf.can:3
loader = require((...):gsub("gltf$", "loader")) -- ./gltf/gltf.can:3
local draw -- ./gltf/gltf.can:4
draw = require((...):gsub("gltf$", "draw")) -- ./gltf/gltf.can:4
local gltf_mt -- ./gltf/gltf.can:7
gltf_mt = { -- ./gltf/gltf.can:7
["gltf"] = nil, -- ./gltf/gltf.can:9
["draw"] = function(self, shader) -- ./gltf/gltf.can:12
draw(self["gltf"], shader) -- ./gltf/gltf.can:13
end -- ./gltf/gltf.can:13
} -- ./gltf/gltf.can:13
gltf_mt["__index"] = gltf_mt -- ./gltf/gltf.can:16
return function(path) -- ./gltf/gltf.can:19
return setmetatable({ ["gltf"] = loader(path) }, gltf_mt) -- ./gltf/gltf.can:22
end -- ./gltf/gltf.can:22

389
gltf/loader.lua Normal file
View file

@ -0,0 +1,389 @@
local json_decode -- ./gltf/loader.can:4
do -- ./gltf/loader.can:6
local r, json -- ./gltf/loader.can:6
r, json = pcall(require, "json") -- ./gltf/loader.can:6
if not r then -- ./gltf/loader.can:7
json = require((...):gsub("gltf%.loader$", "lib.json")) -- ./gltf/loader.can:7
end -- ./gltf/loader.can:7
json_decode = json["decode"] -- ./gltf/loader.can:8
end -- ./gltf/loader.can:8
local cpml -- ./gltf/loader.can:11
cpml = require("cpml") -- ./gltf/loader.can:11
local mat4, vec3, quat -- ./gltf/loader.can:12
mat4, vec3, quat = cpml["mat4"], cpml["vec3"], cpml["quat"] -- ./gltf/loader.can:12
local dunpack -- ./gltf/loader.can:14
dunpack = string["unpack"] or love["data"]["unpack"] -- ./gltf/loader.can:14
local attributeName -- ./gltf/loader.can:17
attributeName = { -- ./gltf/loader.can:17
["POSITION"] = "VertexPosition", -- ./gltf/loader.can:18
["NORMAL"] = "VertexNormal", -- ./gltf/loader.can:19
["TANGENT"] = "VertexTangent", -- ./gltf/loader.can:20
["TEXCOORD_0"] = "VertexTexCoord", -- ./gltf/loader.can:21
["TEXCOORD_1"] = "VertexTexCoord1", -- ./gltf/loader.can:22
["COLOR_0"] = "VertexColor", -- ./gltf/loader.can:23
["JOINTS_0"] = "VertexJoints", -- ./gltf/loader.can:24
["WEIGHTS_0"] = "VertexWeights" -- ./gltf/loader.can:25
} -- ./gltf/loader.can:25
local componentType -- ./gltf/loader.can:28
componentType = { -- ./gltf/loader.can:28
[5120] = "byte", -- ./gltf/loader.can:29
[5121] = "unsigned byte", -- ./gltf/loader.can:30
[5122] = "short", -- ./gltf/loader.can:31
[5123] = "unsigned short", -- ./gltf/loader.can:32
[5125] = "int", -- ./gltf/loader.can:33
[5126] = "float" -- ./gltf/loader.can:34
} -- ./gltf/loader.can:34
local samplerEnum -- ./gltf/loader.can:37
samplerEnum = { -- ./gltf/loader.can:37
[9728] = "nearest", -- ./gltf/loader.can:38
[9729] = "linear", -- ./gltf/loader.can:39
[9984] = "nearest_mipmap_nearest", -- ./gltf/loader.can:40
[9985] = "linear_mipmap_nearest", -- ./gltf/loader.can:41
[9986] = "nearest_mipmap_linear", -- ./gltf/loader.can:42
[9987] = "linear_mipmap_linear", -- ./gltf/loader.can:43
[33071] = "clamp", -- ./gltf/loader.can:44
[33648] = "mirroredrepeat", -- ./gltf/loader.can:45
[10497] = "repeat" -- ./gltf/loader.can:46
} -- ./gltf/loader.can:46
local mode -- ./gltf/loader.can:49
mode = { -- ./gltf/loader.can:49
[0] = "points", -- ./gltf/loader.can:50
[1] = "lines", -- ./gltf/loader.can:51
[2] = "line_loop", -- ./gltf/loader.can:52
[3] = "line_strip", -- ./gltf/loader.can:53
[4] = "triangles", -- ./gltf/loader.can:54
[5] = "strip", -- ./gltf/loader.can:55
[6] = "fan" -- ./gltf/loader.can:56
} -- ./gltf/loader.can:56
local gltf -- ./gltf/loader.can:77
gltf = function(path) -- ./gltf/loader.can:77
local f -- ./gltf/loader.can:78
f = assert(io["open"](path, "r")) -- ./gltf/loader.can:78
local t -- ./gltf/loader.can:79
t = json_decode(f:read("*a")) -- ./gltf/loader.can:79
f:close() -- ./gltf/loader.can:80
if t["asset"]["minVersion"] then -- ./gltf/loader.can:83
local maj, min -- ./gltf/loader.can:84
maj, min = t["asset"]["minVersion"]:match("^(%d+)%.(%d+)$") -- ./gltf/loader.can:84
assert(maj == "2" and min == "0", ("asset require at least glTF version %s.%s but we only support 2.0"):format(maj, min)) -- ./gltf/loader.can:85
else -- ./gltf/loader.can:85
local maj, min -- ./gltf/loader.can:87
maj, min = t["asset"]["version"]:match("^(%d+)%.(%d+)$") -- ./gltf/loader.can:87
assert(maj == "2", ("asset require glTF version %s.%s but we only support 2.x"):format(maj, min)) -- ./gltf/loader.can:88
end -- ./gltf/loader.can:88
t["nodes"] = t["nodes"] or ({}) -- ./gltf/loader.can:92
t["scenes"] = t["scenes"] or ({}) -- ./gltf/loader.can:93
t["cameras"] = t["cameras"] or ({}) -- ./gltf/loader.can:94
t["meshes"] = t["meshes"] or ({}) -- ./gltf/loader.can:95
t["buffers"] = t["buffers"] or ({}) -- ./gltf/loader.can:96
t["bufferViews"] = t["bufferViews"] or ({}) -- ./gltf/loader.can:97
t["accessors"] = t["accessors"] or ({}) -- ./gltf/loader.can:98
t["materials"] = t["materials"] or ({}) -- ./gltf/loader.can:99
t["textures"] = t["textures"] or ({}) -- ./gltf/loader.can:100
t["images"] = t["images"] or ({}) -- ./gltf/loader.can:101
t["samplers"] = t["samplers"] or ({}) -- ./gltf/loader.can:102
t["skins"] = t["skins"] or ({}) -- ./gltf/loader.can:103
t["animations"] = t["animations"] or ({}) -- ./gltf/loader.can:104
for _, scene in ipairs(t["scenes"]) do -- ./gltf/loader.can:107
if scene["name"] then -- ./gltf/loader.can:108
t["scenes"][scene["name"]] = scene -- ./gltf/loader.can:108
end -- ./gltf/loader.can:108
for i, node in ipairs(scene["nodes"]) do -- ./gltf/loader.can:109
scene["nodes"][i] = t["nodes"][node + 1] -- ./gltf/loader.can:110
if scene["nodes"][i]["name"] then -- ./gltf/loader.can:111
scene["nodes"][scene["nodes"][i]["name"]] = scene["nodes"][i] -- ./gltf/loader.can:111
end -- ./gltf/loader.can:111
end -- ./gltf/loader.can:111
end -- ./gltf/loader.can:111
if t["scene"] then -- ./gltf/loader.can:116
t["scene"] = t["scenes"][t["scene"] + 1] -- ./gltf/loader.can:117
end -- ./gltf/loader.can:117
for _, node in ipairs(t["nodes"]) do -- ./gltf/loader.can:121
if node["name"] then -- ./gltf/loader.can:122
t["nodes"][node["name"]] = node -- ./gltf/loader.can:122
end -- ./gltf/loader.can:122
node["children"] = node["children"] or ({}) -- ./gltf/loader.can:123
for i, child in ipairs(node["children"]) do -- ./gltf/loader.can:124
node["children"][i] = t["nodes"][child + 1] -- ./gltf/loader.can:125
end -- ./gltf/loader.can:125
if node["matrix"] then -- ./gltf/loader.can:127
node["matrix"] = mat4(node["matrix"]) -- ./gltf/loader.can:128
else -- ./gltf/loader.can:128
node["translation"] = node["translation"] or ({ -- ./gltf/loader.can:130
0, -- ./gltf/loader.can:130
0, -- ./gltf/loader.can:130
0 -- ./gltf/loader.can:130
}) -- ./gltf/loader.can:130
node["rotation"] = node["rotation"] or ({ -- ./gltf/loader.can:131
0, -- ./gltf/loader.can:131
0, -- ./gltf/loader.can:131
0, -- ./gltf/loader.can:131
1 -- ./gltf/loader.can:131
}) -- ./gltf/loader.can:131
node["scale"] = node["scale"] or ({ -- ./gltf/loader.can:132
1, -- ./gltf/loader.can:132
1, -- ./gltf/loader.can:132
1 -- ./gltf/loader.can:132
}) -- ./gltf/loader.can:132
node["translation"] = vec3(node["translation"]) -- ./gltf/loader.can:134
node["rotation"] = quat(node["rotation"]) -- ./gltf/loader.can:135
node["scale"] = vec3(node["scale"]) -- ./gltf/loader.can:136
node["matrix"] = mat4["identity"]() -- ./gltf/loader.can:139
node["matrix"]:scale(node["matrix"], node["scale"]) -- ./gltf/loader.can:140
node["matrix"]:mul(mat4["from_quaternion"](node["rotation"]), node["matrix"]) -- ./gltf/loader.can:141
node["matrix"]:translate(node["matrix"], node["translation"]) -- ./gltf/loader.can:142
end -- ./gltf/loader.can:142
if node["mesh"] then -- ./gltf/loader.can:144
node["mesh"] = t["meshes"][node["mesh"] + 1] -- ./gltf/loader.can:145
end -- ./gltf/loader.can:145
if node["camera"] then -- ./gltf/loader.can:147
node["camera"] = t["cameras"][node["camera"] + 1] -- ./gltf/loader.can:148
end -- ./gltf/loader.can:148
end -- ./gltf/loader.can:148
for i, buffer in ipairs(t["buffers"]) do -- ./gltf/loader.can:153
if i == 1 and not buffer["uri"] then -- ./gltf/loader.can:154
error("no support for glb-stored buffer") -- ./gltf/loader.can:155
end -- ./gltf/loader.can:155
if buffer["uri"]:match("data:") then -- ./gltf/loader.can:157
local data = buffer["uri"]:match("^data:.-,(.*)$") -- ./gltf/loader.can:158
if buffer["uri"]:match("^data:.-;base64,") then -- ./gltf/loader.can:159
buffer["data"] = love["data"]["decode"]("string", "base64", data):sub(1, buffer["byteLength"] + 1) -- ./gltf/loader.can:160
else -- ./gltf/loader.can:160
buffer["data"] = data:gsub("%%(%x%x)", function(hex) -- ./gltf/loader.can:162
return love["data"]["decode"]("string", "hex", hex) -- ./gltf/loader.can:163
end):sub(1, buffer["byteLength"] + 1) -- ./gltf/loader.can:164
end -- ./gltf/loader.can:164
else -- ./gltf/loader.can:164
local bf -- ./gltf/loader.can:167
bf = assert(io["open"](buffer["uri"], "r"), ("can't find ressource %s"):format(buffer["uri"])) -- ./gltf/loader.can:167
local s -- ./gltf/loader.can:168
s = bf:read("*a") -- ./gltf/loader.can:168
bf:close() -- ./gltf/loader.can:169
buffer["data"] = s:sub(1, buffer["byteLength"] + 1) -- ./gltf/loader.can:170
end -- ./gltf/loader.can:170
end -- ./gltf/loader.can:170
for _, view in ipairs(t["bufferViews"]) do -- ./gltf/loader.can:175
view["buffer"] = t["buffers"][view["buffer"] + 1] -- ./gltf/loader.can:176
view["byteOffset"] = view["byteOffset"] or (0) -- ./gltf/loader.can:177
end -- ./gltf/loader.can:177
for _, accessor in ipairs(t["accessors"]) do -- ./gltf/loader.can:182
accessor["bufferView"] = t["bufferViews"][accessor["bufferView"] + 1] -- ./gltf/loader.can:183
accessor["byteOffset"] = accessor["byteOffset"] or (0) -- ./gltf/loader.can:184
local view -- ./gltf/loader.can:186
view = accessor["bufferView"] -- ./gltf/loader.can:186
local data -- ./gltf/loader.can:187
data = view["buffer"]["data"] -- ./gltf/loader.can:187
local fmt, size -- ./gltf/loader.can:190
accessor["componentType"] = componentType[accessor["componentType"]] -- ./gltf/loader.can:191
if accessor["componentType"] == "byte" then -- ./gltf/loader.can:192
fmt, size = "b", 1 -- ./gltf/loader.can:193
elseif accessor["componentType"] == "unsigned byte" then -- ./gltf/loader.can:194
fmt, size = "B", 1 -- ./gltf/loader.can:195
elseif accessor["componentType"] == "short" then -- ./gltf/loader.can:196
fmt, size = "h", 2 -- ./gltf/loader.can:197
elseif accessor["componentType"] == "unsigned short" then -- ./gltf/loader.can:198
fmt, size = "H", 2 -- ./gltf/loader.can:199
elseif accessor["componentType"] == "unsigned int" then -- ./gltf/loader.can:200
fmt, size = "I4", 4 -- ./gltf/loader.can:201
elseif accessor["componentType"] == "float" then -- ./gltf/loader.can:202
fmt, size = "f", 4 -- ./gltf/loader.can:203
end -- ./gltf/loader.can:203
if accessor["type"] == "SCALAR" then -- ./gltf/loader.can:207
accessor["components"], fmt = 1, fmt -- ./gltf/loader.can:208
elseif accessor["type"] == "VEC2" then -- ./gltf/loader.can:209
accessor["components"], fmt = 2, fmt:rep(2) -- ./gltf/loader.can:210
elseif accessor["type"] == "VEC3" then -- ./gltf/loader.can:211
accessor["components"], fmt = 3, fmt:rep(3) -- ./gltf/loader.can:212
elseif accessor["type"] == "VEC4" then -- ./gltf/loader.can:213
accessor["components"], fmt = 4, fmt:rep(4) -- ./gltf/loader.can:214
elseif accessor["type"] == "MAT2" then -- ./gltf/loader.can:215
accessor["components"] = 4 -- ./gltf/loader.can:216
fmt = (fmt:rep(2) .. ("x"):rep(4 - (size * 2) % 4)):rep(2) -- ./gltf/loader.can:217
elseif accessor["type"] == "MAT3" then -- ./gltf/loader.can:218
accessor["components"] = 9 -- ./gltf/loader.can:219
fmt = (fmt:rep(3) .. ("x"):rep(4 - (size * 3) % 4)):rep(3) -- ./gltf/loader.can:220
elseif accessor["type"] == "MAT4" then -- ./gltf/loader.can:221
accessor["components"] = 16 -- ./gltf/loader.can:222
fmt = (fmt:rep(4) .. ("x"):rep(4 - (size * 4) % 4)):rep(4) -- ./gltf/loader.can:223
end -- ./gltf/loader.can:223
fmt = ("<") .. fmt -- ./gltf/loader.can:226
accessor["data"] = {} -- ./gltf/loader.can:229
local i -- ./gltf/loader.can:230
i = view["byteOffset"] + 1 + accessor["byteOffset"] -- ./gltf/loader.can:230
local stop -- ./gltf/loader.can:231
stop = view["byteOffset"] + 1 + view["byteLength"] -- ./gltf/loader.can:231
local count = 0 -- ./gltf/loader.can:232
while i < stop and count < accessor["count"] do -- ./gltf/loader.can:233
local d = { dunpack(fmt, data, i) } -- ./gltf/loader.can:234
d[# d] = nil -- ./gltf/loader.can:235
if accessor["components"] > 1 then -- ./gltf/loader.can:236
table["insert"](accessor["data"], d) -- ./gltf/loader.can:237
else -- ./gltf/loader.can:237
table["insert"](accessor["data"], d[1]) -- ./gltf/loader.can:239
end -- ./gltf/loader.can:239
count = count + (1) -- ./gltf/loader.can:241
i = i + (view["byteStride"] or (size * accessor["components"])) -- ./gltf/loader.can:242
end -- ./gltf/loader.can:242
end -- ./gltf/loader.can:242
for _, image in ipairs(t["images"]) do -- ./gltf/loader.can:249
if image["uri"] then -- ./gltf/loader.can:250
image["image"] = love["graphics"]["newImage"](image["uri"]) -- ./gltf/loader.can:251
else -- ./gltf/loader.can:251
image["bufferView"] = t["bufferViews"][image["bufferView"] + 1] -- ./gltf/loader.can:253
local view -- ./gltf/loader.can:255
view = image["bufferView"] -- ./gltf/loader.can:255
local data -- ./gltf/loader.can:256
data = view["buffer"]["data"] -- ./gltf/loader.can:256
image["data"] = love["image"]["newImageData"](love["data"]["newByteData"](data:sub(view["byteOffset"] + 1, view["byteOffset"] + view["byteLength"]))) -- ./gltf/loader.can:258
end -- ./gltf/loader.can:258
end -- ./gltf/loader.can:258
for _, sampler in ipairs(t["samplers"]) do -- ./gltf/loader.can:262
sampler["wrapS"] = sampler["wrapS"] or (10497) -- ./gltf/loader.can:263
sampler["wrapT"] = sampler["wrapT"] or (10497) -- ./gltf/loader.can:264
sampler["magFilter"] = samplerEnum[sampler["magFilter"]] -- ./gltf/loader.can:266
sampler["minFilter"] = samplerEnum[sampler["minFilter"]] -- ./gltf/loader.can:267
sampler["wrapS"] = samplerEnum[sampler["wrapS"]] -- ./gltf/loader.can:268
sampler["wrapT"] = samplerEnum[sampler["wrapT"]] -- ./gltf/loader.can:269
end -- ./gltf/loader.can:269
for _, texture in ipairs(t["textures"]) do -- ./gltf/loader.can:272
texture["source"] = t["images"][texture["source"] + 1] or {} -- ./gltf/loader.can:273
texture["sampler"] = t["samplers"][texture["sampler"] + 1] -- ./gltf/loader.can:274
local mag -- ./gltf/loader.can:276
mag = texture["sampler"]["magFilter"] -- ./gltf/loader.can:276
local min -- ./gltf/loader.can:277
min = texture["sampler"]["minFilter"] -- ./gltf/loader.can:277
local mip -- ./gltf/loader.can:278
if min:match("_mipmap_") then -- ./gltf/loader.can:279
min, mip = min:match("^(.*)_mipmap_(.*)$") -- ./gltf/loader.can:280
end -- ./gltf/loader.can:280
texture["image"] = love["graphics"]["newImage"](texture["source"]["data"], { ["mipmaps"] = not not mip }) -- ./gltf/loader.can:282
texture["image"]:setFilter(min or "linear", mag) -- ./gltf/loader.can:283
if mip then -- ./gltf/loader.can:284
texture["image"]:setMipmapFilter(mip) -- ./gltf/loader.can:284
end -- ./gltf/loader.can:284
texture["image"]:setWrap(texture["sampler"]["wrapS"], texture["sampler"]["wrapT"]) -- ./gltf/loader.can:285
end -- ./gltf/loader.can:285
t["materials"][0] = { -- ./gltf/loader.can:289
["pbrMetallicRoughness"] = { -- ./gltf/loader.can:290
["baseColorFactor"] = { -- ./gltf/loader.can:291
1, -- ./gltf/loader.can:291
1, -- ./gltf/loader.can:291
1, -- ./gltf/loader.can:291
1 -- ./gltf/loader.can:291
}, -- ./gltf/loader.can:291
["metallicFactor"] = 1, -- ./gltf/loader.can:292
["roughnessFactor"] = 1 -- ./gltf/loader.can:293
}, -- ./gltf/loader.can:293
["emissiveFactor"] = { -- ./gltf/loader.can:295
0, -- ./gltf/loader.can:295
0, -- ./gltf/loader.can:295
0 -- ./gltf/loader.can:295
}, -- ./gltf/loader.can:295
["alphaMode"] = "OPAQUE", -- ./gltf/loader.can:296
["alphaCutoff"] = .5, -- ./gltf/loader.can:297
["doubleSided"] = false -- ./gltf/loader.can:298
} -- ./gltf/loader.can:298
for _, material in ipairs(t["materials"]) do -- ./gltf/loader.can:301
material["pbrMetallicRoughness"] = material["pbrMetallicRoughness"] or ({}) -- ./gltf/loader.can:302
material["pbrMetallicRoughness"]["baseColorFactor"] = material["pbrMetallicRoughness"]["baseColorFactor"] or ({ -- ./gltf/loader.can:303
1, -- ./gltf/loader.can:303
1, -- ./gltf/loader.can:303
1, -- ./gltf/loader.can:303
1 -- ./gltf/loader.can:303
}) -- ./gltf/loader.can:303
if material["pbrMetallicRoughness"]["baseColorTexture"] then -- ./gltf/loader.can:304
material["pbrMetallicRoughness"]["baseColorTexture"]["index"] = t["textures"][material["pbrMetallicRoughness"]["baseColorTexture"]["index"] + 1] -- ./gltf/loader.can:305
material["pbrMetallicRoughness"]["baseColorTexture"]["texCoord"] = material["pbrMetallicRoughness"]["baseColorTexture"]["texCoord"] or (0) -- ./gltf/loader.can:306
end -- ./gltf/loader.can:306
material["pbrMetallicRoughness"]["metallicFactor"] = material["pbrMetallicRoughness"]["metallicFactor"] or (1) -- ./gltf/loader.can:308
material["pbrMetallicRoughness"]["roughnessFactor"] = material["pbrMetallicRoughness"]["roughnessFactor"] or (1) -- ./gltf/loader.can:309
if material["pbrMetallicRoughness"]["metallicRoughnessTexture"] then -- ./gltf/loader.can:310
material["pbrMetallicRoughness"]["metallicRoughnessTexture"]["index"] = t["textures"][material["pbrMetallicRoughness"]["metallicRoughnessTexture"]["index"] + 1] -- ./gltf/loader.can:311
material["pbrMetallicRoughness"]["metallicRoughnessTexture"]["texCoord"] = material["pbrMetallicRoughness"]["metallicRoughnessTexture"]["texCoord"] or (0) -- ./gltf/loader.can:312
end -- ./gltf/loader.can:312
if material["normalTexture"] then -- ./gltf/loader.can:314
material["normalTexture"]["index"] = t["textures"][material["normalTexture"]["index"] + 1] -- ./gltf/loader.can:315
material["normalTexture"]["texCoord"] = material["normalTexture"]["texCoord"] or (0) -- ./gltf/loader.can:316
material["normalTexture"]["scale"] = material["normalTexture"]["scale"] or (1) -- ./gltf/loader.can:317
end -- ./gltf/loader.can:317
if material["occlusionTexture"] then -- ./gltf/loader.can:319
material["occlusionTexture"]["index"] = t["textures"][material["occlusionTexture"]["index"] + 1] -- ./gltf/loader.can:320
material["occlusionTexture"]["texCoord"] = material["occlusionTexture"]["texCoord"] or (0) -- ./gltf/loader.can:321
material["occlusionTexture"]["strength"] = material["occlusionTexture"]["strength"] or (1) -- ./gltf/loader.can:322
end -- ./gltf/loader.can:322
if material["emissiveTexture"] then -- ./gltf/loader.can:324
material["emissiveTexture"]["index"] = t["textures"][material["emissiveTexture"]["index"] + 1] -- ./gltf/loader.can:325
material["emissiveTexture"]["texCoord"] = material["emissiveTexture"]["texCoord"] or (0) -- ./gltf/loader.can:326
end -- ./gltf/loader.can:326
material["emissiveFactor"] = material["emissiveFactor"] or ({ -- ./gltf/loader.can:328
0, -- ./gltf/loader.can:328
0, -- ./gltf/loader.can:328
0 -- ./gltf/loader.can:328
}) -- ./gltf/loader.can:328
material["alphaMode"] = material["alphaMode"] or ("OPAQUE") -- ./gltf/loader.can:329
material["alphaCutoff"] = material["alphaCutoff"] or (.5) -- ./gltf/loader.can:330
material["doubleSided"] = material["doubleSided"] or (false) -- ./gltf/loader.can:331
end -- ./gltf/loader.can:331
for _, mesh in ipairs(t["meshes"]) do -- ./gltf/loader.can:335
for _, primitive in ipairs(mesh["primitives"]) do -- ./gltf/loader.can:336
local vertexformat -- ./gltf/loader.can:337
vertexformat = {} -- ./gltf/loader.can:337
local vertices -- ./gltf/loader.can:338
vertices = {} -- ./gltf/loader.can:338
for n, v in pairs(primitive["attributes"]) do -- ./gltf/loader.can:339
local accessor -- ./gltf/loader.can:340
accessor = t["accessors"][v + 1] -- ./gltf/loader.can:340
primitive["attributes"][n] = accessor -- ./gltf/loader.can:341
table["insert"](vertexformat, { -- ./gltf/loader.can:342
attributeName[n] or n, -- ./gltf/loader.can:342
accessor["componentType"], -- ./gltf/loader.can:342
accessor["components"] -- ./gltf/loader.can:342
}) -- ./gltf/loader.can:342
for i, x in ipairs(accessor["data"]) do -- ./gltf/loader.can:343
local vertex -- ./gltf/loader.can:344
vertex = vertices[i] -- ./gltf/loader.can:344
if not vertex then -- ./gltf/loader.can:345
table["insert"](vertices, i, {}) -- ./gltf/loader.can:346
vertex = vertices[i] -- ./gltf/loader.can:347
end -- ./gltf/loader.can:347
for _, c in ipairs(x) do -- ./gltf/loader.can:349
table["insert"](vertex, c) -- ./gltf/loader.can:350
end -- ./gltf/loader.can:350
end -- ./gltf/loader.can:350
end -- ./gltf/loader.can:350
if primitive["mode"] then -- ./gltf/loader.can:355
primitive["mode"] = mode[primitive["mode"]] -- ./gltf/loader.can:356
else -- ./gltf/loader.can:356
primitive["mode"] = "triangles" -- ./gltf/loader.can:358
end -- ./gltf/loader.can:358
primitive["mesh"] = love["graphics"]["newMesh"](vertexformat, vertices, primitive["mode"]) -- ./gltf/loader.can:361
if primitive["indices"] then -- ./gltf/loader.can:362
primitive["indices"] = (function() -- ./gltf/loader.can:363
local self = {} -- ./gltf/loader.can:363
for _, i in ipairs(t["accessors"][primitive["indices"] + 1]["data"]) do -- ./gltf/loader.can:363
self[#self+1] = i + 1 -- ./gltf/loader.can:363
end -- ./gltf/loader.can:363
return self -- ./gltf/loader.can:363
end)() -- ./gltf/loader.can:363
primitive["mesh"]:setVertexMap(primitive["indices"]) -- ./gltf/loader.can:364
end -- ./gltf/loader.can:364
primitive["material"] = t["materials"][(primitive["material"] or - 1) + 1] -- ./gltf/loader.can:367
if primitive["material"]["pbrMetallicRoughness"]["baseColorTexture"] then -- ./gltf/loader.can:368
primitive["mesh"]:setTexture(primitive["material"]["pbrMetallicRoughness"]["baseColorTexture"]["index"]["image"]) -- ./gltf/loader.can:369
end -- ./gltf/loader.can:369
end -- ./gltf/loader.can:369
end -- ./gltf/loader.can:369
for _, camera in ipairs(t["cameras"]) do -- ./gltf/loader.can:377
if camera["name"] then -- ./gltf/loader.can:378
t["cameras"][camera["name"]] = camera -- ./gltf/loader.can:378
end -- ./gltf/loader.can:378
if camera["type"] == "perspective" then -- ./gltf/loader.can:379
camera["perspective"]["aspectRatio"] = camera["perspective"]["aspectRatio"] or (16 / 9) -- ./gltf/loader.can:380
camera["matrix"] = mat4["from_perspective"](camera["perspective"]["yfov"], camera["perspective"]["aspectRatio"], camera["perspective"]["znear"], camera["perspective"]["zfar"]) -- ./gltf/loader.can:381
elseif camera["type"] == "orthographic" then -- ./gltf/loader.can:382
camera["matrix"] = mat4["from_ortho"](0, 0, camera["orthographic"]["xmag"], camera["orthographic"]["ymag"], camera["orthographic"]["znear"], camera["orthographic"]["zfar"]) -- ./gltf/loader.can:383
end -- ./gltf/loader.can:383
end -- ./gltf/loader.can:383
return t -- ./gltf/loader.can:395
end -- ./gltf/loader.can:395
return gltf -- ./gltf/loader.can:398

File diff suppressed because it is too large Load diff

View file

@ -1,143 +1,226 @@
local registry_mt -- ./signal/signal.can:13 local signal -- ./signal/signal.can:30
registry_mt = { -- ./signal/signal.can:13 local registry_mt -- ./signal/signal.can:36
["signals"] = {}, -- ./signal/signal.can:16 registry_mt = { -- ./signal/signal.can:36
["bind"] = function(self, name, fn, ...) -- ./signal/signal.can:22 ["signals"] = {}, -- ./signal/signal.can:39
if not self["signals"][name] then -- ./signal/signal.can:23 ["chained"] = {}, -- ./signal/signal.can:43
self["signals"][name] = {} -- ./signal/signal.can:24 ["bind"] = function(self, name, fn) -- ./signal/signal.can:48
end -- ./signal/signal.can:24 assert(not self:has(name, fn), ("function %s already bound to signal %s"):format(fn, name)) -- ./signal/signal.can:49
table["insert"](self["signals"][name], fn) -- ./signal/signal.can:26 if not self["signals"][name] then -- ./signal/signal.can:50
if ... then -- ./signal/signal.can:27 self["signals"][name] = {} -- ./signal/signal.can:51
self:bind(name, ...) -- ./signal/signal.can:28 end -- ./signal/signal.can:51
end -- ./signal/signal.can:28 table["insert"](self["signals"][name], fn) -- ./signal/signal.can:53
end, -- ./signal/signal.can:28 return self -- ./signal/signal.can:54
["unbind"] = function(self, name, fn, ...) -- ./signal/signal.can:36 end, -- ./signal/signal.can:54
if not self["signals"][name] then -- ./signal/signal.can:37 ["has"] = function(self, name, fn) -- ./signal/signal.can:60
return -- ./signal/signal.can:38
end -- ./signal/signal.can:38
for i = # self["signals"][name], 1, - 1 do -- ./signal/signal.can:40
if self["signals"][name] == fn then -- ./signal/signal.can:41
table["remove"](self["signals"][name], i) -- ./signal/signal.can:42
end -- ./signal/signal.can:42
end -- ./signal/signal.can:42
if ... then -- ./signal/signal.can:45
self:unbind(name, ...) -- ./signal/signal.can:46
end -- ./signal/signal.can:46
end, -- ./signal/signal.can:46
["unbindAll"] = function(self, name) -- ./signal/signal.can:52
self["signals"][name] = nil -- ./signal/signal.can:53
end, -- ./signal/signal.can:53
["replace"] = function(self, name, sourceFn, destFn) -- ./signal/signal.can:60
if not self["signals"][name] then -- ./signal/signal.can:61 if not self["signals"][name] then -- ./signal/signal.can:61
self["signals"][name] = {} -- ./signal/signal.can:62 return false -- ./signal/signal.can:62
end -- ./signal/signal.can:62 end -- ./signal/signal.can:62
for i, fn in ipairs(self["signals"][name]) do -- ./signal/signal.can:64 for _, f in ipairs(self["signals"][name]) do -- ./signal/signal.can:64
if fn == sourceFn then -- ./signal/signal.can:65 if f == fn then -- ./signal/signal.can:65
self["signals"][name][i] = destFn -- ./signal/signal.can:66 return true -- ./signal/signal.can:66
break -- ./signal/signal.can:67 end -- ./signal/signal.can:66
end -- ./signal/signal.can:67 end -- ./signal/signal.can:66
end -- ./signal/signal.can:67 return false -- ./signal/signal.can:69
end, -- ./signal/signal.can:67 end, -- ./signal/signal.can:69
["clear"] = function(self) -- ./signal/signal.can:73 ["unbind"] = function(self, name, fn) -- ./signal/signal.can:75
self["signals"] = {} -- ./signal/signal.can:74 if not self["signals"][name] then -- ./signal/signal.can:76
end, -- ./signal/signal.can:74 self["signals"][name] = {} -- ./signal/signal.can:77
["emit"] = function(self, name, ...) -- ./signal/signal.can:80 end -- ./signal/signal.can:77
if self["signals"][name] then -- ./signal/signal.can:81 for i = # self["signals"][name], 1, - 1 do -- ./signal/signal.can:79
for _, fn in ipairs(self["signals"][name]) do -- ./signal/signal.can:82 local f = self["signals"][name][i] -- ./signal/signal.can:80
fn(...) -- ./signal/signal.can:83 if f == fn then -- ./signal/signal.can:81
table["remove"](self["signals"][name], i) -- ./signal/signal.can:82
return self -- ./signal/signal.can:83
end -- ./signal/signal.can:83 end -- ./signal/signal.can:83
end -- ./signal/signal.can:83 end -- ./signal/signal.can:83
end -- ./signal/signal.can:83 error(("function %s not bound to signal %s"):format(fn, name)) -- ./signal/signal.can:86
} -- ./signal/signal.can:83 end, -- ./signal/signal.can:86
registry_mt["__index"] = registry_mt -- ./signal/signal.can:88 ["unbindPattern"] = function(self, pat, fn) -- ./signal/signal.can:91
local signal -- ./signal/signal.can:96 return self:_patternize("unbind", pat, fn) -- ./signal/signal.can:92
signal = { -- ./signal/signal.can:96 end, -- ./signal/signal.can:92
["new"] = function() -- ./signal/signal.can:99 ["clear"] = function(self, name) -- ./signal/signal.can:97
return setmetatable({ ["signals"] = {} }, registry_mt) -- ./signal/signal.can:100 self["signals"][name] = nil -- ./signal/signal.can:98
end, -- ./signal/signal.can:100 end, -- ./signal/signal.can:98
["signals"] = {}, -- ./signal/signal.can:104 ["clearPattern"] = function(self, pat) -- ./signal/signal.can:102
["bind"] = function(...) -- ./signal/signal.can:105 return self:_patternize("clear", pat) -- ./signal/signal.can:103
return registry_mt["bind"](signal, ...) -- ./signal/signal.can:106 end, -- ./signal/signal.can:103
end, -- ./signal/signal.can:106 ["emit"] = function(self, name, ...) -- ./signal/signal.can:109
["unbind"] = function(...) -- ./signal/signal.can:108 if self["signals"][name] then -- ./signal/signal.can:110
return registry_mt["unbind"](signal, ...) -- ./signal/signal.can:109 for _, fn in ipairs(self["signals"][name]) do -- ./signal/signal.can:111
end, -- ./signal/signal.can:109 fn(...) -- ./signal/signal.can:112
["unbindAll"] = function(...) -- ./signal/signal.can:111 end -- ./signal/signal.can:112
return registry_mt["unbindAll"](signal, ...) -- ./signal/signal.can:112 end -- ./signal/signal.can:112
end, -- ./signal/signal.can:112 for _, c in ipairs(self["chained"]) do -- ./signal/signal.can:115
["replace"] = function(...) -- ./signal/signal.can:114 c:emit(name, ...) -- ./signal/signal.can:116
return registry_mt["replace"](signal, ...) -- ./signal/signal.can:115 end -- ./signal/signal.can:116
end, -- ./signal/signal.can:115 return self -- ./signal/signal.can:118
["clear"] = function(...) -- ./signal/signal.can:117
return registry_mt["clear"](signal, ...) -- ./signal/signal.can:118
end, -- ./signal/signal.can:118 end, -- ./signal/signal.can:118
["emit"] = function(...) -- ./signal/signal.can:120 ["emitPattern"] = function(self, pat, ...) -- ./signal/signal.can:123
return registry_mt["emit"](signal, ...) -- ./signal/signal.can:121 return self:_patternize("emit", pat, ...) -- ./signal/signal.can:124
end, -- ./signal/signal.can:121 end, -- ./signal/signal.can:124
["event"] = nil, -- ./signal/signal.can:136 ["chain"] = function(self, registry) -- ./signal/signal.can:131
["registerEvents"] = function() -- ./signal/signal.can:141 if not registry then -- ./signal/signal.can:132
local callbacks = { -- ./signal/signal.can:142 registry = signal["new"]() -- ./signal/signal.can:133
"displayrotated", -- ./signal/signal.can:143 end -- ./signal/signal.can:133
"draw", -- ./signal/signal.can:143 table["insert"](self["chained"], registry) -- ./signal/signal.can:135
"load", -- ./signal/signal.can:143 return registry -- ./signal/signal.can:136
"lowmemory", -- ./signal/signal.can:143 end, -- ./signal/signal.can:136
"quit", -- ./signal/signal.can:143 ["unchain"] = function(self, registry) -- ./signal/signal.can:141
"update", -- ./signal/signal.can:143 for i = # self["chained"], 1, - 1 do -- ./signal/signal.can:142
"directorydropped", -- ./signal/signal.can:144 if self["chained"][i] == registry then -- ./signal/signal.can:143
"filedropped", -- ./signal/signal.can:144 table["remove"](self["chained"], i) -- ./signal/signal.can:144
"focus", -- ./signal/signal.can:144 return self -- ./signal/signal.can:145
"mousefocus", -- ./signal/signal.can:144 end -- ./signal/signal.can:145
"resize", -- ./signal/signal.can:144 end -- ./signal/signal.can:145
"visible", -- ./signal/signal.can:144 error("the givent registry is not chained with this registry") -- ./signal/signal.can:148
"keypressed", -- ./signal/signal.can:145 end, -- ./signal/signal.can:148
"keyreleased", -- ./signal/signal.can:145 ["_patternize"] = function(self, method, pat, ...) -- ./signal/signal.can:151
"textedited", -- ./signal/signal.can:145 for name in pairs(self["signals"]) do -- ./signal/signal.can:152
"textinput", -- ./signal/signal.can:145 if name:match(pat) then -- ./signal/signal.can:153
"mousemoved", -- ./signal/signal.can:146 self[method](self, name, ...) -- ./signal/signal.can:154
"mousepressed", -- ./signal/signal.can:146 end -- ./signal/signal.can:154
"mousereleased", -- ./signal/signal.can:146 end -- ./signal/signal.can:154
"wheelmoved", -- ./signal/signal.can:146 end -- ./signal/signal.can:154
"gamepadaxis", -- ./signal/signal.can:147 } -- ./signal/signal.can:154
"gamepadpressed", -- ./signal/signal.can:147 registry_mt["__index"] = registry_mt -- ./signal/signal.can:159
"gamepadreleased", -- ./signal/signal.can:147 local group_mt -- ./signal/signal.can:172
"joystickadded", -- ./signal/signal.can:148 group_mt = { -- ./signal/signal.can:172
"joystickaxis", -- ./signal/signal.can:148 ["paused"] = false, -- ./signal/signal.can:175
"joystickhat", -- ./signal/signal.can:148 ["binds"] = {}, -- ./signal/signal.can:179
"joystickpressed", -- ./signal/signal.can:148 ["bind"] = function(self, registry, name, fn) -- ./signal/signal.can:187
"joystickreleased", -- ./signal/signal.can:148 table["insert"](self["binds"], { -- ./signal/signal.can:188
"joystickremoved", -- ./signal/signal.can:148 registry, -- ./signal/signal.can:188
"touchmoved", -- ./signal/signal.can:149 name, -- ./signal/signal.can:188
"touchpressed", -- ./signal/signal.can:149 fn -- ./signal/signal.can:188
"touchreleased" -- ./signal/signal.can:149 }) -- ./signal/signal.can:188
} -- ./signal/signal.can:149 if not self["paused"] then -- ./signal/signal.can:189
local event = signal["event"] -- ./signal/signal.can:151 registry:bind(name, fn) -- ./signal/signal.can:189
for _, callback in ipairs(callbacks) do -- ./signal/signal.can:152 end -- ./signal/signal.can:189
if callback == "update" then -- ./signal/signal.can:153 end, -- ./signal/signal.can:189
if love[callback] then -- ./signal/signal.can:154 ["clear"] = function(self) -- ./signal/signal.can:193
local old = love[callback] -- ./signal/signal.can:155 if not self["paused"] then -- ./signal/signal.can:194
love[callback] = function(dt) -- ./signal/signal.can:156 for _, b in ipairs(self["binds"]) do -- ./signal/signal.can:195
old(dt) -- ./signal/signal.can:157 b[1]:unbind(b[2], b[3]) -- ./signal/signal.can:196
event:emit(callback, dt) -- ./signal/signal.can:158 end -- ./signal/signal.can:196
end -- ./signal/signal.can:158 end -- ./signal/signal.can:196
else -- ./signal/signal.can:158 self["binds"] = {} -- ./signal/signal.can:199
love[callback] = function(dt) -- ./signal/signal.can:161 end, -- ./signal/signal.can:199
event:emit(callback, dt) -- ./signal/signal.can:162 ["pause"] = function(self) -- ./signal/signal.can:204
end -- ./signal/signal.can:162 assert(not self["paused"], "event group is already paused") -- ./signal/signal.can:205
end -- ./signal/signal.can:162 self["paused"] = true -- ./signal/signal.can:206
else -- ./signal/signal.can:162 for _, b in ipairs(self["binds"]) do -- ./signal/signal.can:207
if love[callback] then -- ./signal/signal.can:166 b[1]:unbind(b[2], b[3]) -- ./signal/signal.can:208
local old = love[callback] -- ./signal/signal.can:167 end -- ./signal/signal.can:208
love[callback] = function(...) -- ./signal/signal.can:168 end, -- ./signal/signal.can:208
old(...) -- ./signal/signal.can:169 ["resume"] = function(self) -- ./signal/signal.can:214
event:emit(callback, ...) -- ./signal/signal.can:170 assert(self["paused"], "event group is not paused") -- ./signal/signal.can:215
end -- ./signal/signal.can:170 self["paused"] = false -- ./signal/signal.can:216
else -- ./signal/signal.can:170 for _, b in ipairs(self["binds"]) do -- ./signal/signal.can:217
love[callback] = function(...) -- ./signal/signal.can:173 b[1]:bind(b[2], b[3]) -- ./signal/signal.can:218
event:emit(callback, ...) -- ./signal/signal.can:174 end -- ./signal/signal.can:218
end -- ./signal/signal.can:174 end -- ./signal/signal.can:218
end -- ./signal/signal.can:174 } -- ./signal/signal.can:218
end -- ./signal/signal.can:174 group_mt["__index"] = group_mt -- ./signal/signal.can:222
end -- ./signal/signal.can:174 signal = { -- ./signal/signal.can:228
end -- ./signal/signal.can:174 ["new"] = function() -- ./signal/signal.can:231
} -- ./signal/signal.can:174 return setmetatable({ -- ./signal/signal.can:232
signal["event"] = signal["new"]() -- ./signal/signal.can:182 ["signals"] = {}, -- ./signal/signal.can:232
return signal -- ./signal/signal.can:184 ["chained"] = {} -- ./signal/signal.can:232
}, registry_mt) -- ./signal/signal.can:232
end, -- ./signal/signal.can:232
["group"] = function() -- ./signal/signal.can:237
return setmetatable({ ["binds"] = {} }, group_mt) -- ./signal/signal.can:238
end, -- ./signal/signal.can:238
["signals"] = {}, -- ./signal/signal.can:242
["bind"] = function(...) -- ./signal/signal.can:243
return registry_mt["bind"](signal, ...) -- ./signal/signal.can:244
end, -- ./signal/signal.can:244
["has"] = function(...) -- ./signal/signal.can:246
return registry_mt["has"](signal, ...) -- ./signal/signal.can:247
end, -- ./signal/signal.can:247
["unbind"] = function(...) -- ./signal/signal.can:249
return registry_mt["unbind"](signal, ...) -- ./signal/signal.can:250
end, -- ./signal/signal.can:250
["unbindPattern"] = function(...) -- ./signal/signal.can:252
return registry_mt["unbindPattern"](signal, ...) -- ./signal/signal.can:253
end, -- ./signal/signal.can:253
["clear"] = function(...) -- ./signal/signal.can:255
return registry_mt["clear"](signal, ...) -- ./signal/signal.can:256
end, -- ./signal/signal.can:256
["clearPattern"] = function(...) -- ./signal/signal.can:258
return registry_mt["clearPattern"](signal, ...) -- ./signal/signal.can:259
end, -- ./signal/signal.can:259
["emit"] = function(...) -- ./signal/signal.can:261
return registry_mt["emit"](signal, ...) -- ./signal/signal.can:262
end, -- ./signal/signal.can:262
["emitPattern"] = function(...) -- ./signal/signal.can:264
return registry_mt["emitPattern"](signal, ...) -- ./signal/signal.can:265
end, -- ./signal/signal.can:265
["event"] = nil, -- ./signal/signal.can:286
["registerEvents"] = function() -- ./signal/signal.can:291
local callbacks = { -- ./signal/signal.can:292
"displayrotated", -- ./signal/signal.can:293
"draw", -- ./signal/signal.can:293
"load", -- ./signal/signal.can:293
"lowmemory", -- ./signal/signal.can:293
"quit", -- ./signal/signal.can:293
"update", -- ./signal/signal.can:293
"directorydropped", -- ./signal/signal.can:294
"filedropped", -- ./signal/signal.can:294
"focus", -- ./signal/signal.can:294
"mousefocus", -- ./signal/signal.can:294
"resize", -- ./signal/signal.can:294
"visible", -- ./signal/signal.can:294
"keypressed", -- ./signal/signal.can:295
"keyreleased", -- ./signal/signal.can:295
"textedited", -- ./signal/signal.can:295
"textinput", -- ./signal/signal.can:295
"mousemoved", -- ./signal/signal.can:296
"mousepressed", -- ./signal/signal.can:296
"mousereleased", -- ./signal/signal.can:296
"wheelmoved", -- ./signal/signal.can:296
"gamepadaxis", -- ./signal/signal.can:297
"gamepadpressed", -- ./signal/signal.can:297
"gamepadreleased", -- ./signal/signal.can:297
"joystickadded", -- ./signal/signal.can:298
"joystickaxis", -- ./signal/signal.can:298
"joystickhat", -- ./signal/signal.can:298
"joystickpressed", -- ./signal/signal.can:298
"joystickreleased", -- ./signal/signal.can:298
"joystickremoved", -- ./signal/signal.can:298
"touchmoved", -- ./signal/signal.can:299
"touchpressed", -- ./signal/signal.can:299
"touchreleased" -- ./signal/signal.can:299
} -- ./signal/signal.can:299
local event = signal["event"] -- ./signal/signal.can:301
for _, callback in ipairs(callbacks) do -- ./signal/signal.can:302
if callback == "update" then -- ./signal/signal.can:303
if love[callback] then -- ./signal/signal.can:304
local old = love[callback] -- ./signal/signal.can:305
love[callback] = function(dt) -- ./signal/signal.can:306
old(dt) -- ./signal/signal.can:307
event:emit(callback, dt) -- ./signal/signal.can:308
end -- ./signal/signal.can:308
else -- ./signal/signal.can:308
love[callback] = function(dt) -- ./signal/signal.can:311
event:emit(callback, dt) -- ./signal/signal.can:312
end -- ./signal/signal.can:312
end -- ./signal/signal.can:312
else -- ./signal/signal.can:312
if love[callback] then -- ./signal/signal.can:316
local old = love[callback] -- ./signal/signal.can:317
love[callback] = function(...) -- ./signal/signal.can:318
old(...) -- ./signal/signal.can:319
event:emit(callback, ...) -- ./signal/signal.can:320
end -- ./signal/signal.can:320
else -- ./signal/signal.can:320
love[callback] = function(...) -- ./signal/signal.can:323
event:emit(callback, ...) -- ./signal/signal.can:324
end -- ./signal/signal.can:324
end -- ./signal/signal.can:324
end -- ./signal/signal.can:324
end -- ./signal/signal.can:324
end -- ./signal/signal.can:324
} -- ./signal/signal.can:324
signal["event"] = signal["new"]() -- ./signal/signal.can:332
return signal -- ./signal/signal.can:334