@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,223 @@
1
+ // src/gpu/GPUBuffers.ts
2
+ var GPUBufferManager = class {
3
+ context;
4
+ device;
5
+ particleCount;
6
+ buffers = null;
7
+ // Buffer sizes (in bytes)
8
+ positionBufferSize;
9
+ velocityBufferSize;
10
+ stateBufferSize;
11
+ uniformBufferSize;
12
+ constructor(context, particleCount) {
13
+ this.context = context;
14
+ this.device = context.getDevice();
15
+ this.particleCount = particleCount;
16
+ this.positionBufferSize = particleCount * 4 * Float32Array.BYTES_PER_ELEMENT;
17
+ this.velocityBufferSize = particleCount * 4 * Float32Array.BYTES_PER_ELEMENT;
18
+ this.stateBufferSize = particleCount * 4 * Float32Array.BYTES_PER_ELEMENT;
19
+ this.uniformBufferSize = 32;
20
+ }
21
+ /**
22
+ * Initialize GPU buffers
23
+ */
24
+ async initialize() {
25
+ const positionsRead = this.createStorageBuffer(this.positionBufferSize, "positions-read");
26
+ const positionsWrite = this.createStorageBuffer(this.positionBufferSize, "positions-write");
27
+ const velocitiesRead = this.createStorageBuffer(this.velocityBufferSize, "velocities-read");
28
+ const velocitiesWrite = this.createStorageBuffer(this.velocityBufferSize, "velocities-write");
29
+ const statesRead = this.createStorageBuffer(this.stateBufferSize, "states-read");
30
+ const statesWrite = this.createStorageBuffer(this.stateBufferSize, "states-write");
31
+ const uniforms = this.device.createBuffer({
32
+ label: "uniforms",
33
+ size: this.uniformBufferSize,
34
+ usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
35
+ });
36
+ this.buffers = {
37
+ positionsRead,
38
+ positionsWrite,
39
+ velocitiesRead,
40
+ velocitiesWrite,
41
+ statesRead,
42
+ statesWrite,
43
+ uniforms
44
+ };
45
+ }
46
+ /**
47
+ * Create a storage buffer
48
+ */
49
+ createStorageBuffer(size, label) {
50
+ return this.device.createBuffer({
51
+ label,
52
+ size,
53
+ usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
54
+ });
55
+ }
56
+ /**
57
+ * Upload particle data to GPU
58
+ */
59
+ uploadParticleData(data) {
60
+ if (!this.buffers) {
61
+ throw new Error("Buffers not initialized. Call initialize() first.");
62
+ }
63
+ this.device.queue.writeBuffer(this.buffers.positionsRead, 0, data.positions.buffer);
64
+ this.device.queue.writeBuffer(this.buffers.velocitiesRead, 0, data.velocities.buffer);
65
+ this.device.queue.writeBuffer(this.buffers.statesRead, 0, data.states.buffer);
66
+ }
67
+ /**
68
+ * Upload uniform data (simulation parameters)
69
+ */
70
+ uploadUniformData(uniforms) {
71
+ if (!this.buffers) {
72
+ throw new Error("Buffers not initialized");
73
+ }
74
+ const data = new Float32Array([
75
+ uniforms.dt,
76
+ uniforms.gravity,
77
+ uniforms.groundY,
78
+ uniforms.restitution,
79
+ uniforms.friction,
80
+ uniforms.particleCount,
81
+ uniforms._pad1 ?? 0,
82
+ uniforms._pad2 ?? 0
83
+ ]);
84
+ this.device.queue.writeBuffer(this.buffers.uniforms, 0, data.buffer);
85
+ }
86
+ /**
87
+ * Download particle data from GPU (for rendering or analysis)
88
+ *
89
+ * Note: This is an async operation that stalls the pipeline.
90
+ * Use sparingly (e.g., once per frame for rendering).
91
+ */
92
+ async downloadParticleData() {
93
+ if (!this.buffers) {
94
+ throw new Error("Buffers not initialized");
95
+ }
96
+ const positionsStaging = this.createStagingBuffer(this.positionBufferSize);
97
+ const velocitiesStaging = this.createStagingBuffer(this.velocityBufferSize);
98
+ const statesStaging = this.createStagingBuffer(this.stateBufferSize);
99
+ const commandEncoder = this.device.createCommandEncoder({ label: "readback-encoder" });
100
+ commandEncoder.copyBufferToBuffer(
101
+ this.buffers.positionsRead,
102
+ 0,
103
+ positionsStaging,
104
+ 0,
105
+ this.positionBufferSize
106
+ );
107
+ commandEncoder.copyBufferToBuffer(
108
+ this.buffers.velocitiesRead,
109
+ 0,
110
+ velocitiesStaging,
111
+ 0,
112
+ this.velocityBufferSize
113
+ );
114
+ commandEncoder.copyBufferToBuffer(
115
+ this.buffers.statesRead,
116
+ 0,
117
+ statesStaging,
118
+ 0,
119
+ this.stateBufferSize
120
+ );
121
+ this.device.queue.submit([commandEncoder.finish()]);
122
+ await Promise.all([
123
+ positionsStaging.mapAsync(GPUMapMode.READ),
124
+ velocitiesStaging.mapAsync(GPUMapMode.READ),
125
+ statesStaging.mapAsync(GPUMapMode.READ)
126
+ ]);
127
+ const positions = new Float32Array(positionsStaging.getMappedRange()).slice();
128
+ const velocities = new Float32Array(velocitiesStaging.getMappedRange()).slice();
129
+ const states = new Float32Array(statesStaging.getMappedRange()).slice();
130
+ positionsStaging.unmap();
131
+ velocitiesStaging.unmap();
132
+ statesStaging.unmap();
133
+ positionsStaging.destroy();
134
+ velocitiesStaging.destroy();
135
+ statesStaging.destroy();
136
+ return { positions, velocities, states };
137
+ }
138
+ /**
139
+ * Create a staging buffer for GPU→CPU readback
140
+ */
141
+ createStagingBuffer(size) {
142
+ return this.device.createBuffer({
143
+ size,
144
+ usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST
145
+ });
146
+ }
147
+ /**
148
+ * Swap read/write buffers (ping-pong)
149
+ *
150
+ * After a compute pass, the "write" buffers contain the new state.
151
+ * This function swaps read ↔ write so the next pass can read the latest data.
152
+ */
153
+ swap() {
154
+ if (!this.buffers) {
155
+ throw new Error("Buffers not initialized");
156
+ }
157
+ const tempPos = this.buffers.positionsRead;
158
+ this.buffers.positionsRead = this.buffers.positionsWrite;
159
+ this.buffers.positionsWrite = tempPos;
160
+ const tempVel = this.buffers.velocitiesRead;
161
+ this.buffers.velocitiesRead = this.buffers.velocitiesWrite;
162
+ this.buffers.velocitiesWrite = tempVel;
163
+ const tempState = this.buffers.statesRead;
164
+ this.buffers.statesRead = this.buffers.statesWrite;
165
+ this.buffers.statesWrite = tempState;
166
+ }
167
+ /**
168
+ * Get buffer set for binding to compute pipeline
169
+ */
170
+ getBuffers() {
171
+ if (!this.buffers) {
172
+ throw new Error("Buffers not initialized");
173
+ }
174
+ return this.buffers;
175
+ }
176
+ /**
177
+ * Get particle count
178
+ */
179
+ getParticleCount() {
180
+ return this.particleCount;
181
+ }
182
+ /**
183
+ * Destroy buffers and free GPU memory
184
+ */
185
+ destroy() {
186
+ if (!this.buffers) return;
187
+ this.buffers.positionsRead.destroy();
188
+ this.buffers.positionsWrite.destroy();
189
+ this.buffers.velocitiesRead.destroy();
190
+ this.buffers.velocitiesWrite.destroy();
191
+ this.buffers.statesRead.destroy();
192
+ this.buffers.statesWrite.destroy();
193
+ this.buffers.uniforms.destroy();
194
+ this.buffers = null;
195
+ }
196
+ };
197
+ function createInitialParticleData(count, options = {}) {
198
+ const { positionRange = { min: -5, max: 5 }, radius = 0.05, mass = 1 } = options;
199
+ const positions = new Float32Array(count * 4);
200
+ const velocities = new Float32Array(count * 4);
201
+ const states = new Float32Array(count * 4);
202
+ for (let i = 0; i < count; i++) {
203
+ const idx = i * 4;
204
+ positions[idx + 0] = Math.random() * (positionRange.max - positionRange.min) + positionRange.min;
205
+ positions[idx + 1] = Math.random() * (positionRange.max - positionRange.min) + positionRange.min;
206
+ positions[idx + 2] = Math.random() * (positionRange.max - positionRange.min) + positionRange.min;
207
+ positions[idx + 3] = radius;
208
+ velocities[idx + 0] = 0;
209
+ velocities[idx + 1] = 0;
210
+ velocities[idx + 2] = 0;
211
+ velocities[idx + 3] = mass;
212
+ states[idx + 0] = 1;
213
+ states[idx + 1] = 0;
214
+ states[idx + 2] = 1;
215
+ states[idx + 3] = 0;
216
+ }
217
+ return { positions, velocities, states };
218
+ }
219
+
220
+ export {
221
+ GPUBufferManager,
222
+ createInitialParticleData
223
+ };