@babylonjs/core 7.53.2 → 7.53.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AudioV2/abstractAudio/abstractSound.d.ts +1 -1
- package/AudioV2/abstractAudio/abstractSound.js +12 -12
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +15 -8
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +23 -11
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -1
- package/AudioV2/abstractAudio/staticSound.js +8 -0
- package/AudioV2/abstractAudio/staticSound.js.map +1 -1
- package/AudioV2/abstractAudio/staticSoundInstance.d.ts +2 -0
- package/AudioV2/abstractAudio/staticSoundInstance.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +4 -4
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +3 -3
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +23 -16
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +3 -3
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +13 -6
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +13 -8
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +18 -14
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +10 -6
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +7 -3
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +5 -5
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +9 -9
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +4 -4
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +4 -0
- package/AudioV2/webAudio/webAudioStaticSound.js +14 -0
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/Engines/abstractEngine.js +2 -3
- package/Engines/abstractEngine.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/Lights/IES/iesLoader.d.ts +1 -1
- package/Lights/IES/iesLoader.js +1 -1
- package/Lights/IES/iesLoader.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +2 -2
- package/Lights/Shadows/shadowGenerator.js +2 -2
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/spotLight.d.ts +1 -1
- package/Lights/spotLight.js +1 -1
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +2 -2
- package/Materials/PBR/pbrBaseMaterial.js +2 -2
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Loaders/basisTextureLoader.d.ts +1 -0
- package/Materials/Textures/Loaders/basisTextureLoader.js +1 -0
- package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/exrTextureLoader.d.ts +5 -4
- package/Materials/Textures/Loaders/exrTextureLoader.js +5 -4
- package/Materials/Textures/Loaders/exrTextureLoader.js.map +1 -1
- package/Maths/math.scalar.d.ts +1 -0
- package/Maths/math.scalar.functions.d.ts +9 -0
- package/Maths/math.scalar.functions.js +11 -0
- package/Maths/math.scalar.functions.js.map +1 -1
- package/Meshes/Node/Blocks/geometryEaseBlock.d.ts +96 -0
- package/Meshes/Node/Blocks/geometryEaseBlock.js +318 -0
- package/Meshes/Node/Blocks/geometryEaseBlock.js.map +1 -0
- package/Meshes/Node/index.d.ts +1 -0
- package/Meshes/Node/index.js +1 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/csg2.d.ts +3 -3
- package/Meshes/csg2.js +3 -3
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/lattice.d.ts +2 -2
- package/Meshes/lattice.js +5 -4
- package/Meshes/lattice.js.map +1 -1
- package/Meshes/lattice.material.d.ts +2 -2
- package/Meshes/lattice.material.js +2 -2
- package/Meshes/lattice.material.js.map +1 -1
- package/Meshes/mesh.d.ts +2 -2
- package/Meshes/mesh.js +2 -2
- package/Meshes/mesh.js.map +1 -1
- package/Misc/fileTools.d.ts +1 -1
- package/Misc/fileTools.js +1 -1
- package/Misc/fileTools.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +4 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +11 -16
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +6 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +7 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import type { InternalTexture } from "../../../Materials/Textures/internalTextur
|
|
|
3
3
|
import type { IInternalTextureLoader } from "./internalTextureLoader";
|
|
4
4
|
/**
|
|
5
5
|
* Loader for .basis file format
|
|
6
|
+
* @internal
|
|
6
7
|
*/
|
|
7
8
|
export declare class _BasisTextureLoader implements IInternalTextureLoader {
|
|
8
9
|
/**
|
|
@@ -2,6 +2,7 @@ import { LoadTextureFromTranscodeResult, TranscodeAsync } from "../../../Misc/ba
|
|
|
2
2
|
import { Tools } from "../../../Misc/tools.js";
|
|
3
3
|
/**
|
|
4
4
|
* Loader for .basis file format
|
|
5
|
+
* @internal
|
|
5
6
|
*/
|
|
6
7
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
8
|
export class _BasisTextureLoader {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basisTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/basisTextureLoader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,8BAA8B,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"basisTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/basisTextureLoader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,8BAA8B,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,mBAAmB;IAAhC;QACI;;WAEG;QACa,oBAAe,GAAG,KAAK,CAAC;IAyF5C,CAAC;IAvFG;;;;;;;OAOG;IACI,YAAY,CACf,IAAyC,EACzC,OAAwB,EACxB,iBAA0B,EAC1B,MAAsC,EACtC,OAA8D;QAE9D,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,OAAO;QACX,CAAC;QACD,MAAM,IAAI,GAAG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M,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,eAAe,CAAC;YACzF,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE;gBAC9E,8BAA8B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,KAAK,CAAC,IAAI,CAAC,iFAAiF,CAAC,CAAC;YAC9F,KAAK,CAAC,IAAI,CAAC,mCAAmC,GAAG,EAAE,CAAC,CAAC;YACrD,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACX,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\r\nimport type { InternalTexture } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IInternalTextureLoader } from \"./internalTextureLoader\";\r\nimport { LoadTextureFromTranscodeResult, TranscodeAsync } from \"../../../Misc/basis\";\r\nimport { Tools } from \"../../../Misc/tools\";\r\n\r\n/**\r\n * Loader for .basis file format\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class _BasisTextureLoader implements IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n public readonly supportCascades = false;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param createPolynomials will be true if polynomials have been requested\r\n * @param onLoad defines the callback to trigger once the texture is ready\r\n * @param onError defines the callback to trigger in case of error\r\n */\r\n public loadCubeData(\r\n data: ArrayBufferView | ArrayBufferView[],\r\n texture: InternalTexture,\r\n createPolynomials: boolean,\r\n onLoad: Nullable<(data?: any) => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>\r\n ): void {\r\n if (Array.isArray(data)) {\r\n return;\r\n }\r\n const caps = texture.getEngine().getCaps();\r\n const transcodeConfig = {\r\n supportedCompressionFormats: {\r\n etc1: caps.etc1 ? true : false,\r\n s3tc: caps.s3tc ? true : false,\r\n pvrtc: caps.pvrtc ? true : false,\r\n etc2: caps.etc2 ? true : false,\r\n astc: caps.astc ? true : false,\r\n bc7: caps.bptc ? true : false,\r\n },\r\n };\r\n TranscodeAsync(data, transcodeConfig)\r\n .then((result) => {\r\n const hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;\r\n LoadTextureFromTranscodeResult(texture, result);\r\n texture.getEngine()._setCubeMapTextureParams(texture, hasMipmap);\r\n texture.isReady = true;\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n })\r\n .catch((err) => {\r\n const errorMessage = \"Failed to transcode Basis file, transcoding may not be supported on this device\";\r\n Tools.Warn(errorMessage);\r\n texture.isReady = true;\r\n if (onError) {\r\n onError(err);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n */\r\n public loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, failedLoading?: boolean) => void\r\n ): void {\r\n const caps = texture.getEngine().getCaps();\r\n const transcodeConfig = {\r\n supportedCompressionFormats: {\r\n etc1: caps.etc1 ? true : false,\r\n s3tc: caps.s3tc ? true : false,\r\n pvrtc: caps.pvrtc ? true : false,\r\n etc2: caps.etc2 ? true : false,\r\n astc: caps.astc ? true : false,\r\n bc7: caps.bptc ? true : false,\r\n },\r\n };\r\n TranscodeAsync(data, transcodeConfig)\r\n .then((result) => {\r\n const rootImage = result.fileInfo.images[0].levels[0];\r\n const hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;\r\n callback(rootImage.width, rootImage.height, hasMipmap, result.format !== -1, () => {\r\n LoadTextureFromTranscodeResult(texture, result);\r\n });\r\n })\r\n .catch((err) => {\r\n Tools.Warn(\"Failed to transcode Basis file, transcoding may not be supported on this device\");\r\n Tools.Warn(`Failed to transcode Basis file: ${err}`);\r\n callback(0, 0, false, false, () => {}, true);\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -8,10 +8,11 @@ import type { IInternalTextureLoader } from "./internalTextureLoader";
|
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Loader for .exr file format
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* @see [PIZ compression](https://playground.babylonjs.com/#4RN0VF#151)
|
|
12
|
+
* @see [ZIP compression](https://playground.babylonjs.com/#4RN0VF#146)
|
|
13
|
+
* @see [RLE compression](https://playground.babylonjs.com/#4RN0VF#149)
|
|
14
|
+
* @see [PXR24 compression](https://playground.babylonjs.com/#4RN0VF#150)
|
|
15
|
+
* @internal
|
|
15
16
|
*/
|
|
16
17
|
export declare class _ExrTextureLoader implements IInternalTextureLoader {
|
|
17
18
|
/**
|
|
@@ -67,10 +67,11 @@ import { ExrLoaderGlobalConfiguration } from "./EXR/exrLoader.configuration.js";
|
|
|
67
67
|
// // End of OpenEXR license -------------------------------------------------
|
|
68
68
|
/**
|
|
69
69
|
* Loader for .exr file format
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
70
|
+
* @see [PIZ compression](https://playground.babylonjs.com/#4RN0VF#151)
|
|
71
|
+
* @see [ZIP compression](https://playground.babylonjs.com/#4RN0VF#146)
|
|
72
|
+
* @see [RLE compression](https://playground.babylonjs.com/#4RN0VF#149)
|
|
73
|
+
* @see [PXR24 compression](https://playground.babylonjs.com/#4RN0VF#150)
|
|
74
|
+
* @internal
|
|
74
75
|
*/
|
|
75
76
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
76
77
|
export class _ExrTextureLoader {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exrTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/exrTextureLoader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAE7E;;;;GAIG;AAEH,KAAK;AACL,0CAA0C;AAC1C,uBAAuB;AAEvB,qEAAqE;AACrE,8EAA8E;AAC9E,uEAAuE;AACvE,sEAAsE;AACtE,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,qDAAqD;AACrD,6EAA6E;AAC7E,8EAA8E;AAE9E,kFAAkF;AAClF,gFAAgF;AAChF,yEAAyE;AACzE,qEAAqE;AACrE,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,6EAA6E;AAC7E,gFAAgF;AAChF,+DAA+D;AAC/D,KAAK;AAEL,8EAA8E;AAE9E,8EAA8E;AAC9E,KAAK;AACL,uEAAuE;AACvE,sBAAsB;AACtB,KAAK;AACL,0BAA0B;AAC1B,KAAK;AACL,wEAAwE;AACxE,4EAA4E;AAC5E,UAAU;AACV,4EAA4E;AAC5E,mEAAmE;AACnE,qEAAqE;AACrE,4EAA4E;AAC5E,mEAAmE;AACnE,mBAAmB;AACnB,2EAA2E;AAC3E,yEAAyE;AACzE,mEAAmE;AACnE,KAAK;AACL,yEAAyE;AACzE,uEAAuE;AACvE,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E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AAO,CAAC,SAAS,EAAE,CAAC;YACnC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;YAC/B,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC;YACnC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;YACxB,OAAO,CAAC,WAAW,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC;YAC1C,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;gBACpB,MAAM,CAAC,4BAA4B,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;YAC3F,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { InternalTexture } from \"../internalTexture\";\r\nimport type { IInternalTextureLoader } from \"./internalTextureLoader\";\r\nimport { GetExrHeader } from \"./EXR/exrLoader.header\";\r\nimport { CreateDecoderAsync, ScanData } from \"./EXR/exrLoader.decoder\";\r\nimport { ExrLoaderGlobalConfiguration } from \"./EXR/exrLoader.configuration\";\r\n\r\n/**\r\n * Inspired by https://github.com/sciecode/three.js/blob/dev/examples/jsm/loaders/EXRLoader.js\r\n * Referred to the original Industrial Light & Magic OpenEXR implementation and the TinyEXR / Syoyo Fujita\r\n * implementation.\r\n */\r\n\r\n// /*\r\n// Copyright (c) 2014 - 2017, Syoyo Fujita\r\n// All rights reserved.\r\n\r\n// Redistribution and use in source and binary forms, with or without\r\n// modification, are permitted provided that the following conditions are met:\r\n// * Redistributions of source code must retain the above copyright\r\n// notice, this list of conditions and the following disclaimer.\r\n// * Redistributions in binary form must reproduce the above copyright\r\n// notice, this list of conditions and the following disclaimer in the\r\n// documentation and/or other materials provided with the distribution.\r\n// * Neither the name of the Syoyo Fujita nor the\r\n// names of its contributors may be used to endorse or promote products\r\n// derived from this software without specific prior written permission.\r\n\r\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\n// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\n// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\n// DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\r\n// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\n// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r\n// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\n// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n// */\r\n\r\n// // TinyEXR contains some OpenEXR code, which is licensed under ------------\r\n\r\n// ///////////////////////////////////////////////////////////////////////////\r\n// //\r\n// // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas\r\n// // Digital Ltd. LLC\r\n// //\r\n// // All rights reserved.\r\n// //\r\n// // Redistribution and use in source and binary forms, with or without\r\n// // modification, are permitted provided that the following conditions are\r\n// // met:\r\n// // * Redistributions of source code must retain the above copyright\r\n// // notice, this list of conditions and the following disclaimer.\r\n// // * Redistributions in binary form must reproduce the above\r\n// // copyright notice, this list of conditions and the following disclaimer\r\n// // in the documentation and/or other materials provided with the\r\n// // distribution.\r\n// // * Neither the name of Industrial Light & Magic nor the names of\r\n// // its contributors may be used to endorse or promote products derived\r\n// // from this software without specific prior written permission.\r\n// //\r\n// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n// // \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\n// // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\n// // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\n// // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\n// // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\n// // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\n// // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\n// // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n// // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\n// // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n// //\r\n// ///////////////////////////////////////////////////////////////////////////\r\n\r\n// // End of OpenEXR license -------------------------------------------------\r\n\r\n/**\r\n * Loader for .exr file format\r\n * #4RN0VF#151: PIZ compression\r\n * #4RN0VF#146: ZIP compression\r\n * #4RN0VF#149: RLE compression\r\n * #4RN0VF#150: PXR24 compression\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class _ExrTextureLoader implements IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n public readonly supportCascades = false;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n * @param _data contains the texture data\r\n * @param _texture defines the BabylonJS internal texture\r\n * @param _createPolynomials will be true if polynomials have been requested\r\n * @param _onLoad defines the callback to trigger once the texture is ready\r\n * @param _onError defines the callback to trigger in case of error\r\n * Cube texture are not supported by .exr files\r\n */\r\n public loadCubeData(\r\n _data: ArrayBufferView | ArrayBufferView[],\r\n _texture: InternalTexture,\r\n _createPolynomials: boolean,\r\n _onLoad: Nullable<(data?: any) => void>,\r\n _onError: Nullable<(message?: string, exception?: any) => void>\r\n ): void {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \".exr not supported in Cube.\";\r\n }\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n */\r\n public async loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, failedLoading?: boolean) => void\r\n ) {\r\n const dataView = new DataView(data.buffer);\r\n\r\n const offset = { value: 0 };\r\n const header = GetExrHeader(dataView, offset);\r\n const decoder = await CreateDecoderAsync(header, dataView, offset, ExrLoaderGlobalConfiguration.DefaultOutputType);\r\n\r\n ScanData(decoder, header, dataView, offset);\r\n\r\n // Updating texture\r\n const width = header.dataWindow.xMax - header.dataWindow.xMin + 1;\r\n const height = header.dataWindow.yMax - header.dataWindow.yMin + 1;\r\n callback(width, height, texture.generateMipMaps, false, () => {\r\n const engine = texture.getEngine();\r\n texture.format = header.format;\r\n texture.type = decoder.textureType;\r\n texture.invertY = false;\r\n texture._gammaSpace = !header.linearSpace;\r\n if (decoder.byteArray) {\r\n engine._uploadDataToTextureDirectly(texture, decoder.byteArray, 0, 0, undefined, true);\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"exrTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/exrTextureLoader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAE7E;;;;GAIG;AAEH,KAAK;AACL,0CAA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r\nimport type { IInternalTextureLoader } from \"./internalTextureLoader\";\r\nimport { GetExrHeader } from \"./EXR/exrLoader.header\";\r\nimport { CreateDecoderAsync, ScanData } from \"./EXR/exrLoader.decoder\";\r\nimport { ExrLoaderGlobalConfiguration } from \"./EXR/exrLoader.configuration\";\r\n\r\n/**\r\n * Inspired by https://github.com/sciecode/three.js/blob/dev/examples/jsm/loaders/EXRLoader.js\r\n * Referred to the original Industrial Light & Magic OpenEXR implementation and the TinyEXR / Syoyo Fujita\r\n * implementation.\r\n */\r\n\r\n// /*\r\n// Copyright (c) 2014 - 2017, Syoyo Fujita\r\n// All rights reserved.\r\n\r\n// Redistribution and use in source and binary forms, with or without\r\n// modification, are permitted provided that the following conditions are met:\r\n// * Redistributions of source code must retain the above copyright\r\n// notice, this list of conditions and the following disclaimer.\r\n// * Redistributions in binary form must reproduce the above copyright\r\n// notice, this list of conditions and the following disclaimer in the\r\n// documentation and/or other materials provided with the distribution.\r\n// * Neither the name of the Syoyo Fujita nor the\r\n// names of its contributors may be used to endorse or promote products\r\n// derived from this software without specific prior written permission.\r\n\r\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\n// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\n// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\n// DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY\r\n// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\n// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r\n// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\n// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n// */\r\n\r\n// // TinyEXR contains some OpenEXR code, which is licensed under ------------\r\n\r\n// ///////////////////////////////////////////////////////////////////////////\r\n// //\r\n// // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas\r\n// // Digital Ltd. LLC\r\n// //\r\n// // All rights reserved.\r\n// //\r\n// // Redistribution and use in source and binary forms, with or without\r\n// // modification, are permitted provided that the following conditions are\r\n// // met:\r\n// // * Redistributions of source code must retain the above copyright\r\n// // notice, this list of conditions and the following disclaimer.\r\n// // * Redistributions in binary form must reproduce the above\r\n// // copyright notice, this list of conditions and the following disclaimer\r\n// // in the documentation and/or other materials provided with the\r\n// // distribution.\r\n// // * Neither the name of Industrial Light & Magic nor the names of\r\n// // its contributors may be used to endorse or promote products derived\r\n// // from this software without specific prior written permission.\r\n// //\r\n// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n// // \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\n// // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\n// // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\n// // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\n// // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\n// // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\n// // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\n// // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n// // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\n// // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n// //\r\n// ///////////////////////////////////////////////////////////////////////////\r\n\r\n// // End of OpenEXR license -------------------------------------------------\r\n\r\n/**\r\n * Loader for .exr file format\r\n * @see [PIZ compression](https://playground.babylonjs.com/#4RN0VF#151)\r\n * @see [ZIP compression](https://playground.babylonjs.com/#4RN0VF#146)\r\n * @see [RLE compression](https://playground.babylonjs.com/#4RN0VF#149)\r\n * @see [PXR24 compression](https://playground.babylonjs.com/#4RN0VF#150)\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class _ExrTextureLoader implements IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n public readonly supportCascades = false;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n * @param _data contains the texture data\r\n * @param _texture defines the BabylonJS internal texture\r\n * @param _createPolynomials will be true if polynomials have been requested\r\n * @param _onLoad defines the callback to trigger once the texture is ready\r\n * @param _onError defines the callback to trigger in case of error\r\n * Cube texture are not supported by .exr files\r\n */\r\n public loadCubeData(\r\n _data: ArrayBufferView | ArrayBufferView[],\r\n _texture: InternalTexture,\r\n _createPolynomials: boolean,\r\n _onLoad: Nullable<(data?: any) => void>,\r\n _onError: Nullable<(message?: string, exception?: any) => void>\r\n ): void {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \".exr not supported in Cube.\";\r\n }\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n */\r\n public async loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, failedLoading?: boolean) => void\r\n ) {\r\n const dataView = new DataView(data.buffer);\r\n\r\n const offset = { value: 0 };\r\n const header = GetExrHeader(dataView, offset);\r\n const decoder = await CreateDecoderAsync(header, dataView, offset, ExrLoaderGlobalConfiguration.DefaultOutputType);\r\n\r\n ScanData(decoder, header, dataView, offset);\r\n\r\n // Updating texture\r\n const width = header.dataWindow.xMax - header.dataWindow.xMin + 1;\r\n const height = header.dataWindow.yMax - header.dataWindow.yMin + 1;\r\n callback(width, height, texture.generateMipMaps, false, () => {\r\n const engine = texture.getEngine();\r\n texture.format = header.format;\r\n texture.type = decoder.textureType;\r\n texture.invertY = false;\r\n texture._gammaSpace = !header.linearSpace;\r\n if (decoder.byteArray) {\r\n engine._uploadDataToTextureDirectly(texture, decoder.byteArray, 0, 0, undefined, true);\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
package/Maths/math.scalar.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const Scalar: {
|
|
|
27
27
|
HCF: (a: number, b: number) => number;
|
|
28
28
|
ExtractAsInt(value: number): number;
|
|
29
29
|
WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
|
|
30
|
+
OutsideRange(num: number, min: number, max: number, epsilon?: number): boolean;
|
|
30
31
|
RandomRange(min: number, max: number): number;
|
|
31
32
|
Lerp(start: number, end: number, amount: number): number;
|
|
32
33
|
LerpAngle(start: number, end: number, amount: number): number;
|
|
@@ -12,6 +12,15 @@ export declare function ExtractAsInt(value: number): number;
|
|
|
12
12
|
* @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
|
|
13
13
|
*/
|
|
14
14
|
export declare function WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Boolean : true if the number is outside a range
|
|
17
|
+
* @param num number
|
|
18
|
+
* @param min min value
|
|
19
|
+
* @param max max value
|
|
20
|
+
* @param epsilon (default = Number.EPSILON)
|
|
21
|
+
* @returns true if the number is between min and max values
|
|
22
|
+
*/
|
|
23
|
+
export declare function OutsideRange(num: number, min: number, max: number, epsilon?: number): boolean;
|
|
15
24
|
/**
|
|
16
25
|
* Returns a random float number between and min and max values
|
|
17
26
|
* @param min min value of random
|
|
@@ -16,6 +16,17 @@ export function ExtractAsInt(value) {
|
|
|
16
16
|
export function WithinEpsilon(a, b, epsilon = 1.401298e-45) {
|
|
17
17
|
return Math.abs(a - b) <= epsilon;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Boolean : true if the number is outside a range
|
|
21
|
+
* @param num number
|
|
22
|
+
* @param min min value
|
|
23
|
+
* @param max max value
|
|
24
|
+
* @param epsilon (default = Number.EPSILON)
|
|
25
|
+
* @returns true if the number is between min and max values
|
|
26
|
+
*/
|
|
27
|
+
export function OutsideRange(num, min, max, epsilon = 1.401298e-45) {
|
|
28
|
+
return num < min - epsilon || num > max + epsilon;
|
|
29
|
+
}
|
|
19
30
|
/**
|
|
20
31
|
* Returns a random float number between and min and max values
|
|
21
32
|
* @param min min value of random
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.scalar.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.scalar.functions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,CAAS,EAAE,CAAS,EAAE,UAAkB,YAAY;IAC9E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,GAAW;IAChD,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QACd,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,G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AG,GAAG,CAAC,GAAG,OAAO,GAAG,GAAG,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,CAAS,EAAE,CAAS;IACpD,MAAM,CAAC,GAAW,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACV,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/**\r\n * Extract int value\r\n * @param value number value\r\n * @returns int value\r\n */\r\nexport function ExtractAsInt(value: number) {\r\n return parseInt(value.toString().replace(/\\W/g, \"\"));\r\n}\r\n\r\n/**\r\n * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n * @param a number\r\n * @param b number\r\n * @param epsilon (default = 1.401298E-45)\r\n * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n */\r\nexport function WithinEpsilon(a: number, b: number, epsilon: number = 1.401298e-45): boolean {\r\n return Math.abs(a - b) <= epsilon;\r\n}\r\n\r\n/**\r\n * Returns a random float number between and min and max values\r\n * @param min min value of random\r\n * @param max max value of random\r\n * @returns random value\r\n */\r\nexport function RandomRange(min: number, max: number): number {\r\n if (min === max) {\r\n return min;\r\n }\r\n return Math.random() * (max - min) + min;\r\n}\r\n\r\n/**\r\n * Creates a new scalar with values linearly interpolated of \"amount\" between the start scalar and the end scalar.\r\n * @param start start value\r\n * @param end target value\r\n * @param amount amount to lerp between\r\n * @returns the lerped value\r\n */\r\nexport function Lerp(start: number, end: number, amount: number): number {\r\n return start + (end - start) * amount;\r\n}\r\n\r\n/**\r\n * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.\r\n * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.\r\n * @param start start value\r\n * @param end target value\r\n * @param amount amount to lerp between\r\n * @returns the lerped value\r\n */\r\nexport function LerpAngle(start: number, end: number, amount: number): number {\r\n let num: number = Repeat(end - start, 360.0);\r\n if (num > 180.0) {\r\n num -= 360.0;\r\n }\r\n return start + num * Clamp(amount);\r\n}\r\n\r\n/**\r\n * Calculates the linear parameter t that produces the interpolant value within the range [a, b].\r\n * @param a start value\r\n * @param b target value\r\n * @param value value between a and b\r\n * @returns the inverseLerp value\r\n */\r\nexport function InverseLerp(a: number, b: number, value: number): number {\r\n let result: number = 0;\r\n if (a != b) {\r\n result = Clamp((value - a) / (b - a));\r\n } else {\r\n result = 0.0;\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Returns a new scalar located for \"amount\" (float) on the Hermite spline defined by the scalars \"value1\", \"value3\", \"tangent1\", \"tangent2\".\r\n * @see http://mathworld.wolfram.com/HermitePolynomial.html\r\n * @param value1 defines the first control point\r\n * @param tangent1 defines the first tangent\r\n * @param value2 defines the second control point\r\n * @param tangent2 defines the second tangent\r\n * @param amount defines the amount on the interpolation spline (between 0 and 1)\r\n * @returns hermite result\r\n */\r\nexport function Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number {\r\n const squared = amount * amount;\r\n const cubed = amount * squared;\r\n const part1 = 2.0 * cubed - 3.0 * squared + 1.0;\r\n const part2 = -2.0 * cubed + 3.0 * squared;\r\n const part3 = cubed - 2.0 * squared + amount;\r\n const part4 = cubed - squared;\r\n\r\n return value1 * part1 + value2 * part2 + tangent1 * part3 + tangent2 * part4;\r\n}\r\n\r\n/**\r\n * Returns a new scalar which is the 1st derivative of the Hermite spline defined by the scalars \"value1\", \"value2\", \"tangent1\", \"tangent2\".\r\n * @param value1 defines the first control point\r\n * @param tangent1 defines the first tangent\r\n * @param value2 defines the second control point\r\n * @param tangent2 defines the second tangent\r\n * @param time define where the derivative must be done\r\n * @returns 1st derivative\r\n */\r\nexport function Hermite1stDerivative(value1: number, tangent1: number, value2: number, tangent2: number, time: number): number {\r\n const t2 = time * time;\r\n return (t2 - time) * 6 * value1 + (3 * t2 - 4 * time + 1) * tangent1 + (-t2 + time) * 6 * value2 + (3 * t2 - 2 * time) * tangent2;\r\n}\r\n\r\n/**\r\n * Returns the value itself if it's between min and max.\r\n * Returns min if the value is lower than min.\r\n * Returns max if the value is greater than max.\r\n * @param value the value to clmap\r\n * @param min the min value to clamp to (default: 0)\r\n * @param max the max value to clamp to (default: 1)\r\n * @returns the clamped value\r\n */\r\nexport function Clamp(value: number, min = 0, max = 1): number {\r\n return Math.min(max, Math.max(min, value));\r\n}\r\n\r\n/**\r\n * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.\r\n * @param angle The angle to normalize in radian.\r\n * @returns The converted angle.\r\n */\r\nexport function NormalizeRadians(angle: number): number {\r\n // More precise but slower version kept for reference.\r\n // angle = angle % Tools.TwoPi;\r\n // angle = (angle + Tools.TwoPi) % Tools.TwoPi;\r\n\r\n //if (angle > Math.PI) {\r\n //\tangle -= Tools.TwoPi;\r\n //}\r\n\r\n angle -= Math.PI * 2 * Math.floor((angle + Math.PI) / (Math.PI * 2));\r\n\r\n return angle;\r\n}\r\n\r\n/**\r\n * Returns a string : the upper case translation of the number i to hexadecimal.\r\n * @param i number\r\n * @returns the upper case translation of the number i to hexadecimal.\r\n */\r\nexport function ToHex(i: number): string {\r\n const str = i.toString(16);\r\n\r\n if (i <= 15) {\r\n return (\"0\" + str).toUpperCase();\r\n }\r\n\r\n return str.toUpperCase();\r\n}\r\n\r\n/**\r\n * the floor part of a log2 value.\r\n * @param value the value to compute log2 of\r\n * @returns the log2 of value.\r\n */\r\nexport function ILog2(value: number): number {\r\n if (Math.log2) {\r\n return Math.floor(Math.log2(value));\r\n }\r\n\r\n if (value < 0) {\r\n return NaN;\r\n } else if (value === 0) {\r\n return -Infinity;\r\n }\r\n\r\n let n = 0;\r\n if (value < 1) {\r\n while (value < 1) {\r\n n++;\r\n value = value * 2;\r\n }\r\n n = -n;\r\n } else if (value > 1) {\r\n while (value > 1) {\r\n n++;\r\n value = Math.floor(value / 2);\r\n }\r\n }\r\n\r\n return n;\r\n}\r\n\r\n/**\r\n * Loops the value, so that it is never larger than length and never smaller than 0.\r\n *\r\n * This is similar to the modulo operator but it works with floating point numbers.\r\n * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.\r\n * With t = 5 and length = 2.5, the result would be 0.0.\r\n * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator\r\n * @param value the value\r\n * @param length the length\r\n * @returns the looped value\r\n */\r\nexport function Repeat(value: number, length: number): number {\r\n return value - Math.floor(value / length) * length;\r\n}\r\n\r\n/**\r\n * Normalize the value between 0.0 and 1.0 using min and max values\r\n * @param value value to normalize\r\n * @param min max to normalize between\r\n * @param max min to normalize between\r\n * @returns the normalized value\r\n */\r\nexport function Normalize(value: number, min: number, max: number): number {\r\n return (value - min) / (max - min);\r\n}\r\n\r\n/**\r\n * Denormalize the value from 0.0 and 1.0 using min and max values\r\n * @param normalized value to denormalize\r\n * @param min max to denormalize between\r\n * @param max min to denormalize between\r\n * @returns the denormalized value\r\n */\r\nexport function Denormalize(normalized: number, min: number, max: number): number {\r\n return normalized * (max - min) + min;\r\n}\r\n\r\n/**\r\n * Calculates the shortest difference between two given angles given in degrees.\r\n * @param current current angle in degrees\r\n * @param target target angle in degrees\r\n * @returns the delta\r\n */\r\nexport function DeltaAngle(current: number, target: number): number {\r\n let num: number = Repeat(target - current, 360.0);\r\n if (num > 180.0) {\r\n num -= 360.0;\r\n }\r\n return num;\r\n}\r\n\r\n/**\r\n * PingPongs the value t, so that it is never larger than length and never smaller than 0.\r\n * @param tx value\r\n * @param length length\r\n * @returns The returned value will move back and forth between 0 and length\r\n */\r\nexport function PingPong(tx: number, length: number): number {\r\n const t: number = Repeat(tx, length * 2.0);\r\n return length - Math.abs(t - length);\r\n}\r\n\r\n/**\r\n * Interpolates between min and max with smoothing at the limits.\r\n *\r\n * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up\r\n * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.\r\n * @param from from\r\n * @param to to\r\n * @param tx value\r\n * @returns the smooth stepped value\r\n */\r\nexport function SmoothStep(from: number, to: number, tx: number): number {\r\n let t: number = Clamp(tx);\r\n t = -2.0 * t * t * t + 3.0 * t * t;\r\n return to * t + from * (1.0 - t);\r\n}\r\n\r\n/**\r\n * Moves a value current towards target.\r\n *\r\n * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.\r\n * Negative values of maxDelta pushes the value away from target.\r\n * @param current current value\r\n * @param target target value\r\n * @param maxDelta max distance to move\r\n * @returns resulting value\r\n */\r\nexport function MoveTowards(current: number, target: number, maxDelta: number): number {\r\n let result: number = 0;\r\n if (Math.abs(target - current) <= maxDelta) {\r\n result = target;\r\n } else {\r\n result = current + Math.sign(target - current) * maxDelta;\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.\r\n *\r\n * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta\r\n * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.\r\n * @param current current value\r\n * @param target target value\r\n * @param maxDelta max distance to move\r\n * @returns resulting angle\r\n */\r\nexport function MoveTowardsAngle(current: number, target: number, maxDelta: number): number {\r\n const num: number = DeltaAngle(current, target);\r\n let result: number = 0;\r\n if (-maxDelta < num && num < maxDelta) {\r\n result = target;\r\n } else {\r\n target = current + num;\r\n result = MoveTowards(current, target, maxDelta);\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * This function returns percentage of a number in a given range.\r\n *\r\n * RangeToPercent(40,20,60) will return 0.5 (50%)\r\n * RangeToPercent(34,0,100) will return 0.34 (34%)\r\n * @param number to convert to percentage\r\n * @param min min range\r\n * @param max max range\r\n * @returns the percentage\r\n */\r\nexport function RangeToPercent(number: number, min: number, max: number): number {\r\n return (number - min) / (max - min);\r\n}\r\n\r\n/**\r\n * This function returns number that corresponds to the percentage in a given range.\r\n *\r\n * PercentToRange(0.34,0,100) will return 34.\r\n * @param percent to convert to number\r\n * @param min min range\r\n * @param max max range\r\n * @returns the number\r\n */\r\nexport function PercentToRange(percent: number, min: number, max: number): number {\r\n return (max - min) * percent + min;\r\n}\r\n\r\n/**\r\n * Returns the highest common factor of two integers.\r\n * @param a first parameter\r\n * @param b second parameter\r\n * @returns HCF of a and b\r\n */\r\nexport function HighestCommonFactor(a: number, b: number): number {\r\n const r: number = a % b;\r\n if (r === 0) {\r\n return b;\r\n }\r\n return HighestCommonFactor(b, r);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"math.scalar.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.scalar.functions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,CAAS,EAAE,CAAS,EAAE,UAAkB,YAAY;IAC9E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC;AACtC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,UAAkB,YAAY;IAC9F,OAAO,GAAG,GAAG,GAAG,GAAG,OAAO,IAAI,GAAG,GAAG,GAAG,GAAG,OAAO,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,GAAW;IAChD,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QACd,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI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AU,mBAAmB,CAAC,CAAS,EAAE,CAAS;IACpD,MAAM,CAAC,GAAW,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACV,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/**\r\n * Extract int value\r\n * @param value number value\r\n * @returns int value\r\n */\r\nexport function ExtractAsInt(value: number) {\r\n return parseInt(value.toString().replace(/\\W/g, \"\"));\r\n}\r\n\r\n/**\r\n * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n * @param a number\r\n * @param b number\r\n * @param epsilon (default = 1.401298E-45)\r\n * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n */\r\nexport function WithinEpsilon(a: number, b: number, epsilon: number = 1.401298e-45): boolean {\r\n return Math.abs(a - b) <= epsilon;\r\n}\r\n\r\n/**\r\n * Boolean : true if the number is outside a range\r\n * @param num number\r\n * @param min min value\r\n * @param max max value\r\n * @param epsilon (default = Number.EPSILON)\r\n * @returns true if the number is between min and max values\r\n */\r\nexport function OutsideRange(num: number, min: number, max: number, epsilon: number = 1.401298e-45): boolean {\r\n return num < min - epsilon || num > max + epsilon;\r\n}\r\n\r\n/**\r\n * Returns a random float number between and min and max values\r\n * @param min min value of random\r\n * @param max max value of random\r\n * @returns random value\r\n */\r\nexport function RandomRange(min: number, max: number): number {\r\n if (min === max) {\r\n return min;\r\n }\r\n return Math.random() * (max - min) + min;\r\n}\r\n\r\n/**\r\n * Creates a new scalar with values linearly interpolated of \"amount\" between the start scalar and the end scalar.\r\n * @param start start value\r\n * @param end target value\r\n * @param amount amount to lerp between\r\n * @returns the lerped value\r\n */\r\nexport function Lerp(start: number, end: number, amount: number): number {\r\n return start + (end - start) * amount;\r\n}\r\n\r\n/**\r\n * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.\r\n * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.\r\n * @param start start value\r\n * @param end target value\r\n * @param amount amount to lerp between\r\n * @returns the lerped value\r\n */\r\nexport function LerpAngle(start: number, end: number, amount: number): number {\r\n let num: number = Repeat(end - start, 360.0);\r\n if (num > 180.0) {\r\n num -= 360.0;\r\n }\r\n return start + num * Clamp(amount);\r\n}\r\n\r\n/**\r\n * Calculates the linear parameter t that produces the interpolant value within the range [a, b].\r\n * @param a start value\r\n * @param b target value\r\n * @param value value between a and b\r\n * @returns the inverseLerp value\r\n */\r\nexport function InverseLerp(a: number, b: number, value: number): number {\r\n let result: number = 0;\r\n if (a != b) {\r\n result = Clamp((value - a) / (b - a));\r\n } else {\r\n result = 0.0;\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Returns a new scalar located for \"amount\" (float) on the Hermite spline defined by the scalars \"value1\", \"value3\", \"tangent1\", \"tangent2\".\r\n * @see http://mathworld.wolfram.com/HermitePolynomial.html\r\n * @param value1 defines the first control point\r\n * @param tangent1 defines the first tangent\r\n * @param value2 defines the second control point\r\n * @param tangent2 defines the second tangent\r\n * @param amount defines the amount on the interpolation spline (between 0 and 1)\r\n * @returns hermite result\r\n */\r\nexport function Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number {\r\n const squared = amount * amount;\r\n const cubed = amount * squared;\r\n const part1 = 2.0 * cubed - 3.0 * squared + 1.0;\r\n const part2 = -2.0 * cubed + 3.0 * squared;\r\n const part3 = cubed - 2.0 * squared + amount;\r\n const part4 = cubed - squared;\r\n\r\n return value1 * part1 + value2 * part2 + tangent1 * part3 + tangent2 * part4;\r\n}\r\n\r\n/**\r\n * Returns a new scalar which is the 1st derivative of the Hermite spline defined by the scalars \"value1\", \"value2\", \"tangent1\", \"tangent2\".\r\n * @param value1 defines the first control point\r\n * @param tangent1 defines the first tangent\r\n * @param value2 defines the second control point\r\n * @param tangent2 defines the second tangent\r\n * @param time define where the derivative must be done\r\n * @returns 1st derivative\r\n */\r\nexport function Hermite1stDerivative(value1: number, tangent1: number, value2: number, tangent2: number, time: number): number {\r\n const t2 = time * time;\r\n return (t2 - time) * 6 * value1 + (3 * t2 - 4 * time + 1) * tangent1 + (-t2 + time) * 6 * value2 + (3 * t2 - 2 * time) * tangent2;\r\n}\r\n\r\n/**\r\n * Returns the value itself if it's between min and max.\r\n * Returns min if the value is lower than min.\r\n * Returns max if the value is greater than max.\r\n * @param value the value to clmap\r\n * @param min the min value to clamp to (default: 0)\r\n * @param max the max value to clamp to (default: 1)\r\n * @returns the clamped value\r\n */\r\nexport function Clamp(value: number, min = 0, max = 1): number {\r\n return Math.min(max, Math.max(min, value));\r\n}\r\n\r\n/**\r\n * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.\r\n * @param angle The angle to normalize in radian.\r\n * @returns The converted angle.\r\n */\r\nexport function NormalizeRadians(angle: number): number {\r\n // More precise but slower version kept for reference.\r\n // angle = angle % Tools.TwoPi;\r\n // angle = (angle + Tools.TwoPi) % Tools.TwoPi;\r\n\r\n //if (angle > Math.PI) {\r\n //\tangle -= Tools.TwoPi;\r\n //}\r\n\r\n angle -= Math.PI * 2 * Math.floor((angle + Math.PI) / (Math.PI * 2));\r\n\r\n return angle;\r\n}\r\n\r\n/**\r\n * Returns a string : the upper case translation of the number i to hexadecimal.\r\n * @param i number\r\n * @returns the upper case translation of the number i to hexadecimal.\r\n */\r\nexport function ToHex(i: number): string {\r\n const str = i.toString(16);\r\n\r\n if (i <= 15) {\r\n return (\"0\" + str).toUpperCase();\r\n }\r\n\r\n return str.toUpperCase();\r\n}\r\n\r\n/**\r\n * the floor part of a log2 value.\r\n * @param value the value to compute log2 of\r\n * @returns the log2 of value.\r\n */\r\nexport function ILog2(value: number): number {\r\n if (Math.log2) {\r\n return Math.floor(Math.log2(value));\r\n }\r\n\r\n if (value < 0) {\r\n return NaN;\r\n } else if (value === 0) {\r\n return -Infinity;\r\n }\r\n\r\n let n = 0;\r\n if (value < 1) {\r\n while (value < 1) {\r\n n++;\r\n value = value * 2;\r\n }\r\n n = -n;\r\n } else if (value > 1) {\r\n while (value > 1) {\r\n n++;\r\n value = Math.floor(value / 2);\r\n }\r\n }\r\n\r\n return n;\r\n}\r\n\r\n/**\r\n * Loops the value, so that it is never larger than length and never smaller than 0.\r\n *\r\n * This is similar to the modulo operator but it works with floating point numbers.\r\n * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.\r\n * With t = 5 and length = 2.5, the result would be 0.0.\r\n * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator\r\n * @param value the value\r\n * @param length the length\r\n * @returns the looped value\r\n */\r\nexport function Repeat(value: number, length: number): number {\r\n return value - Math.floor(value / length) * length;\r\n}\r\n\r\n/**\r\n * Normalize the value between 0.0 and 1.0 using min and max values\r\n * @param value value to normalize\r\n * @param min max to normalize between\r\n * @param max min to normalize between\r\n * @returns the normalized value\r\n */\r\nexport function Normalize(value: number, min: number, max: number): number {\r\n return (value - min) / (max - min);\r\n}\r\n\r\n/**\r\n * Denormalize the value from 0.0 and 1.0 using min and max values\r\n * @param normalized value to denormalize\r\n * @param min max to denormalize between\r\n * @param max min to denormalize between\r\n * @returns the denormalized value\r\n */\r\nexport function Denormalize(normalized: number, min: number, max: number): number {\r\n return normalized * (max - min) + min;\r\n}\r\n\r\n/**\r\n * Calculates the shortest difference between two given angles given in degrees.\r\n * @param current current angle in degrees\r\n * @param target target angle in degrees\r\n * @returns the delta\r\n */\r\nexport function DeltaAngle(current: number, target: number): number {\r\n let num: number = Repeat(target - current, 360.0);\r\n if (num > 180.0) {\r\n num -= 360.0;\r\n }\r\n return num;\r\n}\r\n\r\n/**\r\n * PingPongs the value t, so that it is never larger than length and never smaller than 0.\r\n * @param tx value\r\n * @param length length\r\n * @returns The returned value will move back and forth between 0 and length\r\n */\r\nexport function PingPong(tx: number, length: number): number {\r\n const t: number = Repeat(tx, length * 2.0);\r\n return length - Math.abs(t - length);\r\n}\r\n\r\n/**\r\n * Interpolates between min and max with smoothing at the limits.\r\n *\r\n * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up\r\n * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.\r\n * @param from from\r\n * @param to to\r\n * @param tx value\r\n * @returns the smooth stepped value\r\n */\r\nexport function SmoothStep(from: number, to: number, tx: number): number {\r\n let t: number = Clamp(tx);\r\n t = -2.0 * t * t * t + 3.0 * t * t;\r\n return to * t + from * (1.0 - t);\r\n}\r\n\r\n/**\r\n * Moves a value current towards target.\r\n *\r\n * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.\r\n * Negative values of maxDelta pushes the value away from target.\r\n * @param current current value\r\n * @param target target value\r\n * @param maxDelta max distance to move\r\n * @returns resulting value\r\n */\r\nexport function MoveTowards(current: number, target: number, maxDelta: number): number {\r\n let result: number = 0;\r\n if (Math.abs(target - current) <= maxDelta) {\r\n result = target;\r\n } else {\r\n result = current + Math.sign(target - current) * maxDelta;\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.\r\n *\r\n * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta\r\n * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.\r\n * @param current current value\r\n * @param target target value\r\n * @param maxDelta max distance to move\r\n * @returns resulting angle\r\n */\r\nexport function MoveTowardsAngle(current: number, target: number, maxDelta: number): number {\r\n const num: number = DeltaAngle(current, target);\r\n let result: number = 0;\r\n if (-maxDelta < num && num < maxDelta) {\r\n result = target;\r\n } else {\r\n target = current + num;\r\n result = MoveTowards(current, target, maxDelta);\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * This function returns percentage of a number in a given range.\r\n *\r\n * RangeToPercent(40,20,60) will return 0.5 (50%)\r\n * RangeToPercent(34,0,100) will return 0.34 (34%)\r\n * @param number to convert to percentage\r\n * @param min min range\r\n * @param max max range\r\n * @returns the percentage\r\n */\r\nexport function RangeToPercent(number: number, min: number, max: number): number {\r\n return (number - min) / (max - min);\r\n}\r\n\r\n/**\r\n * This function returns number that corresponds to the percentage in a given range.\r\n *\r\n * PercentToRange(0.34,0,100) will return 34.\r\n * @param percent to convert to number\r\n * @param min min range\r\n * @param max max range\r\n * @returns the number\r\n */\r\nexport function PercentToRange(percent: number, min: number, max: number): number {\r\n return (max - min) * percent + min;\r\n}\r\n\r\n/**\r\n * Returns the highest common factor of two integers.\r\n * @param a first parameter\r\n * @param b second parameter\r\n * @returns HCF of a and b\r\n */\r\nexport function HighestCommonFactor(a: number, b: number): number {\r\n const r: number = a % b;\r\n if (r === 0) {\r\n return b;\r\n }\r\n return HighestCommonFactor(b, r);\r\n}\r\n"]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { NodeGeometryBlock } from "../nodeGeometryBlock";
|
|
2
|
+
import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnectionPoint";
|
|
3
|
+
import type { NodeGeometryBuildState } from "../nodeGeometryBuildState";
|
|
4
|
+
/**
|
|
5
|
+
* Types of easing function supported by the Ease block
|
|
6
|
+
*/
|
|
7
|
+
export declare enum GeometryEaseBlockTypes {
|
|
8
|
+
/** EaseInSine */
|
|
9
|
+
EaseInSine = 0,
|
|
10
|
+
/** EaseOutSine */
|
|
11
|
+
EaseOutSine = 1,
|
|
12
|
+
/** EaseInOutSine */
|
|
13
|
+
EaseInOutSine = 2,
|
|
14
|
+
/** EaseInQuad */
|
|
15
|
+
EaseInQuad = 3,
|
|
16
|
+
/** EaseOutQuad */
|
|
17
|
+
EaseOutQuad = 4,
|
|
18
|
+
/** EaseInOutQuad */
|
|
19
|
+
EaseInOutQuad = 5,
|
|
20
|
+
/** EaseInCubic */
|
|
21
|
+
EaseInCubic = 6,
|
|
22
|
+
/** EaseOutCubic */
|
|
23
|
+
EaseOutCubic = 7,
|
|
24
|
+
/** EaseInOutCubic */
|
|
25
|
+
EaseInOutCubic = 8,
|
|
26
|
+
/** EaseInQuart */
|
|
27
|
+
EaseInQuart = 9,
|
|
28
|
+
/** EaseOutQuart */
|
|
29
|
+
EaseOutQuart = 10,
|
|
30
|
+
/** EaseInOutQuart */
|
|
31
|
+
EaseInOutQuart = 11,
|
|
32
|
+
/** EaseInQuint */
|
|
33
|
+
EaseInQuint = 12,
|
|
34
|
+
/** EaseOutQuint */
|
|
35
|
+
EaseOutQuint = 13,
|
|
36
|
+
/** EaseInOutQuint */
|
|
37
|
+
EaseInOutQuint = 14,
|
|
38
|
+
/** EaseInExpo */
|
|
39
|
+
EaseInExpo = 15,
|
|
40
|
+
/** EaseOutExpo */
|
|
41
|
+
EaseOutExpo = 16,
|
|
42
|
+
/** EaseInOutExpo */
|
|
43
|
+
EaseInOutExpo = 17,
|
|
44
|
+
/** EaseInCirc */
|
|
45
|
+
EaseInCirc = 18,
|
|
46
|
+
/** EaseOutCirc */
|
|
47
|
+
EaseOutCirc = 19,
|
|
48
|
+
/** EaseInOutCirc */
|
|
49
|
+
EaseInOutCirc = 20,
|
|
50
|
+
/** EaseInBack */
|
|
51
|
+
EaseInBack = 21,
|
|
52
|
+
/** EaseOutBack */
|
|
53
|
+
EaseOutBack = 22,
|
|
54
|
+
/** EaseInOutBack */
|
|
55
|
+
EaseInOutBack = 23,
|
|
56
|
+
/** EaseInElastic */
|
|
57
|
+
EaseInElastic = 24,
|
|
58
|
+
/** EaseOutElastic */
|
|
59
|
+
EaseOutElastic = 25,
|
|
60
|
+
/** EaseInOutElastic */
|
|
61
|
+
EaseInOutElastic = 26
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Block used to apply an easing function to floats
|
|
65
|
+
*/
|
|
66
|
+
export declare class GeometryEaseBlock extends NodeGeometryBlock {
|
|
67
|
+
private _easingFunction;
|
|
68
|
+
private _type;
|
|
69
|
+
/**
|
|
70
|
+
* Gets or sets the type of the easing functions applied by the block
|
|
71
|
+
*/
|
|
72
|
+
get type(): GeometryEaseBlockTypes;
|
|
73
|
+
set type(value: GeometryEaseBlockTypes);
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new GeometryEaseBlock
|
|
76
|
+
* @param name defines the block name
|
|
77
|
+
*/
|
|
78
|
+
constructor(name: string);
|
|
79
|
+
/**
|
|
80
|
+
* Gets the current class name
|
|
81
|
+
* @returns the class name
|
|
82
|
+
*/
|
|
83
|
+
getClassName(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the input component
|
|
86
|
+
*/
|
|
87
|
+
get input(): NodeGeometryConnectionPoint;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the output component
|
|
90
|
+
*/
|
|
91
|
+
get output(): NodeGeometryConnectionPoint;
|
|
92
|
+
protected _buildBlock(state: NodeGeometryBuildState): this | undefined;
|
|
93
|
+
serialize(): any;
|
|
94
|
+
_deserialize(serializationObject: any): void;
|
|
95
|
+
protected _dumpPropertiesCode(): string;
|
|
96
|
+
}
|