@glyphcss/react 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +19 -6
- package/dist/index.d.cts +42 -10
- package/dist/index.d.ts +42 -10
- package/dist/index.js +19 -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
|
}
|
|
@@ -594,12 +605,13 @@ function GlyphOrbitControls({
|
|
|
594
605
|
drag = true,
|
|
595
606
|
wheel = true,
|
|
596
607
|
invert = false,
|
|
608
|
+
clampPitch = true,
|
|
597
609
|
animate = false
|
|
598
610
|
}) {
|
|
599
611
|
const { sceneRef } = useGlyphSceneContext();
|
|
600
612
|
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 };
|
|
613
|
+
const propsRef = (0, import_react11.useRef)({ drag, wheel, invert, clampPitch, animate });
|
|
614
|
+
propsRef.current = { drag, wheel, invert, clampPitch, animate };
|
|
603
615
|
(0, import_react11.useEffect)(() => {
|
|
604
616
|
const scene = sceneRef.current;
|
|
605
617
|
if (!scene) return;
|
|
@@ -607,6 +619,7 @@ function GlyphOrbitControls({
|
|
|
607
619
|
drag: propsRef.current.drag,
|
|
608
620
|
wheel: propsRef.current.wheel,
|
|
609
621
|
invert: propsRef.current.invert,
|
|
622
|
+
clampPitch: propsRef.current.clampPitch,
|
|
610
623
|
animate: propsRef.current.animate === false ? false : propsRef.current.animate
|
|
611
624
|
};
|
|
612
625
|
const controls = (0, import_glyphcss5.createGlyphOrbitControls)(scene, opts);
|
|
@@ -619,7 +632,7 @@ function GlyphOrbitControls({
|
|
|
619
632
|
(0, import_react11.useEffect)(() => {
|
|
620
633
|
const controls = controlsRef.current;
|
|
621
634
|
if (!controls) return;
|
|
622
|
-
controls.update({ drag, wheel, invert, animate: animate === false ? false : animate });
|
|
635
|
+
controls.update({ drag, wheel, invert, clampPitch, animate: animate === false ? false : animate });
|
|
623
636
|
});
|
|
624
637
|
return null;
|
|
625
638
|
}
|
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,9 @@ 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
|
-
/** Camera zoom —
|
|
169
|
+
/** Camera zoom — absolute px per world unit (zoom=1 → BASE_TILE=50). Default 0.65. */
|
|
143
170
|
zoom?: number;
|
|
144
171
|
/** Extra horizontal stretch on top of cellAspect. Default 1.0. */
|
|
145
172
|
stretch?: number;
|
|
@@ -172,6 +199,11 @@ interface GlyphOrbitControlsProps {
|
|
|
172
199
|
wheel?: boolean;
|
|
173
200
|
/** Drag-direction inversion. Default false. */
|
|
174
201
|
invert?: boolean | number;
|
|
202
|
+
/**
|
|
203
|
+
* Clamp vertical drag to ±π/2. Default true. Set false for globe-style
|
|
204
|
+
* unrestricted tumbling past the poles.
|
|
205
|
+
*/
|
|
206
|
+
clampPitch?: boolean;
|
|
175
207
|
/** Auto-rotate config. Default false. */
|
|
176
208
|
animate?: false | {
|
|
177
209
|
speed?: number;
|
|
@@ -179,7 +211,7 @@ interface GlyphOrbitControlsProps {
|
|
|
179
211
|
pauseOnInteraction?: boolean;
|
|
180
212
|
};
|
|
181
213
|
}
|
|
182
|
-
declare function GlyphOrbitControls({ drag, wheel, invert, animate, }: GlyphOrbitControlsProps): null;
|
|
214
|
+
declare function GlyphOrbitControls({ drag, wheel, invert, clampPitch, animate, }: GlyphOrbitControlsProps): null;
|
|
183
215
|
|
|
184
216
|
interface GlyphMapControlsProps {
|
|
185
217
|
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,9 @@ 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
|
-
/** Camera zoom —
|
|
169
|
+
/** Camera zoom — absolute px per world unit (zoom=1 → BASE_TILE=50). Default 0.65. */
|
|
143
170
|
zoom?: number;
|
|
144
171
|
/** Extra horizontal stretch on top of cellAspect. Default 1.0. */
|
|
145
172
|
stretch?: number;
|
|
@@ -172,6 +199,11 @@ interface GlyphOrbitControlsProps {
|
|
|
172
199
|
wheel?: boolean;
|
|
173
200
|
/** Drag-direction inversion. Default false. */
|
|
174
201
|
invert?: boolean | number;
|
|
202
|
+
/**
|
|
203
|
+
* Clamp vertical drag to ±π/2. Default true. Set false for globe-style
|
|
204
|
+
* unrestricted tumbling past the poles.
|
|
205
|
+
*/
|
|
206
|
+
clampPitch?: boolean;
|
|
175
207
|
/** Auto-rotate config. Default false. */
|
|
176
208
|
animate?: false | {
|
|
177
209
|
speed?: number;
|
|
@@ -179,7 +211,7 @@ interface GlyphOrbitControlsProps {
|
|
|
179
211
|
pauseOnInteraction?: boolean;
|
|
180
212
|
};
|
|
181
213
|
}
|
|
182
|
-
declare function GlyphOrbitControls({ drag, wheel, invert, animate, }: GlyphOrbitControlsProps): null;
|
|
214
|
+
declare function GlyphOrbitControls({ drag, wheel, invert, clampPitch, animate, }: GlyphOrbitControlsProps): null;
|
|
183
215
|
|
|
184
216
|
interface GlyphMapControlsProps {
|
|
185
217
|
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
|
}
|
|
@@ -550,12 +561,13 @@ function GlyphOrbitControls({
|
|
|
550
561
|
drag = true,
|
|
551
562
|
wheel = true,
|
|
552
563
|
invert = false,
|
|
564
|
+
clampPitch = true,
|
|
553
565
|
animate = false
|
|
554
566
|
}) {
|
|
555
567
|
const { sceneRef } = useGlyphSceneContext();
|
|
556
568
|
const controlsRef = useRef8(null);
|
|
557
|
-
const propsRef = useRef8({ drag, wheel, invert, animate });
|
|
558
|
-
propsRef.current = { drag, wheel, invert, animate };
|
|
569
|
+
const propsRef = useRef8({ drag, wheel, invert, clampPitch, animate });
|
|
570
|
+
propsRef.current = { drag, wheel, invert, clampPitch, animate };
|
|
559
571
|
useEffect7(() => {
|
|
560
572
|
const scene = sceneRef.current;
|
|
561
573
|
if (!scene) return;
|
|
@@ -563,6 +575,7 @@ function GlyphOrbitControls({
|
|
|
563
575
|
drag: propsRef.current.drag,
|
|
564
576
|
wheel: propsRef.current.wheel,
|
|
565
577
|
invert: propsRef.current.invert,
|
|
578
|
+
clampPitch: propsRef.current.clampPitch,
|
|
566
579
|
animate: propsRef.current.animate === false ? false : propsRef.current.animate
|
|
567
580
|
};
|
|
568
581
|
const controls = createGlyphOrbitControls(scene, opts);
|
|
@@ -575,7 +588,7 @@ function GlyphOrbitControls({
|
|
|
575
588
|
useEffect7(() => {
|
|
576
589
|
const controls = controlsRef.current;
|
|
577
590
|
if (!controls) return;
|
|
578
|
-
controls.update({ drag, wheel, invert, animate: animate === false ? false : animate });
|
|
591
|
+
controls.update({ drag, wheel, invert, clampPitch, animate: animate === false ? false : animate });
|
|
579
592
|
});
|
|
580
593
|
return null;
|
|
581
594
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glyphcss/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
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.4",
|
|
44
|
+
"glyphcss": "^0.0.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|