@babylonjs/core 5.9.1 → 5.12.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/Cameras/Inputs/freeCameraTouchInput.d.ts +1 -0
- package/Cameras/Inputs/freeCameraTouchInput.js +3 -2
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Engines/Extensions/engine.query.js +1 -1
- package/Engines/Extensions/engine.query.js.map +1 -1
- package/Engines/ICanvas.d.ts +5 -0
- package/Engines/ICanvas.js.map +1 -1
- package/Engines/WebGPU/webgpuConstants.d.ts +1 -1
- package/Engines/WebGPU/webgpuConstants.js +5 -5
- package/Engines/WebGPU/webgpuConstants.js.map +1 -1
- package/Engines/engine.d.ts +2 -2
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +2 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +2 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrAnisotropicConfiguration.d.ts +1 -1
- package/Materials/PBR/pbrAnisotropicConfiguration.js +1 -1
- package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +9 -4
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +2 -1
- package/Materials/Textures/baseTexture.js +6 -3
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.js +1 -1
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.js +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js +1 -1
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/effect.d.ts +5 -0
- package/Materials/effect.js +5 -0
- package/Materials/effect.js.map +1 -1
- package/Materials/material.d.ts +2 -0
- package/Materials/material.js +4 -1
- package/Materials/material.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +14 -0
- package/Materials/materialPluginBase.js +16 -0
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialPluginEvent.d.ts +2 -0
- package/Materials/materialPluginEvent.js.map +1 -1
- package/Materials/materialPluginManager.d.ts +1 -0
- package/Materials/materialPluginManager.js +13 -1
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +17 -2
- package/Materials/shaderMaterial.js +65 -4
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.js +8 -3
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.vector.d.ts +7 -0
- package/Maths/math.vector.js +43 -11
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/shapeBuilder.d.ts +12 -0
- package/Meshes/Builders/shapeBuilder.js +48 -10
- package/Meshes/Builders/shapeBuilder.js.map +1 -1
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/subMesh.d.ts +2 -1
- package/Meshes/subMesh.js +4 -2
- package/Meshes/subMesh.js.map +1 -1
- package/Misc/computePressure.js +4 -3
- package/Misc/computePressure.js.map +1 -1
- package/Misc/iInspectable.d.ts +1 -1
- package/Misc/iInspectable.js.map +1 -1
- package/Misc/screenshotTools.js +31 -14
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/tools.d.ts +16 -0
- package/Misc/tools.js +44 -30
- package/Misc/tools.js.map +1 -1
- package/Offline/database.js +2 -2
- package/Offline/database.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/prePassRendererSceneComponent.js +2 -2
- package/Rendering/prePassRendererSceneComponent.js.map +1 -1
- package/XR/webXRCamera.js +11 -0
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRExperienceHelper.js +2 -1
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/package.json +2 -2
- package/sceneComponent.d.ts +2 -2
- package/sceneComponent.js +2 -2
- package/sceneComponent.js.map +1 -1
package/Meshes/subMesh.d.ts
CHANGED
|
@@ -175,9 +175,10 @@ export declare class SubMesh implements ICullable {
|
|
|
175
175
|
getEffectiveMesh(): AbstractMesh;
|
|
176
176
|
/**
|
|
177
177
|
* Returns the submesh material
|
|
178
|
+
* @param getDefaultMaterial Defines whether or not to get the default material if nothing has been defined.
|
|
178
179
|
* @returns null or the current material
|
|
179
180
|
*/
|
|
180
|
-
getMaterial(): Nullable<Material>;
|
|
181
|
+
getMaterial(getDefaultMaterial?: boolean): Nullable<Material>;
|
|
181
182
|
private _isMultiMaterial;
|
|
182
183
|
/**
|
|
183
184
|
* Sets a new updated BoundingInfo object to the submesh
|
package/Meshes/subMesh.js
CHANGED
|
@@ -265,13 +265,15 @@ var SubMesh = /** @class */ (function () {
|
|
|
265
265
|
};
|
|
266
266
|
/**
|
|
267
267
|
* Returns the submesh material
|
|
268
|
+
* @param getDefaultMaterial Defines whether or not to get the default material if nothing has been defined.
|
|
268
269
|
* @returns null or the current material
|
|
269
270
|
*/
|
|
270
|
-
SubMesh.prototype.getMaterial = function () {
|
|
271
|
+
SubMesh.prototype.getMaterial = function (getDefaultMaterial) {
|
|
271
272
|
var _a;
|
|
273
|
+
if (getDefaultMaterial === void 0) { getDefaultMaterial = true; }
|
|
272
274
|
var rootMaterial = (_a = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)) !== null && _a !== void 0 ? _a : this._renderingMesh.material;
|
|
273
275
|
if (!rootMaterial) {
|
|
274
|
-
return this._mesh.getScene().defaultMaterial;
|
|
276
|
+
return getDefaultMaterial ? this._mesh.getScene().defaultMaterial : null;
|
|
275
277
|
}
|
|
276
278
|
else if (this._isMultiMaterial(rootMaterial)) {
|
|
277
279
|
var effectiveMaterial = rootMaterial.getSubMaterial(this.materialIndex);
|
package/Meshes/subMesh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subMesh.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Meshes/subMesh.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAYvD;;GAEG;AACH;IA8JI;;;;;;;;;;;OAWG;IACH;IACI,gCAAgC;IACzB,aAAqB;IAC5B,yBAAyB;IAClB,aAAqB;IAC5B,qBAAqB;IACd,aAAqB;IAC5B,kBAAkB;IACX,UAAkB;IACzB,oBAAoB;IACb,UAAkB,EACzB,IAAkB,EAClB,aAAoB,EACpB,iBAAiC,EACjC,SAAgB;QADhB,kCAAA,EAAA,wBAAiC;QACjC,0BAAA,EAAA,gBAAgB;QAZT,kBAAa,GAAb,aAAa,CAAQ;QAErB,kBAAa,GAAb,aAAa,CAAQ;QAErB,kBAAa,GAAb,aAAa,CAAQ;QAErB,eAAU,GAAV,UAAU,CAAQ;QAElB,eAAU,GAAV,UAAU,CAAQ;QAhLrB,6BAAwB,GAA0B,IAAI,CAAC;QAyG/D,cAAc;QACP,qBAAgB,GAAW,CAAC,CAAC;QAI5B,sBAAiB,GAAyB,IAAI,CAAC;QACvD,cAAc;QACP,+BAA0B,GAAwB,IAAI,CAAC;QAG9D,cAAc;QACP,iCAA4B,GAAqB,IAAI,CAAC;QAE7D,cAAc;QACP,cAAS,GAAG,CAAC,CAAC;QACrB,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;AAAD,CAAC,AAvvBD,IAuvBC","sourcesContent":["import type { Nullable, IndicesArray, DeepImmutable, FloatArray } from \"../types\";\r\nimport type { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { ICullable } from \"../Culling/boundingInfo\";\r\nimport { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { extractMinAndMaxIndexed } from \"../Maths/math.functions\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { IMaterialContext } from \"../Engines/IMaterialContext\";\r\n\r\ndeclare type Collider = import(\"../Collisions/collider\").Collider;\r\ndeclare type Material = import(\"../Materials/material\").Material;\r\ndeclare type MaterialDefines = import(\"../Materials/materialDefines\").MaterialDefines;\r\ndeclare type MultiMaterial = import(\"../Materials/multiMaterial\").MultiMaterial;\r\ndeclare type AbstractMesh = import(\"./abstractMesh\").AbstractMesh;\r\ndeclare type Mesh = import(\"./mesh\").Mesh;\r\ndeclare type Ray = import(\"../Culling/ray\").Ray;\r\ndeclare type TrianglePickingPredicate = import(\"../Culling/ray\").TrianglePickingPredicate;\r\n\r\n/**\r\n * Defines a subdivision inside a mesh\r\n */\r\nexport class SubMesh implements ICullable {\r\n private _engine: Engine;\r\n /** @hidden */\r\n public _drawWrappers: Array<DrawWrapper>; // index in this array = pass id\r\n private _mainDrawWrapperOverride: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Gets material defines used by the effect associated to the sub mesh\r\n */\r\n public get materialDefines(): Nullable<MaterialDefines> {\r\n return this._mainDrawWrapperOverride ? (this._mainDrawWrapperOverride.defines as MaterialDefines) : (this._getDrawWrapper()?.defines as Nullable<MaterialDefines>);\r\n }\r\n\r\n /**\r\n * Sets material defines used by the effect associated to the sub mesh\r\n */\r\n public set materialDefines(defines: Nullable<MaterialDefines>) {\r\n const drawWrapper = this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n drawWrapper.defines = defines;\r\n }\r\n\r\n /**\r\n * @param passId\r\n * @param createIfNotExisting\r\n * @hidden\r\n */\r\n public _getDrawWrapper(passId?: number, createIfNotExisting = false): DrawWrapper | undefined {\r\n passId = passId ?? this._engine.currentRenderPassId;\r\n let drawWrapper = this._drawWrappers[passId];\r\n if (!drawWrapper && createIfNotExisting) {\r\n this._drawWrappers[passId] = drawWrapper = new DrawWrapper(this._mesh.getScene().getEngine());\r\n }\r\n return drawWrapper;\r\n }\r\n\r\n /**\r\n * @param passId\r\n * @param disposeWrapper\r\n * @hidden\r\n */\r\n public _removeDrawWrapper(passId: number, disposeWrapper = true) {\r\n if (disposeWrapper) {\r\n this._drawWrappers[passId]?.dispose();\r\n }\r\n this._drawWrappers[passId] = undefined as any;\r\n }\r\n\r\n /**\r\n * Gets associated (main) effect (possibly the effect override if defined)\r\n */\r\n public get effect(): Nullable<Effect> {\r\n return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : this._getDrawWrapper()?.effect ?? null;\r\n }\r\n\r\n /** @hidden */\r\n public get _drawWrapper(): DrawWrapper {\r\n return this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n }\r\n\r\n /** @hidden */\r\n public get _drawWrapperOverride(): Nullable<DrawWrapper> {\r\n return this._mainDrawWrapperOverride;\r\n }\r\n\r\n /**\r\n * @param wrapper\r\n * @hidden\r\n */\r\n public _setMainDrawWrapperOverride(wrapper: Nullable<DrawWrapper>): void {\r\n this._mainDrawWrapperOverride = wrapper;\r\n }\r\n\r\n /**\r\n * Sets associated effect (effect used to render this submesh)\r\n * @param effect defines the effect to associate with\r\n * @param defines defines the set of defines used to compile this effect\r\n * @param materialContext material context associated to the effect\r\n * @param resetContext true to reset the draw context\r\n */\r\n public setEffect(effect: Nullable<Effect>, defines: Nullable<string | MaterialDefines> = null, materialContext?: IMaterialContext, resetContext = true) {\r\n const drawWrapper = this._drawWrapper;\r\n drawWrapper.setEffect(effect, defines, resetContext);\r\n if (materialContext !== undefined) {\r\n drawWrapper.materialContext = materialContext;\r\n }\r\n if (!effect) {\r\n drawWrapper.defines = null;\r\n drawWrapper.materialContext = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Resets the draw wrappers cache\r\n * @param passId If provided, releases only the draw wrapper corresponding to this render pass id\r\n */\r\n public resetDrawCache(passId?: number): void {\r\n if (this._drawWrappers) {\r\n if (passId !== undefined) {\r\n this._removeDrawWrapper(passId);\r\n return;\r\n } else {\r\n for (const drawWrapper of this._drawWrappers) {\r\n drawWrapper?.dispose();\r\n }\r\n }\r\n }\r\n this._drawWrappers = [];\r\n }\r\n\r\n /** @hidden */\r\n public _linesIndexCount: number = 0;\r\n private _mesh: AbstractMesh;\r\n private _renderingMesh: Mesh;\r\n private _boundingInfo: BoundingInfo;\r\n private _linesIndexBuffer: Nullable<DataBuffer> = null;\r\n /** @hidden */\r\n public _lastColliderWorldVertices: Nullable<Vector3[]> = null;\r\n /** @hidden */\r\n public _trianglePlanes: Plane[];\r\n /** @hidden */\r\n public _lastColliderTransformMatrix: Nullable<Matrix> = null;\r\n\r\n /** @hidden */\r\n public _renderId = 0;\r\n /** @hidden */\r\n public _alphaIndex: number = 0;\r\n /** @hidden */\r\n public _distanceToCamera: number = 0;\r\n /** @hidden */\r\n public _id: number;\r\n\r\n private _currentMaterial: Nullable<Material> = null;\r\n\r\n /**\r\n * Add a new submesh to a mesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns the new submesh\r\n */\r\n public static AddToMesh(\r\n materialIndex: number,\r\n verticesStart: number,\r\n verticesCount: number,\r\n indexStart: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n\r\n /**\r\n * Creates a new submesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)\r\n */\r\n constructor(\r\n /** the material index to use */\r\n public materialIndex: number,\r\n /** vertex index start */\r\n public verticesStart: number,\r\n /** vertices count */\r\n public verticesCount: number,\r\n /** index start */\r\n public indexStart: number,\r\n /** indices count */\r\n public indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true,\r\n addToMesh = true\r\n ) {\r\n this._mesh = mesh;\r\n this._renderingMesh = renderingMesh || <Mesh>mesh;\r\n if (addToMesh) {\r\n mesh.subMeshes.push(this);\r\n }\r\n\r\n this._engine = this._mesh.getScene().getEngine();\r\n this.resetDrawCache();\r\n this._trianglePlanes = [];\r\n\r\n this._id = mesh.subMeshes.length - 1;\r\n\r\n if (createBoundingBox) {\r\n this.refreshBoundingInfo();\r\n mesh.computeWorldMatrix(true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if this submesh covers the entire parent mesh\r\n * @ignorenaming\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get IsGlobal(): boolean {\r\n return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices() && this.indexStart === 0 && this.indexCount === this._mesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * Returns the submesh BoundingInfo object\r\n * @returns current bounding info (or mesh's one if the submesh is global)\r\n */\r\n public getBoundingInfo(): BoundingInfo {\r\n if (this.IsGlobal) {\r\n return this._mesh.getBoundingInfo();\r\n }\r\n\r\n return this._boundingInfo;\r\n }\r\n\r\n /**\r\n * Sets the submesh BoundingInfo\r\n * @param boundingInfo defines the new bounding info to use\r\n * @returns the SubMesh\r\n */\r\n public setBoundingInfo(boundingInfo: BoundingInfo): SubMesh {\r\n this._boundingInfo = boundingInfo;\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the mesh of the current submesh\r\n * @return the parent mesh\r\n */\r\n public getMesh(): AbstractMesh {\r\n return this._mesh;\r\n }\r\n\r\n /**\r\n * Returns the rendering mesh of the submesh\r\n * @returns the rendering mesh (could be different from parent mesh)\r\n */\r\n public getRenderingMesh(): Mesh {\r\n return this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the replacement mesh of the submesh\r\n * @returns the replacement mesh (could be different from parent mesh)\r\n */\r\n public getReplacementMesh(): Nullable<AbstractMesh> {\r\n return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n }\r\n\r\n /**\r\n * Returns the effective mesh of the submesh\r\n * @returns the effective mesh (could be different from parent mesh)\r\n */\r\n public getEffectiveMesh(): AbstractMesh {\r\n const replacementMesh = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n\r\n return replacementMesh ? replacementMesh : this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the submesh material\r\n * @returns null or the current material\r\n */\r\n public getMaterial(): Nullable<Material> {\r\n const rootMaterial = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId) ?? this._renderingMesh.material;\r\n\r\n if (!rootMaterial) {\r\n return this._mesh.getScene().defaultMaterial;\r\n } else if (this._isMultiMaterial(rootMaterial)) {\r\n const effectiveMaterial = rootMaterial.getSubMaterial(this.materialIndex);\r\n\r\n if (this._currentMaterial !== effectiveMaterial) {\r\n this._currentMaterial = effectiveMaterial;\r\n this.resetDrawCache();\r\n }\r\n\r\n return effectiveMaterial;\r\n }\r\n\r\n return rootMaterial;\r\n }\r\n\r\n private _isMultiMaterial(material: Material): material is MultiMaterial {\r\n return (material as MultiMaterial).getSubMaterial !== undefined;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Sets a new updated BoundingInfo object to the submesh\r\n * @param data defines an optional position array to use to determine the bounding info\r\n * @returns the SubMesh\r\n */\r\n public refreshBoundingInfo(data: Nullable<FloatArray> = null): SubMesh {\r\n this._lastColliderWorldVertices = null;\r\n\r\n if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {\r\n return this;\r\n }\r\n\r\n if (!data) {\r\n data = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind);\r\n }\r\n\r\n if (!data) {\r\n this._boundingInfo = this._mesh.getBoundingInfo();\r\n return this;\r\n }\r\n\r\n const indices = <IndicesArray>this._renderingMesh.getIndices();\r\n let extend: { minimum: Vector3; maximum: Vector3 };\r\n\r\n //is this the only submesh?\r\n if (this.indexStart === 0 && this.indexCount === indices.length) {\r\n const boundingInfo = this._renderingMesh.getBoundingInfo();\r\n\r\n //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.\r\n extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };\r\n } else {\r\n extend = extractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);\r\n }\r\n\r\n if (this._boundingInfo) {\r\n this._boundingInfo.reConstruct(extend.minimum, extend.maximum);\r\n } else {\r\n this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @param collider\r\n * @hidden\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n return boundingInfo._checkCollision(collider);\r\n }\r\n\r\n /**\r\n * Updates the submesh BoundingInfo\r\n * @param world defines the world matrix to use to update the bounding info\r\n * @returns the submesh\r\n */\r\n public updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh {\r\n let boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n this.refreshBoundingInfo();\r\n boundingInfo = this.getBoundingInfo();\r\n }\r\n if (boundingInfo) {\r\n (<BoundingInfo>boundingInfo).update(world);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box intersects the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is intersecting with the frustum\r\n */\r\n public isInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is inside the frustum\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Renders the submesh\r\n * @param enableAlphaMode defines if alpha needs to be used\r\n * @returns the submesh\r\n */\r\n public render(enableAlphaMode: boolean): SubMesh {\r\n this._renderingMesh.render(this, enableAlphaMode, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : undefined);\r\n return this;\r\n }\r\n\r\n /**\r\n * @param indices\r\n * @param engine\r\n * @hidden\r\n */\r\n public _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer {\r\n if (!this._linesIndexBuffer) {\r\n const linesIndices = [];\r\n\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);\r\n }\r\n\r\n this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);\r\n this._linesIndexCount = linesIndices.length;\r\n }\r\n return this._linesIndexBuffer;\r\n }\r\n\r\n /**\r\n * Checks if the submesh intersects with a ray\r\n * @param ray defines the ray to test\r\n * @returns true is the passed ray intersects the submesh bounding box\r\n */\r\n public canIntersects(ray: Ray): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return ray.intersectsBox(boundingInfo.boundingBox);\r\n }\r\n\r\n /**\r\n * Intersects current submesh with a ray\r\n * @param ray defines the ray to test\r\n * @param positions defines mesh's positions array\r\n * @param indices defines mesh's indices array\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected\r\n * @returns intersection info or null if no intersection\r\n */\r\n public intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo> {\r\n const material = this.getMaterial();\r\n if (!material) {\r\n return null;\r\n }\r\n let step = 3;\r\n let checkStopper = false;\r\n\r\n switch (material.fillMode) {\r\n case Constants.MATERIAL_PointListDrawMode:\r\n case Constants.MATERIAL_LineLoopDrawMode:\r\n case Constants.MATERIAL_LineStripDrawMode:\r\n case Constants.MATERIAL_TriangleFanDrawMode:\r\n return null;\r\n case Constants.MATERIAL_TriangleStripDrawMode:\r\n step = 1;\r\n checkStopper = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n // LineMesh first as it's also a Mesh...\r\n if (material.fillMode === Constants.MATERIAL_LineListDrawMode) {\r\n // Check if mesh is unindexed\r\n if (!indices.length) {\r\n return this._intersectUnIndexedLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n }\r\n return this._intersectLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n } else {\r\n // Check if mesh is unindexed\r\n if (!indices.length && this._mesh._unIndexed) {\r\n return this._intersectUnIndexedTriangles(ray, positions, indices, fastCheck, trianglePredicate);\r\n }\r\n\r\n return this._intersectTriangles(ray, positions, indices, step, checkStopper, fastCheck, trianglePredicate);\r\n }\r\n }\r\n\r\n /**\r\n * @param ray\r\n * @param positions\r\n * @param indices\r\n * @param intersectionThreshold\r\n * @param fastCheck\r\n * @hidden\r\n */\r\n private _intersectLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {\r\n const p0 = positions[indices[index]];\r\n const p1 = positions[indices[index + 1]];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @param ray\r\n * @param positions\r\n * @param indices\r\n * @param intersectionThreshold\r\n * @param fastCheck\r\n * @hidden\r\n */\r\n private _intersectUnIndexedLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 2) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @param ray\r\n * @param positions\r\n * @param indices\r\n * @param step\r\n * @param checkStopper\r\n * @param fastCheck\r\n * @param trianglePredicate\r\n * @hidden\r\n */\r\n private _intersectTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n step: number,\r\n checkStopper: boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Triangles test\r\n let faceId = -1;\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount - (3 - step); index += step) {\r\n faceId++;\r\n const indexA = indices[index];\r\n const indexB = indices[index + 1];\r\n const indexC = indices[index + 2];\r\n\r\n if (checkStopper && indexC === 0xffffffff) {\r\n index += 2;\r\n continue;\r\n }\r\n\r\n const p0 = positions[indexA];\r\n const p1 = positions[indexB];\r\n const p2 = positions[indexC];\r\n\r\n // stay defensive and don't check against undefined positions.\r\n if (!p0 || !p1 || !p2) {\r\n continue;\r\n }\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = faceId;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @param ray\r\n * @param positions\r\n * @param indices\r\n * @param fastCheck\r\n * @param trianglePredicate\r\n * @hidden\r\n */\r\n private _intersectUnIndexedTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n // Triangles test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n const p2 = positions[index + 2];\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = index / 3;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild(): void {\r\n if (this._linesIndexBuffer) {\r\n this._linesIndexBuffer = null;\r\n }\r\n }\r\n\r\n // Clone\r\n /**\r\n * Creates a new submesh from the passed mesh\r\n * @param newMesh defines the new hosting mesh\r\n * @param newRenderingMesh defines an optional rendering mesh\r\n * @returns the new submesh\r\n */\r\n public clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh {\r\n const result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);\r\n\r\n if (!this.IsGlobal) {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return result;\r\n }\r\n\r\n result._boundingInfo = new BoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // Dispose\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._linesIndexBuffer) {\r\n this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);\r\n this._linesIndexBuffer = null;\r\n }\r\n\r\n // Remove from mesh\r\n const index = this._mesh.subMeshes.indexOf(this);\r\n this._mesh.subMeshes.splice(index, 1);\r\n\r\n this.resetDrawCache();\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"SubMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"SubMesh\";\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a new submesh from indices data\r\n * @param materialIndex the index of the main mesh material\r\n * @param startIndex the index where to start the copy in the mesh indices array\r\n * @param indexCount the number of indices to copy then from the startIndex\r\n * @param mesh the main mesh to create the submesh from\r\n * @param renderingMesh the optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns a new submesh\r\n */\r\n public static CreateFromIndices(\r\n materialIndex: number,\r\n startIndex: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n let minVertexIndex = Number.MAX_VALUE;\r\n let maxVertexIndex = -Number.MAX_VALUE;\r\n\r\n const whatWillRender = renderingMesh || mesh;\r\n const indices = whatWillRender!.getIndices()!;\r\n\r\n for (let index = startIndex; index < startIndex + indexCount; index++) {\r\n const vertexIndex = indices[index];\r\n\r\n if (vertexIndex < minVertexIndex) {\r\n minVertexIndex = vertexIndex;\r\n }\r\n if (vertexIndex > maxVertexIndex) {\r\n maxVertexIndex = vertexIndex;\r\n }\r\n }\r\n\r\n return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"subMesh.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Meshes/subMesh.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EA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ACjD,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEtC,IAAI,CAAC,cAAc,EAAE,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,8BAAY,GAAnB;QACI,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,UAAU;IACV;;;;;;;;;OASG;IACW,yBAAiB,GAA/B,UACI,aAAqB,EACrB,UAAkB,EAClB,UAAkB,EAClB,IAAkB,EAClB,aAAoB,EACpB,iBAAiC;QAAjC,kCAAA,EAAA,wBAAiC;QAEjC,IAAI,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC;QACtC,IAAI,cAAc,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;QAEvC,IAAM,cAAc,GAAG,aAAa,IAAI,IAAI,CAAC;QAC7C,IAAM,OAAO,GAAG,cAAe,CAAC,UAAU,EAAG,CAAC;QAE9C,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,GAAG,UAAU,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE;YACnE,IAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAEnC,IAAI,WAAW,GAAG,cAAc,EAAE;gBAC9B,cAAc,GAAG,WAAW,CAAC;aAChC;YACD,IAAI,WAAW,GAAG,cAAc,EAAE;gBAC9B,cAAc,GAAG,WAAW,CAAC;aAChC;SACJ;QAED,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,cAAc,EAAE,cAAc,GAAG,cAAc,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAC3J,CAAC;IACL,cAAC;AAAD,CAAC,AAxvBD,IAwvBC","sourcesContent":["import type { Nullable, IndicesArray, DeepImmutable, FloatArray } from \"../types\";\r\nimport type { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { ICullable } from \"../Culling/boundingInfo\";\r\nimport { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { extractMinAndMaxIndexed } from \"../Maths/math.functions\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { IMaterialContext } from \"../Engines/IMaterialContext\";\r\n\r\ndeclare type Collider = import(\"../Collisions/collider\").Collider;\r\ndeclare type Material = import(\"../Materials/material\").Material;\r\ndeclare type MaterialDefines = import(\"../Materials/materialDefines\").MaterialDefines;\r\ndeclare type MultiMaterial = import(\"../Materials/multiMaterial\").MultiMaterial;\r\ndeclare type AbstractMesh = import(\"./abstractMesh\").AbstractMesh;\r\ndeclare type Mesh = import(\"./mesh\").Mesh;\r\ndeclare type Ray = import(\"../Culling/ray\").Ray;\r\ndeclare type TrianglePickingPredicate = import(\"../Culling/ray\").TrianglePickingPredicate;\r\n\r\n/**\r\n * Defines a subdivision inside a mesh\r\n */\r\nexport class SubMesh implements ICullable {\r\n private _engine: Engine;\r\n /** @hidden */\r\n public _drawWrappers: Array<DrawWrapper>; // index in this array = pass id\r\n private _mainDrawWrapperOverride: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Gets material defines used by the effect associated to the sub mesh\r\n */\r\n public get materialDefines(): Nullable<MaterialDefines> {\r\n return this._mainDrawWrapperOverride ? (this._mainDrawWrapperOverride.defines as MaterialDefines) : (this._getDrawWrapper()?.defines as Nullable<MaterialDefines>);\r\n }\r\n\r\n /**\r\n * Sets material defines used by the effect associated to the sub mesh\r\n */\r\n public set materialDefines(defines: Nullable<MaterialDefines>) {\r\n const drawWrapper = this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n drawWrapper.defines = defines;\r\n }\r\n\r\n /**\r\n * @param passId\r\n * @param createIfNotExisting\r\n * @hidden\r\n */\r\n public _getDrawWrapper(passId?: number, createIfNotExisting = false): DrawWrapper | undefined {\r\n passId = passId ?? this._engine.currentRenderPassId;\r\n let drawWrapper = this._drawWrappers[passId];\r\n if (!drawWrapper && createIfNotExisting) {\r\n this._drawWrappers[passId] = drawWrapper = new DrawWrapper(this._mesh.getScene().getEngine());\r\n }\r\n return drawWrapper;\r\n }\r\n\r\n /**\r\n * @param passId\r\n * @param disposeWrapper\r\n * @hidden\r\n */\r\n public _removeDrawWrapper(passId: number, disposeWrapper = true) {\r\n if (disposeWrapper) {\r\n this._drawWrappers[passId]?.dispose();\r\n }\r\n this._drawWrappers[passId] = undefined as any;\r\n }\r\n\r\n /**\r\n * Gets associated (main) effect (possibly the effect override if defined)\r\n */\r\n public get effect(): Nullable<Effect> {\r\n return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : this._getDrawWrapper()?.effect ?? null;\r\n }\r\n\r\n /** @hidden */\r\n public get _drawWrapper(): DrawWrapper {\r\n return this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n }\r\n\r\n /** @hidden */\r\n public get _drawWrapperOverride(): Nullable<DrawWrapper> {\r\n return this._mainDrawWrapperOverride;\r\n }\r\n\r\n /**\r\n * @param wrapper\r\n * @hidden\r\n */\r\n public _setMainDrawWrapperOverride(wrapper: Nullable<DrawWrapper>): void {\r\n this._mainDrawWrapperOverride = wrapper;\r\n }\r\n\r\n /**\r\n * Sets associated effect (effect used to render this submesh)\r\n * @param effect defines the effect to associate with\r\n * @param defines defines the set of defines used to compile this effect\r\n * @param materialContext material context associated to the effect\r\n * @param resetContext true to reset the draw context\r\n */\r\n public setEffect(effect: Nullable<Effect>, defines: Nullable<string | MaterialDefines> = null, materialContext?: IMaterialContext, resetContext = true) {\r\n const drawWrapper = this._drawWrapper;\r\n drawWrapper.setEffect(effect, defines, resetContext);\r\n if (materialContext !== undefined) {\r\n drawWrapper.materialContext = materialContext;\r\n }\r\n if (!effect) {\r\n drawWrapper.defines = null;\r\n drawWrapper.materialContext = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Resets the draw wrappers cache\r\n * @param passId If provided, releases only the draw wrapper corresponding to this render pass id\r\n */\r\n public resetDrawCache(passId?: number): void {\r\n if (this._drawWrappers) {\r\n if (passId !== undefined) {\r\n this._removeDrawWrapper(passId);\r\n return;\r\n } else {\r\n for (const drawWrapper of this._drawWrappers) {\r\n drawWrapper?.dispose();\r\n }\r\n }\r\n }\r\n this._drawWrappers = [];\r\n }\r\n\r\n /** @hidden */\r\n public _linesIndexCount: number = 0;\r\n private _mesh: AbstractMesh;\r\n private _renderingMesh: Mesh;\r\n private _boundingInfo: BoundingInfo;\r\n private _linesIndexBuffer: Nullable<DataBuffer> = null;\r\n /** @hidden */\r\n public _lastColliderWorldVertices: Nullable<Vector3[]> = null;\r\n /** @hidden */\r\n public _trianglePlanes: Plane[];\r\n /** @hidden */\r\n public _lastColliderTransformMatrix: Nullable<Matrix> = null;\r\n\r\n /** @hidden */\r\n public _renderId = 0;\r\n /** @hidden */\r\n public _alphaIndex: number = 0;\r\n /** @hidden */\r\n public _distanceToCamera: number = 0;\r\n /** @hidden */\r\n public _id: number;\r\n\r\n private _currentMaterial: Nullable<Material> = null;\r\n\r\n /**\r\n * Add a new submesh to a mesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns the new submesh\r\n */\r\n public static AddToMesh(\r\n materialIndex: number,\r\n verticesStart: number,\r\n verticesCount: number,\r\n indexStart: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n\r\n /**\r\n * Creates a new submesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)\r\n */\r\n constructor(\r\n /** the material index to use */\r\n public materialIndex: number,\r\n /** vertex index start */\r\n public verticesStart: number,\r\n /** vertices count */\r\n public verticesCount: number,\r\n /** index start */\r\n public indexStart: number,\r\n /** indices count */\r\n public indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true,\r\n addToMesh = true\r\n ) {\r\n this._mesh = mesh;\r\n this._renderingMesh = renderingMesh || <Mesh>mesh;\r\n if (addToMesh) {\r\n mesh.subMeshes.push(this);\r\n }\r\n\r\n this._engine = this._mesh.getScene().getEngine();\r\n this.resetDrawCache();\r\n this._trianglePlanes = [];\r\n\r\n this._id = mesh.subMeshes.length - 1;\r\n\r\n if (createBoundingBox) {\r\n this.refreshBoundingInfo();\r\n mesh.computeWorldMatrix(true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if this submesh covers the entire parent mesh\r\n * @ignorenaming\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get IsGlobal(): boolean {\r\n return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices() && this.indexStart === 0 && this.indexCount === this._mesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * Returns the submesh BoundingInfo object\r\n * @returns current bounding info (or mesh's one if the submesh is global)\r\n */\r\n public getBoundingInfo(): BoundingInfo {\r\n if (this.IsGlobal) {\r\n return this._mesh.getBoundingInfo();\r\n }\r\n\r\n return this._boundingInfo;\r\n }\r\n\r\n /**\r\n * Sets the submesh BoundingInfo\r\n * @param boundingInfo defines the new bounding info to use\r\n * @returns the SubMesh\r\n */\r\n public setBoundingInfo(boundingInfo: BoundingInfo): SubMesh {\r\n this._boundingInfo = boundingInfo;\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the mesh of the current submesh\r\n * @return the parent mesh\r\n */\r\n public getMesh(): AbstractMesh {\r\n return this._mesh;\r\n }\r\n\r\n /**\r\n * Returns the rendering mesh of the submesh\r\n * @returns the rendering mesh (could be different from parent mesh)\r\n */\r\n public getRenderingMesh(): Mesh {\r\n return this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the replacement mesh of the submesh\r\n * @returns the replacement mesh (could be different from parent mesh)\r\n */\r\n public getReplacementMesh(): Nullable<AbstractMesh> {\r\n return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n }\r\n\r\n /**\r\n * Returns the effective mesh of the submesh\r\n * @returns the effective mesh (could be different from parent mesh)\r\n */\r\n public getEffectiveMesh(): AbstractMesh {\r\n const replacementMesh = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n\r\n return replacementMesh ? replacementMesh : this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the submesh material\r\n * @param getDefaultMaterial Defines whether or not to get the default material if nothing has been defined.\r\n * @returns null or the current material\r\n */\r\n public getMaterial(getDefaultMaterial = true): Nullable<Material> {\r\n const rootMaterial = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId) ?? this._renderingMesh.material;\r\n\r\n if (!rootMaterial) {\r\n return getDefaultMaterial ? this._mesh.getScene().defaultMaterial : null;\r\n } else if (this._isMultiMaterial(rootMaterial)) {\r\n const effectiveMaterial = rootMaterial.getSubMaterial(this.materialIndex);\r\n\r\n if (this._currentMaterial !== effectiveMaterial) {\r\n this._currentMaterial = effectiveMaterial;\r\n this.resetDrawCache();\r\n }\r\n\r\n return effectiveMaterial;\r\n }\r\n\r\n return rootMaterial;\r\n }\r\n\r\n private _isMultiMaterial(material: Material): material is MultiMaterial {\r\n return (material as MultiMaterial).getSubMaterial !== undefined;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Sets a new updated BoundingInfo object to the submesh\r\n * @param data defines an optional position array to use to determine the bounding info\r\n * @returns the SubMesh\r\n */\r\n public refreshBoundingInfo(data: Nullable<FloatArray> = null): SubMesh {\r\n this._lastColliderWorldVertices = null;\r\n\r\n if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {\r\n return this;\r\n }\r\n\r\n if (!data) {\r\n data = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind);\r\n }\r\n\r\n if (!data) {\r\n this._boundingInfo = this._mesh.getBoundingInfo();\r\n return this;\r\n }\r\n\r\n const indices = <IndicesArray>this._renderingMesh.getIndices();\r\n let extend: { minimum: Vector3; maximum: Vector3 };\r\n\r\n //is this the only submesh?\r\n if (this.indexStart === 0 && this.indexCount === indices.length) {\r\n const boundingInfo = this._renderingMesh.getBoundingInfo();\r\n\r\n //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.\r\n extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };\r\n } else {\r\n extend = extractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);\r\n }\r\n\r\n if (this._boundingInfo) {\r\n this._boundingInfo.reConstruct(extend.minimum, extend.maximum);\r\n } else {\r\n this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @param collider\r\n * @hidden\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n return boundingInfo._checkCollision(collider);\r\n }\r\n\r\n /**\r\n * Updates the submesh BoundingInfo\r\n * @param world defines the world matrix to use to update the bounding info\r\n * @returns the submesh\r\n */\r\n public updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh {\r\n let boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n this.refreshBoundingInfo();\r\n boundingInfo = this.getBoundingInfo();\r\n }\r\n if (boundingInfo) {\r\n (<BoundingInfo>boundingInfo).update(world);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box intersects the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is intersecting with the frustum\r\n */\r\n public isInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is inside the frustum\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Renders the submesh\r\n * @param enableAlphaMode defines if alpha needs to be used\r\n * @returns the submesh\r\n */\r\n public render(enableAlphaMode: boolean): SubMesh {\r\n this._renderingMesh.render(this, enableAlphaMode, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : undefined);\r\n return this;\r\n }\r\n\r\n /**\r\n * @param indices\r\n * @param engine\r\n * @hidden\r\n */\r\n public _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer {\r\n if (!this._linesIndexBuffer) {\r\n const linesIndices = [];\r\n\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);\r\n }\r\n\r\n this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);\r\n this._linesIndexCount = linesIndices.length;\r\n }\r\n return this._linesIndexBuffer;\r\n }\r\n\r\n /**\r\n * Checks if the submesh intersects with a ray\r\n * @param ray defines the ray to test\r\n * @returns true is the passed ray intersects the submesh bounding box\r\n */\r\n public canIntersects(ray: Ray): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return ray.intersectsBox(boundingInfo.boundingBox);\r\n }\r\n\r\n /**\r\n * Intersects current submesh with a ray\r\n * @param ray defines the ray to test\r\n * @param positions defines mesh's positions array\r\n * @param indices defines mesh's indices array\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected\r\n * @returns intersection info or null if no intersection\r\n */\r\n public intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo> {\r\n const material = this.getMaterial();\r\n if (!material) {\r\n return null;\r\n }\r\n let step = 3;\r\n let checkStopper = false;\r\n\r\n switch (material.fillMode) {\r\n case Constants.MATERIAL_PointListDrawMode:\r\n case Constants.MATERIAL_LineLoopDrawMode:\r\n case Constants.MATERIAL_LineStripDrawMode:\r\n case Constants.MATERIAL_TriangleFanDrawMode:\r\n return null;\r\n case Constants.MATERIAL_TriangleStripDrawMode:\r\n step = 1;\r\n checkStopper = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n // LineMesh first as it's also a Mesh...\r\n if (material.fillMode === Constants.MATERIAL_LineListDrawMode) {\r\n // Check if mesh is unindexed\r\n if (!indices.length) {\r\n return this._intersectUnIndexedLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n }\r\n return this._intersectLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n } else {\r\n // Check if mesh is unindexed\r\n if (!indices.length && this._mesh._unIndexed) {\r\n return this._intersectUnIndexedTriangles(ray, positions, indices, fastCheck, trianglePredicate);\r\n }\r\n\r\n return this._intersectTriangles(ray, positions, indices, step, checkStopper, fastCheck, trianglePredicate);\r\n }\r\n }\r\n\r\n /**\r\n * @param ray\r\n * @param positions\r\n * @param indices\r\n * @param intersectionThreshold\r\n * @param fastCheck\r\n * @hidden\r\n */\r\n private _intersectLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {\r\n const p0 = positions[indices[index]];\r\n const p1 = positions[indices[index + 1]];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @param ray\r\n * @param positions\r\n * @param indices\r\n * @param intersectionThreshold\r\n * @param fastCheck\r\n * @hidden\r\n */\r\n private _intersectUnIndexedLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 2) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @param ray\r\n * @param positions\r\n * @param indices\r\n * @param step\r\n * @param checkStopper\r\n * @param fastCheck\r\n * @param trianglePredicate\r\n * @hidden\r\n */\r\n private _intersectTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n step: number,\r\n checkStopper: boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Triangles test\r\n let faceId = -1;\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount - (3 - step); index += step) {\r\n faceId++;\r\n const indexA = indices[index];\r\n const indexB = indices[index + 1];\r\n const indexC = indices[index + 2];\r\n\r\n if (checkStopper && indexC === 0xffffffff) {\r\n index += 2;\r\n continue;\r\n }\r\n\r\n const p0 = positions[indexA];\r\n const p1 = positions[indexB];\r\n const p2 = positions[indexC];\r\n\r\n // stay defensive and don't check against undefined positions.\r\n if (!p0 || !p1 || !p2) {\r\n continue;\r\n }\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = faceId;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @param ray\r\n * @param positions\r\n * @param indices\r\n * @param fastCheck\r\n * @param trianglePredicate\r\n * @hidden\r\n */\r\n private _intersectUnIndexedTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n // Triangles test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n const p2 = positions[index + 2];\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = index / 3;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild(): void {\r\n if (this._linesIndexBuffer) {\r\n this._linesIndexBuffer = null;\r\n }\r\n }\r\n\r\n // Clone\r\n /**\r\n * Creates a new submesh from the passed mesh\r\n * @param newMesh defines the new hosting mesh\r\n * @param newRenderingMesh defines an optional rendering mesh\r\n * @returns the new submesh\r\n */\r\n public clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh {\r\n const result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);\r\n\r\n if (!this.IsGlobal) {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return result;\r\n }\r\n\r\n result._boundingInfo = new BoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // Dispose\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._linesIndexBuffer) {\r\n this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);\r\n this._linesIndexBuffer = null;\r\n }\r\n\r\n // Remove from mesh\r\n const index = this._mesh.subMeshes.indexOf(this);\r\n this._mesh.subMeshes.splice(index, 1);\r\n\r\n this.resetDrawCache();\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"SubMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"SubMesh\";\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a new submesh from indices data\r\n * @param materialIndex the index of the main mesh material\r\n * @param startIndex the index where to start the copy in the mesh indices array\r\n * @param indexCount the number of indices to copy then from the startIndex\r\n * @param mesh the main mesh to create the submesh from\r\n * @param renderingMesh the optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns a new submesh\r\n */\r\n public static CreateFromIndices(\r\n materialIndex: number,\r\n startIndex: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n let minVertexIndex = Number.MAX_VALUE;\r\n let maxVertexIndex = -Number.MAX_VALUE;\r\n\r\n const whatWillRender = renderingMesh || mesh;\r\n const indices = whatWillRender!.getIndices()!;\r\n\r\n for (let index = startIndex; index < startIndex + indexCount; index++) {\r\n const vertexIndex = indices[index];\r\n\r\n if (vertexIndex < minVertexIndex) {\r\n minVertexIndex = vertexIndex;\r\n }\r\n if (vertexIndex > maxVertexIndex) {\r\n maxVertexIndex = vertexIndex;\r\n }\r\n }\r\n\r\n return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n}\r\n"]}
|
package/Misc/computePressure.js
CHANGED
|
@@ -28,9 +28,10 @@ var ComputePressureObserverWrapper = /** @class */ (function () {
|
|
|
28
28
|
*/
|
|
29
29
|
ComputePressureObserverWrapper.prototype.observe = function () {
|
|
30
30
|
var _a, _b;
|
|
31
|
-
((_a = this._observer) === null || _a === void 0 ? void 0 : _a.observe) &&
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
((_a = this._observer) === null || _a === void 0 ? void 0 : _a.observe) &&
|
|
32
|
+
((_b = this._observer) === null || _b === void 0 ? void 0 : _b.observe().catch(function () {
|
|
33
|
+
// Ignore error
|
|
34
|
+
}));
|
|
34
35
|
};
|
|
35
36
|
/**
|
|
36
37
|
* Method that must be called to stop observing changes and triggering callbacks (cleanup function).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computePressure.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/computePressure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;GAEG;AACH;IAEI;;;;OAIG;IACH,wCAAY,QAAgD,EAAE,UAAsC;QAChG,IAAI,8BAA8B,CAAC,WAAW,EAAE;YAC5C,IAAI,CAAC,SAAS,GAAG,IAAU,MAAO,CAAC,uBAAuB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;SACpF;IACL,CAAC;IAKD,sBAAkB,6CAAW;QAH7B;;WAEG;aACH;YACI,OAAO,mBAAmB,EAAE,IAAI,yBAAyB,IAAI,MAAM,CAAC;QACxE,CAAC;;;OAAA;IAED;;OAEG;IACH,gDAAO,GAAP;;QACI,CAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"computePressure.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/computePressure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;GAEG;AACH;IAEI;;;;OAIG;IACH,wCAAY,QAAgD,EAAE,UAAsC;QAChG,IAAI,8BAA8B,CAAC,WAAW,EAAE;YAC5C,IAAI,CAAC,SAAS,GAAG,IAAU,MAAO,CAAC,uBAAuB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;SACpF;IACL,CAAC;IAKD,sBAAkB,6CAAW;QAH7B;;WAEG;aACH;YACI,OAAO,mBAAmB,EAAE,IAAI,yBAAyB,IAAI,MAAM,CAAC;QACxE,CAAC;;;OAAA;IAED;;OAEG;IACH,gDAAO,GAAP;;QACI,CAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO;aACnB,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,GAAG,KAAK,CAAC;gBAC5B,eAAe;YACnB,CAAC,CAAC,CAAA,CAAC;IACX,CAAC;IAED;;OAEG;IACH,kDAAS,GAAT;;QACI,CAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,SAAS,MAAI,MAAA,IAAI,CAAC,SAAS,0CAAE,SAAS,EAAE,CAAA,CAAC;IAC7D,CAAC;IACL,qCAAC;AAAD,CAAC,AApCD,IAoCC","sourcesContent":["import { IsWindowObjectExist } from \"./domManagement\";\r\n\r\n/**\r\n * A wrapper for the experimental compute pressure api which allows a callback to be called whenever certain thresholds are met.\r\n */\r\nexport class ComputePressureObserverWrapper {\r\n private _observer: any;\r\n /**\r\n * A compute pressure observer will call this callback, whenever these thresholds are met.\r\n * @param callback The callback that is called whenever thresholds are met.\r\n * @param thresholds An object containing the thresholds used to decide what value to to return for each update property (average of start and end of a threshold boundary).\r\n */\r\n constructor(callback: (update: IComputePressureData) => void, thresholds: IComputePressureThresholds) {\r\n if (ComputePressureObserverWrapper.IsAvailable) {\r\n this._observer = new (<any>window).ComputePressureObserver(callback, thresholds);\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if ComputePressureObserver is available for use, false otherwise.\r\n */\r\n public static get IsAvailable() {\r\n return IsWindowObjectExist() && \"ComputePressureObserver\" in window;\r\n }\r\n\r\n /**\r\n * Method that must be called to begin observing changes, and triggering callbacks.\r\n */\r\n observe(): void {\r\n this._observer?.observe &&\r\n this._observer?.observe().catch(() => {\r\n // Ignore error\r\n });\r\n }\r\n\r\n /**\r\n * Method that must be called to stop observing changes and triggering callbacks (cleanup function).\r\n */\r\n unobserve(): void {\r\n this._observer?.unobserve && this._observer?.unobserve();\r\n }\r\n}\r\n\r\n/**\r\n * An interface defining the shape of the thresholds parameter in the experimental compute pressure api\r\n */\r\nexport interface IComputePressureThresholds {\r\n /**\r\n * Thresholds to make buckets out of for the cpu utilization, the average between the start and end points of a threshold will be returned to the callback.\r\n */\r\n cpuUtilizationThresholds: number[];\r\n /**\r\n * Thresholds to make buckets out of for the cpu speed, the average between the start and end points of a threshold will be returned to the callback.\r\n * 0.5 represents base speed.\r\n */\r\n cpuSpeedThresholds: number[];\r\n}\r\n\r\n/**\r\n * An interface defining the shape of the data sent to the callback in the compute pressure observer.\r\n */\r\nexport interface IComputePressureData {\r\n /**\r\n * The cpu utilization which will be a number between 0.0 and 1.0.\r\n */\r\n cpuUtilization: number;\r\n /**\r\n * The cpu speed which will be a number between 0.0 and 1.0.\r\n */\r\n cpuSpeed: number;\r\n}\r\n"]}
|
package/Misc/iInspectable.d.ts
CHANGED
package/Misc/iInspectable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iInspectable.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/iInspectable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,eAqCX;AArCD,WAAY,eAAe;IACvB;;OAEG;IACH,6DAAY,CAAA;IACZ;;OAEG;IACH,yDAAU,CAAA;IACV;;OAEG;IACH,2DAAW,CAAA;IACX;;OAEG;IACH,iEAAc,CAAA;IACd;;OAEG;IACH,yDAAU,CAAA;IACV;;OAEG;IACH,yDAAU,CAAA;IACV;;OAEG;IACH,yDAAU,CAAA;IACV;;OAEG;IACH,2DAAW,CAAA;IACX;;OAEG;IACH,mDAAO,CAAA;AACX,CAAC,EArCW,eAAe,KAAf,eAAe,QAqC1B","sourcesContent":["/**\r\n * Enum that determines the text-wrapping mode to use.\r\n */\r\nexport enum InspectableType {\r\n /**\r\n * Checkbox for booleans\r\n */\r\n Checkbox = 0,\r\n /**\r\n * Sliders for numbers\r\n */\r\n Slider = 1,\r\n /**\r\n * Vector3\r\n */\r\n Vector3 = 2,\r\n /**\r\n * Quaternions\r\n */\r\n Quaternion = 3,\r\n /**\r\n * Color3\r\n */\r\n Color3 = 4,\r\n /**\r\n * String\r\n */\r\n String = 5,\r\n /**\r\n * Button\r\n */\r\n Button = 6,\r\n /**\r\n * Options\r\n */\r\n Options = 7,\r\n /**\r\n * Tab\r\n */\r\n Tab = 8,\r\n}\r\n\r\n/**\r\n * Interface used to define custom inspectable options in \"Options\" mode.\r\n * This interface is used by the inspector to display the list of options\r\n */\r\nexport interface IInspectableOptions {\r\n /**\r\n * Defines the visible part of the option\r\n */\r\n label: string;\r\n /**\r\n * Defines the value part of the option (returned through the callback)\r\n */\r\n value: number | string;\r\n /**\r\n * Defines if the option should be selected or not\r\n */\r\n selected?: boolean;\r\n}\r\n\r\n/**\r\n * Interface used to define custom inspectable properties.\r\n * This interface is used by the inspector to display custom property grids\r\n * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility\r\n */\r\nexport interface IInspectable {\r\n /**\r\n * Gets the label to display\r\n */\r\n label: string;\r\n /**\r\n * Gets the name of the property to edit\r\n */\r\n propertyName: string;\r\n /**\r\n * Gets the type of the editor to use\r\n */\r\n type: InspectableType;\r\n /**\r\n * Gets the minimum value of the property when using in \"slider\" mode\r\n */\r\n min?: number;\r\n /**\r\n * Gets the maximum value of the property when using in \"slider\" mode\r\n */\r\n max?: number;\r\n /**\r\n * Gets the setp to use when using in \"slider\" mode\r\n */\r\n step?: number;\r\n /**\r\n * Gets the callback function when using \"Button\" mode\r\n */\r\n callback?: () => void;\r\n /**\r\n * Gets the list of options when using \"Option\" mode\r\n */\r\n options?: [];\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"iInspectable.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/iInspectable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,eAqCX;AArCD,WAAY,eAAe;IACvB;;OAEG;IACH,6DAAY,CAAA;IACZ;;OAEG;IACH,yDAAU,CAAA;IACV;;OAEG;IACH,2DAAW,CAAA;IACX;;OAEG;IACH,iEAAc,CAAA;IACd;;OAEG;IACH,yDAAU,CAAA;IACV;;OAEG;IACH,yDAAU,CAAA;IACV;;OAEG;IACH,yDAAU,CAAA;IACV;;OAEG;IACH,2DAAW,CAAA;IACX;;OAEG;IACH,mDAAO,CAAA;AACX,CAAC,EArCW,eAAe,KAAf,eAAe,QAqC1B","sourcesContent":["/**\r\n * Enum that determines the text-wrapping mode to use.\r\n */\r\nexport enum InspectableType {\r\n /**\r\n * Checkbox for booleans\r\n */\r\n Checkbox = 0,\r\n /**\r\n * Sliders for numbers\r\n */\r\n Slider = 1,\r\n /**\r\n * Vector3\r\n */\r\n Vector3 = 2,\r\n /**\r\n * Quaternions\r\n */\r\n Quaternion = 3,\r\n /**\r\n * Color3\r\n */\r\n Color3 = 4,\r\n /**\r\n * String\r\n */\r\n String = 5,\r\n /**\r\n * Button\r\n */\r\n Button = 6,\r\n /**\r\n * Options\r\n */\r\n Options = 7,\r\n /**\r\n * Tab\r\n */\r\n Tab = 8,\r\n}\r\n\r\n/**\r\n * Interface used to define custom inspectable options in \"Options\" mode.\r\n * This interface is used by the inspector to display the list of options\r\n */\r\nexport interface IInspectableOptions {\r\n /**\r\n * Defines the visible part of the option\r\n */\r\n label: string;\r\n /**\r\n * Defines the value part of the option (returned through the callback)\r\n */\r\n value: number | string;\r\n /**\r\n * Defines if the option should be selected or not\r\n */\r\n selected?: boolean;\r\n}\r\n\r\n/**\r\n * Interface used to define custom inspectable properties.\r\n * This interface is used by the inspector to display custom property grids\r\n * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility\r\n */\r\nexport interface IInspectable {\r\n /**\r\n * Gets the label to display\r\n */\r\n label: string;\r\n /**\r\n * Gets the name of the property to edit\r\n */\r\n propertyName: string;\r\n /**\r\n * Gets the type of the editor to use\r\n */\r\n type: InspectableType;\r\n /**\r\n * Gets the minimum value of the property when using in \"slider\" mode\r\n */\r\n min?: number;\r\n /**\r\n * Gets the maximum value of the property when using in \"slider\" mode\r\n */\r\n max?: number;\r\n /**\r\n * Gets the setp to use when using in \"slider\" mode\r\n */\r\n step?: number;\r\n /**\r\n * Gets the callback function when using \"Button\" mode\r\n */\r\n callback?: () => void;\r\n /**\r\n * Gets the list of options when using \"Option\" mode\r\n */\r\n options?: IInspectableOptions[];\r\n}\r\n"]}
|
package/Misc/screenshotTools.js
CHANGED
|
@@ -44,21 +44,38 @@ export function CreateScreenshot(engine, camera, size, successCallback, mimeType
|
|
|
44
44
|
}
|
|
45
45
|
var offsetX = Math.max(0, width - newWidth) / 2;
|
|
46
46
|
var offsetY = Math.max(0, height - newHeight) / 2;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
var scene = camera.getScene();
|
|
48
|
+
if (scene.activeCamera !== camera) {
|
|
49
|
+
CreateScreenshotUsingRenderTarget(engine, camera, size, function (data) {
|
|
50
|
+
if (forceDownload) {
|
|
51
|
+
var blob = new Blob([data]);
|
|
52
|
+
Tools.DownloadBlob(blob);
|
|
53
|
+
if (successCallback) {
|
|
54
|
+
successCallback("");
|
|
55
|
+
}
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
}
|
|
57
|
+
else if (successCallback) {
|
|
58
|
+
successCallback(data);
|
|
59
|
+
}
|
|
60
|
+
}, mimeType, 1, engine.getCreationOptions().antialias);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
engine.onEndFrameObservable.addOnce(function () {
|
|
64
|
+
var renderingCanvas = engine.getRenderingCanvas();
|
|
65
|
+
if (renderContext && renderingCanvas) {
|
|
66
|
+
renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
|
|
67
|
+
}
|
|
68
|
+
if (forceDownload) {
|
|
69
|
+
Tools.EncodeScreenshotCanvasData(undefined, mimeType);
|
|
70
|
+
if (successCallback) {
|
|
71
|
+
successCallback("");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
Tools.EncodeScreenshotCanvasData(successCallback, mimeType);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
62
79
|
}
|
|
63
80
|
/**
|
|
64
81
|
* Captures a screenshot of the current rendering
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/screenshotTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKhC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAc,EACd,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAA8B,EAC9B,aAAqB;IADrB,yBAAA,EAAA,sBAA8B;IAC9B,8BAAA,EAAA,qBAAqB;IAEf,IAAA,KAAoB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAA1D,MAAM,YAAA,EAAE,KAAK,WAA6C,CAAC;IAEnE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE;QACpB,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC3C,OAAO;KACV;IAED,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE;QAC1B,KAAK,CAAC,iBAAiB,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;KAC9D;IAED,KAAK,CAAC,i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;;;;;;;;;;;;;OAoBG;IACH,iCAAiC,mCAAA;IAEjC;;;;;;;;;;;;;;;;;;OAkBG;IACH,sCAAsC,wCAAA;CACzC,CAAC;AAEF;;;;;GAKG;AACH,IAAM,eAAe,GAAG;IACpB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\n\r\ndeclare type Engine = import(\"../Engines/engine\").Engine;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n */\r\nexport function CreateScreenshot(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType: string = \"image/png\",\r\n forceDownload = false\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n if (!Tools._ScreenshotCanvas) {\r\n Tools._ScreenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n Tools._ScreenshotCanvas.width = width;\r\n Tools._ScreenshotCanvas.height = height;\r\n\r\n const renderContext = Tools._ScreenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\r\n\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(undefined, mimeType);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(successCallback, mimeType);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType: string = \"image/png\"): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType: string = \"image/png\"): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType: string = \"image/png\",\r\n samples: number = 1,\r\n antialiasing: boolean = false,\r\n fileName?: string,\r\n renderSprites: boolean = false,\r\n enableStencilBuffer: boolean = false\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const scene = camera.getScene();\r\n let previousCamera: Nullable<Camera> = null;\r\n const previousCameras = scene.activeCameras;\r\n\r\n scene.activeCameras = null;\r\n\r\n if (scene.activeCamera !== camera) {\r\n previousCamera = scene.activeCamera;\r\n scene.activeCamera = camera;\r\n }\r\n\r\n scene.render(); // make sure the scene is ready to be rendered in the RTT with the right list of active meshes (which depends on the camera, that may have been changed above)\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT,\r\n false,\r\n Texture.NEAREST_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = null;\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n\r\n const renderToTexture = () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n Tools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true);\r\n texture.dispose();\r\n });\r\n });\r\n\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n texture.render(true);\r\n\r\n // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur\r\n // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n if (previousCamera) {\r\n scene.activeCamera = previousCamera;\r\n }\r\n scene.activeCameras = previousCameras;\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType: string = \"image/png\",\r\n samples: number = 1,\r\n antialiasing: boolean = false,\r\n fileName?: string,\r\n renderSprites: boolean = false\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine\r\n * @param camera\r\n * @param size\r\n * @private\r\n */\r\nfunction _GetScreenshotSize(engine: Engine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number } {\r\n let height = 0;\r\n let width = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n\r\n return { height: height | 0, width: width | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @hidden\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
|
|
1
|
+
{"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/screenshotTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKhC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAc,EACd,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAA8B,EAC9B,aAAqB;IADrB,yBAAA,EAAA,sBAA8B;IAC9B,8BAAA,EAAA,qBAAq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,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\n\r\ndeclare type Engine = import(\"../Engines/engine\").Engine;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n */\r\nexport function CreateScreenshot(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType: string = \"image/png\",\r\n forceDownload = false\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n if (!Tools._ScreenshotCanvas) {\r\n Tools._ScreenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n Tools._ScreenshotCanvas.width = width;\r\n Tools._ScreenshotCanvas.height = height;\r\n\r\n const renderContext = Tools._ScreenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1,\r\n engine.getCreationOptions().antialias\r\n );\r\n } else {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(undefined, mimeType);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(successCallback, mimeType);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType: string = \"image/png\"): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType: string = \"image/png\"): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType: string = \"image/png\",\r\n samples: number = 1,\r\n antialiasing: boolean = false,\r\n fileName?: string,\r\n renderSprites: boolean = false,\r\n enableStencilBuffer: boolean = false\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const scene = camera.getScene();\r\n let previousCamera: Nullable<Camera> = null;\r\n const previousCameras = scene.activeCameras;\r\n\r\n scene.activeCameras = null;\r\n\r\n if (scene.activeCamera !== camera) {\r\n previousCamera = scene.activeCamera;\r\n scene.activeCamera = camera;\r\n }\r\n\r\n scene.render(); // make sure the scene is ready to be rendered in the RTT with the right list of active meshes (which depends on the camera, that may have been changed above)\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT,\r\n false,\r\n Texture.NEAREST_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = null;\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n\r\n const renderToTexture = () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n Tools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true);\r\n texture.dispose();\r\n });\r\n });\r\n\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n texture.render(true);\r\n\r\n // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur\r\n // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n if (previousCamera) {\r\n scene.activeCamera = previousCamera;\r\n }\r\n scene.activeCameras = previousCameras;\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType: string = \"image/png\",\r\n samples: number = 1,\r\n antialiasing: boolean = false,\r\n fileName?: string,\r\n renderSprites: boolean = false\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine\r\n * @param camera\r\n * @param size\r\n * @private\r\n */\r\nfunction _GetScreenshotSize(engine: Engine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number } {\r\n let height = 0;\r\n let width = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n\r\n return { height: height | 0, width: width | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @hidden\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
|
package/Misc/tools.d.ts
CHANGED
|
@@ -164,6 +164,15 @@ export declare class Tools {
|
|
|
164
164
|
static SetCorsBehavior(url: string | string[], element: {
|
|
165
165
|
crossOrigin: string | null;
|
|
166
166
|
}): void;
|
|
167
|
+
/**
|
|
168
|
+
* Sets the referrerPolicy behavior on a dom element.
|
|
169
|
+
* @param referrerPolicy define the referrer policy to use
|
|
170
|
+
* @param element define the dom element where to configure the referrer policy
|
|
171
|
+
* @param element.referrerPolicy
|
|
172
|
+
*/
|
|
173
|
+
static SetReferrerPolicyBehavior(referrerPolicy: Nullable<ReferrerPolicy>, element: {
|
|
174
|
+
referrerPolicy: string | null;
|
|
175
|
+
}): void;
|
|
167
176
|
/**
|
|
168
177
|
* Removes unwanted characters from an url
|
|
169
178
|
* @param url defines the url to clean
|
|
@@ -333,6 +342,13 @@ export declare class Tools {
|
|
|
333
342
|
* @param quality defines the quality of the result
|
|
334
343
|
*/
|
|
335
344
|
static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string, quality?: number): void;
|
|
345
|
+
/**
|
|
346
|
+
* Download a Blob object
|
|
347
|
+
* @param blob the Blob object
|
|
348
|
+
* @param fileName the file name to download
|
|
349
|
+
* @returns
|
|
350
|
+
*/
|
|
351
|
+
static DownloadBlob(blob: Blob, fileName?: string): void;
|
|
336
352
|
/**
|
|
337
353
|
* Encodes the canvas data to base 64 or automatically download the result if filename is defined
|
|
338
354
|
* @param successCallback defines the callback triggered once the data are available
|