@shapediver/viewer.data-engine.html-element-anchor-engine 3.3.4 → 3.3.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapediver/viewer.data-engine.html-element-anchor-engine",
3
- "version": "3.3.4",
3
+ "version": "3.3.7",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "Michael Oppitz <michael@shapediver.com>",
@@ -10,11 +10,10 @@
10
10
  "test": "__tests__"
11
11
  },
12
12
  "files": [
13
- "dist",
14
- "src",
15
13
  "package.json",
14
+ "dist/",
16
15
  "README.md",
17
- "tsconfig.json"
16
+ "LICENSE"
18
17
  ],
19
18
  "publishConfig": {
20
19
  "access": "public"
@@ -40,13 +39,13 @@
40
39
  },
41
40
  "dependencies": {
42
41
  "@shapediver/sdk.geometry-api-sdk-v2": "1.11.0",
43
- "@shapediver/viewer.data-engine.shared-types": "3.3.4",
44
- "@shapediver/viewer.shared.math": "3.3.4",
45
- "@shapediver/viewer.shared.node-tree": "3.3.4",
46
- "@shapediver/viewer.shared.services": "3.3.4",
47
- "@shapediver/viewer.shared.types": "3.3.4",
42
+ "@shapediver/viewer.data-engine.shared-types": "3.3.7",
43
+ "@shapediver/viewer.shared.math": "3.3.7",
44
+ "@shapediver/viewer.shared.node-tree": "3.3.7",
45
+ "@shapediver/viewer.shared.services": "3.3.7",
46
+ "@shapediver/viewer.shared.types": "3.3.7",
48
47
  "axios": "^1.2.6",
49
48
  "gl-matrix": "3.3.0"
50
49
  },
51
- "gitHead": "8193da527b4e3fc4d90181018bd60d6ac70be3e8"
50
+ "gitHead": "112787d5c5226cca5e89d08102d0b1a3dd4a1d71"
52
51
  }
@@ -1,130 +0,0 @@
1
- import { HTMLElementAnchorData, HTMLElementAnchorTextData, HTMLElementAnchorImageData, IAnchorDataText, IAnchorDataImage } from '@shapediver/viewer.shared.types'
2
- import { ITreeNode, TreeNode } from '@shapediver/viewer.shared.node-tree'
3
- import { Logger, Converter, ShapeDiverViewerDataProcessingError, InputValidator } from '@shapediver/viewer.shared.services'
4
- import { vec3, vec4 } from 'gl-matrix'
5
- import { Box } from '@shapediver/viewer.shared.math'
6
- import { ShapeDiverResponseOutputContent } from '@shapediver/sdk.geometry-api-sdk-v2'
7
- import { IAnchor, ITag2D } from '@shapediver/viewer.data-engine.shared-types'
8
-
9
- export class HTMLElementAnchorEngine {
10
- // #region Properties (4)
11
-
12
- private readonly _converter: Converter = Converter.instance;
13
- private readonly _inputValidator: InputValidator = InputValidator.instance;
14
- private readonly _logger: Logger = Logger.instance;
15
-
16
- private static _instance: HTMLElementAnchorEngine;
17
-
18
- // #endregion Properties (4)
19
-
20
- // #region Public Static Accessors (1)
21
-
22
- public static get instance() {
23
- return this._instance || (this._instance = new this());
24
- }
25
-
26
- // #endregion Public Static Accessors (1)
27
-
28
- // #region Public Methods (1)
29
-
30
- /**
31
- * Load the material content into a scene graph node.
32
- *
33
- * @param content the material content
34
- * @returns the scene graph node
35
- */
36
- public async loadContent(content: ShapeDiverResponseOutputContent): Promise<ITreeNode> {
37
- try {
38
- const node = new TreeNode('htmlElementAnchors');
39
- if (content.format === 'tag2d') {
40
- const data: ITag2D[] = content.data;
41
- data.forEach((element: ITag2D) => {
42
- // we need a location and a text, otherwise this doesn't make sense
43
- if (!element.location || !element.text) {
44
- this._logger.warn('HTMLElementAnchorEngine.load: One of the specified Tag2D elements did not have all necessary properties.');
45
- return;
46
- }
47
- const cleanedText = this._inputValidator.sanitize(element.text);
48
- node.data.push(new HTMLElementAnchorTextData({
49
- location: this._converter.toVec3(element.location),
50
- data: { color: element.color || '#000000', text: cleanedText }
51
- }))
52
- });
53
- } else if (content.format === 'anchor') {
54
- const data: IAnchor[] = content.data;
55
- data.forEach((element: IAnchor) => {
56
- if (!element.location || !element.data) {
57
- this._logger.warn('HTMLElementAnchorEngine.load: One of the specified Anchor elements did not have all necessary properties.');
58
- return;
59
- }
60
-
61
- let position
62
- if (element.data.position)
63
- position = {
64
- vertical: element.data.position.vertical,
65
- horizontal: element.data.position.horizontal
66
- }
67
-
68
- let intersectionTarget;
69
- if (element.intersectionTarget) {
70
- if (typeof element.intersectionTarget === 'string' || Array.isArray(element.intersectionTarget)) {
71
- intersectionTarget = element.intersectionTarget;
72
- } else if (element.intersectionTarget.min && element.intersectionTarget.max) {
73
- intersectionTarget = new Box(this._converter.toVec3(element.intersectionTarget.min), this._converter.toVec3(element.intersectionTarget.max))
74
- }
75
- }
76
-
77
- if (!element.format || (element.format === 'text')) {
78
- if (!(<IAnchorDataText>element.data).text) {
79
- this._logger.warn('HTMLElementAnchorEngine.load: The text property for an Anchor element is missing.');
80
- return;
81
- }
82
- const textData = <IAnchorDataText>element.data;
83
- const cleanedText = this._inputValidator.sanitize(textData.text);
84
-
85
- node.data.push(new HTMLElementAnchorTextData({
86
- location: this._converter.toVec3(element.location),
87
- data: {
88
- color: textData.color || '#000000',
89
- text: cleanedText,
90
- hidden: textData.hidden,
91
- textAlign: textData.textAlign,
92
- position
93
- },
94
- hideable: element.hideable,
95
- viewports: element.viewports,
96
- intersectionTarget
97
- }));
98
-
99
- } else if (element.format === 'image') {
100
- if (!(<IAnchorDataImage>element.data).src || !(<IAnchorDataImage>element.data).width || !(<IAnchorDataImage>element.data).height || !(<IAnchorDataImage>element.data).alt) {
101
- this._logger.warn('HTMLElementAnchorEngine.load: One of the specified Anchor elements did not have all necessary properties.');
102
- return;
103
- }
104
- const imageData = <IAnchorDataImage>element.data;
105
- node.data.push(new HTMLElementAnchorImageData({
106
- location: this._converter.toVec3(element.location),
107
- data: {
108
- alt: imageData.alt,
109
- height: typeof imageData.height === 'string' ? +imageData.height : imageData.height,
110
- width: typeof imageData.width === 'string' ? +imageData.width : imageData.width,
111
- src: imageData.src,
112
- hidden: imageData.hidden,
113
- position
114
- },
115
- hideable: element.hideable,
116
- viewports: element.viewports,
117
- intersectionTarget
118
- }));
119
- }
120
- this._logger.warn(`HTMLElementAnchorEngine.load: The Anchor does not have a recognized format: ${element.format}`);
121
- });
122
- }
123
- return node;
124
- } catch (e) {
125
- throw new ShapeDiverViewerDataProcessingError('HTMLElementAnchorEngine.load: Loading of anchors failed.');
126
- }
127
- }
128
-
129
- // #endregion Public Methods (1)
130
- }
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- import { HTMLElementAnchorEngine } from './HTMLElementAnchorEngine'
2
-
3
- export {
4
- HTMLElementAnchorEngine
5
- }
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "include": [
4
- "./**/*.ts"
5
- ],
6
- "compilerOptions": {
7
- "rootDir": "src",
8
- "outDir": "dist"
9
- },
10
- "exclude": [
11
- "__tests__",
12
- "node_modules",
13
- "dist",
14
- "dist-dev",
15
- "dist-prod"
16
- ]
17
- }