@itwin/core-common 3.0.0-extension.0 → 3.1.0-dev.5
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/CHANGELOG.md +84 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/BackgroundMapSettings.d.ts +1 -1
- package/lib/cjs/BackgroundMapSettings.d.ts.map +1 -1
- package/lib/cjs/BackgroundMapSettings.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts +28 -11
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +26 -12
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/ContextRealityModel.d.ts +36 -16
- package/lib/cjs/ContextRealityModel.d.ts.map +1 -1
- package/lib/cjs/ContextRealityModel.js +46 -7
- package/lib/cjs/ContextRealityModel.js.map +1 -1
- package/lib/cjs/DisplayStyleSettings.d.ts +30 -24
- package/lib/cjs/DisplayStyleSettings.d.ts.map +1 -1
- package/lib/cjs/DisplayStyleSettings.js +43 -16
- package/lib/cjs/DisplayStyleSettings.js.map +1 -1
- package/lib/cjs/ECSqlReader.d.ts +17 -5
- package/lib/cjs/ECSqlReader.d.ts.map +1 -1
- package/lib/cjs/ECSqlReader.js +55 -22
- package/lib/cjs/ECSqlReader.js.map +1 -1
- package/lib/cjs/ECSqlTypes.d.ts +3 -3
- package/lib/cjs/ECSqlTypes.js +3 -3
- package/lib/cjs/ECSqlTypes.js.map +1 -1
- package/lib/cjs/ElementProps.d.ts +9 -0
- package/lib/cjs/ElementProps.d.ts.map +1 -1
- package/lib/cjs/ElementProps.js.map +1 -1
- package/lib/cjs/Environment.d.ts +61 -0
- package/lib/cjs/Environment.d.ts.map +1 -0
- package/lib/cjs/Environment.js +74 -0
- package/lib/cjs/Environment.js.map +1 -0
- package/lib/cjs/FeatureSymbology.d.ts +97 -18
- package/lib/cjs/FeatureSymbology.d.ts.map +1 -1
- package/lib/cjs/FeatureSymbology.js +83 -27
- package/lib/cjs/FeatureSymbology.js.map +1 -1
- package/lib/cjs/GeoCoordinateServices.d.ts +66 -1
- package/lib/cjs/GeoCoordinateServices.d.ts.map +1 -1
- package/lib/cjs/GeoCoordinateServices.js +39 -1
- package/lib/cjs/GeoCoordinateServices.js.map +1 -1
- package/lib/cjs/Gradient.d.ts.map +1 -1
- package/lib/cjs/Gradient.js +10 -0
- package/lib/cjs/Gradient.js.map +1 -1
- package/lib/cjs/GroundPlane.d.ts +26 -15
- package/lib/cjs/GroundPlane.d.ts.map +1 -1
- package/lib/cjs/GroundPlane.js +40 -39
- package/lib/cjs/GroundPlane.js.map +1 -1
- package/lib/cjs/IModel.d.ts +33 -4
- package/lib/cjs/IModel.d.ts.map +1 -1
- package/lib/cjs/IModel.js +27 -10
- package/lib/cjs/IModel.js.map +1 -1
- package/lib/cjs/LightSettings.d.ts +59 -0
- package/lib/cjs/LightSettings.d.ts.map +1 -1
- package/lib/cjs/LightSettings.js +75 -6
- package/lib/cjs/LightSettings.js.map +1 -1
- package/lib/cjs/Localization.d.ts +1 -1
- package/lib/cjs/Localization.js.map +1 -1
- package/lib/cjs/MapLayerSettings.d.ts +2 -2
- package/lib/cjs/MapLayerSettings.js +2 -2
- package/lib/cjs/MapLayerSettings.js.map +1 -1
- package/lib/cjs/NativeAppProps.d.ts +2 -36
- package/lib/cjs/NativeAppProps.d.ts.map +1 -1
- package/lib/cjs/NativeAppProps.js.map +1 -1
- package/lib/cjs/PlanarClipMask.d.ts +73 -8
- package/lib/cjs/PlanarClipMask.d.ts.map +1 -1
- package/lib/cjs/PlanarClipMask.js +17 -24
- package/lib/cjs/PlanarClipMask.js.map +1 -1
- package/lib/cjs/RealityDataAccessProps.d.ts +42 -0
- package/lib/cjs/RealityDataAccessProps.d.ts.map +1 -0
- package/lib/cjs/RealityDataAccessProps.js +20 -0
- package/lib/cjs/RealityDataAccessProps.js.map +1 -0
- package/lib/cjs/RenderMaterial.d.ts +7 -7
- package/lib/cjs/RenderMaterial.d.ts.map +1 -1
- package/lib/cjs/RenderMaterial.js +10 -5
- package/lib/cjs/RenderMaterial.js.map +1 -1
- package/lib/cjs/RenderSchedule.d.ts +4 -0
- package/lib/cjs/RenderSchedule.d.ts.map +1 -1
- package/lib/cjs/RenderSchedule.js +5 -1
- package/lib/cjs/RenderSchedule.js.map +1 -1
- package/lib/cjs/RenderTexture.d.ts +8 -1
- package/lib/cjs/RenderTexture.d.ts.map +1 -1
- package/lib/cjs/RenderTexture.js.map +1 -1
- package/lib/cjs/SkyBox.d.ts +142 -34
- package/lib/cjs/SkyBox.d.ts.map +1 -1
- package/lib/cjs/SkyBox.js +192 -6
- package/lib/cjs/SkyBox.js.map +1 -1
- package/lib/cjs/TextureMapping.d.ts +3 -1
- package/lib/cjs/TextureMapping.d.ts.map +1 -1
- package/lib/cjs/TextureMapping.js +9 -6
- package/lib/cjs/TextureMapping.js.map +1 -1
- package/lib/cjs/TextureProps.d.ts +21 -2
- package/lib/cjs/TextureProps.d.ts.map +1 -1
- package/lib/cjs/TextureProps.js +19 -0
- package/lib/cjs/TextureProps.js.map +1 -1
- package/lib/cjs/ThematicDisplay.d.ts +6 -0
- package/lib/cjs/ThematicDisplay.d.ts.map +1 -1
- package/lib/cjs/ThematicDisplay.js +26 -0
- package/lib/cjs/ThematicDisplay.js.map +1 -1
- package/lib/cjs/TileProps.d.ts +6 -0
- package/lib/cjs/TileProps.d.ts.map +1 -1
- package/lib/cjs/TileProps.js.map +1 -1
- package/lib/cjs/ViewFlags.d.ts +8 -0
- package/lib/cjs/ViewFlags.d.ts.map +1 -1
- package/lib/cjs/ViewFlags.js +30 -10
- package/lib/cjs/ViewFlags.js.map +1 -1
- package/lib/cjs/core-common.d.ts +7 -0
- package/lib/cjs/core-common.d.ts.map +1 -1
- package/lib/cjs/core-common.js +7 -0
- package/lib/cjs/core-common.js.map +1 -1
- package/lib/cjs/geometry/AdditionalTransform.d.ts +1 -1
- package/lib/cjs/geometry/AdditionalTransform.js +1 -1
- package/lib/cjs/geometry/AdditionalTransform.js.map +1 -1
- package/lib/cjs/geometry/CoordinateReferenceSystem.d.ts +25 -10
- package/lib/cjs/geometry/CoordinateReferenceSystem.d.ts.map +1 -1
- package/lib/cjs/geometry/CoordinateReferenceSystem.js +9 -7
- package/lib/cjs/geometry/CoordinateReferenceSystem.js.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.d.ts +12 -8
- package/lib/cjs/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.js.map +1 -1
- package/lib/cjs/geometry/FrustumPlanes.d.ts +1 -1
- package/lib/cjs/geometry/FrustumPlanes.d.ts.map +1 -1
- package/lib/cjs/geometry/FrustumPlanes.js +26 -13
- package/lib/cjs/geometry/FrustumPlanes.js.map +1 -1
- package/lib/cjs/ipc/IpcWebSocket.d.ts +12 -5
- package/lib/cjs/ipc/IpcWebSocket.d.ts.map +1 -1
- package/lib/cjs/ipc/IpcWebSocket.js +32 -8
- package/lib/cjs/ipc/IpcWebSocket.js.map +1 -1
- package/lib/cjs/ipc/IpcWebSocketTransport.d.ts +15 -0
- package/lib/cjs/ipc/IpcWebSocketTransport.d.ts.map +1 -0
- package/lib/cjs/ipc/IpcWebSocketTransport.js +142 -0
- package/lib/cjs/ipc/IpcWebSocketTransport.js.map +1 -0
- package/lib/cjs/rpc/core/RpcInvocation.d.ts +4 -4
- package/lib/cjs/rpc/core/RpcInvocation.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.js +3 -1
- package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/cjs/tile/ElementGraphics.d.ts +5 -1
- package/lib/cjs/tile/ElementGraphics.d.ts.map +1 -1
- package/lib/cjs/tile/ElementGraphics.js.map +1 -1
- package/lib/cjs/tile/GltfTileIO.d.ts +16 -79
- package/lib/cjs/tile/GltfTileIO.d.ts.map +1 -1
- package/lib/cjs/tile/GltfTileIO.js +72 -153
- package/lib/cjs/tile/GltfTileIO.js.map +1 -1
- package/lib/cjs/tile/TileMetadata.d.ts +20 -8
- package/lib/cjs/tile/TileMetadata.d.ts.map +1 -1
- package/lib/cjs/tile/TileMetadata.js +50 -53
- package/lib/cjs/tile/TileMetadata.js.map +1 -1
- package/lib/esm/BackgroundMapSettings.d.ts +1 -1
- package/lib/esm/BackgroundMapSettings.d.ts.map +1 -1
- package/lib/esm/BackgroundMapSettings.js.map +1 -1
- package/lib/esm/ConcurrentQuery.d.ts +28 -11
- package/lib/esm/ConcurrentQuery.d.ts.map +1 -1
- package/lib/esm/ConcurrentQuery.js +26 -12
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/ContextRealityModel.d.ts +36 -16
- package/lib/esm/ContextRealityModel.d.ts.map +1 -1
- package/lib/esm/ContextRealityModel.js +45 -6
- package/lib/esm/ContextRealityModel.js.map +1 -1
- package/lib/esm/DisplayStyleSettings.d.ts +30 -24
- package/lib/esm/DisplayStyleSettings.d.ts.map +1 -1
- package/lib/esm/DisplayStyleSettings.js +43 -16
- package/lib/esm/DisplayStyleSettings.js.map +1 -1
- package/lib/esm/ECSqlReader.d.ts +17 -5
- package/lib/esm/ECSqlReader.d.ts.map +1 -1
- package/lib/esm/ECSqlReader.js +56 -23
- package/lib/esm/ECSqlReader.js.map +1 -1
- package/lib/esm/ECSqlTypes.d.ts +3 -3
- package/lib/esm/ECSqlTypes.js +3 -3
- package/lib/esm/ECSqlTypes.js.map +1 -1
- package/lib/esm/ElementProps.d.ts +9 -0
- package/lib/esm/ElementProps.d.ts.map +1 -1
- package/lib/esm/ElementProps.js.map +1 -1
- package/lib/esm/Environment.d.ts +61 -0
- package/lib/esm/Environment.d.ts.map +1 -0
- package/lib/esm/Environment.js +70 -0
- package/lib/esm/Environment.js.map +1 -0
- package/lib/esm/FeatureSymbology.d.ts +97 -18
- package/lib/esm/FeatureSymbology.d.ts.map +1 -1
- package/lib/esm/FeatureSymbology.js +84 -28
- package/lib/esm/FeatureSymbology.js.map +1 -1
- package/lib/esm/GeoCoordinateServices.d.ts +66 -1
- package/lib/esm/GeoCoordinateServices.d.ts.map +1 -1
- package/lib/esm/GeoCoordinateServices.js +39 -1
- package/lib/esm/GeoCoordinateServices.js.map +1 -1
- package/lib/esm/Gradient.d.ts.map +1 -1
- package/lib/esm/Gradient.js +10 -0
- package/lib/esm/Gradient.js.map +1 -1
- package/lib/esm/GroundPlane.d.ts +26 -15
- package/lib/esm/GroundPlane.d.ts.map +1 -1
- package/lib/esm/GroundPlane.js +40 -39
- package/lib/esm/GroundPlane.js.map +1 -1
- package/lib/esm/IModel.d.ts +33 -4
- package/lib/esm/IModel.d.ts.map +1 -1
- package/lib/esm/IModel.js +27 -10
- package/lib/esm/IModel.js.map +1 -1
- package/lib/esm/LightSettings.d.ts +59 -0
- package/lib/esm/LightSettings.d.ts.map +1 -1
- package/lib/esm/LightSettings.js +74 -6
- package/lib/esm/LightSettings.js.map +1 -1
- package/lib/esm/Localization.d.ts +1 -1
- package/lib/esm/Localization.js.map +1 -1
- package/lib/esm/MapLayerSettings.d.ts +2 -2
- package/lib/esm/MapLayerSettings.js +2 -2
- package/lib/esm/MapLayerSettings.js.map +1 -1
- package/lib/esm/NativeAppProps.d.ts +2 -36
- package/lib/esm/NativeAppProps.d.ts.map +1 -1
- package/lib/esm/NativeAppProps.js.map +1 -1
- package/lib/esm/PlanarClipMask.d.ts +73 -8
- package/lib/esm/PlanarClipMask.d.ts.map +1 -1
- package/lib/esm/PlanarClipMask.js +17 -24
- package/lib/esm/PlanarClipMask.js.map +1 -1
- package/lib/esm/RealityDataAccessProps.d.ts +42 -0
- package/lib/esm/RealityDataAccessProps.d.ts.map +1 -0
- package/lib/esm/RealityDataAccessProps.js +17 -0
- package/lib/esm/RealityDataAccessProps.js.map +1 -0
- package/lib/esm/RenderMaterial.d.ts +7 -7
- package/lib/esm/RenderMaterial.d.ts.map +1 -1
- package/lib/esm/RenderMaterial.js +10 -5
- package/lib/esm/RenderMaterial.js.map +1 -1
- package/lib/esm/RenderSchedule.d.ts +4 -0
- package/lib/esm/RenderSchedule.d.ts.map +1 -1
- package/lib/esm/RenderSchedule.js +5 -1
- package/lib/esm/RenderSchedule.js.map +1 -1
- package/lib/esm/RenderTexture.d.ts +8 -1
- package/lib/esm/RenderTexture.d.ts.map +1 -1
- package/lib/esm/RenderTexture.js.map +1 -1
- package/lib/esm/SkyBox.d.ts +142 -34
- package/lib/esm/SkyBox.d.ts.map +1 -1
- package/lib/esm/SkyBox.js +187 -5
- package/lib/esm/SkyBox.js.map +1 -1
- package/lib/esm/TextureMapping.d.ts +3 -1
- package/lib/esm/TextureMapping.d.ts.map +1 -1
- package/lib/esm/TextureMapping.js +9 -6
- package/lib/esm/TextureMapping.js.map +1 -1
- package/lib/esm/TextureProps.d.ts +21 -2
- package/lib/esm/TextureProps.d.ts.map +1 -1
- package/lib/esm/TextureProps.js +18 -1
- package/lib/esm/TextureProps.js.map +1 -1
- package/lib/esm/ThematicDisplay.d.ts +6 -0
- package/lib/esm/ThematicDisplay.d.ts.map +1 -1
- package/lib/esm/ThematicDisplay.js +26 -0
- package/lib/esm/ThematicDisplay.js.map +1 -1
- package/lib/esm/TileProps.d.ts +6 -0
- package/lib/esm/TileProps.d.ts.map +1 -1
- package/lib/esm/TileProps.js.map +1 -1
- package/lib/esm/ViewFlags.d.ts +8 -0
- package/lib/esm/ViewFlags.d.ts.map +1 -1
- package/lib/esm/ViewFlags.js +30 -10
- package/lib/esm/ViewFlags.js.map +1 -1
- package/lib/esm/core-common.d.ts +7 -0
- package/lib/esm/core-common.d.ts.map +1 -1
- package/lib/esm/core-common.js +7 -0
- package/lib/esm/core-common.js.map +1 -1
- package/lib/esm/geometry/AdditionalTransform.d.ts +1 -1
- package/lib/esm/geometry/AdditionalTransform.js +1 -1
- package/lib/esm/geometry/AdditionalTransform.js.map +1 -1
- package/lib/esm/geometry/CoordinateReferenceSystem.d.ts +25 -10
- package/lib/esm/geometry/CoordinateReferenceSystem.d.ts.map +1 -1
- package/lib/esm/geometry/CoordinateReferenceSystem.js +9 -7
- package/lib/esm/geometry/CoordinateReferenceSystem.js.map +1 -1
- package/lib/esm/geometry/ElementGeometry.d.ts +12 -8
- package/lib/esm/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/esm/geometry/ElementGeometry.js.map +1 -1
- package/lib/esm/geometry/FrustumPlanes.d.ts +1 -1
- package/lib/esm/geometry/FrustumPlanes.d.ts.map +1 -1
- package/lib/esm/geometry/FrustumPlanes.js +26 -13
- package/lib/esm/geometry/FrustumPlanes.js.map +1 -1
- package/lib/esm/ipc/IpcWebSocket.d.ts +12 -5
- package/lib/esm/ipc/IpcWebSocket.d.ts.map +1 -1
- package/lib/esm/ipc/IpcWebSocket.js +31 -6
- package/lib/esm/ipc/IpcWebSocket.js.map +1 -1
- package/lib/esm/ipc/IpcWebSocketTransport.d.ts +15 -0
- package/lib/esm/ipc/IpcWebSocketTransport.d.ts.map +1 -0
- package/lib/esm/ipc/IpcWebSocketTransport.js +138 -0
- package/lib/esm/ipc/IpcWebSocketTransport.js.map +1 -0
- package/lib/esm/rpc/core/RpcInvocation.d.ts +4 -4
- package/lib/esm/rpc/core/RpcInvocation.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcInvocation.js +3 -1
- package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/esm/tile/ElementGraphics.d.ts +5 -1
- package/lib/esm/tile/ElementGraphics.d.ts.map +1 -1
- package/lib/esm/tile/ElementGraphics.js.map +1 -1
- package/lib/esm/tile/GltfTileIO.d.ts +16 -79
- package/lib/esm/tile/GltfTileIO.d.ts.map +1 -1
- package/lib/esm/tile/GltfTileIO.js +70 -149
- package/lib/esm/tile/GltfTileIO.js.map +1 -1
- package/lib/esm/tile/TileMetadata.d.ts +20 -8
- package/lib/esm/tile/TileMetadata.d.ts.map +1 -1
- package/lib/esm/tile/TileMetadata.js +50 -53
- package/lib/esm/tile/TileMetadata.js.map +1 -1
- package/package.json +10 -11
package/lib/esm/SkyBox.d.ts
CHANGED
|
@@ -1,49 +1,70 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module DisplayStyles
|
|
3
3
|
*/
|
|
4
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
5
|
-
import { ColorDefProps } from "./ColorDef";
|
|
6
|
-
|
|
4
|
+
import { Id64String, NonFunctionPropertiesOf } from "@itwin/core-bentley";
|
|
5
|
+
import { ColorDef, ColorDefProps } from "./ColorDef";
|
|
6
|
+
import { TextureImageSpec } from "./RenderTexture";
|
|
7
|
+
/** Supported types of [[SkyBox]] images.
|
|
8
|
+
* @see [[SkyBoxImageProps]].
|
|
7
9
|
* @public
|
|
8
10
|
*/
|
|
9
11
|
export declare enum SkyBoxImageType {
|
|
12
|
+
/** No image, indicating a [[SkyGradient]] should be displayed. */
|
|
10
13
|
None = 0,
|
|
11
|
-
/** A single image mapped to the surface of a sphere.
|
|
14
|
+
/** A single image mapped to the surface of a sphere.
|
|
15
|
+
* @see [[SkySphere]].
|
|
16
|
+
*/
|
|
12
17
|
Spherical = 1,
|
|
13
|
-
/** 6 images mapped to the faces of a cube. @see [SkyCube]($frontend) */
|
|
14
|
-
Cube = 2,
|
|
15
18
|
/** @internal not yet supported */
|
|
16
|
-
Cylindrical =
|
|
19
|
+
Cylindrical = 2,
|
|
20
|
+
/** Six images mapped to the faces of a cube.
|
|
21
|
+
* @see [[SkyCube]].
|
|
22
|
+
*/
|
|
23
|
+
Cube = 3
|
|
17
24
|
}
|
|
18
|
-
/** JSON representation of
|
|
25
|
+
/** JSON representation of the six images used by a [[SkyCube]].
|
|
26
|
+
* Each property specifies the image for a face of the cube as either an image URL, or the Id of a [Texture]($backend) element.
|
|
27
|
+
* Each image must be square and have the same dimensions as all the other images.
|
|
19
28
|
* @public
|
|
20
29
|
*/
|
|
21
30
|
export interface SkyCubeProps {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/** Id of a persistent texture element stored in the iModel to use for the bottom of the skybox cube. */
|
|
29
|
-
bottom?: Id64String;
|
|
30
|
-
/** Id of a persistent texture element stored in the iModel to use for the right side of the skybox cube. */
|
|
31
|
-
right?: Id64String;
|
|
32
|
-
/** Id of a persistent texture element stored in the iModel to use for the left side of the skybox cube. */
|
|
33
|
-
left?: Id64String;
|
|
31
|
+
front: TextureImageSpec;
|
|
32
|
+
back: TextureImageSpec;
|
|
33
|
+
top: TextureImageSpec;
|
|
34
|
+
bottom: TextureImageSpec;
|
|
35
|
+
right: TextureImageSpec;
|
|
36
|
+
left: TextureImageSpec;
|
|
34
37
|
}
|
|
35
|
-
/** JSON representation of
|
|
38
|
+
/** JSON representation of the image used for a [[SkySphere]].
|
|
39
|
+
* @see [[SkyBoxProps.image]].
|
|
36
40
|
* @public
|
|
37
41
|
*/
|
|
38
|
-
export interface
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
/** For [[SkyBoxImageType.Cube]], the Ids of persistent texture elements stored in the iModel drawn on each face of the cube. */
|
|
44
|
-
textures?: SkyCubeProps;
|
|
42
|
+
export interface SkySphereImageProps {
|
|
43
|
+
type: SkyBoxImageType.Spherical;
|
|
44
|
+
texture: TextureImageSpec;
|
|
45
|
+
/** @internal */
|
|
46
|
+
textures?: never;
|
|
45
47
|
}
|
|
46
|
-
/** JSON representation of
|
|
48
|
+
/** JSON representation of the images used for a [[SkyCube]].
|
|
49
|
+
* @see [[SkyBoxProps.image]].
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export interface SkyCubeImageProps {
|
|
53
|
+
type: SkyBoxImageType.Cube;
|
|
54
|
+
textures: SkyCubeProps;
|
|
55
|
+
/** @internal */
|
|
56
|
+
texture?: never;
|
|
57
|
+
}
|
|
58
|
+
/** JSON representation of the image(s) to be mapped to the surfaces of a [[SkyBox]].
|
|
59
|
+
* @see [[SkyBoxProps.image]].
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export declare type SkyBoxImageProps = SkySphereImageProps | SkyCubeImageProps | {
|
|
63
|
+
type?: SkyBoxImageType;
|
|
64
|
+
texture?: never;
|
|
65
|
+
textures?: never;
|
|
66
|
+
};
|
|
67
|
+
/** JSON representation of a [[SkyBox]] that can be drawn as the background of a [ViewState3d]($frontend).
|
|
47
68
|
* An object of this type can describe one of several types of sky box:
|
|
48
69
|
* - A cube with a texture image mapped to each face; or
|
|
49
70
|
* - A sphere with a single texture image mapped to its surface; or
|
|
@@ -68,15 +89,15 @@ export interface SkyBoxProps {
|
|
|
68
89
|
* Default: false.
|
|
69
90
|
*/
|
|
70
91
|
display?: boolean;
|
|
71
|
-
/** For a [SkyGradient]
|
|
92
|
+
/** For a [[SkyGradient]], if true, a 2-color gradient skybox is used instead of a 4-color.
|
|
72
93
|
* Default: false.
|
|
73
94
|
*/
|
|
74
95
|
twoColor?: boolean;
|
|
75
|
-
/** The color of the sky at the horizon. Unused unless this is a four-color [SkyGradient]
|
|
96
|
+
/** The color of the sky at the horizon. Unused unless this is a four-color [[SkyGradient]].
|
|
76
97
|
* Default: (143, 205, 255).
|
|
77
98
|
*/
|
|
78
99
|
skyColor?: ColorDefProps;
|
|
79
|
-
/** The color of the ground at the horizon. Unused unless this is a four-color [SkyGradient]
|
|
100
|
+
/** The color of the ground at the horizon. Unused unless this is a four-color [[SkyGradient]].
|
|
80
101
|
* Default: (120, 143, 125).
|
|
81
102
|
*/
|
|
82
103
|
groundColor?: ColorDefProps;
|
|
@@ -88,11 +109,11 @@ export interface SkyBoxProps {
|
|
|
88
109
|
* Default: (40, 15, 0).
|
|
89
110
|
*/
|
|
90
111
|
nadirColor?: ColorDefProps;
|
|
91
|
-
/** For a 4-color [SkyGradient]
|
|
112
|
+
/** For a 4-color [[SkyGradient]], controls speed of change from sky color to zenith color; otherwise unused.
|
|
92
113
|
* Default: 4.0.
|
|
93
114
|
*/
|
|
94
115
|
skyExponent?: number;
|
|
95
|
-
/** For a 4-color [SkyGradient]
|
|
116
|
+
/** For a 4-color [[SkyGradient]], controls speed of change from ground color to nadir color; otherwise unused.
|
|
96
117
|
* Default: 4.0.
|
|
97
118
|
*/
|
|
98
119
|
groundExponent?: number;
|
|
@@ -101,4 +122,91 @@ export interface SkyBoxProps {
|
|
|
101
122
|
*/
|
|
102
123
|
image?: SkyBoxImageProps;
|
|
103
124
|
}
|
|
125
|
+
/** A type containing all of the properties and none of the methods of [[SkyGradient]] with `readonly` modifiers removed.
|
|
126
|
+
* @see [[SkyGradient.create]] and [[SkyGradient.clone]].
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare type SkyGradientProperties = NonFunctionPropertiesOf<SkyGradient>;
|
|
130
|
+
/** Describes how to map a two- or four-color [[Gradient]] to the interior of a sphere to produce a [[SkyBox]].
|
|
131
|
+
* @see [[SkyBox.gradient]].
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
export declare class SkyGradient {
|
|
135
|
+
readonly twoColor: boolean;
|
|
136
|
+
readonly skyColor: ColorDef;
|
|
137
|
+
readonly groundColor: ColorDef;
|
|
138
|
+
readonly zenithColor: ColorDef;
|
|
139
|
+
readonly nadirColor: ColorDef;
|
|
140
|
+
readonly skyExponent: number;
|
|
141
|
+
readonly groundExponent: number;
|
|
142
|
+
private constructor();
|
|
143
|
+
/** Default settings for a four-color gradient. */
|
|
144
|
+
static readonly defaults: SkyGradient;
|
|
145
|
+
/** Create a new gradient. Any properties not specified by `props` are initialized to their default values. */
|
|
146
|
+
static create(props?: Partial<SkyGradientProperties>): SkyGradient;
|
|
147
|
+
/** Create from JSON representation. */
|
|
148
|
+
static fromJSON(props?: SkyBoxProps): SkyGradient;
|
|
149
|
+
/** Create ea copy of this gradient, identical except for any properties explicitly specified by `changedProps`.
|
|
150
|
+
* Any properties of `changedProps` explicitly set to `undefined` will be reset to their default values.
|
|
151
|
+
*/
|
|
152
|
+
clone(changedProps: SkyGradientProperties): SkyGradient;
|
|
153
|
+
/** Convert to JSON representation. */
|
|
154
|
+
toJSON(): SkyBoxProps;
|
|
155
|
+
/** Returns true if this gradient is equivalent to the supplied gradient. */
|
|
156
|
+
equals(other: SkyGradient): boolean;
|
|
157
|
+
}
|
|
158
|
+
/** Describes how to draw a representation of a sky, as part of an [[Environment]].
|
|
159
|
+
* @see [[SkyBoxProps]].
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
162
|
+
export declare class SkyBox {
|
|
163
|
+
/** The gradient settings, used if no cube or sphere images are supplied, or if the images cannot be loaded. */
|
|
164
|
+
readonly gradient: SkyGradient;
|
|
165
|
+
protected constructor(gradient: SkyGradient);
|
|
166
|
+
/** Default settings for a four-color gradient. */
|
|
167
|
+
static readonly defaults: SkyBox;
|
|
168
|
+
/** Create a skybox that displays the specified gradient, or the default gradient if none is supplied. */
|
|
169
|
+
static createGradient(gradient?: SkyGradient): SkyBox;
|
|
170
|
+
/** Create from JSON representation. */
|
|
171
|
+
static fromJSON(props?: SkyBoxProps): SkyBox;
|
|
172
|
+
/** Convert to JSON representation.
|
|
173
|
+
* @param display If defined, the value to use for [[SkyBoxProps.display]]; otherwise, that property will be left undefined.
|
|
174
|
+
*/
|
|
175
|
+
toJSON(display?: boolean): SkyBoxProps;
|
|
176
|
+
/** @internal */
|
|
177
|
+
get textureIds(): Iterable<Id64String>;
|
|
178
|
+
}
|
|
179
|
+
/** Describes how to draw a representation of a sky by mapping a single image to the interior of a sphere.
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
export declare class SkySphere extends SkyBox {
|
|
183
|
+
/** The image to map to the interior of the sphere. */
|
|
184
|
+
readonly image: TextureImageSpec;
|
|
185
|
+
/** Create a new sky sphere using the specified image.
|
|
186
|
+
* @param image The image to map to the interior of the sphere.
|
|
187
|
+
* @param gradient Optionally overrides the default gradient settings used if the image cannot be obtained.
|
|
188
|
+
*/
|
|
189
|
+
constructor(image: TextureImageSpec, gradient?: SkyGradient);
|
|
190
|
+
/** @internal override */
|
|
191
|
+
toJSON(display?: boolean): SkyBoxProps;
|
|
192
|
+
/** @internal */
|
|
193
|
+
get textureIds(): Iterable<Id64String>;
|
|
194
|
+
}
|
|
195
|
+
/** Describes how to draw a representation of a sky by mapping images to the interior faces of a cube.
|
|
196
|
+
* The images are required to be *square*, and each image must have the same dimensions as the other images.
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
export declare class SkyCube extends SkyBox {
|
|
200
|
+
/** The images to map to each face of the cube. */
|
|
201
|
+
readonly images: SkyCubeProps;
|
|
202
|
+
/** Create a new sky cube using the specified images.
|
|
203
|
+
* @param images The images to map to each face of the cube.
|
|
204
|
+
* @param Optionally overrides the default gradient settings used if the images cannot be obtained.
|
|
205
|
+
*/
|
|
206
|
+
constructor(images: SkyCubeProps, gradient?: SkyGradient);
|
|
207
|
+
/** @internal override */
|
|
208
|
+
toJSON(display?: boolean): SkyBoxProps;
|
|
209
|
+
/** @internal */
|
|
210
|
+
get textureIds(): Iterable<Id64String>;
|
|
211
|
+
}
|
|
104
212
|
//# sourceMappingURL=SkyBox.d.ts.map
|
package/lib/esm/SkyBox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkyBox.d.ts","sourceRoot":"","sources":["../../src/SkyBox.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"SkyBox.d.ts","sourceRoot":"","sources":["../../src/SkyBox.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAQ,UAAU,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;GAGG;AACH,oBAAY,eAAe;IACzB,kEAAkE;IAClE,IAAI,IAAI;IACR;;OAEG;IACH,SAAS,IAAI;IACb,kCAAkC;IAClC,WAAW,IAA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;IAQ7C,gBAAgB;IAChB,IAAW,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,CAE5C;CACF;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,MAAM;IACnC,sDAAsD;IACtD,SAAgB,KAAK,EAAE,gBAAgB,CAAC;IAExC;;;OAGG;gBACgB,KAAK,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,WAAW;IAKlE,yBAAyB;IACT,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW;IAUtD,gBAAgB;IAChB,IAAoB,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,CAErD;CACF;AAED;;;GAGG;AACH,qBAAa,OAAQ,SAAQ,MAAM;IACjC,kDAAkD;IAClD,SAAgB,MAAM,EAAE,YAAY,CAAC;IAErC;;;OAGG;gBACgB,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,WAAW;IAK/D,yBAAyB;IACT,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW;IAUtD,gBAAgB;IAChB,IAAoB,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,CAGrD;CACF"}
|
package/lib/esm/SkyBox.js
CHANGED
|
@@ -5,17 +5,199 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module DisplayStyles
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import { Id64 } from "@itwin/core-bentley";
|
|
9
|
+
import { ColorDef } from "./ColorDef";
|
|
10
|
+
/** Supported types of [[SkyBox]] images.
|
|
11
|
+
* @see [[SkyBoxImageProps]].
|
|
9
12
|
* @public
|
|
10
13
|
*/
|
|
11
14
|
export var SkyBoxImageType;
|
|
12
15
|
(function (SkyBoxImageType) {
|
|
16
|
+
/** No image, indicating a [[SkyGradient]] should be displayed. */
|
|
13
17
|
SkyBoxImageType[SkyBoxImageType["None"] = 0] = "None";
|
|
14
|
-
/** A single image mapped to the surface of a sphere.
|
|
18
|
+
/** A single image mapped to the surface of a sphere.
|
|
19
|
+
* @see [[SkySphere]].
|
|
20
|
+
*/
|
|
15
21
|
SkyBoxImageType[SkyBoxImageType["Spherical"] = 1] = "Spherical";
|
|
16
|
-
/** 6 images mapped to the faces of a cube. @see [SkyCube]($frontend) */
|
|
17
|
-
SkyBoxImageType[SkyBoxImageType["Cube"] = 2] = "Cube";
|
|
18
22
|
/** @internal not yet supported */
|
|
19
|
-
SkyBoxImageType[SkyBoxImageType["Cylindrical"] =
|
|
23
|
+
SkyBoxImageType[SkyBoxImageType["Cylindrical"] = 2] = "Cylindrical";
|
|
24
|
+
/** Six images mapped to the faces of a cube.
|
|
25
|
+
* @see [[SkyCube]].
|
|
26
|
+
*/
|
|
27
|
+
SkyBoxImageType[SkyBoxImageType["Cube"] = 3] = "Cube";
|
|
20
28
|
})(SkyBoxImageType || (SkyBoxImageType = {}));
|
|
29
|
+
const defaultGroundColor = ColorDef.from(143, 205, 125);
|
|
30
|
+
const defaultZenithColor = ColorDef.from(54, 117, 255);
|
|
31
|
+
const defaultNadirColor = ColorDef.from(40, 125, 0);
|
|
32
|
+
const defaultSkyColor = ColorDef.from(142, 205, 255);
|
|
33
|
+
const defaultExponent = 4.0;
|
|
34
|
+
function colorDefFromJson(props) {
|
|
35
|
+
return undefined !== props ? ColorDef.fromJSON(props) : undefined;
|
|
36
|
+
}
|
|
37
|
+
/** Describes how to map a two- or four-color [[Gradient]] to the interior of a sphere to produce a [[SkyBox]].
|
|
38
|
+
* @see [[SkyBox.gradient]].
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export class SkyGradient {
|
|
42
|
+
constructor(args) {
|
|
43
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
44
|
+
this.twoColor = (_a = args.twoColor) !== null && _a !== void 0 ? _a : false;
|
|
45
|
+
this.skyColor = (_b = args.skyColor) !== null && _b !== void 0 ? _b : defaultSkyColor;
|
|
46
|
+
this.groundColor = (_c = args.groundColor) !== null && _c !== void 0 ? _c : defaultGroundColor;
|
|
47
|
+
this.nadirColor = (_d = args.nadirColor) !== null && _d !== void 0 ? _d : defaultNadirColor;
|
|
48
|
+
this.zenithColor = (_e = args.zenithColor) !== null && _e !== void 0 ? _e : defaultZenithColor;
|
|
49
|
+
this.skyExponent = (_f = args.skyExponent) !== null && _f !== void 0 ? _f : defaultExponent;
|
|
50
|
+
this.groundExponent = (_g = args.groundExponent) !== null && _g !== void 0 ? _g : defaultExponent;
|
|
51
|
+
}
|
|
52
|
+
/** Create a new gradient. Any properties not specified by `props` are initialized to their default values. */
|
|
53
|
+
static create(props) {
|
|
54
|
+
return props ? new this(props) : this.defaults;
|
|
55
|
+
}
|
|
56
|
+
/** Create from JSON representation. */
|
|
57
|
+
static fromJSON(props) {
|
|
58
|
+
if (!props)
|
|
59
|
+
return this.defaults;
|
|
60
|
+
return new this({
|
|
61
|
+
twoColor: props.twoColor,
|
|
62
|
+
skyExponent: props.skyExponent,
|
|
63
|
+
groundExponent: props.groundExponent,
|
|
64
|
+
skyColor: colorDefFromJson(props.skyColor),
|
|
65
|
+
groundColor: colorDefFromJson(props.groundColor),
|
|
66
|
+
nadirColor: colorDefFromJson(props.nadirColor),
|
|
67
|
+
zenithColor: colorDefFromJson(props.zenithColor),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/** Create ea copy of this gradient, identical except for any properties explicitly specified by `changedProps`.
|
|
71
|
+
* Any properties of `changedProps` explicitly set to `undefined` will be reset to their default values.
|
|
72
|
+
*/
|
|
73
|
+
clone(changedProps) {
|
|
74
|
+
return new SkyGradient({ ...this, ...changedProps });
|
|
75
|
+
}
|
|
76
|
+
/** Convert to JSON representation. */
|
|
77
|
+
toJSON() {
|
|
78
|
+
const props = {
|
|
79
|
+
skyColor: this.skyColor.toJSON(),
|
|
80
|
+
groundColor: this.groundColor.toJSON(),
|
|
81
|
+
nadirColor: this.nadirColor.toJSON(),
|
|
82
|
+
zenithColor: this.zenithColor.toJSON(),
|
|
83
|
+
};
|
|
84
|
+
if (this.groundExponent !== defaultExponent)
|
|
85
|
+
props.groundExponent = this.groundExponent;
|
|
86
|
+
if (this.skyExponent !== defaultExponent)
|
|
87
|
+
props.skyExponent = this.skyExponent;
|
|
88
|
+
if (this.twoColor)
|
|
89
|
+
props.twoColor = this.twoColor;
|
|
90
|
+
return props;
|
|
91
|
+
}
|
|
92
|
+
/** Returns true if this gradient is equivalent to the supplied gradient. */
|
|
93
|
+
equals(other) {
|
|
94
|
+
if (this === other)
|
|
95
|
+
return true;
|
|
96
|
+
return this.twoColor === other.twoColor && this.skyColor.equals(other.skyColor) && this.groundColor.equals(other.groundColor) &&
|
|
97
|
+
this.zenithColor.equals(other.zenithColor) && this.nadirColor.equals(other.nadirColor);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Default settings for a four-color gradient. */
|
|
101
|
+
SkyGradient.defaults = new SkyGradient({});
|
|
102
|
+
/** Describes how to draw a representation of a sky, as part of an [[Environment]].
|
|
103
|
+
* @see [[SkyBoxProps]].
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
export class SkyBox {
|
|
107
|
+
constructor(gradient) {
|
|
108
|
+
this.gradient = gradient;
|
|
109
|
+
}
|
|
110
|
+
/** Create a skybox that displays the specified gradient, or the default gradient if none is supplied. */
|
|
111
|
+
static createGradient(gradient) {
|
|
112
|
+
return gradient ? new this(gradient) : this.defaults;
|
|
113
|
+
}
|
|
114
|
+
/** Create from JSON representation. */
|
|
115
|
+
static fromJSON(props) {
|
|
116
|
+
const gradient = SkyGradient.fromJSON(props);
|
|
117
|
+
if (props === null || props === void 0 ? void 0 : props.image) {
|
|
118
|
+
switch (props.image.type) {
|
|
119
|
+
case SkyBoxImageType.Spherical:
|
|
120
|
+
if (undefined !== props.image.texture)
|
|
121
|
+
return new SkySphere(props.image.texture, gradient);
|
|
122
|
+
break;
|
|
123
|
+
case SkyBoxImageType.Cube: {
|
|
124
|
+
const tx = props.image.textures;
|
|
125
|
+
if (tx && undefined !== tx.top && undefined !== tx.bottom && undefined !== tx.right && undefined !== tx.left && undefined !== tx.front && undefined !== tx.back)
|
|
126
|
+
return new SkyCube(tx, gradient);
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return this.createGradient(gradient);
|
|
132
|
+
}
|
|
133
|
+
/** Convert to JSON representation.
|
|
134
|
+
* @param display If defined, the value to use for [[SkyBoxProps.display]]; otherwise, that property will be left undefined.
|
|
135
|
+
*/
|
|
136
|
+
toJSON(display) {
|
|
137
|
+
const props = this.gradient.toJSON();
|
|
138
|
+
if (undefined !== display)
|
|
139
|
+
props.display = display;
|
|
140
|
+
return props;
|
|
141
|
+
}
|
|
142
|
+
/** @internal */
|
|
143
|
+
get textureIds() {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Default settings for a four-color gradient. */
|
|
148
|
+
SkyBox.defaults = new SkyBox(SkyGradient.defaults);
|
|
149
|
+
/** Describes how to draw a representation of a sky by mapping a single image to the interior of a sphere.
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
export class SkySphere extends SkyBox {
|
|
153
|
+
/** Create a new sky sphere using the specified image.
|
|
154
|
+
* @param image The image to map to the interior of the sphere.
|
|
155
|
+
* @param gradient Optionally overrides the default gradient settings used if the image cannot be obtained.
|
|
156
|
+
*/
|
|
157
|
+
constructor(image, gradient) {
|
|
158
|
+
super(gradient !== null && gradient !== void 0 ? gradient : SkyGradient.defaults);
|
|
159
|
+
this.image = image;
|
|
160
|
+
}
|
|
161
|
+
/** @internal override */
|
|
162
|
+
toJSON(display) {
|
|
163
|
+
const props = super.toJSON(display);
|
|
164
|
+
props.image = {
|
|
165
|
+
type: SkyBoxImageType.Spherical,
|
|
166
|
+
texture: this.image,
|
|
167
|
+
};
|
|
168
|
+
return props;
|
|
169
|
+
}
|
|
170
|
+
/** @internal */
|
|
171
|
+
get textureIds() {
|
|
172
|
+
return Id64.isValidId64(this.image) ? [this.image] : [];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Describes how to draw a representation of a sky by mapping images to the interior faces of a cube.
|
|
176
|
+
* The images are required to be *square*, and each image must have the same dimensions as the other images.
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
export class SkyCube extends SkyBox {
|
|
180
|
+
/** Create a new sky cube using the specified images.
|
|
181
|
+
* @param images The images to map to each face of the cube.
|
|
182
|
+
* @param Optionally overrides the default gradient settings used if the images cannot be obtained.
|
|
183
|
+
*/
|
|
184
|
+
constructor(images, gradient) {
|
|
185
|
+
super(gradient !== null && gradient !== void 0 ? gradient : SkyGradient.defaults);
|
|
186
|
+
this.images = { ...images };
|
|
187
|
+
}
|
|
188
|
+
/** @internal override */
|
|
189
|
+
toJSON(display) {
|
|
190
|
+
const props = super.toJSON(display);
|
|
191
|
+
props.image = {
|
|
192
|
+
type: SkyBoxImageType.Cube,
|
|
193
|
+
textures: { ...this.images },
|
|
194
|
+
};
|
|
195
|
+
return props;
|
|
196
|
+
}
|
|
197
|
+
/** @internal */
|
|
198
|
+
get textureIds() {
|
|
199
|
+
const imgs = this.images;
|
|
200
|
+
return [imgs.front, imgs.back, imgs.top, imgs.bottom, imgs.left, imgs.right].filter((x) => Id64.isValidId64(x));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
21
203
|
//# sourceMappingURL=SkyBox.js.map
|
package/lib/esm/SkyBox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkyBox.js","sourceRoot":"","sources":["../../src/SkyBox.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAKH;;GAEG;AACH,MAAM,CAAN,IAAY,eAQX;AARD,WAAY,eAAe;IACzB,qDAAI,CAAA;IACJ,oFAAoF;IACpF,+DAAS,CAAA;IACT,wEAAwE;IACxE,qDAAI,CAAA;IACJ,kCAAkC;IAClC,mEAAW,CAAA;AACb,CAAC,EARW,eAAe,KAAf,eAAe,QAQ1B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module DisplayStyles\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { ColorDefProps } from \"./ColorDef\";\r\n\r\n/** Enumerates the supported types of [SkyBox]($frontend) images.\r\n * @public\r\n */\r\nexport enum SkyBoxImageType {\r\n None,\r\n /** A single image mapped to the surface of a sphere. @see [SkySphere]($frontend) */\r\n Spherical,\r\n /** 6 images mapped to the faces of a cube. @see [SkyCube]($frontend) */\r\n Cube,\r\n /** @internal not yet supported */\r\n Cylindrical,\r\n}\r\n\r\n/** JSON representation of a set of images used by a [SkyCube]($frontend). Each property specifies the element ID of a texture associated with one face of the cube.\r\n * @public\r\n */\r\nexport interface SkyCubeProps {\r\n /** Id of a persistent texture element stored in the iModel to use for the front side of the skybox cube. */\r\n front?: Id64String;\r\n /** Id of a persistent texture element stored in the iModel to use for the back side of the skybox cube. */\r\n back?: Id64String;\r\n /** Id of a persistent texture element stored in the iModel to use for the top of the skybox cube. */\r\n top?: Id64String;\r\n /** Id of a persistent texture element stored in the iModel to use for the bottom of the skybox cube. */\r\n bottom?: Id64String;\r\n /** Id of a persistent texture element stored in the iModel to use for the right side of the skybox cube. */\r\n right?: Id64String;\r\n /** Id of a persistent texture element stored in the iModel to use for the left side of the skybox cube. */\r\n left?: Id64String;\r\n}\r\n\r\n/** JSON representation of an image or images used by a [SkySphere]($frontend) or [SkyCube]($frontend).\r\n * @public\r\n */\r\nexport interface SkyBoxImageProps {\r\n /** The type of skybox image. */\r\n type?: SkyBoxImageType;\r\n /** For [[SkyBoxImageType.Spherical]], the Id of a persistent texture element stored in the iModel to be drawn as the \"sky\". */\r\n texture?: Id64String;\r\n /** For [[SkyBoxImageType.Cube]], the Ids of persistent texture elements stored in the iModel drawn on each face of the cube. */\r\n textures?: SkyCubeProps;\r\n}\r\n\r\n/** JSON representation of a [SkyBox]($frontend) that can be drawn as the background of a [ViewState3d]($frontend).\r\n * An object of this type can describe one of several types of sky box:\r\n * - A cube with a texture image mapped to each face; or\r\n * - A sphere with a single texture image mapped to its surface; or\r\n * - A sphere with a two- or four-color vertical [[Gradient]] mapped to its surface.\r\n *\r\n * Whether cuboid or spherical, the skybox is drawn as if the viewer and the contents of the view are contained within its interior.\r\n *\r\n * For a two-color gradient, the gradient transitions smoothly from the nadir color at the bottom of the sphere to the zenith color at the top of the sphere.\r\n * The sky and ground colors are unused, as are the sky and ground exponents.\r\n *\r\n * For a four-color gradient, a \"horizon\" is produced on the equator of the sphere, where the ground color and sky color meet. The lower half of the sphere transitions\r\n * smoothly from the ground color at the equator to the nadir color at the bottom, and the upper half transitions from the sky color at the equator to the zenith color at\r\n * the top of the sphere.\r\n *\r\n * The color and exponent properties are unused if one or more texture images are supplied.\r\n *\r\n * @see [[DisplayStyle3dSettings.environment]] to define the skybox for a display style.\r\n * @public\r\n */\r\nexport interface SkyBoxProps {\r\n /** Whether or not the skybox should be displayed.\r\n * Default: false.\r\n */\r\n display?: boolean;\r\n /** For a [SkyGradient]($frontend), if true, a 2-color gradient skybox is used instead of a 4-color.\r\n * Default: false.\r\n */\r\n twoColor?: boolean;\r\n /** The color of the sky at the horizon. Unused unless this is a four-color [SkyGradient]($frontend).\r\n * Default: (143, 205, 255).\r\n */\r\n skyColor?: ColorDefProps;\r\n /** The color of the ground at the horizon. Unused unless this is a four-color [SkyGradient]($frontend).\r\n * Default: (120, 143, 125).\r\n */\r\n groundColor?: ColorDefProps;\r\n /** The color of the top of the sphere.\r\n * Default: (54, 117, 255).\r\n */\r\n zenithColor?: ColorDefProps;\r\n /** The color of the bottom of the sphere.\r\n * Default: (40, 15, 0).\r\n */\r\n nadirColor?: ColorDefProps;\r\n /** For a 4-color [SkyGradient]($frontend), controls speed of change from sky color to zenith color; otherwise unused.\r\n * Default: 4.0.\r\n */\r\n skyExponent?: number;\r\n /** For a 4-color [SkyGradient]($frontend), controls speed of change from ground color to nadir color; otherwise unused.\r\n * Default: 4.0.\r\n */\r\n groundExponent?: number;\r\n /** The image(s), if any, to be mapped to the surfaces of the sphere or cube. If undefined, the skybox will be displayed as a gradient instead.\r\n * Default: undefined.\r\n */\r\n image?: SkyBoxImageProps;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SkyBox.js","sourceRoot":"","sources":["../../src/SkyBox.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAuC,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAGrD;;;GAGG;AACH,MAAM,CAAN,IAAY,eAaX;AAbD,WAAY,eAAe;IACzB,kEAAkE;IAClE,qDAAQ,CAAA;IACR;;OAEG;IACH,+DAAa,CAAA;IACb,kCAAkC;IAClC,mEAAe,CAAA;IACf;;OAEG;IACH,qDAAQ,CAAA;AACV,CAAC,EAbW,eAAe,KAAf,eAAe,QAa1B;AAuGD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACxD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACvD,MAAM,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AACpD,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACrD,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,SAAS,gBAAgB,CAAC,KAAqB;IAC7C,OAAO,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,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,EAAE,QAAsB;QAC7D,KAAK,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED,yBAAyB;IACT,MAAM,CAAC,OAAiB;QACtC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,CAAC,KAAK,GAAG;YACZ,IAAI,EAAE,eAAe,CAAC,IAAI;YAC1B,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE;SAC7B,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gBAAgB;IAChB,IAAoB,UAAU;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAClH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module DisplayStyles\r\n */\r\n\r\nimport { Id64, Id64String, NonFunctionPropertiesOf } from \"@itwin/core-bentley\";\r\nimport { ColorDef, ColorDefProps } from \"./ColorDef\";\r\nimport { TextureImageSpec } from \"./RenderTexture\";\r\n\r\n/** Supported types of [[SkyBox]] images.\r\n * @see [[SkyBoxImageProps]].\r\n * @public\r\n */\r\nexport enum SkyBoxImageType {\r\n /** No image, indicating a [[SkyGradient]] should be displayed. */\r\n None = 0,\r\n /** A single image mapped to the surface of a sphere.\r\n * @see [[SkySphere]].\r\n */\r\n Spherical = 1,\r\n /** @internal not yet supported */\r\n Cylindrical = 2,\r\n /** Six images mapped to the faces of a cube.\r\n * @see [[SkyCube]].\r\n */\r\n Cube = 3,\r\n}\r\n\r\n/** JSON representation of the six images used by a [[SkyCube]].\r\n * Each property specifies the image for a face of the cube as either an image URL, or the Id of a [Texture]($backend) element.\r\n * Each image must be square and have the same dimensions as all the other images.\r\n * @public\r\n */\r\nexport interface SkyCubeProps {\r\n front: TextureImageSpec;\r\n back: TextureImageSpec;\r\n top: TextureImageSpec;\r\n bottom: TextureImageSpec;\r\n right: TextureImageSpec;\r\n left: TextureImageSpec;\r\n}\r\n\r\n/** JSON representation of the image used for a [[SkySphere]].\r\n * @see [[SkyBoxProps.image]].\r\n * @public\r\n */\r\nexport interface SkySphereImageProps {\r\n type: SkyBoxImageType.Spherical;\r\n texture: TextureImageSpec;\r\n /** @internal */\r\n textures?: never;\r\n}\r\n\r\n/** JSON representation of the images used for a [[SkyCube]].\r\n * @see [[SkyBoxProps.image]].\r\n * @public\r\n */\r\nexport interface SkyCubeImageProps {\r\n type: SkyBoxImageType.Cube;\r\n textures: SkyCubeProps;\r\n /** @internal */\r\n texture?: never;\r\n}\r\n\r\n/** JSON representation of the image(s) to be mapped to the surfaces of a [[SkyBox]].\r\n * @see [[SkyBoxProps.image]].\r\n * @public\r\n */\r\nexport type SkyBoxImageProps = SkySphereImageProps | SkyCubeImageProps | { type?: SkyBoxImageType, texture?: never, textures?: never };\r\n\r\n/** JSON representation of a [[SkyBox]] that can be drawn as the background of a [ViewState3d]($frontend).\r\n * An object of this type can describe one of several types of sky box:\r\n * - A cube with a texture image mapped to each face; or\r\n * - A sphere with a single texture image mapped to its surface; or\r\n * - A sphere with a two- or four-color vertical [[Gradient]] mapped to its surface.\r\n *\r\n * Whether cuboid or spherical, the skybox is drawn as if the viewer and the contents of the view are contained within its interior.\r\n *\r\n * For a two-color gradient, the gradient transitions smoothly from the nadir color at the bottom of the sphere to the zenith color at the top of the sphere.\r\n * The sky and ground colors are unused, as are the sky and ground exponents.\r\n *\r\n * For a four-color gradient, a \"horizon\" is produced on the equator of the sphere, where the ground color and sky color meet. The lower half of the sphere transitions\r\n * smoothly from the ground color at the equator to the nadir color at the bottom, and the upper half transitions from the sky color at the equator to the zenith color at\r\n * the top of the sphere.\r\n *\r\n * The color and exponent properties are unused if one or more texture images are supplied.\r\n *\r\n * @see [[DisplayStyle3dSettings.environment]] to define the skybox for a display style.\r\n * @public\r\n */\r\nexport interface SkyBoxProps {\r\n /** Whether or not the skybox should be displayed.\r\n * Default: false.\r\n */\r\n display?: boolean;\r\n /** For a [[SkyGradient]], if true, a 2-color gradient skybox is used instead of a 4-color.\r\n * Default: false.\r\n */\r\n twoColor?: boolean;\r\n /** The color of the sky at the horizon. Unused unless this is a four-color [[SkyGradient]].\r\n * Default: (143, 205, 255).\r\n */\r\n skyColor?: ColorDefProps;\r\n /** The color of the ground at the horizon. Unused unless this is a four-color [[SkyGradient]].\r\n * Default: (120, 143, 125).\r\n */\r\n groundColor?: ColorDefProps;\r\n /** The color of the top of the sphere.\r\n * Default: (54, 117, 255).\r\n */\r\n zenithColor?: ColorDefProps;\r\n /** The color of the bottom of the sphere.\r\n * Default: (40, 15, 0).\r\n */\r\n nadirColor?: ColorDefProps;\r\n /** For a 4-color [[SkyGradient]], controls speed of change from sky color to zenith color; otherwise unused.\r\n * Default: 4.0.\r\n */\r\n skyExponent?: number;\r\n /** For a 4-color [[SkyGradient]], controls speed of change from ground color to nadir color; otherwise unused.\r\n * Default: 4.0.\r\n */\r\n groundExponent?: number;\r\n /** The image(s), if any, to be mapped to the surfaces of the sphere or cube. If undefined, the skybox will be displayed as a gradient instead.\r\n * Default: undefined.\r\n */\r\n image?: SkyBoxImageProps;\r\n}\r\n\r\nconst defaultGroundColor = ColorDef.from(143, 205, 125);\r\nconst defaultZenithColor = ColorDef.from(54, 117, 255);\r\nconst defaultNadirColor = ColorDef.from(40, 125, 0);\r\nconst defaultSkyColor = ColorDef.from(142, 205, 255);\r\nconst defaultExponent = 4.0;\r\n\r\nfunction colorDefFromJson(props?: ColorDefProps): ColorDef | undefined {\r\n return undefined !== props ? ColorDef.fromJSON(props) : undefined;\r\n}\r\n\r\n/** A type containing all of the properties and none of the methods of [[SkyGradient]] with `readonly` modifiers removed.\r\n * @see [[SkyGradient.create]] and [[SkyGradient.clone]].\r\n * @public\r\n */\r\nexport type SkyGradientProperties = NonFunctionPropertiesOf<SkyGradient>;\r\n\r\n/** Describes how to map a two- or four-color [[Gradient]] to the interior of a sphere to produce a [[SkyBox]].\r\n * @see [[SkyBox.gradient]].\r\n * @public\r\n */\r\nexport class SkyGradient {\r\n public readonly twoColor: boolean;\r\n public readonly skyColor: ColorDef;\r\n public readonly groundColor: ColorDef;\r\n public readonly zenithColor: ColorDef;\r\n public readonly nadirColor: ColorDef;\r\n public readonly skyExponent: number;\r\n public readonly groundExponent: number;\r\n\r\n private constructor(args: Partial<SkyGradientProperties>) {\r\n this.twoColor = args.twoColor ?? false;\r\n this.skyColor = args.skyColor ?? defaultSkyColor;\r\n this.groundColor = args.groundColor ?? defaultGroundColor;\r\n this.nadirColor = args.nadirColor ?? defaultNadirColor;\r\n this.zenithColor = args.zenithColor ?? defaultZenithColor;\r\n this.skyExponent = args.skyExponent ?? defaultExponent;\r\n this.groundExponent = args.groundExponent ?? defaultExponent;\r\n }\r\n\r\n /** Default settings for a four-color gradient. */\r\n public static readonly defaults = new SkyGradient({});\r\n\r\n /** Create a new gradient. Any properties not specified by `props` are initialized to their default values. */\r\n public static create(props?: Partial<SkyGradientProperties>): SkyGradient {\r\n return props ? new this(props) : this.defaults;\r\n }\r\n\r\n /** Create from JSON representation. */\r\n public static fromJSON(props?: SkyBoxProps): SkyGradient {\r\n if (!props)\r\n return this.defaults;\r\n\r\n return new this({\r\n twoColor: props.twoColor,\r\n skyExponent: props.skyExponent,\r\n groundExponent: props.groundExponent,\r\n skyColor: colorDefFromJson(props.skyColor),\r\n groundColor: colorDefFromJson(props.groundColor),\r\n nadirColor: colorDefFromJson(props.nadirColor),\r\n zenithColor: colorDefFromJson(props.zenithColor),\r\n });\r\n }\r\n\r\n /** Create ea copy of this gradient, identical except for any properties explicitly specified by `changedProps`.\r\n * Any properties of `changedProps` explicitly set to `undefined` will be reset to their default values.\r\n */\r\n public clone(changedProps: SkyGradientProperties): SkyGradient {\r\n return new SkyGradient({ ...this, ...changedProps });\r\n }\r\n\r\n /** Convert to JSON representation. */\r\n public toJSON(): SkyBoxProps {\r\n const props: SkyBoxProps = {\r\n skyColor: this.skyColor.toJSON(),\r\n groundColor: this.groundColor.toJSON(),\r\n nadirColor: this.nadirColor.toJSON(),\r\n zenithColor: this.zenithColor.toJSON(),\r\n };\r\n\r\n if (this.groundExponent !== defaultExponent)\r\n props.groundExponent = this.groundExponent;\r\n\r\n if (this.skyExponent !== defaultExponent)\r\n props.skyExponent = this.skyExponent;\r\n\r\n if (this.twoColor)\r\n props.twoColor = this.twoColor;\r\n\r\n return props;\r\n }\r\n\r\n /** Returns true if this gradient is equivalent to the supplied gradient. */\r\n public equals(other: SkyGradient): boolean {\r\n if (this === other)\r\n return true;\r\n\r\n return this.twoColor === other.twoColor && this.skyColor.equals(other.skyColor) && this.groundColor.equals(other.groundColor) &&\r\n this.zenithColor.equals(other.zenithColor) && this.nadirColor.equals(other.nadirColor);\r\n }\r\n}\r\n\r\n/** Describes how to draw a representation of a sky, as part of an [[Environment]].\r\n * @see [[SkyBoxProps]].\r\n * @public\r\n */\r\nexport class SkyBox {\r\n /** The gradient settings, used if no cube or sphere images are supplied, or if the images cannot be loaded. */\r\n public readonly gradient: SkyGradient;\r\n\r\n protected constructor(gradient: SkyGradient) {\r\n this.gradient = gradient;\r\n }\r\n\r\n /** Default settings for a four-color gradient. */\r\n public static readonly defaults = new SkyBox(SkyGradient.defaults);\r\n\r\n /** Create a skybox that displays the specified gradient, or the default gradient if none is supplied. */\r\n public static createGradient(gradient?: SkyGradient): SkyBox {\r\n return gradient ? new this(gradient) : this.defaults;\r\n }\r\n\r\n /** Create from JSON representation. */\r\n public static fromJSON(props?: SkyBoxProps): SkyBox {\r\n const gradient = SkyGradient.fromJSON(props);\r\n\r\n if (props?.image) {\r\n switch (props.image.type) {\r\n case SkyBoxImageType.Spherical:\r\n if (undefined !== props.image.texture)\r\n return new SkySphere(props.image.texture, gradient);\r\n\r\n break;\r\n case SkyBoxImageType.Cube: {\r\n const tx = props.image.textures;\r\n if (tx && undefined !== tx.top && undefined !== tx.bottom && undefined !== tx.right && undefined !== tx.left && undefined !== tx.front && undefined !== tx.back)\r\n return new SkyCube(tx, gradient);\r\n\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return this.createGradient(gradient);\r\n }\r\n\r\n /** Convert to JSON representation.\r\n * @param display If defined, the value to use for [[SkyBoxProps.display]]; otherwise, that property will be left undefined.\r\n */\r\n public toJSON(display?: boolean): SkyBoxProps {\r\n const props = this.gradient.toJSON();\r\n if (undefined !== display)\r\n props.display = display;\r\n\r\n return props;\r\n }\r\n\r\n /** @internal */\r\n public get textureIds(): Iterable<Id64String> {\r\n return [];\r\n }\r\n}\r\n\r\n/** Describes how to draw a representation of a sky by mapping a single image to the interior of a sphere.\r\n * @public\r\n */\r\nexport class SkySphere extends SkyBox {\r\n /** The image to map to the interior of the sphere. */\r\n public readonly image: TextureImageSpec;\r\n\r\n /** Create a new sky sphere using the specified image.\r\n * @param image The image to map to the interior of the sphere.\r\n * @param gradient Optionally overrides the default gradient settings used if the image cannot be obtained.\r\n */\r\n public constructor(image: TextureImageSpec, gradient?: SkyGradient) {\r\n super(gradient ?? SkyGradient.defaults);\r\n this.image = image;\r\n }\r\n\r\n /** @internal override */\r\n public override toJSON(display?: boolean): SkyBoxProps {\r\n const props = super.toJSON(display);\r\n props.image = {\r\n type: SkyBoxImageType.Spherical,\r\n texture: this.image,\r\n };\r\n\r\n return props;\r\n }\r\n\r\n /** @internal */\r\n public override get textureIds(): Iterable<Id64String> {\r\n return Id64.isValidId64(this.image) ? [this.image] : [];\r\n }\r\n}\r\n\r\n/** Describes how to draw a representation of a sky by mapping images to the interior faces of a cube.\r\n * The images are required to be *square*, and each image must have the same dimensions as the other images.\r\n * @public\r\n */\r\nexport class SkyCube extends SkyBox {\r\n /** The images to map to each face of the cube. */\r\n public readonly images: SkyCubeProps;\r\n\r\n /** Create a new sky cube using the specified images.\r\n * @param images The images to map to each face of the cube.\r\n * @param Optionally overrides the default gradient settings used if the images cannot be obtained.\r\n */\r\n public constructor(images: SkyCubeProps, gradient?: SkyGradient) {\r\n super(gradient ?? SkyGradient.defaults);\r\n this.images = { ...images };\r\n }\r\n\r\n /** @internal override */\r\n public override toJSON(display?: boolean): SkyBoxProps {\r\n const props = super.toJSON(display);\r\n props.image = {\r\n type: SkyBoxImageType.Cube,\r\n textures: { ...this.images },\r\n };\r\n\r\n return props;\r\n }\r\n\r\n /** @internal */\r\n public override get textureIds(): Iterable<Id64String> {\r\n const imgs = this.images;\r\n return [imgs.front, imgs.back, imgs.top, imgs.bottom, imgs.left, imgs.right].filter((x) => Id64.isValidId64(x));\r\n }\r\n}\r\n"]}
|
|
@@ -53,6 +53,8 @@ export declare namespace TextureMapping {
|
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
constructor(m00?: number, m01?: number, originX?: number, m10?: number, m11?: number, originY?: number);
|
|
56
|
+
/** An immutable 2x3 identity matrix. */
|
|
57
|
+
static readonly identity: Trans2x3;
|
|
56
58
|
}
|
|
57
59
|
/** Properties used to construct a [[TextureMapping.Params]]. */
|
|
58
60
|
interface ParamProps {
|
|
@@ -83,7 +85,7 @@ export declare namespace TextureMapping {
|
|
|
83
85
|
mode: TextureMapping.Mode;
|
|
84
86
|
/** @internal */
|
|
85
87
|
worldMapping: boolean;
|
|
86
|
-
constructor(props?: ParamProps);
|
|
88
|
+
constructor(props?: TextureMapping.ParamProps);
|
|
87
89
|
/**
|
|
88
90
|
* Generates UV parameters for textured surfaces. Returns undefined on failure.
|
|
89
91
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextureMapping.d.ts","sourceRoot":"","sources":["../../src/TextureMapping.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAAY,OAAO,EAAW,eAAe,EAAE,SAAS,EAAY,MAAM,sBAAsB,CAAC;AAChI,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,qBAAa,cAAc;IACzB,+CAA+C;IAC/C,SAAgB,OAAO,EAAE,aAAa,CAAC;IACvC,gFAAgF;IAChF,SAAgB,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC;gBAE3B,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM;IAKnE,gBAAgB;IACT,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,GAAG,OAAO,EAAE,GAAG,SAAS;CAGtG;AAED,cAAc;AACd,yBAAiB,cAAc,CAAC;IAC9B,qDAAqD;IACrD,KAAY,IAAI;QACd,IAAI,KAAK;QACT,UAAU,IAAI;QACd,cAAc,IAAI;QAClB,MAAM,IAAI;QACV,gBAAgB;QAChB,gBAAgB,IAAI;QACpB,gBAAgB;QAChB,KAAK,IAAI;QACT,gBAAgB;QAChB,SAAS,IAAI;QACb,gBAAgB;QAChB,WAAW,IAAI;QACf,gBAAgB;QAChB,KAAK,IAAI;QACT,sCAAsC;QACtC,YAAY,IAAI;KACjB;IAED,6DAA6D;IAC7D,MAAa,QAAQ;QACnB,sDAAsD;QACtD,SAAgB,SAAS,EAAE,SAAS,CAAC;QAErC;;;;;;;;;;;WAWG;oBACgB,GAAG,SAAI,EAAE,GAAG,SAAI,EAAE,OAAO,SAAI,EAAE,GAAG,SAAI,EAAE,GAAG,SAAI,EAAE,OAAO,SAAI;
|
|
1
|
+
{"version":3,"file":"Texture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CAAC;QACxC;;;;WAIG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB;;WAEG;QACH,OAAO,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC;QAC9B,gBAAgB;QAChB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB;IAED,oFAAoF;IACpF,MAAa,MAAM;QACjB,qDAAqD;QAC9C,aAAa,EAAE,cAAc,CAAC,QAAQ,CAAC;QAC9C;;WAEG;QACI,MAAM,EAAE,MAAM,CAAC;QACtB,uDAAuD;QAChD,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC;QACjC,gBAAgB;QACT,YAAY,EAAE,OAAO,CAAC;oBAEV,KAAK,CAAC,EAAE,cAAc,CAAC,UAAU;QAOpD;;;WAGG;QACI,eAAe,CAAC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,SAAS,GAAG,OAAO,EAAE,GAAG,SAAS;QAwB5G,yEAAyE;QACzE,OAAO,CAAC,yBAAyB;QAiBjC,sHAAsH;QACtH,OAAO,CAAC,qBAAqB;QA+C7B,+HAA+H;QAC/H,OAAO,CAAC,6BAA6B;KActC;CACF"}
|
|
@@ -61,15 +61,17 @@ export class TextureMapping {
|
|
|
61
61
|
this.transform = Transform.createRefs(origin, matrix);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
/** An immutable 2x3 identity matrix. */
|
|
65
|
+
Trans2x3.identity = new Trans2x3();
|
|
64
66
|
TextureMapping.Trans2x3 = Trans2x3;
|
|
65
67
|
/** Parameters describing how a [[RenderTexture]]'s image is mapped to a surface. */
|
|
66
68
|
class Params {
|
|
67
|
-
constructor(props
|
|
68
|
-
|
|
69
|
-
this.textureMatrix = textureMat2x3;
|
|
70
|
-
this.weight = textureWeight;
|
|
71
|
-
this.mode = mapMode;
|
|
72
|
-
this.worldMapping = worldMapping;
|
|
69
|
+
constructor(props) {
|
|
70
|
+
var _a, _b, _c, _d;
|
|
71
|
+
this.textureMatrix = (_a = props === null || props === void 0 ? void 0 : props.textureMat2x3) !== null && _a !== void 0 ? _a : Trans2x3.identity;
|
|
72
|
+
this.weight = (_b = props === null || props === void 0 ? void 0 : props.textureWeight) !== null && _b !== void 0 ? _b : 1;
|
|
73
|
+
this.mode = (_c = props === null || props === void 0 ? void 0 : props.mapMode) !== null && _c !== void 0 ? _c : Mode.Parametric;
|
|
74
|
+
this.worldMapping = (_d = props === null || props === void 0 ? void 0 : props.worldMapping) !== null && _d !== void 0 ? _d : false;
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* Generates UV parameters for textured surfaces. Returns undefined on failure.
|
|
@@ -165,4 +167,5 @@ export class TextureMapping {
|
|
|
165
167
|
}
|
|
166
168
|
TextureMapping.Params = Params;
|
|
167
169
|
})(TextureMapping || (TextureMapping = {}));
|
|
170
|
+
Object.freeze(TextureMapping.Trans2x3.identity);
|
|
168
171
|
//# sourceMappingURL=TextureMapping.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextureMapping.js","sourceRoot":"","sources":["../../src/TextureMapping.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA0B,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAmB,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhI;;GAEG;AACH,MAAM,OAAO,cAAc;IAMzB,YAAmB,EAAiB,EAAE,MAA6B;QACjE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,gBAAgB;IACT,eAAe,CAAC,OAAwB,EAAE,iBAA4B;QAC3E,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAiC,EAAE,iBAAiB,CAAC,CAAC;IAC3F,CAAC;CACF;AAED,cAAc;AACd,WAAiB,cAAc;IAC7B,qDAAqD;IACrD,IAAY,IAiBX;IAjBD,WAAY,IAAI;QACd,gCAAS,CAAA;QACT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EAAE,iBAA6B;YAC1H,MAAM,MAAM,GAAc,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;YAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;gBACjC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC,CAAC;gBAE/D,IAAI,iBAAiB,KAAK,SAAS;oBACjC,iBAAiB,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAElD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvC,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aACnD;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF;IA9HY,qBAAM,SA8HlB,CAAA;AACH,CAAC,EA/LgB,cAAc,KAAd,cAAc,QA+L9B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { IndexedPolyfaceVisitor, Matrix3d, Point2d, Point3d, PolyfaceVisitor, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { RenderTexture } from \"./RenderTexture\";\r\n\r\n/** Describes how to map a [[RenderTexture]]'s image onto a surface as part of a [[RenderMaterial]].\r\n * @public\r\n */\r\nexport class TextureMapping {\r\n /** The texture to be mapped to the surface. */\r\n public readonly texture: RenderTexture;\r\n /** The parameters describing how the texture image is mapped to the surface. */\r\n public readonly params: TextureMapping.Params;\r\n\r\n public constructor(tx: RenderTexture, params: TextureMapping.Params) {\r\n this.texture = tx;\r\n this.params = params;\r\n }\r\n\r\n /** @internal */\r\n public computeUVParams(visitor: PolyfaceVisitor, transformToImodel: Transform): Point2d[] | undefined {\r\n return this.params.computeUVParams(visitor as IndexedPolyfaceVisitor, transformToImodel);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace TextureMapping { // eslint-disable-line no-redeclare\r\n /** Enumerates the possible texture mapping modes. */\r\n export enum Mode {\r\n None = -1,\r\n Parametric = 0,\r\n ElevationDrape = 1,\r\n Planar = 2,\r\n /** @internal */\r\n DirectionalDrape = 3,\r\n /** @internal */\r\n Cubic = 4,\r\n /** @internal */\r\n Spherical = 5,\r\n /** @internal */\r\n Cylindrical = 6,\r\n /** @internal */\r\n Solid = 7,\r\n /** @internal Only valid for lights */\r\n FrontProject = 8,\r\n }\r\n\r\n /** A 2x3 matrix for mapping a texture image to a surface. */\r\n export class Trans2x3 {\r\n /** The 3x4 transform produced from the 2x3 matrix. */\r\n public readonly transform: Transform;\r\n\r\n /** Construct from the two rows of the matrix:\r\n * ```\r\n * | m00 m01 originX |\r\n * | m10 m11 originY |\r\n * ```\r\n * Producing the [Transform]($core-geometry):\r\n * ```\r\n * | m00 m01 0 originX |\r\n * | m10 m11 0 originY |\r\n * | 0 0 1 0 |\r\n * ```\r\n */\r\n public constructor(m00 = 1, m01 = 0, originX = 0, m10 = 0, m11 = 1, originY = 0) {\r\n const origin = new Point3d(originX, originY, 0);\r\n const matrix = Matrix3d.createRowValues(m00, m01, 0, m10, m11, 0, 0, 0, 1);\r\n this.transform = Transform.createRefs(origin, matrix);\r\n }\r\n }\r\n\r\n /** Properties used to construct a [[TextureMapping.Params]]. */\r\n export interface ParamProps {\r\n /** The matrix used to map the image to a surface. */\r\n textureMat2x3?: TextureMapping.Trans2x3;\r\n /** The ratio in [0, 1] with which to mix the color sampled from the texture with the surface's color.\r\n * A value of 0.0 uses only the surface color. A value of 1.0 uses only the texture color. A value of 0.5 uses an even mix of both.\r\n * @note This affects only the red, green, and blue components of the color. The alpha sampled from the texture is always multiplied by the surface color's alpha.\r\n * @note Defaults to 1.0\r\n */\r\n textureWeight?: number;\r\n /** The mode by which to map the image to a surface.\r\n * @note Defaults to [[TextureMapping.Mode.Parametric]].\r\n */\r\n mapMode?: TextureMapping.Mode;\r\n /** @internal */\r\n worldMapping?: boolean;\r\n }\r\n\r\n /** Parameters describing how a [[RenderTexture]]'s image is mapped to a surface. */\r\n export class Params {\r\n /** The matrix used to map the image to a surface. */\r\n public textureMatrix: TextureMapping.Trans2x3;\r\n /** The ratio in [0, 1] with which to mix the color sampled from the texture with the element's color.\r\n * A value of 0.0 uses only the element color. A value of 1.0 uses only the texture color.\r\n */\r\n public weight: number;\r\n /** The mode by which to map the image to a surface. */\r\n public mode: TextureMapping.Mode;\r\n /** @internal */\r\n public worldMapping: boolean;\r\n\r\n constructor(props = {} as TextureMapping.ParamProps) {\r\n const { textureMat2x3 = new Trans2x3(), textureWeight = 1.0, mapMode = Mode.Parametric, worldMapping = false } = props;\r\n this.textureMatrix = textureMat2x3; this.weight = textureWeight; this.mode = mapMode; this.worldMapping = worldMapping;\r\n }\r\n\r\n /**\r\n * Generates UV parameters for textured surfaces. Returns undefined on failure.\r\n * @internal\r\n */\r\n public computeUVParams(visitor: IndexedPolyfaceVisitor, transformToImodel: Transform): Point2d[] | undefined {\r\n switch (this.mode) {\r\n default: // Fall through to parametric in default case\r\n case TextureMapping.Mode.Parametric: {\r\n return this.computeParametricUVParams(visitor, this.textureMatrix.transform, !this.worldMapping);\r\n }\r\n case TextureMapping.Mode.Planar: {\r\n const normalIndices = visitor.normalIndex;\r\n if (!normalIndices)\r\n return undefined;\r\n\r\n // Ignore planar mode unless master or sub units for scaleMode and facet is planar\r\n if (!this.worldMapping || (visitor.normalIndex !== undefined && (normalIndices[0] !== normalIndices[1] || normalIndices[0] !== normalIndices[2]))) {\r\n return this.computeParametricUVParams(visitor, this.textureMatrix.transform, !this.worldMapping);\r\n } else {\r\n return this.computePlanarUVParams(visitor, this.textureMatrix.transform);\r\n }\r\n }\r\n case TextureMapping.Mode.ElevationDrape: {\r\n return this.computeElevationDrapeUVParams(visitor, this.textureMatrix.transform, transformToImodel);\r\n }\r\n }\r\n }\r\n\r\n /** Computes UV parameters given a texture mapping mode of parametric. */\r\n private computeParametricUVParams(visitor: IndexedPolyfaceVisitor, uvTransform: Transform, isRelativeUnits: boolean): Point2d[] {\r\n const params: Point2d[] = [];\r\n for (let i = 0; i < visitor.numEdgesThisFacet; i++) {\r\n let param = Point2d.create();\r\n\r\n if (isRelativeUnits || !visitor.tryGetDistanceParameter(i, param)) {\r\n if (!visitor.tryGetNormalizedParameter(i, param)) {\r\n // If mesh does not have facetFaceData, we still want to use the texture coordinates if they are present\r\n param = visitor.getParam(i)!;\r\n }\r\n }\r\n\r\n params.push(uvTransform.multiplyPoint2d(param));\r\n }\r\n return params;\r\n }\r\n\r\n /** Computes UV parameters given a texture mapping mode of planar. The result is stored in the Point2d array given. */\r\n private computePlanarUVParams(visitor: IndexedPolyfaceVisitor, uvTransform: Transform): Point2d[] | undefined {\r\n const params: Point2d[] = [];\r\n const points = visitor.point;\r\n let normal: Vector3d;\r\n\r\n if (visitor.normal === undefined)\r\n normal = points.getPoint3dAtUncheckedPointIndex(0).crossProductToPoints(points.getPoint3dAtUncheckedPointIndex(1), points.getPoint3dAtUncheckedPointIndex(2));\r\n else\r\n normal = visitor.normal.getVector3dAtCheckedVectorIndex(0)!;\r\n\r\n if (!normal.normalize(normal))\r\n return undefined;\r\n\r\n // adjust U texture coordinate to be a continuous length starting at the\r\n // origin. V coordinate stays the same. This mode assumes Z is up vector\r\n\r\n // Flipping normal puts us in a planar coordinate system consistent with MicroStation's display system\r\n normal.scale(-1.0, normal);\r\n\r\n // pick the first vertex normal\r\n const sideVector = Vector3d.create(normal.y, -normal.x, 0.0);\r\n\r\n // if the magnitude of the normal is near zero, the real normal points\r\n // almost straighten up.. In this case, use Y as the up vector to match QV\r\n\r\n const magnitude = sideVector.magnitude();\r\n sideVector.normalize(sideVector); // won't remain undefined if failed due to following check..\r\n\r\n if (magnitude < 1e-3) {\r\n normal.set(0, 0, -1);\r\n sideVector.set(1, 0, 0);\r\n }\r\n\r\n const upVector = sideVector.crossProduct(normal).normalize();\r\n if (!upVector)\r\n return undefined;\r\n\r\n const numEdges = visitor.numEdgesThisFacet;\r\n for (let i = 0; i < numEdges; i++) {\r\n const vector = Vector3d.createFrom(points.getPoint3dAtUncheckedPointIndex(i));\r\n\r\n params.push(Point2d.create(vector.dotProduct(sideVector), vector.dotProduct(upVector)));\r\n uvTransform.multiplyPoint2d(params[i], params[i]);\r\n }\r\n return params;\r\n }\r\n\r\n /** Computes UV parameters given a texture mapping mode of elevation drape. The result is stored in the Point2d array given. */\r\n private computeElevationDrapeUVParams(visitor: IndexedPolyfaceVisitor, uvTransform: Transform, transformToIModel?: Transform): Point2d[] {\r\n const params: Point2d[] = [];\r\n const numEdges = visitor.numEdgesThisFacet;\r\n for (let i = 0; i < numEdges; i++) {\r\n const point = visitor.point.getPoint3dAtUncheckedPointIndex(i);\r\n\r\n if (transformToIModel !== undefined)\r\n transformToIModel.multiplyPoint3d(point, point);\r\n\r\n params.push(Point2d.createFrom(point));\r\n uvTransform.multiplyPoint2d(params[i], params[i]);\r\n }\r\n return params;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TextureMapping.js","sourceRoot":"","sources":["../../src/TextureMapping.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA0B,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAmB,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhI;;GAEG;AACH,MAAM,OAAO,cAAc;IAMzB,YAAmB,EAAiB,EAAE,MAA6B;QACjE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,gBAAgB;IACT,eAAe,CAAC,OAAwB,EAAE,iBAA4B;QAC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CAAC;gBAE9E,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACxF,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aACnD;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,+HAA+H;QACvH,6BAA6B,CAAC,OAA+B,EAAE,WAAsB,EAAE,iBAA6B;YAC1H,MAAM,MAAM,GAAc,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;YAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;gBACjC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC,CAAC;gBAE/D,IAAI,iBAAiB,KAAK,SAAS;oBACjC,iBAAiB,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAElD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvC,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aACnD;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF;IAhIY,qBAAM,SAgIlB,CAAA;AACH,CAAC,EApMgB,cAAc,KAAd,cAAc,QAoM9B;AAED,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { IndexedPolyfaceVisitor, Matrix3d, Point2d, Point3d, PolyfaceVisitor, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { RenderTexture } from \"./RenderTexture\";\r\n\r\n/** Describes how to map a [[RenderTexture]]'s image onto a surface as part of a [[RenderMaterial]].\r\n * @public\r\n */\r\nexport class TextureMapping {\r\n /** The texture to be mapped to the surface. */\r\n public readonly texture: RenderTexture;\r\n /** The parameters describing how the texture image is mapped to the surface. */\r\n public readonly params: TextureMapping.Params;\r\n\r\n public constructor(tx: RenderTexture, params: TextureMapping.Params) {\r\n this.texture = tx;\r\n this.params = params;\r\n }\r\n\r\n /** @internal */\r\n public computeUVParams(visitor: PolyfaceVisitor, transformToImodel: Transform): Point2d[] | undefined {\r\n return this.params.computeUVParams(visitor as IndexedPolyfaceVisitor, transformToImodel);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace TextureMapping { // eslint-disable-line no-redeclare\r\n /** Enumerates the possible texture mapping modes. */\r\n export enum Mode {\r\n None = -1,\r\n Parametric = 0,\r\n ElevationDrape = 1,\r\n Planar = 2,\r\n /** @internal */\r\n DirectionalDrape = 3,\r\n /** @internal */\r\n Cubic = 4,\r\n /** @internal */\r\n Spherical = 5,\r\n /** @internal */\r\n Cylindrical = 6,\r\n /** @internal */\r\n Solid = 7,\r\n /** @internal Only valid for lights */\r\n FrontProject = 8,\r\n }\r\n\r\n /** A 2x3 matrix for mapping a texture image to a surface. */\r\n export class Trans2x3 {\r\n /** The 3x4 transform produced from the 2x3 matrix. */\r\n public readonly transform: Transform;\r\n\r\n /** Construct from the two rows of the matrix:\r\n * ```\r\n * | m00 m01 originX |\r\n * | m10 m11 originY |\r\n * ```\r\n * Producing the [Transform]($core-geometry):\r\n * ```\r\n * | m00 m01 0 originX |\r\n * | m10 m11 0 originY |\r\n * | 0 0 1 0 |\r\n * ```\r\n */\r\n public constructor(m00 = 1, m01 = 0, originX = 0, m10 = 0, m11 = 1, originY = 0) {\r\n const origin = new Point3d(originX, originY, 0);\r\n const matrix = Matrix3d.createRowValues(m00, m01, 0, m10, m11, 0, 0, 0, 1);\r\n this.transform = Transform.createRefs(origin, matrix);\r\n }\r\n\r\n /** An immutable 2x3 identity matrix. */\r\n public static readonly identity = new Trans2x3();\r\n }\r\n\r\n /** Properties used to construct a [[TextureMapping.Params]]. */\r\n export interface ParamProps {\r\n /** The matrix used to map the image to a surface. */\r\n textureMat2x3?: TextureMapping.Trans2x3;\r\n /** The ratio in [0, 1] with which to mix the color sampled from the texture with the surface's color.\r\n * A value of 0.0 uses only the surface color. A value of 1.0 uses only the texture color. A value of 0.5 uses an even mix of both.\r\n * @note This affects only the red, green, and blue components of the color. The alpha sampled from the texture is always multiplied by the surface color's alpha.\r\n * @note Defaults to 1.0\r\n */\r\n textureWeight?: number;\r\n /** The mode by which to map the image to a surface.\r\n * @note Defaults to [[TextureMapping.Mode.Parametric]].\r\n */\r\n mapMode?: TextureMapping.Mode;\r\n /** @internal */\r\n worldMapping?: boolean;\r\n }\r\n\r\n /** Parameters describing how a [[RenderTexture]]'s image is mapped to a surface. */\r\n export class Params {\r\n /** The matrix used to map the image to a surface. */\r\n public textureMatrix: TextureMapping.Trans2x3;\r\n /** The ratio in [0, 1] with which to mix the color sampled from the texture with the element's color.\r\n * A value of 0.0 uses only the element color. A value of 1.0 uses only the texture color.\r\n */\r\n public weight: number;\r\n /** The mode by which to map the image to a surface. */\r\n public mode: TextureMapping.Mode;\r\n /** @internal */\r\n public worldMapping: boolean;\r\n\r\n public constructor(props?: TextureMapping.ParamProps) {\r\n this.textureMatrix = props?.textureMat2x3 ?? Trans2x3.identity;\r\n this.weight = props?.textureWeight ?? 1;\r\n this.mode = props?.mapMode ?? Mode.Parametric;\r\n this.worldMapping = props?.worldMapping ?? false;\r\n }\r\n\r\n /**\r\n * Generates UV parameters for textured surfaces. Returns undefined on failure.\r\n * @internal\r\n */\r\n public computeUVParams(visitor: IndexedPolyfaceVisitor, transformToImodel: Transform): Point2d[] | undefined {\r\n switch (this.mode) {\r\n default: // Fall through to parametric in default case\r\n case TextureMapping.Mode.Parametric: {\r\n return this.computeParametricUVParams(visitor, this.textureMatrix.transform, !this.worldMapping);\r\n }\r\n case TextureMapping.Mode.Planar: {\r\n const normalIndices = visitor.normalIndex;\r\n if (!normalIndices)\r\n return undefined;\r\n\r\n // Ignore planar mode unless master or sub units for scaleMode and facet is planar\r\n if (!this.worldMapping || (visitor.normalIndex !== undefined && (normalIndices[0] !== normalIndices[1] || normalIndices[0] !== normalIndices[2]))) {\r\n return this.computeParametricUVParams(visitor, this.textureMatrix.transform, !this.worldMapping);\r\n } else {\r\n return this.computePlanarUVParams(visitor, this.textureMatrix.transform);\r\n }\r\n }\r\n case TextureMapping.Mode.ElevationDrape: {\r\n return this.computeElevationDrapeUVParams(visitor, this.textureMatrix.transform, transformToImodel);\r\n }\r\n }\r\n }\r\n\r\n /** Computes UV parameters given a texture mapping mode of parametric. */\r\n private computeParametricUVParams(visitor: IndexedPolyfaceVisitor, uvTransform: Transform, isRelativeUnits: boolean): Point2d[] {\r\n const params: Point2d[] = [];\r\n for (let i = 0; i < visitor.numEdgesThisFacet; i++) {\r\n let param = Point2d.create();\r\n\r\n if (isRelativeUnits || !visitor.tryGetDistanceParameter(i, param)) {\r\n if (!visitor.tryGetNormalizedParameter(i, param)) {\r\n // If mesh does not have facetFaceData, we still want to use the texture coordinates if they are present\r\n param = visitor.getParam(i)!;\r\n }\r\n }\r\n\r\n params.push(uvTransform.multiplyPoint2d(param));\r\n }\r\n return params;\r\n }\r\n\r\n /** Computes UV parameters given a texture mapping mode of planar. The result is stored in the Point2d array given. */\r\n private computePlanarUVParams(visitor: IndexedPolyfaceVisitor, uvTransform: Transform): Point2d[] | undefined {\r\n const params: Point2d[] = [];\r\n const points = visitor.point;\r\n let normal: Vector3d;\r\n\r\n if (visitor.normal === undefined)\r\n normal = points.getPoint3dAtUncheckedPointIndex(0).crossProductToPoints(points.getPoint3dAtUncheckedPointIndex(1), points.getPoint3dAtUncheckedPointIndex(2));\r\n else\r\n normal = visitor.normal.getVector3dAtCheckedVectorIndex(0)!;\r\n\r\n if (!normal.normalize(normal))\r\n return undefined;\r\n\r\n // adjust U texture coordinate to be a continuous length starting at the\r\n // origin. V coordinate stays the same. This mode assumes Z is up vector\r\n\r\n // Flipping normal puts us in a planar coordinate system consistent with MicroStation's display system\r\n normal.scale(-1.0, normal);\r\n\r\n // pick the first vertex normal\r\n const sideVector = Vector3d.create(normal.y, -normal.x, 0.0);\r\n\r\n // if the magnitude of the normal is near zero, the real normal points\r\n // almost straighten up.. In this case, use Y as the up vector to match QV\r\n\r\n const magnitude = sideVector.magnitude();\r\n sideVector.normalize(sideVector); // won't remain undefined if failed due to following check..\r\n\r\n if (magnitude < 1e-3) {\r\n normal.set(0, 0, -1);\r\n sideVector.set(1, 0, 0);\r\n }\r\n\r\n const upVector = sideVector.crossProduct(normal).normalize();\r\n if (!upVector)\r\n return undefined;\r\n\r\n const numEdges = visitor.numEdgesThisFacet;\r\n for (let i = 0; i < numEdges; i++) {\r\n const vector = Vector3d.createFrom(points.getPoint3dAtUncheckedPointIndex(i));\r\n\r\n params.push(Point2d.create(vector.dotProduct(sideVector), vector.dotProduct(upVector)));\r\n uvTransform.multiplyPoint2d(params[i], params[i]);\r\n }\r\n return params;\r\n }\r\n\r\n /** Computes UV parameters given a texture mapping mode of elevation drape. The result is stored in the Point2d array given. */\r\n private computeElevationDrapeUVParams(visitor: IndexedPolyfaceVisitor, uvTransform: Transform, transformToIModel?: Transform): Point2d[] {\r\n const params: Point2d[] = [];\r\n const numEdges = visitor.numEdgesThisFacet;\r\n for (let i = 0; i < numEdges; i++) {\r\n const point = visitor.point.getPoint3dAtUncheckedPointIndex(i);\r\n\r\n if (transformToIModel !== undefined)\r\n transformToIModel.multiplyPoint3d(point, point);\r\n\r\n params.push(Point2d.createFrom(point));\r\n uvTransform.multiplyPoint2d(params[i], params[i]);\r\n }\r\n return params;\r\n }\r\n }\r\n}\r\n\r\nObject.freeze(TextureMapping.Trans2x3.identity);\r\n"]}
|