@layoutit/polycss-react 0.2.4 → 0.2.5
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 +1 -1
- package/dist/index.cjs +12 -24
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -61
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -84,7 +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
|
+
- Tooling can reuse `buildPolyMeshTransform`, `buildPolySceneTransform`, `worldPositionToPolyCss`, `worldDirectionToPolyCss`, `worldDirectionalLightToPolyCss`, `worldDistanceToPolyCss`, `polyCssDistanceToWorld`, and `polyCssPositionToWorld` for renderer-compatible transforms and world/CSS conversions.
|
|
88
88
|
|
|
89
89
|
### Controls
|
|
90
90
|
|
package/dist/index.cjs
CHANGED
|
@@ -64,6 +64,7 @@ __export(src_exports, {
|
|
|
64
64
|
bakeSolidTextureSamples: () => import_polycss_core27.bakeSolidTextureSamples,
|
|
65
65
|
boxPolygons: () => import_polycss_core27.boxPolygons,
|
|
66
66
|
buildPolyMeshTransform: () => import_polycss_core27.buildPolyMeshTransform,
|
|
67
|
+
buildPolySceneTransform: () => import_polycss_core27.buildPolySceneTransform,
|
|
67
68
|
buildSceneContext: () => import_polycss_core27.buildSceneContext,
|
|
68
69
|
cameraCullNormalGroups: () => import_polycss_core27.cameraCullNormalGroups,
|
|
69
70
|
cameraCullNormalGroupsFromPolygons: () => import_polycss_core27.cameraCullNormalGroupsFromPolygons,
|
|
@@ -136,6 +137,7 @@ __export(src_exports, {
|
|
|
136
137
|
usePolySelect: () => usePolySelect,
|
|
137
138
|
usePolySelectionApi: () => usePolySelectionApi,
|
|
138
139
|
worldDirectionToPolyCss: () => import_polycss_core27.worldDirectionToCss,
|
|
140
|
+
worldDirectionalLightToPolyCss: () => import_polycss_core27.worldDirectionalLightToCss,
|
|
139
141
|
worldDistanceToPolyCss: () => import_polycss_core27.worldDistanceToCss,
|
|
140
142
|
worldPositionToPolyCss: () => import_polycss_core27.worldPositionToCss
|
|
141
143
|
});
|
|
@@ -232,18 +234,10 @@ function usePolyCamera(options) {
|
|
|
232
234
|
handle.update(next);
|
|
233
235
|
const el = sceneElRef.current;
|
|
234
236
|
if (el) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const wy = s.target[1] + oy;
|
|
240
|
-
const wz = s.target[2] + oz;
|
|
241
|
-
const cssX = wy * tileSize;
|
|
242
|
-
const cssY = wx * tileSize;
|
|
243
|
-
const cssZ = wz * tileSize;
|
|
244
|
-
const cssZoom = s.zoom / tileSize;
|
|
245
|
-
const distancePart = s.distance !== 0 ? `translateZ(${-s.distance}px) ` : "";
|
|
246
|
-
el.style.transform = `${distancePart}scale(${cssZoom}) rotateX(${s.rotX}deg) rotate(${s.rotY}deg) translate3d(${-cssX}px, ${-cssY}px, ${-cssZ}px)`;
|
|
237
|
+
el.style.transform = (0, import_polycss_core.buildPolySceneTransform)({
|
|
238
|
+
...handle.state,
|
|
239
|
+
autoCenterOffset: store.getState().autoCenterOffset
|
|
240
|
+
});
|
|
247
241
|
}
|
|
248
242
|
store.updateCameraFromRef(handle);
|
|
249
243
|
store.notifyAll();
|
|
@@ -253,18 +247,10 @@ function usePolyCamera(options) {
|
|
|
253
247
|
const el = sceneElRef.current;
|
|
254
248
|
if (!el) return;
|
|
255
249
|
const handle = handleRef.current;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const wy = s.target[1] + oy;
|
|
261
|
-
const wz = s.target[2] + oz;
|
|
262
|
-
const cssX = wy * tileSize;
|
|
263
|
-
const cssY = wx * tileSize;
|
|
264
|
-
const cssZ = wz * tileSize;
|
|
265
|
-
const cssZoom = s.zoom / tileSize;
|
|
266
|
-
const distancePart = s.distance !== 0 ? `translateZ(${-s.distance}px) ` : "";
|
|
267
|
-
el.style.transform = `${distancePart}scale(${cssZoom}) rotateX(${s.rotX}deg) rotate(${s.rotY}deg) translate3d(${-cssX}px, ${-cssY}px, ${-cssZ}px)`;
|
|
250
|
+
el.style.transform = (0, import_polycss_core.buildPolySceneTransform)({
|
|
251
|
+
...handle.state,
|
|
252
|
+
autoCenterOffset: store.getState().autoCenterOffset
|
|
253
|
+
});
|
|
268
254
|
}, [store]);
|
|
269
255
|
return {
|
|
270
256
|
store,
|
|
@@ -7295,6 +7281,7 @@ var import_polycss_core27 = require("@layoutit/polycss-core");
|
|
|
7295
7281
|
bakeSolidTextureSamples,
|
|
7296
7282
|
boxPolygons,
|
|
7297
7283
|
buildPolyMeshTransform,
|
|
7284
|
+
buildPolySceneTransform,
|
|
7298
7285
|
buildSceneContext,
|
|
7299
7286
|
cameraCullNormalGroups,
|
|
7300
7287
|
cameraCullNormalGroupsFromPolygons,
|
|
@@ -7367,6 +7354,7 @@ var import_polycss_core27 = require("@layoutit/polycss-core");
|
|
|
7367
7354
|
usePolySelect,
|
|
7368
7355
|
usePolySelectionApi,
|
|
7369
7356
|
worldDirectionToPolyCss,
|
|
7357
|
+
worldDirectionalLightToPolyCss,
|
|
7370
7358
|
worldDistanceToPolyCss,
|
|
7371
7359
|
worldPositionToPolyCss
|
|
7372
7360
|
});
|
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, 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';
|
|
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, PolySceneTransformInput, 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, buildPolySceneTransform, 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, worldDirectionalLightToCss as worldDirectionalLightToPolyCss, 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, 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';
|
|
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, PolySceneTransformInput, 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, buildPolySceneTransform, 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, worldDirectionalLightToCss as worldDirectionalLightToPolyCss, 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
|
@@ -14,7 +14,7 @@ function useCameraContext() {
|
|
|
14
14
|
|
|
15
15
|
// src/camera/useCamera.ts
|
|
16
16
|
import { useRef as useRef2, useCallback as useCallback2, useEffect, useMemo } from "react";
|
|
17
|
-
import {
|
|
17
|
+
import { buildPolySceneTransform, createIsometricCamera } from "@layoutit/polycss-core";
|
|
18
18
|
|
|
19
19
|
// src/store/sceneStore.ts
|
|
20
20
|
import { useSyncExternalStore, useRef, useCallback } from "react";
|
|
@@ -89,18 +89,10 @@ function usePolyCamera(options) {
|
|
|
89
89
|
handle.update(next);
|
|
90
90
|
const el = sceneElRef.current;
|
|
91
91
|
if (el) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const wy = s.target[1] + oy;
|
|
97
|
-
const wz = s.target[2] + oz;
|
|
98
|
-
const cssX = wy * tileSize;
|
|
99
|
-
const cssY = wx * tileSize;
|
|
100
|
-
const cssZ = wz * tileSize;
|
|
101
|
-
const cssZoom = s.zoom / tileSize;
|
|
102
|
-
const distancePart = s.distance !== 0 ? `translateZ(${-s.distance}px) ` : "";
|
|
103
|
-
el.style.transform = `${distancePart}scale(${cssZoom}) rotateX(${s.rotX}deg) rotate(${s.rotY}deg) translate3d(${-cssX}px, ${-cssY}px, ${-cssZ}px)`;
|
|
92
|
+
el.style.transform = buildPolySceneTransform({
|
|
93
|
+
...handle.state,
|
|
94
|
+
autoCenterOffset: store.getState().autoCenterOffset
|
|
95
|
+
});
|
|
104
96
|
}
|
|
105
97
|
store.updateCameraFromRef(handle);
|
|
106
98
|
store.notifyAll();
|
|
@@ -110,18 +102,10 @@ function usePolyCamera(options) {
|
|
|
110
102
|
const el = sceneElRef.current;
|
|
111
103
|
if (!el) return;
|
|
112
104
|
const handle = handleRef.current;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const wy = s.target[1] + oy;
|
|
118
|
-
const wz = s.target[2] + oz;
|
|
119
|
-
const cssX = wy * tileSize;
|
|
120
|
-
const cssY = wx * tileSize;
|
|
121
|
-
const cssZ = wz * tileSize;
|
|
122
|
-
const cssZoom = s.zoom / tileSize;
|
|
123
|
-
const distancePart = s.distance !== 0 ? `translateZ(${-s.distance}px) ` : "";
|
|
124
|
-
el.style.transform = `${distancePart}scale(${cssZoom}) rotateX(${s.rotX}deg) rotate(${s.rotY}deg) translate3d(${-cssX}px, ${-cssY}px, ${-cssZ}px)`;
|
|
105
|
+
el.style.transform = buildPolySceneTransform({
|
|
106
|
+
...handle.state,
|
|
107
|
+
autoCenterOffset: store.getState().autoCenterOffset
|
|
108
|
+
});
|
|
125
109
|
}, [store]);
|
|
126
110
|
return {
|
|
127
111
|
store,
|
|
@@ -221,7 +205,7 @@ var PolyOrthographicCamera = memo2(PolyOrthographicCameraInner);
|
|
|
221
205
|
|
|
222
206
|
// src/scene/PolyScene.tsx
|
|
223
207
|
import { memo as memo8, useCallback as useCallback5, useEffect as useEffect3, useLayoutEffect, useMemo as useMemo6, useRef as useRef4, useState as useState2 } from "react";
|
|
224
|
-
import { BASE_TILE
|
|
208
|
+
import { BASE_TILE, DEFAULT_SEAM_BLEED, parseHexColor, worldDirectionToCss } from "@layoutit/polycss-core";
|
|
225
209
|
|
|
226
210
|
// src/scene/useSceneContext.ts
|
|
227
211
|
import { useMemo as useMemo4 } from "react";
|
|
@@ -2656,7 +2640,7 @@ function PolySceneInner({
|
|
|
2656
2640
|
}
|
|
2657
2641
|
if (!Number.isFinite(minWorldZ)) return null;
|
|
2658
2642
|
const lift = shadow?.lift ?? 0.05;
|
|
2659
|
-
return (minWorldZ + lift) *
|
|
2643
|
+
return (minWorldZ + lift) * BASE_TILE;
|
|
2660
2644
|
}, [shadow]);
|
|
2661
2645
|
const registerShadowCaster = useCallback5((meshId, data) => {
|
|
2662
2646
|
if (data === null) {
|
|
@@ -2781,7 +2765,7 @@ import {
|
|
|
2781
2765
|
useState as useState4
|
|
2782
2766
|
} from "react";
|
|
2783
2767
|
import {
|
|
2784
|
-
BASE_TILE as
|
|
2768
|
+
BASE_TILE as BASE_TILE3,
|
|
2785
2769
|
buildPolyMeshTransform,
|
|
2786
2770
|
buildSharedEdgeMap,
|
|
2787
2771
|
computeReceiverShadowFaces,
|
|
@@ -2894,7 +2878,7 @@ import { createPortal } from "react-dom";
|
|
|
2894
2878
|
|
|
2895
2879
|
// src/scene/voxelRenderer.ts
|
|
2896
2880
|
import {
|
|
2897
|
-
BASE_TILE as
|
|
2881
|
+
BASE_TILE as BASE_TILE2,
|
|
2898
2882
|
computeProjectiveQuadMatrix,
|
|
2899
2883
|
normalFacesCamera,
|
|
2900
2884
|
parsePureColor as parsePureColor2,
|
|
@@ -3003,11 +2987,11 @@ function polygonBrush(polygon) {
|
|
|
3003
2987
|
return {
|
|
3004
2988
|
axis: "z",
|
|
3005
2989
|
face,
|
|
3006
|
-
left: minY *
|
|
3007
|
-
top: minX *
|
|
3008
|
-
width: Math.max(0, (maxY - minY) *
|
|
3009
|
-
height: Math.max(0, (maxX - minX) *
|
|
3010
|
-
z: minZ *
|
|
2990
|
+
left: minY * BASE_TILE2,
|
|
2991
|
+
top: minX * BASE_TILE2,
|
|
2992
|
+
width: Math.max(0, (maxY - minY) * BASE_TILE2),
|
|
2993
|
+
height: Math.max(0, (maxX - minX) * BASE_TILE2),
|
|
2994
|
+
z: minZ * BASE_TILE2,
|
|
3011
2995
|
baseColor,
|
|
3012
2996
|
bleed: zeroVoxelSeamBleed()
|
|
3013
2997
|
};
|
|
@@ -3016,11 +3000,11 @@ function polygonBrush(polygon) {
|
|
|
3016
3000
|
return {
|
|
3017
3001
|
axis: "x",
|
|
3018
3002
|
face,
|
|
3019
|
-
left: minY *
|
|
3020
|
-
top: minZ *
|
|
3021
|
-
width: Math.max(0, (maxY - minY) *
|
|
3022
|
-
height: Math.max(0, (maxZ - minZ) *
|
|
3023
|
-
z: -minX *
|
|
3003
|
+
left: minY * BASE_TILE2,
|
|
3004
|
+
top: minZ * BASE_TILE2,
|
|
3005
|
+
width: Math.max(0, (maxY - minY) * BASE_TILE2),
|
|
3006
|
+
height: Math.max(0, (maxZ - minZ) * BASE_TILE2),
|
|
3007
|
+
z: -minX * BASE_TILE2,
|
|
3024
3008
|
baseColor,
|
|
3025
3009
|
bleed: zeroVoxelSeamBleed()
|
|
3026
3010
|
};
|
|
@@ -3029,11 +3013,11 @@ function polygonBrush(polygon) {
|
|
|
3029
3013
|
return {
|
|
3030
3014
|
axis: "y",
|
|
3031
3015
|
face,
|
|
3032
|
-
left: minZ *
|
|
3033
|
-
top: minX *
|
|
3034
|
-
width: Math.max(0, (maxZ - minZ) *
|
|
3035
|
-
height: Math.max(0, (maxX - minX) *
|
|
3036
|
-
z: -minY *
|
|
3016
|
+
left: minZ * BASE_TILE2,
|
|
3017
|
+
top: minX * BASE_TILE2,
|
|
3018
|
+
width: Math.max(0, (maxZ - minZ) * BASE_TILE2),
|
|
3019
|
+
height: Math.max(0, (maxX - minX) * BASE_TILE2),
|
|
3020
|
+
z: -minY * BASE_TILE2,
|
|
3037
3021
|
baseColor,
|
|
3038
3022
|
bleed: zeroVoxelSeamBleed()
|
|
3039
3023
|
};
|
|
@@ -3053,7 +3037,7 @@ function worldLineKey(segment) {
|
|
|
3053
3037
|
return key;
|
|
3054
3038
|
}
|
|
3055
3039
|
function cssPointForVertex(v) {
|
|
3056
|
-
return [v[1] *
|
|
3040
|
+
return [v[1] * BASE_TILE2, v[0] * BASE_TILE2, v[2] * BASE_TILE2];
|
|
3057
3041
|
}
|
|
3058
3042
|
function localPointForItem(item, p) {
|
|
3059
3043
|
if (item.axis === "x") return [p[0], p[2]];
|
|
@@ -4020,7 +4004,7 @@ var PolyMesh = forwardRef(function PolyMesh2({
|
|
|
4020
4004
|
const userGroundLightDir = sceneDirectionalLight?.direction ?? [0.4, -0.7, 0.59];
|
|
4021
4005
|
const lightDir = worldDirectionToCss2(userGroundLightDir);
|
|
4022
4006
|
const meshPosZ = position?.[2] ?? 0;
|
|
4023
|
-
const localGroundCssZ = bakedShadowGroundCssZ - meshPosZ *
|
|
4007
|
+
const localGroundCssZ = bakedShadowGroundCssZ - meshPosZ * BASE_TILE3;
|
|
4024
4008
|
const shadowDedupDrop = findOverlappingPolygonDuplicates(polygons, {
|
|
4025
4009
|
normalTolerance: 0.1,
|
|
4026
4010
|
distanceTolerance: 0.5,
|
|
@@ -4038,9 +4022,9 @@ var PolyMesh = forwardRef(function PolyMesh2({
|
|
|
4038
4022
|
const projected = [];
|
|
4039
4023
|
for (const v of polygon.vertices) {
|
|
4040
4024
|
const cssVertex = [
|
|
4041
|
-
v[1] *
|
|
4042
|
-
v[0] *
|
|
4043
|
-
v[2] *
|
|
4025
|
+
v[1] * BASE_TILE3,
|
|
4026
|
+
v[0] * BASE_TILE3,
|
|
4027
|
+
v[2] * BASE_TILE3
|
|
4044
4028
|
];
|
|
4045
4029
|
if (cssVertex[0] < fpMinX) fpMinX = cssVertex[0];
|
|
4046
4030
|
if (cssVertex[1] < fpMinY) fpMinY = cssVertex[1];
|
|
@@ -4412,7 +4396,7 @@ function RenderPropPolygon({
|
|
|
4412
4396
|
}
|
|
4413
4397
|
|
|
4414
4398
|
// src/scene/PolyIframe.tsx
|
|
4415
|
-
import { BASE_TILE as
|
|
4399
|
+
import { BASE_TILE as BASE_TILE4 } from "@layoutit/polycss-core";
|
|
4416
4400
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
4417
4401
|
function buildIframeTransform(position, rotation, scale, cssWidth, cssHeight) {
|
|
4418
4402
|
const sx = typeof scale === "number" ? scale : scale?.[0] ?? 1;
|
|
@@ -4420,9 +4404,9 @@ function buildIframeTransform(position, rotation, scale, cssWidth, cssHeight) {
|
|
|
4420
4404
|
const sz = typeof scale === "number" ? scale : scale?.[2] ?? 1;
|
|
4421
4405
|
const hasScale = sx !== 1 || sy !== 1 || sz !== 1;
|
|
4422
4406
|
const hasRotation = !!rotation && (!!rotation[0] || !!rotation[1] || !!rotation[2]);
|
|
4423
|
-
const cssX = (position?.[1] ?? 0) *
|
|
4424
|
-
const cssY = (position?.[0] ?? 0) *
|
|
4425
|
-
const cssZ = (position?.[2] ?? 0) *
|
|
4407
|
+
const cssX = (position?.[1] ?? 0) * BASE_TILE4;
|
|
4408
|
+
const cssY = (position?.[0] ?? 0) * BASE_TILE4;
|
|
4409
|
+
const cssZ = (position?.[2] ?? 0) * BASE_TILE4;
|
|
4426
4410
|
const parts = [];
|
|
4427
4411
|
parts.push(`translate3d(${cssX}px, ${cssY}px, ${cssZ}px)`);
|
|
4428
4412
|
if (hasRotation) {
|
|
@@ -4449,8 +4433,8 @@ function PolyIframe({
|
|
|
4449
4433
|
className,
|
|
4450
4434
|
style
|
|
4451
4435
|
}) {
|
|
4452
|
-
const cssW = width *
|
|
4453
|
-
const cssH = height *
|
|
4436
|
+
const cssW = width * BASE_TILE4;
|
|
4437
|
+
const cssH = height * BASE_TILE4;
|
|
4454
4438
|
const transform = buildIframeTransform(position, rotation, scale, cssW, cssH);
|
|
4455
4439
|
const wrapperStyle = {
|
|
4456
4440
|
position: "absolute",
|
|
@@ -4972,7 +4956,7 @@ function PolyTorus({
|
|
|
4972
4956
|
|
|
4973
4957
|
// src/controls/PolyFirstPersonControls.tsx
|
|
4974
4958
|
import { useEffect as useEffect6, useRef as useRef7, useImperativeHandle as useImperativeHandle2, forwardRef as forwardRef2 } from "react";
|
|
4975
|
-
import { BASE_TILE as
|
|
4959
|
+
import { BASE_TILE as BASE_TILE5 } from "@layoutit/polycss-core";
|
|
4976
4960
|
var DEFAULTS = {
|
|
4977
4961
|
enabled: true,
|
|
4978
4962
|
lookEnabled: true,
|
|
@@ -5148,7 +5132,7 @@ var PolyFirstPersonControls = forwardRef2(function PolyFirstPersonControls2(prop
|
|
|
5148
5132
|
const host = cameraElRef.current;
|
|
5149
5133
|
const perspStr = host ? getComputedStyle(host).perspective : "";
|
|
5150
5134
|
const n = parseFloat(perspStr);
|
|
5151
|
-
return (Number.isFinite(n) && n > 0 ? n : 32e3) /
|
|
5135
|
+
return (Number.isFinite(n) && n > 0 ? n : 32e3) / BASE_TILE5;
|
|
5152
5136
|
}
|
|
5153
5137
|
function deriveTarget() {
|
|
5154
5138
|
const s = cameraRef.current.state;
|
|
@@ -5389,7 +5373,7 @@ var PolyFirstPersonControls = forwardRef2(function PolyFirstPersonControls2(prop
|
|
|
5389
5373
|
import { useEffect as useEffect7, useRef as useRef8 } from "react";
|
|
5390
5374
|
|
|
5391
5375
|
// src/controls/sharedControls.ts
|
|
5392
|
-
import { BASE_TILE as
|
|
5376
|
+
import { BASE_TILE as BASE_TILE6 } from "@layoutit/polycss-core";
|
|
5393
5377
|
var POINTER_DRAG_SPEED = 4;
|
|
5394
5378
|
function invertFactor(invert) {
|
|
5395
5379
|
if (invert === true) return -1;
|
|
@@ -5410,7 +5394,7 @@ function applyPan(dx, dy, s, handle, _invert) {
|
|
|
5410
5394
|
const cosRotX = cosRotXRaw >= 0 ? Math.max(0.1, cosRotXRaw) : Math.min(-0.1, cosRotXRaw);
|
|
5411
5395
|
const cZ = Math.cos(s.rotY * Math.PI / 180);
|
|
5412
5396
|
const sZ = Math.sin(s.rotY * Math.PI / 180);
|
|
5413
|
-
const k = z *
|
|
5397
|
+
const k = z * BASE_TILE6;
|
|
5414
5398
|
const targetD0 = (dx * sZ - dy * cZ / cosRotX) / k;
|
|
5415
5399
|
const targetD1 = -(dx * cZ + dy * sZ / cosRotX) / k;
|
|
5416
5400
|
const t = s.target;
|
|
@@ -7277,8 +7261,9 @@ import {
|
|
|
7277
7261
|
planePolygons as planePolygons3,
|
|
7278
7262
|
buildSceneContext as buildSceneContext2,
|
|
7279
7263
|
buildPolyMeshTransform as buildPolyMeshTransform2,
|
|
7264
|
+
buildPolySceneTransform as buildPolySceneTransform2,
|
|
7280
7265
|
computeSceneBbox as computeSceneBbox2,
|
|
7281
|
-
BASE_TILE as
|
|
7266
|
+
BASE_TILE as BASE_TILE7,
|
|
7282
7267
|
DEFAULT_CAMERA_STATE as DEFAULT_CAMERA_STATE2,
|
|
7283
7268
|
DEFAULT_PROJECTION,
|
|
7284
7269
|
normalizeInvertMultiplier,
|
|
@@ -7293,10 +7278,11 @@ import {
|
|
|
7293
7278
|
cssPositionToWorld,
|
|
7294
7279
|
worldDistanceToCss,
|
|
7295
7280
|
worldDirectionToCss as worldDirectionToCss3,
|
|
7281
|
+
worldDirectionalLightToCss as worldDirectionalLightToCss2,
|
|
7296
7282
|
worldPositionToCss
|
|
7297
7283
|
} from "@layoutit/polycss-core";
|
|
7298
7284
|
export {
|
|
7299
|
-
|
|
7285
|
+
BASE_TILE7 as BASE_TILE,
|
|
7300
7286
|
CAMERA_BACKFACE_CULL_EPS,
|
|
7301
7287
|
DEFAULT_CAMERA_STATE2 as DEFAULT_CAMERA_STATE,
|
|
7302
7288
|
DEFAULT_PROJECTION,
|
|
@@ -7340,6 +7326,7 @@ export {
|
|
|
7340
7326
|
bakeSolidTextureSamples,
|
|
7341
7327
|
boxPolygons2 as boxPolygons,
|
|
7342
7328
|
buildPolyMeshTransform2 as buildPolyMeshTransform,
|
|
7329
|
+
buildPolySceneTransform2 as buildPolySceneTransform,
|
|
7343
7330
|
buildSceneContext2 as buildSceneContext,
|
|
7344
7331
|
cameraCullNormalGroups,
|
|
7345
7332
|
cameraCullNormalGroupsFromPolygons,
|
|
@@ -7412,6 +7399,7 @@ export {
|
|
|
7412
7399
|
usePolySelect,
|
|
7413
7400
|
usePolySelectionApi,
|
|
7414
7401
|
worldDirectionToCss3 as worldDirectionToPolyCss,
|
|
7402
|
+
worldDirectionalLightToCss2 as worldDirectionalLightToPolyCss,
|
|
7415
7403
|
worldDistanceToCss as worldDistanceToPolyCss,
|
|
7416
7404
|
worldPositionToCss as worldPositionToPolyCss
|
|
7417
7405
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layoutit/polycss-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
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.
|
|
44
|
+
"@layoutit/polycss-core": "^0.2.5"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|