@buildcores/render-client 1.5.0 → 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/index.js CHANGED
@@ -270,6 +270,8 @@ const createRenderBuildJob = async (request, config) => {
270
270
  ...(request.gridSettings ? { gridSettings: request.gridSettings } : {}),
271
271
  // Include frame quality for sprite rendering
272
272
  ...(request.frameQuality ? { frameQuality: request.frameQuality } : {}),
273
+ // Include camera zoom for render-time scaling
274
+ ...(request.cameraZoom !== undefined ? { cameraZoom: request.cameraZoom } : {}),
273
275
  };
274
276
  const response = await fetch(buildApiUrl(API_ENDPOINTS.RENDER_BUILD, config), {
275
277
  method: "POST",
@@ -466,6 +468,7 @@ const createRenderByShareCodeJob = async (shareCode, config, options) => {
466
468
  ...(options?.cameraOffsetX !== undefined ? { cameraOffsetX: options.cameraOffsetX } : {}),
467
469
  ...(options?.gridSettings ? { gridSettings: options.gridSettings } : {}),
468
470
  ...(options?.frameQuality ? { frameQuality: options.frameQuality } : {}),
471
+ ...(options?.cameraZoom !== undefined ? { cameraZoom: options.cameraZoom } : {}),
469
472
  };
470
473
  const response = await fetch(url, {
471
474
  method: "POST",
@@ -693,6 +696,7 @@ const useSpriteRender = (input, apiConfig, onLoadStart, options) => {
693
696
  profile: currentInput.profile,
694
697
  showGrid: currentInput.showGrid,
695
698
  cameraOffsetX: currentInput.cameraOffsetX,
699
+ cameraZoom: currentInput.cameraZoom,
696
700
  gridSettings: currentInput.gridSettings,
697
701
  frameQuality: currentInput.frameQuality
698
702
  });
@@ -718,6 +722,7 @@ const useSpriteRender = (input, apiConfig, onLoadStart, options) => {
718
722
  ...currentParts,
719
723
  showGrid: currentInput.showGrid,
720
724
  cameraOffsetX: currentInput.cameraOffsetX,
725
+ cameraZoom: currentInput.cameraZoom,
721
726
  gridSettings: currentInput.gridSettings,
722
727
  frameQuality,
723
728
  }, apiConfig);
@@ -743,6 +748,7 @@ const useSpriteRender = (input, apiConfig, onLoadStart, options) => {
743
748
  format: "sprite",
744
749
  showGrid: currentInput.showGrid,
745
750
  cameraOffsetX: currentInput.cameraOffsetX,
751
+ cameraZoom: currentInput.cameraZoom,
746
752
  gridSettings: currentInput.gridSettings,
747
753
  frameQuality,
748
754
  }, apiConfig);
@@ -776,6 +782,7 @@ const useSpriteRender = (input, apiConfig, onLoadStart, options) => {
776
782
  a.profile === b.profile &&
777
783
  a.showGrid === b.showGrid &&
778
784
  a.cameraOffsetX === b.cameraOffsetX &&
785
+ a.cameraZoom === b.cameraZoom &&
779
786
  a.frameQuality === b.frameQuality &&
780
787
  gridSettingsEqual;
781
788
  }
@@ -785,6 +792,7 @@ const useSpriteRender = (input, apiConfig, onLoadStart, options) => {
785
792
  return arePartsEqual(a.parts, b.parts) &&
786
793
  a.showGrid === b.showGrid &&
787
794
  a.cameraOffsetX === b.cameraOffsetX &&
795
+ a.cameraZoom === b.cameraZoom &&
788
796
  a.frameQuality === b.frameQuality &&
789
797
  gridSettingsEqual;
790
798
  }
@@ -877,10 +885,10 @@ const getTouchDistance = (touches) => {
877
885
  return 0;
878
886
  return Math.hypot(second.clientX - first.clientX, second.clientY - first.clientY);
879
887
  };
880
- const useZoomPan = ({ displayWidth, displayHeight, minScale = 1, maxScale = 4, } = {}) => {
881
- const [scale, setScale] = react.useState(1);
888
+ const useZoomPan = ({ displayWidth, displayHeight, minScale = 0.5, maxScale = 2.5, initialScale = 1, } = {}) => {
889
+ const [scale, setScale] = react.useState(initialScale);
882
890
  const [isPinching, setIsPinching] = react.useState(false);
883
- const scaleRef = react.useRef(1);
891
+ const scaleRef = react.useRef(initialScale);
884
892
  const pinchDataRef = react.useRef({
885
893
  initialDistance: 0,
886
894
  initialScale: 1,
@@ -949,9 +957,9 @@ const useZoomPan = ({ displayWidth, displayHeight, minScale = 1, maxScale = 4, }
949
957
  };
950
958
  }, [isPinching, setScaleSafe]);
951
959
  const reset = react.useCallback(() => {
952
- scaleRef.current = 1;
953
- setScale(1);
954
- }, []);
960
+ scaleRef.current = initialScale;
961
+ setScale(initialScale);
962
+ }, [initialScale]);
955
963
  return {
956
964
  scale,
957
965
  isPinching,
@@ -961,7 +969,7 @@ const useZoomPan = ({ displayWidth, displayHeight, minScale = 1, maxScale = 4, }
961
969
  };
962
970
  };
963
971
 
964
- const BuildRender = ({ parts, shareCode, width, height, size, apiConfig, useSpriteRenderOptions, mouseSensitivity = 0.2, touchSensitivity = 0.2, showGrid, cameraOffsetX, gridSettings, animationMode = 'bounce', spinDuration = 10000, interactive = true, frameQuality, }) => {
972
+ const BuildRender = ({ parts, shareCode, width, height, size, apiConfig, useSpriteRenderOptions, mouseSensitivity = 0.2, touchSensitivity = 0.2, showGrid, cameraOffsetX, cameraZoom, gridSettings, animationMode = 'bounce', spinDuration = 10000, interactive = true, frameQuality, zoom = 1, }) => {
965
973
  const canvasRef = react.useRef(null);
966
974
  const containerRef = react.useRef(null);
967
975
  const [img, setImg] = react.useState(null);
@@ -978,6 +986,7 @@ const BuildRender = ({ parts, shareCode, width, height, size, apiConfig, useSpri
978
986
  profile: parts?.profile,
979
987
  showGrid,
980
988
  cameraOffsetX,
989
+ cameraZoom,
981
990
  gridSettings,
982
991
  frameQuality,
983
992
  };
@@ -987,10 +996,11 @@ const BuildRender = ({ parts, shareCode, width, height, size, apiConfig, useSpri
987
996
  parts: parts,
988
997
  showGrid,
989
998
  cameraOffsetX,
999
+ cameraZoom,
990
1000
  gridSettings,
991
1001
  frameQuality,
992
1002
  };
993
- }, [shareCode, parts, showGrid, cameraOffsetX, gridSettings, frameQuality]);
1003
+ }, [shareCode, parts, showGrid, cameraOffsetX, cameraZoom, gridSettings, frameQuality]);
994
1004
  // Use custom hook for sprite rendering
995
1005
  const { spriteSrc, isRenderingSprite, renderError, spriteMetadata } = useSpriteRender(renderInput, apiConfig, undefined, useSpriteRenderOptions);
996
1006
  const total = spriteMetadata ? spriteMetadata.totalFrames : 72;
@@ -1003,6 +1013,7 @@ const BuildRender = ({ parts, shareCode, width, height, size, apiConfig, useSpri
1003
1013
  const { scale, handleWheel: handleZoomWheel, handleTouchStart: handleZoomTouchStart, reset: resetZoom, } = useZoomPan({
1004
1014
  displayWidth: displayW,
1005
1015
  displayHeight: displayH,
1016
+ initialScale: zoom,
1006
1017
  });
1007
1018
  // Image/frame sizes - only calculate if image dimensions match expected metadata
1008
1019
  // This prevents using stale image with new metadata during transitions