@layoutit/polycss-react 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/index.cjs +2312 -475
- package/dist/index.d.cts +159 -18
- package/dist/index.d.ts +159 -18
- package/dist/index.js +2284 -440
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import react__default, { ReactNode, CSSProperties, MouseEventHandler, PointerEventHandler, FocusEventHandler, KeyboardEventHandler, RefObject, MouseEvent as MouseEvent$1 } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { Vec3, CameraState, CameraHandle, Vec2, PolyMaterial, PolyDirectionalLight, PolyTextureLightingMode, Polygon, PolyAmbientLight, LoadMeshOptions, PolyAnimationTarget, PolyAnimationMixer, PolyAnimationClip, PolyAnimationAction, ParseAnimationController } from '@layoutit/polycss-core';
|
|
5
|
-
export { ArrowPolygonsOptions, AutoRotateConfig, AutoRotateOption, AxesHelperOptions, BASE_TILE, CameraHandle, CameraState, CameraStyleInput, CoverPlanarPolygonsOptions, CullInteriorOptions, DEFAULT_CAMERA_STATE, DEFAULT_PROJECTION, GltfParseOptions, LoadMeshOptions, LoopMode, LoopOnce, LoopPingPong, LoopRepeat, MtlParseResult, NormalizeResult, ObjParseOptions, OctahedronPolygonsOptions, ParseAnimationClip, ParseAnimationController, ParseResult, ParsedColor, PolyAmbientLight, PolyAnimationAction, PolyAnimationClip, PolyAnimationMixer, PolyAnimationTarget, PolyDirectionalLight, PolyMaterial, PolyTextureLightingMode, Polygon, PolygonFace, RingPolygonsOptions, SceneBbox, SceneContext, SceneContextBuildArgs, SceneContextBuildResult, SolidTextureSampleOptions, TexturePaintMetrics, TexturePaintMetricsOptions, TextureTriangle, Vec2, Vec3, VoxParseOptions, arrowPolygons, axesHelperPolygons, bakeSolidTextureSampledPolygons, bakeSolidTextureSamples, buildSceneContext, clampChannel, computeSceneBbox, computeShapeLighting, computeTexturePaintMetrics, coverPlanarPolygons, createIsometricCamera, createPolyAnimationMixer, cullInteriorPolygons, formatColor, inverseRotateVec3, loadMesh, mergePolygons, normalizeInvertMultiplier, normalizePolygons, octahedronPolygons, parseColor, parseGltf, parseHexColor, parseMtl, parseObj, parsePureColor, parseRgbColor, parseVox, polygonFaces, ringPolygons, rotateVec3, shadeColor } from '@layoutit/polycss-core';
|
|
5
|
+
export { ApproximateMergeOptions, ArrowPolygonsOptions, AutoRotateConfig, AutoRotateOption, AxesHelperOptions, BASE_TILE, BoxFace, BoxFaceOptions, BoxPolygonsOptions, CAMERA_BACKFACE_CULL_EPS, CameraCullNormalGroup, CameraCullRotation, CameraHandle, CameraState, CameraStyleInput, CoverPlanarPolygonsOptions, CullInteriorOptions, DEFAULT_CAMERA_STATE, DEFAULT_PROJECTION, GltfParseOptions, LoadMeshOptions, LoopMode, LoopOnce, LoopPingPong, LoopRepeat, MeshResolution, MtlParseResult, NormalizeResult, ObjParseOptions, OctahedronPolygonsOptions, OptimizeMeshPolygonsOptions, ParseAnimationClip, ParseAnimationController, ParseResult, ParsedColor, PolyAmbientLight, PolyAnimationAction, PolyAnimationClip, PolyAnimationMixer, PolyAnimationTarget, PolyDirectionalLight, PolyMaterial, PolyTextureLightingMode, Polygon, PolygonFace, RingPolygonsOptions, SceneBbox, SceneContext, SceneContextBuildArgs, SceneContextBuildResult, SolidTextureSampleOptions, TexturePaintMetrics, TexturePaintMetricsOptions, TextureTriangle, 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, coverPlanarPolygons, createIsometricCamera, createPolyAnimationMixer, cullInteriorPolygons, formatColor, inverseRotateVec3, isAxisAlignedSurfaceNormal, isVoxelCameraCullableNormalGroups, loadMesh, mergePolygons, normalFacesCamera, normalizeInvertMultiplier, normalizePolygons, octahedronPolygons, optimizeMeshPolygons, parseColor, parseGltf, parseHexColor, parseMtl, parseObj, parsePureColor, parseRgbColor, parseVox, polygonCssSurfaceNormal, polygonFaces, polygonFacesCamera, ringPolygons, rotateVec3, shadeColor } from '@layoutit/polycss-core';
|
|
6
6
|
|
|
7
7
|
interface PolyPerspectiveCameraProps {
|
|
8
8
|
zoom?: number;
|
|
@@ -36,6 +36,13 @@ declare const PolyOrthographicCamera: react.MemoExoticComponent<typeof PolyOrtho
|
|
|
36
36
|
|
|
37
37
|
interface SceneStoreState {
|
|
38
38
|
cameraState: CameraState;
|
|
39
|
+
/**
|
|
40
|
+
* Bbox-center of all auto-centerable meshes in world coords. Kept separate
|
|
41
|
+
* from `target` so user pan (written to `target` by controls) survives mesh
|
|
42
|
+
* add/remove without fighting the auto-managed centering offset.
|
|
43
|
+
* [0, 0, 0] when autoCenter is off or there are no centerable meshes.
|
|
44
|
+
*/
|
|
45
|
+
autoCenterOffset: Vec3;
|
|
39
46
|
}
|
|
40
47
|
interface SceneStore {
|
|
41
48
|
getState(): SceneStoreState;
|
|
@@ -45,6 +52,8 @@ interface SceneStore {
|
|
|
45
52
|
updateCameraFromRef(handle: CameraHandle): boolean;
|
|
46
53
|
/** Force notify all subscribers (e.g. after prop-driven camera change). */
|
|
47
54
|
notifyAll(): void;
|
|
55
|
+
/** Update the autoCenterOffset (world coords bbox center). */
|
|
56
|
+
setAutoCenterOffset(offset: Vec3): void;
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
interface UseCameraOptions {
|
|
@@ -95,7 +104,21 @@ interface PolyCameraContextValue {
|
|
|
95
104
|
declare const PolyCameraContext: react.Context<PolyCameraContextValue | null>;
|
|
96
105
|
declare function useCameraContext(): PolyCameraContextValue;
|
|
97
106
|
|
|
98
|
-
|
|
107
|
+
interface ShadowOptions {
|
|
108
|
+
color?: string;
|
|
109
|
+
opacity?: number;
|
|
110
|
+
lift?: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** A render strategy tag that can be selectively disabled. */
|
|
114
|
+
type PolyRenderStrategy = "b" | "i" | "u";
|
|
115
|
+
interface PolyRenderStrategiesOption {
|
|
116
|
+
/** Strategies to skip; polygons that would normally use them fall through
|
|
117
|
+
* the chain (b → i → s, u → i → s, i → s). `<s>` is the universal
|
|
118
|
+
* fallback and cannot be disabled — textured polys have no other path. */
|
|
119
|
+
disable?: readonly PolyRenderStrategy[];
|
|
120
|
+
}
|
|
121
|
+
type TextureQuality = number | "auto";
|
|
99
122
|
|
|
100
123
|
/**
|
|
101
124
|
* Three.js-style transform props accepted by every polycss component.
|
|
@@ -159,14 +182,15 @@ interface PolyProps extends TransformProps, DOMPassthroughProps {
|
|
|
159
182
|
layerElevation?: number;
|
|
160
183
|
directionalLight?: PolyDirectionalLight;
|
|
161
184
|
textureLighting?: PolyTextureLightingMode;
|
|
162
|
-
|
|
185
|
+
textureQuality?: TextureQuality;
|
|
163
186
|
debugShowBackfaces?: boolean;
|
|
164
187
|
[key: string]: unknown;
|
|
165
188
|
};
|
|
166
189
|
/** Textured polygon lighting mode. Defaults to scene context, then "baked". */
|
|
167
190
|
textureLighting?: PolyTextureLightingMode;
|
|
168
|
-
/**
|
|
169
|
-
|
|
191
|
+
/** Atlas bitmap budget and CSS sprite size. `"auto"` (default) uses a
|
|
192
|
+
* device-appropriate memory budget and desktop/mobile sprite sizing. */
|
|
193
|
+
textureQuality?: TextureQuality;
|
|
170
194
|
/** Pre-computed shaded base color from the parent (optional override). */
|
|
171
195
|
baseColor?: string;
|
|
172
196
|
}
|
|
@@ -196,8 +220,18 @@ interface PolySceneProps extends TransformProps {
|
|
|
196
220
|
ambientLight?: PolyAmbientLight;
|
|
197
221
|
/** Textured polygon lighting mode. Defaults to "baked". */
|
|
198
222
|
textureLighting?: PolyTextureLightingMode;
|
|
199
|
-
/**
|
|
200
|
-
|
|
223
|
+
/** Atlas bitmap budget and CSS sprite size. `"auto"` (default) uses a
|
|
224
|
+
* device-appropriate memory budget (~4 MB mobile / ~16 MB desktop) and
|
|
225
|
+
* desktop/mobile sprite sizing. Numeric values 0.1..1 force an explicit
|
|
226
|
+
* raster scale and the 64px sprite. */
|
|
227
|
+
textureQuality?: TextureQuality;
|
|
228
|
+
/**
|
|
229
|
+
* Render strategy overrides. Use `{ disable: ["u"] }` to force solid
|
|
230
|
+
* triangles through the atlas path (`<s>`), or `{ disable: ["b", "i", "u"] }`
|
|
231
|
+
* to force every polygon through the atlas. Mirrors the same option on
|
|
232
|
+
* `renderPolygonsWithTextureAtlas` in `@layoutit/polycss`.
|
|
233
|
+
*/
|
|
234
|
+
strategies?: PolyRenderStrategiesOption;
|
|
201
235
|
/**
|
|
202
236
|
* When `true`, rotation pivots around the mesh's bbox center instead of
|
|
203
237
|
* world (0,0,0). Polygon data is not mutated — the scene element's
|
|
@@ -208,13 +242,19 @@ interface PolySceneProps extends TransformProps {
|
|
|
208
242
|
* origin is at a corner / feet / arbitrary point.
|
|
209
243
|
*/
|
|
210
244
|
autoCenter?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Shadow appearance for meshes with `castShadow={true}`. Only applies in
|
|
247
|
+
* dynamic lighting mode — baked mode does not emit shadow leaves.
|
|
248
|
+
* Defaults: `{ color: "#000000", opacity: 0.25, lift: 0.05 }`.
|
|
249
|
+
*/
|
|
250
|
+
shadow?: ShadowOptions;
|
|
211
251
|
className?: string;
|
|
212
252
|
style?: CSSProperties;
|
|
213
253
|
children?: ReactNode;
|
|
214
254
|
debugShowLabels?: boolean;
|
|
215
255
|
debugShowBackfaces?: boolean;
|
|
216
256
|
}
|
|
217
|
-
declare function PolySceneInner({ polygons: polygonsProp, centerPolygons: centerPolygonsProp, perspective: _perspective, rotX: _rotX, rotY: _rotY, zoom: _zoom, directionalLight, ambientLight, textureLighting,
|
|
257
|
+
declare function PolySceneInner({ polygons: polygonsProp, centerPolygons: centerPolygonsProp, perspective: _perspective, rotX: _rotX, rotY: _rotY, zoom: _zoom, directionalLight, ambientLight, textureLighting, textureQuality, strategies, autoCenter, shadow, className, style, children, position: _position, scale: _scale, rotation: _rotation, debugShowLabels: _debugShowLabels, debugShowBackfaces, }: PolySceneProps): react_jsx_runtime.JSX.Element;
|
|
218
258
|
declare const PolyScene: react.MemoExoticComponent<typeof PolySceneInner>;
|
|
219
259
|
|
|
220
260
|
type UseMeshOptions = LoadMeshOptions;
|
|
@@ -288,6 +328,15 @@ interface PolyMeshHandle {
|
|
|
288
328
|
* safe to call.
|
|
289
329
|
*/
|
|
290
330
|
rebakeAtlas(): void;
|
|
331
|
+
/**
|
|
332
|
+
* Mutate a single polygon in place and re-render the mesh. `target` is
|
|
333
|
+
* either a polygon reference (as returned by `getPolygons()`) or its index.
|
|
334
|
+
* `partial` fields are merged onto the polygon via `Object.assign`. Skips
|
|
335
|
+
* the merge pass — cheaper than a full prop change for targeted edits like
|
|
336
|
+
* color picker updates from an inspector UI. Silently no-ops when `target`
|
|
337
|
+
* is not found or the index is out of range.
|
|
338
|
+
*/
|
|
339
|
+
updatePolygon(target: Polygon | number, partial: Partial<Polygon>): void;
|
|
291
340
|
}
|
|
292
341
|
/**
|
|
293
342
|
* Pointer event payload delivered to <PolyMesh> handlers. Mirrors r3f's
|
|
@@ -373,21 +422,46 @@ interface PolyMeshProps extends TransformProps, InteractionProps {
|
|
|
373
422
|
autoCenter?: boolean;
|
|
374
423
|
/** Textured polygon lighting mode. Defaults to "baked". */
|
|
375
424
|
textureLighting?: PolyTextureLightingMode;
|
|
376
|
-
/**
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
425
|
+
/** Atlas bitmap budget and CSS sprite size. `"auto"` (default) uses a
|
|
426
|
+
* device-appropriate memory budget (~4 MB mobile / ~16 MB desktop) and
|
|
427
|
+
* desktop/mobile sprite sizing. Numeric values 0.1..1 force an explicit
|
|
428
|
+
* raster scale and the 64px sprite. */
|
|
429
|
+
textureQuality?: TextureQuality;
|
|
430
|
+
/** Per-polygon override render, or static children mounted inside the mesh wrapper. */
|
|
431
|
+
children?: ((polygon: Polygon, index: number) => ReactNode) | ReactNode;
|
|
380
432
|
/** Loading slot — rendered while `src` is being fetched/parsed. */
|
|
381
433
|
fallback?: ReactNode;
|
|
382
434
|
/** Error slot — rendered if parse fails. Receives the Error. */
|
|
383
435
|
errorFallback?: (error: Error) => ReactNode;
|
|
384
436
|
/** Parser options forwarded to parseObj/parseGltf. */
|
|
385
437
|
parseOptions?: UseMeshOptions;
|
|
438
|
+
/**
|
|
439
|
+
* When `true` and the scene is in dynamic lighting mode, emits a flat
|
|
440
|
+
* shadow leaf (`<q class="polycss-shadow">`) sibling for each polygon.
|
|
441
|
+
* The shadow is projected onto the ground plane along the CSS-space light
|
|
442
|
+
* direction via `--shadow-proj` (a CSS var on the scene root). Zero JS in
|
|
443
|
+
* the render loop — projection is pure `calc()`. Defaults to `false`.
|
|
444
|
+
*/
|
|
445
|
+
castShadow?: boolean;
|
|
386
446
|
className?: string;
|
|
387
447
|
style?: CSSProperties;
|
|
388
448
|
}
|
|
389
449
|
declare const PolyMesh: react.ForwardRefExoticComponent<PolyMeshProps & react.RefAttributes<PolyMeshHandle>>;
|
|
390
450
|
|
|
451
|
+
interface PolyGroundProps {
|
|
452
|
+
/** Side length of the ground quad in world units. Default `6`. */
|
|
453
|
+
size?: number;
|
|
454
|
+
/** World-space Z (floor height). Default `0`. */
|
|
455
|
+
z?: number;
|
|
456
|
+
/** World-space XY center. Default `[0, 0]`. */
|
|
457
|
+
center?: [number, number];
|
|
458
|
+
/** Fill color. Default `#7d848e` — medium gray, chosen so the 25% black
|
|
459
|
+
* `<q>` shadow leaves on top have visible contrast against it. */
|
|
460
|
+
color?: string;
|
|
461
|
+
className?: string;
|
|
462
|
+
}
|
|
463
|
+
declare function PolyGround({ size, z, center, color, className, }: PolyGroundProps): react_jsx_runtime.JSX.Element;
|
|
464
|
+
|
|
391
465
|
interface UseSceneContextOptions {
|
|
392
466
|
directionalLight?: PolyDirectionalLight;
|
|
393
467
|
}
|
|
@@ -435,9 +509,76 @@ declare function usePolyMaterial(options: {
|
|
|
435
509
|
* check is sound here because polygon data (vertices, color, texture) is
|
|
436
510
|
* typically created once at parse time and passed by reference.
|
|
437
511
|
*/
|
|
438
|
-
declare function PolyInner({ vertices, color, texture, uvs, data, material, position, scale, rotation, className, style: styleProp, id, onClick, onDoubleClick, onMouseEnter, onMouseLeave, onMouseMove, onPointerDown, onPointerUp, onPointerEnter, onPointerLeave, onFocus, onBlur, onKeyDown, tabIndex, role, "aria-label": ariaLabel, "aria-hidden": ariaHidden, pointerEvents: pointerEventsProp, context, textureLighting: textureLightingProp,
|
|
512
|
+
declare function PolyInner({ vertices, color, texture, uvs, data, material, position, scale, rotation, className, style: styleProp, id, onClick, onDoubleClick, onMouseEnter, onMouseLeave, onMouseMove, onPointerDown, onPointerUp, onPointerEnter, onPointerLeave, onFocus, onBlur, onKeyDown, tabIndex, role, "aria-label": ariaLabel, "aria-hidden": ariaHidden, pointerEvents: pointerEventsProp, context, textureLighting: textureLightingProp, textureQuality: textureQualityProp, baseColor: baseColorProp, ...dataAttrs }: PolyProps): react_jsx_runtime.JSX.Element | null;
|
|
439
513
|
declare const Poly: react__default.MemoExoticComponent<typeof PolyInner>;
|
|
440
514
|
|
|
515
|
+
interface PolyFirstPersonControlsOptions {
|
|
516
|
+
/** Master switch. When `false`, all sub-controls are inert. Default: `true`. */
|
|
517
|
+
enabled?: boolean;
|
|
518
|
+
/** Pointer-lock mouselook (rotX = pitch, rotY = yaw). Default: `true`. */
|
|
519
|
+
lookEnabled?: boolean;
|
|
520
|
+
/** WASD / arrow-key planar movement on world XY. Default: `true`. */
|
|
521
|
+
moveEnabled?: boolean;
|
|
522
|
+
/** Space-bar parametric jump arc on world Z. Default: `true`. */
|
|
523
|
+
jumpEnabled?: boolean;
|
|
524
|
+
/** Ctrl crouch (lowers eye height while held). Default: `true`. */
|
|
525
|
+
crouchEnabled?: boolean;
|
|
526
|
+
/** Mouselook sensitivity in degrees per pixel. Default: `0.15`. */
|
|
527
|
+
lookSensitivity?: number;
|
|
528
|
+
/** Invert vertical mouselook. Default: `false`. */
|
|
529
|
+
invertY?: boolean;
|
|
530
|
+
/** Movement speed in world units per second. Default: `5`. */
|
|
531
|
+
moveSpeed?: number;
|
|
532
|
+
/** Initial vertical velocity for a jump, world units per second. Default: `7`. */
|
|
533
|
+
jumpVelocity?: number;
|
|
534
|
+
/** Gravity acceleration in world units per second squared. Default: `18`. */
|
|
535
|
+
gravity?: number;
|
|
536
|
+
/** Standing eye height above the ground plane. Default: `1.7`. */
|
|
537
|
+
eyeHeight?: number;
|
|
538
|
+
/** Eye height while crouching. Default: `1`. */
|
|
539
|
+
crouchHeight?: number;
|
|
540
|
+
/** World Z of the ground plane the player walks on. Default: `0`. */
|
|
541
|
+
groundZ?: number;
|
|
542
|
+
/** Min pitch (rotX) angle in degrees. Default: `5`. */
|
|
543
|
+
minPitch?: number;
|
|
544
|
+
/** Max pitch (rotX) angle in degrees. Default: `175`. */
|
|
545
|
+
maxPitch?: number;
|
|
546
|
+
}
|
|
547
|
+
interface PolyFirstPersonControlsHandle {
|
|
548
|
+
update(partial: PolyFirstPersonControlsOptions): void;
|
|
549
|
+
resume(): void;
|
|
550
|
+
pause(): void;
|
|
551
|
+
destroy(): void;
|
|
552
|
+
/** Request pointer-lock now. Call from a user gesture (click). */
|
|
553
|
+
lock(): void;
|
|
554
|
+
/** Release pointer-lock. */
|
|
555
|
+
unlock(): void;
|
|
556
|
+
/** Whether pointer-lock is currently held. */
|
|
557
|
+
isLocked(): boolean;
|
|
558
|
+
/**
|
|
559
|
+
* The camera's WORLD position (the eye). Snapshot — mutate via WASD /
|
|
560
|
+
* jump / crouch, or by calling `setOrigin`.
|
|
561
|
+
*/
|
|
562
|
+
getOrigin(): [number, number, number];
|
|
563
|
+
/**
|
|
564
|
+
* Move the camera origin to a specific world position. Re-derives the
|
|
565
|
+
* scene's target so the perspective viewer follows.
|
|
566
|
+
*/
|
|
567
|
+
setOrigin(origin: [number, number, number]): void;
|
|
568
|
+
addEventListener(type: "change" | "start" | "end", listener: () => void): void;
|
|
569
|
+
removeEventListener(type: "change" | "start" | "end", listener: () => void): void;
|
|
570
|
+
hasEventListener(type: "change" | "start" | "end", listener: () => void): boolean;
|
|
571
|
+
}
|
|
572
|
+
interface PolyFirstPersonControlsProps extends PolyFirstPersonControlsOptions {
|
|
573
|
+
/** Called on every camera state change (mouselook, WASD, jump, crouch). */
|
|
574
|
+
onChange?: () => void;
|
|
575
|
+
/** Called when pointer-lock is acquired (interaction starts). */
|
|
576
|
+
onInteractionStart?: () => void;
|
|
577
|
+
/** Called when pointer-lock is released (interaction ends). */
|
|
578
|
+
onInteractionEnd?: () => void;
|
|
579
|
+
}
|
|
580
|
+
declare const PolyFirstPersonControls: react.ForwardRefExoticComponent<PolyFirstPersonControlsProps & react.RefAttributes<PolyFirstPersonControlsHandle>>;
|
|
581
|
+
|
|
441
582
|
interface PolyControlsAnimateOptions {
|
|
442
583
|
/** Degrees per 60Hz-equivalent frame. Default 0.3 (≈ 18 deg/sec). */
|
|
443
584
|
speed?: number;
|
|
@@ -485,14 +626,14 @@ interface SharedControlsProps {
|
|
|
485
626
|
onInteractionEnd?: (camera: PolyControlsCamera) => void;
|
|
486
627
|
}
|
|
487
628
|
|
|
488
|
-
interface PolyOrbitControlsProps extends SharedControlsProps {
|
|
489
|
-
}
|
|
490
|
-
declare function PolyOrbitControls({ drag, wheel, dolly, invert, minZoom, maxZoom, minDistance, maxDistance, animate, onChange, onInteractionStart, onInteractionEnd, }: PolyOrbitControlsProps): null;
|
|
491
|
-
|
|
492
629
|
interface PolyMapControlsProps extends SharedControlsProps {
|
|
493
630
|
}
|
|
494
631
|
declare function PolyMapControls({ drag, wheel, dolly, invert, minZoom, maxZoom, minDistance, maxDistance, animate, onChange, onInteractionStart, onInteractionEnd, }: PolyMapControlsProps): null;
|
|
495
632
|
|
|
633
|
+
interface PolyOrbitControlsProps extends SharedControlsProps {
|
|
634
|
+
}
|
|
635
|
+
declare function PolyOrbitControls({ drag, wheel, dolly, invert, minZoom, maxZoom, minDistance, maxDistance, animate, onChange, onInteractionStart, onInteractionEnd, }: PolyOrbitControlsProps): null;
|
|
636
|
+
|
|
496
637
|
/** Optional ref-or-direct binding to a target mesh. */
|
|
497
638
|
type PolyTransformControlsObject = PolyMeshHandle | RefObject<PolyMeshHandle | null> | null;
|
|
498
639
|
interface PolyTransformControlsObjectChangeEvent {
|
|
@@ -666,4 +807,4 @@ interface UsePolyAnimationResult {
|
|
|
666
807
|
}
|
|
667
808
|
declare function usePolyAnimation(clips: PolyAnimationClip[] | undefined, controller: ParseAnimationController | undefined, root?: RefObject<PolyAnimationTarget | null> | PolyAnimationTarget | null): UsePolyAnimationResult;
|
|
668
809
|
|
|
669
|
-
export { type DOMPassthroughProps, type InteractionProps, Poly, PolyAxesHelper, type PolyAxesHelperProps, PolyPerspectiveCamera as PolyCamera, PolyCameraContext, type PolyCameraContextValue, type PolyPerspectiveCameraProps as PolyCameraProps, type PolyControlsAnimateOptions, type PolyControlsCamera, PolyDirectionalLightHelper, type PolyDirectionalLightHelperProps, type PolyEventHandler, PolyMapControls, type PolyControlsCamera as PolyMapControlsCamera, type PolyMapControlsProps, PolyMesh, type PolyMeshHandle, type PolyMeshProps, type PolyMouseEvent, PolyOrbitControls, type PolyControlsCamera as PolyOrbitControlsCamera, type PolyOrbitControlsProps, PolyOrthographicCamera, type PolyOrthographicCameraProps, PolyPerspectiveCamera, type PolyPerspectiveCameraProps, type PolyPointerEvent, type PolyProps, PolyScene, type PolySceneProps, PolySelect, type PolySelectProps, type PolySelectionApi, PolyTransformControls, type PolyTransformControlsObject, type PolyTransformControlsObjectChangeEvent, type PolyTransformControlsProps, type PolyWheelEvent, type SharedControlsProps, type TransformProps, type UseCameraOptions, type UseCameraResult, type UseMeshOptions, type UseMeshResult, type UsePolyAnimationResult, type UseSceneContextOptions, type UseSceneContextResult, findMeshUnderPoint, findPolyMeshHandle, injectPolyBaseStyles, pointInMeshElement, useCameraContext, usePolyAnimation, usePolyCamera, usePolyMaterial, usePolyMesh, usePolySceneContext, usePolySelect, usePolySelectionApi };
|
|
810
|
+
export { type DOMPassthroughProps, type InteractionProps, Poly, PolyAxesHelper, type PolyAxesHelperProps, PolyPerspectiveCamera as PolyCamera, PolyCameraContext, type PolyCameraContextValue, type PolyPerspectiveCameraProps as PolyCameraProps, type PolyControlsAnimateOptions, type PolyControlsCamera, PolyDirectionalLightHelper, type PolyDirectionalLightHelperProps, type PolyEventHandler, PolyFirstPersonControls, type PolyFirstPersonControlsHandle, type PolyFirstPersonControlsOptions, type PolyFirstPersonControlsProps, PolyGround, type PolyGroundProps, PolyMapControls, type PolyControlsCamera as PolyMapControlsCamera, type PolyMapControlsProps, PolyMesh, type PolyMeshHandle, type PolyMeshProps, type PolyMouseEvent, PolyOrbitControls, type PolyControlsCamera as PolyOrbitControlsCamera, type PolyOrbitControlsProps, PolyOrthographicCamera, type PolyOrthographicCameraProps, PolyPerspectiveCamera, type PolyPerspectiveCameraProps, type PolyPointerEvent, type PolyProps, type PolyRenderStrategiesOption, type PolyRenderStrategy, PolyScene, type PolySceneProps, PolySelect, type PolySelectProps, type PolySelectionApi, PolyTransformControls, type PolyTransformControlsObject, type PolyTransformControlsObjectChangeEvent, type PolyTransformControlsProps, type PolyWheelEvent, type SharedControlsProps, type TransformProps, type UseCameraOptions, type UseCameraResult, type UseMeshOptions, type UseMeshResult, type UsePolyAnimationResult, type UseSceneContextOptions, type UseSceneContextResult, findMeshUnderPoint, findPolyMeshHandle, injectPolyBaseStyles, pointInMeshElement, useCameraContext, usePolyAnimation, usePolyCamera, usePolyMaterial, usePolyMesh, usePolySceneContext, usePolySelect, usePolySelectionApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import react__default, { ReactNode, CSSProperties, MouseEventHandler, PointerEventHandler, FocusEventHandler, KeyboardEventHandler, RefObject, MouseEvent as MouseEvent$1 } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { Vec3, CameraState, CameraHandle, Vec2, PolyMaterial, PolyDirectionalLight, PolyTextureLightingMode, Polygon, PolyAmbientLight, LoadMeshOptions, PolyAnimationTarget, PolyAnimationMixer, PolyAnimationClip, PolyAnimationAction, ParseAnimationController } from '@layoutit/polycss-core';
|
|
5
|
-
export { ArrowPolygonsOptions, AutoRotateConfig, AutoRotateOption, AxesHelperOptions, BASE_TILE, CameraHandle, CameraState, CameraStyleInput, CoverPlanarPolygonsOptions, CullInteriorOptions, DEFAULT_CAMERA_STATE, DEFAULT_PROJECTION, GltfParseOptions, LoadMeshOptions, LoopMode, LoopOnce, LoopPingPong, LoopRepeat, MtlParseResult, NormalizeResult, ObjParseOptions, OctahedronPolygonsOptions, ParseAnimationClip, ParseAnimationController, ParseResult, ParsedColor, PolyAmbientLight, PolyAnimationAction, PolyAnimationClip, PolyAnimationMixer, PolyAnimationTarget, PolyDirectionalLight, PolyMaterial, PolyTextureLightingMode, Polygon, PolygonFace, RingPolygonsOptions, SceneBbox, SceneContext, SceneContextBuildArgs, SceneContextBuildResult, SolidTextureSampleOptions, TexturePaintMetrics, TexturePaintMetricsOptions, TextureTriangle, Vec2, Vec3, VoxParseOptions, arrowPolygons, axesHelperPolygons, bakeSolidTextureSampledPolygons, bakeSolidTextureSamples, buildSceneContext, clampChannel, computeSceneBbox, computeShapeLighting, computeTexturePaintMetrics, coverPlanarPolygons, createIsometricCamera, createPolyAnimationMixer, cullInteriorPolygons, formatColor, inverseRotateVec3, loadMesh, mergePolygons, normalizeInvertMultiplier, normalizePolygons, octahedronPolygons, parseColor, parseGltf, parseHexColor, parseMtl, parseObj, parsePureColor, parseRgbColor, parseVox, polygonFaces, ringPolygons, rotateVec3, shadeColor } from '@layoutit/polycss-core';
|
|
5
|
+
export { ApproximateMergeOptions, ArrowPolygonsOptions, AutoRotateConfig, AutoRotateOption, AxesHelperOptions, BASE_TILE, BoxFace, BoxFaceOptions, BoxPolygonsOptions, CAMERA_BACKFACE_CULL_EPS, CameraCullNormalGroup, CameraCullRotation, CameraHandle, CameraState, CameraStyleInput, CoverPlanarPolygonsOptions, CullInteriorOptions, DEFAULT_CAMERA_STATE, DEFAULT_PROJECTION, GltfParseOptions, LoadMeshOptions, LoopMode, LoopOnce, LoopPingPong, LoopRepeat, MeshResolution, MtlParseResult, NormalizeResult, ObjParseOptions, OctahedronPolygonsOptions, OptimizeMeshPolygonsOptions, ParseAnimationClip, ParseAnimationController, ParseResult, ParsedColor, PolyAmbientLight, PolyAnimationAction, PolyAnimationClip, PolyAnimationMixer, PolyAnimationTarget, PolyDirectionalLight, PolyMaterial, PolyTextureLightingMode, Polygon, PolygonFace, RingPolygonsOptions, SceneBbox, SceneContext, SceneContextBuildArgs, SceneContextBuildResult, SolidTextureSampleOptions, TexturePaintMetrics, TexturePaintMetricsOptions, TextureTriangle, 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, coverPlanarPolygons, createIsometricCamera, createPolyAnimationMixer, cullInteriorPolygons, formatColor, inverseRotateVec3, isAxisAlignedSurfaceNormal, isVoxelCameraCullableNormalGroups, loadMesh, mergePolygons, normalFacesCamera, normalizeInvertMultiplier, normalizePolygons, octahedronPolygons, optimizeMeshPolygons, parseColor, parseGltf, parseHexColor, parseMtl, parseObj, parsePureColor, parseRgbColor, parseVox, polygonCssSurfaceNormal, polygonFaces, polygonFacesCamera, ringPolygons, rotateVec3, shadeColor } from '@layoutit/polycss-core';
|
|
6
6
|
|
|
7
7
|
interface PolyPerspectiveCameraProps {
|
|
8
8
|
zoom?: number;
|
|
@@ -36,6 +36,13 @@ declare const PolyOrthographicCamera: react.MemoExoticComponent<typeof PolyOrtho
|
|
|
36
36
|
|
|
37
37
|
interface SceneStoreState {
|
|
38
38
|
cameraState: CameraState;
|
|
39
|
+
/**
|
|
40
|
+
* Bbox-center of all auto-centerable meshes in world coords. Kept separate
|
|
41
|
+
* from `target` so user pan (written to `target` by controls) survives mesh
|
|
42
|
+
* add/remove without fighting the auto-managed centering offset.
|
|
43
|
+
* [0, 0, 0] when autoCenter is off or there are no centerable meshes.
|
|
44
|
+
*/
|
|
45
|
+
autoCenterOffset: Vec3;
|
|
39
46
|
}
|
|
40
47
|
interface SceneStore {
|
|
41
48
|
getState(): SceneStoreState;
|
|
@@ -45,6 +52,8 @@ interface SceneStore {
|
|
|
45
52
|
updateCameraFromRef(handle: CameraHandle): boolean;
|
|
46
53
|
/** Force notify all subscribers (e.g. after prop-driven camera change). */
|
|
47
54
|
notifyAll(): void;
|
|
55
|
+
/** Update the autoCenterOffset (world coords bbox center). */
|
|
56
|
+
setAutoCenterOffset(offset: Vec3): void;
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
interface UseCameraOptions {
|
|
@@ -95,7 +104,21 @@ interface PolyCameraContextValue {
|
|
|
95
104
|
declare const PolyCameraContext: react.Context<PolyCameraContextValue | null>;
|
|
96
105
|
declare function useCameraContext(): PolyCameraContextValue;
|
|
97
106
|
|
|
98
|
-
|
|
107
|
+
interface ShadowOptions {
|
|
108
|
+
color?: string;
|
|
109
|
+
opacity?: number;
|
|
110
|
+
lift?: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** A render strategy tag that can be selectively disabled. */
|
|
114
|
+
type PolyRenderStrategy = "b" | "i" | "u";
|
|
115
|
+
interface PolyRenderStrategiesOption {
|
|
116
|
+
/** Strategies to skip; polygons that would normally use them fall through
|
|
117
|
+
* the chain (b → i → s, u → i → s, i → s). `<s>` is the universal
|
|
118
|
+
* fallback and cannot be disabled — textured polys have no other path. */
|
|
119
|
+
disable?: readonly PolyRenderStrategy[];
|
|
120
|
+
}
|
|
121
|
+
type TextureQuality = number | "auto";
|
|
99
122
|
|
|
100
123
|
/**
|
|
101
124
|
* Three.js-style transform props accepted by every polycss component.
|
|
@@ -159,14 +182,15 @@ interface PolyProps extends TransformProps, DOMPassthroughProps {
|
|
|
159
182
|
layerElevation?: number;
|
|
160
183
|
directionalLight?: PolyDirectionalLight;
|
|
161
184
|
textureLighting?: PolyTextureLightingMode;
|
|
162
|
-
|
|
185
|
+
textureQuality?: TextureQuality;
|
|
163
186
|
debugShowBackfaces?: boolean;
|
|
164
187
|
[key: string]: unknown;
|
|
165
188
|
};
|
|
166
189
|
/** Textured polygon lighting mode. Defaults to scene context, then "baked". */
|
|
167
190
|
textureLighting?: PolyTextureLightingMode;
|
|
168
|
-
/**
|
|
169
|
-
|
|
191
|
+
/** Atlas bitmap budget and CSS sprite size. `"auto"` (default) uses a
|
|
192
|
+
* device-appropriate memory budget and desktop/mobile sprite sizing. */
|
|
193
|
+
textureQuality?: TextureQuality;
|
|
170
194
|
/** Pre-computed shaded base color from the parent (optional override). */
|
|
171
195
|
baseColor?: string;
|
|
172
196
|
}
|
|
@@ -196,8 +220,18 @@ interface PolySceneProps extends TransformProps {
|
|
|
196
220
|
ambientLight?: PolyAmbientLight;
|
|
197
221
|
/** Textured polygon lighting mode. Defaults to "baked". */
|
|
198
222
|
textureLighting?: PolyTextureLightingMode;
|
|
199
|
-
/**
|
|
200
|
-
|
|
223
|
+
/** Atlas bitmap budget and CSS sprite size. `"auto"` (default) uses a
|
|
224
|
+
* device-appropriate memory budget (~4 MB mobile / ~16 MB desktop) and
|
|
225
|
+
* desktop/mobile sprite sizing. Numeric values 0.1..1 force an explicit
|
|
226
|
+
* raster scale and the 64px sprite. */
|
|
227
|
+
textureQuality?: TextureQuality;
|
|
228
|
+
/**
|
|
229
|
+
* Render strategy overrides. Use `{ disable: ["u"] }` to force solid
|
|
230
|
+
* triangles through the atlas path (`<s>`), or `{ disable: ["b", "i", "u"] }`
|
|
231
|
+
* to force every polygon through the atlas. Mirrors the same option on
|
|
232
|
+
* `renderPolygonsWithTextureAtlas` in `@layoutit/polycss`.
|
|
233
|
+
*/
|
|
234
|
+
strategies?: PolyRenderStrategiesOption;
|
|
201
235
|
/**
|
|
202
236
|
* When `true`, rotation pivots around the mesh's bbox center instead of
|
|
203
237
|
* world (0,0,0). Polygon data is not mutated — the scene element's
|
|
@@ -208,13 +242,19 @@ interface PolySceneProps extends TransformProps {
|
|
|
208
242
|
* origin is at a corner / feet / arbitrary point.
|
|
209
243
|
*/
|
|
210
244
|
autoCenter?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Shadow appearance for meshes with `castShadow={true}`. Only applies in
|
|
247
|
+
* dynamic lighting mode — baked mode does not emit shadow leaves.
|
|
248
|
+
* Defaults: `{ color: "#000000", opacity: 0.25, lift: 0.05 }`.
|
|
249
|
+
*/
|
|
250
|
+
shadow?: ShadowOptions;
|
|
211
251
|
className?: string;
|
|
212
252
|
style?: CSSProperties;
|
|
213
253
|
children?: ReactNode;
|
|
214
254
|
debugShowLabels?: boolean;
|
|
215
255
|
debugShowBackfaces?: boolean;
|
|
216
256
|
}
|
|
217
|
-
declare function PolySceneInner({ polygons: polygonsProp, centerPolygons: centerPolygonsProp, perspective: _perspective, rotX: _rotX, rotY: _rotY, zoom: _zoom, directionalLight, ambientLight, textureLighting,
|
|
257
|
+
declare function PolySceneInner({ polygons: polygonsProp, centerPolygons: centerPolygonsProp, perspective: _perspective, rotX: _rotX, rotY: _rotY, zoom: _zoom, directionalLight, ambientLight, textureLighting, textureQuality, strategies, autoCenter, shadow, className, style, children, position: _position, scale: _scale, rotation: _rotation, debugShowLabels: _debugShowLabels, debugShowBackfaces, }: PolySceneProps): react_jsx_runtime.JSX.Element;
|
|
218
258
|
declare const PolyScene: react.MemoExoticComponent<typeof PolySceneInner>;
|
|
219
259
|
|
|
220
260
|
type UseMeshOptions = LoadMeshOptions;
|
|
@@ -288,6 +328,15 @@ interface PolyMeshHandle {
|
|
|
288
328
|
* safe to call.
|
|
289
329
|
*/
|
|
290
330
|
rebakeAtlas(): void;
|
|
331
|
+
/**
|
|
332
|
+
* Mutate a single polygon in place and re-render the mesh. `target` is
|
|
333
|
+
* either a polygon reference (as returned by `getPolygons()`) or its index.
|
|
334
|
+
* `partial` fields are merged onto the polygon via `Object.assign`. Skips
|
|
335
|
+
* the merge pass — cheaper than a full prop change for targeted edits like
|
|
336
|
+
* color picker updates from an inspector UI. Silently no-ops when `target`
|
|
337
|
+
* is not found or the index is out of range.
|
|
338
|
+
*/
|
|
339
|
+
updatePolygon(target: Polygon | number, partial: Partial<Polygon>): void;
|
|
291
340
|
}
|
|
292
341
|
/**
|
|
293
342
|
* Pointer event payload delivered to <PolyMesh> handlers. Mirrors r3f's
|
|
@@ -373,21 +422,46 @@ interface PolyMeshProps extends TransformProps, InteractionProps {
|
|
|
373
422
|
autoCenter?: boolean;
|
|
374
423
|
/** Textured polygon lighting mode. Defaults to "baked". */
|
|
375
424
|
textureLighting?: PolyTextureLightingMode;
|
|
376
|
-
/**
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
425
|
+
/** Atlas bitmap budget and CSS sprite size. `"auto"` (default) uses a
|
|
426
|
+
* device-appropriate memory budget (~4 MB mobile / ~16 MB desktop) and
|
|
427
|
+
* desktop/mobile sprite sizing. Numeric values 0.1..1 force an explicit
|
|
428
|
+
* raster scale and the 64px sprite. */
|
|
429
|
+
textureQuality?: TextureQuality;
|
|
430
|
+
/** Per-polygon override render, or static children mounted inside the mesh wrapper. */
|
|
431
|
+
children?: ((polygon: Polygon, index: number) => ReactNode) | ReactNode;
|
|
380
432
|
/** Loading slot — rendered while `src` is being fetched/parsed. */
|
|
381
433
|
fallback?: ReactNode;
|
|
382
434
|
/** Error slot — rendered if parse fails. Receives the Error. */
|
|
383
435
|
errorFallback?: (error: Error) => ReactNode;
|
|
384
436
|
/** Parser options forwarded to parseObj/parseGltf. */
|
|
385
437
|
parseOptions?: UseMeshOptions;
|
|
438
|
+
/**
|
|
439
|
+
* When `true` and the scene is in dynamic lighting mode, emits a flat
|
|
440
|
+
* shadow leaf (`<q class="polycss-shadow">`) sibling for each polygon.
|
|
441
|
+
* The shadow is projected onto the ground plane along the CSS-space light
|
|
442
|
+
* direction via `--shadow-proj` (a CSS var on the scene root). Zero JS in
|
|
443
|
+
* the render loop — projection is pure `calc()`. Defaults to `false`.
|
|
444
|
+
*/
|
|
445
|
+
castShadow?: boolean;
|
|
386
446
|
className?: string;
|
|
387
447
|
style?: CSSProperties;
|
|
388
448
|
}
|
|
389
449
|
declare const PolyMesh: react.ForwardRefExoticComponent<PolyMeshProps & react.RefAttributes<PolyMeshHandle>>;
|
|
390
450
|
|
|
451
|
+
interface PolyGroundProps {
|
|
452
|
+
/** Side length of the ground quad in world units. Default `6`. */
|
|
453
|
+
size?: number;
|
|
454
|
+
/** World-space Z (floor height). Default `0`. */
|
|
455
|
+
z?: number;
|
|
456
|
+
/** World-space XY center. Default `[0, 0]`. */
|
|
457
|
+
center?: [number, number];
|
|
458
|
+
/** Fill color. Default `#7d848e` — medium gray, chosen so the 25% black
|
|
459
|
+
* `<q>` shadow leaves on top have visible contrast against it. */
|
|
460
|
+
color?: string;
|
|
461
|
+
className?: string;
|
|
462
|
+
}
|
|
463
|
+
declare function PolyGround({ size, z, center, color, className, }: PolyGroundProps): react_jsx_runtime.JSX.Element;
|
|
464
|
+
|
|
391
465
|
interface UseSceneContextOptions {
|
|
392
466
|
directionalLight?: PolyDirectionalLight;
|
|
393
467
|
}
|
|
@@ -435,9 +509,76 @@ declare function usePolyMaterial(options: {
|
|
|
435
509
|
* check is sound here because polygon data (vertices, color, texture) is
|
|
436
510
|
* typically created once at parse time and passed by reference.
|
|
437
511
|
*/
|
|
438
|
-
declare function PolyInner({ vertices, color, texture, uvs, data, material, position, scale, rotation, className, style: styleProp, id, onClick, onDoubleClick, onMouseEnter, onMouseLeave, onMouseMove, onPointerDown, onPointerUp, onPointerEnter, onPointerLeave, onFocus, onBlur, onKeyDown, tabIndex, role, "aria-label": ariaLabel, "aria-hidden": ariaHidden, pointerEvents: pointerEventsProp, context, textureLighting: textureLightingProp,
|
|
512
|
+
declare function PolyInner({ vertices, color, texture, uvs, data, material, position, scale, rotation, className, style: styleProp, id, onClick, onDoubleClick, onMouseEnter, onMouseLeave, onMouseMove, onPointerDown, onPointerUp, onPointerEnter, onPointerLeave, onFocus, onBlur, onKeyDown, tabIndex, role, "aria-label": ariaLabel, "aria-hidden": ariaHidden, pointerEvents: pointerEventsProp, context, textureLighting: textureLightingProp, textureQuality: textureQualityProp, baseColor: baseColorProp, ...dataAttrs }: PolyProps): react_jsx_runtime.JSX.Element | null;
|
|
439
513
|
declare const Poly: react__default.MemoExoticComponent<typeof PolyInner>;
|
|
440
514
|
|
|
515
|
+
interface PolyFirstPersonControlsOptions {
|
|
516
|
+
/** Master switch. When `false`, all sub-controls are inert. Default: `true`. */
|
|
517
|
+
enabled?: boolean;
|
|
518
|
+
/** Pointer-lock mouselook (rotX = pitch, rotY = yaw). Default: `true`. */
|
|
519
|
+
lookEnabled?: boolean;
|
|
520
|
+
/** WASD / arrow-key planar movement on world XY. Default: `true`. */
|
|
521
|
+
moveEnabled?: boolean;
|
|
522
|
+
/** Space-bar parametric jump arc on world Z. Default: `true`. */
|
|
523
|
+
jumpEnabled?: boolean;
|
|
524
|
+
/** Ctrl crouch (lowers eye height while held). Default: `true`. */
|
|
525
|
+
crouchEnabled?: boolean;
|
|
526
|
+
/** Mouselook sensitivity in degrees per pixel. Default: `0.15`. */
|
|
527
|
+
lookSensitivity?: number;
|
|
528
|
+
/** Invert vertical mouselook. Default: `false`. */
|
|
529
|
+
invertY?: boolean;
|
|
530
|
+
/** Movement speed in world units per second. Default: `5`. */
|
|
531
|
+
moveSpeed?: number;
|
|
532
|
+
/** Initial vertical velocity for a jump, world units per second. Default: `7`. */
|
|
533
|
+
jumpVelocity?: number;
|
|
534
|
+
/** Gravity acceleration in world units per second squared. Default: `18`. */
|
|
535
|
+
gravity?: number;
|
|
536
|
+
/** Standing eye height above the ground plane. Default: `1.7`. */
|
|
537
|
+
eyeHeight?: number;
|
|
538
|
+
/** Eye height while crouching. Default: `1`. */
|
|
539
|
+
crouchHeight?: number;
|
|
540
|
+
/** World Z of the ground plane the player walks on. Default: `0`. */
|
|
541
|
+
groundZ?: number;
|
|
542
|
+
/** Min pitch (rotX) angle in degrees. Default: `5`. */
|
|
543
|
+
minPitch?: number;
|
|
544
|
+
/** Max pitch (rotX) angle in degrees. Default: `175`. */
|
|
545
|
+
maxPitch?: number;
|
|
546
|
+
}
|
|
547
|
+
interface PolyFirstPersonControlsHandle {
|
|
548
|
+
update(partial: PolyFirstPersonControlsOptions): void;
|
|
549
|
+
resume(): void;
|
|
550
|
+
pause(): void;
|
|
551
|
+
destroy(): void;
|
|
552
|
+
/** Request pointer-lock now. Call from a user gesture (click). */
|
|
553
|
+
lock(): void;
|
|
554
|
+
/** Release pointer-lock. */
|
|
555
|
+
unlock(): void;
|
|
556
|
+
/** Whether pointer-lock is currently held. */
|
|
557
|
+
isLocked(): boolean;
|
|
558
|
+
/**
|
|
559
|
+
* The camera's WORLD position (the eye). Snapshot — mutate via WASD /
|
|
560
|
+
* jump / crouch, or by calling `setOrigin`.
|
|
561
|
+
*/
|
|
562
|
+
getOrigin(): [number, number, number];
|
|
563
|
+
/**
|
|
564
|
+
* Move the camera origin to a specific world position. Re-derives the
|
|
565
|
+
* scene's target so the perspective viewer follows.
|
|
566
|
+
*/
|
|
567
|
+
setOrigin(origin: [number, number, number]): void;
|
|
568
|
+
addEventListener(type: "change" | "start" | "end", listener: () => void): void;
|
|
569
|
+
removeEventListener(type: "change" | "start" | "end", listener: () => void): void;
|
|
570
|
+
hasEventListener(type: "change" | "start" | "end", listener: () => void): boolean;
|
|
571
|
+
}
|
|
572
|
+
interface PolyFirstPersonControlsProps extends PolyFirstPersonControlsOptions {
|
|
573
|
+
/** Called on every camera state change (mouselook, WASD, jump, crouch). */
|
|
574
|
+
onChange?: () => void;
|
|
575
|
+
/** Called when pointer-lock is acquired (interaction starts). */
|
|
576
|
+
onInteractionStart?: () => void;
|
|
577
|
+
/** Called when pointer-lock is released (interaction ends). */
|
|
578
|
+
onInteractionEnd?: () => void;
|
|
579
|
+
}
|
|
580
|
+
declare const PolyFirstPersonControls: react.ForwardRefExoticComponent<PolyFirstPersonControlsProps & react.RefAttributes<PolyFirstPersonControlsHandle>>;
|
|
581
|
+
|
|
441
582
|
interface PolyControlsAnimateOptions {
|
|
442
583
|
/** Degrees per 60Hz-equivalent frame. Default 0.3 (≈ 18 deg/sec). */
|
|
443
584
|
speed?: number;
|
|
@@ -485,14 +626,14 @@ interface SharedControlsProps {
|
|
|
485
626
|
onInteractionEnd?: (camera: PolyControlsCamera) => void;
|
|
486
627
|
}
|
|
487
628
|
|
|
488
|
-
interface PolyOrbitControlsProps extends SharedControlsProps {
|
|
489
|
-
}
|
|
490
|
-
declare function PolyOrbitControls({ drag, wheel, dolly, invert, minZoom, maxZoom, minDistance, maxDistance, animate, onChange, onInteractionStart, onInteractionEnd, }: PolyOrbitControlsProps): null;
|
|
491
|
-
|
|
492
629
|
interface PolyMapControlsProps extends SharedControlsProps {
|
|
493
630
|
}
|
|
494
631
|
declare function PolyMapControls({ drag, wheel, dolly, invert, minZoom, maxZoom, minDistance, maxDistance, animate, onChange, onInteractionStart, onInteractionEnd, }: PolyMapControlsProps): null;
|
|
495
632
|
|
|
633
|
+
interface PolyOrbitControlsProps extends SharedControlsProps {
|
|
634
|
+
}
|
|
635
|
+
declare function PolyOrbitControls({ drag, wheel, dolly, invert, minZoom, maxZoom, minDistance, maxDistance, animate, onChange, onInteractionStart, onInteractionEnd, }: PolyOrbitControlsProps): null;
|
|
636
|
+
|
|
496
637
|
/** Optional ref-or-direct binding to a target mesh. */
|
|
497
638
|
type PolyTransformControlsObject = PolyMeshHandle | RefObject<PolyMeshHandle | null> | null;
|
|
498
639
|
interface PolyTransformControlsObjectChangeEvent {
|
|
@@ -666,4 +807,4 @@ interface UsePolyAnimationResult {
|
|
|
666
807
|
}
|
|
667
808
|
declare function usePolyAnimation(clips: PolyAnimationClip[] | undefined, controller: ParseAnimationController | undefined, root?: RefObject<PolyAnimationTarget | null> | PolyAnimationTarget | null): UsePolyAnimationResult;
|
|
668
809
|
|
|
669
|
-
export { type DOMPassthroughProps, type InteractionProps, Poly, PolyAxesHelper, type PolyAxesHelperProps, PolyPerspectiveCamera as PolyCamera, PolyCameraContext, type PolyCameraContextValue, type PolyPerspectiveCameraProps as PolyCameraProps, type PolyControlsAnimateOptions, type PolyControlsCamera, PolyDirectionalLightHelper, type PolyDirectionalLightHelperProps, type PolyEventHandler, PolyMapControls, type PolyControlsCamera as PolyMapControlsCamera, type PolyMapControlsProps, PolyMesh, type PolyMeshHandle, type PolyMeshProps, type PolyMouseEvent, PolyOrbitControls, type PolyControlsCamera as PolyOrbitControlsCamera, type PolyOrbitControlsProps, PolyOrthographicCamera, type PolyOrthographicCameraProps, PolyPerspectiveCamera, type PolyPerspectiveCameraProps, type PolyPointerEvent, type PolyProps, PolyScene, type PolySceneProps, PolySelect, type PolySelectProps, type PolySelectionApi, PolyTransformControls, type PolyTransformControlsObject, type PolyTransformControlsObjectChangeEvent, type PolyTransformControlsProps, type PolyWheelEvent, type SharedControlsProps, type TransformProps, type UseCameraOptions, type UseCameraResult, type UseMeshOptions, type UseMeshResult, type UsePolyAnimationResult, type UseSceneContextOptions, type UseSceneContextResult, findMeshUnderPoint, findPolyMeshHandle, injectPolyBaseStyles, pointInMeshElement, useCameraContext, usePolyAnimation, usePolyCamera, usePolyMaterial, usePolyMesh, usePolySceneContext, usePolySelect, usePolySelectionApi };
|
|
810
|
+
export { type DOMPassthroughProps, type InteractionProps, Poly, PolyAxesHelper, type PolyAxesHelperProps, PolyPerspectiveCamera as PolyCamera, PolyCameraContext, type PolyCameraContextValue, type PolyPerspectiveCameraProps as PolyCameraProps, type PolyControlsAnimateOptions, type PolyControlsCamera, PolyDirectionalLightHelper, type PolyDirectionalLightHelperProps, type PolyEventHandler, PolyFirstPersonControls, type PolyFirstPersonControlsHandle, type PolyFirstPersonControlsOptions, type PolyFirstPersonControlsProps, PolyGround, type PolyGroundProps, PolyMapControls, type PolyControlsCamera as PolyMapControlsCamera, type PolyMapControlsProps, PolyMesh, type PolyMeshHandle, type PolyMeshProps, type PolyMouseEvent, PolyOrbitControls, type PolyControlsCamera as PolyOrbitControlsCamera, type PolyOrbitControlsProps, PolyOrthographicCamera, type PolyOrthographicCameraProps, PolyPerspectiveCamera, type PolyPerspectiveCameraProps, type PolyPointerEvent, type PolyProps, type PolyRenderStrategiesOption, type PolyRenderStrategy, PolyScene, type PolySceneProps, PolySelect, type PolySelectProps, type PolySelectionApi, PolyTransformControls, type PolyTransformControlsObject, type PolyTransformControlsObjectChangeEvent, type PolyTransformControlsProps, type PolyWheelEvent, type SharedControlsProps, type TransformProps, type UseCameraOptions, type UseCameraResult, type UseMeshOptions, type UseMeshResult, type UsePolyAnimationResult, type UseSceneContextOptions, type UseSceneContextResult, findMeshUnderPoint, findPolyMeshHandle, injectPolyBaseStyles, pointInMeshElement, useCameraContext, usePolyAnimation, usePolyCamera, usePolyMaterial, usePolyMesh, usePolySceneContext, usePolySelect, usePolySelectionApi };
|