|
177 | 177 |
|
178 | 178 | resolve(request.result[cacheFieldName]);
|
179 | 179 | } else {
|
180 |
| - console.log("get no data"); |
181 |
| - |
182 |
| - resolve(null); |
| 180 | + reject("get no cache") |
183 | 181 | }
|
184 | 182 | };
|
185 | 183 | })
|
|
234 | 232 |
|
235 | 233 |
|
236 | 234 |
|
237 |
| - |
238 |
| - api.loadAssetBundle( |
239 |
| - _getAssetBundlePath() + wabRelativePath |
| 235 | + api.loadWABAndSetToState( |
| 236 | + wabRelativePath, _getAssetBundlePath |
240 | 237 | ).flatMap((wab) => {
|
241 | 238 | console.log("wab: ", wab);
|
242 | 239 |
|
|
260 | 257 | api.setState(state);
|
261 | 258 |
|
262 | 259 |
|
263 |
| - return api.loadAndAssembleAllDependencyRAB( |
| 260 | + return api.loadAllDependencyRABAndSetToState( |
264 | 261 | sabRelativePath,
|
265 | 262 | manifest,
|
266 | 263 | [
|
|
270 | 267 | _getAssetBundleArrayBufferCache,
|
271 | 268 | _cacheAssetBundleArrayBuffer
|
272 | 269 | ]
|
273 |
| - |
274 |
| - ).concat( |
| 270 | + ).merge( |
275 | 271 | api.loadSABAndSetToState(
|
276 | 272 | sabRelativePath,
|
277 | 273 | manifest,
|
|
284 | 280 | ]
|
285 | 281 |
|
286 | 282 | )
|
| 283 | + ).concat( |
| 284 | + api.assembleAllDependencyRAB(sabRelativePath, wholeDependencyRelationMap) |
287 | 285 | )
|
288 | 286 | })
|
289 | 287 | .subscribe({
|
|
315 | 313 | // console.log("init->a: ", a)
|
316 | 314 |
|
317 | 315 |
|
318 |
| - // var intervalId = setInterval(() => { |
319 |
| - // var state = api.unsafeGetState(); |
| 316 | + var intervalId = setInterval(() => { |
| 317 | + var state = api.unsafeGetState(); |
| 318 | + |
| 319 | + if (!api.isWABLoaded( |
| 320 | + wabRelativePath, |
| 321 | + state |
| 322 | + )) { |
| 323 | + console.log("wab is not loaded"); |
320 | 324 |
|
321 |
| - // if (api.isSABLoaded( |
322 |
| - // sabRelativePath, state |
323 |
| - // )) { |
324 |
| - // console.log("assemble sab"); |
| 325 | + return; |
| 326 | + } |
325 | 327 |
|
326 |
| - // clearInterval(intervalId); |
| 328 | + if (api.canAssembleSAB( |
| 329 | + sabRelativePath, |
| 330 | + wabRelativePath, |
| 331 | + state |
| 332 | + )) { |
| 333 | + console.log("assemble sab"); |
327 | 334 |
|
328 |
| - // api.assembleSAB( |
329 |
| - // sabRelativePath, |
| 335 | + clearInterval(intervalId); |
330 | 336 |
|
331 |
| - // api.unsafeGetLoadedSAB( |
332 |
| - // sabRelativePath, state |
333 |
| - // ), |
334 |
| - // api.unsafeGetWholeDependencyRelationMap( |
335 |
| - // wabRelativePath, state |
336 |
| - // ) |
337 |
| - // ). |
| 337 | + api.assembleSAB( |
| 338 | + sabRelativePath, |
338 | 339 |
|
339 |
| - // subscribe( |
340 |
| - // { |
341 |
| - // "next": (sceneGameObject) => { |
342 |
| - // var state = api.unsafeGetState(); |
| 340 | + api.unsafeGetLoadedSAB( |
| 341 | + sabRelativePath, state |
| 342 | + ), |
| 343 | + api.unsafeGetWholeDependencyRelationMap( |
| 344 | + wabRelativePath, state |
| 345 | + ) |
| 346 | + ). |
343 | 347 |
|
344 |
| - // var state = api.initAllSABGameObjects( |
345 |
| - // sceneGameObject, state |
346 |
| - // ); |
| 348 | + subscribe( |
| 349 | + { |
| 350 | + "next": (sceneGameObject) => { |
| 351 | + var state = api.unsafeGetState(); |
347 | 352 |
|
| 353 | + var state = api.initAllSABGameObjects( |
| 354 | + sceneGameObject, state |
| 355 | + ); |
348 | 356 |
|
349 |
| - // // var state = |
350 |
| - // // api.disposeSceneAllChildren(state); |
351 | 357 |
|
352 |
| - // // var state = |
353 |
| - // // api.setSABSceneGameObjectToBeScene(sceneGameObject, state); |
| 358 | + // var state = |
| 359 | + // api.disposeSceneAllChildren(state); |
354 | 360 |
|
| 361 | + // var state = |
| 362 | + // api.setSABSceneGameObjectToBeScene(sceneGameObject, state); |
355 | 363 |
|
356 |
| - // var state = |
357 |
| - // api.addSABSceneGameObjectChildrenToScene(sceneGameObject, state); |
358 | 364 |
|
| 365 | + var state = |
| 366 | + api.addSABSceneGameObjectChildrenToScene(sceneGameObject, state); |
359 | 367 |
|
360 |
| - // api.setState(state); |
361 |
| - // }, |
362 |
| - // "error": e => { |
363 |
| - // console.log("error: ", e); |
364 |
| - // }, |
365 |
| - // "complete": () => { |
366 |
| - // console.log("complete"); |
367 |
| - // } |
368 |
| - // } |
369 | 368 |
|
| 369 | + api.setState(state); |
| 370 | + }, |
| 371 | + "error": e => { |
| 372 | + console.log("error: ", e); |
| 373 | + }, |
| 374 | + "complete": () => { |
| 375 | + console.log("complete"); |
| 376 | + } |
| 377 | + } |
370 | 378 |
|
371 |
| - // ) |
372 |
| - // } |
373 |
| - // else { |
374 |
| - // console.log("sab not loaded! need wait", |
375 |
| - // api.getAllDependencyRABCount( |
376 |
| - // sabRelativePath, |
377 |
| - // wabRelativePath, |
378 |
| - // state, |
379 |
| - // ), |
380 |
| - // api.getLoadedDependencyRABCount( |
381 |
| - // sabRelativePath, |
382 |
| - // wabRelativePath, |
383 |
| - // state, |
384 |
| - // ) |
385 |
| - // ) |
386 |
| - // } |
387 | 379 |
|
388 |
| - // }, 30); |
| 380 | + ) |
| 381 | + } |
| 382 | + else { |
| 383 | + console.log("sab can't be assembled! need wait", |
| 384 | + api.getAllNeededABCount( |
| 385 | + sabRelativePath, |
| 386 | + wabRelativePath, |
| 387 | + state, |
| 388 | + ), |
| 389 | + api.getLoadedNeededABCount( |
| 390 | + sabRelativePath, |
| 391 | + wabRelativePath, |
| 392 | + state, |
| 393 | + ) |
| 394 | + ) |
| 395 | + } |
| 396 | + }, 30); |
389 | 397 |
|
390 | 398 |
|
391 | 399 |
|
|
0 commit comments