@buildcores/render-client 1.4.1 → 1.6.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/dist/hooks/useContinuousSpin.d.ts +17 -0
- package/dist/hooks/useSpriteRender.d.ts +4 -0
- package/dist/hooks/useZoomPan.d.ts +2 -1
- package/dist/index.d.ts +164 -1
- package/dist/index.esm.js +187 -53
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +187 -52
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +141 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ContinuousSpinResult {
|
|
2
|
+
/** Current frame index (integer part) */
|
|
3
|
+
frame: number;
|
|
4
|
+
/** Next frame index for interpolation */
|
|
5
|
+
nextFrame: number;
|
|
6
|
+
/** Blend factor between frames (0-1), used for cross-fade interpolation */
|
|
7
|
+
blend: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook for continuous 360° spin animation with smooth interpolation support.
|
|
11
|
+
*
|
|
12
|
+
* @param enabled - Whether the animation is enabled
|
|
13
|
+
* @param duration - Duration in ms for one full rotation (default: 10000ms = 10 seconds)
|
|
14
|
+
* @param totalFrames - Total number of frames in the sprite (default: 72)
|
|
15
|
+
* @returns Object with current frame, next frame, and blend factor for smooth interpolation
|
|
16
|
+
*/
|
|
17
|
+
export declare function useContinuousSpin(enabled?: boolean, duration?: number, totalFrames?: number): ContinuousSpinResult;
|
|
@@ -35,13 +35,17 @@ export type SpriteRenderInput = {
|
|
|
35
35
|
parts: RenderBuildRequest;
|
|
36
36
|
showGrid?: boolean;
|
|
37
37
|
cameraOffsetX?: number;
|
|
38
|
+
cameraZoom?: number;
|
|
38
39
|
gridSettings?: RenderGridSettings;
|
|
40
|
+
frameQuality?: 'standard' | 'high';
|
|
39
41
|
} | {
|
|
40
42
|
type: 'shareCode';
|
|
41
43
|
shareCode: string;
|
|
42
44
|
profile?: 'cinematic' | 'flat' | 'fast';
|
|
43
45
|
showGrid?: boolean;
|
|
44
46
|
cameraOffsetX?: number;
|
|
47
|
+
cameraZoom?: number;
|
|
45
48
|
gridSettings?: RenderGridSettings;
|
|
49
|
+
frameQuality?: 'standard' | 'high';
|
|
46
50
|
};
|
|
47
51
|
export declare const useSpriteRender: (input: RenderBuildRequest | SpriteRenderInput, apiConfig: ApiConfig, onLoadStart?: () => void, options?: UseSpriteRenderOptions) => UseSpriteRenderReturn;
|
|
@@ -4,6 +4,7 @@ interface UseZoomOptions {
|
|
|
4
4
|
displayHeight?: number;
|
|
5
5
|
minScale?: number;
|
|
6
6
|
maxScale?: number;
|
|
7
|
+
initialScale?: number;
|
|
7
8
|
}
|
|
8
9
|
interface UseZoomReturn {
|
|
9
10
|
scale: number;
|
|
@@ -12,5 +13,5 @@ interface UseZoomReturn {
|
|
|
12
13
|
handleTouchStart: (event: ReactTouchEvent<HTMLCanvasElement>) => boolean;
|
|
13
14
|
reset: () => void;
|
|
14
15
|
}
|
|
15
|
-
export declare const useZoomPan: ({ displayWidth, displayHeight, minScale, maxScale, }?: UseZoomOptions) => UseZoomReturn;
|
|
16
|
+
export declare const useZoomPan: ({ displayWidth, displayHeight, minScale, maxScale, initialScale, }?: UseZoomOptions) => UseZoomReturn;
|
|
16
17
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -240,6 +240,121 @@ interface BuildRenderProps {
|
|
|
240
240
|
* Works for both parts and shareCode rendering.
|
|
241
241
|
*/
|
|
242
242
|
gridSettings?: GridSettings;
|
|
243
|
+
/**
|
|
244
|
+
* Animation mode for the auto-rotation.
|
|
245
|
+
*
|
|
246
|
+
* - **bounce**: (default) Quick back-and-forth partial rotation with pauses
|
|
247
|
+
* - **spin360**: Slow continuous 360° rotation
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```tsx
|
|
251
|
+
* // Continuous slow spin (good for showcases)
|
|
252
|
+
* <BuildRender
|
|
253
|
+
* shareCode="abc123"
|
|
254
|
+
* animationMode="spin360"
|
|
255
|
+
* spinDuration={12000} // 12 seconds per full rotation
|
|
256
|
+
* />
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @default "bounce"
|
|
260
|
+
*/
|
|
261
|
+
animationMode?: 'bounce' | 'spin360';
|
|
262
|
+
/**
|
|
263
|
+
* Duration in milliseconds for one full 360° rotation.
|
|
264
|
+
* Only applies when `animationMode` is "spin360".
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```tsx
|
|
268
|
+
* <BuildRender
|
|
269
|
+
* shareCode="abc123"
|
|
270
|
+
* animationMode="spin360"
|
|
271
|
+
* spinDuration={15000} // 15 seconds per rotation
|
|
272
|
+
* />
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* @default 10000 (10 seconds)
|
|
276
|
+
*/
|
|
277
|
+
spinDuration?: number;
|
|
278
|
+
/**
|
|
279
|
+
* Whether to enable user interaction (drag to rotate, scroll to zoom).
|
|
280
|
+
*
|
|
281
|
+
* When set to `false`:
|
|
282
|
+
* - Drag-to-rotate is disabled
|
|
283
|
+
* - Scroll-to-zoom is disabled
|
|
284
|
+
* - Cursor shows as "pointer" instead of "grab"
|
|
285
|
+
* - Click events pass through (useful for wrapping in a link)
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```tsx
|
|
289
|
+
* // Non-interactive showcase with link
|
|
290
|
+
* <a href="https://buildcores.com/build/abc123">
|
|
291
|
+
* <BuildRender
|
|
292
|
+
* shareCode="abc123"
|
|
293
|
+
* animationMode="spin360"
|
|
294
|
+
* interactive={false}
|
|
295
|
+
* />
|
|
296
|
+
* </a>
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @default true
|
|
300
|
+
*/
|
|
301
|
+
interactive?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Frame quality for sprite renders.
|
|
304
|
+
* - **standard**: 72 frames (default) - good balance of quality and file size
|
|
305
|
+
* - **high**: 144 frames - smoother animation, larger file size (~2x file size)
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```tsx
|
|
309
|
+
* <BuildRender
|
|
310
|
+
* shareCode="abc123"
|
|
311
|
+
* frameQuality="high" // 144 frames for smoother rotation
|
|
312
|
+
* />
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @default "standard"
|
|
316
|
+
*/
|
|
317
|
+
frameQuality?: 'standard' | 'high';
|
|
318
|
+
/**
|
|
319
|
+
* Initial zoom level for the build.
|
|
320
|
+
* Range: 0.5 (50%) to 2.5 (250%). Values less than 1 make the build appear smaller,
|
|
321
|
+
* values greater than 1 make it appear larger.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```tsx
|
|
325
|
+
* <BuildRender
|
|
326
|
+
* shareCode="abc123"
|
|
327
|
+
* zoom={0.7} // 70% size - build appears smaller
|
|
328
|
+
* />
|
|
329
|
+
*
|
|
330
|
+
* <BuildRender
|
|
331
|
+
* shareCode="abc123"
|
|
332
|
+
* zoom={1.5} // 150% size - build appears larger
|
|
333
|
+
* />
|
|
334
|
+
* ```
|
|
335
|
+
*
|
|
336
|
+
* @default 1
|
|
337
|
+
*/
|
|
338
|
+
zoom?: number;
|
|
339
|
+
/**
|
|
340
|
+
* Camera zoom level for server-side rendering.
|
|
341
|
+
* Values > 1 move the camera further away (build appears smaller in the sprite).
|
|
342
|
+
* Values < 1 move the camera closer (build appears larger in the sprite).
|
|
343
|
+
*
|
|
344
|
+
* Use this for higher quality scaled-down renders vs client-side zoom scaling.
|
|
345
|
+
* Range: 0.5 to 2.0
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```tsx
|
|
349
|
+
* <BuildRender
|
|
350
|
+
* shareCode="abc123"
|
|
351
|
+
* cameraZoom={1.3} // Camera 30% further away - smaller build in sprite
|
|
352
|
+
* />
|
|
353
|
+
* ```
|
|
354
|
+
*
|
|
355
|
+
* @default 1
|
|
356
|
+
*/
|
|
357
|
+
cameraZoom?: number;
|
|
243
358
|
}
|
|
244
359
|
/**
|
|
245
360
|
* API configuration for environment and authentication
|
|
@@ -448,6 +563,23 @@ interface RenderBuildRequest {
|
|
|
448
563
|
* Only applies when showGrid is true.
|
|
449
564
|
*/
|
|
450
565
|
gridSettings?: GridSettings;
|
|
566
|
+
/**
|
|
567
|
+
* Frame quality for sprite renders.
|
|
568
|
+
* - **standard**: 72 frames (default) - good balance of quality and file size
|
|
569
|
+
* - **high**: 144 frames - smoother animation, larger file size
|
|
570
|
+
*
|
|
571
|
+
* @default "standard"
|
|
572
|
+
*/
|
|
573
|
+
frameQuality?: 'standard' | 'high';
|
|
574
|
+
/**
|
|
575
|
+
* Camera zoom level for server-side rendering.
|
|
576
|
+
* Values > 1 move the camera further away (build appears smaller in the sprite).
|
|
577
|
+
* Values < 1 move the camera closer (build appears larger in the sprite).
|
|
578
|
+
* Range: 0.5 to 2.0
|
|
579
|
+
*
|
|
580
|
+
* @default 1
|
|
581
|
+
*/
|
|
582
|
+
cameraZoom?: number;
|
|
451
583
|
}
|
|
452
584
|
/**
|
|
453
585
|
* Response structure containing all available parts for each category.
|
|
@@ -591,6 +723,11 @@ interface BuildResponse {
|
|
|
591
723
|
partDetails: {
|
|
592
724
|
[K in PartCategory]?: PartDetailsWithCategory[];
|
|
593
725
|
};
|
|
726
|
+
/**
|
|
727
|
+
* Whether the case in this build has an interactive 3D model available.
|
|
728
|
+
* If false, the build cannot be rendered in 3D.
|
|
729
|
+
*/
|
|
730
|
+
hasInteractiveModel: boolean;
|
|
594
731
|
}
|
|
595
732
|
/**
|
|
596
733
|
* Response from the get parts by IDs endpoint.
|
|
@@ -640,6 +777,10 @@ interface RenderByShareCodeOptions {
|
|
|
640
777
|
cameraOffsetX?: number;
|
|
641
778
|
/** Grid appearance settings (for thicker/more visible grid in renders) */
|
|
642
779
|
gridSettings?: GridSettings;
|
|
780
|
+
/** Frame quality - 'standard' (72 frames) or 'high' (144 frames for smoother animation) */
|
|
781
|
+
frameQuality?: 'standard' | 'high';
|
|
782
|
+
/** Camera zoom level for rendering. Values > 1 move camera further (build appears smaller). Range: 0.5 to 2.0 */
|
|
783
|
+
cameraZoom?: number;
|
|
643
784
|
/** Polling interval in milliseconds (default: 1500) */
|
|
644
785
|
pollIntervalMs?: number;
|
|
645
786
|
/** Timeout in milliseconds (default: 120000 = 2 minutes) */
|
|
@@ -708,6 +849,24 @@ declare function useBouncePatternProgress(enabled?: boolean): {
|
|
|
708
849
|
isBouncing: boolean;
|
|
709
850
|
};
|
|
710
851
|
|
|
852
|
+
interface ContinuousSpinResult {
|
|
853
|
+
/** Current frame index (integer part) */
|
|
854
|
+
frame: number;
|
|
855
|
+
/** Next frame index for interpolation */
|
|
856
|
+
nextFrame: number;
|
|
857
|
+
/** Blend factor between frames (0-1), used for cross-fade interpolation */
|
|
858
|
+
blend: number;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Hook for continuous 360° spin animation with smooth interpolation support.
|
|
862
|
+
*
|
|
863
|
+
* @param enabled - Whether the animation is enabled
|
|
864
|
+
* @param duration - Duration in ms for one full rotation (default: 10000ms = 10 seconds)
|
|
865
|
+
* @param totalFrames - Total number of frames in the sprite (default: 72)
|
|
866
|
+
* @returns Object with current frame, next frame, and blend factor for smooth interpolation
|
|
867
|
+
*/
|
|
868
|
+
declare function useContinuousSpin(enabled?: boolean, duration?: number, totalFrames?: number): ContinuousSpinResult;
|
|
869
|
+
|
|
711
870
|
/**
|
|
712
871
|
* Compares two RenderBuildRequest objects for equality by checking if the same IDs
|
|
713
872
|
* are present in each category array, regardless of order.
|
|
@@ -764,14 +923,18 @@ type SpriteRenderInput = {
|
|
|
764
923
|
parts: RenderBuildRequest;
|
|
765
924
|
showGrid?: boolean;
|
|
766
925
|
cameraOffsetX?: number;
|
|
926
|
+
cameraZoom?: number;
|
|
767
927
|
gridSettings?: RenderGridSettings;
|
|
928
|
+
frameQuality?: 'standard' | 'high';
|
|
768
929
|
} | {
|
|
769
930
|
type: 'shareCode';
|
|
770
931
|
shareCode: string;
|
|
771
932
|
profile?: 'cinematic' | 'flat' | 'fast';
|
|
772
933
|
showGrid?: boolean;
|
|
773
934
|
cameraOffsetX?: number;
|
|
935
|
+
cameraZoom?: number;
|
|
774
936
|
gridSettings?: RenderGridSettings;
|
|
937
|
+
frameQuality?: 'standard' | 'high';
|
|
775
938
|
};
|
|
776
939
|
declare const useSpriteRender: (input: RenderBuildRequest | SpriteRenderInput, apiConfig: ApiConfig, onLoadStart?: () => void, options?: UseSpriteRenderOptions) => UseSpriteRenderReturn;
|
|
777
940
|
|
|
@@ -939,5 +1102,5 @@ declare const createRenderByShareCodeJob: (shareCode: string, config: ApiConfig,
|
|
|
939
1102
|
*/
|
|
940
1103
|
declare const renderByShareCode: (shareCode: string, config: ApiConfig, options?: RenderByShareCodeOptions) => Promise<RenderByShareCodeResponse>;
|
|
941
1104
|
|
|
942
|
-
export { API_BASE_URL, API_ENDPOINTS, BuildRender, BuildRenderVideo, DragIcon, InstructionTooltip, LoadingErrorOverlay, PartCategory, arePartsEqual, buildApiUrl, buildHeaders, calculateCircularFrame, calculateCircularTime, createRenderByShareCodeJob, getAvailableParts, getBuildByShareCode, getPartsByIds, renderBuildExperimental, renderByShareCode, renderSpriteExperimental, useBouncePatternProgress, useBuildRender, useSpriteRender, useSpriteScrubbing, useVideoScrubbing };
|
|
1105
|
+
export { API_BASE_URL, API_ENDPOINTS, BuildRender, BuildRenderVideo, DragIcon, InstructionTooltip, LoadingErrorOverlay, PartCategory, arePartsEqual, buildApiUrl, buildHeaders, calculateCircularFrame, calculateCircularTime, createRenderByShareCodeJob, getAvailableParts, getBuildByShareCode, getPartsByIds, renderBuildExperimental, renderByShareCode, renderSpriteExperimental, useBouncePatternProgress, useBuildRender, useContinuousSpin, useSpriteRender, useSpriteScrubbing, useVideoScrubbing };
|
|
943
1106
|
export type { ApiConfig, AvailablePartsResponse, BuildRenderProps, BuildRenderVideoProps, BuildResponse, GetAvailablePartsOptions, GridSettings, PartDetails, PartDetailsWithCategory, PartsResponse, RenderAPIService, RenderBuildRequest, RenderBuildResponse, RenderByShareCodeJobResponse, RenderByShareCodeOptions, RenderByShareCodeResponse, RenderSpriteResponse, SpriteRenderInput, UseBuildRenderOptions, UseBuildRenderReturn, UseSpriteRenderOptions, UseSpriteRenderReturn };
|