智慧水务管理系统 - 精河县供水工程综合管理平台

wasm_splats.js 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. let wasm;
  2. const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
  3. if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
  4. let cachedUint8ArrayMemory0 = null;
  5. function getUint8ArrayMemory0() {
  6. if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
  7. cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
  8. }
  9. return cachedUint8ArrayMemory0;
  10. }
  11. function getStringFromWasm0(ptr, len) {
  12. ptr = ptr >>> 0;
  13. return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
  14. }
  15. let cachedUint32ArrayMemory0 = null;
  16. function getUint32ArrayMemory0() {
  17. if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
  18. cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
  19. }
  20. return cachedUint32ArrayMemory0;
  21. }
  22. function getArrayU32FromWasm0(ptr, len) {
  23. ptr = ptr >>> 0;
  24. return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
  25. }
  26. let WASM_VECTOR_LEN = 0;
  27. function passArray32ToWasm0(arg, malloc) {
  28. const ptr = malloc(arg.length * 4, 4) >>> 0;
  29. getUint32ArrayMemory0().set(arg, ptr / 4);
  30. WASM_VECTOR_LEN = arg.length;
  31. return ptr;
  32. }
  33. function takeFromExternrefTable0(idx) {
  34. const value = wasm.__wbindgen_export_0.get(idx);
  35. wasm.__externref_table_dealloc(idx);
  36. return value;
  37. }
  38. /**
  39. * Generate a splat texture from the given attributes.
  40. *
  41. * Wraps the [`texture_gen::generate_texture_from_attrs`] function for access from JavaScript.
  42. * @param {Float32Array} positions
  43. * @param {Float32Array} scales
  44. * @param {Float32Array} rotations
  45. * @param {Uint8Array} colors
  46. * @param {number} count
  47. * @returns {TextureData}
  48. */
  49. export function generate_splat_texture(positions, scales, rotations, colors, count) {
  50. const ret = wasm.generate_splat_texture(positions, scales, rotations, colors, count);
  51. if (ret[2]) {
  52. throw takeFromExternrefTable0(ret[1]);
  53. }
  54. return TextureData.__wrap(ret[0]);
  55. }
  56. /**
  57. * Sorts the Gaussian Splats by depth using a radix sort.
  58. *
  59. * Wraps the [`radix::radix_sort_gaussians_indexes`] function for access from JavaScript.
  60. * @param {Float32Array} positions_arr
  61. * @param {Float32Array} model_view_arr
  62. * @param {number} count
  63. * @returns {Uint32Array}
  64. */
  65. export function radix_sort_gaussians_indexes(positions_arr, model_view_arr, count) {
  66. const ret = wasm.radix_sort_gaussians_indexes(positions_arr, model_view_arr, count);
  67. if (ret[2]) {
  68. throw takeFromExternrefTable0(ret[1]);
  69. }
  70. return takeFromExternrefTable0(ret[0]);
  71. }
  72. const TextureDataFinalization = (typeof FinalizationRegistry === 'undefined')
  73. ? { register: () => {}, unregister: () => {} }
  74. : new FinalizationRegistry(ptr => wasm.__wbg_texturedata_free(ptr >>> 0, 1));
  75. /**
  76. * A structure representing texture data. This is used to pass the texture data from generation in [`texture_gen`] to the JavaScript side.
  77. */
  78. export class TextureData {
  79. static __wrap(ptr) {
  80. ptr = ptr >>> 0;
  81. const obj = Object.create(TextureData.prototype);
  82. obj.__wbg_ptr = ptr;
  83. TextureDataFinalization.register(obj, obj.__wbg_ptr, obj);
  84. return obj;
  85. }
  86. __destroy_into_raw() {
  87. const ptr = this.__wbg_ptr;
  88. this.__wbg_ptr = 0;
  89. TextureDataFinalization.unregister(this);
  90. return ptr;
  91. }
  92. free() {
  93. const ptr = this.__destroy_into_raw();
  94. wasm.__wbg_texturedata_free(ptr, 0);
  95. }
  96. /**
  97. * Getter for the underlying texture data. Always returns a copy.
  98. * @returns {Uint32Array}
  99. */
  100. get data() {
  101. const ret = wasm.texturedata_data(this.__wbg_ptr);
  102. var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
  103. wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
  104. return v1;
  105. }
  106. /**
  107. * Getter for the width of the texture in pixels.
  108. * @returns {number}
  109. */
  110. get width() {
  111. const ret = wasm.texturedata_width(this.__wbg_ptr);
  112. return ret >>> 0;
  113. }
  114. /**
  115. * Getter for the height of the texture in pixels.
  116. * @returns {number}
  117. */
  118. get height() {
  119. const ret = wasm.texturedata_height(this.__wbg_ptr);
  120. return ret >>> 0;
  121. }
  122. /**
  123. * Creates a new texture data object with the underlying data, width, and height.
  124. * @param {Uint32Array} data
  125. * @param {number} width
  126. * @param {number} height
  127. * @returns {TextureData}
  128. */
  129. static new(data, width, height) {
  130. const ptr0 = passArray32ToWasm0(data, wasm.__wbindgen_malloc);
  131. const len0 = WASM_VECTOR_LEN;
  132. const ret = wasm.texturedata_new(ptr0, len0, width, height);
  133. return TextureData.__wrap(ret);
  134. }
  135. }
  136. async function __wbg_load(module, imports) {
  137. if (typeof Response === 'function' && module instanceof Response) {
  138. if (typeof WebAssembly.instantiateStreaming === 'function') {
  139. try {
  140. return await WebAssembly.instantiateStreaming(module, imports);
  141. } catch (e) {
  142. if (module.headers.get('Content-Type') != 'application/wasm') {
  143. console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
  144. } else {
  145. throw e;
  146. }
  147. }
  148. }
  149. const bytes = await module.arrayBuffer();
  150. return await WebAssembly.instantiate(bytes, imports);
  151. } else {
  152. const instance = await WebAssembly.instantiate(module, imports);
  153. if (instance instanceof WebAssembly.Instance) {
  154. return { instance, module };
  155. } else {
  156. return instance;
  157. }
  158. }
  159. }
  160. function __wbg_get_imports() {
  161. const imports = {};
  162. imports.wbg = {};
  163. imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
  164. const ret = arg0.buffer;
  165. return ret;
  166. };
  167. imports.wbg.__wbg_length_3b4f022188ae8db6 = function(arg0) {
  168. const ret = arg0.length;
  169. return ret;
  170. };
  171. imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
  172. const ret = arg0.length;
  173. return ret;
  174. };
  175. imports.wbg.__wbg_new_780abee5c1739fd7 = function(arg0) {
  176. const ret = new Float32Array(arg0);
  177. return ret;
  178. };
  179. imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
  180. const ret = new Uint8Array(arg0);
  181. return ret;
  182. };
  183. imports.wbg.__wbg_new_e3b321dcfef89fc7 = function(arg0) {
  184. const ret = new Uint32Array(arg0);
  185. return ret;
  186. };
  187. imports.wbg.__wbg_newwithbyteoffsetandlength_f1dead44d1fc7212 = function(arg0, arg1, arg2) {
  188. const ret = new Uint32Array(arg0, arg1 >>> 0, arg2 >>> 0);
  189. return ret;
  190. };
  191. imports.wbg.__wbg_set_10bad9bee0e9c58b = function(arg0, arg1, arg2) {
  192. arg0.set(arg1, arg2 >>> 0);
  193. };
  194. imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
  195. arg0.set(arg1, arg2 >>> 0);
  196. };
  197. imports.wbg.__wbindgen_init_externref_table = function() {
  198. const table = wasm.__wbindgen_export_0;
  199. const offset = table.grow(4);
  200. table.set(0, undefined);
  201. table.set(offset + 0, undefined);
  202. table.set(offset + 1, null);
  203. table.set(offset + 2, true);
  204. table.set(offset + 3, false);
  205. ;
  206. };
  207. imports.wbg.__wbindgen_memory = function() {
  208. const ret = wasm.memory;
  209. return ret;
  210. };
  211. imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
  212. const ret = getStringFromWasm0(arg0, arg1);
  213. return ret;
  214. };
  215. imports.wbg.__wbindgen_throw = function(arg0, arg1) {
  216. throw new Error(getStringFromWasm0(arg0, arg1));
  217. };
  218. return imports;
  219. }
  220. function __wbg_init_memory(imports, memory) {
  221. }
  222. function __wbg_finalize_init(instance, module) {
  223. wasm = instance.exports;
  224. __wbg_init.__wbindgen_wasm_module = module;
  225. cachedUint32ArrayMemory0 = null;
  226. cachedUint8ArrayMemory0 = null;
  227. wasm.__wbindgen_start();
  228. return wasm;
  229. }
  230. function initSync(module) {
  231. if (wasm !== undefined) return wasm;
  232. if (typeof module !== 'undefined') {
  233. if (Object.getPrototypeOf(module) === Object.prototype) {
  234. ({module} = module)
  235. } else {
  236. console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
  237. }
  238. }
  239. const imports = __wbg_get_imports();
  240. __wbg_init_memory(imports);
  241. if (!(module instanceof WebAssembly.Module)) {
  242. module = new WebAssembly.Module(module);
  243. }
  244. const instance = new WebAssembly.Instance(module, imports);
  245. return __wbg_finalize_init(instance, module);
  246. }
  247. async function __wbg_init(module_or_path) {
  248. if (wasm !== undefined) return wasm;
  249. if (typeof module_or_path !== 'undefined') {
  250. if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
  251. ({module_or_path} = module_or_path)
  252. } else {
  253. console.warn('using deprecated parameters for the initialization function; pass a single object instead')
  254. }
  255. }
  256. if (typeof module_or_path === 'undefined') {
  257. module_or_path = new URL('wasm_splats_bg.wasm', import.meta.url);
  258. }
  259. const imports = __wbg_get_imports();
  260. if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
  261. module_or_path = fetch(module_or_path);
  262. }
  263. __wbg_init_memory(imports);
  264. const { instance, module } = await __wbg_load(await module_or_path, imports);
  265. return __wbg_finalize_init(instance, module);
  266. }
  267. export { initSync };
  268. export default __wbg_init;