s3m-three 0.4.21 → 0.4.22

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.
@@ -246,6 +246,8 @@ export type BuildTileFn = (
246
246
  assembled?: TileGeometryData;
247
247
  /** 深度偏移配置(透传给 buildTileObjects),见 BuildTileOptions.polygonOffset */
248
248
  polygonOffset?: { factor: number; units: number };
249
+ /** 光照模型档位(透传给 buildTileObjects),见 BuildTileOptions.materialQuality */
250
+ materialQuality?: 'pbr' | 'lambert';
249
251
  }
250
252
  ) => Promise<{ group: Group; stats: Partial<Stats> }>;
251
253
 
@@ -258,6 +260,11 @@ export interface S3MTilesetOptions {
258
260
  buildTile?: BuildTileFn | null;
259
261
  /** 三角面材质深度偏移(共面摩尔纹 / 重合面归属),透传给 buildTileObjects */
260
262
  polygonOffset?: { factor: number; units: number };
263
+ /**
264
+ * 光照模型档位,透传给 buildTileObjects。不传 = 读模块级默认。
265
+ * 由 DatasetManager 从图层 / 数据集设置带下来。
266
+ */
267
+ materialQuality?: 'pbr' | 'lambert';
261
268
  /**
262
269
  * 是否用 Web Worker 解析经典 `.s3mb` 瓦片(默认开)。
263
270
  *
@@ -471,6 +478,7 @@ export class S3MTileset {
471
478
  private isS3MV1 = false;
472
479
  private _buildTile: BuildTileFn | null;
473
480
  private readonly _polygonOffset: { factor: number; units: number } | undefined;
481
+ private _materialQuality: 'pbr' | 'lambert' | undefined;
474
482
  private readonly _uniforms: StyleUniforms | null;
475
483
  /** 经典 .s3mb 的 Worker 解析客户端;undefined = 尚未尝试创建,null = 不可用/已降级 */
476
484
  private _workerClient: S3MWorkerClient | null | undefined; private readonly _useWorker: boolean;
@@ -491,6 +499,7 @@ export class S3MTileset {
491
499
  // 渲染层可注入:Node 环境下不需要 three,也能跑 URL / 解析链路
492
500
  this._buildTile = options.buildTile ?? null;
493
501
  this._polygonOffset = options.polygonOffset;
502
+ this._materialQuality = options.materialQuality;
494
503
  // 着色器共享 uniform,由 S3MLayer 持有并传进来
495
504
  this._uniforms = options.uniforms ?? null;
496
505
  this._useWorker = options.useWorker !== false;
@@ -722,6 +731,15 @@ export class S3MTileset {
722
731
  this.maxMemory = Number.isFinite(bytes) && bytes > 0 ? bytes : Infinity;
723
732
  }
724
733
 
734
+ /**
735
+ * 运行时改本数据集的光照模型档位。只影响**之后**构建的瓦片材质;
736
+ * 场上已有材质由 `S3MViewer.setMaterialQuality` 原位重建。
737
+ * `undefined` = 跟随模块级默认。
738
+ */
739
+ setMaterialQuality(q: 'pbr' | 'lambert' | undefined): void {
740
+ this._materialQuality = q;
741
+ }
742
+
725
743
  /**
726
744
  * 当前数据集驻留的显存与内存总字节数(几何缓冲精确大小 + 纹理显存估计)
727
745
  */
@@ -1245,6 +1263,7 @@ export class S3MTileset {
1245
1263
  uniforms: this._uniforms,
1246
1264
  assembled,
1247
1265
  polygonOffset: this._polygonOffset,
1266
+ materialQuality: this._materialQuality,
1248
1267
  });
1249
1268
  const { group, stats } = buildRes;
1250
1269
  const texKeys = (buildRes as any).textureKeys ?? (group.userData?.textureKeys as string[] | undefined) ?? Object.keys(tile.textures ?? {});