three-cad-viewer 4.3.7 → 4.3.9

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.
@@ -48,6 +48,13 @@ declare class StudioManager {
48
48
  private _savedClippingState;
49
49
  private _shadowLights;
50
50
  private _ctx;
51
+ /**
52
+ * Renderer pixel ratio saved on Studio entry, restored on leave.
53
+ * Studio mode bumps the pixel ratio to apply supersampling, which
54
+ * compensates for low DPR (e.g., VSCode webviews report DPR=1 even
55
+ * on Retina displays) and improves AA on shallow-angle edges.
56
+ */
57
+ private _savedPixelRatio;
51
58
  constructor(ctx: StudioManagerContext);
52
59
  get isActive(): boolean;
53
60
  get hasComposer(): boolean;
@@ -271,6 +271,14 @@ export interface ViewerOptions extends StudioModeOptions {
271
271
  zoomSpeed?: number;
272
272
  /** Show timings in browser console (default: false) */
273
273
  timeit?: boolean;
274
+ /**
275
+ * Tab to land on after render (default: "tree", i.e. CAD mode).
276
+ * When set to a non-tree tab, the initial CAD paint is skipped so the
277
+ * user doesn't see a brief CAD-mode flicker before the target tab takes
278
+ * over. Especially noticeable for "studio" (async env-map load) and
279
+ * "zebra" (material swap).
280
+ */
281
+ tab?: ActiveTab;
274
282
  }
275
283
  /** Zebra tool options */
276
284
  export interface ZebraOptions {
@@ -508,6 +516,9 @@ export interface MaterialXMaterial {
508
516
  textures: Record<string, string>;
509
517
  /** Optional texture tiling [u, v], default [1, 1]. Applied to all textures. */
510
518
  textureRepeat?: [number, number];
519
+ /** Optional texture rotation in **radians**, counterclockwise. Pivot is
520
+ * the texture center (0.5, 0.5). Applied to all textures. */
521
+ textureRotation?: number;
511
522
  }
512
523
  /**
513
524
  * Type guard to check if a material entry is a threejs-materials format dict.
@@ -183,6 +183,7 @@ declare class Viewer {
183
183
  private _pendingDisposal;
184
184
  shapes: Shapes | null;
185
185
  gridSize: number;
186
+ private _previousGridSize;
186
187
  hasAnimationLoop: boolean;
187
188
  mixer: THREE.AnimationMixer | null;
188
189
  continueAnimation: boolean;
package/dist/index.d.ts CHANGED
@@ -15,10 +15,10 @@ import { Timer } from "./utils/timer.js";
15
15
  import { logger } from "./utils/logger.js";
16
16
  import { gpuTracker } from "./utils/gpu-tracker.js";
17
17
  import { version } from "./_version.js";
18
- export { Viewer, Display, EnvironmentManager, Timer, logger, gpuTracker, version };
19
- export { MATERIAL_PRESETS, MATERIAL_PRESET_NAMES } from "./rendering/material-presets.js";
18
+ export { Viewer, Display, EnvironmentManager, Timer, logger, gpuTracker, version, };
19
+ export { MATERIAL_PRESETS, MATERIAL_PRESET_NAMES, } from "./rendering/material-presets.js";
20
20
  export type { LogLevel } from "./utils/logger.js";
21
- export type { ResourceType, TrackedResource, ResourceSummary } from "./utils/gpu-tracker.js";
21
+ export type { ResourceType, TrackedResource, ResourceSummary, } from "./utils/gpu-tracker.js";
22
22
  export type { Vector3Tuple, QuaternionTuple } from "three";
23
23
  export type { ThemeInput, Theme, ControlType, UpDirection, AnimationMode, ActiveTab, ZebraColorScheme, ZebraMappingMode, ShapeType, ShapeSubtype, Axis, ClipIndex, ColorValue, RGBColor, RGBAColor, AxisColors, AxisColorsFlatArray, } from "./core/types.js";
24
24
  export { CLIP_INDICES, isClipIndex, CollapseState } from "./core/types.js";
@@ -27,12 +27,12 @@ export type { BoundingBox, BoundingSphere, BoundingBoxFlat, } from "./core/types
27
27
  export type { PickInfo } from "./core/types.js";
28
28
  export type { ChangeInfos, ChangeNotification, NotificationCallback, } from "./core/types.js";
29
29
  export type { DisplayOptions, RenderOptions, ViewerOptions, ZebraOptions, CombinedOptions, } from "./core/types.js";
30
- export type { ViewerStateShape, StateKey, } from "./core/types.js";
30
+ export type { ViewerStateShape, StateKey } from "./core/types.js";
31
31
  export type { Texture, Shape, ShapeBinary, ShapeNested, Location, VisibilityValue, VisibilityState, Shapes, } from "./core/types.js";
32
32
  export { isShapeBinaryFormat, hasTrianglesPerFace, hasSegmentsPerEdge, } from "./core/types.js";
33
33
  export type { DomEventCallback } from "./core/types.js";
34
34
  export type { ColoredMaterial } from "./core/types.js";
35
35
  export type { MaterialAppearance, MaterialXMaterial, StudioOptions, StudioBackground, StudioModeOptions, StudioEnvironment, StudioToneMapping, StudioTextureMapping, } from "./core/types.js";
36
36
  export { isMaterialXMaterial } from "./core/types.js";
37
- export { isInstancedFormat, decodeInstancedFormat } from "./utils/decode-instances.js";
37
+ export { isInstancedFormat, decodeInstancedFormat, } from "./utils/decode-instances.js";
38
38
  export type { SubscribeOptions } from "./core/types.js";
@@ -221,7 +221,7 @@ declare class EnvironmentManager {
221
221
  * Load an HDR file and generate a PMREM texture from it.
222
222
  *
223
223
  * Uses HDRLoader to fetch the .hdr file, then PMREMGenerator.fromEquirectangular()
224
- * to create the PMREM cubemap. The source equirectangular texture is disposed
224
+ * to create the PMREM cubemap. The source equirectangular HDR is disposed
225
225
  * after PMREM generation. The PMREM texture itself serves as both the IBL
226
226
  * environment and the background (in "environment" mode).
227
227
  *
@@ -117,12 +117,12 @@ declare class MaterialFactory {
117
117
  * Create a standard material for back faces with PBR properties.
118
118
  * Used for polygon rendering where back faces need full shading.
119
119
  */
120
- createBackFaceStandardMaterial({ color, alpha, polygonOffsetUnits, visible }: BackFaceMaterialOptions, label?: string): THREE.MeshStandardMaterial;
120
+ createBackFaceStandardMaterial({ color, alpha, polygonOffsetUnits, visible, }: BackFaceMaterialOptions, label?: string): THREE.MeshStandardMaterial;
121
121
  /**
122
122
  * Create a basic material for back faces (no lighting/PBR).
123
123
  * Used for shape rendering where back faces are simple fills.
124
124
  */
125
- createBackFaceBasicMaterial({ color, alpha, polygonOffsetUnits, visible }: BackFaceMaterialOptions, label?: string): THREE.MeshBasicMaterial;
125
+ createBackFaceBasicMaterial({ color, alpha, polygonOffsetUnits, visible, }: BackFaceMaterialOptions, label?: string): THREE.MeshBasicMaterial;
126
126
  /**
127
127
  * Create a basic front face material (no PBR, for simple shapes).
128
128
  */
@@ -130,7 +130,7 @@ declare class MaterialFactory {
130
130
  /**
131
131
  * Create a fat line material (LineMaterial from Three.js examples).
132
132
  */
133
- createEdgeMaterial({ lineWidth, color, vertexColors, visible, resolution }: EdgeMaterialOptions, label?: string): LineMaterial;
133
+ createEdgeMaterial({ lineWidth, color, vertexColors, visible, resolution, }: EdgeMaterialOptions, label?: string): LineMaterial;
134
134
  /**
135
135
  * Create a basic line material for simple edges (e.g., polygon outlines).
136
136
  */
@@ -156,7 +156,7 @@ declare class MaterialFactory {
156
156
  * @param label - Optional label for GPU tracking
157
157
  * @returns Configured MeshPhysicalMaterial (or MeshBasicMaterial if unlit)
158
158
  */
159
- createStudioMaterial({ materialDef, fallbackColor, fallbackAlpha, textureCache }: StudioMaterialOptions, label?: string): Promise<THREE.MeshPhysicalMaterial | THREE.MeshBasicMaterial>;
159
+ createStudioMaterial({ materialDef, fallbackColor, fallbackAlpha, textureCache, }: StudioMaterialOptions, label?: string): Promise<THREE.MeshPhysicalMaterial | THREE.MeshBasicMaterial>;
160
160
  /**
161
161
  * Create a Studio mode material from a threejs-materials format entry.
162
162
  *
@@ -167,11 +167,13 @@ declare class MaterialFactory {
167
167
  * @param values - Scalar PBR values from threejs-materials
168
168
  * @param textures - Texture map references from threejs-materials
169
169
  * @param textureRepeat - Optional [u, v] texture tiling applied to all loaded textures
170
+ * @param textureRotation - Optional texture rotation in radians (counterclockwise),
171
+ * pivoting around the texture center (0.5, 0.5)
170
172
  * @param textureCache - TextureCache for resolving data URI textures
171
173
  * @param label - Optional label for GPU tracking
172
174
  * @returns Configured MeshPhysicalMaterial
173
175
  */
174
- createStudioMaterialFromMaterialX(values: Record<string, unknown>, textures: Record<string, string>, textureRepeat: [number, number] | undefined, textureCache: TextureCacheInterface | null, label?: string): Promise<THREE.MeshPhysicalMaterial>;
176
+ createStudioMaterialFromMaterialX(values: Record<string, unknown>, textures: Record<string, string>, textureRepeat: [number, number] | undefined, textureRotation: number | undefined, textureCache: TextureCacheInterface | null, label?: string): Promise<THREE.MeshPhysicalMaterial>;
175
177
  /**
176
178
  * Apply alpha mode settings to a material.
177
179
  *
@@ -201,4 +203,4 @@ declare class MaterialFactory {
201
203
  update(options: UpdateOptions): void;
202
204
  }
203
205
  export { MaterialFactory };
204
- export type { MaterialFactoryOptions, UpdateOptions, StudioMaterialOptions, TextureCacheInterface };
206
+ export type { MaterialFactoryOptions, UpdateOptions, StudioMaterialOptions, TextureCacheInterface, };
@@ -11,7 +11,7 @@ export declare const TopoFilter: {
11
11
  face: "face";
12
12
  solid: "solid";
13
13
  };
14
- export type TopoFilterType = typeof TopoFilter[keyof typeof TopoFilter];
14
+ export type TopoFilterType = (typeof TopoFilter)[keyof typeof TopoFilter];
15
15
  interface RaycastFilters {
16
16
  topoFilter: TopoFilterType[];
17
17
  }
@@ -61,7 +61,7 @@ declare class StudioComposer {
61
61
  * @param width - Canvas width in pixels
62
62
  * @param height - Canvas height in pixels
63
63
  */
64
- constructor(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, width: number, height: number);
64
+ constructor(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, width: number, height: number, onSmaaReady?: () => void);
65
65
  /**
66
66
  * Enable or disable solid-background protection.
67
67
  *
@@ -7,7 +7,7 @@ declare const States: {
7
7
  readonly mixed: 2;
8
8
  readonly disabled: 3;
9
9
  };
10
- type StateValue = typeof States[keyof typeof States];
10
+ type StateValue = (typeof States)[keyof typeof States];
11
11
  /** Icon index: 0 for shapes, 1 for edges */
12
12
  type IconIndex = 0 | 1;
13
13
  /**