illutions 0.29.0 → 0.30.0

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/CHANGELOG.md CHANGED
@@ -1,10 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.30.0
4
+
5
+ ### Changed
6
+
7
+ - Replaced `Mesh3D.setTexture()` and `TextureSlot` with `requestImageTexture()` and `getImageTexture()` to separate requesting unused GLTF images from accessing their initialized Three.js textures and assigning them directly to material slots.
8
+ - Textures created from unused GLTF images now remain stable across progressive model levels while their image and mipmap data is updated.
9
+
10
+ ### Fixed
11
+
12
+ - Fixed the `Obj3D.onStart()` lifecycle so it is called before GLTF model loading begins, as documented.
13
+
14
+ ## 0.29.1
15
+
16
+ ### Fixed
17
+
18
+ - Fixed progressive model loading so textures belonging to materials not currently assigned to a mesh are updated through all model quality levels.
19
+
3
20
  ## 0.29.0
4
21
 
5
22
  ### Added
6
23
 
7
- - Added protected `Mesh3D.setTexture()` to assign unused GLTF images by name to the `ColorMap`, `LightMap`, or `AlphaMap` material slot, with optional UV channel and light map intensity settings; registered textures are updated across progressive model levels.
24
+ - Added protected `Mesh3D.setTexture()` to assign unused GLTF images by name to the `ColorMap`, `LightMap`, or `AlphaMap` material slot, with optional UV channel and light map intensity settings; registered textures are updated across progressive model levels.
8
25
  - Added the exported `TextureSlot` union for the supported material slots.
9
26
 
10
27
  ## 0.28.0
package/README.md CHANGED
@@ -19,6 +19,9 @@ Coordinate GLTF animation clips, GSAP transitions, camera paths and custom dolly
19
19
  **Progressive model and HDRI loading**
20
20
  Load ordered model levels and environment maps progressively for faster initial presentation and seamless quality upgrades.
21
21
 
22
+ **Flexible baked texture workflows**
23
+ Assign embedded GLTF textures by name to any object and material as light maps, fully baked combined color maps or alpha maps.
24
+
22
25
  **XState-powered application logic**
23
26
  Model complex application flows as predictable and inspectable state machines with integrated XState 5 usage.
24
27
 
package/dist/main.d.ts CHANGED
@@ -1694,31 +1694,12 @@ export declare class Mesh3D extends Obj3D {
1694
1694
  [key: string]: any;
1695
1695
  }): void;
1696
1696
  /**
1697
- * Updates one or more material properties of this mesh.
1698
- * @param properties - Material properties to update. Texture paths are supported for `map` and `emissiveMap`.
1699
- * @param properties.needsUpdate - Requests material recompilation after applying the properties. Default: **false**
1700
- */
1701
- setMaterialProperties({ needsUpdate, ...properties }: {
1702
- needsUpdate?: boolean;
1703
- [key: string]: any;
1704
- }): void;
1705
- /**
1706
- * Loads an unused texture embedded in the current GLTF and assigns it to a material.
1707
- * @param options - Unused texture assignment settings.
1708
- * @param options.name - Name of the GLTF image used by the texture.
1709
- * @param options.material - Material that receives the unused texture.
1710
- * @param options.slot - Target material texture slot. See {@link TextureSlot}.
1711
- * @param options.lightMapIntensity - Light map intensity used for `LightMap`. Default: **1**
1712
- * @param options.channel - Texture UV channel. Default: **1**
1697
+ * Returns an image texture requested from an unused GLTF image.
1698
+ * @param name - GLTF image name passed to {@link requestImageTexture} during `onStart()`.
1699
+ * @returns The initialized texture shared across progressive model levels.
1713
1700
  * @public
1714
1701
  */
1715
- protected setTexture({ name, material, slot, lightMapIntensity, channel }: {
1716
- name: string;
1717
- material: THREE_TYPE.MeshBasicMaterial | THREE_TYPE.MeshStandardMaterial;
1718
- slot: TextureSlot;
1719
- lightMapIntensity?: number;
1720
- channel?: number;
1721
- }): void;
1702
+ protected getImageTexture(name: string): THREE_TYPE.Texture;
1722
1703
  /**
1723
1704
  * Called for each traversed mesh during GLTF parsing. Stores the current `THREE.Mesh` in `this.obj`.
1724
1705
  * @param objGltf - The currently traversed mesh.
@@ -1728,6 +1709,21 @@ export declare class Mesh3D extends Obj3D {
1728
1709
  * {@includeCode ../../examples/mesh3D-cube.ts}
1729
1710
  */
1730
1711
  protected onTraverse(objGltf: THREE_TYPE.Mesh): void;
1712
+ /**
1713
+ * Requests a Three.js texture from an unused GLTF image for initialization before the model is traversed. Call this method from `onStart()` for every unused image that will be accessed later.
1714
+ * @param name - Name of the GLTF image.
1715
+ * @public
1716
+ */
1717
+ protected requestImageTexture(name: string): void;
1718
+ /**
1719
+ * Updates one or more material properties of this mesh.
1720
+ * @param properties - Material properties to update. Texture paths are supported for `map` and `emissiveMap`.
1721
+ * @param properties.needsUpdate - Requests material recompilation after applying the properties. Default: **false**
1722
+ */
1723
+ setMaterialProperties({ needsUpdate, ...properties }: {
1724
+ needsUpdate?: boolean;
1725
+ [key: string]: any;
1726
+ }): void;
1731
1727
  /* Excluded from this release type: setModel */
1732
1728
  /* Excluded from this release type: setReflectivesSSR */
1733
1729
  /* Excluded from this release type: traverse */
@@ -1768,26 +1764,28 @@ declare class Model {
1768
1764
  /* Excluded from this release type: sceneReady */
1769
1765
  private resolveSceneReady;
1770
1766
  private rejectSceneReady;
1771
- private gltf;
1772
1767
  private meshes;
1773
1768
  private scene;
1774
- private readonly textsUsed;
1775
- private readonly textsUnused;
1776
- constructor({ canvas, cfg, events, modules, renderer, rendererReady, initFirstScene: initFirstScene, reportModelReady, waitForRender }: ModelParams);
1777
- private addMaterials;
1778
- private addText;
1779
- private addTextUnused;
1780
- private loadTextsUnused;
1781
- private applyTextsUnused;
1782
- private disposeObsoleteResources;
1769
+ private readonly imageNamesUnused;
1770
+ private readonly imageTexturesUnused;
1771
+ private readonly textures;
1772
+ constructor({ canvas, cfg, events, modules, renderer, rendererReady, initFirstScene, reportModelReady, waitForRender }: ModelParams);
1773
+ /* Excluded from this release type: addImageUnusedName */
1774
+ private addMaterialsFromMesh;
1775
+ private addTexturesFromMaterial;
1776
+ private addTexture;
1777
+ private disposeGeometries;
1778
+ private disposeMaterialsAndTextures;
1779
+ /* Excluded from this release type: getTextureFromImageUnused */
1780
+ private initTextureFromImageUnused;
1781
+ private initTexturesFromImagesUnused;
1782
+ private initTexturesGltf;
1783
1783
  /* Excluded from this release type: load */
1784
1784
  private loadGltf;
1785
- private loadTextUnused;
1785
+ private prepareTextureImages;
1786
1786
  private reportError;
1787
- /* Excluded from this release type: setTextUsed */
1788
- private updateMaterials;
1789
- private updateMeshes;
1790
- private updateTextImages;
1787
+ private updateGeometries;
1788
+ private updateTextureImages;
1791
1789
  }
1792
1790
 
1793
1791
  /**
@@ -2845,17 +2843,6 @@ export declare interface StateMachineCfg {
2845
2843
  */
2846
2844
  export declare type StopMode = 'all' | 'last' | 'none';
2847
2845
 
2848
- /**
2849
- * Defines the material texture slots available for unused GLTF images.
2850
- *
2851
- * - `ColorMap` assigns the texture to `map`. Use it with a `MeshBasicMaterial` for a fully baked color texture.
2852
- * - `LightMap` assigns the texture to the `lightMap` slot and requires a `MeshStandardMaterial`.
2853
- * - `AlphaMap` assigns a separate alpha texture to the `alphaMap` slot, which GLTF does not support natively.
2854
- */
2855
- export declare type TextureSlot = 'ColorMap' | 'LightMap' | 'AlphaMap';
2856
-
2857
- /* Excluded from this release type: TextUsed */
2858
-
2859
2846
  /** Function returned by an event subscription. Calling it removes the associated listener. */
2860
2847
  export declare type Unsubscribe = () => void;
2861
2848