@babylonjs/core 6.6.0 → 6.6.1
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/Behaviors/behavior.d.ts +1 -1
- package/Behaviors/behavior.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -0
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/gizmo.d.ts +21 -0
- package/Gizmos/gizmo.js +30 -3
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/positionGizmo.d.ts +3 -1
- package/Gizmos/positionGizmo.js +9 -0
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +3 -1
- package/Gizmos/rotationGizmo.js +9 -0
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +3 -1
- package/Gizmos/scaleGizmo.js +11 -0
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +25 -24
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +1 -1
- package/Physics/v2/physicsBody.js +5 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAnisotropic.js +3 -3
- package/Shaders/ShadersInclude/pbrBlockAnisotropic.js.map +1 -1
- package/ShadersWGSL/postprocess.vertex.d.ts +5 -0
- package/ShadersWGSL/postprocess.vertex.js +12 -0
- package/ShadersWGSL/postprocess.vertex.js.map +1 -0
- package/assetContainer.js +5 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ export declare class PhysicsBody {
|
|
|
50
50
|
private _nodeDisposeObserver;
|
|
51
51
|
/**
|
|
52
52
|
* Constructs a new physics body for the given node.
|
|
53
|
-
* @param transformNode - The Transform Node to construct the physics body for.
|
|
53
|
+
* @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.
|
|
54
54
|
* @param motionType - The motion type of the physics body. The options are:
|
|
55
55
|
* - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.
|
|
56
56
|
* - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.
|
|
@@ -8,7 +8,7 @@ import { Space } from "../../Maths/math.axis.js";
|
|
|
8
8
|
export class PhysicsBody {
|
|
9
9
|
/**
|
|
10
10
|
* Constructs a new physics body for the given node.
|
|
11
|
-
* @param transformNode - The Transform Node to construct the physics body for.
|
|
11
|
+
* @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.
|
|
12
12
|
* @param motionType - The motion type of the physics body. The options are:
|
|
13
13
|
* - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.
|
|
14
14
|
* - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.
|
|
@@ -65,6 +65,10 @@ export class PhysicsBody {
|
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
67
|
// single instance
|
|
68
|
+
if (transformNode.parent) {
|
|
69
|
+
// Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.
|
|
70
|
+
transformNode.computeWorldMatrix(true);
|
|
71
|
+
}
|
|
68
72
|
this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);
|
|
69
73
|
}
|
|
70
74
|
this.transformNode = transformNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1E,OAAO,EAAE,KAAK,EAAE,iCAA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CAAC,CAAC;IACtE,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,aAAsB;QAC1C,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,qEAAqE;QACrE,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC1B,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;SAC3C;QACD,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC3B,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;SACpC;QACD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { 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\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 * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\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 /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for.\r\n * @param motionType - The motion type of the physics body. 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 as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, motionType, transformNode.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 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 * 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._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public 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 *\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 */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\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 */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * intial values, which you can then customize.\r\n */\r\n public computeMassProperties(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 *\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 *\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 * @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 *\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 *\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 *\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 *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, 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 *\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 return this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\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 * 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(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for all collisions happening for event-enabled bodies\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(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 * 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 // 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._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1E,OAAO,EAAE,KAAK,EAAE,iCAA6B;AAO7C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAsCpB;;;;;;;;;;;;;OAaG;IACH,YAAY,aAA4B,EAAE,UAA6B,EAAE,YAAqB,EAAE,KAAY;QAnD5G;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAS7C;;WAEG;QACK,wBAAmB,GAAY,KAAK,CAAC;QAK7C;;;WAGG;QACH,mBAAc,GAAY,IAAI,CAAC;QAwB3B,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAmB,CAAC;QAChE,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,aA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,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { 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\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 * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\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 /**\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 as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\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 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 * 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._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public 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 *\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 */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\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 */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * intial values, which you can then customize.\r\n */\r\n public computeMassProperties(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 *\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 *\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 * @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 *\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 *\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 *\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 *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, 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 *\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 return this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\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 * 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(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for all collisions happening for event-enabled bodies\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(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 * 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 // 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._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
|
|
@@ -8,11 +8,11 @@ vec3 anisotropyMapData;
|
|
|
8
8
|
void anisotropicBlock(
|
|
9
9
|
in vec3 anisotropyMapData,
|
|
10
10
|
in mat3 TBN,
|
|
11
|
-
anisotropy*=anisotropyMapData.b;
|
|
11
|
+
anisotropy*=anisotropyMapData.b;
|
|
12
|
+
outParams.anisotropyMapData=anisotropyMapData;
|
|
13
|
+
anisotropyMapData.rg=anisotropyMapData.rg*2.0-1.0;
|
|
12
14
|
anisotropyDirection.rg*=anisotropyMapData.rg;
|
|
13
15
|
anisotropyDirection.xy=mat2(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(anisotropyMapData.rg);
|
|
14
|
-
#if DEBUGMODE>0
|
|
15
|
-
outParams.anisotropyMapData=anisotropyMapData;
|
|
16
16
|
#endif
|
|
17
17
|
mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));
|
|
18
18
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrBlockAnisotropic.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/ShadersInclude/pbrBlockAnisotropic.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Cd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"pbrBlockAnisotropic\";\nconst shader = `#ifdef ANISOTROPIC\nstruct anisotropicOutParams\r{\rfloat anisotropy;\rvec3 anisotropicTangent;\rvec3 anisotropicBitangent;\rvec3 anisotropicNormal;\r#if DEBUGMODE>0\nvec3 anisotropyMapData;\r#endif\n};\r#define pbr_inline\nvoid anisotropicBlock(\rin vec3 vAnisotropy,\rin float roughness,\r#ifdef ANISOTROPIC_TEXTURE\nin vec3 anisotropyMapData,\r#endif\nin mat3 TBN,\rin vec3 normalW,\rin vec3 viewDirectionW,\rout anisotropicOutParams outParams\r)\r{\rfloat anisotropy=vAnisotropy.b;\rvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\r#ifdef ANISOTROPIC_TEXTURE\nanisotropy*=anisotropyMapData.b;\
|
|
1
|
+
{"version":3,"file":"pbrBlockAnisotropic.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/ShadersInclude/pbrBlockAnisotropic.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Cd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"pbrBlockAnisotropic\";\nconst shader = `#ifdef ANISOTROPIC\nstruct anisotropicOutParams\r{\rfloat anisotropy;\rvec3 anisotropicTangent;\rvec3 anisotropicBitangent;\rvec3 anisotropicNormal;\r#if DEBUGMODE>0\nvec3 anisotropyMapData;\r#endif\n};\r#define pbr_inline\nvoid anisotropicBlock(\rin vec3 vAnisotropy,\rin float roughness,\r#ifdef ANISOTROPIC_TEXTURE\nin vec3 anisotropyMapData,\r#endif\nin mat3 TBN,\rin vec3 normalW,\rin vec3 viewDirectionW,\rout anisotropicOutParams outParams\r)\r{\rfloat anisotropy=vAnisotropy.b;\rvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\r#ifdef ANISOTROPIC_TEXTURE\nanisotropy*=anisotropyMapData.b;\r#if DEBUGMODE>0\noutParams.anisotropyMapData=anisotropyMapData;\r#endif\nanisotropyMapData.rg=anisotropyMapData.rg*2.0-1.0;\r#ifdef ANISOTROPIC_LEGACY\nanisotropyDirection.rg*=anisotropyMapData.rg;\r#else\nanisotropyDirection.xy=mat2(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(anisotropyMapData.rg);\r#endif\n#endif\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\rvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\rvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\routParams.anisotropy=anisotropy;\routParams.anisotropicTangent=anisotropicTangent;\routParams.anisotropicBitangent=anisotropicBitangent;\routParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);\r}\r#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const pbrBlockAnisotropic = { name, shader };\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
|
+
const name = "postprocessVertexShader";
|
|
4
|
+
const shader = `attribute position: vec2<f32>;
|
|
5
|
+
@vertex
|
|
6
|
+
vertexOutputs.vUV=(vertexInputs.position*madd+madd)*uniforms.scale;
|
|
7
|
+
}
|
|
8
|
+
// Sideeffect
|
|
9
|
+
ShaderStore.ShadersStoreWGSL[name] = shader;
|
|
10
|
+
/** @internal */
|
|
11
|
+
export const postprocessVertexShader = { name, shader };
|
|
12
|
+
//# sourceMappingURL=postprocess.vertex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postprocess.vertex.js","sourceRoot":"","sources":["../../../../lts/core/generated/ShadersWGSL/postprocess.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,IAAI,GAAG,yBAAyB,CAAC;AACvC,MAAM,MAAM,GAAG;;;;;;;;;;;;CAYd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\n\nconst name = \"postprocessVertexShader\";\nconst shader = `attribute position: vec2<f32>;\runiform scale: vec2<f32>;\rvarying vUV: vec2<f32>;\rconst madd=vec2(0.5,0.5);\r#define CUSTOM_VERTEX_DEFINITIONS\n@vertex\rfn main(input : VertexInputs)->FragmentInputs {\r#define CUSTOM_VERTEX_MAIN_BEGIN\nvertexOutputs.vUV=(vertexInputs.position*madd+madd)*uniforms.scale;\rvertexOutputs.position=vec4(vertexInputs.position,0.0,1.0);\r#define CUSTOM_VERTEX_MAIN_END\n}\r`;\n// Sideeffect\nShaderStore.ShadersStoreWGSL[name] = shader;\n/** @internal */\nexport const postprocessVertexShader = { name, shader };\n"]}
|
package/assetContainer.js
CHANGED
|
@@ -369,7 +369,11 @@ export class AssetContainer extends AbstractScene {
|
|
|
369
369
|
else {
|
|
370
370
|
// Mesh or TransformNode
|
|
371
371
|
let canInstance = true;
|
|
372
|
-
if (node.getClassName() === "TransformNode" ||
|
|
372
|
+
if (node.getClassName() === "TransformNode" ||
|
|
373
|
+
node.getClassName() === "Node" ||
|
|
374
|
+
node.skeleton ||
|
|
375
|
+
!node.getTotalVertices ||
|
|
376
|
+
node.getTotalVertices() === 0) {
|
|
373
377
|
// Transform nodes, skinned meshes, and meshes with no vertices can never be instanced!
|
|
374
378
|
canInstance = false;
|
|
375
379
|
}
|
package/assetContainer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetContainer.js","sourceRoot":"","sources":["../../../lts/core/generated/assetContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,w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B,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,EACjE,SAAS,EACT,IAAI,EACJ,SAAS,EACT,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CACtE,CAAC;gBAEF,uDAAuD;gBACvD,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aAC1C;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ","sourcesContent":["import { AbstractScene } from \"./abstractScene\";\r\nimport type { Scene } from \"./scene\";\r\nimport { Mesh } from \"./Meshes/mesh\";\r\nimport { TransformNode } from \"./Meshes/transformNode\";\r\nimport type { Skeleton } from \"./Bones/skeleton\";\r\nimport type { AnimationGroup } from \"./Animations/animationGroup\";\r\nimport type { Animatable } from \"./Animations/animatable\";\r\nimport type { AbstractMesh } from \"./Meshes/abstractMesh\";\r\nimport type { MultiMaterial } from \"./Materials/multiMaterial\";\r\nimport type { Material } from \"./Materials/material\";\r\nimport { Logger } from \"./Misc/logger\";\r\nimport { EngineStore } from \"./Engines/engineStore\";\r\nimport type { Nullable } from \"./types\";\r\nimport type { Node } from \"./node\";\r\nimport type { Observer } from \"./Misc/observable\";\r\nimport type { ThinEngine } from \"./Engines/thinEngine\";\r\nimport { InstancedMesh } from \"./Meshes/instancedMesh\";\r\nimport { Light } from \"./Lights/light\";\r\nimport { Camera } from \"./Cameras/camera\";\r\nimport { Tools } from \"./Misc/tools\";\r\n\r\n/**\r\n * Set of assets to keep when moving a scene into an asset container.\r\n */\r\nexport class KeepAssets extends AbstractScene {}\r\n\r\n/**\r\n * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function\r\n */\r\nexport class InstantiatedEntries {\r\n /**\r\n * List of new root nodes (eg. nodes with no parent)\r\n */\r\n public rootNodes: Node[] = [];\r\n\r\n /**\r\n * List of new skeletons\r\n */\r\n public skeletons: Skeleton[] = [];\r\n\r\n /**\r\n * List of new animation groups\r\n */\r\n public animationGroups: AnimationGroup[] = [];\r\n\r\n /**\r\n * Disposes the instantiated entries from the scene\r\n */\r\n public dispose() {\r\n this.rootNodes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.rootNodes.length = 0;\r\n\r\n this.skeletons.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.skeletons.length = 0;\r\n\r\n this.animationGroups.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.animationGroups.length = 0;\r\n }\r\n}\r\n\r\n/**\r\n * Container with a set of assets that can be added or removed from a scene.\r\n */\r\nexport class AssetContainer extends AbstractScene {\r\n private _wasAddedToScene = false;\r\n private _onContextRestoredObserver: Nullable<Observer<ThinEngine>>;\r\n\r\n /**\r\n * The scene the AssetContainer belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Instantiates an AssetContainer.\r\n * @param scene The scene the AssetContainer belongs to.\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n super();\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this.scene = scene;\r\n this[\"sounds\"] = [];\r\n this[\"effectLayers\"] = [];\r\n this[\"layers\"] = [];\r\n this[\"lensFlareSystems\"] = [];\r\n this[\"proceduralTextures\"] = [];\r\n this[\"reflectionProbes\"] = [];\r\n\r\n scene.onDisposeObservable.add(() => {\r\n if (!this._wasAddedToScene) {\r\n this.dispose();\r\n }\r\n });\r\n\r\n this._onContextRestoredObserver = scene.getEngine().onContextRestoredObservable.add(() => {\r\n for (const geometry of this.geometries) {\r\n geometry._rebuild();\r\n }\r\n\r\n for (const mesh of this.meshes) {\r\n mesh._rebuild();\r\n }\r\n\r\n for (const system of this.particleSystems) {\r\n system.rebuild();\r\n }\r\n\r\n for (const texture of this.textures) {\r\n texture._rebuild();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Given a list of nodes, return a topological sorting of them.\r\n * @param nodes\r\n */\r\n private _topologicalSort(nodes: Node[]): Node[] {\r\n const nodesUidMap = new Map<number, Node>();\r\n\r\n for (const node of nodes) {\r\n nodesUidMap.set(node.uniqueId, node);\r\n }\r\n\r\n const dependencyGraph = {\r\n dependsOn: new Map<number, Set<number>>(), // given a node id, what are the ids of the nodes it depends on\r\n dependedBy: new Map<number, Set<number>>(), // given a node id, what are the ids of the nodes that depend on it\r\n };\r\n\r\n // Build the dependency graph given the list of nodes\r\n\r\n // First pass: Initialize the empty dependency graph\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n dependencyGraph.dependsOn.set(nodeId, new Set<number>());\r\n dependencyGraph.dependedBy.set(nodeId, new Set<number>());\r\n }\r\n\r\n // Second pass: Populate the dependency graph. We assume that we\r\n // don't need to check for cycles here, as the scene graph cannot\r\n // contain cycles. Our graph also already contains all transitive\r\n // dependencies because getDescendants returns the transitive\r\n // dependencies by default.\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n const dependsOn = dependencyGraph.dependsOn.get(nodeId)!;\r\n if (node instanceof InstancedMesh) {\r\n const masterMesh = node.sourceMesh;\r\n if (nodesUidMap.has(masterMesh.uniqueId)) {\r\n dependsOn.add(masterMesh.uniqueId);\r\n dependencyGraph.dependedBy.get(masterMesh.uniqueId)!.add(nodeId);\r\n }\r\n }\r\n const dependedBy = dependencyGraph.dependedBy.get(nodeId)!;\r\n\r\n for (const child of node.getDescendants()) {\r\n const childId = child.uniqueId;\r\n if (nodesUidMap.has(childId)) {\r\n dependedBy.add(childId);\r\n\r\n const childDependsOn = dependencyGraph.dependsOn.get(childId)!;\r\n childDependsOn.add(nodeId);\r\n }\r\n }\r\n }\r\n\r\n // Third pass: Topological sort\r\n const sortedNodes: Node[] = [];\r\n\r\n // First: Find all nodes that have no dependencies\r\n const leaves: Node[] = [];\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n if (dependencyGraph.dependsOn.get(nodeId)!.size === 0) {\r\n leaves.push(node);\r\n nodesUidMap.delete(nodeId);\r\n }\r\n }\r\n\r\n const visitList = leaves;\r\n while (visitList.length > 0) {\r\n const nodeToVisit = visitList.shift()!;\r\n\r\n sortedNodes.push(nodeToVisit);\r\n\r\n // Remove the node from the dependency graph\r\n // When a node is visited, we know that dependsOn is empty.\r\n // So we only need to remove the node from dependedBy.\r\n const dependedByVisitedNode = dependencyGraph.dependedBy.get(nodeToVisit.uniqueId)!;\r\n // Array.from(x.values()) is to make the TS compiler happy\r\n for (const dependedByVisitedNodeId of Array.from(dependedByVisitedNode.values())) {\r\n const dependsOnDependedByVisitedNode = dependencyGraph.dependsOn.get(dependedByVisitedNodeId)!;\r\n dependsOnDependedByVisitedNode.delete(nodeToVisit.uniqueId);\r\n\r\n if (dependsOnDependedByVisitedNode.size === 0 && nodesUidMap.get(dependedByVisitedNodeId)) {\r\n visitList.push(nodesUidMap.get(dependedByVisitedNodeId)!);\r\n nodesUidMap.delete(dependedByVisitedNodeId);\r\n }\r\n }\r\n }\r\n\r\n if (nodesUidMap.size > 0) {\r\n console.error(\"SceneSerializer._topologicalSort: There were unvisited nodes:\");\r\n nodesUidMap.forEach((node) => console.error(node.name));\r\n }\r\n\r\n return sortedNodes;\r\n }\r\n\r\n private _addNodeAndDescendantsToList(list: Node[], addedIds: Set<number>, rootNode?: Node, predicate?: (entity: any) => boolean) {\r\n if (!rootNode || (predicate && !predicate(rootNode)) || addedIds.has(rootNode.uniqueId)) {\r\n return;\r\n }\r\n\r\n list.push(rootNode);\r\n addedIds.add(rootNode.uniqueId);\r\n\r\n for (const child of rootNode.getDescendants(true)) {\r\n this._addNodeAndDescendantsToList(list, addedIds, child, predicate);\r\n }\r\n }\r\n\r\n /**\r\n * Check if a specific node is contained in this asset container.\r\n * @param node\r\n */\r\n private _isNodeInContainer(node: Node) {\r\n if (node instanceof Mesh && this.meshes.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof TransformNode && this.transformNodes.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof Light && this.lights.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof Camera && this.cameras.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * For every node in the scene, check if its parent node is also in the scene.\r\n */\r\n private _isValidHierarchy() {\r\n for (const node of this.meshes) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.transformNodes) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.lights) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.cameras) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Instantiate or clone all meshes and add the new ones to the scene.\r\n * Skeletons and animation groups will all be cloned\r\n * @param nameFunction defines an optional function used to get new names for clones\r\n * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)\r\n * @param options defines an optional list of options to control how to instantiate / clone models\r\n * @param options.doNotInstantiate defines if the model must be instantiated or just cloned\r\n * @param options.predicate defines a predicate used to filter whih mesh to instantiate/clone\r\n * @returns a list of rootNodes, skeletons and animation groups that were duplicated\r\n */\r\n public instantiateModelsToScene(\r\n nameFunction?: (sourceName: string) => string,\r\n cloneMaterials = false,\r\n options?: { doNotInstantiate?: boolean | ((node: Node) => boolean); predicate?: (entity: any) => boolean }\r\n ): InstantiatedEntries {\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n const conversionMap: { [key: number]: number } = {};\r\n const storeMap: { [key: number]: any } = {};\r\n const result = new InstantiatedEntries();\r\n const alreadySwappedSkeletons: Skeleton[] = [];\r\n const alreadySwappedMaterials: Material[] = [];\r\n\r\n const localOptions = {\r\n doNotInstantiate: true,\r\n ...options,\r\n };\r\n\r\n const onClone = (source: Node, clone: Node) => {\r\n conversionMap[source.uniqueId] = clone.uniqueId;\r\n storeMap[clone.uniqueId] = clone;\r\n\r\n if (nameFunction) {\r\n clone.name = nameFunction(source.name);\r\n }\r\n\r\n if (clone instanceof Mesh) {\r\n const clonedMesh = clone as Mesh;\r\n\r\n if (clonedMesh.morphTargetManager) {\r\n const oldMorphTargetManager = (source as Mesh).morphTargetManager!;\r\n clonedMesh.morphTargetManager = oldMorphTargetManager.clone();\r\n\r\n for (let index = 0; index < oldMorphTargetManager.numTargets; index++) {\r\n const oldTarget = oldMorphTargetManager.getTarget(index);\r\n const newTarget = clonedMesh.morphTargetManager.getTarget(index);\r\n\r\n conversionMap[oldTarget.uniqueId] = newTarget.uniqueId;\r\n storeMap[newTarget.uniqueId] = newTarget;\r\n }\r\n }\r\n }\r\n };\r\n\r\n const nodesToSort: Node[] = [];\r\n const idsOnSortList = new Set<number>();\r\n\r\n for (const transformNode of this.transformNodes) {\r\n if (transformNode.parent === null) {\r\n this._addNodeAndDescendantsToList(nodesToSort, idsOnSortList, transformNode, localOptions.predicate);\r\n }\r\n }\r\n\r\n for (const mesh of this.meshes) {\r\n if (mesh.parent === null) {\r\n this._addNodeAndDescendantsToList(nodesToSort, idsOnSortList, mesh, localOptions.predicate);\r\n }\r\n }\r\n\r\n // Topologically sort nodes by parenting/instancing relationships so that all resources are in place\r\n // when a given node is instantiated.\r\n const sortedNodes = this._topologicalSort(nodesToSort);\r\n\r\n const onNewCreated = (source: Node, clone: Node) => {\r\n onClone(source, clone);\r\n\r\n if (source.parent) {\r\n const replicatedParentId = conversionMap[source.parent.uniqueId];\r\n const replicatedParent = storeMap[replicatedParentId];\r\n\r\n if (replicatedParent) {\r\n clone.parent = replicatedParent;\r\n } else {\r\n clone.parent = source.parent;\r\n }\r\n }\r\n\r\n if ((clone as any).position && (source as any).position) {\r\n (clone as any).position.copyFrom((source as any).position);\r\n }\r\n if ((clone as any).rotationQuaternion && (source as any).rotationQuaternion) {\r\n (clone as any).rotationQuaternion.copyFrom((source as any).rotationQuaternion);\r\n }\r\n if ((clone as any).rotation && (source as any).rotation) {\r\n (clone as any).rotation.copyFrom((source as any).rotation);\r\n }\r\n if ((clone as any).scaling && (source as any).scaling) {\r\n (clone as any).scaling.copyFrom((source as any).scaling);\r\n }\r\n\r\n if ((clone as any).material) {\r\n const mesh = clone as AbstractMesh;\r\n\r\n if (mesh.material) {\r\n if (cloneMaterials) {\r\n const sourceMaterial = (source as AbstractMesh).material!;\r\n\r\n if (alreadySwappedMaterials.indexOf(sourceMaterial) === -1) {\r\n let swap = sourceMaterial.clone(nameFunction ? nameFunction(sourceMaterial.name) : \"Clone of \" + sourceMaterial.name)!;\r\n alreadySwappedMaterials.push(sourceMaterial);\r\n conversionMap[sourceMaterial.uniqueId] = swap.uniqueId;\r\n storeMap[swap.uniqueId] = swap;\r\n\r\n if (sourceMaterial.getClassName() === \"MultiMaterial\") {\r\n const multi = sourceMaterial as MultiMaterial;\r\n\r\n for (const material of multi.subMaterials) {\r\n if (!material) {\r\n continue;\r\n }\r\n swap = material.clone(nameFunction ? nameFunction(material.name) : \"Clone of \" + material.name)!;\r\n alreadySwappedMaterials.push(material);\r\n conversionMap[material.uniqueId] = swap.uniqueId;\r\n storeMap[swap.uniqueId] = swap;\r\n }\r\n\r\n multi.subMaterials = multi.subMaterials.map((m) => m && storeMap[conversionMap[m.uniqueId]]);\r\n }\r\n }\r\n\r\n if (mesh.getClassName() !== \"InstancedMesh\") {\r\n mesh.material = storeMap[conversionMap[sourceMaterial.uniqueId]];\r\n }\r\n } else {\r\n if (mesh.material.getClassName() === \"MultiMaterial\") {\r\n if (this.scene.multiMaterials.indexOf(mesh.material as MultiMaterial) === -1) {\r\n this.scene.addMultiMaterial(mesh.material as MultiMaterial);\r\n }\r\n } else {\r\n if (this.scene.materials.indexOf(mesh.material) === -1) {\r\n this.scene.addMaterial(mesh.material);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (clone.parent === null) {\r\n result.rootNodes.push(clone);\r\n }\r\n };\r\n\r\n sortedNodes.forEach((node) => {\r\n if (node.getClassName() === \"InstancedMesh\") {\r\n const instancedNode = node as InstancedMesh;\r\n const sourceMesh = instancedNode.sourceMesh;\r\n const replicatedSourceId = conversionMap[sourceMesh.uniqueId];\r\n const replicatedSource = typeof replicatedSourceId === \"number\" ? storeMap[replicatedSourceId] : sourceMesh;\r\n const replicatedInstancedNode = replicatedSource.createInstance(instancedNode.name);\r\n onNewCreated(instancedNode, replicatedInstancedNode);\r\n } else {\r\n // Mesh or TransformNode\r\n let canInstance = true;\r\n if (node.getClassName() === \"TransformNode\" || node.getClassName() === \"Node\" || (node as Mesh).skeleton || (node as Mesh).getTotalVertices() === 0) {\r\n // Transform nodes, skinned meshes, and meshes with no vertices can never be instanced!\r\n canInstance = false;\r\n } else if (localOptions.doNotInstantiate) {\r\n if (typeof localOptions.doNotInstantiate === \"function\") {\r\n canInstance = !localOptions.doNotInstantiate(node);\r\n } else {\r\n canInstance = !localOptions.doNotInstantiate;\r\n }\r\n }\r\n const replicatedNode = canInstance ? (node as Mesh).createInstance(`instance of ${node.name}`) : node.clone(`Clone of ${node.name}`, null, true);\r\n if (!replicatedNode) {\r\n throw new Error(`Could not clone or instantiate node on Asset Container ${node.name}`);\r\n }\r\n onNewCreated(node, replicatedNode);\r\n }\r\n });\r\n\r\n this.skeletons.forEach((s) => {\r\n if (localOptions.predicate && !localOptions.predicate(s)) {\r\n return;\r\n }\r\n\r\n const clone = s.clone(nameFunction ? nameFunction(s.name) : \"Clone of \" + s.name);\r\n\r\n for (const m of this.meshes) {\r\n if (m.skeleton === s && !m.isAnInstance) {\r\n const copy = storeMap[conversionMap[m.uniqueId]] as Mesh;\r\n if (!copy || copy.isAnInstance) {\r\n continue;\r\n }\r\n copy.skeleton = clone;\r\n\r\n if (alreadySwappedSkeletons.indexOf(clone) !== -1) {\r\n continue;\r\n }\r\n\r\n alreadySwappedSkeletons.push(clone);\r\n\r\n // Check if bones are mesh linked\r\n for (const bone of clone.bones) {\r\n if (bone._linkedTransformNode) {\r\n bone._linkedTransformNode = storeMap[conversionMap[bone._linkedTransformNode.uniqueId]];\r\n }\r\n }\r\n }\r\n }\r\n\r\n result.skeletons.push(clone);\r\n });\r\n\r\n this.animationGroups.forEach((o) => {\r\n if (localOptions.predicate && !localOptions.predicate(o)) {\r\n return;\r\n }\r\n\r\n const clone = o.clone(nameFunction ? nameFunction(o.name) : \"Clone of \" + o.name, (oldTarget) => {\r\n const newTarget = storeMap[conversionMap[oldTarget.uniqueId]];\r\n\r\n return newTarget || oldTarget;\r\n });\r\n\r\n result.animationGroups.push(clone);\r\n });\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Adds all the assets from the container to the scene.\r\n */\r\n public addAllToScene() {\r\n if (this._wasAddedToScene) {\r\n return;\r\n }\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n\r\n this._wasAddedToScene = true;\r\n\r\n this.addToScene(null);\r\n\r\n if (this.environmentTexture) {\r\n this.scene.environmentTexture = this.environmentTexture;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.addFromContainer(this);\r\n }\r\n\r\n this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n\r\n /**\r\n * Adds assets from the container to the scene.\r\n * @param predicate defines a predicate used to select which entity will be added (can be null)\r\n */\r\n public addToScene(predicate: Nullable<(entity: any) => boolean> = null) {\r\n this.cameras.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addCamera(o);\r\n });\r\n this.lights.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addLight(o);\r\n });\r\n this.meshes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMesh(o);\r\n });\r\n this.skeletons.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addSkeleton(o);\r\n });\r\n this.animations.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addAnimation(o);\r\n });\r\n this.animationGroups.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addAnimationGroup(o);\r\n });\r\n this.multiMaterials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMultiMaterial(o);\r\n });\r\n this.materials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMaterial(o);\r\n });\r\n this.morphTargetManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMorphTargetManager(o);\r\n });\r\n this.geometries.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addGeometry(o);\r\n });\r\n this.transformNodes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addTransformNode(o);\r\n });\r\n this.actionManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addActionManager(o);\r\n });\r\n this.textures.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addTexture(o);\r\n });\r\n this.reflectionProbes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addReflectionProbe(o);\r\n });\r\n }\r\n\r\n /**\r\n * Removes all the assets in the container from the scene\r\n */\r\n public removeAllFromScene() {\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n\r\n this._wasAddedToScene = false;\r\n\r\n this.removeFromScene(null);\r\n\r\n if (this.environmentTexture === this.scene.environmentTexture) {\r\n this.scene.environmentTexture = null;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.removeFromContainer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Removes assets in the container from the scene\r\n * @param predicate defines a predicate used to select which entity will be added (can be null)\r\n */\r\n public removeFromScene(predicate: Nullable<(entity: any) => boolean> = null) {\r\n this.cameras.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeCamera(o);\r\n });\r\n this.lights.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeLight(o);\r\n });\r\n this.meshes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMesh(o);\r\n });\r\n this.skeletons.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeSkeleton(o);\r\n });\r\n this.animations.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeAnimation(o);\r\n });\r\n this.animationGroups.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeAnimationGroup(o);\r\n });\r\n this.multiMaterials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMultiMaterial(o);\r\n });\r\n this.materials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMaterial(o);\r\n });\r\n this.morphTargetManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMorphTargetManager(o);\r\n });\r\n this.geometries.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeGeometry(o);\r\n });\r\n this.transformNodes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeTransformNode(o);\r\n });\r\n this.actionManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeActionManager(o);\r\n });\r\n this.textures.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeTexture(o);\r\n });\r\n this.reflectionProbes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeReflectionProbe(o);\r\n });\r\n }\r\n\r\n /**\r\n * Disposes all the assets in the container\r\n */\r\n public dispose() {\r\n this.cameras.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.cameras.length = 0;\r\n\r\n this.lights.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.lights.length = 0;\r\n\r\n this.meshes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.meshes.length = 0;\r\n\r\n this.skeletons.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.skeletons.length = 0;\r\n\r\n this.animationGroups.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.animationGroups.length = 0;\r\n\r\n this.multiMaterials.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.multiMaterials.length = 0;\r\n\r\n this.materials.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.materials.length = 0;\r\n\r\n this.geometries.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.geometries.length = 0;\r\n\r\n this.transformNodes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.transformNodes.length = 0;\r\n\r\n this.actionManagers.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.actionManagers.length = 0;\r\n\r\n this.textures.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.textures.length = 0;\r\n\r\n this.reflectionProbes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.reflectionProbes.length = 0;\r\n\r\n this.morphTargetManagers.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.morphTargetManagers.length = 0;\r\n\r\n if (this.environmentTexture) {\r\n this.environmentTexture.dispose();\r\n this.environmentTexture = null;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.removeFromContainer(this, true);\r\n }\r\n\r\n if (this._onContextRestoredObserver) {\r\n this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n }\r\n\r\n private _moveAssets<T>(sourceAssets: T[], targetAssets: T[], keepAssets: T[]): void {\r\n if (!sourceAssets || !targetAssets) {\r\n return;\r\n }\r\n\r\n for (const asset of sourceAssets) {\r\n let move = true;\r\n if (keepAssets) {\r\n for (const keepAsset of keepAssets) {\r\n if (asset === keepAsset) {\r\n move = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (move) {\r\n targetAssets.push(asset);\r\n (asset as any)._parentContainer = this;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Removes all the assets contained in the scene and adds them to the container.\r\n * @param keepAssets Set of assets to keep in the scene. (default: empty)\r\n */\r\n public moveAllFromScene(keepAssets?: KeepAssets): void {\r\n this._wasAddedToScene = false;\r\n\r\n if (keepAssets === undefined) {\r\n keepAssets = new KeepAssets();\r\n }\r\n\r\n for (const key in this) {\r\n if (Object.prototype.hasOwnProperty.call(this, key)) {\r\n (<any>this)[key] = (<any>this)[key] || (key === \"_environmentTexture\" ? null : []);\r\n this._moveAssets((<any>this.scene)[key], (<any>this)[key], (<any>keepAssets)[key]);\r\n }\r\n }\r\n\r\n this.environmentTexture = this.scene.environmentTexture;\r\n\r\n this.removeAllFromScene();\r\n }\r\n\r\n /**\r\n * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.\r\n * @returns the root mesh\r\n */\r\n public createRootMesh() {\r\n const rootMesh = new Mesh(\"assetContainerRootMesh\", this.scene);\r\n this.meshes.forEach((m) => {\r\n if (!m.parent) {\r\n rootMesh.addChild(m);\r\n }\r\n });\r\n this.meshes.unshift(rootMesh);\r\n return rootMesh;\r\n }\r\n\r\n /**\r\n * Merge animations (direct and animation groups) from this asset container into a scene\r\n * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)\r\n * @param animatables set of animatables to retarget to a node from the scene\r\n * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)\r\n * @returns an array of the new AnimationGroup added to the scene (empty array if none)\r\n */\r\n public mergeAnimationsTo(\r\n scene: Nullable<Scene> = EngineStore.LastCreatedScene,\r\n animatables: Animatable[],\r\n targetConverter: Nullable<(target: any) => Nullable<Node>> = null\r\n ): AnimationGroup[] {\r\n if (!scene) {\r\n Logger.Error(\"No scene available to merge animations to\");\r\n return [];\r\n }\r\n\r\n const _targetConverter = targetConverter\r\n ? targetConverter\r\n : (target: any) => {\r\n let node = null;\r\n\r\n const targetProperty = target.animations.length ? target.animations[0].targetProperty : \"\";\r\n /*\r\n BabylonJS adds special naming to targets that are children of nodes.\r\n This name attempts to remove that special naming to get the parent nodes name in case the target\r\n can't be found in the node tree\r\n\r\n Ex: Torso_primitive0 likely points to a Mesh primitive. We take away primitive0 and are left with \"Torso\" which is the name\r\n of the primitive's parent.\r\n */\r\n const name = target.name.split(\".\").join(\"\").split(\"_primitive\")[0];\r\n\r\n switch (targetProperty) {\r\n case \"position\":\r\n case \"rotationQuaternion\":\r\n node = scene.getTransformNodeByName(target.name) || scene.getTransformNodeByName(name);\r\n break;\r\n case \"influence\":\r\n node = scene.getMorphTargetByName(target.name) || scene.getMorphTargetByName(name);\r\n break;\r\n default:\r\n node = scene.getNodeByName(target.name) || scene.getNodeByName(name);\r\n }\r\n\r\n return node;\r\n };\r\n\r\n // Copy new node animations\r\n const nodesInAC = this.getNodes();\r\n nodesInAC.forEach((nodeInAC) => {\r\n const nodeInScene = _targetConverter(nodeInAC);\r\n if (nodeInScene !== null) {\r\n // Remove old animations with same target property as a new one\r\n for (const animationInAC of nodeInAC.animations) {\r\n // Doing treatment on an array for safety measure\r\n const animationsWithSameProperty = nodeInScene.animations.filter((animationInScene) => {\r\n return animationInScene.targetProperty === animationInAC.targetProperty;\r\n });\r\n for (const animationWithSameProperty of animationsWithSameProperty) {\r\n const index = nodeInScene.animations.indexOf(animationWithSameProperty, 0);\r\n if (index > -1) {\r\n nodeInScene.animations.splice(index, 1);\r\n }\r\n }\r\n }\r\n\r\n // Append new animations\r\n nodeInScene.animations = nodeInScene.animations.concat(nodeInAC.animations);\r\n }\r\n });\r\n\r\n const newAnimationGroups = new Array<AnimationGroup>();\r\n\r\n // Copy new animation groups\r\n this.animationGroups.slice().forEach((animationGroupInAC) => {\r\n // Clone the animation group and all its animatables\r\n newAnimationGroups.push(animationGroupInAC.clone(animationGroupInAC.name, _targetConverter));\r\n\r\n // Remove animatables related to the asset container\r\n animationGroupInAC.animatables.forEach((animatable) => {\r\n animatable.stop();\r\n });\r\n });\r\n\r\n // Retarget animatables\r\n animatables.forEach((animatable) => {\r\n const target = _targetConverter(animatable.target);\r\n\r\n if (target) {\r\n // Clone the animatable and retarget it\r\n scene.beginAnimation(\r\n target,\r\n animatable.fromFrame,\r\n animatable.toFrame,\r\n animatable.loopAnimation,\r\n animatable.speedRatio,\r\n animatable.onAnimationEnd ? animatable.onAnimationEnd : undefined,\r\n undefined,\r\n true,\r\n undefined,\r\n animatable.onAnimationLoop ? animatable.onAnimationLoop : undefined\r\n );\r\n\r\n // Stop animation for the target in the asset container\r\n scene.stopAnimation(animatable.target);\r\n }\r\n });\r\n\r\n return newAnimationGroups;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"assetContainer.js","sourceRoot":"","sources":["../../../lts/core/generated/assetContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAA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EACpB,UAAU,CAAC,OAAO,EAClB,UAAU,CAAC,aAAa,EACxB,UAAU,CAAC,UAAU,EACrB,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,EACjE,SAAS,EACT,IAAI,EACJ,SAAS,EACT,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CACtE,CAAC;gBAEF,uDAAuD;gBACvD,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aAC1C;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ","sourcesContent":["import { AbstractScene } from \"./abstractScene\";\r\nimport type { Scene } from \"./scene\";\r\nimport { Mesh } from \"./Meshes/mesh\";\r\nimport { TransformNode } from \"./Meshes/transformNode\";\r\nimport type { Skeleton } from \"./Bones/skeleton\";\r\nimport type { AnimationGroup } from \"./Animations/animationGroup\";\r\nimport type { Animatable } from \"./Animations/animatable\";\r\nimport type { AbstractMesh } from \"./Meshes/abstractMesh\";\r\nimport type { MultiMaterial } from \"./Materials/multiMaterial\";\r\nimport type { Material } from \"./Materials/material\";\r\nimport { Logger } from \"./Misc/logger\";\r\nimport { EngineStore } from \"./Engines/engineStore\";\r\nimport type { Nullable } from \"./types\";\r\nimport type { Node } from \"./node\";\r\nimport type { Observer } from \"./Misc/observable\";\r\nimport type { ThinEngine } from \"./Engines/thinEngine\";\r\nimport { InstancedMesh } from \"./Meshes/instancedMesh\";\r\nimport { Light } from \"./Lights/light\";\r\nimport { Camera } from \"./Cameras/camera\";\r\nimport { Tools } from \"./Misc/tools\";\r\n\r\n/**\r\n * Set of assets to keep when moving a scene into an asset container.\r\n */\r\nexport class KeepAssets extends AbstractScene {}\r\n\r\n/**\r\n * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function\r\n */\r\nexport class InstantiatedEntries {\r\n /**\r\n * List of new root nodes (eg. nodes with no parent)\r\n */\r\n public rootNodes: Node[] = [];\r\n\r\n /**\r\n * List of new skeletons\r\n */\r\n public skeletons: Skeleton[] = [];\r\n\r\n /**\r\n * List of new animation groups\r\n */\r\n public animationGroups: AnimationGroup[] = [];\r\n\r\n /**\r\n * Disposes the instantiated entries from the scene\r\n */\r\n public dispose() {\r\n this.rootNodes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.rootNodes.length = 0;\r\n\r\n this.skeletons.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.skeletons.length = 0;\r\n\r\n this.animationGroups.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.animationGroups.length = 0;\r\n }\r\n}\r\n\r\n/**\r\n * Container with a set of assets that can be added or removed from a scene.\r\n */\r\nexport class AssetContainer extends AbstractScene {\r\n private _wasAddedToScene = false;\r\n private _onContextRestoredObserver: Nullable<Observer<ThinEngine>>;\r\n\r\n /**\r\n * The scene the AssetContainer belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Instantiates an AssetContainer.\r\n * @param scene The scene the AssetContainer belongs to.\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n super();\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this.scene = scene;\r\n this[\"sounds\"] = [];\r\n this[\"effectLayers\"] = [];\r\n this[\"layers\"] = [];\r\n this[\"lensFlareSystems\"] = [];\r\n this[\"proceduralTextures\"] = [];\r\n this[\"reflectionProbes\"] = [];\r\n\r\n scene.onDisposeObservable.add(() => {\r\n if (!this._wasAddedToScene) {\r\n this.dispose();\r\n }\r\n });\r\n\r\n this._onContextRestoredObserver = scene.getEngine().onContextRestoredObservable.add(() => {\r\n for (const geometry of this.geometries) {\r\n geometry._rebuild();\r\n }\r\n\r\n for (const mesh of this.meshes) {\r\n mesh._rebuild();\r\n }\r\n\r\n for (const system of this.particleSystems) {\r\n system.rebuild();\r\n }\r\n\r\n for (const texture of this.textures) {\r\n texture._rebuild();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Given a list of nodes, return a topological sorting of them.\r\n * @param nodes\r\n */\r\n private _topologicalSort(nodes: Node[]): Node[] {\r\n const nodesUidMap = new Map<number, Node>();\r\n\r\n for (const node of nodes) {\r\n nodesUidMap.set(node.uniqueId, node);\r\n }\r\n\r\n const dependencyGraph = {\r\n dependsOn: new Map<number, Set<number>>(), // given a node id, what are the ids of the nodes it depends on\r\n dependedBy: new Map<number, Set<number>>(), // given a node id, what are the ids of the nodes that depend on it\r\n };\r\n\r\n // Build the dependency graph given the list of nodes\r\n\r\n // First pass: Initialize the empty dependency graph\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n dependencyGraph.dependsOn.set(nodeId, new Set<number>());\r\n dependencyGraph.dependedBy.set(nodeId, new Set<number>());\r\n }\r\n\r\n // Second pass: Populate the dependency graph. We assume that we\r\n // don't need to check for cycles here, as the scene graph cannot\r\n // contain cycles. Our graph also already contains all transitive\r\n // dependencies because getDescendants returns the transitive\r\n // dependencies by default.\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n const dependsOn = dependencyGraph.dependsOn.get(nodeId)!;\r\n if (node instanceof InstancedMesh) {\r\n const masterMesh = node.sourceMesh;\r\n if (nodesUidMap.has(masterMesh.uniqueId)) {\r\n dependsOn.add(masterMesh.uniqueId);\r\n dependencyGraph.dependedBy.get(masterMesh.uniqueId)!.add(nodeId);\r\n }\r\n }\r\n const dependedBy = dependencyGraph.dependedBy.get(nodeId)!;\r\n\r\n for (const child of node.getDescendants()) {\r\n const childId = child.uniqueId;\r\n if (nodesUidMap.has(childId)) {\r\n dependedBy.add(childId);\r\n\r\n const childDependsOn = dependencyGraph.dependsOn.get(childId)!;\r\n childDependsOn.add(nodeId);\r\n }\r\n }\r\n }\r\n\r\n // Third pass: Topological sort\r\n const sortedNodes: Node[] = [];\r\n\r\n // First: Find all nodes that have no dependencies\r\n const leaves: Node[] = [];\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n if (dependencyGraph.dependsOn.get(nodeId)!.size === 0) {\r\n leaves.push(node);\r\n nodesUidMap.delete(nodeId);\r\n }\r\n }\r\n\r\n const visitList = leaves;\r\n while (visitList.length > 0) {\r\n const nodeToVisit = visitList.shift()!;\r\n\r\n sortedNodes.push(nodeToVisit);\r\n\r\n // Remove the node from the dependency graph\r\n // When a node is visited, we know that dependsOn is empty.\r\n // So we only need to remove the node from dependedBy.\r\n const dependedByVisitedNode = dependencyGraph.dependedBy.get(nodeToVisit.uniqueId)!;\r\n // Array.from(x.values()) is to make the TS compiler happy\r\n for (const dependedByVisitedNodeId of Array.from(dependedByVisitedNode.values())) {\r\n const dependsOnDependedByVisitedNode = dependencyGraph.dependsOn.get(dependedByVisitedNodeId)!;\r\n dependsOnDependedByVisitedNode.delete(nodeToVisit.uniqueId);\r\n\r\n if (dependsOnDependedByVisitedNode.size === 0 && nodesUidMap.get(dependedByVisitedNodeId)) {\r\n visitList.push(nodesUidMap.get(dependedByVisitedNodeId)!);\r\n nodesUidMap.delete(dependedByVisitedNodeId);\r\n }\r\n }\r\n }\r\n\r\n if (nodesUidMap.size > 0) {\r\n console.error(\"SceneSerializer._topologicalSort: There were unvisited nodes:\");\r\n nodesUidMap.forEach((node) => console.error(node.name));\r\n }\r\n\r\n return sortedNodes;\r\n }\r\n\r\n private _addNodeAndDescendantsToList(list: Node[], addedIds: Set<number>, rootNode?: Node, predicate?: (entity: any) => boolean) {\r\n if (!rootNode || (predicate && !predicate(rootNode)) || addedIds.has(rootNode.uniqueId)) {\r\n return;\r\n }\r\n\r\n list.push(rootNode);\r\n addedIds.add(rootNode.uniqueId);\r\n\r\n for (const child of rootNode.getDescendants(true)) {\r\n this._addNodeAndDescendantsToList(list, addedIds, child, predicate);\r\n }\r\n }\r\n\r\n /**\r\n * Check if a specific node is contained in this asset container.\r\n * @param node\r\n */\r\n private _isNodeInContainer(node: Node) {\r\n if (node instanceof Mesh && this.meshes.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof TransformNode && this.transformNodes.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof Light && this.lights.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof Camera && this.cameras.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * For every node in the scene, check if its parent node is also in the scene.\r\n */\r\n private _isValidHierarchy() {\r\n for (const node of this.meshes) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.transformNodes) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.lights) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.cameras) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Instantiate or clone all meshes and add the new ones to the scene.\r\n * Skeletons and animation groups will all be cloned\r\n * @param nameFunction defines an optional function used to get new names for clones\r\n * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)\r\n * @param options defines an optional list of options to control how to instantiate / clone models\r\n * @param options.doNotInstantiate defines if the model must be instantiated or just cloned\r\n * @param options.predicate defines a predicate used to filter whih mesh to instantiate/clone\r\n * @returns a list of rootNodes, skeletons and animation groups that were duplicated\r\n */\r\n public instantiateModelsToScene(\r\n nameFunction?: (sourceName: string) => string,\r\n cloneMaterials = false,\r\n options?: { doNotInstantiate?: boolean | ((node: Node) => boolean); predicate?: (entity: any) => boolean }\r\n ): InstantiatedEntries {\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n const conversionMap: { [key: number]: number } = {};\r\n const storeMap: { [key: number]: any } = {};\r\n const result = new InstantiatedEntries();\r\n const alreadySwappedSkeletons: Skeleton[] = [];\r\n const alreadySwappedMaterials: Material[] = [];\r\n\r\n const localOptions = {\r\n doNotInstantiate: true,\r\n ...options,\r\n };\r\n\r\n const onClone = (source: Node, clone: Node) => {\r\n conversionMap[source.uniqueId] = clone.uniqueId;\r\n storeMap[clone.uniqueId] = clone;\r\n\r\n if (nameFunction) {\r\n clone.name = nameFunction(source.name);\r\n }\r\n\r\n if (clone instanceof Mesh) {\r\n const clonedMesh = clone as Mesh;\r\n\r\n if (clonedMesh.morphTargetManager) {\r\n const oldMorphTargetManager = (source as Mesh).morphTargetManager!;\r\n clonedMesh.morphTargetManager = oldMorphTargetManager.clone();\r\n\r\n for (let index = 0; index < oldMorphTargetManager.numTargets; index++) {\r\n const oldTarget = oldMorphTargetManager.getTarget(index);\r\n const newTarget = clonedMesh.morphTargetManager.getTarget(index);\r\n\r\n conversionMap[oldTarget.uniqueId] = newTarget.uniqueId;\r\n storeMap[newTarget.uniqueId] = newTarget;\r\n }\r\n }\r\n }\r\n };\r\n\r\n const nodesToSort: Node[] = [];\r\n const idsOnSortList = new Set<number>();\r\n\r\n for (const transformNode of this.transformNodes) {\r\n if (transformNode.parent === null) {\r\n this._addNodeAndDescendantsToList(nodesToSort, idsOnSortList, transformNode, localOptions.predicate);\r\n }\r\n }\r\n\r\n for (const mesh of this.meshes) {\r\n if (mesh.parent === null) {\r\n this._addNodeAndDescendantsToList(nodesToSort, idsOnSortList, mesh, localOptions.predicate);\r\n }\r\n }\r\n\r\n // Topologically sort nodes by parenting/instancing relationships so that all resources are in place\r\n // when a given node is instantiated.\r\n const sortedNodes = this._topologicalSort(nodesToSort);\r\n\r\n const onNewCreated = (source: Node, clone: Node) => {\r\n onClone(source, clone);\r\n\r\n if (source.parent) {\r\n const replicatedParentId = conversionMap[source.parent.uniqueId];\r\n const replicatedParent = storeMap[replicatedParentId];\r\n\r\n if (replicatedParent) {\r\n clone.parent = replicatedParent;\r\n } else {\r\n clone.parent = source.parent;\r\n }\r\n }\r\n\r\n if ((clone as any).position && (source as any).position) {\r\n (clone as any).position.copyFrom((source as any).position);\r\n }\r\n if ((clone as any).rotationQuaternion && (source as any).rotationQuaternion) {\r\n (clone as any).rotationQuaternion.copyFrom((source as any).rotationQuaternion);\r\n }\r\n if ((clone as any).rotation && (source as any).rotation) {\r\n (clone as any).rotation.copyFrom((source as any).rotation);\r\n }\r\n if ((clone as any).scaling && (source as any).scaling) {\r\n (clone as any).scaling.copyFrom((source as any).scaling);\r\n }\r\n\r\n if ((clone as any).material) {\r\n const mesh = clone as AbstractMesh;\r\n\r\n if (mesh.material) {\r\n if (cloneMaterials) {\r\n const sourceMaterial = (source as AbstractMesh).material!;\r\n\r\n if (alreadySwappedMaterials.indexOf(sourceMaterial) === -1) {\r\n let swap = sourceMaterial.clone(nameFunction ? nameFunction(sourceMaterial.name) : \"Clone of \" + sourceMaterial.name)!;\r\n alreadySwappedMaterials.push(sourceMaterial);\r\n conversionMap[sourceMaterial.uniqueId] = swap.uniqueId;\r\n storeMap[swap.uniqueId] = swap;\r\n\r\n if (sourceMaterial.getClassName() === \"MultiMaterial\") {\r\n const multi = sourceMaterial as MultiMaterial;\r\n\r\n for (const material of multi.subMaterials) {\r\n if (!material) {\r\n continue;\r\n }\r\n swap = material.clone(nameFunction ? nameFunction(material.name) : \"Clone of \" + material.name)!;\r\n alreadySwappedMaterials.push(material);\r\n conversionMap[material.uniqueId] = swap.uniqueId;\r\n storeMap[swap.uniqueId] = swap;\r\n }\r\n\r\n multi.subMaterials = multi.subMaterials.map((m) => m && storeMap[conversionMap[m.uniqueId]]);\r\n }\r\n }\r\n\r\n if (mesh.getClassName() !== \"InstancedMesh\") {\r\n mesh.material = storeMap[conversionMap[sourceMaterial.uniqueId]];\r\n }\r\n } else {\r\n if (mesh.material.getClassName() === \"MultiMaterial\") {\r\n if (this.scene.multiMaterials.indexOf(mesh.material as MultiMaterial) === -1) {\r\n this.scene.addMultiMaterial(mesh.material as MultiMaterial);\r\n }\r\n } else {\r\n if (this.scene.materials.indexOf(mesh.material) === -1) {\r\n this.scene.addMaterial(mesh.material);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (clone.parent === null) {\r\n result.rootNodes.push(clone);\r\n }\r\n };\r\n\r\n sortedNodes.forEach((node) => {\r\n if (node.getClassName() === \"InstancedMesh\") {\r\n const instancedNode = node as InstancedMesh;\r\n const sourceMesh = instancedNode.sourceMesh;\r\n const replicatedSourceId = conversionMap[sourceMesh.uniqueId];\r\n const replicatedSource = typeof replicatedSourceId === \"number\" ? storeMap[replicatedSourceId] : sourceMesh;\r\n const replicatedInstancedNode = replicatedSource.createInstance(instancedNode.name);\r\n onNewCreated(instancedNode, replicatedInstancedNode);\r\n } else {\r\n // Mesh or TransformNode\r\n let canInstance = true;\r\n if (\r\n node.getClassName() === \"TransformNode\" ||\r\n node.getClassName() === \"Node\" ||\r\n (node as Mesh).skeleton ||\r\n !(node as any).getTotalVertices ||\r\n (node as Mesh).getTotalVertices() === 0\r\n ) {\r\n // Transform nodes, skinned meshes, and meshes with no vertices can never be instanced!\r\n canInstance = false;\r\n } else if (localOptions.doNotInstantiate) {\r\n if (typeof localOptions.doNotInstantiate === \"function\") {\r\n canInstance = !localOptions.doNotInstantiate(node);\r\n } else {\r\n canInstance = !localOptions.doNotInstantiate;\r\n }\r\n }\r\n const replicatedNode = canInstance ? (node as Mesh).createInstance(`instance of ${node.name}`) : node.clone(`Clone of ${node.name}`, null, true);\r\n if (!replicatedNode) {\r\n throw new Error(`Could not clone or instantiate node on Asset Container ${node.name}`);\r\n }\r\n onNewCreated(node, replicatedNode);\r\n }\r\n });\r\n\r\n this.skeletons.forEach((s) => {\r\n if (localOptions.predicate && !localOptions.predicate(s)) {\r\n return;\r\n }\r\n\r\n const clone = s.clone(nameFunction ? nameFunction(s.name) : \"Clone of \" + s.name);\r\n\r\n for (const m of this.meshes) {\r\n if (m.skeleton === s && !m.isAnInstance) {\r\n const copy = storeMap[conversionMap[m.uniqueId]] as Mesh;\r\n if (!copy || copy.isAnInstance) {\r\n continue;\r\n }\r\n copy.skeleton = clone;\r\n\r\n if (alreadySwappedSkeletons.indexOf(clone) !== -1) {\r\n continue;\r\n }\r\n\r\n alreadySwappedSkeletons.push(clone);\r\n\r\n // Check if bones are mesh linked\r\n for (const bone of clone.bones) {\r\n if (bone._linkedTransformNode) {\r\n bone._linkedTransformNode = storeMap[conversionMap[bone._linkedTransformNode.uniqueId]];\r\n }\r\n }\r\n }\r\n }\r\n\r\n result.skeletons.push(clone);\r\n });\r\n\r\n this.animationGroups.forEach((o) => {\r\n if (localOptions.predicate && !localOptions.predicate(o)) {\r\n return;\r\n }\r\n\r\n const clone = o.clone(nameFunction ? nameFunction(o.name) : \"Clone of \" + o.name, (oldTarget) => {\r\n const newTarget = storeMap[conversionMap[oldTarget.uniqueId]];\r\n\r\n return newTarget || oldTarget;\r\n });\r\n\r\n result.animationGroups.push(clone);\r\n });\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Adds all the assets from the container to the scene.\r\n */\r\n public addAllToScene() {\r\n if (this._wasAddedToScene) {\r\n return;\r\n }\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n\r\n this._wasAddedToScene = true;\r\n\r\n this.addToScene(null);\r\n\r\n if (this.environmentTexture) {\r\n this.scene.environmentTexture = this.environmentTexture;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.addFromContainer(this);\r\n }\r\n\r\n this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n\r\n /**\r\n * Adds assets from the container to the scene.\r\n * @param predicate defines a predicate used to select which entity will be added (can be null)\r\n */\r\n public addToScene(predicate: Nullable<(entity: any) => boolean> = null) {\r\n this.cameras.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addCamera(o);\r\n });\r\n this.lights.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addLight(o);\r\n });\r\n this.meshes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMesh(o);\r\n });\r\n this.skeletons.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addSkeleton(o);\r\n });\r\n this.animations.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addAnimation(o);\r\n });\r\n this.animationGroups.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addAnimationGroup(o);\r\n });\r\n this.multiMaterials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMultiMaterial(o);\r\n });\r\n this.materials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMaterial(o);\r\n });\r\n this.morphTargetManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMorphTargetManager(o);\r\n });\r\n this.geometries.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addGeometry(o);\r\n });\r\n this.transformNodes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addTransformNode(o);\r\n });\r\n this.actionManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addActionManager(o);\r\n });\r\n this.textures.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addTexture(o);\r\n });\r\n this.reflectionProbes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addReflectionProbe(o);\r\n });\r\n }\r\n\r\n /**\r\n * Removes all the assets in the container from the scene\r\n */\r\n public removeAllFromScene() {\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n\r\n this._wasAddedToScene = false;\r\n\r\n this.removeFromScene(null);\r\n\r\n if (this.environmentTexture === this.scene.environmentTexture) {\r\n this.scene.environmentTexture = null;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.removeFromContainer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Removes assets in the container from the scene\r\n * @param predicate defines a predicate used to select which entity will be added (can be null)\r\n */\r\n public removeFromScene(predicate: Nullable<(entity: any) => boolean> = null) {\r\n this.cameras.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeCamera(o);\r\n });\r\n this.lights.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeLight(o);\r\n });\r\n this.meshes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMesh(o);\r\n });\r\n this.skeletons.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeSkeleton(o);\r\n });\r\n this.animations.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeAnimation(o);\r\n });\r\n this.animationGroups.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeAnimationGroup(o);\r\n });\r\n this.multiMaterials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMultiMaterial(o);\r\n });\r\n this.materials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMaterial(o);\r\n });\r\n this.morphTargetManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMorphTargetManager(o);\r\n });\r\n this.geometries.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeGeometry(o);\r\n });\r\n this.transformNodes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeTransformNode(o);\r\n });\r\n this.actionManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeActionManager(o);\r\n });\r\n this.textures.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeTexture(o);\r\n });\r\n this.reflectionProbes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeReflectionProbe(o);\r\n });\r\n }\r\n\r\n /**\r\n * Disposes all the assets in the container\r\n */\r\n public dispose() {\r\n this.cameras.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.cameras.length = 0;\r\n\r\n this.lights.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.lights.length = 0;\r\n\r\n this.meshes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.meshes.length = 0;\r\n\r\n this.skeletons.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.skeletons.length = 0;\r\n\r\n this.animationGroups.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.animationGroups.length = 0;\r\n\r\n this.multiMaterials.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.multiMaterials.length = 0;\r\n\r\n this.materials.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.materials.length = 0;\r\n\r\n this.geometries.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.geometries.length = 0;\r\n\r\n this.transformNodes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.transformNodes.length = 0;\r\n\r\n this.actionManagers.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.actionManagers.length = 0;\r\n\r\n this.textures.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.textures.length = 0;\r\n\r\n this.reflectionProbes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.reflectionProbes.length = 0;\r\n\r\n this.morphTargetManagers.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.morphTargetManagers.length = 0;\r\n\r\n if (this.environmentTexture) {\r\n this.environmentTexture.dispose();\r\n this.environmentTexture = null;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.removeFromContainer(this, true);\r\n }\r\n\r\n if (this._onContextRestoredObserver) {\r\n this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n }\r\n\r\n private _moveAssets<T>(sourceAssets: T[], targetAssets: T[], keepAssets: T[]): void {\r\n if (!sourceAssets || !targetAssets) {\r\n return;\r\n }\r\n\r\n for (const asset of sourceAssets) {\r\n let move = true;\r\n if (keepAssets) {\r\n for (const keepAsset of keepAssets) {\r\n if (asset === keepAsset) {\r\n move = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (move) {\r\n targetAssets.push(asset);\r\n (asset as any)._parentContainer = this;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Removes all the assets contained in the scene and adds them to the container.\r\n * @param keepAssets Set of assets to keep in the scene. (default: empty)\r\n */\r\n public moveAllFromScene(keepAssets?: KeepAssets): void {\r\n this._wasAddedToScene = false;\r\n\r\n if (keepAssets === undefined) {\r\n keepAssets = new KeepAssets();\r\n }\r\n\r\n for (const key in this) {\r\n if (Object.prototype.hasOwnProperty.call(this, key)) {\r\n (<any>this)[key] = (<any>this)[key] || (key === \"_environmentTexture\" ? null : []);\r\n this._moveAssets((<any>this.scene)[key], (<any>this)[key], (<any>keepAssets)[key]);\r\n }\r\n }\r\n\r\n this.environmentTexture = this.scene.environmentTexture;\r\n\r\n this.removeAllFromScene();\r\n }\r\n\r\n /**\r\n * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.\r\n * @returns the root mesh\r\n */\r\n public createRootMesh() {\r\n const rootMesh = new Mesh(\"assetContainerRootMesh\", this.scene);\r\n this.meshes.forEach((m) => {\r\n if (!m.parent) {\r\n rootMesh.addChild(m);\r\n }\r\n });\r\n this.meshes.unshift(rootMesh);\r\n return rootMesh;\r\n }\r\n\r\n /**\r\n * Merge animations (direct and animation groups) from this asset container into a scene\r\n * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)\r\n * @param animatables set of animatables to retarget to a node from the scene\r\n * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)\r\n * @returns an array of the new AnimationGroup added to the scene (empty array if none)\r\n */\r\n public mergeAnimationsTo(\r\n scene: Nullable<Scene> = EngineStore.LastCreatedScene,\r\n animatables: Animatable[],\r\n targetConverter: Nullable<(target: any) => Nullable<Node>> = null\r\n ): AnimationGroup[] {\r\n if (!scene) {\r\n Logger.Error(\"No scene available to merge animations to\");\r\n return [];\r\n }\r\n\r\n const _targetConverter = targetConverter\r\n ? targetConverter\r\n : (target: any) => {\r\n let node = null;\r\n\r\n const targetProperty = target.animations.length ? target.animations[0].targetProperty : \"\";\r\n /*\r\n BabylonJS adds special naming to targets that are children of nodes.\r\n This name attempts to remove that special naming to get the parent nodes name in case the target\r\n can't be found in the node tree\r\n\r\n Ex: Torso_primitive0 likely points to a Mesh primitive. We take away primitive0 and are left with \"Torso\" which is the name\r\n of the primitive's parent.\r\n */\r\n const name = target.name.split(\".\").join(\"\").split(\"_primitive\")[0];\r\n\r\n switch (targetProperty) {\r\n case \"position\":\r\n case \"rotationQuaternion\":\r\n node = scene.getTransformNodeByName(target.name) || scene.getTransformNodeByName(name);\r\n break;\r\n case \"influence\":\r\n node = scene.getMorphTargetByName(target.name) || scene.getMorphTargetByName(name);\r\n break;\r\n default:\r\n node = scene.getNodeByName(target.name) || scene.getNodeByName(name);\r\n }\r\n\r\n return node;\r\n };\r\n\r\n // Copy new node animations\r\n const nodesInAC = this.getNodes();\r\n nodesInAC.forEach((nodeInAC) => {\r\n const nodeInScene = _targetConverter(nodeInAC);\r\n if (nodeInScene !== null) {\r\n // Remove old animations with same target property as a new one\r\n for (const animationInAC of nodeInAC.animations) {\r\n // Doing treatment on an array for safety measure\r\n const animationsWithSameProperty = nodeInScene.animations.filter((animationInScene) => {\r\n return animationInScene.targetProperty === animationInAC.targetProperty;\r\n });\r\n for (const animationWithSameProperty of animationsWithSameProperty) {\r\n const index = nodeInScene.animations.indexOf(animationWithSameProperty, 0);\r\n if (index > -1) {\r\n nodeInScene.animations.splice(index, 1);\r\n }\r\n }\r\n }\r\n\r\n // Append new animations\r\n nodeInScene.animations = nodeInScene.animations.concat(nodeInAC.animations);\r\n }\r\n });\r\n\r\n const newAnimationGroups = new Array<AnimationGroup>();\r\n\r\n // Copy new animation groups\r\n this.animationGroups.slice().forEach((animationGroupInAC) => {\r\n // Clone the animation group and all its animatables\r\n newAnimationGroups.push(animationGroupInAC.clone(animationGroupInAC.name, _targetConverter));\r\n\r\n // Remove animatables related to the asset container\r\n animationGroupInAC.animatables.forEach((animatable) => {\r\n animatable.stop();\r\n });\r\n });\r\n\r\n // Retarget animatables\r\n animatables.forEach((animatable) => {\r\n const target = _targetConverter(animatable.target);\r\n\r\n if (target) {\r\n // Clone the animatable and retarget it\r\n scene.beginAnimation(\r\n target,\r\n animatable.fromFrame,\r\n animatable.toFrame,\r\n animatable.loopAnimation,\r\n animatable.speedRatio,\r\n animatable.onAnimationEnd ? animatable.onAnimationEnd : undefined,\r\n undefined,\r\n true,\r\n undefined,\r\n animatable.onAnimationLoop ? animatable.onAnimationLoop : undefined\r\n );\r\n\r\n // Stop animation for the target in the asset container\r\n scene.stopAnimation(animatable.target);\r\n }\r\n });\r\n\r\n return newAnimationGroups;\r\n }\r\n}\r\n"]}
|