<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dw="https://www.dreamwidth.org">
  <id>tag:dreamwidth.org,2017-04-25:3165654</id>
  <title>Kevin Reid's blog</title>
  <subtitle>Kevin Reid</subtitle>
  <author>
    <name>Kevin Reid</name>
  </author>
  <link rel="alternate" type="text/html" href="https://kpreid.dreamwidth.org/"/>
  <link rel="self" type="text/xml" href="https://kpreid.dreamwidth.org/data/atom"/>
  <updated>2020-10-13T18:04:27Z</updated>
  <dw:journal username="kpreid" type="personal"/>
  <entry>
    <id>tag:dreamwidth.org,2017-04-25:3165654:54839</id>
    <link rel="alternate" type="text/html" href="https://kpreid.dreamwidth.org/54839.html"/>
    <link rel="self" type="text/xml" href="https://kpreid.dreamwidth.org/data/atom/?itemid=54839"/>
    <title>All is Cubes progress report</title>
    <published>2020-10-13T18:04:01Z</published>
    <updated>2020-10-13T18:04:27Z</updated>
    <category term="programming"/>
    <category term="webgl"/>
    <category term="web"/>
    <category term="all is cubes"/>
    <category term="rust"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;p&gt;I woke up last night with a great feature idea which on further examination was totally inapplicable to &lt;a href="https://github.com/kpreid/all-is-cubes"&gt;All is Cubes&lt;/a&gt; in its current state. (I was for some dream-ish reason imagining top-down tile- and turn-based movement, and had the idea to change the cursor depending on whether a click was a normal move or an only-allowed-because-we're-debugging teleport. This is totally unlike anything I've done yet and makes no sense for a first-person free movement game. But I might think about cursor/crosshair changes to signal what clicking on a block would do.)

&lt;p&gt;That seems like a good excuse to write a status update. Since &lt;a href="https://kpreid.dreamwidth.org/54200.html"&gt;my last post&lt;/a&gt; I've made significant progress, but there are still large missing pieces compared to the original JavaScript version.

&lt;p&gt;(The hazard in any rewrite, of course, is second-system effect — “we know what mistakes we made last time, so let's make zero of them this time”, with the result that you add both constraints and features, and overengineer the second version until you have a complex system that doesn't work. I'm trying to pay close attention to signs of overconstraint.)

&lt;p style="text-align: center;"&gt;
&lt;a href="https://switchb.org/kpreid/2020/all-is-cubes-10-13-progress.png"&gt;&lt;img src="https://switchb.org/kpreid/2020/all-is-cubes-10-13-progress.png" alt="[screenshot]" style="margin: 4px; max-height: 40em; max-width: 90%; border: none; padding: 1px; box-shadow: #22A 0px 1px 4px 0px; vertical-align: middle;"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Now done:

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;There's a web server you can run (&lt;code&gt;aic-server&lt;/code&gt;) that will serve the web app version; right now it's just static files with no client-server features.

&lt;li&gt;&lt;p&gt;Recursive blocks exist, and they can be rendered both in the WebGL and raytracing modes.

&lt;li&gt;&lt;p&gt;There's an actual camera/character component, so we can have perspective projection, WASD movement (but not yet mouselook), and collision.

  &lt;p&gt;For collision, right now the body is considered a point, but I'm in the middle of adding axis-aligned box collisions. I've improved on the original implementation in that I'm using the raycasting algorithm rather than making three separate axis-aligned moves, so we have true “continuous collision detection” and fast objects will never pass through walls or collide with things that aren't actually in their path.

&lt;li&gt;&lt;p&gt;You can click on blocks to remove them (but not place new ones).

&lt;li&gt;&lt;p&gt;Most of the lighting algorithm from the original, with the addition of RGB color.

  &lt;p&gt;Also new in this implementation, &lt;code&gt;Space&lt;/code&gt; has an explicit field for the “sky color” which is used &lt;em&gt;both&lt;/em&gt; for rendering and for illuminating blocks from outside the bounds. This actually reduces the number of constants used in the code, but also gets us closer to “physically based rendering”, and allows having “night” scenes without needing to put a roof over everything. (I expect to eventually generalize from a single color to a &lt;a href="https://en.wikipedia.org/wiki/Skybox_(video_games)"&gt;skybox&lt;/a&gt; of some sort, for outdoor directional lighting and having a visible horizon, sun, or other decorative elements.)

&lt;li&gt;&lt;p&gt;Rendering space in chunks instead of a single list of vertices that has to be recomputed for every change.

&lt;li&gt;&lt;p&gt;Added a data structure (&lt;code&gt;EvaluatedBlock&lt;/code&gt;) for caching computed details of blocks like whether their faces are opaque, and used it to correctly implement interior surface removal and lighting. This will also be critical for efficiently supporting things like rotated variants of blocks. (In the JS version, the &lt;code&gt;Block&lt;/code&gt; type was a JS object which memoized this information, but here, &lt;code&gt;Block&lt;/code&gt; is designed to be lightweight and copiable (because I've replaced having a &lt;code&gt;Blockset&lt;/code&gt; defining numeric IDs with passing around the actual &lt;code&gt;Block&lt;/code&gt; and letting the &lt;code&gt;Space&lt;/code&gt; handle allocating IDs), so it's less desirable to be storing computed values in &lt;code&gt;Block&lt;/code&gt;.)

&lt;li&gt;&lt;p&gt;Made nearly all of the GL/&lt;a href="https://github.com/phaazon/luminance-rs/"&gt;luminance&lt;/a&gt; rendering code not wasm-specific. That way, we can support "desktop application" as an option if we want to (I might do this solely for purposes of being able to graphically debug physics tests) and there is less code that can only be compiled with the wasm cross-compilation target.

&lt;li&gt;&lt;p&gt;Integrated &lt;a href="https://crates.io/crates/embedded-graphics"&gt;embedded_graphics&lt;/a&gt; to allow us to draw text (and other 2D graphics) into voxels. (That library was convenient because it came with fonts and because it allows implementing new drawing targets as the minimal interface "write this color (whatever you mean by color) to the pixel at these coordinates".) I plan to use this for building possibly the entire user interface out of voxels — but for now it's also an additional tool for test content generation.
&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Still to do that original Cubes had:

&lt;ul&gt;
&lt;li&gt;Mouselook/pointer lock.
&lt;li&gt;Block selection UI and placement.
&lt;li&gt;Any UI at all other than movement and targeting blocks. I've got ambitious plans to build the UI itself out of blocks, which both fits the "recursive self-defining blocks" theme and means I can do less platform-specific UI code (while running headlong down the path of problematically from-scratch inaccessible video game UI).
&lt;li&gt;Collision with recursive subcubes rather than whole cubes (so slopes/stairs and other smaller-than-an-entire-cube blocks work as expected).
&lt;li&gt;Persistence (saving to disk).
&lt;li&gt;Lots and lots of currently unhandled edge cases and "reallocate this buffer bigger" cases.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Stuff I want to do that's entirely new:

&lt;ul&gt;
&lt;li&gt;Networking; if not multiplayer, at least the web client saves its world data &lt;em&gt;to a server.&lt;/em&gt; I've probably already gone a bit too far down the path of writing a data model without consideration for networking.
&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=kpreid&amp;ditemid=54839" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2017-04-25:3165654:54200</id>
    <link rel="alternate" type="text/html" href="https://kpreid.dreamwidth.org/54200.html"/>
    <link rel="self" type="text/xml" href="https://kpreid.dreamwidth.org/data/atom/?itemid=54200"/>
    <title>Cubes reboot: All is Cubes</title>
    <published>2020-08-09T15:06:50Z</published>
    <updated>2020-08-09T15:06:50Z</updated>
    <category term="all is cubes"/>
    <category term="rust"/>
    <category term="web"/>
    <category term="cubes"/>
    <category term="webgl"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;p&gt;I've been getting back into playing Minecraft recently, and getting back into that frame of mind caused me to take another look at my &lt;a href="https://github.com/kpreid/cubes/"&gt;block-game-engine project titled "Cubes"&lt;/a&gt; (&lt;a href="https://kpreid.dreamwidth.org/tag/cubes"&gt;previous posts&lt;/a&gt;).

&lt;p&gt;I've fixed some API-change bitrot in Cubes so that it's runnable on current browsers; unfortunately the GitHub Pages build is broken so the running version that I'd otherwise link to isn't updated. (I intend to fix that.)

&lt;p&gt;The bigger news is that I've decided to rewrite it. Why?

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;There's some &lt;a href="https://github.com/kpreid/cubes/issues/71"&gt;inconsistency in the design&lt;/a&gt; of how block rotation works, and the way I've thought of to fix it is to start with a completely different strategy: instead of rotation being a feature of a block's behavior, there will be the general notion of blocks derived from other block definitions, so “this block but rotated” is such a derivation.
&lt;li&gt;&lt;p&gt;I'd like to start with a client-server architecture from the beginning, to support the options of both multiplayer and ✨ saving to the cloud!✨ — I mean, having a server which stores the world data instead of fitting it all into browser local storage.
&lt;li&gt;&lt;p&gt;&lt;strong&gt;I've been looking for an excuse to learn &lt;a href="https://www.rust-lang.org/"&gt;Rust&lt;/a&gt;.&lt;/strong&gt; And, if it works as I hope, I'll be able to program with a much better tradeoff between performance and high-level code.
&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/li&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;The new version is &lt;a href="https://github.com/kpreid/all-is-cubes"&gt;already on GitHub&lt;/a&gt;. I've given it the name “All is Cubes”, because “Cubes” really was a placeholder from the beginning and it's too generic.

&lt;p&gt;I'm currently working on porting (with improvements) various core data structures and algorithms from the original version — the first one being the voxel raycasting algorithm, which I then used to implement a raytracer that outputs to the terminal. (Conveniently, "ASCII art" is low-resolution and thus doesn't require too many rays.) And after getting that solid, I set up compiling the Rust code into WebAssembly to run in web browsers and render with WebGL.

&lt;p style="text-align: center;"&gt;
&lt;img src="https://switchb.org/kpreid/2020/all-is-cubes-first-console.png" alt="[console screenshot]" style="margin: 4px; max-height: 30em; max-width: 50%; border: none; padding: 1px; box-shadow: #22A 0px 1px 4px 0px; vertical-align: middle;"&gt;
&lt;img src="https://switchb.org/kpreid/2020/all-is-cubes-first-webgl.png" alt="[WebGL screenshot]" style="margin: 4px; max-height: 30em; max-width: 50%; border: none; padding: 1px; box-shadow: #22A 0px 1px 4px 0px; vertical-align:middle;"&gt;
&lt;/p&gt;

&lt;p&gt;(In the unlikely event that anyone cares, I haven't quite decided what to do with the post tags; I think that I will switch to tagging them all with &lt;a href="https://kpreid.dreamwidth.org/tag/all+is+cubes"&gt;all is cubes&lt;/a&gt;, but I might or might not go back and apply that to the old posts on the grounds that having a tag that gets everything is good and I'm not really giving the rewrite a &lt;em&gt;different&lt;/em&gt; name so much as taking the opportunity to replace the placeholder at a convenient time.)&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=kpreid&amp;ditemid=54200" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2017-04-25:3165654:53011</id>
    <link rel="alternate" type="text/html" href="https://kpreid.dreamwidth.org/53011.html"/>
    <link rel="self" type="text/xml" href="https://kpreid.dreamwidth.org/data/atom/?itemid=53011"/>
    <title>HTTPS, finally</title>
    <published>2018-06-28T17:43:13Z</published>
    <updated>2018-06-28T18:06:12Z</updated>
    <category term="web"/>
    <category term="security"/>
    <category term="meta"/>
    <category term="web site"/>
    <category term="apache"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;p&gt;In further news of updating my personal web presence, I have finally set up HTTPS for &lt;a href="https://switchb.org/kpreid/"&gt;switchb.org&lt;/a&gt;. As I write this I'm working on updating all the links to it that I control.

&lt;p&gt;The thing I found underdocumented in Let's Encrypt/Certbot is: if you want to (or must) manually edit the HTTP configuration, what should the edits be? What I concluded was:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;VirtualHost *:443&amp;gt;
  ServerName &lt;var&gt;YOUR DOMAIN NAME&lt;/var&gt;
  Include /etc/letsencrypt/options-ssl-apache.conf
  SSLCertificateFile /etc/letsencrypt/live/&lt;var&gt;YOUR DOMAIN OR CERT NAME&lt;/var&gt;/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/&lt;var&gt;YOUR DOMAIN OR CERT NAME&lt;/var&gt;/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/&lt;var&gt;YOUR DOMAIN OR CERT NAME&lt;/var&gt;/chain.pem

  &lt;var&gt;...rest of configuration for this virtual host...&lt;/var&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notes:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/etc/letsencrypt/options-ssl-apache.conf&lt;/code&gt; (which of course may be in a different location depending on your OS and package manager) contains the basic configuration to enable SSL (&lt;code&gt;SSLEngine on&lt;/code&gt;) and certbot-recommended cipher options.
&lt;li&gt;You have to have a separate VirtualHost entry for *:443 and *:80; there's no way to copy the common configuration as far as I heard.
&lt;li&gt;By "&lt;var&gt;CERT NAME&lt;/var&gt;" I mean the name assigned to a multi-domain-name certificate if you have requested one. You can find out the certificate names with the command &lt;kbd&gt;certbot certificates&lt;/kbd&gt;. For a single domain it will be identical to the domain name.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=kpreid&amp;ditemid=53011" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
</feed>
