@ikijs/engine 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/index.d.mts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +34 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -417,6 +417,10 @@ var IkiPlayer = class {
|
|
|
417
417
|
textures = [];
|
|
418
418
|
/** Bumped by every `load` and by `destroy`; lets a stale async load bail. */
|
|
419
419
|
loadGeneration = 0;
|
|
420
|
+
/** True from the moment `load()` is entered until it resolves or throws. */
|
|
421
|
+
loadPending = false;
|
|
422
|
+
/** Latches the un-awaited-load report, so a repeat caller says it once. */
|
|
423
|
+
warnedLoadUnfinished = false;
|
|
420
424
|
destroyed = false;
|
|
421
425
|
/**
|
|
422
426
|
* Engine-internal mesh buffers, keyed by the part's INDEX in `this.parts`
|
|
@@ -444,8 +448,21 @@ var IkiPlayer = class {
|
|
|
444
448
|
* Mesh buffer allocation failure IS fatal (unlike per-texture skip) because
|
|
445
449
|
* textures have an `IkiLoadResult.failedTextures` reporting surface and mesh
|
|
446
450
|
* buffers have none — there is no partial-mesh concept in the format.
|
|
451
|
+
*
|
|
452
|
+
* AWAIT THIS before reading {@link getParameters}. The swap happens after
|
|
453
|
+
* texture decoding, so an un-awaited `load()` leaves the parameter store
|
|
454
|
+
* empty for the rest of the tick; `getParameters` reports that case rather
|
|
455
|
+
* than letting a host conclude the model drives nothing.
|
|
447
456
|
*/
|
|
448
457
|
async load(model) {
|
|
458
|
+
this.loadPending = true;
|
|
459
|
+
try {
|
|
460
|
+
return await this.adoptModel(model);
|
|
461
|
+
} finally {
|
|
462
|
+
this.loadPending = false;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
async adoptModel(model) {
|
|
449
466
|
const { gl } = this;
|
|
450
467
|
const generation = ++this.loadGeneration;
|
|
451
468
|
const sources = model.textures ?? [];
|
|
@@ -657,8 +674,24 @@ var IkiPlayer = class {
|
|
|
657
674
|
getParameter(id) {
|
|
658
675
|
return this.params.get(id);
|
|
659
676
|
}
|
|
660
|
-
/**
|
|
677
|
+
/**
|
|
678
|
+
* The model's parameter descriptors, for building UI or host wiring.
|
|
679
|
+
*
|
|
680
|
+
* Empty until the first {@link load} resolves. Reaching it through an
|
|
681
|
+
* un-awaited `load()` is the one mistake in this class that produces no
|
|
682
|
+
* error and no motion: the caller gets `[]`, concludes the model has no
|
|
683
|
+
* parameters, and drives nothing — so that case is reported instead of
|
|
684
|
+
* being indistinguishable from a model that really declares none. A
|
|
685
|
+
* reload is deliberately NOT reported: those parameters are stale rather
|
|
686
|
+
* than absent, and warning there would fire on legitimate concurrent reads.
|
|
687
|
+
*/
|
|
661
688
|
getParameters() {
|
|
689
|
+
if (this.loadPending && this.model === void 0 && !this.warnedLoadUnfinished) {
|
|
690
|
+
this.warnedLoadUnfinished = true;
|
|
691
|
+
console.error(
|
|
692
|
+
"Iki: getParameters() ran before load() finished, so it returned an empty list \u2014 await load() before reading parameters."
|
|
693
|
+
);
|
|
694
|
+
}
|
|
662
695
|
return this.params.list();
|
|
663
696
|
}
|
|
664
697
|
destroy() {
|