@configura/web-core 2.1.0-alpha.2 → 2.1.0-alpha.3

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 (173) hide show
  1. package/.eslintrc.json +5 -5
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/cm/basic/Color.d.ts +16 -16
  5. package/dist/cm/basic/Color.js +18 -18
  6. package/dist/cm/basic/ColorF.d.ts +9 -9
  7. package/dist/cm/basic/ColorF.js +10 -10
  8. package/dist/cm/basic/boolean.d.ts +2 -2
  9. package/dist/cm/basic/boolean.js +11 -11
  10. package/dist/cm/basic/number.d.ts +3 -3
  11. package/dist/cm/basic/number.js +18 -18
  12. package/dist/cm/basic/string.d.ts +2 -2
  13. package/dist/cm/basic/string.js +11 -11
  14. package/dist/cm/core3D/ATriMeshF.d.ts +96 -96
  15. package/dist/cm/core3D/ATriMeshF.js +197 -197
  16. package/dist/cm/core3D/GMaterial3D.d.ts +62 -62
  17. package/dist/cm/core3D/GMaterial3D.js +112 -112
  18. package/dist/cm/core3D/GMaterialClassic.d.ts +55 -55
  19. package/dist/cm/core3D/GMaterialClassic.js +171 -171
  20. package/dist/cm/core3D/GMaterialPBR.d.ts +73 -73
  21. package/dist/cm/core3D/GMaterialPBR.js +314 -314
  22. package/dist/cm/core3D/MultiGMaterial3D.d.ts +8 -8
  23. package/dist/cm/core3D/MultiGMaterial3D.js +17 -17
  24. package/dist/cm/core3D/uvmapper/UVMapEnv.d.ts +19 -19
  25. package/dist/cm/core3D/uvmapper/UVMapEnv.js +47 -47
  26. package/dist/cm/core3D/uvmapper/UVMapper.d.ts +41 -41
  27. package/dist/cm/core3D/uvmapper/UVMapper.js +94 -94
  28. package/dist/cm/core3D/uvmapper/UVMapperBox.d.ts +4 -4
  29. package/dist/cm/core3D/uvmapper/UVMapperBox.js +181 -181
  30. package/dist/cm/core3D/uvmapper/UVMapperCylinder.d.ts +9 -9
  31. package/dist/cm/core3D/uvmapper/UVMapperCylinder.js +96 -96
  32. package/dist/cm/core3D/uvmapper/UVMapperPlane.d.ts +3 -3
  33. package/dist/cm/core3D/uvmapper/UVMapperPlane.js +84 -84
  34. package/dist/cm/core3D/uvmapper/UVTransformer.d.ts +5 -5
  35. package/dist/cm/core3D/uvmapper/UVTransformer.js +5 -5
  36. package/dist/cm/core3D/uvmapper/instantiateUVMapper.d.ts +3 -3
  37. package/dist/cm/core3D/uvmapper/instantiateUVMapper.js +4 -4
  38. package/dist/cm/format/cmsym/InvalidationEnv.d.ts +9 -9
  39. package/dist/cm/format/cmsym/InvalidationEnv.js +13 -13
  40. package/dist/cm/format/cmsym/SymImportEnv.d.ts +9 -9
  41. package/dist/cm/format/cmsym/SymImportEnv.js +9 -9
  42. package/dist/cm/format/cmsym/SymInv.d.ts +8 -8
  43. package/dist/cm/format/cmsym/SymInv.js +17 -17
  44. package/dist/cm/format/cmsym/SymNode.d.ts +94 -94
  45. package/dist/cm/format/cmsym/SymNode.js +652 -652
  46. package/dist/cm/format/cmsym/components/SymBox.d.ts +15 -15
  47. package/dist/cm/format/cmsym/components/SymBox.js +39 -39
  48. package/dist/cm/format/cmsym/components/SymComponent.d.ts +29 -29
  49. package/dist/cm/format/cmsym/components/SymComponent.js +56 -56
  50. package/dist/cm/format/cmsym/components/SymConnector.d.ts +5 -5
  51. package/dist/cm/format/cmsym/components/SymConnector.js +10 -10
  52. package/dist/cm/format/cmsym/components/SymDexObj.d.ts +11 -11
  53. package/dist/cm/format/cmsym/components/SymDexObj.js +10 -10
  54. package/dist/cm/format/cmsym/components/SymGFX.d.ts +11 -11
  55. package/dist/cm/format/cmsym/components/SymGFX.js +20 -20
  56. package/dist/cm/format/cmsym/components/SymGMaterial.d.ts +19 -19
  57. package/dist/cm/format/cmsym/components/SymGMaterial.js +88 -88
  58. package/dist/cm/format/cmsym/components/SymGMaterialSelector.d.ts +17 -17
  59. package/dist/cm/format/cmsym/components/SymGMaterialSelector.js +22 -22
  60. package/dist/cm/format/cmsym/components/SymGetMeshEnv.d.ts +9 -9
  61. package/dist/cm/format/cmsym/components/SymGetMeshEnv.js +9 -9
  62. package/dist/cm/format/cmsym/components/SymLODGroup.d.ts +9 -9
  63. package/dist/cm/format/cmsym/components/SymLODGroup.js +13 -13
  64. package/dist/cm/format/cmsym/components/SymLight.d.ts +8 -8
  65. package/dist/cm/format/cmsym/components/SymLight.js +10 -10
  66. package/dist/cm/format/cmsym/components/SymLines2D.d.ts +5 -5
  67. package/dist/cm/format/cmsym/components/SymLines2D.js +7 -7
  68. package/dist/cm/format/cmsym/components/SymMeasure.d.ts +33 -33
  69. package/dist/cm/format/cmsym/components/SymMeasure.js +149 -149
  70. package/dist/cm/format/cmsym/components/SymMesh.d.ts +29 -29
  71. package/dist/cm/format/cmsym/components/SymMesh.js +130 -130
  72. package/dist/cm/format/cmsym/components/SymMeshLight.d.ts +8 -8
  73. package/dist/cm/format/cmsym/components/SymMeshLight.js +10 -10
  74. package/dist/cm/format/cmsym/components/SymMultiSelector.d.ts +13 -13
  75. package/dist/cm/format/cmsym/components/SymMultiSelector.js +48 -48
  76. package/dist/cm/format/cmsym/components/SymParams.d.ts +16 -16
  77. package/dist/cm/format/cmsym/components/SymParams.js +58 -58
  78. package/dist/cm/format/cmsym/components/SymPlane.d.ts +15 -15
  79. package/dist/cm/format/cmsym/components/SymPlane.js +30 -30
  80. package/dist/cm/format/cmsym/components/SymPlaneDivider.d.ts +4 -4
  81. package/dist/cm/format/cmsym/components/SymPlaneDivider.js +7 -7
  82. package/dist/cm/format/cmsym/components/SymPrimitive2D.d.ts +3 -3
  83. package/dist/cm/format/cmsym/components/SymPrimitive2D.js +3 -3
  84. package/dist/cm/format/cmsym/components/SymProgs.d.ts +32 -32
  85. package/dist/cm/format/cmsym/components/SymProgs.js +120 -120
  86. package/dist/cm/format/cmsym/components/SymProps.d.ts +54 -54
  87. package/dist/cm/format/cmsym/components/SymProps.js +171 -171
  88. package/dist/cm/format/cmsym/components/SymRep.d.ts +13 -13
  89. package/dist/cm/format/cmsym/components/SymRep.js +28 -28
  90. package/dist/cm/format/cmsym/components/SymReps.d.ts +36 -36
  91. package/dist/cm/format/cmsym/components/SymReps.js +230 -230
  92. package/dist/cm/format/cmsym/components/SymShape.d.ts +10 -10
  93. package/dist/cm/format/cmsym/components/SymShape.js +17 -17
  94. package/dist/cm/format/cmsym/components/SymSphere.d.ts +18 -18
  95. package/dist/cm/format/cmsym/components/SymSphere.js +33 -33
  96. package/dist/cm/format/cmsym/components/SymSpotlight.d.ts +8 -8
  97. package/dist/cm/format/cmsym/components/SymSpotlight.js +10 -10
  98. package/dist/cm/format/cmsym/components/SymTags.d.ts +11 -11
  99. package/dist/cm/format/cmsym/components/SymTags.js +20 -20
  100. package/dist/cm/format/cmsym/components/SymText2D.d.ts +5 -5
  101. package/dist/cm/format/cmsym/components/SymText2D.js +8 -8
  102. package/dist/cm/format/cmsym/components/SymText3D.d.ts +5 -5
  103. package/dist/cm/format/cmsym/components/SymText3D.js +8 -8
  104. package/dist/cm/format/cmsym/components/SymTransform.d.ts +23 -23
  105. package/dist/cm/format/cmsym/components/SymTransform.js +101 -101
  106. package/dist/cm/format/cmsym/components/SymUVMapper.d.ts +13 -13
  107. package/dist/cm/format/cmsym/components/SymUVMapper.js +50 -50
  108. package/dist/cm/format/cmsym/components/instantiate.d.ts +2 -2
  109. package/dist/cm/format/cmsym/components/instantiate.js +121 -121
  110. package/dist/cm/format/cmsym/components/legacy.d.ts +7 -7
  111. package/dist/cm/format/cmsym/components/legacy.js +27 -27
  112. package/dist/cm/format/cmsym/components/mesh.d.ts +8 -8
  113. package/dist/cm/format/cmsym/components/mesh.js +28 -28
  114. package/dist/cm/format/cmsym/invalidation.d.ts +4 -4
  115. package/dist/cm/format/cmsym/invalidation.js +72 -72
  116. package/dist/cm/format/dex/DexIRef.d.ts +9 -9
  117. package/dist/cm/format/dex/DexIRef.js +18 -18
  118. package/dist/cm/format/dex/DexInt.d.ts +11 -11
  119. package/dist/cm/format/dex/DexInt.js +18 -18
  120. package/dist/cm/format/dex/DexInternalizedXRef.d.ts +19 -19
  121. package/dist/cm/format/dex/DexInternalizedXRef.js +65 -65
  122. package/dist/cm/format/dex/DexLoader.d.ts +8 -8
  123. package/dist/cm/format/dex/DexLoader.js +12 -12
  124. package/dist/cm/format/dex/DexManager.d.ts +20 -20
  125. package/dist/cm/format/dex/DexManager.js +78 -78
  126. package/dist/cm/format/dex/DexObj.d.ts +15 -15
  127. package/dist/cm/format/dex/DexObj.js +86 -86
  128. package/dist/cm/format/dex/DexReader.d.ts +90 -90
  129. package/dist/cm/format/dex/DexReader.js +532 -532
  130. package/dist/cm/format/dex/DexRef.d.ts +6 -6
  131. package/dist/cm/format/dex/DexRef.js +8 -8
  132. package/dist/cm/format/dex/DexReplacedXRefs.d.ts +9 -9
  133. package/dist/cm/format/dex/DexReplacedXRefs.js +22 -22
  134. package/dist/cm/format/dex/DexURL.d.ts +4 -4
  135. package/dist/cm/format/dex/DexURL.js +5 -5
  136. package/dist/cm/format/dex/DexVersion.d.ts +15 -15
  137. package/dist/cm/format/dex/DexVersion.js +53 -53
  138. package/dist/cm/format/dex/DexXRef.d.ts +18 -18
  139. package/dist/cm/format/dex/DexXRef.js +51 -51
  140. package/dist/cm/format/dex/DexXRefTargetFilter.d.ts +4 -4
  141. package/dist/cm/format/dex/DexXRefTargetFilter.js +5 -5
  142. package/dist/cm/geometry/Angle.d.ts +9 -9
  143. package/dist/cm/geometry/Angle.js +18 -18
  144. package/dist/cm/geometry/AngleF.d.ts +5 -5
  145. package/dist/cm/geometry/AngleF.js +8 -8
  146. package/dist/cm/geometry/Box.d.ts +7 -7
  147. package/dist/cm/geometry/Box.js +9 -9
  148. package/dist/cm/geometry/DetailMask.d.ts +37 -37
  149. package/dist/cm/geometry/DetailMask.js +114 -114
  150. package/dist/cm/geometry/LayerExpr.d.ts +2 -2
  151. package/dist/cm/geometry/LayerExpr.js +2 -2
  152. package/dist/cm/geometry/Matrix22.d.ts +7 -7
  153. package/dist/cm/geometry/Matrix22.js +9 -9
  154. package/dist/cm/geometry/Matrix33.d.ts +42 -42
  155. package/dist/cm/geometry/Matrix33.js +124 -124
  156. package/dist/cm/geometry/Orientation.d.ts +7 -7
  157. package/dist/cm/geometry/Orientation.js +7 -7
  158. package/dist/cm/geometry/Plane.d.ts +8 -8
  159. package/dist/cm/geometry/Plane.js +14 -14
  160. package/dist/cm/geometry/Point.d.ts +21 -21
  161. package/dist/cm/geometry/Point.js +65 -65
  162. package/dist/cm/geometry/Point2D.d.ts +9 -9
  163. package/dist/cm/geometry/Point2D.js +23 -23
  164. package/dist/cm/geometry/PointF.d.ts +11 -11
  165. package/dist/cm/geometry/PointF.js +27 -27
  166. package/dist/cm/geometry/Transform.d.ts +11 -11
  167. package/dist/cm/geometry/Transform.js +61 -61
  168. package/dist/cm/geometry/Transform2D.d.ts +7 -7
  169. package/dist/cm/geometry/Transform2D.js +6 -6
  170. package/dist/cm/io/Semver.d.ts +18 -18
  171. package/dist/cm/io/Semver.js +61 -61
  172. package/dist/index.js +1 -1
  173. package/package.json +4 -4
@@ -1,17 +1,17 @@
1
- export class MultiGMaterial3D {
2
- constructor(materialMap = new Map(), realtimeMaterial3D, renderMaterial3D) {
3
- this.materialMap = materialMap;
4
- if (realtimeMaterial3D !== undefined) {
5
- this.materialMap.set("medium", realtimeMaterial3D);
6
- }
7
- if (renderMaterial3D !== undefined) {
8
- this.materialMap.set("super", renderMaterial3D);
9
- }
10
- }
11
- realtimeMaterial() {
12
- return this.materialMap.get("medium");
13
- }
14
- renderMaterial() {
15
- return this.materialMap.get("super");
16
- }
17
- }
1
+ export class MultiGMaterial3D {
2
+ constructor(materialMap = new Map(), realtimeMaterial3D, renderMaterial3D) {
3
+ this.materialMap = materialMap;
4
+ if (realtimeMaterial3D !== undefined) {
5
+ this.materialMap.set("medium", realtimeMaterial3D);
6
+ }
7
+ if (renderMaterial3D !== undefined) {
8
+ this.materialMap.set("super", renderMaterial3D);
9
+ }
10
+ }
11
+ realtimeMaterial() {
12
+ return this.materialMap.get("medium");
13
+ }
14
+ renderMaterial() {
15
+ return this.materialMap.get("super");
16
+ }
17
+ }
@@ -1,20 +1,20 @@
1
- import { Point } from "../../geometry/Point.js";
2
- import { UVTransformer } from "./UVTransformer.js";
3
- export declare enum UVMapperType {
4
- Box = 0,
5
- Spherical = 1,
6
- Planar = 2,
7
- Cylindrical = 3
8
- }
9
- export declare function castUVMapperType(name: string): UVMapperType | undefined;
10
- export declare function fcastUVMapperType(name: string): UVMapperType;
11
- export declare class UVMapEnv {
12
- type: UVMapperType;
13
- transforms?: UVTransformer[] | undefined;
14
- normal: Point;
15
- uniform: boolean;
16
- constructor(type: UVMapperType, transforms?: UVTransformer[] | undefined, normal?: Point, uniform?: boolean);
17
- private _hash;
18
- get hash(): number;
19
- }
1
+ import { Point } from "../../geometry/Point.js";
2
+ import { UVTransformer } from "./UVTransformer.js";
3
+ export declare enum UVMapperType {
4
+ Box = 0,
5
+ Spherical = 1,
6
+ Planar = 2,
7
+ Cylindrical = 3
8
+ }
9
+ export declare function castUVMapperType(name: string): UVMapperType | undefined;
10
+ export declare function fcastUVMapperType(name: string): UVMapperType;
11
+ export declare class UVMapEnv {
12
+ type: UVMapperType;
13
+ transforms?: UVTransformer[] | undefined;
14
+ normal: Point;
15
+ uniform: boolean;
16
+ constructor(type: UVMapperType, transforms?: UVTransformer[] | undefined, normal?: Point, uniform?: boolean);
17
+ private _hash;
18
+ get hash(): number;
19
+ }
20
20
  //# sourceMappingURL=UVMapEnv.d.ts.map
@@ -1,47 +1,47 @@
1
- import { hashCode } from "@configura/web-utilities";
2
- import { Point } from "../../geometry/Point.js";
3
- export var UVMapperType;
4
- (function (UVMapperType) {
5
- UVMapperType[UVMapperType["Box"] = 0] = "Box";
6
- UVMapperType[UVMapperType["Spherical"] = 1] = "Spherical";
7
- UVMapperType[UVMapperType["Planar"] = 2] = "Planar";
8
- UVMapperType[UVMapperType["Cylindrical"] = 3] = "Cylindrical";
9
- })(UVMapperType || (UVMapperType = {}));
10
- export function castUVMapperType(name) {
11
- switch (name) {
12
- case "box":
13
- return UVMapperType.Box;
14
- case "spherical":
15
- return UVMapperType.Spherical;
16
- case "planar":
17
- return UVMapperType.Planar;
18
- case "cylindrical":
19
- return UVMapperType.Cylindrical;
20
- }
21
- }
22
- export function fcastUVMapperType(name) {
23
- const type = castUVMapperType(name);
24
- if (type === undefined) {
25
- throw new Error(`unknown UVMapperType: ${name}`);
26
- }
27
- return type;
28
- }
29
- export class UVMapEnv {
30
- constructor(type, transforms, normal = new Point(0, 0, 0), uniform = true) {
31
- this.type = type;
32
- this.transforms = transforms;
33
- this.normal = normal;
34
- this.uniform = uniform;
35
- }
36
- get hash() {
37
- if (this._hash === undefined) {
38
- this._hash = hashCode(`ty${this.type}-tr${(this.transforms || [])
39
- .map((t) => {
40
- const { pos, mapping } = t.transform;
41
- return `po${pos.toString()}-ma${mapping.toString()}`;
42
- })
43
- .join("-")}-no${this.normal.toString()}-un${this.uniform}`);
44
- }
45
- return this._hash;
46
- }
47
- }
1
+ import { hashCode } from "@configura/web-utilities";
2
+ import { Point } from "../../geometry/Point.js";
3
+ export var UVMapperType;
4
+ (function (UVMapperType) {
5
+ UVMapperType[UVMapperType["Box"] = 0] = "Box";
6
+ UVMapperType[UVMapperType["Spherical"] = 1] = "Spherical";
7
+ UVMapperType[UVMapperType["Planar"] = 2] = "Planar";
8
+ UVMapperType[UVMapperType["Cylindrical"] = 3] = "Cylindrical";
9
+ })(UVMapperType || (UVMapperType = {}));
10
+ export function castUVMapperType(name) {
11
+ switch (name) {
12
+ case "box":
13
+ return UVMapperType.Box;
14
+ case "spherical":
15
+ return UVMapperType.Spherical;
16
+ case "planar":
17
+ return UVMapperType.Planar;
18
+ case "cylindrical":
19
+ return UVMapperType.Cylindrical;
20
+ }
21
+ }
22
+ export function fcastUVMapperType(name) {
23
+ const type = castUVMapperType(name);
24
+ if (type === undefined) {
25
+ throw new Error(`unknown UVMapperType: ${name}`);
26
+ }
27
+ return type;
28
+ }
29
+ export class UVMapEnv {
30
+ constructor(type, transforms, normal = new Point(0, 0, 0), uniform = true) {
31
+ this.type = type;
32
+ this.transforms = transforms;
33
+ this.normal = normal;
34
+ this.uniform = uniform;
35
+ }
36
+ get hash() {
37
+ if (this._hash === undefined) {
38
+ this._hash = hashCode(`ty${this.type}-tr${(this.transforms || [])
39
+ .map((t) => {
40
+ const { pos, mapping } = t.transform;
41
+ return `po${pos.toString()}-ma${mapping.toString()}`;
42
+ })
43
+ .join("-")}-no${this.normal.toString()}-un${this.uniform}`);
44
+ }
45
+ return this._hash;
46
+ }
47
+ }
@@ -1,42 +1,42 @@
1
- import { Logger } from "@configura/web-utilities";
2
- import { UVMapEnv } from "./UVMapEnv.js";
3
- import { UVTransformer } from "./UVTransformer.js";
4
- export declare type MinMaxSize = {
5
- min: number[];
6
- max: number[];
7
- size: number[];
8
- };
9
- export declare class UVMapper {
10
- env?: UVMapEnv | undefined;
11
- /**
12
- * Applies linear transformations to the UV-coordinates. This is essentially rotating, scaling
13
- * moving the texture before applying it.
14
- */
15
- static applyUvTransform(uv: [number, number], t: UVTransformer): [number, number];
16
- static calculateLimits(bounds: MinMaxSize, refBounds: MinMaxSize | undefined): {
17
- refMin: number[];
18
- refSize: number[];
19
- textureFixMin: number[];
20
- textureFixMax: number[];
21
- };
22
- static calculateTextureFixLimits(bounds: MinMaxSize, refBounds: MinMaxSize): {
23
- min: number[];
24
- max: number[];
25
- };
26
- constructor(env?: UVMapEnv | undefined);
27
- /**
28
- * Do not use this method if you have prebaked coordinates in the CmSym file generated by CET.
29
- * It is safer to use the existing ones since CET has already modified the geometry of the
30
- * mesh by splitting vertices etc.
31
- */
32
- createUVCoordinates(logger: Logger, positions: Float32Array, bounds: MinMaxSize, normals: Float32Array): Float32Array;
33
- /**
34
- * @param positions Stretched positions
35
- * @param normals Used both for stretched and non-stretched. We cheat a bit by always using the same normals
36
- * @param refPositions Non-stretched positions
37
- * @param refUvs Non-stretched UV coordinates
38
- * @returns
39
- */
40
- createUVCoordinatesForStretched(logger: Logger, positions: Float32Array, bounds: MinMaxSize, normals: Float32Array, refPositions: Float32Array, refBounds: MinMaxSize, refUvs: Float32Array): Float32Array;
41
- }
1
+ import { Logger } from "@configura/web-utilities";
2
+ import { UVMapEnv } from "./UVMapEnv.js";
3
+ import { UVTransformer } from "./UVTransformer.js";
4
+ export declare type MinMaxSize = {
5
+ min: number[];
6
+ max: number[];
7
+ size: number[];
8
+ };
9
+ export declare class UVMapper {
10
+ env?: UVMapEnv | undefined;
11
+ /**
12
+ * Applies linear transformations to the UV-coordinates. This is essentially rotating, scaling
13
+ * moving the texture before applying it.
14
+ */
15
+ static applyUvTransform(uv: [number, number], t: UVTransformer): [number, number];
16
+ static calculateLimits(bounds: MinMaxSize, refBounds: MinMaxSize | undefined): {
17
+ refMin: number[];
18
+ refSize: number[];
19
+ textureFixMin: number[];
20
+ textureFixMax: number[];
21
+ };
22
+ static calculateTextureFixLimits(bounds: MinMaxSize, refBounds: MinMaxSize): {
23
+ min: number[];
24
+ max: number[];
25
+ };
26
+ constructor(env?: UVMapEnv | undefined);
27
+ /**
28
+ * Do not use this method if you have prebaked coordinates in the CmSym file generated by CET.
29
+ * It is safer to use the existing ones since CET has already modified the geometry of the
30
+ * mesh by splitting vertices etc.
31
+ */
32
+ createUVCoordinates(logger: Logger, positions: Float32Array, bounds: MinMaxSize, normals: Float32Array): Float32Array;
33
+ /**
34
+ * @param positions Stretched positions
35
+ * @param normals Used both for stretched and non-stretched. We cheat a bit by always using the same normals
36
+ * @param refPositions Non-stretched positions
37
+ * @param refUvs Non-stretched UV coordinates
38
+ * @returns
39
+ */
40
+ createUVCoordinatesForStretched(logger: Logger, positions: Float32Array, bounds: MinMaxSize, normals: Float32Array, refPositions: Float32Array, refBounds: MinMaxSize, refUvs: Float32Array): Float32Array;
41
+ }
42
42
  //# sourceMappingURL=UVMapper.d.ts.map
@@ -1,94 +1,94 @@
1
- import { UVMapperType } from "./UVMapEnv.js";
2
- import { createUVBoxCoordinates, createUVBoxCoordinatesForStretched } from "./UVMapperBox.js";
3
- import { createUVCylinderCoordinates, createUVCylinderCoordinatesForStretched, } from "./UVMapperCylinder.js";
4
- import { createUVPlaneCoordinates, createUVPlaneCoordinatesForStretched } from "./UVMapperPlane.js";
5
- const xyz = [0, 1, 2];
6
- export class UVMapper {
7
- constructor(env) {
8
- this.env = env;
9
- }
10
- /**
11
- * Applies linear transformations to the UV-coordinates. This is essentially rotating, scaling
12
- * moving the texture before applying it.
13
- */
14
- static applyUvTransform(uv, t) {
15
- const { mapping, pos } = t.transform;
16
- const [u, v] = uv;
17
- const { x, y } = pos;
18
- let uNew = u;
19
- let vNew = v;
20
- const { c0, c1 } = mapping;
21
- uNew = c0.x * u + c1.x * v;
22
- vNew = c0.y * u + c1.y * v;
23
- uNew += x;
24
- vNew += y;
25
- return [uNew, vNew];
26
- }
27
- static calculateLimits(bounds, refBounds) {
28
- const { min: refMin, size: refSize } = refBounds || bounds;
29
- const { min: textureFixMin, max: textureFixMax } = refBounds === undefined
30
- ? { min: [0, 0, 0], max: [0, 0, 0] }
31
- : UVMapper.calculateTextureFixLimits(bounds, refBounds);
32
- return {
33
- refMin,
34
- refSize,
35
- textureFixMin,
36
- textureFixMax,
37
- };
38
- }
39
- static calculateTextureFixLimits(bounds, refBounds) {
40
- return {
41
- min: xyz.map((axis) => (refBounds.min[axis] - bounds.min[axis]) / refBounds.size[axis]),
42
- max: xyz.map((axis) => (refBounds.max[axis] - bounds.max[axis]) / refBounds.size[axis]),
43
- };
44
- }
45
- /**
46
- * Do not use this method if you have prebaked coordinates in the CmSym file generated by CET.
47
- * It is safer to use the existing ones since CET has already modified the geometry of the
48
- * mesh by splitting vertices etc.
49
- */
50
- createUVCoordinates(logger, positions, bounds, normals) {
51
- const env = this.env;
52
- if (env === undefined) {
53
- throw new Error("No UV mapping env");
54
- }
55
- switch (env.type) {
56
- case UVMapperType.Box:
57
- return createUVBoxCoordinates(env, positions, bounds, normals);
58
- case UVMapperType.Planar:
59
- return createUVPlaneCoordinates(env, positions);
60
- case UVMapperType.Cylindrical:
61
- return createUVCylinderCoordinates(env, positions, bounds, normals);
62
- case UVMapperType.Spherical:
63
- throw logger.errorAsObject(`Unsupported UV-mapper: ${env.type} (Spherical)`);
64
- default:
65
- throw logger.errorAsObject("Unknown UV-mapper: " + env.type);
66
- }
67
- }
68
- /**
69
- * @param positions Stretched positions
70
- * @param normals Used both for stretched and non-stretched. We cheat a bit by always using the same normals
71
- * @param refPositions Non-stretched positions
72
- * @param refUvs Non-stretched UV coordinates
73
- * @returns
74
- */
75
- createUVCoordinatesForStretched(logger, positions, bounds, normals, refPositions, refBounds, refUvs) {
76
- const env = this.env;
77
- if (env === undefined) {
78
- throw new Error("No mapping env");
79
- }
80
- switch (env.type) {
81
- case UVMapperType.Box:
82
- return createUVBoxCoordinatesForStretched(env, positions, bounds, normals, refPositions, refBounds, refUvs);
83
- case UVMapperType.Planar:
84
- return createUVPlaneCoordinatesForStretched(env, positions, refPositions);
85
- case UVMapperType.Cylindrical:
86
- return createUVCylinderCoordinatesForStretched(env, positions, bounds, normals, refPositions, refBounds, refUvs);
87
- case UVMapperType.Spherical:
88
- logger.warn("Spherical mapping is not implemented for stretch. Original UV-coordinates will be used.");
89
- return refUvs;
90
- default:
91
- throw logger.errorAsObject("Unknown UV-mapper");
92
- }
93
- }
94
- }
1
+ import { UVMapperType } from "./UVMapEnv.js";
2
+ import { createUVBoxCoordinates, createUVBoxCoordinatesForStretched } from "./UVMapperBox.js";
3
+ import { createUVCylinderCoordinates, createUVCylinderCoordinatesForStretched, } from "./UVMapperCylinder.js";
4
+ import { createUVPlaneCoordinates, createUVPlaneCoordinatesForStretched } from "./UVMapperPlane.js";
5
+ const xyz = [0, 1, 2];
6
+ export class UVMapper {
7
+ constructor(env) {
8
+ this.env = env;
9
+ }
10
+ /**
11
+ * Applies linear transformations to the UV-coordinates. This is essentially rotating, scaling
12
+ * moving the texture before applying it.
13
+ */
14
+ static applyUvTransform(uv, t) {
15
+ const { mapping, pos } = t.transform;
16
+ const [u, v] = uv;
17
+ const { x, y } = pos;
18
+ let uNew = u;
19
+ let vNew = v;
20
+ const { c0, c1 } = mapping;
21
+ uNew = c0.x * u + c1.x * v;
22
+ vNew = c0.y * u + c1.y * v;
23
+ uNew += x;
24
+ vNew += y;
25
+ return [uNew, vNew];
26
+ }
27
+ static calculateLimits(bounds, refBounds) {
28
+ const { min: refMin, size: refSize } = refBounds || bounds;
29
+ const { min: textureFixMin, max: textureFixMax } = refBounds === undefined
30
+ ? { min: [0, 0, 0], max: [0, 0, 0] }
31
+ : UVMapper.calculateTextureFixLimits(bounds, refBounds);
32
+ return {
33
+ refMin,
34
+ refSize,
35
+ textureFixMin,
36
+ textureFixMax,
37
+ };
38
+ }
39
+ static calculateTextureFixLimits(bounds, refBounds) {
40
+ return {
41
+ min: xyz.map((axis) => (refBounds.min[axis] - bounds.min[axis]) / refBounds.size[axis]),
42
+ max: xyz.map((axis) => (refBounds.max[axis] - bounds.max[axis]) / refBounds.size[axis]),
43
+ };
44
+ }
45
+ /**
46
+ * Do not use this method if you have prebaked coordinates in the CmSym file generated by CET.
47
+ * It is safer to use the existing ones since CET has already modified the geometry of the
48
+ * mesh by splitting vertices etc.
49
+ */
50
+ createUVCoordinates(logger, positions, bounds, normals) {
51
+ const env = this.env;
52
+ if (env === undefined) {
53
+ throw new Error("No UV mapping env");
54
+ }
55
+ switch (env.type) {
56
+ case UVMapperType.Box:
57
+ return createUVBoxCoordinates(env, positions, bounds, normals);
58
+ case UVMapperType.Planar:
59
+ return createUVPlaneCoordinates(env, positions);
60
+ case UVMapperType.Cylindrical:
61
+ return createUVCylinderCoordinates(env, positions, bounds, normals);
62
+ case UVMapperType.Spherical:
63
+ throw logger.errorAsObject(`Unsupported UV-mapper: ${env.type} (Spherical)`);
64
+ default:
65
+ throw logger.errorAsObject("Unknown UV-mapper: " + env.type);
66
+ }
67
+ }
68
+ /**
69
+ * @param positions Stretched positions
70
+ * @param normals Used both for stretched and non-stretched. We cheat a bit by always using the same normals
71
+ * @param refPositions Non-stretched positions
72
+ * @param refUvs Non-stretched UV coordinates
73
+ * @returns
74
+ */
75
+ createUVCoordinatesForStretched(logger, positions, bounds, normals, refPositions, refBounds, refUvs) {
76
+ const env = this.env;
77
+ if (env === undefined) {
78
+ throw new Error("No mapping env");
79
+ }
80
+ switch (env.type) {
81
+ case UVMapperType.Box:
82
+ return createUVBoxCoordinatesForStretched(env, positions, bounds, normals, refPositions, refBounds, refUvs);
83
+ case UVMapperType.Planar:
84
+ return createUVPlaneCoordinatesForStretched(env, positions, refPositions);
85
+ case UVMapperType.Cylindrical:
86
+ return createUVCylinderCoordinatesForStretched(env, positions, bounds, normals, refPositions, refBounds, refUvs);
87
+ case UVMapperType.Spherical:
88
+ logger.warn("Spherical mapping is not implemented for stretch. Original UV-coordinates will be used.");
89
+ return refUvs;
90
+ default:
91
+ throw logger.errorAsObject("Unknown UV-mapper");
92
+ }
93
+ }
94
+ }
@@ -1,5 +1,5 @@
1
- import { UVMapEnv } from "./UVMapEnv.js";
2
- import { MinMaxSize } from "./UVMapper.js";
3
- export declare function createUVBoxCoordinates(env: UVMapEnv | undefined, positions: Float32Array, bounds: MinMaxSize, normals: Float32Array): Float32Array;
4
- export declare function createUVBoxCoordinatesForStretched(env: UVMapEnv | undefined, positions: Float32Array, bounds: MinMaxSize, normals: Float32Array, refPositions: Float32Array, refBounds: MinMaxSize, refUvs: Float32Array): Float32Array;
1
+ import { UVMapEnv } from "./UVMapEnv.js";
2
+ import { MinMaxSize } from "./UVMapper.js";
3
+ export declare function createUVBoxCoordinates(env: UVMapEnv | undefined, positions: Float32Array, bounds: MinMaxSize, normals: Float32Array): Float32Array;
4
+ export declare function createUVBoxCoordinatesForStretched(env: UVMapEnv | undefined, positions: Float32Array, bounds: MinMaxSize, normals: Float32Array, refPositions: Float32Array, refBounds: MinMaxSize, refUvs: Float32Array): Float32Array;
5
5
  //# sourceMappingURL=UVMapperBox.d.ts.map