@babylonjs/core 6.2.0 → 6.3.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/Engines/WebGPU/webgpuHardwareTexture.js +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/thinEngine.js +21 -4
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -6
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/gizmo.js +1 -0
- package/Gizmos/gizmo.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +2 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +4 -0
- package/Materials/Node/Blocks/triPlanarBlock.js +44 -6
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +2 -1
- package/Materials/PBR/pbrMaterial.js +3 -2
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +2 -2
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +6 -0
- package/Materials/Textures/baseTexture.js +8 -0
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.d.ts +7 -0
- package/Materials/Textures/cubeTexture.js +25 -2
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/standardMaterial.d.ts +2 -1
- package/Materials/standardMaterial.js +3 -2
- package/Materials/standardMaterial.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.d.ts +4 -0
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +19 -4
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/decorators.d.ts +5 -1
- package/Misc/decorators.js +12 -4
- package/Misc/decorators.js.map +1 -1
- package/Misc/error.d.ts +1 -1
- package/Misc/error.js.map +1 -1
- package/Misc/tools.d.ts +6 -6
- package/Misc/tools.js +17 -14
- package/Misc/tools.js.map +1 -1
- package/Physics/physicsRaycastResult.js +6 -6
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +2 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +16 -1
- package/Physics/v2/Plugins/havokPlugin.js +43 -3
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +0 -50
- package/Physics/v2/physicsAggregate.js +3 -2
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +12 -0
- package/Physics/v2/physicsBody.js +17 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/assetContainer.d.ts +2 -3
- package/assetContainer.js +13 -4
- package/assetContainer.js.map +1 -1
- package/node.d.ts +8 -0
- package/node.js +23 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,10 @@ import type { CubeMapInfo } from "./panoramaToCubemap";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class CubeMapToSphericalPolynomialTools {
|
|
10
10
|
private static _FileFaces;
|
|
11
|
+
/** @internal */
|
|
12
|
+
static MAX_HDRI_VALUE: number;
|
|
13
|
+
/** @internal */
|
|
14
|
+
static PRESERVE_CLAMPED_COLORS: boolean;
|
|
11
15
|
/**
|
|
12
16
|
* Converts a texture to the according Spherical Polynomial data.
|
|
13
17
|
* This extracts the first 3 orders only as they are the only one used in the lighting.
|
|
@@ -141,10 +141,21 @@ export class CubeMapToSphericalPolynomialTools {
|
|
|
141
141
|
}
|
|
142
142
|
// Prevent to explode in case of really high dynamic ranges.
|
|
143
143
|
// sh 3 would not be enough to accurately represent it.
|
|
144
|
-
const max =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
const max = this.MAX_HDRI_VALUE;
|
|
145
|
+
if (this.PRESERVE_CLAMPED_COLORS) {
|
|
146
|
+
const currentMax = Math.max(r, g, b);
|
|
147
|
+
if (currentMax > max) {
|
|
148
|
+
const factor = max / currentMax;
|
|
149
|
+
r *= factor;
|
|
150
|
+
g *= factor;
|
|
151
|
+
b *= factor;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
r = Scalar.Clamp(r, 0, max);
|
|
156
|
+
g = Scalar.Clamp(g, 0, max);
|
|
157
|
+
b = Scalar.Clamp(b, 0, max);
|
|
158
|
+
}
|
|
148
159
|
const color = new Color3(r, g, b);
|
|
149
160
|
sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
|
|
150
161
|
totalSolidAngle += deltaSolidAngle;
|
|
@@ -177,4 +188,8 @@ CubeMapToSphericalPolynomialTools._FileFaces = [
|
|
|
177
188
|
new FileFaceOrientation("front", new Vector3(0, 0, 1), new Vector3(1, 0, 0), new Vector3(0, -1, 0)),
|
|
178
189
|
new FileFaceOrientation("back", new Vector3(0, 0, -1), new Vector3(-1, 0, 0), new Vector3(0, -1, 0)), // -Z bottom
|
|
179
190
|
];
|
|
191
|
+
/** @internal */
|
|
192
|
+
CubeMapToSphericalPolynomialTools.MAX_HDRI_VALUE = 4096;
|
|
193
|
+
/** @internal */
|
|
194
|
+
CubeMapToSphericalPolynomialTools.PRESERVE_CLAMPED_COLORS = false;
|
|
180
195
|
//# sourceMappingURL=cubemapToSphericalPolynomial.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cubemapToSphericalPolynomial.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MA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AAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/F,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACnG,IAAI,mBAAmB,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnG,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY;CACrH,CAAC","sourcesContent":["import { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { SphericalPolynomial, SphericalHarmonics } from \"../../Maths/sphericalPolynomial\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { CubeMapInfo } from \"./panoramaToCubemap\";\r\nimport { ToLinearSpace } from \"../../Maths/math.constants\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\n\r\nclass FileFaceOrientation {\r\n public name: string;\r\n public worldAxisForNormal: Vector3; // the world axis corresponding to the normal to the face\r\n public worldAxisForFileX: Vector3; // the world axis corresponding to texture right x-axis in file\r\n public worldAxisForFileY: Vector3; // the world axis corresponding to texture down y-axis in file\r\n\r\n public constructor(name: string, worldAxisForNormal: Vector3, worldAxisForFileX: Vector3, worldAxisForFileY: Vector3) {\r\n this.name = name;\r\n this.worldAxisForNormal = worldAxisForNormal;\r\n this.worldAxisForFileX = worldAxisForFileX;\r\n this.worldAxisForFileY = worldAxisForFileY;\r\n }\r\n}\r\n\r\n/**\r\n * Helper class dealing with the extraction of spherical polynomial dataArray\r\n * from a cube map.\r\n */\r\nexport class CubeMapToSphericalPolynomialTools {\r\n private static _FileFaces: FileFaceOrientation[] = [\r\n new FileFaceOrientation(\"right\", new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector3(0, -1, 0)), // +X east\r\n new FileFaceOrientation(\"left\", new Vector3(-1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, -1, 0)), // -X west\r\n new FileFaceOrientation(\"up\", new Vector3(0, 1, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1)), // +Y north\r\n new FileFaceOrientation(\"down\", new Vector3(0, -1, 0), new Vector3(1, 0, 0), new Vector3(0, 0, -1)), // -Y south\r\n new FileFaceOrientation(\"front\", new Vector3(0, 0, 1), new Vector3(1, 0, 0), new Vector3(0, -1, 0)), // +Z top\r\n new FileFaceOrientation(\"back\", new Vector3(0, 0, -1), new Vector3(-1, 0, 0), new Vector3(0, -1, 0)), // -Z bottom\r\n ];\r\n\r\n /**\r\n * Converts a texture to the according Spherical Polynomial data.\r\n * This extracts the first 3 orders only as they are the only one used in the lighting.\r\n *\r\n * @param texture The texture to extract the information from.\r\n * @returns The Spherical Polynomial data.\r\n */\r\n public static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>> {\r\n if (!texture.isCube) {\r\n // Only supports cube Textures currently.\r\n return null;\r\n }\r\n\r\n texture.getScene()?.getEngine().flushFramebuffer();\r\n\r\n const size = texture.getSize().width;\r\n const rightPromise = texture.readPixels(0, undefined, undefined, false);\r\n const leftPromise = texture.readPixels(1, undefined, undefined, false);\r\n\r\n let upPromise: Nullable<Promise<ArrayBufferView>>;\r\n let downPromise: Nullable<Promise<ArrayBufferView>>;\r\n if (texture.isRenderTarget) {\r\n upPromise = texture.readPixels(3, undefined, undefined, false);\r\n downPromise = texture.readPixels(2, undefined, undefined, false);\r\n } else {\r\n upPromise = texture.readPixels(2, undefined, undefined, false);\r\n downPromise = texture.readPixels(3, undefined, undefined, false);\r\n }\r\n\r\n const frontPromise = texture.readPixels(4, undefined, undefined, false);\r\n const backPromise = texture.readPixels(5, undefined, undefined, false);\r\n\r\n const gammaSpace = texture.gammaSpace;\r\n // Always read as RGBA.\r\n const format = Constants.TEXTUREFORMAT_RGBA;\r\n let type = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n if (texture.textureType == Constants.TEXTURETYPE_FLOAT || texture.textureType == Constants.TEXTURETYPE_HALF_FLOAT) {\r\n type = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n return new Promise((resolve) => {\r\n Promise.all([leftPromise, rightPromise, upPromise, downPromise, frontPromise, backPromise]).then(([left, right, up, down, front, back]) => {\r\n const cubeInfo: CubeMapInfo = {\r\n size,\r\n right,\r\n left,\r\n up,\r\n down,\r\n front,\r\n back,\r\n format,\r\n type,\r\n gammaSpace,\r\n };\r\n\r\n resolve(this.ConvertCubeMapToSphericalPolynomial(cubeInfo));\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Compute the area on the unit sphere of the rectangle defined by (x,y) and the origin\r\n * See https://www.rorydriscoll.com/2012/01/15/cubemap-texel-solid-angle/\r\n * @param x\r\n * @param y\r\n */\r\n private static _AreaElement(x: number, y: number): number {\r\n return Math.atan2(x * y, Math.sqrt(x * x + y * y + 1));\r\n }\r\n\r\n /**\r\n * Converts a cubemap to the according Spherical Polynomial data.\r\n * This extracts the first 3 orders only as they are the only one used in the lighting.\r\n *\r\n * @param cubeInfo The Cube map to extract the information from.\r\n * @returns The Spherical Polynomial data.\r\n */\r\n public static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial {\r\n const sphericalHarmonics = new SphericalHarmonics();\r\n let totalSolidAngle = 0.0;\r\n\r\n // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.\r\n const du = 2.0 / cubeInfo.size;\r\n const dv = du;\r\n\r\n const halfTexel = 0.5 * du;\r\n\r\n // The (u,v) of the first texel is half a texel from the corner (-1,-1).\r\n const minUV = halfTexel - 1.0;\r\n\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n const fileFace = this._FileFaces[faceIndex];\r\n const dataArray = (<any>cubeInfo)[fileFace.name];\r\n let v = minUV;\r\n\r\n // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).\r\n // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.\r\n // Because SP is still linear, so summation is fine in that basis.\r\n const stride = cubeInfo.format === Constants.TEXTUREFORMAT_RGBA ? 4 : 3;\r\n for (let y = 0; y < cubeInfo.size; y++) {\r\n let u = minUV;\r\n\r\n for (let x = 0; x < cubeInfo.size; x++) {\r\n // World direction (not normalised)\r\n const worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);\r\n worldDirection.normalize();\r\n\r\n const deltaSolidAngle =\r\n this._AreaElement(u - halfTexel, v - halfTexel) -\r\n this._AreaElement(u - halfTexel, v + halfTexel) -\r\n this._AreaElement(u + halfTexel, v - halfTexel) +\r\n this._AreaElement(u + halfTexel, v + halfTexel);\r\n\r\n let r = dataArray[y * cubeInfo.size * stride + x * stride + 0];\r\n let g = dataArray[y * cubeInfo.size * stride + x * stride + 1];\r\n let b = dataArray[y * cubeInfo.size * stride + x * stride + 2];\r\n\r\n // Prevent NaN harmonics with extreme HDRI data.\r\n if (isNaN(r)) {\r\n r = 0;\r\n }\r\n if (isNaN(g)) {\r\n g = 0;\r\n }\r\n if (isNaN(b)) {\r\n b = 0;\r\n }\r\n\r\n // Handle Integer types.\r\n if (cubeInfo.type === Constants.TEXTURETYPE_UNSIGNED_INT) {\r\n r /= 255;\r\n g /= 255;\r\n b /= 255;\r\n }\r\n\r\n // Handle Gamma space textures.\r\n if (cubeInfo.gammaSpace) {\r\n r = Math.pow(Scalar.Clamp(r), ToLinearSpace);\r\n g = Math.pow(Scalar.Clamp(g), ToLinearSpace);\r\n b = Math.pow(Scalar.Clamp(b), ToLinearSpace);\r\n }\r\n\r\n // Prevent to explode in case of really high dynamic ranges.\r\n // sh 3 would not be enough to accurately represent it.\r\n const max = 4096;\r\n r = Scalar.Clamp(r, 0, max);\r\n g = Scalar.Clamp(g, 0, max);\r\n b = Scalar.Clamp(b, 0, max);\r\n\r\n const color = new Color3(r, g, b);\r\n\r\n sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);\r\n\r\n totalSolidAngle += deltaSolidAngle;\r\n\r\n u += du;\r\n }\r\n\r\n v += dv;\r\n }\r\n }\r\n\r\n // Solid angle for entire sphere is 4*pi\r\n const sphereSolidAngle = 4.0 * Math.PI;\r\n\r\n // Adjust the solid angle to allow for how many faces we processed.\r\n const facesProcessed = 6.0;\r\n const expectedSolidAngle = (sphereSolidAngle * facesProcessed) / 6.0;\r\n\r\n // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.\r\n // This is needed because the numerical integration over the cube uses a\r\n // small angle approximation of solid angle for each texel (see deltaSolidAngle),\r\n // and also to compensate for accumulative error due to float precision in the summation.\r\n const correctionFactor = expectedSolidAngle / totalSolidAngle;\r\n sphericalHarmonics.scaleInPlace(correctionFactor);\r\n\r\n sphericalHarmonics.convertIncidentRadianceToIrradiance();\r\n sphericalHarmonics.convertIrradianceToLambertianRadiance();\r\n\r\n return SphericalPolynomial.FromHarmonics(sphericalHarmonics);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"cubemapToSphericalPol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AE,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY;CACrH,CAAC;AAEF,gBAAgB;AACF,gDAAc,GAAG,IAAI,CAAC;AACpC,gBAAgB;AACF,yDAAuB,GAAG,KAAK,CAAC","sourcesContent":["import { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { SphericalPolynomial, SphericalHarmonics } from \"../../Maths/sphericalPolynomial\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { CubeMapInfo } from \"./panoramaToCubemap\";\r\nimport { ToLinearSpace } from \"../../Maths/math.constants\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\n\r\nclass FileFaceOrientation {\r\n public name: string;\r\n public worldAxisForNormal: Vector3; // the world axis corresponding to the normal to the face\r\n public worldAxisForFileX: Vector3; // the world axis corresponding to texture right x-axis in file\r\n public worldAxisForFileY: Vector3; // the world axis corresponding to texture down y-axis in file\r\n\r\n public constructor(name: string, worldAxisForNormal: Vector3, worldAxisForFileX: Vector3, worldAxisForFileY: Vector3) {\r\n this.name = name;\r\n this.worldAxisForNormal = worldAxisForNormal;\r\n this.worldAxisForFileX = worldAxisForFileX;\r\n this.worldAxisForFileY = worldAxisForFileY;\r\n }\r\n}\r\n\r\n/**\r\n * Helper class dealing with the extraction of spherical polynomial dataArray\r\n * from a cube map.\r\n */\r\nexport class CubeMapToSphericalPolynomialTools {\r\n private static _FileFaces: FileFaceOrientation[] = [\r\n new FileFaceOrientation(\"right\", new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector3(0, -1, 0)), // +X east\r\n new FileFaceOrientation(\"left\", new Vector3(-1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, -1, 0)), // -X west\r\n new FileFaceOrientation(\"up\", new Vector3(0, 1, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1)), // +Y north\r\n new FileFaceOrientation(\"down\", new Vector3(0, -1, 0), new Vector3(1, 0, 0), new Vector3(0, 0, -1)), // -Y south\r\n new FileFaceOrientation(\"front\", new Vector3(0, 0, 1), new Vector3(1, 0, 0), new Vector3(0, -1, 0)), // +Z top\r\n new FileFaceOrientation(\"back\", new Vector3(0, 0, -1), new Vector3(-1, 0, 0), new Vector3(0, -1, 0)), // -Z bottom\r\n ];\r\n\r\n /** @internal */\r\n public static MAX_HDRI_VALUE = 4096;\r\n /** @internal */\r\n public static PRESERVE_CLAMPED_COLORS = false;\r\n\r\n /**\r\n * Converts a texture to the according Spherical Polynomial data.\r\n * This extracts the first 3 orders only as they are the only one used in the lighting.\r\n *\r\n * @param texture The texture to extract the information from.\r\n * @returns The Spherical Polynomial data.\r\n */\r\n public static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>> {\r\n if (!texture.isCube) {\r\n // Only supports cube Textures currently.\r\n return null;\r\n }\r\n\r\n texture.getScene()?.getEngine().flushFramebuffer();\r\n\r\n const size = texture.getSize().width;\r\n const rightPromise = texture.readPixels(0, undefined, undefined, false);\r\n const leftPromise = texture.readPixels(1, undefined, undefined, false);\r\n\r\n let upPromise: Nullable<Promise<ArrayBufferView>>;\r\n let downPromise: Nullable<Promise<ArrayBufferView>>;\r\n if (texture.isRenderTarget) {\r\n upPromise = texture.readPixels(3, undefined, undefined, false);\r\n downPromise = texture.readPixels(2, undefined, undefined, false);\r\n } else {\r\n upPromise = texture.readPixels(2, undefined, undefined, false);\r\n downPromise = texture.readPixels(3, undefined, undefined, false);\r\n }\r\n\r\n const frontPromise = texture.readPixels(4, undefined, undefined, false);\r\n const backPromise = texture.readPixels(5, undefined, undefined, false);\r\n\r\n const gammaSpace = texture.gammaSpace;\r\n // Always read as RGBA.\r\n const format = Constants.TEXTUREFORMAT_RGBA;\r\n let type = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n if (texture.textureType == Constants.TEXTURETYPE_FLOAT || texture.textureType == Constants.TEXTURETYPE_HALF_FLOAT) {\r\n type = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n return new Promise((resolve) => {\r\n Promise.all([leftPromise, rightPromise, upPromise, downPromise, frontPromise, backPromise]).then(([left, right, up, down, front, back]) => {\r\n const cubeInfo: CubeMapInfo = {\r\n size,\r\n right,\r\n left,\r\n up,\r\n down,\r\n front,\r\n back,\r\n format,\r\n type,\r\n gammaSpace,\r\n };\r\n\r\n resolve(this.ConvertCubeMapToSphericalPolynomial(cubeInfo));\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Compute the area on the unit sphere of the rectangle defined by (x,y) and the origin\r\n * See https://www.rorydriscoll.com/2012/01/15/cubemap-texel-solid-angle/\r\n * @param x\r\n * @param y\r\n */\r\n private static _AreaElement(x: number, y: number): number {\r\n return Math.atan2(x * y, Math.sqrt(x * x + y * y + 1));\r\n }\r\n\r\n /**\r\n * Converts a cubemap to the according Spherical Polynomial data.\r\n * This extracts the first 3 orders only as they are the only one used in the lighting.\r\n *\r\n * @param cubeInfo The Cube map to extract the information from.\r\n * @returns The Spherical Polynomial data.\r\n */\r\n public static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial {\r\n const sphericalHarmonics = new SphericalHarmonics();\r\n let totalSolidAngle = 0.0;\r\n\r\n // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.\r\n const du = 2.0 / cubeInfo.size;\r\n const dv = du;\r\n\r\n const halfTexel = 0.5 * du;\r\n\r\n // The (u,v) of the first texel is half a texel from the corner (-1,-1).\r\n const minUV = halfTexel - 1.0;\r\n\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n const fileFace = this._FileFaces[faceIndex];\r\n const dataArray = (<any>cubeInfo)[fileFace.name];\r\n let v = minUV;\r\n\r\n // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).\r\n // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.\r\n // Because SP is still linear, so summation is fine in that basis.\r\n const stride = cubeInfo.format === Constants.TEXTUREFORMAT_RGBA ? 4 : 3;\r\n for (let y = 0; y < cubeInfo.size; y++) {\r\n let u = minUV;\r\n\r\n for (let x = 0; x < cubeInfo.size; x++) {\r\n // World direction (not normalised)\r\n const worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);\r\n worldDirection.normalize();\r\n\r\n const deltaSolidAngle =\r\n this._AreaElement(u - halfTexel, v - halfTexel) -\r\n this._AreaElement(u - halfTexel, v + halfTexel) -\r\n this._AreaElement(u + halfTexel, v - halfTexel) +\r\n this._AreaElement(u + halfTexel, v + halfTexel);\r\n\r\n let r = dataArray[y * cubeInfo.size * stride + x * stride + 0];\r\n let g = dataArray[y * cubeInfo.size * stride + x * stride + 1];\r\n let b = dataArray[y * cubeInfo.size * stride + x * stride + 2];\r\n\r\n // Prevent NaN harmonics with extreme HDRI data.\r\n if (isNaN(r)) {\r\n r = 0;\r\n }\r\n if (isNaN(g)) {\r\n g = 0;\r\n }\r\n if (isNaN(b)) {\r\n b = 0;\r\n }\r\n\r\n // Handle Integer types.\r\n if (cubeInfo.type === Constants.TEXTURETYPE_UNSIGNED_INT) {\r\n r /= 255;\r\n g /= 255;\r\n b /= 255;\r\n }\r\n\r\n // Handle Gamma space textures.\r\n if (cubeInfo.gammaSpace) {\r\n r = Math.pow(Scalar.Clamp(r), ToLinearSpace);\r\n g = Math.pow(Scalar.Clamp(g), ToLinearSpace);\r\n b = Math.pow(Scalar.Clamp(b), ToLinearSpace);\r\n }\r\n\r\n // Prevent to explode in case of really high dynamic ranges.\r\n // sh 3 would not be enough to accurately represent it.\r\n const max = this.MAX_HDRI_VALUE;\r\n if (this.PRESERVE_CLAMPED_COLORS) {\r\n const currentMax = Math.max(r, g, b);\r\n if (currentMax > max) {\r\n const factor = max / currentMax;\r\n r *= factor;\r\n g *= factor;\r\n b *= factor;\r\n }\r\n } else {\r\n r = Scalar.Clamp(r, 0, max);\r\n g = Scalar.Clamp(g, 0, max);\r\n b = Scalar.Clamp(b, 0, max);\r\n }\r\n\r\n const color = new Color3(r, g, b);\r\n\r\n sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);\r\n\r\n totalSolidAngle += deltaSolidAngle;\r\n\r\n u += du;\r\n }\r\n\r\n v += dv;\r\n }\r\n }\r\n\r\n // Solid angle for entire sphere is 4*pi\r\n const sphereSolidAngle = 4.0 * Math.PI;\r\n\r\n // Adjust the solid angle to allow for how many faces we processed.\r\n const facesProcessed = 6.0;\r\n const expectedSolidAngle = (sphereSolidAngle * facesProcessed) / 6.0;\r\n\r\n // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.\r\n // This is needed because the numerical integration over the cube uses a\r\n // small angle approximation of solid angle for each texel (see deltaSolidAngle),\r\n // and also to compensate for accumulative error due to float precision in the summation.\r\n const correctionFactor = expectedSolidAngle / totalSolidAngle;\r\n sphericalHarmonics.scaleInPlace(correctionFactor);\r\n\r\n sphericalHarmonics.convertIncidentRadianceToIrradiance();\r\n sphericalHarmonics.convertIrradianceToLambertianRadiance();\r\n\r\n return SphericalPolynomial.FromHarmonics(sphericalHarmonics);\r\n }\r\n}\r\n"]}
|
package/Misc/decorators.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ declare type ImageProcessingConfiguration = import("../Materials/imageProcessing
|
|
|
5
5
|
declare type FresnelParameters = import("../Materials/fresnelParameters").FresnelParameters;
|
|
6
6
|
declare type ColorCurves = import("../Materials/colorCurves").ColorCurves;
|
|
7
7
|
declare type BaseTexture = import("../Materials/Textures/baseTexture").BaseTexture;
|
|
8
|
+
/** @internal */
|
|
9
|
+
export interface CopySourceOptions {
|
|
10
|
+
cloneTexturesOnlyOnce?: boolean;
|
|
11
|
+
}
|
|
8
12
|
export declare function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
|
|
9
13
|
export declare function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
|
|
10
14
|
export declare function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
|
|
@@ -83,7 +87,7 @@ export declare class SerializationHelper {
|
|
|
83
87
|
* @param source defines the source object
|
|
84
88
|
* @returns the cloned object
|
|
85
89
|
*/
|
|
86
|
-
static Clone<T>(creationFunction: () => T, source: T): T;
|
|
90
|
+
static Clone<T>(creationFunction: () => T, source: T, options?: CopySourceOptions): T;
|
|
87
91
|
/**
|
|
88
92
|
* Instanciates a new object based on a source one (some data will be shared between both object)
|
|
89
93
|
* @param creationFunction defines the function used to instanciate the new object
|
package/Misc/decorators.js
CHANGED
|
@@ -6,13 +6,15 @@ import { _WarnImport } from "./devTools.js";
|
|
|
6
6
|
import { Color4, Color3 } from "../Maths/math.color.js";
|
|
7
7
|
const __decoratorInitialStore = {};
|
|
8
8
|
const __mergedStore = {};
|
|
9
|
-
const _copySource = function (creationFunction, source, instanciate) {
|
|
9
|
+
const _copySource = function (creationFunction, source, instanciate, options = {}) {
|
|
10
10
|
const destination = creationFunction();
|
|
11
11
|
// Tags
|
|
12
12
|
if (Tags && Tags.HasTags(source)) {
|
|
13
13
|
Tags.AddTagsTo(destination, Tags.GetTags(source, true));
|
|
14
14
|
}
|
|
15
15
|
const classStore = getMergedStore(destination);
|
|
16
|
+
// Map from source texture uniqueId to destination texture
|
|
17
|
+
const textureMap = {};
|
|
16
18
|
// Properties
|
|
17
19
|
for (const property in classStore) {
|
|
18
20
|
const propertyDescriptor = classStore[property];
|
|
@@ -26,7 +28,13 @@ const _copySource = function (creationFunction, source, instanciate) {
|
|
|
26
28
|
destination[property] = sourceProperty;
|
|
27
29
|
break;
|
|
28
30
|
case 1: // Texture
|
|
29
|
-
|
|
31
|
+
if (options.cloneTexturesOnlyOnce && textureMap[sourceProperty.uniqueId]) {
|
|
32
|
+
destination[property] = textureMap[sourceProperty.uniqueId];
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
destination[property] = instanciate || sourceProperty.isRenderTarget ? sourceProperty : sourceProperty.clone();
|
|
36
|
+
textureMap[sourceProperty.uniqueId] = destination[property];
|
|
37
|
+
}
|
|
30
38
|
break;
|
|
31
39
|
case 2: // Color3
|
|
32
40
|
case 3: // FresnelParameters
|
|
@@ -345,8 +353,8 @@ export class SerializationHelper {
|
|
|
345
353
|
* @param source defines the source object
|
|
346
354
|
* @returns the cloned object
|
|
347
355
|
*/
|
|
348
|
-
static Clone(creationFunction, source) {
|
|
349
|
-
return _copySource(creationFunction, source, false);
|
|
356
|
+
static Clone(creationFunction, source, options = {}) {
|
|
357
|
+
return _copySource(creationFunction, source, false, options);
|
|
350
358
|
}
|
|
351
359
|
/**
|
|
352
360
|
* Instanciates a new object based on a source one (some data will be shared between both object)
|
package/Misc/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/decorators.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,yDAAyD;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAUrD,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,WAAW,GAAG,UAAa,gBAAyB,EAAE,MAAS,EAAE,WAAoB;IACvF,MAAM,WAAW,GAAG,gBAAgB,EAAE,CAAC;IAEvC,OAAO;IACP,IAAI,IAAI,IAAI,IAAI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,OAAO,CAAC,WAAW,CAA0C,CAAC;YACjF,0LAA0L;YAC1L,IAAI,SAAS,EAAE;gBACX,mHAAmH;gBACnH,IAAI,GAAG,CAAC,GAAG,MAAqB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;aAC3G;iBAAM;gBACH,mEAAmE;gBACnE,IAAI,GAAG,UAAU,CAAC;aACrB;SACJ;QAED,0EAA0E;QAC1E,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;QAE3B,wJAAwJ;QACxJ,0IAA0I;QAC1I,OAAO,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,cAAc,CAAC,MAAM,GAAG,UAAiD,SAAY;IACjF,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA0E,EAAE,EAAE,CACpH,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACnE,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Tags } from \"../Misc/tags\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Quaternion, Vector2, Vector3, Matrix } from \"../Maths/math.vector\";\r\nimport { _WarnImport } from \"./devTools\";\r\nimport type { IAnimatable } from \"../Animations/animatable.interface\";\r\nimport { Color4, Color3 } from \"../Maths/math.color\";\r\n\r\ndeclare type Scene = import(\"../scene\").Scene;\r\ndeclare type Camera = import(\"../Cameras/camera\").Camera;\r\n\r\ndeclare type ImageProcessingConfiguration = import(\"../Materials/imageProcessingConfiguration\").ImageProcessingConfiguration;\r\ndeclare type FresnelParameters = import(\"../Materials/fresnelParameters\").FresnelParameters;\r\ndeclare type ColorCurves = import(\"../Materials/colorCurves\").ColorCurves;\r\ndeclare type BaseTexture = import(\"../Materials/Textures/baseTexture\").BaseTexture;\r\n\r\nconst __decoratorInitialStore = {};\r\nconst __mergedStore = {};\r\n\r\nconst _copySource = function <T>(creationFunction: () => T, source: T, instanciate: boolean): T {\r\n const destination = creationFunction();\r\n\r\n // Tags\r\n if (Tags && Tags.HasTags(source)) {\r\n Tags.AddTagsTo(destination, Tags.GetTags(source, true));\r\n }\r\n\r\n const classStore = getMergedStore(destination);\r\n\r\n // Properties\r\n for (const property in classStore) {\r\n const propertyDescriptor = classStore[property];\r\n const sourceProperty = (<any>source)[property];\r\n const propertyType = propertyDescriptor.type;\r\n\r\n if (sourceProperty !== undefined && sourceProperty !== null && (property !== \"uniqueId\" || SerializationHelper.AllowLoadingUniqueId)) {\r\n switch (propertyType) {\r\n case 0: // Value\r\n case 6: // Mesh reference\r\n case 11: // Camera reference\r\n (<any>destination)[property] = sourceProperty;\r\n break;\r\n case 1: // Texture\r\n (<any>destination)[property] = instanciate || sourceProperty.isRenderTarget ? sourceProperty : sourceProperty.clone();\r\n break;\r\n case 2: // Color3\r\n case 3: // FresnelParameters\r\n case 4: // Vector2\r\n case 5: // Vector3\r\n case 7: // Color Curves\r\n case 10: // Quaternion\r\n case 12: // Matrix\r\n (<any>destination)[property] = instanciate ? sourceProperty : sourceProperty.clone();\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return destination;\r\n};\r\n\r\nfunction getDirectStore(target: any): any {\r\n const classKey = target.getClassName();\r\n\r\n if (!(<any>__decoratorInitialStore)[classKey]) {\r\n (<any>__decoratorInitialStore)[classKey] = {};\r\n }\r\n\r\n return (<any>__decoratorInitialStore)[classKey];\r\n}\r\n\r\n/**\r\n * Return the list of properties flagged as serializable\r\n * @param target host object\r\n */\r\nfunction getMergedStore(target: any): any {\r\n const classKey = target.getClassName();\r\n\r\n if ((<any>__mergedStore)[classKey]) {\r\n return (<any>__mergedStore)[classKey];\r\n }\r\n\r\n (<any>__mergedStore)[classKey] = {};\r\n\r\n const store = (<any>__mergedStore)[classKey];\r\n let currentTarget = target;\r\n let currentKey = classKey;\r\n while (currentKey) {\r\n const initialStore = (<any>__decoratorInitialStore)[currentKey];\r\n for (const property in initialStore) {\r\n store[property] = initialStore[property];\r\n }\r\n\r\n let parent: any;\r\n let done = false;\r\n\r\n do {\r\n parent = Object.getPrototypeOf(currentTarget);\r\n if (!parent.getClassName) {\r\n done = true;\r\n break;\r\n }\r\n\r\n if (parent.getClassName() !== currentKey) {\r\n break;\r\n }\r\n\r\n currentTarget = parent;\r\n } while (parent);\r\n\r\n if (done) {\r\n break;\r\n }\r\n\r\n currentKey = parent.getClassName();\r\n currentTarget = parent;\r\n }\r\n\r\n return store;\r\n}\r\n\r\nfunction generateSerializableMember(type: number, sourceName?: string) {\r\n return (target: any, propertyKey: string | symbol) => {\r\n const classStore = getDirectStore(target);\r\n\r\n if (!classStore[propertyKey]) {\r\n classStore[propertyKey] = { type: type, sourceName: sourceName };\r\n }\r\n };\r\n}\r\n\r\nfunction generateExpandMember(setCallback: string, targetKey: Nullable<string> = null) {\r\n return (target: any, propertyKey: string) => {\r\n const key = targetKey || \"_\" + propertyKey;\r\n Object.defineProperty(target, propertyKey, {\r\n get: function (this: any) {\r\n return this[key];\r\n },\r\n set: function (this: any, value) {\r\n // does this object (i.e. vector3) has an equals function? use it!\r\n // Note - not using \"with epsilon\" here, it is expected te behave like the internal cache does.\r\n if (typeof this.equals === \"function\") {\r\n if (this.equals(value)) {\r\n return;\r\n }\r\n }\r\n if (this[key] === value) {\r\n return;\r\n }\r\n this[key] = value;\r\n\r\n target[setCallback].apply(this);\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n });\r\n };\r\n}\r\n\r\nexport function expandToProperty(callback: string, targetKey: Nullable<string> = null) {\r\n return generateExpandMember(callback, targetKey);\r\n}\r\n\r\nexport function serialize(sourceName?: string) {\r\n return generateSerializableMember(0, sourceName); // value member\r\n}\r\n\r\nexport function serializeAsTexture(sourceName?: string) {\r\n return generateSerializableMember(1, sourceName); // texture member\r\n}\r\n\r\nexport function serializeAsColor3(sourceName?: string) {\r\n return generateSerializableMember(2, sourceName); // color3 member\r\n}\r\n\r\nexport function serializeAsFresnelParameters(sourceName?: string) {\r\n return generateSerializableMember(3, sourceName); // fresnel parameters member\r\n}\r\n\r\nexport function serializeAsVector2(sourceName?: string) {\r\n return generateSerializableMember(4, sourceName); // vector2 member\r\n}\r\n\r\nexport function serializeAsVector3(sourceName?: string) {\r\n return generateSerializableMember(5, sourceName); // vector3 member\r\n}\r\n\r\nexport function serializeAsMeshReference(sourceName?: string) {\r\n return generateSerializableMember(6, sourceName); // mesh reference member\r\n}\r\n\r\nexport function serializeAsColorCurves(sourceName?: string) {\r\n return generateSerializableMember(7, sourceName); // color curves\r\n}\r\n\r\nexport function serializeAsColor4(sourceName?: string) {\r\n return generateSerializableMember(8, sourceName); // color 4\r\n}\r\n\r\nexport function serializeAsImageProcessingConfiguration(sourceName?: string) {\r\n return generateSerializableMember(9, sourceName); // image processing\r\n}\r\n\r\nexport function serializeAsQuaternion(sourceName?: string) {\r\n return generateSerializableMember(10, sourceName); // quaternion member\r\n}\r\n\r\nexport function serializeAsMatrix(sourceName?: string) {\r\n return generateSerializableMember(12, sourceName); // matrix member\r\n}\r\n\r\n/**\r\n * Decorator used to define property that can be serialized as reference to a camera\r\n * @param sourceName defines the name of the property to decorate\r\n */\r\nexport function serializeAsCameraReference(sourceName?: string) {\r\n return generateSerializableMember(11, sourceName); // camera reference member\r\n}\r\n\r\n/**\r\n * Class used to help serialization objects\r\n */\r\nexport class SerializationHelper {\r\n /**\r\n * Gets or sets a boolean to indicate if the UniqueId property should be serialized\r\n */\r\n public static AllowLoadingUniqueId = false;\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _ImageProcessingConfigurationParser = (sourceProperty: any): ImageProcessingConfiguration => {\r\n throw _WarnImport(\"ImageProcessingConfiguration\");\r\n };\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _FresnelParametersParser = (sourceProperty: any): FresnelParameters => {\r\n throw _WarnImport(\"FresnelParameters\");\r\n };\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _ColorCurvesParser = (sourceProperty: any): ColorCurves => {\r\n throw _WarnImport(\"ColorCurves\");\r\n };\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _TextureParser = (sourceProperty: any, scene: Scene, rootUrl: string): Nullable<BaseTexture> => {\r\n throw _WarnImport(\"Texture\");\r\n };\r\n\r\n /**\r\n * Appends the serialized animations from the source animations\r\n * @param source Source containing the animations\r\n * @param destination Target to store the animations\r\n */\r\n public static AppendSerializedAnimations(source: IAnimatable, destination: any): void {\r\n if (source.animations) {\r\n destination.animations = [];\r\n for (let animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {\r\n const animation = source.animations[animationIndex];\r\n\r\n destination.animations.push(animation.serialize());\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Static function used to serialized a specific entity\r\n * @param entity defines the entity to serialize\r\n * @param serializationObject defines the optional target object where serialization data will be stored\r\n * @returns a JSON compatible object representing the serialization of the entity\r\n */\r\n public static Serialize<T>(entity: T, serializationObject?: any): any {\r\n if (!serializationObject) {\r\n serializationObject = {};\r\n }\r\n\r\n // Tags\r\n if (Tags) {\r\n serializationObject.tags = Tags.GetTags(entity);\r\n }\r\n\r\n const serializedProperties = getMergedStore(entity);\r\n\r\n // Properties\r\n for (const property in serializedProperties) {\r\n const propertyDescriptor = serializedProperties[property];\r\n const targetPropertyName = propertyDescriptor.sourceName || property;\r\n const propertyType = propertyDescriptor.type;\r\n const sourceProperty = (<any>entity)[property];\r\n\r\n if (sourceProperty !== undefined && sourceProperty !== null && (property !== \"uniqueId\" || SerializationHelper.AllowLoadingUniqueId)) {\r\n switch (propertyType) {\r\n case 0: // Value\r\n serializationObject[targetPropertyName] = sourceProperty;\r\n break;\r\n case 1: // Texture\r\n serializationObject[targetPropertyName] = sourceProperty.serialize();\r\n break;\r\n case 2: // Color3\r\n serializationObject[targetPropertyName] = sourceProperty.asArray();\r\n break;\r\n case 3: // FresnelParameters\r\n serializationObject[targetPropertyName] = sourceProperty.serialize();\r\n break;\r\n case 4: // Vector2\r\n serializationObject[targetPropertyName] = sourceProperty.asArray();\r\n break;\r\n case 5: // Vector3\r\n serializationObject[targetPropertyName] = sourceProperty.asArray();\r\n break;\r\n case 6: // Mesh reference\r\n serializationObject[targetPropertyName] = sourceProperty.id;\r\n break;\r\n case 7: // Color Curves\r\n serializationObject[targetPropertyName] = sourceProperty.serialize();\r\n break;\r\n case 8: // Color 4\r\n serializationObject[targetPropertyName] = (<Color4>sourceProperty).asArray();\r\n break;\r\n case 9: // Image Processing\r\n serializationObject[targetPropertyName] = (<ImageProcessingConfiguration>sourceProperty).serialize();\r\n break;\r\n case 10: // Quaternion\r\n serializationObject[targetPropertyName] = (<Quaternion>sourceProperty).asArray();\r\n break;\r\n case 11: // Camera reference\r\n serializationObject[targetPropertyName] = (<Camera>sourceProperty).id;\r\n break;\r\n case 12: // Matrix\r\n serializationObject[targetPropertyName] = (<Matrix>sourceProperty).asArray();\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Given a source json and a destination object in a scene, this function will parse the source and will try to apply its content to the destination object\r\n * @param source the source json data\r\n * @param destination the destination object\r\n * @param scene the scene where the object is\r\n * @param rootUrl root url to use to load assets\r\n */\r\n public static ParseProperties(source: any, destination: any, scene: Nullable<Scene>, rootUrl: Nullable<string>) {\r\n if (!rootUrl) {\r\n rootUrl = \"\";\r\n }\r\n\r\n const classStore = getMergedStore(destination);\r\n\r\n // Properties\r\n for (const property in classStore) {\r\n const propertyDescriptor = classStore[property];\r\n const sourceProperty = source[propertyDescriptor.sourceName || property];\r\n const propertyType = propertyDescriptor.type;\r\n\r\n if (sourceProperty !== undefined && sourceProperty !== null && (property !== \"uniqueId\" || SerializationHelper.AllowLoadingUniqueId)) {\r\n const dest = <any>destination;\r\n switch (propertyType) {\r\n case 0: // Value\r\n dest[property] = sourceProperty;\r\n break;\r\n case 1: // Texture\r\n if (scene) {\r\n dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);\r\n }\r\n break;\r\n case 2: // Color3\r\n dest[property] = Color3.FromArray(sourceProperty);\r\n break;\r\n case 3: // FresnelParameters\r\n dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);\r\n break;\r\n case 4: // Vector2\r\n dest[property] = Vector2.FromArray(sourceProperty);\r\n break;\r\n case 5: // Vector3\r\n dest[property] = Vector3.FromArray(sourceProperty);\r\n break;\r\n case 6: // Mesh reference\r\n if (scene) {\r\n dest[property] = scene.getLastMeshById(sourceProperty);\r\n }\r\n break;\r\n case 7: // Color Curves\r\n dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);\r\n break;\r\n case 8: // Color 4\r\n dest[property] = Color4.FromArray(sourceProperty);\r\n break;\r\n case 9: // Image Processing\r\n dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);\r\n break;\r\n case 10: // Quaternion\r\n dest[property] = Quaternion.FromArray(sourceProperty);\r\n break;\r\n case 11: // Camera reference\r\n if (scene) {\r\n dest[property] = scene.getCameraById(sourceProperty);\r\n }\r\n break;\r\n case 12: // Matrix\r\n dest[property] = Matrix.FromArray(sourceProperty);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new entity from a serialization data object\r\n * @param creationFunction defines a function used to instanciated the new entity\r\n * @param source defines the source serialization data\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root url for resources\r\n * @returns a new entity\r\n */\r\n public static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl: Nullable<string> = null): T {\r\n const destination = creationFunction();\r\n\r\n // Tags\r\n if (Tags) {\r\n Tags.AddTagsTo(destination, source.tags);\r\n }\r\n\r\n SerializationHelper.ParseProperties(source, destination, scene, rootUrl);\r\n\r\n return destination;\r\n }\r\n\r\n /**\r\n * Clones an object\r\n * @param creationFunction defines the function used to instanciate the new object\r\n * @param source defines the source object\r\n * @returns the cloned object\r\n */\r\n public static Clone<T>(creationFunction: () => T, source: T): T {\r\n return _copySource(creationFunction, source, false);\r\n }\r\n\r\n /**\r\n * Instanciates a new object based on a source one (some data will be shared between both object)\r\n * @param creationFunction defines the function used to instanciate the new object\r\n * @param source defines the source object\r\n * @returns the new object\r\n */\r\n public static Instanciate<T>(creationFunction: () => T, source: T): T {\r\n return _copySource(creationFunction, source, true);\r\n }\r\n}\r\n\r\n/** @internal */\r\ndeclare const _native: any;\r\n\r\n/**\r\n * Decorator used to redirect a function to a native implementation if available.\r\n * @internal\r\n */\r\nexport function nativeOverride<T extends (...params: any[]) => boolean>(\r\n target: any,\r\n propertyKey: string,\r\n descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => unknown>,\r\n predicate?: T\r\n) {\r\n // Cache the original JS function for later.\r\n const jsFunc = descriptor.value!;\r\n\r\n // Override the JS function to check for a native override on first invocation. Setting descriptor.value overrides the function at the early stage of code being loaded/imported.\r\n descriptor.value = (...params: Parameters<T>): unknown => {\r\n // Assume the resolved function will be the original JS function, then we will check for the Babylon Native context.\r\n let func = jsFunc;\r\n\r\n // Check if we are executing in a Babylon Native context (e.g. check the presence of the _native global property) and if so also check if a function override is available.\r\n if (typeof _native !== \"undefined\" && _native[propertyKey]) {\r\n const nativeFunc = _native[propertyKey] as (...params: Parameters<T>) => unknown;\r\n // If a predicate was provided, then we'll need to invoke the predicate on each invocation of the underlying function to determine whether to call the native function or the JS function.\r\n if (predicate) {\r\n // The resolved function will execute the predicate and then either execute the native function or the JS function.\r\n func = (...params: Parameters<T>) => (predicate(...params) ? nativeFunc(...params) : jsFunc(...params));\r\n } else {\r\n // The resolved function will directly execute the native function.\r\n func = nativeFunc;\r\n }\r\n }\r\n\r\n // Override the JS function again with the final resolved target function.\r\n target[propertyKey] = func;\r\n\r\n // The JS function has now been overridden based on whether we're executing in the context of Babylon Native, but we still need to invoke that function.\r\n // Future invocations of the function will just directly invoke the final overridden function, not any of the decorator setup logic above.\r\n return func(...params);\r\n };\r\n}\r\n\r\n/**\r\n * Decorator factory that applies the nativeOverride decorator, but determines whether to redirect to the native implementation based on a filter function that evaluates the function arguments.\r\n * @param predicate\r\n * @example @nativeOverride.filter((...[arg1]: Parameters<typeof someClass.someMethod>) => arg1.length > 20)\r\n * public someMethod(arg1: string, arg2: number): string {\r\n * @internal\r\n */\r\nnativeOverride.filter = function <T extends (...params: any) => boolean>(predicate: T) {\r\n return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => unknown>) =>\r\n nativeOverride(target, propertyKey, descriptor, predicate);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/decorators.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,yDAAyD;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAUrD,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,aAAa,GAAG,EAAE,CAAC;AAWzB,MAAM,WAAW,GAAG,UAAa,gBAAyB,EAAE,MAAS,EAAE,WAAoB,EAAE,UAA6B,EAAE;IACxH,MAAM,WAAW,GAAG,gBAAgB,EAAE,CAAC;IAEvC,OAAO;IACP,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC9B,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;KAC3D;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,WAAW,C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QACrD,oHAAoH;QACpH,IAAI,IAAI,GAAG,MAAM,CAAC;QAElB,2KAA2K;QAC3K,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,EAAE;YACxD,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAA0C,CAAC;YACjF,0LAA0L;YAC1L,IAAI,SAAS,EAAE;gBACX,mHAAmH;gBACnH,IAAI,GAAG,CAAC,GAAG,MAAqB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;aAC3G;iBAAM;gBACH,mEAAmE;gBACnE,IAAI,GAAG,UAAU,CAAC;aACrB;SACJ;QAED,0EAA0E;QAC1E,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;QAE3B,wJAAwJ;QACxJ,0IAA0I;QAC1I,OAAO,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,cAAc,CAAC,MAAM,GAAG,UAAiD,SAAY;IACjF,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA0E,EAAE,EAAE,CACpH,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACnE,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Tags } from \"../Misc/tags\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Quaternion, Vector2, Vector3, Matrix } from \"../Maths/math.vector\";\r\nimport { _WarnImport } from \"./devTools\";\r\nimport type { IAnimatable } from \"../Animations/animatable.interface\";\r\nimport { Color4, Color3 } from \"../Maths/math.color\";\r\n\r\ndeclare type Scene = import(\"../scene\").Scene;\r\ndeclare type Camera = import(\"../Cameras/camera\").Camera;\r\n\r\ndeclare type ImageProcessingConfiguration = import(\"../Materials/imageProcessingConfiguration\").ImageProcessingConfiguration;\r\ndeclare type FresnelParameters = import(\"../Materials/fresnelParameters\").FresnelParameters;\r\ndeclare type ColorCurves = import(\"../Materials/colorCurves\").ColorCurves;\r\ndeclare type BaseTexture = import(\"../Materials/Textures/baseTexture\").BaseTexture;\r\n\r\nconst __decoratorInitialStore = {};\r\nconst __mergedStore = {};\r\n\r\n/** @internal */\r\nexport interface CopySourceOptions {\r\n /*\r\n * if a texture is used in more than one channel (e.g diffuse and opacity),\r\n * only clone it once and reuse it on the other channels. Default false\r\n */\r\n cloneTexturesOnlyOnce?: boolean;\r\n}\r\n\r\nconst _copySource = function <T>(creationFunction: () => T, source: T, instanciate: boolean, options: CopySourceOptions = {}): T {\r\n const destination = creationFunction();\r\n\r\n // Tags\r\n if (Tags && Tags.HasTags(source)) {\r\n Tags.AddTagsTo(destination, Tags.GetTags(source, true));\r\n }\r\n\r\n const classStore = getMergedStore(destination);\r\n\r\n // Map from source texture uniqueId to destination texture\r\n const textureMap: Record<number, any> = {};\r\n\r\n // Properties\r\n for (const property in classStore) {\r\n const propertyDescriptor = classStore[property];\r\n const sourceProperty = (<any>source)[property];\r\n const propertyType = propertyDescriptor.type;\r\n\r\n if (sourceProperty !== undefined && sourceProperty !== null && (property !== \"uniqueId\" || SerializationHelper.AllowLoadingUniqueId)) {\r\n switch (propertyType) {\r\n case 0: // Value\r\n case 6: // Mesh reference\r\n case 11: // Camera reference\r\n (<any>destination)[property] = sourceProperty;\r\n break;\r\n case 1: // Texture\r\n if (options.cloneTexturesOnlyOnce && textureMap[sourceProperty.uniqueId]) {\r\n (<any>destination)[property] = textureMap[sourceProperty.uniqueId];\r\n } else {\r\n (<any>destination)[property] = instanciate || sourceProperty.isRenderTarget ? sourceProperty : sourceProperty.clone();\r\n textureMap[sourceProperty.uniqueId] = (<any>destination)[property];\r\n }\r\n break;\r\n case 2: // Color3\r\n case 3: // FresnelParameters\r\n case 4: // Vector2\r\n case 5: // Vector3\r\n case 7: // Color Curves\r\n case 10: // Quaternion\r\n case 12: // Matrix\r\n (<any>destination)[property] = instanciate ? sourceProperty : sourceProperty.clone();\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return destination;\r\n};\r\n\r\nfunction getDirectStore(target: any): any {\r\n const classKey = target.getClassName();\r\n\r\n if (!(<any>__decoratorInitialStore)[classKey]) {\r\n (<any>__decoratorInitialStore)[classKey] = {};\r\n }\r\n\r\n return (<any>__decoratorInitialStore)[classKey];\r\n}\r\n\r\n/**\r\n * Return the list of properties flagged as serializable\r\n * @param target host object\r\n */\r\nfunction getMergedStore(target: any): any {\r\n const classKey = target.getClassName();\r\n\r\n if ((<any>__mergedStore)[classKey]) {\r\n return (<any>__mergedStore)[classKey];\r\n }\r\n\r\n (<any>__mergedStore)[classKey] = {};\r\n\r\n const store = (<any>__mergedStore)[classKey];\r\n let currentTarget = target;\r\n let currentKey = classKey;\r\n while (currentKey) {\r\n const initialStore = (<any>__decoratorInitialStore)[currentKey];\r\n for (const property in initialStore) {\r\n store[property] = initialStore[property];\r\n }\r\n\r\n let parent: any;\r\n let done = false;\r\n\r\n do {\r\n parent = Object.getPrototypeOf(currentTarget);\r\n if (!parent.getClassName) {\r\n done = true;\r\n break;\r\n }\r\n\r\n if (parent.getClassName() !== currentKey) {\r\n break;\r\n }\r\n\r\n currentTarget = parent;\r\n } while (parent);\r\n\r\n if (done) {\r\n break;\r\n }\r\n\r\n currentKey = parent.getClassName();\r\n currentTarget = parent;\r\n }\r\n\r\n return store;\r\n}\r\n\r\nfunction generateSerializableMember(type: number, sourceName?: string) {\r\n return (target: any, propertyKey: string | symbol) => {\r\n const classStore = getDirectStore(target);\r\n\r\n if (!classStore[propertyKey]) {\r\n classStore[propertyKey] = { type: type, sourceName: sourceName };\r\n }\r\n };\r\n}\r\n\r\nfunction generateExpandMember(setCallback: string, targetKey: Nullable<string> = null) {\r\n return (target: any, propertyKey: string) => {\r\n const key = targetKey || \"_\" + propertyKey;\r\n Object.defineProperty(target, propertyKey, {\r\n get: function (this: any) {\r\n return this[key];\r\n },\r\n set: function (this: any, value) {\r\n // does this object (i.e. vector3) has an equals function? use it!\r\n // Note - not using \"with epsilon\" here, it is expected te behave like the internal cache does.\r\n if (typeof this.equals === \"function\") {\r\n if (this.equals(value)) {\r\n return;\r\n }\r\n }\r\n if (this[key] === value) {\r\n return;\r\n }\r\n this[key] = value;\r\n\r\n target[setCallback].apply(this);\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n });\r\n };\r\n}\r\n\r\nexport function expandToProperty(callback: string, targetKey: Nullable<string> = null) {\r\n return generateExpandMember(callback, targetKey);\r\n}\r\n\r\nexport function serialize(sourceName?: string) {\r\n return generateSerializableMember(0, sourceName); // value member\r\n}\r\n\r\nexport function serializeAsTexture(sourceName?: string) {\r\n return generateSerializableMember(1, sourceName); // texture member\r\n}\r\n\r\nexport function serializeAsColor3(sourceName?: string) {\r\n return generateSerializableMember(2, sourceName); // color3 member\r\n}\r\n\r\nexport function serializeAsFresnelParameters(sourceName?: string) {\r\n return generateSerializableMember(3, sourceName); // fresnel parameters member\r\n}\r\n\r\nexport function serializeAsVector2(sourceName?: string) {\r\n return generateSerializableMember(4, sourceName); // vector2 member\r\n}\r\n\r\nexport function serializeAsVector3(sourceName?: string) {\r\n return generateSerializableMember(5, sourceName); // vector3 member\r\n}\r\n\r\nexport function serializeAsMeshReference(sourceName?: string) {\r\n return generateSerializableMember(6, sourceName); // mesh reference member\r\n}\r\n\r\nexport function serializeAsColorCurves(sourceName?: string) {\r\n return generateSerializableMember(7, sourceName); // color curves\r\n}\r\n\r\nexport function serializeAsColor4(sourceName?: string) {\r\n return generateSerializableMember(8, sourceName); // color 4\r\n}\r\n\r\nexport function serializeAsImageProcessingConfiguration(sourceName?: string) {\r\n return generateSerializableMember(9, sourceName); // image processing\r\n}\r\n\r\nexport function serializeAsQuaternion(sourceName?: string) {\r\n return generateSerializableMember(10, sourceName); // quaternion member\r\n}\r\n\r\nexport function serializeAsMatrix(sourceName?: string) {\r\n return generateSerializableMember(12, sourceName); // matrix member\r\n}\r\n\r\n/**\r\n * Decorator used to define property that can be serialized as reference to a camera\r\n * @param sourceName defines the name of the property to decorate\r\n */\r\nexport function serializeAsCameraReference(sourceName?: string) {\r\n return generateSerializableMember(11, sourceName); // camera reference member\r\n}\r\n\r\n/**\r\n * Class used to help serialization objects\r\n */\r\nexport class SerializationHelper {\r\n /**\r\n * Gets or sets a boolean to indicate if the UniqueId property should be serialized\r\n */\r\n public static AllowLoadingUniqueId = false;\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _ImageProcessingConfigurationParser = (sourceProperty: any): ImageProcessingConfiguration => {\r\n throw _WarnImport(\"ImageProcessingConfiguration\");\r\n };\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _FresnelParametersParser = (sourceProperty: any): FresnelParameters => {\r\n throw _WarnImport(\"FresnelParameters\");\r\n };\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _ColorCurvesParser = (sourceProperty: any): ColorCurves => {\r\n throw _WarnImport(\"ColorCurves\");\r\n };\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _TextureParser = (sourceProperty: any, scene: Scene, rootUrl: string): Nullable<BaseTexture> => {\r\n throw _WarnImport(\"Texture\");\r\n };\r\n\r\n /**\r\n * Appends the serialized animations from the source animations\r\n * @param source Source containing the animations\r\n * @param destination Target to store the animations\r\n */\r\n public static AppendSerializedAnimations(source: IAnimatable, destination: any): void {\r\n if (source.animations) {\r\n destination.animations = [];\r\n for (let animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {\r\n const animation = source.animations[animationIndex];\r\n\r\n destination.animations.push(animation.serialize());\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Static function used to serialized a specific entity\r\n * @param entity defines the entity to serialize\r\n * @param serializationObject defines the optional target object where serialization data will be stored\r\n * @returns a JSON compatible object representing the serialization of the entity\r\n */\r\n public static Serialize<T>(entity: T, serializationObject?: any): any {\r\n if (!serializationObject) {\r\n serializationObject = {};\r\n }\r\n\r\n // Tags\r\n if (Tags) {\r\n serializationObject.tags = Tags.GetTags(entity);\r\n }\r\n\r\n const serializedProperties = getMergedStore(entity);\r\n\r\n // Properties\r\n for (const property in serializedProperties) {\r\n const propertyDescriptor = serializedProperties[property];\r\n const targetPropertyName = propertyDescriptor.sourceName || property;\r\n const propertyType = propertyDescriptor.type;\r\n const sourceProperty = (<any>entity)[property];\r\n\r\n if (sourceProperty !== undefined && sourceProperty !== null && (property !== \"uniqueId\" || SerializationHelper.AllowLoadingUniqueId)) {\r\n switch (propertyType) {\r\n case 0: // Value\r\n serializationObject[targetPropertyName] = sourceProperty;\r\n break;\r\n case 1: // Texture\r\n serializationObject[targetPropertyName] = sourceProperty.serialize();\r\n break;\r\n case 2: // Color3\r\n serializationObject[targetPropertyName] = sourceProperty.asArray();\r\n break;\r\n case 3: // FresnelParameters\r\n serializationObject[targetPropertyName] = sourceProperty.serialize();\r\n break;\r\n case 4: // Vector2\r\n serializationObject[targetPropertyName] = sourceProperty.asArray();\r\n break;\r\n case 5: // Vector3\r\n serializationObject[targetPropertyName] = sourceProperty.asArray();\r\n break;\r\n case 6: // Mesh reference\r\n serializationObject[targetPropertyName] = sourceProperty.id;\r\n break;\r\n case 7: // Color Curves\r\n serializationObject[targetPropertyName] = sourceProperty.serialize();\r\n break;\r\n case 8: // Color 4\r\n serializationObject[targetPropertyName] = (<Color4>sourceProperty).asArray();\r\n break;\r\n case 9: // Image Processing\r\n serializationObject[targetPropertyName] = (<ImageProcessingConfiguration>sourceProperty).serialize();\r\n break;\r\n case 10: // Quaternion\r\n serializationObject[targetPropertyName] = (<Quaternion>sourceProperty).asArray();\r\n break;\r\n case 11: // Camera reference\r\n serializationObject[targetPropertyName] = (<Camera>sourceProperty).id;\r\n break;\r\n case 12: // Matrix\r\n serializationObject[targetPropertyName] = (<Matrix>sourceProperty).asArray();\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Given a source json and a destination object in a scene, this function will parse the source and will try to apply its content to the destination object\r\n * @param source the source json data\r\n * @param destination the destination object\r\n * @param scene the scene where the object is\r\n * @param rootUrl root url to use to load assets\r\n */\r\n public static ParseProperties(source: any, destination: any, scene: Nullable<Scene>, rootUrl: Nullable<string>) {\r\n if (!rootUrl) {\r\n rootUrl = \"\";\r\n }\r\n\r\n const classStore = getMergedStore(destination);\r\n\r\n // Properties\r\n for (const property in classStore) {\r\n const propertyDescriptor = classStore[property];\r\n const sourceProperty = source[propertyDescriptor.sourceName || property];\r\n const propertyType = propertyDescriptor.type;\r\n\r\n if (sourceProperty !== undefined && sourceProperty !== null && (property !== \"uniqueId\" || SerializationHelper.AllowLoadingUniqueId)) {\r\n const dest = <any>destination;\r\n switch (propertyType) {\r\n case 0: // Value\r\n dest[property] = sourceProperty;\r\n break;\r\n case 1: // Texture\r\n if (scene) {\r\n dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);\r\n }\r\n break;\r\n case 2: // Color3\r\n dest[property] = Color3.FromArray(sourceProperty);\r\n break;\r\n case 3: // FresnelParameters\r\n dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);\r\n break;\r\n case 4: // Vector2\r\n dest[property] = Vector2.FromArray(sourceProperty);\r\n break;\r\n case 5: // Vector3\r\n dest[property] = Vector3.FromArray(sourceProperty);\r\n break;\r\n case 6: // Mesh reference\r\n if (scene) {\r\n dest[property] = scene.getLastMeshById(sourceProperty);\r\n }\r\n break;\r\n case 7: // Color Curves\r\n dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);\r\n break;\r\n case 8: // Color 4\r\n dest[property] = Color4.FromArray(sourceProperty);\r\n break;\r\n case 9: // Image Processing\r\n dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);\r\n break;\r\n case 10: // Quaternion\r\n dest[property] = Quaternion.FromArray(sourceProperty);\r\n break;\r\n case 11: // Camera reference\r\n if (scene) {\r\n dest[property] = scene.getCameraById(sourceProperty);\r\n }\r\n break;\r\n case 12: // Matrix\r\n dest[property] = Matrix.FromArray(sourceProperty);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new entity from a serialization data object\r\n * @param creationFunction defines a function used to instanciated the new entity\r\n * @param source defines the source serialization data\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root url for resources\r\n * @returns a new entity\r\n */\r\n public static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl: Nullable<string> = null): T {\r\n const destination = creationFunction();\r\n\r\n // Tags\r\n if (Tags) {\r\n Tags.AddTagsTo(destination, source.tags);\r\n }\r\n\r\n SerializationHelper.ParseProperties(source, destination, scene, rootUrl);\r\n\r\n return destination;\r\n }\r\n\r\n /**\r\n * Clones an object\r\n * @param creationFunction defines the function used to instanciate the new object\r\n * @param source defines the source object\r\n * @returns the cloned object\r\n */\r\n public static Clone<T>(creationFunction: () => T, source: T, options: CopySourceOptions = {}): T {\r\n return _copySource(creationFunction, source, false, options);\r\n }\r\n\r\n /**\r\n * Instanciates a new object based on a source one (some data will be shared between both object)\r\n * @param creationFunction defines the function used to instanciate the new object\r\n * @param source defines the source object\r\n * @returns the new object\r\n */\r\n public static Instanciate<T>(creationFunction: () => T, source: T): T {\r\n return _copySource(creationFunction, source, true);\r\n }\r\n}\r\n\r\n/** @internal */\r\ndeclare const _native: any;\r\n\r\n/**\r\n * Decorator used to redirect a function to a native implementation if available.\r\n * @internal\r\n */\r\nexport function nativeOverride<T extends (...params: any[]) => boolean>(\r\n target: any,\r\n propertyKey: string,\r\n descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => unknown>,\r\n predicate?: T\r\n) {\r\n // Cache the original JS function for later.\r\n const jsFunc = descriptor.value!;\r\n\r\n // Override the JS function to check for a native override on first invocation. Setting descriptor.value overrides the function at the early stage of code being loaded/imported.\r\n descriptor.value = (...params: Parameters<T>): unknown => {\r\n // Assume the resolved function will be the original JS function, then we will check for the Babylon Native context.\r\n let func = jsFunc;\r\n\r\n // Check if we are executing in a Babylon Native context (e.g. check the presence of the _native global property) and if so also check if a function override is available.\r\n if (typeof _native !== \"undefined\" && _native[propertyKey]) {\r\n const nativeFunc = _native[propertyKey] as (...params: Parameters<T>) => unknown;\r\n // If a predicate was provided, then we'll need to invoke the predicate on each invocation of the underlying function to determine whether to call the native function or the JS function.\r\n if (predicate) {\r\n // The resolved function will execute the predicate and then either execute the native function or the JS function.\r\n func = (...params: Parameters<T>) => (predicate(...params) ? nativeFunc(...params) : jsFunc(...params));\r\n } else {\r\n // The resolved function will directly execute the native function.\r\n func = nativeFunc;\r\n }\r\n }\r\n\r\n // Override the JS function again with the final resolved target function.\r\n target[propertyKey] = func;\r\n\r\n // The JS function has now been overridden based on whether we're executing in the context of Babylon Native, but we still need to invoke that function.\r\n // Future invocations of the function will just directly invoke the final overridden function, not any of the decorator setup logic above.\r\n return func(...params);\r\n };\r\n}\r\n\r\n/**\r\n * Decorator factory that applies the nativeOverride decorator, but determines whether to redirect to the native implementation based on a filter function that evaluates the function arguments.\r\n * @param predicate\r\n * @example @nativeOverride.filter((...[arg1]: Parameters<typeof someClass.someMethod>) => arg1.length > 20)\r\n * public someMethod(arg1: string, arg2: number): string {\r\n * @internal\r\n */\r\nnativeOverride.filter = function <T extends (...params: any) => boolean>(predicate: T) {\r\n return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => unknown>) =>\r\n nativeOverride(target, propertyKey, descriptor, predicate);\r\n};\r\n"]}
|
package/Misc/error.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const ErrorCodes: {
|
|
|
28
28
|
/**
|
|
29
29
|
* Error code type
|
|
30
30
|
*/
|
|
31
|
-
export type ErrorCodesType = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
31
|
+
export type ErrorCodesType = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
32
32
|
/**
|
|
33
33
|
* Application runtime error
|
|
34
34
|
*/
|
package/Misc/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/error.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD;;;;GAIG;AACH,MAAM,OAAgB,SAAU,SAAQ,KAAK;;AACzC,yGAAyG;AACzG,oIAAoI;AAEpI,mDAAmD;AAClC,yBAAe,GAC3B,MAAc,CAAC,cAAc;IAC9B,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;QACV,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC;QACpB,OAAO,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;AAGX,8DAA8D;AAC9D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,oBAAoB;IACpB,8CAA8C;IAC9C,yBAAyB,EAAE,CAAC;IAE5B,2BAA2B;IAC3B,iCAAiC;IACjC,uBAAuB,EAAE,IAAI;IAE7B,8BAA8B;IAC9B,yDAAyD;IACzD,8BAA8B,EAAE,IAAI;IAEpC,+BAA+B;IAC/B,yEAAyE;IACzE,gBAAgB,EAAE,IAAI;IAEtB,gCAAgC;IAChC,sBAAsB;IACtB,aAAa,EAAE,IAAI;IACnB,yBAAyB;IACzB,gBAAgB,EAAE,IAAI;IACtB,sBAAsB;IACtB,aAAa,EAAE,IAAI;CACb,CAAC;AAOX;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IAWvC;;;;;OAKG;IACH,YAAmB,OAAe,EAAE,SAAyB,EAAE,UAAkB;QAC7E,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\n/**\r\n * Base error. Due to limitations of typedoc-check and missing documentation\r\n * in lib.es5.d.ts, cannot extend Error directly for RuntimeError.\r\n * @ignore\r\n */\r\nexport abstract class BaseError extends Error {\r\n // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript\r\n // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work\r\n\r\n // Polyfill for Object.setPrototypeOf if necessary.\r\n protected static _setPrototypeOf: (o: any, proto: object | null) => any =\r\n (Object as any).setPrototypeOf ||\r\n ((o, proto) => {\r\n o.__proto__ = proto;\r\n return o;\r\n });\r\n}\r\n\r\n/* IMP! DO NOT CHANGE THE NUMBERING OF EXISTING ERROR CODES */\r\n/**\r\n * Error codes for BaseError\r\n */\r\nexport const ErrorCodes = {\r\n // Mesh errors 0-999\r\n /** Invalid or empty mesh vertex positions. */\r\n MeshInvalidPositionsError: 0,\r\n\r\n // Texture errors 1000-1999\r\n /** Unsupported texture found. */\r\n UnsupportedTextureError: 1000,\r\n\r\n // GLTFLoader errors 2000-2999\r\n /** Unexpected magic number found in GLTF file header. */\r\n GLTFLoaderUnexpectedMagicError: 2000,\r\n\r\n // SceneLoader errors 3000-3999\r\n /** SceneLoader generic error code. Ideally wraps the inner exception. */\r\n SceneLoaderError: 3000,\r\n\r\n // File related errors 4000-4999\r\n /** Load file error */\r\n LoadFileError: 4000,\r\n /** Request file error */\r\n RequestFileError: 4001,\r\n /** Read file error */\r\n ReadFileError: 4002,\r\n} as const;\r\n\r\n/**\r\n * Error code type\r\n */\r\nexport type ErrorCodesType = typeof ErrorCodes[keyof typeof ErrorCodes];\r\n\r\n/**\r\n * Application runtime error\r\n */\r\nexport class RuntimeError extends BaseError {\r\n /**\r\n * The error code\r\n */\r\n public errorCode: ErrorCodesType;\r\n\r\n /**\r\n * The error that caused this outer error\r\n */\r\n public innerError?: Error;\r\n\r\n /**\r\n * Creates a new RuntimeError\r\n * @param message defines the message of the error\r\n * @param errorCode the error code\r\n * @param innerError the error that caused the outer error\r\n */\r\n public constructor(message: string, errorCode: ErrorCodesType, innerError?: Error) {\r\n super(message);\r\n\r\n this.errorCode = errorCode;\r\n this.innerError = innerError;\r\n\r\n this.name = \"RuntimeError\";\r\n BaseError._setPrototypeOf(this, RuntimeError.prototype);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/error.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD;;;;GAIG;AACH,MAAM,OAAgB,SAAU,SAAQ,KAAK;;AACzC,yGAAyG;AACzG,oIAAoI;AAEpI,mDAAmD;AAClC,yBAAe,GAC3B,MAAc,CAAC,cAAc;IAC9B,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;QACV,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC;QACpB,OAAO,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;AAGX,8DAA8D;AAC9D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,oBAAoB;IACpB,8CAA8C;IAC9C,yBAAyB,EAAE,CAAC;IAE5B,2BAA2B;IAC3B,iCAAiC;IACjC,uBAAuB,EAAE,IAAI;IAE7B,8BAA8B;IAC9B,yDAAyD;IACzD,8BAA8B,EAAE,IAAI;IAEpC,+BAA+B;IAC/B,yEAAyE;IACzE,gBAAgB,EAAE,IAAI;IAEtB,gCAAgC;IAChC,sBAAsB;IACtB,aAAa,EAAE,IAAI;IACnB,yBAAyB;IACzB,gBAAgB,EAAE,IAAI;IACtB,sBAAsB;IACtB,aAAa,EAAE,IAAI;CACb,CAAC;AAOX;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IAWvC;;;;;OAKG;IACH,YAAmB,OAAe,EAAE,SAAyB,EAAE,UAAkB;QAC7E,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\n/**\r\n * Base error. Due to limitations of typedoc-check and missing documentation\r\n * in lib.es5.d.ts, cannot extend Error directly for RuntimeError.\r\n * @ignore\r\n */\r\nexport abstract class BaseError extends Error {\r\n // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript\r\n // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work\r\n\r\n // Polyfill for Object.setPrototypeOf if necessary.\r\n protected static _setPrototypeOf: (o: any, proto: object | null) => any =\r\n (Object as any).setPrototypeOf ||\r\n ((o, proto) => {\r\n o.__proto__ = proto;\r\n return o;\r\n });\r\n}\r\n\r\n/* IMP! DO NOT CHANGE THE NUMBERING OF EXISTING ERROR CODES */\r\n/**\r\n * Error codes for BaseError\r\n */\r\nexport const ErrorCodes = {\r\n // Mesh errors 0-999\r\n /** Invalid or empty mesh vertex positions. */\r\n MeshInvalidPositionsError: 0,\r\n\r\n // Texture errors 1000-1999\r\n /** Unsupported texture found. */\r\n UnsupportedTextureError: 1000,\r\n\r\n // GLTFLoader errors 2000-2999\r\n /** Unexpected magic number found in GLTF file header. */\r\n GLTFLoaderUnexpectedMagicError: 2000,\r\n\r\n // SceneLoader errors 3000-3999\r\n /** SceneLoader generic error code. Ideally wraps the inner exception. */\r\n SceneLoaderError: 3000,\r\n\r\n // File related errors 4000-4999\r\n /** Load file error */\r\n LoadFileError: 4000,\r\n /** Request file error */\r\n RequestFileError: 4001,\r\n /** Read file error */\r\n ReadFileError: 4002,\r\n} as const;\r\n\r\n/**\r\n * Error code type\r\n */\r\nexport type ErrorCodesType = (typeof ErrorCodes)[keyof typeof ErrorCodes];\r\n\r\n/**\r\n * Application runtime error\r\n */\r\nexport class RuntimeError extends BaseError {\r\n /**\r\n * The error code\r\n */\r\n public errorCode: ErrorCodesType;\r\n\r\n /**\r\n * The error that caused this outer error\r\n */\r\n public innerError?: Error;\r\n\r\n /**\r\n * Creates a new RuntimeError\r\n * @param message defines the message of the error\r\n * @param errorCode the error code\r\n * @param innerError the error that caused the outer error\r\n */\r\n public constructor(message: string, errorCode: ErrorCodesType, innerError?: Error) {\r\n super(message);\r\n\r\n this.errorCode = errorCode;\r\n this.innerError = innerError;\r\n\r\n this.name = \"RuntimeError\";\r\n BaseError._setPrototypeOf(this, RuntimeError.prototype);\r\n }\r\n}\r\n"]}
|
package/Misc/tools.d.ts
CHANGED
|
@@ -351,12 +351,12 @@ export declare class Tools {
|
|
|
351
351
|
*/
|
|
352
352
|
static DownloadBlob(blob: Blob, fileName?: string): void;
|
|
353
353
|
/**
|
|
354
|
-
* Encodes the canvas data to base 64 or automatically
|
|
355
|
-
* @param canvas canvas to get the data from
|
|
356
|
-
* @param successCallback
|
|
357
|
-
* @param mimeType
|
|
358
|
-
* @param fileName
|
|
359
|
-
* @param quality
|
|
354
|
+
* Encodes the canvas data to base 64, or automatically downloads the result if `fileName` is defined.
|
|
355
|
+
* @param canvas The canvas to get the data from, which can be an offscreen canvas.
|
|
356
|
+
* @param successCallback The callback which is triggered once the data is available. If `fileName` is defined, the callback will be invoked after the download occurs, and the `data` argument will be an empty string.
|
|
357
|
+
* @param mimeType The mime type of the result.
|
|
358
|
+
* @param fileName The name of the file to download. If defined, the result will automatically be downloaded. If not defined, and `successCallback` is also not defined, the result will automatically be downloaded with an auto-generated file name.
|
|
359
|
+
* @param quality The quality of the result. See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.
|
|
360
360
|
*/
|
|
361
361
|
static EncodeScreenshotCanvasData(canvas: HTMLCanvasElement | OffscreenCanvas, successCallback?: (data: string) => void, mimeType?: string, fileName?: string, quality?: number): void;
|
|
362
362
|
/**
|
package/Misc/tools.js
CHANGED
|
@@ -599,15 +599,25 @@ export class Tools {
|
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
/**
|
|
602
|
-
* Encodes the canvas data to base 64 or automatically
|
|
603
|
-
* @param canvas canvas to get the data from
|
|
604
|
-
* @param successCallback
|
|
605
|
-
* @param mimeType
|
|
606
|
-
* @param fileName
|
|
607
|
-
* @param quality
|
|
602
|
+
* Encodes the canvas data to base 64, or automatically downloads the result if `fileName` is defined.
|
|
603
|
+
* @param canvas The canvas to get the data from, which can be an offscreen canvas.
|
|
604
|
+
* @param successCallback The callback which is triggered once the data is available. If `fileName` is defined, the callback will be invoked after the download occurs, and the `data` argument will be an empty string.
|
|
605
|
+
* @param mimeType The mime type of the result.
|
|
606
|
+
* @param fileName The name of the file to download. If defined, the result will automatically be downloaded. If not defined, and `successCallback` is also not defined, the result will automatically be downloaded with an auto-generated file name.
|
|
607
|
+
* @param quality The quality of the result. See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.
|
|
608
608
|
*/
|
|
609
609
|
static EncodeScreenshotCanvasData(canvas, successCallback, mimeType = "image/png", fileName, quality) {
|
|
610
|
-
if (successCallback) {
|
|
610
|
+
if (typeof fileName === "string" || !successCallback) {
|
|
611
|
+
this.ToBlob(canvas, function (blob) {
|
|
612
|
+
if (blob) {
|
|
613
|
+
Tools.DownloadBlob(blob, fileName);
|
|
614
|
+
}
|
|
615
|
+
if (successCallback) {
|
|
616
|
+
successCallback("");
|
|
617
|
+
}
|
|
618
|
+
}, mimeType, quality);
|
|
619
|
+
}
|
|
620
|
+
else if (successCallback) {
|
|
611
621
|
if (Tools._IsOffScreenCanvas(canvas)) {
|
|
612
622
|
canvas
|
|
613
623
|
.convertToBlob({
|
|
@@ -627,13 +637,6 @@ export class Tools {
|
|
|
627
637
|
const base64Image = canvas.toDataURL(mimeType, quality);
|
|
628
638
|
successCallback(base64Image);
|
|
629
639
|
}
|
|
630
|
-
else {
|
|
631
|
-
this.ToBlob(canvas, function (blob) {
|
|
632
|
-
if (blob) {
|
|
633
|
-
Tools.DownloadBlob(blob, fileName);
|
|
634
|
-
}
|
|
635
|
-
}, mimeType, quality);
|
|
636
|
-
}
|
|
637
640
|
}
|
|
638
641
|
/**
|
|
639
642
|
* Downloads a blob in the browser
|