Forum Discussion

Madlios's avatar
Madlios
Start Member
23 days ago

TypedArray & ArrayBuffer typescript support

I'm trying to get TypedArray to work in typescript but it doesnt seem to be recognized in Horizon Worlds. Is there a reason for this? I managed to get ArrayBuffer to work with DataView. But DataView is slower than TypedArrays which i need for high performance ECS. Is there a plan to support this or does anyone know if DataView works as fast as TypedArray in Horizon worlds?

1 Reply

  • Hey Madlios,

    You aren't missing anything—native TypedArray constructors (like Float32Array, Int32Array, etc.) are not currently exposed directly in the Horizon Worlds TypeScript environment. This is a known limitation of the current scripting sandbox, which is why DataView is the only "official" way to interact with an ArrayBuffer right now.

    Regarding performance:

    1. DataView vs. TypedArray: You are correct that DataView is generally slower for high-frequency access because every read/write involves a function call (e.g., getFloat32()) rather than a direct memory offset access. In standard JS engines (like V8), this gap has closed, but in the specific constraints used here, that overhead can still be significant.
    2. Alternative: If DataView is proving too slow you might actually find better raw performance using standard number[] arrays. While they use more memory (doubles) and lack the cache locality of a true binary buffer, the access speed ( arr[i] ) can sometimes beat the function-call overhead of DataView in these sandboxed environments.

    Hopefully, they add full TypedArray support for those of us doing heavy data manipulation!"