|
@@ -1386,7 +1386,192 @@ declare module 'babylonjs-viewer/managers/observablesManager' {
|
|
|
}
|
|
|
|
|
|
declare module 'babylonjs-viewer/managers/sceneManager' {
|
|
|
-
|
|
|
+ import { Scene, ArcRotateCamera, Engine, Light, SceneOptimizer, EnvironmentHelper, Color3, Observable, DefaultRenderingPipeline, Nullable, VRExperienceHelper } from 'babylonjs';
|
|
|
+ import { ILightConfiguration, ISceneConfiguration, ISceneOptimizerConfiguration, ICameraConfiguration, ISkyboxConfiguration, ViewerConfiguration, IGroundConfiguration, IModelConfiguration, IVRConfiguration } from 'babylonjs-viewer/configuration';
|
|
|
+ import { ViewerModel } from 'babylonjs-viewer/model/viewerModel';
|
|
|
+ import { ViewerLabs } from 'babylonjs-viewer/labs/viewerLabs';
|
|
|
+ import { ObservablesManager } from 'babylonjs-viewer/managers/observablesManager';
|
|
|
+ import { ConfigurationContainer } from 'babylonjs-viewer/configuration/configurationContainer';
|
|
|
+ import { IEnvironmentMapConfiguration } from 'babylonjs-viewer/configuration/interfaces/environmentMapConfiguration';
|
|
|
+ /**
|
|
|
+ * This interface describes the structure of the variable sent with the configuration observables of the scene manager.
|
|
|
+ * O - the type of object we are dealing with (Light, ArcRotateCamera, Scene, etc')
|
|
|
+ * T - the configuration type
|
|
|
+ */
|
|
|
+ export interface IPostConfigurationCallback<OBJ, CONF> {
|
|
|
+ newConfiguration: CONF;
|
|
|
+ sceneManager: SceneManager;
|
|
|
+ object: OBJ;
|
|
|
+ model?: ViewerModel;
|
|
|
+ }
|
|
|
+ export class SceneManager {
|
|
|
+ /**
|
|
|
+ * Will notify when the scene was initialized
|
|
|
+ */
|
|
|
+ onSceneInitObservable: Observable<Scene>;
|
|
|
+ /**
|
|
|
+ * Will notify after the scene was configured. Can be used to further configure the scene
|
|
|
+ */
|
|
|
+ onSceneConfiguredObservable: Observable<IPostConfigurationCallback<Scene, ISceneConfiguration>>;
|
|
|
+ /**
|
|
|
+ * Will notify after the scene optimized was configured. Can be used to further configure the scene optimizer
|
|
|
+ */
|
|
|
+ onSceneOptimizerConfiguredObservable: Observable<IPostConfigurationCallback<SceneOptimizer, ISceneOptimizerConfiguration | boolean>>;
|
|
|
+ /**
|
|
|
+ * Will notify after the camera was configured. Can be used to further configure the camera
|
|
|
+ */
|
|
|
+ onCameraConfiguredObservable: Observable<IPostConfigurationCallback<ArcRotateCamera, ICameraConfiguration>>;
|
|
|
+ /**
|
|
|
+ * Will notify after the lights were configured. Can be used to further configure lights
|
|
|
+ */
|
|
|
+ onLightsConfiguredObservable: Observable<IPostConfigurationCallback<Array<Light>, {
|
|
|
+ [name: string]: ILightConfiguration | boolean | number;
|
|
|
+ }>>;
|
|
|
+ /**
|
|
|
+ * Will notify after the model(s) were configured. Can be used to further configure models
|
|
|
+ */
|
|
|
+ onModelsConfiguredObservable: Observable<IPostConfigurationCallback<Array<ViewerModel>, IModelConfiguration>>;
|
|
|
+ /**
|
|
|
+ * Will notify after the envirnoment was configured. Can be used to further configure the environment
|
|
|
+ */
|
|
|
+ onEnvironmentConfiguredObservable: Observable<IPostConfigurationCallback<EnvironmentHelper, {
|
|
|
+ skybox?: ISkyboxConfiguration | boolean;
|
|
|
+ ground?: IGroundConfiguration | boolean;
|
|
|
+ }>>;
|
|
|
+ /**
|
|
|
+ * Will notify after the model(s) were configured. Can be used to further configure models
|
|
|
+ */
|
|
|
+ onVRConfiguredObservable: Observable<IPostConfigurationCallback<VRExperienceHelper, IVRConfiguration>>;
|
|
|
+ /**
|
|
|
+ * The Babylon Scene of this viewer
|
|
|
+ */
|
|
|
+ scene: Scene;
|
|
|
+ /**
|
|
|
+ * The camera used in this viewer
|
|
|
+ */
|
|
|
+ camera: ArcRotateCamera;
|
|
|
+ /**
|
|
|
+ * Babylon's scene optimizer
|
|
|
+ */
|
|
|
+ sceneOptimizer: SceneOptimizer;
|
|
|
+ /**
|
|
|
+ * Models displayed in this viewer.
|
|
|
+ */
|
|
|
+ models: Array<ViewerModel>;
|
|
|
+ /**
|
|
|
+ * Babylon's environment helper of this viewer
|
|
|
+ */
|
|
|
+ environmentHelper?: EnvironmentHelper;
|
|
|
+ protected _defaultHighpTextureType: number;
|
|
|
+ protected _shadowGeneratorBias: number;
|
|
|
+ protected _defaultPipelineTextureType: number;
|
|
|
+ /**
|
|
|
+ * The maximum number of shadows supported by the curent viewer
|
|
|
+ */
|
|
|
+ protected _maxShadows: number;
|
|
|
+ /**
|
|
|
+ * The labs variable consists of objects that will have their API change.
|
|
|
+ * Please be careful when using labs in production.
|
|
|
+ */
|
|
|
+ labs: ViewerLabs;
|
|
|
+ readonly defaultRenderingPipeline: Nullable<DefaultRenderingPipeline>;
|
|
|
+ protected _vrHelper?: VRExperienceHelper;
|
|
|
+ readonly vrHelper: VRExperienceHelper | undefined;
|
|
|
+ constructor(_engine: Engine, _configurationContainer: ConfigurationContainer, _observablesManager?: ObservablesManager | undefined);
|
|
|
+ /**
|
|
|
+ * Returns a boolean representing HDR support
|
|
|
+ */
|
|
|
+ readonly isHdrSupported: boolean;
|
|
|
+ /**
|
|
|
+ * Return the main color defined in the configuration.
|
|
|
+ */
|
|
|
+ readonly mainColor: Color3;
|
|
|
+ readonly reflectionColor: Color3;
|
|
|
+ animationBlendingEnabled: boolean;
|
|
|
+ readonly observablesManager: ObservablesManager | undefined;
|
|
|
+ /**
|
|
|
+ * Should shadows be rendered every frame, or only once and stop.
|
|
|
+ * This can be used to optimize a scene.
|
|
|
+ *
|
|
|
+ * Not that the shadows will NOT disapear but will remain in place.
|
|
|
+ * @param process if true shadows will be updated once every frame. if false they will stop being updated.
|
|
|
+ */
|
|
|
+ processShadows: boolean;
|
|
|
+ groundEnabled: boolean;
|
|
|
+ /**
|
|
|
+ * sets wether the reflection is disabled.
|
|
|
+ */
|
|
|
+ groundMirrorEnabled: boolean;
|
|
|
+ defaultRenderingPipelineEnabled: boolean;
|
|
|
+ /**
|
|
|
+ * Sets the engine flags to unlock all babylon features.
|
|
|
+ * Can also be configured using the scene.flags configuration object
|
|
|
+ */
|
|
|
+ unlockBabylonFeatures(): void;
|
|
|
+ /**
|
|
|
+ * initialize the scene. Calling this function again will dispose the old scene, if exists.
|
|
|
+ */
|
|
|
+ initScene(sceneConfiguration?: ISceneConfiguration, optimizerConfiguration?: boolean | ISceneOptimizerConfiguration): Promise<Scene>;
|
|
|
+ clearScene(clearModels?: boolean, clearLights?: boolean): void;
|
|
|
+ /**
|
|
|
+ * This will update the scene's configuration, including camera, lights, environment.
|
|
|
+ * @param newConfiguration the delta that should be configured. This includes only the changes
|
|
|
+ * @param globalConfiguration The global configuration object, after the new configuration was merged into it
|
|
|
+ */
|
|
|
+ updateConfiguration(newConfiguration: Partial<ViewerConfiguration>): void;
|
|
|
+ bloomEnabled: boolean;
|
|
|
+ fxaaEnabled: boolean;
|
|
|
+ /**
|
|
|
+ * internally configure the scene using the provided configuration.
|
|
|
+ * The scene will not be recreated, but just updated.
|
|
|
+ * @param sceneConfig the (new) scene configuration
|
|
|
+ */
|
|
|
+ protected _configureScene(sceneConfig: ISceneConfiguration): void;
|
|
|
+ /**
|
|
|
+ * Configure the scene optimizer.
|
|
|
+ * The existing scene optimizer will be disposed and a new one will be created.
|
|
|
+ * @param optimizerConfig the (new) optimizer configuration
|
|
|
+ */
|
|
|
+ protected _configureOptimizer(optimizerConfig: ISceneOptimizerConfiguration | boolean): void;
|
|
|
+ /**
|
|
|
+ * configure all models using the configuration.
|
|
|
+ * @param modelConfiguration the configuration to use to reconfigure the models
|
|
|
+ */
|
|
|
+ protected _configureVR(vrConfig: IVRConfiguration): void;
|
|
|
+ protected _configureEnvironmentMap(environmentMapConfiguration: IEnvironmentMapConfiguration): any;
|
|
|
+ /**
|
|
|
+ * (Re) configure the camera. The camera will only be created once and from this point will only be reconfigured.
|
|
|
+ * @param cameraConfig the new camera configuration
|
|
|
+ * @param model optionally use the model to configure the camera.
|
|
|
+ */
|
|
|
+ protected _configureCamera(cameraConfig?: ICameraConfiguration): void;
|
|
|
+ protected _configureEnvironment(skyboxConifguration?: ISkyboxConfiguration | boolean, groundConfiguration?: IGroundConfiguration | boolean): void;
|
|
|
+ /**
|
|
|
+ * configure the lights.
|
|
|
+ *
|
|
|
+ * @param lightsConfiguration the (new) light(s) configuration
|
|
|
+ * @param model optionally use the model to configure the camera.
|
|
|
+ */
|
|
|
+ protected _configureLights(lightsConfiguration?: {
|
|
|
+ [name: string]: ILightConfiguration | boolean | number;
|
|
|
+ }): void;
|
|
|
+ /**
|
|
|
+ * Gets the shadow map blur kernel according to the light configuration.
|
|
|
+ * @param light The light used to generate the shadows
|
|
|
+ * @param bufferSize The size of the shadow map
|
|
|
+ * @return the kernel blur size
|
|
|
+ */
|
|
|
+ getBlurKernel(light: BABYLON.IShadowLight, bufferSize: number): number;
|
|
|
+ /**
|
|
|
+ * Alters render settings to reduce features based on hardware feature limitations
|
|
|
+ * @param enableHDR Allows the viewer to run in HDR mode.
|
|
|
+ */
|
|
|
+ protected _handleHardwareLimitations(enableHDR?: boolean): void;
|
|
|
+ /**
|
|
|
+ * Dispoe the entire viewer including the scene and the engine
|
|
|
+ */
|
|
|
+ dispose(): void;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
declare module 'babylonjs-viewer/configuration/interfaces/modelConfiguration' {
|
|
@@ -1555,6 +1740,57 @@ declare module 'babylonjs-viewer/templating/eventManager' {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+declare module 'babylonjs-viewer/labs/viewerLabs' {
|
|
|
+ import { PBREnvironment } from "babylonjs-viewer/labs/environmentSerializer";
|
|
|
+ import { ShadowLight, Vector3, Scene } from 'babylonjs';
|
|
|
+ /**
|
|
|
+ * The ViewerLabs class will hold functions that are not (!) backwards compatible.
|
|
|
+ * The APIs in all labs-related classes and configuration might change.
|
|
|
+ * Once stable, lab features will be moved to the publis API and configuration object.
|
|
|
+ */
|
|
|
+ export class ViewerLabs {
|
|
|
+ constructor(_scene: Scene);
|
|
|
+ assetsRootURL: string;
|
|
|
+ environment: PBREnvironment;
|
|
|
+ /**
|
|
|
+ * Loads an environment map from a given URL
|
|
|
+ * @param url URL of environment map
|
|
|
+ * @param onSuccess Callback fired after environment successfully applied to the scene
|
|
|
+ * @param onProgress Callback fired at progress events while loading the environment map
|
|
|
+ * @param onError Callback fired when the load fails
|
|
|
+ */
|
|
|
+ loadEnvironment(url: string, onSuccess?: (env: PBREnvironment) => void, onProgress?: (bytesLoaded: number, bytesTotal: number) => void, onError?: (e: any) => void): void;
|
|
|
+ /**
|
|
|
+ * Loads an environment map from a given URL
|
|
|
+ * @param buffer ArrayBuffer containing environment map
|
|
|
+ * @param onSuccess Callback fired after environment successfully applied to the scene
|
|
|
+ * @param onProgress Callback fired at progress events while loading the environment map
|
|
|
+ * @param onError Callback fired when the load fails
|
|
|
+ */
|
|
|
+ loadEnvironment(buffer: ArrayBuffer, onSuccess?: (env: PBREnvironment) => void, onProgress?: (bytesLoaded: number, bytesTotal: number) => void, onError?: (e: any) => void): void;
|
|
|
+ /**
|
|
|
+ * Sets the environment to an already loaded environment
|
|
|
+ * @param env PBREnvironment instance
|
|
|
+ * @param onSuccess Callback fired after environment successfully applied to the scene
|
|
|
+ * @param onProgress Callback fired at progress events while loading the environment map
|
|
|
+ * @param onError Callback fired when the load fails
|
|
|
+ */
|
|
|
+ loadEnvironment(env: PBREnvironment, onSuccess?: (env: PBREnvironment) => void, onProgress?: (bytesLoaded: number, bytesTotal: number) => void, onError?: (e: any) => void): void;
|
|
|
+ /**
|
|
|
+ * Applies an `EnvironmentMapConfiguration` to the scene
|
|
|
+ * @param environmentMapConfiguration Environment map configuration to apply
|
|
|
+ */
|
|
|
+ applyEnvironmentMapConfiguration(rotationY?: number): void;
|
|
|
+ /**
|
|
|
+ * Get an environment asset url by using the configuration if the path is not absolute.
|
|
|
+ * @param url Asset url
|
|
|
+ * @returns The Asset url using the `environmentAssetsRootURL` if the url is not an absolute path.
|
|
|
+ */
|
|
|
+ getAssetUrl(url: string): string;
|
|
|
+ rotateShadowLight(shadowLight: ShadowLight, amount: number, point?: Vector3, axis?: Vector3, target?: Vector3): void;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
declare module 'babylonjs-viewer/configuration/interfaces/modelAnimationConfiguration' {
|
|
|
/**
|
|
|
* Defines an animation to be applied to a model (translation, scale or rotation).
|
|
@@ -1804,49 +2040,7 @@ declare module 'babylonjs-viewer/configuration/interfaces/groundConfiguration' {
|
|
|
}
|
|
|
|
|
|
declare module 'babylonjs-viewer/configuration/interfaces/imageProcessingConfiguration' {
|
|
|
- export interface IImageProcessingConfiguration {
|
|
|
- colorGradingEnabled?: boolean;
|
|
|
- colorCurvesEnabled?: boolean;
|
|
|
- colorCurves?: {
|
|
|
- globalHue?: number;
|
|
|
- globalDensity?: number;
|
|
|
- globalSaturation?: number;
|
|
|
- globalExposure?: number;
|
|
|
- highlightsHue?: number;
|
|
|
- highlightsDensity?: number;
|
|
|
- highlightsSaturation?: number;
|
|
|
- highlightsExposure?: number;
|
|
|
- midtonesHue?: number;
|
|
|
- midtonesDensity?: number;
|
|
|
- midtonesSaturation?: number;
|
|
|
- midtonesExposure?: number;
|
|
|
- shadowsHue?: number;
|
|
|
- shadowsDensity?: number;
|
|
|
- shadowsSaturation?: number;
|
|
|
- shadowsExposure?: number;
|
|
|
- };
|
|
|
- colorGradingWithGreenDepth?: boolean;
|
|
|
- colorGradingBGR?: boolean;
|
|
|
- exposure?: number;
|
|
|
- toneMappingEnabled?: boolean;
|
|
|
- contrast?: number;
|
|
|
- vignetteEnabled?: boolean;
|
|
|
- vignetteStretch?: number;
|
|
|
- vignetteCentreX?: number;
|
|
|
- vignetteCentreY?: number;
|
|
|
- vignetteWeight?: number;
|
|
|
- vignetteColor?: {
|
|
|
- r: number;
|
|
|
- g: number;
|
|
|
- b: number;
|
|
|
- a?: number;
|
|
|
- };
|
|
|
- vignetteCameraFov?: number;
|
|
|
- vignetteBlendMode?: number;
|
|
|
- vignetteM?: boolean;
|
|
|
- applyByPostProcess?: boolean;
|
|
|
- isEnabled?: boolean;
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
declare module 'babylonjs-viewer/configuration/interfaces/lightConfiguration' {
|
|
@@ -2112,3 +2306,295 @@ declare module 'babylonjs-viewer/configuration/interfaces/vrConfiguration' {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+declare module 'babylonjs-viewer/labs/environmentSerializer' {
|
|
|
+ import { Vector3 } from "babylonjs";
|
|
|
+ import { TextureCube } from 'babylonjs-viewer/labs/texture';
|
|
|
+ /**
|
|
|
+ * Spherical polynomial coefficients (counter part to spherical harmonic coefficients used in shader irradiance calculation)
|
|
|
+ * @ignoreChildren
|
|
|
+ */
|
|
|
+ export interface SphericalPolynomalCoefficients {
|
|
|
+ x: Vector3;
|
|
|
+ y: Vector3;
|
|
|
+ z: Vector3;
|
|
|
+ xx: Vector3;
|
|
|
+ yy: Vector3;
|
|
|
+ zz: Vector3;
|
|
|
+ yz: Vector3;
|
|
|
+ zx: Vector3;
|
|
|
+ xy: Vector3;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Wraps data and maps required for environments with physically based rendering
|
|
|
+ */
|
|
|
+ export interface PBREnvironment {
|
|
|
+ /**
|
|
|
+ * Spherical Polynomial Coefficients representing an irradiance map
|
|
|
+ */
|
|
|
+ irradiancePolynomialCoefficients: SphericalPolynomalCoefficients;
|
|
|
+ /**
|
|
|
+ * Specular cubemap
|
|
|
+ */
|
|
|
+ specularTexture?: TextureCube;
|
|
|
+ /**
|
|
|
+ * A scale factor applied to RGB values after reading from environment maps
|
|
|
+ */
|
|
|
+ textureIntensityScale: number;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Environment map representations: layouts, projections and approximations
|
|
|
+ */
|
|
|
+ export type MapType = 'irradiance_sh_coefficients_9' | 'cubemap_faces';
|
|
|
+ /**
|
|
|
+ * Image type used for environment map
|
|
|
+ */
|
|
|
+ export type ImageType = 'png';
|
|
|
+ /**
|
|
|
+ * A generic field in JSON that report's its type
|
|
|
+ */
|
|
|
+ export interface TypedObject<T> {
|
|
|
+ type: T;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Describes a range of bytes starting at byte pos (inclusive) and finishing at byte pos + length - 1
|
|
|
+ */
|
|
|
+ export interface ByteRange {
|
|
|
+ pos: number;
|
|
|
+ length: number;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Complete Spectre Environment JSON Descriptor
|
|
|
+ */
|
|
|
+ export interface EnvJsonDescriptor {
|
|
|
+ radiance: TypedObject<MapType>;
|
|
|
+ irradiance: TypedObject<MapType>;
|
|
|
+ specular: TypedObject<MapType>;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Spherical harmonic coefficients to provide an irradiance map
|
|
|
+ */
|
|
|
+ export interface IrradianceSHCoefficients9 extends TypedObject<MapType> {
|
|
|
+ l00: Array<number>;
|
|
|
+ l1_1: Array<number>;
|
|
|
+ l10: Array<number>;
|
|
|
+ l11: Array<number>;
|
|
|
+ l2_2: Array<number>;
|
|
|
+ l2_1: Array<number>;
|
|
|
+ l20: Array<number>;
|
|
|
+ l21: Array<number>;
|
|
|
+ l22: Array<number>;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * A generic set of images, where the image content is specified by byte ranges in the mipmaps field
|
|
|
+ */
|
|
|
+ export interface ImageSet<T> extends TypedObject<MapType> {
|
|
|
+ imageType: ImageType;
|
|
|
+ width: number;
|
|
|
+ height: number;
|
|
|
+ mipmaps: Array<T>;
|
|
|
+ multiplier: number;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * A set of cubemap faces
|
|
|
+ */
|
|
|
+ export type CubemapFaces = ImageSet<Array<ByteRange>>;
|
|
|
+ /**
|
|
|
+ * A single image containing an atlas of equirectangular-projection maps across all mip levels
|
|
|
+ */
|
|
|
+ export type EquirectangularMipmapAtlas = ImageSet<ByteRange>;
|
|
|
+ /**
|
|
|
+ * A static class proving methods to aid parsing Spectre environment files
|
|
|
+ */
|
|
|
+ export class EnvironmentDeserializer {
|
|
|
+ /**
|
|
|
+ * Parses an arraybuffer into a new PBREnvironment object
|
|
|
+ * @param arrayBuffer The arraybuffer of the Spectre environment file
|
|
|
+ * @return a PBREnvironment object
|
|
|
+ */
|
|
|
+ static Parse(arrayBuffer: ArrayBuffer): PBREnvironment;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+declare module 'babylonjs-viewer/labs/texture' {
|
|
|
+ import { Scene, CubeTexture, BaseTexture } from "babylonjs";
|
|
|
+ /**
|
|
|
+ * WebGL Pixel Formats
|
|
|
+ */
|
|
|
+ export const enum PixelFormat {
|
|
|
+ DEPTH_COMPONENT = 6402,
|
|
|
+ ALPHA = 6406,
|
|
|
+ RGB = 6407,
|
|
|
+ RGBA = 6408,
|
|
|
+ LUMINANCE = 6409,
|
|
|
+ LUMINANCE_ALPHA = 6410
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * WebGL Pixel Types
|
|
|
+ */
|
|
|
+ export const enum PixelType {
|
|
|
+ UNSIGNED_BYTE = 5121,
|
|
|
+ UNSIGNED_SHORT_4_4_4_4 = 32819,
|
|
|
+ UNSIGNED_SHORT_5_5_5_1 = 32820,
|
|
|
+ UNSIGNED_SHORT_5_6_5 = 33635
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * WebGL Texture Magnification Filter
|
|
|
+ */
|
|
|
+ export const enum TextureMagFilter {
|
|
|
+ NEAREST = 9728,
|
|
|
+ LINEAR = 9729
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * WebGL Texture Minification Filter
|
|
|
+ */
|
|
|
+ export const enum TextureMinFilter {
|
|
|
+ NEAREST = 9728,
|
|
|
+ LINEAR = 9729,
|
|
|
+ NEAREST_MIPMAP_NEAREST = 9984,
|
|
|
+ LINEAR_MIPMAP_NEAREST = 9985,
|
|
|
+ NEAREST_MIPMAP_LINEAR = 9986,
|
|
|
+ LINEAR_MIPMAP_LINEAR = 9987
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * WebGL Texture Wrap Modes
|
|
|
+ */
|
|
|
+ export const enum TextureWrapMode {
|
|
|
+ REPEAT = 10497,
|
|
|
+ CLAMP_TO_EDGE = 33071,
|
|
|
+ MIRRORED_REPEAT = 33648
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Raw texture data and descriptor sufficient for WebGL texture upload
|
|
|
+ */
|
|
|
+ export interface TextureData {
|
|
|
+ /**
|
|
|
+ * Width of image
|
|
|
+ */
|
|
|
+ width: number;
|
|
|
+ /**
|
|
|
+ * Height of image
|
|
|
+ */
|
|
|
+ height: number;
|
|
|
+ /**
|
|
|
+ * Format of pixels in data
|
|
|
+ */
|
|
|
+ format: PixelFormat;
|
|
|
+ /**
|
|
|
+ * Row byte alignment of pixels in data
|
|
|
+ */
|
|
|
+ alignment: number;
|
|
|
+ /**
|
|
|
+ * Pixel data
|
|
|
+ */
|
|
|
+ data: ArrayBufferView;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Wraps sampling parameters for a WebGL texture
|
|
|
+ */
|
|
|
+ export interface SamplingParameters {
|
|
|
+ /**
|
|
|
+ * Magnification mode when upsampling from a WebGL texture
|
|
|
+ */
|
|
|
+ magFilter?: TextureMagFilter;
|
|
|
+ /**
|
|
|
+ * Minification mode when upsampling from a WebGL texture
|
|
|
+ */
|
|
|
+ minFilter?: TextureMinFilter;
|
|
|
+ /**
|
|
|
+ * X axis wrapping mode when sampling out of a WebGL texture bounds
|
|
|
+ */
|
|
|
+ wrapS?: TextureWrapMode;
|
|
|
+ /**
|
|
|
+ * Y axis wrapping mode when sampling out of a WebGL texture bounds
|
|
|
+ */
|
|
|
+ wrapT?: TextureWrapMode;
|
|
|
+ /**
|
|
|
+ * Anisotropic filtering samples
|
|
|
+ */
|
|
|
+ maxAnisotropy?: number;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Represents a valid WebGL texture source for use in texImage2D
|
|
|
+ */
|
|
|
+ export type TextureSource = TextureData | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;
|
|
|
+ /**
|
|
|
+ * A generic set of texture mipmaps (where index 0 has the largest dimension)
|
|
|
+ */
|
|
|
+ export type Mipmaps<T> = Array<T>;
|
|
|
+ /**
|
|
|
+ * A set of 6 cubemap arranged in the order [+x, -x, +y, -y, +z, -z]
|
|
|
+ */
|
|
|
+ export type Faces<T> = Array<T>;
|
|
|
+ /**
|
|
|
+ * A set of texture mipmaps specifically for 2D textures in WebGL (where index 0 has the largest dimension)
|
|
|
+ */
|
|
|
+ export type Mipmaps2D = Mipmaps<TextureSource>;
|
|
|
+ /**
|
|
|
+ * A set of texture mipmaps specifically for cubemap textures in WebGL (where index 0 has the largest dimension)
|
|
|
+ */
|
|
|
+ export type MipmapsCube = Mipmaps<Faces<TextureSource>>;
|
|
|
+ /**
|
|
|
+ * A minimal WebGL cubemap descriptor
|
|
|
+ */
|
|
|
+ export class TextureCube {
|
|
|
+ internalFormat: PixelFormat;
|
|
|
+ type: PixelType;
|
|
|
+ source: MipmapsCube;
|
|
|
+ /**
|
|
|
+ * Returns the width of a face of the texture or 0 if not available
|
|
|
+ */
|
|
|
+ readonly Width: number;
|
|
|
+ /**
|
|
|
+ * Returns the height of a face of the texture or 0 if not available
|
|
|
+ */
|
|
|
+ readonly Height: number;
|
|
|
+ /**
|
|
|
+ * constructor
|
|
|
+ * @param internalFormat WebGL pixel format for the texture on the GPU
|
|
|
+ * @param type WebGL pixel type of the supplied data and texture on the GPU
|
|
|
+ * @param source An array containing mipmap levels of faces, where each mipmap level is an array of faces and each face is a TextureSource object
|
|
|
+ */
|
|
|
+ constructor(internalFormat: PixelFormat, type: PixelType, source?: MipmapsCube);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * A static class providing methods to aid working with Bablyon textures.
|
|
|
+ */
|
|
|
+ export class TextureUtils {
|
|
|
+ /**
|
|
|
+ * A prefix used when storing a babylon texture object reference on a Spectre texture object
|
|
|
+ */
|
|
|
+ static BabylonTextureKeyPrefix: string;
|
|
|
+ /**
|
|
|
+ * Controls anisotropic filtering for deserialized textures.
|
|
|
+ */
|
|
|
+ static MaxAnisotropy: number;
|
|
|
+ /**
|
|
|
+ * Returns a BabylonCubeTexture instance from a Spectre texture cube, subject to sampling parameters.
|
|
|
+ * If such a texture has already been requested in the past, this texture will be returned, otherwise a new one will be created.
|
|
|
+ * The advantage of this is to enable working with texture objects without the need to initialize on the GPU until desired.
|
|
|
+ * @param scene A Babylon Scene instance
|
|
|
+ * @param textureCube A Spectre TextureCube object
|
|
|
+ * @param parameters WebGL texture sampling parameters
|
|
|
+ * @param automaticMipmaps Pass true to enable automatic mipmap generation where possible (requires power of images)
|
|
|
+ * @param environment Specifies that the texture will be used as an environment
|
|
|
+ * @param singleLod Specifies that the texture will be a singleLod (for environment)
|
|
|
+ * @return Babylon cube texture
|
|
|
+ */
|
|
|
+ static GetBabylonCubeTexture(scene: Scene, textureCube: TextureCube, automaticMipmaps: boolean, environment?: boolean, singleLod?: boolean): CubeTexture;
|
|
|
+ /**
|
|
|
+ * Applies Spectre SamplingParameters to a Babylon texture by directly setting texture parameters on the internal WebGLTexture as well as setting Babylon fields
|
|
|
+ * @param babylonTexture Babylon texture to apply texture to (requires the Babylon texture has an initialize _texture field)
|
|
|
+ * @param parameters Spectre SamplingParameters to apply
|
|
|
+ */
|
|
|
+ static ApplySamplingParameters(babylonTexture: BaseTexture, parameters: SamplingParameters): void;
|
|
|
+ /**
|
|
|
+ * Environment preprocessing dedicated value (Internal Use or Advanced only).
|
|
|
+ */
|
|
|
+ static EnvironmentLODScale: number;
|
|
|
+ /**
|
|
|
+ * Environment preprocessing dedicated value (Internal Use or Advanced only)..
|
|
|
+ */
|
|
|
+ static EnvironmentLODOffset: number;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|