@babylonjs/core 8.14.1 → 8.15.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/Culling/ray.core.js +2 -2
- package/Culling/ray.core.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Maths/math.vector.d.ts +0 -4
- package/Maths/math.vector.js +1 -13
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/transformNode.d.ts +1 -0
- package/Meshes/transformNode.js +10 -2
- package/Meshes/transformNode.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +0 -1
- package/Physics/v2/physicsBody.js +1 -2
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Sprites/spriteManager.d.ts +6 -1
- package/Sprites/spriteManager.js +2 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteSceneComponent.d.ts +14 -0
- package/Sprites/spriteSceneComponent.js +23 -0
- package/Sprites/spriteSceneComponent.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAc1E;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA8BpB;;;OAGG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,YAAY,IAAI,kBAAkB,CAAC,QAAQ,CAAC;IAC5D,CAAC;IAED,IAAW,cAAc,CAAC,KAAc;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC;IAC1F,CAAC;IAqBD;;;;;;;;;;;;;OAaG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;QACX,CAAC;QACD,qEAAqE;QACrE,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC3B,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChC,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACrC,CAAC;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,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { IBasePhysicsCollisionEvent, IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsMotionType, PhysicsPrestepType } 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 { 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\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { BoundingBox } from \"core/Culling/boundingBox\";\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 * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n\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 public get disablePreStep(): boolean {\r\n return this._prestepType == PhysicsPrestepType.DISABLED;\r\n }\r\n\r\n public set disablePreStep(value: boolean) {\r\n this._prestepType = value ? PhysicsPrestepType.DISABLED : PhysicsPrestepType.TELEPORT;\r\n }\r\n\r\n /**\r\n * Disable sync from physics to transformNode. This value is set to true at body creation or at motionType setting when the body is not dynamic.\r\n */\r\n disableSync: boolean = false;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _motionType: PhysicsMotionType;\r\n\r\n private _prestepType: PhysicsPrestepType = PhysicsPrestepType.DISABLED;\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. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\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, startsAsleep: boolean, 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;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n this._motionType = motionType;\r\n\r\n // only dynamic and animated body needs sync from physics to transformNode\r\n this.disableSync = motionType == PhysicsMotionType.STATIC;\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 if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\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 * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\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.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\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 * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get 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._motionType;\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: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\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(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics body.\r\n * @returns The bounding box of the physics body.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBodyBoundingBox(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 * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\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 setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\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 getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this.disableSync = motionType == PhysicsMotionType.STATIC;\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the prestep type of the body\r\n * @param prestepType prestep type provided by PhysicsPrestepType\r\n */\r\n public setPrestepType(prestepType: PhysicsPrestepType): void {\r\n this._prestepType = prestepType;\r\n }\r\n\r\n /**\r\n * Get the current prestep type of the body\r\n * @returns the type of prestep associated with the body and its instance index\r\n */\r\n public getPrestepType(): PhysicsPrestepType {\r\n return this._prestepType;\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 * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\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 * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\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 setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\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 getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\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 setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\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 getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\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 setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\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 getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\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 */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\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 */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\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 * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\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 getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\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 * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Add torque to a physics body\r\n * @param angularImpulse The angular impulse vector.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n */\r\n public applyAngularImpulse(angularImpulse: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyAngularImpulse(this, angularImpulse, instanceIndex);\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 * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\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(): object {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\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 * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @returns\r\n */\r\n public getCollisionEndedObservable(): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(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 this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\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 * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\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 * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\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._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\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.transformNode.physicsBody = null;\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAc1E;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA8BpB;;;OAGG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,YAAY,IAAI,kBAAkB,CAAC,QAAQ,CAAC;IAC5D,CAAC;IAED,IAAW,cAAc,CAAC,KAAc;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC;IAC1F,CAAC;IAmBD;;;;;;;;;;;;;OAaG;IACH,YAAY,aAA4B,EAAE,UAA6B,EAAE,YAAqB,EAAE,KAAY;QAxE5G;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAS7C;;WAEG;QACK,wBAAmB,GAAY,KAAK,CAAC;QAC7C;;WAEG;QACK,6BAAwB,GAAY,KAAK,CAAC;QAkBlD;;WAEG;QACH,gBAAW,GAAY,KAAK,CAAC;QASrB,gBAAW,GAAG,KAAK,CAAC;QAEpB,WAAM,GAA2B,IAAI,CAAC;QAEt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CAAC;YACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACrC,CAAC;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,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { IBasePhysicsCollisionEvent, IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsMotionType, PhysicsPrestepType } 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 { 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\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { BoundingBox } from \"core/Culling/boundingBox\";\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 * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n\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 public get disablePreStep(): boolean {\r\n return this._prestepType == PhysicsPrestepType.DISABLED;\r\n }\r\n\r\n public set disablePreStep(value: boolean) {\r\n this._prestepType = value ? PhysicsPrestepType.DISABLED : PhysicsPrestepType.TELEPORT;\r\n }\r\n\r\n /**\r\n * Disable sync from physics to transformNode. This value is set to true at body creation or at motionType setting when the body is not dynamic.\r\n */\r\n disableSync: boolean = false;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _prestepType: PhysicsPrestepType = PhysicsPrestepType.DISABLED;\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. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\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, startsAsleep: boolean, 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;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n // only dynamic and animated body needs sync from physics to transformNode\r\n this.disableSync = motionType == PhysicsMotionType.STATIC;\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 if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\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 * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\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.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\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 * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get 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 * 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: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\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(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics body.\r\n * @returns The bounding box of the physics body.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBodyBoundingBox(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 * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\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 setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\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 getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this.disableSync = motionType == PhysicsMotionType.STATIC;\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the prestep type of the body\r\n * @param prestepType prestep type provided by PhysicsPrestepType\r\n */\r\n public setPrestepType(prestepType: PhysicsPrestepType): void {\r\n this._prestepType = prestepType;\r\n }\r\n\r\n /**\r\n * Get the current prestep type of the body\r\n * @returns the type of prestep associated with the body and its instance index\r\n */\r\n public getPrestepType(): PhysicsPrestepType {\r\n return this._prestepType;\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 * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\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 * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\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 setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\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 getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\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 setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\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 getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\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 setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\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 getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\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 */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\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 */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\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 * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\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 * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\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 getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\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 * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Add torque to a physics body\r\n * @param angularImpulse The angular impulse vector.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n */\r\n public applyAngularImpulse(angularImpulse: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyAngularImpulse(this, angularImpulse, instanceIndex);\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 * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\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, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\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(): object {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\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 * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @returns\r\n */\r\n public getCollisionEndedObservable(): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(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 this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\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 * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\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 * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\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._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\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.transformNode.physicsBody = null;\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
|
|
@@ -2,6 +2,7 @@ import type { IDisposable, Scene } from "../scene.js";
|
|
|
2
2
|
import type { Nullable } from "../types.js";
|
|
3
3
|
import { Observable } from "../Misc/observable.js";
|
|
4
4
|
import { Sprite } from "./sprite.js";
|
|
5
|
+
import type { InternalSpriteAugmentedScene } from "./spriteSceneComponent.js";
|
|
5
6
|
import { PickingInfo } from "../Collisions/pickingInfo.js";
|
|
6
7
|
import type { Camera } from "../Cameras/camera.js";
|
|
7
8
|
import { Texture } from "../Materials/Textures/texture.js";
|
|
@@ -11,6 +12,10 @@ import type { Ray } from "../Culling/ray.js";
|
|
|
11
12
|
* Defines the minimum interface to fulfill in order to be a sprite manager.
|
|
12
13
|
*/
|
|
13
14
|
export interface ISpriteManager extends IDisposable {
|
|
15
|
+
/**
|
|
16
|
+
* Gets or sets the unique id of the texture
|
|
17
|
+
*/
|
|
18
|
+
uniqueId: number;
|
|
14
19
|
/**
|
|
15
20
|
* Gets manager's name
|
|
16
21
|
*/
|
|
@@ -128,7 +133,7 @@ export declare class SpriteManager implements ISpriteManager {
|
|
|
128
133
|
/**
|
|
129
134
|
* Gets the hosting scene
|
|
130
135
|
*/
|
|
131
|
-
get scene():
|
|
136
|
+
get scene(): InternalSpriteAugmentedScene;
|
|
132
137
|
/**
|
|
133
138
|
* Gets the capacity of the manager
|
|
134
139
|
*/
|
package/Sprites/spriteManager.js
CHANGED
|
@@ -200,6 +200,7 @@ export class SpriteManager {
|
|
|
200
200
|
if (this._fromPacked) {
|
|
201
201
|
this._makePacked(imgUrl, spriteJSON);
|
|
202
202
|
}
|
|
203
|
+
this._scene._onNewSpriteManagerAddedObservable?.notifyObservers(this);
|
|
203
204
|
}
|
|
204
205
|
/**
|
|
205
206
|
* Returns the string "SpriteManager"
|
|
@@ -466,6 +467,7 @@ export class SpriteManager {
|
|
|
466
467
|
if (this._scene.spriteManagers) {
|
|
467
468
|
const index = this._scene.spriteManagers.indexOf(this);
|
|
468
469
|
this._scene.spriteManagers.splice(index, 1);
|
|
470
|
+
this._scene._onSpriteManagerRemovedObservable?.notifyObservers(this);
|
|
469
471
|
}
|
|
470
472
|
// Callback
|
|
471
473
|
this.onDisposeObservable.notifyObservers(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spriteManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Sprites/spriteManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAoGjD;;;GAGG;AACH,MAAM,OAAO,aAAa;IA6BtB;;OAEG;IACH,IAAW,SAAS,CAAC,QAAoB;QACrC,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrE,CAAC;IAOD;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;I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,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;wBAC9D,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,IAAI,WAAW,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;wBAExG,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;wBAE7B,OAAO,CAAC,MAAM,CAAC,CAAC;oBACpB,CAAC;yBAAM,CAAC;wBACJ,2EAA2E;wBAC3E,MAAM,CAAC,6BAA6B,GAAG,SAAS,CAAC,CAAC;oBACtD,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;;AA1sBD,sCAAsC;AACxB,wBAAU,GAAG,SAAS,CAAC,UAAU,AAAvB,CAAwB;AA2sBhD;;;;;;;GAOG;AACW,oCAAsB,GAAG,aAAa,CAAC,qBAAqB,AAAtC,CAAuC","sourcesContent":["import type { IDisposable, Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../Maths/math.vector\";\r\nimport { Sprite } from \"./sprite\";\r\nimport { SpriteSceneComponent } from \"./spriteSceneComponent\";\r\nimport { PickingInfo } from \"../Collisions/pickingInfo\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport { WebRequest } from \"../Misc/webRequest\";\r\nimport type { SpriteRendererOptions } from \"./spriteRenderer\";\r\nimport { SpriteRenderer } from \"./spriteRenderer\";\r\nimport type { ThinSprite } from \"./thinSprite\";\r\nimport type { ISize } from \"../Maths/math.size\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport type { Ray } from \"../Culling/ray\";\r\n\r\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect\r\ndeclare const Reflect: any;\r\n\r\n/**\r\n * Defines the minimum interface to fulfill in order to be a sprite manager.\r\n */\r\nexport interface ISpriteManager extends IDisposable {\r\n /**\r\n * Gets manager's name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Restricts the camera to viewing objects with the same layerMask.\r\n * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0\r\n */\r\n layerMask: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true\r\n */\r\n isPickable: boolean;\r\n\r\n /**\r\n * Gets the hosting scene\r\n */\r\n scene: Scene;\r\n\r\n /**\r\n * Specifies the rendering group id for this mesh (0 by default)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/transparent_rendering#rendering-groups\r\n */\r\n renderingGroupId: number;\r\n\r\n /**\r\n * Defines the list of sprites managed by the manager.\r\n */\r\n sprites: Array<Sprite>;\r\n\r\n /**\r\n * Gets or sets the spritesheet texture\r\n */\r\n texture: Texture;\r\n\r\n /** Defines the default width of a cell in the spritesheet */\r\n cellWidth: number;\r\n /** Defines the default height of a cell in the spritesheet */\r\n cellHeight: number;\r\n\r\n /** @internal */\r\n _wasDispatched: boolean;\r\n\r\n /**\r\n * Tests the intersection of a sprite with a specific ray.\r\n * @param ray The ray we are sending to test the collision\r\n * @param camera The camera space we are sending rays in\r\n * @param predicate A predicate allowing excluding sprites from the list of object to test\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @returns picking info or null.\r\n */\r\n intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;\r\n\r\n /**\r\n * Intersects the sprites with a ray\r\n * @param ray defines the ray to intersect with\r\n * @param camera defines the current active camera\r\n * @param predicate defines a predicate used to select candidate sprites\r\n * @returns null if no hit or a PickingInfo array\r\n */\r\n multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;\r\n\r\n /**\r\n * Renders the list of sprites on screen.\r\n */\r\n render(): void;\r\n\r\n /**\r\n * Rebuilds the manager (after a context lost, for eg)\r\n */\r\n rebuild(): void;\r\n\r\n /**\r\n * Serializes the sprite manager to a JSON object\r\n */\r\n serialize(serializeTexture?: boolean): any;\r\n}\r\n\r\n/**\r\n * Options for the SpriteManager\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface SpriteManagerOptions {\r\n /** Options for the sprite renderer */\r\n spriteRendererOptions: SpriteRendererOptions;\r\n}\r\n\r\n/**\r\n * Class used to manage multiple sprites on the same spritesheet\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/sprites\r\n */\r\nexport class SpriteManager implements ISpriteManager {\r\n /** Define the Url to load snippets */\r\n public static SnippetUrl = Constants.SnippetUrl;\r\n\r\n /** Snippet ID if the manager was created from the snippet server */\r\n public snippetId: string;\r\n\r\n /** Gets the list of sprites */\r\n public sprites: Sprite[] = [];\r\n /** Gets or sets the rendering group id (0 by default) */\r\n public renderingGroupId = 0;\r\n /** Gets or sets camera layer mask */\r\n public layerMask: number = 0x0fffffff;\r\n /** Gets or sets a boolean indicating if the sprites are pickable */\r\n public isPickable = false;\r\n\r\n /**\r\n * Gets or sets an object used to store user defined information for the sprite manager\r\n */\r\n public metadata: any = null;\r\n\r\n /** @internal */\r\n public _wasDispatched = false;\r\n\r\n /**\r\n * An event triggered when the manager is disposed.\r\n */\r\n public onDisposeObservable = new Observable<SpriteManager>();\r\n\r\n /**\r\n * Callback called when the manager is disposed\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Gets or sets the unique id of the sprite\r\n */\r\n public uniqueId: number;\r\n\r\n /**\r\n * Gets the array of sprites\r\n */\r\n public get children() {\r\n return this.sprites;\r\n }\r\n\r\n /**\r\n * Gets the hosting scene\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the capacity of the manager\r\n */\r\n public get capacity() {\r\n return this._spriteRenderer.capacity;\r\n }\r\n\r\n /**\r\n * Gets or sets the spritesheet texture\r\n */\r\n public get texture(): Texture {\r\n return this._spriteRenderer.texture as Texture;\r\n }\r\n public set texture(value: Texture) {\r\n value.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n value.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n this._spriteRenderer.texture = value;\r\n this._textureContent = null;\r\n }\r\n\r\n /** Defines the default width of a cell in the spritesheet */\r\n public get cellWidth(): number {\r\n return this._spriteRenderer.cellWidth;\r\n }\r\n public set cellWidth(value: number) {\r\n this._spriteRenderer.cellWidth = value;\r\n }\r\n\r\n /** Defines the default height of a cell in the spritesheet */\r\n public get cellHeight(): number {\r\n return this._spriteRenderer.cellHeight;\r\n }\r\n public set cellHeight(value: number) {\r\n this._spriteRenderer.cellHeight = value;\r\n }\r\n\r\n /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */\r\n public get fogEnabled(): boolean {\r\n return this._spriteRenderer.fogEnabled;\r\n }\r\n public set fogEnabled(value: boolean) {\r\n this._spriteRenderer.fogEnabled = value;\r\n }\r\n\r\n /** Gets or sets a boolean indicating if the manager must use logarithmic depth when rendering */\r\n public get useLogarithmicDepth(): boolean {\r\n return this._spriteRenderer.useLogarithmicDepth;\r\n }\r\n public set useLogarithmicDepth(value: boolean) {\r\n this._spriteRenderer.useLogarithmicDepth = value;\r\n }\r\n\r\n /**\r\n * Blend mode use to render the particle, it can be any of\r\n * the static Constants.ALPHA_x properties provided in this class.\r\n * Default value is Constants.ALPHA_COMBINE\r\n */\r\n public get blendMode() {\r\n return this._spriteRenderer.blendMode;\r\n }\r\n public set blendMode(blendMode: number) {\r\n this._spriteRenderer.blendMode = blendMode;\r\n }\r\n\r\n private _disableDepthWrite: boolean = false;\r\n /** Disables writing to the depth buffer when rendering the sprites.\r\n * It can be handy to disable depth writing when using textures without alpha channel\r\n * and setting some specific blend modes.\r\n */\r\n public get disableDepthWrite() {\r\n return this._disableDepthWrite;\r\n }\r\n\r\n public set disableDepthWrite(value: boolean) {\r\n this._disableDepthWrite = value;\r\n this._spriteRenderer.disableDepthWrite = value;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the renderer must render sprites with pixel perfect rendering\r\n * In this mode, sprites are rendered as \"pixel art\", which means that they appear as pixelated but remain stable when moving or when rotated or scaled.\r\n * Note that for this mode to work as expected, the sprite texture must use the BILINEAR sampling mode, not NEAREST!\r\n */\r\n public get pixelPerfect() {\r\n return this._spriteRenderer.pixelPerfect;\r\n }\r\n\r\n public set pixelPerfect(value: boolean) {\r\n this._spriteRenderer.pixelPerfect = value;\r\n if (value && this.texture.samplingMode !== Constants.TEXTURE_TRILINEAR_SAMPLINGMODE) {\r\n this.texture.updateSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE);\r\n }\r\n }\r\n\r\n private _spriteRenderer: SpriteRenderer;\r\n /** Associative array from JSON sprite data file */\r\n private _cellData: any;\r\n /** Array of sprite names from JSON sprite data file */\r\n private _spriteMap: Array<string>;\r\n /** True when packed cell data from JSON file is ready*/\r\n private _packedAndReady: boolean = false;\r\n private _textureContent: Nullable<Uint8Array>;\r\n private _onDisposeObserver: Nullable<Observer<SpriteManager>>;\r\n private _fromPacked: boolean;\r\n private _scene: Scene;\r\n\r\n /**\r\n * Creates a new sprite manager\r\n * @param name defines the manager's name\r\n * @param imgUrl defines the sprite sheet url\r\n * @param capacity defines the maximum allowed number of sprites\r\n * @param cellSize defines the size of a sprite cell\r\n * @param scene defines the hosting scene\r\n * @param epsilon defines the epsilon value to align texture (0.01 by default)\r\n * @param samplingMode defines the sampling mode to use with spritesheet\r\n * @param fromPacked set to false; do not alter\r\n * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter\r\n * @param options options used to create the SpriteManager instance\r\n */\r\n constructor(\r\n /** defines the manager's name */\r\n public name: string,\r\n imgUrl: string,\r\n capacity: number,\r\n cellSize: any,\r\n scene: Scene,\r\n epsilon: number = 0.01,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n fromPacked: boolean = false,\r\n spriteJSON: null | string = null,\r\n options?: SpriteManagerOptions\r\n ) {\r\n if (!scene) {\r\n scene = EngineStore.LastCreatedScene!;\r\n }\r\n\r\n if (!scene._getComponent(SceneComponentConstants.NAME_SPRITE)) {\r\n scene._addComponent(new SpriteSceneComponent(scene));\r\n }\r\n this._fromPacked = fromPacked;\r\n\r\n this._scene = scene;\r\n const engine = this._scene.getEngine();\r\n this._spriteRenderer = new SpriteRenderer(engine, capacity, epsilon, scene, options?.spriteRendererOptions);\r\n\r\n if (cellSize.width && cellSize.height) {\r\n this.cellWidth = cellSize.width;\r\n this.cellHeight = cellSize.height;\r\n } else if (cellSize !== undefined) {\r\n this.cellWidth = cellSize;\r\n this.cellHeight = cellSize;\r\n } else {\r\n this._spriteRenderer = <any>null;\r\n return;\r\n }\r\n\r\n this._scene.spriteManagers && this._scene.spriteManagers.push(this);\r\n this.uniqueId = this.scene.getUniqueId();\r\n\r\n if (imgUrl) {\r\n this.texture = new Texture(imgUrl, scene, true, false, samplingMode);\r\n }\r\n\r\n if (this._fromPacked) {\r\n this._makePacked(imgUrl, spriteJSON);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the string \"SpriteManager\"\r\n * @returns \"SpriteManager\"\r\n */\r\n public getClassName(): string {\r\n return \"SpriteManager\";\r\n }\r\n\r\n private _makePacked(imgUrl: string, spriteJSON: any) {\r\n if (spriteJSON !== null) {\r\n try {\r\n //Get the JSON and Check its structure. If its an array parse it if its a JSON string etc...\r\n let celldata: any;\r\n if (typeof spriteJSON === \"string\") {\r\n celldata = JSON.parse(spriteJSON);\r\n } else {\r\n celldata = spriteJSON;\r\n }\r\n\r\n if (celldata.frames.length) {\r\n const frametemp: any = {};\r\n for (let i = 0; i < celldata.frames.length; i++) {\r\n const _f = celldata.frames[i];\r\n if (typeof Object.keys(_f)[0] !== \"string\") {\r\n throw new Error(\"Invalid JSON Format. Check the frame values and make sure the name is the first parameter.\");\r\n }\r\n\r\n const name: string = _f[Object.keys(_f)[0]];\r\n frametemp[name] = _f;\r\n }\r\n celldata.frames = frametemp;\r\n }\r\n\r\n const spritemap = <string[]>Reflect.ownKeys(celldata.frames);\r\n\r\n this._spriteMap = spritemap;\r\n this._packedAndReady = true;\r\n this._cellData = celldata.frames;\r\n } catch (e) {\r\n this._fromPacked = false;\r\n this._packedAndReady = false;\r\n throw new Error(\"Invalid JSON from string. Spritesheet managed with constant cell size.\");\r\n }\r\n } else {\r\n const re = /\\./g;\r\n let li: number;\r\n do {\r\n li = re.lastIndex;\r\n re.test(imgUrl);\r\n } while (re.lastIndex > 0);\r\n const jsonUrl = imgUrl.substring(0, li - 1) + \".json\";\r\n const onerror = () => {\r\n Logger.Error(\"JSON ERROR: Unable to load JSON file.\");\r\n this._fromPacked = false;\r\n this._packedAndReady = false;\r\n };\r\n const onload = (data: string | ArrayBuffer) => {\r\n try {\r\n const celldata = JSON.parse(data as string);\r\n const spritemap = <string[]>Reflect.ownKeys(celldata.frames);\r\n this._spriteMap = spritemap;\r\n this._packedAndReady = true;\r\n this._cellData = celldata.frames;\r\n } catch (e) {\r\n this._fromPacked = false;\r\n this._packedAndReady = false;\r\n throw new Error(\"Invalid JSON format. Please check documentation for format specifications.\");\r\n }\r\n };\r\n Tools.LoadFile(jsonUrl, onload, undefined, undefined, false, onerror);\r\n }\r\n }\r\n\r\n private _checkTextureAlpha(sprite: Sprite, ray: Ray, distance: number, min: Vector3, max: Vector3) {\r\n if (!sprite.useAlphaForPicking || !this.texture?.isReady()) {\r\n return true;\r\n }\r\n\r\n const textureSize = this.texture.getSize();\r\n if (!this._textureContent) {\r\n this._textureContent = new Uint8Array(textureSize.width * textureSize.height * 4);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.texture.readPixels(0, 0, this._textureContent);\r\n }\r\n\r\n const contactPoint = TmpVectors.Vector3[0];\r\n\r\n contactPoint.copyFrom(ray.direction);\r\n\r\n contactPoint.normalize();\r\n contactPoint.scaleInPlace(distance);\r\n contactPoint.addInPlace(ray.origin);\r\n\r\n const contactPointU = (contactPoint.x - min.x) / (max.x - min.x);\r\n const contactPointV = 1.0 - (contactPoint.y - min.y) / (max.y - min.y);\r\n\r\n const u = (sprite._xOffset * textureSize.width + contactPointU * sprite._xSize) | 0;\r\n const v = (sprite._yOffset * textureSize.height + contactPointV * sprite._ySize) | 0;\r\n\r\n const alpha = this._textureContent[(u + v * textureSize.width) * 4 + 3];\r\n\r\n return alpha > 0.5;\r\n }\r\n\r\n /**\r\n * Intersects the sprites with a ray\r\n * @param ray defines the ray to intersect with\r\n * @param camera defines the current active camera\r\n * @param predicate defines a predicate used to select candidate sprites\r\n * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)\r\n * @returns null if no hit or a PickingInfo\r\n */\r\n public intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo> {\r\n const count = Math.min(this.capacity, this.sprites.length);\r\n const min = Vector3.Zero();\r\n const max = Vector3.Zero();\r\n let distance = Number.MAX_VALUE;\r\n let currentSprite: Nullable<Sprite> = null;\r\n const pickedPoint = TmpVectors.Vector3[0];\r\n const cameraSpacePosition = TmpVectors.Vector3[1];\r\n const cameraView = camera.getViewMatrix();\r\n let activeRay: Ray = ray;\r\n let pickedRay: Ray = ray;\r\n\r\n for (let index = 0; index < count; index++) {\r\n const sprite = this.sprites[index];\r\n if (!sprite) {\r\n continue;\r\n }\r\n\r\n if (predicate) {\r\n if (!predicate(sprite)) {\r\n continue;\r\n }\r\n } else if (!sprite.isPickable) {\r\n continue;\r\n }\r\n\r\n Vector3.TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);\r\n\r\n if (sprite.angle) {\r\n // Create a rotation matrix to rotate the ray to the sprite's rotation\r\n Matrix.TranslationToRef(-cameraSpacePosition.x, -cameraSpacePosition.y, 0, TmpVectors.Matrix[1]);\r\n Matrix.TranslationToRef(cameraSpacePosition.x, cameraSpacePosition.y, 0, TmpVectors.Matrix[2]);\r\n Matrix.RotationZToRef(-sprite.angle, TmpVectors.Matrix[3]);\r\n\r\n // inv translation x rotation x translation\r\n TmpVectors.Matrix[1].multiplyToRef(TmpVectors.Matrix[3], TmpVectors.Matrix[4]);\r\n TmpVectors.Matrix[4].multiplyToRef(TmpVectors.Matrix[2], TmpVectors.Matrix[0]);\r\n\r\n activeRay = ray.clone();\r\n Vector3.TransformCoordinatesToRef(ray.origin, TmpVectors.Matrix[0], activeRay.origin);\r\n Vector3.TransformNormalToRef(ray.direction, TmpVectors.Matrix[0], activeRay.direction);\r\n } else {\r\n activeRay = ray;\r\n }\r\n\r\n min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);\r\n max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);\r\n\r\n if (activeRay.intersectsBoxMinMax(min, max)) {\r\n const currentDistance = Vector3.Distance(cameraSpacePosition, activeRay.origin);\r\n\r\n if (distance > currentDistance) {\r\n if (!this._checkTextureAlpha(sprite, activeRay, currentDistance, min, max)) {\r\n continue;\r\n }\r\n\r\n pickedRay = activeRay;\r\n distance = currentDistance;\r\n currentSprite = sprite;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (currentSprite) {\r\n const result = new PickingInfo();\r\n\r\n cameraView.invertToRef(TmpVectors.Matrix[0]);\r\n result.hit = true;\r\n result.pickedSprite = currentSprite;\r\n result.distance = distance;\r\n\r\n // Get picked point\r\n const direction = TmpVectors.Vector3[2];\r\n direction.copyFrom(pickedRay.direction);\r\n direction.normalize();\r\n direction.scaleInPlace(distance);\r\n\r\n pickedRay.origin.addToRef(direction, pickedPoint);\r\n result.pickedPoint = Vector3.TransformCoordinates(pickedPoint, TmpVectors.Matrix[0]);\r\n\r\n return result;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Intersects the sprites with a ray\r\n * @param ray defines the ray to intersect with\r\n * @param camera defines the current active camera\r\n * @param predicate defines a predicate used to select candidate sprites\r\n * @returns null if no hit or a PickingInfo array\r\n */\r\n public multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]> {\r\n const count = Math.min(this.capacity, this.sprites.length);\r\n const min = Vector3.Zero();\r\n const max = Vector3.Zero();\r\n let distance: number;\r\n const results: Nullable<PickingInfo[]> = [];\r\n const pickedPoint = TmpVectors.Vector3[0].copyFromFloats(0, 0, 0);\r\n const cameraSpacePosition = TmpVectors.Vector3[1].copyFromFloats(0, 0, 0);\r\n const cameraView = camera.getViewMatrix();\r\n\r\n for (let index = 0; index < count; index++) {\r\n const sprite = this.sprites[index];\r\n if (!sprite) {\r\n continue;\r\n }\r\n\r\n if (predicate) {\r\n if (!predicate(sprite)) {\r\n continue;\r\n }\r\n } else if (!sprite.isPickable) {\r\n continue;\r\n }\r\n\r\n Vector3.TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);\r\n\r\n min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);\r\n max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);\r\n\r\n if (ray.intersectsBoxMinMax(min, max)) {\r\n distance = Vector3.Distance(cameraSpacePosition, ray.origin);\r\n\r\n if (!this._checkTextureAlpha(sprite, ray, distance, min, max)) {\r\n continue;\r\n }\r\n\r\n const result = new PickingInfo();\r\n results.push(result);\r\n\r\n cameraView.invertToRef(TmpVectors.Matrix[0]);\r\n result.hit = true;\r\n result.pickedSprite = sprite;\r\n result.distance = distance;\r\n\r\n // Get picked point\r\n const direction = TmpVectors.Vector3[2];\r\n direction.copyFrom(ray.direction);\r\n direction.normalize();\r\n direction.scaleInPlace(distance);\r\n\r\n ray.origin.addToRef(direction, pickedPoint);\r\n result.pickedPoint = Vector3.TransformCoordinates(pickedPoint, TmpVectors.Matrix[0]);\r\n }\r\n }\r\n\r\n return results;\r\n }\r\n\r\n /**\r\n * Render all child sprites\r\n */\r\n public render(): void {\r\n // Check\r\n if (this._fromPacked && (!this._packedAndReady || !this._spriteMap || !this._cellData)) {\r\n return;\r\n }\r\n\r\n const engine = this._scene.getEngine();\r\n const deltaTime = engine.getDeltaTime();\r\n if (this._packedAndReady) {\r\n this._spriteRenderer.render(this.sprites, deltaTime, this._scene.getViewMatrix(), this._scene.getProjectionMatrix(), this._customUpdate);\r\n } else {\r\n this._spriteRenderer.render(this.sprites, deltaTime, this._scene.getViewMatrix(), this._scene.getProjectionMatrix());\r\n }\r\n }\r\n\r\n private _customUpdate = (sprite: ThinSprite, baseSize: ISize): void => {\r\n if (!sprite.cellRef) {\r\n sprite.cellIndex = 0;\r\n }\r\n const num = sprite.cellIndex;\r\n if (typeof num === \"number\" && isFinite(num) && Math.floor(num) === num) {\r\n sprite.cellRef = this._spriteMap[sprite.cellIndex];\r\n }\r\n sprite._xOffset = this._cellData[sprite.cellRef].frame.x / baseSize.width;\r\n sprite._yOffset = this._cellData[sprite.cellRef].frame.y / baseSize.height;\r\n sprite._xSize = this._cellData[sprite.cellRef].frame.w;\r\n sprite._ySize = this._cellData[sprite.cellRef].frame.h;\r\n };\r\n\r\n /**\r\n * Rebuilds the manager (after a context lost, for eg)\r\n */\r\n public rebuild(): void {\r\n this._spriteRenderer?.rebuild();\r\n }\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._spriteRenderer) {\r\n this._spriteRenderer.dispose();\r\n (<any>this._spriteRenderer) = null;\r\n }\r\n\r\n this._textureContent = null;\r\n\r\n // Remove from scene\r\n if (this._scene.spriteManagers) {\r\n const index = this._scene.spriteManagers.indexOf(this);\r\n this._scene.spriteManagers.splice(index, 1);\r\n }\r\n\r\n // Callback\r\n this.onDisposeObservable.notifyObservers(this);\r\n this.onDisposeObservable.clear();\r\n\r\n this.metadata = null;\r\n }\r\n\r\n /**\r\n * Serializes the sprite manager to a JSON object\r\n * @param serializeTexture defines if the texture must be serialized as well\r\n * @returns the JSON object\r\n */\r\n public serialize(serializeTexture = false): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.name = this.name;\r\n serializationObject.capacity = this.capacity;\r\n serializationObject.cellWidth = this.cellWidth;\r\n serializationObject.cellHeight = this.cellHeight;\r\n serializationObject.fogEnabled = this.fogEnabled;\r\n serializationObject.blendMode = this.blendMode;\r\n serializationObject.disableDepthWrite = this.disableDepthWrite;\r\n serializationObject.pixelPerfect = this.pixelPerfect;\r\n serializationObject.useLogarithmicDepth = this.useLogarithmicDepth;\r\n\r\n if (this.texture) {\r\n if (serializeTexture) {\r\n serializationObject.texture = this.texture.serialize();\r\n } else {\r\n serializationObject.textureUrl = this.texture.name;\r\n serializationObject.invertY = this.texture._invertY;\r\n }\r\n }\r\n\r\n serializationObject.sprites = [];\r\n\r\n for (const sprite of this.sprites) {\r\n serializationObject.sprites.push(sprite.serialize());\r\n }\r\n\r\n serializationObject.metadata = this.metadata;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parses a JSON object to create a new sprite manager.\r\n * @param parsedManager The JSON object to parse\r\n * @param scene The scene to create the sprite manager\r\n * @param rootUrl The root url to use to load external dependencies like texture\r\n * @returns the new sprite manager\r\n */\r\n public static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager {\r\n const manager = new SpriteManager(\r\n parsedManager.name,\r\n \"\",\r\n parsedManager.capacity,\r\n {\r\n width: parsedManager.cellWidth,\r\n height: parsedManager.cellHeight,\r\n },\r\n scene\r\n );\r\n\r\n if (parsedManager.fogEnabled !== undefined) {\r\n manager.fogEnabled = parsedManager.fogEnabled;\r\n }\r\n if (parsedManager.blendMode !== undefined) {\r\n manager.blendMode = parsedManager.blendMode;\r\n }\r\n if (parsedManager.disableDepthWrite !== undefined) {\r\n manager.disableDepthWrite = parsedManager.disableDepthWrite;\r\n }\r\n if (parsedManager.pixelPerfect !== undefined) {\r\n manager.pixelPerfect = parsedManager.pixelPerfect;\r\n }\r\n if (parsedManager.useLogarithmicDepth !== undefined) {\r\n manager.useLogarithmicDepth = parsedManager.useLogarithmicDepth;\r\n }\r\n\r\n if (parsedManager.metadata !== undefined) {\r\n manager.metadata = parsedManager.metadata;\r\n }\r\n\r\n if (parsedManager.texture) {\r\n manager.texture = Texture.Parse(parsedManager.texture, scene, rootUrl) as Texture;\r\n } else if (parsedManager.textureName) {\r\n manager.texture = new Texture(rootUrl + parsedManager.textureUrl, scene, false, parsedManager.invertY !== undefined ? parsedManager.invertY : true);\r\n }\r\n\r\n for (const parsedSprite of parsedManager.sprites) {\r\n Sprite.Parse(parsedSprite, manager);\r\n }\r\n\r\n return manager;\r\n }\r\n\r\n /**\r\n * Creates a sprite manager from a snippet saved in a remote file\r\n * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)\r\n * @param url defines the url to load from\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a promise that will resolve to the new sprite manager\r\n */\r\n public static async ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl: string = \"\"): Promise<SpriteManager> {\r\n return await new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const serializationObject = JSON.parse(request.responseText);\r\n const output = SpriteManager.Parse(serializationObject, scene || EngineStore.LastCreatedScene, rootUrl);\r\n\r\n if (name) {\r\n output.name = name;\r\n }\r\n\r\n resolve(output);\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(\"Unable to load the sprite manager\");\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", url);\r\n request.send();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a sprite manager from a snippet saved by the sprite editor\r\n * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a promise that will resolve to the new sprite manager\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n public static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl: string = \"\"): Promise<SpriteManager> {\r\n if (snippetId === \"_BLANK\") {\r\n return Promise.resolve(new SpriteManager(\"Default sprite manager\", \"//playground.babylonjs.com/textures/player.png\", 500, 64, scene));\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);\r\n const serializationObject = JSON.parse(snippet.spriteManager);\r\n const output = SpriteManager.Parse(serializationObject, scene || EngineStore.LastCreatedScene, rootUrl);\r\n\r\n output.snippetId = snippetId;\r\n\r\n resolve(output);\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(\"Unable to load the snippet \" + snippetId);\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", this.SnippetUrl + \"/\" + snippetId.replace(/#/g, \"/\"));\r\n request.send();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a sprite manager from a snippet saved by the sprite editor\r\n * @deprecated Please use ParseFromSnippetAsync instead\r\n * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a promise that will resolve to the new sprite manager\r\n */\r\n public static CreateFromSnippetAsync = SpriteManager.ParseFromSnippetAsync;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"spriteManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Sprites/spriteManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAyGjD;;;GAGG;AACH,MAAM,OAAO,aAAa;IA6BtB;;OAEG;IACH,IAAW,SAAS,CAAC,QAAoB;QACrC,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,C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AE;YACnC,MAAM,OAAO,GAAG,IAAI,UAAU,EAAE,CAAC;YACjC,OAAO,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE;gBAC9C,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,EAAE,CAAC;oBAC1B,IAAI,OAAO,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;wBACxB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,CAAC;wBACzE,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;wBAC9D,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,IAAI,WAAW,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;wBAExG,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;wBAE7B,OAAO,CAAC,MAAM,CAAC,CAAC;oBACpB,CAAC;yBAAM,CAAC;wBACJ,2EAA2E;wBAC3E,MAAM,CAAC,6BAA6B,GAAG,SAAS,CAAC,CAAC;oBACtD,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;;AA7sBD,sCAAsC;AACxB,wBAAU,GAAG,SAAS,CAAC,UAAU,AAAvB,CAAwB;AA8sBhD;;;;;;;GAOG;AACW,oCAAsB,GAAG,aAAa,CAAC,qBAAqB,AAAtC,CAAuC","sourcesContent":["import type { IDisposable, Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../Maths/math.vector\";\r\nimport { Sprite } from \"./sprite\";\r\nimport { SpriteSceneComponent } from \"./spriteSceneComponent\";\r\nimport type { InternalSpriteAugmentedScene } from \"./spriteSceneComponent\";\r\nimport { PickingInfo } from \"../Collisions/pickingInfo\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport { WebRequest } from \"../Misc/webRequest\";\r\nimport type { SpriteRendererOptions } from \"./spriteRenderer\";\r\nimport { SpriteRenderer } from \"./spriteRenderer\";\r\nimport type { ThinSprite } from \"./thinSprite\";\r\nimport type { ISize } from \"../Maths/math.size\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport type { Ray } from \"../Culling/ray\";\r\n\r\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect\r\ndeclare const Reflect: any;\r\n\r\n/**\r\n * Defines the minimum interface to fulfill in order to be a sprite manager.\r\n */\r\nexport interface ISpriteManager extends IDisposable {\r\n /**\r\n * Gets or sets the unique id of the texture\r\n */\r\n uniqueId: number;\r\n\r\n /**\r\n * Gets manager's name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Restricts the camera to viewing objects with the same layerMask.\r\n * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0\r\n */\r\n layerMask: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true\r\n */\r\n isPickable: boolean;\r\n\r\n /**\r\n * Gets the hosting scene\r\n */\r\n scene: Scene;\r\n\r\n /**\r\n * Specifies the rendering group id for this mesh (0 by default)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/transparent_rendering#rendering-groups\r\n */\r\n renderingGroupId: number;\r\n\r\n /**\r\n * Defines the list of sprites managed by the manager.\r\n */\r\n sprites: Array<Sprite>;\r\n\r\n /**\r\n * Gets or sets the spritesheet texture\r\n */\r\n texture: Texture;\r\n\r\n /** Defines the default width of a cell in the spritesheet */\r\n cellWidth: number;\r\n /** Defines the default height of a cell in the spritesheet */\r\n cellHeight: number;\r\n\r\n /** @internal */\r\n _wasDispatched: boolean;\r\n\r\n /**\r\n * Tests the intersection of a sprite with a specific ray.\r\n * @param ray The ray we are sending to test the collision\r\n * @param camera The camera space we are sending rays in\r\n * @param predicate A predicate allowing excluding sprites from the list of object to test\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @returns picking info or null.\r\n */\r\n intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;\r\n\r\n /**\r\n * Intersects the sprites with a ray\r\n * @param ray defines the ray to intersect with\r\n * @param camera defines the current active camera\r\n * @param predicate defines a predicate used to select candidate sprites\r\n * @returns null if no hit or a PickingInfo array\r\n */\r\n multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;\r\n\r\n /**\r\n * Renders the list of sprites on screen.\r\n */\r\n render(): void;\r\n\r\n /**\r\n * Rebuilds the manager (after a context lost, for eg)\r\n */\r\n rebuild(): void;\r\n\r\n /**\r\n * Serializes the sprite manager to a JSON object\r\n */\r\n serialize(serializeTexture?: boolean): any;\r\n}\r\n\r\n/**\r\n * Options for the SpriteManager\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface SpriteManagerOptions {\r\n /** Options for the sprite renderer */\r\n spriteRendererOptions: SpriteRendererOptions;\r\n}\r\n\r\n/**\r\n * Class used to manage multiple sprites on the same spritesheet\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/sprites\r\n */\r\nexport class SpriteManager implements ISpriteManager {\r\n /** Define the Url to load snippets */\r\n public static SnippetUrl = Constants.SnippetUrl;\r\n\r\n /** Snippet ID if the manager was created from the snippet server */\r\n public snippetId: string;\r\n\r\n /** Gets the list of sprites */\r\n public sprites: Sprite[] = [];\r\n /** Gets or sets the rendering group id (0 by default) */\r\n public renderingGroupId = 0;\r\n /** Gets or sets camera layer mask */\r\n public layerMask: number = 0x0fffffff;\r\n /** Gets or sets a boolean indicating if the sprites are pickable */\r\n public isPickable = false;\r\n\r\n /**\r\n * Gets or sets an object used to store user defined information for the sprite manager\r\n */\r\n public metadata: any = null;\r\n\r\n /** @internal */\r\n public _wasDispatched = false;\r\n\r\n /**\r\n * An event triggered when the manager is disposed.\r\n */\r\n public onDisposeObservable = new Observable<SpriteManager>();\r\n\r\n /**\r\n * Callback called when the manager is disposed\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Gets or sets the unique id of the sprite\r\n */\r\n public uniqueId: number;\r\n\r\n /**\r\n * Gets the array of sprites\r\n */\r\n public get children() {\r\n return this.sprites;\r\n }\r\n\r\n /**\r\n * Gets the hosting scene\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the capacity of the manager\r\n */\r\n public get capacity() {\r\n return this._spriteRenderer.capacity;\r\n }\r\n\r\n /**\r\n * Gets or sets the spritesheet texture\r\n */\r\n public get texture(): Texture {\r\n return this._spriteRenderer.texture as Texture;\r\n }\r\n public set texture(value: Texture) {\r\n value.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n value.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n this._spriteRenderer.texture = value;\r\n this._textureContent = null;\r\n }\r\n\r\n /** Defines the default width of a cell in the spritesheet */\r\n public get cellWidth(): number {\r\n return this._spriteRenderer.cellWidth;\r\n }\r\n public set cellWidth(value: number) {\r\n this._spriteRenderer.cellWidth = value;\r\n }\r\n\r\n /** Defines the default height of a cell in the spritesheet */\r\n public get cellHeight(): number {\r\n return this._spriteRenderer.cellHeight;\r\n }\r\n public set cellHeight(value: number) {\r\n this._spriteRenderer.cellHeight = value;\r\n }\r\n\r\n /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */\r\n public get fogEnabled(): boolean {\r\n return this._spriteRenderer.fogEnabled;\r\n }\r\n public set fogEnabled(value: boolean) {\r\n this._spriteRenderer.fogEnabled = value;\r\n }\r\n\r\n /** Gets or sets a boolean indicating if the manager must use logarithmic depth when rendering */\r\n public get useLogarithmicDepth(): boolean {\r\n return this._spriteRenderer.useLogarithmicDepth;\r\n }\r\n public set useLogarithmicDepth(value: boolean) {\r\n this._spriteRenderer.useLogarithmicDepth = value;\r\n }\r\n\r\n /**\r\n * Blend mode use to render the particle, it can be any of\r\n * the static Constants.ALPHA_x properties provided in this class.\r\n * Default value is Constants.ALPHA_COMBINE\r\n */\r\n public get blendMode() {\r\n return this._spriteRenderer.blendMode;\r\n }\r\n public set blendMode(blendMode: number) {\r\n this._spriteRenderer.blendMode = blendMode;\r\n }\r\n\r\n private _disableDepthWrite: boolean = false;\r\n /** Disables writing to the depth buffer when rendering the sprites.\r\n * It can be handy to disable depth writing when using textures without alpha channel\r\n * and setting some specific blend modes.\r\n */\r\n public get disableDepthWrite() {\r\n return this._disableDepthWrite;\r\n }\r\n\r\n public set disableDepthWrite(value: boolean) {\r\n this._disableDepthWrite = value;\r\n this._spriteRenderer.disableDepthWrite = value;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the renderer must render sprites with pixel perfect rendering\r\n * In this mode, sprites are rendered as \"pixel art\", which means that they appear as pixelated but remain stable when moving or when rotated or scaled.\r\n * Note that for this mode to work as expected, the sprite texture must use the BILINEAR sampling mode, not NEAREST!\r\n */\r\n public get pixelPerfect() {\r\n return this._spriteRenderer.pixelPerfect;\r\n }\r\n\r\n public set pixelPerfect(value: boolean) {\r\n this._spriteRenderer.pixelPerfect = value;\r\n if (value && this.texture.samplingMode !== Constants.TEXTURE_TRILINEAR_SAMPLINGMODE) {\r\n this.texture.updateSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE);\r\n }\r\n }\r\n\r\n private _spriteRenderer: SpriteRenderer;\r\n /** Associative array from JSON sprite data file */\r\n private _cellData: any;\r\n /** Array of sprite names from JSON sprite data file */\r\n private _spriteMap: Array<string>;\r\n /** True when packed cell data from JSON file is ready*/\r\n private _packedAndReady: boolean = false;\r\n private _textureContent: Nullable<Uint8Array>;\r\n private _onDisposeObserver: Nullable<Observer<SpriteManager>>;\r\n private _fromPacked: boolean;\r\n private _scene: InternalSpriteAugmentedScene;\r\n\r\n /**\r\n * Creates a new sprite manager\r\n * @param name defines the manager's name\r\n * @param imgUrl defines the sprite sheet url\r\n * @param capacity defines the maximum allowed number of sprites\r\n * @param cellSize defines the size of a sprite cell\r\n * @param scene defines the hosting scene\r\n * @param epsilon defines the epsilon value to align texture (0.01 by default)\r\n * @param samplingMode defines the sampling mode to use with spritesheet\r\n * @param fromPacked set to false; do not alter\r\n * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter\r\n * @param options options used to create the SpriteManager instance\r\n */\r\n constructor(\r\n /** defines the manager's name */\r\n public name: string,\r\n imgUrl: string,\r\n capacity: number,\r\n cellSize: any,\r\n scene: Scene,\r\n epsilon: number = 0.01,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n fromPacked: boolean = false,\r\n spriteJSON: null | string = null,\r\n options?: SpriteManagerOptions\r\n ) {\r\n if (!scene) {\r\n scene = EngineStore.LastCreatedScene!;\r\n }\r\n\r\n if (!scene._getComponent(SceneComponentConstants.NAME_SPRITE)) {\r\n scene._addComponent(new SpriteSceneComponent(scene));\r\n }\r\n this._fromPacked = fromPacked;\r\n\r\n this._scene = scene as InternalSpriteAugmentedScene;\r\n const engine = this._scene.getEngine();\r\n this._spriteRenderer = new SpriteRenderer(engine, capacity, epsilon, scene, options?.spriteRendererOptions);\r\n\r\n if (cellSize.width && cellSize.height) {\r\n this.cellWidth = cellSize.width;\r\n this.cellHeight = cellSize.height;\r\n } else if (cellSize !== undefined) {\r\n this.cellWidth = cellSize;\r\n this.cellHeight = cellSize;\r\n } else {\r\n this._spriteRenderer = <any>null;\r\n return;\r\n }\r\n\r\n this._scene.spriteManagers && this._scene.spriteManagers.push(this);\r\n this.uniqueId = this.scene.getUniqueId();\r\n\r\n if (imgUrl) {\r\n this.texture = new Texture(imgUrl, scene, true, false, samplingMode);\r\n }\r\n\r\n if (this._fromPacked) {\r\n this._makePacked(imgUrl, spriteJSON);\r\n }\r\n\r\n this._scene._onNewSpriteManagerAddedObservable?.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Returns the string \"SpriteManager\"\r\n * @returns \"SpriteManager\"\r\n */\r\n public getClassName(): string {\r\n return \"SpriteManager\";\r\n }\r\n\r\n private _makePacked(imgUrl: string, spriteJSON: any) {\r\n if (spriteJSON !== null) {\r\n try {\r\n //Get the JSON and Check its structure. If its an array parse it if its a JSON string etc...\r\n let celldata: any;\r\n if (typeof spriteJSON === \"string\") {\r\n celldata = JSON.parse(spriteJSON);\r\n } else {\r\n celldata = spriteJSON;\r\n }\r\n\r\n if (celldata.frames.length) {\r\n const frametemp: any = {};\r\n for (let i = 0; i < celldata.frames.length; i++) {\r\n const _f = celldata.frames[i];\r\n if (typeof Object.keys(_f)[0] !== \"string\") {\r\n throw new Error(\"Invalid JSON Format. Check the frame values and make sure the name is the first parameter.\");\r\n }\r\n\r\n const name: string = _f[Object.keys(_f)[0]];\r\n frametemp[name] = _f;\r\n }\r\n celldata.frames = frametemp;\r\n }\r\n\r\n const spritemap = <string[]>Reflect.ownKeys(celldata.frames);\r\n\r\n this._spriteMap = spritemap;\r\n this._packedAndReady = true;\r\n this._cellData = celldata.frames;\r\n } catch (e) {\r\n this._fromPacked = false;\r\n this._packedAndReady = false;\r\n throw new Error(\"Invalid JSON from string. Spritesheet managed with constant cell size.\");\r\n }\r\n } else {\r\n const re = /\\./g;\r\n let li: number;\r\n do {\r\n li = re.lastIndex;\r\n re.test(imgUrl);\r\n } while (re.lastIndex > 0);\r\n const jsonUrl = imgUrl.substring(0, li - 1) + \".json\";\r\n const onerror = () => {\r\n Logger.Error(\"JSON ERROR: Unable to load JSON file.\");\r\n this._fromPacked = false;\r\n this._packedAndReady = false;\r\n };\r\n const onload = (data: string | ArrayBuffer) => {\r\n try {\r\n const celldata = JSON.parse(data as string);\r\n const spritemap = <string[]>Reflect.ownKeys(celldata.frames);\r\n this._spriteMap = spritemap;\r\n this._packedAndReady = true;\r\n this._cellData = celldata.frames;\r\n } catch (e) {\r\n this._fromPacked = false;\r\n this._packedAndReady = false;\r\n throw new Error(\"Invalid JSON format. Please check documentation for format specifications.\");\r\n }\r\n };\r\n Tools.LoadFile(jsonUrl, onload, undefined, undefined, false, onerror);\r\n }\r\n }\r\n\r\n private _checkTextureAlpha(sprite: Sprite, ray: Ray, distance: number, min: Vector3, max: Vector3) {\r\n if (!sprite.useAlphaForPicking || !this.texture?.isReady()) {\r\n return true;\r\n }\r\n\r\n const textureSize = this.texture.getSize();\r\n if (!this._textureContent) {\r\n this._textureContent = new Uint8Array(textureSize.width * textureSize.height * 4);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.texture.readPixels(0, 0, this._textureContent);\r\n }\r\n\r\n const contactPoint = TmpVectors.Vector3[0];\r\n\r\n contactPoint.copyFrom(ray.direction);\r\n\r\n contactPoint.normalize();\r\n contactPoint.scaleInPlace(distance);\r\n contactPoint.addInPlace(ray.origin);\r\n\r\n const contactPointU = (contactPoint.x - min.x) / (max.x - min.x);\r\n const contactPointV = 1.0 - (contactPoint.y - min.y) / (max.y - min.y);\r\n\r\n const u = (sprite._xOffset * textureSize.width + contactPointU * sprite._xSize) | 0;\r\n const v = (sprite._yOffset * textureSize.height + contactPointV * sprite._ySize) | 0;\r\n\r\n const alpha = this._textureContent[(u + v * textureSize.width) * 4 + 3];\r\n\r\n return alpha > 0.5;\r\n }\r\n\r\n /**\r\n * Intersects the sprites with a ray\r\n * @param ray defines the ray to intersect with\r\n * @param camera defines the current active camera\r\n * @param predicate defines a predicate used to select candidate sprites\r\n * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)\r\n * @returns null if no hit or a PickingInfo\r\n */\r\n public intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo> {\r\n const count = Math.min(this.capacity, this.sprites.length);\r\n const min = Vector3.Zero();\r\n const max = Vector3.Zero();\r\n let distance = Number.MAX_VALUE;\r\n let currentSprite: Nullable<Sprite> = null;\r\n const pickedPoint = TmpVectors.Vector3[0];\r\n const cameraSpacePosition = TmpVectors.Vector3[1];\r\n const cameraView = camera.getViewMatrix();\r\n let activeRay: Ray = ray;\r\n let pickedRay: Ray = ray;\r\n\r\n for (let index = 0; index < count; index++) {\r\n const sprite = this.sprites[index];\r\n if (!sprite) {\r\n continue;\r\n }\r\n\r\n if (predicate) {\r\n if (!predicate(sprite)) {\r\n continue;\r\n }\r\n } else if (!sprite.isPickable) {\r\n continue;\r\n }\r\n\r\n Vector3.TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);\r\n\r\n if (sprite.angle) {\r\n // Create a rotation matrix to rotate the ray to the sprite's rotation\r\n Matrix.TranslationToRef(-cameraSpacePosition.x, -cameraSpacePosition.y, 0, TmpVectors.Matrix[1]);\r\n Matrix.TranslationToRef(cameraSpacePosition.x, cameraSpacePosition.y, 0, TmpVectors.Matrix[2]);\r\n Matrix.RotationZToRef(-sprite.angle, TmpVectors.Matrix[3]);\r\n\r\n // inv translation x rotation x translation\r\n TmpVectors.Matrix[1].multiplyToRef(TmpVectors.Matrix[3], TmpVectors.Matrix[4]);\r\n TmpVectors.Matrix[4].multiplyToRef(TmpVectors.Matrix[2], TmpVectors.Matrix[0]);\r\n\r\n activeRay = ray.clone();\r\n Vector3.TransformCoordinatesToRef(ray.origin, TmpVectors.Matrix[0], activeRay.origin);\r\n Vector3.TransformNormalToRef(ray.direction, TmpVectors.Matrix[0], activeRay.direction);\r\n } else {\r\n activeRay = ray;\r\n }\r\n\r\n min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);\r\n max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);\r\n\r\n if (activeRay.intersectsBoxMinMax(min, max)) {\r\n const currentDistance = Vector3.Distance(cameraSpacePosition, activeRay.origin);\r\n\r\n if (distance > currentDistance) {\r\n if (!this._checkTextureAlpha(sprite, activeRay, currentDistance, min, max)) {\r\n continue;\r\n }\r\n\r\n pickedRay = activeRay;\r\n distance = currentDistance;\r\n currentSprite = sprite;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (currentSprite) {\r\n const result = new PickingInfo();\r\n\r\n cameraView.invertToRef(TmpVectors.Matrix[0]);\r\n result.hit = true;\r\n result.pickedSprite = currentSprite;\r\n result.distance = distance;\r\n\r\n // Get picked point\r\n const direction = TmpVectors.Vector3[2];\r\n direction.copyFrom(pickedRay.direction);\r\n direction.normalize();\r\n direction.scaleInPlace(distance);\r\n\r\n pickedRay.origin.addToRef(direction, pickedPoint);\r\n result.pickedPoint = Vector3.TransformCoordinates(pickedPoint, TmpVectors.Matrix[0]);\r\n\r\n return result;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Intersects the sprites with a ray\r\n * @param ray defines the ray to intersect with\r\n * @param camera defines the current active camera\r\n * @param predicate defines a predicate used to select candidate sprites\r\n * @returns null if no hit or a PickingInfo array\r\n */\r\n public multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]> {\r\n const count = Math.min(this.capacity, this.sprites.length);\r\n const min = Vector3.Zero();\r\n const max = Vector3.Zero();\r\n let distance: number;\r\n const results: Nullable<PickingInfo[]> = [];\r\n const pickedPoint = TmpVectors.Vector3[0].copyFromFloats(0, 0, 0);\r\n const cameraSpacePosition = TmpVectors.Vector3[1].copyFromFloats(0, 0, 0);\r\n const cameraView = camera.getViewMatrix();\r\n\r\n for (let index = 0; index < count; index++) {\r\n const sprite = this.sprites[index];\r\n if (!sprite) {\r\n continue;\r\n }\r\n\r\n if (predicate) {\r\n if (!predicate(sprite)) {\r\n continue;\r\n }\r\n } else if (!sprite.isPickable) {\r\n continue;\r\n }\r\n\r\n Vector3.TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);\r\n\r\n min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);\r\n max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);\r\n\r\n if (ray.intersectsBoxMinMax(min, max)) {\r\n distance = Vector3.Distance(cameraSpacePosition, ray.origin);\r\n\r\n if (!this._checkTextureAlpha(sprite, ray, distance, min, max)) {\r\n continue;\r\n }\r\n\r\n const result = new PickingInfo();\r\n results.push(result);\r\n\r\n cameraView.invertToRef(TmpVectors.Matrix[0]);\r\n result.hit = true;\r\n result.pickedSprite = sprite;\r\n result.distance = distance;\r\n\r\n // Get picked point\r\n const direction = TmpVectors.Vector3[2];\r\n direction.copyFrom(ray.direction);\r\n direction.normalize();\r\n direction.scaleInPlace(distance);\r\n\r\n ray.origin.addToRef(direction, pickedPoint);\r\n result.pickedPoint = Vector3.TransformCoordinates(pickedPoint, TmpVectors.Matrix[0]);\r\n }\r\n }\r\n\r\n return results;\r\n }\r\n\r\n /**\r\n * Render all child sprites\r\n */\r\n public render(): void {\r\n // Check\r\n if (this._fromPacked && (!this._packedAndReady || !this._spriteMap || !this._cellData)) {\r\n return;\r\n }\r\n\r\n const engine = this._scene.getEngine();\r\n const deltaTime = engine.getDeltaTime();\r\n if (this._packedAndReady) {\r\n this._spriteRenderer.render(this.sprites, deltaTime, this._scene.getViewMatrix(), this._scene.getProjectionMatrix(), this._customUpdate);\r\n } else {\r\n this._spriteRenderer.render(this.sprites, deltaTime, this._scene.getViewMatrix(), this._scene.getProjectionMatrix());\r\n }\r\n }\r\n\r\n private _customUpdate = (sprite: ThinSprite, baseSize: ISize): void => {\r\n if (!sprite.cellRef) {\r\n sprite.cellIndex = 0;\r\n }\r\n const num = sprite.cellIndex;\r\n if (typeof num === \"number\" && isFinite(num) && Math.floor(num) === num) {\r\n sprite.cellRef = this._spriteMap[sprite.cellIndex];\r\n }\r\n sprite._xOffset = this._cellData[sprite.cellRef].frame.x / baseSize.width;\r\n sprite._yOffset = this._cellData[sprite.cellRef].frame.y / baseSize.height;\r\n sprite._xSize = this._cellData[sprite.cellRef].frame.w;\r\n sprite._ySize = this._cellData[sprite.cellRef].frame.h;\r\n };\r\n\r\n /**\r\n * Rebuilds the manager (after a context lost, for eg)\r\n */\r\n public rebuild(): void {\r\n this._spriteRenderer?.rebuild();\r\n }\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._spriteRenderer) {\r\n this._spriteRenderer.dispose();\r\n (<any>this._spriteRenderer) = null;\r\n }\r\n\r\n this._textureContent = null;\r\n\r\n // Remove from scene\r\n if (this._scene.spriteManagers) {\r\n const index = this._scene.spriteManagers.indexOf(this);\r\n this._scene.spriteManagers.splice(index, 1);\r\n this._scene._onSpriteManagerRemovedObservable?.notifyObservers(this);\r\n }\r\n\r\n // Callback\r\n this.onDisposeObservable.notifyObservers(this);\r\n this.onDisposeObservable.clear();\r\n\r\n this.metadata = null;\r\n }\r\n\r\n /**\r\n * Serializes the sprite manager to a JSON object\r\n * @param serializeTexture defines if the texture must be serialized as well\r\n * @returns the JSON object\r\n */\r\n public serialize(serializeTexture = false): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.name = this.name;\r\n serializationObject.capacity = this.capacity;\r\n serializationObject.cellWidth = this.cellWidth;\r\n serializationObject.cellHeight = this.cellHeight;\r\n serializationObject.fogEnabled = this.fogEnabled;\r\n serializationObject.blendMode = this.blendMode;\r\n serializationObject.disableDepthWrite = this.disableDepthWrite;\r\n serializationObject.pixelPerfect = this.pixelPerfect;\r\n serializationObject.useLogarithmicDepth = this.useLogarithmicDepth;\r\n\r\n if (this.texture) {\r\n if (serializeTexture) {\r\n serializationObject.texture = this.texture.serialize();\r\n } else {\r\n serializationObject.textureUrl = this.texture.name;\r\n serializationObject.invertY = this.texture._invertY;\r\n }\r\n }\r\n\r\n serializationObject.sprites = [];\r\n\r\n for (const sprite of this.sprites) {\r\n serializationObject.sprites.push(sprite.serialize());\r\n }\r\n\r\n serializationObject.metadata = this.metadata;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parses a JSON object to create a new sprite manager.\r\n * @param parsedManager The JSON object to parse\r\n * @param scene The scene to create the sprite manager\r\n * @param rootUrl The root url to use to load external dependencies like texture\r\n * @returns the new sprite manager\r\n */\r\n public static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager {\r\n const manager = new SpriteManager(\r\n parsedManager.name,\r\n \"\",\r\n parsedManager.capacity,\r\n {\r\n width: parsedManager.cellWidth,\r\n height: parsedManager.cellHeight,\r\n },\r\n scene\r\n );\r\n\r\n if (parsedManager.fogEnabled !== undefined) {\r\n manager.fogEnabled = parsedManager.fogEnabled;\r\n }\r\n if (parsedManager.blendMode !== undefined) {\r\n manager.blendMode = parsedManager.blendMode;\r\n }\r\n if (parsedManager.disableDepthWrite !== undefined) {\r\n manager.disableDepthWrite = parsedManager.disableDepthWrite;\r\n }\r\n if (parsedManager.pixelPerfect !== undefined) {\r\n manager.pixelPerfect = parsedManager.pixelPerfect;\r\n }\r\n if (parsedManager.useLogarithmicDepth !== undefined) {\r\n manager.useLogarithmicDepth = parsedManager.useLogarithmicDepth;\r\n }\r\n\r\n if (parsedManager.metadata !== undefined) {\r\n manager.metadata = parsedManager.metadata;\r\n }\r\n\r\n if (parsedManager.texture) {\r\n manager.texture = Texture.Parse(parsedManager.texture, scene, rootUrl) as Texture;\r\n } else if (parsedManager.textureName) {\r\n manager.texture = new Texture(rootUrl + parsedManager.textureUrl, scene, false, parsedManager.invertY !== undefined ? parsedManager.invertY : true);\r\n }\r\n\r\n for (const parsedSprite of parsedManager.sprites) {\r\n Sprite.Parse(parsedSprite, manager);\r\n }\r\n\r\n return manager;\r\n }\r\n\r\n /**\r\n * Creates a sprite manager from a snippet saved in a remote file\r\n * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)\r\n * @param url defines the url to load from\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a promise that will resolve to the new sprite manager\r\n */\r\n public static async ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl: string = \"\"): Promise<SpriteManager> {\r\n return await new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const serializationObject = JSON.parse(request.responseText);\r\n const output = SpriteManager.Parse(serializationObject, scene || EngineStore.LastCreatedScene, rootUrl);\r\n\r\n if (name) {\r\n output.name = name;\r\n }\r\n\r\n resolve(output);\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(\"Unable to load the sprite manager\");\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", url);\r\n request.send();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a sprite manager from a snippet saved by the sprite editor\r\n * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a promise that will resolve to the new sprite manager\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n public static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl: string = \"\"): Promise<SpriteManager> {\r\n if (snippetId === \"_BLANK\") {\r\n return Promise.resolve(new SpriteManager(\"Default sprite manager\", \"//playground.babylonjs.com/textures/player.png\", 500, 64, scene));\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);\r\n const serializationObject = JSON.parse(snippet.spriteManager);\r\n const output = SpriteManager.Parse(serializationObject, scene || EngineStore.LastCreatedScene, rootUrl);\r\n\r\n output.snippetId = snippetId;\r\n\r\n resolve(output);\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(\"Unable to load the snippet \" + snippetId);\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", this.SnippetUrl + \"/\" + snippetId.replace(/#/g, \"/\"));\r\n request.send();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a sprite manager from a snippet saved by the sprite editor\r\n * @deprecated Please use ParseFromSnippetAsync instead\r\n * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a promise that will resolve to the new sprite manager\r\n */\r\n public static CreateFromSnippetAsync = SpriteManager.ParseFromSnippetAsync;\r\n}\r\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Nullable } from "../types.js";
|
|
2
2
|
import { Observable } from "../Misc/observable.js";
|
|
3
|
+
import type { IReadonlyObservable } from "../Misc/observable.js";
|
|
3
4
|
import { Scene } from "../scene.js";
|
|
4
5
|
import type { Sprite } from "./sprite.js";
|
|
5
6
|
import type { ISpriteManager } from "./spriteManager.js";
|
|
@@ -20,6 +21,14 @@ declare module "../scene.js" {
|
|
|
20
21
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/sprites
|
|
21
22
|
*/
|
|
22
23
|
spriteManagers?: Array<ISpriteManager>;
|
|
24
|
+
/**
|
|
25
|
+
* An event triggered when a sprite manager is added to the scene
|
|
26
|
+
*/
|
|
27
|
+
readonly onNewSpriteManagerAddedObservable: IReadonlyObservable<ISpriteManager>;
|
|
28
|
+
/**
|
|
29
|
+
* An event triggered when a sprite manager is removed from the scene
|
|
30
|
+
*/
|
|
31
|
+
readonly onSpriteManagerRemovedObservable: IReadonlyObservable<ISpriteManager>;
|
|
23
32
|
/**
|
|
24
33
|
* An event triggered when sprites rendering is about to start
|
|
25
34
|
* Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
|
|
@@ -78,6 +87,11 @@ declare module "../scene.js" {
|
|
|
78
87
|
getPointerOverSprite(): Nullable<Sprite>;
|
|
79
88
|
}
|
|
80
89
|
}
|
|
90
|
+
/** @internal */
|
|
91
|
+
export type InternalSpriteAugmentedScene = Scene & {
|
|
92
|
+
_onNewSpriteManagerAddedObservable?: Observable<ISpriteManager>;
|
|
93
|
+
_onSpriteManagerRemovedObservable?: Observable<ISpriteManager>;
|
|
94
|
+
};
|
|
81
95
|
/**
|
|
82
96
|
* Defines the sprite scene component responsible to manage sprites
|
|
83
97
|
* in a given scene.
|
|
@@ -5,6 +5,28 @@ import { PickingInfo } from "../Collisions/pickingInfo.js";
|
|
|
5
5
|
import { SceneComponentConstants } from "../sceneComponent.js";
|
|
6
6
|
import { ActionEvent } from "../Actions/actionEvent.js";
|
|
7
7
|
|
|
8
|
+
Object.defineProperty(Scene.prototype, "onNewSpriteManagerAddedObservable", {
|
|
9
|
+
get: function () {
|
|
10
|
+
if (!this.isDisposed && !this._onNewSpriteManagerAddedObservable) {
|
|
11
|
+
const onNewSpriteManagerAddedObservable = (this._onNewSpriteManagerAddedObservable = new Observable());
|
|
12
|
+
this.onDisposeObservable.addOnce(() => onNewSpriteManagerAddedObservable.clear());
|
|
13
|
+
}
|
|
14
|
+
return this._onNewSpriteManagerAddedObservable;
|
|
15
|
+
},
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(Scene.prototype, "onSpriteManagerRemovedObservable", {
|
|
20
|
+
get: function () {
|
|
21
|
+
if (!this.isDisposed && !this._onSpriteManagerRemovedObservable) {
|
|
22
|
+
const onSpriteManagerRemovedObservable = (this._onSpriteManagerRemovedObservable = new Observable());
|
|
23
|
+
this.onDisposeObservable.addOnce(() => onSpriteManagerRemovedObservable.clear());
|
|
24
|
+
}
|
|
25
|
+
return this._onSpriteManagerRemovedObservable;
|
|
26
|
+
},
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
});
|
|
8
30
|
Scene.prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
|
|
9
31
|
if (!PickingInfo) {
|
|
10
32
|
return null;
|
|
@@ -138,6 +160,7 @@ export class SpriteSceneComponent {
|
|
|
138
160
|
this.name = SceneComponentConstants.NAME_SPRITE;
|
|
139
161
|
this.scene = scene;
|
|
140
162
|
this.scene.spriteManagers = [];
|
|
163
|
+
// This ray is used to pick sprites in the scene
|
|
141
164
|
this.scene._tempSpritePickingRay = Ray ? Ray.Zero() : null;
|
|
142
165
|
this.scene.onBeforeSpritesRenderingObservable = new Observable();
|
|
143
166
|
this.scene.onAfterSpritesRenderingObservable = new Observable();
|