Browse Source

fix js_wasm `time.tick_now`, `performance.now()` returns a float

Laytan Laats 1 year ago
parent
commit
667883b3d5
2 changed files with 3 additions and 3 deletions
  1. 2 2
      core/time/time_js.odin
  2. 1 1
      vendor/wasm/js/runtime.js

+ 2 - 2
core/time/time_js.odin

@@ -24,9 +24,9 @@ _sleep :: proc "contextless" (d: Duration) {
 
 _tick_now :: proc "contextless" () -> Tick {
 	foreign odin_env {
-		tick_now :: proc "contextless" () -> i64 ---
+		tick_now :: proc "contextless" () -> f32 ---
 	}
-	return Tick{tick_now()*1e6}
+	return Tick{i64(tick_now()*1e6)}
 }
 
 _yield :: proc "contextless" () {

+ 1 - 1
vendor/wasm/js/runtime.js

@@ -1335,7 +1335,7 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement) {
 
 			// return a bigint to be converted to i64
 			time_now: () => BigInt(Date.now()),
-			tick_now: () => BigInt(performance.now()),
+			tick_now: () => performance.now(),
 			time_sleep: (duration_ms) => {
 				if (duration_ms > 0) {
 					// TODO(bill): Does this even make any sense?