@layoutit/polycss-react 0.2.2 → 0.2.4

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/README.md CHANGED
@@ -84,6 +84,7 @@ export default function App() {
84
84
  - `autoCenter` shifts the mesh bbox center to local origin.
85
85
  - `meshResolution` chooses `"lossy"` (default) or `"lossless"` optimization. STL imports use the conservative lossless path in both modes.
86
86
  - `castShadow` emits CSS-projected shadows in dynamic lighting mode.
87
+ - Tooling can reuse `buildPolyMeshTransform`, `worldPositionToPolyCss`, `worldDirectionToPolyCss`, `worldDistanceToPolyCss`, `polyCssDistanceToWorld`, and `polyCssPositionToWorld` for renderer-compatible transforms and world/CSS conversions.
87
88
 
88
89
  ### Controls
89
90
 
package/dist/index.cjs CHANGED
@@ -63,6 +63,7 @@ __export(src_exports, {
63
63
  bakeSolidTextureSampledPolygons: () => import_polycss_core27.bakeSolidTextureSampledPolygons,
64
64
  bakeSolidTextureSamples: () => import_polycss_core27.bakeSolidTextureSamples,
65
65
  boxPolygons: () => import_polycss_core27.boxPolygons,
66
+ buildPolyMeshTransform: () => import_polycss_core27.buildPolyMeshTransform,
66
67
  buildSceneContext: () => import_polycss_core27.buildSceneContext,
67
68
  cameraCullNormalGroups: () => import_polycss_core27.cameraCullNormalGroups,
68
69
  cameraCullNormalGroupsFromPolygons: () => import_polycss_core27.cameraCullNormalGroupsFromPolygons,
@@ -109,6 +110,8 @@ __export(src_exports, {
109
110
  parseVox: () => import_polycss_core27.parseVox,
110
111
  planePolygons: () => import_polycss_core27.planePolygons,
111
112
  pointInMeshElement: () => pointInMeshElement,
113
+ polyCssDistanceToWorld: () => import_polycss_core27.cssDistanceToWorld,
114
+ polyCssPositionToWorld: () => import_polycss_core27.cssPositionToWorld,
112
115
  polygonCssSurfaceNormal: () => import_polycss_core27.polygonCssSurfaceNormal,
113
116
  polygonFaces: () => import_polycss_core27.polygonFaces,
114
117
  polygonFacesCamera: () => import_polycss_core27.polygonFacesCamera,
@@ -131,7 +134,10 @@ __export(src_exports, {
131
134
  usePolyMesh: () => usePolyMesh,
132
135
  usePolySceneContext: () => usePolySceneContext,
133
136
  usePolySelect: () => usePolySelect,
134
- usePolySelectionApi: () => usePolySelectionApi
137
+ usePolySelectionApi: () => usePolySelectionApi,
138
+ worldDirectionToPolyCss: () => import_polycss_core27.worldDirectionToCss,
139
+ worldDistanceToPolyCss: () => import_polycss_core27.worldDistanceToCss,
140
+ worldPositionToPolyCss: () => import_polycss_core27.worldPositionToCss
135
141
  });
136
142
  module.exports = __toCommonJS(src_exports);
137
143
 
@@ -3699,27 +3705,6 @@ function solidPaintVars(defaults) {
3699
3705
  }
3700
3706
  return Object.keys(out).length > 0 ? out : null;
3701
3707
  }
3702
- function buildTransform(position, scale, rotation) {
3703
- const sx = typeof scale === "number" ? scale : scale?.[0] ?? 1;
3704
- const sy = typeof scale === "number" ? scale : scale?.[1] ?? 1;
3705
- const sz = typeof scale === "number" ? scale : scale?.[2] ?? 1;
3706
- const hasScale = sx !== 1 || sy !== 1 || sz !== 1;
3707
- const hasRotation = !!rotation && (!!rotation[0] || !!rotation[1] || !!rotation[2]);
3708
- const cssPos = position ? [position[1] * import_polycss_core16.BASE_TILE, position[0] * import_polycss_core16.BASE_TILE, position[2] * import_polycss_core16.BASE_TILE] : [0, 0, 0];
3709
- const parts = [];
3710
- if (cssPos[0] !== 0 || cssPos[1] !== 0 || cssPos[2] !== 0) {
3711
- parts.push(`translate3d(${cssPos[0]}px, ${cssPos[1]}px, ${cssPos[2]}px)`);
3712
- }
3713
- if (hasRotation) {
3714
- if (rotation[0]) parts.push(`rotateY(${-rotation[0]}deg)`);
3715
- if (rotation[1]) parts.push(`rotateX(${-rotation[1]}deg)`);
3716
- if (rotation[2]) parts.push(`rotateZ(${-rotation[2]}deg)`);
3717
- }
3718
- if (hasScale) {
3719
- parts.push(`scale3d(${sx}, ${sy}, ${sz})`);
3720
- }
3721
- return parts.length > 0 ? parts.join(" ") : void 0;
3722
- }
3723
3708
  function recenterPolygons(polygons) {
3724
3709
  if (polygons.length === 0) return polygons;
3725
3710
  const bbox = (0, import_polycss_core16.computeSceneBbox)(polygons);
@@ -3807,7 +3792,7 @@ var PolyMesh = (0, import_react16.forwardRef)(function PolyMesh2({
3807
3792
  () => autoCenter ? recenterPolygons(sourcePolygons) : sourcePolygons,
3808
3793
  [sourcePolygons, autoCenter]
3809
3794
  );
3810
- const transform = buildTransform(position, scale, rotation);
3795
+ const transform = (0, import_polycss_core16.buildPolyMeshTransform)({ position, scale, rotation });
3811
3796
  const wrapperRef = (0, import_react16.useRef)(null);
3812
3797
  const propsRef = (0, import_react16.useRef)({ position, scale, rotation });
3813
3798
  propsRef.current = { position, scale, rotation };
@@ -7309,6 +7294,7 @@ var import_polycss_core27 = require("@layoutit/polycss-core");
7309
7294
  bakeSolidTextureSampledPolygons,
7310
7295
  bakeSolidTextureSamples,
7311
7296
  boxPolygons,
7297
+ buildPolyMeshTransform,
7312
7298
  buildSceneContext,
7313
7299
  cameraCullNormalGroups,
7314
7300
  cameraCullNormalGroupsFromPolygons,
@@ -7355,6 +7341,8 @@ var import_polycss_core27 = require("@layoutit/polycss-core");
7355
7341
  parseVox,
7356
7342
  planePolygons,
7357
7343
  pointInMeshElement,
7344
+ polyCssDistanceToWorld,
7345
+ polyCssPositionToWorld,
7358
7346
  polygonCssSurfaceNormal,
7359
7347
  polygonFaces,
7360
7348
  polygonFacesCamera,
@@ -7377,5 +7365,8 @@ var import_polycss_core27 = require("@layoutit/polycss-core");
7377
7365
  usePolyMesh,
7378
7366
  usePolySceneContext,
7379
7367
  usePolySelect,
7380
- usePolySelectionApi
7368
+ usePolySelectionApi,
7369
+ worldDirectionToPolyCss,
7370
+ worldDistanceToPolyCss,
7371
+ worldPositionToPolyCss
7381
7372
  });
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ import React__default, { ReactNode, CSSProperties, MouseEventHandler, PointerEve
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as _layoutit_polycss_core from '@layoutit/polycss-core';
5
5
  import { Vec3, CameraState, CameraHandle, Vec2, PolyMaterial, PolyDirectionalLight, PolyTextureLightingMode, TextureQuality, Polygon, PolyAmbientLight, PolySeamBleed, PolyRenderStrategiesOption, LoadMeshOptions, ParseResult, MeshResolution, BoxPolygonsOptions, ConePolygonsOptions, CylinderPolygonsOptions, DodecahedronPolygonsOptions, IcosahedronPolygonsOptions, OctahedronPolygonsOptions, PlanePolygonsOptions, RingPolygonsOptions, SpherePolygonsOptions, TetrahedronPolygonsOptions, TorusPolygonsOptions, PolyAnimationTarget, PolyAnimationMixer, PolyAnimationClip, PolyAnimationAction, ParseAnimationController } from '@layoutit/polycss-core';
6
- export { ArrowPolygonsOptions, AutoRotateConfig, AutoRotateOption, AxesHelperOptions, BASE_TILE, BoxFace, BoxFaceOptions, BoxPolygonsOptions, CAMERA_BACKFACE_CULL_EPS, CameraCullNormalGroup, CameraCullRotation, CameraHandle, CameraState, CameraStyleInput, ConePolygonsOptions, CoverPlanarPolygonsOptions, CullInteriorOptions, CylinderPolygonsOptions, DEFAULT_CAMERA_STATE, DEFAULT_PROJECTION, DEFAULT_SEAM_FACET_SPLIT_OPTIONS, DEFAULT_SEAM_OVERLAP_OPTIONS, DodecahedronPolygonsOptions, GltfParseOptions, IcosahedronPolygonsOptions, LoadMeshOptions, LoopMode, LoopOnce, LoopPingPong, LoopRepeat, MeshResolution, MtlParseResult, NormalizeResult, ObjParseOptions, OctahedronPolygonsOptions, OptimizeAnimatedMeshPolygonsOptions, OptimizeMeshParseResultOptions, OptimizeMeshPolygonsOptions, ParseAnimationClip, ParseAnimationController, ParseResult, ParseStlColor, ParseStlSolid, ParseStlTopology, ParsedColor, PlanePolygonsOptions, PolyAmbientLight, PolyAnimationAction, PolyAnimationClip, PolyAnimationMixer, PolyAnimationTarget, PolyDirectionalLight, PolyMaterial, PolyRenderStrategiesOption, PolyRenderStrategy, PolyTextureLightingMode, Polygon, PolygonFace, RingPolygonsOptions, SceneBbox, SceneContext, SceneContextBuildArgs, SceneContextBuildResult, SeamFacetSplitCandidate, SeamFacetSplitCandidateReason, SeamFacetSplitOptions, SeamFacetSplitReport, SeamOverlapCandidate, SeamOverlapCandidateKind, SeamOverlapDiagnostics, SeamOverlapOptions, SimplifyTriangleMeshPolygonsOptions, SolidTextureSampleOptions, StlParseOptions, TetrahedronPolygonsOptions, TexturePaintMetrics, TexturePaintMetricsOptions, TextureTriangle, TorusPolygonsOptions, VOXEL_CAMERA_CULL_AXIS_EPS, VOXEL_CAMERA_CULL_NORMAL_LIMIT, Vec2, Vec3, VoxParseOptions, arrowPolygons, axesHelperPolygons, bakeSolidTextureSampledPolygons, bakeSolidTextureSamples, boxPolygons, buildSceneContext, cameraCullNormalGroups, cameraCullNormalGroupsFromPolygons, cameraCullNormalKey, cameraCullVisibleSignature, cameraFacingDepth, clampChannel, computeSceneBbox, computeShapeLighting, computeTexturePaintMetrics, conePolygons, coverPlanarPolygons, createIsometricCamera, createPolyAnimationMixer, cullInteriorPolygons, cylinderPolygons, dodecahedronPolygons, formatColor, icosahedronPolygons, inverseRotateVec3, isAxisAlignedSurfaceNormal, isVoxelCameraCullableNormalGroups, loadMesh, mergePolygons, normalFacesCamera, normalizeInvertMultiplier, normalizePolygons, octahedronPolygons, optimizeAnimatedMeshPolygons, optimizeMeshParseResult, optimizeMeshPolygons, parseColor, parseGltf, parseHexColor, parseMtl, parseObj, parsePureColor, parseRgbColor, parseStl, parseVox, planePolygons, polygonCssSurfaceNormal, polygonFaces, polygonFacesCamera, repairMeshSeams, ringPolygons, rotateVec3, seamFacetSplitPolygons, seamFacetSplitReport, seamOverlapDiagnostics, seamOverlapPolygons, seamOverlapReport, shadeColor, simplifyTriangleMeshPolygons, tetrahedronPolygons, torusPolygons } from '@layoutit/polycss-core';
6
+ export { ArrowPolygonsOptions, AutoRotateConfig, AutoRotateOption, AxesHelperOptions, BASE_TILE, BoxFace, BoxFaceOptions, BoxPolygonsOptions, CAMERA_BACKFACE_CULL_EPS, CameraCullNormalGroup, CameraCullRotation, CameraHandle, CameraState, CameraStyleInput, ConePolygonsOptions, CoverPlanarPolygonsOptions, CullInteriorOptions, CylinderPolygonsOptions, DEFAULT_CAMERA_STATE, DEFAULT_PROJECTION, DEFAULT_SEAM_FACET_SPLIT_OPTIONS, DEFAULT_SEAM_OVERLAP_OPTIONS, DodecahedronPolygonsOptions, GltfParseOptions, IcosahedronPolygonsOptions, LoadMeshOptions, LoopMode, LoopOnce, LoopPingPong, LoopRepeat, MeshResolution, MtlParseResult, NormalizeResult, ObjParseOptions, OctahedronPolygonsOptions, OptimizeAnimatedMeshPolygonsOptions, OptimizeMeshParseResultOptions, OptimizeMeshPolygonsOptions, ParseAnimationClip, ParseAnimationController, ParseResult, ParseStlColor, ParseStlSolid, ParseStlTopology, ParsedColor, PlanePolygonsOptions, PolyAmbientLight, PolyAnimationAction, PolyAnimationClip, PolyAnimationMixer, PolyAnimationTarget, PolyDirectionalLight, PolyMaterial, PolyMeshTransformInput, PolyRenderStrategiesOption, PolyRenderStrategy, PolyTextureLightingMode, Polygon, PolygonFace, RingPolygonsOptions, SceneBbox, SceneContext, SceneContextBuildArgs, SceneContextBuildResult, SeamFacetSplitCandidate, SeamFacetSplitCandidateReason, SeamFacetSplitOptions, SeamFacetSplitReport, SeamOverlapCandidate, SeamOverlapCandidateKind, SeamOverlapDiagnostics, SeamOverlapOptions, SimplifyTriangleMeshPolygonsOptions, SolidTextureSampleOptions, StlParseOptions, TetrahedronPolygonsOptions, TexturePaintMetrics, TexturePaintMetricsOptions, TextureTriangle, TorusPolygonsOptions, VOXEL_CAMERA_CULL_AXIS_EPS, VOXEL_CAMERA_CULL_NORMAL_LIMIT, Vec2, Vec3, VoxParseOptions, arrowPolygons, axesHelperPolygons, bakeSolidTextureSampledPolygons, bakeSolidTextureSamples, boxPolygons, buildPolyMeshTransform, buildSceneContext, cameraCullNormalGroups, cameraCullNormalGroupsFromPolygons, cameraCullNormalKey, cameraCullVisibleSignature, cameraFacingDepth, clampChannel, computeSceneBbox, computeShapeLighting, computeTexturePaintMetrics, conePolygons, coverPlanarPolygons, createIsometricCamera, createPolyAnimationMixer, cullInteriorPolygons, cylinderPolygons, dodecahedronPolygons, formatColor, icosahedronPolygons, inverseRotateVec3, isAxisAlignedSurfaceNormal, isVoxelCameraCullableNormalGroups, loadMesh, mergePolygons, normalFacesCamera, normalizeInvertMultiplier, normalizePolygons, octahedronPolygons, optimizeAnimatedMeshPolygons, optimizeMeshParseResult, optimizeMeshPolygons, parseColor, parseGltf, parseHexColor, parseMtl, parseObj, parsePureColor, parseRgbColor, parseStl, parseVox, planePolygons, cssDistanceToWorld as polyCssDistanceToWorld, cssPositionToWorld as polyCssPositionToWorld, polygonCssSurfaceNormal, polygonFaces, polygonFacesCamera, repairMeshSeams, ringPolygons, rotateVec3, seamFacetSplitPolygons, seamFacetSplitReport, seamOverlapDiagnostics, seamOverlapPolygons, seamOverlapReport, shadeColor, simplifyTriangleMeshPolygons, tetrahedronPolygons, torusPolygons, worldDirectionToCss as worldDirectionToPolyCss, worldDistanceToCss as worldDistanceToPolyCss, worldPositionToCss as worldPositionToPolyCss } from '@layoutit/polycss-core';
7
7
 
8
8
  interface PolyPerspectiveCameraProps {
9
9
  zoom?: number;
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import React__default, { ReactNode, CSSProperties, MouseEventHandler, PointerEve
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as _layoutit_polycss_core from '@layoutit/polycss-core';
5
5
  import { Vec3, CameraState, CameraHandle, Vec2, PolyMaterial, PolyDirectionalLight, PolyTextureLightingMode, TextureQuality, Polygon, PolyAmbientLight, PolySeamBleed, PolyRenderStrategiesOption, LoadMeshOptions, ParseResult, MeshResolution, BoxPolygonsOptions, ConePolygonsOptions, CylinderPolygonsOptions, DodecahedronPolygonsOptions, IcosahedronPolygonsOptions, OctahedronPolygonsOptions, PlanePolygonsOptions, RingPolygonsOptions, SpherePolygonsOptions, TetrahedronPolygonsOptions, TorusPolygonsOptions, PolyAnimationTarget, PolyAnimationMixer, PolyAnimationClip, PolyAnimationAction, ParseAnimationController } from '@layoutit/polycss-core';
6
- export { ArrowPolygonsOptions, AutoRotateConfig, AutoRotateOption, AxesHelperOptions, BASE_TILE, BoxFace, BoxFaceOptions, BoxPolygonsOptions, CAMERA_BACKFACE_CULL_EPS, CameraCullNormalGroup, CameraCullRotation, CameraHandle, CameraState, CameraStyleInput, ConePolygonsOptions, CoverPlanarPolygonsOptions, CullInteriorOptions, CylinderPolygonsOptions, DEFAULT_CAMERA_STATE, DEFAULT_PROJECTION, DEFAULT_SEAM_FACET_SPLIT_OPTIONS, DEFAULT_SEAM_OVERLAP_OPTIONS, DodecahedronPolygonsOptions, GltfParseOptions, IcosahedronPolygonsOptions, LoadMeshOptions, LoopMode, LoopOnce, LoopPingPong, LoopRepeat, MeshResolution, MtlParseResult, NormalizeResult, ObjParseOptions, OctahedronPolygonsOptions, OptimizeAnimatedMeshPolygonsOptions, OptimizeMeshParseResultOptions, OptimizeMeshPolygonsOptions, ParseAnimationClip, ParseAnimationController, ParseResult, ParseStlColor, ParseStlSolid, ParseStlTopology, ParsedColor, PlanePolygonsOptions, PolyAmbientLight, PolyAnimationAction, PolyAnimationClip, PolyAnimationMixer, PolyAnimationTarget, PolyDirectionalLight, PolyMaterial, PolyRenderStrategiesOption, PolyRenderStrategy, PolyTextureLightingMode, Polygon, PolygonFace, RingPolygonsOptions, SceneBbox, SceneContext, SceneContextBuildArgs, SceneContextBuildResult, SeamFacetSplitCandidate, SeamFacetSplitCandidateReason, SeamFacetSplitOptions, SeamFacetSplitReport, SeamOverlapCandidate, SeamOverlapCandidateKind, SeamOverlapDiagnostics, SeamOverlapOptions, SimplifyTriangleMeshPolygonsOptions, SolidTextureSampleOptions, StlParseOptions, TetrahedronPolygonsOptions, TexturePaintMetrics, TexturePaintMetricsOptions, TextureTriangle, TorusPolygonsOptions, VOXEL_CAMERA_CULL_AXIS_EPS, VOXEL_CAMERA_CULL_NORMAL_LIMIT, Vec2, Vec3, VoxParseOptions, arrowPolygons, axesHelperPolygons, bakeSolidTextureSampledPolygons, bakeSolidTextureSamples, boxPolygons, buildSceneContext, cameraCullNormalGroups, cameraCullNormalGroupsFromPolygons, cameraCullNormalKey, cameraCullVisibleSignature, cameraFacingDepth, clampChannel, computeSceneBbox, computeShapeLighting, computeTexturePaintMetrics, conePolygons, coverPlanarPolygons, createIsometricCamera, createPolyAnimationMixer, cullInteriorPolygons, cylinderPolygons, dodecahedronPolygons, formatColor, icosahedronPolygons, inverseRotateVec3, isAxisAlignedSurfaceNormal, isVoxelCameraCullableNormalGroups, loadMesh, mergePolygons, normalFacesCamera, normalizeInvertMultiplier, normalizePolygons, octahedronPolygons, optimizeAnimatedMeshPolygons, optimizeMeshParseResult, optimizeMeshPolygons, parseColor, parseGltf, parseHexColor, parseMtl, parseObj, parsePureColor, parseRgbColor, parseStl, parseVox, planePolygons, polygonCssSurfaceNormal, polygonFaces, polygonFacesCamera, repairMeshSeams, ringPolygons, rotateVec3, seamFacetSplitPolygons, seamFacetSplitReport, seamOverlapDiagnostics, seamOverlapPolygons, seamOverlapReport, shadeColor, simplifyTriangleMeshPolygons, tetrahedronPolygons, torusPolygons } from '@layoutit/polycss-core';
6
+ export { ArrowPolygonsOptions, AutoRotateConfig, AutoRotateOption, AxesHelperOptions, BASE_TILE, BoxFace, BoxFaceOptions, BoxPolygonsOptions, CAMERA_BACKFACE_CULL_EPS, CameraCullNormalGroup, CameraCullRotation, CameraHandle, CameraState, CameraStyleInput, ConePolygonsOptions, CoverPlanarPolygonsOptions, CullInteriorOptions, CylinderPolygonsOptions, DEFAULT_CAMERA_STATE, DEFAULT_PROJECTION, DEFAULT_SEAM_FACET_SPLIT_OPTIONS, DEFAULT_SEAM_OVERLAP_OPTIONS, DodecahedronPolygonsOptions, GltfParseOptions, IcosahedronPolygonsOptions, LoadMeshOptions, LoopMode, LoopOnce, LoopPingPong, LoopRepeat, MeshResolution, MtlParseResult, NormalizeResult, ObjParseOptions, OctahedronPolygonsOptions, OptimizeAnimatedMeshPolygonsOptions, OptimizeMeshParseResultOptions, OptimizeMeshPolygonsOptions, ParseAnimationClip, ParseAnimationController, ParseResult, ParseStlColor, ParseStlSolid, ParseStlTopology, ParsedColor, PlanePolygonsOptions, PolyAmbientLight, PolyAnimationAction, PolyAnimationClip, PolyAnimationMixer, PolyAnimationTarget, PolyDirectionalLight, PolyMaterial, PolyMeshTransformInput, PolyRenderStrategiesOption, PolyRenderStrategy, PolyTextureLightingMode, Polygon, PolygonFace, RingPolygonsOptions, SceneBbox, SceneContext, SceneContextBuildArgs, SceneContextBuildResult, SeamFacetSplitCandidate, SeamFacetSplitCandidateReason, SeamFacetSplitOptions, SeamFacetSplitReport, SeamOverlapCandidate, SeamOverlapCandidateKind, SeamOverlapDiagnostics, SeamOverlapOptions, SimplifyTriangleMeshPolygonsOptions, SolidTextureSampleOptions, StlParseOptions, TetrahedronPolygonsOptions, TexturePaintMetrics, TexturePaintMetricsOptions, TextureTriangle, TorusPolygonsOptions, VOXEL_CAMERA_CULL_AXIS_EPS, VOXEL_CAMERA_CULL_NORMAL_LIMIT, Vec2, Vec3, VoxParseOptions, arrowPolygons, axesHelperPolygons, bakeSolidTextureSampledPolygons, bakeSolidTextureSamples, boxPolygons, buildPolyMeshTransform, buildSceneContext, cameraCullNormalGroups, cameraCullNormalGroupsFromPolygons, cameraCullNormalKey, cameraCullVisibleSignature, cameraFacingDepth, clampChannel, computeSceneBbox, computeShapeLighting, computeTexturePaintMetrics, conePolygons, coverPlanarPolygons, createIsometricCamera, createPolyAnimationMixer, cullInteriorPolygons, cylinderPolygons, dodecahedronPolygons, formatColor, icosahedronPolygons, inverseRotateVec3, isAxisAlignedSurfaceNormal, isVoxelCameraCullableNormalGroups, loadMesh, mergePolygons, normalFacesCamera, normalizeInvertMultiplier, normalizePolygons, octahedronPolygons, optimizeAnimatedMeshPolygons, optimizeMeshParseResult, optimizeMeshPolygons, parseColor, parseGltf, parseHexColor, parseMtl, parseObj, parsePureColor, parseRgbColor, parseStl, parseVox, planePolygons, cssDistanceToWorld as polyCssDistanceToWorld, cssPositionToWorld as polyCssPositionToWorld, polygonCssSurfaceNormal, polygonFaces, polygonFacesCamera, repairMeshSeams, ringPolygons, rotateVec3, seamFacetSplitPolygons, seamFacetSplitReport, seamOverlapDiagnostics, seamOverlapPolygons, seamOverlapReport, shadeColor, simplifyTriangleMeshPolygons, tetrahedronPolygons, torusPolygons, worldDirectionToCss as worldDirectionToPolyCss, worldDistanceToCss as worldDistanceToPolyCss, worldPositionToCss as worldPositionToPolyCss } from '@layoutit/polycss-core';
7
7
 
8
8
  interface PolyPerspectiveCameraProps {
9
9
  zoom?: number;
package/dist/index.js CHANGED
@@ -2782,6 +2782,7 @@ import {
2782
2782
  } from "react";
2783
2783
  import {
2784
2784
  BASE_TILE as BASE_TILE4,
2785
+ buildPolyMeshTransform,
2785
2786
  buildSharedEdgeMap,
2786
2787
  computeReceiverShadowFaces,
2787
2788
  computeSceneBbox,
@@ -3635,27 +3636,6 @@ function solidPaintVars(defaults) {
3635
3636
  }
3636
3637
  return Object.keys(out).length > 0 ? out : null;
3637
3638
  }
3638
- function buildTransform(position, scale, rotation) {
3639
- const sx = typeof scale === "number" ? scale : scale?.[0] ?? 1;
3640
- const sy = typeof scale === "number" ? scale : scale?.[1] ?? 1;
3641
- const sz = typeof scale === "number" ? scale : scale?.[2] ?? 1;
3642
- const hasScale = sx !== 1 || sy !== 1 || sz !== 1;
3643
- const hasRotation = !!rotation && (!!rotation[0] || !!rotation[1] || !!rotation[2]);
3644
- const cssPos = position ? [position[1] * BASE_TILE4, position[0] * BASE_TILE4, position[2] * BASE_TILE4] : [0, 0, 0];
3645
- const parts = [];
3646
- if (cssPos[0] !== 0 || cssPos[1] !== 0 || cssPos[2] !== 0) {
3647
- parts.push(`translate3d(${cssPos[0]}px, ${cssPos[1]}px, ${cssPos[2]}px)`);
3648
- }
3649
- if (hasRotation) {
3650
- if (rotation[0]) parts.push(`rotateY(${-rotation[0]}deg)`);
3651
- if (rotation[1]) parts.push(`rotateX(${-rotation[1]}deg)`);
3652
- if (rotation[2]) parts.push(`rotateZ(${-rotation[2]}deg)`);
3653
- }
3654
- if (hasScale) {
3655
- parts.push(`scale3d(${sx}, ${sy}, ${sz})`);
3656
- }
3657
- return parts.length > 0 ? parts.join(" ") : void 0;
3658
- }
3659
3639
  function recenterPolygons(polygons) {
3660
3640
  if (polygons.length === 0) return polygons;
3661
3641
  const bbox = computeSceneBbox(polygons);
@@ -3743,7 +3723,7 @@ var PolyMesh = forwardRef(function PolyMesh2({
3743
3723
  () => autoCenter ? recenterPolygons(sourcePolygons) : sourcePolygons,
3744
3724
  [sourcePolygons, autoCenter]
3745
3725
  );
3746
- const transform = buildTransform(position, scale, rotation);
3726
+ const transform = buildPolyMeshTransform({ position, scale, rotation });
3747
3727
  const wrapperRef = useRef6(null);
3748
3728
  const propsRef = useRef6({ position, scale, rotation });
3749
3729
  propsRef.current = { position, scale, rotation };
@@ -7296,6 +7276,7 @@ import {
7296
7276
  torusPolygons as torusPolygons2,
7297
7277
  planePolygons as planePolygons3,
7298
7278
  buildSceneContext as buildSceneContext2,
7279
+ buildPolyMeshTransform as buildPolyMeshTransform2,
7299
7280
  computeSceneBbox as computeSceneBbox2,
7300
7281
  BASE_TILE as BASE_TILE8,
7301
7282
  DEFAULT_CAMERA_STATE as DEFAULT_CAMERA_STATE2,
@@ -7307,7 +7288,12 @@ import {
7307
7288
  DEFAULT_SEAM_OVERLAP_OPTIONS,
7308
7289
  LoopOnce,
7309
7290
  LoopRepeat,
7310
- LoopPingPong
7291
+ LoopPingPong,
7292
+ cssDistanceToWorld,
7293
+ cssPositionToWorld,
7294
+ worldDistanceToCss,
7295
+ worldDirectionToCss as worldDirectionToCss3,
7296
+ worldPositionToCss
7311
7297
  } from "@layoutit/polycss-core";
7312
7298
  export {
7313
7299
  BASE_TILE8 as BASE_TILE,
@@ -7353,6 +7339,7 @@ export {
7353
7339
  bakeSolidTextureSampledPolygons,
7354
7340
  bakeSolidTextureSamples,
7355
7341
  boxPolygons2 as boxPolygons,
7342
+ buildPolyMeshTransform2 as buildPolyMeshTransform,
7356
7343
  buildSceneContext2 as buildSceneContext,
7357
7344
  cameraCullNormalGroups,
7358
7345
  cameraCullNormalGroupsFromPolygons,
@@ -7399,6 +7386,8 @@ export {
7399
7386
  parseVox,
7400
7387
  planePolygons3 as planePolygons,
7401
7388
  pointInMeshElement,
7389
+ cssDistanceToWorld as polyCssDistanceToWorld,
7390
+ cssPositionToWorld as polyCssPositionToWorld,
7402
7391
  polygonCssSurfaceNormal,
7403
7392
  polygonFaces,
7404
7393
  polygonFacesCamera,
@@ -7421,5 +7410,8 @@ export {
7421
7410
  usePolyMesh,
7422
7411
  usePolySceneContext,
7423
7412
  usePolySelect,
7424
- usePolySelectionApi
7413
+ usePolySelectionApi,
7414
+ worldDirectionToCss3 as worldDirectionToPolyCss,
7415
+ worldDistanceToCss as worldDistanceToPolyCss,
7416
+ worldPositionToCss as worldPositionToPolyCss
7425
7417
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layoutit/polycss-react",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "React components for the CSS-based polygon mesh rendering engine",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@layoutit/polycss-core": "^0.2.2"
44
+ "@layoutit/polycss-core": "^0.2.4"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": "^18.0.0 || ^19.0.0",