matrix-engine-wgpu 1.2.0 → 1.2.2

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.
@@ -28,6 +28,12 @@
28
28
  "sounds": "Zvuk",
29
29
  "welcomeMsg": "Dobro došli, <br> otvoren izvori kod 🎲 Ultimate Jamb igra <br> Pokupi kod: ",
30
30
  "ready":"Sve je spremno za igru 🎲!",
31
+ "freetoroll":"Zavrtite 🎲!",
32
+ "pick5":"Izaberi 5 najboljih 🎲 i izaberi polje u tabeli.",
31
33
  "hand1":"Prvo bacanje - sackajte...",
32
- "choosename":"Izaberi alias:"
34
+ "hand2":"Drugo bacanje - sackajte...",
35
+ "graphics":"Grafika",
36
+ "choosename":"Izaberi alias:",
37
+ "table":"Tabla",
38
+ "about":"Ultimate Yahtzee je moderna 3D igra sa kockicama u potpunosti izgrađena pomoću MatrixEngineWGPU-a, visokoperformansnog rendering endžina zasnovanog na WebGPU-u, razvijenog za kreiranje interaktivne grafike direktno u pregledaču. Igra pruža glatke vizuelne efekte, realističnu fiziku kockica i zanimljivo korisničko iskustvo — sve bez potrebe za bilo kakvim dodacima ili instalacijama.\n Ovaj projekat je pokretan otvorenim tehnologijama i dizajniran je da bude lagan, brz i veoma prilagodljiv. Odličan je primer kako se WebGPU može koristiti za interaktivni sadržaj u realnom vremenu. \n 🔗 Preuzmite / Isprobajte: \n github.com/zlatnaspirala/matrix-engine-wgpu \n 🛠 Licenca: \n Osnovni endžin i projekat Ultimate Yahtzee objavljeni su pod GPL v3 licencom, što ih čini besplatnim i otvorenog koda za ličnu i komercijalnu upotrebu — sve dok poštujete uslove licence. \n Bez obzira da li ste programer, igrač ili entuzijasta, Ultimate Yahtzee je zabavan način da iskusite potencijal moderne 3D tehnologije zasnovane na pregledaču."
33
39
  }
package/readme.md CHANGED
@@ -322,4 +322,6 @@ You may use, modify, and sell projects based on this code — just keep this not
322
322
 
323
323
  [Full License Text](https://github.com/webgpu/webgpu-samples/blob/main/LICENSE.txt)
324
324
 
325
+ Top level main.js instance (Ultimate Yahtzee)
326
+
325
327
  ---
@@ -721,22 +721,109 @@ export let mb = {
721
721
  }
722
722
  }
723
723
 
724
- export function typeText(elementId, text, delay = 50) {
724
+ // Registry to track running animations per element
725
+ const typingStates = new Map();
726
+
727
+ export function typeText(elementId, htmlString, delay = 50) {
725
728
  const el = document.getElementById(elementId);
726
- el.innerText = '';
727
- let index = 0;
729
+ if (!el) return;
730
+
731
+ // If an existing typing is running for this element, cancel it
732
+ if (typingStates.has(elementId)) {
733
+ clearTimeout(typingStates.get(elementId).timeoutId);
734
+ typingStates.delete(elementId);
735
+ }
736
+
737
+ el.innerHTML = ''; // Clear previous content
738
+
739
+ const tempEl = document.createElement('div');
740
+ tempEl.innerHTML = htmlString;
741
+
742
+ const queue = [];
743
+
744
+ function flatten(node) {
745
+ if (node.nodeType === Node.TEXT_NODE) {
746
+ queue.push({ type: 'text', text: node.textContent });
747
+ } else if (node.nodeType === Node.ELEMENT_NODE) {
748
+ if (node.tagName.toLowerCase() === 'img') {
749
+ queue.push({
750
+ type: 'img',
751
+ src: node.getAttribute('src'),
752
+ alt: node.getAttribute('alt') || ''
753
+ });
754
+ } else {
755
+ queue.push({
756
+ type: 'element',
757
+ tag: node.tagName.toLowerCase(),
758
+ attributes: Object.fromEntries([...node.attributes].map(attr => [attr.name, attr.value]))
759
+ });
760
+ for (const child of node.childNodes) flatten(child);
761
+ queue.push({ type: 'end' });
762
+ }
763
+ }
764
+ }
765
+
766
+ for (const node of tempEl.childNodes) flatten(node);
767
+
768
+ let stack = [];
769
+ let currentElement = el;
728
770
 
729
771
  function typeNextChar() {
730
- if(index < text.length) {
731
- el.textContent += text.charAt(index);
732
- index++;
733
- setTimeout(typeNextChar, delay);
772
+ if (queue.length === 0) {
773
+ typingStates.delete(elementId); // Cleanup after finish
774
+ return;
734
775
  }
776
+
777
+ const item = queue[0];
778
+
779
+ if (item.type === 'text') {
780
+ if (!item.index) item.index = 0;
781
+
782
+ const ch = item.text[item.index];
783
+ if (ch === '\n') {
784
+ currentElement.appendChild(document.createElement('br'));
785
+ } else {
786
+ currentElement.appendChild(document.createTextNode(ch));
787
+ }
788
+
789
+ item.index++;
790
+ if (item.index >= item.text.length) queue.shift();
791
+
792
+ } else if (item.type === 'element') {
793
+ const newEl = document.createElement(item.tag);
794
+ if (item.attributes) {
795
+ for (let [key, val] of Object.entries(item.attributes)) {
796
+ newEl.setAttribute(key, val);
797
+ }
798
+ }
799
+ currentElement.appendChild(newEl);
800
+ stack.push(currentElement);
801
+ currentElement = newEl;
802
+ queue.shift();
803
+
804
+ } else if (item.type === 'end') {
805
+ currentElement = stack.pop();
806
+ queue.shift();
807
+
808
+ } else if (item.type === 'img') {
809
+ const img = document.createElement('img');
810
+ img.src = item.src;
811
+ img.alt = item.alt;
812
+ img.style.maxWidth = '100px';
813
+ img.style.verticalAlign = 'middle';
814
+ currentElement.appendChild(img);
815
+ queue.shift();
816
+ }
817
+
818
+ // Schedule next step and store timeoutId for control
819
+ const timeoutId = setTimeout(typeNextChar, delay);
820
+ typingStates.set(elementId, { timeoutId });
735
821
  }
736
822
 
737
823
  typeNextChar();
738
824
  }
739
825
 
826
+
740
827
  export function setupCanvasFilters(canvasId) {
741
828
  let canvas = document.getElementById(canvasId);
742
829
  if(canvas == null) {