@3driseai/3drise-viewer 0.1.44 → 0.1.45

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.
@@ -1 +1 @@
1
- {"version":3,"file":"GeometryShape.d.ts","sourceRoot":"","sources":["../../src/components/GeometryShape.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAwF,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAS/I,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQjH,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnC,KAAK,QAAQ,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;CAChB,GAAG;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,YAAY,CAAC;CAC3B,GAAG;IACA,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,EAAE,EAAE,CAAC;CAChB,GAAG;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,EAAE,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACvD,MAAM,EAAE,mBAAmB,CAAC;IAC5B,gHAAgH;IAChH,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qE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AAgB,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,EAAE,EAAE,CAKnD;AACD,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,GAAG,EAAE,EAAE,CAuBzF;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG;IAC7F,SAAS,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,EAAE,EAAE,CAAC;CAClB,CAoCJ;AACD,wBAAgB,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE,UAAU,GAAG,QAAQ,CAkBxE;AAMD,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAA8B,EAAE,KAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,iBAAiB,+BA+BjM;AAED,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,MAAY,EAAE,QAAQ,EAAE,EAAE;IACnD,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAQ2E,GAAG,CACtF"}
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { useObjectReady } from '../hooks/useObjectReady.js';
4
4
  import { EdgesGeometry, WireframeGeometry, Mesh, MeshBasicMaterial, Raycaster, Vector3, DoubleSide, } from 'three';
5
- import { applyShapeLayout, applyShapeLayoutGrounds, buildSegmentQuadGeometry, shapeLayoutData } from '@3driseai/3drise-core';
5
+ import { applyMeshCage, applyMeshEdit, applyShapeLayout, meshEditLayout, applyShapeLayoutGrounds, buildSegmentQuadGeometry, shapeLayoutData } from '@3driseai/3drise-core';
6
6
  import LayoutGrounds from './layout/LayoutGrounds.js';
7
7
  import { useLayoutRefVersion } from '../hooks/useResolvedLayout.js';
8
8
  import { shapeGenerators } from '../utils/shapes.js';
@@ -88,7 +88,11 @@ function useAsyncShapeTick(cfg) {
88
88
  }, [svgUrl]);
89
89
  return tick;
90
90
  }
91
- /** The shape's geometry and, with a layout applied (the object's layout.shape), its ground holes' geometries. */
91
+ /**
92
+ * The shape's geometry and its ground holes' geometries: built from the config, then its own edit
93
+ * (config.edit — its outline or a cage, core applyMeshEdit) or, without an outline of its own, a
94
+ * layout applied (the object's layout.shape). `layout`: the layout its ground holes come from.
95
+ */
92
96
  function useShapeBuild(options, shapeLayout) {
93
97
  const safeOptions = useMemo(() => normalizeShapeConfig(options), [options]);
94
98
  const key = JSON.stringify(safeOptions);
@@ -100,8 +104,36 @@ function useShapeBuild(options, shapeLayout) {
100
104
  const built = useMemo(() => {
101
105
  const generator = shapeGenerators[safeOptions.type] ?? shapeGenerators.box;
102
106
  const base = generator(safeOptions);
107
+ // the mesh's own edit (Edit mesh): its outline wins over a layout (and takes its cage too)
108
+ const edit = safeOptions.edit;
109
+ if (edit?.area && meshEditLayout(safeOptions)) {
110
+ try {
111
+ const r = applyMeshEdit(base, safeOptions);
112
+ if (r.geometry !== base)
113
+ base.dispose();
114
+ return { geometry: r.geometry, grounds: r.grounds, layout: r.layout };
115
+ }
116
+ catch (e) {
117
+ console.warn('[meshEdit] could not apply the edit:', e);
118
+ }
119
+ }
120
+ const built = buildWithLayout(base);
121
+ // a cage bends whatever the mesh is (a layout included)
122
+ if (edit?.cage && Object.keys(edit.cage.points ?? {}).length) {
123
+ try {
124
+ const bent = applyMeshCage(built.geometry, edit.cage);
125
+ built.geometry.dispose();
126
+ built.geometry = bent;
127
+ }
128
+ catch (e) {
129
+ console.warn('[meshEdit] could not apply the cage:', e);
130
+ }
131
+ }
132
+ return built;
133
+ }, [safeOptions.type, key, fontTick, asyncTick, layoutTick, layoutKey]); // eslint-disable-line react-hooks/exhaustive-deps
134
+ function buildWithLayout(base) {
103
135
  if (!shapeLayout)
104
- return { geometry: base, grounds: [] };
136
+ return { geometry: base, grounds: [], layout: null };
105
137
  // until a saved layout has loaded (or when it gives nothing) the shape shows as it is
106
138
  let shaped = null, grounds = [];
107
139
  try {
@@ -114,10 +146,10 @@ function useShapeBuild(options, shapeLayout) {
114
146
  console.warn('[shapeLayout] could not apply the layout:', e);
115
147
  }
116
148
  if (!shaped)
117
- return { geometry: base, grounds: [] };
149
+ return { geometry: base, grounds: [], layout: null };
118
150
  base.dispose();
119
- return { geometry: shaped, grounds };
120
- }, [safeOptions.type, key, fontTick, asyncTick, layoutTick, layoutKey]); // eslint-disable-line react-hooks/exhaustive-deps
151
+ return { geometry: shaped, grounds, layout: shapeLayout };
152
+ }
121
153
  useEffect(() => () => { built.geometry.dispose(); for (const g of built.grounds)
122
154
  g.geometry.dispose(); }, [built]);
123
155
  return built;
@@ -397,7 +429,7 @@ export function GeometryMesh({ config, shapeLayout, materialSettings, animations
397
429
  // <points>; relabel so it still surfaces as this geometry's config.
398
430
  const reportReady = (_object, ref) => onObjectReady && onObjectReady(config, ref);
399
431
  const reportDispose = (_object, ref) => onObjectDispose && onObjectDispose(config, ref);
400
- const { geometry, grounds } = useShapeBuild(config, shapeLayout);
432
+ const { geometry, grounds, layout: groundsLayout } = useShapeBuild(config, shapeLayout);
401
433
  const safeModeConfig = normalizeModeConfig(modeConfig);
402
434
  const data = useModeData(geometry, safeModeConfig);
403
435
  // Line modes are ribbons of quads, not line primitives, so the material
@@ -416,7 +448,7 @@ export function GeometryMesh({ config, shapeLayout, materialSettings, animations
416
448
  return lineGeometry ? (_jsx("mesh", { ref: rootRef, geometry: lineGeometry, children: children ?? _jsx("meshBasicMaterial", { color: color, side: DoubleSide }) })) : null;
417
449
  if (data.kind === 'plexus')
418
450
  return (_jsxs("group", { ref: rootRef, children: [_jsx(PointCloud, { positions: data.positions, animations: animations, materialSettings: materialSettings }), lineGeometry && (_jsx("mesh", { geometry: lineGeometry, children: children ?? _jsx("meshBasicMaterial", { color: color, side: DoubleSide, transparent: true, opacity: 0.45 }) }))] }));
419
- return (_jsxs("mesh", { ref: rootRef, geometry: geometry, children: [children ?? _jsx("meshPhongMaterial", { color: color, side: DoubleSide }), shapeLayout && grounds.length > 0 && _jsx(LayoutGrounds, { grounds: grounds, shapeLayout: shapeLayout, uv: "metres", untextured: "object" })] }));
451
+ return (_jsxs("mesh", { ref: rootRef, geometry: geometry, children: [children ?? _jsx("meshPhongMaterial", { color: color, side: DoubleSide }), groundsLayout && grounds.length > 0 && _jsx(LayoutGrounds, { grounds: grounds, shapeLayout: groundsLayout, uv: "metres", untextured: "object" })] }));
420
452
  }
421
453
  export function FitGroup({ geometry, radius = 1.7, children }) {
422
454
  const { scale, position } = useMemo(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3driseai/3drise-viewer",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "clean": "rimraf dist",
21
21
  "bump": "npm version patch",
22
22
  "check:dist": "node ../../tools/check-dist.mjs",
23
- "pub": "node ../../tools/check-dist.mjs && npm publish --access public"
23
+ "pub": "node ../../tools/check-dist.mjs --only viewer && npm publish --access public"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@gsap/react": "^2.1.2",
@@ -41,7 +41,7 @@
41
41
  "typescript": "^5.7.2"
42
42
  },
43
43
  "dependencies": {
44
- "@3driseai/3drise-core": "^1.0.31",
44
+ "@3driseai/3drise-core": "^1.0.33",
45
45
  "three-mesh-bvh": "^0.8.3"
46
46
  }
47
47
  }