@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.
- package/.eslintrc.json +5 -5
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/cm/basic/Color.d.ts +16 -16
- package/dist/cm/basic/Color.js +18 -18
- package/dist/cm/basic/ColorF.d.ts +9 -9
- package/dist/cm/basic/ColorF.js +10 -10
- package/dist/cm/basic/boolean.d.ts +2 -2
- package/dist/cm/basic/boolean.js +11 -11
- package/dist/cm/basic/number.d.ts +3 -3
- package/dist/cm/basic/number.js +18 -18
- package/dist/cm/basic/string.d.ts +2 -2
- package/dist/cm/basic/string.js +11 -11
- package/dist/cm/core3D/ATriMeshF.d.ts +96 -96
- package/dist/cm/core3D/ATriMeshF.js +197 -197
- package/dist/cm/core3D/GMaterial3D.d.ts +62 -62
- package/dist/cm/core3D/GMaterial3D.js +112 -112
- package/dist/cm/core3D/GMaterialClassic.d.ts +55 -55
- package/dist/cm/core3D/GMaterialClassic.js +171 -171
- package/dist/cm/core3D/GMaterialPBR.d.ts +73 -73
- package/dist/cm/core3D/GMaterialPBR.js +314 -314
- package/dist/cm/core3D/MultiGMaterial3D.d.ts +8 -8
- package/dist/cm/core3D/MultiGMaterial3D.js +17 -17
- package/dist/cm/core3D/uvmapper/UVMapEnv.d.ts +19 -19
- package/dist/cm/core3D/uvmapper/UVMapEnv.js +47 -47
- package/dist/cm/core3D/uvmapper/UVMapper.d.ts +41 -41
- package/dist/cm/core3D/uvmapper/UVMapper.js +94 -94
- package/dist/cm/core3D/uvmapper/UVMapperBox.d.ts +4 -4
- package/dist/cm/core3D/uvmapper/UVMapperBox.js +181 -181
- package/dist/cm/core3D/uvmapper/UVMapperCylinder.d.ts +9 -9
- package/dist/cm/core3D/uvmapper/UVMapperCylinder.js +96 -96
- package/dist/cm/core3D/uvmapper/UVMapperPlane.d.ts +3 -3
- package/dist/cm/core3D/uvmapper/UVMapperPlane.js +84 -84
- package/dist/cm/core3D/uvmapper/UVTransformer.d.ts +5 -5
- package/dist/cm/core3D/uvmapper/UVTransformer.js +5 -5
- package/dist/cm/core3D/uvmapper/instantiateUVMapper.d.ts +3 -3
- package/dist/cm/core3D/uvmapper/instantiateUVMapper.js +4 -4
- package/dist/cm/format/cmsym/InvalidationEnv.d.ts +9 -9
- package/dist/cm/format/cmsym/InvalidationEnv.js +13 -13
- package/dist/cm/format/cmsym/SymImportEnv.d.ts +9 -9
- package/dist/cm/format/cmsym/SymImportEnv.js +9 -9
- package/dist/cm/format/cmsym/SymInv.d.ts +8 -8
- package/dist/cm/format/cmsym/SymInv.js +17 -17
- package/dist/cm/format/cmsym/SymNode.d.ts +94 -94
- package/dist/cm/format/cmsym/SymNode.js +652 -652
- package/dist/cm/format/cmsym/components/SymBox.d.ts +15 -15
- package/dist/cm/format/cmsym/components/SymBox.js +39 -39
- package/dist/cm/format/cmsym/components/SymComponent.d.ts +29 -29
- package/dist/cm/format/cmsym/components/SymComponent.js +56 -56
- package/dist/cm/format/cmsym/components/SymConnector.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymConnector.js +10 -10
- package/dist/cm/format/cmsym/components/SymDexObj.d.ts +11 -11
- package/dist/cm/format/cmsym/components/SymDexObj.js +10 -10
- package/dist/cm/format/cmsym/components/SymGFX.d.ts +11 -11
- package/dist/cm/format/cmsym/components/SymGFX.js +20 -20
- package/dist/cm/format/cmsym/components/SymGMaterial.d.ts +19 -19
- package/dist/cm/format/cmsym/components/SymGMaterial.js +88 -88
- package/dist/cm/format/cmsym/components/SymGMaterialSelector.d.ts +17 -17
- package/dist/cm/format/cmsym/components/SymGMaterialSelector.js +22 -22
- package/dist/cm/format/cmsym/components/SymGetMeshEnv.d.ts +9 -9
- package/dist/cm/format/cmsym/components/SymGetMeshEnv.js +9 -9
- package/dist/cm/format/cmsym/components/SymLODGroup.d.ts +9 -9
- package/dist/cm/format/cmsym/components/SymLODGroup.js +13 -13
- package/dist/cm/format/cmsym/components/SymLight.d.ts +8 -8
- package/dist/cm/format/cmsym/components/SymLight.js +10 -10
- package/dist/cm/format/cmsym/components/SymLines2D.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymLines2D.js +7 -7
- package/dist/cm/format/cmsym/components/SymMeasure.d.ts +33 -33
- package/dist/cm/format/cmsym/components/SymMeasure.js +149 -149
- package/dist/cm/format/cmsym/components/SymMesh.d.ts +29 -29
- package/dist/cm/format/cmsym/components/SymMesh.js +130 -130
- package/dist/cm/format/cmsym/components/SymMeshLight.d.ts +8 -8
- package/dist/cm/format/cmsym/components/SymMeshLight.js +10 -10
- package/dist/cm/format/cmsym/components/SymMultiSelector.d.ts +13 -13
- package/dist/cm/format/cmsym/components/SymMultiSelector.js +48 -48
- package/dist/cm/format/cmsym/components/SymParams.d.ts +16 -16
- package/dist/cm/format/cmsym/components/SymParams.js +58 -58
- package/dist/cm/format/cmsym/components/SymPlane.d.ts +15 -15
- package/dist/cm/format/cmsym/components/SymPlane.js +30 -30
- package/dist/cm/format/cmsym/components/SymPlaneDivider.d.ts +4 -4
- package/dist/cm/format/cmsym/components/SymPlaneDivider.js +7 -7
- package/dist/cm/format/cmsym/components/SymPrimitive2D.d.ts +3 -3
- package/dist/cm/format/cmsym/components/SymPrimitive2D.js +3 -3
- package/dist/cm/format/cmsym/components/SymProgs.d.ts +32 -32
- package/dist/cm/format/cmsym/components/SymProgs.js +120 -120
- package/dist/cm/format/cmsym/components/SymProps.d.ts +54 -54
- package/dist/cm/format/cmsym/components/SymProps.js +171 -171
- package/dist/cm/format/cmsym/components/SymRep.d.ts +13 -13
- package/dist/cm/format/cmsym/components/SymRep.js +28 -28
- package/dist/cm/format/cmsym/components/SymReps.d.ts +36 -36
- package/dist/cm/format/cmsym/components/SymReps.js +230 -230
- package/dist/cm/format/cmsym/components/SymShape.d.ts +10 -10
- package/dist/cm/format/cmsym/components/SymShape.js +17 -17
- package/dist/cm/format/cmsym/components/SymSphere.d.ts +18 -18
- package/dist/cm/format/cmsym/components/SymSphere.js +33 -33
- package/dist/cm/format/cmsym/components/SymSpotlight.d.ts +8 -8
- package/dist/cm/format/cmsym/components/SymSpotlight.js +10 -10
- package/dist/cm/format/cmsym/components/SymTags.d.ts +11 -11
- package/dist/cm/format/cmsym/components/SymTags.js +20 -20
- package/dist/cm/format/cmsym/components/SymText2D.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymText2D.js +8 -8
- package/dist/cm/format/cmsym/components/SymText3D.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymText3D.js +8 -8
- package/dist/cm/format/cmsym/components/SymTransform.d.ts +23 -23
- package/dist/cm/format/cmsym/components/SymTransform.js +101 -101
- package/dist/cm/format/cmsym/components/SymUVMapper.d.ts +13 -13
- package/dist/cm/format/cmsym/components/SymUVMapper.js +50 -50
- package/dist/cm/format/cmsym/components/instantiate.d.ts +2 -2
- package/dist/cm/format/cmsym/components/instantiate.js +121 -121
- package/dist/cm/format/cmsym/components/legacy.d.ts +7 -7
- package/dist/cm/format/cmsym/components/legacy.js +27 -27
- package/dist/cm/format/cmsym/components/mesh.d.ts +8 -8
- package/dist/cm/format/cmsym/components/mesh.js +28 -28
- package/dist/cm/format/cmsym/invalidation.d.ts +4 -4
- package/dist/cm/format/cmsym/invalidation.js +72 -72
- package/dist/cm/format/dex/DexIRef.d.ts +9 -9
- package/dist/cm/format/dex/DexIRef.js +18 -18
- package/dist/cm/format/dex/DexInt.d.ts +11 -11
- package/dist/cm/format/dex/DexInt.js +18 -18
- package/dist/cm/format/dex/DexInternalizedXRef.d.ts +19 -19
- package/dist/cm/format/dex/DexInternalizedXRef.js +65 -65
- package/dist/cm/format/dex/DexLoader.d.ts +8 -8
- package/dist/cm/format/dex/DexLoader.js +12 -12
- package/dist/cm/format/dex/DexManager.d.ts +20 -20
- package/dist/cm/format/dex/DexManager.js +78 -78
- package/dist/cm/format/dex/DexObj.d.ts +15 -15
- package/dist/cm/format/dex/DexObj.js +86 -86
- package/dist/cm/format/dex/DexReader.d.ts +90 -90
- package/dist/cm/format/dex/DexReader.js +532 -532
- package/dist/cm/format/dex/DexRef.d.ts +6 -6
- package/dist/cm/format/dex/DexRef.js +8 -8
- package/dist/cm/format/dex/DexReplacedXRefs.d.ts +9 -9
- package/dist/cm/format/dex/DexReplacedXRefs.js +22 -22
- package/dist/cm/format/dex/DexURL.d.ts +4 -4
- package/dist/cm/format/dex/DexURL.js +5 -5
- package/dist/cm/format/dex/DexVersion.d.ts +15 -15
- package/dist/cm/format/dex/DexVersion.js +53 -53
- package/dist/cm/format/dex/DexXRef.d.ts +18 -18
- package/dist/cm/format/dex/DexXRef.js +51 -51
- package/dist/cm/format/dex/DexXRefTargetFilter.d.ts +4 -4
- package/dist/cm/format/dex/DexXRefTargetFilter.js +5 -5
- package/dist/cm/geometry/Angle.d.ts +9 -9
- package/dist/cm/geometry/Angle.js +18 -18
- package/dist/cm/geometry/AngleF.d.ts +5 -5
- package/dist/cm/geometry/AngleF.js +8 -8
- package/dist/cm/geometry/Box.d.ts +7 -7
- package/dist/cm/geometry/Box.js +9 -9
- package/dist/cm/geometry/DetailMask.d.ts +37 -37
- package/dist/cm/geometry/DetailMask.js +114 -114
- package/dist/cm/geometry/LayerExpr.d.ts +2 -2
- package/dist/cm/geometry/LayerExpr.js +2 -2
- package/dist/cm/geometry/Matrix22.d.ts +7 -7
- package/dist/cm/geometry/Matrix22.js +9 -9
- package/dist/cm/geometry/Matrix33.d.ts +42 -42
- package/dist/cm/geometry/Matrix33.js +124 -124
- package/dist/cm/geometry/Orientation.d.ts +7 -7
- package/dist/cm/geometry/Orientation.js +7 -7
- package/dist/cm/geometry/Plane.d.ts +8 -8
- package/dist/cm/geometry/Plane.js +14 -14
- package/dist/cm/geometry/Point.d.ts +21 -21
- package/dist/cm/geometry/Point.js +65 -65
- package/dist/cm/geometry/Point2D.d.ts +9 -9
- package/dist/cm/geometry/Point2D.js +23 -23
- package/dist/cm/geometry/PointF.d.ts +11 -11
- package/dist/cm/geometry/PointF.js +27 -27
- package/dist/cm/geometry/Transform.d.ts +11 -11
- package/dist/cm/geometry/Transform.js +61 -61
- package/dist/cm/geometry/Transform2D.d.ts +7 -7
- package/dist/cm/geometry/Transform2D.js +6 -6
- package/dist/cm/io/Semver.d.ts +18 -18
- package/dist/cm/io/Semver.js +61 -61
- package/dist/index.js +1 -1
- 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
|