illutions 0.29.1 → 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,5 +1,16 @@
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
+
3
14
  ## 0.29.1
4
15
 
5
16
  ### Fixed
@@ -10,7 +21,7 @@
10
21
 
11
22
  ### Added
12
23
 
13
- - 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.
14
25
  - Added the exported `TextureSlot` union for the supported material slots.
15
26
 
16
27
  ## 0.28.0
package/dist/main.d.ts CHANGED
@@ -1475,14 +1475,6 @@ export declare interface HemisphereCfg {
1475
1475
  intensity: number;
1476
1476
  }
1477
1477
 
1478
- declare interface ImageTexture {
1479
- name: string;
1480
- material: THREE_TYPE.MeshBasicMaterial | THREE_TYPE.MeshStandardMaterial;
1481
- slot: TextureSlot;
1482
- lightMapIntensity: number;
1483
- channel: number;
1484
- }
1485
-
1486
1478
  /**
1487
1479
  * Defines the built-in engine infobox settings used to display FPS, CPU/frame timing and renderer.info values.
1488
1480
  * @category Cfg
@@ -1702,31 +1694,12 @@ export declare class Mesh3D extends Obj3D {
1702
1694
  [key: string]: any;
1703
1695
  }): void;
1704
1696
  /**
1705
- * Updates one or more material properties of this mesh.
1706
- * @param properties - Material properties to update. Texture paths are supported for `map` and `emissiveMap`.
1707
- * @param properties.needsUpdate - Requests material recompilation after applying the properties. Default: **false**
1708
- */
1709
- setMaterialProperties({ needsUpdate, ...properties }: {
1710
- needsUpdate?: boolean;
1711
- [key: string]: any;
1712
- }): void;
1713
- /**
1714
- * Loads an unused texture embedded in the current GLTF and assigns it to a material.
1715
- * @param options - Unused texture assignment settings.
1716
- * @param options.name - Name of the GLTF image used by the texture.
1717
- * @param options.material - Material that receives the unused texture.
1718
- * @param options.slot - Target material texture slot. See {@link TextureSlot}.
1719
- * @param options.lightMapIntensity - Light map intensity used for `LightMap`. Default: **1**
1720
- * @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.
1721
1700
  * @public
1722
1701
  */
1723
- protected setTexture({ name, material, slot, lightMapIntensity, channel }: {
1724
- name: string;
1725
- material: THREE_TYPE.MeshBasicMaterial | THREE_TYPE.MeshStandardMaterial;
1726
- slot: TextureSlot;
1727
- lightMapIntensity?: number;
1728
- channel?: number;
1729
- }): void;
1702
+ protected getImageTexture(name: string): THREE_TYPE.Texture;
1730
1703
  /**
1731
1704
  * Called for each traversed mesh during GLTF parsing. Stores the current `THREE.Mesh` in `this.obj`.
1732
1705
  * @param objGltf - The currently traversed mesh.
@@ -1736,6 +1709,21 @@ export declare class Mesh3D extends Obj3D {
1736
1709
  * {@includeCode ../../examples/mesh3D-cube.ts}
1737
1710
  */
1738
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;
1739
1727
  /* Excluded from this release type: setModel */
1740
1728
  /* Excluded from this release type: setReflectivesSSR */
1741
1729
  /* Excluded from this release type: traverse */
@@ -1776,26 +1764,25 @@ declare class Model {
1776
1764
  /* Excluded from this release type: sceneReady */
1777
1765
  private resolveSceneReady;
1778
1766
  private rejectSceneReady;
1779
- private gltf;
1780
1767
  private meshes;
1781
1768
  private scene;
1782
- private readonly imageTextures;
1783
- private readonly imageTextureInits;
1769
+ private readonly imageNamesUnused;
1770
+ private readonly imageTexturesUnused;
1784
1771
  private readonly textures;
1785
1772
  constructor({ canvas, cfg, events, modules, renderer, rendererReady, initFirstScene, reportModelReady, waitForRender }: ModelParams);
1773
+ /* Excluded from this release type: addImageUnusedName */
1786
1774
  private addMaterialsFromMesh;
1787
1775
  private addTexturesFromMaterial;
1788
1776
  private addTexture;
1789
- private applyImageTexturesToMaterials;
1790
1777
  private disposeGeometries;
1791
- private disposeSourceMaterials;
1792
- private initImageTexture;
1793
- private initImageTextures;
1794
- private initTextures;
1778
+ private disposeMaterialsAndTextures;
1779
+ /* Excluded from this release type: getTextureFromImageUnused */
1780
+ private initTextureFromImageUnused;
1781
+ private initTexturesFromImagesUnused;
1782
+ private initTexturesGltf;
1795
1783
  /* Excluded from this release type: load */
1796
1784
  private loadGltf;
1797
- private prepareImageTextures;
1798
- /* Excluded from this release type: prepareImageTextureForMaterial */
1785
+ private prepareTextureImages;
1799
1786
  private reportError;
1800
1787
  private updateGeometries;
1801
1788
  private updateTextureImages;
@@ -2856,15 +2843,6 @@ export declare interface StateMachineCfg {
2856
2843
  */
2857
2844
  export declare type StopMode = 'all' | 'last' | 'none';
2858
2845
 
2859
- /**
2860
- * Defines the material texture slots available for unused GLTF images.
2861
- *
2862
- * - `ColorMap` assigns the texture to `map`. Use it with a `MeshBasicMaterial` for a fully baked color texture.
2863
- * - `LightMap` assigns the texture to the `lightMap` slot and requires a `MeshStandardMaterial`.
2864
- * - `AlphaMap` assigns a separate alpha texture to the `alphaMap` slot, which GLTF does not support natively.
2865
- */
2866
- export declare type TextureSlot = 'ColorMap' | 'LightMap' | 'AlphaMap';
2867
-
2868
2846
  /** Function returned by an event subscription. Calling it removes the associated listener. */
2869
2847
  export declare type Unsubscribe = () => void;
2870
2848