@babylonjs/core 5.55.0 → 5.57.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/Compute/computeShader.d.ts +3 -3
- package/Compute/computeShader.js +22 -12
- package/Compute/computeShader.js.map +1 -1
- package/Culling/boundingInfo.d.ts +1 -1
- package/Culling/boundingInfo.js +9 -3
- package/Culling/boundingInfo.js.map +1 -1
- package/Engines/WebGL/webGLPipelineContext.d.ts +30 -35
- package/Engines/WebGL/webGLPipelineContext.js +399 -94
- package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Layers/effectLayer.js +2 -2
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/highlightLayer.js +12 -7
- package/Layers/highlightLayer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.d.ts +2 -2
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +2 -2
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +4 -0
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.d.ts +3 -1
- package/Materials/clipPlaneMaterialHelper.js +53 -32
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/effect.d.ts +35 -35
- package/Materials/effect.js +375 -24
- package/Materials/effect.js.map +1 -1
- package/Materials/shaderMaterial.js +2 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +9 -0
- package/Meshes/instancedMesh.js +30 -0
- package/Meshes/instancedMesh.js.map +1 -1
- package/Particles/gpuParticleSystem.js +2 -2
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.js +2 -2
- package/Particles/particleSystem.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +2 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +5 -0
- package/PostProcesses/postProcess.js +9 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/Rendering/depthRenderer.js +2 -2
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +2 -2
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js +2 -2
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Sprites/spriteManager.js +3 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,8 @@ import type { IPhysicsCollisionEvent, MassProperties, PhysicsMotionType } from "
|
|
|
2
2
|
import type { PhysicsShape } from "./physicsShape";
|
|
3
3
|
import { Vector3, Quaternion } from "../../Maths/math.vector";
|
|
4
4
|
import type { Scene } from "../../scene";
|
|
5
|
-
import type {
|
|
5
|
+
import type { AbstractMesh } from "../../Meshes/abstractMesh";
|
|
6
|
+
import type { TransformNode } from "../../Meshes/transformNode";
|
|
6
7
|
import type { PhysicsConstraint } from "./physicsConstraint";
|
|
7
8
|
import type { Bone } from "../../Bones/bone.js";
|
|
8
9
|
import type { Observable } from "../../Misc/observable";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAO1E,OAAO,EAAE,KAAK,EAAE,iCAA6B;AAI7C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA+BpB;;;;;;;;;OASG;IACH,YAAY,aAA4B,EAAE,UAA6B,EAAE,KAAY;QAxCrF;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAa7C;;;WAGG;QACH,mBAAc,GAAY,IAAI,CAAC;QAiB3B,IAAI,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AAI,CAAC,IAAI,UAAU,EAAE;YACnE,WAAW,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;SACrC;QAED,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,EAAE;YACnD,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,WAAW,CAAC;YACjC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,WAAW,CAAC;YACjC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,WAAW,CAAC;SACpC;QAED,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC3B,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;SACpC;QACD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAC;;AAjfc,gCAAoB,GAAY,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,gCAAoB,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { IPhysicsCollisionEvent, IPhysicsEnginePluginV2, MassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Mesh, TransformNode, AbstractMesh } from \"../../Meshes\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n private static _DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);\r\n private static _IDENTITY_QUATERNION = Quaternion.Identity();\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for.\r\n * @param motionType - The motion type of the physics body.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, motionType, transformNode.position, transformNode.rotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.motionType, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * Adds the physics shape associated with the transform node to this body\r\n * @param shapeNode - A node with a physics shape. Should be a child of the body node\r\n */\r\n public addNodeShape(shapeNode: TransformNode) {\r\n this._physicsPlugin.addNodeShape(this, shapeNode);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: PhysicsShape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): PhysicsShape {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the filter group of the physics body.\r\n * @param group - The filter group of the physics body.\r\n *\r\n * This method is useful for setting the filter group of the physics body.\r\n * The filter group is used to determine which bodies should collide with each other.\r\n * This allows for more control over the physics engine and can be used to create more realistic simulations.\r\n */\r\n public set filterGroup(group: number) {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n * Gets the filter group of the physics engine.\r\n *\r\n * @returns The filter group of the physics engine.\r\n *\r\n * This method is useful for getting the filter group of the physics engine,\r\n * which is used to determine which objects will interact with each other.\r\n * This is important for creating realistic physics simulations.\r\n */\r\n public get filterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public set eventMask(eventMask: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public get eventMask(): number {\r\n return this._physicsPlugin.getEventMask(this);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public set motionType(motionType: PhysicsMotionType) {\r\n this._physicsPlugin.setMotionType(this, motionType);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * intial values, which you can then customize.\r\n */\r\n public computeMassProperties(): MassProperties {\r\n return this._physicsPlugin.computeMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public set massProperties(massProps: MassProperties) {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public get massProperties(): MassProperties {\r\n return this._physicsPlugin.getMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public set linearDamping(damping: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public get linearDamping(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public set angularDamping(damping: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public get angularDamping(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3): void {\r\n this._physicsPlugin.applyForce(this, force, location);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for all collisions happening for event-enabled bodies\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n return this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Gets the object extents\r\n * @returns the object extents\r\n */\r\n public getObjectExtents(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const q = this.transformNode.rotationQuaternion;\r\n const scaling = this.transformNode.scaling.clone();\r\n //reset rotation\r\n this.transformNode.rotationQuaternion = PhysicsBody._IDENTITY_QUATERNION;\r\n //calculate the world matrix with no rotation\r\n const worldMatrix = this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n if (worldMatrix) {\r\n worldMatrix.decompose(scaling, undefined, undefined);\r\n }\r\n tmAbstractMesh.refreshBoundingInfo();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n // get the global scaling of the object\r\n const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);\r\n size.x = Math.abs(size.x);\r\n size.y = Math.abs(size.y);\r\n size.z = Math.abs(size.z);\r\n //bring back the rotation\r\n this.transformNode.rotationQuaternion = q;\r\n //calculate the world matrix with the new rotation\r\n this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n return size;\r\n } else {\r\n return PhysicsBody._DEFAULT_OBJECT_SIZE;\r\n }\r\n }\r\n\r\n /**\r\n * returns the delta between the object bounding box center and the mesh origin\r\n * @returns delta between object bounding box center and origin\r\n */\r\n public getObjectCenterDelta(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const delta = new Vector3();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n this.transformNode.computeWorldMatrix(true);\r\n tmAbstractMesh.refreshBoundingInfo();\r\n delta.copyFrom(boundingInfo.boundingBox.centerWorld);\r\n delta.subtractInPlace(tmAbstractMesh.getAbsolutePosition());\r\n delta.x /= tmAbstractMesh.scaling.x;\r\n delta.y /= tmAbstractMesh.scaling.y;\r\n delta.z /= tmAbstractMesh.scaling.z;\r\n return delta;\r\n } else {\r\n return Vector3.Zero();\r\n }\r\n }\r\n\r\n /**\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenter(): Vector3 {\r\n if ((<any>this.transformNode).getBoundingInfo) {\r\n const boundingInfo = (<any>this.transformNode).getBoundingInfo();\r\n return boundingInfo.boundingBox.centerWorld;\r\n } else {\r\n return this.transformNode.position;\r\n }\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAy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AI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,gCAAoB,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { IPhysicsCollisionEvent, IPhysicsEnginePluginV2, MassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n private static _DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);\r\n private static _IDENTITY_QUATERNION = Quaternion.Identity();\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for.\r\n * @param motionType - The motion type of the physics body.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, motionType, transformNode.position, transformNode.rotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.motionType, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * Adds the physics shape associated with the transform node to this body\r\n * @param shapeNode - A node with a physics shape. Should be a child of the body node\r\n */\r\n public addNodeShape(shapeNode: TransformNode) {\r\n this._physicsPlugin.addNodeShape(this, shapeNode);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: PhysicsShape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): PhysicsShape {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the filter group of the physics body.\r\n * @param group - The filter group of the physics body.\r\n *\r\n * This method is useful for setting the filter group of the physics body.\r\n * The filter group is used to determine which bodies should collide with each other.\r\n * This allows for more control over the physics engine and can be used to create more realistic simulations.\r\n */\r\n public set filterGroup(group: number) {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n * Gets the filter group of the physics engine.\r\n *\r\n * @returns The filter group of the physics engine.\r\n *\r\n * This method is useful for getting the filter group of the physics engine,\r\n * which is used to determine which objects will interact with each other.\r\n * This is important for creating realistic physics simulations.\r\n */\r\n public get filterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public set eventMask(eventMask: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public get eventMask(): number {\r\n return this._physicsPlugin.getEventMask(this);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public set motionType(motionType: PhysicsMotionType) {\r\n this._physicsPlugin.setMotionType(this, motionType);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * intial values, which you can then customize.\r\n */\r\n public computeMassProperties(): MassProperties {\r\n return this._physicsPlugin.computeMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public set massProperties(massProps: MassProperties) {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public get massProperties(): MassProperties {\r\n return this._physicsPlugin.getMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public set linearDamping(damping: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public get linearDamping(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public set angularDamping(damping: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public get angularDamping(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3): void {\r\n this._physicsPlugin.applyForce(this, force, location);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for all collisions happening for event-enabled bodies\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n return this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Gets the object extents\r\n * @returns the object extents\r\n */\r\n public getObjectExtents(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const q = this.transformNode.rotationQuaternion;\r\n const scaling = this.transformNode.scaling.clone();\r\n //reset rotation\r\n this.transformNode.rotationQuaternion = PhysicsBody._IDENTITY_QUATERNION;\r\n //calculate the world matrix with no rotation\r\n const worldMatrix = this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n if (worldMatrix) {\r\n worldMatrix.decompose(scaling, undefined, undefined);\r\n }\r\n tmAbstractMesh.refreshBoundingInfo();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n // get the global scaling of the object\r\n const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);\r\n size.x = Math.abs(size.x);\r\n size.y = Math.abs(size.y);\r\n size.z = Math.abs(size.z);\r\n //bring back the rotation\r\n this.transformNode.rotationQuaternion = q;\r\n //calculate the world matrix with the new rotation\r\n this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n return size;\r\n } else {\r\n return PhysicsBody._DEFAULT_OBJECT_SIZE;\r\n }\r\n }\r\n\r\n /**\r\n * returns the delta between the object bounding box center and the mesh origin\r\n * @returns delta between object bounding box center and origin\r\n */\r\n public getObjectCenterDelta(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const delta = new Vector3();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n this.transformNode.computeWorldMatrix(true);\r\n tmAbstractMesh.refreshBoundingInfo();\r\n delta.copyFrom(boundingInfo.boundingBox.centerWorld);\r\n delta.subtractInPlace(tmAbstractMesh.getAbsolutePosition());\r\n delta.x /= tmAbstractMesh.scaling.x;\r\n delta.y /= tmAbstractMesh.scaling.y;\r\n delta.z /= tmAbstractMesh.scaling.z;\r\n return delta;\r\n } else {\r\n return Vector3.Zero();\r\n }\r\n }\r\n\r\n /**\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenter(): Vector3 {\r\n if ((<any>this.transformNode).getBoundingInfo) {\r\n const boundingInfo = (<any>this.transformNode).getBoundingInfo();\r\n return boundingInfo.boundingBox.centerWorld;\r\n } else {\r\n return this.transformNode.position;\r\n }\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
|
|
@@ -98,6 +98,11 @@ export declare class PostProcess {
|
|
|
98
98
|
* Should be set to false if shader will overwrite all previous pixels.
|
|
99
99
|
*/
|
|
100
100
|
autoClear: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* If clearing the buffer should be forced in autoClear mode, even when alpha mode is enabled (default: false).
|
|
103
|
+
* By default, the buffer will only be cleared if alpha mode is disabled (and autoClear is true).
|
|
104
|
+
*/
|
|
105
|
+
forceAutoClearInAlphaMode: boolean;
|
|
101
106
|
/**
|
|
102
107
|
* Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
|
|
103
108
|
*/
|
|
@@ -181,6 +181,11 @@ export class PostProcess {
|
|
|
181
181
|
* Should be set to false if shader will overwrite all previous pixels.
|
|
182
182
|
*/
|
|
183
183
|
this.autoClear = true;
|
|
184
|
+
/**
|
|
185
|
+
* If clearing the buffer should be forced in autoClear mode, even when alpha mode is enabled (default: false).
|
|
186
|
+
* By default, the buffer will only be cleared if alpha mode is disabled (and autoClear is true).
|
|
187
|
+
*/
|
|
188
|
+
this.forceAutoClearInAlphaMode = false;
|
|
184
189
|
/**
|
|
185
190
|
* Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
|
|
186
191
|
*/
|
|
@@ -540,7 +545,7 @@ export class PostProcess {
|
|
|
540
545
|
(_b = (_a = this._engine)._debugInsertMarker) === null || _b === void 0 ? void 0 : _b.call(_a, `post process ${this.name} input`);
|
|
541
546
|
this.onActivateObservable.notifyObservers(camera);
|
|
542
547
|
// Clear
|
|
543
|
-
if (this.autoClear && this.alphaMode === 0) {
|
|
548
|
+
if (this.autoClear && (this.alphaMode === 0 || this.forceAutoClearInAlphaMode)) {
|
|
544
549
|
this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
|
|
545
550
|
}
|
|
546
551
|
if (this._reusable) {
|
|
@@ -770,6 +775,9 @@ __decorate([
|
|
|
770
775
|
__decorate([
|
|
771
776
|
serialize()
|
|
772
777
|
], PostProcess.prototype, "autoClear", void 0);
|
|
778
|
+
__decorate([
|
|
779
|
+
serialize()
|
|
780
|
+
], PostProcess.prototype, "forceAutoClearInAlphaMode", void 0);
|
|
773
781
|
__decorate([
|
|
774
782
|
serialize()
|
|
775
783
|
], PostProcess.prototype, "alphaMode", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postProcess.js","sourceRoot":"","sources":["../../../../lts/core/generated/PostProcesses/postProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,2CAA2C,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAsC7D;;;GAGG;AACH,MAAM,OAAO,WAAW;IAMpB;;;;;OAKG;IACI,MAAM,CAAC,4BAA4B,CAAC,eAAiC,EAAE,0BAAkE;QAC5I,IAAI,CAAC,0BAA0B,EAAE;YAC7B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;IADC,SAAS,EAAE;yCACQ;AAMpB;IADC,SAAS,EAAE;0CACM;AAMlB;IADC,SAAS,EAAE;2CACO;AAiBnB;IADC,SAAS,EAAE;6DAC4B;AAKxC;IADC,iBAAiB,EAAE;+CACM;AAM1B;IADC,SAAS,EAAE;8CACY;AAKxB;IADC,SAAS,EAAE;8CAC+B;AAK3C;IADC,SAAS,EAAE;mDACkB;AAW9B;IADC,SAAS,EAAE;2DAC0B;AAMtC;IADC,SAAS,EAAE;4DAC0B;AAmBtC;IADC,SAAS,EAAE;8CACiC;AAK7C;IADC,SAAS,EAAE;mDACkB;AAG9B;IADC,SAAS,CAAC,SAAS,CAAC;6CACA;AAqBrB;IADC,SAAS,EAAE;gEAC+B;AAo0B/C,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { RenderTargetCreationOptions } from \"../Materials/Textures/textureCreationOptions\";\r\nimport \"../Shaders/postprocess.vertex\";\r\nimport type { IInspectable } from \"../Misc/iInspectable\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { Color4 } from \"../Maths/math.color\";\r\n\r\nimport \"../Engines/Extensions/engine.renderTarget\";\r\nimport type { NodeMaterial } from \"../Materials/Node/nodeMaterial\";\r\nimport { serialize, serializeAsColor4, SerializationHelper } from \"../Misc/decorators\";\r\nimport { GetClass, RegisterClass } from \"../Misc/typeStore\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { AbstractScene } from \"../abstractScene\";\r\nimport type { RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport { ShaderLanguage } from \"../Materials/shaderLanguage\";\r\n\r\ndeclare type Scene = import(\"../scene\").Scene;\r\ndeclare type InternalTexture = import(\"../Materials/Textures/internalTexture\").InternalTexture;\r\ndeclare type WebVRFreeCamera = import(\"../Cameras/VR/webVRCamera\").WebVRFreeCamera;\r\ndeclare type Animation = import(\"../Animations/animation\").Animation;\r\ndeclare type PrePassRenderer = import(\"../Rendering/prePassRenderer\").PrePassRenderer;\r\ndeclare type PrePassEffectConfiguration = import(\"../Rendering/prePassEffectConfiguration\").PrePassEffectConfiguration;\r\n\r\n/**\r\n * Allows for custom processing of the shader code used by a post process\r\n */\r\nexport type PostProcessCustomShaderCodeProcessing = {\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated after the #include have been processed\r\n */\r\n processCodeAfterIncludes?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called before creating the effect to collect additional custom bindings (defines, uniforms, samplers)\r\n */\r\n defineCustomBindings?: (postProcessName: string, defines: Nullable<string>, uniforms: string[], samplers: string[]) => Nullable<string>;\r\n /**\r\n * If provided, will be called when binding inputs to the shader code to allow the user to add custom bindings\r\n */\r\n bindCustomBindings?: (postProcessName: string, effect: Effect) => void;\r\n};\r\n\r\n/**\r\n * Size options for a post process\r\n */\r\nexport type PostProcessOptions = { width: number; height: number };\r\n\r\ntype TextureCache = { texture: RenderTargetWrapper; postProcessChannel: number; lastUsedRenderId: number };\r\n\r\n/**\r\n * PostProcess can be used to apply a shader to a texture after it has been rendered\r\n * See https://doc.babylonjs.com/features/featuresDeepDive/postProcesses/usePostProcesses\r\n */\r\nexport class PostProcess {\r\n /** @internal */\r\n public _parentContainer: Nullable<AbstractScene> = null;\r\n\r\n private static _CustomShaderCodeProcessing: { [postProcessName: string]: PostProcessCustomShaderCodeProcessing } = {};\r\n\r\n /**\r\n * Registers a shader code processing with a post process name.\r\n * @param postProcessName name of the post process. Use null for the fallback shader code processing. This is the shader code processing that will be used in case no specific shader code processing has been associated to a post process name\r\n * @param customShaderCodeProcessing shader code processing to associate to the post process name\r\n * @returns\r\n */\r\n public static RegisterShaderCodeProcessing(postProcessName: Nullable<string>, customShaderCodeProcessing?: PostProcessCustomShaderCodeProcessing) {\r\n if (!customShaderCodeProcessing) {\r\n delete PostProcess._CustomShaderCodeProcessing[postProcessName ?? \"\"];\r\n return;\r\n }\r\n\r\n PostProcess._CustomShaderCodeProcessing[postProcessName ?? \"\"] = customShaderCodeProcessing;\r\n }\r\n\r\n private static _GetShaderCodeProcessing(postProcessName: string) {\r\n return PostProcess._CustomShaderCodeProcessing[postProcessName] ?? PostProcess._CustomShaderCodeProcessing[\"\"];\r\n }\r\n\r\n /**\r\n * Gets or sets the unique id of the post process\r\n */\r\n @serialize()\r\n public uniqueId: number;\r\n\r\n /** Name of the PostProcess. */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * Width of the texture to apply the post process on\r\n */\r\n @serialize()\r\n public width = -1;\r\n\r\n /**\r\n * Height of the texture to apply the post process on\r\n */\r\n @serialize()\r\n public height = -1;\r\n\r\n /**\r\n * Gets the node material used to create this postprocess (null if the postprocess was manually created)\r\n */\r\n public nodeMaterialSource: Nullable<NodeMaterial> = null;\r\n\r\n /**\r\n * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)\r\n * @internal\r\n */\r\n public _outputTexture: Nullable<RenderTargetWrapper> = null;\r\n /**\r\n * Sampling mode used by the shader\r\n * See https://doc.babylonjs.com/classes/3.1/texture\r\n */\r\n @serialize()\r\n public renderTargetSamplingMode: number;\r\n /**\r\n * Clear color to use when screen clearing\r\n */\r\n @serializeAsColor4()\r\n public clearColor: Color4;\r\n /**\r\n * If the buffer needs to be cleared before applying the post process. (default: true)\r\n * Should be set to false if shader will overwrite all previous pixels.\r\n */\r\n @serialize()\r\n public autoClear = true;\r\n /**\r\n * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)\r\n */\r\n @serialize()\r\n public alphaMode = Constants.ALPHA_DISABLE;\r\n /**\r\n * Sets the setAlphaBlendConstants of the babylon engine\r\n */\r\n @serialize()\r\n public alphaConstants: Color4;\r\n /**\r\n * Animations to be used for the post processing\r\n */\r\n public animations = new Array<Animation>();\r\n\r\n /**\r\n * Enable Pixel Perfect mode where texture is not scaled to be power of 2.\r\n * Can only be used on a single postprocess or on the last one of a chain. (default: false)\r\n */\r\n @serialize()\r\n public enablePixelPerfectMode = false;\r\n\r\n /**\r\n * Force the postprocess to be applied without taking in account viewport\r\n */\r\n @serialize()\r\n public forceFullscreenViewport = true;\r\n\r\n /**\r\n * List of inspectable custom properties (used by the Inspector)\r\n * @see https://doc.babylonjs.com/toolsAndResources/inspector#extensibility\r\n */\r\n public inspectableCustomProperties: IInspectable[];\r\n\r\n /**\r\n * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)\r\n *\r\n * | Value | Type | Description |\r\n * | ----- | ----------------------------------- | ----------- |\r\n * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |\r\n * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |\r\n * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |\r\n *\r\n */\r\n @serialize()\r\n public scaleMode = Constants.SCALEMODE_FLOOR;\r\n /**\r\n * Force textures to be a power of two (default: false)\r\n */\r\n @serialize()\r\n public alwaysForcePOT = false;\r\n\r\n @serialize(\"samples\")\r\n private _samples = 1;\r\n\r\n /**\r\n * Number of sample textures (default: 1)\r\n */\r\n public get samples() {\r\n return this._samples;\r\n }\r\n\r\n public set samples(n: number) {\r\n this._samples = Math.min(n, this._engine.getCaps().maxMSAASamples);\r\n\r\n this._textures.forEach((texture) => {\r\n texture.setSamples(this._samples);\r\n });\r\n }\r\n\r\n /**\r\n * Modify the scale of the post process to be the same as the viewport (default: false)\r\n */\r\n @serialize()\r\n public adaptScaleToCurrentViewport = false;\r\n\r\n private _camera: Camera;\r\n protected _scene: Scene;\r\n private _engine: Engine;\r\n\r\n private _options: number | PostProcessOptions;\r\n private _reusable = false;\r\n private _renderId = 0;\r\n private _textureType: number;\r\n private _textureFormat: number;\r\n private _shaderLanguage: ShaderLanguage;\r\n\r\n /**\r\n * if externalTextureSamplerBinding is true, the \"apply\" method won't bind the textureSampler texture, it is expected to be done by the \"outside\" (by the onApplyObservable observer most probably).\r\n * counter-productive in some cases because if the texture bound by \"apply\" is different from the currently texture bound, (the one set by the onApplyObservable observer, for eg) some\r\n * internal structures (materialContext) will be dirtified, which may impact performances\r\n */\r\n public externalTextureSamplerBinding = false;\r\n\r\n /**\r\n * Smart array of input and output textures for the post process.\r\n * @internal\r\n */\r\n public _textures = new SmartArray<RenderTargetWrapper>(2);\r\n /**\r\n * Smart array of input and output textures for the post process.\r\n * @internal\r\n */\r\n private _textureCache: TextureCache[] = [];\r\n /**\r\n * The index in _textures that corresponds to the output texture.\r\n * @internal\r\n */\r\n public _currentRenderTextureInd = 0;\r\n private _drawWrapper: DrawWrapper;\r\n private _samplers: string[];\r\n private _fragmentUrl: string;\r\n private _vertexUrl: string;\r\n private _parameters: string[];\r\n protected _postProcessDefines: Nullable<string>;\r\n private _scaleRatio = new Vector2(1, 1);\r\n protected _indexParameters: any;\r\n private _shareOutputWithPostProcess: Nullable<PostProcess>;\r\n private _texelSize = Vector2.Zero();\r\n\r\n /** @internal */\r\n public _forcedOutputTexture: Nullable<RenderTargetWrapper>;\r\n\r\n /**\r\n * Prepass configuration in case this post process needs a texture from prepass\r\n * @internal\r\n */\r\n public _prePassEffectConfiguration: PrePassEffectConfiguration;\r\n\r\n /**\r\n * Returns the fragment url or shader name used in the post process.\r\n * @returns the fragment url or name in the shader store.\r\n */\r\n public getEffectName(): string {\r\n return this._fragmentUrl;\r\n }\r\n\r\n // Events\r\n\r\n /**\r\n * An event triggered when the postprocess is activated.\r\n */\r\n public onActivateObservable = new Observable<Camera>();\r\n\r\n private _onActivateObserver: Nullable<Observer<Camera>>;\r\n /**\r\n * A function that is added to the onActivateObservable\r\n */\r\n public set onActivate(callback: Nullable<(camera: Camera) => void>) {\r\n if (this._onActivateObserver) {\r\n this.onActivateObservable.remove(this._onActivateObserver);\r\n }\r\n if (callback) {\r\n this._onActivateObserver = this.onActivateObservable.add(callback);\r\n }\r\n }\r\n\r\n /**\r\n * An event triggered when the postprocess changes its size.\r\n */\r\n public onSizeChangedObservable = new Observable<PostProcess>();\r\n\r\n private _onSizeChangedObserver: Nullable<Observer<PostProcess>>;\r\n /**\r\n * A function that is added to the onSizeChangedObservable\r\n */\r\n public set onSizeChanged(callback: (postProcess: PostProcess) => void) {\r\n if (this._onSizeChangedObserver) {\r\n this.onSizeChangedObservable.remove(this._onSizeChangedObserver);\r\n }\r\n this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered when the postprocess applies its effect.\r\n */\r\n public onApplyObservable = new Observable<Effect>();\r\n\r\n private _onApplyObserver: Nullable<Observer<Effect>>;\r\n /**\r\n * A function that is added to the onApplyObservable\r\n */\r\n public set onApply(callback: (effect: Effect) => void) {\r\n if (this._onApplyObserver) {\r\n this.onApplyObservable.remove(this._onApplyObserver);\r\n }\r\n this._onApplyObserver = this.onApplyObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered before rendering the postprocess\r\n */\r\n public onBeforeRenderObservable = new Observable<Effect>();\r\n\r\n private _onBeforeRenderObserver: Nullable<Observer<Effect>>;\r\n /**\r\n * A function that is added to the onBeforeRenderObservable\r\n */\r\n public set onBeforeRender(callback: (effect: Effect) => void) {\r\n if (this._onBeforeRenderObserver) {\r\n this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n }\r\n this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered after rendering the postprocess\r\n */\r\n public onAfterRenderObservable = new Observable<Effect>();\r\n\r\n private _onAfterRenderObserver: Nullable<Observer<Effect>>;\r\n /**\r\n * A function that is added to the onAfterRenderObservable\r\n */\r\n public set onAfterRender(callback: (efect: Effect) => void) {\r\n if (this._onAfterRenderObserver) {\r\n this.onAfterRenderObservable.remove(this._onAfterRenderObserver);\r\n }\r\n this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);\r\n }\r\n\r\n /**\r\n * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will\r\n * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.\r\n */\r\n public get inputTexture(): RenderTargetWrapper {\r\n return this._textures.data[this._currentRenderTextureInd];\r\n }\r\n\r\n public set inputTexture(value: RenderTargetWrapper) {\r\n this._forcedOutputTexture = value;\r\n }\r\n\r\n /**\r\n * Since inputTexture should always be defined, if we previously manually set `inputTexture`,\r\n * the only way to unset it is to use this function to restore its internal state\r\n */\r\n public restoreDefaultInputTexture() {\r\n if (this._forcedOutputTexture) {\r\n this._forcedOutputTexture = null;\r\n this.markTextureDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the camera which post process is applied to.\r\n * @returns The camera the post process is applied to.\r\n */\r\n public getCamera(): Camera {\r\n return this._camera;\r\n }\r\n\r\n /**\r\n * Gets the texel size of the postprocess.\r\n * See https://en.wikipedia.org/wiki/Texel_(graphics)\r\n */\r\n public get texelSize(): Vector2 {\r\n if (this._shareOutputWithPostProcess) {\r\n return this._shareOutputWithPostProcess.texelSize;\r\n }\r\n\r\n if (this._forcedOutputTexture) {\r\n this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);\r\n }\r\n\r\n return this._texelSize;\r\n }\r\n\r\n /**\r\n * Creates a new instance PostProcess\r\n * @param name The name of the PostProcess.\r\n * @param fragmentUrl The url of the fragment shader to be used.\r\n * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.\r\n * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.\r\n * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)\r\n * @param camera The camera to apply the render pass to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param defines String of defines that will be set when running the fragment shader. (default: null)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param vertexUrl The url of the vertex shader to be used. (default: \"postprocess\")\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param blockCompilation If the shader should not be compiled immediatly. (default: false)\r\n * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)\r\n */\r\n constructor(\r\n name: string,\r\n fragmentUrl: string,\r\n parameters: Nullable<string[]>,\r\n samplers: Nullable<string[]>,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode: number = Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n engine?: Engine,\r\n reusable?: boolean,\r\n defines: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n vertexUrl: string = \"postprocess\",\r\n indexParameters?: any,\r\n blockCompilation = false,\r\n textureFormat = Constants.TEXTUREFORMAT_RGBA,\r\n shaderLanguage = ShaderLanguage.GLSL\r\n ) {\r\n this.name = name;\r\n if (camera != null) {\r\n this._camera = camera;\r\n this._scene = camera.getScene();\r\n camera.attachPostProcess(this);\r\n this._engine = this._scene.getEngine();\r\n\r\n this._scene.postProcesses.push(this);\r\n this.uniqueId = this._scene.getUniqueId();\r\n } else if (engine) {\r\n this._engine = engine;\r\n this._engine.postProcesses.push(this);\r\n }\r\n this._options = options;\r\n this.renderTargetSamplingMode = samplingMode ? samplingMode : Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n this._reusable = reusable || false;\r\n this._textureType = textureType;\r\n this._textureFormat = textureFormat;\r\n this._shaderLanguage = shaderLanguage;\r\n\r\n this._samplers = samplers || [];\r\n this._samplers.push(\"textureSampler\");\r\n\r\n this._fragmentUrl = fragmentUrl;\r\n this._vertexUrl = vertexUrl;\r\n this._parameters = parameters || [];\r\n\r\n this._parameters.push(\"scale\");\r\n\r\n this._indexParameters = indexParameters;\r\n this._drawWrapper = new DrawWrapper(this._engine);\r\n\r\n if (!blockCompilation) {\r\n this.updateEffect(defines);\r\n }\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"PostProcess\" string\r\n */\r\n public getClassName(): string {\r\n return \"PostProcess\";\r\n }\r\n\r\n /**\r\n * Gets the engine which this post process belongs to.\r\n * @returns The engine the post process was enabled with.\r\n */\r\n public getEngine(): Engine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * The effect that is created when initializing the post process.\r\n * @returns The created effect corresponding the the postprocess.\r\n */\r\n public getEffect(): Effect {\r\n return this._drawWrapper.effect!;\r\n }\r\n\r\n /**\r\n * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.\r\n * @param postProcess The post process to share the output with.\r\n * @returns This post process.\r\n */\r\n public shareOutputWith(postProcess: PostProcess): PostProcess {\r\n this._disposeTextures();\r\n\r\n this._shareOutputWithPostProcess = postProcess;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.\r\n * This should be called if the post process that shares output with this post process is disabled/disposed.\r\n */\r\n public useOwnOutput() {\r\n if (this._textures.length == 0) {\r\n this._textures = new SmartArray<RenderTargetWrapper>(2);\r\n }\r\n\r\n this._shareOutputWithPostProcess = null;\r\n }\r\n\r\n /**\r\n * Updates the effect with the current post process compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)\r\n * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)\r\n */\r\n public updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void,\r\n vertexUrl?: string,\r\n fragmentUrl?: string\r\n ) {\r\n const customShaderCodeProcessing = PostProcess._GetShaderCodeProcessing(this.name);\r\n if (customShaderCodeProcessing?.defineCustomBindings) {\r\n const newUniforms = uniforms?.slice() ?? [];\r\n newUniforms.push(...this._parameters);\r\n\r\n const newSamplers = samplers?.slice() ?? [];\r\n newSamplers.push(...this._samplers);\r\n\r\n defines = customShaderCodeProcessing.defineCustomBindings(this.name, defines, newUniforms, newSamplers);\r\n uniforms = newUniforms;\r\n samplers = newSamplers;\r\n }\r\n this._postProcessDefines = defines;\r\n this._drawWrapper.effect = this._engine.createEffect(\r\n { vertex: vertexUrl ?? this._vertexUrl, fragment: fragmentUrl ?? this._fragmentUrl },\r\n {\r\n attributes: [\"position\"],\r\n uniformsNames: uniforms || this._parameters,\r\n uniformBuffersNames: [],\r\n samplers: samplers || this._samplers,\r\n defines: defines !== null ? defines : \"\",\r\n fallbacks: null,\r\n onCompiled: onCompiled ?? null,\r\n onError: onError ?? null,\r\n indexParameters: indexParameters || this._indexParameters,\r\n processCodeAfterIncludes: customShaderCodeProcessing?.processCodeAfterIncludes\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing!.processCodeAfterIncludes!(this.name, shaderType, code)\r\n : null,\r\n processFinalCode: customShaderCodeProcessing?.processFinalCode\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing!.processFinalCode!(this.name, shaderType, code)\r\n : null,\r\n shaderLanguage: this._shaderLanguage,\r\n },\r\n this._engine\r\n );\r\n }\r\n\r\n /**\r\n * The post process is reusable if it can be used multiple times within one frame.\r\n * @returns If the post process is reusable\r\n */\r\n public isReusable(): boolean {\r\n return this._reusable;\r\n }\r\n\r\n /** invalidate frameBuffer to hint the postprocess to create a depth buffer */\r\n public markTextureDirty(): void {\r\n this.width = -1;\r\n }\r\n\r\n private _createRenderTargetTexture(textureSize: { width: number; height: number }, textureOptions: RenderTargetCreationOptions, channel = 0) {\r\n for (let i = 0; i < this._textureCache.length; i++) {\r\n if (\r\n this._textureCache[i].texture.width === textureSize.width &&\r\n this._textureCache[i].texture.height === textureSize.height &&\r\n this._textureCache[i].postProcessChannel === channel &&\r\n this._textureCache[i].texture._generateDepthBuffer === textureOptions.generateDepthBuffer &&\r\n this._textureCache[i].texture.samples === textureOptions.samples\r\n ) {\r\n return this._textureCache[i].texture;\r\n }\r\n }\r\n\r\n const tex = this._engine.createRenderTargetTexture(textureSize, textureOptions);\r\n this._textureCache.push({ texture: tex, postProcessChannel: channel, lastUsedRenderId: -1 });\r\n\r\n return tex;\r\n }\r\n\r\n private _flushTextureCache() {\r\n const currentRenderId = this._renderId;\r\n\r\n for (let i = this._textureCache.length - 1; i >= 0; i--) {\r\n if (currentRenderId - this._textureCache[i].lastUsedRenderId > 100) {\r\n let currentlyUsed = false;\r\n for (let j = 0; j < this._textures.length; j++) {\r\n if (this._textures.data[j] === this._textureCache[i].texture) {\r\n currentlyUsed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!currentlyUsed) {\r\n this._textureCache[i].texture.dispose();\r\n this._textureCache.splice(i, 1);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _resize(width: number, height: number, camera: Camera, needMipMaps: boolean, forceDepthStencil?: boolean) {\r\n if (this._textures.length > 0) {\r\n this._textures.reset();\r\n }\r\n\r\n this.width = width;\r\n this.height = height;\r\n\r\n let firstPP = null;\r\n for (let i = 0; i < camera._postProcesses.length; i++) {\r\n if (camera._postProcesses[i] !== null) {\r\n firstPP = camera._postProcesses[i];\r\n break;\r\n }\r\n }\r\n\r\n const textureSize = { width: this.width, height: this.height };\r\n const textureOptions = {\r\n generateMipMaps: needMipMaps,\r\n generateDepthBuffer: forceDepthStencil || firstPP === this,\r\n generateStencilBuffer: (forceDepthStencil || firstPP === this) && this._engine.isStencilEnable,\r\n samplingMode: this.renderTargetSamplingMode,\r\n type: this._textureType,\r\n format: this._textureFormat,\r\n samples: this._samples,\r\n label: \"PostProcessRTT-\" + this.name,\r\n };\r\n\r\n this._textures.push(this._createRenderTargetTexture(textureSize, textureOptions, 0));\r\n\r\n if (this._reusable) {\r\n this._textures.push(this._createRenderTargetTexture(textureSize, textureOptions, 1));\r\n }\r\n\r\n this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);\r\n\r\n this.onSizeChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.\r\n * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.\r\n * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.\r\n * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)\r\n * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)\r\n * @returns The render target wrapper that was bound to be written to.\r\n */\r\n public activate(camera: Nullable<Camera>, sourceTexture: Nullable<InternalTexture> = null, forceDepthStencil?: boolean): RenderTargetWrapper {\r\n camera = camera || this._camera;\r\n\r\n const scene = camera.getScene();\r\n const engine = scene.getEngine();\r\n const maxSize = engine.getCaps().maxTextureSize;\r\n\r\n let requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * <number>this._options) | 0;\r\n const requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * <number>this._options) | 0;\r\n\r\n // If rendering to a webvr camera's left or right eye only half the width should be used to avoid resize when rendered to screen\r\n const webVRCamera = <WebVRFreeCamera>camera.parent;\r\n if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {\r\n requiredWidth /= 2;\r\n }\r\n\r\n let desiredWidth = (<PostProcessOptions>this._options).width || requiredWidth;\r\n let desiredHeight = (<PostProcessOptions>this._options).height || requiredHeight;\r\n\r\n const needMipMaps =\r\n this.renderTargetSamplingMode !== Constants.TEXTURE_NEAREST_LINEAR &&\r\n this.renderTargetSamplingMode !== Constants.TEXTURE_NEAREST_NEAREST &&\r\n this.renderTargetSamplingMode !== Constants.TEXTURE_LINEAR_LINEAR;\r\n\r\n if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {\r\n if (this.adaptScaleToCurrentViewport) {\r\n const currentViewport = engine.currentViewport;\r\n\r\n if (currentViewport) {\r\n desiredWidth *= currentViewport.width;\r\n desiredHeight *= currentViewport.height;\r\n }\r\n }\r\n\r\n if (needMipMaps || this.alwaysForcePOT) {\r\n if (!(<PostProcessOptions>this._options).width) {\r\n desiredWidth = engine.needPOTTextures ? Engine.GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;\r\n }\r\n\r\n if (!(<PostProcessOptions>this._options).height) {\r\n desiredHeight = engine.needPOTTextures ? Engine.GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;\r\n }\r\n }\r\n\r\n if (this.width !== desiredWidth || this.height !== desiredHeight) {\r\n this._resize(desiredWidth, desiredHeight, camera, needMipMaps, forceDepthStencil);\r\n }\r\n\r\n this._textures.forEach((texture) => {\r\n if (texture.samples !== this.samples) {\r\n this._engine.updateRenderTargetTextureSampleCount(texture, this.samples);\r\n }\r\n });\r\n\r\n this._flushTextureCache();\r\n this._renderId++;\r\n }\r\n\r\n let target: RenderTargetWrapper;\r\n\r\n if (this._shareOutputWithPostProcess) {\r\n target = this._shareOutputWithPostProcess.inputTexture;\r\n } else if (this._forcedOutputTexture) {\r\n target = this._forcedOutputTexture;\r\n\r\n this.width = this._forcedOutputTexture.width;\r\n this.height = this._forcedOutputTexture.height;\r\n } else {\r\n target = this.inputTexture;\r\n\r\n let cache;\r\n for (let i = 0; i < this._textureCache.length; i++) {\r\n if (this._textureCache[i].texture === target) {\r\n cache = this._textureCache[i];\r\n break;\r\n }\r\n }\r\n\r\n if (cache) {\r\n cache.lastUsedRenderId = this._renderId;\r\n }\r\n }\r\n\r\n // Bind the input of this post process to be used as the output of the previous post process.\r\n if (this.enablePixelPerfectMode) {\r\n this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);\r\n this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);\r\n } else {\r\n this._scaleRatio.copyFromFloats(1, 1);\r\n this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);\r\n }\r\n\r\n this._engine._debugInsertMarker?.(`post process ${this.name} input`);\r\n\r\n this.onActivateObservable.notifyObservers(camera);\r\n\r\n // Clear\r\n if (this.autoClear && this.alphaMode === Constants.ALPHA_DISABLE) {\r\n this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);\r\n }\r\n\r\n if (this._reusable) {\r\n this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;\r\n }\r\n return target;\r\n }\r\n\r\n /**\r\n * If the post process is supported.\r\n */\r\n public get isSupported(): boolean {\r\n return this._drawWrapper.effect!.isSupported;\r\n }\r\n\r\n /**\r\n * The aspect ratio of the output texture.\r\n */\r\n public get aspectRatio(): number {\r\n if (this._shareOutputWithPostProcess) {\r\n return this._shareOutputWithPostProcess.aspectRatio;\r\n }\r\n\r\n if (this._forcedOutputTexture) {\r\n return this._forcedOutputTexture.width / this._forcedOutputTexture.height;\r\n }\r\n return this.width / this.height;\r\n }\r\n\r\n /**\r\n * Get a value indicating if the post-process is ready to be used\r\n * @returns true if the post-process is ready (shader is compiled)\r\n */\r\n public isReady(): boolean {\r\n return this._drawWrapper.effect?.isReady() ?? false;\r\n }\r\n\r\n /**\r\n * Binds all textures and uniforms to the shader, this will be run on every pass.\r\n * @returns the effect corresponding to this post process. Null if not compiled or not ready.\r\n */\r\n public apply(): Nullable<Effect> {\r\n // Check\r\n if (!this._drawWrapper.effect?.isReady()) {\r\n return null;\r\n }\r\n\r\n // States\r\n this._engine.enableEffect(this._drawWrapper);\r\n this._engine.setState(false);\r\n this._engine.setDepthBuffer(false);\r\n this._engine.setDepthWrite(false);\r\n\r\n // Alpha\r\n this._engine.setAlphaMode(this.alphaMode);\r\n if (this.alphaConstants) {\r\n this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);\r\n }\r\n\r\n // Bind the output texture of the preivous post process as the input to this post process.\r\n let source: RenderTargetWrapper;\r\n if (this._shareOutputWithPostProcess) {\r\n source = this._shareOutputWithPostProcess.inputTexture;\r\n } else if (this._forcedOutputTexture) {\r\n source = this._forcedOutputTexture;\r\n } else {\r\n source = this.inputTexture;\r\n }\r\n\r\n if (!this.externalTextureSamplerBinding) {\r\n this._drawWrapper.effect._bindTexture(\"textureSampler\", source?.texture);\r\n }\r\n\r\n // Parameters\r\n this._drawWrapper.effect.setVector2(\"scale\", this._scaleRatio);\r\n this.onApplyObservable.notifyObservers(this._drawWrapper.effect);\r\n\r\n PostProcess._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name, this._drawWrapper.effect);\r\n\r\n return this._drawWrapper.effect;\r\n }\r\n\r\n private _disposeTextures() {\r\n if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {\r\n this._disposeTextureCache();\r\n return;\r\n }\r\n\r\n this._disposeTextureCache();\r\n this._textures.dispose();\r\n }\r\n\r\n private _disposeTextureCache() {\r\n for (let i = this._textureCache.length - 1; i >= 0; i--) {\r\n this._textureCache[i].texture.dispose();\r\n }\r\n\r\n this._textureCache.length = 0;\r\n }\r\n\r\n /**\r\n * Sets the required values to the prepass renderer.\r\n * @param prePassRenderer defines the prepass renderer to setup.\r\n * @returns true if the pre pass is needed.\r\n */\r\n public setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean {\r\n if (this._prePassEffectConfiguration) {\r\n this._prePassEffectConfiguration = prePassRenderer.addEffectConfiguration(this._prePassEffectConfiguration);\r\n this._prePassEffectConfiguration.enabled = true;\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Disposes the post process.\r\n * @param camera The camera to dispose the post process on.\r\n */\r\n public dispose(camera?: Camera): void {\r\n camera = camera || this._camera;\r\n\r\n this._disposeTextures();\r\n\r\n let index;\r\n if (this._scene) {\r\n index = this._scene.postProcesses.indexOf(this);\r\n if (index !== -1) {\r\n this._scene.postProcesses.splice(index, 1);\r\n }\r\n }\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.postProcesses.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.postProcesses.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n index = this._engine.postProcesses.indexOf(this);\r\n if (index !== -1) {\r\n this._engine.postProcesses.splice(index, 1);\r\n }\r\n\r\n if (!camera) {\r\n return;\r\n }\r\n camera.detachPostProcess(this);\r\n\r\n index = camera._postProcesses.indexOf(this);\r\n if (index === 0 && camera._postProcesses.length > 0) {\r\n const firstPostProcess = this._camera._getFirstPostProcess();\r\n if (firstPostProcess) {\r\n firstPostProcess.markTextureDirty();\r\n }\r\n }\r\n\r\n this.onActivateObservable.clear();\r\n this.onAfterRenderObservable.clear();\r\n this.onApplyObservable.clear();\r\n this.onBeforeRenderObservable.clear();\r\n this.onSizeChangedObservable.clear();\r\n }\r\n\r\n /**\r\n * Serializes the post process to a JSON object\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n const camera = this.getCamera() || (this._scene && this._scene.activeCamera);\r\n serializationObject.customType = \"BABYLON.\" + this.getClassName();\r\n serializationObject.cameraId = camera ? camera.id : null;\r\n serializationObject.reusable = this._reusable;\r\n serializationObject.textureType = this._textureType;\r\n serializationObject.fragmentUrl = this._fragmentUrl;\r\n serializationObject.parameters = this._parameters;\r\n serializationObject.samplers = this._samplers;\r\n serializationObject.options = this._options;\r\n serializationObject.defines = this._postProcessDefines;\r\n serializationObject.textureFormat = this._textureFormat;\r\n serializationObject.vertexUrl = this._vertexUrl;\r\n serializationObject.indexParameters = this._indexParameters;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Clones this post process\r\n * @returns a new post process similar to this one\r\n */\r\n public clone(): Nullable<PostProcess> {\r\n const serializationObject = this.serialize();\r\n serializationObject._engine = this._engine;\r\n serializationObject.cameraId = null;\r\n\r\n const result = PostProcess.Parse(serializationObject, this._scene, \"\");\r\n\r\n if (!result) {\r\n return null;\r\n }\r\n\r\n result.onActivateObservable = this.onActivateObservable.clone();\r\n result.onSizeChangedObservable = this.onSizeChangedObservable.clone();\r\n result.onApplyObservable = this.onApplyObservable.clone();\r\n result.onBeforeRenderObservable = this.onBeforeRenderObservable.clone();\r\n result.onAfterRenderObservable = this.onAfterRenderObservable.clone();\r\n\r\n result._prePassEffectConfiguration = this._prePassEffectConfiguration;\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a material from parsed material data\r\n * @param parsedPostProcess defines parsed post process data\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures\r\n * @returns a new post process\r\n */\r\n public static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess> {\r\n const postProcessType = GetClass(parsedPostProcess.customType);\r\n\r\n if (!postProcessType || !postProcessType._Parse) {\r\n return null;\r\n }\r\n\r\n const camera = scene ? scene.getCameraById(parsedPostProcess.cameraId) : null;\r\n return postProcessType._Parse(parsedPostProcess, camera, scene, rootUrl);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new PostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.fragmentUrl,\r\n parsedPostProcess.parameters,\r\n parsedPostProcess.samplers,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess._engine,\r\n parsedPostProcess.reusable,\r\n parsedPostProcess.defines,\r\n parsedPostProcess.textureType,\r\n parsedPostProcess.vertexUrl,\r\n parsedPostProcess.indexParameters,\r\n false,\r\n parsedPostProcess.textureFormat\r\n );\r\n },\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.PostProcess\", PostProcess);\r\n"]}
|
|
1
|
+
{"version":3,"file":"postProcess.js","sourceRoot":"","sources":["../../../../lts/core/generated/PostProcesses/postProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,2CAA2C,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM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,EAC7B,iBAAiB,CAAC,SAAS,EAC3B,iBAAiB,CAAC,eAAe,EACjC,KAAK,EACL,iBAAiB,CAAC,aAAa,CAClC,CAAC;QACN,CAAC,EACD,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;;AAv9Bc,uCAA2B,GAAyE,EAAE,CAAC;AAyBtH;IADC,SAAS,EAAE;6CACY;AAIxB;IADC,SAAS,EAAE;yCACQ;AAMpB;IADC,SAAS,EAAE;0CACM;AAMlB;IADC,SAAS,EAAE;2CACO;AAiBnB;IADC,SAAS,EAAE;6DAC4B;AAKxC;IADC,iBAAiB,EAAE;+CACM;AAM1B;IADC,SAAS,EAAE;8CACY;AAMxB;IADC,SAAS,EAAE;8DAC6B;AAKzC;IADC,SAAS,EAAE;8CAC+B;AAK3C;IADC,SAAS,EAAE;mDACkB;AAW9B;IADC,SAAS,EAAE;2DAC0B;AAMtC;IADC,SAAS,EAAE;4DAC0B;AAmBtC;IADC,SAAS,EAAE;8CACiC;AAK7C;IADC,SAAS,EAAE;mDACkB;AAG9B;IADC,SAAS,CAAC,SAAS,CAAC;6CACA;AAqBrB;IADC,SAAS,EAAE;gEAC+B;AAo0B/C,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { RenderTargetCreationOptions } from \"../Materials/Textures/textureCreationOptions\";\r\nimport \"../Shaders/postprocess.vertex\";\r\nimport type { IInspectable } from \"../Misc/iInspectable\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { Color4 } from \"../Maths/math.color\";\r\n\r\nimport \"../Engines/Extensions/engine.renderTarget\";\r\nimport type { NodeMaterial } from \"../Materials/Node/nodeMaterial\";\r\nimport { serialize, serializeAsColor4, SerializationHelper } from \"../Misc/decorators\";\r\nimport { GetClass, RegisterClass } from \"../Misc/typeStore\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { AbstractScene } from \"../abstractScene\";\r\nimport type { RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport { ShaderLanguage } from \"../Materials/shaderLanguage\";\r\n\r\ndeclare type Scene = import(\"../scene\").Scene;\r\ndeclare type InternalTexture = import(\"../Materials/Textures/internalTexture\").InternalTexture;\r\ndeclare type WebVRFreeCamera = import(\"../Cameras/VR/webVRCamera\").WebVRFreeCamera;\r\ndeclare type Animation = import(\"../Animations/animation\").Animation;\r\ndeclare type PrePassRenderer = import(\"../Rendering/prePassRenderer\").PrePassRenderer;\r\ndeclare type PrePassEffectConfiguration = import(\"../Rendering/prePassEffectConfiguration\").PrePassEffectConfiguration;\r\n\r\n/**\r\n * Allows for custom processing of the shader code used by a post process\r\n */\r\nexport type PostProcessCustomShaderCodeProcessing = {\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated after the #include have been processed\r\n */\r\n processCodeAfterIncludes?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called before creating the effect to collect additional custom bindings (defines, uniforms, samplers)\r\n */\r\n defineCustomBindings?: (postProcessName: string, defines: Nullable<string>, uniforms: string[], samplers: string[]) => Nullable<string>;\r\n /**\r\n * If provided, will be called when binding inputs to the shader code to allow the user to add custom bindings\r\n */\r\n bindCustomBindings?: (postProcessName: string, effect: Effect) => void;\r\n};\r\n\r\n/**\r\n * Size options for a post process\r\n */\r\nexport type PostProcessOptions = { width: number; height: number };\r\n\r\ntype TextureCache = { texture: RenderTargetWrapper; postProcessChannel: number; lastUsedRenderId: number };\r\n\r\n/**\r\n * PostProcess can be used to apply a shader to a texture after it has been rendered\r\n * See https://doc.babylonjs.com/features/featuresDeepDive/postProcesses/usePostProcesses\r\n */\r\nexport class PostProcess {\r\n /** @internal */\r\n public _parentContainer: Nullable<AbstractScene> = null;\r\n\r\n private static _CustomShaderCodeProcessing: { [postProcessName: string]: PostProcessCustomShaderCodeProcessing } = {};\r\n\r\n /**\r\n * Registers a shader code processing with a post process name.\r\n * @param postProcessName name of the post process. Use null for the fallback shader code processing. This is the shader code processing that will be used in case no specific shader code processing has been associated to a post process name\r\n * @param customShaderCodeProcessing shader code processing to associate to the post process name\r\n * @returns\r\n */\r\n public static RegisterShaderCodeProcessing(postProcessName: Nullable<string>, customShaderCodeProcessing?: PostProcessCustomShaderCodeProcessing) {\r\n if (!customShaderCodeProcessing) {\r\n delete PostProcess._CustomShaderCodeProcessing[postProcessName ?? \"\"];\r\n return;\r\n }\r\n\r\n PostProcess._CustomShaderCodeProcessing[postProcessName ?? \"\"] = customShaderCodeProcessing;\r\n }\r\n\r\n private static _GetShaderCodeProcessing(postProcessName: string) {\r\n return PostProcess._CustomShaderCodeProcessing[postProcessName] ?? PostProcess._CustomShaderCodeProcessing[\"\"];\r\n }\r\n\r\n /**\r\n * Gets or sets the unique id of the post process\r\n */\r\n @serialize()\r\n public uniqueId: number;\r\n\r\n /** Name of the PostProcess. */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * Width of the texture to apply the post process on\r\n */\r\n @serialize()\r\n public width = -1;\r\n\r\n /**\r\n * Height of the texture to apply the post process on\r\n */\r\n @serialize()\r\n public height = -1;\r\n\r\n /**\r\n * Gets the node material used to create this postprocess (null if the postprocess was manually created)\r\n */\r\n public nodeMaterialSource: Nullable<NodeMaterial> = null;\r\n\r\n /**\r\n * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)\r\n * @internal\r\n */\r\n public _outputTexture: Nullable<RenderTargetWrapper> = null;\r\n /**\r\n * Sampling mode used by the shader\r\n * See https://doc.babylonjs.com/classes/3.1/texture\r\n */\r\n @serialize()\r\n public renderTargetSamplingMode: number;\r\n /**\r\n * Clear color to use when screen clearing\r\n */\r\n @serializeAsColor4()\r\n public clearColor: Color4;\r\n /**\r\n * If the buffer needs to be cleared before applying the post process. (default: true)\r\n * Should be set to false if shader will overwrite all previous pixels.\r\n */\r\n @serialize()\r\n public autoClear = true;\r\n /**\r\n * If clearing the buffer should be forced in autoClear mode, even when alpha mode is enabled (default: false).\r\n * By default, the buffer will only be cleared if alpha mode is disabled (and autoClear is true).\r\n */\r\n @serialize()\r\n public forceAutoClearInAlphaMode = false;\r\n /**\r\n * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)\r\n */\r\n @serialize()\r\n public alphaMode = Constants.ALPHA_DISABLE;\r\n /**\r\n * Sets the setAlphaBlendConstants of the babylon engine\r\n */\r\n @serialize()\r\n public alphaConstants: Color4;\r\n /**\r\n * Animations to be used for the post processing\r\n */\r\n public animations = new Array<Animation>();\r\n\r\n /**\r\n * Enable Pixel Perfect mode where texture is not scaled to be power of 2.\r\n * Can only be used on a single postprocess or on the last one of a chain. (default: false)\r\n */\r\n @serialize()\r\n public enablePixelPerfectMode = false;\r\n\r\n /**\r\n * Force the postprocess to be applied without taking in account viewport\r\n */\r\n @serialize()\r\n public forceFullscreenViewport = true;\r\n\r\n /**\r\n * List of inspectable custom properties (used by the Inspector)\r\n * @see https://doc.babylonjs.com/toolsAndResources/inspector#extensibility\r\n */\r\n public inspectableCustomProperties: IInspectable[];\r\n\r\n /**\r\n * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)\r\n *\r\n * | Value | Type | Description |\r\n * | ----- | ----------------------------------- | ----------- |\r\n * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |\r\n * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |\r\n * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |\r\n *\r\n */\r\n @serialize()\r\n public scaleMode = Constants.SCALEMODE_FLOOR;\r\n /**\r\n * Force textures to be a power of two (default: false)\r\n */\r\n @serialize()\r\n public alwaysForcePOT = false;\r\n\r\n @serialize(\"samples\")\r\n private _samples = 1;\r\n\r\n /**\r\n * Number of sample textures (default: 1)\r\n */\r\n public get samples() {\r\n return this._samples;\r\n }\r\n\r\n public set samples(n: number) {\r\n this._samples = Math.min(n, this._engine.getCaps().maxMSAASamples);\r\n\r\n this._textures.forEach((texture) => {\r\n texture.setSamples(this._samples);\r\n });\r\n }\r\n\r\n /**\r\n * Modify the scale of the post process to be the same as the viewport (default: false)\r\n */\r\n @serialize()\r\n public adaptScaleToCurrentViewport = false;\r\n\r\n private _camera: Camera;\r\n protected _scene: Scene;\r\n private _engine: Engine;\r\n\r\n private _options: number | PostProcessOptions;\r\n private _reusable = false;\r\n private _renderId = 0;\r\n private _textureType: number;\r\n private _textureFormat: number;\r\n private _shaderLanguage: ShaderLanguage;\r\n\r\n /**\r\n * if externalTextureSamplerBinding is true, the \"apply\" method won't bind the textureSampler texture, it is expected to be done by the \"outside\" (by the onApplyObservable observer most probably).\r\n * counter-productive in some cases because if the texture bound by \"apply\" is different from the currently texture bound, (the one set by the onApplyObservable observer, for eg) some\r\n * internal structures (materialContext) will be dirtified, which may impact performances\r\n */\r\n public externalTextureSamplerBinding = false;\r\n\r\n /**\r\n * Smart array of input and output textures for the post process.\r\n * @internal\r\n */\r\n public _textures = new SmartArray<RenderTargetWrapper>(2);\r\n /**\r\n * Smart array of input and output textures for the post process.\r\n * @internal\r\n */\r\n private _textureCache: TextureCache[] = [];\r\n /**\r\n * The index in _textures that corresponds to the output texture.\r\n * @internal\r\n */\r\n public _currentRenderTextureInd = 0;\r\n private _drawWrapper: DrawWrapper;\r\n private _samplers: string[];\r\n private _fragmentUrl: string;\r\n private _vertexUrl: string;\r\n private _parameters: string[];\r\n protected _postProcessDefines: Nullable<string>;\r\n private _scaleRatio = new Vector2(1, 1);\r\n protected _indexParameters: any;\r\n private _shareOutputWithPostProcess: Nullable<PostProcess>;\r\n private _texelSize = Vector2.Zero();\r\n\r\n /** @internal */\r\n public _forcedOutputTexture: Nullable<RenderTargetWrapper>;\r\n\r\n /**\r\n * Prepass configuration in case this post process needs a texture from prepass\r\n * @internal\r\n */\r\n public _prePassEffectConfiguration: PrePassEffectConfiguration;\r\n\r\n /**\r\n * Returns the fragment url or shader name used in the post process.\r\n * @returns the fragment url or name in the shader store.\r\n */\r\n public getEffectName(): string {\r\n return this._fragmentUrl;\r\n }\r\n\r\n // Events\r\n\r\n /**\r\n * An event triggered when the postprocess is activated.\r\n */\r\n public onActivateObservable = new Observable<Camera>();\r\n\r\n private _onActivateObserver: Nullable<Observer<Camera>>;\r\n /**\r\n * A function that is added to the onActivateObservable\r\n */\r\n public set onActivate(callback: Nullable<(camera: Camera) => void>) {\r\n if (this._onActivateObserver) {\r\n this.onActivateObservable.remove(this._onActivateObserver);\r\n }\r\n if (callback) {\r\n this._onActivateObserver = this.onActivateObservable.add(callback);\r\n }\r\n }\r\n\r\n /**\r\n * An event triggered when the postprocess changes its size.\r\n */\r\n public onSizeChangedObservable = new Observable<PostProcess>();\r\n\r\n private _onSizeChangedObserver: Nullable<Observer<PostProcess>>;\r\n /**\r\n * A function that is added to the onSizeChangedObservable\r\n */\r\n public set onSizeChanged(callback: (postProcess: PostProcess) => void) {\r\n if (this._onSizeChangedObserver) {\r\n this.onSizeChangedObservable.remove(this._onSizeChangedObserver);\r\n }\r\n this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered when the postprocess applies its effect.\r\n */\r\n public onApplyObservable = new Observable<Effect>();\r\n\r\n private _onApplyObserver: Nullable<Observer<Effect>>;\r\n /**\r\n * A function that is added to the onApplyObservable\r\n */\r\n public set onApply(callback: (effect: Effect) => void) {\r\n if (this._onApplyObserver) {\r\n this.onApplyObservable.remove(this._onApplyObserver);\r\n }\r\n this._onApplyObserver = this.onApplyObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered before rendering the postprocess\r\n */\r\n public onBeforeRenderObservable = new Observable<Effect>();\r\n\r\n private _onBeforeRenderObserver: Nullable<Observer<Effect>>;\r\n /**\r\n * A function that is added to the onBeforeRenderObservable\r\n */\r\n public set onBeforeRender(callback: (effect: Effect) => void) {\r\n if (this._onBeforeRenderObserver) {\r\n this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n }\r\n this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);\r\n }\r\n\r\n /**\r\n * An event triggered after rendering the postprocess\r\n */\r\n public onAfterRenderObservable = new Observable<Effect>();\r\n\r\n private _onAfterRenderObserver: Nullable<Observer<Effect>>;\r\n /**\r\n * A function that is added to the onAfterRenderObservable\r\n */\r\n public set onAfterRender(callback: (efect: Effect) => void) {\r\n if (this._onAfterRenderObserver) {\r\n this.onAfterRenderObservable.remove(this._onAfterRenderObserver);\r\n }\r\n this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);\r\n }\r\n\r\n /**\r\n * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will\r\n * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.\r\n */\r\n public get inputTexture(): RenderTargetWrapper {\r\n return this._textures.data[this._currentRenderTextureInd];\r\n }\r\n\r\n public set inputTexture(value: RenderTargetWrapper) {\r\n this._forcedOutputTexture = value;\r\n }\r\n\r\n /**\r\n * Since inputTexture should always be defined, if we previously manually set `inputTexture`,\r\n * the only way to unset it is to use this function to restore its internal state\r\n */\r\n public restoreDefaultInputTexture() {\r\n if (this._forcedOutputTexture) {\r\n this._forcedOutputTexture = null;\r\n this.markTextureDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the camera which post process is applied to.\r\n * @returns The camera the post process is applied to.\r\n */\r\n public getCamera(): Camera {\r\n return this._camera;\r\n }\r\n\r\n /**\r\n * Gets the texel size of the postprocess.\r\n * See https://en.wikipedia.org/wiki/Texel_(graphics)\r\n */\r\n public get texelSize(): Vector2 {\r\n if (this._shareOutputWithPostProcess) {\r\n return this._shareOutputWithPostProcess.texelSize;\r\n }\r\n\r\n if (this._forcedOutputTexture) {\r\n this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);\r\n }\r\n\r\n return this._texelSize;\r\n }\r\n\r\n /**\r\n * Creates a new instance PostProcess\r\n * @param name The name of the PostProcess.\r\n * @param fragmentUrl The url of the fragment shader to be used.\r\n * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.\r\n * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.\r\n * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)\r\n * @param camera The camera to apply the render pass to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param defines String of defines that will be set when running the fragment shader. (default: null)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param vertexUrl The url of the vertex shader to be used. (default: \"postprocess\")\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param blockCompilation If the shader should not be compiled immediatly. (default: false)\r\n * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)\r\n */\r\n constructor(\r\n name: string,\r\n fragmentUrl: string,\r\n parameters: Nullable<string[]>,\r\n samplers: Nullable<string[]>,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode: number = Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n engine?: Engine,\r\n reusable?: boolean,\r\n defines: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n vertexUrl: string = \"postprocess\",\r\n indexParameters?: any,\r\n blockCompilation = false,\r\n textureFormat = Constants.TEXTUREFORMAT_RGBA,\r\n shaderLanguage = ShaderLanguage.GLSL\r\n ) {\r\n this.name = name;\r\n if (camera != null) {\r\n this._camera = camera;\r\n this._scene = camera.getScene();\r\n camera.attachPostProcess(this);\r\n this._engine = this._scene.getEngine();\r\n\r\n this._scene.postProcesses.push(this);\r\n this.uniqueId = this._scene.getUniqueId();\r\n } else if (engine) {\r\n this._engine = engine;\r\n this._engine.postProcesses.push(this);\r\n }\r\n this._options = options;\r\n this.renderTargetSamplingMode = samplingMode ? samplingMode : Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n this._reusable = reusable || false;\r\n this._textureType = textureType;\r\n this._textureFormat = textureFormat;\r\n this._shaderLanguage = shaderLanguage;\r\n\r\n this._samplers = samplers || [];\r\n this._samplers.push(\"textureSampler\");\r\n\r\n this._fragmentUrl = fragmentUrl;\r\n this._vertexUrl = vertexUrl;\r\n this._parameters = parameters || [];\r\n\r\n this._parameters.push(\"scale\");\r\n\r\n this._indexParameters = indexParameters;\r\n this._drawWrapper = new DrawWrapper(this._engine);\r\n\r\n if (!blockCompilation) {\r\n this.updateEffect(defines);\r\n }\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"PostProcess\" string\r\n */\r\n public getClassName(): string {\r\n return \"PostProcess\";\r\n }\r\n\r\n /**\r\n * Gets the engine which this post process belongs to.\r\n * @returns The engine the post process was enabled with.\r\n */\r\n public getEngine(): Engine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * The effect that is created when initializing the post process.\r\n * @returns The created effect corresponding the the postprocess.\r\n */\r\n public getEffect(): Effect {\r\n return this._drawWrapper.effect!;\r\n }\r\n\r\n /**\r\n * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.\r\n * @param postProcess The post process to share the output with.\r\n * @returns This post process.\r\n */\r\n public shareOutputWith(postProcess: PostProcess): PostProcess {\r\n this._disposeTextures();\r\n\r\n this._shareOutputWithPostProcess = postProcess;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.\r\n * This should be called if the post process that shares output with this post process is disabled/disposed.\r\n */\r\n public useOwnOutput() {\r\n if (this._textures.length == 0) {\r\n this._textures = new SmartArray<RenderTargetWrapper>(2);\r\n }\r\n\r\n this._shareOutputWithPostProcess = null;\r\n }\r\n\r\n /**\r\n * Updates the effect with the current post process compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)\r\n * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)\r\n */\r\n public updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void,\r\n vertexUrl?: string,\r\n fragmentUrl?: string\r\n ) {\r\n const customShaderCodeProcessing = PostProcess._GetShaderCodeProcessing(this.name);\r\n if (customShaderCodeProcessing?.defineCustomBindings) {\r\n const newUniforms = uniforms?.slice() ?? [];\r\n newUniforms.push(...this._parameters);\r\n\r\n const newSamplers = samplers?.slice() ?? [];\r\n newSamplers.push(...this._samplers);\r\n\r\n defines = customShaderCodeProcessing.defineCustomBindings(this.name, defines, newUniforms, newSamplers);\r\n uniforms = newUniforms;\r\n samplers = newSamplers;\r\n }\r\n this._postProcessDefines = defines;\r\n this._drawWrapper.effect = this._engine.createEffect(\r\n { vertex: vertexUrl ?? this._vertexUrl, fragment: fragmentUrl ?? this._fragmentUrl },\r\n {\r\n attributes: [\"position\"],\r\n uniformsNames: uniforms || this._parameters,\r\n uniformBuffersNames: [],\r\n samplers: samplers || this._samplers,\r\n defines: defines !== null ? defines : \"\",\r\n fallbacks: null,\r\n onCompiled: onCompiled ?? null,\r\n onError: onError ?? null,\r\n indexParameters: indexParameters || this._indexParameters,\r\n processCodeAfterIncludes: customShaderCodeProcessing?.processCodeAfterIncludes\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing!.processCodeAfterIncludes!(this.name, shaderType, code)\r\n : null,\r\n processFinalCode: customShaderCodeProcessing?.processFinalCode\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing!.processFinalCode!(this.name, shaderType, code)\r\n : null,\r\n shaderLanguage: this._shaderLanguage,\r\n },\r\n this._engine\r\n );\r\n }\r\n\r\n /**\r\n * The post process is reusable if it can be used multiple times within one frame.\r\n * @returns If the post process is reusable\r\n */\r\n public isReusable(): boolean {\r\n return this._reusable;\r\n }\r\n\r\n /** invalidate frameBuffer to hint the postprocess to create a depth buffer */\r\n public markTextureDirty(): void {\r\n this.width = -1;\r\n }\r\n\r\n private _createRenderTargetTexture(textureSize: { width: number; height: number }, textureOptions: RenderTargetCreationOptions, channel = 0) {\r\n for (let i = 0; i < this._textureCache.length; i++) {\r\n if (\r\n this._textureCache[i].texture.width === textureSize.width &&\r\n this._textureCache[i].texture.height === textureSize.height &&\r\n this._textureCache[i].postProcessChannel === channel &&\r\n this._textureCache[i].texture._generateDepthBuffer === textureOptions.generateDepthBuffer &&\r\n this._textureCache[i].texture.samples === textureOptions.samples\r\n ) {\r\n return this._textureCache[i].texture;\r\n }\r\n }\r\n\r\n const tex = this._engine.createRenderTargetTexture(textureSize, textureOptions);\r\n this._textureCache.push({ texture: tex, postProcessChannel: channel, lastUsedRenderId: -1 });\r\n\r\n return tex;\r\n }\r\n\r\n private _flushTextureCache() {\r\n const currentRenderId = this._renderId;\r\n\r\n for (let i = this._textureCache.length - 1; i >= 0; i--) {\r\n if (currentRenderId - this._textureCache[i].lastUsedRenderId > 100) {\r\n let currentlyUsed = false;\r\n for (let j = 0; j < this._textures.length; j++) {\r\n if (this._textures.data[j] === this._textureCache[i].texture) {\r\n currentlyUsed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!currentlyUsed) {\r\n this._textureCache[i].texture.dispose();\r\n this._textureCache.splice(i, 1);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _resize(width: number, height: number, camera: Camera, needMipMaps: boolean, forceDepthStencil?: boolean) {\r\n if (this._textures.length > 0) {\r\n this._textures.reset();\r\n }\r\n\r\n this.width = width;\r\n this.height = height;\r\n\r\n let firstPP = null;\r\n for (let i = 0; i < camera._postProcesses.length; i++) {\r\n if (camera._postProcesses[i] !== null) {\r\n firstPP = camera._postProcesses[i];\r\n break;\r\n }\r\n }\r\n\r\n const textureSize = { width: this.width, height: this.height };\r\n const textureOptions = {\r\n generateMipMaps: needMipMaps,\r\n generateDepthBuffer: forceDepthStencil || firstPP === this,\r\n generateStencilBuffer: (forceDepthStencil || firstPP === this) && this._engine.isStencilEnable,\r\n samplingMode: this.renderTargetSamplingMode,\r\n type: this._textureType,\r\n format: this._textureFormat,\r\n samples: this._samples,\r\n label: \"PostProcessRTT-\" + this.name,\r\n };\r\n\r\n this._textures.push(this._createRenderTargetTexture(textureSize, textureOptions, 0));\r\n\r\n if (this._reusable) {\r\n this._textures.push(this._createRenderTargetTexture(textureSize, textureOptions, 1));\r\n }\r\n\r\n this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);\r\n\r\n this.onSizeChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.\r\n * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.\r\n * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.\r\n * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)\r\n * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)\r\n * @returns The render target wrapper that was bound to be written to.\r\n */\r\n public activate(camera: Nullable<Camera>, sourceTexture: Nullable<InternalTexture> = null, forceDepthStencil?: boolean): RenderTargetWrapper {\r\n camera = camera || this._camera;\r\n\r\n const scene = camera.getScene();\r\n const engine = scene.getEngine();\r\n const maxSize = engine.getCaps().maxTextureSize;\r\n\r\n let requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * <number>this._options) | 0;\r\n const requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * <number>this._options) | 0;\r\n\r\n // If rendering to a webvr camera's left or right eye only half the width should be used to avoid resize when rendered to screen\r\n const webVRCamera = <WebVRFreeCamera>camera.parent;\r\n if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {\r\n requiredWidth /= 2;\r\n }\r\n\r\n let desiredWidth = (<PostProcessOptions>this._options).width || requiredWidth;\r\n let desiredHeight = (<PostProcessOptions>this._options).height || requiredHeight;\r\n\r\n const needMipMaps =\r\n this.renderTargetSamplingMode !== Constants.TEXTURE_NEAREST_LINEAR &&\r\n this.renderTargetSamplingMode !== Constants.TEXTURE_NEAREST_NEAREST &&\r\n this.renderTargetSamplingMode !== Constants.TEXTURE_LINEAR_LINEAR;\r\n\r\n if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {\r\n if (this.adaptScaleToCurrentViewport) {\r\n const currentViewport = engine.currentViewport;\r\n\r\n if (currentViewport) {\r\n desiredWidth *= currentViewport.width;\r\n desiredHeight *= currentViewport.height;\r\n }\r\n }\r\n\r\n if (needMipMaps || this.alwaysForcePOT) {\r\n if (!(<PostProcessOptions>this._options).width) {\r\n desiredWidth = engine.needPOTTextures ? Engine.GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;\r\n }\r\n\r\n if (!(<PostProcessOptions>this._options).height) {\r\n desiredHeight = engine.needPOTTextures ? Engine.GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;\r\n }\r\n }\r\n\r\n if (this.width !== desiredWidth || this.height !== desiredHeight) {\r\n this._resize(desiredWidth, desiredHeight, camera, needMipMaps, forceDepthStencil);\r\n }\r\n\r\n this._textures.forEach((texture) => {\r\n if (texture.samples !== this.samples) {\r\n this._engine.updateRenderTargetTextureSampleCount(texture, this.samples);\r\n }\r\n });\r\n\r\n this._flushTextureCache();\r\n this._renderId++;\r\n }\r\n\r\n let target: RenderTargetWrapper;\r\n\r\n if (this._shareOutputWithPostProcess) {\r\n target = this._shareOutputWithPostProcess.inputTexture;\r\n } else if (this._forcedOutputTexture) {\r\n target = this._forcedOutputTexture;\r\n\r\n this.width = this._forcedOutputTexture.width;\r\n this.height = this._forcedOutputTexture.height;\r\n } else {\r\n target = this.inputTexture;\r\n\r\n let cache;\r\n for (let i = 0; i < this._textureCache.length; i++) {\r\n if (this._textureCache[i].texture === target) {\r\n cache = this._textureCache[i];\r\n break;\r\n }\r\n }\r\n\r\n if (cache) {\r\n cache.lastUsedRenderId = this._renderId;\r\n }\r\n }\r\n\r\n // Bind the input of this post process to be used as the output of the previous post process.\r\n if (this.enablePixelPerfectMode) {\r\n this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);\r\n this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);\r\n } else {\r\n this._scaleRatio.copyFromFloats(1, 1);\r\n this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);\r\n }\r\n\r\n this._engine._debugInsertMarker?.(`post process ${this.name} input`);\r\n\r\n this.onActivateObservable.notifyObservers(camera);\r\n\r\n // Clear\r\n if (this.autoClear && (this.alphaMode === Constants.ALPHA_DISABLE || this.forceAutoClearInAlphaMode)) {\r\n this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);\r\n }\r\n\r\n if (this._reusable) {\r\n this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;\r\n }\r\n return target;\r\n }\r\n\r\n /**\r\n * If the post process is supported.\r\n */\r\n public get isSupported(): boolean {\r\n return this._drawWrapper.effect!.isSupported;\r\n }\r\n\r\n /**\r\n * The aspect ratio of the output texture.\r\n */\r\n public get aspectRatio(): number {\r\n if (this._shareOutputWithPostProcess) {\r\n return this._shareOutputWithPostProcess.aspectRatio;\r\n }\r\n\r\n if (this._forcedOutputTexture) {\r\n return this._forcedOutputTexture.width / this._forcedOutputTexture.height;\r\n }\r\n return this.width / this.height;\r\n }\r\n\r\n /**\r\n * Get a value indicating if the post-process is ready to be used\r\n * @returns true if the post-process is ready (shader is compiled)\r\n */\r\n public isReady(): boolean {\r\n return this._drawWrapper.effect?.isReady() ?? false;\r\n }\r\n\r\n /**\r\n * Binds all textures and uniforms to the shader, this will be run on every pass.\r\n * @returns the effect corresponding to this post process. Null if not compiled or not ready.\r\n */\r\n public apply(): Nullable<Effect> {\r\n // Check\r\n if (!this._drawWrapper.effect?.isReady()) {\r\n return null;\r\n }\r\n\r\n // States\r\n this._engine.enableEffect(this._drawWrapper);\r\n this._engine.setState(false);\r\n this._engine.setDepthBuffer(false);\r\n this._engine.setDepthWrite(false);\r\n\r\n // Alpha\r\n this._engine.setAlphaMode(this.alphaMode);\r\n if (this.alphaConstants) {\r\n this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);\r\n }\r\n\r\n // Bind the output texture of the preivous post process as the input to this post process.\r\n let source: RenderTargetWrapper;\r\n if (this._shareOutputWithPostProcess) {\r\n source = this._shareOutputWithPostProcess.inputTexture;\r\n } else if (this._forcedOutputTexture) {\r\n source = this._forcedOutputTexture;\r\n } else {\r\n source = this.inputTexture;\r\n }\r\n\r\n if (!this.externalTextureSamplerBinding) {\r\n this._drawWrapper.effect._bindTexture(\"textureSampler\", source?.texture);\r\n }\r\n\r\n // Parameters\r\n this._drawWrapper.effect.setVector2(\"scale\", this._scaleRatio);\r\n this.onApplyObservable.notifyObservers(this._drawWrapper.effect);\r\n\r\n PostProcess._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name, this._drawWrapper.effect);\r\n\r\n return this._drawWrapper.effect;\r\n }\r\n\r\n private _disposeTextures() {\r\n if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {\r\n this._disposeTextureCache();\r\n return;\r\n }\r\n\r\n this._disposeTextureCache();\r\n this._textures.dispose();\r\n }\r\n\r\n private _disposeTextureCache() {\r\n for (let i = this._textureCache.length - 1; i >= 0; i--) {\r\n this._textureCache[i].texture.dispose();\r\n }\r\n\r\n this._textureCache.length = 0;\r\n }\r\n\r\n /**\r\n * Sets the required values to the prepass renderer.\r\n * @param prePassRenderer defines the prepass renderer to setup.\r\n * @returns true if the pre pass is needed.\r\n */\r\n public setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean {\r\n if (this._prePassEffectConfiguration) {\r\n this._prePassEffectConfiguration = prePassRenderer.addEffectConfiguration(this._prePassEffectConfiguration);\r\n this._prePassEffectConfiguration.enabled = true;\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Disposes the post process.\r\n * @param camera The camera to dispose the post process on.\r\n */\r\n public dispose(camera?: Camera): void {\r\n camera = camera || this._camera;\r\n\r\n this._disposeTextures();\r\n\r\n let index;\r\n if (this._scene) {\r\n index = this._scene.postProcesses.indexOf(this);\r\n if (index !== -1) {\r\n this._scene.postProcesses.splice(index, 1);\r\n }\r\n }\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.postProcesses.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.postProcesses.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n index = this._engine.postProcesses.indexOf(this);\r\n if (index !== -1) {\r\n this._engine.postProcesses.splice(index, 1);\r\n }\r\n\r\n if (!camera) {\r\n return;\r\n }\r\n camera.detachPostProcess(this);\r\n\r\n index = camera._postProcesses.indexOf(this);\r\n if (index === 0 && camera._postProcesses.length > 0) {\r\n const firstPostProcess = this._camera._getFirstPostProcess();\r\n if (firstPostProcess) {\r\n firstPostProcess.markTextureDirty();\r\n }\r\n }\r\n\r\n this.onActivateObservable.clear();\r\n this.onAfterRenderObservable.clear();\r\n this.onApplyObservable.clear();\r\n this.onBeforeRenderObservable.clear();\r\n this.onSizeChangedObservable.clear();\r\n }\r\n\r\n /**\r\n * Serializes the post process to a JSON object\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n const camera = this.getCamera() || (this._scene && this._scene.activeCamera);\r\n serializationObject.customType = \"BABYLON.\" + this.getClassName();\r\n serializationObject.cameraId = camera ? camera.id : null;\r\n serializationObject.reusable = this._reusable;\r\n serializationObject.textureType = this._textureType;\r\n serializationObject.fragmentUrl = this._fragmentUrl;\r\n serializationObject.parameters = this._parameters;\r\n serializationObject.samplers = this._samplers;\r\n serializationObject.options = this._options;\r\n serializationObject.defines = this._postProcessDefines;\r\n serializationObject.textureFormat = this._textureFormat;\r\n serializationObject.vertexUrl = this._vertexUrl;\r\n serializationObject.indexParameters = this._indexParameters;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Clones this post process\r\n * @returns a new post process similar to this one\r\n */\r\n public clone(): Nullable<PostProcess> {\r\n const serializationObject = this.serialize();\r\n serializationObject._engine = this._engine;\r\n serializationObject.cameraId = null;\r\n\r\n const result = PostProcess.Parse(serializationObject, this._scene, \"\");\r\n\r\n if (!result) {\r\n return null;\r\n }\r\n\r\n result.onActivateObservable = this.onActivateObservable.clone();\r\n result.onSizeChangedObservable = this.onSizeChangedObservable.clone();\r\n result.onApplyObservable = this.onApplyObservable.clone();\r\n result.onBeforeRenderObservable = this.onBeforeRenderObservable.clone();\r\n result.onAfterRenderObservable = this.onAfterRenderObservable.clone();\r\n\r\n result._prePassEffectConfiguration = this._prePassEffectConfiguration;\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a material from parsed material data\r\n * @param parsedPostProcess defines parsed post process data\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures\r\n * @returns a new post process\r\n */\r\n public static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess> {\r\n const postProcessType = GetClass(parsedPostProcess.customType);\r\n\r\n if (!postProcessType || !postProcessType._Parse) {\r\n return null;\r\n }\r\n\r\n const camera = scene ? scene.getCameraById(parsedPostProcess.cameraId) : null;\r\n return postProcessType._Parse(parsedPostProcess, camera, scene, rootUrl);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new PostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.fragmentUrl,\r\n parsedPostProcess.parameters,\r\n parsedPostProcess.samplers,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess._engine,\r\n parsedPostProcess.reusable,\r\n parsedPostProcess.defines,\r\n parsedPostProcess.textureType,\r\n parsedPostProcess.vertexUrl,\r\n parsedPostProcess.indexParameters,\r\n false,\r\n parsedPostProcess.textureFormat\r\n );\r\n },\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.PostProcess\", PostProcess);\r\n"]}
|
|
@@ -8,7 +8,7 @@ import { Camera } from "../Cameras/camera.js";
|
|
|
8
8
|
import "../Shaders/depth.fragment.js";
|
|
9
9
|
import "../Shaders/depth.vertex.js";
|
|
10
10
|
import { _WarnImport } from "../Misc/devTools.js";
|
|
11
|
-
import { addClipPlaneUniforms, bindClipPlane,
|
|
11
|
+
import { addClipPlaneUniforms, bindClipPlane, prepareStringDefinesForClipPlanes } from "../Materials/clipPlaneMaterialHelper.js";
|
|
12
12
|
/**
|
|
13
13
|
* This represents a depth renderer in Babylon.
|
|
14
14
|
* A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
|
|
@@ -321,7 +321,7 @@ export class DepthRenderer {
|
|
|
321
321
|
defines.push("#define PACKED");
|
|
322
322
|
}
|
|
323
323
|
// Clip planes
|
|
324
|
-
|
|
324
|
+
prepareStringDefinesForClipPlanes(material, scene, defines);
|
|
325
325
|
// Get correct effect
|
|
326
326
|
const drawWrapper = subMesh._getDrawWrapper(undefined, true);
|
|
327
327
|
const cachedDefines = drawWrapper.defines;
|