@equinor/videx-3d 5.1.0-beta
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/LICENSE.md +21 -0
- package/README.md +120 -0
- package/dist/chunk-BX-cez1_.js +23 -0
- package/dist/chunk-CnY6Tmof.js +358 -0
- package/dist/chunk-MFzFdEWm.js +591 -0
- package/dist/chunk-iY0wQ9Z6.js +887 -0
- package/dist/generators.js +711 -0
- package/dist/main.js +8405 -0
- package/dist/sdk.js +610 -0
- package/dist/shaderLib/color-conversion.glsl +33 -0
- package/dist/shaderLib/colors.glsl +8 -0
- package/dist/shaderLib/glyphs.glsl +78 -0
- package/dist/shaderLib/random.glsl +3 -0
- package/dist/shaderLib/remap.glsl +13 -0
- package/dist/shaderLib/render-number.glsl +74 -0
- package/dist/shaderLib/render-text.glsl +66 -0
- package/dist/shaderLib/rotation.glsl +19 -0
- package/dist/shaderLib/sdf-functions.glsl +18 -0
- package/dist/textures/normal_map.jpg +0 -0
- package/dist/types/common/color-ramps.d.ts +5 -0
- package/dist/types/common/types.d.ts +25 -0
- package/dist/types/components/Annotations/Annotations.d.ts +42 -0
- package/dist/types/components/Annotations/AnnotationsHMTL.d.ts +1 -0
- package/dist/types/components/Annotations/AnnotationsLayer.d.ts +46 -0
- package/dist/types/components/Annotations/AutoUpdate.d.ts +3 -0
- package/dist/types/components/Annotations/DefaultLabelComponent.d.ts +11 -0
- package/dist/types/components/Annotations/TestAnnotations.d.ts +12 -0
- package/dist/types/components/Annotations/annotations-renderer.d.ts +26 -0
- package/dist/types/components/Annotations/annotations-state.d.ts +88 -0
- package/dist/types/components/Annotations/helpers.d.ts +11 -0
- package/dist/types/components/Annotations/index.d.ts +8 -0
- package/dist/types/components/Annotations/types.d.ts +80 -0
- package/dist/types/components/Annotations/update-annotations.d.ts +12 -0
- package/dist/types/components/CameraTargetMarker/CameraTargetMarker.d.ts +29 -0
- package/dist/types/components/Distance/Distance.d.ts +35 -0
- package/dist/types/components/Distance/DistanceContext.d.ts +12 -0
- package/dist/types/components/Distance/index.d.ts +2 -0
- package/dist/types/components/EventEmitter/EventEmitter.d.ts +20 -0
- package/dist/types/components/EventEmitter/EventEmitterContext.d.ts +90 -0
- package/dist/types/components/EventEmitter/index.d.ts +3 -0
- package/dist/types/components/EventEmitter/picking-helper.d.ts +32 -0
- package/dist/types/components/EventEmitter/picking-material.d.ts +11 -0
- package/dist/types/components/Grids/BoxGrid/BoxGrid.d.ts +52 -0
- package/dist/types/components/Grids/Grid/Grid.d.ts +62 -0
- package/dist/types/components/Grids/Grid/GridAxesLabels.d.ts +24 -0
- package/dist/types/components/Grids/Grid/UtmGrid.d.ts +30 -0
- package/dist/types/components/Grids/Grid/grid-helpers.d.ts +2 -0
- package/dist/types/components/Grids/index.d.ts +5 -0
- package/dist/types/components/Highlighter/Highlighter.d.ts +23 -0
- package/dist/types/components/Highlighter/highlight-state.d.ts +43 -0
- package/dist/types/components/Highlighter/index.d.ts +2 -0
- package/dist/types/components/Html/DepthSelector.d.ts +1 -0
- package/dist/types/components/Html/OutputPanel/OutputPanel.d.ts +10 -0
- package/dist/types/components/Html/OutputPanel/index.d.ts +2 -0
- package/dist/types/components/Html/OutputPanel/output-panel-state.d.ts +38 -0
- package/dist/types/components/Html/Panel/Panel.d.ts +20 -0
- package/dist/types/components/Html/WellMap/ActiveTrack.d.ts +9 -0
- package/dist/types/components/Html/WellMap/DepthCursor.d.ts +8 -0
- package/dist/types/components/Html/WellMap/DepthReadout.d.ts +6 -0
- package/dist/types/components/Html/WellMap/Schematic.d.ts +15 -0
- package/dist/types/components/Html/WellMap/Track.d.ts +13 -0
- package/dist/types/components/Html/WellMap/WellMap.d.ts +47 -0
- package/dist/types/components/Html/WellMap/addons/WellMapCasingShoes.d.ts +14 -0
- package/dist/types/components/Html/WellMap/addons/WellMapCompletionIntervals.d.ts +15 -0
- package/dist/types/components/Html/WellMap/addons/WellMapFormations.d.ts +14 -0
- package/dist/types/components/Html/WellMap/addons/WellMapTvd.d.ts +14 -0
- package/dist/types/components/Html/WellMap/addons/index.d.ts +4 -0
- package/dist/types/components/Html/WellMap/index.d.ts +4 -0
- package/dist/types/components/Html/WellMap/themes.d.ts +13 -0
- package/dist/types/components/Html/WellMap/well-map-context.d.ts +34 -0
- package/dist/types/components/Html/WellMap/well-map-state.d.ts +38 -0
- package/dist/types/components/Html/index.d.ts +5 -0
- package/dist/types/components/ObservableGroup/ObservableGroup.d.ts +38 -0
- package/dist/types/components/SDFTest/SDFTest.d.ts +12 -0
- package/dist/types/components/Surfaces/Surface.d.ts +46 -0
- package/dist/types/components/Surfaces/SurfaceMaterial.d.ts +53 -0
- package/dist/types/components/Surfaces/index.d.ts +4 -0
- package/dist/types/components/Surfaces/surface-defs.d.ts +7 -0
- package/dist/types/components/Symbol/Symbol.d.ts +45 -0
- package/dist/types/components/Symbol/index.d.ts +1 -0
- package/dist/types/components/UtmArea/UtmArea.d.ts +37 -0
- package/dist/types/components/UtmArea/UtmAreaContext.d.ts +32 -0
- package/dist/types/components/UtmArea/UtmPosition.d.ts +26 -0
- package/dist/types/components/UtmArea/Wgs84Position.d.ts +26 -0
- package/dist/types/components/UtmArea/index.d.ts +4 -0
- package/dist/types/components/Wellbores/BasicTrajectory/BasicTrajectory.d.ts +27 -0
- package/dist/types/components/Wellbores/BasicTrajectory/basic-trajectory-defs.d.ts +3 -0
- package/dist/types/components/Wellbores/BasicTrajectory/index.d.ts +2 -0
- package/dist/types/components/Wellbores/Casings/CasingAnnotations/CasingAnnotations.d.ts +9 -0
- package/dist/types/components/Wellbores/Casings/CasingAnnotations/CasingLabel.d.ts +9 -0
- package/dist/types/components/Wellbores/Casings/CasingAnnotations/casing-annotations-defs.d.ts +1 -0
- package/dist/types/components/Wellbores/Casings/Casings.d.ts +42 -0
- package/dist/types/components/Wellbores/Casings/casings-defs.d.ts +6 -0
- package/dist/types/components/Wellbores/Casings/index.d.ts +5 -0
- package/dist/types/components/Wellbores/CompletionTools/CompletionAnnotations/CompletionAnnotations.d.ts +9 -0
- package/dist/types/components/Wellbores/CompletionTools/CompletionAnnotations/completion-annotations-defs.d.ts +1 -0
- package/dist/types/components/Wellbores/CompletionTools/CompletionTools.d.ts +31 -0
- package/dist/types/components/Wellbores/CompletionTools/Screen/screen-material.d.ts +8 -0
- package/dist/types/components/Wellbores/CompletionTools/completion-tools-defs.d.ts +4 -0
- package/dist/types/components/Wellbores/CompletionTools/index.d.ts +5 -0
- package/dist/types/components/Wellbores/DepthMarkers/DepthMarkerLabel.d.ts +11 -0
- package/dist/types/components/Wellbores/DepthMarkers/DepthMarkers.d.ts +27 -0
- package/dist/types/components/Wellbores/DepthMarkers/depth-markers-defs.d.ts +1 -0
- package/dist/types/components/Wellbores/DepthMarkers/index.d.ts +3 -0
- package/dist/types/components/Wellbores/FormationMarkers/FormationMarkerLabel.d.ts +10 -0
- package/dist/types/components/Wellbores/FormationMarkers/FormationMarkers.d.ts +33 -0
- package/dist/types/components/Wellbores/FormationMarkers/formation-markers-defs.d.ts +3 -0
- package/dist/types/components/Wellbores/FormationMarkers/index.d.ts +3 -0
- package/dist/types/components/Wellbores/Perforations/Perforations.d.ts +32 -0
- package/dist/types/components/Wellbores/Perforations/index.d.ts +2 -0
- package/dist/types/components/Wellbores/Perforations/perforations-defs.d.ts +3 -0
- package/dist/types/components/Wellbores/Perimeter/Perimeter.d.ts +29 -0
- package/dist/types/components/Wellbores/Perimeter/index.d.ts +2 -0
- package/dist/types/components/Wellbores/Perimeter/perimeter-defs.d.ts +3 -0
- package/dist/types/components/Wellbores/PositionMarkers/PositionMarkers.d.ts +12 -0
- package/dist/types/components/Wellbores/PositionMarkers/position-markers-defs.d.ts +3 -0
- package/dist/types/components/Wellbores/Shoes/Shoes.d.ts +34 -0
- package/dist/types/components/Wellbores/Shoes/index.d.ts +2 -0
- package/dist/types/components/Wellbores/Shoes/shoes-defs.d.ts +3 -0
- package/dist/types/components/Wellbores/TubeTrajectory/TubeTrajectory.d.ts +25 -0
- package/dist/types/components/Wellbores/TubeTrajectory/index.d.ts +2 -0
- package/dist/types/components/Wellbores/TubeTrajectory/tube-geometry-defs.d.ts +3 -0
- package/dist/types/components/Wellbores/Wellbore/Wellbore.d.ts +45 -0
- package/dist/types/components/Wellbores/Wellbore/WellboreContext.d.ts +19 -0
- package/dist/types/components/Wellbores/Wellbore/index.d.ts +2 -0
- package/dist/types/components/Wellbores/WellboreBounds/WellboreBounds.d.ts +47 -0
- package/dist/types/components/Wellbores/WellboreBounds/index.d.ts +2 -0
- package/dist/types/components/Wellbores/WellboreBounds/wellbore-bounds-defs.d.ts +1 -0
- package/dist/types/components/Wellbores/WellboreFormationColumn/WellboreFormationColumn.d.ts +30 -0
- package/dist/types/components/Wellbores/WellboreFormationColumn/index.d.ts +2 -0
- package/dist/types/components/Wellbores/WellboreFormationColumn/wellbore-formation-column-defs.d.ts +3 -0
- package/dist/types/components/Wellbores/WellboreLabel/WellboreAnnotationLabel.d.ts +10 -0
- package/dist/types/components/Wellbores/WellboreLabel/WellboreLabel.d.ts +25 -0
- package/dist/types/components/Wellbores/WellboreLabel/index.d.ts +3 -0
- package/dist/types/components/Wellbores/WellboreLabel/wellbore-label-defs.d.ts +1 -0
- package/dist/types/components/Wellbores/WellboreRibbon/WellboreRibbon.d.ts +22 -0
- package/dist/types/components/Wellbores/WellboreRibbon/WellboreRibbonContext.d.ts +16 -0
- package/dist/types/components/Wellbores/WellboreRibbon/index.d.ts +4 -0
- package/dist/types/components/Wellbores/WellboreRibbon/stripes/FormationsStripe.d.ts +30 -0
- package/dist/types/components/Wellbores/WellboreRibbon/stripes/MeasuredDepthStripe.d.ts +28 -0
- package/dist/types/components/Wellbores/WellboreSeismicSection/WellboreSeismicSection.d.ts +34 -0
- package/dist/types/components/Wellbores/WellboreSeismicSection/index.d.ts +2 -0
- package/dist/types/components/Wellbores/WellboreSeismicSection/wellbore-seismic-section-defs.d.ts +12 -0
- package/dist/types/components/Wellbores/Wells/Wells.d.ts +43 -0
- package/dist/types/components/Wellbores/Wells/index.d.ts +1 -0
- package/dist/types/contexts/DataContext.d.ts +15 -0
- package/dist/types/contexts/DataContextProvider.d.ts +33 -0
- package/dist/types/contexts/GeneratorsContext.d.ts +13 -0
- package/dist/types/contexts/GeneratorsContextProvider.d.ts +34 -0
- package/dist/types/contexts/GlyphsContext.d.ts +19 -0
- package/dist/types/contexts/GlyphsContextProvider.d.ts +29 -0
- package/dist/types/events/camera-events.d.ts +34 -0
- package/dist/types/events/depth-events.d.ts +22 -0
- package/dist/types/events/interaction-events.d.ts +7 -0
- package/dist/types/events/wellbore-events.d.ts +46 -0
- package/dist/types/generators/basic-trajectory-generator.d.ts +2 -0
- package/dist/types/generators/casing-annotations-generator.d.ts +8 -0
- package/dist/types/generators/casings-generator.d.ts +4 -0
- package/dist/types/generators/completion-annotations-generator.d.ts +7 -0
- package/dist/types/generators/completion-tools-generator.d.ts +2 -0
- package/dist/types/generators/depth-markers-generator.d.ts +3 -0
- package/dist/types/generators/formation-markers-generator.d.ts +2 -0
- package/dist/types/generators/index.d.ts +20 -0
- package/dist/types/generators/perforations-generator.d.ts +2 -0
- package/dist/types/generators/perimieter-generator.d.ts +2 -0
- package/dist/types/generators/position-markers-generator.d.ts +2 -0
- package/dist/types/generators/shoes-generator.d.ts +2 -0
- package/dist/types/generators/surface-generator.d.ts +4 -0
- package/dist/types/generators/tube-trajectory-generator.d.ts +2 -0
- package/dist/types/generators/wellbore-bounds-generator.d.ts +2 -0
- package/dist/types/generators/wellbore-formation-column-generator.d.ts +2 -0
- package/dist/types/generators/wellbore-label-generator.d.ts +7 -0
- package/dist/types/generators/wellbore-seismic-section-generator.d.ts +3 -0
- package/dist/types/hooks/useData.d.ts +25 -0
- package/dist/types/hooks/useGenerator.d.ts +43 -0
- package/dist/types/hooks/useWellboreContext.d.ts +13 -0
- package/dist/types/layers/layers.d.ts +6 -0
- package/dist/types/main.d.ts +48 -0
- package/dist/types/rendering/fullscreen-renderer.d.ts +9 -0
- package/dist/types/rendering/index.d.ts +2 -0
- package/dist/types/rendering/render-passes.d.ts +16 -0
- package/dist/types/sdk/data/DataLoader.d.ts +54 -0
- package/dist/types/sdk/data/GeneratorRegistry.d.ts +15 -0
- package/dist/types/sdk/data/Store.d.ts +29 -0
- package/dist/types/sdk/data/helpers/formations-helpers.d.ts +24 -0
- package/dist/types/sdk/data/helpers/well-helpers.d.ts +9 -0
- package/dist/types/sdk/data/types/Casing.d.ts +8 -0
- package/dist/types/sdk/data/types/CompletionTool.d.ts +11 -0
- package/dist/types/sdk/data/types/DepthReferencePoint.d.ts +1 -0
- package/dist/types/sdk/data/types/Formation.d.ts +32 -0
- package/dist/types/sdk/data/types/PerforationInterval.d.ts +9 -0
- package/dist/types/sdk/data/types/Pick.d.ts +8 -0
- package/dist/types/sdk/data/types/PositionLog.d.ts +17 -0
- package/dist/types/sdk/data/types/StratColumn.d.ts +18 -0
- package/dist/types/sdk/data/types/SurfaceMeta.d.ts +23 -0
- package/dist/types/sdk/data/types/SurfaceValues.d.ts +1 -0
- package/dist/types/sdk/data/types/Symbol.d.ts +6 -0
- package/dist/types/sdk/data/types/VerticalSlice.d.ts +9 -0
- package/dist/types/sdk/data/types/WellboreHeader.d.ts +15 -0
- package/dist/types/sdk/data/types/index.d.ts +11 -0
- package/dist/types/sdk/geometries/curve/curve-3d.d.ts +46 -0
- package/dist/types/sdk/geometries/curve/tube-geometry.d.ts +34 -0
- package/dist/types/sdk/geometries/delatin.d.ts +44 -0
- package/dist/types/sdk/geometries/fence.d.ts +3 -0
- package/dist/types/sdk/geometries/packing.d.ts +46 -0
- package/dist/types/sdk/geometries/triangulate-grid-delaunay.d.ts +8 -0
- package/dist/types/sdk/geometries/triangulate-grid.d.ts +28 -0
- package/dist/types/sdk/index.d.ts +39 -0
- package/dist/types/sdk/managers/CameraManager.d.ts +11 -0
- package/dist/types/sdk/managers/WellboreManager.d.ts +18 -0
- package/dist/types/sdk/materials/depth-material.d.ts +4 -0
- package/dist/types/sdk/materials/ribbon-material.d.ts +24 -0
- package/dist/types/sdk/materials/tube-material.d.ts +7 -0
- package/dist/types/sdk/materials/uv-material.d.ts +2 -0
- package/dist/types/sdk/projection/crs.d.ts +37 -0
- package/dist/types/sdk/types/common.d.ts +4 -0
- package/dist/types/sdk/utils/array.d.ts +0 -0
- package/dist/types/sdk/utils/colors.d.ts +2 -0
- package/dist/types/sdk/utils/conversions.d.ts +5 -0
- package/dist/types/sdk/utils/depth-reader.d.ts +5 -0
- package/dist/types/sdk/utils/elevation-map.d.ts +15 -0
- package/dist/types/sdk/utils/glyphs.d.ts +50 -0
- package/dist/types/sdk/utils/irapbin-parser.d.ts +17 -0
- package/dist/types/sdk/utils/num-array.d.ts +2 -0
- package/dist/types/sdk/utils/numbers.d.ts +5 -0
- package/dist/types/sdk/utils/packing.d.ts +1 -0
- package/dist/types/sdk/utils/scene.d.ts +2 -0
- package/dist/types/sdk/utils/segments.d.ts +4 -0
- package/dist/types/sdk/utils/strings.d.ts +2 -0
- package/dist/types/sdk/utils/trajectory.d.ts +59 -0
- package/dist/types/sdk/utils/trigonometry.d.ts +12 -0
- package/dist/types/sdk/utils/typed-2d-array.d.ts +52 -0
- package/dist/types/sdk/utils/typed-array.d.ts +2 -0
- package/dist/types/sdk/utils/vector-operations.d.ts +29 -0
- package/package.json +127 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
uniform vec2 size;
|
|
2
|
+
uniform sampler2D glyphAtlas;
|
|
3
|
+
|
|
4
|
+
uniform float in_bias;
|
|
5
|
+
uniform float out_bias;
|
|
6
|
+
|
|
7
|
+
uniform GlyphData {
|
|
8
|
+
vec4 glyphPosition[GLYPHS_LENGTH];
|
|
9
|
+
vec3 glyphOffset[GLYPHS_LENGTH];
|
|
10
|
+
vec2 glyphTextureSize;
|
|
11
|
+
float glyphFontSize;
|
|
12
|
+
float glyphPixelRange;
|
|
13
|
+
float glyphLineHeight;
|
|
14
|
+
float glyphBaseLine;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//varying vec2 vUv;
|
|
18
|
+
|
|
19
|
+
struct GlyphParams {
|
|
20
|
+
vec2 position;
|
|
21
|
+
uint index;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
uint _numDigits(float number) {
|
|
25
|
+
float log10 = 0.4342944819032518 * log(number);
|
|
26
|
+
return uint(max(trunc(log10), 0.0) + 1.0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
uint _getDigit(float number, uint position) {
|
|
30
|
+
return uint(trunc(mod(number / pow(10.0, float(position - 1u)), 10.0)));
|
|
31
|
+
//return uint(floor(fract(number / pow(10.0, float(position))) * 10.0));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
float _median(float r, float g, float b) {
|
|
35
|
+
return max(min(r, g), min(max(r, g), b));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
vec2 _calcGlyphUv(vec2 texPos) {
|
|
39
|
+
vec2 glyphUv = vec2(texPos.x / glyphTextureSize.x, (glyphTextureSize.y - texPos.y) / glyphTextureSize.y);
|
|
40
|
+
|
|
41
|
+
return clamp(glyphUv, 0.0, 1.0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
float _calculateGlyphVerticalOffset(float vAlign) {
|
|
45
|
+
float pxRangeOffset = floor(glyphPixelRange / 2.0);
|
|
46
|
+
float lineHightOffset = glyphLineHeight / 2.0;
|
|
47
|
+
float vAlignOffset = (glyphFontSize / 2.0) * vAlign;
|
|
48
|
+
//float vAlignOffset = vAlign != 0.0 ? mix(mix(BOTTOM, 0.0, vAlign + 1.0), mix(0.0, TOP, vAlign), step(0.0, vAlign)) : 0.0;
|
|
49
|
+
return lineHightOffset + pxRangeOffset + vAlignOffset;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
float _screenPixelRange(float scale) {
|
|
53
|
+
vec2 scaledSize = size * scale;
|
|
54
|
+
vec2 screenPxRange = glyphPixelRange / fwidth(vUv * scaledSize);
|
|
55
|
+
return max(min(screenPxRange.x, screenPxRange.y), 1.0);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
float _sdfGlyph(vec2 p, uint glyphId) {
|
|
59
|
+
vec2 offset = vec2(p.x - glyphOffset[glyphId].x, p.y - glyphOffset[glyphId].y);
|
|
60
|
+
vec2 uv = glyphPosition[glyphId].xy + offset;
|
|
61
|
+
float sigDist = -0.5;
|
|
62
|
+
|
|
63
|
+
if(offset.x >= 0.0 && offset.y >= 0.0 && offset.x <= glyphPosition[glyphId].z && offset.y <= glyphPosition[glyphId].w) {
|
|
64
|
+
vec2 TexCoord = _calcGlyphUv(uv);
|
|
65
|
+
vec3 mdf = texture2D(glyphAtlas, TexCoord).rgb;
|
|
66
|
+
sigDist = _median(mdf.r, mdf.g, mdf.b);
|
|
67
|
+
}
|
|
68
|
+
return sigDist;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void renderGlyph(inout vec3 outColor, vec2 position, uint glyphId, vec3 glyphColor, float pxRange) {
|
|
72
|
+
float dist = _sdfGlyph(position, glyphId);
|
|
73
|
+
float e = pxRange * (dist - 0.5 + in_bias) + 0.5 + out_bias;
|
|
74
|
+
|
|
75
|
+
float contour = clamp(e, 0.0, 1.0);
|
|
76
|
+
|
|
77
|
+
outColor = mix(outColor, glyphColor, contour);
|
|
78
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
float inverseLerp(float v, float minValue, float maxValue) {
|
|
2
|
+
return (v - minValue) / (maxValue - minValue);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
float remap(float v, float inMin, float inMax, float outMin, float outMax) {
|
|
6
|
+
float t = inverseLerp(v, inMin, inMax);
|
|
7
|
+
return mix(outMin, outMax, t);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
float inverseSmoothstep(float y)
|
|
11
|
+
{
|
|
12
|
+
return 0.5 - sin(asin(1.0- 2.0 * y) / 3.0);
|
|
13
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
uniform uint digits[12];
|
|
2
|
+
|
|
3
|
+
float renderNumber(
|
|
4
|
+
inout vec3 outColor,
|
|
5
|
+
vec2 position,
|
|
6
|
+
float number,
|
|
7
|
+
uint decimals,
|
|
8
|
+
float verticalAlign,
|
|
9
|
+
float horizontalAlign,
|
|
10
|
+
vec3 textColor,
|
|
11
|
+
float spacing,
|
|
12
|
+
float scale
|
|
13
|
+
) {
|
|
14
|
+
|
|
15
|
+
float width = 0.0;
|
|
16
|
+
float totalWidth = 0.0;
|
|
17
|
+
float offset = 0.0;
|
|
18
|
+
|
|
19
|
+
// store glyphId and width during calculation of total width so we don't need to re-calculate these values
|
|
20
|
+
uvec2 temp[30];
|
|
21
|
+
|
|
22
|
+
uint glyphId;
|
|
23
|
+
uint nDigits;
|
|
24
|
+
|
|
25
|
+
vec2 pos = position.xy;
|
|
26
|
+
uint c = 0u;
|
|
27
|
+
|
|
28
|
+
if (number < 0.0) {
|
|
29
|
+
glyphId = digits[11];
|
|
30
|
+
width = glyphOffset[glyphId].z + spacing;
|
|
31
|
+
offset = width;
|
|
32
|
+
temp[c++] = uvec2(glyphId, width);
|
|
33
|
+
number = -number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
float intPart;
|
|
37
|
+
float fractPart = modf(number, intPart);
|
|
38
|
+
fractPart *= pow(10.0, float(decimals));
|
|
39
|
+
nDigits = _numDigits(intPart);
|
|
40
|
+
|
|
41
|
+
for(uint n = 0u; n < nDigits; n++) {
|
|
42
|
+
glyphId = digits[_getDigit(intPart, nDigits - n)];
|
|
43
|
+
width = glyphOffset[glyphId].z + spacing;
|
|
44
|
+
temp[c++] = uvec2(glyphId, width);
|
|
45
|
+
totalWidth += width;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if(decimals > 0u) {
|
|
49
|
+
glyphId = digits[10];
|
|
50
|
+
width = glyphOffset[glyphId].z + spacing;
|
|
51
|
+
temp[c++] = uvec2(glyphId, width);
|
|
52
|
+
totalWidth += width;
|
|
53
|
+
|
|
54
|
+
nDigits = _numDigits(fractPart);
|
|
55
|
+
for(uint n = 0u; n < decimals; n++) {
|
|
56
|
+
glyphId = digits[_getDigit(fractPart, nDigits - n)];
|
|
57
|
+
width = glyphOffset[glyphId].z + spacing;
|
|
58
|
+
temp[c++] = uvec2(glyphId, width);
|
|
59
|
+
totalWidth += width;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if(c > 0u) {
|
|
64
|
+
pos.x += (totalWidth - spacing) * horizontalAlign + offset;
|
|
65
|
+
pos.y += _calculateGlyphVerticalOffset(verticalAlign);
|
|
66
|
+
|
|
67
|
+
uint n = 0u;
|
|
68
|
+
|
|
69
|
+
while (n < c && pos.x > float(temp[n].y)) pos.x -= float(temp[n++].y);
|
|
70
|
+
if (n < c) renderGlyph(outColor, pos, temp[n].x, textColor, _screenPixelRange(scale));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return totalWidth;
|
|
74
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
uniform usampler2D textTexture;
|
|
2
|
+
uniform uint textPointersCount;
|
|
3
|
+
uniform uint textPointersOffset;
|
|
4
|
+
|
|
5
|
+
uint _readGlyphIdFromTexture(uint index) {
|
|
6
|
+
uint value = texelFetch(textTexture, ivec2(index, 0), 0).r;
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
GlyphParams _findGlyph(vec2 pixelCoords, uvec3 textPointer, float spacing) {
|
|
11
|
+
|
|
12
|
+
uint id = _readGlyphIdFromTexture(textPointer.x);
|
|
13
|
+
float width = glyphOffset[id].z + spacing;
|
|
14
|
+
vec2 position = pixelCoords.xy;
|
|
15
|
+
|
|
16
|
+
uint i = textPointer.x;
|
|
17
|
+
|
|
18
|
+
while(position.x >= width && i++ < textPointer.y - 1u) {
|
|
19
|
+
position.x -= width;
|
|
20
|
+
uint j = _readGlyphIdFromTexture(i);
|
|
21
|
+
|
|
22
|
+
id = j;
|
|
23
|
+
width = glyphOffset[id].z + spacing;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return GlyphParams(position, id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
uvec3 readTextPointerFromTexture(uint index) {
|
|
30
|
+
uvec3 pointer = uvec3(0u);
|
|
31
|
+
uint pos = (index * 3u) + textPointersOffset;
|
|
32
|
+
pointer.x = texelFetch(textTexture, ivec2(pos, 0), 0).r;
|
|
33
|
+
pointer.y = texelFetch(textTexture, ivec2(pos + 1u, 0), 0).r;
|
|
34
|
+
pointer.z = texelFetch(textTexture, ivec2(pos + 2u, 0), 0).r;
|
|
35
|
+
|
|
36
|
+
return pointer;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void renderText(
|
|
40
|
+
inout vec3 outColor,
|
|
41
|
+
vec2 position,
|
|
42
|
+
uvec3 textPointer,
|
|
43
|
+
float verticalAlign,
|
|
44
|
+
float horizontalAlign,
|
|
45
|
+
vec3 textColor,
|
|
46
|
+
float spacing,
|
|
47
|
+
float scale
|
|
48
|
+
) {
|
|
49
|
+
// do nothing if the text widht is 0
|
|
50
|
+
if(textPointer.z == 0u)
|
|
51
|
+
return;
|
|
52
|
+
|
|
53
|
+
float spacingWidth = spacing * float(textPointer.y - textPointer.x - 1u);
|
|
54
|
+
position.x += (float(textPointer.z) + spacingWidth) * horizontalAlign;
|
|
55
|
+
|
|
56
|
+
//if (position.y > glyphLineHeight / 2.0 || position.y < -glyphLineHeight / 2.0) return;
|
|
57
|
+
|
|
58
|
+
vec2 pos = position;
|
|
59
|
+
pos.y += _calculateGlyphVerticalOffset(verticalAlign);
|
|
60
|
+
|
|
61
|
+
if(pos.x < 0.0)
|
|
62
|
+
return;
|
|
63
|
+
|
|
64
|
+
GlyphParams params = _findGlyph(pos, textPointer, spacing);
|
|
65
|
+
renderGlyph(outColor, params.position, params.index, textColor, _screenPixelRange(scale));
|
|
66
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
mat2 rotation2d(float angle) {
|
|
2
|
+
float s = sin(angle);
|
|
3
|
+
float c = cos(angle);
|
|
4
|
+
return mat2(c, -s, s, c);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
mat4 rotation3d(vec3 axis, float angle) {
|
|
8
|
+
axis = normalize(axis);
|
|
9
|
+
float s = sin(angle);
|
|
10
|
+
float c = cos(angle);
|
|
11
|
+
float oc = 1.0 - c;
|
|
12
|
+
|
|
13
|
+
return mat4(
|
|
14
|
+
oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
|
|
15
|
+
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
|
|
16
|
+
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
|
|
17
|
+
0.0, 0.0, 0.0, 1.0
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SDF functions
|
|
2
|
+
|
|
3
|
+
float sdfLine(vec2 p, vec2 a, vec2 b) {
|
|
4
|
+
vec2 pa = p - a;
|
|
5
|
+
vec2 ba = b - a;
|
|
6
|
+
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
|
|
7
|
+
|
|
8
|
+
return length(pa - ba * h);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
float sdfBox(vec2 p, vec2 b) {
|
|
12
|
+
vec2 d = abs(p) - b;
|
|
13
|
+
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
float sdfCircle(vec2 p, float r) {
|
|
17
|
+
return length(p) - r;
|
|
18
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CanvasTexture } from 'three';
|
|
2
|
+
export type RampFunction = (ctx: CanvasRenderingContext2D, y: number) => void;
|
|
3
|
+
export declare function createColorRamps(ramps: RampFunction[], width: number): HTMLCanvasElement;
|
|
4
|
+
export declare const colorRamps: RampFunction[];
|
|
5
|
+
export declare const colorRampTexture: CanvasTexture<HTMLCanvasElement>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Layers } from '@react-three/fiber';
|
|
2
|
+
import { Material } from 'three';
|
|
3
|
+
import { Vec3 } from '../sdk';
|
|
4
|
+
/**
|
|
5
|
+
* Common props for 3d components
|
|
6
|
+
*/
|
|
7
|
+
export type CommonComponentProps = {
|
|
8
|
+
name?: string;
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
userData?: Record<string, any>;
|
|
11
|
+
position?: Vec3;
|
|
12
|
+
castShadow?: boolean;
|
|
13
|
+
receiveShadow?: boolean;
|
|
14
|
+
renderOrder?: number;
|
|
15
|
+
layers?: Layers;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Common props for 3d components that allow overriding shader materials
|
|
19
|
+
*/
|
|
20
|
+
export type CustomMaterialProps = {
|
|
21
|
+
customMaterial?: Material | Material[];
|
|
22
|
+
customDepthMaterial?: Material;
|
|
23
|
+
customDistanceMaterial?: Material;
|
|
24
|
+
onMaterialPropertiesChange?: (props: Record<string, any>, material: Material | Material[]) => void;
|
|
25
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Annotations provider component props
|
|
4
|
+
* @expand
|
|
5
|
+
*/
|
|
6
|
+
export type AnnotationsProviderProps = {
|
|
7
|
+
autoUpdate?: boolean;
|
|
8
|
+
maxVisible?: number;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The Annotations component is special provider component responsible for managing
|
|
13
|
+
* and updating annotation layers and instances.
|
|
14
|
+
*
|
|
15
|
+
* It allow you to register layers, using the AnnotationLayer component, and set a
|
|
16
|
+
* global max visible annotations.
|
|
17
|
+
*
|
|
18
|
+
* Annotations adds point-feature labeling support, where labels are rendered as
|
|
19
|
+
* regular React HTML components. Anchors and connector lines are drawn to the frame buffer
|
|
20
|
+
* after the 3D scene frame is completed.
|
|
21
|
+
*
|
|
22
|
+
* Annotations are processed globally to support label collision, occlusion and
|
|
23
|
+
* ordering tests. Priority and visibillity distances can be set in the AnnotationLayer
|
|
24
|
+
* component and/or int the individual annotation elements.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* <Annotations>
|
|
28
|
+
* <AnnotationLayer id="casings_annotations" name="Casing Annotations" />
|
|
29
|
+
* </Annotations>
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* This component sets up a global state and takes control over the render loop!
|
|
33
|
+
* It's therefore important that only a single instance of this component is mounted
|
|
34
|
+
* at any time in your project. Using this compoent with an EffectsComposer may cause issues,
|
|
35
|
+
* and we will likely convert it from being a component into being a post-processing pass at some point.
|
|
36
|
+
*
|
|
37
|
+
* @see [Storybook](/videx-3d/?path=/docs/components-misc-annotations--docs)
|
|
38
|
+
* @see {@link AnnotationsLayer}
|
|
39
|
+
*
|
|
40
|
+
* @group Components
|
|
41
|
+
*/
|
|
42
|
+
export declare const Annotations: ({ maxVisible, autoUpdate, children, }: AnnotationsProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AnnotationsHTML: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { AnnotationLayer } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* AnnotationsLayer props
|
|
5
|
+
* @expand
|
|
6
|
+
*/
|
|
7
|
+
export type AnnotationsLayerProps = Partial<AnnotationLayer> & {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Use the AnnotationsLayer component to register and configure a layer for adding
|
|
13
|
+
* annotations. This needs to be added as a child of the `Annotations` component.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* <Annotations>
|
|
17
|
+
* <AnnotationsLayer
|
|
18
|
+
* id="wellbore-labels"
|
|
19
|
+
* name="Wellbore Labels"
|
|
20
|
+
* priority={4}
|
|
21
|
+
* anchorSize={5}
|
|
22
|
+
* anchorColor='cyan'
|
|
23
|
+
* connectorWidth={1.5}
|
|
24
|
+
* distanceFactor={1000}
|
|
25
|
+
* labelOffset={50}
|
|
26
|
+
* minDistance={1}
|
|
27
|
+
* maxDistance={10000}
|
|
28
|
+
* anchorOcclusionRadius={20}
|
|
29
|
+
* labelComponent={WellboreAnnotationLabel}
|
|
30
|
+
* onClick={(annotation: AnnotationComponentProps) => {
|
|
31
|
+
* dispatchEvent(new CameraFocusAtPointEvent({ point: annotation.position, distance: 500 }))
|
|
32
|
+
* }}
|
|
33
|
+
* />
|
|
34
|
+
* </Annotations>
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* The AnnotationsLayer component is for adding and configuring a layer. Annotations are added to a layer
|
|
38
|
+
* using the `useAnnotations` hook with a layer id and a user defined scope.
|
|
39
|
+
*
|
|
40
|
+
* @see [Storybook](/videx-3d/?path=/docs/components-misc-annotations--docs)
|
|
41
|
+
* @see {@link Annotations}
|
|
42
|
+
* @see {@link useAnnotations}
|
|
43
|
+
*
|
|
44
|
+
* @group Components
|
|
45
|
+
*/
|
|
46
|
+
export declare const AnnotationsLayer: ({ id, name, priority, visible, distanceFactor, minDistance, maxDistance, anchorOcclusionRadius, anchorSize, anchorColor, connectorWidth, connectorColor, labelOffset, labelComponent, onClick, children, }: PropsWithChildren<AnnotationsLayerProps>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AnnotationComponentProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The default component for rendering annotation labels. You can override this by
|
|
4
|
+
* supplying a custom component in the `AnnotationsLayer` component.
|
|
5
|
+
*
|
|
6
|
+
* @see [Storybook](/path=/docs/components-misc-annotations--docs)
|
|
7
|
+
* @see {@link AnnotationsLayer}
|
|
8
|
+
*
|
|
9
|
+
* @group Components
|
|
10
|
+
*/
|
|
11
|
+
export declare const DefaultLabelComponent: ({ id, name, }: AnnotationComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Vec3 } from '../../sdk';
|
|
2
|
+
type Props = {
|
|
3
|
+
layer: string;
|
|
4
|
+
count?: number;
|
|
5
|
+
position?: Vec3;
|
|
6
|
+
radius?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @interal for testing purposes
|
|
10
|
+
*/
|
|
11
|
+
export declare const TestAnnotations: ({ layer, count, radius, position, }: Props) => null;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Camera, CanvasTexture, Clock, PerspectiveCamera, ShaderMaterial, Vector2, WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
2
|
+
import { FullscreenRenderer } from '../../rendering/fullscreen-renderer';
|
|
3
|
+
import { AnnotationInstance } from './types';
|
|
4
|
+
export declare class AnnotationsRenderer {
|
|
5
|
+
maxVisible: number;
|
|
6
|
+
camera: PerspectiveCamera;
|
|
7
|
+
clock: Clock;
|
|
8
|
+
pointer: Vector2;
|
|
9
|
+
ctx: CanvasRenderingContext2D;
|
|
10
|
+
overlayTexture: CanvasTexture | null;
|
|
11
|
+
annotationsTexSize: number;
|
|
12
|
+
annotationsRenderTarget: WebGLRenderTarget;
|
|
13
|
+
annotationsBuffer: Uint8Array;
|
|
14
|
+
annotationsMaterial: ShaderMaterial;
|
|
15
|
+
fullscreenRenderer: FullscreenRenderer;
|
|
16
|
+
annotationsData: AnnotationInstance[];
|
|
17
|
+
isBusy: boolean;
|
|
18
|
+
dataTextureNeedsUpdate: boolean;
|
|
19
|
+
unsubscribeListeners: () => void;
|
|
20
|
+
constructor(camera: Camera, clock: Clock, pointer: Vector2, maxVisible?: number);
|
|
21
|
+
updateAnnotationsData(buffer: Uint8Array): void;
|
|
22
|
+
updateOverlayTexture(inViewSpace: AnnotationInstance[]): void;
|
|
23
|
+
updateDataTexture(): void;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
render(renderer: WebGLRenderer, buffer: WebGLRenderTarget | null): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AnnotationInstance, AnnotationLayer, AnnotationProps } from './types';
|
|
2
|
+
export type AnnotationsState = {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
update: {
|
|
5
|
+
required: boolean;
|
|
6
|
+
ref: ReturnType<typeof setTimeout> | null;
|
|
7
|
+
setRef: (v: ReturnType<typeof setTimeout>) => void;
|
|
8
|
+
};
|
|
9
|
+
layers: Record<string, AnnotationLayer>;
|
|
10
|
+
annotations: Record<string, AnnotationProps[]>;
|
|
11
|
+
instances: AnnotationInstance[];
|
|
12
|
+
toggleVisibility: () => void;
|
|
13
|
+
clear: () => void;
|
|
14
|
+
createLayer: (newLayer: AnnotationLayer) => () => void;
|
|
15
|
+
updateLayer: (id: string, updatedLayer: Partial<AnnotationLayer>) => void;
|
|
16
|
+
layerExist: (id: string) => boolean;
|
|
17
|
+
addLayerAnnotations: (layerId: string, scope: string, annotations: AnnotationProps[]) => void;
|
|
18
|
+
removeLayerAnnotations: (layerId: string, scope?: string) => void;
|
|
19
|
+
setInstances: (newInstances: AnnotationInstance[]) => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Get access to annotations global state.
|
|
23
|
+
* This is used internally and should not be used by other components. Use the `useAnnotations` hook instead.
|
|
24
|
+
* @internal
|
|
25
|
+
*
|
|
26
|
+
* @see {@link useAnnotations}
|
|
27
|
+
*
|
|
28
|
+
* @group Hooks
|
|
29
|
+
*/
|
|
30
|
+
export declare const useAnnotationsState: import('zustand').UseBoundStore<Omit<import('zustand').StoreApi<AnnotationsState>, "subscribe"> & {
|
|
31
|
+
subscribe: {
|
|
32
|
+
(listener: (selectedState: AnnotationsState, previousSelectedState: AnnotationsState) => void): () => void;
|
|
33
|
+
<U>(selector: (state: AnnotationsState) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
34
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
35
|
+
fireImmediately?: boolean;
|
|
36
|
+
} | undefined): () => void;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* This hook allow you to add annotations to an exisiting `AnnotationsLayer`.
|
|
41
|
+
* A scope is a user defined string, which should uniquely tie the added anotations to your component.
|
|
42
|
+
* If your annotations belong to a specific wellbore, the wellbore name or id would work well as a scope.
|
|
43
|
+
*
|
|
44
|
+
* A single function `addAnnotations` is returned, which you can call from within a `useEffect`
|
|
45
|
+
* hook to set annotations. Annotations must be an array of `AnnotationProps`.
|
|
46
|
+
* The `addAnnotations` function will return a dispose function when invoked, which you should
|
|
47
|
+
* call within the effect dispose function.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* const { addAnnotations } = useAnnotations('casings', scope)
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* Note that annotation positions needs to be in world space. You can optionally provide a matrixWorld to
|
|
54
|
+
* the annotation props that can be used to transform the local postion to world position. In the components
|
|
55
|
+
* using annotations, this is done by rendering a "dummy" Object3D and passing its matrixWorld instance to the
|
|
56
|
+
* annotation props.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* useEffect(() => {
|
|
60
|
+
* let dispose: (() => void) | null = null
|
|
61
|
+
* if (generator && id) {
|
|
62
|
+
* const v = new Vector3()
|
|
63
|
+
* generator(id).then(response => {
|
|
64
|
+
* if (response && positionRef.current) {
|
|
65
|
+
* response.forEach((d, i) => {
|
|
66
|
+
* v.set(...d.position)
|
|
67
|
+
* positionRef.current.localToWorld(v)
|
|
68
|
+
* d.position = v.toArray()
|
|
69
|
+
* d.id = i.toString()
|
|
70
|
+
* })
|
|
71
|
+
* dispose = addAnnotations(response || [])
|
|
72
|
+
* }
|
|
73
|
+
* })
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* return () => {
|
|
77
|
+
* if (dispose) dispose()
|
|
78
|
+
* }
|
|
79
|
+
* }, [addAnnotations, id, generator, positionRef])
|
|
80
|
+
*
|
|
81
|
+
* @see {@link AnnotationsLayer}
|
|
82
|
+
* @see {@link Annotations}
|
|
83
|
+
*
|
|
84
|
+
* @group Hooks
|
|
85
|
+
*/
|
|
86
|
+
export declare const useAnnotations: (layer: string, scope: string) => {
|
|
87
|
+
addAnnotations: (annotations: AnnotationProps[]) => (() => void) | undefined;
|
|
88
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PerspectiveCamera } from 'three';
|
|
2
|
+
import { Vec2, Vec3 } from '../../sdk';
|
|
3
|
+
export declare const labelAngles: number[];
|
|
4
|
+
/**
|
|
5
|
+
* 0 = [-] annotation is pointing approx. horizontally
|
|
6
|
+
* 1 = [/] annotation is pointing approx. diagonally (from lower left to upper right)
|
|
7
|
+
* 2 = [|] annotation is pointing approx. vertically
|
|
8
|
+
* 3 = [\] annotation is pointing approx. diagonally (from upper left to lower right)
|
|
9
|
+
*/
|
|
10
|
+
export declare const labelAnglesMap: number[][];
|
|
11
|
+
export declare const getLabelQuadrant: (originScreen: Vec2, origin3d: Vec3, direction3d: Vec3, camera: PerspectiveCamera) => number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Vec3 } from '../../sdk';
|
|
2
|
+
import { AnnotationProps } from './types';
|
|
3
|
+
export * from './Annotations';
|
|
4
|
+
export * from './annotations-renderer';
|
|
5
|
+
export * from './annotations-state';
|
|
6
|
+
export * from './AnnotationsLayer';
|
|
7
|
+
export * from './types';
|
|
8
|
+
export declare const getAnnotationPosition: (annotation: AnnotationProps) => Vec3;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { Matrix4 } from 'three';
|
|
3
|
+
import { Vec2, Vec3 } from '../../sdk';
|
|
4
|
+
export type AnnotationProps = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
position: Vec3;
|
|
8
|
+
matrixWorld?: Matrix4;
|
|
9
|
+
scope?: string;
|
|
10
|
+
data?: any;
|
|
11
|
+
priority?: number;
|
|
12
|
+
direction?: Vec3;
|
|
13
|
+
};
|
|
14
|
+
export type AnnotationComponentProps = AnnotationProps & {
|
|
15
|
+
instanceId: string;
|
|
16
|
+
};
|
|
17
|
+
export type AnnotationLayer = {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
visible: boolean;
|
|
21
|
+
priority: number;
|
|
22
|
+
distanceFactor: number;
|
|
23
|
+
minDistance: number;
|
|
24
|
+
maxDistance: number;
|
|
25
|
+
labelOffset: number;
|
|
26
|
+
anchorOcclusionRadius: number;
|
|
27
|
+
anchorSize: number;
|
|
28
|
+
anchorColor: string;
|
|
29
|
+
connectorWidth: number;
|
|
30
|
+
connectorColor: string;
|
|
31
|
+
onClick?: (annotation: AnnotationComponentProps) => void;
|
|
32
|
+
labelComponent?: (props: AnnotationComponentProps) => React.JSX.Element;
|
|
33
|
+
};
|
|
34
|
+
export type AnnotationInstanceState = {
|
|
35
|
+
visible: boolean;
|
|
36
|
+
health: number;
|
|
37
|
+
distance: number;
|
|
38
|
+
position: Vec3;
|
|
39
|
+
inViewSpace?: boolean;
|
|
40
|
+
occluded?: boolean;
|
|
41
|
+
inTransition?: boolean;
|
|
42
|
+
transitionTime?: number;
|
|
43
|
+
quadrant?: number;
|
|
44
|
+
positionSlot?: number;
|
|
45
|
+
screenPosition: Vec2;
|
|
46
|
+
labelPosition?: Vec2;
|
|
47
|
+
scaledOffset?: Vec2;
|
|
48
|
+
anchorPosition?: Vec2;
|
|
49
|
+
prevAnchorPosition?: Vec2;
|
|
50
|
+
prevLabelPosition?: Vec2;
|
|
51
|
+
prevQuadrant?: number;
|
|
52
|
+
scaleFactor?: number;
|
|
53
|
+
labelHovered?: boolean;
|
|
54
|
+
boost?: boolean;
|
|
55
|
+
kill?: boolean;
|
|
56
|
+
cooldown?: number;
|
|
57
|
+
opacity?: number;
|
|
58
|
+
labelWidht: number;
|
|
59
|
+
labelHeight: number;
|
|
60
|
+
labelX?: number;
|
|
61
|
+
labelY?: number;
|
|
62
|
+
anchorX?: number;
|
|
63
|
+
anchorY?: number;
|
|
64
|
+
zIndex: number;
|
|
65
|
+
capped?: boolean;
|
|
66
|
+
_visibility?: string;
|
|
67
|
+
_opacity?: string;
|
|
68
|
+
_zIndex?: string;
|
|
69
|
+
_transform?: string;
|
|
70
|
+
_needsUpdate?: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type AnnotationInstance = {
|
|
73
|
+
id: string;
|
|
74
|
+
ref: RefObject<HTMLDivElement | null> | null;
|
|
75
|
+
layer: AnnotationLayer;
|
|
76
|
+
annotation: AnnotationProps;
|
|
77
|
+
priority: number;
|
|
78
|
+
rank: number;
|
|
79
|
+
state: AnnotationInstanceState;
|
|
80
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Clock, PerspectiveCamera } from 'three';
|
|
2
|
+
import { Vec2 } from '../../sdk';
|
|
3
|
+
import { AnnotationInstance } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* PRE-PROCESS INSTANCES
|
|
6
|
+
*/
|
|
7
|
+
export declare function preprocessInstances(instances: AnnotationInstance[], camera: PerspectiveCamera, clock: Clock, maxVisible: number): AnnotationInstance[];
|
|
8
|
+
/**
|
|
9
|
+
* POST PROCESS INSTANCES
|
|
10
|
+
*/
|
|
11
|
+
export declare function postProcessInstances(instances: AnnotationInstance[], size: Vec2): void;
|
|
12
|
+
export declare function updateInstanceDOMElements(instances: AnnotationInstance[]): void;
|