@glyphcss/react 0.0.1 → 0.0.2

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 CHANGED
@@ -20,99 +20,168 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- BASE_TILE: () => import_core2.BASE_TILE,
24
- CAMERA_BACKFACE_CULL_EPS: () => import_core2.CAMERA_BACKFACE_CULL_EPS,
25
- DEFAULT_CAMERA_STATE: () => import_core2.DEFAULT_CAMERA_STATE,
26
- DEFAULT_PROJECTION: () => import_core2.DEFAULT_PROJECTION,
27
- GlyphcssAxesHelper: () => GlyphcssAxesHelper,
28
- GlyphcssCamera: () => GlyphcssPerspectiveCamera,
29
- GlyphcssCameraContext: () => GlyphcssCameraContext,
30
- GlyphcssDirectionalLightHelper: () => GlyphcssDirectionalLightHelper,
31
- GlyphcssFirstPersonControls: () => GlyphcssFirstPersonControls,
32
- GlyphcssHotspot: () => GlyphcssHotspot,
33
- GlyphcssMapControls: () => GlyphcssMapControls,
34
- GlyphcssMesh: () => GlyphcssMesh,
35
- GlyphcssOrbitControls: () => GlyphcssOrbitControls,
36
- GlyphcssOrthographicCamera: () => GlyphcssOrthographicCamera,
37
- GlyphcssPerspectiveCamera: () => GlyphcssPerspectiveCamera,
38
- GlyphcssScene: () => GlyphcssScene,
39
- GlyphcssSceneContext: () => GlyphcssSceneContext,
40
- LoopOnce: () => import_core2.LoopOnce,
41
- LoopPingPong: () => import_core2.LoopPingPong,
42
- LoopRepeat: () => import_core2.LoopRepeat,
43
- VOXEL_CAMERA_CULL_AXIS_EPS: () => import_core2.VOXEL_CAMERA_CULL_AXIS_EPS,
44
- VOXEL_CAMERA_CULL_NORMAL_LIMIT: () => import_core2.VOXEL_CAMERA_CULL_NORMAL_LIMIT,
45
- arrowPolygons: () => import_core2.arrowPolygons,
46
- axesHelperPolygons: () => import_core2.axesHelperPolygons,
47
- bakeSolidTextureSampledPolygons: () => import_core2.bakeSolidTextureSampledPolygons,
48
- bakeSolidTextureSamples: () => import_core2.bakeSolidTextureSamples,
49
- buildSceneContext: () => import_core2.buildSceneContext,
50
- cameraCullNormalGroups: () => import_core2.cameraCullNormalGroups,
51
- cameraCullNormalGroupsFromPolygons: () => import_core2.cameraCullNormalGroupsFromPolygons,
52
- cameraCullNormalKey: () => import_core2.cameraCullNormalKey,
53
- cameraCullVisibleSignature: () => import_core2.cameraCullVisibleSignature,
54
- cameraFacingDepth: () => import_core2.cameraFacingDepth,
55
- clampChannel: () => import_core2.clampChannel,
56
- computeSceneBbox: () => import_core2.computeSceneBbox,
57
- computeShapeLighting: () => import_core2.computeShapeLighting,
58
- coverPlanarPolygons: () => import_core2.coverPlanarPolygons,
59
- createGlyphcssAnimationMixer: () => import_core2.createGlyphcssAnimationMixer,
60
- createIsometricCamera: () => import_core2.createIsometricCamera,
61
- cullInteriorPolygons: () => import_core2.cullInteriorPolygons,
62
- findGlyphcssMeshHandle: () => findGlyphcssMeshHandle,
63
- formatColor: () => import_core2.formatColor,
64
- injectGlyphcssBaseStyles: () => import_glyphcss8.injectGlyphcssBaseStyles,
65
- inverseRotateVec3: () => import_core2.inverseRotateVec3,
66
- isAxisAlignedSurfaceNormal: () => import_core2.isAxisAlignedSurfaceNormal,
67
- isVoxelCameraCullableNormalGroups: () => import_core2.isVoxelCameraCullableNormalGroups,
68
- loadMesh: () => import_core2.loadMesh,
69
- mergePolygons: () => import_core2.mergePolygons,
70
- normalFacesCamera: () => import_core2.normalFacesCamera,
71
- normalizeInvertMultiplier: () => import_core2.normalizeInvertMultiplier,
72
- normalizePolygons: () => import_core2.normalizePolygons,
73
- octahedronPolygons: () => import_core2.octahedronPolygons,
74
- optimizeMeshPolygons: () => import_core2.optimizeMeshPolygons,
75
- parseColor: () => import_core2.parseColor,
76
- parseGltf: () => import_core2.parseGltf,
77
- parseHexColor: () => import_core2.parseHexColor,
78
- parseMtl: () => import_core2.parseMtl,
79
- parseObj: () => import_core2.parseObj,
80
- parsePureColor: () => import_core2.parsePureColor,
81
- parseRgbColor: () => import_core2.parseRgbColor,
82
- parseVox: () => import_core2.parseVox,
83
- polygonCssSurfaceNormal: () => import_core2.polygonCssSurfaceNormal,
84
- polygonFaces: () => import_core2.polygonFaces,
85
- polygonFacesCamera: () => import_core2.polygonFacesCamera,
86
- ringPolygons: () => import_core2.ringPolygons,
87
- rotateVec3: () => import_core2.rotateVec3,
88
- shadeColor: () => import_core2.shadeColor,
89
- useGlyphcssAnimation: () => useGlyphcssAnimation,
90
- useGlyphcssCamera: () => useGlyphcssCamera,
91
- useGlyphcssMesh: () => useGlyphcssMesh,
92
- useGlyphcssSceneContext: () => useGlyphcssSceneContext
23
+ BASE_TILE: () => import_core4.BASE_TILE,
24
+ CAMERA_BACKFACE_CULL_EPS: () => import_core4.CAMERA_BACKFACE_CULL_EPS,
25
+ DEFAULT_CAMERA_STATE: () => import_core4.DEFAULT_CAMERA_STATE,
26
+ DEFAULT_PROJECTION: () => import_core4.DEFAULT_PROJECTION,
27
+ GlyphAxesHelper: () => GlyphAxesHelper,
28
+ GlyphCamera: () => GlyphOrthographicCamera,
29
+ GlyphCameraContext: () => GlyphCameraContext,
30
+ GlyphDirectionalLightHelper: () => GlyphDirectionalLightHelper,
31
+ GlyphFirstPersonControls: () => GlyphFirstPersonControls,
32
+ GlyphGround: () => GlyphGround,
33
+ GlyphHotspot: () => GlyphHotspot,
34
+ GlyphMapControls: () => GlyphMapControls,
35
+ GlyphMesh: () => GlyphMesh,
36
+ GlyphOrbitControls: () => GlyphOrbitControls,
37
+ GlyphOrthographicCamera: () => GlyphOrthographicCamera,
38
+ GlyphPerspectiveCamera: () => GlyphPerspectiveCamera,
39
+ GlyphScene: () => GlyphScene,
40
+ GlyphSceneContext: () => GlyphSceneContext,
41
+ LoopOnce: () => import_core4.LoopOnce,
42
+ LoopPingPong: () => import_core4.LoopPingPong,
43
+ LoopRepeat: () => import_core4.LoopRepeat,
44
+ VOXEL_CAMERA_CULL_AXIS_EPS: () => import_core4.VOXEL_CAMERA_CULL_AXIS_EPS,
45
+ VOXEL_CAMERA_CULL_NORMAL_LIMIT: () => import_core4.VOXEL_CAMERA_CULL_NORMAL_LIMIT,
46
+ antiprismPolygons: () => import_core4.antiprismPolygons,
47
+ arrowPolygons: () => import_core4.arrowPolygons,
48
+ axesHelperPolygons: () => import_core4.axesHelperPolygons,
49
+ bakeSolidTextureSampledPolygons: () => import_core4.bakeSolidTextureSampledPolygons,
50
+ bakeSolidTextureSamples: () => import_core4.bakeSolidTextureSamples,
51
+ bipyramidPolygons: () => import_core4.bipyramidPolygons,
52
+ buildSceneContext: () => import_core4.buildSceneContext,
53
+ cameraCullNormalGroups: () => import_core4.cameraCullNormalGroups,
54
+ cameraCullNormalGroupsFromPolygons: () => import_core4.cameraCullNormalGroupsFromPolygons,
55
+ cameraCullNormalKey: () => import_core4.cameraCullNormalKey,
56
+ cameraCullVisibleSignature: () => import_core4.cameraCullVisibleSignature,
57
+ cameraFacingDepth: () => import_core4.cameraFacingDepth,
58
+ clampChannel: () => import_core4.clampChannel,
59
+ computeSceneBbox: () => import_core4.computeSceneBbox,
60
+ computeShapeLighting: () => import_core4.computeShapeLighting,
61
+ conePolygons: () => import_core4.conePolygons,
62
+ coverPlanarPolygons: () => import_core4.coverPlanarPolygons,
63
+ createGlyphAnimationMixer: () => import_core4.createGlyphAnimationMixer,
64
+ createIsometricCamera: () => import_core4.createIsometricCamera,
65
+ cubePolygons: () => import_core4.cubePolygons,
66
+ cuboctahedronPolygons: () => import_core4.cuboctahedronPolygons,
67
+ cullInteriorPolygons: () => import_core4.cullInteriorPolygons,
68
+ cylinderPolygons: () => import_core4.cylinderPolygons,
69
+ deltoidalHexecontahedronPolygons: () => import_core4.deltoidalHexecontahedronPolygons,
70
+ deltoidalIcositetrahedronPolygons: () => import_core4.deltoidalIcositetrahedronPolygons,
71
+ disdyakisDodecahedronPolygons: () => import_core4.disdyakisDodecahedronPolygons,
72
+ disdyakisTriacontahedronPolygons: () => import_core4.disdyakisTriacontahedronPolygons,
73
+ dodecahedronPolygons: () => import_core4.dodecahedronPolygons,
74
+ findGlyphMeshHandle: () => findGlyphMeshHandle,
75
+ findMeshUnderPoint: () => findMeshUnderPoint,
76
+ formatColor: () => import_core4.formatColor,
77
+ greatDodecahedronPolygons: () => import_core4.greatDodecahedronPolygons,
78
+ greatIcosahedronPolygons: () => import_core4.greatIcosahedronPolygons,
79
+ greatStellatedDodecahedronPolygons: () => import_core4.greatStellatedDodecahedronPolygons,
80
+ icosahedronPolygons: () => import_core4.icosahedronPolygons,
81
+ icosidodecahedronPolygons: () => import_core4.icosidodecahedronPolygons,
82
+ injectGlyphBaseStyles: () => import_glyphcss8.injectGlyphBaseStyles,
83
+ inverseRotateVec3: () => import_core4.inverseRotateVec3,
84
+ isAxisAlignedSurfaceNormal: () => import_core4.isAxisAlignedSurfaceNormal,
85
+ isVoxelCameraCullableNormalGroups: () => import_core4.isVoxelCameraCullableNormalGroups,
86
+ loadMesh: () => import_core4.loadMesh,
87
+ mergePolygons: () => import_core4.mergePolygons,
88
+ normalFacesCamera: () => import_core4.normalFacesCamera,
89
+ normalizeInvertMultiplier: () => import_core4.normalizeInvertMultiplier,
90
+ normalizePolygons: () => import_core4.normalizePolygons,
91
+ octahedronPolygons: () => import_core4.octahedronPolygons,
92
+ optimizeMeshPolygons: () => import_core4.optimizeMeshPolygons,
93
+ parseColor: () => import_core4.parseColor,
94
+ parseGltf: () => import_core4.parseGltf,
95
+ parseHexColor: () => import_core4.parseHexColor,
96
+ parseMtl: () => import_core4.parseMtl,
97
+ parseObj: () => import_core4.parseObj,
98
+ parsePureColor: () => import_core4.parsePureColor,
99
+ parseRgbColor: () => import_core4.parseRgbColor,
100
+ parseVox: () => import_core4.parseVox,
101
+ pentagonalHexecontahedronPolygons: () => import_core4.pentagonalHexecontahedronPolygons,
102
+ pentagonalIcositetrahedronPolygons: () => import_core4.pentagonalIcositetrahedronPolygons,
103
+ pentakisDodecahedronPolygons: () => import_core4.pentakisDodecahedronPolygons,
104
+ planePolygons: () => import_core4.planePolygons,
105
+ pointInMeshElement: () => pointInMeshElement,
106
+ polygonCssSurfaceNormal: () => import_core4.polygonCssSurfaceNormal,
107
+ polygonFaces: () => import_core4.polygonFaces,
108
+ polygonFacesCamera: () => import_core4.polygonFacesCamera,
109
+ prismPolygons: () => import_core4.prismPolygons,
110
+ pyramidPolygons: () => import_core4.pyramidPolygons,
111
+ resolveGeometry: () => import_core4.resolveGeometry,
112
+ rhombicDodecahedronPolygons: () => import_core4.rhombicDodecahedronPolygons,
113
+ rhombicTriacontahedronPolygons: () => import_core4.rhombicTriacontahedronPolygons,
114
+ rhombicosidodecahedronPolygons: () => import_core4.rhombicosidodecahedronPolygons,
115
+ rhombicuboctahedronPolygons: () => import_core4.rhombicuboctahedronPolygons,
116
+ ringPolygons: () => import_core4.ringPolygons,
117
+ ringQuadPolygons: () => import_core4.ringQuadPolygons,
118
+ rotateVec3: () => import_core4.rotateVec3,
119
+ shadeColor: () => import_core4.shadeColor,
120
+ smallStellatedDodecahedronPolygons: () => import_core4.smallStellatedDodecahedronPolygons,
121
+ snubCubePolygons: () => import_core4.snubCubePolygons,
122
+ snubDodecahedronPolygons: () => import_core4.snubDodecahedronPolygons,
123
+ spherePolygons: () => import_core4.spherePolygons,
124
+ tetrahedronPolygons: () => import_core4.tetrahedronPolygons,
125
+ tetrakisHexahedronPolygons: () => import_core4.tetrakisHexahedronPolygons,
126
+ torusPolygons: () => import_core4.torusPolygons,
127
+ trapezohedronPolygons: () => import_core4.trapezohedronPolygons,
128
+ triakisIcosahedronPolygons: () => import_core4.triakisIcosahedronPolygons,
129
+ triakisOctahedronPolygons: () => import_core4.triakisOctahedronPolygons,
130
+ triakisTetrahedronPolygons: () => import_core4.triakisTetrahedronPolygons,
131
+ truncatedCubePolygons: () => import_core4.truncatedCubePolygons,
132
+ truncatedCuboctahedronPolygons: () => import_core4.truncatedCuboctahedronPolygons,
133
+ truncatedDodecahedronPolygons: () => import_core4.truncatedDodecahedronPolygons,
134
+ truncatedIcosahedronPolygons: () => import_core4.truncatedIcosahedronPolygons,
135
+ truncatedIcosidodecahedronPolygons: () => import_core4.truncatedIcosidodecahedronPolygons,
136
+ truncatedOctahedronPolygons: () => import_core4.truncatedOctahedronPolygons,
137
+ truncatedTetrahedronPolygons: () => import_core4.truncatedTetrahedronPolygons,
138
+ useGlyphAnimation: () => useGlyphAnimation,
139
+ useGlyphCamera: () => useGlyphCamera,
140
+ useGlyphMesh: () => useGlyphMesh,
141
+ useGlyphSceneContext: () => useGlyphSceneContext
93
142
  });
94
143
  module.exports = __toCommonJS(src_exports);
95
- var import_core2 = require("@glyphcss/core");
144
+ var import_core4 = require("@glyphcss/core");
96
145
 
97
- // src/glyphcss/scene/GlyphcssScene.tsx
98
- var import_react2 = require("react");
146
+ // src/glyphcss/scene/GlyphScene.tsx
147
+ var import_react3 = require("react");
99
148
  var import_glyphcss = require("glyphcss");
100
149
 
101
- // src/glyphcss/scene/context.ts
150
+ // src/glyphcss/camera/context.ts
102
151
  var import_react = require("react");
103
- var GlyphcssSceneContext = (0, import_react.createContext)(null);
104
- function useGlyphcssSceneContext() {
105
- const ctx = (0, import_react.useContext)(GlyphcssSceneContext);
152
+ var GlyphCameraContext = (0, import_react.createContext)(null);
153
+ function useGlyphCamera() {
154
+ const ctx = (0, import_react.useContext)(GlyphCameraContext);
155
+ if (!ctx) {
156
+ throw new Error("glyphcss: camera hook must be used inside a GlyphCamera.");
157
+ }
158
+ return ctx;
159
+ }
160
+ function useGlyphCameraContext() {
161
+ const ctx = (0, import_react.useContext)(GlyphCameraContext);
162
+ if (!ctx) {
163
+ throw new Error(
164
+ "glyphcss: GlyphScene must be placed inside a GlyphPerspectiveCamera or GlyphOrthographicCamera."
165
+ );
166
+ }
167
+ return ctx;
168
+ }
169
+
170
+ // src/glyphcss/scene/context.ts
171
+ var import_react2 = require("react");
172
+ var GlyphSceneContext = (0, import_react2.createContext)(null);
173
+ function useGlyphSceneContext() {
174
+ const ctx = (0, import_react2.useContext)(GlyphSceneContext);
106
175
  if (!ctx) {
107
- throw new Error("glyphcss: GlyphcssMesh must be used inside a GlyphcssScene.");
176
+ throw new Error("glyphcss: component must be used inside a GlyphScene.");
108
177
  }
109
178
  return ctx;
110
179
  }
111
- var GlyphcssMeshContext = (0, import_react.createContext)(null);
180
+ var GlyphMeshContext = (0, import_react2.createContext)(null);
112
181
 
113
- // src/glyphcss/scene/GlyphcssScene.tsx
182
+ // src/glyphcss/scene/GlyphScene.tsx
114
183
  var import_jsx_runtime = require("react/jsx-runtime");
115
- function GlyphcssSceneInner({
184
+ function GlyphSceneInner({
116
185
  mode,
117
186
  glyphPalette,
118
187
  useColors,
@@ -121,13 +190,17 @@ function GlyphcssSceneInner({
121
190
  cellAspect,
122
191
  directionalLight,
123
192
  ambientLight,
193
+ smoothShading,
194
+ creaseAngle,
195
+ autoSize,
124
196
  className,
125
197
  style,
126
198
  children
127
199
  }) {
128
- const hostRef = (0, import_react2.useRef)(null);
129
- const sceneRef = (0, import_react2.useRef)(null);
130
- const initialOpts = (0, import_react2.useMemo)(() => ({
200
+ const { cameraRef, sceneRerenderRef } = useGlyphCameraContext();
201
+ const hostRef = (0, import_react3.useRef)(null);
202
+ const sceneRef = (0, import_react3.useRef)(null);
203
+ const initialOpts = (0, import_react3.useMemo)(() => ({
131
204
  mode,
132
205
  glyphPalette,
133
206
  useColors,
@@ -135,20 +208,27 @@ function GlyphcssSceneInner({
135
208
  rows,
136
209
  cellAspect,
137
210
  directionalLight,
138
- ambientLight
211
+ ambientLight,
212
+ smoothShading,
213
+ creaseAngle,
214
+ autoSize,
215
+ camera: cameraRef.current ?? void 0
139
216
  }), []);
140
- const hostCallbackRef = (0, import_react2.useCallback)((el) => {
217
+ const hostCallbackRef = (0, import_react3.useCallback)((el) => {
141
218
  if (el && !sceneRef.current) {
142
219
  hostRef.current = el;
143
- (0, import_glyphcss.injectGlyphcssBaseStyles)(el.ownerDocument ?? void 0);
144
- sceneRef.current = (0, import_glyphcss.createGlyphcssScene)(el, initialOpts);
220
+ (0, import_glyphcss.injectGlyphBaseStyles)(el.ownerDocument ?? void 0);
221
+ const camera = cameraRef.current ?? void 0;
222
+ sceneRef.current = (0, import_glyphcss.createGlyphScene)(el, { ...initialOpts, camera });
223
+ sceneRerenderRef.current = () => sceneRef.current?.rerender();
145
224
  } else if (!el && sceneRef.current) {
146
225
  sceneRef.current.destroy();
147
226
  sceneRef.current = null;
227
+ sceneRerenderRef.current = null;
148
228
  hostRef.current = null;
149
229
  }
150
- }, [initialOpts]);
151
- (0, import_react2.useEffect)(() => {
230
+ }, [initialOpts, cameraRef, sceneRerenderRef]);
231
+ (0, import_react3.useEffect)(() => {
152
232
  const scene = sceneRef.current;
153
233
  if (!scene) return;
154
234
  const partial = {};
@@ -160,18 +240,22 @@ function GlyphcssSceneInner({
160
240
  if (cellAspect !== void 0) partial.cellAspect = cellAspect;
161
241
  if (directionalLight !== void 0) partial.directionalLight = directionalLight;
162
242
  if (ambientLight !== void 0) partial.ambientLight = ambientLight;
243
+ if (smoothShading !== void 0) partial.smoothShading = smoothShading;
244
+ if (creaseAngle !== void 0) partial.creaseAngle = creaseAngle;
245
+ if (autoSize !== void 0) partial.autoSize = autoSize;
163
246
  if (Object.keys(partial).length > 0) {
164
247
  scene.setOptions(partial);
165
248
  }
166
- }, [mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight]);
167
- const ctxValue = (0, import_react2.useMemo)(() => ({ sceneRef }), [sceneRef]);
168
- const computedClassName = `glyphcss-host${className ? ` ${className}` : ""}`;
169
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlyphcssSceneContext.Provider, { value: ctxValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: hostCallbackRef, className: computedClassName, style, children }) });
249
+ }, [mode, glyphPalette, useColors, cols, rows, cellAspect, directionalLight, ambientLight, smoothShading, creaseAngle, autoSize]);
250
+ const ctxValue = (0, import_react3.useMemo)(() => ({ sceneRef }), [sceneRef]);
251
+ const computedClassName = `glyph-host${className ? ` ${className}` : ""}`;
252
+ 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 }) });
170
253
  }
171
- var GlyphcssScene = (0, import_react2.memo)(GlyphcssSceneInner);
254
+ var GlyphScene = (0, import_react3.memo)(GlyphSceneInner);
172
255
 
173
- // src/glyphcss/scene/GlyphcssMesh.tsx
174
- var import_react3 = require("react");
256
+ // src/glyphcss/scene/GlyphMesh.tsx
257
+ var import_react4 = require("react");
258
+ var import_core = require("@glyphcss/core");
175
259
 
176
260
  // src/glyphcss/scene/events.ts
177
261
  var MESH_REGISTRY = /* @__PURE__ */ new WeakMap();
@@ -181,7 +265,7 @@ function registerMeshElement(el, handle) {
181
265
  function unregisterMeshElement(el) {
182
266
  MESH_REGISTRY.delete(el);
183
267
  }
184
- function findGlyphcssMeshHandle(el) {
268
+ function findGlyphMeshHandle(el) {
185
269
  let cur = el;
186
270
  while (cur) {
187
271
  if (cur instanceof HTMLElement) {
@@ -192,12 +276,33 @@ function findGlyphcssMeshHandle(el) {
192
276
  }
193
277
  return null;
194
278
  }
279
+ function pointInMeshElement(meshEl, clientX, clientY) {
280
+ const r = meshEl.getBoundingClientRect();
281
+ if (r.width <= 0 || r.height <= 0) return false;
282
+ return clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom;
283
+ }
284
+ function findMeshUnderPoint(clientX, clientY, filter) {
285
+ if (typeof document === "undefined") return null;
286
+ const meshEls = Array.from(
287
+ document.querySelectorAll(".glyph-mesh")
288
+ );
289
+ for (const meshEl of meshEls) {
290
+ if (filter && !filter(meshEl)) continue;
291
+ const handle = findGlyphMeshHandle(meshEl);
292
+ if (!handle) continue;
293
+ if (pointInMeshElement(meshEl, clientX, clientY)) return handle;
294
+ }
295
+ return null;
296
+ }
195
297
 
196
- // src/glyphcss/scene/GlyphcssMesh.tsx
298
+ // src/glyphcss/scene/GlyphMesh.tsx
197
299
  var import_jsx_runtime2 = require("react/jsx-runtime");
198
- function GlyphcssMeshInner({
300
+ function GlyphMeshInner({
199
301
  id,
200
- triangles: trianglesProp,
302
+ polygons: polygonsProp,
303
+ geometry,
304
+ size = 1,
305
+ color,
201
306
  position,
202
307
  scale,
203
308
  rotation,
@@ -205,56 +310,97 @@ function GlyphcssMeshInner({
205
310
  style,
206
311
  children
207
312
  }) {
208
- const { sceneRef } = useGlyphcssSceneContext();
209
- const meshRef = (0, import_react3.useRef)(null);
210
- const wrapperRef = (0, import_react3.useRef)(null);
211
- const triangles = (0, import_react3.useMemo)(() => trianglesProp ?? [], [trianglesProp]);
212
- const transform = (0, import_react3.useMemo)(() => ({
313
+ const { sceneRef } = useGlyphSceneContext();
314
+ const meshRef = (0, import_react4.useRef)(null);
315
+ const wrapperRef = (0, import_react4.useRef)(null);
316
+ const polygons = (0, import_react4.useMemo)(() => {
317
+ if (polygonsProp !== void 0) return polygonsProp;
318
+ if (geometry !== void 0) return (0, import_core.resolveGeometry)(geometry, { size, color });
319
+ return [];
320
+ }, [polygonsProp, geometry, size, color]);
321
+ const transform = (0, import_react4.useMemo)(() => ({
322
+ id,
213
323
  position,
214
324
  scale,
215
325
  rotation
216
- }), [position, scale, rotation]);
217
- (0, import_react3.useEffect)(() => {
326
+ }), [id, position, scale, rotation]);
327
+ (0, import_react4.useEffect)(() => {
218
328
  const scene = sceneRef.current;
219
329
  if (!scene) return;
220
- const handle = scene.add(triangles, transform);
330
+ const handle = scene.add(polygons, transform);
221
331
  meshRef.current = handle;
222
332
  return () => {
223
333
  handle.dispose();
224
334
  meshRef.current = null;
225
335
  };
226
- }, [sceneRef, triangles]);
227
- (0, import_react3.useEffect)(() => {
336
+ }, [sceneRef, polygons]);
337
+ (0, import_react4.useEffect)(() => {
228
338
  const mesh = meshRef.current;
229
339
  if (!mesh) return;
230
340
  mesh.setTransform(transform);
231
341
  sceneRef.current?.rerender();
232
342
  }, [sceneRef, transform]);
233
- (0, import_react3.useEffect)(() => {
343
+ (0, import_react4.useEffect)(() => {
234
344
  const el = wrapperRef.current;
235
345
  const handle = meshRef.current;
236
346
  if (!el || !handle) return;
237
347
  registerMeshElement(el, handle);
238
348
  return () => unregisterMeshElement(el);
239
349
  });
240
- const computedClassName = `glyphcss-mesh${className ? ` ${className}` : ""}`;
350
+ const computedClassName = `glyph-mesh${className ? ` ${className}` : ""}`;
241
351
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
242
352
  "div",
243
353
  {
244
354
  ref: wrapperRef,
245
- "data-glyphcss-mesh-id": id,
355
+ "data-glyph-mesh-id": id,
246
356
  className: computedClassName,
247
357
  style,
248
358
  children
249
359
  }
250
360
  );
251
361
  }
252
- var GlyphcssMesh = (0, import_react3.memo)(GlyphcssMeshInner);
362
+ var GlyphMesh = (0, import_react4.memo)(GlyphMeshInner);
253
363
 
254
- // src/glyphcss/scene/GlyphcssHotspot.tsx
255
- var import_react4 = require("react");
364
+ // src/glyphcss/scene/GlyphGround.tsx
365
+ var import_react5 = require("react");
366
+ var import_core2 = require("@glyphcss/core");
256
367
  var import_jsx_runtime3 = require("react/jsx-runtime");
257
- function GlyphcssHotspotInner({
368
+ function GlyphGroundInner({
369
+ size = 5,
370
+ color = "#444444",
371
+ position = [0, -0.5, 0],
372
+ rotation,
373
+ id,
374
+ className,
375
+ style
376
+ }) {
377
+ const polygons = (0, import_react5.useMemo)(
378
+ () => (0, import_core2.planePolygons)({
379
+ axis: 1,
380
+ size,
381
+ offset: 0,
382
+ color
383
+ }),
384
+ [size, color]
385
+ );
386
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
387
+ GlyphMesh,
388
+ {
389
+ id,
390
+ polygons,
391
+ position,
392
+ rotation,
393
+ className,
394
+ style
395
+ }
396
+ );
397
+ }
398
+ var GlyphGround = (0, import_react5.memo)(GlyphGroundInner);
399
+
400
+ // src/glyphcss/scene/GlyphHotspot.tsx
401
+ var import_react6 = require("react");
402
+ var import_react_dom = require("react-dom");
403
+ function GlyphHotspotInner({
258
404
  id,
259
405
  at,
260
406
  size,
@@ -262,57 +408,61 @@ function GlyphcssHotspotInner({
262
408
  className,
263
409
  children
264
410
  }) {
265
- const { sceneRef } = useGlyphcssSceneContext();
266
- const hotspotRef = (0, import_react4.useRef)(null);
267
- const onClickRef = (0, import_react4.useRef)(onClick);
411
+ const { sceneRef } = useGlyphSceneContext();
412
+ const hotspotRef = (0, import_react6.useRef)(null);
413
+ const onClickRef = (0, import_react6.useRef)(onClick);
268
414
  onClickRef.current = onClick;
269
- const atKey = (0, import_react4.useMemo)(() => at.join(","), [at]);
415
+ const [overlayEl, setOverlayEl] = (0, import_react6.useState)(null);
416
+ const atKey = (0, import_react6.useMemo)(() => at.join(","), [at]);
270
417
  const sizeKey = size ? size.join(",") : "";
271
- (0, import_react4.useEffect)(() => {
418
+ (0, import_react6.useEffect)(() => {
272
419
  const scene = sceneRef.current;
273
420
  if (!scene) return;
274
421
  const handle = scene.addHotspot(
275
422
  { id, at, size },
276
- () => {
277
- }
423
+ () => onClickRef.current?.({})
278
424
  );
279
425
  hotspotRef.current = handle;
426
+ setOverlayEl(handle.el);
280
427
  return () => {
281
428
  handle.remove();
282
429
  hotspotRef.current = null;
430
+ setOverlayEl(null);
283
431
  };
284
432
  }, [sceneRef, id, atKey, sizeKey]);
285
- if (!children && !onClick && !className) return null;
286
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
287
- "div",
288
- {
289
- "data-glyphcss-hotspot-id": id,
290
- className,
291
- style: { display: "contents" },
292
- onClick,
293
- children
294
- }
295
- );
433
+ (0, import_react6.useEffect)(() => {
434
+ const el = overlayEl;
435
+ if (!el || !onClick) return;
436
+ const handler = (e) => onClick(e);
437
+ el.addEventListener("click", handler);
438
+ return () => el.removeEventListener("click", handler);
439
+ }, [overlayEl, onClick]);
440
+ (0, import_react6.useEffect)(() => {
441
+ if (!overlayEl) return;
442
+ overlayEl.className = `glyph-hotspot${className ? ` ${className}` : ""}`;
443
+ }, [overlayEl, className]);
444
+ if (!children || !overlayEl) return null;
445
+ return (0, import_react_dom.createPortal)(children, overlayEl);
296
446
  }
297
- var GlyphcssHotspot = (0, import_react4.memo)(GlyphcssHotspotInner);
447
+ var GlyphHotspot = (0, import_react6.memo)(GlyphHotspotInner);
298
448
 
299
- // src/glyphcss/scene/useGlyphcssMesh.ts
300
- var import_react5 = require("react");
301
- function useGlyphcssMesh(triangles, options) {
302
- const { sceneRef } = useGlyphcssSceneContext();
303
- const meshRef = (0, import_react5.useRef)(null);
304
- const [loading] = (0, import_react5.useState)(false);
305
- (0, import_react5.useEffect)(() => {
449
+ // src/glyphcss/scene/useGlyphMesh.ts
450
+ var import_react7 = require("react");
451
+ function useGlyphMesh(polygons, options) {
452
+ const { sceneRef } = useGlyphSceneContext();
453
+ const meshRef = (0, import_react7.useRef)(null);
454
+ const [loading] = (0, import_react7.useState)(false);
455
+ (0, import_react7.useEffect)(() => {
306
456
  const scene = sceneRef.current;
307
457
  if (!scene) return;
308
- const handle = scene.add(triangles, options?.transform);
458
+ const handle = scene.add(polygons, options?.transform);
309
459
  meshRef.current = handle;
310
460
  return () => {
311
461
  handle.dispose();
312
462
  meshRef.current = null;
313
463
  };
314
- }, [sceneRef, triangles]);
315
- (0, import_react5.useEffect)(() => {
464
+ }, [sceneRef, polygons]);
465
+ (0, import_react7.useEffect)(() => {
316
466
  const mesh = meshRef.current;
317
467
  if (!mesh) return;
318
468
  if (options?.transform) {
@@ -323,51 +473,30 @@ function useGlyphcssMesh(triangles, options) {
323
473
  return { meshRef, loading };
324
474
  }
325
475
 
326
- // src/glyphcss/camera/GlyphcssPerspectiveCamera.tsx
327
- var import_react7 = require("react");
476
+ // src/glyphcss/camera/GlyphOrthographicCamera.tsx
477
+ var import_react8 = require("react");
328
478
  var import_glyphcss2 = require("glyphcss");
329
-
330
- // src/glyphcss/camera/context.ts
331
- var import_react6 = require("react");
332
- var GlyphcssCameraContext = (0, import_react6.createContext)(null);
333
- function useGlyphcssCamera() {
334
- const ctx = (0, import_react6.useContext)(GlyphcssCameraContext);
335
- if (!ctx) {
336
- throw new Error("glyphcss: camera hook must be used inside a GlyphcssCamera.");
337
- }
338
- return ctx;
339
- }
340
-
341
- // src/glyphcss/camera/GlyphcssPerspectiveCamera.tsx
342
479
  var import_jsx_runtime4 = require("react/jsx-runtime");
343
- function GlyphcssPerspectiveCameraInner({
480
+ function GlyphOrthographicCameraInner({
344
481
  rotX,
345
482
  rotY,
346
- distance,
347
- scale,
348
- stretch,
483
+ zoom,
349
484
  center,
485
+ className,
486
+ style,
350
487
  children
351
488
  }) {
352
- const { sceneRef } = useGlyphcssSceneContext();
353
- const cameraRef = (0, import_react7.useRef)(null);
489
+ const cameraRef = (0, import_react8.useRef)(null);
490
+ const sceneRerenderRef = (0, import_react8.useRef)(null);
354
491
  if (!cameraRef.current) {
355
492
  const opts = {};
356
493
  if (rotX !== void 0) opts.rotX = rotX;
357
494
  if (rotY !== void 0) opts.rotY = rotY;
358
- if (distance !== void 0) opts.distance = distance;
359
- if (scale !== void 0) opts.scale = scale;
360
- if (stretch !== void 0) opts.stretch = stretch;
495
+ if (zoom !== void 0) opts.zoom = zoom;
361
496
  if (center !== void 0) opts.center = center;
362
- cameraRef.current = (0, import_glyphcss2.createGlyphcssPerspectiveCamera)(opts);
497
+ cameraRef.current = (0, import_glyphcss2.createGlyphOrthographicCamera)(opts);
363
498
  }
364
- (0, import_react7.useEffect)(() => {
365
- const scene = sceneRef.current;
366
- if (!scene || !cameraRef.current) return;
367
- scene.setOptions({ camera: cameraRef.current });
368
- scene.rerender();
369
- }, [sceneRef]);
370
- (0, import_react7.useEffect)(() => {
499
+ (0, import_react8.useEffect)(() => {
371
500
  const camera = cameraRef.current;
372
501
  if (!camera) return;
373
502
  let dirty = false;
@@ -379,56 +508,48 @@ function GlyphcssPerspectiveCameraInner({
379
508
  camera.rotY = rotY;
380
509
  dirty = true;
381
510
  }
382
- if (distance !== void 0 && camera.distance !== distance) {
383
- camera.distance = distance;
384
- dirty = true;
385
- }
386
- if (scale !== void 0 && camera.scale !== scale) {
387
- camera.scale = scale;
388
- dirty = true;
389
- }
390
- if (stretch !== void 0 && camera.stretch !== stretch) {
391
- camera.stretch = stretch;
511
+ if (zoom !== void 0 && camera.zoom !== zoom) {
512
+ camera.zoom = zoom;
392
513
  dirty = true;
393
514
  }
394
515
  if (dirty) {
395
- sceneRef.current?.rerender();
516
+ sceneRerenderRef.current?.();
396
517
  }
397
518
  });
398
- const rerender = () => sceneRef.current?.rerender();
399
- const ctxValue = (0, import_react7.useMemo)(() => ({ cameraRef, rerender }), [cameraRef]);
400
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GlyphcssCameraContext.Provider, { value: ctxValue, children });
519
+ const rerender = (0, import_react8.useMemo)(() => () => sceneRerenderRef.current?.(), []);
520
+ const ctxValue = (0, import_react8.useMemo)(() => ({ cameraRef, rerender, sceneRerenderRef }), [cameraRef, rerender]);
521
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GlyphCameraContext.Provider, { value: ctxValue, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className, style, children }) });
401
522
  }
402
- var GlyphcssPerspectiveCamera = (0, import_react7.memo)(GlyphcssPerspectiveCameraInner);
523
+ var GlyphOrthographicCamera = (0, import_react8.memo)(GlyphOrthographicCameraInner);
403
524
 
404
- // src/glyphcss/camera/GlyphcssOrthographicCamera.tsx
405
- var import_react8 = require("react");
525
+ // src/glyphcss/camera/GlyphPerspectiveCamera.tsx
526
+ var import_react9 = require("react");
406
527
  var import_glyphcss3 = require("glyphcss");
407
528
  var import_jsx_runtime5 = require("react/jsx-runtime");
408
- function GlyphcssOrthographicCameraInner({
529
+ function GlyphPerspectiveCameraInner({
409
530
  rotX,
410
531
  rotY,
532
+ distance,
411
533
  zoom,
534
+ stretch,
412
535
  center,
536
+ className,
537
+ style,
413
538
  children
414
539
  }) {
415
- const { sceneRef } = useGlyphcssSceneContext();
416
- const cameraRef = (0, import_react8.useRef)(null);
540
+ const cameraRef = (0, import_react9.useRef)(null);
541
+ const sceneRerenderRef = (0, import_react9.useRef)(null);
417
542
  if (!cameraRef.current) {
418
543
  const opts = {};
419
544
  if (rotX !== void 0) opts.rotX = rotX;
420
545
  if (rotY !== void 0) opts.rotY = rotY;
546
+ if (distance !== void 0) opts.distance = distance;
421
547
  if (zoom !== void 0) opts.zoom = zoom;
548
+ if (stretch !== void 0) opts.stretch = stretch;
422
549
  if (center !== void 0) opts.center = center;
423
- cameraRef.current = (0, import_glyphcss3.createGlyphcssOrthographicCamera)(opts);
550
+ cameraRef.current = (0, import_glyphcss3.createGlyphPerspectiveCamera)(opts);
424
551
  }
425
- (0, import_react8.useEffect)(() => {
426
- const scene = sceneRef.current;
427
- if (!scene || !cameraRef.current) return;
428
- scene.setOptions({ camera: cameraRef.current });
429
- scene.rerender();
430
- }, [sceneRef]);
431
- (0, import_react8.useEffect)(() => {
552
+ (0, import_react9.useEffect)(() => {
432
553
  const camera = cameraRef.current;
433
554
  if (!camera) return;
434
555
  let dirty = false;
@@ -440,36 +561,46 @@ function GlyphcssOrthographicCameraInner({
440
561
  camera.rotY = rotY;
441
562
  dirty = true;
442
563
  }
443
- if (zoom !== void 0 && camera.scale !== zoom) {
444
- camera.scale = zoom;
564
+ if (distance !== void 0 && camera.distance !== distance) {
565
+ camera.distance = distance;
445
566
  dirty = true;
446
567
  }
447
- if (dirty) sceneRef.current?.rerender();
568
+ if (zoom !== void 0 && camera.zoom !== zoom) {
569
+ camera.zoom = zoom;
570
+ dirty = true;
571
+ }
572
+ if (stretch !== void 0 && camera.stretch !== stretch) {
573
+ camera.stretch = stretch;
574
+ dirty = true;
575
+ }
576
+ if (dirty) {
577
+ sceneRerenderRef.current?.();
578
+ }
448
579
  });
449
- const rerender = () => sceneRef.current?.rerender();
450
- const ctxValue = (0, import_react8.useMemo)(() => ({ cameraRef, rerender }), [cameraRef]);
451
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GlyphcssCameraContext.Provider, { value: ctxValue, children });
580
+ const rerender = (0, import_react9.useMemo)(() => () => sceneRerenderRef.current?.(), []);
581
+ const ctxValue = (0, import_react9.useMemo)(() => ({ cameraRef, rerender, sceneRerenderRef }), [cameraRef, rerender]);
582
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GlyphCameraContext.Provider, { value: ctxValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, style, children }) });
452
583
  }
453
- var GlyphcssOrthographicCamera = (0, import_react8.memo)(GlyphcssOrthographicCameraInner);
584
+ var GlyphPerspectiveCamera = (0, import_react9.memo)(GlyphPerspectiveCameraInner);
454
585
 
455
- // src/glyphcss/camera/useGlyphcssCamera.ts
456
- var import_react9 = require("react");
586
+ // src/glyphcss/camera/useGlyphCamera.ts
587
+ var import_react10 = require("react");
457
588
  var import_glyphcss4 = require("glyphcss");
458
589
 
459
- // src/glyphcss/controls/GlyphcssOrbitControls.tsx
460
- var import_react10 = require("react");
590
+ // src/glyphcss/controls/GlyphOrbitControls.tsx
591
+ var import_react11 = require("react");
461
592
  var import_glyphcss5 = require("glyphcss");
462
- function GlyphcssOrbitControls({
593
+ function GlyphOrbitControls({
463
594
  drag = true,
464
595
  wheel = true,
465
596
  invert = false,
466
597
  animate = false
467
598
  }) {
468
- const { sceneRef } = useGlyphcssSceneContext();
469
- const controlsRef = (0, import_react10.useRef)(null);
470
- const propsRef = (0, import_react10.useRef)({ drag, wheel, invert, animate });
599
+ const { sceneRef } = useGlyphSceneContext();
600
+ const controlsRef = (0, import_react11.useRef)(null);
601
+ const propsRef = (0, import_react11.useRef)({ drag, wheel, invert, animate });
471
602
  propsRef.current = { drag, wheel, invert, animate };
472
- (0, import_react10.useEffect)(() => {
603
+ (0, import_react11.useEffect)(() => {
473
604
  const scene = sceneRef.current;
474
605
  if (!scene) return;
475
606
  const opts = {
@@ -478,14 +609,14 @@ function GlyphcssOrbitControls({
478
609
  invert: propsRef.current.invert,
479
610
  animate: propsRef.current.animate === false ? false : propsRef.current.animate
480
611
  };
481
- const controls = (0, import_glyphcss5.createGlyphcssOrbitControls)(scene, opts);
612
+ const controls = (0, import_glyphcss5.createGlyphOrbitControls)(scene, opts);
482
613
  controlsRef.current = controls;
483
614
  return () => {
484
615
  controls.destroy();
485
616
  controlsRef.current = null;
486
617
  };
487
618
  }, [sceneRef]);
488
- (0, import_react10.useEffect)(() => {
619
+ (0, import_react11.useEffect)(() => {
489
620
  const controls = controlsRef.current;
490
621
  if (!controls) return;
491
622
  controls.update({ drag, wheel, invert, animate: animate === false ? false : animate });
@@ -493,20 +624,20 @@ function GlyphcssOrbitControls({
493
624
  return null;
494
625
  }
495
626
 
496
- // src/glyphcss/controls/GlyphcssMapControls.tsx
497
- var import_react11 = require("react");
627
+ // src/glyphcss/controls/GlyphMapControls.tsx
628
+ var import_react12 = require("react");
498
629
  var import_glyphcss6 = require("glyphcss");
499
- function GlyphcssMapControls({
630
+ function GlyphMapControls({
500
631
  drag = true,
501
632
  wheel = true,
502
633
  invert = false,
503
634
  animate = false
504
635
  }) {
505
- const { sceneRef } = useGlyphcssSceneContext();
506
- const controlsRef = (0, import_react11.useRef)(null);
507
- const propsRef = (0, import_react11.useRef)({ drag, wheel, invert, animate });
636
+ const { sceneRef } = useGlyphSceneContext();
637
+ const controlsRef = (0, import_react12.useRef)(null);
638
+ const propsRef = (0, import_react12.useRef)({ drag, wheel, invert, animate });
508
639
  propsRef.current = { drag, wheel, invert, animate };
509
- (0, import_react11.useEffect)(() => {
640
+ (0, import_react12.useEffect)(() => {
510
641
  const scene = sceneRef.current;
511
642
  if (!scene) return;
512
643
  const opts = {
@@ -515,14 +646,14 @@ function GlyphcssMapControls({
515
646
  invert: propsRef.current.invert,
516
647
  animate: propsRef.current.animate === false ? false : propsRef.current.animate
517
648
  };
518
- const controls = (0, import_glyphcss6.createGlyphcssMapControls)(scene, opts);
649
+ const controls = (0, import_glyphcss6.createGlyphMapControls)(scene, opts);
519
650
  controlsRef.current = controls;
520
651
  return () => {
521
652
  controls.destroy();
522
653
  controlsRef.current = null;
523
654
  };
524
655
  }, [sceneRef]);
525
- (0, import_react11.useEffect)(() => {
656
+ (0, import_react12.useEffect)(() => {
526
657
  const controls = controlsRef.current;
527
658
  if (!controls) return;
528
659
  controls.update({ drag, wheel, invert, animate: animate === false ? false : animate });
@@ -530,21 +661,21 @@ function GlyphcssMapControls({
530
661
  return null;
531
662
  }
532
663
 
533
- // src/glyphcss/controls/GlyphcssFirstPersonControls.tsx
534
- var import_react12 = require("react");
664
+ // src/glyphcss/controls/GlyphFirstPersonControls.tsx
665
+ var import_react13 = require("react");
535
666
  var import_glyphcss7 = require("glyphcss");
536
- function GlyphcssFirstPersonControls({
667
+ function GlyphFirstPersonControls({
537
668
  drag = true,
538
669
  keyboard = true,
539
670
  moveSpeed = 0.05,
540
671
  lookSpeed = 4e-3,
541
672
  invert = false
542
673
  }) {
543
- const { sceneRef } = useGlyphcssSceneContext();
544
- const controlsRef = (0, import_react12.useRef)(null);
545
- const propsRef = (0, import_react12.useRef)({ drag, keyboard, moveSpeed, lookSpeed, invert });
674
+ const { sceneRef } = useGlyphSceneContext();
675
+ const controlsRef = (0, import_react13.useRef)(null);
676
+ const propsRef = (0, import_react13.useRef)({ drag, keyboard, moveSpeed, lookSpeed, invert });
546
677
  propsRef.current = { drag, keyboard, moveSpeed, lookSpeed, invert };
547
- (0, import_react12.useEffect)(() => {
678
+ (0, import_react13.useEffect)(() => {
548
679
  const scene = sceneRef.current;
549
680
  if (!scene) return;
550
681
  const opts = {
@@ -554,14 +685,14 @@ function GlyphcssFirstPersonControls({
554
685
  lookSpeed: propsRef.current.lookSpeed,
555
686
  invert: propsRef.current.invert
556
687
  };
557
- const controls = (0, import_glyphcss7.createGlyphcssFirstPersonControls)(scene, opts);
688
+ const controls = (0, import_glyphcss7.createGlyphFirstPersonControls)(scene, opts);
558
689
  controlsRef.current = controls;
559
690
  return () => {
560
691
  controls.destroy();
561
692
  controlsRef.current = null;
562
693
  };
563
694
  }, [sceneRef]);
564
- (0, import_react12.useEffect)(() => {
695
+ (0, import_react13.useEffect)(() => {
565
696
  const controls = controlsRef.current;
566
697
  if (!controls) return;
567
698
  controls.update({ drag, keyboard, moveSpeed, lookSpeed, invert });
@@ -569,46 +700,46 @@ function GlyphcssFirstPersonControls({
569
700
  return null;
570
701
  }
571
702
 
572
- // src/glyphcss/helpers/GlyphcssAxesHelper.tsx
573
- var import_react13 = require("react");
574
- function axisTriangles(size) {
703
+ // src/glyphcss/helpers/GlyphAxesHelper.tsx
704
+ var import_react14 = require("react");
705
+ function axisPolygons(size) {
575
706
  const s = size;
576
707
  const t = s * 0.05;
577
- const triangles = [];
708
+ const polygons = [];
578
709
  function addBar(a, b, color) {
579
710
  const v0 = [a[0] - t, a[1] - t, a[2]];
580
711
  const v1 = [b[0] - t, b[1] - t, b[2]];
581
712
  const v2 = [b[0] + t, b[1] + t, b[2]];
582
713
  const v3 = [a[0] + t, a[1] + t, a[2]];
583
- triangles.push({ vertices: [v0, v1, v2], color });
584
- triangles.push({ vertices: [v0, v2, v3], color });
714
+ polygons.push({ vertices: [v0, v1, v2], color });
715
+ polygons.push({ vertices: [v0, v2, v3], color });
585
716
  }
586
717
  addBar([0, 0, 0], [s, 0, 0], "#ff0000");
587
718
  addBar([0, 0, 0], [0, s, 0], "#00ff00");
588
719
  addBar([0, 0, 0], [0, 0, s], "#0000ff");
589
- return triangles;
720
+ return polygons;
590
721
  }
591
- function GlyphcssAxesHelperInner({ size = 1 }) {
592
- const { sceneRef } = useGlyphcssSceneContext();
593
- const meshRef = (0, import_react13.useRef)(null);
594
- const triangles = (0, import_react13.useMemo)(() => axisTriangles(size), [size]);
595
- (0, import_react13.useEffect)(() => {
722
+ function GlyphAxesHelperInner({ size = 1 }) {
723
+ const { sceneRef } = useGlyphSceneContext();
724
+ const meshRef = (0, import_react14.useRef)(null);
725
+ const polygons = (0, import_react14.useMemo)(() => axisPolygons(size), [size]);
726
+ (0, import_react14.useEffect)(() => {
596
727
  const scene = sceneRef.current;
597
728
  if (!scene) return;
598
- const handle = scene.add(triangles);
729
+ const handle = scene.add(polygons);
599
730
  meshRef.current = handle;
600
731
  return () => {
601
732
  handle.dispose();
602
733
  meshRef.current = null;
603
734
  };
604
- }, [sceneRef, triangles]);
735
+ }, [sceneRef, polygons]);
605
736
  return null;
606
737
  }
607
- var GlyphcssAxesHelper = (0, import_react13.memo)(GlyphcssAxesHelperInner);
738
+ var GlyphAxesHelper = (0, import_react14.memo)(GlyphAxesHelperInner);
608
739
 
609
- // src/glyphcss/helpers/GlyphcssDirectionalLightHelper.tsx
610
- var import_react14 = require("react");
611
- function lightMarkerTriangles(position, color, size) {
740
+ // src/glyphcss/helpers/GlyphDirectionalLightHelper.tsx
741
+ var import_react15 = require("react");
742
+ function lightMarkerPolygons(position, color, size) {
612
743
  const [px, py, pz] = position;
613
744
  const s = size;
614
745
  const top = [px, py, pz + s];
@@ -628,46 +759,46 @@ function lightMarkerTriangles(position, color, size) {
628
759
  { vertices: [bot, right, back], color }
629
760
  ];
630
761
  }
631
- function GlyphcssDirectionalLightHelperInner({
762
+ function GlyphDirectionalLightHelperInner({
632
763
  position = [1, 1, 1],
633
764
  color = "#ffff00",
634
765
  size = 0.1
635
766
  }) {
636
- const { sceneRef } = useGlyphcssSceneContext();
637
- const meshRef = (0, import_react14.useRef)(null);
638
- const triangles = (0, import_react14.useMemo)(
639
- () => lightMarkerTriangles(position, color, size),
767
+ const { sceneRef } = useGlyphSceneContext();
768
+ const meshRef = (0, import_react15.useRef)(null);
769
+ const polygons = (0, import_react15.useMemo)(
770
+ () => lightMarkerPolygons(position, color, size),
640
771
  [position, color, size]
641
772
  );
642
- (0, import_react14.useEffect)(() => {
773
+ (0, import_react15.useEffect)(() => {
643
774
  const scene = sceneRef.current;
644
775
  if (!scene) return;
645
- const handle = scene.add(triangles);
776
+ const handle = scene.add(polygons);
646
777
  meshRef.current = handle;
647
778
  return () => {
648
779
  handle.dispose();
649
780
  meshRef.current = null;
650
781
  };
651
- }, [sceneRef, triangles]);
782
+ }, [sceneRef, polygons]);
652
783
  return null;
653
784
  }
654
- var GlyphcssDirectionalLightHelper = (0, import_react14.memo)(GlyphcssDirectionalLightHelperInner);
785
+ var GlyphDirectionalLightHelper = (0, import_react15.memo)(GlyphDirectionalLightHelperInner);
655
786
 
656
787
  // src/glyphcss/styles/index.ts
657
788
  var import_glyphcss8 = require("glyphcss");
658
789
 
659
- // src/animation/useGlyphcssAnimation.ts
660
- var import_react15 = require("react");
661
- var import_core = require("@glyphcss/core");
790
+ // src/animation/useGlyphAnimation.ts
791
+ var import_react16 = require("react");
792
+ var import_core3 = require("@glyphcss/core");
662
793
  function resolveRoot(rootArg) {
663
794
  if (!rootArg) return null;
664
795
  if ("current" in rootArg) return rootArg.current;
665
796
  return rootArg;
666
797
  }
667
- function useGlyphcssAnimation(clips, controller, root) {
668
- const internalRef = (0, import_react15.useRef)(null);
669
- const mixerRef = (0, import_react15.useRef)(null);
670
- (0, import_react15.useEffect)(() => {
798
+ function useGlyphAnimation(clips, controller, root) {
799
+ const internalRef = (0, import_react16.useRef)(null);
800
+ const mixerRef = (0, import_react16.useRef)(null);
801
+ (0, import_react16.useEffect)(() => {
671
802
  if (!clips || clips.length === 0 || !controller) {
672
803
  mixerRef.current = null;
673
804
  return;
@@ -677,14 +808,14 @@ function useGlyphcssAnimation(clips, controller, root) {
677
808
  mixerRef.current = null;
678
809
  return;
679
810
  }
680
- mixerRef.current = (0, import_core.createGlyphcssAnimationMixer)(resolvedRoot, controller);
811
+ mixerRef.current = (0, import_core3.createGlyphAnimationMixer)(resolvedRoot, controller);
681
812
  return () => {
682
813
  mixerRef.current?.stopAllAction();
683
814
  mixerRef.current?.uncacheRoot();
684
815
  mixerRef.current = null;
685
816
  };
686
817
  }, [clips, controller]);
687
- (0, import_react15.useEffect)(() => {
818
+ (0, import_react16.useEffect)(() => {
688
819
  if (!clips || clips.length === 0 || !controller) return;
689
820
  let rafId;
690
821
  let lastTime = null;
@@ -707,7 +838,7 @@ function useGlyphcssAnimation(clips, controller, root) {
707
838
  }, [clips, controller]);
708
839
  const resolvedClips = clips ?? [];
709
840
  const resolvedNames = resolvedClips.map((c) => c.name);
710
- const actions = (0, import_react15.useMemo)(() => {
841
+ const actions = (0, import_react16.useMemo)(() => {
711
842
  const target = {};
712
843
  for (const clip of resolvedClips) {
713
844
  Object.defineProperty(target, clip.name, {
@@ -739,28 +870,31 @@ function useGlyphcssAnimation(clips, controller, root) {
739
870
  CAMERA_BACKFACE_CULL_EPS,
740
871
  DEFAULT_CAMERA_STATE,
741
872
  DEFAULT_PROJECTION,
742
- GlyphcssAxesHelper,
743
- GlyphcssCamera,
744
- GlyphcssCameraContext,
745
- GlyphcssDirectionalLightHelper,
746
- GlyphcssFirstPersonControls,
747
- GlyphcssHotspot,
748
- GlyphcssMapControls,
749
- GlyphcssMesh,
750
- GlyphcssOrbitControls,
751
- GlyphcssOrthographicCamera,
752
- GlyphcssPerspectiveCamera,
753
- GlyphcssScene,
754
- GlyphcssSceneContext,
873
+ GlyphAxesHelper,
874
+ GlyphCamera,
875
+ GlyphCameraContext,
876
+ GlyphDirectionalLightHelper,
877
+ GlyphFirstPersonControls,
878
+ GlyphGround,
879
+ GlyphHotspot,
880
+ GlyphMapControls,
881
+ GlyphMesh,
882
+ GlyphOrbitControls,
883
+ GlyphOrthographicCamera,
884
+ GlyphPerspectiveCamera,
885
+ GlyphScene,
886
+ GlyphSceneContext,
755
887
  LoopOnce,
756
888
  LoopPingPong,
757
889
  LoopRepeat,
758
890
  VOXEL_CAMERA_CULL_AXIS_EPS,
759
891
  VOXEL_CAMERA_CULL_NORMAL_LIMIT,
892
+ antiprismPolygons,
760
893
  arrowPolygons,
761
894
  axesHelperPolygons,
762
895
  bakeSolidTextureSampledPolygons,
763
896
  bakeSolidTextureSamples,
897
+ bipyramidPolygons,
764
898
  buildSceneContext,
765
899
  cameraCullNormalGroups,
766
900
  cameraCullNormalGroupsFromPolygons,
@@ -770,13 +904,28 @@ function useGlyphcssAnimation(clips, controller, root) {
770
904
  clampChannel,
771
905
  computeSceneBbox,
772
906
  computeShapeLighting,
907
+ conePolygons,
773
908
  coverPlanarPolygons,
774
- createGlyphcssAnimationMixer,
909
+ createGlyphAnimationMixer,
775
910
  createIsometricCamera,
911
+ cubePolygons,
912
+ cuboctahedronPolygons,
776
913
  cullInteriorPolygons,
777
- findGlyphcssMeshHandle,
914
+ cylinderPolygons,
915
+ deltoidalHexecontahedronPolygons,
916
+ deltoidalIcositetrahedronPolygons,
917
+ disdyakisDodecahedronPolygons,
918
+ disdyakisTriacontahedronPolygons,
919
+ dodecahedronPolygons,
920
+ findGlyphMeshHandle,
921
+ findMeshUnderPoint,
778
922
  formatColor,
779
- injectGlyphcssBaseStyles,
923
+ greatDodecahedronPolygons,
924
+ greatIcosahedronPolygons,
925
+ greatStellatedDodecahedronPolygons,
926
+ icosahedronPolygons,
927
+ icosidodecahedronPolygons,
928
+ injectGlyphBaseStyles,
780
929
  inverseRotateVec3,
781
930
  isAxisAlignedSurfaceNormal,
782
931
  isVoxelCameraCullableNormalGroups,
@@ -795,14 +944,45 @@ function useGlyphcssAnimation(clips, controller, root) {
795
944
  parsePureColor,
796
945
  parseRgbColor,
797
946
  parseVox,
947
+ pentagonalHexecontahedronPolygons,
948
+ pentagonalIcositetrahedronPolygons,
949
+ pentakisDodecahedronPolygons,
950
+ planePolygons,
951
+ pointInMeshElement,
798
952
  polygonCssSurfaceNormal,
799
953
  polygonFaces,
800
954
  polygonFacesCamera,
955
+ prismPolygons,
956
+ pyramidPolygons,
957
+ resolveGeometry,
958
+ rhombicDodecahedronPolygons,
959
+ rhombicTriacontahedronPolygons,
960
+ rhombicosidodecahedronPolygons,
961
+ rhombicuboctahedronPolygons,
801
962
  ringPolygons,
963
+ ringQuadPolygons,
802
964
  rotateVec3,
803
965
  shadeColor,
804
- useGlyphcssAnimation,
805
- useGlyphcssCamera,
806
- useGlyphcssMesh,
807
- useGlyphcssSceneContext
966
+ smallStellatedDodecahedronPolygons,
967
+ snubCubePolygons,
968
+ snubDodecahedronPolygons,
969
+ spherePolygons,
970
+ tetrahedronPolygons,
971
+ tetrakisHexahedronPolygons,
972
+ torusPolygons,
973
+ trapezohedronPolygons,
974
+ triakisIcosahedronPolygons,
975
+ triakisOctahedronPolygons,
976
+ triakisTetrahedronPolygons,
977
+ truncatedCubePolygons,
978
+ truncatedCuboctahedronPolygons,
979
+ truncatedDodecahedronPolygons,
980
+ truncatedIcosahedronPolygons,
981
+ truncatedIcosidodecahedronPolygons,
982
+ truncatedOctahedronPolygons,
983
+ truncatedTetrahedronPolygons,
984
+ useGlyphAnimation,
985
+ useGlyphCamera,
986
+ useGlyphMesh,
987
+ useGlyphSceneContext
808
988
  });