@shapediver/viewer.shared.types 2.6.4 → 2.7.0

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.
Files changed (63) hide show
  1. package/LICENSE +2 -2
  2. package/dist/implementation/data/GeometryData.d.ts +2 -3
  3. package/dist/implementation/data/GeometryData.d.ts.map +1 -1
  4. package/dist/implementation/data/GeometryData.js +49 -21
  5. package/dist/implementation/data/GeometryData.js.map +1 -1
  6. package/dist/implementation/material/AbstractMaterialData.d.ts +5 -4
  7. package/dist/implementation/material/AbstractMaterialData.d.ts.map +1 -1
  8. package/dist/implementation/material/AbstractMaterialData.js.map +1 -1
  9. package/dist/implementation/material/MapData.d.ts +3 -2
  10. package/dist/implementation/material/MapData.d.ts.map +1 -1
  11. package/dist/implementation/material/MapData.js.map +1 -1
  12. package/dist/implementation/material/MaterialGemData.d.ts +5 -4
  13. package/dist/implementation/material/MaterialGemData.d.ts.map +1 -1
  14. package/dist/implementation/material/MaterialGemData.js.map +1 -1
  15. package/dist/implementation/material/MaterialSpecularGlossinessData.d.ts +3 -2
  16. package/dist/implementation/material/MaterialSpecularGlossinessData.d.ts.map +1 -1
  17. package/dist/implementation/material/MaterialSpecularGlossinessData.js.map +1 -1
  18. package/dist/implementation/material/MaterialStandardData.d.ts +7 -6
  19. package/dist/implementation/material/MaterialStandardData.d.ts.map +1 -1
  20. package/dist/implementation/material/MaterialStandardData.js +2 -2
  21. package/dist/implementation/material/MaterialStandardData.js.map +1 -1
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/interfaces/data/IGeometryData.d.ts +1 -1
  26. package/dist/interfaces/data/IGeometryData.d.ts.map +1 -1
  27. package/dist/interfaces/data/IHTMLElementAnchorData.d.ts +2 -1
  28. package/dist/interfaces/data/IHTMLElementAnchorData.d.ts.map +1 -1
  29. package/dist/interfaces/data/material/IMapData.d.ts +2 -1
  30. package/dist/interfaces/data/material/IMapData.d.ts.map +1 -1
  31. package/dist/interfaces/data/material/IMapData.js.map +1 -1
  32. package/dist/interfaces/data/material/IMaterialAbstractData.d.ts +5 -4
  33. package/dist/interfaces/data/material/IMaterialAbstractData.d.ts.map +1 -1
  34. package/dist/interfaces/data/material/IMaterialAbstractData.js.map +1 -1
  35. package/dist/interfaces/data/material/IMaterialGemDataProperties.d.ts +5 -4
  36. package/dist/interfaces/data/material/IMaterialGemDataProperties.d.ts.map +1 -1
  37. package/dist/interfaces/data/material/IMaterialGemDataProperties.js.map +1 -1
  38. package/dist/interfaces/data/material/IMaterialSpecularGlossinessDataProperties.d.ts +3 -2
  39. package/dist/interfaces/data/material/IMaterialSpecularGlossinessDataProperties.d.ts.map +1 -1
  40. package/dist/interfaces/data/material/IMaterialSpecularGlossinessDataProperties.js.map +1 -1
  41. package/dist/interfaces/data/material/IMaterialStandardData.d.ts +7 -6
  42. package/dist/interfaces/data/material/IMaterialStandardData.d.ts.map +1 -1
  43. package/dist/interfaces/data/material/IMaterialStandardData.js.map +1 -1
  44. package/dist/types.d.ts +3 -0
  45. package/dist/types.d.ts.map +1 -0
  46. package/dist/types.js +3 -0
  47. package/dist/types.js.map +1 -0
  48. package/package.json +5 -5
  49. package/src/implementation/data/GeometryData.ts +47 -20
  50. package/src/implementation/material/AbstractMaterialData.ts +7 -6
  51. package/src/implementation/material/MapData.ts +4 -3
  52. package/src/implementation/material/MaterialGemData.ts +7 -6
  53. package/src/implementation/material/MaterialSpecularGlossinessData.ts +4 -3
  54. package/src/implementation/material/MaterialStandardData.ts +12 -11
  55. package/src/index.ts +5 -0
  56. package/src/interfaces/data/IGeometryData.ts +1 -1
  57. package/src/interfaces/data/IHTMLElementAnchorData.ts +2 -1
  58. package/src/interfaces/data/material/IMapData.ts +2 -1
  59. package/src/interfaces/data/material/IMaterialAbstractData.ts +5 -4
  60. package/src/interfaces/data/material/IMaterialGemDataProperties.ts +5 -4
  61. package/src/interfaces/data/material/IMaterialSpecularGlossinessDataProperties.ts +3 -2
  62. package/src/interfaces/data/material/IMaterialStandardData.ts +7 -6
  63. package/src/types.ts +3 -0
@@ -1,12 +1,13 @@
1
1
  import { vec2 } from "gl-matrix";
2
2
  import { AbstractTreeNodeData } from "@shapediver/viewer.shared.node-tree";
3
3
  import { IMapData, TEXTURE_FILTERING, TEXTURE_WRAPPING } from "../../interfaces/data/material/IMapData";
4
+ import { Color } from "../../types";
4
5
 
5
6
  export class MapData extends AbstractTreeNodeData implements IMapData {
6
7
  // #region Properties (11)
7
8
 
8
9
  readonly #center: vec2 = vec2.fromValues(0, 0);
9
- readonly #color?: string;
10
+ readonly #color?: Color;
10
11
  readonly #flipY: boolean = true;
11
12
  readonly #image: HTMLImageElement;
12
13
  readonly #magFilter: TEXTURE_FILTERING = TEXTURE_FILTERING.NONE;
@@ -28,7 +29,7 @@ export class MapData extends AbstractTreeNodeData implements IMapData {
28
29
  minFilter: TEXTURE_FILTERING = TEXTURE_FILTERING.NONE,
29
30
  magFilter: TEXTURE_FILTERING = TEXTURE_FILTERING.NONE,
30
31
  center: vec2 = vec2.fromValues(0, 0),
31
- color?: string,
32
+ color?: Color,
32
33
  offset: vec2 = vec2.fromValues(0, 0),
33
34
  repeat: vec2 = vec2.fromValues(1, 1),
34
35
  rotation: number = 0,
@@ -56,7 +57,7 @@ export class MapData extends AbstractTreeNodeData implements IMapData {
56
57
  return this.#center;
57
58
  }
58
59
 
59
- public get color(): string | undefined {
60
+ public get color(): Color | undefined {
60
61
  return this.#color;
61
62
  }
62
63
 
@@ -3,6 +3,7 @@ import { IMaterialGemData, IMaterialGemDataProperties } from '../../interfaces/d
3
3
  import { MATERIAL_ALPHA, MATERIAL_SHADING, MATERIAL_SIDE } from '../../interfaces/data/material/IMaterialAbstractData';
4
4
  import { IMapData } from '../../interfaces/data/material/IMapData';
5
5
  import { mat3, mat4, vec3 } from 'gl-matrix';
6
+ import { Color } from '../../types';
6
7
 
7
8
  export class MaterialGemData extends AbstractMaterialData implements IMaterialGemData {
8
9
  // #region Properties (5)
@@ -11,8 +12,8 @@ export class MaterialGemData extends AbstractMaterialData implements IMaterialGe
11
12
  #refractionIndex: number = 2.4;
12
13
  #impurityMap?: IMapData;
13
14
  #impurityScale: number = 1.0;
14
- #colorTransferBegin: string = '#ffffff';
15
- #colorTransferEnd: string = '#ffffff';
15
+ #colorTransferBegin: Color = '#ffffff';
16
+ #colorTransferEnd: Color = '#ffffff';
16
17
  #center: vec3 = vec3.create();
17
18
  #radius: number = 1;
18
19
  #sphericalNormalMap?: IMapData;
@@ -86,19 +87,19 @@ export class MaterialGemData extends AbstractMaterialData implements IMaterialGe
86
87
  this.#impurityScale = value;
87
88
  }
88
89
 
89
- public get colorTransferBegin(): string {
90
+ public get colorTransferBegin(): Color {
90
91
  return this.#colorTransferBegin;
91
92
  }
92
93
 
93
- public set colorTransferBegin(value: string) {
94
+ public set colorTransferBegin(value: Color) {
94
95
  this.#colorTransferBegin = value;
95
96
  }
96
97
 
97
- public get colorTransferEnd(): string {
98
+ public get colorTransferEnd(): Color {
98
99
  return this.#colorTransferEnd;
99
100
  }
100
101
 
101
- public set colorTransferEnd(value: string) {
102
+ public set colorTransferEnd(value: Color) {
102
103
  this.#colorTransferEnd = value;
103
104
  }
104
105
 
@@ -2,13 +2,14 @@ import { AbstractMaterialData } from './AbstractMaterialData';
2
2
  import { IMaterialSpecularGlossinessData, IMaterialSpecularGlossinessDataProperties } from '../../interfaces/data/material/IMaterialSpecularGlossinessDataProperties';
3
3
  import { MATERIAL_ALPHA, MATERIAL_SHADING, MATERIAL_SIDE } from '../../interfaces/data/material/IMaterialAbstractData';
4
4
  import { IMapData } from '../../interfaces/data/material/IMapData';
5
+ import { Color } from '../../types';
5
6
 
6
7
  export class MaterialSpecularGlossinessData extends AbstractMaterialData implements IMaterialSpecularGlossinessData {
7
8
  // #region Properties (5)
8
9
 
9
10
  #glossiness: number = 1;
10
11
  #glossinessMap?: IMapData;
11
- #specular: string = '#ffffff';
12
+ #specular: Color = '#ffffff';
12
13
  #specularGlossinessMap?: IMapData;
13
14
  #specularMap?: IMapData;
14
15
  #envMap?: string | string[];
@@ -66,11 +67,11 @@ export class MaterialSpecularGlossinessData extends AbstractMaterialData impleme
66
67
  this.#glossinessMap = value;
67
68
  }
68
69
 
69
- public get specular(): string {
70
+ public get specular(): Color {
70
71
  return this.#specular;
71
72
  }
72
73
 
73
- public set specular(value: string) {
74
+ public set specular(value: Color) {
74
75
  this.#specular = value;
75
76
  }
76
77
 
@@ -2,12 +2,13 @@ import { AbstractMaterialData } from './AbstractMaterialData';
2
2
  import { IMaterialStandardData, IMaterialStandardDataProperties } from '../../interfaces/data/material/IMaterialStandardData';
3
3
  import { IMapData } from '../../interfaces/data/material/IMapData';
4
4
  import { MATERIAL_ALPHA, MATERIAL_SHADING, MATERIAL_SIDE } from '../../interfaces/data/material/IMaterialAbstractData';
5
+ import { Color } from '../../types';
5
6
 
6
7
  export class MaterialStandardData extends AbstractMaterialData implements IMaterialStandardData {
7
8
  // #region Properties (26)
8
9
 
9
- #attenuationColor: string = '#ffffff';
10
- #attenuationDistance = 0.0;
10
+ #attenuationColor: Color = '#ffffff';
11
+ #attenuationDistance = Infinity;
11
12
  #clearcoat: number = 0;
12
13
  #clearcoatMap?: IMapData;
13
14
  #clearcoatNormalMap?: IMapData;
@@ -24,11 +25,11 @@ export class MaterialStandardData extends AbstractMaterialData implements IMater
24
25
  #roughness = 1.0;
25
26
  #roughnessMap?: IMapData;
26
27
  #sheen = 0.0;
27
- #sheenColor: string = '#ffffff';
28
+ #sheenColor: Color = '#ffffff';
28
29
  #sheenColorMap?: IMapData;
29
30
  #sheenRoughness = 1.0;
30
31
  #sheenRoughnessMap?: IMapData;
31
- #specularColor: string = '#ffffff';
32
+ #specularColor: Color = '#ffffff';
32
33
  #specularColorMap?: IMapData;
33
34
  #specularIntensity = 1.0;
34
35
  #specularIntensityMap?: IMapData;
@@ -89,11 +90,11 @@ export class MaterialStandardData extends AbstractMaterialData implements IMater
89
90
 
90
91
  // #region Public Accessors (52)
91
92
 
92
- public get attenuationColor(): string {
93
+ public get attenuationColor(): Color {
93
94
  return this.#attenuationColor;
94
95
  }
95
96
 
96
- public set attenuationColor(value: string) {
97
+ public set attenuationColor(value: Color) {
97
98
  this.#attenuationColor = value;
98
99
  }
99
100
 
@@ -233,11 +234,11 @@ export class MaterialStandardData extends AbstractMaterialData implements IMater
233
234
  this.#sheen = value;
234
235
  }
235
236
 
236
- public get sheenColor(): string {
237
+ public get sheenColor(): Color {
237
238
  return this.#sheenColor;
238
239
  }
239
240
 
240
- public set sheenColor(value: string) {
241
+ public set sheenColor(value: Color) {
241
242
  this.#sheenColor = value;
242
243
  }
243
244
 
@@ -265,11 +266,11 @@ export class MaterialStandardData extends AbstractMaterialData implements IMater
265
266
  this.#sheenRoughnessMap = value;
266
267
  }
267
268
 
268
- public get specularColor(): string {
269
+ public get specularColor(): Color {
269
270
  return this.#specularColor;
270
271
  }
271
272
 
272
- public set specularColor(value: string) {
273
+ public set specularColor(value: Color) {
273
274
  this.#specularColor = value;
274
275
  }
275
276
 
@@ -353,7 +354,7 @@ export class MaterialStandardData extends AbstractMaterialData implements IMater
353
354
  this.side = MATERIAL_SIDE.DOUBLE;
354
355
 
355
356
  this.attenuationColor = '#ffffff';
356
- this.attenuationDistance = 1;
357
+ this.attenuationDistance = Infinity;
357
358
  this.clearcoat = 0;
358
359
  this.clearcoatMap = undefined;
359
360
  this.clearcoatNormalMap = undefined;
package/src/index.ts CHANGED
@@ -41,6 +41,7 @@ import { MaterialGemData } from './implementation/material/MaterialGemData'
41
41
  import { IMaterialGemData, IMaterialGemDataProperties } from './interfaces/data/material/IMaterialGemDataProperties'
42
42
  import { MaterialShadowData } from './implementation/material/MaterialShadowData'
43
43
  import { IMaterialShadowData, IMaterialShadowDataProperties } from './interfaces/data/material/IMaterialShadowData'
44
+ import { Color } from './types'
44
45
 
45
46
  export {
46
47
  IMaterialStandardData, MaterialStandardData, IMaterialStandardDataProperties,
@@ -71,4 +72,8 @@ export {
71
72
  export {
72
73
  ISDTFOverviewData, SDTFOverviewData, ISDTFOverview, SDTFAttributesData, ISDTFAttributesData, ISDTFAttributeData, SDTFAttributeData, SDTFItemData, ISDTFItemData, ISDTFAttributeVisualizationData,
73
74
  SdtfTypeHintName as SDTF_TYPEHINT, SdtfPrimitiveTypeGuard
75
+ }
76
+
77
+ export {
78
+ Color
74
79
  }
@@ -61,6 +61,7 @@ export interface IPrimitiveData extends ITreeNodeData {
61
61
  // #region Public Methods (1)
62
62
 
63
63
  clone(): IPrimitiveData;
64
+ computeBoundingBox(matrix: mat4): IBox;
64
65
 
65
66
  // #endregion Public Methods (1)
66
67
  }
@@ -68,7 +69,6 @@ export interface IPrimitiveData extends ITreeNodeData {
68
69
  export interface IGeometryData extends ITreeNodeData {
69
70
  // #region Properties (7)
70
71
 
71
- readonly matrix: mat4;
72
72
  readonly primitive: IPrimitiveData;
73
73
 
74
74
  boundingBox: IBox;
@@ -1,6 +1,7 @@
1
1
  import { vec2, vec3 } from "gl-matrix";
2
2
  import { ITreeNodeData } from "@shapediver/viewer.shared.node-tree";
3
3
  import { IBox } from "@shapediver/viewer.shared.math";
4
+ import { Color } from "../../types";
4
5
 
5
6
  export interface IAnchorDataImage {
6
7
  // #region Properties (6)
@@ -22,7 +23,7 @@ export interface IAnchorDataImage {
22
23
  export interface IAnchorDataText {
23
24
  // #region Properties (5)
24
25
 
25
- color: string | number | vec3,
26
+ color: Color,
26
27
  hidden?: boolean,
27
28
  position?: {
28
29
  horizontal?: string,
@@ -1,5 +1,6 @@
1
1
  import { ITreeNodeData } from "@shapediver/viewer.shared.node-tree";
2
2
  import { vec2 } from "gl-matrix";
3
+ import { Color } from "../../../types";
3
4
 
4
5
  export enum TEXTURE_WRAPPING {
5
6
  REPEAT = 10497,
@@ -21,7 +22,7 @@ export interface IMapData extends ITreeNodeData {
21
22
  // #region Properties (11)
22
23
 
23
24
  readonly center: vec2;
24
- readonly color?: string;
25
+ readonly color?: Color;
25
26
  readonly flipY: boolean;
26
27
  readonly image: HTMLImageElement;
27
28
  readonly magFilter: TEXTURE_FILTERING;
@@ -1,4 +1,5 @@
1
1
  import { ITreeNodeData } from "@shapediver/viewer.shared.node-tree";
2
+ import { Color } from "../../../types";
2
3
  import { IMapData } from "./IMapData";
3
4
 
4
5
  export enum MATERIAL_SIDE {
@@ -28,9 +29,9 @@ export interface IMaterialAbstractDataProperties {
28
29
  aoMapIntensity?: number,
29
30
  bumpMap?: IMapData,
30
31
  bumpScale?: number,
31
- color?: string,
32
+ color?: Color,
32
33
  emissiveMap?: IMapData,
33
- emissiveness?: string,
34
+ emissiveness?: Color,
34
35
  map?: IMapData,
35
36
  name?: string,
36
37
  normalMap?: IMapData,
@@ -52,9 +53,9 @@ export interface IMaterialAbstractData extends ITreeNodeData {
52
53
  aoMapIntensity: number,
53
54
  bumpMap?: IMapData,
54
55
  bumpScale: number,
55
- color: string,
56
+ color: Color,
56
57
  emissiveMap?: IMapData,
57
- emissiveness: string,
58
+ emissiveness: Color,
58
59
  map?: IMapData,
59
60
  materialOutput: boolean;
60
61
  name?: string,
@@ -1,4 +1,5 @@
1
1
  import { mat3, mat4, vec3 } from "gl-matrix";
2
+ import { Color } from "../../../types";
2
3
  import { IMapData } from "./IMapData";
3
4
  import { IMaterialAbstractData, IMaterialAbstractDataProperties } from "./IMaterialAbstractData";
4
5
 
@@ -7,8 +8,8 @@ export interface IMaterialGemDataProperties extends IMaterialAbstractDataPropert
7
8
 
8
9
  brightness?: number;
9
10
  center?: vec3;
10
- colorTransferBegin?: string;
11
- colorTransferEnd?: string;
11
+ colorTransferBegin?: Color;
12
+ colorTransferEnd?: Color;
12
13
  contrast?: number;
13
14
  dispersion?: number;
14
15
  envMap?: string | string[];
@@ -29,8 +30,8 @@ export interface IMaterialGemData extends IMaterialAbstractData {
29
30
 
30
31
  brightness?: number;
31
32
  center?: vec3;
32
- colorTransferBegin?: string;
33
- colorTransferEnd?: string;
33
+ colorTransferBegin?: Color;
34
+ colorTransferEnd?: Color;
34
35
  contrast?: number;
35
36
  dispersion?: number;
36
37
  envMap?: string | string[];
@@ -1,3 +1,4 @@
1
+ import { Color } from "../../../types";
1
2
  import { IMapData } from "./IMapData";
2
3
  import { IMaterialAbstractData, IMaterialAbstractDataProperties } from "./IMaterialAbstractData";
3
4
 
@@ -7,7 +8,7 @@ export interface IMaterialSpecularGlossinessDataProperties extends IMaterialAbst
7
8
  envMap?: string | string[];
8
9
  glossiness?: number,
9
10
  glossinessMap?: IMapData,
10
- specular?: string,
11
+ specular?: Color,
11
12
  specularGlossinessMap?: IMapData,
12
13
  specularMap?: IMapData,
13
14
 
@@ -20,7 +21,7 @@ export interface IMaterialSpecularGlossinessData extends IMaterialAbstractData {
20
21
  envMap?: string | string[];
21
22
  glossiness: number,
22
23
  glossinessMap?: IMapData,
23
- specular: string,
24
+ specular: Color,
24
25
  specularGlossinessMap?: IMapData,
25
26
  specularMap?: IMapData,
26
27
 
@@ -1,10 +1,11 @@
1
+ import { Color } from "../../../types";
1
2
  import { IMapData } from "./IMapData";
2
3
  import { IMaterialAbstractData, IMaterialAbstractDataProperties } from "./IMaterialAbstractData";
3
4
 
4
5
  export interface IMaterialStandardDataProperties extends IMaterialAbstractDataProperties {
5
6
  // #region Properties (30)
6
7
 
7
- attenuationColor?: string,
8
+ attenuationColor?: Color,
8
9
  attenuationDistance?: number;
9
10
  clearcoat?: number;
10
11
  clearcoatMap?: IMapData;
@@ -22,11 +23,11 @@ export interface IMaterialStandardDataProperties extends IMaterialAbstractDataPr
22
23
  roughness?: number,
23
24
  roughnessMap?: IMapData,
24
25
  sheen?: number,
25
- sheenColor?: string,
26
+ sheenColor?: Color,
26
27
  sheenColorMap?: IMapData,
27
28
  sheenRoughness?: number,
28
29
  sheenRoughnessMap?: IMapData,
29
- specularColor?: string,
30
+ specularColor?: Color,
30
31
  specularColorMap?: IMapData,
31
32
  specularIntensity?: number,
32
33
  specularIntensityMap?: IMapData,
@@ -41,7 +42,7 @@ export interface IMaterialStandardDataProperties extends IMaterialAbstractDataPr
41
42
  export interface IMaterialStandardData extends IMaterialAbstractData {
42
43
  // #region Properties (30)
43
44
 
44
- attenuationColor: string,
45
+ attenuationColor: Color,
45
46
  attenuationDistance: number;
46
47
  clearcoat: number;
47
48
  clearcoatMap?: IMapData;
@@ -59,11 +60,11 @@ export interface IMaterialStandardData extends IMaterialAbstractData {
59
60
  roughness: number,
60
61
  roughnessMap?: IMapData,
61
62
  sheen: number,
62
- sheenColor: string,
63
+ sheenColor: Color,
63
64
  sheenColorMap?: IMapData,
64
65
  sheenRoughness: number,
65
66
  sheenRoughnessMap?: IMapData,
66
- specularColor: string,
67
+ specularColor: Color,
67
68
  specularColorMap?: IMapData,
68
69
  specularIntensity: number,
69
70
  specularIntensityMap?: IMapData,
package/src/types.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { vec3, vec4 } from "gl-matrix";
2
+
3
+ export type Color = string | number | number[] | vec3 | vec4;