I just created an on chain 3d rendering of my pixel pepe using recursive inscriptions. In the process, I inscribed tooling that will be critical as we build out the bitcoinverse.
This is how it did it 🧵
The first primitive i needed was a 3d renderer. I decided on using model-viewer by google - easy to integrate and shipped with favorable licensing for open use.
But there was a problem, the minified javascript came in at 845KB! Too large to put on chain w/o talking to a miner
The solution? I gzipped the library and got it down to 244kb.
But now i needed a way to decompress model-viewer so i could actually use it in a recursive inscription.
Enter our next primitive, fflate, a fast pure js library for gzip compressing and decomposing
Combining fflate and the gzipped version of model-viewer, i was able to create an inscription that gives you the full functionality of model-viewer
Usage:
<script type="module" src="/content/547a6709441bc5c9d206150ce5fb7605c28a90c46bd6e4330c4420cb41477aeai0"></script>
Next I put a blank glb template on chain, that i would later be able to repaint in the browser with any content i wanted.
I was able to compress my model from 226kb to 181kb using gzip and then re-use the fflate library to inflate it when i needed it
I then created a simple library that lets you repaint textures on a model. You can apply lines, text, and even images to any texture on any 3d model
import transform from '/content/7d3dd64f6598ea371aeff4d70b0f1728af0f57dd1747b58a190f7e52a9f5cd30i0'
I pulled it all together by making an inscription that will paint the card model with any title, image and attributes you pass to it
import card from '/content/c56a3b998b2b2dc72fa694e599b52569e3f99be8a4fc23869f96043849ddc752i0'
Finally, I had all the primitives i needed to create an inscription of my 3d pixel pepe. I created an html inscription that combined it all
You can view it on
@ordinalswallet
And on
@ord_io
from
@LeonidasNFT
To recap, the newly inscribed primatives:
fflate.js
f815bd5c566c6e46de5cdb6ccb3a7043c63deeba61f4234baea84b602b0d4440i0
model-viewer.js
c56a3b998b2b2dc72fa694e599b52569e3f99be8a4fc23869f96043849ddc752i0
The caveat, there are still some CSP headers blocking the texture repainting in the official ord client. I created a pull request to fix this and found another PR from
@OrdinalFomojis
who ran into the same issue