@layoutit/polycss-react 0.2.3 → 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 +18 -24
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +55 -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`, and `
|
|
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,
|
|
@@ -110,6 +111,8 @@ __export(src_exports, {
|
|
|
110
111
|
parseVox: () => import_polycss_core27.parseVox,
|
|
111
112
|
planePolygons: () => import_polycss_core27.planePolygons,
|
|
112
113
|
pointInMeshElement: () => pointInMeshElement,
|
|
114
|
+
polyCssDistanceToWorld: () => import_polycss_core27.cssDistanceToWorld,
|
|
115
|
+
polyCssPositionToWorld: () => import_polycss_core27.cssPositionToWorld,
|
|
113
116
|
polygonCssSurfaceNormal: () => import_polycss_core27.polygonCssSurfaceNormal,
|
|
114
117
|
polygonFaces: () => import_polycss_core27.polygonFaces,
|
|
115
118
|
polygonFacesCamera: () => import_polycss_core27.polygonFacesCamera,
|
|
@@ -134,6 +137,8 @@ __export(src_exports, {
|
|
|
134
137
|
usePolySelect: () => usePolySelect,
|
|
135
138
|
usePolySelectionApi: () => usePolySelectionApi,
|
|
136
139
|
worldDirectionToPolyCss: () => import_polycss_core27.worldDirectionToCss,
|
|
140
|
+
worldDirectionalLightToPolyCss: () => import_polycss_core27.worldDirectionalLightToCss,
|
|
141
|
+
worldDistanceToPolyCss: () => import_polycss_core27.worldDistanceToCss,
|
|
137
142
|
worldPositionToPolyCss: () => import_polycss_core27.worldPositionToCss
|
|
138
143
|
});
|
|
139
144
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -229,18 +234,10 @@ function usePolyCamera(options) {
|
|
|
229
234
|
handle.update(next);
|
|
230
235
|
const el = sceneElRef.current;
|
|
231
236
|
if (el) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const wy = s.target[1] + oy;
|
|
237
|
-
const wz = s.target[2] + oz;
|
|
238
|
-
const cssX = wy * tileSize;
|
|
239
|
-
const cssY = wx * tileSize;
|
|
240
|
-
const cssZ = wz * tileSize;
|
|
241
|
-
const cssZoom = s.zoom / tileSize;
|
|
242
|
-
const distancePart = s.distance !== 0 ? `translateZ(${-s.distance}px) ` : "";
|
|
243
|
-
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
|
+
});
|
|
244
241
|
}
|
|
245
242
|
store.updateCameraFromRef(handle);
|
|
246
243
|
store.notifyAll();
|
|
@@ -250,18 +247,10 @@ function usePolyCamera(options) {
|
|
|
250
247
|
const el = sceneElRef.current;
|
|
251
248
|
if (!el) return;
|
|
252
249
|
const handle = handleRef.current;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const wy = s.target[1] + oy;
|
|
258
|
-
const wz = s.target[2] + oz;
|
|
259
|
-
const cssX = wy * tileSize;
|
|
260
|
-
const cssY = wx * tileSize;
|
|
261
|
-
const cssZ = wz * tileSize;
|
|
262
|
-
const cssZoom = s.zoom / tileSize;
|
|
263
|
-
const distancePart = s.distance !== 0 ? `translateZ(${-s.distance}px) ` : "";
|
|
264
|
-
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
|
+
});
|
|
265
254
|
}, [store]);
|
|
266
255
|
return {
|
|
267
256
|
store,
|
|
@@ -7292,6 +7281,7 @@ var import_polycss_core27 = require("@layoutit/polycss-core");
|
|
|
7292
7281
|
bakeSolidTextureSamples,
|
|
7293
7282
|
boxPolygons,
|
|
7294
7283
|
buildPolyMeshTransform,
|
|
7284
|
+
buildPolySceneTransform,
|
|
7295
7285
|
buildSceneContext,
|
|
7296
7286
|
cameraCullNormalGroups,
|
|
7297
7287
|
cameraCullNormalGroupsFromPolygons,
|
|
@@ -7338,6 +7328,8 @@ var import_polycss_core27 = require("@layoutit/polycss-core");
|
|
|
7338
7328
|
parseVox,
|
|
7339
7329
|
planePolygons,
|
|
7340
7330
|
pointInMeshElement,
|
|
7331
|
+
polyCssDistanceToWorld,
|
|
7332
|
+
polyCssPositionToWorld,
|
|
7341
7333
|
polygonCssSurfaceNormal,
|
|
7342
7334
|
polygonFaces,
|
|
7343
7335
|
polygonFacesCamera,
|
|
@@ -7362,5 +7354,7 @@ var import_polycss_core27 = require("@layoutit/polycss-core");
|
|
|
7362
7354
|
usePolySelect,
|
|
7363
7355
|
usePolySelectionApi,
|
|
7364
7356
|
worldDirectionToPolyCss,
|
|
7357
|
+
worldDirectionalLightToPolyCss,
|
|
7358
|
+
worldDistanceToPolyCss,
|
|
7365
7359
|
worldPositionToPolyCss
|
|
7366
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, polygonCssSurfaceNormal, polygonFaces, polygonFacesCamera, repairMeshSeams, ringPolygons, rotateVec3, seamFacetSplitPolygons, seamFacetSplitReport, seamOverlapDiagnostics, seamOverlapPolygons, seamOverlapReport, shadeColor, simplifyTriangleMeshPolygons, tetrahedronPolygons, torusPolygons, worldDirectionToCss as worldDirectionToPolyCss, 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, polygonCssSurfaceNormal, polygonFaces, polygonFacesCamera, repairMeshSeams, ringPolygons, rotateVec3, seamFacetSplitPolygons, seamFacetSplitReport, seamOverlapDiagnostics, seamOverlapPolygons, seamOverlapReport, shadeColor, simplifyTriangleMeshPolygons, tetrahedronPolygons, torusPolygons, worldDirectionToCss as worldDirectionToPolyCss, 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,
|
|
@@ -7289,11 +7274,15 @@ import {
|
|
|
7289
7274
|
LoopOnce,
|
|
7290
7275
|
LoopRepeat,
|
|
7291
7276
|
LoopPingPong,
|
|
7277
|
+
cssDistanceToWorld,
|
|
7278
|
+
cssPositionToWorld,
|
|
7279
|
+
worldDistanceToCss,
|
|
7292
7280
|
worldDirectionToCss as worldDirectionToCss3,
|
|
7281
|
+
worldDirectionalLightToCss as worldDirectionalLightToCss2,
|
|
7293
7282
|
worldPositionToCss
|
|
7294
7283
|
} from "@layoutit/polycss-core";
|
|
7295
7284
|
export {
|
|
7296
|
-
|
|
7285
|
+
BASE_TILE7 as BASE_TILE,
|
|
7297
7286
|
CAMERA_BACKFACE_CULL_EPS,
|
|
7298
7287
|
DEFAULT_CAMERA_STATE2 as DEFAULT_CAMERA_STATE,
|
|
7299
7288
|
DEFAULT_PROJECTION,
|
|
@@ -7337,6 +7326,7 @@ export {
|
|
|
7337
7326
|
bakeSolidTextureSamples,
|
|
7338
7327
|
boxPolygons2 as boxPolygons,
|
|
7339
7328
|
buildPolyMeshTransform2 as buildPolyMeshTransform,
|
|
7329
|
+
buildPolySceneTransform2 as buildPolySceneTransform,
|
|
7340
7330
|
buildSceneContext2 as buildSceneContext,
|
|
7341
7331
|
cameraCullNormalGroups,
|
|
7342
7332
|
cameraCullNormalGroupsFromPolygons,
|
|
@@ -7383,6 +7373,8 @@ export {
|
|
|
7383
7373
|
parseVox,
|
|
7384
7374
|
planePolygons3 as planePolygons,
|
|
7385
7375
|
pointInMeshElement,
|
|
7376
|
+
cssDistanceToWorld as polyCssDistanceToWorld,
|
|
7377
|
+
cssPositionToWorld as polyCssPositionToWorld,
|
|
7386
7378
|
polygonCssSurfaceNormal,
|
|
7387
7379
|
polygonFaces,
|
|
7388
7380
|
polygonFacesCamera,
|
|
@@ -7407,5 +7399,7 @@ export {
|
|
|
7407
7399
|
usePolySelect,
|
|
7408
7400
|
usePolySelectionApi,
|
|
7409
7401
|
worldDirectionToCss3 as worldDirectionToPolyCss,
|
|
7402
|
+
worldDirectionalLightToCss2 as worldDirectionalLightToPolyCss,
|
|
7403
|
+
worldDistanceToCss as worldDistanceToPolyCss,
|
|
7410
7404
|
worldPositionToCss as worldPositionToPolyCss
|
|
7411
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",
|