@buildcores/render-client 1.0.9 → 1.0.10

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/index.d.ts CHANGED
@@ -45,24 +45,12 @@ interface BuildRenderVideoProps {
45
45
  */
46
46
  parts: RenderBuildRequest;
47
47
  /**
48
- * Video size in pixels (width and height will be the same).
49
- *
50
- * This determines the resolution of the rendered 3D video. Higher values
51
- * provide better quality but may impact performance.
52
- *
53
- * @example
54
- * ```tsx
55
- * <BuildRender parts={parts} size={300} /> // 300x300px
56
- * <BuildRender parts={parts} size={500} /> // 500x500px
57
- * <BuildRender parts={parts} size={800} /> // 800x800px - high quality
58
- * ```
59
- *
60
- * Recommended sizes:
61
- * - 300px: Good for thumbnails or small previews
62
- * - 500px: Standard size for most use cases
63
- * - 800px+: High quality for detailed viewing
48
+ * Width and height in pixels. If only `size` is provided, both width and height use it.
49
+ * If `width`/`height` are provided, they override `size` individually.
64
50
  */
65
- size: number;
51
+ width?: number;
52
+ height?: number;
53
+ size?: number;
66
54
  /**
67
55
  * API configuration for environment and authentication.
68
56
  * This is required to make API calls to the BuildCores rendering service.
@@ -159,19 +147,12 @@ interface BuildRenderProps {
159
147
  */
160
148
  parts: RenderBuildRequest;
161
149
  /**
162
- * Sprite size in pixels (width and height will be the same).
163
- *
164
- * This determines the display size of the rendered 3D sprite. The sprite sheet
165
- * itself is rendered at a fixed resolution, but this controls the display size.
166
- *
167
- * @example
168
- * ```tsx
169
- * <SpriteRender parts={parts} size={300} /> // 300x300px
170
- * <SpriteRender parts={parts} size={500} /> // 500x500px
171
- * <SpriteRender parts={parts} size={800} /> // 800x800px - larger display
172
- * ```
150
+ * Width and height in pixels. If only `size` is provided, both width and height use it.
151
+ * If `width`/`height` are provided, they override `size` individually.
173
152
  */
174
- size: number;
153
+ width?: number;
154
+ height?: number;
155
+ size?: number;
175
156
  /**
176
157
  * API configuration for environment and authentication.
177
158
  * This is required to make API calls to the BuildCores rendering service.
package/dist/index.esm.js CHANGED
@@ -729,11 +729,13 @@ const InstructionTooltip = ({ isVisible, progressValue, instructionIcon, }) => {
729
729
  } })) }));
730
730
  };
731
731
 
732
- const BuildRender = ({ parts, size, apiConfig, mouseSensitivity = 0.2, touchSensitivity = 0.2, }) => {
732
+ const BuildRender = ({ parts, width, height, size, apiConfig, mouseSensitivity = 0.2, touchSensitivity = 0.2, }) => {
733
733
  const canvasRef = useRef(null);
734
734
  const [img, setImg] = useState(null);
735
735
  const [isLoading, setIsLoading] = useState(true);
736
736
  const [bouncingAllowed, setBouncingAllowed] = useState(false);
737
+ const displayW = width ?? size ?? 300;
738
+ const displayH = height ?? size ?? 300;
737
739
  // Use custom hook for sprite rendering
738
740
  const { spriteSrc, isRenderingSprite, renderError, spriteMetadata } = useSpriteRender(parts, apiConfig);
739
741
  const { value: progressValue, isBouncing } = useBouncePatternProgress(bouncingAllowed);
@@ -779,8 +781,8 @@ const BuildRender = ({ parts, size, apiConfig, mouseSensitivity = 0.2, touchSens
779
781
  return;
780
782
  // Backing store sized for HiDPI; CSS size stays `size`
781
783
  const dpr = Math.max(1, window.devicePixelRatio || 1);
782
- const targetW = Math.round(size * dpr);
783
- const targetH = Math.round(size * dpr);
784
+ const targetW = Math.round(displayW * dpr);
785
+ const targetH = Math.round(displayH * dpr);
784
786
  if (cnv.width !== targetW || cnv.height !== targetH) {
785
787
  cnv.width = targetW;
786
788
  cnv.height = targetH;
@@ -800,7 +802,7 @@ const BuildRender = ({ parts, size, apiConfig, mouseSensitivity = 0.2, touchSens
800
802
  ctx.imageSmoothingEnabled = true;
801
803
  ctx.imageSmoothingQuality = "high";
802
804
  ctx.drawImage(img, sx, sy, sw, sh, 0, 0, targetW, targetH);
803
- }, [img, frameW, frameH, size, cols, total]);
805
+ }, [img, frameW, frameH, displayW, displayH, cols, total]);
804
806
  const { isDragging, handleMouseDown, handleTouchStart, hasDragged } = useSpriteScrubbing(canvasRef, total, {
805
807
  mouseSensitivity,
806
808
  touchSensitivity,
@@ -830,19 +832,19 @@ const BuildRender = ({ parts, size, apiConfig, mouseSensitivity = 0.2, touchSens
830
832
  }, [img, isLoading, draw]);
831
833
  return (jsxs("div", { style: {
832
834
  position: "relative",
833
- width: size,
834
- height: size,
835
+ width: displayW,
836
+ height: displayH,
835
837
  backgroundColor: "black",
836
838
  }, children: [img && (jsx("canvas", { ref: canvasRef, onMouseDown: handleMouseDown, onTouchStart: handleTouchStart, style: {
837
- width: size,
838
- height: size,
839
+ width: displayW,
840
+ height: displayH,
839
841
  cursor: isDragging ? "grabbing" : "grab",
840
842
  touchAction: "none", // Prevents default touch behaviors like scrolling
841
843
  display: "block",
842
844
  userSelect: "none",
843
845
  WebkitUserSelect: "none",
844
846
  WebkitTouchCallout: "none",
845
- }, role: "img", "aria-label": "360\u00B0 viewer", onContextMenu: (e) => e.preventDefault() })), jsx(LoadingErrorOverlay, { isVisible: isLoading || isRenderingSprite || !!renderError, renderError: renderError || undefined, size: size }), jsx(InstructionTooltip, { isVisible: !isLoading &&
847
+ }, role: "img", "aria-label": "360\u00B0 viewer", onContextMenu: (e) => e.preventDefault() })), jsx(LoadingErrorOverlay, { isVisible: isLoading || isRenderingSprite || !!renderError, renderError: renderError || undefined, size: Math.min(displayW, displayH) }), jsx(InstructionTooltip, { isVisible: !isLoading &&
846
848
  !isRenderingSprite &&
847
849
  !renderError &&
848
850
  isBouncing &&
@@ -942,10 +944,12 @@ const useVideoScrubbing = (videoRef, options = {}) => {
942
944
  };
943
945
  };
944
946
 
945
- const BuildRenderVideo = ({ parts, size, apiConfig, mouseSensitivity = 0.01, touchSensitivity = 0.01, }) => {
947
+ const BuildRenderVideo = ({ parts, width, height, size, apiConfig, mouseSensitivity = 0.01, touchSensitivity = 0.01, }) => {
946
948
  const videoRef = useRef(null);
947
949
  const [isLoading, setIsLoading] = useState(true);
948
950
  const [bouncingAllowed, setBouncingAllowed] = useState(false);
951
+ const displayW = width ?? size ?? 300;
952
+ const displayH = height ?? size ?? 300;
949
953
  // Use custom hook for build rendering
950
954
  const { videoSrc, isRenderingBuild, renderError } = useBuildRender(parts, apiConfig);
951
955
  const { value: progressValue, isBouncing } = useBouncePatternProgress(bouncingAllowed);
@@ -975,7 +979,7 @@ const BuildRenderVideo = ({ parts, size, apiConfig, mouseSensitivity = 0.01, tou
975
979
  videoRef.current.currentTime = time;
976
980
  }
977
981
  }, [progressValue, hasDragged]);
978
- return (jsxs("div", { style: { position: "relative", width: size, height: size }, children: [videoSrc && (jsx("video", { ref: videoRef, src: videoSrc, width: size, height: size, autoPlay: true, preload: "metadata", muted: true, playsInline: true, controls: false, disablePictureInPicture: true, controlsList: "nodownload nofullscreen noremoteplayback", ...{ "x-webkit-airplay": "deny" }, onMouseDown: handleMouseDown, onTouchStart: handleTouchStart, onLoadStart: handleLoadStartInternal, onCanPlay: handleCanPlayInternal, onLoadedData: () => {
982
+ return (jsxs("div", { style: { position: "relative", width: displayW, height: displayH }, children: [videoSrc && (jsx("video", { ref: videoRef, src: videoSrc, width: displayW, height: displayH, autoPlay: true, preload: "metadata", muted: true, playsInline: true, controls: false, disablePictureInPicture: true, controlsList: "nodownload nofullscreen noremoteplayback", ...{ "x-webkit-airplay": "deny" }, onMouseDown: handleMouseDown, onTouchStart: handleTouchStart, onLoadStart: handleLoadStartInternal, onCanPlay: handleCanPlayInternal, onLoadedData: () => {
979
983
  if (videoRef.current) {
980
984
  videoRef.current.pause();
981
985
  }
@@ -993,7 +997,7 @@ const BuildRenderVideo = ({ parts, size, apiConfig, mouseSensitivity = 0.01, tou
993
997
  WebkitTouchCallout: "none",
994
998
  WebkitUserSelect: "none",
995
999
  userSelect: "none",
996
- }, children: "Your browser does not support the video tag." }, videoSrc)), jsx(LoadingErrorOverlay, { isVisible: isLoading || isRenderingBuild || !!renderError, renderError: renderError || undefined, size: size }), jsx(InstructionTooltip, { isVisible: !isLoading &&
1000
+ }, children: "Your browser does not support the video tag." }, videoSrc)), jsx(LoadingErrorOverlay, { isVisible: isLoading || isRenderingBuild || !!renderError, renderError: renderError || undefined, size: Math.min(displayW, displayH) }), jsx(InstructionTooltip, { isVisible: !isLoading &&
997
1001
  !isRenderingBuild &&
998
1002
  !renderError &&
999
1003
  isBouncing &&