wip vite lib, typst markup
This commit is contained in:
35
main.typ
Normal file
35
main.typ
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#let put(x, y, z, ..args) = {
|
||||||
|
(
|
||||||
|
"p",
|
||||||
|
str(x),
|
||||||
|
str(y),
|
||||||
|
str(z),
|
||||||
|
..args.pos().map(str),
|
||||||
|
..args.named().pairs().map((u, v) => str(u) + "=" + str(v)),
|
||||||
|
).join(" ")
|
||||||
|
}
|
||||||
|
|
||||||
|
#html.html({
|
||||||
|
html.head({
|
||||||
|
html.link(rel: "stylesheet", href: "./mc-diorama.css")
|
||||||
|
html.script(src: "./mc-diorama.mjs", type: "module")
|
||||||
|
})
|
||||||
|
html.body({
|
||||||
|
html.main([
|
||||||
|
= hello world
|
||||||
|
])
|
||||||
|
|
||||||
|
html.elem("mc-diorama", {
|
||||||
|
html.elem("mc-camera")
|
||||||
|
html.elem(
|
||||||
|
"mc-world",
|
||||||
|
"
|
||||||
|
p 0 0 0 stone;
|
||||||
|
p 0 0 1 piston facing=up extended=false &
|
||||||
|
|
||||||
|
p 1 0 0 redstone_block;
|
||||||
|
",
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
40
package-lock.json
generated
40
package-lock.json
generated
@@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "wireless",
|
"name": "mc-diorama",
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "wireless",
|
"name": "mc-diorama",
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^8.1.1"
|
"vite": "^8.1.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@emnapi/core": {
|
"node_modules/@emnapi/core": {
|
||||||
@@ -167,9 +167,6 @@
|
|||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -187,9 +184,6 @@
|
|||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -207,9 +201,6 @@
|
|||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -227,9 +218,6 @@
|
|||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -247,9 +235,6 @@
|
|||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -267,9 +252,6 @@
|
|||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -553,9 +535,6 @@
|
|||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -577,9 +556,6 @@
|
|||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -601,9 +577,6 @@
|
|||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -625,9 +598,6 @@
|
|||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
|
|||||||
21
package.json
21
package.json
@@ -1,14 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "wireless",
|
"name": "mc-diorama",
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"files": [
|
||||||
"type": "module",
|
"dist"
|
||||||
"scripts": {
|
],
|
||||||
"dev": "vite",
|
"module": "./dist/mc-diorama.es.js",
|
||||||
"build": "vite build",
|
"exports": {
|
||||||
"preview": "vite preview"
|
".": {
|
||||||
},
|
"import": "./dist/mc-diorama.es.js"
|
||||||
"devDependencies": {
|
}
|
||||||
"vite": "^8.1.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {SpacetimeController} from './controller.js';
|
|||||||
window.mcEngine = new Engine();
|
window.mcEngine = new Engine();
|
||||||
document.body.appendChild(window.mcEngine.canvas)
|
document.body.appendChild(window.mcEngine.canvas)
|
||||||
|
|
||||||
export class MCWorldElement extends HTMLElement {
|
class MCWorldElement extends HTMLElement {
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
if (this.world) return;
|
if (this.world) return;
|
||||||
// Read text content directly, allowing inline scripting
|
// Read text content directly, allowing inline scripting
|
||||||
@@ -17,7 +17,7 @@ export class MCWorldElement extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MCFrameElement extends HTMLElement {
|
class MCFrameElement extends HTMLElement {
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
// Use a microtask to ensure children are parsed
|
// Use a microtask to ensure children are parsed
|
||||||
setTimeout(() => this.init(), 0);
|
setTimeout(() => this.init(), 0);
|
||||||
@@ -42,7 +42,7 @@ export class MCFrameElement extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MCDioramaElement extends HTMLElement {
|
class MCDioramaElement extends HTMLElement {
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
setTimeout(() => this.init(), 0);
|
setTimeout(() => this.init(), 0);
|
||||||
}
|
}
|
||||||
|
|||||||
2
src/lib.js
Normal file
2
src/lib.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import './components.js';
|
||||||
|
import './components.css';
|
||||||
@@ -54,10 +54,10 @@ export class TextureHandler {
|
|||||||
|
|
||||||
const drawMissing = () => {
|
const drawMissing = () => {
|
||||||
const half = this.cellSize / 2;
|
const half = this.cellSize / 2;
|
||||||
this.ctx.fillStyle = '#33333366'; // Gray
|
this.ctx.fillStyle = '#666666FF'; // Gray
|
||||||
this.ctx.fillRect(pos.x, pos.y, half, half);
|
this.ctx.fillRect(pos.x, pos.y, half, half);
|
||||||
this.ctx.fillRect(pos.x + half, pos.y + half, half, half);
|
this.ctx.fillRect(pos.x + half, pos.y + half, half, half);
|
||||||
this.ctx.fillStyle = '#00000066'; // Black
|
this.ctx.fillStyle = '#333333FF'; // Black
|
||||||
this.ctx.fillRect(pos.x + half, pos.y, half, half);
|
this.ctx.fillRect(pos.x + half, pos.y, half, half);
|
||||||
this.ctx.fillRect(pos.x, pos.y + half, half, half);
|
this.ctx.fillRect(pos.x, pos.y + half, half, half);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export class World {
|
|||||||
capturedInitialState = true;
|
capturedInitialState = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const lines = script.split('\n').map(l => l.trim()).filter(l => l && !l.startsWith('#'));
|
const lines = script.split(/\n|;|(?<=&)/).map(l => l.trim()).filter(l => l && !l.startsWith('#'));
|
||||||
|
|
||||||
let currentBatch = [];
|
let currentBatch = [];
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
export default {
|
import {dirname, resolve} from 'node:path'
|
||||||
base: "/secret-knowledge/",
|
import {defineConfig} from 'vite'
|
||||||
}
|
|
||||||
|
export default defineConfig({
|
||||||
|
build: {
|
||||||
|
lib: {
|
||||||
|
entry: resolve(import.meta.dirname, 'src/lib.js'),
|
||||||
|
name: 'mc-diorama',
|
||||||
|
fileName: 'mc-diorama',
|
||||||
|
formats: ['es']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user