@babylonjs/viewer 5.0.0-rc.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configuration/configuration.d.ts +13 -13
- package/configuration/configuration.js +1 -1
- package/configuration/configuration.js.map +1 -1
- package/configuration/configurationCompatibility.d.ts +1 -1
- package/configuration/configurationCompatibility.js +2 -2
- package/configuration/configurationCompatibility.js.map +1 -1
- package/configuration/configurationContainer.d.ts +3 -3
- package/configuration/configurationContainer.js +1 -1
- package/configuration/configurationContainer.js.map +1 -1
- package/configuration/globals.d.ts +1 -1
- package/configuration/globals.js.map +1 -1
- package/configuration/index.d.ts +2 -2
- package/configuration/index.js +3 -2
- package/configuration/index.js.map +1 -1
- package/configuration/interfaces/cameraConfiguration.js.map +1 -1
- package/configuration/interfaces/colorGradingConfiguration.js.map +1 -1
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.d.ts +1 -1
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.js.map +1 -1
- package/configuration/interfaces/environmentMapConfiguration.js.map +1 -1
- package/configuration/interfaces/groundConfiguration.js.map +1 -1
- package/configuration/interfaces/imageProcessingConfiguration.js.map +1 -1
- package/configuration/interfaces/index.d.ts +15 -15
- package/configuration/interfaces/index.js +15 -15
- package/configuration/interfaces/index.js.map +1 -1
- package/configuration/interfaces/lightConfiguration.js.map +1 -1
- package/configuration/interfaces/modelAnimationConfiguration.js.map +1 -1
- package/configuration/interfaces/modelConfiguration.d.ts +1 -1
- package/configuration/interfaces/modelConfiguration.js.map +1 -1
- package/configuration/interfaces/observersConfiguration.js.map +1 -1
- package/configuration/interfaces/sceneConfiguration.d.ts +3 -3
- package/configuration/interfaces/sceneConfiguration.js.map +1 -1
- package/configuration/interfaces/sceneOptimizerConfiguration.js.map +1 -1
- package/configuration/interfaces/skyboxConfiguration.d.ts +1 -1
- package/configuration/interfaces/skyboxConfiguration.js.map +1 -1
- package/configuration/interfaces/templateConfiguration.js.map +1 -1
- package/configuration/interfaces/vrConfiguration.d.ts +1 -1
- package/configuration/interfaces/vrConfiguration.js.map +1 -1
- package/configuration/loader.js +3 -15
- package/configuration/loader.js.map +1 -1
- package/configuration/mappers.d.ts +3 -3
- package/configuration/mappers.js +13 -12
- package/configuration/mappers.js.map +1 -1
- package/configuration/renderOnlyLoader.d.ts +1 -1
- package/configuration/renderOnlyLoader.js +18 -15
- package/configuration/renderOnlyLoader.js.map +1 -1
- package/configuration/types/default.d.ts +2 -2
- package/configuration/types/default.js +37 -36
- package/configuration/types/default.js.map +1 -1
- package/configuration/types/environmentMap.d.ts +1 -1
- package/configuration/types/environmentMap.js +5 -5
- package/configuration/types/environmentMap.js.map +1 -1
- package/configuration/types/extended.d.ts +2 -2
- package/configuration/types/extended.js +49 -49
- package/configuration/types/extended.js.map +1 -1
- package/configuration/types/index.d.ts +4 -4
- package/configuration/types/index.js +14 -13
- package/configuration/types/index.js.map +1 -1
- package/configuration/types/minimal.d.ts +2 -2
- package/configuration/types/minimal.js +12 -12
- package/configuration/types/minimal.js.map +1 -1
- package/configuration/types/renderOnlyDefault.d.ts +1 -1
- package/configuration/types/renderOnlyDefault.js +8 -8
- package/configuration/types/renderOnlyDefault.js.map +1 -1
- package/configuration/types/shadowLight.d.ts +1 -1
- package/configuration/types/shadowLight.js +12 -12
- package/configuration/types/shadowLight.js.map +1 -1
- package/helper/index.d.ts +3 -3
- package/helper/index.js +14 -8
- package/helper/index.js.map +1 -1
- package/index.d.ts +20 -20
- package/index.js +22 -18
- package/index.js.map +1 -1
- package/initializer.js +8 -7
- package/initializer.js.map +1 -1
- package/interfaces.js.map +1 -1
- package/labs/environmentSerializer.d.ts +6 -6
- package/labs/environmentSerializer.js +18 -14
- package/labs/environmentSerializer.js.map +1 -1
- package/labs/texture.d.ts +7 -8
- package/labs/texture.js +30 -27
- package/labs/texture.js.map +1 -1
- package/labs/viewerLabs.d.ts +11 -11
- package/labs/viewerLabs.js +9 -7
- package/labs/viewerLabs.js.map +1 -1
- package/license.md +71 -0
- package/loader/modelLoader.d.ts +10 -7
- package/loader/modelLoader.js +26 -19
- package/loader/modelLoader.js.map +1 -1
- package/loader/plugins/applyMaterialConfig.d.ts +4 -4
- package/loader/plugins/applyMaterialConfig.js.map +1 -1
- package/loader/plugins/extendedMaterialLoaderPlugin.d.ts +2 -2
- package/loader/plugins/extendedMaterialLoaderPlugin.js +1 -1
- package/loader/plugins/extendedMaterialLoaderPlugin.js.map +1 -1
- package/loader/plugins/index.d.ts +5 -4
- package/loader/plugins/index.js +9 -8
- package/loader/plugins/index.js.map +1 -1
- package/loader/plugins/loaderPlugin.d.ts +7 -7
- package/loader/plugins/loaderPlugin.js.map +1 -1
- package/loader/plugins/msftLodLoaderPlugin.d.ts +5 -5
- package/loader/plugins/msftLodLoaderPlugin.js +2 -1
- package/loader/plugins/msftLodLoaderPlugin.js.map +1 -1
- package/loader/plugins/telemetryLoaderPlugin.d.ts +4 -4
- package/loader/plugins/telemetryLoaderPlugin.js +4 -4
- package/loader/plugins/telemetryLoaderPlugin.js.map +1 -1
- package/managers/observablesManager.d.ts +6 -6
- package/managers/observablesManager.js +1 -1
- package/managers/observablesManager.js.map +1 -1
- package/managers/sceneManager.d.ts +28 -30
- package/managers/sceneManager.js +96 -95
- package/managers/sceneManager.js.map +1 -1
- package/managers/telemetryManager.d.ts +6 -6
- package/managers/telemetryManager.js +6 -6
- package/managers/telemetryManager.js.map +1 -1
- package/model/modelAnimation.d.ts +14 -14
- package/model/modelAnimation.js +3 -3
- package/model/modelAnimation.js.map +1 -1
- package/model/viewerModel.d.ts +23 -31
- package/model/viewerModel.js +51 -46
- package/model/viewerModel.js.map +1 -1
- package/optimizer/custom/extended.d.ts +3 -5
- package/optimizer/custom/extended.js +3 -5
- package/optimizer/custom/extended.js.map +1 -1
- package/optimizer/custom/index.d.ts +1 -1
- package/optimizer/custom/index.js +1 -1
- package/optimizer/custom/index.js.map +1 -1
- package/package.json +41 -215
- package/readme.md +12 -8
- package/renderOnlyIndex.d.ts +10 -10
- package/renderOnlyIndex.js +6 -4
- package/renderOnlyIndex.js.map +1 -1
- package/templating/eventManager.d.ts +1 -1
- package/templating/eventManager.js +4 -2
- package/templating/eventManager.js.map +1 -1
- package/templating/plugins/hdButtonPlugin.d.ts +2 -2
- package/templating/plugins/hdButtonPlugin.js +2 -15
- package/templating/plugins/hdButtonPlugin.js.map +1 -1
- package/templating/plugins/printButton.d.ts +2 -3
- package/templating/plugins/printButton.js +3 -16
- package/templating/plugins/printButton.js.map +1 -1
- package/templating/templateManager.d.ts +8 -7
- package/templating/templateManager.js +72 -62
- package/templating/templateManager.js.map +1 -1
- package/templating/viewerTemplatePlugin.d.ts +1 -1
- package/templating/viewerTemplatePlugin.js +4 -4
- package/templating/viewerTemplatePlugin.js.map +1 -1
- package/viewer/defaultViewer.d.ts +17 -11
- package/viewer/defaultViewer.js +116 -121
- package/viewer/defaultViewer.js.map +1 -1
- package/viewer/renderOnlyViewer.d.ts +2 -2
- package/viewer/renderOnlyViewer.js +17 -24
- package/viewer/renderOnlyViewer.js.map +1 -1
- package/viewer/viewer.d.ts +19 -18
- package/viewer/viewer.js +63 -49
- package/viewer/viewer.js.map +1 -1
- package/viewer/viewerManager.d.ts +5 -5
- package/viewer/viewerManager.js +4 -3
- package/viewer/viewerManager.js.map +1 -1
- package/viewer/viewerWithTemplate.js +2 -15
- package/viewer/viewerWithTemplate.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadowLight.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"shadowLight.js","sourceRoot":"","sources":["../../../../../../tools/viewer/src/configuration/types/shadowLight.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,IAAM,mCAAmC,GAAwB;IACpE,KAAK,EAAE;QACH,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,IAAI;KACnB;IACD,MAAM,EAAE;QACJ,cAAc,EAAE,IAAI;KACvB;IACD,MAAM,E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AI;YAChB,YAAY,EAAE;gBACV,kBAAkB,EAAE,GAAG;gBACvB,UAAU,EAAE,EAAE;gBACd,2BAA2B,EAAE,IAAI;aACpC;SACJ;KACJ;CACJ,CAAC","sourcesContent":["import type { ViewerConfiguration } from \"./../configuration\";\r\n\r\n/**\r\n * Defines a default directional shadow light for normalized objects (!)\r\n */\r\nexport const shadowDirectionalLightConfiguration: ViewerConfiguration = {\r\n model: {\r\n receiveShadows: true,\r\n castShadow: true,\r\n },\r\n ground: {\r\n receiveShadows: true,\r\n },\r\n lights: {\r\n shadowDirectionalLight: {\r\n type: 1,\r\n shadowEnabled: true,\r\n target: { x: 0, y: 0, z: 0.5 },\r\n position: { x: 1.49, y: 2.39, z: -1.33 },\r\n diffuse: { r: 0.867, g: 0.816, b: 0.788 },\r\n intensity: 4.887,\r\n intensityMode: 0,\r\n shadowBufferSize: 1024,\r\n shadowFrustumSize: 6.0,\r\n shadowFieldOfView: 50.977,\r\n shadowMinZ: 0.1,\r\n shadowMaxZ: 10.0,\r\n shadowConfig: {\r\n blurKernel: 32,\r\n useBlurCloseExponentialShadowMap: true,\r\n },\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * Defines a default shadow-enabled spot light for normalized objects.\r\n */\r\nexport const shadowSpotlLightConfiguration: ViewerConfiguration = {\r\n model: {\r\n receiveShadows: true,\r\n castShadow: true,\r\n },\r\n ground: {\r\n receiveShadows: true,\r\n },\r\n lights: {\r\n shadowSpotLight: {\r\n type: 2,\r\n intensity: 2,\r\n shadowEnabled: true,\r\n target: { x: 0, y: 0, z: 0.5 },\r\n position: { x: 0, y: 3.5, z: 3.7 },\r\n angle: 1,\r\n shadowOrthoScale: 0.5,\r\n shadowBufferSize: 1024,\r\n shadowMinZ: 0.1,\r\n shadowMaxZ: 50.0,\r\n shadowConfig: {\r\n frustumEdgeFalloff: 0.5,\r\n blurKernel: 32,\r\n useBlurExponentialShadowMap: true,\r\n },\r\n },\r\n },\r\n};\r\n"]}
|
package/helper/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare const expDm: Ideepmerge;
|
|
2
2
|
export { expDm as deepmerge };
|
|
3
3
|
/**
|
|
4
4
|
* Is the provided string a URL?
|
|
@@ -10,12 +10,12 @@ export declare function isUrl(urlToCheck: string): boolean;
|
|
|
10
10
|
* Convert a string from kebab-case to camelCase
|
|
11
11
|
* @param s string to convert
|
|
12
12
|
*/
|
|
13
|
-
export declare function kebabToCamel(s:
|
|
13
|
+
export declare function kebabToCamel(s: string): string;
|
|
14
14
|
/**
|
|
15
15
|
* Convert a string from camelCase to kebab-case
|
|
16
16
|
* @param str string to convert
|
|
17
17
|
*/
|
|
18
|
-
export declare function camelToKebab(str:
|
|
18
|
+
export declare function camelToKebab(str: string): string | null;
|
|
19
19
|
/**
|
|
20
20
|
* This will extend an object with configuration values.
|
|
21
21
|
* What it practically does it take the keys from the configuration and set them on the object.
|
package/helper/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as deepmerge from
|
|
2
|
-
var expDm = deepmerge[
|
|
1
|
+
import * as deepmerge from "deepmerge";
|
|
2
|
+
var expDm = deepmerge["default"];
|
|
3
3
|
export { expDm as deepmerge };
|
|
4
4
|
/**
|
|
5
5
|
* Is the provided string a URL?
|
|
@@ -7,7 +7,7 @@ export { expDm as deepmerge };
|
|
|
7
7
|
* @param urlToCheck the url to inspect
|
|
8
8
|
*/
|
|
9
9
|
export function isUrl(urlToCheck) {
|
|
10
|
-
if (urlToCheck.indexOf(
|
|
10
|
+
if (urlToCheck.indexOf("http") === 0 || urlToCheck.indexOf("/") === 0 || urlToCheck.indexOf("./") === 0 || urlToCheck.indexOf("../") === 0) {
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
return false;
|
|
@@ -17,7 +17,9 @@ export function isUrl(urlToCheck) {
|
|
|
17
17
|
* @param s string to convert
|
|
18
18
|
*/
|
|
19
19
|
export function kebabToCamel(s) {
|
|
20
|
-
return s.replace(/(
|
|
20
|
+
return s.replace(/(-\w)/g, function (m) {
|
|
21
|
+
return m[1].toUpperCase();
|
|
22
|
+
});
|
|
21
23
|
}
|
|
22
24
|
//https://gist.github.com/youssman/745578062609e8acac9f
|
|
23
25
|
/**
|
|
@@ -25,7 +27,11 @@ export function kebabToCamel(s) {
|
|
|
25
27
|
* @param str string to convert
|
|
26
28
|
*/
|
|
27
29
|
export function camelToKebab(str) {
|
|
28
|
-
return !str
|
|
30
|
+
return !str
|
|
31
|
+
? null
|
|
32
|
+
: str.replace(/([A-Z])/g, function (g) {
|
|
33
|
+
return "-" + g[0].toLowerCase();
|
|
34
|
+
});
|
|
29
35
|
}
|
|
30
36
|
/**
|
|
31
37
|
* This will extend an object with configuration values.
|
|
@@ -35,15 +41,15 @@ export function camelToKebab(str) {
|
|
|
35
41
|
* @param config the configuration object that will extend the object
|
|
36
42
|
*/
|
|
37
43
|
export function extendClassWithConfig(object, config) {
|
|
38
|
-
if (!config || typeof config !==
|
|
44
|
+
if (!config || typeof config !== "object") {
|
|
39
45
|
return;
|
|
40
46
|
}
|
|
41
47
|
Object.keys(config).forEach(function (key) {
|
|
42
|
-
if (key in object && typeof object[key] !==
|
|
48
|
+
if (key in object && typeof object[key] !== "function") {
|
|
43
49
|
// if (typeof object[key] === 'function') return;
|
|
44
50
|
// if it is an object, iterate internally until reaching basic types
|
|
45
51
|
// but null is an object so if its null and config[key] is not an object eg. number, the number should be set
|
|
46
|
-
if (
|
|
52
|
+
if (typeof object[key] === "object" && (object[key] !== null || typeof config[key] === "object")) {
|
|
47
53
|
extendClassWithConfig(object[key], config[key]);
|
|
48
54
|
}
|
|
49
55
|
else {
|
package/helper/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../tools/viewer/src/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,S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AAG,CAAC,KAAK,UAAU,EAAE;YACpD,iDAAiD;YACjD,oEAAoE;YACpE,6GAA6G;YAC7G,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,EAAE;gBAC9F,qBAAqB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;aACnD;iBAAM;gBACH,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;oBAC3B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;iBAC7B;aACJ;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import * as deepmerge from \"deepmerge\";\r\n\r\nconst expDm = deepmerge[\"default\"];\r\nexport { expDm as deepmerge };\r\n\r\n/**\r\n * Is the provided string a URL?\r\n *\r\n * @param urlToCheck the url to inspect\r\n */\r\nexport function isUrl(urlToCheck: string): boolean {\r\n if (urlToCheck.indexOf(\"http\") === 0 || urlToCheck.indexOf(\"/\") === 0 || urlToCheck.indexOf(\"./\") === 0 || urlToCheck.indexOf(\"../\") === 0) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Convert a string from kebab-case to camelCase\r\n * @param s string to convert\r\n */\r\nexport function kebabToCamel(s: string) {\r\n return s.replace(/(-\\w)/g, function (m) {\r\n return m[1].toUpperCase();\r\n });\r\n}\r\n\r\n//https://gist.github.com/youssman/745578062609e8acac9f\r\n/**\r\n * Convert a string from camelCase to kebab-case\r\n * @param str string to convert\r\n */\r\nexport function camelToKebab(str: string) {\r\n return !str\r\n ? null\r\n : str.replace(/([A-Z])/g, function (g) {\r\n return \"-\" + g[0].toLowerCase();\r\n });\r\n}\r\n\r\n/**\r\n * This will extend an object with configuration values.\r\n * What it practically does it take the keys from the configuration and set them on the object.\r\n * If the configuration is a tree, it will traverse into the tree.\r\n * @param object the object to extend\r\n * @param config the configuration object that will extend the object\r\n */\r\nexport function extendClassWithConfig(object: any, config: any) {\r\n if (!config || typeof config !== \"object\") {\r\n return;\r\n }\r\n Object.keys(config).forEach(function (key) {\r\n if (key in object && typeof object[key] !== \"function\") {\r\n // if (typeof object[key] === 'function') return;\r\n // if it is an object, iterate internally until reaching basic types\r\n // but null is an object so if its null and config[key] is not an object eg. number, the number should be set\r\n if (typeof object[key] === \"object\" && (object[key] !== null || typeof config[key] === \"object\")) {\r\n extendClassWithConfig(object[key], config[key]);\r\n } else {\r\n if (config[key] !== undefined) {\r\n object[key] = config[key];\r\n }\r\n }\r\n }\r\n });\r\n}\r\n"]}
|
package/index.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { mapperManager } from
|
|
2
|
-
import { viewerGlobals } from
|
|
3
|
-
import { viewerManager } from
|
|
4
|
-
import { DefaultViewer } from
|
|
5
|
-
import { AbstractViewer } from
|
|
6
|
-
import { telemetryManager } from
|
|
7
|
-
import { ModelLoader } from
|
|
8
|
-
import { ViewerModel, ModelState } from
|
|
9
|
-
import { AnimationPlayMode, AnimationState } from
|
|
10
|
-
import { ILoaderPlugin } from
|
|
11
|
-
import { AbstractViewerNavbarButton } from
|
|
12
|
-
import { registerCustomOptimizer } from
|
|
1
|
+
import { mapperManager } from "./configuration/mappers";
|
|
2
|
+
import { viewerGlobals } from "./configuration/globals";
|
|
3
|
+
import { viewerManager } from "./viewer/viewerManager";
|
|
4
|
+
import { DefaultViewer } from "./viewer/defaultViewer";
|
|
5
|
+
import { AbstractViewer } from "./viewer/viewer";
|
|
6
|
+
import { telemetryManager } from "./managers/telemetryManager";
|
|
7
|
+
import { ModelLoader } from "./loader/modelLoader";
|
|
8
|
+
import { ViewerModel, ModelState } from "./model/viewerModel";
|
|
9
|
+
import { AnimationPlayMode, AnimationState } from "./model/modelAnimation";
|
|
10
|
+
import { ILoaderPlugin } from "./loader/plugins/loaderPlugin";
|
|
11
|
+
import { AbstractViewerNavbarButton } from "./templating/viewerTemplatePlugin";
|
|
12
|
+
import { registerCustomOptimizer } from "./optimizer/custom/index";
|
|
13
13
|
/**
|
|
14
14
|
* BabylonJS Viewer
|
|
15
15
|
*
|
|
16
16
|
* An HTML-Based viewer for 3D models, based on BabylonJS and its extensions.
|
|
17
17
|
*/
|
|
18
|
-
import * as BABYLON from
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { InitTags } from
|
|
22
|
-
declare
|
|
18
|
+
import * as BABYLON from "@babylonjs/core/index.js";
|
|
19
|
+
import "@babylonjs/loaders/.js";
|
|
20
|
+
import "pepjs";
|
|
21
|
+
import { InitTags } from "./initializer";
|
|
22
|
+
declare const disableInit: boolean;
|
|
23
23
|
/**
|
|
24
24
|
* Dispose all viewers currently registered
|
|
25
25
|
*/
|
|
26
26
|
declare function disposeAll(): void;
|
|
27
27
|
declare const Version: string;
|
|
28
|
-
export { BABYLON, Version, InitTags, DefaultViewer, AbstractViewer, viewerGlobals, telemetryManager, disableInit, viewerManager, mapperManager, disposeAll, ModelLoader, ViewerModel, AnimationPlayMode, AnimationState, ModelState, ILoaderPlugin, AbstractViewerNavbarButton, registerCustomOptimizer };
|
|
29
|
-
export { GLTF2 } from
|
|
30
|
-
export * from
|
|
28
|
+
export { BABYLON, Version, InitTags, DefaultViewer, AbstractViewer, viewerGlobals, telemetryManager, disableInit, viewerManager, mapperManager, disposeAll, ModelLoader, ViewerModel, AnimationPlayMode, AnimationState, ModelState, ILoaderPlugin, AbstractViewerNavbarButton, registerCustomOptimizer, };
|
|
29
|
+
export { GLTF2 } from "@babylonjs/loaders/glTF/index.js";
|
|
30
|
+
export * from "./configuration/index";
|
package/index.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { mapperManager } from
|
|
2
|
-
import { viewerGlobals } from
|
|
3
|
-
import { viewerManager } from
|
|
4
|
-
import { DefaultViewer } from
|
|
5
|
-
import { AbstractViewer } from
|
|
6
|
-
import { telemetryManager } from
|
|
7
|
-
import { ModelLoader } from
|
|
8
|
-
import { ViewerModel, ModelState } from
|
|
9
|
-
import { AnimationPlayMode, AnimationState } from
|
|
10
|
-
import { AbstractViewerNavbarButton } from
|
|
11
|
-
|
|
1
|
+
import { mapperManager } from "./configuration/mappers.js";
|
|
2
|
+
import { viewerGlobals } from "./configuration/globals.js";
|
|
3
|
+
import { viewerManager } from "./viewer/viewerManager.js";
|
|
4
|
+
import { DefaultViewer } from "./viewer/defaultViewer.js";
|
|
5
|
+
import { AbstractViewer } from "./viewer/viewer.js";
|
|
6
|
+
import { telemetryManager } from "./managers/telemetryManager.js";
|
|
7
|
+
import { ModelLoader } from "./loader/modelLoader.js";
|
|
8
|
+
import { ViewerModel, ModelState } from "./model/viewerModel.js";
|
|
9
|
+
import { AnimationPlayMode, AnimationState } from "./model/modelAnimation.js";
|
|
10
|
+
import { AbstractViewerNavbarButton } from "./templating/viewerTemplatePlugin.js";
|
|
11
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
12
|
+
import { registerCustomOptimizer } from "./optimizer/custom/index.js";
|
|
12
13
|
/**
|
|
13
14
|
* BabylonJS Viewer
|
|
14
15
|
*
|
|
15
16
|
* An HTML-Based viewer for 3D models, based on BabylonJS and its extensions.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
19
|
+
import * as BABYLON from "@babylonjs/core/index.js";
|
|
18
20
|
// load needed modules.
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { initListeners, InitTags } from
|
|
21
|
+
import "@babylonjs/loaders/.js";
|
|
22
|
+
import "pepjs";
|
|
23
|
+
import { initListeners, InitTags } from "./initializer.js";
|
|
22
24
|
// promise polyfill, if needed!
|
|
23
25
|
BABYLON.PromisePolyfill.Apply();
|
|
24
26
|
initListeners();
|
|
@@ -35,8 +37,10 @@ function disposeAll() {
|
|
|
35
37
|
var Version = viewerGlobals.version;
|
|
36
38
|
console.log("Babylon.js viewer (v" + Version + ")");
|
|
37
39
|
// public API for initialization
|
|
38
|
-
export { BABYLON, Version, InitTags, DefaultViewer, AbstractViewer, viewerGlobals, telemetryManager, disableInit, viewerManager, mapperManager, disposeAll, ModelLoader, ViewerModel, AnimationPlayMode, AnimationState, ModelState, AbstractViewerNavbarButton, registerCustomOptimizer };
|
|
39
|
-
|
|
40
|
+
export { BABYLON, Version, InitTags, DefaultViewer, AbstractViewer, viewerGlobals, telemetryManager, disableInit, viewerManager, mapperManager, disposeAll, ModelLoader, ViewerModel, AnimationPlayMode, AnimationState, ModelState, AbstractViewerNavbarButton, registerCustomOptimizer, };
|
|
41
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
42
|
+
export { GLTF2 } from "@babylonjs/loaders/glTF/index.js";
|
|
40
43
|
// export publicliy all configuration interfaces
|
|
41
|
-
|
|
44
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
45
|
+
export * from "./configuration/index.js";
|
|
42
46
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../tools/viewer/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAA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./configuration/globals\";\r\nimport { viewerManager } from \"./viewer/viewerManager\";\r\nimport { DefaultViewer } from \"./viewer/defaultViewer\";\r\nimport { AbstractViewer } from \"./viewer/viewer\";\r\nimport { telemetryManager } from \"./managers/telemetryManager\";\r\nimport { ModelLoader } from \"./loader/modelLoader\";\r\nimport { ViewerModel, ModelState } from \"./model/viewerModel\";\r\nimport { AnimationPlayMode, AnimationState } from \"./model/modelAnimation\";\r\nimport { ILoaderPlugin } from \"./loader/plugins/loaderPlugin\";\r\nimport { AbstractViewerNavbarButton } from \"./templating/viewerTemplatePlugin\";\r\n// eslint-disable-next-line import/no-internal-modules\r\nimport { registerCustomOptimizer } from \"./optimizer/custom/index\";\r\n\r\n/**\r\n * BabylonJS Viewer\r\n *\r\n * An HTML-Based viewer for 3D models, based on BabylonJS and its extensions.\r\n */\r\n\r\n// eslint-disable-next-line import/no-internal-modules\r\nimport * as BABYLON from \"core/index\";\r\n\r\n// load needed modules.\r\nimport \"loaders\";\r\nimport \"pepjs\";\r\n\r\nimport { initListeners, InitTags } from \"./initializer\";\r\n\r\n// promise polyfill, if needed!\r\nBABYLON.PromisePolyfill.Apply();\r\ninitListeners();\r\n\r\n//deprectaed, here for backwards compatibility\r\nconst disableInit: boolean = viewerGlobals.disableInit;\r\n\r\n/**\r\n * Dispose all viewers currently registered\r\n */\r\nfunction disposeAll() {\r\n viewerManager.dispose();\r\n mapperManager.dispose();\r\n telemetryManager.dispose();\r\n}\r\n\r\nconst Version = viewerGlobals.version;\r\n\r\nconsole.log(\"Babylon.js viewer (v\" + Version + \")\");\r\n\r\n// public API for initialization\r\nexport {\r\n BABYLON,\r\n Version,\r\n InitTags,\r\n DefaultViewer,\r\n AbstractViewer,\r\n viewerGlobals,\r\n telemetryManager,\r\n disableInit,\r\n viewerManager,\r\n mapperManager,\r\n disposeAll,\r\n ModelLoader,\r\n ViewerModel,\r\n AnimationPlayMode,\r\n AnimationState,\r\n ModelState,\r\n ILoaderPlugin,\r\n AbstractViewerNavbarButton,\r\n registerCustomOptimizer,\r\n};\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport { GLTF2 } from \"loaders/glTF/index\";\r\n// export publicliy all configuration interfaces\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport * from \"./configuration/index\";\r\n"]}
|
package/initializer.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DefaultViewer } from
|
|
2
|
-
import { mapperManager } from
|
|
3
|
-
import { viewerGlobals } from
|
|
1
|
+
import { DefaultViewer } from "./viewer/defaultViewer.js";
|
|
2
|
+
import { mapperManager } from "./configuration/mappers.js";
|
|
3
|
+
import { viewerGlobals } from "./configuration/globals.js";
|
|
4
4
|
/**
|
|
5
5
|
* Will attach an init function the the DOMContentLoaded event.
|
|
6
6
|
* The init function will be removed automatically after the event was triggered.
|
|
7
7
|
*/
|
|
8
8
|
export function initListeners() {
|
|
9
9
|
document.addEventListener("DOMContentLoaded", init);
|
|
10
|
-
function init(
|
|
10
|
+
function init() {
|
|
11
11
|
document.removeEventListener("DOMContentLoaded", init);
|
|
12
12
|
if (viewerGlobals.disableInit) {
|
|
13
13
|
return;
|
|
@@ -21,14 +21,15 @@ export function initListeners() {
|
|
|
21
21
|
* @param selector the selector to initialize the viewer on (default is 'babylon')
|
|
22
22
|
*/
|
|
23
23
|
export function InitTags(selector) {
|
|
24
|
-
if (selector === void 0) { selector =
|
|
24
|
+
if (selector === void 0) { selector = "babylon"; }
|
|
25
25
|
var elements = document.querySelectorAll(selector);
|
|
26
26
|
for (var i = 0; i < elements.length; ++i) {
|
|
27
27
|
var element = elements.item(i);
|
|
28
28
|
// get the html configuration
|
|
29
|
-
var configMapper = mapperManager.getMapper(
|
|
29
|
+
var configMapper = mapperManager.getMapper("dom");
|
|
30
30
|
var config = configMapper.map(element);
|
|
31
|
-
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
+
new DefaultViewer(element, config);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
//# sourceMappingURL=initializer.js.map
|
package/initializer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializer.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"initializer.js","sourceRoot":"","sources":["../../../../tools/viewer/src/initializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,aAAa;IACzB,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IACpD,SAAS,IAAI;QACT,QAAQ,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACvD,IAAI,aAAa,CAAC,WAAW,EAAE;YAC3B,OAAO;SACV;QACD,QAAQ,EAAE,CAAC;IACf,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IAA5B,yBAAA,EAAA,oBAA4B;IACjD,IAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACrD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACtC,IAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEjC,6BAA6B;QAC7B,IAAM,YAAY,GAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACpD,IAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEzC,6DAA6D;QAC7D,IAAI,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KACtC;AACL,CAAC","sourcesContent":["import { DefaultViewer } from \"./viewer/defaultViewer\";\r\nimport { mapperManager } from \"./configuration/mappers\";\r\nimport { viewerGlobals } from \"./configuration/globals\";\r\n\r\n/**\r\n * Will attach an init function the the DOMContentLoaded event.\r\n * The init function will be removed automatically after the event was triggered.\r\n */\r\nexport function initListeners() {\r\n document.addEventListener(\"DOMContentLoaded\", init);\r\n function init() {\r\n document.removeEventListener(\"DOMContentLoaded\", init);\r\n if (viewerGlobals.disableInit) {\r\n return;\r\n }\r\n InitTags();\r\n }\r\n}\r\n\r\n/**\r\n * Select all HTML tags on the page that match the selector and initialize a viewer\r\n *\r\n * @param selector the selector to initialize the viewer on (default is 'babylon')\r\n */\r\nexport function InitTags(selector: string = \"babylon\") {\r\n const elements = document.querySelectorAll(selector);\r\n for (let i = 0; i < elements.length; ++i) {\r\n const element = elements.item(i);\r\n\r\n // get the html configuration\r\n const configMapper = mapperManager.getMapper(\"dom\");\r\n const config = configMapper.map(element);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n new DefaultViewer(element, config);\r\n }\r\n}\r\n"]}
|
package/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../tools/viewer/src/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["export const enum CameraBehavior {\r\n AUTOROTATION,\r\n BOUNCING,\r\n FRAMING,\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Vector3 } from
|
|
2
|
-
import { TextureCube } from
|
|
1
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.js";
|
|
2
|
+
import { TextureCube } from "./texture";
|
|
3
3
|
/**
|
|
4
4
|
* Spherical polynomial coefficients (counter part to spherical harmonic coefficients used in shader irradiance calculation)
|
|
5
5
|
* @ignoreChildren
|
|
@@ -33,13 +33,13 @@ export interface PBREnvironment {
|
|
|
33
33
|
textureIntensityScale: number;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export declare type MapType =
|
|
36
|
+
* Environment map representations: layouts, projections and approximations
|
|
37
|
+
*/
|
|
38
|
+
export declare type MapType = "irradiance_sh_coefficients_9" | "cubemap_faces";
|
|
39
39
|
/**
|
|
40
40
|
* Image type used for environment map
|
|
41
41
|
*/
|
|
42
|
-
export declare type ImageType =
|
|
42
|
+
export declare type ImageType = "png";
|
|
43
43
|
/**
|
|
44
44
|
* A generic field in JSON that report's its type
|
|
45
45
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.js";
|
|
3
|
+
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
|
4
|
+
import { TextureCube } from "./texture.js";
|
|
4
5
|
/**
|
|
5
6
|
* A static class proving methods to aid parsing Spectre environment files
|
|
6
7
|
*/
|
|
@@ -24,7 +25,7 @@ var EnvironmentDeserializer = /** @class */ (function () {
|
|
|
24
25
|
zz: new Vector3(0, 0, 0),
|
|
25
26
|
yz: new Vector3(0, 0, 0),
|
|
26
27
|
zx: new Vector3(0, 0, 0),
|
|
27
|
-
xy: new Vector3(0, 0, 0)
|
|
28
|
+
xy: new Vector3(0, 0, 0),
|
|
28
29
|
},
|
|
29
30
|
//specular
|
|
30
31
|
textureIntensityScale: 1.0,
|
|
@@ -36,7 +37,7 @@ var EnvironmentDeserializer = /** @class */ (function () {
|
|
|
36
37
|
var pos = 0;
|
|
37
38
|
for (var i = 0; i < magicBytes.length; i++) {
|
|
38
39
|
if (dataView.getUint8(pos++) !== magicBytes[i]) {
|
|
39
|
-
Tools.Error(
|
|
40
|
+
Tools.Error("Not a Spectre environment map");
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
var version = dataView.getUint16(pos, littleEndian);
|
|
@@ -45,7 +46,7 @@ var EnvironmentDeserializer = /** @class */ (function () {
|
|
|
45
46
|
Tools.Warn('Unsupported Spectre environment map version "' + version + '"');
|
|
46
47
|
}
|
|
47
48
|
//read json descriptor - collect characters up to null terminator
|
|
48
|
-
var descriptorString =
|
|
49
|
+
var descriptorString = "";
|
|
49
50
|
var charCode = 0x00;
|
|
50
51
|
while ((charCode = dataView.getUint8(pos++))) {
|
|
51
52
|
descriptorString += String.fromCharCode(charCode);
|
|
@@ -54,21 +55,22 @@ var EnvironmentDeserializer = /** @class */ (function () {
|
|
|
54
55
|
var payloadPos = pos;
|
|
55
56
|
//irradiance
|
|
56
57
|
switch (descriptor.irradiance.type) {
|
|
57
|
-
case
|
|
58
|
+
case "irradiance_sh_coefficients_9": {
|
|
58
59
|
//irradiance
|
|
59
60
|
var harmonics = descriptor.irradiance;
|
|
60
61
|
EnvironmentDeserializer._ConvertSHIrradianceToLambertianRadiance(harmonics);
|
|
61
62
|
//harmonics now represent radiance
|
|
62
63
|
EnvironmentDeserializer._ConvertSHToSP(harmonics, environment.irradiancePolynomialCoefficients);
|
|
63
64
|
break;
|
|
65
|
+
}
|
|
64
66
|
default:
|
|
65
|
-
Tools.Error(
|
|
67
|
+
Tools.Error("Unhandled MapType descriptor.irradiance.type (" + descriptor.irradiance.type + ")");
|
|
66
68
|
}
|
|
67
69
|
//specular
|
|
68
70
|
switch (descriptor.specular.type) {
|
|
69
|
-
case
|
|
71
|
+
case "cubemap_faces": {
|
|
70
72
|
var specularDescriptor = descriptor.specular;
|
|
71
|
-
var specularTexture = environment.specularTexture = new TextureCube(6408 /* RGBA */, 5121 /* UNSIGNED_BYTE */);
|
|
73
|
+
var specularTexture = (environment.specularTexture = new TextureCube(6408 /* RGBA */, 5121 /* UNSIGNED_BYTE */));
|
|
72
74
|
environment.textureIntensityScale = specularDescriptor.multiplier != null ? specularDescriptor.multiplier : 1.0;
|
|
73
75
|
var mipmaps = specularDescriptor.mipmaps;
|
|
74
76
|
var imageType = specularDescriptor.imageType;
|
|
@@ -79,21 +81,23 @@ var EnvironmentDeserializer = /** @class */ (function () {
|
|
|
79
81
|
var range = faceRanges[i];
|
|
80
82
|
var bytes = new Uint8Array(arrayBuffer, payloadPos + range.pos, range.length);
|
|
81
83
|
switch (imageType) {
|
|
82
|
-
case
|
|
84
|
+
case "png": {
|
|
83
85
|
//construct image element from bytes
|
|
84
86
|
var image = new Image();
|
|
85
|
-
var src = URL.createObjectURL(new Blob([bytes], { type:
|
|
87
|
+
var src = URL.createObjectURL(new Blob([bytes], { type: "image/png" }));
|
|
86
88
|
image.src = src;
|
|
87
89
|
specularTexture.source[l][i] = image;
|
|
88
90
|
break;
|
|
91
|
+
}
|
|
89
92
|
default:
|
|
90
|
-
Tools.Error(
|
|
93
|
+
Tools.Error("Unhandled ImageType descriptor.specular.imageType (" + imageType + ")");
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
break;
|
|
98
|
+
}
|
|
95
99
|
default:
|
|
96
|
-
Tools.Error(
|
|
100
|
+
Tools.Error("Unhandled MapType descriptor.specular.type (" + descriptor.specular.type + ")");
|
|
97
101
|
}
|
|
98
102
|
return environment;
|
|
99
103
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentSerializer.js","sourceRoot":"","sources":["../../../../sourceES6/viewer/src/labs/environmentSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAA0B,MAAM,WAAW,CAAC;AAkHhE;;GAEG;AACH;IAAA;IAqNA,CAAC;IAnNG;;;;OAIG;IACW,6BAAK,GAAnB,UAAoB,WAAwB;QACxC,IAAI,WAAW,GAAmB;YAC9B,YAAY;YACZ,gCAAgC,EAAE;gBAC9B,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC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} from '@babylonjs/core/Misc/tools';\r\nimport { TextureCube, PixelFormat, PixelType } from './texture';\r\n\r\n/**\r\n * Spherical polynomial coefficients (counter part to spherical harmonic coefficients used in shader irradiance calculation)\r\n * @ignoreChildren\r\n */\r\nexport interface SphericalPolynomalCoefficients {\r\n x: Vector3;\r\n y: Vector3;\r\n z: Vector3;\r\n xx: Vector3;\r\n yy: Vector3;\r\n zz: Vector3;\r\n yz: Vector3;\r\n zx: Vector3;\r\n xy: Vector3;\r\n}\r\n\r\n/**\r\n * Wraps data and maps required for environments with physically based rendering\r\n */\r\nexport interface PBREnvironment {\r\n\r\n /**\r\n * Spherical Polynomial Coefficients representing an irradiance map\r\n */\r\n irradiancePolynomialCoefficients: SphericalPolynomalCoefficients;\r\n\r\n /**\r\n * Specular cubemap\r\n */\r\n specularTexture?: TextureCube;\r\n /**\r\n * A scale factor applied to RGB values after reading from environment maps\r\n */\r\n textureIntensityScale: number;\r\n}\r\n\r\n/**\r\n * Environment map representations: layouts, projections and approximations\r\n */\r\nexport type MapType =\r\n 'irradiance_sh_coefficients_9' |\r\n 'cubemap_faces';\r\n\r\n/**\r\n * Image type used for environment map\r\n */\r\nexport type ImageType = 'png';\r\n\r\n//Payload Descriptor\r\n\r\n/**\r\n * A generic field in JSON that report's its type\r\n */\r\nexport interface TypedObject<T> {\r\n type: T;\r\n}\r\n\r\n/**\r\n * Describes a range of bytes starting at byte pos (inclusive) and finishing at byte pos + length - 1\r\n */\r\nexport interface ByteRange {\r\n pos: number;\r\n length: number;\r\n}\r\n\r\n/**\r\n * Complete Spectre Environment JSON Descriptor\r\n */\r\nexport interface EnvJsonDescriptor {\r\n radiance: TypedObject<MapType>;\r\n irradiance: TypedObject<MapType>;\r\n specular: TypedObject<MapType>;\r\n}\r\n\r\n/**\r\n * Spherical harmonic coefficients to provide an irradiance map\r\n */\r\nexport interface IrradianceSHCoefficients9 extends TypedObject<MapType> {\r\n l00: Array<number>;\r\n\r\n l1_1: Array<number>;\r\n l10: Array<number>;\r\n l11: Array<number>;\r\n\r\n l2_2: Array<number>;\r\n l2_1: Array<number>;\r\n l20: Array<number>;\r\n l21: Array<number>;\r\n l22: Array<number>;\r\n}\r\n\r\n/**\r\n * A generic set of images, where the image content is specified by byte ranges in the mipmaps field\r\n */\r\nexport interface ImageSet<T> extends TypedObject<MapType> {\r\n imageType: ImageType;\r\n width: number;\r\n height: number;\r\n mipmaps: Array<T>;\r\n multiplier: number;\r\n}\r\n\r\n/**\r\n * A set of cubemap faces\r\n */\r\nexport type CubemapFaces = ImageSet<Array<ByteRange>>;\r\n\r\n/**\r\n * A single image containing an atlas of equirectangular-projection maps across all mip levels\r\n */\r\nexport type EquirectangularMipmapAtlas = ImageSet<ByteRange>;\r\n\r\n/**\r\n * A static class proving methods to aid parsing Spectre environment files\r\n */\r\nexport class EnvironmentDeserializer {\r\n\r\n /**\r\n * Parses an arraybuffer into a new PBREnvironment object\r\n * @param arrayBuffer The arraybuffer of the Spectre environment file\r\n * @return a PBREnvironment object\r\n */\r\n public static Parse(arrayBuffer: ArrayBuffer): PBREnvironment {\r\n var environment: PBREnvironment = {\r\n //irradiance\r\n irradiancePolynomialCoefficients: {\r\n x: new Vector3(0, 0, 0),\r\n y: new Vector3(0, 0, 0),\r\n z: new Vector3(0, 0, 0),\r\n xx: new Vector3(0, 0, 0),\r\n yy: new Vector3(0, 0, 0),\r\n zz: new Vector3(0, 0, 0),\r\n yz: new Vector3(0, 0, 0),\r\n zx: new Vector3(0, 0, 0),\r\n xy: new Vector3(0, 0, 0)\r\n },\r\n\r\n //specular\r\n textureIntensityScale: 1.0,\r\n };\r\n\r\n //read .env\r\n let littleEndian = false;\r\n\r\n let magicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\r\n\r\n let dataView = new DataView(arrayBuffer);\r\n let pos = 0;\r\n\r\n for (let i = 0; i < magicBytes.length; i++) {\r\n if (dataView.getUint8(pos++) !== magicBytes[i]) {\r\n Tools.Error('Not a Spectre environment map');\r\n }\r\n }\r\n\r\n let version = dataView.getUint16(pos, littleEndian); pos += 2;\r\n\r\n if (version !== 1) {\r\n Tools.Warn('Unsupported Spectre environment map version \"' + version + '\"');\r\n }\r\n\r\n //read json descriptor - collect characters up to null terminator\r\n let descriptorString = '';\r\n let charCode = 0x00;\r\n while ((charCode = dataView.getUint8(pos++))) {\r\n descriptorString += String.fromCharCode(charCode);\r\n }\r\n\r\n let descriptor: EnvJsonDescriptor = JSON.parse(descriptorString);\r\n\r\n let payloadPos = pos;\r\n\r\n //irradiance\r\n switch (descriptor.irradiance.type) {\r\n case 'irradiance_sh_coefficients_9':\r\n //irradiance\r\n let harmonics = <IrradianceSHCoefficients9>descriptor.irradiance;\r\n\r\n EnvironmentDeserializer._ConvertSHIrradianceToLambertianRadiance(harmonics);\r\n\r\n //harmonics now represent radiance\r\n EnvironmentDeserializer._ConvertSHToSP(harmonics, environment.irradiancePolynomialCoefficients);\r\n break;\r\n default:\r\n Tools.Error('Unhandled MapType descriptor.irradiance.type (' + descriptor.irradiance.type + ')');\r\n }\r\n\r\n //specular\r\n switch (descriptor.specular.type) {\r\n case 'cubemap_faces':\r\n\r\n var specularDescriptor = <CubemapFaces>descriptor.specular;\r\n\r\n let specularTexture = environment.specularTexture = new TextureCube(PixelFormat.RGBA, PixelType.UNSIGNED_BYTE);\r\n environment.textureIntensityScale = specularDescriptor.multiplier != null ? specularDescriptor.multiplier : 1.0;\r\n\r\n let mipmaps = specularDescriptor.mipmaps;\r\n let imageType = specularDescriptor.imageType;\r\n\r\n for (let l = 0; l < mipmaps.length; l++) {\r\n let faceRanges = mipmaps[l];\r\n\r\n specularTexture.source[l] = [];\r\n\r\n for (let i = 0; i < 6; i++) {\r\n\r\n let range = faceRanges[i];\r\n let bytes = new Uint8Array(arrayBuffer, payloadPos + range.pos, range.length);\r\n\r\n switch (imageType) {\r\n case 'png':\r\n\r\n //construct image element from bytes\r\n let image = new Image();\r\n let src = URL.createObjectURL(new Blob([bytes], { type: 'image/png' }));\r\n image.src = src;\r\n specularTexture.source[l][i] = image;\r\n\r\n break;\r\n default:\r\n Tools.Error('Unhandled ImageType descriptor.specular.imageType (' + imageType + ')');\r\n }\r\n }\r\n }\r\n\r\n break;\r\n default:\r\n Tools.Error('Unhandled MapType descriptor.specular.type (' + descriptor.specular.type + ')');\r\n }\r\n\r\n return environment;\r\n }\r\n\r\n /**\r\n * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.\r\n *\t L = (1/pi) * E * rho\r\n *\r\n * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n */\r\n private static _ConvertSHIrradianceToLambertianRadiance(harmonics: any): void {\r\n EnvironmentDeserializer._ScaleSH(harmonics, 1 / Math.PI);\r\n // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied\r\n // (The pixel shader must apply albedo after texture fetches, etc).\r\n }\r\n\r\n /**\r\n * Convert spherical harmonics to spherical polynomial coefficients\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result\r\n */\r\n private static _ConvertSHToSP(harmonics: any, outPolynomialCoefficents: SphericalPolynomalCoefficients) {\r\n const rPi = 1 / Math.PI;\r\n\r\n //x\r\n outPolynomialCoefficents.x.x = 1.02333 * harmonics.l11[0] * rPi;\r\n outPolynomialCoefficents.x.y = 1.02333 * harmonics.l11[1] * rPi;\r\n outPolynomialCoefficents.x.z = 1.02333 * harmonics.l11[2] * rPi;\r\n\r\n outPolynomialCoefficents.y.x = 1.02333 * harmonics.l1_1[0] * rPi;\r\n outPolynomialCoefficents.y.y = 1.02333 * harmonics.l1_1[1] * rPi;\r\n outPolynomialCoefficents.y.z = 1.02333 * harmonics.l1_1[2] * rPi;\r\n\r\n outPolynomialCoefficents.z.x = 1.02333 * harmonics.l10[0] * rPi;\r\n outPolynomialCoefficents.z.y = 1.02333 * harmonics.l10[1] * rPi;\r\n outPolynomialCoefficents.z.z = 1.02333 * harmonics.l10[2] * rPi;\r\n\r\n //xx\r\n outPolynomialCoefficents.xx.x = (0.886277 * harmonics.l00[0] - 0.247708 * harmonics.l20[0] + 0.429043 * harmonics.l22[0]) * rPi;\r\n outPolynomialCoefficents.xx.y = (0.886277 * harmonics.l00[1] - 0.247708 * harmonics.l20[1] + 0.429043 * harmonics.l22[1]) * rPi;\r\n outPolynomialCoefficents.xx.z = (0.886277 * harmonics.l00[2] - 0.247708 * harmonics.l20[2] + 0.429043 * harmonics.l22[2]) * rPi;\r\n\r\n outPolynomialCoefficents.yy.x = (0.886277 * harmonics.l00[0] - 0.247708 * harmonics.l20[0] - 0.429043 * harmonics.l22[0]) * rPi;\r\n outPolynomialCoefficents.yy.y = (0.886277 * harmonics.l00[1] - 0.247708 * harmonics.l20[1] - 0.429043 * harmonics.l22[1]) * rPi;\r\n outPolynomialCoefficents.yy.z = (0.886277 * harmonics.l00[2] - 0.247708 * harmonics.l20[2] - 0.429043 * harmonics.l22[2]) * rPi;\r\n\r\n outPolynomialCoefficents.zz.x = (0.886277 * harmonics.l00[0] + 0.495417 * harmonics.l20[0]) * rPi;\r\n outPolynomialCoefficents.zz.y = (0.886277 * harmonics.l00[1] + 0.495417 * harmonics.l20[1]) * rPi;\r\n outPolynomialCoefficents.zz.z = (0.886277 * harmonics.l00[2] + 0.495417 * harmonics.l20[2]) * rPi;\r\n\r\n //yz\r\n outPolynomialCoefficents.yz.x = 0.858086 * harmonics.l2_1[0] * rPi;\r\n outPolynomialCoefficents.yz.y = 0.858086 * harmonics.l2_1[1] * rPi;\r\n outPolynomialCoefficents.yz.z = 0.858086 * harmonics.l2_1[2] * rPi;\r\n\r\n outPolynomialCoefficents.zx.x = 0.858086 * harmonics.l21[0] * rPi;\r\n outPolynomialCoefficents.zx.y = 0.858086 * harmonics.l21[1] * rPi;\r\n outPolynomialCoefficents.zx.z = 0.858086 * harmonics.l21[2] * rPi;\r\n\r\n outPolynomialCoefficents.xy.x = 0.858086 * harmonics.l2_2[0] * rPi;\r\n outPolynomialCoefficents.xy.y = 0.858086 * harmonics.l2_2[1] * rPi;\r\n outPolynomialCoefficents.xy.z = 0.858086 * harmonics.l2_2[2] * rPi;\r\n }\r\n\r\n /**\r\n * Multiplies harmonic coefficients in place\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n * @param scaleFactor Value to multiply by\r\n */\r\n private static _ScaleSH(harmonics: any, scaleFactor: number) {\r\n harmonics.l00[0] *= scaleFactor;\r\n harmonics.l00[1] *= scaleFactor;\r\n harmonics.l00[2] *= scaleFactor;\r\n harmonics.l1_1[0] *= scaleFactor;\r\n harmonics.l1_1[1] *= scaleFactor;\r\n harmonics.l1_1[2] *= scaleFactor;\r\n harmonics.l10[0] *= scaleFactor;\r\n harmonics.l10[1] *= scaleFactor;\r\n harmonics.l10[2] *= scaleFactor;\r\n harmonics.l11[0] *= scaleFactor;\r\n harmonics.l11[1] *= scaleFactor;\r\n harmonics.l11[2] *= scaleFactor;\r\n harmonics.l2_2[0] *= scaleFactor;\r\n harmonics.l2_2[1] *= scaleFactor;\r\n harmonics.l2_2[2] *= scaleFactor;\r\n harmonics.l2_1[0] *= scaleFactor;\r\n harmonics.l2_1[1] *= scaleFactor;\r\n harmonics.l2_1[2] *= scaleFactor;\r\n harmonics.l20[0] *= scaleFactor;\r\n harmonics.l20[1] *= scaleFactor;\r\n harmonics.l20[2] *= scaleFactor;\r\n harmonics.l21[0] *= scaleFactor;\r\n harmonics.l21[1] *= scaleFactor;\r\n harmonics.l21[2] *= scaleFactor;\r\n harmonics.l22[0] *= scaleFactor;\r\n harmonics.l22[1] *= scaleFactor;\r\n harmonics.l22[2] *= scaleFactor;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"environmentSerializer.js","sourceRoot":"","sources":["../../../../../tools/viewer/src/labs/environmentSerializer.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE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CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;IACpC,CAAC;IACL,8BAAC;AAAD,CAAC,AArND,IAqNC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Vector3 } from \"core/Maths/math\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { TextureCube, PixelFormat, PixelType } from \"./texture\";\r\n\r\n/**\r\n * Spherical polynomial coefficients (counter part to spherical harmonic coefficients used in shader irradiance calculation)\r\n * @ignoreChildren\r\n */\r\nexport interface SphericalPolynomalCoefficients {\r\n x: Vector3;\r\n y: Vector3;\r\n z: Vector3;\r\n xx: Vector3;\r\n yy: Vector3;\r\n zz: Vector3;\r\n yz: Vector3;\r\n zx: Vector3;\r\n xy: Vector3;\r\n}\r\n\r\n/**\r\n * Wraps data and maps required for environments with physically based rendering\r\n */\r\nexport interface PBREnvironment {\r\n /**\r\n * Spherical Polynomial Coefficients representing an irradiance map\r\n */\r\n irradiancePolynomialCoefficients: SphericalPolynomalCoefficients;\r\n\r\n /**\r\n * Specular cubemap\r\n */\r\n specularTexture?: TextureCube;\r\n /**\r\n * A scale factor applied to RGB values after reading from environment maps\r\n */\r\n textureIntensityScale: number;\r\n}\r\n\r\n/**\r\n * Environment map representations: layouts, projections and approximations\r\n */\r\nexport type MapType = \"irradiance_sh_coefficients_9\" | \"cubemap_faces\";\r\n\r\n/**\r\n * Image type used for environment map\r\n */\r\nexport type ImageType = \"png\";\r\n\r\n//Payload Descriptor\r\n\r\n/**\r\n * A generic field in JSON that report's its type\r\n */\r\nexport interface TypedObject<T> {\r\n type: T;\r\n}\r\n\r\n/**\r\n * Describes a range of bytes starting at byte pos (inclusive) and finishing at byte pos + length - 1\r\n */\r\nexport interface ByteRange {\r\n pos: number;\r\n length: number;\r\n}\r\n\r\n/**\r\n * Complete Spectre Environment JSON Descriptor\r\n */\r\nexport interface EnvJsonDescriptor {\r\n radiance: TypedObject<MapType>;\r\n irradiance: TypedObject<MapType>;\r\n specular: TypedObject<MapType>;\r\n}\r\n\r\n/**\r\n * Spherical harmonic coefficients to provide an irradiance map\r\n */\r\nexport interface IrradianceSHCoefficients9 extends TypedObject<MapType> {\r\n l00: Array<number>;\r\n\r\n l1_1: Array<number>;\r\n l10: Array<number>;\r\n l11: Array<number>;\r\n\r\n l2_2: Array<number>;\r\n l2_1: Array<number>;\r\n l20: Array<number>;\r\n l21: Array<number>;\r\n l22: Array<number>;\r\n}\r\n\r\n/**\r\n * A generic set of images, where the image content is specified by byte ranges in the mipmaps field\r\n */\r\nexport interface ImageSet<T> extends TypedObject<MapType> {\r\n imageType: ImageType;\r\n width: number;\r\n height: number;\r\n mipmaps: Array<T>;\r\n multiplier: number;\r\n}\r\n\r\n/**\r\n * A set of cubemap faces\r\n */\r\nexport type CubemapFaces = ImageSet<Array<ByteRange>>;\r\n\r\n/**\r\n * A single image containing an atlas of equirectangular-projection maps across all mip levels\r\n */\r\nexport type EquirectangularMipmapAtlas = ImageSet<ByteRange>;\r\n\r\n/**\r\n * A static class proving methods to aid parsing Spectre environment files\r\n */\r\nexport class EnvironmentDeserializer {\r\n /**\r\n * Parses an arraybuffer into a new PBREnvironment object\r\n * @param arrayBuffer The arraybuffer of the Spectre environment file\r\n * @return a PBREnvironment object\r\n */\r\n public static Parse(arrayBuffer: ArrayBuffer): PBREnvironment {\r\n const environment: PBREnvironment = {\r\n //irradiance\r\n irradiancePolynomialCoefficients: {\r\n x: new Vector3(0, 0, 0),\r\n y: new Vector3(0, 0, 0),\r\n z: new Vector3(0, 0, 0),\r\n xx: new Vector3(0, 0, 0),\r\n yy: new Vector3(0, 0, 0),\r\n zz: new Vector3(0, 0, 0),\r\n yz: new Vector3(0, 0, 0),\r\n zx: new Vector3(0, 0, 0),\r\n xy: new Vector3(0, 0, 0),\r\n },\r\n\r\n //specular\r\n textureIntensityScale: 1.0,\r\n };\r\n\r\n //read .env\r\n const littleEndian = false;\r\n\r\n const magicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\r\n\r\n const dataView = new DataView(arrayBuffer);\r\n let pos = 0;\r\n\r\n for (let i = 0; i < magicBytes.length; i++) {\r\n if (dataView.getUint8(pos++) !== magicBytes[i]) {\r\n Tools.Error(\"Not a Spectre environment map\");\r\n }\r\n }\r\n\r\n const version = dataView.getUint16(pos, littleEndian);\r\n pos += 2;\r\n\r\n if (version !== 1) {\r\n Tools.Warn('Unsupported Spectre environment map version \"' + version + '\"');\r\n }\r\n\r\n //read json descriptor - collect characters up to null terminator\r\n let descriptorString = \"\";\r\n let charCode = 0x00;\r\n while ((charCode = dataView.getUint8(pos++))) {\r\n descriptorString += String.fromCharCode(charCode);\r\n }\r\n\r\n const descriptor: EnvJsonDescriptor = JSON.parse(descriptorString);\r\n\r\n const payloadPos = pos;\r\n\r\n //irradiance\r\n switch (descriptor.irradiance.type) {\r\n case \"irradiance_sh_coefficients_9\": {\r\n //irradiance\r\n const harmonics = <IrradianceSHCoefficients9>descriptor.irradiance;\r\n\r\n EnvironmentDeserializer._ConvertSHIrradianceToLambertianRadiance(harmonics);\r\n\r\n //harmonics now represent radiance\r\n EnvironmentDeserializer._ConvertSHToSP(harmonics, environment.irradiancePolynomialCoefficients);\r\n break;\r\n }\r\n default:\r\n Tools.Error(\"Unhandled MapType descriptor.irradiance.type (\" + descriptor.irradiance.type + \")\");\r\n }\r\n\r\n //specular\r\n switch (descriptor.specular.type) {\r\n case \"cubemap_faces\": {\r\n const specularDescriptor = <CubemapFaces>descriptor.specular;\r\n\r\n const specularTexture = (environment.specularTexture = new TextureCube(PixelFormat.RGBA, PixelType.UNSIGNED_BYTE));\r\n environment.textureIntensityScale = specularDescriptor.multiplier != null ? specularDescriptor.multiplier : 1.0;\r\n\r\n const mipmaps = specularDescriptor.mipmaps;\r\n const imageType = specularDescriptor.imageType;\r\n\r\n for (let l = 0; l < mipmaps.length; l++) {\r\n const faceRanges = mipmaps[l];\r\n\r\n specularTexture.source[l] = [];\r\n\r\n for (let i = 0; i < 6; i++) {\r\n const range = faceRanges[i];\r\n const bytes = new Uint8Array(arrayBuffer, payloadPos + range.pos, range.length);\r\n\r\n switch (imageType) {\r\n case \"png\": {\r\n //construct image element from bytes\r\n const image = new Image();\r\n const src = URL.createObjectURL(new Blob([bytes], { type: \"image/png\" }));\r\n image.src = src;\r\n specularTexture.source[l][i] = image;\r\n\r\n break;\r\n }\r\n default:\r\n Tools.Error(\"Unhandled ImageType descriptor.specular.imageType (\" + imageType + \")\");\r\n }\r\n }\r\n }\r\n\r\n break;\r\n }\r\n default:\r\n Tools.Error(\"Unhandled MapType descriptor.specular.type (\" + descriptor.specular.type + \")\");\r\n }\r\n\r\n return environment;\r\n }\r\n\r\n /**\r\n * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.\r\n *\t L = (1/pi) * E * rho\r\n *\r\n * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n */\r\n private static _ConvertSHIrradianceToLambertianRadiance(harmonics: any): void {\r\n EnvironmentDeserializer._ScaleSH(harmonics, 1 / Math.PI);\r\n // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied\r\n // (The pixel shader must apply albedo after texture fetches, etc).\r\n }\r\n\r\n /**\r\n * Convert spherical harmonics to spherical polynomial coefficients\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result\r\n */\r\n private static _ConvertSHToSP(harmonics: any, outPolynomialCoefficents: SphericalPolynomalCoefficients) {\r\n const rPi = 1 / Math.PI;\r\n\r\n //x\r\n outPolynomialCoefficents.x.x = 1.02333 * harmonics.l11[0] * rPi;\r\n outPolynomialCoefficents.x.y = 1.02333 * harmonics.l11[1] * rPi;\r\n outPolynomialCoefficents.x.z = 1.02333 * harmonics.l11[2] * rPi;\r\n\r\n outPolynomialCoefficents.y.x = 1.02333 * harmonics.l1_1[0] * rPi;\r\n outPolynomialCoefficents.y.y = 1.02333 * harmonics.l1_1[1] * rPi;\r\n outPolynomialCoefficents.y.z = 1.02333 * harmonics.l1_1[2] * rPi;\r\n\r\n outPolynomialCoefficents.z.x = 1.02333 * harmonics.l10[0] * rPi;\r\n outPolynomialCoefficents.z.y = 1.02333 * harmonics.l10[1] * rPi;\r\n outPolynomialCoefficents.z.z = 1.02333 * harmonics.l10[2] * rPi;\r\n\r\n //xx\r\n outPolynomialCoefficents.xx.x = (0.886277 * harmonics.l00[0] - 0.247708 * harmonics.l20[0] + 0.429043 * harmonics.l22[0]) * rPi;\r\n outPolynomialCoefficents.xx.y = (0.886277 * harmonics.l00[1] - 0.247708 * harmonics.l20[1] + 0.429043 * harmonics.l22[1]) * rPi;\r\n outPolynomialCoefficents.xx.z = (0.886277 * harmonics.l00[2] - 0.247708 * harmonics.l20[2] + 0.429043 * harmonics.l22[2]) * rPi;\r\n\r\n outPolynomialCoefficents.yy.x = (0.886277 * harmonics.l00[0] - 0.247708 * harmonics.l20[0] - 0.429043 * harmonics.l22[0]) * rPi;\r\n outPolynomialCoefficents.yy.y = (0.886277 * harmonics.l00[1] - 0.247708 * harmonics.l20[1] - 0.429043 * harmonics.l22[1]) * rPi;\r\n outPolynomialCoefficents.yy.z = (0.886277 * harmonics.l00[2] - 0.247708 * harmonics.l20[2] - 0.429043 * harmonics.l22[2]) * rPi;\r\n\r\n outPolynomialCoefficents.zz.x = (0.886277 * harmonics.l00[0] + 0.495417 * harmonics.l20[0]) * rPi;\r\n outPolynomialCoefficents.zz.y = (0.886277 * harmonics.l00[1] + 0.495417 * harmonics.l20[1]) * rPi;\r\n outPolynomialCoefficents.zz.z = (0.886277 * harmonics.l00[2] + 0.495417 * harmonics.l20[2]) * rPi;\r\n\r\n //yz\r\n outPolynomialCoefficents.yz.x = 0.858086 * harmonics.l2_1[0] * rPi;\r\n outPolynomialCoefficents.yz.y = 0.858086 * harmonics.l2_1[1] * rPi;\r\n outPolynomialCoefficents.yz.z = 0.858086 * harmonics.l2_1[2] * rPi;\r\n\r\n outPolynomialCoefficents.zx.x = 0.858086 * harmonics.l21[0] * rPi;\r\n outPolynomialCoefficents.zx.y = 0.858086 * harmonics.l21[1] * rPi;\r\n outPolynomialCoefficents.zx.z = 0.858086 * harmonics.l21[2] * rPi;\r\n\r\n outPolynomialCoefficents.xy.x = 0.858086 * harmonics.l2_2[0] * rPi;\r\n outPolynomialCoefficents.xy.y = 0.858086 * harmonics.l2_2[1] * rPi;\r\n outPolynomialCoefficents.xy.z = 0.858086 * harmonics.l2_2[2] * rPi;\r\n }\r\n\r\n /**\r\n * Multiplies harmonic coefficients in place\r\n * @param harmonics Spherical harmonic coefficients (9)\r\n * @param scaleFactor Value to multiply by\r\n */\r\n private static _ScaleSH(harmonics: any, scaleFactor: number) {\r\n harmonics.l00[0] *= scaleFactor;\r\n harmonics.l00[1] *= scaleFactor;\r\n harmonics.l00[2] *= scaleFactor;\r\n harmonics.l1_1[0] *= scaleFactor;\r\n harmonics.l1_1[1] *= scaleFactor;\r\n harmonics.l1_1[2] *= scaleFactor;\r\n harmonics.l10[0] *= scaleFactor;\r\n harmonics.l10[1] *= scaleFactor;\r\n harmonics.l10[2] *= scaleFactor;\r\n harmonics.l11[0] *= scaleFactor;\r\n harmonics.l11[1] *= scaleFactor;\r\n harmonics.l11[2] *= scaleFactor;\r\n harmonics.l2_2[0] *= scaleFactor;\r\n harmonics.l2_2[1] *= scaleFactor;\r\n harmonics.l2_2[2] *= scaleFactor;\r\n harmonics.l2_1[0] *= scaleFactor;\r\n harmonics.l2_1[1] *= scaleFactor;\r\n harmonics.l2_1[2] *= scaleFactor;\r\n harmonics.l20[0] *= scaleFactor;\r\n harmonics.l20[1] *= scaleFactor;\r\n harmonics.l20[2] *= scaleFactor;\r\n harmonics.l21[0] *= scaleFactor;\r\n harmonics.l21[1] *= scaleFactor;\r\n harmonics.l21[2] *= scaleFactor;\r\n harmonics.l22[0] *= scaleFactor;\r\n harmonics.l22[1] *= scaleFactor;\r\n harmonics.l22[2] *= scaleFactor;\r\n }\r\n}\r\n"]}
|
package/labs/texture.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Scene } from "@babylonjs/core/scene";
|
|
2
|
-
import { CubeTexture } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
3
|
-
import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture";
|
|
1
|
+
import type { Scene } from "@babylonjs/core/scene.js";
|
|
2
|
+
import { CubeTexture } from "@babylonjs/core/Materials/Textures/cubeTexture.js";
|
|
3
|
+
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
|
4
4
|
/**
|
|
5
5
|
* WebGL Pixel Formats
|
|
6
6
|
*/
|
|
@@ -93,8 +93,8 @@ export interface SamplingParameters {
|
|
|
93
93
|
*/
|
|
94
94
|
wrapT?: TextureWrapMode;
|
|
95
95
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
* Anisotropic filtering samples
|
|
97
|
+
*/
|
|
98
98
|
maxAnisotropy?: number;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
@@ -141,8 +141,8 @@ export declare class TextureCube {
|
|
|
141
141
|
constructor(internalFormat: PixelFormat, type: PixelType, source?: MipmapsCube);
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
* A static class providing methods to aid working with Bablyon textures.
|
|
145
|
+
*/
|
|
146
146
|
export declare class TextureUtils {
|
|
147
147
|
/**
|
|
148
148
|
* A prefix used when storing a babylon texture object reference on a Spectre texture object
|
|
@@ -158,7 +158,6 @@ export declare class TextureUtils {
|
|
|
158
158
|
* The advantage of this is to enable working with texture objects without the need to initialize on the GPU until desired.
|
|
159
159
|
* @param scene A Babylon Scene instance
|
|
160
160
|
* @param textureCube A Spectre TextureCube object
|
|
161
|
-
* @param parameters WebGL texture sampling parameters
|
|
162
161
|
* @param automaticMipmaps Pass true to enable automatic mipmap generation where possible (requires power of images)
|
|
163
162
|
* @param environment Specifies that the texture will be used as an environment
|
|
164
163
|
* @param singleLod Specifies that the texture will be a singleLod (for environment)
|