@pascal-app/viewer 0.3.0 → 0.3.1
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/components/viewer/index.d.ts.map +1 -1
- package/dist/components/viewer/index.js +4 -2
- package/dist/components/viewer/post-processing.d.ts.map +1 -1
- package/dist/components/viewer/post-processing.js +46 -63
- package/dist/store/use-viewer.d.ts +2 -2
- package/dist/store/use-viewer.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/hooks/use-grid-events.d.ts +0 -12
- package/dist/hooks/use-grid-events.d.ts.map +0 -1
- package/dist/hooks/use-grid-events.js +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/viewer/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAkB,KAAK,kBAAkB,EAAsB,MAAM,oBAAoB,CAAA;AAEhG,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/viewer/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAkB,KAAK,kBAAkB,EAAsB,MAAM,oBAAoB,CAAA;AAEhG,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AA0CrC,OAAO,QAAQ,oBAAoB,CAAC;IAClC,UAAU,aAAc,SAAQ,kBAAkB,CAAC,OAAO,KAAK,CAAC;KAAG;CACpE;AA+BD,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,gBAAgB,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IACvC,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA6DjC,CAAA;AASD,eAAe,MAAM,CAAA"}
|
|
@@ -13,7 +13,6 @@ import { ScanSystem } from '../../systems/scan/scan-system';
|
|
|
13
13
|
import { WallCutout } from '../../systems/wall/wall-cutout';
|
|
14
14
|
import { ZoneSystem } from '../../systems/zone/zone-system';
|
|
15
15
|
import { SceneRenderer } from '../renderers/scene-renderer';
|
|
16
|
-
import { GroundOccluder } from './ground-occluder';
|
|
17
16
|
import { Lights } from './lights';
|
|
18
17
|
import { PerfMonitor } from './perf-monitor';
|
|
19
18
|
import PostProcessing from './post-processing';
|
|
@@ -68,11 +67,14 @@ const Viewer = ({ children, selectionManager = 'default', perf = false, }) => {
|
|
|
68
67
|
const renderer = new THREE.WebGPURenderer(props);
|
|
69
68
|
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
70
69
|
renderer.toneMappingExposure = 0.9;
|
|
70
|
+
// renderer.init() // Only use when using <DebugRenderer />
|
|
71
71
|
return renderer;
|
|
72
|
+
}, resize: {
|
|
73
|
+
debounce: 100,
|
|
72
74
|
}, shadows: {
|
|
73
75
|
type: THREE.PCFShadowMap,
|
|
74
76
|
enabled: true,
|
|
75
|
-
}, children: [_jsx(
|
|
77
|
+
}, children: [_jsx(ViewerCamera, {}), _jsx(Lights, {}), _jsx(Bvh, { children: _jsx(SceneRenderer, {}) }), _jsx(LevelSystem, {}), _jsx(GuideSystem, {}), _jsx(ScanSystem, {}), _jsx(WallCutout, {}), _jsx(CeilingSystem, {}), _jsx(DoorSystem, {}), _jsx(ItemSystem, {}), _jsx(RoofSystem, {}), _jsx(SlabSystem, {}), _jsx(WallSystem, {}), _jsx(WindowSystem, {}), _jsx(ZoneSystem, {}), _jsx(PostProcessing, {}), _jsx(GPUDeviceWatcher, {}), _jsx(ItemLightSystem, {}), selectionManager === 'default' && _jsx(SelectionManager, {}), perf && _jsx(PerfMonitor, {}), children] }));
|
|
76
78
|
};
|
|
77
79
|
const DebugRenderer = () => {
|
|
78
80
|
useFrame(({ gl, scene, camera }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-processing.d.ts","sourceRoot":"","sources":["../../../src/components/viewer/post-processing.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"post-processing.d.ts","sourceRoot":"","sources":["../../../src/components/viewer/post-processing.tsx"],"names":[],"mappings":"AA4BA,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAavB,CAAA;AAQD,QAAA,MAAM,oBAAoB,YAkRzB,CAAA;AAED,eAAe,oBAAoB,CAAA"}
|
|
@@ -3,9 +3,8 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
3
3
|
import { Color, Layers, UnsignedByteType } from 'three';
|
|
4
4
|
import { outline } from 'three/addons/tsl/display/OutlineNode.js';
|
|
5
5
|
import { ssgi } from 'three/addons/tsl/display/SSGINode.js';
|
|
6
|
-
import { traa } from 'three/addons/tsl/display/TRAANode.js';
|
|
7
6
|
import { denoise } from 'three/examples/jsm/tsl/display/DenoiseNode.js';
|
|
8
|
-
import { add, colorToDirection, diffuseColor, directionToColor, float, mix, mrt, normalView, oscSine, output, pass, sample, time, uniform, vec4,
|
|
7
|
+
import { add, colorToDirection, diffuseColor, directionToColor, float, mix, mrt, normalView, oscSine, output, pass, sample, time, uniform, vec4, } from 'three/tsl';
|
|
9
8
|
import { RenderPipeline } from 'three/webgpu';
|
|
10
9
|
import { SCENE_LAYER, ZONE_LAYER } from '../../lib/layers';
|
|
11
10
|
import useViewer from '../../store/use-viewer';
|
|
@@ -93,64 +92,58 @@ const PostProcessingPasses = () => {
|
|
|
93
92
|
outliner.selectedObjects.length = 0;
|
|
94
93
|
outliner.hoveredObjects.length = 0;
|
|
95
94
|
try {
|
|
96
|
-
// Scene pass with MRT for SSGI
|
|
97
95
|
const scenePass = pass(scene, camera);
|
|
98
|
-
scenePass.setMRT(mrt({
|
|
99
|
-
output,
|
|
100
|
-
diffuseColor,
|
|
101
|
-
normal: directionToColor(normalView),
|
|
102
|
-
velocity,
|
|
103
|
-
}));
|
|
104
|
-
// Get texture outputs
|
|
105
|
-
const scenePassColor = scenePass.getTextureNode('output');
|
|
106
|
-
const scenePassDiffuse = scenePass.getTextureNode('diffuseColor');
|
|
107
|
-
const scenePassDepth = scenePass.getTextureNode('depth');
|
|
108
|
-
const scenePassNormal = scenePass.getTextureNode('normal');
|
|
109
|
-
const scenePassVelocity = scenePass.getTextureNode('velocity');
|
|
110
|
-
// Optimize texture bandwidth
|
|
111
|
-
const diffuseTexture = scenePass.getTexture('diffuseColor');
|
|
112
|
-
diffuseTexture.type = UnsignedByteType;
|
|
113
|
-
const normalTexture = scenePass.getTexture('normal');
|
|
114
|
-
normalTexture.type = UnsignedByteType;
|
|
115
|
-
// Extract normal from color-encoded texture
|
|
116
|
-
const sceneNormal = sample((uv) => {
|
|
117
|
-
return colorToDirection(scenePassNormal.sample(uv));
|
|
118
|
-
});
|
|
119
96
|
const zonePass = pass(scene, camera);
|
|
120
97
|
zonePass.setLayers(zoneLayers);
|
|
121
|
-
|
|
122
|
-
const giPass = ssgi(scenePassColor, scenePassDepth, sceneNormal, camera);
|
|
123
|
-
giPass.sliceCount.value = SSGI_PARAMS.sliceCount;
|
|
124
|
-
giPass.stepCount.value = SSGI_PARAMS.stepCount;
|
|
125
|
-
giPass.radius.value = SSGI_PARAMS.radius;
|
|
126
|
-
giPass.expFactor.value = SSGI_PARAMS.expFactor;
|
|
127
|
-
giPass.thickness.value = SSGI_PARAMS.thickness;
|
|
128
|
-
giPass.backfaceLighting.value = SSGI_PARAMS.backfaceLighting;
|
|
129
|
-
giPass.aoIntensity.value = SSGI_PARAMS.aoIntensity;
|
|
130
|
-
giPass.giIntensity.value = SSGI_PARAMS.giIntensity;
|
|
131
|
-
giPass.useLinearThickness.value = SSGI_PARAMS.useLinearThickness;
|
|
132
|
-
giPass.useScreenSpaceSampling.value = SSGI_PARAMS.useScreenSpaceSampling;
|
|
133
|
-
giPass.useTemporalFiltering = SSGI_PARAMS.useTemporalFiltering;
|
|
134
|
-
const giTexture = giPass.getTextureNode();
|
|
135
|
-
// DenoiseNode only denoises RGB — alpha is passed through unchanged.
|
|
136
|
-
// SSGI packs AO into alpha, so we remap it into RGB before denoising.
|
|
137
|
-
// convertToTexture() inside denoise() will call rtt() on this vec4 node automatically.
|
|
138
|
-
const aoAsRgb = vec4(giTexture.a, giTexture.a, giTexture.a, float(1));
|
|
139
|
-
const denoisePass = denoise(aoAsRgb, scenePassDepth, sceneNormal, camera);
|
|
140
|
-
denoisePass.index.value = 0;
|
|
141
|
-
denoisePass.radius.value = 4;
|
|
142
|
-
const gi = giPass.rgb;
|
|
143
|
-
const ao = denoisePass.r;
|
|
144
|
-
// const gi = giPass.rgb;
|
|
145
|
-
// const ao = giPass.a;
|
|
98
|
+
const scenePassColor = scenePass.getTextureNode('output');
|
|
146
99
|
// Background detection via alpha: renderer clears with alpha=0 (setClearAlpha(0) in useFrame),
|
|
147
100
|
// so background pixels have scenePassColor.a=0 while geometry pixels have output.a=1.
|
|
148
101
|
// WebGPU only applies clearColorValue to MRT attachment 0 (output), so scenePassColor.a
|
|
149
102
|
// is the reliable geometry mask — no normals, no flicker.
|
|
150
103
|
const hasGeometry = scenePassColor.a;
|
|
151
104
|
const contentAlpha = hasGeometry.max(zonePass.a);
|
|
152
|
-
|
|
153
|
-
|
|
105
|
+
let sceneColor = scenePassColor;
|
|
106
|
+
if (SSGI_PARAMS.enabled) {
|
|
107
|
+
// MRT only needed for SSGI (diffuse for GI, normal for SSGI sampling)
|
|
108
|
+
scenePass.setMRT(mrt({
|
|
109
|
+
output,
|
|
110
|
+
diffuseColor,
|
|
111
|
+
normal: directionToColor(normalView),
|
|
112
|
+
}));
|
|
113
|
+
const scenePassDiffuse = scenePass.getTextureNode('diffuseColor');
|
|
114
|
+
const scenePassDepth = scenePass.getTextureNode('depth');
|
|
115
|
+
const scenePassNormal = scenePass.getTextureNode('normal');
|
|
116
|
+
// Optimize texture bandwidth
|
|
117
|
+
const diffuseTexture = scenePass.getTexture('diffuseColor');
|
|
118
|
+
diffuseTexture.type = UnsignedByteType;
|
|
119
|
+
const normalTexture = scenePass.getTexture('normal');
|
|
120
|
+
normalTexture.type = UnsignedByteType;
|
|
121
|
+
// Extract normal from color-encoded texture
|
|
122
|
+
const sceneNormal = sample((uv) => colorToDirection(scenePassNormal.sample(uv)));
|
|
123
|
+
const giPass = ssgi(scenePassColor, scenePassDepth, sceneNormal, camera);
|
|
124
|
+
giPass.sliceCount.value = SSGI_PARAMS.sliceCount;
|
|
125
|
+
giPass.stepCount.value = SSGI_PARAMS.stepCount;
|
|
126
|
+
giPass.radius.value = SSGI_PARAMS.radius;
|
|
127
|
+
giPass.expFactor.value = SSGI_PARAMS.expFactor;
|
|
128
|
+
giPass.thickness.value = SSGI_PARAMS.thickness;
|
|
129
|
+
giPass.backfaceLighting.value = SSGI_PARAMS.backfaceLighting;
|
|
130
|
+
giPass.aoIntensity.value = SSGI_PARAMS.aoIntensity;
|
|
131
|
+
giPass.giIntensity.value = SSGI_PARAMS.giIntensity;
|
|
132
|
+
giPass.useLinearThickness.value = SSGI_PARAMS.useLinearThickness;
|
|
133
|
+
giPass.useScreenSpaceSampling.value = SSGI_PARAMS.useScreenSpaceSampling;
|
|
134
|
+
giPass.useTemporalFiltering = SSGI_PARAMS.useTemporalFiltering;
|
|
135
|
+
const giTexture = giPass.getTextureNode();
|
|
136
|
+
// DenoiseNode only denoises RGB — alpha is passed through unchanged.
|
|
137
|
+
// SSGI packs AO into alpha, so we remap it into RGB before denoising.
|
|
138
|
+
const aoAsRgb = vec4(giTexture.a, giTexture.a, giTexture.a, float(1));
|
|
139
|
+
const denoisePass = denoise(aoAsRgb, scenePassDepth, sceneNormal, camera);
|
|
140
|
+
denoisePass.index.value = 0;
|
|
141
|
+
denoisePass.radius.value = 4;
|
|
142
|
+
const gi = giPass.rgb;
|
|
143
|
+
const ao = denoisePass.r;
|
|
144
|
+
// Composite: scene * AO + diffuse * GI
|
|
145
|
+
sceneColor = vec4(add(scenePassColor.rgb.mul(ao), add(zonePass.rgb, scenePassDiffuse.rgb.mul(gi))), contentAlpha);
|
|
146
|
+
}
|
|
154
147
|
function generateSelectedOutlinePass() {
|
|
155
148
|
const edgeStrength = uniform(3);
|
|
156
149
|
const edgeGlow = uniform(0);
|
|
@@ -193,18 +186,8 @@ const PostProcessingPasses = () => {
|
|
|
193
186
|
}
|
|
194
187
|
const selectedOutlinePass = generateSelectedOutlinePass();
|
|
195
188
|
const hoverOutlinePass = generateHoverOutlinePass();
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
? vec4(add(compositePass.rgb, selectedOutlinePass.add(hoverOutlinePass)), compositePass.a)
|
|
199
|
-
: vec4(add(scenePassColor.rgb, selectedOutlinePass.add(hoverOutlinePass)), scenePassColor.a);
|
|
200
|
-
// TRAA (Temporal Reprojection Anti-Aliasing) - applied AFTER combining everything
|
|
201
|
-
const traaOutput = traa(compositeWithOutlines, scenePassDepth, scenePassVelocity, camera);
|
|
202
|
-
// For zone-over-background pixels, scenePassDepth=1.0 (no scene geometry) causes TRAA
|
|
203
|
-
// to output black. Use hasGeometry to blend: geometry pixels use traaRgb, all others
|
|
204
|
-
// (zones over background, pure background) use compositePass.rgb directly.
|
|
205
|
-
const traaRgb = traaOutput.rgb;
|
|
206
|
-
const colorSource = mix(compositePass.rgb, traaRgb, hasGeometry);
|
|
207
|
-
const finalOutput = vec4(mix(bgUniform.current, colorSource, contentAlpha), float(1));
|
|
189
|
+
const compositeWithOutlines = vec4(add(sceneColor.rgb, selectedOutlinePass.add(hoverOutlinePass)), sceneColor.a);
|
|
190
|
+
const finalOutput = vec4(mix(bgUniform.current, compositeWithOutlines.rgb, contentAlpha), float(1));
|
|
208
191
|
const renderPipeline = new RenderPipeline(renderer);
|
|
209
192
|
renderPipeline.outputNode = finalOutput;
|
|
210
193
|
renderPipelineRef.current = renderPipeline;
|
|
@@ -40,8 +40,8 @@ type ViewerState = {
|
|
|
40
40
|
setSelection: (updates: Partial<SelectionPath>) => void;
|
|
41
41
|
resetSelection: () => void;
|
|
42
42
|
outliner: Outliner;
|
|
43
|
-
exportScene: (() => Promise<void>) | null;
|
|
44
|
-
setExportScene: (fn: (() => Promise<void>) | null) => void;
|
|
43
|
+
exportScene: ((format?: 'glb' | 'stl' | 'obj') => Promise<void>) | null;
|
|
44
|
+
setExportScene: (fn: ((format?: 'glb' | 'stl' | 'obj') => Promise<void>) | null) => void;
|
|
45
45
|
debugColors: boolean;
|
|
46
46
|
setDebugColors: (enabled: boolean) => void;
|
|
47
47
|
cameraDragging: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-viewer.d.ts","sourceRoot":"","sources":["../../src/store/use-viewer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC5F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAKrC,KAAK,aAAa,GAAG;IACnB,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACrC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAC/B,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAC7B,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAA;CAC9B,CAAA;AAED,KAAK,QAAQ,GAAG;IACd,eAAe,EAAE,QAAQ,EAAE,CAAA;IAC3B,cAAc,EAAE,QAAQ,EAAE,CAAA;CAC3B,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,aAAa,CAAA;IACxB,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAChD,YAAY,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,IAAI,CAAA;IAEjE,UAAU,EAAE,aAAa,GAAG,cAAc,CAAA;IAC1C,aAA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MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAA;IACvE,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,CAAA;IAExF,WAAW,EAAE,OAAO,CAAA;IACpB,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAE1C,cAAc,EAAE,OAAO,CAAA;IACvB,iBAAiB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;CAC/C,CAAA;AAED,QAAA,MAAM,SAAS;;;;;;;;;;;4BApBG,OAAO;6BAAe,OAAO;2BAAa,OAAO;;;;;;;;;;;;;;;4BAAjD,OAAO;6BAAe,OAAO;2BAAa,OAAO;;;;EAqJlE,CAAA;AAED,eAAe,SAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ThreeEvent } from "@react-three/fiber";
|
|
2
|
-
export declare function useGridEvents(): {
|
|
3
|
-
onPointerDown: (e: ThreeEvent<PointerEvent>) => void;
|
|
4
|
-
onPointerUp: (e: ThreeEvent<PointerEvent>) => void;
|
|
5
|
-
onClick: (e: ThreeEvent<PointerEvent>) => void;
|
|
6
|
-
onPointerEnter: (e: ThreeEvent<PointerEvent>) => void;
|
|
7
|
-
onPointerLeave: (e: ThreeEvent<PointerEvent>) => void;
|
|
8
|
-
onPointerMove: (e: ThreeEvent<PointerEvent>) => void;
|
|
9
|
-
onDoubleClick: (e: ThreeEvent<PointerEvent>) => void;
|
|
10
|
-
onContextMenu: (e: ThreeEvent<PointerEvent>) => void;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=use-grid-events.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-grid-events.d.ts","sourceRoot":"","sources":["../../src/hooks/use-grid-events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,wBAAgB,aAAa;uBAYN,UAAU,CAAC,YAAY,CAAC;qBAI1B,UAAU,CAAC,YAAY,CAAC;iBAI5B,UAAU,CAAC,YAAY,CAAC;wBAIjB,UAAU,CAAC,YAAY,CAAC;wBACxB,UAAU,CAAC,YAAY,CAAC;uBACzB,UAAU,CAAC,YAAY,CAAC;uBACxB,UAAU,CAAC,YAAY,CAAC;uBACxB,UAAU,CAAC,YAAY,CAAC;EAE9C"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { emitter } from "@pascal-app/core";
|
|
2
|
-
export function useGridEvents() {
|
|
3
|
-
const emit = (suffix, e) => {
|
|
4
|
-
const eventKey = `grid:${suffix}`;
|
|
5
|
-
const payload = {
|
|
6
|
-
position: [e.point.x, e.point.y, e.point.z],
|
|
7
|
-
nativeEvent: e,
|
|
8
|
-
};
|
|
9
|
-
emitter.emit(eventKey, payload);
|
|
10
|
-
};
|
|
11
|
-
return {
|
|
12
|
-
onPointerDown: (e) => {
|
|
13
|
-
if (e.button !== 0)
|
|
14
|
-
return;
|
|
15
|
-
emit("pointerdown", e);
|
|
16
|
-
},
|
|
17
|
-
onPointerUp: (e) => {
|
|
18
|
-
if (e.button !== 0)
|
|
19
|
-
return;
|
|
20
|
-
emit("pointerup", e);
|
|
21
|
-
},
|
|
22
|
-
onClick: (e) => {
|
|
23
|
-
if (e.button !== 0)
|
|
24
|
-
return;
|
|
25
|
-
emit("click", e);
|
|
26
|
-
},
|
|
27
|
-
onPointerEnter: (e) => emit("enter", e),
|
|
28
|
-
onPointerLeave: (e) => emit("leave", e),
|
|
29
|
-
onPointerMove: (e) => emit("move", e),
|
|
30
|
-
onDoubleClick: (e) => emit("double-click", e),
|
|
31
|
-
onContextMenu: (e) => emit("context-menu", e),
|
|
32
|
-
};
|
|
33
|
-
}
|