@glyphcss/react 0.0.3 → 0.0.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/dist/index.cjs +25 -6
- package/dist/index.d.cts +46 -11
- package/dist/index.d.ts +46 -11
- package/dist/index.js +25 -6
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -193,6 +193,7 @@ function GlyphSceneInner({
|
|
|
193
193
|
smoothShading,
|
|
194
194
|
creaseAngle,
|
|
195
195
|
autoSize,
|
|
196
|
+
shadow,
|
|
196
197
|
className,
|
|
197
198
|
style,
|
|
198
199
|
children
|
|
@@ -212,6 +213,7 @@ function GlyphSceneInner({
|
|
|
212
213
|
smoothShading,
|
|
213
214
|
creaseAngle,
|
|
214
215
|
autoSize,
|
|
216
|
+
shadow,
|
|
215
217
|
camera: cameraRef.current ?? void 0
|
|
216
218
|
}), []);
|
|
217
219
|
const hostCallbackRef = (0, import_react3.useCallback)((el) => {
|
|
@@ -243,10 +245,11 @@ function GlyphSceneInner({
|
|
|
243
245
|
if (smoothShading !== void 0) partial.smoothShading = smoothShading;
|
|
244
246
|
if (creaseAngle !== void 0) partial.creaseAngle = creaseAngle;
|
|
245
247
|
if (autoSize !== void 0) partial.autoSize = autoSize;
|
|
248
|
+
partial.shadow = shadow;
|
|
246
249
|
if (Object.keys(partial).length > 0) {
|
|
247
250
|
scene.setOptions(partial);
|
|
248
251
|
}
|
|
249
|
-
}, [mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight, smoothShading, creaseAngle, autoSize]);
|
|
252
|
+
}, [mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight, smoothShading, creaseAngle, autoSize, shadow]);
|
|
250
253
|
const ctxValue = (0, import_react3.useMemo)(() => ({ sceneRef }), [sceneRef]);
|
|
251
254
|
const computedClassName = `glyph-host${className ? ` ${className}` : ""}`;
|
|
252
255
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlyphSceneContext.Provider, { value: ctxValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: hostCallbackRef, className: computedClassName, style, children }) });
|
|
@@ -306,6 +309,8 @@ function GlyphMeshInner({
|
|
|
306
309
|
position,
|
|
307
310
|
scale,
|
|
308
311
|
rotation,
|
|
312
|
+
castShadow = false,
|
|
313
|
+
receiveShadow = false,
|
|
309
314
|
className,
|
|
310
315
|
style,
|
|
311
316
|
children
|
|
@@ -322,8 +327,10 @@ function GlyphMeshInner({
|
|
|
322
327
|
id,
|
|
323
328
|
position,
|
|
324
329
|
scale,
|
|
325
|
-
rotation
|
|
326
|
-
|
|
330
|
+
rotation,
|
|
331
|
+
castShadow,
|
|
332
|
+
receiveShadow
|
|
333
|
+
}), [id, position, scale, rotation, castShadow, receiveShadow]);
|
|
327
334
|
(0, import_react4.useEffect)(() => {
|
|
328
335
|
const scene = sceneRef.current;
|
|
329
336
|
if (!scene) return;
|
|
@@ -371,6 +378,8 @@ function GlyphGroundInner({
|
|
|
371
378
|
position = [0, -0.5, 0],
|
|
372
379
|
rotation,
|
|
373
380
|
id,
|
|
381
|
+
castShadow = false,
|
|
382
|
+
receiveShadow = true,
|
|
374
383
|
className,
|
|
375
384
|
style
|
|
376
385
|
}) {
|
|
@@ -390,6 +399,8 @@ function GlyphGroundInner({
|
|
|
390
399
|
polygons,
|
|
391
400
|
position,
|
|
392
401
|
rotation,
|
|
402
|
+
castShadow,
|
|
403
|
+
receiveShadow,
|
|
393
404
|
className,
|
|
394
405
|
style
|
|
395
406
|
}
|
|
@@ -530,6 +541,7 @@ function GlyphPerspectiveCameraInner({
|
|
|
530
541
|
rotX,
|
|
531
542
|
rotY,
|
|
532
543
|
distance,
|
|
544
|
+
perspective,
|
|
533
545
|
zoom,
|
|
534
546
|
stretch,
|
|
535
547
|
center,
|
|
@@ -544,6 +556,7 @@ function GlyphPerspectiveCameraInner({
|
|
|
544
556
|
if (rotX !== void 0) opts.rotX = rotX;
|
|
545
557
|
if (rotY !== void 0) opts.rotY = rotY;
|
|
546
558
|
if (distance !== void 0) opts.distance = distance;
|
|
559
|
+
if (perspective !== void 0) opts.perspective = perspective;
|
|
547
560
|
if (zoom !== void 0) opts.zoom = zoom;
|
|
548
561
|
if (stretch !== void 0) opts.stretch = stretch;
|
|
549
562
|
if (center !== void 0) opts.center = center;
|
|
@@ -565,6 +578,10 @@ function GlyphPerspectiveCameraInner({
|
|
|
565
578
|
camera.distance = distance;
|
|
566
579
|
dirty = true;
|
|
567
580
|
}
|
|
581
|
+
if (perspective !== void 0 && camera.perspective !== perspective) {
|
|
582
|
+
camera.perspective = perspective;
|
|
583
|
+
dirty = true;
|
|
584
|
+
}
|
|
568
585
|
if (zoom !== void 0 && camera.zoom !== zoom) {
|
|
569
586
|
camera.zoom = zoom;
|
|
570
587
|
dirty = true;
|
|
@@ -594,12 +611,13 @@ function GlyphOrbitControls({
|
|
|
594
611
|
drag = true,
|
|
595
612
|
wheel = true,
|
|
596
613
|
invert = false,
|
|
614
|
+
clampPitch = true,
|
|
597
615
|
animate = false
|
|
598
616
|
}) {
|
|
599
617
|
const { sceneRef } = useGlyphSceneContext();
|
|
600
618
|
const controlsRef = (0, import_react11.useRef)(null);
|
|
601
|
-
const propsRef = (0, import_react11.useRef)({ drag, wheel, invert, animate });
|
|
602
|
-
propsRef.current = { drag, wheel, invert, animate };
|
|
619
|
+
const propsRef = (0, import_react11.useRef)({ drag, wheel, invert, clampPitch, animate });
|
|
620
|
+
propsRef.current = { drag, wheel, invert, clampPitch, animate };
|
|
603
621
|
(0, import_react11.useEffect)(() => {
|
|
604
622
|
const scene = sceneRef.current;
|
|
605
623
|
if (!scene) return;
|
|
@@ -607,6 +625,7 @@ function GlyphOrbitControls({
|
|
|
607
625
|
drag: propsRef.current.drag,
|
|
608
626
|
wheel: propsRef.current.wheel,
|
|
609
627
|
invert: propsRef.current.invert,
|
|
628
|
+
clampPitch: propsRef.current.clampPitch,
|
|
610
629
|
animate: propsRef.current.animate === false ? false : propsRef.current.animate
|
|
611
630
|
};
|
|
612
631
|
const controls = (0, import_glyphcss5.createGlyphOrbitControls)(scene, opts);
|
|
@@ -619,7 +638,7 @@ function GlyphOrbitControls({
|
|
|
619
638
|
(0, import_react11.useEffect)(() => {
|
|
620
639
|
const controls = controlsRef.current;
|
|
621
640
|
if (!controls) return;
|
|
622
|
-
controls.update({ drag, wheel, invert, animate: animate === false ? false : animate });
|
|
641
|
+
controls.update({ drag, wheel, invert, clampPitch, animate: animate === false ? false : animate });
|
|
623
642
|
});
|
|
624
643
|
return null;
|
|
625
644
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -3,8 +3,8 @@ export { ApproximateMergeOptions, ArrowPolygonsOptions, AutoRotateConfig, AutoRo
|
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { CSSProperties, ReactNode, MouseEventHandler, RefObject } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
-
import { GlyphDirectionalLight, GlyphAmbientLight, GlyphPointerEvent, GlyphMouseEvent, GlyphWheelEvent, GlyphSceneHandle, GlyphMeshTransform, GlyphMeshHandle, GlyphCamera } from 'glyphcss';
|
|
7
|
-
export { GlyphEventHandler, GlyphMeshHandle, GlyphMouseEvent, GlyphPointerEvent, GlyphWheelEvent, injectGlyphBaseStyles } from 'glyphcss';
|
|
6
|
+
import { GlyphDirectionalLight, GlyphAmbientLight, GlyphShadowOptions, GlyphPointerEvent, GlyphMouseEvent, GlyphWheelEvent, GlyphSceneHandle, GlyphMeshTransform, GlyphMeshHandle, GlyphCamera } from 'glyphcss';
|
|
7
|
+
export { GlyphEventHandler, GlyphMeshHandle, GlyphMouseEvent, GlyphPointerEvent, GlyphShadowOptions, GlyphWheelEvent, injectGlyphBaseStyles } from 'glyphcss';
|
|
8
8
|
|
|
9
9
|
interface GlyphSceneProps {
|
|
10
10
|
/** Render mode: "wireframe" | "solid". Default "solid". */
|
|
@@ -27,11 +27,17 @@ interface GlyphSceneProps {
|
|
|
27
27
|
creaseAngle?: number;
|
|
28
28
|
/** Observe host element and adapt cols/rows to fill it. Default false. */
|
|
29
29
|
autoSize?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Shadow-map configuration. `undefined` (default) means no shadows.
|
|
32
|
+
* Set this together with `castShadow`/`receiveShadow` on child `GlyphMesh`
|
|
33
|
+
* components to enable shadow casting.
|
|
34
|
+
*/
|
|
35
|
+
shadow?: GlyphShadowOptions;
|
|
30
36
|
className?: string;
|
|
31
37
|
style?: CSSProperties;
|
|
32
38
|
children?: ReactNode;
|
|
33
39
|
}
|
|
34
|
-
declare function GlyphSceneInner({ mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight, smoothShading, creaseAngle, autoSize, className, style, children, }: GlyphSceneProps): react_jsx_runtime.JSX.Element;
|
|
40
|
+
declare function GlyphSceneInner({ mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight, smoothShading, creaseAngle, autoSize, shadow, className, style, children, }: GlyphSceneProps): react_jsx_runtime.JSX.Element;
|
|
35
41
|
declare const GlyphScene: react.MemoExoticComponent<typeof GlyphSceneInner>;
|
|
36
42
|
|
|
37
43
|
interface GlyphMeshProps {
|
|
@@ -51,6 +57,17 @@ interface GlyphMeshProps {
|
|
|
51
57
|
position?: Vec3;
|
|
52
58
|
scale?: number | Vec3;
|
|
53
59
|
rotation?: Vec3;
|
|
60
|
+
/**
|
|
61
|
+
* This mesh casts shadows onto `receiveShadow` surfaces.
|
|
62
|
+
* Default false — opt-in, matching PolyMesh behaviour.
|
|
63
|
+
*/
|
|
64
|
+
castShadow?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* This mesh receives (displays) shadows from `castShadow` meshes.
|
|
67
|
+
* A mesh that is both `castShadow` and `receiveShadow` will self-shadow.
|
|
68
|
+
* Default false — opt-in, matching PolyMesh behaviour.
|
|
69
|
+
*/
|
|
70
|
+
receiveShadow?: boolean;
|
|
54
71
|
className?: string;
|
|
55
72
|
style?: CSSProperties;
|
|
56
73
|
children?: ReactNode;
|
|
@@ -62,7 +79,7 @@ interface GlyphMeshProps {
|
|
|
62
79
|
onClick?: (event: GlyphMouseEvent) => void;
|
|
63
80
|
onWheel?: (event: GlyphWheelEvent) => void;
|
|
64
81
|
}
|
|
65
|
-
declare function GlyphMeshInner({ id, polygons: polygonsProp, geometry, size, color, position, scale, rotation, className, style, children, }: GlyphMeshProps): react_jsx_runtime.JSX.Element;
|
|
82
|
+
declare function GlyphMeshInner({ id, polygons: polygonsProp, geometry, size, color, position, scale, rotation, castShadow, receiveShadow, className, style, children, }: GlyphMeshProps): react_jsx_runtime.JSX.Element;
|
|
66
83
|
declare const GlyphMesh: react.MemoExoticComponent<typeof GlyphMeshInner>;
|
|
67
84
|
|
|
68
85
|
interface GlyphGroundProps {
|
|
@@ -72,14 +89,24 @@ interface GlyphGroundProps {
|
|
|
72
89
|
color?: string;
|
|
73
90
|
/** World-space position. Default [0, -0.5, 0]. */
|
|
74
91
|
position?: Vec3;
|
|
75
|
-
/** World-space rotation in
|
|
92
|
+
/** World-space rotation in degrees (Euler XYZ). */
|
|
76
93
|
rotation?: Vec3;
|
|
77
94
|
/** String id forwarded to the underlying mesh handle. */
|
|
78
95
|
id?: string;
|
|
96
|
+
/**
|
|
97
|
+
* This ground plane casts shadows onto other `receiveShadow` surfaces.
|
|
98
|
+
* Default false — ground planes typically only receive shadows, matching PolyGround.
|
|
99
|
+
*/
|
|
100
|
+
castShadow?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* This ground plane receives (displays) shadows from `castShadow` meshes.
|
|
103
|
+
* Default true — ground planes are the primary shadow receivers, matching PolyGround.
|
|
104
|
+
*/
|
|
105
|
+
receiveShadow?: boolean;
|
|
79
106
|
className?: string;
|
|
80
107
|
style?: CSSProperties;
|
|
81
108
|
}
|
|
82
|
-
declare function GlyphGroundInner({ size, color, position, rotation, id, className, style, }: GlyphGroundProps): react_jsx_runtime.JSX.Element;
|
|
109
|
+
declare function GlyphGroundInner({ size, color, position, rotation, id, castShadow, receiveShadow, className, style, }: GlyphGroundProps): react_jsx_runtime.JSX.Element;
|
|
83
110
|
declare const GlyphGround: react.MemoExoticComponent<typeof GlyphGroundInner>;
|
|
84
111
|
|
|
85
112
|
interface GlyphHotspotProps {
|
|
@@ -123,7 +150,7 @@ declare function findMeshUnderPoint(clientX: number, clientY: number, filter?: (
|
|
|
123
150
|
interface GlyphOrthographicCameraProps {
|
|
124
151
|
rotX?: number;
|
|
125
152
|
rotY?: number;
|
|
126
|
-
/** Orthographic zoom
|
|
153
|
+
/** Orthographic zoom — absolute px per world unit (zoom=1 → BASE_TILE=50). Default 0.65. */
|
|
127
154
|
zoom?: number;
|
|
128
155
|
/** Center of projection in normalized grid coords. Default [0.5, 0.5]. */
|
|
129
156
|
center?: [number, number];
|
|
@@ -137,9 +164,12 @@ declare const GlyphOrthographicCamera: react.MemoExoticComponent<typeof GlyphOrt
|
|
|
137
164
|
interface GlyphPerspectiveCameraProps {
|
|
138
165
|
rotX?: number;
|
|
139
166
|
rotY?: number;
|
|
140
|
-
/** Perspective distance. Default
|
|
167
|
+
/** Perspective distance (world units). Default 6. */
|
|
141
168
|
distance?: number;
|
|
142
|
-
/**
|
|
169
|
+
/** CSS-perspective distance in virtual pixels (matches voxcss). Larger =
|
|
170
|
+
* flatter. Default 32000. Set 0 to disable (legacy orbit projection). */
|
|
171
|
+
perspective?: number;
|
|
172
|
+
/** Camera zoom — absolute px per world unit (zoom=1 → BASE_TILE=50). Default 0.65. */
|
|
143
173
|
zoom?: number;
|
|
144
174
|
/** Extra horizontal stretch on top of cellAspect. Default 1.0. */
|
|
145
175
|
stretch?: number;
|
|
@@ -149,7 +179,7 @@ interface GlyphPerspectiveCameraProps {
|
|
|
149
179
|
style?: CSSProperties;
|
|
150
180
|
children?: ReactNode;
|
|
151
181
|
}
|
|
152
|
-
declare function GlyphPerspectiveCameraInner({ rotX, rotY, distance, zoom, stretch, center, className, style, children, }: GlyphPerspectiveCameraProps): react_jsx_runtime.JSX.Element;
|
|
182
|
+
declare function GlyphPerspectiveCameraInner({ rotX, rotY, distance, perspective, zoom, stretch, center, className, style, children, }: GlyphPerspectiveCameraProps): react_jsx_runtime.JSX.Element;
|
|
153
183
|
declare const GlyphPerspectiveCamera: react.MemoExoticComponent<typeof GlyphPerspectiveCameraInner>;
|
|
154
184
|
|
|
155
185
|
interface GlyphCameraContextValue {
|
|
@@ -172,6 +202,11 @@ interface GlyphOrbitControlsProps {
|
|
|
172
202
|
wheel?: boolean;
|
|
173
203
|
/** Drag-direction inversion. Default false. */
|
|
174
204
|
invert?: boolean | number;
|
|
205
|
+
/**
|
|
206
|
+
* Clamp vertical drag to ±π/2. Default true. Set false for globe-style
|
|
207
|
+
* unrestricted tumbling past the poles.
|
|
208
|
+
*/
|
|
209
|
+
clampPitch?: boolean;
|
|
175
210
|
/** Auto-rotate config. Default false. */
|
|
176
211
|
animate?: false | {
|
|
177
212
|
speed?: number;
|
|
@@ -179,7 +214,7 @@ interface GlyphOrbitControlsProps {
|
|
|
179
214
|
pauseOnInteraction?: boolean;
|
|
180
215
|
};
|
|
181
216
|
}
|
|
182
|
-
declare function GlyphOrbitControls({ drag, wheel, invert, animate, }: GlyphOrbitControlsProps): null;
|
|
217
|
+
declare function GlyphOrbitControls({ drag, wheel, invert, clampPitch, animate, }: GlyphOrbitControlsProps): null;
|
|
183
218
|
|
|
184
219
|
interface GlyphMapControlsProps {
|
|
185
220
|
drag?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { ApproximateMergeOptions, ArrowPolygonsOptions, AutoRotateConfig, AutoRo
|
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { CSSProperties, ReactNode, MouseEventHandler, RefObject } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
-
import { GlyphDirectionalLight, GlyphAmbientLight, GlyphPointerEvent, GlyphMouseEvent, GlyphWheelEvent, GlyphSceneHandle, GlyphMeshTransform, GlyphMeshHandle, GlyphCamera } from 'glyphcss';
|
|
7
|
-
export { GlyphEventHandler, GlyphMeshHandle, GlyphMouseEvent, GlyphPointerEvent, GlyphWheelEvent, injectGlyphBaseStyles } from 'glyphcss';
|
|
6
|
+
import { GlyphDirectionalLight, GlyphAmbientLight, GlyphShadowOptions, GlyphPointerEvent, GlyphMouseEvent, GlyphWheelEvent, GlyphSceneHandle, GlyphMeshTransform, GlyphMeshHandle, GlyphCamera } from 'glyphcss';
|
|
7
|
+
export { GlyphEventHandler, GlyphMeshHandle, GlyphMouseEvent, GlyphPointerEvent, GlyphShadowOptions, GlyphWheelEvent, injectGlyphBaseStyles } from 'glyphcss';
|
|
8
8
|
|
|
9
9
|
interface GlyphSceneProps {
|
|
10
10
|
/** Render mode: "wireframe" | "solid". Default "solid". */
|
|
@@ -27,11 +27,17 @@ interface GlyphSceneProps {
|
|
|
27
27
|
creaseAngle?: number;
|
|
28
28
|
/** Observe host element and adapt cols/rows to fill it. Default false. */
|
|
29
29
|
autoSize?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Shadow-map configuration. `undefined` (default) means no shadows.
|
|
32
|
+
* Set this together with `castShadow`/`receiveShadow` on child `GlyphMesh`
|
|
33
|
+
* components to enable shadow casting.
|
|
34
|
+
*/
|
|
35
|
+
shadow?: GlyphShadowOptions;
|
|
30
36
|
className?: string;
|
|
31
37
|
style?: CSSProperties;
|
|
32
38
|
children?: ReactNode;
|
|
33
39
|
}
|
|
34
|
-
declare function GlyphSceneInner({ mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight, smoothShading, creaseAngle, autoSize, className, style, children, }: GlyphSceneProps): react_jsx_runtime.JSX.Element;
|
|
40
|
+
declare function GlyphSceneInner({ mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight, smoothShading, creaseAngle, autoSize, shadow, className, style, children, }: GlyphSceneProps): react_jsx_runtime.JSX.Element;
|
|
35
41
|
declare const GlyphScene: react.MemoExoticComponent<typeof GlyphSceneInner>;
|
|
36
42
|
|
|
37
43
|
interface GlyphMeshProps {
|
|
@@ -51,6 +57,17 @@ interface GlyphMeshProps {
|
|
|
51
57
|
position?: Vec3;
|
|
52
58
|
scale?: number | Vec3;
|
|
53
59
|
rotation?: Vec3;
|
|
60
|
+
/**
|
|
61
|
+
* This mesh casts shadows onto `receiveShadow` surfaces.
|
|
62
|
+
* Default false — opt-in, matching PolyMesh behaviour.
|
|
63
|
+
*/
|
|
64
|
+
castShadow?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* This mesh receives (displays) shadows from `castShadow` meshes.
|
|
67
|
+
* A mesh that is both `castShadow` and `receiveShadow` will self-shadow.
|
|
68
|
+
* Default false — opt-in, matching PolyMesh behaviour.
|
|
69
|
+
*/
|
|
70
|
+
receiveShadow?: boolean;
|
|
54
71
|
className?: string;
|
|
55
72
|
style?: CSSProperties;
|
|
56
73
|
children?: ReactNode;
|
|
@@ -62,7 +79,7 @@ interface GlyphMeshProps {
|
|
|
62
79
|
onClick?: (event: GlyphMouseEvent) => void;
|
|
63
80
|
onWheel?: (event: GlyphWheelEvent) => void;
|
|
64
81
|
}
|
|
65
|
-
declare function GlyphMeshInner({ id, polygons: polygonsProp, geometry, size, color, position, scale, rotation, className, style, children, }: GlyphMeshProps): react_jsx_runtime.JSX.Element;
|
|
82
|
+
declare function GlyphMeshInner({ id, polygons: polygonsProp, geometry, size, color, position, scale, rotation, castShadow, receiveShadow, className, style, children, }: GlyphMeshProps): react_jsx_runtime.JSX.Element;
|
|
66
83
|
declare const GlyphMesh: react.MemoExoticComponent<typeof GlyphMeshInner>;
|
|
67
84
|
|
|
68
85
|
interface GlyphGroundProps {
|
|
@@ -72,14 +89,24 @@ interface GlyphGroundProps {
|
|
|
72
89
|
color?: string;
|
|
73
90
|
/** World-space position. Default [0, -0.5, 0]. */
|
|
74
91
|
position?: Vec3;
|
|
75
|
-
/** World-space rotation in
|
|
92
|
+
/** World-space rotation in degrees (Euler XYZ). */
|
|
76
93
|
rotation?: Vec3;
|
|
77
94
|
/** String id forwarded to the underlying mesh handle. */
|
|
78
95
|
id?: string;
|
|
96
|
+
/**
|
|
97
|
+
* This ground plane casts shadows onto other `receiveShadow` surfaces.
|
|
98
|
+
* Default false — ground planes typically only receive shadows, matching PolyGround.
|
|
99
|
+
*/
|
|
100
|
+
castShadow?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* This ground plane receives (displays) shadows from `castShadow` meshes.
|
|
103
|
+
* Default true — ground planes are the primary shadow receivers, matching PolyGround.
|
|
104
|
+
*/
|
|
105
|
+
receiveShadow?: boolean;
|
|
79
106
|
className?: string;
|
|
80
107
|
style?: CSSProperties;
|
|
81
108
|
}
|
|
82
|
-
declare function GlyphGroundInner({ size, color, position, rotation, id, className, style, }: GlyphGroundProps): react_jsx_runtime.JSX.Element;
|
|
109
|
+
declare function GlyphGroundInner({ size, color, position, rotation, id, castShadow, receiveShadow, className, style, }: GlyphGroundProps): react_jsx_runtime.JSX.Element;
|
|
83
110
|
declare const GlyphGround: react.MemoExoticComponent<typeof GlyphGroundInner>;
|
|
84
111
|
|
|
85
112
|
interface GlyphHotspotProps {
|
|
@@ -123,7 +150,7 @@ declare function findMeshUnderPoint(clientX: number, clientY: number, filter?: (
|
|
|
123
150
|
interface GlyphOrthographicCameraProps {
|
|
124
151
|
rotX?: number;
|
|
125
152
|
rotY?: number;
|
|
126
|
-
/** Orthographic zoom
|
|
153
|
+
/** Orthographic zoom — absolute px per world unit (zoom=1 → BASE_TILE=50). Default 0.65. */
|
|
127
154
|
zoom?: number;
|
|
128
155
|
/** Center of projection in normalized grid coords. Default [0.5, 0.5]. */
|
|
129
156
|
center?: [number, number];
|
|
@@ -137,9 +164,12 @@ declare const GlyphOrthographicCamera: react.MemoExoticComponent<typeof GlyphOrt
|
|
|
137
164
|
interface GlyphPerspectiveCameraProps {
|
|
138
165
|
rotX?: number;
|
|
139
166
|
rotY?: number;
|
|
140
|
-
/** Perspective distance. Default
|
|
167
|
+
/** Perspective distance (world units). Default 6. */
|
|
141
168
|
distance?: number;
|
|
142
|
-
/**
|
|
169
|
+
/** CSS-perspective distance in virtual pixels (matches voxcss). Larger =
|
|
170
|
+
* flatter. Default 32000. Set 0 to disable (legacy orbit projection). */
|
|
171
|
+
perspective?: number;
|
|
172
|
+
/** Camera zoom — absolute px per world unit (zoom=1 → BASE_TILE=50). Default 0.65. */
|
|
143
173
|
zoom?: number;
|
|
144
174
|
/** Extra horizontal stretch on top of cellAspect. Default 1.0. */
|
|
145
175
|
stretch?: number;
|
|
@@ -149,7 +179,7 @@ interface GlyphPerspectiveCameraProps {
|
|
|
149
179
|
style?: CSSProperties;
|
|
150
180
|
children?: ReactNode;
|
|
151
181
|
}
|
|
152
|
-
declare function GlyphPerspectiveCameraInner({ rotX, rotY, distance, zoom, stretch, center, className, style, children, }: GlyphPerspectiveCameraProps): react_jsx_runtime.JSX.Element;
|
|
182
|
+
declare function GlyphPerspectiveCameraInner({ rotX, rotY, distance, perspective, zoom, stretch, center, className, style, children, }: GlyphPerspectiveCameraProps): react_jsx_runtime.JSX.Element;
|
|
153
183
|
declare const GlyphPerspectiveCamera: react.MemoExoticComponent<typeof GlyphPerspectiveCameraInner>;
|
|
154
184
|
|
|
155
185
|
interface GlyphCameraContextValue {
|
|
@@ -172,6 +202,11 @@ interface GlyphOrbitControlsProps {
|
|
|
172
202
|
wheel?: boolean;
|
|
173
203
|
/** Drag-direction inversion. Default false. */
|
|
174
204
|
invert?: boolean | number;
|
|
205
|
+
/**
|
|
206
|
+
* Clamp vertical drag to ±π/2. Default true. Set false for globe-style
|
|
207
|
+
* unrestricted tumbling past the poles.
|
|
208
|
+
*/
|
|
209
|
+
clampPitch?: boolean;
|
|
175
210
|
/** Auto-rotate config. Default false. */
|
|
176
211
|
animate?: false | {
|
|
177
212
|
speed?: number;
|
|
@@ -179,7 +214,7 @@ interface GlyphOrbitControlsProps {
|
|
|
179
214
|
pauseOnInteraction?: boolean;
|
|
180
215
|
};
|
|
181
216
|
}
|
|
182
|
-
declare function GlyphOrbitControls({ drag, wheel, invert, animate, }: GlyphOrbitControlsProps): null;
|
|
217
|
+
declare function GlyphOrbitControls({ drag, wheel, invert, clampPitch, animate, }: GlyphOrbitControlsProps): null;
|
|
183
218
|
|
|
184
219
|
interface GlyphMapControlsProps {
|
|
185
220
|
drag?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -149,6 +149,7 @@ function GlyphSceneInner({
|
|
|
149
149
|
smoothShading,
|
|
150
150
|
creaseAngle,
|
|
151
151
|
autoSize,
|
|
152
|
+
shadow,
|
|
152
153
|
className,
|
|
153
154
|
style,
|
|
154
155
|
children
|
|
@@ -168,6 +169,7 @@ function GlyphSceneInner({
|
|
|
168
169
|
smoothShading,
|
|
169
170
|
creaseAngle,
|
|
170
171
|
autoSize,
|
|
172
|
+
shadow,
|
|
171
173
|
camera: cameraRef.current ?? void 0
|
|
172
174
|
}), []);
|
|
173
175
|
const hostCallbackRef = useCallback((el) => {
|
|
@@ -199,10 +201,11 @@ function GlyphSceneInner({
|
|
|
199
201
|
if (smoothShading !== void 0) partial.smoothShading = smoothShading;
|
|
200
202
|
if (creaseAngle !== void 0) partial.creaseAngle = creaseAngle;
|
|
201
203
|
if (autoSize !== void 0) partial.autoSize = autoSize;
|
|
204
|
+
partial.shadow = shadow;
|
|
202
205
|
if (Object.keys(partial).length > 0) {
|
|
203
206
|
scene.setOptions(partial);
|
|
204
207
|
}
|
|
205
|
-
}, [mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight, smoothShading, creaseAngle, autoSize]);
|
|
208
|
+
}, [mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight, smoothShading, creaseAngle, autoSize, shadow]);
|
|
206
209
|
const ctxValue = useMemo(() => ({ sceneRef }), [sceneRef]);
|
|
207
210
|
const computedClassName = `glyph-host${className ? ` ${className}` : ""}`;
|
|
208
211
|
return /* @__PURE__ */ jsx(GlyphSceneContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsx("div", { ref: hostCallbackRef, className: computedClassName, style, children }) });
|
|
@@ -262,6 +265,8 @@ function GlyphMeshInner({
|
|
|
262
265
|
position,
|
|
263
266
|
scale,
|
|
264
267
|
rotation,
|
|
268
|
+
castShadow = false,
|
|
269
|
+
receiveShadow = false,
|
|
265
270
|
className,
|
|
266
271
|
style,
|
|
267
272
|
children
|
|
@@ -278,8 +283,10 @@ function GlyphMeshInner({
|
|
|
278
283
|
id,
|
|
279
284
|
position,
|
|
280
285
|
scale,
|
|
281
|
-
rotation
|
|
282
|
-
|
|
286
|
+
rotation,
|
|
287
|
+
castShadow,
|
|
288
|
+
receiveShadow
|
|
289
|
+
}), [id, position, scale, rotation, castShadow, receiveShadow]);
|
|
283
290
|
useEffect2(() => {
|
|
284
291
|
const scene = sceneRef.current;
|
|
285
292
|
if (!scene) return;
|
|
@@ -327,6 +334,8 @@ function GlyphGroundInner({
|
|
|
327
334
|
position = [0, -0.5, 0],
|
|
328
335
|
rotation,
|
|
329
336
|
id,
|
|
337
|
+
castShadow = false,
|
|
338
|
+
receiveShadow = true,
|
|
330
339
|
className,
|
|
331
340
|
style
|
|
332
341
|
}) {
|
|
@@ -346,6 +355,8 @@ function GlyphGroundInner({
|
|
|
346
355
|
polygons,
|
|
347
356
|
position,
|
|
348
357
|
rotation,
|
|
358
|
+
castShadow,
|
|
359
|
+
receiveShadow,
|
|
349
360
|
className,
|
|
350
361
|
style
|
|
351
362
|
}
|
|
@@ -486,6 +497,7 @@ function GlyphPerspectiveCameraInner({
|
|
|
486
497
|
rotX,
|
|
487
498
|
rotY,
|
|
488
499
|
distance,
|
|
500
|
+
perspective,
|
|
489
501
|
zoom,
|
|
490
502
|
stretch,
|
|
491
503
|
center,
|
|
@@ -500,6 +512,7 @@ function GlyphPerspectiveCameraInner({
|
|
|
500
512
|
if (rotX !== void 0) opts.rotX = rotX;
|
|
501
513
|
if (rotY !== void 0) opts.rotY = rotY;
|
|
502
514
|
if (distance !== void 0) opts.distance = distance;
|
|
515
|
+
if (perspective !== void 0) opts.perspective = perspective;
|
|
503
516
|
if (zoom !== void 0) opts.zoom = zoom;
|
|
504
517
|
if (stretch !== void 0) opts.stretch = stretch;
|
|
505
518
|
if (center !== void 0) opts.center = center;
|
|
@@ -521,6 +534,10 @@ function GlyphPerspectiveCameraInner({
|
|
|
521
534
|
camera.distance = distance;
|
|
522
535
|
dirty = true;
|
|
523
536
|
}
|
|
537
|
+
if (perspective !== void 0 && camera.perspective !== perspective) {
|
|
538
|
+
camera.perspective = perspective;
|
|
539
|
+
dirty = true;
|
|
540
|
+
}
|
|
524
541
|
if (zoom !== void 0 && camera.zoom !== zoom) {
|
|
525
542
|
camera.zoom = zoom;
|
|
526
543
|
dirty = true;
|
|
@@ -550,12 +567,13 @@ function GlyphOrbitControls({
|
|
|
550
567
|
drag = true,
|
|
551
568
|
wheel = true,
|
|
552
569
|
invert = false,
|
|
570
|
+
clampPitch = true,
|
|
553
571
|
animate = false
|
|
554
572
|
}) {
|
|
555
573
|
const { sceneRef } = useGlyphSceneContext();
|
|
556
574
|
const controlsRef = useRef8(null);
|
|
557
|
-
const propsRef = useRef8({ drag, wheel, invert, animate });
|
|
558
|
-
propsRef.current = { drag, wheel, invert, animate };
|
|
575
|
+
const propsRef = useRef8({ drag, wheel, invert, clampPitch, animate });
|
|
576
|
+
propsRef.current = { drag, wheel, invert, clampPitch, animate };
|
|
559
577
|
useEffect7(() => {
|
|
560
578
|
const scene = sceneRef.current;
|
|
561
579
|
if (!scene) return;
|
|
@@ -563,6 +581,7 @@ function GlyphOrbitControls({
|
|
|
563
581
|
drag: propsRef.current.drag,
|
|
564
582
|
wheel: propsRef.current.wheel,
|
|
565
583
|
invert: propsRef.current.invert,
|
|
584
|
+
clampPitch: propsRef.current.clampPitch,
|
|
566
585
|
animate: propsRef.current.animate === false ? false : propsRef.current.animate
|
|
567
586
|
};
|
|
568
587
|
const controls = createGlyphOrbitControls(scene, opts);
|
|
@@ -575,7 +594,7 @@ function GlyphOrbitControls({
|
|
|
575
594
|
useEffect7(() => {
|
|
576
595
|
const controls = controlsRef.current;
|
|
577
596
|
if (!controls) return;
|
|
578
|
-
controls.update({ drag, wheel, invert, animate: animate === false ? false : animate });
|
|
597
|
+
controls.update({ drag, wheel, invert, clampPitch, animate: animate === false ? false : animate });
|
|
579
598
|
});
|
|
580
599
|
return null;
|
|
581
600
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glyphcss/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "React components for the glyphcss ASCII polygon mesh rendering engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@glyphcss/core": "^0.0.
|
|
44
|
-
"glyphcss": "^0.0.
|
|
43
|
+
"@glyphcss/core": "^0.0.5",
|
|
44
|
+
"glyphcss": "^0.0.5"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|