@holoscript/engine 6.0.3 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/AutoMesher-CK47F6AV.js +17 -0
  2. package/dist/GPUBuffers-2LHBCD7X.js +9 -0
  3. package/dist/WebGPUContext-TNEUYU2Y.js +11 -0
  4. package/dist/animation/index.cjs +38 -38
  5. package/dist/animation/index.d.cts +1 -1
  6. package/dist/animation/index.d.ts +1 -1
  7. package/dist/animation/index.js +1 -1
  8. package/dist/audio/index.cjs +16 -6
  9. package/dist/audio/index.d.cts +1 -1
  10. package/dist/audio/index.d.ts +1 -1
  11. package/dist/audio/index.js +1 -1
  12. package/dist/camera/index.cjs +23 -23
  13. package/dist/camera/index.d.cts +1 -1
  14. package/dist/camera/index.d.ts +1 -1
  15. package/dist/camera/index.js +1 -1
  16. package/dist/character/index.cjs +6 -4
  17. package/dist/character/index.js +1 -1
  18. package/dist/choreography/index.cjs +1194 -0
  19. package/dist/choreography/index.d.cts +687 -0
  20. package/dist/choreography/index.d.ts +687 -0
  21. package/dist/choreography/index.js +1156 -0
  22. package/dist/chunk-2CSNRI2N.js +217 -0
  23. package/dist/chunk-33T2WINR.js +266 -0
  24. package/dist/chunk-35R73OFM.js +1257 -0
  25. package/dist/chunk-4MMDSUNP.js +1256 -0
  26. package/dist/chunk-5V6HOU72.js +319 -0
  27. package/dist/chunk-6QOP6PYF.js +1038 -0
  28. package/dist/chunk-7KMJVHIL.js +8944 -0
  29. package/dist/chunk-7VPUC62U.js +1106 -0
  30. package/dist/chunk-A2Y6RCAT.js +1878 -0
  31. package/dist/chunk-AHM42MK6.js +8944 -0
  32. package/dist/chunk-BL7IDTHE.js +218 -0
  33. package/dist/chunk-CITOMSWL.js +10462 -0
  34. package/dist/chunk-CXDPKW2K.js +8944 -0
  35. package/dist/chunk-CXZPLD4S.js +223 -0
  36. package/dist/chunk-CZYJE7IH.js +5169 -0
  37. package/dist/chunk-D2OP7YC7.js +6325 -0
  38. package/dist/chunk-EDRVQHUU.js +1544 -0
  39. package/dist/chunk-EJSLOOW2.js +3589 -0
  40. package/dist/chunk-F53SFGW5.js +1878 -0
  41. package/dist/chunk-HCFPELPY.js +919 -0
  42. package/dist/chunk-HNEE36PY.js +93 -0
  43. package/dist/chunk-HYXNV36F.js +1256 -0
  44. package/dist/chunk-IB7KHVFY.js +821 -0
  45. package/dist/chunk-IBBO7YYG.js +690 -0
  46. package/dist/chunk-ILIBGINU.js +5470 -0
  47. package/dist/chunk-IS4MHLKN.js +5479 -0
  48. package/dist/chunk-JT2PFKWD.js +5479 -0
  49. package/dist/chunk-K4CUB4NY.js +1038 -0
  50. package/dist/chunk-KATDQXRJ.js +10462 -0
  51. package/dist/chunk-KBQE6ZFJ.js +8944 -0
  52. package/dist/chunk-KBVD5K7E.js +560 -0
  53. package/dist/chunk-KCDPVQRY.js +4088 -0
  54. package/dist/chunk-KN4QJPKN.js +8944 -0
  55. package/dist/chunk-KWJ3ROSI.js +8944 -0
  56. package/dist/chunk-L45VF6DD.js +919 -0
  57. package/dist/chunk-LY4T37YK.js +307 -0
  58. package/dist/chunk-MDN5WZXA.js +1544 -0
  59. package/dist/chunk-MGCDP6VU.js +928 -0
  60. package/dist/chunk-NCX7X6G2.js +8681 -0
  61. package/dist/chunk-OF54BPVD.js +913 -0
  62. package/dist/chunk-OWSN2Q3Q.js +690 -0
  63. package/dist/chunk-PRRB5TTA.js +406 -0
  64. package/dist/chunk-PXWVQF76.js +4086 -0
  65. package/dist/chunk-PYCOIDT2.js +812 -0
  66. package/dist/chunk-PZCSADOV.js +928 -0
  67. package/dist/chunk-Q2XBVS2K.js +1038 -0
  68. package/dist/chunk-QDZRXWN5.js +1776 -0
  69. package/dist/chunk-RNWOZ6WQ.js +913 -0
  70. package/dist/chunk-ROLFT4CJ.js +1693 -0
  71. package/dist/chunk-SLTJRZ2N.js +266 -0
  72. package/dist/chunk-SRUS5XSU.js +4088 -0
  73. package/dist/chunk-TKCA3WZ5.js +5409 -0
  74. package/dist/chunk-TNRMXYI2.js +1650 -0
  75. package/dist/chunk-TQB3GJGM.js +9763 -0
  76. package/dist/chunk-TUFGXG6K.js +510 -0
  77. package/dist/chunk-U6KMTGQJ.js +632 -0
  78. package/dist/chunk-VMGJQST6.js +8681 -0
  79. package/dist/chunk-X4F4TCG4.js +5470 -0
  80. package/dist/chunk-ZIFROE75.js +1544 -0
  81. package/dist/chunk-ZIJQYHSQ.js +1204 -0
  82. package/dist/combat/index.cjs +4 -4
  83. package/dist/combat/index.d.cts +1 -1
  84. package/dist/combat/index.d.ts +1 -1
  85. package/dist/combat/index.js +1 -1
  86. package/dist/ecs/index.cjs +1 -1
  87. package/dist/ecs/index.js +1 -1
  88. package/dist/environment/index.cjs +14 -14
  89. package/dist/environment/index.d.cts +1 -1
  90. package/dist/environment/index.d.ts +1 -1
  91. package/dist/environment/index.js +1 -1
  92. package/dist/gpu/index.cjs +4810 -0
  93. package/dist/gpu/index.js +3714 -0
  94. package/dist/hologram/index.cjs +27 -1
  95. package/dist/hologram/index.js +1 -1
  96. package/dist/index-B2PIsAmR.d.cts +2180 -0
  97. package/dist/index-B2PIsAmR.d.ts +2180 -0
  98. package/dist/index-BHySEPX7.d.cts +2921 -0
  99. package/dist/index-BJV21zuy.d.cts +341 -0
  100. package/dist/index-BJV21zuy.d.ts +341 -0
  101. package/dist/index-BQutTphC.d.cts +790 -0
  102. package/dist/index-ByIq2XrS.d.cts +3910 -0
  103. package/dist/index-BysHjDSO.d.cts +224 -0
  104. package/dist/index-BysHjDSO.d.ts +224 -0
  105. package/dist/index-CKwAJGck.d.ts +455 -0
  106. package/dist/index-CUl3QstQ.d.cts +3006 -0
  107. package/dist/index-CUl3QstQ.d.ts +3006 -0
  108. package/dist/index-CmYtNiI-.d.cts +953 -0
  109. package/dist/index-CmYtNiI-.d.ts +953 -0
  110. package/dist/index-CnRzWxi_.d.cts +522 -0
  111. package/dist/index-CnRzWxi_.d.ts +522 -0
  112. package/dist/index-CwRWbSC7.d.ts +2921 -0
  113. package/dist/index-CxKIBstO.d.ts +790 -0
  114. package/dist/index-DJ6-R8vh.d.cts +455 -0
  115. package/dist/index-DQKisbcI.d.cts +4968 -0
  116. package/dist/index-DQKisbcI.d.ts +4968 -0
  117. package/dist/index-DRT2zJez.d.ts +3910 -0
  118. package/dist/index-DfNLiAka.d.cts +192 -0
  119. package/dist/index-DfNLiAka.d.ts +192 -0
  120. package/dist/index-nMvkoRm8.d.cts +405 -0
  121. package/dist/index-nMvkoRm8.d.ts +405 -0
  122. package/dist/index-s9yOFU37.d.cts +604 -0
  123. package/dist/index-s9yOFU37.d.ts +604 -0
  124. package/dist/index.cjs +22966 -6960
  125. package/dist/index.d.cts +864 -20
  126. package/dist/index.d.ts +864 -20
  127. package/dist/index.js +3062 -48
  128. package/dist/input/index.cjs +1 -1
  129. package/dist/input/index.js +1 -1
  130. package/dist/orbital/index.cjs +3 -3
  131. package/dist/orbital/index.d.cts +1 -1
  132. package/dist/orbital/index.d.ts +1 -1
  133. package/dist/orbital/index.js +1 -1
  134. package/dist/particles/index.cjs +16 -16
  135. package/dist/particles/index.d.cts +1 -1
  136. package/dist/particles/index.d.ts +1 -1
  137. package/dist/particles/index.js +1 -1
  138. package/dist/physics/index.cjs +2377 -21
  139. package/dist/physics/index.d.cts +1 -1
  140. package/dist/physics/index.d.ts +1 -1
  141. package/dist/physics/index.js +35 -1
  142. package/dist/postfx/index.cjs +3491 -0
  143. package/dist/postfx/index.js +93 -0
  144. package/dist/procedural/index.cjs +1 -1
  145. package/dist/procedural/index.js +1 -1
  146. package/dist/puppeteer-5VF6KDVO.js +52197 -0
  147. package/dist/puppeteer-IZVZ3SG4.js +52197 -0
  148. package/dist/rendering/index.cjs +33 -32
  149. package/dist/rendering/index.d.cts +1 -1
  150. package/dist/rendering/index.d.ts +1 -1
  151. package/dist/rendering/index.js +8 -6
  152. package/dist/runtime/index.cjs +23 -13
  153. package/dist/runtime/index.d.cts +1 -1
  154. package/dist/runtime/index.d.ts +1 -1
  155. package/dist/runtime/index.js +8 -6
  156. package/dist/runtime/protocols/index.cjs +349 -0
  157. package/dist/runtime/protocols/index.js +15 -0
  158. package/dist/scene/index.cjs +8 -8
  159. package/dist/scene/index.d.cts +1 -1
  160. package/dist/scene/index.d.ts +1 -1
  161. package/dist/scene/index.js +1 -1
  162. package/dist/shader/index.cjs +3087 -0
  163. package/dist/shader/index.js +3044 -0
  164. package/dist/simulation/index.cjs +10680 -0
  165. package/dist/simulation/index.d.cts +3 -0
  166. package/dist/simulation/index.d.ts +3 -0
  167. package/dist/simulation/index.js +307 -0
  168. package/dist/spatial/index.cjs +2443 -0
  169. package/dist/spatial/index.d.cts +1545 -0
  170. package/dist/spatial/index.d.ts +1545 -0
  171. package/dist/spatial/index.js +2400 -0
  172. package/dist/terrain/index.cjs +1 -1
  173. package/dist/terrain/index.d.cts +1 -1
  174. package/dist/terrain/index.d.ts +1 -1
  175. package/dist/terrain/index.js +1 -1
  176. package/dist/transformers.node-4NKAPD5U.js +45620 -0
  177. package/dist/vm/index.cjs +7 -8
  178. package/dist/vm/index.d.cts +1 -1
  179. package/dist/vm/index.d.ts +1 -1
  180. package/dist/vm/index.js +1 -1
  181. package/dist/vm-bridge/index.cjs +2 -2
  182. package/dist/vm-bridge/index.d.cts +2 -2
  183. package/dist/vm-bridge/index.d.ts +2 -2
  184. package/dist/vm-bridge/index.js +1 -1
  185. package/dist/vr/index.cjs +6 -6
  186. package/dist/vr/index.js +1 -1
  187. package/dist/world/index.cjs +3 -3
  188. package/dist/world/index.d.cts +1 -1
  189. package/dist/world/index.d.ts +1 -1
  190. package/dist/world/index.js +1 -1
  191. package/package.json +53 -21
  192. package/LICENSE +0 -21
@@ -0,0 +1,1257 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-AKLW2MUS.js";
4
+
5
+ // src/vm/index.ts
6
+ var vm_exports = {};
7
+ __export(vm_exports, {
8
+ AssetType: () => AssetType,
9
+ BodyType: () => BodyType,
10
+ ColliderShape: () => ColliderShape,
11
+ ComponentType: () => ComponentType,
12
+ ECSWorld: () => ECSWorld,
13
+ GeometryType: () => GeometryType,
14
+ HOLOB_MAGIC: () => HOLOB_MAGIC,
15
+ HOLOB_VERSION: () => HOLOB_VERSION,
16
+ HoloBytecodeBuilder: () => HoloBytecodeBuilder,
17
+ HoloFunctionBuilder: () => HoloFunctionBuilder,
18
+ HoloOpCode: () => HoloOpCode,
19
+ HoloVM: () => HoloVM,
20
+ HolobFlags: () => HolobFlags,
21
+ LightType: () => LightType,
22
+ SyncTier: () => SyncTier,
23
+ VMStatus: () => VMStatus,
24
+ ValueType: () => ValueType,
25
+ getOpcodeFamily: () => getOpcodeFamily,
26
+ getOpcodeName: () => getOpcodeName,
27
+ isControlFlow: () => isControlFlow
28
+ });
29
+
30
+ // src/vm/opcodes.ts
31
+ var HoloOpCode = /* @__PURE__ */ ((HoloOpCode2) => {
32
+ HoloOpCode2[HoloOpCode2["SPAWN"] = 1] = "SPAWN";
33
+ HoloOpCode2[HoloOpCode2["DESPAWN"] = 2] = "DESPAWN";
34
+ HoloOpCode2[HoloOpCode2["CLONE"] = 3] = "CLONE";
35
+ HoloOpCode2[HoloOpCode2["SET_COMPONENT"] = 4] = "SET_COMPONENT";
36
+ HoloOpCode2[HoloOpCode2["GET_COMPONENT"] = 5] = "GET_COMPONENT";
37
+ HoloOpCode2[HoloOpCode2["REMOVE_COMPONENT"] = 6] = "REMOVE_COMPONENT";
38
+ HoloOpCode2[HoloOpCode2["SET_PARENT"] = 7] = "SET_PARENT";
39
+ HoloOpCode2[HoloOpCode2["QUERY"] = 8] = "QUERY";
40
+ HoloOpCode2[HoloOpCode2["TRANSFORM"] = 16] = "TRANSFORM";
41
+ HoloOpCode2[HoloOpCode2["TRANSLATE"] = 17] = "TRANSLATE";
42
+ HoloOpCode2[HoloOpCode2["ROTATE"] = 18] = "ROTATE";
43
+ HoloOpCode2[HoloOpCode2["LOOK_AT"] = 19] = "LOOK_AT";
44
+ HoloOpCode2[HoloOpCode2["RAYCAST"] = 20] = "RAYCAST";
45
+ HoloOpCode2[HoloOpCode2["QUERY_BOX"] = 21] = "QUERY_BOX";
46
+ HoloOpCode2[HoloOpCode2["QUERY_SPHERE"] = 22] = "QUERY_SPHERE";
47
+ HoloOpCode2[HoloOpCode2["FIND_PATH"] = 23] = "FIND_PATH";
48
+ HoloOpCode2[HoloOpCode2["GET_ZONE"] = 24] = "GET_ZONE";
49
+ HoloOpCode2[HoloOpCode2["ADD_RIGIDBODY"] = 32] = "ADD_RIGIDBODY";
50
+ HoloOpCode2[HoloOpCode2["APPLY_FORCE"] = 33] = "APPLY_FORCE";
51
+ HoloOpCode2[HoloOpCode2["APPLY_IMPULSE"] = 34] = "APPLY_IMPULSE";
52
+ HoloOpCode2[HoloOpCode2["SET_VELOCITY"] = 35] = "SET_VELOCITY";
53
+ HoloOpCode2[HoloOpCode2["ADD_COLLIDER"] = 36] = "ADD_COLLIDER";
54
+ HoloOpCode2[HoloOpCode2["ADD_JOINT"] = 37] = "ADD_JOINT";
55
+ HoloOpCode2[HoloOpCode2["SET_GRAVITY"] = 38] = "SET_GRAVITY";
56
+ HoloOpCode2[HoloOpCode2["PHYSICS_STEP"] = 39] = "PHYSICS_STEP";
57
+ HoloOpCode2[HoloOpCode2["SET_GEOMETRY"] = 48] = "SET_GEOMETRY";
58
+ HoloOpCode2[HoloOpCode2["SET_MATERIAL"] = 49] = "SET_MATERIAL";
59
+ HoloOpCode2[HoloOpCode2["SET_VISIBLE"] = 50] = "SET_VISIBLE";
60
+ HoloOpCode2[HoloOpCode2["SET_LOD"] = 51] = "SET_LOD";
61
+ HoloOpCode2[HoloOpCode2["SET_LIGHT"] = 52] = "SET_LIGHT";
62
+ HoloOpCode2[HoloOpCode2["SET_ANIMATION"] = 53] = "SET_ANIMATION";
63
+ HoloOpCode2[HoloOpCode2["SET_GAUSSIAN_SPLAT"] = 54] = "SET_GAUSSIAN_SPLAT";
64
+ HoloOpCode2[HoloOpCode2["SET_PARTICLE_SYSTEM"] = 55] = "SET_PARTICLE_SYSTEM";
65
+ HoloOpCode2[HoloOpCode2["APPLY_TRAIT"] = 64] = "APPLY_TRAIT";
66
+ HoloOpCode2[HoloOpCode2["REMOVE_TRAIT"] = 65] = "REMOVE_TRAIT";
67
+ HoloOpCode2[HoloOpCode2["RESOLVE_TRAITS"] = 66] = "RESOLVE_TRAITS";
68
+ HoloOpCode2[HoloOpCode2["EMIT_EVENT"] = 67] = "EMIT_EVENT";
69
+ HoloOpCode2[HoloOpCode2["ON_EVENT"] = 68] = "ON_EVENT";
70
+ HoloOpCode2[HoloOpCode2["EVAL_CONDITION"] = 69] = "EVAL_CONDITION";
71
+ HoloOpCode2[HoloOpCode2["LOAD_ASSET"] = 80] = "LOAD_ASSET";
72
+ HoloOpCode2[HoloOpCode2["PLAY_AUDIO"] = 81] = "PLAY_AUDIO";
73
+ HoloOpCode2[HoloOpCode2["NET_SYNC"] = 82] = "NET_SYNC";
74
+ HoloOpCode2[HoloOpCode2["NET_SEND"] = 83] = "NET_SEND";
75
+ HoloOpCode2[HoloOpCode2["NET_RECV"] = 84] = "NET_RECV";
76
+ HoloOpCode2[HoloOpCode2["XR_INPUT"] = 85] = "XR_INPUT";
77
+ HoloOpCode2[HoloOpCode2["HAPTIC"] = 86] = "HAPTIC";
78
+ HoloOpCode2[HoloOpCode2["NOP"] = 96] = "NOP";
79
+ HoloOpCode2[HoloOpCode2["JUMP"] = 97] = "JUMP";
80
+ HoloOpCode2[HoloOpCode2["JUMP_IF"] = 98] = "JUMP_IF";
81
+ HoloOpCode2[HoloOpCode2["CALL"] = 99] = "CALL";
82
+ HoloOpCode2[HoloOpCode2["RETURN"] = 100] = "RETURN";
83
+ HoloOpCode2[HoloOpCode2["PUSH"] = 101] = "PUSH";
84
+ HoloOpCode2[HoloOpCode2["POP"] = 102] = "POP";
85
+ HoloOpCode2[HoloOpCode2["STORE"] = 103] = "STORE";
86
+ HoloOpCode2[HoloOpCode2["LOAD"] = 104] = "LOAD";
87
+ HoloOpCode2[HoloOpCode2["HALT"] = 105] = "HALT";
88
+ HoloOpCode2[HoloOpCode2["YIELD"] = 106] = "YIELD";
89
+ HoloOpCode2[HoloOpCode2["TIMER"] = 107] = "TIMER";
90
+ HoloOpCode2[HoloOpCode2["ADD"] = 108] = "ADD";
91
+ HoloOpCode2[HoloOpCode2["SUB"] = 109] = "SUB";
92
+ HoloOpCode2[HoloOpCode2["MUL"] = 110] = "MUL";
93
+ HoloOpCode2[HoloOpCode2["DIV"] = 111] = "DIV";
94
+ HoloOpCode2[HoloOpCode2["AGENT_INVOKE"] = 112] = "AGENT_INVOKE";
95
+ HoloOpCode2[HoloOpCode2["AGENT_READ"] = 113] = "AGENT_READ";
96
+ HoloOpCode2[HoloOpCode2["AGENT_SUBSCRIBE"] = 114] = "AGENT_SUBSCRIBE";
97
+ HoloOpCode2[HoloOpCode2["DIALOG_SHOW"] = 115] = "DIALOG_SHOW";
98
+ HoloOpCode2[HoloOpCode2["QUEST_UPDATE"] = 116] = "QUEST_UPDATE";
99
+ HoloOpCode2[HoloOpCode2["CMP_EQ"] = 128] = "CMP_EQ";
100
+ HoloOpCode2[HoloOpCode2["CMP_LT"] = 129] = "CMP_LT";
101
+ HoloOpCode2[HoloOpCode2["CMP_GT"] = 130] = "CMP_GT";
102
+ HoloOpCode2[HoloOpCode2["NOT"] = 131] = "NOT";
103
+ return HoloOpCode2;
104
+ })(HoloOpCode || {});
105
+ var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
106
+ ComponentType2[ComponentType2["Transform"] = 1] = "Transform";
107
+ ComponentType2[ComponentType2["Geometry"] = 2] = "Geometry";
108
+ ComponentType2[ComponentType2["Material"] = 3] = "Material";
109
+ ComponentType2[ComponentType2["RigidBody"] = 4] = "RigidBody";
110
+ ComponentType2[ComponentType2["Collider"] = 5] = "Collider";
111
+ ComponentType2[ComponentType2["Light"] = 6] = "Light";
112
+ ComponentType2[ComponentType2["Animation"] = 7] = "Animation";
113
+ ComponentType2[ComponentType2["Audio"] = 8] = "Audio";
114
+ ComponentType2[ComponentType2["Network"] = 9] = "Network";
115
+ ComponentType2[ComponentType2["Trait"] = 10] = "Trait";
116
+ ComponentType2[ComponentType2["ParticleSystem"] = 11] = "ParticleSystem";
117
+ ComponentType2[ComponentType2["GaussianSplat"] = 12] = "GaussianSplat";
118
+ ComponentType2[ComponentType2["LOD"] = 13] = "LOD";
119
+ ComponentType2[ComponentType2["Custom"] = 255] = "Custom";
120
+ return ComponentType2;
121
+ })(ComponentType || {});
122
+ var GeometryType = /* @__PURE__ */ ((GeometryType2) => {
123
+ GeometryType2[GeometryType2["Cube"] = 1] = "Cube";
124
+ GeometryType2[GeometryType2["Sphere"] = 2] = "Sphere";
125
+ GeometryType2[GeometryType2["Cylinder"] = 3] = "Cylinder";
126
+ GeometryType2[GeometryType2["Plane"] = 4] = "Plane";
127
+ GeometryType2[GeometryType2["Cone"] = 5] = "Cone";
128
+ GeometryType2[GeometryType2["Torus"] = 6] = "Torus";
129
+ GeometryType2[GeometryType2["Capsule"] = 7] = "Capsule";
130
+ GeometryType2[GeometryType2["Mesh"] = 8] = "Mesh";
131
+ GeometryType2[GeometryType2["Text3D"] = 9] = "Text3D";
132
+ GeometryType2[GeometryType2["Portal"] = 10] = "Portal";
133
+ GeometryType2[GeometryType2["Terrain"] = 11] = "Terrain";
134
+ GeometryType2[GeometryType2["Skybox"] = 12] = "Skybox";
135
+ GeometryType2[GeometryType2["Billboard"] = 13] = "Billboard";
136
+ GeometryType2[GeometryType2["Line"] = 14] = "Line";
137
+ return GeometryType2;
138
+ })(GeometryType || {});
139
+ var BodyType = /* @__PURE__ */ ((BodyType2) => {
140
+ BodyType2[BodyType2["Static"] = 0] = "Static";
141
+ BodyType2[BodyType2["Dynamic"] = 1] = "Dynamic";
142
+ BodyType2[BodyType2["Kinematic"] = 2] = "Kinematic";
143
+ return BodyType2;
144
+ })(BodyType || {});
145
+ var ColliderShape = /* @__PURE__ */ ((ColliderShape2) => {
146
+ ColliderShape2[ColliderShape2["Box"] = 1] = "Box";
147
+ ColliderShape2[ColliderShape2["Sphere"] = 2] = "Sphere";
148
+ ColliderShape2[ColliderShape2["Capsule"] = 3] = "Capsule";
149
+ ColliderShape2[ColliderShape2["Cylinder"] = 4] = "Cylinder";
150
+ ColliderShape2[ColliderShape2["ConvexHull"] = 5] = "ConvexHull";
151
+ ColliderShape2[ColliderShape2["TriMesh"] = 6] = "TriMesh";
152
+ return ColliderShape2;
153
+ })(ColliderShape || {});
154
+ var LightType = /* @__PURE__ */ ((LightType2) => {
155
+ LightType2[LightType2["Directional"] = 1] = "Directional";
156
+ LightType2[LightType2["Point"] = 2] = "Point";
157
+ LightType2[LightType2["Spot"] = 3] = "Spot";
158
+ LightType2[LightType2["Ambient"] = 4] = "Ambient";
159
+ LightType2[LightType2["Area"] = 5] = "Area";
160
+ return LightType2;
161
+ })(LightType || {});
162
+ var SyncTier = /* @__PURE__ */ ((SyncTier2) => {
163
+ SyncTier2[SyncTier2["Physics"] = 0] = "Physics";
164
+ SyncTier2[SyncTier2["Movement"] = 1] = "Movement";
165
+ SyncTier2[SyncTier2["AIAgent"] = 2] = "AIAgent";
166
+ SyncTier2[SyncTier2["Cosmetic"] = 3] = "Cosmetic";
167
+ return SyncTier2;
168
+ })(SyncTier || {});
169
+ var ValueType = /* @__PURE__ */ ((ValueType2) => {
170
+ ValueType2[ValueType2["Null"] = 0] = "Null";
171
+ ValueType2[ValueType2["Bool"] = 1] = "Bool";
172
+ ValueType2[ValueType2["I32"] = 2] = "I32";
173
+ ValueType2[ValueType2["F32"] = 3] = "F32";
174
+ ValueType2[ValueType2["F64"] = 4] = "F64";
175
+ ValueType2[ValueType2["String"] = 5] = "String";
176
+ ValueType2[ValueType2["Vec3"] = 6] = "Vec3";
177
+ ValueType2[ValueType2["Quat"] = 7] = "Quat";
178
+ ValueType2[ValueType2["EntityRef"] = 8] = "EntityRef";
179
+ ValueType2[ValueType2["Array"] = 9] = "Array";
180
+ return ValueType2;
181
+ })(ValueType || {});
182
+ var FAMILY_NAMES = {
183
+ 0: "Entity",
184
+ 1: "Spatial",
185
+ 2: "Physics",
186
+ 3: "Rendering",
187
+ 4: "Trait",
188
+ 5: "I/O",
189
+ 6: "Control",
190
+ 7: "Agent",
191
+ 8: "Comparison"
192
+ };
193
+ function getOpcodeFamily(opcode) {
194
+ const familyByte = opcode >> 4 & 15;
195
+ return FAMILY_NAMES[familyByte] ?? "Unknown";
196
+ }
197
+ function getOpcodeName(opcode) {
198
+ return HoloOpCode[opcode] ?? `UNKNOWN_0x${opcode.toString(16).padStart(2, "0")}`;
199
+ }
200
+ function isControlFlow(opcode) {
201
+ return opcode === 97 /* JUMP */ || opcode === 98 /* JUMP_IF */ || opcode === 99 /* CALL */ || opcode === 100 /* RETURN */ || opcode === 105 /* HALT */ || opcode === 106 /* YIELD */;
202
+ }
203
+
204
+ // src/vm/bytecode.ts
205
+ var HOLOB_MAGIC = 1213156418;
206
+ var HOLOB_VERSION = 1;
207
+ var HolobFlags = /* @__PURE__ */ ((HolobFlags2) => {
208
+ HolobFlags2[HolobFlags2["None"] = 0] = "None";
209
+ HolobFlags2[HolobFlags2["Debug"] = 1] = "Debug";
210
+ HolobFlags2[HolobFlags2["SIMD"] = 2] = "SIMD";
211
+ HolobFlags2[HolobFlags2["Threads"] = 4] = "Threads";
212
+ HolobFlags2[HolobFlags2["Networking"] = 8] = "Networking";
213
+ HolobFlags2[HolobFlags2["Physics"] = 16] = "Physics";
214
+ return HolobFlags2;
215
+ })(HolobFlags || {});
216
+ var AssetType = /* @__PURE__ */ ((AssetType2) => {
217
+ AssetType2[AssetType2["Mesh"] = 1] = "Mesh";
218
+ AssetType2[AssetType2["Texture"] = 2] = "Texture";
219
+ AssetType2[AssetType2["Audio"] = 3] = "Audio";
220
+ AssetType2[AssetType2["Animation"] = 4] = "Animation";
221
+ AssetType2[AssetType2["GaussianSplat"] = 5] = "GaussianSplat";
222
+ AssetType2[AssetType2["Font"] = 6] = "Font";
223
+ AssetType2[AssetType2["Script"] = 7] = "Script";
224
+ return AssetType2;
225
+ })(AssetType || {});
226
+ var HoloBytecodeBuilder = class {
227
+ strings = /* @__PURE__ */ new Map();
228
+ stringList = [];
229
+ assets = [];
230
+ traits = [];
231
+ functions = [];
232
+ entities = [];
233
+ events = [];
234
+ flags = 0 /* None */;
235
+ /**
236
+ * Intern a string and return its index
237
+ */
238
+ internString(str) {
239
+ const existing = this.strings.get(str);
240
+ if (existing !== void 0) return existing;
241
+ const idx = this.stringList.length;
242
+ this.stringList.push(str);
243
+ this.strings.set(str, idx);
244
+ return idx;
245
+ }
246
+ /**
247
+ * Add a feature flag
248
+ */
249
+ addFlag(flag) {
250
+ this.flags |= flag;
251
+ return this;
252
+ }
253
+ /**
254
+ * Add an asset reference
255
+ */
256
+ addAsset(uri, type) {
257
+ const idx = this.assets.length;
258
+ this.assets.push({ uriIndex: this.internString(uri), type });
259
+ return idx;
260
+ }
261
+ /**
262
+ * Add a trait definition
263
+ */
264
+ addTrait(name, deps = [], initFunc = -1) {
265
+ const idx = this.traits.length;
266
+ this.traits.push({
267
+ nameIndex: this.internString(name),
268
+ dependencies: deps,
269
+ initFunctionIndex: initFunc,
270
+ eventHandlers: /* @__PURE__ */ new Map()
271
+ });
272
+ return idx;
273
+ }
274
+ /**
275
+ * Begin building a function
276
+ */
277
+ addFunction(name, paramCount = 0) {
278
+ const idx = this.functions.length;
279
+ const fn = {
280
+ nameIndex: this.internString(name),
281
+ instructions: [],
282
+ registerCount: 0,
283
+ paramCount
284
+ };
285
+ this.functions.push(fn);
286
+ return new HoloFunctionBuilder(fn, this, idx);
287
+ }
288
+ /**
289
+ * Add an entity definition
290
+ */
291
+ addEntity(name, archetype = 0, parentIndex = -1) {
292
+ const idx = this.entities.length;
293
+ this.entities.push({
294
+ nameIndex: this.internString(name),
295
+ archetype,
296
+ components: [],
297
+ parentIndex
298
+ });
299
+ return idx;
300
+ }
301
+ /**
302
+ * Add component data to an entity
303
+ */
304
+ addComponentToEntity(entityIdx, componentType, values) {
305
+ this.entities[entityIdx].components.push({ componentType, values });
306
+ return this;
307
+ }
308
+ /**
309
+ * Add an event binding
310
+ */
311
+ addEvent(eventType, handlerFunctionIndex, entityFilter = -1) {
312
+ this.events.push({ eventType, handlerFunctionIndex, entityFilter });
313
+ return this;
314
+ }
315
+ /**
316
+ * Build the final bytecode module
317
+ */
318
+ build() {
319
+ return {
320
+ magic: HOLOB_MAGIC,
321
+ version: HOLOB_VERSION,
322
+ flags: this.flags,
323
+ strings: [...this.stringList],
324
+ assets: [...this.assets],
325
+ traits: [...this.traits],
326
+ functions: [...this.functions],
327
+ entities: [...this.entities],
328
+ events: [...this.events]
329
+ };
330
+ }
331
+ };
332
+ var HoloFunctionBuilder = class {
333
+ constructor(func, parent, index) {
334
+ this.func = func;
335
+ this.parent = parent;
336
+ this.index = index;
337
+ }
338
+ emit(opcode, ...operands) {
339
+ this.func.instructions.push({ opcode, operands });
340
+ return this;
341
+ }
342
+ // ── Entity ────────────────────────────────────────────────────────────────
343
+ spawn(entityType, name) {
344
+ return this.emit(1 /* SPAWN */, entityType, this.parent.internString(name));
345
+ }
346
+ despawn(entityId) {
347
+ return this.emit(2 /* DESPAWN */, entityId);
348
+ }
349
+ setComponent(entityId, compType, ...data) {
350
+ return this.emit(4 /* SET_COMPONENT */, entityId, compType, ...data);
351
+ }
352
+ getComponent(entityId, compType) {
353
+ return this.emit(5 /* GET_COMPONENT */, entityId, compType);
354
+ }
355
+ setParent(childId, parentId) {
356
+ return this.emit(7 /* SET_PARENT */, childId, parentId);
357
+ }
358
+ query(archetypeMask) {
359
+ return this.emit(8 /* QUERY */, archetypeMask);
360
+ }
361
+ // ── Spatial ───────────────────────────────────────────────────────────────
362
+ transform(entityId, x, y, z) {
363
+ return this.emit(16 /* TRANSFORM */, entityId, x, y, z, 0, 0, 0, 1, 1, 1, 1);
364
+ }
365
+ translate(entityId, dx, dy, dz) {
366
+ return this.emit(17 /* TRANSLATE */, entityId, dx, dy, dz);
367
+ }
368
+ rotate(entityId, qx, qy, qz, qw) {
369
+ return this.emit(18 /* ROTATE */, entityId, qx, qy, qz, qw);
370
+ }
371
+ lookAt(entityId, tx, ty, tz) {
372
+ return this.emit(19 /* LOOK_AT */, entityId, tx, ty, tz);
373
+ }
374
+ raycast(ox, oy, oz, dx, dy, dz, maxDist) {
375
+ return this.emit(20 /* RAYCAST */, ox, oy, oz, dx, dy, dz, maxDist);
376
+ }
377
+ // ── Physics ───────────────────────────────────────────────────────────────
378
+ addRigidbody(entityId, mass, bodyType) {
379
+ return this.emit(32 /* ADD_RIGIDBODY */, entityId, mass, bodyType);
380
+ }
381
+ applyForce(entityId, fx, fy, fz) {
382
+ return this.emit(33 /* APPLY_FORCE */, entityId, fx, fy, fz);
383
+ }
384
+ applyImpulse(entityId, ix, iy, iz) {
385
+ return this.emit(34 /* APPLY_IMPULSE */, entityId, ix, iy, iz);
386
+ }
387
+ setGravity(gx, gy, gz) {
388
+ return this.emit(38 /* SET_GRAVITY */, gx, gy, gz);
389
+ }
390
+ physicsStep(dt) {
391
+ return this.emit(39 /* PHYSICS_STEP */, dt);
392
+ }
393
+ // ── Rendering Hints ───────────────────────────────────────────────────────
394
+ setGeometry(entityId, geoType) {
395
+ return this.emit(48 /* SET_GEOMETRY */, entityId, geoType);
396
+ }
397
+ setMaterial(entityId, ...desc) {
398
+ return this.emit(49 /* SET_MATERIAL */, entityId, ...desc);
399
+ }
400
+ setVisible(entityId, visible) {
401
+ return this.emit(50 /* SET_VISIBLE */, entityId, visible ? 1 : 0);
402
+ }
403
+ setLight(entityId, lightType, ...params) {
404
+ return this.emit(52 /* SET_LIGHT */, entityId, lightType, ...params);
405
+ }
406
+ setAnimation(entityId, animId) {
407
+ return this.emit(53 /* SET_ANIMATION */, entityId, animId);
408
+ }
409
+ // ── Trait ─────────────────────────────────────────────────────────────────
410
+ applyTrait(entityId, traitId) {
411
+ return this.emit(64 /* APPLY_TRAIT */, entityId, traitId);
412
+ }
413
+ removeTrait(entityId, traitId) {
414
+ return this.emit(65 /* REMOVE_TRAIT */, entityId, traitId);
415
+ }
416
+ emitEvent(eventType, ...payload) {
417
+ return this.emit(67 /* EMIT_EVENT */, eventType, ...payload);
418
+ }
419
+ onEvent(eventType, handlerOffset) {
420
+ return this.emit(68 /* ON_EVENT */, eventType, handlerOffset);
421
+ }
422
+ // ── I/O ───────────────────────────────────────────────────────────────────
423
+ loadAsset(uri, assetType) {
424
+ return this.emit(80 /* LOAD_ASSET */, this.parent.internString(uri), assetType);
425
+ }
426
+ playAudio(soundId, x, y, z) {
427
+ return this.emit(81 /* PLAY_AUDIO */, soundId, x, y, z);
428
+ }
429
+ netSync(entityId, syncTier) {
430
+ return this.emit(82 /* NET_SYNC */, entityId, syncTier);
431
+ }
432
+ // ── Control Flow ──────────────────────────────────────────────────────────
433
+ nop() {
434
+ return this.emit(96 /* NOP */);
435
+ }
436
+ jump(offset) {
437
+ return this.emit(97 /* JUMP */, offset);
438
+ }
439
+ jumpIf(offset) {
440
+ return this.emit(98 /* JUMP_IF */, offset);
441
+ }
442
+ call(funcIdx) {
443
+ return this.emit(99 /* CALL */, funcIdx);
444
+ }
445
+ ret() {
446
+ return this.emit(100 /* RETURN */);
447
+ }
448
+ push(value) {
449
+ return this.emit(101 /* PUSH */, value);
450
+ }
451
+ pop() {
452
+ return this.emit(102 /* POP */);
453
+ }
454
+ store(registerIdx) {
455
+ this.func.registerCount = Math.max(this.func.registerCount, registerIdx + 1);
456
+ return this.emit(103 /* STORE */, registerIdx);
457
+ }
458
+ load(registerIdx) {
459
+ return this.emit(104 /* LOAD */, registerIdx);
460
+ }
461
+ halt() {
462
+ return this.emit(105 /* HALT */);
463
+ }
464
+ yieldTick() {
465
+ return this.emit(106 /* YIELD */);
466
+ }
467
+ timer(delayMs, handlerOffset) {
468
+ return this.emit(107 /* TIMER */, delayMs, handlerOffset);
469
+ }
470
+ // ── Arithmetic ────────────────────────────────────────────────────────────
471
+ add() {
472
+ return this.emit(108 /* ADD */);
473
+ }
474
+ sub() {
475
+ return this.emit(109 /* SUB */);
476
+ }
477
+ mul() {
478
+ return this.emit(110 /* MUL */);
479
+ }
480
+ div() {
481
+ return this.emit(111 /* DIV */);
482
+ }
483
+ // ── Comparison ────────────────────────────────────────────────────────────
484
+ cmpEq() {
485
+ return this.emit(128 /* CMP_EQ */);
486
+ }
487
+ cmpLt() {
488
+ return this.emit(129 /* CMP_LT */);
489
+ }
490
+ cmpGt() {
491
+ return this.emit(130 /* CMP_GT */);
492
+ }
493
+ not() {
494
+ return this.emit(131 /* NOT */);
495
+ }
496
+ // ── Agent Bridge ──────────────────────────────────────────────────────────
497
+ agentInvoke(agentId, actionIdx) {
498
+ return this.emit(112 /* AGENT_INVOKE */, agentId, actionIdx);
499
+ }
500
+ agentRead(agentId, fieldIdx) {
501
+ return this.emit(113 /* AGENT_READ */, agentId, fieldIdx);
502
+ }
503
+ dialogShow(npcId, dialogTreeId) {
504
+ return this.emit(115 /* DIALOG_SHOW */, npcId, dialogTreeId);
505
+ }
506
+ questUpdate(questId, state) {
507
+ return this.emit(116 /* QUEST_UPDATE */, questId, state);
508
+ }
509
+ /** Get the current instruction count (useful for jump targets) */
510
+ get instructionCount() {
511
+ return this.func.instructions.length;
512
+ }
513
+ };
514
+
515
+ // src/vm/executor.ts
516
+ var ECSWorld = class {
517
+ entities = /* @__PURE__ */ new Map();
518
+ nextEntityId = 1;
519
+ archetypeIndex = /* @__PURE__ */ new Map();
520
+ /**
521
+ * Spawn a new entity
522
+ */
523
+ spawn(name, archetype = 0) {
524
+ const id = this.nextEntityId++;
525
+ const entity = {
526
+ id,
527
+ name,
528
+ parentId: -1,
529
+ childIds: [],
530
+ components: /* @__PURE__ */ new Map(),
531
+ traits: /* @__PURE__ */ new Set(),
532
+ alive: true,
533
+ dirty: true
534
+ };
535
+ this.entities.set(id, entity);
536
+ if (!this.archetypeIndex.has(archetype)) {
537
+ this.archetypeIndex.set(archetype, /* @__PURE__ */ new Set());
538
+ }
539
+ this.archetypeIndex.get(archetype).add(id);
540
+ return id;
541
+ }
542
+ /**
543
+ * Despawn an entity and its children
544
+ */
545
+ despawn(entityId) {
546
+ const entity = this.entities.get(entityId);
547
+ if (!entity) return false;
548
+ for (const childId of [...entity.childIds]) {
549
+ this.despawn(childId);
550
+ }
551
+ if (entity.parentId !== -1) {
552
+ const parent = this.entities.get(entity.parentId);
553
+ if (parent) {
554
+ parent.childIds = parent.childIds.filter((id) => id !== entityId);
555
+ }
556
+ }
557
+ entity.alive = false;
558
+ this.entities.delete(entityId);
559
+ return true;
560
+ }
561
+ /**
562
+ * Set a component on an entity
563
+ */
564
+ setComponent(entityId, componentType, data) {
565
+ const entity = this.entities.get(entityId);
566
+ if (!entity) return false;
567
+ entity.components.set(componentType, data);
568
+ entity.dirty = true;
569
+ return true;
570
+ }
571
+ /**
572
+ * Get a component from an entity
573
+ */
574
+ getComponent(entityId, componentType) {
575
+ const entity = this.entities.get(entityId);
576
+ if (!entity) return void 0;
577
+ return entity.components.get(componentType);
578
+ }
579
+ /**
580
+ * Remove a component from an entity
581
+ */
582
+ removeComponent(entityId, componentType) {
583
+ const entity = this.entities.get(entityId);
584
+ if (!entity) return false;
585
+ entity.dirty = true;
586
+ return entity.components.delete(componentType);
587
+ }
588
+ /**
589
+ * Set parent-child relationship
590
+ */
591
+ setParent(childId, parentId) {
592
+ const child = this.entities.get(childId);
593
+ const parent = this.entities.get(parentId);
594
+ if (!child || !parent) return false;
595
+ if (child.parentId !== -1) {
596
+ const oldParent = this.entities.get(child.parentId);
597
+ if (oldParent) {
598
+ oldParent.childIds = oldParent.childIds.filter((id) => id !== childId);
599
+ }
600
+ }
601
+ child.parentId = parentId;
602
+ parent.childIds.push(childId);
603
+ child.dirty = true;
604
+ return true;
605
+ }
606
+ /**
607
+ * Query entities by archetype mask
608
+ */
609
+ queryArchetype(mask) {
610
+ const set = this.archetypeIndex.get(mask);
611
+ return set ? [...set] : [];
612
+ }
613
+ /**
614
+ * Get entity by ID
615
+ */
616
+ getEntity(entityId) {
617
+ return this.entities.get(entityId);
618
+ }
619
+ /**
620
+ * Get all dirty entities and clear dirty flags
621
+ */
622
+ flushDirty() {
623
+ const dirty = [];
624
+ for (const entity of this.entities.values()) {
625
+ if (entity.dirty) {
626
+ dirty.push(entity);
627
+ entity.dirty = false;
628
+ }
629
+ }
630
+ return dirty;
631
+ }
632
+ /**
633
+ * Get all living entities
634
+ */
635
+ getAllEntities() {
636
+ return [...this.entities.values()];
637
+ }
638
+ /**
639
+ * Get entity count
640
+ */
641
+ get entityCount() {
642
+ return this.entities.size;
643
+ }
644
+ };
645
+ var VMStatus = /* @__PURE__ */ ((VMStatus2) => {
646
+ VMStatus2["Idle"] = "IDLE";
647
+ VMStatus2["Running"] = "RUNNING";
648
+ VMStatus2["Yielded"] = "YIELDED";
649
+ VMStatus2["Halted"] = "HALTED";
650
+ VMStatus2["Error"] = "ERROR";
651
+ return VMStatus2;
652
+ })(VMStatus || {});
653
+ var HoloVM = class {
654
+ // Core state
655
+ bytecode = null;
656
+ world = new ECSWorld();
657
+ // Execution state
658
+ stack = [];
659
+ callStack = [];
660
+ status = "IDLE" /* Idle */;
661
+ tickCount = 0;
662
+ // Timer system
663
+ timers = [];
664
+ currentTimeMs = 0;
665
+ // Event queue
666
+ eventQueue = [];
667
+ // Limits
668
+ maxStackSize = 4096;
669
+ maxCallDepth = 256;
670
+ maxInstructionsPerTick = 1e4;
671
+ /**
672
+ * Load a bytecode module into the VM
673
+ */
674
+ load(bytecode) {
675
+ this.bytecode = bytecode;
676
+ this.reset();
677
+ this.initializeEntities();
678
+ }
679
+ /**
680
+ * Reset VM state without unloading bytecode
681
+ */
682
+ reset() {
683
+ this.stack = [];
684
+ this.callStack = [];
685
+ this.status = "IDLE" /* Idle */;
686
+ this.tickCount = 0;
687
+ this.timers = [];
688
+ this.currentTimeMs = 0;
689
+ this.eventQueue = [];
690
+ }
691
+ /**
692
+ * Initialize entities from the bytecode's init section
693
+ */
694
+ initializeEntities() {
695
+ if (!this.bytecode) return;
696
+ for (const entityDef of this.bytecode.entities) {
697
+ const name = this.bytecode.strings[entityDef.nameIndex] ?? `entity_${entityDef.nameIndex}`;
698
+ const entityId = this.world.spawn(name, entityDef.archetype);
699
+ for (const comp of entityDef.components) {
700
+ this.world.setComponent(entityId, comp.componentType, comp.values);
701
+ }
702
+ if (entityDef.parentIndex >= 0) {
703
+ this.world.setParent(entityId, entityDef.parentIndex + 1);
704
+ }
705
+ }
706
+ }
707
+ /**
708
+ * Execute one tick of the VM (called at ~90fps)
709
+ *
710
+ * Each tick:
711
+ * 1. Process expired timers
712
+ * 2. Dispatch queued events
713
+ * 3. Resume execution from yield point (or run init)
714
+ * 4. Return dirty entities for rendering
715
+ */
716
+ tick(deltaMs) {
717
+ if (!this.bytecode) {
718
+ return {
719
+ status: "ERROR" /* Error */,
720
+ stackTop: null,
721
+ tickCount: this.tickCount,
722
+ entityCount: 0,
723
+ error: "No bytecode loaded"
724
+ };
725
+ }
726
+ this.tickCount++;
727
+ this.currentTimeMs += deltaMs;
728
+ this.processTimers();
729
+ this.dispatchEvents();
730
+ if (this.status === "YIELDED" /* Yielded */) {
731
+ this.status = "RUNNING" /* Running */;
732
+ this.executeInstructions();
733
+ } else if (this.status === "IDLE" /* Idle */ && this.bytecode.functions.length > 0) {
734
+ this.callFunction(0);
735
+ this.executeInstructions();
736
+ }
737
+ return {
738
+ status: this.status,
739
+ stackTop: this.stack.length > 0 ? this.stack[this.stack.length - 1] : null,
740
+ tickCount: this.tickCount,
741
+ entityCount: this.world.entityCount
742
+ };
743
+ }
744
+ /**
745
+ * Main execution loop — runs until YIELD, HALT, or instruction limit
746
+ */
747
+ executeInstructions() {
748
+ if (!this.bytecode) return;
749
+ let instructionsExecuted = 0;
750
+ while (this.status === "RUNNING" /* Running */ && instructionsExecuted < this.maxInstructionsPerTick) {
751
+ const frame = this.currentFrame;
752
+ if (!frame) {
753
+ this.status = "HALTED" /* Halted */;
754
+ break;
755
+ }
756
+ const func = this.bytecode.functions[frame.functionIndex];
757
+ if (!func || frame.pc >= func.instructions.length) {
758
+ this.callStack.pop();
759
+ if (this.callStack.length === 0) {
760
+ this.status = "HALTED" /* Halted */;
761
+ }
762
+ break;
763
+ }
764
+ const instr = func.instructions[frame.pc];
765
+ frame.pc++;
766
+ instructionsExecuted++;
767
+ try {
768
+ this.executeInstruction(instr, frame);
769
+ } catch (_err) {
770
+ this.status = "ERROR" /* Error */;
771
+ break;
772
+ }
773
+ if (this.status !== "RUNNING" /* Running */) break;
774
+ }
775
+ }
776
+ /**
777
+ * Execute a single instruction
778
+ */
779
+ executeInstruction(instr, frame) {
780
+ const op = instr.opcode;
781
+ const operands = instr.operands;
782
+ switch (op) {
783
+ // ── Entity Operations ───────────────────────────────────────────────
784
+ case 1 /* SPAWN */: {
785
+ const entityType = operands[0];
786
+ const nameIdx = operands[1];
787
+ const name = this.getString(nameIdx);
788
+ const id = this.world.spawn(name, entityType);
789
+ this.push(id);
790
+ break;
791
+ }
792
+ case 2 /* DESPAWN */: {
793
+ const entityId = operands[0];
794
+ this.world.despawn(entityId);
795
+ break;
796
+ }
797
+ case 4 /* SET_COMPONENT */: {
798
+ const entityId = operands[0];
799
+ const compType = operands[1];
800
+ const data = operands.slice(2);
801
+ this.world.setComponent(entityId, compType, data);
802
+ break;
803
+ }
804
+ case 5 /* GET_COMPONENT */: {
805
+ const entityId = operands[0];
806
+ const compType = operands[1];
807
+ const data = this.world.getComponent(entityId, compType);
808
+ this.push(data ?? null);
809
+ break;
810
+ }
811
+ case 6 /* REMOVE_COMPONENT */: {
812
+ const entityId = operands[0];
813
+ const compType = operands[1];
814
+ this.world.removeComponent(entityId, compType);
815
+ break;
816
+ }
817
+ case 7 /* SET_PARENT */: {
818
+ const childId = operands[0];
819
+ const parentId = operands[1];
820
+ this.world.setParent(childId, parentId);
821
+ break;
822
+ }
823
+ case 8 /* QUERY */: {
824
+ const mask = operands[0];
825
+ const entities = this.world.queryArchetype(mask);
826
+ this.push(entities);
827
+ break;
828
+ }
829
+ // ── Spatial Operations ──────────────────────────────────────────────
830
+ case 16 /* TRANSFORM */: {
831
+ const entityId = operands[0];
832
+ const transform = {
833
+ position: {
834
+ x: operands[1],
835
+ y: operands[2],
836
+ z: operands[3]
837
+ },
838
+ rotation: {
839
+ x: operands[4],
840
+ y: operands[5],
841
+ z: operands[6],
842
+ w: operands[7]
843
+ },
844
+ scale: { x: operands[8], y: operands[9], z: operands[10] }
845
+ };
846
+ this.world.setComponent(entityId, 1 /* Transform */, transform);
847
+ break;
848
+ }
849
+ case 17 /* TRANSLATE */: {
850
+ const entityId = operands[0];
851
+ const existing = this.world.getComponent(
852
+ entityId,
853
+ 1 /* Transform */
854
+ );
855
+ if (existing) {
856
+ existing.position.x += operands[1];
857
+ existing.position.y += operands[2];
858
+ existing.position.z += operands[3];
859
+ this.world.setComponent(entityId, 1 /* Transform */, existing);
860
+ }
861
+ break;
862
+ }
863
+ case 18 /* ROTATE */: {
864
+ const entityId = operands[0];
865
+ this.world.setComponent(entityId, 1 /* Transform */, {
866
+ position: { x: 0, y: 0, z: 0 },
867
+ rotation: {
868
+ x: operands[1],
869
+ y: operands[2],
870
+ z: operands[3],
871
+ w: operands[4]
872
+ },
873
+ scale: { x: 1, y: 1, z: 1 }
874
+ });
875
+ break;
876
+ }
877
+ case 48 /* SET_GEOMETRY */: {
878
+ const entityId = operands[0];
879
+ const geoType = operands[1];
880
+ this.world.setComponent(entityId, 2 /* Geometry */, { type: geoType, params: {} });
881
+ break;
882
+ }
883
+ case 49 /* SET_MATERIAL */: {
884
+ const entityId = operands[0];
885
+ const material = {
886
+ color: operands[1] ?? 16777215,
887
+ metalness: operands[2] ?? 0,
888
+ roughness: operands[3] ?? 0.5,
889
+ emissive: operands[4] ?? 0,
890
+ opacity: operands[5] ?? 1
891
+ };
892
+ this.world.setComponent(entityId, 3 /* Material */, material);
893
+ break;
894
+ }
895
+ case 50 /* SET_VISIBLE */: {
896
+ const entityId = operands[0];
897
+ const _visible = operands[1] !== 0;
898
+ const entity = this.world.getEntity(entityId);
899
+ if (entity) entity.dirty = true;
900
+ break;
901
+ }
902
+ case 52 /* SET_LIGHT */: {
903
+ const entityId = operands[0];
904
+ const lightType = operands[1];
905
+ this.world.setComponent(entityId, 6 /* Light */, {
906
+ type: lightType,
907
+ params: operands.slice(2)
908
+ });
909
+ break;
910
+ }
911
+ // ── Physics Operations ──────────────────────────────────────────────
912
+ case 32 /* ADD_RIGIDBODY */: {
913
+ const entityId = operands[0];
914
+ const rb = {
915
+ mass: operands[1],
916
+ bodyType: operands[2],
917
+ velocity: { x: 0, y: 0, z: 0 },
918
+ angularVelocity: { x: 0, y: 0, z: 0 }
919
+ };
920
+ this.world.setComponent(entityId, 4 /* RigidBody */, rb);
921
+ break;
922
+ }
923
+ case 33 /* APPLY_FORCE */: {
924
+ const entityId = operands[0];
925
+ const rb = this.world.getComponent(entityId, 4 /* RigidBody */);
926
+ if (rb && rb.mass > 0) {
927
+ const dt = 1 / 90;
928
+ rb.velocity.x += operands[1] / rb.mass * dt;
929
+ rb.velocity.y += operands[2] / rb.mass * dt;
930
+ rb.velocity.z += operands[3] / rb.mass * dt;
931
+ this.world.setComponent(entityId, 4 /* RigidBody */, rb);
932
+ }
933
+ break;
934
+ }
935
+ case 34 /* APPLY_IMPULSE */: {
936
+ const entityId = operands[0];
937
+ const rb = this.world.getComponent(entityId, 4 /* RigidBody */);
938
+ if (rb && rb.mass > 0) {
939
+ rb.velocity.x += operands[1] / rb.mass;
940
+ rb.velocity.y += operands[2] / rb.mass;
941
+ rb.velocity.z += operands[3] / rb.mass;
942
+ this.world.setComponent(entityId, 4 /* RigidBody */, rb);
943
+ }
944
+ break;
945
+ }
946
+ case 35 /* SET_VELOCITY */: {
947
+ const entityId = operands[0];
948
+ const rb = this.world.getComponent(entityId, 4 /* RigidBody */);
949
+ if (rb) {
950
+ rb.velocity = {
951
+ x: operands[1],
952
+ y: operands[2],
953
+ z: operands[3]
954
+ };
955
+ this.world.setComponent(entityId, 4 /* RigidBody */, rb);
956
+ }
957
+ break;
958
+ }
959
+ case 38 /* SET_GRAVITY */: {
960
+ this.world.setComponent(0, 255, { x: operands[0], y: operands[1], z: operands[2] });
961
+ break;
962
+ }
963
+ // ── Trait Operations ────────────────────────────────────────────────
964
+ case 64 /* APPLY_TRAIT */: {
965
+ const entityId = operands[0];
966
+ const traitId = operands[1];
967
+ const entity = this.world.getEntity(entityId);
968
+ if (entity) {
969
+ entity.traits.add(traitId);
970
+ entity.dirty = true;
971
+ }
972
+ break;
973
+ }
974
+ case 65 /* REMOVE_TRAIT */: {
975
+ const entityId = operands[0];
976
+ const traitId = operands[1];
977
+ const entity = this.world.getEntity(entityId);
978
+ if (entity) {
979
+ entity.traits.delete(traitId);
980
+ entity.dirty = true;
981
+ }
982
+ break;
983
+ }
984
+ case 67 /* EMIT_EVENT */: {
985
+ const eventType = operands[0];
986
+ const payload = operands.slice(1);
987
+ this.eventQueue.push({ eventType, payload });
988
+ break;
989
+ }
990
+ // ── Control Flow ────────────────────────────────────────────────────
991
+ case 96 /* NOP */:
992
+ break;
993
+ case 97 /* JUMP */: {
994
+ frame.pc = operands[0];
995
+ break;
996
+ }
997
+ case 98 /* JUMP_IF */: {
998
+ const condition = this.pop();
999
+ if (condition) {
1000
+ frame.pc = operands[0];
1001
+ }
1002
+ break;
1003
+ }
1004
+ case 99 /* CALL */: {
1005
+ const funcIdx = operands[0];
1006
+ this.callFunction(funcIdx);
1007
+ break;
1008
+ }
1009
+ case 100 /* RETURN */: {
1010
+ this.callStack.pop();
1011
+ if (this.callStack.length === 0) {
1012
+ this.status = "HALTED" /* Halted */;
1013
+ }
1014
+ break;
1015
+ }
1016
+ case 101 /* PUSH */: {
1017
+ this.push(operands[0]);
1018
+ break;
1019
+ }
1020
+ case 102 /* POP */: {
1021
+ this.pop();
1022
+ break;
1023
+ }
1024
+ case 103 /* STORE */: {
1025
+ const regIdx = operands[0];
1026
+ const value = this.pop();
1027
+ if (regIdx < frame.registers.length) {
1028
+ frame.registers[regIdx] = value;
1029
+ }
1030
+ break;
1031
+ }
1032
+ case 104 /* LOAD */: {
1033
+ const regIdx = operands[0];
1034
+ if (regIdx < frame.registers.length) {
1035
+ this.push(frame.registers[regIdx]);
1036
+ } else {
1037
+ this.push(null);
1038
+ }
1039
+ break;
1040
+ }
1041
+ case 105 /* HALT */: {
1042
+ this.status = "HALTED" /* Halted */;
1043
+ break;
1044
+ }
1045
+ case 106 /* YIELD */: {
1046
+ this.status = "YIELDED" /* Yielded */;
1047
+ break;
1048
+ }
1049
+ case 107 /* TIMER */: {
1050
+ const delayMs = operands[0];
1051
+ const handlerFunc = operands[1];
1052
+ this.timers.push({
1053
+ triggerTimeMs: this.currentTimeMs + delayMs,
1054
+ handlerFunctionIndex: handlerFunc
1055
+ });
1056
+ break;
1057
+ }
1058
+ // ── Arithmetic ──────────────────────────────────────────────────────
1059
+ case 108 /* ADD */: {
1060
+ const b = this.pop();
1061
+ const a = this.pop();
1062
+ this.push((a ?? 0) + (b ?? 0));
1063
+ break;
1064
+ }
1065
+ case 109 /* SUB */: {
1066
+ const b = this.pop();
1067
+ const a = this.pop();
1068
+ this.push((a ?? 0) - (b ?? 0));
1069
+ break;
1070
+ }
1071
+ case 110 /* MUL */: {
1072
+ const b = this.pop();
1073
+ const a = this.pop();
1074
+ this.push((a ?? 0) * (b ?? 0));
1075
+ break;
1076
+ }
1077
+ case 111 /* DIV */: {
1078
+ const b = this.pop();
1079
+ const a = this.pop();
1080
+ this.push(b !== 0 ? (a ?? 0) / b : 0);
1081
+ break;
1082
+ }
1083
+ // ── Comparison ──────────────────────────────────────────────────────
1084
+ case 128 /* CMP_EQ */: {
1085
+ const b = this.pop();
1086
+ const a = this.pop();
1087
+ this.push(a === b ? 1 : 0);
1088
+ break;
1089
+ }
1090
+ case 129 /* CMP_LT */: {
1091
+ const b = this.pop();
1092
+ const a = this.pop();
1093
+ this.push(a < b ? 1 : 0);
1094
+ break;
1095
+ }
1096
+ case 130 /* CMP_GT */: {
1097
+ const b = this.pop();
1098
+ const a = this.pop();
1099
+ this.push(a > b ? 1 : 0);
1100
+ break;
1101
+ }
1102
+ case 131 /* NOT */: {
1103
+ const val = this.pop();
1104
+ this.push(val ? 0 : 1);
1105
+ break;
1106
+ }
1107
+ // ── Agent Bridge (stubs — filled in by host integration) ────────────
1108
+ case 112 /* AGENT_INVOKE */:
1109
+ case 113 /* AGENT_READ */:
1110
+ case 114 /* AGENT_SUBSCRIBE */:
1111
+ case 115 /* DIALOG_SHOW */:
1112
+ case 116 /* QUEST_UPDATE */:
1113
+ this.push(null);
1114
+ break;
1115
+ // ── I/O (stubs — filled in by host integration) ─────────────────────
1116
+ case 80 /* LOAD_ASSET */:
1117
+ case 81 /* PLAY_AUDIO */:
1118
+ case 82 /* NET_SYNC */:
1119
+ case 83 /* NET_SEND */:
1120
+ case 84 /* NET_RECV */:
1121
+ case 85 /* XR_INPUT */:
1122
+ case 86 /* HAPTIC */:
1123
+ this.push(null);
1124
+ break;
1125
+ // ── Spatial queries (stubs — need spatial index) ─────────────────────
1126
+ case 20 /* RAYCAST */:
1127
+ case 21 /* QUERY_BOX */:
1128
+ case 22 /* QUERY_SPHERE */:
1129
+ case 23 /* FIND_PATH */:
1130
+ case 24 /* GET_ZONE */:
1131
+ this.push(null);
1132
+ break;
1133
+ default:
1134
+ break;
1135
+ }
1136
+ }
1137
+ // ── Stack operations ──────────────────────────────────────────────────────
1138
+ push(value) {
1139
+ if (this.stack.length >= this.maxStackSize) {
1140
+ this.status = "ERROR" /* Error */;
1141
+ return;
1142
+ }
1143
+ this.stack.push(value);
1144
+ }
1145
+ pop() {
1146
+ return this.stack.pop() ?? null;
1147
+ }
1148
+ // ── Call frame management ─────────────────────────────────────────────────
1149
+ get currentFrame() {
1150
+ return this.callStack[this.callStack.length - 1];
1151
+ }
1152
+ callFunction(funcIdx) {
1153
+ if (!this.bytecode) return;
1154
+ if (this.callStack.length >= this.maxCallDepth) {
1155
+ this.status = "ERROR" /* Error */;
1156
+ return;
1157
+ }
1158
+ const func = this.bytecode.functions[funcIdx];
1159
+ if (!func) {
1160
+ this.status = "ERROR" /* Error */;
1161
+ return;
1162
+ }
1163
+ const frame = {
1164
+ functionIndex: funcIdx,
1165
+ pc: 0,
1166
+ registers: new Array(func.registerCount).fill(null),
1167
+ stackBase: this.stack.length
1168
+ };
1169
+ this.callStack.push(frame);
1170
+ this.status = "RUNNING" /* Running */;
1171
+ }
1172
+ // ── Timer processing ──────────────────────────────────────────────────────
1173
+ processTimers() {
1174
+ const expired = [];
1175
+ this.timers = this.timers.filter((t) => {
1176
+ if (t.triggerTimeMs <= this.currentTimeMs) {
1177
+ expired.push(t);
1178
+ return false;
1179
+ }
1180
+ return true;
1181
+ });
1182
+ for (const timer of expired) {
1183
+ this.callFunction(timer.handlerFunctionIndex);
1184
+ this.executeInstructions();
1185
+ }
1186
+ }
1187
+ // ── Event dispatch ────────────────────────────────────────────────────────
1188
+ dispatchEvents() {
1189
+ if (!this.bytecode) return;
1190
+ const events = [...this.eventQueue];
1191
+ this.eventQueue = [];
1192
+ for (const event of events) {
1193
+ for (const binding of this.bytecode.events) {
1194
+ if (binding.eventType === event.eventType) {
1195
+ for (const p of event.payload) {
1196
+ this.push(p);
1197
+ }
1198
+ this.callFunction(binding.handlerFunctionIndex);
1199
+ this.executeInstructions();
1200
+ }
1201
+ }
1202
+ }
1203
+ }
1204
+ // ── Utility ───────────────────────────────────────────────────────────────
1205
+ getString(index) {
1206
+ if (!this.bytecode) return "";
1207
+ return this.bytecode.strings[index] ?? `str_${index}`;
1208
+ }
1209
+ /**
1210
+ * Get current VM status
1211
+ */
1212
+ getStatus() {
1213
+ return this.status;
1214
+ }
1215
+ /**
1216
+ * Get current stack snapshot (for debugging)
1217
+ */
1218
+ getStack() {
1219
+ return [...this.stack];
1220
+ }
1221
+ /**
1222
+ * Get the tick count
1223
+ */
1224
+ getTickCount() {
1225
+ return this.tickCount;
1226
+ }
1227
+ /**
1228
+ * Queue an external event (e.g., from user input or network)
1229
+ */
1230
+ queueEvent(eventType, ...payload) {
1231
+ this.eventQueue.push({ eventType, payload });
1232
+ }
1233
+ };
1234
+
1235
+ export {
1236
+ HoloOpCode,
1237
+ ComponentType,
1238
+ GeometryType,
1239
+ BodyType,
1240
+ ColliderShape,
1241
+ LightType,
1242
+ SyncTier,
1243
+ ValueType,
1244
+ getOpcodeFamily,
1245
+ getOpcodeName,
1246
+ isControlFlow,
1247
+ HOLOB_MAGIC,
1248
+ HOLOB_VERSION,
1249
+ HolobFlags,
1250
+ AssetType,
1251
+ HoloBytecodeBuilder,
1252
+ HoloFunctionBuilder,
1253
+ ECSWorld,
1254
+ VMStatus,
1255
+ HoloVM,
1256
+ vm_exports
1257
+ };