mittens-engine 0.7.0

A Vulkan and OpenXR scene engine with ECS, reactive signals, and Meow Meow scripting
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
// array-access.mms
//
// Sketch-only MMS example for future array indexing + array mutation support.
// This file is intended to show the target authoring shape before the parser
// and evaluator support `values[i]` reads/writes.
//
// Desired not-yet-implemented features exercised here:
//   1. array indexing: values[0]
//   2. array mutation: values[0] = values[0] + 1
//   3. loading display text from the same indexed array slot
//
// Layout: 6 rows inside one LayoutRoot. Each row has:
//   up button  |  value text  |  down button
//
// Button icons reuse the floating triangle style from component-method-call.mms.

RendererSettings {
    window_size(1100, 760)
}

BGC {
    C.rgba(0.93, 0.93, 0.95, 1.0)
}

AL.rgb(0.55, 0.55, 0.60)

T.position(3.0, 5.0, 4.0) {
    DL {}
}

I.speed(3.0) {
    InputTransformMode.forward_z() {
        fps_rotation()
        roll_axis_y()
    }

    T.position(0.0, -0.3, 3.2) {
        C3D {
            Pointer {}
        }
    }
}

BG {
    T.position(0, -10, 0).scale(10000, 1, 10000) {
        R.cube() { C.rgba(0.65, 0.65, 0.67, 1.0) }
    }
}

let values = [0, 0, 0, 0, 0, 0]
let layout_root = null

T.position(-1.5, 0.5, 0.0).scale(0.065, 0.065, 0.065) {
    layout_root = LayoutRoot {
        available_width(42.0)
        available_height(70.0)

        Text {
            Style.padding_bottom(1.5)
                    .font_size(1.2) {}
            "Array access sketch"
        }

        Text {
            Style.padding_bottom(1.5)
                    .font_size(0.75) {}
            "Six counters driven from one array"
        }

        T.position(0, 0, 0.05) {
            name = "row_0"
            Style.display("flex")
                    .flex_direction("row")
                    .gap(1.0)
                    .padding(1.0)
                    .background_color([0.95, 0.72, 0.72, 1.0]) {}

            T.position(0, 0, 0.08) {
                name = "up_0"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.82, 0.28, 0.28, 1.0]) {}
                T.position(0, 0, 0.6).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }

            T.position(0, 0, 0.05) {
                Style.padding_xy(2.4, 2.0)
                        .background_color([0.60, 0.18, 0.18, 1.0]) {}
                Text {
                    name = "text_0"
                    values[0]
                }
            }

            T.position(0, 0, 0.08) {
                name = "down_0"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.70, 0.20, 0.20, 1.0]) {}
                T.position(0, 0, 0.6).rotation(0, 0, 3.14159).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }
        }

        T.position(0, 0, 0.05) {
            name = "row_1"
            Style.display("flex")
                    .flex_direction("row")
                    .gap(1.0)
                    .padding(1.0)
                    .background_color([0.95, 0.80, 0.67, 1.0]) {}

            T.position(0, 0, 0.08) {
                name = "up_1"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.85, 0.48, 0.10, 1.0]) {}
                T.position(0, 0, 0.6).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }

            T.position(0, 0, 0.05) {
                Style.padding_xy(2.4, 2.0)
                        .background_color([0.64, 0.36, 0.06, 1.0]) {}
                Text {
                    name = "text_1"
                    values[1]
                }
            }

            T.position(0, 0, 0.08) {
                name = "down_1"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.74, 0.40, 0.08, 1.0]) {}
                T.position(0, 0, 0.6).rotation(0, 0, 3.14159).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }
        }

        T.position(0, 0, 0.05) {
            name = "row_2"
            Style.display("flex")
                    .flex_direction("row")
                    .gap(1.0)
                    .padding(1.0)
                    .background_color([0.95, 0.90, 0.64, 1.0]) {}

            T.position(0, 0, 0.08) {
                name = "up_2"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.82, 0.66, 0.12, 1.0]) {}
                T.position(0, 0, 0.6).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }

            T.position(0, 0, 0.05) {
                Style.padding_xy(2.4, 2.0)
                        .background_color([0.62, 0.49, 0.08, 1.0]) {}
                Text {
                    name = "text_2"
                    values[2]
                }
            }

            T.position(0, 0, 0.08) {
                name = "down_2"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.72, 0.58, 0.10, 1.0]) {}
                T.position(0, 0, 0.6).rotation(0, 0, 3.14159).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }
        }

        T.position(0, 0, 0.05) {
            name = "row_3"
            Style.display("flex")
                    .flex_direction("row")
                    .gap(1.0)
                    .padding(1.0)
                    .background_color([0.78, 0.94, 0.68, 1.0]) {}

            T.position(0, 0, 0.08) {
                name = "up_3"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.22, 0.64, 0.26, 1.0]) {}
                T.position(0, 0, 0.6).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }

            T.position(0, 0, 0.05) {
                Style.padding_xy(2.4, 2.0)
                        .background_color([0.16, 0.45, 0.18, 1.0]) {}
                Text {
                    name = "text_3"
                    values[3]
                }
            }

            T.position(0, 0, 0.08) {
                name = "down_3"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.18, 0.54, 0.22, 1.0]) {}
                T.position(0, 0, 0.6).rotation(0, 0, 3.14159).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }
        }

        T.position(0, 0, 0.05) {
            name = "row_4"
            Style.display("flex")
                    .flex_direction("row")
                    .gap(1.0)
                    .padding(1.0)
                    .background_color([0.67, 0.86, 0.95, 1.0]) {}

            T.position(0, 0, 0.08) {
                name = "up_4"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.18, 0.44, 0.82, 1.0]) {}
                T.position(0, 0, 0.6).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }

            T.position(0, 0, 0.05) {
                Style.padding_xy(2.4, 2.0)
                        .background_color([0.12, 0.30, 0.60, 1.0]) {}
                Text {
                    name = "text_4"
                    values[4]
                }
            }

            T.position(0, 0, 0.08) {
                name = "down_4"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.14, 0.36, 0.70, 1.0]) {}
                T.position(0, 0, 0.6).rotation(0, 0, 3.14159).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }
        }

        T.position(0, 0, 0.05) {
            name = "row_5"
            Style.display("flex")
                    .flex_direction("row")
                    .gap(1.0)
                    .padding(1.0)
                    .background_color([0.84, 0.74, 0.95, 1.0]) {}

            T.position(0, 0, 0.08) {
                name = "up_5"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.48, 0.26, 0.82, 1.0]) {}
                T.position(0, 0, 0.6).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }

            T.position(0, 0, 0.05) {
                Style.padding_xy(2.4, 2.0)
                        .background_color([0.34, 0.16, 0.60, 1.0]) {}
                Text {
                    name = "text_5"
                    values[5]
                }
            }

            T.position(0, 0, 0.08) {
                name = "down_5"
                Style.padding_xy(1.6, 1.6)
                        .background_color([0.42, 0.20, 0.72, 1.0]) {}
                T.position(0, 0, 0.6).rotation(0, 0, 3.14159).scale(0.75, 0.75, 0.75) {
                    R.triangle() {
                        C.rgba(1.0, 1.0, 1.0, 1.0)
                        Raycastable.enabled()
                    }
                }
            }
        }
    }

    layout_root
}

let up_0 = layout_root.query("#up_0")
let down_0 = layout_root.query("#down_0")
let text_0 = layout_root.query("#text_0")

let up_1 = layout_root.query("#up_1")
let down_1 = layout_root.query("#down_1")
let text_1 = layout_root.query("#text_1")

let up_2 = layout_root.query("#up_2")
let down_2 = layout_root.query("#down_2")
let text_2 = layout_root.query("#text_2")

let up_3 = layout_root.query("#up_3")
let down_3 = layout_root.query("#down_3")
let text_3 = layout_root.query("#text_3")

let up_4 = layout_root.query("#up_4")
let down_4 = layout_root.query("#down_4")
let text_4 = layout_root.query("#text_4")

let up_5 = layout_root.query("#up_5")
let down_5 = layout_root.query("#down_5")
let text_5 = layout_root.query("#text_5")

// These handlers sketch the intended future syntax.
// They are expected to fail until array indexing and array mutation land.

on(up_0, "Click", fn(event) {
    values[0] = values[0] + 1
    text_0.set_text(values[0])
})

on(down_0, "Click", fn(event) {
    values[0] = values[0] - 1
    text_0.set_text(values[0])
})

on(up_1, "Click", fn(event) {
    values[1] = values[1] + 1
    text_1.set_text(values[1])
})

on(down_1, "Click", fn(event) {
    values[1] = values[1] - 1
    text_1.set_text(values[1])
})

on(up_2, "Click", fn(event) {
    values[2] = values[2] + 1
    text_2.set_text(values[2])
})

on(down_2, "Click", fn(event) {
    values[2] = values[2] - 1
    text_2.set_text(values[2])
})

on(up_3, "Click", fn(event) {
    values[3] = values[3] + 1
    text_3.set_text(values[3])
})

on(down_3, "Click", fn(event) {
    values[3] = values[3] - 1
    text_3.set_text(values[3])
})

on(up_4, "Click", fn(event) {
    values[4] = values[4] + 1
    text_4.set_text(values[4])
})

on(down_4, "Click", fn(event) {
    values[4] = values[4] - 1
    text_4.set_text(values[4])
})

on(up_5, "Click", fn(event) {
    values[5] = values[5] + 1
    text_5.set_text(values[5])
})

on(down_5, "Click", fn(event) {
    values[5] = values[5] - 1
    text_5.set_text(values[5])
})