| 128 | // } | null = null; |
| 129 | |
| 130 | const onStatus = async (data: unknown) => { |
| 131 | const { loaded, total } = data as { loaded: number; total: number }; |
| 132 | if (loaded !== undefined && onProgress) { |
| 133 | onProgress( |
| 134 | new ProgressEvent("progress", { |
| 135 | lengthComputable: total !== 0, |
| 136 | loaded, |
| 137 | total, |
| 138 | }), |
| 139 | ); |
| 140 | } |
| 141 | |
| 142 | if ((data as { nextChunk?: boolean }).nextChunk) { |
| 143 | let chunk: Uint8Array; |
| 144 | if (!readStream) { |
| 145 | chunk = new Uint8Array(0); |
| 146 | } else { |
| 147 | const { done, value } = await readStream.read(); |
| 148 | if (done) { |
| 149 | readStream.releaseLock(); |
| 150 | readStream = undefined; |
| 151 | chunk = new Uint8Array(0); |
| 152 | } else { |
| 153 | chunk = value; |
| 154 | } |
| 155 | } |
| 156 | worker.call("nextChunk", { chunk }); |
| 157 | } |
| 158 | |
| 159 | // if ((data as { orig?: unknown }).orig) { |
| 160 | // if (extSplats) { |
| 161 | // initExt = (data as { orig?: unknown }).orig as { |
| 162 | // numSplats: number; |
| 163 | // ext0: Uint32Array; |
| 164 | // ext1: Uint32Array; |
| 165 | // extra: Record<string, unknown>; |
| 166 | // }; |
| 167 | // extSplats.initialize({ |
| 168 | // numSplats: initExt?.numSplats, |
| 169 | // extArrays: [initExt?.ext0, initExt?.ext1], |
| 170 | // extra: initExt?.extra, |
| 171 | // }); |
| 172 | // calledOnLoad = true; |
| 173 | // onLoad?.(extSplats); |
| 174 | // } else if (packedSplats) { |
| 175 | // init = (data as { orig?: unknown }).orig as { |
| 176 | // numSplats: number; |
| 177 | // packedArray: Uint32Array; |
| 178 | // extra: Record<string, unknown>; |
| 179 | // splatEncoding: SplatEncoding; |
| 180 | // }; |
| 181 | // packedSplats.initialize({ |
| 182 | // numSplats: init?.numSplats, |
| 183 | // packedArray: init?.packedArray, |
| 184 | // extra: init?.extra, |
| 185 | // splatEncoding: init?.splatEncoding, |
| 186 | // }); |
| 187 | // calledOnLoad = true; |